local-operator-ui 0.56.4 → 0.57.0

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 (95) hide show
  1. package/out/main/index.js +341 -67
  2. package/out/renderer/assets/{_basePickBy-BLdIZThE.js → _basePickBy-KILczdpd.js} +1 -1
  3. package/out/renderer/assets/{_baseUniq-pSMOLACP.js → _baseUniq-DwSvqTuO.js} +1 -1
  4. package/out/renderer/assets/{agent-details-page-DNVnFKl6.js → agent-details-page-BA3aPU8m.js} +1 -1
  5. package/out/renderer/assets/{agent-hub-page-D6mwt016.js → agent-hub-page-Dzh1rDmn.js} +1 -1
  6. package/out/renderer/assets/{agents-page-BmvuuADf.js → agents-page-CUoi_2pk.js} +3 -3
  7. package/out/renderer/assets/{appearance-BAuF7bEx.js → appearance-CwnOp778.js} +1 -1
  8. package/out/renderer/assets/{approvalsOverlay-BrqPw38n.js → approvalsOverlay-BwjLtwDu.js} +1 -1
  9. package/out/renderer/assets/{arc-amub664J.js → arc-CJvZx5za.js} +1 -1
  10. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-AkzGd1oc.js → architectureDiagram-IEHRJDOE-C9vZttIF.js} +1 -1
  11. package/out/renderer/assets/{avatar-cropper-3EV8Y8P7.js → avatar-cropper-BDGDatvK.js} +1 -1
  12. package/out/renderer/assets/{blockDiagram-JOT3LUYC-B-e76-DH.js → blockDiagram-JOT3LUYC-CrTilJoM.js} +1 -1
  13. package/out/renderer/assets/{book-open-DmG3y7w8.js → book-open-Dry7YYVL.js} +1 -1
  14. package/out/renderer/assets/browser-page-DnEBJrfB.js +1 -0
  15. package/out/renderer/assets/{browser-webauthn-prompt-CxRqCCKX.js → browser-webauthn-prompt-DgwGUq_y.js} +1 -1
  16. package/out/renderer/assets/{c4Diagram-VJAJSXHY-BAJ98HDd.js → c4Diagram-VJAJSXHY-ChxxzcOx.js} +1 -1
  17. package/out/renderer/assets/channel-DwhJuNn0.js +1 -0
  18. package/out/renderer/assets/{chunk-4BMEZGHF-fZlmcD7B.js → chunk-4BMEZGHF-C5t-MiXC.js} +1 -1
  19. package/out/renderer/assets/{chunk-A2AXSNBT-DBdtsfRL.js → chunk-A2AXSNBT-B6OrQoN1.js} +1 -1
  20. package/out/renderer/assets/{chunk-AEK57VVT-CernlUp4.js → chunk-AEK57VVT-B-CCcK_3.js} +1 -1
  21. package/out/renderer/assets/{chunk-D6G4REZN-9wtlYb5j.js → chunk-D6G4REZN-BZY21A1n.js} +1 -1
  22. package/out/renderer/assets/{chunk-RZ5BOZE2-Ck3HRnv1.js → chunk-RZ5BOZE2-YDupMRm6.js} +1 -1
  23. package/out/renderer/assets/{chunk-XZIHB7SX-Bf-HLTrZ.js → chunk-XZIHB7SX-PmEzlYQH.js} +1 -1
  24. package/out/renderer/assets/classDiagram-GIVACNV2-CNoIpxaO.js +1 -0
  25. package/out/renderer/assets/classDiagram-v2-COTLJTTW-CNoIpxaO.js +1 -0
  26. package/out/renderer/assets/clone-CziNdcSc.js +1 -0
  27. package/out/renderer/assets/{console-mirror-W8BRoBXL.js → console-mirror-C2GMTxaO.js} +1 -1
  28. package/out/renderer/assets/{consoleCapture-DR-TTWei.js → consoleCapture-DhwMLWG1.js} +1 -1
  29. package/out/renderer/assets/{conversation-input-sync-Det8Vy-l.js → conversation-input-sync-DQzjsgau.js} +4 -4
  30. package/out/renderer/assets/{dagre-OKDRZEBW-BEXaOllz.js → dagre-OKDRZEBW-S28CMqSq.js} +1 -1
  31. package/out/renderer/assets/{diagram-SSKATNLV-DEvLfVKL.js → diagram-SSKATNLV-WzdBELA1.js} +1 -1
  32. package/out/renderer/assets/{diagram-VNBRO52H-BHLZ9WAa.js → diagram-VNBRO52H-qidgAHUU.js} +1 -1
  33. package/out/renderer/assets/{erDiagram-Q7BY3M3F-BdOSLv0x.js → erDiagram-Q7BY3M3F-BR10KXA9.js} +1 -1
  34. package/out/renderer/assets/{error-boundary-Bz8JEE9a.js → error-boundary-BybE5CQk.js} +1 -1
  35. package/out/renderer/assets/{flowDiagram-4HSFHLVR-DU-y_o-H.js → flowDiagram-4HSFHLVR-ClhsJJ21.js} +1 -1
  36. package/out/renderer/assets/{ganttDiagram-APWFNJXF-CEYDp8ZK.js → ganttDiagram-APWFNJXF-BjEVo5xd.js} +1 -1
  37. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-DX_wjSsK.js → gitGraphDiagram-7IBYFJ6S-QJx1K_MA.js} +1 -1
  38. package/out/renderer/assets/{graph-Zonj4XBZ.js → graph-D8kqU9r6.js} +1 -1
  39. package/out/renderer/assets/{heart-CqF1dVly.js → heart-CGJZ_0g2.js} +1 -1
  40. package/out/renderer/assets/{index-BYjrZLS9.js → index-B4qqqwn0.js} +1 -1
  41. package/out/renderer/assets/{index-DCJth93z.js → index-BBe7L_J1.js} +58 -58
  42. package/out/renderer/assets/{index-DghClltC.js → index-BcYx997M.js} +1 -1
  43. package/out/renderer/assets/{index-StI9UbEF.js → index-DK_NuUky.js} +1 -1
  44. package/out/renderer/assets/infoDiagram-PH2N3AL5-DMreaGue.js +2 -0
  45. package/out/renderer/assets/{inline-error-boundary-HFpzZn_0.js → inline-error-boundary-DOS1DXOx.js} +1 -1
  46. package/out/renderer/assets/{installer-DkRrEoHT.js → installer-RTtkaOE-.js} +1 -1
  47. package/out/renderer/assets/{journeyDiagram-U35MCT3I-Cyey7g_P.js → journeyDiagram-U35MCT3I-BlLbr51x.js} +1 -1
  48. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-BjojOc_Z.js → kanban-definition-NDS4AKOZ-BvYkqSCW.js} +1 -1
  49. package/out/renderer/assets/{layout-LStN58Ol.js → layout-OVp1bACI.js} +1 -1
  50. package/out/renderer/assets/{legacy-agents-page-C93wx-P2.js → legacy-agents-page-B8YXq61l.js} +1 -1
  51. package/out/renderer/assets/{library-page-CN9NoSIq.js → library-page-DxGR_lbd.js} +3 -3
  52. package/out/renderer/assets/{log-in-DZcV_TqN.js → log-in-C-mju2Fl.js} +1 -1
  53. package/out/renderer/assets/{mermaid.core-DL4n5f9y.js → mermaid.core-KbHnAgh8.js} +5 -5
  54. package/out/renderer/assets/{mesh-page-x7IwMrXM.js → mesh-page-CdPPFCEA.js} +1 -1
  55. package/out/renderer/assets/{messages-B7JCOGPz.js → messages-CgcB7p0m.js} +8 -8
  56. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-Dw40vg_z.js → mindmap-definition-ALO5MXBD-D1s6RkD7.js} +1 -1
  57. package/out/renderer/assets/{mini-CP2iPIzy.js → mini-Cs05nJ14.js} +1 -1
  58. package/out/renderer/assets/{notebook-pen-7xAWt0As.js → notebook-pen-BI7SUwbx.js} +1 -1
  59. package/out/renderer/assets/{notifications-page-R4HHh4Tl.js → notifications-page-DsVCRE8a.js} +1 -1
  60. package/out/renderer/assets/{org-access-BSSetwe3.js → org-access-BHlbtr9E.js} +1 -1
  61. package/out/renderer/assets/{org-surface-gate-DN0fPbOq.js → org-surface-gate-D-Jcow5S.js} +1 -1
  62. package/out/renderer/assets/{page-header-DpgqXNG2.js → page-header-C6GFFNe-.js} +1 -1
  63. package/out/renderer/assets/{pieDiagram-IB7DONF6-DPaFc1dy.js → pieDiagram-IB7DONF6-DRhQISdy.js} +1 -1
  64. package/out/renderer/assets/{projects-page-ihp7BnlR.js → projects-page-Cc4UKW-0.js} +1 -1
  65. package/out/renderer/assets/{publication-validation-x7pRrJE9.js → publication-validation-OCdcDY3B.js} +1 -1
  66. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-e_IBvuYO.js → quadrantDiagram-7GDLP6J5-BxklmBHR.js} +1 -1
  67. package/out/renderer/assets/{radar-MK3ICKWK-9cAqsmf5.js → radar-MK3ICKWK-BH9o7akL.js} +1 -1
  68. package/out/renderer/assets/{radient-auth-buttons-CIfGBCET.js → radient-auth-buttons-CLSOEpUB.js} +1 -1
  69. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-B85D0bNl.js → requirementDiagram-KVF5MWMF-CBEi4Kx9.js} +1 -1
  70. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-LyaXovcj.js → sankeyDiagram-QLVOVGJD-rMPW5rkC.js} +1 -1
  71. package/out/renderer/assets/{schedules-page-BsOmBm6E.js → schedules-page-DFf63xd_.js} +1 -1
  72. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-BReeonq-.js → sequenceDiagram-X6HHIX6F-WqUDcsDn.js} +1 -1
  73. package/out/renderer/assets/{settings-page-BJEpNKl9.js → settings-page-C8IMxrdI.js} +1 -1
  74. package/out/renderer/assets/{smartart-DVSEEz9C.js → smartart-BlgfZyCb.js} +1 -1
  75. package/out/renderer/assets/{stateDiagram-DGXRK772-CEk4VlHq.js → stateDiagram-DGXRK772-Ujb5QrpB.js} +1 -1
  76. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-CdhLbMWA.js +1 -0
  77. package/out/renderer/assets/{team-bridge-page-Dddoo3gP.js → team-bridge-page-uLjkfWXE.js} +1 -1
  78. package/out/renderer/assets/{timeline-definition-BDJGKUSR-bzblTJq0.js → timeline-definition-BDJGKUSR-C0Z6JR3u.js} +1 -1
  79. package/out/renderer/assets/{use-default-on-banner-DVZYI7Aa.js → use-default-on-banner-CDiD6d05.js} +1 -1
  80. package/out/renderer/assets/{use-download-agent-mutation-CZZCW6Vo.js → use-download-agent-mutation-anAgYgC7.js} +1 -1
  81. package/out/renderer/assets/{use-session-snapshot-DrBdw6VP.js → use-session-snapshot-CUKwiap8.js} +1 -1
  82. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-CW48CuQ1.js → xychartDiagram-VJFVF3MP-eiOvoznq.js} +1 -1
  83. package/out/renderer/browser-approvals-overlay.html +2 -2
  84. package/out/renderer/console-capture.html +5 -5
  85. package/out/renderer/index.html +7 -7
  86. package/out/renderer/installer.html +4 -4
  87. package/out/renderer/mini.html +7 -7
  88. package/package.json +1 -1
  89. package/out/renderer/assets/browser-page-BhSsfQ0d.js +0 -1
  90. package/out/renderer/assets/channel-DKWE8IAz.js +0 -1
  91. package/out/renderer/assets/classDiagram-GIVACNV2-NtjCP5bY.js +0 -1
  92. package/out/renderer/assets/classDiagram-v2-COTLJTTW-NtjCP5bY.js +0 -1
  93. package/out/renderer/assets/clone-P3_xsQGC.js +0 -1
  94. package/out/renderer/assets/infoDiagram-PH2N3AL5-D_pSCS-K.js +0 -2
  95. package/out/renderer/assets/stateDiagram-v2-YXO3MK2T-Dqk8-DTg.js +0 -1
@@ -1,5 +1,5 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-StI9UbEF.js","./index-BYjrZLS9.js","./messages-B7JCOGPz.js","./index-Bg4CBuDE.css","./appearance-BAuF7bEx.js","./roles-D1pcbxAx.js","./error-boundary-Bz8JEE9a.js","./index-DghClltC.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-DL4n5f9y.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
- import{r as $,b as te,h as M4e,j as d,c as X,u as uA,g as Bn,J as Jce,l as eue,n as OA,i as L4e,K as rw,f as gn,t as tue}from"./index-BYjrZLS9.js";import{bv as F4e,f4 as IG,f5 as B4e,f6 as H4e,bs as K4e,f7 as J4e,f8 as ZG,f9 as eEe,bt as nue,u as ga,bB as tEe,fa as nEe,fb as rEe,O as zr,fc as rue,fd as jv,fe as iEe,b6 as aEe,ff as oEe,fg as sEe,fh as lEe,g as yu,aa as iue,fi as cEe,fj as DG,fk as uEe,fl as OEe,fm as dEe,Q as Pn,fn as xn,au as Ba,fo as cf,cp as J_,fp as T3,ao as rS,c1 as aue,N as ju,fq as fEe,m as St,r as ei,y as hEe,w as Si,aq as NO,fr as pEe,c as _n,A as fn,a as dr,i as ni,at as mEe,d as Xe,bR as dA,c5 as oue,k as To,fs as sue,ab as D$,ft as ek,c3 as gEe,c4 as lue,eu as $Ee,ai as Cv,l as zv,j as ur,I as It,a7 as yEe,o as vEe,fu as bEe,aC as wEe,fv as xEe,fw as SEe,dQ as QEe,dP as _Ee,dU as f2,dR as kEe,b_ as cue,fx as PEe,fy as TEe,fz as XEe,fA as REe,fB as EEe,eU as qEe,dV as jEe,as as yO,fC as tk,fD as Wp,fE as fA,fF as CEe,fG as VG,J as Fn,fH as MG,dK as wr,fI as uue,fJ as Oue,aE as ka,c0 as hA,fK as zEe,fL as AEe,fM as UEe,fN as WEe,fO as NEe,fP as iS,fQ as due,fR as V$,fS as YEe,fT as LG,aU as uf,fU as GEe,fV as Av,fW as IEe,fX as ZEe,fY as DEe,fZ as VEe,f_ as fue,f$ as hue,aS as jc,g0 as MEe,g1 as LEe,g2 as FEe,cx as BEe,cv as HEe,g3 as KEe,g4 as JEe,g5 as eqe,dz as Vs,g6 as Ms,g7 as tu,g8 as Kn,g9 as tqe,ga as aS,gb as nqe,b1 as rqe,bo as h2,gc as iqe,gd as aqe,ge as oqe,gf as sqe,gg as lqe,gh as pA,gi as cqe,M as uqe,e9 as mA,co as pue,aY as mue,b0 as Oqe,a$ as dqe,an as gA,gj as fqe,gk as hqe,gl as pqe,gm as mqe,gn as gqe,go as $qe,gp as gue,gq as yqe,gr as vqe,gs as bqe,gt as wqe,gu as xqe,gv as Sqe,gw as QO,gx as $A,gy as $ue,gz as Np,gA as Qqe,a1 as M$,gB as _qe,$ as yue,Y as vue,gC as rx,gD as kqe,gE as Pqe,gF as X3,gG as Tqe,gH as FG,gI as Xqe,gJ as Rqe,gK as Eqe,gL as _O,gM as qqe,gN as jqe,gO as yA,gP as Cqe,gQ as zqe,gR as Aqe,gS as Uqe,gT as Wqe,gU as Nqe,gV as Yqe,gW as Gqe,gX as Iqe,gY as Zqe,gZ as Dqe,g_ as Vqe,g$ as Mqe,h0 as Lqe,h1 as Fqe,n as nk,h2 as Bqe,h3 as bue,h4 as Hqe,h5 as Kqe,h6 as Uv,h7 as wue,h8 as xue,h9 as Sue,ha as vA,hb as Jqe,hc as eje,hd as tje,aO as nje,he as rje,f0 as rk,eF as ije,e as bA,hf as aje,hg as oje,D as sje,bl as lje,hh as cje,z as uje,hi as Oje,hj as dje,hk as fje,hl as hje,hm as L$,hn as pje,ho as BG,hp as Que,hq as mje,hr as HG,hs as gje,ht as $je,hu as yje,hv as _ue,hw as vje,hx as bje,hy as iw,hz as KG,hA as wje,hB as JG,hC as xje,hD as eI,br as tI,hE as nI,hF as Sje,hG as Qje,hH as rI,hI as R3,el as iI,hJ as _je,ap as aI,cC as kje,hK as Pje,hL as Tje,hM as Xje,hN as Yp,hO as Rje,dg as Eje,hP as qje,bI as jje,hQ as Cje,dd as zje,df as Aje,de as Uje,b7 as Wje,bj as Nje,cs as wA,cq as Yje,hR as Gje,dX as kue,dW as Pue,ak as F$,hS as a$,aV as Tue,hT as Ije,aX as Xue,hU as Zje,hV as xA,hW as Dje,hX as Vje,cR as Mje,aP as Lje,hY as Fje,aW as Bje,hZ as Hje,h_ as Kje,h$ as Jje,i0 as oI,i1 as e3e,i2 as oS,i3 as Rue,cA as t3e,i4 as Eue,i5 as n3e,i6 as r3e,i7 as i3e,i8 as a3e,h as o3e,i9 as ik,ia as SA,ib as s3e,ic as l3e,id as que,ie as B$,ig as Cc,ih as c3e,ii as u3e,ij as O3e,ik as d3e,e5 as f3e,il as sS,im as h3e,io as p3e,ip as m3e,iq as g3e,ir as sI,is as $3e,it as y3e,iu as v3e,iv as b3e,iw as w3e,ix as x3e,S as S3e,aD as lI,iy as E3,iz as q3,iA as Q3e}from"./appearance-BAuF7bEx.js";import{aA as _3e,c as je,aJ as k3e,aK as jue,aL as P3e,aM as T3e,aN as X3e,aO as R3e,aP as E3e,aQ as q3e,aR as Ug,aS as j3e,B as ve,m as QA,n as _A,y as C3e,o as kA,F as z3e,u as be,z as lS,S as ti,T as ak,w as $t,h as cS,J as Cue,r as Of,b as Ai,e as Is,X as Zr,a as zue,d as H$,f as A3e,A as rs,D as ok,g as sk,i as lk,I as Lo,l as oa,C as Aue,ak as K$,_ as p2,ac as U3e,v as W3e,a7 as Gp,p as ip,x as uS,au as PA,q as nu,R as cI,aT as N3e,a8 as Y3e,a9 as G3e,aa as I3e,ag as Z3e,at as D3e,a0 as V3e,N as M3e,O as L3e,P as F3e,K as Ha,U as Uue,V as Wue,W as Nue,Y as Yue,Z as j3,$ as B3e,L as Gue,aI as H3e,a1 as K3e,a2 as J3e,a3 as uI,a4 as OI,a5 as e7e,a6 as dI,an as t7e,s as n7e,G as m2,H as fI,E as hI}from"./error-boundary-Bz8JEE9a.js";import{b as Iue,c as TA,t as h,r as r7e,e as XA,L as zd,f as i7e,i as a7e,g as C3}from"./messages-B7JCOGPz.js";import{P as RA}from"./roles-D1pcbxAx.js";var o7e=class extends F4e{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:IG()})}getOptimisticResult(e){return e.behavior=IG(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,l=n.fetchMeta?.fetchMore?.direction,c=o&&l==="forward",u=i&&l==="forward",O=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:H4e(t,n.data),hasPreviousPage:B4e(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:f,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!f}}},s7e=class extends K4e{#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),J4e(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&ZG(n.mutationKey)!==ZG(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??eEe();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){nue.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 OS(e,t){const n=ga(t),[r]=$.useState(()=>new s7e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(nue.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(tEe)},[r]);if(i.error&&nEe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Zue(e,t){return rEe(e,o7e,t)}const l7e=5e3;let Due=0;function c7e(e=l7e){Due=Date.now()+e}function ghn(e=Date.now()){return e<=Due}function u7e(e){c7e(),e.invalidateQueries({queryKey:zr.capabilities})}const O7e=e=>e!==""&&Iue(TA())==="rtl"?`⁦${e}⁩`:e;function d7e(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!f7e(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,f=u===1?c:`${c} (${O})`;for(;o.has(f)||f!==c&&a.has(f);)f=`${c} (${++O})`;o.add(f);const p=t.find(m=>m.kind==="audio"&&typeof l.digest=="string"&&m.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:f,audio:p,costCaption:Vue(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 Vue(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 h("ui.chat.canonical.sound.cost.no_charge");if(n?.basis==="estimated")return h("ui.chat.canonical.sound.cost.estimated_zero")}return jv({...e,billing_basis:n?.basis??e.billing_basis})}function g2(e){const t=e,n=Vue(t);if(!n)return h("ui.chat.canonical.sound.cost.batch_unknown");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 f7e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function h7e(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 h("ui.chat.canonical.sound.batch.summary",{completed:r("completed"),failed:r("failed"),cancelled:i,unknown:a,has_attention:o.length?"yes":"no",labels:rue(o.map(s=>s.label))})}function p7e(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-DK_NuUky.js","./index-B4qqqwn0.js","./messages-CgcB7p0m.js","./index-Bg4CBuDE.css","./appearance-CwnOp778.js","./roles-D1pcbxAx.js","./error-boundary-BybE5CQk.js","./index-BcYx997M.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-KbHnAgh8.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
+ import{r as $,b as te,h as M4e,j as d,c as X,u as uA,g as Bn,J as Jce,l as eue,n as OA,i as L4e,K as rw,f as gn,t as tue}from"./index-B4qqqwn0.js";import{bv as F4e,f4 as IG,f5 as B4e,f6 as H4e,bs as K4e,f7 as J4e,f8 as ZG,f9 as eEe,bt as nue,u as ga,bB as tEe,fa as nEe,fb as rEe,O as zr,fc as rue,fd as jv,fe as iEe,b6 as aEe,ff as oEe,fg as sEe,fh as lEe,g as yu,aa as iue,fi as cEe,fj as DG,fk as uEe,fl as OEe,fm as dEe,Q as Pn,fn as xn,au as Ba,fo as cf,cp as J_,fp as T3,ao as rS,c1 as aue,N as ju,fq as fEe,m as St,r as ei,y as hEe,w as Si,aq as NO,fr as pEe,c as _n,A as fn,a as dr,i as ni,at as mEe,d as Xe,bR as dA,c5 as oue,k as To,fs as sue,ab as D$,ft as ek,c3 as gEe,c4 as lue,eu as $Ee,ai as Cv,l as zv,j as ur,I as It,a7 as yEe,o as vEe,fu as bEe,aC as wEe,fv as xEe,fw as SEe,dQ as QEe,dP as _Ee,dU as f2,dR as kEe,b_ as cue,fx as PEe,fy as TEe,fz as XEe,fA as REe,fB as EEe,eU as qEe,dV as jEe,as as yO,fC as tk,fD as Wp,fE as fA,fF as CEe,fG as VG,J as Fn,fH as MG,dK as wr,fI as uue,fJ as Oue,aE as ka,c0 as hA,fK as zEe,fL as AEe,fM as UEe,fN as WEe,fO as NEe,fP as iS,fQ as due,fR as V$,fS as YEe,fT as LG,aU as uf,fU as GEe,fV as Av,fW as IEe,fX as ZEe,fY as DEe,fZ as VEe,f_ as fue,f$ as hue,aS as jc,g0 as MEe,g1 as LEe,g2 as FEe,cx as BEe,cv as HEe,g3 as KEe,g4 as JEe,g5 as eqe,dz as Vs,g6 as Ms,g7 as tu,g8 as Kn,g9 as tqe,ga as aS,gb as nqe,b1 as rqe,bo as h2,gc as iqe,gd as aqe,ge as oqe,gf as sqe,gg as lqe,gh as pA,gi as cqe,M as uqe,e9 as mA,co as pue,aY as mue,b0 as Oqe,a$ as dqe,an as gA,gj as fqe,gk as hqe,gl as pqe,gm as mqe,gn as gqe,go as $qe,gp as gue,gq as yqe,gr as vqe,gs as bqe,gt as wqe,gu as xqe,gv as Sqe,gw as QO,gx as $A,gy as $ue,gz as Np,gA as Qqe,a1 as M$,gB as _qe,$ as yue,Y as vue,gC as rx,gD as kqe,gE as Pqe,gF as X3,gG as Tqe,gH as FG,gI as Xqe,gJ as Rqe,gK as Eqe,gL as _O,gM as qqe,gN as jqe,gO as yA,gP as Cqe,gQ as zqe,gR as Aqe,gS as Uqe,gT as Wqe,gU as Nqe,gV as Yqe,gW as Gqe,gX as Iqe,gY as Zqe,gZ as Dqe,g_ as Vqe,g$ as Mqe,h0 as Lqe,h1 as Fqe,n as nk,h2 as Bqe,h3 as bue,h4 as Hqe,h5 as Kqe,h6 as Uv,h7 as wue,h8 as xue,h9 as Sue,ha as vA,hb as Jqe,hc as eje,hd as tje,aO as nje,he as rje,f0 as rk,eF as ije,e as bA,hf as aje,hg as oje,D as sje,bl as lje,hh as cje,z as uje,hi as Oje,hj as dje,hk as fje,hl as hje,hm as L$,hn as pje,ho as BG,hp as Que,hq as mje,hr as HG,hs as gje,ht as $je,hu as yje,hv as _ue,hw as vje,hx as bje,hy as iw,hz as KG,hA as wje,hB as JG,hC as xje,hD as eI,br as tI,hE as nI,hF as Sje,hG as Qje,hH as rI,hI as R3,el as iI,hJ as _je,ap as aI,cC as kje,hK as Pje,hL as Tje,hM as Xje,hN as Yp,hO as Rje,dg as Eje,hP as qje,bI as jje,hQ as Cje,dd as zje,df as Aje,de as Uje,b7 as Wje,bj as Nje,cs as wA,cq as Yje,hR as Gje,dX as kue,dW as Pue,ak as F$,hS as a$,aV as Tue,hT as Ije,aX as Xue,hU as Zje,hV as xA,hW as Dje,hX as Vje,cR as Mje,aP as Lje,hY as Fje,aW as Bje,hZ as Hje,h_ as Kje,h$ as Jje,i0 as oI,i1 as e3e,i2 as oS,i3 as Rue,cA as t3e,i4 as Eue,i5 as n3e,i6 as r3e,i7 as i3e,i8 as a3e,h as o3e,i9 as ik,ia as SA,ib as s3e,ic as l3e,id as que,ie as B$,ig as Cc,ih as c3e,ii as u3e,ij as O3e,ik as d3e,e5 as f3e,il as sS,im as h3e,io as p3e,ip as m3e,iq as g3e,ir as sI,is as $3e,it as y3e,iu as v3e,iv as b3e,iw as w3e,ix as x3e,S as S3e,aD as lI,iy as E3,iz as q3,iA as Q3e}from"./appearance-CwnOp778.js";import{aA as _3e,c as je,aJ as k3e,aK as jue,aL as P3e,aM as T3e,aN as X3e,aO as R3e,aP as E3e,aQ as q3e,aR as Ug,aS as j3e,B as ve,m as QA,n as _A,y as C3e,o as kA,F as z3e,u as be,z as lS,S as ti,T as ak,w as $t,h as cS,J as Cue,r as Of,b as Ai,e as Is,X as Zr,a as zue,d as H$,f as A3e,A as rs,D as ok,g as sk,i as lk,I as Lo,l as oa,C as Aue,ak as K$,_ as p2,ac as U3e,v as W3e,a7 as Gp,p as ip,x as uS,au as PA,q as nu,R as cI,aT as N3e,a8 as Y3e,a9 as G3e,aa as I3e,ag as Z3e,at as D3e,a0 as V3e,N as M3e,O as L3e,P as F3e,K as Ha,U as Uue,V as Wue,W as Nue,Y as Yue,Z as j3,$ as B3e,L as Gue,aI as H3e,a1 as K3e,a2 as J3e,a3 as uI,a4 as OI,a5 as e7e,a6 as dI,an as t7e,s as n7e,G as m2,H as fI,E as hI}from"./error-boundary-BybE5CQk.js";import{b as Iue,c as TA,t as h,r as r7e,e as XA,L as zd,f as i7e,i as a7e,g as C3}from"./messages-CgcB7p0m.js";import{P as RA}from"./roles-D1pcbxAx.js";var o7e=class extends F4e{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:IG()})}getOptimisticResult(e){return e.behavior=IG(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,t){const{state:n}=e,r=super.createResult(e,t),{isFetching:i,isRefetching:a,isError:o,isRefetchError:s}=r,l=n.fetchMeta?.fetchMore?.direction,c=o&&l==="forward",u=i&&l==="forward",O=o&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:H4e(t,n.data),hasPreviousPage:B4e(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:f,isRefetchError:s&&!c&&!O,isRefetching:a&&!u&&!f}}},s7e=class extends K4e{#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),J4e(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&ZG(n.mutationKey)!==ZG(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??eEe();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){nue.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 OS(e,t){const n=ga(t),[r]=$.useState(()=>new s7e(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(o=>r.subscribe(nue.batchCalls(o)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((o,s)=>{r.mutate(o,s).catch(tEe)},[r]);if(i.error&&nEe(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Zue(e,t){return rEe(e,o7e,t)}const l7e=5e3;let Due=0;function c7e(e=l7e){Due=Date.now()+e}function ghn(e=Date.now()){return e<=Due}function u7e(e){c7e(),e.invalidateQueries({queryKey:zr.capabilities})}const O7e=e=>e!==""&&Iue(TA())==="rtl"?`⁦${e}⁩`:e;function d7e(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!f7e(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,f=u===1?c:`${c} (${O})`;for(;o.has(f)||f!==c&&a.has(f);)f=`${c} (${++O})`;o.add(f);const p=t.find(m=>m.kind==="audio"&&typeof l.digest=="string"&&m.attachment===l.digest)??null;return{id:JSON.stringify([l.request_id??null,c,u]),name:c,label:f,audio:p,costCaption:Vue(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 Vue(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 h("ui.chat.canonical.sound.cost.no_charge");if(n?.basis==="estimated")return h("ui.chat.canonical.sound.cost.estimated_zero")}return jv({...e,billing_basis:n?.basis??e.billing_basis})}function g2(e){const t=e,n=Vue(t);if(!n)return h("ui.chat.canonical.sound.cost.batch_unknown");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 f7e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function h7e(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 h("ui.chat.canonical.sound.batch.summary",{completed:r("completed"),failed:r("failed"),cancelled:i,unknown:a,has_attention:o.length?"yes":"no",labels:rue(o.map(s=>s.label))})}function p7e(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 m7e(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"?h("ui.chat.canonical.sound.batch.latest_update",{name:n.name,item:a,total:i}):null;return{total:i,note:o}}const EA="generate_video",qA="generate_voiceover",jA="generate_sound_effect",g7e=new Set(["generate_image",EA,qA,jA]);function Mue(e){return g7e.has(e)}function $7e(e){return e===EA}function y7e(e){return e===qA||e===jA}function v7e(e){return e===EA?"video":e===qA?"voiceover":e===jA?"sound-effect":"image"}function b7e(e){if(!e||typeof e!="object")return null;const t=e;if(t.stage!=="cancelled")return null;const n=t.error_type;if(typeof n=="string"&&n)return null;const r=t.settling;if(typeof r!="boolean"||!("vendor_stopped"in t))return null;const i=t.vendor_stopped;return i!==null&&typeof i!="boolean"?null:{vendorStopped:i,settling:r}}function w7e(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 x7e(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:w7e(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 pI(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?Lue:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const Lue=Object.freeze({fraction:null,logs:[],queuePosition:null});function S7e(e,{stopping:t=!1,settled:n=!1}={}){const r=x7e(e.details),i=v7e(e.toolName),a=i==="voiceover"||i==="sound-effect",o=a&&e.phase==="done"?d7e(e.details,e.images??[]):null,s=a?m7e(e.args,e.details):null,l=o?{batch:o,batchSummary:h7e(e.details,o),batchNote:p7e(e.details,e.output)}:{},c=a?k7e(e.details):null,u=c?.caption??null,O=c?.pending===!0,f=b7e(e.details);if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...o?{...l,material:i,costCaption:g2(e.details)}:{},...u?{settlementCaption:u}:{},...O?{settlementPending:O}:{},...f?{cancel:f}:{},...u||O||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,errorCode:$2(e.notRunKind,e.notRunReason)};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,errorCode:$2(r.errorType,r.error??e.output),...l,costCaption:g2(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,...f?{cancel:f}:{},...u?{settlementCaption:u}:{},...O?{settlementPending:O}:{},...u||O||n?{settled:!0}:{}}:{state:"failed",material:i,message:r.error??e.output??null,errorCode:$2(r.errorType,r.error??e.output)};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,material:i,startedAtMs:null,progress:Lue}:{state:"queued",material:i,composing:e.phase==="composing",argumentBytes:e.argumentBytes??0,queuePosition:r.queuePosition};case"running":{const p=e.startedAt??null;return t?{state:"cancelling",generating:!0,material:i,startedAtMs:p,progress:pI(r)}:{state:"running",material:i,startedAtMs:p,progress:pI(r),note:r.error,...s?{batchProgress:s}:{}}}case"done":{const p=a?jv(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:o,...l,costCaption:o?g2(e.details):p}}}}const Q7e=/\s*Checking for settlement\.?\s*$/;function _7e(e){return e.replace(Q7e,"").trimEnd()}function k7e(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?{caption:jv(e),pending:!1}:t.settled===null&&t.cost_usd===null&&n?.basis==="quote"?{caption:null,pending:!0}:null}function $2(e,t){if(!e)return null;const n=e.replace(/_/g," ");return t?.toLowerCase().startsWith(n.toLowerCase())?null:e}function P7e(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 T7e(e,t){if(!$7e(e))return t?{onCancel:t}:void 0}function X7e(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 R7e=e=>{switch(e){case"success":return j7e;case"info":return z7e;case"warning":return C7e;case"error":return A7e;default:return null}},E7e=Array(12).fill(0),q7e=({visible:e,className:t})=>te.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},te.createElement("div",{className:"sonner-spinner"},E7e.map((n,r)=>te.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),j7e=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.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"})),C7e=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},te.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"})),z7e=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.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"})),A7e=te.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},te.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"})),U7e=te.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"},te.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),te.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),W7e=()=>{const[e,t]=te.useState(document.hidden);return te.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let z3=1;class N7e{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:z3++,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],te.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(G7e(c)&&!c.ok){a=!1;const O=typeof n.error=="function"?await n.error(`HTTP error! status: ${c.status}`):n.error,f=typeof n.description=="function"?await n.description(`HTTP error! status: ${c.status}`):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:f,...m})}else if(c instanceof Error){a=!1;const O=typeof n.error=="function"?await n.error(c):n.error,f=typeof n.description=="function"?await n.description(c):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"error",description:f,...m})}else if(n.success!==void 0){a=!1;const O=typeof n.success=="function"?await n.success(c):n.success,f=typeof n.description=="function"?await n.description(c):n.description,m=typeof O=="object"&&!te.isValidElement(O)?O:{message:O};this.create({id:r,type:"success",description:f,...m})}}).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,p=typeof u=="object"&&!te.isValidElement(u)?u:{message:u};this.create({id:r,type:"error",description:O,...p})}}).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||z3++;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 Na=new N7e,Y7e=(e,t)=>{const n=t?.id||z3++;return Na.addToast({title:e,...t,id:n}),n},G7e=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",I7e=Y7e,Z7e=()=>Na.toasts,D7e=()=>Na.getActiveToasts(),Uf=Object.assign(I7e,{success:Na.success,info:Na.info,warning:Na.warning,error:Na.error,custom:Na.custom,message:Na.message,promise:Na.promise,dismiss:Na.dismiss,loading:Na.loading},{getHistory:Z7e,getToasts:D7e});X7e("[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 aw(e){return e.label!==void 0}const V7e=3,M7e="24px",L7e="16px",mI=4e3,F7e=356,B7e=14,H7e=45,K7e=200;function ul(...e){return e.filter(Boolean).join(" ")}function J7e(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const eCe=e=>{var t,n,r,i,a,o,s,l,c;const{invert:u,toast:O,unstyled:f,interacting:p,setHeights:m,visibleToasts:g,heights:y,index:v,toasts:b,expanded:x,removeToast:Q,defaultRichColors:w,closeButton:S,style:_,cancelButtonStyle:k,actionButtonStyle:R,className:E="",descriptionClassName:T="",duration:q,position:A,gap:G,expandByDefault:I,classNames:z,icons:U,closeButtonAriaLabel:Y="Close toast"}=e,[M,C]=te.useState(null),[Z,K]=te.useState(null),[N,ce]=te.useState(!1),[ee,D]=te.useState(!1),[ne,J]=te.useState(!1),[L,B]=te.useState(!1),[ae,ie]=te.useState(!1),[ke,fe]=te.useState(0),[_e,qe]=te.useState(0),Ce=te.useRef(O.duration||q||mI),Oe=te.useRef(null),we=te.useRef(null),Je=v===0,ct=v+1<=g,nt=O.type,gt=O.dismissible!==!1,me=O.className||"",Ke=O.descriptionClassName||"",pe=te.useMemo(()=>y.findIndex(at=>at.toastId===O.id)||0,[y,O.id]),re=te.useMemo(()=>{var at;return(at=O.closeButton)!=null?at:S},[O.closeButton,S]),$e=te.useMemo(()=>O.duration||q||mI,[O.duration,q]),Qe=te.useRef(0),Se=te.useRef(0),ft=te.useRef(0),We=te.useRef(null),[rt,Wt]=A.split("-"),yt=te.useMemo(()=>y.reduce((at,At,on)=>on>=pe?at:at+At.height,0),[y,pe]),Ue=W7e(),_t=O.invert||u,Zt=nt==="loading";Se.current=te.useMemo(()=>pe*G+yt,[pe,yt]),te.useEffect(()=>{Ce.current=$e},[$e]),te.useEffect(()=>{ce(!0)},[]),te.useEffect(()=>{const at=we.current;if(at){const At=at.getBoundingClientRect().height;return qe(At),m(on=>[{toastId:O.id,height:At,position:O.position},...on]),()=>m(on=>on.filter(Cn=>Cn.toastId!==O.id))}},[m,O.id]),te.useLayoutEffect(()=>{if(!N)return;const at=we.current,At=at.style.height;at.style.height="auto";const on=at.getBoundingClientRect().height;at.style.height=At,qe(on),m(Cn=>Cn.find(Yt=>Yt.toastId===O.id)?Cn.map(Yt=>Yt.toastId===O.id?{...Yt,height:on}:Yt):[{toastId:O.id,height:on,position:O.position},...Cn])},[N,O.title,O.description,m,O.id]);const Ye=te.useCallback(()=>{D(!0),fe(Se.current),m(at=>at.filter(At=>At.toastId!==O.id)),setTimeout(()=>{Q(O)},K7e)},[O,Q,m,Se]);te.useEffect(()=>{if(O.promise&&nt==="loading"||O.duration===1/0||O.type==="loading")return;let at;return x||p||Ue?(()=>{if(ft.current<Qe.current){const Cn=new Date().getTime()-Qe.current;Ce.current=Ce.current-Cn}ft.current=new Date().getTime()})():(()=>{Ce.current!==1/0&&(Qe.current=new Date().getTime(),at=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),Ye()},Ce.current))})(),()=>clearTimeout(at)},[x,p,O,nt,Ue,Ye]),te.useEffect(()=>{O.delete&&Ye()},[Ye,O.delete]);function Nt(){var at;if(U?.loading){var At;return te.createElement("div",{className:ul(z?.loader,O==null||(At=O.classNames)==null?void 0:At.loader,"sonner-loader"),"data-visible":nt==="loading"},U.loading)}return te.createElement(q7e,{className:ul(z?.loader,O==null||(at=O.classNames)==null?void 0:at.loader),visible:nt==="loading"})}const Ae=O.icon||U?.[nt]||R7e(nt);var it,Ct;return te.createElement("li",{tabIndex:0,ref:we,className:ul(E,me,z?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,z?.default,z?.[nt],O==null||(n=O.classNames)==null?void 0:n[nt]),"data-sonner-toast":"","data-rich-colors":(it=O.richColors)!=null?it:w,"data-styled":!(O.jsx||O.unstyled||f),"data-mounted":N,"data-promise":!!O.promise,"data-swiped":ae,"data-removed":ee,"data-visible":ct,"data-y-position":rt,"data-x-position":Wt,"data-index":v,"data-front":Je,"data-swiping":ne,"data-dismissible":gt,"data-type":nt,"data-invert":_t,"data-swipe-out":L,"data-swipe-direction":Z,"data-expanded":!!(x||I&&N),style:{"--index":v,"--toasts-before":v,"--z-index":b.length-v,"--offset":`${ee?ke:Se.current}px`,"--initial-height":I?"auto":`${_e}px`,..._,...O.style},onDragEnd:()=>{J(!1),C(null),We.current=null},onPointerDown:at=>{Zt||!gt||(Oe.current=new Date,fe(Se.current),at.target.setPointerCapture(at.pointerId),at.target.tagName!=="BUTTON"&&(J(!0),We.current={x:at.clientX,y:at.clientY}))},onPointerUp:()=>{var at,At,on;if(L||!gt)return;We.current=null;const Cn=Number(((at=we.current)==null?void 0:at.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),kr=Number(((At=we.current)==null?void 0:At.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Yt=new Date().getTime()-((on=Oe.current)==null?void 0:on.getTime()),or=M==="x"?Cn:kr,pi=Math.abs(or)/Yt;if(Math.abs(or)>=H7e||pi>.11){fe(Se.current),O.onDismiss==null||O.onDismiss.call(O,O),K(M==="x"?Cn>0?"right":"left":kr>0?"down":"up"),Ye(),B(!0);return}else{var Tt,zn;(Tt=we.current)==null||Tt.style.setProperty("--swipe-amount-x","0px"),(zn=we.current)==null||zn.style.setProperty("--swipe-amount-y","0px")}ie(!1),J(!1),C(null)},onPointerMove:at=>{var At,on,Cn;if(!We.current||!gt||((At=window.getSelection())==null?void 0:At.toString().length)>0)return;const Yt=at.clientY-We.current.y,or=at.clientX-We.current.x;var pi;const Tt=(pi=e.swipeDirections)!=null?pi:J7e(A);!M&&(Math.abs(or)>1||Math.abs(Yt)>1)&&C(Math.abs(or)>Math.abs(Yt)?"x":"y");let zn={x:0,y:0};const Bi=$n=>1/(1.5+Math.abs($n)/20);if(M==="y"){if(Tt.includes("top")||Tt.includes("bottom"))if(Tt.includes("top")&&Yt<0||Tt.includes("bottom")&&Yt>0)zn.y=Yt;else{const $n=Yt*Bi(Yt);zn.y=Math.abs($n)<Math.abs(Yt)?$n:Yt}}else if(M==="x"&&(Tt.includes("left")||Tt.includes("right")))if(Tt.includes("left")&&or<0||Tt.includes("right")&&or>0)zn.x=or;else{const $n=or*Bi(or);zn.x=Math.abs($n)<Math.abs(or)?$n:or}(Math.abs(zn.x)>0||Math.abs(zn.y)>0)&&ie(!0),(on=we.current)==null||on.style.setProperty("--swipe-amount-x",`${zn.x}px`),(Cn=we.current)==null||Cn.style.setProperty("--swipe-amount-y",`${zn.y}px`)}},re&&!O.jsx&&nt!=="loading"?te.createElement("button",{"aria-label":Y,"data-disabled":Zt,"data-close-button":!0,onClick:Zt||!gt?()=>{}:()=>{Ye(),O.onDismiss==null||O.onDismiss.call(O,O)},className:ul(z?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(Ct=U?.close)!=null?Ct:U7e):null,(nt||O.icon||O.promise)&&O.icon!==null&&(U?.[nt]!==null||O.icon)?te.createElement("div",{"data-icon":"",className:ul(z?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Nt():null,O.type!=="loading"?Ae:null):null,te.createElement("div",{"data-content":"",className:ul(z?.content,O==null||(a=O.classNames)==null?void 0:a.content)},te.createElement("div",{"data-title":"",className:ul(z?.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?te.createElement("div",{"data-description":"",className:ul(T,Ke,z?.description,O==null||(s=O.classNames)==null?void 0:s.description)},typeof O.description=="function"?O.description():O.description):null),te.isValidElement(O.cancel)?O.cancel:O.cancel&&aw(O.cancel)?te.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||k,onClick:at=>{aw(O.cancel)&&gt&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,at),Ye())},className:ul(z?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,te.isValidElement(O.action)?O.action:O.action&&aw(O.action)?te.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||R,onClick:at=>{aw(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,at),!at.defaultPrevented&&Ye())},className:ul(z?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function gI(){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 tCe(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,o=a?"--mobile-offset":"--offset",s=a?L7e:M7e;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 nCe=te.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:f,duration:p,style:m,visibleToasts:g=V7e,toastOptions:y,dir:v=gI(),gap:b=B7e,icons:x,containerAriaLabel:Q="Notifications"}=t,[w,S]=te.useState([]),_=te.useMemo(()=>Array.from(new Set([i].concat(w.filter(Z=>Z.position).map(Z=>Z.position)))),[w,i]),[k,R]=te.useState([]),[E,T]=te.useState(!1),[q,A]=te.useState(!1),[G,I]=te.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),z=te.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),Y=te.useRef(null),M=te.useRef(!1),C=te.useCallback(Z=>{S(K=>{var N;return(N=K.find(ce=>ce.id===Z.id))!=null&&N.delete||Na.dismiss(Z.id),K.filter(({id:ce})=>ce!==Z.id)})},[]);return te.useEffect(()=>Na.subscribe(Z=>{if(Z.dismiss){requestAnimationFrame(()=>{S(K=>K.map(N=>N.id===Z.id?{...N,delete:!0}:N))});return}setTimeout(()=>{_3e.flushSync(()=>{S(K=>{const N=K.findIndex(ce=>ce.id===Z.id);return N!==-1?[...K.slice(0,N),{...K[N],...Z},...K.slice(N+1)]:[Z,...K]})})})}),[w]),te.useEffect(()=>{if(O!=="system"){I(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?I("dark"):I("light")),typeof window>"u")return;const Z=window.matchMedia("(prefers-color-scheme: dark)");try{Z.addEventListener("change",({matches:K})=>{I(K?"dark":"light")})}catch{Z.addListener(({matches:N})=>{try{I(N?"dark":"light")}catch(ce){console.error(ce)}})}},[O]),te.useEffect(()=>{w.length<=1&&T(!1)},[w]),te.useEffect(()=>{const Z=K=>{var N;if(a.every(D=>K[D]||K.code===D)){var ee;T(!0),(ee=z.current)==null||ee.focus()}K.code==="Escape"&&(document.activeElement===z.current||(N=z.current)!=null&&N.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[a]),te.useEffect(()=>{if(z.current)return()=>{Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null,M.current=!1)}},[z.current]),te.createElement("section",{ref:n,"aria-label":`${Q} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},_.map((Z,K)=>{var N;const[ce,ee]=Z.split("-");return w.length?te.createElement("ol",{key:Z,dir:v==="auto"?gI():v,tabIndex:-1,ref:z,className:l,"data-sonner-toaster":!0,"data-sonner-theme":G,"data-y-position":ce,"data-lifted":E&&w.length>1&&!o,"data-x-position":ee,style:{"--front-toast-height":`${((N=k[0])==null?void 0:N.height)||0}px`,"--width":`${F7e}px`,"--gap":`${b}px`,...m,...tCe(c,u)},onBlur:D=>{M.current&&!D.currentTarget.contains(D.relatedTarget)&&(M.current=!1,Y.current&&(Y.current.focus({preventScroll:!0}),Y.current=null))},onFocus:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||M.current||(M.current=!0,Y.current=D.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{q||T(!1)},onDragEnd:()=>T(!1),onPointerDown:D=>{D.target instanceof HTMLElement&&D.target.dataset.dismissible==="false"||A(!0)},onPointerUp:()=>A(!1)},w.filter(D=>!D.position&&K===0||D.position===Z).map((D,ne)=>{var J,L;return te.createElement(eCe,{key:D.id,icons:x,index:ne,toast:D,defaultRichColors:f,duration:(J=y?.duration)!=null?J:p,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(L=y?.closeButton)!=null?L:s,interacting:q,position:Z,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:C,toasts:w.filter(B=>B.position==D.position),heights:k.filter(B=>B.position==D.position),setHeights:R,expandByDefault:o,gap:b,expanded:E,swipeDirections:t.swipeDirections})})):null}))}),rCe=["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"],iCe=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],aCe=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],oCe=new Set(rCe),sCe=/[:\-\u2014\n]$/,lCe=/^[:\n]/,$I=/[:\uff1a\n\u2014]| - /g,cCe=/^(?:\s*Error:\s*)+/,uCe=/:\s+Error:\s+/g,OCe=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,dCe=iCe.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function y2(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||sCe.test(r),o=i===""||lCe.test(i);return a&&o}function Fue(e){const t=hCe(e);if(!t)return null;const n=Bue(t);for(const r of n.matchAll(OCe)){const i=r[1];if(!oCe.has(i))continue;const a=r.index??0,o=a+r[0].length;return{code:`net::${i}`,start:a,end:o,clauseText:v2(n,a,o),clause:y2(n,a,o-a)}}for(const{code:r,pattern:i}of dCe){const a=i.exec(n);if(a){const o=a.index,s=o+a[0].length;return{code:r,start:o,end:s,clauseText:v2(n,o,s),clause:y2(n,o,s-o)}}}for(const r of aCe){const i=n.indexOf(r);if(i!==-1&&y2(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:v2(n,i,i+r.length),clause:!0}}return null}function fCe(e){return Fue(e)?.code??null}function $hn(e){return fCe(e)!==null}function hCe(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 v2(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll($I))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll($I)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function Bue(e){return e.replace(cCe,"").replace(uCe,": ")}const Wg=new Map,b2=new Map,w2=new Map,yI=5e3,pCe=1,mCe={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},gCe={"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},x2=()=>h("ui.common.connection.transport_failure"),Hue=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call(gCe,t))return x2();const n=Bue(t),r=Fue(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${x2()}${n.slice(r.end)}`:x2()},$Ce=e=>{for(const[t,n]of Object.entries(mCe))if(n.some(r=>e.includes(r)))return t;return null},yCe=(e,t)=>Uf.loading(e,t),Jn=(e,t)=>{const n=Date.now(),i=$Ce(e)||e,a=Hue(e),o=b2.get(i);if(o&&n-o<yI)return null;const s=w2.get(i)||0;if(s>=pCe)return null;if(Wg.has(i))return b2.set(i,n),Wg.get(i);const l=Uf.error(a,{...t,onDismiss:c=>{Wg.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{Wg.delete(i),t?.onAutoClose?.(c)}});return Wg.set(i,l),b2.set(i,n),w2.set(i,s+1),setTimeout(()=>{w2.set(i,0)},yI),l},S2=(e,t)=>Uf.error(Hue(e),t),_o=(e,t)=>Uf.info(e,t),o$=e=>{Uf.dismiss(e)},Ls=(e,t)=>Uf.success(e,t),Hh=(e,t)=>Uf.warning(e,t),vCe={"under-window":{dark:{canvas:.53,surface:.59,elevated:.68},light:{canvas:.61,surface:.5,elevated:.45}},menu:{dark:{canvas:.67,surface:.72,elevated:.8},light:{canvas:.79,surface:.7,elevated:.65}},popover:{dark:{canvas:.75,surface:.78,elevated:.86},light:{canvas:.86,surface:.79,elevated:.75}}},bCe={dark:.09,light:.12},wCe={dark:{role:"sunken",scale:.68},light:{role:"surface",scale:.72}},xCe={"under-window":{dark:.15,light:.2},menu:{dark:.1,light:.2},popover:{dark:.1,light:.15}},SCe={dark:.88,light:.78},QCe={dark:.7,light:.5},_Ce={dark:.65,light:.6},kCe={dark:.3,light:.4},PCe={hover:.05,selected:.08,field:.05,work:.08},TCe="Minimum ground alphas, the minimum ink and edge mixes the floating overlay carries, the state/field overlay alphas and the edge mix the window-glass feature paints, derived by scripts/derive-glass-floors.mjs (AA ink over the worst measured backdrop WITH the state overlay stacked; the 3:1 structural edge via a border->ink mix; the overlay floor against the least opaque column the app can present, plus the two mixes that carry the semantic inks and the panel's own boundary on it). Asserted by scripts/contrast-contract.mjs. Never hand-lower or hand-pick a value: re-derive.",CA={alphaFloor:vCe,blockVeil:bCe,laneWash:wCe,controlMix:xCe,bandFloor:SCe,overlayFloor:QCe,overlayInkMix:_Ce,overlayEdgeMix:kCe,stateAlpha:PCe,_why:TCe},yhn=["sidebars","full"],Kue=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",Jue=.96,zA=e=>Math.round(e*100)/100;function XCe(e,t,n,r=CA){const i=r.alphaFloor[Kue(e,t)][n];return{canvas:i.canvas,surface:i.surface,elevated:i.elevated}}function RCe(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=XCe(e.mechanism,e.material,e.scheme,e.floors),r=i=>{const a=Math.max(Jue,i);return zA(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}function ECe(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=CA.overlayFloor[e.scheme],r=Math.max(Jue,n);return zA(r-t*(r-n))}const qCe={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function jCe(e){const t=e.floors??CA,n=RCe(e),r=a=>n.canvas===1?0:zA(Math.min(1,Math.max(0,1-(1-a)/(1-n.canvas)))),i={"--lo-glass-a-canvas":String(n.canvas),"--lo-glass-a-surface":String(n.surface),"--lo-glass-a-elevated":String(n.elevated),"--lo-glass-a-row-hover":String(t.stateAlpha.hover),"--lo-glass-a-row-selected":String(t.stateAlpha.selected),"--lo-glass-a-row-work":String(t.stateAlpha.work),"--lo-glass-a-field":String(t.stateAlpha.field),"--lo-glass-a-block-veil":String(t.blockVeil[e.scheme]),"--lo-glass-a-band-floor":String(t.bandFloor[e.scheme]),"--lo-glass-a-overlay":String(ECe({intensity:e.intensity,scheme:e.scheme})),"--lo-glass-overlay-ink-mix":String(t.overlayInkMix[e.scheme]),"--lo-glass-overlay-edge-mix":String(t.overlayEdgeMix[e.scheme]),"--lo-glass-a-lane":String(Math.round(n.canvas*t.laneWash[e.scheme].scale*100)/100),"--lo-glass-lane-tone":t.laneWash[e.scheme].role==="sunken"?"var(--lo-sunken)":"var(--lo-surface)","--lo-glass-control-mix":String(t.controlMix[Kue(e.mechanism,e.material)][e.scheme]),"--lo-glass-in-surface":String(r(n.surface)),"--lo-glass-in-elevated":String(r(n.elevated))};return{kinds:qCe[e.coverage].join(" "),vars:i}}const eOe=()=>document.documentElement,CCe=["--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-overlay","--lo-glass-overlay-ink-mix","--lo-glass-overlay-edge-mix","--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 ix=null;const dS=()=>eOe().classList.contains("dark")?"dark":"light";function fS(e){ix=e;const t=eOe();if(!e||!e.active){delete t.dataset.glass;for(const a of CCe)t.style.removeProperty(a);return}const n=iEe(document),{kinds:r,vars:i}=jCe({floors:n?aEe(n):void 0,coverage:e.settings.coverage,intensity:e.settings.intensity,mechanism:e.mechanism,material:e.settings.material,scheme:e.scheme});t.dataset.glass=r;for(const[a,o]of Object.entries(i))t.style.setProperty(a,o)}function vhn(e){fS(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function A3(e){if(!e||!e.active||e.capability.mechanism==="none"){fS(null);return}e.restartRequired&&e.active||fS({active:!0,scheme:dS(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function bhn(){!ix||!ix.active||(fS({...ix,scheme:dS()}),window.api?.windowGlass?.reportScheme?.(dS()))}function whn(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>A3(r)),n=r=>{r&&A3(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function xhn(){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),A3(i),window.api?.windowGlass?.reportScheme?.(dS()))}}}const zCe=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),ACe=function(e,t){return new URL(e,t).href},vI={},xe=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=ACe(c,r),c in vI)return;vI[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(!!r)for(let m=o.length-1;m>=0;m--){const g=o[m];if(g.href===c&&(!u||g.rel==="stylesheet"))return}else if(document.querySelector(`link[href="${c}"]${O}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":zCe,u||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((m,g)=>{p.addEventListener("load",m),p.addEventListener("error",()=>g(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
  *
@@ -901,7 +901,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
901
901
  `))};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=Le.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((dt.mac||dt.android)&&c.from==o-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:s,to:l,insert:Vn.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);VU(t,c,Le.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(On.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:R0e.of(On.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=by(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 Pt{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||yat(t.parent)||document,this.viewState=new JM(t.state||Wn.create(t)),t.scrollTo&&t.scrollTo.is(Rw)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(sp).map(i=>new FT(i));for(let i of this.plugins)i.update(this);this.observer=new Aot(this),this.inputState=new oot(this),this.inputState.ensureHandlers(this.plugins),this.docView=new jM(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 Li?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 f of t){if(f.startState!=a)throw new RangeError("Trying to update state with a transaction that doesn't start from the previous state.");a=f.state}if(this.destroyed){this.viewState.state=a;return}let o=this.hasFocus,s=0,l=null;t.some(f=>f.annotation(Z0e))?(this.inputState.notifiedFocused=o,s=1):o!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=o,l=D0e(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(Wn.phrases)!=this.state.facet(Wn.phrases))return this.setState(a);i=MS.create(this,a,t),i.flags|=s;let O=this.viewState.scrollTarget;try{this.updateState=2;for(let f of t){if(O&&(O=O.map(f.changes)),f.scrollIntoView){let{main:p}=f.state.selection;O=new Sp(p.empty?p:Le.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is(Rw)&&(O=p.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=FS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(G0)!=this.styleModules&&this.mountStyles(),r=this.updateAttrs(),this.showAnnouncements(t),this.docView.updateSelection(n,t.some(f=>f.isUserEvent("select.pointer")))}finally{this.updateState=0}if(i.startState.facet(Aw)!=i.state.facet(Aw)&&(this.viewState.mustMeasureContent=!0),(n||r||O||this.viewState.mustEnforceCursorAssoc||this.viewState.mustMeasureContent)&&this.requestMeasure(),n&&this.docViewUpdate(),!i.empty)for(let f of this.state.facet(bC))try{f(i)}catch(p){Va(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!U0e(this,u)&&c.force&&xp(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 JM(t),this.plugins=t.facet(sp).map(r=>new FT(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new jM(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(sp),r=t.state.facet(sp);if(n!=r){let i=[];for(let a of r){let o=n.indexOf(a);if(o<0)i.push(new FT(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){Va(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(a0e(r))a=-1,o=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);a=p.from,o=p.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(p=>{try{return p.read(this)}catch(m){return Va(this.state,m),rL}}),O=MS.create(this,this.state,[]),f=!1;O.flags|=l,n?n.flags|=l:n=O,this.updateState=2,O.empty||(this.updatePlugins(O),this.inputState.update(O),this.updateAttrs(),f=this.docView.update(O),f&&this.docViewUpdate());for(let p=0;p<c.length;p++)if(u[p]!=rL)try{let m=c[p];m.write&&m.write(u[p],this)}catch(m){Va(this.state,m)}if(f&&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 m=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-o;if(m>1||m<-1){i=i+m,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(bC))s(n)}get themeClasses(){return _C+" "+(this.state.facet(QC)?F0e:L0e)+" "+this.state.facet(Aw)}updateAttrs(){let t=iL(this,E0e,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Ec)?"true":"false",class:"cm-content",style:`${dt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),iL(this,IU,n);let r=this.observer.ignore(()=>{let i=mC(this.contentDOM,this.contentAttrs,n),a=mC(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(Pt.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(G0);let t=this.state.facet(Pt.cspNonce);CO.mount(this.root,this.styleModules.concat(Cot).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 HT(this,t,WM(this,t,n,r))}moveByGroup(t,n){return HT(this,t,WM(this,t,n,r=>Hat(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 Le.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return Bat(this,t,n,r)}moveVertically(t,n,r){return HT(this,t,Kat(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(),A0e(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[OO.find(a,t-i.from,-1,n)];return ab(r,o.dir==xr.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(P0e)||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>Not)return v0e(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||y0e(a.isolates,r=qM(this,t))))return a.order;r||(r=qM(this,t));let i=jat(t.text,n,r);return this.bidiCache.push(new FS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||dt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{r0e(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 Rw.of(new Sp(typeof t=="number"?Le.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 Rw.of(new Sp(Le.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 xi.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return xi.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=CO.newName(),i=[Aw.of(r),G0.of(kC(`.${r}`,t))];return n&&n.dark&&i.push(QC.of(!0)),i}static baseTheme(t){return LO.lowest(G0.of(kC("."+_C,t,B0e)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&nr.get(r)||nr.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}Pt.styleModule=G0;Pt.inputHandler=_0e;Pt.clipboardInputFilter=YU;Pt.clipboardOutputFilter=GU;Pt.scrollHandler=X0e;Pt.focusChangeEffect=k0e;Pt.perLineTextDirection=P0e;Pt.exceptionSink=Q0e;Pt.updateListener=bC;Pt.editable=Ec;Pt.mouseSelectionStyle=S0e;Pt.dragMovesSelection=x0e;Pt.clickAddsSelectionRange=w0e;Pt.decorations=wy;Pt.outerDecorations=q0e;Pt.atomicRanges=ZU;Pt.bidiIsolatedRanges=j0e;Pt.scrollMargins=C0e;Pt.darkTheme=QC;Pt.cspNonce=mt.define({combine:e=>e.length?e[0]:""});Pt.contentAttributes=IU;Pt.editorAttributes=E0e;Pt.lineWrapping=Pt.contentAttributes.of({class:"cm-lineWrapping"});Pt.announce=Qn.define();const Not=4096,rL={};class FS{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:xr.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 FS(n.mapPos(o.from,1),n.mapPos(o.to,-1),o.dir,o.isolates,!1,o.order))}return r}}function iL(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&&pC(o,n)}return n}const Yot=dt.mac?"mac":dt.windows?"win":dt.linux?"linux":"key";function Got(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 Uw(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 Iot=LO.default(Pt.domEventHandlers({keydown(e,t){return K0e(H0e(t.state),e,t,"editor")}})),Fk=mt.define({enables:Iot}),aL=new WeakMap;function H0e(e){let t=e.facet(Fk),n=aL.get(t);return n||aL.set(t,n=Dot(t.reduce((r,i)=>r.concat(i),[]))),n}function zgn(e,t,n){return K0e(H0e(e.state),t,e,n)}let aO=null;const Zot=4e3;function Dot(e,t=Yot){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,f;let p=n[o]||(n[o]=Object.create(null)),m=s.split(/ (?!$)/).map(v=>Got(v,t));for(let v=1;v<m.length;v++){let b=m.slice(0,v).join(" ");i(b,!0),p[b]||(p[b]={preventDefault:!0,stopPropagation:!1,run:[x=>{let Q=aO={view:x,prefix:b,scope:o};return setTimeout(()=>{aO==Q&&(aO=null)},Zot),!0}]})}let g=m.join(" ");i(g,!1);let y=p[g]||(p[g]={preventDefault:!1,stopPropagation:!1,run:((f=(O=p._any)===null||O===void 0?void 0:O.run)===null||f===void 0?void 0:f.slice())||[]});l&&y.run.push(l),c&&(y.preventDefault=!0),u&&(y.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 f in u)u[f].run.push(p=>O(p,PC))}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 PC=null;function K0e(e,t,n,r){PC=t;let i=hat(t),a=yo(i,0),o=Rc(a)==i.length&&i!=" ",s="",l=!1,c=!1,u=!1;aO&&aO.view==n&&aO.scope==r&&(s=aO.prefix+" ",N0e.indexOf(t.keyCode)<0&&(c=!0,aO=null));let O=new Set,f=y=>{if(y){for(let v of y.run)if(!O.has(v)&&(O.add(v),v(n)))return y.stopPropagation&&(u=!0),!0;y.preventDefault&&(y.stopPropagation&&(u=!0),c=!0)}return!1},p=e[r],m,g;return p&&(f(p[s+Uw(i,t,!o)])?l=!0:o&&(t.altKey||t.metaKey||t.ctrlKey)&&!(dt.windows&&t.ctrlKey&&t.altKey)&&(m=zO[t.keyCode])&&m!=i?(f(p[s+Uw(m,t,!0)])||t.shiftKey&&(g=vy[t.keyCode])!=i&&g!=m&&f(p[s+Uw(g,t,!1)]))&&(l=!0):o&&t.shiftKey&&f(p[s+Uw(i,t,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),PC=null,l}class lb{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=J0e(t);return[new lb(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Vot(t,n,r)}}function J0e(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==xr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function oL(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 Vot(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==xr.LTR,o=e.contentDOM,s=o.getBoundingClientRect(),l=J0e(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),f=s.right-(u?parseInt(u.paddingRight):0),p=xC(e,r,1),m=xC(e,i,-1),g=p.type==Ea.Text?p:null,y=m.type==Ea.Text?m:null;if(g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=oL(e,r,1,g)),y&&(e.lineWrapping||m.widgetLineBreaks)&&(y=oL(e,i,-1,y)),g&&y&&g.from==y.from&&g.to==y.to)return b(x(n.from,n.to,g));{let w=g?x(n.from,null,g):Q(p,!1),S=y?x(null,n.to,y):Q(m,!0),_=[];return(g||p).to<(y||m).from-(g&&y?1:0)||p.widgetLineBreaks>1&&w.bottom+e.defaultLineHeight/2<S.top?_.push(v(O,w.bottom,f,S.top)):w.bottom<S.top&&e.elementAtHeight((w.bottom+S.top)/2).type==Ea.Text&&(w.bottom=S.top=(w.bottom+S.top)/2),b(w).concat(_).concat(b(S))}function v(w,S,_,k){return new lb(t,w-l.left,S-l.top,_-w,k-S)}function b({top:w,bottom:S,horizontal:_}){let k=[];for(let R=0;R<_.length;R+=2)k.push(v(_[R],w,_[R+1],S));return k}function x(w,S,_){let k=1e9,R=-1e9,E=[];function T(G,I,z,U,Y){let M=e.coordsAtPos(G,G==_.to?-2:2),C=e.coordsAtPos(z,z==_.from?2:-2);!M||!C||(k=Math.min(M.top,C.top,k),R=Math.max(M.bottom,C.bottom,R),Y==xr.LTR?E.push(a&&I?O:M.left,a&&U?f:C.right):E.push(!a&&U?O:C.left,!a&&I?f:M.right))}let q=w??_.from,A=S??_.to;for(let G of e.visibleRanges)if(G.to>q&&G.from<A)for(let I=Math.max(G.from,q),z=Math.min(G.to,A);;){let U=e.state.doc.lineAt(I);for(let Y of e.bidiSpans(U)){let M=Y.from+U.from,C=Y.to+U.from;if(M>=z)break;C>I&&T(Math.max(M,I),w==null&&M<=q,Math.min(C,z),S==null&&C>=A,Y.dir)}if(I=U.to+1,I>=z)break}return E.length==0&&T(q,w==null,A,S==null,e.textDirection),{top:k,bottom:R,horizontal:E}}function Q(w,S){let _=s.top+(S?w.top:w.bottom);return{top:_,bottom:_,horizontal:[]}}}function Mot(e,t){return e.constructor==t.constructor&&e.eq(t)}class Lot{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(xx)!=t.state.facet(xx)&&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(xx);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)=>!Mot(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 xx=mt.define();function e$e(e){return[xi.define(t=>new Lot(t,e)),xx.of(e)]}const xy=mt.define({combine(e){return tg(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Agn(e={}){return[xy.of(e),Fot,Bot,Hot,T0e.of(!0)]}function t$e(e){return e.startState.facet(xy)!=e.state.facet(xy)}const Fot=e$e({above:!0,markers(e){let{state:t}=e,n=t.facet(xy),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:Le.cursor(i.head,i.head>i.anchor?-1:1);for(let l of lb.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=t$e(e);return n&&sL(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){sL(t.state,e)},class:"cm-cursorLayer"});function sL(e,t){t.style.animationDuration=e.facet(xy).cursorBlinkRate+"ms"}const Bot=e$e({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:lb.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||t$e(e)},class:"cm-selectionLayer"}),Hot=LO.highest(Pt.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"}}}})),n$e=Qn.define({map(e,t){return e==null?null:t.mapPos(e)}}),D0=eo.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(n$e)?r.value:n,e)}}),Kot=xi.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(D0);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(D0)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(D0),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(D0)!=e&&this.view.dispatch({effects:n$e.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 Ugn(){return[D0,Kot]}function lL(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 Jot(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 est{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 $f,r=n.add.bind(n);for(let{from:i,to:a}of Jot(t,this.maxLength))lL(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 f=[],p,m=(g,y,v)=>f.push(v.range(g,y));if(l==c)for(this.regexp.lastIndex=u-l.from;(p=this.regexp.exec(l.text))&&p.index<O-l.from;)this.addMatch(p,t,p.index+l.from,m);else lL(t.state.doc,this.regexp,u,O,(g,y)=>this.addMatch(y,t,g,m));n=n.update({filterFrom:u,filterTo:O,filter:(g,y)=>g<u||y>O,add:f})}}return n}}const TC=/x/.unicode!=null?"gu":"g",tst=new RegExp(`[\0-\b
902
902
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,TC),nst={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 eX=null;function rst(){var e;if(eX==null&&typeof document<"u"&&document.body){let t=document.body.style;eX=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return eX||!1}const Sx=mt.define({combine(e){let t=tg(e,{render:null,specialChars:tst,addSpecialChars:null});return(t.replaceTabs=!rst())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,TC)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,TC)),t}});function Wgn(e={}){return[Sx.of(e),ist()]}let cL=null;function ist(){return cL||(cL=xi.fromClass(class{constructor(e){this.view=e,this.decorations=On.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(Sx)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new est({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=yo(t[0],0);if(a==9){let o=i.lineAt(r),s=n.state.tabSize,l=jO(o.text,s,r-o.from);return On.replace({widget:new lst((s-l%s)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=On.replace({widget:new sst(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(Sx);e.startState.facet(Sx)!=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 ast="•";function ost(e){return e>=32?ast:e==10?"␤":String.fromCharCode(9216+e)}class sst extends xu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=ost(this.code),r=t.state.phrase("Control character")+" "+(nst[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 lst extends xu{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 Ngn(){return ust}const cst=On.line({class:"cm-activeLine"}),ust=xi.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(cst.range(i.from)),t=i.from)}return On.set(n)}},{decorations:e=>e.decorations});class Ost extends xu{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?tm(t.firstChild):[];if(!n.length)return null;let r=window.getComputedStyle(t.parentNode),i=ab(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 Ygn(e){let t=xi.fromClass(class{constructor(n){this.view=n,this.placeholder=e?On.set([On.widget({widget:new Ost(e),side:1}).range(0)]):On.none}get decorations(){return this.view.state.doc.length?On.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,Pt.contentAttributes.of({"aria-placeholder":e})]:t}const XC=2e3;function dst(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>XC||n.off>XC||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(Le.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=lC(c.text,o,e.tabSize,!0);if(u<0)a.push(Le.cursor(c.to));else{let O=lC(c.text,s,e.tabSize);a.push(Le.range(c.from+u,c.from+O))}}}return a}function fst(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function uL(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>XC?-1:i==r.length?fst(e,t.clientX):jO(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function hst(e,t){let n=uL(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=uL(e,i);if(!s)return r;let l=dst(e.state,n,s);return l.length?o?Le.create(l.concat(r.ranges)):Le.create(l):r}}:null}function Ggn(e){let t=n=>n.altKey&&n.button==0;return Pt.mouseSelectionStyle.of((n,r)=>t(r)?hst(n,r):null)}const pst={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},mst={style:"cursor: crosshair"};function Ign(e={}){let[t,n]=pst[e.key||"Alt"],r=xi.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,Pt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?mst:null})]}const Kg="-10000px";class r$e{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 f=this.tooltips[O];f&&f.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 gst(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const tX=mt.define({combine:e=>{var t,n,r;return{position:dt.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)||gst}}}),OL=new WeakMap,FU=xi.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(tX);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 r$e(e,BU,(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(tX);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=Kg,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(dt.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Kg&&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=DU(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(tX).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],f=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=Kg;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,y=(t=OL.get(c))!==null&&t!==void 0?t:f.bottom-f.top,v=c.offset||yst,b=this.view.textDirection==xr.LTR,x=f.width>r.right-r.left?b?r.left:r.right-f.width:b?Math.max(r.left,Math.min(O.left-(p?14:0)+v.x,r.right-g)):Math.min(Math.max(r.left,O.left-g+(p?14:0)-v.x),r.right-g),Q=this.above[s];!l.strictSide&&(Q?O.top-y-m-v.y<r.top:O.bottom+y+m+v.y>r.bottom)&&Q==r.bottom-O.bottom>O.top-r.top&&(Q=this.above[s]=!Q);let w=(Q?O.top-r.top:r.bottom-O.bottom)-m;if(w<y&&c.resize!==!1){if(w<this.view.defaultLineHeight){u.style.top=Kg;continue}OL.set(c,y),u.style.height=(y=w)/a+"px"}else u.style.height&&(u.style.height="");let S=Q?O.top-y-m-v.y:O.bottom+m+v.y,_=x+g;if(c.overlap!==!0)for(let k of o)k.left<_&&k.right>x&&k.top<S+y&&k.bottom>S&&(S=Q?k.top-y-2-m:k.bottom+m+2);if(this.position=="absolute"?(u.style.top=(S-e.parent.top)/a+"px",dL(u,(x-e.parent.left)/i)):(u.style.top=S/a+"px",dL(u,x/i)),p){let k=O.left+(b?v.x:-v.x)-(x+14-7);p.style.left=k/i+"px"}c.overlap!==!0&&o.push({left:x,top:S,right:_,bottom:S+y}),u.classList.toggle("cm-tooltip-above",Q),u.classList.toggle("cm-tooltip-below",!Q),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=Kg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function dL(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const $st=Pt.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"}}}),yst={x:0,y:0},BU=mt.define({enables:[FU,$st]}),BS=mt.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class Bk{static create(t){return new Bk(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new r$e(t,BS,(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 vst=BU.compute([BS],e=>{let t=e.facet(BS);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:Bk.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class bst{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 uO)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==xr.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=>Va(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(FU),n=t?t.manager.tooltips.findIndex(r=>r.create==Bk.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&&!wst(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:!xst(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 Ww=4;function wst(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-Ww&&t.clientX<=r+Ww&&t.clientY>=i-Ww&&t.clientY<=a+Ww}function xst(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 Zgn(e,t={}){let n=Qn.define(),r=eo.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,Mi.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(Sst)&&(i=[]);return i},provide:i=>BS.from(i)});return{active:r,extension:[r,xi.define(i=>new bst(i,e,r,n,t.hoverTime||300)),vst]}}function i$e(e,t){let n=e.plugin(FU);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const Sst=Qn.define(),fL=mt.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 Dgn(e,t){let n=e.plugin(a$e),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const a$e=xi.fromClass(class{constructor(e){this.input=e.state.facet(pL),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(fL);this.top=new Nw(e,!0,t.topContainer),this.bottom=new Nw(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(fL);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Nw(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Nw(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(pL);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=>Pt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Nw{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=hL(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=hL(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 hL(e){let t=e.nextSibling;return e.remove(),t}const pL=mt.define({enables:a$e});class su extends gf{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}su.prototype.elementClass="";su.prototype.toDOM=void 0;su.prototype.mapMode=Mi.TrackBefore;su.prototype.startSide=su.prototype.endSide=-1;su.prototype.point=!0;const Qx=mt.define(),Qst=mt.define(),_st={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>Sn.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},w$=mt.define();function kst(e){return[o$e(),w$.of({..._st,...e})]}const mL=mt.define({combine:e=>e.some(t=>t)});function o$e(e){return[Pst]}const Pst=xi.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(w$).map(t=>new $L(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(mL),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(mL)!=!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=Sn.iter(this.view.state.facet(Qx),this.view.viewport.from),r=[],i=this.gutters.map(a=>new Tst(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==Ea.Text&&o){RC(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==Ea.Text){RC(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(w$),n=e.state.facet(w$),r=e.docChanged||e.heightChanged||e.viewportChanged||!Sn.eq(e.startState.facet(Qx),e.state.facet(Qx),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 $L(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=>Pt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==xr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function gL(e){return Array.isArray(e)?e:[e]}function RC(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class Tst{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=Sn.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 s$e(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=[];RC(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(Qst)){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 $L{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=gL(n.markers(t)),n.initialSpacer&&(this.spacer=new s$e(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=gL(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!Sn.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 s$e{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":""),Xst(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 Xst(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 Rst=mt.define(),Est=mt.define(),lp=mt.define({combine(e){return tg(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 nX extends su{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function rX(e,t){return e.state.facet(lp).formatNumber(t,e.state)}const qst=w$.compute([lp],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(Rst)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new nX(rX(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(Est)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(lp)!=t.state.facet(lp),initialSpacer(t){return new nX(rX(t,yL(t.state.doc.lines)))},updateSpacer(t,n){let r=rX(n.view,yL(n.view.state.doc.lines));return r==t.number?t:new nX(r)},domEventHandlers:e.facet(lp).domEventHandlers}));function Vgn(e={}){return[lp.of(e),o$e(),qst]}function yL(e){let t=9;for(;t<e;)t=t*10+9;return t}const jst=new class extends su{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},Cst=Qx.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(jst.range(i)))}return Sn.of(t)});function Mgn(){return Cst}let zst=0;class ot{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=zst++}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 ot&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new ot(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 HS(t);return r=>r.modified.indexOf(n)>-1?r:HS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let Ast=0;class HS{constructor(t){this.name=t,this.instances=[],this.id=Ast++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(s=>s.base==t&&Ust(n,s.modified));if(r)return r;let i=[],a=new ot(t.name,i,t,n);for(let s of n)s.instances.push(a);let o=Wst(n);for(let s of t.set)if(!s.modified.length)for(let l of o)i.push(HS.get(s,l));return a}}function Ust(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function Wst(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 jn(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 f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(s);if(!f)throw new RangeError("Invalid path: "+i);if(a.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),O+=f[0].length,O==i.length)break;let p=i[O++];if(O==i.length&&p=="!"){o=0;break}if(p!="/")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 KS(r,o,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return l$e.add(t)}const l$e=new Vt;let KS=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}};KS.empty=new KS([],2,null);function c$e(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 Nst(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function Yst(e,t,n,r=0,i=e.length){let a=new Gst(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Gst{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(p=>!p.scope||p.scope(o)));let c=i,u=Ist(t)||KS.empty,O=Nst(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 f=t.tree&&t.tree.prop(Vt.mounted);if(f&&f.overlay){let p=t.node.enter(f.overlay[0].from+s,1),m=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),g=t.firstChild();for(let y=0,v=s;;y++){let b=y<f.overlay.length?f.overlay[y]:null,x=b?b.from+s:l,Q=Math.max(n,v),w=Math.min(r,x);if(Q<w&&g)for(;t.from<w&&(this.highlightRange(t,Q,w,i,a),this.startSpan(Math.min(w,t.to),c),!(t.to>=x||!t.nextSibling())););if(!b||x>r)break;v=b.to+s,v>n&&(this.highlightRange(p.cursor(),Math.max(n,b.from+s),Math.min(r,v),"",m),this.startSpan(Math.min(r,v),c))}g&&t.parent()}else if(t.firstChild()){f&&(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 Ist(e){let t=e.type.prop(l$e);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const tt=ot.define,Yw=tt(),Hu=tt(),vL=tt(Hu),bL=tt(Hu),Ku=tt(),Gw=tt(Ku),iX=tt(Ku),gl=tt(),md=tt(gl),dl=tt(),fl=tt(),EC=tt(),Jg=tt(EC),Iw=tt(),P={comment:Yw,lineComment:tt(Yw),blockComment:tt(Yw),docComment:tt(Yw),name:Hu,variableName:tt(Hu),typeName:vL,tagName:tt(vL),propertyName:bL,attributeName:tt(bL),className:tt(Hu),labelName:tt(Hu),namespace:tt(Hu),macroName:tt(Hu),literal:Ku,string:Gw,docString:tt(Gw),character:tt(Gw),attributeValue:tt(Gw),number:iX,integer:tt(iX),float:tt(iX),bool:tt(Ku),regexp:tt(Ku),escape:tt(Ku),color:tt(Ku),url:tt(Ku),keyword:dl,self:tt(dl),null:tt(dl),atom:tt(dl),unit:tt(dl),modifier:tt(dl),operatorKeyword:tt(dl),controlKeyword:tt(dl),definitionKeyword:tt(dl),moduleKeyword:tt(dl),operator:fl,derefOperator:tt(fl),arithmeticOperator:tt(fl),logicOperator:tt(fl),bitwiseOperator:tt(fl),compareOperator:tt(fl),updateOperator:tt(fl),definitionOperator:tt(fl),typeOperator:tt(fl),controlOperator:tt(fl),punctuation:EC,separator:tt(EC),bracket:Jg,angleBracket:tt(Jg),squareBracket:tt(Jg),paren:tt(Jg),brace:tt(Jg),content:gl,heading:md,heading1:tt(md),heading2:tt(md),heading3:tt(md),heading4:tt(md),heading5:tt(md),heading6:tt(md),contentSeparator:tt(gl),list:tt(gl),quote:tt(gl),emphasis:tt(gl),strong:tt(gl),link:tt(gl),monospace:tt(gl),strikethrough:tt(gl),inserted:tt(),deleted:tt(),changed:tt(),invalid:tt(),meta:Iw,documentMeta:tt(Iw),annotation:tt(Iw),processingInstruction:tt(Iw),definition:ot.defineModifier("definition"),constant:ot.defineModifier("constant"),function:ot.defineModifier("function"),standard:ot.defineModifier("standard"),local:ot.defineModifier("local"),special:ot.defineModifier("special")};for(let e in P){let t=P[e];t instanceof ot&&(t.name=e)}c$e([{tag:P.link,class:"tok-link"},{tag:P.heading,class:"tok-heading"},{tag:P.emphasis,class:"tok-emphasis"},{tag:P.strong,class:"tok-strong"},{tag:P.keyword,class:"tok-keyword"},{tag:P.atom,class:"tok-atom"},{tag:P.bool,class:"tok-bool"},{tag:P.url,class:"tok-url"},{tag:P.labelName,class:"tok-labelName"},{tag:P.inserted,class:"tok-inserted"},{tag:P.deleted,class:"tok-deleted"},{tag:P.literal,class:"tok-literal"},{tag:P.string,class:"tok-string"},{tag:P.number,class:"tok-number"},{tag:[P.regexp,P.escape,P.special(P.string)],class:"tok-string2"},{tag:P.variableName,class:"tok-variableName"},{tag:P.local(P.variableName),class:"tok-variableName tok-local"},{tag:P.definition(P.variableName),class:"tok-variableName tok-definition"},{tag:P.special(P.variableName),class:"tok-variableName2"},{tag:P.definition(P.propertyName),class:"tok-propertyName tok-definition"},{tag:P.typeName,class:"tok-typeName"},{tag:P.namespace,class:"tok-namespace"},{tag:P.className,class:"tok-className"},{tag:P.macroName,class:"tok-macroName"},{tag:P.propertyName,class:"tok-propertyName"},{tag:P.operator,class:"tok-operator"},{tag:P.comment,class:"tok-comment"},{tag:P.meta,class:"tok-meta"},{tag:P.invalid,class:"tok-invalid"},{tag:P.punctuation,class:"tok-punctuation"}]);var aX;const dO=new Vt;function Hk(e){return mt.define({combine:e?t=>t.concat(e):void 0})}const HU=new Vt;class So{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Wn.prototype.hasOwnProperty("tree")||Object.defineProperty(Wn.prototype,"tree",{get(){return Mn(this)}}),this.parser=n,this.extension=[UO.of(this),Wn.languageData.of((a,o,s)=>{let l=wL(a,o,s),c=l.type.prop(dO);if(!c)return[];let u=a.facet(c),O=l.type.prop(HU);if(O){let f=l.resolve(o-l.from,s);for(let p of O)if(p.test(f,a)){let m=a.facet(p.facet);return p.type=="replace"?m:m.concat(u)}}return u})].concat(r)}isActiveAt(t,n,r=-1){return wL(t,n,r).type.prop(dO)==this.data}findRegions(t){let n=t.facet(UO);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(dO)==this.data){r.push({from:o,to:o+a.length});return}let s=a.prop(Vt.mounted);if(s){if(s.tree.prop(dO)==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 pn&&i(c,a.positions[l]+o)}};return i(Mn(t),0),r}get allowsNesting(){return!0}}So.setState=Qn.define();function wL(e,t,n){let r=e.facet(UO),i=Mn(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,tr.ExcludeBuffers))a.type.isTop&&(i=a);return i}class Tn extends So{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=Hk(t.languageData);return new Tn(n,t.parser.configure({props:[dO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new Tn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function Mn(e){let t=e.field(So.state,!1);return t?t.tree:pn.empty}class Zst{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 e0=null;class wf{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 wf(t,n,[],pn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Zst(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=pn.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(Lc.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(Lc.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=e0;e0=this;try{return t()}finally{e0=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=xL(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,f)=>l.push({fromA:c,toA:u,fromB:O,toB:f})),r=Lc.applyChanges(r,l),i=pn.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 wf(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=xL(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 Dk{createParse(n,r,i){let a=i[0].from,o=i[i.length-1].to;return{parsedPos:a,advance(){let l=e0;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 pn(fi.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 e0}}function xL(e,t,n){return Lc.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class am{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 am(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=wf.create(t.facet(UO).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new am(r)}}So.state=eo.define({create:am.init,update(e,t){for(let n of t.effects)if(n.is(So.setState))return n.value;return t.startState.facet(UO)!=t.state.facet(UO)?am.init(t.state):e.apply(t)}});let u$e=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(u$e=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const oX=typeof navigator<"u"&&(!((aX=navigator.scheduling)===null||aX===void 0)&&aX.isInputPending)?()=>navigator.scheduling.isInputPending():null,Dst=xi.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(So.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(So.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=u$e(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(So.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let o=Date.now()+Math.min(this.chunkBudget,100,t&&!oX?Math.max(25,t.timeRemaining()-5):1e9),s=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>oX&&oX()||Date.now()>o,i+(s?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:So.setState.of(new am(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=>Va(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()}}}),UO=mt.define({combine(e){return e.length?e[0]:null},enables:e=>[So.state,Dst,Pt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class vn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class ye{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 ye(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 Vst=mt.define(),Kk=mt.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 JS(e){let t=e.facet(Kk);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Mst(e,t){let n="",r=e.tabSize,i=e.facet(Kk)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function Lst(e,t){e instanceof Wn&&(e=new O$e(e));for(let r of e.state.facet(Vst)){let i=r(e,t);if(i!==void 0)return i}let n=Mn(e.state);return n.length>=t?Fst(e,n,t):null}class O$e{constructor(t,n={}){this.state=t,this.options=n,this.unit=JS(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 jO(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 Ar=new Vt;function Fst(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 d$e(r,e,n)}function d$e(e,t,n){for(let r=e;r;r=r.next){let i=Hst(r.node);if(i)return i(KU.create(t,n,r))}return 0}function Bst(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Hst(e){let t=e.type.prop(Ar);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(Vt.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return o=>f$e(o,!0,1,void 0,a&&!Bst(o)?i.from:void 0)}return e.parent==null?Kst:null}function Kst(){return 0}class KU extends O$e{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 KU(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(Jst(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return d$e(this.context.next,this.base,this.pos)}}function Jst(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function elt(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 as({closing:e,align:t=!0,units:n=1}){return r=>f$e(r,t,n,e)}function f$e(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?elt(e):null;return l?s?e.column(l.from):e.column(l.to):e.baseIndent+(s?0:e.unit*n)}const JU=e=>e.baseIndent;function Ir({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const tlt=200;function Bgn(){return Wn.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+tlt)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=Lst(o,u.from);if(O==null)continue;let f=/^\s*/.exec(u.text)[0],p=Mst(o,O);f!=p&&l.push({from:u.from,to:u.from+f.length,insert:p})}return l.length?[e,{changes:l,sequential:!0}]:e})}const h$e=mt.define(),_r=new Vt;function ma(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 nlt(e,t,n){let r=Mn(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(_r);if(l&&(s.to<r.length-50||r.length==e.doc.length||!rlt(s))){let c=l(s,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function rlt(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function eQ(e,t,n){for(let r of e.facet(h$e)){let i=r(e,t,n);if(i)return i}return nlt(e,t,n)}function p$e(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 Jk=Qn.define({map:p$e}),cb=Qn.define({map:p$e});function m$e(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 xf=eo.define({create(){return On.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(Jk)&&!ilt(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(y$e),i=r?On.replace({widget:new ult(r(t.state,n.value))}):SL;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(cb)&&(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=>Pt.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(SL.range(r,i))}return On.set(t,!0)}});function tQ(e,t,n){var r;let i=null;return(r=e.field(xf,!1))===null||r===void 0||r.between(t,n,(a,o)=>{(!i||i.from>a)&&(i={from:a,to:o})}),i}function ilt(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function g$e(e,t){return e.field(xf,!1)?t:t.concat(Qn.appendConfig.of(v$e()))}const alt=e=>{for(let t of m$e(e)){let n=eQ(e.state,t.from,t.to);if(n)return e.dispatch({effects:g$e(e.state,[Jk.of(n),$$e(e,n)])}),!0}return!1},olt=e=>{if(!e.state.field(xf,!1))return!1;let t=[];for(let n of m$e(e)){let r=tQ(e.state,n.from,n.to);r&&t.push(cb.of(r),$$e(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function $$e(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return Pt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const slt=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=eQ(t,i.from,i.to);a&&n.push(Jk.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:g$e(e.state,n)}),!!n.length},llt=e=>{let t=e.state.field(xf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(cb.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Hgn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:alt},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:olt},{key:"Ctrl-Alt-[",run:slt},{key:"Ctrl-Alt-]",run:llt}],clt={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},y$e=mt.define({combine(e){return tg(e,clt)}});function v$e(e){return[xf,dlt]}function b$e(e,t){let{state:n}=e,r=n.facet(y$e),i=o=>{let s=e.lineBlockAt(e.posAtDOM(o.target)),l=tQ(e.state,s.from,s.to);l&&e.dispatch({effects:cb.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 SL=On.replace({widget:new class extends xu{toDOM(e){return b$e(e,null)}}});class ult extends xu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return b$e(t,this.value)}}const Olt={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class sX extends su{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 Kgn(e={}){let t={...Olt,...e},n=new sX(t,!0),r=new sX(t,!1),i=xi.fromClass(class{constructor(o){this.from=o.viewport.from,this.markers=this.buildMarkers(o)}update(o){(o.docChanged||o.viewportChanged||o.startState.facet(UO)!=o.state.facet(UO)||o.startState.field(xf,!1)!=o.state.field(xf,!1)||Mn(o.startState)!=Mn(o.state)||t.foldingChanged(o))&&(this.markers=this.buildMarkers(o.view))}buildMarkers(o){let s=new $f;for(let l of o.viewportLineBlocks){let c=tQ(o.state,l.from,l.to)?r:eQ(o.state,l.from,l.to)?n:null;c&&s.add(l.from,l.from,c)}return s.finish()}}),{domEventHandlers:a}=t;return[i,kst({class:"cm-foldGutter",markers(o){var s;return((s=o.plugin(i))===null||s===void 0?void 0:s.markers)||Sn.empty},initialSpacer(){return new sX(t,!1)},domEventHandlers:{...a,click:(o,s,l)=>{if(a.click&&a.click(o,s,l))return!0;let c=tQ(o.state,s.from,s.to);if(c)return o.dispatch({effects:cb.of(c)}),!0;let u=eQ(o.state,s.from,s.to);return u?(o.dispatch({effects:Jk.of(u)}),!0):!1}}}),v$e()]}const dlt=Pt.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 eP{constructor(t,n){this.specs=t;let r;function i(s){let l=CO.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 So?s=>s.prop(dO)==o.data:o?s=>s==o:void 0,this.style=c$e(t.map(s=>({tag:s.tag,class:s.class||i(Object.assign({},s,{tag:null}))})),{all:a}).style,this.module=r?new CO(r):null,this.themeType=n.themeType}static define(t,n){return new eP(t,n||{})}}const qC=mt.define(),w$e=mt.define({combine(e){return e.length?[e[0]]:null}});function lX(e){let t=e.facet(qC);return t.length?t:e.facet(w$e)}function Jgn(e,t){let n=[hlt],r;return e instanceof eP&&(e.module&&n.push(Pt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(w$e.of(e)):r?n.push(qC.computeN([Pt.darkTheme],i=>i.facet(Pt.darkTheme)==(r=="dark")?[e]:[])):n.push(qC.of(e)),n}class flt{constructor(t){this.markCache=Object.create(null),this.tree=Mn(t.state),this.decorations=this.buildDeco(t,lX(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=Mn(t.state),r=lX(t.state),i=r!=lX(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 On.none;let r=new $f;for(let{from:i,to:a}of t.visibleRanges)Yst(this.tree,n,(o,s,l)=>{r.add(o,s,this.markCache[l]||(this.markCache[l]=On.mark({class:l})))},i,a);return r.finish()}}const hlt=LO.high(xi.fromClass(flt,{decorations:e=>e.decorations})),e0n=eP.define([{tag:P.meta,color:"#404740"},{tag:P.link,textDecoration:"underline"},{tag:P.heading,textDecoration:"underline",fontWeight:"bold"},{tag:P.emphasis,fontStyle:"italic"},{tag:P.strong,fontWeight:"bold"},{tag:P.strikethrough,textDecoration:"line-through"},{tag:P.keyword,color:"#708"},{tag:[P.atom,P.bool,P.url,P.contentSeparator,P.labelName],color:"#219"},{tag:[P.literal,P.inserted],color:"#164"},{tag:[P.string,P.deleted],color:"#a11"},{tag:[P.regexp,P.escape,P.special(P.string)],color:"#e40"},{tag:P.definition(P.variableName),color:"#00f"},{tag:P.local(P.variableName),color:"#30a"},{tag:[P.typeName,P.namespace],color:"#085"},{tag:P.className,color:"#167"},{tag:[P.special(P.variableName),P.macroName],color:"#256"},{tag:P.definition(P.propertyName),color:"#00c"},{tag:P.comment,color:"#940"},{tag:P.invalid,color:"#f00"}]),plt=Pt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),x$e=1e4,S$e="()[]{}",Q$e=mt.define({combine(e){return tg(e,{afterCursor:!0,brackets:S$e,maxScanDistance:x$e,renderMatch:$lt})}}),mlt=On.mark({class:"cm-matchingBracket"}),glt=On.mark({class:"cm-nonmatchingBracket"});function $lt(e){let t=[],n=e.matched?mlt:glt;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 ylt=eo.define({create(){return On.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Q$e);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=Zw(t.state,i.head,-1,r)||i.head>0&&Zw(t.state,i.head-1,1,r)||r.afterCursor&&(Zw(t.state,i.head,1,r)||i.head<t.state.doc.length&&Zw(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return On.set(n,!0)},provide:e=>Pt.decorations.from(e)}),vlt=[ylt,plt];function t0n(e={}){return[Q$e.of(e),vlt]}const eW=new Vt;function jC(e,t,n){let r=e.prop(t<0?Vt.openedBy:Vt.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 CC(e){let t=e.type.prop(eW);return t?t(e.node):e}function Zw(e,t,n,r={}){let i=r.maxScanDistance||x$e,a=r.brackets||S$e,o=Mn(e),s=o.resolveInner(t,n);for(let l=s;l;l=l.parent){let c=jC(l.type,n,a);if(c&&l.from<l.to){let u=CC(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return blt(e,t,n,l,u,c,a)}}return wlt(e,t,n,o,s.type,i,a)}function blt(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=CC(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(jC(u.type,n,o))c++;else if(jC(u.type,-n,o)){if(c==0){let O=CC(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 wlt(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 f=0;!u.next().done&&f<=a;){let p=u.value;n<0&&(f+=p.length);let m=t+f*n;for(let g=n>0?0:p.length-1,y=n>0?p.length:-1;g!=y;g+=n){let v=o.indexOf(p[g]);if(!(v<0||r.resolveInner(m+g,1).type!=i))if(v%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:m+g,to:m+g+1},matched:v>>1==l>>1};O--}}n>0&&(f+=p.length)}return u.done?{start:c,matched:!1}:null}function QL(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 _$e{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=QL(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:QL(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 xlt(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||Slt,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||nW,mergeTokens:e.mergeTokens!==!1}}function Slt(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 _L=new WeakMap;class Ge extends So{constructor(t){let n=Hk(t.languageData),r=xlt(t),i,a=new class extends Dk{createParse(o,s,l){return new _lt(i,o,s,l)}};super(n,a,[],t.name),this.topNode=Tlt(n,this),i=this,this.streamParser=r,this.stateAfter=new Vt({perNode:!0}),this.tokenTable=t.tokenTable?new X$e(r.tokenTable):Plt}static define(t){return new Ge(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=_L.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=tW(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 _$e(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)P$e(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&&_L.set(t.state,s.from),this.streamParser.indent(o,/^\s*(.*)/.exec(s.text)[1],t)}get allowsNesting(){return!1}}function tW(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 pn&&l<i&&tW(e,s,l,r,i);if(c)return c}return null}function k$e(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 pn){if(!(l=k$e(e,s,n-o,r-o,i)))break;return i?new pn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),o+l.length):l}}return null}function Qlt(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&&tW(e,a.tree,0-a.offset,n,s),c;if(l&&l.pos<=r&&(c=k$e(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?JS(i):4),tree:pn.empty}}let _lt=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=wf.get(),o=i[0].from,{state:s,tree:l}=Qlt(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(JS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=wf.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==`
903
903
  `&&(n="");else{let r=n.indexOf(`
904
- `);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 _$e(n,t?t.state.tabSize:4,t?JS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=P$e(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=pn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:klt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new pn(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 pn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function P$e(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 nW=Object.create(null),Sy=[fi.none],klt=new eg(Sy),kL=[],PL=Object.create(null),T$e=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"]])T$e[e]=R$e(nW,t);class X$e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),T$e)}resolve(t){return t?this.table[t]||(this.table[t]=R$e(this.extra,t)):0}}const Plt=new X$e(nW);function cX(e,t){kL.indexOf(e)>-1||(kL.push(e),console.warn(t))}function R$e(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):cX(c,`Modifier ${c} used at start of tag`):l.length?cX(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:cX(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=PL[i];if(a)return a.id;let o=PL[i]=fi.define({id:Sy.length,name:r,props:[jn({[r]:n})]});return Sy.push(o),o.id}function Tlt(e,t){let n=fi.define({id:Sy.length,name:"Document",props:[dO.add(()=>e),Ar.add(()=>r=>t.getIndent(r))],top:!0});return Sy.push(n),n}xr.RTL,xr.LTR;function ze(e){return new vn(Ge.define(e))}function Nu(e){return xe(()=>Promise.resolve().then(()=>Jgt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Xlt=[ye.of({name:"C",extensions:["c","h","ino"],load(){return xe(()=>Promise.resolve().then(()=>yB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return xe(()=>Promise.resolve().then(()=>yB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return xe(()=>Promise.resolve().then(()=>hOt),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return xe(()=>import("./index-StI9UbEF.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return xe(()=>Promise.resolve().then(()=>adt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return xe(()=>Promise.resolve().then(()=>r0t),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return xe(()=>Promise.resolve().then(()=>uft),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return xe(()=>Promise.resolve().then(()=>_dt),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return xe(()=>Promise.resolve().then(()=>Gyt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return xe(()=>Promise.resolve().then(()=>pdt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Nu("MSSQL")}}),ye.of({name:"MySQL",load(){return Nu("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return xe(()=>Promise.resolve().then(()=>yyt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return xe(()=>Promise.resolve().then(()=>Gmt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return xe(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return xe(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return xe(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),ye.of({name:"SQLite",load(){return Nu("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return xe(()=>Promise.resolve().then(()=>Dyt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return xe(()=>Promise.resolve().then(()=>ugt),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return xe(()=>import("./index-DghClltC.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return xe(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>ze(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return xe(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>ze(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return xe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ze(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>ze(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return xe(()=>Promise.resolve().then(()=>Pwt),void 0,import.meta.url).then(e=>ze(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return xe(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>ze(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return xe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ze(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return xe(()=>Promise.resolve().then(()=>Mwt),void 0,import.meta.url).then(e=>ze(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return xe(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>ze(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return xe(()=>Promise.resolve().then(()=>b1t),void 0,import.meta.url).then(e=>ze(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return xe(()=>Promise.resolve().then(()=>W1t),void 0,import.meta.url).then(e=>ze(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return xe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ze(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return xe(()=>Promise.resolve().then(()=>q1t),void 0,import.meta.url).then(e=>ze(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return xe(()=>Promise.resolve().then(()=>V1t),void 0,import.meta.url).then(e=>ze(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return xe(()=>Promise.resolve().then(()=>M1t),void 0,import.meta.url).then(e=>ze(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return xe(()=>Promise.resolve().then(()=>oxt),void 0,import.meta.url).then(e=>ze(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return xe(()=>Promise.resolve().then(()=>cxt),void 0,import.meta.url).then(e=>ze(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return xe(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>ze(e.dylan))}}),ye.of({name:"EBNF",load(){return xe(()=>Promise.resolve().then(()=>pxt),void 0,import.meta.url).then(e=>ze(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return xe(()=>Promise.resolve().then(()=>xxt),void 0,import.meta.url).then(e=>ze(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return xe(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>ze(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return xe(()=>Promise.resolve().then(()=>Nxt),void 0,import.meta.url).then(e=>ze(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return xe(()=>Promise.resolve().then(()=>uSt),void 0,import.meta.url).then(e=>ze(e.erlang))}}),ye.of({name:"Esper",load(){return xe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ze(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return xe(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ze(e.factor))}}),ye.of({name:"FCL",load(){return xe(()=>Promise.resolve().then(()=>mSt),void 0,import.meta.url).then(e=>ze(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return xe(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>ze(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return xe(()=>Promise.resolve().then(()=>_St),void 0,import.meta.url).then(e=>ze(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return xe(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>ze(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return xe(()=>Promise.resolve().then(()=>TSt),void 0,import.meta.url).then(e=>ze(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return xe(()=>Promise.resolve().then(()=>NSt),void 0,import.meta.url).then(e=>ze(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return xe(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ze(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return xe(()=>Promise.resolve().then(()=>GH),void 0,import.meta.url).then(e=>ze(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return xe(()=>Promise.resolve().then(()=>GH),void 0,import.meta.url).then(e=>ze(e.hxml))}}),ye.of({name:"HTTP",load(){return xe(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>ze(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return xe(()=>Promise.resolve().then(()=>xQt),void 0,import.meta.url).then(e=>ze(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return xe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ze(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return xe(()=>Promise.resolve().then(()=>kQt),void 0,import.meta.url).then(e=>ze(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return xe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>ze(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return xe(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>ze(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return xe(()=>Promise.resolve().then(()=>u_t),void 0,import.meta.url).then(e=>ze(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return xe(()=>Promise.resolve().then(()=>q_t),void 0,import.meta.url).then(e=>ze(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return xe(()=>Promise.resolve().then(()=>$_t),void 0,import.meta.url).then(e=>ze(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return xe(()=>Promise.resolve().then(()=>I_t),void 0,import.meta.url).then(e=>ze(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return xe(()=>Promise.resolve().then(()=>akt),void 0,import.meta.url).then(e=>ze(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return xe(()=>Promise.resolve().then(()=>X_t),void 0,import.meta.url).then(e=>ze(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>ukt),void 0,import.meta.url).then(e=>ze(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return xe(()=>Promise.resolve().then(()=>Okt),void 0,import.meta.url).then(e=>ze(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return xe(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>ze(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>ze(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return xe(()=>Promise.resolve().then(()=>Ckt),void 0,import.meta.url).then(e=>ze(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return xe(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>ze(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return xe(()=>Promise.resolve().then(()=>Gkt),void 0,import.meta.url).then(e=>ze(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return xe(()=>Promise.resolve().then(()=>Dkt),void 0,import.meta.url).then(e=>ze(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return xe(()=>Promise.resolve().then(()=>sPt),void 0,import.meta.url).then(e=>ze(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return xe(()=>Promise.resolve().then(()=>lPt),void 0,import.meta.url).then(e=>ze(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return xe(()=>Promise.resolve().then(()=>fPt),void 0,import.meta.url).then(e=>ze(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return xe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>ze(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return xe(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>ze(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return xe(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>ze(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return xe(()=>Promise.resolve().then(()=>RPt),void 0,import.meta.url).then(e=>ze(e.r))}}),ye.of({name:"RPM Changes",load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return xe(()=>Promise.resolve().then(()=>NPt),void 0,import.meta.url).then(e=>ze(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return xe(()=>Promise.resolve().then(()=>ZPt),void 0,import.meta.url).then(e=>ze(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return xe(()=>Promise.resolve().then(()=>r5t),void 0,import.meta.url).then(e=>ze(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return xe(()=>Promise.resolve().then(()=>s5t),void 0,import.meta.url).then(e=>ze(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return xe(()=>Promise.resolve().then(()=>d5t),void 0,import.meta.url).then(e=>ze(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return xe(()=>Promise.resolve().then(()=>p5t),void 0,import.meta.url).then(e=>ze(e.smalltalk))}}),ye.of({name:"Solr",load(){return xe(()=>Promise.resolve().then(()=>w5t),void 0,import.meta.url).then(e=>ze(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return xe(()=>Promise.resolve().then(()=>T5t),void 0,import.meta.url).then(e=>ze(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return xe(()=>Promise.resolve().then(()=>X5t),void 0,import.meta.url).then(e=>ze(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return xe(()=>Promise.resolve().then(()=>K5t),void 0,import.meta.url).then(e=>ze(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return xe(()=>Promise.resolve().then(()=>$2t),void 0,import.meta.url).then(e=>ze(e.swift))}}),ye.of({name:"sTeX",load(){return xe(()=>Promise.resolve().then(()=>qK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return xe(()=>Promise.resolve().then(()=>qK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return xe(()=>Promise.resolve().then(()=>JK),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return xe(()=>Promise.resolve().then(()=>w2t),void 0,import.meta.url).then(e=>ze(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return xe(()=>Promise.resolve().then(()=>_2t),void 0,import.meta.url).then(e=>ze(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return xe(()=>Promise.resolve().then(()=>M2t),void 0,import.meta.url).then(e=>ze(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return xe(()=>Promise.resolve().then(()=>eTt),void 0,import.meta.url).then(e=>ze(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return xe(()=>Promise.resolve().then(()=>tTt),void 0,import.meta.url).then(e=>ze(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return xe(()=>Promise.resolve().then(()=>iTt),void 0,import.meta.url).then(e=>ze(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return xe(()=>Promise.resolve().then(()=>wTt),void 0,import.meta.url).then(e=>ze(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return xe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ze(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return xe(()=>Promise.resolve().then(()=>QTt),void 0,import.meta.url).then(e=>ze(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return xe(()=>Promise.resolve().then(()=>$Xt),void 0,import.meta.url).then(e=>ze(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return xe(()=>Promise.resolve().then(()=>NTt),void 0,import.meta.url).then(e=>ze(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return xe(()=>Promise.resolve().then(()=>GTt),void 0,import.meta.url).then(e=>ze(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return xe(()=>Promise.resolve().then(()=>DTt),void 0,import.meta.url).then(e=>ze(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return xe(()=>Promise.resolve().then(()=>JK),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return xe(()=>Promise.resolve().then(()=>eXt),void 0,import.meta.url).then(e=>ze(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return xe(()=>Promise.resolve().then(()=>PXt),void 0,import.meta.url).then(e=>ze(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return xe(()=>Promise.resolve().then(()=>UXt),void 0,import.meta.url).then(e=>ze(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return xe(()=>Promise.resolve().then(()=>IXt),void 0,import.meta.url).then(e=>ze(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return xe(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return xe(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>e.angular())}})];class rW{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=Mn(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(E$e(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 TL(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 Rlt(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=TL(t)+TL(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function ub(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Rlt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tP(e,t){return n=>{for(let r=Mn(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 XL{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function tf(e){return e.selection.main.from}function E$e(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 iW=If.define();function Elt(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:Le.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const RL=new WeakMap;function qlt(e){if(!Array.isArray(e))return e;let t=RL.get(e);return t||RL.set(e,t=ub(e)),t}const nQ=Qn.define(),Qy=Qn.define();class jlt{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=yo(t,n),i=Rc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(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 b=yo(t,0),x=Rc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[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 b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=yo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=Rc(Q)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=yo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=b),g=b+1,p++):p=0));let S,_=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=Ige(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||_==1&&y||Q==0&&_!=0)&&(n[O]==w||r[O]==w&&(f=!0)?o[O++]=b:o.length&&(v=!1)),Q=_,b+=Rc(w)}return O==l&&o[0]==0&&v?this.result(-100+(f?-200:0),o,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(v?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?Rc(yo(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 Clt{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 Ci=mt.define({combine(e){return tg(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:zlt,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=>EL(t(r),n(r)),optionClass:(t,n)=>r=>EL(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function EL(e,t){return e?t?e+" "+t:e:t}function zlt(e,t,n,r,i,a){let o=e.textDirection==xr.RTL,s=o,l=!1,c="top",u,O,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,g=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?f:p);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Alt(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 f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(s.slice(u,O))),f.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 uX(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 Ult{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(Ci);this.optionContent=Alt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=uX(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(Ci).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:Qy.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=uX(a.length,o,t.state.facet(Ci).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=uX(n.options.length,n.selected,this.view.state.facet(Ci).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=>Va(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&&Nlt(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(Ci).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 f=typeof c=="string"?c:c.name;if(f!=a&&(o>r.from||r.from==0))if(a=f,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=f}}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 f of this.optionContent){let p=f(s,this.view.state,this.view,l);p&&u.appendChild(p)}}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 Wlt(e,t){return n=>new Ult(n,e,t)}function Nlt(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 qL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Ylt(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(f=>f.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Ci);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 XL(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new Clt(O):new jlt(O);for(let m of c.result.options)if(f=p.match(m.label)){let g=m.displayLabel?u?u(m,f.matched):[]:f.matched;i(new XL(m,c.source,g,f.score+(m.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(f,p)=>{var m,g;return((m=f.rank)!==null&&m!==void 0?m:1e9)-((g=p.rank)!==null&&g!==void 0?g:1e9)||(f.name<p.name?-1:1)};for(let f of r.sort(O))u-=1e5,c[f.name]=u;for(let f of n){let{section:p}=f.completion;p&&(f.score+=c[typeof p=="string"?p:p.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):qL(c.completion)>qL(s)&&(o[o.length-1]=c),s=c.completion}return o}class cp{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 cp(this.options,jL(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=Ylt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ci).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 cp(s,jL(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Mlt,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new cp(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 cp(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rQ{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rQ(Dlt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ci),a=(r.override||n.languageDataAt("autocomplete",tf(n)).map(qlt)).map(l=>(this.active.find(u=>u.source==l)||new es(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(aW));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Glt(a,this.active)||s?o=cp.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 es(l.source,0):l));for(let l of t.effects)l.is(j$e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new rQ(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Ilt:Zlt}}function Glt(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 Ilt={"aria-autocomplete":"list"},Zlt={};function jL(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Dlt=[];function q$e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(iW);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 es{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=q$e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new es(i.source,0)),r&4&&i.state==0&&(i=new es(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(nQ))i=new es(i.source,1,a.value);else if(a.is(Qy))i=new es(i.source,0);else if(a.is(aW))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(tf(t.state))}}class Qp extends es{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=tf(t.state);if(s>o||!i||n&2&&(tf(t.startState)==this.from||s<this.limit))return new es(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Vlt(i.validFor,t.state,a,o)?new Qp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new rW(t.state,s,!1)))?new Qp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:tf(t.state)):new es(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Qp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new es(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Vlt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):E$e(e,!0).test(i)}const aW=Qn.define({map(e,t){return e.map(n=>n.map(t))}}),j$e=Qn.define(),Ia=eo.define({create(){return rQ.start()},update(e,t){return e.update(t)},provide:e=>[BU.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function oW(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ia).active.find(i=>i.source==t.source);return r instanceof Qp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Elt(e.state,n,r.from,r.to)),{annotations:iW.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Mlt=Wlt(Ia,oW);function Dw(e,t="option"){return n=>{let r=n.state.field(Ia,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ci).interactionDelay)return!1;let i=1,a;t=="page"&&(a=i$e(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:j$e.of(s)}),!0}}const Llt=e=>{let t=e.state.field(Ia,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ci).interactionDelay?!1:oW(e,t.open.options[t.open.selected])},CL=e=>e.state.field(Ia,!1)?(e.dispatch({effects:nQ.of(!0)}),!0):!1,Flt=e=>{let t=e.state.field(Ia,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Qy.of(null)}),!0)};class Blt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Hlt=50,Klt=1e3,Jlt=xi.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(Ia).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ia),n=e.state.facet(Ci);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ia)==t)return;let r=e.transactions.some(a=>{let o=q$e(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>Hlt&&Date.now()-o.time>Klt){for(let s of o.context.abortListeners)try{s()}catch(l){Va(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(nQ)))&&(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(Ia);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(Ci).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=tf(t),r=new rW(t,n,e.explicit,this.view),i=new Blt(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:Qy.of(null)}),Va(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(Ci).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ci),r=this.view.state.field(Ia);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=tf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Qp(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 es(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:aW.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ia,!1);if(t&&t.tooltip&&this.view.state.facet(Ci).closeOnBlur){let n=t.open&&i$e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Qy.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nQ.of(!1)}),20),this.composing=0}}}),ect=typeof navigator=="object"&&/Win/.test(navigator.platform),tct=LO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ia,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(ect&&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&&oW(t,r),!1}})),C$e=Pt.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 nct{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class sW{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Mi.TrackDel),r=t.mapPos(this.to,1,Mi.TrackDel);return n==null||r==null?null:new sW(this.field,n,r)}}class lW{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(Kk);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 sW(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 f of i)f.field>=c&&f.field++}i.push(new nct(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 lW(r,i)}}let rct=On.widget({widget:new class extends xu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),ict=On.mark({class:"cm-snippetField"});class ng{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?rct:ict).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 ng(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 Ob=Qn.define({map(e,t){return e&&e.map(t)}}),act=Qn.define(),_y=eo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ob))return n.value;if(n.is(act)&&e)return new ng(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=>Pt.decorations.from(e,t=>t?t.deco:On.none)});function cW(e,t){return Le.create(e.filter(n=>n.field==t).map(n=>Le.range(n.from,n.to)))}function oct(e){let t=lW.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:Vn.of(o)},scrollIntoView:!0,annotations:r?[iW.of(r),Li.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=cW(s,0)),s.some(u=>u.field>0)){let u=new ng(s,0),O=c.effects=[Ob.of(u)];n.state.field(_y,!1)===void 0&&O.push(Qn.appendConfig.of([_y,Oct,dct,C$e]))}n.dispatch(n.state.update(c))}}function z$e(e){return({state:t,dispatch:n})=>{let r=t.field(_y,!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:cW(r.ranges,i),effects:Ob.of(a?null:new ng(r.ranges,i)),scrollIntoView:!0})),!0}}const sct=({state:e,dispatch:t})=>e.field(_y,!1)?(t(e.update({effects:Ob.of(null)})),!0):!1,lct=z$e(1),cct=z$e(-1),uct=[{key:"Tab",run:lct,shift:cct},{key:"Escape",run:sct}],zL=mt.define({combine(e){return e.length?e[0]:uct}}),Oct=LO.highest(Fk.compute([zL],e=>e.facet(zL)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:oct(e)})}const dct=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(_y,!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:cW(n.ranges,i.field),effects:Ob.of(n.ranges.some(a=>a.field>i.field)?new ng(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ky={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Yd=Qn.define({map(e,t){let n=t.mapPos(e,-1,Mi.TrackAfter);return n??void 0}}),uW=new class extends gf{};uW.startSide=1;uW.endSide=-1;const A$e=eo.define({create(){return Sn.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(Yd)&&(e=e.update({add:[uW.range(n.value,n.value+1)]}));return e}});function r0n(){return[hct,A$e]}const OX="()[]{}<>«»»«[]{}";function U$e(e){for(let t=0;t<OX.length;t+=2)if(OX.charCodeAt(t)==e)return OX.charAt(t+1);return Ige(e<128?e:e+1)}function W$e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ky}const fct=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),hct=Pt.inputHandler.of((e,t,n,r)=>{if((fct?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Rc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=mct(e.state,r);return a?(e.dispatch(a),!0):!1}),pct=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=W$e(e,e.selection.main.head).brackets||ky.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=gct(e.doc,o.head);for(let l of r)if(l==s&&nP(e.doc,o.head)==U$e(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Le.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},i0n=[{key:"Backspace",run:pct}];function mct(e,t){let n=W$e(e,e.selection.main.head),r=n.brackets||ky.brackets;for(let i of r){let a=U$e(yo(i,0));if(t==i)return a==i?vct(e,i,r.indexOf(i+i+i)>-1,n):$ct(e,i,a,n.before||ky.before);if(t==a&&N$e(e,e.selection.main.from))return yct(e,i,a)}return null}function N$e(e,t){let n=!1;return e.field(A$e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Rc(yo(n,0)))}function gct(e,t){let n=e.sliceString(t-2,t);return Rc(yo(n,0))==n.length?n:n.slice(1)}function $ct(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:Yd.of(o.to+t.length),range:Le.range(o.anchor+t.length,o.head+t.length)};let s=nP(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Yd.of(o.head+t.length),range:Le.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function yct(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nP(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Le.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function vct(e,t,n,r){let i=r.stringPrefixes||ky.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Yd.of(s.to+t.length),range:Le.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=nP(e.doc,l),u;if(c==t){if(AL(e,l))return{changes:{insert:t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)};if(N$e(e,l)){let f=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+f.length,insert:f},range:Le.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=UL(e,l-2*t.length,i))>-1&&AL(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Jo.Word&&UL(e,l,i)>-1&&!bct(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function AL(e,t){let n=Mn(e).resolveInner(t+1);return n.parent&&n.from==t}function bct(e,t,n,r){let i=Mn(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 UL(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Jo.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))!=Jo.Word)return a}return-1}function a0n(e={}){return[tct,Ia,Ci.of(e),Jlt,xct,C$e]}const wct=[{key:"Ctrl-Space",run:CL},{mac:"Alt-`",run:CL},{key:"Escape",run:Flt},{key:"ArrowDown",run:Dw(!0)},{key:"ArrowUp",run:Dw(!1)},{key:"PageDown",run:Dw(!0,"page")},{key:"PageUp",run:Dw(!1,"page")},{key:"Enter",run:Llt}],xct=LO.highest(Fk.computeN([Ci],e=>e.facet(Ci).defaultKeymap?[wct]:[]));class iQ{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new iQ(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=[[Vt.contextHash,i]]}addChild(t,n){t.prop(Vt.contextHash)!=this.hash&&(t=new pn(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 pn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new pn(fi.none,i,a,o,this.hashProp)})}}var Fe;(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"})(Fe||(Fe={}));class Sct{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Qct=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 x$(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 WL(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==Fe.OrderedList?fW:dW)(n,t,!1);return r>0&&(e.type!=Fe.BulletList||OW(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Y$e={[Fe.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(yn(Fe.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ps(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Fe.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Fe.OrderedList]:WL,[Fe.BulletList]:WL,[Fe.Document](){return!0}};function ps(e){return e==32||e==9||e==10||e==13}function x$(e,t=0){for(;t<e.length&&ps(e.charCodeAt(t));)t++;return t}function NL(e,t,n){for(;t>n&&ps(e.charCodeAt(t-1));)t--;return t}function G$e(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 I$e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function OW(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(!ps(a))return-1}return n&&e.next==45&&V$e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(B$e.SetextHeading)>-1||r<3?-1:1}function Z$e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function dW(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ps(e.text.charCodeAt(e.pos+1)))&&(!n||Z$e(t,Fe.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function fW(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&&!ps(e.text.charCodeAt(r+1))||n&&!Z$e(t,Fe.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function D$e(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 V$e(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&&ps(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const zC=/^[ \t]*$/,M$e=/-->/,L$e=/\?>/,AC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,M$e],[/^\s*<\?/,L$e],[/^\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,zC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,zC]];function F$e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=AC.length-(n?1:0);i<a;i++)if(AC[i][0].test(r))return i;return-1}function YL(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 gd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Fe.CodeText?e[r].to=n:e.push(yn(Fe.CodeText,t,n))}const Vw={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(gd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){gd(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==Fe.CodeText?gd(o,c.from,c.to):o.push(c);s=[]}gd(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&&gd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Fe.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Fe.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=G$e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=NL(t.text,t.text.length,o),l=[yn(Fe.CodeMark,r,r+a)];o<s&&l.push(yn(Fe.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(yn(Fe.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||gd(l,e.lineStart-1,e.lineStart);for(let p of t.markers)l.push(p);let O=e.lineStart+t.basePos,f=e.lineStart+t.text.length;O<f&&gd(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Fe.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=I$e(t);return n<0?!1:(e.startContext(Fe.Blockquote,t.pos),e.addNode(Fe.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(OW(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Fe.HorizontalRule,n),!0},BulletList(e,t){let n=dW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.BulletList&&e.startContext(Fe.BulletList,t.basePos,t.next);let r=YL(t,t.pos+1);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=fW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.OrderedList&&e.startContext(Fe.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=YL(t,t.pos+n);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=D$e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=NL(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ps(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Fe.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Fe.HeaderMark,o-r,a-r);let l=s.finish(Fe.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=F$e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=AC[n][1],a=[],o=i!=zC;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==M$e?Fe.CommentBlock:i==L$e?Fe.ProcessingInstructionBlock:Fe.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class _ct{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+`
904
+ `);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 _$e(n,t?t.state.tabSize:4,t?JS(t.state):2);if(o.eol())a.blankLine(this.state,o.indentUnit);else for(;!o.eol();){let s=P$e(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=pn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:klt,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new pn(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 pn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function P$e(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 nW=Object.create(null),Sy=[fi.none],klt=new eg(Sy),kL=[],PL=Object.create(null),T$e=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"]])T$e[e]=R$e(nW,t);class X$e{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),T$e)}resolve(t){return t?this.table[t]||(this.table[t]=R$e(this.extra,t)):0}}const Plt=new X$e(nW);function cX(e,t){kL.indexOf(e)>-1||(kL.push(e),console.warn(t))}function R$e(e,t){let n=[];for(let s of t.split(" ")){let l=[];for(let c of s.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):cX(c,`Modifier ${c} used at start of tag`):l.length?cX(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:cX(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=PL[i];if(a)return a.id;let o=PL[i]=fi.define({id:Sy.length,name:r,props:[jn({[r]:n})]});return Sy.push(o),o.id}function Tlt(e,t){let n=fi.define({id:Sy.length,name:"Document",props:[dO.add(()=>e),Ar.add(()=>r=>t.getIndent(r))],top:!0});return Sy.push(n),n}xr.RTL,xr.LTR;function ze(e){return new vn(Ge.define(e))}function Nu(e){return xe(()=>Promise.resolve().then(()=>Jgt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const Xlt=[ye.of({name:"C",extensions:["c","h","ino"],load(){return xe(()=>Promise.resolve().then(()=>yB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return xe(()=>Promise.resolve().then(()=>yB),void 0,import.meta.url).then(e=>e.cpp())}}),ye.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return Nu("Cassandra")}}),ye.of({name:"CSS",extensions:["css"],load(){return xe(()=>Promise.resolve().then(()=>hOt),void 0,import.meta.url).then(e=>e.css())}}),ye.of({name:"Go",extensions:["go"],load(){return xe(()=>import("./index-DK_NuUky.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),ye.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return xe(()=>Promise.resolve().then(()=>adt),void 0,import.meta.url).then(e=>e.html())}}),ye.of({name:"Java",extensions:["java"],load(){return xe(()=>Promise.resolve().then(()=>r0t),void 0,import.meta.url).then(e=>e.java())}}),ye.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript())}}),ye.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return xe(()=>Promise.resolve().then(()=>uft),void 0,import.meta.url).then(e=>e.json())}}),ye.of({name:"JSX",extensions:["jsx"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),ye.of({name:"LESS",extensions:["less"],load(){return xe(()=>Promise.resolve().then(()=>_dt),void 0,import.meta.url).then(e=>e.less())}}),ye.of({name:"Liquid",extensions:["liquid"],load(){return xe(()=>Promise.resolve().then(()=>Gyt),void 0,import.meta.url).then(e=>e.liquid())}}),ye.of({name:"MariaDB SQL",load(){return Nu("MariaSQL")}}),ye.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return xe(()=>Promise.resolve().then(()=>pdt),void 0,import.meta.url).then(e=>e.markdown())}}),ye.of({name:"MS SQL",load(){return Nu("MSSQL")}}),ye.of({name:"MySQL",load(){return Nu("MySQL")}}),ye.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return xe(()=>Promise.resolve().then(()=>yyt),void 0,import.meta.url).then(e=>e.php())}}),ye.of({name:"PLSQL",extensions:["pls"],load(){return Nu("PLSQL")}}),ye.of({name:"PostgreSQL",load(){return Nu("PostgreSQL")}}),ye.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return xe(()=>Promise.resolve().then(()=>Gmt),void 0,import.meta.url).then(e=>e.python())}}),ye.of({name:"Rust",extensions:["rs"],load(){return xe(()=>Promise.resolve().then(()=>x0t),void 0,import.meta.url).then(e=>e.rust())}}),ye.of({name:"Sass",extensions:["sass"],load(){return xe(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),ye.of({name:"SCSS",extensions:["scss"],load(){return xe(()=>Promise.resolve().then(()=>jF),void 0,import.meta.url).then(e=>e.sass())}}),ye.of({name:"SQL",extensions:["sql"],load(){return Nu("StandardSQL")}}),ye.of({name:"SQLite",load(){return Nu("SQLite")}}),ye.of({name:"TSX",extensions:["tsx"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),ye.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return xe(()=>Promise.resolve().then(()=>Lw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),ye.of({name:"WebAssembly",extensions:["wat","wast"],load(){return xe(()=>Promise.resolve().then(()=>Dyt),void 0,import.meta.url).then(e=>e.wast())}}),ye.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return xe(()=>Promise.resolve().then(()=>ugt),void 0,import.meta.url).then(e=>e.xml())}}),ye.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return xe(()=>import("./index-BcYx997M.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),ye.of({name:"APL",extensions:["dyalog","apl"],load(){return xe(()=>Promise.resolve().then(()=>vwt),void 0,import.meta.url).then(e=>ze(e.apl))}}),ye.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return xe(()=>Promise.resolve().then(()=>bwt),void 0,import.meta.url).then(e=>ze(e.asciiArmor))}}),ye.of({name:"ASN.1",extensions:["asn","asn1"],load(){return xe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>ze(e.asn1({})))}}),ye.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>_wt),void 0,import.meta.url).then(e=>ze(e.asterisk))}}),ye.of({name:"Brainfuck",extensions:["b","bf"],load(){return xe(()=>Promise.resolve().then(()=>Pwt),void 0,import.meta.url).then(e=>ze(e.brainfuck))}}),ye.of({name:"Cobol",extensions:["cob","cpy"],load(){return xe(()=>Promise.resolve().then(()=>n1t),void 0,import.meta.url).then(e=>ze(e.cobol))}}),ye.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.csharp))}}),ye.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"ClojureScript",extensions:["cljs"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return xe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>ze(e.gss))}}),ye.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return xe(()=>Promise.resolve().then(()=>Mwt),void 0,import.meta.url).then(e=>ze(e.cmake))}}),ye.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return xe(()=>Promise.resolve().then(()=>p1t),void 0,import.meta.url).then(e=>ze(e.coffeeScript))}}),ye.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return xe(()=>Promise.resolve().then(()=>b1t),void 0,import.meta.url).then(e=>ze(e.commonLisp))}}),ye.of({name:"Cypher",extensions:["cyp","cypher"],load(){return xe(()=>Promise.resolve().then(()=>W1t),void 0,import.meta.url).then(e=>ze(e.cypher))}}),ye.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return xe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>ze(e.cython))}}),ye.of({name:"Crystal",extensions:["cr"],load(){return xe(()=>Promise.resolve().then(()=>q1t),void 0,import.meta.url).then(e=>ze(e.crystal))}}),ye.of({name:"D",extensions:["d"],load(){return xe(()=>Promise.resolve().then(()=>V1t),void 0,import.meta.url).then(e=>ze(e.d))}}),ye.of({name:"Dart",extensions:["dart"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.dart))}}),ye.of({name:"diff",extensions:["diff","patch"],load(){return xe(()=>Promise.resolve().then(()=>M1t),void 0,import.meta.url).then(e=>ze(e.diff))}}),ye.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return xe(()=>Promise.resolve().then(()=>oxt),void 0,import.meta.url).then(e=>ze(e.dockerFile))}}),ye.of({name:"DTD",extensions:["dtd"],load(){return xe(()=>Promise.resolve().then(()=>cxt),void 0,import.meta.url).then(e=>ze(e.dtd))}}),ye.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return xe(()=>Promise.resolve().then(()=>hxt),void 0,import.meta.url).then(e=>ze(e.dylan))}}),ye.of({name:"EBNF",load(){return xe(()=>Promise.resolve().then(()=>pxt),void 0,import.meta.url).then(e=>ze(e.ebnf))}}),ye.of({name:"ECL",extensions:["ecl"],load(){return xe(()=>Promise.resolve().then(()=>xxt),void 0,import.meta.url).then(e=>ze(e.ecl))}}),ye.of({name:"edn",extensions:["edn"],load(){return xe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>ze(e.clojure))}}),ye.of({name:"Eiffel",extensions:["e"],load(){return xe(()=>Promise.resolve().then(()=>Txt),void 0,import.meta.url).then(e=>ze(e.eiffel))}}),ye.of({name:"Elm",extensions:["elm"],load(){return xe(()=>Promise.resolve().then(()=>Nxt),void 0,import.meta.url).then(e=>ze(e.elm))}}),ye.of({name:"Erlang",extensions:["erl"],load(){return xe(()=>Promise.resolve().then(()=>uSt),void 0,import.meta.url).then(e=>ze(e.erlang))}}),ye.of({name:"Esper",load(){return xe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>ze(e.esper))}}),ye.of({name:"Factor",extensions:["factor"],load(){return xe(()=>Promise.resolve().then(()=>OSt),void 0,import.meta.url).then(e=>ze(e.factor))}}),ye.of({name:"FCL",load(){return xe(()=>Promise.resolve().then(()=>mSt),void 0,import.meta.url).then(e=>ze(e.fcl))}}),ye.of({name:"Forth",extensions:["forth","fth","4th"],load(){return xe(()=>Promise.resolve().then(()=>ySt),void 0,import.meta.url).then(e=>ze(e.forth))}}),ye.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return xe(()=>Promise.resolve().then(()=>_St),void 0,import.meta.url).then(e=>ze(e.fortran))}}),ye.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.fSharp))}}),ye.of({name:"Gas",extensions:["s"],load(){return xe(()=>Promise.resolve().then(()=>PSt),void 0,import.meta.url).then(e=>ze(e.gas))}}),ye.of({name:"Gherkin",extensions:["feature"],load(){return xe(()=>Promise.resolve().then(()=>TSt),void 0,import.meta.url).then(e=>ze(e.gherkin))}}),ye.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return xe(()=>Promise.resolve().then(()=>NSt),void 0,import.meta.url).then(e=>ze(e.groovy))}}),ye.of({name:"Haskell",extensions:["hs"],load(){return xe(()=>Promise.resolve().then(()=>MSt),void 0,import.meta.url).then(e=>ze(e.haskell))}}),ye.of({name:"Haxe",extensions:["hx"],load(){return xe(()=>Promise.resolve().then(()=>GH),void 0,import.meta.url).then(e=>ze(e.haxe))}}),ye.of({name:"HXML",extensions:["hxml"],load(){return xe(()=>Promise.resolve().then(()=>GH),void 0,import.meta.url).then(e=>ze(e.hxml))}}),ye.of({name:"HTTP",load(){return xe(()=>Promise.resolve().then(()=>mQt),void 0,import.meta.url).then(e=>ze(e.http))}}),ye.of({name:"IDL",extensions:["pro"],load(){return xe(()=>Promise.resolve().then(()=>xQt),void 0,import.meta.url).then(e=>ze(e.idl))}}),ye.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return xe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>ze(e.jsonld))}}),ye.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return xe(()=>Promise.resolve().then(()=>kQt),void 0,import.meta.url).then(e=>ze(e.jinja2))}}),ye.of({name:"Julia",extensions:["jl"],load(){return xe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>ze(e.julia))}}),ye.of({name:"Kotlin",extensions:["kt","kts"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.kotlin))}}),ye.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return xe(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>ze(e.liveScript))}}),ye.of({name:"Lua",extensions:["lua"],load(){return xe(()=>Promise.resolve().then(()=>u_t),void 0,import.meta.url).then(e=>ze(e.lua))}}),ye.of({name:"mIRC",extensions:["mrc"],load(){return xe(()=>Promise.resolve().then(()=>q_t),void 0,import.meta.url).then(e=>ze(e.mirc))}}),ye.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return xe(()=>Promise.resolve().then(()=>$_t),void 0,import.meta.url).then(e=>ze(e.mathematica))}}),ye.of({name:"Modelica",extensions:["mo"],load(){return xe(()=>Promise.resolve().then(()=>I_t),void 0,import.meta.url).then(e=>ze(e.modelica))}}),ye.of({name:"MUMPS",extensions:["mps"],load(){return xe(()=>Promise.resolve().then(()=>akt),void 0,import.meta.url).then(e=>ze(e.mumps))}}),ye.of({name:"Mbox",extensions:["mbox"],load(){return xe(()=>Promise.resolve().then(()=>X_t),void 0,import.meta.url).then(e=>ze(e.mbox))}}),ye.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return xe(()=>Promise.resolve().then(()=>ukt),void 0,import.meta.url).then(e=>ze(e.nginx))}}),ye.of({name:"NSIS",extensions:["nsh","nsi"],load(){return xe(()=>Promise.resolve().then(()=>Okt),void 0,import.meta.url).then(e=>ze(e.nsis))}}),ye.of({name:"NTriples",extensions:["nt","nq"],load(){return xe(()=>Promise.resolve().then(()=>dkt),void 0,import.meta.url).then(e=>ze(e.ntriples))}}),ye.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.objectiveC))}}),ye.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.objectiveCpp))}}),ye.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.oCaml))}}),ye.of({name:"Octave",extensions:["m"],load(){return xe(()=>Promise.resolve().then(()=>xkt),void 0,import.meta.url).then(e=>ze(e.octave))}}),ye.of({name:"Oz",extensions:["oz"],load(){return xe(()=>Promise.resolve().then(()=>Ckt),void 0,import.meta.url).then(e=>ze(e.oz))}}),ye.of({name:"Pascal",extensions:["p","pas"],load(){return xe(()=>Promise.resolve().then(()=>Ykt),void 0,import.meta.url).then(e=>ze(e.pascal))}}),ye.of({name:"Perl",extensions:["pl","pm"],load(){return xe(()=>Promise.resolve().then(()=>Gkt),void 0,import.meta.url).then(e=>ze(e.perl))}}),ye.of({name:"Pig",extensions:["pig"],load(){return xe(()=>Promise.resolve().then(()=>Dkt),void 0,import.meta.url).then(e=>ze(e.pig))}}),ye.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return xe(()=>Promise.resolve().then(()=>sPt),void 0,import.meta.url).then(e=>ze(e.powerShell))}}),ye.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return xe(()=>Promise.resolve().then(()=>lPt),void 0,import.meta.url).then(e=>ze(e.properties))}}),ye.of({name:"ProtoBuf",extensions:["proto"],load(){return xe(()=>Promise.resolve().then(()=>fPt),void 0,import.meta.url).then(e=>ze(e.protobuf))}}),ye.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return xe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>ze(e.pug))}}),ye.of({name:"Puppet",extensions:["pp"],load(){return xe(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>ze(e.puppet))}}),ye.of({name:"Q",extensions:["q"],load(){return xe(()=>Promise.resolve().then(()=>SPt),void 0,import.meta.url).then(e=>ze(e.q))}}),ye.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return xe(()=>Promise.resolve().then(()=>RPt),void 0,import.meta.url).then(e=>ze(e.r))}}),ye.of({name:"RPM Changes",load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmChanges))}}),ye.of({name:"RPM Spec",extensions:["spec"],load(){return xe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>ze(e.rpmSpec))}}),ye.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return xe(()=>Promise.resolve().then(()=>NPt),void 0,import.meta.url).then(e=>ze(e.ruby))}}),ye.of({name:"SAS",extensions:["sas"],load(){return xe(()=>Promise.resolve().then(()=>ZPt),void 0,import.meta.url).then(e=>ze(e.sas))}}),ye.of({name:"Scala",extensions:["scala"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.scala))}}),ye.of({name:"Scheme",extensions:["scm","ss"],load(){return xe(()=>Promise.resolve().then(()=>r5t),void 0,import.meta.url).then(e=>ze(e.scheme))}}),ye.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return xe(()=>Promise.resolve().then(()=>s5t),void 0,import.meta.url).then(e=>ze(e.shell))}}),ye.of({name:"Sieve",extensions:["siv","sieve"],load(){return xe(()=>Promise.resolve().then(()=>d5t),void 0,import.meta.url).then(e=>ze(e.sieve))}}),ye.of({name:"Smalltalk",extensions:["st"],load(){return xe(()=>Promise.resolve().then(()=>p5t),void 0,import.meta.url).then(e=>ze(e.smalltalk))}}),ye.of({name:"Solr",load(){return xe(()=>Promise.resolve().then(()=>w5t),void 0,import.meta.url).then(e=>ze(e.solr))}}),ye.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return xe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>ze(e.sml))}}),ye.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return xe(()=>Promise.resolve().then(()=>T5t),void 0,import.meta.url).then(e=>ze(e.sparql))}}),ye.of({name:"Spreadsheet",alias:["excel","formula"],load(){return xe(()=>Promise.resolve().then(()=>X5t),void 0,import.meta.url).then(e=>ze(e.spreadsheet))}}),ye.of({name:"Squirrel",extensions:["nut"],load(){return xe(()=>Promise.resolve().then(()=>vd),void 0,import.meta.url).then(e=>ze(e.squirrel))}}),ye.of({name:"Stylus",extensions:["styl"],load(){return xe(()=>Promise.resolve().then(()=>K5t),void 0,import.meta.url).then(e=>ze(e.stylus))}}),ye.of({name:"Swift",extensions:["swift"],load(){return xe(()=>Promise.resolve().then(()=>$2t),void 0,import.meta.url).then(e=>ze(e.swift))}}),ye.of({name:"sTeX",load(){return xe(()=>Promise.resolve().then(()=>qK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return xe(()=>Promise.resolve().then(()=>qK),void 0,import.meta.url).then(e=>ze(e.stex))}}),ye.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return xe(()=>Promise.resolve().then(()=>JK),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"Tcl",extensions:["tcl"],load(){return xe(()=>Promise.resolve().then(()=>w2t),void 0,import.meta.url).then(e=>ze(e.tcl))}}),ye.of({name:"Textile",extensions:["textile"],load(){return xe(()=>Promise.resolve().then(()=>_2t),void 0,import.meta.url).then(e=>ze(e.textile))}}),ye.of({name:"TiddlyWiki",load(){return xe(()=>Promise.resolve().then(()=>M2t),void 0,import.meta.url).then(e=>ze(e.tiddlyWiki))}}),ye.of({name:"Tiki wiki",load(){return xe(()=>Promise.resolve().then(()=>eTt),void 0,import.meta.url).then(e=>ze(e.tiki))}}),ye.of({name:"TOML",extensions:["toml"],load(){return xe(()=>Promise.resolve().then(()=>tTt),void 0,import.meta.url).then(e=>ze(e.toml))}}),ye.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return xe(()=>Promise.resolve().then(()=>iTt),void 0,import.meta.url).then(e=>ze(e.troff))}}),ye.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return xe(()=>Promise.resolve().then(()=>wTt),void 0,import.meta.url).then(e=>ze(e.ttcn))}}),ye.of({name:"TTCN_CFG",extensions:["cfg"],load(){return xe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>ze(e.ttcnCfg))}}),ye.of({name:"Turtle",extensions:["ttl"],load(){return xe(()=>Promise.resolve().then(()=>QTt),void 0,import.meta.url).then(e=>ze(e.turtle))}}),ye.of({name:"Web IDL",extensions:["webidl"],load(){return xe(()=>Promise.resolve().then(()=>$Xt),void 0,import.meta.url).then(e=>ze(e.webIDL))}}),ye.of({name:"VB.NET",extensions:["vb"],load(){return xe(()=>Promise.resolve().then(()=>NTt),void 0,import.meta.url).then(e=>ze(e.vb))}}),ye.of({name:"VBScript",extensions:["vbs"],load(){return xe(()=>Promise.resolve().then(()=>GTt),void 0,import.meta.url).then(e=>ze(e.vbScript))}}),ye.of({name:"Velocity",extensions:["vtl"],load(){return xe(()=>Promise.resolve().then(()=>DTt),void 0,import.meta.url).then(e=>ze(e.velocity))}}),ye.of({name:"Verilog",extensions:["v"],load(){return xe(()=>Promise.resolve().then(()=>JK),void 0,import.meta.url).then(e=>ze(e.verilog))}}),ye.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return xe(()=>Promise.resolve().then(()=>eXt),void 0,import.meta.url).then(e=>ze(e.vhdl))}}),ye.of({name:"XQuery",extensions:["xy","xquery"],load(){return xe(()=>Promise.resolve().then(()=>PXt),void 0,import.meta.url).then(e=>ze(e.xQuery))}}),ye.of({name:"Yacas",extensions:["ys"],load(){return xe(()=>Promise.resolve().then(()=>UXt),void 0,import.meta.url).then(e=>ze(e.yacas))}}),ye.of({name:"Z80",extensions:["z80"],load(){return xe(()=>Promise.resolve().then(()=>IXt),void 0,import.meta.url).then(e=>ze(e.z80))}}),ye.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.mscgen))}}),ye.of({name:"Xù",extensions:["xu"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.xu))}}),ye.of({name:"MsGenny",extensions:["msgenny"],load(){return xe(()=>Promise.resolve().then(()=>pR),void 0,import.meta.url).then(e=>ze(e.msgenny))}}),ye.of({name:"Vue",extensions:["vue"],load(){return xe(()=>Promise.resolve().then(()=>Jyt),void 0,import.meta.url).then(e=>e.vue())}}),ye.of({name:"Angular Template",load(){return xe(()=>Promise.resolve().then(()=>$vt),void 0,import.meta.url).then(e=>e.angular())}})];class rW{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=Mn(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(E$e(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 TL(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 Rlt(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=TL(t)+TL(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function ub(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:Rlt(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tP(e,t){return n=>{for(let r=Mn(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 XL{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function tf(e){return e.selection.main.from}function E$e(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 iW=If.define();function Elt(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:Le.cursor(s.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const RL=new WeakMap;function qlt(e){if(!Array.isArray(e))return e;let t=RL.get(e);return t||RL.set(e,t=ub(e)),t}const nQ=Qn.define(),Qy=Qn.define();class jlt{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=yo(t,n),i=Rc(r);this.chars.push(r);let a=t.slice(n,n+i),o=a.toUpperCase();this.folded.push(yo(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 b=yo(t,0),x=Rc(b),Q=x==t.length?0:-100;if(b!=n[0])if(b==r[0])Q+=-200;else return null;return this.ret(Q,[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 b=0,x=Math.min(t.length,200);b<x&&c<l;){let Q=yo(t,b);(Q==n[c]||Q==r[c])&&(i[c++]=b),b+=Rc(Q)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),v=!0;for(let b=0,x=Math.min(t.length,200),Q=0;b<x&&O<l;){let w=yo(t,b);s<0&&(u<l&&w==n[u]&&(a[u++]=b),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=b),g=b+1,p++):p=0));let S,_=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(S=Ige(w))!=S.toLowerCase()?1:S!=S.toUpperCase()?2:0;(!b||_==1&&y||Q==0&&_!=0)&&(n[O]==w||r[O]==w&&(f=!0)?o[O++]=b:o.length&&(v=!1)),Q=_,b+=Rc(w)}return O==l&&o[0]==0&&v?this.result(-100+(f?-200:0),o,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):s>-1?this.ret(-700-t.length,[s,s+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(v?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?Rc(yo(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 Clt{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 Ci=mt.define({combine(e){return tg(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:zlt,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=>EL(t(r),n(r)),optionClass:(t,n)=>r=>EL(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function EL(e,t){return e?t?e+" "+t:e:t}function zlt(e,t,n,r,i,a){let o=e.textDirection==xr.RTL,s=o,l=!1,c="top",u,O,f=t.left-i.left,p=i.right-t.right,m=r.right-r.left,g=r.bottom-r.top;if(s&&f<Math.min(m,p)?s=!1:!s&&p<Math.min(m,f)&&(s=!0),m<=(s?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,s?f:p);else{l=!0,O=Math.min(400,(o?t.right:i.right-t.left)-30);let b=i.bottom-t.bottom;b>=g||b>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,v=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/v}px`,class:"cm-completionInfo-"+(l?o?"left-narrow":"right-narrow":s?"left":"right")}}function Alt(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 f=o.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(s.slice(u,O))),f.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 uX(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 Ult{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(Ci);this.optionContent=Alt(s),this.optionClass=s.optionClass,this.tooltipClass=s.tooltipClass,this.range=uX(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(Ci).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:Qy.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=uX(a.length,o,t.state.facet(Ci).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=uX(n.options.length,n.selected,this.view.state.facet(Ci).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=>Va(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&&Nlt(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(Ci).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 f=typeof c=="string"?c:c.name;if(f!=a&&(o>r.from||r.from==0))if(a=f,typeof c!="string"&&c.header)i.appendChild(c.header(c));else{let p=i.appendChild(document.createElement("completion-section"));p.textContent=f}}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 f of this.optionContent){let p=f(s,this.view.state,this.view,l);p&&u.appendChild(p)}}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 Wlt(e,t){return n=>new Ult(n,e,t)}function Nlt(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 qL(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function Ylt(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(f=>f.name==O)||r.push(typeof u=="string"?{name:O}:u)}},a=t.facet(Ci);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 XL(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new Clt(O):new jlt(O);for(let m of c.result.options)if(f=p.match(m.label)){let g=m.displayLabel?u?u(m,f.matched):[]:f.matched;i(new XL(m,c.source,g,f.score+(m.boost||0)))}}}if(r){let c=Object.create(null),u=0,O=(f,p)=>{var m,g;return((m=f.rank)!==null&&m!==void 0?m:1e9)-((g=p.rank)!==null&&g!==void 0?g:1e9)||(f.name<p.name?-1:1)};for(let f of r.sort(O))u-=1e5,c[f.name]=u;for(let f of n){let{section:p}=f.completion;p&&(f.score+=c[typeof p=="string"?p:p.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):qL(c.completion)>qL(s)&&(o[o.length-1]=c),s=c.completion}return o}class cp{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 cp(this.options,jL(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=Ylt(t,n);if(!s.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Ci).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 cp(s,jL(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Mlt,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new cp(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 cp(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class rQ{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new rQ(Dlt,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Ci),a=(r.override||n.languageDataAt("autocomplete",tf(n)).map(qlt)).map(l=>(this.active.find(u=>u.source==l)||new es(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(aW));o&&t.docChanged&&(o=o.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Glt(a,this.active)||s?o=cp.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 es(l.source,0):l));for(let l of t.effects)l.is(j$e)&&(o=o&&o.setSelected(l.value,this.id));return a==this.active&&o==this.open?this:new rQ(a,this.id,o)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?Ilt:Zlt}}function Glt(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 Ilt={"aria-autocomplete":"list"},Zlt={};function jL(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Dlt=[];function q$e(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(iW);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 es{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=q$e(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new es(i.source,0)),r&4&&i.state==0&&(i=new es(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(nQ))i=new es(i.source,1,a.value);else if(a.is(Qy))i=new es(i.source,0);else if(a.is(aW))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(tf(t.state))}}class Qp extends es{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=tf(t.state);if(s>o||!i||n&2&&(tf(t.startState)==this.from||s<this.limit))return new es(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Vlt(i.validFor,t.state,a,o)?new Qp(this.source,this.explicit,l,i,a,o):i.update&&(i=i.update(i,a,o,new rW(t.state,s,!1)))?new Qp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:tf(t.state)):new es(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Qp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new es(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Vlt(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):E$e(e,!0).test(i)}const aW=Qn.define({map(e,t){return e.map(n=>n.map(t))}}),j$e=Qn.define(),Ia=eo.define({create(){return rQ.start()},update(e,t){return e.update(t)},provide:e=>[BU.from(e,t=>t.tooltip),Pt.contentAttributes.from(e,t=>t.attrs)]});function oW(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(Ia).active.find(i=>i.source==t.source);return r instanceof Qp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},Elt(e.state,n,r.from,r.to)),{annotations:iW.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Mlt=Wlt(Ia,oW);function Dw(e,t="option"){return n=>{let r=n.state.field(Ia,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Ci).interactionDelay)return!1;let i=1,a;t=="page"&&(a=i$e(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:j$e.of(s)}),!0}}const Llt=e=>{let t=e.state.field(Ia,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Ci).interactionDelay?!1:oW(e,t.open.options[t.open.selected])},CL=e=>e.state.field(Ia,!1)?(e.dispatch({effects:nQ.of(!0)}),!0):!1,Flt=e=>{let t=e.state.field(Ia,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:Qy.of(null)}),!0)};class Blt{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Hlt=50,Klt=1e3,Jlt=xi.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(Ia).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(Ia),n=e.state.facet(Ci);if(!e.selectionSet&&!e.docChanged&&e.startState.field(Ia)==t)return;let r=e.transactions.some(a=>{let o=q$e(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>Hlt&&Date.now()-o.time>Klt){for(let s of o.context.abortListeners)try{s()}catch(l){Va(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(nQ)))&&(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(Ia);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(Ci).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=tf(t),r=new rW(t,n,e.explicit,this.view),i=new Blt(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:Qy.of(null)}),Va(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(Ci).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Ci),r=this.view.state.field(Ia);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=tf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(s,a.done.from+(a.active.explicit?0:1)),c=new Qp(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 es(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:aW.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(Ia,!1);if(t&&t.tooltip&&this.view.state.facet(Ci).closeOnBlur){let n=t.open&&i$e(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:Qy.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:nQ.of(!1)}),20),this.composing=0}}}),ect=typeof navigator=="object"&&/Win/.test(navigator.platform),tct=LO.highest(Pt.domEventHandlers({keydown(e,t){let n=t.state.field(Ia,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(ect&&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&&oW(t,r),!1}})),C$e=Pt.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 nct{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class sW{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,Mi.TrackDel),r=t.mapPos(this.to,1,Mi.TrackDel);return n==null||r==null?null:new sW(this.field,n,r)}}class lW{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(Kk);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 sW(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 f of i)f.field>=c&&f.field++}i.push(new nct(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 lW(r,i)}}let rct=On.widget({widget:new class extends xu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),ict=On.mark({class:"cm-snippetField"});class ng{constructor(t,n){this.ranges=t,this.active=n,this.deco=On.set(t.map(r=>(r.from==r.to?rct:ict).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 ng(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 Ob=Qn.define({map(e,t){return e&&e.map(t)}}),act=Qn.define(),_y=eo.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(Ob))return n.value;if(n.is(act)&&e)return new ng(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=>Pt.decorations.from(e,t=>t?t.deco:On.none)});function cW(e,t){return Le.create(e.filter(n=>n.field==t).map(n=>Le.range(n.from,n.to)))}function oct(e){let t=lW.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:Vn.of(o)},scrollIntoView:!0,annotations:r?[iW.of(r),Li.userEvent.of("input.complete")]:void 0};if(s.length&&(c.selection=cW(s,0)),s.some(u=>u.field>0)){let u=new ng(s,0),O=c.effects=[Ob.of(u)];n.state.field(_y,!1)===void 0&&O.push(Qn.appendConfig.of([_y,Oct,dct,C$e]))}n.dispatch(n.state.update(c))}}function z$e(e){return({state:t,dispatch:n})=>{let r=t.field(_y,!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:cW(r.ranges,i),effects:Ob.of(a?null:new ng(r.ranges,i)),scrollIntoView:!0})),!0}}const sct=({state:e,dispatch:t})=>e.field(_y,!1)?(t(e.update({effects:Ob.of(null)})),!0):!1,lct=z$e(1),cct=z$e(-1),uct=[{key:"Tab",run:lct,shift:cct},{key:"Escape",run:sct}],zL=mt.define({combine(e){return e.length?e[0]:uct}}),Oct=LO.highest(Fk.compute([zL],e=>e.facet(zL)));function gr(e,t){return Object.assign(Object.assign({},t),{apply:oct(e)})}const dct=Pt.domEventHandlers({mousedown(e,t){let n=t.state.field(_y,!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:cW(n.ranges,i.field),effects:Ob.of(n.ranges.some(a=>a.field>i.field)?new ng(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),ky={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},Yd=Qn.define({map(e,t){let n=t.mapPos(e,-1,Mi.TrackAfter);return n??void 0}}),uW=new class extends gf{};uW.startSide=1;uW.endSide=-1;const A$e=eo.define({create(){return Sn.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(Yd)&&(e=e.update({add:[uW.range(n.value,n.value+1)]}));return e}});function r0n(){return[hct,A$e]}const OX="()[]{}<>«»»«[]{}";function U$e(e){for(let t=0;t<OX.length;t+=2)if(OX.charCodeAt(t)==e)return OX.charAt(t+1);return Ige(e<128?e:e+1)}function W$e(e,t){return e.languageDataAt("closeBrackets",t)[0]||ky}const fct=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),hct=Pt.inputHandler.of((e,t,n,r)=>{if((fct?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Rc(yo(r,0))==1||t!=i.from||n!=i.to)return!1;let a=mct(e.state,r);return a?(e.dispatch(a),!0):!1}),pct=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=W$e(e,e.selection.main.head).brackets||ky.brackets,i=null,a=e.changeByRange(o=>{if(o.empty){let s=gct(e.doc,o.head);for(let l of r)if(l==s&&nP(e.doc,o.head)==U$e(yo(l,0)))return{changes:{from:o.head-l.length,to:o.head+l.length},range:Le.cursor(o.head-l.length)}}return{range:i=o}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},i0n=[{key:"Backspace",run:pct}];function mct(e,t){let n=W$e(e,e.selection.main.head),r=n.brackets||ky.brackets;for(let i of r){let a=U$e(yo(i,0));if(t==i)return a==i?vct(e,i,r.indexOf(i+i+i)>-1,n):$ct(e,i,a,n.before||ky.before);if(t==a&&N$e(e,e.selection.main.from))return yct(e,i,a)}return null}function N$e(e,t){let n=!1;return e.field(A$e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nP(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Rc(yo(n,0)))}function gct(e,t){let n=e.sliceString(t-2,t);return Rc(yo(n,0))==n.length?n:n.slice(1)}function $ct(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:Yd.of(o.to+t.length),range:Le.range(o.anchor+t.length,o.head+t.length)};let s=nP(e.doc,o.head);return!s||/\s/.test(s)||r.indexOf(s)>-1?{changes:{insert:t+n,from:o.head},effects:Yd.of(o.head+t.length),range:Le.cursor(o.head+t.length)}:{range:i=o}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function yct(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nP(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:Le.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function vct(e,t,n,r){let i=r.stringPrefixes||ky.stringPrefixes,a=null,o=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:t,from:s.to}],effects:Yd.of(s.to+t.length),range:Le.range(s.anchor+t.length,s.head+t.length)};let l=s.head,c=nP(e.doc,l),u;if(c==t){if(AL(e,l))return{changes:{insert:t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)};if(N$e(e,l)){let f=n&&e.sliceDoc(l,l+t.length*3)==t+t+t?t+t+t:t;return{changes:{from:l,to:l+f.length,insert:f},range:Le.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=UL(e,l-2*t.length,i))>-1&&AL(e,u))return{changes:{insert:t+t+t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=Jo.Word&&UL(e,l,i)>-1&&!bct(e,l,t,i))return{changes:{insert:t+t,from:l},effects:Yd.of(l+t.length),range:Le.cursor(l+t.length)}}return{range:a=s}});return a?null:e.update(o,{scrollIntoView:!0,userEvent:"input.type"})}function AL(e,t){let n=Mn(e).resolveInner(t+1);return n.parent&&n.from==t}function bct(e,t,n,r){let i=Mn(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 UL(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=Jo.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))!=Jo.Word)return a}return-1}function a0n(e={}){return[tct,Ia,Ci.of(e),Jlt,xct,C$e]}const wct=[{key:"Ctrl-Space",run:CL},{mac:"Alt-`",run:CL},{key:"Escape",run:Flt},{key:"ArrowDown",run:Dw(!0)},{key:"ArrowUp",run:Dw(!1)},{key:"PageDown",run:Dw(!0,"page")},{key:"PageUp",run:Dw(!1,"page")},{key:"Enter",run:Llt}],xct=LO.highest(Fk.computeN([Ci],e=>e.facet(Ci).defaultKeymap?[wct]:[]));class iQ{static create(t,n,r,i,a){let o=i+(i<<8)+t+(n<<4)|0;return new iQ(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=[[Vt.contextHash,i]]}addChild(t,n){t.prop(Vt.contextHash)!=this.hash&&(t=new pn(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 pn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,o)=>new pn(fi.none,i,a,o,this.hashProp)})}}var Fe;(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"})(Fe||(Fe={}));class Sct{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let Qct=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 x$(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 WL(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==Fe.OrderedList?fW:dW)(n,t,!1);return r>0&&(e.type!=Fe.BulletList||OW(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const Y$e={[Fe.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(yn(Fe.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(ps(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[Fe.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[Fe.OrderedList]:WL,[Fe.BulletList]:WL,[Fe.Document](){return!0}};function ps(e){return e==32||e==9||e==10||e==13}function x$(e,t=0){for(;t<e.length&&ps(e.charCodeAt(t));)t++;return t}function NL(e,t,n){for(;t>n&&ps(e.charCodeAt(t-1));)t--;return t}function G$e(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 I$e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function OW(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(!ps(a))return-1}return n&&e.next==45&&V$e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(B$e.SetextHeading)>-1||r<3?-1:1}function Z$e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function dW(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||ps(e.text.charCodeAt(e.pos+1)))&&(!n||Z$e(t,Fe.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function fW(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&&!ps(e.text.charCodeAt(r+1))||n&&!Z$e(t,Fe.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function D$e(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 V$e(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&&ps(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const zC=/^[ \t]*$/,M$e=/-->/,L$e=/\?>/,AC=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,M$e],[/^\s*<\?/,L$e],[/^\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,zC],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,zC]];function F$e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=AC.length-(n?1:0);i<a;i++)if(AC[i][0].test(r))return i;return-1}function YL(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 gd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==Fe.CodeText?e[r].to=n:e.push(yn(Fe.CodeText,t,n))}const Vw={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(gd(o,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){gd(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==Fe.CodeText?gd(o,c.from,c.to):o.push(c);s=[]}gd(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&&gd(o,l,a)}}return s.length&&(s=s.filter(l=>l.type!=Fe.CodeText),s.length&&(t.markers=s.concat(t.markers))),e.addNode(e.buffer.writeElements(o,-i).finish(Fe.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=G$e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,o=t.skipSpace(n),s=NL(t.text,t.text.length,o),l=[yn(Fe.CodeMark,r,r+a)];o<s&&l.push(yn(Fe.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(yn(Fe.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||gd(l,e.lineStart-1,e.lineStart);for(let p of t.markers)l.push(p);let O=e.lineStart+t.basePos,f=e.lineStart+t.text.length;O<f&&gd(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(Fe.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=I$e(t);return n<0?!1:(e.startContext(Fe.Blockquote,t.pos),e.addNode(Fe.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(OW(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(Fe.HorizontalRule,n),!0},BulletList(e,t){let n=dW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.BulletList&&e.startContext(Fe.BulletList,t.basePos,t.next);let r=YL(t,t.pos+1);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=fW(t,e,!1);if(n<0)return!1;e.block.type!=Fe.OrderedList&&e.startContext(Fe.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=YL(t,t.pos+n);return e.startContext(Fe.ListItem,t.basePos,r-t.baseIndent),e.addNode(Fe.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=D$e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=NL(t.text,t.text.length,r),o=a;for(;o>r&&t.text.charCodeAt(o-1)==t.next;)o--;(o==a||o==r||!ps(t.text.charCodeAt(o-1)))&&(o=t.text.length);let s=e.buffer.write(Fe.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,o),i+n+1),-i);o<t.text.length&&s.write(Fe.HeaderMark,o-r,a-r);let l=s.finish(Fe.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=F$e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=AC[n][1],a=[],o=i!=zC;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==M$e?Fe.CommentBlock:i==L$e?Fe.ProcessingInstructionBlock:Fe.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(s,l-r),r),!0},SetextHeading:void 0};class _ct{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+`
905
905
  `+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)&&x$(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,yn(Fe.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(aye(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(yn(Fe.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(rye(t,x$(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=x$(t,this.pos),r=0;if(n>this.pos){let i=iye(t,n,this.start);if(i){let a=dX(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=dX(t,this.pos)),r>0&&r<t.length?r:-1}else return dX(t,this.pos)}}}function dX(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!ps(n))return-1}return t}class kct{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:V$e(n),a=n.next;if(i<0)return!1;let o=yn(Fe.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,yn(a==61?Fe.SetextHeading1:Fe.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),o])),!0}finish(){return!1}}const B$e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new _ct(t):null},SetextHeading(){return new kct}},Pct=[(e,t)=>D$e(t)>=0,(e,t)=>G$e(t)>=0,(e,t)=>I$e(t)>=0,(e,t)=>dW(t,e,!0)>=0,(e,t)=>fW(t,e,!0)>=0,(e,t)=>OW(t,e,!0)>=0,(e,t)=>F$e(t,e,!0)>=0],Tct={text:"",end:0};class Xct{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new Qct,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=iQ.create(Fe.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new jct(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 Sct(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+=`
906
906
  `+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=oye(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=Tct;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 "+Fe[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==`
907
907
  `?"":n;else{let i=n.indexOf(`
@@ -939,7 +939,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
939
939
  `)?{...i,capture:o}:{...i,capture:dp(o,i.buffer,i.caret,"typing")}}return pN(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function jQ(e){return Ya(e)?{arm:e.arm,typingAt:null,value:""}:e}function b4t(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 w4t(e,t,n,r,i){const a=b4t(t,n),o=Kf(e);let s={capture:e,buffer:n,caret:r};if(a.inserted!==""&&o!==null&&a.top<=o.end&&a.bottom>=o.start)s={capture:jQ(e),buffer:n,caret:r};else{const l=pN(e,n,r,a);l?s=l:Ya(e)&&a.inserted.includes(`
940
940
  `)&&(s={capture:jQ(e),buffer:n,caret:r})}return{...s,capture:dp(s.capture,s.buffer,s.caret,i)}}function x4t(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,o=Kf(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=KQe(i,t.value),c=l+CP,u=n.slice(0,s)+c+n.slice(o.end);return{minted:!0,capture:Za,buffer:u,caret:s+c.length,payload:{index:i,key:JQe(a,e.draw),value:t.value,marker:l}}}const S4t=e=>Ya(e)&&e.value!=="";function Q4t(e,t){const n=Kf(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:Za,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 _4t(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function k4t(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,o=Kf(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:jQ(e),buffer:i,caret:a,payload:null}}function P4t(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=pN(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=Kn(i);if(!a)return i===""?null:k4t(t,n,e.selection,i);const o=t.arm,s=KQe(e.index,a),l=s+CP,c=n.slice(0,o.start)+l+n.slice(o.end);return{kind:"minted",capture:Za,buffer:c,caret:o.start+l.length,payload:{index:e.index,key:JQe(e.taken,e.draw),value:a,marker:s}}}const HQe=e=>`${p4t(e)} chars`,KQe=(e,t)=>`[Credential #${e}, ${HQe(t)}]`;function T4t(e){Rl.lastIndex=0;const t=Rl.exec(e);return Rl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function X4t(e){Rl.lastIndex=0;const t=Rl.exec(e);if(Rl.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 Sb(e,t){if(T4t(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const ER=/\[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,qR=/\[credential NOT stored \u2014 [^\]\n]*\]/y,jR=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,R4t=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&W6.test(t[1])?t[1]:""};function E4t(e,t){if(e.charCodeAt(t)!==91)return null;ER.lastIndex=t;const n=ER.exec(e);if(ER.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};qR.lastIndex=t;const r=qR.exec(e);if(qR.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};jR.lastIndex=t;const i=jR.exec(e);return jR.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:R4t(i[0])}:null}function zP(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=E4t(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 mJ(e,t){const n=[];for(const r of t){const i=Sb(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 q4t(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 j4t=e=>`[credential ${e.key} (${HQe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function C4t(e,t,n=new Map){const r=[...t],i=[];for(const o of r){const s=Sb(e,o);s!==null&&i.push({span:s,payload:o})}for(const o of MQe(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?q4t(l??"lost",s?.key):j4t(s);a=a.slice(0,o.start)+c+a.slice(o.end)}return a}const z4t=(e,t,n)=>h("ui.chat.credential_notice.cleared",{key:e,index:t,undoCap:n}),A4t=e=>h("ui.chat.credential_notice.clear_label",{index:e}),U4t=(e,t)=>h("ui.chat.credential_notice.chip_title",{index:e,chars:t}),W4t=(e,t,n)=>z4t(e,t,n),N4t=()=>h("ui.chat.credential_notice.undo"),Y4t=e=>h("ui.notices.credentials.removed",{index:e}),G4t=e=>e.unredacted!==null?e.unredacted:e.armed?F4t():e.cleared!==null?W4t(e.cleared.key,e.cleared.index,e.undoCap):null;function I4t(e){const{buffer:t,payload:n}=e,r=Sb(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===CP?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 Z4t(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 gJ=e=>h("ui.notices.credentials.stored",{keys:Vs(e)});function $J(e){return h("ui.notices.credentials.unstored",{count:e.length,keys:Vs([...e].sort())})}const D4t=()=>h("ui.chat.credential_notice.unconfirmed_alone"),V4t=e=>e===""?D4t():h("ui.chat.credential_notice.unconfirmed_labelled",{key:e}),M4t=()=>h("ui.chat.credential_notice.operator_move"),L4t=e=>`${e} ${M4t()}`;function yJ(e){return h("ui.notices.credentials.unconfirmed",{count:e.length,keys:Vs([...e].sort())})}const F4t=()=>h("ui.chat.credential_notice.armed"),B4t=()=>h("ui.chat.credential_notice.typing"),H4t=()=>h("ui.chat.credential_notice.empty_span"),K4t=()=>h("ui.chat.credential_notice.escape_held"),J4t=()=>h("ui.chat.credential_notice.discarded"),eEt=()=>h("ui.chat.credential_notice.empty_span_draft"),tEt=e=>h("ui.chat.credential_notice.unredacted",{length:e});function nEt(e,t){const n=Kf(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const vJ=(e,t)=>e&&e.over===t?e.chars:null,rEt=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},iEt=16,aEt=16;function JQe(e=[],t=rEt){const n=new Set(e);for(let r=0;r<iEt;r++){const i=hJ+bJ(8,t);if(!n.has(i))return i}return hJ+bJ(aEt,t)}const bJ=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=fJ[t(fJ.length)];return n},oEt=8,sEt=256,lEt=/^[/@$#]/,cEt=/^\w+:\/\//,uEt=/^[A-Za-z]+$/,OEt=/^\d+$/,dEt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],fEt=3,hEt=20,pEt=/^[A-Za-z0-9_\-+/=.]+$/,mEt=new RegExp(`^[^${tu}@]+@[^${tu}@]+\\.[A-Za-z]{2,}$`),gEt=/^[\w.-]+(?:\/[\w.-]+)+$/,$Et=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,yEt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,vEt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,bEt=/^[\w.-]+:\d{2,5}$/,wEt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,xEt=/^[a-z]+(?:_[a-z]+)+$/,SEt=/^[a-z]+(?:-[a-z]+)+$/,QEt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,_Et=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,kEt=/\d{4,}/,wJ=e=>{const t=e.trim();return t.length<oEt||t.length>sEt||Ms.test(t)||lEt.test(t)||cEt.test(t)||n8(t)!==null||mEt.test(t)||gEt.test(t)||$Et.test(t)||yEt.test(t)||vEt.test(t)||bEt.test(t)||wEt.test(t)||xEt.test(t)||SEt.test(t)||QEt.test(t)||_Et.test(t)&&kEt.test(t)||uEt.test(t)||OEt.test(t)?!1:dEt.filter(r=>r.test(t)).length>=fEt?!0:t.length>=hEt&&pEt.test(t)},e_e=X("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),t_e=X("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),PEt=({chars:e})=>(be(),d.jsx("span",{className:"shrink-0",children:h("ui.chat.credential_notice.chip_chars",{chars:e})})),n_e=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:o,style:s,small:l=!1})=>d.jsxs("span",{className:X("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?t_e:e_e,l?"text-body-sm":"text-body",o),title:r,style:s,children:[n==="warning"?d.jsx(ak,{"aria-hidden":"true",className:"size-3 shrink-0"}):d.jsx(Pze,{"aria-hidden":"true",className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&d.jsx(PEt,{chars:t}),i&&d.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:d.jsx(Zr,{"aria-hidden":"true",className:"size-3"})}),r&&d.jsx("span",{className:"sr-only",children:r})]}),Yy="#lo-credential/",TEt=`${Yy}unstored`,xJ=`${Yy}unconfirmed`,XEt=/^\d+$/,r_e=e=>e.kind==="stored"?`${Yy}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${xJ}/${e.key}`:xJ:TEt;function REt(e){if(!e||!e.startsWith(Yy))return null;const t=e.slice(Yy.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return W6.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!W6.test(r)||!XEt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function SJ(e,t){const n=REt(e);if(n===null)return null;const r=zP(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return r_e(i)!==e?null:n}const AP=()=>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=zP(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:r_e(s),title:s.text,children:[{type:"text",value:s.text}]})}}i&&(n.children=r)};t(e)},EEt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?V4t(e.key):h("ui.chat.page_chrome.credential_not_stored"),qEt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?L4t(t):t,jEt=({citation:e,title:t})=>(be(),d.jsx(n_e,{tone:e.kind==="stored"?"live":"warning",label:EEt(e),chars:e.kind==="stored"?e.chars:null,title:qEt(e,t),className:"align-middle"})),CEt=(e,t)=>typeof t=="string"?SJ(e,t):t==null?SJ(e,""):null,zEt=e=>({href:t,title:n,children:r})=>{const i=CEt(t,r);if(i===null){const a=e;return d.jsx(a,{href:t,title:n,children:r})}return d.jsx(jEt,{citation:i,title:n})},i_e=e=>Drt(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")||ape(e)?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",mN=e=>{const t=i_e(e);return t==="other"?"path":t},CR={id:"open-file",get label(){return h("ui.common.file_actions.open_file")}},AEt={id:"show-in-canvas",get label(){return h("ui.common.file_actions.show_in_canvas")}},UEt={id:"save-as",get label(){return h("ui.chat.image_actions.save_as")}},zR={id:"open-folder",get label(){return h("ui.common.file_actions.open_folder")}},AR={id:"copy-file-path",get label(){return h("ui.common.file_actions.copy_file_path")}},Uh={id:"copy-image",get label(){return h("ui.chat.image_actions.copy_image")}},WEt={id:"copy-image-url",get label(){return h("ui.chat.image_actions.copy_image_url")}},NEt={id:"open-in-browser",get label(){return h("ui.chat.image_actions.open_in_browser")}};function a_e(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const o=[...t?[AEt]:[],...a?[{id:"expand-image",get label(){return h("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...o,...i?[CR,zR,AR]:[],UEt,...r==="video"||r==="audio"?[]:[Uh]];case"path":return[...o,CR,zR,AR,...r==="video"||r==="audio"?[]:[Uh]];case"data":return[...o,Uh];case"blob":return i?[...o,CR,zR,AR,Uh]:[Uh];case"http":return[...YEt(n)?[Uh]:[],WEt,NEt];case"other":return[]}}const o_e=(e,t)=>a_e(e,t).length>0;function YEt(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 gN=e=>e.startsWith("file://")?e.slice(7):e;function s_e(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 QJ(e,t,n){if(e==="data")return s_e(t);if(e==="blob"){const o=jOe(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=gN(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:Tk(i)})}const GEt=e=>e.trim().toLowerCase()!=="image/png";async function IEt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!GEt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await ZEt(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 ZEt(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 DEt=6e4;function VEt(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),DEt)}const MEt=32*1024*1024;function f0n(e,t){if(!e.remote)return null;const n=e.origin_device??null;return{fileId:e.id,sessionId:t,deviceName:n?.name||n?.id||"",readKind:e.remote_read?.kind??null,unreadable:e.remote_unreadable??(e.remote_read?null:"outside_session_files"),ownerPath:e.ref.type==="path"?e.ref.path:null,sizeBytes:e.size_bytes}}function UP(e){const t=e.deviceName;switch(e.unreadable){case"missing":return h("ui.canvas.files.remoteReason.missing",{device:t});case"too_large":return h("ui.canvas.files.remoteReason.tooLarge",{device:t});case"sensitive":return h("ui.canvas.files.remoteReason.sensitive",{device:t});case"not_referenced":return h("ui.canvas.files.remoteReason.notReferenced",{device:t});default:return h("ui.canvas.files.remoteReason.workspace",{device:t})}}function LEt(e){return e.sizeBytes===null||e.sizeBytes<=MEt}function FEt(e){return h("ui.canvas.files.remoteTooLargeToOpen",{device:e.deviceName})}function h0n(e){return e.unreadable?UP(e):null}function p0n(e,t){return t?void 0:e}function l_e(e){return e?h("ui.canvas.files.remoteUnreachable",{device:e}):h("ui.canvas.files.remoteUnreachableUnnamed")}function m0n(e,{mediaKind:t,canShowInCanvas:n,canExpand:r,landedPath:i}){const a=e.deviceName,o=e.ownerPath,s=o?[{id:"copy-owner-path",label:h("ui.canvas.files.remoteCopyOwnerPath",{device:a}),disabledReason:null,target:o}]:[];if(e.unreadable){const u=UP(e);return[...n?[{id:"show-in-canvas",label:h("ui.common.file_actions.show_in_canvas"),disabledReason:u,target:null}]:[],{id:"download",label:h("ui.canvas.files.remoteDownload"),disabledReason:u,target:null},...s,{id:"save-as",label:h("ui.chat.image_actions.save_as"),disabledReason:u,target:null}]}const l=LEt(e),c=[];return n&&c.push({id:"show-in-canvas",label:h("ui.common.file_actions.show_in_canvas"),disabledReason:l?null:FEt(e),target:null}),r&&t==="image"&&c.push({id:"expand-image",label:h("ui.chat.image_actions.expand_image"),disabledReason:null,target:null}),i?c.push({id:"open-file",label:h("ui.common.file_actions.open_file"),disabledReason:null,target:i},{id:"open-folder",label:h("ui.common.file_actions.open_folder"),disabledReason:null,target:i},{id:"copy-file-path",label:h("ui.common.file_actions.copy_file_path"),disabledReason:null,target:i}):c.push({id:"download",label:h("ui.canvas.files.remoteDownload"),disabledReason:null,target:null},...s),l&&(c.push({id:"save-as",label:h("ui.chat.image_actions.save_as"),disabledReason:null,target:null}),t==="image"&&c.push({id:"copy-image",label:h("ui.chat.image_actions.copy_image"),disabledReason:null,target:null})),c}function g0n(e){if(e.unsupported_reason==="peer_update_required"){const t=e.device_name||null,n=t??h("ui.canvas.files.remoteDeviceFallback"),r=h("ui.canvas.files.remotePeerUpdate",{device:n});return t?`${r}
941
941
  ${h("ui.canvas.files.remotePeerUpdateHow",{device:n})}`:r}return BEt}const BEt="Remote files cannot be opened on this device.",HEt={"expand-image":d.jsx(uOe,{"aria-hidden":"true"}),"open-file":d.jsx(Wv,{"aria-hidden":"true"}),"show-in-canvas":d.jsx(cOe,{"aria-hidden":"true"}),"save-as":d.jsx(ck,{"aria-hidden":"true"}),"open-folder":d.jsx(Dp,{"aria-hidden":"true"}),"copy-file-path":d.jsx(UA,{"aria-hidden":"true"}),"copy-image":d.jsx(YO,{"aria-hidden":"true"}),"copy-image-url":d.jsx(Eze,{"aria-hidden":"true"}),"open-in-browser":d.jsx(Zp,{"aria-hidden":"true"})},_J=(e,t,n)=>n instanceof Xk?t:n instanceof Fp?l_e(""):e;function KEt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:o,saveName:s}){return a_e(mN(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!o}).filter(l=>(l.id!=="save-as"||!!s)&&(!r||l.id==="copy-file-path"))}const c_e=({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:f,resolveBytes:p,tooltip:m=h("ui.chat.image_actions.actions"),"aria-label":g})=>{be();const y=mN(e),v=KEt({file:e,src:t,resolvePath:s,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:f});if(v.length===0)return null;const b=async(_,k,R)=>{try{await navigator.clipboard.writeText(_),Ls(k)}catch(E){console.error(`${R}: `,E),Jn(R)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const _=p?await p():await QJ(y,e,t),k=await IEt(_);await navigator.clipboard.write([new ClipboardItem({[k.type]:k})]),Ls(h("ui.notices.files.image_copied"))}catch(_){console.error("Failed to copy image: ",_),Jn(_J(h("ui.notices.files.image_copy_failed"),h("ui.notices.files.image_copy_failed_gone"),_))}},Q=async()=>{try{const _=p?await p():await QJ(y,e,t);VEt(_,f??"download")}catch(_){console.error("Failed to save file: ",_),Jn(_J(h("ui.notices.files.save_failed"),h("ui.notices.files.save_failed_gone"),_))}},w=async _=>{let k=gN(e);if(s&&["open-file","open-folder","copy-file-path"].includes(_.id))try{k=await s()}catch{Jn(h("ui.canvas.files.prepareError"));return}switch(_.id){case"expand-image":O?.();return;case"open-file":Ou(k);return;case"open-folder":EP(k);return;case"show-in-canvas":c?.();return;case"copy-file-path":b(k,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":Q();return;case"copy-image-url":b(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":dN(t??e);return}},S=g??(n!=null?h("ui.common.actions.actions_for_name",{name:n}):h("ui.chat.image_actions.actions"));return d.jsxs(ok,{open:r,onOpenChange:i,children:[d.jsx($t,{content:m,children:d.jsx(sk,{asChild:!0,children:d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":S,tabIndex:o,onClick:_=>_.stopPropagation(),children:d.jsx(hS,{"aria-hidden":"true"})})})}),d.jsxs(lk,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:_=>_.stopPropagation(),children:[s&&d.jsx("div",{role:"note",className:X("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:h("ui.canvas.files.pathCopyNote")}),v.map(_=>d.jsxs(Lo,{onSelect:()=>w(_),children:[HEt[_.id],d.jsx("span",{children:_.label})]},_.id))]})]})},JEt=({src:e,alt:t,title:n,className:r})=>{const i=wb(),a=e??"",o=i_e(a);if(o==="other")return d.jsx("img",{src:e,alt:t,title:n,className:r});const s=i!==null&&o==="path",l=o_e(o,{canShowInCanvas:s,source:a});return d.jsxs("span",{className:X("group/mdimg relative inline-block max-w-full"),children:[d.jsx("img",{src:e,alt:t,title:n,className:r}),l&&d.jsx("span",{"data-markdown-image":"",className:X("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:d.jsx(c_e,{file:a,src:e,label:t,onShowInCanvas:s&&i?()=>{i.openInCanvas(a).then(c=>{c||Ou(gN(a))})}:void 0})})]})};function eqt(){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 tqt={tokenize:nqt,concrete:!0,name:"mathFlow"},kJ={tokenize:rqt,partial:!0};function nqt(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(b){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(b)}function l(b){return b===36?(e.consume(b),o++,l):o<2?n(b):(e.exit("mathFlowFenceSequence"),un(e,c,"whitespace")(b))}function c(b){return b===null||xt(b)?O(b):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(b))}function u(b){return b===null||xt(b)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(b)):b===36?n(b):(e.consume(b),u)}function O(b){return e.exit("mathFlowFence"),r.interrupt?t(b):e.attempt(kJ,f,y)(b)}function f(b){return e.attempt({tokenize:v,partial:!0},y,p)(b)}function p(b){return(a?un(e,m,"linePrefix",a+1):m)(b)}function m(b){return b===null?y(b):xt(b)?e.attempt(kJ,f,y)(b):(e.enter("mathFlowValue"),g(b))}function g(b){return b===null||xt(b)?(e.exit("mathFlowValue"),m(b)):(e.consume(b),g)}function y(b){return e.exit("mathFlow"),t(b)}function v(b,x,Q){let w=0;return un(b,S,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function S(R){return b.enter("mathFlowFence"),b.enter("mathFlowFenceSequence"),_(R)}function _(R){return R===36?(w++,b.consume(R),_):w<o?Q(R):(b.exit("mathFlowFenceSequence"),un(b,k,"whitespace")(R))}function k(R){return R===null||xt(R)?(b.exit("mathFlowFence"),x(R)):Q(R)}}}function rqt(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 iqt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:aqt,previous:oqt,name:"mathText"};function r(i,a,o){let s=0,l,c;return u;function u(g){return i.enter("mathText"),i.enter("mathTextSequence"),O(g)}function O(g){return g===36?(i.consume(g),s++,O):s<2&&!n?o(g):(i.exit("mathTextSequence"),f(g))}function f(g){return g===null?o(g):g===36?(c=i.enter("mathTextSequence"),l=0,m(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),f):xt(g)?(i.enter("lineEnding"),i.consume(g),i.exit("lineEnding"),f):(i.enter("mathTextData"),p(g))}function p(g){return g===null||g===32||g===36||xt(g)?(i.exit("mathTextData"),f(g)):(i.consume(g),p)}function m(g){return g===36?(i.consume(g),l++,m):l===s?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",p(g))}}}function aqt(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 oqt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function sqt(e){return{flow:{36:tqt},text:{36:iqt()}}}function u_e(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}const El=92,lqt=40,cqt=41,O_e=91,$N=93,Y6=32,wO=e=>e!==null&&e<-2,js=e=>e===Y6||e===-2||e===-1,d_e=e=>e===94||e===95||e===123||e===125,f_e=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122||e===123||e===125),UR=new WeakMap,PJ=new WeakMap,h_e=e=>Object.prototype.hasOwnProperty.call(e,"interrupt")?Object.getPrototypeOf(e):e,G6="mathTextDisplay";function uqt(e,t,n){let r=cqt,i=!1,a,o=!1,s=!1,l=0,c;const u=this,O={tokenize:_,partial:!0};return f;function f(k){return k!==El?n(k):(l=u.now().offset,c=h_e(u),a=e.enter("mathText"),e.enter("mathTextSequence"),e.consume(k),p)}function p(k){if(k===O_e)r=$N,i=!0,a.type=G6;else if(k!==lqt)return n(k);const R=UR.get(c)?.get(r);return R!==void 0&&l>R?n(k):(e.consume(k),e.exit("mathTextSequence"),m)}function m(k){return k===null?x(k):k===El?e.check(O,w,g)(k):k===Y6?(e.enter("space"),e.consume(k),e.exit("space"),m):wO(k)?(e.enter("lineEnding"),e.consume(k),e.exit("lineEnding"),m):g(k)}function g(k){return e.enter("mathTextData"),k===El?v(k):y(k)}function y(k){return k===null||k===Y6||wO(k)?(e.exit("mathTextData"),m(k)):k===El?e.check(O,Q,v)(k):(o=!0,d_e(k)&&(s=!0),e.consume(k),y)}function v(k){return o=!0,e.consume(k),b}function b(k){return k===null||wO(k)||js(k)?y(k):(f_e(k)&&(s=!0),e.consume(k),y)}function x(k){let R=UR.get(c);R||(R=new Map,UR.set(c,R));const E=R.get(r);return(E===void 0||l<E)&&R.set(r,l),n(k)}function Q(k){return e.exit("mathTextData"),w(k)}function w(k){return!o||i&&!s?n(k):(e.enter("mathTextSequence"),e.consume(k),S)}function S(k){return e.consume(k),e.exit("mathTextSequence"),e.exit(a.type),t}function _(k,R,E){return T=>(k.enter("mathTextSequence"),k.consume(T),q=>q!==r?E(q):(k.consume(q),k.exit("mathTextSequence"),R))}}const Oqt={name:"mathTextBackslash",tokenize:uqt,resolve:u_e},dqt={partial:!0,tokenize(e,t,n){return r=>r===null?t(r):(e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),i=>this.parser.lazy[this.now().line]?n(i):t(i))}},TJ={partial:!0,tokenize(e,t,n){return a=>(e.enter("mathFlowFenceSequence"),e.consume(a),o=>o!==$N?n(o):(e.consume(o),e.exit("mathFlowFenceSequence"),r));function r(a){return js(a)?(e.enter("whitespace"),i(a)):a===null||wO(a)?t(a):n(a)}function i(a){return js(a)?(e.consume(a),i):(e.exit("whitespace"),a===null||wO(a)?t(a):n(a))}}};function fqt(e,t,n){const r=this.events[this.events.length-1],i=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0;let a=!1,o=!1,s=0,l=!1;const c=this,u=h_e(this);let O=0;return f;function f(z){if(z!==El)return n(z);O=c.now().offset;const U=PJ.get(u);return U&&O>U[0]&&O<U[1]?n(z):(e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(z),p)}function p(z){return z!==O_e?n(z):(e.consume(z),e.exit("mathFlowFenceSequence"),m)}function m(z){return js(z)?(e.enter("whitespace"),g(z)):y(z)}function g(z){return js(z)?(e.consume(z),g):(e.exit("whitespace"),y(z))}function y(z){return z===null?b(z):(e.exit("mathFlowFence"),o=!0,w(z))}function v(z){return o?e.attempt(dqt,x,b)(z):b(z)}function b(z){return l||PJ.set(u,[O,c.now().offset]),n(z)}function x(z){return o=!1,s=i,s>0&&js(z)?(e.enter("linePrefix"),Q(z)):w(z)}function Q(z){return s>0&&js(z)?(s--,e.consume(z),Q):(e.exit("linePrefix"),w(z))}function w(z){return z===null?b(z):wO(z)?v(z):z===El?e.check(TJ,T,S)(z):S(z)}function S(z){return e.enter("mathFlowValue"),z===El?k(z):_(z)}function _(z){return z===null||wO(z)?(e.exit("mathFlowValue"),w(z)):z===El?e.check(TJ,E,k)(z):(js(z)||(o=!0),d_e(z)&&(a=!0),e.consume(z),_)}function k(z){return o=!0,e.consume(z),R}function R(z){return z===null||wO(z)||js(z)?_(z):z===$N?(l=!0,n(z)):(f_e(z)&&(a=!0),e.consume(z),_)}function E(z){return e.exit("mathFlowValue"),T(z)}function T(z){return a?(e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(z),q):(l=!0,n(z))}function q(z){return e.consume(z),e.exit("mathFlowFenceSequence"),A}function A(z){return js(z)?(e.enter("whitespace"),G(z)):I(z)}function G(z){return js(z)?(e.consume(z),G):(e.exit("whitespace"),I(z))}function I(z){return e.exit("mathFlowFence"),e.exit("mathFlow"),t(z)}}const hqt={name:"mathFlowBracket",tokenize:fqt,concrete:!0},pqt={flow:{[El]:[hqt]},text:{[El]:[Oqt]}},mqt={enter:{[G6](e){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-display"]},hChildren:[]}},e),this.buffer()}},exit:{[G6](e){const t=this.resume(),n=this.stack[this.stack.length-1];this.exit(e),n.value=t,n.data.hChildren.push({type:"text",value:t})}}},fp=36,XJ=e=>e!==null&&e<-2,RJ=e=>e===null||e===32||e<0,EJ=e=>e!==null&&e>=48&&e<=57,qJ=92,gqt=e=>e===94||e===95||e===123||e===125,jJ=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122),$qt=e=>e===44||e===46||e===59||e===58||e===33||e===63,yqt=96,p_e=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:u_e,previous:vqt,name:"mathText"};function n(r,i,a){const o=this;let s=0,l=null,c=!1,u=!1,O=!1,f=0,p=0,m="letters",g=!1,y=!1,v=!1,b,x;return Q;function Q(T){return r.enter("mathText"),r.enter("mathTextSequence"),w(T)}function w(T){return T===fp?(r.consume(T),s++,w):s<2&&!t||s===1&&RJ(T)?a(T):(c=s===1&&EJ(T),r.exit("mathTextSequence"),S(T))}function S(T){return T===null?a(T):T===fp?(x=r.enter("mathTextSequence"),b=0,l=o.previous,E(T)):T===32?(r.enter("space"),r.consume(T),r.exit("space"),S):XJ(T)?(r.enter("lineEnding"),r.consume(T),r.exit("lineEnding"),S):(r.enter("mathTextData"),p=0,m="letters",R(T))}function _(){const T=m!=="other"&&p>=2&&f===0;T&&g&&(y=!0),g=T}function k(T,q){T===yqt&&(v=!0),!q&&T===123&&f++,!q&&T===125&&f>0&&f--,m==="letters"&&!q&&jJ(T)?p++:m==="letters"&&p>=2&&$qt(T)?m="punct":m="other"}function R(T){return T===null||T===32||T===fp||XJ(T)?(O=!1,_(),r.exit("mathTextData"),S(T)):(k(T,O||T===qJ),O?(u=!0,O=!1):T===qJ?O=!0:gqt(T)&&(u=!0),r.consume(T),R)}function E(T){return T===fp?(r.consume(T),b++,E):b===s?s===1&&(RJ(l)||EJ(T))||s===1&&c&&!u||s===1&&c&&(jJ(T)||T===95||v||y)?a(T):(r.exit("mathTextSequence"),r.exit("mathText"),i(T)):(x.type="mathTextData",R(T))}}};function vqt(e){return e!==fp||this.events[this.events.length-1][1].type==="characterEscape"}const bqt=sqt().flow,wqt=p_e();function WP(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?wqt:p_e(e);n.push({flow:bqt,text:{[fp]:i}}),n.push(pqt),r.push(eqt()),r.push(mqt)}const xqt=/\$(?!\d)(.+?)\$/,Sqt=/\$\$([\s\S]+?)\$\$/,Qqt=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,_qt=/\\[a-zA-Z]+(\{[^}]*\})?/,kqt=/\\\([\s\S]+?\\\)/,Pqt=/\\\[[\s\S]+?\\\]/,Tqt=/^ {0,3}(?:`{3,}|~{3,})[ \t]*math[ \t]*$/m,Xqt=/(?<![\\$])\$(?=\d)([^$]*)\$(?![\dA-Za-z_])/g,Rqt=/\\[^ \r\n$]|[\^_{}]/,Eqt=/[^ \t\r\n]$/,qqt=/^[A-Za-z]{2,}[,.;:!?]?$/,jqt=e=>{let t=0,n=!1,r=!1,i="";const a=()=>{if(i==="")return!1;const o=t===0&&qqt.test(i),s=o&&r;return r=o,i="",s};for(const o of e){if(o===" "||o===`
942
- `||o==="\r"){if(n=!1,a())return!0;continue}i+=n||o==="\\"?"\0":o,!n&&o==="{"&&t++,!n&&o==="}"&&t>0&&t--,n=!n&&o==="\\"}return a()},Cqt=e=>{const t=new RegExp(Xqt.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(Eqt.test(r)&&Rqt.test(r)&&!r.includes("`")&&!jqt(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},CJ=e=>xqt.test(e)||Sqt.test(e)||kqt.test(e)||Pqt.test(e)||Tqt.test(e)||Cqt(e)||Qqt.test(e)?!0:_qt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),zqt=e=>{const t=zP(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},Aqt=e=>zP(e).filter(t=>t.kind!=="text").length,Uqt=e=>{if(!CJ(e))return!1;const t=zqt(e);return t===null?!0:CJ(t)||t.includes("$")?!1:Aqt(e)<2},m_e=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),g_e=Object.freeze(RA.filter(e=>!["overlayShadow","scrim"].includes(e))),$_e=65536,y_e=/^#[0-9a-fA-F]{6}$/,Wqt=(e,t)=>Object.hasOwn(e,t),zJ=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),wa=e=>{throw new Error(e)},Nqt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},Gy=(e,t)=>{const n={...e};for(const r of m_e){const i=rqe(t.seeds?.[r]);if(!i)continue;const a=h2(e[r]),o=h2(i);n[r]=i;for(const s of Nqt[r]){const l=h2(e[s]);n[s]=iqe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=aqe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of g_e)y_e.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},yN=(e,t)=>tqe(e,t),$0n=(e,t)=>{const n=Gy(e,t),r=lqe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of g_e)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return yN(Gy(e,o),t.base).length?null:o},v_e=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>$_e)&&wa("import_size");let i;try{i=JSON.parse(e)}catch{wa("import_invalid_json")}zJ(i)||wa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&wa("import_unsafe"),i.format!=="local-operator-theme"&&wa("import_format"),i.version!==1&&wa("import_version"),(typeof i.base!="string"||!t(i.base))&&wa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&wa("import_name");const o={};for(const s of["seeds","overrides"]){(!Wqt(i,s)||!zJ(i[s]))&&wa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?m_e:RA).includes(c)||typeof u!="string")&&wa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||wa("import_roles"),l[c]=u):(y_e.test(u)||wa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},Yqt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>$_e*aS)&&wa("load_error");let n;try{n=JSON.parse(e)}catch{wa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||wa("load_error");const i=[],a=new Set;for(const o of r.slice(0,aS))try{const s=nqe(o,{isThemeName:t,isRole:c=>RA.includes(c)});if(!s||a.has(s.id))continue;const l=v_e(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},Gqt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),y0n=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=aS+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},v0n=(e,t)=>{const n=oqe({composed:!0,capturePairs:!0});return sqe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let WO={themes:[],error:!1,loading:!1};const I6=new Set,b_e=()=>{for(const e of I6)e()},AJ=()=>WO,Iqt=e=>(I6.add(e),()=>{I6.delete(e)}),UJ=()=>{try{WO={themes:Yqt(localStorage.getItem(pA),eue).filter(t=>{const n=OA(t.base)?.palette;return n&&yN(Gy(n,t),t.base).length===0}),error:!1,loading:!1}}catch{WO={themes:[],error:!0,loading:!1}}b_e()},vN=()=>$.useSyncExternalStore(Iqt,AJ,AJ),Zqt=e=>WO.themes.find(t=>t.id===e),w_e=e=>{localStorage.setItem(pA,JSON.stringify({version:1,themes:e})),WO={themes:e,error:!1,loading:!1},b_e()},b0n=e=>{const t=cqe(e.id);if(!t)throw new Error("invalid custom theme id");const n=v_e(Gqt(e),eue,{id:t,now:e.updatedAt}),r=OA(n.base)?.palette;if(!r||yN(Gy(r,n),n.base).length)throw new Error("contrast");if(!Zqt(n.id)&&WO.themes.length>=aS)throw new Error("limit");w_e([n,...WO.themes.filter(i=>i.id!==n.id)])},w0n=e=>w_e(WO.themes.filter(t=>t.id!==e));typeof window<"u"&&(UJ(),window.addEventListener("storage",e=>{(e.key===pA||e.key===null)&&UJ()}));const Dqt=()=>{const e=It(i=>i.themeName),t=It(i=>i.contrast),n=It(i=>i.accent),r=It(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},Vqt=e=>{const t=e?OA(e.base)?.palette:void 0;return t&&e?Gy(t,e):void 0},Mqt=()=>{const e=Dqt(),t=vN();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=Vqt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:uqe(e,r,i)}},[e,t])},NP=()=>Mqt().resolved,x0n=()=>NP().palette.mode==="dark",tn="var(--color-ink)",Oc="var(--color-ink-muted)",ml="var(--color-surface)",Zu="var(--color-elevated)",dc="var(--color-sunken)",ea="var(--color-hairline)",Du="var(--color-control)",Wh="var(--color-accent)",H0="var(--color-accent-wash)",Lqt="var(--color-accent-alt-wash)",Fqt="var(--color-on-accent)",Bqt="var(--color-info)",x_e="var(--color-info-wash)",Hqt="var(--color-success)",S_e="var(--color-success-wash)",Kqt="var(--color-warning)",Z6="var(--color-warning-wash)",Jqt="var(--color-warning-border)",WR="var(--color-danger)",D6="var(--color-danger-wash)",WJ=[H0,Lqt,x_e,S_e,Z6,D6],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),ejt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--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:ml,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:ea,tertiaryTextColor:tn,tertiaryBorderColor:ea,lineColor:Oc,arrowheadColor:Oc,textColor:tn,secondBkg:dc,border1:Du,border2:ea,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:Oc,titleColor:tn,noteBkgColor:Z6,noteBorderColor:Jqt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:ea,signalColor:Oc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:ea,labelTextColor:tn,loopTextColor:tn,activationBkgColor:H0,activationBorderColor:Wh,sequenceNumberColor:ml,sectionBkgColor:dc,sectionBkgColor2:ml,altSectionBkgColor:dc,excludeBkgColor:dc,taskBkgColor:H0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:Wh,activeTaskBkgColor:H0,activeTaskBorderColor:Wh,gridColor:ea,doneTaskBkgColor:dc,doneTaskBorderColor:ea,critBkgColor:D6,critBorderColor:WR,todayLineColor:Wh,transitionColor:Oc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:ml,compositeBackground:dc,altBackground:dc,compositeTitleBackground:Zu,compositeBorder:ea,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:ml,attributeBackgroundColorEven:dc,rowOdd:ml,rowEven:dc,errorBkgColor:D6,errorTextColor:WR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:ml,pieOuterStrokeColor:ea,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:Oc,relationLabelBackground:ml,relationLabelColor:tn,branchLabelColor:Fqt,commitLabelColor:tn,commitLabelBackground:ml,tagLabelColor:tn,tagLabelBackground:H0,tagLabelBorder:Du,quadrant2Fill:x_e,quadrant3Fill:S_e,quadrant4Fill:Z6,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:Wh,archEdgeColor:Oc,archEdgeArrowColor:Oc,archGroupBorderColor:ea,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:Oc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:ea,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:ml,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:ea,xAxisLineColor:ea,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:ea,yAxisLineColor:ea,plotColorPalette:[Wh,Bqt,Hqt,Kqt,WR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=ea;for(let n=0;n<8;n++)t[`fillType${n}`]=WJ[n%WJ.length];return{...t,...e}};let NR=null,NJ=null;const tjt=async e=>{NR||(NR=xe(async()=>{const{default:n}=await import("./mermaid.core-DL4n5f9y.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await NR;return NJ!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:ejt()}),NJ=e),t},YJ=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>d.jsxs("div",{"data-lo-floating":"",className:X("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx($t,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(gOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx($Oe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(r9e,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(dk,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(ck,{})})}),d.jsx($t,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:o,children:d.jsx(YO,{className:X(t&&"text-success")})})}),s]}),V6=({title:e,children:t})=>d.jsxs(rs,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(ip,{children:e}),d.jsx(uS,{children:t})]}),njt=({error:e})=>(be(),d.jsxs(V6,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class rjt 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||d.jsx(njt,{error:this.state.error}):this.props.children}}const ijt=$.memo(({chart:e,id:t})=>{be();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[f,p]=$.useState({scale:1,x:0,y:0}),[m,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,_]=$.useState("idle"),k=NP().id,R=$.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 N=await tjt(k),ce=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:ee}=await N.render(ce,e);if(!ee||typeof ee!="string"||ee.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(ee)}catch(N){console.error("Mermaid rendering error:",N);const ce=N instanceof Error?N.message:"Failed to render mermaid diagram";a(ce),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{R().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ce=r.current.getBoundingClientRect(),ee=document.createElement("div");ee.innerHTML=l;const D=ee.querySelector("svg");if(!D)return 1;const ne=D.getBoundingClientRect?.()?.width||Number.parseFloat(D.getAttribute("width")||"0")||D.viewBox?.baseVal?.width||800,J=D.getBoundingClientRect?.()?.height||Number.parseFloat(D.getAttribute("height")||"0")||D.viewBox?.baseVal?.height||600,L=ce.width*.9/ne,B=ce.height*.9/J;return Math.min(L,B,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const T=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.min(ee.scale*1.2,10)}))}catch(ce){console.error("Error in zoom in:",ce)}},[]),q=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.max(ee.scale/1.2,.1)}))}catch(ce){console.error("Error in zoom out:",ce)}},[]),A=$.useCallback((N=!1)=>{try{const ce=N?g:p;if(N){const ee=E();ce({scale:ee,x:0,y:0})}else ce({scale:1,x:0,y:0})}catch(ce){console.error("Error in reset:",ce)}},[E]),G=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),ce=URL.createObjectURL(N),ee=document.createElement("a");ee.href=ce,ee.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(ce)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),z=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),_("copied"),setTimeout(()=>_("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(ce){console.error("Error in mouse down:",ce)}},[]),Y=$.useCallback((N,ce=!1)=>{try{if(!y)return;const ee=N.clientX-b.x,D=N.clientY-b.y;(ce?g:p)(J=>({...J,x:J.x+ee,y:J.y+D})),x({x:N.clientX,y:N.clientY})}catch(ee){console.error("Error in mouse move:",ee)}},[y,b]),M=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),C=$.useCallback((N,ce=!1)=>{try{N.preventDefault();const ee=N.deltaY>0?.9:1.1;(ce?g:p)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*ee,.1),5)}))}catch(ee){console.error("Error in wheel:",ee)}},[]),Z=$.useCallback(N=>{try{O(N)}catch(ce){console.error("Error toggling fullscreen:",ce)}},[]);if(i)return d.jsxs(V6,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:X("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:X("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(N=!1)=>{try{const ce=N?r:n,ee=N?m:f;return d.jsx("div",{ref:ce,className:X("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:D=>Y(D,N),onMouseUp:M,onMouseLeave:M,onWheel:D=>C(D,N),children:o?d.jsx("div",{className:X("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:X("flex h-full w-full items-center justify-center"),style:{transform:`translate(${ee.x}px, ${ee.y}px) scale(${ee.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ce){return console.error("Error rendering diagram content:",ce),d.jsx(V6,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:X("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:[K(!1),d.jsx(YJ,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:G,onCopy:I,children:d.jsx($t,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>Z(!0),children:d.jsx(uOe,{})})})})]}),d.jsx(Vp,{open:u,onClose:()=>Z(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:X("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:[K(!0),d.jsx(YJ,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:G,onCopy:z,children:d.jsx($t,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>Z(!1),children:d.jsx(Zr,{})})})})]})})]})}),ajt=$.memo(e=>d.jsx(rjt,{children:d.jsx(ijt,{...e})}));let Q_e=!1,YR=null;const ojt=()=>(YR||(YR=xe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(Q_e=!0,e))),YR),sjt=/language-(\w+)/,ljt=mA,cjt=new RegExp(`^[^${tu}\\d*+-]`),ujt=/\n$/,__e=({href:e,children:t})=>{const n=yQe(e),r=wb();return!n||n.kind==="other"?d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):d.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=>fjt(i,r):void 0,children:t})},Ojt=e=>yQe(e)?.kind==="file",djt=xQe,fjt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(wQe)??"file",i=n.getAttribute(djt),a=HXt({kind:r,hasHighlight:pRt(n),canOpenInCanvas:ON(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||Ou(i)});return}Ou(i)}},M6=(e,t)=>t==="href"&&Ojt(e)?e:Tfe(e),Iy={a:__e,table:T8,img:JEt,code:({node:e,className:t,children:n,...r})=>sjt.exec(t??"")?.[1]==="mermaid"?d.jsx(ajt,{chart:String(n).replace(ujt,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},hjt={...Iy,a:zEt(__e)},pjt=[ls],mjt=[ls,WP],gjt=[ls,qP],$jt=[ls,WP,qP],yjt=[ls,AP,jP],vjt=[ls,WP,AP,jP],bjt=[ls,qP,AP,jP],wjt=[ls,WP,qP,AP,jP],xjt={"000":pjt,"001":yjt,"010":gjt,"011":bjt,100:mjt,101:vjt,110:$jt,111:wjt},Sjt=[],Qjt={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},_jt=[[Yrt,Qjt]],k_e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),P_e=(e,t,n,r)=>{const i=$.useMemo(()=>Uqt(e),[e]),[a,o]=$.useState(Q_e),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return ojt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=xjt[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[i4t,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?_jt:Sjt}},T_e=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=uit(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=tRt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return uN(i,window.api?.probeFiles,pue,JXt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>bQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},Zy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=P_e(s,r,i,a),u=k_e(t);return T_e(s,r,o),d.jsx("div",{className:X("lo-markdown",n),style:u,children:d.jsx(sy,{remarkPlugins:l,rehypePlugins:c,urlTransform:M6,components:i?hjt:Iy,children:s})})});Zy.displayName="MarkdownRenderer";const GJ={...Iy,a:({children:e})=>d.jsx(d.Fragment,{children:e})},X_e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:cJ(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=zQe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=P_e(n,t,!1);if(T_e(e,t),r!==null){const o=cJ(r.before);return d.jsxs(d.Fragment,{children:[o.trim()!==""&&d.jsx(sy,{remarkPlugins:i,rehypePlugins:a,urlTransform:M6,components:t?Iy:GJ,children:o}),d.jsx(kjt,{info:r.info,body:r.body})]})}return d.jsx(sy,{remarkPlugins:i,rehypePlugins:a,urlTransform:M6,components:t?Iy:GJ,children:n})});X_e.displayName="ParsedBlock";const kjt=({info:e,body:t})=>{const n=e.split(ljt)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
942
+ `||o==="\r"){if(n=!1,a())return!0;continue}i+=n||o==="\\"?"\0":o,!n&&o==="{"&&t++,!n&&o==="}"&&t>0&&t--,n=!n&&o==="\\"}return a()},Cqt=e=>{const t=new RegExp(Xqt.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(Eqt.test(r)&&Rqt.test(r)&&!r.includes("`")&&!jqt(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},CJ=e=>xqt.test(e)||Sqt.test(e)||kqt.test(e)||Pqt.test(e)||Tqt.test(e)||Cqt(e)||Qqt.test(e)?!0:_qt.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),zqt=e=>{const t=zP(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},Aqt=e=>zP(e).filter(t=>t.kind!=="text").length,Uqt=e=>{if(!CJ(e))return!1;const t=zqt(e);return t===null?!0:CJ(t)||t.includes("$")?!1:Aqt(e)<2},m_e=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),g_e=Object.freeze(RA.filter(e=>!["overlayShadow","scrim"].includes(e))),$_e=65536,y_e=/^#[0-9a-fA-F]{6}$/,Wqt=(e,t)=>Object.hasOwn(e,t),zJ=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),wa=e=>{throw new Error(e)},Nqt={canvas:["surface","elevated","sunken","messageSurface","mediaSurface","rowHover","rowSelected","accentWash","accentAltWash","successWash","warningWash","dangerWash","infoWash"],surface:["elevated","rowHover","rowSelected"],ink:["inkMuted","inkDim","inkDisabled"],inkMuted:["inkDim"],accent:["accentHover","accentActive","accentWash","chartBarHover"],borderControl:["hairline","hairlineStrong"]},Gy=(e,t)=>{const n={...e};for(const r of m_e){const i=rqe(t.seeds?.[r]);if(!i)continue;const a=h2(e[r]),o=h2(i);n[r]=i;for(const s of Nqt[r]){const l=h2(e[s]);n[s]=iqe({l:o.l+l.l-a.l,c:a.c>.01?o.c*l.c/a.c:l.c,h:o.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=aqe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of g_e)y_e.test(t.overrides?.[r]??"")&&(n[r]=t.overrides[r]);for(const r of["overlayShadow","scrim"]){const i=t.overrides?.[r];typeof i=="string"&&/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(i)&&(n[r]=e[r].replace(/\/\s*[\d.]+\)/,`/ ${i})`))}return n},yN=(e,t)=>tqe(e,t),$0n=(e,t)=>{const n=Gy(e,t),r=lqe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(s=>r[s]!==n[s]))return null;const a={...t.overrides};for(const s of g_e)r[s]!==n[s]&&(a[s]=r[s]);const o={...t,overrides:a};return yN(Gy(e,o),t.base).length?null:o},v_e=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>$_e)&&wa("import_size");let i;try{i=JSON.parse(e)}catch{wa("import_invalid_json")}zJ(i)||wa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(s=>!a.has(s))&&wa("import_unsafe"),i.format!=="local-operator-theme"&&wa("import_format"),i.version!==1&&wa("import_version"),(typeof i.base!="string"||!t(i.base))&&wa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&wa("import_name");const o={};for(const s of["seeds","overrides"]){(!Wqt(i,s)||!zJ(i[s]))&&wa("import_roles");const l={};for(const[c,u]of Object.entries(i[s]))(!(s==="seeds"?m_e:RA).includes(c)||typeof u!="string")&&wa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||wa("import_roles"),l[c]=u):(y_e.test(u)||wa("import_roles"),l[c]=u.toUpperCase());o[s]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...o,updatedAt:r}},Yqt=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>$_e*aS)&&wa("load_error");let n;try{n=JSON.parse(e)}catch{wa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||wa("load_error");const i=[],a=new Set;for(const o of r.slice(0,aS))try{const s=nqe(o,{isThemeName:t,isRole:c=>RA.includes(c)});if(!s||a.has(s.id))continue;const l=v_e(JSON.stringify(o),t,{id:s.id,now:s.updatedAt});i.push(l),a.add(l.id)}catch{}return i},Gqt=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),y0n=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=aS+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},v0n=(e,t)=>{const n=oqe({composed:!0,capturePairs:!0});return sqe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let WO={themes:[],error:!1,loading:!1};const I6=new Set,b_e=()=>{for(const e of I6)e()},AJ=()=>WO,Iqt=e=>(I6.add(e),()=>{I6.delete(e)}),UJ=()=>{try{WO={themes:Yqt(localStorage.getItem(pA),eue).filter(t=>{const n=OA(t.base)?.palette;return n&&yN(Gy(n,t),t.base).length===0}),error:!1,loading:!1}}catch{WO={themes:[],error:!0,loading:!1}}b_e()},vN=()=>$.useSyncExternalStore(Iqt,AJ,AJ),Zqt=e=>WO.themes.find(t=>t.id===e),w_e=e=>{localStorage.setItem(pA,JSON.stringify({version:1,themes:e})),WO={themes:e,error:!1,loading:!1},b_e()},b0n=e=>{const t=cqe(e.id);if(!t)throw new Error("invalid custom theme id");const n=v_e(Gqt(e),eue,{id:t,now:e.updatedAt}),r=OA(n.base)?.palette;if(!r||yN(Gy(r,n),n.base).length)throw new Error("contrast");if(!Zqt(n.id)&&WO.themes.length>=aS)throw new Error("limit");w_e([n,...WO.themes.filter(i=>i.id!==n.id)])},w0n=e=>w_e(WO.themes.filter(t=>t.id!==e));typeof window<"u"&&(UJ(),window.addEventListener("storage",e=>{(e.key===pA||e.key===null)&&UJ()}));const Dqt=()=>{const e=It(i=>i.themeName),t=It(i=>i.contrast),n=It(i=>i.accent),r=It(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},Vqt=e=>{const t=e?OA(e.base)?.palette:void 0;return t&&e?Gy(t,e):void 0},Mqt=()=>{const e=Dqt(),t=vN();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=Vqt(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:uqe(e,r,i)}},[e,t])},NP=()=>Mqt().resolved,x0n=()=>NP().palette.mode==="dark",tn="var(--color-ink)",Oc="var(--color-ink-muted)",ml="var(--color-surface)",Zu="var(--color-elevated)",dc="var(--color-sunken)",ea="var(--color-hairline)",Du="var(--color-control)",Wh="var(--color-accent)",H0="var(--color-accent-wash)",Lqt="var(--color-accent-alt-wash)",Fqt="var(--color-on-accent)",Bqt="var(--color-info)",x_e="var(--color-info-wash)",Hqt="var(--color-success)",S_e="var(--color-success-wash)",Kqt="var(--color-warning)",Z6="var(--color-warning-wash)",Jqt="var(--color-warning-border)",WR="var(--color-danger)",D6="var(--color-danger-wash)",WJ=[H0,Lqt,x_e,S_e,Z6,D6],Vu=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),ejt=()=>{const e={primaryColor:Vu("--color-accent"),secondaryColor:Vu("--color-success"),tertiaryColor:Vu("--color-info"),mainBkg:Vu("--color-elevated"),clusterBkg:Vu("--color-sunken"),clusterBorder:Vu("--color-hairline"),edgeLabelBackground:Vu("--color-surface"),quadrant1Fill:Vu("--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:ml,primaryTextColor:tn,primaryBorderColor:Du,secondaryTextColor:tn,secondaryBorderColor:ea,tertiaryTextColor:tn,tertiaryBorderColor:ea,lineColor:Oc,arrowheadColor:Oc,textColor:tn,secondBkg:dc,border1:Du,border2:ea,labelColor:tn,nodeBkg:Zu,nodeBorder:Du,nodeTextColor:tn,defaultLinkColor:Oc,titleColor:tn,noteBkgColor:Z6,noteBorderColor:Jqt,noteTextColor:tn,actorBkg:Zu,actorBorder:Du,actorTextColor:tn,actorLineColor:ea,signalColor:Oc,signalTextColor:tn,labelBoxBkgColor:Zu,labelBoxBorderColor:ea,labelTextColor:tn,loopTextColor:tn,activationBkgColor:H0,activationBorderColor:Wh,sequenceNumberColor:ml,sectionBkgColor:dc,sectionBkgColor2:ml,altSectionBkgColor:dc,excludeBkgColor:dc,taskBkgColor:H0,taskBorderColor:Du,taskTextColor:tn,taskTextLightColor:tn,taskTextDarkColor:tn,taskTextOutsideColor:tn,taskTextClickableColor:Wh,activeTaskBkgColor:H0,activeTaskBorderColor:Wh,gridColor:ea,doneTaskBkgColor:dc,doneTaskBorderColor:ea,critBkgColor:D6,critBorderColor:WR,todayLineColor:Wh,transitionColor:Oc,transitionLabelColor:tn,stateLabelColor:tn,stateBkg:Zu,labelBackgroundColor:ml,compositeBackground:dc,altBackground:dc,compositeTitleBackground:Zu,compositeBorder:ea,innerEndBackground:tn,specialStateColor:tn,classText:tn,attributeBackgroundColorOdd:ml,attributeBackgroundColorEven:dc,rowOdd:ml,rowEven:dc,errorBkgColor:D6,errorTextColor:WR,pieTitleTextColor:tn,pieSectionTextColor:tn,pieLegendTextColor:tn,pieStrokeColor:ml,pieOuterStrokeColor:ea,requirementBackground:Zu,requirementBorderColor:Du,requirementTextColor:tn,relationColor:Oc,relationLabelBackground:ml,relationLabelColor:tn,branchLabelColor:Fqt,commitLabelColor:tn,commitLabelBackground:ml,tagLabelColor:tn,tagLabelBackground:H0,tagLabelBorder:Du,quadrant2Fill:x_e,quadrant3Fill:S_e,quadrant4Fill:Z6,quadrant2TextFill:tn,quadrant3TextFill:tn,quadrant4TextFill:tn,quadrantPointFill:Wh,archEdgeColor:Oc,archEdgeArrowColor:Oc,archGroupBorderColor:ea,scaleLabelColor:tn,packet:{startByteColor:tn,endByteColor:tn,labelColor:tn,titleColor:tn,blockStrokeColor:Du,blockFillColor:Zu},radar:{axisColor:Oc,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:ea,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:ml,titleColor:tn,xAxisTitleColor:tn,xAxisLabelColor:tn,xAxisTickColor:ea,xAxisLineColor:ea,yAxisTitleColor:tn,yAxisLabelColor:tn,yAxisTickColor:ea,yAxisLineColor:ea,plotColorPalette:[Wh,Bqt,Hqt,Kqt,WR].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=Zu,t[`surfacePeer${n}`]=ea;for(let n=0;n<8;n++)t[`fillType${n}`]=WJ[n%WJ.length];return{...t,...e}};let NR=null,NJ=null;const tjt=async e=>{NR||(NR=xe(async()=>{const{default:n}=await import("./mermaid.core-KbHnAgh8.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await NR;return NJ!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:ejt()}),NJ=e),t},YJ=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:o,children:s})=>d.jsxs("div",{"data-lo-floating":"",className:X("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx($t,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(gOe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx($Oe,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(r9e,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(dk,{})})}),d.jsx($t,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(ck,{})})}),d.jsx($t,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:o,children:d.jsx(YO,{className:X(t&&"text-success")})})}),s]}),V6=({title:e,children:t})=>d.jsxs(rs,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(ip,{children:e}),d.jsx(uS,{children:t})]}),njt=({error:e})=>(be(),d.jsxs(V6,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class rjt 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||d.jsx(njt,{error:this.state.error}):this.props.children}}const ijt=$.memo(({chart:e,id:t})=>{be();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[o,s]=$.useState(!0),[l,c]=$.useState(""),[u,O]=$.useState(!1),[f,p]=$.useState({scale:1,x:0,y:0}),[m,g]=$.useState({scale:1,x:0,y:0}),[y,v]=$.useState(!1),[b,x]=$.useState({x:0,y:0}),[Q,w]=$.useState("idle"),[S,_]=$.useState("idle"),k=NP().id,R=$.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 N=await tjt(k),ce=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:ee}=await N.render(ce,e);if(!ee||typeof ee!="string"||ee.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(ee)}catch(N){console.error("Mermaid rendering error:",N);const ce=N instanceof Error?N.message:"Failed to render mermaid diagram";a(ce),c("")}finally{s(!1)}},[e,t,k]);$.useEffect(()=>{R().catch(N=>{console.error("Error in renderDiagram effect:",N),a("Failed to initialize diagram rendering"),s(!1)})},[R]);const E=$.useCallback(()=>{try{if(!l||!r.current)return 1;const ce=r.current.getBoundingClientRect(),ee=document.createElement("div");ee.innerHTML=l;const D=ee.querySelector("svg");if(!D)return 1;const ne=D.getBoundingClientRect?.()?.width||Number.parseFloat(D.getAttribute("width")||"0")||D.viewBox?.baseVal?.width||800,J=D.getBoundingClientRect?.()?.height||Number.parseFloat(D.getAttribute("height")||"0")||D.viewBox?.baseVal?.height||600,L=ce.width*.9/ne,B=ce.height*.9/J;return Math.min(L,B,1)}catch(N){return console.error("Error calculating fullscreen scale:",N),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const N=E();g({scale:N,x:0,y:0})}catch(N){console.error("Error setting fullscreen transform:",N)}},100)},[u,l,E]);const T=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.min(ee.scale*1.2,10)}))}catch(ce){console.error("Error in zoom in:",ce)}},[]),q=$.useCallback((N=!1)=>{try{(N?g:p)(ee=>({...ee,scale:Math.max(ee.scale/1.2,.1)}))}catch(ce){console.error("Error in zoom out:",ce)}},[]),A=$.useCallback((N=!1)=>{try{const ce=N?g:p;if(N){const ee=E();ce({scale:ee,x:0,y:0})}else ce({scale:1,x:0,y:0})}catch(ce){console.error("Error in reset:",ce)}},[E]),G=$.useCallback(()=>{if(l)try{const N=new Blob([l],{type:"image/svg+xml"}),ce=URL.createObjectURL(N),ee=document.createElement("a");ee.href=ce,ee.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(ee),ee.click(),document.body.removeChild(ee),URL.revokeObjectURL(ce)}catch(N){console.error("Failed to save SVG:",N)}},[l]),I=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),z=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),_("copied"),setTimeout(()=>_("idle"),1200)}catch(N){console.error("Failed to copy Mermaid chart text:",N)}},[e]),U=$.useCallback(N=>{try{v(!0),x({x:N.clientX,y:N.clientY}),N.preventDefault()}catch(ce){console.error("Error in mouse down:",ce)}},[]),Y=$.useCallback((N,ce=!1)=>{try{if(!y)return;const ee=N.clientX-b.x,D=N.clientY-b.y;(ce?g:p)(J=>({...J,x:J.x+ee,y:J.y+D})),x({x:N.clientX,y:N.clientY})}catch(ee){console.error("Error in mouse move:",ee)}},[y,b]),M=$.useCallback(()=>{try{v(!1)}catch(N){console.error("Error in mouse up:",N)}},[]),C=$.useCallback((N,ce=!1)=>{try{N.preventDefault();const ee=N.deltaY>0?.9:1.1;(ce?g:p)(ne=>({...ne,scale:Math.min(Math.max(ne.scale*ee,.1),5)}))}catch(ee){console.error("Error in wheel:",ee)}},[]),Z=$.useCallback(N=>{try{O(N)}catch(ce){console.error("Error toggling fullscreen:",ce)}},[]);if(i)return d.jsxs(V6,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:X("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:X("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const K=(N=!1)=>{try{const ce=N?r:n,ee=N?m:f;return d.jsx("div",{ref:ce,className:X("mermaid flex w-full items-center justify-center",N?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:D=>Y(D,N),onMouseUp:M,onMouseLeave:M,onWheel:D=>C(D,N),children:o?d.jsx("div",{className:X("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:X("flex h-full w-full items-center justify-center"),style:{transform:`translate(${ee.x}px, ${ee.y}px) scale(${ee.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(ce){return console.error("Error rendering diagram content:",ce),d.jsx(V6,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:X("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:[K(!1),d.jsx(YJ,{className:"top-2 right-2",copied:Q==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>q(!1),onReset:()=>A(!1),onSave:G,onCopy:I,children:d.jsx($t,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>Z(!0),children:d.jsx(uOe,{})})})})]}),d.jsx(Vp,{open:u,onClose:()=>Z(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:X("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:[K(!0),d.jsx(YJ,{className:"top-4 right-4",copied:S==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>q(!0),onReset:()=>A(!0),onSave:G,onCopy:z,children:d.jsx($t,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>Z(!1),children:d.jsx(Zr,{})})})})]})})]})}),ajt=$.memo(e=>d.jsx(rjt,{children:d.jsx(ijt,{...e})}));let Q_e=!1,YR=null;const ojt=()=>(YR||(YR=xe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(Q_e=!0,e))),YR),sjt=/language-(\w+)/,ljt=mA,cjt=new RegExp(`^[^${tu}\\d*+-]`),ujt=/\n$/,__e=({href:e,children:t})=>{const n=yQe(e),r=wb();return!n||n.kind==="other"?d.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",children:t}):d.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=>fjt(i,r):void 0,children:t})},Ojt=e=>yQe(e)?.kind==="file",djt=xQe,fjt=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(wQe)??"file",i=n.getAttribute(djt),a=HXt({kind:r,hasHighlight:pRt(n),canOpenInCanvas:ON(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(o=>{o||Ou(i)});return}Ou(i)}},M6=(e,t)=>t==="href"&&Ojt(e)?e:Tfe(e),Iy={a:__e,table:T8,img:JEt,code:({node:e,className:t,children:n,...r})=>sjt.exec(t??"")?.[1]==="mermaid"?d.jsx(ajt,{chart:String(n).replace(ujt,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},hjt={...Iy,a:zEt(__e)},pjt=[ls],mjt=[ls,WP],gjt=[ls,qP],$jt=[ls,WP,qP],yjt=[ls,AP,jP],vjt=[ls,WP,AP,jP],bjt=[ls,qP,AP,jP],wjt=[ls,WP,qP,AP,jP],xjt={"000":pjt,"001":yjt,"010":gjt,"011":bjt,100:mjt,101:vjt,110:$jt,111:wjt},Sjt=[],Qjt={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},_jt=[[Yrt,Qjt]],k_e=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),P_e=(e,t,n,r)=>{const i=$.useMemo(()=>Uqt(e),[e]),[a,o]=$.useState(Q_e),s=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return ojt().then(()=>{O||o(!0)}),()=>{O=!0}},[i,a]);const l=xjt[`${s?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[i4t,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:s?_jt:Sjt}},T_e=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=uit(e);if(i.length===0)return;let a=!0;const o=new Set(i),s=tRt(l=>{a&&l.some(c=>o.has(c))&&r(c=>c+1)});return uN(i,window.api?.probeFiles,pue,JXt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>bQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,s()}},[e,t,n])},Zy=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:o})=>{const s=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=P_e(s,r,i,a),u=k_e(t);return T_e(s,r,o),d.jsx("div",{className:X("lo-markdown",n),style:u,children:d.jsx(sy,{remarkPlugins:l,rehypePlugins:c,urlTransform:M6,components:i?hjt:Iy,children:s})})});Zy.displayName="MarkdownRenderer";const GJ={...Iy,a:({children:e})=>d.jsx(d.Fragment,{children:e})},X_e=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:cJ(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const o=zQe(e);return o!==null&&!o.nested?o:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=P_e(n,t,!1);if(T_e(e,t),r!==null){const o=cJ(r.before);return d.jsxs(d.Fragment,{children:[o.trim()!==""&&d.jsx(sy,{remarkPlugins:i,rehypePlugins:a,urlTransform:M6,components:t?Iy:GJ,children:o}),d.jsx(kjt,{info:r.info,body:r.body})]})}return d.jsx(sy,{remarkPlugins:i,rehypePlugins:a,urlTransform:M6,components:t?Iy:GJ,children:n})});X_e.displayName="ParsedBlock";const kjt=({info:e,body:t})=>{const n=e.split(ljt)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
943
943
  `)?"":`
944
944
  `}`})})},R_e=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=yRt());const i=r.current;xRt(i,e);const{blockStart:a}=i,o=a+SRt(e.slice(a));let s=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&cjt.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((f,p)=>({key:p,source:f,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=k_e(t);return d.jsx("div",{className:X("lo-markdown",n),style:O,children:u.map(f=>d.jsx(X_e,{source:f.source,closed:f.closed},f.key))})};R_e.displayName="StreamingMarkdown";const L6=({mark:e,name:t,className:n})=>{const r=mue(It(o=>o.agentAvatarSize)),i=dqe[r],a=Oqe[r];return d.jsx("div",{className:X("flex",a.className,n),"data-turn-avatar-gap":a.px,children:d.jsx(TFe,{mark:e,boxClassName:i.className,glyphClassName:i.glyphClassName,hitClassName:i.hitClassName,alt:t??"",agentName:t})})},fa=({isUser:e,children:t,className:n})=>e?d.jsx("div",{className:X("flex w-full justify-end",n),children:t}):d.jsx("div",{className:X("group relative w-full",n),children:t}),bN=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},Pjt=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 wN=bN(Date.now()),Tc=null,IJ=0,ZJ=0,DJ=0;const Gx=new Set,Tjt=1e3,Xjt=()=>typeof performance>"u"?Date.now():performance.now(),E_e=()=>{const e=Date.now(),t=e+Pjt(e),n=Xjt();Tc!==null&&t===IJ&&Math.abs(e-ZJ-(n-DJ))<=Tjt||(Tc!==null&&clearTimeout(Tc),IJ=t,ZJ=e,DJ=n,Tc=setTimeout(()=>{Tc=null,wN=bN(Date.now());for(const r of Gx)r();E_e()},t-e),Tc.unref?.())},Rjt=e=>(Gx.add(e),wN=bN(Date.now()),E_e(),()=>{Gx.delete(e),Gx.size===0&&Tc!==null&&(clearTimeout(Tc),Tc=null)}),VJ=()=>wN,Ejt=()=>$.useSyncExternalStore(Rjt,VJ,VJ),qjt=e=>new Date(e+1e3),jjt=()=>qjt(Ejt()),S0n=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":Cv(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},Cjt=(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=zv(n,{hour:"numeric",minute:"2-digit"});if(n.toDateString()===t.toDateString())return r;const i=new Date(t);if(i.setDate(t.getDate()-1),n.toDateString()===i.toDateString())return h("ui.common.time.yesterday_at",{time:r});const a=Cv(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),""}},zjt=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":gA(t,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}catch(t){return console.error("Error formatting calendar date-time:",t),""}},Ajt=(e,t)=>{switch(e){case"turn":return h("ui.chat.user_turn.stamp.sent",{date:t});case"answer":return h("ui.chat.user_turn.stamp.answered",{date:t});case"tool":return h("ui.chat.user_turn.stamp.ran",{date:t})}},CQ=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=jjt();if(Number.isNaN(r.getTime()))return null;const a=zjt(r);return d.jsx($t,{content:a,side:"bottom",delayDuration:1200,children:d.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":Ajt(t,a),className:X("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:d.jsx("bdi",{children:Cjt(r,i)})})})},xN=({replies:e,onRemoveReply:t})=>(be(),d.jsxs("div",{className:"mb-2 flex flex-col gap-1.5 rounded-sm bg-sunken p-2",children:[d.jsxs("div",{className:"flex items-center gap-1.5 text-ink-dim",children:[d.jsx(OOe,{size:12,"aria-hidden":"true"}),d.jsx("span",{className:"text-meta",children:h("ui.chat.reply.replying_to")})]}),e.map(n=>d.jsxs("div",{className:"flex items-center gap-2 border-hairline border-s-2 py-0.5 ps-2",children:[d.jsx("span",{className:"flex-1 truncate text-body-sm text-ink-muted",title:n.text,children:n.text}),t&&d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"shrink-0 text-ink-dim hover:bg-elevated hover:text-ink",onClick:()=>t(n.id),"data-reply-chip-remove":!0,"aria-label":h("ui.chat.reply.remove"),children:d.jsx(Zr,{"aria-hidden":"true"})})]},n.id))]})),Ujt=({children:e,className:t})=>d.jsx("span",{"aria-hidden":!0,className:X("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),Wjt="group/diff-toggle block w-full cursor-pointer bg-sunken text-start text-ink-dim underline underline-offset-2 transition-colors duration-fast ease-out-quart hover:text-ink focus-visible:outline-none",Njt={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},Yjt=({line:e,index:t})=>d.jsx("span",{"data-diff-line":t,className:X(Njt[e.kind],"block"),children:e.text}),Gjt=({diff:e,truncatedRows:t=0,className:n})=>{const[r,i]=$.useState(!1),a=$.useId(),o=$.useRef(null),s=$.useRef(null),l=$.useRef(null),c=fqe(e,{expanded:r});$.useLayoutEffect(()=>{const O=l.current;if(O)if(l.current=null,r){const f=o.current?.querySelector(`[data-diff-line="${hqe}"]`);if(f){const p=f.getBoundingClientRect().top-O.scroller.getBoundingClientRect().top;O.scroller.scrollTop+=p-O.top}}else o.current?.scrollIntoView({block:"nearest"})},[r]);const u=()=>{const O=o.current?.closest("[data-lo-canonical-transcript]");O&&s.current&&(l.current={scroller:O,top:s.current.getBoundingClientRect().top-O.getBoundingClientRect().top}),i(f=>!f)};return d.jsxs("div",{id:a,ref:o,className:X("rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",r?"overflow-x-clip":X("overflow-y-auto overflow-x-hidden",t>0?"max-h-[758px]":"max-h-[740px]"),n),children:[c.withheld?d.jsx("span",{className:"block text-ink-dim",children:pqe()}):c.lines.map((O,f)=>d.jsx(Yjt,{line:O,index:f},f)),!c.withheld&&t>0&&d.jsx("span",{className:"block text-ink-dim",children:mqe(t)}),c.expandable&&d.jsx("button",{type:"button",ref:s,"aria-expanded":r,"aria-controls":a,onClick:u,className:X(Wjt,"sticky -mb-3 pb-3",r?"bottom-0":"-bottom-3"),children:d.jsx("span",{className:"block group-focus-visible/diff-toggle:outline group-focus-visible/diff-toggle:outline-2 group-focus-visible/diff-toggle:outline-accent group-focus-visible/diff-toggle:outline-offset-[-2px]",children:r?gqe():$qe(c.hidden)})})]})},Ijt=(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()},MJ=e=>e.startsWith("file://")?e.slice(7):e,Zjt={READ:{verb:"ui.chat.trace.action.read.settled",runningVerb:"ui.chat.trace.action.read.running",icon:nOe},WRITE:{verb:"ui.chat.trace.action.write.settled",runningVerb:"ui.chat.trace.action.write.running",icon:WA},EDIT:{verb:"ui.chat.trace.action.edit.settled",runningVerb:"ui.chat.trace.action.edit.running",icon:b9e},CODE:{verb:"ui.chat.trace.action.code.settled",runningVerb:"ui.chat.trace.action.code.running",icon:iOe},DELEGATE:{verb:"ui.chat.trace.action.delegate.settled",runningVerb:"ui.chat.trace.action.delegate.running",icon:U9e},DONE:{verb:"ui.chat.trace.action.done.settled",runningVerb:"ui.chat.trace.action.done.running",icon:PA},ASK:{verb:"ui.chat.trace.action.ask.settled",runningVerb:"ui.chat.trace.action.ask.running",icon:Ip},BYE:{verb:"ui.chat.trace.action.bye.settled",runningVerb:"ui.chat.trace.action.bye.running",icon:U6e}},Djt={verb:"ui.chat.trace.action.fallback.settled",runningVerb:"ui.chat.trace.action.fallback.running",icon:iOe},Vjt=(e,t,n,r)=>{const i=e?Zjt[e]:Djt;let a;if(t)a=MJ(t);else if(n&&n.length>0){const s=n.filter(l=>!l.startsWith("data:"));s.length===1?a=MJ(s[0]):s.length>1&&(a=h("ui.chat.trace.object.file_count",{count:s.length}))}const o=!a&&r?Ijt(r):"";return{verb:h(i.verb),runningVerb:h(i.runningVerb),object:a,narration:o||void 0,icon:i.icon}},LJ="min-h-5 py-0",Mjt=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:o})=>d.jsxs("span",{className:X("flex min-w-0 gap-2",o?"items-start":"items-center"),"aria-busy":i||void 0,children:[d.jsx(Ujt,{className:X(a?"text-danger":"text-ink-dim",o&&Cde),children:e}),d.jsxs("span",{className:X(o?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[d.jsxs("span",{...C2,className:X("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?d.jsxs("span",{...C2,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?d.jsxs("span",{...C2,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),FJ=({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:f,dense:p=!1})=>{const m=Vjt(e,t,n,r),g=c??(i?m.runningVerb:m.verb),y=a?nu:m.icon,v=a||!c||!O?d.jsx(y,{}):O,b=d.jsx(Mjt,{icon:v,verb:g,object:c?u:m.object,narration:c?r:m.narration,running:i,failed:a,wrap:f}),x=f?"firstLine":"center";return s?d.jsx(zi,{summary:b,chevron:"leading",summaryAlign:x,defaultOpen:o,className:l,rowClassName:p?LJ:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:s}):d.jsx(zi,{disabled:!0,summary:b,summaryAlign:x,className:l,rowClassName:p?LJ:void 0})};function qi(e){return e.normalize("NFKC").trim().replace(/\s+/g," ").toLocaleLowerCase()}function SN(e,t,n){const r=e.trim(),i=t.trim();return r===""||qi(r)===qi(i)?n.unnamed(i):n.named(r,i)}const Dy="all";function Q0n(e){return e}function _0n(e){return e===Dy?Dy:e}function F6(e){return e.kind==="agent"?PN(e.display_label,null):YP(e.display_label)}function Ljt(e,t){const n=e.name?.trim();if(n)return n;const r=e.members.filter(a=>a.state!=="removed"&&!(a.kind==="human"&&a.account_id===t));if(e.kind==="dm"){const a=r.find(o=>o.state==="active")??r[0];return a?F6(a):null}const i=r.filter(a=>a.state==="active").map(F6).filter(a=>a!==null);return i.length===0?null:i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`}function k0n(e){return e.discoverable===!0&&e.member===!1}function Fjt(e){return e.notify??(e.muted?"mute":"all")}function Bjt(e){return Fjt(e)==="mute"}function P0n(e){return Bjt(e)?"quiet":"attention"}function T0n(e){return e==="mute"?"all":"mute"}const X0n=[{value:"all",labelKey:"ui.teamBridge.agentNotify.all"},{value:"mention",labelKey:"ui.teamBridge.agentNotify.mention"},{value:"mute",labelKey:"ui.teamBridge.agentNotify.mute"}];function q_e(e,t){return t?e.members.find(n=>n.kind==="agent"&&n.account_id===t&&n.state==="active")??null:null}function QN(e){const t=e.notify;return t==="all"||t==="mention"||t==="mute"?t:null}function R0n(e,t){const n=q_e(e,t);return n?{notify:QN(n)}:void 0}function E0n(e,t,n){const r=q_e(t,n),i=r?QN(r):null;return i===null?e:Hjt(e,{conversationId:t.id,tenantId:t.tenant_id},n,i)}function Hjt(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t.conversationId&&i.tenant_id===t.tenantId?{...i,members:i.members.map(a=>a.kind==="agent"&&a.account_id===n&&a.state==="active"?{...a,notify:r}:a)}:i)}}function q0n(e,t,n,r,i){return{...e,conversations:e.conversations.map(a=>a.id===t.conversationId&&a.tenant_id===t.tenantId?{...a,members:a.members.map(o=>{if(o.kind!=="agent"||o.account_id!==n||o.state!=="active"||QN(o)!==r)return o;if(i!==null)return{...o,notify:i};const{notify:s,...l}=o;return l})}:a)}}const j0n=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function C0n(e){return e==="mention"||e==="mute"?e:"all"}function z0n(e,t,n,r){return{...e,conversations:e.conversations.map(i=>i.id===t&&(!r||i.tenant_id===r)?{...i,notify:n,muted:n==="mute"}:i)}}function A0n(e){return e.kind==="channel"&&e.status==="open"&&!e.builtin&&e.can_administer===!0}function U0n(e){return e.kind==="channel"&&e.status==="archived"&&!e.builtin&&e.can_administer===!0}const j_e=(e,t,n)=>e.id===t&&(!n||e.tenant_id===n);function W0n(e,t,n){return{...e,conversations:e.conversations.filter(r=>!j_e(r,t,n))}}function N0n(e,t,n,r){return{...e,conversations:e.conversations.map(i=>j_e(i,t,r)?{...i,status:n}:i)}}function Y0n(e,t){const n=new Set(e.map(r=>r.id));return[...e,...t.filter(r=>!n.has(r.id))]}function G0n(e){return e.filter(t=>t.kind==="channel"&&t.status==="archived")}function I0n(e){return typeof e=="object"&&e!==null&&e.code==="not_a_member"}function Z0n(e,t,n=[]){const r=n3t(e,n).channels,i=r.findIndex(l=>l.id===t),a=i>=0?r[i+1]??r[i-1]:BJ(r,n),o=e.filter(l=>l.id!==t),s=a&&a.id!==t?a:BJ(o,n);return s?{type:"conversation",id:s.id}:null}function D0n(e,t){const n=new Set(e.conversations.map(r=>r.id));return{...t,conversations:[...e.conversations,...t.conversations.filter(r=>!n.has(r.id))]}}function V0n(e,t){return e.isError&&e.variables?.conversationId===t}function M0n(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function L0n(e){let t=0,n=0;for(const r of e.members)r.state==="active"&&(t+=1),r.state==="invited"&&(n+=1);return{active:t,invited:n}}function Kjt(e){return[...e].sort((t,n)=>t.seq-n.seq)}function F0n(e,t=[],n){const r=new Map(t.map(l=>[l.tenant_id,l.unread])),i=e.filter(l=>l.status==="active");if(!n)return i.map(l=>({tenantId:l.tenant_id,name:l.tenant_name,role:l.role,unread:r.get(l.tenant_id)??0}));const a=new Map(i.map(l=>[l.tenant_id,l])),o=new Set,s=[];for(const l of n){if(o.has(l.tenant_id))continue;o.add(l.tenant_id);const c=a.get(l.tenant_id);s.push({tenantId:l.tenant_id,name:l.tenant_name?.trim()||c?.tenant_name?.trim()||l.tenant_id,role:c?.role??"",unread:r.get(l.tenant_id)??0})}return s}function B0n(e,t,n,r){if(n)return t;if(e.length===1)return e[0].tenantId;if(e.length>1)return Dy;const i=new Set((r??[]).map(a=>a.tenant_id));return t===Dy&&i.size===1?[...i][0]:t}function H0n(e,t){return e.find(n=>n.tenantId===t)??null}function _N(e){const t=n=>{const r=Date.parse(n);return Number.isNaN(r)?Number.NEGATIVE_INFINITY:r};return[...e].sort((n,r)=>{const i=t(r.last_message_at)-t(n.last_message_at);return i!==0?i:n.id.localeCompare(r.id)})}function K0n(e){return e?.status?.tenants??null}function J0n(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function Jjt(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function e$n(e,t,n){return t!==Dy?[...e]:_N(e).filter(r=>Jjt(r,n)!==null)}function t$n(e){return e?e.state==="signed_out"?"signed_out":e.state==="update_required"||e.update_required?"update_required":e.state==="unavailable"?"unavailable":e.surface_state==="A"?"plan_required":e.state!=="ready"?null:e.surface_state==="E"?"off":(e.surface_state==="C"||e.surface_state==="D")&&e.local?.enabled===!1?"off_local":null:null}function Ix(e){return e.display_label.trim()||e.account_id}function n$n(e){const t=e,n=typeof t?.status=="number"?t.status:null,r=typeof t?.code=="string"?t.code:null;return n===401?"sign_in":n===403&&r==="bridge_not_available"?"plan":n===403?"refused":n===422||r==="invalid_request"?"invalid":n===400||n===404||t?.name==="ZodError"?"outdated":n===null?"unreachable":"server"}function e3t(e,t){return t&&e.account_id===t?"self":e.bridge_enabled&&(e.bridge_state==="active"||e.bridge_state==="paused")?e.bridge_state==="paused"?"paused":"openable":"unavailable"}function B6(e,t,n){const r=e.filter(i=>i.kind!=="dm"||i.status==="archived"||!i.members.some(o=>o.kind==="human"&&o.account_id===t&&o.state!=="removed")?!1:n?i.members.some(o=>o.kind==="human"&&o.account_id===n&&o.state!=="removed"):!0);return r.length===0?null:_N(r)[0]??null}function r$n(e){return e.trim().charAt(0).toUpperCase()||"?"}function t3t(e,t){const n=[];for(const r of e){if(t&&r.account_id===t)continue;const i=r.agent;!i||i.state==="disabled"||n.push({person:r,endpointId:i.endpoint_id,agentName:i.name.trim(),paused:i.state==="paused"})}return n}function H6(e,t,n){const r=e.filter(i=>i.kind==="dm"&&i.status!=="archived"&&i.members.some(a=>a.kind==="agent"&&a.account_id===t&&a.state!=="removed")&&(!n||i.members.some(a=>a.kind==="human"&&a.account_id===n&&a.state!=="removed")));return r.length===0?null:_N(r)[0]??null}const K6=["general","humans","agents"];function C_e(e,t,n){const r=K6.indexOf(e.builtin)-K6.indexOf(t.builtin);if(r!==0)return r;const i=o=>{const s=n.indexOf(o);return s<0?Number.POSITIVE_INFINITY:s},a=i(e.tenant_id)-i(t.tenant_id);return a!==0&&!Number.isNaN(a)?a:e.tenant_id.localeCompare(t.tenant_id)}function BJ(e,t=[]){const n=r=>e.filter(i=>i.builtin===r).sort((i,a)=>C_e(i,a,t))[0];return n("general")??n("humans")??e[0]}function i$n(e){switch(e){case"general":return"ui.teamBridge.builtin.general_topic";case"humans":return"ui.teamBridge.builtin.humans_topic";case"agents":return"ui.teamBridge.builtin.agents_topic";default:return null}}function n3t(e,t=[]){const n=[],r=[],i=[],a=[];for(const o of e)o.kind==="channel"?o.builtin&&K6.includes(o.builtin)?n.push(o):r.push(o):o.kind==="group"?i.push(o):a.push(o);return n.sort((o,s)=>C_e(o,s,t)),{channels:[...n,...r],groups:i,directs:a}}function a$n(e,t,n,r){const i=new Set;for(const a of t){if(r!==void 0&&a.account_id===r)continue;const o=B6(e,a.account_id,r);o&&i.add(o.id)}for(const a of n){const o=H6(e,a.person.account_id,r);o&&i.add(o.id)}return e.filter(a=>!i.has(a.id))}function o$n(e){return`${e.kind}:${e.accountId}`}function s$n(e,t,n){if(e===null)return null;switch(e.type){case"conversation":return t.find(r=>r.id===e.id)??null;case"person":return B6(t,e.accountId,n);case"chief":return H6(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[r]=e.recipients;return r.kind==="agent"?H6(t,r.accountId,n):B6(t,r.accountId,n)}}}function r3t(e){return kN(e.trim())??e}function i3t(e){const t=e.ownerLabel?.trim();if(e.agentName!==void 0&&t){const n=e.agentName.trim();return n!==""&&qi(n)!==qi(t)?n:t}return r3t(e.label)}function a3t(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:i3t(e).slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function l$n(e,t,n){const r=e.filter(a=>{const o=e3t(a,t);return o==="openable"||o==="paused"}).map(a=>({kind:"human",accountId:a.account_id,label:Ix(a)})),i=t3t(e,t).map(a=>({kind:"agent",accountId:a.person.account_id,endpointId:a.endpointId,agentName:a.agentName,ownerLabel:Ix(a.person),label:SN(a.agentName,Ix(a.person),n)}));return[...r,...i]}function c$n(e){if(e.length===0)return null;const t=e.map(a3t);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const o3t="Member";function YP(e){const t=e.trim();return t===""||t===o3t?null:t}const zQ={"(":")","(":")"},z_e=256;function s3t(e,t){if(e.length>z_e)return null;const n=qi(t);if(n==="")return null;for(let r=0;r<e.length;r+=1){const i=zQ[e[r]];if(i===void 0||!e.endsWith(i))continue;const a=e.slice(r+1,e.length-i.length),o=e.slice(0,r).trim();if(o!==""&&qi(a)===n)return o}return null}function l3t(e){const t=new Set(Object.values(zQ)),n=[];for(const r of e){const i=zQ[r];if(i!==void 0)n.push(i);else if(t.has(r)&&n.pop()!==r)return!1}return n.length===0}function kN(e){if(e.length>z_e)return null;for(let t=0;t<e.length;t+=1){const n=zQ[e[t]];if(n===void 0||!e.endsWith(n))continue;const r=e.slice(t+1,e.length-n.length),i=e.slice(0,t).trim();if(i!==""&&l3t(r)&&qi(i)===qi(r))return i}return null}const A_e=["'s chief of staff","’s chief of staff"],c3t=64;function u3t(e){const t=e.replace(/[\s\u0085]+/gu," ").trim(),n=new TextEncoder().encode(t);let r=c3t-A_e[0].length;if(n.length<=r)return t;for(;r>0&&(n[r]&192)===128;)r-=1;return new TextDecoder().decode(n.subarray(0,r)).trim()}function PN(e,t){const n=YP(e);if(n===null||t!==null&&qi(n)===qi(t)||t!==null&&[t,u3t(t)].some(r=>A_e.some(i=>qi(n)===qi(`${r}${i}`))))return null;if(t!==null){const r=s3t(n,t);if(r!==null)return qi(r)===qi(t)?null:r}return kN(n)!==null?null:n}function U_e(e,t){const n=F6(e);if(n!==null||e.kind!=="agent")return n;const r=YP(e.display_label),i=r===null?null:kN(r);return i===null?null:t.unnamed(i)}function u$n(e,t){const n=e.ownerLabel.trim();return n===""?U_e({kind:"agent",display_label:e.label},t):SN(PN(e.label,n)??"",n,t)}function O$n(e,t,n,r){const i=t.find(l=>l.account_id===e.account_id),a=i?Ix(i):null;if(e.kind==="human"){const l=YP(e.display_label),c=r&&r.accountId===e.account_id&&r.name.trim()||null;return a??c??l}const o=i?.agent?.name.trim()??"",s=o!==""&&(a===null||qi(o)!==qi(a))?o:PN(e.display_label,a);return a?SN(s??"",a,n):s??U_e({kind:"agent",display_label:e.display_label},n)}const O3t=5*6e4;function GR(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function d$n(e,t){const n=GR(t),r=GR(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),i=[];let a=null,o=null;for(const s of Kjt(e)){const l=new Date(s.created_at),c=!Number.isNaN(l.getTime()),u=c?GR(l):null;u!==null&&u!==o&&i.push({type:"day",key:u,date:l,relative:u===n?"today":u===r?"yesterday":null});const O=a!==null&&c&&u===o&&a.sender.account_id===s.sender.account_id&&a.sender.kind===s.sender.kind&&l.getTime()-Date.parse(a.created_at)<O3t;i.push({type:"message",message:s,continuation:O}),a=s,u!==null&&(o=u)}return i}const HJ="Team Bridge create answered for another tenant",IR=new WeakMap;async function f$n(e){if(IR.get(e.remembered)?.has(e.draftKey))throw new Error(HJ);let t=e.remembered.get(e.draftKey);if(t===void 0){const n=await e.create(e.input);if(!n.id)throw new Error("create returned no conversation id");if(e.tenantId!==void 0&&typeof n.tenant_id=="string"&&n.tenant_id!==e.tenantId){const r=IR.get(e.remembered)??new Set;throw r.add(e.draftKey),IR.set(e.remembered,r),new Error(HJ)}t={id:n.id,tenantId:n.tenant_id??e.tenantId},e.remembered.set(e.draftKey,t)}return e.onCreated?.(t),await e.post(t.id,{clientRef:e.clientRef,body:e.body,tenantId:t.tenantId}),e.remembered.delete(e.draftKey),t}const d3t=["channel","here","everyone"];function h$n(e){const{body:t,candidates:n,self:r}=e;if(!t||!t.includes("@"))return null;const i=r?[...n,{kind:"human",accountId:r.accountId,label:r.label}]:n,a=c=>r!==null&&c===r.accountId;if(Array.isArray(e.mentions)){const c=[];for(const u of e.mentions){if(!u||typeof u!="object")continue;if(u.kind==="channel"){const f=d3t.find(p=>W_e(t,[{label:p,viewer:!1}],!0).some(m=>m.kind==="mention"));f&&c.push({label:f,viewer:!1});continue}const O=i.find(f=>f.kind===u.kind&&f.accountId===u.account_id);O&&O.label!==""&&c.push({label:O.label,viewer:a(u.account_id)})}return c.length>0?{source:"message",runs:c,caseSensitive:!0}:null}const o=c=>r!==null&&r.labelUnique===!0&&c.kind==="human"&&c.accountId===r.accountId&&!n.some(u=>u.accountId!==r.accountId&&qi(u.label)===qi(c.label)),s=new Map;for(const c of i)c.label===""||!t.includes(`@${c.label}`)||s.set(c.label,(s.get(c.label)??!1)||o(c));const l=[...s].map(([c,u])=>({label:c,viewer:u}));return l.length>0?{source:"fallback",runs:l,caseSensitive:!0}:null}const KJ=/[\p{L}\p{N}_]/u;function W_e(e,t,n=!0){const r=(l,c)=>n?l===c:l.toLocaleLowerCase()===c.toLocaleLowerCase(),i=[...t].sort((l,c)=>c.label.length-l.label.length),a=[];let o="",s=0;for(;s<e.length;){const l=s===0?"":e.charAt(s-1),c=e.charAt(s)==="@"&&!KJ.test(l)&&l!=="."?i.find(O=>{const f=s+1+O.label.length;return r(e.slice(s+1,f),O.label)&&!KJ.test(e.charAt(f))}):void 0;if(!c){o+=e.charAt(s),s+=1;continue}o&&a.push({kind:"text",text:o}),o="";const u=s+1+c.label.length;a.push({kind:"mention",text:e.slice(s,u),viewer:c.viewer}),s=u}return o&&a.push({kind:"text",text:o}),a}const f3t="team-bridge-mention rounded-sm px-0.5 font-medium bg-accent-wash text-accent",h3t="team-bridge-mention rounded-sm px-0.5 font-medium bg-warning-wash text-warning";function p3t(e){return()=>t=>{xk(t,"text",(n,r,i)=>{if(!i||r===void 0||!n.value.includes("@"))return;const a=W_e(n.value,e);if(a.some(o=>o.kind==="mention"))return i.children.splice(r,1,...a.map(o=>o.kind==="text"?{type:"text",value:o.text}:{type:"mention",data:{hName:"span",hProperties:{className:o.viewer?h3t:f3t,"data-mention":o.viewer?"viewer":"other"}},children:[{type:"text",value:o.text}]})),r+a.length})}}const m3t=/^(https?:|mailto:)/i,g3t={a:({href:e,children:t})=>typeof e=="string"&&m3t.test(e)?d.jsx("a",{href:e,target:"_blank",rel:"noreferrer",children:t}):d.jsx("span",{className:"font-mono text-mono-sm",children:t}),img:({alt:e,src:t})=>d.jsx("span",{className:"text-ink-muted",children:e||(typeof t=="string"?t:"")}),table:T8},N_e=$.memo(({children:e,className:t,mentions:n,style:r})=>{const i=$.useMemo(()=>n?.length?[ls,p3t(n)]:[ls],[n]);return d.jsx("div",{className:X("lo-markdown",t),style:r,children:d.jsx(sy,{remarkPlugins:i,components:g3t,children:e})})});N_e.displayName="TeamBridgeMarkdown";const Y_e=8,$3t="… deeper values not shown",y3t="(empty)";function v3t(e){return`… ${e} more line${e===1?"":"s"}`}const JJ=.5;function b3t(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 G_e(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function TN(e){return typeof e=="object"&&e!==null}function I_e(e,t,n,r){if(n>Y_e){r.push({key:t,value:$3t,depth:n});return}if(TN(e)){for(const[a,o]of Object.entries(e))I_e(o,t?`${t}.${a}`:a,n+1,r);return}const i=G_e(e);i!==null&&r.push({key:t,value:i,depth:n})}function Z_e(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))I_e(r,n,1,t);return t}const w3t=512;function x3t(e,t){if(t)return!0;if(!e)return!1;let n=w3t;const r=(i,a)=>{if(n--<=0||a>Y_e)return!0;if(!TN(i))return G_e(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 S3t(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(!TN(n))return null;const r=Z_e(n);return r.length>0?r:[{key:"",value:y3t,depth:1}]}const Q3t=8,Vy="max-h-[min(320px,40vh)]",D_e=Vy,V_e=({line:e})=>d.jsxs("div",{className:X("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*Q3t},children:[e.key?d.jsxs("span",{className:X("text-ink-muted"),children:[e.key,": "]}):null,d.jsx("span",{className:X("text-ink-dim"),children:e.value})]}),eee=({lines:e,section:t})=>d.jsx("div",{className:X("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>d.jsx(V_e,{line:n},r))});function tee(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(),f=c.getBoundingClientRect();i(f.height>O.height+JJ);const p=c.children.length>0?Array.from(c.children):[c];n(b3t(p.map(m=>{const g=m.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,JJ))};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 nee=({lines:e,overflowing:t})=>t?d.jsx("span",{className:X("mt-1 block text-ink-dim"),children:e>0?v3t(e):" "}):null,_3t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{be();const a=Z_e(e),o=S3t(t),s=$.useRef(null),l=$.useRef(null),c=tee(s),u=tee(l);return a.length===0&&!t&&!i?null:d.jsxs("div",{className:X("w-full rounded-md bg-sunken p-3 font-mono text-mono-sm"),children:[a.length>0&&d.jsxs("div",{"data-detail-section":"input",children:[d.jsx("div",{ref:s,className:X(Vy,"overflow-auto"),children:d.jsx(eee,{lines:a,section:"input"})}),d.jsx(nee,{lines:c.lines,overflowing:c.overflowing})]}),i&&d.jsx("div",{className:X("whitespace-normal font-sans text-body-sm text-ink-muted",a.length>0&&"mt-3"),"data-detail-section":"note",children:i}),t&&d.jsxs("div",{className:X(a.length>0&&"mt-3"),"data-detail-section":"output",children:[d.jsx("span",{className:X("mb-1 block text-meta",n&&!r?"text-danger":"text-ink-dim"),children:r?h("ui.chat.canonical.tool_row.detail_section.interrupted"):n?h("ui.chat.canonical.tool_row.detail_section.error"):h("ui.chat.canonical.tool_row.detail_section.output")}),d.jsx("div",{ref:l,className:X(Vy,"overflow-auto"),children:o?d.jsx(eee,{lines:o,section:"result-json"}):d.jsx("pre",{className:X("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),d.jsx(nee,{lines:u.lines,overflowing:u.overflowing})]})]})},M_e=({view:e,isError:t,note:n=null,children:r})=>{const i=n??e.outcome,a=e.internals.length>0||!!e.raw;return d.jsxs("div",{className:X("flex w-full flex-col gap-2 rounded-md bg-sunken p-3 font-sans text-body-sm"),"data-bridge-detail":"",children:[e.headline?d.jsx("div",{className:X("font-medium text-ink"),"data-detail-section":"bridge-target",children:e.headline}):null,e.body?d.jsx("div",{className:X(Vy,"overflow-auto text-ink"),"data-detail-section":"bridge-body",children:d.jsx(N_e,{children:e.body})}):null,i?d.jsx("div",{className:X("whitespace-normal",t?"text-danger":"text-ink-muted"),"data-detail-section":"bridge-outcome",children:i}):null,r,a?d.jsx(zi,{chevron:"trailing",chevronClassName:"text-ink-dim",summary:d.jsx("span",{className:X("text-ink-dim text-meta"),children:h("ui.chat.canonical.tool_row.bridge.detail.details")}),triggerData:{"data-detail-section":"bridge-details"},children:d.jsxs("div",{className:X(Vy,"overflow-auto pt-1 font-mono text-mono-sm"),children:[e.internals.map(o=>d.jsx(V_e,{line:{key:o.key,value:o.value,depth:1}},o.key)),e.raw?d.jsx("pre",{className:X("mt-2 whitespace-pre-wrap break-words font-mono text-ink-dim"),children:e.raw}):null]})}):null]})},k3t="mcp__",P3t={bash:V9e,read:J$,write:_I,edit:_I,glob:Dp,grep:Nv,todo:jze,wake:Wf,list_variables:RI,read_variable:RI,browser:kI,console:dOe,project:E6e,project_delete:L9e,web_search:kI,web_fetch:ck,task:s$,agent:s$,send:pS,peer:_ze,sessions:S9e,bridge:Bze};function T3t(e){const t=e.trim().toLowerCase(),n=P3t[t];return n||(t.startsWith(k3t)?fOe:lAe)}const X3t=AA,R3t=Wze,E3t=Aze,q3t=Ize,j3t=lOe,ree="min-h-5 py-0",iee={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},C3t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?iee.plain:iee[vqe(t)],z3t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",A3t=({added:e,removed:t})=>e<=0&&t<=0?null:d.jsxs("span",{className:X("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&d.jsxs("span",{className:X("text-success"),children:["+",e]}),t>0&&d.jsxs("span",{className:X("text-danger"),children:["-",t]})]}),U3t={running:"",success:"ui.chat.canonical.tool_row.outcome.succeeded",error:"ui.chat.canonical.tool_row.outcome.failed",interrupted:"ui.chat.canonical.tool_row.outcome.interrupted","not-run":"ui.chat.canonical.tool_row.outcome.never_ran",partial:"",receipt:""},ZR=e=>{const t=U3t[e];return t===""?"":h(t)},W3t=1e3;function N3t(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,W3t);return()=>window.clearInterval(i)},[e]),t}const Y3t=({toolName:e="",outcome:t,deliveryState:n=null,failureWord:r=null,durationS:i,startedAt:a})=>{const o=t==="running",s=N3t(o?a??null:null),l=t==="error"||t==="not-run",c=t==="partial",u=bqe(n,e),O=c?u:l?u??r??ZR(t):null,f=c?"text-warning":"text-danger",p=c?wqe(n,e):null,m=X("font-medium text-meta",f,c&&(p?"hidden @[40rem]/toolrow:inline":"hidden @[19rem]/toolrow:inline")),g=X("font-medium text-meta",f,"hidden @[20rem]/toolrow:inline @[40rem]/toolrow:hidden"),y=c?xqe(n,e):null,v=c?Sqe(n,e):void 0,b=c?n==="mailbox"?R3t:n==="unconfirmed"?E3t:n==="inbox_only"?q3t:n==="awaiting_acceptance"?j3t:null:t==="interrupted"?X3t:null,x=b&&c?"text-warning":"text-ink-dim",Q=o?a==null?"":QO(s??0):$A(i);return d.jsxs("span",{className:X("flex shrink-0 items-center gap-1.5"),children:[O?d.jsx("span",{className:m,title:v,"aria-hidden":y?!0:void 0,children:O}):null,O&&p?d.jsx("span",{className:g,title:v,"aria-hidden":y?!0:void 0,"data-status-word":"short",children:p}):null,d.jsxs("span",{className:X("flex shrink-0 [&_svg]:size-3.5",b&&"size-3.5",x),children:[b?d.jsx(b,{"aria-hidden":!0}):null,!l&&ZR(t)?d.jsx("span",{className:X("sr-only"),children:ZR(t)}):null,y?d.jsx("span",{className:X("sr-only"),children:y}):null]}),d.jsx("span",{className:X("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:Q})]})},Hc=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:o=!1,summaryIsCopy:s=!1,outcome:l,deliveryState:c=null,settledVerb:u=null,failureWord:O=null,durationS:f,startedAt:p=null,added:m=0,removed:g=0,details:y,defaultOpen:v=!1,className:b,media:x})=>{const Q=Fl(),w=l==="running",S=l==="error",_=T3t(e),k=V$(e),{verb:R,object:E}=gue(e,r,i,w,t,u??yqe(c)),T=d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),children:[d.jsx("span",{"aria-hidden":!0,className:X("flex size-3.5 shrink-0 [&_svg]:size-3.5",C3t(l,e)),children:d.jsx(_,{})}),n?null:d.jsx("span",{"data-trace-verb":"",className:X("min-w-0 truncate text-body-sm",z3t(l)),title:`${R} (${k})`,children:R}),d.jsx("span",{className:X(o?"min-w-0 flex-1 break-words whitespace-normal font-mono text-ink-muted text-mono-sm":"min-w-0 flex-1 truncate font-mono text-ink-muted text-mono-sm"),title:a?void 0:E,children:a?d.jsxs(d.Fragment,{children:[d.jsx("span",{className:"text-ink-dim","data-label-hold":"true","aria-hidden":!0,children:"…"}),d.jsx("span",{className:X("sr-only"),children:h("ui.chat.canonical.tool_row.pending")})]}):d.jsx("bdi",{dir:s?Q:"ltr",children:E})}),d.jsx(A3t,{added:m,removed:g}),d.jsx(Y3t,{toolName:e,outcome:l,deliveryState:c,failureWord:O,durationS:f,startedAt:p})]}),q=w?{"data-glass-state":"running"}:void 0,A=w?"bg-elevated":S?"bg-danger-wash":"hover:bg-row-hover",G=y?d.jsx(zi,{summary:T,chevron:"leading",defaultOpen:v,className:X("@container/toolrow",b),triggerData:q,rowClassName:ree,triggerClassName:X("-mx-2 rounded-sm px-2",A),children:y}):d.jsx(zi,{disabled:!0,summary:T,triggerData:q,rowClassName:ree,className:X("@container/toolrow",(w||S)&&X("-mx-2 rounded-sm px-2",A),b)});return x?d.jsxs("div",{className:X("flex flex-col"),children:[G,x]}):G},G3t=3,I3t=2;function Z3t(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=$ue(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)=>{o>0&&i.push(s(o))};return a(t.incoming,o=>h("ui.chat.canonical.fold.receipt.incoming",{count:o})),a(t.job_result,o=>h("ui.chat.canonical.fold.receipt.job_result",{count:o})),a(t.wake,o=>h("ui.chat.canonical.fold.receipt.wake",{count:o})),a(t.monitor_prompt,o=>h("ui.chat.canonical.fold.receipt.monitor_prompt",{count:o})),a(e.length-t.incoming-t.job_result-t.wake-t.monitor_prompt,o=>h("ui.chat.canonical.fold.receipt.other",{count:o})),n&&i.push(h("ui.chat.canonical.fold.receipt.reply_requested")),r&&i.push(h("ui.chat.canonical.fold.receipt.steered")),i}const L_e=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},D3t=(e,t,n)=>{switch(e){case"files":return h("ui.chat.canonical.fold.sentence.files",{count:t});case"searches":return h("ui.chat.canonical.fold.sentence.searches",{count:t});case"web":return n?h("ui.chat.canonical.fold.sentence.web_follow",{count:t}):h("ui.chat.canonical.fold.sentence.web_lead",{count:t});case"commands":return n?h("ui.chat.canonical.fold.sentence.commands_follow",{count:t}):h("ui.chat.canonical.fold.sentence.commands_lead",{count:t});case"edits":return n?h("ui.chat.canonical.fold.sentence.edits_follow",{count:t}):h("ui.chat.canonical.fold.sentence.edits_lead",{count:t});case"delegated":return n?h("ui.chat.canonical.fold.sentence.delegated_follow",{count:t}):h("ui.chat.canonical.fold.sentence.delegated_lead",{count:t})}},F_e=()=>h("ui.chat.canonical.fold.unit_separator"),B_e=e=>{const t=new Map;let n=0;for(const o of e){const s=L_e(o.name);s===null?n+=1:t.set(s,(t.get(s)??0)+1)}const r=XN(e);if(n>0||t.size>2){const o=H_e(r);return{units:o.length===0?[h("ui.chat.canonical.fold.count.actions",{count:e.length})]:o,prose:!1,countUnits:r}}const i=["files","searches","web","commands","edits","delegated"],a=[];for(const o of i){const s=t.get(o)??0;s!==0&&a.push(D3t(o,s,a.length>0))}return a.length===0?{units:[h("ui.chat.canonical.fold.count.actions",{count:e.length})],prose:!0,countUnits:r}:{units:[a.length===1?a[0]:h("ui.chat.canonical.fold.sentence.join",{first:a[0],second:a[1]})],prose:!0,countUnits:r}},V3t=e=>B_e(e).units;function M3t(e){return V3t(e).join(F_e())}const DR={agent:{sort:"agent",label:e=>h("ui.chat.canonical.fold.count.agent",{count:e})},team:{sort:"team",label:e=>h("ui.chat.canonical.fold.count.team",{count:e})},team_delete:{sort:"team deletion",label:e=>h("ui.chat.canonical.fold.count.team_delete",{count:e})},hub:{sort:"subagent",label:e=>h("ui.chat.canonical.fold.count.hub",{count:e})},secret:{sort:"secret",label:e=>h("ui.chat.canonical.fold.count.secret",{count:e})},project:{sort:"project",label:e=>h("ui.chat.canonical.fold.count.project",{count:e})},project_delete:{sort:"project deletion",label:e=>h("ui.chat.canonical.fold.count.project_delete",{count:e})},wake:{sort:"wake",label:e=>h("ui.chat.canonical.fold.count.wake",{count:e})},jobs:{sort:"job check",label:e=>h("ui.chat.canonical.fold.count.jobs",{count:e})},console:{sort:"console",label:e=>h("ui.chat.canonical.fold.count.console",{count:e})},network:{sort:"network call",label:e=>h("ui.chat.canonical.fold.count.network",{count:e})},browser:{sort:"browser action",label:e=>h("ui.chat.canonical.fold.count.browser",{count:e})},todo:{sort:"todo update",label:e=>h("ui.chat.canonical.fold.count.todo",{count:e})},send:{sort:"message",label:e=>h("ui.chat.canonical.fold.count.send",{count:e})},ask:{sort:"question",label:e=>h("ui.chat.canonical.fold.count.ask",{count:e})},wait:{sort:"wait",label:e=>h("ui.chat.canonical.fold.count.wait",{count:e})},lsp:{sort:"code lookup",label:e=>h("ui.chat.canonical.fold.count.lsp",{count:e})},web_read:{sort:"page",label:e=>h("ui.chat.canonical.fold.count.web_read",{count:e})},list_variables:{sort:"variable lookup",label:e=>h("ui.chat.canonical.fold.count.list_variables",{count:e})},read_variable:{sort:"variable read",label:e=>h("ui.chat.canonical.fold.count.read_variable",{count:e})},sessions:{sort:"session",label:e=>h("ui.chat.canonical.fold.count.sessions",{count:e})}},VR=5,H_e=e=>{if(e.length<=VR)return e.map(r=>r.label);const t=e.slice(0,VR),n=e.slice(VR).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),h("ui.chat.canonical.fold.count.other_actions",{count:n})]},XN=e=>{const t=new Map,n=(o,s)=>{const l=t.get(o);l?l.count+=1:t.set(o,{kind:s,count:1})};for(const o of e){const s=o.name.toLowerCase();if(s==="bash"||s==="exec"||s==="shell"||s==="run"){n("kind:shell",{sort:"shell",label:c=>h("ui.chat.canonical.fold.count.shell",{count:c})});continue}if(s==="eval"){n("kind:python",{sort:"python",label:c=>h("ui.chat.canonical.fold.count.python",{count:c})});continue}const l=L_e(o.name);if(l==="files")n("class:files",{sort:"file",label:c=>h("ui.chat.canonical.fold.count.file",{count:c})});else if(l==="searches")n("class:searches",{sort:"search",label:c=>h("ui.chat.canonical.fold.count.search",{count:c})});else if(l==="web")n("class:web",{sort:"web search",label:c=>h("ui.chat.canonical.fold.count.web",{count:c})});else if(l==="edits")n("class:edits",{sort:"edit",label:c=>h("ui.chat.canonical.fold.count.edit",{count:c})});else if(l==="delegated")n("class:delegated",{sort:"task",label:c=>h("ui.chat.canonical.fold.count.task",{count:c})});else if(s==="todo")(o.op??"").toLowerCase()==="view"?n("kind:todo:view",{sort:"todo read",label:c=>h("ui.chat.canonical.fold.count.todo_read",{count:c})}):n("kind:todo",DR.todo);else if(s==="jobs")(o.op??"").toLowerCase()==="cancel"?n("kind:jobs:cancel",{sort:"job cancellation",label:c=>h("ui.chat.canonical.fold.count.jobs_cancel",{count:c})}):n("kind:jobs",DR.jobs);else if(s==="bridge")Qqe.has((o.op??"").toLowerCase())?n("kind:bridge:post",{sort:"team message",label:c=>`${c} ${c===1?h("ui.chat.canonical.fold.bridge_post.one"):h("ui.chat.canonical.fold.bridge_post.other")}`}):n("kind:bridge",{sort:"team action",label:c=>`${c} ${c===1?h("ui.chat.canonical.fold.bridge.one"):h("ui.chat.canonical.fold.bridge.other")}`});else{const c=DR[s];if(c)n(`kind:${s}`,c);else{const u=V$(o.name);n(`name:${u}`,{sort:u,label:O=>h("ui.chat.canonical.fold.count.named",{count:O,name:u})})}}}const r=["class:files","class:searches","class:web","kind:shell","kind:python","class:edits","class:delegated","kind:agent","kind:team","kind:hub"],i=[];for(const o of r){const s=t.get(o);s&&i.push({key:o,label:s.kind.label(s.count),count:s.count})}const a=[...t.entries()].filter(([o])=>!r.includes(o)).sort(([,o],[,s])=>s.count-o.count||o.kind.sort.localeCompare(s.kind.sort));for(const[o,s]of a)i.push({key:o,label:s.kind.label(s.count),count:s.count});return i};function L3t(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 F3t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=L3t(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 B3t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return gue(n.name,n.summary??"",null,!0,n.op)}return null}function H3t(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function K3t(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 f={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&&(f.summary=t.summaryOf(O)),t.opOf&&(f.op=t.opOf(O)),t.runningOf&&(f.running=t.runningOf(O)),t.executingOf&&(f.executing=t.executingOf(O)),f}),s=a.length?t.receiptSummaryOf?.(a)??[]:[],l=s.length>0?s:a.length>0?[`${a.length} receipt${a.length===1?"":"s"}`]:[],c=t.isReceipt?H3t(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>=G3t||c>=I3t||u){const O=(()=>{if(o.length===0)return{units:[],prose:!1,countUnits:[]};const f=XN(o);return l.length>0?{units:H_e(f),prose:!1,countUnits:f}:B_e(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,countUnits:O.countUnits},failedCount:o.filter(f=>f.failed).length,span:F3t(o),live:B3t(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 J3t(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 aee=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&$ue(n.record)==="incoming")))for(const r of n.record.images??[])Np(r)&&t.push(r);return t},Zx=5,e7t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<Zx?{shown:Math.max(e,0),more:0}:{shown:Zx-1,more:e-(Zx-1)},t7t=e=>{const t=Zx-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},AQ=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function UQ(e){return e.record.kind==="tool"?e.record.durationS:null}function K_e(e){let t=null;for(const n of e){const r=UQ(n);typeof r=="number"&&(t=(t??0)+r)}return t}function n7t(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 r7t="min-h-5 py-0",i7t=(e,t)=>e.map(n=>t==="rtl"?`⁧${n}⁩`:n).join(F_e()),a7t=1e3;function o7t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,a7t);return()=>window.clearInterval(i)},[e]),t}const s7t=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:o,mediaCount:s=0,recordIds:l,children:c})=>{const u=Fl(),O=o7t(t?.running===!0),f=t===null?null:Math.max(0,((t.running?O:t.endedAtMs??O)-t.startedAtMs)/1e3),p=f===null?"":$A(f),m=$.useRef(null),g=()=>{m.current?.querySelector("button[aria-expanded]")?.focus(),i(!0)};return d.jsxs("div",{ref:m,className:a,"data-fold-ids":l.join(" "),children:[d.jsx(zi,{animate:r||!o,open:r,onOpenChange:i,rowClassName:r7t,triggerClassName:X("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),children:[n!==null&&!r&&d.jsxs(d.Fragment,{children:[d.jsxs("span",{"data-fold-live":"",className:X("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[d.jsx("span",{className:X("text-accent"),children:n.verb})," ",d.jsx("span",{className:X("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"})]}),d.jsx("span",{className:X("min-w-0 break-words text-body-sm text-ink-muted"),title:i7t(e.units,u),"data-fold-summary":"",children:e.units.map((y,v)=>d.jsxs($.Fragment,{children:[v>0&&d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:X(e.prose?"whitespace-normal":"whitespace-nowrap"),children:d.jsx("bdi",{dir:u,children:y})})]},y))}),AQ(s)!==null&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{className:X("shrink-0 text-ink-muted text-meta"),children:AQ(s)})]}),p!==""&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{"data-fold-span":"",className:X("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:p})]})]}),children:d.jsx("div",{className:X("flex flex-col"),children:c})}),!r&&o&&o(g)]})},oee=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],l7t=80,c7t=1e3,J_e=({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,f=c8("(prefers-reduced-motion: reduce)"),p=$.useRef(n??Date.now()),m=$.useRef(t),g=$.useRef(n);if(m.current!==t)m.current=t,g.current=n,p.current=n??Date.now(),c&&u(!1),l(0);else if(g.current!==n){const b=g.current!==void 0&&n===void 0;g.current=n,u(b),b||(p.current=n,l(Math.floor((Date.now()-n)/1e3)))}const y=$.useRef(r!==!1),v=$.useRef(t);return $.useEffect(()=>{const b=r!==!1,x=y.current,Q=v.current===t;y.current=b,v.current=t,!x&&b&&Q&&l(Math.floor((Date.now()-p.current)/1e3))},[r,t]),$.useEffect(()=>{const b=O?window.setInterval(()=>l(Math.floor((Date.now()-p.current)/1e3)),c7t):null;if(f)return o(0),()=>{b!==null&&window.clearInterval(b)};const x=window.setInterval(()=>o(Q=>(Q+1)%oee.length),l7t);return()=>{window.clearInterval(x),b!==null&&window.clearInterval(b)}},[f,O]),d.jsxs("div",{className:X("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[d.jsx("span",{"aria-hidden":!0,className:X("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:oee[a]}),d.jsx("span",{className:X("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),d.jsx("span",{"aria-hidden":!0,className:X("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?QO(s):""})]})},u7t="min-h-5 py-0",Mu=()=>d.jsx("span",{"aria-hidden":!0,className:X("text-ink-dim text-meta"),children:"·"}),O7t=({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:f,children:p,condensedMedia:m,mediaCount:g=0,group:y=null,episode:v=null})=>{be();const b=o?h("ui.chat.canonical.fold.count.actions_partial",{count:a}):h("ui.chat.canonical.fold.count.actions",{count:a}),x=`At least ${a===1?"1 action":`${a} actions`} — earlier rows of this turn are not loaded`,Q=v?.receipts??y?.count,w=Q===void 0?null:`At least ${Q} messages — earlier rows are not loaded`,S=$.useRef(null),_=()=>{S.current?.querySelector("button[aria-expanded]")?.focus(),f(!0)};return c===null&&i===null&&a===0&&y===null&&v===null&&g===0?null:d.jsxs("div",{ref:S,className:X("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!v?.active?"true":void 0,"data-segment-active":v?.active?"true":void 0,"data-record-id":n,children:[d.jsx(zi,{open:O,onOpenChange:f,chevron:"trailing",rowClassName:u7t,triggerClassName:X("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:X("-mr-6","text-ink-muted"),summary:d.jsxs("span",{className:X("flex min-w-0 flex-1 items-center gap-2"),title:s??void 0,children:[c!==null&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!v?.active&&d.jsx(d.Fragment,{children:d.jsx(PA,{"aria-hidden":!0,className:X("size-3.5 shrink-0 text-success")})}),v?.active?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(Mu,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v.receipts}+`:v.receipts}),a>0&&d.jsxs(d.Fragment,{children:[d.jsx(Mu,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:o?x:void 0,children:d.jsx("bdi",{children:b})})]}),v.phaseLine!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Mu,{}),d.jsx(J_e,{activity:v.phaseLine.activity,phase:v.phaseLine.phase,startedAt:v.phaseLine.startedAt,clock:v.phaseLine.clock,className:"min-w-0"})]})]}):y!==null?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(Mu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),title:o?w??void 0:void 0,"aria-label":o?w??void 0:void 0,children:o?`${v?.receipts??y.count}+`:`${v?.receipts??y.count}`}),y.spanS!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Mu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:QO(y.spanS)})]})]}):d.jsxs(d.Fragment,{children:[c!==null&&(i!==null||a>0)&&d.jsx(Mu,{}),i!==null&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:h("ui.chat.canonical.turn_summary.took",{duration:QO(i)})}),i!==null&&a>0&&d.jsx(Mu,{}),a>0&&d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),title:o?x:void 0,"aria-label":o?x:void 0,children:d.jsx("bdi",{children:b})})]}),AQ(g)!==null&&d.jsxs(d.Fragment,{children:[d.jsx(Mu,{}),d.jsx("span",{className:X("shrink-0 text-body-sm text-ink-muted"),children:AQ(g)})]}),u&&!v?.active&&d.jsx("span",{className:X("sr-only"),children:h("ui.chat.canonical.turn_summary.completed")}),l!==null&&d.jsx("span",{className:X("ms-auto"),children:d.jsx(CQ,{timestamp:l,scope:"answer"})})]}),children:d.jsx("div",{className:X("flex flex-col"),children:p})}),!O&&m&&d.jsx("div",{className:X("pb-2"),children:m(_)})]})},eke="lo-missing-session-notice";function d7t(e){return e===!0?{kind:"temporary",title:"ui.chat.canonical.temporary_deleted.title",detail:"ui.chat.canonical.temporary_deleted.detail",actions:[{key:"ui.chat.canonical.temporary_deleted.new",temporary:!0},{key:"ui.chat.canonical.temporary_deleted.back",temporary:!1}]}:{kind:"generic",title:"ui.chat.canonical.transcript.missing_session",detail:"ui.chat.canonical.transcript.missing_session_detail",actions:[{key:"ui.chat.canonical.transcript.start_new_chat",temporary:!1}]}}function tke(e){const t=$.useRef(null);return $.useEffect(()=>{e&&t.current?.focus({preventScroll:!0})},[]),t}const du=({children:e,className:t,boundary:n="hairline",...r})=>d.jsx("div",{className:X("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}),f7t="could not be displayed. It may have been moved, renamed, or deleted.",RN="could not be displayed. Its stored copy is not available to this reader.",nke="could not be played. Its stored copy is not available to this reader.",rke=nke,Tf=({name:e,detail:t=f7t,className:n,compact:r=!1})=>r?d.jsx("div",{className:X("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:d.jsx(TI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):d.jsxs("div",{className:X("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),children:[d.jsx(TI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[d.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),` ${t}`]})]}),Qb=({name:e,onRetry:t,className:n,compact:r=!1,device:i=null,focusOnMount:a=!1})=>{const o=tke(a),s=i?h("ui.canvas.files.remoteUnreachable",{device:i}):null,l=s??h("ui.chat.attachments.owner_unreachable"),c=h("ui.chat.attachments.retry_fetch");return r?d.jsxs("button",{ref:o,type:"button",onClick:u=>{u.stopPropagation(),t()},className:X("flex h-[78px] w-[117px] flex-col items-center justify-center gap-1 rounded-sm border border-control bg-sunken hover:bg-row-hover",n),"aria-label":`${e} ${l} ${c}`,title:`${e} ${l} ${c}`,"data-attachment-retryable":"",children:[d.jsx(cI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsx("span",{className:"text-ink-muted text-meta","aria-hidden":!0,children:c})]}):d.jsxs("div",{className:X("flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2",n),"data-attachment-retryable":"",children:[d.jsx(cI,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0}),d.jsxs("span",{className:"min-w-0 text-body-sm text-ink-muted",children:[d.jsx("span",{className:"truncate font-mono text-ink text-mono-sm",children:e}),s?d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,children:" · "}),s]}):` ${l}`]}),d.jsx("button",{ref:o,type:"button",onClick:u=>{u.stopPropagation(),t()},className:"shrink-0 rounded-sm px-1 text-accent text-body-sm hover:underline",children:c})]})},EN=({device:e,compact:t=!1,video:n=!1,focusOnMount:r=!1})=>{const i=tke(r),a=h("ui.canvas.files.remoteFetching",{device:e}),o=r?{ref:i,tabIndex:-1,"aria-busy":!0}:{};return t?d.jsx("output",{...o,"aria-label":a,title:a,className:"flex h-[78px] w-[117px] items-center justify-center rounded-sm border border-control bg-sunken","data-attachment-pending":"",children:d.jsx(ti,{size:"sm",className:"text-ink-dim"})}):n?d.jsxs("output",{...o,className:"flex aspect-video w-[427px] max-w-full flex-col items-center justify-center gap-2 self-start rounded-sm border border-hairline bg-sunken px-3","data-attachment-pending":"","data-attachment-pending-video":"",children:[d.jsx(ti,{size:"sm",className:"text-ink-dim"}),d.jsx("span",{className:"min-w-0 max-w-full truncate text-body-sm text-ink-muted",children:a})]}):d.jsxs("output",{...o,className:"flex w-fit max-w-full items-center gap-2.5 rounded-sm border border-hairline bg-sunken px-3 py-2","data-attachment-pending":"",children:[d.jsx(ti,{size:"sm",className:"text-ink-dim"}),d.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink-muted",children:a})]})},h7t="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",WQ=4,ike=2,p7t=2,ake=4,oke=WQ+ike,m7t=.8,g7t=24,see=.3,lee=1;function $7t(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+ike)/oke))}function y7t(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/g7t)):0}function v7t(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 ske(e,t,n){const r=$7t(t),i=e===null?null:v7t(e,r),a=[],o=Math.max(1,r-1);for(let s=0;s<r;s+=1){const l=s*oke,c=l+WQ/2,O=(i===null?0:i[s])*n*m7t,f=Math.max(ake,Math.round(O)),p=see+(lee-see)*(s/o);a.push({x:l,width:WQ,height:f,alpha:Math.min(lee,p)*y7t(c,t)})}return a}function j$(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 b7t(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 w7t(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}const cee=(e,t)=>h("ui.chat.audio.position_value",{current:j$(e),total:j$(t)}),x7t=4,uee=1,lke=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,hideUnknownTotal:a=!1,variant:o="full",className:s})=>{const l=be(),c=Zi(D=>D.ownerId===e),u=Zi(D=>D.ownerId===e?D.status:"idle"),O=Zi(D=>D.ownerId===e?D.duration:0),[f,p]=$.useState(!1),[m,g]=$.useState(!1);$.useEffect(()=>{(u==="loading"||u==="playing")&&g(!1)},[u]);const y=O>0?O:i??0,v=c&&u==="playing",b=c&&u==="loading",x=m||c&&u==="error",Q=$.useRef(null),w=$.useRef(null),S=$.useRef(null),_=$.useRef(null),k=$.useRef(null),[R,E]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const D=Q.current;if(!D)return;const ne=()=>{const L=D.getBoundingClientRect();E({width:L.width,height:L.height,dpr:window.devicePixelRatio||1})};ne();const J=new ResizeObserver(ne);return J.observe(D),()=>J.disconnect()},[]);const T=$.useCallback(D=>{if(!D||R.width<=0)return;const ne=D.getContext("2d");if(!ne)return;D.width=Math.max(1,Math.round(R.width*R.dpr)),D.height=Math.max(1,Math.round(R.height*R.dpr)),ne.setTransform(R.dpr,0,0,R.dpr,0,0),ne.clearRect(0,0,R.width,R.height);const J=getComputedStyle(D).color,L=ske(r,R.width,R.height);ne.fillStyle=J;for(const B of L)ne.globalAlpha=B.alpha,ne.beginPath(),ne.roundRect(B.x,(R.height-B.height)/2,B.width,B.height,p7t),ne.fill();ne.globalAlpha=1},[R.width,R.height,R.dpr,r]);$.useEffect(()=>{T(w.current),T(S.current)},[T]);const q=$.useRef(null),A=$.useCallback(D=>{const ne=w7t(D,y),J=S.current;Q.current?.style.setProperty("--sound-progress",`${ne*100}%`),J&&(J.style.clipPath=`inset(0 ${(1-ne)*100}% 0 0)`);const L=j$(D);k.current&&k.current.textContent!==L&&(k.current.textContent=L);const B=_.current;B&&(B.setAttribute("aria-valuenow",String(Math.floor(D))),B.setAttribute("aria-valuetext",cee(D,y)))},[y,l]);$.useEffect(()=>{const D=v||f,ne=()=>A(c?kT()?.currentTime??0:U.current);if(!D){ne();return}let J=0;const L=()=>{const B=q.current??kT()?.currentTime??0;A(B),J=requestAnimationFrame(L)};return J=requestAnimationFrame(L),()=>cancelAnimationFrame(J)},[v,f,c,A]);const G=$.useCallback(async()=>(g(!1),Zi.getState().play(e,t,{onError:()=>g(!0)})),[e,t]),I=$.useCallback(D=>{const ne=Zi.getState();if(v){ne.seek(e,D),A(D);return}G().then(J=>{J!==!1&&(Zi.getState().seek(e,D),A(D))})},[e,v,G,A]),z=$.useCallback(async()=>{if(v){Zi.getState().pause(e);return}g(!1),await Zi.getState().toggle(e,t,{onError:()=>g(!0)})},[e,t,v]),U=$.useRef(0),Y=$.useRef(null),M=$.useCallback(D=>{const ne=Q.current;if(!ne)return 0;const J=ne.getBoundingClientRect();return b7t(D-J.left,J.width,y)},[y]),C=D=>{if(b)return;D.currentTarget.setPointerCapture?.(D.pointerId),Y.current={pointerId:D.pointerId,startX:D.clientX,moved:!1,pendingX:D.clientX,raf:0}},Z=D=>{const ne=Y.current;!ne||ne.pointerId!==D.pointerId||(Math.abs(D.clientX-ne.startX)>x7t&&(ne.moved||p(!0),ne.moved=!0),ne.pendingX=D.clientX,ne.moved&&ne.raf===0&&(ne.raf=requestAnimationFrame(()=>{const J=Y.current;if(!J)return;J.raf=0;const L=M(J.pendingX);q.current=L,Zi.getState().scrub(e,L),A(L)})))},K=D=>{const ne=Y.current;if(!ne||ne.pointerId!==D.pointerId)return;ne.raf!==0&&cancelAnimationFrame(ne.raf),Y.current=null,q.current=null,D.currentTarget.releasePointerCapture?.(D.pointerId);const J=M(D.clientX);if(ne.moved){U.current=J,p(!1),Zi.getState().seek(e,J),A(J);return}I(J)},N=D=>{const ne=kT(),J=c&&ne?ne.currentTime:0;if(D.key===" "||D.key==="Enter"){D.preventDefault(),z();return}let L=null;if(D.key==="ArrowLeft"?L=J-uee:D.key==="ArrowRight"?L=J+uee:D.key==="Home"?L=0:D.key==="End"&&(L=y),L===null)return;D.preventDefault();const B=Math.max(0,Math.min(y,L));I(B)},ce=o==="compact",ee=h("ui.chat.audio.position_label",{label:n});return d.jsxs("div",{"data-sound-player":o,"data-sound-peaks":r?"stored":"flat","data-sound-status":x?"error":f?"scrubbing":c?u:"idle",className:X("flex w-full min-w-0 items-center gap-2",ce?"gap-1.5":"gap-2",s),children:[d.jsx("button",{type:"button",className:h7t,disabled:b,onClick:()=>void z(),"aria-label":v?h("ui.chat.audio.pause_label",{label:n}):h("ui.chat.audio.play_label",{label:n}),children:b?d.jsx(ti,{size:"sm"}):v?d.jsx(rOe,{size:22,"aria-hidden":"true"}):d.jsx(_6e,{size:22,"aria-hidden":"true"})}),d.jsx("div",{ref:_,role:"slider",tabIndex:0,"aria-label":ee,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(y)),"aria-valuenow":0,"aria-valuetext":cee(0,y),"data-sound-slider":"",className:X("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",x&&"cursor-default"),onPointerDown:C,onPointerMove:Z,onPointerUp:K,onPointerCancel:K,onKeyDown:N,children:d.jsxs("div",{ref:Q,className:"absolute inset-0",children:[d.jsx("canvas",{ref:w,className:"absolute inset-0 h-full w-full text-ink-dim"}),d.jsx("canvas",{ref:S,style:{clipPath:"inset(0 100% 0 0)"},className:"absolute inset-0 h-full w-full text-ink-muted"}),d.jsx("span",{"data-sound-thumb":"",className:X("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",f&&"bg-accent"),style:{left:"var(--sound-progress, 0%)"}})]})}),d.jsx("span",{ref:k,"data-sound-time":"",className:X("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:j$(0)}),d.jsx("span",{"data-sound-total":"","aria-hidden":a&&y<=0?!0:void 0,className:X("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums",a&&y<=0&&"invisible"),children:j$(y)}),x?d.jsx("span",{"data-sound-error":"",className:X("shrink-0 text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.player_failed")}):null]})};function MR(e){return e.live_state.trim().toLowerCase()==="attached"}function p$n(e,t){return e.keep||!e.lost?null:{body:e.lost,confirmLabel:e.to==="local"?h("ui.mesh.mesh_drop.recall_it"):h("ui.mesh.mesh_drop.move_it"),risky:t}}function m$n(e){return e.keep?h("ui.mesh.mesh_actions.the_original_stays_where_it_is"):e.to==="local"?h("ui.mesh.mesh_actions.the_copy_there_is_deleted_once_it"):h("ui.mesh.mesh_actions.the_copy_here_is_deleted_once_it")}function Id(e,t){return h("ui.mesh.mesh_drop.copy_loss",{source:e,destination:t})}function Oee(e,t){return h("ui.mesh.mesh_drop.running_now",{conversation:e.name||h("ui.mesh.mesh_drop.this_conversation"),where:t})}function dee(e,t,n){return e?M$(e,n,!0):t}function S7t(e,t,n){if(e.suspect)return{kind:"refused",code:"suspect_device",sentence:h("ui.mesh.mesh_drop.duplicate_key",{device:M$(e,n,!0),reason:e.reason?` (${e.reason})`:""}),remedy:{kind:"open",label:h("ui.mesh.mesh_drop.see_this_device"),deviceId:t}};if(!e.reachable){const r=yue(vue(e));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.reach_refusal",{device:M$(e,n,!0),reach:r,reason:e.reason?` (${e.reason})`:""}),reach:r,remedy:{kind:"resume",label:h("ui.mesh.mesh_actions.check_again")}}}return null}function g$n(e,t,n){const{session:r,ownerDeviceId:i}=e,{selfDeviceId:a,devices:o,networks:s}=n,l=[...o.keys()],c=o.get(i),u=c?M$(c,l,!0):M$({id:i,name:r.owner_device_name});if(t.kind==="ground")return{kind:"none"};if(t.kind==="network"){const v=s.get(t.networkId);return{kind:"refused",code:"not_a_device",sentence:h("ui.mesh.mesh_drop.network_not_destination",{network:v?.label??h("ui.mesh.mesh_drop.a_network")}),remedy:null}}if(_qe(r))return{kind:"refused",code:"busy",sentence:h("ui.mesh.mesh_drop.turn_in_flight",{conversation:r.name||h("ui.mesh.mesh_drop.this_conversation")}),remedy:{kind:"wait",label:h("ui.mesh.mesh_actions.wait_for_the_turn_to_finish"),waitS:300},plan:{sessionId:r.id,to:t.deviceId===a?"local":t.deviceId,keep:!1,verb:t.deviceId===a?h("ui.mesh.mesh_card.recall_to_this_device"):h("ui.mesh.mesh_card.move_to",{device:dee(o.get(t.deviceId),t.deviceId,l)}),waitS:0,lost:null}};if(i===t.deviceId)return{kind:"none"};const O=o.get(t.deviceId),f=O?S7t(O,t.deviceId,l):{code:"unknown_device",sentence:h("ui.mesh.mesh_drop.that_device_is_no_longer_in_any"),remedy:null};if(f)return{kind:"refused",...f};const p=dee(O,t.deviceId,l);if(!(r.locality==="local")){if(c&&!c.reachable){const v=yue(vue(c));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.owner_reach_refusal",{device:u,reach:v,reason:c.reason?` (${c.reason})`:""}),reach:v,remedy:{kind:"resume",label:h("ui.mesh.mesh_actions.check_again")}}}if(t.deviceId!==a)return{kind:"refused",code:"third_device",sentence:h("ui.mesh.mesh_drop.recall_first",{owner:u}),remedy:null}}if(t.deviceId===a){const v={sessionId:r.id,to:"local",keep:!1,verb:h("ui.mesh.mesh_card.recall_to_this_device"),waitS:0,lost:MR(r)?`${Oee(r,h("ui.mesh.mesh_drop.on_owner",{owner:u}))} ${Id(u,h("ui.mesh.mesh_drop.this_device"))}`:Id(u,h("ui.mesh.mesh_drop.this_device"))};return{kind:"plan",plan:v,risky:MR(r),alternatives:[{...v,keep:!0,verb:h("ui.mesh.mesh_card.copy_here_leave_it_there"),lost:null}]}}if(r.locality==="local"&&t.deviceId===i)return{kind:"none"};const g=MR(r),y={sessionId:r.id,to:t.deviceId,keep:!1,verb:h("ui.mesh.mesh_card.move_to",{device:p}),waitS:0,lost:g?`${Oee(r,h("ui.mesh.mesh_drop.on_this_device"))} ${Id(h("ui.mesh.mesh_drop.this_device"),p)}`:Id(h("ui.mesh.mesh_drop.this_device"),p)};return{kind:"plan",plan:y,risky:g,alternatives:[{...y,keep:!0,verb:h("ui.mesh.mesh_card.copy_to",{device:p}),lost:null}]}}function $$n(e){return e.kind==="refused"?h("ui.mesh.mesh_drop.drop_refusal",{sentence:e.sentence}):e.kind==="plan"?e.plan.verb:null}function Q7t(e){switch(e.kind){case"draft":return e.name;case"local":return"";default:return e.name}}function y$n(e){switch(e.kind){case"draft":return e.deviceId?h("ui.chat.device.label.new_on",{name:e.name}):h("ui.chat.device.label.new_on_this_device");case"local":return h("ui.chat.device.label.on_this_device");case"remote":case"gone":return h("ui.chat.device.label.on",{name:e.name});case"moving":return h("ui.chat.device.label.moving_to",{name:e.name})}}function v$n(e){switch(e.kind){case"draft":return e.deviceId?h("ui.chat.device.sentence.draft_elsewhere",{name:e.name}):h("ui.chat.device.sentence.draft_here");case"local":return h("ui.chat.device.sentence.local");case"remote":return e.reachable===!1?e.reason?h("ui.chat.device.sentence.remote_did_not_answer_reason",{name:e.name,reason:e.reason}):h("ui.chat.device.sentence.remote_did_not_answer",{name:e.name}):h("ui.chat.device.sentence.remote",{name:e.name});case"gone":return e.reachable===!1?h("ui.chat.device.sentence.gone_did_not_answer",{name:e.name}):h("ui.chat.device.sentence.gone",{name:e.name});case"moving":return h("ui.chat.device.sentence.moving",{name:e.name})}}const _7t=()=>h("ui.chat.device.footer.move_deletes_copy");function b$n(e){switch(e){case"enabled":return null;case"unknown":return h("ui.chat.device_move.gate.checking");case"unpaired":return h("ui.chat.device_move.gate.unpaired");case"below-version":return h("ui.chat.device_move.gate.below_version")}}function w$n(e){return e==="unknown"?"dim":"warning"}const k7t=()=>h("ui.chat.device.row.not_here_why"),P7t=()=>h("ui.chat.device.label.this_device"),T7t=()=>h("ui.chat.device.sentence.pairing_guidance"),X7t=()=>h("ui.chat.device.sentence.mesh_read_failure");function R7t(e){return h("ui.chat.device.sentence.move_in_flight",{name:e})}const x$n=()=>h("ui.chat.device.notice.move_hold_detail");function LR(e){return h("ui.chat.device.row.conversations",{count:e})}function S$n(e){return`${e} ${e===1?"device":"devices"}`}function fee(e){return e.canTransfer?e.reachable?h("ui.chat.device_move.ineligible.cannot_receive"):h("ui.chat.device_move.ineligible.no_answer"):h("ui.chat.device_move.ineligible.no_transfer")}function Q$n(e){const{draft:t,host:n,move:r,reachableFor:i}=e;return r?.kind==="moving"?{kind:"moving",deviceId:r.deviceId,name:r.name}:r?.kind==="moved"?r.receipt.locality==="local"||r.deviceId==="local"?{kind:"local"}:r.receipt.source_retired?{kind:"gone",deviceId:r.deviceId,name:r.name,reachable:i(r.deviceId)}:{kind:"remote",deviceId:r.deviceId,name:r.name,reachable:i(r.deviceId),reason:""}:t?{kind:"draft",deviceId:t.deviceId,name:t.name}:n?{kind:"remote",deviceId:n.deviceId,name:n.name,reachable:i(n.deviceId),reason:""}:{kind:"local"}}function _$n(e){const{placement:t,selfDeviceId:n,networks:r,peers:i}=e,a=t.kind==="local"||t.kind==="remote"||t.kind==="gone"||t.kind==="moving",o=t.kind==="gone",s=t.kind==="remote"||t.kind==="draft"||t.kind==="gone"?t.deviceId:null,l=t.kind==="local"||t.kind==="draft"&&t.deviceId===null,c=new Map(i.map(y=>[y.device_id,y])),u=e.selfName.trim(),O={deviceId:n,name:u||P7t(),facts:u?[LR(e.selfConversations),h("ui.chat.device.fact.this_device")]:[LR(e.selfConversations)],state:l?"current":e.canTransfer?"candidate":"ineligible",why:l||e.canTransfer?void 0:fee({canTransfer:!1,reachable:!0})},f=r.map(y=>{const v=y.members.filter(b=>b.device_id!==n&&b.active).map(b=>{const x=c.get(b.device_id),Q=[b.role,x?.session_count!=null?LR(x.session_count):""].filter(Boolean);!b.reachable&&!a&&Q.push("unreachable");const w=e.canTransfer&&b.capabilities.includes("move")&&b.reachable,S=s!==null&&b.device_id===s,_=a&&(!w||o&&!S);return{deviceId:b.device_id,name:b.name,facts:Q,state:S?"current":_?"ineligible":"candidate",why:_?w?k7t():fee({canTransfer:e.canTransfer,reachable:b.reachable}):void 0}});return{key:y.network_id,name:y.name,count:v.length,rows:v}}),p=r.some(y=>y.members.some(v=>v.device_id!==n&&v.active&&v.reachable)),m=r.some(y=>y.members.some(v=>v.device_id!==n&&v.active&&e.canTransfer&&!v.reachable)),g=e.meshRead==="failed";return{heading:a?h("ui.chat.device.picker.heading.move"):h("ui.chat.device.picker.heading.start"),self:O,sections:f,footer:t.kind==="local"||t.kind==="remote"||t.kind==="moving"?_7t():t.kind==="gone"?Id(t.name,h("ui.mesh.mesh_drop.this_device")):null,guidance:e.meshRead==="ok"&&r.length===0?T7t():null,readFailure:g?X7t():null,inFlight:e.busy?R7t(Q7t(t)||h("ui.chat.device_move.another_device")):null,offerCheckAgain:g||r.length>0&&(!p||m)}}function k$n(e){const{engaged:t,name:n,from:r,newSessionId:i,sourceRetired:a}=e;return r!==null?{verb:h("ui.chat.device_move.result.back.verb"),detail:a?h("ui.chat.device_move.result.back.detail_deleted",{from:r}):h("ui.chat.device_move.result.back.detail"),second:null}:a?t===!0?{verb:h("ui.chat.device_move.result.moved.verb",{name:n}),detail:h("ui.chat.device_move.result.moved.detail_running"),second:null}:{verb:h("ui.chat.device_move.result.moved.verb",{name:n}),detail:h("ui.chat.device_move.result.moved.detail_there"),second:h("ui.chat.device_move.result.moved.second",{name:n})}:{verb:h("ui.chat.device_move.result.copied.verb",{name:n}),detail:h("ui.chat.device_move.result.copied.detail",{name:n,id:i.slice(-6)}),second:t===!0?null:h("ui.chat.device_move.result.copied.second",{name:n})}}function E7t(e,t){return e.trim()||t.slice(-8)}function P$n(e){const t={sessionId:e.sessionId,waitS:0},n=e.destination.name,r=h("ui.mesh.mesh_drop.this_device");return e.recall?{plan:{...t,to:"local",keep:!1,verb:h("ui.chat.device_move.plan.recall"),lost:Id(e.source??h("ui.chat.device_move.other_device"),h("ui.mesh.mesh_drop.this_device"))},alternatives:[{...t,to:"local",keep:!0,verb:h("ui.chat.device_move.plan.copy_here"),lost:null}]}:{plan:{...t,to:e.destination.deviceId,keep:!1,verb:h("ui.chat.device_move.plan.move",{name:n}),lost:Id(r,n)},alternatives:[{...t,to:e.destination.deviceId,keep:!0,verb:h("ui.chat.device_move.plan.copy",{name:n}),lost:null}]}}function T$n(e){let t=0;for(const n of e)n.locality!=="remote"&&(t+=1);return t}function cke(e){return E7t(typeof e.owner_device_name=="string"?e.owner_device_name:"",typeof e.owner_device=="string"?e.owner_device:"")||"another device"}function X$n(e){const t=new Map,n=e?.networks;if(!Array.isArray(n))return t;for(const r of n){if(r===null||typeof r!="object")continue;const i=r,a=typeof i.name=="string"?i.name.trim():"";if(!(!a||!Array.isArray(i.members)))for(const o of i.members){if(o===null||typeof o!="object")continue;const s=o.device_id;typeof s!="string"||s===""||t.has(s)||t.set(s,a)}}return t}function R$n(e,t){const n=cke(e),r=(t??"").trim();return r?`on ${n} · ${r}`:`on ${n}`}function E$n(e){return e.reachable!==!1?"":`unreachable · ${(typeof e.unreachable_reason=="string"?e.unreachable_reason.trim():"")||"it did not answer"}`}function qN(e){return fn(t=>{if(!e)return null;const n=t.sessions.find(r=>r.session_id===e);return!n||n.locality!=="remote"?null:cke(n)})}function hee(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 FR=new Map,jN=Symbol("waveform-pending"),CN=Symbol("waveform-unkept");async function q7t(e,t){try{const n=await Ba({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return hee(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return hee(JSON.parse(r))}catch{return null}}return n.status===504?jN:n.status===409?CN:null}catch{return null}}function uke(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?j7t(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let o=!0,s;const l=c=>{C7t({sessionId:n,childId:r},e).then(u=>{if(!o)return;if(u===CN){a(null);return}if(u!==jN){a(u);return}const O=eb[c];O!==void 0&&(s=setTimeout(()=>{s=void 0,o&&l(c+1)},O))})};return l(0),()=>{o=!1,s!==void 0&&clearTimeout(s)}},[e,n,r]),i}function j7t(e){return J6.get(e)??null}const J6=new Map;function C7t(e,t){const n=FR.get(t);if(n)return n;const r=q7t(e,t).then(i=>i===jN||i===CN?(FR.delete(t),i):(J6.set(t,i),i)).catch(()=>(J6.set(t,null),null));return FR.set(t,r),r}function Oke(e){return`sound:${e.attachment??e.id}`}const GP=({audio:e,scope:t,label:n,ownerId:r})=>{const i=tb(e,t),a=uke(e.attachment,t),o=qN(t?.sessionId),[s,l]=$.useState(!1);return i.state==="missing"?d.jsx(Tf,{name:n,detail:rke}):i.state==="retryable"?d.jsx(Qb,{name:n,onRetry:()=>{l(!0),i.retry()},device:o,focusOnMount:s}):i.state==="resolving"&&i.pending&&o?d.jsx(EN,{device:o,focusOnMount:s}):i.state==="resolving"?d.jsx("div",{className:X("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(du,{"data-attachment-reserved":""})}):d.jsx("div",{className:X("w-full max-w-[560px] self-start"),children:d.jsx(lke,{ownerId:r??Oke(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},Td=1,dke=4,pee=(e,t)=>Math.min(dke,Math.max(Td,e+t)),$0=Object.freeze({x:0,y:0}),BR=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),HR=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,z7t=(e,t)=>h("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),mee=(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))}},A7t="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",U7t="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",gee=e=>X(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),W7t="opacity-85",Nh="bg-surface/85 disabled:bg-surface/85",zN=({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})=>{be();const f=c==="video",p=(J,L)=>u==="asset"?h("ui.common.viewer.position",{kind:"asset",index:J+1,count:L}):z7t(J,L),[m,g]=$.useState(null),y=e!==void 0&&m===e,[v,b]=$.useState(Td),[x,Q]=$.useState($0),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,b(Td),Q($0))},[e]);const[S,_]=$.useState(!0),k=$.useRef(null);$.useEffect(()=>{if(!n)return;let J;const L=()=>{clearTimeout(J),J=setTimeout(()=>{const ae=k.current;if(ae&&(ae.matches(":hover")||ae.contains(document.activeElement))){L();return}_(!1)},bhe)},B=()=>{_(!0),L()};return _(!0),L(),document.addEventListener("pointermove",B,{passive:!0}),document.addEventListener("pointerdown",B,{passive:!0}),document.addEventListener("keydown",B),document.addEventListener("focusin",B),()=>{clearTimeout(J),document.removeEventListener("pointermove",B),document.removeEventListener("pointerdown",B),document.removeEventListener("keydown",B),document.removeEventListener("focusin",B)}},[n]);const R=s?.onPrev,E=s?.onNext,T=s!==void 0&&s.count>1,q=T?U7t:A7t,A=$.useRef(null),G=l??A;$.useEffect(()=>{if(!n||!T)return;const J=L=>{L.defaultPrevented||L.metaKey||L.ctrlKey||L.altKey||(L.key==="ArrowLeft"?(L.preventDefault(),R?.()):L.key==="ArrowRight"&&(L.preventDefault(),E?.()))};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[n,T,R,E]),uA(n,"lightbox");const I=$.useRef(null),z=!f&&e!==void 0&&!y,U=v===Td&&x.x===$0.x&&x.y===$0.y,Y=J=>{if(!z)return;b(J);const L=I.current;L&&Q(B=>mee(B,{width:L.clientWidth,height:L.clientHeight},J))},M=()=>{z&&(b(Td),Q($0))},C=$.useRef(null),[Z,K]=$.useState(!1),N=z&&v>Td,ce=J=>{!N||J.button!==0||(J.currentTarget.setPointerCapture(J.pointerId),C.current={pointerId:J.pointerId,startX:J.clientX,startY:J.clientY,pan:x},K(!0))},ee=J=>{const L=C.current,B=I.current;!L||L.pointerId!==J.pointerId||!B||Q(mee({x:L.pan.x+(J.clientX-L.startX),y:L.pan.y+(J.clientY-L.startY)},{width:B.clientWidth,height:B.clientHeight},v))},D=J=>{C.current?.pointerId===J.pointerId&&(C.current=null,K(!1))},ne=e!==void 0&&!y?d.jsx("div",{ref:I,"data-image-viewport":"",tabIndex:-1,className:X(q,"relative h-fit w-fit overflow-hidden leading-none outline-none",N&&(Z?"cursor-grabbing":"cursor-grab"),N&&"touch-none"),onPointerDown:ce,onPointerMove:ee,onPointerUp:D,onPointerCancel:D,children:f?d.jsx("video",{src:e,controls:!0,autoPlay:!0,className:X(q,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):d.jsx("img",{src:e,alt:t,draggable:!1,className:X(q,"block select-none object-contain"),style:U?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${v})`},onError:()=>g(e)})}):e===void 0&&o?d.jsx("div",{className:gee(q),"aria-hidden":"true"}):d.jsx("div",{className:gee(q),children:a});return d.jsx(QA,{open:n,onOpenChange:r,children:d.jsxs(_A,{ref:G,tabIndex:-1,onOpenAutoFocus:J=>{J.preventDefault(),(I.current??G.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:J=>{const L=i?.current;L&&(J.preventDefault(),L.focus())},className:X("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",q,"gap-0 rounded-none bg-transparent p-0 shadow-none"),...O,children:[d.jsx(kA,{className:"sr-only",children:t}),T&&s?d.jsx("div",{"aria-live":"polite",className:"sr-only",children:p(s.index,s.count)}):null,ne,d.jsxs("div",{ref:k,"data-image-viewer-controls":"",className:X("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",S?"opacity-100 duration-fast":`${W7t} duration-base`),children:[T&&s?.filmstrip?d.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,T?d.jsxs(d.Fragment,{children:[d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.previous",{kind:u}),title:h("ui.common.viewer.previous",{kind:u}),onClick:s?.onPrev,className:X("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",Nh),"data-image-viewer-prev":"",children:d.jsx(d6e,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.next",{kind:u}),title:h("ui.common.viewer.next",{kind:u}),onClick:s?.onNext,className:X("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",Nh),"data-image-viewer-next":"",children:d.jsx(Cue,{"aria-hidden":"true"})})]}):null,!f&&d.jsxs("div",{className:"pointer-events-auto fixed right-4 bottom-4 flex items-center gap-1",children:[d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_out"),title:h("ui.common.viewer.zoom_out"),disabled:!z||v===Td,onClick:()=>Y(pee(v,-1)),className:Nh,children:d.jsx($Oe,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_in"),title:h("ui.common.viewer.zoom_in"),disabled:!z||v===dke,onClick:()=>Y(pee(v,1)),className:Nh,children:d.jsx(gOe,{"aria-hidden":"true"})}),d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.reset_view"),title:h("ui.common.viewer.reset_view"),disabled:!z||U,onClick:M,className:Nh,children:d.jsx(dk,{"aria-hidden":"true"})})]}),d.jsx(N3e,{asChild:!0,children:d.jsx(ve,{variant:"ghost",size:"icon-sm",className:X("pointer-events-auto fixed top-4 right-4",Nh),"aria-label":h("ui.common.viewer.close",{kind:u}),title:h("ui.common.viewer.close",{kind:u}),children:d.jsx(Zr,{"aria-hidden":"true"})})})]})]})})};zN.displayName="ImageLightbox";const N7t={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(" ")},Y7t=/[/\\]/,$ee=e=>{const t=e.split(Y7t);return t[t.length-1]},fke=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:o,pathActions:s})=>{be();const[l,c]=$.useState(!1),[u,O]=$.useState(!1),[f,p]=$.useState(!1),m=$.useRef(null),g=It(E=>E.setCanvasOpen),{setViewMode:y}=Wd(),v=$.useCallback(async()=>{const E=$ee(e),T=I=>{I&&console.error("Error processing file:",I);const z=e.startsWith("file://")?e.substring(7):e;window.api.openFile(z).catch(U=>{console.error("Error opening file:",U)})},{setFiles:q,setOpenTabs:A,setSelectedTab:G}=Wd.getState();if(e.startsWith("data:"))if(C6(E)){const I=e,z={id:I,title:E,path:I,content:e,type:NS(e)},Y=Wd.getState().conversations?.[n],M=Y?.files??[],C=Y?.openTabs??[],Z=(()=>{const ce=M.findIndex(ee=>ee.id===I);return ce!==-1?[...M.slice(0,ce),z,...M.slice(ce+1)]:[...M,z]})();q(n,Z);const N=C.some(ce=>ce.id===I)?C:[...C,{id:I,title:E}];A(n,N),G(n,I),g(!0),y(n,"documents")}else g(!0),y(n,"files");else{const I=e.startsWith("file://")?e.substring(7):e;try{const z=await window.api.readFile(I);if(z.success&&C6(E)){const U=I,Y={id:U,title:E,path:I,content:z.data,type:NS(e)},C=Wd.getState().conversations?.[n],Z=C?.files??[],K=C?.openTabs??[],N=(()=>{const D=Z.findIndex(ne=>ne.id===U);return D!==-1?[...Z.slice(0,D),Y,...Z.slice(D+1)]:[...Z,Y]})();q(n,N);const ee=K.some(D=>D.id===U)?K:[...K,{id:U,title:E}];A(n,ee),G(n,U),g(!0),y(n,"documents");return}g(!0),y(n,"files")}catch(z){const U=z instanceof Error?z.message:String(z??"Unknown error reading file");return T(U)}}},[e,g,y,n]),b=()=>{c(!0)},x=mN(e),w=(x==="path"||x==="data")&&n!==""||!!s?.onShowInCanvas,S=o_e(x,{canShowInCanvas:w,source:t,artifactPathActions:!!s}),_=x==="path",k=r??$ee(e);if(l)return d.jsx(Tf,{name:k,compact:i==="thumbnail"});const R=d.jsx(du,{boundary:i==="thumbnail"?"control":"hairline",children:d.jsx("img",{className:X(N7t[i],u?"opacity-100":"opacity-0"),src:t,alt:k,loading:"lazy",decoding:"async",onLoad:()=>O(!0),onError:b})});return d.jsxs("div",{className:"group relative inline-block",children:[d.jsx("button",{ref:m,type:"button",className:X("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:o?o.onPress:()=>p(!0),"aria-label":o?o.label:h("ui.chat.attachments.expand_aria",{name:k}),title:o?o.title:h("ui.chat.attachments.expand_title",{name:k}),"aria-current":o?.current?"true":void 0,children:R}),S&&d.jsx("div",{className:"file-actions-menu pointer-events-none absolute top-1 end-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:E=>{E.stopPropagation()},onKeyDown:E=>E.stopPropagation(),children:d.jsx(c_e,{file:e,src:t,label:k,onShowInCanvas:s?.onShowInCanvas??(w?v:void 0),resolvePath:s?.resolvePath})}),o?null:a?a({open:f,onOpenChange:p,restoreFocusTo:m}):d.jsx(zN,{src:t,label:k,open:f,onOpenChange:p,restoreFocusTo:m,fallback:d.jsx(Tf,{name:k,detail:_?void 0:RN})})]})});fke.displayName="ImageAttachment";function AN(e,t){return h("ui.chat.canonical.media.image_label",{position:e,count:t})}function G7t(e,t){return h("ui.chat.canonical.media.sound_label",{position:e,count:t})}const I7t=(e,t,n)=>e.name??AN(t+1,n),k1=(e,t)=>h("ui.chat.canonical.lightbox.show_image",{index:e,count:t}),Z7t={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},D7t=({cold:e,children:t})=>e?d.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,V7t=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:o=I7t})=>{be();const s=e.length,[l,c]=$.useState(()=>BR(t,s)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(BR(t,s)));const f=BR(l,s),p=e[f]??Z7t,m=o(p,f,s),g=I8(p,n),y=$.useRef(null),v=$.useRef(null),[b,x]=$.useState(!1),Q=$.useCallback(U=>{y.current=U,x(U!==null)},[]),w=U=>{const Y=y.current?.querySelector(`[data-image-slot="${U+1}"] button`);Y?Y.focus():v.current?.focus()},S=U=>{const Y=HR(f,s,U),M=y.current?.contains(document.activeElement)??!1;c(Y),M&&w(Y)},_=()=>S(-1),k=()=>S(1),R=JSON.stringify([n?.sessionId,n?.childId,e.map(U=>[U.id,U.attachment,U.mimeType])]),[E,T]=$.useState(()=>({identity:R,open:r,indices:new Set}));(E.identity!==R||E.open!==r)&&T({identity:R,open:r,indices:new Set});const q=$.useCallback(U=>{T(Y=>{if(!r||Y.identity!==R||!Y.open||U.every(C=>Y.indices.has(C)))return Y;const M=new Set(Y.indices);for(const C of U)M.add(C);return{...Y,indices:M}})},[R,r]),A=HR(f,s,-1),G=HR(f,s,1);$.useEffect(()=>{r&&q([f,A,G])},[r,f,A,G,q]),$.useEffect(()=>{const U=y.current;if(!r||!b||!U||typeof IntersectionObserver>"u")return;let Y=!0;const M=new IntersectionObserver(C=>{Y&&q(C.filter(Z=>Z.isIntersecting).map(Z=>Number(Z.target.dataset.imageSlot)-1))},{root:U});for(const C of U.querySelectorAll("[data-image-slot]"))M.observe(C);return()=>{Y=!1,M.disconnect()}},[r,b,q]);const I=(U,Y)=>!!U.data||!U.attachment||Y===f||Y===A||Y===G||E.identity===R&&E.open&&E.indices.has(Y);$.useEffect(()=>{(y.current?.querySelector(`[data-image-slot="${f+1}"]`)??y.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[b,f]);const z=s>1?d.jsx("ul",{role:"list",ref:Q,"aria-label":h("ui.chat.canonical.lightbox.filmstrip_aria",{count:s,count_display:String(s)}),"data-image-filmstrip":"",className:"flex max-w-full items-center gap-2 overflow-x-auto px-2 py-1 leading-none",children:e.map((U,Y)=>d.jsx("li",{"data-image-slot":Y+1,className:X("flex shrink-0 scroll-mx-px rounded-sm leading-none",Y===f&&"ring-1 ring-ink"),children:d.jsx(D7t,{cold:!!U.attachment&&!U.data,children:I(U,Y)?d.jsx(Jf,{image:U,scope:n,size:"thumbnail",label:o(U,Y,s),press:{onPress:()=>c(Y),label:k1(Y+1,s),title:k1(Y+1,s),current:Y===f}}):d.jsx("button",{type:"button","aria-label":k1(Y+1,s),title:k1(Y+1,s),className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{q([Y]),c(Y)},children:d.jsx(du,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},U.id))}):void 0;return d.jsx(zN,{src:g.state==="ready"?g.url:void 0,pending:g.state==="resolving",label:m,open:r,onOpenChange:i,restoreFocusTo:a,fallback:g.state==="retryable"?d.jsx(Qb,{name:m,onRetry:g.retry}):d.jsx(Tf,{name:m,detail:RN}),layerRef:v,group:{index:f,count:s,onPrev:_,onNext:k,filmstrip:z}})},Jf=({image:e,scope:t,label:n,size:r,group:i,press:a,pathActions:o})=>{const s=I8(e,t),l=qN(t?.sessionId),[c,u]=$.useState(!1);if(s.state==="resolving"&&s.pending&&l&&!a)return d.jsx(EN,{device:l,compact:r==="thumbnail",focusOnMount:c});if(s.state==="resolving"){const f=d.jsx(du,{boundary:r==="thumbnail"?"control":"hairline",className:r==="thumbnail"?"h-[78px] w-[117px]":void 0,"data-attachment-reserved":""});return a?d.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:f}):d.jsx("div",{className:X("inline-block max-w-full"),"aria-hidden":!0,children:f})}if(s.state==="retryable")return d.jsx(Qb,{name:n,compact:r==="thumbnail",onRetry:()=>{u(!0),s.retry()},device:l,focusOnMount:c});if(s.state==="missing")return d.jsx(Tf,{name:n,compact:r==="thumbnail",detail:RN});const O=s.url;return d.jsx("div",{className:X("inline-block max-w-full"),children:d.jsx(fke,{file:O,src:O,label:n,size:r,conversationId:t?.sessionId??"",press:a,pathActions:o,overlay:i?f=>d.jsx(V7t,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:f.open,onOpenChange:f.onOpenChange,restoreFocusTo:f.restoreFocusTo}):void 0})})};function M7t(){return h("ui.chat.checkpoint.generating_name")}const L7t={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 F7t(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function hke(e,t){return h("ui.chat.checkpoint.turn",{turn:e,total:t})}function B7t(e,t){const n=hke(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function H7t(e){return e.kind==="completion"&&e.naming?.state==="pending"}function K7t(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function J7t(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const eCt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function tCt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":zv(t,{hour:"numeric",minute:"2-digit"})}function nCt(e,t){if(e.kind==="user"){const r=tCt(e.ts);return r?h("ui.chat.checkpoint.jump_user",{turn:e.turn,total:t,clock:r}):h("ui.chat.checkpoint.jump_user_no_clock",{turn:e.turn,total:t})}const n=e.naming?.state==="ready"?e.naming.name?.trim():"";return n?h("ui.chat.checkpoint.jump_agent",{turn:e.turn,total:t,name:n}):h("ui.chat.checkpoint.jump_agent_unnamed",{turn:e.turn,total:t})}function rCt(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 KR(e,t){const n=[];for(const r of t)rCt(e,r)==="pending"&&n.push(r);return n}const iCt=120,yee=80,Nc=10,NQ=24,aCt=2,ez=420,pke=32;function IP(e,t){return(t?aCt:0)+NQ+e*Nc}function vee(e,t){return IP(e,t)+NQ}function oCt(e,t,n){if(t<=0)return{start:0,end:0};const r=pke*Nc,i=Math.floor(Math.max(0,e)/r),a=i*r-ez,o=(i+1)*r+2*ez,s=IP(0,n),l=Math.max(0,Math.floor((a-s)/Nc)),c=Math.min(t,Math.ceil((o-s)/Nc));return{start:Math.min(l,c),end:c}}function sCt(e,t,n,r,i=24){const a=IP(e,t),o=a+Nc;return a<n+i?Math.max(0,a-i):o>n+r-i?o-r+i:null}const lCt=()=>h("ui.chat.canonical.checkpoint_rail.label"),cCt={complete:Ai,error:nu,interrupted:AA,open:w6e},uCt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},OCt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?cCt[n]:null,i=K7t(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:X("text-body-sm font-medium text-ink"),children:[hke(e.turn,t),a&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:X("font-normal text-ink-muted"),children:a})]})]}),H7t(e)&&d.jsx("p",{className:X("text-ink-dim text-meta"),children:M7t()}),i&&d.jsx("p",{className:X("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&d.jsx("div",{className:X("flex items-center gap-1.5 text-ink-dim text-meta"),children:d.jsxs("span",{className:X("flex items-center gap-1",uCt[n]),children:[d.jsx(r,{"aria-hidden":"true",className:X("size-3.5 shrink-0")}),eCt[n]]})})]})},dCt=$.memo(function({checkpoint:t,state:n,label:r,top:i,roving:a,registerTick:o,onPreview:s,onPreviewEnd:l,onFocusMark:c,onBlurMark:u,onActivate:O,onKeyMark:f,describedBy:p}){const m=g=>{g.pointerType!=="touch"&&s(t.id)};return d.jsx("button",{ref:g=>o(t.id,g),type:"button","data-checkpoint-id":t.id,"data-mark-state":n,"aria-label":r,"aria-describedby":p,tabIndex:a?0:-1,className:X("group pointer-events-auto absolute start-0 block h-2.5 w-7"),style:{top:i},onPointerMove:m,onPointerLeave:l,onFocus:()=>c(t.id),onBlur:u,onClick:()=>O(t.id),onKeyDown:g=>f(g,t.id),children:d.jsx("span",{"aria-hidden":"true",className:X("ms-auto me-1.5 block h-0.5 w-5 origin-right rtl:origin-left rounded-full","transition-[transform,background-color] duration-fast ease-out-quart","motion-reduce:transition-none",L7t[n])})})}),fCt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:o=null})=>{be();const s=$.useId(),[l,c]=$.useState(null),[u,O]=$.useState(null),[f,p]=$.useState(null),m=$.useRef(t);m.current=t;const g=$.useRef(new Map),y=$.useRef(null),v=$.useMemo(()=>new Map(t.map((Oe,we)=>[Oe.id,we])),[t]),b=$.useRef(v);b.current=v;const x=$.useRef(i);x.current=i;const[Q,w]=$.useState({sessionId:"",top:0}),S=pke*Nc,_=$.useCallback(Oe=>{const we=Math.floor(Math.max(0,Oe)/S)*S;w(Je=>Je.sessionId===e&&Je.top===we?Je:{sessionId:e,top:we})},[S,e]),k=Q.sessionId===e?Q.top:Math.max(0,vee(t.length,i)-ez),R=$.useRef(null),E=$.useRef(null),T=$.useCallback(()=>{R.current!==null&&(clearTimeout(R.current),R.current=null),E.current!==null&&(clearTimeout(E.current),E.current=null)},[]),q=$.useCallback((Oe,we)=>{T();const Je=()=>{O(Oe),p(m.current.find(ct=>ct.id===Oe)??null)};if(we<=0){Je();return}R.current=setTimeout(()=>{R.current=null,Je()},we)},[T]),A=$.useCallback(Oe=>{if(T(),Oe<=0){O(null);return}E.current=setTimeout(()=>{E.current=null,O(null)},Oe)},[T]),G=$.useRef(e);$.useEffect(()=>{G.current!==e&&(G.current=e,T(),L.current=null,c(null),O(null),p(null))},[e,T]);const I=$.useRef(null);$.useLayoutEffect(()=>{const Oe=y.current;if(!(t.length===0||Oe===null)){if(o!==null&&z.current===e){I.current=e,_(Oe.scrollTop);return}I.current!==e&&(I.current=e,Oe.scrollTop=vee(t.length,i),_(Oe.scrollTop))}},[o,i,t.length,e,_]);const z=$.useRef(null);$.useLayoutEffect(()=>{if(o===null)return;const Oe=y.current,we=b.current.get(o);if(Oe===null||we===void 0)return;z.current=e;const Je=sCt(we,x.current,Oe.scrollTop,Oe.clientHeight);Je!==null&&(Oe.scrollTop=Je),_(Oe.scrollTop)},[o,e,_]),$.useEffect(()=>()=>T(),[T]);const U=$.useRef(r);$.useEffect(()=>{U.current=r});const Y=$.useMemo(()=>J7t(t),[t]),M=u&&f?.id===u?f:null,C=u&&g.current.get(u)||null,Z=$.useMemo(()=>({current:C}),[C]),K=M!==null&&C!==null;$.useEffect(()=>{U.current(K&&u?u:null)},[K,u]);const N=$.useCallback((Oe,we)=>{we?g.current.set(Oe,we):g.current.delete(Oe)},[]),[ce,ee]=$.useState(null),D=ce&&v.has(ce)?ce:t[0]?.id??null,ne=$.useRef(null),J=$.useCallback(Oe=>{const we=Math.max(0,Math.min(t.length-1,Oe)),Je=t[we];if(!Je)return;ee(Je.id);const ct=g.current.get(Je.id);if(ct){ct.focus();return}const nt=y.current;nt!==null&&(nt.scrollTop=Math.max(0,IP(we,i)+Nc/2-nt.clientHeight/2),_(nt.scrollTop)),ne.current=Je.id},[i,t,_]);$.useLayoutEffect(()=>{const Oe=ne.current;if(Oe===null)return;const we=g.current.get(Oe);we&&(ne.current=null,we.focus())});const L=$.useRef(null),B=$.useCallback(Oe=>{L.current!==Oe&&(L.current=Oe,c(Oe),q(Oe,iCt))},[q]),ae=$.useCallback(()=>{L.current=null,c(Oe=>Oe===null?Oe:null),A(yee)},[A]),ie=$.useCallback(Oe=>{L.current=Oe,ee(Oe),c(we=>we===Oe?we:Oe),q(Oe,0)},[q]),ke=$.useCallback(()=>{L.current=null,c(Oe=>Oe===null?Oe:null),A(yee)},[A]),fe=$.useCallback(Oe=>{A(0),L.current=null,c(null),n(Oe)},[A,n]),_e=$.useCallback((Oe,we)=>{if(Oe.key==="Escape"){A(0);return}const Je=v.get(we);if(Je!==void 0){if(Oe.key==="ArrowDown"){Oe.preventDefault(),Oe.stopPropagation(),J(Je+1);return}if(Oe.key==="ArrowUp"){Oe.preventDefault(),Oe.stopPropagation(),J(Je-1);return}if(Oe.key==="Home"){Oe.preventDefault(),Oe.stopPropagation(),J(0);return}Oe.key==="End"&&(Oe.preventDefault(),Oe.stopPropagation(),J(t.length-1))}},[t.length,A,J,v]),qe=oCt(k,t.length,i),Ce=[];for(let Oe=qe.start;Oe<qe.end;Oe+=1)Ce.push(Oe);for(const Oe of[D,u,l]){const we=Oe===null?void 0:v.get(Oe);we!==void 0&&(we<qe.start||we>=qe.end)&&!Ce.includes(we)&&Ce.push(we)}return Ce.sort((Oe,we)=>Oe-we),t.length===0&&!i?null:d.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":lCt(),className:X("pointer-events-none absolute inset-y-0 end-3 z-10 hidden w-7 select-none","flex-col justify-center","@[900px]/chatcol:flex"),children:[d.jsxs("div",{"data-rail-frame":"","data-checkpoint-count":t.length,ref:y,onScroll:Oe=>_(Oe.currentTarget.scrollTop),className:X("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&&d.jsx("span",{"aria-hidden":"true","data-rail-building":"",className:X("ms-auto me-1.5 block h-0.5 w-5 animate-pulse-visible rounded-full bg-ink-dim")}),d.jsx("div",{"data-rail-track":"",className:"relative py-6",style:{height:t.length*Nc+2*NQ},children:Ce.map(Oe=>{const we=t[Oe];return d.jsx(dCt,{checkpoint:we,top:NQ+Oe*Nc,state:F7t({id:we.id,previewId:l,activeId:o,loaded:a?a.has(we.id):!0}),label:nCt(we,Y),roving:we.id===D,registerTick:N,onPreview:B,onPreviewEnd:ae,onFocusMark:ie,onBlurMark:ke,onActivate:fe,onKeyMark:_e,describedBy:K&&u===we.id?s:void 0},we.id)})})]}),d.jsxs(Y3e,{open:K,onOpenChange:Oe=>{Oe||A(0)},children:[d.jsx(G3e,{virtualRef:Z}),M&&d.jsx(I3e,{id:s,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":M.kind==="user"?h("ui.chat.transcript_copy.row.your_message"):B7t(M,Y),onOpenAutoFocus:Oe=>Oe.preventDefault(),onCloseAutoFocus:Oe=>Oe.preventDefault(),onFocusOutside:Oe=>{const we=Oe.detail?.originalEvent?.target;we instanceof Element&&we.closest("[data-lo-checkpoint-rail]")&&Oe.preventDefault()},className:X("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:M.kind==="user"?d.jsx("div",{"data-checkpoint-card-text":"",className:X("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:M.text}):d.jsx(OCt,{checkpoint:M,turnCount:Y})})]})]})},hCt=$.memo(fCt),pCt={cold:"ui.chat.canonical.loading.cold",revalidating:"ui.chat.canonical.loading.revalidating",older:"ui.chat.canonical.loading.older",remote:"ui.chat.canonical.loading.remote"};function mke(e){return h(pCt[e])}const tz=({variant:e,announce:t=!0,isSmallView:n=!1,className:r})=>{be();const i=d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-lo-loading-mark":!0,className:"inline-flex shrink-0",children:d.jsx(ti,{size:"sm",className:"border-2 forced-colors:border-[CanvasText] forced-colors:border-t-[Highlight]"})}),d.jsx("span",{"data-lo-loading-pill":!0,className:"min-w-0 truncate rounded-full bg-accent/10 px-2 text-ink-muted text-meta",children:mke(e)})]}),a=X("flex min-w-0 items-center gap-2 font-sans",n&&"gap-1.5",r);return t?d.jsx("output",{"aria-label":e==="cold"?h("ui.chat.canonical.loading.region_label"):void 0,"data-lo-conversation-loading":e,className:a,children:i}):d.jsx("span",{"data-lo-conversation-loading":e,className:a,children:i})};function mCt(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 gCt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function $Ct(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function gke(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):!gCt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function yCt(e,t){return $Ct(e,t)||gke(e,t)!==null}const vCt=3;function bCt(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>=vCt){n.onMissing();return}const s=gke(e,t)?.querySelector("button[aria-expanded]");if(!s){n.onMissing();return}s.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const bee=(e,t,n)=>AN(t+1,n),wee=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{be();const{shown:a,more:o}=e7t(e.length,{uncapped:r}),s=t7t(a),l=s.length>1,c=new Set;for(let O=0,f=0;f<s.length;f+=1)c.add(O),O+=s[f];const u=e.slice(0,a).map((O,f)=>d.jsx("li",{className:X("flex leading-none",l&&c.has(f)&&"col-start-1"),children:d.jsx(Jf,{image:O,scope:t,size:"thumbnail",label:bee(O,f,e.length),group:{images:e,index:f,labelFor:bee}})},O.id));return d.jsxs("ul",{role:"list","aria-label":h("ui.chat.canonical.fold.images_aria",{count_display:String(e.length),count:e.length}),"data-fold-media":"",className:X("mt-2 gap-2",l?"grid grid-cols-[repeat(4,max-content)] items-start":"flex flex-wrap items-center",i==="content"?"ms-5":"ms-0"),children:[u,o>0&&d.jsx("li",{className:X("flex h-[78px] items-center leading-none"),children:d.jsx(ve,{variant:"outline",size:"sm",onClick:n,"aria-label":h("ui.chat.canonical.fold.more_images",{count_display:String(o),count:o}),title:h("ui.chat.canonical.fold.more_images",{count:o,count_display:String(o)}),children:`+${o}`})},"fold-media-more")]})};function xee(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 wCt(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)))}function xCt(e,t){return e===null?{session:t,key:String(t)}:t===null||t===e.session?e:e.session===null?{session:t,key:e.key}:{session:t,key:t}}const SCt=({video:e,scope:t,label:n})=>{const r=tb(e,t),[i,a]=$.useState(!1),o=qN(t?.sessionId),[s,l]=$.useState(!1);return r.state==="retryable"?d.jsx(Qb,{name:n,onRetry:()=>{l(!0),r.retry()},device:o,focusOnMount:s}):r.state==="resolving"&&r.pending&&o?d.jsx(EN,{device:o,video:!0,focusOnMount:s}):r.state==="missing"||i?d.jsx(Tf,{name:n,detail:nke}):r.state==="resolving"?d.jsx("div",{className:X("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(du,{"data-attachment-reserved":""})}):d.jsx("div",{className:X("inline-block max-w-full self-start"),children:d.jsx(du,{children:d.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:X("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function QCt({items:e,summary:t,scope:n}){return be(),d.jsxs("div",{"data-sound-batch":"",className:X("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[d.jsx("p",{className:X("text-meta text-ink-muted break-words [overflow-wrap:anywhere]"),children:t}),d.jsx("ul",{className:"flex min-w-0 flex-col gap-4",children:e.map(r=>d.jsxs("li",{"data-sound-batch-item":"",className:X("min-w-0"),children:[d.jsx("p",{className:X("text-body text-ink break-words [overflow-wrap:anywhere]"),children:r.status==="completed"?r.label:h("ui.chat.canonical.sound.batch.item_status",{status:r.status,label:r.label})}),r.error?d.jsx("p",{className:X("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?d.jsx(GP,{audio:r.audio,ownerId:`${Oke(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):d.jsx("p",{className:X("text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.batch_attachment_unavailable")}),d.jsx("p",{className:X("text-meta text-ink-dim"),children:r.costCaption??h("ui.chat.canonical.sound.cost.unknown")})]},r.id))})]})}function q$n({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,o]=$.useState(!1),s=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const p=l.current!==e;l.current=e,!(!p&&t)&&a&&(o(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{o(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const p=s.current?.querySelector("[data-sound-stop-confirmation] button");if(p){p.focus();return}if(t){o(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{o(!1),i(),r()},[r,i]),f=$.useMemo(()=>a&&t?d.jsx($ke,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:s,stop:u,confirmation:f}}function $ke({onKeepWaiting:e,onRequestStop:t}){be();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]),d.jsxs("fieldset",{"data-sound-stop-confirmation":"","aria-label":h("ui.chat.canonical.sound.stop.confirm_label"),className:"flex flex-col items-start gap-2",children:[d.jsx("p",{className:"text-meta text-ink","aria-live":"polite",children:h("ui.chat.canonical.sound.stop.question")}),d.jsx("p",{id:r,className:"text-body-sm text-ink-dim",children:h("ui.chat.canonical.sound.stop.warning")}),d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[d.jsx(ve,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:h("ui.chat.canonical.sound.stop.keep_waiting")}),d.jsx(ve,{variant:"secondary",size:"sm",onClick:t,children:h("ui.chat.canonical.sound.stop.request_stop")})]})]})}const _Ct=1e3;function kCt(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,_Ct);return()=>window.clearInterval(i)},[e]),t}function PCt(){return d.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:X("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:d.jsx("span",{className:X("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 See=44,TCt=240,JR=12,XCt=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function RCt({state:e}){const t=ske(XCt,TCt-JR*2,See);return d.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:X("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:See},children:d.jsx("div",{className:X("flex w-full items-center"),style:{paddingLeft:JR,paddingRight:JR},children:t.map((n,r)=>d.jsx("span",{"data-sound-loading-bar":"",className:X("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:WQ,height:e==="failed"?ake:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function Fu(e){return e==="sound-effect"?"sound_effect":e}function YQ(e){const t=h("ui.chat.canonical.image_gen.cancel.running");return e?`${t} ${h("ui.chat.canonical.image_gen.cancel.checking")}`:t}function yke(e,t){return!e||e.vendorStopped===null?null:e.vendorStopped?h("ui.chat.canonical.image_gen.cancel.queued"):YQ(t&&e.settling)}function ECt(e){switch(e){case"audio_rate_limited":return h("ui.chat.canonical.image_gen.error_class.audio_rate_limited");case"unknown_tool":return h("ui.chat.canonical.image_gen.error_class.unknown_tool");case"invalid_arguments":return h("ui.chat.canonical.image_gen.error_class.invalid_arguments");case"duplicate_id":return h("ui.chat.canonical.image_gen.error_class.duplicate_id");case"denied":return h("ui.chat.canonical.image_gen.error_class.denied");case"gate_failed":return h("ui.chat.canonical.image_gen.error_class.gate_failed");default:{const t=e.replace(/_/g," ");return t.charAt(0).toUpperCase()+t.slice(1)}}}function qCt({view:e,elapsed:t}){let n,r=null,i=!1;switch(e.state){case"queued":n=e.composing?h("ui.chat.canonical.image_gen.state.writing_request"):h("ui.chat.canonical.image_gen.state.queued"),r=e.queuePosition!==null?h("ui.chat.canonical.image_gen.state.queue_ahead",{count:e.queuePosition}):e.argumentBytes>0?rx(e.argumentBytes):null;break;case"running":n=e.batchProgress?h("ui.chat.canonical.image_gen.state.running_batch",{material:Fu(e.material),total:e.batchProgress.total}):h("ui.chat.canonical.image_gen.state.running",{material:Fu(e.material)}),r=t===null?null:QO(t);break;case"cancelling":n=e.generating?YQ(!0):h("ui.chat.canonical.image_gen.cancel.queued");break;case"done":n=e.receipt==="already-finished"?h("ui.chat.canonical.image_gen.state.already_finished"):e.batch?h("ui.chat.canonical.image_gen.state.done_batch",{material:Fu(e.material)}):h("ui.chat.canonical.image_gen.state.done",{material:Fu(e.material)}),r=e.receipt==="already-finished"||e.durationS===null?null:$A(e.durationS);break;case"failed":n=e.batch?h("ui.chat.canonical.image_gen.state.failed_batch",{material:Fu(e.material)}):e.message??(e.errorCode==="audio_rate_limited"?h("ui.chat.canonical.image_gen.error.audio_rate_limited"):h("ui.chat.canonical.image_gen.state.failed",{material:Fu(e.material)})),i=!0;break;case"cancelled":{const a=!!(e.settlementCaption||e.settled),o=yke(e.cancel,!a),s=e.message?a?_7e(e.message):e.message:e.generating?YQ(!a):h("ui.chat.canonical.image_gen.cancel.queued");n=e.batch?h("ui.chat.canonical.image_gen.state.cancelled_batch",{material:Fu(e.material??"sound-effect")}):o??s;break}}return d.jsxs("p",{className:X("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[d.jsx("span",{className:X("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:d.jsxs("span",{className:X("shrink-0 text-meta text-ink-dim"),children:["· ",d.jsx("bdi",{dir:"auto",children:r})]})]})}function jCt({line:e}){return d.jsx("p",{"data-imagegen-log":"",title:e,className:X("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function Sd({line:e,prominent:t=!1}){return d.jsx("p",{"data-imagegen-note":"",className:X("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function CCt(e,t){return e==="cancel"?h("ui.chat.canonical.image_gen.control.stop"):e==="restart"?t==="failed"?h("ui.common.actions.retry"):h("ui.chat.canonical.image_gen.control.restart"):h("ui.chat.canonical.image_gen.control.edit_and_restart")}const zCt=({view:e,scope:t,actions:n})=>{be();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 w=o.current;return()=>{w?.contains(document.activeElement)&&w.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=kCt(c),O=P7e(e,n),f={cancel:n?.onCancel,restart:n?.onRestart,editRestart:n?.onEditRestart},p=e.state==="running"||e.state==="cancelling",m=p&&(e.state==="running"||e.generating),g="material"in e?e.material:void 0,y=g==="voiceover"||g==="sound-effect",v=y?e.state==="queued"?"queued":e.state==="cancelling"?e.generating?"stopped":null:m?"running":e.state==="failed"?"failed":e.state==="cancelled"?"stopped":null:null,b=e.state==="cancelled"&&!e.batch&&!!yke(e.cancel,!0),x=y&&!b&&(e.state==="failed"?e.batch?.some(w=>w.status==="cancelled"):e.state==="cancelled"&&(e.batch?.some(w=>w.status==="cancelled")||e.message))?YQ(!0):null,Q=p&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return d.jsxs("div",{ref:o,tabIndex:-1,"data-imagegen-card":e.state,className:X("flex w-full flex-col gap-2"),children:[v?d.jsx(RCt,{state:v}):m?d.jsx(PCt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorCode?d.jsx("p",{className:X("text-meta text-ink-dim"),children:ECt(e.errorCode)}):null,d.jsx(qCt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?d.jsx(Sd,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?d.jsx(Sd,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?d.jsx(Sd,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?d.jsx(Sd,{line:e.settlementCaption}):null,e.state==="cancelled"&&e.settlementPending?d.jsx(Sd,{line:h("ui.chat.canonical.image_gen.settlement.pending")}):null,x?d.jsx(Sd,{line:x}):null,l&&r?d.jsx($ke,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?d.jsx(Sd,{line:e.note}):null,m&&e.progress.fraction!==null?d.jsx(Z3e,{"aria-label":h("ui.chat.canonical.image_gen.progress"),className:X("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,Q===null?null:d.jsx(jCt,{line:Q}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?d.jsx(QCt,{items:e.batch,summary:e.batchSummary??h("ui.chat.canonical.image_gen.batch_summary",{count_display:String(e.batch.length),count:e.batch.length}),scope:t}):e.state==="done"&&e.images.length>0?d.jsx("div",{className:X("flex flex-col gap-2"),children:e.images.map((w,S)=>{const _=h("ui.chat.canonical.image_gen.state.done",{material:Fu(w.kind==="audio"?e.material:w.kind??"image")}),k=e.images.length===1?_:`${_} ${S+1}`;return w.kind==="video"?d.jsx(SCt,{video:w,scope:t,label:k},w.id):w.kind==="audio"?d.jsx(GP,{audio:w,scope:t,label:k},w.id):d.jsx(Jf,{image:w,scope:t,label:k},w.id)})}):null,O.length>0&&!(l&&r)?d.jsx("div",{"data-imagegen-controls":"",className:X("flex items-center gap-2"),children:O.map(w=>d.jsx(ve,{variant:"secondary",size:"sm",disabled:w.disabled,title:w.kind==="cancel"?e.state==="queued"||e.state==="cancelling"&&!e.generating?h("ui.chat.canonical.image_gen.control.stop_hint_queued"):h("ui.chat.canonical.image_gen.control.stop_hint_running"):void 0,onClick:w.kind==="cancel"&&l?()=>{const S=o.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(S){S.focus();return}i(!0)}:f[w.kind],children:CCt(w.kind,e.state)},w.kind))}):null]})},og="data-lo-quote-toolkit";function nz(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const Qee=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${og}]`)??null,ACt=e=>e.nodeType===Node.ELEMENT_NODE,UCt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>ACt(r)&&r.hasAttribute(og));return n===-1?t.length:n},WCt=(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,NCt=e=>{const t=Array.from(document.querySelectorAll(`[${og}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>WCt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function Xp(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(Qee(n.startContainer)||Qee(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,UCt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:NCt(n)}}const _ee="[data-lo-canonical-transcript]",YCt="[data-lo-transcript-content]",kee=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),GCt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function vke(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,f=o.current;if(!O||!f){l(null);return}const p=c.current();if(!p||p.length===0){l(null);return}const m=Jet({lines:p,container:kee((O.closest(_ee)??O).getBoundingClientRect()),viewport:GCt(),size:{width:f.offsetWidth,height:f.offsetHeight},row:kee(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),g=O.getBoundingClientRect(),y=m?{top:m.top-g.top,left:m.left-g.left,placement:m.placement}:null;l(v=>v===y||v&&y&&v.top===y.top&&v.left===y.left&&v.placement===y.placement?v:y)},[t,a]);return $.useLayoutEffect(()=>{if(!n){l(null);return}u();let O=0;const f=()=>{O||(O=requestAnimationFrame(()=>{O=0,u()}))};document.addEventListener("scroll",f,!0),document.addEventListener("selectionchange",f),window.addEventListener("resize",f);const p=t.current?.closest(_ee),m=p?.querySelector(YCt),g=new ResizeObserver(f);return p&&g.observe(p),m&&g.observe(m),()=>{O&&cancelAnimationFrame(O),document.removeEventListener("scroll",f,!0),document.removeEventListener("selectionchange",f),window.removeEventListener("resize",f),g.disconnect()}},[n,u,t,i]),{controlRef:o,placement:s}}function bke(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(Xp(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 np="data-lo-link-toolbar",ICt=120,ZCt=2;function wke(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(p=>p===null?p:null),i(p=>p===!1?p:!1);return}const O=oRt(u);if(O){n(p=>p===O?p:O),i(p=>p===!0?p:!0);return}if(i(p=>p===!1?p:!1),QQe()){n(p=>p===null?p:null);return}const f=o.current&&u.contains(o.current)?o.current:null;n(p=>p===f?p:f)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const f=_=>{O&&(clearTimeout(O),O=0),o.current=_,l()},p=_=>{if(O&&clearTimeout(O),!_){O=0,o.current=null,l();return}o.current!==_&&(s.current=null,O=setTimeout(()=>{O=0,o.current=_,l()},ICt))},m=(_,k)=>{const R=o.current;if(!R||!u.contains(R))return!1;const E=u.querySelector(`[${np}]`),T=rU+ZCt;for(const q of[R,E]){if(!q)continue;const A=q.getBoundingClientRect();if(!(A.width<=0||A.height<=0)&&_>=A.left-T&&_<=A.right+T&&k>=A.top-T&&k<=A.bottom+T)return!0}return!1},g=_=>{const k=_.target;if(k?.closest(`[${og}]`))return;const R=k?.closest(tp)??null;!R&&m(_.clientX,_.clientY)||p(R)},y=_=>{const k=_.relatedTarget;k&&u.contains(k)||m(_.clientX,_.clientY)||f(null)},v=_=>{const k=_.target?.closest(tp);if(k){if(k===s.current){s.current=null;return}f(k)}},b=_=>{const k=_.relatedTarget;k&&u.contains(k)||f(null)},x=()=>Array.from(u.querySelectorAll(`[${np}] button:not([disabled])`)),Q=_=>{const k=_.target;if(!k)return!1;if(k.closest(`[${np}]`)){const q=x(),A=q.indexOf(k);if(A===-1)return!1;if(_.shiftKey&&A===0){const G=o.current;return G instanceof HTMLElement?(G.focus(),!0):!1}if(!_.shiftKey&&A===q.length-1){const G=Array.from(u.querySelectorAll(tp)),I=o.current,z=I?G.indexOf(I)+1:-1,U=z>0?G[z]:void 0;return U?(U.focus(),!0):!1}return!1}if(_.shiftKey)return!1;const E=k.closest(tp);if(!E||!u.contains(E))return!1;o.current!==E&&f(E);const[T]=x();return T?(T.focus(),!0):!1},w=_=>{if(_.key==="Tab"&&Q(_)){_.preventDefault();return}if(!(_.key==="ContextMenu"||_.shiftKey&&_.key==="F10"))return;const R=_.target?.closest(tp);!R||!u.contains(R)||(_.preventDefault(),f(R),requestAnimationFrame(()=>{u.querySelector(`[${np}] button`)?.focus()}))},S=_=>{const k=_.target;k&&u.contains(k)||f(null)};return u.addEventListener("pointerover",g),u.addEventListener("pointerout",y),u.addEventListener("focusin",v),u.addEventListener("focusout",b),u.addEventListener("keydown",w),document.addEventListener("pointerdown",S,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",g),u.removeEventListener("pointerout",y),u.removeEventListener("focusin",v),u.removeEventListener("focusout",b),u.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S,!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(`[${np}]`))return;const p=window.getSelection();p&&!p.isCollapsed&&p.removeAllRanges(),c()};return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[t,c]),{subject:t,quoteAvailable:r,dismiss:c}}function xke(e,t,n){const r=Fn(i=>i.addReply);return $.useCallback(()=>{const a=Xp(t.current)?.text??(QQe()?null:n?.()??null);a&&(r(e,{id:ka(),text:a}),window.getSelection()?.removeAllRanges(),i8())},[r,e,t,n])}const Ske=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{be();const a=n.getAttribute(xQe)??"",o=n.getAttribute("data-lo-kind")??"file",s=wb(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=xke(e,t,l),{text:u}=bke(t),{speak:O}=Hm(),f=qk(e),p=u??l(),m=p===null?null:Kp(e,Ek(p).text);rme(m);const g=Ck({key:m,getText:()=>Xp(t.current)?.text??l(),play:({text:I})=>O(Kp(e,I),jk(f,I))}),[y,v]=$.useState(!1),[b,x]=$.useState(()=>Yx(a)??null),{controlRef:Q,placement:w}=vke({turnRef:t,visible:!0,lines:()=>{const I=n.getClientRects();return Array.from(I,z=>({top:z.top,left:z.left,right:z.right,bottom:z.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const I=Yx(a);if(x(I??null),v(!1),I!==void 0)return;let z=!0;return eRt(a,window.api?.probeFiles).then(()=>{z&&x(Yx(a)??null)}),()=>{z=!1}},[a]);const S=o==="file"&&ON(s,a),_=PQe({target:a,isDirectory:b?.exists===!0&&!b.isFile,probe:b,canOpenInCanvas:S}),k=cRt({kind:o,target:a,probe:b,quotable:r,canOpenInCanvas:S});if(!k||!a)return null;const R=async()=>{await xb(a)&&v(!0)},E=async()=>{if(o==="url"){await oJ(o,a);return}s&&_&&await s.openInCanvas(a)||await oJ(o,a)||x(null)},T=async()=>{await Ou(a)||x(null)},q=async()=>{await EP(a)||x(null)},A={quote:d.jsx(hOe,{}),copy:y?d.jsx(Ai,{}):d.jsx(YO,{}),open:_?d.jsx(p9e,{}):o==="url"?d.jsx(Zp,{}):d.jsx(Wv,{}),"open-default":d.jsx(HCe,{}),"open-folder":d.jsx(Dp,{})},G={quote:c,copy:()=>{R()},open:()=>{E()},"open-default":()=>{T()},"open-folder":()=>{q()}};return d.jsxs(iU,{[og]:"",[np]:"",ref:Q,label:k.label,className:X("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:I=>{if(I.key!=="Escape")return;window.getSelection()?.removeAllRanges();const z=n;I.preventDefault(),i(),z.focus?.()},children:[k.actions.map(I=>d.jsxs($.Fragment,{children:[d.jsx($t,{content:I.id==="copy"&&y?h("ui.common.actions.copied"):I.label,side:w?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":I.id==="copy"&&y?h("ui.common.actions.copied"):I.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:G[I.id],children:A[I.id]})}),I.id==="quote"&&d.jsx(zk,{control:g,side:w?.placement==="below"?"bottom":"top"})]},I.id)),k.note&&d.jsx("span",{className:"max-w-56 truncate ps-1 text-ink-dim text-meta",title:k.noteTitle??k.note,children:k.note})]})};function DCt({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 rz(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const Pee=96;function VCt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=Pee?t:`${t.slice(0,Pee-1).trimEnd()}…`}function MCt(){return h("ui.chat.response_actions.answer_label")}function LCt(){return h("ui.chat.response_actions.yours_label")}const FCt="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 Tee(e){return e?"opacity-100":FCt}const Qke=2e3,BCt=1e4;function j$n(e){const{request:t}=e;return t?e.now-t.requestedAt>BCt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let Xee=0,P1=0;const HCt=Si(e=>({request:null,requestPanel:(t,n,r,i)=>{Xee+=1,e({request:{destination:t,nonce:Xee,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:()=>{P1+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,P1=Math.max(0,P1-1),P1===0&&e({presenterClaimed:!1}))}}})),KCt=(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)},JCt=9e4,Ree=new Set,e6t=2600,Dx=$.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,f]=$.useState(!1),[p,m]=$.useState(!1),g=$.useRef(null),y=$.useRef(null),v=$.useRef(null),b=$.useRef(null),{playSpeech:x}=Hm(),Q=qk(r??null),w=Ck({key:i?tme(i):null,getText:()=>t,play:({text:A})=>{i&&x(i,Q,A)}}),S=HCt(A=>A.requestPanel),_=!!(s&&l);be();const k=DCt({role:n,forkable:_}),R=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||o===void 0||Ree.has(a)||(Ree.add(a),Date.now()-o>JCt))return;const A=y.current;if(A===null)return;const G=A.closest(".group")??A;if(KCt(A,G))return;m(!0);const I=()=>{m(!1),G.removeEventListener("pointerenter",I),G.removeEventListener("focusin",I)};return G.addEventListener("pointerenter",I),G.addEventListener("focusin",I),()=>{G.removeEventListener("pointerenter",I),G.removeEventListener("focusin",I)}},[a,o]),$.useEffect(()=>{if(p)return b.current=setTimeout(()=>{b.current=null,m(!1)},e6t),()=>{b.current!==null&&clearTimeout(b.current)}},[p]);const E=async()=>{await xb(t)&&(f(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,f(!1)},Qke))},T=()=>{!s||!l||S("session.fork",v.current,s,{id:l,excerpt:VCt(t)})},q={copy:d.jsx($t,{content:O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),side:"bottom",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),className:X("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:E,children:O?d.jsx(Ai,{"aria-hidden":"true"}):d.jsx(YO,{"aria-hidden":"true"})})}),speak:d.jsx(zk,{control:w,side:"bottom",className:X("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:d.jsx($t,{content:h("ui.chat.pickers.destination_pickers.fork_from_this_message"),side:"bottom",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.pickers.destination_pickers.fork_from_this_message"),ref:v,className:X("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:T,children:d.jsx(hze,{"aria-hidden":"true"})})})};return d.jsx("div",{role:"toolbar","aria-label":n==="user"?LCt():n==="commentary"?h("ui.chat.commentary_actions.label"):n==="response"?h("ui.chat.response_actions.label"):MCt(),ref:y,onAnimationEnd:A=>{A.target===A.currentTarget&&m(!1)},...p?{"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:X(c?X("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",Tee(R),u):X("flex h-8 shrink-0 items-center gap-1",Tee(R))),children:k.map(A=>d.jsx($.Fragment,{children:q[A]},A))})}),t6t="video",_ke="music",n6t=e=>(e.jobType===t6t||e.jobType===_ke)&&mf(e)&&e.music?.stage!=="cancel_requested",r6t=()=>h("ui.chat.run_controls.job.not_found"),i6t=e=>e instanceof Pn&&e.status===null,C$n=(e,t)=>i6t(t)?e<1:!1,z$n=e=>e instanceof Pn&&e.status===404&&e.message===sue?r6t():To(e,h("ui.chat.run_controls.job.cancel_failed")),a6t=new Set(["generate_music","modify_music"]),UN=e=>a6t.has(e),o6t=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function WN(e){return!o6t(e)||e.material!=="music"?null:typeof e.job_id=="string"&&e.job_id.length>0?e.job_id:null}function s6t(e){const t=/^background job '[^\n]*' (completed|failed|cancelled|paused)\b/.exec(e);return t?t[1]:null}function l6t(e){const t=new Map,n=new Map;for(const r of e){if(r.kind!=="custom"||!r.jobId)continue;const i={status:s6t(r.text),receipt:r.music??null},a=r.music?.job;a&&a!==r.jobId?n.set(a,i):t.set(r.jobId,i)}for(const[r,i]of n)t.set(r,{...t.get(r)??{status:null,receipt:null},successor:i});return t}function A$n(e){const t=new Map,n=new Map;for(const r of e){if(r.jobType!==_ke)continue;const i=r.music?.job;i&&i!==r.id?n.set(i,r):t.set(r.id,r)}return{rows:t,successors:n}}const kke=$.createContext(null),Pke=$.createContext(new Map);function Tke(e){if(!e||e.tracks.length===0)return null;let t=0,n;for(const r of e.tracks){const i=r.cost;if(!i||typeof i.amount_usd!="number"||n!==void 0&&i.basis!==n)return null;n=i.basis,t+=i.amount_usd}return jv({cost_usd:t,billing_basis:n})}function c6t(e,{settlement:t,row:n,successorRow:r}){const i=t?.successor;if(!i&&!r||!(t?.status==="cancelled"||n?.status==="cancelled"||n?.music?.stage==="cancel_requested"||r?.music?.stage==="cancel_requested"))return null;if(i){const c=i.receipt?.tracks??[],u=c.filter(O=>O.images.length>0).length;return{...e,state:u>0?"finished_after_cancel":"cancelled",completed:c.length,total:c.length,cost:Tke(i.receipt)}}const o=r,s=o.music?.completed??0,l=o.music?.total??0;return mf(o)?{...e,state:"cancel_requested",completed:s,total:l,cost:null}:{...e,state:o.status==="done"?"finished_after_cancel":"cancelled",completed:l,total:l,cost:null}}function Xke({toolName:e,details:t,row:n,settlement:r,successorRow:i,liveLoaded:a=!1}){if(!UN(e))return null;const o=WN(t);if(o===null)return null;const l={jobId:o,modify:e==="modify_music",cost:null,cancelRow:null},c=c6t(l,{settlement:r,row:n,successorRow:i});if(c)return c;if(r?.successor||i)return Xke({toolName:e,details:t,row:i??n,settlement:r?.successor??(r?{status:r.status,receipt:r.receipt}:void 0),liveLoaded:a});if(r){const u=r.receipt?.tracks??[],O=u.filter(p=>p.images.length>0).length,f=r.status==="cancelled"?"cancelled":r.status==="failed"||u.length>0&&O===0?"failed":r.status==="completed"||O>0?"done":"unavailable";return{...l,state:f,completed:u.length,total:u.length,cost:f==="done"?null:Tke(r.receipt)}}if(n){const u=n.music?.completed??0,O=n.music?.total??0;if(!mf(n)){const m=n.status==="cancelled"?"cancelled":n.status==="failed"?"failed":"done";return{...l,state:m,completed:O,total:O}}const f=n.music?.stage,p=f==="cancel_requested"?"cancel_requested":f==="polling"||n.status==="running"?"generating":"queued";return{...l,state:p,completed:u,total:O,cancelRow:n6t(n)?n:null}}return{...l,state:a?"unavailable":"queued",completed:0,total:0}}const u6t=({active:e,settled:t=!1,completed:n,total:r,attribution:i})=>d.jsxs("div",{"data-music-processing":"",className:X("flex min-w-0 flex-col gap-1 py-1"),children:[d.jsxs("div",{className:X("flex items-center gap-2 text-ink-muted text-body-sm"),children:[d.jsx(t9e,{size:14,"aria-hidden":"true"}),d.jsx("span",{children:h("ui.music.label")}),typeof r=="number"&&r>0&&d.jsx("span",{children:h("ui.music.progress",{completed:(n??0).toLocaleString(),total:r.toLocaleString()})})]}),d.jsx("svg",{"data-music-motif":"",width:"240",height:"44",viewBox:"0 0 240 44","aria-hidden":"true",className:X("max-w-full text-ink-dim",e&&!t&&"motion-safe:animate-pulse",t&&"opacity-40"),children:[0,1,2,3].map(a=>d.jsx("g",{transform:`translate(${a*64},0)`,children:[{id:0,height:8},{id:1,height:20},{id:2,height:32},{id:3,height:20},{id:4,height:12}].map(({height:o,id:s})=>d.jsx("rect",{x:s*6,y:(44-o)/2,width:"4",height:o,rx:"2",fill:"currentColor"},s))},a))}),i&&d.jsx("p",{className:X("text-body-sm text-ink"),children:i})]}),O6t=e=>{switch(e.state){case"queued":return h("ui.music.queued");case"generating":return e.modify?h("ui.music.modifying"):e.total>1?h("ui.music.generating_tracks",{count:e.total}):h("ui.music.generating");case"cancel_requested":return h("ui.music.cancel_requested");case"done":return h("ui.music.ready");case"failed":return h("ui.music.job_failed");case"cancelled":return h("ui.music.job_cancelled");case"finished_after_cancel":return h("ui.music.finished_after_cancel");case"unavailable":return h("ui.music.job_status.unavailable")}},d6t=new Set(["done","failed","cancelled","finished_after_cancel"]),f6t=({view:e,onCancel:t})=>{const n=e.cost;return d.jsxs("div",{"data-music-generating":e.jobId,"data-music-state":e.state,className:X("mt-2 flex min-w-0 items-start gap-2"),children:[d.jsxs("div",{className:X("flex min-w-0 flex-1 flex-col"),children:[d.jsxs("p",{"aria-live":"polite",className:X("text-body-sm",e.state==="failed"?"text-danger":"text-ink"),children:[O6t(e),n&&d.jsxs("span",{className:X("text-ink-muted"),children:[" ",n]})]}),d.jsx(u6t,{active:e.state==="generating",settled:d6t.has(e.state),completed:e.completed,total:e.total})]}),e.cancelRow&&t&&d.jsx(ve,{variant:"ghost",size:"sm","data-music-cancel":e.jobId,"aria-label":h("ui.chat.run_details.job_cancel_aria",{label:e.cancelRow.label}),className:X("h-6 shrink-0 px-1.5 hover:bg-danger-wash hover:text-danger"),onClick:r=>t(r.currentTarget.getBoundingClientRect()),children:h("ui.common.actions.cancel")})]})},h6t=5e3,p6t=(e,t)=>{const n=$.useContext(kke),r=$.useContext(Pke),i=WN(t),a=i?n?.rows.get(i):void 0,o=i?n?.successors?.get(i):void 0,s=i?r.get(i):void 0,l=i!==null&&n?.loaded===!0&&!a&&!o&&!s,[c,u]=$.useState(null);return $.useEffect(()=>{if(!l||i===null)return;const O=setTimeout(()=>u(i),h6t);return()=>clearTimeout(O)},[l,i]),Xke({toolName:e,details:t,row:a,settlement:s,successorRow:o,liveLoaded:l&&c===i})},m6t=({view:e})=>{const n=$.useContext(kke)?.request??null,r=e.cancelRow;return d.jsx(f6t,{view:e,onCancel:n&&r?i=>n(r,{left:i.left,top:i.top,bottom:i.bottom,right:i.right}):void 0})},g6t=({receipt:e,scope:t})=>d.jsxs("div",{"data-music-result":"",className:X("mt-2 flex min-w-0 flex-col gap-3"),children:[e.attribution&&d.jsx("p",{className:X("text-body-sm text-ink"),children:e.attribution}),e.tracks.length===0&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:h("ui.music.empty")}),e.tracks.map(n=>{const r=n.title||h("ui.music.track",{index:(n.variantIndex+1).toLocaleString()}),i=n.cost?jv({cost_usd:n.cost.amount_usd,billing_basis:n.cost.basis}):null;return d.jsxs("div",{"data-music-track":n.id,className:X("flex min-w-0 flex-col gap-1"),children:[d.jsx("p",{className:X("text-body-sm text-ink"),children:r}),n.title&&e.tracks.length>1&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:h("ui.music.track",{index:(n.variantIndex+1).toLocaleString()})}),n.images.map(a=>d.jsx(GP,{audio:a,scope:t,label:a.name||r},a.id)),n.error&&d.jsx("p",{className:X("text-body-sm text-danger"),children:h("ui.music.failed")}),i&&d.jsx("p",{className:X("text-body-sm text-ink-muted"),children:i})]},n.id)})]}),Rke="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",T1="@min-[260px]/olderhistory:hidden",X1="@max-[260px]/olderhistory:hidden",Eke="lo-older-history-hint",$6t=({state:e,loadingVariant:t="older",transportDown:n=!1,onLoadOlder:r,onRetryHydration:i})=>{be();const a=e==="loading"?mke(t):e==="failed"?n?h("ui.chat.canonical.older_history.transport.long"):h("ui.chat.canonical.older_history.failed.long"):e==="unproven"?h("ui.chat.canonical.older_history.unproven.long"):null,o=e==="loading";return d.jsxs("div",{className:Rke,children:[d.jsx("output",{className:"sr-only","aria-live":"polite",children:a}),e==="failed"&&n?d.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:[d.jsx("span",{className:T1,children:h("ui.chat.canonical.older_history.transport.short")}),d.jsx("span",{className:X1,children:h("ui.chat.canonical.older_history.transport.long")})]}):e==="failed"?d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"min-w-0 truncate text-danger text-meta",title:h("ui.chat.canonical.older_history.failed.long"),children:[d.jsx("span",{className:T1,children:h("ui.chat.canonical.older_history.failed.short")}),d.jsx("span",{className:X1,children:h("ui.chat.canonical.older_history.failed.long")})]}),d.jsx(ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:h("ui.chat.canonical.older_history.try_again")})]}):o?d.jsx(ve,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:s=>{s.preventDefault()},className:"min-w-0 text-ink-muted",children:d.jsx(tz,{variant:t,announce:!1})}):e==="idle"?d.jsx(ve,{variant:"ghost",size:"sm",onClick:r,children:h("ui.chat.canonical.older_history.load")}):e==="windowed"?d.jsxs("span",{id:Eke,className:"min-w-0 truncate text-ink-dim text-meta",title:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.title_gesture"),children:[d.jsx("span",{className:T1,children:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.short_gesture")}),d.jsx("span",{className:X1,children:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.title_gesture")})]}):e==="unproven"?d.jsxs(d.Fragment,{children:[d.jsxs("span",{className:"min-w-0 truncate text-ink-dim text-meta",title:h("ui.chat.canonical.older_history.unproven.long"),children:[d.jsx("span",{className:T1,children:h("ui.chat.canonical.older_history.unproven.short")}),d.jsx("span",{className:X1,children:h("ui.chat.canonical.older_history.unproven.long")})]}),!n&&i&&d.jsx(ve,{variant:"ghost",size:"sm",className:"shrink-0",onClick:i,children:h("ui.chat.canonical.older_history.try_again")})]}):d.jsx("span",{className:"min-w-0 truncate text-ink-dim text-meta",children:h("ui.chat.canonical.older_history.conversation_start")})]})},y6t=()=>d.jsx("div",{"aria-hidden":"true",className:Rke}),v6t="/settings?section=providers",Eee="/settings?section=providers&provider=radient",b6t="/settings?section=radient",qee=/sign in to radient/i,w6t=[/insufficient credits/i,/credit balance is too low/i],x6t=[/rate limit or quota/i],S6t=[/insufficient credits/i,/\bHTTP 402\b/i];function qke(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function NN(e){return qke(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&S6t.some(n=>n.test(e.text)):!1}function Q6t(e){if(!NN(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?h("ui.chat.provider_error.headline.out_of_credits",{status:a,body:i}):h("ui.chat.provider_error.headline.out_of_credits_refused",{status:a})}}function _6t(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function jee(e){const t=qke(e.provider)||qee.test(e.text);let n=_6t(e.category);return NN(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(qee.test(e.text)?n="sign-in":w6t.some(r=>r.test(e.text))?n="billing":x6t.some(r=>r.test(e.text))&&(n="quota")),n===null?null:n==="sign-in"&&t?{label:h("ui.chat.provider_error.action.sign_in_radient"),to:Eee}:n==="billing"&&t?{label:h("ui.chat.provider_error.action.open_radient_account"),to:b6t}:{label:h("ui.chat.provider_error.action.open_provider_settings"),to:t?Eee:v6t}}const jke=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{be();const{text:r,clear:i}=bke(t),a=r!==null,o=xke(e,t);$.useEffect(()=>{const v=t.current;if(!v||!a)return;const b=v.closest("[data-record-id]")??v,x=[...b.querySelectorAll("[data-lo-gutter-actions], [data-lo-user-actions], [data-lo-answer-actions], [data-lo-response-actions]")];b.setAttribute("data-lo-selection-active","");for(const Q of x)Q.setAttribute("inert",""),Q.setAttribute("aria-hidden","true");return()=>{b.removeAttribute("data-lo-selection-active");for(const Q of x)Q.removeAttribute("inert"),Q.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 v=Xp(t.current)?.text??r;v&&await xb(v)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},Qke))},[r,t]),{controlRef:O,placement:f}=vke({turnRef:t,visible:a,lines:()=>Xp(t.current)?.lines??null}),{speak:p}=Hm(),m=qk(e),g=r===null?null:Kp(e,Ek(r).text);rme(g);const y=Ck({key:g,getText:()=>Xp(t.current)?.text??null,play:({text:v})=>p(Kp(e,v),jk(m,v))});return $.useEffect(()=>{if(!a)return;const v=b=>{b.key!=="Escape"||b.defaultPrevented||(window.getSelection()?.removeAllRanges(),i())};return document.addEventListener("keydown",v),()=>document.removeEventListener("keydown",v)},[a,i]),a?d.jsxs(iU,{[og]:"",ref:O,label:h("ui.chat.transcript_copy.selection.toolbar"),className:X("absolute z-20",!f&&"invisible"),style:f?{top:f.top,left:f.left}:void 0,children:[n&&d.jsx($t,{content:h("ui.chat.transcript_copy.selection.quote"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.transcript_copy.selection.quote"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:o,children:d.jsx(hOe,{})})}),d.jsx($t,{content:s?h("ui.chat.transcript_copy.toast.copied_selection"):h("ui.chat.transcript_copy.selection.copy"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(ve,{variant:"ghost",size:"icon-sm","aria-label":s?h("ui.chat.transcript_copy.toast.copied_selection"):h("ui.chat.transcript_copy.selection.copy"),className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:()=>{u()},children:s?d.jsx(Ai,{}):d.jsx(YO,{})})}),d.jsx(zk,{control:y,side:f?.placement==="below"?"bottom":"top"})]}):null},Cke={all:["radient-prices"],prices:()=>[...Cke.all,"prices"]},k6t=()=>{const e=St({queryKey:Cke.prices(),queryFn:()=>q8({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}},Cee="https://console.radienthq.com/dashboard/verification",P6t="https://console.radienthq.com",zee="https://console.radienthq.com/dashboard/billing",Aee=()=>h("ui.common.account.top_up");function T6t(e){return!e.email_verified&&e.signup_grant!=="claimed"}const U$n=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),iz=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,X6t=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:iz(e)});function az(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}const W$n="/settings?section=radient";function zke(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const R6t=(e,t)=>e==="pending"?{sentence:h("ui.common.account.verify_pending",{amount:t}),action:h("ui.common.account.open_verification")}:e==="expired"?{sentence:h("ui.common.account.verify_expired",{amount:t}),action:h("ui.common.account.request_new_link")}:{sentence:h("ui.common.account.verify_none"),action:h("ui.common.account.open_verification")};function E6t(e,t){if(e===void 0)return{state:"unknown",lines:[h("ui.common.account.out_unknown_verify"),h("ui.common.account.out_unknown_top_up")],links:[{label:h("ui.common.account.open_verification"),url:Cee},{label:Aee(),url:zee}]};if(T6t(e)){const i=az(e.claim_url,Cee),{action:a}=R6t(e.signup_grant,"");if(e.signup_grant==="none")return{state:"unverified",lines:[h("ui.common.account.out_unverified_none")],links:[{label:a,url:i}]};const o=X6t(e.grant_amount??t);return{state:"unverified",lines:[h("ui.common.account.out_unverified_claim",{amount:o}),e.signup_grant==="expired"?h("ui.common.account.out_unverified_expired"):h("ui.common.account.out_unverified_inbox")],links:[{label:a,url:i}]}}const n=e.first_topup,r=[h("ui.common.account.out_verified")];return n!==void 0&&n.bonus_received===!1&&Number.isFinite(n.bonus_amount)&&Number.isFinite(n.minimum_purchase)&&r.push(h("ui.common.account.first_top_up_bonus",{bonus:iz(n.bonus_amount),minimum:iz(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:Aee(),url:az(n?.topup_url,zee)}]}}const q6t=5*1e3,j6t=({action:e})=>{const{user:t,accountRead:n}=dhe({staleTime:q6t,retryOnMount:!1}),r=dr(),{prices:i}=k6t(),o=r.isPending||n==="checking"?null:E6t(n==="ready"?t?.verification:void 0,i?.default_new_credits);return d.jsxs("div",{className:"mt-1 flex flex-col items-start gap-2 ps-6",children:[o?d.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:[d.jsx(Gp,{className:"mt-0.5 size-4 shrink-0 text-ink-muted","aria-hidden":"true"}),d.jsx("div",{className:"min-w-0 text-body-sm text-ink",children:o.lines.map(s=>d.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:s},s))})]}):null,d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[o?.links.map(s=>d.jsx(ve,{variant:"secondary",size:"sm",onClick:()=>zke(s.url),children:s.label},s.url)),d.jsx(ve,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx(tOe,{to:e.to,children:e.label})})]})]})},K0="data-jump-highlight",C6t=1400,e4=new WeakMap;function oz(e){const t=e4.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(K0);e.removeAttribute(K0),n&&e.offsetHeight,e.setAttribute(K0,""),e4.set(e,window.setTimeout(()=>{e4.delete(e),e.removeAttribute(K0)},C6t))}const Vx=24,Ake=6,sz=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),Uee=async e=>{for(let t=0;t<Ake;t+=1){if(e())return;await sz()}},Uke=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},z6t=e=>{const t=Uke(e.loadOlder),n=()=>Uee(()=>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 Uee(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(o>=i.maxPages||(o+=1,!await t()))return"exhausted";await n()}}}},A6t=12,U6t=1200,W6t=Ake,N6t=W6t+2,Y6t=2,G6t=30,Wee=1,y0=Vx;let Yh=0;async function I6t(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await z6t({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:A6t,maxRows:U6t})==="landed"}async function Z6t(e,t,n){if(!n()||!t.isConnected)return;Yh+=1;const r=Yh;hx(e,t,"reversed",y0);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<N6t&&(await sz(),!(!n()||!t.isConnected||a||r!==Yh));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-y0;if(Math.abs(O)<=Wee){if(l+=1,l>=Y6t){c=!0;break}continue}l=0,hx(e,t,"reversed",y0)}if(c&&!a&&r===Yh){const u=e,O=t,f=()=>{a=!0};u.addEventListener("wheel",f,{passive:!0,once:!0}),u.addEventListener("pointerdown",f,{passive:!0,once:!0}),u.addEventListener("touchstart",f,{passive:!0,once:!0}),window.addEventListener("keydown",s),(async()=>{try{for(let p=0;p<G6t;p+=1){if(await sz(),!n()||a||r!==Yh||!u.isConnected||!O.isConnected)return;const m=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-y0;if(Math.abs(m)<=Wee)continue;hx(u,O,"reversed",y0);const g=u.ownerDocument?.defaultView;g!=null&&u.dispatchEvent(new g.Event("scroll"))}}finally{u.removeEventListener("wheel",f),u.removeEventListener("pointerdown",f),u.removeEventListener("touchstart",f),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===Yh){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function Wke(e,t,n,r=()=>!0){return r()?new Promise(i=>{bCt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}oz(a),Z6t(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(K0)&&oz(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const pO=120,R1=400,D6t=.5,V6t=320,M6t=900,E1=64,ZP=2,t4=24,n4=3,L6t=4,My=12,lz=My,F6t=120,B6t=.35,Nee=12,H6t=8,K6t=My,J6t=.5,Yee=()=>({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}),Nke=e=>Math.min(M6t,Math.max(V6t,Math.round(e*D6t))),ezt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=R1?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=R1?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=R1?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=E1,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=R1,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>=E1:e.actTravelled||t.travelledPx>=E1,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>=E1&&!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}},v0=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=ZP,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}}),tzt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!Yke(t).inZone?!1:t.distanceFromTopPx<=ZP?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=lz?!1:n-e.lastInputAt>=pO:!0;function Yke(e,t=Nke(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const nzt=(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=Nke(t.clientHeight),{inZone:a}=Yke(t,i),o=n-e.lastInputAt>=pO||t.distanceFromTopPx<=ZP,s=e.revealsThisAct<K6t;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<Nee&&s)return o?v0({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return v0(e,r,t);if(r==="fetch"&&e.failures>=n4)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>=pO;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<lz?v0(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return v0(e,r,t)}if(e.continuation){const l=e.actAsks<lz,c=l&&e.chainInvisible>0&&e.chainInvisible<My;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:s&&(r==="widen"?e.chainWiden<Nee:(c||l&&e.chainFetch<L6t)&&e.failures<n4)?v0({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},Gee=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:o=null}={})=>{const s=r!==null&&r<H6t,l=r===null&&t&&i!==null&&i<Math.max(F6t,B6t*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,My):0,continuation:t&&n>0||c&&e.chainInvisible+1<My||!e.retained&&!e.turnedAround}},rzt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),izt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),azt=(e,t,n,r)=>n===r?Gke(e,t):null,Gke=(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)<J6t?0:n};function GQ({path:e}){switch(Y8(e)){case"image":return d.jsx(oOe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return d.jsx(sOe,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return d.jsx(J$,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return d.jsx(Wv,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function ozt(e,t){try{return ON(e,t)}catch{return!1}}function _b(e,t,n,r){const i=$.useCallback(async s=>{try{const l=r?await r():e,[c]=await window.api.probeFiles([l],t??void 0);if(!c?.resolved.startsWith("/"))throw new Error("File path has no session working directory");await s(c.resolved)}catch{Jn(h("ui.chat.highlights.file_resolution_failed"))}},[e,t,r]),a=ozt(n??null,e),o=$.useCallback(()=>{i(async s=>{a&&n&&await n.openInCanvas(s)||await Ou(s)})},[i,a,n]);return{canOpenInCanvas:a,press:o,withTarget:i}}const DP=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1,resolveActionPath:o,missing:s=!1}){be();const{canOpenInCanvas:l,withTarget:c}=_b(t,r,i,o),[u,O]=$.useState(!1),f=n?h("ui.common.actions.actions_for_name",{name:n}):h("ui.common.actions.file_actions_menu.file_actions");return d.jsxs(ok,{children:[d.jsx($t,{content:h("ui.common.actions.file_actions_menu.file_actions"),children:d.jsx(sk,{asChild:!0,children:a?d.jsx(ve,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":f,children:d.jsx(hS,{"aria-hidden":"true"})}):d.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":f,children:d.jsx(hS,{"aria-hidden":"true",className:"size-3.5"})})})}),d.jsxs(lk,{align:"end",className:"min-w-45",children:[l&&!s&&d.jsxs(Lo,{onSelect:()=>{c(p=>i?.openInCanvas(p))},children:[d.jsx(cOe,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),!s&&d.jsxs(Lo,{onSelect:()=>{c(Ou)},children:[d.jsx(Wv,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),!s&&d.jsxs(Lo,{onSelect:()=>{c(EP)},children:[d.jsx(Dp,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),d.jsxs(Lo,{onSelect:()=>{(o&&!s?o():Promise.resolve(t)).then(p=>navigator.clipboard.writeText(p)).then(()=>O(!0)).catch(()=>Jn(h("ui.notices.files.copy_path_failed")))},children:[d.jsx(UA,{"aria-hidden":"true"}),d.jsx("span",{children:u?h("ui.common.actions.copied"):h("ui.common.file_actions.copy_file_path")})]})]})]})});function szt(e){return e.materialisable===!1&&!e.stored?"gone":e.exists===!0?"present":e.exists===!1?e.stored?"retained":"gone":e.stored?"present":"gone"}const YN=(e,t,n)=>`${e}:${t??`#${n}`}`;function lzt(e){if(!e||typeof e.message_id!="string"||!e.message_id||e.kind!=="document"&&e.kind!=="image")return null;const t=typeof e.attachment=="string"&&e.attachment?e.attachment:null;return{key:YN(e.message_id,t,e.index??0),messageId:e.message_id,ts:Math.round((typeof e.ts=="number"?e.ts:0)*1e3),kind:e.kind,digest:t,data:null,filename:e.filename??null,mimeType:e.mime_type??(e.kind==="image"?"image/png":"application/octet-stream"),bytes:typeof e.bytes=="number"?e.bytes:null,path:e.path??null,storedPath:e.stored_path??null,availability:szt(e),index:typeof e.index=="number"?e.index:0,materialisable:typeof e.materialisable=="boolean"?e.materialisable:null,originExists:typeof e.exists=="boolean"?e.exists:null}}function czt(e,t,n){return{key:YN(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"document",digest:t.attachment,data:null,filename:t.filename,mimeType:t.mimeType,bytes:t.bytes>0?t.bytes:null,path:t.path,storedPath:t.storedPath,availability:"unknown",materialisable:null}}function uzt(e,t,n){return{key:YN(e.id,t.attachment,n),messageId:e.id,ts:e.ts,kind:"image",digest:t.attachment,data:t.data,filename:t.name??null,mimeType:t.mimeType,bytes:t.sizeBytes??null,path:null,storedPath:null,availability:"unknown",materialisable:null}}function Ike(e){const t=[];for(const n of e??[])n.kind==="user"&&((n.documents??[]).forEach((r,i)=>{t.push(czt(n,r,i))}),n.images.forEach((r,i)=>{r.kind!==void 0&&r.kind!=="image"||t.push(uzt(n,r,i))}));return t}function Ozt(e,t,n=!1){const r=e?.state==="ready",i=r?(e?.items??[]).map(lzt).filter(m=>m!==null):[],a=!n||e?.state==="unsupported"?"none":r?i.length>0&&i.every(m=>m.materialisable===null)?"none":"ready":"pending",o=new Map(i.map(m=>[m.key,m])),s=new Map;for(const m of i){const g=`${m.messageId}:${m.kind}`;s.set(g,(s.get(g)??0)+1)}const l=Ike(t),c=new Map,u=fzt({items:i,verdicts:a}),O=new Map;for(const m of l){const g=`${m.messageId}:${m.kind}`;O.set(g,(O.get(g)??0)+1)}const f=new Map,p=[...i];for(const m of l){const g=`${m.messageId}:${m.kind}`,y=f.get(g)??0;if(f.set(g,y+1),o.has(m.key))continue;const v=cz(u,{messageId:m.messageId,kind:m.kind,position:y,count:O.get(g)??0,digest:m.digest,path:m.path}),b=v===null?m:{...m,materialisable:v};if(b.digest===null){const x=`${b.messageId}:${b.kind}`,Q=c.get(x)??0;if(c.set(x,Q+1),Q<(s.get(x)??0))continue}o.set(b.key,b),p.push(b)}return p.sort((m,g)=>g.ts-m.ts),{items:p,complete:r,truncated:!!e?.truncated,verdicts:a}}const kb={digests:new Set,slots:new Map,paths:new Set,verdicts:"none",judged:new Map},dzt={...kb,verdicts:"pending"};function fzt(e){const t=e.verdicts??"none";if(t==="pending")return dzt;const n=new Set,r=new Set,i=new Map,a=new Map;for(const s of e.items){if(typeof s.materialisable!="boolean"||s.index===void 0)continue;const l=`${s.messageId}:${s.kind}`;i.set(l,(i.get(l)??0)+1);const c=s.materialisable===!1;c&&s.digest&&n.add(s.digest),c&&s.path&&r.add(s.path);const u=a.get(l)??[];u.push({index:s.index,refused:c}),a.set(l,u)}const o=new Map;for(const[s,l]of a)l.some(c=>c.refused)&&(l.sort((c,u)=>c.index-u.index),o.set(s,l.map(c=>c.refused)));return!o.size&&t==="none"?kb:{digests:n,slots:o,paths:r,verdicts:t,judged:i}}function cz(e,t){if(t.digest&&e.digests.has(t.digest)||t.path&&e.paths.has(t.path))return!1;if(e.verdicts==="pending")return"pending";const n=`${t.messageId}:${t.kind}`,r=e.slots.get(n);return r&&(r.length!==t.count||r[t.position])?!1:e.verdicts==="ready"&&(e.judged.get(n)??0)<t.count?"pending":null}function Iee(e,t){return e&&t!==!1&&t!=="pending"}function N$n(e){return new Set(e.items.map(t=>t.digest).filter(t=>t!==null))}function Y$n(e,t,n=0,r=!0){const i=dr(),a=i.data!==void 0,o=_n(i.data,"session_attachments"),s=$.useMemo(()=>Ike(t),[t]),l=s.map(R=>`${R.key}:${R.digest??""}`).join("|"),[c,u]=$.useState({key:"",value:null,state:"loading"}),O=`${e??"draft"}:${o}`,[f,p]=$.useState(0),{echoIds:m,durableIds:g}=$.useMemo(()=>{const R=new Set(s.map(q=>q.messageId)),E=[],T=[];for(const q of t??[])q.kind!=="user"||!R.has(q.id)||(q.local||q.provisional?E:T).push(q.id);return{echoIds:E.join(`
945
945
  `),durableIds:T.join(`