local-operator-ui 0.57.6 → 0.57.8

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 (70) hide show
  1. package/out/renderer/assets/{_basePickBy-B-jviuZn.js → _basePickBy-D1tae6TD.js} +1 -1
  2. package/out/renderer/assets/{_baseUniq-CB--SXpA.js → _baseUniq-Dqwg6YCA.js} +1 -1
  3. package/out/renderer/assets/{agent-details-page-Rj5q_fCa.js → agent-details-page-2NwaDcAV.js} +1 -1
  4. package/out/renderer/assets/{agent-hub-page-l5W_PjC3.js → agent-hub-page-bhye8SZ9.js} +1 -1
  5. package/out/renderer/assets/{agents-page-CArTBEeZ.js → agents-page-Cg9BJoOY.js} +3 -3
  6. package/out/renderer/assets/{arc-7V4fcfFy.js → arc-CI5kHP39.js} +1 -1
  7. package/out/renderer/assets/{architectureDiagram-IEHRJDOE-Dcyvqi39.js → architectureDiagram-IEHRJDOE-eLXhTv9y.js} +1 -1
  8. package/out/renderer/assets/{avatar-cropper-Dcp0LFWW.js → avatar-cropper-BqlT2v-z.js} +1 -1
  9. package/out/renderer/assets/{blockDiagram-JOT3LUYC-DmHN5dMQ.js → blockDiagram-JOT3LUYC-DP4tinRN.js} +1 -1
  10. package/out/renderer/assets/{browser-page-B-cFBNC7.js → browser-page-CaUTMz3E.js} +1 -1
  11. package/out/renderer/assets/{browser-webauthn-prompt-CVVkNRv8.js → browser-webauthn-prompt-BMx_zU-j.js} +1 -1
  12. package/out/renderer/assets/{c4Diagram-VJAJSXHY-C7H6l8eq.js → c4Diagram-VJAJSXHY-1cHhY0DK.js} +1 -1
  13. package/out/renderer/assets/channel-DNk_hzpt.js +1 -0
  14. package/out/renderer/assets/{chunk-4BMEZGHF-tTnNOvEp.js → chunk-4BMEZGHF-xyVnm8de.js} +1 -1
  15. package/out/renderer/assets/{chunk-A2AXSNBT-C23KzvlW.js → chunk-A2AXSNBT-CCp5Cfzr.js} +1 -1
  16. package/out/renderer/assets/{chunk-AEK57VVT-Dt-ZRHiY.js → chunk-AEK57VVT-CS0s86Fq.js} +1 -1
  17. package/out/renderer/assets/{chunk-D6G4REZN-6apjoADm.js → chunk-D6G4REZN-0OHQRG_d.js} +1 -1
  18. package/out/renderer/assets/{chunk-RZ5BOZE2-DFoe9y1v.js → chunk-RZ5BOZE2-VEv3pyRd.js} +1 -1
  19. package/out/renderer/assets/{chunk-XZIHB7SX-D6DOqhCs.js → chunk-XZIHB7SX-LeYzGnO2.js} +1 -1
  20. package/out/renderer/assets/{classDiagram-GIVACNV2-DoITEvsZ.js → classDiagram-GIVACNV2-Cab_hjm_.js} +1 -1
  21. package/out/renderer/assets/{classDiagram-v2-COTLJTTW-DoITEvsZ.js → classDiagram-v2-COTLJTTW-Cab_hjm_.js} +1 -1
  22. package/out/renderer/assets/clone-Bs7bHp6e.js +1 -0
  23. package/out/renderer/assets/{conversation-input-sync-Ct2zCBYF.js → conversation-input-sync-DGRJrS5U.js} +4 -4
  24. package/out/renderer/assets/{dagre-OKDRZEBW-DOhwhl11.js → dagre-OKDRZEBW-DW0ckFtl.js} +1 -1
  25. package/out/renderer/assets/{diagram-SSKATNLV-BX2CdvmA.js → diagram-SSKATNLV-zHzzTLdD.js} +1 -1
  26. package/out/renderer/assets/{diagram-VNBRO52H-C4KzHc8j.js → diagram-VNBRO52H-ITKMWXE4.js} +1 -1
  27. package/out/renderer/assets/{erDiagram-Q7BY3M3F-CpUcYyyI.js → erDiagram-Q7BY3M3F-Bv7G9ync.js} +1 -1
  28. package/out/renderer/assets/{flowDiagram-4HSFHLVR-D2aWAymM.js → flowDiagram-4HSFHLVR-CPE8yDo8.js} +1 -1
  29. package/out/renderer/assets/{ganttDiagram-APWFNJXF-Cd_Dj7zL.js → ganttDiagram-APWFNJXF-CtIAfAsa.js} +1 -1
  30. package/out/renderer/assets/{gitGraphDiagram-7IBYFJ6S-BBY4KsnA.js → gitGraphDiagram-7IBYFJ6S-BJdv3O5i.js} +1 -1
  31. package/out/renderer/assets/{graph-D2g8XBf7.js → graph-DVEeevJk.js} +1 -1
  32. package/out/renderer/assets/{index-C0H7kM3J.js → index-CQp2KnyE.js} +1 -1
  33. package/out/renderer/assets/{index-CQFKudfT.js → index-CpIFRblO.js} +1 -1
  34. package/out/renderer/assets/{index-BGpYdNTO.js → index-D7k0o6RN.js} +186 -186
  35. package/out/renderer/assets/{infoDiagram-PH2N3AL5-BtzqRf67.js → infoDiagram-PH2N3AL5-D92y3EJB.js} +1 -1
  36. package/out/renderer/assets/{journeyDiagram-U35MCT3I-B65gNVcP.js → journeyDiagram-U35MCT3I-CCvE_pAn.js} +1 -1
  37. package/out/renderer/assets/{kanban-definition-NDS4AKOZ-CMd8INjd.js → kanban-definition-NDS4AKOZ-B8Si35EL.js} +1 -1
  38. package/out/renderer/assets/{layout-BoF8dZNw.js → layout-CbPE3gih.js} +1 -1
  39. package/out/renderer/assets/{legacy-agents-page-B-S_yV2F.js → legacy-agents-page-B3PRK3_g.js} +1 -1
  40. package/out/renderer/assets/{library-page-DvZTJ7j4.js → library-page-CY4_k-cH.js} +3 -3
  41. package/out/renderer/assets/{mermaid.core-dEA97al4.js → mermaid.core-B_TP914x.js} +5 -5
  42. package/out/renderer/assets/{mesh-page-DUuThZeI.js → mesh-page-YCUdTT4P.js} +1 -1
  43. package/out/renderer/assets/{mindmap-definition-ALO5MXBD-PMU5ZHod.js → mindmap-definition-ALO5MXBD-BqzgtHTf.js} +1 -1
  44. package/out/renderer/assets/{mini-GzRreoSs.js → mini-BpkQ6IM4.js} +1 -1
  45. package/out/renderer/assets/{notifications-page-D5g7-xwj.js → notifications-page-B9gCsV6P.js} +1 -1
  46. package/out/renderer/assets/{org-access-BRXH5JNq.js → org-access-D07X1Jyj.js} +1 -1
  47. package/out/renderer/assets/{pieDiagram-IB7DONF6-DpBdBGLa.js → pieDiagram-IB7DONF6-BddlCswk.js} +1 -1
  48. package/out/renderer/assets/{projects-page-RFm3rLMq.js → projects-page-D5JS7Our.js} +1 -1
  49. package/out/renderer/assets/{publication-validation-Z48Tl9nu.js → publication-validation-DsfwLP5e.js} +1 -1
  50. package/out/renderer/assets/{quadrantDiagram-7GDLP6J5-e4IzsruS.js → quadrantDiagram-7GDLP6J5-BAHfg6fS.js} +1 -1
  51. package/out/renderer/assets/{radar-MK3ICKWK-CeKg2QF3.js → radar-MK3ICKWK-CpYYCJB2.js} +1 -1
  52. package/out/renderer/assets/{radient-auth-buttons-B8E0XSrK.js → radient-auth-buttons-CtgXvexs.js} +1 -1
  53. package/out/renderer/assets/{requirementDiagram-KVF5MWMF-BTrEs5oZ.js → requirementDiagram-KVF5MWMF-CFWvpL6s.js} +1 -1
  54. package/out/renderer/assets/{sankeyDiagram-QLVOVGJD-uc3_kW8_.js → sankeyDiagram-QLVOVGJD-C623D-M_.js} +1 -1
  55. package/out/renderer/assets/{schedules-page-CkuD7GyP.js → schedules-page-BPPDUrWr.js} +1 -1
  56. package/out/renderer/assets/{sequenceDiagram-X6HHIX6F-D6vxB-KR.js → sequenceDiagram-X6HHIX6F-D8ZMC786.js} +1 -1
  57. package/out/renderer/assets/{settings-page-fuN-GHC2.js → settings-page-CPDb5uS3.js} +1 -1
  58. package/out/renderer/assets/{smartart-DzT7aCrc.js → smartart-4vh1pL3A.js} +1 -1
  59. package/out/renderer/assets/{stateDiagram-DGXRK772-CLM56psj.js → stateDiagram-DGXRK772-QfneJmpt.js} +1 -1
  60. package/out/renderer/assets/{stateDiagram-v2-YXO3MK2T-BPxZxHiI.js → stateDiagram-v2-YXO3MK2T-DJSDYDMK.js} +1 -1
  61. package/out/renderer/assets/{team-bridge-page-DqC4o4p8.js → team-bridge-page-DWyEqQte.js} +1 -1
  62. package/out/renderer/assets/{timeline-definition-BDJGKUSR-CdOFIdlp.js → timeline-definition-BDJGKUSR-CGDMUIew.js} +1 -1
  63. package/out/renderer/assets/{use-default-on-banner-BIByq1Es.js → use-default-on-banner-CmGkWOLt.js} +1 -1
  64. package/out/renderer/assets/{use-download-agent-mutation-BoPnd7Du.js → use-download-agent-mutation-xykoZDgt.js} +1 -1
  65. package/out/renderer/assets/{xychartDiagram-VJFVF3MP-Cbxqqv2i.js → xychartDiagram-VJFVF3MP-BiKK9yQH.js} +1 -1
  66. package/out/renderer/index.html +2 -2
  67. package/out/renderer/mini.html +2 -2
  68. package/package.json +1 -1
  69. package/out/renderer/assets/channel-BDcP_PSS.js +0 -1
  70. package/out/renderer/assets/clone-CeQBf91Q.js +0 -1
@@ -1,4 +1,4 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-C0H7kM3J.js","./index-D0qlrLIs.js","./messages-BYDbMAVA.js","./index-BKLUTBo0.css","./appearance-DO4VPBSi.js","./roles-D1pcbxAx.js","./error-boundary-BsWceBKP.js","./index-CQFKudfT.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-dEA97al4.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CQp2KnyE.js","./index-D0qlrLIs.js","./messages-BYDbMAVA.js","./index-BKLUTBo0.css","./appearance-DO4VPBSi.js","./roles-D1pcbxAx.js","./error-boundary-BsWceBKP.js","./index-CpIFRblO.js","./pug-DukmZTjD.js","./javascript-qCveANmP.js","./mermaid.core-B_TP914x.js","./katex-BCx1q_2Y.css"])))=>i.map(i=>d[i]);
2
2
  import{r as $,b as ne,h as f6e,j as d,c as R,i as vN,g as ar,K as UOe,l as IOe,n as wN,u as h6e,L as Dv,f as Sn,t as WOe}from"./index-D0qlrLIs.js";import{bu as p6e,f7 as oG,f8 as m6e,f9 as g6e,br as $6e,fa as y6e,fb as lG,fc as b6e,bs as DOe,u as Ea,bA as v6e,fd as w6e,fe as x6e,O as Mr,ff as YOe,fg as $1,fh as _6e,b3 as S6e,fi as k6e,fj as Q6e,fk as P6e,f as Uu,aa as GOe,fl as T6e,fm as cG,fn as E6e,fo as R6e,fp as X6e,Q as Pn,fq as Xn,ay as Os,fr as Af,cq as VQ,fs as AA,as as V_,c2 as LOe,N as eO,ft as C6e,m as Xt,r as ui,y as A6e,w as Ai,au as ud,fu as q6e,d as jn,A as vn,a as vr,h as di,ax as j6e,j as qe,bR as xN,c6 as MOe,k as Ys,fv as ZOe,ab as Py,fw as FQ,c4 as N6e,c5 as VOe,ex as z6e,ai as y1,l as b1,i as yr,I as Ht,a7 as U6e,o as I6e,fx as W6e,az as D6e,fy as Y6e,fz as G6e,dT as L6e,dS as M6e,dX as f5,dU as Z6e,c0 as FOe,fA as V6e,fB as F6e,fC as B6e,fD as H6e,fE as K6e,eX as J6e,dY as eCe,aw as YO,fF as BQ,fG as dm,fH as _N,fI as tCe,fJ as uG,J as ir,fK as OG,dN as Xr,fL as BOe,fM as HOe,aB as Ia,bq as SN,fN as nCe,fO as rCe,fP as iCe,fQ as aCe,fR as sCe,fS as F_,fT as KOe,fU as Ty,fV as oCe,fW as dG,aR as qf,fX as lCe,fY as v1,fZ as cCe,f_ as uCe,f$ as OCe,g0 as dCe,g1 as JOe,g2 as ede,aP as eu,g3 as fCe,g4 as hCe,g5 as pCe,cy as mCe,cw as gCe,g6 as $Ce,g7 as yCe,g8 as bCe,dB as ll,g9 as cl,ga as vu,gb as or,gc as vCe,gd as B_,ge as wCe,a_ as xCe,bl as h5,gf as _Ce,gg as SCe,gh as kCe,gi as QCe,gj as PCe,gk as kN,gl as TCe,M as ECe,ec as QN,cp as tde,aV as nde,aZ as RCe,aY as XCe,ar as PN,gm as rde,gn as CCe,go as ACe,gp as qCe,gq as jCe,gr as ide,gs as NCe,gt as zCe,gu as UCe,gv as fG,gw as hG,gx as pG,gy as ICe,gz as WCe,gA as DCe,gB as YCe,gC as GCe,gD as LCe,gE as MCe,gF as ZCe,gG as Yv,gH as VCe,gI as qA,gJ as FCe,gK as BCe,gL as HCe,gM as KCe,gN as JCe,gO as eAe,gP as tAe,gQ as nAe,gR as rAe,gS as iAe,gT as ade,gU as aAe,gV as sAe,gW as oAe,gX as lAe,gY as cAe,gZ as uAe,g_ as FO,g$ as TN,h0 as sde,h1 as fm,h2 as OAe,a1 as Ey,h3 as dAe,$ as ode,Y as lde,h4 as Lx,h5 as fAe,h6 as hAe,h7 as jA,h8 as pAe,h9 as mG,ha as mAe,hb as gAe,hc as $Ae,hd as BO,he as yAe,hf as bAe,hg as EN,hh as vAe,hi as wAe,hj as xAe,hk as _Ae,hl as SAe,hm as kAe,hn as QAe,ho as PAe,hp as TAe,hq as EAe,hr as RAe,hs as XAe,ht as CAe,hu as AAe,hv as qAe,n as HQ,hw as jAe,hx as cde,hy as NAe,hz as zAe,hA as w1,hB as ude,hC as Ode,hD as dde,hE as RN,hF as UAe,hG as IAe,hH as WAe,aL as DAe,hI as YAe,f3 as KQ,eI as GAe,c as XN,hJ as LAe,hK as MAe,D as ZAe,bi as VAe,hL as FAe,z as BAe,hM as HAe,hN as KAe,hO as JAe,hP as eqe,hQ as tqe,hR as Ry,hS as nqe,hT as gG,hU as fde,hV as rqe,hW as $G,hX as iqe,hY as aqe,hZ as sqe,h_ as hde,h$ as oqe,i0 as lqe,i1 as Gv,i2 as yG,i3 as cqe,i4 as bG,i5 as uqe,eo as vG,i6 as wG,bo as xG,i7 as _G,i8 as Oqe,i9 as dqe,ia as SG,ib as NA,ic as fqe,at as kG,cD as hqe,id as pqe,ie as mqe,ig as gqe,ih as hm,ii as $qe,di as yqe,ij as bqe,bH as vqe,ik as wqe,df as xqe,dh as _qe,dg as Sqe,b4 as kqe,bg as Qqe,ct as CN,cr as Pqe,il as Tqe,d_ as pde,dZ as mde,ao as Xy,im as N$,aS as gde,io as Eqe,aU as $de,ip as Rqe,iq as AN,ir as Xqe,is as Cqe,cS as Aqe,aM as qqe,it as jqe,aT as Nqe,iu as zqe,iv as Uqe,iw as Iqe,ix as QG,iy as Wqe,iz as H_,iA as yde,cB as Dqe,iB as bde,iC as Yqe,iD as Gqe,iE as Lqe,iF as Mqe,g as Zqe,iG as JQ,iH as qN,iI as Vqe,iJ as Fqe,iK as vde,iL as Cy,iM as tu,iN as Bqe,iO as Hqe,iP as Kqe,iQ as Jqe,e8 as eje,iR as K_,iS as tje,iT as nje,iU as rje,iV as ije,iW as PG,iX as aje,iY as sje,iZ as oje,i_ as lje,i$ as cje,j0 as uje,S as Oje,aA as TG,j1 as zA,j2 as UA,j3 as dje}from"./appearance-DO4VPBSi.js";import{aA as fje,c as Ie,aJ as hje,aK as wde,aL as pje,aM as mje,aN as gje,aO as $je,aP as yje,aQ as bje,aR as fg,aS as vje,B as Se,m as jN,n as NN,y as wje,o as zN,F as xje,u as ke,z as J_,S as Oi,T as eP,w as kt,h as eS,J as xde,r as jf,b as Fi,e as al,X as ei,a as _de,d as Ay,f as _je,A as bo,D as tP,g as nP,i as rP,I as uo,l as ya,C as Sde,ak as qy,a4 as p5,ag as Sje,v as kje,ad as pm,p as Ep,x as tS,au as UN,q as wu,R as EG,aT as Qje,a1 as Pje,ae as Tje,a3 as Eje,ah as Rje,at as Xje,a6 as Cje,N as Aje,O as qje,P as jje,K as ds,U as kde,V as Qde,W as Pde,Y as Tde,Z as IA,a5 as Nje,L as Ede,aI as zje,a7 as Uje,a8 as Ije,a9 as RG,aa as XG,ab as Wje,ac as CG,an as Dje,s as Yje,G as m5,H as AG,E as qG}from"./error-boundary-BsWceBKP.js";import{b as Rde,c as IN,t as h,r as Gje,e as WN,L as of,f as Lje,i as Mje,g as WA}from"./messages-BYDbMAVA.js";import{P as DN}from"./roles-D1pcbxAx.js";var Zje=class extends p6e{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:oG()})}getOptimisticResult(e){return e.behavior=oG(),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:s,isRefetchError:o}=r,l=n.fetchMeta?.fetchMore?.direction,c=s&&l==="forward",u=i&&l==="forward",O=s&&l==="backward",f=i&&l==="backward";return{...r,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:g6e(t,n.data),hasPreviousPage:m6e(t,n.data),isFetchNextPageError:c,isFetchingNextPage:u,isFetchPreviousPageError:O,isFetchingPreviousPage:f,isRefetchError:o&&!c&&!O,isRefetching:a&&!u&&!f}}},Vje=class extends $6e{#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),y6e(this.options,n)||this.#n.getMutationCache().notify({type:"observerOptionsUpdated",mutation:this.#e,observer:this}),n?.mutationKey&&this.options.mutationKey&&lG(n.mutationKey)!==lG(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??b6e();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){DOe.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 nS(e,t){const n=Ea(t),[r]=$.useState(()=>new Vje(n,e));$.useEffect(()=>{r.setOptions(e)},[r,e]);const i=$.useSyncExternalStore($.useCallback(s=>r.subscribe(DOe.batchCalls(s)),[r]),()=>r.getCurrentResult(),()=>r.getCurrentResult()),a=$.useCallback((s,o)=>{r.mutate(s,o).catch(v6e)},[r]);if(i.error&&w6e(r.options.throwOnError,[i.error]))throw i.error;return{...i,mutate:a,mutateAsync:i.mutate}}function Xde(e,t){return x6e(e,Zje,t)}const Fje=5e3;let Cde=0;function Bje(e=Fje){Cde=Date.now()+e}function iyn(e=Date.now()){return e<=Cde}function Hje(e){Bje(),e.invalidateQueries({queryKey:Mr.capabilities})}const Kje=e=>e!==""&&Rde(IN())==="rtl"?`⁦${e}⁩`:e;function Jje(e,t){if(!e||typeof e!="object")return null;const n=e,r=n.artifacts;if(!e7e(n)||!Array.isArray(r)||r.length===0||r.some(o=>!o||typeof o!="object"||typeof o.name!="string"))return null;const i=new Map,a=new Set(r.map(o=>o.name)),s=new Set;return r.map(o=>{const l=o,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(;s.has(f)||f!==c&&a.has(f);)f=`${c} (${++O})`;s.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:Ade(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 Ade(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 $1({...e,billing_basis:n?.basis??e.billing_basis})}function g5(e){const t=e,n=Ade(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 e7e(e){return"cost_complete"in e||["completed","failed","cancelled"].some(t=>t in e)}function t7e(e,t){const n=e,r=o=>{const l=n[o];return typeof l=="number"&&Number.isInteger(l)&&l>=0?l:t.filter(c=>c.status===o).length},i=r("cancelled"),a=t.filter(o=>o.status==="unknown").length,s=t.filter(o=>o.status!=="completed");return h("ui.chat.canonical.sound.batch.summary",{completed:r("completed"),failed:r("failed"),cancelled:i,unknown:a,has_attention:s.length?"yes":"no",labels:YOe(s.map(o=>o.label))})}function n7e(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 r7e(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,s=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:s}}const YN="generate_video",GN="generate_voiceover",LN="generate_sound_effect",i7e=new Set(["generate_image",YN,GN,LN]);function qde(e){return i7e.has(e)}function a7e(e){return e===YN}function s7e(e){return e===GN||e===LN}function o7e(e){return e===YN?"video":e===GN?"voiceover":e===LN?"sound-effect":"image"}function l7e(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 c7e(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 u7e(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:c7e(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 jG(e){return e.fraction===null&&e.logs.length===0&&e.queuePosition===null?jde:{fraction:e.fraction,logs:e.logs,queuePosition:e.queuePosition}}const jde=Object.freeze({fraction:null,logs:[],queuePosition:null});function O7e(e,{stopping:t=!1,settled:n=!1}={}){const r=u7e(e.details),i=o7e(e.toolName),a=i==="voiceover"||i==="sound-effect",s=a&&e.phase==="done"?Jje(e.details,e.images??[]):null,o=a?r7e(e.args,e.details):null,l=s?{batch:s,batchSummary:t7e(e.details,s),batchNote:n7e(e.details,e.output)}:{},c=a?h7e(e.details):null,u=c?.caption??null,O=c?.pending===!0,f=l7e(e.details);if(e.stopped===!0)return{state:"cancelled",generating:e.startedAt!==null,message:r.error??e.output,...s?{...l,material:i,costCaption:g5(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:$5(e.notRunKind,e.notRunReason)};if(e.neverSent===!0)return{state:"cancelled",generating:!1,message:e.output};if(s&&e.isError)return{state:"failed",material:i,message:r.error??e.output,errorCode:$5(r.errorType,r.error??e.output),...l,costCaption:g5(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:$5(r.errorType,r.error??e.output)};switch(e.phase){case"composing":case"queued":return t?{state:"cancelling",generating:!1,material:i,startedAtMs:null,progress:jde}:{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:jG(r)}:{state:"running",material:i,startedAtMs:p,progress:jG(r),note:r.error,...o?{batchProgress:o}:{}}}case"done":{const p=a?$1(e.details,e.output):null;return{state:"done",images:e.images??[],material:i,durationS:e.durationS??null,receipt:"generated",batch:s,...l,costCaption:s?g5(e.details):p}}}}const d7e=/\s*Checking for settlement\.?\s*$/;function f7e(e){return e.replace(d7e,"").trimEnd()}function h7e(e){if(!e||typeof e!="object")return null;const t=e,n=t.cost;return t.settled===!0?{caption:$1(e),pending:!1}:t.settled===null&&t.cost_usd===null&&n?.basis==="quote"?{caption:null,pending:!0}:null}function $5(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 m7e(e,t){if(!a7e(e))return t?{onCancel:t}:void 0}function g7e(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 $7e=e=>{switch(e){case"success":return v7e;case"info":return x7e;case"warning":return w7e;case"error":return _7e;default:return null}},y7e=Array(12).fill(0),b7e=({visible:e,className:t})=>ne.createElement("div",{className:["sonner-loading-wrapper",t].filter(Boolean).join(" "),"data-visible":e},ne.createElement("div",{className:"sonner-spinner"},y7e.map((n,r)=>ne.createElement("div",{className:"sonner-loading-bar",key:`spinner-bar-${r}`})))),v7e=ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ne.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"})),w7e=ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",height:"20",width:"20"},ne.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"})),x7e=ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ne.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"})),_7e=ne.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",fill:"currentColor",height:"20",width:"20"},ne.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"})),S7e=ne.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"},ne.createElement("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ne.createElement("line",{x1:"6",y1:"6",x2:"18",y2:"18"})),k7e=()=>{const[e,t]=ne.useState(document.hidden);return ne.useEffect(()=>{const n=()=>{t(document.hidden)};return document.addEventListener("visibilitychange",n),()=>window.removeEventListener("visibilitychange",n)},[]),e};let DA=1;class Q7e{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:DA++,s=this.toasts.find(l=>l.id===a),o=t.dismissible===void 0?!0:t.dismissible;return this.dismissedToasts.has(a)&&this.dismissedToasts.delete(a),s?this.toasts=this.toasts.map(l=>l.id===a?(this.publish({...l,...t,id:a,title:r}),{...l,...t,id:a,dismissible:o,title:r}):l):this.addToast({title:r,...i,dismissible:o,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,s;const o=i.then(async c=>{if(s=["resolve",c],ne.isValidElement(c))a=!1,this.create({id:r,type:"default",message:c});else if(T7e(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"&&!ne.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"&&!ne.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"&&!ne.isValidElement(O)?O:{message:O};this.create({id:r,type:"success",description:f,...m})}}).catch(async c=>{if(s=["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"&&!ne.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)=>o.then(()=>s[0]==="reject"?u(s[1]):c(s[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||DA++;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 es=new Q7e,P7e=(e,t)=>{const n=t?.id||DA++;return es.addToast({title:e,...t,id:n}),n},T7e=e=>e&&typeof e=="object"&&"ok"in e&&typeof e.ok=="boolean"&&"status"in e&&typeof e.status=="number",E7e=P7e,R7e=()=>es.toasts,X7e=()=>es.getActiveToasts(),ch=Object.assign(E7e,{success:es.success,info:es.info,warning:es.warning,error:es.error,custom:es.custom,message:es.message,promise:es.promise,dismiss:es.dismiss,loading:es.loading},{getHistory:R7e,getToasts:X7e});g7e("[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 Lv(e){return e.label!==void 0}const C7e=3,A7e="24px",q7e="16px",NG=4e3,j7e=356,N7e=14,z7e=45,U7e=200;function Pl(...e){return e.filter(Boolean).join(" ")}function I7e(e){const[t,n]=e.split("-"),r=[];return t&&r.push(t),n&&r.push(n),r}const W7e=e=>{var t,n,r,i,a,s,o,l,c;const{invert:u,toast:O,unstyled:f,interacting:p,setHeights:m,visibleToasts:g,heights:y,index:b,toasts:v,expanded:x,removeToast:S,defaultRichColors:w,closeButton:_,style:k,cancelButtonStyle:Q,actionButtonStyle:X,className:C="",descriptionClassName:T="",duration:A,position:z,gap:Y,expandByDefault:G,classNames:j,icons:U,closeButtonAriaLabel:D="Close toast"}=e,[Z,N]=ne.useState(null),[L,J]=ne.useState(null),[W,fe]=ne.useState(!1),[te,M]=ne.useState(!1),[ie,ee]=ne.useState(!1),[F,H]=ne.useState(!1),[le,oe]=ne.useState(!1),[Ce,ge]=ne.useState(0),[Xe,Ue]=ne.useState(0),We=ne.useRef(O.duration||A||NG),pe=ne.useRef(null),Qe=ne.useRef(null),ot=b===0,gt=b+1<=g,ut=O.type,St=O.dismissible!==!1,be=O.className||"",st=O.descriptionClassName||"",ye=ne.useMemo(()=>y.findIndex(ft=>ft.toastId===O.id)||0,[y,O.id]),ae=ne.useMemo(()=>{var ft;return(ft=O.closeButton)!=null?ft:_},[O.closeButton,_]),xe=ne.useMemo(()=>O.duration||A||NG,[O.duration,A]),Re=ne.useRef(0),Te=ne.useRef(0),vt=ne.useRef(0),Le=ne.useRef(null),[Ot,Zt]=z.split("-"),Qt=ne.useMemo(()=>y.reduce((ft,Lt,hn)=>hn>=ye?ft:ft+Lt.height,0),[y,ye]),Ge=k7e(),At=O.invert||u,Kt=ut==="loading";Te.current=ne.useMemo(()=>ye*Y+Qt,[ye,Qt]),ne.useEffect(()=>{We.current=xe},[xe]),ne.useEffect(()=>{fe(!0)},[]),ne.useEffect(()=>{const ft=Qe.current;if(ft){const Lt=ft.getBoundingClientRect().height;return Ue(Lt),m(hn=>[{toastId:O.id,height:Lt,position:O.position},...hn]),()=>m(hn=>hn.filter(Gn=>Gn.toastId!==O.id))}},[m,O.id]),ne.useLayoutEffect(()=>{if(!W)return;const ft=Qe.current,Lt=ft.style.height;ft.style.height="auto";const hn=ft.getBoundingClientRect().height;ft.style.height=Lt,Ue(hn),m(Gn=>Gn.find(Ft=>Ft.toastId===O.id)?Gn.map(Ft=>Ft.toastId===O.id?{...Ft,height:hn}:Ft):[{toastId:O.id,height:hn,position:O.position},...Gn])},[W,O.title,O.description,m,O.id]);const Ve=ne.useCallback(()=>{M(!0),ge(Te.current),m(ft=>ft.filter(Lt=>Lt.toastId!==O.id)),setTimeout(()=>{S(O)},U7e)},[O,S,m,Te]);ne.useEffect(()=>{if(O.promise&&ut==="loading"||O.duration===1/0||O.type==="loading")return;let ft;return x||p||Ge?(()=>{if(vt.current<Re.current){const Gn=new Date().getTime()-Re.current;We.current=We.current-Gn}vt.current=new Date().getTime()})():(()=>{We.current!==1/0&&(Re.current=new Date().getTime(),ft=setTimeout(()=>{O.onAutoClose==null||O.onAutoClose.call(O,O),Ve()},We.current))})(),()=>clearTimeout(ft)},[x,p,O,ut,Ge,Ve]),ne.useEffect(()=>{O.delete&&Ve()},[Ve,O.delete]);function Vt(){var ft;if(U?.loading){var Lt;return ne.createElement("div",{className:Pl(j?.loader,O==null||(Lt=O.classNames)==null?void 0:Lt.loader,"sonner-loader"),"data-visible":ut==="loading"},U.loading)}return ne.createElement(b7e,{className:Pl(j?.loader,O==null||(ft=O.classNames)==null?void 0:ft.loader),visible:ut==="loading"})}const Ye=O.icon||U?.[ut]||$7e(ut);var dt,Yt;return ne.createElement("li",{tabIndex:0,ref:Qe,className:Pl(C,be,j?.toast,O==null||(t=O.classNames)==null?void 0:t.toast,j?.default,j?.[ut],O==null||(n=O.classNames)==null?void 0:n[ut]),"data-sonner-toast":"","data-rich-colors":(dt=O.richColors)!=null?dt:w,"data-styled":!(O.jsx||O.unstyled||f),"data-mounted":W,"data-promise":!!O.promise,"data-swiped":le,"data-removed":te,"data-visible":gt,"data-y-position":Ot,"data-x-position":Zt,"data-index":b,"data-front":ot,"data-swiping":ie,"data-dismissible":St,"data-type":ut,"data-invert":At,"data-swipe-out":F,"data-swipe-direction":L,"data-expanded":!!(x||G&&W),style:{"--index":b,"--toasts-before":b,"--z-index":v.length-b,"--offset":`${te?Ce:Te.current}px`,"--initial-height":G?"auto":`${Xe}px`,...k,...O.style},onDragEnd:()=>{ee(!1),N(null),Le.current=null},onPointerDown:ft=>{Kt||!St||(pe.current=new Date,ge(Te.current),ft.target.setPointerCapture(ft.pointerId),ft.target.tagName!=="BUTTON"&&(ee(!0),Le.current={x:ft.clientX,y:ft.clientY}))},onPointerUp:()=>{var ft,Lt,hn;if(F||!St)return;Le.current=null;const Gn=Number(((ft=Qe.current)==null?void 0:ft.style.getPropertyValue("--swipe-amount-x").replace("px",""))||0),Nr=Number(((Lt=Qe.current)==null?void 0:Lt.style.getPropertyValue("--swipe-amount-y").replace("px",""))||0),Ft=new Date().getTime()-((hn=pe.current)==null?void 0:hn.getTime()),pr=Z==="x"?Gn:Nr,Si=Math.abs(pr)/Ft;if(Math.abs(pr)>=z7e||Si>.11){ge(Te.current),O.onDismiss==null||O.onDismiss.call(O,O),J(Z==="x"?Gn>0?"right":"left":Nr>0?"down":"up"),Ve(),H(!0);return}else{var Nt,Ln;(Nt=Qe.current)==null||Nt.style.setProperty("--swipe-amount-x","0px"),(Ln=Qe.current)==null||Ln.style.setProperty("--swipe-amount-y","0px")}oe(!1),ee(!1),N(null)},onPointerMove:ft=>{var Lt,hn,Gn;if(!Le.current||!St||((Lt=window.getSelection())==null?void 0:Lt.toString().length)>0)return;const Ft=ft.clientY-Le.current.y,pr=ft.clientX-Le.current.x;var Si;const Nt=(Si=e.swipeDirections)!=null?Si:I7e(z);!Z&&(Math.abs(pr)>1||Math.abs(Ft)>1)&&N(Math.abs(pr)>Math.abs(Ft)?"x":"y");let Ln={x:0,y:0};const ca=kn=>1/(1.5+Math.abs(kn)/20);if(Z==="y"){if(Nt.includes("top")||Nt.includes("bottom"))if(Nt.includes("top")&&Ft<0||Nt.includes("bottom")&&Ft>0)Ln.y=Ft;else{const kn=Ft*ca(Ft);Ln.y=Math.abs(kn)<Math.abs(Ft)?kn:Ft}}else if(Z==="x"&&(Nt.includes("left")||Nt.includes("right")))if(Nt.includes("left")&&pr<0||Nt.includes("right")&&pr>0)Ln.x=pr;else{const kn=pr*ca(pr);Ln.x=Math.abs(kn)<Math.abs(pr)?kn:pr}(Math.abs(Ln.x)>0||Math.abs(Ln.y)>0)&&oe(!0),(hn=Qe.current)==null||hn.style.setProperty("--swipe-amount-x",`${Ln.x}px`),(Gn=Qe.current)==null||Gn.style.setProperty("--swipe-amount-y",`${Ln.y}px`)}},ae&&!O.jsx&&ut!=="loading"?ne.createElement("button",{"aria-label":D,"data-disabled":Kt,"data-close-button":!0,onClick:Kt||!St?()=>{}:()=>{Ve(),O.onDismiss==null||O.onDismiss.call(O,O)},className:Pl(j?.closeButton,O==null||(r=O.classNames)==null?void 0:r.closeButton)},(Yt=U?.close)!=null?Yt:S7e):null,(ut||O.icon||O.promise)&&O.icon!==null&&(U?.[ut]!==null||O.icon)?ne.createElement("div",{"data-icon":"",className:Pl(j?.icon,O==null||(i=O.classNames)==null?void 0:i.icon)},O.promise||O.type==="loading"&&!O.icon?O.icon||Vt():null,O.type!=="loading"?Ye:null):null,ne.createElement("div",{"data-content":"",className:Pl(j?.content,O==null||(a=O.classNames)==null?void 0:a.content)},ne.createElement("div",{"data-title":"",className:Pl(j?.title,O==null||(s=O.classNames)==null?void 0:s.title)},O.jsx?O.jsx:typeof O.title=="function"?O.title():O.title),O.description?ne.createElement("div",{"data-description":"",className:Pl(T,st,j?.description,O==null||(o=O.classNames)==null?void 0:o.description)},typeof O.description=="function"?O.description():O.description):null),ne.isValidElement(O.cancel)?O.cancel:O.cancel&&Lv(O.cancel)?ne.createElement("button",{"data-button":!0,"data-cancel":!0,style:O.cancelButtonStyle||Q,onClick:ft=>{Lv(O.cancel)&&St&&(O.cancel.onClick==null||O.cancel.onClick.call(O.cancel,ft),Ve())},className:Pl(j?.cancelButton,O==null||(l=O.classNames)==null?void 0:l.cancelButton)},O.cancel.label):null,ne.isValidElement(O.action)?O.action:O.action&&Lv(O.action)?ne.createElement("button",{"data-button":!0,"data-action":!0,style:O.actionButtonStyle||X,onClick:ft=>{Lv(O.action)&&(O.action.onClick==null||O.action.onClick.call(O.action,ft),!ft.defaultPrevented&&Ve())},className:Pl(j?.actionButton,O==null||(c=O.classNames)==null?void 0:c.actionButton)},O.action.label):null)};function zG(){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 D7e(e,t){const n={};return[e,t].forEach((r,i)=>{const a=i===1,s=a?"--mobile-offset":"--offset",o=a?q7e:A7e;function l(c){["top","right","bottom","left"].forEach(u=>{n[`${s}-${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[`${s}-${c}`]=o:n[`${s}-${c}`]=typeof r[c]=="number"?`${r[c]}px`:r[c]}):l(o)}),n}const Y7e=ne.forwardRef(function(t,n){const{invert:r,position:i="bottom-right",hotkey:a=["altKey","KeyT"],expand:s,closeButton:o,className:l,offset:c,mobileOffset:u,theme:O="light",richColors:f,duration:p,style:m,visibleToasts:g=C7e,toastOptions:y,dir:b=zG(),gap:v=N7e,icons:x,containerAriaLabel:S="Notifications"}=t,[w,_]=ne.useState([]),k=ne.useMemo(()=>Array.from(new Set([i].concat(w.filter(L=>L.position).map(L=>L.position)))),[w,i]),[Q,X]=ne.useState([]),[C,T]=ne.useState(!1),[A,z]=ne.useState(!1),[Y,G]=ne.useState(O!=="system"?O:typeof window<"u"&&window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),j=ne.useRef(null),U=a.join("+").replace(/Key/g,"").replace(/Digit/g,""),D=ne.useRef(null),Z=ne.useRef(!1),N=ne.useCallback(L=>{_(J=>{var W;return(W=J.find(fe=>fe.id===L.id))!=null&&W.delete||es.dismiss(L.id),J.filter(({id:fe})=>fe!==L.id)})},[]);return ne.useEffect(()=>es.subscribe(L=>{if(L.dismiss){requestAnimationFrame(()=>{_(J=>J.map(W=>W.id===L.id?{...W,delete:!0}:W))});return}setTimeout(()=>{fje.flushSync(()=>{_(J=>{const W=J.findIndex(fe=>fe.id===L.id);return W!==-1?[...J.slice(0,W),{...J[W],...L},...J.slice(W+1)]:[L,...J]})})})}),[w]),ne.useEffect(()=>{if(O!=="system"){G(O);return}if(O==="system"&&(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches?G("dark"):G("light")),typeof window>"u")return;const L=window.matchMedia("(prefers-color-scheme: dark)");try{L.addEventListener("change",({matches:J})=>{G(J?"dark":"light")})}catch{L.addListener(({matches:W})=>{try{G(W?"dark":"light")}catch(fe){console.error(fe)}})}},[O]),ne.useEffect(()=>{w.length<=1&&T(!1)},[w]),ne.useEffect(()=>{const L=J=>{var W;if(a.every(M=>J[M]||J.code===M)){var te;T(!0),(te=j.current)==null||te.focus()}J.code==="Escape"&&(document.activeElement===j.current||(W=j.current)!=null&&W.contains(document.activeElement))&&T(!1)};return document.addEventListener("keydown",L),()=>document.removeEventListener("keydown",L)},[a]),ne.useEffect(()=>{if(j.current)return()=>{D.current&&(D.current.focus({preventScroll:!0}),D.current=null,Z.current=!1)}},[j.current]),ne.createElement("section",{ref:n,"aria-label":`${S} ${U}`,tabIndex:-1,"aria-live":"polite","aria-relevant":"additions text","aria-atomic":"false",suppressHydrationWarning:!0},k.map((L,J)=>{var W;const[fe,te]=L.split("-");return w.length?ne.createElement("ol",{key:L,dir:b==="auto"?zG():b,tabIndex:-1,ref:j,className:l,"data-sonner-toaster":!0,"data-sonner-theme":Y,"data-y-position":fe,"data-lifted":C&&w.length>1&&!s,"data-x-position":te,style:{"--front-toast-height":`${((W=Q[0])==null?void 0:W.height)||0}px`,"--width":`${j7e}px`,"--gap":`${v}px`,...m,...D7e(c,u)},onBlur:M=>{Z.current&&!M.currentTarget.contains(M.relatedTarget)&&(Z.current=!1,D.current&&(D.current.focus({preventScroll:!0}),D.current=null))},onFocus:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||Z.current||(Z.current=!0,D.current=M.relatedTarget)},onMouseEnter:()=>T(!0),onMouseMove:()=>T(!0),onMouseLeave:()=>{A||T(!1)},onDragEnd:()=>T(!1),onPointerDown:M=>{M.target instanceof HTMLElement&&M.target.dataset.dismissible==="false"||z(!0)},onPointerUp:()=>z(!1)},w.filter(M=>!M.position&&J===0||M.position===L).map((M,ie)=>{var ee,F;return ne.createElement(W7e,{key:M.id,icons:x,index:ie,toast:M,defaultRichColors:f,duration:(ee=y?.duration)!=null?ee:p,className:y?.className,descriptionClassName:y?.descriptionClassName,invert:r,visibleToasts:g,closeButton:(F=y?.closeButton)!=null?F:o,interacting:A,position:L,style:y?.style,unstyled:y?.unstyled,classNames:y?.classNames,cancelButtonStyle:y?.cancelButtonStyle,actionButtonStyle:y?.actionButtonStyle,closeButtonAriaLabel:y?.closeButtonAriaLabel,removeToast:N,toasts:w.filter(H=>H.position==M.position),heights:Q.filter(H=>H.position==M.position),setHeights:X,expandByDefault:s,gap:v,expanded:C,swipeDirections:t.swipeDirections})})):null}))}),G7e=["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"],L7e=["ENOTFOUND","EAI_AGAIN","ETIMEDOUT","ECONNRESET","ECONNREFUSED","EHOSTUNREACH","ENETUNREACH","ENETDOWN","ENETRESET","ECONNABORTED","EPIPE"],M7e=["Failed to fetch","Load failed","NetworkError when attempting to fetch resource."],Z7e=new Set(G7e),V7e=/[:\-\u2014\n]$/,F7e=/^[:\n]/,UG=/[:\uff1a\n\u2014]| - /g,B7e=/^(?:\s*Error:\s*)+/,H7e=/:\s+Error:\s+/g,K7e=/\b(?:net::)?(ERR_[A-Z0-9_]+)\b/g,J7e=L7e.map(e=>({code:e,pattern:new RegExp(`\\b${e}\\b`)}));function y5(e,t,n){const r=e.slice(0,t).trimEnd(),i=e.slice(t+n).trimStart(),a=r===""||V7e.test(r),s=i===""||F7e.test(i);return a&&s}function Nde(e){const t=t9e(e);if(!t)return null;const n=zde(t);for(const r of n.matchAll(K7e)){const i=r[1];if(!Z7e.has(i))continue;const a=r.index??0,s=a+r[0].length;return{code:`net::${i}`,start:a,end:s,clauseText:b5(n,a,s),clause:y5(n,a,s-a)}}for(const{code:r,pattern:i}of J7e){const a=i.exec(n);if(a){const s=a.index,o=s+a[0].length;return{code:r,start:s,end:o,clauseText:b5(n,s,o),clause:y5(n,s,o-s)}}}for(const r of M7e){const i=n.indexOf(r);if(i!==-1&&y5(n,i,r.length))return{code:r,start:i,end:i+r.length,clauseText:b5(n,i,i+r.length),clause:!0}}return null}function e9e(e){return Nde(e)?.code??null}function ayn(e){return e9e(e)!==null}function t9e(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 b5(e,t,n){let r=0;for(const a of e.slice(0,t).matchAll(UG))r=(a.index??0)+a[0].length;let i=e.length;for(const a of e.slice(n).matchAll(UG)){i=n+(a.index??0);break}return e.slice(r,i).trim()}function zde(e){return e.replace(B7e,"").replace(H7e,": ")}const hg=new Map,v5=new Map,w5=new Map,IG=5e3,n9e=1,r9e={CONNECTION:["Failed to fetch","Network error","ERR_CONNECTION_REFUSED","Server is offline","Connection failed"]},i9e={"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},x5=()=>h("ui.common.connection.transport_failure"),Ude=e=>{const t=e.trim();if(Object.prototype.hasOwnProperty.call(i9e,t))return x5();const n=zde(t),r=Nde(n);return r===null?e:r.clause?`${n.slice(0,r.start)}${x5()}${n.slice(r.end)}`:x5()},a9e=e=>{for(const[t,n]of Object.entries(r9e))if(n.some(r=>e.includes(r)))return t;return null},s9e=(e,t)=>ch.loading(e,t),lr=(e,t)=>{const n=Date.now(),i=a9e(e)||e,a=Ude(e),s=v5.get(i);if(s&&n-s<IG)return null;const o=w5.get(i)||0;if(o>=n9e)return null;if(hg.has(i))return v5.set(i,n),hg.get(i);const l=ch.error(a,{...t,onDismiss:c=>{hg.delete(i),t?.onDismiss?.(c)},onAutoClose:c=>{hg.delete(i),t?.onAutoClose?.(c)}});return hg.set(i,l),v5.set(i,n),w5.set(i,o+1),setTimeout(()=>{w5.set(i,0)},IG),l},_5=(e,t)=>ch.error(Ude(e),t),Is=(e,t)=>ch.info(e,t),z$=e=>{ch.dismiss(e)},ul=(e,t)=>ch.success(e,t),xp=(e,t)=>ch.warning(e,t),o9e={"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}}},l9e={dark:.09,light:.12},c9e={dark:{role:"sunken",scale:.68},light:{role:"surface",scale:.72}},u9e={"under-window":{dark:.15,light:.2},menu:{dark:.1,light:.2},popover:{dark:.1,light:.15}},O9e={dark:.88,light:.78},d9e={dark:.7,light:.5},f9e={dark:.65,light:.6},h9e={dark:.3,light:.4},p9e={hover:.05,selected:.08,field:.05,work:.08},m9e="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.",MN={alphaFloor:o9e,blockVeil:l9e,laneWash:c9e,controlMix:u9e,bandFloor:O9e,overlayFloor:d9e,overlayInkMix:f9e,overlayEdgeMix:h9e,stateAlpha:p9e,_why:m9e},syn=["sidebars","full"],Ide=(e,t)=>e!=="vibrancy"?"popover":t==="menu"?"menu":t==="popover"?"popover":"under-window",Wde=.96,ZN=e=>Math.round(e*100)/100;function g9e(e,t,n,r=MN){const i=r.alphaFloor[Ide(e,t)][n];return{canvas:i.canvas,surface:i.surface,elevated:i.elevated}}function $9e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=g9e(e.mechanism,e.material,e.scheme,e.floors),r=i=>{const a=Math.max(Wde,i);return ZN(a-t*(a-i))};return{canvas:r(n.canvas),surface:r(n.surface),elevated:r(n.elevated)}}function y9e(e){const t=Math.min(100,Math.max(0,e.intensity))/100,n=MN.overlayFloor[e.scheme],r=Math.max(Wde,n);return ZN(r-t*(r-n))}const b9e={sidebars:["sidebar"],full:["sidebar","canvas","pane"]};function v9e(e){const t=e.floors??MN,n=$9e(e),r=a=>n.canvas===1?0:ZN(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(y9e({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[Ide(e.mechanism,e.material)][e.scheme]),"--lo-glass-in-surface":String(r(n.surface)),"--lo-glass-in-elevated":String(r(n.elevated))};return{kinds:b9e[e.coverage].join(" "),vars:i}}const Dde=()=>document.documentElement,w9e=["--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 Mx=null;const rS=()=>Dde().classList.contains("dark")?"dark":"light";function iS(e){Mx=e;const t=Dde();if(!e||!e.active){delete t.dataset.glass;for(const a of w9e)t.style.removeProperty(a);return}const n=_6e(document),{kinds:r,vars:i}=v9e({floors:n?S6e(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,s]of Object.entries(i))t.style.setProperty(a,s)}function oyn(e){iS(e?{active:!0,scheme:e.scheme,mechanism:e.mechanism,settings:{coverage:e.coverage,intensity:e.intensity,material:e.material}}:null)}function YA(e){if(!e||!e.active||e.capability.mechanism==="none"){iS(null);return}e.restartRequired&&e.active||iS({active:!0,scheme:rS(),mechanism:e.capability.mechanism,settings:{coverage:e.settings.coverage,intensity:e.settings.intensity,material:e.settings.material}})}function lyn(){!Mx||!Mx.active||(iS({...Mx,scheme:rS()}),window.api?.windowGlass?.reportScheme?.(rS()))}function cyn(){const e=window.api?.windowGlass;if(!e)return()=>{};const t=e.onState(r=>YA(r)),n=r=>{r&&YA(r)};return typeof CSS<"u"&&e.reportRenderer?.({backdropFilter:CSS.supports("backdrop-filter: blur(1px)")}).then(n,()=>{}),e.get?.().then(n,()=>{}),t}function uyn(){const[e,t]=$.useState(null);return $.useEffect(()=>{const r=window.api?.windowGlass;if(!r)return;let i=!1;r.get().then(s=>{i||t(s)});const a=r.onState(s=>t(s));return()=>{i=!0,a()}},[]),{state:e,set:async r=>{const i=await window.api?.windowGlass?.set(r);i&&(t(i),YA(i),window.api?.windowGlass?.reportScheme?.(rS()))}}}const x9e=function(){const t=typeof document<"u"&&document.createElement("link").relList;return t&&t.supports&&t.supports("modulepreload")?"modulepreload":"preload"}(),_9e=function(e,t){return new URL(e,t).href},WG={},Pe=function(t,n,r){let i=Promise.resolve();if(n&&n.length>0){const s=document.getElementsByTagName("link"),o=document.querySelector("meta[property=csp-nonce]"),l=o?.nonce||o?.getAttribute("nonce");i=Promise.allSettled(n.map(c=>{if(c=_9e(c,r),c in WG)return;WG[c]=!0;const u=c.endsWith(".css"),O=u?'[rel="stylesheet"]':"";if(!!r)for(let m=s.length-1;m>=0;m--){const g=s[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":x9e,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(s){const o=new Event("vite:preloadError",{cancelable:!0});if(o.payload=s,window.dispatchEvent(o),!o.defaultPrevented)throw s}return i.then(s=>{for(const o of s||[])o.status==="rejected"&&a(o.reason);return t().catch(a)})};/**
4
4
  * React Router DOM v6.30.0
@@ -890,7 +890,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
890
890
  |[ \r ]+
891
891
  ?)[ \r ]*`,Jq="[̀-ͯ]",gct=new RegExp(Jq+"+$"),$ct="("+_$e+"+)|"+(mct+"|")+"([!-\\[\\]-‧‪-퟿豈-￿]"+(Jq+"*")+"|[\uD800-\uDBFF][\uDC00-\uDFFF]"+(Jq+"*")+"|\\\\verb\\*([^]).*?\\4|\\\\verb([^*a-zA-Z]).*?\\5"+("|"+pct)+("|"+hct+")");class AV{constructor(t,n){this.input=void 0,this.settings=void 0,this.tokenRegex=void 0,this.catcodes=void 0,this.input=t,this.settings=n,this.tokenRegex=new RegExp($ct,"g"),this.catcodes={"%":14,"~":13}}setCatcode(t,n){this.catcodes[t]=n}lex(){var t=this.input,n=this.tokenRegex.lastIndex;if(n===t.length)return new nc("EOF",new Xs(this,n,n));var r=this.tokenRegex.exec(t);if(r===null||r.index!==n)throw new Je("Unexpected character: '"+t[n]+"'",new nc(t[n],new Xs(this,n,n+1)));var i=r[6]||r[3]||(r[2]?"\\ ":" ");if(this.catcodes[i]===14){var a=t.indexOf(`
892
892
  `,this.tokenRegex.lastIndex);return a===-1?(this.tokenRegex.lastIndex=t.length,this.settings.reportNonstrict("commentAtEnd","% comment has no terminating newline; LaTeX would fail because of commenting the end of math mode (e.g. $)")):this.tokenRegex.lastIndex=a+1,this.lex()}return new nc(i,new Xs(this,n,this.tokenRegex.lastIndex))}}class yct{constructor(t,n){t===void 0&&(t={}),n===void 0&&(n={}),this.current=void 0,this.builtins=void 0,this.undefStack=void 0,this.current=n,this.builtins=t,this.undefStack=[]}beginGroup(){this.undefStack.push({})}endGroup(){if(this.undefStack.length===0)throw new Je("Unbalanced namespace destruction: attempt to pop global namespace; please report this as a bug");var t=this.undefStack.pop();for(var n in t)t.hasOwnProperty(n)&&(t[n]==null?delete this.current[n]:this.current[n]=t[n])}endGroups(){for(;this.undefStack.length>0;)this.endGroup()}has(t){return this.current.hasOwnProperty(t)||this.builtins.hasOwnProperty(t)}get(t){return this.current.hasOwnProperty(t)?this.current[t]:this.builtins[t]}set(t,n,r){if(r===void 0&&(r=!1),r){for(var i=0;i<this.undefStack.length;i++)delete this.undefStack[i][t];this.undefStack.length>0&&(this.undefStack[this.undefStack.length-1][t]=n)}else{var a=this.undefStack[this.undefStack.length-1];a&&!a.hasOwnProperty(t)&&(a[t]=this.current[t])}n==null?delete this.current[t]:this.current[t]=n}}var bct=f$e;K("\\noexpand",function(e){var t=e.popToken();return e.isExpandable(t.text)&&(t.noexpand=!0,t.treatAsRelax=!0),{tokens:[t],numArgs:0}});K("\\expandafter",function(e){var t=e.popToken();return e.expandOnce(!0),{tokens:[t],numArgs:0}});K("\\@firstoftwo",function(e){var t=e.consumeArgs(2);return{tokens:t[0],numArgs:0}});K("\\@secondoftwo",function(e){var t=e.consumeArgs(2);return{tokens:t[1],numArgs:0}});K("\\@ifnextchar",function(e){var t=e.consumeArgs(3);e.consumeSpaces();var n=e.future();return t[0].length===1&&t[0][0].text===n.text?{tokens:t[1],numArgs:0}:{tokens:t[2],numArgs:0}});K("\\@ifstar","\\@ifnextchar *{\\@firstoftwo{#1}}");K("\\TextOrMath",function(e){var t=e.consumeArgs(2);return e.mode==="text"?{tokens:t[0],numArgs:0}:{tokens:t[1],numArgs:0}});var qV={0:0,1:1,2:2,3:3,4:4,5:5,6:6,7:7,8:8,9:9,a:10,A:10,b:11,B:11,c:12,C:12,d:13,D:13,e:14,E:14,f:15,F:15};K("\\char",function(e){var t=e.popToken(),n,r="";if(t.text==="'")n=8,t=e.popToken();else if(t.text==='"')n=16,t=e.popToken();else if(t.text==="`")if(t=e.popToken(),t.text[0]==="\\")r=t.text.charCodeAt(1);else{if(t.text==="EOF")throw new Je("\\char` missing argument");r=t.text.charCodeAt(0)}else n=10;if(n){if(r=qV[t.text],r==null||r>=n)throw new Je("Invalid base-"+n+" digit "+t.text);for(var i;(i=qV[e.future().text])!=null&&i<n;)r*=n,r+=i,e.popToken()}return"\\@char{"+r+"}"});var IU=(e,t,n,r)=>{var i=e.consumeArg().tokens;if(i.length!==1)throw new Je("\\newcommand's first argument must be a macro name");var a=i[0].text,s=e.isDefined(a);if(s&&!t)throw new Je("\\newcommand{"+a+"} attempting to redefine "+(a+"; use \\renewcommand"));if(!s&&!n)throw new Je("\\renewcommand{"+a+"} when command "+a+" does not yet exist; use \\newcommand");var o=0;if(i=e.consumeArg().tokens,i.length===1&&i[0].text==="["){for(var l="",c=e.expandNextToken();c.text!=="]"&&c.text!=="EOF";)l+=c.text,c=e.expandNextToken();if(!l.match(/^\s*[0-9]+\s*$/))throw new Je("Invalid number of arguments: "+l);o=parseInt(l),i=e.consumeArg().tokens}return s&&r||e.macros.set(a,{tokens:i,numArgs:o}),""};K("\\newcommand",e=>IU(e,!1,!0,!1));K("\\renewcommand",e=>IU(e,!0,!1,!1));K("\\providecommand",e=>IU(e,!0,!0,!0));K("\\message",e=>{var t=e.consumeArgs(1)[0];return console.log(t.reverse().map(n=>n.text).join("")),""});K("\\errmessage",e=>{var t=e.consumeArgs(1)[0];return console.error(t.reverse().map(n=>n.text).join("")),""});K("\\show",e=>{var t=e.popToken(),n=t.text;return console.log(t,e.macros.get(n),XO[n],br.math[n],br.text[n]),""});K("\\bgroup","{");K("\\egroup","}");K("~","\\nobreakspace");K("\\lq","`");K("\\rq","'");K("\\aa","\\r a");K("\\AA","\\r A");K("\\textcopyright","\\html@mathml{\\textcircled{c}}{\\char`©}");K("\\copyright","\\TextOrMath{\\textcopyright}{\\text{\\textcopyright}}");K("\\textregistered","\\html@mathml{\\textcircled{\\scriptsize R}}{\\char`®}");K("ℬ","\\mathscr{B}");K("ℰ","\\mathscr{E}");K("ℱ","\\mathscr{F}");K("ℋ","\\mathscr{H}");K("ℐ","\\mathscr{I}");K("ℒ","\\mathscr{L}");K("ℳ","\\mathscr{M}");K("ℛ","\\mathscr{R}");K("ℭ","\\mathfrak{C}");K("ℌ","\\mathfrak{H}");K("ℨ","\\mathfrak{Z}");K("\\Bbbk","\\Bbb{k}");K("·","\\cdotp");K("\\llap","\\mathllap{\\textrm{#1}}");K("\\rlap","\\mathrlap{\\textrm{#1}}");K("\\clap","\\mathclap{\\textrm{#1}}");K("\\mathstrut","\\vphantom{(}");K("\\underbar","\\underline{\\text{#1}}");K("\\not",'\\html@mathml{\\mathrel{\\mathrlap\\@not}}{\\char"338}');K("\\neq","\\html@mathml{\\mathrel{\\not=}}{\\mathrel{\\char`≠}}");K("\\ne","\\neq");K("≠","\\neq");K("\\notin","\\html@mathml{\\mathrel{{\\in}\\mathllap{/\\mskip1mu}}}{\\mathrel{\\char`∉}}");K("∉","\\notin");K("≘","\\html@mathml{\\mathrel{=\\kern{-1em}\\raisebox{0.4em}{$\\scriptsize\\frown$}}}{\\mathrel{\\char`≘}}");K("≙","\\html@mathml{\\stackrel{\\tiny\\wedge}{=}}{\\mathrel{\\char`≘}}");K("≚","\\html@mathml{\\stackrel{\\tiny\\vee}{=}}{\\mathrel{\\char`≚}}");K("≛","\\html@mathml{\\stackrel{\\scriptsize\\star}{=}}{\\mathrel{\\char`≛}}");K("≝","\\html@mathml{\\stackrel{\\tiny\\mathrm{def}}{=}}{\\mathrel{\\char`≝}}");K("≞","\\html@mathml{\\stackrel{\\tiny\\mathrm{m}}{=}}{\\mathrel{\\char`≞}}");K("≟","\\html@mathml{\\stackrel{\\tiny?}{=}}{\\mathrel{\\char`≟}}");K("⟂","\\perp");K("‼","\\mathclose{!\\mkern-0.8mu!}");K("∌","\\notni");K("⌜","\\ulcorner");K("⌝","\\urcorner");K("⌞","\\llcorner");K("⌟","\\lrcorner");K("©","\\copyright");K("®","\\textregistered");K("️","\\textregistered");K("\\ulcorner",'\\html@mathml{\\@ulcorner}{\\mathop{\\char"231c}}');K("\\urcorner",'\\html@mathml{\\@urcorner}{\\mathop{\\char"231d}}');K("\\llcorner",'\\html@mathml{\\@llcorner}{\\mathop{\\char"231e}}');K("\\lrcorner",'\\html@mathml{\\@lrcorner}{\\mathop{\\char"231f}}');K("\\vdots","{\\varvdots\\rule{0pt}{15pt}}");K("⋮","\\vdots");K("\\varGamma","\\mathit{\\Gamma}");K("\\varDelta","\\mathit{\\Delta}");K("\\varTheta","\\mathit{\\Theta}");K("\\varLambda","\\mathit{\\Lambda}");K("\\varXi","\\mathit{\\Xi}");K("\\varPi","\\mathit{\\Pi}");K("\\varSigma","\\mathit{\\Sigma}");K("\\varUpsilon","\\mathit{\\Upsilon}");K("\\varPhi","\\mathit{\\Phi}");K("\\varPsi","\\mathit{\\Psi}");K("\\varOmega","\\mathit{\\Omega}");K("\\substack","\\begin{subarray}{c}#1\\end{subarray}");K("\\colon","\\nobreak\\mskip2mu\\mathpunct{}\\mathchoice{\\mkern-3mu}{\\mkern-3mu}{}{}{:}\\mskip6mu\\relax");K("\\boxed","\\fbox{$\\displaystyle{#1}$}");K("\\iff","\\DOTSB\\;\\Longleftrightarrow\\;");K("\\implies","\\DOTSB\\;\\Longrightarrow\\;");K("\\impliedby","\\DOTSB\\;\\Longleftarrow\\;");K("\\dddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ...}}{#1}}");K("\\ddddot","{\\overset{\\raisebox{-0.1ex}{\\normalsize ....}}{#1}}");var jV={",":"\\dotsc","\\not":"\\dotsb","+":"\\dotsb","=":"\\dotsb","<":"\\dotsb",">":"\\dotsb","-":"\\dotsb","*":"\\dotsb",":":"\\dotsb","\\DOTSB":"\\dotsb","\\coprod":"\\dotsb","\\bigvee":"\\dotsb","\\bigwedge":"\\dotsb","\\biguplus":"\\dotsb","\\bigcap":"\\dotsb","\\bigcup":"\\dotsb","\\prod":"\\dotsb","\\sum":"\\dotsb","\\bigotimes":"\\dotsb","\\bigoplus":"\\dotsb","\\bigodot":"\\dotsb","\\bigsqcup":"\\dotsb","\\And":"\\dotsb","\\longrightarrow":"\\dotsb","\\Longrightarrow":"\\dotsb","\\longleftarrow":"\\dotsb","\\Longleftarrow":"\\dotsb","\\longleftrightarrow":"\\dotsb","\\Longleftrightarrow":"\\dotsb","\\mapsto":"\\dotsb","\\longmapsto":"\\dotsb","\\hookrightarrow":"\\dotsb","\\doteq":"\\dotsb","\\mathbin":"\\dotsb","\\mathrel":"\\dotsb","\\relbar":"\\dotsb","\\Relbar":"\\dotsb","\\xrightarrow":"\\dotsb","\\xleftarrow":"\\dotsb","\\DOTSI":"\\dotsi","\\int":"\\dotsi","\\oint":"\\dotsi","\\iint":"\\dotsi","\\iiint":"\\dotsi","\\iiiint":"\\dotsi","\\idotsint":"\\dotsi","\\DOTSX":"\\dotsx"};K("\\dots",function(e){var t="\\dotso",n=e.expandAfterFuture().text;return n in jV?t=jV[n]:(n.slice(0,4)==="\\not"||n in br.math&&zt.contains(["bin","rel"],br.math[n].group))&&(t="\\dotsb"),t});var WU={")":!0,"]":!0,"\\rbrack":!0,"\\}":!0,"\\rbrace":!0,"\\rangle":!0,"\\rceil":!0,"\\rfloor":!0,"\\rgroup":!0,"\\rmoustache":!0,"\\right":!0,"\\bigr":!0,"\\biggr":!0,"\\Bigr":!0,"\\Biggr":!0,$:!0,";":!0,".":!0,",":!0};K("\\dotso",function(e){var t=e.future().text;return t in WU?"\\ldots\\,":"\\ldots"});K("\\dotsc",function(e){var t=e.future().text;return t in WU&&t!==","?"\\ldots\\,":"\\ldots"});K("\\cdots",function(e){var t=e.future().text;return t in WU?"\\@cdots\\,":"\\@cdots"});K("\\dotsb","\\cdots");K("\\dotsm","\\cdots");K("\\dotsi","\\!\\cdots");K("\\dotsx","\\ldots\\,");K("\\DOTSI","\\relax");K("\\DOTSB","\\relax");K("\\DOTSX","\\relax");K("\\tmspace","\\TextOrMath{\\kern#1#3}{\\mskip#1#2}\\relax");K("\\,","\\tmspace+{3mu}{.1667em}");K("\\thinspace","\\,");K("\\>","\\mskip{4mu}");K("\\:","\\tmspace+{4mu}{.2222em}");K("\\medspace","\\:");K("\\;","\\tmspace+{5mu}{.2777em}");K("\\thickspace","\\;");K("\\!","\\tmspace-{3mu}{.1667em}");K("\\negthinspace","\\!");K("\\negmedspace","\\tmspace-{4mu}{.2222em}");K("\\negthickspace","\\tmspace-{5mu}{.277em}");K("\\enspace","\\kern.5em ");K("\\enskip","\\hskip.5em\\relax");K("\\quad","\\hskip1em\\relax");K("\\qquad","\\hskip2em\\relax");K("\\tag","\\@ifstar\\tag@literal\\tag@paren");K("\\tag@paren","\\tag@literal{({#1})}");K("\\tag@literal",e=>{if(e.macros.get("\\df@tag"))throw new Je("Multiple \\tag");return"\\gdef\\df@tag{\\text{#1}}"});K("\\bmod","\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}\\mathbin{\\rm mod}\\mathchoice{\\mskip1mu}{\\mskip1mu}{\\mskip5mu}{\\mskip5mu}");K("\\pod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern8mu}{\\mkern8mu}{\\mkern8mu}(#1)");K("\\pmod","\\pod{{\\rm mod}\\mkern6mu#1}");K("\\mod","\\allowbreak\\mathchoice{\\mkern18mu}{\\mkern12mu}{\\mkern12mu}{\\mkern12mu}{\\rm mod}\\,\\,#1");K("\\newline","\\\\\\relax");K("\\TeX","\\textrm{\\html@mathml{T\\kern-.1667em\\raisebox{-.5ex}{E}\\kern-.125emX}{TeX}}");var S$e=lt(Ml["Main-Regular"][84][1]-.7*Ml["Main-Regular"][65][1]);K("\\LaTeX","\\textrm{\\html@mathml{"+("L\\kern-.36em\\raisebox{"+S$e+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{LaTeX}}");K("\\KaTeX","\\textrm{\\html@mathml{"+("K\\kern-.17em\\raisebox{"+S$e+"}{\\scriptstyle A}")+"\\kern-.15em\\TeX}{KaTeX}}");K("\\hspace","\\@ifstar\\@hspacer\\@hspace");K("\\@hspace","\\hskip #1\\relax");K("\\@hspacer","\\rule{0pt}{0pt}\\hskip #1\\relax");K("\\ordinarycolon",":");K("\\vcentcolon","\\mathrel{\\mathop\\ordinarycolon}");K("\\dblcolon",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-.9mu}\\vcentcolon}}{\\mathop{\\char"2237}}');K("\\coloneqq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2254}}');K("\\Coloneqq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}=}}{\\mathop{\\char"2237\\char"3d}}');K("\\coloneq",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"3a\\char"2212}}');K("\\Coloneq",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\mathrel{-}}}{\\mathop{\\char"2237\\char"2212}}');K("\\eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2255}}');K("\\Eqqcolon",'\\html@mathml{\\mathrel{=\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"3d\\char"2237}}');K("\\eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\vcentcolon}}{\\mathop{\\char"2239}}');K("\\Eqcolon",'\\html@mathml{\\mathrel{\\mathrel{-}\\mathrel{\\mkern-1.2mu}\\dblcolon}}{\\mathop{\\char"2212\\char"2237}}');K("\\colonapprox",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"3a\\char"2248}}');K("\\Colonapprox",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\approx}}{\\mathop{\\char"2237\\char"2248}}');K("\\colonsim",'\\html@mathml{\\mathrel{\\vcentcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"3a\\char"223c}}');K("\\Colonsim",'\\html@mathml{\\mathrel{\\dblcolon\\mathrel{\\mkern-1.2mu}\\sim}}{\\mathop{\\char"2237\\char"223c}}');K("∷","\\dblcolon");K("∹","\\eqcolon");K("≔","\\coloneqq");K("≕","\\eqqcolon");K("⩴","\\Coloneqq");K("\\ratio","\\vcentcolon");K("\\coloncolon","\\dblcolon");K("\\colonequals","\\coloneqq");K("\\coloncolonequals","\\Coloneqq");K("\\equalscolon","\\eqqcolon");K("\\equalscoloncolon","\\Eqqcolon");K("\\colonminus","\\coloneq");K("\\coloncolonminus","\\Coloneq");K("\\minuscolon","\\eqcolon");K("\\minuscoloncolon","\\Eqcolon");K("\\coloncolonapprox","\\Colonapprox");K("\\coloncolonsim","\\Colonsim");K("\\simcolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\vcentcolon}");K("\\simcoloncolon","\\mathrel{\\sim\\mathrel{\\mkern-1.2mu}\\dblcolon}");K("\\approxcolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\vcentcolon}");K("\\approxcoloncolon","\\mathrel{\\approx\\mathrel{\\mkern-1.2mu}\\dblcolon}");K("\\notni","\\html@mathml{\\not\\ni}{\\mathrel{\\char`∌}}");K("\\limsup","\\DOTSB\\operatorname*{lim\\,sup}");K("\\liminf","\\DOTSB\\operatorname*{lim\\,inf}");K("\\injlim","\\DOTSB\\operatorname*{inj\\,lim}");K("\\projlim","\\DOTSB\\operatorname*{proj\\,lim}");K("\\varlimsup","\\DOTSB\\operatorname*{\\overline{lim}}");K("\\varliminf","\\DOTSB\\operatorname*{\\underline{lim}}");K("\\varinjlim","\\DOTSB\\operatorname*{\\underrightarrow{lim}}");K("\\varprojlim","\\DOTSB\\operatorname*{\\underleftarrow{lim}}");K("\\gvertneqq","\\html@mathml{\\@gvertneqq}{≩}");K("\\lvertneqq","\\html@mathml{\\@lvertneqq}{≨}");K("\\ngeqq","\\html@mathml{\\@ngeqq}{≱}");K("\\ngeqslant","\\html@mathml{\\@ngeqslant}{≱}");K("\\nleqq","\\html@mathml{\\@nleqq}{≰}");K("\\nleqslant","\\html@mathml{\\@nleqslant}{≰}");K("\\nshortmid","\\html@mathml{\\@nshortmid}{∤}");K("\\nshortparallel","\\html@mathml{\\@nshortparallel}{∦}");K("\\nsubseteqq","\\html@mathml{\\@nsubseteqq}{⊈}");K("\\nsupseteqq","\\html@mathml{\\@nsupseteqq}{⊉}");K("\\varsubsetneq","\\html@mathml{\\@varsubsetneq}{⊊}");K("\\varsubsetneqq","\\html@mathml{\\@varsubsetneqq}{⫋}");K("\\varsupsetneq","\\html@mathml{\\@varsupsetneq}{⊋}");K("\\varsupsetneqq","\\html@mathml{\\@varsupsetneqq}{⫌}");K("\\imath","\\html@mathml{\\@imath}{ı}");K("\\jmath","\\html@mathml{\\@jmath}{ȷ}");K("\\llbracket","\\html@mathml{\\mathopen{[\\mkern-3.2mu[}}{\\mathopen{\\char`⟦}}");K("\\rrbracket","\\html@mathml{\\mathclose{]\\mkern-3.2mu]}}{\\mathclose{\\char`⟧}}");K("⟦","\\llbracket");K("⟧","\\rrbracket");K("\\lBrace","\\html@mathml{\\mathopen{\\{\\mkern-3.2mu[}}{\\mathopen{\\char`⦃}}");K("\\rBrace","\\html@mathml{\\mathclose{]\\mkern-3.2mu\\}}}{\\mathclose{\\char`⦄}}");K("⦃","\\lBrace");K("⦄","\\rBrace");K("\\minuso","\\mathbin{\\html@mathml{{\\mathrlap{\\mathchoice{\\kern{0.145em}}{\\kern{0.145em}}{\\kern{0.1015em}}{\\kern{0.0725em}}\\circ}{-}}}{\\char`⦵}}");K("⦵","\\minuso");K("\\darr","\\downarrow");K("\\dArr","\\Downarrow");K("\\Darr","\\Downarrow");K("\\lang","\\langle");K("\\rang","\\rangle");K("\\uarr","\\uparrow");K("\\uArr","\\Uparrow");K("\\Uarr","\\Uparrow");K("\\N","\\mathbb{N}");K("\\R","\\mathbb{R}");K("\\Z","\\mathbb{Z}");K("\\alef","\\aleph");K("\\alefsym","\\aleph");K("\\Alpha","\\mathrm{A}");K("\\Beta","\\mathrm{B}");K("\\bull","\\bullet");K("\\Chi","\\mathrm{X}");K("\\clubs","\\clubsuit");K("\\cnums","\\mathbb{C}");K("\\Complex","\\mathbb{C}");K("\\Dagger","\\ddagger");K("\\diamonds","\\diamondsuit");K("\\empty","\\emptyset");K("\\Epsilon","\\mathrm{E}");K("\\Eta","\\mathrm{H}");K("\\exist","\\exists");K("\\harr","\\leftrightarrow");K("\\hArr","\\Leftrightarrow");K("\\Harr","\\Leftrightarrow");K("\\hearts","\\heartsuit");K("\\image","\\Im");K("\\infin","\\infty");K("\\Iota","\\mathrm{I}");K("\\isin","\\in");K("\\Kappa","\\mathrm{K}");K("\\larr","\\leftarrow");K("\\lArr","\\Leftarrow");K("\\Larr","\\Leftarrow");K("\\lrarr","\\leftrightarrow");K("\\lrArr","\\Leftrightarrow");K("\\Lrarr","\\Leftrightarrow");K("\\Mu","\\mathrm{M}");K("\\natnums","\\mathbb{N}");K("\\Nu","\\mathrm{N}");K("\\Omicron","\\mathrm{O}");K("\\plusmn","\\pm");K("\\rarr","\\rightarrow");K("\\rArr","\\Rightarrow");K("\\Rarr","\\Rightarrow");K("\\real","\\Re");K("\\reals","\\mathbb{R}");K("\\Reals","\\mathbb{R}");K("\\Rho","\\mathrm{P}");K("\\sdot","\\cdot");K("\\sect","\\S");K("\\spades","\\spadesuit");K("\\sub","\\subset");K("\\sube","\\subseteq");K("\\supe","\\supseteq");K("\\Tau","\\mathrm{T}");K("\\thetasym","\\vartheta");K("\\weierp","\\wp");K("\\Zeta","\\mathrm{Z}");K("\\argmin","\\DOTSB\\operatorname*{arg\\,min}");K("\\argmax","\\DOTSB\\operatorname*{arg\\,max}");K("\\plim","\\DOTSB\\mathop{\\operatorname{plim}}\\limits");K("\\bra","\\mathinner{\\langle{#1}|}");K("\\ket","\\mathinner{|{#1}\\rangle}");K("\\braket","\\mathinner{\\langle{#1}\\rangle}");K("\\Bra","\\left\\langle#1\\right|");K("\\Ket","\\left|#1\\right\\rangle");var k$e=e=>t=>{var n=t.consumeArg().tokens,r=t.consumeArg().tokens,i=t.consumeArg().tokens,a=t.consumeArg().tokens,s=t.macros.get("|"),o=t.macros.get("\\|");t.macros.beginGroup();var l=O=>f=>{e&&(f.macros.set("|",s),i.length&&f.macros.set("\\|",o));var p=O;if(!O&&i.length){var m=f.future();m.text==="|"&&(f.popToken(),p=!0)}return{tokens:p?i:r,numArgs:0}};t.macros.set("|",l(!1)),i.length&&t.macros.set("\\|",l(!0));var c=t.consumeArg().tokens,u=t.expandTokens([...a,...c,...n]);return t.macros.endGroup(),{tokens:u.reverse(),numArgs:0}};K("\\bra@ket",k$e(!1));K("\\bra@set",k$e(!0));K("\\Braket","\\bra@ket{\\left\\langle}{\\,\\middle\\vert\\,}{\\,\\middle\\vert\\,}{\\right\\rangle}");K("\\Set","\\bra@set{\\left\\{\\:}{\\;\\middle\\vert\\;}{\\;\\middle\\Vert\\;}{\\:\\right\\}}");K("\\set","\\bra@set{\\{\\,}{\\mid}{}{\\,\\}}");K("\\angln","{\\angl n}");K("\\blue","\\textcolor{##6495ed}{#1}");K("\\orange","\\textcolor{##ffa500}{#1}");K("\\pink","\\textcolor{##ff00af}{#1}");K("\\red","\\textcolor{##df0030}{#1}");K("\\green","\\textcolor{##28ae7b}{#1}");K("\\gray","\\textcolor{gray}{#1}");K("\\purple","\\textcolor{##9d38bd}{#1}");K("\\blueA","\\textcolor{##ccfaff}{#1}");K("\\blueB","\\textcolor{##80f6ff}{#1}");K("\\blueC","\\textcolor{##63d9ea}{#1}");K("\\blueD","\\textcolor{##11accd}{#1}");K("\\blueE","\\textcolor{##0c7f99}{#1}");K("\\tealA","\\textcolor{##94fff5}{#1}");K("\\tealB","\\textcolor{##26edd5}{#1}");K("\\tealC","\\textcolor{##01d1c1}{#1}");K("\\tealD","\\textcolor{##01a995}{#1}");K("\\tealE","\\textcolor{##208170}{#1}");K("\\greenA","\\textcolor{##b6ffb0}{#1}");K("\\greenB","\\textcolor{##8af281}{#1}");K("\\greenC","\\textcolor{##74cf70}{#1}");K("\\greenD","\\textcolor{##1fab54}{#1}");K("\\greenE","\\textcolor{##0d923f}{#1}");K("\\goldA","\\textcolor{##ffd0a9}{#1}");K("\\goldB","\\textcolor{##ffbb71}{#1}");K("\\goldC","\\textcolor{##ff9c39}{#1}");K("\\goldD","\\textcolor{##e07d10}{#1}");K("\\goldE","\\textcolor{##a75a05}{#1}");K("\\redA","\\textcolor{##fca9a9}{#1}");K("\\redB","\\textcolor{##ff8482}{#1}");K("\\redC","\\textcolor{##f9685d}{#1}");K("\\redD","\\textcolor{##e84d39}{#1}");K("\\redE","\\textcolor{##bc2612}{#1}");K("\\maroonA","\\textcolor{##ffbde0}{#1}");K("\\maroonB","\\textcolor{##ff92c6}{#1}");K("\\maroonC","\\textcolor{##ed5fa6}{#1}");K("\\maroonD","\\textcolor{##ca337c}{#1}");K("\\maroonE","\\textcolor{##9e034e}{#1}");K("\\purpleA","\\textcolor{##ddd7ff}{#1}");K("\\purpleB","\\textcolor{##c6b9fc}{#1}");K("\\purpleC","\\textcolor{##aa87ff}{#1}");K("\\purpleD","\\textcolor{##7854ab}{#1}");K("\\purpleE","\\textcolor{##543b78}{#1}");K("\\mintA","\\textcolor{##f5f9e8}{#1}");K("\\mintB","\\textcolor{##edf2df}{#1}");K("\\mintC","\\textcolor{##e0e5cc}{#1}");K("\\grayA","\\textcolor{##f6f7f7}{#1}");K("\\grayB","\\textcolor{##f0f1f2}{#1}");K("\\grayC","\\textcolor{##e3e5e6}{#1}");K("\\grayD","\\textcolor{##d6d8da}{#1}");K("\\grayE","\\textcolor{##babec2}{#1}");K("\\grayF","\\textcolor{##888d93}{#1}");K("\\grayG","\\textcolor{##626569}{#1}");K("\\grayH","\\textcolor{##3b3e40}{#1}");K("\\grayI","\\textcolor{##21242c}{#1}");K("\\kaBlue","\\textcolor{##314453}{#1}");K("\\kaGreen","\\textcolor{##71B307}{#1}");var Q$e={"^":!0,_:!0,"\\limits":!0,"\\nolimits":!0};class vct{constructor(t,n,r){this.settings=void 0,this.expansionCount=void 0,this.lexer=void 0,this.macros=void 0,this.stack=void 0,this.mode=void 0,this.settings=n,this.expansionCount=0,this.feed(t),this.macros=new yct(bct,n.macros),this.mode=r,this.stack=[]}feed(t){this.lexer=new AV(t,this.settings)}switchMode(t){this.mode=t}beginGroup(){this.macros.beginGroup()}endGroup(){this.macros.endGroup()}endGroups(){this.macros.endGroups()}future(){return this.stack.length===0&&this.pushToken(this.lexer.lex()),this.stack[this.stack.length-1]}popToken(){return this.future(),this.stack.pop()}pushToken(t){this.stack.push(t)}pushTokens(t){this.stack.push(...t)}scanArgument(t){var n,r,i;if(t){if(this.consumeSpaces(),this.future().text!=="[")return null;n=this.popToken(),{tokens:i,end:r}=this.consumeArg(["]"])}else({tokens:i,start:n,end:r}=this.consumeArg());return this.pushToken(new nc("EOF",r.loc)),this.pushTokens(i),n.range(r,"")}consumeSpaces(){for(;;){var t=this.future();if(t.text===" ")this.stack.pop();else break}}consumeArg(t){var n=[],r=t&&t.length>0;r||this.consumeSpaces();var i=this.future(),a,s=0,o=0;do{if(a=this.popToken(),n.push(a),a.text==="{")++s;else if(a.text==="}"){if(--s,s===-1)throw new Je("Extra }",a)}else if(a.text==="EOF")throw new Je("Unexpected end of input in a macro argument, expected '"+(t&&r?t[o]:"}")+"'",a);if(t&&r)if((s===0||s===1&&t[o]==="{")&&a.text===t[o]){if(++o,o===t.length){n.splice(-o,o);break}}else o=0}while(s!==0||r);return i.text==="{"&&n[n.length-1].text==="}"&&(n.pop(),n.shift()),n.reverse(),{tokens:n,start:i,end:a}}consumeArgs(t,n){if(n){if(n.length!==t+1)throw new Je("The length of delimiters doesn't match the number of args!");for(var r=n[0],i=0;i<r.length;i++){var a=this.popToken();if(r[i]!==a.text)throw new Je("Use of the macro doesn't match its definition",a)}}for(var s=[],o=0;o<t;o++)s.push(this.consumeArg(n&&n[o+1]).tokens);return s}countExpansion(t){if(this.expansionCount+=t,this.expansionCount>this.settings.maxExpand)throw new Je("Too many expansions: infinite loop or need to increase maxExpand setting")}expandOnce(t){var n=this.popToken(),r=n.text,i=n.noexpand?null:this._getExpansion(r);if(i==null||t&&i.unexpandable){if(t&&i==null&&r[0]==="\\"&&!this.isDefined(r))throw new Je("Undefined control sequence: "+r);return this.pushToken(n),!1}this.countExpansion(1);var a=i.tokens,s=this.consumeArgs(i.numArgs,i.delimiters);if(i.numArgs){a=a.slice();for(var o=a.length-1;o>=0;--o){var l=a[o];if(l.text==="#"){if(o===0)throw new Je("Incomplete placeholder at end of macro body",l);if(l=a[--o],l.text==="#")a.splice(o+1,1);else if(/^[1-9]$/.test(l.text))a.splice(o,2,...s[+l.text-1]);else throw new Je("Not a valid argument number",l)}}}return this.pushTokens(a),a.length}expandAfterFuture(){return this.expandOnce(),this.future()}expandNextToken(){for(;;)if(this.expandOnce()===!1){var t=this.stack.pop();return t.treatAsRelax&&(t.text="\\relax"),t}throw new Error}expandMacro(t){return this.macros.has(t)?this.expandTokens([new nc(t)]):void 0}expandTokens(t){var n=[],r=this.stack.length;for(this.pushTokens(t);this.stack.length>r;)if(this.expandOnce(!0)===!1){var i=this.stack.pop();i.treatAsRelax&&(i.noexpand=!1,i.treatAsRelax=!1),n.push(i)}return this.countExpansion(n.length),n}expandMacroAsText(t){var n=this.expandMacro(t);return n&&n.map(r=>r.text).join("")}_getExpansion(t){var n=this.macros.get(t);if(n==null)return n;if(t.length===1){var r=this.lexer.catcodes[t];if(r!=null&&r!==13)return}var i=typeof n=="function"?n(this):n;if(typeof i=="string"){var a=0;if(i.indexOf("#")!==-1)for(var s=i.replace(/##/g,"");s.indexOf("#"+(a+1))!==-1;)++a;for(var o=new AV(i,this.settings),l=[],c=o.lex();c.text!=="EOF";)l.push(c),c=o.lex();l.reverse();var u={tokens:l,numArgs:a};return u}return i}isDefined(t){return this.macros.has(t)||XO.hasOwnProperty(t)||br.math.hasOwnProperty(t)||br.text.hasOwnProperty(t)||Q$e.hasOwnProperty(t)}isExpandable(t){var n=this.macros.get(t);return n!=null?typeof n=="string"||typeof n=="function"||!n.unexpandable:XO.hasOwnProperty(t)&&!XO[t].primitive}}var NV=/^[₊₋₌₍₎₀₁₂₃₄₅₆₇₈₉ₐₑₕᵢⱼₖₗₘₙₒₚᵣₛₜᵤᵥₓᵦᵧᵨᵩᵪ]/,dw=Object.freeze({"₊":"+","₋":"-","₌":"=","₍":"(","₎":")","₀":"0","₁":"1","₂":"2","₃":"3","₄":"4","₅":"5","₆":"6","₇":"7","₈":"8","₉":"9","ₐ":"a","ₑ":"e","ₕ":"h","ᵢ":"i","ⱼ":"j","ₖ":"k","ₗ":"l","ₘ":"m","ₙ":"n","ₒ":"o","ₚ":"p","ᵣ":"r","ₛ":"s","ₜ":"t","ᵤ":"u","ᵥ":"v","ₓ":"x","ᵦ":"β","ᵧ":"γ","ᵨ":"ρ","ᵩ":"ϕ","ᵪ":"χ","⁺":"+","⁻":"-","⁼":"=","⁽":"(","⁾":")","⁰":"0","¹":"1","²":"2","³":"3","⁴":"4","⁵":"5","⁶":"6","⁷":"7","⁸":"8","⁹":"9","ᴬ":"A","ᴮ":"B","ᴰ":"D","ᴱ":"E","ᴳ":"G","ᴴ":"H","ᴵ":"I","ᴶ":"J","ᴷ":"K","ᴸ":"L","ᴹ":"M","ᴺ":"N","ᴼ":"O","ᴾ":"P","ᴿ":"R","ᵀ":"T","ᵁ":"U","ⱽ":"V","ᵂ":"W","ᵃ":"a","ᵇ":"b","ᶜ":"c","ᵈ":"d","ᵉ":"e","ᶠ":"f","ᵍ":"g",ʰ:"h","ⁱ":"i",ʲ:"j","ᵏ":"k",ˡ:"l","ᵐ":"m",ⁿ:"n","ᵒ":"o","ᵖ":"p",ʳ:"r",ˢ:"s","ᵗ":"t","ᵘ":"u","ᵛ":"v",ʷ:"w",ˣ:"x",ʸ:"y","ᶻ":"z","ᵝ":"β","ᵞ":"γ","ᵟ":"δ","ᵠ":"ϕ","ᵡ":"χ","ᶿ":"θ"}),ZE={"́":{text:"\\'",math:"\\acute"},"̀":{text:"\\`",math:"\\grave"},"̈":{text:'\\"',math:"\\ddot"},"̃":{text:"\\~",math:"\\tilde"},"̄":{text:"\\=",math:"\\bar"},"̆":{text:"\\u",math:"\\breve"},"̌":{text:"\\v",math:"\\check"},"̂":{text:"\\^",math:"\\hat"},"̇":{text:"\\.",math:"\\dot"},"̊":{text:"\\r",math:"\\mathring"},"̋":{text:"\\H"},"̧":{text:"\\c"}},zV={á:"á",à:"à",ä:"ä",ǟ:"ǟ",ã:"ã",ā:"ā",ă:"ă",ắ:"ắ",ằ:"ằ",ẵ:"ẵ",ǎ:"ǎ",â:"â",ấ:"ấ",ầ:"ầ",ẫ:"ẫ",ȧ:"ȧ",ǡ:"ǡ",å:"å",ǻ:"ǻ",ḃ:"ḃ",ć:"ć",ḉ:"ḉ",č:"č",ĉ:"ĉ",ċ:"ċ",ç:"ç",ď:"ď",ḋ:"ḋ",ḑ:"ḑ",é:"é",è:"è",ë:"ë",ẽ:"ẽ",ē:"ē",ḗ:"ḗ",ḕ:"ḕ",ĕ:"ĕ",ḝ:"ḝ",ě:"ě",ê:"ê",ế:"ế",ề:"ề",ễ:"ễ",ė:"ė",ȩ:"ȩ",ḟ:"ḟ",ǵ:"ǵ",ḡ:"ḡ",ğ:"ğ",ǧ:"ǧ",ĝ:"ĝ",ġ:"ġ",ģ:"ģ",ḧ:"ḧ",ȟ:"ȟ",ĥ:"ĥ",ḣ:"ḣ",ḩ:"ḩ",í:"í",ì:"ì",ï:"ï",ḯ:"ḯ",ĩ:"ĩ",ī:"ī",ĭ:"ĭ",ǐ:"ǐ",î:"î",ǰ:"ǰ",ĵ:"ĵ",ḱ:"ḱ",ǩ:"ǩ",ķ:"ķ",ĺ:"ĺ",ľ:"ľ",ļ:"ļ",ḿ:"ḿ",ṁ:"ṁ",ń:"ń",ǹ:"ǹ",ñ:"ñ",ň:"ň",ṅ:"ṅ",ņ:"ņ",ó:"ó",ò:"ò",ö:"ö",ȫ:"ȫ",õ:"õ",ṍ:"ṍ",ṏ:"ṏ",ȭ:"ȭ",ō:"ō",ṓ:"ṓ",ṑ:"ṑ",ŏ:"ŏ",ǒ:"ǒ",ô:"ô",ố:"ố",ồ:"ồ",ỗ:"ỗ",ȯ:"ȯ",ȱ:"ȱ",ő:"ő",ṕ:"ṕ",ṗ:"ṗ",ŕ:"ŕ",ř:"ř",ṙ:"ṙ",ŗ:"ŗ",ś:"ś",ṥ:"ṥ",š:"š",ṧ:"ṧ",ŝ:"ŝ",ṡ:"ṡ",ş:"ş",ẗ:"ẗ",ť:"ť",ṫ:"ṫ",ţ:"ţ",ú:"ú",ù:"ù",ü:"ü",ǘ:"ǘ",ǜ:"ǜ",ǖ:"ǖ",ǚ:"ǚ",ũ:"ũ",ṹ:"ṹ",ū:"ū",ṻ:"ṻ",ŭ:"ŭ",ǔ:"ǔ",û:"û",ů:"ů",ű:"ű",ṽ:"ṽ",ẃ:"ẃ",ẁ:"ẁ",ẅ:"ẅ",ŵ:"ŵ",ẇ:"ẇ",ẘ:"ẘ",ẍ:"ẍ",ẋ:"ẋ",ý:"ý",ỳ:"ỳ",ÿ:"ÿ",ỹ:"ỹ",ȳ:"ȳ",ŷ:"ŷ",ẏ:"ẏ",ẙ:"ẙ",ź:"ź",ž:"ž",ẑ:"ẑ",ż:"ż",Á:"Á",À:"À",Ä:"Ä",Ǟ:"Ǟ",Ã:"Ã",Ā:"Ā",Ă:"Ă",Ắ:"Ắ",Ằ:"Ằ",Ẵ:"Ẵ",Ǎ:"Ǎ",Â:"Â",Ấ:"Ấ",Ầ:"Ầ",Ẫ:"Ẫ",Ȧ:"Ȧ",Ǡ:"Ǡ",Å:"Å",Ǻ:"Ǻ",Ḃ:"Ḃ",Ć:"Ć",Ḉ:"Ḉ",Č:"Č",Ĉ:"Ĉ",Ċ:"Ċ",Ç:"Ç",Ď:"Ď",Ḋ:"Ḋ",Ḑ:"Ḑ",É:"É",È:"È",Ë:"Ë",Ẽ:"Ẽ",Ē:"Ē",Ḗ:"Ḗ",Ḕ:"Ḕ",Ĕ:"Ĕ",Ḝ:"Ḝ",Ě:"Ě",Ê:"Ê",Ế:"Ế",Ề:"Ề",Ễ:"Ễ",Ė:"Ė",Ȩ:"Ȩ",Ḟ:"Ḟ",Ǵ:"Ǵ",Ḡ:"Ḡ",Ğ:"Ğ",Ǧ:"Ǧ",Ĝ:"Ĝ",Ġ:"Ġ",Ģ:"Ģ",Ḧ:"Ḧ",Ȟ:"Ȟ",Ĥ:"Ĥ",Ḣ:"Ḣ",Ḩ:"Ḩ",Í:"Í",Ì:"Ì",Ï:"Ï",Ḯ:"Ḯ",Ĩ:"Ĩ",Ī:"Ī",Ĭ:"Ĭ",Ǐ:"Ǐ",Î:"Î",İ:"İ",Ĵ:"Ĵ",Ḱ:"Ḱ",Ǩ:"Ǩ",Ķ:"Ķ",Ĺ:"Ĺ",Ľ:"Ľ",Ļ:"Ļ",Ḿ:"Ḿ",Ṁ:"Ṁ",Ń:"Ń",Ǹ:"Ǹ",Ñ:"Ñ",Ň:"Ň",Ṅ:"Ṅ",Ņ:"Ņ",Ó:"Ó",Ò:"Ò",Ö:"Ö",Ȫ:"Ȫ",Õ:"Õ",Ṍ:"Ṍ",Ṏ:"Ṏ",Ȭ:"Ȭ",Ō:"Ō",Ṓ:"Ṓ",Ṑ:"Ṑ",Ŏ:"Ŏ",Ǒ:"Ǒ",Ô:"Ô",Ố:"Ố",Ồ:"Ồ",Ỗ:"Ỗ",Ȯ:"Ȯ",Ȱ:"Ȱ",Ő:"Ő",Ṕ:"Ṕ",Ṗ:"Ṗ",Ŕ:"Ŕ",Ř:"Ř",Ṙ:"Ṙ",Ŗ:"Ŗ",Ś:"Ś",Ṥ:"Ṥ",Š:"Š",Ṧ:"Ṧ",Ŝ:"Ŝ",Ṡ:"Ṡ",Ş:"Ş",Ť:"Ť",Ṫ:"Ṫ",Ţ:"Ţ",Ú:"Ú",Ù:"Ù",Ü:"Ü",Ǘ:"Ǘ",Ǜ:"Ǜ",Ǖ:"Ǖ",Ǚ:"Ǚ",Ũ:"Ũ",Ṹ:"Ṹ",Ū:"Ū",Ṻ:"Ṻ",Ŭ:"Ŭ",Ǔ:"Ǔ",Û:"Û",Ů:"Ů",Ű:"Ű",Ṽ:"Ṽ",Ẃ:"Ẃ",Ẁ:"Ẁ",Ẅ:"Ẅ",Ŵ:"Ŵ",Ẇ:"Ẇ",Ẍ:"Ẍ",Ẋ:"Ẋ",Ý:"Ý",Ỳ:"Ỳ",Ÿ:"Ÿ",Ỹ:"Ỹ",Ȳ:"Ȳ",Ŷ:"Ŷ",Ẏ:"Ẏ",Ź:"Ź",Ž:"Ž",Ẑ:"Ẑ",Ż:"Ż",ά:"ά",ὰ:"ὰ",ᾱ:"ᾱ",ᾰ:"ᾰ",έ:"έ",ὲ:"ὲ",ή:"ή",ὴ:"ὴ",ί:"ί",ὶ:"ὶ",ϊ:"ϊ",ΐ:"ΐ",ῒ:"ῒ",ῑ:"ῑ",ῐ:"ῐ",ό:"ό",ὸ:"ὸ",ύ:"ύ",ὺ:"ὺ",ϋ:"ϋ",ΰ:"ΰ",ῢ:"ῢ",ῡ:"ῡ",ῠ:"ῠ",ώ:"ώ",ὼ:"ὼ",Ύ:"Ύ",Ὺ:"Ὺ",Ϋ:"Ϋ",Ῡ:"Ῡ",Ῠ:"Ῠ",Ώ:"Ώ",Ὼ:"Ὼ"};let P$e=class T$e{constructor(t,n){this.mode=void 0,this.gullet=void 0,this.settings=void 0,this.leftrightDepth=void 0,this.nextToken=void 0,this.mode="math",this.gullet=new vct(t,n,this.mode),this.settings=n,this.leftrightDepth=0}expect(t,n){if(n===void 0&&(n=!0),this.fetch().text!==t)throw new Je("Expected '"+t+"', got '"+this.fetch().text+"'",this.fetch());n&&this.consume()}consume(){this.nextToken=null}fetch(){return this.nextToken==null&&(this.nextToken=this.gullet.expandNextToken()),this.nextToken}switchMode(t){this.mode=t,this.gullet.switchMode(t)}parse(){this.settings.globalGroup||this.gullet.beginGroup(),this.settings.colorIsTextColor&&this.gullet.macros.set("\\color","\\textcolor");try{var t=this.parseExpression(!1);return this.expect("EOF"),this.settings.globalGroup||this.gullet.endGroup(),t}finally{this.gullet.endGroups()}}subparse(t){var n=this.nextToken;this.consume(),this.gullet.pushToken(new nc("}")),this.gullet.pushTokens(t);var r=this.parseExpression(!1);return this.expect("}"),this.nextToken=n,r}parseExpression(t,n){for(var r=[];;){this.mode==="math"&&this.consumeSpaces();var i=this.fetch();if(T$e.endOfExpression.indexOf(i.text)!==-1||n&&i.text===n||t&&XO[i.text]&&XO[i.text].infix)break;var a=this.parseAtom(n);if(a){if(a.type==="internal")continue}else break;r.push(a)}return this.mode==="text"&&this.formLigatures(r),this.handleInfixNodes(r)}handleInfixNodes(t){for(var n=-1,r,i=0;i<t.length;i++)if(t[i].type==="infix"){if(n!==-1)throw new Je("only one infix operator per group",t[i].token);n=i,r=t[i].replaceWith}if(n!==-1&&r){var a,s,o=t.slice(0,n),l=t.slice(n+1);o.length===1&&o[0].type==="ordgroup"?a=o[0]:a={type:"ordgroup",mode:this.mode,body:o},l.length===1&&l[0].type==="ordgroup"?s=l[0]:s={type:"ordgroup",mode:this.mode,body:l};var c;return r==="\\\\abovefrac"?c=this.callFunction(r,[a,t[n],s],[]):c=this.callFunction(r,[a,s],[]),[c]}else return t}handleSupSubscript(t){var n=this.fetch(),r=n.text;this.consume(),this.consumeSpaces();var i;do{var a;i=this.parseGroup(t)}while(((a=i)==null?void 0:a.type)==="internal");if(!i)throw new Je("Expected group after '"+r+"'",n);return i}formatUnsupportedCmd(t){for(var n=[],r=0;r<t.length;r++)n.push({type:"textord",mode:"text",text:t[r]});var i={type:"text",mode:this.mode,body:n},a={type:"color",mode:this.mode,color:this.settings.errorColor,body:[i]};return a}parseAtom(t){var n=this.parseGroup("atom",t);if(n?.type==="internal"||this.mode==="text")return n;for(var r,i;;){this.consumeSpaces();var a=this.fetch();if(a.text==="\\limits"||a.text==="\\nolimits"){if(n&&n.type==="op"){var s=a.text==="\\limits";n.limits=s,n.alwaysHandleSupSub=!0}else if(n&&n.type==="operatorname")n.alwaysHandleSupSub&&(n.limits=a.text==="\\limits");else throw new Je("Limit controls must follow a math operator",a);this.consume()}else if(a.text==="^"){if(r)throw new Je("Double superscript",a);r=this.handleSupSubscript("superscript")}else if(a.text==="_"){if(i)throw new Je("Double subscript",a);i=this.handleSupSubscript("subscript")}else if(a.text==="'"){if(r)throw new Je("Double superscript",a);var o={type:"textord",mode:this.mode,text:"\\prime"},l=[o];for(this.consume();this.fetch().text==="'";)l.push(o),this.consume();this.fetch().text==="^"&&l.push(this.handleSupSubscript("superscript")),r={type:"ordgroup",mode:this.mode,body:l}}else if(dw[a.text]){var c=NV.test(a.text),u=[];for(u.push(new nc(dw[a.text])),this.consume();;){var O=this.fetch().text;if(!dw[O]||NV.test(O)!==c)break;u.unshift(new nc(dw[O])),this.consume()}var f=this.subparse(u);c?i={type:"ordgroup",mode:"math",body:f}:r={type:"ordgroup",mode:"math",body:f}}else break}return r||i?{type:"supsub",mode:this.mode,base:n,sup:r,sub:i}:n}parseFunction(t,n){var r=this.fetch(),i=r.text,a=XO[i];if(!a)return null;if(this.consume(),n&&n!=="atom"&&!a.allowedInArgument)throw new Je("Got function '"+i+"' with no arguments"+(n?" as "+n:""),r);if(this.mode==="text"&&!a.allowedInText)throw new Je("Can't use function '"+i+"' in text mode",r);if(this.mode==="math"&&a.allowedInMath===!1)throw new Je("Can't use function '"+i+"' in math mode",r);var{args:s,optArgs:o}=this.parseArguments(i,a);return this.callFunction(i,s,o,r,t)}callFunction(t,n,r,i,a){var s={funcName:t,parser:this,token:i,breakOnTokenText:a},o=XO[t];if(o&&o.handler)return o.handler(s,n,r);throw new Je("No function handler for "+t)}parseArguments(t,n){var r=n.numArgs+n.numOptionalArgs;if(r===0)return{args:[],optArgs:[]};for(var i=[],a=[],s=0;s<r;s++){var o=n.argTypes&&n.argTypes[s],l=s<n.numOptionalArgs;(n.primitive&&o==null||n.type==="sqrt"&&s===1&&a[0]==null)&&(o="primitive");var c=this.parseGroupOfType("argument to '"+t+"'",o,l);if(l)a.push(c);else if(c!=null)i.push(c);else throw new Je("Null argument, please report this as a bug")}return{args:i,optArgs:a}}parseGroupOfType(t,n,r){switch(n){case"color":return this.parseColorGroup(r);case"size":return this.parseSizeGroup(r);case"url":return this.parseUrlGroup(r);case"math":case"text":return this.parseArgumentGroup(r,n);case"hbox":{var i=this.parseArgumentGroup(r,"text");return i!=null?{type:"styling",mode:i.mode,body:[i],style:"text"}:null}case"raw":{var a=this.parseStringGroup("raw",r);return a!=null?{type:"raw",mode:"text",string:a.text}:null}case"primitive":{if(r)throw new Je("A primitive argument cannot be optional");var s=this.parseGroup(t);if(s==null)throw new Je("Expected group as "+t,this.fetch());return s}case"original":case null:case void 0:return this.parseArgumentGroup(r);default:throw new Je("Unknown group type as "+t,this.fetch())}}consumeSpaces(){for(;this.fetch().text===" ";)this.consume()}parseStringGroup(t,n){var r=this.gullet.scanArgument(n);if(r==null)return null;for(var i="",a;(a=this.fetch()).text!=="EOF";)i+=a.text,this.consume();return this.consume(),r.text=i,r}parseRegexGroup(t,n){for(var r=this.fetch(),i=r,a="",s;(s=this.fetch()).text!=="EOF"&&t.test(a+s.text);)i=s,a+=i.text,this.consume();if(a==="")throw new Je("Invalid "+n+": '"+r.text+"'",r);return r.range(i,a)}parseColorGroup(t){var n=this.parseStringGroup("color",t);if(n==null)return null;var r=/^(#[a-f0-9]{3}|#?[a-f0-9]{6}|[a-z]+)$/i.exec(n.text);if(!r)throw new Je("Invalid color: '"+n.text+"'",n);var i=r[0];return/^[0-9a-f]{6}$/i.test(i)&&(i="#"+i),{type:"color-token",mode:this.mode,color:i}}parseSizeGroup(t){var n,r=!1;if(this.gullet.consumeSpaces(),!t&&this.gullet.future().text!=="{"?n=this.parseRegexGroup(/^[-+]? *(?:$|\d+|\d+\.\d*|\.\d*) *[a-z]{0,2} *$/,"size"):n=this.parseStringGroup("size",t),!n)return null;!t&&n.text.length===0&&(n.text="0pt",r=!0);var i=/([-+]?) *(\d+(?:\.\d*)?|\.\d+) *([a-z]{2})/.exec(n.text);if(!i)throw new Je("Invalid size: '"+n.text+"'",n);var a={number:+(i[1]+i[2]),unit:i[3]};if(!Nge(a))throw new Je("Invalid unit: '"+a.unit+"'",n);return{type:"size",mode:this.mode,value:a,isBlank:r}}parseUrlGroup(t){this.gullet.lexer.setCatcode("%",13),this.gullet.lexer.setCatcode("~",12);var n=this.parseStringGroup("url",t);if(this.gullet.lexer.setCatcode("%",14),this.gullet.lexer.setCatcode("~",13),n==null)return null;var r=n.text.replace(/\\([#$%&~_^{}])/g,"$1");return{type:"url",mode:this.mode,url:r}}parseArgumentGroup(t,n){var r=this.gullet.scanArgument(t);if(r==null)return null;var i=this.mode;n&&this.switchMode(n),this.gullet.beginGroup();var a=this.parseExpression(!1,"EOF");this.expect("EOF"),this.gullet.endGroup();var s={type:"ordgroup",mode:this.mode,loc:r.loc,body:a};return n&&this.switchMode(i),s}parseGroup(t,n){var r=this.fetch(),i=r.text,a;if(i==="{"||i==="\\begingroup"){this.consume();var s=i==="{"?"}":"\\endgroup";this.gullet.beginGroup();var o=this.parseExpression(!1,s),l=this.fetch();this.expect(s),this.gullet.endGroup(),a={type:"ordgroup",mode:this.mode,loc:Xs.range(r,l),body:o,semisimple:i==="\\begingroup"||void 0}}else if(a=this.parseFunction(n,t)||this.parseSymbol(),a==null&&i[0]==="\\"&&!Q$e.hasOwnProperty(i)){if(this.settings.throwOnError)throw new Je("Undefined control sequence: "+i,r);a=this.formatUnsupportedCmd(i),this.consume()}return a}formLigatures(t){for(var n=t.length-1,r=0;r<n;++r){var i=t[r],a=i.text;a==="-"&&t[r+1].text==="-"&&(r+1<n&&t[r+2].text==="-"?(t.splice(r,3,{type:"textord",mode:"text",loc:Xs.range(i,t[r+2]),text:"---"}),n-=2):(t.splice(r,2,{type:"textord",mode:"text",loc:Xs.range(i,t[r+1]),text:"--"}),n-=1)),(a==="'"||a==="`")&&t[r+1].text===a&&(t.splice(r,2,{type:"textord",mode:"text",loc:Xs.range(i,t[r+1]),text:a+a}),n-=1)}}parseSymbol(){var t=this.fetch(),n=t.text;if(/^\\verb[^a-zA-Z]/.test(n)){this.consume();var r=n.slice(5),i=r.charAt(0)==="*";if(i&&(r=r.slice(1)),r.length<2||r.charAt(0)!==r.slice(-1))throw new Je(`\\verb assertion failed --
893
- please report what input caused this bug`);return r=r.slice(1,-1),{type:"verb",mode:"text",body:r,star:i}}zV.hasOwnProperty(n[0])&&!br[this.mode][n[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+n[0]+'" used in math mode',t),n=zV[n[0]]+n.slice(1));var a=gct.exec(n);a&&(n=n.substring(0,a.index),n==="i"?n="ı":n==="j"&&(n="ȷ"));var s;if(br[this.mode][n]){this.settings.strict&&this.mode==="math"&&Vq.indexOf(n)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+n[0]+'" used in math mode',t);var o=br[this.mode][n].group,l=Xs.range(t),c;if(clt.hasOwnProperty(o)){var u=o;c={type:"atom",mode:this.mode,family:u,loc:l,text:n}}else c={type:o,mode:this.mode,loc:l,text:n};s=c}else if(n.charCodeAt(0)>=128)this.settings.strict&&(qge(n.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+n[0]+'" used in math mode',t):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+n[0]+'"'+(" ("+n.charCodeAt(0)+")"),t)),s={type:"textord",mode:"text",loc:Xs.range(t),text:n};else return null;if(this.consume(),a)for(var O=0;O<a[0].length;O++){var f=a[0][O];if(!ZE[f])throw new Je("Unknown accent ' "+f+"'",t);var p=ZE[f][this.mode]||ZE[f].text;if(!p)throw new Je("Accent "+f+" unsupported in "+this.mode+" mode",t);s={type:"accent",mode:this.mode,loc:Xs.range(t),label:p,isStretchy:!1,isShifty:!0,base:s}}return s}};P$e.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var DU=function(t,n){if(!(typeof t=="string"||t instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var r=new P$e(t,n);delete r.gullet.macros.current["\\df@tag"];var i=r.parse();if(delete r.gullet.macros.current["\\current@color"],delete r.gullet.macros.current["\\color"],r.gullet.macros.get("\\df@tag")){if(!n.displayMode)throw new Je("\\tag works only in display equations");i=[{type:"tag",mode:"text",body:i,tag:r.subparse([new nc("\\df@tag")])}]}return i},YU=function(t,n,r){n.textContent="";var i=YP(t,r).toNode();n.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),YU=function(){throw new Je("KaTeX doesn't work in quirks mode.")});var E$e=function(t,n){var r=YP(t,n).toMarkup();return r},R$e=function(t,n){var r=new _U(n);return DU(t,r)},X$e=function(t,n,r){if(r.throwOnError||!(t instanceof Je))throw t;var i=we.makeSpan(["katex-error"],[new ko(n)]);return i.setAttribute("title",t.toString()),i.setAttribute("style","color:"+r.errorColor),i},YP=function(t,n){var r=new _U(n);try{var i=DU(t,r);return Xlt(i,t,r)}catch(a){return X$e(a,t,r)}},C$e=function(t,n){var r=new _U(n);try{var i=DU(t,r);return Clt(i,t,r)}catch(a){return X$e(a,t,r)}},A$e="0.16.22",q$e={Span:D1,Anchor:QU,SymbolNode:ko,SvgNode:xu,PathNode:td,LineNode:Zq},ej={version:A$e,render:YU,renderToString:E$e,ParseError:Je,SETTINGS_SCHEMA:J$,__parse:R$e,__renderToDomTree:YP,__renderToHTMLTree:C$e,__setFontMetrics:jge,__defineSymbol:q,__defineFunction:pt,__defineMacro:K,__domTree:q$e};const Ovn=Object.freeze(Object.defineProperty({__proto__:null,ParseError:Je,SETTINGS_SCHEMA:J$,__defineFunction:pt,__defineMacro:K,__defineSymbol:q,__domTree:q$e,__parse:R$e,__renderToDomTree:YP,__renderToHTMLTree:C$e,__setFontMetrics:jge,default:ej,get render(){return YU},renderToString:E$e,version:A$e},Symbol.toStringTag,{value:"Module"})),wct={},xct=[];function _ct(e){const t=e||wct;return function(n,r){jz(n,"element",function(i,a){const s=Array.isArray(i.properties.className)?i.properties.className:xct,o=s.includes("language-math"),l=s.includes("math-display"),c=s.includes("math-inline");let u=l;if(!o&&!l&&!c)return;let O=a[a.length-1],f=i;if(i.tagName==="code"&&o&&O&&O.type==="element"&&O.tagName==="pre"&&(f=O,O=a[a.length-2],u=!0),!O)return;const p=vot(f,{whitespace:"pre"});let m;try{m=ej.renderToString(p,{...t,displayMode:u,throwOnError:!0})}catch(y){const b=y,v=b.name.toLowerCase();r.message("Could not render math with KaTeX",{ancestors:[...a,i],cause:b,place:i.position,ruleId:v,source:"rehype-katex"});try{m=ej.renderToString(p,{...t,displayMode:u,strict:"ignore",throwOnError:!1})}catch{m=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(y)},children:[{type:"text",value:p}]}]}}typeof m=="string"&&(m=hot(m).children);const g=O.children.indexOf(f);return O.children.splice(g,1,...m),dpe})}}function dvn(e){return e?e.viewMode!=="projects"?e.viewMode:e.lastCanvasView??"documents":"documents"}const tj={isOpen:!1,openTabs:[],selectedTabId:null,files:[],mentionedFiles:[],viewMode:"documents",spreadsheetData:{}},Bs=(e,t)=>{const n=e[t];return n?{...tj,...n}:{...tj}},uf=Ai()(ud((e,t)=>({conversations:{},setSpreadsheetData:(n,r,i)=>{e(a=>{const s=Bs(a.conversations,n);return{conversations:{...a.conversations,[n]:{...s,spreadsheetData:{...s.spreadsheetData,[r]:i}}}}})},setCanvasOpen:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),isOpen:r}}}))},setOpenTabs:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),openTabs:r}}}))},setSelectedTab:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),selectedTabId:r}}}))},setFiles:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),files:r}}}))},updateOneFile:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),s=a.files.map(o=>o.id===r.id?r:o);return{conversations:{...i.conversations,[n]:{...a,files:s}}}})},resetConversationCanvas:n=>{e(r=>{const i={...r.conversations};return i[n]={...tj},{conversations:i}})},setMentionedFiles:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),mentionedFiles:r}}}))},addMentionedFile:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),o=a.mentionedFiles.find(l=>l.id===r.id)?a.mentionedFiles:[...a.mentionedFiles,r];return{conversations:{...i.conversations,[n]:{...a,mentionedFiles:o}}}})},addMentionedFilesBatch:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),s=new Set(a.mentionedFiles.map(l=>l.id)),o=r.filter(l=>!s.has(l.id));return o.length===0?i:{conversations:{...i.conversations,[n]:{...a,mentionedFiles:[...a.mentionedFiles,...o]}}}})},setViewMode:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),viewMode:r,...r==="projects"?{}:{lastCanvasView:r}}}}))},setSelectedProject:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),selectedProjectId:r}}}))},addFileAndSelect:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),o=a.openTabs.some(u=>u.id===r.id)?a.openTabs:[...a.openTabs,{id:r.id,title:r.title}],c=a.files.some(u=>u.id===r.id)?a.files:[...a.files,r];return{conversations:{...i.conversations,[n]:{...a,files:c,openTabs:o,selectedTabId:r.id,viewMode:"documents",lastCanvasView:"documents"}}}})}}),{name:"canvas-store"})),nj="artifact:",fvn="[0-9a-f]{32}",Sct=/^[0-9a-f]{32}$/,kct=/(?:^|\/)attachments\/([0-9a-f]{32})\.bin$/;function Qct(e){return`${nj}${e}`}function Pct(e){return e.startsWith(nj)&&Sct.test(e.slice(nj.length))}function hvn(e){return kct.exec(e)?.[1]??null}function j$e(e,t){switch(e){case"video":return`Video ${t.slice(0,8)}`;case"image":return`Image ${t.slice(0,8)}`;case"audio":return`Sound ${t.slice(0,8)}`;default:return`File ${t.slice(0,8)}`}}const Tct={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","application/pdf":"pdf","audio/mpeg":"mp3","audio/wav":"wav"},Ect=/\.[A-Za-z0-9]{2,5}$/;function pvn(e){const t=e.contentType&&Tct[e.contentType]||(e.kind==="video"?"mp4":e.kind==="image"?"png":e.kind==="audio"?"mp3":"bin"),n=e.name?.replace(/[\\/]/g,"-").trim();return n&&Ect.test(n)?n:n?`${n}-${e.digest.slice(0,8)}.${t}`:`${j$e(e.kind,e.digest)}.${t}`}const N$e=8;function Rct(e){return e==="file"?"File kept in this session":e==="audio"?"Generated sound, kept in this session":`Generated ${e}, kept in this session`}function mvn(e){const t=e.digest.slice(0,N$e);return`${e.title.includes(t)?e.title:`${e.title} · ${t}`} · ${Rct(e.kind)}`}function gvn(e){const t=new Map;for(const r of e)r.artifact&&t.set(r.title,(t.get(r.title)??0)+1);const n=new Map;for(const r of e){const i=r.artifact&&(t.get(r.title)??0)>1;n.set(r.id,i&&r.artifact?`${r.title} · ${r.artifact.digest.slice(0,N$e)}`:r.title)}return n}const qS=e=>e.startsWith("data:image/")?"image":e.startsWith("data:video/")?"video":e.startsWith("data:audio/")?"audio":e.startsWith("data:application/pdf")?"pdf":aU(e),UV=/name=([^;,]+)/,Xct=/[/\\]/,kf=e=>{if(e.startsWith("data:image/")){const n=e.match(UV);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return h("ui.chat.composer_media.pasted_image")}return h("ui.chat.composer_media.pasted_image")}if(e.startsWith("data:")){const n=e.match(UV);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return h("ui.chat.composer_media.pasted_file")}return h("ui.chat.composer_media.pasted_file")}const t=e.split(Xct);return t[t.length-1]},Cct=e=>e.startsWith("file://")?e.slice(7):e;function Act(e,t={}){const n=Cct(e),r={id:n,title:t.title??kf(e),path:n,content:t.content??"",type:t.type??qS(e)};return t.availability!==void 0&&(r.availability=t.availability),t.sizeBytes!==void 0&&(r.sizeBytes=t.sizeBytes),t.lastAgentModified!==void 0&&(r.lastAgentModified=t.lastAgentModified),t.readMtimeMs!==void 0&&(r.readMtimeMs=t.readMtimeMs),r}function $vn(e){const t=Qct(e.digest),n={id:t,title:e.name??j$e(e.kind,e.digest),path:t,content:"",type:e.kind==="file"?"other":e.kind,artifact:e};return e.sizeBytes!==void 0&&(n.sizeBytes=e.sizeBytes),n}const GU=/[$*?{}<>…]/,z$e=/(?:^|[/\\])\.{3,}(?=[/\\]|$)/,qct=/^[^&#]+=[^&#]*(?:&[^&#]+=[^&#]*)*$/,LU=/:[0-9]+(?::[0-9]+)?$/,rj=/[\s"'`()\[\]{}<>,;*|]/,jct=/https?:\/\/\S+/g,U$e=/[\n\r]/,jS=/\s/,Nct=new Set(["*","}",">"]),zct=/file:\/\/(?:localhost)?\/[^\s"'`>*,;}]+/g,Uct=/(?:~\/|\/)[^\s"'`()\[\]{}<>,;*|]+/g,MU=/[.,;:)\]}"'`]+$/;function Ict(e,t){const n=/[^\s]*$/.exec(e.slice(0,t))?.[0]??"";if(!n.endsWith(">"))return!1;const r=n.indexOf("<");return r<=0?!1:n.slice(0,r).includes("/")}const Wct=new Set([`
893
+ please report what input caused this bug`);return r=r.slice(1,-1),{type:"verb",mode:"text",body:r,star:i}}zV.hasOwnProperty(n[0])&&!br[this.mode][n[0]]&&(this.settings.strict&&this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Accented Unicode text character "'+n[0]+'" used in math mode',t),n=zV[n[0]]+n.slice(1));var a=gct.exec(n);a&&(n=n.substring(0,a.index),n==="i"?n="ı":n==="j"&&(n="ȷ"));var s;if(br[this.mode][n]){this.settings.strict&&this.mode==="math"&&Vq.indexOf(n)>=0&&this.settings.reportNonstrict("unicodeTextInMathMode",'Latin-1/Unicode text character "'+n[0]+'" used in math mode',t);var o=br[this.mode][n].group,l=Xs.range(t),c;if(clt.hasOwnProperty(o)){var u=o;c={type:"atom",mode:this.mode,family:u,loc:l,text:n}}else c={type:o,mode:this.mode,loc:l,text:n};s=c}else if(n.charCodeAt(0)>=128)this.settings.strict&&(qge(n.charCodeAt(0))?this.mode==="math"&&this.settings.reportNonstrict("unicodeTextInMathMode",'Unicode text character "'+n[0]+'" used in math mode',t):this.settings.reportNonstrict("unknownSymbol",'Unrecognized Unicode character "'+n[0]+'"'+(" ("+n.charCodeAt(0)+")"),t)),s={type:"textord",mode:"text",loc:Xs.range(t),text:n};else return null;if(this.consume(),a)for(var O=0;O<a[0].length;O++){var f=a[0][O];if(!ZE[f])throw new Je("Unknown accent ' "+f+"'",t);var p=ZE[f][this.mode]||ZE[f].text;if(!p)throw new Je("Accent "+f+" unsupported in "+this.mode+" mode",t);s={type:"accent",mode:this.mode,loc:Xs.range(t),label:p,isStretchy:!1,isShifty:!0,base:s}}return s}};P$e.endOfExpression=["}","\\endgroup","\\end","\\right","&"];var DU=function(t,n){if(!(typeof t=="string"||t instanceof String))throw new TypeError("KaTeX can only parse string typed expression");var r=new P$e(t,n);delete r.gullet.macros.current["\\df@tag"];var i=r.parse();if(delete r.gullet.macros.current["\\current@color"],delete r.gullet.macros.current["\\color"],r.gullet.macros.get("\\df@tag")){if(!n.displayMode)throw new Je("\\tag works only in display equations");i=[{type:"tag",mode:"text",body:i,tag:r.subparse([new nc("\\df@tag")])}]}return i},YU=function(t,n,r){n.textContent="";var i=YP(t,r).toNode();n.appendChild(i)};typeof document<"u"&&document.compatMode!=="CSS1Compat"&&(typeof console<"u"&&console.warn("Warning: KaTeX doesn't work in quirks mode. Make sure your website has a suitable doctype."),YU=function(){throw new Je("KaTeX doesn't work in quirks mode.")});var E$e=function(t,n){var r=YP(t,n).toMarkup();return r},R$e=function(t,n){var r=new _U(n);return DU(t,r)},X$e=function(t,n,r){if(r.throwOnError||!(t instanceof Je))throw t;var i=we.makeSpan(["katex-error"],[new ko(n)]);return i.setAttribute("title",t.toString()),i.setAttribute("style","color:"+r.errorColor),i},YP=function(t,n){var r=new _U(n);try{var i=DU(t,r);return Xlt(i,t,r)}catch(a){return X$e(a,t,r)}},C$e=function(t,n){var r=new _U(n);try{var i=DU(t,r);return Clt(i,t,r)}catch(a){return X$e(a,t,r)}},A$e="0.16.22",q$e={Span:D1,Anchor:QU,SymbolNode:ko,SvgNode:xu,PathNode:td,LineNode:Zq},ej={version:A$e,render:YU,renderToString:E$e,ParseError:Je,SETTINGS_SCHEMA:J$,__parse:R$e,__renderToDomTree:YP,__renderToHTMLTree:C$e,__setFontMetrics:jge,__defineSymbol:q,__defineFunction:pt,__defineMacro:K,__domTree:q$e};const Ovn=Object.freeze(Object.defineProperty({__proto__:null,ParseError:Je,SETTINGS_SCHEMA:J$,__defineFunction:pt,__defineMacro:K,__defineSymbol:q,__domTree:q$e,__parse:R$e,__renderToDomTree:YP,__renderToHTMLTree:C$e,__setFontMetrics:jge,default:ej,get render(){return YU},renderToString:E$e,version:A$e},Symbol.toStringTag,{value:"Module"})),wct={},xct=[];function _ct(e){const t=e||wct;return function(n,r){jz(n,"element",function(i,a){const s=Array.isArray(i.properties.className)?i.properties.className:xct,o=s.includes("language-math"),l=s.includes("math-display"),c=s.includes("math-inline");let u=l;if(!o&&!l&&!c)return;let O=a[a.length-1],f=i;if(i.tagName==="code"&&o&&O&&O.type==="element"&&O.tagName==="pre"&&(f=O,O=a[a.length-2],u=!0),!O)return;const p=vot(f,{whitespace:"pre"});let m;try{m=ej.renderToString(p,{...t,displayMode:u,throwOnError:!0})}catch(y){const b=y,v=b.name.toLowerCase();r.message("Could not render math with KaTeX",{ancestors:[...a,i],cause:b,place:i.position,ruleId:v,source:"rehype-katex"});try{m=ej.renderToString(p,{...t,displayMode:u,strict:"ignore",throwOnError:!1})}catch{m=[{type:"element",tagName:"span",properties:{className:["katex-error"],style:"color:"+(t.errorColor||"#cc0000"),title:String(y)},children:[{type:"text",value:p}]}]}}typeof m=="string"&&(m=hot(m).children);const g=O.children.indexOf(f);return O.children.splice(g,1,...m),dpe})}}function dvn(e){return e?e.viewMode!=="projects"?e.viewMode:e.lastCanvasView??"documents":"documents"}const tj={isOpen:!1,openTabs:[],selectedTabId:null,files:[],mentionedFiles:[],viewMode:"documents",spreadsheetData:{}},Bs=(e,t)=>{const n=e[t];return n?{...tj,...n}:{...tj}},uf=Ai()(ud((e,t)=>({conversations:{},setSpreadsheetData:(n,r,i)=>{e(a=>{const s=Bs(a.conversations,n);return{conversations:{...a.conversations,[n]:{...s,spreadsheetData:{...s.spreadsheetData,[r]:i}}}}})},setCanvasOpen:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),isOpen:r}}}))},setOpenTabs:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),openTabs:r}}}))},setSelectedTab:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),selectedTabId:r}}}))},setFiles:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),files:r}}}))},updateOneFile:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),s=a.files.map(o=>o.id===r.id?r:o);return{conversations:{...i.conversations,[n]:{...a,files:s}}}})},resetConversationCanvas:n=>{e(r=>{const i={...r.conversations};return i[n]={...tj},{conversations:i}})},setMentionedFiles:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),mentionedFiles:r}}}))},addMentionedFile:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),o=a.mentionedFiles.find(l=>l.id===r.id)?a.mentionedFiles:[...a.mentionedFiles,r];return{conversations:{...i.conversations,[n]:{...a,mentionedFiles:o}}}})},addMentionedFilesBatch:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),s=new Set(a.mentionedFiles.map(l=>l.id)),o=r.filter(l=>!s.has(l.id));return o.length===0?i:{conversations:{...i.conversations,[n]:{...a,mentionedFiles:[...a.mentionedFiles,...o]}}}})},setViewMode:(n,r)=>{e(i=>({conversations:{...i.conversations,[n]:{...Bs(i.conversations,n),viewMode:r,...r==="projects"?{}:{lastCanvasView:r}}}}))},setSelectedProject:(n,r,i,a)=>{e(s=>({conversations:{...s.conversations,[n]:{...Bs(s.conversations,n),selectedProjectId:r,selectedProjectSessionId:i,projectListEscape:a}}}))},addFileAndSelect:(n,r)=>{e(i=>{const a=Bs(i.conversations,n),o=a.openTabs.some(u=>u.id===r.id)?a.openTabs:[...a.openTabs,{id:r.id,title:r.title}],c=a.files.some(u=>u.id===r.id)?a.files:[...a.files,r];return{conversations:{...i.conversations,[n]:{...a,files:c,openTabs:o,selectedTabId:r.id,viewMode:"documents",lastCanvasView:"documents"}}}})}}),{name:"canvas-store"})),nj="artifact:",fvn="[0-9a-f]{32}",Sct=/^[0-9a-f]{32}$/,kct=/(?:^|\/)attachments\/([0-9a-f]{32})\.bin$/;function Qct(e){return`${nj}${e}`}function Pct(e){return e.startsWith(nj)&&Sct.test(e.slice(nj.length))}function hvn(e){return kct.exec(e)?.[1]??null}function j$e(e,t){switch(e){case"video":return`Video ${t.slice(0,8)}`;case"image":return`Image ${t.slice(0,8)}`;case"audio":return`Sound ${t.slice(0,8)}`;default:return`File ${t.slice(0,8)}`}}const Tct={"image/png":"png","image/jpeg":"jpg","image/gif":"gif","image/webp":"webp","image/bmp":"bmp","image/svg+xml":"svg","video/mp4":"mp4","video/webm":"webm","video/quicktime":"mov","application/pdf":"pdf","audio/mpeg":"mp3","audio/wav":"wav"},Ect=/\.[A-Za-z0-9]{2,5}$/;function pvn(e){const t=e.contentType&&Tct[e.contentType]||(e.kind==="video"?"mp4":e.kind==="image"?"png":e.kind==="audio"?"mp3":"bin"),n=e.name?.replace(/[\\/]/g,"-").trim();return n&&Ect.test(n)?n:n?`${n}-${e.digest.slice(0,8)}.${t}`:`${j$e(e.kind,e.digest)}.${t}`}const N$e=8;function Rct(e){return e==="file"?"File kept in this session":e==="audio"?"Generated sound, kept in this session":`Generated ${e}, kept in this session`}function mvn(e){const t=e.digest.slice(0,N$e);return`${e.title.includes(t)?e.title:`${e.title} · ${t}`} · ${Rct(e.kind)}`}function gvn(e){const t=new Map;for(const r of e)r.artifact&&t.set(r.title,(t.get(r.title)??0)+1);const n=new Map;for(const r of e){const i=r.artifact&&(t.get(r.title)??0)>1;n.set(r.id,i&&r.artifact?`${r.title} · ${r.artifact.digest.slice(0,N$e)}`:r.title)}return n}const qS=e=>e.startsWith("data:image/")?"image":e.startsWith("data:video/")?"video":e.startsWith("data:audio/")?"audio":e.startsWith("data:application/pdf")?"pdf":aU(e),UV=/name=([^;,]+)/,Xct=/[/\\]/,kf=e=>{if(e.startsWith("data:image/")){const n=e.match(UV);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return h("ui.chat.composer_media.pasted_image")}return h("ui.chat.composer_media.pasted_image")}if(e.startsWith("data:")){const n=e.match(UV);if(n?.[1])try{return decodeURIComponent(n[1])}catch{return h("ui.chat.composer_media.pasted_file")}return h("ui.chat.composer_media.pasted_file")}const t=e.split(Xct);return t[t.length-1]},Cct=e=>e.startsWith("file://")?e.slice(7):e;function Act(e,t={}){const n=Cct(e),r={id:n,title:t.title??kf(e),path:n,content:t.content??"",type:t.type??qS(e)};return t.availability!==void 0&&(r.availability=t.availability),t.sizeBytes!==void 0&&(r.sizeBytes=t.sizeBytes),t.lastAgentModified!==void 0&&(r.lastAgentModified=t.lastAgentModified),t.readMtimeMs!==void 0&&(r.readMtimeMs=t.readMtimeMs),r}function $vn(e){const t=Qct(e.digest),n={id:t,title:e.name??j$e(e.kind,e.digest),path:t,content:"",type:e.kind==="file"?"other":e.kind,artifact:e};return e.sizeBytes!==void 0&&(n.sizeBytes=e.sizeBytes),n}const GU=/[$*?{}<>…]/,z$e=/(?:^|[/\\])\.{3,}(?=[/\\]|$)/,qct=/^[^&#]+=[^&#]*(?:&[^&#]+=[^&#]*)*$/,LU=/:[0-9]+(?::[0-9]+)?$/,rj=/[\s"'`()\[\]{}<>,;*|]/,jct=/https?:\/\/\S+/g,U$e=/[\n\r]/,jS=/\s/,Nct=new Set(["*","}",">"]),zct=/file:\/\/(?:localhost)?\/[^\s"'`>*,;}]+/g,Uct=/(?:~\/|\/)[^\s"'`()\[\]{}<>,;*|]+/g,MU=/[.,;:)\]}"'`]+$/;function Ict(e,t){const n=/[^\s]*$/.exec(e.slice(0,t))?.[0]??"";if(!n.endsWith(">"))return!1;const r=n.indexOf("<");return r<=0?!1:n.slice(0,r).includes("/")}const Wct=new Set([`
894
894
  `," "," ","`",'"',"'","(","[","{","<",">","=",",",";",":","|","*","—"]);function I$e(e){return e===void 0||Wct.has(e)}const ZU=4096,W$e=["/v1/","/api/"];function Dct(e){let t=e.trim().replace(MU,"");return!t||t.length>ZU||(t=t.replace(LU,""),!t)||t.includes("://")||t.startsWith("//")||W$e.some(n=>t.startsWith(n))||!t.startsWith("/")&&!t.startsWith("~/")||jS.test(t)||GU.test(t)||z$e.test(t)?null:t}const D$e=/[/\\]+$/;function VU(e){return(e.replace(D$e,"").split("/").pop()??"").startsWith(".")?!1:hd(e)===null}function Y$e(e){const t=e.split("#",1)[0]??e,n=t.indexOf("?");if(n!==-1&&!qct.test(t.slice(n+1)))return null;let r;try{const i=new URL(e);if(i.protocol!=="file:"||i.host&&i.host!=="localhost")return null;r=i.pathname;try{r=decodeURIComponent(r)}catch{}}catch{return null}return r=r.replace(MU,""),!r||r.length>ZU||(r=r.replace(LU,""),!r)||W$e.some(i=>r.startsWith(i))||GU.test(r)||z$e.test(r)?null:r.startsWith("/")?r:null}const yvn={knownExtensionRequired:!0,rejectFragments:!1},G$e={knownExtensionRequired:!1,rejectFragments:!0},IV=e=>{const t=e.replace(MU,"");return e.length-t.replace(LU,"").length},Yct={"(":")","[":"]","{":"}","<":">"},Gct=new Set(["*","}",">","|"]),Lct=e=>e.includes("/")||e.includes("."),Mct=e=>{const t=e[0];if(t===void 0)return!1;const n=Yct[t];return n?(e.slice(1).split(jS,1)[0]??"").includes(n):Gct.has(t)?Lct(e.slice(1).split(rj,1)[0]??""):!1};function GP(e,t){const n=[];for(const i of e.matchAll(zct)){const a=i.index??0,s=a+i[0].length,o=e.slice(s),l=o.trimStart(),c=o.slice(0,o.length-l.length),u=p=>p.includes("/")||p.includes(".");if(c!==""&&!U$e.test(c)){const p=l.split(rj,1)[0]??"";if(u(p))continue}const O=o[0];if(O!==void 0&&Nct.has(O)){const p=o.slice(1).split(rj,1)[0]??"";if(u(p))continue}const f=Y$e(i[0]);f&&n.push({start:a,end:s-IV(i[0]),kind:"file-url",target:f,href:f})}const r=e.replace(jct,i=>" ".repeat(i.length));for(const i of r.matchAll(Uct)){const a=i.index??0,s=a>0?r[a-1]:void 0;if(!I$e(s)||Ict(r,a))continue;const o=i[0],l=o.indexOf("#"),c=l===-1?o:o.slice(0,l);if(!c||t.rejectFragments&&Mct(r.slice(a+c.length)))continue;const u=Dct(c);if(u){if(t.knownExtensionRequired){const O=hd(u);if(!O||!iU.has(O))continue}VU(u)&&t.evidence?.(u)!=="exists"||n.push({start:a,end:a+c.length-IV(c),kind:"path",target:u,href:u})}}return n.sort((i,a)=>i.start-a.start)}const ij={...G$e,evidence:()=>"exists"};function Zct(e){const t=new Set,n=[];for(const r of GP(e,ij))r.kind==="path"&&VU(r.target)&&n.push(r);return n.push(...put(e,ij)),n.sort((r,i)=>r.start-i.start).map(r=>r.target).filter(r=>t.has(r)?!1:(t.add(r),!0))}const Vct=/^[`*_]*\s*:\s*$/,Fct=/:\s*$/,Bct=/^[a-z0-9]{1,10}$/,Hct=/[.,;:]+$/;function L$e(e){if(!Fct.test(e))return null;const t=e.slice(F$e.exec(e)?.[0].length??0);if(nut.test(t))return null;const n=GP(e,ij),r=n[n.length-1];if(!r||!Vct.test(e.slice(r.end)))return null;const i=r.target,a=i.slice(i.lastIndexOf("/")+1);return(i.endsWith("/")||a.indexOf(".",1)===-1)&&(r.kind==="file-url"||i.startsWith("~/")||i.indexOf("/",1)!==-1)?i:null}function WV(e,t,n){const r=t.trim().replace(Hct,"");if(!r||r.length>ZU||U$e.test(r)||r.includes("/")||r.includes("\\")||GU.test(r))return null;const i=hd(r);if(!i||!Bct.test(i))return null;const a=iU.has(i);return n.knownExtensionRequired&&!a||jS.test(r)&&!a||!n.evidence&&(jS.test(r)||!a)?null:`${e.replace(D$e,"")}/${r}`}const Kct=[" — "," – "," - ",": "],Jct=e=>{let t=-1;for(const n of Kct){const r=e.indexOf(n);r>0&&(t===-1||r<t)&&(t=r)}return t};function M$e(e,t,n){const r=t.trim(),i=Jct(r);if(i>0){const s=r.slice(0,i),o=hd(s);if(o!==null&&iU.has(o)){const l=WV(e,s,n);if(l?.endsWith(`/${s}`))return n.evidence?.(l)!=="exists"?null:{target:l,length:s.length}}}const a=WV(e,r,n);return!a||n.evidence&&n.evidence(a)!=="exists"?null:{target:a,length:a.length-a.lastIndexOf("/")-1}}const Z$e=/^(\s*)([-*+]|\d{1,9}[.)])[ \t]+(?:\[[ xX]\][ \t]+)?(.*)$/,eut=e=>V$e.test(e)?`ordered${e.slice(-1)}`:e,V$e=/^\d/,tut=/^`([^`]+)`$/,FU=/\r$/,F$e=/^\s*(?:(?:[-*+]|\d{1,9}[.)])[ \t]+)?/,nut=/^(?:>|#{1,6}(?:[ \t]|$))/,rut=/^\s*(`{3,}|~{3,})(.*)$/,iut=/^1[.)]/,aut=e=>{let t=0;for(const n of e)if(n===" ")t+=1;else if(n===" ")t+=4-t%4;else break;return t},sut=e=>{const t=[];let n=null,r=!0,i=!1,a=!1;for(const s of e){const o=s.replace(FU,""),l=o.trim()==="";if(n){t.push(!0);const f=o.trim();let p=0;for(;f[p]===n.char;)p+=1;p>=n.length&&p===f.length&&(n=null),r=!1;continue}const c=rut.exec(o),u=c?.[1]??"";if(c&&!(u[0]==="`"&&(c[2]??"").includes("`"))){n={char:u[0]??"`",length:u.length},t.push(!0),a=!1,r=!1;continue}const O=aut(o);if(!l&&O>=4&&(a||r&&!i)){t.push(!0),a=!0,r=!1;continue}l||(a=!1,i=Z$e.test(o)||i&&(O>0||!r)),t.push(!1),r=l}return t},out=/&(?:#([0-9]{1,7})|#[xX]([0-9a-fA-F]{1,6})|([a-zA-Z][a-zA-Z0-9]{1,31}));/g,lut={amp:"&",lt:"<",gt:">",quot:'"',apos:"'",nbsp:" "},DV=e=>e.replace(out,(t,n,r,i)=>{if(i!==void 0)return lut[i]??t;const a=Number.parseInt(r??n,r?16:10);if(a===0||a>1114111)return t;try{return String.fromCodePoint(a)}catch{return t}}),YV=/\\([!-/:-@[-`{-~])/g,cut=/^\s*(?:(?:[-*+]|\d{1,9}[.)])[ \t]|>|#{1,6}(?:[ \t]|$)|`{3}|~{3}|(?:(?:[-*_])[ \t]*){3,}$)/,B$e=/^\s*(?:>[ \t]?)+/,uut=/^\s*(?:#{1,6}(?:[ \t]|$)|`{3}|~{3}|(?:(?:[-*_])[ \t]*){3,}$)/,Out=e=>{const t=e.replace(B$e,"");return t.trim()!==""&&!uut.test(t)},dut=(e,t)=>{let n=t;for(;n>=0;){const r=(e[n]??"").replace(FU,"");if(r.trim()==="")return!1;if(B$e.test(r))return Out(r);if(cut.test(r))return!1;n-=1}return!1},fut=/^`([^`]+)`(.*)$/,hut=e=>{const t=e.trim(),n=tut.exec(t);if(n)return{text:n[1]??"",code:!0};const r=fut.exec(t);return r?{text:`${r[1]??""}${DV((r[2]??"").replace(YV,"$1"))}`,code:!0}:{text:DV(t.replace(YV,"$1")),code:!1}};function put(e,t){if(!e.includes(":"))return[];const n=[],r=e.split(`
895
895
  `),i=[];let a=0;for(const o of r)i.push(a),a+=o.length+1;const s=sut(r);for(let o=0;o<r.length;o+=1){if(s[o])continue;const l=r[o]??"";if(o>0&&!s[o-1]&&dut(r,o-1))continue;const c=L$e(l);if(!c)continue;const u=F$e.exec(l)?.[0].length??0;let O=null,f="",p=null,m=!1,g=o+1;for(;g<r.length;g+=1){const y=(r[g]??"").replace(FU,"");if(y.trim()===""){m=!0;continue}const b=Z$e.exec(y),v=y.length-y.trimStart().length;if(s[g]){if(O!==null&&v>O){p=null;continue}break}if(!b){if(O===null)break;if(!m){p=null;continue}if(v>O){p=null;continue}break}const x=m;m=!1;const S=eut(b[2]??"");if(O===null){if(v<u||v>u+3||!x&&V$e.test(b[2]??"")&&!iut.test(b[2]??""))break;O=v,f=S}if(v>O)continue;if(v<O||S!==f)break;p&&n.push(p),p=null;const w=b[3]??"",_=hut(w),k=M$e(c,_.text,t);if(!k)continue;const Q=(i[g]??0)+y.length-w.length;p={start:Q,end:Q+k.length+(_.code?2:0),kind:"path",target:k.target,href:k.target}}p&&n.push(p),o=Math.max(o,g-1)}return n}const H$e=1024;let mut=0,po=class{constructor(t,n){this.from=t,this.to=n}};class en{constructor(t={}){this.id=mut++,this.perNode=!!t.perNode,this.deserialize=t.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")})}add(t){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof t!="function"&&(t=xi.match(t)),n=>{let r=t(n);return r===void 0?null:[this,r]}}}en.closedBy=new en({deserialize:e=>e.split(" ")});en.openedBy=new en({deserialize:e=>e.split(" ")});en.group=new en({deserialize:e=>e.split(" ")});en.isolate=new en({deserialize:e=>{if(e&&e!="rtl"&&e!="ltr"&&e!="auto")throw new RangeError("Invalid value for isolate: "+e);return e||"auto"}});en.contextHash=new en({perNode:!0});en.lookAhead=new en({perNode:!0});en.mounted=new en({perNode:!0});class Jy{constructor(t,n,r){this.tree=t,this.overlay=n,this.parser=r}static get(t){return t&&t.props&&t.props[en.mounted.id]}}const gut=Object.create(null);class xi{constructor(t,n,r,i=0){this.name=t,this.props=n,this.id=r,this.flags=i}static define(t){let n=t.props&&t.props.length?Object.create(null):gut,r=(t.top?1:0)|(t.skipped?2:0)|(t.error?4:0)|(t.name==null?8:0),i=new xi(t.name||"",n,t.id,r);if(t.props){for(let a of t.props)if(Array.isArray(a)||(a=a(i)),a){if(a[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[a[0].id]=a[1]}}return i}prop(t){return this.props[t.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(t){if(typeof t=="string"){if(this.name==t)return!0;let n=this.prop(en.group);return n?n.indexOf(t)>-1:!1}return this.id==t}static match(t){let n=Object.create(null);for(let r in t)for(let i of r.split(" "))n[i]=t[r];return r=>{for(let i=r.prop(en.group),a=-1;a<(i?i.length:0);a++){let s=n[a<0?r.name:i[a]];if(s)return s}}}}xi.none=new xi("",Object.create(null),0,8);class T0{constructor(t){this.types=t;for(let n=0;n<t.length;n++)if(t[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...t){let n=[];for(let r of this.types){let i=null;for(let a of t){let s=a(r);s&&(i||(i=Object.assign({},r.props)),i[s[0].id]=s[1])}n.push(i?new xi(r.name,i,r.id,r.flags):r)}return new T0(n)}}const fw=new WeakMap,GV=new WeakMap;var ur;(function(e){e[e.ExcludeBuffers=1]="ExcludeBuffers",e[e.IncludeAnonymous=2]="IncludeAnonymous",e[e.IgnoreMounts=4]="IgnoreMounts",e[e.IgnoreOverlays=8]="IgnoreOverlays"})(ur||(ur={}));class xn{constructor(t,n,r,i,a){if(this.type=t,this.children=n,this.positions=r,this.length=i,this.props=null,a&&a.length){this.props=Object.create(null);for(let[s,o]of a)this.props[typeof s=="number"?s:s.id]=o}}toString(){let t=Jy.get(this);if(t&&!t.overlay)return t.tree.toString();let n="";for(let r of this.children){let i=r.toString();i&&(n&&(n+=","),n+=i)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(t=0){return new NS(this.topNode,t)}cursorAt(t,n=0,r=0){let i=fw.get(this)||this.topNode,a=new NS(i);return a.moveTo(t,n),fw.set(this,a._tree),a}get topNode(){return new Qa(this,0,0,null)}resolve(t,n=0){let r=eb(fw.get(this)||this.topNode,t,n,!1);return fw.set(this,r),r}resolveInner(t,n=0){let r=eb(GV.get(this)||this.topNode,t,n,!0);return GV.set(this,r),r}resolveStack(t,n=0){return but(this,t,n)}iterate(t){let{enter:n,leave:r,from:i=0,to:a=this.length}=t,s=t.mode||0,o=(s&ur.IncludeAnonymous)>0;for(let l=this.cursor(s|ur.IncludeAnonymous);;){let c=!1;if(l.from<=a&&l.to>=i&&(!o&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(o||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(t){return t.perNode?this.props?this.props[t.id]:void 0:this.type.prop(t)}get propValues(){let t=[];if(this.props)for(let n in this.props)t.push([+n,this.props[n]]);return t}balance(t={}){return this.children.length<=8?this:KU(xi.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,i)=>new xn(this.type,n,r,i,this.propValues),t.makeTree||((n,r,i)=>new xn(xi.none,n,r,i)))}static build(t){return vut(t)}}xn.empty=new xn(xi.none,[],[],0);class BU{constructor(t,n){this.buffer=t,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new BU(this.buffer,this.index)}}class rd{constructor(t,n,r){this.buffer=t,this.length=n,this.set=r}get type(){return xi.none}toString(){let t=[];for(let n=0;n<this.buffer.length;)t.push(this.childString(n)),n=this.buffer[n+3];return t.join(",")}childString(t){let n=this.buffer[t],r=this.buffer[t+3],i=this.set.types[n],a=i.name;if(/\W/.test(a)&&!i.isError&&(a=JSON.stringify(a)),t+=4,r==t)return a;let s=[];for(;t<r;)s.push(this.childString(t)),t=this.buffer[t+3];return a+"("+s.join(",")+")"}findChild(t,n,r,i,a){let{buffer:s}=this,o=-1;for(let l=t;l!=n&&!(K$e(a,i,s[l+1],s[l+2])&&(o=l,r>0));l=s[l+3]);return o}slice(t,n,r){let i=this.buffer,a=new Uint16Array(n-t),s=0;for(let o=t,l=0;o<n;){a[l++]=i[o++],a[l++]=i[o++]-r;let c=a[l++]=i[o++]-r;a[l++]=i[o++]-t,s=Math.max(s,c)}return new rd(a,s,this.set)}}function K$e(e,t,n,r){switch(e){case-2:return n<t;case-1:return r>=t&&n<t;case 0:return n<t&&r>t;case 1:return n<=t&&r>t;case 2:return r>t;case 4:return!0}}function eb(e,t,n,r){for(var i;e.from==e.to||(n<1?e.from>=t:e.from>t)||(n>-1?e.to<=t:e.to<t);){let s=!r&&e instanceof Qa&&e.index<0?null:e.parent;if(!s)return e;e=s}let a=r?0:ur.IgnoreOverlays;if(r)for(let s=e,o=s.parent;o;s=o,o=s.parent)s instanceof Qa&&s.index<0&&((i=o.enter(t,n,a))===null||i===void 0?void 0:i.from)!=s.from&&(e=o);for(;;){let s=e.enter(t,n,a);if(!s)return e;e=s}}class J$e{cursor(t=0){return new NS(this,t)}getChild(t,n=null,r=null){let i=LV(this,t,n,r);return i.length?i[0]:null}getChildren(t,n=null,r=null){return LV(this,t,n,r)}resolve(t,n=0){return eb(this,t,n,!1)}resolveInner(t,n=0){return eb(this,t,n,!0)}matchContext(t){return aj(this.parent,t)}enterUnfinishedNodesBefore(t){let n=this.childBefore(t),r=this;for(;n;){let i=n.lastChild;if(!i||i.to!=n.to)break;i.type.isError&&i.from==i.to?(r=n,n=i.prevSibling):n=i}return r}get node(){return this}get next(){return this.parent}}class Qa extends J$e{constructor(t,n,r,i){super(),this._tree=t,this.from=n,this.index=r,this._parent=i}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(t,n,r,i,a=0){for(let s=this;;){for(let{children:o,positions:l}=s._tree,c=n>0?o.length:-1;t!=c;t+=n){let u=o[t],O=l[t]+s.from;if(K$e(i,r,O,O+u.length)){if(u instanceof rd){if(a&ur.ExcludeBuffers)continue;let f=u.findChild(0,u.buffer.length,n,r-O,i);if(f>-1)return new Vl(new $ut(s,u,t,O),null,f)}else if(a&ur.IncludeAnonymous||!u.type.isAnonymous||HU(u)){let f;if(!(a&ur.IgnoreMounts)&&(f=Jy.get(u))&&!f.overlay)return new Qa(f.tree,O,t,s);let p=new Qa(u,O,t,s);return a&ur.IncludeAnonymous||!p.type.isAnonymous?p:p.nextChild(n<0?u.children.length-1:0,n,r,i)}}}if(a&ur.IncludeAnonymous||!s.type.isAnonymous||(s.index>=0?t=s.index+n:t=n<0?-1:s._parent._tree.children.length,s=s._parent,!s))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(t){return this.nextChild(0,1,t,2)}childBefore(t){return this.nextChild(this._tree.children.length-1,-1,t,-2)}enter(t,n,r=0){let i;if(!(r&ur.IgnoreOverlays)&&(i=Jy.get(this._tree))&&i.overlay){let a=t-this.from;for(let{from:s,to:o}of i.overlay)if((n>0?s<=a:s<a)&&(n<0?o>=a:o>a))return new Qa(i.tree,i.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,t,n,r)}nextSignificantParent(){let t=this;for(;t.type.isAnonymous&&t._parent;)t=t._parent;return t}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function LV(e,t,n,r){let i=e.cursor(),a=[];if(!i.firstChild())return a;if(n!=null){for(let s=!1;!s;)if(s=i.type.is(n),!i.nextSibling())return a}for(;;){if(r!=null&&i.type.is(r))return a;if(i.type.is(t)&&a.push(i.node),!i.nextSibling())return r==null?a:[]}}function aj(e,t,n=t.length-1){for(let r=e;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(t[n]&&t[n]!=r.name)return!1;n--}}return!0}class $ut{constructor(t,n,r,i){this.parent=t,this.buffer=n,this.index=r,this.start=i}}class Vl extends J$e{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(t,n,r){super(),this.context=t,this._parent=n,this.index=r,this.type=t.buffer.set.types[t.buffer.buffer[r]]}child(t,n,r){let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.context.start,r);return a<0?null:new Vl(this.context,this,a)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(t){return this.child(1,t,2)}childBefore(t){return this.child(-1,t,-2)}enter(t,n,r=0){if(r&ur.ExcludeBuffers)return null;let{buffer:i}=this.context,a=i.findChild(this.index+4,i.buffer[this.index+3],n>0?1:-1,t-this.context.start,n);return a<0?null:new Vl(this.context,this,a)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(t){return this._parent?null:this.context.parent.nextChild(this.context.index+t,t,0,4)}get nextSibling(){let{buffer:t}=this.context,n=t.buffer[this.index+3];return n<(this._parent?t.buffer[this._parent.index+3]:t.buffer.length)?new Vl(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:t}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new Vl(this.context,this._parent,t.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let t=[],n=[],{buffer:r}=this.context,i=this.index+4,a=r.buffer[this.index+3];if(a>i){let s=r.buffer[this.index+1];t.push(r.slice(i,a,s)),n.push(0)}return new xn(this.type,t,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function eye(e){if(!e.length)return null;let t=0,n=e[0];for(let a=1;a<e.length;a++){let s=e[a];(s.from>n.from||s.to<n.to)&&(n=s,t=a)}let r=n instanceof Qa&&n.index<0?null:n.parent,i=e.slice();return r?i[t]=r:i.splice(t,1),new yut(i,n)}class yut{constructor(t,n){this.heads=t,this.node=n}get next(){return eye(this.heads)}}function but(e,t,n){let r=e.resolveInner(t,n),i=null;for(let a=r instanceof Qa?r:r.context.parent;a;a=a.parent)if(a.index<0){let s=a.parent;(i||(i=[r])).push(s.resolve(t,n)),a=s}else{let s=Jy.get(a.tree);if(s&&s.overlay&&s.overlay[0].from<=t&&s.overlay[s.overlay.length-1].to>=t){let o=new Qa(s.tree,s.overlay[0].from+a.from,-1,a);(i||(i=[r])).push(eb(o,t,n,!1))}}return i?eye(i):r}class NS{get name(){return this.type.name}constructor(t,n=0){if(this.mode=n,this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,t instanceof Qa)this.yieldNode(t);else{this._tree=t.context.parent,this.buffer=t.context;for(let r=t._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=t,this.yieldBuf(t.index)}}yieldNode(t){return t?(this._tree=t,this.type=t.type,this.from=t.from,this.to=t.to,!0):!1}yieldBuf(t,n){this.index=t;let{start:r,buffer:i}=this.buffer;return this.type=n||i.set.types[i.buffer[t]],this.from=r+i.buffer[t+1],this.to=r+i.buffer[t+2],!0}yield(t){return t?t instanceof Qa?(this.buffer=null,this.yieldNode(t)):(this.buffer=t.context,this.yieldBuf(t.index,t.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(t,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(t<0?this._tree._tree.children.length-1:0,t,n,r,this.mode));let{buffer:i}=this.buffer,a=i.findChild(this.index+4,i.buffer[this.index+3],t,n-this.buffer.start,r);return a<0?!1:(this.stack.push(this.index),this.yieldBuf(a))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(t){return this.enterChild(1,t,2)}childBefore(t){return this.enterChild(-1,t,-2)}enter(t,n,r=this.mode){return this.buffer?r&ur.ExcludeBuffers?!1:this.enterChild(1,t,n):this.yield(this._tree.enter(t,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&ur.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let t=this.mode&ur.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(t)}sibling(t){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+t,t,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(t<0){let i=r<0?0:this.stack[r]+4;if(this.index!=i)return this.yieldBuf(n.findChild(i,this.index,-1,0,4))}else{let i=n.buffer[this.index+3];if(i<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(i)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+t,t,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(t){let n,r,{buffer:i}=this;if(i){if(t>0){if(this.index<i.buffer.buffer.length)return!1}else for(let a=0;a<this.index;a++)if(i.buffer.buffer[a+3]<this.index)return!1;({index:n,parent:r}=i)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let a=n+t,s=t<0?-1:r._tree.children.length;a!=s;a+=t){let o=r._tree.children[a];if(this.mode&ur.IncludeAnonymous||o instanceof rd||!o.type.isAnonymous||HU(o))return!1}return!0}move(t,n){if(n&&this.enterChild(t,0,4))return!0;for(;;){if(this.sibling(t))return!0;if(this.atLastNode(t)||!this.parent())return!1}}next(t=!0){return this.move(1,t)}prev(t=!0){return this.move(-1,t)}moveTo(t,n=0){for(;(this.from==this.to||(n<1?this.from>=t:this.from>t)||(n>-1?this.to<=t:this.to<t))&&this.parent(););for(;this.enterChild(1,t,n););return this}get node(){if(!this.buffer)return this._tree;let t=this.bufferNode,n=null,r=0;if(t&&t.context==this.buffer)e:for(let i=this.index,a=this.stack.length;a>=0;){for(let s=t;s;s=s._parent)if(s.index==i){if(i==this.index)return s;n=s,r=a+1;break e}i=this.stack[--a]}for(let i=r;i<this.stack.length;i++)n=new Vl(this.buffer,n,this.stack[i]);return this.bufferNode=new Vl(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(t,n){for(let r=0;;){let i=!1;if(this.type.isAnonymous||t(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(i=!0)}for(;;){if(i&&n&&n(this),i=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,i=!0}}}matchContext(t){if(!this.buffer)return aj(this.node.parent,t);let{buffer:n}=this.buffer,{types:r}=n.set;for(let i=t.length-1,a=this.stack.length-1;i>=0;a--){if(a<0)return aj(this._tree,t,i);let s=r[n.buffer[this.stack[a]]];if(!s.isAnonymous){if(t[i]&&t[i]!=s.name)return!1;i--}}return!0}}function HU(e){return e.children.some(t=>t instanceof rd||!t.type.isAnonymous||HU(t))}function vut(e){var t;let{buffer:n,nodeSet:r,maxBufferLength:i=H$e,reused:a=[],minRepeatType:s=r.types.length}=e,o=Array.isArray(n)?new BU(n,n.length):n,l=r.types,c=0,u=0;function O(w,_,k,Q,X,C){let{id:T,start:A,end:z,size:Y}=o,G=u,j=c;for(;Y<0;)if(o.next(),Y==-1){let L=a[T];k.push(L),Q.push(A-w);return}else if(Y==-3){c=T;return}else if(Y==-4){u=T;return}else throw new RangeError(`Unrecognized record size: ${Y}`);let U=l[T],D,Z,N=A-w;if(z-A<=i&&(Z=y(o.pos-_,X))){let L=new Uint16Array(Z.size-Z.skip),J=o.pos-Z.size,W=L.length;for(;o.pos>J;)W=b(Z.start,L,W);D=new rd(L,z-Z.start,r),N=Z.start-w}else{let L=o.pos-Y;o.next();let J=[],W=[],fe=T>=s?T:-1,te=0,M=z;for(;o.pos>L;)fe>=0&&o.id==fe&&o.size>=0?(o.end<=M-i&&(m(J,W,A,te,o.end,M,fe,G,j),te=J.length,M=o.end),o.next()):C>2500?f(A,L,J,W):O(A,L,J,W,fe,C+1);if(fe>=0&&te>0&&te<J.length&&m(J,W,A,te,A,M,fe,G,j),J.reverse(),W.reverse(),fe>-1&&te>0){let ie=p(U,j);D=KU(U,J,W,0,J.length,0,z-A,ie,ie)}else D=g(U,J,W,z-A,G-z,j)}k.push(D),Q.push(N)}function f(w,_,k,Q){let X=[],C=0,T=-1;for(;o.pos>_;){let{id:A,start:z,end:Y,size:G}=o;if(G>4)o.next();else{if(T>-1&&z<T)break;T<0&&(T=Y-i),X.push(A,z,Y),C++,o.next()}}if(C){let A=new Uint16Array(C*4),z=X[X.length-2];for(let Y=X.length-3,G=0;Y>=0;Y-=3)A[G++]=X[Y],A[G++]=X[Y+1]-z,A[G++]=X[Y+2]-z,A[G++]=G;k.push(new rd(A,X[2]-z,r)),Q.push(z-w)}}function p(w,_){return(k,Q,X)=>{let C=0,T=k.length-1,A,z;if(T>=0&&(A=k[T])instanceof xn){if(!T&&A.type==w&&A.length==X)return A;(z=A.prop(en.lookAhead))&&(C=Q[T]+A.length+z)}return g(w,k,Q,X,C,_)}}function m(w,_,k,Q,X,C,T,A,z){let Y=[],G=[];for(;w.length>Q;)Y.push(w.pop()),G.push(_.pop()+k-X);w.push(g(r.types[T],Y,G,C-X,A-C,z)),_.push(X-k)}function g(w,_,k,Q,X,C,T){if(C){let A=[en.contextHash,C];T=T?[A].concat(T):[A]}if(X>25){let A=[en.lookAhead,X];T=T?[A].concat(T):[A]}return new xn(w,_,k,Q,T)}function y(w,_){let k=o.fork(),Q=0,X=0,C=0,T=k.end-i,A={size:0,start:0,skip:0};e:for(let z=k.pos-w;k.pos>z;){let Y=k.size;if(k.id==_&&Y>=0){A.size=Q,A.start=X,A.skip=C,C+=4,Q+=4,k.next();continue}let G=k.pos-Y;if(Y<0||G<z||k.start<T)break;let j=k.id>=s?4:0,U=k.start;for(k.next();k.pos>G;){if(k.size<0)if(k.size==-3)j+=4;else break e;else k.id>=s&&(j+=4);k.next()}X=U,Q+=Y,C+=j}return(_<0||Q==w)&&(A.size=Q,A.start=X,A.skip=C),A.size>4?A:void 0}function b(w,_,k){let{id:Q,start:X,end:C,size:T}=o;if(o.next(),T>=0&&Q<s){let A=k;if(T>4){let z=o.pos-(T-4);for(;o.pos>z;)k=b(w,_,k)}_[--k]=A,_[--k]=C-w,_[--k]=X-w,_[--k]=Q}else T==-3?c=Q:T==-4&&(u=Q);return k}let v=[],x=[];for(;o.pos>0;)O(e.start||0,e.bufferStart||0,v,x,-1,0);let S=(t=e.length)!==null&&t!==void 0?t:v.length?x[0]+v[0].length:0;return new xn(l[e.topID],v.reverse(),x.reverse(),S)}const MV=new WeakMap;function o_(e,t){if(!e.isAnonymous||t instanceof rd||t.type!=e)return 1;let n=MV.get(t);if(n==null){n=1;for(let r of t.children){if(r.type!=e||!(r instanceof xn)){n=1;break}n+=o_(e,r)}MV.set(t,n)}return n}function KU(e,t,n,r,i,a,s,o,l){let c=0;for(let m=r;m<i;m++)c+=o_(e,t[m]);let u=Math.ceil(c*1.5/8),O=[],f=[];function p(m,g,y,b,v){for(let x=y;x<b;){let S=x,w=g[x],_=o_(e,m[x]);for(x++;x<b;x++){let k=o_(e,m[x]);if(_+k>=u)break;_+=k}if(x==S+1){if(_>u){let k=m[S];p(k.children,k.positions,0,k.children.length,g[S]+v);continue}O.push(m[S])}else{let k=g[x-1]+m[x-1].length-w;O.push(KU(e,m,g,S,x,w,k,null,l))}f.push(w+v-a)}}return p(t,n,r,i,0),(o||l)(O,f,s)}class JU{constructor(){this.map=new WeakMap}setBuffer(t,n,r){let i=this.map.get(t);i||this.map.set(t,i=new Map),i.set(n,r)}getBuffer(t,n){let r=this.map.get(t);return r&&r.get(n)}set(t,n){t instanceof Vl?this.setBuffer(t.context.buffer,t.index,n):t instanceof Qa&&this.map.set(t.tree,n)}get(t){return t instanceof Vl?this.getBuffer(t.context.buffer,t.index):t instanceof Qa?this.map.get(t.tree):void 0}cursorSet(t,n){t.buffer?this.setBuffer(t.buffer.buffer,t.index,n):this.map.set(t.tree,n)}cursorGet(t){return t.buffer?this.getBuffer(t.buffer.buffer,t.index):this.map.get(t.tree)}}class hu{constructor(t,n,r,i,a=!1,s=!1){this.from=t,this.to=n,this.tree=r,this.offset=i,this.open=(a?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(t,n=[],r=!1){let i=[new hu(0,t.length,t,0,!1,r)];for(let a of n)a.to>t.length&&i.push(a);return i}static applyChanges(t,n,r=128){if(!n.length)return t;let i=[],a=1,s=t.length?t[0]:null;for(let o=0,l=0,c=0;;o++){let u=o<n.length?n[o]:null,O=u?u.fromA:1e9;if(O-l>=r)for(;s&&s.from<O;){let f=s;if(l>=f.from||O<=f.to||c){let p=Math.max(f.from,l)-c,m=Math.min(f.to,O)-c;f=p>=m?null:new hu(p,m,f.tree,f.offset+c,o>0,!!u)}if(f&&i.push(f),s.to>O)break;s=a<t.length?t[a++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return i}}class LP{startParse(t,n,r){return typeof t=="string"&&(t=new wut(t)),r=r?r.length?r.map(i=>new po(i.from,i.to)):[new po(0,0)]:[new po(0,t.length)],this.createParse(t,n||[],r)}parse(t,n,r){let i=this.startParse(t,n,r);for(;;){let a=i.advance();if(a)return a}}}class wut{constructor(t){this.string=t}get length(){return this.string.length}chunk(t){return this.string.slice(t)}get lineChunks(){return!1}read(t,n){return this.string.slice(t,n)}}function Ro(e){return(t,n,r,i)=>new _ut(t,e,n,r,i)}class ZV{constructor(t,n,r,i,a){this.parser=t,this.parse=n,this.overlay=r,this.target=i,this.from=a}}function VV(e){if(!e.length||e.some(t=>t.from>=t.to))throw new RangeError("Invalid inner parse ranges given: "+JSON.stringify(e))}class xut{constructor(t,n,r,i,a,s,o){this.parser=t,this.predicate=n,this.mounts=r,this.index=i,this.start=a,this.target=s,this.prev=o,this.depth=0,this.ranges=[]}}const sj=new en({perNode:!0});class _ut{constructor(t,n,r,i,a){this.nest=n,this.input=r,this.fragments=i,this.ranges=a,this.inner=[],this.innerDone=0,this.baseTree=null,this.stoppedAt=null,this.baseParse=t}advance(){if(this.baseParse){let r=this.baseParse.advance();if(!r)return null;if(this.baseParse=null,this.baseTree=r,this.startInner(),this.stoppedAt!=null)for(let i of this.inner)i.parse.stopAt(this.stoppedAt)}if(this.innerDone==this.inner.length){let r=this.baseTree;return this.stoppedAt!=null&&(r=new xn(r.type,r.children,r.positions,r.length,r.propValues.concat([[sj,this.stoppedAt]]))),r}let t=this.inner[this.innerDone],n=t.parse.advance();if(n){this.innerDone++;let r=Object.assign(Object.create(null),t.target.props);r[en.mounted.id]=new Jy(n,t.overlay,t.parser),t.target.props=r}return null}get parsedPos(){if(this.baseParse)return 0;let t=this.input.length;for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].from<t&&(t=Math.min(t,this.inner[n].parse.parsedPos));return t}stopAt(t){if(this.stoppedAt=t,this.baseParse)this.baseParse.stopAt(t);else for(let n=this.innerDone;n<this.inner.length;n++)this.inner[n].parse.stopAt(t)}startInner(){let t=new Qut(this.fragments),n=null,r=null,i=new NS(new Qa(this.baseTree,this.ranges[0].from,0,null),ur.IncludeAnonymous|ur.IgnoreMounts);e:for(let a,s;;){let o=!0,l;if(this.stoppedAt!=null&&i.from>=this.stoppedAt)o=!1;else if(t.hasNode(i)){if(n){let c=n.mounts.find(u=>u.frag.from<=i.from&&u.frag.to>=i.to&&u.mount.overlay);if(c)for(let u of c.mount.overlay){let O=u.from+c.pos,f=u.to+c.pos;O>=i.from&&f<=i.to&&!n.ranges.some(p=>p.from<f&&p.to>O)&&n.ranges.push({from:O,to:f})}}o=!1}else if(r&&(s=Sut(r.ranges,i.from,i.to)))o=s!=2;else if(!i.type.isAnonymous&&(a=this.nest(i,this.input))&&(i.from<i.to||!a.overlay)){i.tree||kut(i);let c=t.findMounts(i.from,a.parser);if(typeof a.overlay=="function")n=new xut(a.parser,a.overlay,c,this.inner.length,i.from,i.tree,n);else{let u=HV(this.ranges,a.overlay||(i.from<i.to?[new po(i.from,i.to)]:[]));u.length&&VV(u),(u.length||!a.overlay)&&this.inner.push(new ZV(a.parser,u.length?a.parser.startParse(this.input,KV(c,u),u):a.parser.startParse(""),a.overlay?a.overlay.map(O=>new po(O.from-i.from,O.to-i.from)):null,i.tree,u.length?u[0].from:i.from)),a.overlay?u.length&&(r={ranges:u,depth:0,prev:r}):o=!1}}else if(n&&(l=n.predicate(i))&&(l===!0&&(l=new po(i.from,i.to)),l.from<l.to)){let c=n.ranges.length-1;c>=0&&n.ranges[c].to==l.from?n.ranges[c]={from:n.ranges[c].from,to:l.to}:n.ranges.push(l)}if(o&&i.firstChild())n&&n.depth++,r&&r.depth++;else for(;!i.nextSibling();){if(!i.parent())break e;if(n&&!--n.depth){let c=HV(this.ranges,n.ranges);c.length&&(VV(c),this.inner.splice(n.index,0,new ZV(n.parser,n.parser.startParse(this.input,KV(n.mounts,c),c),n.ranges.map(u=>new po(u.from-n.start,u.to-n.start)),n.target,c[0].from))),n=n.prev}r&&!--r.depth&&(r=r.prev)}}}}function Sut(e,t,n){for(let r of e){if(r.from>=n)break;if(r.to>t)return r.from<=t&&r.to>=n?2:1}return 0}function FV(e,t,n,r,i,a){if(t<n){let s=e.buffer[t+1];r.push(e.slice(t,n,s)),i.push(s-a)}}function kut(e){let{node:t}=e,n=[],r=t.context.buffer;do n.push(e.index),e.parent();while(!e.tree);let i=e.tree,a=i.children.indexOf(r),s=i.children[a],o=s.buffer,l=[a];function c(u,O,f,p,m,g){let y=n[g],b=[],v=[];FV(s,u,y,b,v,p);let x=o[y+1],S=o[y+2];l.push(b.length);let w=g?c(y+4,o[y+3],s.set.types[o[y]],x,S-x,g-1):t.toTree();return b.push(w),v.push(x-p),FV(s,o[y+3],O,b,v,p),new xn(f,b,v,m)}i.children[a]=c(0,o.length,xi.none,0,s.length,n.length-1);for(let u of l){let O=e.tree.children[u],f=e.tree.positions[u];e.yield(new Qa(O,f+e.from,u,e._tree))}}class BV{constructor(t,n){this.offset=n,this.done=!1,this.cursor=t.cursor(ur.IncludeAnonymous|ur.IgnoreMounts)}moveTo(t){let{cursor:n}=this,r=t-this.offset;for(;!this.done&&n.from<r;)n.to>=t&&n.enter(r,1,ur.IgnoreOverlays|ur.ExcludeBuffers)||n.next(!1)||(this.done=!0)}hasNode(t){if(this.moveTo(t.from),!this.done&&this.cursor.from+this.offset==t.from&&this.cursor.tree)for(let n=this.cursor.tree;;){if(n==t.tree)return!0;if(n.children.length&&n.positions[0]==0&&n.children[0]instanceof xn)n=n.children[0];else break}return!1}}let Qut=class{constructor(t){var n;if(this.fragments=t,this.curTo=0,this.fragI=0,t.length){let r=this.curFrag=t[0];this.curTo=(n=r.tree.prop(sj))!==null&&n!==void 0?n:r.to,this.inner=new BV(r.tree,-r.offset)}else this.curFrag=this.inner=null}hasNode(t){for(;this.curFrag&&t.from>=this.curTo;)this.nextFrag();return this.curFrag&&this.curFrag.from<=t.from&&this.curTo>=t.to&&this.inner.hasNode(t)}nextFrag(){var t;if(this.fragI++,this.fragI==this.fragments.length)this.curFrag=this.inner=null;else{let n=this.curFrag=this.fragments[this.fragI];this.curTo=(t=n.tree.prop(sj))!==null&&t!==void 0?t:n.to,this.inner=new BV(n.tree,-n.offset)}}findMounts(t,n){var r;let i=[];if(this.inner){this.inner.cursor.moveTo(t,1);for(let a=this.inner.cursor.node;a;a=a.parent){let s=(r=a.tree)===null||r===void 0?void 0:r.prop(en.mounted);if(s&&s.parser==n)for(let o=this.fragI;o<this.fragments.length;o++){let l=this.fragments[o];if(l.from>=a.to)break;l.tree==this.curFrag.tree&&i.push({frag:l,pos:a.from-l.offset,mount:s})}}}return i}};function HV(e,t){let n=null,r=t;for(let i=1,a=0;i<e.length;i++){let s=e[i-1].to,o=e[i].from;for(;a<r.length;a++){let l=r[a];if(l.from>=o)break;l.to<=s||(n||(r=n=t.slice()),l.from<s?(n[a]=new po(l.from,s),l.to>o&&n.splice(a+1,0,new po(o,l.to))):l.to>o?n[a--]=new po(o,l.to):n.splice(a--,1))}}return r}function Put(e,t,n,r){let i=0,a=0,s=!1,o=!1,l=-1e9,c=[];for(;;){let u=i==e.length?1e9:s?e[i].to:e[i].from,O=a==t.length?1e9:o?t[a].to:t[a].from;if(s!=o){let f=Math.max(l,n),p=Math.min(u,O,r);f<p&&c.push(new po(f,p))}if(l=Math.min(u,O),l==1e9)break;u==l&&(s?(s=!1,i++):s=!0),O==l&&(o?(o=!1,a++):o=!0)}return c}function KV(e,t){let n=[];for(let{pos:r,mount:i,frag:a}of e){let s=r+(i.overlay?i.overlay[0].from:0),o=s+i.tree.length,l=Math.max(a.from,s),c=Math.min(a.to,o);if(i.overlay){let u=i.overlay.map(f=>new po(f.from+r,f.to+r)),O=Put(t,u,l,c);for(let f=0,p=l;;f++){let m=f==O.length,g=m?c:O[f].from;if(g>p&&n.push(new hu(p,g,i.tree,-s,a.from>=p||a.openStart,a.to<=g||a.openEnd)),m)break;p=O[f].to}}else n.push(new hu(l,c,i.tree,-s,a.from>=s||a.openStart,a.to<=o||a.openEnd))}return n}let oj=[],tye=[];(()=>{let e="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(t=>t?parseInt(t,36):1);for(let t=0,n=0;t<e.length;t++)(t%2?tye:oj).push(n=n+e[t])})();function Tut(e){if(e<768)return!1;for(let t=0,n=oj.length;;){let r=t+n>>1;if(e<oj[r])n=r;else if(e>=tye[r])t=r+1;else return!0;if(t==n)return!1}}function JV(e){return e>=127462&&e<=127487}const eF=8205;function Eut(e,t,n=!0,r=!0){return(n?nye:Rut)(e,t,r)}function nye(e,t,n){if(t==e.length)return t;t&&rye(e.charCodeAt(t))&&iye(e.charCodeAt(t-1))&&t--;let r=VE(e,t);for(t+=tF(r);t<e.length;){let i=VE(e,t);if(r==eF||i==eF||n&&Tut(i))t+=tF(i),r=i;else if(JV(i)){let a=0,s=t-2;for(;s>=0&&JV(VE(e,s));)a++,s-=2;if(a%2==0)break;t+=2}else break}return t}function Rut(e,t,n){for(;t>0;){let r=nye(e,t-2,n);if(r<t)return r;t--}return 0}function VE(e,t){let n=e.charCodeAt(t);if(!iye(n)||t+1==e.length)return n;let r=e.charCodeAt(t+1);return rye(r)?(n-55296<<10)+(r-56320)+65536:n}function rye(e){return e>=56320&&e<57344}function iye(e){return e>=55296&&e<56320}function tF(e){return e<65536?1:2}let tr=class aye{lineAt(t){if(t<0||t>this.length)throw new RangeError(`Invalid position ${t} in document of length ${this.length}`);return this.lineInner(t,!1,1,0)}line(t){if(t<1||t>this.lines)throw new RangeError(`Invalid line number ${t} in ${this.lines}-line document`);return this.lineInner(t,!0,1,0)}replace(t,n,r){[t,n]=Pm(this,t,n);let i=[];return this.decompose(0,t,i,2),r.length&&r.decompose(0,r.length,i,3),this.decompose(n,this.length,i,1),Dl.from(i,this.length-(n-t)+r.length)}append(t){return this.replace(this.length,this.length,t)}slice(t,n=this.length){[t,n]=Pm(this,t,n);let r=[];return this.decompose(t,n,r,0),Dl.from(r,n-t)}eq(t){if(t==this)return!0;if(t.length!=this.length||t.lines!=this.lines)return!1;let n=this.scanIdentical(t,1),r=this.length-this.scanIdentical(t,-1),i=new ty(this),a=new ty(t);for(let s=n,o=n;;){if(i.next(s),a.next(s),s=0,i.lineBreak!=a.lineBreak||i.done!=a.done||i.value!=a.value)return!1;if(o+=i.value.length,i.done||o>=r)return!0}}iter(t=1){return new ty(this,t)}iterRange(t,n=this.length){return new sye(this,t,n)}iterLines(t,n){let r;if(t==null)r=this.iter();else{n==null&&(n=this.lines+1);let i=this.line(t).from;r=this.iterRange(i,Math.max(i,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new oye(r)}toString(){return this.sliceString(0)}toJSON(){let t=[];return this.flatten(t),t}constructor(){}static of(t){if(t.length==0)throw new RangeError("A document must have at least one line");return t.length==1&&!t[0]?aye.empty:t.length<=32?new si(t):Dl.from(si.split(t,[]))}};class si extends tr{constructor(t,n=Xut(t)){super(),this.text=t,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(t,n,r,i){for(let a=0;;a++){let s=this.text[a],o=i+s.length;if((n?r:o)>=t)return new Cut(i,o,r,s);i=o+1,r++}}decompose(t,n,r,i){let a=t<=0&&n>=this.length?this:new si(nF(this.text,t,n),Math.min(n,this.length)-Math.max(0,t));if(i&1){let s=r.pop(),o=l_(a.text,s.text.slice(),0,a.length);if(o.length<=32)r.push(new si(o,s.length+a.length));else{let l=o.length>>1;r.push(new si(o.slice(0,l)),new si(o.slice(l)))}}else r.push(a)}replace(t,n,r){if(!(r instanceof si))return super.replace(t,n,r);[t,n]=Pm(this,t,n);let i=l_(this.text,l_(r.text,nF(this.text,0,t)),n),a=this.length+r.length-(n-t);return i.length<=32?new si(i,a):Dl.from(si.split(i,[]),a)}sliceString(t,n=this.length,r=`
896
896
  `){[t,n]=Pm(this,t,n);let i="";for(let a=0,s=0;a<=n&&s<this.text.length;s++){let o=this.text[s],l=a+o.length;a>t&&s&&(i+=r),t<l&&n>a&&(i+=o.slice(Math.max(0,t-a),n-a)),a=l+1}return i}flatten(t){for(let n of this.text)t.push(n)}scanIdentical(){return 0}static split(t,n){let r=[],i=-1;for(let a of t)r.push(a),i+=a.length+1,r.length==32&&(n.push(new si(r,i)),r=[],i=-1);return i>-1&&n.push(new si(r,i)),n}}class Dl extends tr{constructor(t,n){super(),this.children=t,this.length=n,this.lines=0;for(let r of t)this.lines+=r.lines}lineInner(t,n,r,i){for(let a=0;;a++){let s=this.children[a],o=i+s.length,l=r+s.lines-1;if((n?l:o)>=t)return s.lineInner(t,n,r,i);i=o+1,r=l+1}}decompose(t,n,r,i){for(let a=0,s=0;s<=n&&a<this.children.length;a++){let o=this.children[a],l=s+o.length;if(t<=l&&n>=s){let c=i&((s<=t?1:0)|(l>=n?2:0));s>=t&&l<=n&&!c?r.push(o):o.decompose(t-s,n-s,r,c)}s=l+1}}replace(t,n,r){if([t,n]=Pm(this,t,n),r.lines<this.lines)for(let i=0,a=0;i<this.children.length;i++){let s=this.children[i],o=a+s.length;if(t>=a&&n<=o){let l=s.replace(t-a,n-a,r),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[i]=l,new Dl(u,this.length-(n-t)+r.length)}return super.replace(a,o,l)}a=o+1}return super.replace(t,n,r)}sliceString(t,n=this.length,r=`
@@ -904,7 +904,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
904
904
  `))};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=nt.single(this.toEditorPos(r.selectionStart),this.toEditorPos(r.selectionEnd));u.main.eq(i)||t.dispatch({selection:u,userEvent:"select"});return}if((bt.mac||bt.android)&&c.from==s-1&&/^\. ?$/.test(r.text)&&t.contentDOM.getAttribute("autocorrect")=="off"&&(c={from:o,to:l,insert:tr.of([r.text.replace("."," ")])}),this.pendingContextChange=c,!t.state.readOnly){let u=this.to-this.from+(c.to-c.from+c.insert.length);uI(t,c,nt.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 s=this.toEditorPos(r.rangeStart),o=this.toEditorPos(r.rangeEnd);s<o;s++){let l=t.coordsForChar(s);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 s=a.underlineStyle,o=a.underlineThickness;if(s!="None"&&o!="None"){let l=this.toEditorPos(a.rangeStart),c=this.toEditorPos(a.rangeEnd);if(l<c){let u=`text-decoration: underline ${s=="Dashed"?"dashed ":s=="Squiggle"?"wavy ":""}${o=="Thin"?1:2}px`;i.push(yn.mark({attributes:{style:u}}).range(l,c))}}}t.dispatch({effects:Bye.of(yn.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=ab(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,s,o,l,c)=>{if(r)return;let u=c.length-(s-a);if(i&&s>=i.to)if(i.from==a&&i.to==s&&i.insert.eq(c)){i=this.pendingContextChange=null,n+=u,this.to+=u;return}else i=null,this.revertPending(t.state);if(a+=n,s+=n,s<=this.from)this.from+=u,this.to+=u;else if(a<this.to){if(a<this.from||s>this.to||this.to-this.from+c.length>3e4){r=!0;return}this.editContext.updateText(this.toContextPos(a),this.toContextPos(s),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 jt{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||nOt(t.parent)||document,this.viewState=new jF(t.state||Vn.create(t)),t.scrollTo&&t.scrollTo.is($w)&&(this.viewState.scrollTarget=t.scrollTo.value.clip(this.viewState.state)),this.plugins=this.state.facet(Ap).map(i=>new KE(i));for(let i of this.plugins)i.update(this);this.observer=new bdt(this),this.inputState=new YOt(this),this.inputState.ensureHandlers(this.plugins),this.docView=new gF(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 sa?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 s=this.hasFocus,o=0,l=null;t.some(f=>f.annotation(cbe))?(this.inputState.notifiedFocused=s,o=1):s!=this.inputState.notifiedFocused&&(this.inputState.notifiedFocused=s,l=ube(a,s),l||(o=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(Vn.phrases)!=this.state.facet(Vn.phrases))return this.setState(a);i=DS.create(this,a,t),i.flags|=o;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 Hp(p.empty?p:nt.cursor(p.head,p.head>p.anchor?-1:1))}for(let p of f.effects)p.is($w)&&(O=p.value.clip(this.state))}this.viewState.update(i,O),this.bidiCache=GS.update(this.bidiCache,i.changes),i.empty||(this.updatePlugins(i),this.inputState.update(i)),n=this.docView.update(i),this.state.facet(b$)!=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(_w)!=i.state.facet(_w)&&(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(Rj))try{f(i)}catch(p){os(this.state,p,"update listener")}(l||u)&&Promise.resolve().then(()=>{l&&this.state==l.startState&&this.dispatch(l),u&&!rbe(this,u)&&c.force&&Bp(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 jF(t),this.plugins=t.facet(Ap).map(r=>new KE(r)),this.pluginMap.clear();for(let r of this.plugins)r.update(this);this.docView.destroy(),this.docView=new gF(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(Ap),r=t.state.facet(Ap);if(n!=r){let i=[];for(let a of r){let s=n.indexOf(a);if(s<0)i.push(new KE(a));else{let o=this.plugins[s];o.mustUpdate=t,i.push(o)}}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){os(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:s}=this.viewState;Math.abs(i-this.viewState.scrollTop)>1&&(s=-1),this.viewState.scrollAnchorHeight=-1;try{for(let o=0;;o++){if(s<0)if(_ye(r))a=-1,s=this.viewState.heightMap.height;else{let p=this.viewState.scrollAnchorAt(i);a=p.from,s=p.top}this.updateState=1;let l=this.viewState.measure(this);if(!l&&!this.measureRequests.length&&this.viewState.scrollTarget==null)break;if(o>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 os(this.state,m),IF}}),O=DS.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]!=IF)try{let m=c[p];m.write&&m.write(u[p],this)}catch(m){os(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,s=-1;continue}else{let m=(a<0?this.viewState.heightMap.height:this.viewState.lineBlockAt(a).top)-s;if(m>1||m<-1){i=i+m,r.scrollTop=i/this.scaleY,s=-1;continue}}break}}}finally{this.updateState=0,this.measureScheduled=-1}if(n&&!n.empty)for(let o of this.state.facet(Rj))o(n)}get themeClasses(){return jj+" "+(this.state.facet(qj)?hbe:fbe)+" "+this.state.facet(_w)}updateAttrs(){let t=WF(this,Hye,{class:"cm-editor"+(this.hasFocus?" cm-focused ":" ")+this.themeClasses}),n={spellcheck:"false",autocorrect:"off",autocapitalize:"off",writingsuggestions:"false",translate:"no",contenteditable:this.state.facet(Kc)?"true":"false",class:"cm-content",style:`${bt.tabSize}: ${this.state.tabSize}`,role:"textbox","aria-multiline":"true"};this.state.readOnly&&(n["aria-readonly"]="true"),WF(this,oI,n);let r=this.observer.ignore(()=>{let i=kj(this.contentDOM,this.contentAttrs,n),a=kj(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(jt.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(b$);let t=this.state.facet(jt.cspNonce);ad.mount(this.root,this.styleModules.concat($dt).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 eR(this,t,wF(this,t,n,r))}moveByGroup(t,n){return eR(this,t,wF(this,t,n,r=>AOt(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 nt.cursor(a.side(n,i)+t.from,a.forward(!n,i)?1:-1)}moveToLineBoundary(t,n,r=!0){return COt(this,t,n,r)}moveVertically(t,n,r){return eR(this,t,qOt(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(),nbe(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),s=a[qO.find(a,t-i.from,-1,n)];return G1(r,s.dir==Cr.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(Zye)||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>xdt)return Uye(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||zye(a.isolates,r=mF(this,t))))return a.order;r||(r=mF(this,t));let i=gOt(t.text,n,r);return this.bidiCache.push(new GS(t.from,t.to,n,r,!0,i)),i}get hasFocus(){var t;return(this.dom.ownerDocument.hasFocus()||bt.safari&&((t=this.inputState)===null||t===void 0?void 0:t.lastContextMenu)>Date.now()-3e4)&&this.root.activeElement==this.contentDOM}focus(){this.observer.ignore(()=>{wye(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 $w.of(new Hp(typeof t=="number"?nt.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 $w.of(new Hp(nt.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 Ci.define(()=>({}),{eventHandlers:t})}static domEventObservers(t){return Ci.define(()=>({}),{eventObservers:t})}static theme(t,n){let r=ad.newName(),i=[_w.of(r),b$.of(Nj(`.${r}`,t))];return n&&n.dark&&i.push(qj.of(!0)),i}static baseTheme(t){return $d.lowest(b$.of(Nj("."+jj,t,pbe)))}static findFromDOM(t){var n;let r=t.querySelector(".cm-content"),i=r&&Or.get(r)||Or.get(t);return((n=i?.rootView)===null||n===void 0?void 0:n.view)||null}}jt.styleModule=b$;jt.inputHandler=Lye;jt.clipboardInputFilter=aI;jt.clipboardOutputFilter=sI;jt.scrollHandler=Fye;jt.focusChangeEffect=Mye;jt.perLineTextDirection=Zye;jt.exceptionSink=Gye;jt.updateListener=Rj;jt.editable=Kc;jt.mouseSelectionStyle=Yye;jt.dragMovesSelection=Dye;jt.clickAddsSelectionRange=Wye;jt.decorations=sb;jt.outerDecorations=Kye;jt.atomicRanges=lI;jt.bidiIsolatedRanges=Jye;jt.scrollMargins=ebe;jt.darkTheme=qj;jt.cspNonce=_t.define({combine:e=>e.length?e[0]:""});jt.contentAttributes=oI;jt.editorAttributes=Hye;jt.lineWrapping=jt.contentAttributes.of({class:"cm-lineWrapping"});jt.announce=qn.define();const xdt=4096,IF={};class GS{constructor(t,n,r,i,a,s){this.from=t,this.to=n,this.dir=r,this.isolates=i,this.fresh=a,this.order=s}static update(t,n){if(n.empty&&!t.some(a=>a.fresh))return t;let r=[],i=t.length?t[t.length-1].dir:Cr.LTR;for(let a=Math.max(0,t.length-10);a<t.length;a++){let s=t[a];s.dir==i&&!n.touchesRange(s.from,s.to)&&r.push(new GS(n.mapPos(s.from,1),n.mapPos(s.to,-1),s.dir,s.isolates,!1,s.order))}return r}}function WF(e,t,n){for(let r=e.state.facet(t),i=r.length-1;i>=0;i--){let a=r[i],s=typeof a=="function"?a(e):a;s&&Sj(s,n)}return n}const _dt=bt.mac?"mac":bt.windows?"win":bt.linux?"linux":"key";function Sdt(e,t){const n=e.split(/-(?!$)/);let r=n[n.length-1];r=="Space"&&(r=" ");let i,a,s,o;for(let l=0;l<n.length-1;++l){const c=n[l];if(/^(cmd|meta|m)$/i.test(c))o=!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))s=!0;else if(/^mod$/i.test(c))t=="mac"?o=!0:a=!0;else throw new Error("Unrecognized modifier name: "+c)}return i&&(r="Alt-"+r),a&&(r="Ctrl-"+r),o&&(r="Meta-"+r),s&&(r="Shift-"+r),r}function Sw(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 kdt=$d.default(jt.domEventHandlers({keydown(e,t){return gbe(mbe(t.state),e,t,"editor")}})),FP=_t.define({enables:kdt}),DF=new WeakMap;function mbe(e){let t=e.facet(FP),n=DF.get(t);return n||DF.set(t,n=Pdt(t.reduce((r,i)=>r.concat(i),[]))),n}function _vn(e,t,n){return gbe(mbe(e.state),t,e,n)}let PO=null;const Qdt=4e3;function Pdt(e,t=_dt){let n=Object.create(null),r=Object.create(null),i=(s,o)=>{let l=r[s];if(l==null)r[s]=o;else if(l!=o)throw new Error("Key binding "+s+" is used both as a regular binding and as a multi-stroke prefix")},a=(s,o,l,c,u)=>{var O,f;let p=n[s]||(n[s]=Object.create(null)),m=o.split(/ (?!$)/).map(b=>Sdt(b,t));for(let b=1;b<m.length;b++){let v=m.slice(0,b).join(" ");i(v,!0),p[v]||(p[v]={preventDefault:!0,stopPropagation:!1,run:[x=>{let S=PO={view:x,prefix:v,scope:s};return setTimeout(()=>{PO==S&&(PO=null)},Qdt),!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 s of e){let o=s.scope?s.scope.split(" "):["editor"];if(s.any)for(let c of o){let u=n[c]||(n[c]=Object.create(null));u._any||(u._any={preventDefault:!1,stopPropagation:!1,run:[]});let{any:O}=s;for(let f in u)u[f].run.push(p=>O(p,zj))}let l=s[t]||s.key;if(l)for(let c of o)a(c,l,s.run,s.preventDefault,s.stopPropagation),s.shift&&a(c,"Shift-"+l,s.shift,s.preventDefault,s.stopPropagation)}return n}let zj=null;function gbe(e,t,n,r){zj=t;let i=Hut(t),a=Cs(i,0),s=Hc(a)==i.length&&i!=" ",o="",l=!1,c=!1,u=!1;PO&&PO.view==n&&PO.scope==r&&(o=PO.prefix+" ",abe.indexOf(t.keyCode)<0&&(c=!0,PO=null));let O=new Set,f=y=>{if(y){for(let b of y.run)if(!O.has(b)&&(O.add(b),b(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[o+Sw(i,t,!s)])?l=!0:s&&(t.altKey||t.metaKey||t.ctrlKey)&&!(bt.windows&&t.ctrlKey&&t.altKey)&&(m=sd[t.keyCode])&&m!=i?(f(p[o+Sw(m,t,!0)])||t.shiftKey&&(g=ib[t.keyCode])!=i&&g!=m&&f(p[o+Sw(g,t,!1)]))&&(l=!0):s&&t.shiftKey&&f(p[o+Sw(i,t,!0)])&&(l=!0),!l&&f(p._any)&&(l=!0)),c&&(l=!0),l&&u&&t.stopPropagation(),zj=null,l}class Z1{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=$be(t);return[new Z1(n,i.left-a.left,i.top-a.top,null,i.bottom-i.top)]}else return Tdt(t,n,r)}}function $be(e){let t=e.scrollDOM.getBoundingClientRect();return{left:(e.textDirection==Cr.LTR?t.left:t.right-e.scrollDOM.clientWidth*e.scaleX)-e.scrollDOM.scrollLeft*e.scaleX,top:t.top-e.scrollDOM.scrollTop*e.scaleY}}function YF(e,t,n,r){let i=e.coordsAtPos(t,n*2);if(!i)return r;let a=e.dom.getBoundingClientRect(),s=(i.top+i.bottom)/2,o=e.posAtCoords({x:a.left+1,y:s}),l=e.posAtCoords({x:a.right-1,y:s});return o==null||l==null?r:{from:Math.max(r.from,Math.min(o,l)),to:Math.min(r.to,Math.max(o,l))}}function Tdt(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==Cr.LTR,s=e.contentDOM,o=s.getBoundingClientRect(),l=$be(e),c=s.querySelector(".cm-line"),u=c&&window.getComputedStyle(c),O=o.left+(u?parseInt(u.paddingLeft)+Math.min(0,parseInt(u.textIndent)):0),f=o.right-(u?parseInt(u.paddingRight):0),p=Cj(e,r,1),m=Cj(e,i,-1),g=p.type==La.Text?p:null,y=m.type==La.Text?m:null;if(g&&(e.lineWrapping||p.widgetLineBreaks)&&(g=YF(e,r,1,g)),y&&(e.lineWrapping||m.widgetLineBreaks)&&(y=YF(e,i,-1,y)),g&&y&&g.from==y.from&&g.to==y.to)return v(x(n.from,n.to,g));{let w=g?x(n.from,null,g):S(p,!1),_=y?x(null,n.to,y):S(m,!0),k=[];return(g||p).to<(y||m).from-(g&&y?1:0)||p.widgetLineBreaks>1&&w.bottom+e.defaultLineHeight/2<_.top?k.push(b(O,w.bottom,f,_.top)):w.bottom<_.top&&e.elementAtHeight((w.bottom+_.top)/2).type==La.Text&&(w.bottom=_.top=(w.bottom+_.top)/2),v(w).concat(k).concat(v(_))}function b(w,_,k,Q){return new Z1(t,w-l.left,_-l.top,k-w,Q-_)}function v({top:w,bottom:_,horizontal:k}){let Q=[];for(let X=0;X<k.length;X+=2)Q.push(b(k[X],w,k[X+1],_));return Q}function x(w,_,k){let Q=1e9,X=-1e9,C=[];function T(Y,G,j,U,D){let Z=e.coordsAtPos(Y,Y==k.to?-2:2),N=e.coordsAtPos(j,j==k.from?2:-2);!Z||!N||(Q=Math.min(Z.top,N.top,Q),X=Math.max(Z.bottom,N.bottom,X),D==Cr.LTR?C.push(a&&G?O:Z.left,a&&U?f:N.right):C.push(!a&&U?O:N.left,!a&&G?f:Z.right))}let A=w??k.from,z=_??k.to;for(let Y of e.visibleRanges)if(Y.to>A&&Y.from<z)for(let G=Math.max(Y.from,A),j=Math.min(Y.to,z);;){let U=e.state.doc.lineAt(G);for(let D of e.bidiSpans(U)){let Z=D.from+U.from,N=D.to+U.from;if(Z>=j)break;N>G&&T(Math.max(Z,G),w==null&&Z<=A,Math.min(N,j),_==null&&N>=z,D.dir)}if(G=U.to+1,G>=j)break}return C.length==0&&T(A,w==null,z,_==null,e.textDirection),{top:Q,bottom:X,horizontal:C}}function S(w,_){let k=o.top+(_?w.top:w.bottom);return{top:k,bottom:k,horizontal:[]}}}function Edt(e,t){return e.constructor==t.constructor&&e.eq(t)}class Rdt{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(h_)!=t.state.facet(h_)&&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(h_);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)=>!Edt(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 h_=_t.define();function ybe(e){return[Ci.define(t=>new Rdt(t,e)),h_.of(e)]}const ob=_t.define({combine(e){return E0(e,{cursorBlinkRate:1200,drawRangeCursor:!0},{cursorBlinkRate:(t,n)=>Math.min(t,n),drawRangeCursor:(t,n)=>t||n})}});function Svn(e={}){return[ob.of(e),Xdt,Cdt,Adt,Vye.of(!0)]}function bbe(e){return e.startState.facet(ob)!=e.state.facet(ob)}const Xdt=ybe({above:!0,markers(e){let{state:t}=e,n=t.facet(ob),r=[];for(let i of t.selection.ranges){let a=i==t.selection.main;if(i.empty||n.drawRangeCursor){let s=a?"cm-cursor cm-cursor-primary":"cm-cursor cm-cursor-secondary",o=i.empty?i:nt.cursor(i.head,i.head>i.anchor?-1:1);for(let l of Z1.forRange(e,s,o))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=bbe(e);return n&&GF(e.state,t),e.docChanged||e.selectionSet||n},mount(e,t){GF(t.state,e)},class:"cm-cursorLayer"});function GF(e,t){t.style.animationDuration=e.facet(ob).cursorBlinkRate+"ms"}const Cdt=ybe({above:!1,markers(e){return e.state.selection.ranges.map(t=>t.empty?[]:Z1.forRange(e,"cm-selectionBackground",t)).reduce((t,n)=>t.concat(n))},update(e,t){return e.docChanged||e.selectionSet||e.viewportChanged||bbe(e)},class:"cm-selectionLayer"}),Adt=$d.highest(jt.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"}}}})),vbe=qn.define({map(e,t){return e==null?null:t.mapPos(e)}}),x$=ps.define({create(){return null},update(e,t){return e!=null&&(e=t.changes.mapPos(e)),t.effects.reduce((n,r)=>r.is(vbe)?r.value:n,e)}}),qdt=Ci.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(x$);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(x$)!=n||e.docChanged||e.geometryChanged)&&this.view.requestMeasure(this.measureReq))}readPos(){let{view:e}=this,t=e.state.field(x$),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(x$)!=e&&this.view.dispatch({effects:vbe.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 kvn(){return[x$,qdt]}function LF(e,t,n,r,i){t.lastIndex=0;for(let a=e.iterRange(n,r),s=n,o;!a.next().done;s+=a.value.length)if(!a.lineBreak)for(;o=t.exec(a.value);)i(s+o.index,o)}function jdt(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 Ndt{constructor(t){const{regexp:n,decoration:r,decorate:i,boundary:a,maxLength:s=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=(o,l,c,u)=>i(u,c,c+o[0].length,o,l);else if(typeof r=="function")this.addMatch=(o,l,c,u)=>{let O=r(o,l,c);O&&u(c,c+o[0].length,O)};else if(r)this.addMatch=(o,l,c,u)=>u(c,c+o[0].length,r);else throw new RangeError("Either 'decorate' or 'decoration' should be provided to MatchDecorator");this.boundary=a,this.maxLength=s}createDeco(t){let n=new Yf,r=n.add.bind(n);for(let{from:i,to:a}of jdt(t,this.maxLength))LF(t.state.doc,this.regexp,i,a,(s,o)=>this.addMatch(o,t,s,r));return n.finish()}updateDeco(t,n){let r=1e9,i=-1;return t.docChanged&&t.changes.iterChanges((a,s,o,l)=>{l>=t.view.viewport.from&&o<=t.view.viewport.to&&(r=Math.min(o,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 s=Math.max(a.from,r),o=Math.min(a.to,i);if(o>=s){let l=t.state.doc.lineAt(s),c=l.to<o?t.state.doc.lineAt(o):l,u=Math.max(a.from,l.from),O=Math.min(a.to,c.to);if(this.boundary){for(;s>l.from;s--)if(this.boundary.test(l.text[s-1-l.from])){u=s;break}for(;o<c.to;o++)if(this.boundary.test(c.text[o-c.from])){O=o;break}}let f=[],p,m=(g,y,b)=>f.push(b.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 LF(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 Uj=/x/.unicode!=null?"gu":"g",zdt=new RegExp(`[\0-\b
905
905
  --Ÿ­؜​‎‏\u2028\u2029‭‮⁦⁧⁩\uFEFF-]`,Uj),Udt={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 rR=null;function Idt(){var e;if(rR==null&&typeof document<"u"&&document.body){let t=document.body.style;rR=((e=t.tabSize)!==null&&e!==void 0?e:t.MozTabSize)!=null}return rR||!1}const p_=_t.define({combine(e){let t=E0(e,{render:null,specialChars:zdt,addSpecialChars:null});return(t.replaceTabs=!Idt())&&(t.specialChars=new RegExp(" |"+t.specialChars.source,Uj)),t.addSpecialChars&&(t.specialChars=new RegExp(t.specialChars.source+"|"+t.addSpecialChars.source,Uj)),t}});function Qvn(e={}){return[p_.of(e),Wdt()]}let MF=null;function Wdt(){return MF||(MF=Ci.fromClass(class{constructor(e){this.view=e,this.decorations=yn.none,this.decorationCache=Object.create(null),this.decorator=this.makeDecorator(e.state.facet(p_)),this.decorations=this.decorator.createDeco(e)}makeDecorator(e){return new Ndt({regexp:e.specialChars,decoration:(t,n,r)=>{let{doc:i}=n.state,a=Cs(t[0],0);if(a==9){let s=i.lineAt(r),o=n.state.tabSize,l=id(s.text,o,r-s.from);return yn.replace({widget:new Ldt((o-l%o)*this.view.defaultCharacterWidth/this.view.scaleX)})}return this.decorationCache[a]||(this.decorationCache[a]=yn.replace({widget:new Gdt(e,a)}))},boundary:e.replaceTabs?void 0:/[^]/})}update(e){let t=e.state.facet(p_);e.startState.facet(p_)!=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 Ddt="•";function Ydt(e){return e>=32?Ddt:e==10?"␤":String.fromCharCode(9216+e)}class Gdt extends Yu{constructor(t,n){super(),this.options=t,this.code=n}eq(t){return t.code==this.code}toDOM(t){let n=Ydt(this.code),r=t.state.phrase("Control character")+" "+(Udt[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 Ldt extends Yu{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 Pvn(){return Zdt}const Mdt=yn.line({class:"cm-activeLine"}),Zdt=Ci.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(Mdt.range(i.from)),t=i.from)}return yn.set(n)}},{decorations:e=>e.decorations});class Vdt extends Yu{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=G1(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 Tvn(e){let t=Ci.fromClass(class{constructor(n){this.view=n,this.placeholder=e?yn.set([yn.widget({widget:new Vdt(e),side:1}).range(0)]):yn.none}get decorations(){return this.view.state.doc.length?yn.none:this.placeholder}},{decorations:n=>n.decorations});return typeof e=="string"?[t,jt.contentAttributes.of({"aria-placeholder":e})]:t}const Ij=2e3;function Fdt(e,t,n){let r=Math.min(t.line,n.line),i=Math.max(t.line,n.line),a=[];if(t.off>Ij||n.off>Ij||t.col<0||n.col<0){let s=Math.min(t.off,n.off),o=Math.max(t.off,n.off);for(let l=r;l<=i;l++){let c=e.doc.line(l);c.length<=o&&a.push(nt.range(c.from+s,c.to+o))}}else{let s=Math.min(t.col,n.col),o=Math.max(t.col,n.col);for(let l=r;l<=i;l++){let c=e.doc.line(l),u=$j(c.text,s,e.tabSize,!0);if(u<0)a.push(nt.cursor(c.to));else{let O=$j(c.text,o,e.tabSize);a.push(nt.range(c.from+u,c.from+O))}}}return a}function Bdt(e,t){let n=e.coordsAtPos(e.viewport.from);return n?Math.round(Math.abs((n.left-t)/e.defaultCharacterWidth)):-1}function ZF(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>Ij?-1:i==r.length?Bdt(e,t.clientX):id(r.text,e.state.tabSize,n-r.from);return{line:r.number,col:a,off:i}}function Hdt(e,t){let n=ZF(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),s=i.state.doc.lineAt(a);n={line:s.number,col:n.col,off:Math.min(n.off,s.length)},r=r.map(i.changes)}},get(i,a,s){let o=ZF(e,i);if(!o)return r;let l=Fdt(e.state,n,o);return l.length?s?nt.create(l.concat(r.ranges)):nt.create(l):r}}:null}function Evn(e){let t=n=>n.altKey&&n.button==0;return jt.mouseSelectionStyle.of((n,r)=>t(r)?Hdt(n,r):null)}const Kdt={Alt:[18,e=>!!e.altKey],Control:[17,e=>!!e.ctrlKey],Shift:[16,e=>!!e.shiftKey],Meta:[91,e=>!!e.metaKey]},Jdt={style:"cursor: crosshair"};function Rvn(e={}){let[t,n]=Kdt[e.key||"Alt"],r=Ci.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,jt.contentAttributes.of(i=>{var a;return!((a=i.plugin(r))===null||a===void 0)&&a.isDown?Jdt:null})]}const Tg="-10000px";class wbe{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(s=>s);let a=null;this.tooltipViews=this.tooltips.map(s=>a=r(s,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 s=[],o=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)s[l]=this.createTooltipView(c,l?s[l-1]:null),o&&(o[l]=!!c.above);else{let O=s[l]=this.tooltipViews[u];o&&(o[l]=n[u]),O.update&&O.update(t)}}}for(let l of this.tooltipViews)s.indexOf(l)<0&&(this.removeTooltipView(l),(r=l.destroy)===null||r===void 0||r.call(l));return n&&(o.forEach((l,c)=>n[c]=l),n.length=o.length),this.input=i,this.tooltips=a,this.tooltipViews=s,!0}}function eft(e){let t=e.dom.ownerDocument.documentElement;return{top:0,left:0,bottom:t.clientHeight,right:t.clientWidth}}const iR=_t.define({combine:e=>{var t,n,r;return{position:bt.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)||eft}}}),VF=new WeakMap,fI=Ci.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(iR);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 wbe(e,hI,(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(iR);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=Tg,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(bt.gecko)n=a.offsetParent!=this.container.ownerDocument.body;else if(a.style.top==Tg&&a.style.left=="0px"){let s=a.getBoundingClientRect();n=Math.abs(s.top+1e4)>1||Math.abs(s.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=cI(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,s)=>{let o=this.manager.tooltipViews[s];return o.getCoords?o.getCoords(a.pos):this.view.coordsAtPos(a.pos)}),size:this.manager.tooltipViews.map(({dom:a})=>a.getBoundingClientRect()),space:this.view.state.facet(iR).tooltipSpace(this.view),scaleX:e,scaleY:t,makeAbsolute:n}}writeMeasure(e){var t;if(e.makeAbsolute){this.madeAbsolute=!0,this.position="absolute";for(let o of this.manager.tooltipViews)o.dom.style.position="absolute"}let{visible:n,space:r,scaleX:i,scaleY:a}=e,s=[];for(let o=0;o<this.manager.tooltips.length;o++){let l=this.manager.tooltips[o],c=this.manager.tooltipViews[o],{dom:u}=c,O=e.pos[o],f=e.size[o];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=Tg;continue}let p=l.arrow?c.dom.querySelector(".cm-tooltip-arrow"):null,m=p?7:0,g=f.right-f.left,y=(t=VF.get(c))!==null&&t!==void 0?t:f.bottom-f.top,b=c.offset||nft,v=this.view.textDirection==Cr.LTR,x=f.width>r.right-r.left?v?r.left:r.right-f.width:v?Math.max(r.left,Math.min(O.left-(p?14:0)+b.x,r.right-g)):Math.min(Math.max(r.left,O.left-g+(p?14:0)-b.x),r.right-g),S=this.above[o];!l.strictSide&&(S?O.top-y-m-b.y<r.top:O.bottom+y+m+b.y>r.bottom)&&S==r.bottom-O.bottom>O.top-r.top&&(S=this.above[o]=!S);let w=(S?O.top-r.top:r.bottom-O.bottom)-m;if(w<y&&c.resize!==!1){if(w<this.view.defaultLineHeight){u.style.top=Tg;continue}VF.set(c,y),u.style.height=(y=w)/a+"px"}else u.style.height&&(u.style.height="");let _=S?O.top-y-m-b.y:O.bottom+m+b.y,k=x+g;if(c.overlap!==!0)for(let Q of s)Q.left<k&&Q.right>x&&Q.top<_+y&&Q.bottom>_&&(_=S?Q.top-y-2-m:Q.bottom+m+2);if(this.position=="absolute"?(u.style.top=(_-e.parent.top)/a+"px",FF(u,(x-e.parent.left)/i)):(u.style.top=_/a+"px",FF(u,x/i)),p){let Q=O.left+(v?b.x:-b.x)-(x+14-7);p.style.left=Q/i+"px"}c.overlap!==!0&&s.push({left:x,top:_,right:k,bottom:_+y}),u.classList.toggle("cm-tooltip-above",S),u.classList.toggle("cm-tooltip-below",!S),c.positioned&&c.positioned(e.space)}}maybeMeasure(){if(this.manager.tooltips.length&&(this.view.inView&&this.view.requestMeasure(this.measureReq),this.inView!=this.view.inView&&(this.inView=this.view.inView,!this.inView)))for(let e of this.manager.tooltipViews)e.dom.style.top=Tg}},{eventObservers:{scroll(){this.maybeMeasure()}}});function FF(e,t){let n=parseInt(e.style.left,10);(isNaN(n)||Math.abs(t-n)>1)&&(e.style.left=t+"px")}const tft=jt.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"}}}),nft={x:0,y:0},hI=_t.define({enables:[fI,tft]}),LS=_t.define({combine:e=>e.reduce((t,n)=>t.concat(n),[])});class BP{static create(t){return new BP(t)}constructor(t){this.view=t,this.mounted=!1,this.dom=document.createElement("div"),this.dom.classList.add("cm-tooltip-hover"),this.manager=new wbe(t,LS,(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 rft=hI.compute([LS],e=>{let t=e.facet(LS);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:BP.create,above:t[0].above,arrow:t.some(n=>n.arrow)}});class ift{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 AO)i=r.posAtStart;else{if(i=t.posAtCoords(n),i==null)return;let o=t.coordsAtPos(i);if(!o||n.y<o.top||n.y>o.bottom||n.x<o.left-t.defaultCharacterWidth||n.x>o.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==Cr.RTL?-1:1;a=n.x<o.left?-c:c}let s=this.source(t,i,a);if(s?.then){let o=this.pending={pos:i};s.then(l=>{this.pending==o&&(this.pending=null,l&&!(Array.isArray(l)&&!l.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(l)?l:[l])}))},l=>os(t.state,l,"hover tooltip"))}else s&&!(Array.isArray(s)&&!s.length)&&t.dispatch({effects:this.setHover.of(Array.isArray(s)?s:[s])})}get tooltip(){let t=this.view.plugin(fI),n=t?t.manager.tooltips.findIndex(r=>r.create==BP.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&&!aft(a.dom,t)||this.pending){let{pos:s}=i[0]||this.pending,o=(r=(n=i[0])===null||n===void 0?void 0:n.end)!==null&&r!==void 0?r:s;(s==o?this.view.posAtCoords(this.lastMove)!=s:!sft(this.view,s,o,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 kw=4;function aft(e,t){let{left:n,right:r,top:i,bottom:a}=e.getBoundingClientRect(),s;if(s=e.querySelector(".cm-tooltip-arrow")){let o=s.getBoundingClientRect();i=Math.min(o.top,i),a=Math.max(o.bottom,a)}return t.clientX>=n-kw&&t.clientX<=r+kw&&t.clientY>=i-kw&&t.clientY<=a+kw}function sft(e,t,n,r,i,a){let s=e.scrollDOM.getBoundingClientRect(),o=e.documentTop+e.documentPadding.top+e.contentHeight;if(s.left>r||s.right<r||s.top>i||Math.min(s.bottom,o)<i)return!1;let l=e.posAtCoords({x:r,y:i},!1);return l>=t&&l<=n}function Xvn(e,t={}){let n=qn.define(),r=ps.define({create(){return[]},update(i,a){if(i.length&&(t.hideOnChange&&(a.docChanged||a.selection)?i=[]:t.hideOn&&(i=i.filter(s=>!t.hideOn(a,s))),a.docChanged)){let s=[];for(let o of i){let l=a.changes.mapPos(o.pos,-1,aa.TrackDel);if(l!=null){let c=Object.assign(Object.create(null),o);c.pos=l,c.end!=null&&(c.end=a.changes.mapPos(c.end)),s.push(c)}}i=s}for(let s of a.effects)s.is(n)&&(i=s.value),s.is(oft)&&(i=[]);return i},provide:i=>LS.from(i)});return{active:r,extension:[r,Ci.define(i=>new ift(i,e,r,n,t.hoverTime||300)),rft]}}function xbe(e,t){let n=e.plugin(fI);if(!n)return null;let r=n.manager.tooltips.indexOf(t);return r<0?null:n.manager.tooltipViews[r]}const oft=qn.define(),BF=_t.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 Cvn(e,t){let n=e.plugin(_be),r=n?n.specs.indexOf(t):-1;return r>-1?n.panels[r]:null}const _be=Ci.fromClass(class{constructor(e){this.input=e.state.facet(KF),this.specs=this.input.filter(n=>n),this.panels=this.specs.map(n=>n(e));let t=e.state.facet(BF);this.top=new Qw(e,!0,t.topContainer),this.bottom=new Qw(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(BF);this.top.container!=t.topContainer&&(this.top.sync([]),this.top=new Qw(e.view,!0,t.topContainer)),this.bottom.container!=t.bottomContainer&&(this.bottom.sync([]),this.bottom=new Qw(e.view,!1,t.bottomContainer)),this.top.syncClasses(),this.bottom.syncClasses();let n=e.state.facet(KF);if(n!=this.input){let r=n.filter(l=>l),i=[],a=[],s=[],o=[];for(let l of r){let c=this.specs.indexOf(l),u;c<0?(u=l(e.view),o.push(u)):(u=this.panels[c],u.update&&u.update(e)),i.push(u),(u.top?a:s).push(u)}this.specs=r,this.panels=i,this.top.sync(a),this.bottom.sync(s);for(let l of o)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=>jt.scrollMargins.of(t=>{let n=t.plugin(e);return n&&{top:n.top.scrollMargin(),bottom:n.bottom.scrollMargin()}})});class Qw{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=HF(t);t=t.nextSibling}else this.dom.insertBefore(n.dom,t);for(;t;)t=HF(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 HF(e){let t=e.nextSibling;return e.remove(),t}const KF=_t.define({enables:_be});class Qu extends Df{compare(t){return this==t||this.constructor==t.constructor&&this.eq(t)}eq(t){return!1}destroy(t){}}Qu.prototype.elementClass="";Qu.prototype.toDOM=void 0;Qu.prototype.mapMode=aa.TrackBefore;Qu.prototype.startSide=Qu.prototype.endSide=-1;Qu.prototype.point=!0;const m_=_t.define(),lft=_t.define(),cft={class:"",renderEmptyElements:!1,elementStyle:"",markers:()=>An.empty,lineMarker:()=>null,widgetMarker:()=>null,lineMarkerChange:null,initialSpacer:null,updateSpacer:null,domEventHandlers:{}},ay=_t.define();function uft(e){return[Sbe(),ay.of({...cft,...e})]}const JF=_t.define({combine:e=>e.some(t=>t)});function Sbe(e){return[Oft]}const Oft=Ci.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(ay).map(t=>new tB(e,t));for(let t of this.gutters)this.dom.appendChild(t.dom);this.fixed=!e.state.facet(JF),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(JF)!=!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=An.iter(this.view.state.facet(m_),this.view.viewport.from),r=[],i=this.gutters.map(a=>new dft(a,this.view.viewport,-this.view.documentPadding.top));for(let a of this.view.viewportLineBlocks)if(r.length&&(r=[]),Array.isArray(a.type)){let s=!0;for(let o of a.type)if(o.type==La.Text&&s){Wj(n,r,o.from);for(let l of i)l.line(this.view,o,r);s=!1}else if(o.widget)for(let l of i)l.widget(this.view,o)}else if(a.type==La.Text){Wj(n,r,a.from);for(let s of i)s.line(this.view,a,r)}else if(a.widget)for(let s of i)s.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(ay),n=e.state.facet(ay),r=e.docChanged||e.heightChanged||e.viewportChanged||!An.eq(e.startState.facet(m_),e.state.facet(m_),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 s=t.indexOf(a);s<0?i.push(new tB(this.view,a)):(this.gutters[s].update(e),i.push(this.gutters[s]))}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=>jt.scrollMargins.of(t=>{let n=t.plugin(e);return!n||n.gutters.length==0||!n.fixed?null:t.textDirection==Cr.LTR?{left:n.dom.offsetWidth*t.scaleX}:{right:n.dom.offsetWidth*t.scaleX}})});function eB(e){return Array.isArray(e)?e:[e]}function Wj(e,t,n){for(;e.value&&e.from<=n;)e.from==n&&t.push(e.value),e.next()}class dft{constructor(t,n,r){this.gutter=t,this.height=r,this.i=0,this.cursor=An.iter(t.markers,n.from)}addElement(t,n,r){let{gutter:i}=this,a=(n.top-this.height)/t.scaleY,s=n.height/t.scaleY;if(this.i==i.elements.length){let o=new kbe(t,s,a,r);i.elements.push(o),i.dom.appendChild(o.dom)}else i.elements[this.i].update(t,s,a,r);this.height=n.bottom,this.i++}line(t,n,r){let i=[];Wj(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 s=this.gutter;i.length==0&&!s.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(lft)){let s=a(t,n.widget,n);s&&(i||(i=[])).push(s)}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 tB{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,s;if(a!=this.dom&&this.dom.contains(a)){for(;a.parentNode!=this.dom;)a=a.parentNode;let l=a.getBoundingClientRect();s=(l.top+l.bottom)/2}else s=i.clientY;let o=t.lineBlockAtHeight(s-t.documentTop);n.domEventHandlers[r](t,o,i)&&i.preventDefault()});this.markers=eB(n.markers(t)),n.initialSpacer&&(this.spacer=new kbe(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=eB(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!An.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 kbe{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":""),fft(this.markers,i)||this.setMarkers(t,i)}setMarkers(t,n){let r="cm-gutterElement",i=this.dom.firstChild;for(let a=0,s=0;;){let o=s,l=a<n.length?n[a++]:null,c=!1;if(l){let u=l.elementClass;u&&(r+=" "+u);for(let O=s;O<this.markers.length;O++)if(this.markers[O].compare(l)){o=O,c=!0;break}}else o=this.markers.length;for(;s<o;){let u=this.markers[s++];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&&s++}this.dom.className=r,this.markers=n}destroy(){this.setMarkers(null,[])}}function fft(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 hft=_t.define(),pft=_t.define(),qp=_t.define({combine(e){return E0(e,{formatNumber:String,domEventHandlers:{}},{domEventHandlers(t,n){let r=Object.assign({},t);for(let i in n){let a=r[i],s=n[i];r[i]=a?(o,l,c)=>a(o,l,c)||s(o,l,c):s}return r}})}});class aR extends Qu{constructor(t){super(),this.number=t}eq(t){return this.number==t.number}toDOM(){return document.createTextNode(this.number)}}function sR(e,t){return e.state.facet(qp).formatNumber(t,e.state)}const mft=ay.compute([qp],e=>({class:"cm-lineNumbers",renderEmptyElements:!1,markers(t){return t.state.facet(hft)},lineMarker(t,n,r){return r.some(i=>i.toDOM)?null:new aR(sR(t,t.state.doc.lineAt(n.from).number))},widgetMarker:(t,n,r)=>{for(let i of t.state.facet(pft)){let a=i(t,n,r);if(a)return a}return null},lineMarkerChange:t=>t.startState.facet(qp)!=t.state.facet(qp),initialSpacer(t){return new aR(sR(t,nB(t.state.doc.lines)))},updateSpacer(t,n){let r=sR(n.view,nB(n.view.state.doc.lines));return r==t.number?t:new aR(r)},domEventHandlers:e.facet(qp).domEventHandlers}));function Avn(e={}){return[qp.of(e),Sbe(),mft]}function nB(e){let t=9;for(;t<e;)t=t*10+9;return t}const gft=new class extends Qu{constructor(){super(...arguments),this.elementClass="cm-activeLineGutter"}},$ft=m_.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(gft.range(i)))}return An.of(t)});function qvn(){return $ft}let yft=0;class ht{constructor(t,n,r,i){this.name=t,this.set=n,this.base=r,this.modified=i,this.id=yft++}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 ht&&(n=t),n?.base)throw new Error("Can not derive from a modified tag");let i=new ht(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 MS(t);return r=>r.modified.indexOf(n)>-1?r:MS.get(r.base||r,r.modified.concat(n).sort((i,a)=>i.id-a.id))}}let bft=0;class MS{constructor(t){this.name=t,this.instances=[],this.id=bft++}static get(t,n){if(!n.length)return t;let r=n[0].instances.find(o=>o.base==t&&vft(n,o.modified));if(r)return r;let i=[],a=new ht(t.name,i,t,n);for(let o of n)o.instances.push(a);let s=wft(n);for(let o of t.set)if(!o.modified.length)for(let l of s)i.push(MS.get(o,l));return a}}function vft(e,t){return e.length==t.length&&e.every((n,r)=>n==t[r])}function wft(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 Yn(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=[],s=2,o=i;for(let O=0;;){if(o=="..."&&O>0&&O+3==i.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(o);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=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+i);o=i.slice(O)}let l=a.length-1,c=a[l];if(!c)throw new RangeError("Invalid path: "+i);let u=new ZS(r,s,l>0?a.slice(0,l):null);t[c]=u.sort(t[c])}}return Qbe.add(t)}const Qbe=new en;let ZS=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}};ZS.empty=new ZS([],2,null);function Pbe(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 s of a.tag)n[s.id]=a.class;let{scope:r,all:i=null}=t||{};return{style:a=>{let s=i;for(let o of a)for(let l of o.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function xft(e,t){let n=null;for(let r of e){let i=r.style(t);i&&(n=n?n+" "+i:i)}return n}function _ft(e,t,n,r=0,i=e.length){let a=new Sft(r,Array.isArray(t)?t:[t],n);a.highlightRange(e.cursor(),r,i,"",a.highlighters),a.flush(i)}class Sft{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:s,from:o,to:l}=t;if(o>=r||l<=n)return;s.isTop&&(a=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=i,u=kft(t)||ZS.empty,O=xft(a,u.tags);if(O&&(c&&(c+=" "),c+=O,u.mode==1&&(i+=(i?" ":"")+O)),this.startSpan(Math.max(n,o),c),u.opaque)return;let f=t.tree&&t.tree.prop(en.mounted);if(f&&f.overlay){let p=t.node.enter(f.overlay[0].from+o,1),m=this.highlighters.filter(y=>!y.scope||y.scope(f.tree.type)),g=t.firstChild();for(let y=0,b=o;;y++){let v=y<f.overlay.length?f.overlay[y]:null,x=v?v.from+o:l,S=Math.max(n,b),w=Math.min(r,x);if(S<w&&g)for(;t.from<w&&(this.highlightRange(t,S,w,i,a),this.startSpan(Math.min(w,t.to),c),!(t.to>=x||!t.nextSibling())););if(!v||x>r)break;b=v.to+o,b>n&&(this.highlightRange(p.cursor(),Math.max(n,v.from+o),Math.min(r,b),"",m),this.startSpan(Math.min(r,b),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 kft(e){let t=e.type.prop(Qbe);for(;t&&t.context&&!e.matchContext(t.context);)t=t.next;return t||null}const ct=ht.define,Pw=ct(),bO=ct(),rB=ct(bO),iB=ct(bO),vO=ct(),Tw=ct(vO),oR=ct(vO),ql=ct(),Id=ct(ql),El=ct(),Rl=ct(),Dj=ct(),Eg=ct(Dj),Ew=ct(),P={comment:Pw,lineComment:ct(Pw),blockComment:ct(Pw),docComment:ct(Pw),name:bO,variableName:ct(bO),typeName:rB,tagName:ct(rB),propertyName:iB,attributeName:ct(iB),className:ct(bO),labelName:ct(bO),namespace:ct(bO),macroName:ct(bO),literal:vO,string:Tw,docString:ct(Tw),character:ct(Tw),attributeValue:ct(Tw),number:oR,integer:ct(oR),float:ct(oR),bool:ct(vO),regexp:ct(vO),escape:ct(vO),color:ct(vO),url:ct(vO),keyword:El,self:ct(El),null:ct(El),atom:ct(El),unit:ct(El),modifier:ct(El),operatorKeyword:ct(El),controlKeyword:ct(El),definitionKeyword:ct(El),moduleKeyword:ct(El),operator:Rl,derefOperator:ct(Rl),arithmeticOperator:ct(Rl),logicOperator:ct(Rl),bitwiseOperator:ct(Rl),compareOperator:ct(Rl),updateOperator:ct(Rl),definitionOperator:ct(Rl),typeOperator:ct(Rl),controlOperator:ct(Rl),punctuation:Dj,separator:ct(Dj),bracket:Eg,angleBracket:ct(Eg),squareBracket:ct(Eg),paren:ct(Eg),brace:ct(Eg),content:ql,heading:Id,heading1:ct(Id),heading2:ct(Id),heading3:ct(Id),heading4:ct(Id),heading5:ct(Id),heading6:ct(Id),contentSeparator:ct(ql),list:ct(ql),quote:ct(ql),emphasis:ct(ql),strong:ct(ql),link:ct(ql),monospace:ct(ql),strikethrough:ct(ql),inserted:ct(),deleted:ct(),changed:ct(),invalid:ct(),meta:Ew,documentMeta:ct(Ew),annotation:ct(Ew),processingInstruction:ct(Ew),definition:ht.defineModifier("definition"),constant:ht.defineModifier("constant"),function:ht.defineModifier("function"),standard:ht.defineModifier("standard"),local:ht.defineModifier("local"),special:ht.defineModifier("special")};for(let e in P){let t=P[e];t instanceof ht&&(t.name=e)}Pbe([{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 lR;const jO=new en;function HP(e){return _t.define({combine:e?t=>t.concat(e):void 0})}const pI=new en;class zs{constructor(t,n,r=[],i=""){this.data=t,this.name=i,Vn.prototype.hasOwnProperty("tree")||Object.defineProperty(Vn.prototype,"tree",{get(){return nr(this)}}),this.parser=n,this.extension=[ld.of(this),Vn.languageData.of((a,s,o)=>{let l=aB(a,s,o),c=l.type.prop(jO);if(!c)return[];let u=a.facet(c),O=l.type.prop(pI);if(O){let f=l.resolve(s-l.from,o);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 aB(t,n,r).type.prop(jO)==this.data}findRegions(t){let n=t.facet(ld);if(n?.data==this.data)return[{from:0,to:t.doc.length}];if(!n||!n.allowsNesting)return[];let r=[],i=(a,s)=>{if(a.prop(jO)==this.data){r.push({from:s,to:s+a.length});return}let o=a.prop(en.mounted);if(o){if(o.tree.prop(jO)==this.data){if(o.overlay)for(let l of o.overlay)r.push({from:l.from+s,to:l.to+s});else r.push({from:s,to:s+a.length});return}else if(o.overlay){let l=r.length;if(i(o.tree,o.overlay[0].from+s),r.length>l)return}}for(let l=0;l<a.children.length;l++){let c=a.children[l];c instanceof xn&&i(c,a.positions[l]+s)}};return i(nr(t),0),r}get allowsNesting(){return!0}}zs.setState=qn.define();function aB(e,t,n){let r=e.facet(ld),i=nr(e).topNode;if(!r||r.allowsNesting)for(let a=i;a;a=a.enter(t,n,ur.ExcludeBuffers))a.type.isTop&&(i=a);return i}class zn extends zs{constructor(t,n,r){super(t,n,[],r),this.parser=n}static define(t){let n=HP(t.languageData);return new zn(n,t.parser.configure({props:[jO.add(r=>r.isTop?n:void 0)]}),t.name)}configure(t,n){return new zn(this.data,this.parser.configure(t),n||this.name)}get allowsNesting(){return this.parser.hasWrappers()}}function nr(e){let t=e.field(zs.state,!1);return t?t.tree:xn.empty}class Qft{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 Rg=null;class Zf{constructor(t,n,r=[],i,a,s,o,l){this.parser=t,this.state=n,this.fragments=r,this.tree=i,this.treeLen=a,this.viewport=s,this.skipped=o,this.scheduleOn=l,this.parse=null,this.tempSkipped=[]}static create(t,n,r){return new Zf(t,n,[],xn.empty,0,r,[],null)}startParse(){return this.parser.startParse(new Qft(this.state.doc),this.fragments)}work(t,n){return n!=null&&n>=this.state.doc.length&&(n=void 0),this.tree!=xn.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(hu.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(hu.addTree(this.tree,this.fragments,!0)),this.parse=null)}withContext(t){let n=Rg;Rg=this;try{return t()}finally{Rg=n}}withoutTempSkipped(t){for(let n;n=this.tempSkipped.pop();)t=sB(t,n.from,n.to);return t}changes(t,n){let{fragments:r,tree:i,treeLen:a,viewport:s,skipped:o}=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=hu.applyChanges(r,l),i=xn.empty,a=0,s={from:t.mapPos(s.from,-1),to:t.mapPos(s.to,1)},this.skipped.length){o=[];for(let c of this.skipped){let u=t.mapPos(c.from,1),O=t.mapPos(c.to,-1);u<O&&o.push({from:u,to:O})}}}return new Zf(this.parser,n,r,i,a,s,o,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=sB(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 LP{createParse(n,r,i){let a=i[0].from,s=i[i.length-1].to;return{parsedPos:a,advance(){let l=Rg;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=s,new xn(xi.none,[],[],s-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 Rg}}function sB(e,t,n){return hu.applyChanges(e,[{fromA:t,toA:n,fromB:t,toB:n}])}class Cm{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 Cm(n)}static init(t){let n=Math.min(3e3,t.doc.length),r=Zf.create(t.facet(ld).parser,t,{from:0,to:n});return r.work(20,n)||r.takeTree(),new Cm(r)}}zs.state=ps.define({create:Cm.init,update(e,t){for(let n of t.effects)if(n.is(zs.setState))return n.value;return t.startState.facet(ld)!=t.state.facet(ld)?Cm.init(t.state):e.apply(t)}});let Tbe=e=>{let t=setTimeout(()=>e(),500);return()=>clearTimeout(t)};typeof requestIdleCallback<"u"&&(Tbe=e=>{let t=-1,n=setTimeout(()=>{t=requestIdleCallback(e,{timeout:400})},100);return()=>t<0?clearTimeout(n):cancelIdleCallback(t)});const cR=typeof navigator<"u"&&(!((lR=navigator.scheduling)===null||lR===void 0)&&lR.isInputPending)?()=>navigator.scheduling.isInputPending():null,Pft=Ci.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(zs.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(zs.state);(n.tree!=n.context.tree||!n.context.isDone(t.doc.length))&&(this.working=Tbe(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(zs.state);if(a.tree==a.context.tree&&a.context.isDone(i+1e5))return;let s=Date.now()+Math.min(this.chunkBudget,100,t&&!cR?Math.max(25,t.timeRemaining()-5):1e9),o=a.context.treeLen<i&&r.doc.length>i+1e3,l=a.context.work(()=>cR&&cR()||Date.now()>s,i+(o?0:1e5));this.chunkBudget-=Date.now()-n,(l||this.chunkBudget<=0)&&(a.context.takeTree(),this.view.dispatch({effects:zs.setState.of(new Cm(a.context))})),this.chunkBudget>0&&!(l&&!o)&&this.scheduleWork(),this.checkAsyncSchedule(a.context)}checkAsyncSchedule(t){t.scheduleOn&&(this.workScheduled++,t.scheduleOn.then(()=>this.scheduleWork()).catch(n=>os(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()}}}),ld=_t.define({combine(e){return e.length?e[0]:null},enables:e=>[zs.state,Pft,jt.contentAttributes.compute([e],t=>{let n=t.facet(e);return n&&n.name?{"data-language":n.name}:{}})]});class Tn{constructor(t,n=[]){this.language=t,this.support=n,this.extension=[t,n]}}class _e{constructor(t,n,r,i,a,s=void 0){this.name=t,this.alias=n,this.extensions=r,this.filename=i,this.loadFunc=a,this.support=s,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 _e(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 s=n.indexOf(a);if(s>-1&&(a.length>2||!/\w/.test(n[s-1])&&!/\w/.test(n[s+a.length])))return i}return null}}const Tft=_t.define(),KP=_t.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 VS(e){let t=e.facet(KP);return t.charCodeAt(0)==9?e.tabSize*t.length:t.length}function Eft(e,t){let n="",r=e.tabSize,i=e.facet(KP)[0];if(i==" "){for(;t>=r;)n+=" ",t-=r;i=" "}for(let a=0;a<t;a++)n+=i;return n}function Rft(e,t){e instanceof Vn&&(e=new Ebe(e));for(let r of e.state.facet(Tft)){let i=r(e,t);if(i!==void 0)return i}let n=nr(e.state);return n.length>=t?Xft(e,n,t):null}class Ebe{constructor(t,n={}){this.state=t,this.options=n,this.unit=VS(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),s=this.options.overrideIndentation?this.options.overrideIndentation(i):-1;return s>-1&&(a+=s-this.countColumn(r,r.search(/\S|$/))),a}countColumn(t,n=t.length){return id(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 s=a(i);if(s>-1)return s}return this.countColumn(r,r.search(/\S|$/))}get simulatedBreak(){return this.options.simulateBreak||null}}const Zr=new en;function Xft(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 s=i;s&&!(s.from<r.node.from||s.to>r.node.to||s.from==r.node.from&&s.type==r.node.type);s=s.parent)a.push(s);for(let s=a.length-1;s>=0;s--)r={node:a[s],next:r}}return Rbe(r,e,n)}function Rbe(e,t,n){for(let r=e;r;r=r.next){let i=Aft(r.node);if(i)return i(mI.create(t,n,r))}return 0}function Cft(e){return e.pos==e.options.simulateBreak&&e.options.simulateDoubleBreak}function Aft(e){let t=e.type.prop(Zr);if(t)return t;let n=e.firstChild,r;if(n&&(r=n.type.prop(en.closedBy))){let i=e.lastChild,a=i&&r.indexOf(i.name)>-1;return s=>Xbe(s,!0,1,void 0,a&&!Cft(s)?i.from:void 0)}return e.parent==null?qft:null}function qft(){return 0}class mI extends Ebe{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 mI(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(jft(r,t))break;n=this.state.doc.lineAt(r.from)}return this.lineIndent(n.from)}continue(){return Rbe(this.context.next,this.base,this.pos)}}function jft(e,t){for(let n=t;n;n=n.parent)if(e==n)return!0;return!1}function Nft(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),s=i==null||i<=a.from?a.to:Math.min(a.to,i);for(let o=n.to;;){let l=t.childAfter(o);if(!l||l==r)return null;if(!l.type.isSkipped){if(l.from>=s)return null;let c=/^ */.exec(a.text.slice(n.to-a.from))[0].length;return{from:n.from,to:n.to+c}}o=l.to}}function wo({closing:e,align:t=!0,units:n=1}){return r=>Xbe(r,t,n,e)}function Xbe(e,t,n,r,i){let a=e.textAfter,s=a.match(/^\s*/)[0].length,o=r&&a.slice(s,s+r.length)==r||i==e.pos+s,l=t?Nft(e):null;return l?o?e.column(l.from):e.column(l.to):e.baseIndent+(o?0:e.unit*n)}const gI=e=>e.baseIndent;function Jr({except:e,units:t=1}={}){return n=>{let r=e&&e.test(n.textAfter);return n.baseIndent+(r?0:t*n.unit)}}const zft=200;function zvn(){return Vn.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+zft)return e;let a=n.sliceString(i.from,r);if(!t.some(c=>c.test(a)))return e;let{state:s}=e,o=-1,l=[];for(let{head:c}of s.selection.ranges){let u=s.doc.lineAt(c);if(u.from==o)continue;o=u.from;let O=Rft(s,u.from);if(O==null)continue;let f=/^\s*/.exec(u.text)[0],p=Eft(s,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 Cbe=_t.define(),jr=new en;function Ta(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 Uft(e,t,n){let r=nr(e);if(r.length<n)return null;let i=r.resolveStack(n,1),a=null;for(let s=i;s;s=s.next){let o=s.node;if(o.to<=n||o.from>n)continue;if(a&&o.from<t)break;let l=o.type.prop(jr);if(l&&(o.to<r.length-50||r.length==e.doc.length||!Ift(o))){let c=l(o,e);c&&c.from<=n&&c.from>=t&&c.to>n&&(a=c)}}return a}function Ift(e){let t=e.lastChild;return t&&t.to==e.to&&t.type.isError}function FS(e,t,n){for(let r of e.facet(Cbe)){let i=r(e,t,n);if(i)return i}return Uft(e,t,n)}function Abe(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 JP=qn.define({map:Abe}),V1=qn.define({map:Abe});function qbe(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 Vf=ps.define({create(){return yn.none},update(e,t){e=e.map(t.changes);for(let n of t.effects)if(n.is(JP)&&!Wft(e,n.value.from,n.value.to)){let{preparePlaceholder:r}=t.state.facet(zbe),i=r?yn.replace({widget:new Zft(r(t.state,n.value))}):oB;e=e.update({add:[i.range(n.value.from,n.value.to)]})}else n.is(V1)&&(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=>jt.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(oB.range(r,i))}return yn.set(t,!0)}});function BS(e,t,n){var r;let i=null;return(r=e.field(Vf,!1))===null||r===void 0||r.between(t,n,(a,s)=>{(!i||i.from>a)&&(i={from:a,to:s})}),i}function Wft(e,t,n){let r=!1;return e.between(t,t,(i,a)=>{i==t&&a==n&&(r=!0)}),r}function jbe(e,t){return e.field(Vf,!1)?t:t.concat(qn.appendConfig.of(Ube()))}const Dft=e=>{for(let t of qbe(e)){let n=FS(e.state,t.from,t.to);if(n)return e.dispatch({effects:jbe(e.state,[JP.of(n),Nbe(e,n)])}),!0}return!1},Yft=e=>{if(!e.state.field(Vf,!1))return!1;let t=[];for(let n of qbe(e)){let r=BS(e.state,n.from,n.to);r&&t.push(V1.of(r),Nbe(e,r,!1))}return t.length&&e.dispatch({effects:t}),t.length>0};function Nbe(e,t,n=!0){let r=e.state.doc.lineAt(t.from).number,i=e.state.doc.lineAt(t.to).number;return jt.announce.of(`${e.state.phrase(n?"Folded lines":"Unfolded lines")} ${r} ${e.state.phrase("to")} ${i}.`)}const Gft=e=>{let{state:t}=e,n=[];for(let r=0;r<t.doc.length;){let i=e.lineBlockAt(r),a=FS(t,i.from,i.to);a&&n.push(JP.of(a)),r=(a?e.lineBlockAt(a.to):i).to+1}return n.length&&e.dispatch({effects:jbe(e.state,n)}),!!n.length},Lft=e=>{let t=e.state.field(Vf,!1);if(!t||!t.size)return!1;let n=[];return t.between(0,e.state.doc.length,(r,i)=>{n.push(V1.of({from:r,to:i}))}),e.dispatch({effects:n}),!0},Uvn=[{key:"Ctrl-Shift-[",mac:"Cmd-Alt-[",run:Dft},{key:"Ctrl-Shift-]",mac:"Cmd-Alt-]",run:Yft},{key:"Ctrl-Alt-[",run:Gft},{key:"Ctrl-Alt-]",run:Lft}],Mft={placeholderDOM:null,preparePlaceholder:null,placeholderText:"…"},zbe=_t.define({combine(e){return E0(e,Mft)}});function Ube(e){return[Vf,Fft]}function Ibe(e,t){let{state:n}=e,r=n.facet(zbe),i=s=>{let o=e.lineBlockAt(e.posAtDOM(s.target)),l=BS(e.state,o.from,o.to);l&&e.dispatch({effects:V1.of(l)}),s.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 oB=yn.replace({widget:new class extends Yu{toDOM(e){return Ibe(e,null)}}});class Zft extends Yu{constructor(t){super(),this.value=t}eq(t){return this.value==t.value}toDOM(t){return Ibe(t,this.value)}}const Vft={openText:"⌄",closedText:"›",markerDOM:null,domEventHandlers:{},foldingChanged:()=>!1};class uR extends Qu{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 Ivn(e={}){let t={...Vft,...e},n=new uR(t,!0),r=new uR(t,!1),i=Ci.fromClass(class{constructor(s){this.from=s.viewport.from,this.markers=this.buildMarkers(s)}update(s){(s.docChanged||s.viewportChanged||s.startState.facet(ld)!=s.state.facet(ld)||s.startState.field(Vf,!1)!=s.state.field(Vf,!1)||nr(s.startState)!=nr(s.state)||t.foldingChanged(s))&&(this.markers=this.buildMarkers(s.view))}buildMarkers(s){let o=new Yf;for(let l of s.viewportLineBlocks){let c=BS(s.state,l.from,l.to)?r:FS(s.state,l.from,l.to)?n:null;c&&o.add(l.from,l.from,c)}return o.finish()}}),{domEventHandlers:a}=t;return[i,uft({class:"cm-foldGutter",markers(s){var o;return((o=s.plugin(i))===null||o===void 0?void 0:o.markers)||An.empty},initialSpacer(){return new uR(t,!1)},domEventHandlers:{...a,click:(s,o,l)=>{if(a.click&&a.click(s,o,l))return!0;let c=BS(s.state,o.from,o.to);if(c)return s.dispatch({effects:V1.of(c)}),!0;let u=FS(s.state,o.from,o.to);return u?(s.dispatch({effects:JP.of(u)}),!0):!1}}}),Ube()]}const Fft=jt.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 eT{constructor(t,n){this.specs=t;let r;function i(o){let l=ad.newName();return(r||(r=Object.create(null)))["."+l]=o,l}const a=typeof n.all=="string"?n.all:n.all?i(n.all):void 0,s=n.scope;this.scope=s instanceof zs?o=>o.prop(jO)==s.data:s?o=>o==s:void 0,this.style=Pbe(t.map(o=>({tag:o.tag,class:o.class||i(Object.assign({},o,{tag:null}))})),{all:a}).style,this.module=r?new ad(r):null,this.themeType=n.themeType}static define(t,n){return new eT(t,n||{})}}const Yj=_t.define(),Wbe=_t.define({combine(e){return e.length?[e[0]]:null}});function OR(e){let t=e.facet(Yj);return t.length?t:e.facet(Wbe)}function Wvn(e,t){let n=[Hft],r;return e instanceof eT&&(e.module&&n.push(jt.styleModule.of(e.module)),r=e.themeType),t?.fallback?n.push(Wbe.of(e)):r?n.push(Yj.computeN([jt.darkTheme],i=>i.facet(jt.darkTheme)==(r=="dark")?[e]:[])):n.push(Yj.of(e)),n}class Bft{constructor(t){this.markCache=Object.create(null),this.tree=nr(t.state),this.decorations=this.buildDeco(t,OR(t.state)),this.decoratedTo=t.viewport.to}update(t){let n=nr(t.state),r=OR(t.state),i=r!=OR(t.startState),{viewport:a}=t.view,s=t.changes.mapPos(this.decoratedTo,1);n.length<a.to&&!i&&n.type==this.tree.type&&s>=a.to?(this.decorations=this.decorations.map(t.changes),this.decoratedTo=s):(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 yn.none;let r=new Yf;for(let{from:i,to:a}of t.visibleRanges)_ft(this.tree,n,(s,o,l)=>{r.add(s,o,this.markCache[l]||(this.markCache[l]=yn.mark({class:l})))},i,a);return r.finish()}}const Hft=$d.high(Ci.fromClass(Bft,{decorations:e=>e.decorations})),Dvn=eT.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"}]),Kft=jt.baseTheme({"&.cm-focused .cm-matchingBracket":{backgroundColor:"#328c8252"},"&.cm-focused .cm-nonmatchingBracket":{backgroundColor:"#bb555544"}}),Dbe=1e4,Ybe="()[]{}",Gbe=_t.define({combine(e){return E0(e,{afterCursor:!0,brackets:Ybe,maxScanDistance:Dbe,renderMatch:tht})}}),Jft=yn.mark({class:"cm-matchingBracket"}),eht=yn.mark({class:"cm-nonmatchingBracket"});function tht(e){let t=[],n=e.matched?Jft:eht;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 nht=ps.define({create(){return yn.none},update(e,t){if(!t.docChanged&&!t.selection)return e;let n=[],r=t.state.facet(Gbe);for(let i of t.state.selection.ranges){if(!i.empty)continue;let a=Rw(t.state,i.head,-1,r)||i.head>0&&Rw(t.state,i.head-1,1,r)||r.afterCursor&&(Rw(t.state,i.head,1,r)||i.head<t.state.doc.length&&Rw(t.state,i.head+1,-1,r));a&&(n=n.concat(r.renderMatch(a,t.state)))}return yn.set(n,!0)},provide:e=>jt.decorations.from(e)}),rht=[nht,Kft];function Yvn(e={}){return[Gbe.of(e),rht]}const $I=new en;function Gj(e,t,n){let r=e.prop(t<0?en.openedBy:en.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 Lj(e){let t=e.type.prop($I);return t?t(e.node):e}function Rw(e,t,n,r={}){let i=r.maxScanDistance||Dbe,a=r.brackets||Ybe,s=nr(e),o=s.resolveInner(t,n);for(let l=o;l;l=l.parent){let c=Gj(l.type,n,a);if(c&&l.from<l.to){let u=Lj(l);if(u&&(n>0?t>=u.from&&t<u.to:t>u.from&&t<=u.to))return iht(e,t,n,l,u,c,a)}}return aht(e,t,n,s,o.type,i,a)}function iht(e,t,n,r,i,a,s){let o=r.parent,l={from:i.from,to:i.to},c=0,u=o?.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=Lj(u);return{start:l,end:O?{from:O.from,to:O.to}:void 0,matched:!0}}else if(Gj(u.type,n,s))c++;else if(Gj(u.type,-n,s)){if(c==0){let O=Lj(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 aht(e,t,n,r,i,a,s){let o=n<0?e.sliceDoc(t-1,t):e.sliceDoc(t,t+1),l=s.indexOf(o);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 b=s.indexOf(p[g]);if(!(b<0||r.resolveInner(m+g,1).type!=i))if(b%2==0==n>0)O++;else{if(O==1)return{start:c,end:{from:m+g,to:m+g+1},matched:b>>1==l>>1};O--}}n>0&&(f+=p.length)}return u.done?{start:c,matched:!1}:null}function lB(e,t,n,r=0,i=0){t==null&&(t=e.search(/[^\s\u00a0]/),t==-1&&(t=e.length));let a=i;for(let s=r;s<t;s++)e.charCodeAt(s)==9?a+=n-a%n:a++;return a}class Lbe{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=lB(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:lB(this.string,null,this.tabSize)}match(t,n,r){if(typeof t=="string"){let i=s=>r?s.toLowerCase():s,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 sht(e){return{name:e.name||"",token:e.token,blankLine:e.blankLine||(()=>{}),startState:e.startState||(()=>!0),copyState:e.copyState||oht,indent:e.indent||(()=>null),languageData:e.languageData||{},tokenTable:e.tokenTable||bI,mergeTokens:e.mergeTokens!==!1}}function oht(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 cB=new WeakMap;class Fe extends zs{constructor(t){let n=HP(t.languageData),r=sht(t),i,a=new class extends LP{createParse(s,o,l){return new cht(i,s,o,l)}};super(n,a,[],t.name),this.topNode=dht(n,this),i=this,this.streamParser=r,this.stateAfter=new en({perNode:!0}),this.tokenTable=t.tokenTable?new Fbe(r.tokenTable):Oht}static define(t){return new Fe(t)}getIndent(t){let n,{overrideIndentation:r}=t.options;r&&(n=cB.get(t.state),n!=null&&n<t.pos-1e4&&(n=void 0));let i=yI(this,t.node.tree,t.node.from,t.node.from,n??t.pos),a,s;if(i?(s=i.state,a=i.pos+1):(s=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 Lbe(l.text,t.state.tabSize,t.unit,u<0?void 0:u);for(;O.pos<c-l.from;)Zbe(this.streamParser.token,O,s)}else this.streamParser.blankLine(s,t.unit);if(c==t.pos)break;a=l.to+1}let o=t.lineAt(t.pos);return r&&n==null&&cB.set(t.state,o.from),this.streamParser.indent(s,/^\s*(.*)/.exec(o.text)[1],t)}get allowsNesting(){return!1}}function yI(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 s=t.children.length-1;s>=0;s--){let o=t.children[s],l=n+t.positions[s],c=o instanceof xn&&l<i&&yI(e,o,l,r,i);if(c)return c}return null}function Mbe(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 s=t.positions[a],o=t.children[a],l;if(s<r&&o instanceof xn){if(!(l=Mbe(e,o,n-s,r-s,i)))break;return i?new xn(t.type,t.children.slice(0,a).concat(l),t.positions.slice(0,a+1),s+l.length):l}}return null}function lht(e,t,n,r,i){for(let a of t){let s=a.from+(a.openStart?25:0),o=a.to-(a.openEnd?25:0),l=s<=n&&o>n&&yI(e,a.tree,0-a.offset,n,o),c;if(l&&l.pos<=r&&(c=Mbe(e,a.tree,n+a.offset,l.pos+a.offset,!1)))return{state:l.state,tree:c}}return{state:e.streamParser.startState(i?VS(i):4),tree:xn.empty}}let cht=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=Zf.get(),s=i[0].from,{state:o,tree:l}=lht(t,r,s,this.to,a?.state);this.state=o,this.parsedPos=this.chunkStart=s+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(VS(a.state)),a.skipUntilInView(this.parsedPos,a.viewport.from),this.parsedPos=a.viewport.from),this.moveRangeIndex()}advance(){let t=Zf.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==`
906
906
  `&&(n="");else{let r=n.indexOf(`
907
- `);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 s=this.ranges[i].from,o=this.lineAfter(s);n+=o,r=s+o.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 s=this.ranges[++this.rangeIndex].from;n+=s-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 o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-o}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==n?this.chunk[s+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,s=new Lbe(n,t?t.state.tabSize:4,t?VS(t.state):2);if(s.eol())a.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let o=Zbe(a.token,s,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+s.start,this.parsedPos+s.pos,i)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=xn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:uht,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new xn(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 xn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Zbe(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 bI=Object.create(null),lb=[xi.none],uht=new T0(lb),uB=[],OB=Object.create(null),Vbe=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"]])Vbe[e]=Bbe(bI,t);class Fbe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Vbe)}resolve(t){return t?this.table[t]||(this.table[t]=Bbe(this.extra,t)):0}}const Oht=new Fbe(bI);function dR(e,t){uB.indexOf(e)>-1||(uB.push(e),console.warn(t))}function Bbe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):dR(c,`Modifier ${c} used at start of tag`):l.length?dR(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:dR(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(o=>o.id),a=OB[i];if(a)return a.id;let s=OB[i]=xi.define({id:lb.length,name:r,props:[Yn({[r]:n})]});return lb.push(s),s.id}function dht(e,t){let n=xi.define({id:lb.length,name:"Document",props:[jO.add(()=>e),Zr.add(()=>r=>t.getIndent(r))],top:!0});return lb.push(n),n}Cr.RTL,Cr.LTR;function De(e){return new Tn(Fe.define(e))}function sO(e){return Pe(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const fht=[_e.of({name:"C",extensions:["c","h","ino"],load(){return Pe(()=>Promise.resolve().then(()=>nK),void 0,import.meta.url).then(e=>e.cpp())}}),_e.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Pe(()=>Promise.resolve().then(()=>nK),void 0,import.meta.url).then(e=>e.cpp())}}),_e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return sO("Cassandra")}}),_e.of({name:"CSS",extensions:["css"],load(){return Pe(()=>Promise.resolve().then(()=>Hmt),void 0,import.meta.url).then(e=>e.css())}}),_e.of({name:"Go",extensions:["go"],load(){return Pe(()=>import("./index-C0H7kM3J.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),_e.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Pe(()=>Promise.resolve().then(()=>D0t),void 0,import.meta.url).then(e=>e.html())}}),_e.of({name:"Java",extensions:["java"],load(){return Pe(()=>Promise.resolve().then(()=>Ivt),void 0,import.meta.url).then(e=>e.java())}}),_e.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript())}}),_e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Pe(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>e.json())}}),_e.of({name:"JSX",extensions:["jsx"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),_e.of({name:"LESS",extensions:["less"],load(){return Pe(()=>Promise.resolve().then(()=>cgt),void 0,import.meta.url).then(e=>e.less())}}),_e.of({name:"Liquid",extensions:["liquid"],load(){return Pe(()=>Promise.resolve().then(()=>S_t),void 0,import.meta.url).then(e=>e.liquid())}}),_e.of({name:"MariaDB SQL",load(){return sO("MariaSQL")}}),_e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Pe(()=>Promise.resolve().then(()=>K0t),void 0,import.meta.url).then(e=>e.markdown())}}),_e.of({name:"MS SQL",load(){return sO("MSSQL")}}),_e.of({name:"MySQL",load(){return sO("MySQL")}}),_e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Pe(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>e.php())}}),_e.of({name:"PLSQL",extensions:["pls"],load(){return sO("PLSQL")}}),_e.of({name:"PostgreSQL",load(){return sO("PostgreSQL")}}),_e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Pe(()=>Promise.resolve().then(()=>S1t),void 0,import.meta.url).then(e=>e.python())}}),_e.of({name:"Rust",extensions:["rs"],load(){return Pe(()=>Promise.resolve().then(()=>swt),void 0,import.meta.url).then(e=>e.rust())}}),_e.of({name:"Sass",extensions:["sass"],load(){return Pe(()=>Promise.resolve().then(()=>gH),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),_e.of({name:"SCSS",extensions:["scss"],load(){return Pe(()=>Promise.resolve().then(()=>gH),void 0,import.meta.url).then(e=>e.sass())}}),_e.of({name:"SQL",extensions:["sql"],load(){return sO("StandardSQL")}}),_e.of({name:"SQLite",load(){return sO("SQLite")}}),_e.of({name:"TSX",extensions:["tsx"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),_e.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),_e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Pe(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>e.wast())}}),_e.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Pe(()=>Promise.resolve().then(()=>Z1t),void 0,import.meta.url).then(e=>e.xml())}}),_e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Pe(()=>import("./index-CQFKudfT.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),_e.of({name:"APL",extensions:["dyalog","apl"],load(){return Pe(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>De(e.apl))}}),_e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Pe(()=>Promise.resolve().then(()=>iQt),void 0,import.meta.url).then(e=>De(e.asciiArmor))}}),_e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Pe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>De(e.asn1({})))}}),_e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Pe(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>De(e.asterisk))}}),_e.of({name:"Brainfuck",extensions:["b","bf"],load(){return Pe(()=>Promise.resolve().then(()=>OQt),void 0,import.meta.url).then(e=>De(e.brainfuck))}}),_e.of({name:"Cobol",extensions:["cob","cpy"],load(){return Pe(()=>Promise.resolve().then(()=>UQt),void 0,import.meta.url).then(e=>De(e.cobol))}}),_e.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.csharp))}}),_e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"ClojureScript",extensions:["cljs"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Pe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>De(e.gss))}}),_e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Pe(()=>Promise.resolve().then(()=>EQt),void 0,import.meta.url).then(e=>De(e.cmake))}}),_e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Pe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>De(e.coffeeScript))}}),_e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Pe(()=>Promise.resolve().then(()=>iPt),void 0,import.meta.url).then(e=>De(e.commonLisp))}}),_e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Pe(()=>Promise.resolve().then(()=>wPt),void 0,import.meta.url).then(e=>De(e.cypher))}}),_e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Pe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>De(e.cython))}}),_e.of({name:"Crystal",extensions:["cr"],load(){return Pe(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>De(e.crystal))}}),_e.of({name:"D",extensions:["d"],load(){return Pe(()=>Promise.resolve().then(()=>TPt),void 0,import.meta.url).then(e=>De(e.d))}}),_e.of({name:"Dart",extensions:["dart"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.dart))}}),_e.of({name:"diff",extensions:["diff","patch"],load(){return Pe(()=>Promise.resolve().then(()=>EPt),void 0,import.meta.url).then(e=>De(e.diff))}}),_e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Pe(()=>Promise.resolve().then(()=>YPt),void 0,import.meta.url).then(e=>De(e.dockerFile))}}),_e.of({name:"DTD",extensions:["dtd"],load(){return Pe(()=>Promise.resolve().then(()=>MPt),void 0,import.meta.url).then(e=>De(e.dtd))}}),_e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Pe(()=>Promise.resolve().then(()=>HPt),void 0,import.meta.url).then(e=>De(e.dylan))}}),_e.of({name:"EBNF",load(){return Pe(()=>Promise.resolve().then(()=>KPt),void 0,import.meta.url).then(e=>De(e.ebnf))}}),_e.of({name:"ECL",extensions:["ecl"],load(){return Pe(()=>Promise.resolve().then(()=>sTt),void 0,import.meta.url).then(e=>De(e.ecl))}}),_e.of({name:"edn",extensions:["edn"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"Eiffel",extensions:["e"],load(){return Pe(()=>Promise.resolve().then(()=>dTt),void 0,import.meta.url).then(e=>De(e.eiffel))}}),_e.of({name:"Elm",extensions:["elm"],load(){return Pe(()=>Promise.resolve().then(()=>xTt),void 0,import.meta.url).then(e=>De(e.elm))}}),_e.of({name:"Erlang",extensions:["erl"],load(){return Pe(()=>Promise.resolve().then(()=>ZTt),void 0,import.meta.url).then(e=>De(e.erlang))}}),_e.of({name:"Esper",load(){return Pe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>De(e.esper))}}),_e.of({name:"Factor",extensions:["factor"],load(){return Pe(()=>Promise.resolve().then(()=>VTt),void 0,import.meta.url).then(e=>De(e.factor))}}),_e.of({name:"FCL",load(){return Pe(()=>Promise.resolve().then(()=>JTt),void 0,import.meta.url).then(e=>De(e.fcl))}}),_e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Pe(()=>Promise.resolve().then(()=>n2t),void 0,import.meta.url).then(e=>De(e.forth))}}),_e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Pe(()=>Promise.resolve().then(()=>c2t),void 0,import.meta.url).then(e=>De(e.fortran))}}),_e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.fSharp))}}),_e.of({name:"Gas",extensions:["s"],load(){return Pe(()=>Promise.resolve().then(()=>O2t),void 0,import.meta.url).then(e=>De(e.gas))}}),_e.of({name:"Gherkin",extensions:["feature"],load(){return Pe(()=>Promise.resolve().then(()=>d2t),void 0,import.meta.url).then(e=>De(e.gherkin))}}),_e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Pe(()=>Promise.resolve().then(()=>x2t),void 0,import.meta.url).then(e=>De(e.groovy))}}),_e.of({name:"Haskell",extensions:["hs"],load(){return Pe(()=>Promise.resolve().then(()=>E2t),void 0,import.meta.url).then(e=>De(e.haskell))}}),_e.of({name:"Haxe",extensions:["hx"],load(){return Pe(()=>Promise.resolve().then(()=>SJ),void 0,import.meta.url).then(e=>De(e.haxe))}}),_e.of({name:"HXML",extensions:["hxml"],load(){return Pe(()=>Promise.resolve().then(()=>SJ),void 0,import.meta.url).then(e=>De(e.hxml))}}),_e.of({name:"HTTP",load(){return Pe(()=>Promise.resolve().then(()=>J2t),void 0,import.meta.url).then(e=>De(e.http))}}),_e.of({name:"IDL",extensions:["pro"],load(){return Pe(()=>Promise.resolve().then(()=>s5t),void 0,import.meta.url).then(e=>De(e.idl))}}),_e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Pe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>De(e.jsonld))}}),_e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Pe(()=>Promise.resolve().then(()=>u5t),void 0,import.meta.url).then(e=>De(e.jinja2))}}),_e.of({name:"Julia",extensions:["jl"],load(){return Pe(()=>Promise.resolve().then(()=>q5t),void 0,import.meta.url).then(e=>De(e.julia))}}),_e.of({name:"Kotlin",extensions:["kt","kts"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.kotlin))}}),_e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Pe(()=>Promise.resolve().then(()=>U5t),void 0,import.meta.url).then(e=>De(e.liveScript))}}),_e.of({name:"Lua",extensions:["lua"],load(){return Pe(()=>Promise.resolve().then(()=>Z5t),void 0,import.meta.url).then(e=>De(e.lua))}}),_e.of({name:"mIRC",extensions:["mrc"],load(){return Pe(()=>Promise.resolve().then(()=>mEt),void 0,import.meta.url).then(e=>De(e.mirc))}}),_e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Pe(()=>Promise.resolve().then(()=>tEt),void 0,import.meta.url).then(e=>De(e.mathematica))}}),_e.of({name:"Modelica",extensions:["mo"],load(){return Pe(()=>Promise.resolve().then(()=>kEt),void 0,import.meta.url).then(e=>De(e.modelica))}}),_e.of({name:"MUMPS",extensions:["mps"],load(){return Pe(()=>Promise.resolve().then(()=>DEt),void 0,import.meta.url).then(e=>De(e.mumps))}}),_e.of({name:"Mbox",extensions:["mbox"],load(){return Pe(()=>Promise.resolve().then(()=>fEt),void 0,import.meta.url).then(e=>De(e.mbox))}}),_e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Pe(()=>Promise.resolve().then(()=>ZEt),void 0,import.meta.url).then(e=>De(e.nginx))}}),_e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Pe(()=>Promise.resolve().then(()=>VEt),void 0,import.meta.url).then(e=>De(e.nsis))}}),_e.of({name:"NTriples",extensions:["nt","nq"],load(){return Pe(()=>Promise.resolve().then(()=>FEt),void 0,import.meta.url).then(e=>De(e.ntriples))}}),_e.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.objectiveC))}}),_e.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.objectiveCpp))}}),_e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.oCaml))}}),_e.of({name:"Octave",extensions:["m"],load(){return Pe(()=>Promise.resolve().then(()=>sRt),void 0,import.meta.url).then(e=>De(e.octave))}}),_e.of({name:"Oz",extensions:["oz"],load(){return Pe(()=>Promise.resolve().then(()=>$Rt),void 0,import.meta.url).then(e=>De(e.oz))}}),_e.of({name:"Pascal",extensions:["p","pas"],load(){return Pe(()=>Promise.resolve().then(()=>_Rt),void 0,import.meta.url).then(e=>De(e.pascal))}}),_e.of({name:"Perl",extensions:["pl","pm"],load(){return Pe(()=>Promise.resolve().then(()=>SRt),void 0,import.meta.url).then(e=>De(e.perl))}}),_e.of({name:"Pig",extensions:["pig"],load(){return Pe(()=>Promise.resolve().then(()=>PRt),void 0,import.meta.url).then(e=>De(e.pig))}}),_e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Pe(()=>Promise.resolve().then(()=>GRt),void 0,import.meta.url).then(e=>De(e.powerShell))}}),_e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Pe(()=>Promise.resolve().then(()=>LRt),void 0,import.meta.url).then(e=>De(e.properties))}}),_e.of({name:"ProtoBuf",extensions:["proto"],load(){return Pe(()=>Promise.resolve().then(()=>BRt),void 0,import.meta.url).then(e=>De(e.protobuf))}}),_e.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Pe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>De(e.pug))}}),_e.of({name:"Puppet",extensions:["pp"],load(){return Pe(()=>Promise.resolve().then(()=>JRt),void 0,import.meta.url).then(e=>De(e.puppet))}}),_e.of({name:"Q",extensions:["q"],load(){return Pe(()=>Promise.resolve().then(()=>o4t),void 0,import.meta.url).then(e=>De(e.q))}}),_e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Pe(()=>Promise.resolve().then(()=>h4t),void 0,import.meta.url).then(e=>De(e.r))}}),_e.of({name:"RPM Changes",load(){return Pe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>De(e.rpmChanges))}}),_e.of({name:"RPM Spec",extensions:["spec"],load(){return Pe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>De(e.rpmSpec))}}),_e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Pe(()=>Promise.resolve().then(()=>x4t),void 0,import.meta.url).then(e=>De(e.ruby))}}),_e.of({name:"SAS",extensions:["sas"],load(){return Pe(()=>Promise.resolve().then(()=>Q4t),void 0,import.meta.url).then(e=>De(e.sas))}}),_e.of({name:"Scala",extensions:["scala"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.scala))}}),_e.of({name:"Scheme",extensions:["scm","ss"],load(){return Pe(()=>Promise.resolve().then(()=>I4t),void 0,import.meta.url).then(e=>De(e.scheme))}}),_e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Pe(()=>Promise.resolve().then(()=>G4t),void 0,import.meta.url).then(e=>De(e.shell))}}),_e.of({name:"Sieve",extensions:["siv","sieve"],load(){return Pe(()=>Promise.resolve().then(()=>F4t),void 0,import.meta.url).then(e=>De(e.sieve))}}),_e.of({name:"Smalltalk",extensions:["st"],load(){return Pe(()=>Promise.resolve().then(()=>K4t),void 0,import.meta.url).then(e=>De(e.smalltalk))}}),_e.of({name:"Solr",load(){return Pe(()=>Promise.resolve().then(()=>aXt),void 0,import.meta.url).then(e=>De(e.solr))}}),_e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.sml))}}),_e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Pe(()=>Promise.resolve().then(()=>dXt),void 0,import.meta.url).then(e=>De(e.sparql))}}),_e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Pe(()=>Promise.resolve().then(()=>fXt),void 0,import.meta.url).then(e=>De(e.spreadsheet))}}),_e.of({name:"Squirrel",extensions:["nut"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.squirrel))}}),_e.of({name:"Stylus",extensions:["styl"],load(){return Pe(()=>Promise.resolve().then(()=>qXt),void 0,import.meta.url).then(e=>De(e.stylus))}}),_e.of({name:"Swift",extensions:["swift"],load(){return Pe(()=>Promise.resolve().then(()=>t3t),void 0,import.meta.url).then(e=>De(e.swift))}}),_e.of({name:"sTeX",load(){return Pe(()=>Promise.resolve().then(()=>mee),void 0,import.meta.url).then(e=>De(e.stex))}}),_e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Pe(()=>Promise.resolve().then(()=>mee),void 0,import.meta.url).then(e=>De(e.stex))}}),_e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Pe(()=>Promise.resolve().then(()=>jee),void 0,import.meta.url).then(e=>De(e.verilog))}}),_e.of({name:"Tcl",extensions:["tcl"],load(){return Pe(()=>Promise.resolve().then(()=>a3t),void 0,import.meta.url).then(e=>De(e.tcl))}}),_e.of({name:"Textile",extensions:["textile"],load(){return Pe(()=>Promise.resolve().then(()=>c3t),void 0,import.meta.url).then(e=>De(e.textile))}}),_e.of({name:"TiddlyWiki",load(){return Pe(()=>Promise.resolve().then(()=>E3t),void 0,import.meta.url).then(e=>De(e.tiddlyWiki))}}),_e.of({name:"Tiki wiki",load(){return Pe(()=>Promise.resolve().then(()=>N3t),void 0,import.meta.url).then(e=>De(e.tiki))}}),_e.of({name:"TOML",extensions:["toml"],load(){return Pe(()=>Promise.resolve().then(()=>z3t),void 0,import.meta.url).then(e=>De(e.toml))}}),_e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Pe(()=>Promise.resolve().then(()=>W3t),void 0,import.meta.url).then(e=>De(e.troff))}}),_e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Pe(()=>Promise.resolve().then(()=>a6t),void 0,import.meta.url).then(e=>De(e.ttcn))}}),_e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Pe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>De(e.ttcnCfg))}}),_e.of({name:"Turtle",extensions:["ttl"],load(){return Pe(()=>Promise.resolve().then(()=>l6t),void 0,import.meta.url).then(e=>De(e.turtle))}}),_e.of({name:"Web IDL",extensions:["webidl"],load(){return Pe(()=>Promise.resolve().then(()=>tCt),void 0,import.meta.url).then(e=>De(e.webIDL))}}),_e.of({name:"VB.NET",extensions:["vb"],load(){return Pe(()=>Promise.resolve().then(()=>x6t),void 0,import.meta.url).then(e=>De(e.vb))}}),_e.of({name:"VBScript",extensions:["vbs"],load(){return Pe(()=>Promise.resolve().then(()=>S6t),void 0,import.meta.url).then(e=>De(e.vbScript))}}),_e.of({name:"Velocity",extensions:["vtl"],load(){return Pe(()=>Promise.resolve().then(()=>P6t),void 0,import.meta.url).then(e=>De(e.velocity))}}),_e.of({name:"Verilog",extensions:["v"],load(){return Pe(()=>Promise.resolve().then(()=>jee),void 0,import.meta.url).then(e=>De(e.verilog))}}),_e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Pe(()=>Promise.resolve().then(()=>N6t),void 0,import.meta.url).then(e=>De(e.vhdl))}}),_e.of({name:"XQuery",extensions:["xy","xquery"],load(){return Pe(()=>Promise.resolve().then(()=>OCt),void 0,import.meta.url).then(e=>De(e.xQuery))}}),_e.of({name:"Yacas",extensions:["ys"],load(){return Pe(()=>Promise.resolve().then(()=>vCt),void 0,import.meta.url).then(e=>De(e.yacas))}}),_e.of({name:"Z80",extensions:["z80"],load(){return Pe(()=>Promise.resolve().then(()=>kCt),void 0,import.meta.url).then(e=>De(e.z80))}}),_e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.mscgen))}}),_e.of({name:"Xù",extensions:["xu"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.xu))}}),_e.of({name:"MsGenny",extensions:["msgenny"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.msgenny))}}),_e.of({name:"Vue",extensions:["vue"],load(){return Pe(()=>Promise.resolve().then(()=>j_t),void 0,import.meta.url).then(e=>e.vue())}}),_e.of({name:"Angular Template",load(){return Pe(()=>Promise.resolve().then(()=>tSt),void 0,import.meta.url).then(e=>e.angular())}})];class vI{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=nr(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(Hbe(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 dB(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 hht(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=dB(t)+dB(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function F1(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:hht(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tT(e,t){return n=>{for(let r=nr(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 fB{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Qf(e){return e.selection.main.from}function Hbe(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 wI=ph.define();function pht(e,t,n,r){let{main:i}=e.selection,a=n-i.from,s=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+a,o.from+s)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+a,to:r==i.from?o.to:o.from+s,insert:l},range:nt.cursor(o.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const hB=new WeakMap;function mht(e){if(!Array.isArray(e))return e;let t=hB.get(e);return t||hB.set(e,t=F1(e)),t}const HS=qn.define(),cb=qn.define();class ght{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=Cs(t,n),i=Hc(r);this.chars.push(r);let a=t.slice(n,n+i),s=a.toUpperCase();this.folded.push(Cs(s==a?a.toLowerCase():s,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:s}=this;if(n.length==1){let v=Cs(t,0),x=Hc(v),S=x==t.length?0:-100;if(v!=n[0])if(v==r[0])S+=-200;else return null;return this.ret(S,[0,x])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let v=0,x=Math.min(t.length,200);v<x&&c<l;){let S=Cs(t,v);(S==n[c]||S==r[c])&&(i[c++]=v),v+=Hc(S)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),b=!0;for(let v=0,x=Math.min(t.length,200),S=0;v<x&&O<l;){let w=Cs(t,v);o<0&&(u<l&&w==n[u]&&(a[u++]=v),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=v),g=v+1,p++):p=0));let _,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(_=lye(w))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!v||k==1&&y||S==0&&k!=0)&&(n[O]==w||r[O]==w&&(f=!0)?s[O++]=v:s.length&&(b=!1)),S=k,v+=Hc(w)}return O==l&&s[0]==0&&b?this.result(-100+(f?-200:0),s,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(b?0:-1100),s,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 s of n){let o=s+(this.astral?Hc(Cs(r,s)):1);a&&i[a-1]==s?i[a-1]=o:(i[a++]=s,i[a++]=o)}return this.ret(t-r.length,i)}}class $ht{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 Zi=_t.define({combine(e){return E0(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:yht,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=>pB(t(r),n(r)),optionClass:(t,n)=>r=>pB(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function pB(e,t){return e?t?e+" "+t:e:t}function yht(e,t,n,r,i,a){let s=e.textDirection==Cr.RTL,o=s,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(o&&f<Math.min(m,p)?o=!1:!o&&p<Math.min(m,f)&&(o=!0),m<=(o?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,o?f:p);else{l=!0,O=Math.min(400,(s?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=g||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,b=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":o?"left":"right")}}function bht(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 s=document.createElement("span");s.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&s.appendChild(document.createTextNode(o.slice(l,u)));let f=s.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(u,O))),f.className="cm-completionMatchedText",l=O}return l<o.length&&s.appendChild(document.createTextNode(o.slice(l))),s},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 fR(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 vht{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:s}=i.open,o=t.state.facet(Zi);this.optionContent=bht(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fR(a.length,s,o.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(Zi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:cb.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:s,disabled:o}=r.open;(!i.open||i.open.options!=a)&&(this.range=fR(a.length,s,t.state.facet(Zi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}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=fR(n.options.length,n.selected,this.view.state.facet(Zi).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(s=>{s&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(s,r)}).catch(s=>os(this.view.state,s,"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&&xht(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 s=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:s.clientWidth,bottom:s.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(Zi).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",s=>{s.target==i&&s.preventDefault()});let a=null;for(let s=r.from;s<r.to;s++){let{completion:o,match:l}=t[s],{section:c}=o;if(c){let f=typeof c=="string"?c:c.name;if(f!=a&&(s>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+"-"+s,u.setAttribute("role","option");let O=this.optionClass(o);O&&(u.className=O);for(let f of this.optionContent){let p=f(o,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 wht(e,t){return n=>new vht(n,e,t)}function xht(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 mB(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function _ht(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(Zi);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 fB(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new $ht(O):new ght(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 fB(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 s=[],o=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;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?s.push(c):mB(c.completion)>mB(o)&&(s[s.length-1]=c),o=c.completion}return s}class jp{constructor(t,n,r,i,a,s){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=s}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new jp(this.options,gB(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,s){if(i&&!s&&t.some(c=>c.isPending))return i.setDisabled();let o=_ht(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Zi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new jp(o,gB(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Eht,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new jp(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 jp(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class KS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new KS(Pht,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Zi),a=(r.override||n.languageDataAt("autocomplete",Qf(n)).map(mht)).map(l=>(this.active.find(u=>u.source==l)||new go(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 s=this.open,o=t.effects.some(l=>l.is(xI));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Sht(a,this.active)||o?s=jp.build(a,n,this.id,s,r,o):s&&s.disabled&&!a.some(l=>l.isPending)&&(s=null),!s&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new go(l.source,0):l));for(let l of t.effects)l.is(Jbe)&&(s=s&&s.setSelected(l.value,this.id));return a==this.active&&s==this.open?this:new KS(a,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?kht:Qht}}function Sht(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 kht={"aria-autocomplete":"list"},Qht={};function gB(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Pht=[];function Kbe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(wI);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 go{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=Kbe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new go(i.source,0)),r&4&&i.state==0&&(i=new go(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(HS))i=new go(i.source,1,a.value);else if(a.is(cb))i=new go(i.source,0);else if(a.is(xI))for(let s of a.value)s.source==i.source&&(i=s);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Qf(t.state))}}class Kp extends go{constructor(t,n,r,i,a,s){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=s}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),s=t.changes.mapPos(this.to,1),o=Qf(t.state);if(o>s||!i||n&2&&(Qf(t.startState)==this.from||o<this.limit))return new go(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Tht(i.validFor,t.state,a,s)?new Kp(this.source,this.explicit,l,i,a,s):i.update&&(i=i.update(i,a,s,new vI(t.state,o,!1)))?new Kp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Qf(t.state)):new go(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Kp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new go(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Tht(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Hbe(e,!0).test(i)}const xI=qn.define({map(e,t){return e.map(n=>n.map(t))}}),Jbe=qn.define(),rs=ps.define({create(){return KS.start()},update(e,t){return e.update(t)},provide:e=>[hI.from(e,t=>t.tooltip),jt.contentAttributes.from(e,t=>t.attrs)]});function _I(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(rs).active.find(i=>i.source==t.source);return r instanceof Kp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},pht(e.state,n,r.from,r.to)),{annotations:wI.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Eht=wht(rs,_I);function Xw(e,t="option"){return n=>{let r=n.state.field(rs,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Zi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=xbe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:s-1;return o<0?o=t=="page"?0:s-1:o>=s&&(o=t=="page"?s-1:0),n.dispatch({effects:Jbe.of(o)}),!0}}const Rht=e=>{let t=e.state.field(rs,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Zi).interactionDelay?!1:_I(e,t.open.options[t.open.selected])},$B=e=>e.state.field(rs,!1)?(e.dispatch({effects:HS.of(!0)}),!0):!1,Xht=e=>{let t=e.state.field(rs,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:cb.of(null)}),!0)};class Cht{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Aht=50,qht=1e3,jht=Ci.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(rs).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(rs),n=e.state.facet(Zi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(rs)==t)return;let r=e.transactions.some(a=>{let s=Kbe(a,n);return s&8||(a.selection||a.docChanged)&&!(s&3)});for(let a=0;a<this.running.length;a++){let s=this.running[a];if(r||s.context.abortOnDocChange&&e.docChanged||s.updates.length+e.transactions.length>Aht&&Date.now()-s.time>qht){for(let o of s.context.abortListeners)try{o()}catch(l){os(this.view.state,l)}s.context.abortListeners=null,this.running.splice(a--,1)}else s.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(s=>s.is(HS)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(s=>s.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(rs);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(Zi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Qf(t),r=new vI(t,n,e.explicit,this.view),i=new Cht(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:cb.of(null)}),os(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(Zi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Zi),r=this.view.state.field(rs);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 o=Qf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(o,a.done.from+(a.active.explicit?0:1)),c=new Kp(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:o);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let s=r.active.find(o=>o.source==a.active.source);if(s&&s.isPending)if(a.done==null){let o=new go(a.active.source,0);for(let l of a.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:xI.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(rs,!1);if(t&&t.tooltip&&this.view.state.facet(Zi).closeOnBlur){let n=t.open&&xbe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:cb.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:HS.of(!1)}),20),this.composing=0}}}),Nht=typeof navigator=="object"&&/Win/.test(navigator.platform),zht=$d.highest(jt.domEventHandlers({keydown(e,t){let n=t.state.field(rs,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Nht&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(s=>s.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&_I(t,r),!1}})),e1e=jt.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 Uht{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class SI{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,aa.TrackDel),r=t.mapPos(this.to,1,aa.TrackDel);return n==null||r==null?null:new SI(this.field,n,r)}}class kI{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),s=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(KP);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new SI(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],a;for(let s of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let o=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++)(o!=null?n[O].seq==o:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(o==null||n[O].seq!=null&&n[O].seq<o);)O++;n.splice(O,0,{seq:o,name:u}),c=O;for(let f of i)f.field>=c&&f.field++}i.push(new Uht(c,r.length,a.index,a.index+u.length)),s=s.slice(0,a.index)+l+s.slice(a.index+a[0].length)}s=s.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(s)}return new kI(r,i)}}let Iht=yn.widget({widget:new class extends Yu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Wht=yn.mark({class:"cm-snippetField"});class R0{constructor(t,n){this.ranges=t,this.active=n,this.deco=yn.set(t.map(r=>(r.from==r.to?Iht:Wht).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 R0(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 B1=qn.define({map(e,t){return e&&e.map(t)}}),Dht=qn.define(),ub=ps.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(B1))return n.value;if(n.is(Dht)&&e)return new R0(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=>jt.decorations.from(e,t=>t?t.deco:yn.none)});function QI(e,t){return nt.create(e.filter(n=>n.field==t).map(n=>nt.range(n.from,n.to)))}function Yht(e){let t=kI.parse(e);return(n,r,i,a)=>{let{text:s,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:tr.of(s)},scrollIntoView:!0,annotations:r?[wI.of(r),sa.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=QI(o,0)),o.some(u=>u.field>0)){let u=new R0(o,0),O=c.effects=[B1.of(u)];n.state.field(ub,!1)===void 0&&O.push(qn.appendConfig.of([ub,Vht,Fht,e1e]))}n.dispatch(n.state.update(c))}}function t1e(e){return({state:t,dispatch:n})=>{let r=t.field(ub,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(s=>s.field==i+e);return n(t.update({selection:QI(r.ranges,i),effects:B1.of(a?null:new R0(r.ranges,i)),scrollIntoView:!0})),!0}}const Ght=({state:e,dispatch:t})=>e.field(ub,!1)?(t(e.update({effects:B1.of(null)})),!0):!1,Lht=t1e(1),Mht=t1e(-1),Zht=[{key:"Tab",run:Lht,shift:Mht},{key:"Escape",run:Ght}],yB=_t.define({combine(e){return e.length?e[0]:Zht}}),Vht=$d.highest(FP.compute([yB],e=>e.facet(yB)));function kr(e,t){return Object.assign(Object.assign({},t),{apply:Yht(e)})}const Fht=jt.domEventHandlers({mousedown(e,t){let n=t.state.field(ub,!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:QI(n.ranges,i.field),effects:B1.of(n.ranges.some(a=>a.field>i.field)?new R0(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Ob={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},df=qn.define({map(e,t){let n=t.mapPos(e,-1,aa.TrackAfter);return n??void 0}}),PI=new class extends Df{};PI.startSide=1;PI.endSide=-1;const n1e=ps.define({create(){return An.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(df)&&(e=e.update({add:[PI.range(n.value,n.value+1)]}));return e}});function Lvn(){return[Hht,n1e]}const hR="()[]{}<>«»»«[]{}";function r1e(e){for(let t=0;t<hR.length;t+=2)if(hR.charCodeAt(t)==e)return hR.charAt(t+1);return lye(e<128?e:e+1)}function i1e(e,t){return e.languageDataAt("closeBrackets",t)[0]||Ob}const Bht=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Hht=jt.inputHandler.of((e,t,n,r)=>{if((Bht?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Hc(Cs(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Jht(e.state,r);return a?(e.dispatch(a),!0):!1}),Kht=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=i1e(e,e.selection.main.head).brackets||Ob.brackets,i=null,a=e.changeByRange(s=>{if(s.empty){let o=ept(e.doc,s.head);for(let l of r)if(l==o&&nT(e.doc,s.head)==r1e(Cs(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:nt.cursor(s.head-l.length)}}return{range:i=s}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Mvn=[{key:"Backspace",run:Kht}];function Jht(e,t){let n=i1e(e,e.selection.main.head),r=n.brackets||Ob.brackets;for(let i of r){let a=r1e(Cs(i,0));if(t==i)return a==i?rpt(e,i,r.indexOf(i+i+i)>-1,n):tpt(e,i,a,n.before||Ob.before);if(t==a&&a1e(e,e.selection.main.from))return npt(e,i,a)}return null}function a1e(e,t){let n=!1;return e.field(n1e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nT(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Hc(Cs(n,0)))}function ept(e,t){let n=e.sliceString(t-2,t);return Hc(Cs(n,0))==n.length?n:n.slice(1)}function tpt(e,t,n,r){let i=null,a=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:df.of(s.to+t.length),range:nt.range(s.anchor+t.length,s.head+t.length)};let o=nT(e.doc,s.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:s.head},effects:df.of(s.head+t.length),range:nt.cursor(s.head+t.length)}:{range:i=s}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function npt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nT(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:nt.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function rpt(e,t,n,r){let i=r.stringPrefixes||Ob.stringPrefixes,a=null,s=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:df.of(o.to+t.length),range:nt.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=nT(e.doc,l),u;if(c==t){if(bB(e,l))return{changes:{insert:t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)};if(a1e(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:nt.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=vB(e,l-2*t.length,i))>-1&&bB(e,u))return{changes:{insert:t+t+t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=mo.Word&&vB(e,l,i)>-1&&!ipt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)}}return{range:a=o}});return a?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bB(e,t){let n=nr(e).resolveInner(t+1);return n.parent&&n.from==t}function ipt(e,t,n,r){let i=nr(e).resolveInner(t,-1),a=r.reduce((s,o)=>Math.max(s,o.length),0);for(let s=0;s<5;s++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.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 vB(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=mo.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))!=mo.Word)return a}return-1}function Zvn(e={}){return[zht,rs,Zi.of(e),jht,spt,e1e]}const apt=[{key:"Ctrl-Space",run:$B},{mac:"Alt-`",run:$B},{key:"Escape",run:Xht},{key:"ArrowDown",run:Xw(!0)},{key:"ArrowUp",run:Xw(!1)},{key:"PageDown",run:Xw(!0,"page")},{key:"PageUp",run:Xw(!1,"page")},{key:"Enter",run:Rht}],spt=$d.highest(FP.computeN([Zi],e=>e.facet(Zi).defaultKeymap?[apt]:[]));class JS{static create(t,n,r,i,a){let s=i+(i<<8)+t+(n<<4)|0;return new JS(t,n,r,s,a,[],[])}constructor(t,n,r,i,a,s,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=s,this.positions=o,this.hashProp=[[en.contextHash,i]]}addChild(t,n){t.prop(en.contextHash)!=this.hash&&(t=new xn(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 xn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,s)=>new xn(xi.none,i,a,s,this.hashProp)})}}var rt;(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"})(rt||(rt={}));class opt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let lpt=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 sy(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 wB(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==rt.OrderedList?RI:EI)(n,t,!1);return r>0&&(e.type!=rt.BulletList||TI(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const s1e={[rt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Qn(rt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Xo(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[rt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[rt.OrderedList]:wB,[rt.BulletList]:wB,[rt.Document](){return!0}};function Xo(e){return e==32||e==9||e==10||e==13}function sy(e,t=0){for(;t<e.length&&Xo(e.charCodeAt(t));)t++;return t}function xB(e,t,n){for(;t>n&&Xo(e.charCodeAt(t-1));)t--;return t}function o1e(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 l1e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function TI(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(!Xo(a))return-1}return n&&e.next==45&&O1e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(p1e.SetextHeading)>-1||r<3?-1:1}function c1e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function EI(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Xo(e.text.charCodeAt(e.pos+1)))&&(!n||c1e(t,rt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function RI(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&&!Xo(e.text.charCodeAt(r+1))||n&&!c1e(t,rt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function u1e(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 O1e(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&&Xo(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Mj=/^[ \t]*$/,d1e=/-->/,f1e=/\?>/,Zj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,d1e],[/^\s*<\?/,f1e],[/^\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,Mj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Mj]];function h1e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=Zj.length-(n?1:0);i<a;i++)if(Zj[i][0].test(r))return i;return-1}function _B(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 Wd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==rt.CodeText?e[r].to=n:e.push(Qn(rt.CodeText,t,n))}const Cw={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,s=[],o=[];for(Wd(s,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Wd(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==rt.CodeText?Wd(s,c.from,c.to):s.push(c);o=[]}Wd(s,e.lineStart-1,e.lineStart);for(let c of t.markers)s.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&Wd(s,l,a)}}return o.length&&(o=o.filter(l=>l.type!=rt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(s,-i).finish(rt.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=o1e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,s=t.skipSpace(n),o=xB(t.text,t.text.length,s),l=[Qn(rt.CodeMark,r,r+a)];s<o&&l.push(Qn(rt.CodeInfo,e.lineStart+s,e.lineStart+o));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(Qn(rt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||Wd(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&&Wd(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(rt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=l1e(t);return n<0?!1:(e.startContext(rt.Blockquote,t.pos),e.addNode(rt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(TI(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(rt.HorizontalRule,n),!0},BulletList(e,t){let n=EI(t,e,!1);if(n<0)return!1;e.block.type!=rt.BulletList&&e.startContext(rt.BulletList,t.basePos,t.next);let r=_B(t,t.pos+1);return e.startContext(rt.ListItem,t.basePos,r-t.baseIndent),e.addNode(rt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=RI(t,e,!1);if(n<0)return!1;e.block.type!=rt.OrderedList&&e.startContext(rt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=_B(t,t.pos+n);return e.startContext(rt.ListItem,t.basePos,r-t.baseIndent),e.addNode(rt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=u1e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=xB(t.text,t.text.length,r),s=a;for(;s>r&&t.text.charCodeAt(s-1)==t.next;)s--;(s==a||s==r||!Xo(t.text.charCodeAt(s-1)))&&(s=t.text.length);let o=e.buffer.write(rt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,s),i+n+1),-i);s<t.text.length&&o.write(rt.HeaderMark,s-r,a-r);let l=o.finish(rt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=h1e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Zj[n][1],a=[],s=i!=Mj;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){s=!1;break}for(let c of t.markers)a.push(c)}s&&e.nextLine();let o=i==d1e?rt.CommentBlock:i==f1e?rt.ProcessingInstructionBlock:rt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class cpt{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+`
907
+ `);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 s=this.ranges[i].from,o=this.lineAfter(s);n+=o,r=s+o.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 s=this.ranges[++this.rangeIndex].from;n+=s-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 o=this.chunk.length;i=this.skipGapsTo(r,i,-1),r+=i,a+=this.chunk.length-o}let s=this.chunk.length-4;return this.lang.streamParser.mergeTokens&&a==4&&s>=0&&this.chunk[s]==t&&this.chunk[s+2]==n?this.chunk[s+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,s=new Lbe(n,t?t.state.tabSize:4,t?VS(t.state):2);if(s.eol())a.blankLine(this.state,s.indentUnit);else for(;!s.eol();){let o=Zbe(a.token,s,this.state);if(o&&(i=this.emitToken(this.lang.tokenTable.resolve(o),this.parsedPos+s.start,this.parsedPos+s.pos,i)),s.start>1e4)break}this.parsedPos=r,this.moveRangeIndex(),this.parsedPos<this.to&&this.parsedPos++}finishChunk(){let t=xn.build({buffer:this.chunk,start:this.chunkStart,length:this.parsedPos-this.chunkStart,nodeSet:uht,topID:0,maxBufferLength:2048,reused:this.chunkReused});t=new xn(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 xn(this.lang.topNode,this.chunks,this.chunkPos,this.parsedPos-this.ranges[0].from).balance()}};function Zbe(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 bI=Object.create(null),lb=[xi.none],uht=new T0(lb),uB=[],OB=Object.create(null),Vbe=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"]])Vbe[e]=Bbe(bI,t);class Fbe{constructor(t){this.extra=t,this.table=Object.assign(Object.create(null),Vbe)}resolve(t){return t?this.table[t]||(this.table[t]=Bbe(this.extra,t)):0}}const Oht=new Fbe(bI);function dR(e,t){uB.indexOf(e)>-1||(uB.push(e),console.warn(t))}function Bbe(e,t){let n=[];for(let o of t.split(" ")){let l=[];for(let c of o.split(".")){let u=e[c]||P[c];u?typeof u=="function"?l.length?l=l.map(u):dR(c,`Modifier ${c} used at start of tag`):l.length?dR(c,`Tag ${c} used as modifier`):l=Array.isArray(u)?u:[u]:dR(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(o=>o.id),a=OB[i];if(a)return a.id;let s=OB[i]=xi.define({id:lb.length,name:r,props:[Yn({[r]:n})]});return lb.push(s),s.id}function dht(e,t){let n=xi.define({id:lb.length,name:"Document",props:[jO.add(()=>e),Zr.add(()=>r=>t.getIndent(r))],top:!0});return lb.push(n),n}Cr.RTL,Cr.LTR;function De(e){return new Tn(Fe.define(e))}function sO(e){return Pe(()=>Promise.resolve().then(()=>jvt),void 0,import.meta.url).then(t=>t.sql({dialect:t[e]}))}const fht=[_e.of({name:"C",extensions:["c","h","ino"],load(){return Pe(()=>Promise.resolve().then(()=>nK),void 0,import.meta.url).then(e=>e.cpp())}}),_e.of({name:"C++",alias:["cpp"],extensions:["cpp","c++","cc","cxx","hpp","h++","hh","hxx"],load(){return Pe(()=>Promise.resolve().then(()=>nK),void 0,import.meta.url).then(e=>e.cpp())}}),_e.of({name:"CQL",alias:["cassandra"],extensions:["cql"],load(){return sO("Cassandra")}}),_e.of({name:"CSS",extensions:["css"],load(){return Pe(()=>Promise.resolve().then(()=>Hmt),void 0,import.meta.url).then(e=>e.css())}}),_e.of({name:"Go",extensions:["go"],load(){return Pe(()=>import("./index-CQp2KnyE.js"),__vite__mapDeps([0,1,2,3,4,5,6]),import.meta.url).then(e=>e.go())}}),_e.of({name:"HTML",alias:["xhtml"],extensions:["html","htm","handlebars","hbs"],load(){return Pe(()=>Promise.resolve().then(()=>D0t),void 0,import.meta.url).then(e=>e.html())}}),_e.of({name:"Java",extensions:["java"],load(){return Pe(()=>Promise.resolve().then(()=>Ivt),void 0,import.meta.url).then(e=>e.java())}}),_e.of({name:"JavaScript",alias:["ecmascript","js","node"],extensions:["js","mjs","cjs"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript())}}),_e.of({name:"JSON",alias:["json5"],extensions:["json","map"],load(){return Pe(()=>Promise.resolve().then(()=>Zgt),void 0,import.meta.url).then(e=>e.json())}}),_e.of({name:"JSX",extensions:["jsx"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0}))}}),_e.of({name:"LESS",extensions:["less"],load(){return Pe(()=>Promise.resolve().then(()=>cgt),void 0,import.meta.url).then(e=>e.less())}}),_e.of({name:"Liquid",extensions:["liquid"],load(){return Pe(()=>Promise.resolve().then(()=>S_t),void 0,import.meta.url).then(e=>e.liquid())}}),_e.of({name:"MariaDB SQL",load(){return sO("MariaSQL")}}),_e.of({name:"Markdown",extensions:["md","markdown","mkd"],load(){return Pe(()=>Promise.resolve().then(()=>K0t),void 0,import.meta.url).then(e=>e.markdown())}}),_e.of({name:"MS SQL",load(){return sO("MSSQL")}}),_e.of({name:"MySQL",load(){return sO("MySQL")}}),_e.of({name:"PHP",extensions:["php","php3","php4","php5","php7","phtml"],load(){return Pe(()=>Promise.resolve().then(()=>n_t),void 0,import.meta.url).then(e=>e.php())}}),_e.of({name:"PLSQL",extensions:["pls"],load(){return sO("PLSQL")}}),_e.of({name:"PostgreSQL",load(){return sO("PostgreSQL")}}),_e.of({name:"Python",extensions:["BUILD","bzl","py","pyw"],filename:/^(BUCK|BUILD)$/,load(){return Pe(()=>Promise.resolve().then(()=>S1t),void 0,import.meta.url).then(e=>e.python())}}),_e.of({name:"Rust",extensions:["rs"],load(){return Pe(()=>Promise.resolve().then(()=>swt),void 0,import.meta.url).then(e=>e.rust())}}),_e.of({name:"Sass",extensions:["sass"],load(){return Pe(()=>Promise.resolve().then(()=>gH),void 0,import.meta.url).then(e=>e.sass({indented:!0}))}}),_e.of({name:"SCSS",extensions:["scss"],load(){return Pe(()=>Promise.resolve().then(()=>gH),void 0,import.meta.url).then(e=>e.sass())}}),_e.of({name:"SQL",extensions:["sql"],load(){return sO("StandardSQL")}}),_e.of({name:"SQLite",load(){return sO("SQLite")}}),_e.of({name:"TSX",extensions:["tsx"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({jsx:!0,typescript:!0}))}}),_e.of({name:"TypeScript",alias:["ts"],extensions:["ts","mts","cts"],load(){return Pe(()=>Promise.resolve().then(()=>qw),void 0,import.meta.url).then(e=>e.javascript({typescript:!0}))}}),_e.of({name:"WebAssembly",extensions:["wat","wast"],load(){return Pe(()=>Promise.resolve().then(()=>P_t),void 0,import.meta.url).then(e=>e.wast())}}),_e.of({name:"XML",alias:["rss","wsdl","xsd"],extensions:["xml","xsl","xsd","svg"],load(){return Pe(()=>Promise.resolve().then(()=>Z1t),void 0,import.meta.url).then(e=>e.xml())}}),_e.of({name:"YAML",alias:["yml"],extensions:["yaml","yml"],load(){return Pe(()=>import("./index-CpIFRblO.js"),__vite__mapDeps([7,1,2,3,4,5,6]),import.meta.url).then(e=>e.yaml())}}),_e.of({name:"APL",extensions:["dyalog","apl"],load(){return Pe(()=>Promise.resolve().then(()=>rQt),void 0,import.meta.url).then(e=>De(e.apl))}}),_e.of({name:"PGP",alias:["asciiarmor"],extensions:["asc","pgp","sig"],load(){return Pe(()=>Promise.resolve().then(()=>iQt),void 0,import.meta.url).then(e=>De(e.asciiArmor))}}),_e.of({name:"ASN.1",extensions:["asn","asn1"],load(){return Pe(()=>import("./asn1-EdZsLKOL.js"),[],import.meta.url).then(e=>De(e.asn1({})))}}),_e.of({name:"Asterisk",filename:/^extensions\.conf$/i,load(){return Pe(()=>Promise.resolve().then(()=>cQt),void 0,import.meta.url).then(e=>De(e.asterisk))}}),_e.of({name:"Brainfuck",extensions:["b","bf"],load(){return Pe(()=>Promise.resolve().then(()=>OQt),void 0,import.meta.url).then(e=>De(e.brainfuck))}}),_e.of({name:"Cobol",extensions:["cob","cpy"],load(){return Pe(()=>Promise.resolve().then(()=>UQt),void 0,import.meta.url).then(e=>De(e.cobol))}}),_e.of({name:"C#",alias:["csharp","cs"],extensions:["cs"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.csharp))}}),_e.of({name:"Clojure",extensions:["clj","cljc","cljx"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"ClojureScript",extensions:["cljs"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"Closure Stylesheets (GSS)",extensions:["gss"],load(){return Pe(()=>import("./css-BnMrqG3P.js"),[],import.meta.url).then(e=>De(e.gss))}}),_e.of({name:"CMake",extensions:["cmake","cmake.in"],filename:/^CMakeLists\.txt$/,load(){return Pe(()=>Promise.resolve().then(()=>EQt),void 0,import.meta.url).then(e=>De(e.cmake))}}),_e.of({name:"CoffeeScript",alias:["coffee","coffee-script"],extensions:["coffee"],load(){return Pe(()=>Promise.resolve().then(()=>KQt),void 0,import.meta.url).then(e=>De(e.coffeeScript))}}),_e.of({name:"Common Lisp",alias:["lisp"],extensions:["cl","lisp","el"],load(){return Pe(()=>Promise.resolve().then(()=>iPt),void 0,import.meta.url).then(e=>De(e.commonLisp))}}),_e.of({name:"Cypher",extensions:["cyp","cypher"],load(){return Pe(()=>Promise.resolve().then(()=>wPt),void 0,import.meta.url).then(e=>De(e.cypher))}}),_e.of({name:"Cython",extensions:["pyx","pxd","pxi"],load(){return Pe(()=>import("./python-BuPzkPfP.js"),[],import.meta.url).then(e=>De(e.cython))}}),_e.of({name:"Crystal",extensions:["cr"],load(){return Pe(()=>Promise.resolve().then(()=>mPt),void 0,import.meta.url).then(e=>De(e.crystal))}}),_e.of({name:"D",extensions:["d"],load(){return Pe(()=>Promise.resolve().then(()=>TPt),void 0,import.meta.url).then(e=>De(e.d))}}),_e.of({name:"Dart",extensions:["dart"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.dart))}}),_e.of({name:"diff",extensions:["diff","patch"],load(){return Pe(()=>Promise.resolve().then(()=>EPt),void 0,import.meta.url).then(e=>De(e.diff))}}),_e.of({name:"Dockerfile",filename:/^Dockerfile$/,load(){return Pe(()=>Promise.resolve().then(()=>YPt),void 0,import.meta.url).then(e=>De(e.dockerFile))}}),_e.of({name:"DTD",extensions:["dtd"],load(){return Pe(()=>Promise.resolve().then(()=>MPt),void 0,import.meta.url).then(e=>De(e.dtd))}}),_e.of({name:"Dylan",extensions:["dylan","dyl","intr"],load(){return Pe(()=>Promise.resolve().then(()=>HPt),void 0,import.meta.url).then(e=>De(e.dylan))}}),_e.of({name:"EBNF",load(){return Pe(()=>Promise.resolve().then(()=>KPt),void 0,import.meta.url).then(e=>De(e.ebnf))}}),_e.of({name:"ECL",extensions:["ecl"],load(){return Pe(()=>Promise.resolve().then(()=>sTt),void 0,import.meta.url).then(e=>De(e.ecl))}}),_e.of({name:"edn",extensions:["edn"],load(){return Pe(()=>import("./clojure-BMjYHr_A.js"),[],import.meta.url).then(e=>De(e.clojure))}}),_e.of({name:"Eiffel",extensions:["e"],load(){return Pe(()=>Promise.resolve().then(()=>dTt),void 0,import.meta.url).then(e=>De(e.eiffel))}}),_e.of({name:"Elm",extensions:["elm"],load(){return Pe(()=>Promise.resolve().then(()=>xTt),void 0,import.meta.url).then(e=>De(e.elm))}}),_e.of({name:"Erlang",extensions:["erl"],load(){return Pe(()=>Promise.resolve().then(()=>ZTt),void 0,import.meta.url).then(e=>De(e.erlang))}}),_e.of({name:"Esper",load(){return Pe(()=>import("./sql-D0XecflT.js"),[],import.meta.url).then(e=>De(e.esper))}}),_e.of({name:"Factor",extensions:["factor"],load(){return Pe(()=>Promise.resolve().then(()=>VTt),void 0,import.meta.url).then(e=>De(e.factor))}}),_e.of({name:"FCL",load(){return Pe(()=>Promise.resolve().then(()=>JTt),void 0,import.meta.url).then(e=>De(e.fcl))}}),_e.of({name:"Forth",extensions:["forth","fth","4th"],load(){return Pe(()=>Promise.resolve().then(()=>n2t),void 0,import.meta.url).then(e=>De(e.forth))}}),_e.of({name:"Fortran",extensions:["f","for","f77","f90","f95"],load(){return Pe(()=>Promise.resolve().then(()=>c2t),void 0,import.meta.url).then(e=>De(e.fortran))}}),_e.of({name:"F#",alias:["fsharp"],extensions:["fs"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.fSharp))}}),_e.of({name:"Gas",extensions:["s"],load(){return Pe(()=>Promise.resolve().then(()=>O2t),void 0,import.meta.url).then(e=>De(e.gas))}}),_e.of({name:"Gherkin",extensions:["feature"],load(){return Pe(()=>Promise.resolve().then(()=>d2t),void 0,import.meta.url).then(e=>De(e.gherkin))}}),_e.of({name:"Groovy",extensions:["groovy","gradle"],filename:/^Jenkinsfile$/,load(){return Pe(()=>Promise.resolve().then(()=>x2t),void 0,import.meta.url).then(e=>De(e.groovy))}}),_e.of({name:"Haskell",extensions:["hs"],load(){return Pe(()=>Promise.resolve().then(()=>E2t),void 0,import.meta.url).then(e=>De(e.haskell))}}),_e.of({name:"Haxe",extensions:["hx"],load(){return Pe(()=>Promise.resolve().then(()=>SJ),void 0,import.meta.url).then(e=>De(e.haxe))}}),_e.of({name:"HXML",extensions:["hxml"],load(){return Pe(()=>Promise.resolve().then(()=>SJ),void 0,import.meta.url).then(e=>De(e.hxml))}}),_e.of({name:"HTTP",load(){return Pe(()=>Promise.resolve().then(()=>J2t),void 0,import.meta.url).then(e=>De(e.http))}}),_e.of({name:"IDL",extensions:["pro"],load(){return Pe(()=>Promise.resolve().then(()=>s5t),void 0,import.meta.url).then(e=>De(e.idl))}}),_e.of({name:"JSON-LD",alias:["jsonld"],extensions:["jsonld"],load(){return Pe(()=>import("./javascript-qCveANmP.js"),[],import.meta.url).then(e=>De(e.jsonld))}}),_e.of({name:"Jinja2",extensions:["j2","jinja","jinja2"],load(){return Pe(()=>Promise.resolve().then(()=>u5t),void 0,import.meta.url).then(e=>De(e.jinja2))}}),_e.of({name:"Julia",extensions:["jl"],load(){return Pe(()=>Promise.resolve().then(()=>q5t),void 0,import.meta.url).then(e=>De(e.julia))}}),_e.of({name:"Kotlin",extensions:["kt","kts"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.kotlin))}}),_e.of({name:"LiveScript",alias:["ls"],extensions:["ls"],load(){return Pe(()=>Promise.resolve().then(()=>U5t),void 0,import.meta.url).then(e=>De(e.liveScript))}}),_e.of({name:"Lua",extensions:["lua"],load(){return Pe(()=>Promise.resolve().then(()=>Z5t),void 0,import.meta.url).then(e=>De(e.lua))}}),_e.of({name:"mIRC",extensions:["mrc"],load(){return Pe(()=>Promise.resolve().then(()=>mEt),void 0,import.meta.url).then(e=>De(e.mirc))}}),_e.of({name:"Mathematica",extensions:["m","nb","wl","wls"],load(){return Pe(()=>Promise.resolve().then(()=>tEt),void 0,import.meta.url).then(e=>De(e.mathematica))}}),_e.of({name:"Modelica",extensions:["mo"],load(){return Pe(()=>Promise.resolve().then(()=>kEt),void 0,import.meta.url).then(e=>De(e.modelica))}}),_e.of({name:"MUMPS",extensions:["mps"],load(){return Pe(()=>Promise.resolve().then(()=>DEt),void 0,import.meta.url).then(e=>De(e.mumps))}}),_e.of({name:"Mbox",extensions:["mbox"],load(){return Pe(()=>Promise.resolve().then(()=>fEt),void 0,import.meta.url).then(e=>De(e.mbox))}}),_e.of({name:"Nginx",filename:/nginx.*\.conf$/i,load(){return Pe(()=>Promise.resolve().then(()=>ZEt),void 0,import.meta.url).then(e=>De(e.nginx))}}),_e.of({name:"NSIS",extensions:["nsh","nsi"],load(){return Pe(()=>Promise.resolve().then(()=>VEt),void 0,import.meta.url).then(e=>De(e.nsis))}}),_e.of({name:"NTriples",extensions:["nt","nq"],load(){return Pe(()=>Promise.resolve().then(()=>FEt),void 0,import.meta.url).then(e=>De(e.ntriples))}}),_e.of({name:"Objective-C",alias:["objective-c","objc"],extensions:["m"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.objectiveC))}}),_e.of({name:"Objective-C++",alias:["objective-c++","objc++"],extensions:["mm"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.objectiveCpp))}}),_e.of({name:"OCaml",extensions:["ml","mli","mll","mly"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.oCaml))}}),_e.of({name:"Octave",extensions:["m"],load(){return Pe(()=>Promise.resolve().then(()=>sRt),void 0,import.meta.url).then(e=>De(e.octave))}}),_e.of({name:"Oz",extensions:["oz"],load(){return Pe(()=>Promise.resolve().then(()=>$Rt),void 0,import.meta.url).then(e=>De(e.oz))}}),_e.of({name:"Pascal",extensions:["p","pas"],load(){return Pe(()=>Promise.resolve().then(()=>_Rt),void 0,import.meta.url).then(e=>De(e.pascal))}}),_e.of({name:"Perl",extensions:["pl","pm"],load(){return Pe(()=>Promise.resolve().then(()=>SRt),void 0,import.meta.url).then(e=>De(e.perl))}}),_e.of({name:"Pig",extensions:["pig"],load(){return Pe(()=>Promise.resolve().then(()=>PRt),void 0,import.meta.url).then(e=>De(e.pig))}}),_e.of({name:"PowerShell",extensions:["ps1","psd1","psm1"],load(){return Pe(()=>Promise.resolve().then(()=>GRt),void 0,import.meta.url).then(e=>De(e.powerShell))}}),_e.of({name:"Properties files",alias:["ini","properties"],extensions:["properties","ini","in"],load(){return Pe(()=>Promise.resolve().then(()=>LRt),void 0,import.meta.url).then(e=>De(e.properties))}}),_e.of({name:"ProtoBuf",extensions:["proto"],load(){return Pe(()=>Promise.resolve().then(()=>BRt),void 0,import.meta.url).then(e=>De(e.protobuf))}}),_e.of({name:"Pug",alias:["jade"],extensions:["pug","jade"],load(){return Pe(()=>import("./pug-DukmZTjD.js"),__vite__mapDeps([8,9]),import.meta.url).then(e=>De(e.pug))}}),_e.of({name:"Puppet",extensions:["pp"],load(){return Pe(()=>Promise.resolve().then(()=>JRt),void 0,import.meta.url).then(e=>De(e.puppet))}}),_e.of({name:"Q",extensions:["q"],load(){return Pe(()=>Promise.resolve().then(()=>o4t),void 0,import.meta.url).then(e=>De(e.q))}}),_e.of({name:"R",alias:["rscript"],extensions:["r","R"],load(){return Pe(()=>Promise.resolve().then(()=>h4t),void 0,import.meta.url).then(e=>De(e.r))}}),_e.of({name:"RPM Changes",load(){return Pe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>De(e.rpmChanges))}}),_e.of({name:"RPM Spec",extensions:["spec"],load(){return Pe(()=>import("./rpm-CTu-6PCP.js"),[],import.meta.url).then(e=>De(e.rpmSpec))}}),_e.of({name:"Ruby",alias:["jruby","macruby","rake","rb","rbx"],extensions:["rb"],filename:/^(Gemfile|Rakefile)$/,load(){return Pe(()=>Promise.resolve().then(()=>x4t),void 0,import.meta.url).then(e=>De(e.ruby))}}),_e.of({name:"SAS",extensions:["sas"],load(){return Pe(()=>Promise.resolve().then(()=>Q4t),void 0,import.meta.url).then(e=>De(e.sas))}}),_e.of({name:"Scala",extensions:["scala"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.scala))}}),_e.of({name:"Scheme",extensions:["scm","ss"],load(){return Pe(()=>Promise.resolve().then(()=>I4t),void 0,import.meta.url).then(e=>De(e.scheme))}}),_e.of({name:"Shell",alias:["bash","sh","zsh"],extensions:["sh","ksh","bash"],filename:/^PKGBUILD$/,load(){return Pe(()=>Promise.resolve().then(()=>G4t),void 0,import.meta.url).then(e=>De(e.shell))}}),_e.of({name:"Sieve",extensions:["siv","sieve"],load(){return Pe(()=>Promise.resolve().then(()=>F4t),void 0,import.meta.url).then(e=>De(e.sieve))}}),_e.of({name:"Smalltalk",extensions:["st"],load(){return Pe(()=>Promise.resolve().then(()=>K4t),void 0,import.meta.url).then(e=>De(e.smalltalk))}}),_e.of({name:"Solr",load(){return Pe(()=>Promise.resolve().then(()=>aXt),void 0,import.meta.url).then(e=>De(e.solr))}}),_e.of({name:"SML",extensions:["sml","sig","fun","smackspec"],load(){return Pe(()=>import("./mllike-CXdrOF99.js"),[],import.meta.url).then(e=>De(e.sml))}}),_e.of({name:"SPARQL",alias:["sparul"],extensions:["rq","sparql"],load(){return Pe(()=>Promise.resolve().then(()=>dXt),void 0,import.meta.url).then(e=>De(e.sparql))}}),_e.of({name:"Spreadsheet",alias:["excel","formula"],load(){return Pe(()=>Promise.resolve().then(()=>fXt),void 0,import.meta.url).then(e=>De(e.spreadsheet))}}),_e.of({name:"Squirrel",extensions:["nut"],load(){return Pe(()=>Promise.resolve().then(()=>Gd),void 0,import.meta.url).then(e=>De(e.squirrel))}}),_e.of({name:"Stylus",extensions:["styl"],load(){return Pe(()=>Promise.resolve().then(()=>qXt),void 0,import.meta.url).then(e=>De(e.stylus))}}),_e.of({name:"Swift",extensions:["swift"],load(){return Pe(()=>Promise.resolve().then(()=>t3t),void 0,import.meta.url).then(e=>De(e.swift))}}),_e.of({name:"sTeX",load(){return Pe(()=>Promise.resolve().then(()=>mee),void 0,import.meta.url).then(e=>De(e.stex))}}),_e.of({name:"LaTeX",alias:["tex"],extensions:["text","ltx","tex"],load(){return Pe(()=>Promise.resolve().then(()=>mee),void 0,import.meta.url).then(e=>De(e.stex))}}),_e.of({name:"SystemVerilog",extensions:["v","sv","svh"],load(){return Pe(()=>Promise.resolve().then(()=>jee),void 0,import.meta.url).then(e=>De(e.verilog))}}),_e.of({name:"Tcl",extensions:["tcl"],load(){return Pe(()=>Promise.resolve().then(()=>a3t),void 0,import.meta.url).then(e=>De(e.tcl))}}),_e.of({name:"Textile",extensions:["textile"],load(){return Pe(()=>Promise.resolve().then(()=>c3t),void 0,import.meta.url).then(e=>De(e.textile))}}),_e.of({name:"TiddlyWiki",load(){return Pe(()=>Promise.resolve().then(()=>E3t),void 0,import.meta.url).then(e=>De(e.tiddlyWiki))}}),_e.of({name:"Tiki wiki",load(){return Pe(()=>Promise.resolve().then(()=>N3t),void 0,import.meta.url).then(e=>De(e.tiki))}}),_e.of({name:"TOML",extensions:["toml"],load(){return Pe(()=>Promise.resolve().then(()=>z3t),void 0,import.meta.url).then(e=>De(e.toml))}}),_e.of({name:"Troff",extensions:["1","2","3","4","5","6","7","8","9"],load(){return Pe(()=>Promise.resolve().then(()=>W3t),void 0,import.meta.url).then(e=>De(e.troff))}}),_e.of({name:"TTCN",extensions:["ttcn","ttcn3","ttcnpp"],load(){return Pe(()=>Promise.resolve().then(()=>a6t),void 0,import.meta.url).then(e=>De(e.ttcn))}}),_e.of({name:"TTCN_CFG",extensions:["cfg"],load(){return Pe(()=>import("./ttcn-cfg-B9xdYoR4.js"),[],import.meta.url).then(e=>De(e.ttcnCfg))}}),_e.of({name:"Turtle",extensions:["ttl"],load(){return Pe(()=>Promise.resolve().then(()=>l6t),void 0,import.meta.url).then(e=>De(e.turtle))}}),_e.of({name:"Web IDL",extensions:["webidl"],load(){return Pe(()=>Promise.resolve().then(()=>tCt),void 0,import.meta.url).then(e=>De(e.webIDL))}}),_e.of({name:"VB.NET",extensions:["vb"],load(){return Pe(()=>Promise.resolve().then(()=>x6t),void 0,import.meta.url).then(e=>De(e.vb))}}),_e.of({name:"VBScript",extensions:["vbs"],load(){return Pe(()=>Promise.resolve().then(()=>S6t),void 0,import.meta.url).then(e=>De(e.vbScript))}}),_e.of({name:"Velocity",extensions:["vtl"],load(){return Pe(()=>Promise.resolve().then(()=>P6t),void 0,import.meta.url).then(e=>De(e.velocity))}}),_e.of({name:"Verilog",extensions:["v"],load(){return Pe(()=>Promise.resolve().then(()=>jee),void 0,import.meta.url).then(e=>De(e.verilog))}}),_e.of({name:"VHDL",extensions:["vhd","vhdl"],load(){return Pe(()=>Promise.resolve().then(()=>N6t),void 0,import.meta.url).then(e=>De(e.vhdl))}}),_e.of({name:"XQuery",extensions:["xy","xquery"],load(){return Pe(()=>Promise.resolve().then(()=>OCt),void 0,import.meta.url).then(e=>De(e.xQuery))}}),_e.of({name:"Yacas",extensions:["ys"],load(){return Pe(()=>Promise.resolve().then(()=>vCt),void 0,import.meta.url).then(e=>De(e.yacas))}}),_e.of({name:"Z80",extensions:["z80"],load(){return Pe(()=>Promise.resolve().then(()=>kCt),void 0,import.meta.url).then(e=>De(e.z80))}}),_e.of({name:"MscGen",extensions:["mscgen","mscin","msc"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.mscgen))}}),_e.of({name:"Xù",extensions:["xu"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.xu))}}),_e.of({name:"MsGenny",extensions:["msgenny"],load(){return Pe(()=>Promise.resolve().then(()=>$4),void 0,import.meta.url).then(e=>De(e.msgenny))}}),_e.of({name:"Vue",extensions:["vue"],load(){return Pe(()=>Promise.resolve().then(()=>j_t),void 0,import.meta.url).then(e=>e.vue())}}),_e.of({name:"Angular Template",load(){return Pe(()=>Promise.resolve().then(()=>tSt),void 0,import.meta.url).then(e=>e.angular())}})];class vI{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=nr(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(Hbe(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 dB(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 hht(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=dB(t)+dB(n)+"*$";return[new RegExp("^"+r),new RegExp(r)]}function F1(e){let t=e.map(i=>typeof i=="string"?{label:i}:i),[n,r]=t.every(i=>/^\w+$/.test(i.label))?[/\w*$/,/\w+$/]:hht(t);return i=>{let a=i.matchBefore(r);return a||i.explicit?{from:a?a.from:i.pos,options:t,validFor:n}:null}}function tT(e,t){return n=>{for(let r=nr(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 fB{constructor(t,n,r,i){this.completion=t,this.source=n,this.match=r,this.score=i}}function Qf(e){return e.selection.main.from}function Hbe(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 wI=ph.define();function pht(e,t,n,r){let{main:i}=e.selection,a=n-i.from,s=r-i.from;return Object.assign(Object.assign({},e.changeByRange(o=>{if(o!=i&&n!=r&&e.sliceDoc(o.from+a,o.from+s)!=e.sliceDoc(n,r))return{range:o};let l=e.toText(t);return{changes:{from:o.from+a,to:r==i.from?o.to:o.from+s,insert:l},range:nt.cursor(o.from+a+l.length)}})),{scrollIntoView:!0,userEvent:"input.complete"})}const hB=new WeakMap;function mht(e){if(!Array.isArray(e))return e;let t=hB.get(e);return t||hB.set(e,t=F1(e)),t}const HS=qn.define(),cb=qn.define();class ght{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=Cs(t,n),i=Hc(r);this.chars.push(r);let a=t.slice(n,n+i),s=a.toUpperCase();this.folded.push(Cs(s==a?a.toLowerCase():s,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:s}=this;if(n.length==1){let v=Cs(t,0),x=Hc(v),S=x==t.length?0:-100;if(v!=n[0])if(v==r[0])S+=-200;else return null;return this.ret(S,[0,x])}let o=t.indexOf(this.pattern);if(o==0)return this.ret(t.length==this.pattern.length?0:-100,[0,this.pattern.length]);let l=n.length,c=0;if(o<0){for(let v=0,x=Math.min(t.length,200);v<x&&c<l;){let S=Cs(t,v);(S==n[c]||S==r[c])&&(i[c++]=v),v+=Hc(S)}if(c<l)return null}let u=0,O=0,f=!1,p=0,m=-1,g=-1,y=/[a-z]/.test(t),b=!0;for(let v=0,x=Math.min(t.length,200),S=0;v<x&&O<l;){let w=Cs(t,v);o<0&&(u<l&&w==n[u]&&(a[u++]=v),p<l&&(w==n[p]||w==r[p]?(p==0&&(m=v),g=v+1,p++):p=0));let _,k=w<255?w>=48&&w<=57||w>=97&&w<=122?2:w>=65&&w<=90?1:0:(_=lye(w))!=_.toLowerCase()?1:_!=_.toUpperCase()?2:0;(!v||k==1&&y||S==0&&k!=0)&&(n[O]==w||r[O]==w&&(f=!0)?s[O++]=v:s.length&&(b=!1)),S=k,v+=Hc(w)}return O==l&&s[0]==0&&b?this.result(-100+(f?-200:0),s,t):p==l&&m==0?this.ret(-200-t.length+(g==t.length?0:-100),[0,g]):o>-1?this.ret(-700-t.length,[o,o+this.pattern.length]):p==l?this.ret(-900-t.length,[m,g]):O==l?this.result(-100+(f?-200:0)+-700+(b?0:-1100),s,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 s of n){let o=s+(this.astral?Hc(Cs(r,s)):1);a&&i[a-1]==s?i[a-1]=o:(i[a++]=s,i[a++]=o)}return this.ret(t-r.length,i)}}class $ht{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 Zi=_t.define({combine(e){return E0(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:yht,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=>pB(t(r),n(r)),optionClass:(t,n)=>r=>pB(t(r),n(r)),addToOptions:(t,n)=>t.concat(n),filterStrict:(t,n)=>t||n})}});function pB(e,t){return e?t?e+" "+t:e:t}function yht(e,t,n,r,i,a){let s=e.textDirection==Cr.RTL,o=s,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(o&&f<Math.min(m,p)?o=!1:!o&&p<Math.min(m,f)&&(o=!0),m<=(o?f:p))u=Math.max(i.top,Math.min(n.top,i.bottom-g))-t.top,O=Math.min(400,o?f:p);else{l=!0,O=Math.min(400,(s?t.right:i.right-t.left)-30);let v=i.bottom-t.bottom;v>=g||v>t.top?u=n.bottom-t.top:(c="bottom",u=t.bottom-n.top)}let y=(t.bottom-t.top)/a.offsetHeight,b=(t.right-t.left)/a.offsetWidth;return{style:`${c}: ${u/y}px; max-width: ${O/b}px`,class:"cm-completionInfo-"+(l?s?"left-narrow":"right-narrow":o?"left":"right")}}function bht(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 s=document.createElement("span");s.className="cm-completionLabel";let o=n.displayLabel||n.label,l=0;for(let c=0;c<a.length;){let u=a[c++],O=a[c++];u>l&&s.appendChild(document.createTextNode(o.slice(l,u)));let f=s.appendChild(document.createElement("span"));f.appendChild(document.createTextNode(o.slice(u,O))),f.className="cm-completionMatchedText",l=O}return l<o.length&&s.appendChild(document.createTextNode(o.slice(l))),s},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 fR(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 vht{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:s}=i.open,o=t.state.facet(Zi);this.optionContent=bht(o),this.optionClass=o.optionClass,this.tooltipClass=o.tooltipClass,this.range=fR(a.length,s,o.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(Zi).closeOnBlur&&l.relatedTarget!=t.contentDOM&&t.dispatch({effects:cb.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:s,disabled:o}=r.open;(!i.open||i.open.options!=a)&&(this.range=fR(a.length,s,t.state.facet(Zi).maxRenderedOptions),this.showOptions(a,r.id)),this.updateSel(),o!=((n=i.open)===null||n===void 0?void 0:n.disabled)&&this.dom.classList.toggle("cm-tooltip-autocomplete-disabled",!!o)}}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=fR(n.options.length,n.selected,this.view.state.facet(Zi).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(s=>{s&&this.view.state.field(this.stateField,!1)==t&&this.addInfoPane(s,r)}).catch(s=>os(this.view.state,s,"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&&xht(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 s=this.dom.ownerDocument.documentElement;a={left:0,top:0,right:s.clientWidth,bottom:s.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(Zi).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",s=>{s.target==i&&s.preventDefault()});let a=null;for(let s=r.from;s<r.to;s++){let{completion:o,match:l}=t[s],{section:c}=o;if(c){let f=typeof c=="string"?c:c.name;if(f!=a&&(s>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+"-"+s,u.setAttribute("role","option");let O=this.optionClass(o);O&&(u.className=O);for(let f of this.optionContent){let p=f(o,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 wht(e,t){return n=>new vht(n,e,t)}function xht(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 mB(e){return(e.boost||0)*100+(e.apply?10:0)+(e.info?5:0)+(e.type?1:0)}function _ht(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(Zi);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 fB(O,c.source,u?u(O):[],1e9-n.length));else{let O=t.sliceDoc(c.from,c.to),f,p=a.filterStrict?new $ht(O):new ght(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 fB(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 s=[],o=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;!o||o.label!=u.label||o.detail!=u.detail||o.type!=null&&u.type!=null&&o.type!=u.type||o.apply!=u.apply||o.boost!=u.boost?s.push(c):mB(c.completion)>mB(o)&&(s[s.length-1]=c),o=c.completion}return s}class jp{constructor(t,n,r,i,a,s){this.options=t,this.attrs=n,this.tooltip=r,this.timestamp=i,this.selected=a,this.disabled=s}setSelected(t,n){return t==this.selected||t>=this.options.length?this:new jp(this.options,gB(n,t),this.tooltip,this.timestamp,t,this.disabled)}static build(t,n,r,i,a,s){if(i&&!s&&t.some(c=>c.isPending))return i.setDisabled();let o=_ht(t,n);if(!o.length)return i&&t.some(c=>c.isPending)?i.setDisabled():null;let l=n.facet(Zi).selectOnOpen?0:-1;if(i&&i.selected!=l&&i.selected!=-1){let c=i.options[i.selected].completion;for(let u=0;u<o.length;u++)if(o[u].completion==c){l=u;break}}return new jp(o,gB(r,l),{pos:t.reduce((c,u)=>u.hasResult()?Math.min(c,u.from):c,1e8),create:Eht,above:a.aboveCursor},i?i.timestamp:Date.now(),l,!1)}map(t){return new jp(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 jp(this.options,this.attrs,this.tooltip,this.timestamp,this.selected,!0)}}class KS{constructor(t,n,r){this.active=t,this.id=n,this.open=r}static start(){return new KS(Pht,"cm-ac-"+Math.floor(Math.random()*2e6).toString(36),null)}update(t){let{state:n}=t,r=n.facet(Zi),a=(r.override||n.languageDataAt("autocomplete",Qf(n)).map(mht)).map(l=>(this.active.find(u=>u.source==l)||new go(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 s=this.open,o=t.effects.some(l=>l.is(xI));s&&t.docChanged&&(s=s.map(t.changes)),t.selection||a.some(l=>l.hasResult()&&t.changes.touchesRange(l.from,l.to))||!Sht(a,this.active)||o?s=jp.build(a,n,this.id,s,r,o):s&&s.disabled&&!a.some(l=>l.isPending)&&(s=null),!s&&a.every(l=>!l.isPending)&&a.some(l=>l.hasResult())&&(a=a.map(l=>l.hasResult()?new go(l.source,0):l));for(let l of t.effects)l.is(Jbe)&&(s=s&&s.setSelected(l.value,this.id));return a==this.active&&s==this.open?this:new KS(a,this.id,s)}get tooltip(){return this.open?this.open.tooltip:null}get attrs(){return this.open?this.open.attrs:this.active.length?kht:Qht}}function Sht(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 kht={"aria-autocomplete":"list"},Qht={};function gB(e,t){let n={"aria-autocomplete":"list","aria-haspopup":"listbox","aria-controls":e};return t>-1&&(n["aria-activedescendant"]=e+"-"+t),n}const Pht=[];function Kbe(e,t){if(e.isUserEvent("input.complete")){let r=e.annotation(wI);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 go{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=Kbe(t,n),i=this;(r&8||r&16&&this.touches(t))&&(i=new go(i.source,0)),r&4&&i.state==0&&(i=new go(this.source,1)),i=i.updateFor(t,r);for(let a of t.effects)if(a.is(HS))i=new go(i.source,1,a.value);else if(a.is(cb))i=new go(i.source,0);else if(a.is(xI))for(let s of a.value)s.source==i.source&&(i=s);return i}updateFor(t,n){return this.map(t.changes)}map(t){return this}touches(t){return t.changes.touchesRange(Qf(t.state))}}class Kp extends go{constructor(t,n,r,i,a,s){super(t,3,n),this.limit=r,this.result=i,this.from=a,this.to=s}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),s=t.changes.mapPos(this.to,1),o=Qf(t.state);if(o>s||!i||n&2&&(Qf(t.startState)==this.from||o<this.limit))return new go(this.source,n&4?1:0);let l=t.changes.mapPos(this.limit);return Tht(i.validFor,t.state,a,s)?new Kp(this.source,this.explicit,l,i,a,s):i.update&&(i=i.update(i,a,s,new vI(t.state,o,!1)))?new Kp(this.source,this.explicit,l,i,i.from,(r=i.to)!==null&&r!==void 0?r:Qf(t.state)):new go(this.source,1,this.explicit)}map(t){return t.empty?this:(this.result.map?this.result.map(this.result,t):this.result)?new Kp(this.source,this.explicit,t.mapPos(this.limit),this.result,t.mapPos(this.from),t.mapPos(this.to,1)):new go(this.source,0)}touches(t){return t.changes.touchesRange(this.from,this.to)}}function Tht(e,t,n,r){if(!e)return!1;let i=t.sliceDoc(n,r);return typeof e=="function"?e(i,n,r,t):Hbe(e,!0).test(i)}const xI=qn.define({map(e,t){return e.map(n=>n.map(t))}}),Jbe=qn.define(),rs=ps.define({create(){return KS.start()},update(e,t){return e.update(t)},provide:e=>[hI.from(e,t=>t.tooltip),jt.contentAttributes.from(e,t=>t.attrs)]});function _I(e,t){const n=t.completion.apply||t.completion.label;let r=e.state.field(rs).active.find(i=>i.source==t.source);return r instanceof Kp?(typeof n=="string"?e.dispatch(Object.assign(Object.assign({},pht(e.state,n,r.from,r.to)),{annotations:wI.of(t.completion)})):n(e,t.completion,r.from,r.to),!0):!1}const Eht=wht(rs,_I);function Xw(e,t="option"){return n=>{let r=n.state.field(rs,!1);if(!r||!r.open||r.open.disabled||Date.now()-r.open.timestamp<n.state.facet(Zi).interactionDelay)return!1;let i=1,a;t=="page"&&(a=xbe(n,r.open.tooltip))&&(i=Math.max(2,Math.floor(a.dom.offsetHeight/a.dom.querySelector("li").offsetHeight)-1));let{length:s}=r.open.options,o=r.open.selected>-1?r.open.selected+i*(e?1:-1):e?0:s-1;return o<0?o=t=="page"?0:s-1:o>=s&&(o=t=="page"?s-1:0),n.dispatch({effects:Jbe.of(o)}),!0}}const Rht=e=>{let t=e.state.field(rs,!1);return e.state.readOnly||!t||!t.open||t.open.selected<0||t.open.disabled||Date.now()-t.open.timestamp<e.state.facet(Zi).interactionDelay?!1:_I(e,t.open.options[t.open.selected])},$B=e=>e.state.field(rs,!1)?(e.dispatch({effects:HS.of(!0)}),!0):!1,Xht=e=>{let t=e.state.field(rs,!1);return!t||!t.active.some(n=>n.state!=0)?!1:(e.dispatch({effects:cb.of(null)}),!0)};class Cht{constructor(t,n){this.active=t,this.context=n,this.time=Date.now(),this.updates=[],this.done=void 0}}const Aht=50,qht=1e3,jht=Ci.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(rs).active)t.isPending&&this.startQuery(t)}update(e){let t=e.state.field(rs),n=e.state.facet(Zi);if(!e.selectionSet&&!e.docChanged&&e.startState.field(rs)==t)return;let r=e.transactions.some(a=>{let s=Kbe(a,n);return s&8||(a.selection||a.docChanged)&&!(s&3)});for(let a=0;a<this.running.length;a++){let s=this.running[a];if(r||s.context.abortOnDocChange&&e.docChanged||s.updates.length+e.transactions.length>Aht&&Date.now()-s.time>qht){for(let o of s.context.abortListeners)try{o()}catch(l){os(this.view.state,l)}s.context.abortListeners=null,this.running.splice(a--,1)}else s.updates.push(...e.transactions)}this.debounceUpdate>-1&&clearTimeout(this.debounceUpdate),e.transactions.some(a=>a.effects.some(s=>s.is(HS)))&&(this.pendingStart=!0);let i=this.pendingStart?50:n.activateOnTypingDelay;if(this.debounceUpdate=t.active.some(a=>a.isPending&&!this.running.some(s=>s.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(rs);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(Zi).updateSyncTime))}startQuery(e){let{state:t}=this.view,n=Qf(t),r=new vI(t,n,e.explicit,this.view),i=new Cht(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:cb.of(null)}),os(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(Zi).updateSyncTime))}accept(){var e;this.debounceAccept>-1&&clearTimeout(this.debounceAccept),this.debounceAccept=-1;let t=[],n=this.view.state.facet(Zi),r=this.view.state.field(rs);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 o=Qf(a.updates.length?a.updates[0].startState:this.view.state),l=Math.min(o,a.done.from+(a.active.explicit?0:1)),c=new Kp(a.active.source,a.active.explicit,l,a.done,a.done.from,(e=a.done.to)!==null&&e!==void 0?e:o);for(let u of a.updates)c=c.update(u,n);if(c.hasResult()){t.push(c);continue}}let s=r.active.find(o=>o.source==a.active.source);if(s&&s.isPending)if(a.done==null){let o=new go(a.active.source,0);for(let l of a.updates)o=o.update(l,n);o.isPending||t.push(o)}else this.startQuery(s)}(t.length||r.open&&r.open.disabled)&&this.view.dispatch({effects:xI.of(t)})}},{eventHandlers:{blur(e){let t=this.view.state.field(rs,!1);if(t&&t.tooltip&&this.view.state.facet(Zi).closeOnBlur){let n=t.open&&xbe(this.view,t.open.tooltip);(!n||!n.dom.contains(e.relatedTarget))&&setTimeout(()=>this.view.dispatch({effects:cb.of(null)}),10)}},compositionstart(){this.composing=1},compositionend(){this.composing==3&&setTimeout(()=>this.view.dispatch({effects:HS.of(!1)}),20),this.composing=0}}}),Nht=typeof navigator=="object"&&/Win/.test(navigator.platform),zht=$d.highest(jt.domEventHandlers({keydown(e,t){let n=t.state.field(rs,!1);if(!n||!n.open||n.open.disabled||n.open.selected<0||e.key.length>1||e.ctrlKey&&!(Nht&&e.altKey)||e.metaKey)return!1;let r=n.open.options[n.open.selected],i=n.active.find(s=>s.source==r.source),a=r.completion.commitCharacters||i.result.commitCharacters;return a&&a.indexOf(e.key)>-1&&_I(t,r),!1}})),e1e=jt.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 Uht{constructor(t,n,r,i){this.field=t,this.line=n,this.from=r,this.to=i}}class SI{constructor(t,n,r){this.field=t,this.from=n,this.to=r}map(t){let n=t.mapPos(this.from,-1,aa.TrackDel),r=t.mapPos(this.to,1,aa.TrackDel);return n==null||r==null?null:new SI(this.field,n,r)}}class kI{constructor(t,n){this.lines=t,this.fieldPositions=n}instantiate(t,n){let r=[],i=[n],a=t.doc.lineAt(n),s=/^\s*/.exec(a.text)[0];for(let l of this.lines){if(r.length){let c=s,u=/^\t*/.exec(l)[0].length;for(let O=0;O<u;O++)c+=t.facet(KP);i.push(n+c.length-u),l=c+l.slice(u)}r.push(l),n+=l.length+1}let o=this.fieldPositions.map(l=>new SI(l.field,i[l.line]+l.from,i[l.line]+l.to));return{text:r,ranges:o}}static parse(t){let n=[],r=[],i=[],a;for(let s of t.split(/\r\n?|\n/)){for(;a=/[#$]\{(?:(\d+)(?::([^}]*))?|((?:\\[{}]|[^}])*))\}/.exec(s);){let o=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++)(o!=null?n[O].seq==o:u&&n[O].name==u)&&(c=O);if(c<0){let O=0;for(;O<n.length&&(o==null||n[O].seq!=null&&n[O].seq<o);)O++;n.splice(O,0,{seq:o,name:u}),c=O;for(let f of i)f.field>=c&&f.field++}i.push(new Uht(c,r.length,a.index,a.index+u.length)),s=s.slice(0,a.index)+l+s.slice(a.index+a[0].length)}s=s.replace(/\\([{}])/g,(o,l,c)=>{for(let u of i)u.line==r.length&&u.from>c&&(u.from--,u.to--);return l}),r.push(s)}return new kI(r,i)}}let Iht=yn.widget({widget:new class extends Yu{toDOM(){let e=document.createElement("span");return e.className="cm-snippetFieldPosition",e}ignoreEvent(){return!1}}}),Wht=yn.mark({class:"cm-snippetField"});class R0{constructor(t,n){this.ranges=t,this.active=n,this.deco=yn.set(t.map(r=>(r.from==r.to?Iht:Wht).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 R0(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 B1=qn.define({map(e,t){return e&&e.map(t)}}),Dht=qn.define(),ub=ps.define({create(){return null},update(e,t){for(let n of t.effects){if(n.is(B1))return n.value;if(n.is(Dht)&&e)return new R0(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=>jt.decorations.from(e,t=>t?t.deco:yn.none)});function QI(e,t){return nt.create(e.filter(n=>n.field==t).map(n=>nt.range(n.from,n.to)))}function Yht(e){let t=kI.parse(e);return(n,r,i,a)=>{let{text:s,ranges:o}=t.instantiate(n.state,i),{main:l}=n.state.selection,c={changes:{from:i,to:a==l.from?l.to:a,insert:tr.of(s)},scrollIntoView:!0,annotations:r?[wI.of(r),sa.userEvent.of("input.complete")]:void 0};if(o.length&&(c.selection=QI(o,0)),o.some(u=>u.field>0)){let u=new R0(o,0),O=c.effects=[B1.of(u)];n.state.field(ub,!1)===void 0&&O.push(qn.appendConfig.of([ub,Vht,Fht,e1e]))}n.dispatch(n.state.update(c))}}function t1e(e){return({state:t,dispatch:n})=>{let r=t.field(ub,!1);if(!r||e<0&&r.active==0)return!1;let i=r.active+e,a=e>0&&!r.ranges.some(s=>s.field==i+e);return n(t.update({selection:QI(r.ranges,i),effects:B1.of(a?null:new R0(r.ranges,i)),scrollIntoView:!0})),!0}}const Ght=({state:e,dispatch:t})=>e.field(ub,!1)?(t(e.update({effects:B1.of(null)})),!0):!1,Lht=t1e(1),Mht=t1e(-1),Zht=[{key:"Tab",run:Lht,shift:Mht},{key:"Escape",run:Ght}],yB=_t.define({combine(e){return e.length?e[0]:Zht}}),Vht=$d.highest(FP.compute([yB],e=>e.facet(yB)));function kr(e,t){return Object.assign(Object.assign({},t),{apply:Yht(e)})}const Fht=jt.domEventHandlers({mousedown(e,t){let n=t.state.field(ub,!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:QI(n.ranges,i.field),effects:B1.of(n.ranges.some(a=>a.field>i.field)?new R0(n.ranges,i.field):null),scrollIntoView:!0}),!0)}}),Ob={brackets:["(","[","{","'",'"'],before:")]}:;>",stringPrefixes:[]},df=qn.define({map(e,t){let n=t.mapPos(e,-1,aa.TrackAfter);return n??void 0}}),PI=new class extends Df{};PI.startSide=1;PI.endSide=-1;const n1e=ps.define({create(){return An.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(df)&&(e=e.update({add:[PI.range(n.value,n.value+1)]}));return e}});function Lvn(){return[Hht,n1e]}const hR="()[]{}<>«»»«[]{}";function r1e(e){for(let t=0;t<hR.length;t+=2)if(hR.charCodeAt(t)==e)return hR.charAt(t+1);return lye(e<128?e:e+1)}function i1e(e,t){return e.languageDataAt("closeBrackets",t)[0]||Ob}const Bht=typeof navigator=="object"&&/Android\b/.test(navigator.userAgent),Hht=jt.inputHandler.of((e,t,n,r)=>{if((Bht?e.composing:e.compositionStarted)||e.state.readOnly)return!1;let i=e.state.selection.main;if(r.length>2||r.length==2&&Hc(Cs(r,0))==1||t!=i.from||n!=i.to)return!1;let a=Jht(e.state,r);return a?(e.dispatch(a),!0):!1}),Kht=({state:e,dispatch:t})=>{if(e.readOnly)return!1;let r=i1e(e,e.selection.main.head).brackets||Ob.brackets,i=null,a=e.changeByRange(s=>{if(s.empty){let o=ept(e.doc,s.head);for(let l of r)if(l==o&&nT(e.doc,s.head)==r1e(Cs(l,0)))return{changes:{from:s.head-l.length,to:s.head+l.length},range:nt.cursor(s.head-l.length)}}return{range:i=s}});return i||t(e.update(a,{scrollIntoView:!0,userEvent:"delete.backward"})),!i},Mvn=[{key:"Backspace",run:Kht}];function Jht(e,t){let n=i1e(e,e.selection.main.head),r=n.brackets||Ob.brackets;for(let i of r){let a=r1e(Cs(i,0));if(t==i)return a==i?rpt(e,i,r.indexOf(i+i+i)>-1,n):tpt(e,i,a,n.before||Ob.before);if(t==a&&a1e(e,e.selection.main.from))return npt(e,i,a)}return null}function a1e(e,t){let n=!1;return e.field(n1e).between(0,e.doc.length,r=>{r==t&&(n=!0)}),n}function nT(e,t){let n=e.sliceString(t,t+2);return n.slice(0,Hc(Cs(n,0)))}function ept(e,t){let n=e.sliceString(t-2,t);return Hc(Cs(n,0))==n.length?n:n.slice(1)}function tpt(e,t,n,r){let i=null,a=e.changeByRange(s=>{if(!s.empty)return{changes:[{insert:t,from:s.from},{insert:n,from:s.to}],effects:df.of(s.to+t.length),range:nt.range(s.anchor+t.length,s.head+t.length)};let o=nT(e.doc,s.head);return!o||/\s/.test(o)||r.indexOf(o)>-1?{changes:{insert:t+n,from:s.head},effects:df.of(s.head+t.length),range:nt.cursor(s.head+t.length)}:{range:i=s}});return i?null:e.update(a,{scrollIntoView:!0,userEvent:"input.type"})}function npt(e,t,n){let r=null,i=e.changeByRange(a=>a.empty&&nT(e.doc,a.head)==n?{changes:{from:a.head,to:a.head+n.length,insert:n},range:nt.cursor(a.head+n.length)}:r={range:a});return r?null:e.update(i,{scrollIntoView:!0,userEvent:"input.type"})}function rpt(e,t,n,r){let i=r.stringPrefixes||Ob.stringPrefixes,a=null,s=e.changeByRange(o=>{if(!o.empty)return{changes:[{insert:t,from:o.from},{insert:t,from:o.to}],effects:df.of(o.to+t.length),range:nt.range(o.anchor+t.length,o.head+t.length)};let l=o.head,c=nT(e.doc,l),u;if(c==t){if(bB(e,l))return{changes:{insert:t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)};if(a1e(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:nt.cursor(l+f.length)}}}else{if(n&&e.sliceDoc(l-2*t.length,l)==t+t&&(u=vB(e,l-2*t.length,i))>-1&&bB(e,u))return{changes:{insert:t+t+t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)};if(e.charCategorizer(l)(c)!=mo.Word&&vB(e,l,i)>-1&&!ipt(e,l,t,i))return{changes:{insert:t+t,from:l},effects:df.of(l+t.length),range:nt.cursor(l+t.length)}}return{range:a=o}});return a?null:e.update(s,{scrollIntoView:!0,userEvent:"input.type"})}function bB(e,t){let n=nr(e).resolveInner(t+1);return n.parent&&n.from==t}function ipt(e,t,n,r){let i=nr(e).resolveInner(t,-1),a=r.reduce((s,o)=>Math.max(s,o.length),0);for(let s=0;s<5;s++){let o=e.sliceDoc(i.from,Math.min(i.to,i.from+n.length+a)),l=o.indexOf(n);if(!l||l>-1&&r.indexOf(o.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 vB(e,t,n){let r=e.charCategorizer(t);if(r(e.sliceDoc(t-1,t))!=mo.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))!=mo.Word)return a}return-1}function Zvn(e={}){return[zht,rs,Zi.of(e),jht,spt,e1e]}const apt=[{key:"Ctrl-Space",run:$B},{mac:"Alt-`",run:$B},{key:"Escape",run:Xht},{key:"ArrowDown",run:Xw(!0)},{key:"ArrowUp",run:Xw(!1)},{key:"PageDown",run:Xw(!0,"page")},{key:"PageUp",run:Xw(!1,"page")},{key:"Enter",run:Rht}],spt=$d.highest(FP.computeN([Zi],e=>e.facet(Zi).defaultKeymap?[apt]:[]));class JS{static create(t,n,r,i,a){let s=i+(i<<8)+t+(n<<4)|0;return new JS(t,n,r,s,a,[],[])}constructor(t,n,r,i,a,s,o){this.type=t,this.value=n,this.from=r,this.hash=i,this.end=a,this.children=s,this.positions=o,this.hashProp=[[en.contextHash,i]]}addChild(t,n){t.prop(en.contextHash)!=this.hash&&(t=new xn(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 xn(t.types[this.type],this.children,this.positions,n-this.from).balance({makeTree:(i,a,s)=>new xn(xi.none,i,a,s,this.hashProp)})}}var rt;(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"})(rt||(rt={}));class opt{constructor(t,n){this.start=t,this.content=n,this.marks=[],this.parsers=[]}}let lpt=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 sy(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 wB(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==rt.OrderedList?RI:EI)(n,t,!1);return r>0&&(e.type!=rt.BulletList||TI(n,t,!1)<0)&&n.text.charCodeAt(n.pos+r-1)==e.value}const s1e={[rt.Blockquote](e,t,n){return n.next!=62?!1:(n.markers.push(Qn(rt.QuoteMark,t.lineStart+n.pos,t.lineStart+n.pos+1)),n.moveBase(n.pos+(Xo(n.text.charCodeAt(n.pos+1))?2:1)),e.end=t.lineStart+n.text.length,!0)},[rt.ListItem](e,t,n){return n.indent<n.baseIndent+e.value&&n.next>-1?!1:(n.moveBaseColumn(n.baseIndent+e.value),!0)},[rt.OrderedList]:wB,[rt.BulletList]:wB,[rt.Document](){return!0}};function Xo(e){return e==32||e==9||e==10||e==13}function sy(e,t=0){for(;t<e.length&&Xo(e.charCodeAt(t));)t++;return t}function xB(e,t,n){for(;t>n&&Xo(e.charCodeAt(t-1));)t--;return t}function o1e(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 l1e(e){return e.next!=62?-1:e.text.charCodeAt(e.pos+1)==32?2:1}function TI(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(!Xo(a))return-1}return n&&e.next==45&&O1e(e)>-1&&e.depth==t.stack.length&&t.parser.leafBlockParsers.indexOf(p1e.SetextHeading)>-1||r<3?-1:1}function c1e(e,t){for(let n=e.stack.length-1;n>=0;n--)if(e.stack[n].type==t)return!0;return!1}function EI(e,t,n){return(e.next==45||e.next==43||e.next==42)&&(e.pos==e.text.length-1||Xo(e.text.charCodeAt(e.pos+1)))&&(!n||c1e(t,rt.BulletList)||e.skipSpace(e.pos+2)<e.text.length)?1:-1}function RI(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&&!Xo(e.text.charCodeAt(r+1))||n&&!c1e(t,rt.OrderedList)&&(e.skipSpace(r+1)==e.text.length||r>e.pos+1||e.next!=49)?-1:r+1-e.pos}function u1e(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 O1e(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&&Xo(e.text.charCodeAt(t));)t++;return t==e.text.length?n:-1}const Mj=/^[ \t]*$/,d1e=/-->/,f1e=/\?>/,Zj=[[/^<(?:script|pre|style)(?:\s|>|$)/i,/<\/(?:script|pre|style)>/i],[/^\s*<!--/,d1e],[/^\s*<\?/,f1e],[/^\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,Mj],[/^\s*(?:<\/[a-z][\w-]*\s*>|<[a-z][\w-]*(\s+[a-z:_][\w-.]*(?:\s*=\s*(?:[^\s"'=<>`]+|'[^']*'|"[^"]*"))?)*\s*>)\s*$/i,Mj]];function h1e(e,t,n){if(e.next!=60)return-1;let r=e.text.slice(e.pos);for(let i=0,a=Zj.length-(n?1:0);i<a;i++)if(Zj[i][0].test(r))return i;return-1}function _B(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 Wd(e,t,n){let r=e.length-1;r>=0&&e[r].to==t&&e[r].type==rt.CodeText?e[r].to=n:e.push(Qn(rt.CodeText,t,n))}const Cw={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,s=[],o=[];for(Wd(s,i,a);e.nextLine()&&t.depth>=e.stack.length;)if(t.pos==t.text.length){Wd(o,e.lineStart-1,e.lineStart);for(let l of t.markers)o.push(l)}else{if(t.indent<n)break;{if(o.length){for(let c of o)c.type==rt.CodeText?Wd(s,c.from,c.to):s.push(c);o=[]}Wd(s,e.lineStart-1,e.lineStart);for(let c of t.markers)s.push(c);a=e.lineStart+t.text.length;let l=e.lineStart+t.findColumn(t.baseIndent+4);l<a&&Wd(s,l,a)}}return o.length&&(o=o.filter(l=>l.type!=rt.CodeText),o.length&&(t.markers=o.concat(t.markers))),e.addNode(e.buffer.writeElements(s,-i).finish(rt.CodeBlock,a-i),i),!0},FencedCode(e,t){let n=o1e(t);if(n<0)return!1;let r=e.lineStart+t.pos,i=t.next,a=n-t.pos,s=t.skipSpace(n),o=xB(t.text,t.text.length,s),l=[Qn(rt.CodeMark,r,r+a)];s<o&&l.push(Qn(rt.CodeInfo,e.lineStart+s,e.lineStart+o));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(Qn(rt.CodeMark,e.lineStart+t.pos,e.lineStart+u)),e.nextLine();break}else{c||Wd(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&&Wd(l,O,f)}}return e.addNode(e.buffer.writeElements(l,-r).finish(rt.FencedCode,e.prevLineEnd()-r),r),!0},Blockquote(e,t){let n=l1e(t);return n<0?!1:(e.startContext(rt.Blockquote,t.pos),e.addNode(rt.QuoteMark,e.lineStart+t.pos,e.lineStart+t.pos+1),t.moveBase(t.pos+n),null)},HorizontalRule(e,t){if(TI(t,e,!1)<0)return!1;let n=e.lineStart+t.pos;return e.nextLine(),e.addNode(rt.HorizontalRule,n),!0},BulletList(e,t){let n=EI(t,e,!1);if(n<0)return!1;e.block.type!=rt.BulletList&&e.startContext(rt.BulletList,t.basePos,t.next);let r=_B(t,t.pos+1);return e.startContext(rt.ListItem,t.basePos,r-t.baseIndent),e.addNode(rt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},OrderedList(e,t){let n=RI(t,e,!1);if(n<0)return!1;e.block.type!=rt.OrderedList&&e.startContext(rt.OrderedList,t.basePos,t.text.charCodeAt(t.pos+n-1));let r=_B(t,t.pos+n);return e.startContext(rt.ListItem,t.basePos,r-t.baseIndent),e.addNode(rt.ListMark,e.lineStart+t.pos,e.lineStart+t.pos+n),t.moveBaseColumn(r),null},ATXHeading(e,t){let n=u1e(t);if(n<0)return!1;let r=t.pos,i=e.lineStart+r,a=xB(t.text,t.text.length,r),s=a;for(;s>r&&t.text.charCodeAt(s-1)==t.next;)s--;(s==a||s==r||!Xo(t.text.charCodeAt(s-1)))&&(s=t.text.length);let o=e.buffer.write(rt.HeaderMark,0,n).writeElements(e.parser.parseInline(t.text.slice(r+n+1,s),i+n+1),-i);s<t.text.length&&o.write(rt.HeaderMark,s-r,a-r);let l=o.finish(rt.ATXHeading1-1+n,t.text.length-r);return e.nextLine(),e.addNode(l,i),!0},HTMLBlock(e,t){let n=h1e(t,e,!1);if(n<0)return!1;let r=e.lineStart+t.pos,i=Zj[n][1],a=[],s=i!=Mj;for(;!i.test(t.text)&&e.nextLine();){if(t.depth<e.stack.length){s=!1;break}for(let c of t.markers)a.push(c)}s&&e.nextLine();let o=i==d1e?rt.CommentBlock:i==f1e?rt.ProcessingInstructionBlock:rt.HTMLBlock,l=e.prevLineEnd();return e.addNode(e.buffer.writeElements(a,-r).finish(o,l-r),r),!0},SetextHeading:void 0};class cpt{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+`
908
908
  `+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)&&sy(n.content,this.pos)==n.content.length?this.complete(t,n,n.content.length):!1}complete(t,n,r){return t.addLeafElement(n,Qn(rt.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(_1e(t,this.pos,this.start,!0)))return-1;if(t.charCodeAt(this.pos)!=58)return this.stage=-1;this.elts.push(Qn(rt.LinkMark,this.pos+this.start,this.pos+this.start+1)),this.pos++}else if(this.stage==1){if(!this.nextStage(w1e(t,sy(t,this.pos),this.start)))return-1}else if(this.stage==2){let n=sy(t,this.pos),r=0;if(n>this.pos){let i=x1e(t,n,this.start);if(i){let a=pR(t,i.to-this.start);a>0&&(this.nextStage(i),r=a)}}return r||(r=pR(t,this.pos)),r>0&&r<t.length?r:-1}else return pR(t,this.pos)}}}function pR(e,t){for(;t<e.length;t++){let n=e.charCodeAt(t);if(n==10)break;if(!Xo(n))return-1}return t}class upt{nextLine(t,n,r){let i=n.depth<t.stack.length?-1:O1e(n),a=n.next;if(i<0)return!1;let s=Qn(rt.HeaderMark,t.lineStart+n.pos,t.lineStart+i);return t.nextLine(),t.addLeafElement(r,Qn(a==61?rt.SetextHeading1:rt.SetextHeading2,r.start,t.prevLineEnd(),[...t.parser.parseInline(r.content,r.start),s])),!0}finish(){return!1}}const p1e={LinkReference(e,t){return t.content.charCodeAt(0)==91?new cpt(t):null},SetextHeading(){return new upt}},Opt=[(e,t)=>u1e(t)>=0,(e,t)=>o1e(t)>=0,(e,t)=>l1e(t)>=0,(e,t)=>EI(t,e,!0)>=0,(e,t)=>RI(t,e,!0)>=0,(e,t)=>TI(t,e,!0)>=0,(e,t)=>h1e(t,e,!0)>=0],dpt={text:"",end:0};class fpt{constructor(t,n,r,i){this.parser=t,this.input=n,this.ranges=i,this.line=new lpt,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=JS.create(rt.Document,0,this.lineStart,0,0),this.stack=[this.block],this.fragments=r.length?new gpt(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 opt(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+=`
909
909
  `+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=S1e(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=dpt;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,s=this.lineChunkAt(a);n.end=a+s.length,n.text=n.text.slice(0,this.ranges[i-1].to-r)+s,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 "+rt[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==`
910
910
  `?"":n;else{let i=n.indexOf(`
@@ -942,7 +942,7 @@ l0,-`+(n+144)+`c-2,-159.3,-10,-310.7,-24,-454c-53.3,-528,-210,-949.7,
942
942
  `)?{...i,capture:s}:{...i,capture:Up(s,i.buffer,i.caret,"typing")}}return CW(e,i.buffer,i.caret,{top:n.start,bottom:n.end,inserted:r})??i}function Tk(e){return ts(e)?{arm:e.arm,typingAt:null,value:""}:e}function aqt(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 sqt(e,t,n,r,i){const a=aqt(t,n),s=_h(e);let o={capture:e,buffer:n,caret:r};if(a.inserted!==""&&s!==null&&a.top<=s.end&&a.bottom>=s.start)o={capture:Tk(e),buffer:n,caret:r};else{const l=CW(e,n,r,a);l?o=l:ts(e)&&a.inserted.includes(`
943
943
  `)&&(o={capture:Tk(e),buffer:n,caret:r})}return{...o,capture:Up(o.capture,o.buffer,o.caret,i)}}function oqt(e){const{capture:t,buffer:n,caret:r,index:i,taken:a}=e,s=_h(t);if(s===null||t.value==="")return{minted:!1,capture:t,buffer:n,caret:r,payload:null};const o=t.arm===null?s.start:t.arm.start,l=$Pe(i,t.value),c=l+qT,u=n.slice(0,o)+c+n.slice(s.end);return{minted:!0,capture:as,buffer:u,caret:o+c.length,payload:{index:i,key:yPe(a,e.draw),value:t.value,marker:l}}}const lqt=e=>ts(e)&&e.value!=="";function cqt(e,t){const n=_h(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:as,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 uqt(e,t){return t===null||t.text.length===0?!1:e.slice(t.span.start,t.span.start+t.text.length)===t.text}function Oqt(e,t,n,r){const i=t.slice(0,n.start)+r+t.slice(n.end),a=n.start+r.length,s=_h(e);return s===null?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:n.start<=s.start?{kind:"passthrough",capture:{...e,typingAt:s.start+r.length},buffer:i,caret:a,payload:null}:n.start>=s.end?{kind:"passthrough",capture:e,buffer:i,caret:a,payload:null}:{kind:"passthrough",capture:Tk(e),buffer:i,caret:a,payload:null}}function dqt(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=CW(t,n,r,{top:e.selection.start,bottom:e.selection.end,inserted:i});return u===null?null:{kind:"masked",...u,payload:null}}const a=or(i);if(!a)return i===""?null:Oqt(t,n,e.selection,i);const s=t.arm,o=$Pe(e.index,a),l=o+qT,c=n.slice(0,s.start)+l+n.slice(s.end);return{kind:"minted",capture:as,buffer:c,caret:s.start+l.length,payload:{index:e.index,key:yPe(e.taken,e.draw),value:a,marker:o}}}const gPe=e=>`${JAt(e)} chars`,$Pe=(e,t)=>`[Credential #${e}, ${gPe(t)}]`;function fqt(e){Bl.lastIndex=0;const t=Bl.exec(e);return Bl.lastIndex=0,t===null||t[0]!==e?null:Number.parseInt(t[1],10)}function hqt(e){Bl.lastIndex=0;const t=Bl.exec(e);if(Bl.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 cv(e,t){if(fqt(t.marker)!==t.index)return null;const n=e.indexOf(t.marker);return n===-1?null:{start:n,end:n+t.marker.length}}const q4=/\[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,j4=/\[credential NOT stored \u2014 [^\]\n]*\]/y,N4=/\[credential unconfirmed \u2014 [^\]\n]*\]/y,pqt=e=>{const t=/\$([A-Z0-9_]+)/.exec(e);return t!==null&&F7.test(t[1])?t[1]:""};function mqt(e,t){if(e.charCodeAt(t)!==91)return null;q4.lastIndex=t;const n=q4.exec(e);if(q4.lastIndex=0,n!==null&&n[1]===n[3])return{kind:"stored",text:n[0],key:n[1],chars:Number.parseInt(n[2],10)};j4.lastIndex=t;const r=j4.exec(e);if(j4.lastIndex=0,r!==null)return{kind:"unstored",text:r[0]};N4.lastIndex=t;const i=N4.exec(e);return N4.lastIndex=0,i!==null?{kind:"unconfirmed",text:i[0],key:pqt(i[0])}:null}function jT(e){const t=[];let n=0,r=0;for(;r<e.length;){const i=mqt(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 Jee(e,t){const n=[];for(const r of t){const i=cv(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 gqt(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 $qt=e=>`[credential ${e.key} (${gPe(e.value)}) — available to bash and eval as $${e.key}; its value cannot be read]`;function yqt(e,t,n=new Map){const r=[...t],i=[];for(const s of r){const o=cv(e,s);o!==null&&i.push({span:o,payload:s})}for(const s of fPe(e,r))i.push({span:s,payload:null});let a=e;for(const{span:s,payload:o}of i.sort((l,c)=>c.span.start-l.span.start)){const l=o===null?"lost":n.get(o.index),c=o===null||l!==void 0?gqt(l??"lost",o?.key):$qt(o);a=a.slice(0,s.start)+c+a.slice(s.end)}return a}const bqt=(e,t,n)=>h("ui.chat.credential_notice.cleared",{key:e,index:t,undoCap:n}),vqt=e=>h("ui.chat.credential_notice.clear_label",{index:e}),wqt=(e,t)=>h("ui.chat.credential_notice.chip_title",{index:e,chars:t}),xqt=(e,t,n)=>bqt(e,t,n),_qt=()=>h("ui.chat.credential_notice.undo"),Sqt=e=>h("ui.notices.credentials.removed",{index:e}),kqt=e=>e.unredacted!==null?e.unredacted:e.armed?Cqt():e.cleared!==null?xqt(e.cleared.key,e.cleared.index,e.undoCap):null;function Qqt(e){const{buffer:t,payload:n}=e,r=cv(t,n);if(r===null)return{cleared:!1,buffer:t,caret:t.length,removed:""};const i=t[r.end]===qT?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 Pqt(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 ete=e=>h("ui.notices.credentials.stored",{keys:ll(e)});function tte(e){return h("ui.notices.credentials.unstored",{count:e.length,keys:ll([...e].sort())})}const Tqt=()=>h("ui.chat.credential_notice.unconfirmed_alone"),Eqt=e=>e===""?Tqt():h("ui.chat.credential_notice.unconfirmed_labelled",{key:e}),Rqt=()=>h("ui.chat.credential_notice.operator_move"),Xqt=e=>`${e} ${Rqt()}`;function nte(e){return h("ui.notices.credentials.unconfirmed",{count:e.length,keys:ll([...e].sort())})}const Cqt=()=>h("ui.chat.credential_notice.armed"),Aqt=()=>h("ui.chat.credential_notice.typing"),qqt=()=>h("ui.chat.credential_notice.empty_span"),jqt=()=>h("ui.chat.credential_notice.escape_held"),Nqt=()=>h("ui.chat.credential_notice.discarded"),zqt=()=>h("ui.chat.credential_notice.empty_span_draft"),Uqt=e=>h("ui.chat.credential_notice.unredacted",{length:e});function Iqt(e,t){const n=_h(t);return n===null?e:e.slice(0,n.start)+t.value+e.slice(n.end)}const rte=(e,t)=>e&&e.over===t?e.chars:null,Wqt=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},Dqt=16,Yqt=16;function yPe(e=[],t=Wqt){const n=new Set(e);for(let r=0;r<Dqt;r++){const i=Hee+ite(8,t);if(!n.has(i))return i}return Hee+ite(Yqt,t)}const ite=(e,t)=>{let n="";for(let r=0;r<e;r++)n+=Bee[t(Bee.length)];return n},Gqt=8,Lqt=256,Mqt=/^[/@$#]/,Zqt=/^\w+:\/\//,Vqt=/^[A-Za-z]+$/,Fqt=/^\d+$/,Bqt=[/[a-z]/,/[A-Z]/,/\d/,/[^A-Za-z0-9]/],Hqt=3,Kqt=20,Jqt=/^[A-Za-z0-9_\-+/=.]+$/,ejt=new RegExp(`^[^${vu}@]+@[^${vu}@]+\\.[A-Za-z]{2,}$`),tjt=/^[\w.-]+(?:\/[\w.-]+)+$/,njt=/\.[A-Za-z][A-Za-z0-9]{0,7}$/,rjt=/^v?\d+(?:\.\d+)+(?:[-+][0-9A-Za-z.-]+)?$/,ijt=/^\d{4}-\d{2}-\d{2}(?:[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d+)?)?(?:Z|[+-]\d{2}:?\d{2})?)?$/,ajt=/^[\w.-]+:\d{2,5}$/,sjt=/^(?:[0-9a-f]{7,12}|[0-9a-f]{40})$/i,ojt=/^[a-z]+(?:_[a-z]+)+$/,ljt=/^[a-z]+(?:-[a-z]+)+$/,cjt=/^[a-z][a-z0-9]*(?:[A-Z][a-z0-9]+)+$/,ujt=/^[a-z0-9]+(?:-[a-z0-9]+)+$/,Ojt=/\d{4,}/,ate=e=>{const t=e.trim();return t.length<Gqt||t.length>Lqt||cl.test(t)||Mqt.test(t)||Zqt.test(t)||fz(t)!==null||ejt.test(t)||tjt.test(t)||njt.test(t)||rjt.test(t)||ijt.test(t)||ajt.test(t)||sjt.test(t)||ojt.test(t)||ljt.test(t)||cjt.test(t)||ujt.test(t)&&Ojt.test(t)||Vqt.test(t)||Fqt.test(t)?!1:Bqt.filter(r=>r.test(t)).length>=Hqt?!0:t.length>=Kqt&&Jqt.test(t)},bPe=R("rounded-xs bg-info-wash","outline-1 outline-solid outline-info-border","box-decoration-clone"),vPe=R("rounded-xs bg-warning-wash","outline-1 outline-dashed outline-warning-border","box-decoration-clone"),djt=({chars:e})=>(ke(),d.jsx("span",{className:"shrink-0",children:h("ui.chat.credential_notice.chip_chars",{chars:e})})),wPe=({label:e,chars:t=null,tone:n="live",title:r,onClear:i,clearLabel:a,className:s,style:o,small:l=!1})=>d.jsxs("span",{className:R("inline-flex max-w-full items-center justify-between gap-1.5 px-3 text-ink",n==="warning"?vPe:bPe,l?"text-body-sm":"text-body",s),title:r,style:o,children:[n==="warning"?d.jsx(eP,{"aria-hidden":"true",className:"size-3 shrink-0"}):d.jsx(pNe,{"aria-hidden":"true",className:"size-3 shrink-0"}),d.jsx("span",{className:"min-w-0 truncate",children:e}),t!==null&&d.jsx(djt,{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(ei,{"aria-hidden":"true",className:"size-3"})}),r&&d.jsx("span",{className:"sr-only",children:r})]}),Sb="#lo-credential/",fjt=`${Sb}unstored`,ste=`${Sb}unconfirmed`,hjt=/^\d+$/,xPe=e=>e.kind==="stored"?`${Sb}${e.key??""}/${e.chars??0}`:e.kind==="unconfirmed"?e.key?`${ste}/${e.key}`:ste:fjt;function pjt(e){if(!e||!e.startsWith(Sb))return null;const t=e.slice(Sb.length);if(t==="unstored")return{kind:"unstored"};if(t==="unconfirmed")return{kind:"unconfirmed",key:""};if(t.startsWith("unconfirmed/")){const a=t.slice(12);return F7.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!F7.test(r)||!hjt.test(i)?null:{kind:"stored",key:r,chars:Number.parseInt(i,10)}}function ote(e,t){const n=pjt(e);if(n===null)return null;const r=jT(t);if(r.length!==1||r[0].kind==="text")return null;const i=r[0];return xPe(i)!==e?null:n}const NT=()=>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 s=jT(a.value);if(s.length===1&&s[0].kind==="text"){r.push(a);continue}i=!0;for(const o of s){if(o.kind==="text"){r.push({type:"text",value:o.text});continue}r.push({type:"link",url:xPe(o),title:o.text,children:[{type:"text",value:o.text}]})}}i&&(n.children=r)};t(e)},mjt=e=>e.kind==="stored"?e.key:e.kind==="unconfirmed"?Eqt(e.key):h("ui.chat.page_chrome.credential_not_stored"),gjt=(e,t)=>e.kind==="unconfirmed"&&t!==void 0?Xqt(t):t,$jt=({citation:e,title:t})=>(ke(),d.jsx(wPe,{tone:e.kind==="stored"?"live":"warning",label:mjt(e),chars:e.kind==="stored"?e.chars:null,title:gjt(e,t),className:"align-middle"})),yjt=(e,t)=>typeof t=="string"?ote(e,t):t==null?ote(e,""):null,bjt=e=>({href:t,title:n,children:r})=>{const i=yjt(t,r);if(i===null){const a=e;return d.jsx(a,{href:t,title:n,children:r})}return d.jsx($jt,{citation:i,title:n})},_Pe=e=>Pct(e)?"artifact":e.startsWith("data:")?"data":e.startsWith("blob:")||S0e(e)?"blob":e.startsWith("http://")||e.startsWith("https://")?"http":e.startsWith("file://")||e.startsWith("/")||e.startsWith("~")?"path":"other",AW=e=>{const t=_Pe(e);return t==="other"?"path":t},z4={id:"open-file",get label(){return h("ui.common.file_actions.open_file")}},vjt={id:"show-in-canvas",get label(){return h("ui.common.file_actions.show_in_canvas")}},wjt={id:"save-as",get label(){return h("ui.chat.image_actions.save_as")}},U4={id:"open-folder",get label(){return h("ui.common.file_actions.open_folder")}},I4={id:"copy-file-path",get label(){return h("ui.common.file_actions.copy_file_path")}},up={id:"copy-image",get label(){return h("ui.chat.image_actions.copy_image")}},xjt={id:"copy-image-url",get label(){return h("ui.chat.image_actions.copy_image_url")}},_jt={id:"open-in-browser",get label(){return h("ui.chat.image_actions.open_in_browser")}};function SPe(e,{canShowInCanvas:t,source:n,mediaKind:r,artifactPathActions:i,canExpand:a}){const s=[...t?[vjt]:[],...a?[{id:"expand-image",get label(){return h("ui.chat.image_actions.expand_image")}}]:[]];switch(e){case"artifact":return[...s,...i?[z4,U4,I4]:[],wjt,...r==="video"||r==="audio"?[]:[up]];case"path":return[...s,z4,U4,I4,...r==="video"||r==="audio"?[]:[up]];case"data":return[...s,up];case"blob":return i?[...s,z4,U4,I4,up]:[up];case"http":return[...Sjt(n)?[up]:[],xjt,_jt];case"other":return[]}}const kPe=(e,t)=>SPe(e,t).length>0;function Sjt(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 qW=e=>e.startsWith("file://")?e.slice(7):e;function QPe(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 o=atob(r),l=new Uint8Array(o.length);for(let c=0;c<o.length;c+=1)l[c]=o.charCodeAt(c);return new Blob([l],{type:i})}const a=decodeURIComponent(r),s=new Uint8Array(a.length);for(let o=0;o<a.length;o+=1)s[o]=a.charCodeAt(o);return new Blob([s],{type:i})}async function lte(e,t,n){if(e==="data")return QPe(t);if(e==="blob"){const s=wfe(n??t);if(s===null)throw new Error("These image bytes are not available in this window");return s}if(e==="http"){const s=await fetch(n??t);if(!s.ok)throw new Error(`The image server answered ${s.status}`);return s.blob()}const r=window.api?.readFileBytes;if(typeof r!="function")throw new Error("This window cannot read local files");const i=qW(t),a=await r(i);if(!a.success)throw new Error(a.error??`Could not read ${i}`);return new Blob([a.data],{type:TP(i)})}const kjt=e=>e.trim().toLowerCase()!=="image/png";async function Qjt(e){if(e.size===0)throw new Error("This image has no bytes to copy");if(!kjt(e.type))return e;const t=URL.createObjectURL(e);try{const n=await Pjt(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(s=>{r.toBlob(s,"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 Pjt(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 Tjt=6e4;function Ejt(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),Tjt)}const Rjt=32*1024*1024;function twn(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 zT(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 Xjt(e){return e.sizeBytes===null||e.sizeBytes<=Rjt}function Cjt(e){return h("ui.canvas.files.remoteTooLargeToOpen",{device:e.deviceName})}function nwn(e){return e.unreadable?zT(e):null}function rwn(e,t){return t?void 0:e}function PPe(e){return e?h("ui.canvas.files.remoteUnreachable",{device:e}):h("ui.canvas.files.remoteUnreachableUnnamed")}function iwn(e,{mediaKind:t,canShowInCanvas:n,canExpand:r,landedPath:i}){const a=e.deviceName,s=e.ownerPath,o=s?[{id:"copy-owner-path",label:h("ui.canvas.files.remoteCopyOwnerPath",{device:a}),disabledReason:null,target:s}]:[];if(e.unreadable){const u=zT(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},...o,{id:"save-as",label:h("ui.chat.image_actions.save_as"),disabledReason:u,target:null}]}const l=Xjt(e),c=[];return n&&c.push({id:"show-in-canvas",label:h("ui.common.file_actions.show_in_canvas"),disabledReason:l?null:Cjt(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},...o),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 awn(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}
944
944
  ${h("ui.canvas.files.remotePeerUpdateHow",{device:n})}`:r}return Ajt}const Ajt="Remote files cannot be opened on this device.",qjt={"expand-image":d.jsx(Kde,{"aria-hidden":"true"}),"open-file":d.jsx(x1,{"aria-hidden":"true"}),"show-in-canvas":d.jsx(Hde,{"aria-hidden":"true"}),"save-as":d.jsx(iP,{"aria-hidden":"true"}),"open-folder":d.jsx($m,{"aria-hidden":"true"}),"copy-file-path":d.jsx(FN,{"aria-hidden":"true"}),"copy-image":d.jsx(Od,{"aria-hidden":"true"}),"copy-image-url":d.jsx(yNe,{"aria-hidden":"true"}),"open-in-browser":d.jsx(gm,{"aria-hidden":"true"})},cte=(e,t,n)=>n instanceof EP?t:n instanceof xm?PPe(""):e;function jjt({file:e,src:t,resolvePath:n,missing:r,onShowInCanvas:i,mediaKind:a,onExpand:s,saveName:o}){return SPe(AW(e),{canShowInCanvas:!!i,source:t??e,mediaKind:a,artifactPathActions:!!n,canExpand:!!s}).filter(l=>(l.id!=="save-as"||!!o)&&(!r||l.id==="copy-file-path"))}const TPe=({file:e,src:t,label:n,open:r,onOpenChange:i,onCloseAutoFocus:a,triggerTabIndex:s,resolvePath:o,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:f,resolveBytes:p,tooltip:m=h("ui.chat.image_actions.actions"),"aria-label":g})=>{ke();const y=AW(e),b=jjt({file:e,src:t,resolvePath:o,missing:l,onShowInCanvas:c,mediaKind:u,onExpand:O,saveName:f});if(b.length===0)return null;const v=async(k,Q,X)=>{try{await navigator.clipboard.writeText(k),ul(Q)}catch(C){console.error(`${X}: `,C),lr(X)}},x=async()=>{try{if(typeof ClipboardItem>"u")throw new Error("this window cannot write an image to the clipboard");const k=p?await p():await lte(y,e,t),Q=await Qjt(k);await navigator.clipboard.write([new ClipboardItem({[Q.type]:Q})]),ul(h("ui.notices.files.image_copied"))}catch(k){console.error("Failed to copy image: ",k),lr(cte(h("ui.notices.files.image_copy_failed"),h("ui.notices.files.image_copy_failed_gone"),k))}},S=async()=>{try{const k=p?await p():await lte(y,e,t);Ejt(k,f??"download")}catch(k){console.error("Failed to save file: ",k),lr(cte(h("ui.notices.files.save_failed"),h("ui.notices.files.save_failed_gone"),k))}},w=async k=>{let Q=qW(e);if(o&&["open-file","open-folder","copy-file-path"].includes(k.id))try{Q=await o()}catch{lr(h("ui.canvas.files.prepareError"));return}switch(k.id){case"expand-image":O?.();return;case"open-file":Ru(Q);return;case"open-folder":XT(Q);return;case"show-in-canvas":c?.();return;case"copy-file-path":v(Q,"File path copied to clipboard","Failed to copy file path");return;case"copy-image":x();return;case"save-as":S();return;case"copy-image-url":v(t??e,"Image URL copied to clipboard","Failed to copy image URL");return;case"open-in-browser":EW(t??e);return}},_=g??(n!=null?h("ui.common.actions.actions_for_name",{name:n}):h("ui.chat.image_actions.actions"));return d.jsxs(tP,{open:r,onOpenChange:i,children:[d.jsx(kt,{content:m,children:d.jsx(nP,{asChild:!0,children:d.jsx(Se,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":_,tabIndex:s,onClick:k=>k.stopPropagation(),children:d.jsx(aS,{"aria-hidden":"true"})})})}),d.jsxs(rP,{onCloseAutoFocus:a,align:"end",className:"min-w-45",onClick:k=>k.stopPropagation(),children:[o&&d.jsx("div",{role:"note",className:R("max-w-64 px-2 py-1 text-meta text-ink-muted"),children:h("ui.canvas.files.pathCopyNote")}),b.map(k=>d.jsxs(uo,{onSelect:()=>w(k),children:[qjt[k.id],d.jsx("span",{children:k.label})]},k.id))]})]})},Njt=({src:e,alt:t,title:n,className:r})=>{const i=ov(),a=e??"",s=_Pe(a);if(s==="other")return d.jsx("img",{src:e,alt:t,title:n,className:r});const o=i!==null&&s==="path",l=kPe(s,{canShowInCanvas:o,source:a});return d.jsxs("span",{className:R("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:R("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(TPe,{file:a,src:e,label:t,onShowInCanvas:o&&i?()=>{i.openInCanvas(a).then(c=>{c||Ru(qW(a))})}:void 0})})]})};function zjt(){return{enter:{mathFlow:e,mathFlowFenceMeta:t,mathText:a},exit:{mathFlow:i,mathFlowFence:r,mathFlowFenceMeta:n,mathFlowValue:o,mathText:s,mathTextData:o}};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 s(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 o(l){this.config.enter.data.call(this,l),this.config.exit.data.call(this,l)}}const Ujt={tokenize:Ijt,concrete:!0,name:"mathFlow"},ute={tokenize:Wjt,partial:!0};function Ijt(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 s=0;return o;function o(v){return e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),l(v)}function l(v){return v===36?(e.consume(v),s++,l):s<2?n(v):(e.exit("mathFlowFenceSequence"),$n(e,c,"whitespace")(v))}function c(v){return v===null||Rt(v)?O(v):(e.enter("mathFlowFenceMeta"),e.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||Rt(v)?(e.exit("chunkString"),e.exit("mathFlowFenceMeta"),O(v)):v===36?n(v):(e.consume(v),u)}function O(v){return e.exit("mathFlowFence"),r.interrupt?t(v):e.attempt(ute,f,y)(v)}function f(v){return e.attempt({tokenize:b,partial:!0},y,p)(v)}function p(v){return(a?$n(e,m,"linePrefix",a+1):m)(v)}function m(v){return v===null?y(v):Rt(v)?e.attempt(ute,f,y)(v):(e.enter("mathFlowValue"),g(v))}function g(v){return v===null||Rt(v)?(e.exit("mathFlowValue"),m(v)):(e.consume(v),g)}function y(v){return e.exit("mathFlow"),t(v)}function b(v,x,S){let w=0;return $n(v,_,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4);function _(X){return v.enter("mathFlowFence"),v.enter("mathFlowFenceSequence"),k(X)}function k(X){return X===36?(w++,v.consume(X),k):w<s?S(X):(v.exit("mathFlowFenceSequence"),$n(v,Q,"whitespace")(X))}function Q(X){return X===null||Rt(X)?(v.exit("mathFlowFence"),x(X)):S(X)}}}function Wjt(e,t,n){const r=this;return i;function i(s){return s===null?t(s):(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),a)}function a(s){return r.parser.lazy[r.now().line]?n(s):t(s)}}function Djt(e){let n={}.singleDollarTextMath;return n==null&&(n=!0),{tokenize:r,resolve:Yjt,previous:Gjt,name:"mathText"};function r(i,a,s){let o=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),o++,O):o<2&&!n?s(g):(i.exit("mathTextSequence"),f(g))}function f(g){return g===null?s(g):g===36?(c=i.enter("mathTextSequence"),l=0,m(g)):g===32?(i.enter("space"),i.consume(g),i.exit("space"),f):Rt(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||Rt(g)?(i.exit("mathTextData"),f(g)):(i.consume(g),p)}function m(g){return g===36?(i.consume(g),l++,m):l===o?(i.exit("mathTextSequence"),i.exit("mathText"),a(g)):(c.type="mathTextData",p(g))}}}function Yjt(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 Gjt(e){return e!==36||this.events[this.events.length-1][1].type==="characterEscape"}function Ljt(e){return{flow:{36:Ujt},text:{36:Djt()}}}function EPe(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 Hl=92,Mjt=40,Zjt=41,RPe=91,jW=93,H7=32,MO=e=>e!==null&&e<-2,Bo=e=>e===H7||e===-2||e===-1,XPe=e=>e===94||e===95||e===123||e===125,CPe=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122||e===123||e===125),W4=new WeakMap,Ote=new WeakMap,APe=e=>Object.prototype.hasOwnProperty.call(e,"interrupt")?Object.getPrototypeOf(e):e,K7="mathTextDisplay";function Vjt(e,t,n){let r=Zjt,i=!1,a,s=!1,o=!1,l=0,c;const u=this,O={tokenize:k,partial:!0};return f;function f(Q){return Q!==Hl?n(Q):(l=u.now().offset,c=APe(u),a=e.enter("mathText"),e.enter("mathTextSequence"),e.consume(Q),p)}function p(Q){if(Q===RPe)r=jW,i=!0,a.type=K7;else if(Q!==Mjt)return n(Q);const X=W4.get(c)?.get(r);return X!==void 0&&l>X?n(Q):(e.consume(Q),e.exit("mathTextSequence"),m)}function m(Q){return Q===null?x(Q):Q===Hl?e.check(O,w,g)(Q):Q===H7?(e.enter("space"),e.consume(Q),e.exit("space"),m):MO(Q)?(e.enter("lineEnding"),e.consume(Q),e.exit("lineEnding"),m):g(Q)}function g(Q){return e.enter("mathTextData"),Q===Hl?b(Q):y(Q)}function y(Q){return Q===null||Q===H7||MO(Q)?(e.exit("mathTextData"),m(Q)):Q===Hl?e.check(O,S,b)(Q):(s=!0,XPe(Q)&&(o=!0),e.consume(Q),y)}function b(Q){return s=!0,e.consume(Q),v}function v(Q){return Q===null||MO(Q)||Bo(Q)?y(Q):(CPe(Q)&&(o=!0),e.consume(Q),y)}function x(Q){let X=W4.get(c);X||(X=new Map,W4.set(c,X));const C=X.get(r);return(C===void 0||l<C)&&X.set(r,l),n(Q)}function S(Q){return e.exit("mathTextData"),w(Q)}function w(Q){return!s||i&&!o?n(Q):(e.enter("mathTextSequence"),e.consume(Q),_)}function _(Q){return e.consume(Q),e.exit("mathTextSequence"),e.exit(a.type),t}function k(Q,X,C){return T=>(Q.enter("mathTextSequence"),Q.consume(T),A=>A!==r?C(A):(Q.consume(A),Q.exit("mathTextSequence"),X))}}const Fjt={name:"mathTextBackslash",tokenize:Vjt,resolve:EPe},Bjt={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))}},dte={partial:!0,tokenize(e,t,n){return a=>(e.enter("mathFlowFenceSequence"),e.consume(a),s=>s!==jW?n(s):(e.consume(s),e.exit("mathFlowFenceSequence"),r));function r(a){return Bo(a)?(e.enter("whitespace"),i(a)):a===null||MO(a)?t(a):n(a)}function i(a){return Bo(a)?(e.consume(a),i):(e.exit("whitespace"),a===null||MO(a)?t(a):n(a))}}};function Hjt(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,s=!1,o=0,l=!1;const c=this,u=APe(this);let O=0;return f;function f(j){if(j!==Hl)return n(j);O=c.now().offset;const U=Ote.get(u);return U&&O>U[0]&&O<U[1]?n(j):(e.enter("mathFlow"),e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(j),p)}function p(j){return j!==RPe?n(j):(e.consume(j),e.exit("mathFlowFenceSequence"),m)}function m(j){return Bo(j)?(e.enter("whitespace"),g(j)):y(j)}function g(j){return Bo(j)?(e.consume(j),g):(e.exit("whitespace"),y(j))}function y(j){return j===null?v(j):(e.exit("mathFlowFence"),s=!0,w(j))}function b(j){return s?e.attempt(Bjt,x,v)(j):v(j)}function v(j){return l||Ote.set(u,[O,c.now().offset]),n(j)}function x(j){return s=!1,o=i,o>0&&Bo(j)?(e.enter("linePrefix"),S(j)):w(j)}function S(j){return o>0&&Bo(j)?(o--,e.consume(j),S):(e.exit("linePrefix"),w(j))}function w(j){return j===null?v(j):MO(j)?b(j):j===Hl?e.check(dte,T,_)(j):_(j)}function _(j){return e.enter("mathFlowValue"),j===Hl?Q(j):k(j)}function k(j){return j===null||MO(j)?(e.exit("mathFlowValue"),w(j)):j===Hl?e.check(dte,C,Q)(j):(Bo(j)||(s=!0),XPe(j)&&(a=!0),e.consume(j),k)}function Q(j){return s=!0,e.consume(j),X}function X(j){return j===null||MO(j)||Bo(j)?k(j):j===jW?(l=!0,n(j)):(CPe(j)&&(a=!0),e.consume(j),k)}function C(j){return e.exit("mathFlowValue"),T(j)}function T(j){return a?(e.enter("mathFlowFence"),e.enter("mathFlowFenceSequence"),e.consume(j),A):(l=!0,n(j))}function A(j){return e.consume(j),e.exit("mathFlowFenceSequence"),z}function z(j){return Bo(j)?(e.enter("whitespace"),Y(j)):G(j)}function Y(j){return Bo(j)?(e.consume(j),Y):(e.exit("whitespace"),G(j))}function G(j){return e.exit("mathFlowFence"),e.exit("mathFlow"),t(j)}}const Kjt={name:"mathFlowBracket",tokenize:Hjt,concrete:!0},Jjt={flow:{[Hl]:[Kjt]},text:{[Hl]:[Fjt]}},e7t={enter:{[K7](e){this.enter({type:"inlineMath",value:"",data:{hName:"code",hProperties:{className:["language-math","math-display"]},hChildren:[]}},e),this.buffer()}},exit:{[K7](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})}}},Ip=36,fte=e=>e!==null&&e<-2,hte=e=>e===null||e===32||e<0,pte=e=>e!==null&&e>=48&&e<=57,mte=92,t7t=e=>e===94||e===95||e===123||e===125,gte=e=>e!==null&&(e>=65&&e<=90||e>=97&&e<=122),n7t=e=>e===44||e===46||e===59||e===58||e===33||e===63,r7t=96,qPe=e=>{const t=e?.singleDollarTextMath??!0;return{tokenize:n,resolve:EPe,previous:i7t,name:"mathText"};function n(r,i,a){const s=this;let o=0,l=null,c=!1,u=!1,O=!1,f=0,p=0,m="letters",g=!1,y=!1,b=!1,v,x;return S;function S(T){return r.enter("mathText"),r.enter("mathTextSequence"),w(T)}function w(T){return T===Ip?(r.consume(T),o++,w):o<2&&!t||o===1&&hte(T)?a(T):(c=o===1&&pte(T),r.exit("mathTextSequence"),_(T))}function _(T){return T===null?a(T):T===Ip?(x=r.enter("mathTextSequence"),v=0,l=s.previous,C(T)):T===32?(r.enter("space"),r.consume(T),r.exit("space"),_):fte(T)?(r.enter("lineEnding"),r.consume(T),r.exit("lineEnding"),_):(r.enter("mathTextData"),p=0,m="letters",X(T))}function k(){const T=m!=="other"&&p>=2&&f===0;T&&g&&(y=!0),g=T}function Q(T,A){T===r7t&&(b=!0),!A&&T===123&&f++,!A&&T===125&&f>0&&f--,m==="letters"&&!A&&gte(T)?p++:m==="letters"&&p>=2&&n7t(T)?m="punct":m="other"}function X(T){return T===null||T===32||T===Ip||fte(T)?(O=!1,k(),r.exit("mathTextData"),_(T)):(Q(T,O||T===mte),O?(u=!0,O=!1):T===mte?O=!0:t7t(T)&&(u=!0),r.consume(T),X)}function C(T){return T===Ip?(r.consume(T),v++,C):v===o?o===1&&(hte(l)||pte(T))||o===1&&c&&!u||o===1&&c&&(gte(T)||T===95||b||y)?a(T):(r.exit("mathTextSequence"),r.exit("mathText"),i(T)):(x.type="mathTextData",X(T))}}};function i7t(e){return e!==Ip||this.events[this.events.length-1][1].type==="characterEscape"}const a7t=Ljt().flow,s7t=qPe();function UT(e){const t=this.data();t.micromarkExtensions??=[],t.fromMarkdownExtensions??=[];const n=t.micromarkExtensions,r=t.fromMarkdownExtensions,i=e?.singleDollarTextMath===void 0?s7t:qPe(e);n.push({flow:a7t,text:{[Ip]:i}}),n.push(Jjt),r.push(zjt()),r.push(e7t)}const o7t=/\$(?!\d)(.+?)\$/,l7t=/\$\$([\s\S]+?)\$\$/,c7t=/\\begin\{([^}]+)\}([\s\S]+?)\\end\{\1\}/,u7t=/\\[a-zA-Z]+(\{[^}]*\})?/,O7t=/\\\([\s\S]+?\\\)/,d7t=/\\\[[\s\S]+?\\\]/,f7t=/^ {0,3}(?:`{3,}|~{3,})[ \t]*math[ \t]*$/m,h7t=/(?<![\\$])\$(?=\d)([^$]*)\$(?![\dA-Za-z_])/g,p7t=/\\[^ \r\n$]|[\^_{}]/,m7t=/[^ \t\r\n]$/,g7t=/^[A-Za-z]{2,}[,.;:!?]?$/,$7t=e=>{let t=0,n=!1,r=!1,i="";const a=()=>{if(i==="")return!1;const s=t===0&&g7t.test(i),o=s&&r;return r=s,i="",o};for(const s of e){if(s===" "||s===`
945
- `||s==="\r"){if(n=!1,a())return!0;continue}i+=n||s==="\\"?"\0":s,!n&&s==="{"&&t++,!n&&s==="}"&&t>0&&t--,n=!n&&s==="\\"}return a()},y7t=e=>{const t=new RegExp(h7t.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(m7t.test(r)&&p7t.test(r)&&!r.includes("`")&&!$7t(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},$te=e=>o7t.test(e)||l7t.test(e)||O7t.test(e)||d7t.test(e)||f7t.test(e)||y7t(e)||c7t.test(e)?!0:u7t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),b7t=e=>{const t=jT(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},v7t=e=>jT(e).filter(t=>t.kind!=="text").length,w7t=e=>{if(!$te(e))return!1;const t=b7t(e);return t===null?!0:$te(t)||t.includes("$")?!1:v7t(e)<2},jPe=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),NPe=Object.freeze(DN.filter(e=>!["overlayShadow","scrim"].includes(e))),zPe=65536,UPe=/^#[0-9a-fA-F]{6}$/,x7t=(e,t)=>Object.hasOwn(e,t),yte=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),qa=e=>{throw new Error(e)},_7t={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"]},kb=(e,t)=>{const n={...e};for(const r of jPe){const i=xCe(t.seeds?.[r]);if(!i)continue;const a=h5(e[r]),s=h5(i);n[r]=i;for(const o of _7t[r]){const l=h5(e[o]);n[o]=_Ce({l:s.l+l.l-a.l,c:a.c>.01?s.c*l.c/a.c:l.c,h:s.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=SCe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of NPe)UPe.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},NW=(e,t)=>vCe(e,t),swn=(e,t)=>{const n=kb(e,t),r=PCe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(o=>r[o]!==n[o]))return null;const a={...t.overrides};for(const o of NPe)r[o]!==n[o]&&(a[o]=r[o]);const s={...t,overrides:a};return NW(kb(e,s),t.base).length?null:s},IPe=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>zPe)&&qa("import_size");let i;try{i=JSON.parse(e)}catch{qa("import_invalid_json")}yte(i)||qa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(o=>!a.has(o))&&qa("import_unsafe"),i.format!=="local-operator-theme"&&qa("import_format"),i.version!==1&&qa("import_version"),(typeof i.base!="string"||!t(i.base))&&qa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&qa("import_name");const s={};for(const o of["seeds","overrides"]){(!x7t(i,o)||!yte(i[o]))&&qa("import_roles");const l={};for(const[c,u]of Object.entries(i[o]))(!(o==="seeds"?jPe:DN).includes(c)||typeof u!="string")&&qa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||qa("import_roles"),l[c]=u):(UPe.test(u)||qa("import_roles"),l[c]=u.toUpperCase());s[o]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...s,updatedAt:r}},S7t=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>zPe*B_)&&qa("load_error");let n;try{n=JSON.parse(e)}catch{qa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||qa("load_error");const i=[],a=new Set;for(const s of r.slice(0,B_))try{const o=wCe(s,{isThemeName:t,isRole:c=>DN.includes(c)});if(!o||a.has(o.id))continue;const l=IPe(JSON.stringify(s),t,{id:o.id,now:o.updatedAt});i.push(l),a.add(l.id)}catch{}return i},k7t=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),own=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=B_+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},lwn=(e,t)=>{const n=kCe({composed:!0,capturePairs:!0});return QCe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let cd={themes:[],error:!1,loading:!1};const J7=new Set,WPe=()=>{for(const e of J7)e()},bte=()=>cd,Q7t=e=>(J7.add(e),()=>{J7.delete(e)}),vte=()=>{try{cd={themes:S7t(localStorage.getItem(kN),IOe).filter(t=>{const n=wN(t.base)?.palette;return n&&NW(kb(n,t),t.base).length===0}),error:!1,loading:!1}}catch{cd={themes:[],error:!0,loading:!1}}WPe()},zW=()=>$.useSyncExternalStore(Q7t,bte,bte),P7t=e=>cd.themes.find(t=>t.id===e),DPe=e=>{localStorage.setItem(kN,JSON.stringify({version:1,themes:e})),cd={themes:e,error:!1,loading:!1},WPe()},cwn=e=>{const t=TCe(e.id);if(!t)throw new Error("invalid custom theme id");const n=IPe(k7t(e),IOe,{id:t,now:e.updatedAt}),r=wN(n.base)?.palette;if(!r||NW(kb(r,n),n.base).length)throw new Error("contrast");if(!P7t(n.id)&&cd.themes.length>=B_)throw new Error("limit");DPe([n,...cd.themes.filter(i=>i.id!==n.id)])},uwn=e=>DPe(cd.themes.filter(t=>t.id!==e));typeof window<"u"&&(vte(),window.addEventListener("storage",e=>{(e.key===kN||e.key===null)&&vte()}));const T7t=()=>{const e=Ht(i=>i.themeName),t=Ht(i=>i.contrast),n=Ht(i=>i.accent),r=Ht(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},E7t=e=>{const t=e?wN(e.base)?.palette:void 0;return t&&e?kb(t,e):void 0},R7t=()=>{const e=T7t(),t=zW();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=E7t(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:ECe(e,r,i)}},[e,t])},IT=()=>R7t().resolved,Own=()=>IT().palette.mode==="dark",un="var(--color-ink)",Ec="var(--color-ink-muted)",Al="var(--color-surface)",uO="var(--color-elevated)",Rc="var(--color-sunken)",fa="var(--color-hairline)",OO="var(--color-control)",Op="var(--color-accent)",T$="var(--color-accent-wash)",X7t="var(--color-accent-alt-wash)",C7t="var(--color-on-accent)",A7t="var(--color-info)",YPe="var(--color-info-wash)",q7t="var(--color-success)",GPe="var(--color-success-wash)",j7t="var(--color-warning)",e9="var(--color-warning-wash)",N7t="var(--color-warning-border)",D4="var(--color-danger)",t9="var(--color-danger-wash)",wte=[T$,X7t,YPe,GPe,e9,t9],dO=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),z7t=()=>{const e={primaryColor:dO("--color-accent"),secondaryColor:dO("--color-success"),tertiaryColor:dO("--color-info"),mainBkg:dO("--color-elevated"),clusterBkg:dO("--color-sunken"),clusterBorder:dO("--color-hairline"),edgeLabelBackground:dO("--color-surface"),quadrant1Fill:dO("--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:Al,primaryTextColor:un,primaryBorderColor:OO,secondaryTextColor:un,secondaryBorderColor:fa,tertiaryTextColor:un,tertiaryBorderColor:fa,lineColor:Ec,arrowheadColor:Ec,textColor:un,secondBkg:Rc,border1:OO,border2:fa,labelColor:un,nodeBkg:uO,nodeBorder:OO,nodeTextColor:un,defaultLinkColor:Ec,titleColor:un,noteBkgColor:e9,noteBorderColor:N7t,noteTextColor:un,actorBkg:uO,actorBorder:OO,actorTextColor:un,actorLineColor:fa,signalColor:Ec,signalTextColor:un,labelBoxBkgColor:uO,labelBoxBorderColor:fa,labelTextColor:un,loopTextColor:un,activationBkgColor:T$,activationBorderColor:Op,sequenceNumberColor:Al,sectionBkgColor:Rc,sectionBkgColor2:Al,altSectionBkgColor:Rc,excludeBkgColor:Rc,taskBkgColor:T$,taskBorderColor:OO,taskTextColor:un,taskTextLightColor:un,taskTextDarkColor:un,taskTextOutsideColor:un,taskTextClickableColor:Op,activeTaskBkgColor:T$,activeTaskBorderColor:Op,gridColor:fa,doneTaskBkgColor:Rc,doneTaskBorderColor:fa,critBkgColor:t9,critBorderColor:D4,todayLineColor:Op,transitionColor:Ec,transitionLabelColor:un,stateLabelColor:un,stateBkg:uO,labelBackgroundColor:Al,compositeBackground:Rc,altBackground:Rc,compositeTitleBackground:uO,compositeBorder:fa,innerEndBackground:un,specialStateColor:un,classText:un,attributeBackgroundColorOdd:Al,attributeBackgroundColorEven:Rc,rowOdd:Al,rowEven:Rc,errorBkgColor:t9,errorTextColor:D4,pieTitleTextColor:un,pieSectionTextColor:un,pieLegendTextColor:un,pieStrokeColor:Al,pieOuterStrokeColor:fa,requirementBackground:uO,requirementBorderColor:OO,requirementTextColor:un,relationColor:Ec,relationLabelBackground:Al,relationLabelColor:un,branchLabelColor:C7t,commitLabelColor:un,commitLabelBackground:Al,tagLabelColor:un,tagLabelBackground:T$,tagLabelBorder:OO,quadrant2Fill:YPe,quadrant3Fill:GPe,quadrant4Fill:e9,quadrant2TextFill:un,quadrant3TextFill:un,quadrant4TextFill:un,quadrantPointFill:Op,archEdgeColor:Ec,archEdgeArrowColor:Ec,archGroupBorderColor:fa,scaleLabelColor:un,packet:{startByteColor:un,endByteColor:un,labelColor:un,titleColor:un,blockStrokeColor:OO,blockFillColor:uO},radar:{axisColor:Ec,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:fa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Al,titleColor:un,xAxisTitleColor:un,xAxisLabelColor:un,xAxisTickColor:fa,xAxisLineColor:fa,yAxisTitleColor:un,yAxisLabelColor:un,yAxisTickColor:fa,yAxisLineColor:fa,plotColorPalette:[Op,A7t,q7t,j7t,D4].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=uO,t[`surfacePeer${n}`]=fa;for(let n=0;n<8;n++)t[`fillType${n}`]=wte[n%wte.length];return{...t,...e}};let Y4=null,xte=null;const U7t=async e=>{Y4||(Y4=Pe(async()=>{const{default:n}=await import("./mermaid.core-dEA97al4.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await Y4;return xte!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:z7t()}),xte=e),t},_te=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:s,children:o})=>d.jsxs("div",{"data-lo-floating":"",className:R("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx(kt,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(afe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx(sfe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(GNe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(oP,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(iP,{})})}),d.jsx(kt,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:s,children:d.jsx(Od,{className:R(t&&"text-success")})})}),o]}),n9=({title:e,children:t})=>d.jsxs(bo,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(Ep,{children:e}),d.jsx(tS,{children:t})]}),I7t=({error:e})=>(ke(),d.jsxs(n9,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class W7t 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(I7t,{error:this.state.error}):this.props.children}}const D7t=$.memo(({chart:e,id:t})=>{ke();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[s,o]=$.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,b]=$.useState(!1),[v,x]=$.useState({x:0,y:0}),[S,w]=$.useState("idle"),[_,k]=$.useState("idle"),Q=IT().id,X=$.useCallback(async()=>{try{if(o(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const W=await U7t(Q),fe=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:te}=await W.render(fe,e);if(!te||typeof te!="string"||te.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(te)}catch(W){console.error("Mermaid rendering error:",W);const fe=W instanceof Error?W.message:"Failed to render mermaid diagram";a(fe),c("")}finally{o(!1)}},[e,t,Q]);$.useEffect(()=>{X().catch(W=>{console.error("Error in renderDiagram effect:",W),a("Failed to initialize diagram rendering"),o(!1)})},[X]);const C=$.useCallback(()=>{try{if(!l||!r.current)return 1;const fe=r.current.getBoundingClientRect(),te=document.createElement("div");te.innerHTML=l;const M=te.querySelector("svg");if(!M)return 1;const ie=M.getBoundingClientRect?.()?.width||Number.parseFloat(M.getAttribute("width")||"0")||M.viewBox?.baseVal?.width||800,ee=M.getBoundingClientRect?.()?.height||Number.parseFloat(M.getAttribute("height")||"0")||M.viewBox?.baseVal?.height||600,F=fe.width*.9/ie,H=fe.height*.9/ee;return Math.min(F,H,1)}catch(W){return console.error("Error calculating fullscreen scale:",W),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const W=C();g({scale:W,x:0,y:0})}catch(W){console.error("Error setting fullscreen transform:",W)}},100)},[u,l,C]);const T=$.useCallback((W=!1)=>{try{(W?g:p)(te=>({...te,scale:Math.min(te.scale*1.2,10)}))}catch(fe){console.error("Error in zoom in:",fe)}},[]),A=$.useCallback((W=!1)=>{try{(W?g:p)(te=>({...te,scale:Math.max(te.scale/1.2,.1)}))}catch(fe){console.error("Error in zoom out:",fe)}},[]),z=$.useCallback((W=!1)=>{try{const fe=W?g:p;if(W){const te=C();fe({scale:te,x:0,y:0})}else fe({scale:1,x:0,y:0})}catch(fe){console.error("Error in reset:",fe)}},[C]),Y=$.useCallback(()=>{if(l)try{const W=new Blob([l],{type:"image/svg+xml"}),fe=URL.createObjectURL(W),te=document.createElement("a");te.href=fe,te.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(fe)}catch(W){console.error("Failed to save SVG:",W)}},[l]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(W){console.error("Failed to copy Mermaid chart text:",W)}},[e]),j=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(W){console.error("Failed to copy Mermaid chart text:",W)}},[e]),U=$.useCallback(W=>{try{b(!0),x({x:W.clientX,y:W.clientY}),W.preventDefault()}catch(fe){console.error("Error in mouse down:",fe)}},[]),D=$.useCallback((W,fe=!1)=>{try{if(!y)return;const te=W.clientX-v.x,M=W.clientY-v.y;(fe?g:p)(ee=>({...ee,x:ee.x+te,y:ee.y+M})),x({x:W.clientX,y:W.clientY})}catch(te){console.error("Error in mouse move:",te)}},[y,v]),Z=$.useCallback(()=>{try{b(!1)}catch(W){console.error("Error in mouse up:",W)}},[]),N=$.useCallback((W,fe=!1)=>{try{W.preventDefault();const te=W.deltaY>0?.9:1.1;(fe?g:p)(ie=>({...ie,scale:Math.min(Math.max(ie.scale*te,.1),5)}))}catch(te){console.error("Error in wheel:",te)}},[]),L=$.useCallback(W=>{try{O(W)}catch(fe){console.error("Error toggling fullscreen:",fe)}},[]);if(i)return d.jsxs(n9,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:R("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:R("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(W=!1)=>{try{const fe=W?r:n,te=W?m:f;return d.jsx("div",{ref:fe,className:R("mermaid flex w-full items-center justify-center",W?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:M=>D(M,W),onMouseUp:Z,onMouseLeave:Z,onWheel:M=>N(M,W),children:s?d.jsx("div",{className:R("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:R("flex h-full w-full items-center justify-center"),style:{transform:`translate(${te.x}px, ${te.y}px) scale(${te.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(fe){return console.error("Error rendering diagram content:",fe),d.jsx(n9,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:R("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),d.jsx(_te,{className:"top-2 right-2",copied:S==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>A(!1),onReset:()=>z(!1),onSave:Y,onCopy:G,children:d.jsx(kt,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>L(!0),children:d.jsx(Kde,{})})})})]}),d.jsx(ym,{open:u,onClose:()=>L(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:R("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),d.jsx(_te,{className:"top-4 right-4",copied:_==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>A(!0),onReset:()=>z(!0),onSave:Y,onCopy:j,children:d.jsx(kt,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>L(!1),children:d.jsx(ei,{})})})})]})})]})}),Y7t=$.memo(e=>d.jsx(W7t,{children:d.jsx(D7t,{...e})}));let LPe=!1,G4=null;const G7t=()=>(G4||(G4=Pe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(LPe=!0,e))),G4),L7t=/language-(\w+)/,M7t=QN,Z7t=new RegExp(`^[^${vu}\\d*+-]`),V7t=/\n$/,MPe=({href:e,children:t})=>{const n=zQe(e),r=ov();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=>H7t(i,r):void 0,children:t})},F7t=e=>zQe(e)?.kind==="file",B7t=DQe,H7t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(WQe)??"file",i=n.getAttribute(B7t),a=ACt({kind:r,hasHighlight:KCt(n),canOpenInCanvas:TW(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(s=>{s||Ru(i)});return}Ru(i)}},r9=(e,t)=>t==="href"&&F7t(e)?e:fpe(e),Qb={a:MPe,table:Dz,img:Njt,code:({node:e,className:t,children:n,...r})=>L7t.exec(t??"")?.[1]==="mermaid"?d.jsx(Y7t,{chart:String(n).replace(V7t,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},K7t={...Qb,a:bjt(MPe)},J7t=[So,Ol],e9t=[So,Ol,UT],t9t=[So,Ol,CT],n9t=[So,Ol,UT,CT],r9t=[So,Ol,NT,AT],i9t=[So,Ol,UT,NT,AT],a9t=[So,Ol,CT,NT,AT],s9t=[So,Ol,UT,CT,NT,AT],o9t={"000":J7t,"001":r9t,"010":t9t,"011":a9t,100:e9t,101:i9t,110:n9t,111:s9t},l9t=[],c9t={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},u9t=[[_ct,c9t]],ZPe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),VPe=(e,t,n,r)=>{const i=$.useMemo(()=>w7t(e),[e]),[a,s]=$.useState(LPe),o=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return G7t().then(()=>{O||s(!0)}),()=>{O=!0}},[i,a]);const l=o9t[`${o?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[DAt,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:o?u9t:l9t}},FPe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=Zct(e);if(i.length===0)return;let a=!0;const s=new Set(i),o=zCt(l=>{a&&l.some(c=>s.has(c))&&r(c=>c+1)});return PW(i,window.api?.probeFiles,tde,jCt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>IQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,o()}},[e,t,n])},Pb=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:s})=>{const o=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=VPe(o,r,i,a),u=ZPe(t);return FPe(o,r,s),d.jsx("div",{className:R("lo-markdown",n),style:u,children:d.jsx(Gy,{remarkPlugins:l,rehypePlugins:c,urlTransform:r9,components:i?K7t:Qb,children:o})})});Pb.displayName="MarkdownRenderer";const Ste={...Qb,a:({children:e})=>d.jsx(d.Fragment,{children:e})},BPe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:Mee(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const s=nPe(e);return s!==null&&!s.nested?s:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=VPe(n,t,!1);if(FPe(e,t),r!==null){const s=Mee(r.before);return d.jsxs(d.Fragment,{children:[s.trim()!==""&&d.jsx(Gy,{remarkPlugins:i,rehypePlugins:a,urlTransform:r9,components:t?Qb:Ste,children:s}),d.jsx(O9t,{info:r.info,body:r.body})]})}return d.jsx(Gy,{remarkPlugins:i,rehypePlugins:a,urlTransform:r9,components:t?Qb:Ste,children:n})});BPe.displayName="ParsedBlock";const O9t=({info:e,body:t})=>{const n=e.split(M7t)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
945
+ `||s==="\r"){if(n=!1,a())return!0;continue}i+=n||s==="\\"?"\0":s,!n&&s==="{"&&t++,!n&&s==="}"&&t>0&&t--,n=!n&&s==="\\"}return a()},y7t=e=>{const t=new RegExp(h7t.source,"g");let n=t.exec(e);for(;n!==null;){const r=n[1];if(m7t.test(r)&&p7t.test(r)&&!r.includes("`")&&!$7t(r))return!0;t.lastIndex=n.index+1,n=t.exec(e)}return!1},$te=e=>o7t.test(e)||l7t.test(e)||O7t.test(e)||d7t.test(e)||f7t.test(e)||y7t(e)||c7t.test(e)?!0:u7t.test(e)&&(e.includes("\\frac")||e.includes("\\sum")||e.includes("\\int")||e.includes("\\sqrt")),b7t=e=>{const t=jT(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},v7t=e=>jT(e).filter(t=>t.kind!=="text").length,w7t=e=>{if(!$te(e))return!1;const t=b7t(e);return t===null?!0:$te(t)||t.includes("$")?!1:v7t(e)<2},jPe=Object.freeze(["canvas","surface","ink","inkMuted","accent","borderControl"]),NPe=Object.freeze(DN.filter(e=>!["overlayShadow","scrim"].includes(e))),zPe=65536,UPe=/^#[0-9a-fA-F]{6}$/,x7t=(e,t)=>Object.hasOwn(e,t),yte=e=>e!==null&&typeof e=="object"&&!Array.isArray(e)&&[Object.prototype,null].includes(Object.getPrototypeOf(e)),qa=e=>{throw new Error(e)},_7t={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"]},kb=(e,t)=>{const n={...e};for(const r of jPe){const i=xCe(t.seeds?.[r]);if(!i)continue;const a=h5(e[r]),s=h5(i);n[r]=i;for(const o of _7t[r]){const l=h5(e[o]);n[o]=_Ce({l:s.l+l.l-a.l,c:a.c>.01?s.c*l.c/a.c:l.c,h:s.h+l.h-a.h})}}n.accent.toUpperCase()!==e.accent.toUpperCase()&&(n.onAccent=SCe(n.accent,[e.onAccent,n.ink,n.canvas,"#000000","#FFFFFF"]));for(const r of NPe)UPe.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},NW=(e,t)=>vCe(e,t),swn=(e,t)=>{const n=kb(e,t),r=PCe(n,t.base,e,{pinned:Object.keys(t.overrides??{}),maxEvaluations:320,lightnessOnly:!0}).palette;if(!r||Object.keys(t.overrides??{}).some(o=>r[o]!==n[o]))return null;const a={...t.overrides};for(const o of NPe)r[o]!==n[o]&&(a[o]=r[o]);const s={...t,overrides:a};return NW(kb(e,s),t.base).length?null:s},IPe=(e,t,{id:n="custom-import",now:r=Date.now()}={})=>{(typeof e!="string"||new TextEncoder().encode(e).length>zPe)&&qa("import_size");let i;try{i=JSON.parse(e)}catch{qa("import_invalid_json")}yte(i)||qa("import_format");const a=new Set(["format","version","name","base","seeds","overrides","id","updatedAt"]);Object.keys(i).some(o=>!a.has(o))&&qa("import_unsafe"),i.format!=="local-operator-theme"&&qa("import_format"),i.version!==1&&qa("import_version"),(typeof i.base!="string"||!t(i.base))&&qa("import_base"),(typeof i.name!="string"||!i.name.trim()||i.name.trim().length>60)&&qa("import_name");const s={};for(const o of["seeds","overrides"]){(!x7t(i,o)||!yte(i[o]))&&qa("import_roles");const l={};for(const[c,u]of Object.entries(i[o]))(!(o==="seeds"?jPe:DN).includes(c)||typeof u!="string")&&qa("import_roles"),["overlayShadow","scrim"].includes(c)?(/^(0(?:\.\d{1,3})?|1(?:\.0{1,3})?)$/.test(u)||qa("import_roles"),l[c]=u):(UPe.test(u)||qa("import_roles"),l[c]=u.toUpperCase());s[o]=l}return{format:"local-operator-theme",version:1,id:n,name:i.name.trim(),base:i.base,...s,updatedAt:r}},S7t=(e,t)=>{if(e==null)return[];(typeof e!="string"||e.length>zPe*B_)&&qa("load_error");let n;try{n=JSON.parse(e)}catch{qa("load_error")}const r=Array.isArray(n)?n:n?.version===1?n.themes:null;Array.isArray(r)||qa("load_error");const i=[],a=new Set;for(const s of r.slice(0,B_))try{const o=wCe(s,{isThemeName:t,isRole:c=>DN.includes(c)});if(!o||a.has(o.id))continue;const l=IPe(JSON.stringify(s),t,{id:o.id,now:o.updatedAt});i.push(l),a.add(l.id)}catch{}return i},k7t=e=>JSON.stringify({format:"local-operator-theme",version:1,name:e.name,base:e.base,seeds:e.seeds,overrides:e.overrides},null,2),own=(e,t)=>{const n=new Set(t.map(r=>r.name));if(!n.has(e))return e;for(let r=2;r<=B_+1;r++){const i=`${e.slice(0,54)} (${r})`;if(!n.has(i))return i}return e},lwn=(e,t)=>{const n=kCe({composed:!0,capturePairs:!0});return QCe(n,{id:t,palette:e}),{findings:n.log,readings:n.readings}};let cd={themes:[],error:!1,loading:!1};const J7=new Set,WPe=()=>{for(const e of J7)e()},bte=()=>cd,Q7t=e=>(J7.add(e),()=>{J7.delete(e)}),vte=()=>{try{cd={themes:S7t(localStorage.getItem(kN),IOe).filter(t=>{const n=wN(t.base)?.palette;return n&&NW(kb(n,t),t.base).length===0}),error:!1,loading:!1}}catch{cd={themes:[],error:!0,loading:!1}}WPe()},zW=()=>$.useSyncExternalStore(Q7t,bte,bte),P7t=e=>cd.themes.find(t=>t.id===e),DPe=e=>{localStorage.setItem(kN,JSON.stringify({version:1,themes:e})),cd={themes:e,error:!1,loading:!1},WPe()},cwn=e=>{const t=TCe(e.id);if(!t)throw new Error("invalid custom theme id");const n=IPe(k7t(e),IOe,{id:t,now:e.updatedAt}),r=wN(n.base)?.palette;if(!r||NW(kb(r,n),n.base).length)throw new Error("contrast");if(!P7t(n.id)&&cd.themes.length>=B_)throw new Error("limit");DPe([n,...cd.themes.filter(i=>i.id!==n.id)])},uwn=e=>DPe(cd.themes.filter(t=>t.id!==e));typeof window<"u"&&(vte(),window.addEventListener("storage",e=>{(e.key===kN||e.key===null)&&vte()}));const T7t=()=>{const e=Ht(i=>i.themeName),t=Ht(i=>i.contrast),n=Ht(i=>i.accent),r=Ht(i=>i.customThemeId);return $.useMemo(()=>({themeName:e,contrast:t,accent:n,customThemeId:r}),[e,t,n,r])},E7t=e=>{const t=e?wN(e.base)?.palette:void 0;return t&&e?kb(t,e):void 0},R7t=()=>{const e=T7t(),t=zW();return $.useMemo(()=>{const n=t.themes.find(a=>a.id===e.customThemeId),r=E7t(n),i=n?.base;return{appearance:e,savedPalette:r,savedBase:i,resolved:ECe(e,r,i)}},[e,t])},IT=()=>R7t().resolved,Own=()=>IT().palette.mode==="dark",un="var(--color-ink)",Ec="var(--color-ink-muted)",Al="var(--color-surface)",uO="var(--color-elevated)",Rc="var(--color-sunken)",fa="var(--color-hairline)",OO="var(--color-control)",Op="var(--color-accent)",T$="var(--color-accent-wash)",X7t="var(--color-accent-alt-wash)",C7t="var(--color-on-accent)",A7t="var(--color-info)",YPe="var(--color-info-wash)",q7t="var(--color-success)",GPe="var(--color-success-wash)",j7t="var(--color-warning)",e9="var(--color-warning-wash)",N7t="var(--color-warning-border)",D4="var(--color-danger)",t9="var(--color-danger-wash)",wte=[T$,X7t,YPe,GPe,e9,t9],dO=e=>getComputedStyle(document.documentElement).getPropertyValue(e).trim(),z7t=()=>{const e={primaryColor:dO("--color-accent"),secondaryColor:dO("--color-success"),tertiaryColor:dO("--color-info"),mainBkg:dO("--color-elevated"),clusterBkg:dO("--color-sunken"),clusterBorder:dO("--color-hairline"),edgeLabelBackground:dO("--color-surface"),quadrant1Fill:dO("--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:Al,primaryTextColor:un,primaryBorderColor:OO,secondaryTextColor:un,secondaryBorderColor:fa,tertiaryTextColor:un,tertiaryBorderColor:fa,lineColor:Ec,arrowheadColor:Ec,textColor:un,secondBkg:Rc,border1:OO,border2:fa,labelColor:un,nodeBkg:uO,nodeBorder:OO,nodeTextColor:un,defaultLinkColor:Ec,titleColor:un,noteBkgColor:e9,noteBorderColor:N7t,noteTextColor:un,actorBkg:uO,actorBorder:OO,actorTextColor:un,actorLineColor:fa,signalColor:Ec,signalTextColor:un,labelBoxBkgColor:uO,labelBoxBorderColor:fa,labelTextColor:un,loopTextColor:un,activationBkgColor:T$,activationBorderColor:Op,sequenceNumberColor:Al,sectionBkgColor:Rc,sectionBkgColor2:Al,altSectionBkgColor:Rc,excludeBkgColor:Rc,taskBkgColor:T$,taskBorderColor:OO,taskTextColor:un,taskTextLightColor:un,taskTextDarkColor:un,taskTextOutsideColor:un,taskTextClickableColor:Op,activeTaskBkgColor:T$,activeTaskBorderColor:Op,gridColor:fa,doneTaskBkgColor:Rc,doneTaskBorderColor:fa,critBkgColor:t9,critBorderColor:D4,todayLineColor:Op,transitionColor:Ec,transitionLabelColor:un,stateLabelColor:un,stateBkg:uO,labelBackgroundColor:Al,compositeBackground:Rc,altBackground:Rc,compositeTitleBackground:uO,compositeBorder:fa,innerEndBackground:un,specialStateColor:un,classText:un,attributeBackgroundColorOdd:Al,attributeBackgroundColorEven:Rc,rowOdd:Al,rowEven:Rc,errorBkgColor:t9,errorTextColor:D4,pieTitleTextColor:un,pieSectionTextColor:un,pieLegendTextColor:un,pieStrokeColor:Al,pieOuterStrokeColor:fa,requirementBackground:uO,requirementBorderColor:OO,requirementTextColor:un,relationColor:Ec,relationLabelBackground:Al,relationLabelColor:un,branchLabelColor:C7t,commitLabelColor:un,commitLabelBackground:Al,tagLabelColor:un,tagLabelBackground:T$,tagLabelBorder:OO,quadrant2Fill:YPe,quadrant3Fill:GPe,quadrant4Fill:e9,quadrant2TextFill:un,quadrant3TextFill:un,quadrant4TextFill:un,quadrantPointFill:Op,archEdgeColor:Ec,archEdgeArrowColor:Ec,archGroupBorderColor:fa,scaleLabelColor:un,packet:{startByteColor:un,endByteColor:un,labelColor:un,titleColor:un,blockStrokeColor:OO,blockFillColor:uO},radar:{axisColor:Ec,axisStrokeWidth:2,axisLabelFontSize:12,curveOpacity:.5,curveStrokeWidth:2,graticuleColor:fa,graticuleStrokeWidth:1,graticuleOpacity:.3,legendBoxSize:12,legendFontSize:12},xyChart:{backgroundColor:Al,titleColor:un,xAxisTitleColor:un,xAxisLabelColor:un,xAxisTickColor:fa,xAxisLineColor:fa,yAxisTitleColor:un,yAxisLabelColor:un,yAxisTickColor:fa,yAxisLineColor:fa,plotColorPalette:[Op,A7t,q7t,j7t,D4].join(",")}};for(let n=0;n<5;n++)t[`surface${n}`]=uO,t[`surfacePeer${n}`]=fa;for(let n=0;n<8;n++)t[`fillType${n}`]=wte[n%wte.length];return{...t,...e}};let Y4=null,xte=null;const U7t=async e=>{Y4||(Y4=Pe(async()=>{const{default:n}=await import("./mermaid.core-B_TP914x.js").then(r=>r.b4);return{default:n}},__vite__mapDeps([10,1,2,3]),import.meta.url).then(({default:n})=>n));const t=await Y4;return xte!==e&&(t.initialize({startOnLoad:!0,theme:"base",securityLevel:"loose",fontFamily:"var(--font-sans)",fontSize:14,suppressErrorRendering:!0,themeVariables:z7t()}),xte=e),t},_te=({className:e,copied:t,onZoomIn:n,onZoomOut:r,onReset:i,onSave:a,onCopy:s,children:o})=>d.jsxs("div",{"data-lo-floating":"",className:R("absolute z-10 flex items-center gap-0.5 rounded-md bg-elevated p-1 shadow-overlay",e),children:[d.jsx(kt,{content:h("ui.chat.mermaid.zoom_in"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_in"),onClick:n,children:d.jsx(afe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.zoom_out"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.zoom_out"),onClick:r,children:d.jsx(sfe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.pan_hint"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.pan"),children:d.jsx(GNe,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.reset_view"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.reset_view"),onClick:i,children:d.jsx(oP,{})})}),d.jsx(kt,{content:h("ui.chat.mermaid.save_svg"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.save_svg"),onClick:a,children:d.jsx(iP,{})})}),d.jsx(kt,{content:t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":t?h("ui.chat.mermaid.copied"):h("ui.chat.mermaid.copy_text"),onClick:s,children:d.jsx(Od,{className:R(t&&"text-success")})})}),o]}),n9=({title:e,children:t})=>d.jsxs(bo,{variant:"danger",role:"alert",className:"my-4",children:[d.jsx(Ep,{children:e}),d.jsx(tS,{children:t})]}),I7t=({error:e})=>(ke(),d.jsxs(n9,{title:h("ui.chat.mermaid.error_title"),children:[e?.message||h("ui.chat.mermaid.unexpected_error")," ",h("ui.chat.mermaid.error_contained")]}));class W7t 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(I7t,{error:this.state.error}):this.props.children}}const D7t=$.memo(({chart:e,id:t})=>{ke();const n=$.useRef(null),r=$.useRef(null),[i,a]=$.useState(null),[s,o]=$.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,b]=$.useState(!1),[v,x]=$.useState({x:0,y:0}),[S,w]=$.useState("idle"),[_,k]=$.useState("idle"),Q=IT().id,X=$.useCallback(async()=>{try{if(o(!0),a(null),c(""),!e||typeof e!="string"||e.trim().length===0)throw new Error("Invalid or empty chart content");const W=await U7t(Q),fe=t||`mermaid-${Date.now()}-${Math.floor(Math.random()*1e6)}`,{svg:te}=await W.render(fe,e);if(!te||typeof te!="string"||te.trim().length===0)throw new Error("Mermaid failed to generate valid SVG output");c(te)}catch(W){console.error("Mermaid rendering error:",W);const fe=W instanceof Error?W.message:"Failed to render mermaid diagram";a(fe),c("")}finally{o(!1)}},[e,t,Q]);$.useEffect(()=>{X().catch(W=>{console.error("Error in renderDiagram effect:",W),a("Failed to initialize diagram rendering"),o(!1)})},[X]);const C=$.useCallback(()=>{try{if(!l||!r.current)return 1;const fe=r.current.getBoundingClientRect(),te=document.createElement("div");te.innerHTML=l;const M=te.querySelector("svg");if(!M)return 1;const ie=M.getBoundingClientRect?.()?.width||Number.parseFloat(M.getAttribute("width")||"0")||M.viewBox?.baseVal?.width||800,ee=M.getBoundingClientRect?.()?.height||Number.parseFloat(M.getAttribute("height")||"0")||M.viewBox?.baseVal?.height||600,F=fe.width*.9/ie,H=fe.height*.9/ee;return Math.min(F,H,1)}catch(W){return console.error("Error calculating fullscreen scale:",W),1}},[l]);$.useEffect(()=>{u&&l&&setTimeout(()=>{try{const W=C();g({scale:W,x:0,y:0})}catch(W){console.error("Error setting fullscreen transform:",W)}},100)},[u,l,C]);const T=$.useCallback((W=!1)=>{try{(W?g:p)(te=>({...te,scale:Math.min(te.scale*1.2,10)}))}catch(fe){console.error("Error in zoom in:",fe)}},[]),A=$.useCallback((W=!1)=>{try{(W?g:p)(te=>({...te,scale:Math.max(te.scale/1.2,.1)}))}catch(fe){console.error("Error in zoom out:",fe)}},[]),z=$.useCallback((W=!1)=>{try{const fe=W?g:p;if(W){const te=C();fe({scale:te,x:0,y:0})}else fe({scale:1,x:0,y:0})}catch(fe){console.error("Error in reset:",fe)}},[C]),Y=$.useCallback(()=>{if(l)try{const W=new Blob([l],{type:"image/svg+xml"}),fe=URL.createObjectURL(W),te=document.createElement("a");te.href=fe,te.download=`mermaid-diagram-${Date.now()}.svg`,document.body.appendChild(te),te.click(),document.body.removeChild(te),URL.revokeObjectURL(fe)}catch(W){console.error("Failed to save SVG:",W)}},[l]),G=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),w("copied"),setTimeout(()=>w("idle"),1200)}catch(W){console.error("Failed to copy Mermaid chart text:",W)}},[e]),j=$.useCallback(async()=>{try{await navigator.clipboard.writeText(e),k("copied"),setTimeout(()=>k("idle"),1200)}catch(W){console.error("Failed to copy Mermaid chart text:",W)}},[e]),U=$.useCallback(W=>{try{b(!0),x({x:W.clientX,y:W.clientY}),W.preventDefault()}catch(fe){console.error("Error in mouse down:",fe)}},[]),D=$.useCallback((W,fe=!1)=>{try{if(!y)return;const te=W.clientX-v.x,M=W.clientY-v.y;(fe?g:p)(ee=>({...ee,x:ee.x+te,y:ee.y+M})),x({x:W.clientX,y:W.clientY})}catch(te){console.error("Error in mouse move:",te)}},[y,v]),Z=$.useCallback(()=>{try{b(!1)}catch(W){console.error("Error in mouse up:",W)}},[]),N=$.useCallback((W,fe=!1)=>{try{W.preventDefault();const te=W.deltaY>0?.9:1.1;(fe?g:p)(ie=>({...ie,scale:Math.min(Math.max(ie.scale*te,.1),5)}))}catch(te){console.error("Error in wheel:",te)}},[]),L=$.useCallback(W=>{try{O(W)}catch(fe){console.error("Error toggling fullscreen:",fe)}},[]);if(i)return d.jsxs(n9,{title:h("ui.chat.mermaid.error_title"),children:[i,d.jsx("span",{className:R("mt-2 block text-ink-muted"),children:h("ui.chat.mermaid.chart_label")}),d.jsx("span",{className:R("mt-1 block whitespace-pre-wrap font-mono text-mono-sm"),children:e})]});const J=(W=!1)=>{try{const fe=W?r:n,te=W?m:f;return d.jsx("div",{ref:fe,className:R("mermaid flex w-full items-center justify-center",W?"h-full min-h-full":"h-auto min-h-50",y?"cursor-grabbing":"cursor-grab"),onMouseDown:U,onMouseMove:M=>D(M,W),onMouseUp:Z,onMouseLeave:Z,onWheel:M=>N(M,W),children:s?d.jsx("div",{className:R("p-4 text-body-sm text-ink-muted"),children:h("ui.chat.mermaid.loading")}):l?d.jsx("div",{className:R("flex h-full w-full items-center justify-center"),style:{transform:`translate(${te.x}px, ${te.y}px) scale(${te.scale})`,transformOrigin:"center center"},dangerouslySetInnerHTML:{__html:l}}):null})}catch(fe){return console.error("Error rendering diagram content:",fe),d.jsx(n9,{title:h("ui.chat.mermaid.rendering_error"),children:h("ui.chat.mermaid.render_failed")})}};return d.jsxs(d.Fragment,{children:[d.jsxs("div",{className:R("relative flex items-center justify-center overflow-hidden rounded-md bg-surface","[&_svg]:h-auto [&_svg]:min-h-100 [&_svg]:max-w-none [&_svg]:bg-transparent"),children:[J(!1),d.jsx(_te,{className:"top-2 right-2",copied:S==="copied",onZoomIn:()=>T(!1),onZoomOut:()=>A(!1),onReset:()=>z(!1),onSave:Y,onCopy:G,children:d.jsx(kt,{content:h("ui.chat.mermaid.fullscreen"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.open_fullscreen"),onClick:()=>L(!0),children:d.jsx(Kde,{})})})})]}),d.jsx(ym,{open:u,onClose:()=>L(!1),title:h("ui.chat.mermaid.diagram_title"),maxWidth:"xl",fullWidth:!0,dialogProps:{className:"h-[90vh] max-h-[90vh]"},children:d.jsxs("div",{className:R("relative flex h-[80vh] w-full items-center justify-center overflow-hidden","[&_svg]:h-auto [&_svg]:max-h-full [&_svg]:w-auto [&_svg]:max-w-full [&_svg]:bg-transparent"),children:[J(!0),d.jsx(_te,{className:"top-4 right-4",copied:_==="copied",onZoomIn:()=>T(!0),onZoomOut:()=>A(!0),onReset:()=>z(!0),onSave:Y,onCopy:j,children:d.jsx(kt,{content:h("ui.chat.mermaid.close_fullscreen"),children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.mermaid.close_fullscreen"),onClick:()=>L(!1),children:d.jsx(ei,{})})})})]})})]})}),Y7t=$.memo(e=>d.jsx(W7t,{children:d.jsx(D7t,{...e})}));let LPe=!1,G4=null;const G7t=()=>(G4||(G4=Pe(()=>Promise.resolve({}),__vite__mapDeps([11]),import.meta.url).then(e=>(LPe=!0,e))),G4),L7t=/language-(\w+)/,M7t=QN,Z7t=new RegExp(`^[^${vu}\\d*+-]`),V7t=/\n$/,MPe=({href:e,children:t})=>{const n=zQe(e),r=ov();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=>H7t(i,r):void 0,children:t})},F7t=e=>zQe(e)?.kind==="file",B7t=DQe,H7t=(e,t)=>{const n=e.currentTarget,r=n.getAttribute(WQe)??"file",i=n.getAttribute(B7t),a=ACt({kind:r,hasHighlight:KCt(n),canOpenInCanvas:TW(t,i)});if(a!=="browse"&&(e.preventDefault(),!(a==="hold"||!i))){if(a==="canvas"&&t){t.openInCanvas(i).then(s=>{s||Ru(i)});return}Ru(i)}},r9=(e,t)=>t==="href"&&F7t(e)?e:fpe(e),Qb={a:MPe,table:Dz,img:Njt,code:({node:e,className:t,children:n,...r})=>L7t.exec(t??"")?.[1]==="mermaid"?d.jsx(Y7t,{chart:String(n).replace(V7t,"")}):d.jsx("code",{dir:"ltr",className:t,...r,children:n})},K7t={...Qb,a:bjt(MPe)},J7t=[So,Ol],e9t=[So,Ol,UT],t9t=[So,Ol,CT],n9t=[So,Ol,UT,CT],r9t=[So,Ol,NT,AT],i9t=[So,Ol,UT,NT,AT],a9t=[So,Ol,CT,NT,AT],s9t=[So,Ol,UT,CT,NT,AT],o9t={"000":J7t,"001":r9t,"010":t9t,"011":a9t,100:e9t,101:i9t,110:n9t,111:s9t},l9t=[],c9t={throwOnError:!1,strict:"ignore",trust:!1,errorColor:"var(--lo-danger)"},u9t=[[_ct,c9t]],ZPe=e=>$.useMemo(()=>{if(!(!e?.fontSize&&!e?.lineHeight))return{"--md-font-size":e.fontSize,"--md-line-height":e.lineHeight}},[e?.fontSize,e?.lineHeight]),VPe=(e,t,n,r)=>{const i=$.useMemo(()=>w7t(e),[e]),[a,s]=$.useState(LPe),o=i&&a;$.useEffect(()=>{if(!i||a)return;let O=!1;return G7t().then(()=>{O||s(!0)}),()=>{O=!0}},[i,a]);const l=o9t[`${o?1:0}${t?1:0}${n?1:0}`],c=n&&r?r.join("\0"):"";return{remarkPlugins:$.useMemo(()=>c===""?l:[[DAt,{names:c.split("\0")}],...l],[l,c]),rehypePlugins:o?u9t:l9t}},FPe=(e,t,n)=>{const[,r]=$.useState(0);$.useEffect(()=>{if(!t)return;const i=Zct(e);if(i.length===0)return;let a=!0;const s=new Set(i),o=zCt(l=>{a&&l.some(c=>s.has(c))&&r(c=>c+1)});return PW(i,window.api?.probeFiles,tde,jCt(n===void 0?e:`${n}\0${e}`)).then(()=>{a&&i.some(l=>IQe(l)!=="unknown")&&r(l=>l+1)}),()=>{a=!1,o()}},[e,t,n])},Pb=$.memo(({content:e,styleProps:t,className:n,linkify:r=!0,credentialCitations:i=!1,skillNames:a,documentId:s})=>{const o=$.useMemo(()=>e.trim(),[e]),{remarkPlugins:l,rehypePlugins:c}=VPe(o,r,i,a),u=ZPe(t);return FPe(o,r,s),d.jsx("div",{className:R("lo-markdown",n),style:u,children:d.jsx(Gy,{remarkPlugins:l,rehypePlugins:c,urlTransform:r9,components:i?K7t:Qb,children:o})})});Pb.displayName="MarkdownRenderer";const Ste={...Qb,a:({children:e})=>d.jsx(d.Fragment,{children:e})},BPe=$.memo(({source:e,closed:t})=>{const n=$.useMemo(()=>t?e:Mee(e),[t,e]),r=$.useMemo(()=>{if(t)return null;const s=nPe(e);return s!==null&&!s.nested?s:null},[t,e]),{remarkPlugins:i,rehypePlugins:a}=VPe(n,t,!1);if(FPe(e,t),r!==null){const s=Mee(r.before);return d.jsxs(d.Fragment,{children:[s.trim()!==""&&d.jsx(Gy,{remarkPlugins:i,rehypePlugins:a,urlTransform:r9,components:t?Qb:Ste,children:s}),d.jsx(O9t,{info:r.info,body:r.body})]})}return d.jsx(Gy,{remarkPlugins:i,rehypePlugins:a,urlTransform:r9,components:t?Qb:Ste,children:n})});BPe.displayName="ParsedBlock";const O9t=({info:e,body:t})=>{const n=e.split(M7t)[0];return d.jsx("pre",{children:d.jsx("code",{className:n?`language-${n}`:void 0,children:t===""?"":`${t}${t.endsWith(`
946
946
  `)?"":`
947
947
  `}`})})},HPe=({content:e,styleProps:t,className:n})=>{const r=$.useRef(null);r.current===null&&(r.current=rAt());const i=r.current;oAt(i,e);const{blockStart:a}=i,s=a+lAt(e.slice(a));let o=null,l=a;(i.kind==="other"||(i.kind==="list"||i.kind==="indented-code")&&Z7t.test(e.slice(i.cursor)))&&i.fence===null&&i.blankRunStart>=a&&i.cursor<s&&e.slice(i.cursor,s).trim().length>0&&(o=e.slice(a,i.blankRunStart),l=i.cursor);const c=e.slice(l,s),u=i.blocks.map((f,p)=>({key:p,source:f,closed:!0}));o!==null&&u.push({key:i.blocks.length,source:o,closed:!0}),c!==""&&u.push({key:u.length,source:c,closed:!1});const O=ZPe(t);return d.jsx("div",{className:R("lo-markdown",n),style:O,children:u.map(f=>d.jsx(BPe,{source:f.source,closed:f.closed},f.key))})};HPe.displayName="StreamingMarkdown";const i9=({mark:e,name:t,className:n})=>{const r=nde(Ht(s=>s.agentAvatarSize)),i=XCe[r],a=RCe[r];return d.jsx("div",{className:R("flex",a.className,n),"data-turn-avatar-gap":a.px,children:d.jsx(wtt,{mark:e,boxClassName:i.className,glyphClassName:i.glyphClassName,hitClassName:i.hitClassName,alt:t??"",agentName:t})})},ka=({isUser:e,children:t,className:n})=>e?d.jsx("div",{className:R("flex w-full justify-end",n),children:t}):d.jsx("div",{className:R("group relative w-full",n),children:t}),UW=e=>{const t=new Date(e);return t.setHours(0,0,0,0),t.getTime()},d9t=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 IW=UW(Date.now()),Vc=null,kte=0,Qte=0,Pte=0;const C_=new Set,f9t=1e3,h9t=()=>typeof performance>"u"?Date.now():performance.now(),KPe=()=>{const e=Date.now(),t=e+d9t(e),n=h9t();Vc!==null&&t===kte&&Math.abs(e-Qte-(n-Pte))<=f9t||(Vc!==null&&clearTimeout(Vc),kte=t,Qte=e,Pte=n,Vc=setTimeout(()=>{Vc=null,IW=UW(Date.now());for(const r of C_)r();KPe()},t-e),Vc.unref?.())},p9t=e=>(C_.add(e),IW=UW(Date.now()),KPe(),()=>{C_.delete(e),C_.size===0&&Vc!==null&&(clearTimeout(Vc),Vc=null)}),Tte=()=>IW,m9t=()=>$.useSyncExternalStore(p9t,Tte,Tte),g9t=e=>new Date(e+1e3),$9t=()=>g9t(m9t()),dwn=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":y1(t,{year:"numeric",month:"long",day:"numeric"})}catch(t){return console.error("Error formatting calendar date:",t),""}},y9t=(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=b1(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=y1(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),""}},b9t=e=>{if(!e)return"";try{const t=e instanceof Date?e:new Date(e);return Number.isNaN(t.getTime())?"":PN(t,{year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"2-digit"})}catch(t){return console.error("Error formatting calendar date-time:",t),""}},v9t=(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})}},Ek=({timestamp:e,scope:t,className:n})=>{const r=e instanceof Date?e:new Date(e),i=$9t();if(Number.isNaN(r.getTime()))return null;const a=b9t(r);return d.jsx(kt,{content:a,side:"bottom",delayDuration:1200,children:d.jsx("time",{dateTime:r.toISOString(),"data-stamp":t,"aria-label":v9t(t,a),className:R("shrink-0 select-none whitespace-nowrap text-ink-dim text-meta",n),children:d.jsx("bdi",{children:y9t(r,i)})})})},WW=({replies:e,onRemoveReply:t})=>(ke(),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(Jde,{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(Se,{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(ei,{"aria-hidden":"true"})})]},n.id))]})),w9t=({children:e,className:t})=>d.jsx("span",{"aria-hidden":!0,className:R("flex size-3.5 shrink-0 [&_svg]:size-3.5",t),children:e}),a9={hunk:"text-ink-muted",added:"text-success",removed:"text-danger",context:"text-ink-dim"},Ete=qA,L4={start:0,offset:0};async function x9t(e,t,n){const{start:r,offset:i}=n;try{const a=await qe(e.childId?{op:"subagents.diff",sessionId:e.sessionId,childId:e.childId,callId:t,start:r,offset:i,limit:qA}:{op:"sessions.diff",sessionId:e.sessionId,callId:t,start:r,offset:i,limit:qA}),s=HCe(a,n);if(!s)throw new Error("malformed diff page");return s}catch(a){if(a instanceof Pn&&a.status===404)return"not_found";throw a}}function M4(e){return e!=="not_found"&&e.state==="archived"}function _9t(e,t){const[n,r]=$.useState({kind:"loading"}),i=$.useRef(0),a=$.useRef([]),{sessionId:s,childId:o}=e,l=$.useCallback(async(O,f)=>{const p=++i.current,m={sessionId:s,childId:o};r({kind:"loading"});try{const g=[],y=async S=>{if(i.current!==p)throw Rte;return x9t(m,t,S)};let v=f==="before"?{start:ZCe(O.start),offset:0}:O,x=await y(v);if(f==="before"){let S=0;for(;M4(x);){const w=Yv(x);if(!w||VCe(w,O)>=0||w.start>x.start&&++S>Ete)break;g.push(v),v=w,x=await y(v)}M4(x)&&(x=FCe(x,O))}if(f==="last"){let S=0;for(;M4(x);){const w=Yv(x);if(!w)break;w.start>x.start&&++S>Ete?(g.length=0,S=0,v={start:Math.max(0,x.totalRows-1),offset:0}):(g.push(v),v=w),x=await y(v)}}if(i.current!==p)return;x==="not_found"?r({kind:"notice",notice:"not_found"}):x.state!=="archived"?r({kind:"notice",notice:x.state}):(f!=="exact"&&(a.current=g),r({kind:"page",page:x}))}catch(g){if(g===Rte||i.current!==p)return;r({kind:"error",cursor:O,mode:f})}},[s,o,t]);$.useEffect(()=>(a.current=[],l(L4,"exact"),()=>{i.current+=1}),[l]);const c=n.kind==="page"?n.page:null,u=c?.totalRows??0;return{state:n,first:()=>{a.current=[],l(L4,"exact")},prev:()=>{if(!c)return;const O=a.current.pop();O!==void 0?l(O,"exact"):l({start:c.start,offset:c.offset},"before")},next:()=>{const O=c?Yv(c):null;!c||!O||(a.current.push({start:c.start,offset:c.offset}),l(O,"exact"))},last:()=>{a.current=[],l({start:BCe(u),offset:0},"last")},retry:()=>{n.kind==="error"?l(n.cursor,n.mode):l(L4,"exact")},canPrev:!!(c&&(c.start>0||c.offset>0)),canNext:!!(c&&Yv(c))}}const Rte=Symbol("diff-history-cancelled"),S9t=500,k9t=1e4;function hx(e){const t=e?.closest("[data-lo-canonical-transcript]"),n=e?.nextElementSibling;if(!t||!e||!(n instanceof HTMLElement))return;t.scrollTop+=n.getBoundingClientRect().top-t.getBoundingClientRect().top;const r=e.ownerDocument.defaultView,i=Number.parseFloat(r?.getComputedStyle(e).marginBottom??"")||0;for(let a=0;a<3;a+=1){const s=n.getBoundingClientRect().top-(e.getBoundingClientRect().bottom+i);if(Math.abs(s)<1)break;t.scrollTop+=s}}const fO="cursor-pointer text-ink-dim underline underline-offset-2 transition-colors duration-fast ease-out-quart hover:text-ink aria-disabled:cursor-default aria-disabled:no-underline aria-disabled:text-ink-disabled aria-disabled:hover:text-ink-disabled focus-visible:outline focus-visible:outline-2 focus-visible:outline-accent",Q9t=({scope:e,callId:t,headerRows:n,onBack:r,onNotice:i})=>{const a=_9t(e,t),{state:s}=a,o=s.kind==="notice"?s.notice:null;$.useEffect(()=>{o&&i?.(o)},[o]);const l=$.useRef(0);s.kind==="page"&&s.page.start===0&&s.page.offset===0&&(l.current=rde(s.page.rows));const c=n??l.current,u=$.useRef(null),O=$.useRef(null),f=$.useRef(!1),p=$.useRef(null);s.kind==="page"?p.current=s.page:s.kind==="notice"&&(p.current=null);const m=$.useRef(!1),g=(T,A)=>()=>{T&&(m.current=!!u.current?.contains(document.activeElement),f.current=!0,A())};$.useLayoutEffect(()=>{f.current=!0,hx(O.current),O.current?.focus({preventScroll:!0})},[]);const y=$.useRef(0),b=$.useRef(()=>{});$.useEffect(()=>{const T=O.current?.closest("[data-lo-canonical-transcript]");if(!T)return;let A=0;const z=()=>performance.now()<y.current,Y=()=>{A=0,z()&&(hx(O.current),A=requestAnimationFrame(Y))},G=()=>{A===0&&z()&&(A=requestAnimationFrame(Y))},j=()=>{f.current=!1,m.current=!1,y.current=0,A&&cancelAnimationFrame(A),A=0};b.current=G;const U=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>{z()&&hx(O.current)});U?.observe(T.querySelector("[data-lo-transcript-content]")??T),u.current&&U?.observe(u.current);const D=["wheel","pointerdown","keydown","touchstart"];for(const Z of D)T.addEventListener(Z,j,{capture:!0,passive:!0});return G(),()=>{b.current=()=>{},A&&cancelAnimationFrame(A),U?.disconnect();for(const Z of D)T.removeEventListener(Z,j,{capture:!0})}},[]),$.useLayoutEffect(()=>{f.current&&(hx(O.current),y.current=performance.now()+(s.kind==="loading"?k9t:S9t),b.current(),s.kind!=="loading"&&(f.current=!1)),m.current&&!u.current?.contains(document.activeElement)&&O.current?.focus({preventScroll:!0}),s.kind!=="loading"&&(m.current=!1)},[s]);const v=s.kind==="page"?s.page:null,x=v??(s.kind==="notice"?null:p.current),S=x&&x.rows.length>0?CCe(x,c):null,w=v??(s.kind==="error"?p.current:null),_=w?ACe(w):null,k=v?.clippedRows.length??0,Q=S!==null&&s.kind!=="error",X=Q&&v!==null&&_!==null&&_.lines.length>0,C=s.kind==="loading"?qCe():s.kind==="error"?jCe():s.kind==="notice"?ide(s.notice):_&&_.lines.length===0?NCe():"";return d.jsxs("div",{ref:u,"data-diff-history":"","aria-busy":s.kind==="loading",children:[d.jsxs("nav",{ref:O,tabIndex:-1,"aria-label":zCe(),className:R("flex flex-wrap items-baseline gap-x-3 gap-y-1 text-ink-dim focus:outline-none","sticky top-0 z-10 -mx-3 -mt-3 mb-2 bg-sunken px-3 pt-3 pb-1"),children:[Q&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.first),children:UCe()}),d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.prev),children:fG()})]}),d.jsx("span",{"data-diff-history-range":"","aria-live":"polite",children:S?hG(S.first,S.last,S.total):null}),Q&&d.jsxs(d.Fragment,{children:[d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.next),children:pG()}),d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.last),children:ICe()})]}),d.jsx("button",{type:"button",className:R(fO,"ms-auto"),onClick:r,children:WCe()})]}),d.jsx("output",{"data-diff-history-status":"",className:"block text-ink-dim",children:C}),s.kind==="error"&&d.jsx("button",{type:"button",className:fO,onClick:g(!0,a.retry),children:DCe()}),_?.hunkHeader&&d.jsx("span",{"data-diff-hunk-context":"",className:R(a9.hunk,"block"),children:_.hunkHeader}),_?.lines.map(T=>d.jsxs("span",{"data-diff-line":T.index,className:R(a9[T.kind],"block"),children:[T.text,T.continued&&d.jsxs("span",{className:"text-ink-dim","data-diff-continued":"",children:[" ",YCe()]}),T.continues&&d.jsxs("span",{className:"text-ink-dim","data-diff-continues":"",children:[" ",GCe()]}),T.clipped&&d.jsxs("span",{className:"text-ink-dim","data-diff-clipped":"",children:[" ",LCe()]})]},T.index)),k>0&&d.jsx("span",{className:"mt-2 block text-ink-dim",children:MCe(k)}),X&&S&&d.jsxs("div",{"data-diff-history-foot":"",className:"mt-2 flex flex-wrap items-baseline gap-x-3 gap-y-1 text-ink-dim",children:[d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canPrev,onClick:g(a.canPrev,a.prev),children:fG()}),d.jsx("span",{children:hG(S.first,S.last,S.total)}),d.jsx("button",{type:"button",className:fO,"aria-disabled":!a.canNext,onClick:g(a.canNext,a.next),children:pG()})]})]})},Xte="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",P9t=({line:e,index:t})=>d.jsx("span",{"data-diff-line":t,className:R(a9[e.kind],"block"),children:e.text}),T9t=({diff:e,truncatedRows:t=0,history:n,className:r})=>{const[i,a]=$.useState(!1),[s,o]=$.useState(!1),l=e.length===0&&!!n?.descriptor,c=t>0||l,u=c?n?.descriptor??null:null,O=u?.state==="archived"&&n?.scope?n:null,[f,p]=$.useState(null),m=O&&!f?O:null,g=f??(u&&u.state!=="archived"?u.state:null),y=$.useId(),b=$.useRef(null),v=$.useRef(null),x=$.useRef(null),S=$.useRef(null),w=KCe(e,{expanded:i}),_=rde(e),k=l?2:_;$.useLayoutEffect(()=>{const X=x.current;if(X)if(x.current=null,i){const C=b.current?.querySelector(`[data-diff-line="${JCe}"]`);if(C){const T=C.getBoundingClientRect().top-X.scroller.getBoundingClientRect().top;X.scroller.scrollTop+=T-X.top}}else b.current?.scrollIntoView({block:"nearest"})},[i]);const Q=()=>{const X=b.current?.closest("[data-lo-canonical-transcript]");X&&v.current&&(x.current={scroller:X,top:v.current.getBoundingClientRect().top-X.getBoundingClientRect().top}),a(C=>!C)};return d.jsxs("div",{id:y,ref:b,className:R("rounded-md bg-sunken p-3 font-mono text-ink text-mono-sm whitespace-pre-wrap break-words",i||s?"overflow-x-clip":R("overflow-y-auto overflow-x-hidden",c?g&&!f?"max-h-[776px]":"max-h-[758px]":"max-h-[740px]"),r),children:[s&&O?.scope&&d.jsx(Q9t,{scope:O.scope,callId:O.callId,headerRows:l?void 0:_,onNotice:p,onBack:()=>{o(!1),requestAnimationFrame(()=>{b.current?.scrollIntoView({block:"nearest"}),(S.current??v.current)?.focus({preventScroll:!0})})}}),(!s||f)&&(w.withheld?d.jsx("span",{className:"block text-ink-dim",children:eAe()}):w.lines.map((X,C)=>d.jsx(P9t,{line:X,index:C},C))),!s&&!w.withheld&&c&&(m?d.jsx("button",{type:"button",ref:S,"data-diff-view-full":"",onClick:()=>o(!0),className:Xte,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:tAe(u?.state==="archived"?Math.max(0,u.rows-k):0)})}):d.jsxs(d.Fragment,{children:[t>0&&!f&&d.jsx("span",{className:"block text-ink-dim",children:nAe(t)}),g&&d.jsx("span",{"data-diff-full-notice":g,className:"block text-ink-dim",children:ide(g)})]})),(!s||f)&&w.expandable&&!m&&d.jsx("button",{type:"button",ref:v,"aria-expanded":i,"aria-controls":y,onClick:Q,className:R(Xte,"sticky -mb-3 pb-3",i?"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:i?rAe():iAe(w.hidden)})})]})},E9t=(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),s=a.lastIndexOf(" ");i=`${a.slice(0,s>32?s:t).trimEnd()}…`}return i.replace(/[.!?…]+$/g,"").trimEnd()},Cte=e=>e.startsWith("file://")?e.slice(7):e,R9t={READ:{verb:"ui.chat.trace.action.read.settled",runningVerb:"ui.chat.trace.action.read.running",icon:Gde},WRITE:{verb:"ui.chat.trace.action.write.settled",runningVerb:"ui.chat.trace.action.write.running",icon:BN},EDIT:{verb:"ui.chat.trace.action.edit.settled",runningVerb:"ui.chat.trace.action.edit.running",icon:lze},CODE:{verb:"ui.chat.trace.action.code.settled",runningVerb:"ui.chat.trace.action.code.running",icon:Mde},DELEGATE:{verb:"ui.chat.trace.action.delegate.settled",runningVerb:"ui.chat.trace.action.delegate.running",icon:Sze},DONE:{verb:"ui.chat.trace.action.done.settled",runningVerb:"ui.chat.trace.action.done.running",icon:UN},ASK:{verb:"ui.chat.trace.action.ask.settled",runningVerb:"ui.chat.trace.action.ask.running",icon:mm},BYE:{verb:"ui.chat.trace.action.bye.settled",runningVerb:"ui.chat.trace.action.bye.running",icon:S8e}},X9t={verb:"ui.chat.trace.action.fallback.settled",runningVerb:"ui.chat.trace.action.fallback.running",icon:Mde},C9t=(e,t,n,r)=>{const i=e?R9t[e]:X9t;let a;if(t)a=Cte(t);else if(n&&n.length>0){const o=n.filter(l=>!l.startsWith("data:"));o.length===1?a=Cte(o[0]):o.length>1&&(a=h("ui.chat.trace.object.file_count",{count:o.length}))}const s=!a&&r?E9t(r):"";return{verb:h(i.verb),runningVerb:h(i.runningVerb),object:a,narration:s||void 0,icon:i.icon}},Ate="min-h-5 py-0",A9t=({icon:e,verb:t,object:n,narration:r,running:i,failed:a,wrap:s})=>d.jsxs("span",{className:R("flex min-w-0 gap-2",s?"items-start":"items-center"),"aria-busy":i||void 0,children:[d.jsx(w9t,{className:R(a?"text-danger":"text-ink-dim",s&&xhe),children:e}),d.jsxs("span",{className:R(s?"min-w-0 whitespace-pre-wrap break-words":"truncate"),children:[d.jsxs("span",{...q5,className:R("select-text font-mono text-mono-sm",a?"text-danger":"text-ink-muted"),children:[t,r?":":null]}),n?d.jsxs("span",{...q5,className:"select-text font-mono text-ink-muted text-mono-sm",children:[" ",n]}):null,r?d.jsxs("span",{...q5,className:"select-text text-body-sm text-ink-muted",children:[" ",r]}):null]})]}),qte=({action:e,filePath:t,files:n,narration:r,running:i=!1,failed:a=!1,defaultOpen:s=!1,details:o,className:l,verbOverride:c,object:u,glyph:O,wrap:f,dense:p=!1})=>{const m=C9t(e,t,n,r),g=c??(i?m.runningVerb:m.verb),y=a?wu:m.icon,b=a||!c||!O?d.jsx(y,{}):O,v=d.jsx(A9t,{icon:b,verb:g,object:c?u:m.object,narration:c?r:m.narration,running:i,failed:a,wrap:f}),x=f?"firstLine":"center";return o?d.jsx(Vi,{summary:v,chevron:"leading",summaryAlign:x,defaultOpen:s,className:l,rowClassName:p?Ate:void 0,triggerClassName:"-mx-2 rounded-sm px-2 hover:bg-elevated",children:o}):d.jsx(Vi,{disabled:!0,summary:v,summaryAlign:x,className:l,rowClassName:p?Ate:void 0})};function Gi(e){return e.normalize("NFKC").trim().replace(/\s+/g," ").toLocaleLowerCase()}function DW(e,t,n){const r=e.trim(),i=t.trim();return r===""||Gi(r)===Gi(i)?n.unnamed(i):n.named(r,i)}const Tb="all";function fwn(e){return e}function hwn(e){return e===Tb?Tb:e}function s9(e){return e.kind==="agent"?MW(e.display_label,null):WT(e.display_label)}function q9t(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(s=>s.state==="active")??r[0];return a?s9(a):null}const i=r.filter(a=>a.state==="active").map(s9).filter(a=>a!==null);return i.length===0?null:i.length<=3?i.join(", "):`${i.slice(0,2).join(", ")} +${i.length-2}`}function pwn(e){return e.discoverable===!0&&e.member===!1}function j9t(e){return e.notify??(e.muted?"mute":"all")}function N9t(e){return j9t(e)==="mute"}function mwn(e){return N9t(e)?"quiet":"attention"}function gwn(e){return e==="mute"?"all":"mute"}const $wn=[{value:"all",labelKey:"ui.teamBridge.agentNotify.all"},{value:"mention",labelKey:"ui.teamBridge.agentNotify.mention"},{value:"mute",labelKey:"ui.teamBridge.agentNotify.mute"}];function JPe(e,t){return t?e.members.find(n=>n.kind==="agent"&&n.account_id===t&&n.state==="active")??null:null}function YW(e){const t=e.notify;return t==="all"||t==="mention"||t==="mute"?t:null}function ywn(e,t){const n=JPe(e,t);return n?{notify:YW(n)}:void 0}function bwn(e,t,n){const r=JPe(t,n),i=r?YW(r):null;return i===null?e:z9t(e,{conversationId:t.id,tenantId:t.tenant_id},n,i)}function z9t(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 vwn(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(s=>{if(s.kind!=="agent"||s.account_id!==n||s.state!=="active"||YW(s)!==r)return s;if(i!==null)return{...s,notify:i};const{notify:o,...l}=s;return l})}:a)}}const wwn=[{value:"all",labelKey:"ui.teamBridge.notify.all"},{value:"mention",labelKey:"ui.teamBridge.notify.mention"},{value:"mute",labelKey:"ui.teamBridge.notify.mute"}];function xwn(e){return e==="mention"||e==="mute"?e:"all"}function _wn(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 Swn(e){return e.kind==="channel"&&e.status==="open"&&!e.builtin&&e.can_administer===!0}function kwn(e){return e.kind==="channel"&&e.status==="archived"&&!e.builtin&&e.can_administer===!0}const eTe=(e,t,n)=>e.id===t&&(!n||e.tenant_id===n);function Qwn(e,t,n){return{...e,conversations:e.conversations.filter(r=>!eTe(r,t,n))}}function Pwn(e,t,n,r){return{...e,conversations:e.conversations.map(i=>eTe(i,t,r)?{...i,status:n}:i)}}function Twn(e,t){const n=new Set(e.map(r=>r.id));return[...e,...t.filter(r=>!n.has(r.id))]}function Ewn(e){return e.filter(t=>t.kind==="channel"&&t.status==="archived")}function Rwn(e){return typeof e=="object"&&e!==null&&e.code==="not_a_member"}function Xwn(e,t,n=[]){const r=Y9t(e,n).channels,i=r.findIndex(l=>l.id===t),a=i>=0?r[i+1]??r[i-1]:jte(r,n),s=e.filter(l=>l.id!==t),o=a&&a.id!==t?a:jte(s,n);return o?{type:"conversation",id:o.id}:null}function Cwn(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 Awn(e,t){return e.isError&&e.variables?.conversationId===t}function qwn(e){return e.members.length>0?e.members.filter(t=>t.state==="active").length:e.member_count??0}function jwn(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 U9t(e){return[...e].sort((t,n)=>t.seq-n.seq)}function Nwn(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])),s=new Set,o=[];for(const l of n){if(s.has(l.tenant_id))continue;s.add(l.tenant_id);const c=a.get(l.tenant_id);o.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 o}function zwn(e,t,n,r){if(n)return t;if(e.length===1)return e[0].tenantId;if(e.length>1)return Tb;const i=new Set((r??[]).map(a=>a.tenant_id));return t===Tb&&i.size===1?[...i][0]:t}function Uwn(e,t){return e.find(n=>n.tenantId===t)??null}function GW(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 Iwn(e){return e?.status?.tenants??null}function Wwn(e,t){return e!==null?{pending:!1,failed:!1}:{pending:t.isLoading,failed:t.isError}}function I9t(e,t){return t.find(n=>n.tenantId===e.tenant_id)?.name??null}function Dwn(e,t,n){return t!==Tb?[...e]:GW(e).filter(r=>I9t(r,n)!==null)}function Ywn(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 A_(e){return e.display_label.trim()||e.account_id}function Gwn(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 W9t(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 o9(e,t,n){const r=e.filter(i=>i.kind!=="dm"||i.status==="archived"||!i.members.some(s=>s.kind==="human"&&s.account_id===t&&s.state!=="removed")?!1:n?i.members.some(s=>s.kind==="human"&&s.account_id===n&&s.state!=="removed"):!0);return r.length===0?null:GW(r)[0]??null}function Lwn(e){return e.trim().charAt(0).toUpperCase()||"?"}function D9t(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 l9(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:GW(r)[0]??null}const c9=["general","humans","agents"];function tTe(e,t,n){const r=c9.indexOf(e.builtin)-c9.indexOf(t.builtin);if(r!==0)return r;const i=s=>{const o=n.indexOf(s);return o<0?Number.POSITIVE_INFINITY:o},a=i(e.tenant_id)-i(t.tenant_id);return a!==0&&!Number.isNaN(a)?a:e.tenant_id.localeCompare(t.tenant_id)}function jte(e,t=[]){const n=r=>e.filter(i=>i.builtin===r).sort((i,a)=>tTe(i,a,t))[0];return n("general")??n("humans")??e[0]}function Mwn(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 Y9t(e,t=[]){const n=[],r=[],i=[],a=[];for(const s of e)s.kind==="channel"?s.builtin&&c9.includes(s.builtin)?n.push(s):r.push(s):s.kind==="group"?i.push(s):a.push(s);return n.sort((s,o)=>tTe(s,o,t)),{channels:[...n,...r],groups:i,directs:a}}function Zwn(e,t,n,r){const i=new Set;for(const a of t){if(r!==void 0&&a.account_id===r)continue;const s=o9(e,a.account_id,r);s&&i.add(s.id)}for(const a of n){const s=l9(e,a.person.account_id,r);s&&i.add(s.id)}return e.filter(a=>!i.has(a.id))}function Vwn(e){return`${e.kind}:${e.accountId}`}function Fwn(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 o9(t,e.accountId,n);case"chief":return l9(t,e.accountId,n);case"compose":{if(e.recipients.length!==1)return null;const[r]=e.recipients;return r.kind==="agent"?l9(t,r.accountId,n):o9(t,r.accountId,n)}}}function G9t(e){return LW(e.trim())??e}function L9t(e){const t=e.ownerLabel?.trim();if(e.agentName!==void 0&&t){const n=e.agentName.trim();return n!==""&&Gi(n)!==Gi(t)?n:t}return G9t(e.label)}function M9t(e){return e.kind==="agent"?{account_id:e.accountId,kind:"agent",endpoint_id:e.endpointId,display_label:L9t(e).slice(0,64)}:{account_id:e.accountId,kind:"human",display_label:e.label.slice(0,64)}}function Bwn(e,t,n){const r=e.filter(a=>{const s=W9t(a,t);return s==="openable"||s==="paused"}).map(a=>({kind:"human",accountId:a.account_id,label:A_(a)})),i=D9t(e,t).map(a=>({kind:"agent",accountId:a.person.account_id,endpointId:a.endpointId,agentName:a.agentName,ownerLabel:A_(a.person),label:DW(a.agentName,A_(a.person),n)}));return[...r,...i]}function Hwn(e){if(e.length===0)return null;const t=e.map(M9t);return{kind:e.length===1?"dm":"group",visibility:"private",agentCapable:e.some(n=>n.kind==="agent"),members:t}}const Z9t="Member";function WT(e){const t=e.trim();return t===""||t===Z9t?null:t}const Rk={"(":")","(":")"},nTe=256;function V9t(e,t){if(e.length>nTe)return null;const n=Gi(t);if(n==="")return null;for(let r=0;r<e.length;r+=1){const i=Rk[e[r]];if(i===void 0||!e.endsWith(i))continue;const a=e.slice(r+1,e.length-i.length),s=e.slice(0,r).trim();if(s!==""&&Gi(a)===n)return s}return null}function F9t(e){const t=new Set(Object.values(Rk)),n=[];for(const r of e){const i=Rk[r];if(i!==void 0)n.push(i);else if(t.has(r)&&n.pop()!==r)return!1}return n.length===0}function LW(e){if(e.length>nTe)return null;for(let t=0;t<e.length;t+=1){const n=Rk[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!==""&&F9t(r)&&Gi(i)===Gi(r))return i}return null}const rTe=["'s chief of staff","’s chief of staff"],B9t=64;function H9t(e){const t=e.replace(/[\s\u0085]+/gu," ").trim(),n=new TextEncoder().encode(t);let r=B9t-rTe[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 MW(e,t){const n=WT(e);if(n===null||t!==null&&Gi(n)===Gi(t)||t!==null&&[t,H9t(t)].some(r=>rTe.some(i=>Gi(n)===Gi(`${r}${i}`))))return null;if(t!==null){const r=V9t(n,t);if(r!==null)return Gi(r)===Gi(t)?null:r}return LW(n)!==null?null:n}function iTe(e,t){const n=s9(e);if(n!==null||e.kind!=="agent")return n;const r=WT(e.display_label),i=r===null?null:LW(r);return i===null?null:t.unnamed(i)}function Kwn(e,t){const n=e.ownerLabel.trim();return n===""?iTe({kind:"agent",display_label:e.label},t):DW(MW(e.label,n)??"",n,t)}function Jwn(e,t,n,r){const i=t.find(l=>l.account_id===e.account_id),a=i?A_(i):null;if(e.kind==="human"){const l=WT(e.display_label),c=r&&r.accountId===e.account_id&&r.name.trim()||null;return a??c??l}const s=i?.agent?.name.trim()??"",o=s!==""&&(a===null||Gi(s)!==Gi(a))?s:MW(e.display_label,a);return a?DW(o??"",a,n):o??iTe({kind:"agent",display_label:e.display_label},n)}const K9t=5*6e4;function Z4(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function exn(e,t){const n=Z4(t),r=Z4(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1)),i=[];let a=null,s=null;for(const o of U9t(e)){const l=new Date(o.created_at),c=!Number.isNaN(l.getTime()),u=c?Z4(l):null;u!==null&&u!==s&&i.push({type:"day",key:u,date:l,relative:u===n?"today":u===r?"yesterday":null});const O=a!==null&&c&&u===s&&a.sender.account_id===o.sender.account_id&&a.sender.kind===o.sender.kind&&l.getTime()-Date.parse(a.created_at)<K9t;i.push({type:"message",message:o,continuation:O}),a=o,u!==null&&(s=u)}return i}const Nte="Team Bridge create answered for another tenant",V4=new WeakMap;async function txn(e){if(V4.get(e.remembered)?.has(e.draftKey))throw new Error(Nte);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=V4.get(e.remembered)??new Set;throw r.add(e.draftKey),V4.set(e.remembered,r),new Error(Nte)}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 J9t=["channel","here","everyone"];function nxn(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=J9t.find(p=>aTe(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 s=c=>r!==null&&r.labelUnique===!0&&c.kind==="human"&&c.accountId===r.accountId&&!n.some(u=>u.accountId!==r.accountId&&Gi(u.label)===Gi(c.label)),o=new Map;for(const c of i)c.label===""||!t.includes(`@${c.label}`)||o.set(c.label,(o.get(c.label)??!1)||s(c));const l=[...o].map(([c,u])=>({label:c,viewer:u}));return l.length>0?{source:"fallback",runs:l,caseSensitive:!0}:null}const zte=/[\p{L}\p{N}_]/u;function aTe(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 s="",o=0;for(;o<e.length;){const l=o===0?"":e.charAt(o-1),c=e.charAt(o)==="@"&&!zte.test(l)&&l!=="."?i.find(O=>{const f=o+1+O.label.length;return r(e.slice(o+1,f),O.label)&&!zte.test(e.charAt(f))}):void 0;if(!c){s+=e.charAt(o),o+=1;continue}s&&a.push({kind:"text",text:s}),s="";const u=o+1+c.label.length;a.push({kind:"mention",text:e.slice(o,u),viewer:c.viewer}),o=u}return s&&a.push({kind:"text",text:s}),a}const e8t="team-bridge-mention rounded-sm px-0.5 font-medium bg-accent-wash text-accent",t8t="team-bridge-mention rounded-sm px-0.5 font-medium bg-warning-wash text-warning";function n8t(e){return()=>t=>{$P(t,"text",(n,r,i)=>{if(!i||r===void 0||!n.value.includes("@"))return;const a=aTe(n.value,e);if(a.some(s=>s.kind==="mention"))return i.children.splice(r,1,...a.map(s=>s.kind==="text"?{type:"text",value:s.text}:{type:"mention",data:{hName:"span",hProperties:{className:s.viewer?t8t:e8t,"data-mention":s.viewer?"viewer":"other"}},children:[{type:"text",value:s.text}]})),r+a.length})}}const r8t=/^(https?:|mailto:)/i,i8t={a:({href:e,children:t})=>typeof e=="string"&&r8t.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:Dz},sTe=$.memo(({children:e,className:t,mentions:n,style:r})=>{const i=$.useMemo(()=>n?.length?[So,Ol,n8t(n)]:[So,Ol],[n]);return d.jsx("div",{className:R("lo-markdown",t),style:r,children:d.jsx(Gy,{remarkPlugins:i,components:i8t,children:e})})});sTe.displayName="TeamBridgeMarkdown";const oTe=8,a8t="… deeper values not shown",s8t="(empty)";function o8t(e){return`… ${e} more line${e===1?"":"s"}`}const Ute=.5;function l8t(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 s=Math.max(1,Math.round(a.height/t));for(let o=1;o<=s;o++)a.top+o*t>n+r&&i++}return i}function lTe(e){return e==null?"null":typeof e=="string"?e.trim()||null:typeof e=="number"||typeof e=="boolean"?String(e):null}function ZW(e){return typeof e=="object"&&e!==null}function cTe(e,t,n,r){if(n>oTe){r.push({key:t,value:a8t,depth:n});return}if(ZW(e)){for(const[a,s]of Object.entries(e))cTe(s,t?`${t}.${a}`:a,n+1,r);return}const i=lTe(e);i!==null&&r.push({key:t,value:i,depth:n})}function uTe(e){if(!e)return[];const t=[];for(const[n,r]of Object.entries(e))cTe(r,n,1,t);return t}const c8t=512;function u8t(e,t){if(t)return!0;if(!e)return!1;let n=c8t;const r=(i,a)=>{if(n--<=0||a>oTe)return!0;if(!ZW(i))return lTe(i)!==null;for(const s of Object.values(i))if(r(s,a+1))return!0;return!1};for(const i of Object.values(e))if(r(i,1))return!0;return!1}function O8t(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(!ZW(n))return null;const r=uTe(n);return r.length>0?r:[{key:"",value:s8t,depth:1}]}const d8t=8,Eb="max-h-[min(320px,40vh)]",OTe=Eb,dTe=({line:e})=>d.jsxs("div",{className:R("whitespace-pre-wrap break-words"),style:{paddingInlineStart:(e.depth-1)*d8t},children:[e.key?d.jsxs("span",{className:R("text-ink-muted"),children:[e.key,": "]}):null,d.jsx("span",{className:R("text-ink-dim"),children:e.value})]}),Ite=({lines:e,section:t})=>d.jsx("div",{className:R("flex flex-col gap-1"),"data-detail-lines":t,children:e.map((n,r)=>d.jsx(dTe,{line:n},r))});function Wte(e){const[t,n]=$.useState(0),[r,i]=$.useState(!1);return $.useLayoutEffect(()=>{const a=e.current;if(!a)return;const s=a.firstElementChild,o=()=>{const c=s??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+Ute);const p=c.children.length>0?Array.from(c.children):[c];n(l8t(p.map(m=>{const g=m.getBoundingClientRect();return{top:g.top,height:g.height}}),u,O.bottom,Ute))};o(),a.addEventListener("scroll",o,{passive:!0});const l=new ResizeObserver(o);return l.observe(s??a),()=>{a.removeEventListener("scroll",o),l.disconnect()}}),{lines:t,overflowing:r}}const Dte=({lines:e,overflowing:t})=>t?d.jsx("span",{className:R("mt-1 block text-ink-dim"),children:e>0?o8t(e):" "}):null,f8t=({args:e,output:t,isError:n,interrupted:r=!1,note:i=null})=>{ke();const a=uTe(e),s=O8t(t),o=$.useRef(null),l=$.useRef(null),c=Wte(o),u=Wte(l);return a.length===0&&!t&&!i?null:d.jsxs("div",{className:R("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:o,className:R(Eb,"overflow-auto"),children:d.jsx(Ite,{lines:a,section:"input"})}),d.jsx(Dte,{lines:c.lines,overflowing:c.overflowing})]}),i&&d.jsx("div",{className:R("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:R(a.length>0&&"mt-3"),"data-detail-section":"output",children:[d.jsx("span",{className:R("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:R(Eb,"overflow-auto"),children:s?d.jsx(Ite,{lines:s,section:"result-json"}):d.jsx("pre",{className:R("whitespace-pre font-mono",n&&!r?"text-danger":"text-ink"),children:t})}),d.jsx(Dte,{lines:u.lines,overflowing:u.overflowing})]})]})},fTe=({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:R("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:R("font-medium text-ink"),"data-detail-section":"bridge-target",children:e.headline}):null,e.body?d.jsx("div",{className:R(Eb,"overflow-auto text-ink"),"data-detail-section":"bridge-body",children:d.jsx(sTe,{children:e.body})}):null,i?d.jsx("div",{className:R("whitespace-normal",t?"text-danger":"text-ink-muted"),"data-detail-section":"bridge-outcome",children:i}):null,r,a?d.jsx(Vi,{chevron:"trailing",chevronClassName:"text-ink-dim",summary:d.jsx("span",{className:R("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:R(Eb,"overflow-auto pt-1 font-mono text-mono-sm"),children:[e.internals.map(s=>d.jsx(dTe,{line:{key:s.key,value:s.value,depth:1}},s.key)),e.raw?d.jsx("pre",{className:R("mt-2 whitespace-pre-wrap break-words font-mono text-ink-dim"),children:e.raw}):null]})}):null]})},h8t="mcp__",p8t={bash:Cze,read:jy,write:ZG,edit:ZG,glob:$m,grep:_1,todo:vNe,wake:uh,list_variables:KG,read_variable:KG,browser:VG,console:efe,project:y8e,project_delete:qze,web_search:VG,web_fetch:iP,task:U$,agent:U$,send:sS,peer:fNe,sessions:Oze,bridge:NNe};function m8t(e){const t=e.trim().toLowerCase(),n=p8t[t];return n||(t.startsWith(h8t)?tfe:Fze)}const g8t=VN,$8t=kNe,y8t=_Ne,b8t=ENe,v8t=Bde,Yte="min-h-5 py-0",Gte={read:"text-info",mutate:"text-ink-muted",exec:"text-ink-muted",meta:"text-accent-alt",plain:"text-ink-muted"},w8t=(e,t)=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":e==="receipt"?Gte.plain:Gte[sAe(t)],x8t=e=>e==="running"?"text-accent":e==="error"||e==="not-run"?"text-danger":"text-ink-muted",_8t=({added:e,removed:t})=>e<=0&&t<=0?null:d.jsxs("span",{className:R("hidden shrink-0 gap-1 font-mono text-mono-sm tabular-nums @[34rem]/toolrow:flex"),children:[e>0&&d.jsxs("span",{className:R("text-success"),children:["+",e]}),t>0&&d.jsxs("span",{className:R("text-danger"),children:["-",t]})]}),S8t={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:""},F4=e=>{const t=S8t[e];return t===""?"":h(t)},k8t=1e3;function Q8t(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,k8t);return()=>window.clearInterval(i)},[e]),t}const P8t=({toolName:e="",outcome:t,deliveryState:n=null,failureWord:r=null,durationS:i,startedAt:a})=>{const s=t==="running",o=Q8t(s?a??null:null),l=t==="error"||t==="not-run",c=t==="partial",u=oAe(n,e),O=c?u:l?u??r??F4(t):null,f=c?"text-warning":"text-danger",p=c?lAe(n,e):null,m=R("font-medium text-meta",f,c&&(p?"hidden @[40rem]/toolrow:inline":"hidden @[19rem]/toolrow:inline")),g=R("font-medium text-meta",f,"hidden @[20rem]/toolrow:inline @[40rem]/toolrow:hidden"),y=c?cAe(n,e):null,b=c?uAe(n,e):void 0,v=c?n==="mailbox"?$8t:n==="unconfirmed"?y8t:n==="inbox_only"?b8t:n==="awaiting_acceptance"?v8t:null:t==="interrupted"?g8t:null,x=v&&c?"text-warning":"text-ink-dim",S=s?a==null?"":FO(o??0):TN(i);return d.jsxs("span",{className:R("flex shrink-0 items-center gap-1.5"),children:[O?d.jsx("span",{className:m,title:b,"aria-hidden":y?!0:void 0,children:O}):null,O&&p?d.jsx("span",{className:g,title:b,"aria-hidden":y?!0:void 0,"data-status-word":"short",children:p}):null,d.jsxs("span",{className:R("flex shrink-0 [&_svg]:size-3.5",v&&"size-3.5",x),children:[v?d.jsx(v,{"aria-hidden":!0}):null,!l&&F4(t)?d.jsx("span",{className:R("sr-only"),children:F4(t)}):null,y?d.jsx("span",{className:R("sr-only"),children:y}):null]}),d.jsx("span",{className:R("hidden w-[5ch] text-right font-mono text-ink-dim text-mono-sm tabular-nums @[19rem]/toolrow:inline"),children:S})]})},gu=({toolName:e,op:t="",verbless:n=!1,summary:r,summaryFallback:i=null,summaryHold:a=!1,summaryWrap:s=!1,summaryIsCopy:o=!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:b=!1,className:v,media:x})=>{const S=hc(),w=l==="running",_=l==="error",k=m8t(e),Q=Ty(e),{verb:X,object:C}=ade(e,r,i,w,t,u??aAe(c)),T=d.jsxs("span",{className:R("flex min-w-0 flex-1 items-center gap-2"),children:[d.jsx("span",{"aria-hidden":!0,className:R("flex size-3.5 shrink-0 [&_svg]:size-3.5",w8t(l,e)),children:d.jsx(k,{})}),n?null:d.jsx("span",{"data-trace-verb":"",className:R("min-w-0 truncate text-body-sm",x8t(l)),title:`${X} (${Q})`,children:X}),d.jsx("span",{className:R(s?"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:C,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:R("sr-only"),children:h("ui.chat.canonical.tool_row.pending")})]}):d.jsx("bdi",{dir:o?S:"ltr",children:C})}),d.jsx(_8t,{added:m,removed:g}),d.jsx(P8t,{toolName:e,outcome:l,deliveryState:c,failureWord:O,durationS:f,startedAt:p})]}),A=w?{"data-glass-state":"running"}:void 0,z=w?"bg-elevated":_?"bg-danger-wash":"hover:bg-row-hover",Y=y?d.jsx(Vi,{summary:T,chevron:"leading",defaultOpen:b,className:R("@container/toolrow",v),triggerData:A,rowClassName:Yte,triggerClassName:R("-mx-2 rounded-sm px-2",z),children:y}):d.jsx(Vi,{disabled:!0,summary:T,triggerData:A,rowClassName:Yte,className:R("@container/toolrow",(w||_)&&R("-mx-2 rounded-sm px-2",z),v)});return x?d.jsxs("div",{className:R("flex flex-col"),children:[Y,x]}):Y},T8t=3,E8t=2;function R8t(e){const t={incoming:0,job_result:0,wake:0,monitor_prompt:0};let n=!1,r=!1;for(const{record:s}of e){const o=sde(s);o&&(t[o]+=1),s.kind==="custom"&&(s.receipt?.expectsReply===!0&&(n=!0),s.receipt?.steer===!0&&(r=!0))}const i=[],a=(s,o)=>{s>0&&i.push(o(s))};return a(t.incoming,s=>h("ui.chat.canonical.fold.receipt.incoming",{count:s})),a(t.job_result,s=>h("ui.chat.canonical.fold.receipt.job_result",{count:s})),a(t.wake,s=>h("ui.chat.canonical.fold.receipt.wake",{count:s})),a(t.monitor_prompt,s=>h("ui.chat.canonical.fold.receipt.monitor_prompt",{count:s})),a(e.length-t.incoming-t.job_result-t.wake-t.monitor_prompt,s=>h("ui.chat.canonical.fold.receipt.other",{count:s})),n&&i.push(h("ui.chat.canonical.fold.receipt.reply_requested")),r&&i.push(h("ui.chat.canonical.fold.receipt.steered")),i}const hTe=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},X8t=(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})}},pTe=()=>h("ui.chat.canonical.fold.unit_separator"),mTe=e=>{const t=new Map;let n=0;for(const s of e){const o=hTe(s.name);o===null?n+=1:t.set(o,(t.get(o)??0)+1)}const r=VW(e);if(n>0||t.size>2){const s=gTe(r);return{units:s.length===0?[h("ui.chat.canonical.fold.count.actions",{count:e.length})]:s,prose:!1,countUnits:r}}const i=["files","searches","web","commands","edits","delegated"],a=[];for(const s of i){const o=t.get(s)??0;o!==0&&a.push(X8t(s,o,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}},C8t=e=>mTe(e).units;function A8t(e){return C8t(e).join(pTe())}const B4={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})}},H4=5,gTe=e=>{if(e.length<=H4)return e.map(r=>r.label);const t=e.slice(0,H4),n=e.slice(H4).reduce((r,i)=>r+i.count,0);return[...t.map(r=>r.label),h("ui.chat.canonical.fold.count.other_actions",{count:n})]},VW=e=>{const t=new Map,n=(s,o)=>{const l=t.get(s);l?l.count+=1:t.set(s,{kind:o,count:1})};for(const s of e){const o=s.name.toLowerCase();if(o==="bash"||o==="exec"||o==="shell"||o==="run"){n("kind:shell",{sort:"shell",label:c=>h("ui.chat.canonical.fold.count.shell",{count:c})});continue}if(o==="eval"){n("kind:python",{sort:"python",label:c=>h("ui.chat.canonical.fold.count.python",{count:c})});continue}const l=hTe(s.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(o==="todo")(s.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",B4.todo);else if(o==="jobs")(s.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",B4.jobs);else if(o==="bridge")OAe.has((s.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=B4[o];if(c)n(`kind:${o}`,c);else{const u=Ty(s.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 s of r){const o=t.get(s);o&&i.push({key:s,label:o.kind.label(o.count),count:o.count})}const a=[...t.entries()].filter(([s])=>!r.includes(s)).sort(([,s],[,o])=>o.count-s.count||s.kind.sort.localeCompare(o.kind.sort));for(const[s,o]of a)i.push({key:s,label:o.kind.label(o.count),count:o.count});return i};function q8t(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 j8t(e){let t=null,n=null,r=!1;for(const i of e){i.running===!0&&(r=!0);const a=q8t(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 N8t(e){for(let t=e.length-1;t>=0;t-=1){const n=e[t];if(n.executing===!0)return ade(n.name,n.summary??"",null,!0,n.op)}return null}function z8t(e,t){let n=0;for(let r=e.length-1;r>=0&&t(e[r]);r-=1)n+=1;return n}function U8t(e,t){const n=[];let r=[];const i=()=>{if(r.length===0)return;const a=r.filter(O=>t.isReceipt?.(O)),s=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}),o=a.length?t.receiptSummaryOf?.(a)??[]:[],l=o.length>0?o:a.length>0?[`${a.length} receipt${a.length===1?"":"s"}`]:[],c=t.isReceipt?z8t(r,t.isReceipt):0,u=t.liveTurn===!0&&t.latchedFoldIds!==void 0&&r.some(O=>t.latchedFoldIds?.has(O.record.id)===!0);if(s.length>=T8t||c>=E8t||u){const O=(()=>{if(s.length===0)return{units:[],prose:!1,countUnits:[]};const f=VW(s);return l.length>0?{units:gTe(f),prose:!1,countUnits:f}:mTe(s)})();n.push({kind:"run",id:r[0].record.id,gap:r[0].gap,rows:r,actions:s,summary:{units:[...O.units,...l],prose:O.prose,countUnits:O.countUnits},failedCount:s.filter(f=>f.failed).length,span:j8t(s),live:N8t(s)})}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 I8t(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 Lte=e=>{const t=[];for(const n of e)if(!(n.record.kind!=="tool"&&!(n.record.kind==="custom"&&sde(n.record)==="incoming")))for(const r of n.record.images??[])fm(r)&&t.push(r);return t},q_=5,W8t=(e,{uncapped:t=!1}={})=>t?{shown:Math.max(e,0),more:0}:e<q_?{shown:Math.max(e,0),more:0}:{shown:q_-1,more:e-(q_-1)},D8t=e=>{const t=q_-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},Xk=e=>e<=0?null:`${e} image${e===1?"":"s"}`;function Ck(e){return e.record.kind==="tool"?e.record.durationS:null}function $Te(e){let t=null;for(const n of e){const r=Ck(n);typeof r=="number"&&(t=(t??0)+r)}return t}function Y8t(e,t){const n=new Map,r=t.opensRun??(l=>l.gap==="turn"||l.gap==="first");let i=0,a=0,s=null,o=null;for(const l of e){if(r(l)&&(i=0,a=0,s=null,o=null),t.isAction(l)){i+=1,t.failedOf(l)&&(a+=1,o??=l.record.id);const c=t.durationOf?t.durationOf(l):null;typeof c=="number"&&(s=(s??0)+c)}l.closesTurn&&n.set(l.record.id,{actions:i,failed:a,durationS:s,firstFailedId:o})}return n}const G8t="min-h-5 py-0",L8t=(e,t)=>e.map(n=>t==="rtl"?`⁧${n}⁩`:n).join(pTe()),M8t=1e3;function Z8t(e){const[t,n]=$.useState(()=>Date.now());return $.useEffect(()=>{if(!e)return;const r=()=>n(Date.now());r();const i=window.setInterval(r,M8t);return()=>window.clearInterval(i)},[e]),t}const V8t=({summary:e,span:t,live:n,open:r,onOpenChange:i,className:a,condensedMedia:s,mediaCount:o=0,recordIds:l,children:c})=>{const u=hc(),O=Z8t(t?.running===!0),f=t===null?null:Math.max(0,((t.running?O:t.endedAtMs??O)-t.startedAtMs)/1e3),p=f===null?"":TN(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(Vi,{animate:r||!s,open:r,onOpenChange:i,rowClassName:G8t,triggerClassName:R("-mx-2 rounded-sm px-2","hover:bg-row-hover"),summary:d.jsxs("span",{className:R("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:R("min-w-0 shrink-[100000] truncate"),title:`${n.verb} ${n.object}`,children:[d.jsx("span",{className:R("text-accent"),children:n.verb})," ",d.jsx("span",{className:R("font-mono text-mono-sm text-ink-muted"),children:n.object})]}),d.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"})]}),d.jsx("span",{className:R("min-w-0 break-words text-body-sm text-ink-muted"),title:L8t(e.units,u),"data-fold-summary":"",children:e.units.map((y,b)=>d.jsxs($.Fragment,{children:[b>0&&d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:R(e.prose?"whitespace-normal":"whitespace-nowrap"),children:d.jsx("bdi",{dir:u,children:y})})]},y))}),Xk(o)!==null&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{className:R("shrink-0 text-ink-muted text-meta"),children:Xk(o)})]}),p!==""&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),d.jsx("span",{"data-fold-span":"",className:R("shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:p})]})]}),children:d.jsx("div",{className:R("flex flex-col"),children:c})}),!r&&s&&s(g)]})},Mte=["⣾","⣽","⣻","⢿","⡿","⣟","⣯","⣷"],F8t=80,B8t=1e3,yTe=({activity:e,phase:t,startedAt:n,clock:r,className:i})=>{const[a,s]=$.useState(0),[o,l]=$.useState(()=>n===void 0?0:Math.floor((Date.now()-n)/1e3)),[c,u]=$.useState(!1),O=r!==!1&&!c,f=bz("(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 v=g.current!==void 0&&n===void 0;g.current=n,u(v),v||(p.current=n,l(Math.floor((Date.now()-n)/1e3)))}const y=$.useRef(r!==!1),b=$.useRef(t);return $.useEffect(()=>{const v=r!==!1,x=y.current,S=b.current===t;y.current=v,b.current=t,!x&&v&&S&&l(Math.floor((Date.now()-p.current)/1e3))},[r,t]),$.useEffect(()=>{const v=O?window.setInterval(()=>l(Math.floor((Date.now()-p.current)/1e3)),B8t):null;if(f)return s(0),()=>{v!==null&&window.clearInterval(v)};const x=window.setInterval(()=>s(S=>(S+1)%Mte.length),F8t);return()=>{window.clearInterval(x),v!==null&&window.clearInterval(v)}},[f,O]),d.jsxs("div",{className:R("flex items-center gap-2",i),"data-lo-working-line":!0,"aria-live":"polite",children:[d.jsx("span",{"aria-hidden":!0,className:R("w-[1ch] shrink-0 select-none font-mono text-ink-muted text-mono-sm"),children:Mte[a]}),d.jsx("span",{className:R("min-w-0 truncate font-mono text-ink-dim text-mono-sm"),children:e}),d.jsx("span",{"aria-hidden":!0,className:R("w-[6ch] shrink-0 font-mono text-ink-dim text-mono-sm tabular-nums"),children:O?FO(o):""})]})},H8t="min-h-5 py-0",hO=()=>d.jsx("span",{"aria-hidden":!0,className:R("text-ink-dim text-meta"),children:"·"}),K8t=({recordIds:e,segmentIds:t,anchorRecordId:n,className:r,durationS:i,actionCount:a,partial:s=!1,title:o,stampTs:l,label:c=null,completed:u=!1,open:O,onOpenChange:f,children:p,condensedMedia:m,mediaCount:g=0,group:y=null,episode:b=null})=>{ke();const v=s?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`,S=b?.receipts??y?.count,w=S===void 0?null:`At least ${S} messages — earlier rows are not loaded`,_=$.useRef(null),k=()=>{_.current?.querySelector("button[aria-expanded]")?.focus(),f(!0)};return c===null&&i===null&&a===0&&y===null&&b===null&&g===0?null:d.jsxs("div",{ref:_,className:R("border-b border-hairline pb-3",r),"data-turn-summary":"","data-run-ids":e.join(" "),"data-segment-ids":t?.join(" "),"data-segment-complete":u&&!b?.active?"true":void 0,"data-segment-active":b?.active?"true":void 0,"data-record-id":n,children:[d.jsx(Vi,{open:O,onOpenChange:f,chevron:"trailing",rowClassName:H8t,triggerClassName:R("-ms-2 -me-2 w-[calc(100%+1rem)] rounded-sm ps-2 pe-6","hover:bg-row-hover"),chevronClassName:R("-mr-6","text-ink-muted"),summary:d.jsxs("span",{className:R("flex min-w-0 flex-1 items-center gap-2"),title:o??void 0,children:[c!==null&&d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),"data-segment-label":"",children:c}),u&&!b?.active&&d.jsx(d.Fragment,{children:d.jsx(UN,{"aria-hidden":!0,className:R("size-3.5 shrink-0 text-success")})}),b?.active?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(hO,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:s?w??void 0:void 0,"aria-label":s?w??void 0:void 0,children:s?`${b.receipts}+`:b.receipts}),a>0&&d.jsxs(d.Fragment,{children:[d.jsx(hO,{}),d.jsx("span",{className:"shrink-0 text-body-sm text-ink-muted",title:s?x:void 0,children:d.jsx("bdi",{children:v})})]}),b.phaseLine!==null&&d.jsxs(d.Fragment,{children:[d.jsx(hO,{}),d.jsx(yTe,{activity:b.phaseLine.activity,phase:b.phaseLine.phase,startedAt:b.phaseLine.startedAt,clock:b.phaseLine.clock,className:"min-w-0"})]})]}):y!==null?d.jsxs(d.Fragment,{children:[c!==null&&d.jsx(hO,{}),d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),title:s?w??void 0:void 0,"aria-label":s?w??void 0:void 0,children:s?`${b?.receipts??y.count}+`:`${b?.receipts??y.count}`}),y.spanS!==null&&d.jsxs(d.Fragment,{children:[d.jsx(hO,{}),d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:FO(y.spanS)})]})]}):d.jsxs(d.Fragment,{children:[c!==null&&(i!==null||a>0)&&d.jsx(hO,{}),i!==null&&d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:h("ui.chat.canonical.turn_summary.took",{duration:FO(i)})}),i!==null&&a>0&&d.jsx(hO,{}),a>0&&d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),title:s?x:void 0,"aria-label":s?x:void 0,children:d.jsx("bdi",{children:v})})]}),Xk(g)!==null&&d.jsxs(d.Fragment,{children:[d.jsx(hO,{}),d.jsx("span",{className:R("shrink-0 text-body-sm text-ink-muted"),children:Xk(g)})]}),u&&!b?.active&&d.jsx("span",{className:R("sr-only"),children:h("ui.chat.canonical.turn_summary.completed")}),l!==null&&d.jsx("span",{className:R("ms-auto"),children:d.jsx(Ek,{timestamp:l,scope:"answer"})})]}),children:d.jsx("div",{className:R("flex flex-col"),children:p})}),!O&&m&&d.jsx("div",{className:R("pb-2"),children:m(k)})]})},bTe="lo-missing-session-notice";function J8t(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 vTe(e){const t=$.useRef(null);return $.useEffect(()=>{e&&t.current?.focus({preventScroll:!0})},[]),t}const Xu=({children:e,className:t,boundary:n="hairline",...r})=>d.jsx("div",{className:R("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}),eNt="could not be displayed. It may have been moved, renamed, or deleted.",FW="could not be displayed. Its stored copy is not available to this reader.",wTe="could not be played. Its stored copy is not available to this reader.",xTe=wTe,eh=({name:e,detail:t=eNt,className:n,compact:r=!1})=>r?d.jsx("div",{className:R("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(BG,{className:"size-4 shrink-0 text-ink-dim","aria-hidden":!0})}):d.jsxs("div",{className:R("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(BG,{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}`]})]}),uv=({name:e,onRetry:t,className:n,compact:r=!1,device:i=null,focusOnMount:a=!1})=>{const s=vTe(a),o=i?h("ui.canvas.files.remoteUnreachable",{device:i}):null,l=o??h("ui.chat.attachments.owner_unreachable"),c=h("ui.chat.attachments.retry_fetch");return r?d.jsxs("button",{ref:s,type:"button",onClick:u=>{u.stopPropagation(),t()},className:R("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(EG,{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:R("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(EG,{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}),o?d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":!0,children:" · "}),o]}):` ${l}`]}),d.jsx("button",{ref:s,type:"button",onClick:u=>{u.stopPropagation(),t()},className:"shrink-0 rounded-sm px-1 text-accent text-body-sm hover:underline",children:c})]})},BW=({device:e,compact:t=!1,video:n=!1,focusOnMount:r=!1})=>{const i=vTe(r),a=h("ui.canvas.files.remoteFetching",{device:e}),s=r?{ref:i,tabIndex:-1,"aria-busy":!0}:{};return t?d.jsx("output",{...s,"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(Oi,{size:"sm",className:"text-ink-dim"})}):n?d.jsxs("output",{...s,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(Oi,{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",{...s,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(Oi,{size:"sm",className:"text-ink-dim"}),d.jsx("span",{className:"min-w-0 truncate text-body-sm text-ink-muted",children:a})]})},tNt="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",Ak=4,_Te=2,nNt=2,STe=4,kTe=Ak+_Te,rNt=.8,iNt=24,Zte=.3,Vte=1;function aNt(e){return!Number.isFinite(e)||e<=0?1:Math.max(1,Math.floor((e+_Te)/kTe))}function sNt(e,t){const n=Math.min(e,t-e);return Number.isFinite(n)?Math.max(0,Math.min(1,n/iNt)):0}function oNt(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),s=Math.max(a+1,Math.floor((i+1)*r));let o=0;for(let l=a;l<s&&l<e.length;l+=1){const c=e[l];Number.isFinite(c)&&c>o&&(o=c)}n[i]=Math.max(0,Math.min(1,o))}return n}function QTe(e,t,n){const r=aNt(t),i=e===null?null:oNt(e,r),a=[],s=Math.max(1,r-1);for(let o=0;o<r;o+=1){const l=o*kTe,c=l+Ak/2,O=(i===null?0:i[o])*n*rNt,f=Math.max(STe,Math.round(O)),p=Zte+(Vte-Zte)*(o/s);a.push({x:l,width:Ak,height:f,alpha:Math.min(Vte,p)*sNt(c,t)})}return a}function gy(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 lNt(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 cNt(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}const Fte=(e,t)=>h("ui.chat.audio.position_value",{current:gy(e),total:gy(t)}),uNt=4,Bte=1,PTe=({ownerId:e,src:t,label:n,peaks:r,durationHint:i=null,hideUnknownTotal:a=!1,variant:s="full",className:o})=>{const l=ke(),c=na(M=>M.ownerId===e),u=na(M=>M.ownerId===e?M.status:"idle"),O=na(M=>M.ownerId===e?M.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,b=c&&u==="playing",v=c&&u==="loading",x=m||c&&u==="error",S=$.useRef(null),w=$.useRef(null),_=$.useRef(null),k=$.useRef(null),Q=$.useRef(null),[X,C]=$.useState({width:0,height:0,dpr:1});$.useEffect(()=>{const M=S.current;if(!M)return;const ie=()=>{const F=M.getBoundingClientRect();C({width:F.width,height:F.height,dpr:window.devicePixelRatio||1})};ie();const ee=new ResizeObserver(ie);return ee.observe(M),()=>ee.disconnect()},[]);const T=$.useCallback(M=>{if(!M||X.width<=0)return;const ie=M.getContext("2d");if(!ie)return;M.width=Math.max(1,Math.round(X.width*X.dpr)),M.height=Math.max(1,Math.round(X.height*X.dpr)),ie.setTransform(X.dpr,0,0,X.dpr,0,0),ie.clearRect(0,0,X.width,X.height);const ee=getComputedStyle(M).color,F=QTe(r,X.width,X.height);ie.fillStyle=ee;for(const H of F)ie.globalAlpha=H.alpha,ie.beginPath(),ie.roundRect(H.x,(X.height-H.height)/2,H.width,H.height,nNt),ie.fill();ie.globalAlpha=1},[X.width,X.height,X.dpr,r]);$.useEffect(()=>{T(w.current),T(_.current)},[T]);const A=$.useRef(null),z=$.useCallback(M=>{const ie=cNt(M,y),ee=_.current;S.current?.style.setProperty("--sound-progress",`${ie*100}%`),ee&&(ee.style.clipPath=`inset(0 ${(1-ie)*100}% 0 0)`);const F=gy(M);Q.current&&Q.current.textContent!==F&&(Q.current.textContent=F);const H=k.current;H&&(H.setAttribute("aria-valuenow",String(Math.floor(M))),H.setAttribute("aria-valuetext",Fte(M,y)))},[y,l]);$.useEffect(()=>{const M=b||f,ie=()=>z(c?RE()?.currentTime??0:U.current);if(!M){ie();return}let ee=0;const F=()=>{const H=A.current??RE()?.currentTime??0;z(H),ee=requestAnimationFrame(F)};return ee=requestAnimationFrame(F),()=>cancelAnimationFrame(ee)},[b,f,c,z]);const Y=$.useCallback(async()=>(g(!1),na.getState().play(e,t,{onError:()=>g(!0)})),[e,t]),G=$.useCallback(M=>{const ie=na.getState();if(b){ie.seek(e,M),z(M);return}Y().then(ee=>{ee!==!1&&(na.getState().seek(e,M),z(M))})},[e,b,Y,z]),j=$.useCallback(async()=>{if(b){na.getState().pause(e);return}g(!1),await na.getState().toggle(e,t,{onError:()=>g(!0)})},[e,t,b]),U=$.useRef(0),D=$.useRef(null),Z=$.useCallback(M=>{const ie=S.current;if(!ie)return 0;const ee=ie.getBoundingClientRect();return lNt(M-ee.left,ee.width,y)},[y]),N=M=>{if(v)return;M.currentTarget.setPointerCapture?.(M.pointerId),D.current={pointerId:M.pointerId,startX:M.clientX,moved:!1,pendingX:M.clientX,raf:0}},L=M=>{const ie=D.current;!ie||ie.pointerId!==M.pointerId||(Math.abs(M.clientX-ie.startX)>uNt&&(ie.moved||p(!0),ie.moved=!0),ie.pendingX=M.clientX,ie.moved&&ie.raf===0&&(ie.raf=requestAnimationFrame(()=>{const ee=D.current;if(!ee)return;ee.raf=0;const F=Z(ee.pendingX);A.current=F,na.getState().scrub(e,F),z(F)})))},J=M=>{const ie=D.current;if(!ie||ie.pointerId!==M.pointerId)return;ie.raf!==0&&cancelAnimationFrame(ie.raf),D.current=null,A.current=null,M.currentTarget.releasePointerCapture?.(M.pointerId);const ee=Z(M.clientX);if(ie.moved){U.current=ee,p(!1),na.getState().seek(e,ee),z(ee);return}G(ee)},W=M=>{const ie=RE(),ee=c&&ie?ie.currentTime:0;if(M.key===" "||M.key==="Enter"){M.preventDefault(),j();return}let F=null;if(M.key==="ArrowLeft"?F=ee-Bte:M.key==="ArrowRight"?F=ee+Bte:M.key==="Home"?F=0:M.key==="End"&&(F=y),F===null)return;M.preventDefault();const H=Math.max(0,Math.min(y,F));G(H)},fe=s==="compact",te=h("ui.chat.audio.position_label",{label:n});return d.jsxs("div",{"data-sound-player":s,"data-sound-peaks":r?"stored":"flat","data-sound-status":x?"error":f?"scrubbing":c?u:"idle",className:R("flex w-full min-w-0 items-center gap-2",fe?"gap-1.5":"gap-2",o),children:[d.jsx("button",{type:"button",className:tNt,disabled:v,onClick:()=>void j(),"aria-label":b?h("ui.chat.audio.pause_label",{label:n}):h("ui.chat.audio.play_label",{label:n}),children:v?d.jsx(Oi,{size:"sm"}):b?d.jsx(Lde,{size:22,"aria-hidden":"true"}):d.jsx(f8e,{size:22,"aria-hidden":"true"})}),d.jsx("div",{ref:k,role:"slider",tabIndex:0,"aria-label":te,"aria-valuemin":0,"aria-valuemax":Math.max(0,Math.round(y)),"aria-valuenow":0,"aria-valuetext":Fte(0,y),"data-sound-slider":"",className:R("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:N,onPointerMove:L,onPointerUp:J,onPointerCancel:J,onKeyDown:W,children:d.jsxs("div",{ref:S,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:_,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:R("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:Q,"data-sound-time":"",className:R("min-w-10 shrink-0 text-center text-meta text-ink-muted tabular-nums"),children:gy(0)}),d.jsx("span",{"data-sound-total":"","aria-hidden":a&&y<=0?!0:void 0,className:R("min-w-10 shrink-0 text-center text-meta text-ink-dim tabular-nums",a&&y<=0&&"invisible"),children:gy(y)}),x?d.jsx("span",{"data-sound-error":"",className:R("shrink-0 text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.player_failed")}):null]})};function K4(e){return e.live_state.trim().toLowerCase()==="attached"}function rxn(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 ixn(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 hf(e,t){return h("ui.mesh.mesh_drop.copy_loss",{source:e,destination:t})}function Hte(e,t){return h("ui.mesh.mesh_drop.running_now",{conversation:e.name||h("ui.mesh.mesh_drop.this_conversation"),where:t})}function Kte(e,t,n){return e?Ey(e,n,!0):t}function ONt(e,t,n){if(e.suspect)return{kind:"refused",code:"suspect_device",sentence:h("ui.mesh.mesh_drop.duplicate_key",{device:Ey(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=ode(lde(e));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.reach_refusal",{device:Ey(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 axn(e,t,n){const{session:r,ownerDeviceId:i}=e,{selfDeviceId:a,devices:s,networks:o}=n,l=[...s.keys()],c=s.get(i),u=c?Ey(c,l,!0):Ey({id:i,name:r.owner_device_name});if(t.kind==="ground")return{kind:"none"};if(t.kind==="network"){const b=o.get(t.networkId);return{kind:"refused",code:"not_a_device",sentence:h("ui.mesh.mesh_drop.network_not_destination",{network:b?.label??h("ui.mesh.mesh_drop.a_network")}),remedy:null}}if(dAe(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:Kte(s.get(t.deviceId),t.deviceId,l)}),waitS:0,lost:null}};if(i===t.deviceId)return{kind:"none"};const O=s.get(t.deviceId),f=O?ONt(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=Kte(O,t.deviceId,l);if(!(r.locality==="local")){if(c&&!c.reachable){const b=ode(lde(c));return{kind:"refused",code:"unreachable",sentence:h("ui.mesh.mesh_drop.owner_reach_refusal",{device:u,reach:b,reason:c.reason?` (${c.reason})`:""}),reach:b,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 b={sessionId:r.id,to:"local",keep:!1,verb:h("ui.mesh.mesh_card.recall_to_this_device"),waitS:0,lost:K4(r)?`${Hte(r,h("ui.mesh.mesh_drop.on_owner",{owner:u}))} ${hf(u,h("ui.mesh.mesh_drop.this_device"))}`:hf(u,h("ui.mesh.mesh_drop.this_device"))};return{kind:"plan",plan:b,risky:K4(r),alternatives:[{...b,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=K4(r),y={sessionId:r.id,to:t.deviceId,keep:!1,verb:h("ui.mesh.mesh_card.move_to",{device:p}),waitS:0,lost:g?`${Hte(r,h("ui.mesh.mesh_drop.on_this_device"))} ${hf(h("ui.mesh.mesh_drop.this_device"),p)}`:hf(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 sxn(e){return e.kind==="refused"?h("ui.mesh.mesh_drop.drop_refusal",{sentence:e.sentence}):e.kind==="plan"?e.plan.verb:null}function dNt(e){switch(e.kind){case"draft":return e.name;case"local":return"";default:return e.name}}function oxn(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 lxn(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 fNt=()=>h("ui.chat.device.footer.move_deletes_copy");function cxn(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 uxn(e){return e==="unknown"?"dim":"warning"}const hNt=()=>h("ui.chat.device.row.not_here_why"),pNt=()=>h("ui.chat.device.label.this_device"),mNt=()=>h("ui.chat.device.sentence.pairing_guidance"),gNt=()=>h("ui.chat.device.sentence.mesh_read_failure");function $Nt(e){return h("ui.chat.device.sentence.move_in_flight",{name:e})}const Oxn=()=>h("ui.chat.device.notice.move_hold_detail");function J4(e){return h("ui.chat.device.row.conversations",{count:e})}function dxn(e){return`${e} ${e===1?"device":"devices"}`}function Jte(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 fxn(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 hxn(e){const{placement:t,selfDeviceId:n,networks:r,peers:i}=e,a=t.kind==="local"||t.kind==="remote"||t.kind==="gone"||t.kind==="moving",s=t.kind==="gone",o=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||pNt(),facts:u?[J4(e.selfConversations),h("ui.chat.device.fact.this_device")]:[J4(e.selfConversations)],state:l?"current":e.canTransfer?"candidate":"ineligible",why:l||e.canTransfer?void 0:Jte({canTransfer:!1,reachable:!0})},f=r.map(y=>{const b=y.members.filter(v=>v.device_id!==n&&v.active).map(v=>{const x=c.get(v.device_id),S=[v.role,x?.session_count!=null?J4(x.session_count):""].filter(Boolean);!v.reachable&&!a&&S.push("unreachable");const w=e.canTransfer&&v.capabilities.includes("move")&&v.reachable,_=o!==null&&v.device_id===o,k=a&&(!w||s&&!_);return{deviceId:v.device_id,name:v.name,facts:S,state:_?"current":k?"ineligible":"candidate",why:k?w?hNt():Jte({canTransfer:e.canTransfer,reachable:v.reachable}):void 0}});return{key:y.network_id,name:y.name,count:b.length,rows:b}}),p=r.some(y=>y.members.some(b=>b.device_id!==n&&b.active&&b.reachable)),m=r.some(y=>y.members.some(b=>b.device_id!==n&&b.active&&e.canTransfer&&!b.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"?fNt():t.kind==="gone"?hf(t.name,h("ui.mesh.mesh_drop.this_device")):null,guidance:e.meshRead==="ok"&&r.length===0?mNt():null,readFailure:g?gNt():null,inFlight:e.busy?$Nt(dNt(t)||h("ui.chat.device_move.another_device")):null,offerCheckAgain:g||r.length>0&&(!p||m)}}function pxn(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 yNt(e,t){return e.trim()||t.slice(-8)}function mxn(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:hf(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:hf(r,n)},alternatives:[{...t,to:e.destination.deviceId,keep:!0,verb:h("ui.chat.device_move.plan.copy",{name:n}),lost:null}]}}function gxn(e){let t=0;for(const n of e)n.locality!=="remote"&&(t+=1);return t}function TTe(e){return yNt(typeof e.owner_device_name=="string"?e.owner_device_name:"",typeof e.owner_device=="string"?e.owner_device:"")||"another device"}function $xn(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 s of i.members){if(s===null||typeof s!="object")continue;const o=s.device_id;typeof o!="string"||o===""||t.has(o)||t.set(o,a)}}return t}function yxn(e,t){const n=TTe(e),r=(t??"").trim();return r?`on ${n} · ${r}`:`on ${n}`}function bxn(e){return e.reachable!==!1?"":`unreachable · ${(typeof e.unreachable_reason=="string"?e.unreachable_reason.trim():"")||"it did not answer"}`}function HW(e){return vn(t=>{if(!e)return null;const n=t.sessions.find(r=>r.session_id===e);return!n||n.locality!=="remote"?null:TTe(n)})}function ene(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 eX=new Map,KW=Symbol("waveform-pending"),JW=Symbol("waveform-unkept");async function bNt(e,t){try{const n=await Os({op:"sessions.attachment.waveform",sessionId:e.sessionId,digest:t},null);if(n.kind==="json")return ene(n.body);if(n.kind==="bytes"){const r=new TextDecoder().decode(n.data);try{return ene(JSON.parse(r))}catch{return null}}return n.status===504?KW:n.status===409?JW:null}catch{return null}}function ETe(e,t){const n=t?.sessionId??null,r=t?.childId??null,[i,a]=$.useState(()=>e?vNt(e):null);return $.useEffect(()=>{if(!e||!n){a(null);return}let s=!0,o;const l=c=>{wNt({sessionId:n,childId:r},e).then(u=>{if(!s)return;if(u===JW){a(null);return}if(u!==KW){a(u);return}const O=U1[c];O!==void 0&&(o=setTimeout(()=>{o=void 0,s&&l(c+1)},O))})};return l(0),()=>{s=!1,o!==void 0&&clearTimeout(o)}},[e,n,r]),i}function vNt(e){return u9.get(e)??null}const u9=new Map;function wNt(e,t){const n=eX.get(t);if(n)return n;const r=bNt(e,t).then(i=>i===KW||i===JW?(eX.delete(t),i):(u9.set(t,i),i)).catch(()=>(u9.set(t,null),null));return eX.set(t,r),r}function RTe(e){return`sound:${e.attachment??e.id}`}const DT=({audio:e,scope:t,label:n,ownerId:r})=>{const i=I1(e,t),a=ETe(e.attachment,t),s=HW(t?.sessionId),[o,l]=$.useState(!1);return i.state==="missing"?d.jsx(eh,{name:n,detail:xTe}):i.state==="retryable"?d.jsx(uv,{name:n,onRetry:()=>{l(!0),i.retry()},device:s,focusOnMount:o}):i.state==="resolving"&&i.pending&&s?d.jsx(BW,{device:s,focusOnMount:o}):i.state==="resolving"?d.jsx("div",{className:R("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(Xu,{"data-attachment-reserved":""})}):d.jsx("div",{className:R("w-full max-w-[560px] self-start"),children:d.jsx(PTe,{ownerId:r??RTe(e),src:i.url,label:n,peaks:a,durationHint:e.durationS??null})})},Jd=1,XTe=4,tne=(e,t)=>Math.min(XTe,Math.max(Jd,e+t)),Fg=Object.freeze({x:0,y:0}),tX=(e,t)=>t<=0?0:Math.min(t-1,Math.max(0,Math.trunc(e))),nX=(e,t,n)=>t<=0?0:((e+n)%t+t)%t,xNt=(e,t)=>h("ui.common.viewer.position",{kind:"image",index:e+1,count:t}),nne=(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))}},_Nt="max-h-[min(90vh,calc(100vh-104px))] max-w-[min(90vw,calc(100vw-104px))]",SNt="max-h-[min(90vh,calc(100vh-208px))] max-w-[min(90vw,calc(100vw-104px))]",rne=e=>R(e,"flex min-h-16 min-w-64 items-center justify-center p-6"),kNt="opacity-85",dp="bg-surface/85 disabled:bg-surface/85",eD=({src:e,label:t,open:n,onOpenChange:r,restoreFocusTo:i,fallback:a,pending:s=!1,group:o,layerRef:l,mediaKind:c="image",mediaLabel:u="image",layerAttributes:O})=>{ke();const f=c==="video",p=(ee,F)=>u==="asset"?h("ui.common.viewer.position",{kind:"asset",index:ee+1,count:F}):xNt(ee,F),[m,g]=$.useState(null),y=e!==void 0&&m===e,[b,v]=$.useState(Jd),[x,S]=$.useState(Fg),w=$.useRef(e);$.useLayoutEffect(()=>{w.current!==e&&(w.current=e,v(Jd),S(Fg))},[e]);const[_,k]=$.useState(!0),Q=$.useRef(null);$.useEffect(()=>{if(!n)return;let ee;const F=()=>{clearTimeout(ee),ee=setTimeout(()=>{const le=Q.current;if(le&&(le.matches(":hover")||le.contains(document.activeElement))){F();return}k(!1)},Wme)},H=()=>{k(!0),F()};return k(!0),F(),document.addEventListener("pointermove",H,{passive:!0}),document.addEventListener("pointerdown",H,{passive:!0}),document.addEventListener("keydown",H),document.addEventListener("focusin",H),()=>{clearTimeout(ee),document.removeEventListener("pointermove",H),document.removeEventListener("pointerdown",H),document.removeEventListener("keydown",H),document.removeEventListener("focusin",H)}},[n]);const X=o?.onPrev,C=o?.onNext,T=o!==void 0&&o.count>1,A=T?SNt:_Nt,z=$.useRef(null),Y=l??z;$.useEffect(()=>{if(!n||!T)return;const ee=F=>{F.defaultPrevented||F.metaKey||F.ctrlKey||F.altKey||(F.key==="ArrowLeft"?(F.preventDefault(),X?.()):F.key==="ArrowRight"&&(F.preventDefault(),C?.()))};return document.addEventListener("keydown",ee),()=>document.removeEventListener("keydown",ee)},[n,T,X,C]),vN(n,"lightbox");const G=$.useRef(null),j=!f&&e!==void 0&&!y,U=b===Jd&&x.x===Fg.x&&x.y===Fg.y,D=ee=>{if(!j)return;v(ee);const F=G.current;F&&S(H=>nne(H,{width:F.clientWidth,height:F.clientHeight},ee))},Z=()=>{j&&(v(Jd),S(Fg))},N=$.useRef(null),[L,J]=$.useState(!1),W=j&&b>Jd,fe=ee=>{!W||ee.button!==0||(ee.currentTarget.setPointerCapture(ee.pointerId),N.current={pointerId:ee.pointerId,startX:ee.clientX,startY:ee.clientY,pan:x},J(!0))},te=ee=>{const F=N.current,H=G.current;!F||F.pointerId!==ee.pointerId||!H||S(nne({x:F.pan.x+(ee.clientX-F.startX),y:F.pan.y+(ee.clientY-F.startY)},{width:H.clientWidth,height:H.clientHeight},b))},M=ee=>{N.current?.pointerId===ee.pointerId&&(N.current=null,J(!1))},ie=e!==void 0&&!y?d.jsx("div",{ref:G,"data-image-viewport":"",tabIndex:-1,className:R(A,"relative h-fit w-fit overflow-hidden leading-none outline-none",W&&(L?"cursor-grabbing":"cursor-grab"),W&&"touch-none"),onPointerDown:fe,onPointerMove:te,onPointerUp:M,onPointerCancel:M,children:f?d.jsx("video",{src:e,controls:!0,autoPlay:!0,className:R(A,"block object-contain"),"data-lightbox-video":"",onError:()=>g(e),children:t}):d.jsx("img",{src:e,alt:t,draggable:!1,className:R(A,"block select-none object-contain"),style:U?void 0:{transform:`translate(${x.x}px, ${x.y}px) scale(${b})`},onError:()=>g(e)})}):e===void 0&&s?d.jsx("div",{className:rne(A),"aria-hidden":"true"}):d.jsx("div",{className:rne(A),children:a});return d.jsx(jN,{open:n,onOpenChange:r,children:d.jsxs(NN,{ref:Y,tabIndex:-1,onOpenAutoFocus:ee=>{ee.preventDefault(),(G.current??Y.current)?.focus()},showClose:!1,"aria-describedby":void 0,onCloseAutoFocus:ee=>{const F=i?.current;F&&(ee.preventDefault(),F.focus())},className:R("inset-0 top-0 left-0 m-auto h-fit w-fit translate-none outline-none",A,"gap-0 rounded-none bg-transparent p-0 shadow-none"),...O,children:[d.jsx(zN,{className:"sr-only",children:t}),T&&o?d.jsx("div",{"aria-live":"polite",className:"sr-only",children:p(o.index,o.count)}):null,ie,d.jsxs("div",{ref:Q,"data-image-viewer-controls":"",className:R("pointer-events-none fixed inset-0 transition-opacity ease-out-quart",_?"opacity-100 duration-fast":`${kNt} duration-base`),children:[T&&o?.filmstrip?d.jsx("div",{className:"pointer-events-auto fixed inset-x-0 bottom-4 mx-auto w-fit max-w-[calc(100vw-256px)]",children:o.filmstrip}):null,T?d.jsxs(d.Fragment,{children:[d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.previous",{kind:u}),title:h("ui.common.viewer.previous",{kind:u}),onClick:o?.onPrev,className:R("pointer-events-auto fixed top-0 bottom-0 left-4 my-auto",dp),"data-image-viewer-prev":"",children:d.jsx(J9e,{"aria-hidden":"true"})}),d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.next",{kind:u}),title:h("ui.common.viewer.next",{kind:u}),onClick:o?.onNext,className:R("pointer-events-auto fixed top-0 right-4 bottom-0 my-auto",dp),"data-image-viewer-next":"",children:d.jsx(xde,{"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(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_out"),title:h("ui.common.viewer.zoom_out"),disabled:!j||b===Jd,onClick:()=>D(tne(b,-1)),className:dp,children:d.jsx(sfe,{"aria-hidden":"true"})}),d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.zoom_in"),title:h("ui.common.viewer.zoom_in"),disabled:!j||b===XTe,onClick:()=>D(tne(b,1)),className:dp,children:d.jsx(afe,{"aria-hidden":"true"})}),d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.common.viewer.reset_view"),title:h("ui.common.viewer.reset_view"),disabled:!j||U,onClick:Z,className:dp,children:d.jsx(oP,{"aria-hidden":"true"})})]}),d.jsx(Qje,{asChild:!0,children:d.jsx(Se,{variant:"ghost",size:"icon-sm",className:R("pointer-events-auto fixed top-4 right-4",dp),"aria-label":h("ui.common.viewer.close",{kind:u}),title:h("ui.common.viewer.close",{kind:u}),children:d.jsx(ei,{"aria-hidden":"true"})})})]})]})})};eD.displayName="ImageLightbox";const QNt={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(" ")},PNt=/[/\\]/,ine=e=>{const t=e.split(PNt);return t[t.length-1]},CTe=$.memo(({file:e,src:t,conversationId:n,label:r,size:i="full",overlay:a,press:s,pathActions:o})=>{ke();const[l,c]=$.useState(!1),[u,O]=$.useState(!1),[f,p]=$.useState(!1),m=$.useRef(null),g=Ht(C=>C.setCanvasOpen),{setViewMode:y}=uf(),b=$.useCallback(async()=>{const C=ine(e),T=G=>{G&&console.error("Error processing file:",G);const j=e.startsWith("file://")?e.substring(7):e;window.api.openFile(j).catch(U=>{console.error("Error opening file:",U)})},{setFiles:A,setOpenTabs:z,setSelectedTab:Y}=uf.getState();if(e.startsWith("data:"))if(L7(C)){const G=e,j={id:G,title:C,path:G,content:e,type:qS(e)},D=uf.getState().conversations?.[n],Z=D?.files??[],N=D?.openTabs??[],L=(()=>{const fe=Z.findIndex(te=>te.id===G);return fe!==-1?[...Z.slice(0,fe),j,...Z.slice(fe+1)]:[...Z,j]})();A(n,L);const W=N.some(fe=>fe.id===G)?N:[...N,{id:G,title:C}];z(n,W),Y(n,G),g(!0),y(n,"documents")}else g(!0),y(n,"files");else{const G=e.startsWith("file://")?e.substring(7):e;try{const j=await window.api.readFile(G);if(j.success&&L7(C)){const U=G,D={id:U,title:C,path:G,content:j.data,type:qS(e)},N=uf.getState().conversations?.[n],L=N?.files??[],J=N?.openTabs??[],W=(()=>{const M=L.findIndex(ie=>ie.id===U);return M!==-1?[...L.slice(0,M),D,...L.slice(M+1)]:[...L,D]})();A(n,W);const te=J.some(M=>M.id===U)?J:[...J,{id:U,title:C}];z(n,te),Y(n,U),g(!0),y(n,"documents");return}g(!0),y(n,"files")}catch(j){const U=j instanceof Error?j.message:String(j??"Unknown error reading file");return T(U)}}},[e,g,y,n]),v=()=>{c(!0)},x=AW(e),w=(x==="path"||x==="data")&&n!==""||!!o?.onShowInCanvas,_=kPe(x,{canShowInCanvas:w,source:t,artifactPathActions:!!o}),k=x==="path",Q=r??ine(e);if(l)return d.jsx(eh,{name:Q,compact:i==="thumbnail"});const X=d.jsx(Xu,{boundary:i==="thumbnail"?"control":"hairline",children:d.jsx("img",{className:R(QNt[i],u?"opacity-100":"opacity-0"),src:t,alt:Q,loading:"lazy",decoding:"async",onLoad:()=>O(!0),onError:v})});return d.jsxs("div",{className:"group relative inline-block",children:[d.jsx("button",{ref:m,type:"button",className:R("block max-w-full cursor-pointer",i==="thumbnail"&&"group/tile rounded-sm"),onClick:s?s.onPress:()=>p(!0),"aria-label":s?s.label:h("ui.chat.attachments.expand_aria",{name:Q}),title:s?s.title:h("ui.chat.attachments.expand_title",{name:Q}),"aria-current":s?.current?"true":void 0,children:X}),_&&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:C=>{C.stopPropagation()},onKeyDown:C=>C.stopPropagation(),children:d.jsx(TPe,{file:e,src:t,label:Q,onShowInCanvas:o?.onShowInCanvas??(w?b:void 0),resolvePath:o?.resolvePath})}),s?null:a?a({open:f,onOpenChange:p,restoreFocusTo:m}):d.jsx(eD,{src:t,label:Q,open:f,onOpenChange:p,restoreFocusTo:m,fallback:d.jsx(eh,{name:Q,detail:k?void 0:FW})})]})});CTe.displayName="ImageAttachment";function tD(e,t){return h("ui.chat.canonical.media.image_label",{position:e,count:t})}function TNt(e,t){return h("ui.chat.canonical.media.sound_label",{position:e,count:t})}const ENt=(e,t,n)=>e.name??tD(t+1,n),px=(e,t)=>h("ui.chat.canonical.lightbox.show_image",{index:e,count:t}),RNt={id:"image-group:empty",data:null,attachment:null,mimeType:"image/png"},XNt=({cold:e,children:t})=>e?d.jsx("div",{className:"flex h-[79px] w-[117px] items-start leading-none",children:t}):t,CNt=({images:e,index:t,scope:n,open:r,onOpenChange:i,restoreFocusTo:a,labelFor:s=ENt})=>{ke();const o=e.length,[l,c]=$.useState(()=>tX(t,o)),[u,O]=$.useState(r);u!==r&&(O(r),r&&c(tX(t,o)));const f=tX(l,o),p=e[f]??RNt,m=s(p,f,o),g=oU(p,n),y=$.useRef(null),b=$.useRef(null),[v,x]=$.useState(!1),S=$.useCallback(U=>{y.current=U,x(U!==null)},[]),w=U=>{const D=y.current?.querySelector(`[data-image-slot="${U+1}"] button`);D?D.focus():b.current?.focus()},_=U=>{const D=nX(f,o,U),Z=y.current?.contains(document.activeElement)??!1;c(D),Z&&w(D)},k=()=>_(-1),Q=()=>_(1),X=JSON.stringify([n?.sessionId,n?.childId,e.map(U=>[U.id,U.attachment,U.mimeType])]),[C,T]=$.useState(()=>({identity:X,open:r,indices:new Set}));(C.identity!==X||C.open!==r)&&T({identity:X,open:r,indices:new Set});const A=$.useCallback(U=>{T(D=>{if(!r||D.identity!==X||!D.open||U.every(N=>D.indices.has(N)))return D;const Z=new Set(D.indices);for(const N of U)Z.add(N);return{...D,indices:Z}})},[X,r]),z=nX(f,o,-1),Y=nX(f,o,1);$.useEffect(()=>{r&&A([f,z,Y])},[r,f,z,Y,A]),$.useEffect(()=>{const U=y.current;if(!r||!v||!U||typeof IntersectionObserver>"u")return;let D=!0;const Z=new IntersectionObserver(N=>{D&&A(N.filter(L=>L.isIntersecting).map(L=>Number(L.target.dataset.imageSlot)-1))},{root:U});for(const N of U.querySelectorAll("[data-image-slot]"))Z.observe(N);return()=>{D=!1,Z.disconnect()}},[r,v,A]);const G=(U,D)=>!!U.data||!U.attachment||D===f||D===z||D===Y||C.identity===X&&C.open&&C.indices.has(D);$.useEffect(()=>{(y.current?.querySelector(`[data-image-slot="${f+1}"]`)??y.current)?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[v,f]);const j=o>1?d.jsx("ul",{role:"list",ref:S,"aria-label":h("ui.chat.canonical.lightbox.filmstrip_aria",{count:o,count_display:String(o)}),"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,D)=>d.jsx("li",{"data-image-slot":D+1,className:R("flex shrink-0 scroll-mx-px rounded-sm leading-none",D===f&&"ring-1 ring-ink"),children:d.jsx(XNt,{cold:!!U.attachment&&!U.data,children:G(U,D)?d.jsx(Sh,{image:U,scope:n,size:"thumbnail",label:s(U,D,o),press:{onPress:()=>c(D),label:px(D+1,o),title:px(D+1,o),current:D===f}}):d.jsx("button",{type:"button","aria-label":px(D+1,o),title:px(D+1,o),className:"group/tile inline-block max-w-full cursor-zoom-in rounded-sm leading-none",onClick:()=>{A([D]),c(D)},children:d.jsx(Xu,{boundary:"control",className:"h-[78px] w-[117px]","data-attachment-reserved":"","data-attachment-deferred":""})})})},U.id))}):void 0;return d.jsx(eD,{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(uv,{name:m,onRetry:g.retry}):d.jsx(eh,{name:m,detail:FW}),layerRef:b,group:{index:f,count:o,onPrev:k,onNext:Q,filmstrip:j}})},Sh=({image:e,scope:t,label:n,size:r,group:i,press:a,pathActions:s})=>{const o=oU(e,t),l=HW(t?.sessionId),[c,u]=$.useState(!1);if(o.state==="resolving"&&o.pending&&l&&!a)return d.jsx(BW,{device:l,compact:r==="thumbnail",focusOnMount:c});if(o.state==="resolving"){const f=d.jsx(Xu,{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:R("inline-block max-w-full"),"aria-hidden":!0,children:f})}if(o.state==="retryable")return d.jsx(uv,{name:n,compact:r==="thumbnail",onRetry:()=>{u(!0),o.retry()},device:l,focusOnMount:c});if(o.state==="missing")return d.jsx(eh,{name:n,compact:r==="thumbnail",detail:FW});const O=o.url;return d.jsx("div",{className:R("inline-block max-w-full"),children:d.jsx(CTe,{file:O,src:O,label:n,size:r,conversationId:t?.sessionId??"",press:a,pathActions:s,overlay:i?f=>d.jsx(CNt,{images:i.images,index:i.index,labelFor:i.labelFor,scope:t,open:f.open,onOpenChange:f.onOpenChange,restoreFocusTo:f.restoreFocusTo}):void 0})})};function ANt(){return h("ui.chat.checkpoint.generating_name")}const qNt={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 jNt(e){return e.id===e.activeId?"active":e.id===e.previewId?"preview":e.loaded===!1?"unloaded":"rest"}function ATe(e,t){return h("ui.chat.checkpoint.turn",{turn:e,total:t})}function NNt(e,t){const n=ATe(e.turn,t),r=e.naming?.state==="ready"?e.naming.name?.trim():"";return r?`${n} · ${r}`:n}function zNt(e){return e.kind==="completion"&&e.naming?.state==="pending"}function UNt(e){const t=e.naming?.state==="ready"?e.naming.summary:null;return t?.trim()?t:null}function INt(e){let t=0;for(const n of e)n.turn>t&&(t=n.turn);return t}const WNt={complete:"Complete",error:"Error",interrupted:"Interrupted",open:"Open"};function DNt(e){if(!Number.isFinite(e)||e<=0)return"";const t=new Date(e*1e3);return Number.isNaN(t.getTime())?"":b1(t,{hour:"numeric",minute:"2-digit"})}function YNt(e,t){if(e.kind==="user"){const r=DNt(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 GNt(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 rX(e,t){const n=[];for(const r of t)GNt(e,r)==="pending"&&n.push(r);return n}const LNt=120,ane=80,su=10,qk=24,MNt=2,O9=420,qTe=32;function YT(e,t){return(t?MNt:0)+qk+e*su}function sne(e,t){return YT(e,t)+qk}function ZNt(e,t,n){if(t<=0)return{start:0,end:0};const r=qTe*su,i=Math.floor(Math.max(0,e)/r),a=i*r-O9,s=(i+1)*r+2*O9,o=YT(0,n),l=Math.max(0,Math.floor((a-o)/su)),c=Math.min(t,Math.ceil((s-o)/su));return{start:Math.min(l,c),end:c}}function VNt(e,t,n,r,i=24){const a=YT(e,t),s=a+su;return a<n+i?Math.max(0,a-i):s>n+r-i?s-r+i:null}const FNt=()=>h("ui.chat.canonical.checkpoint_rail.label"),BNt={complete:Fi,error:wu,interrupted:VN,open:c8e},HNt={complete:"text-success",error:"text-danger",interrupted:"text-warning",open:"text-ink-dim"},KNt=({checkpoint:e,turnCount:t})=>{const n=e.outcome,r=n?BNt[n]:null,i=UNt(e),a=e.naming?.state==="ready"?e.naming.name?.trim():"";return d.jsxs(d.Fragment,{children:[d.jsxs("p",{className:R("text-body-sm font-medium text-ink"),children:[ATe(e.turn,t),a&&d.jsxs(d.Fragment,{children:[d.jsx("span",{"aria-hidden":"true",children:" · "}),d.jsx("span",{className:R("font-normal text-ink-muted"),children:a})]})]}),zNt(e)&&d.jsx("p",{className:R("text-ink-dim text-meta"),children:ANt()}),i&&d.jsx("p",{className:R("line-clamp-2 break-words text-body-sm text-ink-muted"),children:i}),n&&r&&d.jsx("div",{className:R("flex items-center gap-1.5 text-ink-dim text-meta"),children:d.jsxs("span",{className:R("flex items-center gap-1",HNt[n]),children:[d.jsx(r,{"aria-hidden":"true",className:R("size-3.5 shrink-0")}),WNt[n]]})})]})},JNt=$.memo(function({checkpoint:t,state:n,label:r,top:i,roving:a,registerTick:s,onPreview:o,onPreviewEnd:l,onFocusMark:c,onBlurMark:u,onActivate:O,onKeyMark:f,describedBy:p}){const m=g=>{g.pointerType!=="touch"&&o(t.id)};return d.jsx("button",{ref:g=>s(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:R("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:R("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",qNt[n])})})}),ezt=({sessionId:e,checkpoints:t,onJump:n,onHover:r,building:i=!1,loadedIds:a,activeId:s=null})=>{ke();const o=$.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),b=$.useMemo(()=>new Map(t.map((pe,Qe)=>[pe.id,Qe])),[t]),v=$.useRef(b);v.current=b;const x=$.useRef(i);x.current=i;const[S,w]=$.useState({sessionId:"",top:0}),_=qTe*su,k=$.useCallback(pe=>{const Qe=Math.floor(Math.max(0,pe)/_)*_;w(ot=>ot.sessionId===e&&ot.top===Qe?ot:{sessionId:e,top:Qe})},[_,e]),Q=S.sessionId===e?S.top:Math.max(0,sne(t.length,i)-O9),X=$.useRef(null),C=$.useRef(null),T=$.useCallback(()=>{X.current!==null&&(clearTimeout(X.current),X.current=null),C.current!==null&&(clearTimeout(C.current),C.current=null)},[]),A=$.useCallback((pe,Qe)=>{T();const ot=()=>{O(pe),p(m.current.find(gt=>gt.id===pe)??null)};if(Qe<=0){ot();return}X.current=setTimeout(()=>{X.current=null,ot()},Qe)},[T]),z=$.useCallback(pe=>{if(T(),pe<=0){O(null);return}C.current=setTimeout(()=>{C.current=null,O(null)},pe)},[T]),Y=$.useRef(e);$.useEffect(()=>{Y.current!==e&&(Y.current=e,T(),F.current=null,c(null),O(null),p(null))},[e,T]);const G=$.useRef(null);$.useLayoutEffect(()=>{const pe=y.current;if(!(t.length===0||pe===null)){if(s!==null&&j.current===e){G.current=e,k(pe.scrollTop);return}G.current!==e&&(G.current=e,pe.scrollTop=sne(t.length,i),k(pe.scrollTop))}},[s,i,t.length,e,k]);const j=$.useRef(null);$.useLayoutEffect(()=>{if(s===null)return;const pe=y.current,Qe=v.current.get(s);if(pe===null||Qe===void 0)return;j.current=e;const ot=VNt(Qe,x.current,pe.scrollTop,pe.clientHeight);ot!==null&&(pe.scrollTop=ot),k(pe.scrollTop)},[s,e,k]),$.useEffect(()=>()=>T(),[T]);const U=$.useRef(r);$.useEffect(()=>{U.current=r});const D=$.useMemo(()=>INt(t),[t]),Z=u&&f?.id===u?f:null,N=u&&g.current.get(u)||null,L=$.useMemo(()=>({current:N}),[N]),J=Z!==null&&N!==null;$.useEffect(()=>{U.current(J&&u?u:null)},[J,u]);const W=$.useCallback((pe,Qe)=>{Qe?g.current.set(pe,Qe):g.current.delete(pe)},[]),[fe,te]=$.useState(null),M=fe&&b.has(fe)?fe:t[0]?.id??null,ie=$.useRef(null),ee=$.useCallback(pe=>{const Qe=Math.max(0,Math.min(t.length-1,pe)),ot=t[Qe];if(!ot)return;te(ot.id);const gt=g.current.get(ot.id);if(gt){gt.focus();return}const ut=y.current;ut!==null&&(ut.scrollTop=Math.max(0,YT(Qe,i)+su/2-ut.clientHeight/2),k(ut.scrollTop)),ie.current=ot.id},[i,t,k]);$.useLayoutEffect(()=>{const pe=ie.current;if(pe===null)return;const Qe=g.current.get(pe);Qe&&(ie.current=null,Qe.focus())});const F=$.useRef(null),H=$.useCallback(pe=>{F.current!==pe&&(F.current=pe,c(pe),A(pe,LNt))},[A]),le=$.useCallback(()=>{F.current=null,c(pe=>pe===null?pe:null),z(ane)},[z]),oe=$.useCallback(pe=>{F.current=pe,te(pe),c(Qe=>Qe===pe?Qe:pe),A(pe,0)},[A]),Ce=$.useCallback(()=>{F.current=null,c(pe=>pe===null?pe:null),z(ane)},[z]),ge=$.useCallback(pe=>{z(0),F.current=null,c(null),n(pe)},[z,n]),Xe=$.useCallback((pe,Qe)=>{if(pe.key==="Escape"){z(0);return}const ot=b.get(Qe);if(ot!==void 0){if(pe.key==="ArrowDown"){pe.preventDefault(),pe.stopPropagation(),ee(ot+1);return}if(pe.key==="ArrowUp"){pe.preventDefault(),pe.stopPropagation(),ee(ot-1);return}if(pe.key==="Home"){pe.preventDefault(),pe.stopPropagation(),ee(0);return}pe.key==="End"&&(pe.preventDefault(),pe.stopPropagation(),ee(t.length-1))}},[t.length,z,ee,b]),Ue=ZNt(Q,t.length,i),We=[];for(let pe=Ue.start;pe<Ue.end;pe+=1)We.push(pe);for(const pe of[M,u,l]){const Qe=pe===null?void 0:b.get(pe);Qe!==void 0&&(Qe<Ue.start||Qe>=Ue.end)&&!We.includes(Qe)&&We.push(Qe)}return We.sort((pe,Qe)=>pe-Qe),t.length===0&&!i?null:d.jsxs("div",{"data-lo-checkpoint-rail":"",role:"toolbar","aria-orientation":"vertical","aria-label":FNt(),className:R("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:pe=>k(pe.currentTarget.scrollTop),className:R("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:R("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*su+2*qk},children:We.map(pe=>{const Qe=t[pe];return d.jsx(JNt,{checkpoint:Qe,top:qk+pe*su,state:jNt({id:Qe.id,previewId:l,activeId:s,loaded:a?a.has(Qe.id):!0}),label:YNt(Qe,D),roving:Qe.id===M,registerTick:W,onPreview:H,onPreviewEnd:le,onFocusMark:oe,onBlurMark:Ce,onActivate:ge,onKeyMark:Xe,describedBy:J&&u===Qe.id?o:void 0},Qe.id)})})]}),d.jsxs(Pje,{open:J,onOpenChange:pe=>{pe||z(0)},children:[d.jsx(Tje,{virtualRef:L}),Z&&d.jsx(Eje,{id:o,"data-checkpoint-card":"",side:"left",align:"center",sideOffset:10,collisionPadding:8,role:"tooltip","aria-label":Z.kind==="user"?h("ui.chat.transcript_copy.row.your_message"):NNt(Z,D),onOpenAutoFocus:pe=>pe.preventDefault(),onCloseAutoFocus:pe=>pe.preventDefault(),onFocusOutside:pe=>{const Qe=pe.detail?.originalEvent?.target;Qe instanceof Element&&Qe.closest("[data-lo-checkpoint-rail]")&&pe.preventDefault()},className:R("pointer-events-none max-h-[176px] w-[300px] max-w-[300px] overflow-hidden","flex flex-col gap-2"),children:Z.kind==="user"?d.jsx("div",{"data-checkpoint-card-text":"",className:R("line-clamp-3 break-words whitespace-pre-wrap","text-body-sm text-ink"),children:Z.text}):d.jsx(KNt,{checkpoint:Z,turnCount:D})})]})]})},tzt=$.memo(ezt),nzt={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 jTe(e){return h(nzt[e])}const d9=({variant:e,announce:t=!0,isSmallView:n=!1,className:r})=>{ke();const i=d.jsxs(d.Fragment,{children:[d.jsx("span",{"data-lo-loading-mark":!0,className:"inline-flex shrink-0",children:d.jsx(Oi,{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:jTe(e)})]}),a=R("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 rzt(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 izt=(e,t,n)=>(e.getAttribute(t)??"").split(" ").includes(n);function azt(e,t){return e.querySelector(`[data-record-id="${t}"]:not([data-turn-summary])`)!==null}function NTe(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 s=a.getAttribute("data-segment-ids");if(s!==null?!s.split(" ").includes(t):!izt(a,i,t))continue;if(a.querySelector("button[aria-expanded]")?.getAttribute("aria-expanded")==="false")return a}return null}function szt(e,t){return azt(e,t)||NTe(e,t)!==null}const ozt=3;function lzt(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>=ozt){n.onMissing();return}const o=NTe(e,t)?.querySelector("button[aria-expanded]");if(!o){n.onMissing();return}o.click(),window.requestAnimationFrame(()=>{r(i+1)})};r(0)}const one=(e,t,n)=>tD(t+1,n),lne=({images:e,scope:t,onRevealMore:n,uncapped:r=!1,indent:i="content"})=>{ke();const{shown:a,more:s}=W8t(e.length,{uncapped:r}),o=D8t(a),l=o.length>1,c=new Set;for(let O=0,f=0;f<o.length;f+=1)c.add(O),O+=o[f];const u=e.slice(0,a).map((O,f)=>d.jsx("li",{className:R("flex leading-none",l&&c.has(f)&&"col-start-1"),children:d.jsx(Sh,{image:O,scope:t,size:"thumbnail",label:one(O,f,e.length),group:{images:e,index:f,labelFor:one}})},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:R("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,s>0&&d.jsx("li",{className:R("flex h-[78px] items-center leading-none"),children:d.jsx(Se,{variant:"outline",size:"sm",onClick:n,"aria-label":h("ui.chat.canonical.fold.more_images",{count_display:String(s),count:s}),title:h("ui.chat.canonical.fold.more_images",{count:s,count_display:String(s)}),children:`+${s}`})},"fold-media-more")]})};function cne(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 czt(e,t,n,r){if(t.length===0)return[...e];const i=t[0],a=[];let s=!1;for(const o of e){if(!(o.ids[0]===i||o.ids.some(c=>t.includes(c)))){a.push(o);continue}s||(a.push({ids:[...t],open:n}),s=!0)}return s||a.push({ids:[...t],open:n}),a.filter(o=>o.ids.some(l=>r.has(l)))}function uzt(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 Ozt=({video:e,scope:t,label:n})=>{const r=I1(e,t),[i,a]=$.useState(!1),s=HW(t?.sessionId),[o,l]=$.useState(!1);return r.state==="retryable"?d.jsx(uv,{name:n,onRetry:()=>{l(!0),r.retry()},device:s,focusOnMount:o}):r.state==="resolving"&&r.pending&&s?d.jsx(BW,{device:s,video:!0,focusOnMount:o}):r.state==="missing"||i?d.jsx(eh,{name:n,detail:wTe}):r.state==="resolving"?d.jsx("div",{className:R("inline-block max-w-full self-start"),"aria-hidden":!0,children:d.jsx(Xu,{"data-attachment-reserved":""})}):d.jsx("div",{className:R("inline-block max-w-full self-start"),children:d.jsx(Xu,{children:d.jsx("video",{controls:!0,preload:"metadata",src:r.url,"aria-label":n,className:R("max-h-[240px] max-w-full object-contain"),onError:()=>a(!0)})})})};function dzt({items:e,summary:t,scope:n}){return ke(),d.jsxs("div",{"data-sound-batch":"",className:R("flex w-full min-w-0 max-w-[560px] flex-col gap-4"),children:[d.jsx("p",{className:R("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:R("min-w-0"),children:[d.jsx("p",{className:R("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:R("text-body-sm text-ink break-words [overflow-wrap:anywhere]"),children:r.error}):r.audio?d.jsx(DT,{audio:r.audio,ownerId:`${RTe(r.audio)}:batch:${r.audio.id}:${r.id}`,scope:n,label:r.label}):d.jsx("p",{className:R("text-meta text-ink-muted"),children:h("ui.chat.canonical.sound.batch_attachment_unavailable")}),d.jsx("p",{className:R("text-meta text-ink-dim"),children:r.costCaption??h("ui.chat.canonical.sound.cost.unknown")})]},r.id))})]})}function vxn({sessionId:e,runningSound:t,available:n,onInterrupt:r,onRestoreFocus:i}){const[a,s]=$.useState(!1),o=$.useRef(null),l=$.useRef(e);$.useEffect(()=>{const p=l.current!==e;l.current=e,!(!p&&t)&&a&&(s(!1),i())},[e,t,a,i]);const c=$.useCallback(()=>{s(!1),i()},[i]),u=$.useCallback(()=>{if(!e||!n)return;const p=o.current?.querySelector("[data-sound-stop-confirmation] button");if(p){p.focus();return}if(t){s(!0);return}r()},[e,n,t,r]),O=$.useCallback(()=>{s(!1),i(),r()},[r,i]),f=$.useMemo(()=>a&&t?d.jsx(zTe,{onKeepWaiting:c,onRequestStop:O}):null,[a,t,c,O]);return{paneRef:o,stop:u,confirmation:f}}function zTe({onKeepWaiting:e,onRequestStop:t}){ke();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(Se,{ref:n,"aria-describedby":r,variant:"ghost",size:"sm",onClick:e,children:h("ui.chat.canonical.sound.stop.keep_waiting")}),d.jsx(Se,{variant:"secondary",size:"sm",onClick:t,children:h("ui.chat.canonical.sound.stop.request_stop")})]})]})}const fzt=1e3;function hzt(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,fzt);return()=>window.clearInterval(i)},[e]),t}function pzt(){return d.jsx("div",{"aria-hidden":!0,"data-imagegen-tile":"",className:R("relative aspect-[3/2] w-[240px] max-w-full overflow-hidden rounded-sm bg-sunken"),children:d.jsx("span",{className:R("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 une=44,mzt=240,iX=12,gzt=Array.from({length:240},(e,t)=>Math.min(1,.18+Math.abs(Math.sin(t/7)*Math.cos(t/17))*.72));function $zt({state:e}){const t=QTe(gzt,mzt-iX*2,une);return d.jsx("div",{"aria-hidden":!0,"data-sound-loading-tile":"","data-sound-loading":e,className:R("relative flex w-[240px] max-w-full items-center overflow-hidden rounded-sm bg-sunken"),style:{height:une},children:d.jsx("div",{className:R("flex w-full items-center"),style:{paddingLeft:iX,paddingRight:iX},children:t.map((n,r)=>d.jsx("span",{"data-sound-loading-bar":"",className:R("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:Ak,height:e==="failed"?STe:n.height,marginRight:n===t.at(-1)?0:2,animationDelay:e==="running"?`${r%12*90}ms`:void 0}},n.x))})})}function $O(e){return e==="sound-effect"?"sound_effect":e}function jk(e){const t=h("ui.chat.canonical.image_gen.cancel.running");return e?`${t} ${h("ui.chat.canonical.image_gen.cancel.checking")}`:t}function UTe(e,t){return!e||e.vendorStopped===null?null:e.vendorStopped?h("ui.chat.canonical.image_gen.cancel.queued"):jk(t&&e.settling)}function yzt(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 bzt({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?Lx(e.argumentBytes):null;break;case"running":n=e.batchProgress?h("ui.chat.canonical.image_gen.state.running_batch",{material:$O(e.material),total:e.batchProgress.total}):h("ui.chat.canonical.image_gen.state.running",{material:$O(e.material)}),r=t===null?null:FO(t);break;case"cancelling":n=e.generating?jk(!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:$O(e.material)}):h("ui.chat.canonical.image_gen.state.done",{material:$O(e.material)}),r=e.receipt==="already-finished"||e.durationS===null?null:TN(e.durationS);break;case"failed":n=e.batch?h("ui.chat.canonical.image_gen.state.failed_batch",{material:$O(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:$O(e.material)})),i=!0;break;case"cancelled":{const a=!!(e.settlementCaption||e.settled),s=UTe(e.cancel,!a),o=e.message?a?f7e(e.message):e.message:e.generating?jk(!a):h("ui.chat.canonical.image_gen.cancel.queued");n=e.batch?h("ui.chat.canonical.image_gen.state.cancelled_batch",{material:$O(e.material??"sound-effect")}):s??o;break}}return d.jsxs("p",{className:R("flex min-w-0 items-baseline gap-1.5 text-body-sm"),children:[d.jsx("span",{className:R("min-w-0",i?"text-ink":"text-ink-muted"),children:n}),r===null?null:d.jsxs("span",{className:R("shrink-0 text-meta text-ink-dim"),children:["· ",d.jsx("bdi",{dir:"auto",children:r})]})]})}function vzt({line:e}){return d.jsx("p",{"data-imagegen-log":"",title:e,className:R("min-w-0 truncate font-mono text-mono-sm text-ink-dim"),children:e})}function Vd({line:e,prominent:t=!1}){return d.jsx("p",{"data-imagegen-note":"",className:R("min-w-0 text-body-sm",t?"text-ink-muted":"text-ink-dim"),children:e})}function wzt(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 xzt=({view:e,scope:t,actions:n})=>{ke();const[r,i]=$.useState(!1),a=$.useCallback(()=>i(!1),[]),s=$.useRef(null),o=$.useRef(!1);$.useLayoutEffect(()=>{o.current&&!r&&(s.current?.querySelector("[data-imagegen-controls] button")??s.current)?.focus(),o.current=r},[r]),$.useLayoutEffect(()=>{const w=s.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=hzt(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",b=y?e.state==="queued"?"queued":e.state==="cancelling"?e.generating?"stopped":null:m?"running":e.state==="failed"?"failed":e.state==="cancelled"?"stopped":null:null,v=e.state==="cancelled"&&!e.batch&&!!UTe(e.cancel,!0),x=y&&!v&&(e.state==="failed"?e.batch?.some(w=>w.status==="cancelled"):e.state==="cancelled"&&(e.batch?.some(w=>w.status==="cancelled")||e.message))?jk(!0):null,S=p&&e.progress.logs.length>0?e.progress.logs[e.progress.logs.length-1]:null;return d.jsxs("div",{ref:s,tabIndex:-1,"data-imagegen-card":e.state,className:R("flex w-full flex-col gap-2"),children:[b?d.jsx($zt,{state:b}):m?d.jsx(pzt,{}):null,e.state==="failed"&&(e.material==="voiceover"||e.material==="sound-effect")&&e.errorCode?d.jsx("p",{className:R("text-meta text-ink-dim"),children:yzt(e.errorCode)}):null,d.jsx(bzt,{view:e,elapsed:u}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.costCaption?d.jsx(Vd,{line:e.costCaption,prominent:!!e.batch}):null,(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batchNote?d.jsx(Vd,{line:e.batchNote,prominent:!0}):null,e.state==="running"&&e.batchProgress?.note?d.jsx(Vd,{line:e.batchProgress.note}):null,e.state==="cancelled"&&e.settlementCaption?d.jsx(Vd,{line:e.settlementCaption}):null,e.state==="cancelled"&&e.settlementPending?d.jsx(Vd,{line:h("ui.chat.canonical.image_gen.settlement.pending")}):null,x?d.jsx(Vd,{line:x}):null,l&&r?d.jsx(zTe,{onKeepWaiting:a,onRequestStop:()=>{i(!1),n?.onCancel?.()}}):null,e.state==="running"&&typeof e.note=="string"?d.jsx(Vd,{line:e.note}):null,m&&e.progress.fraction!==null?d.jsx(Rje,{"aria-label":h("ui.chat.canonical.image_gen.progress"),className:R("max-w-[240px]"),value:Math.round(Math.min(1,Math.max(0,e.progress.fraction))*100)}):null,S===null?null:d.jsx(vzt,{line:S}),(e.state==="done"||e.state==="failed"||e.state==="cancelled")&&e.batch?d.jsx(dzt,{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:R("flex flex-col gap-2"),children:e.images.map((w,_)=>{const k=h("ui.chat.canonical.image_gen.state.done",{material:$O(w.kind==="audio"?e.material:w.kind??"image")}),Q=e.images.length===1?k:`${k} ${_+1}`;return w.kind==="video"?d.jsx(Ozt,{video:w,scope:t,label:Q},w.id):w.kind==="audio"?d.jsx(DT,{audio:w,scope:t,label:Q},w.id):d.jsx(Sh,{image:w,scope:t,label:Q},w.id)})}):null,O.length>0&&!(l&&r)?d.jsx("div",{"data-imagegen-controls":"",className:R("flex items-center gap-2"),children:O.map(w=>d.jsx(Se,{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.current?.closest("[data-chat-pane]")?.querySelector("[data-sound-stop-confirmation] button");if(_){_.focus();return}i(!0)}:f[w.kind],children:wzt(w.kind,e.state)},w.kind))}):null]})},q0="data-lo-quote-toolkit";function f9(e,t){return e.kind!=="user"&&e.kind!=="assistant"||t.trim().length===0?!1:e.kind!=="assistant"?!0:!e.streaming}const One=e=>(e.nodeType===Node.ELEMENT_NODE?e:e.parentElement)?.closest(`[${q0}]`)??null,_zt=e=>e.nodeType===Node.ELEMENT_NODE,Szt=e=>{const t=Array.from(e.childNodes),n=t.findIndex(r=>_zt(r)&&r.hasAttribute(q0));return n===-1?t.length:n},kzt=(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,Qzt=e=>{const t=Array.from(document.querySelectorAll(`[${q0}]`),n=>n.getBoundingClientRect());return Array.from(e.getClientRects()).filter(n=>!t.some(r=>kzt(r,n))).map(n=>({top:n.top,left:n.left,right:n.right,bottom:n.bottom}))};function rm(e){if(!e)return null;const t=window.getSelection();if(!t||t.rangeCount===0||t.isCollapsed)return null;const n=t.getRangeAt(0);if(One(n.startContainer)||One(n.endContainer)||!e.contains(n.startContainer))return null;const r=n.cloneRange();e.contains(n.endContainer)||r.setEnd(e,Szt(e));const i=r.toString().trim();return i.length===0?null:{text:i,lines:Qzt(n)}}const dne="[data-lo-canonical-transcript]",Pzt="[data-lo-transcript-content]",fne=e=>({top:e.top,left:e.left,right:e.right,bottom:e.bottom}),Tzt=()=>({top:0,left:0,right:window.innerWidth,bottom:window.innerHeight});function ITe(e){const{turnRef:t,visible:n,lines:r,measureKey:i,belowWhenOffFirstLine:a}=e,s=$.useRef(null),[o,l]=$.useState(null),c=$.useRef(r);c.current=r;const u=$.useCallback(()=>{const O=t.current,f=s.current;if(!O||!f){l(null);return}const p=c.current();if(!p||p.length===0){l(null);return}const m=Gst({lines:p,container:fne((O.closest(dne)??O).getBoundingClientRect()),viewport:Tzt(),size:{width:f.offsetWidth,height:f.offsetHeight},row:fne(O.getBoundingClientRect()),belowWhenOffFirstLine:a}),g=O.getBoundingClientRect(),y=m?{top:m.top-g.top,left:m.left-g.left,placement:m.placement}:null;l(b=>b===y||b&&y&&b.top===y.top&&b.left===y.left&&b.placement===y.placement?b: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(dne),m=p?.querySelector(Pzt),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:s,placement:o}}function WTe(e){const[t,n]=$.useState(null);$.useEffect(()=>{const i=()=>n(rm(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 Pp="data-lo-link-toolbar",Ezt=120,Rzt=2;function DTe(e){const[t,n]=$.useState(null),[r,i]=$.useState(!1),a=$.useRef(null);a.current=t;const s=$.useRef(null),o=$.useRef(null),l=$.useCallback(()=>{const u=e.current;if(!u){s.current=null,n(p=>p===null?p:null),i(p=>p===!1?p:!1);return}const O=YCt(u);if(O){n(p=>p===O?p:O),i(p=>p===!0?p:!0);return}if(i(p=>p===!1?p:!1),GQe()){n(p=>p===null?p:null);return}const f=s.current&&u.contains(s.current)?s.current:null;n(p=>p===f?p:f)},[e]);$.useEffect(()=>{const u=e.current;if(!u)return;let O=0;const f=k=>{O&&(clearTimeout(O),O=0),s.current=k,l()},p=k=>{if(O&&clearTimeout(O),!k){O=0,s.current=null,l();return}s.current!==k&&(o.current=null,O=setTimeout(()=>{O=0,s.current=k,l()},Ezt))},m=(k,Q)=>{const X=s.current;if(!X||!u.contains(X))return!1;const C=u.querySelector(`[${Pp}]`),T=vU+Rzt;for(const A of[X,C]){if(!A)continue;const z=A.getBoundingClientRect();if(!(z.width<=0||z.height<=0)&&k>=z.left-T&&k<=z.right+T&&Q>=z.top-T&&Q<=z.bottom+T)return!0}return!1},g=k=>{const Q=k.target;if(Q?.closest(`[${q0}]`))return;const X=Q?.closest(Qp)??null;!X&&m(k.clientX,k.clientY)||p(X)},y=k=>{const Q=k.relatedTarget;Q&&u.contains(Q)||m(k.clientX,k.clientY)||f(null)},b=k=>{const Q=k.target?.closest(Qp);if(Q){if(Q===o.current){o.current=null;return}f(Q)}},v=k=>{const Q=k.relatedTarget;Q&&u.contains(Q)||f(null)},x=()=>Array.from(u.querySelectorAll(`[${Pp}] button:not([disabled])`)),S=k=>{const Q=k.target;if(!Q)return!1;if(Q.closest(`[${Pp}]`)){const A=x(),z=A.indexOf(Q);if(z===-1)return!1;if(k.shiftKey&&z===0){const Y=s.current;return Y instanceof HTMLElement?(Y.focus(),!0):!1}if(!k.shiftKey&&z===A.length-1){const Y=Array.from(u.querySelectorAll(Qp)),G=s.current,j=G?Y.indexOf(G)+1:-1,U=j>0?Y[j]:void 0;return U?(U.focus(),!0):!1}return!1}if(k.shiftKey)return!1;const C=Q.closest(Qp);if(!C||!u.contains(C))return!1;s.current!==C&&f(C);const[T]=x();return T?(T.focus(),!0):!1},w=k=>{if(k.key==="Tab"&&S(k)){k.preventDefault();return}if(!(k.key==="ContextMenu"||k.shiftKey&&k.key==="F10"))return;const X=k.target?.closest(Qp);!X||!u.contains(X)||(k.preventDefault(),f(X),requestAnimationFrame(()=>{u.querySelector(`[${Pp}] button`)?.focus()}))},_=k=>{const Q=k.target;Q&&u.contains(Q)||f(null)};return u.addEventListener("pointerover",g),u.addEventListener("pointerout",y),u.addEventListener("focusin",b),u.addEventListener("focusout",v),u.addEventListener("keydown",w),document.addEventListener("pointerdown",_,!0),document.addEventListener("selectionchange",l),l(),()=>{O&&clearTimeout(O),u.removeEventListener("pointerover",g),u.removeEventListener("pointerout",y),u.removeEventListener("focusin",b),u.removeEventListener("focusout",v),u.removeEventListener("keydown",w),document.removeEventListener("pointerdown",_,!0),document.removeEventListener("selectionchange",l)}},[e,l]);const c=$.useCallback(()=>{o.current=a.current,s.current=null,l()},[l]);return $.useEffect(()=>{if(!t)return;const u=O=>{if(O.key!=="Escape"||O.target?.closest(`[${Pp}]`))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 YTe(e,t,n){const r=ir(i=>i.addReply);return $.useCallback(()=>{const a=rm(t.current)?.text??(GQe()?null:n?.()??null);a&&(r(e,{id:Ia(),text:a}),window.getSelection()?.removeAllRanges(),pz())},[r,e,t,n])}const GTe=({conversationId:e,turnRef:t,subject:n,quoteAvailable:r,onDismiss:i})=>{ke();const a=n.getAttribute(DQe)??"",s=n.getAttribute("data-lo-kind")??"file",o=ov(),l=$.useCallback(()=>(n.textContent??"").trim()||null,[n]),c=YTe(e,t,l),{text:u}=WTe(t),{speak:O}=k0(),f=CP(e),p=u??l(),m=p===null?null:km(e,XP(p).text);xge(m);const g=qP({key:m,getText:()=>rm(t.current)?.text??l(),play:({text:G})=>O(km(e,G),AP(f,G))}),[y,b]=$.useState(!1),[v,x]=$.useState(()=>X_(a)??null),{controlRef:S,placement:w}=ITe({turnRef:t,visible:!0,lines:()=>{const G=n.getClientRects();return Array.from(G,j=>({top:j.top,left:j.left,right:j.right,bottom:j.bottom}))},measureKey:n,belowWhenOffFirstLine:!0});$.useEffect(()=>{const G=X_(a);if(x(G??null),b(!1),G!==void 0)return;let j=!0;return NCt(a,window.api?.probeFiles).then(()=>{j&&x(X_(a)??null)}),()=>{j=!1}},[a]);const _=s==="file"&&TW(o,a),k=ZQe({target:a,isDirectory:v?.exists===!0&&!v.isFile,probe:v,canOpenInCanvas:_}),Q=MCt({kind:s,target:a,probe:v,quotable:r,canOpenInCanvas:_});if(!Q||!a)return null;const X=async()=>{await lv(a)&&b(!0)},C=async()=>{if(s==="url"){await Yee(s,a);return}o&&k&&await o.openInCanvas(a)||await Yee(s,a)||x(null)},T=async()=>{await Ru(a)||x(null)},A=async()=>{await XT(a)||x(null)},z={quote:d.jsx(nfe,{}),copy:y?d.jsx(Fi,{}):d.jsx(Od,{}),open:k?d.jsx(nze,{}):s==="url"?d.jsx(gm,{}):d.jsx(x1,{}),"open-default":d.jsx(z9e,{}),"open-folder":d.jsx($m,{})},Y={quote:c,copy:()=>{X()},open:()=>{C()},"open-default":()=>{T()},"open-folder":()=>{A()}};return d.jsxs(wU,{[q0]:"",[Pp]:"",ref:S,label:Q.label,className:R("absolute z-20",!w&&"invisible"),style:w?{top:w.top,left:w.left}:void 0,onKeyDown:G=>{if(G.key!=="Escape")return;window.getSelection()?.removeAllRanges();const j=n;G.preventDefault(),i(),j.focus?.()},children:[Q.actions.map(G=>d.jsxs($.Fragment,{children:[d.jsx(kt,{content:G.id==="copy"&&y?h("ui.common.actions.copied"):G.label,side:w?.placement==="below"?"bottom":"top",children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":G.id==="copy"&&y?h("ui.common.actions.copied"):G.label,className:"text-ink-dim hover:bg-accent-wash hover:text-accent",onClick:Y[G.id],children:z[G.id]})}),G.id==="quote"&&d.jsx(jP,{control:g,side:w?.placement==="below"?"bottom":"top"})]},G.id)),Q.note&&d.jsx("span",{className:"max-w-56 truncate ps-1 text-ink-dim text-meta",title:Q.noteTitle??Q.note,children:Q.note})]})};function Xzt({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 h9(e){return e.kind!=="user"&&e.kind!=="assistant"||e.kind==="assistant"&&e.streaming?null:e.id||null}const hne=96;function Czt(e){const t=e.replace(/\s+/g," ").trim();return t.length<=hne?t:`${t.slice(0,hne-1).trimEnd()}…`}function Azt(){return h("ui.chat.response_actions.answer_label")}function qzt(){return h("ui.chat.response_actions.yours_label")}const jzt="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 pne(e){return e?"opacity-100":jzt}const LTe=2e3,Nzt=1e4;function wxn(e){const{request:t}=e;return t?e.now-t.requestedAt>Nzt?"retire":e.presentable?e.claimed?"hold":"present":"yield":null}let mne=0,mx=0;const zzt=Ai(e=>({request:null,requestPanel:(t,n,r,i)=>{mne+=1,e({request:{destination:t,nonce:mne,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:()=>{mx+=1,e({presenterClaimed:!0});let t=!1;return()=>{t||(t=!0,mx=Math.max(0,mx-1),mx===0&&e({presenterClaimed:!1}))}}})),Uzt=(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)},Izt=9e4,gne=new Set,Wzt=2600,j_=$.memo(function({bodyText:t,kind:n="answer",agentId:r,speechId:i,revealId:a,revealAt:s,conversationId:o,entryId:l,overlay:c=!1,overlayClassName:u}){const[O,f]=$.useState(!1),[p,m]=$.useState(!1),g=$.useRef(null),y=$.useRef(null),b=$.useRef(null),v=$.useRef(null),{playSpeech:x}=k0(),S=CP(r??null),w=qP({key:i?vge(i):null,getText:()=>t,play:({text:z})=>{i&&x(i,S,z)}}),_=zzt(z=>z.requestPanel),k=!!(o&&l);ke();const Q=Xzt({role:n,forkable:k}),X=O||w.active;$.useEffect(()=>()=>{g.current!==null&&clearTimeout(g.current)},[]),$.useEffect(()=>{if(!a||s===void 0||gne.has(a)||(gne.add(a),Date.now()-s>Izt))return;const z=y.current;if(z===null)return;const Y=z.closest(".group")??z;if(Uzt(z,Y))return;m(!0);const G=()=>{m(!1),Y.removeEventListener("pointerenter",G),Y.removeEventListener("focusin",G)};return Y.addEventListener("pointerenter",G),Y.addEventListener("focusin",G),()=>{Y.removeEventListener("pointerenter",G),Y.removeEventListener("focusin",G)}},[a,s]),$.useEffect(()=>{if(p)return v.current=setTimeout(()=>{v.current=null,m(!1)},Wzt),()=>{v.current!==null&&clearTimeout(v.current)}},[p]);const C=async()=>{await lv(t)&&(f(!0),g.current!==null&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,f(!1)},LTe))},T=()=>{!o||!l||_("session.fork",b.current,o,{id:l,excerpt:Czt(t)})},A={copy:d.jsx(kt,{content:O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),side:"bottom",children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":O?h("ui.chat.response_actions.copied"):h("ui.chat.response_actions.copy"),className:R("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:C,children:O?d.jsx(Fi,{"aria-hidden":"true"}):d.jsx(Od,{"aria-hidden":"true"})})}),speak:d.jsx(jP,{control:w,side:"bottom",className:R("text-ink-dim hover:bg-transparent hover:text-ink")}),fork:d.jsx(kt,{content:h("ui.chat.pickers.destination_pickers.fork_from_this_message"),side:"bottom",children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":h("ui.chat.pickers.destination_pickers.fork_from_this_message"),ref:b,className:R("text-ink-dim hover:bg-transparent hover:text-ink"),onClick:T,children:d.jsx(tNe,{"aria-hidden":"true"})})})};return d.jsx("div",{role:"toolbar","aria-label":n==="user"?qzt():n==="commentary"?h("ui.chat.commentary_actions.label"):n==="response"?h("ui.chat.response_actions.label"):Azt(),ref:y,onAnimationEnd:z=>{z.target===z.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:R(c?R("absolute z-10 flex h-8 items-center gap-1","-top-2 end-0",pne(X),u):R("flex h-8 shrink-0 items-center gap-1",pne(X))),children:Q.map(z=>d.jsx($.Fragment,{children:A[z]},z))})}),Dzt="video",MTe="music",Yzt=e=>(e.jobType===Dzt||e.jobType===MTe)&&Wf(e)&&e.music?.stage!=="cancel_requested",Gzt=()=>h("ui.chat.run_controls.job.not_found"),Lzt=e=>e instanceof Pn&&e.status===null,xxn=(e,t)=>Lzt(t)?e<1:!1,_xn=e=>e instanceof Pn&&e.status===404&&e.message===ZOe?Gzt():Ys(e,h("ui.chat.run_controls.job.cancel_failed")),Mzt=new Set(["generate_music","modify_music"]),nD=e=>Mzt.has(e),Zzt=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function rD(e){return!Zzt(e)||e.material!=="music"?null:typeof e.job_id=="string"&&e.job_id.length>0?e.job_id:null}function Vzt(e){const t=/^background job '[^\n]*' (completed|failed|cancelled|paused)\b/.exec(e);return t?t[1]:null}function Fzt(e){const t=new Map,n=new Map;for(const r of e){if(r.kind!=="custom"||!r.jobId)continue;const i={status:Vzt(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 Sxn(e){const t=new Map,n=new Map;for(const r of e){if(r.jobType!==MTe)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 ZTe=$.createContext(null),VTe=$.createContext(new Map);function FTe(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 $1({cost_usd:t,billing_basis:n})}function Bzt(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:FTe(i.receipt)}}const s=r,o=s.music?.completed??0,l=s.music?.total??0;return Wf(s)?{...e,state:"cancel_requested",completed:o,total:l,cost:null}:{...e,state:s.status==="done"?"finished_after_cancel":"cancelled",completed:l,total:l,cost:null}}function BTe({toolName:e,details:t,row:n,settlement:r,successorRow:i,liveLoaded:a=!1}){if(!nD(e))return null;const s=rD(t);if(s===null)return null;const l={jobId:s,modify:e==="modify_music",cost:null,cancelRow:null},c=Bzt(l,{settlement:r,row:n,successorRow:i});if(c)return c;if(r?.successor||i)return BTe({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:FTe(r.receipt)}}if(n){const u=n.music?.completed??0,O=n.music?.total??0;if(!Wf(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:Yzt(n)?n:null}}return{...l,state:a?"unavailable":"queued",completed:0,total:0}}const Hzt=({active:e,settled:t=!1,completed:n,total:r,attribution:i})=>d.jsxs("div",{"data-music-processing":"",className:R("flex min-w-0 flex-col gap-1 py-1"),children:[d.jsxs("div",{className:R("flex items-center gap-2 text-ink-muted text-body-sm"),children:[d.jsx(DNe,{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:R("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:s,id:o})=>d.jsx("rect",{x:o*6,y:(44-s)/2,width:"4",height:s,rx:"2",fill:"currentColor"},o))},a))}),i&&d.jsx("p",{className:R("text-body-sm text-ink"),children:i})]}),Kzt=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")}},Jzt=new Set(["done","failed","cancelled","finished_after_cancel"]),eUt=({view:e,onCancel:t})=>{const n=e.cost;return d.jsxs("div",{"data-music-generating":e.jobId,"data-music-state":e.state,className:R("mt-2 flex min-w-0 items-start gap-2"),children:[d.jsxs("div",{className:R("flex min-w-0 flex-1 flex-col"),children:[d.jsxs("p",{"aria-live":"polite",className:R("text-body-sm",e.state==="failed"?"text-danger":"text-ink"),children:[Kzt(e),n&&d.jsxs("span",{className:R("text-ink-muted"),children:[" ",n]})]}),d.jsx(Hzt,{active:e.state==="generating",settled:Jzt.has(e.state),completed:e.completed,total:e.total})]}),e.cancelRow&&t&&d.jsx(Se,{variant:"ghost",size:"sm","data-music-cancel":e.jobId,"aria-label":h("ui.chat.run_details.job_cancel_aria",{label:e.cancelRow.label}),className:R("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")})]})},tUt=5e3,nUt=(e,t)=>{const n=$.useContext(ZTe),r=$.useContext(VTe),i=rD(t),a=i?n?.rows.get(i):void 0,s=i?n?.successors?.get(i):void 0,o=i?r.get(i):void 0,l=i!==null&&n?.loaded===!0&&!a&&!s&&!o,[c,u]=$.useState(null);return $.useEffect(()=>{if(!l||i===null)return;const O=setTimeout(()=>u(i),tUt);return()=>clearTimeout(O)},[l,i]),BTe({toolName:e,details:t,row:a,settlement:o,successorRow:s,liveLoaded:l&&c===i})},rUt=({view:e})=>{const n=$.useContext(ZTe)?.request??null,r=e.cancelRow;return d.jsx(eUt,{view:e,onCancel:n&&r?i=>n(r,{left:i.left,top:i.top,bottom:i.bottom,right:i.right}):void 0})},iUt=({receipt:e,scope:t})=>d.jsxs("div",{"data-music-result":"",className:R("mt-2 flex min-w-0 flex-col gap-3"),children:[e.attribution&&d.jsx("p",{className:R("text-body-sm text-ink"),children:e.attribution}),e.tracks.length===0&&d.jsx("p",{className:R("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?$1({cost_usd:n.cost.amount_usd,billing_basis:n.cost.basis}):null;return d.jsxs("div",{"data-music-track":n.id,className:R("flex min-w-0 flex-col gap-1"),children:[d.jsx("p",{className:R("text-body-sm text-ink"),children:r}),n.title&&e.tracks.length>1&&d.jsx("p",{className:R("text-body-sm text-ink-muted"),children:h("ui.music.track",{index:(n.variantIndex+1).toLocaleString()})}),n.images.map(a=>d.jsx(DT,{audio:a,scope:t,label:a.name||r},a.id)),n.error&&d.jsx("p",{className:R("text-body-sm text-danger"),children:h("ui.music.failed")}),i&&d.jsx("p",{className:R("text-body-sm text-ink-muted"),children:i})]},n.id)})]}),HTe="@container/olderhistory mb-4 flex h-7 min-w-0 items-center gap-2",gx="@min-[260px]/olderhistory:hidden",$x="@max-[260px]/olderhistory:hidden",KTe="lo-older-history-hint",aUt=({state:e,loadingVariant:t="older",transportDown:n=!1,onLoadOlder:r,onRetryHydration:i})=>{ke();const a=e==="loading"?jTe(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,s=e==="loading";return d.jsxs("div",{className:HTe,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:gx,children:h("ui.chat.canonical.older_history.transport.short")}),d.jsx("span",{className:$x,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:gx,children:h("ui.chat.canonical.older_history.failed.short")}),d.jsx("span",{className:$x,children:h("ui.chat.canonical.older_history.failed.long")})]}),d.jsx(Se,{variant:"ghost",size:"sm",className:"shrink-0",onClick:r,children:h("ui.chat.canonical.older_history.try_again")})]}):s?d.jsx(Se,{variant:"ghost",size:"sm","aria-disabled":!0,onClick:o=>{o.preventDefault()},className:"min-w-0 text-ink-muted",children:d.jsx(d9,{variant:t,announce:!1})}):e==="idle"?d.jsx(Se,{variant:"ghost",size:"sm",onClick:r,children:h("ui.chat.canonical.older_history.load")}):e==="windowed"?d.jsxs("span",{id:KTe,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:gx,children:n?h("ui.chat.canonical.older_history.windowed.title"):h("ui.chat.canonical.older_history.windowed.short_gesture")}),d.jsx("span",{className:$x,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:gx,children:h("ui.chat.canonical.older_history.unproven.short")}),d.jsx("span",{className:$x,children:h("ui.chat.canonical.older_history.unproven.long")})]}),!n&&i&&d.jsx(Se,{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")})]})},sUt=()=>d.jsx("div",{"aria-hidden":"true",className:HTe}),oUt="/settings?section=providers",$ne="/settings?section=providers&provider=radient",lUt="/settings?section=radient",yne=/sign in to radient/i,cUt=[/insufficient credits/i,/credit balance is too low/i],uUt=[/rate limit or quota/i],OUt=[/insufficient credits/i,/\bHTTP 402\b/i];function JTe(e){return(e??"").split("/")[0]?.trim().toLowerCase()==="radient"}function iD(e){return JTe(e.provider)?e.category==="billing"?!0:(e.category==null||e.category==="unknown"||e.category==="rate-limit")&&OUt.some(n=>n.test(e.text)):!1}function dUt(e){if(!iD(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 fUt(e){return e==="auth"?"sign-in":e==="billing"?"billing":e==="rate-limit"?"quota":null}function bne(e){const t=JTe(e.provider)||yne.test(e.text);let n=fUt(e.category);return iD(e)&&(n="billing"),n===null&&(e.category==null||e.category==="unknown")&&(yne.test(e.text)?n="sign-in":cUt.some(r=>r.test(e.text))?n="billing":uUt.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:$ne}:n==="billing"&&t?{label:h("ui.chat.provider_error.action.open_radient_account"),to:lUt}:{label:h("ui.chat.provider_error.action.open_provider_settings"),to:t?$ne:oUt}}const e2e=({conversationId:e,turnRef:t,allowQuote:n=!0})=>{ke();const{text:r,clear:i}=WTe(t),a=r!==null,s=YTe(e,t);$.useEffect(()=>{const b=t.current;if(!b||!a)return;const v=b.closest("[data-record-id]")??b,x=[...v.querySelectorAll("[data-lo-gutter-actions], [data-lo-user-actions], [data-lo-answer-actions], [data-lo-response-actions]")];v.setAttribute("data-lo-selection-active","");for(const S of x)S.setAttribute("inert",""),S.setAttribute("aria-hidden","true");return()=>{v.removeAttribute("data-lo-selection-active");for(const S of x)S.removeAttribute("inert"),S.removeAttribute("aria-hidden")}},[a,t]);const[o,l]=$.useState(!1),c=$.useRef(null);$.useEffect(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);const u=$.useCallback(async()=>{const b=rm(t.current)?.text??r;b&&await lv(b)&&(l(!0),c.current!==null&&clearTimeout(c.current),c.current=setTimeout(()=>{c.current=null,l(!1)},LTe))},[r,t]),{controlRef:O,placement:f}=ITe({turnRef:t,visible:a,lines:()=>rm(t.current)?.lines??null}),{speak:p}=k0(),m=CP(e),g=r===null?null:km(e,XP(r).text);xge(g);const y=qP({key:g,getText:()=>rm(t.current)?.text??null,play:({text:b})=>p(km(e,b),AP(m,b))});return $.useEffect(()=>{if(!a)return;const b=v=>{v.key!=="Escape"||v.defaultPrevented||(window.getSelection()?.removeAllRanges(),i())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[a,i]),a?d.jsxs(wU,{[q0]:"",ref:O,label:h("ui.chat.transcript_copy.selection.toolbar"),className:R("absolute z-20",!f&&"invisible"),style:f?{top:f.top,left:f.left}:void 0,children:[n&&d.jsx(kt,{content:h("ui.chat.transcript_copy.selection.quote"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(Se,{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:s,children:d.jsx(nfe,{})})}),d.jsx(kt,{content:o?h("ui.chat.transcript_copy.toast.copied_selection"):h("ui.chat.transcript_copy.selection.copy"),side:f?.placement==="below"?"bottom":"top",children:d.jsx(Se,{variant:"ghost",size:"icon-sm","aria-label":o?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:o?d.jsx(Fi,{}):d.jsx(Od,{})})}),d.jsx(jP,{control:y,side:f?.placement==="below"?"bottom":"top"})]}):null},t2e={all:["radient-prices"],prices:()=>[...t2e.all,"prices"]},hUt=()=>{const e=Xt({queryKey:t2e.prices(),queryFn:()=>Hz({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}},vne="https://console.radienthq.com/dashboard/verification",pUt="https://console.radienthq.com",wne="https://console.radienthq.com/dashboard/billing",xne=()=>h("ui.common.account.top_up");function mUt(e){return!e.email_verified&&e.signup_grant!=="claimed"}const kxn=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:`$${e.toFixed(2)}`}),p9=e=>Number.isInteger(e)?`$${e}`:`$${e.toFixed(2)}`,gUt=e=>typeof e!="number"||!Number.isFinite(e)?h("ui.common.account.free_credits_unknown"):h("ui.common.account.free_credits",{amount:p9(e)});function m9(e,t){if(!e)return t;try{const{protocol:n}=new URL(e);return n==="https:"||n==="http:"?e:t}catch{return t}}const Qxn="/settings?section=radient";function n2e(e){window.api?.openExternal?window.api.openExternal(e):window.open(e,"_blank")}const $Ut=(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 yUt(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:vne},{label:xne(),url:wne}]};if(mUt(e)){const i=m9(e.claim_url,vne),{action:a}=$Ut(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 s=gUt(e.grant_amount??t);return{state:"unverified",lines:[h("ui.common.account.out_unverified_claim",{amount:s}),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:p9(n.bonus_amount),minimum:p9(n.minimum_purchase)})),{state:"verified",lines:r,links:[{label:xne(),url:m9(n?.topup_url,wne)}]}}const bUt=5*1e3,vUt=({action:e})=>{const{user:t,accountRead:n}=Xme({staleTime:bUt,retryOnMount:!1}),r=vr(),{prices:i}=hUt(),s=r.isPending||n==="checking"?null:yUt(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:[s?d.jsxs("div",{"data-radient-credits-state":s.state,className:"flex max-w-[60ch] items-start gap-3 rounded-sm border border-hairline bg-surface p-3",children:[d.jsx(pm,{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:s.lines.map(o=>d.jsx("p",{className:"[&:not(:first-child)]:mt-1",children:o},o))})]}):null,d.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s?.links.map(o=>d.jsx(Se,{variant:"secondary",size:"sm",onClick:()=>n2e(o.url),children:o.label},o.url)),d.jsx(Se,{variant:"ghost",size:"sm",asChild:!0,children:d.jsx(Yde,{to:e.to,children:e.label})})]})]})},E$="data-jump-highlight",wUt=1400,aX=new WeakMap;function g9(e){const t=aX.get(e);t!==void 0&&window.clearTimeout(t);const n=e.hasAttribute(E$);e.removeAttribute(E$),n&&e.offsetHeight,e.setAttribute(E$,""),aX.set(e,window.setTimeout(()=>{aX.delete(e),e.removeAttribute(E$)},wUt))}const N_=24,r2e=6,$9=()=>new Promise(e=>{window.requestAnimationFrame(()=>{e()})}),_ne=async e=>{for(let t=0;t<r2e;t+=1){if(e())return;await $9()}},i2e=e=>{let t=null;return()=>(t!==null||(t=e().finally(()=>{t=null})),t)},xUt=e=>{const t=i2e(e.loadOlder),n=()=>_ne(()=>e.reachable()||e.rowDistance()!==null);return{loadOne:t,loadThrough:async i=>{const a=e.hasHeadroom??(()=>!0);let s=0;for(;;){if(e.reachable())return"landed";const o=e.rowDistance();if(o!==null){if(i.maxRows!==void 0&&o>i.maxRows)return"over-budget";if(!a()&&s<i.maxPages&&(s+=1,await t())){await n();continue}return e.mount(o),await _ne(()=>e.reachable()),e.reachable()?"landed":"exhausted"}if(s>=i.maxPages||(s+=1,!await t()))return"exhausted";await n()}}}},_Ut=12,SUt=1200,kUt=r2e,QUt=kUt+2,PUt=2,TUt=30,Sne=1,Bg=N_;let fp=0;async function EUt(e){const{isReachable:t,rowDistance:n,mount:r,loadOlder:i}=e,a=e.hasHeadroom??(()=>!0);return await xUt({reachable:t,rowDistance:n,mount:r,loadOlder:i,hasHeadroom:a}).loadThrough({maxPages:_Ut,maxRows:SUt})==="landed"}async function RUt(e,t,n){if(!n()||!t.isConnected)return;fp+=1;const r=fp;a_(e,t,"reversed",Bg);const i=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);let a=!1;const s=()=>{a=!0},o=l=>{i.has(l.key)&&(a=!0)};e.addEventListener("wheel",s,{passive:!0,once:!0}),e.addEventListener("pointerdown",s,{passive:!0,once:!0}),e.addEventListener("touchstart",s,{passive:!0,once:!0}),window.addEventListener("keydown",o);try{let l=0,c=!1;for(let u=0;u<QUt&&(await $9(),!(!n()||!t.isConnected||a||r!==fp));u+=1){const O=t.getBoundingClientRect().top-e.getBoundingClientRect().top-e.clientTop-Bg;if(Math.abs(O)<=Sne){if(l+=1,l>=PUt){c=!0;break}continue}l=0,a_(e,t,"reversed",Bg)}if(c&&!a&&r===fp){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",o),(async()=>{try{for(let p=0;p<TUt;p+=1){if(await $9(),!n()||a||r!==fp||!u.isConnected||!O.isConnected)return;const m=O.getBoundingClientRect().top-u.getBoundingClientRect().top-u.clientTop-Bg;if(Math.abs(m)<=Sne)continue;a_(u,O,"reversed",Bg);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",o)}})()}}finally{e.removeEventListener("wheel",s),e.removeEventListener("pointerdown",s),e.removeEventListener("touchstart",s),window.removeEventListener("keydown",o)}if(n()&&!a&&r===fp){const l=e.ownerDocument?.defaultView;l!=null&&e.dispatchEvent(new l.Event("scroll"))}}function a2e(e,t,n,r=()=>!0){return r()?new Promise(i=>{lzt(e,n,{isCurrent:r,onRevealed:a=>{if(!r()){i("missing");return}g9(a),RUt(t,a,r).then(()=>{r()&&a.isConnected&&!a.hasAttribute(E$)&&g9(a),i(r()?"landed":"missing")})},onMissing:()=>{i("missing")}})}):Promise.resolve("missing")}const UO=120,yx=400,XUt=.5,CUt=320,AUt=900,bx=64,GT=2,sX=24,oX=3,qUt=4,Rb=12,y9=Rb,jUt=120,NUt=.35,kne=12,zUt=8,UUt=Rb,IUt=.5,Qne=()=>({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}),s2e=e=>Math.min(AUt,Math.max(CUt,Math.round(e*XUt))),WUt=(e,t)=>{if(t.direction==="down")return{...e,armed:!1,deliberate:!1,retained:!1,actFetchSpent:t.at-e.lastInputAt>=yx?!1:e.actFetchSpent,actAsks:t.at-e.lastInputAt>=yx?0:e.actAsks,revealsThisAct:t.at-e.lastInputAt>=yx?0:e.revealsThisAct,continuation:!1,clampLatched:!1,travelledSinceLatch:!1,actTravelled:e.actTravelled||t.travelledPx>=bx,pageWidenOwed:!1,turnedAround:e.busy,chainFetch:0,chainWiden:0,chainInvisible:0,lastInputAt:t.at};const n=t.at-e.lastInputAt>=yx,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>=bx:e.actTravelled||t.travelledPx>=bx,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>=bx&&!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}},Hg=(e,t,n)=>({action:t,state:{...e,armed:!1,deliberate:!1,busy:!0,continuation:!1,clampLatched:e.clampLatched||e.armed&&n.distanceFromTopPx<=GT,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}}),DUt=(e,t,n)=>e.busy||e.pageWidenOwed?!0:!e.armed||!o2e(t).inZone?!1:t.distanceFromTopPx<=GT?!e.pressDemand||!e.clampLatched||e.actTravelled||e.actAsks>=y9?!1:n-e.lastInputAt>=UO:!0;function o2e(e,t=s2e(e.clientHeight)){return{inZone:e.distanceFromTopPx<=t}}const YUt=(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=s2e(t.clientHeight),{inZone:a}=o2e(t,i),s=n-e.lastInputAt>=UO||t.distanceFromTopPx<=GT,o=e.revealsThisAct<UUt;if(e.pageWidenOwed&&r==="widen"&&e.chainWiden<kne&&o)return s?Hg({...e,pageWidenOwed:!1,continuation:!1,armed:!1,retained:!1,deliberate:!1},r,t):{action:"none",state:e};if(e.armed){if(e.deliberate)return Hg(e,r,t);if(r==="fetch"&&e.failures>=oX)return{action:"none",state:{...e,armed:!1}};if(!s)return{action:"none",state:e};if(!a)return{action:"none",state:{...e,armed:!1}};if(r==="fetch"&&e.actFetchSpent){const l=n-e.lastInputAt>=UO;return l&&e.clampLatched&&!e.actTravelled&&e.pressDemand&&e.actAsks<y9?Hg(e,r,t):l?{action:"none",state:{...e,armed:!1}}:{action:"none",state:e}}return Hg(e,r,t)}if(e.continuation){const l=e.actAsks<y9,c=l&&e.chainInvisible>0&&e.chainInvisible<Rb;return t.scrollable&&!(e.pageWidenOwed&&r==="widen")&&!c?{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}:o&&(r==="widen"?e.chainWiden<kne:(c||l&&e.chainFetch<qUt)&&e.failures<oX)?Hg({...e,pageWidenOwed:!1,continuation:!1},r,t):{action:"none",state:{...e,continuation:!1,pageWidenOwed:!1}}}return{action:"none",state:e}},Pne=(e,{network:t=!0,hiddenRowsAfter:n=0,paintedDelta:r=null,growthPx:i=null,clientHeight:a=0,newRecords:s=null}={})=>{const o=r!==null&&r<zUt,l=r===null&&t&&i!==null&&i<Math.max(jUt,NUt*a),c=o||t&&s===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,Rb):0,continuation:t&&n>0||c&&e.chainInvisible+1<Rb||!e.retained&&!e.turnedAround}},GUt=e=>({...e,busy:!1,pressDemand:!1,failures:e.failures+1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),LUt=e=>({...e,busy:!1,pressDemand:!1,armed:!1,deliberate:!1,retained:!1,turnedAround:!1,continuation:!1,actFetchSpent:!1,pageWidenOwed:!1}),MUt=(e,t,n,r)=>n===r?l2e(e,t):null,l2e=(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)<IUt?0:n};function Nk({path:e}){switch(aU(e)){case"image":return d.jsx(Vde,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"spreadsheet":return d.jsx(Fde,{"aria-hidden":"true",className:"size-3.5 shrink-0"});case"markdown":case"text":case"document":return d.jsx(jy,{"aria-hidden":"true",className:"size-3.5 shrink-0"});default:return d.jsx(x1,{"aria-hidden":"true",className:"size-3.5 shrink-0"})}}function ZUt(e,t){try{return TW(e,t)}catch{return!1}}function Ov(e,t,n,r){const i=$.useCallback(async o=>{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 o(c.resolved)}catch{lr(h("ui.chat.highlights.file_resolution_failed"))}},[e,t,r]),a=ZUt(n??null,e),s=$.useCallback(()=>{i(async o=>{a&&n&&await n.openInCanvas(o)||await Ru(o)})},[i,a,n]);return{canOpenInCanvas:a,press:s,withTarget:i}}const LT=$.memo(function({actionPath:t,label:n,cwd:r,pane:i,overlay:a=!1,resolveActionPath:s,missing:o=!1}){ke();const{canOpenInCanvas:l,withTarget:c}=Ov(t,r,i,s),[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(tP,{children:[d.jsx(kt,{content:h("ui.common.actions.file_actions_menu.file_actions"),children:d.jsx(nP,{asChild:!0,children:a?d.jsx(Se,{variant:"ghost",size:"icon-sm",className:"bg-accent-wash","aria-label":f,children:d.jsx(aS,{"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(aS,{"aria-hidden":"true",className:"size-3.5"})})})}),d.jsxs(rP,{align:"end",className:"min-w-45",children:[l&&!o&&d.jsxs(uo,{onSelect:()=>{c(p=>i?.openInCanvas(p))},children:[d.jsx(Hde,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_canvas")})]}),!o&&d.jsxs(uo,{onSelect:()=>{c(Ru)},children:[d.jsx(x1,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.open_in_default_app")})]}),!o&&d.jsxs(uo,{onSelect:()=>{c(XT)},children:[d.jsx($m,{"aria-hidden":"true"}),d.jsx("span",{children:h("ui.chat.canonical.supplement.file_actions.reveal_in_finder")})]}),d.jsxs(uo,{onSelect:()=>{(s&&!o?s():Promise.resolve(t)).then(p=>navigator.clipboard.writeText(p)).then(()=>O(!0)).catch(()=>lr(h("ui.notices.files.copy_path_failed")))},children:[d.jsx(FN,{"aria-hidden":"true"}),d.jsx("span",{children:u?h("ui.common.actions.copied"):h("ui.common.file_actions.copy_file_path")})]})]})]})});function VUt(e){return e.materialisable===!1&&!e.stored?"gone":e.exists===!0?"present":e.exists===!1?e.stored?"retained":"gone":e.stored?"present":"gone"}const aD=(e,t,n)=>`${e}:${t??`#${n}`}`;function FUt(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:aD(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:VUt(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 BUt(e,t,n){return{key:aD(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 HUt(e,t,n){return{key:aD(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 c2e(e){const t=[];for(const n of e??[])n.kind==="user"&&((n.documents??[]).forEach((r,i)=>{t.push(BUt(n,r,i))}),n.images.forEach((r,i)=>{r.kind!==void 0&&r.kind!=="image"||t.push(HUt(n,r,i))}));return t}function KUt(e,t,n=!1){const r=e?.state==="ready",i=r?(e?.items??[]).map(FUt).filter(m=>m!==null):[],a=!n||e?.state==="unsupported"?"none":r?i.length>0&&i.every(m=>m.materialisable===null)?"none":"ready":"pending",s=new Map(i.map(m=>[m.key,m])),o=new Map;for(const m of i){const g=`${m.messageId}:${m.kind}`;o.set(g,(o.get(g)??0)+1)}const l=c2e(t),c=new Map,u=eIt({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),s.has(m.key))continue;const b=b9(u,{messageId:m.messageId,kind:m.kind,position:y,count:O.get(g)??0,digest:m.digest,path:m.path}),v=b===null?m:{...m,materialisable:b};if(v.digest===null){const x=`${v.messageId}:${v.kind}`,S=c.get(x)??0;if(c.set(x,S+1),S<(o.get(x)??0))continue}s.set(v.key,v),p.push(v)}return p.sort((m,g)=>g.ts-m.ts),{items:p,complete:r,truncated:!!e?.truncated,verdicts:a}}const dv={digests:new Set,slots:new Map,paths:new Set,verdicts:"none",judged:new Map},JUt={...dv,verdicts:"pending"};function eIt(e){const t=e.verdicts??"none";if(t==="pending")return JUt;const n=new Set,r=new Set,i=new Map,a=new Map;for(const o of e.items){if(typeof o.materialisable!="boolean"||o.index===void 0)continue;const l=`${o.messageId}:${o.kind}`;i.set(l,(i.get(l)??0)+1);const c=o.materialisable===!1;c&&o.digest&&n.add(o.digest),c&&o.path&&r.add(o.path);const u=a.get(l)??[];u.push({index:o.index,refused:c}),a.set(l,u)}const s=new Map;for(const[o,l]of a)l.some(c=>c.refused)&&(l.sort((c,u)=>c.index-u.index),s.set(o,l.map(c=>c.refused)));return!s.size&&t==="none"?dv:{digests:n,slots:s,paths:r,verdicts:t,judged:i}}function b9(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 Tne(e,t){return e&&t!==!1&&t!=="pending"}function Pxn(e){return new Set(e.items.map(t=>t.digest).filter(t=>t!==null))}function Txn(e,t,n=0,r=!0){const i=vr(),a=i.data!==void 0,s=jn(i.data,"session_attachments"),o=$.useMemo(()=>c2e(t),[t]),l=o.map(X=>`${X.key}:${X.digest??""}`).join("|"),[c,u]=$.useState({key:"",value:null,state:"loading"}),O=`${e??"draft"}:${s}`,[f,p]=$.useState(0),{echoIds:m,durableIds:g}=$.useMemo(()=>{const X=new Set(o.map(A=>A.messageId)),C=[],T=[];for(const A of t??[])A.kind!=="user"||!X.has(A.id)||(A.local||A.provisional?C:T).push(A.id);return{echoIds:C.join(`
948
948
  `),durableIds:T.join(`