@marimo-team/frontend 0.9.28-dev14 → 0.9.28-dev18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{ConnectedDataExplorerComponent-eIOzy8kg.js → ConnectedDataExplorerComponent-DPcdKawL.js} +1 -1
- package/dist/assets/{VegaLite-Dvna4_3L.js → VegaLite-CgPaPGw8.js} +1 -1
- package/dist/assets/{_baseEach-D-oIAGPP.js → _baseEach-Bqlmi48l.js} +1 -1
- package/dist/assets/_baseMap-C3qxL0qV.js +1 -0
- package/dist/assets/{_baseUniq-BlMiCOOg.js → _baseUniq-DjqTbvi9.js} +1 -1
- package/dist/assets/{any-language-editor-Dd0nKkIJ.js → any-language-editor-CQIsSAN2.js} +1 -1
- package/dist/assets/{architectureDiagram-IFBEXTG3-DRrx8a1D.js → architectureDiagram-IFBEXTG3-obA-JpgW.js} +1 -1
- package/dist/assets/{blockDiagram-TCMKQVZ6-qEjiVgNy.js → blockDiagram-TCMKQVZ6-CuJj6kmC.js} +1 -1
- package/dist/assets/{c4Diagram-ZCSEYPFN-BZw2TM8G.js → c4Diagram-ZCSEYPFN-CNagSpAj.js} +1 -1
- package/dist/assets/channel-BgFmdBNr.js +1 -0
- package/dist/assets/{chunk-4LC2V6XN-C9SCh-7q.js → chunk-4LC2V6XN-BRaGafEs.js} +1 -1
- package/dist/assets/{chunk-5RIWM3LS-DqsxjOFJ.js → chunk-5RIWM3LS-BCuifBFV.js} +1 -1
- package/dist/assets/{chunk-6JKP7OK7-DuWPJ3M8.js → chunk-6JKP7OK7-BH04ww4l.js} +1 -1
- package/dist/assets/{chunk-NGC4727B-ggutjN9W.js → chunk-NGC4727B-B-NfZMjT.js} +1 -1
- package/dist/assets/{chunk-REEJFE46-B4Xs2616.js → chunk-REEJFE46-Dehx6WVc.js} +1 -1
- package/dist/assets/{chunk-RYO7GUH3-CfQYq0_q.js → chunk-RYO7GUH3-DfaanueR.js} +1 -1
- package/dist/assets/{chunk-V35ELUW5-FFItP2CD.js → chunk-V35ELUW5-OHesDEMd.js} +1 -1
- package/dist/assets/{classDiagram-Q73GJZWF-xtLPuzhT.js → classDiagram-Q73GJZWF-54MqTh8D.js} +1 -1
- package/dist/assets/{classDiagram-v2-C6QPLPW4-CbCPU_7z.js → classDiagram-v2-C6QPLPW4-D8TeY9E4.js} +1 -1
- package/dist/assets/clone-Bmzo9sKz.js +1 -0
- package/dist/assets/{dagre-7KT5K2WU-CLIRwYOA.js → dagre-7KT5K2WU-BPWsvG9W.js} +1 -1
- package/dist/assets/{data-editor-C5s_cIGF.js → data-editor-COjoH9HV.js} +1 -1
- package/dist/assets/{diagram-AVGMFHF7-BPMOXGHY.js → diagram-AVGMFHF7-AZJY5XHm.js} +1 -1
- package/dist/assets/{edit-page-BzqAHha4.js → edit-page-DuGAchXO.js} +3 -3
- package/dist/assets/{erDiagram-DKC2X5TE-BcsTtGo1.js → erDiagram-DKC2X5TE-CQjZUizQ.js} +1 -1
- package/dist/assets/{flowDiagram-NWEUNK3L-gUAlyn2s.js → flowDiagram-NWEUNK3L-BxwE-bx0.js} +1 -1
- package/dist/assets/{ganttDiagram-HLVPPPRE-Dwxis49U.js → ganttDiagram-HLVPPPRE-Cq0b6Eet.js} +1 -1
- package/dist/assets/{gitGraph-YCYPL57B-CFTzBIfR.js → gitGraph-YCYPL57B-CEhJDAI5.js} +1 -1
- package/dist/assets/{gitGraphDiagram-JPZ3KUXI-Dbo-hHkt.js → gitGraphDiagram-JPZ3KUXI-ShN034Dn.js} +1 -1
- package/dist/assets/{graph-C1gKAOtl.js → graph-D0Nz_OBC.js} +1 -1
- package/dist/assets/{home-page-CeR2cXkT.js → home-page-f8m7tsXR.js} +1 -1
- package/dist/assets/{index-CTEE1uzT.js → index-BB1VLbxl.js} +1 -1
- package/dist/assets/{index-Wy-fSHe8.js → index-BcNeeyXl.js} +1 -1
- package/dist/assets/{index-z7wlfFF1.js → index-BriEBaMD.js} +1 -1
- package/dist/assets/{index-BtBVAntb.js → index-BsaRZgH3.js} +1 -1
- package/dist/assets/{index-CFPvAq0n.js → index-BskX1TES.js} +1 -1
- package/dist/assets/{index-DiO6MKAE.js → index-BxeSyCes.js} +4 -4
- package/dist/assets/{index-Cd5VQnoI.js → index-C4kqVGSJ.js} +1 -1
- package/dist/assets/{index-D_cusyGc.js → index-CA9Ivqfh.js} +1 -1
- package/dist/assets/{index-1TiZkKhw.js → index-CVw6pZ7y.js} +1 -1
- package/dist/assets/{index-DZ3Crx1w.js → index-CiZpaeWR.js} +1 -1
- package/dist/assets/{index-DgSPTavE.js → index-CtO-4MLb.js} +1 -1
- package/dist/assets/{index-DIPCHkR_.js → index-CxHIPvl9.js} +1 -1
- package/dist/assets/{index-CbFE3MSK.js → index-D5asxg4c.js} +1 -1
- package/dist/assets/{index-odWYpVgJ.js → index-DVofz-rJ.js} +1 -1
- package/dist/assets/{index-CBQuuJQw.js → index-DqJrRCiK.js} +1 -1
- package/dist/assets/{index-CXejuVze.js → index-DzPdRF0p.js} +1 -1
- package/dist/assets/{index-CWrgt7tV.js → index-qJ5_1ERS.js} +1 -1
- package/dist/assets/{infoDiagram-RZZSJVI2-BIiITgzj.js → infoDiagram-RZZSJVI2-daGUeqNG.js} +1 -1
- package/dist/assets/{journeyDiagram-BLD6N6MZ-Bzelsalm.js → journeyDiagram-BLD6N6MZ-rQRL_LEZ.js} +1 -1
- package/dist/assets/{json-B9D7XJ7q.js → json-BHg_Eond.js} +1 -1
- package/dist/assets/{layout-B5D6wGwE.js → layout-D7HvMcEl.js} +1 -1
- package/dist/assets/{linear-C38ZnVWG.js → linear-rhrSF5hY.js} +1 -1
- package/dist/assets/{mermaid-dMrZlxaJ.js → mermaid-Dk9xv7VY.js} +3 -3
- package/dist/assets/{min-C9CLs5pF.js → min-CjGuiacy.js} +1 -1
- package/dist/assets/{mindmap-definition-OEB2RXX2-Cbd4f3xN.js → mindmap-definition-OEB2RXX2-DyHCXy57.js} +1 -1
- package/dist/assets/{pieDiagram-X7YZ5ZEZ-Bz9-Zh5P.js → pieDiagram-X7YZ5ZEZ-NdqGMaEK.js} +1 -1
- package/dist/assets/{quadrantDiagram-F36EZAVT-NlRXXFLe.js → quadrantDiagram-F36EZAVT-DivcKvSv.js} +1 -1
- package/dist/assets/{react-plotly-CVoJlMKT.js → react-plotly-CXnGCGBp.js} +1 -1
- package/dist/assets/{requirementDiagram-JG2LMPGF-BHggfVg0.js → requirementDiagram-JG2LMPGF-DHY3hHyg.js} +1 -1
- package/dist/assets/{run-page-BijiEECa.js → run-page-DReq8Be0.js} +1 -1
- package/dist/assets/{sankeyDiagram-ATFNWWW6-DvB_UAsC.js → sankeyDiagram-ATFNWWW6-CcbDJNC9.js} +1 -1
- package/dist/assets/{sequenceDiagram-WK7YDQ3N-C26gGupC.js → sequenceDiagram-WK7YDQ3N-DX0JR-rS.js} +1 -1
- package/dist/assets/{slides-component-nZNmD42F.js → slides-component-BrsSU2P4.js} +1 -1
- package/dist/assets/{sortBy-DXJAJh00.js → sortBy-DyNOE__7.js} +1 -1
- package/dist/assets/{stateDiagram-4JV6CC6H-CJb6dDKC.js → stateDiagram-4JV6CC6H-CQaP3jIK.js} +1 -1
- package/dist/assets/stateDiagram-v2-7KT6RKTD-C-pci2cf.js +1 -0
- package/dist/assets/{terminal-pFINbhgu.js → terminal-BLKbWCsr.js} +1 -1
- package/dist/assets/{time-V21R_lgx.js → time-ChZPeUyP.js} +1 -1
- package/dist/assets/{timeline-definition-3ZMEY6HS-DTt7l1t_.js → timeline-definition-3ZMEY6HS-CxY4Mqft.js} +1 -1
- package/dist/assets/{transform-DSnYyYYr.js → transform-rsMiis9u.js} +1 -1
- package/dist/assets/{tree-C5mBjNPD.js → tree-DSXaKJeB.js} +1 -1
- package/dist/assets/{useMarimoWebSocket-D1tuuF1J.js → useMarimoWebSocket-Q0rgYJeg.js} +3 -3
- package/dist/assets/{vega-component-4OjZI9gu.js → vega-component-m4FW3QKO.js} +1 -1
- package/dist/assets/{xychartDiagram-KECQ2H5Q-BTcbfgrj.js → xychartDiagram-KECQ2H5Q-9GfWVJ_Q.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +10 -10
- package/dist/assets/_baseMap-BHVyb3ut.js +0 -1
- package/dist/assets/channel-BjupRBqd.js +0 -1
- package/dist/assets/clone-D12tvmGl.js +0 -1
- package/dist/assets/stateDiagram-v2-7KT6RKTD-Q-Sk0_lP.js +0 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-
|
|
2
|
-
var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);import{b0 as o,G as r,h9 as a,ha as i,hb as s,hc as l,hd as c,he as d,R as u,hf as h,hg as f,hh as m,hi as p,hj as g,hk as v,hl as y,hm as x,D as b,by as w,K as k,hn as S,at as N,W as C,a2 as E,Z as j,_,ho as I,X as A,e7 as T,hp as M,cU as O,dl as D,ei as P,ej as R,ek as L,em as z,eg as F,eh as B,el as U,hq as V,hr as H,dp as $,dt as W,al as G,F as q,hs as Y,eD as X,ht as K,ar as J,dX as Z,cd as Q,hu as ee,dr as te,hv as ne,hw as oe,a0 as re,hx as ae,dv as ie,hy as se,H as le,b9 as ce,hz as de,hA as ue,hB as he,di as fe,hC as me,dm as pe,hD as ge,hE as ve,hF as ye,cT as xe,hG as be,hH as we,bA as ke,hI as Se,hJ as Ne,bb as Ce,hK as Ee,hL as je,hM as _e,Y as Ie,bq as Ae,hN as Te,a6 as Me,dj as Oe,ff as De,eQ as Pe,fi as Re,b6 as Le,eR as ze,as as Fe,hO as Be,hP as Ue,hQ as Ve,eS as He,hR as $e,hS as We,eW as Ge,hT as qe,hU as Ye,hV as Xe,hW as Ke,d8 as Je,hX as Ze,bo as Qe,$ as et,ap as tt,a1 as nt,bE as ot,hY as rt,dW as at,hZ as it,c_ as st,dq as lt,eo as ct,h_ as dt,bz as ut,h$ as ht,de as ft,i0 as mt,i1 as pt,bu as gt,i2 as vt,i3 as yt,i4 as xt,i5 as bt,i6 as wt,i7 as kt,T as St,a3 as Nt,i8 as Ct,d9 as Et,bB as jt,eV as _t,cV as It,i9 as At,fj as Tt,ia as Mt,bj as Ot,bC as Dt,ib as Pt,ic as Rt,id as Lt,ie as zt,dn as Ft,be as Bt,bf as Ut,ig as Vt,dL as Ht,d6 as $t,ih as Wt,eC as Gt,k as qt,j as Yt,ii as Xt,ij as Kt,ik as Jt,ey as Zt,il as Qt,im as en,cZ as tn,io as nn,ip as on,a7 as rn,b1 as an,aj as sn,ba as ln,iq as cn,bt as dn,ir as un,fm as hn,fl as fn,is as mn,eG as pn,it as gn,iu as vn,eN as yn,iv as xn,ex as bn,iw as wn,ix as kn,iy as Sn,iz as Nn,iA as Cn,iB as En,m as jn,iC as _n,iD as In,iE as An,t as Tn,iF as Mn,iG as On,iH as Dn,iI as Pn,iJ as Rn,iK as Ln,iL as zn,iM as Fn,iN as Bn,iO as Un,iP as Vn,iQ as Hn,iR as $n,iS as Wn,iT as Gn,iU as qn,iV as Yn,iW as Xn,iX as Kn,iY as Jn,iZ as Zn,i_ as Qn,i$ as eo,j0 as to,j1 as no,j2 as oo,j3 as ro,j4 as ao,j5 as io,j6 as so,j7 as lo,j8 as co,j9 as uo,ja as ho,jb as fo,fn as mo,jc as po,jd as go,je as vo,jf as yo,jg as xo,jh as bo,ji as wo,jj as ko,jk as So,jl as No,jm as Co,jn as Eo,jo,jp as _o,dx as Io,jq as Ao,jr as To,dA as Mo,js as Oo,jt as Do,ju as Po,jv as Ro,jw as Lo,jx as zo,jy as Fo,a8 as Bo,df as Uo,jz as Vo,dE as Ho,jA as $o,jB as Wo,jC as Go,jD as qo,jE as Yo,jF as Xo,jG as Ko,jH as Jo,jI as Zo,jJ as Qo,a4 as er,jK as tr,jL as nr,dU as or,jM as rr,jN as ar,jO as ir,jP as sr,jQ as lr,jR as cr,jS as dr,jT as ur,jU as hr,jV as fr,jW as mr,jX as pr,jY as gr,jZ as vr,j_ as yr,fk as xr,j$ as br,k0 as wr,k1 as kr,bn as Sr,eL as Nr,k2 as Cr,k3 as Er,k4 as jr,k5 as _r,k6 as Ir,k7 as Ar,k8 as Tr,eA as Mr,k9 as Or,bi as Dr,ka as Pr,bT as Rr,b2 as Lr,ah as zr,dV as Fr,kb as Br,cR as Ur,b7 as Vr,kc as Hr,dO as $r,bY as Wr,kd as Gr,bp as qr,ke as Yr,kf as Xr,kg as Kr,kh as Jr,ki as Zr,kj as Qr,kk as ea,kl as ta,km as na,br as oa,bc as ra,kn as aa,ko as ia,dd as sa,kp as la,kq as ca,kr as da,ks as ua,kt as ha,cW as fa,es as ma,dh as pa,ku as ga,bm as va,kv as ya,e9 as xa,eZ as ba,e_ as wa,e$ as ka,f3 as Sa,f1 as Na,f4 as Ca,f6 as Ea,f9 as ja,fc as _a,f7 as Ia,kw as Aa,kx as Ta,dM as Ma,ky as Oa,e5 as Da,kz as Pa,fa as Ra,kA as La,kB as za,kC as Fa,kD as Ba,J as Ua,ds as Va,kE as Ha,kF as $a,kG as Wa,M as Ga,kH as qa,kI as Ya,O as Xa,kJ as Ka,dk as Ja,kK as Za,kL as Qa,P as ei,kM as ti,ew as ni,b8 as oi,kN as ri,kO as ai,kP as ii,fb as si,kQ as li,dT as ci,kR as di,kS as ui,dc as hi,kT as fi,kU as mi,kV as pi,kW as gi,er as vi,kX as yi,kY as xi,dw as bi,kZ as wi,k_ as ki,k$ as Si,l0 as Ni,l1 as Ci,l2 as Ei,l3 as ji,l4 as _i,l5 as Ii,l6 as Ai,l7 as Ti,l8 as Mi,l9 as Oi,la as Di,lb as Pi,d1 as Ri,lc as Li,ld as zi,le as Fi,lf as Bi,lg as Ui,aq as Vi,bv as Hi,lh as $i,li as Wi,lj as Gi,lk as qi,ll as Yi,lm as Xi,ln as Ki,lo as Ji,lp as Zi,lq as Qi,lr as es,ls as ts,lt as ns,eF as os,lu as rs,lv as as,lw as is,lx as ss,ly as ls,e4 as cs,cM as ds,lz as us,b5 as hs,lA as fs,lB as ms,lC as ps,au as gs,lD as vs,lE as ys,lF as xs,lG as bs,g as ws,lH as ks,b4 as Ss,dZ as Ns}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-CtO-4MLb.js","./VegaLite-CgPaPGw8.js","./index-BxeSyCes.js","./index-DtS1iA00.css","./time-ChZPeUyP.js","./timer-CK-RIWfW.js","./linear-rhrSF5hY.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./zoom-COrs4lFh.js","./ordinal-DDUp3AbE.js","./colors-bszWmPJw.js","./arc-lt4NHaVr.js","./step-CNn2V7Th.js","./index-CVw6pZ7y.js","./terminal-BLKbWCsr.js","./terminal-DMtZkNnb.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o)(e,"symbol"!=typeof n?n+"":n,o);import{b0 as o,G as r,h9 as a,ha as i,hb as s,hc as l,hd as c,he as d,R as u,hf as h,hg as f,hh as m,hi as p,hj as g,hk as v,hl as y,hm as x,D as b,by as w,K as k,hn as S,at as N,W as C,a2 as E,Z as j,_,ho as I,X as A,e7 as T,hp as M,cU as O,dl as D,ei as P,ej as R,ek as L,em as z,eg as F,eh as B,el as U,hq as V,hr as H,dp as $,dt as W,al as G,F as q,hs as Y,eD as X,ht as K,ar as J,dX as Z,cd as Q,hu as ee,dr as te,hv as ne,hw as oe,a0 as re,hx as ae,dv as ie,hy as se,H as le,b9 as ce,hz as de,hA as ue,hB as he,di as fe,hC as me,dm as pe,hD as ge,hE as ve,hF as ye,cT as xe,hG as be,hH as we,bA as ke,hI as Se,hJ as Ne,bb as Ce,hK as Ee,hL as je,hM as _e,Y as Ie,bq as Ae,hN as Te,a6 as Me,dj as Oe,ff as De,eQ as Pe,fi as Re,b6 as Le,eR as ze,as as Fe,hO as Be,hP as Ue,hQ as Ve,eS as He,hR as $e,hS as We,eW as Ge,hT as qe,hU as Ye,hV as Xe,hW as Ke,d8 as Je,hX as Ze,bo as Qe,$ as et,ap as tt,a1 as nt,bE as ot,hY as rt,dW as at,hZ as it,c_ as st,dq as lt,eo as ct,h_ as dt,bz as ut,h$ as ht,de as ft,i0 as mt,i1 as pt,bu as gt,i2 as vt,i3 as yt,i4 as xt,i5 as bt,i6 as wt,i7 as kt,T as St,a3 as Nt,i8 as Ct,d9 as Et,bB as jt,eV as _t,cV as It,i9 as At,fj as Tt,ia as Mt,bj as Ot,bC as Dt,ib as Pt,ic as Rt,id as Lt,ie as zt,dn as Ft,be as Bt,bf as Ut,ig as Vt,dL as Ht,d6 as $t,ih as Wt,eC as Gt,k as qt,j as Yt,ii as Xt,ij as Kt,ik as Jt,ey as Zt,il as Qt,im as en,cZ as tn,io as nn,ip as on,a7 as rn,b1 as an,aj as sn,ba as ln,iq as cn,bt as dn,ir as un,fm as hn,fl as fn,is as mn,eG as pn,it as gn,iu as vn,eN as yn,iv as xn,ex as bn,iw as wn,ix as kn,iy as Sn,iz as Nn,iA as Cn,iB as En,m as jn,iC as _n,iD as In,iE as An,t as Tn,iF as Mn,iG as On,iH as Dn,iI as Pn,iJ as Rn,iK as Ln,iL as zn,iM as Fn,iN as Bn,iO as Un,iP as Vn,iQ as Hn,iR as $n,iS as Wn,iT as Gn,iU as qn,iV as Yn,iW as Xn,iX as Kn,iY as Jn,iZ as Zn,i_ as Qn,i$ as eo,j0 as to,j1 as no,j2 as oo,j3 as ro,j4 as ao,j5 as io,j6 as so,j7 as lo,j8 as co,j9 as uo,ja as ho,jb as fo,fn as mo,jc as po,jd as go,je as vo,jf as yo,jg as xo,jh as bo,ji as wo,jj as ko,jk as So,jl as No,jm as Co,jn as Eo,jo,jp as _o,dx as Io,jq as Ao,jr as To,dA as Mo,js as Oo,jt as Do,ju as Po,jv as Ro,jw as Lo,jx as zo,jy as Fo,a8 as Bo,df as Uo,jz as Vo,dE as Ho,jA as $o,jB as Wo,jC as Go,jD as qo,jE as Yo,jF as Xo,jG as Ko,jH as Jo,jI as Zo,jJ as Qo,a4 as er,jK as tr,jL as nr,dU as or,jM as rr,jN as ar,jO as ir,jP as sr,jQ as lr,jR as cr,jS as dr,jT as ur,jU as hr,jV as fr,jW as mr,jX as pr,jY as gr,jZ as vr,j_ as yr,fk as xr,j$ as br,k0 as wr,k1 as kr,bn as Sr,eL as Nr,k2 as Cr,k3 as Er,k4 as jr,k5 as _r,k6 as Ir,k7 as Ar,k8 as Tr,eA as Mr,k9 as Or,bi as Dr,ka as Pr,bT as Rr,b2 as Lr,ah as zr,dV as Fr,kb as Br,cR as Ur,b7 as Vr,kc as Hr,dO as $r,bY as Wr,kd as Gr,bp as qr,ke as Yr,kf as Xr,kg as Kr,kh as Jr,ki as Zr,kj as Qr,kk as ea,kl as ta,km as na,br as oa,bc as ra,kn as aa,ko as ia,dd as sa,kp as la,kq as ca,kr as da,ks as ua,kt as ha,cW as fa,es as ma,dh as pa,ku as ga,bm as va,kv as ya,e9 as xa,eZ as ba,e_ as wa,e$ as ka,f3 as Sa,f1 as Na,f4 as Ca,f6 as Ea,f9 as ja,fc as _a,f7 as Ia,kw as Aa,kx as Ta,dM as Ma,ky as Oa,e5 as Da,kz as Pa,fa as Ra,kA as La,kB as za,kC as Fa,kD as Ba,J as Ua,ds as Va,kE as Ha,kF as $a,kG as Wa,M as Ga,kH as qa,kI as Ya,O as Xa,kJ as Ka,dk as Ja,kK as Za,kL as Qa,P as ei,kM as ti,ew as ni,b8 as oi,kN as ri,kO as ai,kP as ii,fb as si,kQ as li,dT as ci,kR as di,kS as ui,dc as hi,kT as fi,kU as mi,kV as pi,kW as gi,er as vi,kX as yi,kY as xi,dw as bi,kZ as wi,k_ as ki,k$ as Si,l0 as Ni,l1 as Ci,l2 as Ei,l3 as ji,l4 as _i,l5 as Ii,l6 as Ai,l7 as Ti,l8 as Mi,l9 as Oi,la as Di,lb as Pi,d1 as Ri,lc as Li,ld as zi,le as Fi,lf as Bi,lg as Ui,aq as Vi,bv as Hi,lh as $i,li as Wi,lj as Gi,lk as qi,ll as Yi,lm as Xi,ln as Ki,lo as Ji,lp as Zi,lq as Qi,lr as es,ls as ts,lt as ns,eF as os,lu as rs,lv as as,lw as is,lx as ss,ly as ls,e4 as cs,cM as ds,lz as us,b5 as hs,lA as fs,lB as ms,lC as ps,au as gs,lD as vs,lE as ys,lF as xs,lG as bs,g as ws,lH as ks,b4 as Ss,dZ as Ns}from"./index-BxeSyCes.js";import{a as Cs,B as Es,G as js,g as _s,M as Is,b as As,c as Ts,d as Ms,s as Os,k as Ds,C as Ps,S as Rs,K as Ls,e as zs,f as Fs,i as Bs,h as Us,j as Vs,L as Hs,l as $s,m as Ws,n as Gs,u as qs,o as Ys,p as Xs,q as Ks,P as Js,r as Zs,t as Qs,T as el}from"./tree-DSXaKJeB.js";import{b as tl,c as nl,L as ol,I as rl,N as al,V as il,d as sl,W as ll,F as cl,e as dl,M as ul,E as hl,f as fl,g as ml,h as pl,i as gl,j as vl,k as yl,l as xl,m as bl,n as wl,o as kl,u as Sl,C as Nl,R as Cl,p as El,a as jl,A as _l,q as Il,r as Al,O as Tl,T as Ml}from"./useMarimoWebSocket-Q0rgYJeg.js";import{s as Ol,i as Dl,T as Pl,c as Rl}from"./transform-rsMiis9u.js";import{g as Ll}from"./timer-CK-RIWfW.js";import{i as zl}from"./zoom-COrs4lFh.js";import{s as Fl}from"./sortBy-DyNOE__7.js";import"./main-cdvIQCIX.js";import"./index-CVw6pZ7y.js";import"./_baseEach-Bqlmi48l.js";import"./_baseMap-C3qxL0qV.js";
|
|
3
3
|
/**
|
|
4
4
|
* @license lucide-react v0.428.0 - ISC
|
|
5
5
|
*
|
|
@@ -11,4 +11,4 @@ var e,t=Object.defineProperty,n=(e,n,o)=>((e,n,o)=>n in e?t(e,n,{enumerable:!0,c
|
|
|
11
11
|
*
|
|
12
12
|
* This source code is licensed under the ISC license.
|
|
13
13
|
* See the LICENSE file in the root directory of this source tree.
|
|
14
|
-
*/const nd=r.createContext({});function od(e,t){[e,t]=l(e,t,nd);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":o,orientation:l="horizontal"}=e;let[c,d]=r.useState(!1);a((()=>{var e;d(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:u}=i(),h="rtl"===u&&"horizontal"===l;let f=s(t);const m=r.useRef(null);return{toolbarProps:{role:c?"group":"toolbar","aria-orientation":l,"aria-label":n,"aria-labelledby":null==n?o:void 0,onKeyDownCapture:c?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===l&&"ArrowRight"===e.key||"vertical"===l&&"ArrowDown"===e.key)h?f.focusPrevious():f.focusNext();else{if(!("horizontal"===l&&"ArrowLeft"===e.key||"vertical"===l&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),m.current=document.activeElement,void(e.shiftKey?f.focusFirst():f.focusLast())):void 0;h?f.focusNext():f.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:c?void 0:e=>{var n,o;m.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(o=m.current)||void 0===o||o.focus(),m.current=null)},onBlurCapture:c?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||m.current||(m.current=e.target)}}}}(e,t),o=c({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),f=d(e);return delete f.id,u.createElement("div",{...h(n,f),...o,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},o.children)}const rd=r.forwardRef(od);function ad(e,t){const n=f(e),o=f(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function id(e){const t=f(e);return+function(e){const t=f(e);return t.setHours(23,59,59,999),t}(t)==+function(e){const t=f(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}(t)}function sd(e,t){const n=f(e),o=f(t),r=ad(n,o),a=Math.abs(function(e,t){const n=f(e),o=f(t);return 12*(n.getFullYear()-o.getFullYear())+(n.getMonth()-o.getMonth())}(n,o));let i;if(a<1)i=0;else{1===n.getMonth()&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let t=ad(n,o)===-r;id(f(e))&&1===a&&1===ad(e,o)&&(t=!1),i=r*(a-Number(t))}return 0===i?0:i}function ld(e,t,n){const o=function(e,t){return+f(e)-+f(t)}(e,t)/1e3;return(r=null==n?void 0:n.roundingMethod,e=>{const t=(r?Math[r]:Math.trunc)(e);return 0===t?0:t})(o);var r}function cd(e,t){return function(e,t,n){const o=x(),r=(null==n?void 0:n.locale)??o.locale??p,a=ad(e,t);if(isNaN(a))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:null==n?void 0:n.addSuffix,comparison:a});let s,l;a>0?(s=f(t),l=f(e)):(s=f(e),l=f(t));const c=ld(l,s),d=(g(l)-g(s))/1e3,u=Math.round((c-d)/60);let h;if(u<2)return(null==n?void 0:n.includeSeconds)?c<5?r.formatDistance("lessThanXSeconds",5,i):c<10?r.formatDistance("lessThanXSeconds",10,i):c<20?r.formatDistance("lessThanXSeconds",20,i):c<40?r.formatDistance("halfAMinute",0,i):c<60?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",1,i):0===u?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",u,i);if(u<45)return r.formatDistance("xMinutes",u,i);if(u<90)return r.formatDistance("aboutXHours",1,i);if(u<v){const e=Math.round(u/60);return r.formatDistance("aboutXHours",e,i)}if(u<2520)return r.formatDistance("xDays",1,i);if(u<y){const e=Math.round(u/v);return r.formatDistance("xDays",e,i)}if(u<2*y)return h=Math.round(u/y),r.formatDistance("aboutXMonths",h,i);if(h=sd(l,s),h<12){const e=Math.round(u/y);return r.formatDistance("xMonths",e,i)}{const e=h%12,t=Math.trunc(h/12);return e<3?r.formatDistance("aboutXYears",t,i):e<9?r.formatDistance("overXYears",t,i):r.formatDistance("almostXYears",t+1,i)}}(e,function(e){return m(e,Date.now())}(e),t)}const dd=e=>{const t=b(35);let n;t[0]!==e?(n=()=>{E(new Blob([e.getCellsAsJSON()],{type:"text/plain"}),`${e.proposedName}.json`)},t[0]=e,t[1]=n):n=t[1];const o=n;let r,a,i,s,l,c,d,u,h,f,m,p,g,v,y,x,w;return t[2]!==o||t[3]!==e?(r=t=>{t.preventDefault(),o(),e.closeModal()},t[2]=o,t[3]=e,t[4]=r):r=t[4],t[5]!==e?(a=t=>{"Escape"===t.key&&e.closeModal()},t[5]=e,t[6]=a):a=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(j,{className:"text-accent mb-6",children:"Download unsaved changes?"}),t[7]=i):i=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(s={wordBreak:"break-word"},l=k.jsx("p",{children:"This app has unsaved changes. To recover:"}),c={paddingBottom:"10px"},t[8]=s,t[9]=l,t[10]=c):(s=t[8],l=t[9],c=t[10]),t[11]!==e.proposedName?(d=k.jsxs("li",{style:c,children:['Click the "Download" button. This will download a file called ',k.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[11]=e.proposedName,t[12]=d):d=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(u={paddingBottom:"10px"},t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h={display:"block",padding:"10px"},t[14]=h):h=t[14],t[15]!==e.proposedName?(f=k.jsxs("code",{style:h,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=f):f=t[16],t[17]!==e.proposedName?(m=k.jsxs("code",{children:[e.proposedName,".py"]}),t[17]=e.proposedName,t[18]=m):m=t[18],t[19]!==f||t[20]!==m?(p=k.jsxs("li",{style:u,children:["In your terminal, type",f,"to overwrite ",m," with the recovered changes."]}),t[19]=f,t[20]=m,t[21]=p):p=t[21],t[22]!==d||t[23]!==p?(g=k.jsxs(_,{className:"markdown break-words",style:s,children:[l,k.jsxs("ol",{children:[d,p]})]}),t[22]=d,t[23]=p,t[24]=g):g=t[24],t[25]!==e.closeModal?(v=k.jsx(C,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[25]=e.closeModal,t[26]=v):v=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(y=k.jsx(C,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[27]=y):y=t[27],t[28]!==v?(x=k.jsxs(I,{children:[v,y]}),t[28]=v,t[29]=x):x=t[29],t[30]!==r||t[31]!==a||t[32]!==g||t[33]!==x?(w=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:r,onKeyDown:a,children:[i,g,x]})}),t[30]=r,t[31]=a,t[32]=g,t[33]=x,t[34]=w):w=t[34],w},ud=e=>{const t=b(13),{filename:n,needsSave:o,getCellsAsJSON:r}=e,{openModal:a,closeModal:i}=w();let s;t[0]!==n?(s=null===n?"app":n.slice(0,-3),t[0]=n,t[1]=s):s=t[1];const l=s;let c;t[2]!==o||t[3]!==a||t[4]!==r||t[5]!==l||t[6]!==i?(c=()=>{o&&a(k.jsx(dd,{getCellsAsJSON:r,proposedName:l,closeModal:i}))},t[2]=o,t[3]=a,t[4]=r,t[5]=l,t[6]=i,t[7]=c):c=t[7];const d=c;let u;Cs("global.save",d),t[8]===Symbol.for("react.memo_cache_sentinel")?(u=S("global.save"),t[8]=u):u=t[8];const h=o?"yellow":"gray";let f,m;return t[9]===Symbol.for("react.memo_cache_sentinel")?(f=k.jsx(Pc,{strokeWidth:1.5,size:18}),t[9]=f):f=t[9],t[10]!==d||t[11]!==h?(m=k.jsx(N,{content:u,children:k.jsx(Es,{onClick:d,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:f})}),t[10]=d,t[11]=h,t[12]=m):m=t[12],m},hd=()=>{const e=b(7),{selectedLayout:t}=tl(),{setLayoutView:n}=nl();if(D()&&!_s("wasm_layouts"))return null;let o,r,a,i;return e[0]!==n?(o=e=>n(e),e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(F,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:k.jsx(B,{placeholder:"Select a view"})}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(P,{children:k.jsxs(R,{children:[k.jsx(L,{children:"View as"}),ol.map(gd)]})}),e[3]=a):a=e[3],e[4]!==t||e[5]!==o?(i=k.jsxs(U,{"data-testid":"layout-select",value:t,onValueChange:o,children:[r,a]}),e[4]=t,e[5]=o,e[6]=i):i=e[6],i};function fd(e){const t=md(e);return k.jsx(t,{className:"h-4 w-4"})}function md(e){switch(e){case"vertical":return yc;case"grid":return js;case"slides":return Tc;default:return T(e),M}}function pd(e){return O(e)}function gd(e){return k.jsx(z,{value:e,children:k.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[fd(e),k.jsx("span",{children:pd(e)})]})},e)}function vd(){const e=b(7);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[n,o]=function(e,t){const n=b(10);let o;n[0]!==e||n[1]!==t?(o=new V(e,t),n[0]=e,n[1]=t,n[2]=o):o=n[2];const a=o;let i;n[3]!==a?(i=()=>a.get(),n[3]=a,n[4]=i):i=n[4];const[s,l]=r.useState(i);let c;n[5]!==a?(c=e=>{l(e),a.set(e)},n[5]=a,n[6]=c):c=n[6];const d=c;let u;return n[7]!==s||n[8]!==d?(u=[s,d],n[7]=s,n[8]=d,n[9]=u):u=n[9],u}("marimo:commands",t);let a,i;return e[1]!==n||e[2]!==o?(a=e=>{const t=(r=[e,...n],[...new Set(r)]);var r;o(t.slice(0,3))},e[1]=n,e[2]=o,e[3]=a):a=e[3],e[4]!==n||e[5]!==a?(i={recentCommands:n,addRecentCommand:a},e[4]=n,e[5]=a,e[6]=i):i=e[6],i}function yd(e){return void 0!==e.dropdown}function xd(e,t=""){return e.flatMap((e=>e.label?yd(e)?xd(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const bd=e=>{const t=b(8),{children:n,layerTop:o}=e,r=void 0!==o&&o;let a;t[0]!==n?(a=u.Children.toArray(n),t[0]=n,t[1]=a):a=t[1];const[i,s]=a,l=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let c,d;return t[2]!==l||t[3]!==s?(c=k.jsx("div",{className:l,children:s}),t[2]=l,t[3]=s,t[4]=c):c=t[4],t[5]!==i||t[6]!==c?(d=k.jsxs("div",{className:"multi-icon relative w-fit",children:[i,c]}),t[5]=i,t[6]=c,t[7]=d):d=t[7],d};function wd(){const e=b(3),t=W(),{prepareForRun:n}=q();let o;e[0]!==t||e[1]!==n?(o=async e=>{if(0===e.length)return;const{cellHandles:o,cellData:r}=t,a=[];for(const t of e){const e=o[t];e.current?(a.push(X(e.current.editorView)),e.current.registerRun()):(n({cellId:t}),a.push(r[t].code))}await K({cellIds:e,codes:a}).catch((e=>{J.error(e)}))},e[0]=t,e[1]=n,e[2]=o):o=e[2];return G(o)}const kd=Z(null),Sd=Z(!1),Nd=Z({chats:[],activeChatId:null}),Cd=Z((e=>{const t=e(Nd);return t.chats.find((e=>e.id===t.activeChatId))}),((e,t,n)=>{t(Nd,(e=>({...e,activeChatId:n})))})),Ed=e=>{const t=b(7);let n,o;t[0]!==e.onClick?(n=t=>{var n;(t.ctrlKey||t.metaKey)&&"z"===t.key&&(t.preventDefault(),t.stopPropagation(),null==(n=e.onClick)||n.call(e,t))},t[0]=e.onClick,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o={capture:!0},t[2]=o):o=t[2],Q(window,"keydown",n,o);const r=e.children??"Undo";let a,i;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(ee,{className:"ml-2",shortcut:"cmd-z"}),t[3]=a):a=t[3],t[4]!==e||t[5]!==r?(i=k.jsxs(C,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[r," ",a]}),t[4]=e,t[5]=r,t[6]=i):i=t[6],i};function jd(){const e=b(3),{deleteCell:t,undoDeleteCell:n}=q();let o;return e[0]!==t||e[1]!==n?(o=e=>{if(te.get(ne))return;const{cellId:o}=e;t({cellId:o}),oe({cellId:o}).catch((()=>{n()}));const{dismiss:r}=re({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:k.jsx(Ed,{"data-testid":"undo-delete-button",onClick:()=>{n(),a()}})}),a=r},e[0]=t,e[1]=n,e[2]=o):o=e[2],G(o)}function _d(e,t,n,o=te){if(t in o.get(ae))return!1;const{cellData:r,cellIds:a}=o.get(ie),i=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const s of a.inOrderIds)if(i.test(r[s].code))return!1;return n(`import ${e} as ${t}`),!0}function Id(e,t,n){return _d("marimo","mo",(o=>{const r=se.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&K({cellIds:[r],codes:[o]})}))}function Ad(e){const t=b(52),{cell:n}=e,{createNewCell:o,updateCellConfig:r,updateCellCode:a,updateCellName:i,moveCell:s,sendToTop:l,sendToBottom:c,addColumnBreakpoint:d,clearCellOutput:u}=q(),h=function(e){const t=b(3),n=wd();let o;return t[0]!==e||t[1]!==n?(o=()=>{void 0!==e&&n([e])},t[0]=e,t[1]=n,t[2]=o):o=t[2],G(o)}(null==n?void 0:n.cellId),f=!le(ne),m=jd(),{openModal:p}=w(),g=ce(kd),v=le(de),y=le(ue),x=he(),S=le(fe),N=le(me);if(!n||S){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],e}const{cellId:C,config:E,getEditorView:_,name:I,hasOutput:T,status:M}=n;let O;t[1]!==x.inOrderIds||t[2]!==C?(O=x.inOrderIds.indexOf(C),t[1]=x.inOrderIds,t[2]=C,t[3]=O):O=t[3];const D=O;let P;t[4]!==E.disabled||t[5]!==C||t[6]!==r?(P=async()=>{const e={disabled:!E.disabled};await _e({configs:{[C]:e}}),r({cellId:C,config:e})},t[4]=E.disabled,t[5]=C,t[6]=r,t[7]=P):P=t[7];const R=P;let L;t[8]!==E.hide_code||t[9]!==C||t[10]!==r||t[11]!==_?(L=async()=>{const e={hide_code:!E.hide_code};await _e({configs:{[C]:e}}),r({cellId:C,config:e});const t=_();t&&(e.hide_code?t.contentDOM.blur():t.focus())},t[8]=E.hide_code,t[9]=C,t[10]=r,t[11]=_,t[12]=L):L=t[12];const z=L;let F,B;t[13]===Symbol.for("react.memo_cache_sentinel")?(F=k.jsx(Yc,{size:13,strokeWidth:1.5}),t[13]=F):F=t[13],t[14]!==p||t[15]!==D||t[16]!==I||t[17]!==i||t[18]!==C?(B=()=>{p(k.jsxs(A,{children:[k.jsx(Ie,{children:k.jsx(j,{children:"Rename cell"})}),k.jsxs("div",{className:"flex items-center justify-between",children:[k.jsx(Ae,{htmlFor:"cell-name",children:"Cell name"}),k.jsx(al,{placeholder:`cell_${D}`,value:I,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),p(null))},onChange:e=>i({cellId:C,name:e})})]})]}))},t[14]=p,t[15]=D,t[16]=I,t[17]=i,t[18]=C,t[19]=B):B=t[19];const U=`cell_${D}`;let V,W,Y;if(t[20]!==i||t[21]!==C?(V=e=>i({cellId:C,name:e}),t[20]=i,t[21]=C,t[22]=V):V=t[22],t[23]!==U||t[24]!==I||t[25]!==V?(W=k.jsx(al,{placeholder:U,value:I,onChange:V}),t[23]=U,t[24]=I,t[25]=V,t[26]=W):W=t[26],t[27]!==B||t[28]!==W||t[29]!==M||t[30]!==E.disabled||t[31]!==E.hide_code||t[32]!==h||t[33]!==v||t[34]!==g||t[35]!==C||t[36]!==T||t[37]!==_||t[38]!==a||t[39]!==z||t[40]!==R||t[41]!==u||t[42]!==y||t[43]!==o||t[44]!==s||t[45]!==l||t[46]!==c||t[47]!==N||t[48]!==d||t[49]!==f||t[50]!==m){Y=[[{icon:F,label:"Name",disableClick:!0,handle:Dd,handleHeadless:B,rightElement:W},{icon:k.jsx(Ac,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===M||"queued"===M||"disabled-transitively"===M||E.disabled,handle:()=>h()},{icon:k.jsx(Fc,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!v,handle:()=>{g((e=>(null==e?void 0:e.cellId)===C?null:{cellId:C}))},hotkey:"cell.aiCompletion"},{icon:k.jsx(rl,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!T,handle:()=>function(e){const t=document.getElementById(H.create(e));t&&(t.classList.add("printing-output"),$(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(C)},{icon:k.jsx(pe,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const e=_();e&&ge({[C]:e},a)}},{icon:E.hide_code?k.jsx(ve,{size:13,strokeWidth:1.5}):k.jsx(ye,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:z,hotkey:"cell.hideCode"},{icon:E.disabled?k.jsx(ed,{size:13,strokeWidth:1.5}):k.jsx(td,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:k.jsx(xe,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:R}),handle:R},{icon:k.jsx(be,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!T,handle:()=>{u({cellId:C})}}],[{icon:k.jsx(Is,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const e=_();e&&(Id(y,o),we(e,"markdown",{keepCodeAsIs:!0}))}},{icon:k.jsx(ke,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const e=_();e&&(Id(y,o),we(e,"sql",{keepCodeAsIs:!0}))}},{icon:k.jsx(As,{}),label:"Toggle as Python",handle:()=>{const e=_();e&&(Id(y,o),Se(e,"python",{force:!0}))}}],[{icon:k.jsxs(bd,{children:[k.jsx(Jl,{size:13,strokeWidth:1.5}),k.jsx(Ne,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>o({cellId:C,before:!0})},{icon:k.jsxs(bd,{children:[k.jsx(Jl,{size:13,strokeWidth:1.5}),k.jsx(Ce,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>o({cellId:C,before:!1})},{icon:k.jsx(Ne,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>s({cellId:C,before:!0})},{icon:k.jsx(Ce,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>s({cellId:C,before:!1})},{icon:k.jsx(Xl,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>l({cellId:C})},{icon:k.jsx(Yl,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>c({cellId:C})},{icon:k.jsx(Ee,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==N,handle:()=>d({cellId:C})}],[{label:"Delete",hidden:!f,variant:"danger",icon:k.jsx(je,{size:13,strokeWidth:1.5}),handle:()=>{m({cellId:C})}}]].map(Md).filter(Td),t[27]=B,t[28]=W,t[29]=M,t[30]=E.disabled,t[31]=E.hide_code,t[32]=h,t[33]=v,t[34]=g,t[35]=C,t[36]=T,t[37]=_,t[38]=a,t[39]=z,t[40]=R,t[41]=u,t[42]=y,t[43]=o,t[44]=s,t[45]=l,t[46]=c,t[47]=N,t[48]=d,t[49]=f,t[50]=m,t[51]=Y}else Y=t[51];return Y}function Td(e){return e.length>0}function Md(e){return e.filter(Od)}function Od(e){return!e.hidden}function Dd(e){null==e||e.stopPropagation(),null==e||e.preventDefault()}const Pd=Z(null);function Rd(){return le(Pd)}const Ld=Z((e=>{const t=e(Pd);return t?t===Te?null:zd(t,e(ie)):null}));function zd(e,t){var n;const{cellData:o,cellHandles:r,cellRuntime:a}=t,i=o[e],s=a[e],l=null==(n=r[e])?void 0:n.current;if(!i||!l)return null;return{cellId:e,name:i.name,config:i.config,status:s?s.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==s?void 0:s.output)}}function Fd(e){return!e.hidden}const Bd=Z(!1),Ud=()=>{const e=b(32),[t,n]=Le(Bd),o=Ms(),r=le(Ld),a=le(ze);let i;e[0]!==r?(i={cell:r},e[0]=r,e[1]=i):i=e[1];let s=Ad(i).flat();s=xd(s);const l=function(){const e=b(46),{theme:t}=Me(),[n,o]=Oe(),[r,a]=De();let i;e[0]!==o?(i=async e=>{await Pe({config:e}).then((()=>{o(e)}))},e[0]=o,e[1]=i):i=e[1];const s=i;let l;e[2]!==a?(l=async e=>{await Re({config:e}).then((()=>{a(e)}))},e[2]=a,e[3]=l):l=e[3];const c=l;let d,u;if(e[4]!==r||e[5]!==c){let t;e[7]!==r.width?(t=e=>e!==r.width,e[7]=r.width,e[8]=t):t=e[8],d=Ts().filter(t).map((e=>({label:`App config > Set width=${e}`,handle:()=>{c({...r,width:e})}}))),e[4]=r,e[5]=c,e[6]=d}else d=e[6];e[9]!==s||e[10]!==n||e[11]!==t?(u={label:"Config > Toggle dark mode",handle:()=>{s({...n,display:{...n.display,theme:"dark"===t?"light":"dark"}})}},e[9]=s,e[10]=n,e[11]=t,e[12]=u):u=e[12];const h="vim"===n.keymap.preset;let f,m;e[13]!==s||e[14]!==n?(f=()=>{s({...n,keymap:{...n.keymap,preset:"vim"}})},e[13]=s,e[14]=n,e[15]=f):f=e[15],e[16]!==h||e[17]!==f?(m={label:"Config > Switch keymap to VIM",hidden:h,handle:f},e[16]=h,e[17]=f,e[18]=m):m=e[18];const p="default"===n.keymap.preset;let g,v,y;e[19]!==s||e[20]!==n?(g=()=>{s({...n,keymap:{...n.keymap,preset:"default"}})},e[19]=s,e[20]=n,e[21]=g):g=e[21],e[22]!==p||e[23]!==g?(v={label:"Config > Switch keymap to default (current: VIM)",hidden:p,handle:g},e[22]=p,e[23]=g,e[24]=v):v=e[24],e[25]!==s||e[26]!==n?(y=()=>{s({...n,completion:{...n.completion,copilot:!1}})},e[25]=s,e[26]=n,e[27]=y):y=e[27];const x="github"!==n.completion.copilot;let w,k;e[28]!==y||e[29]!==x?(w={label:"Config > Disable GitHub Copilot",handle:y,hidden:x},e[28]=y,e[29]=x,e[30]=w):w=e[30],e[31]!==s||e[32]!==n?(k=()=>{s({...n,completion:{...n.completion,copilot:"github"}})},e[31]=s,e[32]=n,e[33]=k):k=e[33];const S="github"===n.completion.copilot;let N,C;e[34]!==k||e[35]!==S?(N={label:"Config > Enable GitHub Copilot",handle:k,hidden:S},e[34]=k,e[35]=S,e[36]=N):N=e[36],e[37]!==d||e[38]!==u||e[39]!==m||e[40]!==v||e[41]!==w||e[42]!==N?(C=[...d,u,m,v,w,N],e[37]=d,e[38]=u,e[39]=m,e[40]=v,e[41]=w,e[42]=N,e[43]=C):C=e[43];const E=C;let j;return e[44]!==E?(j=E.filter(Fd),e[44]=E,e[45]=j):j=e[45],j}();let c=ru();c=[...xd(c),...xd(l)];const d=c.filter(Vd),u=Fe.keyBy(d,Hd),{recentCommands:h,addRecentCommand:f}=vd(),m=new Set(h);let p,g;e[2]!==a||e[3]!==n?(p=e=>{He(a.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),n((e=>!e)))},e[2]=a,e[3]=n,e[4]=p):p=e[4],Q(document,"keydown",p),e[5]!==o||e[6]!==a||e[7]!==f||e[8]!==n?(g=(e,t)=>{const r=o[e];if(!r)return null;const i=a.getHotkey(e);return k.jsxs($e,{disabled:t.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{r()}))},value:i.name,children:[k.jsxs("span",{children:[i.name,t.tooltip&&k.jsx("span",{className:"ml-2",children:t.tooltip})]}),k.jsx(We,{children:k.jsx(Ge,{shortcut:i.key})})]},e)},e[5]=o,e[6]=a,e[7]=f,e[8]=n,e[9]=g):g=e[9];const v=g;let y;e[10]!==f||e[11]!==n||e[12]!==a?(y=(e,t,o,r)=>{const i=void 0===o?{}:o;return k.jsxs($e,{disabled:i.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{t()}))},value:e,children:[k.jsxs("span",{children:[e,i.tooltip&&k.jsxs("span",{className:"ml-2",children:["(",i.tooltip,")"]})]}),r&&k.jsx(We,{children:k.jsx(Ge,{shortcut:a.getHotkey(r).key})})]},e)},e[10]=f,e[11]=n,e[12]=a,e[13]=y):y=e[13];const x=y,w=qe;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Ye,{placeholder:"Type to search..."}),e[14]=S):S=e[14];const N=Xe;let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=k.jsx(Ke,{children:"No results found."}),e[15]=C):C=e[15];const E=h.length>0&&k.jsxs(k.Fragment,{children:[k.jsx(Be,{heading:"Recently Used",children:h.map((e=>{const t=u[e];return Ue(e)?v(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!yd(t)?x(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),k.jsx(Ve,{})]}),j=Be,_=a.iterate().map((e=>{if(m.has(e))return null;const t=u[e];return v(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),I=d.map((e=>m.has(e.label)?null:x(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}))),A=s.map((e=>m.has(e.label)?null:x(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})));let T,M,O;return e[16]!==j||e[17]!==_||e[18]!==I||e[19]!==A?(T=k.jsxs(j,{heading:"Commands",children:[_,I,A]}),e[16]=j,e[17]=_,e[18]=I,e[19]=A,e[20]=T):T=e[20],e[21]!==N||e[22]!==C||e[23]!==E||e[24]!==T?(M=k.jsxs(N,{children:[C,E,T]}),e[21]=N,e[22]=C,e[23]=E,e[24]=T,e[25]=M):M=e[25],e[26]!==w||e[27]!==t||e[28]!==n||e[29]!==S||e[30]!==M?(O=k.jsxs(w,{open:t,onOpenChange:n,children:[S,M]}),e[26]=w,e[27]=t,e[28]=n,e[29]=S,e[30]=M,e[31]=O):O=e[31],O};function Vd(e){return!e.hotkey}function Hd(e){return e.label}const $d="https://static.marimo.app",Wd=({onClose:e})=>{const[t,n]=r.useState(""),o=`${t}-${r.useRef(Math.random().toString(36).slice(2,6)).current}`,a=`${$d}/static/${o}`;return k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:async t=>{t.preventDefault(),e();const n=await Je({download:!1,includeCode:!0,files:il.INSTANCE.filenames()}),r=re({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${$d}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:n,path:o})}).catch((()=>{r.dismiss(),re({title:"Error uploading static page",description:k.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",k.jsx("a",{href:Ze.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),re({title:"Static page uploaded!",description:k.jsxs("div",{children:["The URL has been copied to your clipboard.",k.jsx("br",{}),"You can share it with anyone."]})})},children:[k.jsxs(Ie,{children:[k.jsx(j,{children:"Share static notebook"}),k.jsxs(_,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",k.jsx("a",{href:$d,target:"_blank",rel:"noreferrer",children:$d}),"."]})]}),k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[k.jsx(Qe,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:t,placeholder:"Notebook slug",onChange:e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");n(t)},required:!0,autoComplete:"off"}),k.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx(Gd,{text:a}),k.jsx("span",{className:"text-primary",children:a})]})]})]}),k.jsxs(I,{children:[k.jsx(C,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:e,children:"Cancel"}),k.jsx(C,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await et(a)},children:"Create"})]})]})})},Gd=e=>{const t=b(8),[n,o]=u.useState(!1);let r;t[0]!==e.text?(r=tt.stopPropagation((async t=>{t.preventDefault(),await et(e.text),o(!0),setTimeout((()=>o(!1)),2e3)})),t[0]=e.text,t[1]=r):r=t[1];const a=r;let i,s,l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(nt,{size:14,strokeWidth:1.5}),t[2]=i):i=t[2],t[3]!==a?(s=k.jsx(C,{"data-testid":"copy-static-notebook-url-button",onClick:a,size:"xs",variant:"secondary",children:i}),t[3]=a,t[4]=s):s=t[4],t[5]!==n||t[6]!==s?(l=k.jsx(N,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=l):l=t[7],l};function qd(){const e=b(3),{openConfirm:t}=w(),n=ce(sl);let o;return e[0]!==t||e[1]!==n?(o=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:k.jsx(ot,{onClick:async()=>{n({state:ll.CLOSING}),await rt(),at()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=n,e[2]=o):o=e[2],o}const Yd=new it("marimo:sidebar",st.object({selectedPanel:st.string().optional().transform((e=>e)),isSidebarOpen:st.boolean(),isTerminalOpen:st.boolean()}),(function(){return{selectedPanel:"variables",isSidebarOpen:!1,isTerminalOpen:!1}}));const{reducer:Xd,createActions:Kd,valueAtom:Jd,useActions:Zd}=lt((()=>Yd.get()),{openApplication:(e,t)=>({...e,selectedPanel:t,isSidebarOpen:!e.isSidebarOpen||e.selectedPanel!==t}),toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,t)=>({...e,isSidebarOpen:t}),toggleTerminal:e=>({...e,isTerminalOpen:!e.isTerminalOpen}),setIsTerminalOpen:(e,t)=>({...e,isTerminalOpen:t})},[(e,t)=>Yd.set(t)]),Qd=()=>{const e=b(2),t=le(Jd);if(t.isSidebarOpen)return t;let n;return e[0]!==t?(n={...t,selectedPanel:void 0},e[0]=t,e[1]=n):n=e[1],n};function eu(){return Zd()}const tu=[{type:"files",Icon:dc,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:ct,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:ke,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:kc,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:ql,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Lc,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:dt,tooltip:"Chat with AI",position:"sidebar",hidden:!_s("chat_sidebar")},{type:"documentation",Icon:Xc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:ut,tooltip:"Notebook logs",position:"sidebar"},{type:"snippets",Icon:Uc,tooltip:"Snippets",position:"sidebar"},{type:"scratchpad",Icon:Sc,hidden:!_s("scratchpad"),tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:be,tooltip:"View errors",position:"footer"}];function nu(){const e=b(2),t=ce(ht);let n;e[0]!==t?(n=()=>{const e=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let o;o=null;for(const t of Array.from(e)){const e=t.getBoundingClientRect();if(e.top>=0&&e.top<=n||e.bottom>=0&&e.bottom<=n){o=ft.parse(t.parentNode.id);break}}t((e=>({mode:mt(e.mode),cellAnchor:o}))),requestAnimationFrame((()=>{var e;null!==o&&(null==(e=document.getElementById(ft.create(o)))||e.scrollIntoView())}))},e[0]=t,e[1]=n):n=e[1];return n}const ou=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function ru(){const[e]=yt(),{openModal:t,closeModal:n}=w(),{openApplication:o}=eu(),{selectedPanel:r}=Qd(),[a]=Le(ht),i=le(fe),s=W(),{updateCellConfig:l,undoDeleteCell:c,clearAllCellOutputs:d}=q(),u=qd(),h=function(e){const t=b(4),{openPrompt:n,closeModal:o}=w();let r;return t[0]!==e||t[1]!==n||t[2]!==o?(r=()=>{if(!e)return null;const t=pt.guessDeliminator(e),r=gt.basename(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${r}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{const r=t.join(gt.dirname(e),n);vt({source:e,destination:r}).then((()=>{o(),re({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${r}`,"_blank")}))}})},t[0]=e,t[1]=n,t[2]=o,t[3]=r):r=t[3],r}(e),f=ce(Bd),m=ce(Os),p=ce(Ds),g=xt(s),v=bt(s),{selectedLayout:y}=tl(),{setLayoutView:x}=nl(),N=nu();return[{icon:k.jsx(zc,{size:14,strokeWidth:1.5}),label:"Share",handle:ou,dropdown:[{icon:k.jsx(wt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",handle:async()=>{t(k.jsx(Wd,{onClose:n}))}},{icon:k.jsx(vc,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:async()=>{const e=await kt(),t=St({code:e.contents});await et(t),re({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:k.jsx(Nt,{size:14,strokeWidth:1.5}),label:"Download",handle:ou,dropdown:[{icon:k.jsx(cl,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await dl({filename:e,includeCode:!0}):re({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:k.jsx(cl,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await dl({filename:e,includeCode:!1}):re({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:k.jsx(Is,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const e=await Ct({download:!1});E(new Blob([e],{type:"text/plain"}),Et.toMarkdown(document.title))}},{icon:k.jsx(tc,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const e=await kt();E(new Blob([e.contents],{type:"text/plain"}),Et.toPY(document.title))}},{divider:!0,icon:k.jsx(rl,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:k.jsxs("span",{children:["Only available in app view. ",k.jsx("br",{}),"Toggle with: ",S("global.hideCode",!1)]}),handle:async()=>{const e=document.getElementById("App");e&&await $(e,document.title)}},{icon:k.jsx(jt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:k.jsxs("span",{children:["Only available in app view. ",k.jsx("br",{}),"Toggle with: ",S("global.hideCode",!1)]}),handle:async()=>{const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout((()=>window.print()),0),setTimeout((()=>window.dispatchEvent(t)),0)}}]},{divider:!0,icon:k.jsx(jc,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:ou,dropdown:tu.flatMap((({type:e,Icon:t,hidden:n})=>{return n?[]:{label:O(e),rightElement:(a=r===e,k.jsx("div",{className:"w-8 flex justify-end",children:a&&k.jsx(It,{size:14})})),icon:k.jsx(t,{size:14,strokeWidth:1.5}),handle:()=>o(e)};var a}))},{icon:k.jsx(Tc,{size:14,strokeWidth:1.5}),label:"Present as",handle:ou,dropdown:[{icon:"present"===a.mode?k.jsx(_t,{size:14,strokeWidth:1.5}):k.jsx(gc,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{N()}},...ol.map(((e,t)=>{const n=md(e);return{divider:0===t,label:pd(e),icon:k.jsx(n,{size:14,strokeWidth:1.5}),rightElement:k.jsx("div",{className:"w-8 flex justify-end",children:y===e&&k.jsx(It,{size:14})}),handle:()=>{x(e),"edit"===a.mode&&N()}}}))]},{icon:k.jsx(lc,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||D(),handle:h},{icon:k.jsx(Zl,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const e=await kt();await et(e.contents),re({title:"Copied",description:"Code copied to clipboard."})}},{icon:k.jsx(td,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:0===g.length||i,handle:async()=>{const e=g.map((e=>e.id)),t=Fe.fromEntries(e.map((e=>[e,{disabled:!1}])));await _e({configs:t});for(const n of e)l({cellId:n,config:{disabled:!1}})}},{icon:k.jsx(ed,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:0===v.length||i,handle:async()=>{const e=v.map((e=>e.id)),t=Fe.fromEntries(e.map((e=>[e,{disabled:!0}])));await _e({configs:t});for(const n of e)l({cellId:n,config:{disabled:!0}})}},{icon:k.jsx(be,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{d()}},{icon:k.jsx(Kc,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!At(s)||i,handle:()=>{c()}},{divider:!0,icon:k.jsx(nc,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>f((e=>!e))},{icon:k.jsx(Tt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>m((e=>!e))},{icon:k.jsx(pc,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>p((e=>!e))},{icon:k.jsx(Gl,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:()=>{window.open("https://docs.marimo.io","_blank")}},{divider:!0,icon:k.jsx(mc,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:()=>{window.location.href=document.baseURI}},{icon:k.jsx(Gc,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:u}].filter((e=>!e.hidden))}const au=()=>{const e=b(10),t=ru();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Es,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:k.jsx(ul,{strokeWidth:1.8})}),e[0]=n):n=e[0];const o=n,r=iu;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{const t=k.jsx(Ot,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:r(e)},e.label);return e.tooltip?k.jsx(N,{content:e.tooltip,side:"left",delayDuration:100,children:k.jsx("span",{children:t})},e.label):t},e[1]=a):a=e[1];const i=a;let s,l,c,d,h;if(e[2]===Symbol.for("react.memo_cache_sentinel")?(s=k.jsx(Dt,{asChild:!0,children:o}),e[2]=s):s=e[2],e[3]!==t){let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=e=>e.hidden?null:e.dropdown?k.jsxs(Pt,{children:[k.jsx(Rt,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:r(e)}),k.jsx(Lt,{children:k.jsx(zt,{children:e.dropdown.map((e=>k.jsxs(u.Fragment,{children:[e.divider&&k.jsx(Ft,{}),i(e)]},e.label)))})})]},e.label):k.jsxs(u.Fragment,{children:[e.divider&&k.jsx(Ft,{}),i(e)]},e.label),e[5]=n):n=e[5],l=t.map(n),e[3]=t,e[4]=l}else l=e[4];return e[6]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Ft,{}),e[6]=c):c=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:k.jsxs("span",{children:["Version: ",Mt()]})}),e[7]=d):d=e[7],e[8]!==l?(h=k.jsxs(Bt,{modal:!1,children:[s,k.jsxs(Ut,{align:"end",className:"no-print w-[240px]",children:[l,c,d]})]}),e[8]=l,e[9]=h):h=e[9],h};function iu(e){return k.jsxs(k.Fragment,{children:[e.icon&&k.jsx("span",{className:"flex-0 mr-2",children:e.icon}),k.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&k.jsx(Vt,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]})}const su=Ht({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},((e,t)=>{if(void 0===t)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}));function lu(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some((e=>e instanceof HTMLElement&&e.childNodes.length>0)))return!1;if(e){const t=e.state.selection.main,n=e.state.sliceDoc(t.from,t.to);n?(te.set(su,{type:"setFind",find:n}),te.set(su,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):te.set(su,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return te.get(su).isOpen?(te.set(su,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{te.set(su,{type:"setIsOpen",isOpen:!0})})),!0):(te.set(su,{type:"setIsOpen",isOpen:!0}),!0)}function cu(){return!!te.get(su).isOpen&&(te.set(su,{type:"setIsOpen",isOpen:!1}),!0)}function du(e){return $t("create"in e,'Expected query to have a "create" method'),e}function uu(e){return()=>{const t=te.get(su),n=new Wt({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:du(n).create(),search:n})}}const hu=e=>uu((({query:t})=>{const n=Gt(),o=te.get(su).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;"prev"===e&&(n.reverse(),r=o.range.from);let a=n.indexOf(o.view);a<0&&(a=0);const i=[...n,...n].slice(a);for(const s of i){const n="next"===e?t.nextMatch(s.state,0,r??0):t.prevMatch(s.state,r??s.state.doc.length,s.state.doc.length);if(!n){r=null,s.dispatch({selection:qt.single(0)});continue}const o=qt.single(n.from,n.to);return s.dispatch({selection:o,effects:[Yt.scrollIntoView(o.main,{y:"center"})],userEvent:"select.search"}),te.set(su,{type:"setCurrentView",view:s,range:{from:n.from,to:n.to}}),n}return!1})),fu=hu("next"),mu=hu("prev"),pu=uu((({query:e})=>{var t;const n=Gt(),o=[];for(const r of n){if(r.state.readOnly)continue;const n=null==(t=e.matchAll(r.state,1e9))?void 0:t.map((t=>{const{from:n,to:o}=t;return{from:n,to:o,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const a=r.state.doc.toString();o.push((()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})})),r.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of o)e()}})),gu=uu((({query:e})=>{const t=Gt(),n=te.get(su).currentView||{view:t[0],range:{from:0,to:0}};let o=n.range.from,r=t.indexOf(n.view);r<0&&(r=0);const a=[...t,...t].slice(r);for(const i of a){const t=e.nextMatch(i.state,0,o??0);if(!t){o=null,i.dispatch({selection:qt.single(0)});continue}const n=i.state.toText(e.getReplacement(t));return i.dispatch({changes:[{from:t.from,to:t.to,insert:n}],userEvent:"input.replace"}),fu()}return!1})),vu=uu((({query:e})=>{const t=Gt();let n=0;const o=new Map;for(const r of t){const t=e.matchAll(r.state,1e9)||[];for(const e of t){const{from:t,to:a}=e,i=o.get(r)||new Map;i.set(`${t}:${a}`,n++),o.set(r,i)}}return{count:n,position:o}})),yu=Xt.define();function xu(){const e=Gt();for(const t of e)t.state.readOnly||t.dispatch({effects:yu.of(new Wt({search:""}))})}const bu=Kt.define({create(){const e=te.get(su);return du(new Wt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord})).create()},update(e,t){for(const n of t.effects)n.is(yu)&&(e=du(n.value).create());return e}}),wu=Jt.mark({class:"cm-searchMatch"}),ku=Jt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Su=Zt.fromClass(class{constructor(e){this.view=e,this.decorations=void 0,this.decorations=this.highlight(e.state.field(bu))}update(e){const t=e.state.field(bu);(t!==e.startState.field(bu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return Jt.none;const{view:t}=this,n=new Qt,o=t.visibleRanges,r=o.length;for(let a=0;a<r;a++){let{to:i}=o[a];const{from:s}=o[a];for(;a<r-1&&i>o[a+1].from-500;)i=o[++a].to;e.highlight(t.state,s,i,((e,o)=>{const r=t.state.selection.ranges.some((t=>t.from===e&&t.to===o));n.add(e,o,r?ku:wu)}))}return n.finish()}},{decorations:e=>e.decorations}),Nu=Yt.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),Cu=()=>{var e;const t=b(99),[n,o]=r.useState(!1),[a,i]=Le(su),[s,l]=r.useState(),c=r.useRef(null),d=le(ze);let u,h,f,m,p;if(t[0]!==n||t[1]!==a.isOpen?(u=()=>(!n||!a.isOpen)&&lu(),t[0]=n,t[1]=a.isOpen,t[2]=u):u=t[2],Cs("cell.findAndReplace",u),t[3]!==a.isOpen?(h=()=>{a.isOpen&&c.current&&(c.current.focus(),c.current.select())},f=[a.isOpen],t[3]=a.isOpen,t[4]=h,t[5]=f):(h=t[4],f=t[5]),r.useEffect(h,f),t[6]!==a.isOpen||t[7]!==a.findText?(m=()=>{if(!a.isOpen)return void xu();if(""===a.findText)return l(void 0),void xu();const e=vu();l(!1===e?void 0:e),function(){const e=te.get(su),t=Gt();for(const n of t)n.state.readOnly||n.dispatch({effects:yu.of(new Wt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()},t[6]=a.isOpen,t[7]=a.findText,t[8]=m):m=t[8],t[9]!==a.findText||t[10]!==a.isOpen||t[11]!==a.caseSensitive||t[12]!==a.regexp||t[13]!==a.wholeWord?(p=[a.findText,a.isOpen,a.caseSensitive,a.regexp,a.wholeWord],t[9]=a.findText,t[10]=a.isOpen,t[11]=a.caseSensitive,t[12]=a.regexp,t[13]=a.wholeWord,t[14]=p):p=t[14],r.useEffect(m,p),!a.isOpen)return null;const g=a.currentView;let v;t[15]!==g||t[16]!==s?(v=g&&s?null==(e=s.position.get(g.view))?void 0:e.get(`${g.range.from}:${g.range.to}`):void 0,t[15]=g,t[16]=s,t[17]=v):v=t[17];const y=v;let x,w,S,E,j,_,I,A,T,M,O;t[18]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(!0),t[18]=x):x=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>o(!1),t[19]=w):w=t[19],t[20]!==i?(S=e=>{"Escape"===e.key&&i({type:"setIsOpen",isOpen:!1})},t[20]=i,t[21]=S):S=t[21],t[22]!==i?(E=()=>i({type:"setIsOpen",isOpen:!1}),t[22]=i,t[23]=E):E=t[23],t[24]===Symbol.for("react.memo_cache_sentinel")?(j=k.jsx(tn,{className:"w-4 h-4"}),t[24]=j):j=t[24],t[25]!==E?(_=k.jsx("div",{className:"absolute top-0 right-0",children:k.jsx(C,{"data-testid":"close-find-replace-button",onClick:E,size:"xs",variant:"text",children:j})}),t[25]=E,t[26]=_):_=t[26],t[27]!==i?(I=e=>{i({type:"setFind",find:e.target.value})},t[27]=i,t[28]=I):I=t[28],t[29]!==a.findText||t[30]!==I?(A=k.jsx(Qe,{ref:c,"data-testid":"find-input",value:a.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:ju,onChange:I}),t[29]=a.findText,t[30]=I,t[31]=A):A=t[31],t[32]!==i?(T=e=>{i({type:"setReplace",replace:e.target.value})},t[32]=i,t[33]=T):T=t[33],t[34]!==a.replaceText||t[35]!==T?(M=k.jsx(Qe,{"data-testid":"replace-input",value:a.replaceText,placeholder:"Replace",onChange:T}),t[34]=a.replaceText,t[35]=T,t[36]=M):M=t[36],t[37]!==A||t[38]!==M?(O=k.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[A,M]}),t[37]=A,t[38]=M,t[39]=O):O=t[39];const D=a.caseSensitive?"on":"off";let P,R,L;t[40]!==i?(P=e=>i({type:"setCaseSensitive",caseSensitive:e}),t[40]=i,t[41]=P):P=t[41],t[42]===Symbol.for("react.memo_cache_sentinel")?(R=k.jsx(nn,{className:"w-4 h-4"}),t[42]=R):R=t[42],t[43]!==a.caseSensitive||t[44]!==D||t[45]!==P?(L=k.jsx(N,{content:"Case Sensitive",children:k.jsx(en,{size:"sm",pressed:a.caseSensitive,"data-state":D,onPressedChange:P,children:R})}),t[43]=a.caseSensitive,t[44]=D,t[45]=P,t[46]=L):L=t[46];const z=a.wholeWord?"on":"off";let F,B,U;t[47]!==i?(F=e=>i({type:"setWholeWord",wholeWord:e}),t[47]=i,t[48]=F):F=t[48],t[49]===Symbol.for("react.memo_cache_sentinel")?(B=k.jsx(Zc,{className:"w-4 h-4"}),t[49]=B):B=t[49],t[50]!==a.wholeWord||t[51]!==z||t[52]!==F?(U=k.jsx(N,{content:"Match Whole Word",children:k.jsx(en,{size:"sm",pressed:a.wholeWord,"data-state":z,onPressedChange:F,children:B})}),t[50]=a.wholeWord,t[51]=z,t[52]=F,t[53]=U):U=t[53];const V=a.regexp?"on":"off";let H,$,W,G;t[54]!==i?(H=e=>i({type:"setRegex",regexp:e}),t[54]=i,t[55]=H):H=t[55],t[56]===Symbol.for("react.memo_cache_sentinel")?($=k.jsx(Mc,{className:"w-4 h-4"}),t[56]=$):$=t[56],t[57]!==a.regexp||t[58]!==V||t[59]!==H?(W=k.jsx(N,{content:"Use Regular Expression",children:k.jsx(en,{size:"sm",pressed:a.regexp,"data-state":V,onPressedChange:H,children:$})}),t[57]=a.regexp,t[58]=V,t[59]=H,t[60]=W):W=t[60],t[61]!==L||t[62]!==U||t[63]!==W?(G=k.jsxs("div",{className:"flex items-center gap-[2px]",children:[L,U,W]}),t[61]=L,t[62]=U,t[63]=W,t[64]=G):G=t[64];const q=""===a.findText||""===a.replaceText;let Y;t[65]!==q?(Y=k.jsx(C,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:_u,disabled:q,children:"Replace Next"}),t[65]=q,t[66]=Y):Y=t[66];const X=""===a.findText||""===a.replaceText;let K,J,Z,Q,ee,ne,oe,re,ae,ie,se,ce;return t[67]!==X?(K=k.jsx(C,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:Iu,disabled:X,children:"Replace All"}),t[67]=X,t[68]=K):K=t[68],t[69]!==Y||t[70]!==K?(J=k.jsxs("div",{className:"flex items-center gap-[2px]",children:[Y,K]}),t[69]=Y,t[70]=K,t[71]=J):J=t[71],t[72]!==G||t[73]!==J?(Z=k.jsxs("div",{className:"flex flex-col gap-2",children:[G,J]}),t[72]=G,t[73]=J,t[74]=Z):Z=t[74],t[75]!==O||t[76]!==Z?(Q=k.jsxs("div",{className:"flex items-center gap-3",children:[O,Z]}),t[75]=O,t[76]=Z,t[77]=Q):Q=t[77],t[78]===Symbol.for("react.memo_cache_sentinel")?(ee=k.jsx(N,{content:"Find Previous",children:k.jsx(C,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:Au,children:k.jsx(Bl,{className:"w-4 h-4"})})}),t[78]=ee):ee=t[78],t[79]===Symbol.for("react.memo_cache_sentinel")?(ne=k.jsx(N,{content:"Find Next",children:k.jsx(C,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:Tu,children:k.jsx(Hl,{className:"w-4 h-4"})})}),t[79]=ne):ne=t[79],t[80]!==s||t[81]!==y?(oe=null!=s&&null==y&&k.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[80]=s,t[81]=y,t[82]=oe):oe=t[82],t[83]!==s||t[84]!==y?(re=null!=s&&null!=y&&k.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[83]=s,t[84]=y,t[85]=re):re=t[85],t[86]!==oe||t[87]!==re?(ae=k.jsxs("div",{className:"flex items-center gap-2",children:[ee,ne,oe,re]}),t[86]=oe,t[87]=re,t[88]=ae):ae=t[88],t[89]!==d?(ie=d.getHotkey("cell.findAndReplace"),t[89]=d,t[90]=ie):ie=t[90],t[91]!==ie.key?(se=k.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",k.jsx(Ge,{shortcut:ie.key})," ","again to open the native browser search."]}),t[91]=ie.key,t[92]=se):se=t[92],t[93]!==S||t[94]!==_||t[95]!==Q||t[96]!==ae||t[97]!==se?(ce=k.jsx(on,{restoreFocus:!0,autoFocus:!0,children:k.jsxs("div",{onFocus:x,onClick:Eu,onBlur:w,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:S,children:[_,Q,ae,se]})}),t[93]=S,t[94]=_,t[95]=Q,t[96]=ae,t[97]=se,t[98]=ce):ce=t[98],ce};function Eu(e){e.stopPropagation(),e.preventDefault()}function ju(e){"Enter"===e.key&&(e.shiftKey?mu():fu())}function _u(){return gu()}function Iu(){const e=pu();if(!e)return;const{dismiss:t}=re({title:"Replaced all occurrences",action:k.jsx(Ed,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),n()}})}),n=t}function Au(){return mu()}function Tu(){return fu()}function Mu(e){const t=b(3),[n,o]=r.useState(!1);let a,i;return t[0]!==e?(a=()=>{if(!e)return;o(!1);const t=setTimeout((()=>{o(!0)}),200);return()=>clearTimeout(t)},i=[e],t[0]=e,t[1]=a,t[2]=i):(a=t[1],i=t[2]),r.useEffect(a,i),e&&n}const Ou=()=>{const e=b(6),t=ce(Bd);let n;e[0]!==t?(n=()=>t((e=>!e)),e[0]=t,e[1]=n):n=e[1];const o=n;let r,a,i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=S("global.commandPalette"),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(nc,{strokeWidth:1.5,size:18}),e[3]=a):a=e[3],e[4]!==o?(i=k.jsx(N,{content:r,children:k.jsx(Es,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:a})}),e[4]=o,e[5]=i):i=e[5],i},Du=e=>{const{children:t}=e;return le(fe)?null:t},Pu=e=>{const{children:t}=e;return le(fe)?t:null},Ru=e=>{const t=b(48),{filename:n,needsSave:o,onSaveNotebook:r,getCellsAsJSON:a,presenting:i,onTogglePresenting:s,onInterrupt:l,onRun:c,closed:d,running:u,needsRun:h,undoAvailable:f,appWidth:m}=e,{undoDeleteCell:p}=q();let g;t[0]!==r?(g=e=>{e.preventDefault(),e.stopPropagation(),r()},t[0]=r,t[1]=g):g=t[1];const v=g;let y,x,w=null;if(!d&&f){let e,n;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Kc,{size:16,strokeWidth:1.5}),t[2]=e):e=t[2],t[3]!==p?(n=k.jsx(N,{content:"Undo cell deletion",children:k.jsx(Es,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:p,children:e})}),t[3]=p,t[4]=n):n=t[4],w=n}t[5]!==i?(y=!i&&k.jsx(Cu,{}),t[5]=i,t[6]=y):y=t[6],t[7]!==d||t[8]!==i?(x=!d&&k.jsxs("div",{className:Fu,children:[i&&k.jsx(hd,{}),k.jsx(au,{}),k.jsx(Ps,{}),k.jsx(Rs,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),t[7]=d,t[8]=i,t[9]=x):x=t[9];const C="compact"===m&&"xl:flex-row items-end";let E,j,_,I,A,T,M,O,D,P,R,L,z;return t[10]!==C?(E=rn(Bu,C),t[10]=C,t[11]=E):E=t[11],t[12]!==d||t[13]!==n||t[14]!==a||t[15]!==o||t[16]!==v?(j=k.jsx(Du,{children:d?k.jsx(ud,{filename:n,getCellsAsJSON:a,needsSave:o}):k.jsx(N,{content:S("global.save"),children:k.jsx(Es,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:o?"yellow":"hint-green",onClick:v,children:k.jsx(Pc,{strokeWidth:1.5,size:18})})})}),t[12]=d,t[13]=n,t[14]=a,t[15]=o,t[16]=v,t[17]=j):j=t[17],t[18]===Symbol.for("react.memo_cache_sentinel")?(_=S("global.hideCode"),t[18]=_):_=t[18],t[19]!==i?(I=i?k.jsx(_t,{strokeWidth:1.5,size:18}):k.jsx(gc,{strokeWidth:1.5,size:18}),t[19]=i,t[20]=I):I=t[20],t[21]!==s||t[22]!==I?(A=k.jsx(N,{content:_,children:k.jsx(Es,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:s,children:I})}),t[21]=s,t[22]=I,t[23]=A):A=t[23],t[24]===Symbol.for("react.memo_cache_sentinel")?(T=k.jsx(Ou,{}),M=k.jsx(Ls,{}),O=k.jsx("div",{}),t[24]=T,t[25]=M,t[26]=O):(T=t[24],M=t[25],O=t[26]),t[27]!==d||t[28]!==u||t[29]!==l?(D=!d&&k.jsx(zu,{running:u,onInterrupt:l}),t[27]=d,t[28]=u,t[29]=l,t[30]=D):D=t[30],t[31]!==d||t[32]!==h||t[33]!==c?(P=!d&&k.jsx(Lu,{needsRun:h,onRun:c}),t[31]=d,t[32]=h,t[33]=c,t[34]=P):P=t[34],t[35]!==w||t[36]!==D||t[37]!==P?(R=k.jsx(Du,{children:k.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[w,D,P]})}),t[35]=w,t[36]=D,t[37]=P,t[38]=R):R=t[38],t[39]!==E||t[40]!==j||t[41]!==A||t[42]!==R?(L=k.jsxs("div",{className:E,children:[j,A,T,M,O,R]}),t[39]=E,t[40]=j,t[41]=A,t[42]=R,t[43]=L):L=t[43],t[44]!==y||t[45]!==x||t[46]!==L?(z=k.jsxs(k.Fragment,{children:[y,x,L]}),t[44]=y,t[45]=x,t[46]=L,t[47]=z):z=t[47],z},Lu=e=>{const t=b(5),{needsRun:n,onRun:o}=e;if(n){let e,n,r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=S("global.runStale"),t[0]=e):e=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Ac,{strokeWidth:1.5,size:16}),t[1]=n):n=t[1],t[2]!==o?(r=k.jsx(N,{content:e,children:k.jsx(Es,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:o,children:n})}),t[2]=o,t[3]=r):r=t[3],r}let r;return t[4]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(N,{content:"Nothing to run",children:k.jsx(Es,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:k.jsx(Ac,{strokeWidth:1.5,size:16})})}),t[4]=r):r=t[4],r},zu=e=>{const t=b(8),{running:n,onInterrupt:o}=e,r=Mu(n);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=S("global.interrupt"),t[0]=a):a=t[0];const i=!r&&"inactive-button active:shadow-xsSolid";let s;t[1]!==i?(s=rn(i),t[1]=i,t[2]=s):s=t[2];const l=r?"yellow":"disabled",c=r?o:an.NOOP;let d,u;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(M,{strokeWidth:1.5,size:16}),t[3]=d):d=t[3],t[4]!==s||t[5]!==l||t[6]!==c?(u=k.jsx(N,{content:a,children:k.jsx(Es,{className:s,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:c,children:d})}),t[4]=s,t[5]=l,t[6]=c,t[7]=u):u=t[7],u},Fu="absolute top-3 right-5 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",Bu="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",Uu=e=>{const t=b(35),{resetOnBlur:n,placeholderText:o,initialValue:a,flexibleWidth:i,onNameChange:s,className:l}=e,c=void 0!==n&&n,d=void 0===a?null:a,u=void 0!==i&&i,[h,f]=r.useState(d);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[0]=m):m=t[0];const[p,g]=r.useState(m),[v,y]=r.useState(!1),x=r.useRef(null),w=r.useRef(!1);let S,N,C;t[1]!==d?(S=()=>{f(d)},N=[d],t[1]=d,t[2]=S,t[3]=N):(S=t[2],N=t[3]),r.useEffect(S,N),t[4]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{y(!0)},t[4]=C):C=t[4];const E=C;let j;t[5]!==c||t[6]!==d?(j=e=>{var t;(null==(t=e.relatedTarget)?void 0:t.closest(".filename-input"))||(y(!1),c&&f(d))},t[5]=c,t[6]=d,t[7]=j):j=t[7];const _=j;let I;t[8]!==h?(I=gt.dirname(h||""),t[8]=h,t[9]=I):I=t[9];const A=I,T=gt.basename(h||""),M=p.filter((e=>gt.basename(e.path).startsWith(T)));let O,D;t[10]!==v||t[11]!==A?(O=async()=>{if(!v)return void g([]);const e=await cn({path:A});g(e.files)},D=[A,v],t[10]=v,t[11]=A,t[12]=O,t[13]=D):(O=t[12],D=t[13]);const{loading:P}=sn(O,D),R=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(_s("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(gt.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||gt.basename(t.path)===e)))return;if(n&&(n===e||gt.basename(n)===e))return;return e}(h,p,d),L=(R||M.length>0)&&k.jsxs(Xe,{className:"font-mono",children:[!P&&k.jsx(Ke,{children:"No files"}),R&&k.jsxs($e,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;R&&(w.current=!0,s(R),null==(e=x.current)||e.blur())},children:[k.jsx(ic,{className:"w-4 h-4 mr-2"})," ",k.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",k.jsx("span",{className:"font-medium text-sm",children:gt.basename(R)})]})]},"_rename_"),M.map((e=>{const t=e.isDirectory?"directory":ln(e.path),n=dn[t];return k.jsxs($e,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?f(`${e.path}/`):f(e.path)},children:[k.jsx(n,{className:"w-4 h-4 mr-2"})," ",gt.basename(e.path)]},e.path)}))]}),z=10*Math.max(20,(null==h?void 0:h.length)||(null==o?void 0:o.length)||0),F=v?h||"":d||"";let B,U,V;t[14]!==u||t[15]!==z?(B=u?{maxWidth:z}:void 0,t[14]=u,t[15]=z,t[16]=B):B=t[16],t[17]!==l?(U=rn(l,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[17]=l,t[18]=U):U=t[18],t[19]!==F||t[20]!==o||t[21]!==B||t[22]!==U?(V=k.jsx(un,{children:k.jsx(Ye,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:F,onKeyDown:Vu,icon:null,ref:x,onValueChange:f,placeholder:o,autoComplete:"off",style:B,className:U})}),t[19]=F,t[20]=o,t[21]=B,t[22]=U,t[23]=V):V=t[23];const H=L&&"group-focus-within:block";let $,W,G,q;return t[24]!==H?($=rn("p-0 w-full min-w-80 max-w-80vw hidden",H),t[24]=H,t[25]=$):$=t[25],t[26]!==$||t[27]!==L?(W=k.jsx(hn,{side:"bottom",className:$,portal:!1,children:L}),t[26]=$,t[27]=L,t[28]=W):W=t[28],t[29]!==V||t[30]!==W?(G=k.jsxs(Xe,{children:[V,W]}),t[29]=V,t[30]=W,t[31]=G):G=t[31],t[32]!==_||t[33]!==G?(q=k.jsx(fn,{open:!0,modal:!1,children:k.jsx(mn,{onFocus:E,onBlur:_,shouldFilter:!1,className:"bg-transparent group filename-input",children:G})}),t[32]=_,t[33]=G,t[34]=q):q=t[34],q};function Vu(e){"Escape"===e.key&&e.currentTarget.blur()}const Hu=e=>{const t=b(7),{filename:n,setFilename:o}=e;let r;t[0]!==n?(r=n?gt.basename(n):"untitled marimo app",t[0]=n,t[1]=r):r=t[1];const a=null===n?"missing-filename":"filename";let i;return t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==a?(i=k.jsx(Uu,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:a}),t[2]=r,t[3]=n,t[4]=o,t[5]=a,t[6]=i):i=t[6],i};function $u(e){return[pn.of([{key:"Escape",preventDefault:!1,run:cu},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:gn},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:lu}]),vn(),Su,bu,Nu]}var Wu=Object.defineProperty,Gu=(e,t,n)=>(((e,t,n)=>{t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const qu=Kt.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is(Yu)));return t.state.doc&&n&&t.state.doc==n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),Yu=Xt.define();class Xu extends xn{constructor(e){super(),Gu(this,"suggestion"),this.suggestion=e}toDOM(){const e=document.createElement("span");return e.style.opacity="0.4",e.className="cm-inline-suggestion",e.textContent=this.suggestion,e}get lineBreaks(){return this.suggestion.split("\n").length-1}}const Ku=e=>Zt.fromClass(class{async update(t){const n=t.state.doc;if(!t.docChanged)return;const o=await e(t.state);t.view.dispatch({effects:Yu.of({text:o,doc:n})})}}),Ju=Zt.fromClass(class{constructor(){Gu(this,"decorations"),this.decorations=Jt.none}update(e){var t;const n=null==(t=e.state.field(qu))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,o=[],r=Jt.widget({widget:new Xu(t),side:1});return o.push(r.range(n)),Jt.set(o)}(e.view,n):Jt.none}},{decorations:e=>e.decorations}),Zu=yn.highest(pn.of([{key:"Tab",run:e=>{var t;const n=null==(t=e.state.field(qu))?void 0:t.suggestion;return!!n&&(e.dispatch({...Qu(e.state,n,e.state.selection.main.head,e.state.selection.main.head)}),!0)}}]));function Qu(e,t,n,o){return{...e.changeByRange((r=>{if(r==e.selection.main)return{changes:{from:n,to:o,insert:t},range:qt.cursor(n+t.length)};const a=o-n;return!r.empty||a&&e.sliceDoc(r.from-a,r.from)!=e.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-a,to:r.from,insert:t},range:qt.cursor(r.from-a+t.length)}})),userEvent:"input.complete"}}function eh(e){const{delay:t=500}=e,n=function(e,t,n){let o=()=>{};return(...r)=>(o(),new Promise(((a,i)=>{const s=setTimeout((()=>a(e(...r))),t);o=()=>{clearTimeout(s),void 0!==n&&i(n)}})))}(e.fetchFn,t);return[qu,Ku(n),Ju,Zu]}const th=Xt.define(),nh=Xt.define(),oh=Xt.define();function rh(e,t){if(!e)throw new Error(t)}function ah(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function ih(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function sh(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const lh=Symbol("@bufbuild/protobuf/enum-type");function ch(e){const t=e[lh];return rh(t,"missing enum type on enum object"),t}function dh(e,t,n,o){e[lh]=uh(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function uh(e,t,n){const o=Object.create(null),r=Object.create(null),a=[];for(const i of t){const e=fh(i);a.push(e),o[i.name]=e,r[i.no]=e}return{typeName:e,values:a,findName:e=>o[e],findNumber:e=>r[e]}}function hh(e,t,n){const o={};for(const r of t){const e=fh(r);o[e.localName]=e.no,o[e.no]=e.localName}return dh(o,e,t),o}function fh(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class mh{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,o=n.makeReadOptions(t);return n.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,t){const n=this.getType(),o=n.runtime.json,r=o.makeReadOptions(t);return o.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${o instanceof Error?o.message:String(o)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),o=n.writerFactory();return t.writeMessage(this,o,n),o.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function ph(){let e=0,t=0;for(let o=0;o<28;o+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let o=3;o<=31;o+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function gh(e,t,n){for(let a=0;a<28;a+=7){const o=e>>>a,r=!(o>>>7==0&&0==t),i=255&(r?128|o:o);if(n.push(i),!r)return}const o=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|o:o)),r){for(let e=3;e<31;e+=7){const o=t>>>e,r=!(o>>>7==0),a=255&(r?128|o:o);if(n.push(a),!r)return}n.push(t>>>31&1)}}const vh=4294967296;function yh(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let o=0,r=0;function a(t,a){const i=Number(e.slice(t,a));r*=n,o=o*n+i,o>=vh&&(r+=o/vh|0,o%=vh)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?wh(o,r):bh(o,r)}function xh(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(vh*t+e);const n=16777215&(e>>>24|t<<8),o=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*o,a=n+8147497*o,i=2*o;const s=1e7;return r>=s&&(a+=Math.floor(r/s),r%=s),a>=s&&(i+=Math.floor(a/s),a%=s),i.toString()+kh(a)+kh(r)}function bh(e,t){return{lo:0|e,hi:0|t}}function wh(e,t){return t=~t,e?e=1+~e:t+=1,bh(e,t)}const kh=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Sh(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Nh(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Ch={};const Eh=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"1"!==Ch.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const o="bigint"==typeof e?e:BigInt(e);if(o>n||o<t)throw new Error(`int64 invalid: ${e}`);return o},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<o)throw new Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>rh(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>rh(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),yh(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),yh(e)),dec:(e,t)=>function(e,t){let n=bh(e,t);const o=2147483648&n.hi;o&&(n=wh(n.lo,n.hi));const r=xh(n.lo,n.hi);return o?"-"+r:r}(e,t),uDec:(e,t)=>xh(e,t)}}();var jh,_h,Ih,Ah,Th,Mh;function Oh(e,t,n){if(t===n)return!0;if(e==jh.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return t==n}return!1}function Dh(e,t){switch(e){case jh.BOOL:return!1;case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return 0==t?Eh.zero:"0";case jh.DOUBLE:case jh.FLOAT:return 0;case jh.BYTES:return new Uint8Array(0);case jh.STRING:return"";default:return 0}}function Ph(e,t){switch(e){case jh.BOOL:return!1===t;case jh.STRING:return""===t;case jh.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(_h=jh||(jh={}))[_h.DOUBLE=1]="DOUBLE",_h[_h.FLOAT=2]="FLOAT",_h[_h.INT64=3]="INT64",_h[_h.UINT64=4]="UINT64",_h[_h.INT32=5]="INT32",_h[_h.FIXED64=6]="FIXED64",_h[_h.FIXED32=7]="FIXED32",_h[_h.BOOL=8]="BOOL",_h[_h.STRING=9]="STRING",_h[_h.BYTES=12]="BYTES",_h[_h.UINT32=13]="UINT32",_h[_h.SFIXED32=15]="SFIXED32",_h[_h.SFIXED64=16]="SFIXED64",_h[_h.SINT32=17]="SINT32",_h[_h.SINT64=18]="SINT64",(Ah=Ih||(Ih={}))[Ah.BIGINT=0]="BIGINT",Ah[Ah.STRING=1]="STRING",(Mh=Th||(Th={}))[Mh.Varint=0]="Varint",Mh[Mh.Bit64=1]="Bit64",Mh[Mh.LengthDelimited=2]="LengthDelimited",Mh[Mh.StartGroup=3]="StartGroup",Mh[Mh.EndGroup=4]="EndGroup",Mh[Mh.Bit32=5]="Bit32";class Rh{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let t=new Uint8Array(e),n=0;for(let o=0;o<this.chunks.length;o++)t.set(this.chunks[o],n),n+=this.chunks[o].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ih(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ah(e),Sh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){sh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ih(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ah(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ah(e),Sh(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=Eh.enc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=Eh.uEnc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}int64(e){let t=Eh.enc(e);return gh(t.lo,t.hi,this.buf),this}sint64(e){let t=Eh.enc(e),n=t.hi>>31;return gh(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Eh.uEnc(e);return gh(t.lo,t.hi,this.buf),this}}class Lh{constructor(e,t){this.varint64=ph,this.uint32=Nh,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Th.Varint:for(;128&this.buf[this.pos++];);break;case Th.Bit64:this.pos+=4;case Th.Bit32:this.pos+=4;break;case Th.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Th.StartGroup:for(;;){const[e,n]=this.tag();if(n===Th.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return Eh.dec(...this.varint64())}uint64(){return Eh.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,Eh.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Eh.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Eh.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function zh(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Dh(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let Fh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Bh=[];for(let oF=0;oF<Fh.length;oF++)Bh[Fh[oF].charCodeAt(0)]=oF;Bh["-".charCodeAt(0)]=Fh.indexOf("+"),Bh["_".charCodeAt(0)]=Fh.indexOf("/");const Uh={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,o=new Uint8Array(t),r=0,a=0,i=0;for(let s=0;s<e.length;s++){if(n=Bh[e.charCodeAt(s)],void 0===n)switch(e[s]){case"=":a=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(a){case 0:i=n,a=1;break;case 1:o[r++]=i<<2|(48&n)>>4,i=n,a=2;break;case 2:o[r++]=(15&i)<<4|(60&n)>>2,i=n,a=3;break;case 3:o[r++]=(3&i)<<6|n,a=0}}if(1==a)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(e){let t,n="",o=0,r=0;for(let a=0;a<e.length;a++)switch(t=e[a],o){case 0:n+=Fh[t>>2],r=(3&t)<<4,o=1;break;case 1:n+=Fh[r|t>>4],r=(15&t)<<2,o=2;break;case 2:n+=Fh[r|t>>6],n+=Fh[63&t],o=0}return o&&(n+=Fh[r],n+="=",1==o&&(n+="=")),n}};function Vh(e,t,n){Wh(t,e);const o=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,i]=zh(t);for(const s of r)t.runtime.bin.readField(a,o.readerFactory(s.data),t.field,s.wireType,o);return i()}function Hh(e,t,n,o){Wh(t,e);const r=t.runtime.bin.makeReadOptions(o),a=t.runtime.bin.makeWriteOptions(o);if($h(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const i=a.writerFactory();let s=t.field;s.opt||s.repeated||"enum"!=s.kind&&"scalar"!=s.kind||(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,i,a);const l=r.readerFactory(i.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),o=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,o)}}function $h(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function Wh(e,t){rh(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Gh(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!Ph(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function qh(e,t){const n=e.localName,o=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=o?e.T.values[0].no:void 0;break;case"scalar":t[n]=o?Dh(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function Yh(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(mh.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function Xh(e,t){return Yh(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}jh.DOUBLE,jh.FLOAT,jh.INT64,jh.UINT64,jh.INT32,jh.UINT32,jh.BOOL,jh.STRING,jh.BYTES;const Kh={ignoreUnknownFields:!1},Jh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Zh(e){return e?Object.assign(Object.assign({},Kh),e):Kh}function Qh(e){return e?Object.assign(Object.assign({},Jh),e):Jh}const ef=Symbol(),tf=Symbol();function nf(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function of(e,t,n,o,r){let a=n.localName;if(n.repeated){if(rh("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`);const s=e[a];for(const e of t){if(null===e)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(e)}`);switch(n.kind){case"message":s.push(n.T.fromJson(e,o));break;case"enum":const t=sf(n.T,e,o.ignoreUnknownFields,!0);t!==tf&&s.push(t);break;case"scalar":try{s.push(af(n.T,e,n.L,!0))}catch(i){let t=`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(e)}`;throw i instanceof Error&&i.message.length>0&&(t+=`: ${i.message}`),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`);const s=e[a];for(const[e,a]of Object.entries(t)){if(null===a)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;try{l=rf(n.K,e)}catch(i){let e=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}switch(n.V.kind){case"message":s[l]=n.V.T.fromJson(a,o);break;case"enum":const e=sf(n.V.T,a,o.ignoreUnknownFields,!0);e!==tf&&(s[l]=e);break;case"scalar":try{s[l]=af(n.V.T,a,Ih.BIGINT,!0)}catch(i){let e=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a="value"),n.kind){case"message":const s=n.T;if(null===t&&"google.protobuf.Value"!=s.typeName)return;let l=e[a];Yh(l)?l.fromJson(t,o):(e[a]=l=s.fromJson(t,o),s.fieldWrapper&&!n.oneof&&(e[a]=s.fieldWrapper.unwrapField(l)));break;case"enum":const c=sf(n.T,t,o.ignoreUnknownFields,!1);switch(c){case ef:qh(n,e);break;case tf:break;default:e[a]=c}break;case"scalar":try{const o=af(n.T,t,n.L,!1);if(o===ef)qh(n,e);else e[a]=o}catch(i){let e=`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}function rf(e,t){if(e===jh.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return af(e,t,Ih.BIGINT,!0).toString()}function af(e,t,n,o){if(null===t)return o?Dh(e,n):ef;switch(e){case jh.DOUBLE:case jh.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const o=Number(t);if(Number.isNaN(o))break;if(!Number.isFinite(o))break;return e==jh.FLOAT&&sh(o),o;case jh.INT32:case jh.FIXED32:case jh.SFIXED32:case jh.SINT32:case jh.UINT32:let a;if("number"==typeof t?a=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),void 0===a)break;return e==jh.UINT32||e==jh.FIXED32?ih(a):ah(a),a;case jh.INT64:case jh.SFIXED64:case jh.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=Eh.parse(t);return n?i.toString():i;case jh.FIXED64:case jh.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const s=Eh.uParse(t);return n?s.toString():s;case jh.BOOL:if("boolean"!=typeof t)break;return t;case jh.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(r){throw new Error("invalid UTF8")}return t;case jh.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return Uh.dec(t)}throw new Error}function sf(e,t,n,o){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:o?e.values[0].no:ef;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const o=e.findName(t);if(void 0!==o)return o.no;if(n)return tf}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${nf(t)}`)}function lf(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function cf(e,t,n){if("map"==e.kind){rh("object"==typeof t&&null!=t);const o={},r=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,a]of r)o[n.toString()]=uf(e.V.T,a);break;case"message":for(const[e,a]of r)o[e.toString()]=a.toJson(n);break;case"enum":const t=e.V.T;for(const[e,a]of r)o[e.toString()]=df(t,a,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(e.repeated){rh(Array.isArray(t));const o=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)o.push(uf(e.T,t[n]));break;case"enum":for(let r=0;r<t.length;r++)o.push(df(e.T,t[r],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)o.push(t[e].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(e.kind){case"scalar":return uf(e.T,t);case"enum":return df(e.T,t,n.enumAsInteger);case"message":return Xh(e.T,t).toJson(n)}}function df(e,t,n){var o;if(rh("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const r=e.findNumber(t);return null!==(o=null==r?void 0:r.name)&&void 0!==o?o:t}function uf(e,t){switch(e){case jh.INT32:case jh.SFIXED32:case jh.SINT32:case jh.FIXED32:case jh.UINT32:return rh("number"==typeof t),t;case jh.FLOAT:case jh.DOUBLE:return rh("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case jh.STRING:return rh("string"==typeof t),t;case jh.BOOL:return rh("boolean"==typeof t),t;case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return rh("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case jh.BYTES:return rh(t instanceof Uint8Array),Uh.enc(t)}}const hf=Symbol("@bufbuild/protobuf/unknown-fields"),ff={readUnknownFields:!0,readerFactory:e=>new Lh(e)},mf={writeUnknownFields:!0,writerFactory:()=>new Rh};function pf(e){return e?Object.assign(Object.assign({},ff),e):ff}function gf(e){return e?Object.assign(Object.assign({},mf),e):mf}function vf(e,t,n,o,r){let{repeated:a,localName:i}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=i&&delete e.value,e.case=i,i="value"),n.kind){case"scalar":case"enum":const s="enum"==n.kind?jh.INT32:n.T;let l=bf;if("scalar"==n.kind&&n.L>0&&(l=xf),a){let n=e[i];if(o==Th.LengthDelimited&&s!=jh.STRING&&s!=jh.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,s))}else n.push(l(t,s))}else e[i]=l(t,s);break;case"message":const c=n.T;a?e[i].push(yf(t,new c,r,n)):Yh(e[i])?yf(t,e[i],r,n):(e[i]=yf(t,new c,r,n),!c.fieldWrapper||n.oneof||n.repeated||(e[i]=c.fieldWrapper.unwrapField(e[i])));break;case"map":let[d,u]=function(e,t,n){const o=t.uint32(),r=t.pos+o;let a,i;for(;t.pos<r;){const[o]=t.tag();switch(o){case 1:a=bf(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=bf(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=yf(t,new e.V.T,n,void 0)}}}void 0===a&&(a=Dh(e.K,Ih.BIGINT));"string"!=typeof a&&"number"!=typeof a&&(a=a.toString());if(void 0===i)switch(e.V.kind){case"scalar":i=Dh(e.V.T,Ih.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T}return[a,i]}(n,t,r);e[i][d]=u}}function yf(e,t,n,o){const r=t.getType().runtime.bin,a=null==o?void 0:o.delimited;return r.readMessage(t,e,a?o.no:e.uint32(),n,a),t}function xf(e,t){const n=bf(e,t);return"bigint"==typeof n?n.toString():n}function bf(e,t){switch(t){case jh.STRING:return e.string();case jh.BOOL:return e.bool();case jh.DOUBLE:return e.double();case jh.FLOAT:return e.float();case jh.INT32:return e.int32();case jh.INT64:return e.int64();case jh.UINT64:return e.uint64();case jh.FIXED64:return e.fixed64();case jh.BYTES:return e.bytes();case jh.FIXED32:return e.fixed32();case jh.SFIXED32:return e.sfixed32();case jh.SFIXED64:return e.sfixed64();case jh.SINT64:return e.sint64();case jh.UINT32:return e.uint32();case jh.SINT32:return e.sint32()}}function wf(e,t,n,o){rh(void 0!==t);const r=e.repeated;switch(e.kind){case"scalar":case"enum":let a="enum"==e.kind?jh.INT32:e.T;if(r)if(rh(Array.isArray(t)),e.packed)!function(e,t,n,o){if(!o.length)return;e.tag(n,Th.LengthDelimited).fork();let[,r]=Cf(t);for(let a=0;a<o.length;a++)e[r](o[a]);e.join()}(n,a,e.no,t);else for(const o of t)Nf(n,a,e.no,o);else Nf(n,a,e.no,t);break;case"message":if(r){rh(Array.isArray(t));for(const r of t)Sf(n,o,e,r)}else Sf(n,o,e,t);break;case"map":rh("object"==typeof t&&null!=t);for(const[r,i]of Object.entries(t))kf(n,o,e,r,i)}}function kf(e,t,n,o,r){e.tag(n.no,Th.LengthDelimited),e.fork();let a=o;switch(n.K){case jh.INT32:case jh.FIXED32:case jh.UINT32:case jh.SFIXED32:case jh.SINT32:a=Number.parseInt(o);break;case jh.BOOL:rh("true"==o||"false"==o),a="true"==o}switch(Nf(e,n.K,1,a),n.V.kind){case"scalar":Nf(e,n.V.T,2,r);break;case"enum":Nf(e,jh.INT32,2,r);break;case"message":rh(void 0!==r),e.tag(2,Th.LengthDelimited).bytes(r.toBinary(t))}e.join()}function Sf(e,t,n,o){const r=Xh(n.T,o);n.delimited?e.tag(n.no,Th.StartGroup).raw(r.toBinary(t)).tag(n.no,Th.EndGroup):e.tag(n.no,Th.LengthDelimited).bytes(r.toBinary(t))}function Nf(e,t,n,o){rh(void 0!==o);let[r,a]=Cf(t);e.tag(n,r)[a](o)}function Cf(e){let t=Th.Varint;switch(e){case jh.BYTES:case jh.STRING:t=Th.LengthDelimited;break;case jh.DOUBLE:case jh.FIXED64:case jh.SFIXED64:t=Th.Bit64;break;case jh.FIXED32:case jh.SFIXED32:case jh.FLOAT:t=Th.Bit32}return[t,jh[e].toLowerCase()]}function Ef(e){if(void 0===e)return e;if(Yh(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function jf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class _f{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function If(e,t){const n=Tf(e);return t?n:Rf(Pf(n))}const Af=Tf;function Tf(e){let t=!1;const n=[];for(let o=0;o<e.length;o++){let r=e.charAt(o);switch(r){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),t=!1;break;default:t&&(t=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Mf=new Set(["constructor","toString","toJSON","valueOf"]),Of=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Df=e=>`${e}$`,Pf=e=>Of.has(e)?Df(e):e,Rf=e=>Mf.has(e)?Df(e):e;class Lf{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=If(e,!1)}addField(e){rh(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const zf=(Ff=e=>new _f(e,(e=>function(e){var t,n,o,r,a,i;const s=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=If(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Af(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(o=c.L)&&void 0!==o?o:Ih.BIGINT),e.delimited=null!==(r=c.delimited)&&void 0!==r&&r,e.req=null!==(a=c.req)&&void 0!==a&&a,e.opt=null!==(i=c.opt)&&void 0!==i&&i,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=jh.BYTES&&c.T!=jh.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new Lf(t)),e.oneof=l,l.addField(e)}s.push(e)}return s}(e))),Bf=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,o=e;if(t.repeated)o[n]=[];else switch(t.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=Dh(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:Zh,makeWriteOptions:Qh,readMessage(e,t,n,o){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${nf(t)}`);o=null!=o?o:new e;const r=new Map,a=n.typeRegistry;for(const[i,s]of Object.entries(t)){const t=e.fields.findJsonName(i);if(t){if(t.oneof){if(null===s&&"scalar"==t.kind)continue;const n=r.get(t.oneof);if(void 0!==n)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${i}"`);r.set(t.oneof,i)}of(o,s,t,n,e)}else{let t=!1;if((null==a?void 0:a.findExtension)&&i.startsWith("[")&&i.endsWith("]")){const r=a.findExtension(i.substring(1,i.length-1));if(r&&r.extendee.typeName==e.typeName){t=!0;const[e,a]=zh(r);of(e,s,r.field,n,r),Hh(o,r,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return o},writeMessage(e,t){const n=e.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!Gh(r,e)){if(r.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!lf(r))continue}const n=cf(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t);void 0!==n&&(o[t.useProtoFieldName?r.name:r.jsonName]=n)}const a=t.typeRegistry;if(null==a?void 0:a.findExtensionFor)for(const r of n.runtime.bin.listUnknownFields(e)){const i=a.findExtensionFor(n.typeName,r.no);if(i&&$h(e,i)){const n=Vh(e,i,t),r=cf(i.field,n,t);void 0!==r&&(o[i.field.jsonName]=r)}}}catch(a){const e=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=a instanceof Error?a.message:String(a);throw new Error(e+(t.length>0?`: ${t}`:""))}return o},readScalar:(e,t,n)=>af(e,t,null!=n?n:Ih.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||Ph(e,t)?uf(e,t):void 0},debug:nf},bin:{makeReadOptions:pf,makeWriteOptions:gf,listUnknownFields(e){var t;return null!==(t=e[hf])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[hf]},writeUnknownFields(e,t){const n=e[hf];if(n)for(const o of n)t.tag(o.no,o.wireType).raw(o.data)},onUnknownField(e,t,n,o){const r=e;Array.isArray(r[hf])||(r[hf]=[]),r[hf].push({no:t,wireType:n,data:o})},readMessage(e,t,n,o,r){const a=e.getType(),i=r?t.len:t.pos+n;let s,l;for(;t.pos<i&&([s,l]=t.tag(),!0!==r||l!=Th.EndGroup);){const n=a.fields.find(s);if(n)vf(e,t,n,l,o);else{const n=t.skip(l,s);o.readUnknownFields&&this.onUnknownField(e,s,l,n)}}if(r&&(l!=Th.EndGroup||s!==n))throw new Error("invalid end group tag")},readField:vf,writeMessage(e,t,n){const o=e.getType();for(const r of o.fields.byNumber())if(Gh(r,e))wf(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,o){void 0!==t&&wf(e,t,n,o)}},util:Object.assign(Object.assign({},{setEnumType:dh,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const o of n.fields.byMember()){const n=o.localName,r=t,a=e;if(null!=a[n])switch(o.kind){case"oneof":const e=a[n].case;if(void 0===e)continue;const t=o.findField(e);let i=a[n].value;t&&"message"==t.kind&&!Yh(i,t.T)?i=new t.T(i):t&&"scalar"===t.kind&&t.T===jh.BYTES&&(i=jf(i)),r[n]={case:e,value:i};break;case"scalar":case"enum":let s=a[n];o.T===jh.BYTES&&(s=o.repeated?s.map(jf):jf(s)),r[n]=s;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===jh.BYTES)for(const[t,o]of Object.entries(a[n]))r[n][t]=jf(o);else Object.assign(r[n],a[n]);break;case"message":const e=o.V.T;for(const t of Object.keys(a[n])){let o=a[n][t];e.fieldWrapper||(o=new e(o)),r[n][t]=o}}break;case"message":const l=o.T;if(o.repeated)r[n]=a[n].map((e=>Yh(e,l)?e:new l(e)));else{const e=a[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?r[n]=jf(e):r[n]=e:r[n]=Yh(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const o=t[e.localName],r=n[e.localName];if(e.repeated){if(o.length!==r.length)return!1;switch(e.kind){case"message":return o.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return o.every(((t,n)=>Oh(e.T,t,r[n])));case"enum":return o.every(((e,t)=>Oh(jh.INT32,e,r[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(o,r);case"enum":return Oh(jh.INT32,o,r);case"scalar":return Oh(e.T,o,r);case"oneof":if(o.case!==r.case)return!1;const t=e.findField(o.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(o.value,r.value);case"enum":return Oh(jh.INT32,o.value,r.value);case"scalar":return Oh(t.T,o.value,r.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(o).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(o[e],r[e])));case"enum":return n.every((e=>Oh(jh.INT32,o[e],r[e])));case"scalar":const a=e.V.T;return n.every((e=>Oh(a,o[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,o=n;for(const r of t.fields.byMember()){const t=e[r.localName];let n;if(r.repeated)n=t.map(Ef);else if("map"==r.kind){n=o[r.localName];for(const[e,o]of Object.entries(t))n[e]=Ef(o)}else n="oneof"==r.kind?r.findField(t.case)?{case:t.case,value:Ef(t.value)}:{case:void 0}:Ef(t);o[r.localName]=n}for(const r of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Ff,initFields:Bf}),makeMessageType(e,t,n){return function(e,t,n,o){var r;const a=null!==(r=null==o?void 0:o.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),i={[a]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[a];return Object.setPrototypeOf(i.prototype,new mh),Object.assign(i,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new i).fromBinary(e,t),fromJson:(e,t)=>(new i).fromJson(e,t),fromJsonString:(e,t)=>(new i).fromJsonString(e,t),equals:(t,n)=>e.util.equals(i,t,n)}),i}(this,e,t,n)},makeEnum:hh,makeEnumType:uh,getEnumType:ch,makeExtension(e,t,n){return function(e,t,n,o){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof o?o():o;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Ff,Bf,Uf,Vf,Hf,$f,Wf,Gf,qf,Yf,Xf,Kf,Jf,Zf,Qf,em;(Vf=Uf||(Uf={}))[Vf.Unary=0]="Unary",Vf[Vf.ServerStreaming=1]="ServerStreaming",Vf[Vf.ClientStreaming=2]="ClientStreaming",Vf[Vf.BiDiStreaming=3]="BiDiStreaming",($f=Hf||(Hf={}))[$f.NoSideEffects=1]="NoSideEffects",$f[$f.Idempotent=2]="Idempotent",(Gf=Wf||(Wf={}))[Gf.UNSPECIFIED=0]="UNSPECIFIED",Gf[Gf.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",zf.util.setEnumType(Wf,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(Yf=qf||(qf={}))[Yf.CODEIUM=0]="CODEIUM",zf.util.setEnumType(qf,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(Kf=Xf||(Xf={}))[Kf.UNSPECIFIED=0]="UNSPECIFIED",Kf[Kf.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",Kf[Kf.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",Kf[Kf.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",Kf[Kf.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",zf.util.setEnumType(Xf,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(Zf=Jf||(Jf={}))[Zf.UNSPECIFIED=0]="UNSPECIFIED",Zf[Zf.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",Zf[Zf.CACHE=2]="CACHE",Zf[Zf.NETWORK=3]="NETWORK",zf.util.setEnumType(Jf,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(em=Qf||(Qf={}))[em.UNSPECIFIED=0]="UNSPECIFIED",em[em.C=1]="C",em[em.CLOJURE=2]="CLOJURE",em[em.COFFEESCRIPT=3]="COFFEESCRIPT",em[em.CPP=4]="CPP",em[em.CSHARP=5]="CSHARP",em[em.CSS=6]="CSS",em[em.CUDACPP=7]="CUDACPP",em[em.DOCKERFILE=8]="DOCKERFILE",em[em.GO=9]="GO",em[em.GROOVY=10]="GROOVY",em[em.HANDLEBARS=11]="HANDLEBARS",em[em.HASKELL=12]="HASKELL",em[em.HCL=13]="HCL",em[em.HTML=14]="HTML",em[em.INI=15]="INI",em[em.JAVA=16]="JAVA",em[em.JAVASCRIPT=17]="JAVASCRIPT",em[em.JSON=18]="JSON",em[em.JULIA=19]="JULIA",em[em.KOTLIN=20]="KOTLIN",em[em.LATEX=21]="LATEX",em[em.LESS=22]="LESS",em[em.LUA=23]="LUA",em[em.MAKEFILE=24]="MAKEFILE",em[em.MARKDOWN=25]="MARKDOWN",em[em.OBJECTIVEC=26]="OBJECTIVEC",em[em.OBJECTIVECPP=27]="OBJECTIVECPP",em[em.PERL=28]="PERL",em[em.PHP=29]="PHP",em[em.PLAINTEXT=30]="PLAINTEXT",em[em.PROTOBUF=31]="PROTOBUF",em[em.PBTXT=32]="PBTXT",em[em.PYTHON=33]="PYTHON",em[em.R=34]="R",em[em.RUBY=35]="RUBY",em[em.RUST=36]="RUST",em[em.SASS=37]="SASS",em[em.SCALA=38]="SCALA",em[em.SCSS=39]="SCSS",em[em.SHELL=40]="SHELL",em[em.SQL=41]="SQL",em[em.STARLARK=42]="STARLARK",em[em.SWIFT=43]="SWIFT",em[em.TSX=44]="TSX",em[em.TYPESCRIPT=45]="TYPESCRIPT",em[em.VISUALBASIC=46]="VISUALBASIC",em[em.VUE=47]="VUE",em[em.XML=48]="XML",em[em.XSL=49]="XSL",em[em.YAML=50]="YAML",em[em.SVELTE=51]="SVELTE",em[em.TOML=52]="TOML",em[em.DART=53]="DART",em[em.RST=54]="RST",em[em.OCAML=55]="OCAML",em[em.CMAKE=56]="CMAKE",em[em.PASCAL=57]="PASCAL",em[em.ELIXIR=58]="ELIXIR",em[em.FSHARP=59]="FSHARP",em[em.LISP=60]="LISP",em[em.MATLAB=61]="MATLAB",em[em.POWERSHELL=62]="POWERSHELL",em[em.SOLIDITY=63]="SOLIDITY",em[em.ADA=64]="ADA",em[em.OCAML_INTERFACE=65]="OCAML_INTERFACE",zf.util.setEnumType(Qf,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const tm=class e extends mh{constructor(e){super(),n(this,"completionId",""),n(this,"text",""),n(this,"prefix",""),n(this,"stop",""),n(this,"score",0),n(this,"tokens",[]),n(this,"decodedTokens",[]),n(this,"probabilities",[]),n(this,"adjustedProbabilities",[]),n(this,"generatedLength",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(tm,"runtime",zf),n(tm,"typeName","exa.codeium_common_pb.Completion"),n(tm,"fields",zf.util.newFieldList((()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])));let nm=tm;const om=class e extends mh{constructor(e){super(),n(this,"ideName",""),n(this,"ideVersion",""),n(this,"extensionName",""),n(this,"extensionVersion",""),n(this,"apiKey",""),n(this,"locale",""),n(this,"sessionId",""),n(this,"requestId",Eh.zero),n(this,"userAgent",""),n(this,"url",""),n(this,"authSource",qf.CODEIUM),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(om,"runtime",zf),n(om,"typeName","exa.codeium_common_pb.Metadata"),n(om,"fields",zf.util.newFieldList((()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:zf.getEnumType(qf)}])));let rm=om;const am=class e extends mh{constructor(e){super(),n(this,"tabSize",Eh.zero),n(this,"insertSpaces",!1),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(am,"runtime",zf),n(am,"typeName","exa.codeium_common_pb.EditorOptions"),n(am,"fields",zf.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let im=am;e=class extends mh{constructor(e){super(),n(this,"eventType",Xf.UNSPECIFIED),n(this,"eventJson",""),n(this,"timestampUnixMs",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}},n(e,"runtime",zf),n(e,"typeName","exa.codeium_common_pb.Event"),n(e,"fields",zf.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:zf.getEnumType(Xf)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class sm extends xn{constructor(e,t){super(),n(this,"index"),n(this,"total"),this.index=e,this.total=t}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-codeium-cycle";const t=e.appendChild(document.createElement("span"));t.className="cm-codeium-cycle-explanation",t.innerText=`${this.index+1}/${this.total}`;const n=e.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="→ (Ctrl ])",n.dataset.action="codeium-cycle",e}ignoreEvent(){return!1}}const lm=bn.define({combine:e=>wn(e,{language:Qf.TYPESCRIPT,timeout:150,widgetClass:sm,alwaysOn:!0},{})}),cm=bn.define({combine:e=>wn(e,{override:()=>[]},{})}),dm=Jt.mark({class:"cm-ghostText"}),um=Kt.define({create:e=>null,update(e,t){var n;const o=t.state.facet(lm);for(const r of t.effects){if(r.is(th)){const{changeSpecs:e,index:t}=r.value,a=e[t].map((e=>dm.range(e.absoluteStartPos,e.absoluteEndPos))),i=null==(n=a.at(-1))?void 0:n.to;return{index:t,decorations:Jt.set([...a,...void 0!==i&&e.length>1&&o.widgetClass?[Jt.widget({widget:new o.widgetClass(t,e.length),side:1}).range(i)]:[]]),changeSpecs:e,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(nh))return null;if(r.is(oh))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>Yt.decorations.from(e,(e=>(null==e?void 0:e.decorations)||Jt.none))}),hm=kn.define(),fm=kn.define();var mm,pm;function gm(e){const t=mm[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let vm;(pm=mm||(mm={}))[pm.Canceled=1]="Canceled",pm[pm.Unknown=2]="Unknown",pm[pm.InvalidArgument=3]="InvalidArgument",pm[pm.DeadlineExceeded=4]="DeadlineExceeded",pm[pm.NotFound=5]="NotFound",pm[pm.AlreadyExists=6]="AlreadyExists",pm[pm.PermissionDenied=7]="PermissionDenied",pm[pm.ResourceExhausted=8]="ResourceExhausted",pm[pm.FailedPrecondition=9]="FailedPrecondition",pm[pm.Aborted=10]="Aborted",pm[pm.OutOfRange=11]="OutOfRange",pm[pm.Unimplemented=12]="Unimplemented",pm[pm.Internal=13]="Internal",pm[pm.Unavailable=14]="Unavailable",pm[pm.DataLoss=15]="DataLoss",pm[pm.Unauthenticated=16]="Unauthenticated";class ym extends Error{constructor(e,t=mm.Unknown,n,o,r){super(function(e,t){return e.length?`[${gm(t)}] ${e}`:`[${gm(t)}]`}(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(null!=n?n:{}),this.details=null!=o?o:[],this.cause=r}static from(e,t=mm.Unknown){return e instanceof ym?e:e instanceof Error?"AbortError"==e.name?new ym(e.message,mm.Canceled):new ym(e.message,t,void 0,void 0,e):new ym(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===ym.prototype||"ConnectError"===e.name&&"code"in e&&"number"==typeof e.code&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&"string"==typeof e.rawMessage&&"cause"in e)}findDetails(e){const t="typeName"in e?{findMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&n.push(r);continue}const e=t.findMessage(r.type);if(e)try{n.push(e.fromBinary(r.value))}catch(o){}}return n}}var xm=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},bm=function(e){return this instanceof bm?(this.v=e,this):new bm(e)},wm=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof bm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};function km(e){return wm(this,arguments,(function*(){yield bm(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:bm(e[o](t)),done:!1}:r?r(t):t}:r}}(xm(e)))}))}var Sm=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Nm=function(e){return this instanceof Nm?(this.v=e,this):new Nm(e)},Cm=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof Nm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};function Em(e,t){const n=function(){var n,o;return Cm(this,arguments,(function*(){const r=yield Nm(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,r.header),yield Nm(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Nm(e[o](t)),done:!1}:r?r(t):t}:r}}(Sm(r.message))),null===(o=null==t?void 0:t.onTrailer)||void 0===o||o.call(t,r.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function jm(e){if(!e.aborted)return;if(void 0!==e.reason)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function _m(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Im(e,t,n){const o="string"==typeof t?t:t.typeName,r="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${o}/${r}`)}function Am(e,t){return t instanceof e?t:new e(t)}function Tm(e,t){function n(t){return!0===t.done?t:{done:t.done,value:Am(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),o={next:()=>e.next().then(n)};return void 0!==e.throw&&(o.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(o.return=t=>e.return(t).then(n)),o}}}function Mm(e,t){var n;return null!==(n=null==t?void 0:t.concat().reverse().reduce(((e,t)=>t(e)),e))&&void 0!==n?n:e}function Om(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function Dm(e,t,n,o){const r=t?Pm(e.I,o):Rm(e.I,n);return{parse:(t?Pm(e.O,o):Rm(e.O,n)).parse,serialize:r.serialize}}function Pm(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(o){const e=o instanceof Error?o.message:String(o);throw new ym(`parse binary: ${e}`,mm.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new ym(`serialize binary: ${e}`,mm.Internal)}}}}function Rm(e,t){var n,o;const r=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,a=null!==(o=null==t?void 0:t.textDecoder)&&void 0!==o?o:new TextDecoder,i=Om(t);return{parse(t){try{const n=a.decode(t);return e.fromJsonString(n,i)}catch(n){throw ym.from(n,mm.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(i);return r.encode(t)}catch(t){throw ym.from(t,mm.Internal)}}}}const Lm=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function zm(e,t,n){if(t&&new Headers(t).forEach(((e,t)=>n.metadata.append(t,e))),"object"!=typeof e||null==e||Array.isArray(e)||!("code"in e)||"string"!=typeof e.code)throw n;const o=function(e){if(!vm){vm={};for(const e of Object.values(mm))"string"!=typeof e&&(vm[gm(e)]=e)}return vm[e]}(e.code);if(void 0===o)throw n;const r=e.message;if(null!=r&&"string"!=typeof r)throw n;const a=new ym(null!=r?r:"",o,t);if("details"in e&&Array.isArray(e.details))for(const s of e.details){if(null===s||"object"!=typeof s||Array.isArray(s)||"string"!=typeof s.type||"string"!=typeof s.value||"debug"in s&&"object"!=typeof s.debug)throw n;try{a.details.push({type:s.type,value:Uh.dec(s.value),debug:s.debug})}catch(i){throw n}}return a}function Fm(e){const t=new ym("invalid end stream",mm.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(r){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const o=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,r]of Object.entries(n.metadata)){if(!Array.isArray(r)||r.some((e=>"string"!=typeof e)))throw t;for(const t of r)o.append(e,t)}}return{metadata:o,error:"error"in n?zm(n.error,o,t):void 0}}const Bm="Content-Type",Um="Content-Length",Vm="Content-Encoding",Hm="Accept-Encoding",$m="Connect-Protocol-Version";function Wm(e){const t=new Headers,n=new Headers;return e.forEach(((e,o)=>{o.toLowerCase().startsWith("trailer-")?n.set(o.substring(8),e):t.set(o,e)})),[t,n]}function Gm(e,t,n,o,r){const a=new Headers(null!=o?o:{});return void 0!==n&&a.set("Connect-Timeout-Ms",`${n}`),a.set(Bm,e==Uf.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set($m,"1"),a}function qm(e,t,n){const o=function(e){const t=null==e?void 0:e.match(Lm);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const r=new ym(`HTTP ${t}`,function(e){switch(e){case 400:return mm.InvalidArgument;case 401:return mm.Unauthenticated;case 403:return mm.PermissionDenied;case 404:return mm.Unimplemented;case 408:return mm.DeadlineExceeded;case 409:return mm.Aborted;case 412:return mm.FailedPrecondition;case 413:case 431:return mm.ResourceExhausted;case 415:return mm.Internal;case 429:case 502:case 503:case 504:return mm.Unavailable;default:return mm.Unknown}}(t),n);if(e==Uf.Unary&&o&&!o.binary)return{isUnaryError:!0,unaryError:r};throw r}return{isUnaryError:!1}}const Ym="application/";function Xm(e,t,n){let o="?connect=v1";const r=e.header.get(Bm);0===(null==r?void 0:r.indexOf(Ym))&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const a=e.header.get(Vm);null!==a&&"identity"!==a&&(o+="&compression="+encodeURIComponent(a),n=!0),n&&(o+="&base64=1"),o+="&message="+function(e,t){return t?Uh.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const i=e.url+o,s=new Headers(e.header);return[$m,Bm,Um,Vm,Hm].forEach((e=>s.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:s})}function Km(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new ym("the operation timed out",mm.DeadlineExceeded))};let o;return void 0!==e&&(e<=0?n():o=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(o)}}(e.timeoutMs),o=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const r of n){if(r.aborted){o.apply(r);break}r.addEventListener("abort",o)}function o(){t.signal.aborted||t.abort(jm(this));for(const e of n)e.removeEventListener("abort",o)}return t}(e.signal,t);return[o.signal,function(e){const r=ym.from(t.aborted?jm(t):e);return o.abort(r),n(),Promise.reject(r)},function(){n(),o.abort()}]}var Jm,Zm,Qm,ep,tp,np;(Zm=Jm||(Jm={}))[Zm.UNSPECIFIED=0]="UNSPECIFIED",Zm[Zm.INACTIVE=1]="INACTIVE",Zm[Zm.PROCESSING=2]="PROCESSING",Zm[Zm.SUCCESS=3]="SUCCESS",Zm[Zm.WARNING=4]="WARNING",Zm[Zm.ERROR=5]="ERROR",zf.util.setEnumType(Jm,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(ep=Qm||(Qm={}))[ep.UNSPECIFIED=0]="UNSPECIFIED",ep[ep.SINGLE=1]="SINGLE",ep[ep.MULTI=2]="MULTI",zf.util.setEnumType(Qm,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(np=tp||(tp={}))[np.UNSPECIFIED=0]="UNSPECIFIED",np[np.INLINE=1]="INLINE",np[np.BLOCK=2]="BLOCK",np[np.INLINE_MASK=3]="INLINE_MASK",zf.util.setEnumType(tp,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const op=class e extends mh{constructor(e){super(),n(this,"threshold",0),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(op,"runtime",zf),n(op,"typeName","exa.language_server_pb.MultilineConfig"),n(op,"fields",zf.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let rp=op;const ap=class e extends mh{constructor(e){super(),n(this,"metadata"),n(this,"document"),n(this,"editorOptions"),n(this,"otherDocuments",[]),n(this,"experimentConfig"),n(this,"modelName",""),n(this,"multilineConfig"),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(ap,"runtime",zf),n(ap,"typeName","exa.language_server_pb.GetCompletionsRequest"),n(ap,"fields",zf.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:rm},{no:2,name:"document",kind:"message",T:bp},{no:3,name:"editor_options",kind:"message",T:im},{no:5,name:"other_documents",kind:"message",T:bp,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:kp},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:rp}])));let ip=ap;const sp=class e extends mh{constructor(e){super(),n(this,"state"),n(this,"completionItems",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(sp,"runtime",zf),n(sp,"typeName","exa.language_server_pb.GetCompletionsResponse"),n(sp,"fields",zf.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:Np},{no:2,name:"completion_items",kind:"message",T:Mp,repeated:!0}])));let lp=sp;const cp=class e extends mh{constructor(e){super(),n(this,"metadata"),n(this,"completionId",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(cp,"runtime",zf),n(cp,"typeName","exa.language_server_pb.AcceptCompletionRequest"),n(cp,"fields",zf.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:rm},{no:2,name:"completion_id",kind:"scalar",T:9}])));let dp=cp;const up=class e extends mh{constructor(e){super(),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(up,"runtime",zf),n(up,"typeName","exa.language_server_pb.AcceptCompletionResponse"),n(up,"fields",zf.util.newFieldList((()=>[])));let hp=up;const fp=class e extends mh{constructor(e){super(),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(fp,"runtime",zf),n(fp,"typeName","exa.language_server_pb.GetAuthTokenRequest"),n(fp,"fields",zf.util.newFieldList((()=>[])));let mp=fp;const pp=class e extends mh{constructor(e){super(),n(this,"authToken",""),n(this,"uuid",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(pp,"runtime",zf),n(pp,"typeName","exa.language_server_pb.GetAuthTokenResponse"),n(pp,"fields",zf.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let gp=pp;const vp=class e extends mh{constructor(e){super(),n(this,"row",Eh.zero),n(this,"col",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(vp,"runtime",zf),n(vp,"typeName","exa.language_server_pb.DocumentPosition"),n(vp,"fields",zf.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let yp=vp;const xp=class e extends mh{constructor(e){super(),n(this,"absolutePath",""),n(this,"relativePath",""),n(this,"text",""),n(this,"editorLanguage",""),n(this,"language",Qf.UNSPECIFIED),n(this,"cursorOffset",Eh.zero),n(this,"cursorPosition"),n(this,"lineEnding",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(xp,"runtime",zf),n(xp,"typeName","exa.language_server_pb.Document"),n(xp,"fields",zf.util.newFieldList((()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:zf.getEnumType(Qf)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:yp},{no:7,name:"line_ending",kind:"scalar",T:9}])));let bp=xp;const wp=class e extends mh{constructor(e){super(),n(this,"forceEnableExperiments",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(wp,"runtime",zf),n(wp,"typeName","exa.language_server_pb.ExperimentConfig"),n(wp,"fields",zf.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:zf.getEnumType(Wf),repeated:!0}])));let kp=wp;const Sp=class e extends mh{constructor(e){super(),n(this,"state",Jm.UNSPECIFIED),n(this,"message",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Sp,"runtime",zf),n(Sp,"typeName","exa.language_server_pb.State"),n(Sp,"fields",zf.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:zf.getEnumType(Jm)},{no:2,name:"message",kind:"scalar",T:9}])));let Np=Sp;const Cp=class e extends mh{constructor(e){super(),n(this,"startOffset",Eh.zero),n(this,"endOffset",Eh.zero),n(this,"startPosition"),n(this,"endPosition"),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Cp,"runtime",zf),n(Cp,"typeName","exa.language_server_pb.Range"),n(Cp,"fields",zf.util.newFieldList((()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:yp},{no:4,name:"end_position",kind:"message",T:yp}])));let Ep=Cp;const jp=class e extends mh{constructor(e){super(),n(this,"text",""),n(this,"deltaCursorOffset",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(jp,"runtime",zf),n(jp,"typeName","exa.language_server_pb.Suffix"),n(jp,"fields",zf.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let _p=jp;const Ip=class e extends mh{constructor(e){super(),n(this,"text",""),n(this,"offset",Eh.zero),n(this,"type",tp.UNSPECIFIED),n(this,"prefix",""),n(this,"line",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Ip,"runtime",zf),n(Ip,"typeName","exa.language_server_pb.CompletionPart"),n(Ip,"fields",zf.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:zf.getEnumType(tp)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let Ap=Ip;const Tp=class e extends mh{constructor(e){super(),n(this,"completion"),n(this,"suffix"),n(this,"range"),n(this,"source",Jf.UNSPECIFIED),n(this,"completionParts",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Tp,"runtime",zf),n(Tp,"typeName","exa.language_server_pb.CompletionItem"),n(Tp,"fields",zf.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:nm},{no:5,name:"suffix",kind:"message",T:_p},{no:2,name:"range",kind:"message",T:Ep},{no:3,name:"source",kind:"enum",T:zf.getEnumType(Jf)},{no:8,name:"completion_parts",kind:"message",T:Ap,repeated:!0}])));let Mp=Tp;const Op={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:ip,O:lp,kind:Uf.Unary},acceptCompletion:{name:"AcceptCompletion",I:dp,O:hp,kind:Uf.Unary},getAuthToken:{name:"GetAuthToken",I:mp,O:gp,kind:Uf.Unary}}};var Dp=function(e){return this instanceof Dp?(this.v=e,this):new Dp(e)},Pp=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof Dp?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};const Rp=function(e){var t;!function(){try{new Headers}catch(e){throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}();const n=null!==(t=e.useBinaryFormat)&&void 0!==t&&t;return{async unary(t,o,r,a,i,s,l){var c;const{serialize:d,parse:u}=Dm(o,n,e.jsonOptions,e.binaryOptions);return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Mm(e.next,e.interceptors),[n,o,r]=Km(e);return t(Object.assign(Object.assign({},e.req),{message:Am(e.req.method.I,e.req.message),signal:n})).then((e=>(r(),e)),o)}({interceptors:e.interceptors,signal:r,timeoutMs:a,req:{stream:!1,service:t,method:o,url:Im(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Gm(o.kind,n,a,i),contextValues:null!=l?l:_m(),message:s},next:async r=>{var a;let i=null;!0===e.useHttpGet&&o.idempotency===Hf.NoSideEffects?r=Xm(r,d(r.message),n):i=d(r.message);const s=null!==(a=e.fetch)&&void 0!==a?a:globalThis.fetch,l=await s(r.url,Object.assign(Object.assign({},r.init),{headers:r.header,signal:r.signal,body:i})),{isUnaryError:c,unaryError:h}=qm(o.kind,l.status,l.headers);if(c)throw zm(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...Wm(l.headers)),h);const[f,m]=Wm(l.headers);return{stream:!1,service:t,method:o,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):o.O.fromJson(await l.json(),Om(e.jsonOptions)),trailer:m}}})},async stream(t,o,r,a,i,s,l){var c;const{serialize:d,parse:u}=Dm(o,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return Pp(this,arguments,(function*(){const o=function(e){let t,n=new Uint8Array(0);function o(e){const t=new Uint8Array(n.length+e.length);t.set(n),t.set(e,n.length),n=t}return new ReadableStream({start(){t=e.getReader()},async pull(e){let r;for(;;){if(void 0===r&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];r={flags:n[0],length:e}}if(void 0!==r&&n.byteLength>=r.length+5)break;const e=await t.read();if(e.done)break;o(e.value)}if(void 0===r)return 0==n.byteLength?void e.close():void e.error(new ym("premature end of stream",mm.DataLoss));const a=n.subarray(5,5+r.length);n=n.subarray(5+r.length),e.enqueue({flags:r.flags,data:a})}})}(e).getReader();let r=!1;for(;;){const e=yield Dp(o.read());if(e.done)break;const{flags:a,data:i}=e.value;if(2&~a)yield yield Dp(u(i));else{r=!0;const e=Fm(i);if(e.error){const t=e.error;throw n.forEach(((e,n)=>{t.metadata.append(n,e)})),t}e.metadata.forEach(((e,n)=>t.set(n,e)))}}if(!r)throw"missing EndStreamResponse"}))}async function f(e){if(o.kind!=Uf.ServerStreaming)throw"The fetch API does not support streaming request bodies";const t=await e[Symbol.asyncIterator]().next();if(1==t.done)throw"missing request message";return function(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const o=new DataView(n.buffer,n.byteOffset,n.byteLength);return o.setUint8(0,e),o.setUint32(1,t.length),n}(0,d(t.value))}return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Mm(e.next,e.interceptors),[n,o,r]=Km(e),a=Object.assign(Object.assign({},e.req),{message:Tm(e.req.method.I,e.req.message),signal:n});let i=!1;return n.addEventListener("abort",(function(){var t,n;const o=e.req.message[Symbol.asyncIterator]();i||null===(t=o.throw)||void 0===t||t.call(o,this.reason).catch((()=>{})),null===(n=o.return)||void 0===n||n.call(o).catch((()=>{}))})),t(a).then((e=>Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator](){const t=e.message[Symbol.asyncIterator]();return{next:()=>t.next().then((e=>(1==e.done&&(i=!0,r()),e)),o)}}}})),o)}({interceptors:e.interceptors,timeoutMs:a,signal:r,req:{stream:!0,service:t,method:o,url:Im(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Gm(o.kind,n,a,i),contextValues:null!=l?l:_m(),message:s},next:async t=>{var n;const r=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,a=await r(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(qm(o.kind,a.status,a.headers),null===a.body)throw"missing response body";const i=new Headers;return Object.assign(Object.assign({},t),{header:a.headers,trailer:i,message:h(a.body,i,a.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Lp=(Fp=Rp,function(e,t){const n={};for(const[o,r]of Object.entries(e.methods)){const a=t(Object.assign(Object.assign({},r),{localName:o,service:e}));null!=a&&(n[o]=a)}return n}(zp=Op,(e=>{switch(e.kind){case Uf.Unary:return function(e,t,n){return async function(o,r){var a,i;const s=await e.unary(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);return null===(a=null==r?void 0:r.onHeader)||void 0===a||a.call(r,s.header),null===(i=null==r?void 0:r.onTrailer)||void 0===i||i.call(r,s.trailer),s.message}}(Fp,zp,e);case Uf.ServerStreaming:return function(e,t,n){return function(o,r){return Em(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,km([o]),null==r?void 0:r.contextValues),r)}}(Fp,zp,e);case Uf.ClientStreaming:return function(e,t,n){return async function(o,r){var a,i,s,l,c,d;const u=await e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);let h;null===(c=null==r?void 0:r.onHeader)||void 0===c||c.call(r,u.header);try{for(var f,m=!0,p=Sm(u.message);!(a=(f=await p.next()).done);m=!0)l=f.value,m=!1,h=l}catch(g){i={error:g}}finally{try{m||a||!(s=p.return)||await s.call(p)}finally{if(i)throw i.error}}if(!h)throw new ym("protocol error: missing response message",mm.Internal);return null===(d=null==r?void 0:r.onTrailer)||void 0===d||d.call(r,u.trailer),h}}(Fp,zp,e);case Uf.BiDiStreaming:return function(e,t,n){return function(o,r){return Em(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues),r)}}(Fp,zp,e);default:return null}})));var zp,Fp;let Bp;try{Bp=crypto.randomUUID()}catch{Bp=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+e/4).toString(16)))}()}async function Up(e,t){const n=e.state.facet(lm),{override:o}=e.state.facet(cm),r=await o(),a=e.state,i=a.selection.main.head,s=a.doc.toString();try{const o=await async function({text:e,cursorOffset:t,config:n,otherDocuments:o}){return await Lp.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Bp,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:o,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Bp}`}})}({text:s,cursorOffset:i,config:n,otherDocuments:r});if(!o||0===o.completionItems.length)return;if(void 0!==t&&i!==t||"active"===Sn(e.state)||!e.hasFocus)return;const l=o.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),o=2===e.type?`\n${e.text}`:e.text,r={absoluteStartPos:t+n,absoluteEndPos:t+n+o.length,from:n,to:n,insert:o};return t+=o.length,r}))})),c=0,d=l.at(c);if(!d)return;const u=Nn.of(d,a.doc.length),h=u.invert(a.doc);e.dispatch({changes:u,effects:th.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function Vp(){let e=null,t=0;return Yt.updateListener.of((n=>{const o=n.view.state.facet(lm);if(!o.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(nh)||e.is(oh)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(um))return!0;if("active"===Sn(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(hm))return!0}(n))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new En(n.view.state,r,!1))||(e=setTimeout((async()=>{r===t&&await Up(n.view,t)}),o.timeout),t=r)}))}function Hp(e){var t;const n=e.state.field(um);if(!n)return!1;const o=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:nh.of(null),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]});let r=0;return null==o||o.iterChangedRanges(((e,t,n,o)=>{r=o})),e.dispatch({changes:o,selection:qt.cursor(r),annotations:[hm.of(null),Cn.addToHistory.of(!0)]}),!0}const $p=e=>{const{state:t}=e,n=t.field(um);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,a=o.at(r);if(!a)return!1;const i=n.reverseChangeSet.apply(t.doc),s=Nn.of(n.reverseChangeSet,t.doc.length).compose(Nn.of(a,i.length)),l=Nn.of(a,i.length).invert(i);return e.dispatch({changes:s,effects:th.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]}),!0};function Wp(e){const t=e.state.field(um);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:oh.of(null),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]}),!1)}function Gp(){return Yt.domEventHandlers({keydown:(e,t)=>("]"!==e.key||!e.ctrlKey)&&("Shift"!==e.key&&"Control"!==e.key&&"Alt"!==e.key&&"Meta"!==e.key&&function(e,t){return!!e.state.field(um)&&("Tab"===t?Hp(e):Wp(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?($p(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let o=!1;const r=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,a=e.state.field(um);return!(void 0===r||!a)&&(null==(n=a.decorations)||n.between(r,r,(()=>{o=!0})),o)}(t)?Hp(t):Wp(t)}})}const qp=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[lm.of(e),um,yn.highest(pn.of([{key:"Ctrl-]",run:$p}])),yn.highest(Yt.updateListener.of((e=>{e.focusChanged&&Wp(e.view)}))),yn.high(Gp()),Vp()]}({apiKey:e.codeium_api_key,language:Qf.PYTHON}),cm.of({override:async()=>[{text:zs(""),language:Qf.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(eh({delay:500,fetchFn:async e=>{if(!Bs())return"";if(0===e.doc.length)return"";await new Promise((e=>setTimeout(e,20)));const t=e.doc.toString(),n=function(e,t){const n=e.doc.toString(),o=t.split("\n").length-n.split("\n").length,r=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return r.line+=o,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:Vs,version:"replace_me",uri:`file://${Vs}`,relativePath:Vs,languageId:Hs,position:r}}}(e,zs(t)),o=function(e,t,n){if(0===e.completions.length)return"";const{displayText:o,position:r}=e.completions[0],a=r.character-t.character,i=a<0?o.slice(-a):o,s=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<i.length;l++){const e=i.slice(l);if(s.startsWith(e))return i.slice(0,l)}return i}(await Us().getCompletion(n),n.doc.position,e);return o&&J.debug("Copilot suggestion:",o),o}})),[...t,Fs().slice(0,-2)]};const Yp=Jt.mark({class:"underline"}),Xp=Xt.define(),Kp=Xt.define(),Jp=Kt.define({create:()=>Jt.none,update(e,t){let n=e.map(t.changes);for(const o of t.effects)o.is(Xp)?n=e.update({add:[Yp.range(o.value.from,o.value.to)]}):o.is(Kp)&&(n=Jt.none);return n},provide:e=>Yt.decorations.from(e)});class Zp{constructor(e,t){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=e=>{"Meta"!==e.key&&"Control"!==e.key||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=e=>{"Meta"!==e.key&&"Control"!==e.key||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=e=>{if(!e.metaKey&&!e.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(null==t)return void this.clearUnderline();const n=jn(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:o}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===o)return;this.clearUnderline(),this.hoveredRange={from:e,to:o,position:t},this.view.dispatch({effects:Xp.of(this.hoveredRange)})}else this.clearUnderline()},this.click=e=>{if(this.hoveredRange){const t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:Kp.of(null)}),this.hoveredRange=null)}}const Qp=({variant:e,settings:t,styles:n})=>{const o=Yt.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:"dark"===e}),r=In.define(n);return[o,An(r)]};Qp({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:Tn.comment,color:"#404080"},{tag:[Tn.string,Tn.regexp],color:"#999999"},{tag:Tn.number,color:"#7090B0"},{tag:[Tn.bool,Tn.null],color:"#8080A0"},{tag:[Tn.punctuation,Tn.derefOperator],color:"#805080"},{tag:Tn.keyword,color:"#60B0FF"},{tag:Tn.definitionKeyword,color:"#B0FFF0"},{tag:Tn.moduleKeyword,color:"#60B0FF"},{tag:Tn.operator,color:"#A0A0FF"},{tag:[Tn.variableName,Tn.self],color:"#008080"},{tag:Tn.operatorKeyword,color:"#A0A0FF"},{tag:Tn.controlKeyword,color:"#80A0FF"},{tag:Tn.className,color:"#70E080"},{tag:[Tn.function(Tn.propertyName),Tn.propertyName],color:"#50A0A0"},{tag:Tn.tagName,color:"#009090"},{tag:Tn.modifier,color:"#B0FFF0"},{tag:[Tn.squareBracket,Tn.attributeName],color:"#D0D0FF"}]}),Qp({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:Tn.comment,color:"#787b8099"},{tag:Tn.string,color:"#86b300"},{tag:Tn.regexp,color:"#4cbf99"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#ffaa33"},{tag:Tn.variableName,color:"#5c6166"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#fa8d3e"},{tag:[Tn.keyword,Tn.special(Tn.brace)],color:"#fa8d3e"},{tag:Tn.operator,color:"#ed9366"},{tag:Tn.separator,color:"#5c6166b3"},{tag:Tn.punctuation,color:"#5c6166"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#f2ae49"},{tag:[Tn.className,Tn.definition(Tn.typeName)],color:"#22a4e6"},{tag:[Tn.tagName,Tn.typeName,Tn.self,Tn.labelName],color:"#55b4d4"},{tag:Tn.angleBracket,color:"#55b4d480"},{tag:Tn.attributeName,color:"#f2ae49"}]}),Qp({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:Tn.comment,color:"#6E6E6E"},{tag:[Tn.string,Tn.regexp,Tn.special(Tn.brace)],color:"#5C81B3"},{tag:Tn.number,color:"#C1E1B8"},{tag:Tn.bool,color:"#53667D"},{tag:[Tn.definitionKeyword,Tn.modifier,Tn.function(Tn.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[Tn.keyword,Tn.moduleKeyword,Tn.operatorKeyword,Tn.operator],color:"#697A8E",fontWeight:"bold"},{tag:[Tn.variableName,Tn.attributeName],color:"#708E67"},{tag:[Tn.function(Tn.variableName),Tn.definition(Tn.propertyName),Tn.derefOperator],color:"#fff"},{tag:Tn.tagName,color:"#A3D295"}]}),Qp({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:Tn.comment,color:"#666666"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#54BE0D"},{tag:Tn.regexp,color:"#E9C062"},{tag:Tn.number,color:"#CF6A4C"},{tag:[Tn.keyword,Tn.operator],color:"#5EA6EA"},{tag:Tn.variableName,color:"#7587A6"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#F9EE98"},{tag:[Tn.propertyName,Tn.function(Tn.variableName)],color:"#937121"},{tag:[Tn.typeName,Tn.angleBracket,Tn.tagName],color:"#9B859D"}]}),Qp({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:Tn.comment,color:"#6B4E32"},{tag:[Tn.keyword,Tn.operator,Tn.derefOperator],color:"#EF5D32"},{tag:Tn.className,color:"#EFAC32",fontWeight:"bold"},{tag:[Tn.typeName,Tn.propertyName,Tn.function(Tn.variableName),Tn.definition(Tn.variableName)],color:"#EFAC32"},{tag:Tn.definition(Tn.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:Tn.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[Tn.number,Tn.bool],color:"#6C99BB"},{tag:[Tn.variableName,Tn.self],color:"#7DAF9C"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#D9D762"},{tag:[Tn.angleBracket,Tn.tagName,Tn.attributeName],color:"#EFCB43"}]}),Qp({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:Tn.comment,color:"#404040"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#00D8FF"},{tag:Tn.number,color:"#E62286"},{tag:[Tn.variableName,Tn.attributeName,Tn.self],color:"#E62286",fontWeight:"bold"},{tag:Tn.function(Tn.variableName),color:"#fff",fontWeight:"bold"}]}),Qp({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:Tn.comment,color:"#BCC8BA"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#5D90CD"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#46A609"},{tag:Tn.keyword,color:"#AF956F"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#C52727"},{tag:[Tn.angleBracket,Tn.tagName,Tn.attributeName],color:"#606060"},{tag:Tn.self,color:"#000"}]}),Qp({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:Tn.comment,color:"#0088FF"},{tag:Tn.string,color:"#3AD900"},{tag:Tn.regexp,color:"#80FFC2"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#FF628C"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#FFEE80"},{tag:Tn.variableName,color:"#CCCCCC"},{tag:Tn.self,color:"#FF80E1"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.definition(Tn.typeName),Tn.labelName],color:"#FFDD00"},{tag:[Tn.keyword,Tn.operator],color:"#FF9D00"},{tag:[Tn.propertyName,Tn.typeName],color:"#80FFBB"},{tag:Tn.special(Tn.brace),color:"#EDEF7D"},{tag:Tn.attributeName,color:"#9EFFFF"},{tag:Tn.derefOperator,color:"#fff"}]}),Qp({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:Tn.comment,color:"#AEAEAE"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#8DFF8E"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.function(Tn.definition(Tn.variableName)),Tn.definition(Tn.typeName)],color:"#A3EBFF"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#62E9BD"},{tag:[Tn.keyword,Tn.operator],color:"#2BF1DC"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#F8FBB1"},{tag:[Tn.variableName,Tn.self],color:"#B683CA"},{tag:[Tn.angleBracket,Tn.tagName,Tn.typeName,Tn.propertyName],color:"#60A4F1"},{tag:Tn.derefOperator,color:"#E0E0E0"},{tag:Tn.attributeName,color:"#7BACCA"}]}),Qp({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:Tn.comment,color:"#6272a4"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#f1fa8c"},{tag:[Tn.number,Tn.self,Tn.bool,Tn.null],color:"#bd93f9"},{tag:[Tn.keyword,Tn.operator],color:"#ff79c6"},{tag:[Tn.definitionKeyword,Tn.typeName],color:"#8be9fd"},{tag:Tn.definition(Tn.typeName),color:"#f8f8f2"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.attributeName],color:"#50fa7b"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:Tn.comment,color:"#AAAAAA"},{tag:[Tn.keyword,Tn.operator,Tn.typeName,Tn.tagName,Tn.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[Tn.attributeName,Tn.definition(Tn.propertyName)],color:"#4F9FD0"},{tag:[Tn.className,Tn.string,Tn.special(Tn.brace)],color:"#CF4F5F"},{tag:Tn.number,color:"#CF4F5F",fontWeight:"bold"},{tag:Tn.variableName,fontWeight:"bold"}]}),Qp({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:Tn.comment,color:"#9995b7"},{tag:Tn.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#ff5792"},{tag:[Tn.className,Tn.tagName,Tn.definition(Tn.typeName)],color:"#0094f0"},{tag:[Tn.number,Tn.bool,Tn.null,Tn.special(Tn.brace)],color:"#5842ff"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#0095a8"},{tag:Tn.typeName,color:"#b3694d"},{tag:[Tn.propertyName,Tn.variableName],color:"#fa8900"},{tag:Tn.operator,color:"#ff5792"},{tag:Tn.self,color:"#e64100"},{tag:[Tn.string,Tn.regexp],color:"#00b368"},{tag:[Tn.paren,Tn.bracket],color:"#0431fa"},{tag:Tn.labelName,color:"#00bdd6"},{tag:Tn.attributeName,color:"#e64100"},{tag:Tn.angleBracket,color:"#9995b7"}]}),Qp({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:Tn.comment,color:"#9893a5"},{tag:[Tn.bool,Tn.null],color:"#286983"},{tag:Tn.number,color:"#d7827e"},{tag:Tn.className,color:"#d7827e"},{tag:[Tn.angleBracket,Tn.tagName,Tn.typeName],color:"#56949f"},{tag:Tn.attributeName,color:"#907aa9"},{tag:Tn.punctuation,color:"#797593"},{tag:[Tn.keyword,Tn.modifier],color:"#286983"},{tag:[Tn.string,Tn.regexp],color:"#ea9d34"},{tag:Tn.variableName,color:"#d7827e"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:Tn.comment,color:"#CFCFCF"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#E66C29"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.labelName,Tn.definition(Tn.typeName)],color:"#2EB43B"},{tag:Tn.keyword,color:"#D8B229"},{tag:Tn.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#925A47"},{tag:Tn.string,color:"#704D3D"},{tag:Tn.typeName,color:"#2F8996"},{tag:[Tn.variableName,Tn.propertyName],color:"#77ACB0"},{tag:Tn.self,color:"#77ACB0",fontWeight:"bold"},{tag:Tn.regexp,color:"#E3965E"},{tag:[Tn.tagName,Tn.angleBracket],color:"#BAA827"},{tag:Tn.attributeName,color:"#B06520"},{tag:Tn.derefOperator,color:"#000"}]}),Qp({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:Tn.comment,color:"#93A1A1"},{tag:Tn.string,color:"#2AA198"},{tag:Tn.regexp,color:"#D30102"},{tag:Tn.number,color:"#D33682"},{tag:Tn.variableName,color:"#268BD2"},{tag:[Tn.keyword,Tn.operator,Tn.punctuation],color:"#859900"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#073642",fontWeight:"bold"},{tag:[Tn.className,Tn.self,Tn.definition(Tn.propertyName)],color:"#268BD2"},{tag:Tn.function(Tn.variableName),color:"#268BD2"},{tag:[Tn.bool,Tn.null],color:"#B58900"},{tag:Tn.tagName,color:"#268BD2",fontWeight:"bold"},{tag:Tn.angleBracket,color:"#93A1A1"},{tag:Tn.attributeName,color:"#93A1A1"},{tag:Tn.typeName,color:"#859900"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:Tn.comment,color:"#8E908C"},{tag:[Tn.variableName,Tn.self,Tn.propertyName,Tn.attributeName,Tn.regexp],color:"#C82829"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#F5871F"},{tag:[Tn.className,Tn.typeName,Tn.definition(Tn.typeName)],color:"#C99E00"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#718C00"},{tag:Tn.operator,color:"#3E999F"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#4271AE"},{tag:Tn.keyword,color:"#8959A8"},{tag:Tn.derefOperator,color:"#4D4D4C"}]});const eg=Qp({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:Tn.comment,color:"#708090"},{tag:Tn.variableName,color:"#000000"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#a11"},{tag:Tn.number,color:"#164"},{tag:Tn.bool,color:"#219"},{tag:Tn.null,color:"#219"},{tag:Tn.keyword,color:"#708",fontWeight:500},{tag:Tn.className,color:"#00f"},{tag:Tn.definition(Tn.typeName),color:"#00f"},{tag:Tn.typeName,color:"#085"},{tag:Tn.angleBracket,color:"#000000"},{tag:Tn.tagName,color:"#170"},{tag:Tn.attributeName,color:"#00c"},{tag:Tn.operator,color:"#a2f",fontWeight:500},{tag:[Tn.function(Tn.variableName)],color:"#00c"},{tag:[Tn.propertyName],color:"#05a"}]});const tg=e=>{const{theme:t,hotkeys:n,completionConfig:o}=e;return[Yt.lineWrapping,Rn(),Ln(),zn(),Fn(),Bn(),Un(),Vn(),Hn({position:"fixed",parent:document.querySelector("#App")??void 0}),$n(),"dark"===t?Wn:eg,Gn(),qp(o),qn(),Yn(),yn.high(pn.of(Xn)),Kn(),Jn(),Zn.of(" "),An(Qn,{fallback:!0}),pn.of(eo),to(e),no.of(oo()),ro.allowMultipleSelections.of(!0),$u(n),pn.of([{key:"Tab",run:e=>ao(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const o=e.state.doc.lineAt(n);return""!==o.text.slice(0,n-o.from).trim()&&co(e)})(e)||io(e),preventDefault:!0}]),pn.of([...so,lo])]};function ng(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}const og="ContextMenu",[rg,ag]=uo(og,[ho]),ig=ho(),[sg,lg]=rg(og),cg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:o=!1,...a}=e,i=lg("ContextMenuTrigger",n),s=ig(n),l=r.useRef({x:0,y:0}),c=r.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=r.useRef(0),u=r.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{l.current={x:e.clientX,y:e.clientY},i.onOpenChange(!0)};return r.useEffect((()=>u),[u]),r.useEffect((()=>{o&&u()}),[o,u]),r.createElement(r.Fragment,null,r.createElement(Co,mo({},s,{virtualRef:c})),r.createElement(Eo.span,mo({"data-state":i.open?"open":"closed","data-disabled":o?"":void 0},a,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:o?e.onContextMenu:jo(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:o?e.onPointerDown:jo(e.onPointerDown,dg((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:o?e.onPointerMove:jo(e.onPointerMove,dg(u)),onPointerCancel:o?e.onPointerCancel:jo(e.onPointerCancel,dg(u)),onPointerUp:o?e.onPointerUp:jo(e.onPointerUp,dg(u))})))}));function dg(e){return t=>"mouse"!==t.pointerType?e(t):void 0}const ug=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=lg("ContextMenuContent",n),i=ig(n),s=r.useRef(!1);return r.createElement(po,mo({},i,o,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&s.current&&t.preventDefault(),s.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||a.modal||(s.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),hg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(go,mo({},a,o,{ref:t}))})),fg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(vo,mo({},a,o,{ref:t}))})),mg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(yo,mo({},a,o,{ref:t}))})),pg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(xo,mo({},a,o,{ref:t}))})),gg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(_o,mo({},a,o,{ref:t}))})),vg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(bo,mo({},a,o,{ref:t}))})),yg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(wo,mo({},a,o,{ref:t}))})),xg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(ko,mo({},a,o,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),bg=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:o,dir:a,modal:i=!0}=e,[s,l]=r.useState(!1),c=ig(t),d=So(o),u=r.useCallback((e=>{l(e),d(e)}),[d]);return r.createElement(sg,{scope:t,open:s,onOpenChange:u,modal:i},r.createElement(No,mo({},c,{dir:a,open:s,onOpenChange:u,modal:i}),n))},wg=cg,kg=Io((e=>{const{__scopeContextMenu:t,...n}=e,o=ig(t);return r.createElement(fo,mo({},o,n))}));r.forwardRef(((e,t)=>{const n=b(14);let o,r,a,i,s,l,c;return n[0]!==e?(({className:o,inset:r,children:i,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o||n[6]!==r?(s=Ao({className:o,inset:r}),n[5]=o,n[6]=r,n[7]=s):s=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Lo,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==t||n[10]!==s||n[11]!==a||n[12]!==i?(c=k.jsxs(yg,{ref:t,className:s,...a,children:[i,l]}),n[9]=t,n[10]=s,n[11]=a,n[12]=i,n[13]=c):c=n[13],c})).displayName=yg.displayName;const Sg="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(To({subcontent:!0}),Sg,o),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(xg,{ref:t,className:a,...r}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i})).displayName=xg.displayName;const Ng=r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(To(),Sg,o),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(kg,{children:k.jsx(Mo,{children:k.jsx(ug,{ref:t,className:a,...r})})}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i}));Ng.displayName=ug.displayName;const Cg=r.forwardRef(((e,t)=>{const n=b(13);let o,r,a,i,s,l;return n[0]!==e?(({className:o,inset:r,variant:a,...i}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o||n[6]!==r||n[7]!==a?(s=Oo({className:o,inset:r,variant:a}),n[5]=o,n[6]=r,n[7]=a,n[8]=s):s=n[8],n[9]!==t||n[10]!==s||n[11]!==i?(l=k.jsx(fg,{ref:t,className:s,...i}),n[9]=t,n[10]=s,n[11]=i,n[12]=l):l=n[12],l}));Cg.displayName=fg.displayName;r.forwardRef(((e,t)=>{const n=b(15);let o,r,a,i,s,l,c,d;return n[0]!==e?(({className:o,children:i,checked:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o?(s=Do({className:o}),n[5]=o,n[6]=s):s=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=Do(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("span",{className:l,children:k.jsx(gg,{children:k.jsx(zo,{className:"h-4 w-4"})})}),n[8]=c):c=n[8],n[9]!==t||n[10]!==s||n[11]!==r||n[12]!==a||n[13]!==i?(d=k.jsxs(mg,{ref:t,className:s,checked:r,...a,children:[c,i]}),n[9]=t,n[10]=s,n[11]=r,n[12]=a,n[13]=i,n[14]=d):d=n[14],d})).displayName=mg.displayName;r.forwardRef(((e,t)=>{const n=b(13);let o,r,a,i,s,l,c;return n[0]!==e?(({className:o,children:a,...r}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o?(i=Do({className:o}),n[4]=o,n[5]=i):i=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(s=Do(),n[6]=s):s=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx("span",{className:s,children:k.jsx(gg,{children:k.jsx(Fo,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==t||n[9]!==i||n[10]!==r||n[11]!==a?(c=k.jsxs(pg,{ref:t,className:i,...r,children:[l,a]}),n[8]=t,n[9]=i,n[10]=r,n[11]=a,n[12]=c):c=n[12],c})).displayName=pg.displayName;r.forwardRef(((e,t)=>{const n=b(11);let o,r,a,i,s;return n[0]!==e?(({className:o,inset:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o||n[5]!==r?(i=Po({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=i):i=n[6],n[7]!==t||n[8]!==i||n[9]!==a?(s=k.jsx(hg,{ref:t,className:i,...a}),n[7]=t,n[8]=i,n[9]=a,n[10]=s):s=n[10],s})).displayName=hg.displayName;const Eg=r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(Ro({className:o})),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(vg,{ref:t,className:a,...r}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i}));Eg.displayName=vg.displayName;const jg=e=>{const t=b(14),{appClosed:n,onClick:o,tooltipContent:r}=e;let a;t[0]!==o?(a=()=>null==o?void 0:o({code:""}),t[0]=o,t[1]=a):a=t[1];const i=n&&" inactive-button";let s,l,c,d,u;return t[2]!==i?(s=rn("shoulder-button hover-action",i),t[2]=i,t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Bo,{strokeWidth:1.8}),t[4]=l):l=t[4],t[5]!==a||t[6]!==s?(c=k.jsx(Es,{onClick:a,className:s,onMouseDown:tt.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:l}),t[5]=a,t[6]=s,t[7]=c):c=t[7],t[8]!==r||t[9]!==c?(d=k.jsx(N,{content:r,usePortal:!1,children:c}),t[8]=r,t[9]=c,t[10]=d):d=t[10],t[11]!==o||t[12]!==d?(u=k.jsx(_g,{onClick:o,children:d}),t[11]=o,t[12]=d,t[13]=u):u=t[13],u},_g=e=>{const t=b(24),{children:n,onClick:o}=e;if(!o)return n;let r,a,i,s,l,c,d,u,h,f,m,p;return t[0]!==n?(r=k.jsx(wg,{children:n}),t[0]=n,t[1]=r):r=t[1],t[2]!==o?(a=e=>{e.stopPropagation(),o({code:""})},t[2]=o,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(As,{})}),t[4]=i):i=t[4],t[5]!==a?(s=k.jsxs(Cg,{onSelect:a,children:[i,"Python cell"]},"python"),t[5]=a,t[6]=s):s=t[6],t[7]!==o?(l=e=>{e.stopPropagation(),o({code:(new Uo).defaultCode})},t[7]=o,t[8]=l):l=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(Is,{})}),t[9]=c):c=t[9],t[10]!==l?(d=k.jsxs(Cg,{onSelect:l,children:[c,"Markdown cell"]},"markdown"),t[10]=l,t[11]=d):d=t[11],t[12]!==o?(u=e=>{e.stopPropagation(),o({code:(new Vo).defaultCode})},t[12]=o,t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(ke,{size:13,strokeWidth:1.5})}),t[14]=h):h=t[14],t[15]!==u?(f=k.jsxs(Cg,{onSelect:u,children:[h,"SQL cell"]},"sql"),t[15]=u,t[16]=f):f=t[16],t[17]!==s||t[18]!==d||t[19]!==f?(m=k.jsxs(Ng,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=m):m=t[20],t[21]!==r||t[22]!==m?(p=k.jsxs(bg,{children:[r,m]}),t[21]=r,t[22]=m,t[23]=p):p=t[23],p},Ig=Ho("rounded-full shadow-xsSolid border p-[5px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-[var(--yellow-3)] hover:bg-[var(--yellow-4)] text-[var(--yellow-11)]",green:"hover:bg-[var(--grass-2)] hover:text-[var(--grass-11)] hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-[var(--red-3)] hover:text-[var(--red-11)]"}},defaultVariants:{variant:"default"}}),Ag=e=>{const t=b(21);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,disabled:n,variant:r,...o}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=void 0!==n&&n;let l,c,d;t[6]!==s||t[7]!==o.onClick?(l=e=>{var t;s||null==(t=o.onClick)||t.call(o,e)},t[6]=s,t[7]=o.onClick,t[8]=l):l=t[8],t[9]!==r||t[10]!==o.className?(c=rn(Ig({variant:r}),o.className),t[9]=r,t[10]=o.className,t[11]=c):c=t[11],t[12]!==s||t[13]!==o||t[14]!==l||t[15]!==c||t[16]!==a?(d=k.jsx("button",{disabled:s,...o,onClick:l,onMouseDown:tt.preventFocus,className:c,children:a}),t[12]=s,t[13]=o,t[14]=l,t[15]=c,t[16]=a,t[17]=d):d=t[17];const u=d;if(i){let e;return t[18]!==i||t[19]!==u?(e=k.jsx(N,{content:i,side:"top",delayDuration:200,usePortal:!1,children:u}),t[18]=i,t[19]=u,t[20]=e):e=t[20],e}return u},Tg=({children:e,className:t})=>k.jsx(rd,{className:rn("flex items-center gap-1 bg-background m-[2px] rounded-full",t),children:e});const Mg=e=>{const t=b(22),{onClick:n,appClosed:o,needsRun:r,status:a,config:i,edited:s}=e,l="disabled-transitively"===a,c="running"===a||"queued"===a,d=o||c||!i.disabled&&l&&!s;let u;t[0]!==o||t[1]!==r||t[2]!==c||t[3]!==d?(u=function(e,t,n,o){return e?"disabled":t&&!n?"stale":n||o?"disabled":"green"}(o,r,c,d),t[0]=o,t[1]=r,t[2]=c,t[3]=d,t[4]=u):u=t[4];const h=u;if(i.disabled){let e,o;return t[5]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(hc,{}),t[5]=e):e=t[5],t[6]!==d||t[7]!==n||t[8]!==h?(o=k.jsx(Ag,{tooltip:"Add code to notebook",disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:e}),t[6]=d,t[7]=n,t[8]=h,t[9]=o):o=t[9],o}if(!i.disabled&&l&&!s){let e,o;return t[10]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Ac,{strokeWidth:1.2}),t[10]=e):e=t[10],t[11]!==d||t[12]!==n||t[13]!==h?(o=k.jsx(Ag,{disabled:d,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:h,"data-testid":"run-button",children:e}),t[11]=d,t[12]=n,t[13]=h,t[14]=o):o=t[14],o}let f,m,p;if(o)f="App disconnected";else if("queued"===a)f="This cell is already queued to run";else if("running"===a)f="This cell is already running.";else{let e;t[15]===Symbol.for("react.memo_cache_sentinel")?(e=S("cell.run"),t[15]=e):e=t[15],f=e}return t[16]===Symbol.for("react.memo_cache_sentinel")?(m=k.jsx(Ac,{strokeWidth:1.2}),t[16]=m):m=t[16],t[17]!==f||t[18]!==d||t[19]!==n||t[20]!==h?(p=k.jsx(Ag,{tooltip:f,disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:m}),t[17]=f,t[18]=d,t[19]=n,t[20]=h,t[21]=p):p=t[21],p},Og=e=>{const t=b(10),{status:n,appClosed:o,onClick:r}=e;let a;a=o?"App disconnected":"running"===n?"A cell can't be deleted when it's running":"queued"===n?"A cell can't be deleted when it's queued to run":"Delete";const i=a,s=(o||("running"===n||"queued"===n))&&"inactive-button";let l,c,d,u,h;return t[0]!==s?(l=rn("hover:bg-transparent text-destructive/60 hover:text-destructive",s),t[0]=s,t[1]=l):l=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(c={boxShadow:"none"},d=k.jsx(je,{size:14}),t[2]=c,t[3]=d):(c=t[2],d=t[3]),t[4]!==r||t[5]!==l?(u=k.jsx(C,{variant:"ghost",size:"icon",onClick:r,"data-testid":"delete-button",onMouseDown:tt.preventFocus,className:l,style:c,children:d}),t[4]=r,t[5]=l,t[6]=u):u=t[6],t[7]!==a||t[8]!==u?(h=k.jsx(N,{content:i,usePortal:!1,children:u}),t[7]=a,t[8]=u,t[9]=h):h=t[9],h};const Dg=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),Pg=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),Rg=e=>{const t=b(79),{editing:n,status:o,disabled:r,staleInputs:a,edited:i,interrupted:s,elapsedTime:l,runStartTimestamp:c,lastRunStartTimestamp:d,uninstantiated:u}=e;if(!n)return null;const h=c??d;let f;t[0]!==h?(f=h?k.jsx(zg,{lastRanTime:h}):null,t[0]=h,t[1]=f):f=t[1];const m=f;if(r&&"running"===o)return J.error("CellStatusComponent: disabled and running"),null;if(r&&a){let e,n,o,r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),t[2]=e):e=t[2],t[3]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[3]=m,t[4]=n):n=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:k.jsxs(bd,{children:[k.jsx($l,{className:"h-5 w-5",strokeWidth:1.5}),k.jsx(Wo,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[5]=o):o=t[5],t[6]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[6]=n,t[7]=r):r=t[7],r}if(r){let e,n,o,r;return t[8]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is disabled"}),t[8]=e):e=t[8],t[9]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[9]=m,t[10]=n):n=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:k.jsx($l,{className:"h-5 w-5",strokeWidth:1.5})}),t[11]=o):o=t[11],t[12]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[12]=n,t[13]=r):r=t[13],r}if(!a&&"disabled-transitively"===o){let e,n,o,r;return t[14]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),t[14]=e):e=t[14],t[15]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[15]=m,t[16]=n):n=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:k.jsxs(bd,{layerTop:!0,children:[k.jsx(Qc,{className:"h-5 w-5",strokeWidth:1.5}),k.jsx($l,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[17]=o):o=t[17],t[18]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[18]=n,t[19]=r):r=t[19],r}if(a&&"disabled-transitively"===o){let e,n,o,r;return t[20]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),t[20]=e):e=t[20],t[21]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[21]=m,t[22]=n):n=t[22],t[23]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:k.jsxs(bd,{children:[k.jsx(Wo,{className:"h-5 w-5",strokeWidth:1}),k.jsx($l,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[23]=o):o=t[23],t[24]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[24]=n,t[25]=r):r=t[25],r}if("running"===o){let e,n,o,r,a;return t[26]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is running"}),t[26]=e):e=t[26],t[27]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[27]=m,t[28]=n):n=t[28],t[29]!==c?(o=$o.fromSeconds(c)||$o.now(),t[29]=c,t[30]=o):o=t[30],t[31]!==o?(r=k.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:k.jsx(Bg,{startTime:o})}),t[31]=o,t[32]=r):r=t[32],t[33]!==n||t[34]!==r?(a=k.jsx(N,{content:n,usePortal:!1,children:r}),t[33]=n,t[34]=r,t[35]=a):a=t[35],a}if("queued"===o){let e,n,o,r;return t[36]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is queued to run"}),t[36]=e):e=t[36],t[37]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[37]=m,t[38]=n):n=t[38],t[39]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:k.jsx(hl,{className:"h-5 w-5",strokeWidth:1.5})}),t[39]=o):o=t[39],t[40]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[40]=n,t[41]=r):r=t[41],r}if(i||s||a||u){let e;t[42]!==l?(e=Fg(l),t[42]=l,t[43]=e):e=t[43];const n=e;let o;t[44]!==l||t[45]!==n?(o=l?k.jsx(Lg,{elapsedTime:n}):null,t[44]=l,t[45]=n,t[46]=o):o=t[46];const r=o;let a,c,d,h,f,p="";if(u)a="This cell has not yet been run";else if(s){let e;a="This cell was interrupted when it was last run",t[47]!==r?(e=k.jsxs("span",{children:["This cell ran for ",r," before being interrupted"]}),t[47]=r,t[48]=e):e=t[48],p=e}else if(i){let e;a="This cell has been modified since it was last run",t[49]!==r?(e=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[49]=r,t[50]=e):e=t[50],p=e}else{let e;a="This cell has not been run with the latest inputs",t[51]!==r?(e=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[51]=r,t[52]=e):e=t[52],p=e}return t[53]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:k.jsx(Wo,{className:"h-5 w-5",strokeWidth:1.5})}),t[53]=c):c=t[53],t[54]!==a?(d=k.jsx(N,{content:a,usePortal:!1,children:c}),t[54]=a,t[55]=d):d=t[55],t[56]!==l||t[57]!==p||t[58]!==m||t[59]!==n?(h=l&&k.jsx(N,{content:k.jsxs("div",{className:"flex flex-col gap-1",children:[p,m]}),usePortal:!1,children:k.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:k.jsx("span",{children:n})})}),t[56]=l,t[57]=p,t[58]=m,t[59]=n,t[60]=h):h=t[60],t[61]!==d||t[62]!==h?(f=k.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[d,h]}),t[61]=d,t[62]=h,t[63]=f):f=t[63],f}if(null!==l){let e;t[64]!==l?(e=Fg(l),t[64]=l,t[65]=e):e=t[65];const n=e;let o;t[66]!==l||t[67]!==n?(o=l?k.jsx(Lg,{elapsedTime:n}):null,t[66]=l,t[67]=n,t[68]=o):o=t[68];const r=o;let a,i,s,c;return t[69]!==r?(a=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[69]=r,t[70]=a):a=t[70],t[71]!==a||t[72]!==m?(i=k.jsxs("div",{className:"flex flex-col gap-1",children:[a,m]}),t[71]=a,t[72]=m,t[73]=i):i=t[73],t[74]!==n?(s=k.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:k.jsx("span",{children:n})}),t[74]=n,t[75]=s):s=t[75],t[76]!==i||t[77]!==s?(c=k.jsx(N,{content:i,usePortal:!1,children:s}),t[76]=i,t[77]=s,t[78]=c):c=t[78],c}return null},Lg=e=>{const t=b(2);let n;return t[0]!==e.elapsedTime?(n=k.jsx("span",{className:"tracking-wide font-semibold",children:e.elapsedTime}),t[0]=e.elapsedTime,t[1]=n):n=t[1],n},zg=e=>{const t=b(18),n=1e3*e.lastRanTime;let o,r,a,i,s,l,c,d,u;if(t[0]!==n){const e=new Date(n),d=new Date,u=e.toDateString()===d.toDateString()?Dg:Pg;i="Ran at",s=" ",l=k.jsx("strong",{className:"tracking-wide font-semibold",children:u.format(e)}),c=" ",o="text-muted-foreground",r="(",a=cd(e),t[0]=n,t[1]=o,t[2]=r,t[3]=a,t[4]=i,t[5]=s,t[6]=l,t[7]=c}else o=t[1],r=t[2],a=t[3],i=t[4],s=t[5],l=t[6],c=t[7];return t[8]!==o||t[9]!==r||t[10]!==a?(d=k.jsxs("span",{className:o,children:[r,a," ago)"]}),t[8]=o,t[9]=r,t[10]=a,t[11]=d):d=t[11],t[12]!==i||t[13]!==s||t[14]!==l||t[15]!==c||t[16]!==d?(u=k.jsxs("span",{children:[i,s,l,c,d]}),t[12]=i,t[13]=s,t[14]=l,t[15]=c,t[16]=d,t[17]=u):u=t[17],u};function Fg(e){if(null===e)return"";if(e>6e4){const t=(e/6e4).toFixed(0),n=(e%6e4/1e3).toFixed(0);return`${t.toString()}m${n.toString()}s`}return e>1e3?`${(e/1e3).toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`}const Bg=e=>{const t=b(6);let n;t[0]!==e.startTime?(n=e.startTime.toMilliseconds(),t[0]=e.startTime,t[1]=n):n=t[1];const o=function(e){const t=r.useRef(e),[n,o]=r.useState(e);return r.useEffect((()=>{const e=setInterval((()=>{o($o.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(n);let a,i;return t[2]!==o?(a=Fg(o),t[2]=o,t[3]=a):a=t[3],t[4]!==a?(i=k.jsx("span",{children:a}),t[4]=a,t[5]=i):i=t[5],i};function Ug(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const Vg={display:"none"};function Hg(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Vg},n)}function $g(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const Wg=r.createContext(null);const Gg={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},qg={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Yg(e){let{announcements:t=qg,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=Gg}=e;const{announce:i,announcement:s}=function(){const[e,t]=r.useState("");return{announce:r.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=Zo("DndLiveRegion"),[c,d]=r.useState(!1);if(r.useEffect((()=>{d(!0)}),[]),function(e){const t=r.useContext(Wg);r.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(r.useMemo((()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:o}=e;t.onDragMove&&i(t.onDragMove({active:n,over:o}))},onDragOver(e){let{active:n,over:o}=e;i(t.onDragOver({active:n,over:o}))},onDragEnd(e){let{active:n,over:o}=e;i(t.onDragEnd({active:n,over:o}))},onDragCancel(e){let{active:n,over:o}=e;i(t.onDragCancel({active:n,over:o}))}})),[i,t])),!c)return null;const h=u.createElement(u.Fragment,null,u.createElement(Hg,{id:o,value:a.draggable}),u.createElement($g,{id:l,announcement:s}));return n?er.createPortal(h,n):h}var Xg,Kg;function Jg(){}function Zg(e,t){return r.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(Kg=Xg||(Xg={})).DragStart="dragStart",Kg.DragMove="dragMove",Kg.DragEnd="dragEnd",Kg.DragCancel="dragCancel",Kg.DragOver="dragOver",Kg.RegisterDroppable="registerDroppable",Kg.SetDroppableDisabled="setDroppableDisabled",Kg.UnregisterDroppable="unregisterDroppable";const Qg=Object.freeze({x:0,y:0});function ev(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function tv(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function nv(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function ov(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function rv(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function av(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const iv=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=av(t,t.left,t.top),a=[];for(const i of o){const{id:e}=i,t=n.get(e);if(t){const n=ev(av(t),r);a.push({id:e,data:{droppableContainer:i,value:n}})}}return a.sort(tv)};function sv(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),i=r-o,s=a-n;if(o<r&&n<a){const n=t.width*t.height,o=e.width*e.height,r=i*s;return Number((r/(n+o-r)).toFixed(4))}return 0}const lv=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const a of o){const{id:e}=a,o=n.get(e);if(o){const n=sv(o,t);n>0&&r.push({id:e,data:{droppableContainer:a,value:n}})}}return r.sort(nv)};function cv(e,t){const{top:n,left:o,bottom:r,right:a}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=a}function dv(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qg}function uv(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const hv=uv(1);const fv={ignoreTransform:!1};function mv(e,t){void 0===t&&(t=fv);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:o}=Go(e).getComputedStyle(e);t&&(n=function(e,t,n){const o=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!o)return e;const{scaleX:r,scaleY:a,x:i,y:s}=o,l=e.left-i-(1-r)*parseFloat(n),c=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=a?e.height/a:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,o))}const{top:o,left:r,width:a,height:i,bottom:s,right:l}=n;return{top:o,left:r,width:a,height:i,bottom:s,right:l}}function pv(e){return mv(e,{ignoreTransform:!0})}function gv(e,t){const n=[];return e?function o(r){if(null!=t&&n.length>=t)return n;if(!r)return n;if(cr(r)&&null!=r.scrollingElement&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!ir(r)||dr(r))return n;if(n.includes(r))return n;const a=Go(e).getComputedStyle(r);return r!==e&&function(e,t){void 0===t&&(t=Go(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const o=t[e];return"string"==typeof o&&n.test(o)}))}(r,a)&&n.push(r),function(e,t){return void 0===t&&(t=Go(e).getComputedStyle(e)),"fixed"===t.position}(r,a)?n:o(r.parentNode)}(e):n}function vv(e){const[t]=gv(e,1);return null!=t?t:null}function yv(e){return ar&&e?ur(e)?e:hr(e)?cr(e)||e===qo(e).scrollingElement?window:ir(e)?e:null:null:null}function xv(e){return ur(e)?e.scrollX:e.scrollLeft}function bv(e){return ur(e)?e.scrollY:e.scrollTop}function wv(e){return{x:xv(e),y:bv(e)}}var kv,Sv;function Nv(e){return!(!ar||!e)&&e===document.scrollingElement}function Cv(e){const t={x:0,y:0},n=Nv(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=o.y,isRight:e.scrollLeft>=o.x,maxScroll:o,minScroll:t}}(Sv=kv||(kv={}))[Sv.Forward=1]="Forward",Sv[Sv.Backward=-1]="Backward";const Ev={x:.2,y:.2};function jv(e,t,n,o,r){let{top:a,left:i,right:s,bottom:l}=n;void 0===o&&(o=10),void 0===r&&(r=Ev);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=Cv(e),f={x:0,y:0},m={x:0,y:0},p=t.height*r.y,g=t.width*r.x;return!c&&a<=t.top+p?(f.y=kv.Backward,m.y=o*Math.abs((t.top+p-a)/p)):!d&&l>=t.bottom-p&&(f.y=kv.Forward,m.y=o*Math.abs((t.bottom-p-l)/p)),!h&&s>=t.right-g?(f.x=kv.Forward,m.x=o*Math.abs((t.right-g-s)/g)):!u&&i<=t.left+g&&(f.x=kv.Backward,m.x=o*Math.abs((t.left+g-i)/g)),{direction:f,speed:m}}function _v(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function Iv(e){return e.reduce(((e,t)=>Ko(e,wv(t))),Qg)}const Av=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+xv(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+bv(t)),0)}]];class Tv{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=gv(t),o=Iv(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[r,a,i]of Av)for(const e of a)Object.defineProperty(this,e,{get:()=>{const t=i(n),a=o[r]-t;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Mv{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var o;null==(o=this.target)||o.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Ov(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t&&o>t.y}var Dv,Pv,Rv,Lv;function zv(e){e.preventDefault()}function Fv(e){e.stopPropagation()}(Pv=Dv||(Dv={})).Click="click",Pv.DragStart="dragstart",Pv.Keydown="keydown",Pv.ContextMenu="contextmenu",Pv.Resize="resize",Pv.SelectionChange="selectionchange",Pv.VisibilityChange="visibilitychange",(Lv=Rv||(Rv={})).Space="Space",Lv.Down="ArrowDown",Lv.Right="ArrowRight",Lv.Left="ArrowLeft",Lv.Up="ArrowUp",Lv.Esc="Escape",Lv.Enter="Enter";const Bv={start:[Rv.Space,Rv.Enter],cancel:[Rv.Esc],end:[Rv.Space,Rv.Enter]},Uv=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Rv.Right:return{...n,x:n.x+25};case Rv.Left:return{...n,x:n.x-25};case Rv.Down:return{...n,y:n.y+25};case Rv.Up:return{...n,y:n.y-25}}};class Vv{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Mv(qo(t)),this.windowListeners=new Mv(Go(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Dv.Resize,this.handleCancel),this.windowListeners.add(Dv.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(Dv.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=mv),!e)return;const{top:n,left:o,bottom:r,right:a}=t(e);vv(e)&&(r<=0||a<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(Qg)}handleKeyDown(e){if(Yo(e)){const{active:t,context:n,options:o}=this.props,{keyboardCodes:r=Bv,coordinateGetter:a=Uv,scrollBehavior:i="smooth"}=o,{code:s}=e;if(r.end.includes(s))return void this.handleEnd(e);if(r.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Qg;this.referenceCoordinates||(this.referenceCoordinates=c);const d=a(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=Xo(d,c),o={x:0,y:0},{scrollableAncestors:r}=n.current;for(const n of r){const r=e.code,{isTop:a,isRight:s,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=Cv(n),f=_v(n),m={x:Math.min(r===Rv.Right?f.right-f.width/2:f.right,Math.max(r===Rv.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(r===Rv.Down?f.bottom-f.height/2:f.bottom,Math.max(r===Rv.Down?f.top:f.top+f.height/2,d.y))},p=r===Rv.Right&&!s||r===Rv.Left&&!l,g=r===Rv.Down&&!c||r===Rv.Up&&!a;if(p&&m.x!==d.x){const e=n.scrollLeft+t.x,a=r===Rv.Right&&e<=u.x||r===Rv.Left&&e>=h.x;if(a&&!t.y)return void n.scrollTo({left:e,behavior:i});o.x=a?n.scrollLeft-e:r===Rv.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,o.x&&n.scrollBy({left:-o.x,behavior:i});break}if(g&&m.y!==d.y){const e=n.scrollTop+t.y,a=r===Rv.Down&&e<=u.y||r===Rv.Up&&e>=h.y;if(a&&!t.x)return void n.scrollTo({top:e,behavior:i});o.y=a?n.scrollTop-e:r===Rv.Down?n.scrollTop-u.y:n.scrollTop-h.y,o.y&&n.scrollBy({top:-o.y,behavior:i});break}}this.handleMove(e,Ko(Xo(d,this.referenceCoordinates),o))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Hv(e){return Boolean(e&&"distance"in e)}function $v(e){return Boolean(e&&"delay"in e)}Vv.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=Bv,onActivation:r}=t,{active:a}=n;const{code:i}=e.nativeEvent;if(o.start.includes(i)){const t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==r||r({event:e.nativeEvent}),!0)}return!1}}];class Wv{constructor(e,t,n){var o;void 0===n&&(n=function(e){const{EventTarget:t}=Go(e);return e instanceof t?e:qo(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:a}=r;this.props=e,this.events=t,this.document=qo(a),this.documentListeners=new Mv(this.document),this.listeners=new Mv(n),this.windowListeners=new Mv(Go(a)),this.initialCoordinates=null!=(o=Qo(r))?o:Qg,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(Dv.Resize,this.handleCancel),this.windowListeners.add(Dv.DragStart,zv),this.windowListeners.add(Dv.VisibilityChange,this.handleCancel),this.windowListeners.add(Dv.ContextMenu,zv),this.documentListeners.add(Dv.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($v(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(Hv(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Dv.Click,Fv,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Dv.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:o,props:r}=this,{onMove:a,options:{activationConstraint:i}}=r;if(!o)return;const s=null!=(t=Qo(e))?t:Qg,l=Xo(o,s);if(!n&&i){if(Hv(i)){if(null!=i.tolerance&&Ov(l,i.tolerance))return this.handleCancel();if(Ov(l,i.distance))return this.handleStart()}return $v(i)&&Ov(l,i.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),a(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Rv.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const Gv={move:{name:"pointermove"},end:{name:"pointerup"}};class qv extends Wv{constructor(e){const{event:t}=e,n=qo(t.target);super(e,Gv,n)}}qv.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!(!n.isPrimary||0!==n.button)&&(null==o||o({event:n}),!0)}}];const Yv={move:{name:"mousemove"},end:{name:"mouseup"}};var Xv,Kv;(Kv=Xv||(Xv={}))[Kv.RightClick=2]="RightClick";(class extends Wv{constructor(e){super(e,Yv,qo(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button!==Xv.RightClick&&(null==o||o({event:n}),!0)}}];const Jv={move:{name:"touchmove"},end:{name:"touchend"}};var Zv,Qv,ey,ty;function ny(e){let{acceleration:t,activator:n=Zv.Pointer,canScroll:o,draggingRect:a,enabled:i,interval:s=5,order:l=ey.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const m=function(e){let{delta:t,disabled:n}=e;const o=or(t);return rr((e=>{if(n||!o||!e)return oy;const r={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[kv.Backward]:e.x[kv.Backward]||-1===r.x,[kv.Forward]:e.x[kv.Forward]||1===r.x},y:{[kv.Backward]:e.y[kv.Backward]||-1===r.y,[kv.Forward]:e.y[kv.Forward]||1===r.y}}}),[n,t,o])}({delta:h,disabled:!i}),[p,g]=nr(),v=r.useRef({x:0,y:0}),y=r.useRef({x:0,y:0}),x=r.useMemo((()=>{switch(n){case Zv.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Zv.DraggableRect:return a}}),[n,a,c]),b=r.useRef(null),w=r.useCallback((()=>{const e=b.current;if(!e)return;const t=v.current.x*y.current.x,n=v.current.y*y.current.y;e.scrollBy(t,n)}),[]),k=r.useMemo((()=>l===ey.TreeOrder?[...d].reverse():d),[l,d]);r.useEffect((()=>{if(i&&d.length&&x){for(const e of k){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=u[n];if(!r)continue;const{direction:a,speed:i}=jv(e,r,x,t,f);for(const e of["x","y"])m[e][a[e]]||(i[e]=0,a[e]=0);if(i.x>0||i.y>0)return g(),b.current=e,p(w,s),v.current=i,void(y.current=a)}v.current={x:0,y:0},y.current={x:0,y:0},g()}else g()}),[t,w,o,g,i,s,JSON.stringify(x),JSON.stringify(m),p,d,k,u,JSON.stringify(f)])}(class extends Wv{constructor(e){super(e,Jv)}static setup(){return window.addEventListener(Jv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Jv.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return!(r.length>1)&&(null==o||o({event:n}),!0)}}],(Qv=Zv||(Zv={}))[Qv.Pointer=0]="Pointer",Qv[Qv.DraggableRect=1]="DraggableRect",(ty=ey||(ey={}))[ty.TreeOrder=0]="TreeOrder",ty[ty.ReversedTreeOrder=1]="ReversedTreeOrder";const oy={x:{[kv.Backward]:!1,[kv.Forward]:!1},y:{[kv.Backward]:!1,[kv.Forward]:!1}};var ry,ay,iy;(ay=ry||(ry={}))[ay.Always=0]="Always",ay[ay.BeforeDragging=1]="BeforeDragging",ay[ay.WhileDragging=2]="WhileDragging",(iy||(iy={})).Optimized="optimized";const sy=new Map;function ly(e,t){return rr((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function cy(e){let{callback:t,disabled:n}=e;const o=fr(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}function dy(e){return new Tv(mv(e),e)}function uy(e,t,n){void 0===t&&(t=dy);const[o,a]=r.useReducer((function(o){if(!e)return null;var r;if(!1===e.isConnected)return null!=(r=null!=o?o:n)?r:null;const a=t(e);if(JSON.stringify(o)===JSON.stringify(a))return o;return a}),null),i=function(e){let{callback:t,disabled:n}=e;const o=fr(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}({callback(t){if(e)for(const n of t){const{type:t,target:o}=n;if("childList"===t&&o instanceof HTMLElement&&o.contains(e)){a();break}}}}),s=cy({callback:a});return tr((()=>{a(),e?(null==s||s.observe(e),null==i||i.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==i||i.disconnect())}),[e]),o}const hy=[];function fy(e,t){void 0===t&&(t=[]);const n=r.useRef(null);return r.useEffect((()=>{n.current=null}),t),r.useEffect((()=>{const t=e!==Qg;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?Xo(e,n.current):Qg}function my(e){return r.useMemo((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const py=[];function gy(e){let{measure:t}=e;const[n,o]=r.useState(null),a=cy({callback:r.useCallback((e=>{for(const{target:n}of e)if(ir(n)){o((e=>{const o=t(n);return e?{...e,width:o.width,height:o.height}:o}));break}}),[t])}),i=r.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ir(t)?t:e}(e);null==a||a.disconnect(),n&&(null==a||a.observe(n)),o(n?t(n):null)}),[t,a]),[s,l]=sr(i);return r.useMemo((()=>({nodeRef:s,rect:n,setRef:l})),[n,s,l])}const vy=[{sensor:qv,options:{}},{sensor:Vv,options:{}}],yy={current:{}},xy={draggable:{measure:pv},droppable:{measure:pv,strategy:ry.WhileDragging,frequency:iy.Optimized},dragOverlay:{measure:mv}};class by extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const wy={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new by,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jg},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:xy,measureDroppableContainers:Jg,windowRect:null,measuringScheduled:!1},ky={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jg,draggableNodes:new Map,over:null,measureDroppableContainers:Jg},Sy=r.createContext(ky),Ny=r.createContext(wy);function Cy(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new by}}}function Ey(e,t){switch(t.type){case Xg.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Xg.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case Xg.DragEnd:case Xg.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Xg.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new by(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case Xg.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,a=e.droppable.containers.get(n);if(!a||o!==a.key)return e;const i=new by(e.droppable.containers);return i.set(n,{...a,disabled:r}),{...e,droppable:{...e.droppable,containers:i}}}case Xg.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const a=new by(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function jy(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:a}=r.useContext(Sy),i=or(o),s=or(null==n?void 0:n.id);return r.useEffect((()=>{if(!t&&!o&&i&&null!=s){if(!Yo(i))return;if(document.activeElement===i.target)return;const e=a.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=lr(e);if(t){t.focus();break}}}))}}),[o,t,a,s,i]),null}const _y=r.createContext({...Qg,scaleX:1,scaleY:1});var Iy,Ay;(Ay=Iy||(Iy={}))[Ay.Uninitialized=0]="Uninitialized",Ay[Ay.Initializing=1]="Initializing",Ay[Ay.Initialized=2]="Initialized";const Ty=r.memo((function(e){var t,n,o,a;let{id:i,accessibility:s,autoScroll:l=!0,children:c,sensors:d=vy,collisionDetection:h=lv,measuring:f,modifiers:m,...p}=e;const g=r.useReducer(Ey,void 0,Cy),[v,y]=g,[x,b]=function(){const[e]=r.useState((()=>new Set)),t=r.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[r.useCallback((t=>{let{type:n,event:o}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,o)}))}),[e]),t]}(),[w,k]=r.useState(Iy.Uninitialized),S=w===Iy.Initialized,{draggable:{active:N,nodes:C,translate:E},droppable:{containers:j}}=v,_=N?C.get(N):null,I=r.useRef({initial:null,translated:null}),A=r.useMemo((()=>{var e;return null!=N?{id:N,data:null!=(e=null==_?void 0:_.data)?e:yy,rect:I}:null}),[N,_]),T=r.useRef(null),[M,O]=r.useState(null),[D,P]=r.useState(null),R=Jo(p,Object.values(p)),L=Zo("DndDescribedBy",i),z=r.useMemo((()=>j.getEnabled()),[j]),F=(B=f,r.useMemo((()=>({draggable:{...xy.draggable,...null==B?void 0:B.draggable},droppable:{...xy.droppable,...null==B?void 0:B.droppable},dragOverlay:{...xy.dragOverlay,...null==B?void 0:B.dragOverlay}})),[null==B?void 0:B.draggable,null==B?void 0:B.droppable,null==B?void 0:B.dragOverlay]));var B;const{droppableRects:U,measureDroppableContainers:V,measuringScheduled:H}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[i,s]=r.useState(null),{frequency:l,measure:c,strategy:d}=a,u=r.useRef(e),h=function(){switch(d){case ry.Always:return!1;case ry.BeforeDragging:return n;default:return!n}}(),f=Jo(h),m=r.useCallback((function(e){void 0===e&&(e=[]),f.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),p=r.useRef(null),g=rr((t=>{if(h&&!n)return sy;if(!t||t===sy||u.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,o=e?new Tv(c(e),e):null;n.rect.current=o,o&&t.set(n.id,o)}return t}return t}),[e,i,n,h,c]);return r.useEffect((()=>{u.current=e}),[e]),r.useEffect((()=>{h||m()}),[n,h]),r.useEffect((()=>{i&&i.length>0&&s(null)}),[JSON.stringify(i)]),r.useEffect((()=>{h||"number"!=typeof l||null!==p.current||(p.current=setTimeout((()=>{m(),p.current=null}),l))}),[l,h,m,...o]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:null!=i}}(z,{dragging:S,dependencies:[E.x,E.y],config:F.droppable}),$=function(e,t){const n=null!==t?e.get(t):void 0,o=n?n.node.current:null;return rr((e=>{var n;return null===t?null:null!=(n=null!=o?o:e)?n:null}),[o,t])}(C,N),W=r.useMemo((()=>D?Qo(D):null),[D]),G=function(){const e=!1===(null==M?void 0:M.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=S&&!e&&!t;if("object"==typeof l)return{...l,enabled:n};return{enabled:n}}(),q=function(e,t){return ly(e,t)}($,F.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:a=!0}=e;const i=r.useRef(!1),{x:s,y:l}="boolean"==typeof a?{x:a,y:a}:a;tr((()=>{if(!s&&!l||!t)return void(i.current=!1);if(i.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=dv(n(e),o);if(s||(r.x=0),l||(r.y=0),i.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=vv(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,s,l,o,n])}({activeNode:N?C.get(N):null,config:G.layoutShiftCompensation,initialRect:q,measure:F.draggable.measure});const Y=uy($,F.draggable.measure,q),X=uy($?$.parentElement:null),K=r.useRef({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),J=j.getNodeFor(null==(t=K.current.over)?void 0:t.id),Z=gy({measure:F.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:$,ee=S?null!=(o=Z.rect)?o:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=dv(oe=te?null:Y,ly(oe));var oe;const re=my(Q?Go(Q):null),ae=function(e){const t=r.useRef(e),n=rr((n=>e?n&&n!==hy&&e&&t.current&&e.parentNode===t.current.parentNode?n:gv(e):hy),[e]);return r.useEffect((()=>{t.current=e}),[e]),n}(S?null!=J?J:$:null),ie=function(e,t){void 0===t&&(t=mv);const[n]=e,o=my(n?Go(n):null),[a,i]=r.useReducer((function(){return e.length?e.map((e=>Nv(e)?o:new Tv(t(e),e))):py}),py),s=cy({callback:i});return e.length>0&&a===py&&i(),tr((()=>{e.length?e.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),i())}),[e]),a}(ae),se=function(e,t){let{transform:n,...o}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...o})),n):n}(m,{transform:{x:E.x-ne.x,y:E.y-ne.y,scaleX:1,scaleY:1},activatorEvent:D,active:A,activeNodeRect:Y,containerNodeRect:X,draggingNodeRect:ee,over:K.current.over,overlayNodeRect:Z.rect,scrollableAncestors:ae,scrollableAncestorRects:ie,windowRect:re}),le=W?Ko(W,E):null,ce=function(e){const[t,n]=r.useState(null),o=r.useRef(e),a=r.useCallback((e=>{const t=yv(e.target);t&&n((e=>e?(e.set(t,wv(t)),new Map(e)):null))}),[]);return r.useEffect((()=>{const t=o.current;if(e!==t){r(t);const i=e.map((e=>{const t=yv(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,wv(t)]):null})).filter((e=>null!=e));n(i.length?new Map(i):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=yv(e);null==t||t.removeEventListener("scroll",a)}))}}),[a,e]),r.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>Ko(e,t)),Qg):Iv(e):Qg),[e,t])}(ae),de=fy(ce),ue=fy(ce,[Y]),he=Ko(se,de),fe=ee?hv(ee,se):null,me=A&&fe?h({active:A,collisionRect:fe,droppableRects:U,droppableContainers:z,pointerCoordinates:le}):null,pe=rv(me,"id"),[ge,ve]=r.useState(null),ye=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?se:Ko(se,ue),null!=(a=null==ge?void 0:ge.rect)?a:null,Y),xe=r.useCallback(((e,t)=>{let{sensor:n,options:o}=t;if(null==T.current)return;const r=C.get(T.current);if(!r)return;const a=e.nativeEvent,i=new n({active:T.current,activeNode:r,event:a,options:o,context:K,onStart(e){const t=T.current;if(null==t)return;const n=C.get(t);if(!n)return;const{onDragStart:o}=R.current,r={active:{id:t,data:n.data,rect:I}};er.unstable_batchedUpdates((()=>{null==o||o(r),k(Iy.Initializing),y({type:Xg.DragStart,initialCoordinates:e,active:t}),x({type:"onDragStart",event:r})}))},onMove(e){y({type:Xg.DragMove,coordinates:e})},onEnd:s(Xg.DragEnd),onCancel:s(Xg.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:o,scrollAdjustedTranslate:r}=K.current;let i=null;if(t&&r){const{cancelDrop:s}=R.current;if(i={activatorEvent:a,active:t,collisions:n,delta:r,over:o},e===Xg.DragEnd&&"function"==typeof s){await Promise.resolve(s(i))&&(e=Xg.DragCancel)}}T.current=null,er.unstable_batchedUpdates((()=>{y({type:e}),k(Iy.Uninitialized),ve(null),O(null),P(null);const t=e===Xg.DragEnd?"onDragEnd":"onDragCancel";if(i){const e=R.current[t];null==e||e(i),x({type:t,event:i})}}))}}er.unstable_batchedUpdates((()=>{O(i),P(e.nativeEvent)}))}),[C]),be=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{const{sensor:o}=n;return[...e,...o.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,r.useCallback(((e,t)=>(n,o)=>{const r=n.nativeEvent,a=C.get(o);if(null!==T.current||!a||r.dndKit||r.defaultPrevented)return;const i={active:a};!0===e(n,t.options,i)&&(r.dndKit={capturedBy:t.sensor},T.current=o,xe(n,t))}),[C,xe]));!function(e){r.useEffect((()=>{if(!ar)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(d),tr((()=>{Y&&w===Iy.Initializing&&k(Iy.Initialized)}),[Y,w]),r.useEffect((()=>{const{onDragMove:e}=R.current,{active:t,activatorEvent:n,collisions:o,over:r}=K.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:o,delta:{x:he.x,y:he.y},over:r};er.unstable_batchedUpdates((()=>{null==e||e(a),x({type:"onDragMove",event:a})}))}),[he.x,he.y]),r.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:o,scrollAdjustedTranslate:r}=K.current;if(!e||null==T.current||!t||!r)return;const{onDragOver:a}=R.current,i=o.get(pe),s=i&&i.rect.current?{id:i.id,rect:i.rect.current,data:i.data,disabled:i.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:r.x,y:r.y},over:s};er.unstable_batchedUpdates((()=>{ve(s),null==a||a(l),x({type:"onDragOver",event:l})}))}),[pe]),tr((()=>{K.current={activatorEvent:D,active:A,activeNode:$,collisionRect:fe,collisions:me,droppableRects:U,draggableNodes:C,draggingNode:Q,draggingNodeRect:ee,droppableContainers:j,over:ge,scrollableAncestors:ae,scrollAdjustedTranslate:he},I.current={initial:ee,translated:fe}}),[A,$,me,fe,C,Q,ee,U,j,ge,ae,he]),ny({...G,delta:E,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:ae,scrollableAncestorRects:ie});const we=r.useMemo((()=>({active:A,activeNode:$,activeNodeRect:Y,activatorEvent:D,collisions:me,containerNodeRect:X,dragOverlay:Z,draggableNodes:C,droppableContainers:j,droppableRects:U,over:ge,measureDroppableContainers:V,scrollableAncestors:ae,scrollableAncestorRects:ie,measuringConfiguration:F,measuringScheduled:H,windowRect:re})),[A,$,Y,D,me,X,Z,C,j,U,ge,V,ae,ie,F,H,re]),ke=r.useMemo((()=>({activatorEvent:D,activators:be,active:A,activeNodeRect:Y,ariaDescribedById:{draggable:L},dispatch:y,draggableNodes:C,over:ge,measureDroppableContainers:V})),[D,be,A,Y,y,L,C,ge,V]);return u.createElement(Wg.Provider,{value:b},u.createElement(Sy.Provider,{value:ke},u.createElement(Ny.Provider,{value:we},u.createElement(_y.Provider,{value:ye},c)),u.createElement(jy,{disabled:!1===(null==s?void 0:s.restoreFocus)})),u.createElement(Yg,{...s,hiddenTextDescribedById:L}))})),My=r.createContext(null),Oy="button";function Dy(e){let{id:t,data:n,disabled:o=!1,attributes:a}=e;const i=Zo("Droppable"),{activators:s,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=r.useContext(Sy),{role:m=Oy,roleDescription:p="draggable",tabIndex:g=0}=null!=a?a:{},v=(null==c?void 0:c.id)===t,y=r.useContext(v?_y:My),[x,b]=sr(),[w,k]=sr(),S=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{let{eventName:o,handler:r}=n;return e[o]=e=>{r(e,t)},e}),{})),[e,t])}(s,t),N=Jo(n);tr((()=>(h.set(t,{id:t,key:i,node:x,activatorNode:w,data:N}),()=>{const e=h.get(t);e&&e.key===i&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:r.useMemo((()=>({role:m,tabIndex:g,"aria-disabled":o,"aria-pressed":!(!v||m!==Oy)||void 0,"aria-roledescription":p,"aria-describedby":u.draggable})),[o,m,g,v,p,u.draggable]),isDragging:v,listeners:o?void 0:S,node:x,over:f,setNodeRef:b,setActivatorNodeRef:k,transform:y}}const Py={timeout:25};function Ry(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o}function Ly(e,t){return e.reduce(((e,n,o)=>{const r=t.get(n);return r&&(e[o]=r),e}),Array(e.length))}function zy(e){return null!==e&&e>=0}const Fy={scaleX:1,scaleY:1},By=e=>{var t;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:a,index:i}=e;const s=null!=(t=n[r])?t:o;if(!s)return null;const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o||!r&&!a)return 0;if(n<t)return r?o.left-(r.left+r.width):a.left-(o.left+o.width);return a?a.left-(o.left+o.width):o.left-(r.left+r.width)}(n,i,r);if(i===r){const e=n[a];return e?{x:r<a?e.left+e.width-(s.left+s.width):e.left-s.left,y:0,...Fy}:null}return i>r&&i<=a?{x:-s.width-l,y:0,...Fy}:i<r&&i>=a?{x:s.width+l,y:0,...Fy}:{x:0,y:0,...Fy}};const Uy=e=>{let{rects:t,activeIndex:n,overIndex:o,index:r}=e;const a=Ry(t,o,n),i=t[r],s=a[r];return s&&i?{x:s.left-i.left,y:s.top-i.top,scaleX:s.width/i.width,scaleY:s.height/i.height}:null},Vy={scaleX:1,scaleY:1},Hy=e=>{var t;let{activeIndex:n,activeNodeRect:o,index:r,rects:a,overIndex:i}=e;const s=null!=(t=a[n])?t:o;if(!s)return null;if(r===n){const e=a[i];return e?{x:0,y:n<i?e.top+e.height-(s.top+s.height):e.top-s.top,...Vy}:null}const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o)return 0;if(n<t)return r?o.top-(r.top+r.height):a?a.top-(o.top+o.height):0;return a?a.top-(o.top+o.height):r?o.top-(r.top+r.height):0}(a,r,n);return r>n&&r<=i?{x:0,y:-s.height-l,...Vy}:r<n&&r>=i?{x:0,y:s.height+l,...Vy}:{x:0,y:0,...Vy}};const $y="Sortable",Wy=u.createContext({activeIndex:-1,containerId:$y,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Uy,disabled:{draggable:!1,droppable:!1}});function Gy(e){let{children:t,id:n,items:o,strategy:a=Uy,disabled:i=!1}=e;const{active:s,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=r.useContext(Ny),f=Zo($y,n),m=Boolean(null!==l.rect),p=r.useMemo((()=>o.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[o]),g=null!=s,v=s?p.indexOf(s.id):-1,y=d?p.indexOf(d.id):-1,x=r.useRef(p),b=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,x.current),w=-1!==y&&-1===v||b,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(i);tr((()=>{b&&g&&h(p)}),[b,p,g,h]),r.useEffect((()=>{x.current=p}),[p]);const S=r.useMemo((()=>({activeIndex:v,containerId:f,disabled:k,disableTransforms:w,items:p,overIndex:y,useDragOverlay:m,sortedRects:Ly(p,c),strategy:a})),[v,f,k.draggable,k.droppable,w,p,y,c,m,a]);return u.createElement(Wy.Provider,{value:S},t)}const qy=e=>{let{id:t,items:n,activeIndex:o,overIndex:r}=e;return Ry(n,o,r).indexOf(t)},Yy=e=>{let{containerId:t,isSorting:n,wasDragging:o,index:r,items:a,newIndex:i,previousItems:s,previousContainerId:l,transition:c}=e;return!(!c||!o)&&((s===a||r!==i)&&(!!n||i!==r&&t===l))},Xy={duration:200,easing:"ease"},Ky="transform",Jy=pr.Transition.toString({property:Ky,duration:0,easing:"linear"}),Zy={roleDescription:"sortable"};function Qy(e){let{animateLayoutChanges:t=Yy,attributes:n,disabled:o,data:a,getNewIndex:i=qy,id:s,strategy:l,resizeObserverConfig:c,transition:d=Xy}=e;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:v,useDragOverlay:y,strategy:x}=r.useContext(Wy),b=function(e,t){var n,o;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(o=null==e?void 0:e.droppable)?o:t.droppable}}(o,m),w=u.indexOf(s),k=r.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...a})),[h,a,w,u]),S=r.useMemo((()=>u.slice(u.indexOf(s))),[u,s]),{rect:N,node:C,isOver:E,setNodeRef:j}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const i=Zo("Droppable"),{active:s,dispatch:l,over:c,measureDroppableContainers:d}=r.useContext(Sy),u=r.useRef({disabled:n}),h=r.useRef(!1),f=r.useRef(null),m=r.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:v}={...Py,...a},y=Jo(null!=g?g:o),x=cy({callback:r.useCallback((()=>{h.current?(null!=m.current&&clearTimeout(m.current),m.current=setTimeout((()=>{d(Array.isArray(y.current)?y.current:[y.current]),m.current=null}),v)):h.current=!0}),[v]),disabled:p||!s}),b=r.useCallback(((e,t)=>{x&&(t&&(x.unobserve(t),h.current=!1),e&&x.observe(e))}),[x]),[w,k]=sr(b),S=Jo(t);return r.useEffect((()=>{x&&w.current&&(x.disconnect(),h.current=!1,x.observe(w.current))}),[w,x]),tr((()=>(l({type:Xg.RegisterDroppable,element:{id:o,key:i,disabled:n,node:w,rect:f,data:S}}),()=>l({type:Xg.UnregisterDroppable,key:i,id:o}))),[o]),r.useEffect((()=>{n!==u.current.disabled&&(l({type:Xg.SetDroppableDisabled,id:o,key:i,disabled:n}),u.current.disabled=n)}),[o,i,n,l]),{active:s,rect:f,isOver:(null==c?void 0:c.id)===o,node:w,over:c,setNodeRef:k}}({id:s,data:k,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:_,activatorEvent:I,activeNodeRect:A,attributes:T,setNodeRef:M,listeners:O,isDragging:D,over:P,setActivatorNodeRef:R,transform:L}=Dy({id:s,data:k,attributes:{...Zy,...n},disabled:b.draggable}),z=mr(j,M),F=Boolean(_),B=F&&!p&&zy(f)&&zy(v),U=!y&&D,V=U&&B?L:null,H=B?null!=V?V:(null!=l?l:x)({rects:g,activeNodeRect:A,activeIndex:f,overIndex:v,index:w}):null,$=zy(f)&&zy(v)?i({id:s,items:u,activeIndex:f,overIndex:v}):w,W=null==_?void 0:_.id,G=r.useRef({activeId:W,items:u,newIndex:$,containerId:h}),q=u!==G.current.items,Y=t({active:_,containerId:h,isDragging:D,isSorting:F,id:s,index:w,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:d,wasDragging:null!=G.current.activeId}),X=function(e){let{disabled:t,index:n,node:o,rect:a}=e;const[i,s]=r.useState(null),l=r.useRef(n);return tr((()=>{if(!t&&n!==l.current&&o.current){const e=a.current;if(e){const t=mv(o.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&s(n)}}n!==l.current&&(l.current=n)}),[t,n,o,a]),r.useEffect((()=>{i&&s(null)}),[i]),i}({disabled:!Y,index:w,node:C,rect:N});return r.useEffect((()=>{F&&G.current.newIndex!==$&&(G.current.newIndex=$),h!==G.current.containerId&&(G.current.containerId=h),u!==G.current.items&&(G.current.items=u)}),[F,$,h,u]),r.useEffect((()=>{if(W===G.current.activeId)return;if(W&&!G.current.activeId)return void(G.current.activeId=W);const e=setTimeout((()=>{G.current.activeId=W}),50);return()=>clearTimeout(e)}),[W]),{active:_,activeIndex:f,attributes:T,data:k,rect:N,index:w,newIndex:$,items:u,isOver:E,isSorting:F,isDragging:D,listeners:O,node:C,overIndex:v,over:P,setNodeRef:z,setActivatorNodeRef:R,setDroppableNodeRef:j,setDraggableNodeRef:M,transform:null!=X?X:H,transition:function(){if(X||q&&G.current.newIndex===w)return Jy;if(U&&!Yo(I)||!d)return;if(F||Y)return pr.Transition.toString({...d,property:Ky});return}()}}function ex(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const tx=[Rv.Down,Rv.Right,Rv.Up,Rv.Left],nx=(e,t)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:a,over:i,scrollableAncestors:s}}=t;if(tx.includes(e.code)){if(e.preventDefault(),!n||!o)return;const t=[];a.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=r.get(n.id);if(a)switch(e.code){case Rv.Down:o.top<a.top&&t.push(n);break;case Rv.Up:o.top>a.top&&t.push(n);break;case Rv.Left:o.left>a.left&&t.push(n);break;case Rv.Right:o.left<a.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=ov(t),a=[];for(const i of o){const{id:e}=i,t=n.get(e);if(t){const n=ov(t),o=r.reduce(((e,t,o)=>e+ev(n[o],t)),0),s=Number((o/4).toFixed(4));a.push({id:e,data:{droppableContainer:i,value:s}})}}return a.sort(tv)})({active:n,collisionRect:o,droppableRects:r,droppableContainers:t,pointerCoordinates:null});let c=rv(l,"id");if(c===(null==i?void 0:i.id)&&l.length>1&&(c=l[1].id),null!=c){const e=a.get(n.id),t=a.get(c),i=t?r.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&i&&e&&t){const n=gv(l).some(((e,t)=>s[t]!==e)),r=ox(e,t),a=function(e,t){if(!ex(e)||!ex(t))return!1;if(!ox(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!r?{x:0,y:0}:{x:a?o.width-i.width:0,y:a?o.height-i.height:0},d={x:i.left,y:i.top};return c.x&&c.y?d:Xo(d,c)}}}};function ox(e,t){return!(!ex(e)||!ex(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const rx=u.createContext(null),ax=r.memo((()=>r.useContext(rx)));ax.displayName="DragHandle";const ix=u.forwardRef((({cellId:e,canMoveX:t,...n},o)=>{const{attributes:r,listeners:a,setNodeRef:i,transform:s,transition:l,isDragging:c}=Qy({id:e.toString()}),d={transform:s?pr.Transform.toString({x:t?s.x:0,y:s.y,scaleX:1,scaleY:1}):void 0,transition:l,zIndex:c?2:void 0,position:"relative"},u=Ug(o,i),h=k.jsx("div",{...r,...a,onMouseDown:tt.preventFocus,"data-testid":"drag-button",className:"py-[1px] cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:k.jsx(uc,{strokeWidth:1,size:20})}),f=Boolean(s);return k.jsx("div",{tabIndex:-1,ref:u,...n,"data-is-dragging":c,className:rn(n.className,f&&"is-moving","outline-offset-4 outline-primary/40 rounded-lg"),style:d,children:k.jsx(rx.Provider,{value:h,children:n.children})})}));ix.displayName="SortableCell";const sx=r.memo(ix),lx=u.memo(u.forwardRef(((e,t)=>{const n=b(34);let o,a,i;n[0]!==e?(({children:i,showTooltip:o,...a}=e),n[0]=e,n[1]=o,n[2]=a,n[3]=i):(o=n[1],a=n[2],i=n[3]);const s=void 0===o||o,[l,c]=r.useState(!1);let d;n[4]!==a?(d={cell:a},n[4]=a,n[5]=d):d=n[5];const u=Ad(d),h=gr();let f,m,p,g,v,y;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>c((e=>!e))}),n[6]=f):f=n[6],r.useImperativeHandle(t,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(m=k.jsx(Ye,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=m):m=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(Ke,{children:"No results"}),n[8]=p):p=n[8],n[9]!==u){let e;n[11]!==u.length?(e=(e,t)=>k.jsxs(r.Fragment,{children:[k.jsx(Be,{children:e.map((e=>k.jsx($e,{onSelect:()=>{e.disableClick||(e.handle(),c(!1))},variant:e.variant,children:k.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&k.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),k.jsx("div",{className:"flex-1",children:e.label}),k.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&vr(e.hotkey),e.rightElement]})]})},e.label)))},t),t<u.length-1&&k.jsx(Ve,{})]},t),n[11]=u.length,n[12]=e):e=n[12],g=u.map(e),n[9]=u,n[10]=g}else g=n[10];n[13]!==g?(v=k.jsxs(mn,{children:[m,k.jsxs(yr,{children:[p,g]})]}),n[13]=g,n[14]=v):v=n[14],n[15]!==h||n[16]!==v?(y=k.jsx(hn,{className:"w-[300px] p-0 pt-1",...h,children:v}),n[15]=h,n[16]=v,n[17]=y):y=n[17];const x=y;if(!s){let e,t;return n[18]!==i?(e=k.jsx(xr,{asChild:!0,children:i}),n[18]=i,n[19]=e):e=n[19],n[20]!==l||n[21]!==e||n[22]!==x?(t=k.jsxs(fn,{open:l,onOpenChange:c,children:[e,x]}),n[20]=l,n[21]=e,n[22]=x,n[23]=t):t=n[23],t}let w;n[24]===Symbol.for("react.memo_cache_sentinel")?(w=k.jsx(br,{tabIndex:-1,children:S("cell.cellActions")}),n[24]=w):w=n[24];const N=!l&&w;let C,E,j;return n[25]!==i?(C=k.jsx(wr,{children:k.jsx(xr,{className:"flex",children:i})}),n[25]=i,n[26]=C):C=n[26],n[27]!==N||n[28]!==C?(E=k.jsxs(kr,{delayDuration:200,disableHoverableContent:!0,children:[N,C]}),n[27]=N,n[28]=C,n[29]=E):E=n[29],n[30]!==l||n[31]!==E||n[32]!==x?(j=k.jsxs(fn,{open:l,onOpenChange:c,children:[E,x]}),n[30]=l,n[31]=E,n[32]=x,n[33]=j):j=n[33],j}))),cx=u.memo((e=>{const t=b(5),{children:n,cellId:o}=e;let r,a;t[0]!==o?(a=function(e){return Z((t=>zd(e,t(ie))))}(o),t[0]=o,t[1]=a):a=t[1],r=a;const i=le(r);if(!i)return null;let s;return t[2]!==i||t[3]!==n?(s=k.jsx(lx,{showTooltip:!1,...i,children:n}),t[2]=i,t[3]=n,t[4]=s):s=t[4],s}));cx.displayName="ConnectionCellActionsDropdown";const dx=({children:e,...t})=>{const n=Ad({cell:t}),[o,a]=u.useState(),i=[{label:"Copy",hidden:Boolean(o),icon:k.jsx(nt,{size:13,strokeWidth:1.5}),handle:async()=>{var e;if(null==(e=window.getSelection())?void 0:e.toString())return void document.execCommand("copy");const n=document.getElementById(H.create(t.cellId));n?await et(n.textContent??""):J.warn("cell-context-menu: output not found")}},{label:"Cut",hidden:Boolean(o),icon:k.jsx(Rc,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("cut")}},{label:"Paste",hidden:Boolean(o),icon:k.jsx(Ql,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=t,n=e();if(!n)return;const o=await navigator.clipboard.readText();if(o){const{from:e,to:t}=n.state.selection.main,r=n.state.update({changes:{from:e,to:t,insert:o}});n.dispatch(r)}}},{label:"Copy image",hidden:!o,icon:k.jsx(Zl,{size:13,strokeWidth:1.5}),handle:async()=>{if(o){const e=await fetch(o.src),t=await e.blob(),n=new ClipboardItem({[t.type]:t});await navigator.clipboard.write([n]).then((()=>{re({title:"Copied image to clipboard"})})).catch((e=>{re({title:"Failed to copy image to clipboard. Try downloading instead.",description:e.message}),J.error("Failed to copy image to clipboard",e)}))}}},{icon:k.jsx(rl,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!o,handle:()=>{if(o){const e=document.createElement("a");e.download="image.png",e.href=o.src,e.click()}}},{label:"Go to Definition",icon:k.jsx(Sr,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=t,n=e();n&&Nr(n)}}];return k.jsxs(bg,{children:[k.jsx(wg,{onContextMenu:e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},asChild:!0,children:e}),k.jsx(Ng,{className:"w-[300px]",children:[i,...n].map(((e,t)=>k.jsxs(r.Fragment,{children:[e.map((e=>e.hidden?null:k.jsx(Cg,{onSelect:t=>{e.handle(t)},variant:e.variant,children:k.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&k.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),k.jsx("div",{className:"flex-1",children:e.label}),k.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&vr(e.hotkey),e.rightElement]})]})},e.label))),t<e.length-1&&k.jsx(Eg,{})]},t)))})]})},ux=e=>{const t=b(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:a}=e;let i,s;t[0]!==o?(s=(new Uo).isSupported(o)||""===o.trim(),t[0]=o,t[1]=s):s=t[1],i=s;const l=i;let c,d;t[2]!==o?(d=(new Vo).isSupported(o)||""===o.trim(),t[2]=o,t[3]=d):d=t[3],c=d;const u=c&&"python"===r;let h,f;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx(ke,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=h):h=t[4],t[5]!==n||t[6]!==r||t[7]!==u||t[8]!==a?(f=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:u,icon:h,toType:"sql",displayName:"SQL",onAfterToggle:a}),t[5]=n,t[6]=r,t[7]=u,t[8]=a,t[9]=f):f=t[9];const m=l&&"python"===r;let p,g,v,y,x;return t[10]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(Is,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=p):p=t[10],t[11]!==n||t[12]!==r||t[13]!==m||t[14]!==a?(g=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:m,icon:p,toType:"markdown",displayName:"Markdown",onAfterToggle:a}),t[11]=n,t[12]=r,t[13]=m,t[14]=a,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(As,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=v):v=t[16],t[17]!==n||t[18]!==r?(y=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:v,toType:"python",displayName:"Python",onAfterToggle:an.NOOP}),t[17]=n,t[18]=r,t[19]=y):y=t[19],t[20]!==f||t[21]!==g||t[22]!==y?(x=k.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,y]}),t[20]=f,t[21]=g,t[22]=y,t[23]=x):x=t[23],x},hx=e=>{const t=b(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:a,toType:i,displayName:s,onAfterToggle:l}=e;if(!r)return null;if(o===i)return null;const c=`View as ${s}`;let d,u,h;return t[0]!==n||t[1]!==i||t[2]!==l?(d=()=>{n&&(we(n,i),l())},t[0]=n,t[1]=i,t[2]=l,t[3]=d):d=t[3],t[4]!==d||t[5]!==a?(u=k.jsx(C,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:a}),t[4]=d,t[5]=a,t[6]=u):u=t[6],t[7]!==c||t[8]!==u?(h=k.jsx(N,{content:c,children:u}),t[7]=c,t[8]=u,t[9]=h):h=t[9],h};var fx={modified:{doc:""},original:{doc:""}},mx=r.createContext(fx);function px(e,t){return mo({},e,t,{modified:mo({},e.modified,t.modified),original:mo({},e.original,t.original)})}var gx=()=>r.useContext(mx),vx=e=>{var{children:t,theme:n}=e,[o,a]=r.useReducer(px,mo({},fx,{theme:n}));return r.useEffect((()=>a({theme:n})),[n]),k.jsx(mx.Provider,{value:mo({},o,{dispatch:a}),children:t})},yx=["extensions","value","selection","onChange"],xx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,i=Cr(e,yx),{theme:s,dispatch:l}=gx(),c=Er(mo({},i,{theme:s}));return r.useEffect((()=>l({original:{doc:n,selection:o,extensions:[...c,...t]},originalExtension:{onChange:a,option:i,extension:[t]}})),[e]),null};xx.displayName="CodeMirrorMerge.Original";var bx=["extensions","value","selection","onChange"],wx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,i=Cr(e,bx),{theme:s,dispatch:l}=gx(),c=Er(mo({},i,{theme:s}));return r.useEffect((()=>{l({modified:{doc:n,selection:o,extensions:[...c,...t]},modifiedExtension:{onChange:a,option:i,extension:[t]}})}),[e]),null};wx.displayName="CodeMirrorMerge.Modified";class kx{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}offset(e,t){return new kx(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function Sx(e,t,n,o,r,a){if(e==o)return[];let i=Ax(e,t,n,o,r,a),s=Tx(e,t+i,n,o,r+i,a),l=(n-=s)-(t+=i),c=(a-=s)-(r+=i);if(!l||!c)return[new kx(t,n,r,a)];if(l>c){let i=e.slice(t,n).indexOf(o.slice(r,a));if(i>-1)return[new kx(t,t+i,r,r),new kx(t+i+c,n,a,a)]}else if(c>l){let i=o.slice(r,a).indexOf(e.slice(t,n));if(i>-1)return[new kx(t,t,r,r+i),new kx(n,n,r+i+l,a)]}if(1==l||1==c)return[new kx(t,n,r,a)];let d=Ox(e,t,n,o,r,a);if(d){let[i,s,l]=d;return Sx(e,t,i,o,r,s).concat(Sx(e,i+l,n,o,s+l,a))}return function(e,t,n,o,r,a){let i=n-t,s=a-r;if(Nx<1e9&&Math.min(i,s)>16*Nx)return Math.min(i,s)>64*Nx?[new kx(t,n,r,a)]:Dx(e,t,n,o,r,a);let l=Math.ceil((i+s)/2);Ex.reset(l),jx.reset(l);let c=(n,a)=>e.charCodeAt(t+n)==o.charCodeAt(r+a),d=(t,r)=>e.charCodeAt(n-t-1)==o.charCodeAt(a-r-1),u=(i-s)%2!=0?jx:null,h=u?null:Ex;for(let f=0;f<l;f++){if(f>Nx)return Dx(e,t,n,o,r,a);let m=Ex.advance(f,i,s,l,u,!1,c)||jx.advance(f,i,s,l,h,!0,d);if(m)return _x(e,t,n,t+m[0],o,r,a,r+m[1])}return[new kx(t,n,r,a)]}(e,t,n,o,r,a)}let Nx=1e9;class Cx{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,o,r,a,i){for(let s=-e+this.start;s<=e-this.end;s+=2){let l=o+s,c=s==-e||s!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-s;for(;c<t&&d<n&&i(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>n)this.start+=2;else if(r){let e=o+(t-n)-s;if(e>=0&&e<this.len&&-1!=r.vec[e])if(a){let n=r.vec[e];if(n>=t-c)return[n,o+n-e]}else{if(c>=t-r.vec[e])return[c,d]}}}return null}}const Ex=new Cx,jx=new Cx;function _x(e,t,n,o,r,a,i,s){let l=!1;return Wx(e,o)||++o!=n||(l=!0),Wx(r,s)||++s!=i||(l=!0),l?[new kx(t,n,a,i)]:Sx(e,t,o,r,a,s).concat(Sx(e,o,n,r,s,i))}function Ix(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n<<=1;return n}function Ax(e,t,n,o,r,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(r))return 0;let i=Ix(n-t,a-r);for(let s=t,l=r;;){let r=s+i,c=l+i;if(r>n||c>a||e.slice(s,r)!=o.slice(l,c)){if(1==i)return s-t-(Wx(e,s)?0:1);i>>=1}else{if(r==n||c==a)return r-t;s=r,l=c}}}function Tx(e,t,n,o,r,a){if(t==n||r==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let i=Ix(n-t,a-r);for(let s=n,l=a;;){let a=s-i,c=l-i;if(a<t||c<r||e.slice(a,s)!=o.slice(c,l)){if(1==i)return n-s-(Wx(e,s)?0:1);i>>=1}else{if(a==t||c==r)return n-a;s=a,l=c}}}function Mx(e,t,n,o,r,a,i,s){let l=o.slice(r,a),c=null;for(;;){if(c||i<s)return c;for(let s=t+i;;){Wx(e,s)||s++;let d=s+i;if(Wx(e,d)||(d+=d==s+1?1:-1),d>=n)break;let u=e.slice(s,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let i=Ax(e,d,n,o,r+h+u.length,a),l=Tx(e,t,s,o,r,r+h),f=u.length+i+l;(!c||c[2]<f)&&(c=[s-l,r+h-l,f])}s=d}if(s<0)return c;i>>=1}}function Ox(e,t,n,o,r,a){let i=n-t,s=a-r;if(i<s){let i=Ox(o,r,a,e,t,n);return i&&[i[1],i[0],i[2]]}return i<4||2*s<i?null:Mx(e,t,n,o,r,a,Math.floor(i/4),-1)}function Dx(e,t,n,o,r,a){let i,s=n-t,l=a-r;if(s<l){let l=Mx(o,r,a,e,t,n,Math.floor(s/6),50);i=l&&[l[1],l[0],l[2]]}else i=Mx(e,t,n,o,r,a,Math.floor(l/6),50);if(!i)return[new kx(t,n,r,a)];let[c,d,u]=i;return Sx(e,t,c,o,r,d).concat(Sx(e,c+u,n,o,d+u,a))}function Px(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];o.toA>r.fromA-t&&o.toB>r.fromB-t&&(e[n-1]=new kx(o.fromA,r.toA,o.fromB,r.toB),e.splice(n--,1))}}let Rx;try{Rx=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(nF){}function Lx(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function zx(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Lx(n)?1:0:Rx?Hx(n)&&t!=e.length-1?Rx.test(e.slice(t,t+2))?2:0:Rx.test(String.fromCharCode(n))?1:0:0}function Fx(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Lx(n)?1:0:Rx?$x(n)&&1!=t?Rx.test(e.slice(t-2,t))?2:0:Rx.test(String.fromCharCode(n))?1:0:0}function Bx(e,t,n){if(t==e.length||!Fx(e,t))return t;for(let o=t,r=t+n;;){let n=zx(e,o);if(!n)return o;if(o+=n,o>r)return t}}function Ux(e,t,n){if(!t||!zx(e,t))return t;for(let o=t,r=t-n;;){let n=Fx(e,o);if(!n)return o;if(o-=n,o<r)return t}}function Vx(e,t,n){for(let o=t,r=t-n;;){let n=o?e.charCodeAt(o-1):10;if(10==n)return o;if(o--,o<r||32!=n&&9!=n)return t}}const Hx=e=>e>=55296&&e<=56319,$x=e=>e>=56320&&e<=57343;function Wx(e,t){return!t||t==e.length||!Hx(e.charCodeAt(t-1))||!$x(e.charCodeAt(t))}function Gx(e,t,n){var o;return Nx=(null!==(o=null==n?void 0:n.scanLimit)&&void 0!==o?o:1e9)>>1,function(e,t,n){for(;;){Px(n,1);let o=!1;for(let r=0;r<n.length;r++){let a,i,s=n[r];(a=Ax(e,s.fromA,s.toA,t,s.fromB,s.toB))&&(s=n[r]=new kx(s.fromA+a,s.toA,s.fromB+a,s.toB)),(i=Tx(e,s.fromA,s.toA,t,s.fromB,s.toB))&&(s=n[r]=new kx(s.fromA,s.toA-i,s.fromB,s.toB-i));let l=s.toA-s.fromA,c=s.toB-s.fromB;if(l&&c)continue;let d=s.fromA-(r?n[r-1].toA:0),u=(r<n.length-1?n[r+1].fromA:e.length)-s.toA;if(!d||!u)continue;let h=l?e.slice(s.fromA,s.toA):t.slice(s.fromB,s.toB);d<=h.length&&e.slice(s.fromA-d,s.fromA)==h.slice(h.length-d)?(n[r]=new kx(s.fromA-d,s.toA-d,s.fromB-d,s.toB-d),o=!0):u<=h.length&&e.slice(s.toA,s.toA+u)==h.slice(0,u)&&(n[r]=new kx(s.fromA+u,s.toA+u,s.fromB+u,s.toB+u),o=!0)}if(!o)break}return n}(e,t,Sx(e,0,e.length,t,0,t.length))}function qx(e,t,n){return function(e,t,n){for(let o=0,r=0;r<e.length;r++){let a=e[r],i=a.toA-a.fromA,s=a.toB-a.fromB;if(i&&s||i>3||s>3){let l=r==e.length-1?t.length:e[r+1].fromA,c=a.fromA-o,d=l-a.toA,u=Ux(t,a.fromA,Math.min(c,5)),h=Bx(t,a.toA,Math.min(d,5)),f=a.fromA-u,m=h-a.toA;if(!i||!s){let d,p,g=Math.max(i,s),[v,y,x]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];f&&m?(g>f&&t.slice(u,a.fromA)==v.slice(x-f,x)?(a=e[r]=new kx(u,u+i,a.fromB-f,a.toB-f),u=a.fromA,h=Bx(t,a.toA,Math.min(l-a.toA,5))):g>m&&t.slice(a.toA,h)==v.slice(y,y+m)&&(a=e[r]=new kx(h-i,h,a.fromB+m,a.toB+m),h=a.toA,u=Ux(t,a.fromA,Math.min(a.fromA-o,5))),f=a.fromA-u,m=h-a.toA):f||m||!(p=a.fromA-(d=Vx(t,a.fromA,c)))||t.slice(d,a.fromA)!=v.slice(x-p,x)||(a=e[r]=new kx(d,d+i,a.fromB-p,a.toB-p))}(f||m)&&(a=e[r]=new kx(a.fromA-f,a.toA+m,a.fromB-f,a.toB+m)),o=a.toA}}return Px(e,3),e}(Gx(e,t,n),e,t)}const Yx=bn.define({combine:e=>e[0]}),Xx=Xt.define(),Kx=Kt.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(Xx)&&(e=n.value);return e}});class Jx{constructor(e,t,n,o,r){this.changes=e,this.fromA=t,this.toA=n,this.fromB=o,this.toB=r}offset(e,t){return e||t?new Jx(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return eb(qx(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,o,r){return rb(ob(e,o,!0,n.length),e,t,n,r)}static updateB(e,t,n,o,r){return rb(ob(e,o,!1,t.length),e,t,n,r)}}function Zx(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[r.from,a.from]}function Qx(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.from==e&&a.from==t?[e,t]:[r.to+1,a.to+1]}function eb(e,t,n,o,r){let a=[];for(let i=0;i<e.length;i++){let s=e[i],[l,c]=Zx(s.fromA+o,s.fromB+r,t,n),[d,u]=Qx(s.toA+o,s.toB+r,t,n),h=[s.offset(-l+o,-c+r)];for(;i<e.length-1;){let a=e[i+1],[s,f]=Zx(a.fromA+o,a.fromB+r,t,n);if(s>d+1&&f>u+1)break;h.push(a.offset(-l+o,-c+r)),[d,u]=Qx(a.toA+o,a.toB+r,t,n),i++}a.push(new Jx(h,l,Math.max(l,d),c,Math.max(c,u)))}return a}const tb=1e3;function nb(e,t,n,o){let r=0,a=e.length;for(;;){if(r==a){let o=0,a=0;r&&({toA:o,toB:a}=e[r-1]);let i=t-(n?o:a);return[o+i,a+i]}let i=r+a>>1,s=e[i],[l,c]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(l>t)a=i;else{if(!(c<=t))return o?[s.fromA,s.fromB]:[s.toA,s.toB];r=i+1}}}function ob(e,t,n,o){let r=[];return t.iterChangedRanges(((a,i,s,l)=>{let c=0,d=n?t.length:o,u=0,h=n?o:t.length;a>tb&&([c,u]=nb(e,a-tb,n,!0)),i<t.length-tb&&([d,h]=nb(e,i+tb,n,!1));let f,m=l-s-(i-a),[p,g]=n?[m,0]:[0,m];r.length&&(f=r[r.length-1]).toA>=c?r[r.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+p,diffB:f.diffB+g}:r.push({fromA:c,toA:d,fromB:u,toB:h,diffA:p,diffB:g})})),r}function rb(e,t,n,o,r){if(!e.length)return t;let a=0,i=0,s=0,l=[];for(let c of e){let e=c.fromA+i,d=c.toA+i+c.diffA,u=c.fromB+s,h=c.toB+s+c.diffB;for(;a<t.length;){let n=t[a];if(n.toA+i<=e&&n.toB+s<=u)l.push(n.offset(i,s));else if(n.fromA+i>d)break;a++}for(let t of eb(qx(n.sliceString(e,d),o.sliceString(u,h),r),n,o,e,u))l.push(t);for(i+=c.diffA,s+=c.diffB;a<t.length;){let e=t[a];if(e.fromA>d+i&&e.fromB>h+s)break;a++}}for(;a<t.length;)l.push(t[a++].offset(i,s));return l}const ab=Zt.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=fb(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(Kx,!1)!=n.field(Kx,!1))||function(e,t){return e.facet(Yx)!=t.facet(Yx)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=fb(e.view))}},{decorations:e=>e.deco}),ib=yn.low(jr({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ab))||void 0===t?void 0:t.gutter)||_r.empty}}));const sb=Jt.line({class:"cm-changedLine"}),lb=Jt.mark({class:"cm-changedText"}),cb=Jt.mark({tagName:"ins",class:"cm-insertedLine"}),db=Jt.mark({tagName:"del",class:"cm-deletedLine"}),ub=new class extends Tr{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function hb(e,t,n,o,r,a){let i=n?e.fromA:e.fromB,s=n?e.toA:e.toB,l=0;if(i!=s){r.add(i,i,sb),r.add(i,s,n?db:cb),a&&a.add(i,i,ub);for(let c=t.iterRange(i,s-1),d=i;!c.next().done;){if(c.lineBreak){d++,r.add(d,d,sb),a&&a.add(d,d,ub);continue}let t=d+c.value.length;if(o)for(;l<e.changes.length;){let o=e.changes[l],a=i+(n?o.fromA:o.fromB),s=i+(n?o.toA:o.toB),c=Math.max(d,a),u=Math.min(t,s);if(c<u&&r.add(c,u,lb),!(s<t))break;l++}d=t}}}function fb(e){let t=e.state.field(Kx),{side:n,highlightChanges:o,markGutter:r}=e.state.facet(Yx),a="a"==n,i=new Qt,s=r?new Qt:null,{from:l,to:c}=e.viewport;for(let d of t){if((a?d.fromA:d.fromB)>=c)break;(a?d.toA:d.toB)>l&&hb(d,e.state.doc,a,o,i,s)}return{deco:i.finish(),gutter:s&&s.finish()}}class mb extends xn{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const pb=Xt.define({map:(e,t)=>e.map(t)}),gb=Kt.define({create:()=>Jt.none,update:(e,t)=>{for(let n of t.effects)if(n.is(pb))return n.value;return e.map(t.changes)},provide:e=>Yt.decorations.from(e)}),vb=.01;const yb=Xt.define({map:(e,t)=>t.mapPos(e)});class xb extends xn{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent="⦚ "+e.state.phrase("$ unchanged lines",this.lines)+" ⦚",t.addEventListener("click",(t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:yb.of(n)});let{side:o,sibling:r}=e.state.facet(Yx);r&&r().dispatch({effects:yb.of(bb(n,e.state.field(Kx),"a"==o))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function bb(e,t,n){let o=0,r=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return r+(e-o);[o,r]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const wb=Kt.define({create:e=>Jt.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(yb)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Yt.decorations.from(e)});function kb({margin:e=3,minSize:t=4}){return wb.init((n=>function(e,t,n){let o=new Qt,r="a"==e.facet(Yx).side,a=e.field(Kx),i=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,c=s?i+t:1,d=l?e.doc.lineAt(r?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&o.add(e.doc.line(c).from,e.doc.line(d).to,Jt.replace({widget:new xb(u),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,r?l.toA:l.toB)).number}return o.finish()}(n,e,t)))}const Sb=Yt.styleModule.of(new Ir({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Nb=Yt.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},".cm-insertedLine, .cm-deletedLine":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}}),Cb=new Ar,Eb=new Ar;class jb{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[yn.low(ab),Nb,Sb,gb,Yt.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(pb)))))&&this.measure()}))],n=[Yx.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(ib);let o=ro.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Yt.editorAttributes.of({class:"cm-merge-a"}),Eb.of(n),t]}),r=[Yx.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&r.push(ib);let a=ro.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Yt.editorAttributes.of({class:"cm-merge-b"}),Eb.of(r),t]});this.chunks=Jx.build(o.doc,a.doc,this.diffConf);let i=[Kx.init((()=>this.chunks)),Cb.of(e.collapseUnchanged?kb(e.collapseUnchanged):[])];o=o.update({effects:Xt.appendConfig.of(i)}).state,a=a.update({effects:Xt.appendConfig.of(i)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let s=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==s?l:c),this.editorDOM.appendChild("a-b"==s?c:l),this.a=new Yt({state:o,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Yt({state:a,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some((e=>e.docChanged))){let n=e[e.length-1],o=e.reduce(((e,t)=>e.compose(t.changes)),Nn.empty(e[0].startState.doc.length));this.chunks=t==this.a?Jx.updateA(this.chunks,n.newDoc,this.b.state.doc,o,this.diffConf):Jx.updateB(this.chunks,this.a.state.doc,n.newDoc,o,this.diffConf),t.update([...e,n.state.update({effects:Xx.of(this.chunks)})]);let r=t==this.a?this.b:this.a;r.update([r.state.update({effects:Xx.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,o=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(t,n,o)}let t="highlightChanges"in e,n="gutter"in e,o="collapseUnchanged"in e;if(t||n||o){let r=[],a=[];if(t||n){let o=this.a.state.facet(Yx),i=n?!1!==e.gutter:o.markGutter,s=t?!1!==e.highlightChanges:o.highlightChanges;r.push(Eb.reconfigure([Yx.of({side:"a",sibling:()=>this.b,highlightChanges:s,markGutter:i}),i?ib:[]])),a.push(Eb.reconfigure([Yx.of({side:"b",sibling:()=>this.a,highlightChanges:s,markGutter:i}),i?ib:[]]))}if(o){let t=Cb.reconfigure(e.collapseUnchanged?kb(e.collapseUnchanged):[]);r.push(t),a.push(t)}this.a.dispatch({effects:r}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(e=>this.revertClicked(e))),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame((()=>{this.measuring=-1,this.measure()}))}}measure(){!function(e,t,n){let o=new Qt,r=new Qt,a=e.state.field(gb).iter(),i=t.state.field(gb).iter(),s=0,l=0,c=0,d=0;for(let m=0;;m++){let u=m<n.length?n[m]:null;if(s<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(s).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,o.add(s,s,Jt.widget({widget:new mb(-n),block:!0,side:-1}))):n>vb&&(d+=n,r.add(l,l,Jt.widget({widget:new mb(n),block:!0,side:-1})))}if(!u)break;for(s=u.toA,l=u.toB;a.value&&a.from<s;)c-=a.value.spec.widget.height,a.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let u=e.contentHeight+c-(t.contentHeight+d);u<vb?o.add(e.state.doc.length,e.state.doc.length,Jt.widget({widget:new mb(-u),block:!0,side:1})):u>vb&&r.add(t.state.doc.length,t.state.doc.length,Jt.widget({widget:new mb(u),block:!0,side:1}));let h=o.finish(),f=r.finish();_r.eq([h],[e.state.field(gb)])||e.dispatch({effects:pb.of(h)}),_r.eq([f],[t.state.field(gb)])||t.dispatch({effects:pb.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,o=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let a=this.chunks[r];if(a.fromA>n.to||a.fromB>o.to)break;if(a.fromA<n.from||a.fromB<o.from)continue;let i=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<r;)t=_b(t);t&&t.dataset.chunk==String(r)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,r),t)}for(;t;)t=_b(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,o,r,a,i,s]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],l=n.state.sliceDoc(r,Math.max(r,a-1));r!=a&&s<=o.state.doc.length&&(l+=n.state.lineBreak),o.dispatch({changes:{from:i,to:Math.min(o.state.doc.length,s),insert:l},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function _b(e){let t=e.nextSibling;return e.remove(),t}var Ib=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl"],Ab=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],Tb=u.forwardRef(((e,t)=>{var{className:n,children:o,orientation:a,revertControls:i,highlightChanges:s,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u}=e,h=Cr(e,Ib),f=gx(),{modified:m,modifiedExtension:p,original:g,originalExtension:v,theme:y,dispatch:x}=f,b=Cr(f,Ab),w=r.useRef(null),S=r.useRef(),N={orientation:a,revertControls:i,highlightChanges:s,gutter:l,collapseUnchanged:c,renderRevertControl:u};r.useImperativeHandle(t,(()=>({container:w.current,view:S.current,modified:m,original:g,config:mo({a:g,b:m,parent:w.current},N)})),[w,S,m,g,N]);var C=Yt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==v?void 0:v.onChange)){var t=e.state.doc.toString();null==v||v.onChange(t,e)}})),E=Yt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==p?void 0:p.onChange)){var t=e.state.doc.toString();null==p||p.onChange(t,e)}}));r.useEffect((()=>{!S.current&&w.current&&v&&p&&(S.current=new jb(mo({a:mo({},g,{extensions:[...(null==v?void 0:v.extension)||[],...Er(mo({},null==v?void 0:v.option,{theme:y})),C]}),b:mo({},m,{extensions:[...(null==p?void 0:p.extension)||[],...Er(mo({},null==p?void 0:p.option,{theme:y})),E]}),parent:w.current},N)),x({view:S.current}))}),[S,w,v,p]),r.useEffect((()=>{if(g&&g.doc&&S.current){var e,t,n=null==(e=S.current)?void 0:e.a.state.doc.toString();if(n!==g.doc)null==(t=S.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:g.doc||""}})}if(m&&m.doc&&S.current){var o,r,a=null==(o=S.current)?void 0:o.b.state.doc.toString();if(a!==m.doc)null==(r=S.current)||r.b.dispatch({changes:{from:0,to:a.length,insert:m.doc||""}})}if(d&&S.current){var i=S.current.a.state.selection.ranges[0].from,s=S.current.b.state.selection.ranges[0].from;S.current.destroy(),S.current=new jb(mo({a:mo({},g,{extensions:[...(null==v?void 0:v.extension)||[],...Er(mo({},null==v?void 0:v.option,{theme:y}))]}),b:mo({},m,{extensions:[...(null==p?void 0:p.extension)||[],...Er(mo({},null==p?void 0:p.option,{theme:y}))]}),parent:w.current},N)),i&&(S.current.a.focus(),S.current.a.dispatch({selection:{anchor:i,head:i}})),s&&(S.current.b.focus(),S.current.b.dispatch({selection:{anchor:s,head:s}}))}}),[S,y,w.current,g,m,v,p,d]),r.useEffect((()=>()=>S.current&&S.current.destroy()),[]),r.useEffect((()=>{if(S.current){var e={};b.orientation!==a&&(e.orientation=a),b.revertControls!==i&&(e.revertControls=i),b.highlightChanges!==s&&(e.highlightChanges=s),b.gutter!==l&&(e.gutter=l),b.collapseUnchanged!==c&&(e.collapseUnchanged=c),b.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&x&&S.current&&(S.current.reconfigure(mo({},e)),x(mo({},e)))}}),[x,S,a,i,s,l,c,u]);return k.jsx("div",mo({ref:w,className:"cm-merge-theme"+(n?" "+n:"")},h,{children:o}))}));Tb.displayName="CodeMirrorMerge.Internal";var Mb=["theme"],Ob=u.forwardRef(((e,t)=>{var{theme:n}=e,o=Cr(e,Mb);return k.jsx(vx,{theme:n,children:k.jsx(Tb,mo({},o,{ref:t}))})}));function Db(e){return void 0===e&&(e=[]),Mr({override:[t=>{var n=t.matchBefore(/@(\w+)?/);return n?n&&n.from==n.to&&!t.explicit?null:{from:null==n?void 0:n.from,options:[...e]}:null}]})}function Pb(e){const t=function(e){const t=te.get(Or),n=Dr.keyBy(t,(e=>e.name)),o=e.match(/@([\w.]+)/g)||[];return o.map((e=>e.slice(1))).map((e=>n.get(e))).filter(Boolean)}(e);return J.debug("Included datasets",t),{includeOtherCode:zs(""),context:{schema:t.map((e=>({name:e.name,columns:e.columns.map((e=>({name:e.name,type:e.type})))})))}}}Ob.Original=xx,Ob.Modified=wx,Ob.displayName="CodeMirrorMerge",Db();const Rb=[Pr(),Yt.lineWrapping],Lb=[Rr(),Yt.lineWrapping],zb=Lr("marimo:ai-language","python"),Fb=e=>{const t=b(65),{onClose:n}=e,{createNewCell:o}=q();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={},t[0]=a):a=t[0];const[i,s]=r.useState(a),[l,c]=Le(zb),{theme:d}=Me();let u,h,f;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=zr("api/ai/completion").toString(),h=Fr.headers(),t[1]=u,t[2]=h):(u=t[1],h=t[2]),t[3]!==i||t[4]!==l?(f={api:u,headers:h,streamMode:"text",body:{...i,language:l,code:""},onError:Ub},t[3]=i,t[4]=l,t[5]=f):f=t[5];const{completion:m,input:p,stop:g,isLoading:v,setCompletion:y,setInput:x,handleSubmit:w}=Br(f);let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Fc,{className:"size-4 text-[var(--blue-11)]"}),t[6]=S):S=t[6];const N="python"===l?"Python":"SQL";let E,j,_,I,A,T,M,O,D,P,R,L,z,F,B;t[7]===Symbol.for("react.memo_cache_sentinel")?(E=k.jsx(Hr,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),t[7]=E):E=t[7],t[8]!==N?(j=k.jsx(Dt,{asChild:!0,children:k.jsxs(C,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:[N,E]})}),t[8]=N,t[9]=j):j=t[9],t[10]!==c?(_=k.jsx(Ot,{onClick:()=>c("python"),children:"Python"}),t[10]=c,t[11]=_):_=t[11],t[12]!==c?(I=k.jsx(Ot,{onClick:()=>c("sql"),children:"SQL"}),t[12]=c,t[13]=I):I=t[13],t[14]!==_||t[15]!==I?(A=k.jsxs(Ut,{align:"center",children:[_,I]}),t[14]=_,t[15]=I,t[16]=A):A=t[16],t[17]!==j||t[18]!==A?(T=k.jsxs(Bt,{modal:!1,children:[j,A]}),t[17]=j,t[18]=A,t[19]=T):T=t[19],t[20]!==y||t[21]!==n?(M=()=>{y(""),n()},t[20]=y,t[21]=n,t[22]=M):M=t[22],t[23]!==x?(O=e=>{x(e),s(Pb(e))},t[23]=x,t[24]=O):O=t[24],t[25]!==v||t[26]!==w?(D=()=>{v||w()},t[25]=v,t[26]=w,t[27]=D):D=t[27],t[28]!==d||t[29]!==M||t[30]!==p||t[31]!==O||t[32]!==D?(P=k.jsx(Bb,{theme:d,onClose:M,value:p,onChange:O,onSubmit:D}),t[28]=d,t[29]=M,t[30]=p,t[31]=O,t[32]=D,t[33]=P):P=t[33],t[34]!==v||t[35]!==g?(R=v&&k.jsxs(C,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:g,children:[k.jsx($r,{className:"animate-spin mr-1",size:14}),"Stop"]}),t[34]=v,t[35]=g,t[36]=R):R=t[36],t[37]!==v||t[38]!==m||t[39]!==o||t[40]!==l||t[41]!==y||t[42]!==n?(L=!v&&m&&k.jsx(C,{"data-testid":"accept-completion-button",variant:"text",size:"sm",className:"mb-0",disabled:v,onClick:()=>{o({cellId:"__end__",before:!1,code:"python"===l?m:Vo.fromQuery(m)}),y(""),n()},children:k.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),t[37]=v,t[38]=m,t[39]=o,t[40]=l,t[41]=y,t[42]=n,t[43]=L):L=t[43],t[44]===Symbol.for("react.memo_cache_sentinel")?(z=k.jsx(tn,{className:"size-4"}),t[44]=z):z=t[44],t[45]!==n?(F=k.jsx(C,{variant:"text",size:"sm",className:"mb-0",onClick:n,children:z}),t[45]=n,t[46]=F):F=t[46],t[47]!==T||t[48]!==P||t[49]!==R||t[50]!==L||t[51]!==F?(B=k.jsxs("div",{className:"flex items-center px-3",children:[S,T,P,R,L,F]}),t[47]=T,t[48]=P,t[49]=R,t[50]=L,t[51]=F,t[52]=B):B=t[52];const U=B;let V,H,$,W;return t[53]===Symbol.for("react.memo_cache_sentinel")?(V=rn("flex flex-col w-full gap-2 py-2"),t[53]=V):V=t[53],t[54]!==m?(H=!m&&k.jsxs("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1",children:[k.jsxs("span",{children:["You can mention"," ",k.jsx("span",{className:"text-[var(--cyan-11)]",children:"@dataframe"})," or"," ",k.jsx("span",{className:"text-[var(--cyan-11)]",children:"@sql_table"})," to pull additional context such as column names."]}),k.jsx("span",{children:"Code from other cells is automatically included."})]}),t[54]=m,t[55]=H):H=t[55],t[56]!==m||t[57]!==d||t[58]!==l||t[59]!==y?($=m&&k.jsx(Wr,{value:m,className:"cm border-t",onChange:y,theme:"dark"===d?"dark":"light",extensions:"python"===l?Rb:Lb}),t[56]=m,t[57]=d,t[58]=l,t[59]=y,t[60]=$):$=t[60],t[61]!==U||t[62]!==H||t[63]!==$?(W=k.jsxs("div",{className:V,children:[U,H,$]}),t[61]=U,t[62]=H,t[63]=$,t[64]=W):W=t[64],W},Bb=e=>{const t=b(24),{value:n,placeholder:o,inputRef:r,className:a,onChange:i,onSubmit:s,onClose:l,theme:c}=e,d=s,u=l,h=le(Or);let f,m,p,g,v,y,x,w;if(t[0]!==h){let e;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=e=>({label:`@${e.name}`,info:()=>{const t=[null==e.num_rows?void 0:`${e.num_rows} rows`,null==e.num_columns?void 0:`${e.num_columns} columns`].filter(Boolean).join(", "),n=document.createElement("div");if(n.classList.add("prose","prose-sm","dark:prose-invert"),t){const e=document.createElement("div");e.textContent=t,e.style.fontWeight="bold",n.append(e)}if(e.source){const t=document.createElement("figcaption");t.textContent=`Source: ${e.source}`,n.append(t)}if(e.columns){const t=document.createElement("table"),o=t.insertRow(),r=o.insertCell();r.textContent="Column",r.style.fontWeight="bold";const a=o.insertCell();a.textContent="Type",a.style.fontWeight="bold",e.columns.forEach((e=>{const n=t.insertRow();n.insertCell().textContent=e.name;n.insertCell().textContent=e.type})),n.append(t)}return n}}),t[2]=e):e=t[2];m=Db(h.map(e)),t[0]=h,t[1]=m}else m=t[1];t[3]===Symbol.for("react.memo_cache_sentinel")?(p=Ur(),t[3]=p):p=t[3],t[4]!==d?(g=yn.highest(pn.of([{preventDefault:!0,stopPropagation:!0,any:(e,t)=>{const n=t.metaKey||t.ctrlKey||t.shiftKey;if("Enter"===t.key&&!n)return d(t,e.state.doc.toString()),t.preventDefault(),t.stopPropagation(),!0;if("Enter"===t.key&&t.shiftKey){const n=e.state.selection.main.from;return e.dispatch({changes:{from:n,to:n,insert:"\n"},selection:{anchor:n+1,head:n+1}}),t.preventDefault(),t.stopPropagation(),!0}return!1}}])),t[4]=d,t[5]=g):g=t[5],t[6]!==u?(v=pn.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(u(),!0)}]),t[6]=u,t[7]=v):v=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(y=pn.of([{key:"ArrowUp",preventDefault:!0,stopPropagation:!0}]),x=pn.of([{key:"ArrowDown",preventDefault:!0,stopPropagation:!0}]),t[8]=y,t[9]=x):(y=t[8],x=t[9]),t[10]!==m||t[11]!==g||t[12]!==v?(w=[m,Yt.lineWrapping,p,g,v,y,x],t[10]=m,t[11]=g,t[12]=v,t[13]=w):w=t[13],f=w;const S=f;let N;t[14]!==a?(N=rn("flex-1 font-sans overflow-auto my-1",a),t[14]=a,t[15]=N):N=t[15];const C="dark"===c?"dark":"light",E=o||"Generate with AI";let j;return t[16]!==r||t[17]!==N||t[18]!==n||t[19]!==S||t[20]!==i||t[21]!==C||t[22]!==E?(j=k.jsx(Wr,{ref:r,className:N,autoFocus:!0,width:"100%",value:n,basicSetup:!1,extensions:S,onChange:i,theme:C,placeholder:E}),t[16]=r,t[17]=N,t[18]=n,t[19]=S,t[20]=i,t[21]=C,t[22]=E,t[23]=j):j=t[23],j};function Ub(e){re({title:"Generate with AI failed",description:Vr(e)})}const Vb=Ob.Original,Hb=Ob.Modified,$b=[Pr(),Yt.lineWrapping],Wb=e=>{const t=b(53),{onChange:n,initialPrompt:o,currentLanguageAdapter:a,currentCode:i,declineChange:s,acceptChange:l,enabled:c,children:d}=e;let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h={},t[0]=h):h=t[0];const[f,m]=r.useState(h),[p,g]=Le(Sd);let v,y,x,w,S;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=zr("api/ai/completion").toString(),y=Fr.headers(),t[1]=v,t[2]=y):(v=t[1],y=t[2]),t[3]!==p||t[4]!==i?(x=p?zs(i):"",t[3]=p,t[4]=i,t[5]=x):x=t[5],t[6]!==f||t[7]!==x||t[8]!==i||t[9]!==a?(w={...f,includeOtherCode:x,code:i,language:a},t[6]=f,t[7]=x,t[8]=i,t[9]=a,t[10]=w):w=t[10],t[11]!==o||t[12]!==w?(S={api:v,headers:y,initialInput:o,streamMode:"text",body:w,onError:Gb},t[11]=o,t[12]=w,t[13]=S):S=t[13];const{completion:E,input:j,stop:_,isLoading:I,setCompletion:A,setInput:T,handleSubmit:M}=Br(S),O=u.useRef(null);let D,P,R,L;t[14]!==c?(D=()=>{const e=O.current;c&&e&&(requestAnimationFrame((()=>{var t;null==(t=e.view)||t.focus()})),Gr(O.current.view))},P=[c],t[14]=c,t[15]=D,t[16]=P):(D=t[15],P=t[16]),r.useEffect(D,P),t[17]!==c||t[18]!==T||t[19]!==o?(R=()=>{c&&T(o||"")},L=[c,o,T],t[17]=c,t[18]=T,t[19]=o,t[20]=R,t[21]=L):(R=t[20],L=t[21]),r.useEffect(R,L);const{theme:z}=Me(),F=c&&"max-h-[400px] min-h-11 visible",B=!c&&"max-h-0 min-h-0 invisible";let U,V,H,$;t[22]!==F||t[23]!==B?(U=rn("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",F,B),t[22]=F,t[23]=B,t[24]=U):U=t[24],t[25]!==c||t[26]!==s||t[27]!==A||t[28]!==T||t[29]!==I||t[30]!==M||t[31]!==O||t[32]!==z||t[33]!==j||t[34]!==_||t[35]!==E||t[36]!==l||t[37]!==g||t[38]!==p?(V=c&&k.jsxs(k.Fragment,{children:[k.jsx(Fc,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),k.jsx(Bb,{inputRef:O,theme:z,onClose:()=>{s(),A("")},value:j,onChange:e=>{T(e),m(Pb(e))},onSubmit:()=>{I||M()}}),I&&k.jsxs(C,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:_,children:[k.jsx($r,{className:"animate-spin mr-1",size:14}),"Stop"]}),!I&&E&&k.jsx(C,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:I,onClick:()=>{l(E),A("")},children:k.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),k.jsx("div",{className:"h-full w-px bg-border mx-2"}),k.jsx(N,{content:"Include code from other cells",children:k.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[k.jsx(qr,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:p,onCheckedChange:e=>g(Boolean(e))}),k.jsx(Ae,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),k.jsx(C,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:I,onClick:()=>{_(),s(),A("")},children:k.jsx(tn,{className:"text-[var(--red-10)]",size:16})})]}),t[25]=c,t[26]=s,t[27]=A,t[28]=T,t[29]=I,t[30]=M,t[31]=O,t[32]=z,t[33]=j,t[34]=_,t[35]=E,t[36]=l,t[37]=g,t[38]=p,t[39]=V):V=t[39],t[40]!==U||t[41]!==V?(H=k.jsx("div",{className:U,children:V}),t[40]=U,t[41]=V,t[42]=H):H=t[42],t[43]!==E||t[44]!==c||t[45]!==n||t[46]!==i||t[47]!==z?($=E&&c&&k.jsxs(Ob,{className:"cm",theme:z,children:[k.jsx(Vb,{onChange:n,value:i,extensions:$b}),k.jsx(Hb,{value:E,editable:!1,readOnly:!0,extensions:$b})]}),t[43]=E,t[44]=c,t[45]=n,t[46]=i,t[47]=z,t[48]=$):$=t[48];const W=(!E||!c)&&d;let G;return t[49]!==H||t[50]!==$||t[51]!==W?(G=k.jsxs("div",{className:"flex flex-col w-full rounded-[inherit] overflow-hidden",children:[H,$,W]}),t[49]=H,t[50]=$,t[51]=W,t[52]=G):G=t[52],G};function Gb(e){re({title:"Completion failed",description:Vr(e)})}const qb=u.forwardRef(((e,t)=>{const{className:n,editorView:o}=e,a=r.useRef(null);return r.useEffect((()=>{null!==o&&null!==a.current&&0===a.current.children.length&&a.current.append(o.dom)}),[o,a]),k.jsx("div",{className:rn("cm",n),ref:Ug(t,a),"data-testid":"cell-editor"})}));qb.displayName="CellCodeMirrorEditor";const Yb=r.memo((({theme:e,showPlaceholder:t,allowFocus:n,id:o,config:a,code:i,status:s,serializedEditorState:l,runCell:c,updateCellCode:d,createNewCell:u,deleteCell:h,focusCell:f,moveCell:m,moveToNextCell:p,updateCellConfig:g,clearSerializedEditorState:v,userConfig:y,editorViewRef:x,hidden:w,setTemporarilyVisible:S})=>{var N;const[C,E]=Le(kd),[j,_]=r.useState(),I=function(){const e=b(2),t=ce(Pd);let n;return e[0]!==t?(n=e=>{Te!==e&&t(e)},e[0]=t,e[1]=n):n=e[1],n}(),A=r.useRef(null),T="running"===s||"queued"===s,{sendToTop:M,sendToBottom:O}=q(),D=function(){const e=b(3),{splitCell:t,undoSplitCell:n}=q();let o;return e[0]!==t||e[1]!==n?(o=e=>{const o=Yr(e.cellId),r=(null==o?void 0:o.state.doc.toString())??"";t(e);const{dismiss:a}=re({title:"Cell split",action:k.jsx(Ed,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...e,snapshot:r}),i()},children:"Undo"})}),i=a},e[0]=t,e[1]=n,e[2]=o):o=e[2],G(o)}(),P=G((()=>!T&&(h({cellId:o}),!0))),R=r.useCallback((()=>u({cellId:o,before:!1})),[o,u]),L=r.useCallback((()=>u({cellId:o,before:!0})),[o,u]),z=r.useCallback((()=>m({cellId:o,before:!1})),[o,m]),F=r.useCallback((()=>m({cellId:o,before:!0})),[o,m]),B=r.useCallback((()=>f({cellId:o,before:!1})),[o,f]),U=r.useCallback((()=>f({cellId:o,before:!0})),[o,f]),V=G((()=>{const e=!a.hide_code;return _e({configs:{[o]:{hide_code:e}}}),g({cellId:o,config:{hide_code:e}}),e})),H=le(ue),$=G((()=>{Id(H,u)})),W=Xr(y),Y=r.useMemo((()=>{const n=(e=>{const{cellId:t,cellMovementCallbacks:n,cellCodeCallbacks:o,keymapConfig:r,hotkeys:a}=e;return[$s(r,n),[Yt.domEventHandlers({drop:(e,t)=>{var n,o;const r=null==(n=e.dataTransfer)?void 0:n.files[0];if(null==r?void 0:r.type.startsWith("text/"))return e.preventDefault(),Mn(t,r),!0;if(null==r?void 0:r.type.startsWith("image/"))return e.preventDefault(),On(t,r),!0;const a=null==(o=e.dataTransfer)?void 0:o.getData("text/plain");if(a){e.preventDefault();const n=t.posAtCoords({x:e.clientX,y:e.clientY});return null!==n&&t.dispatch({changes:{from:n,to:n,insert:a},scrollIntoView:!0}),!0}return!1},dragover:e=>{e.preventDefault()}})],Dn(t,n,a),Pn(t,o,a),tg(e),[Jp,(i=(e,t)=>{_n(e,t)},Zt.define((e=>new Zp(e,i)))),Yt.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})]];var i})({cellId:o,showPlaceholder:t,enableAI:W,cellCodeCallbacks:{updateCellCode:d,afterToggleMarkdown:$},cellMovementCallbacks:{onRun:c,deleteCell:P,createAbove:L,createBelow:R,moveUp:F,moveDown:z,focusUp:U,focusDown:B,sendToTop:M,sendToBottom:O,splitCell:D,moveToNextCell:p,toggleHideCode:V,aiCellCompletion:()=>{let e=!1;return E((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e}},completionConfig:y.completion,keymapConfig:y.keymap,theme:e,hotkeys:new Kr(y.keymap.overrides??{})});return n.push(Zt.define((e=>{const t=e.state.field(Jr);return _(t.type),{update(e){const t=e.state.field(Jr);_(t.type)}}}))),n}),[o,y.keymap,y.completion,W,e,t,L,R,U,B,F,z,p,M,O,D,V,d,P,c,E,$]);r.useEffect((()=>{let e;null===l?null===x.current?(x.current=new Yt({state:ro.create({doc:i,extensions:Y})}),e=!0,we(x.current,Zr(x.current.state).type)):(x.current.dispatch({effects:[Xt.reconfigure.of([Y]),Qr(x.current,y.completion,new Kr(y.keymap.overrides??{}))]}),e=!1):(x.current=new Yt({state:ro.fromJSON(l,{doc:i,extensions:Y},{history:ea})}),we(x.current,Zr(x.current.state).type),e=!0,v({cellId:o})),null!==x.current&&null!==A.current&&A.current.replaceChildren(x.current.dom),e&&n&&requestAnimationFrame((()=>{var e,t;null==(e=x.current)||e.focus(),null==(t=x.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[x,Y,y.completion,y.keymap,v,o,l]),r.useEffect((()=>()=>{var e;null==(e=x.current)||e.destroy()}),[x]);const X=r.useCallback((async()=>{var e,t;if(w&&void 0!==S){S(!0),null==(e=x.current)||e.focus();const n=null==(t=A.current)?void 0:t.parentElement,o=new AbortController;null==n||n.addEventListener("focusout",(()=>{requestAnimationFrame((()=>{var e;const t=document.activeElement;(null==n?void 0:n.contains(t))||(S(!1),null==(e=x.current)||e.dom.blur(),o.abort())}))}),{signal:o.signal})}}),[w,S,x,A]);return k.jsx(Wb,{enabled:(null==C?void 0:C.cellId)===o,initialPrompt:null==C?void 0:C.initialPrompt,currentCode:(null==(N=x.current)?void 0:N.state.doc.toString())??i,currentLanguageAdapter:j,declineChange:()=>{var e;E(null),null==(e=x.current)||e.focus()},onChange:e=>{var t;null==(t=x.current)||t.dispatch({changes:{from:0,to:x.current.state.doc.length,insert:e}})},acceptChange:e=>{var t,n;null==(t=x.current)||t.dispatch({changes:{from:0,to:x.current.state.doc.length,insert:e}}),null==(n=x.current)||n.focus(),E(null)},children:k.jsxs("div",{className:"relative w-full",onFocus:()=>I(o),children:[w&&k.jsx(ta,{onClick:X}),k.jsx(qb,{className:rn(w&&"opacity-20 h-8 overflow-hidden"),editorView:x.current,ref:A}),!w&&k.jsx("div",{className:"absolute top-1 right-5",children:k.jsx(ux,{code:i,editorView:x.current,currentLanguageAdapter:j,onAfterToggle:$})})]})})})),Xb=e=>{const t=b(10);let n,o,r,a;return t[0]!==e.left?(n=k.jsx("div",{className:"flex-1 flex item-center gap-2",children:e.left}),t[0]=e.left,t[1]=n):n=t[1],t[2]!==e.center?(o=k.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),t[2]=e.center,t[3]=o):o=t[3],t[4]!==e.right?(r=k.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right}),t[4]=e.right,t[5]=r):r=t[5],t[6]!==n||t[7]!==o||t[8]!==r?(a=k.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),t[6]=n,t[7]=o,t[8]=r,t[9]=a):a=t[9],a},Kb=e=>{const t=b(8);if(!e.canCollapse&&!e.isCollapsed)return null;const n=e.isCollapsed?"Expand":"Collapse";let o,r,a;return t[0]!==e.isCollapsed?(o=k.jsx(Jb,{isCollapsed:e.isCollapsed}),t[0]=e.isCollapsed,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(r=k.jsx(N,{content:n,children:o}),t[2]=n,t[3]=o,t[4]=r):r=t[4],t[5]!==e.onClick||t[6]!==r?(a=k.jsx(C,{variant:"text",size:"icon",onClick:e.onClick,children:r}),t[5]=e.onClick,t[6]=r,t[7]=a):a=t[7],a},Jb=e=>{const t=b(2),{isCollapsed:n}=e;let o;return t[0]!==n?(o=n?k.jsx(ra,{className:"w-5 h-5 flex-shrink-0"}):k.jsx(Ce,{className:"w-5 h-5 flex-shrink-0"}),t[0]=n,t[1]=o):o=t[1],o},Zb=r.memo((e=>{const t=b(24),{onClick:n,count:o,cellId:r}=e,a=W();let i;t[0]!==a||t[1]!==r?(i=na(a,r),t[0]=a,t[1]=r,t[2]=i):i=t[2];const s=i;let l,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=rn("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Hr,{className:"w-4 h-4 flex-shrink-0"}),t[4]=c):c=t[4];const d=1===o?"cell":"cells";let u,h,f,m,p,g,v;return t[5]!==o||t[6]!==d?(u=k.jsxs(k.Fragment,{children:[c,k.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",d," collapsed"]})]}),t[5]=o,t[6]=d,t[7]=u):u=t[7],t[8]!==s.errored?(h=s.errored&&k.jsx(N,{content:"Has errors",delayDuration:100,children:k.jsx(Nc,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),t[8]=s.errored,t[9]=h):h=t[9],t[10]!==s.stale?(f=s.stale&&k.jsx(N,{content:"Has stale cells",delayDuration:100,children:k.jsx(oa,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),t[10]=s.stale,t[11]=f):f=t[11],t[12]!==s.runningOrQueued?(m=s.runningOrQueued&&k.jsx(N,{content:"Running",delayDuration:100,children:k.jsx($r,{className:"w-4 h-4 flex-shrink-0 animate-spin"})}),t[12]=s.runningOrQueued,t[13]=m):m=t[13],t[14]!==h||t[15]!==f||t[16]!==m?(p=k.jsxs(k.Fragment,{children:[h,f,m]}),t[14]=h,t[15]=f,t[16]=m,t[17]=p):p=t[17],t[18]!==u||t[19]!==p?(g=k.jsx(Xb,{center:u,right:p}),t[18]=u,t[19]=p,t[20]=g):g=t[20],t[21]!==n||t[22]!==g?(v=k.jsx("div",{onClick:n,className:l,children:g}),t[21]=n,t[22]=g,t[23]=v):v=t[23],v}));Zb.displayName="CollapsedCellBanner";const Qb=e=>{const t=b(6),{appClosed:n,status:o}=e,r=Mu("running"===o);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=S("global.interrupt"),t[0]=a):a=t[0];const i=n||!r,s=r?aa:an.NOOP,l=r?"stale":"disabled";let c,d;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(M,{strokeWidth:1.5}),t[1]=c):c=t[1],t[2]!==i||t[3]!==s||t[4]!==l?(d=k.jsx(Ag,{tooltip:a,disabled:i,onClick:s,variant:l,"data-testid":"run-button",children:c}),t[2]=i,t[3]=s,t[4]=l,t[5]=d):d=t[5],d},ew=e=>{const t=b(26),{edited:n,appClosed:o,status:r,cellConfig:a,needsRun:i,hasOutput:s,onRun:l,cellActionDropdownRef:c,cellId:d,getEditorView:u,name:h}=e,f=!i&&"hover-action";let m;t[0]!==f?(m=rn(f),t[0]=f,t[1]=m):m=t[1];const p=o?an.NOOP:l;let g,v,y,x,w;return t[2]!==n||t[3]!==p||t[4]!==o||t[5]!==r||t[6]!==a||t[7]!==i?(g=k.jsx(Mg,{edited:n,onClick:p,appClosed:o,status:r,config:a,needsRun:i}),t[2]=n,t[3]=p,t[4]=o,t[5]=r,t[6]=a,t[7]=i,t[8]=g):g=t[8],t[9]!==r||t[10]!==o?(v=k.jsx(Qb,{status:r,appClosed:o}),t[9]=r,t[10]=o,t[11]=v):v=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(y=k.jsx(Ag,{variant:"green",tooltip:null,children:k.jsx(hl,{strokeWidth:1.5})}),t[12]=y):y=t[12],t[13]!==c||t[14]!==d||t[15]!==r||t[16]!==u||t[17]!==h||t[18]!==a||t[19]!==s?(x=k.jsx(lx,{ref:c,cellId:d,status:r,getEditorView:u,name:h,config:a,hasOutput:s,children:y}),t[13]=c,t[14]=d,t[15]=r,t[16]=u,t[17]=h,t[18]=a,t[19]=s,t[20]=x):x=t[20],t[21]!==m||t[22]!==g||t[23]!==v||t[24]!==x?(w=k.jsxs(Tg,{className:m,children:[g,v,x]}),t[21]=m,t[22]=g,t[23]=v,t[24]=x,t[25]=w):w=t[25],w},tw=r.memo(r.forwardRef((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,output:i,consoleOutputs:s,status:l,runStartTimestamp:c,lastRunStartTimestamp:d,runElapsedTimeMs:u,edited:h,interrupted:f,errored:m,stopped:p,staleInputs:g,serializedEditorState:v,mode:y,debuggerActive:x,appClosed:b,canDelete:w,updateCellCode:N,prepareForRun:C,createNewCell:E,deleteCell:j,focusCell:_,moveCell:I,setStdinResponse:A,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:O,sendToBottom:D,sendToTop:P,collapseCell:R,expandCell:L,userConfig:z,outline:F,isCollapsed:B,collapseCount:U,config:V,canMoveX:H,name:$},W)=>{J.debug("Rendering Cell",o);const q=r.useRef(null),Y=r.useRef(null),Z=r.useRef(null),Q=ce(kd),[ee,te]=r.useState(!1),ne=V.disabled||"disabled-transitively"===l,oe=ia(z.runtime.auto_instantiate,u,l,m,f,p),re=oe||h||f||g&&!ne,ae="running"===l||"queued"===l,ie=sa({status:l,output:i,runStartTimestamp:c,interrupted:f,staleInputs:g},h),se=("queued"===l||h||g)&&!f,le="edit"===y,de=r.useCallback((()=>{const e=ng(Z),t=X(e);return"markdown"!==la(e)&&ca(e),C({cellId:o}),t}),[o,Z,C]);r.useImperativeHandle(W,(()=>({get editorView(){return ng(Z)},registerRun:de})),[Z,de]);const ue=r.useCallback((()=>Z.current),[Z]),he=G((async()=>{if(ae)return;const e=de();await K({cellIds:[o],codes:[e]}).catch((e=>{J.error("Error running cell",e)}))})),fe=r.useCallback(((e={})=>E({cellId:o,before:!1,...e})),[o,E]),me=r.useCallback(((e={})=>E({cellId:o,before:!0,...e})),[o,E]),pe=r.useCallback((e=>{null===q.current||q.current.contains(e.relatedTarget)||null===Z.current||ca(Z.current)}),[]),ge=r.useCallback((e=>{if(q.current===document.activeElement&&null!==Z.current&&"active"===Sn(Z.current.state)){for(const t of da)if(e.key===t.key&&t.run){t.run(Z.current),e.preventDefault(),e.stopPropagation();break}Z.current.focus()}}),[q,Z]),ve=!ua(i),ye=ve&&k.jsxs("div",{className:"relative",children:[k.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:k.jsx(Kb,{isCollapsed:B,onClick:()=>{B?L({cellId:o}):R({cellId:o})},canCollapse:ha(F)})}),k.jsx(fa,{allowExpand:le,output:i,className:"output-area",cellId:o,stale:ie})]}),xe=ma("Cell","hover-actions-parent z-10",{published:!le,interactive:le,"needs-run":re,"has-error":m,stopped:p,disabled:V.disabled,stale:"disabled-transitively"===l}),be=ft.create(o),we=!V.hide_code||ee;if(Ws(le?q:null,{"cell.run":he,"cell.runAndNewBelow":()=>{he(),T({cellId:o,before:!1})},"cell.runAndNewAbove":()=>{he(),T({cellId:o,before:!0})},"cell.createAbove":me,"cell.createBelow":fe,"cell.moveUp":()=>I({cellId:o,before:!0}),"cell.moveDown":()=>I({cellId:o,before:!1}),"cell.hideCode":()=>{var e,t,n;const r=!V.hide_code;_e({configs:{[o]:{hide_code:r}}}),M({cellId:o,config:{hide_code:r}}),r?(null==(e=Z.current)||e.contentDOM.blur(),null==(t=q.current)||t.focus()):null==(n=Z.current)||n.focus()},"cell.focusDown":()=>T({cellId:o,before:!1}),"cell.focusUp":()=>T({cellId:o,before:!0}),"cell.sendToBottom":()=>D({cellId:o}),"cell.sendToTop":()=>P({cellId:o}),"cell.aiCompletion":()=>{let e=!1;Q((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e&&ng(Z).focus()},"cell.cellActions":()=>{var e;null==(e=Y.current)||e.toggle()}}),Gs(le?q:null,{ArrowDown:()=>(T({cellId:o,before:!1,noCreate:!0}),!0),ArrowUp:()=>(T({cellId:o,before:!0,noCreate:!0}),!0),..."vim"!==z.keymap.preset||we?{}:{j:()=>(T({cellId:o,before:!1,noCreate:!0}),!0),k:()=>(T({cellId:o,before:!0,noCreate:!0}),!0)}}),!le){const e=pa(null==i?void 0:i.mimetype);return m||f||p||e?null:k.jsx("div",{tabIndex:-1,id:be,ref:q,className:xe,children:ye})}return k.jsx(dx,{cellId:o,config:V,status:l,getEditorView:ue,hasOutput:ve,name:$,children:k.jsxs(sx,{tabIndex:-1,ref:q,"data-status":l,onBlur:pe,onKeyDown:ge,cellId:o,canMoveX:H,title:V.disabled?"This cell is disabled":"disabled-transitively"===l?"This cell has a disabled ancestor":void 0,children:[k.jsxs("div",{className:xe,id:be,children:["above"===z.display.cell_output&&ye,k.jsxs("div",{className:"tray",children:[k.jsx("div",{className:"absolute right-2 -top-4 z-10",children:k.jsx(ew,{edited:h,appClosed:b,status:l,cellConfig:V,needsRun:re,hasOutput:ve,cellActionDropdownRef:Y,cellId:o,name:$,getEditorView:ue,onRun:he})}),k.jsxs("div",{className:"absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",children:[k.jsx(jg,{tooltipContent:S("cell.createAbove"),appClosed:b,onClick:b?void 0:me}),k.jsx("div",{className:"flex-1"}),k.jsx(jg,{tooltipContent:S("cell.createBelow"),appClosed:b,onClick:b?void 0:fe})]}),k.jsx(Yb,{theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,config:V,status:l,serializedEditorState:v,runCell:he,updateCellCode:N,createNewCell:E,deleteCell:j,focusCell:_,moveCell:I,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:O,userConfig:z,editorViewRef:Z,hidden:!we,setTemporarilyVisible:te}),k.jsxs("div",{className:"shoulder-right z-20",children:[k.jsx(Rg,{status:l,staleInputs:g,interrupted:f,editing:le,edited:h,disabled:V.disabled??!1,elapsedTime:u,runStartTimestamp:c,uninstantiated:oe,lastRunStartTimestamp:d}),k.jsx("div",{className:"flex gap-2 items-end",children:k.jsx(ax,{})})]}),k.jsx("div",{className:"shoulder-bottom hover-action",children:w&&we&&k.jsx(Og,{appClosed:b,status:l,onClick:()=>{ae||b||j({cellId:o})}})})]}),"below"===z.display.cell_output&&ye,k.jsx(fl,{consoleOutputs:s,stale:se,cellName:$,onRefactorWithAI:e=>{Q({cellId:o,initialPrompt:e.prompt})},onSubmitDebugger:(e,t)=>{A({cellId:o,response:e,outputIndex:t}),ga({text:e})},cellId:o,debuggerActive:x})]}),B&&k.jsx(Zb,{onClick:()=>L({cellId:o}),count:U,cellId:o})]})})}))),nw=e=>{const t=b(10),{width:n}=e,{banners:o}=ml(),{removeBanner:r}=pl();if(0===o.length)return null;const a="columns"===n&&"sticky left-12 w-full max-w-[80vw]";let i,s,l;if(t[0]!==a?(i=rn("flex flex-col gap-4 mb-5 print:hidden",a),t[0]=a,t[1]=i):i=t[1],t[2]!==r||t[3]!==o){let e;t[5]!==r?(e=e=>k.jsxs(va,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[k.jsxs("div",{className:"flex justify-between",children:[k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[k.jsx(ya,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),k.jsx(C,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(e.id),children:k.jsx(tn,{className:"w-5 h-5"})})]}),k.jsxs("div",{className:"flex justify-between items-end",children:[k.jsx("span",{children:xa({html:e.description})}),"restart"===e.action&&k.jsx(ow,{})]})]},e.id),t[5]=r,t[6]=e):e=t[6],s=o.map(e),t[2]=r,t[3]=o,t[4]=s}else s=t[4];return t[7]!==i||t[8]!==s?(l=k.jsx("div",{className:i,children:s}),t[7]=i,t[8]=s,t[9]=l):l=t[9],l},ow=()=>{const e=b(3),t=qd();let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Oc,{className:"w-3 h-3 mr-2"}),e[0]=n):n=e[0],e[1]!==t?(o=k.jsxs(C,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:t,children:[n,"Restart"]}),e[1]=t,e[2]=o):o=e[2],o};const rw=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,o=e=>{const t=e.match(n);if(!t)return null;const[,o,r,a,i]=t;return{major:Number.parseInt(o,10),minor:Number.parseInt(r,10),patch:Number.parseInt(a,10),preRelease:i||""}};try{const n=o(e),r=o(t);return n&&r?n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:""===n.preRelease&&""!==r.preRelease?1:""!==n.preRelease&&""===r.preRelease?-1:n.preRelease.localeCompare(r.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const aw=()=>{const e=b(64),{packageAlert:t}=gl(),{clearPackageAlert:n}=vl(),[o]=Oe();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const[i,s]=r.useState(a);if(null===t)return null;const l="pixi"!==o.package_management.manager;if(yl(t)){let r,a,c,d,u,h,f,m,p,g;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[k.jsx(Ec,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),e[1]=r):r=e[1],e[2]!==n||e[3]!==t.id?(a=()=>n(t.id),e[2]=n,e[3]=t.id,e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(tn,{className:"w-5 h-5"}),e[5]=c):c=e[5],e[6]!==a?(d=k.jsxs("div",{className:"flex justify-between",children:[r,k.jsx(C,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:a,children:c})]}),e[6]=a,e[7]=d):d=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx("p",{children:"The following packages were not found:"}),e[8]=u):u=e[8],e[9]!==l||e[10]!==i||e[11]!==t.packages){let n;e[13]!==l||e[14]!==i?(n=(e,t)=>k.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[k.jsx(ql,{size:"1rem"}),e,l&&k.jsx(cw,{value:i[e]??"latest",onChange:t=>s((n=>({...n,[e]:t}))),packageName:e})]},t),e[13]=l,e[14]=i,e[15]=n):n=e[15],h=t.packages.map(n),e[9]=l,e[10]=i,e[11]=t.packages,e[12]=h}else h=e[12];return e[16]!==h?(f=k.jsxs("div",{children:[u,k.jsx("ul",{className:"list-disc ml-4 mt-1",children:h})]}),e[16]=h,e[17]=f):f=e[17],e[18]!==t||e[19]!==n||e[20]!==o||e[21]!==i?(m=k.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:t.isolated?k.jsxs(k.Fragment,{children:[k.jsx(sw,{manager:o.package_management.manager,versions:i,clearPackageAlert:()=>n(t.id)}),!D()&&k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"px-2 text-sm",children:"with"})," ",k.jsx(lw,{})]})]}):k.jsxs("p",{children:["If you set up a"," ",k.jsx("a",{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",className:"text-accent-foreground hover:underline",target:"_blank",rel:"noreferrer",children:"virtual environment"}),", marimo can install these packages for you."]})}),e[18]=t,e[19]=n,e[20]=o,e[21]=i,e[22]=m):m=e[22],e[23]!==f||e[24]!==m?(p=k.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[f,m]}),e[23]=f,e[24]=m,e[25]=p):p=e[25],e[26]!==d||e[27]!==p?(g=k.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:k.jsxs(va,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[d,p]})}),e[26]=d,e[27]=p,e[28]=g):g=e[28],g}if(xl(t)){let o;e[29]!==t.packages?(o=function(e){const t=new Set(Object.values(e)),n=t.has("queued")||t.has("installing")?"installing":t.has("failed")?"failed":"installed";if("installing"===n)return{status:"installing",title:"Installing packages",titleIcon:k.jsx(ec,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:k.jsx(Cc,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:k.jsx(Ec,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(t.packages),e[29]=t.packages,e[30]=o):o=e[30];const{status:r,title:a,titleIcon:i,description:s}=o;"installed"===r&&setTimeout((()=>n(t.id)),1e4);const l="failed"===r?"danger":"info";let c,d,u,h,f;e[31]!==i||e[32]!==a?(c=k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i,a]}),e[31]=i,e[32]=a,e[33]=c):c=e[33],e[34]!==n||e[35]!==t.id?(d=()=>n(t.id),e[34]=n,e[35]=t.id,e[36]=d):d=e[36],e[37]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(tn,{className:"w-5 h-5"}),e[37]=u):u=e[37],e[38]!==d?(h=k.jsx(C,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:d,children:u}),e[38]=d,e[39]=h):h=e[39],e[40]!==c||e[41]!==h?(f=k.jsxs("div",{className:"flex justify-between",children:[c,h]}),e[40]=c,e[41]=h,e[42]=f):f=e[42];const m="installed"===r&&"text-accent-foreground";let p,g,v,y,x,b,w;if(e[43]!==m?(p=rn("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",m),e[43]=m,e[44]=p):p=e[44],e[45]!==s?(g=k.jsx("p",{children:s}),e[45]=s,e[46]=g):g=e[46],e[47]!==t.packages||e[48]!==r){let n;e[50]!==r?(n=(e,t)=>{const[n,o]=e;return k.jsxs("li",{className:rn("flex items-center gap-1 font-mono text-sm","installing"===o&&"font-semibold","failed"===o&&"text-destructive","installed"===o&&"text-accent-foreground","installed"===o&&"failed"===r&&"text-muted-foreground"),children:[k.jsx(iw,{status:o}),n]},t)},e[50]=r,e[51]=n):n=e[51],v=Object.entries(t.packages).map(n),e[47]=t.packages,e[48]=r,e[49]=v}else v=e[49];return e[52]!==v?(y=k.jsx("ul",{className:"list-disc ml-4 mt-1",children:v}),e[52]=v,e[53]=y):y=e[53],e[54]!==g||e[55]!==y?(x=k.jsxs("div",{children:[g,y]}),e[54]=g,e[55]=y,e[56]=x):x=e[56],e[57]!==p||e[58]!==x?(b=k.jsx("div",{className:p,children:x}),e[57]=p,e[58]=x,e[59]=b):b=e[59],e[60]!==l||e[61]!==f||e[62]!==b?(w=k.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:k.jsxs(va,{kind:l,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[f,b]})}),e[60]=l,e[61]=f,e[62]=b,e[63]=w):w=e[63],w}return T(t),null};const iw=e=>{const t=b(4),{status:n}=e;switch(n){case"queued":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(ql,{size:"1rem"}),t[0]=e):e=t[0],e}case"installing":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(ec,{size:"1rem"}),t[1]=e):e=t[1],e}case"installed":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(It,{size:"1rem"}),t[2]=e):e=t[2],e}case"failed":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(tn,{size:"1rem"}),t[3]=e):e=t[3],e}default:return T(n),null}},sw=e=>{const t=b(8),{manager:n,versions:o,clearPackageAlert:r}=e;let a,i,s,l;return t[0]!==r||t[1]!==n||t[2]!==o?(a=async()=>{r(),await Aa({manager:n,versions:o}).catch((e=>{J.error(e)}))},t[0]=r,t[1]=n,t[2]=o,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(ec,{className:"w-4 h-4 mr-2"}),s=k.jsx("span",{className:"font-semibold",children:"Install"}),t[4]=i,t[5]=s):(i=t[4],s=t[5]),t[6]!==a?(l=k.jsxs(C,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:a,children:[i,s]}),t[6]=a,t[7]=l):l=t[7],l},lw=()=>{const e=b(16),[t,n]=Oe();let o,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ba(wa),e[0]=o):o=e[0],e[1]!==t?(r={resolver:o,defaultValues:t},e[1]=t,e[2]=r):r=e[2];const a=ka(r);let i;e[3]!==n?(i=async e=>{await Pe({config:e}).then((()=>{n(e)}))},e[3]=n,e[4]=i):i=e[4];const s=i;let l,c,d,u;return e[5]!==a||e[6]!==s?(l=a.handleSubmit(s),e[5]=a,e[6]=s,e[7]=l):l=e[7],e[8]!==a.control?(c=k.jsx("div",{className:"flex flex-col gap-3",children:k.jsx(Sa,{control:a.control,name:"package_management.manager",render:uw})}),e[8]=a.control,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=k.jsx("form",{onChange:l,className:"flex flex-col gap-5",children:c}),e[10]=l,e[11]=c,e[12]=d):d=e[12],e[13]!==a||e[14]!==d?(u=k.jsx(Na,{...a,children:d}),e[13]=a,e[14]=d,e[15]=u):u=e[15],u},cw=e=>{const t=b(21),{value:n,onChange:o,packageName:r}=e;let a,i;t[0]!==r?(a=async()=>{const e=await fetch(`https://pypi.org/pypi/${t=r,t.replaceAll(/\[.*]/g,"").trim()}/json`,{method:"GET",signal:AbortSignal.timeout(5e3)});var t;const n=await e.json();return["latest",...Object.keys(n.releases).sort(rw).slice(0,100)]},i=[r],t[0]=r,t[1]=a,t[2]=i):(a=t[1],i=t[2]);const{data:s,loading:l,error:c}=sn(a,i);let d;t[3]!==s?(d=void 0===s?[]:s,t[3]=s,t[4]=d):d=t[4];const u=d;if(c){let e,r,a;return t[5]!==o?(e=e=>o(e.target.value),t[5]=o,t[6]=e):e=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx("option",{value:"latest",children:"latest"}),t[7]=r):r=t[7],t[8]!==n||t[9]!==e?(a=k.jsx(N,{content:"Failed to fetch package versions",children:k.jsx(ja,{value:n,onChange:e,disabled:!0,className:"inline-flex ml-2",children:r})}),t[8]=n,t[9]=e,t[10]=a):a=t[10],a}let h,f,m;return t[11]!==o?(h=e=>o(e.target.value),t[11]=o,t[12]=h):h=t[12],t[13]!==l||t[14]!==u?(f=l?k.jsx("option",{value:"latest",children:"latest"}):u.map(hw),t[13]=l,t[14]=u,t[15]=f):f=t[15],t[16]!==n||t[17]!==h||t[18]!==l||t[19]!==f?(m=k.jsx(ja,{value:n,onChange:h,disabled:l,className:"inline-flex ml-2",children:f}),t[16]=n,t[17]=h,t[18]=l,t[19]=f,t[20]=m):m=t[20],m};function dw(e){return k.jsx("option",{value:e,children:e},e)}function uw(e){const{field:t}=e;return k.jsxs(Ca,{children:[k.jsx(Ea,{children:k.jsx(ja,{"data-testid":"install-package-manager-select",onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:"inline-flex mr-2",children:_a.map(dw)})}),k.jsx(Ia,{})]})}function hw(e){return k.jsx("option",{value:e,children:e},e)}const fw=e=>{let{transform:t}=e;return{...t,x:0}},mw={threshold:{x:0,y:.1}},pw=u.memo((e=>{const t=b(25),{children:n,multiColumn:o}=e,{cellIds:a}=W(),{dropCellOverCell:i,dropCellOverColumn:s,moveColumn:l,compactColumns:c}=q(),[d,u]=r.useState(null),[h,f]=r.useState(null),[m]=De();let p;e:{if("columns"===m.width){p=Ta.EMPTY;break e}let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[fw],t[0]=e):e=t[0],p=e}const g=p;let v,y;t[1]===Symbol.for("react.memo_cache_sentinel")?(v={activationConstraint:{distance:8}},t[1]=v):v=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:nx},t[2]=y):y=t[2];const x=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(Zg(qv,v),Zg(Vv,y));let w;t[3]!==a?(w=e=>{u(e.active.id),f(a)},t[3]=a,t[4]=w):w=t[4];const S=G(w);let N;t[5]!==h?(N=()=>{u(null),f(null)},t[5]=h,t[6]=N):N=t[6];const C=G(N);let E;t[7]!==d||t[8]!==a?(E=e=>{const t=e.droppableContainers.filter((e=>vw(e.id)));if(d&&vw(d))return iv({...e,droppableContainers:t});const n=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const a of t){const{id:e}=a,t=n.get(e);if(t&&cv(o,t)){const n=ov(t).reduce(((e,t)=>e+ev(o,t)),0),i=Number((n/4).toFixed(4));r.push({id:e,data:{droppableContainer:a,value:i}})}}return r.sort(tv)})({...e,droppableContainers:t}),o=rv(n.length>0?n:lv({...e,droppableContainers:t}),"id");if(!o)return[];$t(vw(o),`Expected column id. Got: ${o}`);const r=a.get(o);if($t(r,`Expected column. Got: ${o}`),r&&0===r.topLevelIds.length)return[{id:o}];const i=new Set(r.topLevelIds),s=iv({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==o&&i.has(e.id)))});if(s.length>0){const e=s[0].id;return $t(gw(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]},t[7]=d,t[8]=a,t[9]=E):E=t[9];const j=E;let _;t[10]!==s||t[11]!==i||t[12]!==l?(_=e=>{const{active:t,over:n}=e,o=null==n?void 0:n.id;if(null!=o&&t.id!==o){if(gw(t.id)){if(vw(o))return void s({cellId:t.id,columnId:o});if(gw(o))return void i({cellId:t.id,overCellId:o})}vw(t.id)&&vw(o)&&l({column:t.id,overColumn:o})}},t[10]=s,t[11]=i,t[12]=l,t[13]=_):_=t[13];const I=G(_);let A;t[14]!==c?(A=e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&c()},t[14]=c,t[15]=A):A=t[15];const T=G(A),M=o?j:iv;let O;return t[16]!==x||t[17]!==M||t[18]!==g||t[19]!==T||t[20]!==S||t[21]!==C||t[22]!==I||t[23]!==n?(O=k.jsx(Ty,{autoScroll:mw,sensors:x,collisionDetection:M,modifiers:g,onDragEnd:T,onDragStart:S,onDragCancel:C,onDragOver:I,children:n}),t[16]=x,t[17]=M,t[18]=g,t[19]=T,t[20]=S,t[21]=C,t[22]=I,t[23]=n,t[24]=O):O=t[24],O}));function gw(e){return"string"==typeof e&&!e.startsWith("tree_")}function vw(e){return"string"==typeof e&&e.startsWith("tree_")}const yw=u.forwardRef((({columnId:e,canDelete:t,canMoveLeft:n,canMoveRight:o,...r},a)=>{const{attributes:i,listeners:s,setNodeRef:l,transform:c,transition:d,isDragging:u,isOver:h}=Qy({id:e}),f={transform:c?pr.Transform.toString({x:c.x,y:0,scaleX:1,scaleY:1}):void 0,transition:d,zIndex:u?2:void 0,position:"relative","--gutter-width":"50px"},m=Ug(a,l),{deleteColumn:p,moveColumn:g,addColumn:v}=q(),y=rn("h-full hover:bg-muted rounded-none"),x=()=>{const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})},b=k.jsxs("div",{className:"h-6 group flex items-center rounded-t-lg border hover:border-border border-[var(--slate-3)] overflow-hidden bg-[var(--slate-1)]",children:[k.jsx(N,{content:"Move column left",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>g({column:e,overColumn:"_left_"}),disabled:!n,children:k.jsx(Ma,{className:"size-4"})})}),k.jsx(N,{content:"Move column right",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>g({column:e,overColumn:"_right_"}),disabled:!o,children:k.jsx(ra,{className:"size-4"})})}),k.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...i,...s,"data-testid":"column-drag-button"}),t&&k.jsx(N,{content:"Delete column",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:"opacity-0 group-hover:opacity-70 group-hover:hover:opacity-100 text-destructive h-full hover:bg-destructive/20 rounded-none",onClick:()=>p({columnId:e}),children:k.jsx(tn,{className:"size-4"})})}),k.jsx(N,{content:"Add column",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>{v({columnId:e}),requestAnimationFrame(x)},children:k.jsx(Bo,{className:"size-4"})})})]});return k.jsxs("div",{tabIndex:-1,ref:m,...r,style:f,"data-is-dragging":u,className:rn(u?"":r.className,u?"z-20":"z-1 hover:z-10 focus-within:z-10",h&&"bg-accent/20"),children:[b,r.children]})}));yw.displayName="SortableColumn";const xw=r.memo(yw),bw=r.memo((e=>{const t=b(15),n=r.useRef(null),o="columns"===e.width&&"w-contentWidth box-content\t min-h-[100px] border border-t-0 border-[var(--slate-3)] rounded-b-lg px-11 py-6 bg-[var(--slate-2)]";let a,i;t[0]!==o?(a=rn("flex flex-col gap-5",o),t[0]=o,t[1]=a):a=t[1],t[2]!==a||t[3]!==e.children?(i=k.jsx("div",{className:a,children:e.children}),t[2]=a,t[3]=e.children,t[4]=i):i=t[4];const s=i;if("columns"===e.width){let o;return t[5]!==e.canDelete||t[6]!==e.columnId||t[7]!==e.canMoveLeft||t[8]!==e.canMoveRight||t[9]!==e.footer||t[10]!==s?(o=k.jsxs(xw,{tabIndex:-1,ref:n,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[s,e.footer]}),t[5]=e.canDelete,t[6]=e.columnId,t[7]=e.canMoveLeft,t[8]=e.canMoveRight,t[9]=e.footer,t[10]=s,t[11]=o):o=t[11],o}let l;return t[12]!==s||t[13]!==e.footer?(l=k.jsxs(k.Fragment,{children:[s,e.footer]}),t[12]=s,t[13]=e.footer,t[14]=l):l=t[14],l}));bw.displayName="Column";const ww=e=>{const t=b(67),{notebook:n,mode:o,userConfig:a,appConfig:i,connStatus:s}=e,l=q(),{theme:c}=Me(),{toggleSidebarPanel:d}=eu(),{invisible:u}=bl(n.cellIds.idLength,o);let h;Cs("global.focusTop",l.focusTopCell),Cs("global.focusBottom",l.focusBottomCell),Cs("global.toggleSidebar",d),Cs("global.foldCode",l.foldAll),Cs("global.unfoldCode",l.unfoldAll),t[0]!==l.updateCellCode?(h=()=>{Pa(l.updateCellCode)},t[0]=l.updateCellCode,t[1]=h):h=t[1],Cs("global.formatAll",h),Cs("cell.hideCode",an.NOOP),Cs("cell.format",an.NOOP);const f=jd(),m=l.scrollToTarget;let p,g,v,y,x,w,S,N,C,E,j,_,I,A,T,M,O,D,P,R,L,z;if(t[2]!==n.scrollKey||t[3]!==m?(p=()=>{null!==n.scrollKey&&m()},t[2]=n.scrollKey,t[3]=m,t[4]=p):p=t[4],t[5]!==n.cellIds||t[6]!==n.scrollKey||t[7]!==m?(g=[n.cellIds,n.scrollKey,m],t[5]=n.cellIds,t[6]=n.scrollKey,t[7]=m,t[8]=g):g=t[8],r.useEffect(p,g),t[9]!==n.cellIds||t[10]!==n.cellData||t[11]!==n.cellRuntime||t[12]!==n.scrollKey||t[13]!==n.cellHandles||t[14]!==u||t[15]!==i||t[16]!==c||t[17]!==o||t[18]!==s.state||t[19]!==a||t[20]!==l||t[21]!==f){const e=n.cellIds.getColumns();let r;t[37]!==n.cellIds?(r=n.cellIds.hasOnlyOneId(),t[37]=n.cellIds,t[38]=r):r=t[38];const d=r;j=wl,_="pb-[40vh]",I=u,A=i,T="pr-4",t[39]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx(aw,{}),t[39]=M):M=t[39],t[40]!==i.width?(O=k.jsx(nw,{width:i.width}),t[40]=i.width,t[41]=O):O=t[41],C=pw,E="columns"===i.width,x=Gy,w="column-container",S=e.map(Sw),N=By;const h="columns"===i.width&&"grid grid-flow-col auto-cols-min gap-6";t[42]!==h?(v=rn(h),t[42]=h,t[43]=v):v=t[43],y=e.map(((t,r)=>k.jsx(bw,{columnId:t.id,canMoveLeft:r>0,canMoveRight:r<e.length-1,width:i.width,canDelete:e.length>1,footer:k.jsx(kw,{columnId:t.id,className:rn("columns"===i.width&&"opacity-0 group-hover/column:opacity-100")}),children:k.jsx(Gy,{id:`column-${r+1}`,items:t.topLevelIds,strategy:Hy,children:t.topLevelIds.map((e=>{const r=n.cellData[e],h=n.cellRuntime[e];return k.jsx(tw,{theme:c,showPlaceholder:d,allowFocus:!u&&!n.scrollKey,id:r.id,code:r.code,outline:h.outline,output:h.output,consoleOutputs:h.consoleOutputs,status:h.status,edited:r.edited,interrupted:h.interrupted,errored:h.errored,stopped:h.stopped,staleInputs:h.staleInputs,runStartTimestamp:h.runStartTimestamp,lastRunStartTimestamp:h.lastRunStartTimestamp,runElapsedTimeMs:h.runElapsedTimeMs??r.lastExecutionTime,serializedEditorState:r.serializedEditorState,canDelete:!d,mode:o,appClosed:s.state!==ll.OPEN,ref:n.cellHandles[e],userConfig:a,debuggerActive:h.debuggerActive,config:r.config,name:r.name,isCollapsed:t.isCollapsed(e),collapseCount:t.getCount(e),canMoveX:"columns"===i.width,...l,deleteCell:f},r.id.toString())}))})},t.id))),t[9]=n.cellIds,t[10]=n.cellData,t[11]=n.cellRuntime,t[12]=n.scrollKey,t[13]=n.cellHandles,t[14]=u,t[15]=i,t[16]=c,t[17]=o,t[18]=s.state,t[19]=a,t[20]=l,t[21]=f,t[22]=v,t[23]=y,t[24]=x,t[25]=w,t[26]=S,t[27]=N,t[28]=C,t[29]=E,t[30]=j,t[31]=_,t[32]=I,t[33]=A,t[34]=T,t[35]=M,t[36]=O}else v=t[22],y=t[23],x=t[24],w=t[25],S=t[26],N=t[27],C=t[28],E=t[29],j=t[30],_=t[31],I=t[32],A=t[33],T=t[34],M=t[35],O=t[36];return t[44]!==v||t[45]!==y?(D=k.jsx("div",{className:v,children:y}),t[44]=v,t[45]=y,t[46]=D):D=t[46],t[47]!==x||t[48]!==w||t[49]!==S||t[50]!==N||t[51]!==D?(P=k.jsx(x,{id:w,items:S,strategy:N,children:D}),t[47]=x,t[48]=w,t[49]=S,t[50]=N,t[51]=D,t[52]=P):P=t[52],t[53]!==C||t[54]!==E||t[55]!==P?(R=k.jsx(C,{multiColumn:E,children:P}),t[53]=C,t[54]=E,t[55]=P,t[56]=R):R=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(L=k.jsx(kl,{}),t[57]=L):L=t[57],t[58]!==j||t[59]!==_||t[60]!==I||t[61]!==A||t[62]!==T||t[63]!==M||t[64]!==O||t[65]!==R?(z=k.jsxs(j,{className:_,invisible:I,appConfig:A,innerClassName:T,children:[M,O,R,L]}),t[58]=j,t[59]=_,t[60]=I,t[61]=A,t[62]=T,t[63]=M,t[64]=O,t[65]=R,t[66]=z):z=t[66],z},kw=e=>{const t=b(18),{columnId:n,className:o}=e,{createNewCell:r}=q(),a=le(ue),[i,s]=Oa(!1),l=le(de),c=le(Da).sql;let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=rn("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs"),t[0]=d):d=t[0];const u=d;let h;t[1]!==i||t[2]!==s.toggle||t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c||t[7]!==l?(h=()=>i?k.jsx(Fb,{onClose:s.toggle}):k.jsxs(k.Fragment,{children:[k.jsxs(C,{className:u,variant:"text",size:"sm",onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[k.jsx(Bc,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),k.jsxs(C,{className:u,variant:"text",size:"sm",onClick:()=>{Id(a,r),r({cellId:{type:"__end__",columnId:n},before:!1,code:(new Uo).defaultCode})},children:[k.jsx(Hc,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),k.jsx(N,{content:c?null:k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("span",{children:["Additional dependencies required:",k.jsx(Ra,{className:"inline",children:"pip install 'marimo[sql]'"}),"."]}),k.jsx("span",{children:"You will need to restart the notebook after installing."})]}),delayDuration:100,asChild:!1,children:k.jsxs(C,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{Id(a,r),r({cellId:{type:"__end__",columnId:n},before:!1,code:(new Vo).defaultCode})},children:[k.jsx(ke,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]})}),k.jsx(N,{content:l?null:k.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:k.jsxs(C,{className:u,variant:"text",size:"sm",disabled:!l,onClick:s.toggle,children:[k.jsx(Fc,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]}),t[1]=i,t[2]=s.toggle,t[3]=r,t[4]=n,t[5]=a,t[6]=c,t[7]=l,t[8]=h):h=t[8];const f=h,m=!i&&"w-fit",p=i&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]";let g,v,y;return t[9]!==m||t[10]!==p||t[11]!==o?(g=rn("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",m,p,o),t[9]=m,t[10]=p,t[11]=o,t[12]=g):g=t[12],t[13]!==f?(v=f(),t[13]=f,t[14]=v):v=t[14],t[15]!==g||t[16]!==v?(y=k.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:k.jsx("div",{className:g,children:v})}),t[15]=g,t[16]=v,t[17]=y):y=t[17],y};function Sw(e){return e.id}async function Nw(){await za({download:!1,includeCode:!0,files:il.INSTANCE.filenames()})}async function Cw(){await Fa({download:!1})}const Ew=e=>{const t=b(117),{userConfig:n,appConfig:o}=e,a=W();Ba(Ya,qa.onCellIdsChange);const{setCells:i,updateCellCode:s,mergeAllColumns:l}=q(),c=le(ht),[d,u]=yt(),[h,f]=r.useState(),m=tl(),{openModal:p,closeModal:g,openAlert:v}=w(),y="edit"===c.mode,x="present"===c.mode,S=le(Ua),N=le(fe);let C;t[0]!==v?(C=function(){v("Failed to save notebook: not connected to a kernel.")},t[0]=v,t[1]=C):C=t[1];const E=C;let j;t[2]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[2]=j):j=t[2],r.useEffect(Iw,j);const _=n.runtime.auto_instantiate;let I,A,T;t[3]!==i?(I=(e,t)=>{i(e);const n=e.map((e=>e.name)),o=e.map((e=>e.code)),r=e.map((e=>e.config));f({names:n,codes:o,configs:r,layout:t})},t[3]=i,t[4]=I):I=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(A=Xa(),t[5]=A):A=t[5],t[6]!==n.runtime.auto_instantiate||t[7]!==I?(T={autoInstantiate:_,setCells:I,sessionId:A},t[6]=n.runtime.auto_instantiate,t[7]=I,t[8]=T):T=t[8];const{connection:M}=Sl(T);let O;t[9]!==M.state||t[10]!==E||t[11]!==u||t[12]!==o.app_title||t[13]!==v?(O=async e=>M.state!==ll.OPEN?(E(),null):(Ka((t=>{null===e?t.delete(Ja.filePath):t.set(Ja.filePath,e)})),Za({filename:e}).then((()=>(u(e),document.title=o.app_title||gt.basename(e)||"Untitled Notebook",e))).catch((e=>(v(e.message),null)))),t[9]=M.state,t[10]=E,t[11]=u,t[12]=o.app_title,t[13]=v,t[14]=O):O=t[14];const D=G(O);let P,R;t[15]!==o.app_title||t[16]!==d?(P=()=>{document.title=o.app_title||gt.basename(d??"")||"Untitled Notebook"},R=[o.app_title,d],t[15]=o.app_title,t[16]=d,t[17]=P,t[18]=R):(P=t[17],R=t[18]),r.useEffect(P,R);const L=a.cellIds.colLength,z=or(o.width);let F,B,U,V,H,$;t[19]!==z||t[20]!==o.width||t[21]!==l?(F=()=>{"columns"===z&&"columns"!==o.width&&l()},t[19]=z,t[20]=o.width,t[21]=l,t[22]=F):F=t[22],t[23]!==o.width||t[24]!==z||t[25]!==l||t[26]!==L?(B=[o.width,z,l,L],t[23]=o.width,t[24]=z,t[25]=l,t[26]=L,t[27]=B):B=t[27],r.useEffect(F,B),t[28]!==a?($=Va(a),H=$.map(Aw),V=$.map(Tw),U=$.map(Mw),t[28]=a,t[29]=U,t[30]=V,t[31]=H,t[32]=$):(U=t[29],V=t[30],H=t[31],$=t[32]);const X=U;let K;t[33]!==a?(K=Ha(a),t[33]=a,t[34]=K):K=t[34];const Z=K;let ee;t[35]!==a||t[36]!==m||t[37]!==h?(ee=$a(a,m,h),t[35]=a,t[36]=m,t[37]=h,t[38]=ee):ee=t[38];const te=ee;let ne;t[39]!==N||t[40]!==V||t[41]!==M.state||t[42]!==E||t[43]!==H||t[44]!==X||t[45]!==Z||t[46]!==n.save.format_on_save||t[47]!==s||t[48]!==m?(ne=(e,t)=>{N||0!==V.length&&(M.state===ll.OPEN?(J.log("saving to ",e),Qa({cellIds:H,codes:V,names:X,filename:e,configs:Z,layout:El(),persist:!0}).then((()=>{t&&(re({title:"Notebook saved"}),n.save.format_on_save&&Pa(s)),f({names:X,codes:V,configs:Z,layout:m})}))):E())},t[39]=N,t[40]=V,t[41]=M.state,t[42]=E,t[43]=H,t[44]=X,t[45]=Z,t[46]=n.save.format_on_save,t[47]=s,t[48]=m,t[49]=ne):ne=t[49];const oe=G(ne);let ae;t[50]!==d||t[51]!==M.state||t[52]!==oe?(ae=e=>{const t=void 0!==e&&e;null!==d&&M.state===ll.OPEN&&oe(d,t)},t[50]=d,t[51]=M.state,t[52]=oe,t[53]=ae):ae=t[53];const ie=G(ae),se=G((()=>{ie(!0),null===d&&M.state!==ll.CLOSED&&p(k.jsx(jw,{onClose:g,onSave:ue}))}));let ce,de;t[54]!==ie||t[55]!==te||t[56]!==V||t[57]!==Z||t[58]!==X||t[59]!==M||t[60]!==n||t[61]!==N?(ce={onSave:ie,needsSave:te,codes:V,cellConfigs:Z,cellNames:X,connStatus:M,config:n,kioskMode:N},t[54]=ie,t[55]=te,t[56]=V,t[57]=Z,t[58]=X,t[59]=M,t[60]=n,t[61]=N,t[62]=ce):ce=t[62],function(e){const t=b(16),{codes:n,cellConfigs:o,config:a,connStatus:i,cellNames:s,needsSave:l,kioskMode:c,onSave:d}=e,u=r.useRef(null);let h,f;t[0]!==c||t[1]!==a.save.autosave||t[2]!==a.save.autosave_delay||t[3]!==l||t[4]!==i.state||t[5]!==d?(h=()=>{if(!c)return"after_delay"===a.save.autosave&&(null!==u.current&&clearTimeout(u.current),l&&i.state===ll.OPEN&&(u.current=setTimeout(d,a.save.autosave_delay))),()=>{null!==u.current&&clearTimeout(u.current)}},t[0]=c,t[1]=a.save.autosave,t[2]=a.save.autosave_delay,t[3]=l,t[4]=i.state,t[5]=d,t[6]=h):h=t[6],t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a.save||t[11]!==i.state||t[12]!==d||t[13]!==c||t[14]!==l?(f=[n,o,s,a.save,i.state,d,c,l],t[7]=n,t[8]=o,t[9]=s,t[10]=a.save,t[11]=i.state,t[12]=d,t[13]=c,t[14]=l,t[15]=f):f=t[15],r.useEffect(h,f)}(ce),function(){const e=b(4),t=le(La),{state:n}=le(sl),o=t.auto_download.includes("markdown"),r=t.auto_download.includes("html"),a=!o||n!==ll.OPEN,i=!r||n!==ll.OPEN;let s,l;e[0]!==a?(s={delayMs:5e3,whenVisible:!0,disabled:a},e[0]=a,e[1]=s):s=e[1],qs(Cw,s),e[2]!==i?(l={delayMs:5e3,whenVisible:!0,disabled:i},e[2]=i,e[3]=l):l=e[3],qs(Nw,l)}(),t[63]!==te?(de=e=>{if(!ei())return te?(e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to quit?"):void 0},t[63]=te,t[64]=de):de=t[64],Q(window,"beforeunload",de);const ue=e=>{D(e).then((e=>{null!==e&&oe(e,!0)}))},he=function(){const e=b(3),t=W(),n=wd();let o;return e[0]!==n||e[1]!==t?(o=()=>n(Y(t)),e[0]=n,e[1]=t,e[2]=o):o=e[2],G(o)}(),me=nu();let pe,ge,ve;t[65]!==he?(pe=()=>{he()},t[65]=he,t[66]=pe):pe=t[66],Cs("global.runStale",pe),Cs("global.save",se),Cs("global.interrupt",Ow),t[67]!==me?(ge=()=>{me()},t[67]=me,t[68]=ge):ge=t[68],Cs("global.hideCode",ge),t[69]!==d||t[70]!==$?(ve=()=>JSON.stringify({filename:d,cells:$.map((e=>({name:e.name,code:e.code})))},null,2),t[69]=d,t[70]=$,t[71]=ve):ve=t[71];const ye=G(ve);let xe;t[72]!==a||t[73]!==M||t[74]!==c.mode||t[75]!==n||t[76]!==o?(xe=k.jsx(ww,{notebook:a,connStatus:M,mode:c.mode,userConfig:n,appConfig:o}),t[72]=a,t[73]=M,t[74]=c.mode,t[75]=n,t[76]=o,t[77]=xe):xe=t[77];const be=xe,we=o.width;let ke,Se,Ne,Ce,Ee;t[78]===Symbol.for("react.memo_cache_sentinel")?(ke=rn("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),t[78]=ke):ke=t[78],t[79]!==y||t[80]!==d||t[81]!==D?(Se=y&&k.jsx("div",{className:"flex items-center justify-center container",children:k.jsx(Hu,{filename:d,setFilename:D})}),t[79]=y,t[80]=d,t[81]=D,t[82]=Se):Se=t[82],t[83]!==M||t[84]!==Se?(Ne=k.jsx(jl,{connection:M,className:ke,children:Se}),t[83]=M,t[84]=Se,t[85]=Ne):Ne=t[85],t[86]!==$.length||t[87]!==o||t[88]!==c||t[89]!==be?(Ce=$.length>0&&k.jsx(Nl,{appConfig:o,mode:c.mode,children:be}),t[86]=$.length,t[87]=o,t[88]=c,t[89]=be,t[90]=Ce):Ce=t[90],t[91]!==M||t[92]!==S||t[93]!==o.width||t[94]!==Ne||t[95]!==Ce?(Ee=k.jsxs(_l,{connection:M,isRunning:S,width:we,children:[Ne,Ce]}),t[91]=M,t[92]=S,t[93]=o.width,t[94]=Ne,t[95]=Ce,t[96]=Ee):Ee=t[96];const je=M.state===ll.CLOSED;let _e,Ie,Ae,Te;return t[97]!==a?(_e=Wa(a),t[97]=a,t[98]=_e):_e=t[98],t[99]!==a?(Ie=At(a),t[99]=a,t[100]=Ie):Ie=t[100],t[101]!==d||t[102]!==te||t[103]!==se||t[104]!==ye||t[105]!==x||t[106]!==me||t[107]!==he||t[108]!==je||t[109]!==S||t[110]!==_e||t[111]!==Ie||t[112]!==o.width?(Ae=k.jsx(Ru,{filename:d,needsSave:te,onSaveNotebook:se,getCellsAsJSON:ye,presenting:x,onTogglePresenting:me,onInterrupt:aa,onRun:he,closed:je,running:S,needsRun:_e,undoAvailable:Ie,appWidth:o.width}),t[101]=d,t[102]=te,t[103]=se,t[104]=ye,t[105]=x,t[106]=me,t[107]=he,t[108]=je,t[109]=S,t[110]=_e,t[111]=Ie,t[112]=o.width,t[113]=Ae):Ae=t[113],t[114]!==Ee||t[115]!==Ae?(Te=k.jsxs(k.Fragment,{children:[Ee,Ae]}),t[114]=Ee,t[115]=Ae,t[116]=Te):Te=t[116],Te},jw=e=>{const t=b(17),{onClose:n,onSave:o}=e,[a,i]=r.useState();let s;t[0]!==o||t[1]!==n?(s=e=>{i(e),e.trim()&&(o(e),n())},t[0]=o,t[1]=n,t[2]=s):s=t[2];const l=s;let c,d,u,h;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(j,{children:"Save notebook"}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Ae,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=d):d=t[4],t[5]!==l?(u=k.jsxs("div",{className:"flex flex-col",children:[d,k.jsx(Uu,{onNameChange:l,placeholderText:"filename",className:"missing-filename"})]}),t[5]=l,t[6]=u):u=t[6],t[7]!==n?(h=k.jsx(C,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),t[7]=n,t[8]=h):h=t[8];const f=!a;let m,p,g;return t[9]!==f?(m=k.jsx(C,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:f,type:"submit",children:"Save"}),t[9]=f,t[10]=m):m=t[10],t[11]!==h||t[12]!==m?(p=k.jsxs(I,{children:[h,m]}),t[11]=h,t[12]=m,t[13]=p):p=t[13],t[14]!==u||t[15]!==p?(g=k.jsxs(A,{children:[c,u,p]}),t[14]=u,t[15]=p,t[16]=g):g=t[16],g};function _w(){Cl.INSTANCE.stop()}function Iw(){return Cl.INSTANCE.start(Ga),_w}function Aw(e){return e.id}function Tw(e){return e.code}function Mw(e){return e.name}function Ow(){aa()}const{createElement:Dw,createContext:Pw,createRef:Rw,forwardRef:Lw,useCallback:zw,useContext:Fw,useEffect:Bw,useImperativeHandle:Uw,useLayoutEffect:Vw,useMemo:Hw,useRef:$w,useState:Ww}=ti,Gw=ti["useId".toString()],qw=Vw,Yw=Pw(null);Yw.displayName="PanelGroupContext";const Xw=qw,Kw="function"==typeof Gw?Gw:()=>null;let Jw=0;function Zw(e=null){const t=Kw(),n=$w(e||t||null);return null===n.current&&(n.current=""+Jw++),null!=e?e:n.current}function Qw({children:e,className:t="",collapsedSize:n,collapsible:o,defaultSize:r,forwardedRef:a,id:i,maxSize:s,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:f,tagName:m="div",...p}){const g=Fw(Yw);if(null===g)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:y,getPanelSize:x,getPanelStyle:b,groupId:w,isPanelCollapsed:k,reevaluatePanelConstraints:S,registerPanel:N,resizePanel:C,unregisterPanel:E}=g,j=Zw(i),_=$w({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:n,collapsible:o,defaultSize:r,maxSize:s,minSize:l},id:j,idIsFromProps:void 0!==i,order:h});$w({didLogMissingDefaultSizeWarning:!1}),Xw((()=>{const{callbacks:e,constraints:t}=_.current,a={...t};_.current.id=j,_.current.idIsFromProps=void 0!==i,_.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=u,t.collapsedSize=n,t.collapsible=o,t.defaultSize=r,t.maxSize=s,t.minSize=l,a.collapsedSize===t.collapsedSize&&a.collapsible===t.collapsible&&a.maxSize===t.maxSize&&a.minSize===t.minSize||S(_.current,a)})),Xw((()=>{const e=_.current;return N(e),()=>{E(e)}}),[h,j,N,E]),Uw(a,(()=>({collapse:()=>{v(_.current)},expand:e=>{y(_.current,e)},getId:()=>j,getSize:()=>x(_.current),isCollapsed:()=>k(_.current),isExpanded:()=>!k(_.current),resize:e=>{C(_.current,e)}})),[v,y,x,k,j,C]);const I=b(_.current,r);return Dw(m,{...p,children:e,className:t,id:i,style:{...I,...f},"data-panel":"","data-panel-collapsible":o||void 0,"data-panel-group-id":w,"data-panel-id":j,"data-panel-size":parseFloat(""+I.flexGrow).toFixed(1)})}const ek=Lw(((e,t)=>Dw(Qw,{...e,forwardedRef:t})));Qw.displayName="Panel",ek.displayName="forwardRef(Panel)";let tk=null,nk=null;function ok(e,t){const n=function(e,t){if(t){const e=!!(t&gk),n=!!(t&vk);if(t&mk)return e?"se-resize":n?"ne-resize":"e-resize";if(t&pk)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,t);tk!==n&&(tk=n,null===nk&&(nk=document.createElement("style"),document.head.appendChild(nk)),nk.innerHTML=`*{cursor: ${n}!important;}`)}function rk(e){return"keydown"===e.type}function ak(e){return e.type.startsWith("pointer")}function ik(e){return e.type.startsWith("mouse")}function sk(e){if(ak(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ik(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const lk=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ck(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=fk(e))&&void 0!==t?t:e).display;return"flex"===n||"inline-flex"===n}(e))||(+t.opacity<1||("transform"in t&&"none"!==t.transform||("webkitTransform"in t&&"none"!==t.webkitTransform||("mixBlendMode"in t&&"normal"!==t.mixBlendMode||("filter"in t&&"none"!==t.filter||("webkitFilter"in t&&"none"!==t.webkitFilter||("isolation"in t&&"isolate"===t.isolation||(!!lk.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function dk(e){let t=e.length;for(;t--;){const n=e[t];if(Mk(n,"Missing node"),ck(n))return n}return null}function uk(e){return e&&Number(getComputedStyle(e).zIndex)||0}function hk(e){const t=[];for(;e;)t.push(e),e=fk(e);return t}function fk(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const mk=1,pk=2,gk=4,vk=8,yk="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let xk=[],bk=!1,wk=new Map,kk=new Map;const Sk=new Set;function Nk(e){const{target:t}=e,{x:n,y:o}=sk(e);bk=!0,jk({target:t,x:n,y:o}),Ak(),xk.length>0&&(Tk("down",e),e.preventDefault(),e.stopPropagation())}function Ck(e){const{x:t,y:n}=sk(e);if(!bk){const{target:o}=e;jk({target:o,x:t,y:n})}Tk("move",e),Ik(),xk.length>0&&e.preventDefault()}function Ek(e){const{target:t}=e,{x:n,y:o}=sk(e);kk.clear(),bk=!1,xk.length>0&&e.preventDefault(),Tk("up",e),jk({target:t,x:n,y:o}),Ik(),Ak()}function jk({target:e,x:t,y:n}){xk.splice(0);let o=null;e instanceof HTMLElement&&(o=e),Sk.forEach((e=>{const{element:r,hitAreaMargins:a}=e,i=r.getBoundingClientRect(),{bottom:s,left:l,right:c,top:d}=i,u=yk?a.coarse:a.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=s+u){if(null!==o&&r!==o&&!r.contains(o)&&!o.contains(r)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:hk(e),b:hk(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),o=e;Mk(o,"Stacking order can only be calculated for elements with a common ancestor");const r=uk(dk(n.a)),a=uk(dk(n.b));if(r===a){const e=o.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let r=e.length;for(;r--;){const n=e[r];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(r-a)}(o,r)>0){let e=o,t=!1;for(;e&&!e.contains(r);){if(h=e.getBoundingClientRect(),f=i,h.x<f.x+f.width&&h.x+h.width>f.x&&h.y<f.y+f.height&&h.y+h.height>f.y){t=!0;break}e=e.parentElement}if(t)return}xk.push(e)}var h,f}))}function _k(e,t){kk.set(e,t)}function Ik(){let e=!1,t=!1;xk.forEach((n=>{const{direction:o}=n;"horizontal"===o?e=!0:t=!0}));let n=0;kk.forEach((e=>{n|=e})),e&&t?ok("intersection",n):e?ok("horizontal",n):t?ok("vertical",n):null!==nk&&(document.head.removeChild(nk),tk=null,nk=null)}function Ak(){wk.forEach(((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Ek),n.removeEventListener("pointerdown",Nk),n.removeEventListener("pointerleave",Ck),n.removeEventListener("pointermove",Ck)})),window.removeEventListener("pointerup",Ek),window.removeEventListener("pointercancel",Ek),Sk.size>0&&(bk?(xk.length>0&&wk.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Ek),n.addEventListener("pointerleave",Ck),n.addEventListener("pointermove",Ck))})),window.addEventListener("pointerup",Ek),window.addEventListener("pointercancel",Ek)):wk.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Nk,{capture:!0}),n.addEventListener("pointermove",Ck))})))}function Tk(e,t){Sk.forEach((n=>{const{setResizeHandlerState:o}=n,r=xk.includes(n);o(e,r,t)}))}function Mk(e,t){if(!e)throw console.error(t),Error(t)}function Ok(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Dk(e,t,n=10){return 0===Ok(e,t,n)}function Pk(e,t,n){return 0===Ok(e,t,n)}function Rk({panelConstraints:e,panelIndex:t,size:n}){const o=e[t];Mk(null!=o,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:i=100,minSize:s=0}=o;if(Ok(n,s)<0)if(a){n=Ok(n,(r+s)/2)<0?r:s}else n=s;return n=Math.min(i,n),n=parseFloat(n.toFixed(10))}function Lk({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:a}){if(Pk(e,0))return t;const i=[...t],[s,l]=o;Mk(null!=s,"Invalid first pivot index"),Mk(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===a){{const o=e<0?l:s,r=n[o];Mk(r,`Panel constraints not found for index ${o}`);const{collapsedSize:a=0,collapsible:i,minSize:c=0}=r;if(i){const n=t[o];if(Mk(null!=n,`Previous layout not found for panel index ${o}`),Pk(n,a)){const t=c-n;Ok(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const o=e<0?s:l,r=n[o];Mk(r,`No panel constraints found for index ${o}`);const{collapsedSize:a=0,collapsible:i,minSize:c=0}=r;if(i){const n=t[o];if(Mk(null!=n,`Previous layout not found for panel index ${o}`),Pk(n,c)){const t=n-a;Ok(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const o=e<0?1:-1;let r=e<0?l:s,a=0;for(;;){const e=t[r];Mk(null!=e,`Previous layout not found for panel index ${r}`);if(a+=Rk({panelConstraints:n,panelIndex:r,size:100})-e,r+=o,r<0||r>=n.length)break}const i=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-i:i}{let o=e<0?s:l;for(;o>=0&&o<n.length;){const r=Math.abs(e)-Math.abs(c),a=t[o];Mk(null!=a,`Previous layout not found for panel index ${o}`);const s=Rk({panelConstraints:n,panelIndex:o,size:a-r});if(!Pk(a,s)&&(c+=a-s,i[o]=s,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?o--:o++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Pk(e[o],t[o],n))return!1;return!0}(r,i))return r;{const o=e<0?l:s,r=t[o];Mk(null!=r,`Previous layout not found for panel index ${o}`);const a=r+c,d=Rk({panelConstraints:n,panelIndex:o,size:a});if(i[o]=d,!Pk(d,a)){let t=a-d;let o=e<0?l:s;for(;o>=0&&o<n.length;){const r=i[o];Mk(null!=r,`Previous layout not found for panel index ${o}`);const a=Rk({panelConstraints:n,panelIndex:o,size:r+t});if(Pk(r,a)||(t-=a-r,i[o]=a),Pk(t,0))break;e>0?o--:o++}}}return Pk(i.reduce(((e,t)=>t+e),0),100)?i:r}function zk({layout:e,panelsArray:t,pivotIndices:n}){let o=0,r=100,a=0,i=0;const s=n[0];Mk(null!=s,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===s?(o=c,r=l):(a+=c,i+=l)}));return{valueMax:Math.min(r,100-a),valueMin:Math.max(o,100-i),valueNow:e[s]}}function Fk(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Bk(e,t,n=document){const o=Fk(e,n).findIndex((e=>e.getAttribute("data-panel-resize-handle-id")===t));return null!=o?o:null}function Uk(e,t,n){const o=Bk(e,t,n);return null!=o?[o,o+1]:[-1,-1]}function Vk(e,t=document){var n;if(t instanceof HTMLElement&&(null==t||null===(n=t.dataset)||void 0===n?void 0:n.panelGroupId)==e)return t;const o=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return o||null}function Hk(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function $k({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:o,panelDataArray:r,panelGroupElement:a,setLayout:i}){$w({didWarnAboutMissingResizeHandle:!1}),Xw((()=>{if(!a)return;const e=Fk(n,a);for(let t=0;t<r.length-1;t++){const{valueMax:n,valueMin:a,valueNow:i}=zk({layout:o,panelsArray:r,pivotIndices:[t,t+1]}),s=e[t];if(null==s);else{const e=r[t];Mk(e,`No panel data found for index "${t}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(a)),s.setAttribute("aria-valuenow",null!=i?""+Math.round(i):"")}}return()=>{e.forEach(((e,t)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,o,r,a]),Bw((()=>{if(!a)return;const e=t.current;Mk(e,"Eager values not found");const{panelDataArray:r}=e;Mk(null!=Vk(n,a),`No group found for id "${n}"`);const s=Fk(n,a);Mk(s,`No resize handles found for group id "${n}"`);const l=s.map((e=>{const t=e.getAttribute("data-panel-resize-handle-id");Mk(t,"Resize handle element has no handle id attribute");const[s,l]=function(e,t,n,o=document){var r,a,i,s;const l=Hk(t,o),c=Fk(e,o),d=l?c.indexOf(l):-1;return[null!==(r=null===(a=n[d])||void 0===a?void 0:a.id)&&void 0!==r?r:null,null!==(i=null===(s=n[d+1])||void 0===s?void 0:s.id)&&void 0!==i?i:null]}(n,t,r,a);if(null==s||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=r.findIndex((e=>e.id===s));if(l>=0){const e=r[l];Mk(e,`No panel data found for index ${l}`);const s=o[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=s&&d){const e=Lk({delta:Pk(s,c)?u-c:c-s,initialLayout:o,panelConstraints:r.map((e=>e.constraints)),pivotIndices:Uk(n,t,a),prevLayout:o,trigger:"keyboard"});o!==e&&i(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[a,e,t,n,o,r,i])}function Wk(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Gk(e,t){const n="horizontal"===e,{x:o,y:r}=sk(t);return n?o:r}function qk(e,t,n,o,r,a){if(rk(e)){const t="horizontal"===n;let o=0;o=e.shiftKey?100:null!=r?r:10;let a=0;switch(e.key){case"ArrowDown":a=t?0:o;break;case"ArrowLeft":a=t?-o:0;break;case"ArrowRight":a=t?o:0;break;case"ArrowUp":a=t?0:-o;break;case"End":a=100;break;case"Home":a=-100}return a}return null==o?0:function(e,t,n,o,r){const a="horizontal"===n,i=Hk(t,r);Mk(i,`No resize handle element found for id "${t}"`);const s=i.getAttribute("data-panel-group-id");Mk(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=o;const c=Gk(n,e),d=Vk(s,r);Mk(d,`No group element found for id "${s}"`);const u=d.getBoundingClientRect();return(c-l)/(a?u.width:u.height)*100}(e,t,n,o,a)}function Yk(e,t,n){t.forEach(((t,o)=>{const r=e[o];Mk(r,`Panel data not found for index ${o}`);const{callbacks:a,constraints:i,id:s}=r,{collapsedSize:l=0,collapsible:c}=i,d=n[s];if(null==d||t!==d){n[s]=t;const{onCollapse:e,onExpand:o,onResize:r}=a;r&&r(t,d),c&&(e||o)&&(!o||null!=d&&!Dk(d,l)||Dk(t,l)||o(),!e||null!=d&&Dk(d,l)||!Dk(t,l)||e())}}))}function Xk(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Kk(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>{localStorage.setItem(e,t)}}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Jk(e){return`react-resizable-panels:${e}`}function Zk(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:o,order:r}=e;return o?n:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function Qk(e,t){try{const n=Jk(e),o=t.getItem(n);if(o){const e=JSON.parse(o);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function eS(e,t,n,o,r){var a;const i=Jk(e),s=Zk(t),l=null!==(a=Qk(e,r))&&void 0!==a?a:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:o};try{r.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function tS({layout:e,panelConstraints:t}){const n=[...e],o=n.reduce(((e,t)=>e+t),0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!Pk(o,100))for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const t=100/o*e;n[a]=t}let r=0;for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const o=Rk({panelConstraints:t,panelIndex:a,size:e});e!=o&&(r+=e-o,n[a]=o)}if(!Pk(r,0))for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const o=Rk({panelConstraints:t,panelIndex:a,size:e+r});if(e!==o&&(r-=o-e,n[a]=o,Pk(r,0)))break}return n}const nS={getItem:e=>(Kk(nS),nS.getItem(e)),setItem:(e,t)=>{Kk(nS),nS.setItem(e,t)}},oS={};function rS({autoSaveId:e=null,children:t,className:n="",direction:o,forwardedRef:r,id:a=null,onLayout:i=null,keyboardResizeBy:s=null,storage:l=nS,style:c,tagName:d="div",...u}){const h=Zw(a),f=$w(null),[m,p]=Ww(null),[g,v]=Ww([]),y=$w({}),x=$w(new Map),b=$w(0),w=$w({autoSaveId:e,direction:o,dragState:m,id:h,keyboardResizeBy:s,onLayout:i,storage:l}),k=$w({layout:g,panelDataArray:[],panelDataArrayChanged:!1});$w({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Uw(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=k.current;return e},setLayout:e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current,r=tS({layout:e,panelConstraints:o.map((e=>e.constraints))});Wk(n,r)||(v(r),k.current.layout=r,t&&t(r),Yk(o,r,y.current))}})),[]),Xw((()=>{w.current.autoSaveId=e,w.current.direction=o,w.current.dragState=m,w.current.id=h,w.current.onLayout=i,w.current.storage=l})),$k({committedValuesRef:w,eagerValuesRef:k,groupId:h,layout:g,panelDataArray:k.current.panelDataArray,setLayout:v,panelGroupElement:f.current}),Bw((()=>{const{panelDataArray:t}=k.current;if(e){if(0===g.length||g.length!==t.length)return;let n=oS[e];null==n&&(n=function(e,t=10){let n=null;return(...o)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}}(eS,100),oS[e]=n);const o=[...t],r=new Map(x.current);n(e,o,r,g,l)}}),[e,g,l]),Bw((()=>{}));const S=zw((e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current;if(e.constraints.collapsible){const r=o.map((e=>e.constraints)),{collapsedSize:a=0,panelSize:i,pivotIndices:s}=sS(o,e,n);if(Mk(null!=i,`Panel size not found for panel "${e.id}"`),!Dk(i,a)){x.current.set(e.id,i);const l=Lk({delta:iS(o,e)===o.length-1?i-a:a-i,initialLayout:n,panelConstraints:r,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});Xk(n,l)||(v(l),k.current.layout=l,t&&t(l),Yk(o,l,y.current))}}}),[]),N=zw(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current;if(e.constraints.collapsible){const a=r.map((e=>e.constraints)),{collapsedSize:i=0,panelSize:s=0,minSize:l=0,pivotIndices:c}=sS(r,e,o),d=null!=t?t:l;if(Dk(s,i)){const t=x.current.get(e.id),i=null!=t&&t>=d?t:d,l=Lk({delta:iS(r,e)===r.length-1?s-i:i-s,initialLayout:o,panelConstraints:a,pivotIndices:c,prevLayout:o,trigger:"imperative-api"});Xk(o,l)||(v(l),k.current.layout=l,n&&n(l),Yk(r,l,y.current))}}}),[]),C=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{panelSize:o}=sS(n,e,t);return Mk(null!=o,`Panel size not found for panel "${e.id}"`),o}),[]),E=zw(((e,t)=>{const{panelDataArray:n}=k.current,o=iS(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:o,panelIndex:r,precision:a=3}){const i=n[r];let s;return s=null==i?null!=e?e.toPrecision(a):"1":1===o.length?"1":i.toPrecision(a),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:m,layout:g,panelData:n,panelIndex:o})}),[m,g]),j=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=sS(n,e,t);return Mk(null!=a,`Panel size not found for panel "${e.id}"`),!0===r&&Dk(a,o)}),[]),_=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=sS(n,e,t);return Mk(null!=a,`Panel size not found for panel "${e.id}"`),!r||Ok(a,o)>0}),[]),I=zw((e=>{const{panelDataArray:t}=k.current;t.push(e),t.sort(((e,t)=>{const n=e.order,o=t.order;return null==n&&null==o?0:null==n?-1:null==o?1:n-o})),k.current.panelDataArrayChanged=!0}),[]);Xw((()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=w.current,{layout:o,panelDataArray:r}=k.current;let a=null;if(e){const t=function(e,t,n){var o,r;return null!==(r=(null!==(o=Qk(e,n))&&void 0!==o?o:{})[Zk(t)])&&void 0!==r?r:null}(e,r,n);t&&(x.current=new Map(Object.entries(t.expandToSizes)),a=t.layout)}null==a&&(a=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let o=0,r=100;for(let a=0;a<e.length;a++){const e=n[a];Mk(e,`Panel constraints not found for index ${a}`);const{defaultSize:i}=e;null!=i&&(o++,t[a]=i,r-=i)}for(let a=0;a<e.length;a++){const i=n[a];Mk(i,`Panel constraints not found for index ${a}`);const{defaultSize:s}=i;if(null!=s)continue;const l=r/(e.length-o);o++,t[a]=l,r-=l}return t}({panelDataArray:r}));const i=tS({layout:a,panelConstraints:r.map((e=>e.constraints))});Wk(o,i)||(v(i),k.current.layout=i,t&&t(i),Yk(r,i,y.current))}})),Xw((()=>{const e=k.current;return()=>{e.layout=[]}}),[]);const A=zw((e=>function(t){t.preventDefault();const n=f.current;if(!n)return()=>null;const{direction:o,dragState:r,id:a,keyboardResizeBy:i,onLayout:s}=w.current,{layout:l,panelDataArray:c}=k.current,{initialLayout:d}=null!=r?r:{},u=Uk(a,e,n);let h=qk(t,e,o,r,i,n);if(0===h)return;const m="horizontal"===o;"rtl"===document.dir&&m&&(h=-h);const p=Lk({delta:h,initialLayout:null!=d?d:l,panelConstraints:c.map((e=>e.constraints)),pivotIndices:u,prevLayout:l,trigger:rk(t)?"keyboard":"mouse-or-touch"}),g=!Xk(l,p);(ak(t)||ik(t))&&b.current!=h&&(b.current=h,_k(e,g?0:m?h<0?mk:pk:h<0?gk:vk)),g&&(v(p),k.current.layout=p,s&&s(p),Yk(c,p,y.current))}),[]),T=zw(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current,a=r.map((e=>e.constraints)),{panelSize:i,pivotIndices:s}=sS(r,e,o);Mk(null!=i,`Panel size not found for panel "${e.id}"`);const l=Lk({delta:iS(r,e)===r.length-1?i-t:t-i,initialLayout:o,panelConstraints:a,pivotIndices:s,prevLayout:o,trigger:"imperative-api"});Xk(o,l)||(v(l),k.current.layout=l,n&&n(l),Yk(r,l,y.current))}),[]),M=zw(((e,t)=>{const{layout:n,panelDataArray:o}=k.current,{collapsedSize:r=0,collapsible:a}=t,{collapsedSize:i=0,collapsible:s,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=sS(o,e,n);null!=d&&(a&&s&&Dk(d,r)?Dk(r,i)||T(e,i):d<c?T(e,c):d>l&&T(e,l))}),[T]),O=zw(((e,t)=>{const{direction:n}=w.current,{layout:o}=k.current;if(!f.current)return;const r=Hk(e,f.current);Mk(r,`Drag handle element not found for id "${e}"`);const a=Gk(n,t);p({dragHandleId:e,dragHandleRect:r.getBoundingClientRect(),initialCursorPosition:a,initialLayout:o})}),[]),D=zw((()=>{p(null)}),[]),P=zw((e=>{const{panelDataArray:t}=k.current,n=iS(t,e);n>=0&&(t.splice(n,1),delete y.current[e.id],k.current.panelDataArrayChanged=!0)}),[]),R=Hw((()=>({collapsePanel:S,direction:o,dragState:m,expandPanel:N,getPanelSize:C,getPanelStyle:E,groupId:h,isPanelCollapsed:j,isPanelExpanded:_,reevaluatePanelConstraints:M,registerPanel:I,registerResizeHandle:A,resizePanel:T,startDragging:O,stopDragging:D,unregisterPanel:P,panelGroupElement:f.current})),[S,m,o,N,C,E,h,j,_,M,I,A,T,O,D,P]),L={display:"flex",flexDirection:"horizontal"===o?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Dw(Yw.Provider,{value:R},Dw(d,{...u,children:t,className:n,id:a,ref:f,style:{...L,...c},"data-panel-group":"","data-panel-group-direction":o,"data-panel-group-id":h}))}const aS=Lw(((e,t)=>Dw(rS,{...e,forwardedRef:t})));function iS(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function sS(e,t,n){const o=iS(e,t),r=o===e.length-1?[o-1,o]:[o,o+1],a=n[o];return{...t.constraints,panelSize:a,pivotIndices:r}}function lS({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:o,id:r,onDragging:a,style:i={},tabIndex:s=0,tagName:l="div",...c}){var d,u;const h=$w(null),f=$w({onDragging:a});Bw((()=>{f.current.onDragging=a}));const m=Fw(Yw);if(null===m)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,groupId:g,registerResizeHandle:v,startDragging:y,stopDragging:x,panelGroupElement:b}=m,w=Zw(r),[k,S]=Ww("inactive"),[N,C]=Ww(!1),[E,j]=Ww(null),_=$w({state:k});Xw((()=>{_.current.state=k})),Bw((()=>{if(n)j(null);else{const e=v(w);j((()=>e))}}),[n,w,v]);const I=null!==(d=null==o?void 0:o.coarse)&&void 0!==d?d:15,A=null!==(u=null==o?void 0:o.fine)&&void 0!==u?u:5;Bw((()=>{if(n||null==E)return;const e=h.current;Mk(e,"Element ref not attached");return function(e,t,n,o,r){var a;const{ownerDocument:i}=t,s={direction:n,element:t,hitAreaMargins:o,setResizeHandlerState:r},l=null!==(a=wk.get(i))&&void 0!==a?a:0;return wk.set(i,l+1),Sk.add(s),Ak(),function(){var t;kk.delete(e),Sk.delete(s);const n=null!==(t=wk.get(i))&&void 0!==t?t:1;wk.set(i,n-1),Ak(),1===n&&wk.delete(i)}}(w,e,p,{coarse:I,fine:A},((e,t,n)=>{if(t)switch(e){case"down":{S("drag"),y(w,n);const{onDragging:e}=f.current;e&&e(!0);break}case"move":{const{state:e}=_.current;"drag"!==e&&S("hover"),E(n);break}case"up":{S("hover"),x();const{onDragging:e}=f.current;e&&e(!1);break}}else S("inactive")}))}),[I,p,n,A,v,w,E,y,x]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:o}){Bw((()=>{if(e||null==n||null==o)return;const r=Hk(t,o);if(null==r)return;const a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=r.getAttribute("data-panel-group-id");Mk(n,`No group element found for id "${n}"`);const a=Fk(n,o),i=Bk(n,t,o);Mk(null!==i,`No resize element found for id "${t}"`),a[e.shiftKey?i>0?i-1:a.length-1:i+1<a.length?i+1:0].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}),[o,e,t,n])}({disabled:n,handleId:w,resizeHandler:E,panelGroupElement:b});return Dw(l,{...c,children:e,className:t,id:r,onBlur:()=>C(!1),onFocus:()=>C(!0),ref:h,role:"separator",style:{touchAction:"none",userSelect:"none",...i},tabIndex:s,"data-panel-group-direction":p,"data-panel-group-id":g,"data-resize-handle":"","data-resize-handle-active":"drag"===k?"pointer":N?"keyboard":void 0,"data-resize-handle-state":k,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}rS.displayName="PanelGroup",aS.displayName="forwardRef(PanelGroup)",lS.displayName="PanelResizeHandle";const cS=e=>{const t=b(3);let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"}),t[0]=n):n=t[0],t[1]!==e?(o=k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...e,children:n}),t[1]=e,t[2]=o):o=t[2],o},dS=e=>{const t=b(17);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,selected:n,className:o,...r}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=!n&&"hover:bg-[var(--sage-3)]",l=n&&"bg-[var(--sage-4)]";let c,d;t[6]!==s||t[7]!==l||t[8]!==o?(c=rn("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",s,l,o),t[6]=s,t[7]=l,t[8]=o,t[9]=c):c=t[9],t[10]!==c||t[11]!==r||t[12]!==a?(d=k.jsx("div",{className:c,...r,children:a}),t[10]=c,t[11]=r,t[12]=a,t[13]=d):d=t[13];const u=d;if(i){let e;return t[14]!==i||t[15]!==u?(e=k.jsx(N,{content:i,side:"top",delayDuration:200,children:u}),t[14]=i,t[15]=u,t[16]=e):e=t[16],e}return u},uS=()=>{var e;const t=b(10),n=le(fS),o=le(de),r=(null==(e=null==n?void 0:n.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:a}=mS();if(!o){let e,n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Fc,{className:"h-4 w-4 opacity-60"}),t[0]=e):e=t[0],t[1]!==a?(n=k.jsx(dS,{tooltip:"Assist is disabled",selected:!1,onClick:a,children:e}),t[1]=a,t[2]=n):n=t[2],n}let i,s,l,c;return t[3]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("b",{children:"Assist model:"}),t[3]=i):i=t[3],t[4]!==r?(s=k.jsxs(k.Fragment,{children:[i," ",r]}),t[4]=r,t[5]=s):s=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Fc,{className:"h-4 w-4"}),t[6]=l):l=t[6],t[7]!==s||t[8]!==a?(c=k.jsx(dS,{tooltip:s,onClick:a,selected:!1,children:l}),t[7]=s,t[8]=a,t[9]=c):c=t[9],c},hS=Z((e=>e(ni).completion.copilot)),fS=Z((e=>e(ni).ai));function mS(){const e=b(5),t=ce(Ys),n=ce(Os);let o;e[0]!==t||e[1]!==n?(o=()=>{t("ai"),n(!0)},e[0]=t,e[1]=n,e[2]=o):o=e[2];const r=o;let a;return e[3]!==r?(a={handleClick:r},e[3]=r,e[4]=a):a=e[4],a}const pS=()=>{const e=b(1);if("github"===le(hS)){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(gS,{}),e[0]=t):t=e[0],t}return null},gS=()=>{const e=b(10),t=le(Xs),n=null!==le(Ks),{handleClick:o}=mS(),r=t?"Ready":"Not connected";let a,i,s,l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx("b",{children:"GitHub Copilot:"}),e[0]=a):a=e[0],e[1]!==r?(i=k.jsxs(k.Fragment,{children:[a," ",r]}),e[1]=r,e[2]=i):i=e[2],e[3]!==n||e[4]!==t?(s=k.jsx("span",{children:n?k.jsx(oi,{className:"h-4 w-4"}):k.jsx(cS,{className:rn("h-4 w-4",!t&&"opacity-60")})}),e[3]=n,e[4]=t,e[5]=s):s=e[5],e[6]!==i||e[7]!==o||e[8]!==s?(l=k.jsx(dS,{tooltip:i,selected:!1,onClick:o,children:s}),e[6]=i,e[7]=o,e[8]=s,e[9]=l):l=e[9],l},vS=e=>{const t=b(18),[n,o]=r.useState(0),a=le(sl);let i,s,l,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>o((e=>e+1)),s={delayMs:1e4,whenVisible:!0},t[0]=i,t[1]=s):(i=t[0],s=t[1]),qs(i,s),t[2]!==a.state?(l=async()=>D()||a.state!==ll.OPEN?null:ri(),t[2]=a.state,t[3]=l):l=t[3],t[4]!==n||t[5]!==a.state?(c=[n,a.state],t[4]=n,t[5]=a.state,t[6]=c):c=t[6];const{data:d}=sn(l,c);let u,h,f,m,p;return t[7]!==d?(u=d&&k.jsx(xS,{memory:d.memory,kernel:d.kernel,server:d.server}),t[7]=d,t[8]=u):u=t[8],t[9]!==d?(h=d&&k.jsx(bS,{cpu:d.cpu}),t[9]=d,t[10]=h):h=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(f=k.jsxs("div",{className:"flex items-center",children:[k.jsx(uS,{}),k.jsx(pS,{})]}),t[11]=f):f=t[11],t[12]!==a.state?(m=k.jsx(yS,{connection:a.state}),t[12]=a.state,t[13]=m):m=t[13],t[14]!==u||t[15]!==h||t[16]!==m?(p=k.jsxs("div",{className:"flex gap-2 items-center",children:[u,h,f,m]}),t[14]=u,t[15]=h,t[16]=m,t[17]=p):p=t[17],p},yS=e=>{const t=b(18),{connection:n}=e;let o,r,a,i,s,l,c;return t[0]!==n?(o=O(n.toLowerCase()),t[0]=n,t[1]=o):o=t[1],t[2]!==n?(r=n===ll.OPEN&&k.jsx(Kl,{className:"w-4 h-4"}),t[2]=n,t[3]=r):r=t[3],t[4]!==n?(a=n===ll.CLOSED&&k.jsx(Js,{className:"w-4 h-4"}),t[4]=n,t[5]=a):a=t[5],t[6]!==n?(i=n===ll.CONNECTING&&k.jsx(oi,{size:"small"}),t[6]=n,t[7]=i):i=t[7],t[8]!==n?(s=n===ll.CLOSING&&k.jsx(oi,{className:"text-destructive",size:"small"}),t[8]=n,t[9]=s):s=t[9],t[10]!==r||t[11]!==a||t[12]!==i||t[13]!==s?(l=k.jsxs("div",{children:[r,a,i,s]}),t[10]=r,t[11]=a,t[12]=i,t[13]=s,t[14]=l):l=t[14],t[15]!==o||t[16]!==l?(c=k.jsx(N,{delayDuration:200,content:o,children:l}),t[15]=o,t[16]=l,t[17]=c):c=t[17],c},xS=e=>{const t=b(25),{memory:n,kernel:o,server:r}=e,{percent:a,total:i,used:s}=n;let l;t[0]!==a?(l=Math.round(a),t[0]=a,t[1]=l):l=t[1];const c=l;let d,u,h,f,m,p,g,v,y,x;return t[2]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx("b",{children:"computer memory:"}),t[2]=d):d=t[2],t[3]!==s?(u=SS(s),t[3]=s,t[4]=u):u=t[4],t[5]!==i?(h=SS(i),t[5]=i,t[6]=h):h=t[6],t[7]!==u||t[8]!==h||t[9]!==c?(f=k.jsxs("span",{children:[d," ",u," / ",h," GB (",c,"%)"]}),t[7]=u,t[8]=h,t[9]=c,t[10]=f):f=t[10],t[11]!==(null==r?void 0:r.memory)?(m=(null==r?void 0:r.memory)&&k.jsxs("span",{children:[k.jsx("b",{children:"marimo server:"})," ",kS(r.memory)]}),t[11]=null==r?void 0:r.memory,t[12]=m):m=t[12],t[13]!==(null==o?void 0:o.memory)?(p=(null==o?void 0:o.memory)&&k.jsxs("span",{children:[k.jsx("b",{children:"kernel:"})," ",kS(o.memory)]}),t[13]=null==o?void 0:o.memory,t[14]=p):p=t[14],t[15]!==f||t[16]!==m||t[17]!==p?(g=k.jsxs("div",{className:"flex flex-col gap-1",children:[f,m,p]}),t[15]=f,t[16]=m,t[17]=p,t[18]=g):g=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(bc,{className:"w-4 h-4"}),t[19]=v):v=t[19],t[20]!==c?(y=k.jsxs("div",{className:"flex items-center gap-1",children:[v,k.jsx(wS,{percent:c})]}),t[20]=c,t[21]=y):y=t[21],t[22]!==g||t[23]!==y?(x=k.jsx(N,{delayDuration:200,content:g,children:y}),t[22]=g,t[23]=y,t[24]=x):x=t[24],x},bS=e=>{const t=b(11),{cpu:n}=e,{percent:o}=n;let r;t[0]!==o?(r=Math.round(o),t[0]=o,t[1]=r):r=t[1];const a=r;let i,s,l,c,d;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("b",{children:"CPU:"}),t[2]=i):i=t[2],t[3]!==a?(s=k.jsxs("span",{children:[i," ",a,"%"]}),t[3]=a,t[4]=s):s=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Zs,{className:"w-4 h-4"}),t[5]=l):l=t[5],t[6]!==a?(c=k.jsxs("div",{className:"flex items-center gap-1",children:[l,k.jsx(wS,{percent:a})]}),t[6]=a,t[7]=c):c=t[7],t[8]!==s||t[9]!==c?(d=k.jsx(N,{delayDuration:200,content:s,children:c}),t[8]=s,t[9]=c,t[10]=d):d=t[10],d},wS=e=>{const t=b(2),{percent:n}=e,o=`${n}%`;let r;return t[0]!==o?(r=k.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:k.jsx("div",{className:"h-full bg-primary",style:{width:o}})}),t[0]=o,t[1]=r):r=t[1],r};function kS(e){return e>1073741824?`${SS(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function SS(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}const NS=e=>le(Da)[e.capability]?e.children:null,CS=()=>{const e=b(56),{selectedPanel:t,isTerminalOpen:n}=Qd(),{openApplication:o,toggleTerminal:r}=eu(),[a,i]=Oe(),s=le(ai),l=ES,c=tu.find(jS);let d;$t(c,"Error panel not found"),e[0]!==r?(d=()=>{r()},e[0]=r,e[1]=d):d=e[1],Cs("global.toggleTerminal",d);const u=dS,h=c.tooltip,f=t===c.type,m=()=>o(c.type),p=l(c,s>0?"text-destructive":"");let g,v,y,x,w;e[2]!==s?(g=k.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:s}),e[2]=s,e[3]=g):g=e[3],e[4]!==u||e[5]!==c.tooltip||e[6]!==f||e[7]!==m||e[8]!==p||e[9]!==g?(v=k.jsxs(u,{tooltip:h,selected:f,onClick:m,children:[p,g]}),e[4]=u,e[5]=c.tooltip,e[6]=f,e[7]=m,e[8]=p,e[9]=g,e[10]=v):v=e[10],e[11]!==r?(y=()=>r(),e[11]=r,e[12]=y):y=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(x=k.jsx(qc,{className:"h-5 w-5"}),e[13]=x):x=e[13],e[14]!==n||e[15]!==y?(w=k.jsx(NS,{capability:"terminal",children:k.jsx(dS,{tooltip:"Open terminal",selected:n,onClick:y,children:x})}),e[14]=n,e[15]=y,e[16]=w):w=e[16];const S=a.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let C,E,j;e[17]!==a||e[18]!==i?(C=async()=>{const e={...a,runtime:{...a.runtime,auto_instantiate:!a.runtime.auto_instantiate}};await Pe({config:e}).then((()=>i(e)))},e[17]=a,e[18]=i,e[19]=C):C=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(E=k.jsx("span",{children:"on startup: "}),e[20]=E):E=e[20],e[21]!==a.runtime.auto_instantiate?(j=a.runtime.auto_instantiate?k.jsx(td,{size:14}):k.jsx(ed,{size:14}),e[21]=a.runtime.auto_instantiate,e[22]=j):j=e[22];const _=a.runtime.auto_instantiate?"autorun":"lazy";let I,A,T,M;e[23]!==_?(I=k.jsx("span",{children:_}),e[23]=_,e[24]=I):I=e[24],e[25]!==j||e[26]!==I?(A=k.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[E,j,I]}),e[25]=j,e[26]=I,e[27]=A):A=e[27],e[28]!==S||e[29]!==C||e[30]!==A?(T=k.jsx(dS,{tooltip:S,selected:!1,onClick:C,children:A}),e[28]=S,e[29]=C,e[30]=A,e[31]=T):T=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[32]=M):M=e[32];const O="autorun"===a.runtime.on_cell_change?"Disable autorun":"Enable autorun";let P,R,L,z,F,B,U,V,H,$;return e[33]!==a||e[34]!==i?(P=async()=>{const e={...a,runtime:{...a.runtime,on_cell_change:"autorun"===a.runtime.on_cell_change?"lazy":"autorun"}};await Pe({config:e}).then((()=>i(e)))},e[33]=a,e[34]=i,e[35]=P):P=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(R=k.jsx("span",{children:"on cell change: "}),e[36]=R):R=e[36],e[37]!==a.runtime.on_cell_change?(L=k.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[R,"autorun"===a.runtime.on_cell_change?k.jsx(td,{size:14}):k.jsx(ed,{size:14}),k.jsx("span",{children:a.runtime.on_cell_change})]}),e[37]=a.runtime.on_cell_change,e[38]=L):L=e[38],e[39]!==O||e[40]!==P||e[41]!==L?(z=k.jsx(dS,{tooltip:O,selected:!1,onClick:P,children:L}),e[39]=O,e[40]=P,e[41]=L,e[42]=z):z=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(F=k.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[43]=F):F=e[43],e[44]!==a||e[45]!==i?(B=!D()&&k.jsx(dS,{tooltip:null,selected:!1,children:k.jsxs(Bt,{children:[k.jsxs(Dt,{className:"font-prose text-sm flex items-center gap-1",children:[k.jsx("span",{children:"on module change: "}),"off"===a.runtime.auto_reload&&k.jsx(Js,{size:14}),"lazy"===a.runtime.auto_reload&&k.jsx(ed,{size:14}),"autorun"===a.runtime.auto_reload&&k.jsx(td,{size:14}),k.jsx("span",{children:a.runtime.auto_reload}),k.jsx(Ce,{size:14})]}),k.jsx(Ut,{children:["off","lazy","autorun"].map((e=>k.jsxs(Ot,{onClick:async()=>{const t={...a,runtime:{...a.runtime,auto_reload:e}};await Pe({config:t}).then((()=>i(t)))},children:["off"===e&&k.jsx(Js,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&k.jsx(ed,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&k.jsx(td,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),e[44]=a,e[45]=i,e[46]=B):B=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(U=k.jsx("div",{className:"mx-auto"}),e[47]=U):U=e[47],e[48]===Symbol.for("react.memo_cache_sentinel")?(V=k.jsx(Pu,{children:k.jsx(N,{content:k.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:k.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),H=k.jsx(vS,{}),e[48]=V,e[49]=H):(V=e[48],H=e[49]),e[50]!==v||e[51]!==w||e[52]!==T||e[53]!==z||e[54]!==B?($=k.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md pl-1 pr-4 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden hide-on-fullscreen",children:[v,w,T,M,z,F,B,U,V,H]}),e[50]=v,e[51]=w,e[52]=T,e[53]=z,e[54]=B,e[55]=$):$=e[55],$};function ES(e,t){const{Icon:n}=e;return k.jsx(n,{className:rn("h-5 w-5",t)})}function jS(e){return"errors"===e.type}const _S=e=>{const t=b(6),{children:n}=e,{openModal:o,closeModal:r}=w();let a,i;return t[0]!==o||t[1]!==r?(a=()=>o(k.jsx(AS,{onClose:r})),t[0]=o,t[1]=r,t[2]=a):a=t[2],t[3]!==a||t[4]!==n?(i=k.jsx(ii,{onClick:a,children:n}),t[3]=a,t[4]=n,t[5]=i):i=t[5],i},IS={"😡":1,"🙁":2,"😐":3,"🙂":4,"😍":5},AS=e=>{const t=b(13),{onClose:n}=e;let o,r,a,i,s,l,c,d;return t[0]!==n?(o=async e=>{e.preventDefault();const t=new FormData(e.target),o=t.get("rating"),r=t.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:o,message:r})}),n(),re({title:"Feedback sent!",description:"Thank you for your feedback!"})},t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(j,{children:"Send Feedback"}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsxs(Ie,{children:[r,k.jsxs(_,{children:["Let us know what you think about marimo! If you have a bug that you would like to report, please use the"," ",k.jsx("a",{href:Ze.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub issue tracker"}),"."]}),k.jsx(_,{children:"Your feedback is anonymous and will help us improve marimo. Thank you!"})]}),t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[k.jsx("div",{className:"flex gap-5 justify-center",children:Object.entries(IS).map(TS)}),k.jsx(si,{id:"message",name:"message",autoFocus:!0,placeholder:"Your feedback; if you'd like us to respond, please include your email!",rows:5,required:!0,autoComplete:"off"})]}),t[4]=i):i=t[4],t[5]!==n?(s=k.jsx(C,{"data-testid":"feedback-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),t[5]=n,t[6]=s):s=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(C,{"data-testid":"feedback-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[7]=l):l=t[7],t[8]!==s?(c=k.jsxs(I,{children:[s,l]}),t[8]=s,t[9]=c):c=t[9],t[10]!==o||t[11]!==c?(d=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:o,children:[a,i,c]})}),t[10]=o,t[11]=c,t[12]=d):d=t[12],d};function TS(e){const[t,n]=e;return k.jsxs("label",{className:"flex flex-col items-center select-none",children:[k.jsx("input",{type:"radio",className:"peer hidden",name:"rating",value:n,"aria-label":t},t),k.jsx("span",{className:"text-4xl peer-checked:opacity-100 opacity-40 cursor-pointer",children:t})]},t)}const MS=()=>{const e=b(10),{selectedPanel:t}=Qd(),{openApplication:n}=eu(),o=PS;let r,a,i,s,l,c;if(e[0]!==t||e[1]!==n){r="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",a=tu.filter(RS).map((e=>k.jsx(DS,{tooltip:e.tooltip,selected:t===e.type,onClick:()=>n(e.type),children:o(e)},e.type))),e[0]=t,e[1]=n,e[2]=r,e[3]=a}else r=e[2],a=e[3];return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(_S,{children:k.jsx(DS,{tooltip:"Send feedback!",selected:!1,children:k.jsx(wc,{className:"h-5 w-5"})})}),s=k.jsx("div",{className:"flex-1"}),l=k.jsx(OS,{}),e[4]=i,e[5]=s,e[6]=l):(i=e[4],s=e[5],l=e[6]),e[7]!==r||e[8]!==a?(c=k.jsxs("div",{className:r,children:[a,i,s,l]}),e[7]=r,e[8]=a,e[9]=c):c=e[9],c},OS=()=>{const e=b(9),t=le(li);let n,o,r,a;return e[0]!==t?(n=t>0?k.jsxs("span",{children:[t," cell",t>1?"s":""," queued or running"]}):"No cells queued or running",e[0]=t,e[1]=n):n=e[1],e[2]!==t?(o=Array.from({length:t}).map(LS),e[2]=t,e[3]=o):o=e[3],e[4]!==o?(r=k.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:o}),e[4]=o,e[5]=r):r=e[5],e[6]!==n||e[7]!==r?(a=k.jsx(N,{content:n,side:"right",delayDuration:200,children:r}),e[6]=n,e[7]=r,e[8]=a):a=e[8],a},DS=e=>{const t=b(17);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,selected:n,className:o,...r}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=!n&&"hover:bg-[var(--sage-3)]",l=n&&"bg-[var(--sage-4)]";let c,d,u;return t[6]!==s||t[7]!==l||t[8]!==o?(c=rn("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",s,l,o),t[6]=s,t[7]=l,t[8]=o,t[9]=c):c=t[9],t[10]!==c||t[11]!==r||t[12]!==a?(d=k.jsx("div",{className:c,...r,children:a}),t[10]=c,t[11]=r,t[12]=a,t[13]=d):d=t[13],t[14]!==i||t[15]!==d?(u=k.jsx(N,{content:i,side:"right",delayDuration:200,children:d}),t[14]=i,t[15]=d,t[16]=u):u=t[16],u};function PS(e,t){const{Icon:n}=e;return k.jsx(n,{className:rn("h-5 w-5",t)})}function RS(e){return!e.hidden&&"sidebar"===e.position}function LS(e,t){return k.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())}st.record(st.tuple([st.number(),st.number()]));let zS=null;const FS=e=>{const t=b(12),{title:n,description:o,icon:r}=e;let a,i,s,l,c;return t[0]!==r?(a=r&&u.cloneElement(r,{className:"text-accent-foreground"}),t[0]=r,t[1]=a):a=t[1],t[2]!==n?(i=k.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),t[2]=n,t[3]=i):i=t[3],t[4]!==a||t[5]!==i?(s=k.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[a,i]}),t[4]=a,t[5]=i,t[6]=s):s=t[6],t[7]!==o?(l=k.jsx("span",{className:"text-muted-foreground text-sm",children:o}),t[7]=o,t[8]=l):l=t[8],t[9]!==s||t[10]!==l?(c=k.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[s,l]}),t[9]=s,t[10]=l,t[11]=c):c=t[11],c},BS=()=>{const e=b(5),t=ci();if(0===t.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No errors!",icon:k.jsx(_c,{})}),e[0]=t):t=e[0],t}let n,o;return e[1]!==t?(n=t.map(US),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(o=k.jsx("div",{className:"flex flex-col overflow-auto",children:n}),e[3]=n,e[4]=o):o=e[4],o};function US(e){return k.jsxs("div",{children:[k.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:k.jsx(di,{cellId:e.cellId})}),k.jsx("div",{className:"px-2",children:k.jsx(ui,{errors:e.output.data},e.cellId)},e.cellId)]},e.cellId)}const VS=()=>{const e=b(6),{items:t}=le(hi);let n,o;e[0]!==t?(o=Il(t),e[0]=t,e[1]=o):o=e[1],n=o;const r=n,{activeHeaderId:a}=Al(r);if(0===t.length){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:k.jsx(Lc,{})}),e[2]=t):t=e[2],t}let i;return e[3]!==t||e[4]!==a?(i=k.jsx(Tl,{items:t,activeHeaderId:a}),e[3]=t,e[4]=a,e[5]=i):i=e[5],i};function HS(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=HS(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:$S}=u,{useSyncExternalStoreWithSelector:WS}=fi,GS=e=>e;function qS(e,t=GS,n){const o=WS(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return $S(o),o}const YS=(e,t)=>{const n=mi(e),o=(e,o=t)=>qS(n,e,o);return Object.assign(o,n),o};function XS(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function KS(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const JS={passive:!1},ZS={capture:!0,passive:!1};function QS(e){e.stopImmediatePropagation()}function eN(e){e.preventDefault(),e.stopImmediatePropagation()}function tN(e){var t=e.document.documentElement,n=Ol(e).on("dragstart.drag",eN,ZS);"onselectstart"in t?n.on("selectstart.drag",eN,ZS):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nN(e,t){var n=e.document.documentElement,o=Ol(e).on("dragstart.drag",null);t&&(o.on("click.drag",eN,ZS),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const oN=e=>()=>e;function rN(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:a,x:i,y:s,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function aN(e){return!e.ctrlKey&&!e.button}function iN(){return this.parentNode}function sN(e,t){return null==t?{x:e.x,y:e.y}:t}function lN(){return navigator.maxTouchPoints||"ontouchstart"in this}rN.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const cN=e=>()=>e;function dN(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function uN(e){e.stopImmediatePropagation()}function hN(e){e.preventDefault(),e.stopImmediatePropagation()}function fN(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function mN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function pN(){return this.__zoom||Dl}function gN(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vN(){return navigator.maxTouchPoints||"ontouchstart"in this}function yN(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}const xN=r.createContext(null),bN=xN.Provider,wN=e=>`Node type "${e}" not found. Using fallback type "default".`,kN=()=>"The React Flow parent container needs a width and a height to render the graph.",SN=()=>"Only child nodes can use a parent extent.",NN=e=>`Marker type "${e}" doesn't exist.`,CN=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,EN=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",jN=e=>`Edge type "${e}" not found. Using fallback type "default".`,_N=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,IN=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function AN(e,t){const n=r.useContext(xN);if(null===n)throw new Error(IN);return qS(n,e,t)}const TN=()=>{const e=r.useContext(xN);if(null===e)throw new Error(IN);return r.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},MN=e=>e.userSelectionActive?"none":"all";function ON({position:e,children:t,className:n,style:o,...r}){const a=AN(MN),i=`${e}`.split("-");return u.createElement("div",{className:HS(["react-flow__panel",n,...i]),style:{...o,pointerEvents:a},...r},t)}function DN({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:u.createElement(ON,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},u.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var PN=r.memo((({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:i={},labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h})=>{const f=r.useRef(null),[m,p]=r.useState({x:0,y:0,width:0,height:0}),g=HS(["react-flow__edge-textwrapper",d]);return r.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?u.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:g,visibility:m.width?"visible":"hidden",...h},a&&u.createElement("rect",{width:m.width+2*s[0],x:-s[0],y:-s[1],height:m.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),u.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:f,style:o},n),c):null}));const RN=e=>({width:e.offsetWidth,height:e.offsetHeight}),LN=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),zN=(e={x:0,y:0},t)=>({x:LN(e.x,t[0][0],t[1][0]),y:LN(e.y,t[0][1],t[1][1])}),FN=(e,t,n)=>e<t?LN(Math.abs(e-t),1,50)/50:e>n?-LN(Math.abs(e-n),1,50)/50:0,BN=(e,t)=>[20*FN(e.x,35,t.width-35),20*FN(e.y,35,t.height-35)],UN=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},VN=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),HN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),$N=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},WN=e=>!isNaN(e)&&isFinite(e),GN=Symbol.for("internals"),qN=["Enter"," ","Escape"];function YN(e){var t,n;const o=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,r=(null==(n=null==(t=o.composedPath)?void 0:t.call(o))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==r?void 0:r.nodeName)||(null==r?void 0:r.hasAttribute("contenteditable"))||!!(null==r?void 0:r.closest(".nokey"))}const XN=e=>"clientX"in e,KN=(e,t)=>{var n,o;const r=XN(e),a=r?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,i=r?e.clientY:null==(o=e.touches)?void 0:o[0].clientY;return{x:a-((null==t?void 0:t.left)??0),y:i-((null==t?void 0:t.top)??0)}},JN=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},ZN=({id:e,path:t,labelX:n,labelY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m=20})=>u.createElement(u.Fragment,null,u.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&u.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&WN(n)&&WN(o)?u.createElement(PN,{x:n,y:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c}):null);function QN(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}function eC({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,a=n<e?n+r:n-r,i=Math.abs(o-t)/2;return[a,o<t?o+i:o-i,r,i]}function tC({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:a,targetControlX:i,targetControlY:s}){const l=.125*e+.375*r+.375*i+.125*n,c=.125*t+.375*a+.375*s+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var nC,oC,rC,aC,iC,sC,lC,cC,dC,uC,hC,fC;function mC({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===hC.Left||e===hC.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function pC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top}){const[i,s]=mC({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=mC({pos:a,x1:o,y1:r,x2:e,y2:t}),[d,u,h,f]=tC({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:l,targetControlY:c});return[`M${e},${t} C${i},${s} ${l},${c} ${o},${r}`,d,u,h,f]}ZN.displayName="BaseEdge",(oC=nC||(nC={})).Strict="strict",oC.Loose="loose",(aC=rC||(rC={})).Free="free",aC.Vertical="vertical",aC.Horizontal="horizontal",(sC=iC||(iC={})).Partial="partial",sC.Full="full",(cC=lC||(lC={})).Bezier="default",cC.Straight="straight",cC.Step="step",cC.SmoothStep="smoothstep",cC.SimpleBezier="simplebezier",(uC=dC||(dC={})).Arrow="arrow",uC.ArrowClosed="arrowclosed",(fC=hC||(hC={})).Left="left",fC.Top="top",fC.Right="right",fC.Bottom="bottom";const gC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=hC.Bottom,targetPosition:a=hC.Top,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})=>{const[v,y,x]=pC({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a});return u.createElement(ZN,{path:v,labelX:y,labelY:x,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})}));gC.displayName="SimpleBezierEdge";const vC={[hC.Left]:{x:-1,y:0},[hC.Right]:{x:1,y:0},[hC.Top]:{x:0,y:-1},[hC.Bottom]:{x:0,y:1}},yC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xC({source:e,sourcePosition:t=hC.Bottom,target:n,targetPosition:o=hC.Top,center:r,offset:a}){const i=vC[t],s=vC[o],l={x:e.x+i.x*a,y:e.y+i.y*a},c={x:n.x+s.x*a,y:n.y+s.y*a},d=(({source:e,sourcePosition:t=hC.Bottom,target:n})=>t===hC.Left||t===hC.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),u=0!==d.x?"x":"y",h=d[u];let f,m,p=[];const g={x:0,y:0},v={x:0,y:0},[y,x,b,w]=eC({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[u]*s[u]==-1){f=r.x??y,m=r.y??x;const e=[{x:f,y:l.y},{x:f,y:c.y}],t=[{x:l.x,y:m},{x:c.x,y:m}];p=i[u]===h?"x"===u?e:t:"x"===u?t:e}else{const r=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(p="x"===u?i.x===h?d:r:i.y===h?r:d,t===o){const t=Math.abs(e[u]-n[u]);if(t<=a){const o=Math.min(a-1,a-t);i[u]===h?g[u]=(l[u]>e[u]?-1:1)*o:v[u]=(c[u]>n[u]?-1:1)*o}}if(t!==o){const e="x"===u?"y":"x",t=i[u]===s[e],n=l[e]>c[e],o=l[e]<c[e];(1===i[u]&&(!t&&n||t&&o)||1!==i[u]&&(!t&&o||t&&n))&&(p="x"===u?r:d)}const y={x:l.x+g.x,y:l.y+g.y},x={x:c.x+v.x,y:c.y+v.y};Math.max(Math.abs(y.x-p[0].x),Math.abs(x.x-p[0].x))>=Math.max(Math.abs(y.y-p[0].y),Math.abs(x.y-p[0].y))?(f=(y.x+x.x)/2,m=p[0].y):(f=p[0].x,m=(y.y+x.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...p,{x:c.x+v.x,y:c.y+v.y},n],f,m,b,w]}function bC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top,borderRadius:i=5,centerX:s,centerY:l,offset:c=20}){const[d,u,h,f,m]=xC({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:a,center:{x:s,y:l},offset:c});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(yC(e,t)/2,yC(t,n)/2,o),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i)return`L ${a+r*(e.x<n.x?-1:1)},${i}Q ${a},${i} ${a},${i+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${a},${i+r*(e.y<n.y?-1:1)}Q ${a},${i} ${a+r*s},${i}`}(d[n-1],t,d[n+1],i):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),u,h,f,m]}const wC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=hC.Bottom,targetPosition:f=hC.Top,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[y,x,b]=bC({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return u.createElement(ZN,{path:y,labelX:x,labelY:b,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:m,markerStart:p,interactionWidth:v})}));wC.displayName="SmoothStepEdge";const kC=r.memo((e=>{var t;return u.createElement(wC,{...e,pathOptions:r.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));kC.displayName="StepEdge";const SC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[p,g,v]=function({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,a,i,s]=eC({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,a,i,s]}({sourceX:e,sourceY:t,targetX:n,targetY:o});return u.createElement(ZN,{path:p,labelX:g,labelY:v,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})}));function NC(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function CC({pos:e,x1:t,y1:n,x2:o,y2:r,c:a}){switch(e){case hC.Left:return[t-NC(t-o,a),n];case hC.Right:return[t+NC(o-t,a),n];case hC.Top:return[t,n-NC(n-r,a)];case hC.Bottom:return[t,n+NC(r-n,a)]}}function EC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top,curvature:i=.25}){const[s,l]=CC({pos:n,x1:e,y1:t,x2:o,y2:r,c:i}),[c,d]=CC({pos:a,x1:o,y1:r,x2:e,y2:t,c:i}),[u,h,f,m]=tC({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${s},${l} ${c},${d} ${o},${r}`,u,h,f,m]}SC.displayName="StraightEdge";const jC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=hC.Bottom,targetPosition:a=hC.Top,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[y,x,b]=EC({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a,curvature:null==g?void 0:g.curvature});return u.createElement(ZN,{path:y,labelX:x,labelY:b,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:v})}));jC.displayName="BezierEdge";const _C=r.createContext(null),IC=_C.Provider;_C.Consumer;const AC=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,TC=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},MC=({x:e,y:t},[n,o,r],a,[i,s])=>{const l={x:(e-n)/r,y:(t-o)/r};return a?{x:i*Math.round(l.x/i),y:s*Math.round(l.y/s)}:l},OC=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),DC=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},PC=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};return(({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}))(e.reduce(((e,n)=>{const{x:o,y:r}=DC(n,t).positionAbsolute;return a=e,i=VN({x:o,y:r,width:n.width||0,height:n.height||0}),{x:Math.min(a.x,i.x),y:Math.min(a.y,i.y),x2:Math.max(a.x2,i.x2),y2:Math.max(a.y2,i.y2)};var a,i}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},RC=(e,t,[n,o,r]=[0,0,1],a=!1,i=!1,s=[0,0])=>{const l={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(i&&!o||r)return!1;const{positionAbsolute:d}=DC(e,s),u={x:d.x,y:d.y,width:t||0,height:n||0},h=$N(l,u);(void 0===t||void 0===n||null===t||null===n||a&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},LC=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},zC=(e,t,n,o,r,a=.1)=>{const i=t/(e.width*(1+a)),s=n/(e.height*(1+a)),l=Math.min(i,s),c=LN(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},FC=(e,t=0)=>e.transition().duration(t);function BC(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>{var a,i;return`${e.id}-${r.id}-${n}`!==o&&t.push({id:r.id||null,type:n,nodeId:e.id,x:((null==(a=e.positionAbsolute)?void 0:a.x)??0)+r.x+r.width/2,y:((null==(i=e.positionAbsolute)?void 0:i.y)??0)+r.y+r.height/2}),t}),[])}const UC={source:null,target:null,sourceHandle:null,targetHandle:null},VC=()=>({handleDomNode:null,isValid:!1,connection:UC,endHandle:null});function HC(e,t,n,o,r,a,i){const s="target"===r,l=i.querySelector(`.react-flow__handle[data-id="${null==e?void 0:e.nodeId}-${null==e?void 0:e.id}-${null==e?void 0:e.type}"]`),c={...VC(),handleDomNode:l};if(l){const e=$C(void 0,l),r=l.getAttribute("data-nodeid"),i=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:s?r:n,sourceHandle:s?i:o,target:s?n:r,targetHandle:s?o:i};c.connection=h;d&&u&&(t===nC.Strict?s&&"source"===e||!s&&"target"===e:r!==n||i!==o)&&(c.endHandle={nodeId:r,handleId:i,type:e},c.isValid=a(h))}return c}function $C(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function WC(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function GC(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function qC({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:r,getState:a,setState:i,isValidConnection:s,edgeUpdaterType:l,onReconnectEnd:c}){const d=UN(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:g,getNodes:v,cancelConnection:y}=a();let x,b=0;const{x:w,y:k}=KN(e),S=null==d?void 0:d.elementFromPoint(w,k),N=$C(l,S),C=null==h?void 0:h.getBoundingClientRect();if(!C||!N)return;let E,j=KN(e,C),_=!1,I=null,A=!1,T=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce(((e,r)=>{if(r[GN]){const{handleBounds:a}=r[GN];let i=[],s=[];a&&(i=BC(r,a,"source",`${t}-${n}-${o}`),s=BC(r,a,"target",`${t}-${n}-${o}`)),e.push(...i,...s)}return e}),[])}({nodes:v(),nodeId:n,handleId:t,handleType:N}),O=()=>{if(!f)return;const[e,t]=BN(j,C);g({x:e,y:t}),b=requestAnimationFrame(O)};function D(e){const{transform:o}=a();j=KN(e,C);const{handle:l,validHandleResult:c}=function(e,t,n,o,r,a){const{x:i,y:s}=KN(e),l=t.elementsFromPoint(i,s).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=$C(void 0,l),o=l.getAttribute("data-handleid"),i=a({nodeId:e,id:o,type:t});if(i){const a=r.find((n=>n.nodeId===e&&n.type===t&&n.id===o));return{handle:{id:o,type:t,nodeId:e,x:(null==a?void 0:a.x)||n.x,y:(null==a?void 0:a.y)||n.y},validHandleResult:i}}}}let c=[],d=1/0;if(r.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=o){const n=a(e);t<=d&&(t<d?c=[{handle:e,validHandleResult:n}]:t===d&&c.push({handle:e,validHandleResult:n}),d=t)}})),!c.length)return{handle:null,validHandleResult:VC()};if(1===c.length)return c[0];const u=c.some((({validHandleResult:e})=>e.isValid)),h=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>h?"target"===e.type:!u||t.isValid))||c[0]}(e,d,MC(j,o,!1,[1,1]),m,M,(e=>HC(e,u,n,t,r?"target":"source",s,d)));if(x=l,_||(O(),_=!0),T=c.handleDomNode,I=c.connection,A=c.isValid,i({connectionPosition:x&&A?OC({x:x.x,y:x.y},o):j,connectionStatus:GC(!!x,A),connectionEndHandle:c.endHandle}),!x&&!A&&!T)return WC(E);I.source!==I.target&&T&&(WC(E),E=T,T.classList.add("connecting","react-flow__handle-connecting"),T.classList.toggle("valid",A),T.classList.toggle("react-flow__handle-valid",A))}function P(e){var t,n;(x||T)&&I&&A&&(null==o||o(I)),null==(n=(t=a()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),WC(E),y(),cancelAnimationFrame(b),_=!1,A=!1,I=null,T=null,d.removeEventListener("mousemove",D),d.removeEventListener("mouseup",P),d.removeEventListener("touchmove",D),d.removeEventListener("touchend",P)}i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:N,connectionStartHandle:{nodeId:n,handleId:t,type:N},connectionEndHandle:null}),null==p||p(e,{nodeId:n,handleId:t,handleType:N}),d.addEventListener("mousemove",D),d.addEventListener("mouseup",P),d.addEventListener("touchmove",D),d.addEventListener("touchend",P)}const YC=()=>!0,XC=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),KC=r.forwardRef((({type:e="source",position:t=hC.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:c,className:d,onMouseDown:h,onTouchStart:f,...m},p)=>{var g,v;const y=s||null,x="target"===e,b=TN(),w=r.useContext(_C),{connectOnClick:k,noPanClassName:S}=AN(XC,XS),{connecting:N,clickConnecting:C}=AN(((e,t,n)=>o=>{const{connectionStartHandle:r,connectionEndHandle:a,connectionClickStartHandle:i}=o;return{connecting:(null==r?void 0:r.nodeId)===e&&(null==r?void 0:r.handleId)===t&&(null==r?void 0:r.type)===n||(null==a?void 0:a.nodeId)===e&&(null==a?void 0:a.handleId)===t&&(null==a?void 0:a.type)===n,clickConnecting:(null==i?void 0:i.nodeId)===e&&(null==i?void 0:i.handleId)===t&&(null==i?void 0:i.type)===n}})(w,y,e),XS);w||null==(v=(g=b.getState()).onError)||v.call(g,"010",EN());const E=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=b.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=b.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var o;return n="id"in(o=e)&&"source"in o&&"target"in o?{...e}:{...e,id:AC(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(r,e))}null==n||n(r),null==l||l(r)},j=e=>{if(!w)return;const t=XN(e);a&&(t&&0===e.button||!t)&&qC({event:e,handleId:y,nodeId:w,onConnect:E,isTarget:x,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||YC}),t?null==h||h(e):null==f||f(e)};return u.createElement("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${y}-${e}`,className:HS(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,d,{source:!x,target:x,connectable:o,connectablestart:a,connectableend:i,connecting:C,connectionindicator:o&&(a&&!N||i&&N)}]),onMouseDown:j,onTouchStart:j,onClick:k?t=>{const{onClickConnectStart:o,onClickConnectEnd:r,connectionClickStartHandle:i,connectionMode:s,isValidConnection:l}=b.getState();if(!w||!i&&!a)return;if(!i)return null==o||o(t,{nodeId:w,handleId:y,handleType:e}),void b.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:y}});const c=UN(t.target),d=n||l||YC,{connection:u,isValid:h}=HC({nodeId:w,id:y,type:e},s,i.nodeId,i.handleId||null,i.type,d,c);h&&E(u),null==r||r(t),b.setState({connectionClickStartHandle:null})}:void 0,ref:p,...m},c)}));KC.displayName="Handle";var JC=r.memo(KC);const ZC=({data:e,isConnectable:t,targetPosition:n=hC.Top,sourcePosition:o=hC.Bottom})=>u.createElement(u.Fragment,null,u.createElement(JC,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,u.createElement(JC,{type:"source",position:o,isConnectable:t}));ZC.displayName="DefaultNode";var QC=r.memo(ZC);const eE=({data:e,isConnectable:t,sourcePosition:n=hC.Bottom})=>u.createElement(u.Fragment,null,null==e?void 0:e.label,u.createElement(JC,{type:"source",position:n,isConnectable:t}));eE.displayName="InputNode";var tE=r.memo(eE);const nE=({data:e,isConnectable:t,targetPosition:n=hC.Top})=>u.createElement(u.Fragment,null,u.createElement(JC,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);nE.displayName="OutputNode";var oE=r.memo(nE);const rE=()=>null;rE.displayName="GroupNode";const aE=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),iE=e=>e.id;function sE(e,t){return XS(e.selectedNodes.map(iE),t.selectedNodes.map(iE))&&XS(e.selectedEdges.map(iE),t.selectedEdges.map(iE))}const lE=r.memo((({onSelectionChange:e})=>{const t=TN(),{selectedNodes:n,selectedEdges:o}=AN(aE,sE);return r.useEffect((()=>{const r={nodes:n,edges:o};null==e||e(r),t.getState().onSelectionChange.forEach((e=>e(r)))}),[n,o,e]),null}));lE.displayName="SelectionListener";const cE=e=>!!e.onSelectionChange;function dE({onSelectionChange:e}){const t=AN(cE);return e||t?u.createElement(lE,{onSelectionChange:e}):null}const uE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function hE(e,t){r.useEffect((()=>{void 0!==e&&t(e)}),[e])}function fE(e,t,n){r.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const mE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:i,onConnectEnd:s,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:p,minZoom:g,maxZoom:v,nodeExtent:y,onNodesChange:x,onEdgesChange:b,elementsSelectable:w,connectionMode:k,snapGrid:S,snapToGrid:N,translateExtent:C,connectOnClick:E,defaultEdgeOptions:j,fitView:_,fitViewOptions:I,onNodesDelete:A,onEdgesDelete:T,onNodeDrag:M,onNodeDragStart:O,onNodeDragStop:D,onSelectionDrag:P,onSelectionDragStart:R,onSelectionDragStop:L,noPanClassName:z,nodeOrigin:F,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:V,onError:H,connectionRadius:$,isValidConnection:W,nodeDragThreshold:G})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:X,setMinZoom:K,setMaxZoom:J,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=AN(uE,XS),te=TN();return r.useEffect((()=>{const e=null==o?void 0:o.map((e=>({...e,...j})));return X(n,e),()=>{ee()}}),[]),fE("defaultEdgeOptions",j,te.setState),fE("connectionMode",k,te.setState),fE("onConnect",a,te.setState),fE("onConnectStart",i,te.setState),fE("onConnectEnd",s,te.setState),fE("onClickConnectStart",l,te.setState),fE("onClickConnectEnd",c,te.setState),fE("nodesDraggable",d,te.setState),fE("nodesConnectable",u,te.setState),fE("nodesFocusable",h,te.setState),fE("edgesFocusable",f,te.setState),fE("edgesUpdatable",m,te.setState),fE("elementsSelectable",w,te.setState),fE("elevateNodesOnSelect",p,te.setState),fE("snapToGrid",N,te.setState),fE("snapGrid",S,te.setState),fE("onNodesChange",x,te.setState),fE("onEdgesChange",b,te.setState),fE("connectOnClick",E,te.setState),fE("fitViewOnInit",_,te.setState),fE("fitViewOnInitOptions",I,te.setState),fE("onNodesDelete",A,te.setState),fE("onEdgesDelete",T,te.setState),fE("onNodeDrag",M,te.setState),fE("onNodeDragStart",O,te.setState),fE("onNodeDragStop",D,te.setState),fE("onSelectionDrag",P,te.setState),fE("onSelectionDragStart",R,te.setState),fE("onSelectionDragStop",L,te.setState),fE("noPanClassName",z,te.setState),fE("nodeOrigin",F,te.setState),fE("rfId",B,te.setState),fE("autoPanOnConnect",U,te.setState),fE("autoPanOnNodeDrag",V,te.setState),fE("onError",H,te.setState),fE("connectionRadius",$,te.setState),fE("isValidConnection",W,te.setState),fE("nodeDragThreshold",G,te.setState),hE(e,q),hE(t,Y),hE(g,K),hE(v,J),hE(C,Z),hE(y,Q),null},pE={display:"none"},gE={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vE="react-flow__node-desc",yE="react-flow__edge-desc",xE=e=>e.ariaLiveMessage;function bE({rfId:e}){const t=AN(xE);return u.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gE},t)}function wE({rfId:e,disableKeyboardA11y:t}){return u.createElement(u.Fragment,null,u.createElement("div",{id:`${vE}-${e}`,style:pE},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),u.createElement("div",{id:`${yE}-${e}`,style:pE},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&u.createElement(bE,{rfId:e}))}var kE=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=r.useState(!1),a=r.useRef(!1),i=r.useRef(new Set([])),[s,l]=r.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return r.useEffect((()=>{const n="undefined"!=typeof document?document:null,r=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{a.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!a.current||a.current&&!t.actInsideInputWithModifier)&&YN(e))return!1;const n=NE(e.code,l);i.current.add(e[n]),SE(s,i.current,!1)&&(e.preventDefault(),o(!0))},n=e=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&YN(e))return!1;const n=NE(e.code,l);SE(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(e[n]),"Meta"===e.key&&i.current.clear(),a.current=!1},c=()=>{i.current.clear(),o(!1)};return null==r||r.addEventListener("keydown",e),null==r||r.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==r||r.removeEventListener("keydown",e),null==r||r.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,o]),n};function SE(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function NE(e,t){return t.includes(e)?"code":"key"}function CE(e,t,n,o){var r,a;const i=e.parentNode||e.parentId;if(!i)return n;const s=t.get(i),l=DC(s,o);return CE(s,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(r=s[GN])?void 0:r.z)??0)>(n.z??0)?(null==(a=s[GN])?void 0:a.z)??0:n.z??0},o)}function EE(e,t,n){e.forEach((o=>{var r;const a=o.parentNode||o.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||(null==n?void 0:n[o.id])){const{x:a,y:i,z:s}=CE(o,e,{...o.position,z:(null==(r=o[GN])?void 0:r.z)??0},t);o.positionAbsolute={x:a,y:i},o[GN].z=s,(null==n?void 0:n[o.id])&&(o[GN].isParent=!0)}}))}function jE(e,t,n,o){const r=new Map,a={},i=o?1e3:0;return e.forEach((e=>{var n;const o=(WN(e.zIndex)?e.zIndex:0)+(e.selected?i:0),s=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);const d=(null==s?void 0:s.type)&&(null==s?void 0:s.type)!==e.type;Object.defineProperty(l,GN,{enumerable:!1,value:{handleBounds:d||null==(n=null==s?void 0:s[GN])?void 0:n.handleBounds,z:o}}),r.set(e.id,l)})),EE(r,n,a),r}function _E(e,t={}){const{getNodes:n,width:o,height:r,minZoom:a,maxZoom:i,d3Zoom:s,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(s&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const o=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?o&&t.nodes.some((t=>t.id===e.id)):o})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=PC(e,u),{x:c,y:d,zoom:h}=zC(n,o,r,t.minZoom??a,t.maxZoom??i,t.padding??.1),f=Dl.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?s.transform(FC(l,t.duration),f):s.transform(l,f),!0}}return!1}function IE(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[GN]:n[GN],selected:e.selected})})),new Map(t)}function AE(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function TE({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:r,edges:a,onNodesChange:i,onEdgesChange:s,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&o({nodeInternals:IE(e,r)}),null==i||i(e)),(null==t?void 0:t.length)&&(c&&o({edges:AE(t,a)}),null==s||s(t))}const ME=()=>{},OE={zoomIn:ME,zoomOut:ME,zoomTo:ME,getZoom:()=>1,setViewport:ME,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ME,fitBounds:ME,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},DE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function PE(){const e=(()=>{const e=TN(),{d3Zoom:t,d3Selection:n}=AN(DE,XS);return r.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(FC(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(FC(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,o)=>t.scaleTo(FC(n,null==o?void 0:o.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(o,r)=>{const[a,i,s]=e.getState().transform,l=Dl.translate(o.x??a,o.y??i).scale(o.zoom??s);t.transform(FC(n,null==r?void 0:r.duration),l)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>_E(e.getState,t),setCenter:(o,r,a)=>{const{width:i,height:s,maxZoom:l}=e.getState(),c=void 0!==(null==a?void 0:a.zoom)?a.zoom:l,d=i/2-o*c,u=s/2-r*c,h=Dl.translate(d,u).scale(c);t.transform(FC(n,null==a?void 0:a.duration),h)},fitBounds:(o,r)=>{const{width:a,height:i,minZoom:s,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=zC(o,a,i,s,l,(null==r?void 0:r.padding)??.1),h=Dl.translate(c,d).scale(u);t.transform(FC(n,null==r?void 0:r.duration),h)},project:t=>{const{transform:n,snapToGrid:o,snapGrid:r}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),MC(t,n,o,r)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:o,snapGrid:r,domNode:a}=e.getState();if(!a)return t;const{x:i,y:s}=a.getBoundingClientRect(),l={x:t.x-i,y:t.y-s};return MC(l,n,o,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),i=OC(t,n);return{x:i.x+r,y:i.y+a}},viewportInitialized:!0}:OE),[t,n])})(),t=TN(),n=r.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),o=r.useCallback((e=>t.getState().nodeInternals.get(e)),[]),a=r.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),i=r.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),s=r.useCallback((e=>{const{getNodes:n,setNodes:o,hasDefaultNodes:r,onNodesChange:a}=t.getState(),i=n(),s="function"==typeof e?e(i):e;if(r)o(s);else if(a){a(0===s.length?i.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"}))))}}),[]),l=r.useCallback((e=>{const{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:a}=t.getState(),i="function"==typeof e?e(n):e;if(r)o(i);else if(a){a(0===i.length?n.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),c=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:o,setNodes:r,hasDefaultNodes:a,onNodesChange:i}=t.getState();if(a){r([...o(),...n])}else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),d=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:o=[],setEdges:r,hasDefaultEdges:a,onEdgesChange:i}=t.getState();if(a)r([...o,...n]);else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),u=r.useCallback((()=>{const{getNodes:e,edges:n=[],transform:o}=t.getState(),[r,a,i]=o;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:a,zoom:i}}}),[]),h=r.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:o,getNodes:r,edges:a,hasDefaultNodes:i,hasDefaultEdges:s,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),m=r().reduce(((e,t)=>{const n=t.parentNode||t.parentId,o=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||o)&&e.push(t),e}),[]),p=a.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=p.filter((e=>f.includes(e.id)));if(m||g){const e=LC(m,p),n=[...g,...e],r=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((s||i)&&(s&&t.setState({edges:a.filter((e=>!r.includes(e.id)))}),i&&(m.forEach((e=>{o.delete(e.id)})),t.setState({nodeInternals:new Map(o)}))),r.length>0&&(null==c||c(n),u&&u(r.map((e=>({id:e,type:"remove"}))))),m.length>0&&(null==l||l(m),d)){d(m.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=r.useCallback((e=>{const n=WN((o=e).width)&&WN(o.height)&&WN(o.x)&&WN(o.y);var o;const r=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!r)return[null,null,n];return[n?e:HN(r),r,n]}),[]),m=r.useCallback(((e,n=!0,o)=>{const[r,a,i]=f(e);return r?(o||t.getState().getNodes()).filter((e=>{if(!(i||e.id!==a.id&&e.positionAbsolute))return!1;const t=HN(e),o=$N(t,r);return n&&o>0||o>=r.width*r.height})):[]}),[]),p=r.useCallback(((e,t,n=!0)=>{const[o]=f(e);if(!o)return!1;const r=$N(o,t);return n&&r>0||r>=o.width*o.height}),[]);return r.useMemo((()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:i,setNodes:s,setEdges:l,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:p})),[e,n,o,a,i,s,l,c,d,u,h,m,p])}const RE={actInsideInputWithModifier:!1};const LE={position:"absolute",width:"100%",height:"100%",top:0,left:0},zE=e=>({x:e.x,y:e.y,zoom:e.k}),FE=(e,t)=>e.target.closest(`.${t}`),BE=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),UE=e=>{const t=e.ctrlKey&&JN()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},VE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),HE=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=rC.Free,zoomOnDoubleClick:d=!0,elementsSelectable:h,panOnDrag:f=!0,defaultViewport:m,translateExtent:p,minZoom:g,maxZoom:v,zoomActivationKeyCode:y,preventScrolling:x=!0,children:b,noWheelClassName:w,noPanClassName:k})=>{const S=r.useRef(),N=TN(),C=r.useRef(!1),E=r.useRef(!1),j=r.useRef(null),_=r.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:A,d3ZoomHandler:T,userSelectionActive:M}=AN(VE,XS),O=kE(y),D=r.useRef(0),P=r.useRef(!1),R=r.useRef();return function(e){const t=TN();r.useEffect((()=>{let n;const o=()=>{var n,o;if(!e.current)return;const r=RN(e.current);0!==r.height&&0!==r.width||null==(o=(n=t.getState()).onError)||o.call(n,"004",kN()),t.setState({width:r.width||500,height:r.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver((()=>o())),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}}),[])}(j),r.useEffect((()=>{if(j.current){const e=j.current.getBoundingClientRect(),t=function(){var e,t,n,o=fN,r=mN,a=yN,i=gN,s=vN,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=zl,h=Ll("start","zoom","end"),f=0,m=10;function p(e){e.property("__zoom",pN).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",C).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new Pl(t,e.x,e.y)}function v(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new Pl(e.k,o,r)}function y(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,t,n,o){e.on("start.zoom",(function(){b(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){b(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,a=arguments,i=b(e,a).event(o),s=r.apply(e,a),l=null==n?y(s):"function"==typeof n?n.apply(e,a):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,a):t,f=u(d.invert(l).concat(c/d.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new Pl(n,l[0]-t[0]*n,l[1]-t[1]*n)}i.zoom(null,e)}}))}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=b(this,t).event(e),r=this.__zoom,s=Math.max(l[0],Math.min(l[1],r.k*Math.pow(2,i.apply(this,arguments)))),d=KS(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=r.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[d,r.invert(d)],Rl(this),n.start()}hN(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",a(v(g(r,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function S(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,i=b(this,t,!0).event(e),s=Ol(e.view).on("mousemove.zoom",(function(e){if(hN(e),!i.moved){var t=e.clientX-d,n=e.clientY-u;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",a(v(i.that.__zoom,i.mouse[0]=KS(e,r),i.mouse[1]),i.extent,c))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),nN(e.view,i.moved),hN(e),i.event(e).end()}),!0),l=KS(e,r),d=e.clientX,u=e.clientY;tN(e.view),uN(e),i.mouse=[l,this.__zoom.invert(l)],Rl(this),i.start()}}function N(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,i=KS(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(i),l=n.k*(e.shiftKey?.5:2),u=a(v(g(n,l),i,s),r.apply(this,t),c);hN(e),d>0?Ol(this).transition().duration(d).call(x,u,i,e):Ol(this).call(p.transform,u,i,e)}}function C(n,...r){if(o.apply(this,arguments)){var a,i,s,l,c=n.touches,d=c.length,u=b(this,r,n.changedTouches.length===d).event(n);for(uN(n),i=0;i<d;++i)l=[l=KS(s=c[i],this),this.__zoom.invert(l),s.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,a=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),Rl(this),u.start())}}function E(e,...t){if(this.__zooming){var n,o,r,i,s=b(this,t).event(e),l=e.changedTouches,d=l.length;for(hN(e),n=0;n<d;++n)r=KS(o=l[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var u=s.touch0[0],h=s.touch0[1],f=s.touch1[0],m=s.touch1[1],p=(p=f[0]-u[0])*p+(p=f[1]-u[1])*p,y=(y=m[0]-h[0])*y+(y=m[1]-h[1])*y;o=g(o,Math.sqrt(p/y)),r=[(u[0]+f[0])/2,(u[1]+f[1])/2],i=[(h[0]+m[0])/2,(h[1]+m[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],i=s.touch0[1]}s.zoom("touch",a(v(o,r,i),s.extent,c))}}function j(e,...o){if(this.__zooming){var r,a,i=b(this,o).event(e),s=e.changedTouches,l=s.length;for(uN(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),r=0;r<l;++r)a=s[r],i.touch0&&i.touch0[2]===a.identifier?delete i.touch0:i.touch1&&i.touch1[2]===a.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps&&(a=KS(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<m)){var c=Ol(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return p.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",pN),e!==r?x(e,t,n,o):r.interrupt().each((function(){b(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},p.scaleBy=function(e,t,n,o){p.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},p.scaleTo=function(e,t,n,o){p.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,i=null==n?y(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return a(v(g(o,l),i,s),e,c)}),n,o)},p.translateBy=function(e,t,n,o){p.transform(e,(function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),c)}),null,o)},p.translateTo=function(e,t,n,o,i){p.transform(e,(function(){var e=r.apply(this,arguments),i=this.__zoom,s=null==o?y(e):"function"==typeof o?o.apply(this,arguments):o;return a(Dl.translate(s[0],s[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),o,i)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Ol(this.that).datum();h.call(e,this.that,new dN(e,{sourceEvent:this.sourceEvent,target:p,type:e,transform:this.that.__zoom,dispatch:h}),t)}},p.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:cN(+e),p):i},p.filter=function(e){return arguments.length?(o="function"==typeof e?e:cN(!!e),p):o},p.touchable=function(e){return arguments.length?(s="function"==typeof e?e:cN(!!e),p):s},p.extent=function(e){return arguments.length?(r="function"==typeof e?e:cN([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),p):r},p.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],p):[l[0],l[1]]},p.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],p):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},p.constrain=function(e){return arguments.length?(a=e,p):a},p.duration=function(e){return arguments.length?(d=+e,p):d},p.interpolate=function(e){return arguments.length?(u=e,p):u},p.on=function(){var e=h.on.apply(h,arguments);return e===h?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p.tapDistance=function(e){return arguments.length?(m=+e,p):m},p}().scaleExtent([g,v]).translateExtent(p),n=Ol(j.current).call(t),o=Dl.translate(m.x,m.y).scale(LN(m.zoom,g,v)),r=[[0,0],[e.width,e.height]],a=t.constrain()(o,r,p);t.transform(n,a),t.wheelDelta(UE),N.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[a.x,a.y,a.k],domNode:j.current.closest(".react-flow")})}}),[]),r.useEffect((()=>{A&&I&&(!s||O||M?void 0!==T&&A.on("wheel.zoom",(function(e,t){if(!x&&"wheel"===e.type&&!e.ctrlKey||FE(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):A.on("wheel.zoom",(o=>{if(FE(o,w))return!1;o.preventDefault(),o.stopImmediatePropagation();const r=A.property("__zoom").k||1;if(o.ctrlKey&&i){const e=KS(o),t=UE(o),n=r*Math.pow(2,t);return void I.scaleTo(A,n,e,o)}const a=1===o.deltaMode?20:1;let s=c===rC.Vertical?0:o.deltaX*a,d=c===rC.Horizontal?0:o.deltaY*a;!JN()&&o.shiftKey&&c!==rC.Vertical&&(s=o.deltaY*a,d=0),I.translateBy(A,-s/r*l,-d/r*l,{internal:!0});const u=zE(A.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:m}=N.getState();clearTimeout(R.current),P.current||(P.current=!0,null==t||t(o,u),null==h||h(u)),P.current&&(null==e||e(o,u),null==f||f(u),R.current=setTimeout((()=>{null==n||n(o,u),null==m||m(u),P.current=!1}),150))}),{passive:!1}))}),[M,s,c,A,I,T,O,i,x,w,t,e,n]),r.useEffect((()=>{I&&I.on("start",(e=>{var n,o;if(!e.sourceEvent||e.sourceEvent.internal)return null;D.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:r}=N.getState(),a=zE(e.transform);C.current=!0,_.current=a,"mousedown"===(null==(o=e.sourceEvent)?void 0:o.type)&&N.setState({paneDragging:!0}),null==r||r(a),null==t||t(e.sourceEvent,a)}))}),[I,t]),r.useEffect((()=>{I&&(M&&!C.current?I.on("zoom",null):M||I.on("zoom",(t=>{var n;const{onViewportChange:r}=N.getState();if(N.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),E.current=!(!o||!BE(f,D.current??0)),(e||r)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=zE(t.transform);null==r||r(n),null==e||e(t.sourceEvent,n)}})))}),[M,I,e,f,o]),r.useEffect((()=>{I&&I.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=N.getState();if(C.current=!1,N.setState({paneDragging:!1}),o&&BE(f,D.current??0)&&!E.current&&o(e.sourceEvent),E.current=!1,(n||t)&&(r=_.current,a=e.transform,r.x!==a.x||r.y!==a.y||r.zoom!==a.k)){const o=zE(e.transform);_.current=o,clearTimeout(S.current),S.current=setTimeout((()=>{null==t||t(o),null==n||n(e.sourceEvent,o)}),s?150:0)}var r,a}))}),[I,s,f,n,o]),r.useEffect((()=>{I&&I.filter((e=>{const t=O||a,n=i&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(FE(e,"react-flow__node")||FE(e,"react-flow__edge")))return!0;if(!(f||t||s||d||i))return!1;if(M)return!1;if(!d&&"dblclick"===e.type)return!1;if(FE(e,w)&&"wheel"===e.type)return!1;if(FE(e,k)&&("wheel"!==e.type||s&&"wheel"===e.type&&!O))return!1;if(!i&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!s&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const o=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&o}))}),[M,I,a,i,s,d,f,h,O]),u.createElement("div",{className:"react-flow__renderer",ref:j,style:LE},b)},$E=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function WE(){const{userSelectionActive:e,userSelectionRect:t}=AN($E,XS);return e&&t?u.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function GE(e,t){const n=t.parentNode||t.parentId,o=e.find((e=>e.id===n));if(o){const e=t.position.x+t.width-o.width,n=t.position.y+t.height-o.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,e>0&&(o.style.width+=e),n>0&&(o.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);o.position.x=o.position.x-e,o.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);o.position.y=o.position.y-e,o.style.height+=e,t.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function qE(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&GE(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&GE(t,r);break;case"remove":return t}return t.push(r),t}),n)}function YE(e,t){return qE(e,t)}const XE=(e,t)=>({id:e,type:"select",selected:t});function KE(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(XE(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(XE(n.id,!1))),e}),[])}const JE=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},ZE=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),QE=r.memo((({isSelecting:e,selectionMode:t=iC.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:i,onPaneContextMenu:s,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:h,children:f})=>{const m=r.useRef(null),p=TN(),g=r.useRef(0),v=r.useRef(0),y=r.useRef(),{userSelectionActive:x,elementsSelectable:b,dragging:w}=AN(ZE,XS),k=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,v.current=0},S=e=>{null==i||i(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},N=l?e=>l(e):void 0,C=b&&(e||x);return u.createElement("div",{className:HS(["react-flow__pane",{dragging:w,selection:e}]),onClick:C?void 0:JE(S,m),onContextMenu:JE((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==s||s(e)}),m),onWheel:JE(N,m),onMouseEnter:C?void 0:c,onMouseDown:C?t=>{const{resetSelectedElements:n,domNode:r}=p.getState();if(y.current=null==r?void 0:r.getBoundingClientRect(),!b||!e||0!==t.button||t.target!==m.current||!y.current)return;const{x:a,y:i}=KN(t,y.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:i,x:a,y:i}}),null==o||o(t)}:void 0,onMouseMove:C?n=>{const{userSelectionRect:o,nodeInternals:r,edges:a,transform:i,onNodesChange:s,onEdgesChange:l,nodeOrigin:c,getNodes:d}=p.getState();if(!e||!y.current||!o)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=KN(n,y.current),h=o.startX??0,f=o.startY??0,m={...o,x:u.x<h?u.x:h,y:u.y<f?u.y:f,width:Math.abs(u.x-h),height:Math.abs(u.y-f)},x=d(),b=RC(r,m,i,t===iC.Partial,!0,c),w=LC(b,a).map((e=>e.id)),k=b.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=KE(x,k);e.length&&(null==s||s(e))}if(v.current!==w.length){v.current=w.length;const e=KE(a,w);e.length&&(null==l||l(e))}p.setState({userSelectionRect:m})}:d,onMouseUp:C?e=>{if(0!==e.button)return;const{userSelectionRect:t}=p.getState();!x&&t&&e.target===m.current&&(null==S||S(e)),p.setState({nodesSelectionActive:g.current>0}),k(),null==a||a(e)}:void 0,onMouseLeave:C?e=>{x&&(p.setState({nodesSelectionActive:g.current>0}),null==a||a(e)),k()}:h,ref:m,style:LE},f,u.createElement(WE,null))}));function ej(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const o=t.get(n);return!!o&&(!!o.selected||ej(o,t))}function tj(e,t,n){let o=e;do{if(null==o?void 0:o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function nj(e,t,n,o){return Array.from(e.values()).filter((n=>(n.selected||n.id===o)&&(!n.parentNode||n.parentId||!ej(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,o;return{id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-((null==(t=e.positionAbsolute)?void 0:t.x)??0),y:n.y-((null==(o=e.positionAbsolute)?void 0:o.y)??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}}))}function oj(e,t,n,o,r=[0,0],a){const i=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||o);let s=i;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:o,y:a}=DC(t,r).positionAbsolute;s=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:o,y:a}=DC(t,r).positionAbsolute;s=t&&WN(o)&&WN(a)&&WN(t.width)&&WN(t.height)?[[o+e.width*r[0],a+e.height*r[1]],[o+t.width-e.width+e.width*r[0],a+t.height-e.height+e.height*r[1]]]:s}else null==a||a("005",SN()),s=i;let c={x:0,y:0};if(l){const e=n.get(l);c=DC(e,r).positionAbsolute}const d=s&&"parent"!==s?zN(t,s):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function rj({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]}QE.displayName="Pane";const aj=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const a=Array.from(r),i=t.getBoundingClientRect(),s=i.width*o[0],l=i.height*o[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-i.left-s)/n,y:(t.top-i.top-l)/n,...RN(e)}}))};function ij(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);r&&n(o,{...r})}}function sj({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:i,nodeInternals:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(a({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==o?void 0:o.current)?void 0:e.blur()}))):r([e])):null==l||l("012",_N(e))}function lj(e){return(t,n,o)=>null==e?void 0:e(t,o)}function cj({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:i,selectNodesOnDrag:s}){const l=TN(),[c,d]=r.useState(!1),u=r.useRef([]),h=r.useRef({x:null,y:null}),f=r.useRef(0),m=r.useRef(null),p=r.useRef({x:0,y:0}),g=r.useRef(null),v=r.useRef(!1),y=r.useRef(!1),x=r.useRef(!1),b=function(){const e=TN();return r.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:o,snapToGrid:r}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,s={x:(a-n[0])/n[2],y:(i-n[1])/n[2]};return{xSnapped:r?o[0]*Math.round(s.x/o[0]):s.x,ySnapped:r?o[1]*Math.round(s.y/o[1]):s.y,...s}}),[])}();return r.useEffect((()=>{if(null==e?void 0:e.current){const r=Ol(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:o,onSelectionDrag:r,updateNodePositions:i,nodeExtent:s,snapGrid:c,snapToGrid:f,nodeOrigin:m,onError:p}=l.getState();h.current={x:e,y:t};let v=!1,y={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&s){const e=PC(u.current,m);y=VN(e)}if(u.current=u.current.map((o=>{const r={x:e-o.distance.x,y:t-o.distance.y};f&&(r.x=c[0]*Math.round(r.x/c[0]),r.y=c[1]*Math.round(r.y/c[1]));const a=[[s[0][0],s[0][1]],[s[1][0],s[1][1]]];u.current.length>1&&s&&!o.extent&&(a[0][0]=o.positionAbsolute.x-y.x+s[0][0],a[1][0]=o.positionAbsolute.x+(o.width??0)-y.x2+s[1][0],a[0][1]=o.positionAbsolute.y-y.y+s[0][1],a[1][1]=o.positionAbsolute.y+(o.height??0)-y.y2+s[1][1]);const i=oj(o,r,n,a,m,p);return v=v||o.position.x!==i.position.x||o.position.y!==i.position.y,o.position=i.position,o.positionAbsolute=i.positionAbsolute,o})),!v)return;i(u.current,!0,!0),d(!0);const x=a?o:lj(r);if(x&&g.current){const[e,t]=rj({nodeId:a,dragItems:u.current,nodeInternals:n});x(g.current,e,t)}},w=()=>{if(!m.current)return;const[e,t]=BN(p.current,m.current);if(0!==e||0!==t){const{transform:n,panBy:o}=l.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],o({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:o,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:m}=l.getState();y.current=!0;const p=a?f:lj(m);s&&i||r||!a||(null==(n=o.get(a))?void 0:n.selected)||d(),a&&i&&s&&sj({id:a,store:l,nodeRef:e});const g=b(t);if(h.current=g,u.current=nj(o,c,g,a),p&&u.current){const[e,n]=rj({nodeId:a,dragItems:u.current,nodeInternals:o});p(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,o,r=aN,a=iN,i=sN,s=lN,l={},c=Ll("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",g).on("touchmove.drag",v,JS).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,s){if(!o&&r.call(this,i,s)){var l=x(this,a.call(this,i,s),i,s,"mouse");l&&(Ol(i.view).on("mousemove.drag",m,ZS).on("mouseup.drag",p,ZS),tN(i.view),QS(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function m(o){if(eN(o),!n){var r=o.clientX-e,a=o.clientY-t;n=r*r+a*a>u}l.mouse("drag",o)}function p(e){Ol(e.view).on("mousemove.drag mouseup.drag",null),nN(e.view,n),eN(e),l.mouse("end",e)}function g(e,t){if(r.call(this,e,t)){var n,o,i=e.changedTouches,s=a.call(this,e,t),l=i.length;for(n=0;n<l;++n)(o=x(this,s,e,t,i[n].identifier,i[n]))&&(QS(e),o("start",e,i[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=l[o[t].identifier])&&(eN(e),n("drag",e,o[t]))}function y(e){var t,n,r=e.changedTouches,a=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<a;++t)(n=l[r[t].identifier])&&(QS(e),n("end",e,r[t]))}function x(e,t,n,o,r,a){var s,u,f,m=c.copy(),p=KS(a||n,t);if(null!=(f=i.call(e,new rN("beforestart",{sourceEvent:n,target:h,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:m}),o)))return s=f.x-p[0]||0,u=f.y-p[1]||0,function n(a,i,c){var g,v=p;switch(a){case"start":l[r]=n,g=d++;break;case"end":delete l[r],--d;case"drag":p=KS(c||i,t),g=d}m.call(a,e,new rN(a,{sourceEvent:i,subject:f,target:h,identifier:r,active:g,x:p[0]+s,y:p[1]+u,dx:p[0]-v[0],dy:p[1]-v[1],dispatch:m}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:oN(!!e),h):r},h.container=function(e){return arguments.length?(a="function"==typeof e?e:oN(e),h):a},h.subject=function(e){return arguments.length?(i="function"==typeof e?e:oN(e),h):i},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:oN(!!e),h):s},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(u=(e=+e)*e,h):Math.sqrt(u)},h}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&k(e),x.current=!1;const o=b(e);h.current=o,m.current=(null==t?void 0:t.getBoundingClientRect())||null,p.current=KN(e.sourceEvent,m.current)})).on("drag",(e=>{var t,n;const o=b(e),{autoPanOnNodeDrag:r,nodeDragThreshold:a}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!v.current&&y.current&&r&&(v.current=!0,w()),!y.current){const r=o.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),i=o.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(r*r+i*i)>a&&k(e)}(h.current.x!==o.xSnapped||h.current.y!==o.ySnapped)&&u.current&&y.current&&(g.current=e.sourceEvent,p.current=KN(e.sourceEvent,m.current),c(o))}})).on("end",(e=>{if(y.current&&!x.current&&(d(!1),v.current=!1,y.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:o,onSelectionDragStop:r}=l.getState(),i=a?o:lj(r);if(t(u.current,!1,!1),i){const[t,o]=rj({nodeId:a,dragItems:u.current,nodeInternals:n});i(e.sourceEvent,t,o)}}})).filter((t=>{const r=t.target;return!t.button&&(!n||!tj(r,`.${n}`,e))&&(!o||tj(r,o,e))}));return r.call(t),()=>{r.on(".drag",null)}}r.on(".drag",null)}}),[e,t,n,o,i,l,a,s,b]),c}function dj(){const e=TN();return r.useCallback((t=>{const{nodeInternals:n,nodeExtent:o,updateNodePositions:r,getNodes:a,snapToGrid:i,snapGrid:s,onError:l,nodesDraggable:c}=e.getState(),d=a().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=i?s[0]:5,h=i?s[1]:5,f=t.isShiftPressed?4:1,m=t.x*u*f,p=t.y*h*f;r(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+p};i&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));const{positionAbsolute:r,position:a}=oj(e,t,n,o,void 0,l);e.position=a,e.positionAbsolute=r}return e})),!0,!1)}),[])}const uj={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var hj=e=>{const t=({id:t,type:n,data:o,xPos:a,yPos:i,xPosOrigin:s,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:p,onDoubleClick:g,style:v,className:y,isDraggable:x,isSelectable:b,isConnectable:w,isFocusable:k,selectNodesOnDrag:S,sourcePosition:N,targetPosition:C,hidden:E,resizeObserver:j,dragHandle:_,zIndex:I,isParent:A,noDragClassName:T,noPanClassName:M,initialized:O,disableKeyboardA11y:D,ariaLabel:P,rfId:R,hasHandleBounds:L})=>{const z=TN(),F=r.useRef(null),B=r.useRef(null),U=r.useRef(N),V=r.useRef(C),H=r.useRef(n),$=b||x||d||h||f||m,W=dj(),G=ij(t,z.getState,h),q=ij(t,z.getState,f),Y=ij(t,z.getState,m),X=ij(t,z.getState,p),K=ij(t,z.getState,g);r.useEffect((()=>()=>{B.current&&(null==j||j.unobserve(B.current),B.current=null)}),[]),r.useEffect((()=>{if(F.current&&!E){const e=F.current;O&&L&&B.current===e||(B.current&&(null==j||j.unobserve(B.current)),null==j||j.observe(e),B.current=e)}}),[E,O,L]),r.useEffect((()=>{const e=H.current!==n,o=U.current!==N,r=V.current!==C;F.current&&(e||o||r)&&(e&&(H.current=n),o&&(U.current=N),r&&(V.current=C),z.getState().updateNodeDimensions([{id:t,nodeElement:F.current,forceUpdate:!0}]))}),[t,n,N,C]);const J=cj({nodeRef:F,disabled:E||!x,noDragClassName:T,handleSelector:_,nodeId:t,isSelectable:b,selectNodesOnDrag:S});return E?null:u.createElement("div",{className:HS(["react-flow__node",`react-flow__node-${n}`,{[M]:x},y,{selected:c,selectable:b,parent:A,dragging:J}]),ref:F,style:{zIndex:I,transform:`translate(${s}px,${l}px)`,pointerEvents:$?"all":"none",visibility:O?"visible":"hidden",...v},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:G,onMouseMove:q,onMouseLeave:Y,onContextMenu:X,onClick:e=>{const{nodeDragThreshold:n}=z.getState();if(b&&(!S||!x||n>0)&&sj({id:t,store:z,nodeRef:F}),d){const n=z.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:K,onKeyDown:k?e=>{if(!YN(e)&&!D)if(qN.includes(e.key)&&b){const n="Escape"===e.key;sj({id:t,store:z,unselect:n,nodeRef:F})}else x&&c&&Object.prototype.hasOwnProperty.call(uj,e.key)&&(z.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~i}`}),W({x:uj[e.key].x,y:uj[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":D?void 0:`${vE}-${R}`,"aria-label":P},u.createElement(IC,{value:t},u.createElement(e,{id:t,data:o,type:n,xPos:a,yPos:i,selected:c,isConnectable:w,sourcePosition:N,targetPosition:C,dragging:J,dragHandle:_,zIndex:I})))};return t.displayName="NodeWrapper",r.memo(t)};const fj=e=>{const t=e.getNodes().filter((e=>e.selected));return{...PC(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var mj=r.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=TN(),{width:a,height:i,x:s,y:l,transformString:c,userSelectionActive:d}=AN(fj,XS),h=dj(),f=r.useRef(null);if(r.useEffect((()=>{var e;n||null==(e=f.current)||e.focus({preventScroll:!0})}),[n]),cj({nodeRef:f}),d||!a||!i)return null;const m=e?t=>{const n=o.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return u.createElement("div",{className:HS(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},u.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(uj,e.key)&&h({x:uj[e.key].x,y:uj[e.key].y,isShiftPressed:e.shiftKey})},style:{width:a,height:i,top:l,left:s}}))}));const pj=e=>e.nodesSelectionActive,gj=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,deleteKeyCode:l,onMove:c,onMoveStart:d,onMoveEnd:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:y,panActivationKeyCode:x,zoomActivationKeyCode:b,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:N,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,preventScrolling:O,onSelectionContextMenu:D,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:L})=>{const z=AN(pj),F=kE(f),B=kE(x),U=B||_,V=B||N,H=F||m&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=TN(),{deleteElements:o}=PE(),a=kE(e,RE),i=kE(t);r.useEffect((()=>{if(a){const{edges:e,getNodes:t}=n.getState(),r=t().filter((e=>e.selected)),a=e.filter((e=>e.selected));o({nodes:r,edges:a}),n.setState({nodesSelectionActive:!1})}}),[a]),r.useEffect((()=>{n.setState({multiSelectionActive:i})}),[i])})({deleteKeyCode:l,multiSelectionKeyCode:y}),u.createElement(HE,{onMove:c,onMoveStart:d,onMoveEnd:h,onPaneContextMenu:i,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:V,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!F&&U,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,zoomActivationKeyCode:b,preventScrolling:O,noWheelClassName:P,noPanClassName:R},u.createElement(QE,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:U,isSelecting:!!H,selectionMode:p},e,z&&u.createElement(mj,{onSelectionContextMenu:D,noPanClassName:R,disableKeyboardA11y:L})))};gj.displayName="FlowRenderer";var vj=r.memo(gj);function yj(e){return{...{input:hj(e.input||tE),default:hj(e.default||QC),output:hj(e.output||oE),group:hj(e.group||rE)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=hj(e[n]||QC),t)),{})}}const xj=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),bj=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:i,onError:s}=AN(xj,XS),l=(c=e.onlyRenderVisibleElements,AN(r.useCallback((e=>c?RC(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=r.useRef(),h=r.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));i(t)}));return d.current=e,e}),[]);return r.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),u.createElement("div",{className:"react-flow__nodes",style:LE},l.map((r=>{var i,l,c;let d=r.type||"default";e.nodeTypes[d]||(null==s||s("003",wN(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,m=!!(r.draggable||t&&void 0===r.draggable),p=!!(r.selectable||a&&void 0===r.selectable),g=!!(r.connectable||n&&void 0===r.connectable),v=!!(r.focusable||o&&void 0===r.focusable),y=e.nodeExtent?zN(r.positionAbsolute,e.nodeExtent):r.positionAbsolute,x=(null==y?void 0:y.x)??0,b=(null==y?void 0:y.y)??0,w=(({x:e,y:t,width:n,height:o,origin:r})=>n&&o?r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]}:{x:e,y:t})({x:x,y:b,width:r.width??0,height:r.height??0,origin:e.nodeOrigin});return u.createElement(f,{key:r.id,id:r.id,className:r.className,style:r.style,type:d,data:r.data,sourcePosition:r.sourcePosition||hC.Bottom,targetPosition:r.targetPosition||hC.Top,hidden:r.hidden,xPos:x,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!r.selected,isDraggable:m,isSelectable:p,isConnectable:g,isFocusable:v,resizeObserver:h,dragHandle:r.dragHandle,zIndex:(null==(i=r[GN])?void 0:i.z)??0,isParent:!!(null==(l=r[GN])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!r.width&&!!r.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:r.ariaLabel,hasHandleBounds:!!(null==(c=r[GN])?void 0:c.handleBounds)})})))};bj.displayName="NodeRenderer";var wj=r.memo(bj);const kj=(e,t,n)=>n===hC.Left?e-t:n===hC.Right?e+t:e,Sj=(e,t,n)=>n===hC.Top?e-t:n===hC.Bottom?e+t:e,Nj="react-flow__edgeupdater",Cj=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:i,type:s})=>u.createElement("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:i,className:HS([Nj,`${Nj}-${s}`]),cx:kj(t,o,e),cy:Sj(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),Ej=()=>!0;var jj=e=>{const t=({id:t,className:n,type:o,data:a,onClick:i,onEdgeDoubleClick:s,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,style:v,source:y,target:x,sourceX:b,sourceY:w,targetX:k,targetY:S,sourcePosition:N,targetPosition:C,elementsSelectable:E,hidden:j,sourceHandleId:_,targetHandleId:I,onContextMenu:A,onMouseEnter:T,onMouseMove:M,onMouseLeave:O,reconnectRadius:D,onReconnect:P,onReconnectStart:R,onReconnectEnd:L,markerEnd:z,markerStart:F,rfId:B,ariaLabel:U,isFocusable:V,isReconnectable:H,pathOptions:$,interactionWidth:W,disableKeyboardA11y:G})=>{const q=r.useRef(null),[Y,X]=r.useState(!1),[K,J]=r.useState(!1),Z=TN(),Q=r.useMemo((()=>`url('#${TC(F,B)}')`),[F,B]),ee=r.useMemo((()=>`url('#${TC(z,B)}')`),[z,B]);if(j)return null;const te=QN(t,Z.getState,s),ne=QN(t,Z.getState,A),oe=QN(t,Z.getState,T),re=QN(t,Z.getState,M),ae=QN(t,Z.getState,O),ie=(e,n)=>{if(0!==e.button)return;const{edges:o,isValidConnection:r}=Z.getState(),a=n?x:y,i=(n?I:_)||null,s=n?"target":"source",l=r||Ej,c=n,d=o.find((e=>e.id===t));J(!0),null==R||R(e,d,s);qC({event:e,handleId:i,nodeId:a,onConnect:e=>null==P?void 0:P(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:s,onReconnectEnd:e=>{J(!1),null==L||L(e,d,s)}})},se=()=>X(!0),le=()=>X(!1),ce=!E&&!i;return u.createElement("g",{className:HS(["react-flow__edge",`react-flow__edge-${o}`,n,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:o,addSelectedEdges:r,unselectNodesAndEdges:a,multiSelectionActive:s}=Z.getState(),l=o.find((e=>e.id===t));l&&(E&&(Z.setState({nodesSelectionActive:!1}),l.selected&&s?(a({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):r([t])),i&&i(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:oe,onMouseMove:re,onMouseLeave:ae,onKeyDown:V?e=>{var n;if(!G&&qN.includes(e.key)&&E){const{unselectNodesAndEdges:o,addSelectedEdges:r,edges:a}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),o({edges:[a.find((e=>e.id===t))]})):r([t])}}:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${y} to ${x}`,"aria-describedby":V?`${yE}-${B}`:void 0,ref:q},!K&&u.createElement(e,{id:t,source:y,target:x,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,data:a,style:v,sourceX:b,sourceY:w,targetX:k,targetY:S,sourcePosition:N,targetPosition:C,sourceHandleId:_,targetHandleId:I,markerStart:Q,markerEnd:ee,pathOptions:$,interactionWidth:W}),H&&u.createElement(u.Fragment,null,("source"===H||!0===H)&&u.createElement(Cj,{position:N,centerX:b,centerY:w,radius:D,onMouseDown:e=>ie(e,!0),onMouseEnter:se,onMouseOut:le,type:"source"}),("target"===H||!0===H)&&u.createElement(Cj,{position:C,centerX:k,centerY:S,radius:D,onMouseDown:e=>ie(e,!1),onMouseEnter:se,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",r.memo(t)};function _j(e){return{...{default:jj(e.default||jC),straight:jj(e.bezier||SC),step:jj(e.step||kC),smoothstep:jj(e.step||wC),simplebezier:jj(e.simplebezier||gC)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=jj(e[n]||jC),t)),{})}}function Ij(e,t,n=null){const o=((null==n?void 0:n.x)||0)+t.x,r=((null==n?void 0:n.y)||0)+t.y,a=(null==n?void 0:n.width)||t.width,i=(null==n?void 0:n.height)||t.height;switch(e){case hC.Top:return{x:o+a/2,y:r};case hC.Right:return{x:o+a,y:r+i/2};case hC.Bottom:return{x:o+a/2,y:r+i};case hC.Left:return{x:o,y:r+i/2}}}function Aj(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function Tj(e){var t,n,o,r,a;const i=(null==(t=null==e?void 0:e[GN])?void 0:t.handleBounds)||null,s=i&&(null==e?void 0:e.width)&&(null==e?void 0:e.height)&&void 0!==(null==(n=null==e?void 0:e.positionAbsolute)?void 0:n.x)&&void 0!==(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.y);return[{x:(null==(r=null==e?void 0:e.positionAbsolute)?void 0:r.x)||0,y:(null==(a=null==e?void 0:e.positionAbsolute)?void 0:a.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},i,!!s]}const Mj=[{level:0,isMaxLevel:!0,edges:[]}];function Oj(e,t,n){return function(e,t,n=!1){let o=-1;const r=e.reduce(((e,r)=>{var a,i;const s=WN(r.zIndex);let l=s?r.zIndex:0;if(n){const e=t.get(r.target),n=t.get(r.source),o=r.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(a=null==n?void 0:n[GN])?void 0:a.z)||0,(null==(i=null==e?void 0:e[GN])?void 0:i.z)||0,1e3);l=(s?r.zIndex:0)+(o?c:0)}return e[l]?e[l].push(r):e[l]=[r],o=l>o?l:o,e}),{}),a=Object.entries(r).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===o}}));return 0===a.length?Mj:a}(AN(r.useCallback((n=>e?n.edges.filter((e=>{const o=t.get(e.source),r=t.get(e.target);return(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:r,targetHeight:a,width:i,height:s,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+r),y2:Math.max(e.y+o,t.y+a)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=VN({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:i/l[2],height:s/l[2]}),u=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),h=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(u*h)>0}({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:r.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:r.width,targetHeight:r.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const Dj={[dC.Arrow]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[dC.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Pj=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const c=function(e){const t=TN();return r.useMemo((()=>{var n,o;return Object.prototype.hasOwnProperty.call(Dj,e)?Dj[e]:(null==(o=(n=t.getState()).onError)||o.call(n,"009",NN(e)),null)}),[e])}(t);return c?u.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0"},u.createElement(c,{color:n,strokeWidth:s})):null},Rj=({defaultColor:e,rfId:t})=>{const n=AN(r.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const a=TC(r,t);o.includes(a)||(n.push({id:a,color:r.color||e,...r}),o.push(a))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:t}),[e,t]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return u.createElement("defs",null,n.map((e=>u.createElement(Pj,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient}))))};Rj.displayName="MarkerDefinitions";var Lj=r.memo(Rj);const zj=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Fj=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,children:v,disableKeyboardA11y:y})=>{const{edgesFocusable:x,edgesUpdatable:b,elementsSelectable:w,width:k,height:S,connectionMode:N,nodeInternals:C,onError:E}=AN(zj,XS),j=Oj(t,C,n);return k?u.createElement(u.Fragment,null,j.map((({level:t,edges:n,isMaxLevel:v})=>u.createElement("svg",{key:t,style:{zIndex:t},width:k,height:S,className:"react-flow__edges react-flow__container"},v&&u.createElement(Lj,{defaultColor:e,rfId:o}),u.createElement("g",null,n.map((e=>{const[t,n,v]=Tj(C.get(e.source)),[k,S,j]=Tj(C.get(e.target));if(!v||!j)return null;let _=e.type||"default";r[_]||(null==E||E("011",jN(_)),_="default");const I=r[_]||r.default,A=N===nC.Strict?S.target:(S.target??[]).concat(S.source??[]),T=Aj(n.source,e.sourceHandle),M=Aj(A,e.targetHandle),O=(null==T?void 0:T.position)||hC.Bottom,D=(null==M?void 0:M.position)||hC.Top,P=!!(e.focusable||x&&void 0===e.focusable),R=e.reconnectable||e.updatable,L=void 0!==f&&(R||b&&void 0===R);if(!T||!M)return null==E||E("008",CN(T,e)),null;const{sourceX:z,sourceY:F,targetX:B,targetY:U}=((e,t,n,o,r,a)=>{const i=Ij(n,e,t),s=Ij(a,o,r);return{sourceX:i.x,sourceY:i.y,targetX:s.x,targetY:s.y}})(t,T,O,k,M,D);return u.createElement(I,{key:e.id,id:e.id,className:HS([e.className,a]),type:_,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:z,sourceY:F,targetX:B,targetY:U,sourcePosition:O,targetPosition:D,elementsSelectable:w,onContextMenu:i,onMouseEnter:s,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,rfId:o,ariaLabel:e.ariaLabel,isFocusable:P,isReconnectable:L,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:y})})))))),v):null};Fj.displayName="EdgeRenderer";var Bj=r.memo(Fj);const Uj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Vj({children:e}){const t=AN(Uj);return u.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const Hj={[hC.Left]:hC.Right,[hC.Right]:hC.Left,[hC.Top]:hC.Bottom,[hC.Bottom]:hC.Top},$j=({nodeId:e,handleType:t,style:n,type:o=lC.Bezier,CustomComponent:a,connectionStatus:i})=>{var s,l,c;const{fromNode:d,handleId:h,toX:f,toY:m,connectionMode:p}=AN(r.useCallback((t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode})),[e]),XS),g=null==(s=null==d?void 0:d[GN])?void 0:s.handleBounds;let v=null==g?void 0:g[t];if(p===nC.Loose&&(v=v||(null==g?void 0:g["source"===t?"target":"source"])),!d||!v)return null;const y=h?v.find((e=>e.id===h)):v[0],x=y?y.x+y.width/2:(d.width??0)/2,b=y?y.y+y.height/2:d.height??0,w=((null==(l=d.positionAbsolute)?void 0:l.x)??0)+x,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+b,S=null==y?void 0:y.position,N=S?Hj[S]:null;if(!S||!N)return null;if(a)return u.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:y,fromX:w,fromY:k,toX:f,toY:m,fromPosition:S,toPosition:N,connectionStatus:i});let C="";const E={sourceX:w,sourceY:k,sourcePosition:S,targetX:f,targetY:m,targetPosition:N};return o===lC.Bezier?[C]=EC(E):o===lC.Step?[C]=bC({...E,borderRadius:0}):o===lC.SmoothStep?[C]=bC(E):o===lC.SimpleBezier?[C]=pC(E):C=`M${w},${k} ${f},${m}`,u.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};$j.displayName="ConnectionLine";const Wj=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Gj({containerStyle:e,style:t,type:n,component:o}){const{nodeId:r,handleType:a,nodesConnectable:i,width:s,height:l,connectionStatus:c}=AN(Wj,XS);return!!(r&&a&&s&&i)?u.createElement("svg",{style:e,width:s,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},u.createElement("g",{className:HS(["react-flow__connection",c])},u.createElement($j,{nodeId:r,handleType:a,style:t,type:n,CustomComponent:o,connectionStatus:c}))):null}function qj(e,t){r.useRef(null),TN();return r.useMemo((()=>t(e)),[e])}const Yj=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:i,onNodeClick:s,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,onSelectionContextMenu:g,onSelectionStart:v,onSelectionEnd:y,connectionLineType:x,connectionLineStyle:b,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:S,selectionOnDrag:N,selectionMode:C,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,deleteKeyCode:I,onlyRenderVisibleElements:A,elementsSelectable:T,selectNodesOnDrag:M,defaultViewport:O,translateExtent:D,minZoom:P,maxZoom:R,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:H,zoomOnDoubleClick:$,panOnDrag:W,onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneScroll:K,onPaneContextMenu:J,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,noDragClassName:ie,noWheelClassName:se,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const me=qj(e,yj),pe=qj(t,_j);return function(e){const t=PE(),n=r.useRef(!1);r.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(i),u.createElement(vj,{onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneContextMenu:J,onPaneScroll:K,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:N,selectionMode:C,onSelectionStart:v,onSelectionEnd:y,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,elementsSelectable:T,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:F,zoomOnPinch:B,zoomOnDoubleClick:$,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:H,panOnDrag:W,defaultViewport:O,translateExtent:D,minZoom:P,maxZoom:R,onSelectionContextMenu:g,preventScrolling:L,noDragClassName:ie,noWheelClassName:se,noPanClassName:le,disableKeyboardA11y:de},u.createElement(Vj,null,u.createElement(Bj,{edgeTypes:pe,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:A,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,defaultMarkerColor:z,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},u.createElement(Gj,{style:b,type:x,component:w,containerStyle:k})),u.createElement("div",{className:"react-flow__edgelabel-renderer"}),u.createElement(wj,{nodeTypes:me,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,selectNodesOnDrag:M,onlyRenderVisibleElements:A,noPanClassName:le,noDragClassName:ie,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};Yj.displayName="GraphView";var Xj=r.memo(Yj);const Kj=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Jj={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Kj,nodeExtent:Kj,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:nC.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:(e,t)=>{},isValidConnection:void 0},Zj=()=>{return e=(e,t)=>({...Jj,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:a}=t();e({nodeInternals:jE(n,o,r,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},setDefaultNodesAndEdges:(n,o)=>{const r=void 0!==n,a=void 0!==o,i=r?jE(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:a?o:[],hasDefaultNodes:r,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:a,fitViewOnInitDone:i,fitViewOnInitOptions:s,domNode:l,nodeOrigin:c}=t(),d=null==l?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const u=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce(((e,t)=>{const n=r.get(t.id);if(null==n?void 0:n.hidden)r.set(n.id,{...n,[GN]:{...n[GN],handleBounds:void 0}});else if(n){const o=RN(t.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)&&(r.set(n.id,{...n,[GN]:{...n[GN],handleBounds:{source:aj(".source",t.nodeElement,h,c),target:aj(".target",t.nodeElement,h,c)}},...o}),e.push({id:n.id,type:"dimensions",dimensions:o}))}return e}),[]);EE(r,c);const m=i||a&&!i&&_E(t,{initial:!0,...s});e({nodeInternals:new Map(r),fitViewOnInitDone:m}),(null==f?void 0:f.length)>0&&(null==o||o(f))},updateNodePositions:(e,n=!0,o=!1)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:o};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:a,nodeOrigin:i,getNodes:s,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(a){const t=jE(YE(n,s()),r,i,l);e({nodeInternals:t})}null==o||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let i,s=null;o?i=n.map((e=>XE(e,!0))):(i=KE(a(),n),s=KE(r,[])),TE({changedNodes:i,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let i,s=null;o?i=n.map((e=>XE(e,!0))):(i=KE(r,n),s=KE(a(),[])),TE({changedNodes:s,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:a}=t(),i=o||r;TE({changedNodes:(n||a()).map((e=>(e.selected=!1,XE(e.id,!1)))),changedEdges:i.map((e=>XE(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();null==o||o.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();null==o||o.scaleExtent([r,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;null==(o=t().d3Zoom)||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t();TE({changedNodes:o().filter((e=>e.selected)).map((e=>XE(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>XE(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=zN(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:a,d3Selection:i,translateExtent:s}=t();if(!a||!i||!e.x&&!e.y)return!1;const l=Dl.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[o,r]],d=null==a?void 0:a.constrain()(l,c,s);return a.transform(i,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:Jj.connectionNodeId,connectionHandleId:Jj.connectionHandleId,connectionHandleType:Jj.connectionHandleType,connectionStatus:Jj.connectionStatus,connectionStartHandle:Jj.connectionStartHandle,connectionEndHandle:Jj.connectionEndHandle}),reset:()=>e({...Jj})}),t=Object.is,e?YS(e,t):YS;var e,t},Qj=({children:e})=>{const t=r.useRef(null);return t.current||(t.current=Zj()),u.createElement(bN,{value:t.current},e)};Qj.displayName="ReactFlowProvider";const e_=({children:e})=>r.useContext(xN)?u.createElement(u.Fragment,null,e):u.createElement(Qj,null,e);e_.displayName="ReactFlowWrapper";const t_={input:tE,default:QC,output:oE,group:rE},n_={default:jC,straight:SC,step:kC,smoothstep:wC,simplebezier:gC},o_=[0,0],r_=[15,15],a_={x:0,y:0,zoom:1},i_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},s_=r.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a=t_,edgeTypes:i=n_,onNodeClick:s,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:N,onNodeDrag:C,onNodeDragStop:E,onNodesDelete:j,onEdgesDelete:_,onSelectionChange:I,onSelectionDragStart:A,onSelectionDrag:T,onSelectionDragStop:M,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:P,connectionMode:R=nC.Strict,connectionLineType:L=lC.Bezier,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:H=!1,selectionMode:$=iC.Full,panActivationKeyCode:W="Space",multiSelectionKeyCode:G=(JN()?"Meta":"Control"),zoomActivationKeyCode:q=(JN()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:X=r_,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:J=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=o_,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,defaultViewport:ae=a_,minZoom:ie=.5,maxZoom:se=2,translateExtent:le=Kj,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:me=!1,panOnScrollSpeed:pe=.5,panOnScrollMode:ge=rC.Free,zoomOnDoubleClick:ve=!0,panOnDrag:ye=!0,onPaneClick:xe,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ne,children:Ce,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onEdgeUpdate:Te,onEdgeUpdateStart:Me,onEdgeUpdateEnd:Oe,onReconnect:De,onReconnectStart:Pe,onReconnectEnd:Re,reconnectRadius:Le=10,edgeUpdaterRadius:ze=10,onNodesChange:Fe,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:Ve="nowheel",noPanClassName:He="nopan",fitView:$e=!1,fitViewOptions:We,connectOnClick:Ge=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Xe,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:Je=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:ot,style:rt,id:at,nodeDragThreshold:it,...st},lt)=>{const ct=at||"1";return u.createElement("div",{...st,style:{...rt,...i_},ref:lt,className:HS(["react-flow",r]),"data-testid":"rf__wrapper",id:at},u.createElement(e_,null,u.createElement(Xj,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:s,onEdgeClick:l,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:L,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:H,selectionMode:$,deleteKeyCode:U,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:q,onlyRenderVisibleElements:K,selectNodesOnDrag:J,defaultViewport:ae,translateExtent:le,minZoom:ie,maxZoom:se,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ve,panOnScroll:me,panOnScrollSpeed:pe,panOnScrollMode:ge,panOnDrag:ye,onPaneClick:xe,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ne,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:P,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onReconnect:De??Te,onReconnectStart:Pe??Me,onReconnectEnd:Re??Oe,reconnectRadius:Le??ze,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:Ve,noPanClassName:He,elevateEdgesOnSelect:Je,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),u.createElement(mE,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,elevateNodesOnSelect:Ke,minZoom:ie,maxZoom:se,nodeExtent:de,onNodesChange:Fe,onEdgesChange:Be,snapToGrid:Y,snapGrid:X,connectionMode:R,translateExtent:le,connectOnClick:Ge,defaultEdgeOptions:Xe,fitView:$e,fitViewOptions:We,onNodesDelete:j,onEdgesDelete:_,onNodeDragStart:N,onNodeDrag:C,onNodeDragStop:E,onSelectionDrag:T,onSelectionDragStart:A,onSelectionDragStop:M,noPanClassName:He,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:ot,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:it}),u.createElement(dE,{onSelectionChange:I}),Ce,u.createElement(DN,{proOptions:Ye,position:qe}),u.createElement(wE,{rfId:ct,disableKeyboardA11y:Ze})))}));function l_(e){return t=>{const[n,o]=r.useState(t),a=r.useCallback((t=>o((n=>e(t,n)))),[]);return[n,o,a]}}s_.displayName="ReactFlow";const c_=l_(YE),d_=l_((function(e,t){return qE(e,t)}));function u_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},u.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function h_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},u.createElement("path",{d:"M0 0h32v4.2H0z"}))}function f_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},u.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function m_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function p_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const g_=({children:e,className:t,...n})=>u.createElement("button",{type:"button",className:HS(["react-flow__controls-button",t]),...n},e);g_.displayName="ControlButton";const v_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),y_=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:c,className:d,children:h,position:f="bottom-left"})=>{const m=TN(),[p,g]=r.useState(!1),{isInteractive:v,minZoomReached:y,maxZoomReached:x}=AN(v_,XS),{zoomIn:b,zoomOut:w,fitView:k}=PE();if(r.useEffect((()=>{g(!0)}),[]),!p)return null;return u.createElement(ON,{className:HS(["react-flow__controls",d]),position:f,style:e,"data-testid":"rf__controls"},t&&u.createElement(u.Fragment,null,u.createElement(g_,{onClick:()=>{b(),null==i||i()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},u.createElement(u_,null)),u.createElement(g_,{onClick:()=>{w(),null==s||s()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:y},u.createElement(h_,null))),n&&u.createElement(g_,{className:"react-flow__controls-fitview",onClick:()=>{k(a),null==l||l()},title:"fit view","aria-label":"fit view"},u.createElement(f_,null)),o&&u.createElement(g_,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),null==c||c(!v)},title:"toggle interactivity","aria-label":"toggle interactivity"},v?u.createElement(p_,null):u.createElement(m_,null)),h)};y_.displayName="Controls";var x_,b_,w_=r.memo(y_);function k_({color:e,dimensions:t,lineWidth:n}){return u.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function S_({color:e,radius:t}){return u.createElement("circle",{cx:t,cy:t,r:t,fill:e})}(b_=x_||(x_={})).Lines="lines",b_.Dots="dots",b_.Cross="cross";const N_={[x_.Dots]:"#91919a",[x_.Lines]:"#eee",[x_.Cross]:"#e2e2e2"},C_={[x_.Dots]:1,[x_.Lines]:1,[x_.Cross]:6},E_=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function j_({id:e,variant:t=x_.Dots,gap:n=20,size:o,lineWidth:a=1,offset:i=2,color:s,style:l,className:c}){const d=r.useRef(null),{transform:h,patternId:f}=AN(E_,XS),m=s||N_[t],p=o||C_[t],g=t===x_.Dots,v=t===x_.Cross,y=Array.isArray(n)?n:[n,n],x=[y[0]*h[2]||1,y[1]*h[2]||1],b=p*h[2],w=v?[b,b]:x,k=g?[b/i,b/i]:[w[0]/i,w[1]/i];return u.createElement("svg",{className:HS(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},u.createElement("pattern",{id:f+e,x:h[0]%x[0],y:h[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?u.createElement(S_,{color:m,radius:b/i}):u.createElement(k_,{dimensions:w,color:m,lineWidth:a})),u.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}j_.displayName="Background";var __=r.memo(j_);function I_(e){return Math.min(11*e+35,200)}const A_=u.createContext("LR"),T_=r.memo((e=>{const t=b(51),{data:n,selected:o}=e,a=le(n.atom),i=he().inOrderIds.indexOf(a.id),s=o?"var(--gray-9)":"var(--gray-3)",l=AN(O_),c=r.useContext(A_);let d,u,h,f,m;if(t[0]!==a.code||t[1]!==c||t[2]!==s||t[3]!==o){const e=a.code.split("\n").length,n="LR"===c?hC.Left:hC.Top;let r;t[8]!==s?(r={background:s},t[8]=s,t[9]=r):r=t[9],t[10]!==n||t[11]!==r?(h=k.jsx(JC,{type:"target",id:"inputs",position:n,style:r}),t[10]=n,t[11]=r,t[12]=h):h=t[12];const i="LR"===c?hC.Left:hC.Top;let l;t[13]!==s?(l={background:s},t[13]=s,t[14]=l):l=t[14],t[15]!==i||t[16]!==l?(f=k.jsx(JC,{type:"source",id:"inputs",position:i,style:l}),t[15]=i,t[16]=l,t[17]=f):f=t[17];const m=o&&"border-primary";t[18]!==m?(u=rn("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",m),t[18]=m,t[19]=u):u=t[19],d=I_(e),t[0]=a.code,t[1]=c,t[2]=s,t[3]=o,t[4]=d,t[5]=u,t[6]=h,t[7]=f}else d=t[4],u=t[5],h=t[6],f=t[7];var p;let g;t[20]!==n.forceWidth||t[21]!==l?(m=n.forceWidth||(p=l,Math.min(Math.max(p-100,100),400)),t[20]=n.forceWidth,t[21]=l,t[22]=m):m=t[22],t[23]!==d||t[24]!==m?(g={height:d,width:m},t[23]=d,t[24]=m,t[25]=g):g=t[25];const v=pi(a.name,i);let y,x,w;t[26]!==v?(y=k.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:v}),t[26]=v,t[27]=y):y=t[27],t[28]!==a.code?(x=k.jsx(Ml,{code:a.code}),t[28]=a.code,t[29]=x):x=t[29],t[30]!==u||t[31]!==g||t[32]!==y||t[33]!==x?(w=k.jsxs("div",{className:u,style:g,children:[y,x]}),t[30]=u,t[31]=g,t[32]=y,t[33]=x,t[34]=w):w=t[34];const S="LR"===c?hC.Right:hC.Bottom;let N,C;t[35]!==s?(N={background:s},t[35]=s,t[36]=N):N=t[36],t[37]!==S||t[38]!==N?(C=k.jsx(JC,{type:"source",id:"outputs",position:S,style:N}),t[37]=S,t[38]=N,t[39]=C):C=t[39];const E="LR"===c?hC.Right:hC.Bottom;let j,_,I;return t[40]!==s?(j={background:s},t[40]=s,t[41]=j):j=t[41],t[42]!==E||t[43]!==j?(_=k.jsx(JC,{type:"target",id:"outputs",position:E,style:j}),t[42]=E,t[43]=j,t[44]=_):_=t[44],t[45]!==h||t[46]!==f||t[47]!==w||t[48]!==C||t[49]!==_?(I=k.jsxs("div",{children:[h,f,w,C,_]}),t[45]=h,t[46]=f,t[47]=w,t[48]=C,t[49]=_,t[50]=I):I=t[50],I}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));T_.displayName="CustomNode";const M_={custom:T_};function O_(e){const{width:t}=e;return t}const D_=e=>{const t=b(18),{maxCount:n,cellIds:o,onClick:r,skipScroll:a}=e,i=he();let s,l,c,d;if(t[0]!==o||t[1]!==i.inOrderIds||t[2]!==n||t[3]!==a||t[4]!==r){c=Symbol.for("react.early_return_sentinel");e:{let e;t[8]!==i.inOrderIds?(e=(e,t)=>i.inOrderIds.indexOf(e)-i.inOrderIds.indexOf(t),t[8]=i.inOrderIds,t[9]=e):e=t[9];const d=[...o].sort(e);if(0===o.length){let e;t[10]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("div",{className:"text-muted-foreground",children:"--"}),t[10]=e):e=t[10],c=e;break e}let u;t[11]!==a||t[12]!==r||t[13]!==o.length?(u=(e,t)=>k.jsxs("span",{className:"truncate",children:[k.jsx(gi,{variant:"focus",cellId:e,skipScroll:a,className:"whitespace-nowrap",onClick:r?()=>r(e):void 0},e),t<o.length-1&&", "]},e),t[11]=a,t[12]=r,t[13]=o.length,t[14]=u):u=t[14],s=d.slice(0,n).map(u),l=o.length>n&&k.jsxs(fn,{children:[k.jsx(xr,{asChild:!0,children:k.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",o.length-n," more"]})}),k.jsx(hn,{className:"w-auto",children:k.jsx("div",{className:"flex flex-col gap-1 py-1",children:d.slice(n).map((e=>k.jsx(gi,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:r?()=>r(e):void 0},e)))})})]})}t[0]=o,t[1]=i.inOrderIds,t[2]=n,t[3]=a,t[4]=r,t[5]=s,t[6]=l,t[7]=c}else s=t[5],l=t[6],c=t[7];return c!==Symbol.for("react.early_return_sentinel")?c:(t[15]!==s||t[16]!==l?(d=k.jsxs(k.Fragment,{children:[s,l]}),t[15]=s,t[16]=l,t[17]=d):d=t[17],d)},P_=e=>{const t=b(15);let n,o,r,a;t[0]!==e?(({name:r,declaredBy:n,onClick:o,...a}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a):(n=t[1],o=t[2],r=t[3],a=t[4]);const i=n.length>1?"destructive":"outline";let s,l,c;return t[5]!==o||t[6]!==r?(s=async e=>{o?o(e):(await et(r),re({title:"Copied to clipboard"}))},t[5]=o,t[6]=r,t[7]=s):s=t[7],t[8]!==r||t[9]!==i||t[10]!==s?(l=k.jsx(vi,{title:r,variant:i,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:s,children:r}),t[8]=r,t[9]=i,t[10]=s,t[11]=l):l=t[11],t[12]!==a||t[13]!==l?(c=k.jsx("div",{className:"max-w-[130px]",...a,children:l}),t[12]=a,t[13]=l,t[14]=c):c=t[14],c},R_=r.memo((e=>{const t=b(38),{onChange:n,view:o,settings:r,onSettingsChange:a}=e;let i;t[0]!==a||t[1]!==r?(i=(e,t)=>{a({...r,[e]:t})},t[0]=a,t[1]=r,t[2]=i):i=t[2];const s=i;let l,c,d,u,h,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(xr,{asChild:!0,children:k.jsx(C,{variant:"text",size:"xs",children:k.jsx(Tt,{className:"w-4 h-4"})})}),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),t[4]=c):c=t[4],t[5]!==s?(d=e=>s("hidePureMarkdown",Boolean(e)),t[5]=s,t[6]=d):d=t[6],t[7]!==r.hidePureMarkdown||t[8]!==d?(u=k.jsx(qr,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:r.hidePureMarkdown,onCheckedChange:d}),t[7]=r.hidePureMarkdown,t[8]=d,t[9]=u):u=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx(Ae,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),t[10]=h):h=t[10],t[11]!==u?(f=k.jsxs(fn,{children:[l,k.jsxs(hn,{className:"w-auto p-2 text-muted-foreground",children:[c,k.jsxs("div",{className:"flex items-center gap-2",children:[u,h]})]})]}),t[11]=u,t[12]=f):f=t[12];const m=f,p="_minimap_"===o;let g,v,y;t[13]!==n?(g=()=>n("_minimap_"),t[13]=n,t[14]=g):g=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(Dc,{className:"w-4 h-4 mr-1"}),t[15]=v):v=t[15],t[16]!==p||t[17]!==g?(y=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":p,size:"xs",onClick:g,children:[v,"Mini Map"]}),t[16]=p,t[17]=g,t[18]=y):y=t[18];const x="TB"===o;let w,S,N;t[19]!==n?(w=()=>n("TB"),t[19]=n,t[20]=w):w=t[20],t[21]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(kc,{className:"w-4 h-4 mr-1"}),t[21]=S):S=t[21],t[22]!==x||t[23]!==w?(N=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":x,size:"xs",onClick:w,children:[S,"Vertical Tree"]}),t[22]=x,t[23]=w,t[24]=N):N=t[24];const E="LR"===o;let j,_,I,A;t[25]!==n?(j=()=>n("LR"),t[25]=n,t[26]=j):j=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(_=k.jsx(kc,{className:"w-4 h-4 mr-1 transform -rotate-90"}),t[27]=_):_=t[27],t[28]!==E||t[29]!==j?(I=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":E,size:"xs",onClick:j,children:[_," ","Horizontal Tree"]}),t[28]=E,t[29]=j,t[30]=I):I=t[30],t[31]!==y||t[32]!==N||t[33]!==I?(A=k.jsxs("div",{className:"flex gap-2",children:[y,N,I]}),t[31]=y,t[32]=N,t[33]=I,t[34]=A):A=t[34];const T="_minimap_"!==o&&m;let M;return t[35]!==A||t[36]!==T?(M=k.jsxs(ON,{position:"top-right",className:"flex flex-col items-end gap-2",children:[A,T]}),t[35]=A,t[36]=T,t[37]=M):M=t[37],M}));R_.displayName="GraphToolbar";const L_=r.memo((e=>{const t=b(11),{selection:n,variables:o,onClearSelection:r}=e;if(!n)return null;const a=z_;let i;t[0]!==n.type||t[1]!==n.id||t[2]!==n.source||t[3]!==n.target||t[4]!==o||t[5]!==r?(i=()=>{if("node"===n.type){const e=Object.values(o).filter((e=>e.usedBy.includes(n.id))),t=Object.values(o).filter((e=>e.declaredBy.includes(n.id))),i=(e,t)=>k.jsxs(k.Fragment,{children:[0===e.length&&k.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),k.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>k.jsxs(u.Fragment,{children:[k.jsx(P_,{declaredBy:e.declaredBy,name:e.name}),k.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,k.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),k.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:k.jsx(D_,{skipScroll:!0,onClick:()=>a("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[k.jsx(ct,{className:"w-5 h-5"}),k.jsx(gi,{cellId:n.id}),k.jsx("div",{className:"flex-1"}),k.jsx(cx,{cellId:n.id,children:k.jsx(C,{variant:"ghost",size:"icon",children:k.jsx(rc,{className:"w-4 h-4"})})}),k.jsx(C,{variant:"text",size:"icon",onClick:()=>{r()},children:k.jsx(tn,{className:"w-4 h-4"})})]}),k.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[k.jsxs("div",{className:"flex flex-col gap-2",children:[k.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[k.jsx(Ul,{className:"w-4 h-4"}),"Outputs"]}),i(t,"out")]}),k.jsx("hr",{className:"border-divider my-3"}),k.jsxs("div",{className:"flex flex-col gap-2",children:[k.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[k.jsx(Vl,{className:"w-4 h-4"}),"Inputs"]}),i(e,"in")]})]})]})}if("edge"===n.type){const e=Object.values(o).filter((e=>e.declaredBy.includes(n.source)&&e.usedBy.includes(n.target)));return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[k.jsx(Qc,{className:"w-4 h-4"}),k.jsx(gi,{cellId:n.source}),k.jsx(Hl,{className:"w-4 h-4"}),k.jsx(gi,{cellId:n.target})]}),k.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:e.map((e=>k.jsxs(u.Fragment,{children:[k.jsx(P_,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{a(e.declaredBy[0],e.name)}}),k.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),k.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}},t[0]=n.type,t[1]=n.id,t[2]=n.source,t[3]=n.target,t[4]=o,t[5]=r,t[6]=i):i=t[6];const s=i;let l,c;return t[7]!==s?(l=s(),t[7]=s,t[8]=l):l=t[8],t[9]!==l?(c=k.jsx(ON,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:k.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-[var(--slate-1)] text-muted-foreground/80 flex flex-col overflow-y-auto",children:l})}),t[9]=l,t[10]=c):c=t[10],c}));function z_(e,t){const n=Yr(e);n&&yi(n,t)}function F_(){const e=b(7),t=PE(),n=AN(U_),o=AN(B_);let a;e[0]!==t?(a=()=>{t.fitView({duration:100})},e[0]=t,e[1]=a):a=e[1];const i=xi(a,100);let s,l;e[2]!==n||e[3]!==o||e[4]!==i?(s=()=>{n&&o&&i()},l=[n,o,i],e[2]=n,e[3]=o,e[4]=i,e[5]=s,e[6]=l):(s=e[5],l=e[6]),r.useEffect(s,l)}function B_(e){const{height:t}=e;return t}function U_(e){const{width:t}=e;return t}L_.displayName="GraphSelectionPanel";const V_=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:dC.Arrow},id:`${e}-${t}-${n}`,source:e,sourceHandle:n,targetHandle:n,target:t}}createNode(e,t,n){return{id:e,data:{atom:t},width:250,type:"custom",height:I_(te.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,o){let r=0;const a=[],i=[];for(const[l,c]of Ta.zip(e,t)){const e=this.createNode(l,c,r);a.push(e),r=e.position.y+(e.height||0)}const s=new Set;for(const l of Object.values(n)){const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;s.has(t)||(s.add(t),i.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:a,edges:i}}},H_=e=>{const t=b(37),{cellIds:n,variables:o,cellAtoms:a,children:i}=e;let s;t[0]!==n||t[1]!==a||t[2]!==o?(s=V_.createElements(n,a,o,!1),t[0]=n,t[1]=a,t[2]=o,t[3]=s):s=t[3];const{nodes:l,edges:c}=s;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=[],t[4]=d):d=t[4];const[u,h]=d_(d),[f,m]=c_(l),[p,g]=r.useState(),[v,y]=r.useState(),x=r.useRef(!1);F_();const w=AN($_);let S;t[5]!==m||t[6]!==h?(S=e=>{m(e.nodes),h([])},t[5]=m,t[6]=h,t[7]=S):S=t[7];const N=G(S);let C,E,j,_;t[8]!==N||t[9]!==n||t[10]!==a||t[11]!==o?(C=()=>{x.current?N(V_.createElements(n,a,o,!1)):x.current=!0},E=[n,o,a,N],t[8]=N,t[9]=n,t[10]=a,t[11]=o,t[12]=C,t[13]=E):(C=t[12],E=t[13]),r.useEffect(C,E),t[14]!==p||t[15]!==c||t[16]!==h?(j=()=>{if(p){const e=c.filter((e=>{const{source:t,target:n,data:o}=e;return t===p&&"outputs"===o.direction||n===p&&"inputs"===o.direction}));h(e)}},_=[p,h,c],t[14]=p,t[15]=c,t[16]=h,t[17]=j,t[18]=_):(j=t[17],_=t[18]),r.useEffect(j,_);const I=function(e,t){const n=b(17);let o,r;if(n[0]!==t||n[1]!==e){let o;n[3]!==t?(o=(e,n)=>{const{position:o}=n;return Math.min(e,o.y-t/2-10)},n[3]=t,n[4]=o):o=n[4],r=e.reduce(o,Number.POSITIVE_INFINITY),n[0]=t,n[1]=e,n[2]=r}else r=n[2];const a=r;let i;if(n[5]!==t||n[6]!==e){let o;n[8]!==t?(o=(e,n)=>{const{position:o}=n;return Math.max(e,o.y+t/2+10)},n[8]=t,n[9]=o):o=n[9],i=e.reduce(o,Number.NEGATIVE_INFINITY),n[5]=t,n[6]=e,n[7]=i}else i=n[7];const s=i;let l,c,d;n[10]!==a?(l=[Number.NEGATIVE_INFINITY,a],n[10]=a,n[11]=l):l=n[11];n[12]!==s?(c=[Number.POSITIVE_INFINITY,s],n[12]=s,n[13]=c):c=n[13];n[14]!==l||n[15]!==c?(d=[l,c],n[14]=l,n[15]=c,n[16]=d):d=n[16];return o=d,o}(f,w);let A;t[19]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{g(void 0),y(void 0)},t[19]=A):A=t[19];const T=A;let M;t[20]!==v||t[21]!==o||t[22]!==u||t[23]!==p?(M=()=>v?k.jsx(L_,{selection:{type:"edge",source:v.source,target:v.target},onClearSelection:T,variables:o,edges:u}):p?k.jsx(L_,{selection:{type:"node",id:p},variables:o,edges:u,onClearSelection:T}):null,t[20]=v,t[21]=o,t[22]=u,t[23]=p,t[24]=M):M=t[24];const O=M;let D,P,R,L;return t[25]!==h?(D=(e,t)=>{const n=t.id;g(n),y(void 0),h([])},t[25]=h,t[26]=D):D=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(P=(e,t)=>{y(t)},t[27]=P):P=t[27],t[28]!==O?(R=O(),t[28]=O,t[29]=R):R=t[29],t[30]!==f||t[31]!==u||t[32]!==I||t[33]!==D||t[34]!==R||t[35]!==i?(L=k.jsxs(s_,{nodes:f,edges:u,nodeTypes:M_,translateExtent:I,onNodeClick:D,onNodeDoubleClick:W_,onEdgeClick:P,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:rC.Vertical,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,selectNodesOnDrag:!1,panOnDrag:!1,preventScrolling:!1,zoomOnPinch:!1,panOnScroll:!0,autoPanOnNodeDrag:!1,autoPanOnConnect:!1,children:[R,i]}),t[30]=f,t[31]=u,t[32]=I,t[33]=D,t[34]=R,t[35]=i,t[36]=L):L=t[36],L};function $_(e){const{height:t}=e;return t}function W_(e,t){bi(t.id,"focus")}var G_="\0";function q_(e,t){e[t]?e[t]++:e[t]=1}function Y_(e,t){--e[t]||delete e[t]}function X_(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var i=r;r=a,a=i}return r+""+a+""+(void 0===o?"\0":o)}function K_(e,t){return X_(e,t.v,t.w,t.name)}var J_=class{constructor(e){n(this,"_isDirected",!0),n(this,"_isMultigraph",!1),n(this,"_isCompound",!1),n(this,"_label"),n(this,"_defaultNodeLabelFn",(()=>{})),n(this,"_defaultEdgeLabelFn",(()=>{})),n(this,"_nodes",{}),n(this,"_in",{}),n(this,"_preds",{}),n(this,"_out",{}),n(this,"_sucs",{}),n(this,"_edgeObjs",{}),n(this,"_edgeLabels",{}),n(this,"_nodeCount",0),n(this,"_edgeCount",0),n(this,"_parent"),n(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[G_]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var n=arguments,o=this;return e.forEach((function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=G_,this._children[e]={},this._children[G_][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=G_;else{for(var n=t+="";void 0!==n;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==G_)return t}}children(e=G_){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===G_)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const o=new Set(t);for(var n of this.successors(e))o.add(n);return Array.from(o.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach((function([n,o]){e(n)&&t.setNode(n,o)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};function r(e){var a=n.parent(e);return void 0===a||t.hasNode(a)?(o[e]=a,a):a in o?o[a]:r(a)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,r(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,o=arguments;return e.reduce((function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this}setEdge(){var e,t,n,o,r=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,t=a.w,n=a.name,2===arguments.length&&(o=arguments[1],r=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],r=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var i=X_(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,i))return r&&(this._edgeLabels[i]=o),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[i]=r?o:this._defaultEdgeLabelFn(e,t,n);var s=function(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var i=r;r=a,a=i}var s={v:r,w:a};o&&(s.name=o);return s}(this._isDirected,e,t,n);return e=s.v,t=s.w,Object.freeze(s),this._edgeObjs[i]=s,q_(this._preds[t],e),q_(this._sucs[e],t),this._in[t][i]=s,this._out[e][i]=s,this._edgeCount++,this}edge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,o)}removeEdge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n),r=this._edgeObjs[o];return r&&(e=r.v,t=r.w,delete this._edgeLabels[o],delete this._edgeObjs[o],Y_(this._preds[t],e),Y_(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.v===t)):o}}outEdges(e,t){var n=this._out[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.w===t)):o}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},Z_={Graph:J_,version:"2.2.4"},Q_=J_,eI={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:tI(e),edges:nI(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new Q_(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function tI(e){return e.nodes().map((function(t){var n=e.node(t),o=e.parent(t),r={v:t};return void 0!==n&&(r.value=n),void 0!==o&&(r.parent=o),r}))}function nI(e){return e.edges().map((function(t){var n=e.edge(t),o={v:t.v,w:t.w};return void 0!==t.name&&(o.name=t.name),void 0!==n&&(o.value=n),o}))}var oI=function(e){var t,n={},o=[];function r(o){Object.hasOwn(n,o)||(n[o]=!0,t.push(o),e.successors(o).forEach(r),e.predecessors(o).forEach(r))}return e.nodes().forEach((function(e){t=[],r(e),t.length&&o.push(t)})),o};var rI=class{constructor(){n(this,"_arr",[]),n(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var o=this._arr,r=o.length;return n[e]=r,o.push({key:e,priority:t}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){for(var t,n=this._arr,o=n[e].priority;0!==e&&!(n[t=e>>1].priority<o);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,o=this._keyIndices,r=n[e],a=n[t];n[e]=a,n[t]=r,o[a.key]=e,o[r.key]=t}},aI=rI,iI=function(e,t,n,o){return function(e,t,n,o){var r,a,i={},s=new aI,l=function(e){var t=e.v!==r?e.v:e.w,o=i[t],l=n(e),c=a.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);c<o.distance&&(o.distance=c,o.predecessor=r,s.decrease(t,c))};e.nodes().forEach((function(e){var n=e===t?0:Number.POSITIVE_INFINITY;i[e]={distance:n},s.add(e,n)}));for(;s.size()>0&&(r=s.removeMin(),(a=i[r]).distance!==Number.POSITIVE_INFINITY);)o(r).forEach(l);return i}(e,String(t),n||sI,o||function(t){return e.outEdges(t)})},sI=()=>1;var lI=iI,cI=function(e,t,n){return e.nodes().reduce((function(o,r){return o[r]=lI(e,r,t,n),o}),{})};var dI=function(e){var t=0,n=[],o={},r=[];function a(i){var s=o[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach((function(e){Object.hasOwn(o,e)?o[e].onStack&&(s.lowlink=Math.min(s.lowlink,o[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,o[e].lowlink))})),s.lowlink===s.index){var l,c=[];do{l=n.pop(),o[l].onStack=!1,c.push(l)}while(i!==l);r.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(o,e)||a(e)})),r};var uI=dI,hI=function(e){return uI(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var fI=function(e,t,n){return function(e,t,n){var o={},r=e.nodes();return r.forEach((function(e){o[e]={},o[e][e]={distance:0},r.forEach((function(t){e!==t&&(o[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var r=n.v===e?n.w:n.v,a=t(n);o[e][r]={distance:a,predecessor:e}}))})),r.forEach((function(e){var t=o[e];r.forEach((function(n){var a=o[n];r.forEach((function(n){var o=a[e],r=t[n],i=a[n],s=o.distance+r.distance;s<i.distance&&(i.distance=s,i.predecessor=r.predecessor)}))}))})),o}(e,t||mI,n||function(t){return e.outEdges(t)})},mI=()=>1;function pI(e){var t={},n={},o=[];if(e.sinks().forEach((function r(a){if(Object.hasOwn(n,a))throw new gI;Object.hasOwn(t,a)||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(r),delete n[a],o.push(a))})),Object.keys(t).length!==e.nodeCount())throw new gI;return o}class gI extends Error{constructor(){super(...arguments)}}var vI=pI;pI.CycleException=gI;var yI=vI;var xI=function(e,t,n){Array.isArray(t)||(t=[t]);var o=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),r="post"===n?bI:wI,a=[],i={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);r(t,o,i,a)})),a};function bI(e,t,n,o){for(var r=[[e,!1]];r.length>0;){var a=r.pop();a[1]?o.push(a[0]):Object.hasOwn(n,a[0])||(n[a[0]]=!0,r.push([a[0],!0]),kI(t(a[0]),(e=>r.push([e,!1]))))}}function wI(e,t,n,o){for(var r=[e];r.length>0;){var a=r.pop();Object.hasOwn(n,a)||(n[a]=!0,o.push(a),kI(t(a),(e=>r.push(e))))}}function kI(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var SI=xI;var NI=xI;var CI=J_,EI=rI;var jI={Graph:Z_.Graph,json:eI,alg:{components:oI,dijkstra:iI,dijkstraAll:cI,findCycles:hI,floydWarshall:fI,isAcyclic:function(e){try{yI(e)}catch(t){if(t instanceof yI.CycleException)return!1;throw t}return!0},postorder:function(e,t){return SI(e,t,"post")},preorder:function(e,t){return NI(e,t,"pre")},prim:function(e,t){var n,o=new CI,r={},a=new EI;function i(e){var o=e.v===n?e.w:e.v,i=a.priority(o);if(void 0!==i){var s=t(e);s<i&&(r[o]=n,a.decrease(o,s))}}if(0===e.nodeCount())return o;e.nodes().forEach((function(e){a.add(e,Number.POSITIVE_INFINITY),o.setNode(e)})),a.decrease(e.nodes()[0],0);var s=!1;for(;a.size()>0;){if(n=a.removeMin(),Object.hasOwn(r,n))o.setEdge(n,r[n]);else{if(s)throw new Error("Input graph is not connected: "+e);s=!0}e.nodeEdges(n).forEach(i)}return o},tarjan:dI,topsort:vI},version:Z_.version};function _I(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function II(e,t){if("_next"!==e&&"_prev"!==e)return t}let AI=jI.Graph,TI=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return _I(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&_I(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,II)),n=n._prev;return"["+e.join(", ")+"]"}};var MI=function(e,t){if(e.nodeCount()<=1)return[];let n=function(e,t){let n=new AI,o=0,r=0;e.nodes().forEach((e=>{n.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let a=n.edge(e.v,e.w)||0,i=t(e),s=a+i;n.setEdge(e.v,e.w,s),r=Math.max(r,n.node(e.v).out+=i),o=Math.max(o,n.node(e.w).in+=i)}));let a=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(r+o+3).map((()=>new TI)),i=o+1;return n.nodes().forEach((e=>{PI(a,i,n.node(e))})),{graph:n,buckets:a,zeroIdx:i}}(e,t||OI);return function(e,t,n){let o,r=[],a=t[t.length-1],i=t[0];for(;e.nodeCount();){for(;o=i.dequeue();)DI(e,t,n,o);for(;o=a.dequeue();)DI(e,t,n,o);if(e.nodeCount())for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(DI(e,t,n,o,!0));break}}return r}(n.graph,n.buckets,n.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let OI=()=>1;function DI(e,t,n,o,r){let a=r?[]:void 0;return e.inEdges(o.v).forEach((o=>{let i=e.edge(o),s=e.node(o.v);r&&a.push({v:o.v,w:o.w}),s.out-=i,PI(t,n,s)})),e.outEdges(o.v).forEach((o=>{let r=e.edge(o),a=o.w,i=e.node(a);i.in-=r,PI(t,n,i)})),e.removeNode(o.v),a}function PI(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}let RI=jI.Graph;var LI={addBorderNode:function(e,t,n,o){let r={width:0,height:0};arguments.length>=4&&(r.rank=n,r.order=o);return zI(e,"border",r,t)},addDummyNode:zI,applyWithChunking:BI,asNonCompoundGraph:function(e){let t=new RI({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((n=>{e.children(n).length||t.setNode(n,e.node(n))})),e.edges().forEach((n=>{t.setEdge(n,e.edge(n))})),t},buildLayerMatrix:function(e){let t=$I(UI(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let o=e.node(n),r=o.rank;void 0!==r&&(t[r][o.order]=n)})),t},intersectRect:function(e,t){let n,o,r=e.x,a=e.y,i=t.x-r,s=t.y-a,l=e.width/2,c=e.height/2;if(!i&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(i)*c?(s<0&&(c=-c),n=c*i/s,o=c):(i<0&&(l=-l),n=l,o=l*s/i);return{x:r+n,y:a+o}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,o])=>(e[t]=n(o,t),e)),{})},maxRank:UI,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=BI(Math.min,t);e.nodes().forEach((t=>{let o=e.node(t);Object.hasOwn(o,"rank")&&(o.rank-=n)}))},notime:function(e,t){return t()},partition:function(e,t){let n={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?n.lhs.push(e):n.rhs.push(e)})),n},pick:function(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n},predecessorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.inEdges(t).forEach((t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight})),n}));return WI(e.nodes(),t)},range:$I,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=BI(Math.min,t),o=[];e.nodes().forEach((t=>{let r=e.node(t).rank-n;o[r]||(o[r]=[]),o[r].push(t)}));let r=0,a=e.graph().nodeRankFactor;Array.from(o).forEach(((t,n)=>{void 0===t&&n%a!=0?--r:void 0!==t&&r&&t.forEach((t=>e.node(t).rank+=r))}))},simplify:function(e){let t=(new RI).setGraph(e.graph());return e.nodes().forEach((n=>t.setNode(n,e.node(n)))),e.edges().forEach((n=>{let o=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:o.weight+r.weight,minlen:Math.max(o.minlen,r.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.outEdges(t).forEach((t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight})),n}));return WI(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:HI,zipObject:WI};function zI(e,t,n,o){let r;do{r=HI(o)}while(e.hasNode(r));return n.dummy=t,e.setNode(r,n),r}const FI=65535;function BI(e,t){if(t.length>FI){const n=function(e,t=FI){const n=[];for(let o=0;o<e.length;o+=t){const r=e.slice(o,o+t);n.push(r)}return n}(t);return e.apply(null,n.map((t=>e.apply(null,t))))}return e.apply(null,t)}function UI(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return BI(Math.max,t)}let VI=0;function HI(e){var t=++VI;return toString(e)+t}function $I(e,t,n=1){null==t&&(t=e,e=0);let o=e=>e<t;n<0&&(o=e=>t<e);const r=[];for(let a=e;o(a);a+=n)r.push(a);return r}function WI(e,t){return e.reduce(((e,n,o)=>(e[n]=t[o],e)),{})}let GI=MI,qI=LI.uniqueId;var YI={run:function(e){("greedy"===e.graph().acyclicer?GI(e,(t=e,e=>t.edge(e).weight)):function(e){let t=[],n={},o={};function r(a){Object.hasOwn(o,a)||(o[a]=!0,n[a]=!0,e.outEdges(a).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):r(e.w)})),delete n[a])}return e.nodes().forEach(r),t}(e)).forEach((t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,qI("rev"))}));var t},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}}))}};let XI=LI;var KI={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let n,o,r,a=t.v,i=e.node(a).rank,s=t.w,l=e.node(s).rank,c=t.name,d=e.edge(t),u=d.labelRank;if(l===i+1)return;for(e.removeEdge(t),r=0,++i;i<l;++r,++i)d.points=[],o={width:0,height:0,edgeLabel:d,edgeObj:t,rank:i},n=XI.addDummyNode(e,"edge",o,"_d"),i===u&&(o.width=d.width,o.height=d.height,o.dummy="edge-label",o.labelpos=d.labelpos),e.setEdge(a,n,{weight:d.weight},c),0===r&&e.graph().dummyChains.push(n),a=n;e.setEdge(a,s,{weight:d.weight},c)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,o=e.node(t),r=o.edgeLabel;for(e.setEdge(o.edgeObj,r);o.dummy;)n=e.successors(t)[0],e.removeNode(t),r.points.push({x:o.x,y:o.y}),"edge-label"===o.dummy&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),t=n,o=e.node(t)}))}};const{applyWithChunking:JI}=LI;var ZI={longestPath:function(e){var t={};e.sources().forEach((function n(o){var r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let a=e.outEdges(o).map((t=>null==t?Number.POSITIVE_INFINITY:n(t.w)-e.edge(t).minlen));var i=JI(Math.min,a);return i===Number.POSITIVE_INFINITY&&(i=0),r.rank=i}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var QI=jI.Graph,eA=ZI.slack,tA=function(e){var t,n,o=new QI({directed:!1}),r=e.nodes()[0],a=e.nodeCount();o.setNode(r,{});for(;nA(o,e)<a;)t=oA(o,e),n=o.hasNode(t.v)?eA(e,t):-eA(e,t),rA(o,e,n);return o};function nA(e,t){return e.nodes().forEach((function n(o){t.nodeEdges(o).forEach((r=>{var a=r.v,i=o===a?r.w:a;e.hasNode(i)||eA(t,r)||(e.setNode(i,{}),e.setEdge(o,i,{}),n(i))}))})),e.nodeCount()}function oA(e,t){return t.edges().reduce(((n,o)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(r=eA(t,o)),r<n[0]?[r,o]:n}),[Number.POSITIVE_INFINITY,null])[1]}function rA(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}var aA=tA,iA=ZI.slack,sA=ZI.longestPath,lA=jI.alg.preorder,cA=jI.alg.postorder,dA=LI.simplify,uA=hA;function hA(e){e=dA(e),sA(e);var t,n=aA(e);for(pA(n),fA(n,e);t=vA(n);)xA(n,e,t,yA(n,e,t))}function fA(e,t){var n=cA(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var o=e.node(n),r=o.parent;e.edge(n,r).cutvalue=mA(e,t,n)}(e,t,n)))}function mA(e,t,n){var o=e.node(n).parent,r=!0,a=t.edge(n,o),i=0;return a||(r=!1,a=t.edge(o,n)),i=a.weight,t.nodeEdges(n).forEach((a=>{var s,l,c=a.v===n,d=c?a.w:a.v;if(d!==o){var u=c===r,h=t.edge(a).weight;if(i+=u?h:-h,s=n,l=d,e.hasEdge(s,l)){var f=e.edge(n,d).cutvalue;i+=u?-f:f}}})),i}function pA(e,t){arguments.length<2&&(t=e.nodes()[0]),gA(e,{},1,t)}function gA(e,t,n,o,r){var a=n,i=e.node(o);return t[o]=!0,e.neighbors(o).forEach((r=>{Object.hasOwn(t,r)||(n=gA(e,t,n,r,o))})),i.low=a,i.lim=n++,r?i.parent=r:delete i.parent,n}function vA(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function yA(e,t,n){var o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);var a=e.node(o),i=e.node(r),s=a,l=!1;return a.lim>i.lim&&(s=i,l=!0),t.edges().filter((t=>l===bA(e,e.node(t.v),s)&&l!==bA(e,e.node(t.w),s))).reduce(((e,n)=>iA(t,n)<iA(t,e)?n:e))}function xA(e,t,n,o){var r=n.v,a=n.w;e.removeEdge(r,a),e.setEdge(o.v,o.w,{}),pA(e),fA(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),o=lA(e,n);(o=o.slice(1)).forEach((n=>{var o=e.node(n).parent,r=t.edge(n,o),a=!1;r||(r=t.edge(o,n),a=!0),t.node(n).rank=t.node(o).rank+(a?r.minlen:-r.minlen)}))}(e,t)}function bA(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}hA.initLowLimValues=pA,hA.initCutValues=fA,hA.calcCutValue=mA,hA.leaveEdge=vA,hA.enterEdge=yA,hA.exchangeEdges=xA;var wA=ZI.longestPath,kA=tA,SA=uA,NA=function(e){switch(e.graph().ranker){case"network-simplex":default:EA(e);break;case"tight-tree":!function(e){wA(e),kA(e)}(e);break;case"longest-path":CA(e)}};var CA=wA;function EA(e){SA(e)}let jA=LI;function _A(e,t,n,o,r,a,i){let s=e.children(i);if(!s.length)return void(i!==t&&e.setEdge(t,i,{weight:0,minlen:n}));let l=jA.addBorderNode(e,"_bt"),c=jA.addBorderNode(e,"_bb"),d=e.node(i);e.setParent(l,i),d.borderTop=l,e.setParent(c,i),d.borderBottom=c,s.forEach((s=>{_A(e,t,n,o,r,a,s);let d=e.node(s),u=d.borderTop?d.borderTop:s,h=d.borderBottom?d.borderBottom:s,f=d.borderTop?o:2*o,m=u!==h?1:r-a[i]+1;e.setEdge(l,u,{weight:f,minlen:m,nestingEdge:!0}),e.setEdge(h,c,{weight:f,minlen:m,nestingEdge:!0})})),e.parent(i)||e.setEdge(t,l,{weight:0,minlen:r+a[i]})}let IA=LI;function AA(e,t,n,o,r,a){let i={width:0,height:0,rank:a,borderType:t},s=r[t][a-1],l=IA.addDummyNode(e,"border",i,n);r[t][a]=l,e.setParent(l,o),s&&e.setEdge(s,l,{weight:1})}function TA(e){e.nodes().forEach((t=>MA(e.node(t)))),e.edges().forEach((t=>MA(e.edge(t))))}function MA(e){let t=e.width;e.width=e.height,e.height=t}function OA(e){e.y=-e.y}function DA(e){let t=e.x;e.x=e.y,e.y=t}let PA=LI;let RA=LI.zipObject;function LA(e,t,n){let o=RA(n,n.map(((e,t)=>t))),r=t.flatMap((t=>e.outEdges(t).map((t=>({pos:o[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),a=1;for(;a<n.length;)a<<=1;let i=2*a-1;a-=1;let s=new Array(i).fill(0),l=0;return r.forEach((e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;l+=e.weight*n})),l}let zA=LI;let FA=LI;function BA(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}let UA=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let o=n.reduce(((t,n)=>{let o=e.edge(n),r=e.node(n.v);return{sum:t.sum+o.weight*r.order,weight:t.weight+o.weight}}),{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}return{v:t}}))},VA=function(e,t){let n={};return e.forEach(((e,t)=>{let o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(o.barycenter=e.barycenter,o.weight=e.weight)})),t.edges().forEach((e=>{let t=n[e.v],o=n[e.w];void 0!==t&&void 0!==o&&(o.indegree++,t.out.push(n[e.w]))})),function(e){let t=[];function n(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight);t.weight&&(n+=t.barycenter*t.weight,o+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function o(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(o(r))}return t.filter((e=>!e.merged)).map((e=>zA.pick(e,["vs","i","barycenter","weight"])))}(Object.values(n).filter((e=>!e.indegree)))},HA=function(e,t){let n=FA.partition(e,(e=>Object.hasOwn(e,"barycenter"))),o=n.lhs,r=n.rhs.sort(((e,t)=>t.i-e.i)),a=[],i=0,s=0,l=0;o.sort((c=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:c?t.i-e.i:e.i-t.i)),l=BA(a,r,l),o.forEach((e=>{l+=e.vs.length,a.push(e.vs),i+=e.barycenter*e.weight,s+=e.weight,l=BA(a,r,l)}));var c;let d={vs:a.flat(!0)};s&&(d.barycenter=i/s,d.weight=s);return d};var $A=function e(t,n,o,r){let a=t.children(n),i=t.node(n),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,c={};s&&(a=a.filter((e=>e!==s&&e!==l)));let d=UA(t,a);d.forEach((n=>{if(t.children(n.v).length){let s=e(t,n.v,o,r);c[n.v]=s,Object.hasOwn(s,"barycenter")&&(i=s,void 0!==(a=n).barycenter?(a.barycenter=(a.barycenter*a.weight+i.barycenter*i.weight)/(a.weight+i.weight),a.weight+=i.weight):(a.barycenter=i.barycenter,a.weight=i.weight))}var a,i}));let u=VA(d,o);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(u,c);let h=HA(u,r);if(s&&(h.vs=[s,h.vs,l].flat(!0),t.predecessors(s).length)){let e=t.node(t.predecessors(s)[0]),n=t.node(t.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+e.order+n.order)/(h.weight+2),h.weight+=2}return h};let WA=jI.Graph,GA=LI;let qA=function(e){let t={},n=e.nodes().filter((t=>!e.children(t).length)),o=n.map((t=>e.node(t).rank)),r=PA.applyWithChunking(Math.max,o),a=PA.range(r+1).map((()=>[]));return n.sort(((t,n)=>e.node(t).rank-e.node(n).rank)).forEach((function n(o){if(t[o])return;t[o]=!0;let r=e.node(o);a[r.rank].push(o),e.successors(o).forEach(n)})),a},YA=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=LA(e,t[o-1],t[o]);return n},XA=$A,KA=function(e,t,n){let o=function(e){var t;for(;e.hasNode(t=GA.uniqueId("_root")););return t}(e),r=new WA({compound:!0}).setGraph({root:o}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((a=>{let i=e.node(a),s=e.parent(a);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(r.setNode(a),r.setParent(a,s||o),e[n](a).forEach((t=>{let n=t.v===a?t.w:t.v,o=r.edge(n,a),i=void 0!==o?o.weight:0;r.setEdge(n,a,{weight:e.edge(t).weight+i})})),Object.hasOwn(i,"minRank")&&r.setNode(a,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))})),r},JA=function(e,t,n){let o,r={};n.forEach((n=>{let a,i,s=e.parent(n);for(;s;){if(a=e.parent(s),a?(i=r[a],r[a]=s):(i=o,o=s),i&&i!==s)return void t.setEdge(i,s);s=a}}))},ZA=jI.Graph,QA=LI;var eT=function e(t,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(t,e);let o=QA.maxRank(t),r=tT(t,QA.range(1,o+1),"inEdges"),a=tT(t,QA.range(o-1,-1,-1),"outEdges"),i=qA(t);if(oT(t,i),n&&n.disableOptimalOrderHeuristic)return;let s,l=Number.POSITIVE_INFINITY;for(let c=0,d=0;d<4;++c,++d){nT(c%2?r:a,c%4>=2),i=QA.buildLayerMatrix(t);let e=YA(t,i);e<l&&(d=0,s=Object.assign({},i),l=e)}oT(t,s)};function tT(e,t,n){return t.map((function(t){return KA(e,t,n)}))}function nT(e,t){let n=new ZA;e.forEach((function(e){let o=e.graph().root,r=XA(e,o,n,t);r.vs.forEach(((t,n)=>e.node(t).order=n)),JA(e,n,r.vs)}))}function oT(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}let rT=jI.Graph,aT=LI;var iT=function(e){let t,n=aT.buildLayerMatrix(e),o=Object.assign(sT(e,n),lT(e,n)),r={};["u","d"].forEach((a=>{t="u"===a?n:Object.values(n).reverse(),["l","r"].forEach((n=>{"r"===n&&(t=t.map((e=>Object.values(e).reverse())));let i=("u"===a?e.predecessors:e.successors).bind(e),s=uT(e,t,o,i),l=hT(e,t,s.root,s.align,"r"===n);"r"===n&&(l=aT.mapValues(l,(e=>-e))),r[a+n]=l}))}));let a=fT(e,r);return mT(r,a),pT(r,e.graph().align)};function sT(e,t){let n={};return t.length&&t.reduce((function(t,o){let r=0,a=0,i=t.length,s=o[o.length-1];return o.forEach(((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),d=c?e.node(c).order:i;(c||t===s)&&(o.slice(a,l+1).forEach((t=>{e.predecessors(t).forEach((o=>{let a=e.node(o),i=a.order;!(i<r||d<i)||a.dummy&&e.node(t).dummy||cT(n,o,t)}))})),a=l+1,r=d)})),o})),n}function lT(e,t){let n={};function o(t,o,r,a,i){let s;aT.range(o,r).forEach((o=>{s=t[o],e.node(s).dummy&&e.predecessors(s).forEach((t=>{let o=e.node(t);o.dummy&&(o.order<a||o.order>i)&&cT(n,t,s)}))}))}return t.length&&t.reduce((function(t,n){let r,a=-1,i=0;return n.forEach(((s,l)=>{if("border"===e.node(s).dummy){let t=e.predecessors(s);t.length&&(r=e.node(t[0]).order,o(n,i,l,a,r),i=l,a=r)}o(n,i,n.length,r,t.length)})),n})),n}function cT(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];o||(e[t]=o={}),o[n]=!0}function dT(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function uT(e,t,n,o){let r={},a={},i={};return t.forEach((e=>{e.forEach(((e,t)=>{r[e]=e,a[e]=e,i[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let s=o(e);if(s.length){s=s.sort(((e,t)=>i[e]-i[t]));let o=(s.length-1)/2;for(let l=Math.floor(o),c=Math.ceil(o);l<=c;++l){let o=s[l];a[e]===e&&t<i[o]&&!dT(n,e,o)&&(a[o]=e,a[e]=r[e]=r[o],t=i[o])}}}))})),{root:r,align:a}}function hT(e,t,n,o,r){let a={},i=function(e,t,n,o){let r=new rT,a=e.graph(),i=function(e,t,n){return(o,r,a)=>{let i,s=o.node(r),l=o.node(a),c=0;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":i=-s.width/2;break;case"r":i=s.width/2}if(i&&(c+=n?i:-i),i=0,c+=(s.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":i=l.width/2;break;case"r":i=-l.width/2}return i&&(c+=n?i:-i),i=0,c}}(a.nodesep,a.edgesep,o);return t.forEach((t=>{let o;t.forEach((t=>{let a=n[t];if(r.setNode(a),o){var s=n[o],l=r.edge(s,a);r.setEdge(s,a,Math.max(i(e,t,o),l||0))}o=t}))})),r}(e,t,n,r),s=r?"borderLeft":"borderRight";function l(e,t){let n=i.nodes(),o=n.pop(),r={};for(;o;)r[o]?e(o):(r[o]=!0,n.push(o),n=n.concat(t(o))),o=n.pop()}return l((function(e){a[e]=i.inEdges(e).reduce(((e,t)=>Math.max(e,a[t.v]+i.edge(t))),0)}),i.predecessors.bind(i)),l((function(t){let n=i.outEdges(t).reduce(((e,t)=>Math.min(e,a[t.w]-i.edge(t))),Number.POSITIVE_INFINITY),o=e.node(t);n!==Number.POSITIVE_INFINITY&&o.borderType!==s&&(a[t]=Math.max(a[t],n))}),i.successors.bind(i)),Object.keys(o).forEach((e=>a[e]=a[n[e]])),a}function fT(e,t){return Object.values(t).reduce(((t,n)=>{let o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let a=function(e,t){return e.node(t).width}(e,t)/2;o=Math.max(n+a,o),r=Math.min(n-a,r)}));const a=o-r;return a<t[0]&&(t=[a,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function mT(e,t){let n=Object.values(t),o=aT.applyWithChunking(Math.min,n),r=aT.applyWithChunking(Math.max,n);["u","d"].forEach((n=>{["l","r"].forEach((a=>{let i=n+a,s=e[i];if(s===t)return;let l=Object.values(s),c=o-aT.applyWithChunking(Math.min,l);"l"!==a&&(c=r-aT.applyWithChunking(Math.max,l)),c&&(e[i]=aT.mapValues(s,(e=>e+c)))}))}))}function pT(e,t){return aT.mapValues(e.ul,((n,o)=>{if(t)return e[t.toLowerCase()][o];{let t=Object.values(e).map((e=>e[o])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let gT=LI,vT=iT;let yT=YI,xT=KI,bT=NA,wT=LI.normalizeRanks,kT=function(e){let t=function(e){let t={},n=0;function o(r){let a=n;e.children(r).forEach(o),t[r]={low:a,lim:n++}}return e.children().forEach(o),t}(e);e.graph().dummyChains.forEach((n=>{let o=e.node(n),r=o.edgeObj,a=function(e,t,n,o){let r,a,i=[],s=[],l=Math.min(t[n].low,t[o].low),c=Math.max(t[n].lim,t[o].lim);r=n;do{r=e.parent(r),i.push(r)}while(r&&(t[r].low>l||c>t[r].lim));a=r,r=o;for(;(r=e.parent(r))!==a;)s.push(r);return{path:i.concat(s.reverse()),lca:a}}(e,t,r.v,r.w),i=a.path,s=a.lca,l=0,c=i[l],d=!0;for(;n!==r.w;){if(o=e.node(n),d){for(;(c=i[l])!==s&&e.node(c).maxRank<o.rank;)l++;c===s&&(d=!1)}if(!d){for(;l<i.length-1&&e.node(c=i[l+1]).minRank<=o.rank;)l++;c=i[l]}e.setParent(n,c),n=e.successors(n)[0]}}))},ST=LI.removeEmptyRanks,NT={run:function(e){let t=jA.addDummyNode(e,"root",{},"_root"),n=function(e){var t={};function n(o,r){var a=e.children(o);a&&a.length&&a.forEach((e=>n(e,r+1))),t[o]=r}return e.children().forEach((e=>n(e,1))),t}(e),o=Object.values(n),r=jA.applyWithChunking(Math.max,o)-1,a=2*r+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=a));let i=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(e)+1;e.children().forEach((o=>_A(e,t,a,i,r,n,o))),e.graph().nodeRankFactor=a},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}},CT=function(e){e.children().forEach((function t(n){let o=e.children(n),r=e.node(n);if(o.length&&o.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let t=r.minRank,o=r.maxRank+1;t<o;++t)AA(e,"borderLeft","_bl",n,r,t),AA(e,"borderRight","_br",n,r,t)}}))},ET={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||TA(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>OA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(OA),Object.hasOwn(n,"y")&&OA(n)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>DA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(DA),Object.hasOwn(n,"x")&&DA(n)}))}(e),TA(e))}},jT=eT,_T=function(e){(function(e){let t=gT.buildLayerMatrix(e),n=e.graph().ranksep,o=0;t.forEach((t=>{const r=t.reduce(((t,n)=>{const o=e.node(n).height;return t>o?t:o}),0);t.forEach((t=>e.node(t).y=o+r/2)),o+=r+n}))})(e=gT.asNonCompoundGraph(e)),Object.entries(vT(e)).forEach((([t,n])=>e.node(t).x=n))},IT=LI,AT=jI.Graph;var TT=function(e,t){let n=t&&t.debugTiming?IT.time:IT.notime;n("layout",(()=>{let o=n(" buildLayoutGraph",(()=>function(e){let t=new AT({multigraph:!0,compound:!0}),n=UT(e.graph());return t.setGraph(Object.assign({},OT,BT(n,MT),IT.pick(n,DT))),e.nodes().forEach((n=>{const o=BT(UT(e.node(n)),PT);Object.keys(RT).forEach((e=>{void 0===o[e]&&(o[e]=RT[e])})),t.setNode(n,o),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let o=UT(e.edge(n));t.setEdge(n,Object.assign({},zT,BT(o,LT),IT.pick(o,FT)))})),t}(e)));n(" runLayout",(()=>function(e,t,n){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let o=e.edge(n);o.minlen*=2,"c"!==o.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?o.width+=o.labeloffset:o.height+=o.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>yT.run(e))),t(" nestingGraph.run",(()=>NT.run(e))),t(" rank",(()=>bT(IT.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};IT.addDummyNode(e,"edge-proxy",o,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>ST(e))),t(" nestingGraph.cleanup",(()=>NT.cleanup(e))),t(" normalizeRanks",(()=>wT(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,t=Math.max(t,o.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>xT.run(e))),t(" parentDummyChains",(()=>kT(e))),t(" addBorderSegments",(()=>CT(e))),t(" order",(()=>jT(e,n))),t(" insertSelfEdges",(()=>function(e){var t=IT.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,o)=>{var r=e.node(t);r.order=o+n,(r.selfEdges||[]).forEach((t=>{IT.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:r.rank,order:o+ ++n,e:t.e,label:t.label},"_se")})),delete r.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>ET.adjust(e))),t(" position",(()=>_T(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var o=e.node(n.e.v),r=o.x+o.width/2,a=o.y,i=n.x-r,s=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:r+2*i/3,y:a-s},{x:r+5*i/6,y:a-s},{x:r+i,y:a},{x:r+5*i/6,y:a+s},{x:r+2*i/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),o=e.node(n.borderTop),r=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-a.x),n.height=Math.abs(r.y-o.y),n.x=a.x+n.width/2,n.y=o.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>xT.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>ET.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,r=0,a=e.graph(),i=a.marginx||0,s=a.marginy||0;function l(e){let a=e.x,i=e.y,s=e.width,l=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),o=Math.min(o,i-l/2),r=Math.max(r,i+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)})),t-=i,o-=s,e.nodes().forEach((n=>{let r=e.node(n);r.x-=t,r.y-=o})),e.edges().forEach((n=>{let r=e.edge(n);r.points.forEach((e=>{e.x-=t,e.y-=o})),Object.hasOwn(r,"x")&&(r.x-=t),Object.hasOwn(r,"y")&&(r.y-=o)})),a.width=n-t+i,a.height=r-o+s}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,o,r=e.edge(t),a=e.node(t.v),i=e.node(t.w);r.points?(n=r.points[0],o=r.points[r.points.length-1]):(r.points=[],n=i,o=a),r.points.unshift(IT.intersectRect(a,n)),r.points.push(IT.intersectRect(i,o))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(e))),t(" acyclic.undo",(()=>yT.undo(e)))}(o,n,t))),n(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))})),e.edges().forEach((n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,o)))}))};let MT=["nodesep","edgesep","ranksep","marginx","marginy"],OT={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},DT=["acyclicer","ranker","rankdir","align"],PT=["width","height"],RT={width:0,height:0},LT=["minlen","weight","width","height","labeloffset"],zT={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FT=["labelpos"];function BT(e,t){return IT.mapValues(IT.pick(e,t),Number)}function UT(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}let VT=LI,HT=jI.Graph;var $T={graphlib:jI,layout:TT,debug:{debugOrdering:function(e){let t=VT.buildLayerMatrix(e),n=new HT({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{n.setNode(t,{label:t}),n.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>n.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let o="layer"+t;n.setNode(o,{rank:"same"}),e.reduce(((e,t)=>(n.setEdge(e,t,{style:"invis"}),t)))})),n}},util:{time:LI.time,notime:LI.notime},version:"1.1.4"};const WT=(new $T.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),GT=(e,t,n)=>(WT.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>WT.setEdge(e.source,e.target))),e.forEach((e=>WT.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),$T.layout(WT),{nodes:e.map((e=>{const{x:t,y:n}=WT.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),qT=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:dC.ArrowClosed},id:`${e}-${t}`,style:{strokeWidth:2},source:e,sourceHandle:"outputs",targetHandle:"inputs",target:t}}createNode(e,t){return{id:e,data:{atom:t,forceWidth:300},width:300,type:"custom",height:I_(te.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,o){const r=[],a=[],i=new Set,s=new Set;for(const l of Object.values(n)){if("marimo"===l.value&&"mo"===l.name)continue;const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;s.has(t)||(s.add(t),i.add(n),i.add(e),a.push(this.createEdge(n,e)))}}for(const[l,c]of Ta.zip(e,t)){o||r.push(this.createNode(l,c));const e=i.has(l),t=te.get(c).code.trim().startsWith("mo.md");!e&&t||r.push(this.createNode(l,c))}return{nodes:r,edges:a}}},YT=({cellIds:e,variables:t,cellAtoms:n,children:o,layoutDirection:a,settings:i})=>{const s=r.useMemo((()=>{let o=qT.createElements(e,n,t,i.hidePureMarkdown);return o=GT(o.nodes,o.edges,{direction:a}),o}),[]),[l,c,d]=c_(s.nodes),[u,h,f]=d_(s.edges),m=PE(),p=G((e=>{const t=GT(e.nodes,e.edges,{direction:a});c(t.nodes),h(t.edges)}));r.useEffect((()=>{p(qT.createElements(e,n,t,i.hidePureMarkdown))}),[e,t,n,p,i.hidePureMarkdown]);const[g,v]=r.useState();F_();return k.jsx(A_.Provider,{value:a,children:k.jsxs(s_,{nodes:l,edges:u,nodeTypes:M_,minZoom:.2,fitViewOptions:{minZoom:.5,maxZoom:1.5},onNodeClick:(e,t)=>{v({type:"node",id:t.id})},onEdgeClick:(e,t)=>{const{source:n,target:o}=t;v({type:"edge",source:n,target:o})},onNodeDoubleClick:(e,t)=>{bi(t.id,"focus")},fitView:!0,onNodesChange:d,onEdgesChange:f,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[k.jsx(__,{color:"#ccc",variant:x_.Dots}),k.jsx(w_,{position:"bottom-right",showInteractive:!1,children:k.jsx(N,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:k.jsx(g_,{onMouseDown:tt.preventFocus,onClick:()=>{const e=te.get(Pd);if(e){const t=l.find((t=>t.id===e));t&&(m.fitView({padding:1,duration:600,nodes:[t]}),v({type:"node",id:e}))}},children:k.jsx(xc,{className:"size-4"})})})}),k.jsx(L_,{selection:g,variables:t,edges:u,onClearSelection:()=>{v(void 0)}}),o]})})},XT=Z("_minimap_"),KT=Z({hidePureMarkdown:!0}),JT=e=>{const t=b(11),[n,o]=Le(XT),[r,a]=Le(KT);let i;t[0]!==n||t[1]!==e||t[2]!==r||t[3]!==a||t[4]!==o?(i=()=>"_minimap_"===n?k.jsx(H_,{...e,children:k.jsx(R_,{settings:r,onSettingsChange:a,view:n,onChange:o})}):k.jsx(YT,{...e,settings:r,layoutDirection:n,children:k.jsx(R_,{settings:r,onSettingsChange:a,view:n,onChange:o})}),t[0]=n,t[1]=e,t[2]=r,t[3]=a,t[4]=o,t[5]=i):i=t[5];const s=i;let l,c;return t[6]!==s?(l=s(),t[6]=s,t[7]=l):l=t[7],t[8]!==n||t[9]!==l?(c=k.jsx(Qj,{children:l},n),t[8]=n,t[9]=l,t[10]=c):c=t[10],c},ZT=()=>{const e=b(5),t=wi(),n=he(),[o]=ki();let r,a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=rn("w-full h-full flex-1 mx-auto -mb-4 relative"),e[0]=r):r=e[0],e[1]!==o||e[2]!==t||e[3]!==n.inOrderIds?(a=k.jsx("div",{className:r,children:k.jsx(JT,{cellAtoms:o,variables:t,cellIds:n.inOrderIds})}),e[1]=o,e[2]=t,e[3]=n.inOrderIds,e[4]=a):a=e[4],a};const QT="name",eM="type-value",tM="defs-refs",nM=[{id:QT,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>k.jsx(Li,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return k.jsx(P_,{name:t,declaredBy:n})}},{id:eM,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>k.jsx(Li,{header:k.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsx("span",{children:"Type"}),k.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return k.jsxs("div",{className:"max-w-[150px]",children:[k.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),k.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:tM,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>k.jsx(Li,{header:k.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsx("span",{children:"Declared By"}),k.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,o]=e(),r=e=>{const t=Yr(e);t&&yi(t,o)};return k.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[k.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[k.jsx("span",{title:"Declared by",children:k.jsx(Vc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?k.jsx(gi,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>r(t[0])}):k.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>k.jsxs("span",{className:"flex",children:[k.jsx(gi,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(e)},e),n<t.length-1&&", "]},e)))})]}),k.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[k.jsx("span",{title:"Used by",children:k.jsx(Qc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),k.jsx(D_,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}];const oM=r.memo((({className:e,cellIds:t,variables:n})=>{const[o,a]=u.useState([]),[i,s]=u.useState(""),l=Si(),c=r.useMemo((()=>{const e=e=>{const n=l[e];return n===Ri?`cell-${t.indexOf(e)}`:n??`cell-${t.indexOf(e)}`};return Object.values(n).map((t=>({...t,declaredByNames:t.declaredBy.map(e),usedByNames:t.usedBy.map(e)})))}),[n,l,t]),d=r.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:tM,desc:!1});let o=[];switch(t.id){case QT:o=Fl(e,(e=>e.name));break;case eM:o=Fl(e,(e=>e.dataType));break;case tM:o=Fl(e,(e=>n.get(e.declaredBy[0])))}return t.desc?o.reverse():o}(c,o[0],e)}),[c,o,t]),h=Ni({data:d,columns:nM,getCoreRowModel:Ci(),onGlobalFilterChange:s,getFilteredRowModel:Ei(),enableFilters:!0,enableGlobalFilter:!0,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:a,getSortedRowModel:ji(),state:{sorting:o,globalFilter:i}});return k.jsxs(k.Fragment,{children:[k.jsx(_i,{className:"w-full",placeholder:"Search",value:i,onChange:e=>s(e.target.value)}),k.jsxs(Ii,{className:rn("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[k.jsx(Ai,{children:k.jsx(Ti,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map((e=>k.jsx(Mi,{className:"sticky top-0 bg-background border-b",children:Oi(e.column.columnDef.header,e.getContext())},e.id)))})}),k.jsx(Di,{children:h.getRowModel().rows.map((e=>k.jsx(Ti,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>k.jsx(Pi,{className:"border-b",children:Oi(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));oM.displayName="VariableTable";const rM=()=>{const e=b(4),t=wi(),n=he();if(0===Object.keys(t).length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No variables",description:"Global variables will appear here.",icon:k.jsx(ct,{})}),e[0]=t):t=e[0],t}let o;return e[1]!==n.inOrderIds||e[2]!==t?(o=k.jsx(oM,{className:"flex-1",cellIds:n.inOrderIds,variables:t}),e[1]=n.inOrderIds,e[2]=t,e[3]=o):o=e[3],o},aM=()=>{const e=b(9),t=zi(),{clearLogs:n}=q();if(0===t.length){let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx("code",{className:"border rounded px-1",children:"stdout"}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(FS,{title:"No logs",description:k.jsxs("span",{children:[t," and"," ",k.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:k.jsx(ut,{})}),e[1]=n):n=e[1],n}let o,r,a;return e[2]!==n?(o=k.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:k.jsx("button",{"data-testid":"clear-logs-button",className:"text-xs font-semibold text-accent-foreground",onClick:n,children:"Clear"})}),e[2]=n,e[3]=o):o=e[3],e[4]!==t?(r=k.jsx("div",{className:"overflow-auto flex-1",children:k.jsx(iM,{logs:t,className:"min-w-[300px]"})}),e[4]=t,e[5]=r):r=e[5],e[6]!==o||e[7]!==r?(a=k.jsxs(k.Fragment,{children:[o,r]}),e[6]=o,e[7]=r,e[8]=a):a=e[8],a},iM=e=>{const t=b(11),{logs:n,className:o}=e;let r,a,i,s,l;if(t[0]!==o?(r=rn("flex flex-col",o),t[0]=o,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(a={whiteSpace:"pre-wrap"},t[2]=a):a=t[2],t[3]!==n){let e;t[5]===Symbol.for("react.memo_cache_sentinel")?(e=(e,t)=>k.jsxs("div",{className:"contents group",children:[k.jsx("span",{className:rn("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:t+1}),k.jsx("span",{className:rn("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:sM(e)})]},t),t[5]=e):e=t[5],i=n.map(e),t[3]=n,t[4]=i}else i=t[4];return t[6]!==i?(s=k.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:k.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:a,children:i})}),t[6]=i,t[7]=s):s=t[7],t[8]!==r||t[9]!==s?(l=k.jsx("div",{className:r,children:s}),t[8]=r,t[9]=s,t[10]=l):l=t[10],l};function sM(e){const t=Fi(e.timestamp),n=lM[e.level],o=e.level.toUpperCase();return k.jsxs(k.Fragment,{children:[k.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["[",t,"]"]}),k.jsx("span",{className:rn("flex-shrink-0",n),children:o}),k.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",k.jsx(gi,{cellId:e.cellId}),")"]}),e.message]})}const lM={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"},cM=()=>{const e=b(5),{documentation:t}=le(Bi);if(!t){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:k.jsx(Xc,{})}),e[0]=t):t=e[0],t}let n,o;return e[1]!==t?(n=xa({html:t}),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(o=k.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:n}),e[3]=n,e[4]=o):o=e[4],o};function dM(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function uM(e){void 0===e&&(e={});var t=e.onResize,n=r.useRef(void 0);n.current=t;var o=e.round||Math.round,a=r.useRef(),i=r.useState({width:void 0,height:void 0}),s=i[0],l=i[1],c=r.useRef(!1);r.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=r.useRef({width:void 0,height:void 0}),u=function(e,t){var n=r.useRef(null),o=r.useRef(null);o.current=t;var a=r.useRef(null);r.useEffect((function(){i()}));var i=r.useCallback((function(){var t=a.current,r=o.current,i=t||(r?r instanceof Element?r:r.current:null);n.current&&n.current.element===i&&n.current.subscriber===e||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:i,subscriber:e,cleanup:i?e(i):void 0})}),[e]);return r.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),r.useCallback((function(e){a.current=e,i()}),[i])}(r.useCallback((function(t){return a.current&&a.current.box===e.box&&a.current.round===o||(a.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var r=t[0],a="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",i=dM(r,a,"inlineSize"),s=dM(r,a,"blockSize"),u=i?o(i):void 0,h=s?o(s):void 0;if(d.current.width!==u||d.current.height!==h){var f={width:u,height:h};d.current.width=u,d.current.height=h,n.current?n.current(f):c.current||l(f)}}))}),a.current.instance.observe(t,{box:e.box}),function(){a.current&&a.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return r.useMemo((function(){return{ref:u,width:s.width,height:s.height}}),[u,s.width,s.height])}const hM=new Map,fM=({file:e,onOpenNotebook:t})=>{const{theme:n}=Me(),o=le(ze),[a,i]=r.useState(""),{data:s,loading:l,error:c,setData:d}=sn((async()=>{const t=await Ui({path:e.path}),n=t.contents||"";return i(hM.get(e.path)||n),t}),[e.path]),u=async()=>{a!==(null==s?void 0:s.contents)&&await Xi({path:e.path,contents:a}).then((e=>{e.success&&(d((e=>e?{...e,contents:a}:void 0)),i(a))}))},h=r.useRef(a);if(h.current=a,r.useEffect((()=>()=>{if(!s)return;const t=h.current;t===s.contents?hM.delete(e.path):hM.set(e.path,t)}),[e.path,null==s?void 0:s.contents]),c)return k.jsx(Vi,{error:c});if(l||!s)return null;const f=s.mimeType||"text/plain",m=f in pM;if(!s.contents&&!m)return k.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[k.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),k.jsx("div",{children:s.file.name}),k.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),k.jsx("div",{children:f})]});const p=k.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!D()&&k.jsx(N,{content:"Open notebook",children:k.jsx(Es,{size:"small",onClick:e=>t(e),children:k.jsx(Hi,{})})}),k.jsx(N,{content:"Download",children:k.jsx(Es,{size:"small",onClick:()=>{if(mM(f)){const e=Ki(s.contents,f);Ji(e,s.file.name)}else E(new Blob([s.contents||a],{type:f}),s.file.name)},children:k.jsx(Nt,{})})}),!mM(f)&&k.jsxs(k.Fragment,{children:[k.jsx(N,{content:"Copy contents to clipboard",children:k.jsx(Es,{size:"small",onClick:async()=>{await et(a)},children:k.jsx(nt,{})})}),k.jsx(N,{content:S("global.save"),children:k.jsx(Es,{size:"small",color:a===s.contents?void 0:"green",onClick:u,disabled:a===s.contents,children:k.jsx(Pc,{})})})]})]});return f.startsWith("image/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx($i,{base64:s.contents,mime:f})})]}):"text/csv"===f&&s.contents?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(Wi,{contents:s.contents})})]}):f.startsWith("audio/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(Gi,{base64:s.contents,mime:f})})]}):f.startsWith("video/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(qi,{base64:s.contents,mime:f})})]}):k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-auto",children:k.jsx(Yi,{theme:"dark"===n?"dark":"light",language:pM[f]||pM.default,className:"border-b",extensions:[Yt.lineWrapping,pn.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>a!==s.contents&&(u(),!0)}])],value:a,onChange:i})})]})},mM=e=>!!e&&(e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")),pM={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};const gM=Z(new class{constructor(e){this.callbacks=e,this.delegate=new Qs([]),this.rootPath="",this.onChange=an.NOOP,this.path=new pt("/"),this.initialize=async e=>{if(this.onChange=e,0===this.delegate.data.length)try{const e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Qs(e.files),this.rootPath=e.root,this.path=pt.guessDeliminator(e.root)}catch(t){re({title:"Failed",description:Vr(t)})}this.onChange(this.delegate.data)},this.refreshAll=async e=>{const t=[this.rootPath,...e.map((e=>{var t;return null==(t=this.delegate.find(e))?void 0:t.data.path}))].filter(Boolean),n=await Promise.all(t.map((e=>this.callbacks.listFiles({path:e}).catch((()=>({files:[]}))))));for(const[o,r]of t.entries()){const e=n[o];r===this.rootPath?this.delegate=new Qs(e.files):this.delegate.update({id:r,changes:{children:e.files}})}this.onChange(this.delegate.data)},this.relativeFromRoot=e=>{const t=function(e){return e.endsWith("/")?e:`${e}/`}(this.rootPath);return e.startsWith(t)?e.slice(t.length):e},this.handleResponse=e=>e.success?e:(re({title:"Failed",description:e.message}),null)}async expand(e){const t=this.delegate.find(e);if(!t)return!1;if(!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;const n=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(e,t){const n=this.delegate.find(e);if(!n)return;const o=n.data.path,r=this.path.join(this.path.dirname(o),t);await this.callbacks.renameFileOrFolder({path:o,newPath:r}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map((e=>{this.delegate.move({id:e,parentId:t,index:0});const n=this.delegate.find(e);if(!n)return Promise.resolve();const r=this.path.join(o,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:r}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:r}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([o])}async createFile(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"file",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async createFolder(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"directory",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async delete(e){const t=this.delegate.find(e);t&&(await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}({listFiles:cn,createFileOrFolder:Zi,deleteFileOrFolder:Qi,renameFileOrFolder:es})),vM=Z({});function yM(e){const t=b(4);let n;t[0]!==e?(n=void 0===e?{}:e,t[0]=e,t[1]=n):n=t[1];const o=n;let r;return t[2]!==o?(r={multiple:!0,maxSize:104857600,onError:SM,onDropRejected:bM,onDrop:xM,...o},t[2]=o,t[3]=r):r=t[3],ts(r)}async function xM(e){for(const t of e){const e=(await ns(t)).split(",")[1];await Zi({path:"",type:"file",name:t.name,contents:e})}await async function(){await te.get(gM).refreshAll([])}()}function bM(e){re({title:"File upload failed",description:k.jsx("div",{className:"flex flex-col gap-1",children:e.map(wM)}),variant:"danger"})}function wM(e){return k.jsxs("div",{children:[e.file.name," (",e.errors.map(kM).join(", "),")"]},e.file.name)}function kM(e){return e.message}function SM(e){J.error(e),re({title:"File upload failed",description:e.message,variant:"danger"})}const NM=u.createContext(null),CM=e=>{const t=b(60),{height:n}=e,o=r.useRef(null),[a]=Le(gM);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],t[0]=i):i=t[0];const[s,l]=r.useState(i),[c,d]=r.useState(null),{openPrompt:u}=w(),[h,f]=Le(vM);let m,p;t[1]!==a?(m=()=>a.initialize(l),t[1]=a,t[2]=m):m=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[3]=p):p=t[3];const{loading:g,error:v}=sn(m,p);let y;t[4]!==a||t[5]!==h?(y=()=>{a.refreshAll(Object.keys(h).filter((e=>h[e])))},t[4]=a,t[5]=h,t[6]=y):y=t[6];const x=G(y);let S;t[7]!==u||t[8]!==a?(S=async()=>{u({title:"Folder name",onConfirm:async e=>{a.createFolder(e,null)}})},t[7]=u,t[8]=a,t[9]=S):S=t[9];const N=G(S);let E;t[10]!==u||t[11]!==a?(E=async()=>{u({title:"File name",onConfirm:async e=>{a.createFile(e,null)}})},t[10]=u,t[11]=a,t[12]=E):E=t[12];const j=G(E);let _;t[13]!==f?(_=()=>{var e;null==(e=o.current)||e.closeAll(),f({})},t[13]=f,t[14]=_):_=t[14];const I=G(_);if(g){let e;return t[15]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(oi,{size:"medium",centered:!0}),t[15]=e):e=t[15],e}if(v){let e;return t[16]!==v?(e=k.jsx(Vi,{error:v}),t[16]=v,t[17]=e):e=t[17],e}if(c){let e,n,o,i,s,l;return t[18]===Symbol.for("react.memo_cache_sentinel")?(e=()=>d(null),t[18]=e):e=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(C,{onClick:e,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:k.jsx(Bl,{size:16})}),t[19]=n):n=t[19],t[20]!==c.name?(o=k.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[n,k.jsx("span",{className:"font-bold",children:c.name})]}),t[20]=c.name,t[21]=o):o=t[21],t[22]!==a||t[23]!==c.path?(i=e=>MM(e,a.relativeFromRoot(c.path)),t[22]=a,t[23]=c.path,t[24]=i):i=t[24],t[25]!==i||t[26]!==c?(s=k.jsx(r.Suspense,{children:k.jsx(fM,{onOpenNotebook:i,file:c})}),t[25]=i,t[26]=c,t[27]=s):s=t[27],t[28]!==o||t[29]!==s?(l=k.jsxs(k.Fragment,{children:[o,s]}),t[28]=o,t[29]=s,t[30]=l):l=t[30],l}let A;t[31]!==x||t[32]!==j||t[33]!==N||t[34]!==I||t[35]!==a?(A=k.jsx(jM,{onRefresh:x,onCreateFile:j,onCreateFolder:N,onCollapseAll:I,tree:a}),t[31]=x,t[32]=j,t[33]=N,t[34]=I,t[35]=a,t[36]=A):A=t[36];const T=n-33;let M,O,D,P,R,L,z,F;return t[37]!==a?(M=async e=>{const{ids:t}=e;for(const n of t)await a.delete(n)},O=async e=>{const{id:t,name:n}=e;await a.rename(t,n)},D=async e=>{const{dragIds:t,parentId:n}=e;await a.move(t,n)},t[37]=a,t[38]=M,t[39]=O,t[40]=D):(M=t[38],O=t[39],D=t[40]),t[41]===Symbol.for("react.memo_cache_sentinel")?(P=e=>{const t=e[0];t&&(t.data.isDirectory||d(t.data))},t[41]=P):P=t[41],t[42]!==a||t[43]!==h||t[44]!==f?(R=async e=>{if(await a.expand(e)){const t=h[e]??!1;f({...h,[e]:!t})}},t[42]=a,t[43]=h,t[44]=f,t[45]=R):R=t[45],t[46]!==T||t[47]!==s||t[48]!==h||t[49]!==M||t[50]!==O||t[51]!==D||t[52]!==R?(L=k.jsx(el,{width:"100%",ref:o,height:T,className:"h-full",data:s,initialOpenState:h,openByDefault:!1,renderCursor:OM,disableDrop:DM,onDelete:M,onRename:O,onMove:D,onSelect:P,onToggle:R,padding:15,rowHeight:30,indent:EM,overscanCount:1e3,disableMultiSelection:!0,children:AM}),t[46]=T,t[47]=s,t[48]=h,t[49]=M,t[50]=O,t[51]=D,t[52]=R,t[53]=L):L=t[53],t[54]!==a||t[55]!==L?(z=k.jsx(NM.Provider,{value:a,children:L}),t[54]=a,t[55]=L,t[56]=z):z=t[56],t[57]!==A||t[58]!==z?(F=k.jsxs(k.Fragment,{children:[A,z]}),t[57]=A,t[58]=z,t[59]=F):F=t[59],F},EM=15,jM=e=>{const t=b(30),{onRefresh:n,onCreateFile:o,onCreateFolder:r,onCollapseAll:a}=e;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={noDrag:!0,noDragEventsBubbling:!0},t[0]=i):i=t[0];const{getRootProps:s,getInputProps:l}=yM(i);let c,d,u,h,f,m,p,g,v,y,x,w,S,E,j;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(sc,{size:16}),t[1]=c):c=t[1],t[2]!==o?(d=k.jsx(N,{content:"Add file",children:k.jsx(C,{"data-testid":"file-explorer-add-file-button",onClick:o,variant:"text",size:"xs",children:c})}),t[2]=o,t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(cc,{size:16}),t[4]=u):u=t[4],t[5]!==r?(h=k.jsx(N,{content:"Add folder",children:k.jsx(C,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:u})}),t[5]=r,t[6]=h):h=t[6],t[7]!==s?(f=s({}),t[7]=s,t[8]=f):f=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(m=os({variant:"text",size:"xs"}),p=k.jsx(rs,{size:16}),t[9]=m,t[10]=p):(m=t[9],p=t[10]),t[11]!==f?(g=k.jsx(N,{content:"Upload file",children:k.jsx("button",{"data-testid":"file-explorer-upload-button",...f,className:m,children:p})}),t[11]=f,t[12]=g):g=t[12],t[13]!==l?(v=l({}),t[13]=l,t[14]=v):v=t[14],t[15]!==v?(y=k.jsx("input",{...v,type:"file"}),t[15]=v,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(x=k.jsx(oa,{size:16}),t[17]=x):x=t[17],t[18]!==n?(w=k.jsx(N,{content:"Refresh",children:k.jsx(C,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:x})}),t[18]=n,t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(oc,{size:16}),t[20]=S):S=t[20],t[21]!==a?(E=k.jsx(N,{content:"Collapse all folders",children:k.jsx(C,{"data-testid":"file-explorer-collapse-button",onClick:a,variant:"text",size:"xs",children:S})}),t[21]=a,t[22]=E):E=t[22],t[23]!==d||t[24]!==h||t[25]!==g||t[26]!==y||t[27]!==w||t[28]!==E?(j=k.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[d,h,g,y,w,E]}),t[23]=d,t[24]=h,t[25]=g,t[26]=y,t[27]=w,t[28]=E,t[29]=j):j=t[29],j},_M=e=>{const t=b(9),{node:n,onOpenMarimoFile:o}=e;let r,a,i;return t[0]!==n?(r=e=>{n.data.isDirectory||(e.stopPropagation(),n.select())},t[0]=n,t[1]=r):r=t[1],t[2]!==n.data.isMarimoFile||t[3]!==o?(a=n.data.isMarimoFile&&!D()&&k.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:o,children:["open ",k.jsx(Hi,{className:"inline ml-1",size:12})]}),t[2]=n.data.isMarimoFile,t[3]=o,t[4]=a):a=t[4],t[5]!==r||t[6]!==n.data.name||t[7]!==a?(i=k.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:r,children:[n.data.name,a]}),t[5]=r,t[6]=n.data.name,t[7]=a,t[8]=i):i=t[8],i},IM=e=>{const t=b(10),{node:n}=e,o=r.useRef(null);let a,i,s,l,c;return t[0]!==n.data.name?(a=()=>{var e,t;null==(e=o.current)||e.focus(),null==(t=o.current)||t.setSelectionRange(0,n.data.name.lastIndexOf("."))},i=[n.data.name],t[0]=n.data.name,t[1]=a,t[2]=i):(a=t[1],i=t[2]),r.useEffect(a,i),t[3]!==n?(s=()=>n.reset(),l=e=>{"Escape"===e.key&&n.reset(),"Enter"===e.key&&n.submit(e.currentTarget.value)},t[3]=n,t[4]=s,t[5]=l):(s=t[4],l=t[5]),t[6]!==n.data.name||t[7]!==s||t[8]!==l?(c=k.jsx("input",{ref:o,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:PM,onBlur:s,onKeyDown:l}),t[6]=n.data.name,t[7]=s,t[8]=l,t[9]=c):c=t[9],c},AM=e=>{const t=b(52),{node:n,style:o,dragHandle:a}=e;let i;t[0]!==n.data?(i=n.data.isDirectory?"directory":ln(n.data.name),t[0]=n.data,t[1]=i):i=t[1];const s=i,l=dn[s],{openConfirm:c,openPrompt:d}=w(),u=r.useContext(NM);let h;t[2]!==u||t[3]!==n.data.path?(h=async e=>{MM(e,u?u.relativeFromRoot(n.data.path):n.data.path)},t[2]=u,t[3]=n.data.path,t[4]=h):h=t[4];const f=h;let m;t[5]!==c||t[6]!==n.data.name||t[7]!==n.tree||t[8]!==n.id?(m=async e=>{e.stopPropagation(),e.preventDefault(),c({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:k.jsx(ot,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},t[5]=c,t[6]=n.data.name,t[7]=n.tree,t[8]=n.id,t[9]=m):m=t[9];const p=m;let g;t[10]!==n||t[11]!==d||t[12]!==u?(g=async()=>{n.open(),d({title:"Folder name",onConfirm:async e=>{null==u||u.createFolder(e,n.id)}})},t[10]=n,t[11]=d,t[12]=u,t[13]=g):g=t[13];const v=G(g);let y;t[14]!==n||t[15]!==d||t[16]!==u?(y=async()=>{n.open(),d({title:"File name",onConfirm:async e=>{null==u||u.createFile(e,n.id)}})},t[14]=n,t[15]=d,t[16]=u,t[17]=y):y=t[17];const x=G(y);let S;t[18]!==n||t[19]!==x||t[20]!==v||t[21]!==u||t[22]!==s||t[23]!==f||t[24]!==p?(S=()=>{const e={size:14,strokeWidth:1.5,className:"mr-2"};return k.jsxs(Ut,{align:"end",className:"no-print w-[220px]",onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>e.preventDefault(),children:[!n.data.isDirectory&&k.jsxs(Ot,{onSelect:()=>n.select(),children:[k.jsx(Jc,{...e}),"Open file"]}),n.data.isDirectory&&k.jsxs(k.Fragment,{children:[k.jsxs(Ot,{onSelect:()=>x(),children:[k.jsx(sc,{...e}),"Create file"]}),k.jsxs(Ot,{onSelect:()=>v(),children:[k.jsx(cc,{...e}),"Create folder"]}),k.jsx(Ft,{})]}),k.jsxs(Ot,{onSelect:()=>n.edit(),children:[k.jsx(Ic,{...e}),"Rename"]}),k.jsxs(Ot,{onSelect:async()=>{await et(n.data.path),re({title:"Copied to clipboard"})},children:[k.jsx(nt,{...e}),"Copy path"]}),u&&k.jsxs(Ot,{onSelect:async()=>{await et(u.relativeFromRoot(n.data.path)),re({title:"Copied to clipboard"})},children:[k.jsx(nt,{...e}),"Copy relative path"]}),k.jsxs(Ot,{onSelect:async()=>{re({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});const{path:e}=n.data,t=as[s](e);await et(t)},children:[k.jsx(is,{...e}),"Copy snippet for reading file"]}),n.data.isMarimoFile&&!D()&&k.jsxs(k.Fragment,{children:[k.jsx(Ft,{}),k.jsxs(Ot,{onSelect:f,children:[k.jsx($c,{...e}),"Open notebook"]})]}),k.jsx(Ft,{}),!n.data.isDirectory&&k.jsxs(k.Fragment,{children:[k.jsxs(Ot,{onSelect:async()=>{const e=(await Ui({path:n.data.path})).contents||"";E(new Blob([e]),n.data.name)},children:[k.jsx(Nt,{...e}),"Download"]}),k.jsx(Ft,{})]}),k.jsxs(Ot,{onSelect:p,variant:"danger",children:[k.jsx(je,{...e}),"Delete"]})]})},t[18]=n,t[19]=x,t[20]=v,t[21]=u,t[22]=s,t[23]=f,t[24]=p,t[25]=S):S=t[25];const N=S;let j,_,I;t[26]===Symbol.for("react.memo_cache_sentinel")?(j=rn("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),t[26]=j):j=t[26],t[27]!==n?(_=e=>{e.stopPropagation(),n.data.isDirectory&&n.toggle()},I=k.jsx(TM,{node:n}),t[27]=n,t[28]=_,t[29]=I):(_=t[28],I=t[29]);const A=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground";let T,M,O,P,R,L,z;return t[30]!==A?(T=rn("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",A),t[30]=A,t[31]=T):T=t[31],t[32]!==n.data.isMarimoFile||t[33]!==l?(M=n.data.isMarimoFile?k.jsx("img",{src:"/favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):k.jsx(l,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),t[32]=n.data.isMarimoFile,t[33]=l,t[34]=M):M=t[34],t[35]!==n||t[36]!==f?(O=n.isEditing?k.jsx(IM,{node:n}):k.jsx(_M,{node:n,onOpenMarimoFile:f}),t[35]=n,t[36]=f,t[37]=O):O=t[37],t[38]===Symbol.for("react.memo_cache_sentinel")?(P=k.jsx(Dt,{asChild:!0,tabIndex:-1,onClick:RM,children:k.jsx(C,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:k.jsx(rc,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),t[38]=P):P=t[38],t[39]!==N?(R=k.jsxs(Bt,{modal:!1,children:[P,N()]}),t[39]=N,t[40]=R):R=t[40],t[41]!==T||t[42]!==M||t[43]!==O||t[44]!==R?(L=k.jsxs("span",{className:T,children:[M,O,R]}),t[41]=T,t[42]=M,t[43]=O,t[44]=R,t[45]=L):L=t[45],t[46]!==o||t[47]!==a||t[48]!==_||t[49]!==I||t[50]!==L?(z=k.jsxs("div",{style:o,ref:a,className:j,draggable:!0,onClick:_,children:[I,L]}),t[46]=o,t[47]=a,t[48]=_,t[49]=I,t[50]=L,t[51]=z):z=t[51],z},TM=e=>{const t=b(3),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"w-5 h-5 flex-shrink-0"}),t[0]=e):e=t[0],e}let o;return t[1]!==n.isOpen?(o=n.isOpen?k.jsx(Ce,{className:"w-5 h-5 flex-shrink-0"}):k.jsx(ra,{className:"w-5 h-5 flex-shrink-0"}),t[1]=n.isOpen,t[2]=o):o=t[2],o};function MM(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}function OM(){return null}function DM(e){const{parentNode:t}=e;return!t.data.isDirectory}function PM(e){return e.stopPropagation()}function RM(e){return e.stopPropagation()}const LM=()=>{const e=b(20),{ref:t,height:n}=uM(),o=void 0===n?1:n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={noClick:!0,noKeyboard:!0},e[0]=r):r=e[0];const{getRootProps:a,getInputProps:i,isDragActive:s}=yM(r);let l,c,d,u,h,f,m,p;return e[1]!==a?(l=a(),e[1]=a,e[2]=l):l=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(c=rn("flex flex-col flex-1 overflow-hidden relative"),e[3]=c):c=e[3],e[4]!==i?(d=i(),e[4]=i,e[5]=d):d=e[5],e[6]!==d?(u=k.jsx("input",{...d}),e[6]=d,e[7]=u):u=e[7],e[8]!==s?(h=s&&k.jsx("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[8]=s,e[9]=h):h=e[9],e[10]!==o?(f=k.jsx(CM,{height:o}),e[10]=o,e[11]=f):f=e[11],e[12]!==t||e[13]!==f?(m=k.jsx("div",{ref:t,className:"flex flex-col flex-1 overflow-hidden",children:f}),e[12]=t,e[13]=f,e[14]=m):m=e[14],e[15]!==l||e[16]!==u||e[17]!==h||e[18]!==m?(p=k.jsxs("div",{...l,className:c,children:[u,h,m]}),e[15]=l,e[16]=u,e[17]=h,e[18]=m,e[19]=p):p=e[19],p},zM=e=>{const t=b(6),{children:n}=e,{openModal:o,closeModal:r}=w();let a,i;return t[0]!==o||t[1]!==r?(a=()=>o(k.jsx(BM,{onClose:r})),t[0]=o,t[1]=r,t[2]=a):a=t[2],t[3]!==a||t[4]!==n?(i=k.jsx(ii,{onClick:a,children:n}),t[3]=a,t[4]=n,t[5]=i):i=t[5],i},FM=[Yt.lineWrapping],BM=e=>{const t=b(23),{onClose:n}=e,[o,a]=r.useState(""),{theme:i}=Me();let s,l,c,d,u,h;t[0]!==n?(s=async e=>{e.preventDefault();const t=new FormData(e.target),o=t.get("title"),r=t.get("description"),a=t.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o,description:r,code:a})}),n(),re({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},t[0]=n,t[1]=s):s=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(j,{children:"Contribute a Snippet"}),t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsxs(Ie,{children:[l,k.jsxs(_,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",k.jsx("a",{href:Ze.githubPage,target:"_blank",rel:"noreferrer",className:"underline",children:"on GitHub"}),"."]})]}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Qe,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),u=k.jsx(si,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),t[4]=d,t[5]=u):(d=t[4],u=t[5]),t[6]!==o?(h=k.jsx("input",{type:"hidden",name:"code",value:o}),t[6]=o,t[7]=h):h=t[7];const f="dark"===i?"dark":"light";let m,p,g,v,y,x;return t[8]!==f||t[9]!==o?(m=k.jsx(Yi,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:FM,value:o,onChange:a}),t[8]=f,t[9]=o,t[10]=m):m=t[10],t[11]!==h||t[12]!==m?(p=k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[d,u,h,m]}),t[11]=h,t[12]=m,t[13]=p):p=t[13],t[14]!==n?(g=k.jsx(C,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(C,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[16]=v):v=t[16],t[17]!==g?(y=k.jsxs(I,{children:[g,v]}),t[17]=g,t[18]=y):y=t[18],t[19]!==s||t[20]!==p||t[21]!==y?(x=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:s,children:[c,p,y]})}),t[19]=s,t[20]=p,t[21]=y,t[22]=x):x=t[22],x},UM=[Yt.lineWrapping],VM=()=>{const e=b(20),[t,n]=u.useState();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:a,error:i,loading:s}=sn(WM,o);if(i){let t;return e[1]!==i?(t=k.jsx(Vi,{error:i}),e[1]=i,e[2]=t):t=e[2],t}if(s||!a){let t;return e[3]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(oi,{size:"medium",centered:!0}),e[3]=t):t=e[3],t}const l=t?"h-1/3":"h-full";let c,d,h,f,m,p,g,v,y;return e[4]!==l?(c=rn("border-b rounded-none",l),e[4]=l,e[5]=c):c=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Ye,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),e[6]=d):d=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsxs("div",{className:"flex items-center w-full",children:[d,k.jsx(zM,{children:k.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:k.jsx(Bo,{className:"h-4 w-4"})})})]}),f=k.jsx(Ke,{children:"No results"}),e[7]=h,e[8]=f):(h=e[7],f=e[8]),e[9]===Symbol.for("react.memo_cache_sentinel")?(m=e=>n(e),e[9]=m):m=e[9],e[10]!==a.snippets?(p=k.jsx($M,{onSelect:m,snippets:a.snippets}),e[10]=a.snippets,e[11]=p):p=e[11],e[12]!==c||e[13]!==p?(g=k.jsxs(mn,{className:c,children:[h,f,p]}),e[12]=c,e[13]=p,e[14]=g):g=e[14],e[15]!==t?(v=k.jsx(r.Suspense,{children:k.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:t?k.jsx(HM,{snippet:t},t.title):k.jsx(FS,{title:"",description:"Click on a snippet to view its content."})})}),e[15]=t,e[16]=v):v=e[16],e[17]!==g||e[18]!==v?(y=k.jsxs("div",{className:"flex-1 overflow-hidden",children:[g,v]}),e[17]=g,e[18]=v,e[19]=y):y=e[19],y},HM=e=>{const t=b(27),{snippet:n}=e,{theme:o}=Me(),{createNewCell:r}=q(),a=Rd();let i;t[0]!==n.sections||t[1]!==r||t[2]!==a?(i=()=>{for(const e of[...n.sections].reverse())e.code&&r({code:e.code,before:!1,cellId:a??"__end__"})},t[0]=n.sections,t[1]=r,t[2]=a,t[3]=i):i=t[3];const s=i;let l;t[4]!==r||t[5]!==a?(l=e=>{r({code:e,before:!1,cellId:a??"__end__"})},t[4]=r,t[5]=a,t[6]=l):l=t[6];const c=l;let d,u,h,f,m,p;if(t[7]!==n.title?(d=k.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:n.title}),t[7]=n.title,t[8]=d):d=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(Wl,{className:"ml-2 h-4 w-4"}),t[9]=u):u=t[9],t[10]!==s?(h=k.jsx("div",{className:"flex justify-end",children:k.jsx(Du,{children:k.jsxs(C,{className:"float-right",size:"xs",variant:"outline",onClick:s,children:["Insert snippet",u]})})}),t[10]=s,t[11]=h):h=t[11],t[12]!==n.title||t[13]!==n.sections||t[14]!==c||t[15]!==o){let e;t[17]!==n.title||t[18]!==c||t[19]!==o?(e=e=>{const{code:t,html:r,id:a}=e;return r?k.jsx("div",{children:xa({html:r})},`${n.title}-${a}`):t?k.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[k.jsx(Du,{children:k.jsx(N,{content:"Insert snippet",children:k.jsx(C,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{c(t)},children:k.jsx(Wl,{className:"h-5 w-5"})})})}),k.jsx(Yi,{theme:"dark"===o?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:UM,value:t,readOnly:!0},`${n.title}-${a}`)]},`${n.title}-${a}`):null},t[17]=n.title,t[18]=c,t[19]=o,t[20]=e):e=t[20],f=n.sections.map(e),t[12]=n.title,t[13]=n.sections,t[14]=c,t[15]=o,t[16]=f}else f=t[16];return t[21]!==h||t[22]!==f?(m=k.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[h,f]}),t[21]=h,t[22]=f,t[23]=m):m=t[23],t[24]!==d||t[25]!==m?(p=k.jsxs(k.Fragment,{children:[d,m]}),t[24]=d,t[25]=m,t[26]=p):p=t[26],p},$M=e=>{const t=b(7),{snippets:n,onSelect:o}=e;let r,a;if(t[0]!==o||t[1]!==n){let e;t[3]!==o?(e=e=>k.jsx($e,{className:"rounded-none",onSelect:()=>o(e),children:k.jsx("div",{className:"flex flex-row gap-2 items-center",children:k.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title),t[3]=o,t[4]=e):e=t[4],r=n.map(e),t[0]=o,t[1]=n,t[2]=r}else r=t[2];return t[5]!==r?(a=k.jsx(yr,{className:"flex flex-col overflow-auto",children:r}),t[5]=r,t[6]=a):a=t[6],a};function WM(){return ss()}const GM=e=>{const t=b(11),{value:n,className:o,tooltip:a}=e,[i,s]=r.useState(!1);let l;t[0]!==n?(l=tt.stopPropagation((async()=>{await et(n).then((()=>{s(!0),setTimeout((()=>s(!1)),2e3)}))})),t[0]=n,t[1]=l):l=t[1];const c=l;let d,u;t[2]!==i||t[3]!==o?(d=i?k.jsx(It,{className:rn(o,"text-[var(--grass-11)]")}):k.jsx(nt,{className:o}),t[2]=i,t[3]=o,t[4]=d):d=t[4],t[5]!==c||t[6]!==d?(u=k.jsx("span",{onClick:c,children:d}),t[5]=c,t[6]=d,t[7]=u):u=t[7];const h=u;if(!1===a)return h;const f=i?"Copied!":a??"Copy to clipboard";let m;return t[8]!==f||t[9]!==h?(m=k.jsx(N,{content:f,delayDuration:400,children:h}),t[8]=f,t[9]=h,t[10]=m):m=t[10],m},qM=Z((e=>{const t=e(Or),n=e(ae),o=e(Ya);return Fl(t,(e=>{if(!e.variable_name)return-1;const t=Object.values(n).find((t=>t.name===e.variable_name));if(!t)return 0;const r=o.inOrderIds.indexOf(t.declaredBy[0]);return-1===r?0:r}))})),YM=()=>{const e=b(43),[t,n]=u.useState(""),o=le(ue),r=Rd(),{expandedColumns:a,expandedTables:i,columnsPreviews:s}=ls(),{toggleTable:l,toggleColumn:c,closeAllColumns:d}=cs(),{createNewCell:h}=q(),f=le(qM);if(0===f.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",icon:k.jsx(ke,{})}),e[0]=t):t=e[0],t}let m;e[1]!==o||e[2]!==h||e[3]!==r?(m=e=>{e.includes("alt")&&function(e,t,n){_d("altair","alt",(o=>{const r=se.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&K({cellIds:[r],codes:[o]})}))}(o,h,r),h({code:e,before:!1,cellId:r??"__end__"})},e[1]=o,e[2]=h,e[3]=r,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==h||e[7]!==r?(g=e=>{Id(o,h,r);let t="";e:switch(e.source_type){case"local":t=`mo.ui.table(${e.name})`;break e;case"duckdb":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100")`;break e;default:T(e.source_type)}h({code:t,before:!1,cellId:r??"__end__"})},e[5]=o,e[6]=h,e[7]=r,e[8]=g):g=e[8];const v=g,y=!!t.trim();let x,w,S,N,C,E,j,_,I,A,M;return e[9]===Symbol.for("react.memo_cache_sentinel")?(x=rn("border-b bg-background rounded-none","h-full"),e[9]=x):x=e[9],e[10]!==d?(w=e=>{e.length>0&&d(),n(e)},e[10]=d,e[11]=w):w=e[11],e[12]!==t||e[13]!==w?(S=k.jsx(Ye,{placeholder:"Search tables...",className:"h-6 m-1",value:t,onValueChange:w,rootClassName:"flex-1 border-r"}),e[12]=t,e[13]=w,e[14]=S):S=e[14],e[15]!==y?(N=y&&k.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>n(""),children:k.jsx(tn,{className:"h-4 w-4"})}),e[15]=y,e[16]=N):N=e[16],e[17]!==S||e[18]!==N?(C=k.jsxs("div",{className:"flex items-center w-full",children:[S,N]}),e[17]=S,e[18]=N,e[19]=C):C=e[19],e[20]!==c||e[21]!==s?(E=(e,t)=>{const n=`${e.name}:${t.name}`;c({table:e.name,column:t.name}),s.has(n)||us({source:e.source,tableName:e.name,columnName:t.name,sourceType:e.source_type})},e[20]=c,e[21]=s,e[22]=E):E=e[22],e[23]!==l?(j=e=>{l(e.name)},e[23]=l,e[24]=j):j=e[24],e[25]!==y||e[26]!==i?(_=e=>!!y||i.has(e.name),e[25]=y,e[26]=i,e[27]=_):_=e[27],e[28]!==a?(I=(e,t)=>{const n=`${e.name}:${t.name}`;return a.has(n)},e[28]=a,e[29]=I):I=e[29],e[30]!==p||e[31]!==v||e[32]!==E||e[33]!==j||e[34]!==s||e[35]!==f||e[36]!==y||e[37]!==_||e[38]!==I?(A=k.jsx(XM,{onAddColumnChart:p,onAddTable:v,onExpandColumn:E,onExpandTable:j,columnPreviews:s,tables:f,isSearching:y,isTableExpanded:_,isColumnExpanded:I}),e[30]=p,e[31]=v,e[32]=E,e[33]=j,e[34]=s,e[35]=f,e[36]=y,e[37]=_,e[38]=I,e[39]=A):A=e[39],e[40]!==C||e[41]!==A?(M=k.jsx("div",{className:"flex-1 overflow-hidden",children:k.jsxs(mn,{className:x,children:[C,A]})}),e[40]=C,e[41]=A,e[42]=M):M=e[42],M},XM=e=>{const t=b(25),{tables:n,isSearching:o,columnPreviews:r,onAddColumnChart:a,onAddTable:i,onExpandTable:s,onExpandColumn:l,isTableExpanded:c,isColumnExpanded:d}=e;let h,f,m,p;if(t[0]!==n||t[1]!==c||t[2]!==o||t[3]!==s||t[4]!==i||t[5]!==l||t[6]!==d||t[7]!==a||t[8]!==r){let e,p;e=Object.entries(Fe.groupBy(n,eO,tO)),e=Fl(e,nO),t[12]!==c||t[13]!==o||t[14]!==s||t[15]!==i||t[16]!==l||t[17]!==d||t[18]!==a||t[19]!==r?(p=e=>{const t=c(e),n=[k.jsx(KM,{table:e,forceMount:o,onExpand:()=>s(e),onAddTable:()=>i(e),isExpanded:t},e.name)];return t&&n.push(...e.columns.map((t=>k.jsxs(u.Fragment,{children:[k.jsx(JM,{table:e,column:t,onExpandColumn:l,isExpanded:d(e,t)},`${e.name}.${t.name}`),d(e,t)&&k.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:k.jsx(hs,{children:k.jsx(QM,{table:e,column:t,onAddColumnChart:a,preview:r.get(`${e.name}:${t.name}`)})})})]},`${e.name}.${t.name}`)))),n},t[12]=c,t[13]=o,t[14]=s,t[15]=i,t[16]=l,t[17]=d,t[18]=a,t[19]=r,t[20]=p):p=t[20];const g=p;h=yr,f="flex flex-col overflow-auto",m=(()=>0===e.length?null:1===e.length?e[0][1].flatMap(g):e.flatMap(((e,t)=>{const[n,o]=e;return[k.jsx("div",{className:rn("font-bold px-2 py-1 text-muted-foreground bg-[var(--slate-2)] border-t text-sm",t>0&&"border-t"),children:"memory"===n?"In-Memory":n},n),...o.flatMap(g)]})))(),t[0]=n,t[1]=c,t[2]=o,t[3]=s,t[4]=i,t[5]=l,t[6]=d,t[7]=a,t[8]=r,t[9]=h,t[10]=f,t[11]=m}else h=t[9],f=t[10],m=t[11];return t[21]!==h||t[22]!==f||t[23]!==m?(p=k.jsx(h,{className:f,children:m}),t[21]=h,t[22]=f,t[23]=m,t[24]=p):p=t[24],p},KM=e=>{const t=b(27),{table:n,onExpand:o,onAddTable:r,isExpanded:a}=e;let i;t[0]!==n.num_rows||t[1]!==n.num_columns?(i=()=>{const e=[];return null!=n.num_rows&&e.push(`${n.num_rows} rows`),null!=n.num_columns&&e.push(`${n.num_columns} columns`),0===e.length?null:k.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:k.jsx("span",{className:"text-xs text-muted-foreground",children:e.join(", ")})})},t[0]=n.num_rows,t[1]=n.num_columns,t[2]=i):i=t[2];const s=i,l=n.name,c=a&&"rotate-90";let d,u,h,f,m,p,g,v,y;return t[3]!==c?(d=rn("h-3 w-3 transition-transform",c),t[3]=c,t[4]=d):d=t[4],t[5]!==d?(u=k.jsx(ra,{className:d}),t[5]=d,t[6]=u):u=t[6],t[7]!==n.name?(h=k.jsx("span",{className:"text-sm",children:n.name}),t[7]=n.name,t[8]=h):h=t[8],t[9]!==u||t[10]!==h?(f=k.jsxs("div",{className:"flex gap-1 items-center flex-1",children:[u,h]}),t[9]=u,t[10]=h,t[11]=f):f=t[11],t[12]!==s?(m=s(),t[12]=s,t[13]=m):m=t[13],t[14]!==r||t[15]!==n?(p=tt.stopPropagation((()=>r(n))),t[14]=r,t[15]=n,t[16]=p):p=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(g=k.jsx(Wc,{className:"h-3 w-3"}),t[17]=g):g=t[17],t[18]!==p?(v=k.jsx(N,{content:"Add table to notebook",delayDuration:400,children:k.jsx(C,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:p,children:g})}),t[18]=p,t[19]=v):v=t[19],t[20]!==n.name||t[21]!==a||t[22]!==o||t[23]!==f||t[24]!==m||t[25]!==v?(y=k.jsxs($e,{className:"rounded-none py-1 group min-h-9 border-t",value:l,"aria-selected":a,forceMount:!0,onSelect:o,children:[f,m,v]}),t[20]=n.name,t[21]=a,t[22]=o,t[23]=f,t[24]=m,t[25]=v,t[26]=y):y=t[26],y},JM=e=>{const t=b(22),{table:n,column:o,onExpandColumn:r}=e,a=fs[o.type],i=`${n.name}.${o.name}`,s=`${n.name}.${o.name}`;let l,c,d,u,h,f,m;return t[0]!==r||t[1]!==n||t[2]!==o?(l=()=>r(n,o),t[0]=r,t[1]=n,t[2]=o,t[3]=l):l=t[3],t[4]!==a?(c=k.jsx(a,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),t[4]=a,t[5]=c):c=t[5],t[6]!==o.name?(d=k.jsx("span",{children:o.name}),t[6]=o.name,t[7]=d):d=t[7],t[8]!==c||t[9]!==d?(u=k.jsxs("div",{className:"flex flex-row gap-2 items-center pl-6 flex-1",children:[c,d]}),t[8]=c,t[9]=d,t[10]=u):u=t[10],t[11]!==o.name?(h=k.jsx(N,{content:"Copy column name",delayDuration:400,children:k.jsx(C,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:k.jsx(GM,{tooltip:!1,value:o.name,className:"h-3 w-3"})})}),t[11]=o.name,t[12]=h):h=t[12],t[13]!==o.external_type?(f=k.jsx("span",{className:"text-xs text-muted-foreground",children:o.external_type}),t[13]=o.external_type,t[14]=f):f=t[14],t[15]!==i||t[16]!==s||t[17]!==l||t[18]!==u||t[19]!==h||t[20]!==f?(m=k.jsxs($e,{className:"rounded-none py-1 group",value:s,onSelect:l,children:[u,h,f]},i),t[15]=i,t[16]=s,t[17]=l,t[18]=u,t[19]=h,t[20]=f,t[21]=m):m=t[21],m},ZM=u.lazy((()=>ds((()=>import("./index-DgSPTavE.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then((e=>({default:e.VegaLite}))))),QM=e=>{const t=b(26),{table:n,column:o,preview:r,onAddColumnChart:a}=e,{theme:i}=Me();if(!r){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."}),t[0]=e):e=t[0],e}let s;t[1]!==r.error?(s=r.error&&k.jsx("span",{className:"text-xs text-muted-foreground",children:r.error}),t[1]=r.error,t[2]=s):s=t[2];const l=s;let c;t[3]!==r.summary?(c=r.summary&&k.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(r.summary).map(oO)}),t[3]=r.summary,t[4]=c):c=t[4];const d=c,u=rO;let h;t[5]!==r.chart_spec||t[6]!==i?(h=r.chart_spec&&k.jsx(ZM,{spec:u(JSON.parse(r.chart_spec)),width:"container",height:100,actions:!1,theme:"dark"===i?"dark":"vox"}),t[5]=r.chart_spec,t[6]=i,t[7]=h):h=t[7];const f=h;let m;t[8]!==r.chart_code||t[9]!==n||t[10]!==a?(m=r.chart_code&&"local"===n.source_type&&k.jsx(N,{content:"Add chart to notebook",delayDuration:400,children:k.jsx(C,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:tt.stopPropagation((()=>a(r.chart_code||""))),children:k.jsx(Wc,{className:"h-3 w-3"})})}),t[8]=r.chart_code,t[9]=n,t[10]=a,t[11]=m):m=t[11];const p=m;let g;t[12]!==n||t[13]!==o||t[14]!==a?(g="duckdb"===n.source_type&&k.jsx(N,{content:"Add SQL cell",delayDuration:400,children:k.jsx(C,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:tt.stopPropagation((()=>{const e=`_df = mo.sql(f'SELECT "${o.name}" FROM ${n.name} LIMIT 100')`;a(e)})),children:k.jsx(Wc,{className:"h-3 w-3"})})}),t[12]=n,t[13]=o,t[14]=a,t[15]=g):g=t[15];const v=g;let y;t[16]!==r.chart_max_rows_errors?(y=r.chart_max_rows_errors&&k.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."}),t[16]=r.chart_max_rows_errors,t[17]=y):y=t[17];const x=y;if(!(l||d||f||x)){let e;return t[18]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"}),t[18]=e):e=t[18],e}let w;return t[19]!==l||t[20]!==p||t[21]!==v||t[22]!==x||t[23]!==f||t[24]!==d?(w=k.jsxs("div",{className:"flex flex-col gap-2 relative",children:[l,p,v,x,f,d]}),t[19]=l,t[20]=p,t[21]=v,t[22]=x,t[23]=f,t[24]=d,t[25]=w):w=t[25],w};function eO(e){return e.source}function tO(e){return e}function nO(e){const[t]=e;return"memory"===t?0:1}function oO(e){const[t,n]=e;return null==n?null:k.jsxs("div",{className:"flex items-center gap-1 group",children:[k.jsx(GM,{className:"h-3 w-3 invisible group-hover:visible",value:String(n)}),k.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:t}),k.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:ms(n)})]},t)}function rO(e){return{...e,config:{...e.config,background:"transparent"}}}const aO=e=>{const t=b(4),{isOpen:n,children:o}=e,[r,a]=u.useState(!1);let i,s;return t[0]!==n||t[1]!==r?(i=()=>{n&&!r&&a(!0)},s=[n,r],t[0]=n,t[1]=r,t[2]=i,t[3]=s):(i=t[2],s=t[3]),u.useEffect(i,s),r?o:null},iO=Lr("marimo:scratchpadHistory:v1",[]),sO=Z(!1),lO=Z(null,((e,t,n)=>{if(!(n=n.trim()))return;const o=e(iO),r=[n,...o.filter((e=>e!==n))].slice(0,15);t(iO,r)})),cO={hide_code:!1,disabled:!1},dO=()=>{const e=b(79),t=W(),[n]=Oe(),{theme:o}=Me(),a=r.useRef(null),i=Rd(),{createNewCell:s,updateCellCode:l}=q(),c=t.cellRuntime[Te],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=t.cellData[Te],m=(null==f?void 0:f.code)??"",p=ce(lO),[g,v]=Le(sO),y=le(iO);let x;e[0]!==m||e[1]!==p?(x=()=>{ps({code:m}),p(m)},e[0]=m,e[1]=p,e[2]=x):x=e[2];const w=G(x);let E;e[3]!==m||e[4]!==s||e[5]!==i?(E=()=>{m.trim()&&s({code:m,before:!1,cellId:i??"__end__"})},e[3]=m,e[4]=s,e[5]=i,e[6]=E):E=e[6];const j=G(E);let _;e[7]!==l?(_=()=>{l({cellId:Te,code:"",formattingChange:!1}),ps({code:""});const e=a.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})},e[7]=l,e[8]=_):_=e[8];const I=G(_);let A;e[9]!==v||e[10]!==l?(A=e=>{v(!1),l({cellId:Te,code:e,formattingChange:!1});const t=a.current;t&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},e[9]=v,e[10]=l,e[11]=A):A=e[11];const T=G(A);let M,O,D,P,R,L,z,F;if(e[12]!==o||e[13]!==m||e[14]!==w||e[15]!==l||e[16]!==n||e[17]!==d||e[18]!==h||e[19]!==g||e[20]!==y||e[21]!==T||e[22]!==I||e[23]!==j||e[24]!==u||e[25]!==v){const t=()=>k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:k.jsx(Yb,{theme:o,allowFocus:!1,showPlaceholder:!1,id:Te,code:m,config:cO,status:"idle",serializedEditorState:null,runCell:w,updateCellCode:l,createNewCell:an.NOOP,deleteCell:an.NOOP,focusCell:an.NOOP,moveCell:an.NOOP,moveToNextCell:void 0,updateCellConfig:an.NOOP,clearSerializedEditorState:an.NOOP,userConfig:n,editorViewRef:a,hidden:!1})}),k.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:k.jsx(fa,{allowExpand:!1,output:d,className:"output-area",cellId:Te,stale:!1})}),k.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:k.jsx(fl,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:Ri,onSubmitDebugger:an.NOOP,cellId:Te,debuggerActive:!1})})]});let r;e[32]!==g||e[33]!==y||e[34]!==T||e[35]!==o?(r=()=>g?k.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:k.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:y.map(((e,t)=>k.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>T(e),children:k.jsx(Yi,{language:"python",theme:o,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:e.trim(),editable:!1,readOnly:!0})},t)))})}):null,e[32]=g,e[33]=y,e[34]=T,e[35]=o,e[36]=r):r=e[36];const i=r;let s,c,f,p,x,b,E,_,A;D="flex flex-col h-full overflow-hidden divide-y",e[37]===Symbol.for("react.memo_cache_sentinel")?(P=ft.create(Te),e[37]=P):P=e[37],e[38]===Symbol.for("react.memo_cache_sentinel")?(s=S("cell.run"),e[38]=s):s=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Ac,{color:"var(--grass-11)",size:16}),e[39]=c):c=e[39],e[40]!==w||e[41]!==g?(f=k.jsx(N,{content:s,children:k.jsx(C,{"data-testid":"scratchpad-run-button",onClick:w,disabled:g,variant:"text",size:"xs",children:c})}),e[40]=w,e[41]=g,e[42]=f):f=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(ac,{size:16}),e[43]=p):p=e[43],e[44]!==g||e[45]!==I?(x=k.jsx(N,{content:"Clear code and outputs",children:k.jsx(C,{disabled:g,size:"xs",variant:"text",onClick:I,children:p})}),e[44]=g,e[45]=I,e[46]=x):x=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(b=k.jsx(Wl,{size:16}),e[47]=b):b=e[47],e[48]!==g||e[49]!==j?(E=k.jsx(Du,{children:k.jsx(N,{content:"Insert code",children:k.jsx(C,{disabled:g,size:"xs",variant:"text",onClick:j,children:b})})}),e[48]=g,e[49]=j,e[50]=E):E=e[50],e[51]!==u?(_=("running"===u||"queued"===u)&&k.jsx(oi,{className:"inline",size:"small"}),e[51]=u,e[52]=_):_=e[52],e[53]===Symbol.for("react.memo_cache_sentinel")?(A=k.jsx("div",{className:"flex-1"}),e[53]=A):A=e[53];const z=g&&"bg-[var(--sky-3)] rounded-none";let F,B;e[54]!==z?(F=rn(z),e[54]=z,e[55]=F):F=e[55],e[56]!==v||e[57]!==g?(B=()=>v(!g),e[56]=v,e[57]=g,e[58]=B):B=e[58];const U=0===y.length;let V,H;e[59]===Symbol.for("react.memo_cache_sentinel")?(V=k.jsx(fc,{size:16}),e[59]=V):V=e[59],e[60]!==F||e[61]!==B||e[62]!==U?(H=k.jsx(N,{content:"Toggle history",children:k.jsx(C,{size:"xs",variant:"text",className:F,onClick:B,disabled:U,children:V})}),e[60]=F,e[61]=B,e[62]=U,e[63]=H):H=e[63],e[64]!==f||e[65]!==x||e[66]!==E||e[67]!==_||e[68]!==H?(R=k.jsxs("div",{className:"flex items-center flex-shrink-0",children:[f,x,E,_,A,H]}),e[64]=f,e[65]=x,e[66]=E,e[67]=_,e[68]=H,e[69]=R):R=e[69],M="flex-1 divide-y relative",O=t(),L=i(),e[12]=o,e[13]=m,e[14]=w,e[15]=l,e[16]=n,e[17]=d,e[18]=h,e[19]=g,e[20]=y,e[21]=T,e[22]=I,e[23]=j,e[24]=u,e[25]=v,e[26]=M,e[27]=O,e[28]=D,e[29]=P,e[30]=R,e[31]=L}else M=e[26],O=e[27],D=e[28],P=e[29],R=e[30],L=e[31];return e[70]!==M||e[71]!==O||e[72]!==L?(z=k.jsxs("div",{className:M,children:[O,L]}),e[70]=M,e[71]=O,e[72]=L,e[73]=z):z=e[73],e[74]!==D||e[75]!==P||e[76]!==R||e[77]!==z?(F=k.jsxs("div",{className:D,id:P,children:[R,z]}),e[74]=D,e[75]=P,e[76]=R,e[77]=z,e[78]=F):F=e[78],F},uO=()=>{const e=b(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(dO,{}),e[0]=t):t=e[0],t},hO=()=>{const e=b(16),[t]=Oe(),n=t.package_management.manager;let o;e[0]!==n?(o=[n],e[0]=n,e[1]=o):o=e[1];const{data:r,loading:a,error:i,reload:s}=sn(gO,o);if(a&&!r){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(oi,{size:"medium",centered:!0}),e[2]=t):t=e[2],t}if(i){let t;return e[3]!==i?(t=k.jsx(Vi,{error:i}),e[3]=i,e[4]=t):t=e[4],t}let l;e[5]!==(null==r?void 0:r.packages)?(l=(null==r?void 0:r.packages)||[],e[5]=null==r?void 0:r.packages,e[6]=l):l=e[6];const c=l;let d,u,h;return e[7]!==n||e[8]!==s?(d=k.jsx(fO,{packageManager:n,onSuccess:s}),e[7]=n,e[8]=s,e[9]=d):d=e[9],e[10]!==c||e[11]!==s?(u=k.jsx(mO,{packages:c,onSuccess:s}),e[10]=c,e[11]=s,e[12]=u):u=e[12],e[13]!==d||e[14]!==u?(h=k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[d,u]}),e[13]=d,e[14]=u,e[15]=h):h=e[15],h},fO=({onSuccess:e,packageManager:t})=>{const[n,o]=u.useState(""),[r,a]=u.useState(!1),i=async()=>{try{a(!0);const t=await ys({package:n});t.success?(e(),re({title:"Package added",description:k.jsxs("span",{children:["The package ",k.jsx(Ra,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):re({title:"Failed to add package",description:t.error,variant:"danger"})}finally{o(""),a(!1)}};return k.jsxs("div",{className:"flex items-center w-full border-b",children:[k.jsx(_i,{placeholder:`Install packages with ${t}...`,icon:r?k.jsx(oi,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):k.jsx(ql,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),i())},onChange:e=>o(e.target.value)}),k.jsx(N,{delayDuration:300,side:"left",align:"start",content:k.jsxs("div",{className:"text-sm flex flex-col w-full max-w-[360px]",children:["Packages are installed using the package manager specified in your user configuration. Depending on your package manager, you can install packages with various formats:",k.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",k.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",k.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",k.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",k.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",k.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:k.jsx(gs,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),k.jsx("button",{type:"button",className:rn("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",n&&"bg-accent text-accent-foreground","disabled:cursor-not-allowed disabled:opacity-50"),onClick:i,disabled:!n,children:"Add"})]})},mO=e=>{const t=b(9),{onSuccess:n,packages:o}=e;if(0===o.length){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(FS,{title:"No packages",description:"No packages are installed in this environment.",icon:k.jsx(ql,{})}),t[0]=e):e=t[0],e}let r,a,i;if(t[1]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(Ai,{children:k.jsxs(Ti,{children:[k.jsx(Mi,{children:"Name"}),k.jsx(Mi,{children:"Version"}),k.jsx(Mi,{})]})}),t[1]=r):r=t[1],t[2]!==n||t[3]!==o){let e;t[5]!==n?(e=e=>k.jsxs(Ti,{className:"group",onClick:async()=>{await et(`${e.name}==${e.version}`),re({title:"Copied to clipboard"})},children:[k.jsx(Pi,{children:e.name}),k.jsx(Pi,{children:e.version}),k.jsx(Pi,{children:k.jsx(pO,{packageName:e.name,onSuccess:n})})]},e.name),t[5]=n,t[6]=e):e=t[6],a=o.map(e),t[2]=n,t[3]=o,t[4]=a}else a=t[4];return t[7]!==a?(i=k.jsxs(Ii,{className:"overflow-auto flex-1",children:[r,k.jsx(Di,{children:a})]}),t[7]=a,t[8]=i):i=t[8],i},pO=({packageName:e,onSuccess:t})=>{const[n,o]=u.useState(!1);return n?k.jsx(oi,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):k.jsx("button",{type:"button",className:rn("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:tt.stopPropagation((async()=>{try{o(!0);const n=await xs({package:e});n.success?(t(),re({title:"Package removed",description:k.jsxs("span",{children:["The package ",k.jsx(Ra,{className:"inline",children:e})," has been removed from your environment."]})})):re({title:"Failed to add package",description:n.error,variant:"danger"})}finally{o(!1)}})),children:"Remove"})};function gO(){return vs()}function vO(...e){return t=>e.forEach((e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t)))}function yO(...e){return r.useCallback(vO(...e),e)}var xO=r.forwardRef(((e,t)=>{const{children:n,...o}=e,a=r.Children.toArray(n),i=a.find(kO);if(i){const e=i.props.children,n=a.map((t=>t===i?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:t));return k.jsx(bO,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return k.jsx(bO,{...o,ref:t,children:n})}));xO.displayName="Slot";var bO=r.forwardRef(((e,t)=>{const{children:n,...o}=e;if(r.isValidElement(n)){const e=function(e){var t,n;let o=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=o&&"isReactWarning"in o&&o.isReactWarning;if(r)return e.ref;if(o=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,r=o&&"isReactWarning"in o&&o.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n);return r.cloneElement(n,{...SO(o,n.props),ref:t?vO(t,e):e})}return r.Children.count(n)>1?r.Children.only(null):null}));bO.displayName="SlotClone";var wO=({children:e})=>k.jsx(k.Fragment,{children:e});function kO(e){return r.isValidElement(e)&&e.type===wO}function SO(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...e)=>{a(...e),r(...e)}:r&&(n[o]=r):"style"===o?n[o]={...r,...a}:"className"===o&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}var NO=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,t)=>{const n=r.forwardRef(((e,n)=>{const{asChild:o,...r}=e,a=o?xO:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),k.jsx(a,{...r,ref:n})}));return n.displayName=`Primitive.${t}`,{...e,[t]:n}}),{}),CO=Boolean(null==globalThis?void 0:globalThis.document)?r.useLayoutEffect:()=>{};var EO=e=>{const{present:t,children:n}=e,o=function(e){const[t,n]=r.useState(),o=r.useRef({}),a=r.useRef(e),i=r.useRef("none"),s=e?"mounted":"unmounted",[l,c]=function(e,t){return r.useReducer(((e,n)=>t[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=jO(o.current);i.current="mounted"===l?e:"none"}),[l]),CO((()=>{const t=o.current,n=a.current;if(n!==e){const o=i.current,r=jO(t);if(e)c("MOUNT");else if("none"===r||"none"===(null==t?void 0:t.display))c("UNMOUNT");else{c(n&&o!==r?"ANIMATION_OUT":"UNMOUNT")}a.current=e}}),[e,c]),CO((()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,r=r=>{const i=jO(o.current).includes(r.animationName);if(r.target===t&&i&&(c("ANIMATION_END"),!a.current)){const o=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=o)}))}},s=e=>{e.target===t&&(i.current=jO(o.current))};return t.addEventListener("animationstart",s),t.addEventListener("animationcancel",r),t.addEventListener("animationend",r),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",s),t.removeEventListener("animationcancel",r),t.removeEventListener("animationend",r)}}c("ANIMATION_END")}),[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{e&&(o.current=getComputedStyle(e)),n(e)}),[])}}(t),a="function"==typeof n?n({present:o.isPresent}):r.Children.only(n),i=yO(o.ref,function(e){var t,n;let o=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=o&&"isReactWarning"in o&&o.isReactWarning;if(r)return e.ref;if(o=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,r=o&&"isReactWarning"in o&&o.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(a));return"function"==typeof n||o.isPresent?r.cloneElement(a,{ref:i}):null};function jO(e){return(null==e?void 0:e.animationName)||"none"}function _O(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const o=n.reduce(((t,{useScope:n,scopeName:o})=>({...t,...n(e)[`__scope${o}`]})),{});return r.useMemo((()=>({[`__scope${t.scopeName}`]:o})),[o])}};return n.scopeName=t.scopeName,n}function IO(e){const t=r.useRef(e);return r.useEffect((()=>{t.current=e})),r.useMemo((()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[])}EO.displayName="Presence";var AO=r.createContext(void 0);function TO(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(null==e||e(o),!1===n||!o.defaultPrevented)return null==t?void 0:t(o)}}var MO="ScrollArea",[OO,DO]=function(e,t=[]){let n=[];const o=()=>{const t=n.map((e=>r.createContext(e)));return function(n){const o=(null==n?void 0:n[e])||t;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:o}})),[n,o])}};return o.scopeName=e,[function(t,o){const a=r.createContext(o),i=n.length;n=[...n,o];const s=t=>{var n;const{scope:o,children:s,...l}=t,c=(null==(n=null==o?void 0:o[e])?void 0:n[i])||a,d=r.useMemo((()=>l),Object.values(l));return k.jsx(c.Provider,{value:d,children:s})};return s.displayName=t+"Provider",[s,function(n,s){var l;const c=(null==(l=null==s?void 0:s[e])?void 0:l[i])||a,d=r.useContext(c);if(d)return d;if(void 0!==o)return o;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},_O(o,...t)]}(MO),[PO,RO]=OO(MO),LO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,type:o="hover",dir:a,scrollHideDelay:i=600,...s}=e,[l,c]=r.useState(null),[d,u]=r.useState(null),[h,f]=r.useState(null),[m,p]=r.useState(null),[g,v]=r.useState(null),[y,x]=r.useState(0),[b,w]=r.useState(0),[S,N]=r.useState(!1),[C,E]=r.useState(!1),j=yO(t,(e=>c(e))),_=function(e){const t=r.useContext(AO);return e||t||"ltr"}(a);return k.jsx(PO,{scope:n,type:o,dir:_,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:p,scrollbarXEnabled:S,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:C,onScrollbarYEnabledChange:E,onCornerWidthChange:x,onCornerHeightChange:w,children:k.jsx(NO.div,{dir:_,...s,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})}));LO.displayName=MO;var zO="ScrollAreaViewport",FO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,children:o,nonce:a,...i}=e,s=RO(zO,n),l=yO(t,r.useRef(null),s.onViewportChange);return k.jsxs(k.Fragment,{children:[k.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),k.jsx(NO.div,{"data-radix-scroll-area-viewport":"",...i,ref:l,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:k.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})}));FO.displayName=zO;var BO="ScrollAreaScrollbar",UO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=a,l="horizontal"===e.orientation;return r.useEffect((()=>(l?i(!0):s(!0),()=>{l?i(!1):s(!1)})),[l,i,s]),"hover"===a.type?k.jsx(VO,{...o,ref:t,forceMount:n}):"scroll"===a.type?k.jsx(HO,{...o,ref:t,forceMount:n}):"auto"===a.type?k.jsx($O,{...o,ref:t,forceMount:n}):"always"===a.type?k.jsx(WO,{...o,ref:t}):null}));UO.displayName=BO;var VO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),[i,s]=r.useState(!1);return r.useEffect((()=>{const e=a.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),s(!0)},o=()=>{t=window.setTimeout((()=>s(!1)),a.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",o),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",o)}}}),[a.scrollArea,a.scrollHideDelay]),k.jsx(EO,{present:n||i,children:k.jsx($O,{"data-state":i?"visible":"hidden",...o,ref:t})})})),HO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),i="horizontal"===e.orientation,s=dD((()=>c("SCROLL_END")),100),[l,c]=(d="hidden",u={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,t)=>u[e][t]??e),d));var d,u;return r.useEffect((()=>{if("idle"===l){const e=window.setTimeout((()=>c("HIDE")),a.scrollHideDelay);return()=>window.clearTimeout(e)}}),[l,a.scrollHideDelay,c]),r.useEffect((()=>{const e=a.viewport,t=i?"scrollLeft":"scrollTop";if(e){let n=e[t];const o=()=>{const o=e[t];n!==o&&(c("SCROLL"),s()),n=o};return e.addEventListener("scroll",o),()=>e.removeEventListener("scroll",o)}}),[a.viewport,i,c,s]),k.jsx(EO,{present:n||"hidden"!==l,children:k.jsx(WO,{"data-state":"hidden"===l?"hidden":"visible",...o,ref:t,onPointerEnter:TO(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:TO(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),$O=r.forwardRef(((e,t)=>{const n=RO(BO,e.__scopeScrollArea),{forceMount:o,...a}=e,[i,s]=r.useState(!1),l="horizontal"===e.orientation,c=dD((()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(l?e:t)}}),10);return uD(n.viewport,c),uD(n.content,c),k.jsx(EO,{present:o||i,children:k.jsx(WO,{"data-state":i?"visible":"hidden",...a,ref:t})})})),WO=r.forwardRef(((e,t)=>{const{orientation:n="vertical",...o}=e,a=RO(BO,e.__scopeScrollArea),i=r.useRef(null),s=r.useRef(0),[l,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=rD(l.viewport,l.content),u={...o,sizes:l,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e};function h(e,t){return function(e,t,n,o="ltr"){const r=aD(n),a=r/2,i=t||a,s=r-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-s,d=n.content-n.viewport,u="ltr"===o?[0,d]:[-1*d,0];return sD([l,c],u)(e)}(e,s.current,l,t)}return"horizontal"===n?k.jsx(GO,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const e=iD(a.viewport.scrollLeft,l,a.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollLeft=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollLeft=h(e,a.dir))}}):"vertical"===n?k.jsx(qO,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const e=iD(a.viewport.scrollTop,l);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollTop=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollTop=h(e))}}):null})),GO=r.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:o,...a}=e,i=RO(BO,e.__scopeScrollArea),[s,l]=r.useState(),c=r.useRef(null),d=yO(t,c,i.onScrollbarXChange);return r.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),k.jsx(KO,{"data-orientation":"horizontal",...a,ref:d,sizes:n,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":aD(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(i.viewport){const o=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(o),lD(o,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&o({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:oD(s.paddingLeft),paddingEnd:oD(s.paddingRight)}})}})})),qO=r.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:o,...a}=e,i=RO(BO,e.__scopeScrollArea),[s,l]=r.useState(),c=r.useRef(null),d=yO(t,c,i.onScrollbarYChange);return r.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),k.jsx(KO,{"data-orientation":"vertical",...a,ref:d,sizes:n,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":aD(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(i.viewport){const o=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(o),lD(o,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&o({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:oD(s.paddingTop),paddingEnd:oD(s.paddingBottom)}})}})})),[YO,XO]=OO(BO),KO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:a,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,m=RO(BO,n),[p,g]=r.useState(null),v=yO(t,(e=>g(e))),y=r.useRef(null),x=r.useRef(""),b=m.viewport,w=o.content-o.viewport,S=IO(u),N=IO(c),C=dD(h,10);function E(e){if(y.current){const t=e.clientX-y.current.left,n=e.clientY-y.current.top;d({x:t,y:n})}}return r.useEffect((()=>{const e=e=>{const t=e.target;(null==p?void 0:p.contains(t))&&S(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[b,p,w,S]),r.useEffect(N,[o,N]),uD(p,C),uD(m.content,C),k.jsx(YO,{scope:n,scrollbar:p,hasThumb:a,onThumbChange:IO(i),onThumbPointerUp:IO(s),onThumbPositionChange:N,onThumbPointerDown:IO(l),children:k.jsx(NO.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:TO(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),y.current=p.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),E(e)}})),onPointerMove:TO(e.onPointerMove,E),onPointerUp:TO(e.onPointerUp,(e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=x.current,m.viewport&&(m.viewport.style.scrollBehavior=""),y.current=null}))})})})),JO="ScrollAreaThumb",ZO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,r=XO(JO,e.__scopeScrollArea);return k.jsx(EO,{present:n||r.hasThumb,children:k.jsx(QO,{ref:t,...o})})})),QO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,style:o,...a}=e,i=RO(JO,n),s=XO(JO,n),{onThumbPositionChange:l}=s,c=yO(t,(e=>s.onThumbChange(e))),d=r.useRef(),u=dD((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=i.viewport;if(e){const t=()=>{if(u(),!d.current){const t=cD(e,l);d.current=t,l()}};return l(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[i.viewport,u,l]),k.jsx(NO.div,{"data-state":s.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:TO(e.onPointerDownCapture,(e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;s.onThumbPointerDown({x:n,y:o})})),onPointerUp:TO(e.onPointerUp,s.onThumbPointerUp)})}));ZO.displayName=JO;var eD="ScrollAreaCorner",tD=r.forwardRef(((e,t)=>{const n=RO(eD,e.__scopeScrollArea),o=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&o?k.jsx(nD,{...e,ref:t}):null}));tD.displayName=eD;var nD=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,...o}=e,a=RO(eD,n),[i,s]=r.useState(0),[l,c]=r.useState(0),d=Boolean(i&&l);return uD(a.scrollbarX,(()=>{var e;const t=(null==(e=a.scrollbarX)?void 0:e.offsetHeight)||0;a.onCornerHeightChange(t),c(t)})),uD(a.scrollbarY,(()=>{var e;const t=(null==(e=a.scrollbarY)?void 0:e.offsetWidth)||0;a.onCornerWidthChange(t),s(t)})),d?k.jsx(NO.div,{...o,ref:t,style:{width:i,height:l,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0,...e.style}}):null}));function oD(e){return e?parseInt(e,10):0}function rD(e,t){const n=e/t;return isNaN(n)?0:n}function aD(e){const t=rD(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-n)*t;return Math.max(o,18)}function iD(e,t,n="ltr"){const o=aD(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-r,i=t.content-t.viewport,s=a-o,l=function(e,[t,n]){return Math.min(n,Math.max(t,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return sD([0,i],[0,s])(l)}function sD(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function lD(e,t){return e>0&&e<t}var cD=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},o=0;return function r(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,s=n.top!==a.top;(i||s)&&t(),n=a,o=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(o)};function dD(e,t){const n=IO(e),o=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(o.current)),[]),r.useCallback((()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,t)}),[n,t])}function uD(e,t){const n=IO(t);CO((()=>{let t=0;if(e){const o=new ResizeObserver((()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));return o.observe(e),()=>{window.cancelAnimationFrame(t),o.unobserve(e)}}}),[e,n])}var hD=LO,fD=FO,mD=tD;const pD=r.forwardRef(((e,t)=>{const n=b(15);let o,r,a,i,s,l,c,d;return n[0]!==e?(({className:o,children:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o?(i=rn("relative overflow-hidden",o),n[4]=o,n[5]=i):i=n[5],n[6]!==r?(s=k.jsx(fD,{className:"h-full w-full rounded-[inherit]",children:r}),n[6]=r,n[7]=s):s=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(gD,{}),c=k.jsx(mD,{}),n[8]=l,n[9]=c):(l=n[8],c=n[9]),n[10]!==t||n[11]!==i||n[12]!==a||n[13]!==s?(d=k.jsxs(hD,{ref:t,className:i,...a,children:[s,l,c]}),n[10]=t,n[11]=i,n[12]=a,n[13]=s,n[14]=d):d=n[14],d}));pD.displayName=hD.displayName;const gD=r.forwardRef(((e,t)=>{const n=b(14);let o,r,a;n[0]!==e?(({className:r,orientation:o,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]);const i=void 0===o?"vertical":o,s="vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]",l="horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]";let c,d,u;return n[4]!==s||n[5]!==l||n[6]!==r?(c=rn("flex touch-none select-none transition-colors",s,l,r),n[4]=s,n[5]=l,n[6]=r,n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(ZO,{className:"relative flex-1 rounded-full bg-border"}),n[8]=d):d=n[8],n[9]!==t||n[10]!==i||n[11]!==c||n[12]!==a?(u=k.jsx(UO,{ref:t,orientation:i,className:c,...a,children:d}),n[9]=t,n[10]=i,n[11]=c,n[12]=a,n[13]=u):u=n[13],u}));gD.displayName=UO.displayName;const vD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xD={};function bD(e,t){return(xD.jsx?yD:vD).test(e)}const wD=/[ \t\n\f\r]/g;function kD(e){return""===e.replace(wD,"")}class SD{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function ND(e,t){const n={},o={};let r=-1;for(;++r<e.length;)Object.assign(n,e[r].property),Object.assign(o,e[r].normal);return new SD(n,o,t)}function CD(e){return e.toLowerCase()}SD.prototype.property={},SD.prototype.normal={},SD.prototype.space=null;class ED{constructor(e,t){this.property=e,this.attribute=t}}ED.prototype.space=null,ED.prototype.boolean=!1,ED.prototype.booleanish=!1,ED.prototype.overloadedBoolean=!1,ED.prototype.number=!1,ED.prototype.commaSeparated=!1,ED.prototype.spaceSeparated=!1,ED.prototype.commaOrSpaceSeparated=!1,ED.prototype.mustUseProperty=!1,ED.prototype.defined=!1;let jD=0;const _D=PD(),ID=PD(),AD=PD(),TD=PD(),MD=PD(),OD=PD(),DD=PD();function PD(){return 2**++jD}const RD=Object.freeze(Object.defineProperty({__proto__:null,boolean:_D,booleanish:ID,commaOrSpaceSeparated:DD,commaSeparated:OD,number:TD,overloadedBoolean:AD,spaceSeparated:MD},Symbol.toStringTag,{value:"Module"})),LD=Object.keys(RD);class zD extends ED{constructor(e,t,n,o){let r=-1;if(super(e,t),FD(this,"space",o),"number"==typeof n)for(;++r<LD.length;){const e=LD[r];FD(this,LD[r],(n&RD[e])===RD[e])}}}function FD(e,t,n){n&&(e[t]=n)}zD.prototype.defined=!0;const BD={}.hasOwnProperty;function UD(e){const t={},n={};let o;for(o in e.properties)if(BD.call(e.properties,o)){const r=e.properties[o],a=new zD(o,e.transform(e.attributes||{},o),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(o)&&(a.mustUseProperty=!0),t[o]=a,n[CD(o)]=o,n[CD(a.attribute)]=o}return new SD(t,n,e.space)}const VD=UD({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),HD=UD({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function $D(e,t){return t in e?e[t]:t}function WD(e,t){return $D(e,t.toLowerCase())}const GD=UD({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:WD,properties:{xmlns:null,xmlnsXLink:null}}),qD=UD({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:ID,ariaAutoComplete:null,ariaBusy:ID,ariaChecked:ID,ariaColCount:TD,ariaColIndex:TD,ariaColSpan:TD,ariaControls:MD,ariaCurrent:null,ariaDescribedBy:MD,ariaDetails:null,ariaDisabled:ID,ariaDropEffect:MD,ariaErrorMessage:null,ariaExpanded:ID,ariaFlowTo:MD,ariaGrabbed:ID,ariaHasPopup:null,ariaHidden:ID,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MD,ariaLevel:TD,ariaLive:null,ariaModal:ID,ariaMultiLine:ID,ariaMultiSelectable:ID,ariaOrientation:null,ariaOwns:MD,ariaPlaceholder:null,ariaPosInSet:TD,ariaPressed:ID,ariaReadOnly:ID,ariaRelevant:null,ariaRequired:ID,ariaRoleDescription:MD,ariaRowCount:TD,ariaRowIndex:TD,ariaRowSpan:TD,ariaSelected:ID,ariaSetSize:TD,ariaSort:null,ariaValueMax:TD,ariaValueMin:TD,ariaValueNow:TD,ariaValueText:null,role:null}}),YD=UD({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:WD,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:OD,acceptCharset:MD,accessKey:MD,action:null,allow:null,allowFullScreen:_D,allowPaymentRequest:_D,allowUserMedia:_D,alt:null,as:null,async:_D,autoCapitalize:null,autoComplete:MD,autoFocus:_D,autoPlay:_D,blocking:MD,capture:null,charSet:null,checked:_D,cite:null,className:MD,cols:TD,colSpan:null,content:null,contentEditable:ID,controls:_D,controlsList:MD,coords:TD|OD,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_D,defer:_D,dir:null,dirName:null,disabled:_D,download:AD,draggable:ID,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_D,formTarget:null,headers:MD,height:TD,hidden:_D,high:TD,href:null,hrefLang:null,htmlFor:MD,httpEquiv:MD,id:null,imageSizes:null,imageSrcSet:null,inert:_D,inputMode:null,integrity:null,is:null,isMap:_D,itemId:null,itemProp:MD,itemRef:MD,itemScope:_D,itemType:MD,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_D,low:TD,manifest:null,max:null,maxLength:TD,media:null,method:null,min:null,minLength:TD,multiple:_D,muted:_D,name:null,nonce:null,noModule:_D,noValidate:_D,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_D,optimum:TD,pattern:null,ping:MD,placeholder:null,playsInline:_D,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_D,referrerPolicy:null,rel:MD,required:_D,reversed:_D,rows:TD,rowSpan:TD,sandbox:MD,scope:null,scoped:_D,seamless:_D,selected:_D,shadowRootClonable:_D,shadowRootDelegatesFocus:_D,shadowRootMode:null,shape:null,size:TD,sizes:null,slot:null,span:TD,spellCheck:ID,src:null,srcDoc:null,srcLang:null,srcSet:null,start:TD,step:null,style:null,tabIndex:TD,target:null,title:null,translate:null,type:null,typeMustMatch:_D,useMap:null,value:ID,width:TD,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MD,axis:null,background:null,bgColor:null,border:TD,borderColor:null,bottomMargin:TD,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_D,declare:_D,event:null,face:null,frame:null,frameBorder:null,hSpace:TD,leftMargin:TD,link:null,longDesc:null,lowSrc:null,marginHeight:TD,marginWidth:TD,noResize:_D,noHref:_D,noShade:_D,noWrap:_D,object:null,profile:null,prompt:null,rev:null,rightMargin:TD,rules:null,scheme:null,scrolling:ID,standby:null,summary:null,text:null,topMargin:TD,valueType:null,version:null,vAlign:null,vLink:null,vSpace:TD,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_D,disableRemotePlayback:_D,prefix:null,property:null,results:TD,security:null,unselectable:null}}),XD=UD({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:$D,properties:{about:DD,accentHeight:TD,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:TD,amplitude:TD,arabicForm:null,ascent:TD,attributeName:null,attributeType:null,azimuth:TD,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:TD,by:null,calcMode:null,capHeight:TD,className:MD,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:TD,diffuseConstant:TD,direction:null,display:null,dur:null,divisor:TD,dominantBaseline:null,download:_D,dx:null,dy:null,edgeMode:null,editable:null,elevation:TD,enableBackground:null,end:null,event:null,exponent:TD,externalResourcesRequired:null,fill:null,fillOpacity:TD,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:OD,g2:OD,glyphName:OD,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:TD,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:TD,horizOriginX:TD,horizOriginY:TD,id:null,ideographic:TD,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:TD,k:TD,k1:TD,k2:TD,k3:TD,k4:TD,kernelMatrix:DD,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:TD,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:TD,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:TD,overlineThickness:TD,paintOrder:null,panose1:null,path:null,pathLength:TD,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MD,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:TD,pointsAtY:TD,pointsAtZ:TD,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:DD,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:DD,rev:DD,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:DD,requiredFeatures:DD,requiredFonts:DD,requiredFormats:DD,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:TD,specularExponent:TD,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:TD,strikethroughThickness:TD,string:null,stroke:null,strokeDashArray:DD,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:TD,strokeOpacity:TD,strokeWidth:null,style:null,surfaceScale:TD,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:DD,tabIndex:TD,tableValues:null,target:null,targetX:TD,targetY:TD,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:DD,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:TD,underlineThickness:TD,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:TD,values:null,vAlphabetic:TD,vMathematical:TD,vectorEffect:null,vHanging:TD,vIdeographic:TD,version:null,vertAdvY:TD,vertOriginX:TD,vertOriginY:TD,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:TD,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),KD=/^data[-\w.:]+$/i,JD=/-[a-z]/g,ZD=/[A-Z]/g;function QD(e){return"-"+e.toLowerCase()}function eP(e){return e.charAt(1).toUpperCase()}const tP={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},nP=ND([HD,VD,GD,qD,YD],"html"),oP=ND([HD,VD,GD,qD,XD],"svg");const rP=bs.default||bs,aP=sP("end"),iP=sP("start");function sP(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function lP(e){return e&&"object"==typeof e?"position"in e||"type"in e?dP(e.position):"start"in e||"end"in e?dP(e):"line"in e||"column"in e?cP(e):"":""}function cP(e){return uP(e&&e.line)+":"+uP(e&&e.column)}function dP(e){return cP(e&&e.start)+"-"+cP(e&&e.end)}function uP(e){return e&&"number"==typeof e?e:1}class hP extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let o="",r={},a=!1;if(t&&(r="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?o=e:!r.cause&&e&&(a=!0,o=e.message,r.cause=e),!r.ruleId&&!r.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?r.ruleId=n:(r.source=n.slice(0,e),r.ruleId=n.slice(e+1))}if(!r.place&&r.ancestors&&r.ancestors){const e=r.ancestors[r.ancestors.length-1];e&&(r.place=e.position)}const i=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file,this.message=o,this.line=i?i.line:void 0,this.name=lP(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=a&&r.cause&&"string"==typeof r.cause.stack?r.cause.stack:"",this.actual,this.expected,this.note,this.url}}hP.prototype.file="",hP.prototype.name="",hP.prototype.reason="",hP.prototype.message="",hP.prototype.stack="",hP.prototype.column=void 0,hP.prototype.line=void 0,hP.prototype.ancestors=void 0,hP.prototype.cause=void 0,hP.prototype.fatal=void 0,hP.prototype.place=void 0,hP.prototype.ruleId=void 0,hP.prototype.source=void 0;const fP={}.hasOwnProperty,mP=new Map,pP=/[A-Z]/g,gP=/-([a-z])/g,vP=new Set(["table","tbody","thead","tfoot","tr"]),yP=new Set(["td","th"]),xP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function bP(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let o;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=function(e,t){return n;function n(n,o,r,a){const i=Array.isArray(r.children),s=iP(n);return t(o,r,a,i,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");o=function(e,t,n){return o;function o(e,o,r,a){const i=Array.isArray(r.children)?n:t;return a?i(o,r,a):i(o,r)}}(0,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?oP:nP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},a=wP(r,e,void 0);return a&&"string"!=typeof a?a:r.create(e,r.Fragment,{children:a||void 0},void 0)}function wP(e,t,n){return"element"===t.type?function(e,t,n){const o=e.schema;let r=o;"svg"===t.tagName.toLowerCase()&&"html"===o.space&&(r=oP,e.schema=r);e.ancestors.push(t);const a=EP(e,t.tagName,!1),i=function(e,t){const n={};let o,r;for(r in t.properties)if("children"!==r&&fP.call(t.properties,r)){const a=CP(e,r,t.properties[r]);if(a){const[r,i]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof i&&yP.has(t.tagName)?o=i:n[r]=i}}if(o){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=o}return n}(e,t);let s=NP(e,t);vP.has(t.tagName)&&(s=s.filter((function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&kD(t.value):kD(t));var t})));return kP(e,i,a,t),SP(i,s),e.ancestors.pop(),e.schema=o,e.create(t,a,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}jP(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const o=e.schema;let r=o;"svg"===t.name&&"html"===o.space&&(r=oP,e.schema=r);e.ancestors.push(t);const a=null===t.name?e.Fragment:EP(e,t.name,!0),i=function(e,t){const n={};for(const o of t.attributes)if("mdxJsxExpressionAttribute"===o.type)if(o.data&&o.data.estree&&e.evaluater){const t=o.data.estree.body[0];t.type;const r=t.expression;r.type;const a=r.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else jP(e,t.position);else{const r=o.name;let a;if(o.value&&"object"==typeof o.value)if(o.value.data&&o.value.data.estree&&e.evaluater){const t=o.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else jP(e,t.position);else a=null===o.value||o.value;n[r]=a}return n}(e,t),s=NP(e,t);return kP(e,i,a,t),SP(i,s),e.ancestors.pop(),e.schema=o,e.create(t,a,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);jP(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const o={};return SP(o,NP(e,t)),e.create(t,e.Fragment,o,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function kP(e,t,n,o){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=o)}function SP(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function NP(e,t){const n=[];let o=-1;const r=e.passKeys?new Map:mP;for(;++o<t.children.length;){const a=t.children[o];let i;if(e.passKeys){const e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){const t=r.get(e)||0;i=e+"-"+t,r.set(e,t+1)}}const s=wP(e,a,i);void 0!==s&&n.push(s)}return n}function CP(e,t,n){const o=function(e,t){const n=CD(t);let o=t,r=ED;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&KD.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(JD,eP);o="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!JD.test(e)){let n=e.replace(ZD,QD);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}r=zD}return new r(o,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=o.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===o.property){let t="object"==typeof n?n:function(e,t){const n={};try{rP(t,o)}catch(r){if(!e.ignoreInvalidStyle){const t=r,n=new hP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=xP+"#cannot-parse-style-attribute",n}}return n;function o(e,t){let o=e;"--"!==o.slice(0,2)&&("-ms-"===o.slice(0,4)&&(o="ms-"+o.slice(4)),o=o.replace(gP,IP)),n[o]=t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)fP.call(e,n)&&(t[_P(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&o.space?tP[o.property]||o.property:o.attribute,n]}}function EP(e,t,n){let o;if(n)if(t.includes(".")){const e=t.split(".");let n,r=-1;for(;++r<e.length;){const t=bD(e[r])?{type:"Identifier",name:e[r]}:{type:"Literal",value:e[r]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(r&&"Literal"===t.type),optional:!1}:t}o=n}else o=bD(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else o={type:"Literal",value:t};if("Literal"===o.type){const t=o.value;return fP.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(o);jP(e)}function jP(e,t){const n=new hP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=xP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function _P(e){let t=e.replace(pP,AP);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function IP(e,t){return t.toUpperCase()}function AP(e){return"-"+e.toLowerCase()}const TP={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},MP={};function OP(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return DP(e.children,t,n)}return Array.isArray(e)?DP(e,t,n):""}function DP(e,t,n){const o=[];let r=-1;for(;++r<e.length;)o[r]=OP(e[r],t,n);return o.join("")}const PP=document.createElement("i");function RP(e){const t="&"+e+";";PP.innerHTML=t;const n=PP.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function LP(e,t,n,o){const r=e.length;let a,i=0;if(t=t<0?-t>r?0:r+t:t>r?r:t,n=n>0?n:0,o.length<1e4)a=Array.from(o),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<o.length;)a=o.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function zP(e,t){return e.length>0?(LP(e,e.length,0,t),e):t}const FP={}.hasOwnProperty;function BP(e,t){let n;for(n in t){const o=(FP.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let a;if(r)for(a in r){FP.call(o,a)||(o[a]=[]);const e=r[a];UP(o[a],Array.isArray(e)?e:e?[e]:[])}}}function UP(e,t){let n=-1;const o=[];for(;++n<t.length;)("after"===t[n].add?e:o).push(t[n]);LP(e,0,0,o)}function VP(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function HP(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $P=nR(/[A-Za-z]/),WP=nR(/[\dA-Za-z]/),GP=nR(/[#-'*+\--9=?A-Z^-~]/);function qP(e){return null!==e&&(e<32||127===e)}const YP=nR(/\d/),XP=nR(/[\dA-Fa-f]/),KP=nR(/[!-/:-@[-`{-~]/);function JP(e){return null!==e&&e<-2}function ZP(e){return null!==e&&(e<0||32===e)}function QP(e){return-2===e||-1===e||32===e}const eR=nR(new RegExp("\\p{P}|\\p{S}","u")),tR=nR(/\s/);function nR(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function oR(e){const t=[];let n=-1,o=0,r=0;for(;++n<e.length;){const a=e.charCodeAt(n);let i="";if(37===a&&WP(e.charCodeAt(n+1))&&WP(e.charCodeAt(n+2)))r=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(i=String.fromCharCode(a));else if(a>55295&&a<57344){const t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(i=String.fromCharCode(a,t),r=1):i="�"}else i=String.fromCharCode(a);i&&(t.push(e.slice(o,n),encodeURIComponent(i)),o=n+r+1,i=""),r&&(n+=r,r=0)}return t.join("")+e.slice(o)}function rR(e,t,n,o){const r=o?o-1:Number.POSITIVE_INFINITY;let a=0;return function(o){if(QP(o))return e.enter(n),i(o);return t(o)};function i(o){return QP(o)&&a++<r?(e.consume(o),i):(e.exit(n),t(o))}}const aR={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,(function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),rR(e,t,"linePrefix")}),(function(t){return e.enter("paragraph"),o(t)}));let n;return t;function o(t){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,r(t)}function r(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):JP(t)?(e.consume(t),e.exit("chunkText"),o):(e.consume(t),r)}}};const iR={tokenize:function(e){const t=this,n=[];let o,r,a,i=0;return s;function s(o){if(i<n.length){const r=n[i];return t.containerState=r[1],e.attempt(r[0].continuation,l,c)(o)}return c(o)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&y();const n=t.events.length;let r,a=n;for(;a--;)if("exit"===t.events[a][0]&&"chunkFlow"===t.events[a][1].type){r=t.events[a][1].end;break}v(i);let s=n;for(;s<t.events.length;)t.events[s][1].end={...r},s++;return LP(t.events,a+1,0,t.events.slice(n)),t.events.length=s,c(e)}return s(e)}function c(r){if(i===n.length){if(!o)return h(r);if(o.currentConstruct&&o.currentConstruct.concrete)return m(r);t.interrupt=Boolean(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(sR,d,u)(r)}function d(e){return o&&y(),v(i),h(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,a=t.now().offset,m(e)}function h(n){return t.containerState={},e.attempt(sR,f,m)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),h(e)}function m(n){return null===n?(o&&y(),v(0),void e.consume(n)):(o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:r}),p(n))}function p(n){return null===n?(g(e.exit("chunkFlow"),!0),v(0),void e.consume(n)):JP(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,s):(e.consume(n),p)}function g(e,n){const s=t.sliceStream(e);if(n&&s.push(null),e.previous=r,r&&(r.next=e),r=e,o.defineSkip(e.start),o.write(s),t.parser.lazy[e.start.line]){let e=o.events.length;for(;e--;)if(o.events[e][1].start.offset<a&&(!o.events[e][1].end||o.events[e][1].end.offset>a))return;const n=t.events.length;let r,s,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(r){s=t.events[l][1].end;break}r=!0}for(v(i),e=n;e<t.events.length;)t.events[e][1].end={...s},e++;LP(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function v(o){let r=n.length;for(;r-- >o;){const o=n[r];t.containerState=o[1],o[0].exit.call(t,e)}n.length=o}function y(){o.write([null]),r=void 0,o=void 0,t.containerState._closeFlow=void 0}}},sR={tokenize:function(e,t,n){return rR(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function lR(e){return null===e||ZP(e)||tR(e)?1:eR(e)?2:void 0}function cR(e,t,n){const o=[];let r=-1;for(;++r<e.length;){const a=e[r].resolveAll;a&&!o.includes(a)&&(t=a(t,n),o.push(a))}return t}const dR={name:"attention",resolveAll:function(e,t){let n,o,r,a,i,s,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close)for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},h={...e[d][1].start};uR(u,-s),uR(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:s>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},r={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},o={type:s>1?"strong":"emphasis",start:{...a.start},end:{...i.end}},e[n][1].end={...a.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=zP(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=zP(l,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",r,t]]),l=zP(l,cR(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=zP(l,[["exit",r,t],["enter",i,t],["exit",i,t],["exit",o,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=zP(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,LP(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,o=this.previous,r=lR(o);let a;return function(t){return a=t,e.enter("attentionSequence"),i(t)};function i(s){if(s===a)return e.consume(s),i;const l=e.exit("attentionSequence"),c=lR(s),d=!c||2===c&&r||n.includes(s),u=!r||2===r&&c||n.includes(o);return l._open=Boolean(42===a?d:d&&(r||!u)),l._close=Boolean(42===a?u:u&&(c||!d)),t(s)}}};function uR(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const hR={name:"autolink",tokenize:function(e,t,n){let o=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),r};function r(t){return $P(t)?(e.consume(t),a):64===t?n(t):l(t)}function a(e){return 43===e||45===e||46===e||WP(e)?(o=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),o=0,s):(43===t||45===t||46===t||WP(t))&&o++<32?(e.consume(t),i):(o=0,l(t))}function s(o){return 62===o?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):null===o||32===o||60===o||qP(o)?n(o):(e.consume(o),s)}function l(t){return 64===t?(e.consume(t),c):GP(t)?(e.consume(t),l):n(t)}function c(e){return WP(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),o=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||WP(t))&&o++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const fR={partial:!0,tokenize:function(e,t,n){return function(t){return QP(t)?rR(e,o,"linePrefix")(t):o(t)};function o(e){return null===e||JP(e)?t(e):n(e)}}};const mR={continuation:{tokenize:function(e,t,n){const o=this;return function(t){if(QP(t))return rR(e,r,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return r(t)};function r(o){return e.attempt(mR,t,n)(o)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const o=this;return function(t){if(62===t){const n=o.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),r}return n(t)};function r(n){return QP(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const pR={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),o};function o(o){return KP(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}};const gR={name:"characterReference",tokenize:function(e,t,n){const o=this;let r,a,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,a=WP,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,a=XP,c):(e.enter("characterReferenceValue"),r=7,a=YP,c(t))}function c(s){if(59===s&&i){const r=e.exit("characterReferenceValue");return a!==WP||RP(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return a(s)&&i++<r?(e.consume(s),c):n(s)}}};const vR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(e){return o.parser.lazy[o.now().line]?n(e):t(e)}}},yR={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const o=this,r={partial:!0,tokenize:function(e,t,n){let r=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),QP(t)?rR(e,c,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===a?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===a?(r++,e.consume(t),d):r>=s?(e.exit("codeFencedFenceSequence"),QP(t)?rR(e,u,"whitespace")(t):u(t)):n(t)}function u(o){return null===o||JP(o)?(e.exit("codeFencedFence"),t(o)):n(o)}}};let a,i=0,s=0;return function(t){return function(t){const n=o.events[o.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,a=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===a?(s++,e.consume(t),l):s<3?n(t):(e.exit("codeFencedFenceSequence"),QP(t)?rR(e,c,"whitespace")(t):c(t))}function c(n){return null===n||JP(n)?(e.exit("codeFencedFence"),o.interrupt?t(n):e.check(vR,f,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||JP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):QP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),rR(e,u,"whitespace")(t)):96===t&&t===a?n(t):(e.consume(t),d)}function u(t){return null===t||JP(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||JP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===a?n(t):(e.consume(t),h)}function f(t){return e.attempt(r,y,m)(t)}function m(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return i>0&&QP(t)?rR(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||JP(t)?e.check(vR,f,y)(t):(e.enter("codeFlowValue"),v(t))}function v(t){return null===t||JP(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),v)}function y(n){return e.exit("codeFenced"),t(n)}}};const xR={name:"codeIndented",tokenize:function(e,t,n){const o=this;return function(t){return e.enter("codeIndented"),rR(e,r,"linePrefix",5)(t)};function r(e){const t=o.events[o.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?a(e):n(e)}function a(t){return null===t?s(t):JP(t)?e.attempt(bR,a,s)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||JP(t)?(e.exit("codeFlowValue"),a(t)):(e.consume(t),i)}function s(n){return e.exit("codeIndented"),t(n)}}},bR={partial:!0,tokenize:function(e,t,n){const o=this;return r;function r(t){return o.parser.lazy[o.now().line]?n(t):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r):rR(e,a,"linePrefix",5)(t)}function a(e){const a=o.events[o.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):JP(e)?r(e):n(e)}}};const wR={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,o=e.length-4,r=3;if(!("lineEnding"!==e[r][1].type&&"space"!==e[r][1].type||"lineEnding"!==e[o][1].type&&"space"!==e[o][1].type))for(t=r;++t<o;)if("codeTextData"===e[t][1].type){e[r][1].type="codeTextPadding",e[o][1].type="codeTextPadding",r+=2,o-=2;break}t=r-1,o++;for(;++t<=o;)void 0===n?t!==o&&"lineEnding"!==e[t][1].type&&(n=t):t!==o&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),o-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let o,r,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),a++,i):(e.exit("codeTextSequence"),s(t))}function s(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),s):96===t?(r=e.enter("codeTextSequence"),o=0,c(t)):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||JP(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),o++,c):o===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(r.type="codeTextData",l(n))}}};class kR{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const o=t||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return n&&SR(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),SR(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),SR(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);SR(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);SR(this.left,t.reverse())}}}function SR(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function NR(e){const t={};let n,o,r,a,i,s,l,c=-1;const d=new kR(e);for(;++c<d.length;){for(;c in t;)c=t[c];if(n=d.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&(s=n[1]._tokenizer.events,r=0,r<s.length&&"lineEndingBlank"===s[r][1].type&&(r+=2),r<s.length&&"content"===s[r][1].type))for(;++r<s.length&&"content"!==s[r][1].type;)"chunkText"===s[r][1].type&&(s[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,CR(d,c)),c=t[c],l=!0);else if(n[1]._container){for(r=c,o=void 0;r--&&(a=d.get(r),"lineEnding"===a[1].type||"lineEndingBlank"===a[1].type);)"enter"===a[0]&&(o&&(d.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=r);o&&(n[1].end={...d.get(o)[1].start},i=d.slice(o,c),i.unshift(n),d.splice(o,c-o+1,i))}}return LP(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function CR(e,t){const n=e.get(t)[1],o=e.get(t)[2];let r=t-1;const a=[],i=n._tokenizer||o.parser[n.contentType](n.start),s=i.events,l=[],c={};let d,u,h=-1,f=n,m=0,p=0;const g=[p];for(;f;){for(;e.get(++r)[1]!==f;);a.push(r),f._tokenizer||(d=o.sliceStream(f),f.next||d.push(null),u&&i.defineSkip(f.start),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=f,f=f.next}for(f=n;++h<s.length;)"exit"===s[h][0]&&"enter"===s[h-1][0]&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(p=h+1,g.push(p),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(i.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),h=g.length;h--;){const t=s.slice(g[h],g[h+1]),n=a.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),h=-1;++h<l.length;)c[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return c}const ER={resolve:function(e){return NR(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(t)};function o(t){return null===t?r(t):JP(t)?e.check(jR,a,r)(t):(e.consume(t),o)}function r(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}},jR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),rR(e,r,"linePrefix")};function r(r){if(null===r||JP(r))return n(r);const a=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(r):e.interrupt(o.parser.constructs.flow,n,t)(r)}}};function _R(e,t,n,o,r,a,i,s,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(o),e.enter(r),e.enter(a),e.consume(t),e.exit(a),u;if(null===t||32===t||41===t||qP(t))return n(t);return e.enter(o),e.enter(i),e.enter(s),e.enter("chunkString",{contentType:"string"}),m(t)};function u(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),e.exit(o),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),u(t)):null===t||60===t||JP(t)?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function m(r){return d||null!==r&&41!==r&&!ZP(r)?d<c&&40===r?(e.consume(r),d++,m):41===r?(e.consume(r),d--,m):null===r||32===r||40===r||qP(r)?n(r):(e.consume(r),92===r?p:m):(e.exit("chunkString"),e.exit(s),e.exit(i),e.exit(o),t(r))}function p(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function IR(e,t,n,o,r,a){const i=this;let s,l=0;return function(t){return e.enter(o),e.enter(r),e.consume(t),e.exit(r),e.enter(a),c};function c(u){return l>999||null===u||91===u||93===u&&!s||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(a),e.enter(r),e.consume(u),e.exit(r),e.exit(o),t):JP(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||JP(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),s||(s=!QP(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function AR(e,t,n,o,r,a){let i;return function(t){if(34===t||39===t||40===t)return e.enter(o),e.enter(r),e.consume(t),e.exit(r),i=40===t?41:t,s;return n(t)};function s(n){return n===i?(e.enter(r),e.consume(n),e.exit(r),e.exit(o),t):(e.enter(a),l(n))}function l(t){return t===i?(e.exit(a),s(i)):null===t?n(t):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),rR(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||JP(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function TR(e,t){let n;return function o(r){if(JP(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,o;if(QP(r))return rR(e,o,n?"linePrefix":"lineSuffix")(r);return t(r)}}const MR={name:"definition",tokenize:function(e,t,n){const o=this;let r;return function(t){return e.enter("definition"),function(t){return IR.call(o,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function a(t){return r=HP(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return ZP(t)?TR(e,s)(t):s(t)}function s(t){return _R(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(OR,c,c)(t)}function c(t){return QP(t)?rR(e,d,"whitespace")(t):d(t)}function d(a){return null===a||JP(a)?(e.exit("definition"),o.parser.defined.push(r),t(a)):n(a)}}},OR={partial:!0,tokenize:function(e,t,n){return function(t){return ZP(t)?TR(e,o)(t):n(t)};function o(t){return AR(e,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function r(t){return QP(t)?rR(e,a,"whitespace")(t):a(t)}function a(e){return null===e||JP(e)?t(e):n(e)}}};const DR={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),o};function o(o){return JP(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}};const PR={name:"headingAtx",resolve:function(e,t){let n,o,r=e.length-2,a=3;"whitespace"===e[a][1].type&&(a+=2);r-2>a&&"whitespace"===e[r][1].type&&(r-=2);"atxHeadingSequence"===e[r][1].type&&(a===r-1||r-4>a&&"whitespace"===e[r-2][1].type)&&(r-=a+1===r?2:4);r>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[r][1].end},o={type:"chunkText",start:e[a][1].start,end:e[r][1].end,contentType:"text"},LP(e,a,r-a+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let o=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),r(t)}(t)};function r(t){return 35===t&&o++<6?(e.consume(t),r):null===t||ZP(t)?(e.exit("atxHeadingSequence"),a(t)):n(t)}function a(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||JP(n)?(e.exit("atxHeading"),t(n)):QP(n)?rR(e,a,"whitespace")(n):(e.enter("atxHeadingText"),s(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),a(t))}function s(t){return null===t||35===t||ZP(t)?(e.exit("atxHeadingText"),a(t)):(e.consume(t),s)}}};const RR=["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","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],LR=["pre","script","style","textarea"],zR={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const o=this;let r,a,i,s,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(s){return 33===s?(e.consume(s),d):47===s?(e.consume(s),a=!0,f):63===s?(e.consume(s),r=3,o.interrupt?t:D):$P(s)?(e.consume(s),i=String.fromCharCode(s),m):n(s)}function d(a){return 45===a?(e.consume(a),r=2,u):91===a?(e.consume(a),r=5,s=0,h):$P(a)?(e.consume(a),r=4,o.interrupt?t:D):n(a)}function u(r){return 45===r?(e.consume(r),o.interrupt?t:D):n(r)}function h(r){const a="CDATA[";return r===a.charCodeAt(s++)?(e.consume(r),6===s?o.interrupt?t:E:h):n(r)}function f(t){return $P(t)?(e.consume(t),i=String.fromCharCode(t),m):n(t)}function m(s){if(null===s||47===s||62===s||ZP(s)){const l=47===s,c=i.toLowerCase();return l||a||!LR.includes(c)?RR.includes(i.toLowerCase())?(r=6,l?(e.consume(s),p):o.interrupt?t(s):E(s)):(r=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(s):a?g(s):v(s)):(r=1,o.interrupt?t(s):E(s))}return 45===s||WP(s)?(e.consume(s),i+=String.fromCharCode(s),m):n(s)}function p(r){return 62===r?(e.consume(r),o.interrupt?t:E):n(r)}function g(t){return QP(t)?(e.consume(t),g):N(t)}function v(t){return 47===t?(e.consume(t),N):58===t||95===t||$P(t)?(e.consume(t),y):QP(t)?(e.consume(t),v):N(t)}function y(t){return 45===t||46===t||58===t||95===t||WP(t)?(e.consume(t),y):x(t)}function x(t){return 61===t?(e.consume(t),b):QP(t)?(e.consume(t),x):v(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):QP(t)?(e.consume(t),b):k(t)}function w(t){return t===l?(e.consume(t),l=null,S):null===t||JP(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||ZP(t)?x(t):(e.consume(t),k)}function S(e){return 47===e||62===e||QP(e)?v(e):n(e)}function N(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||JP(t)?E(t):QP(t)?(e.consume(t),C):n(t)}function E(t){return 45===t&&2===r?(e.consume(t),A):60===t&&1===r?(e.consume(t),T):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),D):93===t&&5===r?(e.consume(t),O):!JP(t)||6!==r&&7!==r?null===t||JP(t)?(e.exit("htmlFlowData"),j(t)):(e.consume(t),E):(e.exit("htmlFlowData"),e.check(FR,R,j)(t))}function j(t){return e.check(BR,_,R)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||JP(t)?j(t):(e.enter("htmlFlowData"),E(t))}function A(t){return 45===t?(e.consume(t),D):E(t)}function T(t){return 47===t?(e.consume(t),i="",M):E(t)}function M(t){if(62===t){const n=i.toLowerCase();return LR.includes(n)?(e.consume(t),P):E(t)}return $P(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),M):E(t)}function O(t){return 93===t?(e.consume(t),D):E(t)}function D(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),D):E(t)}function P(t){return null===t||JP(t)?(e.exit("htmlFlowData"),R(t)):(e.consume(t),P)}function R(n){return e.exit("htmlFlow"),t(n)}}},FR={partial:!0,tokenize:function(e,t,n){return function(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(fR,t,n)}}},BR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){if(JP(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r;return n(t)};function r(e){return o.parser.lazy[o.now().line]?n(e):t(e)}}};const UR={name:"htmlText",tokenize:function(e,t,n){const o=this;let r,a,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),b):63===t?(e.consume(t),y):$P(t)?(e.consume(t),S):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),a=0,f):$P(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):JP(t)?(i=d,M(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),h):d(t)}function h(e){return 62===e?T(e):45===e?u(e):d(e)}function f(t){const o="CDATA[";return t===o.charCodeAt(a++)?(e.consume(t),6===a?m:f):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),p):JP(t)?(i=m,M(t)):(e.consume(t),m)}function p(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?T(t):93===t?(e.consume(t),g):m(t)}function v(t){return null===t||62===t?T(t):JP(t)?(i=v,M(t)):(e.consume(t),v)}function y(t){return null===t?n(t):63===t?(e.consume(t),x):JP(t)?(i=y,M(t)):(e.consume(t),y)}function x(e){return 62===e?T(e):y(e)}function b(t){return $P(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||WP(t)?(e.consume(t),w):k(t)}function k(t){return JP(t)?(i=k,M(t)):QP(t)?(e.consume(t),k):T(t)}function S(t){return 45===t||WP(t)?(e.consume(t),S):47===t||62===t||ZP(t)?N(t):n(t)}function N(t){return 47===t?(e.consume(t),T):58===t||95===t||$P(t)?(e.consume(t),C):JP(t)?(i=N,M(t)):QP(t)?(e.consume(t),N):T(t)}function C(t){return 45===t||46===t||58===t||95===t||WP(t)?(e.consume(t),C):E(t)}function E(t){return 61===t?(e.consume(t),j):JP(t)?(i=E,M(t)):QP(t)?(e.consume(t),E):N(t)}function j(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,_):JP(t)?(i=j,M(t)):QP(t)?(e.consume(t),j):(e.consume(t),I)}function _(t){return t===r?(e.consume(t),r=void 0,A):null===t?n(t):JP(t)?(i=_,M(t)):(e.consume(t),_)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||ZP(t)?N(t):(e.consume(t),I)}function A(e){return 47===e||62===e||ZP(e)?N(e):n(e)}function T(o){return 62===o?(e.consume(o),e.exit("htmlTextData"),e.exit("htmlText"),t):n(o)}function M(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),O}function O(t){return QP(t)?rR(e,D,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),i(t)}}};const VR={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const o=e[t][1];if(n.push(e[t]),"labelImage"===o.type||"labelLink"===o.type||"labelEnd"===o.type){const e="labelImage"===o.type?4:2;o.type="data",t+=e}}e.length!==n.length&&LP(e,0,e.length,n);return e},resolveTo:function(e,t){let n,o,r,a,i=e.length,s=0;for(;i--;)if(n=e[i][1],o){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(r){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(o=i,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(r=i);const l={type:"labelLink"===e[o][1].type?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[o][1].start},end:{...e[r][1].end}},d={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[r-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=zP(a,e.slice(o+1,o+s+3)),a=zP(a,[["enter",d,t]]),a=zP(a,cR(t.parser.constructs.insideSpan.null,e.slice(o+s+4,r-3),t)),a=zP(a,[["exit",d,t],e[r-2],e[r-1],["exit",c,t]]),a=zP(a,e.slice(r+1)),a=zP(a,[["exit",l,t]]),LP(e,o,e.length,a),e},tokenize:function(e,t,n){const o=this;let r,a,i=o.events.length;for(;i--;)if(("labelImage"===o.events[i][1].type||"labelLink"===o.events[i][1].type)&&!o.events[i][1]._balanced){r=o.events[i][1];break}return function(t){if(!r)return n(t);if(r._inactive)return d(t);return a=o.parser.defined.includes(HP(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s};function s(t){return 40===t?e.attempt(HR,c,a?c:d)(t):91===t?e.attempt($R,c,a?l:d)(t):a?c(t):d(t)}function l(t){return e.attempt(WR,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},HR={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),o};function o(t){return ZP(t)?TR(e,r)(t):r(t)}function r(t){return 41===t?c(t):_R(e,a,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return ZP(t)?TR(e,s)(t):c(t)}function i(e){return n(e)}function s(t){return 34===t||39===t||40===t?AR(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return ZP(t)?TR(e,c)(t):c(t)}function c(o){return 41===o?(e.enter("resourceMarker"),e.consume(o),e.exit("resourceMarker"),e.exit("resource"),t):n(o)}}},$R={tokenize:function(e,t,n){const o=this;return function(t){return IR.call(o,e,r,a,"reference","referenceMarker","referenceString")(t)};function r(e){return o.parser.defined.includes(HP(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},WR={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),o};function o(o){return 93===o?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}};const GR={name:"labelStartImage",resolveAll:VR.resolveAll,tokenize:function(e,t,n){const o=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),r};function r(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in o.parser.constructs?n(e):t(e)}}};const qR={name:"labelStartLink",resolveAll:VR.resolveAll,tokenize:function(e,t,n){const o=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),r};function r(e){return 94===e&&"_hiddenFootnoteSupport"in o.parser.constructs?n(e):t(e)}}};const YR={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),rR(e,t,"linePrefix")}}};const XR={name:"thematicBreak",tokenize:function(e,t,n){let o,r=0;return function(t){return e.enter("thematicBreak"),function(e){return o=e,a(e)}(t)};function a(a){return a===o?(e.enter("thematicBreakSequence"),i(a)):r>=3&&(null===a||JP(a))?(e.exit("thematicBreak"),t(a)):n(a)}function i(t){return t===o?(e.consume(t),r++,i):(e.exit("thematicBreakSequence"),QP(t)?rR(e,a,"whitespace")(t):a(t))}}};const KR={continuation:{tokenize:function(e,t,n){const o=this;return o.containerState._closeFlow=void 0,e.check(fR,(function(n){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,rR(e,t,"listItemIndent",o.containerState.size+1)(n)}),(function(n){if(o.containerState.furtherBlankLines||!QP(n))return o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,r(n);return o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,e.attempt(ZR,t,r)(n)}));function r(r){return o.containerState._closeFlow=!0,o.interrupt=void 0,rR(e,e.attempt(KR,t,n),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const o=this,r=o.events[o.events.length-1];let a=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0,i=0;return function(t){const r=o.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===r?!o.containerState.marker||t===o.containerState.marker:YP(t)){if(o.containerState.type||(o.containerState.type=r,e.enter(r,{_container:!0})),"listUnordered"===r)return e.enter("listItemPrefix"),42===t||45===t?e.check(XR,n,l)(t):l(t);if(!o.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(t)}return n(t)};function s(t){return YP(t)&&++i<10?(e.consume(t),s):(!o.interrupt||i<2)&&(o.containerState.marker?t===o.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||t,e.check(fR,o.interrupt?n:c,e.attempt(JR,u,d))}function c(e){return o.containerState.initialBlankLine=!0,a++,u(e)}function d(t){return QP(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return o.containerState.size=a+o.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},JR={partial:!0,tokenize:function(e,t,n){const o=this;return rR(e,(function(e){const r=o.events[o.events.length-1];return!QP(e)&&r&&"listItemPrefixWhitespace"===r[1].type?t(e):n(e)}),"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},ZR={partial:!0,tokenize:function(e,t,n){const o=this;return rR(e,(function(e){const r=o.events[o.events.length-1];return r&&"listItemIndent"===r[1].type&&r[2].sliceSerialize(r[1],!0).length===o.containerState.size?t(e):n(e)}),"listItemIndent",o.containerState.size+1)}};const QR={name:"setextUnderline",resolveTo:function(e,t){let n,o,r,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(o=a)}else"content"===e[a][1].type&&e.splice(a,1),r||"definition"!==e[a][1].type||(r=a);const i={type:"setextHeading",start:{...e[o][1].start},end:{...e[e.length-1][1].end}};e[o][1].type="setextHeadingText",r?(e.splice(o,0,["enter",i,t]),e.splice(r+1,0,["exit",e[n][1],t]),e[n][1].end={...e[r][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const o=this;let r;return function(t){let i,s=o.events.length;for(;s--;)if("lineEnding"!==o.events[s][1].type&&"linePrefix"!==o.events[s][1].type&&"content"!==o.events[s][1].type){i="paragraph"===o.events[s][1].type;break}if(!o.parser.lazy[o.now().line]&&(o.interrupt||i))return e.enter("setextHeadingLine"),r=t,function(t){return e.enter("setextHeadingLineSequence"),a(t)}(t);return n(t)};function a(t){return t===r?(e.consume(t),a):(e.exit("setextHeadingLineSequence"),QP(t)?rR(e,i,"lineSuffix")(t):i(t))}function i(o){return null===o||JP(o)?(e.exit("setextHeadingLine"),t(o)):n(o)}}};const eL={tokenize:function(e){const t=this,n=e.attempt(fR,(function(o){if(null===o)return void e.consume(o);return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}),e.attempt(this.parser.constructs.flowInitial,o,rR(e,e.attempt(this.parser.constructs.flow,o,e.attempt(ER,o)),"linePrefix")));return n;function o(o){if(null!==o)return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(o)}}};const tL={resolveAll:aL()},nL=rL("string"),oL=rL("text");function rL(e){return{resolveAll:aL("text"===e?iL:void 0),tokenize:function(t){const n=this,o=this.parser.constructs[e],r=t.attempt(o,a,i);return a;function a(e){return l(e)?r(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),s;t.consume(e)}function s(e){return l(e)?(t.exit("data"),r(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;const t=o[e];let r=-1;if(t)for(;++r<t.length;){const e=t[r];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function aL(e){return function(t,n){let o,r=-1;for(;++r<=t.length;)void 0===o?t[r]&&"data"===t[r][1].type&&(o=r,r++):t[r]&&"data"===t[r][1].type||(r!==o+2&&(t[o][1].end=t[r-1][1].end,t.splice(o+2,r-o-2),r=o+2),o=void 0);return e?e(t,n):t}}function iL(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const o=e[n-1][1],r=t.sliceStream(o);let a,i=r.length,s=-1,l=0;for(;i--;){const e=r[i];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)a=!0,l++;else if(-1!==e){i++;break}}if(l){const r={type:n===e.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:o.start._bufferIndex+s,_index:o.start._index+i,line:o.end.line,column:o.end.column-l,offset:o.end.offset-l},end:{...o.end}};o.end={...r.start},o.start.offset===o.end.offset?Object.assign(o,r):(e.splice(n,0,["enter",r,t],["exit",r,t]),n+=2)}n++}return e}const sL={42:KR,43:KR,45:KR,48:KR,49:KR,50:KR,51:KR,52:KR,53:KR,54:KR,55:KR,56:KR,57:KR,62:mR},lL={91:MR},cL={[-2]:xR,[-1]:xR,32:xR},dL={35:PR,42:XR,45:[QR,XR],60:zR,61:QR,95:XR,96:yR,126:yR},uL={38:gR,92:pR},hL={[-5]:YR,[-4]:YR,[-3]:YR,33:GR,38:gR,42:dR,60:[hR,UR],91:qR,92:[DR,pR],93:VR,95:dR,96:wR},fL={null:[dR,tL]},mL=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:lL,disable:{null:[]},document:sL,flow:dL,flowInitial:cL,insideSpan:fL,string:uL,text:hL},Symbol.toStringTag,{value:"Module"}));function pL(e,t,n){let o={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},a=[];let i=[],s=[];const l={attempt:g((function(e,t){v(e,t.from)})),check:g(p),consume:function(e){JP(e)?(o.line++,o.column=1,o.offset+=-3===e?2:1,y()):-1!==e&&(o.column++,o.offset++);o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===i[o._index].length&&(o._bufferIndex=-1,o._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){const t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:g(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){r[e.line]=e.column,y()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const o=[];let r;for(;++n<e.length;){const a=e[n];let i;if("string"==typeof a)i=a;else switch(a){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&r)continue;i=" ";break;default:i=String.fromCharCode(a)}r=-2===a,o.push(i)}return o.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=zP(i,e),f(),null!==i[i.length-1])return[];return v(t,0),c.events=cR(a,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function u(e){return function(e,t){const n=t.start._index,o=t.start._bufferIndex,r=t.end._index,a=t.end._bufferIndex;let i;if(n===r)i=[e[n].slice(o,a)];else{if(i=e.slice(n,r),o>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(o):i.shift()}a>0&&i.push(e[r].slice(0,a))}return i}(i,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:r,offset:a}=o;return{_bufferIndex:e,_index:t,line:n,column:r,offset:a}}function f(){let e;for(;o._index<i.length;){const t=i[o._index];if("string"==typeof t)for(e=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===e&&o._bufferIndex<t.length;)m(t.charCodeAt(o._bufferIndex));else m(t)}}function m(e){d=d(e)}function p(e,t){t.restore()}function g(e,t){return function(n,r,a){let i,d,u,f;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):function(e){return t;function t(t){const n=null!==t&&e[t],o=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(o)?o:o?[o]:[]])(t)}}(n);function m(e){return i=e,d=0,0===e.length?a:p(e[d])}function p(e){return function(n){f=function(){const e=h(),t=c.previous,n=c.currentConstruct,r=c.events.length,a=Array.from(s);return{from:r,restore:i};function i(){o=e,c.previous=t,c.currentConstruct=n,c.events.length=r,s=a,y()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return v();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,v)(n)}}function g(t){return e(u,f),r}function v(e){return f.restore(),++d<i.length?p(i[d]):a}}}function v(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&LP(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function y(){o.line in r&&o.column<2&&(o.column=r[o.line],o.offset+=r[o.line]-1)}}function gL(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)BP(t,e[n]);return t}([mL,...(e||{}).extensions||[]]),content:n(aR),defined:[],document:n(iR),flow:n(eL),lazy:{},string:n(nL),text:n(oL)};return t;function n(e){return function(n){return pL(t,e,n)}}}const vL=/[\0\t\n\r]/g;const yL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function xL(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return VP(n.slice(t?2:1),t?16:10)}return RP(n)||e}const bL={}.hasOwnProperty;function wL(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:a(J),blockQuote:a(G),characterEscape:C,characterReference:C,codeFenced:a(q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(q,i),codeText:a(Y,i),codeTextData:C,data:C,codeFlowValue:C,definition:a(X),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(K),hardBreakEscape:a(Z),hardBreakTrailing:a(Z),htmlFlow:a(Q,i),htmlFlowData:C,htmlText:a(Q,i),htmlTextData:C,image:a(ee),label:i,link:a(te),listItem:a(oe),listItemValue:h,listOrdered:a(ne,u),listUnordered:a(ne),paragraph:a(re),reference:F,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(J),strong:a(ae),thematicBreak:a(se)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:W,autolinkProtocol:$,blockQuote:l(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:V,characterReference:H,codeFenced:l(g),codeFencedFence:p,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:l(v),codeText:l(T),codeTextData:E,data:E,definition:l(),definitionDestinationString:b,definitionLabelString:y,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(_),hardBreakTrailing:l(_),htmlFlow:l(I),htmlFlowData:E,htmlText:l(A),htmlTextData:E,image:l(O),label:P,labelText:D,lineEnding:j,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:R,resourceTitleString:L,resource:z,setextHeading:l(N),setextHeadingLineSequence:S,setextHeadingText:k,strong:l(),thematicBreak:l()}};SL(t,(e||{}).mdastExtensions||[]);const n={};return o;function o(e){let o={type:"root",children:[]};const a={stack:[o],tokenStack:[],config:t,enter:s,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=r(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];bL.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},a),e[u][1])}if(a.tokenStack.length>0){const e=a.tokenStack[a.tokenStack.length-1];(e[1]||CL).call(a,void 0,e[0])}for(o.position={start:kL(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:kL(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)o=t.transforms[u](o)||o;return o}function r(e,t,n){let o,r,a,i,s=t-1,l=-1,c=!1;for(;++s<=n;){const t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!o||i||l||a||(a=s),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(o){let i=s;for(r=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;r&&(e[r][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",r=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}a&&(!r||a<r)&&(o._spread=!0),o.end=Object.assign({},r?e[r][1].start:t[1].end),e.splice(r||s,0,["exit",o,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){const r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=r,e.splice(s,0,["enter",r,t[2]]),s++,n++,a=void 0,i=!0}}}return e[t][1]._spread=c,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:kL(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),o=this.tokenStack.pop();if(!o)throw new Error("Cannot close `"+e.type+"` ("+lP({start:e.start,end:e.end})+"): it’s not open");if(o[0].type!==e.type)if(t)t.call(this,e,o[0]);else{(o[1]||CL).call(this,e,o[0])}n.position.end=kL(e.end)}function d(){return function(e){return OP(e,"boolean"!=typeof MP.includeImageAlt||MP.includeImageAlt,"boolean"!=typeof MP.includeHtml||MP.includeHtml)}(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function h(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function f(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function m(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function p(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HP(this.sliceSerialize(e)).toLowerCase()}function x(){const e=this.resume();this.stack[this.stack.length-1].title=e}function b(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function S(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:kL(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=kL(e.end)}function j(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=kL(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),E.call(this,e))}function _(){this.data.atHardBreak=!0}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function O(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(yL,xL)}(t),n.identifier=HP(t).toLowerCase()}function P(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function R(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function z(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function V(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let o;if(n)o=VP(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{o=RP(t)}this.stack[this.stack.length-1].value+=o}function H(e){this.stack.pop().position.end=kL(e.end)}function $(e){E.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){E.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function G(){return{type:"blockquote",children:[]}}function q(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function X(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function K(){return{type:"emphasis",children:[]}}function J(){return{type:"heading",depth:0,children:[]}}function Z(){return{type:"break"}}function Q(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function oe(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function ae(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function se(){return{type:"thematicBreak"}}}(n)(function(e){for(;!NR(e););return e}(gL(n).document().write(function(){let e,t=1,n="",o=!0;return function(r,a,i){const s=[];let l,c,d,u,h;for(r=n+("string"==typeof r?r.toString():new TextDecoder(a||void 0).decode(r)),d=0,n="",o&&(65279===r.charCodeAt(0)&&d++,o=void 0);d<r.length;){if(vL.lastIndex=d,l=vL.exec(r),u=l&&void 0!==l.index?l.index:r.length,h=r.charCodeAt(u),!l){n=r.slice(d);break}if(10===h&&d===u&&e)s.push(-3),e=void 0;else switch(e&&(s.push(-5),e=void 0),d<u&&(s.push(r.slice(d,u)),t+=u-d),h){case 0:s.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),s.push(-2);t++<c;)s.push(-1);break;case 10:s.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&s.push(-5),n&&s.push(n),s.push(null)),s}}()(e,t,!0))))}function kL(e){return{line:e.line,column:e.column,offset:e.offset}}function SL(e,t){let n=-1;for(;++n<t.length;){const o=t[n];Array.isArray(o)?SL(e,o):NL(e,o)}}function NL(e,t){let n;for(n in t)if(bL.call(t,n))switch(n){case"canContainEols":{const o=t[n];o&&e[n].push(...o);break}case"transforms":{const o=t[n];o&&e[n].push(...o);break}case"enter":case"exit":{const o=t[n];o&&Object.assign(e[n],o);break}}}function CL(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+lP({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+lP({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+lP({start:t.start,end:t.end})+") is still open")}function EL(e){const t=this;t.parser=function(n){return wL(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function jL(e,t){const n=t.referenceType;let o="]";if("collapsed"===n?o+="[]":"full"===n&&(o+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+o}];const r=e.all(t),a=r[0];a&&"text"===a.type?a.value="["+a.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&"text"===i.type?i.value+=o:r.push({type:"text",value:o}),r}function _L(e){const t=e.spread;return null==t?e.children.length>1:t}function IL(e){const t=String(e),n=/\r?\n|\r/g;let o=n.exec(t),r=0;const a=[];for(;o;)a.push(AL(t.slice(r,o.index),r>0,!0),o[0]),r=o.index+o[0].length,o=n.exec(t);return a.push(AL(t.slice(r),r>0,!1)),a.join("")}function AL(e,t,n){let o=0,r=e.length;if(t){let t=e.codePointAt(o);for(;9===t||32===t;)o++,t=e.codePointAt(o)}if(n){let t=e.codePointAt(r-1);for(;9===t||32===t;)r--,t=e.codePointAt(r-1)}return r>o?e.slice(o,r):""}const TL={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",o={};t.lang&&(o.className=["language-"+t.lang]);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:n}]};return t.meta&&(r.data={meta:t.meta}),e.patch(t,r),r=e.applyData(t,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(t,r),r},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",o=String(t.identifier).toUpperCase(),r=oR(o.toLowerCase()),a=e.footnoteOrder.indexOf(o);let i,s=e.footnoteCounts.get(o);void 0===s?(s=0,e.footnoteOrder.push(o),i=e.footnoteOrder.length):i=a+1,s+=1,e.footnoteCounts.set(o,s);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),o=e.definitionById.get(n);if(!o)return jL(e,t);const r={src:oR(o.url||""),alt:t.alt};null!==o.title&&void 0!==o.title&&(r.title=o.title);const a={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){const n={src:oR(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,o),e.applyData(t,o)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const o={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,o),e.applyData(t,o)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),o=e.definitionById.get(n);if(!o)return jL(e,t);const r={href:oR(o.url||"")};null!==o.title&&void 0!==o.title&&(r.title=o.title);const a={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){const n={href:oR(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const o={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},listItem:function(e,t,n){const o=e.all(t),r=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let o=-1;for(;!t&&++o<n.length;)t=_L(n[o])}return t}(n):_L(t),a={},i=[];if("boolean"==typeof t.checked){const e=o[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},o.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<o.length;){const e=o[s];(r||0!==s||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||r?i.push(e):i.push(...e.children)}const l=o[o.length-1];l&&(r||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:a,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},o=e.all(t);let r=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++r<o.length;){const e=o[r];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(o,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),o=n.shift(),r=[];if(o){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([o],!0)};e.patch(t.children[0],n),r.push(n)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=iP(t.children[1]),i=aP(t.children[t.children.length-1]);a&&i&&(o.position={start:a,end:i}),r.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const o=n?n.children:void 0,r=0===(o?o.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,i=a?a.length:t.children.length;let s=-1;const l=[];for(;++s<i;){const n=t.children[s],o={},i=a?a[s]:void 0;i&&(o.align=i);let c={type:"element",tagName:r,properties:o,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:IL(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:ML,yaml:ML,definition:ML,footnoteDefinition:ML};function ML(){}const OL="object"==typeof self?self:globalThis,DL=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),o=r=>{if(e.has(r))return e.get(r);const[a,i]=t[r];switch(a){case 0:case-1:return n(i,r);case 1:{const e=n([],r);for(const t of i)e.push(o(t));return e}case 2:{const e=n({},r);for(const[t,n]of i)e[o(t)]=o(n);return e}case 3:return n(new Date(i),r);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),r)}case 5:{const e=n(new Map,r);for(const[t,n]of i)e.set(o(t),o(n));return e}case 6:{const e=n(new Set,r);for(const t of i)e.add(o(t));return e}case 7:{const{name:e,message:t}=i;return n(new OL[e](t),r)}case 8:return n(BigInt(i),r);case"BigInt":return n(Object(BigInt(i)),r)}return n(new OL[a](i),r)};return o})(new Map,e)(0),PL="",{toString:RL}={},{keys:LL}=Object,zL=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=RL.call(e).slice(8,-1);switch(n){case"Array":return[1,PL];case"Object":return[2,PL];case"Date":return[3,PL];case"RegExp":return[4,PL];case"Map":return[5,PL];case"Set":return[6,PL]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},FL=([e,t])=>0===e&&("function"===t||"symbol"===t),BL=(e,{json:t,lossy:n}={})=>{const o=[];return((e,t,n,o)=>{const r=(e,t)=>{const r=o.push(e)-1;return n.set(t,r),r},a=o=>{if(n.has(o))return n.get(o);let[i,s]=zL(o);switch(i){case 0:{let t=o;switch(s){case"bigint":i=8,t=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+s);t=null;break;case"undefined":return r([-1],o)}return r([i,t],o)}case 1:{if(s)return r([s,[...o]],o);const e=[],t=r([i,e],o);for(const n of o)e.push(a(n));return t}case 2:{if(s)switch(s){case"BigInt":return r([s,o.toString()],o);case"Boolean":case"Number":case"String":return r([s,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const n=[],l=r([i,n],o);for(const t of LL(o))!e&&FL(zL(o[t]))||n.push([a(t),a(o[t])]);return l}case 3:return r([i,o.toISOString()],o);case 4:{const{source:e,flags:t}=o;return r([i,{source:e,flags:t}],o)}case 5:{const t=[],n=r([i,t],o);for(const[r,i]of o)(e||!FL(zL(r))&&!FL(zL(i)))&&t.push([a(r),a(i)]);return n}case 6:{const t=[],n=r([i,t],o);for(const r of o)!e&&FL(zL(r))||t.push(a(r));return n}}const{message:l}=o;return r([i,{name:s,message:l}],o)};return a})(!(t||n),!!t,new Map,o)(e),o},UL="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?DL(BL(e,t)):structuredClone(e):(e,t)=>DL(BL(e,t));function VL(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function HL(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const $L=function(e){if(null==e)return GL;if("function"==typeof e)return WL(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=$L(e[n]);return WL(o);function o(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return WL(n);function n(n){const o=n;let r;for(r in e)if(o[r]!==t[r])return!1;return!0}}(e);if("string"==typeof e)return function(e){return WL(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function WL(e){return function(t,n,o){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,o||void 0))}}function GL(){return!0}const qL=[],YL=!0,XL=!1;function KL(e,t,n,o){let r;"function"==typeof t&&"function"!=typeof n?(o=n,n=t):r=t;const a=$L(r),i=o?-1:1;!function e(r,s,l){const c=r&&"object"==typeof r?r:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,h=qL;if((!t||a(r,s,l[l.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[YL,e];return null==e?qL:[e]}(n(r,l)),h[0]===XL))return h;if("children"in r&&r.children){const t=r;if(t.children&&"skip"!==h[0])for(d=(o?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===XL)return c;d="number"==typeof c[1]?c[1]:d+i}}return h}}(e,void 0,[])()}function JL(e,t,n,o){let r,a,i;"function"==typeof t&&"function"!=typeof n?(a=void 0,i=t,r=n):(a=t,i=n,r=o),KL(e,a,(function(e,t){const n=t[t.length-1],o=n?n.children.indexOf(e):void 0;return i(e,o,n)}),r)}const ZL={}.hasOwnProperty,QL={};function ez(e,t){e.position&&(t.position=function(e){const t=iP(e),n=aP(e);if(t&&n)return{start:t,end:n}}(e))}function tz(e,t){let n=t;if(e&&e.data){const t=e.data.hName,o=e.data.hChildren,r=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&r&&Object.assign(n.properties,UL(r)),"children"in n&&n.children&&null!=o&&(n.children=o)}return n}function nz(e,t){const n=t.data||{},o=!("value"in t)||ZL.call(n,"hProperties")||ZL.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,o),e.applyData(t,o)}function oz(e,t){const n=[];let o=-1;for(t&&n.push({type:"text",value:"\n"});++o<e.length;)o&&n.push({type:"text",value:"\n"}),n.push(e[o]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function rz(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function az(e,t){const n=function(e,t){const n=t||QL,o=new Map,r=new Map,a=new Map,i={...TL,...n.handlers},s={all:function(e){const t=[];if("children"in e){const n=e.children;let o=-1;for(;++o<n.length;){const r=s.one(n[o],e);if(r){if(o&&"break"===n[o-1].type&&(Array.isArray(r)||"text"!==r.type||(r.value=rz(r.value)),!Array.isArray(r)&&"element"===r.type)){const e=r.children[0];e&&"text"===e.type&&(e.value=rz(e.value))}Array.isArray(r)?t.push(...r):t.push(r)}}}return t},applyData:tz,definitionById:o,footnoteById:r,footnoteCounts:a,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,o=s.handlers[n];if(ZL.call(s.handlers,n)&&o)return o(s,e,t);if(s.options.passThrough&&s.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,o=UL(n);return o.children=s.all(e),o}return UL(e)}return(s.options.unknownHandler||nz)(s,e,t)},options:n,patch:ez,wrap:oz};return JL(e,(function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?o:r,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}})),s}(e,t),o=n.one(e,void 0),r=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||VL,o=e.options.footnoteBackLabel||HL,r=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[];let l=-1;for(;++l<e.footnoteOrder.length;){const r=e.footnoteById.get(e.footnoteOrder[l]);if(!r)continue;const a=e.all(r),i=String(r.identifier).toUpperCase(),c=oR(i.toLowerCase());let d=0;const u=[],h=e.footnoteCounts.get(i);for(;void 0!==h&&++d<=h;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof o?o:o(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=a[a.length-1];if(f&&"element"===f.type&&"p"===f.tagName){const e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else a.push(...u);const m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(r,m),s.push(m)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...UL(i),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(n),a=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return r&&a.children.push({type:"text",value:"\n"},r),a}function iz(e,t){return e&&"run"in e?async function(n,o){const r=az(n,{file:o,...t});await e.run(r,o)}:function(n,o){return az(n,{file:o,...e||t})}}function sz(e){if(e)throw e}var lz=Object.prototype.hasOwnProperty,cz=Object.prototype.toString,dz=Object.defineProperty,uz=Object.getOwnPropertyDescriptor,hz=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===cz.call(e)},fz=function(e){if(!e||"[object Object]"!==cz.call(e))return!1;var t,n=lz.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&lz.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!o)return!1;for(t in e);return void 0===t||lz.call(e,t)},mz=function(e,t){dz&&"__proto__"===t.name?dz(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},pz=function(e,t){if("__proto__"===t){if(!lz.call(e,t))return;if(uz)return uz(e,t).value}return e[t]};const gz=ws((function e(){var t,n,o,r,a,i,s=arguments[0],l=1,c=arguments.length,d=!1;for("boolean"==typeof s&&(d=s,s=arguments[1]||{},l=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});l<c;++l)if(null!=(t=arguments[l]))for(n in t)o=pz(s,n),s!==(r=pz(t,n))&&(d&&r&&(fz(r)||(a=hz(r)))?(a?(a=!1,i=o&&hz(o)?o:[]):i=o&&fz(o)?o:{},mz(s,{name:n,newValue:e(d,i,r)})):void 0!==r&&mz(s,{name:n,newValue:r}));return s}));function vz(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function yz(){const e=[],t={run:function(...t){let n=-1;const o=t.pop();if("function"!=typeof o)throw new TypeError("Expected function as last argument, not "+o);!function r(a,...i){const s=e[++n];let l=-1;if(a)o(a);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,s?function(e,t){let n;return o;function o(...t){const o=e.length>t.length;let s;o&&t.push(r);try{s=e.apply(this,t)}catch(a){if(o&&n)throw a;return r(a)}o||(s&&s.then&&"function"==typeof s.then?s.then(i,r):s instanceof Error?r(s):i(s))}function r(e,...o){n||(n=!0,t(e,...o))}function i(e){r(null,e)}}(s,r)(...i):o(null,...i)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const xz={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');bz(e);let n,o=0,r=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){o=a+1;break}}else r<0&&(n=!0,r=a+1);return r<0?"":e.slice(o,r)}if(t===e)return"";let i=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){o=a+1;break}}else i<0&&(n=!0,i=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(r=a):(s=-1,r=i));o===r?r=i:r<0&&(r=e.length);return e.slice(o,r)},dirname:function(e){if(bz(e),0===e.length)return".";let t,n=-1,o=e.length;for(;--o;)if(47===e.codePointAt(o)){if(t){n=o;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){bz(e);let t,n=e.length,o=-1,r=0,a=-1,i=0;for(;n--;){const s=e.codePointAt(n);if(47!==s)o<0&&(t=!0,o=n+1),46===s?a<0?a=n:1!==i&&(i=1):a>-1&&(i=-1);else if(t){r=n+1;break}}if(a<0||o<0||0===i||1===i&&a===o-1&&a===r+1)return"";return e.slice(a,o)},join:function(...e){let t,n=-1;for(;++n<e.length;)bz(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){bz(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,o,r="",a=0,i=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===s);else if(i!==l-1&&2===s){if(r.length<2||2!==a||46!==r.codePointAt(r.length-1)||46!==r.codePointAt(r.length-2))if(r.length>2){if(o=r.lastIndexOf("/"),o!==r.length-1){o<0?(r="",a=0):(r=r.slice(0,o),a=r.length-1-r.lastIndexOf("/")),i=l,s=0;continue}}else if(r.length>0){r="",a=0,i=l,s=0;continue}t&&(r=r.length>0?r+"/..":"..",a=2)}else r.length>0?r+="/"+e.slice(i+1,l):r=e.slice(i+1,l),a=l-i-1;i=l,s=0}else 46===n&&s>-1?s++:s=-1}return r}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function bz(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wz={cwd:function(){return"/"}};function kz(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function Sz(e){if("string"==typeof e)e=new URL(e);else if(!kz(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const Nz=["history","path","basename","stem","extname","dirname"];class Cz{constructor(e){let t;t=e?kz(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":wz.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,o=-1;for(;++o<Nz.length;){const e=Nz[o];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Nz.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?xz.basename(this.path):void 0}set basename(e){jz(e,"basename"),Ez(e,"basename"),this.path=xz.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?xz.dirname(this.path):void 0}set dirname(e){_z(this.basename,"dirname"),this.path=xz.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?xz.extname(this.path):void 0}set extname(e){if(Ez(e,"extname"),_z(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=xz.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){kz(e)&&(e=Sz(e)),jz(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?xz.basename(this.path,this.extname):void 0}set stem(e){jz(e,"stem"),Ez(e,"stem"),this.path=xz.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const o=this.message(e,t,n);throw o.fatal=!0,o}info(e,t,n){const o=this.message(e,t,n);return o.fatal=void 0,o}message(e,t,n){const o=new hP(e,t,n);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function Ez(e,t){if(e&&e.includes(xz.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+xz.sep+"`")}function jz(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function _z(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Iz=function(e){const t=this.constructor.prototype,n=t[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,t),o},Az={}.hasOwnProperty;class Tz extends Iz{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=yz()}copy(){const e=new Tz;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(gz(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Pz("data",this.frozen),this.namespace[e]=t,this):Az.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Pz("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const o=t.call(e,...n);"function"==typeof o&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=zz(e),n=this.parser||this.Parser;return Oz("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),Oz("process",this.parser||this.Parser),Dz("process",this.compiler||this.Compiler),t?o(void 0,t):new Promise(o);function o(o,r){const a=zz(e),i=n.parse(a);function s(e,n){e||!n?r(e):o?o(n):t(void 0,n)}n.run(i,a,(function(e,t,o){if(e||!t||!o)return s(e);const r=t,a=n.stringify(r,o);var i;"string"==typeof(i=a)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(i)?o.value=a:o.result=a,s(e,o)}))}}processSync(e){let t,n=!1;return this.freeze(),Oz("processSync",this.parser||this.Parser),Dz("processSync",this.compiler||this.Compiler),this.process(e,(function(e,o){n=!0,sz(e),t=o})),Lz("processSync","process",n),t}run(e,t,n){Rz(e),this.freeze();const o=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?r(void 0,n):new Promise(r);function r(r,a){const i=zz(t);o.run(e,i,(function(t,o,i){const s=o||e;t?a(t):r?r(s):n(void 0,s,i)}))}}runSync(e,t){let n,o=!1;return this.run(e,t,(function(e,t){sz(e),n=t,o=!0})),Lz("runSync","run",o),n}stringify(e,t){this.freeze();const n=zz(t),o=this.compiler||this.Compiler;return Dz("stringify",o),Rz(e),o(e,n)}use(e,...t){const n=this.attachers,o=this.namespace;if(Pz("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):a(e)}return this;function r(e){if("function"==typeof e)s(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;s(t,n)}else a(e)}}function a(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(o.settings=gz(!0,o.settings,e.settings))}function i(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){r(e[t])}}}function s(e,t){let o=-1,r=-1;for(;++o<n.length;)if(n[o][0]===e){r=o;break}if(-1===r)n.push([e,...t]);else if(t.length>0){let[o,...a]=t;const i=n[r][1];vz(i)&&vz(o)&&(o=gz(!0,i,o)),n[r]=[e,o,...a]}}}}const Mz=(new Tz).freeze();function Oz(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Dz(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Pz(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Rz(e){if(!vz(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Lz(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function zz(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new Cz(e)}const Fz=[],Bz={allowDangerousHtml:!0},Uz=/^(https?|ircs?|mailto|xmpp)$/i,Vz=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Hz(e){const t=e.allowedElements,n=e.allowElement,o=e.children||"",r=e.className,a=e.components,i=e.disallowedElements,s=e.rehypePlugins||Fz,l=e.remarkPlugins||Fz,c=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Bz}:Bz,d=e.skipHtml,u=e.unwrapDisallowed,h=e.urlTransform||$z,f=Mz().use(EL).use(l).use(iz,c).use(s),m=new Cz;"string"==typeof o&&(m.value=o);for(const v of Vz)Object.hasOwn(e,v.from)&&(v.from,v.to&&v.to,v.id);const p=f.parse(m);let g=f.runSync(p,m);return r&&(g={type:"element",tagName:"div",properties:{className:r},children:"root"===g.type?g.children:[g]}),JL(g,(function(e,o,r){if("raw"===e.type&&r&&"number"==typeof o)return d?r.children.splice(o,1):r.children[o]={type:"text",value:e.value},o;if("element"===e.type){let t;for(t in TP)if(Object.hasOwn(TP,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],o=TP[t];(null===o||o.includes(e.tagName))&&(e.properties[t]=h(String(n||""),t,e))}}if("element"===e.type){let a=t?!t.includes(e.tagName):!!i&&i.includes(e.tagName);if(!a&&n&&"number"==typeof o&&(a=!n(e,o,r)),a&&r&&"number"==typeof o)return u&&e.children?r.children.splice(o,1,...e.children):r.children.splice(o,1),o}})),bP(g,{Fragment:k.Fragment,components:a,ignoreInvalidStyle:!0,jsx:k.jsx,jsxs:k.jsxs,passKeys:!0,passNode:!0})}function $z(e){const t=e.indexOf(":"),n=e.indexOf("?"),o=e.indexOf("#"),r=e.indexOf("/");return t<0||r>-1&&t>r||n>-1&&t>n||o>-1&&t>o||Uz.test(e.slice(0,t))?e:""}const Wz=[Yt.lineWrapping],Gz=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]);const qz=e=>{const t=b(26),{code:n,language:o}=e,{theme:a}=Me(),{createNewCell:i}=q(),s=Rd(),l=le(ue),[c,d]=r.useState(n);let u,h,f;t[0]!==n?(u=()=>{d(n)},h=[n],t[0]=n,t[1]=u,t[2]=h):(u=t[1],h=t[2]),r.useEffect(u,h),t[3]!==o||t[4]!==c||t[5]!==l||t[6]!==i||t[7]!==s?(f=()=>{const e=function(e,t){return e?"python"===e?{language:e,code:t}:"sql"===e?{language:"python",code:Vo.fromQuery(t)}:"markdown"===e?{language:"python",code:Uo.fromMarkdown(t)}:"shell"===e||"bash"===e?{language:"python",code:`import subprocess\nsubprocess.run("${t}")`}:{language:"python",code:`_${e} = """\n${t}\n"""`}:{language:"python",code:t}}(o,c);"sql"===o&&Id(l,i,s),i({code:e.code,before:!1,cellId:s??"__end__"})},t[3]=o,t[4]=c,t[5]=l,t[6]=i,t[7]=s,t[8]=f):f=t[8];const m=f;let p;t[9]!==c?(p=async()=>{await et(c)},t[9]=c,t[10]=p):p=t[10];const g=p,v="dark"===a?"dark":"light",y=o&&Gz.has(o)?o:void 0;let x,w,S,N,E,j;return t[11]!==v||t[12]!==y||t[13]!==c?(x=k.jsx(Yi,{theme:v,language:y,className:"cm border rounded overflow-hidden",extensions:Wz,value:c,onChange:d}),t[11]=v,t[12]=y,t[13]=c,t[14]=x):x=t[14],t[15]!==g?(w=k.jsx(C,{size:"xs",variant:"outline",onClick:g,children:"Copy"}),t[15]=g,t[16]=w):w=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Wl,{className:"ml-2 h-4 w-4"}),t[17]=S):S=t[17],t[18]!==m?(N=k.jsxs(C,{size:"xs",variant:"outline",onClick:m,children:["Add to Notebook",S]}),t[18]=m,t[19]=N):N=t[19],t[20]!==w||t[21]!==N?(E=k.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[w,N]}),t[20]=w,t[21]=N,t[22]=E):E=t[22],t[23]!==x||t[24]!==E?(j=k.jsxs("div",{className:"relative",children:[x,E]}),t[23]=x,t[24]=E,t[25]=j):j=t[25],j},Yz={code:({children:e,className:t})=>{const n=null==t?void 0:t.replace("language-","");return n&&"string"==typeof e?k.jsxs("div",{children:[k.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),k.jsx(qz,{code:e.trim(),language:n})]}):k.jsx("code",{className:t,children:e})}},Xz=e=>{const t=b(2),{content:n}=e;let o;return t[0]!==n?(o=k.jsx(Hz,{components:Yz,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),t[0]=n,t[1]=o):o=t[1],o},Kz=(e,t,n,o)=>t?{...e,chats:e.chats.map((e=>e.id===t?{...e,messages:[...e.messages,{role:n,content:o,timestamp:Date.now()}],updatedAt:Date.now()}:e))}:e,Jz=()=>{const[e,t]=Le(Nd),[n,o]=Le(Cd),[a,i]=r.useState({}),[s,l]=r.useState(""),c=r.useRef(null),d=r.useRef(null),{messages:u,input:h,setInput:f,setMessages:m,append:p,handleSubmit:g,error:v,isLoading:y,reload:x}=ks({keepLastMessageOnError:!0,api:zr("api/ai/chat").toString(),headers:Fr.headers(),body:{...a,includeOtherCode:zs("")},streamProtocol:"text",onFinish:n=>{e.activeChatId?t((e=>Kz(e,e.activeChatId,"assistant",n.content))):J.warn("No active chat")},onError:e=>{J.error("An error occurred:",e)},onResponse:e=>{J.debug("Received HTTP response from server:",e)}}),b=e=>{f(e),i(Pb(e))};r.useEffect((()=>{n&&(m(n.messages.map((({role:e,content:t,timestamp:n})=>({role:e,content:t,id:n.toString()})))),b(""))}),[null==n?void 0:n.id]);return k.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[k.jsxs("div",{className:"flex border-b px-2 py-1 justify-between flex-shrink-0",children:[k.jsx(N,{content:"New chat",children:k.jsx(C,{variant:"text",size:"icon",onClick:()=>{o(null),m([]),b(""),l("")},children:k.jsx(Bo,{className:"h-4 w-4"})})}),k.jsxs(fn,{children:[k.jsx(N,{content:"Previous chats",children:k.jsx(xr,{asChild:!0,children:k.jsx(C,{variant:"text",size:"icon",children:k.jsx(Ss,{className:"h-4 w-4"})})})}),k.jsx(hn,{className:"w-[520px] p-0",align:"start",side:"right",children:k.jsx(pD,{className:"h-[500px] p-4",children:k.jsx("div",{className:"space-y-4",children:e.chats.map((e=>k.jsxs("div",{className:rn("p-3 rounded-md cursor-pointer hover:bg-accent",e.id===(null==n?void 0:n.id)&&"bg-accent"),onClick:()=>{o(e.id),m(e.messages.map((({role:e,content:t,timestamp:n})=>({role:e,content:t,id:n.toString()}))))},children:[k.jsx("div",{className:"font-medium",children:e.title}),k.jsx("div",{className:"text-sm text-muted-foreground",children:new Date(e.updatedAt).toLocaleString()})]},e.id)))})})})]})]}),k.jsxs("div",{className:"flex-1 px-3 bg-[var(--slate-1)] gap-4 py-3 flex flex-col overflow-y-auto",children:[(!u||0===u.length)&&k.jsx("div",{className:"flex rounded-md border px-1 bg-background",children:k.jsx(Bb,{value:s,placeholder:"Ask anything, @ to include context",theme:"light",onClose:()=>{var e,t;return null==(t=null==(e=c.current)?void 0:e.editor)?void 0:t.blur()},onChange:l,onSubmit:()=>s.trim()&&(e=>{const n={id:Ns(),title:`${e.slice(0,30)}...`,messages:[{role:"user",content:e,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()};t((e=>({chats:[...e.chats,n],activeChatId:n.id})));const o=Pb(e);i(o),m([]),p({role:"user",content:e},{body:{...o,includeOtherCode:zs("")}})})(s.trim())},"new-thread-input")}),u.map(((n,o)=>k.jsx("div",{className:rn("flex","user"===n.role?"justify-end":"justify-start"),children:"user"===n.role?k.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:k.jsx(Bb,{value:n.content,theme:"light",placeholder:"Type your message...",onChange:()=>{},onSubmit:(n,r)=>{r.trim()&&(m((e=>e.slice(0,o))),i(Pb(r)),p({role:"user",content:r}),e.activeChatId&&t((t=>Kz(t,e.activeChatId,"user",r))))},onClose:()=>{}},n.id)}):k.jsx("div",{className:"w-[95%]",children:k.jsx(Xz,{content:n.content})})},o))),y&&k.jsx("div",{className:"flex justify-center py-4",children:k.jsx($r,{className:"h-4 w-4 animate-spin"})}),v&&k.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[k.jsx(Vi,{error:v}),k.jsx(C,{variant:"outline",size:"sm",onClick:()=>x(),children:"Retry"})]})]}),u&&u.length>0&&k.jsxs("div",{className:"px-2 py-3 border-t relative flex-shrink-0 min-h-[80px]",children:[y&&k.jsx("div",{className:"flex justify-center mb-2 absolute -top-10 left-0 right-0",children:k.jsx(C,{variant:"secondary",size:"xs",onClick:()=>stop(),className:"text-muted-foreground hover:text-foreground",children:"Cancel"})}),k.jsx(Bb,{value:h,onChange:b,onSubmit:(n,o)=>{o.trim()&&(g(n),e.activeChatId&&t((t=>Kz(t,e.activeChatId,"user",o))))},onClose:()=>{var e,t;return null==(t=null==(e=d.current)?void 0:e.editor)?void 0:t.blur()},theme:"light",placeholder:"Type your message..."})]})]})},Zz=u.lazy((()=>ds((()=>import("./terminal-pFINbhgu.js")),__vite__mapDeps([15,2,3,16]),import.meta.url))),Qz=e=>{const t=b(113),{children:n}=e,{isSidebarOpen:o,isTerminalOpen:a,selectedPanel:i}=Qd(),{setIsSidebarOpen:s,setIsTerminalOpen:l}=eu(),c=u.useRef(null),d=u.useRef(null);let h,f,m,p,g;t[0]!==o?(h=()=>{if(!c.current)return;const e=c.current.isCollapsed();o&&e&&c.current.expand(),o||e||c.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))},f=[o],t[0]=o,t[1]=h,t[2]=f):(h=t[1],f=t[2]),r.useEffect(h,f),t[3]!==a?(m=()=>{if(!d.current)return;const e=d.current.isCollapsed();a&&e&&d.current.expand(),a||e||d.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))},p=[a],t[3]=a,t[4]=m,t[5]=p):(m=t[4],p=t[5]),r.useEffect(m,p),t[6]!==n?(g=k.jsx(ek,{id:"app",className:"relative h-full",children:k.jsx(r.Suspense,{children:n})},"app"),t[6]=n,t[7]=g):g=t[7];const v=g,y=eF,x=o?"resize-handle":"resize-handle-collapsed";let w,S;t[8]!==x?(w=rn("border-border no-print z-10",x,"vertical"),t[8]=x,t[9]=w):w=t[9],t[10]!==w?(S=k.jsx(lS,{onDragging:y,className:w}),t[10]=w,t[11]=S):S=t[11];const N=S,E=a?"resize-handle":"resize-handle-collapsed";let j,_;t[12]!==E?(j=rn("border-border no-print z-20",E,"horizontal"),t[12]=E,t[13]=j):j=t[13],t[14]!==j?(_=k.jsx(lS,{onDragging:y,className:j}),t[14]=j,t[15]=_):_=t[15];const I=_;let A,T,M,O,D,P,R,L,z,F,B,U,V,H,$,W,G,q;t[16]!==i?(A=k.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:i}),t[16]=i,t[17]=A):A=t[17],t[18]!==s?(T=()=>s(!1),t[18]=s,t[19]=T):T=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx(tn,{className:"w-4 h-4"}),t[20]=M):M=t[20],t[21]!==T?(O=k.jsx(C,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:T,children:M}),t[21]=T,t[22]=O):O=t[22],t[23]!==A||t[24]!==O?(D=k.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[A,O]}),t[23]=A,t[24]=O,t[25]=D):D=t[25],t[26]!==i?(P="files"===i&&k.jsx(LM,{}),t[26]=i,t[27]=P):P=t[27],t[28]!==i?(R="errors"===i&&k.jsx(BS,{}),t[28]=i,t[29]=R):R=t[29],t[30]!==i?(L="variables"===i&&k.jsx(rM,{}),t[30]=i,t[31]=L):L=t[31],t[32]!==i?(z="dependencies"===i&&k.jsx(ZT,{}),t[32]=i,t[33]=z):z=t[33],t[34]!==i?(F="packages"===i&&k.jsx(hO,{}),t[34]=i,t[35]=F):F=t[35],t[36]!==i?(B="outline"===i&&k.jsx(VS,{}),t[36]=i,t[37]=B):B=t[37],t[38]!==i?(U="datasources"===i&&k.jsx(YM,{}),t[38]=i,t[39]=U):U=t[39],t[40]!==i?(V="documentation"===i&&k.jsx(cM,{}),t[40]=i,t[41]=V):V=t[41],t[42]!==i?(H="snippets"===i&&k.jsx(VM,{}),t[42]=i,t[43]=H):H=t[43],t[44]!==i?($="scratchpad"===i&&k.jsx(uO,{}),t[44]=i,t[45]=$):$=t[45],t[46]!==i?(W="chat"===i&&k.jsx(Jz,{}),t[46]=i,t[47]=W):W=t[47],t[48]!==i?(G="logs"===i&&k.jsx(aM,{}),t[48]=i,t[49]=G):G=t[49],t[50]!==D||t[51]!==P||t[52]!==R||t[53]!==L||t[54]!==z||t[55]!==F||t[56]!==B||t[57]!==U||t[58]!==V||t[59]!==H||t[60]!==$||t[61]!==W||t[62]!==G?(q=k.jsx(hs,{children:k.jsx(r.Suspense,{children:k.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[D,P,R,L,z,F,B,U,V,H,$,W,G]})})}),t[50]=D,t[51]=P,t[52]=R,t[53]=L,t[54]=z,t[55]=F,t[56]=B,t[57]=U,t[58]=V,t[59]=H,t[60]=$,t[61]=W,t[62]=G,t[63]=q):q=t[63];const Y=q,X=o&&"border-r border-l border-[var(--slate-7)]";let K,J,Z,Q,ee,te;t[64]!==X?(K=rn("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",X),t[64]=X,t[65]=K):K=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(J=(e,t)=>{var n;0===t&&10===e&&(null==(n=c.current)||n.resize(30))},t[66]=J):J=t[66],t[67]!==s?(Z=()=>s(!1),Q=()=>s(!0),t[67]=s,t[68]=Z,t[69]=Q):(Z=t[68],Q=t[69]),t[70]!==Y||t[71]!==N?(ee=k.jsxs("span",{className:"flex flex-row h-full",children:[Y," ",N]}),t[70]=Y,t[71]=N,t[72]=ee):ee=t[72],t[73]!==c||t[74]!==K||t[75]!==Z||t[76]!==Q||t[77]!==ee?(te=k.jsx(ek,{ref:c,id:"helper",collapsedSize:0,collapsible:!0,className:K,minSize:10,defaultSize:0,maxSize:75,onResize:J,onCollapse:Z,onExpand:Q,children:ee},"helper"),t[73]=c,t[74]=K,t[75]=Z,t[76]=Q,t[77]=ee,t[78]=te):te=t[78];const ne=te,oe=a&&"border-[var(--slate-7)]";let re,ae,ie,se,le,ce,de,ue;t[79]!==oe?(re=rn("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",oe),t[79]=oe,t[80]=re):re=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(ae=(e,t)=>{var n;0===t&&10===e&&(null==(n=d.current)||n.resize(30))},t[81]=ae):ae=t[81],t[82]!==l?(ie=()=>l(!1),se=()=>l(!0),t[82]=l,t[83]=ie,t[84]=se):(ie=t[83],se=t[84]),t[85]!==l?(le=()=>l(!1),t[85]=l,t[86]=le):le=t[86],t[87]!==a||t[88]!==le?(ce=k.jsx(Zz,{visible:a,onClose:le}),t[87]=a,t[88]=le,t[89]=ce):ce=t[89],t[90]!==a||t[91]!==ce?(de=k.jsx(aO,{isOpen:a,children:ce}),t[90]=a,t[91]=ce,t[92]=de):de=t[92],t[93]!==d||t[94]!==re||t[95]!==ie||t[96]!==se||t[97]!==I||t[98]!==de?(ue=k.jsxs(ek,{ref:d,id:"terminal",collapsedSize:0,collapsible:!0,className:re,minSize:10,defaultSize:0,maxSize:75,onResize:ae,onCollapse:ie,onExpand:se,children:[I,de]},"terminal"),t[93]=d,t[94]=re,t[95]=ie,t[96]=se,t[97]=I,t[98]=de,t[99]=ue):ue=t[99];const he=ue;let fe,me,pe,ge,ve,ye,xe;return t[100]===Symbol.for("react.memo_cache_sentinel")?(fe={getItem:e=>zS||(zS??null),setItem(e,t){zS=t||null}},me=k.jsx(MS,{}),t[100]=fe,t[101]=me):(fe=t[100],me=t[101]),t[102]!==he?(pe=k.jsx(NS,{capability:"terminal",children:he}),t[102]=he,t[103]=pe):pe=t[103],t[104]!==v||t[105]!==pe?(ge=k.jsx(ek,{children:k.jsxs(aS,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[v,pe]})}),t[104]=v,t[105]=pe,t[106]=ge):ge=t[106],t[107]!==ne||t[108]!==ge?(ve=k.jsxs(aS,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:fe,children:[me,ne,ge]}),t[107]=ne,t[108]=ge,t[109]=ve):ve=t[109],t[110]===Symbol.for("react.memo_cache_sentinel")?(ye=k.jsx(hs,{children:k.jsx(CS,{})}),t[110]=ye):ye=t[110],t[111]!==ve?(xe=k.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[ve,ye]}),t[111]=ve,t[112]=xe):xe=t[112],xe};function eF(e){e||window.dispatchEvent(new Event("resize"))}const tF=e=>{const t=b(5);let n,o,r;return t[0]!==e?(n=k.jsx(Ew,{...e}),t[0]=e,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx(Ud,{}),t[2]=o):o=t[2],t[3]!==n?(r=k.jsxs(Qz,{children:[n,o]}),t[3]=n,t[4]=r):r=t[4],r};export{tF as default};
|
|
14
|
+
*/const nd=r.createContext({});function od(e,t){[e,t]=l(e,t,nd);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":o,orientation:l="horizontal"}=e;let[c,d]=r.useState(!1);a((()=>{var e;d(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:u}=i(),h="rtl"===u&&"horizontal"===l;let f=s(t);const m=r.useRef(null);return{toolbarProps:{role:c?"group":"toolbar","aria-orientation":l,"aria-label":n,"aria-labelledby":null==n?o:void 0,onKeyDownCapture:c?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===l&&"ArrowRight"===e.key||"vertical"===l&&"ArrowDown"===e.key)h?f.focusPrevious():f.focusNext();else{if(!("horizontal"===l&&"ArrowLeft"===e.key||"vertical"===l&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),m.current=document.activeElement,void(e.shiftKey?f.focusFirst():f.focusLast())):void 0;h?f.focusNext():f.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:c?void 0:e=>{var n,o;m.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(o=m.current)||void 0===o||o.focus(),m.current=null)},onBlurCapture:c?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||m.current||(m.current=e.target)}}}}(e,t),o=c({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),f=d(e);return delete f.id,u.createElement("div",{...h(n,f),...o,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},o.children)}const rd=r.forwardRef(od);function ad(e,t){const n=f(e),o=f(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function id(e){const t=f(e);return+function(e){const t=f(e);return t.setHours(23,59,59,999),t}(t)==+function(e){const t=f(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}(t)}function sd(e,t){const n=f(e),o=f(t),r=ad(n,o),a=Math.abs(function(e,t){const n=f(e),o=f(t);return 12*(n.getFullYear()-o.getFullYear())+(n.getMonth()-o.getMonth())}(n,o));let i;if(a<1)i=0;else{1===n.getMonth()&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let t=ad(n,o)===-r;id(f(e))&&1===a&&1===ad(e,o)&&(t=!1),i=r*(a-Number(t))}return 0===i?0:i}function ld(e,t,n){const o=function(e,t){return+f(e)-+f(t)}(e,t)/1e3;return(r=null==n?void 0:n.roundingMethod,e=>{const t=(r?Math[r]:Math.trunc)(e);return 0===t?0:t})(o);var r}function cd(e,t){return function(e,t,n){const o=x(),r=(null==n?void 0:n.locale)??o.locale??p,a=ad(e,t);if(isNaN(a))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:null==n?void 0:n.addSuffix,comparison:a});let s,l;a>0?(s=f(t),l=f(e)):(s=f(e),l=f(t));const c=ld(l,s),d=(g(l)-g(s))/1e3,u=Math.round((c-d)/60);let h;if(u<2)return(null==n?void 0:n.includeSeconds)?c<5?r.formatDistance("lessThanXSeconds",5,i):c<10?r.formatDistance("lessThanXSeconds",10,i):c<20?r.formatDistance("lessThanXSeconds",20,i):c<40?r.formatDistance("halfAMinute",0,i):c<60?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",1,i):0===u?r.formatDistance("lessThanXMinutes",1,i):r.formatDistance("xMinutes",u,i);if(u<45)return r.formatDistance("xMinutes",u,i);if(u<90)return r.formatDistance("aboutXHours",1,i);if(u<v){const e=Math.round(u/60);return r.formatDistance("aboutXHours",e,i)}if(u<2520)return r.formatDistance("xDays",1,i);if(u<y){const e=Math.round(u/v);return r.formatDistance("xDays",e,i)}if(u<2*y)return h=Math.round(u/y),r.formatDistance("aboutXMonths",h,i);if(h=sd(l,s),h<12){const e=Math.round(u/y);return r.formatDistance("xMonths",e,i)}{const e=h%12,t=Math.trunc(h/12);return e<3?r.formatDistance("aboutXYears",t,i):e<9?r.formatDistance("overXYears",t,i):r.formatDistance("almostXYears",t+1,i)}}(e,function(e){return m(e,Date.now())}(e),t)}const dd=e=>{const t=b(35);let n;t[0]!==e?(n=()=>{E(new Blob([e.getCellsAsJSON()],{type:"text/plain"}),`${e.proposedName}.json`)},t[0]=e,t[1]=n):n=t[1];const o=n;let r,a,i,s,l,c,d,u,h,f,m,p,g,v,y,x,w;return t[2]!==o||t[3]!==e?(r=t=>{t.preventDefault(),o(),e.closeModal()},t[2]=o,t[3]=e,t[4]=r):r=t[4],t[5]!==e?(a=t=>{"Escape"===t.key&&e.closeModal()},t[5]=e,t[6]=a):a=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(j,{className:"text-accent mb-6",children:"Download unsaved changes?"}),t[7]=i):i=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(s={wordBreak:"break-word"},l=k.jsx("p",{children:"This app has unsaved changes. To recover:"}),c={paddingBottom:"10px"},t[8]=s,t[9]=l,t[10]=c):(s=t[8],l=t[9],c=t[10]),t[11]!==e.proposedName?(d=k.jsxs("li",{style:c,children:['Click the "Download" button. This will download a file called ',k.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[11]=e.proposedName,t[12]=d):d=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(u={paddingBottom:"10px"},t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h={display:"block",padding:"10px"},t[14]=h):h=t[14],t[15]!==e.proposedName?(f=k.jsxs("code",{style:h,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=f):f=t[16],t[17]!==e.proposedName?(m=k.jsxs("code",{children:[e.proposedName,".py"]}),t[17]=e.proposedName,t[18]=m):m=t[18],t[19]!==f||t[20]!==m?(p=k.jsxs("li",{style:u,children:["In your terminal, type",f,"to overwrite ",m," with the recovered changes."]}),t[19]=f,t[20]=m,t[21]=p):p=t[21],t[22]!==d||t[23]!==p?(g=k.jsxs(_,{className:"markdown break-words",style:s,children:[l,k.jsxs("ol",{children:[d,p]})]}),t[22]=d,t[23]=p,t[24]=g):g=t[24],t[25]!==e.closeModal?(v=k.jsx(C,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[25]=e.closeModal,t[26]=v):v=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(y=k.jsx(C,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[27]=y):y=t[27],t[28]!==v?(x=k.jsxs(I,{children:[v,y]}),t[28]=v,t[29]=x):x=t[29],t[30]!==r||t[31]!==a||t[32]!==g||t[33]!==x?(w=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:r,onKeyDown:a,children:[i,g,x]})}),t[30]=r,t[31]=a,t[32]=g,t[33]=x,t[34]=w):w=t[34],w},ud=e=>{const t=b(13),{filename:n,needsSave:o,getCellsAsJSON:r}=e,{openModal:a,closeModal:i}=w();let s;t[0]!==n?(s=null===n?"app":n.slice(0,-3),t[0]=n,t[1]=s):s=t[1];const l=s;let c;t[2]!==o||t[3]!==a||t[4]!==r||t[5]!==l||t[6]!==i?(c=()=>{o&&a(k.jsx(dd,{getCellsAsJSON:r,proposedName:l,closeModal:i}))},t[2]=o,t[3]=a,t[4]=r,t[5]=l,t[6]=i,t[7]=c):c=t[7];const d=c;let u;Cs("global.save",d),t[8]===Symbol.for("react.memo_cache_sentinel")?(u=S("global.save"),t[8]=u):u=t[8];const h=o?"yellow":"gray";let f,m;return t[9]===Symbol.for("react.memo_cache_sentinel")?(f=k.jsx(Pc,{strokeWidth:1.5,size:18}),t[9]=f):f=t[9],t[10]!==d||t[11]!==h?(m=k.jsx(N,{content:u,children:k.jsx(Es,{onClick:d,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:f})}),t[10]=d,t[11]=h,t[12]=m):m=t[12],m},hd=()=>{const e=b(7),{selectedLayout:t}=tl(),{setLayoutView:n}=nl();if(D()&&!_s("wasm_layouts"))return null;let o,r,a,i;return e[0]!==n?(o=e=>n(e),e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(F,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:k.jsx(B,{placeholder:"Select a view"})}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(P,{children:k.jsxs(R,{children:[k.jsx(L,{children:"View as"}),ol.map(gd)]})}),e[3]=a):a=e[3],e[4]!==t||e[5]!==o?(i=k.jsxs(U,{"data-testid":"layout-select",value:t,onValueChange:o,children:[r,a]}),e[4]=t,e[5]=o,e[6]=i):i=e[6],i};function fd(e){const t=md(e);return k.jsx(t,{className:"h-4 w-4"})}function md(e){switch(e){case"vertical":return yc;case"grid":return js;case"slides":return Tc;default:return T(e),M}}function pd(e){return O(e)}function gd(e){return k.jsx(z,{value:e,children:k.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[fd(e),k.jsx("span",{children:pd(e)})]})},e)}function vd(){const e=b(7);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[n,o]=function(e,t){const n=b(10);let o;n[0]!==e||n[1]!==t?(o=new V(e,t),n[0]=e,n[1]=t,n[2]=o):o=n[2];const a=o;let i;n[3]!==a?(i=()=>a.get(),n[3]=a,n[4]=i):i=n[4];const[s,l]=r.useState(i);let c;n[5]!==a?(c=e=>{l(e),a.set(e)},n[5]=a,n[6]=c):c=n[6];const d=c;let u;return n[7]!==s||n[8]!==d?(u=[s,d],n[7]=s,n[8]=d,n[9]=u):u=n[9],u}("marimo:commands",t);let a,i;return e[1]!==n||e[2]!==o?(a=e=>{const t=(r=[e,...n],[...new Set(r)]);var r;o(t.slice(0,3))},e[1]=n,e[2]=o,e[3]=a):a=e[3],e[4]!==n||e[5]!==a?(i={recentCommands:n,addRecentCommand:a},e[4]=n,e[5]=a,e[6]=i):i=e[6],i}function yd(e){return void 0!==e.dropdown}function xd(e,t=""){return e.flatMap((e=>e.label?yd(e)?xd(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const bd=e=>{const t=b(8),{children:n,layerTop:o}=e,r=void 0!==o&&o;let a;t[0]!==n?(a=u.Children.toArray(n),t[0]=n,t[1]=a):a=t[1];const[i,s]=a,l=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let c,d;return t[2]!==l||t[3]!==s?(c=k.jsx("div",{className:l,children:s}),t[2]=l,t[3]=s,t[4]=c):c=t[4],t[5]!==i||t[6]!==c?(d=k.jsxs("div",{className:"multi-icon relative w-fit",children:[i,c]}),t[5]=i,t[6]=c,t[7]=d):d=t[7],d};function wd(){const e=b(3),t=W(),{prepareForRun:n}=q();let o;e[0]!==t||e[1]!==n?(o=async e=>{if(0===e.length)return;const{cellHandles:o,cellData:r}=t,a=[];for(const t of e){const e=o[t];e.current?(a.push(X(e.current.editorView)),e.current.registerRun()):(n({cellId:t}),a.push(r[t].code))}await K({cellIds:e,codes:a}).catch((e=>{J.error(e)}))},e[0]=t,e[1]=n,e[2]=o):o=e[2];return G(o)}const kd=Z(null),Sd=Z(!1),Nd=Z({chats:[],activeChatId:null}),Cd=Z((e=>{const t=e(Nd);return t.chats.find((e=>e.id===t.activeChatId))}),((e,t,n)=>{t(Nd,(e=>({...e,activeChatId:n})))})),Ed=e=>{const t=b(7);let n,o;t[0]!==e.onClick?(n=t=>{var n;(t.ctrlKey||t.metaKey)&&"z"===t.key&&(t.preventDefault(),t.stopPropagation(),null==(n=e.onClick)||n.call(e,t))},t[0]=e.onClick,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o={capture:!0},t[2]=o):o=t[2],Q(window,"keydown",n,o);const r=e.children??"Undo";let a,i;return t[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(ee,{className:"ml-2",shortcut:"cmd-z"}),t[3]=a):a=t[3],t[4]!==e||t[5]!==r?(i=k.jsxs(C,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[r," ",a]}),t[4]=e,t[5]=r,t[6]=i):i=t[6],i};function jd(){const e=b(3),{deleteCell:t,undoDeleteCell:n}=q();let o;return e[0]!==t||e[1]!==n?(o=e=>{if(te.get(ne))return;const{cellId:o}=e;t({cellId:o}),oe({cellId:o}).catch((()=>{n()}));const{dismiss:r}=re({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:k.jsx(Ed,{"data-testid":"undo-delete-button",onClick:()=>{n(),a()}})}),a=r},e[0]=t,e[1]=n,e[2]=o):o=e[2],G(o)}function _d(e,t,n,o=te){if(t in o.get(ae))return!1;const{cellData:r,cellIds:a}=o.get(ie),i=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const s of a.inOrderIds)if(i.test(r[s].code))return!1;return n(`import ${e} as ${t}`),!0}function Id(e,t,n){return _d("marimo","mo",(o=>{const r=se.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&K({cellIds:[r],codes:[o]})}))}function Ad(e){const t=b(52),{cell:n}=e,{createNewCell:o,updateCellConfig:r,updateCellCode:a,updateCellName:i,moveCell:s,sendToTop:l,sendToBottom:c,addColumnBreakpoint:d,clearCellOutput:u}=q(),h=function(e){const t=b(3),n=wd();let o;return t[0]!==e||t[1]!==n?(o=()=>{void 0!==e&&n([e])},t[0]=e,t[1]=n,t[2]=o):o=t[2],G(o)}(null==n?void 0:n.cellId),f=!le(ne),m=jd(),{openModal:p}=w(),g=ce(kd),v=le(de),y=le(ue),x=he(),S=le(fe),N=le(me);if(!n||S){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],e}const{cellId:C,config:E,getEditorView:_,name:I,hasOutput:T,status:M}=n;let O;t[1]!==x.inOrderIds||t[2]!==C?(O=x.inOrderIds.indexOf(C),t[1]=x.inOrderIds,t[2]=C,t[3]=O):O=t[3];const D=O;let P;t[4]!==E.disabled||t[5]!==C||t[6]!==r?(P=async()=>{const e={disabled:!E.disabled};await _e({configs:{[C]:e}}),r({cellId:C,config:e})},t[4]=E.disabled,t[5]=C,t[6]=r,t[7]=P):P=t[7];const R=P;let L;t[8]!==E.hide_code||t[9]!==C||t[10]!==r||t[11]!==_?(L=async()=>{const e={hide_code:!E.hide_code};await _e({configs:{[C]:e}}),r({cellId:C,config:e});const t=_();t&&(e.hide_code?t.contentDOM.blur():t.focus())},t[8]=E.hide_code,t[9]=C,t[10]=r,t[11]=_,t[12]=L):L=t[12];const z=L;let F,B;t[13]===Symbol.for("react.memo_cache_sentinel")?(F=k.jsx(Yc,{size:13,strokeWidth:1.5}),t[13]=F):F=t[13],t[14]!==p||t[15]!==D||t[16]!==I||t[17]!==i||t[18]!==C?(B=()=>{p(k.jsxs(A,{children:[k.jsx(Ie,{children:k.jsx(j,{children:"Rename cell"})}),k.jsxs("div",{className:"flex items-center justify-between",children:[k.jsx(Ae,{htmlFor:"cell-name",children:"Cell name"}),k.jsx(al,{placeholder:`cell_${D}`,value:I,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),p(null))},onChange:e=>i({cellId:C,name:e})})]})]}))},t[14]=p,t[15]=D,t[16]=I,t[17]=i,t[18]=C,t[19]=B):B=t[19];const U=`cell_${D}`;let V,W,Y;if(t[20]!==i||t[21]!==C?(V=e=>i({cellId:C,name:e}),t[20]=i,t[21]=C,t[22]=V):V=t[22],t[23]!==U||t[24]!==I||t[25]!==V?(W=k.jsx(al,{placeholder:U,value:I,onChange:V}),t[23]=U,t[24]=I,t[25]=V,t[26]=W):W=t[26],t[27]!==B||t[28]!==W||t[29]!==M||t[30]!==E.disabled||t[31]!==E.hide_code||t[32]!==h||t[33]!==v||t[34]!==g||t[35]!==C||t[36]!==T||t[37]!==_||t[38]!==a||t[39]!==z||t[40]!==R||t[41]!==u||t[42]!==y||t[43]!==o||t[44]!==s||t[45]!==l||t[46]!==c||t[47]!==N||t[48]!==d||t[49]!==f||t[50]!==m){Y=[[{icon:F,label:"Name",disableClick:!0,handle:Dd,handleHeadless:B,rightElement:W},{icon:k.jsx(Ac,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===M||"queued"===M||"disabled-transitively"===M||E.disabled,handle:()=>h()},{icon:k.jsx(Fc,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!v,handle:()=>{g((e=>(null==e?void 0:e.cellId)===C?null:{cellId:C}))},hotkey:"cell.aiCompletion"},{icon:k.jsx(rl,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!T,handle:()=>function(e){const t=document.getElementById(H.create(e));t&&(t.classList.add("printing-output"),$(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(C)},{icon:k.jsx(pe,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const e=_();e&&ge({[C]:e},a)}},{icon:E.hide_code?k.jsx(ve,{size:13,strokeWidth:1.5}):k.jsx(ye,{size:13,strokeWidth:1.5}),label:E.hide_code?"Show code":"Hide code",handle:z,hotkey:"cell.hideCode"},{icon:E.disabled?k.jsx(ed,{size:13,strokeWidth:1.5}):k.jsx(td,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:k.jsx(xe,{"data-testid":"cell-disable-switch",checked:!E.disabled,size:"sm",onCheckedChange:R}),handle:R},{icon:k.jsx(be,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!T,handle:()=>{u({cellId:C})}}],[{icon:k.jsx(Is,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const e=_();e&&(Id(y,o),we(e,"markdown",{keepCodeAsIs:!0}))}},{icon:k.jsx(ke,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const e=_();e&&(Id(y,o),we(e,"sql",{keepCodeAsIs:!0}))}},{icon:k.jsx(As,{}),label:"Toggle as Python",handle:()=>{const e=_();e&&(Id(y,o),Se(e,"python",{force:!0}))}}],[{icon:k.jsxs(bd,{children:[k.jsx(Jl,{size:13,strokeWidth:1.5}),k.jsx(Ne,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>o({cellId:C,before:!0})},{icon:k.jsxs(bd,{children:[k.jsx(Jl,{size:13,strokeWidth:1.5}),k.jsx(Ce,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>o({cellId:C,before:!1})},{icon:k.jsx(Ne,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>s({cellId:C,before:!0})},{icon:k.jsx(Ce,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>s({cellId:C,before:!1})},{icon:k.jsx(Xl,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>l({cellId:C})},{icon:k.jsx(Yl,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>c({cellId:C})},{icon:k.jsx(Ee,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==N,handle:()=>d({cellId:C})}],[{label:"Delete",hidden:!f,variant:"danger",icon:k.jsx(je,{size:13,strokeWidth:1.5}),handle:()=>{m({cellId:C})}}]].map(Md).filter(Td),t[27]=B,t[28]=W,t[29]=M,t[30]=E.disabled,t[31]=E.hide_code,t[32]=h,t[33]=v,t[34]=g,t[35]=C,t[36]=T,t[37]=_,t[38]=a,t[39]=z,t[40]=R,t[41]=u,t[42]=y,t[43]=o,t[44]=s,t[45]=l,t[46]=c,t[47]=N,t[48]=d,t[49]=f,t[50]=m,t[51]=Y}else Y=t[51];return Y}function Td(e){return e.length>0}function Md(e){return e.filter(Od)}function Od(e){return!e.hidden}function Dd(e){null==e||e.stopPropagation(),null==e||e.preventDefault()}const Pd=Z(null);function Rd(){return le(Pd)}const Ld=Z((e=>{const t=e(Pd);return t?t===Te?null:zd(t,e(ie)):null}));function zd(e,t){var n;const{cellData:o,cellHandles:r,cellRuntime:a}=t,i=o[e],s=a[e],l=null==(n=r[e])?void 0:n.current;if(!i||!l)return null;return{cellId:e,name:i.name,config:i.config,status:s?s.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==s?void 0:s.output)}}function Fd(e){return!e.hidden}const Bd=Z(!1),Ud=()=>{const e=b(32),[t,n]=Le(Bd),o=Ms(),r=le(Ld),a=le(ze);let i;e[0]!==r?(i={cell:r},e[0]=r,e[1]=i):i=e[1];let s=Ad(i).flat();s=xd(s);const l=function(){const e=b(46),{theme:t}=Me(),[n,o]=Oe(),[r,a]=De();let i;e[0]!==o?(i=async e=>{await Pe({config:e}).then((()=>{o(e)}))},e[0]=o,e[1]=i):i=e[1];const s=i;let l;e[2]!==a?(l=async e=>{await Re({config:e}).then((()=>{a(e)}))},e[2]=a,e[3]=l):l=e[3];const c=l;let d,u;if(e[4]!==r||e[5]!==c){let t;e[7]!==r.width?(t=e=>e!==r.width,e[7]=r.width,e[8]=t):t=e[8],d=Ts().filter(t).map((e=>({label:`App config > Set width=${e}`,handle:()=>{c({...r,width:e})}}))),e[4]=r,e[5]=c,e[6]=d}else d=e[6];e[9]!==s||e[10]!==n||e[11]!==t?(u={label:"Config > Toggle dark mode",handle:()=>{s({...n,display:{...n.display,theme:"dark"===t?"light":"dark"}})}},e[9]=s,e[10]=n,e[11]=t,e[12]=u):u=e[12];const h="vim"===n.keymap.preset;let f,m;e[13]!==s||e[14]!==n?(f=()=>{s({...n,keymap:{...n.keymap,preset:"vim"}})},e[13]=s,e[14]=n,e[15]=f):f=e[15],e[16]!==h||e[17]!==f?(m={label:"Config > Switch keymap to VIM",hidden:h,handle:f},e[16]=h,e[17]=f,e[18]=m):m=e[18];const p="default"===n.keymap.preset;let g,v,y;e[19]!==s||e[20]!==n?(g=()=>{s({...n,keymap:{...n.keymap,preset:"default"}})},e[19]=s,e[20]=n,e[21]=g):g=e[21],e[22]!==p||e[23]!==g?(v={label:"Config > Switch keymap to default (current: VIM)",hidden:p,handle:g},e[22]=p,e[23]=g,e[24]=v):v=e[24],e[25]!==s||e[26]!==n?(y=()=>{s({...n,completion:{...n.completion,copilot:!1}})},e[25]=s,e[26]=n,e[27]=y):y=e[27];const x="github"!==n.completion.copilot;let w,k;e[28]!==y||e[29]!==x?(w={label:"Config > Disable GitHub Copilot",handle:y,hidden:x},e[28]=y,e[29]=x,e[30]=w):w=e[30],e[31]!==s||e[32]!==n?(k=()=>{s({...n,completion:{...n.completion,copilot:"github"}})},e[31]=s,e[32]=n,e[33]=k):k=e[33];const S="github"===n.completion.copilot;let N,C;e[34]!==k||e[35]!==S?(N={label:"Config > Enable GitHub Copilot",handle:k,hidden:S},e[34]=k,e[35]=S,e[36]=N):N=e[36],e[37]!==d||e[38]!==u||e[39]!==m||e[40]!==v||e[41]!==w||e[42]!==N?(C=[...d,u,m,v,w,N],e[37]=d,e[38]=u,e[39]=m,e[40]=v,e[41]=w,e[42]=N,e[43]=C):C=e[43];const E=C;let j;return e[44]!==E?(j=E.filter(Fd),e[44]=E,e[45]=j):j=e[45],j}();let c=ru();c=[...xd(c),...xd(l)];const d=c.filter(Vd),u=Fe.keyBy(d,Hd),{recentCommands:h,addRecentCommand:f}=vd(),m=new Set(h);let p,g;e[2]!==a||e[3]!==n?(p=e=>{He(a.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),n((e=>!e)))},e[2]=a,e[3]=n,e[4]=p):p=e[4],Q(document,"keydown",p),e[5]!==o||e[6]!==a||e[7]!==f||e[8]!==n?(g=(e,t)=>{const r=o[e];if(!r)return null;const i=a.getHotkey(e);return k.jsxs($e,{disabled:t.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{r()}))},value:i.name,children:[k.jsxs("span",{children:[i.name,t.tooltip&&k.jsx("span",{className:"ml-2",children:t.tooltip})]}),k.jsx(We,{children:k.jsx(Ge,{shortcut:i.key})})]},e)},e[5]=o,e[6]=a,e[7]=f,e[8]=n,e[9]=g):g=e[9];const v=g;let y;e[10]!==f||e[11]!==n||e[12]!==a?(y=(e,t,o,r)=>{const i=void 0===o?{}:o;return k.jsxs($e,{disabled:i.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{t()}))},value:e,children:[k.jsxs("span",{children:[e,i.tooltip&&k.jsxs("span",{className:"ml-2",children:["(",i.tooltip,")"]})]}),r&&k.jsx(We,{children:k.jsx(Ge,{shortcut:a.getHotkey(r).key})})]},e)},e[10]=f,e[11]=n,e[12]=a,e[13]=y):y=e[13];const x=y,w=qe;let S;e[14]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Ye,{placeholder:"Type to search..."}),e[14]=S):S=e[14];const N=Xe;let C;e[15]===Symbol.for("react.memo_cache_sentinel")?(C=k.jsx(Ke,{children:"No results found."}),e[15]=C):C=e[15];const E=h.length>0&&k.jsxs(k.Fragment,{children:[k.jsx(Be,{heading:"Recently Used",children:h.map((e=>{const t=u[e];return Ue(e)?v(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!yd(t)?x(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),k.jsx(Ve,{})]}),j=Be,_=a.iterate().map((e=>{if(m.has(e))return null;const t=u[e];return v(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),I=d.map((e=>m.has(e.label)?null:x(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}))),A=s.map((e=>m.has(e.label)?null:x(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})));let T,M,O;return e[16]!==j||e[17]!==_||e[18]!==I||e[19]!==A?(T=k.jsxs(j,{heading:"Commands",children:[_,I,A]}),e[16]=j,e[17]=_,e[18]=I,e[19]=A,e[20]=T):T=e[20],e[21]!==N||e[22]!==C||e[23]!==E||e[24]!==T?(M=k.jsxs(N,{children:[C,E,T]}),e[21]=N,e[22]=C,e[23]=E,e[24]=T,e[25]=M):M=e[25],e[26]!==w||e[27]!==t||e[28]!==n||e[29]!==S||e[30]!==M?(O=k.jsxs(w,{open:t,onOpenChange:n,children:[S,M]}),e[26]=w,e[27]=t,e[28]=n,e[29]=S,e[30]=M,e[31]=O):O=e[31],O};function Vd(e){return!e.hotkey}function Hd(e){return e.label}const $d="https://static.marimo.app",Wd=({onClose:e})=>{const[t,n]=r.useState(""),o=`${t}-${r.useRef(Math.random().toString(36).slice(2,6)).current}`,a=`${$d}/static/${o}`;return k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:async t=>{t.preventDefault(),e();const n=await Je({download:!1,includeCode:!0,files:il.INSTANCE.filenames()}),r=re({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${$d}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:n,path:o})}).catch((()=>{r.dismiss(),re({title:"Error uploading static page",description:k.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",k.jsx("a",{href:Ze.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),re({title:"Static page uploaded!",description:k.jsxs("div",{children:["The URL has been copied to your clipboard.",k.jsx("br",{}),"You can share it with anyone."]})})},children:[k.jsxs(Ie,{children:[k.jsx(j,{children:"Share static notebook"}),k.jsxs(_,{children:["You can publish a static, non-interactive version of this notebook to the public web. We will create a link for you that lives on"," ",k.jsx("a",{href:$d,target:"_blank",rel:"noreferrer",children:$d}),"."]})]}),k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[k.jsx(Qe,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:t,placeholder:"Notebook slug",onChange:e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");n(t)},required:!0,autoComplete:"off"}),k.jsxs("div",{className:"font-semibold text-sm text-muted-foreground gap-2 flex flex-col",children:["Anyone will be able to access your notebook at this URL:",k.jsxs("div",{className:"flex items-center gap-2",children:[k.jsx(Gd,{text:a}),k.jsx("span",{className:"text-primary",children:a})]})]})]}),k.jsxs(I,{children:[k.jsx(C,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:e,children:"Cancel"}),k.jsx(C,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await et(a)},children:"Create"})]})]})})},Gd=e=>{const t=b(8),[n,o]=u.useState(!1);let r;t[0]!==e.text?(r=tt.stopPropagation((async t=>{t.preventDefault(),await et(e.text),o(!0),setTimeout((()=>o(!1)),2e3)})),t[0]=e.text,t[1]=r):r=t[1];const a=r;let i,s,l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(nt,{size:14,strokeWidth:1.5}),t[2]=i):i=t[2],t[3]!==a?(s=k.jsx(C,{"data-testid":"copy-static-notebook-url-button",onClick:a,size:"xs",variant:"secondary",children:i}),t[3]=a,t[4]=s):s=t[4],t[5]!==n||t[6]!==s?(l=k.jsx(N,{content:"Copied!",open:n,children:s}),t[5]=n,t[6]=s,t[7]=l):l=t[7],l};function qd(){const e=b(3),{openConfirm:t}=w(),n=ce(sl);let o;return e[0]!==t||e[1]!==n?(o=()=>{t({title:"Restart Kernel",description:"This will restart the Python kernel. You'll lose all data that's in memory. You will also lose any unsaved changes, so make sure to save your work before restarting.",variant:"destructive",confirmAction:k.jsx(ot,{onClick:async()=>{n({state:ll.CLOSING}),await rt(),at()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=n,e[2]=o):o=e[2],o}const Yd=new it("marimo:sidebar",st.object({selectedPanel:st.string().optional().transform((e=>e)),isSidebarOpen:st.boolean(),isTerminalOpen:st.boolean()}),(function(){return{selectedPanel:"variables",isSidebarOpen:!1,isTerminalOpen:!1}}));const{reducer:Xd,createActions:Kd,valueAtom:Jd,useActions:Zd}=lt((()=>Yd.get()),{openApplication:(e,t)=>({...e,selectedPanel:t,isSidebarOpen:!e.isSidebarOpen||e.selectedPanel!==t}),toggleSidebarPanel:e=>({...e,isSidebarOpen:!e.isSidebarOpen}),setIsSidebarOpen:(e,t)=>({...e,isSidebarOpen:t}),toggleTerminal:e=>({...e,isTerminalOpen:!e.isTerminalOpen}),setIsTerminalOpen:(e,t)=>({...e,isTerminalOpen:t})},[(e,t)=>Yd.set(t)]),Qd=()=>{const e=b(2),t=le(Jd);if(t.isSidebarOpen)return t;let n;return e[0]!==t?(n={...t,selectedPanel:void 0},e[0]=t,e[1]=n):n=e[1],n};function eu(){return Zd()}const tu=[{type:"files",Icon:dc,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:ct,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:ke,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:kc,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:ql,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Lc,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:dt,tooltip:"Chat with AI",position:"sidebar",hidden:!_s("chat_sidebar")},{type:"documentation",Icon:Xc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:ut,tooltip:"Notebook logs",position:"sidebar"},{type:"snippets",Icon:Uc,tooltip:"Snippets",position:"sidebar"},{type:"scratchpad",Icon:Sc,hidden:!_s("scratchpad"),tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:be,tooltip:"View errors",position:"footer"}];function nu(){const e=b(2),t=ce(ht);let n;e[0]!==t?(n=()=>{const e=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let o;o=null;for(const t of Array.from(e)){const e=t.getBoundingClientRect();if(e.top>=0&&e.top<=n||e.bottom>=0&&e.bottom<=n){o=ft.parse(t.parentNode.id);break}}t((e=>({mode:mt(e.mode),cellAnchor:o}))),requestAnimationFrame((()=>{var e;null!==o&&(null==(e=document.getElementById(ft.create(o)))||e.scrollIntoView())}))},e[0]=t,e[1]=n):n=e[1];return n}const ou=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function ru(){const[e]=yt(),{openModal:t,closeModal:n}=w(),{openApplication:o}=eu(),{selectedPanel:r}=Qd(),[a]=Le(ht),i=le(fe),s=W(),{updateCellConfig:l,undoDeleteCell:c,clearAllCellOutputs:d}=q(),u=qd(),h=function(e){const t=b(4),{openPrompt:n,closeModal:o}=w();let r;return t[0]!==e||t[1]!==n||t[2]!==o?(r=()=>{if(!e)return null;const t=pt.guessDeliminator(e),r=gt.basename(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${r}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{const r=t.join(gt.dirname(e),n);vt({source:e,destination:r}).then((()=>{o(),re({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${r}`,"_blank")}))}})},t[0]=e,t[1]=n,t[2]=o,t[3]=r):r=t[3],r}(e),f=ce(Bd),m=ce(Os),p=ce(Ds),g=xt(s),v=bt(s),{selectedLayout:y}=tl(),{setLayoutView:x}=nl(),N=nu();return[{icon:k.jsx(zc,{size:14,strokeWidth:1.5}),label:"Share",handle:ou,dropdown:[{icon:k.jsx(wt,{size:14,strokeWidth:1.5}),label:"Publish HTML to web",handle:async()=>{t(k.jsx(Wd,{onClose:n}))}},{icon:k.jsx(vc,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:async()=>{const e=await kt(),t=St({code:e.contents});await et(t),re({title:"Copied",description:"Link copied to clipboard."})}}]},{icon:k.jsx(Nt,{size:14,strokeWidth:1.5}),label:"Download",handle:ou,dropdown:[{icon:k.jsx(cl,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await dl({filename:e,includeCode:!0}):re({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:k.jsx(cl,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await dl({filename:e,includeCode:!1}):re({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:k.jsx(Is,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:async()=>{const e=await Ct({download:!1});E(new Blob([e],{type:"text/plain"}),Et.toMarkdown(document.title))}},{icon:k.jsx(tc,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:async()=>{const e=await kt();E(new Blob([e.contents],{type:"text/plain"}),Et.toPY(document.title))}},{divider:!0,icon:k.jsx(rl,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:k.jsxs("span",{children:["Only available in app view. ",k.jsx("br",{}),"Toggle with: ",S("global.hideCode",!1)]}),handle:async()=>{const e=document.getElementById("App");e&&await $(e,document.title)}},{icon:k.jsx(jt,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:"present"!==a.mode,tooltip:"present"===a.mode?void 0:k.jsxs("span",{children:["Only available in app view. ",k.jsx("br",{}),"Toggle with: ",S("global.hideCode",!1)]}),handle:async()=>{const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout((()=>window.print()),0),setTimeout((()=>window.dispatchEvent(t)),0)}}]},{divider:!0,icon:k.jsx(jc,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:ou,dropdown:tu.flatMap((({type:e,Icon:t,hidden:n})=>{return n?[]:{label:O(e),rightElement:(a=r===e,k.jsx("div",{className:"w-8 flex justify-end",children:a&&k.jsx(It,{size:14})})),icon:k.jsx(t,{size:14,strokeWidth:1.5}),handle:()=>o(e)};var a}))},{icon:k.jsx(Tc,{size:14,strokeWidth:1.5}),label:"Present as",handle:ou,dropdown:[{icon:"present"===a.mode?k.jsx(_t,{size:14,strokeWidth:1.5}):k.jsx(gc,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{N()}},...ol.map(((e,t)=>{const n=md(e);return{divider:0===t,label:pd(e),icon:k.jsx(n,{size:14,strokeWidth:1.5}),rightElement:k.jsx("div",{className:"w-8 flex justify-end",children:y===e&&k.jsx(It,{size:14})}),handle:()=>{x(e),"edit"===a.mode&&N()}}}))]},{icon:k.jsx(lc,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||D(),handle:h},{icon:k.jsx(Zl,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:async()=>{const e=await kt();await et(e.contents),re({title:"Copied",description:"Code copied to clipboard."})}},{icon:k.jsx(td,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:0===g.length||i,handle:async()=>{const e=g.map((e=>e.id)),t=Fe.fromEntries(e.map((e=>[e,{disabled:!1}])));await _e({configs:t});for(const n of e)l({cellId:n,config:{disabled:!1}})}},{icon:k.jsx(ed,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:0===v.length||i,handle:async()=>{const e=v.map((e=>e.id)),t=Fe.fromEntries(e.map((e=>[e,{disabled:!0}])));await _e({configs:t});for(const n of e)l({cellId:n,config:{disabled:!0}})}},{icon:k.jsx(be,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{d()}},{icon:k.jsx(Kc,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!At(s)||i,handle:()=>{c()}},{divider:!0,icon:k.jsx(nc,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>f((e=>!e))},{icon:k.jsx(Tt,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>m((e=>!e))},{icon:k.jsx(pc,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>p((e=>!e))},{icon:k.jsx(Gl,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:()=>{window.open("https://docs.marimo.io","_blank")}},{divider:!0,icon:k.jsx(mc,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:()=>{window.location.href=document.baseURI}},{icon:k.jsx(Gc,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:u}].filter((e=>!e.hidden))}const au=()=>{const e=b(10),t=ru();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Es,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:k.jsx(ul,{strokeWidth:1.8})}),e[0]=n):n=e[0];const o=n,r=iu;let a;e[1]===Symbol.for("react.memo_cache_sentinel")?(a=e=>{const t=k.jsx(Ot,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:r(e)},e.label);return e.tooltip?k.jsx(N,{content:e.tooltip,side:"left",delayDuration:100,children:k.jsx("span",{children:t})},e.label):t},e[1]=a):a=e[1];const i=a;let s,l,c,d,h;if(e[2]===Symbol.for("react.memo_cache_sentinel")?(s=k.jsx(Dt,{asChild:!0,children:o}),e[2]=s):s=e[2],e[3]!==t){let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=e=>e.hidden?null:e.dropdown?k.jsxs(Pt,{children:[k.jsx(Rt,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:r(e)}),k.jsx(Lt,{children:k.jsx(zt,{children:e.dropdown.map((e=>k.jsxs(u.Fragment,{children:[e.divider&&k.jsx(Ft,{}),i(e)]},e.label)))})})]},e.label):k.jsxs(u.Fragment,{children:[e.divider&&k.jsx(Ft,{}),i(e)]},e.label),e[5]=n):n=e[5],l=t.map(n),e[3]=t,e[4]=l}else l=e[4];return e[6]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Ft,{}),e[6]=c):c=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:k.jsxs("span",{children:["Version: ",Mt()]})}),e[7]=d):d=e[7],e[8]!==l?(h=k.jsxs(Bt,{modal:!1,children:[s,k.jsxs(Ut,{align:"end",className:"no-print w-[240px]",children:[l,c,d]})]}),e[8]=l,e[9]=h):h=e[9],h};function iu(e){return k.jsxs(k.Fragment,{children:[e.icon&&k.jsx("span",{className:"flex-0 mr-2",children:e.icon}),k.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&k.jsx(Vt,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]})}const su=Ht({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},((e,t)=>{if(void 0===t)return e;switch(t.type){case"setFind":return{...e,findText:t.find};case"setReplace":return{...e,replaceText:t.replace};case"setCaseSensitive":return{...e,caseSensitive:t.caseSensitive};case"setWholeWord":return{...e,wholeWord:t.wholeWord};case"setRegex":return{...e,regexp:t.regexp};case"setIsOpen":return{...e,isOpen:t.isOpen};case"setCurrentView":return{...e,currentView:{view:t.view,range:t.range}};case"clearCurrentView":return{...e,currentView:void 0}}}));function lu(e){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some((e=>e instanceof HTMLElement&&e.childNodes.length>0)))return!1;if(e){const t=e.state.selection.main,n=e.state.sliceDoc(t.from,t.to);n?(te.set(su,{type:"setFind",find:n}),te.set(su,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):te.set(su,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return te.get(su).isOpen?(te.set(su,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{te.set(su,{type:"setIsOpen",isOpen:!0})})),!0):(te.set(su,{type:"setIsOpen",isOpen:!0}),!0)}function cu(){return!!te.get(su).isOpen&&(te.set(su,{type:"setIsOpen",isOpen:!1}),!0)}function du(e){return $t("create"in e,'Expected query to have a "create" method'),e}function uu(e){return()=>{const t=te.get(su),n=new Wt({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:du(n).create(),search:n})}}const hu=e=>uu((({query:t})=>{const n=Gt(),o=te.get(su).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;"prev"===e&&(n.reverse(),r=o.range.from);let a=n.indexOf(o.view);a<0&&(a=0);const i=[...n,...n].slice(a);for(const s of i){const n="next"===e?t.nextMatch(s.state,0,r??0):t.prevMatch(s.state,r??s.state.doc.length,s.state.doc.length);if(!n){r=null,s.dispatch({selection:qt.single(0)});continue}const o=qt.single(n.from,n.to);return s.dispatch({selection:o,effects:[Yt.scrollIntoView(o.main,{y:"center"})],userEvent:"select.search"}),te.set(su,{type:"setCurrentView",view:s,range:{from:n.from,to:n.to}}),n}return!1})),fu=hu("next"),mu=hu("prev"),pu=uu((({query:e})=>{var t;const n=Gt(),o=[];for(const r of n){if(r.state.readOnly)continue;const n=null==(t=e.matchAll(r.state,1e9))?void 0:t.map((t=>{const{from:n,to:o}=t;return{from:n,to:o,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const a=r.state.doc.toString();o.push((()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})})),r.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of o)e()}})),gu=uu((({query:e})=>{const t=Gt(),n=te.get(su).currentView||{view:t[0],range:{from:0,to:0}};let o=n.range.from,r=t.indexOf(n.view);r<0&&(r=0);const a=[...t,...t].slice(r);for(const i of a){const t=e.nextMatch(i.state,0,o??0);if(!t){o=null,i.dispatch({selection:qt.single(0)});continue}const n=i.state.toText(e.getReplacement(t));return i.dispatch({changes:[{from:t.from,to:t.to,insert:n}],userEvent:"input.replace"}),fu()}return!1})),vu=uu((({query:e})=>{const t=Gt();let n=0;const o=new Map;for(const r of t){const t=e.matchAll(r.state,1e9)||[];for(const e of t){const{from:t,to:a}=e,i=o.get(r)||new Map;i.set(`${t}:${a}`,n++),o.set(r,i)}}return{count:n,position:o}})),yu=Xt.define();function xu(){const e=Gt();for(const t of e)t.state.readOnly||t.dispatch({effects:yu.of(new Wt({search:""}))})}const bu=Kt.define({create(){const e=te.get(su);return du(new Wt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord})).create()},update(e,t){for(const n of t.effects)n.is(yu)&&(e=du(n.value).create());return e}}),wu=Jt.mark({class:"cm-searchMatch"}),ku=Jt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Su=Zt.fromClass(class{constructor(e){this.view=e,this.decorations=void 0,this.decorations=this.highlight(e.state.field(bu))}update(e){const t=e.state.field(bu);(t!==e.startState.field(bu)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return Jt.none;const{view:t}=this,n=new Qt,o=t.visibleRanges,r=o.length;for(let a=0;a<r;a++){let{to:i}=o[a];const{from:s}=o[a];for(;a<r-1&&i>o[a+1].from-500;)i=o[++a].to;e.highlight(t.state,s,i,((e,o)=>{const r=t.state.selection.ranges.some((t=>t.from===e&&t.to===o));n.add(e,o,r?ku:wu)}))}return n.finish()}},{decorations:e=>e.decorations}),Nu=Yt.baseTheme({"&light .cm-searchMatch":{backgroundColor:"#99ff7780"},"&dark .cm-searchMatch":{backgroundColor:"#22bb0070"},"&light .cm-searchMatch-selected":{backgroundColor:"transparent"},"&dark .cm-searchMatch.cm-searchMatch-selected":{backgroundColor:"#6199ff88 !important"}}),Cu=()=>{var e;const t=b(99),[n,o]=r.useState(!1),[a,i]=Le(su),[s,l]=r.useState(),c=r.useRef(null),d=le(ze);let u,h,f,m,p;if(t[0]!==n||t[1]!==a.isOpen?(u=()=>(!n||!a.isOpen)&&lu(),t[0]=n,t[1]=a.isOpen,t[2]=u):u=t[2],Cs("cell.findAndReplace",u),t[3]!==a.isOpen?(h=()=>{a.isOpen&&c.current&&(c.current.focus(),c.current.select())},f=[a.isOpen],t[3]=a.isOpen,t[4]=h,t[5]=f):(h=t[4],f=t[5]),r.useEffect(h,f),t[6]!==a.isOpen||t[7]!==a.findText?(m=()=>{if(!a.isOpen)return void xu();if(""===a.findText)return l(void 0),void xu();const e=vu();l(!1===e?void 0:e),function(){const e=te.get(su),t=Gt();for(const n of t)n.state.readOnly||n.dispatch({effects:yu.of(new Wt({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()},t[6]=a.isOpen,t[7]=a.findText,t[8]=m):m=t[8],t[9]!==a.findText||t[10]!==a.isOpen||t[11]!==a.caseSensitive||t[12]!==a.regexp||t[13]!==a.wholeWord?(p=[a.findText,a.isOpen,a.caseSensitive,a.regexp,a.wholeWord],t[9]=a.findText,t[10]=a.isOpen,t[11]=a.caseSensitive,t[12]=a.regexp,t[13]=a.wholeWord,t[14]=p):p=t[14],r.useEffect(m,p),!a.isOpen)return null;const g=a.currentView;let v;t[15]!==g||t[16]!==s?(v=g&&s?null==(e=s.position.get(g.view))?void 0:e.get(`${g.range.from}:${g.range.to}`):void 0,t[15]=g,t[16]=s,t[17]=v):v=t[17];const y=v;let x,w,S,E,j,_,I,A,T,M,O;t[18]===Symbol.for("react.memo_cache_sentinel")?(x=()=>o(!0),t[18]=x):x=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>o(!1),t[19]=w):w=t[19],t[20]!==i?(S=e=>{"Escape"===e.key&&i({type:"setIsOpen",isOpen:!1})},t[20]=i,t[21]=S):S=t[21],t[22]!==i?(E=()=>i({type:"setIsOpen",isOpen:!1}),t[22]=i,t[23]=E):E=t[23],t[24]===Symbol.for("react.memo_cache_sentinel")?(j=k.jsx(tn,{className:"w-4 h-4"}),t[24]=j):j=t[24],t[25]!==E?(_=k.jsx("div",{className:"absolute top-0 right-0",children:k.jsx(C,{"data-testid":"close-find-replace-button",onClick:E,size:"xs",variant:"text",children:j})}),t[25]=E,t[26]=_):_=t[26],t[27]!==i?(I=e=>{i({type:"setFind",find:e.target.value})},t[27]=i,t[28]=I):I=t[28],t[29]!==a.findText||t[30]!==I?(A=k.jsx(Qe,{ref:c,"data-testid":"find-input",value:a.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:ju,onChange:I}),t[29]=a.findText,t[30]=I,t[31]=A):A=t[31],t[32]!==i?(T=e=>{i({type:"setReplace",replace:e.target.value})},t[32]=i,t[33]=T):T=t[33],t[34]!==a.replaceText||t[35]!==T?(M=k.jsx(Qe,{"data-testid":"replace-input",value:a.replaceText,placeholder:"Replace",onChange:T}),t[34]=a.replaceText,t[35]=T,t[36]=M):M=t[36],t[37]!==A||t[38]!==M?(O=k.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[A,M]}),t[37]=A,t[38]=M,t[39]=O):O=t[39];const D=a.caseSensitive?"on":"off";let P,R,L;t[40]!==i?(P=e=>i({type:"setCaseSensitive",caseSensitive:e}),t[40]=i,t[41]=P):P=t[41],t[42]===Symbol.for("react.memo_cache_sentinel")?(R=k.jsx(nn,{className:"w-4 h-4"}),t[42]=R):R=t[42],t[43]!==a.caseSensitive||t[44]!==D||t[45]!==P?(L=k.jsx(N,{content:"Case Sensitive",children:k.jsx(en,{size:"sm",pressed:a.caseSensitive,"data-state":D,onPressedChange:P,children:R})}),t[43]=a.caseSensitive,t[44]=D,t[45]=P,t[46]=L):L=t[46];const z=a.wholeWord?"on":"off";let F,B,U;t[47]!==i?(F=e=>i({type:"setWholeWord",wholeWord:e}),t[47]=i,t[48]=F):F=t[48],t[49]===Symbol.for("react.memo_cache_sentinel")?(B=k.jsx(Zc,{className:"w-4 h-4"}),t[49]=B):B=t[49],t[50]!==a.wholeWord||t[51]!==z||t[52]!==F?(U=k.jsx(N,{content:"Match Whole Word",children:k.jsx(en,{size:"sm",pressed:a.wholeWord,"data-state":z,onPressedChange:F,children:B})}),t[50]=a.wholeWord,t[51]=z,t[52]=F,t[53]=U):U=t[53];const V=a.regexp?"on":"off";let H,$,W,G;t[54]!==i?(H=e=>i({type:"setRegex",regexp:e}),t[54]=i,t[55]=H):H=t[55],t[56]===Symbol.for("react.memo_cache_sentinel")?($=k.jsx(Mc,{className:"w-4 h-4"}),t[56]=$):$=t[56],t[57]!==a.regexp||t[58]!==V||t[59]!==H?(W=k.jsx(N,{content:"Use Regular Expression",children:k.jsx(en,{size:"sm",pressed:a.regexp,"data-state":V,onPressedChange:H,children:$})}),t[57]=a.regexp,t[58]=V,t[59]=H,t[60]=W):W=t[60],t[61]!==L||t[62]!==U||t[63]!==W?(G=k.jsxs("div",{className:"flex items-center gap-[2px]",children:[L,U,W]}),t[61]=L,t[62]=U,t[63]=W,t[64]=G):G=t[64];const q=""===a.findText||""===a.replaceText;let Y;t[65]!==q?(Y=k.jsx(C,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:_u,disabled:q,children:"Replace Next"}),t[65]=q,t[66]=Y):Y=t[66];const X=""===a.findText||""===a.replaceText;let K,J,Z,Q,ee,ne,oe,re,ae,ie,se,ce;return t[67]!==X?(K=k.jsx(C,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:Iu,disabled:X,children:"Replace All"}),t[67]=X,t[68]=K):K=t[68],t[69]!==Y||t[70]!==K?(J=k.jsxs("div",{className:"flex items-center gap-[2px]",children:[Y,K]}),t[69]=Y,t[70]=K,t[71]=J):J=t[71],t[72]!==G||t[73]!==J?(Z=k.jsxs("div",{className:"flex flex-col gap-2",children:[G,J]}),t[72]=G,t[73]=J,t[74]=Z):Z=t[74],t[75]!==O||t[76]!==Z?(Q=k.jsxs("div",{className:"flex items-center gap-3",children:[O,Z]}),t[75]=O,t[76]=Z,t[77]=Q):Q=t[77],t[78]===Symbol.for("react.memo_cache_sentinel")?(ee=k.jsx(N,{content:"Find Previous",children:k.jsx(C,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:Au,children:k.jsx(Bl,{className:"w-4 h-4"})})}),t[78]=ee):ee=t[78],t[79]===Symbol.for("react.memo_cache_sentinel")?(ne=k.jsx(N,{content:"Find Next",children:k.jsx(C,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:Tu,children:k.jsx(Hl,{className:"w-4 h-4"})})}),t[79]=ne):ne=t[79],t[80]!==s||t[81]!==y?(oe=null!=s&&null==y&&k.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[80]=s,t[81]=y,t[82]=oe):oe=t[82],t[83]!==s||t[84]!==y?(re=null!=s&&null!=y&&k.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[83]=s,t[84]=y,t[85]=re):re=t[85],t[86]!==oe||t[87]!==re?(ae=k.jsxs("div",{className:"flex items-center gap-2",children:[ee,ne,oe,re]}),t[86]=oe,t[87]=re,t[88]=ae):ae=t[88],t[89]!==d?(ie=d.getHotkey("cell.findAndReplace"),t[89]=d,t[90]=ie):ie=t[90],t[91]!==ie.key?(se=k.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",k.jsx(Ge,{shortcut:ie.key})," ","again to open the native browser search."]}),t[91]=ie.key,t[92]=se):se=t[92],t[93]!==S||t[94]!==_||t[95]!==Q||t[96]!==ae||t[97]!==se?(ce=k.jsx(on,{restoreFocus:!0,autoFocus:!0,children:k.jsxs("div",{onFocus:x,onClick:Eu,onBlur:w,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:S,children:[_,Q,ae,se]})}),t[93]=S,t[94]=_,t[95]=Q,t[96]=ae,t[97]=se,t[98]=ce):ce=t[98],ce};function Eu(e){e.stopPropagation(),e.preventDefault()}function ju(e){"Enter"===e.key&&(e.shiftKey?mu():fu())}function _u(){return gu()}function Iu(){const e=pu();if(!e)return;const{dismiss:t}=re({title:"Replaced all occurrences",action:k.jsx(Ed,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),n()}})}),n=t}function Au(){return mu()}function Tu(){return fu()}function Mu(e){const t=b(3),[n,o]=r.useState(!1);let a,i;return t[0]!==e?(a=()=>{if(!e)return;o(!1);const t=setTimeout((()=>{o(!0)}),200);return()=>clearTimeout(t)},i=[e],t[0]=e,t[1]=a,t[2]=i):(a=t[1],i=t[2]),r.useEffect(a,i),e&&n}const Ou=()=>{const e=b(6),t=ce(Bd);let n;e[0]!==t?(n=()=>t((e=>!e)),e[0]=t,e[1]=n):n=e[1];const o=n;let r,a,i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(r=S("global.commandPalette"),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx(nc,{strokeWidth:1.5,size:18}),e[3]=a):a=e[3],e[4]!==o?(i=k.jsx(N,{content:r,children:k.jsx(Es,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:a})}),e[4]=o,e[5]=i):i=e[5],i},Du=e=>{const{children:t}=e;return le(fe)?null:t},Pu=e=>{const{children:t}=e;return le(fe)?t:null},Ru=e=>{const t=b(48),{filename:n,needsSave:o,onSaveNotebook:r,getCellsAsJSON:a,presenting:i,onTogglePresenting:s,onInterrupt:l,onRun:c,closed:d,running:u,needsRun:h,undoAvailable:f,appWidth:m}=e,{undoDeleteCell:p}=q();let g;t[0]!==r?(g=e=>{e.preventDefault(),e.stopPropagation(),r()},t[0]=r,t[1]=g):g=t[1];const v=g;let y,x,w=null;if(!d&&f){let e,n;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Kc,{size:16,strokeWidth:1.5}),t[2]=e):e=t[2],t[3]!==p?(n=k.jsx(N,{content:"Undo cell deletion",children:k.jsx(Es,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:p,children:e})}),t[3]=p,t[4]=n):n=t[4],w=n}t[5]!==i?(y=!i&&k.jsx(Cu,{}),t[5]=i,t[6]=y):y=t[6],t[7]!==d||t[8]!==i?(x=!d&&k.jsxs("div",{className:Fu,children:[i&&k.jsx(hd,{}),k.jsx(au,{}),k.jsx(Ps,{}),k.jsx(Rs,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),t[7]=d,t[8]=i,t[9]=x):x=t[9];const C="compact"===m&&"xl:flex-row items-end";let E,j,_,I,A,T,M,O,D,P,R,L,z;return t[10]!==C?(E=rn(Bu,C),t[10]=C,t[11]=E):E=t[11],t[12]!==d||t[13]!==n||t[14]!==a||t[15]!==o||t[16]!==v?(j=k.jsx(Du,{children:d?k.jsx(ud,{filename:n,getCellsAsJSON:a,needsSave:o}):k.jsx(N,{content:S("global.save"),children:k.jsx(Es,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:o?"yellow":"hint-green",onClick:v,children:k.jsx(Pc,{strokeWidth:1.5,size:18})})})}),t[12]=d,t[13]=n,t[14]=a,t[15]=o,t[16]=v,t[17]=j):j=t[17],t[18]===Symbol.for("react.memo_cache_sentinel")?(_=S("global.hideCode"),t[18]=_):_=t[18],t[19]!==i?(I=i?k.jsx(_t,{strokeWidth:1.5,size:18}):k.jsx(gc,{strokeWidth:1.5,size:18}),t[19]=i,t[20]=I):I=t[20],t[21]!==s||t[22]!==I?(A=k.jsx(N,{content:_,children:k.jsx(Es,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:s,children:I})}),t[21]=s,t[22]=I,t[23]=A):A=t[23],t[24]===Symbol.for("react.memo_cache_sentinel")?(T=k.jsx(Ou,{}),M=k.jsx(Ls,{}),O=k.jsx("div",{}),t[24]=T,t[25]=M,t[26]=O):(T=t[24],M=t[25],O=t[26]),t[27]!==d||t[28]!==u||t[29]!==l?(D=!d&&k.jsx(zu,{running:u,onInterrupt:l}),t[27]=d,t[28]=u,t[29]=l,t[30]=D):D=t[30],t[31]!==d||t[32]!==h||t[33]!==c?(P=!d&&k.jsx(Lu,{needsRun:h,onRun:c}),t[31]=d,t[32]=h,t[33]=c,t[34]=P):P=t[34],t[35]!==w||t[36]!==D||t[37]!==P?(R=k.jsx(Du,{children:k.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[w,D,P]})}),t[35]=w,t[36]=D,t[37]=P,t[38]=R):R=t[38],t[39]!==E||t[40]!==j||t[41]!==A||t[42]!==R?(L=k.jsxs("div",{className:E,children:[j,A,T,M,O,R]}),t[39]=E,t[40]=j,t[41]=A,t[42]=R,t[43]=L):L=t[43],t[44]!==y||t[45]!==x||t[46]!==L?(z=k.jsxs(k.Fragment,{children:[y,x,L]}),t[44]=y,t[45]=x,t[46]=L,t[47]=z):z=t[47],z},Lu=e=>{const t=b(5),{needsRun:n,onRun:o}=e;if(n){let e,n,r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=S("global.runStale"),t[0]=e):e=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Ac,{strokeWidth:1.5,size:16}),t[1]=n):n=t[1],t[2]!==o?(r=k.jsx(N,{content:e,children:k.jsx(Es,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:o,children:n})}),t[2]=o,t[3]=r):r=t[3],r}let r;return t[4]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(N,{content:"Nothing to run",children:k.jsx(Es,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:k.jsx(Ac,{strokeWidth:1.5,size:16})})}),t[4]=r):r=t[4],r},zu=e=>{const t=b(8),{running:n,onInterrupt:o}=e,r=Mu(n);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=S("global.interrupt"),t[0]=a):a=t[0];const i=!r&&"inactive-button active:shadow-xsSolid";let s;t[1]!==i?(s=rn(i),t[1]=i,t[2]=s):s=t[2];const l=r?"yellow":"disabled",c=r?o:an.NOOP;let d,u;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(M,{strokeWidth:1.5,size:16}),t[3]=d):d=t[3],t[4]!==s||t[5]!==l||t[6]!==c?(u=k.jsx(N,{content:a,children:k.jsx(Es,{className:s,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:c,children:d})}),t[4]=s,t[5]=l,t[6]=c,t[7]=u):u=t[7],u},Fu="absolute top-3 right-5 m-0 flex items-center space-x-3 min-h-[28px] no-print pointer-events-auto z-30 print:hidden",Bu="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",Uu=e=>{const t=b(35),{resetOnBlur:n,placeholderText:o,initialValue:a,flexibleWidth:i,onNameChange:s,className:l}=e,c=void 0!==n&&n,d=void 0===a?null:a,u=void 0!==i&&i,[h,f]=r.useState(d);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[0]=m):m=t[0];const[p,g]=r.useState(m),[v,y]=r.useState(!1),x=r.useRef(null),w=r.useRef(!1);let S,N,C;t[1]!==d?(S=()=>{f(d)},N=[d],t[1]=d,t[2]=S,t[3]=N):(S=t[2],N=t[3]),r.useEffect(S,N),t[4]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{y(!0)},t[4]=C):C=t[4];const E=C;let j;t[5]!==c||t[6]!==d?(j=e=>{var t;(null==(t=e.relatedTarget)?void 0:t.closest(".filename-input"))||(y(!1),c&&f(d))},t[5]=c,t[6]=d,t[7]=j):j=t[7];const _=j;let I;t[8]!==h?(I=gt.dirname(h||""),t[8]=h,t[9]=I):I=t[9];const A=I,T=gt.basename(h||""),M=p.filter((e=>gt.basename(e.path).startsWith(T)));let O,D;t[10]!==v||t[11]!==A?(O=async()=>{if(!v)return void g([]);const e=await cn({path:A});g(e.files)},D=[A,v],t[10]=v,t[11]=A,t[12]=O,t[13]=D):(O=t[12],D=t[13]);const{loading:P}=sn(O,D),R=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(_s("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(gt.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||gt.basename(t.path)===e)))return;if(n&&(n===e||gt.basename(n)===e))return;return e}(h,p,d),L=(R||M.length>0)&&k.jsxs(Xe,{className:"font-mono",children:[!P&&k.jsx(Ke,{children:"No files"}),R&&k.jsxs($e,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;R&&(w.current=!0,s(R),null==(e=x.current)||e.blur())},children:[k.jsx(ic,{className:"w-4 h-4 mr-2"})," ",k.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",k.jsx("span",{className:"font-medium text-sm",children:gt.basename(R)})]})]},"_rename_"),M.map((e=>{const t=e.isDirectory?"directory":ln(e.path),n=dn[t];return k.jsxs($e,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?f(`${e.path}/`):f(e.path)},children:[k.jsx(n,{className:"w-4 h-4 mr-2"})," ",gt.basename(e.path)]},e.path)}))]}),z=10*Math.max(20,(null==h?void 0:h.length)||(null==o?void 0:o.length)||0),F=v?h||"":d||"";let B,U,V;t[14]!==u||t[15]!==z?(B=u?{maxWidth:z}:void 0,t[14]=u,t[15]=z,t[16]=B):B=t[16],t[17]!==l?(U=rn(l,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[17]=l,t[18]=U):U=t[18],t[19]!==F||t[20]!==o||t[21]!==B||t[22]!==U?(V=k.jsx(un,{children:k.jsx(Ye,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:F,onKeyDown:Vu,icon:null,ref:x,onValueChange:f,placeholder:o,autoComplete:"off",style:B,className:U})}),t[19]=F,t[20]=o,t[21]=B,t[22]=U,t[23]=V):V=t[23];const H=L&&"group-focus-within:block";let $,W,G,q;return t[24]!==H?($=rn("p-0 w-full min-w-80 max-w-80vw hidden",H),t[24]=H,t[25]=$):$=t[25],t[26]!==$||t[27]!==L?(W=k.jsx(hn,{side:"bottom",className:$,portal:!1,children:L}),t[26]=$,t[27]=L,t[28]=W):W=t[28],t[29]!==V||t[30]!==W?(G=k.jsxs(Xe,{children:[V,W]}),t[29]=V,t[30]=W,t[31]=G):G=t[31],t[32]!==_||t[33]!==G?(q=k.jsx(fn,{open:!0,modal:!1,children:k.jsx(mn,{onFocus:E,onBlur:_,shouldFilter:!1,className:"bg-transparent group filename-input",children:G})}),t[32]=_,t[33]=G,t[34]=q):q=t[34],q};function Vu(e){"Escape"===e.key&&e.currentTarget.blur()}const Hu=e=>{const t=b(7),{filename:n,setFilename:o}=e;let r;t[0]!==n?(r=n?gt.basename(n):"untitled marimo app",t[0]=n,t[1]=r):r=t[1];const a=null===n?"missing-filename":"filename";let i;return t[2]!==r||t[3]!==n||t[4]!==o||t[5]!==a?(i=k.jsx(Uu,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:a}),t[2]=r,t[3]=n,t[4]=o,t[5]=a,t[6]=i):i=t[6],i};function $u(e){return[pn.of([{key:"Escape",preventDefault:!1,run:cu},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:gn},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:lu}]),vn(),Su,bu,Nu]}var Wu=Object.defineProperty,Gu=(e,t,n)=>(((e,t,n)=>{t in e?Wu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n})(e,"symbol"!=typeof t?t+"":t,n),n);const qu=Kt.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is(Yu)));return t.state.doc&&n&&t.state.doc==n.value.doc?{suggestion:n.value.text}:{suggestion:null}}}),Yu=Xt.define();class Xu extends xn{constructor(e){super(),Gu(this,"suggestion"),this.suggestion=e}toDOM(){const e=document.createElement("span");return e.style.opacity="0.4",e.className="cm-inline-suggestion",e.textContent=this.suggestion,e}get lineBreaks(){return this.suggestion.split("\n").length-1}}const Ku=e=>Zt.fromClass(class{async update(t){const n=t.state.doc;if(!t.docChanged)return;const o=await e(t.state);t.view.dispatch({effects:Yu.of({text:o,doc:n})})}}),Ju=Zt.fromClass(class{constructor(){Gu(this,"decorations"),this.decorations=Jt.none}update(e){var t;const n=null==(t=e.state.field(qu))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,o=[],r=Jt.widget({widget:new Xu(t),side:1});return o.push(r.range(n)),Jt.set(o)}(e.view,n):Jt.none}},{decorations:e=>e.decorations}),Zu=yn.highest(pn.of([{key:"Tab",run:e=>{var t;const n=null==(t=e.state.field(qu))?void 0:t.suggestion;return!!n&&(e.dispatch({...Qu(e.state,n,e.state.selection.main.head,e.state.selection.main.head)}),!0)}}]));function Qu(e,t,n,o){return{...e.changeByRange((r=>{if(r==e.selection.main)return{changes:{from:n,to:o,insert:t},range:qt.cursor(n+t.length)};const a=o-n;return!r.empty||a&&e.sliceDoc(r.from-a,r.from)!=e.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-a,to:r.from,insert:t},range:qt.cursor(r.from-a+t.length)}})),userEvent:"input.complete"}}function eh(e){const{delay:t=500}=e,n=function(e,t,n){let o=()=>{};return(...r)=>(o(),new Promise(((a,i)=>{const s=setTimeout((()=>a(e(...r))),t);o=()=>{clearTimeout(s),void 0!==n&&i(n)}})))}(e.fetchFn,t);return[qu,Ku(n),Ju,Zu]}const th=Xt.define(),nh=Xt.define(),oh=Xt.define();function rh(e,t){if(!e)throw new Error(t)}function ah(e){if("number"!=typeof e)throw new Error("invalid int 32: "+typeof e);if(!Number.isInteger(e)||e>2147483647||e<-2147483648)throw new Error("invalid int 32: "+e)}function ih(e){if("number"!=typeof e)throw new Error("invalid uint 32: "+typeof e);if(!Number.isInteger(e)||e>4294967295||e<0)throw new Error("invalid uint 32: "+e)}function sh(e){if("number"!=typeof e)throw new Error("invalid float 32: "+typeof e);if(Number.isFinite(e)&&(e>34028234663852886e22||e<-34028234663852886e22))throw new Error("invalid float 32: "+e)}const lh=Symbol("@bufbuild/protobuf/enum-type");function ch(e){const t=e[lh];return rh(t,"missing enum type on enum object"),t}function dh(e,t,n,o){e[lh]=uh(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function uh(e,t,n){const o=Object.create(null),r=Object.create(null),a=[];for(const i of t){const e=fh(i);a.push(e),o[i.name]=e,r[i.no]=e}return{typeName:e,values:a,findName:e=>o[e],findNumber:e=>r[e]}}function hh(e,t,n){const o={};for(const r of t){const e=fh(r);o[e.localName]=e.no,o[e.no]=e.localName}return dh(o,e,t),o}function fh(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class mh{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,t){const n=this.getType().runtime.bin,o=n.makeReadOptions(t);return n.readMessage(this,o.readerFactory(e),e.byteLength,o),this}fromJson(e,t){const n=this.getType(),o=n.runtime.json,r=o.makeReadOptions(t);return o.readMessage(n,e,r,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(o){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${o instanceof Error?o.message:String(o)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),o=n.writerFactory();return t.writeMessage(this,o,n),o.finish()}toJson(e){const t=this.getType().runtime.json,n=t.makeWriteOptions(e);return t.writeMessage(this,n)}toJsonString(e){var t;const n=this.toJson(e);return JSON.stringify(n,null,null!==(t=null==e?void 0:e.prettySpaces)&&void 0!==t?t:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function ph(){let e=0,t=0;for(let o=0;o<28;o+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}let n=this.buf[this.pos++];if(e|=(15&n)<<28,t=(112&n)>>4,!(128&n))return this.assertBounds(),[e,t];for(let o=3;o<=31;o+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<o,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function gh(e,t,n){for(let a=0;a<28;a+=7){const o=e>>>a,r=!(o>>>7==0&&0==t),i=255&(r?128|o:o);if(n.push(i),!r)return}const o=e>>>28&15|(7&t)<<4,r=!!(t>>3);if(n.push(255&(r?128|o:o)),r){for(let e=3;e<31;e+=7){const o=t>>>e,r=!(o>>>7==0),a=255&(r?128|o:o);if(n.push(a),!r)return}n.push(t>>>31&1)}}const vh=4294967296;function yh(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let o=0,r=0;function a(t,a){const i=Number(e.slice(t,a));r*=n,o=o*n+i,o>=vh&&(r+=o/vh|0,o%=vh)}return a(-24,-18),a(-18,-12),a(-12,-6),a(-6),t?wh(o,r):bh(o,r)}function xh(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(vh*t+e);const n=16777215&(e>>>24|t<<8),o=t>>16&65535;let r=(16777215&e)+6777216*n+6710656*o,a=n+8147497*o,i=2*o;const s=1e7;return r>=s&&(a+=Math.floor(r/s),r%=s),a>=s&&(i+=Math.floor(a/s),a%=s),i.toString()+kh(a)+kh(r)}function bh(e,t){return{lo:0|e,hi:0|t}}function wh(e,t){return t=~t,e?e=1+~e:t+=1,bh(e,t)}const kh=e=>{const t=String(e);return"0000000".slice(t.length)+t};function Sh(e,t){if(e>=0){for(;e>127;)t.push(127&e|128),e>>>=7;t.push(e)}else{for(let n=0;n<9;n++)t.push(127&e|128),e>>=7;t.push(1)}}function Nh(){let e=this.buf[this.pos++],t=127&e;if(!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<7,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<14,!(128&e))return this.assertBounds(),t;if(e=this.buf[this.pos++],t|=(127&e)<<21,!(128&e))return this.assertBounds(),t;e=this.buf[this.pos++],t|=(15&e)<<28;for(let n=5;128&e&&n<10;n++)e=this.buf[this.pos++];if(128&e)throw new Error("invalid varint");return this.assertBounds(),t>>>0}var Ch={};const Eh=function(){const e=new DataView(new ArrayBuffer(8));if("function"==typeof BigInt&&"function"==typeof e.getBigInt64&&"function"==typeof e.getBigUint64&&"function"==typeof e.setBigInt64&&"function"==typeof e.setBigUint64&&("object"!=typeof process||"1"!==Ch.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),o=BigInt("0"),r=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const o="bigint"==typeof e?e:BigInt(e);if(o>n||o<t)throw new Error(`int64 invalid: ${e}`);return o},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>r||t<o)throw new Error(`uint64 invalid: ${e}`);return t},enc(t){return e.setBigInt64(0,this.parse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},uEnc(t){return e.setBigInt64(0,this.uParse(t),!0),{lo:e.getInt32(0,!0),hi:e.getInt32(4,!0)}},dec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigInt64(0,!0)),uDec:(t,n)=>(e.setInt32(0,t,!0),e.setInt32(4,n,!0),e.getBigUint64(0,!0))}}const t=e=>rh(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>rh(/^[0-9]+$/.test(e),`uint64 invalid: ${e}`);return{zero:"0",supported:!1,parse:e=>("string"!=typeof e&&(e=e.toString()),t(e),e),uParse:e=>("string"!=typeof e&&(e=e.toString()),n(e),e),enc:e=>("string"!=typeof e&&(e=e.toString()),t(e),yh(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),yh(e)),dec:(e,t)=>function(e,t){let n=bh(e,t);const o=2147483648&n.hi;o&&(n=wh(n.lo,n.hi));const r=xh(n.lo,n.hi);return o?"-"+r:r}(e,t),uDec:(e,t)=>xh(e,t)}}();var jh,_h,Ih,Ah,Th,Mh;function Oh(e,t,n){if(t===n)return!0;if(e==jh.BYTES){if(!(t instanceof Uint8Array&&n instanceof Uint8Array))return!1;if(t.length!==n.length)return!1;for(let e=0;e<t.length;e++)if(t[e]!==n[e])return!1;return!0}switch(e){case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return t==n}return!1}function Dh(e,t){switch(e){case jh.BOOL:return!1;case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return 0==t?Eh.zero:"0";case jh.DOUBLE:case jh.FLOAT:return 0;case jh.BYTES:return new Uint8Array(0);case jh.STRING:return"";default:return 0}}function Ph(e,t){switch(e){case jh.BOOL:return!1===t;case jh.STRING:return""===t;case jh.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(_h=jh||(jh={}))[_h.DOUBLE=1]="DOUBLE",_h[_h.FLOAT=2]="FLOAT",_h[_h.INT64=3]="INT64",_h[_h.UINT64=4]="UINT64",_h[_h.INT32=5]="INT32",_h[_h.FIXED64=6]="FIXED64",_h[_h.FIXED32=7]="FIXED32",_h[_h.BOOL=8]="BOOL",_h[_h.STRING=9]="STRING",_h[_h.BYTES=12]="BYTES",_h[_h.UINT32=13]="UINT32",_h[_h.SFIXED32=15]="SFIXED32",_h[_h.SFIXED64=16]="SFIXED64",_h[_h.SINT32=17]="SINT32",_h[_h.SINT64=18]="SINT64",(Ah=Ih||(Ih={}))[Ah.BIGINT=0]="BIGINT",Ah[Ah.STRING=1]="STRING",(Mh=Th||(Th={}))[Mh.Varint=0]="Varint",Mh[Mh.Bit64=1]="Bit64",Mh[Mh.LengthDelimited=2]="LengthDelimited",Mh[Mh.StartGroup=3]="StartGroup",Mh[Mh.EndGroup=4]="EndGroup",Mh[Mh.Bit32=5]="Bit32";class Rh{constructor(e){this.stack=[],this.textEncoder=null!=e?e:new TextEncoder,this.chunks=[],this.buf=[]}finish(){this.chunks.push(new Uint8Array(this.buf));let e=0;for(let o=0;o<this.chunks.length;o++)e+=this.chunks[o].length;let t=new Uint8Array(e),n=0;for(let o=0;o<this.chunks.length;o++)t.set(this.chunks[o],n),n+=this.chunks[o].length;return this.chunks=[],t}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),t=this.stack.pop();if(!t)throw new Error("invalid state, fork stack empty");return this.chunks=t.chunks,this.buf=t.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,t){return this.uint32((e<<3|t)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(ih(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return ah(e),Sh(e,this.buf),this}bool(e){return this.buf.push(e?1:0),this}bytes(e){return this.uint32(e.byteLength),this.raw(e)}string(e){let t=this.textEncoder.encode(e);return this.uint32(t.byteLength),this.raw(t)}float(e){sh(e);let t=new Uint8Array(4);return new DataView(t.buffer).setFloat32(0,e,!0),this.raw(t)}double(e){let t=new Uint8Array(8);return new DataView(t.buffer).setFloat64(0,e,!0),this.raw(t)}fixed32(e){ih(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){ah(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return ah(e),Sh(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=Eh.enc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),o=Eh.uEnc(e);return n.setInt32(0,o.lo,!0),n.setInt32(4,o.hi,!0),this.raw(t)}int64(e){let t=Eh.enc(e);return gh(t.lo,t.hi,this.buf),this}sint64(e){let t=Eh.enc(e),n=t.hi>>31;return gh(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Eh.uEnc(e);return gh(t.lo,t.hi,this.buf),this}}class Lh{constructor(e,t){this.varint64=ph,this.uint32=Nh,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=null!=t?t:new TextDecoder}tag(){let e=this.uint32(),t=e>>>3,n=7&e;if(t<=0||n<0||n>5)throw new Error("illegal tag: field no "+t+" wire type "+n);return[t,n]}skip(e,t){let n=this.pos;switch(e){case Th.Varint:for(;128&this.buf[this.pos++];);break;case Th.Bit64:this.pos+=4;case Th.Bit32:this.pos+=4;break;case Th.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Th.StartGroup:for(;;){const[e,n]=this.tag();if(n===Th.EndGroup){if(void 0!==t&&e!==t)throw new Error("invalid end group tag");break}this.skip(n,e)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(n,this.pos)}assertBounds(){if(this.pos>this.len)throw new RangeError("premature EOF")}int32(){return 0|this.uint32()}sint32(){let e=this.uint32();return e>>>1^-(1&e)}int64(){return Eh.dec(...this.varint64())}uint64(){return Eh.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,Eh.dec(e,t)}bool(){let[e,t]=this.varint64();return 0!==e||0!==t}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return Eh.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Eh.dec(this.sfixed32(),this.sfixed32())}float(){return this.view.getFloat32((this.pos+=4)-4,!0)}double(){return this.view.getFloat64((this.pos+=8)-8,!0)}bytes(){let e=this.uint32(),t=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(t,t+e)}string(){return this.textDecoder.decode(this.bytes())}}function zh(e){const t=e.field.localName,n=Object.create(null);return n[t]=function(e){const t=e.field;if(t.repeated)return[];if(void 0!==t.default)return t.default;switch(t.kind){case"enum":return t.T.values[0].no;case"scalar":return Dh(t.T,t.L);case"message":const e=t.T,n=new e;return e.fieldWrapper?e.fieldWrapper.unwrapField(n):n;case"map":throw"map fields are not allowed to be extensions"}}(e),[n,()=>n[t]]}let Fh="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Bh=[];for(let oF=0;oF<Fh.length;oF++)Bh[Fh[oF].charCodeAt(0)]=oF;Bh["-".charCodeAt(0)]=Fh.indexOf("+"),Bh["_".charCodeAt(0)]=Fh.indexOf("/");const Uh={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,o=new Uint8Array(t),r=0,a=0,i=0;for(let s=0;s<e.length;s++){if(n=Bh[e.charCodeAt(s)],void 0===n)switch(e[s]){case"=":a=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(a){case 0:i=n,a=1;break;case 1:o[r++]=i<<2|(48&n)>>4,i=n,a=2;break;case 2:o[r++]=(15&i)<<4|(60&n)>>2,i=n,a=3;break;case 3:o[r++]=(3&i)<<6|n,a=0}}if(1==a)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(e){let t,n="",o=0,r=0;for(let a=0;a<e.length;a++)switch(t=e[a],o){case 0:n+=Fh[t>>2],r=(3&t)<<4,o=1;break;case 1:n+=Fh[r|t>>4],r=(15&t)<<2,o=2;break;case 2:n+=Fh[r|t>>6],n+=Fh[63&t],o=0}return o&&(n+=Fh[r],n+="=",1==o&&(n+="=")),n}};function Vh(e,t,n){Wh(t,e);const o=t.runtime.bin.makeReadOptions(n),r=function(e,t){if(!t.repeated&&("enum"==t.kind||"scalar"==t.kind)){for(let n=e.length-1;n>=0;--n)if(e[n].no==t.no)return[e[n]];return[]}return e.filter((e=>e.no===t.no))}(e.getType().runtime.bin.listUnknownFields(e),t.field),[a,i]=zh(t);for(const s of r)t.runtime.bin.readField(a,o.readerFactory(s.data),t.field,s.wireType,o);return i()}function Hh(e,t,n,o){Wh(t,e);const r=t.runtime.bin.makeReadOptions(o),a=t.runtime.bin.makeWriteOptions(o);if($h(e,t)){const n=e.getType().runtime.bin.listUnknownFields(e).filter((e=>e.no!=t.field.no));e.getType().runtime.bin.discardUnknownFields(e);for(const t of n)e.getType().runtime.bin.onUnknownField(e,t.no,t.wireType,t.data)}const i=a.writerFactory();let s=t.field;s.opt||s.repeated||"enum"!=s.kind&&"scalar"!=s.kind||(s=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(s,n,i,a);const l=r.readerFactory(i.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),o=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,o)}}function $h(e,t){const n=e.getType();return t.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(e).find((e=>e.no==t.field.no))}function Wh(e,t){rh(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Gh(e,t){const n=e.localName;if(e.repeated)return t[n].length>0;if(e.oneof)return t[e.oneof.localName].case===n;switch(e.kind){case"enum":case"scalar":return e.opt||e.req?void 0!==t[n]:"enum"==e.kind?t[n]!==e.T.values[0].no:!Ph(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function qh(e,t){const n=e.localName,o=!e.opt&&!e.req;if(e.repeated)t[n]=[];else if(e.oneof)t[e.oneof.localName]={case:void 0};else switch(e.kind){case"map":t[n]={};break;case"enum":t[n]=o?e.T.values[0].no:void 0;break;case"scalar":t[n]=o?Dh(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function Yh(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(mh.prototype).every((t=>t in e&&"function"==typeof e[t])))return!1;const n=e.getType();return null!==n&&"function"==typeof n&&"typeName"in n&&"string"==typeof n.typeName&&(void 0===t||n.typeName==t.typeName)}function Xh(e,t){return Yh(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}jh.DOUBLE,jh.FLOAT,jh.INT64,jh.UINT64,jh.INT32,jh.UINT32,jh.BOOL,jh.STRING,jh.BYTES;const Kh={ignoreUnknownFields:!1},Jh={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function Zh(e){return e?Object.assign(Object.assign({},Kh),e):Kh}function Qh(e){return e?Object.assign(Object.assign({},Jh),e):Jh}const ef=Symbol(),tf=Symbol();function nf(e){if(null===e)return"null";switch(typeof e){case"object":return Array.isArray(e)?"array":"object";case"string":return e.length>100?"string":`"${e.split('"').join('\\"')}"`;default:return String(e)}}function of(e,t,n,o,r){let a=n.localName;if(n.repeated){if(rh("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`);const s=e[a];for(const e of t){if(null===e)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(e)}`);switch(n.kind){case"message":s.push(n.T.fromJson(e,o));break;case"enum":const t=sf(n.T,e,o.ignoreUnknownFields,!0);t!==tf&&s.push(t);break;case"scalar":try{s.push(af(n.T,e,n.L,!0))}catch(i){let t=`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(e)}`;throw i instanceof Error&&i.message.length>0&&(t+=`: ${i.message}`),new Error(t)}}}}else if("map"==n.kind){if(null===t)return;if("object"!=typeof t||Array.isArray(t))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`);const s=e[a];for(const[e,a]of Object.entries(t)){if(null===a)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let l;try{l=rf(n.K,e)}catch(i){let e=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}switch(n.V.kind){case"message":s[l]=n.V.T.fromJson(a,o);break;case"enum":const e=sf(n.V.T,a,o.ignoreUnknownFields,!0);e!==tf&&(s[l]=e);break;case"scalar":try{s[l]=af(n.V.T,a,Ih.BIGINT,!0)}catch(i){let e=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}}else switch(n.oneof&&(e=e[n.oneof.localName]={case:a},a="value"),n.kind){case"message":const s=n.T;if(null===t&&"google.protobuf.Value"!=s.typeName)return;let l=e[a];Yh(l)?l.fromJson(t,o):(e[a]=l=s.fromJson(t,o),s.fieldWrapper&&!n.oneof&&(e[a]=s.fieldWrapper.unwrapField(l)));break;case"enum":const c=sf(n.T,t,o.ignoreUnknownFields,!1);switch(c){case ef:qh(n,e);break;case tf:break;default:e[a]=c}break;case"scalar":try{const o=af(n.T,t,n.L,!1);if(o===ef)qh(n,e);else e[a]=o}catch(i){let e=`cannot decode field ${r.typeName}.${n.name} from JSON: ${nf(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}function rf(e,t){if(e===jh.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return af(e,t,Ih.BIGINT,!0).toString()}function af(e,t,n,o){if(null===t)return o?Dh(e,n):ef;switch(e){case jh.DOUBLE:case jh.FLOAT:if("NaN"===t)return Number.NaN;if("Infinity"===t)return Number.POSITIVE_INFINITY;if("-Infinity"===t)return Number.NEGATIVE_INFINITY;if(""===t)break;if("string"==typeof t&&t.trim().length!==t.length)break;if("string"!=typeof t&&"number"!=typeof t)break;const o=Number(t);if(Number.isNaN(o))break;if(!Number.isFinite(o))break;return e==jh.FLOAT&&sh(o),o;case jh.INT32:case jh.FIXED32:case jh.SFIXED32:case jh.SINT32:case jh.UINT32:let a;if("number"==typeof t?a=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(a=Number(t)),void 0===a)break;return e==jh.UINT32||e==jh.FIXED32?ih(a):ah(a),a;case jh.INT64:case jh.SFIXED64:case jh.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=Eh.parse(t);return n?i.toString():i;case jh.FIXED64:case jh.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const s=Eh.uParse(t);return n?s.toString():s;case jh.BOOL:if("boolean"!=typeof t)break;return t;case jh.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(r){throw new Error("invalid UTF8")}return t;case jh.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return Uh.dec(t)}throw new Error}function sf(e,t,n,o){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:o?e.values[0].no:ef;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const o=e.findName(t);if(void 0!==o)return o.no;if(n)return tf}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${nf(t)}`)}function lf(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function cf(e,t,n){if("map"==e.kind){rh("object"==typeof t&&null!=t);const o={},r=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,a]of r)o[n.toString()]=uf(e.V.T,a);break;case"message":for(const[e,a]of r)o[e.toString()]=a.toJson(n);break;case"enum":const t=e.V.T;for(const[e,a]of r)o[e.toString()]=df(t,a,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(e.repeated){rh(Array.isArray(t));const o=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)o.push(uf(e.T,t[n]));break;case"enum":for(let r=0;r<t.length;r++)o.push(df(e.T,t[r],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)o.push(t[e].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(e.kind){case"scalar":return uf(e.T,t);case"enum":return df(e.T,t,n.enumAsInteger);case"message":return Xh(e.T,t).toJson(n)}}function df(e,t,n){var o;if(rh("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const r=e.findNumber(t);return null!==(o=null==r?void 0:r.name)&&void 0!==o?o:t}function uf(e,t){switch(e){case jh.INT32:case jh.SFIXED32:case jh.SINT32:case jh.FIXED32:case jh.UINT32:return rh("number"==typeof t),t;case jh.FLOAT:case jh.DOUBLE:return rh("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case jh.STRING:return rh("string"==typeof t),t;case jh.BOOL:return rh("boolean"==typeof t),t;case jh.UINT64:case jh.FIXED64:case jh.INT64:case jh.SFIXED64:case jh.SINT64:return rh("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case jh.BYTES:return rh(t instanceof Uint8Array),Uh.enc(t)}}const hf=Symbol("@bufbuild/protobuf/unknown-fields"),ff={readUnknownFields:!0,readerFactory:e=>new Lh(e)},mf={writeUnknownFields:!0,writerFactory:()=>new Rh};function pf(e){return e?Object.assign(Object.assign({},ff),e):ff}function gf(e){return e?Object.assign(Object.assign({},mf),e):mf}function vf(e,t,n,o,r){let{repeated:a,localName:i}=n;switch(n.oneof&&((e=e[n.oneof.localName]).case!=i&&delete e.value,e.case=i,i="value"),n.kind){case"scalar":case"enum":const s="enum"==n.kind?jh.INT32:n.T;let l=bf;if("scalar"==n.kind&&n.L>0&&(l=xf),a){let n=e[i];if(o==Th.LengthDelimited&&s!=jh.STRING&&s!=jh.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,s))}else n.push(l(t,s))}else e[i]=l(t,s);break;case"message":const c=n.T;a?e[i].push(yf(t,new c,r,n)):Yh(e[i])?yf(t,e[i],r,n):(e[i]=yf(t,new c,r,n),!c.fieldWrapper||n.oneof||n.repeated||(e[i]=c.fieldWrapper.unwrapField(e[i])));break;case"map":let[d,u]=function(e,t,n){const o=t.uint32(),r=t.pos+o;let a,i;for(;t.pos<r;){const[o]=t.tag();switch(o){case 1:a=bf(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=bf(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=yf(t,new e.V.T,n,void 0)}}}void 0===a&&(a=Dh(e.K,Ih.BIGINT));"string"!=typeof a&&"number"!=typeof a&&(a=a.toString());if(void 0===i)switch(e.V.kind){case"scalar":i=Dh(e.V.T,Ih.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T}return[a,i]}(n,t,r);e[i][d]=u}}function yf(e,t,n,o){const r=t.getType().runtime.bin,a=null==o?void 0:o.delimited;return r.readMessage(t,e,a?o.no:e.uint32(),n,a),t}function xf(e,t){const n=bf(e,t);return"bigint"==typeof n?n.toString():n}function bf(e,t){switch(t){case jh.STRING:return e.string();case jh.BOOL:return e.bool();case jh.DOUBLE:return e.double();case jh.FLOAT:return e.float();case jh.INT32:return e.int32();case jh.INT64:return e.int64();case jh.UINT64:return e.uint64();case jh.FIXED64:return e.fixed64();case jh.BYTES:return e.bytes();case jh.FIXED32:return e.fixed32();case jh.SFIXED32:return e.sfixed32();case jh.SFIXED64:return e.sfixed64();case jh.SINT64:return e.sint64();case jh.UINT32:return e.uint32();case jh.SINT32:return e.sint32()}}function wf(e,t,n,o){rh(void 0!==t);const r=e.repeated;switch(e.kind){case"scalar":case"enum":let a="enum"==e.kind?jh.INT32:e.T;if(r)if(rh(Array.isArray(t)),e.packed)!function(e,t,n,o){if(!o.length)return;e.tag(n,Th.LengthDelimited).fork();let[,r]=Cf(t);for(let a=0;a<o.length;a++)e[r](o[a]);e.join()}(n,a,e.no,t);else for(const o of t)Nf(n,a,e.no,o);else Nf(n,a,e.no,t);break;case"message":if(r){rh(Array.isArray(t));for(const r of t)Sf(n,o,e,r)}else Sf(n,o,e,t);break;case"map":rh("object"==typeof t&&null!=t);for(const[r,i]of Object.entries(t))kf(n,o,e,r,i)}}function kf(e,t,n,o,r){e.tag(n.no,Th.LengthDelimited),e.fork();let a=o;switch(n.K){case jh.INT32:case jh.FIXED32:case jh.UINT32:case jh.SFIXED32:case jh.SINT32:a=Number.parseInt(o);break;case jh.BOOL:rh("true"==o||"false"==o),a="true"==o}switch(Nf(e,n.K,1,a),n.V.kind){case"scalar":Nf(e,n.V.T,2,r);break;case"enum":Nf(e,jh.INT32,2,r);break;case"message":rh(void 0!==r),e.tag(2,Th.LengthDelimited).bytes(r.toBinary(t))}e.join()}function Sf(e,t,n,o){const r=Xh(n.T,o);n.delimited?e.tag(n.no,Th.StartGroup).raw(r.toBinary(t)).tag(n.no,Th.EndGroup):e.tag(n.no,Th.LengthDelimited).bytes(r.toBinary(t))}function Nf(e,t,n,o){rh(void 0!==o);let[r,a]=Cf(t);e.tag(n,r)[a](o)}function Cf(e){let t=Th.Varint;switch(e){case jh.BYTES:case jh.STRING:t=Th.LengthDelimited;break;case jh.DOUBLE:case jh.FIXED64:case jh.SFIXED64:t=Th.Bit64;break;case jh.FIXED32:case jh.SFIXED32:case jh.FLOAT:t=Th.Bit32}return[t,jh[e].toLowerCase()]}function Ef(e){if(void 0===e)return e;if(Yh(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function jf(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class _f{constructor(e,t){this._fields=e,this._normalizer=t}findJsonName(e){if(!this.jsonNames){const e={};for(const t of this.list())e[t.jsonName]=e[t.name]=t;this.jsonNames=e}return this.jsonNames[e]}find(e){if(!this.numbers){const e={};for(const t of this.list())e[t.no]=t;this.numbers=e}return this.numbers[e]}list(){return this.all||(this.all=this._normalizer(this._fields)),this.all}byNumber(){return this.numbersAsc||(this.numbersAsc=this.list().concat().sort(((e,t)=>e.no-t.no))),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let t;for(const n of this.list())n.oneof?n.oneof!==t&&(t=n.oneof,e.push(t)):e.push(n)}return this.members}}function If(e,t){const n=Tf(e);return t?n:Rf(Pf(n))}const Af=Tf;function Tf(e){let t=!1;const n=[];for(let o=0;o<e.length;o++){let r=e.charAt(o);switch(r){case"_":t=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),t=!1;break;default:t&&(t=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const Mf=new Set(["constructor","toString","toJSON","valueOf"]),Of=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Df=e=>`${e}$`,Pf=e=>Of.has(e)?Df(e):e,Rf=e=>Mf.has(e)?Df(e):e;class Lf{constructor(e){this.kind="oneof",this.repeated=!1,this.packed=!1,this.opt=!1,this.req=!1,this.default=void 0,this.fields=[],this.name=e,this.localName=If(e,!1)}addField(e){rh(e.oneof===this,`field ${e.name} not one of ${this.name}`),this.fields.push(e)}findField(e){if(!this._lookup){this._lookup=Object.create(null);for(let e=0;e<this.fields.length;e++)this._lookup[this.fields[e].localName]=this.fields[e]}return this._lookup[e]}}const zf=(Ff=e=>new _f(e,(e=>function(e){var t,n,o,r,a,i;const s=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=If(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Af(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(o=c.L)&&void 0!==o?o:Ih.BIGINT),e.delimited=null!==(r=c.delimited)&&void 0!==r&&r,e.req=null!==(a=c.req)&&void 0!==a&&a,e.opt=null!==(i=c.opt)&&void 0!==i&&i,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=jh.BYTES&&c.T!=jh.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new Lf(t)),e.oneof=l,l.addField(e)}s.push(e)}return s}(e))),Bf=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,o=e;if(t.repeated)o[n]=[];else switch(t.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=Dh(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:Zh,makeWriteOptions:Qh,readMessage(e,t,n,o){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${nf(t)}`);o=null!=o?o:new e;const r=new Map,a=n.typeRegistry;for(const[i,s]of Object.entries(t)){const t=e.fields.findJsonName(i);if(t){if(t.oneof){if(null===s&&"scalar"==t.kind)continue;const n=r.get(t.oneof);if(void 0!==n)throw new Error(`cannot decode message ${e.typeName} from JSON: multiple keys for oneof "${t.oneof.name}" present: "${n}", "${i}"`);r.set(t.oneof,i)}of(o,s,t,n,e)}else{let t=!1;if((null==a?void 0:a.findExtension)&&i.startsWith("[")&&i.endsWith("]")){const r=a.findExtension(i.substring(1,i.length-1));if(r&&r.extendee.typeName==e.typeName){t=!0;const[e,a]=zh(r);of(e,s,r.field,n,r),Hh(o,r,a(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return o},writeMessage(e,t){const n=e.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!Gh(r,e)){if(r.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!lf(r))continue}const n=cf(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t);void 0!==n&&(o[t.useProtoFieldName?r.name:r.jsonName]=n)}const a=t.typeRegistry;if(null==a?void 0:a.findExtensionFor)for(const r of n.runtime.bin.listUnknownFields(e)){const i=a.findExtensionFor(n.typeName,r.no);if(i&&$h(e,i)){const n=Vh(e,i,t),r=cf(i.field,n,t);void 0!==r&&(o[i.field.jsonName]=r)}}}catch(a){const e=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=a instanceof Error?a.message:String(a);throw new Error(e+(t.length>0?`: ${t}`:""))}return o},readScalar:(e,t,n)=>af(e,t,null!=n?n:Ih.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||Ph(e,t)?uf(e,t):void 0},debug:nf},bin:{makeReadOptions:pf,makeWriteOptions:gf,listUnknownFields(e){var t;return null!==(t=e[hf])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[hf]},writeUnknownFields(e,t){const n=e[hf];if(n)for(const o of n)t.tag(o.no,o.wireType).raw(o.data)},onUnknownField(e,t,n,o){const r=e;Array.isArray(r[hf])||(r[hf]=[]),r[hf].push({no:t,wireType:n,data:o})},readMessage(e,t,n,o,r){const a=e.getType(),i=r?t.len:t.pos+n;let s,l;for(;t.pos<i&&([s,l]=t.tag(),!0!==r||l!=Th.EndGroup);){const n=a.fields.find(s);if(n)vf(e,t,n,l,o);else{const n=t.skip(l,s);o.readUnknownFields&&this.onUnknownField(e,s,l,n)}}if(r&&(l!=Th.EndGroup||s!==n))throw new Error("invalid end group tag")},readField:vf,writeMessage(e,t,n){const o=e.getType();for(const r of o.fields.byNumber())if(Gh(r,e))wf(r,r.oneof?e[r.oneof.localName].value:e[r.localName],t,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,o){void 0!==t&&wf(e,t,n,o)}},util:Object.assign(Object.assign({},{setEnumType:dh,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const o of n.fields.byMember()){const n=o.localName,r=t,a=e;if(null!=a[n])switch(o.kind){case"oneof":const e=a[n].case;if(void 0===e)continue;const t=o.findField(e);let i=a[n].value;t&&"message"==t.kind&&!Yh(i,t.T)?i=new t.T(i):t&&"scalar"===t.kind&&t.T===jh.BYTES&&(i=jf(i)),r[n]={case:e,value:i};break;case"scalar":case"enum":let s=a[n];o.T===jh.BYTES&&(s=o.repeated?s.map(jf):jf(s)),r[n]=s;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===jh.BYTES)for(const[t,o]of Object.entries(a[n]))r[n][t]=jf(o);else Object.assign(r[n],a[n]);break;case"message":const e=o.V.T;for(const t of Object.keys(a[n])){let o=a[n][t];e.fieldWrapper||(o=new e(o)),r[n][t]=o}}break;case"message":const l=o.T;if(o.repeated)r[n]=a[n].map((e=>Yh(e,l)?e:new l(e)));else{const e=a[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?r[n]=jf(e):r[n]=e:r[n]=Yh(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const o=t[e.localName],r=n[e.localName];if(e.repeated){if(o.length!==r.length)return!1;switch(e.kind){case"message":return o.every(((t,n)=>e.T.equals(t,r[n])));case"scalar":return o.every(((t,n)=>Oh(e.T,t,r[n])));case"enum":return o.every(((e,t)=>Oh(jh.INT32,e,r[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(o,r);case"enum":return Oh(jh.INT32,o,r);case"scalar":return Oh(e.T,o,r);case"oneof":if(o.case!==r.case)return!1;const t=e.findField(o.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(o.value,r.value);case"enum":return Oh(jh.INT32,o.value,r.value);case"scalar":return Oh(t.T,o.value,r.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(o).concat(Object.keys(r));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(o[e],r[e])));case"enum":return n.every((e=>Oh(jh.INT32,o[e],r[e])));case"scalar":const a=e.V.T;return n.every((e=>Oh(a,o[e],r[e])))}}})),clone(e){const t=e.getType(),n=new t,o=n;for(const r of t.fields.byMember()){const t=e[r.localName];let n;if(r.repeated)n=t.map(Ef);else if("map"==r.kind){n=o[r.localName];for(const[e,o]of Object.entries(t))n[e]=Ef(o)}else n="oneof"==r.kind?r.findField(t.case)?{case:t.case,value:Ef(t.value)}:{case:void 0}:Ef(t);o[r.localName]=n}for(const r of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:Ff,initFields:Bf}),makeMessageType(e,t,n){return function(e,t,n,o){var r;const a=null!==(r=null==o?void 0:o.localName)&&void 0!==r?r:t.substring(t.lastIndexOf(".")+1),i={[a]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[a];return Object.setPrototypeOf(i.prototype,new mh),Object.assign(i,{runtime:e,typeName:t,fields:e.util.newFieldList(n),fromBinary:(e,t)=>(new i).fromBinary(e,t),fromJson:(e,t)=>(new i).fromJson(e,t),fromJsonString:(e,t)=>(new i).fromJsonString(e,t),equals:(t,n)=>e.util.equals(i,t,n)}),i}(this,e,t,n)},makeEnum:hh,makeEnumType:uh,getEnumType:ch,makeExtension(e,t,n){return function(e,t,n,o){let r;return{typeName:t,extendee:n,get field(){if(!r){const n="function"==typeof o?o():o;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,r=e.util.newFieldList([n]).list()[0]}return r},runtime:e}}(this,e,t,n)}});var Ff,Bf,Uf,Vf,Hf,$f,Wf,Gf,qf,Yf,Xf,Kf,Jf,Zf,Qf,em;(Vf=Uf||(Uf={}))[Vf.Unary=0]="Unary",Vf[Vf.ServerStreaming=1]="ServerStreaming",Vf[Vf.ClientStreaming=2]="ClientStreaming",Vf[Vf.BiDiStreaming=3]="BiDiStreaming",($f=Hf||(Hf={}))[$f.NoSideEffects=1]="NoSideEffects",$f[$f.Idempotent=2]="Idempotent",(Gf=Wf||(Wf={}))[Gf.UNSPECIFIED=0]="UNSPECIFIED",Gf[Gf.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",zf.util.setEnumType(Wf,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(Yf=qf||(qf={}))[Yf.CODEIUM=0]="CODEIUM",zf.util.setEnumType(qf,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(Kf=Xf||(Xf={}))[Kf.UNSPECIFIED=0]="UNSPECIFIED",Kf[Kf.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",Kf[Kf.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",Kf[Kf.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",Kf[Kf.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",zf.util.setEnumType(Xf,"exa.codeium_common_pb.EventType",[{no:0,name:"EVENT_TYPE_UNSPECIFIED"},{no:1,name:"EVENT_TYPE_ENABLE_CODEIUM"},{no:2,name:"EVENT_TYPE_DISABLE_CODEIUM"},{no:3,name:"EVENT_TYPE_SHOW_PREVIOUS_COMPLETION"},{no:4,name:"EVENT_TYPE_SHOW_NEXT_COMPLETION"}]),(Zf=Jf||(Jf={}))[Zf.UNSPECIFIED=0]="UNSPECIFIED",Zf[Zf.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",Zf[Zf.CACHE=2]="CACHE",Zf[Zf.NETWORK=3]="NETWORK",zf.util.setEnumType(Jf,"exa.codeium_common_pb.CompletionSource",[{no:0,name:"COMPLETION_SOURCE_UNSPECIFIED"},{no:1,name:"COMPLETION_SOURCE_TYPING_AS_SUGGESTED"},{no:2,name:"COMPLETION_SOURCE_CACHE"},{no:3,name:"COMPLETION_SOURCE_NETWORK"}]),(em=Qf||(Qf={}))[em.UNSPECIFIED=0]="UNSPECIFIED",em[em.C=1]="C",em[em.CLOJURE=2]="CLOJURE",em[em.COFFEESCRIPT=3]="COFFEESCRIPT",em[em.CPP=4]="CPP",em[em.CSHARP=5]="CSHARP",em[em.CSS=6]="CSS",em[em.CUDACPP=7]="CUDACPP",em[em.DOCKERFILE=8]="DOCKERFILE",em[em.GO=9]="GO",em[em.GROOVY=10]="GROOVY",em[em.HANDLEBARS=11]="HANDLEBARS",em[em.HASKELL=12]="HASKELL",em[em.HCL=13]="HCL",em[em.HTML=14]="HTML",em[em.INI=15]="INI",em[em.JAVA=16]="JAVA",em[em.JAVASCRIPT=17]="JAVASCRIPT",em[em.JSON=18]="JSON",em[em.JULIA=19]="JULIA",em[em.KOTLIN=20]="KOTLIN",em[em.LATEX=21]="LATEX",em[em.LESS=22]="LESS",em[em.LUA=23]="LUA",em[em.MAKEFILE=24]="MAKEFILE",em[em.MARKDOWN=25]="MARKDOWN",em[em.OBJECTIVEC=26]="OBJECTIVEC",em[em.OBJECTIVECPP=27]="OBJECTIVECPP",em[em.PERL=28]="PERL",em[em.PHP=29]="PHP",em[em.PLAINTEXT=30]="PLAINTEXT",em[em.PROTOBUF=31]="PROTOBUF",em[em.PBTXT=32]="PBTXT",em[em.PYTHON=33]="PYTHON",em[em.R=34]="R",em[em.RUBY=35]="RUBY",em[em.RUST=36]="RUST",em[em.SASS=37]="SASS",em[em.SCALA=38]="SCALA",em[em.SCSS=39]="SCSS",em[em.SHELL=40]="SHELL",em[em.SQL=41]="SQL",em[em.STARLARK=42]="STARLARK",em[em.SWIFT=43]="SWIFT",em[em.TSX=44]="TSX",em[em.TYPESCRIPT=45]="TYPESCRIPT",em[em.VISUALBASIC=46]="VISUALBASIC",em[em.VUE=47]="VUE",em[em.XML=48]="XML",em[em.XSL=49]="XSL",em[em.YAML=50]="YAML",em[em.SVELTE=51]="SVELTE",em[em.TOML=52]="TOML",em[em.DART=53]="DART",em[em.RST=54]="RST",em[em.OCAML=55]="OCAML",em[em.CMAKE=56]="CMAKE",em[em.PASCAL=57]="PASCAL",em[em.ELIXIR=58]="ELIXIR",em[em.FSHARP=59]="FSHARP",em[em.LISP=60]="LISP",em[em.MATLAB=61]="MATLAB",em[em.POWERSHELL=62]="POWERSHELL",em[em.SOLIDITY=63]="SOLIDITY",em[em.ADA=64]="ADA",em[em.OCAML_INTERFACE=65]="OCAML_INTERFACE",zf.util.setEnumType(Qf,"exa.codeium_common_pb.Language",[{no:0,name:"LANGUAGE_UNSPECIFIED"},{no:1,name:"LANGUAGE_C"},{no:2,name:"LANGUAGE_CLOJURE"},{no:3,name:"LANGUAGE_COFFEESCRIPT"},{no:4,name:"LANGUAGE_CPP"},{no:5,name:"LANGUAGE_CSHARP"},{no:6,name:"LANGUAGE_CSS"},{no:7,name:"LANGUAGE_CUDACPP"},{no:8,name:"LANGUAGE_DOCKERFILE"},{no:9,name:"LANGUAGE_GO"},{no:10,name:"LANGUAGE_GROOVY"},{no:11,name:"LANGUAGE_HANDLEBARS"},{no:12,name:"LANGUAGE_HASKELL"},{no:13,name:"LANGUAGE_HCL"},{no:14,name:"LANGUAGE_HTML"},{no:15,name:"LANGUAGE_INI"},{no:16,name:"LANGUAGE_JAVA"},{no:17,name:"LANGUAGE_JAVASCRIPT"},{no:18,name:"LANGUAGE_JSON"},{no:19,name:"LANGUAGE_JULIA"},{no:20,name:"LANGUAGE_KOTLIN"},{no:21,name:"LANGUAGE_LATEX"},{no:22,name:"LANGUAGE_LESS"},{no:23,name:"LANGUAGE_LUA"},{no:24,name:"LANGUAGE_MAKEFILE"},{no:25,name:"LANGUAGE_MARKDOWN"},{no:26,name:"LANGUAGE_OBJECTIVEC"},{no:27,name:"LANGUAGE_OBJECTIVECPP"},{no:28,name:"LANGUAGE_PERL"},{no:29,name:"LANGUAGE_PHP"},{no:30,name:"LANGUAGE_PLAINTEXT"},{no:31,name:"LANGUAGE_PROTOBUF"},{no:32,name:"LANGUAGE_PBTXT"},{no:33,name:"LANGUAGE_PYTHON"},{no:34,name:"LANGUAGE_R"},{no:35,name:"LANGUAGE_RUBY"},{no:36,name:"LANGUAGE_RUST"},{no:37,name:"LANGUAGE_SASS"},{no:38,name:"LANGUAGE_SCALA"},{no:39,name:"LANGUAGE_SCSS"},{no:40,name:"LANGUAGE_SHELL"},{no:41,name:"LANGUAGE_SQL"},{no:42,name:"LANGUAGE_STARLARK"},{no:43,name:"LANGUAGE_SWIFT"},{no:44,name:"LANGUAGE_TSX"},{no:45,name:"LANGUAGE_TYPESCRIPT"},{no:46,name:"LANGUAGE_VISUALBASIC"},{no:47,name:"LANGUAGE_VUE"},{no:48,name:"LANGUAGE_XML"},{no:49,name:"LANGUAGE_XSL"},{no:50,name:"LANGUAGE_YAML"},{no:51,name:"LANGUAGE_SVELTE"},{no:52,name:"LANGUAGE_TOML"},{no:53,name:"LANGUAGE_DART"},{no:54,name:"LANGUAGE_RST"},{no:55,name:"LANGUAGE_OCAML"},{no:56,name:"LANGUAGE_CMAKE"},{no:57,name:"LANGUAGE_PASCAL"},{no:58,name:"LANGUAGE_ELIXIR"},{no:59,name:"LANGUAGE_FSHARP"},{no:60,name:"LANGUAGE_LISP"},{no:61,name:"LANGUAGE_MATLAB"},{no:62,name:"LANGUAGE_POWERSHELL"},{no:63,name:"LANGUAGE_SOLIDITY"},{no:64,name:"LANGUAGE_ADA"},{no:65,name:"LANGUAGE_OCAML_INTERFACE"}]);const tm=class e extends mh{constructor(e){super(),n(this,"completionId",""),n(this,"text",""),n(this,"prefix",""),n(this,"stop",""),n(this,"score",0),n(this,"tokens",[]),n(this,"decodedTokens",[]),n(this,"probabilities",[]),n(this,"adjustedProbabilities",[]),n(this,"generatedLength",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(tm,"runtime",zf),n(tm,"typeName","exa.codeium_common_pb.Completion"),n(tm,"fields",zf.util.newFieldList((()=>[{no:1,name:"completion_id",kind:"scalar",T:9},{no:2,name:"text",kind:"scalar",T:9},{no:3,name:"prefix",kind:"scalar",T:9},{no:4,name:"stop",kind:"scalar",T:9},{no:5,name:"score",kind:"scalar",T:1},{no:6,name:"tokens",kind:"scalar",T:4,repeated:!0},{no:7,name:"decoded_tokens",kind:"scalar",T:9,repeated:!0},{no:8,name:"probabilities",kind:"scalar",T:1,repeated:!0},{no:9,name:"adjusted_probabilities",kind:"scalar",T:1,repeated:!0},{no:10,name:"generated_length",kind:"scalar",T:4}])));let nm=tm;const om=class e extends mh{constructor(e){super(),n(this,"ideName",""),n(this,"ideVersion",""),n(this,"extensionName",""),n(this,"extensionVersion",""),n(this,"apiKey",""),n(this,"locale",""),n(this,"sessionId",""),n(this,"requestId",Eh.zero),n(this,"userAgent",""),n(this,"url",""),n(this,"authSource",qf.CODEIUM),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(om,"runtime",zf),n(om,"typeName","exa.codeium_common_pb.Metadata"),n(om,"fields",zf.util.newFieldList((()=>[{no:1,name:"ide_name",kind:"scalar",T:9},{no:7,name:"ide_version",kind:"scalar",T:9},{no:12,name:"extension_name",kind:"scalar",T:9},{no:2,name:"extension_version",kind:"scalar",T:9},{no:3,name:"api_key",kind:"scalar",T:9},{no:4,name:"locale",kind:"scalar",T:9},{no:10,name:"session_id",kind:"scalar",T:9},{no:9,name:"request_id",kind:"scalar",T:4},{no:13,name:"user_agent",kind:"scalar",T:9},{no:14,name:"url",kind:"scalar",T:9},{no:15,name:"auth_source",kind:"enum",T:zf.getEnumType(qf)}])));let rm=om;const am=class e extends mh{constructor(e){super(),n(this,"tabSize",Eh.zero),n(this,"insertSpaces",!1),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(am,"runtime",zf),n(am,"typeName","exa.codeium_common_pb.EditorOptions"),n(am,"fields",zf.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let im=am;e=class extends mh{constructor(e){super(),n(this,"eventType",Xf.UNSPECIFIED),n(this,"eventJson",""),n(this,"timestampUnixMs",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}},n(e,"runtime",zf),n(e,"typeName","exa.codeium_common_pb.Event"),n(e,"fields",zf.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:zf.getEnumType(Xf)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class sm extends xn{constructor(e,t){super(),n(this,"index"),n(this,"total"),this.index=e,this.total=t}toDOM(){const e=document.createElement("span");e.setAttribute("aria-hidden","true"),e.className="cm-codeium-cycle";const t=e.appendChild(document.createElement("span"));t.className="cm-codeium-cycle-explanation",t.innerText=`${this.index+1}/${this.total}`;const n=e.appendChild(document.createElement("button"));return n.className="cm-codeium-cycle-key",n.innerText="→ (Ctrl ])",n.dataset.action="codeium-cycle",e}ignoreEvent(){return!1}}const lm=bn.define({combine:e=>wn(e,{language:Qf.TYPESCRIPT,timeout:150,widgetClass:sm,alwaysOn:!0},{})}),cm=bn.define({combine:e=>wn(e,{override:()=>[]},{})}),dm=Jt.mark({class:"cm-ghostText"}),um=Kt.define({create:e=>null,update(e,t){var n;const o=t.state.facet(lm);for(const r of t.effects){if(r.is(th)){const{changeSpecs:e,index:t}=r.value,a=e[t].map((e=>dm.range(e.absoluteStartPos,e.absoluteEndPos))),i=null==(n=a.at(-1))?void 0:n.to;return{index:t,decorations:Jt.set([...a,...void 0!==i&&e.length>1&&o.widgetClass?[Jt.widget({widget:new o.widgetClass(t,e.length),side:1}).range(i)]:[]]),changeSpecs:e,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(nh))return null;if(r.is(oh))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>Yt.decorations.from(e,(e=>(null==e?void 0:e.decorations)||Jt.none))}),hm=kn.define(),fm=kn.define();var mm,pm;function gm(e){const t=mm[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let vm;(pm=mm||(mm={}))[pm.Canceled=1]="Canceled",pm[pm.Unknown=2]="Unknown",pm[pm.InvalidArgument=3]="InvalidArgument",pm[pm.DeadlineExceeded=4]="DeadlineExceeded",pm[pm.NotFound=5]="NotFound",pm[pm.AlreadyExists=6]="AlreadyExists",pm[pm.PermissionDenied=7]="PermissionDenied",pm[pm.ResourceExhausted=8]="ResourceExhausted",pm[pm.FailedPrecondition=9]="FailedPrecondition",pm[pm.Aborted=10]="Aborted",pm[pm.OutOfRange=11]="OutOfRange",pm[pm.Unimplemented=12]="Unimplemented",pm[pm.Internal=13]="Internal",pm[pm.Unavailable=14]="Unavailable",pm[pm.DataLoss=15]="DataLoss",pm[pm.Unauthenticated=16]="Unauthenticated";class ym extends Error{constructor(e,t=mm.Unknown,n,o,r){super(function(e,t){return e.length?`[${gm(t)}] ${e}`:`[${gm(t)}]`}(e,t)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=t,this.metadata=new Headers(null!=n?n:{}),this.details=null!=o?o:[],this.cause=r}static from(e,t=mm.Unknown){return e instanceof ym?e:e instanceof Error?"AbortError"==e.name?new ym(e.message,mm.Canceled):new ym(e.message,t,void 0,void 0,e):new ym(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===ym.prototype||"ConnectError"===e.name&&"code"in e&&"number"==typeof e.code&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&"string"==typeof e.rawMessage&&"cause"in e)}findDetails(e){const t="typeName"in e?{findMessage:t=>t===e.typeName?e:void 0}:e,n=[];for(const r of this.details){if("getType"in r){t.findMessage(r.getType().typeName)&&n.push(r);continue}const e=t.findMessage(r.type);if(e)try{n.push(e.fromBinary(r.value))}catch(o){}}return n}}var xm=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},bm=function(e){return this instanceof bm?(this.v=e,this):new bm(e)},wm=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof bm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};function km(e){return wm(this,arguments,(function*(){yield bm(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:bm(e[o](t)),done:!1}:r?r(t):t}:r}}(xm(e)))}))}var Sm=function(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e="function"==typeof __values?__values(e):e[Symbol.iterator](),t={},o("next"),o("throw"),o("return"),t[Symbol.asyncIterator]=function(){return this},t);function o(n){t[n]=e[n]&&function(t){return new Promise((function(o,r){(function(e,t,n,o){Promise.resolve(o).then((function(t){e({value:t,done:n})}),t)})(o,r,(t=e[n](t)).done,t.value)}))}}},Nm=function(e){return this instanceof Nm?(this.v=e,this):new Nm(e)},Cm=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof Nm?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};function Em(e,t){const n=function(){var n,o;return Cm(this,arguments,(function*(){const r=yield Nm(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,r.header),yield Nm(yield*function(e){var t,n;return t={},o("next"),o("throw",(function(e){throw e})),o("return"),t[Symbol.iterator]=function(){return this},t;function o(o,r){t[o]=e[o]?function(t){return(n=!n)?{value:Nm(e[o](t)),done:!1}:r?r(t):t}:r}}(Sm(r.message))),null===(o=null==t?void 0:t.onTrailer)||void 0===o||o.call(t,r.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function jm(e){if(!e.aborted)return;if(void 0!==e.reason)return e.reason;const t=new Error("This operation was aborted");return t.name="AbortError",t}function _m(){return{get(e){return e.id in this?this[e.id]:e.defaultValue},set(e,t){return this[e.id]=t,this},delete(e){return delete this[e.id],this}}}function Im(e,t,n){const o="string"==typeof t?t:t.typeName,r="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${o}/${r}`)}function Am(e,t){return t instanceof e?t:new e(t)}function Tm(e,t){function n(t){return!0===t.done?t:{done:t.done,value:Am(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),o={next:()=>e.next().then(n)};return void 0!==e.throw&&(o.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(o.return=t=>e.return(t).then(n)),o}}}function Mm(e,t){var n;return null!==(n=null==t?void 0:t.concat().reverse().reduce(((e,t)=>t(e)),e))&&void 0!==n?n:e}function Om(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function Dm(e,t,n,o){const r=t?Pm(e.I,o):Rm(e.I,n);return{parse:(t?Pm(e.O,o):Rm(e.O,n)).parse,serialize:r.serialize}}function Pm(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(o){const e=o instanceof Error?o.message:String(o);throw new ym(`parse binary: ${e}`,mm.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new ym(`serialize binary: ${e}`,mm.Internal)}}}}function Rm(e,t){var n,o;const r=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,a=null!==(o=null==t?void 0:t.textDecoder)&&void 0!==o?o:new TextDecoder,i=Om(t);return{parse(t){try{const n=a.decode(t);return e.fromJsonString(n,i)}catch(n){throw ym.from(n,mm.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(i);return r.encode(t)}catch(t){throw ym.from(t,mm.Internal)}}}}const Lm=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function zm(e,t,n){if(t&&new Headers(t).forEach(((e,t)=>n.metadata.append(t,e))),"object"!=typeof e||null==e||Array.isArray(e)||!("code"in e)||"string"!=typeof e.code)throw n;const o=function(e){if(!vm){vm={};for(const e of Object.values(mm))"string"!=typeof e&&(vm[gm(e)]=e)}return vm[e]}(e.code);if(void 0===o)throw n;const r=e.message;if(null!=r&&"string"!=typeof r)throw n;const a=new ym(null!=r?r:"",o,t);if("details"in e&&Array.isArray(e.details))for(const s of e.details){if(null===s||"object"!=typeof s||Array.isArray(s)||"string"!=typeof s.type||"string"!=typeof s.value||"debug"in s&&"object"!=typeof s.debug)throw n;try{a.details.push({type:s.type,value:Uh.dec(s.value),debug:s.debug})}catch(i){throw n}}return a}function Fm(e){const t=new ym("invalid end stream",mm.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(r){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const o=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,r]of Object.entries(n.metadata)){if(!Array.isArray(r)||r.some((e=>"string"!=typeof e)))throw t;for(const t of r)o.append(e,t)}}return{metadata:o,error:"error"in n?zm(n.error,o,t):void 0}}const Bm="Content-Type",Um="Content-Length",Vm="Content-Encoding",Hm="Accept-Encoding",$m="Connect-Protocol-Version";function Wm(e){const t=new Headers,n=new Headers;return e.forEach(((e,o)=>{o.toLowerCase().startsWith("trailer-")?n.set(o.substring(8),e):t.set(o,e)})),[t,n]}function Gm(e,t,n,o,r){const a=new Headers(null!=o?o:{});return void 0!==n&&a.set("Connect-Timeout-Ms",`${n}`),a.set(Bm,e==Uf.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),a.set($m,"1"),a}function qm(e,t,n){const o=function(e){const t=null==e?void 0:e.match(Lm);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const r=new ym(`HTTP ${t}`,function(e){switch(e){case 400:return mm.InvalidArgument;case 401:return mm.Unauthenticated;case 403:return mm.PermissionDenied;case 404:return mm.Unimplemented;case 408:return mm.DeadlineExceeded;case 409:return mm.Aborted;case 412:return mm.FailedPrecondition;case 413:case 431:return mm.ResourceExhausted;case 415:return mm.Internal;case 429:case 502:case 503:case 504:return mm.Unavailable;default:return mm.Unknown}}(t),n);if(e==Uf.Unary&&o&&!o.binary)return{isUnaryError:!0,unaryError:r};throw r}return{isUnaryError:!1}}const Ym="application/";function Xm(e,t,n){let o="?connect=v1";const r=e.header.get(Bm);0===(null==r?void 0:r.indexOf(Ym))&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const a=e.header.get(Vm);null!==a&&"identity"!==a&&(o+="&compression="+encodeURIComponent(a),n=!0),n&&(o+="&base64=1"),o+="&message="+function(e,t){return t?Uh.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const i=e.url+o,s=new Headers(e.header);return[$m,Bm,Um,Vm,Hm].forEach((e=>s.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:s})}function Km(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new ym("the operation timed out",mm.DeadlineExceeded))};let o;return void 0!==e&&(e<=0?n():o=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(o)}}(e.timeoutMs),o=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const r of n){if(r.aborted){o.apply(r);break}r.addEventListener("abort",o)}function o(){t.signal.aborted||t.abort(jm(this));for(const e of n)e.removeEventListener("abort",o)}return t}(e.signal,t);return[o.signal,function(e){const r=ym.from(t.aborted?jm(t):e);return o.abort(r),n(),Promise.reject(r)},function(){n(),o.abort()}]}var Jm,Zm,Qm,ep,tp,np;(Zm=Jm||(Jm={}))[Zm.UNSPECIFIED=0]="UNSPECIFIED",Zm[Zm.INACTIVE=1]="INACTIVE",Zm[Zm.PROCESSING=2]="PROCESSING",Zm[Zm.SUCCESS=3]="SUCCESS",Zm[Zm.WARNING=4]="WARNING",Zm[Zm.ERROR=5]="ERROR",zf.util.setEnumType(Jm,"exa.language_server_pb.CodeiumState",[{no:0,name:"CODEIUM_STATE_UNSPECIFIED"},{no:1,name:"CODEIUM_STATE_INACTIVE"},{no:2,name:"CODEIUM_STATE_PROCESSING"},{no:3,name:"CODEIUM_STATE_SUCCESS"},{no:4,name:"CODEIUM_STATE_WARNING"},{no:5,name:"CODEIUM_STATE_ERROR"}]),(ep=Qm||(Qm={}))[ep.UNSPECIFIED=0]="UNSPECIFIED",ep[ep.SINGLE=1]="SINGLE",ep[ep.MULTI=2]="MULTI",zf.util.setEnumType(Qm,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(np=tp||(tp={}))[np.UNSPECIFIED=0]="UNSPECIFIED",np[np.INLINE=1]="INLINE",np[np.BLOCK=2]="BLOCK",np[np.INLINE_MASK=3]="INLINE_MASK",zf.util.setEnumType(tp,"exa.language_server_pb.CompletionPartType",[{no:0,name:"COMPLETION_PART_TYPE_UNSPECIFIED"},{no:1,name:"COMPLETION_PART_TYPE_INLINE"},{no:2,name:"COMPLETION_PART_TYPE_BLOCK"},{no:3,name:"COMPLETION_PART_TYPE_INLINE_MASK"}]);const op=class e extends mh{constructor(e){super(),n(this,"threshold",0),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(op,"runtime",zf),n(op,"typeName","exa.language_server_pb.MultilineConfig"),n(op,"fields",zf.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let rp=op;const ap=class e extends mh{constructor(e){super(),n(this,"metadata"),n(this,"document"),n(this,"editorOptions"),n(this,"otherDocuments",[]),n(this,"experimentConfig"),n(this,"modelName",""),n(this,"multilineConfig"),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(ap,"runtime",zf),n(ap,"typeName","exa.language_server_pb.GetCompletionsRequest"),n(ap,"fields",zf.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:rm},{no:2,name:"document",kind:"message",T:bp},{no:3,name:"editor_options",kind:"message",T:im},{no:5,name:"other_documents",kind:"message",T:bp,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:kp},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:rp}])));let ip=ap;const sp=class e extends mh{constructor(e){super(),n(this,"state"),n(this,"completionItems",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(sp,"runtime",zf),n(sp,"typeName","exa.language_server_pb.GetCompletionsResponse"),n(sp,"fields",zf.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:Np},{no:2,name:"completion_items",kind:"message",T:Mp,repeated:!0}])));let lp=sp;const cp=class e extends mh{constructor(e){super(),n(this,"metadata"),n(this,"completionId",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(cp,"runtime",zf),n(cp,"typeName","exa.language_server_pb.AcceptCompletionRequest"),n(cp,"fields",zf.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:rm},{no:2,name:"completion_id",kind:"scalar",T:9}])));let dp=cp;const up=class e extends mh{constructor(e){super(),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(up,"runtime",zf),n(up,"typeName","exa.language_server_pb.AcceptCompletionResponse"),n(up,"fields",zf.util.newFieldList((()=>[])));let hp=up;const fp=class e extends mh{constructor(e){super(),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(fp,"runtime",zf),n(fp,"typeName","exa.language_server_pb.GetAuthTokenRequest"),n(fp,"fields",zf.util.newFieldList((()=>[])));let mp=fp;const pp=class e extends mh{constructor(e){super(),n(this,"authToken",""),n(this,"uuid",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(pp,"runtime",zf),n(pp,"typeName","exa.language_server_pb.GetAuthTokenResponse"),n(pp,"fields",zf.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let gp=pp;const vp=class e extends mh{constructor(e){super(),n(this,"row",Eh.zero),n(this,"col",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(vp,"runtime",zf),n(vp,"typeName","exa.language_server_pb.DocumentPosition"),n(vp,"fields",zf.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let yp=vp;const xp=class e extends mh{constructor(e){super(),n(this,"absolutePath",""),n(this,"relativePath",""),n(this,"text",""),n(this,"editorLanguage",""),n(this,"language",Qf.UNSPECIFIED),n(this,"cursorOffset",Eh.zero),n(this,"cursorPosition"),n(this,"lineEnding",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(xp,"runtime",zf),n(xp,"typeName","exa.language_server_pb.Document"),n(xp,"fields",zf.util.newFieldList((()=>[{no:1,name:"absolute_path",kind:"scalar",T:9},{no:2,name:"relative_path",kind:"scalar",T:9},{no:3,name:"text",kind:"scalar",T:9},{no:4,name:"editor_language",kind:"scalar",T:9},{no:5,name:"language",kind:"enum",T:zf.getEnumType(Qf)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:yp},{no:7,name:"line_ending",kind:"scalar",T:9}])));let bp=xp;const wp=class e extends mh{constructor(e){super(),n(this,"forceEnableExperiments",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(wp,"runtime",zf),n(wp,"typeName","exa.language_server_pb.ExperimentConfig"),n(wp,"fields",zf.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:zf.getEnumType(Wf),repeated:!0}])));let kp=wp;const Sp=class e extends mh{constructor(e){super(),n(this,"state",Jm.UNSPECIFIED),n(this,"message",""),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Sp,"runtime",zf),n(Sp,"typeName","exa.language_server_pb.State"),n(Sp,"fields",zf.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:zf.getEnumType(Jm)},{no:2,name:"message",kind:"scalar",T:9}])));let Np=Sp;const Cp=class e extends mh{constructor(e){super(),n(this,"startOffset",Eh.zero),n(this,"endOffset",Eh.zero),n(this,"startPosition"),n(this,"endPosition"),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Cp,"runtime",zf),n(Cp,"typeName","exa.language_server_pb.Range"),n(Cp,"fields",zf.util.newFieldList((()=>[{no:1,name:"start_offset",kind:"scalar",T:4},{no:2,name:"end_offset",kind:"scalar",T:4},{no:3,name:"start_position",kind:"message",T:yp},{no:4,name:"end_position",kind:"message",T:yp}])));let Ep=Cp;const jp=class e extends mh{constructor(e){super(),n(this,"text",""),n(this,"deltaCursorOffset",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(jp,"runtime",zf),n(jp,"typeName","exa.language_server_pb.Suffix"),n(jp,"fields",zf.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let _p=jp;const Ip=class e extends mh{constructor(e){super(),n(this,"text",""),n(this,"offset",Eh.zero),n(this,"type",tp.UNSPECIFIED),n(this,"prefix",""),n(this,"line",Eh.zero),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Ip,"runtime",zf),n(Ip,"typeName","exa.language_server_pb.CompletionPart"),n(Ip,"fields",zf.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"offset",kind:"scalar",T:4},{no:3,name:"type",kind:"enum",T:zf.getEnumType(tp)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let Ap=Ip;const Tp=class e extends mh{constructor(e){super(),n(this,"completion"),n(this,"suffix"),n(this,"range"),n(this,"source",Jf.UNSPECIFIED),n(this,"completionParts",[]),zf.util.initPartial(e,this)}static fromBinary(t,n){return(new e).fromBinary(t,n)}static fromJson(t,n){return(new e).fromJson(t,n)}static fromJsonString(t,n){return(new e).fromJsonString(t,n)}static equals(t,n){return zf.util.equals(e,t,n)}};n(Tp,"runtime",zf),n(Tp,"typeName","exa.language_server_pb.CompletionItem"),n(Tp,"fields",zf.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:nm},{no:5,name:"suffix",kind:"message",T:_p},{no:2,name:"range",kind:"message",T:Ep},{no:3,name:"source",kind:"enum",T:zf.getEnumType(Jf)},{no:8,name:"completion_parts",kind:"message",T:Ap,repeated:!0}])));let Mp=Tp;const Op={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:ip,O:lp,kind:Uf.Unary},acceptCompletion:{name:"AcceptCompletion",I:dp,O:hp,kind:Uf.Unary},getAuthToken:{name:"GetAuthToken",I:mp,O:gp,kind:Uf.Unary}}};var Dp=function(e){return this instanceof Dp?(this.v=e,this):new Dp(e)},Pp=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(e,t||[]),a=[];return o={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),o[Symbol.asyncIterator]=function(){return this},o;function i(e,t){r[e]&&(o[e]=function(t){return new Promise((function(n,o){a.push([e,t,n,o])>1||s(e,t)}))},t&&(o[e]=t(o[e])))}function s(e,t){try{(n=r[e](t)).value instanceof Dp?Promise.resolve(n.value.v).then(l,c):d(a[0][2],n)}catch(o){d(a[0][3],o)}var n}function l(e){s("next",e)}function c(e){s("throw",e)}function d(e,t){e(t),a.shift(),a.length&&s(a[0][0],a[0][1])}};const Rp=function(e){var t;!function(){try{new Headers}catch(e){throw new Error("connect-web requires the fetch API. Are you running on an old version of Node.js? Node.js is not supported in Connect for Web - please stay tuned for Connect for Node.")}}();const n=null!==(t=e.useBinaryFormat)&&void 0!==t&&t;return{async unary(t,o,r,a,i,s,l){var c;const{serialize:d,parse:u}=Dm(o,n,e.jsonOptions,e.binaryOptions);return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Mm(e.next,e.interceptors),[n,o,r]=Km(e);return t(Object.assign(Object.assign({},e.req),{message:Am(e.req.method.I,e.req.message),signal:n})).then((e=>(r(),e)),o)}({interceptors:e.interceptors,signal:r,timeoutMs:a,req:{stream:!1,service:t,method:o,url:Im(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Gm(o.kind,n,a,i),contextValues:null!=l?l:_m(),message:s},next:async r=>{var a;let i=null;!0===e.useHttpGet&&o.idempotency===Hf.NoSideEffects?r=Xm(r,d(r.message),n):i=d(r.message);const s=null!==(a=e.fetch)&&void 0!==a?a:globalThis.fetch,l=await s(r.url,Object.assign(Object.assign({},r.init),{headers:r.header,signal:r.signal,body:i})),{isUnaryError:c,unaryError:h}=qm(o.kind,l.status,l.headers);if(c)throw zm(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...Wm(l.headers)),h);const[f,m]=Wm(l.headers);return{stream:!1,service:t,method:o,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):o.O.fromJson(await l.json(),Om(e.jsonOptions)),trailer:m}}})},async stream(t,o,r,a,i,s,l){var c;const{serialize:d,parse:u}=Dm(o,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return Pp(this,arguments,(function*(){const o=function(e){let t,n=new Uint8Array(0);function o(e){const t=new Uint8Array(n.length+e.length);t.set(n),t.set(e,n.length),n=t}return new ReadableStream({start(){t=e.getReader()},async pull(e){let r;for(;;){if(void 0===r&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];r={flags:n[0],length:e}}if(void 0!==r&&n.byteLength>=r.length+5)break;const e=await t.read();if(e.done)break;o(e.value)}if(void 0===r)return 0==n.byteLength?void e.close():void e.error(new ym("premature end of stream",mm.DataLoss));const a=n.subarray(5,5+r.length);n=n.subarray(5+r.length),e.enqueue({flags:r.flags,data:a})}})}(e).getReader();let r=!1;for(;;){const e=yield Dp(o.read());if(e.done)break;const{flags:a,data:i}=e.value;if(2&~a)yield yield Dp(u(i));else{r=!0;const e=Fm(i);if(e.error){const t=e.error;throw n.forEach(((e,n)=>{t.metadata.append(n,e)})),t}e.metadata.forEach(((e,n)=>t.set(n,e)))}}if(!r)throw"missing EndStreamResponse"}))}async function f(e){if(o.kind!=Uf.ServerStreaming)throw"The fetch API does not support streaming request bodies";const t=await e[Symbol.asyncIterator]().next();if(1==t.done)throw"missing request message";return function(e,t){const n=new Uint8Array(t.length+5);n.set(t,5);const o=new DataView(n.buffer,n.byteOffset,n.byteLength);return o.setUint8(0,e),o.setUint32(1,t.length),n}(0,d(t.value))}return a=void 0===a?e.defaultTimeoutMs:a<=0?void 0:a,await function(e){const t=Mm(e.next,e.interceptors),[n,o,r]=Km(e),a=Object.assign(Object.assign({},e.req),{message:Tm(e.req.method.I,e.req.message),signal:n});let i=!1;return n.addEventListener("abort",(function(){var t,n;const o=e.req.message[Symbol.asyncIterator]();i||null===(t=o.throw)||void 0===t||t.call(o,this.reason).catch((()=>{})),null===(n=o.return)||void 0===n||n.call(o).catch((()=>{}))})),t(a).then((e=>Object.assign(Object.assign({},e),{message:{[Symbol.asyncIterator](){const t=e.message[Symbol.asyncIterator]();return{next:()=>t.next().then((e=>(1==e.done&&(i=!0,r()),e)),o)}}}})),o)}({interceptors:e.interceptors,timeoutMs:a,signal:r,req:{stream:!0,service:t,method:o,url:Im(e.baseUrl,t,o),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Gm(o.kind,n,a,i),contextValues:null!=l?l:_m(),message:s},next:async t=>{var n;const r=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,a=await r(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(qm(o.kind,a.status,a.headers),null===a.body)throw"missing response body";const i=new Headers;return Object.assign(Object.assign({},t),{header:a.headers,trailer:i,message:h(a.body,i,a.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Lp=(Fp=Rp,function(e,t){const n={};for(const[o,r]of Object.entries(e.methods)){const a=t(Object.assign(Object.assign({},r),{localName:o,service:e}));null!=a&&(n[o]=a)}return n}(zp=Op,(e=>{switch(e.kind){case Uf.Unary:return function(e,t,n){return async function(o,r){var a,i;const s=await e.unary(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);return null===(a=null==r?void 0:r.onHeader)||void 0===a||a.call(r,s.header),null===(i=null==r?void 0:r.onTrailer)||void 0===i||i.call(r,s.trailer),s.message}}(Fp,zp,e);case Uf.ServerStreaming:return function(e,t,n){return function(o,r){return Em(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,km([o]),null==r?void 0:r.contextValues),r)}}(Fp,zp,e);case Uf.ClientStreaming:return function(e,t,n){return async function(o,r){var a,i,s,l,c,d;const u=await e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues);let h;null===(c=null==r?void 0:r.onHeader)||void 0===c||c.call(r,u.header);try{for(var f,m=!0,p=Sm(u.message);!(a=(f=await p.next()).done);m=!0)l=f.value,m=!1,h=l}catch(g){i={error:g}}finally{try{m||a||!(s=p.return)||await s.call(p)}finally{if(i)throw i.error}}if(!h)throw new ym("protocol error: missing response message",mm.Internal);return null===(d=null==r?void 0:r.onTrailer)||void 0===d||d.call(r,u.trailer),h}}(Fp,zp,e);case Uf.BiDiStreaming:return function(e,t,n){return function(o,r){return Em(e.stream(t,n,null==r?void 0:r.signal,null==r?void 0:r.timeoutMs,null==r?void 0:r.headers,o,null==r?void 0:r.contextValues),r)}}(Fp,zp,e);default:return null}})));var zp,Fp;let Bp;try{Bp=crypto.randomUUID()}catch{Bp=function(){return"10000000-1000-4000-8000-100000000000".replace(/[018]/g,(e=>(+e^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+e/4).toString(16)))}()}async function Up(e,t){const n=e.state.facet(lm),{override:o}=e.state.facet(cm),r=await o(),a=e.state,i=a.selection.main.head,s=a.doc.toString();try{const o=await async function({text:e,cursorOffset:t,config:n,otherDocuments:o}){return await Lp.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Bp,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:o,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Bp}`}})}({text:s,cursorOffset:i,config:n,otherDocuments:r});if(!o||0===o.completionItems.length)return;if(void 0!==t&&i!==t||"active"===Sn(e.state)||!e.hasFocus)return;const l=o.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),o=2===e.type?`\n${e.text}`:e.text,r={absoluteStartPos:t+n,absoluteEndPos:t+n+o.length,from:n,to:n,insert:o};return t+=o.length,r}))})),c=0,d=l.at(c);if(!d)return;const u=Nn.of(d,a.doc.length),h=u.invert(a.doc);e.dispatch({changes:u,effects:th.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function Vp(){let e=null,t=0;return Yt.updateListener.of((n=>{const o=n.view.state.facet(lm);if(!o.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(nh)||e.is(oh)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(um))return!0;if("active"===Sn(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(hm))return!0}(n))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new En(n.view.state,r,!1))||(e=setTimeout((async()=>{r===t&&await Up(n.view,t)}),o.timeout),t=r)}))}function Hp(e){var t;const n=e.state.field(um);if(!n)return!1;const o=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:nh.of(null),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]});let r=0;return null==o||o.iterChangedRanges(((e,t,n,o)=>{r=o})),e.dispatch({changes:o,selection:qt.cursor(r),annotations:[hm.of(null),Cn.addToHistory.of(!0)]}),!0}const $p=e=>{const{state:t}=e,n=t.field(um);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,a=o.at(r);if(!a)return!1;const i=n.reverseChangeSet.apply(t.doc),s=Nn.of(n.reverseChangeSet,t.doc.length).compose(Nn.of(a,i.length)),l=Nn.of(a,i.length).invert(i);return e.dispatch({changes:s,effects:th.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]}),!0};function Wp(e){const t=e.state.field(um);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:oh.of(null),annotations:[fm.of(null),hm.of(null),Cn.addToHistory.of(!1)]}),!1)}function Gp(){return Yt.domEventHandlers({keydown:(e,t)=>("]"!==e.key||!e.ctrlKey)&&("Shift"!==e.key&&"Control"!==e.key&&"Alt"!==e.key&&"Meta"!==e.key&&function(e,t){return!!e.state.field(um)&&("Tab"===t?Hp(e):Wp(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?($p(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let o=!1;const r=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,a=e.state.field(um);return!(void 0===r||!a)&&(null==(n=a.decorations)||n.between(r,r,(()=>{o=!0})),o)}(t)?Hp(t):Wp(t)}})}const qp=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[lm.of(e),um,yn.highest(pn.of([{key:"Ctrl-]",run:$p}])),yn.highest(Yt.updateListener.of((e=>{e.focusChanged&&Wp(e.view)}))),yn.high(Gp()),Vp()]}({apiKey:e.codeium_api_key,language:Qf.PYTHON}),cm.of({override:async()=>[{text:zs(""),language:Qf.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(eh({delay:500,fetchFn:async e=>{if(!Bs())return"";if(0===e.doc.length)return"";await new Promise((e=>setTimeout(e,20)));const t=e.doc.toString(),n=function(e,t){const n=e.doc.toString(),o=t.split("\n").length-n.split("\n").length,r=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return r.line+=o,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:Vs,version:"replace_me",uri:`file://${Vs}`,relativePath:Vs,languageId:Hs,position:r}}}(e,zs(t)),o=function(e,t,n){if(0===e.completions.length)return"";const{displayText:o,position:r}=e.completions[0],a=r.character-t.character,i=a<0?o.slice(-a):o,s=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<i.length;l++){const e=i.slice(l);if(s.startsWith(e))return i.slice(0,l)}return i}(await Us().getCompletion(n),n.doc.position,e);return o&&J.debug("Copilot suggestion:",o),o}})),[...t,Fs().slice(0,-2)]};const Yp=Jt.mark({class:"underline"}),Xp=Xt.define(),Kp=Xt.define(),Jp=Kt.define({create:()=>Jt.none,update(e,t){let n=e.map(t.changes);for(const o of t.effects)o.is(Xp)?n=e.update({add:[Yp.range(o.value.from,o.value.to)]}):o.is(Kp)&&(n=Jt.none);return n},provide:e=>Yt.decorations.from(e)});class Zp{constructor(e,t){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=e=>{"Meta"!==e.key&&"Control"!==e.key||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=e=>{"Meta"!==e.key&&"Control"!==e.key||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=e=>{if(!e.metaKey&&!e.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const t=this.view.posAtCoords({x:e.clientX,y:e.clientY});if(null==t)return void this.clearUnderline();const n=jn(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:o}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===o)return;this.clearUnderline(),this.hoveredRange={from:e,to:o,position:t},this.view.dispatch({effects:Xp.of(this.hoveredRange)})}else this.clearUnderline()},this.click=e=>{if(this.hoveredRange){const t=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);e.preventDefault(),e.stopPropagation(),this.onClick(this.view,t),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=t,window.addEventListener("keydown",this.keydown),window.addEventListener("keyup",this.keyup),window.addEventListener("blur",this.windowBlur),window.addEventListener("mouseleave",this.windowBlur)}update(e){}destroy(){window.removeEventListener("keydown",this.keydown),window.removeEventListener("keyup",this.keyup),window.removeEventListener("blur",this.windowBlur),window.removeEventListener("mouseleave",this.windowBlur),this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click)}exitCommandClickMode(){this.commandClickMode=!1,this.view.dom.removeEventListener("mousemove",this.mousemove),this.view.dom.removeEventListener("click",this.click),this.clearUnderline()}clearUnderline(){this.hoveredRange&&(this.view.dispatch({effects:Kp.of(null)}),this.hoveredRange=null)}}const Qp=({variant:e,settings:t,styles:n})=>{const o=Yt.theme({"&":{backgroundColor:t.background,color:t.foreground},".cm-content":{caretColor:t.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:t.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:t.selection},".cm-activeLine":{backgroundColor:t.lineHighlight},".cm-gutters":{backgroundColor:t.gutterBackground,color:t.gutterForeground},".cm-activeLineGutter":{backgroundColor:t.lineHighlight}},{dark:"dark"===e}),r=In.define(n);return[o,An(r)]};Qp({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:Tn.comment,color:"#404080"},{tag:[Tn.string,Tn.regexp],color:"#999999"},{tag:Tn.number,color:"#7090B0"},{tag:[Tn.bool,Tn.null],color:"#8080A0"},{tag:[Tn.punctuation,Tn.derefOperator],color:"#805080"},{tag:Tn.keyword,color:"#60B0FF"},{tag:Tn.definitionKeyword,color:"#B0FFF0"},{tag:Tn.moduleKeyword,color:"#60B0FF"},{tag:Tn.operator,color:"#A0A0FF"},{tag:[Tn.variableName,Tn.self],color:"#008080"},{tag:Tn.operatorKeyword,color:"#A0A0FF"},{tag:Tn.controlKeyword,color:"#80A0FF"},{tag:Tn.className,color:"#70E080"},{tag:[Tn.function(Tn.propertyName),Tn.propertyName],color:"#50A0A0"},{tag:Tn.tagName,color:"#009090"},{tag:Tn.modifier,color:"#B0FFF0"},{tag:[Tn.squareBracket,Tn.attributeName],color:"#D0D0FF"}]}),Qp({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:Tn.comment,color:"#787b8099"},{tag:Tn.string,color:"#86b300"},{tag:Tn.regexp,color:"#4cbf99"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#ffaa33"},{tag:Tn.variableName,color:"#5c6166"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#fa8d3e"},{tag:[Tn.keyword,Tn.special(Tn.brace)],color:"#fa8d3e"},{tag:Tn.operator,color:"#ed9366"},{tag:Tn.separator,color:"#5c6166b3"},{tag:Tn.punctuation,color:"#5c6166"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#f2ae49"},{tag:[Tn.className,Tn.definition(Tn.typeName)],color:"#22a4e6"},{tag:[Tn.tagName,Tn.typeName,Tn.self,Tn.labelName],color:"#55b4d4"},{tag:Tn.angleBracket,color:"#55b4d480"},{tag:Tn.attributeName,color:"#f2ae49"}]}),Qp({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:Tn.comment,color:"#6E6E6E"},{tag:[Tn.string,Tn.regexp,Tn.special(Tn.brace)],color:"#5C81B3"},{tag:Tn.number,color:"#C1E1B8"},{tag:Tn.bool,color:"#53667D"},{tag:[Tn.definitionKeyword,Tn.modifier,Tn.function(Tn.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[Tn.keyword,Tn.moduleKeyword,Tn.operatorKeyword,Tn.operator],color:"#697A8E",fontWeight:"bold"},{tag:[Tn.variableName,Tn.attributeName],color:"#708E67"},{tag:[Tn.function(Tn.variableName),Tn.definition(Tn.propertyName),Tn.derefOperator],color:"#fff"},{tag:Tn.tagName,color:"#A3D295"}]}),Qp({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:Tn.comment,color:"#666666"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#54BE0D"},{tag:Tn.regexp,color:"#E9C062"},{tag:Tn.number,color:"#CF6A4C"},{tag:[Tn.keyword,Tn.operator],color:"#5EA6EA"},{tag:Tn.variableName,color:"#7587A6"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#F9EE98"},{tag:[Tn.propertyName,Tn.function(Tn.variableName)],color:"#937121"},{tag:[Tn.typeName,Tn.angleBracket,Tn.tagName],color:"#9B859D"}]}),Qp({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:Tn.comment,color:"#6B4E32"},{tag:[Tn.keyword,Tn.operator,Tn.derefOperator],color:"#EF5D32"},{tag:Tn.className,color:"#EFAC32",fontWeight:"bold"},{tag:[Tn.typeName,Tn.propertyName,Tn.function(Tn.variableName),Tn.definition(Tn.variableName)],color:"#EFAC32"},{tag:Tn.definition(Tn.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:Tn.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[Tn.number,Tn.bool],color:"#6C99BB"},{tag:[Tn.variableName,Tn.self],color:"#7DAF9C"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#D9D762"},{tag:[Tn.angleBracket,Tn.tagName,Tn.attributeName],color:"#EFCB43"}]}),Qp({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:Tn.comment,color:"#404040"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#00D8FF"},{tag:Tn.number,color:"#E62286"},{tag:[Tn.variableName,Tn.attributeName,Tn.self],color:"#E62286",fontWeight:"bold"},{tag:Tn.function(Tn.variableName),color:"#fff",fontWeight:"bold"}]}),Qp({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:Tn.comment,color:"#BCC8BA"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#5D90CD"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#46A609"},{tag:Tn.keyword,color:"#AF956F"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#C52727"},{tag:[Tn.angleBracket,Tn.tagName,Tn.attributeName],color:"#606060"},{tag:Tn.self,color:"#000"}]}),Qp({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:Tn.comment,color:"#0088FF"},{tag:Tn.string,color:"#3AD900"},{tag:Tn.regexp,color:"#80FFC2"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#FF628C"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#FFEE80"},{tag:Tn.variableName,color:"#CCCCCC"},{tag:Tn.self,color:"#FF80E1"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.definition(Tn.typeName),Tn.labelName],color:"#FFDD00"},{tag:[Tn.keyword,Tn.operator],color:"#FF9D00"},{tag:[Tn.propertyName,Tn.typeName],color:"#80FFBB"},{tag:Tn.special(Tn.brace),color:"#EDEF7D"},{tag:Tn.attributeName,color:"#9EFFFF"},{tag:Tn.derefOperator,color:"#fff"}]}),Qp({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:Tn.comment,color:"#AEAEAE"},{tag:[Tn.string,Tn.special(Tn.brace),Tn.regexp],color:"#8DFF8E"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.function(Tn.definition(Tn.variableName)),Tn.definition(Tn.typeName)],color:"#A3EBFF"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#62E9BD"},{tag:[Tn.keyword,Tn.operator],color:"#2BF1DC"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#F8FBB1"},{tag:[Tn.variableName,Tn.self],color:"#B683CA"},{tag:[Tn.angleBracket,Tn.tagName,Tn.typeName,Tn.propertyName],color:"#60A4F1"},{tag:Tn.derefOperator,color:"#E0E0E0"},{tag:Tn.attributeName,color:"#7BACCA"}]}),Qp({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:Tn.comment,color:"#6272a4"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#f1fa8c"},{tag:[Tn.number,Tn.self,Tn.bool,Tn.null],color:"#bd93f9"},{tag:[Tn.keyword,Tn.operator],color:"#ff79c6"},{tag:[Tn.definitionKeyword,Tn.typeName],color:"#8be9fd"},{tag:Tn.definition(Tn.typeName),color:"#f8f8f2"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.attributeName],color:"#50fa7b"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:Tn.comment,color:"#AAAAAA"},{tag:[Tn.keyword,Tn.operator,Tn.typeName,Tn.tagName,Tn.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[Tn.attributeName,Tn.definition(Tn.propertyName)],color:"#4F9FD0"},{tag:[Tn.className,Tn.string,Tn.special(Tn.brace)],color:"#CF4F5F"},{tag:Tn.number,color:"#CF4F5F",fontWeight:"bold"},{tag:Tn.variableName,fontWeight:"bold"}]}),Qp({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:Tn.comment,color:"#9995b7"},{tag:Tn.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#ff5792"},{tag:[Tn.className,Tn.tagName,Tn.definition(Tn.typeName)],color:"#0094f0"},{tag:[Tn.number,Tn.bool,Tn.null,Tn.special(Tn.brace)],color:"#5842ff"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#0095a8"},{tag:Tn.typeName,color:"#b3694d"},{tag:[Tn.propertyName,Tn.variableName],color:"#fa8900"},{tag:Tn.operator,color:"#ff5792"},{tag:Tn.self,color:"#e64100"},{tag:[Tn.string,Tn.regexp],color:"#00b368"},{tag:[Tn.paren,Tn.bracket],color:"#0431fa"},{tag:Tn.labelName,color:"#00bdd6"},{tag:Tn.attributeName,color:"#e64100"},{tag:Tn.angleBracket,color:"#9995b7"}]}),Qp({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:Tn.comment,color:"#9893a5"},{tag:[Tn.bool,Tn.null],color:"#286983"},{tag:Tn.number,color:"#d7827e"},{tag:Tn.className,color:"#d7827e"},{tag:[Tn.angleBracket,Tn.tagName,Tn.typeName],color:"#56949f"},{tag:Tn.attributeName,color:"#907aa9"},{tag:Tn.punctuation,color:"#797593"},{tag:[Tn.keyword,Tn.modifier],color:"#286983"},{tag:[Tn.string,Tn.regexp],color:"#ea9d34"},{tag:Tn.variableName,color:"#d7827e"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:Tn.comment,color:"#CFCFCF"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#E66C29"},{tag:[Tn.className,Tn.definition(Tn.propertyName),Tn.function(Tn.variableName),Tn.labelName,Tn.definition(Tn.typeName)],color:"#2EB43B"},{tag:Tn.keyword,color:"#D8B229"},{tag:Tn.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#925A47"},{tag:Tn.string,color:"#704D3D"},{tag:Tn.typeName,color:"#2F8996"},{tag:[Tn.variableName,Tn.propertyName],color:"#77ACB0"},{tag:Tn.self,color:"#77ACB0",fontWeight:"bold"},{tag:Tn.regexp,color:"#E3965E"},{tag:[Tn.tagName,Tn.angleBracket],color:"#BAA827"},{tag:Tn.attributeName,color:"#B06520"},{tag:Tn.derefOperator,color:"#000"}]}),Qp({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:Tn.comment,color:"#93A1A1"},{tag:Tn.string,color:"#2AA198"},{tag:Tn.regexp,color:"#D30102"},{tag:Tn.number,color:"#D33682"},{tag:Tn.variableName,color:"#268BD2"},{tag:[Tn.keyword,Tn.operator,Tn.punctuation],color:"#859900"},{tag:[Tn.definitionKeyword,Tn.modifier],color:"#073642",fontWeight:"bold"},{tag:[Tn.className,Tn.self,Tn.definition(Tn.propertyName)],color:"#268BD2"},{tag:Tn.function(Tn.variableName),color:"#268BD2"},{tag:[Tn.bool,Tn.null],color:"#B58900"},{tag:Tn.tagName,color:"#268BD2",fontWeight:"bold"},{tag:Tn.angleBracket,color:"#93A1A1"},{tag:Tn.attributeName,color:"#93A1A1"},{tag:Tn.typeName,color:"#859900"}]}),Qp({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:Tn.comment,color:"#8E908C"},{tag:[Tn.variableName,Tn.self,Tn.propertyName,Tn.attributeName,Tn.regexp],color:"#C82829"},{tag:[Tn.number,Tn.bool,Tn.null],color:"#F5871F"},{tag:[Tn.className,Tn.typeName,Tn.definition(Tn.typeName)],color:"#C99E00"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#718C00"},{tag:Tn.operator,color:"#3E999F"},{tag:[Tn.definition(Tn.propertyName),Tn.function(Tn.variableName)],color:"#4271AE"},{tag:Tn.keyword,color:"#8959A8"},{tag:Tn.derefOperator,color:"#4D4D4C"}]});const eg=Qp({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:Tn.comment,color:"#708090"},{tag:Tn.variableName,color:"#000000"},{tag:[Tn.string,Tn.special(Tn.brace)],color:"#a11"},{tag:Tn.number,color:"#164"},{tag:Tn.bool,color:"#219"},{tag:Tn.null,color:"#219"},{tag:Tn.keyword,color:"#708",fontWeight:500},{tag:Tn.className,color:"#00f"},{tag:Tn.definition(Tn.typeName),color:"#00f"},{tag:Tn.typeName,color:"#085"},{tag:Tn.angleBracket,color:"#000000"},{tag:Tn.tagName,color:"#170"},{tag:Tn.attributeName,color:"#00c"},{tag:Tn.operator,color:"#a2f",fontWeight:500},{tag:[Tn.function(Tn.variableName)],color:"#00c"},{tag:[Tn.propertyName],color:"#05a"}]});const tg=e=>{const{theme:t,hotkeys:n,completionConfig:o}=e;return[Yt.lineWrapping,Rn(),Ln(),zn(),Fn(),Bn(),Un(),Vn(),Hn({position:"fixed",parent:document.querySelector("#App")??void 0}),$n(),"dark"===t?Wn:eg,Gn(),qp(o),qn(),Yn(),yn.high(pn.of(Xn)),Kn(),Jn(),Zn.of(" "),An(Qn,{fallback:!0}),pn.of(eo),to(e),no.of(oo()),ro.allowMultipleSelections.of(!0),$u(n),pn.of([{key:"Tab",run:e=>ao(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const o=e.state.doc.lineAt(n);return""!==o.text.slice(0,n-o.from).trim()&&co(e)})(e)||io(e),preventDefault:!0}]),pn.of([...so,lo])]};function ng(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}const og="ContextMenu",[rg,ag]=uo(og,[ho]),ig=ho(),[sg,lg]=rg(og),cg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:o=!1,...a}=e,i=lg("ContextMenuTrigger",n),s=ig(n),l=r.useRef({x:0,y:0}),c=r.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...l.current})}),d=r.useRef(0),u=r.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{l.current={x:e.clientX,y:e.clientY},i.onOpenChange(!0)};return r.useEffect((()=>u),[u]),r.useEffect((()=>{o&&u()}),[o,u]),r.createElement(r.Fragment,null,r.createElement(Co,mo({},s,{virtualRef:c})),r.createElement(Eo.span,mo({"data-state":i.open?"open":"closed","data-disabled":o?"":void 0},a,{ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:o?e.onContextMenu:jo(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:o?e.onPointerDown:jo(e.onPointerDown,dg((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:o?e.onPointerMove:jo(e.onPointerMove,dg(u)),onPointerCancel:o?e.onPointerCancel:jo(e.onPointerCancel,dg(u)),onPointerUp:o?e.onPointerUp:jo(e.onPointerUp,dg(u))})))}));function dg(e){return t=>"mouse"!==t.pointerType?e(t):void 0}const ug=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=lg("ContextMenuContent",n),i=ig(n),s=r.useRef(!1);return r.createElement(po,mo({},i,o,{ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null===(n=e.onCloseAutoFocus)||void 0===n||n.call(e,t),!t.defaultPrevented&&s.current&&t.preventDefault(),s.current=!1},onInteractOutside:t=>{var n;null===(n=e.onInteractOutside)||void 0===n||n.call(e,t),t.defaultPrevented||a.modal||(s.current=!0)},style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),hg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(go,mo({},a,o,{ref:t}))})),fg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(vo,mo({},a,o,{ref:t}))})),mg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(yo,mo({},a,o,{ref:t}))})),pg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(xo,mo({},a,o,{ref:t}))})),gg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(_o,mo({},a,o,{ref:t}))})),vg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(bo,mo({},a,o,{ref:t}))})),yg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(wo,mo({},a,o,{ref:t}))})),xg=r.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...o}=e,a=ig(n);return r.createElement(ko,mo({},a,o,{ref:t,style:{...e.style,"--radix-context-menu-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-context-menu-content-available-width":"var(--radix-popper-available-width)","--radix-context-menu-content-available-height":"var(--radix-popper-available-height)","--radix-context-menu-trigger-width":"var(--radix-popper-anchor-width)","--radix-context-menu-trigger-height":"var(--radix-popper-anchor-height)"}}))})),bg=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:o,dir:a,modal:i=!0}=e,[s,l]=r.useState(!1),c=ig(t),d=So(o),u=r.useCallback((e=>{l(e),d(e)}),[d]);return r.createElement(sg,{scope:t,open:s,onOpenChange:u,modal:i},r.createElement(No,mo({},c,{dir:a,open:s,onOpenChange:u,modal:i}),n))},wg=cg,kg=Io((e=>{const{__scopeContextMenu:t,...n}=e,o=ig(t);return r.createElement(fo,mo({},o,n))}));r.forwardRef(((e,t)=>{const n=b(14);let o,r,a,i,s,l,c;return n[0]!==e?(({className:o,inset:r,children:i,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o||n[6]!==r?(s=Ao({className:o,inset:r}),n[5]=o,n[6]=r,n[7]=s):s=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Lo,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==t||n[10]!==s||n[11]!==a||n[12]!==i?(c=k.jsxs(yg,{ref:t,className:s,...a,children:[i,l]}),n[9]=t,n[10]=s,n[11]=a,n[12]=i,n[13]=c):c=n[13],c})).displayName=yg.displayName;const Sg="data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2";r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(To({subcontent:!0}),Sg,o),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(xg,{ref:t,className:a,...r}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i})).displayName=xg.displayName;const Ng=r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(To(),Sg,o),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(kg,{children:k.jsx(Mo,{children:k.jsx(ug,{ref:t,className:a,...r})})}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i}));Ng.displayName=ug.displayName;const Cg=r.forwardRef(((e,t)=>{const n=b(13);let o,r,a,i,s,l;return n[0]!==e?(({className:o,inset:r,variant:a,...i}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o||n[6]!==r||n[7]!==a?(s=Oo({className:o,inset:r,variant:a}),n[5]=o,n[6]=r,n[7]=a,n[8]=s):s=n[8],n[9]!==t||n[10]!==s||n[11]!==i?(l=k.jsx(fg,{ref:t,className:s,...i}),n[9]=t,n[10]=s,n[11]=i,n[12]=l):l=n[12],l}));Cg.displayName=fg.displayName;r.forwardRef(((e,t)=>{const n=b(15);let o,r,a,i,s,l,c,d;return n[0]!==e?(({className:o,children:i,checked:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a,n[4]=i):(o=n[1],r=n[2],a=n[3],i=n[4]),n[5]!==o?(s=Do({className:o}),n[5]=o,n[6]=s):s=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=Do(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("span",{className:l,children:k.jsx(gg,{children:k.jsx(zo,{className:"h-4 w-4"})})}),n[8]=c):c=n[8],n[9]!==t||n[10]!==s||n[11]!==r||n[12]!==a||n[13]!==i?(d=k.jsxs(mg,{ref:t,className:s,checked:r,...a,children:[c,i]}),n[9]=t,n[10]=s,n[11]=r,n[12]=a,n[13]=i,n[14]=d):d=n[14],d})).displayName=mg.displayName;r.forwardRef(((e,t)=>{const n=b(13);let o,r,a,i,s,l,c;return n[0]!==e?(({className:o,children:a,...r}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o?(i=Do({className:o}),n[4]=o,n[5]=i):i=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(s=Do(),n[6]=s):s=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx("span",{className:s,children:k.jsx(gg,{children:k.jsx(Fo,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==t||n[9]!==i||n[10]!==r||n[11]!==a?(c=k.jsxs(pg,{ref:t,className:i,...r,children:[l,a]}),n[8]=t,n[9]=i,n[10]=r,n[11]=a,n[12]=c):c=n[12],c})).displayName=pg.displayName;r.forwardRef(((e,t)=>{const n=b(11);let o,r,a,i,s;return n[0]!==e?(({className:o,inset:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o||n[5]!==r?(i=Po({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=i):i=n[6],n[7]!==t||n[8]!==i||n[9]!==a?(s=k.jsx(hg,{ref:t,className:i,...a}),n[7]=t,n[8]=i,n[9]=a,n[10]=s):s=n[10],s})).displayName=hg.displayName;const Eg=r.forwardRef(((e,t)=>{const n=b(9);let o,r,a,i;return n[0]!==e?(({className:o,...r}=e),n[0]=e,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(a=rn(Ro({className:o})),n[3]=o,n[4]=a):a=n[4],n[5]!==t||n[6]!==a||n[7]!==r?(i=k.jsx(vg,{ref:t,className:a,...r}),n[5]=t,n[6]=a,n[7]=r,n[8]=i):i=n[8],i}));Eg.displayName=vg.displayName;const jg=e=>{const t=b(14),{appClosed:n,onClick:o,tooltipContent:r}=e;let a;t[0]!==o?(a=()=>null==o?void 0:o({code:""}),t[0]=o,t[1]=a):a=t[1];const i=n&&" inactive-button";let s,l,c,d,u;return t[2]!==i?(s=rn("shoulder-button hover-action",i),t[2]=i,t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Bo,{strokeWidth:1.8}),t[4]=l):l=t[4],t[5]!==a||t[6]!==s?(c=k.jsx(Es,{onClick:a,className:s,onMouseDown:tt.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:l}),t[5]=a,t[6]=s,t[7]=c):c=t[7],t[8]!==r||t[9]!==c?(d=k.jsx(N,{content:r,usePortal:!1,children:c}),t[8]=r,t[9]=c,t[10]=d):d=t[10],t[11]!==o||t[12]!==d?(u=k.jsx(_g,{onClick:o,children:d}),t[11]=o,t[12]=d,t[13]=u):u=t[13],u},_g=e=>{const t=b(24),{children:n,onClick:o}=e;if(!o)return n;let r,a,i,s,l,c,d,u,h,f,m,p;return t[0]!==n?(r=k.jsx(wg,{children:n}),t[0]=n,t[1]=r):r=t[1],t[2]!==o?(a=e=>{e.stopPropagation(),o({code:""})},t[2]=o,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(As,{})}),t[4]=i):i=t[4],t[5]!==a?(s=k.jsxs(Cg,{onSelect:a,children:[i,"Python cell"]},"python"),t[5]=a,t[6]=s):s=t[6],t[7]!==o?(l=e=>{e.stopPropagation(),o({code:(new Uo).defaultCode})},t[7]=o,t[8]=l):l=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(Is,{})}),t[9]=c):c=t[9],t[10]!==l?(d=k.jsxs(Cg,{onSelect:l,children:[c,"Markdown cell"]},"markdown"),t[10]=l,t[11]=d):d=t[11],t[12]!==o?(u=e=>{e.stopPropagation(),o({code:(new Vo).defaultCode})},t[12]=o,t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx("div",{className:"mr-3 text-muted-foreground",children:k.jsx(ke,{size:13,strokeWidth:1.5})}),t[14]=h):h=t[14],t[15]!==u?(f=k.jsxs(Cg,{onSelect:u,children:[h,"SQL cell"]},"sql"),t[15]=u,t[16]=f):f=t[16],t[17]!==s||t[18]!==d||t[19]!==f?(m=k.jsxs(Ng,{children:[s,d,f]}),t[17]=s,t[18]=d,t[19]=f,t[20]=m):m=t[20],t[21]!==r||t[22]!==m?(p=k.jsxs(bg,{children:[r,m]}),t[21]=r,t[22]=m,t[23]=p):p=t[23],p},Ig=Ho("rounded-full shadow-xsSolid border p-[5px] transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 [&>svg]:size-3 active:shadow-none bg-background",{variants:{variant:{default:"hover:bg-accent hover:text-accent-foreground",stale:"bg-[var(--yellow-3)] hover:bg-[var(--yellow-4)] text-[var(--yellow-11)]",green:"hover:bg-[var(--grass-2)] hover:text-[var(--grass-11)] hover:border-[var(--grass-7)],",disabled:"opacity-50 cursor-not-allowed",danger:"hover:bg-[var(--red-3)] hover:text-[var(--red-11)]"}},defaultVariants:{variant:"default"}}),Ag=e=>{const t=b(21);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,disabled:n,variant:r,...o}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=void 0!==n&&n;let l,c,d;t[6]!==s||t[7]!==o.onClick?(l=e=>{var t;s||null==(t=o.onClick)||t.call(o,e)},t[6]=s,t[7]=o.onClick,t[8]=l):l=t[8],t[9]!==r||t[10]!==o.className?(c=rn(Ig({variant:r}),o.className),t[9]=r,t[10]=o.className,t[11]=c):c=t[11],t[12]!==s||t[13]!==o||t[14]!==l||t[15]!==c||t[16]!==a?(d=k.jsx("button",{disabled:s,...o,onClick:l,onMouseDown:tt.preventFocus,className:c,children:a}),t[12]=s,t[13]=o,t[14]=l,t[15]=c,t[16]=a,t[17]=d):d=t[17];const u=d;if(i){let e;return t[18]!==i||t[19]!==u?(e=k.jsx(N,{content:i,side:"top",delayDuration:200,usePortal:!1,children:u}),t[18]=i,t[19]=u,t[20]=e):e=t[20],e}return u},Tg=({children:e,className:t})=>k.jsx(rd,{className:rn("flex items-center gap-1 bg-background m-[2px] rounded-full",t),children:e});const Mg=e=>{const t=b(22),{onClick:n,appClosed:o,needsRun:r,status:a,config:i,edited:s}=e,l="disabled-transitively"===a,c="running"===a||"queued"===a,d=o||c||!i.disabled&&l&&!s;let u;t[0]!==o||t[1]!==r||t[2]!==c||t[3]!==d?(u=function(e,t,n,o){return e?"disabled":t&&!n?"stale":n||o?"disabled":"green"}(o,r,c,d),t[0]=o,t[1]=r,t[2]=c,t[3]=d,t[4]=u):u=t[4];const h=u;if(i.disabled){let e,o;return t[5]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(hc,{}),t[5]=e):e=t[5],t[6]!==d||t[7]!==n||t[8]!==h?(o=k.jsx(Ag,{tooltip:"Add code to notebook",disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:e}),t[6]=d,t[7]=n,t[8]=h,t[9]=o):o=t[9],o}if(!i.disabled&&l&&!s){let e,o;return t[10]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Ac,{strokeWidth:1.2}),t[10]=e):e=t[10],t[11]!==d||t[12]!==n||t[13]!==h?(o=k.jsx(Ag,{disabled:d,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:h,"data-testid":"run-button",children:e}),t[11]=d,t[12]=n,t[13]=h,t[14]=o):o=t[14],o}let f,m,p;if(o)f="App disconnected";else if("queued"===a)f="This cell is already queued to run";else if("running"===a)f="This cell is already running.";else{let e;t[15]===Symbol.for("react.memo_cache_sentinel")?(e=S("cell.run"),t[15]=e):e=t[15],f=e}return t[16]===Symbol.for("react.memo_cache_sentinel")?(m=k.jsx(Ac,{strokeWidth:1.2}),t[16]=m):m=t[16],t[17]!==f||t[18]!==d||t[19]!==n||t[20]!==h?(p=k.jsx(Ag,{tooltip:f,disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:m}),t[17]=f,t[18]=d,t[19]=n,t[20]=h,t[21]=p):p=t[21],p},Og=e=>{const t=b(10),{status:n,appClosed:o,onClick:r}=e;let a;a=o?"App disconnected":"running"===n?"A cell can't be deleted when it's running":"queued"===n?"A cell can't be deleted when it's queued to run":"Delete";const i=a,s=(o||("running"===n||"queued"===n))&&"inactive-button";let l,c,d,u,h;return t[0]!==s?(l=rn("hover:bg-transparent text-destructive/60 hover:text-destructive",s),t[0]=s,t[1]=l):l=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(c={boxShadow:"none"},d=k.jsx(je,{size:14}),t[2]=c,t[3]=d):(c=t[2],d=t[3]),t[4]!==r||t[5]!==l?(u=k.jsx(C,{variant:"ghost",size:"icon",onClick:r,"data-testid":"delete-button",onMouseDown:tt.preventFocus,className:l,style:c,children:d}),t[4]=r,t[5]=l,t[6]=u):u=t[6],t[7]!==a||t[8]!==u?(h=k.jsx(N,{content:i,usePortal:!1,children:u}),t[7]=a,t[8]=u,t[9]=h):h=t[9],h};const Dg=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),Pg=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),Rg=e=>{const t=b(79),{editing:n,status:o,disabled:r,staleInputs:a,edited:i,interrupted:s,elapsedTime:l,runStartTimestamp:c,lastRunStartTimestamp:d,uninstantiated:u}=e;if(!n)return null;const h=c??d;let f;t[0]!==h?(f=h?k.jsx(zg,{lastRanTime:h}):null,t[0]=h,t[1]=f):f=t[1];const m=f;if(r&&"running"===o)return J.error("CellStatusComponent: disabled and running"),null;if(r&&a){let e,n,o,r;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),t[2]=e):e=t[2],t[3]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[3]=m,t[4]=n):n=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:k.jsxs(bd,{children:[k.jsx($l,{className:"h-5 w-5",strokeWidth:1.5}),k.jsx(Wo,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[5]=o):o=t[5],t[6]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[6]=n,t[7]=r):r=t[7],r}if(r){let e,n,o,r;return t[8]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is disabled"}),t[8]=e):e=t[8],t[9]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[9]=m,t[10]=n):n=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:k.jsx($l,{className:"h-5 w-5",strokeWidth:1.5})}),t[11]=o):o=t[11],t[12]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[12]=n,t[13]=r):r=t[13],r}if(!a&&"disabled-transitively"===o){let e,n,o,r;return t[14]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),t[14]=e):e=t[14],t[15]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[15]=m,t[16]=n):n=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:k.jsxs(bd,{layerTop:!0,children:[k.jsx(Qc,{className:"h-5 w-5",strokeWidth:1.5}),k.jsx($l,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[17]=o):o=t[17],t[18]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[18]=n,t[19]=r):r=t[19],r}if(a&&"disabled-transitively"===o){let e,n,o,r;return t[20]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),t[20]=e):e=t[20],t[21]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[21]=m,t[22]=n):n=t[22],t[23]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:k.jsxs(bd,{children:[k.jsx(Wo,{className:"h-5 w-5",strokeWidth:1}),k.jsx($l,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[23]=o):o=t[23],t[24]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[24]=n,t[25]=r):r=t[25],r}if("running"===o){let e,n,o,r,a;return t[26]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is running"}),t[26]=e):e=t[26],t[27]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[27]=m,t[28]=n):n=t[28],t[29]!==c?(o=$o.fromSeconds(c)||$o.now(),t[29]=c,t[30]=o):o=t[30],t[31]!==o?(r=k.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:k.jsx(Bg,{startTime:o})}),t[31]=o,t[32]=r):r=t[32],t[33]!==n||t[34]!==r?(a=k.jsx(N,{content:n,usePortal:!1,children:r}),t[33]=n,t[34]=r,t[35]=a):a=t[35],a}if("queued"===o){let e,n,o,r;return t[36]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{children:"This cell is queued to run"}),t[36]=e):e=t[36],t[37]!==m?(n=k.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[37]=m,t[38]=n):n=t[38],t[39]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:k.jsx(hl,{className:"h-5 w-5",strokeWidth:1.5})}),t[39]=o):o=t[39],t[40]!==n?(r=k.jsx(N,{content:n,usePortal:!1,children:o}),t[40]=n,t[41]=r):r=t[41],r}if(i||s||a||u){let e;t[42]!==l?(e=Fg(l),t[42]=l,t[43]=e):e=t[43];const n=e;let o;t[44]!==l||t[45]!==n?(o=l?k.jsx(Lg,{elapsedTime:n}):null,t[44]=l,t[45]=n,t[46]=o):o=t[46];const r=o;let a,c,d,h,f,p="";if(u)a="This cell has not yet been run";else if(s){let e;a="This cell was interrupted when it was last run",t[47]!==r?(e=k.jsxs("span",{children:["This cell ran for ",r," before being interrupted"]}),t[47]=r,t[48]=e):e=t[48],p=e}else if(i){let e;a="This cell has been modified since it was last run",t[49]!==r?(e=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[49]=r,t[50]=e):e=t[50],p=e}else{let e;a="This cell has not been run with the latest inputs",t[51]!==r?(e=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[51]=r,t[52]=e):e=t[52],p=e}return t[53]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:k.jsx(Wo,{className:"h-5 w-5",strokeWidth:1.5})}),t[53]=c):c=t[53],t[54]!==a?(d=k.jsx(N,{content:a,usePortal:!1,children:c}),t[54]=a,t[55]=d):d=t[55],t[56]!==l||t[57]!==p||t[58]!==m||t[59]!==n?(h=l&&k.jsx(N,{content:k.jsxs("div",{className:"flex flex-col gap-1",children:[p,m]}),usePortal:!1,children:k.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:k.jsx("span",{children:n})})}),t[56]=l,t[57]=p,t[58]=m,t[59]=n,t[60]=h):h=t[60],t[61]!==d||t[62]!==h?(f=k.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[d,h]}),t[61]=d,t[62]=h,t[63]=f):f=t[63],f}if(null!==l){let e;t[64]!==l?(e=Fg(l),t[64]=l,t[65]=e):e=t[65];const n=e;let o;t[66]!==l||t[67]!==n?(o=l?k.jsx(Lg,{elapsedTime:n}):null,t[66]=l,t[67]=n,t[68]=o):o=t[68];const r=o;let a,i,s,c;return t[69]!==r?(a=k.jsxs("span",{children:["This cell took ",r," to run"]}),t[69]=r,t[70]=a):a=t[70],t[71]!==a||t[72]!==m?(i=k.jsxs("div",{className:"flex flex-col gap-1",children:[a,m]}),t[71]=a,t[72]=m,t[73]=i):i=t[73],t[74]!==n?(s=k.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:k.jsx("span",{children:n})}),t[74]=n,t[75]=s):s=t[75],t[76]!==i||t[77]!==s?(c=k.jsx(N,{content:i,usePortal:!1,children:s}),t[76]=i,t[77]=s,t[78]=c):c=t[78],c}return null},Lg=e=>{const t=b(2);let n;return t[0]!==e.elapsedTime?(n=k.jsx("span",{className:"tracking-wide font-semibold",children:e.elapsedTime}),t[0]=e.elapsedTime,t[1]=n):n=t[1],n},zg=e=>{const t=b(18),n=1e3*e.lastRanTime;let o,r,a,i,s,l,c,d,u;if(t[0]!==n){const e=new Date(n),d=new Date,u=e.toDateString()===d.toDateString()?Dg:Pg;i="Ran at",s=" ",l=k.jsx("strong",{className:"tracking-wide font-semibold",children:u.format(e)}),c=" ",o="text-muted-foreground",r="(",a=cd(e),t[0]=n,t[1]=o,t[2]=r,t[3]=a,t[4]=i,t[5]=s,t[6]=l,t[7]=c}else o=t[1],r=t[2],a=t[3],i=t[4],s=t[5],l=t[6],c=t[7];return t[8]!==o||t[9]!==r||t[10]!==a?(d=k.jsxs("span",{className:o,children:[r,a," ago)"]}),t[8]=o,t[9]=r,t[10]=a,t[11]=d):d=t[11],t[12]!==i||t[13]!==s||t[14]!==l||t[15]!==c||t[16]!==d?(u=k.jsxs("span",{children:[i,s,l,c,d]}),t[12]=i,t[13]=s,t[14]=l,t[15]=c,t[16]=d,t[17]=u):u=t[17],u};function Fg(e){if(null===e)return"";if(e>6e4){const t=(e/6e4).toFixed(0),n=(e%6e4/1e3).toFixed(0);return`${t.toString()}m${n.toString()}s`}return e>1e3?`${(e/1e3).toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`}const Bg=e=>{const t=b(6);let n;t[0]!==e.startTime?(n=e.startTime.toMilliseconds(),t[0]=e.startTime,t[1]=n):n=t[1];const o=function(e){const t=r.useRef(e),[n,o]=r.useState(e);return r.useEffect((()=>{const e=setInterval((()=>{o($o.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(n);let a,i;return t[2]!==o?(a=Fg(o),t[2]=o,t[3]=a):a=t[3],t[4]!==a?(i=k.jsx("span",{children:a}),t[4]=a,t[5]=i):i=t[5],i};function Ug(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const Vg={display:"none"};function Hg(e){let{id:t,value:n}=e;return u.createElement("div",{id:t,style:Vg},n)}function $g(e){let{id:t,announcement:n,ariaLiveType:o="assertive"}=e;return u.createElement("div",{id:t,style:{position:"fixed",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"},role:"status","aria-live":o,"aria-atomic":!0},n)}const Wg=r.createContext(null);const Gg={draggable:"\n To pick up a draggable item, press the space bar.\n While dragging, use the arrow keys to move the item.\n Press space again to drop the item in its new position, or press escape to cancel.\n "},qg={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was moved over droppable area "+n.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:n}=e;return n?"Draggable item "+t.id+" was dropped over droppable area "+n.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Yg(e){let{announcements:t=qg,container:n,hiddenTextDescribedById:o,screenReaderInstructions:a=Gg}=e;const{announce:i,announcement:s}=function(){const[e,t]=r.useState("");return{announce:r.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),l=Zo("DndLiveRegion"),[c,d]=r.useState(!1);if(r.useEffect((()=>{d(!0)}),[]),function(e){const t=r.useContext(Wg);r.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(r.useMemo((()=>({onDragStart(e){let{active:n}=e;i(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:o}=e;t.onDragMove&&i(t.onDragMove({active:n,over:o}))},onDragOver(e){let{active:n,over:o}=e;i(t.onDragOver({active:n,over:o}))},onDragEnd(e){let{active:n,over:o}=e;i(t.onDragEnd({active:n,over:o}))},onDragCancel(e){let{active:n,over:o}=e;i(t.onDragCancel({active:n,over:o}))}})),[i,t])),!c)return null;const h=u.createElement(u.Fragment,null,u.createElement(Hg,{id:o,value:a.draggable}),u.createElement($g,{id:l,announcement:s}));return n?er.createPortal(h,n):h}var Xg,Kg;function Jg(){}function Zg(e,t){return r.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(Kg=Xg||(Xg={})).DragStart="dragStart",Kg.DragMove="dragMove",Kg.DragEnd="dragEnd",Kg.DragCancel="dragCancel",Kg.DragOver="dragOver",Kg.RegisterDroppable="registerDroppable",Kg.SetDroppableDisabled="setDroppableDisabled",Kg.UnregisterDroppable="unregisterDroppable";const Qg=Object.freeze({x:0,y:0});function ev(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function tv(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return n-o}function nv(e,t){let{data:{value:n}}=e,{data:{value:o}}=t;return o-n}function ov(e){let{left:t,top:n,height:o,width:r}=e;return[{x:t,y:n},{x:t+r,y:n},{x:t,y:n+o},{x:t+r,y:n+o}]}function rv(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function av(e,t,n){return void 0===t&&(t=e.left),void 0===n&&(n=e.top),{x:t+.5*e.width,y:n+.5*e.height}}const iv=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=av(t,t.left,t.top),a=[];for(const i of o){const{id:e}=i,t=n.get(e);if(t){const n=ev(av(t),r);a.push({id:e,data:{droppableContainer:i,value:n}})}}return a.sort(tv)};function sv(e,t){const n=Math.max(t.top,e.top),o=Math.max(t.left,e.left),r=Math.min(t.left+t.width,e.left+e.width),a=Math.min(t.top+t.height,e.top+e.height),i=r-o,s=a-n;if(o<r&&n<a){const n=t.width*t.height,o=e.width*e.height,r=i*s;return Number((r/(n+o-r)).toFixed(4))}return 0}const lv=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=[];for(const a of o){const{id:e}=a,o=n.get(e);if(o){const n=sv(o,t);n>0&&r.push({id:e,data:{droppableContainer:a,value:n}})}}return r.sort(nv)};function cv(e,t){const{top:n,left:o,bottom:r,right:a}=t;return n<=e.y&&e.y<=r&&o<=e.x&&e.x<=a}function dv(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Qg}function uv(e){return function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce(((t,n)=>({...t,top:t.top+e*n.y,bottom:t.bottom+e*n.y,left:t.left+e*n.x,right:t.right+e*n.x})),{...t})}}const hv=uv(1);const fv={ignoreTransform:!1};function mv(e,t){void 0===t&&(t=fv);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:o}=Go(e).getComputedStyle(e);t&&(n=function(e,t,n){const o=function(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}(t);if(!o)return e;const{scaleX:r,scaleY:a,x:i,y:s}=o,l=e.left-i-(1-r)*parseFloat(n),c=e.top-s-(1-a)*parseFloat(n.slice(n.indexOf(" ")+1)),d=r?e.width/r:e.width,u=a?e.height/a:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,o))}const{top:o,left:r,width:a,height:i,bottom:s,right:l}=n;return{top:o,left:r,width:a,height:i,bottom:s,right:l}}function pv(e){return mv(e,{ignoreTransform:!0})}function gv(e,t){const n=[];return e?function o(r){if(null!=t&&n.length>=t)return n;if(!r)return n;if(cr(r)&&null!=r.scrollingElement&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!ir(r)||dr(r))return n;if(n.includes(r))return n;const a=Go(e).getComputedStyle(r);return r!==e&&function(e,t){void 0===t&&(t=Go(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const o=t[e];return"string"==typeof o&&n.test(o)}))}(r,a)&&n.push(r),function(e,t){return void 0===t&&(t=Go(e).getComputedStyle(e)),"fixed"===t.position}(r,a)?n:o(r.parentNode)}(e):n}function vv(e){const[t]=gv(e,1);return null!=t?t:null}function yv(e){return ar&&e?ur(e)?e:hr(e)?cr(e)||e===qo(e).scrollingElement?window:ir(e)?e:null:null:null}function xv(e){return ur(e)?e.scrollX:e.scrollLeft}function bv(e){return ur(e)?e.scrollY:e.scrollTop}function wv(e){return{x:xv(e),y:bv(e)}}var kv,Sv;function Nv(e){return!(!ar||!e)&&e===document.scrollingElement}function Cv(e){const t={x:0,y:0},n=Nv(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=o.y,isRight:e.scrollLeft>=o.x,maxScroll:o,minScroll:t}}(Sv=kv||(kv={}))[Sv.Forward=1]="Forward",Sv[Sv.Backward=-1]="Backward";const Ev={x:.2,y:.2};function jv(e,t,n,o,r){let{top:a,left:i,right:s,bottom:l}=n;void 0===o&&(o=10),void 0===r&&(r=Ev);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=Cv(e),f={x:0,y:0},m={x:0,y:0},p=t.height*r.y,g=t.width*r.x;return!c&&a<=t.top+p?(f.y=kv.Backward,m.y=o*Math.abs((t.top+p-a)/p)):!d&&l>=t.bottom-p&&(f.y=kv.Forward,m.y=o*Math.abs((t.bottom-p-l)/p)),!h&&s>=t.right-g?(f.x=kv.Forward,m.x=o*Math.abs((t.right-g-s)/g)):!u&&i<=t.left+g&&(f.x=kv.Backward,m.x=o*Math.abs((t.left+g-i)/g)),{direction:f,speed:m}}function _v(e){if(e===document.scrollingElement){const{innerWidth:e,innerHeight:t}=window;return{top:0,left:0,right:e,bottom:t,width:e,height:t}}const{top:t,left:n,right:o,bottom:r}=e.getBoundingClientRect();return{top:t,left:n,right:o,bottom:r,width:e.clientWidth,height:e.clientHeight}}function Iv(e){return e.reduce(((e,t)=>Ko(e,wv(t))),Qg)}const Av=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+xv(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+bv(t)),0)}]];class Tv{constructor(e,t){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const n=gv(t),o=Iv(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[r,a,i]of Av)for(const e of a)Object.defineProperty(this,e,{get:()=>{const t=i(n),a=o[r]-t;return this.rect[e]+a},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Mv{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach((e=>{var t;return null==(t=this.target)?void 0:t.removeEventListener(...e)}))},this.target=e}add(e,t,n){var o;null==(o=this.target)||o.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function Ov(e,t){const n=Math.abs(e.x),o=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+o**2)>t:"x"in t&&"y"in t?n>t.x&&o>t.y:"x"in t?n>t.x:"y"in t&&o>t.y}var Dv,Pv,Rv,Lv;function zv(e){e.preventDefault()}function Fv(e){e.stopPropagation()}(Pv=Dv||(Dv={})).Click="click",Pv.DragStart="dragstart",Pv.Keydown="keydown",Pv.ContextMenu="contextmenu",Pv.Resize="resize",Pv.SelectionChange="selectionchange",Pv.VisibilityChange="visibilitychange",(Lv=Rv||(Rv={})).Space="Space",Lv.Down="ArrowDown",Lv.Right="ArrowRight",Lv.Left="ArrowLeft",Lv.Up="ArrowUp",Lv.Esc="Escape",Lv.Enter="Enter";const Bv={start:[Rv.Space,Rv.Enter],cancel:[Rv.Esc],end:[Rv.Space,Rv.Enter]},Uv=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case Rv.Right:return{...n,x:n.x+25};case Rv.Left:return{...n,x:n.x-25};case Rv.Down:return{...n,y:n.y+25};case Rv.Up:return{...n,y:n.y-25}}};class Vv{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:t}}=e;this.props=e,this.listeners=new Mv(qo(t)),this.windowListeners=new Mv(Go(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Dv.Resize,this.handleCancel),this.windowListeners.add(Dv.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(Dv.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=mv),!e)return;const{top:n,left:o,bottom:r,right:a}=t(e);vv(e)&&(r<=0||a<=0||n>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(Qg)}handleKeyDown(e){if(Yo(e)){const{active:t,context:n,options:o}=this.props,{keyboardCodes:r=Bv,coordinateGetter:a=Uv,scrollBehavior:i="smooth"}=o,{code:s}=e;if(r.end.includes(s))return void this.handleEnd(e);if(r.cancel.includes(s))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Qg;this.referenceCoordinates||(this.referenceCoordinates=c);const d=a(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=Xo(d,c),o={x:0,y:0},{scrollableAncestors:r}=n.current;for(const n of r){const r=e.code,{isTop:a,isRight:s,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=Cv(n),f=_v(n),m={x:Math.min(r===Rv.Right?f.right-f.width/2:f.right,Math.max(r===Rv.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(r===Rv.Down?f.bottom-f.height/2:f.bottom,Math.max(r===Rv.Down?f.top:f.top+f.height/2,d.y))},p=r===Rv.Right&&!s||r===Rv.Left&&!l,g=r===Rv.Down&&!c||r===Rv.Up&&!a;if(p&&m.x!==d.x){const e=n.scrollLeft+t.x,a=r===Rv.Right&&e<=u.x||r===Rv.Left&&e>=h.x;if(a&&!t.y)return void n.scrollTo({left:e,behavior:i});o.x=a?n.scrollLeft-e:r===Rv.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,o.x&&n.scrollBy({left:-o.x,behavior:i});break}if(g&&m.y!==d.y){const e=n.scrollTop+t.y,a=r===Rv.Down&&e<=u.y||r===Rv.Up&&e>=h.y;if(a&&!t.x)return void n.scrollTo({top:e,behavior:i});o.y=a?n.scrollTop-e:r===Rv.Down?n.scrollTop-u.y:n.scrollTop-h.y,o.y&&n.scrollBy({top:-o.y,behavior:i});break}}this.handleMove(e,Ko(Xo(d,this.referenceCoordinates),o))}}}handleMove(e,t){const{onMove:n}=this.props;e.preventDefault(),n(t)}handleEnd(e){const{onEnd:t}=this.props;e.preventDefault(),this.detach(),t()}handleCancel(e){const{onCancel:t}=this.props;e.preventDefault(),this.detach(),t()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function Hv(e){return Boolean(e&&"distance"in e)}function $v(e){return Boolean(e&&"delay"in e)}Vv.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:o=Bv,onActivation:r}=t,{active:a}=n;const{code:i}=e.nativeEvent;if(o.start.includes(i)){const t=a.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==r||r({event:e.nativeEvent}),!0)}return!1}}];class Wv{constructor(e,t,n){var o;void 0===n&&(n=function(e){const{EventTarget:t}=Go(e);return e instanceof t?e:qo(e)}(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=t;const{event:r}=e,{target:a}=r;this.props=e,this.events=t,this.document=qo(a),this.documentListeners=new Mv(this.document),this.listeners=new Mv(n),this.windowListeners=new Mv(Go(a)),this.initialCoordinates=null!=(o=Qo(r))?o:Qg,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:t,bypassActivationConstraint:n}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),this.windowListeners.add(Dv.Resize,this.handleCancel),this.windowListeners.add(Dv.DragStart,zv),this.windowListeners.add(Dv.VisibilityChange,this.handleCancel),this.windowListeners.add(Dv.ContextMenu,zv),this.documentListeners.add(Dv.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if($v(t))return void(this.timeoutId=setTimeout(this.handleStart,t.delay));if(Hv(t))return}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(Dv.Click,Fv,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Dv.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:o,props:r}=this,{onMove:a,options:{activationConstraint:i}}=r;if(!o)return;const s=null!=(t=Qo(e))?t:Qg,l=Xo(o,s);if(!n&&i){if(Hv(i)){if(null!=i.tolerance&&Ov(l,i.tolerance))return this.handleCancel();if(Ov(l,i.distance))return this.handleStart()}return $v(i)&&Ov(l,i.tolerance)?this.handleCancel():void 0}e.cancelable&&e.preventDefault(),a(s)}handleEnd(){const{onEnd:e}=this.props;this.detach(),e()}handleCancel(){const{onCancel:e}=this.props;this.detach(),e()}handleKeydown(e){e.code===Rv.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const Gv={move:{name:"pointermove"},end:{name:"pointerup"}};class qv extends Wv{constructor(e){const{event:t}=e,n=qo(t.target);super(e,Gv,n)}}qv.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return!(!n.isPrimary||0!==n.button)&&(null==o||o({event:n}),!0)}}];const Yv={move:{name:"mousemove"},end:{name:"mouseup"}};var Xv,Kv;(Kv=Xv||(Xv={}))[Kv.RightClick=2]="RightClick";(class extends Wv{constructor(e){super(e,Yv,qo(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;return n.button!==Xv.RightClick&&(null==o||o({event:n}),!0)}}];const Jv={move:{name:"touchmove"},end:{name:"touchend"}};var Zv,Qv,ey,ty;function ny(e){let{acceleration:t,activator:n=Zv.Pointer,canScroll:o,draggingRect:a,enabled:i,interval:s=5,order:l=ey.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const m=function(e){let{delta:t,disabled:n}=e;const o=or(t);return rr((e=>{if(n||!o||!e)return oy;const r={x:Math.sign(t.x-o.x),y:Math.sign(t.y-o.y)};return{x:{[kv.Backward]:e.x[kv.Backward]||-1===r.x,[kv.Forward]:e.x[kv.Forward]||1===r.x},y:{[kv.Backward]:e.y[kv.Backward]||-1===r.y,[kv.Forward]:e.y[kv.Forward]||1===r.y}}}),[n,t,o])}({delta:h,disabled:!i}),[p,g]=nr(),v=r.useRef({x:0,y:0}),y=r.useRef({x:0,y:0}),x=r.useMemo((()=>{switch(n){case Zv.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Zv.DraggableRect:return a}}),[n,a,c]),b=r.useRef(null),w=r.useCallback((()=>{const e=b.current;if(!e)return;const t=v.current.x*y.current.x,n=v.current.y*y.current.y;e.scrollBy(t,n)}),[]),k=r.useMemo((()=>l===ey.TreeOrder?[...d].reverse():d),[l,d]);r.useEffect((()=>{if(i&&d.length&&x){for(const e of k){if(!1===(null==o?void 0:o(e)))continue;const n=d.indexOf(e),r=u[n];if(!r)continue;const{direction:a,speed:i}=jv(e,r,x,t,f);for(const e of["x","y"])m[e][a[e]]||(i[e]=0,a[e]=0);if(i.x>0||i.y>0)return g(),b.current=e,p(w,s),v.current=i,void(y.current=a)}v.current={x:0,y:0},y.current={x:0,y:0},g()}else g()}),[t,w,o,g,i,s,JSON.stringify(x),JSON.stringify(m),p,d,k,u,JSON.stringify(f)])}(class extends Wv{constructor(e){super(e,Jv)}static setup(){return window.addEventListener(Jv.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Jv.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:o}=t;const{touches:r}=n;return!(r.length>1)&&(null==o||o({event:n}),!0)}}],(Qv=Zv||(Zv={}))[Qv.Pointer=0]="Pointer",Qv[Qv.DraggableRect=1]="DraggableRect",(ty=ey||(ey={}))[ty.TreeOrder=0]="TreeOrder",ty[ty.ReversedTreeOrder=1]="ReversedTreeOrder";const oy={x:{[kv.Backward]:!1,[kv.Forward]:!1},y:{[kv.Backward]:!1,[kv.Forward]:!1}};var ry,ay,iy;(ay=ry||(ry={}))[ay.Always=0]="Always",ay[ay.BeforeDragging=1]="BeforeDragging",ay[ay.WhileDragging=2]="WhileDragging",(iy||(iy={})).Optimized="optimized";const sy=new Map;function ly(e,t){return rr((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function cy(e){let{callback:t,disabled:n}=e;const o=fr(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(o)}),[n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}function dy(e){return new Tv(mv(e),e)}function uy(e,t,n){void 0===t&&(t=dy);const[o,a]=r.useReducer((function(o){if(!e)return null;var r;if(!1===e.isConnected)return null!=(r=null!=o?o:n)?r:null;const a=t(e);if(JSON.stringify(o)===JSON.stringify(a))return o;return a}),null),i=function(e){let{callback:t,disabled:n}=e;const o=fr(t),a=r.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(o)}),[o,n]);return r.useEffect((()=>()=>null==a?void 0:a.disconnect()),[a]),a}({callback(t){if(e)for(const n of t){const{type:t,target:o}=n;if("childList"===t&&o instanceof HTMLElement&&o.contains(e)){a();break}}}}),s=cy({callback:a});return tr((()=>{a(),e?(null==s||s.observe(e),null==i||i.observe(document.body,{childList:!0,subtree:!0})):(null==s||s.disconnect(),null==i||i.disconnect())}),[e]),o}const hy=[];function fy(e,t){void 0===t&&(t=[]);const n=r.useRef(null);return r.useEffect((()=>{n.current=null}),t),r.useEffect((()=>{const t=e!==Qg;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?Xo(e,n.current):Qg}function my(e){return r.useMemo((()=>e?function(e){const t=e.innerWidth,n=e.innerHeight;return{top:0,left:0,right:t,bottom:n,width:t,height:n}}(e):null),[e])}const py=[];function gy(e){let{measure:t}=e;const[n,o]=r.useState(null),a=cy({callback:r.useCallback((e=>{for(const{target:n}of e)if(ir(n)){o((e=>{const o=t(n);return e?{...e,width:o.width,height:o.height}:o}));break}}),[t])}),i=r.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return ir(t)?t:e}(e);null==a||a.disconnect(),n&&(null==a||a.observe(n)),o(n?t(n):null)}),[t,a]),[s,l]=sr(i);return r.useMemo((()=>({nodeRef:s,rect:n,setRef:l})),[n,s,l])}const vy=[{sensor:qv,options:{}},{sensor:Vv,options:{}}],yy={current:{}},xy={draggable:{measure:pv},droppable:{measure:pv,strategy:ry.WhileDragging,frequency:iy.Optimized},dragOverlay:{measure:mv}};class by extends Map{get(e){var t;return null!=e&&null!=(t=super.get(e))?t:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter((e=>{let{disabled:t}=e;return!t}))}getNodeFor(e){var t,n;return null!=(t=null==(n=this.get(e))?void 0:n.node.current)?t:void 0}}const wy={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new by,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Jg},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:xy,measureDroppableContainers:Jg,windowRect:null,measuringScheduled:!1},ky={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Jg,draggableNodes:new Map,over:null,measureDroppableContainers:Jg},Sy=r.createContext(ky),Ny=r.createContext(wy);function Cy(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new by}}}function Ey(e,t){switch(t.type){case Xg.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case Xg.DragMove:return e.draggable.active?{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}}:e;case Xg.DragEnd:case Xg.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Xg.RegisterDroppable:{const{element:n}=t,{id:o}=n,r=new by(e.droppable.containers);return r.set(o,n),{...e,droppable:{...e.droppable,containers:r}}}case Xg.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=t,a=e.droppable.containers.get(n);if(!a||o!==a.key)return e;const i=new by(e.droppable.containers);return i.set(n,{...a,disabled:r}),{...e,droppable:{...e.droppable,containers:i}}}case Xg.UnregisterDroppable:{const{id:n,key:o}=t,r=e.droppable.containers.get(n);if(!r||o!==r.key)return e;const a=new by(e.droppable.containers);return a.delete(n),{...e,droppable:{...e.droppable,containers:a}}}default:return e}}function jy(e){let{disabled:t}=e;const{active:n,activatorEvent:o,draggableNodes:a}=r.useContext(Sy),i=or(o),s=or(null==n?void 0:n.id);return r.useEffect((()=>{if(!t&&!o&&i&&null!=s){if(!Yo(i))return;if(document.activeElement===i.target)return;const e=a.get(s);if(!e)return;const{activatorNode:t,node:n}=e;if(!t.current&&!n.current)return;requestAnimationFrame((()=>{for(const e of[t.current,n.current]){if(!e)continue;const t=lr(e);if(t){t.focus();break}}}))}}),[o,t,a,s,i]),null}const _y=r.createContext({...Qg,scaleX:1,scaleY:1});var Iy,Ay;(Ay=Iy||(Iy={}))[Ay.Uninitialized=0]="Uninitialized",Ay[Ay.Initializing=1]="Initializing",Ay[Ay.Initialized=2]="Initialized";const Ty=r.memo((function(e){var t,n,o,a;let{id:i,accessibility:s,autoScroll:l=!0,children:c,sensors:d=vy,collisionDetection:h=lv,measuring:f,modifiers:m,...p}=e;const g=r.useReducer(Ey,void 0,Cy),[v,y]=g,[x,b]=function(){const[e]=r.useState((()=>new Set)),t=r.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[r.useCallback((t=>{let{type:n,event:o}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,o)}))}),[e]),t]}(),[w,k]=r.useState(Iy.Uninitialized),S=w===Iy.Initialized,{draggable:{active:N,nodes:C,translate:E},droppable:{containers:j}}=v,_=N?C.get(N):null,I=r.useRef({initial:null,translated:null}),A=r.useMemo((()=>{var e;return null!=N?{id:N,data:null!=(e=null==_?void 0:_.data)?e:yy,rect:I}:null}),[N,_]),T=r.useRef(null),[M,O]=r.useState(null),[D,P]=r.useState(null),R=Jo(p,Object.values(p)),L=Zo("DndDescribedBy",i),z=r.useMemo((()=>j.getEnabled()),[j]),F=(B=f,r.useMemo((()=>({draggable:{...xy.draggable,...null==B?void 0:B.draggable},droppable:{...xy.droppable,...null==B?void 0:B.droppable},dragOverlay:{...xy.dragOverlay,...null==B?void 0:B.dragOverlay}})),[null==B?void 0:B.draggable,null==B?void 0:B.droppable,null==B?void 0:B.dragOverlay]));var B;const{droppableRects:U,measureDroppableContainers:V,measuringScheduled:H}=function(e,t){let{dragging:n,dependencies:o,config:a}=t;const[i,s]=r.useState(null),{frequency:l,measure:c,strategy:d}=a,u=r.useRef(e),h=function(){switch(d){case ry.Always:return!1;case ry.BeforeDragging:return n;default:return!n}}(),f=Jo(h),m=r.useCallback((function(e){void 0===e&&(e=[]),f.current||s((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),p=r.useRef(null),g=rr((t=>{if(h&&!n)return sy;if(!t||t===sy||u.current!==e||null!=i){const t=new Map;for(let n of e){if(!n)continue;if(i&&i.length>0&&!i.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,o=e?new Tv(c(e),e):null;n.rect.current=o,o&&t.set(n.id,o)}return t}return t}),[e,i,n,h,c]);return r.useEffect((()=>{u.current=e}),[e]),r.useEffect((()=>{h||m()}),[n,h]),r.useEffect((()=>{i&&i.length>0&&s(null)}),[JSON.stringify(i)]),r.useEffect((()=>{h||"number"!=typeof l||null!==p.current||(p.current=setTimeout((()=>{m(),p.current=null}),l))}),[l,h,m,...o]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:null!=i}}(z,{dragging:S,dependencies:[E.x,E.y],config:F.droppable}),$=function(e,t){const n=null!==t?e.get(t):void 0,o=n?n.node.current:null;return rr((e=>{var n;return null===t?null:null!=(n=null!=o?o:e)?n:null}),[o,t])}(C,N),W=r.useMemo((()=>D?Qo(D):null),[D]),G=function(){const e=!1===(null==M?void 0:M.autoScrollEnabled),t="object"==typeof l?!1===l.enabled:!1===l,n=S&&!e&&!t;if("object"==typeof l)return{...l,enabled:n};return{enabled:n}}(),q=function(e,t){return ly(e,t)}($,F.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:o,config:a=!0}=e;const i=r.useRef(!1),{x:s,y:l}="boolean"==typeof a?{x:a,y:a}:a;tr((()=>{if(!s&&!l||!t)return void(i.current=!1);if(i.current||!o)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const r=dv(n(e),o);if(s||(r.x=0),l||(r.y=0),i.current=!0,Math.abs(r.x)>0||Math.abs(r.y)>0){const t=vv(e);t&&t.scrollBy({top:r.y,left:r.x})}}),[t,s,l,o,n])}({activeNode:N?C.get(N):null,config:G.layoutShiftCompensation,initialRect:q,measure:F.draggable.measure});const Y=uy($,F.draggable.measure,q),X=uy($?$.parentElement:null),K=r.useRef({activatorEvent:null,active:null,activeNode:$,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:C,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),J=j.getNodeFor(null==(t=K.current.over)?void 0:t.id),Z=gy({measure:F.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:$,ee=S?null!=(o=Z.rect)?o:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=dv(oe=te?null:Y,ly(oe));var oe;const re=my(Q?Go(Q):null),ae=function(e){const t=r.useRef(e),n=rr((n=>e?n&&n!==hy&&e&&t.current&&e.parentNode===t.current.parentNode?n:gv(e):hy),[e]);return r.useEffect((()=>{t.current=e}),[e]),n}(S?null!=J?J:$:null),ie=function(e,t){void 0===t&&(t=mv);const[n]=e,o=my(n?Go(n):null),[a,i]=r.useReducer((function(){return e.length?e.map((e=>Nv(e)?o:new Tv(t(e),e))):py}),py),s=cy({callback:i});return e.length>0&&a===py&&i(),tr((()=>{e.length?e.forEach((e=>null==s?void 0:s.observe(e))):(null==s||s.disconnect(),i())}),[e]),a}(ae),se=function(e,t){let{transform:n,...o}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...o})),n):n}(m,{transform:{x:E.x-ne.x,y:E.y-ne.y,scaleX:1,scaleY:1},activatorEvent:D,active:A,activeNodeRect:Y,containerNodeRect:X,draggingNodeRect:ee,over:K.current.over,overlayNodeRect:Z.rect,scrollableAncestors:ae,scrollableAncestorRects:ie,windowRect:re}),le=W?Ko(W,E):null,ce=function(e){const[t,n]=r.useState(null),o=r.useRef(e),a=r.useCallback((e=>{const t=yv(e.target);t&&n((e=>e?(e.set(t,wv(t)),new Map(e)):null))}),[]);return r.useEffect((()=>{const t=o.current;if(e!==t){r(t);const i=e.map((e=>{const t=yv(e);return t?(t.addEventListener("scroll",a,{passive:!0}),[t,wv(t)]):null})).filter((e=>null!=e));n(i.length?new Map(i):null),o.current=e}return()=>{r(e),r(t)};function r(e){e.forEach((e=>{const t=yv(e);null==t||t.removeEventListener("scroll",a)}))}}),[a,e]),r.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>Ko(e,t)),Qg):Iv(e):Qg),[e,t])}(ae),de=fy(ce),ue=fy(ce,[Y]),he=Ko(se,de),fe=ee?hv(ee,se):null,me=A&&fe?h({active:A,collisionRect:fe,droppableRects:U,droppableContainers:z,pointerCoordinates:le}):null,pe=rv(me,"id"),[ge,ve]=r.useState(null),ye=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?se:Ko(se,ue),null!=(a=null==ge?void 0:ge.rect)?a:null,Y),xe=r.useCallback(((e,t)=>{let{sensor:n,options:o}=t;if(null==T.current)return;const r=C.get(T.current);if(!r)return;const a=e.nativeEvent,i=new n({active:T.current,activeNode:r,event:a,options:o,context:K,onStart(e){const t=T.current;if(null==t)return;const n=C.get(t);if(!n)return;const{onDragStart:o}=R.current,r={active:{id:t,data:n.data,rect:I}};er.unstable_batchedUpdates((()=>{null==o||o(r),k(Iy.Initializing),y({type:Xg.DragStart,initialCoordinates:e,active:t}),x({type:"onDragStart",event:r})}))},onMove(e){y({type:Xg.DragMove,coordinates:e})},onEnd:s(Xg.DragEnd),onCancel:s(Xg.DragCancel)});function s(e){return async function(){const{active:t,collisions:n,over:o,scrollAdjustedTranslate:r}=K.current;let i=null;if(t&&r){const{cancelDrop:s}=R.current;if(i={activatorEvent:a,active:t,collisions:n,delta:r,over:o},e===Xg.DragEnd&&"function"==typeof s){await Promise.resolve(s(i))&&(e=Xg.DragCancel)}}T.current=null,er.unstable_batchedUpdates((()=>{y({type:e}),k(Iy.Uninitialized),ve(null),O(null),P(null);const t=e===Xg.DragEnd?"onDragEnd":"onDragCancel";if(i){const e=R.current[t];null==e||e(i),x({type:t,event:i})}}))}}er.unstable_batchedUpdates((()=>{O(i),P(e.nativeEvent)}))}),[C]),be=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{const{sensor:o}=n;return[...e,...o.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,r.useCallback(((e,t)=>(n,o)=>{const r=n.nativeEvent,a=C.get(o);if(null!==T.current||!a||r.dndKit||r.defaultPrevented)return;const i={active:a};!0===e(n,t.options,i)&&(r.dndKit={capturedBy:t.sensor},T.current=o,xe(n,t))}),[C,xe]));!function(e){r.useEffect((()=>{if(!ar)return;const t=e.map((e=>{let{sensor:t}=e;return null==t.setup?void 0:t.setup()}));return()=>{for(const e of t)null==e||e()}}),e.map((e=>{let{sensor:t}=e;return t})))}(d),tr((()=>{Y&&w===Iy.Initializing&&k(Iy.Initialized)}),[Y,w]),r.useEffect((()=>{const{onDragMove:e}=R.current,{active:t,activatorEvent:n,collisions:o,over:r}=K.current;if(!t||!n)return;const a={active:t,activatorEvent:n,collisions:o,delta:{x:he.x,y:he.y},over:r};er.unstable_batchedUpdates((()=>{null==e||e(a),x({type:"onDragMove",event:a})}))}),[he.x,he.y]),r.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:o,scrollAdjustedTranslate:r}=K.current;if(!e||null==T.current||!t||!r)return;const{onDragOver:a}=R.current,i=o.get(pe),s=i&&i.rect.current?{id:i.id,rect:i.rect.current,data:i.data,disabled:i.disabled}:null,l={active:e,activatorEvent:t,collisions:n,delta:{x:r.x,y:r.y},over:s};er.unstable_batchedUpdates((()=>{ve(s),null==a||a(l),x({type:"onDragOver",event:l})}))}),[pe]),tr((()=>{K.current={activatorEvent:D,active:A,activeNode:$,collisionRect:fe,collisions:me,droppableRects:U,draggableNodes:C,draggingNode:Q,draggingNodeRect:ee,droppableContainers:j,over:ge,scrollableAncestors:ae,scrollAdjustedTranslate:he},I.current={initial:ee,translated:fe}}),[A,$,me,fe,C,Q,ee,U,j,ge,ae,he]),ny({...G,delta:E,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:ae,scrollableAncestorRects:ie});const we=r.useMemo((()=>({active:A,activeNode:$,activeNodeRect:Y,activatorEvent:D,collisions:me,containerNodeRect:X,dragOverlay:Z,draggableNodes:C,droppableContainers:j,droppableRects:U,over:ge,measureDroppableContainers:V,scrollableAncestors:ae,scrollableAncestorRects:ie,measuringConfiguration:F,measuringScheduled:H,windowRect:re})),[A,$,Y,D,me,X,Z,C,j,U,ge,V,ae,ie,F,H,re]),ke=r.useMemo((()=>({activatorEvent:D,activators:be,active:A,activeNodeRect:Y,ariaDescribedById:{draggable:L},dispatch:y,draggableNodes:C,over:ge,measureDroppableContainers:V})),[D,be,A,Y,y,L,C,ge,V]);return u.createElement(Wg.Provider,{value:b},u.createElement(Sy.Provider,{value:ke},u.createElement(Ny.Provider,{value:we},u.createElement(_y.Provider,{value:ye},c)),u.createElement(jy,{disabled:!1===(null==s?void 0:s.restoreFocus)})),u.createElement(Yg,{...s,hiddenTextDescribedById:L}))})),My=r.createContext(null),Oy="button";function Dy(e){let{id:t,data:n,disabled:o=!1,attributes:a}=e;const i=Zo("Droppable"),{activators:s,activatorEvent:l,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=r.useContext(Sy),{role:m=Oy,roleDescription:p="draggable",tabIndex:g=0}=null!=a?a:{},v=(null==c?void 0:c.id)===t,y=r.useContext(v?_y:My),[x,b]=sr(),[w,k]=sr(),S=function(e,t){return r.useMemo((()=>e.reduce(((e,n)=>{let{eventName:o,handler:r}=n;return e[o]=e=>{r(e,t)},e}),{})),[e,t])}(s,t),N=Jo(n);tr((()=>(h.set(t,{id:t,key:i,node:x,activatorNode:w,data:N}),()=>{const e=h.get(t);e&&e.key===i&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:l,activeNodeRect:d,attributes:r.useMemo((()=>({role:m,tabIndex:g,"aria-disabled":o,"aria-pressed":!(!v||m!==Oy)||void 0,"aria-roledescription":p,"aria-describedby":u.draggable})),[o,m,g,v,p,u.draggable]),isDragging:v,listeners:o?void 0:S,node:x,over:f,setNodeRef:b,setActivatorNodeRef:k,transform:y}}const Py={timeout:25};function Ry(e,t,n){const o=e.slice();return o.splice(n<0?o.length+n:n,0,o.splice(t,1)[0]),o}function Ly(e,t){return e.reduce(((e,n,o)=>{const r=t.get(n);return r&&(e[o]=r),e}),Array(e.length))}function zy(e){return null!==e&&e>=0}const Fy={scaleX:1,scaleY:1},By=e=>{var t;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:a,index:i}=e;const s=null!=(t=n[r])?t:o;if(!s)return null;const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o||!r&&!a)return 0;if(n<t)return r?o.left-(r.left+r.width):a.left-(o.left+o.width);return a?a.left-(o.left+o.width):o.left-(r.left+r.width)}(n,i,r);if(i===r){const e=n[a];return e?{x:r<a?e.left+e.width-(s.left+s.width):e.left-s.left,y:0,...Fy}:null}return i>r&&i<=a?{x:-s.width-l,y:0,...Fy}:i<r&&i>=a?{x:s.width+l,y:0,...Fy}:{x:0,y:0,...Fy}};const Uy=e=>{let{rects:t,activeIndex:n,overIndex:o,index:r}=e;const a=Ry(t,o,n),i=t[r],s=a[r];return s&&i?{x:s.left-i.left,y:s.top-i.top,scaleX:s.width/i.width,scaleY:s.height/i.height}:null},Vy={scaleX:1,scaleY:1},Hy=e=>{var t;let{activeIndex:n,activeNodeRect:o,index:r,rects:a,overIndex:i}=e;const s=null!=(t=a[n])?t:o;if(!s)return null;if(r===n){const e=a[i];return e?{x:0,y:n<i?e.top+e.height-(s.top+s.height):e.top-s.top,...Vy}:null}const l=function(e,t,n){const o=e[t],r=e[t-1],a=e[t+1];if(!o)return 0;if(n<t)return r?o.top-(r.top+r.height):a?a.top-(o.top+o.height):0;return a?a.top-(o.top+o.height):r?o.top-(r.top+r.height):0}(a,r,n);return r>n&&r<=i?{x:0,y:-s.height-l,...Vy}:r<n&&r>=i?{x:0,y:s.height+l,...Vy}:{x:0,y:0,...Vy}};const $y="Sortable",Wy=u.createContext({activeIndex:-1,containerId:$y,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Uy,disabled:{draggable:!1,droppable:!1}});function Gy(e){let{children:t,id:n,items:o,strategy:a=Uy,disabled:i=!1}=e;const{active:s,dragOverlay:l,droppableRects:c,over:d,measureDroppableContainers:h}=r.useContext(Ny),f=Zo($y,n),m=Boolean(null!==l.rect),p=r.useMemo((()=>o.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[o]),g=null!=s,v=s?p.indexOf(s.id):-1,y=d?p.indexOf(d.id):-1,x=r.useRef(p),b=!function(e,t){if(e===t)return!0;if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}(p,x.current),w=-1!==y&&-1===v||b,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(i);tr((()=>{b&&g&&h(p)}),[b,p,g,h]),r.useEffect((()=>{x.current=p}),[p]);const S=r.useMemo((()=>({activeIndex:v,containerId:f,disabled:k,disableTransforms:w,items:p,overIndex:y,useDragOverlay:m,sortedRects:Ly(p,c),strategy:a})),[v,f,k.draggable,k.droppable,w,p,y,c,m,a]);return u.createElement(Wy.Provider,{value:S},t)}const qy=e=>{let{id:t,items:n,activeIndex:o,overIndex:r}=e;return Ry(n,o,r).indexOf(t)},Yy=e=>{let{containerId:t,isSorting:n,wasDragging:o,index:r,items:a,newIndex:i,previousItems:s,previousContainerId:l,transition:c}=e;return!(!c||!o)&&((s===a||r!==i)&&(!!n||i!==r&&t===l))},Xy={duration:200,easing:"ease"},Ky="transform",Jy=pr.Transition.toString({property:Ky,duration:0,easing:"linear"}),Zy={roleDescription:"sortable"};function Qy(e){let{animateLayoutChanges:t=Yy,attributes:n,disabled:o,data:a,getNewIndex:i=qy,id:s,strategy:l,resizeObserverConfig:c,transition:d=Xy}=e;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:v,useDragOverlay:y,strategy:x}=r.useContext(Wy),b=function(e,t){var n,o;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(o=null==e?void 0:e.droppable)?o:t.droppable}}(o,m),w=u.indexOf(s),k=r.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...a})),[h,a,w,u]),S=r.useMemo((()=>u.slice(u.indexOf(s))),[u,s]),{rect:N,node:C,isOver:E,setNodeRef:j}=function(e){let{data:t,disabled:n=!1,id:o,resizeObserverConfig:a}=e;const i=Zo("Droppable"),{active:s,dispatch:l,over:c,measureDroppableContainers:d}=r.useContext(Sy),u=r.useRef({disabled:n}),h=r.useRef(!1),f=r.useRef(null),m=r.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:v}={...Py,...a},y=Jo(null!=g?g:o),x=cy({callback:r.useCallback((()=>{h.current?(null!=m.current&&clearTimeout(m.current),m.current=setTimeout((()=>{d(Array.isArray(y.current)?y.current:[y.current]),m.current=null}),v)):h.current=!0}),[v]),disabled:p||!s}),b=r.useCallback(((e,t)=>{x&&(t&&(x.unobserve(t),h.current=!1),e&&x.observe(e))}),[x]),[w,k]=sr(b),S=Jo(t);return r.useEffect((()=>{x&&w.current&&(x.disconnect(),h.current=!1,x.observe(w.current))}),[w,x]),tr((()=>(l({type:Xg.RegisterDroppable,element:{id:o,key:i,disabled:n,node:w,rect:f,data:S}}),()=>l({type:Xg.UnregisterDroppable,key:i,id:o}))),[o]),r.useEffect((()=>{n!==u.current.disabled&&(l({type:Xg.SetDroppableDisabled,id:o,key:i,disabled:n}),u.current.disabled=n)}),[o,i,n,l]),{active:s,rect:f,isOver:(null==c?void 0:c.id)===o,node:w,over:c,setNodeRef:k}}({id:s,data:k,disabled:b.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:_,activatorEvent:I,activeNodeRect:A,attributes:T,setNodeRef:M,listeners:O,isDragging:D,over:P,setActivatorNodeRef:R,transform:L}=Dy({id:s,data:k,attributes:{...Zy,...n},disabled:b.draggable}),z=mr(j,M),F=Boolean(_),B=F&&!p&&zy(f)&&zy(v),U=!y&&D,V=U&&B?L:null,H=B?null!=V?V:(null!=l?l:x)({rects:g,activeNodeRect:A,activeIndex:f,overIndex:v,index:w}):null,$=zy(f)&&zy(v)?i({id:s,items:u,activeIndex:f,overIndex:v}):w,W=null==_?void 0:_.id,G=r.useRef({activeId:W,items:u,newIndex:$,containerId:h}),q=u!==G.current.items,Y=t({active:_,containerId:h,isDragging:D,isSorting:F,id:s,index:w,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:d,wasDragging:null!=G.current.activeId}),X=function(e){let{disabled:t,index:n,node:o,rect:a}=e;const[i,s]=r.useState(null),l=r.useRef(n);return tr((()=>{if(!t&&n!==l.current&&o.current){const e=a.current;if(e){const t=mv(o.current,{ignoreTransform:!0}),n={x:e.left-t.left,y:e.top-t.top,scaleX:e.width/t.width,scaleY:e.height/t.height};(n.x||n.y)&&s(n)}}n!==l.current&&(l.current=n)}),[t,n,o,a]),r.useEffect((()=>{i&&s(null)}),[i]),i}({disabled:!Y,index:w,node:C,rect:N});return r.useEffect((()=>{F&&G.current.newIndex!==$&&(G.current.newIndex=$),h!==G.current.containerId&&(G.current.containerId=h),u!==G.current.items&&(G.current.items=u)}),[F,$,h,u]),r.useEffect((()=>{if(W===G.current.activeId)return;if(W&&!G.current.activeId)return void(G.current.activeId=W);const e=setTimeout((()=>{G.current.activeId=W}),50);return()=>clearTimeout(e)}),[W]),{active:_,activeIndex:f,attributes:T,data:k,rect:N,index:w,newIndex:$,items:u,isOver:E,isSorting:F,isDragging:D,listeners:O,node:C,overIndex:v,over:P,setNodeRef:z,setActivatorNodeRef:R,setDroppableNodeRef:j,setDraggableNodeRef:M,transform:null!=X?X:H,transition:function(){if(X||q&&G.current.newIndex===w)return Jy;if(U&&!Yo(I)||!d)return;if(F||Y)return pr.Transition.toString({...d,property:Ky});return}()}}function ex(e){if(!e)return!1;const t=e.data.current;return!!(t&&"sortable"in t&&"object"==typeof t.sortable&&"containerId"in t.sortable&&"items"in t.sortable&&"index"in t.sortable)}const tx=[Rv.Down,Rv.Right,Rv.Up,Rv.Left],nx=(e,t)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:a,over:i,scrollableAncestors:s}}=t;if(tx.includes(e.code)){if(e.preventDefault(),!n||!o)return;const t=[];a.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const a=r.get(n.id);if(a)switch(e.code){case Rv.Down:o.top<a.top&&t.push(n);break;case Rv.Up:o.top>a.top&&t.push(n);break;case Rv.Left:o.left>a.left&&t.push(n);break;case Rv.Right:o.left<a.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:o}=e;const r=ov(t),a=[];for(const i of o){const{id:e}=i,t=n.get(e);if(t){const n=ov(t),o=r.reduce(((e,t,o)=>e+ev(n[o],t)),0),s=Number((o/4).toFixed(4));a.push({id:e,data:{droppableContainer:i,value:s}})}}return a.sort(tv)})({active:n,collisionRect:o,droppableRects:r,droppableContainers:t,pointerCoordinates:null});let c=rv(l,"id");if(c===(null==i?void 0:i.id)&&l.length>1&&(c=l[1].id),null!=c){const e=a.get(n.id),t=a.get(c),i=t?r.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&i&&e&&t){const n=gv(l).some(((e,t)=>s[t]!==e)),r=ox(e,t),a=function(e,t){if(!ex(e)||!ex(t))return!1;if(!ox(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!r?{x:0,y:0}:{x:a?o.width-i.width:0,y:a?o.height-i.height:0},d={x:i.left,y:i.top};return c.x&&c.y?d:Xo(d,c)}}}};function ox(e,t){return!(!ex(e)||!ex(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}const rx=u.createContext(null),ax=r.memo((()=>r.useContext(rx)));ax.displayName="DragHandle";const ix=u.forwardRef((({cellId:e,canMoveX:t,...n},o)=>{const{attributes:r,listeners:a,setNodeRef:i,transform:s,transition:l,isDragging:c}=Qy({id:e.toString()}),d={transform:s?pr.Transform.toString({x:t?s.x:0,y:s.y,scaleX:1,scaleY:1}):void 0,transition:l,zIndex:c?2:void 0,position:"relative"},u=Ug(o,i),h=k.jsx("div",{...r,...a,onMouseDown:tt.preventFocus,"data-testid":"drag-button",className:"py-[1px] cursor-grab opacity-50 hover:opacity-100 hover-action hover:bg-muted rounded border border-transparent hover:border-border active:bg-accent",children:k.jsx(uc,{strokeWidth:1,size:20})}),f=Boolean(s);return k.jsx("div",{tabIndex:-1,ref:u,...n,"data-is-dragging":c,className:rn(n.className,f&&"is-moving","outline-offset-4 outline-primary/40 rounded-lg"),style:d,children:k.jsx(rx.Provider,{value:h,children:n.children})})}));ix.displayName="SortableCell";const sx=r.memo(ix),lx=u.memo(u.forwardRef(((e,t)=>{const n=b(34);let o,a,i;n[0]!==e?(({children:i,showTooltip:o,...a}=e),n[0]=e,n[1]=o,n[2]=a,n[3]=i):(o=n[1],a=n[2],i=n[3]);const s=void 0===o||o,[l,c]=r.useState(!1);let d;n[4]!==a?(d={cell:a},n[4]=a,n[5]=d):d=n[5];const u=Ad(d),h=gr();let f,m,p,g,v,y;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>c((e=>!e))}),n[6]=f):f=n[6],r.useImperativeHandle(t,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(m=k.jsx(Ye,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=m):m=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(Ke,{children:"No results"}),n[8]=p):p=n[8],n[9]!==u){let e;n[11]!==u.length?(e=(e,t)=>k.jsxs(r.Fragment,{children:[k.jsx(Be,{children:e.map((e=>k.jsx($e,{onSelect:()=>{e.disableClick||(e.handle(),c(!1))},variant:e.variant,children:k.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&k.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),k.jsx("div",{className:"flex-1",children:e.label}),k.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&vr(e.hotkey),e.rightElement]})]})},e.label)))},t),t<u.length-1&&k.jsx(Ve,{})]},t),n[11]=u.length,n[12]=e):e=n[12],g=u.map(e),n[9]=u,n[10]=g}else g=n[10];n[13]!==g?(v=k.jsxs(mn,{children:[m,k.jsxs(yr,{children:[p,g]})]}),n[13]=g,n[14]=v):v=n[14],n[15]!==h||n[16]!==v?(y=k.jsx(hn,{className:"w-[300px] p-0 pt-1",...h,children:v}),n[15]=h,n[16]=v,n[17]=y):y=n[17];const x=y;if(!s){let e,t;return n[18]!==i?(e=k.jsx(xr,{asChild:!0,children:i}),n[18]=i,n[19]=e):e=n[19],n[20]!==l||n[21]!==e||n[22]!==x?(t=k.jsxs(fn,{open:l,onOpenChange:c,children:[e,x]}),n[20]=l,n[21]=e,n[22]=x,n[23]=t):t=n[23],t}let w;n[24]===Symbol.for("react.memo_cache_sentinel")?(w=k.jsx(br,{tabIndex:-1,children:S("cell.cellActions")}),n[24]=w):w=n[24];const N=!l&&w;let C,E,j;return n[25]!==i?(C=k.jsx(wr,{children:k.jsx(xr,{className:"flex",children:i})}),n[25]=i,n[26]=C):C=n[26],n[27]!==N||n[28]!==C?(E=k.jsxs(kr,{delayDuration:200,disableHoverableContent:!0,children:[N,C]}),n[27]=N,n[28]=C,n[29]=E):E=n[29],n[30]!==l||n[31]!==E||n[32]!==x?(j=k.jsxs(fn,{open:l,onOpenChange:c,children:[E,x]}),n[30]=l,n[31]=E,n[32]=x,n[33]=j):j=n[33],j}))),cx=u.memo((e=>{const t=b(5),{children:n,cellId:o}=e;let r,a;t[0]!==o?(a=function(e){return Z((t=>zd(e,t(ie))))}(o),t[0]=o,t[1]=a):a=t[1],r=a;const i=le(r);if(!i)return null;let s;return t[2]!==i||t[3]!==n?(s=k.jsx(lx,{showTooltip:!1,...i,children:n}),t[2]=i,t[3]=n,t[4]=s):s=t[4],s}));cx.displayName="ConnectionCellActionsDropdown";const dx=({children:e,...t})=>{const n=Ad({cell:t}),[o,a]=u.useState(),i=[{label:"Copy",hidden:Boolean(o),icon:k.jsx(nt,{size:13,strokeWidth:1.5}),handle:async()=>{var e;if(null==(e=window.getSelection())?void 0:e.toString())return void document.execCommand("copy");const n=document.getElementById(H.create(t.cellId));n?await et(n.textContent??""):J.warn("cell-context-menu: output not found")}},{label:"Cut",hidden:Boolean(o),icon:k.jsx(Rc,{size:13,strokeWidth:1.5}),handle:()=>{document.execCommand("cut")}},{label:"Paste",hidden:Boolean(o),icon:k.jsx(Ql,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=t,n=e();if(!n)return;const o=await navigator.clipboard.readText();if(o){const{from:e,to:t}=n.state.selection.main,r=n.state.update({changes:{from:e,to:t,insert:o}});n.dispatch(r)}}},{label:"Copy image",hidden:!o,icon:k.jsx(Zl,{size:13,strokeWidth:1.5}),handle:async()=>{if(o){const e=await fetch(o.src),t=await e.blob(),n=new ClipboardItem({[t.type]:t});await navigator.clipboard.write([n]).then((()=>{re({title:"Copied image to clipboard"})})).catch((e=>{re({title:"Failed to copy image to clipboard. Try downloading instead.",description:e.message}),J.error("Failed to copy image to clipboard",e)}))}}},{icon:k.jsx(rl,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!o,handle:()=>{if(o){const e=document.createElement("a");e.download="image.png",e.href=o.src,e.click()}}},{label:"Go to Definition",icon:k.jsx(Sr,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=t,n=e();n&&Nr(n)}}];return k.jsxs(bg,{children:[k.jsx(wg,{onContextMenu:e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},asChild:!0,children:e}),k.jsx(Ng,{className:"w-[300px]",children:[i,...n].map(((e,t)=>k.jsxs(r.Fragment,{children:[e.map((e=>e.hidden?null:k.jsx(Cg,{onSelect:t=>{e.handle(t)},variant:e.variant,children:k.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&k.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),k.jsx("div",{className:"flex-1",children:e.label}),k.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&vr(e.hotkey),e.rightElement]})]})},e.label))),t<e.length-1&&k.jsx(Eg,{})]},t)))})]})},ux=e=>{const t=b(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:a}=e;let i,s;t[0]!==o?(s=(new Uo).isSupported(o)||""===o.trim(),t[0]=o,t[1]=s):s=t[1],i=s;const l=i;let c,d;t[2]!==o?(d=(new Vo).isSupported(o)||""===o.trim(),t[2]=o,t[3]=d):d=t[3],c=d;const u=c&&"python"===r;let h,f;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx(ke,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=h):h=t[4],t[5]!==n||t[6]!==r||t[7]!==u||t[8]!==a?(f=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:u,icon:h,toType:"sql",displayName:"SQL",onAfterToggle:a}),t[5]=n,t[6]=r,t[7]=u,t[8]=a,t[9]=f):f=t[9];const m=l&&"python"===r;let p,g,v,y,x;return t[10]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(Is,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=p):p=t[10],t[11]!==n||t[12]!==r||t[13]!==m||t[14]!==a?(g=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:m,icon:p,toType:"markdown",displayName:"Markdown",onAfterToggle:a}),t[11]=n,t[12]=r,t[13]=m,t[14]=a,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(As,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=v):v=t[16],t[17]!==n||t[18]!==r?(y=k.jsx(hx,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:v,toType:"python",displayName:"Python",onAfterToggle:an.NOOP}),t[17]=n,t[18]=r,t[19]=y):y=t[19],t[20]!==f||t[21]!==g||t[22]!==y?(x=k.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,y]}),t[20]=f,t[21]=g,t[22]=y,t[23]=x):x=t[23],x},hx=e=>{const t=b(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:a,toType:i,displayName:s,onAfterToggle:l}=e;if(!r)return null;if(o===i)return null;const c=`View as ${s}`;let d,u,h;return t[0]!==n||t[1]!==i||t[2]!==l?(d=()=>{n&&(we(n,i),l())},t[0]=n,t[1]=i,t[2]=l,t[3]=d):d=t[3],t[4]!==d||t[5]!==a?(u=k.jsx(C,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:a}),t[4]=d,t[5]=a,t[6]=u):u=t[6],t[7]!==c||t[8]!==u?(h=k.jsx(N,{content:c,children:u}),t[7]=c,t[8]=u,t[9]=h):h=t[9],h};var fx={modified:{doc:""},original:{doc:""}},mx=r.createContext(fx);function px(e,t){return mo({},e,t,{modified:mo({},e.modified,t.modified),original:mo({},e.original,t.original)})}var gx=()=>r.useContext(mx),vx=e=>{var{children:t,theme:n}=e,[o,a]=r.useReducer(px,mo({},fx,{theme:n}));return r.useEffect((()=>a({theme:n})),[n]),k.jsx(mx.Provider,{value:mo({},o,{dispatch:a}),children:t})},yx=["extensions","value","selection","onChange"],xx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,i=Cr(e,yx),{theme:s,dispatch:l}=gx(),c=Er(mo({},i,{theme:s}));return r.useEffect((()=>l({original:{doc:n,selection:o,extensions:[...c,...t]},originalExtension:{onChange:a,option:i,extension:[t]}})),[e]),null};xx.displayName="CodeMirrorMerge.Original";var bx=["extensions","value","selection","onChange"],wx=e=>{var{extensions:t=[],value:n,selection:o,onChange:a}=e,i=Cr(e,bx),{theme:s,dispatch:l}=gx(),c=Er(mo({},i,{theme:s}));return r.useEffect((()=>{l({modified:{doc:n,selection:o,extensions:[...c,...t]},modifiedExtension:{onChange:a,option:i,extension:[t]}})}),[e]),null};wx.displayName="CodeMirrorMerge.Modified";class kx{constructor(e,t,n,o){this.fromA=e,this.toA=t,this.fromB=n,this.toB=o}offset(e,t){return new kx(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function Sx(e,t,n,o,r,a){if(e==o)return[];let i=Ax(e,t,n,o,r,a),s=Tx(e,t+i,n,o,r+i,a),l=(n-=s)-(t+=i),c=(a-=s)-(r+=i);if(!l||!c)return[new kx(t,n,r,a)];if(l>c){let i=e.slice(t,n).indexOf(o.slice(r,a));if(i>-1)return[new kx(t,t+i,r,r),new kx(t+i+c,n,a,a)]}else if(c>l){let i=o.slice(r,a).indexOf(e.slice(t,n));if(i>-1)return[new kx(t,t,r,r+i),new kx(n,n,r+i+l,a)]}if(1==l||1==c)return[new kx(t,n,r,a)];let d=Ox(e,t,n,o,r,a);if(d){let[i,s,l]=d;return Sx(e,t,i,o,r,s).concat(Sx(e,i+l,n,o,s+l,a))}return function(e,t,n,o,r,a){let i=n-t,s=a-r;if(Nx<1e9&&Math.min(i,s)>16*Nx)return Math.min(i,s)>64*Nx?[new kx(t,n,r,a)]:Dx(e,t,n,o,r,a);let l=Math.ceil((i+s)/2);Ex.reset(l),jx.reset(l);let c=(n,a)=>e.charCodeAt(t+n)==o.charCodeAt(r+a),d=(t,r)=>e.charCodeAt(n-t-1)==o.charCodeAt(a-r-1),u=(i-s)%2!=0?jx:null,h=u?null:Ex;for(let f=0;f<l;f++){if(f>Nx)return Dx(e,t,n,o,r,a);let m=Ex.advance(f,i,s,l,u,!1,c)||jx.advance(f,i,s,l,h,!0,d);if(m)return _x(e,t,n,t+m[0],o,r,a,r+m[1])}return[new kx(t,n,r,a)]}(e,t,n,o,r,a)}let Nx=1e9;class Cx{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let t=0;t<this.len;t++)this.vec[t]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,t,n,o,r,a,i){for(let s=-e+this.start;s<=e-this.end;s+=2){let l=o+s,c=s==-e||s!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-s;for(;c<t&&d<n&&i(c,d);)c++,d++;if(this.vec[l]=c,c>t)this.end+=2;else if(d>n)this.start+=2;else if(r){let e=o+(t-n)-s;if(e>=0&&e<this.len&&-1!=r.vec[e])if(a){let n=r.vec[e];if(n>=t-c)return[n,o+n-e]}else{if(c>=t-r.vec[e])return[c,d]}}}return null}}const Ex=new Cx,jx=new Cx;function _x(e,t,n,o,r,a,i,s){let l=!1;return Wx(e,o)||++o!=n||(l=!0),Wx(r,s)||++s!=i||(l=!0),l?[new kx(t,n,a,i)]:Sx(e,t,o,r,a,s).concat(Sx(e,o,n,r,s,i))}function Ix(e,t){let n=1,o=Math.min(e,t);for(;n<o;)n<<=1;return n}function Ax(e,t,n,o,r,a){if(t==n||t==a||e.charCodeAt(t)!=o.charCodeAt(r))return 0;let i=Ix(n-t,a-r);for(let s=t,l=r;;){let r=s+i,c=l+i;if(r>n||c>a||e.slice(s,r)!=o.slice(l,c)){if(1==i)return s-t-(Wx(e,s)?0:1);i>>=1}else{if(r==n||c==a)return r-t;s=r,l=c}}}function Tx(e,t,n,o,r,a){if(t==n||r==a||e.charCodeAt(n-1)!=o.charCodeAt(a-1))return 0;let i=Ix(n-t,a-r);for(let s=n,l=a;;){let a=s-i,c=l-i;if(a<t||c<r||e.slice(a,s)!=o.slice(c,l)){if(1==i)return n-s-(Wx(e,s)?0:1);i>>=1}else{if(a==t||c==r)return n-a;s=a,l=c}}}function Mx(e,t,n,o,r,a,i,s){let l=o.slice(r,a),c=null;for(;;){if(c||i<s)return c;for(let s=t+i;;){Wx(e,s)||s++;let d=s+i;if(Wx(e,d)||(d+=d==s+1?1:-1),d>=n)break;let u=e.slice(s,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let i=Ax(e,d,n,o,r+h+u.length,a),l=Tx(e,t,s,o,r,r+h),f=u.length+i+l;(!c||c[2]<f)&&(c=[s-l,r+h-l,f])}s=d}if(s<0)return c;i>>=1}}function Ox(e,t,n,o,r,a){let i=n-t,s=a-r;if(i<s){let i=Ox(o,r,a,e,t,n);return i&&[i[1],i[0],i[2]]}return i<4||2*s<i?null:Mx(e,t,n,o,r,a,Math.floor(i/4),-1)}function Dx(e,t,n,o,r,a){let i,s=n-t,l=a-r;if(s<l){let l=Mx(o,r,a,e,t,n,Math.floor(s/6),50);i=l&&[l[1],l[0],l[2]]}else i=Mx(e,t,n,o,r,a,Math.floor(l/6),50);if(!i)return[new kx(t,n,r,a)];let[c,d,u]=i;return Sx(e,t,c,o,r,d).concat(Sx(e,c+u,n,o,d+u,a))}function Px(e,t){for(let n=1;n<e.length;n++){let o=e[n-1],r=e[n];o.toA>r.fromA-t&&o.toB>r.fromB-t&&(e[n-1]=new kx(o.fromA,r.toA,o.fromB,r.toB),e.splice(n--,1))}}let Rx;try{Rx=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(nF){}function Lx(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function zx(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?Lx(n)?1:0:Rx?Hx(n)&&t!=e.length-1?Rx.test(e.slice(t,t+2))?2:0:Rx.test(String.fromCharCode(n))?1:0:0}function Fx(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?Lx(n)?1:0:Rx?$x(n)&&1!=t?Rx.test(e.slice(t-2,t))?2:0:Rx.test(String.fromCharCode(n))?1:0:0}function Bx(e,t,n){if(t==e.length||!Fx(e,t))return t;for(let o=t,r=t+n;;){let n=zx(e,o);if(!n)return o;if(o+=n,o>r)return t}}function Ux(e,t,n){if(!t||!zx(e,t))return t;for(let o=t,r=t-n;;){let n=Fx(e,o);if(!n)return o;if(o-=n,o<r)return t}}function Vx(e,t,n){for(let o=t,r=t-n;;){let n=o?e.charCodeAt(o-1):10;if(10==n)return o;if(o--,o<r||32!=n&&9!=n)return t}}const Hx=e=>e>=55296&&e<=56319,$x=e=>e>=56320&&e<=57343;function Wx(e,t){return!t||t==e.length||!Hx(e.charCodeAt(t-1))||!$x(e.charCodeAt(t))}function Gx(e,t,n){var o;return Nx=(null!==(o=null==n?void 0:n.scanLimit)&&void 0!==o?o:1e9)>>1,function(e,t,n){for(;;){Px(n,1);let o=!1;for(let r=0;r<n.length;r++){let a,i,s=n[r];(a=Ax(e,s.fromA,s.toA,t,s.fromB,s.toB))&&(s=n[r]=new kx(s.fromA+a,s.toA,s.fromB+a,s.toB)),(i=Tx(e,s.fromA,s.toA,t,s.fromB,s.toB))&&(s=n[r]=new kx(s.fromA,s.toA-i,s.fromB,s.toB-i));let l=s.toA-s.fromA,c=s.toB-s.fromB;if(l&&c)continue;let d=s.fromA-(r?n[r-1].toA:0),u=(r<n.length-1?n[r+1].fromA:e.length)-s.toA;if(!d||!u)continue;let h=l?e.slice(s.fromA,s.toA):t.slice(s.fromB,s.toB);d<=h.length&&e.slice(s.fromA-d,s.fromA)==h.slice(h.length-d)?(n[r]=new kx(s.fromA-d,s.toA-d,s.fromB-d,s.toB-d),o=!0):u<=h.length&&e.slice(s.toA,s.toA+u)==h.slice(0,u)&&(n[r]=new kx(s.fromA+u,s.toA+u,s.fromB+u,s.toB+u),o=!0)}if(!o)break}return n}(e,t,Sx(e,0,e.length,t,0,t.length))}function qx(e,t,n){return function(e,t,n){for(let o=0,r=0;r<e.length;r++){let a=e[r],i=a.toA-a.fromA,s=a.toB-a.fromB;if(i&&s||i>3||s>3){let l=r==e.length-1?t.length:e[r+1].fromA,c=a.fromA-o,d=l-a.toA,u=Ux(t,a.fromA,Math.min(c,5)),h=Bx(t,a.toA,Math.min(d,5)),f=a.fromA-u,m=h-a.toA;if(!i||!s){let d,p,g=Math.max(i,s),[v,y,x]=i?[t,a.fromA,a.toA]:[n,a.fromB,a.toB];f&&m?(g>f&&t.slice(u,a.fromA)==v.slice(x-f,x)?(a=e[r]=new kx(u,u+i,a.fromB-f,a.toB-f),u=a.fromA,h=Bx(t,a.toA,Math.min(l-a.toA,5))):g>m&&t.slice(a.toA,h)==v.slice(y,y+m)&&(a=e[r]=new kx(h-i,h,a.fromB+m,a.toB+m),h=a.toA,u=Ux(t,a.fromA,Math.min(a.fromA-o,5))),f=a.fromA-u,m=h-a.toA):f||m||!(p=a.fromA-(d=Vx(t,a.fromA,c)))||t.slice(d,a.fromA)!=v.slice(x-p,x)||(a=e[r]=new kx(d,d+i,a.fromB-p,a.toB-p))}(f||m)&&(a=e[r]=new kx(a.fromA-f,a.toA+m,a.fromB-f,a.toB+m)),o=a.toA}}return Px(e,3),e}(Gx(e,t,n),e,t)}const Yx=bn.define({combine:e=>e[0]}),Xx=Xt.define(),Kx=Kt.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(Xx)&&(e=n.value);return e}});class Jx{constructor(e,t,n,o,r){this.changes=e,this.fromA=t,this.toA=n,this.fromB=o,this.toB=r}offset(e,t){return e||t?new Jx(this.changes,this.fromA+e,this.toA+e,this.fromB+t,this.toB+t):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,t,n){return eb(qx(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,o,r){return rb(ob(e,o,!0,n.length),e,t,n,r)}static updateB(e,t,n,o,r){return rb(ob(e,o,!1,t.length),e,t,n,r)}}function Zx(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.to==e&&a.to==t&&e<n.length&&t<o.length?[e+1,t+1]:[r.from,a.from]}function Qx(e,t,n,o){let r=n.lineAt(e),a=o.lineAt(t);return r.from==e&&a.from==t?[e,t]:[r.to+1,a.to+1]}function eb(e,t,n,o,r){let a=[];for(let i=0;i<e.length;i++){let s=e[i],[l,c]=Zx(s.fromA+o,s.fromB+r,t,n),[d,u]=Qx(s.toA+o,s.toB+r,t,n),h=[s.offset(-l+o,-c+r)];for(;i<e.length-1;){let a=e[i+1],[s,f]=Zx(a.fromA+o,a.fromB+r,t,n);if(s>d+1&&f>u+1)break;h.push(a.offset(-l+o,-c+r)),[d,u]=Qx(a.toA+o,a.toB+r,t,n),i++}a.push(new Jx(h,l,Math.max(l,d),c,Math.max(c,u)))}return a}const tb=1e3;function nb(e,t,n,o){let r=0,a=e.length;for(;;){if(r==a){let o=0,a=0;r&&({toA:o,toB:a}=e[r-1]);let i=t-(n?o:a);return[o+i,a+i]}let i=r+a>>1,s=e[i],[l,c]=n?[s.fromA,s.toA]:[s.fromB,s.toB];if(l>t)a=i;else{if(!(c<=t))return o?[s.fromA,s.fromB]:[s.toA,s.toB];r=i+1}}}function ob(e,t,n,o){let r=[];return t.iterChangedRanges(((a,i,s,l)=>{let c=0,d=n?t.length:o,u=0,h=n?o:t.length;a>tb&&([c,u]=nb(e,a-tb,n,!0)),i<t.length-tb&&([d,h]=nb(e,i+tb,n,!1));let f,m=l-s-(i-a),[p,g]=n?[m,0]:[0,m];r.length&&(f=r[r.length-1]).toA>=c?r[r.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+p,diffB:f.diffB+g}:r.push({fromA:c,toA:d,fromB:u,toB:h,diffA:p,diffB:g})})),r}function rb(e,t,n,o,r){if(!e.length)return t;let a=0,i=0,s=0,l=[];for(let c of e){let e=c.fromA+i,d=c.toA+i+c.diffA,u=c.fromB+s,h=c.toB+s+c.diffB;for(;a<t.length;){let n=t[a];if(n.toA+i<=e&&n.toB+s<=u)l.push(n.offset(i,s));else if(n.fromA+i>d)break;a++}for(let t of eb(qx(n.sliceString(e,d),o.sliceString(u,h),r),n,o,e,u))l.push(t);for(i+=c.diffA,s+=c.diffB;a<t.length;){let e=t[a];if(e.fromA>d+i&&e.fromB>h+s)break;a++}}for(;a<t.length;)l.push(t[a++].offset(i,s));return l}const ab=Zt.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=fb(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(Kx,!1)!=n.field(Kx,!1))||function(e,t){return e.facet(Yx)!=t.facet(Yx)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=fb(e.view))}},{decorations:e=>e.deco}),ib=yn.low(jr({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(ab))||void 0===t?void 0:t.gutter)||_r.empty}}));const sb=Jt.line({class:"cm-changedLine"}),lb=Jt.mark({class:"cm-changedText"}),cb=Jt.mark({tagName:"ins",class:"cm-insertedLine"}),db=Jt.mark({tagName:"del",class:"cm-deletedLine"}),ub=new class extends Tr{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function hb(e,t,n,o,r,a){let i=n?e.fromA:e.fromB,s=n?e.toA:e.toB,l=0;if(i!=s){r.add(i,i,sb),r.add(i,s,n?db:cb),a&&a.add(i,i,ub);for(let c=t.iterRange(i,s-1),d=i;!c.next().done;){if(c.lineBreak){d++,r.add(d,d,sb),a&&a.add(d,d,ub);continue}let t=d+c.value.length;if(o)for(;l<e.changes.length;){let o=e.changes[l],a=i+(n?o.fromA:o.fromB),s=i+(n?o.toA:o.toB),c=Math.max(d,a),u=Math.min(t,s);if(c<u&&r.add(c,u,lb),!(s<t))break;l++}d=t}}}function fb(e){let t=e.state.field(Kx),{side:n,highlightChanges:o,markGutter:r}=e.state.facet(Yx),a="a"==n,i=new Qt,s=r?new Qt:null,{from:l,to:c}=e.viewport;for(let d of t){if((a?d.fromA:d.fromB)>=c)break;(a?d.toA:d.toB)>l&&hb(d,e.state.doc,a,o,i,s)}return{deco:i.finish(),gutter:s&&s.finish()}}class mb extends xn{constructor(e){super(),this.height=e}eq(e){return this.height==e.height}toDOM(){let e=document.createElement("div");return e.className="cm-mergeSpacer",e.style.height=this.height+"px",e}updateDOM(e){return e.style.height=this.height+"px",!0}get estimatedHeight(){return this.height}ignoreEvent(){return!1}}const pb=Xt.define({map:(e,t)=>e.map(t)}),gb=Kt.define({create:()=>Jt.none,update:(e,t)=>{for(let n of t.effects)if(n.is(pb))return n.value;return e.map(t.changes)},provide:e=>Yt.decorations.from(e)}),vb=.01;const yb=Xt.define({map:(e,t)=>t.mapPos(e)});class xb extends xn{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let t=document.createElement("div");return t.className="cm-collapsedLines",t.textContent="⦚ "+e.state.phrase("$ unchanged lines",this.lines)+" ⦚",t.addEventListener("click",(t=>{let n=e.posAtDOM(t.target);e.dispatch({effects:yb.of(n)});let{side:o,sibling:r}=e.state.facet(Yx);r&&r().dispatch({effects:yb.of(bb(n,e.state.field(Kx),"a"==o))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function bb(e,t,n){let o=0,r=0;for(let a=0;;a++){let i=a<t.length?t[a]:null;if(!i||(n?i.fromA:i.fromB)>=e)return r+(e-o);[o,r]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const wb=Kt.define({create:e=>Jt.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(yb)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>Yt.decorations.from(e)});function kb({margin:e=3,minSize:t=4}){return wb.init((n=>function(e,t,n){let o=new Qt,r="a"==e.facet(Yx).side,a=e.field(Kx),i=1;for(let s=0;;s++){let l=s<a.length?a[s]:null,c=s?i+t:1,d=l?e.doc.lineAt(r?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&o.add(e.doc.line(c).from,e.doc.line(d).to,Jt.replace({widget:new xb(u),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,r?l.toA:l.toB)).number}return o.finish()}(n,e,t)))}const Sb=Yt.styleModule.of(new Ir({".cm-mergeView":{overflowY:"auto"},".cm-mergeViewEditors":{display:"flex",alignItems:"stretch"},".cm-mergeViewEditor":{flexGrow:1,flexBasis:0,overflow:"hidden"},".cm-merge-revert":{width:"1.6em",flexGrow:0,flexShrink:0,position:"relative"},".cm-merge-revert button":{position:"absolute",display:"block",width:"100%",boxSizing:"border-box",textAlign:"center",background:"none",border:"none",font:"inherit",cursor:"pointer"}})),Nb=Yt.baseTheme({".cm-mergeView & .cm-scroller, .cm-mergeView &":{height:"auto !important",overflowY:"visible !important"},"&.cm-merge-a .cm-changedLine, .cm-deletedChunk":{backgroundColor:"rgba(160, 128, 100, .08)"},"&.cm-merge-b .cm-changedLine":{backgroundColor:"rgba(100, 160, 128, .08)"},"&light.cm-merge-a .cm-changedText, &light .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ee443366, #ee443366) bottom/100% 2px no-repeat"},"&dark.cm-merge-a .cm-changedText, &dark .cm-deletedChunk .cm-deletedText":{background:"linear-gradient(#ffaa9966, #ffaa9966) bottom/100% 2px no-repeat"},"&light.cm-merge-b .cm-changedText":{background:"linear-gradient(#22bb2266, #22bb2266) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff8866, #88ff8866) bottom/100% 2px no-repeat"},".cm-insertedLine, .cm-deletedLine":{textDecoration:"none"},".cm-deletedChunk":{paddingLeft:"6px","& .cm-chunkButtons":{position:"absolute",insetInlineEnd:"5px"},"& button":{border:"none",cursor:"pointer",color:"white",margin:"0 2px",borderRadius:"3px","&[name=accept]":{background:"#2a2"},"&[name=reject]":{background:"#d43"}}},".cm-collapsedLines":{padding:"5px 5px 5px 10px",cursor:"pointer"},"&light .cm-collapsedLines":{color:"#444",background:"linear-gradient(to bottom, transparent 0, #f3f3f3 30%, #f3f3f3 70%, transparent 100%)"},"&dark .cm-collapsedLines":{color:"#ddd",background:"linear-gradient(to bottom, transparent 0, #222 30%, #222 70%, transparent 100%)"},".cm-changeGutter":{width:"3px",paddingLeft:"1px"},"&light.cm-merge-a .cm-changedLineGutter, &light .cm-deletedLineGutter":{background:"#e43"},"&dark.cm-merge-a .cm-changedLineGutter, &dark .cm-deletedLineGutter":{background:"#fa9"},"&light.cm-merge-b .cm-changedLineGutter":{background:"#2b2"},"&dark.cm-merge-b .cm-changedLineGutter":{background:"#8f8"}}),Cb=new Ar,Eb=new Ar;class jb{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[yn.low(ab),Nb,Sb,gb,Yt.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(pb)))))&&this.measure()}))],n=[Yx.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(ib);let o=ro.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Yt.editorAttributes.of({class:"cm-merge-a"}),Eb.of(n),t]}),r=[Yx.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&r.push(ib);let a=ro.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Yt.editorAttributes.of({class:"cm-merge-b"}),Eb.of(r),t]});this.chunks=Jx.build(o.doc,a.doc,this.diffConf);let i=[Kx.init((()=>this.chunks)),Cb.of(e.collapseUnchanged?kb(e.collapseUnchanged):[])];o=o.update({effects:Xt.appendConfig.of(i)}).state,a=a.update({effects:Xt.appendConfig.of(i)}).state,this.dom=document.createElement("div"),this.dom.className="cm-mergeView",this.editorDOM=this.dom.appendChild(document.createElement("div")),this.editorDOM.className="cm-mergeViewEditors";let s=e.orientation||"a-b",l=document.createElement("div");l.className="cm-mergeViewEditor";let c=document.createElement("div");c.className="cm-mergeViewEditor",this.editorDOM.appendChild("a-b"==s?l:c),this.editorDOM.appendChild("a-b"==s?c:l),this.a=new Yt({state:o,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new Yt({state:a,parent:c,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.b)}),this.setupRevertControls(!!e.revertControls,"b-to-a"==e.revertControls,e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,t){if(e.some((e=>e.docChanged))){let n=e[e.length-1],o=e.reduce(((e,t)=>e.compose(t.changes)),Nn.empty(e[0].startState.doc.length));this.chunks=t==this.a?Jx.updateA(this.chunks,n.newDoc,this.b.state.doc,o,this.diffConf):Jx.updateB(this.chunks,this.a.state.doc,n.newDoc,o,this.diffConf),t.update([...e,n.state.update({effects:Xx.of(this.chunks)})]);let r=t==this.a?this.b:this.a;r.update([r.state.update({effects:Xx.of(this.chunks)})]),this.scheduleMeasure()}else t.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let t="b-a"!=e.orientation;if(t!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let e=this.a.dom.parentNode,n=this.b.dom.parentNode;e.remove(),n.remove(),this.editorDOM.insertBefore(t?e:n,this.editorDOM.firstChild),this.editorDOM.appendChild(t?n:e),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let t=!!this.revertDOM,n=this.revertToA,o=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(o=e.renderRevertControl),this.setupRevertControls(t,n,o)}let t="highlightChanges"in e,n="gutter"in e,o="collapseUnchanged"in e;if(t||n||o){let r=[],a=[];if(t||n){let o=this.a.state.facet(Yx),i=n?!1!==e.gutter:o.markGutter,s=t?!1!==e.highlightChanges:o.highlightChanges;r.push(Eb.reconfigure([Yx.of({side:"a",sibling:()=>this.b,highlightChanges:s,markGutter:i}),i?ib:[]])),a.push(Eb.reconfigure([Yx.of({side:"b",sibling:()=>this.a,highlightChanges:s,markGutter:i}),i?ib:[]]))}if(o){let t=Cb.reconfigure(e.collapseUnchanged?kb(e.collapseUnchanged):[]);r.push(t),a.push(t)}this.a.dispatch({effects:r}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,t,n){this.revertToA=t,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=n,!e&&this.revertDOM?(this.revertDOM.remove(),this.revertDOM=null):e&&!this.revertDOM?(this.revertDOM=this.editorDOM.insertBefore(document.createElement("div"),this.editorDOM.firstChild.nextSibling),this.revertDOM.addEventListener("mousedown",(e=>this.revertClicked(e))),this.revertDOM.className="cm-merge-revert"):this.revertDOM&&(this.revertDOM.textContent="")}scheduleMeasure(){if(this.measuring<0){let e=this.dom.ownerDocument.defaultView||window;this.measuring=e.requestAnimationFrame((()=>{this.measuring=-1,this.measure()}))}}measure(){!function(e,t,n){let o=new Qt,r=new Qt,a=e.state.field(gb).iter(),i=t.state.field(gb).iter(),s=0,l=0,c=0,d=0;for(let m=0;;m++){let u=m<n.length?n[m]:null;if(s<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(s).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,o.add(s,s,Jt.widget({widget:new mb(-n),block:!0,side:-1}))):n>vb&&(d+=n,r.add(l,l,Jt.widget({widget:new mb(n),block:!0,side:-1})))}if(!u)break;for(s=u.toA,l=u.toB;a.value&&a.from<s;)c-=a.value.spec.widget.height,a.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;a.value;)c-=a.value.spec.widget.height,a.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let u=e.contentHeight+c-(t.contentHeight+d);u<vb?o.add(e.state.doc.length,e.state.doc.length,Jt.widget({widget:new mb(-u),block:!0,side:1})):u>vb&&r.add(t.state.doc.length,t.state.doc.length,Jt.widget({widget:new mb(u),block:!0,side:1}));let h=o.finish(),f=r.finish();_r.eq([h],[e.state.field(gb)])||e.dispatch({effects:pb.of(h)}),_r.eq([f],[t.state.field(gb)])||t.dispatch({effects:pb.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,o=this.b.viewport;for(let r=0;r<this.chunks.length;r++){let a=this.chunks[r];if(a.fromA>n.to||a.fromB>o.to)break;if(a.fromA<n.from||a.fromB<o.from)continue;let i=this.a.lineBlockAt(a.fromA).top+"px";for(;t&&+t.dataset.chunk<r;)t=_b(t);t&&t.dataset.chunk==String(r)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,r),t)}for(;t;)t=_b(t)}renderRevertButton(e,t){let n;if(this.renderRevert)n=this.renderRevert();else{n=document.createElement("button");let e=this.a.state.phrase("Revert this chunk");n.setAttribute("aria-label",e),n.setAttribute("title",e),n.textContent=this.revertToLeft?"⇜":"⇝"}return n.style.top=e,n.setAttribute("data-chunk",String(t)),n}revertClicked(e){let t,n=e.target;for(;n&&n.parentNode!=this.revertDOM;)n=n.parentNode;if(n&&(t=this.chunks[n.dataset.chunk])){let[n,o,r,a,i,s]=this.revertToA?[this.b,this.a,t.fromB,t.toB,t.fromA,t.toA]:[this.a,this.b,t.fromA,t.toA,t.fromB,t.toB],l=n.state.sliceDoc(r,Math.max(r,a-1));r!=a&&s<=o.state.doc.length&&(l+=n.state.lineBreak),o.dispatch({changes:{from:i,to:Math.min(o.state.doc.length,s),insert:l},userEvent:"revert"}),e.preventDefault()}}destroy(){this.a.destroy(),this.b.destroy(),this.measuring>-1&&(this.dom.ownerDocument.defaultView||window).cancelAnimationFrame(this.measuring),this.dom.remove()}}function _b(e){let t=e.nextSibling;return e.remove(),t}var Ib=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl"],Ab=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],Tb=u.forwardRef(((e,t)=>{var{className:n,children:o,orientation:a,revertControls:i,highlightChanges:s,gutter:l,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u}=e,h=Cr(e,Ib),f=gx(),{modified:m,modifiedExtension:p,original:g,originalExtension:v,theme:y,dispatch:x}=f,b=Cr(f,Ab),w=r.useRef(null),S=r.useRef(),N={orientation:a,revertControls:i,highlightChanges:s,gutter:l,collapseUnchanged:c,renderRevertControl:u};r.useImperativeHandle(t,(()=>({container:w.current,view:S.current,modified:m,original:g,config:mo({a:g,b:m,parent:w.current},N)})),[w,S,m,g,N]);var C=Yt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==v?void 0:v.onChange)){var t=e.state.doc.toString();null==v||v.onChange(t,e)}})),E=Yt.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==p?void 0:p.onChange)){var t=e.state.doc.toString();null==p||p.onChange(t,e)}}));r.useEffect((()=>{!S.current&&w.current&&v&&p&&(S.current=new jb(mo({a:mo({},g,{extensions:[...(null==v?void 0:v.extension)||[],...Er(mo({},null==v?void 0:v.option,{theme:y})),C]}),b:mo({},m,{extensions:[...(null==p?void 0:p.extension)||[],...Er(mo({},null==p?void 0:p.option,{theme:y})),E]}),parent:w.current},N)),x({view:S.current}))}),[S,w,v,p]),r.useEffect((()=>{if(g&&g.doc&&S.current){var e,t,n=null==(e=S.current)?void 0:e.a.state.doc.toString();if(n!==g.doc)null==(t=S.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:g.doc||""}})}if(m&&m.doc&&S.current){var o,r,a=null==(o=S.current)?void 0:o.b.state.doc.toString();if(a!==m.doc)null==(r=S.current)||r.b.dispatch({changes:{from:0,to:a.length,insert:m.doc||""}})}if(d&&S.current){var i=S.current.a.state.selection.ranges[0].from,s=S.current.b.state.selection.ranges[0].from;S.current.destroy(),S.current=new jb(mo({a:mo({},g,{extensions:[...(null==v?void 0:v.extension)||[],...Er(mo({},null==v?void 0:v.option,{theme:y}))]}),b:mo({},m,{extensions:[...(null==p?void 0:p.extension)||[],...Er(mo({},null==p?void 0:p.option,{theme:y}))]}),parent:w.current},N)),i&&(S.current.a.focus(),S.current.a.dispatch({selection:{anchor:i,head:i}})),s&&(S.current.b.focus(),S.current.b.dispatch({selection:{anchor:s,head:s}}))}}),[S,y,w.current,g,m,v,p,d]),r.useEffect((()=>()=>S.current&&S.current.destroy()),[]),r.useEffect((()=>{if(S.current){var e={};b.orientation!==a&&(e.orientation=a),b.revertControls!==i&&(e.revertControls=i),b.highlightChanges!==s&&(e.highlightChanges=s),b.gutter!==l&&(e.gutter=l),b.collapseUnchanged!==c&&(e.collapseUnchanged=c),b.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&x&&S.current&&(S.current.reconfigure(mo({},e)),x(mo({},e)))}}),[x,S,a,i,s,l,c,u]);return k.jsx("div",mo({ref:w,className:"cm-merge-theme"+(n?" "+n:"")},h,{children:o}))}));Tb.displayName="CodeMirrorMerge.Internal";var Mb=["theme"],Ob=u.forwardRef(((e,t)=>{var{theme:n}=e,o=Cr(e,Mb);return k.jsx(vx,{theme:n,children:k.jsx(Tb,mo({},o,{ref:t}))})}));function Db(e){return void 0===e&&(e=[]),Mr({override:[t=>{var n=t.matchBefore(/@(\w+)?/);return n?n&&n.from==n.to&&!t.explicit?null:{from:null==n?void 0:n.from,options:[...e]}:null}]})}function Pb(e){const t=function(e){const t=te.get(Or),n=Dr.keyBy(t,(e=>e.name)),o=e.match(/@([\w.]+)/g)||[];return o.map((e=>e.slice(1))).map((e=>n.get(e))).filter(Boolean)}(e);return J.debug("Included datasets",t),{includeOtherCode:zs(""),context:{schema:t.map((e=>({name:e.name,columns:e.columns.map((e=>({name:e.name,type:e.type})))})))}}}Ob.Original=xx,Ob.Modified=wx,Ob.displayName="CodeMirrorMerge",Db();const Rb=[Pr(),Yt.lineWrapping],Lb=[Rr(),Yt.lineWrapping],zb=Lr("marimo:ai-language","python"),Fb=e=>{const t=b(65),{onClose:n}=e,{createNewCell:o}=q();let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a={},t[0]=a):a=t[0];const[i,s]=r.useState(a),[l,c]=Le(zb),{theme:d}=Me();let u,h,f;t[1]===Symbol.for("react.memo_cache_sentinel")?(u=zr("api/ai/completion").toString(),h=Fr.headers(),t[1]=u,t[2]=h):(u=t[1],h=t[2]),t[3]!==i||t[4]!==l?(f={api:u,headers:h,streamMode:"text",body:{...i,language:l,code:""},onError:Ub},t[3]=i,t[4]=l,t[5]=f):f=t[5];const{completion:m,input:p,stop:g,isLoading:v,setCompletion:y,setInput:x,handleSubmit:w}=Br(f);let S;t[6]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Fc,{className:"size-4 text-[var(--blue-11)]"}),t[6]=S):S=t[6];const N="python"===l?"Python":"SQL";let E,j,_,I,A,T,M,O,D,P,R,L,z,F,B;t[7]===Symbol.for("react.memo_cache_sentinel")?(E=k.jsx(Hr,{className:"ml-1 h-3.5 w-3.5 text-muted-foreground/70"}),t[7]=E):E=t[7],t[8]!==N?(j=k.jsx(Dt,{asChild:!0,children:k.jsxs(C,{variant:"text",className:"ml-2",size:"xs","data-testid":"language-button",children:[N,E]})}),t[8]=N,t[9]=j):j=t[9],t[10]!==c?(_=k.jsx(Ot,{onClick:()=>c("python"),children:"Python"}),t[10]=c,t[11]=_):_=t[11],t[12]!==c?(I=k.jsx(Ot,{onClick:()=>c("sql"),children:"SQL"}),t[12]=c,t[13]=I):I=t[13],t[14]!==_||t[15]!==I?(A=k.jsxs(Ut,{align:"center",children:[_,I]}),t[14]=_,t[15]=I,t[16]=A):A=t[16],t[17]!==j||t[18]!==A?(T=k.jsxs(Bt,{modal:!1,children:[j,A]}),t[17]=j,t[18]=A,t[19]=T):T=t[19],t[20]!==y||t[21]!==n?(M=()=>{y(""),n()},t[20]=y,t[21]=n,t[22]=M):M=t[22],t[23]!==x?(O=e=>{x(e),s(Pb(e))},t[23]=x,t[24]=O):O=t[24],t[25]!==v||t[26]!==w?(D=()=>{v||w()},t[25]=v,t[26]=w,t[27]=D):D=t[27],t[28]!==d||t[29]!==M||t[30]!==p||t[31]!==O||t[32]!==D?(P=k.jsx(Bb,{theme:d,onClose:M,value:p,onChange:O,onSubmit:D}),t[28]=d,t[29]=M,t[30]=p,t[31]=O,t[32]=D,t[33]=P):P=t[33],t[34]!==v||t[35]!==g?(R=v&&k.jsxs(C,{"data-testid":"stop-completion-button",variant:"text",size:"sm",className:"mb-0",onClick:g,children:[k.jsx($r,{className:"animate-spin mr-1",size:14}),"Stop"]}),t[34]=v,t[35]=g,t[36]=R):R=t[36],t[37]!==v||t[38]!==m||t[39]!==o||t[40]!==l||t[41]!==y||t[42]!==n?(L=!v&&m&&k.jsx(C,{"data-testid":"accept-completion-button",variant:"text",size:"sm",className:"mb-0",disabled:v,onClick:()=>{o({cellId:"__end__",before:!1,code:"python"===l?m:Vo.fromQuery(m)}),y(""),n()},children:k.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),t[37]=v,t[38]=m,t[39]=o,t[40]=l,t[41]=y,t[42]=n,t[43]=L):L=t[43],t[44]===Symbol.for("react.memo_cache_sentinel")?(z=k.jsx(tn,{className:"size-4"}),t[44]=z):z=t[44],t[45]!==n?(F=k.jsx(C,{variant:"text",size:"sm",className:"mb-0",onClick:n,children:z}),t[45]=n,t[46]=F):F=t[46],t[47]!==T||t[48]!==P||t[49]!==R||t[50]!==L||t[51]!==F?(B=k.jsxs("div",{className:"flex items-center px-3",children:[S,T,P,R,L,F]}),t[47]=T,t[48]=P,t[49]=R,t[50]=L,t[51]=F,t[52]=B):B=t[52];const U=B;let V,H,$,W;return t[53]===Symbol.for("react.memo_cache_sentinel")?(V=rn("flex flex-col w-full gap-2 py-2"),t[53]=V):V=t[53],t[54]!==m?(H=!m&&k.jsxs("span",{className:"text-xs text-muted-foreground px-3 flex flex-col gap-1",children:[k.jsxs("span",{children:["You can mention"," ",k.jsx("span",{className:"text-[var(--cyan-11)]",children:"@dataframe"})," or"," ",k.jsx("span",{className:"text-[var(--cyan-11)]",children:"@sql_table"})," to pull additional context such as column names."]}),k.jsx("span",{children:"Code from other cells is automatically included."})]}),t[54]=m,t[55]=H):H=t[55],t[56]!==m||t[57]!==d||t[58]!==l||t[59]!==y?($=m&&k.jsx(Wr,{value:m,className:"cm border-t",onChange:y,theme:"dark"===d?"dark":"light",extensions:"python"===l?Rb:Lb}),t[56]=m,t[57]=d,t[58]=l,t[59]=y,t[60]=$):$=t[60],t[61]!==U||t[62]!==H||t[63]!==$?(W=k.jsxs("div",{className:V,children:[U,H,$]}),t[61]=U,t[62]=H,t[63]=$,t[64]=W):W=t[64],W},Bb=e=>{const t=b(24),{value:n,placeholder:o,inputRef:r,className:a,onChange:i,onSubmit:s,onClose:l,theme:c}=e,d=s,u=l,h=le(Or);let f,m,p,g,v,y,x,w;if(t[0]!==h){let e;t[2]===Symbol.for("react.memo_cache_sentinel")?(e=e=>({label:`@${e.name}`,info:()=>{const t=[null==e.num_rows?void 0:`${e.num_rows} rows`,null==e.num_columns?void 0:`${e.num_columns} columns`].filter(Boolean).join(", "),n=document.createElement("div");if(n.classList.add("prose","prose-sm","dark:prose-invert"),t){const e=document.createElement("div");e.textContent=t,e.style.fontWeight="bold",n.append(e)}if(e.source){const t=document.createElement("figcaption");t.textContent=`Source: ${e.source}`,n.append(t)}if(e.columns){const t=document.createElement("table"),o=t.insertRow(),r=o.insertCell();r.textContent="Column",r.style.fontWeight="bold";const a=o.insertCell();a.textContent="Type",a.style.fontWeight="bold",e.columns.forEach((e=>{const n=t.insertRow();n.insertCell().textContent=e.name;n.insertCell().textContent=e.type})),n.append(t)}return n}}),t[2]=e):e=t[2];m=Db(h.map(e)),t[0]=h,t[1]=m}else m=t[1];t[3]===Symbol.for("react.memo_cache_sentinel")?(p=Ur(),t[3]=p):p=t[3],t[4]!==d?(g=yn.highest(pn.of([{preventDefault:!0,stopPropagation:!0,any:(e,t)=>{const n=t.metaKey||t.ctrlKey||t.shiftKey;if("Enter"===t.key&&!n)return d(t,e.state.doc.toString()),t.preventDefault(),t.stopPropagation(),!0;if("Enter"===t.key&&t.shiftKey){const n=e.state.selection.main.from;return e.dispatch({changes:{from:n,to:n,insert:"\n"},selection:{anchor:n+1,head:n+1}}),t.preventDefault(),t.stopPropagation(),!0}return!1}}])),t[4]=d,t[5]=g):g=t[5],t[6]!==u?(v=pn.of([{key:"Escape",preventDefault:!0,stopPropagation:!0,run:()=>(u(),!0)}]),t[6]=u,t[7]=v):v=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(y=pn.of([{key:"ArrowUp",preventDefault:!0,stopPropagation:!0}]),x=pn.of([{key:"ArrowDown",preventDefault:!0,stopPropagation:!0}]),t[8]=y,t[9]=x):(y=t[8],x=t[9]),t[10]!==m||t[11]!==g||t[12]!==v?(w=[m,Yt.lineWrapping,p,g,v,y,x],t[10]=m,t[11]=g,t[12]=v,t[13]=w):w=t[13],f=w;const S=f;let N;t[14]!==a?(N=rn("flex-1 font-sans overflow-auto my-1",a),t[14]=a,t[15]=N):N=t[15];const C="dark"===c?"dark":"light",E=o||"Generate with AI";let j;return t[16]!==r||t[17]!==N||t[18]!==n||t[19]!==S||t[20]!==i||t[21]!==C||t[22]!==E?(j=k.jsx(Wr,{ref:r,className:N,autoFocus:!0,width:"100%",value:n,basicSetup:!1,extensions:S,onChange:i,theme:C,placeholder:E}),t[16]=r,t[17]=N,t[18]=n,t[19]=S,t[20]=i,t[21]=C,t[22]=E,t[23]=j):j=t[23],j};function Ub(e){re({title:"Generate with AI failed",description:Vr(e)})}const Vb=Ob.Original,Hb=Ob.Modified,$b=[Pr(),Yt.lineWrapping],Wb=e=>{const t=b(53),{onChange:n,initialPrompt:o,currentLanguageAdapter:a,currentCode:i,declineChange:s,acceptChange:l,enabled:c,children:d}=e;let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h={},t[0]=h):h=t[0];const[f,m]=r.useState(h),[p,g]=Le(Sd);let v,y,x,w,S;t[1]===Symbol.for("react.memo_cache_sentinel")?(v=zr("api/ai/completion").toString(),y=Fr.headers(),t[1]=v,t[2]=y):(v=t[1],y=t[2]),t[3]!==p||t[4]!==i?(x=p?zs(i):"",t[3]=p,t[4]=i,t[5]=x):x=t[5],t[6]!==f||t[7]!==x||t[8]!==i||t[9]!==a?(w={...f,includeOtherCode:x,code:i,language:a},t[6]=f,t[7]=x,t[8]=i,t[9]=a,t[10]=w):w=t[10],t[11]!==o||t[12]!==w?(S={api:v,headers:y,initialInput:o,streamMode:"text",body:w,onError:Gb},t[11]=o,t[12]=w,t[13]=S):S=t[13];const{completion:E,input:j,stop:_,isLoading:I,setCompletion:A,setInput:T,handleSubmit:M}=Br(S),O=u.useRef(null);let D,P,R,L;t[14]!==c?(D=()=>{const e=O.current;c&&e&&(requestAnimationFrame((()=>{var t;null==(t=e.view)||t.focus()})),Gr(O.current.view))},P=[c],t[14]=c,t[15]=D,t[16]=P):(D=t[15],P=t[16]),r.useEffect(D,P),t[17]!==c||t[18]!==T||t[19]!==o?(R=()=>{c&&T(o||"")},L=[c,o,T],t[17]=c,t[18]=T,t[19]=o,t[20]=R,t[21]=L):(R=t[20],L=t[21]),r.useEffect(R,L);const{theme:z}=Me(),F=c&&"max-h-[400px] min-h-11 visible",B=!c&&"max-h-0 min-h-0 invisible";let U,V,H,$;t[22]!==F||t[23]!==B?(U=rn("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",F,B),t[22]=F,t[23]=B,t[24]=U):U=t[24],t[25]!==c||t[26]!==s||t[27]!==A||t[28]!==T||t[29]!==I||t[30]!==M||t[31]!==O||t[32]!==z||t[33]!==j||t[34]!==_||t[35]!==E||t[36]!==l||t[37]!==g||t[38]!==p?(V=c&&k.jsxs(k.Fragment,{children:[k.jsx(Fc,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),k.jsx(Bb,{inputRef:O,theme:z,onClose:()=>{s(),A("")},value:j,onChange:e=>{T(e),m(Pb(e))},onSubmit:()=>{I||M()}}),I&&k.jsxs(C,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:_,children:[k.jsx($r,{className:"animate-spin mr-1",size:14}),"Stop"]}),!I&&E&&k.jsx(C,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:I,onClick:()=>{l(E),A("")},children:k.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),k.jsx("div",{className:"h-full w-px bg-border mx-2"}),k.jsx(N,{content:"Include code from other cells",children:k.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[k.jsx(qr,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:p,onCheckedChange:e=>g(Boolean(e))}),k.jsx(Ae,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),k.jsx(C,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:I,onClick:()=>{_(),s(),A("")},children:k.jsx(tn,{className:"text-[var(--red-10)]",size:16})})]}),t[25]=c,t[26]=s,t[27]=A,t[28]=T,t[29]=I,t[30]=M,t[31]=O,t[32]=z,t[33]=j,t[34]=_,t[35]=E,t[36]=l,t[37]=g,t[38]=p,t[39]=V):V=t[39],t[40]!==U||t[41]!==V?(H=k.jsx("div",{className:U,children:V}),t[40]=U,t[41]=V,t[42]=H):H=t[42],t[43]!==E||t[44]!==c||t[45]!==n||t[46]!==i||t[47]!==z?($=E&&c&&k.jsxs(Ob,{className:"cm",theme:z,children:[k.jsx(Vb,{onChange:n,value:i,extensions:$b}),k.jsx(Hb,{value:E,editable:!1,readOnly:!0,extensions:$b})]}),t[43]=E,t[44]=c,t[45]=n,t[46]=i,t[47]=z,t[48]=$):$=t[48];const W=(!E||!c)&&d;let G;return t[49]!==H||t[50]!==$||t[51]!==W?(G=k.jsxs("div",{className:"flex flex-col w-full rounded-[inherit] overflow-hidden",children:[H,$,W]}),t[49]=H,t[50]=$,t[51]=W,t[52]=G):G=t[52],G};function Gb(e){re({title:"Completion failed",description:Vr(e)})}const qb=u.forwardRef(((e,t)=>{const{className:n,editorView:o}=e,a=r.useRef(null);return r.useEffect((()=>{null!==o&&null!==a.current&&0===a.current.children.length&&a.current.append(o.dom)}),[o,a]),k.jsx("div",{className:rn("cm",n),ref:Ug(t,a),"data-testid":"cell-editor"})}));qb.displayName="CellCodeMirrorEditor";const Yb=r.memo((({theme:e,showPlaceholder:t,allowFocus:n,id:o,config:a,code:i,status:s,serializedEditorState:l,runCell:c,updateCellCode:d,createNewCell:u,deleteCell:h,focusCell:f,moveCell:m,moveToNextCell:p,updateCellConfig:g,clearSerializedEditorState:v,userConfig:y,editorViewRef:x,hidden:w,setTemporarilyVisible:S})=>{var N;const[C,E]=Le(kd),[j,_]=r.useState(),I=function(){const e=b(2),t=ce(Pd);let n;return e[0]!==t?(n=e=>{Te!==e&&t(e)},e[0]=t,e[1]=n):n=e[1],n}(),A=r.useRef(null),T="running"===s||"queued"===s,{sendToTop:M,sendToBottom:O}=q(),D=function(){const e=b(3),{splitCell:t,undoSplitCell:n}=q();let o;return e[0]!==t||e[1]!==n?(o=e=>{const o=Yr(e.cellId),r=(null==o?void 0:o.state.doc.toString())??"";t(e);const{dismiss:a}=re({title:"Cell split",action:k.jsx(Ed,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...e,snapshot:r}),i()},children:"Undo"})}),i=a},e[0]=t,e[1]=n,e[2]=o):o=e[2],G(o)}(),P=G((()=>!T&&(h({cellId:o}),!0))),R=r.useCallback((()=>u({cellId:o,before:!1})),[o,u]),L=r.useCallback((()=>u({cellId:o,before:!0})),[o,u]),z=r.useCallback((()=>m({cellId:o,before:!1})),[o,m]),F=r.useCallback((()=>m({cellId:o,before:!0})),[o,m]),B=r.useCallback((()=>f({cellId:o,before:!1})),[o,f]),U=r.useCallback((()=>f({cellId:o,before:!0})),[o,f]),V=G((()=>{const e=!a.hide_code;return _e({configs:{[o]:{hide_code:e}}}),g({cellId:o,config:{hide_code:e}}),e})),H=le(ue),$=G((()=>{Id(H,u)})),W=Xr(y),Y=r.useMemo((()=>{const n=(e=>{const{cellId:t,cellMovementCallbacks:n,cellCodeCallbacks:o,keymapConfig:r,hotkeys:a}=e;return[$s(r,n),[Yt.domEventHandlers({drop:(e,t)=>{var n,o;const r=null==(n=e.dataTransfer)?void 0:n.files[0];if(null==r?void 0:r.type.startsWith("text/"))return e.preventDefault(),Mn(t,r),!0;if(null==r?void 0:r.type.startsWith("image/"))return e.preventDefault(),On(t,r),!0;const a=null==(o=e.dataTransfer)?void 0:o.getData("text/plain");if(a){e.preventDefault();const n=t.posAtCoords({x:e.clientX,y:e.clientY});return null!==n&&t.dispatch({changes:{from:n,to:n,insert:a},scrollIntoView:!0}),!0}return!1},dragover:e=>{e.preventDefault()}})],Dn(t,n,a),Pn(t,o,a),tg(e),[Jp,(i=(e,t)=>{_n(e,t)},Zt.define((e=>new Zp(e,i)))),Yt.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})]];var i})({cellId:o,showPlaceholder:t,enableAI:W,cellCodeCallbacks:{updateCellCode:d,afterToggleMarkdown:$},cellMovementCallbacks:{onRun:c,deleteCell:P,createAbove:L,createBelow:R,moveUp:F,moveDown:z,focusUp:U,focusDown:B,sendToTop:M,sendToBottom:O,splitCell:D,moveToNextCell:p,toggleHideCode:V,aiCellCompletion:()=>{let e=!1;return E((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e}},completionConfig:y.completion,keymapConfig:y.keymap,theme:e,hotkeys:new Kr(y.keymap.overrides??{})});return n.push(Zt.define((e=>{const t=e.state.field(Jr);return _(t.type),{update(e){const t=e.state.field(Jr);_(t.type)}}}))),n}),[o,y.keymap,y.completion,W,e,t,L,R,U,B,F,z,p,M,O,D,V,d,P,c,E,$]);r.useEffect((()=>{let e;null===l?null===x.current?(x.current=new Yt({state:ro.create({doc:i,extensions:Y})}),e=!0,we(x.current,Zr(x.current.state).type)):(x.current.dispatch({effects:[Xt.reconfigure.of([Y]),Qr(x.current,y.completion,new Kr(y.keymap.overrides??{}))]}),e=!1):(x.current=new Yt({state:ro.fromJSON(l,{doc:i,extensions:Y},{history:ea})}),we(x.current,Zr(x.current.state).type),e=!0,v({cellId:o})),null!==x.current&&null!==A.current&&A.current.replaceChildren(x.current.dom),e&&n&&requestAnimationFrame((()=>{var e,t;null==(e=x.current)||e.focus(),null==(t=x.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[x,Y,y.completion,y.keymap,v,o,l]),r.useEffect((()=>()=>{var e;null==(e=x.current)||e.destroy()}),[x]);const X=r.useCallback((async()=>{var e,t;if(w&&void 0!==S){S(!0),null==(e=x.current)||e.focus();const n=null==(t=A.current)?void 0:t.parentElement,o=new AbortController;null==n||n.addEventListener("focusout",(()=>{requestAnimationFrame((()=>{var e;const t=document.activeElement;(null==n?void 0:n.contains(t))||(S(!1),null==(e=x.current)||e.dom.blur(),o.abort())}))}),{signal:o.signal})}}),[w,S,x,A]);return k.jsx(Wb,{enabled:(null==C?void 0:C.cellId)===o,initialPrompt:null==C?void 0:C.initialPrompt,currentCode:(null==(N=x.current)?void 0:N.state.doc.toString())??i,currentLanguageAdapter:j,declineChange:()=>{var e;E(null),null==(e=x.current)||e.focus()},onChange:e=>{var t;null==(t=x.current)||t.dispatch({changes:{from:0,to:x.current.state.doc.length,insert:e}})},acceptChange:e=>{var t,n;null==(t=x.current)||t.dispatch({changes:{from:0,to:x.current.state.doc.length,insert:e}}),null==(n=x.current)||n.focus(),E(null)},children:k.jsxs("div",{className:"relative w-full",onFocus:()=>I(o),children:[w&&k.jsx(ta,{onClick:X}),k.jsx(qb,{className:rn(w&&"opacity-20 h-8 overflow-hidden"),editorView:x.current,ref:A}),!w&&k.jsx("div",{className:"absolute top-1 right-5",children:k.jsx(ux,{code:i,editorView:x.current,currentLanguageAdapter:j,onAfterToggle:$})})]})})})),Xb=e=>{const t=b(10);let n,o,r,a;return t[0]!==e.left?(n=k.jsx("div",{className:"flex-1 flex item-center gap-2",children:e.left}),t[0]=e.left,t[1]=n):n=t[1],t[2]!==e.center?(o=k.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),t[2]=e.center,t[3]=o):o=t[3],t[4]!==e.right?(r=k.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right}),t[4]=e.right,t[5]=r):r=t[5],t[6]!==n||t[7]!==o||t[8]!==r?(a=k.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),t[6]=n,t[7]=o,t[8]=r,t[9]=a):a=t[9],a},Kb=e=>{const t=b(8);if(!e.canCollapse&&!e.isCollapsed)return null;const n=e.isCollapsed?"Expand":"Collapse";let o,r,a;return t[0]!==e.isCollapsed?(o=k.jsx(Jb,{isCollapsed:e.isCollapsed}),t[0]=e.isCollapsed,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(r=k.jsx(N,{content:n,children:o}),t[2]=n,t[3]=o,t[4]=r):r=t[4],t[5]!==e.onClick||t[6]!==r?(a=k.jsx(C,{variant:"text",size:"icon",onClick:e.onClick,children:r}),t[5]=e.onClick,t[6]=r,t[7]=a):a=t[7],a},Jb=e=>{const t=b(2),{isCollapsed:n}=e;let o;return t[0]!==n?(o=n?k.jsx(ra,{className:"w-5 h-5 flex-shrink-0"}):k.jsx(Ce,{className:"w-5 h-5 flex-shrink-0"}),t[0]=n,t[1]=o):o=t[1],o},Zb=r.memo((e=>{const t=b(24),{onClick:n,count:o,cellId:r}=e,a=W();let i;t[0]!==a||t[1]!==r?(i=na(a,r),t[0]=a,t[1]=r,t[2]=i):i=t[2];const s=i;let l,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=rn("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Hr,{className:"w-4 h-4 flex-shrink-0"}),t[4]=c):c=t[4];const d=1===o?"cell":"cells";let u,h,f,m,p,g,v;return t[5]!==o||t[6]!==d?(u=k.jsxs(k.Fragment,{children:[c,k.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",d," collapsed"]})]}),t[5]=o,t[6]=d,t[7]=u):u=t[7],t[8]!==s.errored?(h=s.errored&&k.jsx(N,{content:"Has errors",delayDuration:100,children:k.jsx(Nc,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),t[8]=s.errored,t[9]=h):h=t[9],t[10]!==s.stale?(f=s.stale&&k.jsx(N,{content:"Has stale cells",delayDuration:100,children:k.jsx(oa,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),t[10]=s.stale,t[11]=f):f=t[11],t[12]!==s.runningOrQueued?(m=s.runningOrQueued&&k.jsx(N,{content:"Running",delayDuration:100,children:k.jsx($r,{className:"w-4 h-4 flex-shrink-0 animate-spin"})}),t[12]=s.runningOrQueued,t[13]=m):m=t[13],t[14]!==h||t[15]!==f||t[16]!==m?(p=k.jsxs(k.Fragment,{children:[h,f,m]}),t[14]=h,t[15]=f,t[16]=m,t[17]=p):p=t[17],t[18]!==u||t[19]!==p?(g=k.jsx(Xb,{center:u,right:p}),t[18]=u,t[19]=p,t[20]=g):g=t[20],t[21]!==n||t[22]!==g?(v=k.jsx("div",{onClick:n,className:l,children:g}),t[21]=n,t[22]=g,t[23]=v):v=t[23],v}));Zb.displayName="CollapsedCellBanner";const Qb=e=>{const t=b(6),{appClosed:n,status:o}=e,r=Mu("running"===o);let a;t[0]===Symbol.for("react.memo_cache_sentinel")?(a=S("global.interrupt"),t[0]=a):a=t[0];const i=n||!r,s=r?aa:an.NOOP,l=r?"stale":"disabled";let c,d;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(M,{strokeWidth:1.5}),t[1]=c):c=t[1],t[2]!==i||t[3]!==s||t[4]!==l?(d=k.jsx(Ag,{tooltip:a,disabled:i,onClick:s,variant:l,"data-testid":"run-button",children:c}),t[2]=i,t[3]=s,t[4]=l,t[5]=d):d=t[5],d},ew=e=>{const t=b(26),{edited:n,appClosed:o,status:r,cellConfig:a,needsRun:i,hasOutput:s,onRun:l,cellActionDropdownRef:c,cellId:d,getEditorView:u,name:h}=e,f=!i&&"hover-action";let m;t[0]!==f?(m=rn(f),t[0]=f,t[1]=m):m=t[1];const p=o?an.NOOP:l;let g,v,y,x,w;return t[2]!==n||t[3]!==p||t[4]!==o||t[5]!==r||t[6]!==a||t[7]!==i?(g=k.jsx(Mg,{edited:n,onClick:p,appClosed:o,status:r,config:a,needsRun:i}),t[2]=n,t[3]=p,t[4]=o,t[5]=r,t[6]=a,t[7]=i,t[8]=g):g=t[8],t[9]!==r||t[10]!==o?(v=k.jsx(Qb,{status:r,appClosed:o}),t[9]=r,t[10]=o,t[11]=v):v=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(y=k.jsx(Ag,{variant:"green",tooltip:null,children:k.jsx(hl,{strokeWidth:1.5})}),t[12]=y):y=t[12],t[13]!==c||t[14]!==d||t[15]!==r||t[16]!==u||t[17]!==h||t[18]!==a||t[19]!==s?(x=k.jsx(lx,{ref:c,cellId:d,status:r,getEditorView:u,name:h,config:a,hasOutput:s,children:y}),t[13]=c,t[14]=d,t[15]=r,t[16]=u,t[17]=h,t[18]=a,t[19]=s,t[20]=x):x=t[20],t[21]!==m||t[22]!==g||t[23]!==v||t[24]!==x?(w=k.jsxs(Tg,{className:m,children:[g,v,x]}),t[21]=m,t[22]=g,t[23]=v,t[24]=x,t[25]=w):w=t[25],w},tw=r.memo(r.forwardRef((({theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,output:i,consoleOutputs:s,status:l,runStartTimestamp:c,lastRunStartTimestamp:d,runElapsedTimeMs:u,edited:h,interrupted:f,errored:m,stopped:p,staleInputs:g,serializedEditorState:v,mode:y,debuggerActive:x,appClosed:b,canDelete:w,updateCellCode:N,prepareForRun:C,createNewCell:E,deleteCell:j,focusCell:_,moveCell:I,setStdinResponse:A,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:O,sendToBottom:D,sendToTop:P,collapseCell:R,expandCell:L,userConfig:z,outline:F,isCollapsed:B,collapseCount:U,config:V,canMoveX:H,name:$},W)=>{J.debug("Rendering Cell",o);const q=r.useRef(null),Y=r.useRef(null),Z=r.useRef(null),Q=ce(kd),[ee,te]=r.useState(!1),ne=V.disabled||"disabled-transitively"===l,oe=ia(z.runtime.auto_instantiate,u,l,m,f,p),re=oe||h||f||g&&!ne,ae="running"===l||"queued"===l,ie=sa({status:l,output:i,runStartTimestamp:c,interrupted:f,staleInputs:g},h),se=("queued"===l||h||g)&&!f,le="edit"===y,de=r.useCallback((()=>{const e=ng(Z),t=X(e);return"markdown"!==la(e)&&ca(e),C({cellId:o}),t}),[o,Z,C]);r.useImperativeHandle(W,(()=>({get editorView(){return ng(Z)},registerRun:de})),[Z,de]);const ue=r.useCallback((()=>Z.current),[Z]),he=G((async()=>{if(ae)return;const e=de();await K({cellIds:[o],codes:[e]}).catch((e=>{J.error("Error running cell",e)}))})),fe=r.useCallback(((e={})=>E({cellId:o,before:!1,...e})),[o,E]),me=r.useCallback(((e={})=>E({cellId:o,before:!0,...e})),[o,E]),pe=r.useCallback((e=>{null===q.current||q.current.contains(e.relatedTarget)||null===Z.current||ca(Z.current)}),[]),ge=r.useCallback((e=>{if(q.current===document.activeElement&&null!==Z.current&&"active"===Sn(Z.current.state)){for(const t of da)if(e.key===t.key&&t.run){t.run(Z.current),e.preventDefault(),e.stopPropagation();break}Z.current.focus()}}),[q,Z]),ve=!ua(i),ye=ve&&k.jsxs("div",{className:"relative",children:[k.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:k.jsx(Kb,{isCollapsed:B,onClick:()=>{B?L({cellId:o}):R({cellId:o})},canCollapse:ha(F)})}),k.jsx(fa,{allowExpand:le,output:i,className:"output-area",cellId:o,stale:ie})]}),xe=ma("Cell","hover-actions-parent z-10",{published:!le,interactive:le,"needs-run":re,"has-error":m,stopped:p,disabled:V.disabled,stale:"disabled-transitively"===l}),be=ft.create(o),we=!V.hide_code||ee;if(Ws(le?q:null,{"cell.run":he,"cell.runAndNewBelow":()=>{he(),T({cellId:o,before:!1})},"cell.runAndNewAbove":()=>{he(),T({cellId:o,before:!0})},"cell.createAbove":me,"cell.createBelow":fe,"cell.moveUp":()=>I({cellId:o,before:!0}),"cell.moveDown":()=>I({cellId:o,before:!1}),"cell.hideCode":()=>{var e,t,n;const r=!V.hide_code;_e({configs:{[o]:{hide_code:r}}}),M({cellId:o,config:{hide_code:r}}),r?(null==(e=Z.current)||e.contentDOM.blur(),null==(t=q.current)||t.focus()):null==(n=Z.current)||n.focus()},"cell.focusDown":()=>T({cellId:o,before:!1}),"cell.focusUp":()=>T({cellId:o,before:!0}),"cell.sendToBottom":()=>D({cellId:o}),"cell.sendToTop":()=>P({cellId:o}),"cell.aiCompletion":()=>{let e=!1;Q((t=>(null==t?void 0:t.cellId)===o?(e=!0,null):{cellId:o})),e&&ng(Z).focus()},"cell.cellActions":()=>{var e;null==(e=Y.current)||e.toggle()}}),Gs(le?q:null,{ArrowDown:()=>(T({cellId:o,before:!1,noCreate:!0}),!0),ArrowUp:()=>(T({cellId:o,before:!0,noCreate:!0}),!0),..."vim"!==z.keymap.preset||we?{}:{j:()=>(T({cellId:o,before:!1,noCreate:!0}),!0),k:()=>(T({cellId:o,before:!0,noCreate:!0}),!0)}}),!le){const e=pa(null==i?void 0:i.mimetype);return m||f||p||e?null:k.jsx("div",{tabIndex:-1,id:be,ref:q,className:xe,children:ye})}return k.jsx(dx,{cellId:o,config:V,status:l,getEditorView:ue,hasOutput:ve,name:$,children:k.jsxs(sx,{tabIndex:-1,ref:q,"data-status":l,onBlur:pe,onKeyDown:ge,cellId:o,canMoveX:H,title:V.disabled?"This cell is disabled":"disabled-transitively"===l?"This cell has a disabled ancestor":void 0,children:[k.jsxs("div",{className:xe,id:be,children:["above"===z.display.cell_output&&ye,k.jsxs("div",{className:"tray",children:[k.jsx("div",{className:"absolute right-2 -top-4 z-10",children:k.jsx(ew,{edited:h,appClosed:b,status:l,cellConfig:V,needsRun:re,hasOutput:ve,cellActionDropdownRef:Y,cellId:o,name:$,getEditorView:ue,onRun:he})}),k.jsxs("div",{className:"absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",children:[k.jsx(jg,{tooltipContent:S("cell.createAbove"),appClosed:b,onClick:b?void 0:me}),k.jsx("div",{className:"flex-1"}),k.jsx(jg,{tooltipContent:S("cell.createBelow"),appClosed:b,onClick:b?void 0:fe})]}),k.jsx(Yb,{theme:e,showPlaceholder:t,allowFocus:n,id:o,code:a,config:V,status:l,serializedEditorState:v,runCell:he,updateCellCode:N,createNewCell:E,deleteCell:j,focusCell:_,moveCell:I,moveToNextCell:T,updateCellConfig:M,clearSerializedEditorState:O,userConfig:z,editorViewRef:Z,hidden:!we,setTemporarilyVisible:te}),k.jsxs("div",{className:"shoulder-right z-20",children:[k.jsx(Rg,{status:l,staleInputs:g,interrupted:f,editing:le,edited:h,disabled:V.disabled??!1,elapsedTime:u,runStartTimestamp:c,uninstantiated:oe,lastRunStartTimestamp:d}),k.jsx("div",{className:"flex gap-2 items-end",children:k.jsx(ax,{})})]}),k.jsx("div",{className:"shoulder-bottom hover-action",children:w&&we&&k.jsx(Og,{appClosed:b,status:l,onClick:()=>{ae||b||j({cellId:o})}})})]}),"below"===z.display.cell_output&&ye,k.jsx(fl,{consoleOutputs:s,stale:se,cellName:$,onRefactorWithAI:e=>{Q({cellId:o,initialPrompt:e.prompt})},onSubmitDebugger:(e,t)=>{A({cellId:o,response:e,outputIndex:t}),ga({text:e})},cellId:o,debuggerActive:x})]}),B&&k.jsx(Zb,{onClick:()=>L({cellId:o}),count:U,cellId:o})]})})}))),nw=e=>{const t=b(10),{width:n}=e,{banners:o}=ml(),{removeBanner:r}=pl();if(0===o.length)return null;const a="columns"===n&&"sticky left-12 w-full max-w-[80vw]";let i,s,l;if(t[0]!==a?(i=rn("flex flex-col gap-4 mb-5 print:hidden",a),t[0]=a,t[1]=i):i=t[1],t[2]!==r||t[3]!==o){let e;t[5]!==r?(e=e=>k.jsxs(va,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[k.jsxs("div",{className:"flex justify-between",children:[k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[k.jsx(ya,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),k.jsx(C,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(e.id),children:k.jsx(tn,{className:"w-5 h-5"})})]}),k.jsxs("div",{className:"flex justify-between items-end",children:[k.jsx("span",{children:xa({html:e.description})}),"restart"===e.action&&k.jsx(ow,{})]})]},e.id),t[5]=r,t[6]=e):e=t[6],s=o.map(e),t[2]=r,t[3]=o,t[4]=s}else s=t[4];return t[7]!==i||t[8]!==s?(l=k.jsx("div",{className:i,children:s}),t[7]=i,t[8]=s,t[9]=l):l=t[9],l},ow=()=>{const e=b(3),t=qd();let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(Oc,{className:"w-3 h-3 mr-2"}),e[0]=n):n=e[0],e[1]!==t?(o=k.jsxs(C,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:t,children:[n,"Restart"]}),e[1]=t,e[2]=o):o=e[2],o};const rw=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,o=e=>{const t=e.match(n);if(!t)return null;const[,o,r,a,i]=t;return{major:Number.parseInt(o,10),minor:Number.parseInt(r,10),patch:Number.parseInt(a,10),preRelease:i||""}};try{const n=o(e),r=o(t);return n&&r?n.major!==r.major?n.major-r.major:n.minor!==r.minor?n.minor-r.minor:n.patch!==r.patch?n.patch-r.patch:""===n.preRelease&&""!==r.preRelease?1:""!==n.preRelease&&""===r.preRelease?-1:n.preRelease.localeCompare(r.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const aw=()=>{const e=b(64),{packageAlert:t}=gl(),{clearPackageAlert:n}=vl(),[o]=Oe();let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={},e[0]=a):a=e[0];const[i,s]=r.useState(a);if(null===t)return null;const l="pixi"!==o.package_management.manager;if(yl(t)){let r,a,c,d,u,h,f,m,p,g;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[k.jsx(Ec,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),e[1]=r):r=e[1],e[2]!==n||e[3]!==t.id?(a=()=>n(t.id),e[2]=n,e[3]=t.id,e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(tn,{className:"w-5 h-5"}),e[5]=c):c=e[5],e[6]!==a?(d=k.jsxs("div",{className:"flex justify-between",children:[r,k.jsx(C,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:a,children:c})]}),e[6]=a,e[7]=d):d=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx("p",{children:"The following packages were not found:"}),e[8]=u):u=e[8],e[9]!==l||e[10]!==i||e[11]!==t.packages){let n;e[13]!==l||e[14]!==i?(n=(e,t)=>k.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[k.jsx(ql,{size:"1rem"}),e,l&&k.jsx(cw,{value:i[e]??"latest",onChange:t=>s((n=>({...n,[e]:t}))),packageName:e})]},t),e[13]=l,e[14]=i,e[15]=n):n=e[15],h=t.packages.map(n),e[9]=l,e[10]=i,e[11]=t.packages,e[12]=h}else h=e[12];return e[16]!==h?(f=k.jsxs("div",{children:[u,k.jsx("ul",{className:"list-disc ml-4 mt-1",children:h})]}),e[16]=h,e[17]=f):f=e[17],e[18]!==t||e[19]!==n||e[20]!==o||e[21]!==i?(m=k.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:t.isolated?k.jsxs(k.Fragment,{children:[k.jsx(sw,{manager:o.package_management.manager,versions:i,clearPackageAlert:()=>n(t.id)}),!D()&&k.jsxs(k.Fragment,{children:[k.jsx("span",{className:"px-2 text-sm",children:"with"})," ",k.jsx(lw,{})]})]}):k.jsxs("p",{children:["If you set up a"," ",k.jsx("a",{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",className:"text-accent-foreground hover:underline",target:"_blank",rel:"noreferrer",children:"virtual environment"}),", marimo can install these packages for you."]})}),e[18]=t,e[19]=n,e[20]=o,e[21]=i,e[22]=m):m=e[22],e[23]!==f||e[24]!==m?(p=k.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[f,m]}),e[23]=f,e[24]=m,e[25]=p):p=e[25],e[26]!==d||e[27]!==p?(g=k.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:k.jsxs(va,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[d,p]})}),e[26]=d,e[27]=p,e[28]=g):g=e[28],g}if(xl(t)){let o;e[29]!==t.packages?(o=function(e){const t=new Set(Object.values(e)),n=t.has("queued")||t.has("installing")?"installing":t.has("failed")?"failed":"installed";if("installing"===n)return{status:"installing",title:"Installing packages",titleIcon:k.jsx(ec,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:k.jsx(Cc,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:k.jsx(Ec,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(t.packages),e[29]=t.packages,e[30]=o):o=e[30];const{status:r,title:a,titleIcon:i,description:s}=o;"installed"===r&&setTimeout((()=>n(t.id)),1e4);const l="failed"===r?"danger":"info";let c,d,u,h,f;e[31]!==i||e[32]!==a?(c=k.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i,a]}),e[31]=i,e[32]=a,e[33]=c):c=e[33],e[34]!==n||e[35]!==t.id?(d=()=>n(t.id),e[34]=n,e[35]=t.id,e[36]=d):d=e[36],e[37]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(tn,{className:"w-5 h-5"}),e[37]=u):u=e[37],e[38]!==d?(h=k.jsx(C,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:d,children:u}),e[38]=d,e[39]=h):h=e[39],e[40]!==c||e[41]!==h?(f=k.jsxs("div",{className:"flex justify-between",children:[c,h]}),e[40]=c,e[41]=h,e[42]=f):f=e[42];const m="installed"===r&&"text-accent-foreground";let p,g,v,y,x,b,w;if(e[43]!==m?(p=rn("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",m),e[43]=m,e[44]=p):p=e[44],e[45]!==s?(g=k.jsx("p",{children:s}),e[45]=s,e[46]=g):g=e[46],e[47]!==t.packages||e[48]!==r){let n;e[50]!==r?(n=(e,t)=>{const[n,o]=e;return k.jsxs("li",{className:rn("flex items-center gap-1 font-mono text-sm","installing"===o&&"font-semibold","failed"===o&&"text-destructive","installed"===o&&"text-accent-foreground","installed"===o&&"failed"===r&&"text-muted-foreground"),children:[k.jsx(iw,{status:o}),n]},t)},e[50]=r,e[51]=n):n=e[51],v=Object.entries(t.packages).map(n),e[47]=t.packages,e[48]=r,e[49]=v}else v=e[49];return e[52]!==v?(y=k.jsx("ul",{className:"list-disc ml-4 mt-1",children:v}),e[52]=v,e[53]=y):y=e[53],e[54]!==g||e[55]!==y?(x=k.jsxs("div",{children:[g,y]}),e[54]=g,e[55]=y,e[56]=x):x=e[56],e[57]!==p||e[58]!==x?(b=k.jsx("div",{className:p,children:x}),e[57]=p,e[58]=x,e[59]=b):b=e[59],e[60]!==l||e[61]!==f||e[62]!==b?(w=k.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:k.jsxs(va,{kind:l,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[f,b]})}),e[60]=l,e[61]=f,e[62]=b,e[63]=w):w=e[63],w}return T(t),null};const iw=e=>{const t=b(4),{status:n}=e;switch(n){case"queued":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(ql,{size:"1rem"}),t[0]=e):e=t[0],e}case"installing":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(ec,{size:"1rem"}),t[1]=e):e=t[1],e}case"installed":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(It,{size:"1rem"}),t[2]=e):e=t[2],e}case"failed":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(tn,{size:"1rem"}),t[3]=e):e=t[3],e}default:return T(n),null}},sw=e=>{const t=b(8),{manager:n,versions:o,clearPackageAlert:r}=e;let a,i,s,l;return t[0]!==r||t[1]!==n||t[2]!==o?(a=async()=>{r(),await Aa({manager:n,versions:o}).catch((e=>{J.error(e)}))},t[0]=r,t[1]=n,t[2]=o,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(ec,{className:"w-4 h-4 mr-2"}),s=k.jsx("span",{className:"font-semibold",children:"Install"}),t[4]=i,t[5]=s):(i=t[4],s=t[5]),t[6]!==a?(l=k.jsxs(C,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:a,children:[i,s]}),t[6]=a,t[7]=l):l=t[7],l},lw=()=>{const e=b(16),[t,n]=Oe();let o,r;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=ba(wa),e[0]=o):o=e[0],e[1]!==t?(r={resolver:o,defaultValues:t},e[1]=t,e[2]=r):r=e[2];const a=ka(r);let i;e[3]!==n?(i=async e=>{await Pe({config:e}).then((()=>{n(e)}))},e[3]=n,e[4]=i):i=e[4];const s=i;let l,c,d,u;return e[5]!==a||e[6]!==s?(l=a.handleSubmit(s),e[5]=a,e[6]=s,e[7]=l):l=e[7],e[8]!==a.control?(c=k.jsx("div",{className:"flex flex-col gap-3",children:k.jsx(Sa,{control:a.control,name:"package_management.manager",render:uw})}),e[8]=a.control,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=k.jsx("form",{onChange:l,className:"flex flex-col gap-5",children:c}),e[10]=l,e[11]=c,e[12]=d):d=e[12],e[13]!==a||e[14]!==d?(u=k.jsx(Na,{...a,children:d}),e[13]=a,e[14]=d,e[15]=u):u=e[15],u},cw=e=>{const t=b(21),{value:n,onChange:o,packageName:r}=e;let a,i;t[0]!==r?(a=async()=>{const e=await fetch(`https://pypi.org/pypi/${t=r,t.replaceAll(/\[.*]/g,"").trim()}/json`,{method:"GET",signal:AbortSignal.timeout(5e3)});var t;const n=await e.json();return["latest",...Object.keys(n.releases).sort(rw).slice(0,100)]},i=[r],t[0]=r,t[1]=a,t[2]=i):(a=t[1],i=t[2]);const{data:s,loading:l,error:c}=sn(a,i);let d;t[3]!==s?(d=void 0===s?[]:s,t[3]=s,t[4]=d):d=t[4];const u=d;if(c){let e,r,a;return t[5]!==o?(e=e=>o(e.target.value),t[5]=o,t[6]=e):e=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx("option",{value:"latest",children:"latest"}),t[7]=r):r=t[7],t[8]!==n||t[9]!==e?(a=k.jsx(N,{content:"Failed to fetch package versions",children:k.jsx(ja,{value:n,onChange:e,disabled:!0,className:"inline-flex ml-2",children:r})}),t[8]=n,t[9]=e,t[10]=a):a=t[10],a}let h,f,m;return t[11]!==o?(h=e=>o(e.target.value),t[11]=o,t[12]=h):h=t[12],t[13]!==l||t[14]!==u?(f=l?k.jsx("option",{value:"latest",children:"latest"}):u.map(hw),t[13]=l,t[14]=u,t[15]=f):f=t[15],t[16]!==n||t[17]!==h||t[18]!==l||t[19]!==f?(m=k.jsx(ja,{value:n,onChange:h,disabled:l,className:"inline-flex ml-2",children:f}),t[16]=n,t[17]=h,t[18]=l,t[19]=f,t[20]=m):m=t[20],m};function dw(e){return k.jsx("option",{value:e,children:e},e)}function uw(e){const{field:t}=e;return k.jsxs(Ca,{children:[k.jsx(Ea,{children:k.jsx(ja,{"data-testid":"install-package-manager-select",onChange:e=>t.onChange(e.target.value),value:t.value,disabled:t.disabled,className:"inline-flex mr-2",children:_a.map(dw)})}),k.jsx(Ia,{})]})}function hw(e){return k.jsx("option",{value:e,children:e},e)}const fw=e=>{let{transform:t}=e;return{...t,x:0}},mw={threshold:{x:0,y:.1}},pw=u.memo((e=>{const t=b(25),{children:n,multiColumn:o}=e,{cellIds:a}=W(),{dropCellOverCell:i,dropCellOverColumn:s,moveColumn:l,compactColumns:c}=q(),[d,u]=r.useState(null),[h,f]=r.useState(null),[m]=De();let p;e:{if("columns"===m.width){p=Ta.EMPTY;break e}let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[fw],t[0]=e):e=t[0],p=e}const g=p;let v,y;t[1]===Symbol.for("react.memo_cache_sentinel")?(v={activationConstraint:{distance:8}},t[1]=v):v=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:nx},t[2]=y):y=t[2];const x=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return r.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(Zg(qv,v),Zg(Vv,y));let w;t[3]!==a?(w=e=>{u(e.active.id),f(a)},t[3]=a,t[4]=w):w=t[4];const S=G(w);let N;t[5]!==h?(N=()=>{u(null),f(null)},t[5]=h,t[6]=N):N=t[6];const C=G(N);let E;t[7]!==d||t[8]!==a?(E=e=>{const t=e.droppableContainers.filter((e=>vw(e.id)));if(d&&vw(d))return iv({...e,droppableContainers:t});const n=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:o}=e;if(!o)return[];const r=[];for(const a of t){const{id:e}=a,t=n.get(e);if(t&&cv(o,t)){const n=ov(t).reduce(((e,t)=>e+ev(o,t)),0),i=Number((n/4).toFixed(4));r.push({id:e,data:{droppableContainer:a,value:i}})}}return r.sort(tv)})({...e,droppableContainers:t}),o=rv(n.length>0?n:lv({...e,droppableContainers:t}),"id");if(!o)return[];$t(vw(o),`Expected column id. Got: ${o}`);const r=a.get(o);if($t(r,`Expected column. Got: ${o}`),r&&0===r.topLevelIds.length)return[{id:o}];const i=new Set(r.topLevelIds),s=iv({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==o&&i.has(e.id)))});if(s.length>0){const e=s[0].id;return $t(gw(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]},t[7]=d,t[8]=a,t[9]=E):E=t[9];const j=E;let _;t[10]!==s||t[11]!==i||t[12]!==l?(_=e=>{const{active:t,over:n}=e,o=null==n?void 0:n.id;if(null!=o&&t.id!==o){if(gw(t.id)){if(vw(o))return void s({cellId:t.id,columnId:o});if(gw(o))return void i({cellId:t.id,overCellId:o})}vw(t.id)&&vw(o)&&l({column:t.id,overColumn:o})}},t[10]=s,t[11]=i,t[12]=l,t[13]=_):_=t[13];const I=G(_);let A;t[14]!==c?(A=e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&c()},t[14]=c,t[15]=A):A=t[15];const T=G(A),M=o?j:iv;let O;return t[16]!==x||t[17]!==M||t[18]!==g||t[19]!==T||t[20]!==S||t[21]!==C||t[22]!==I||t[23]!==n?(O=k.jsx(Ty,{autoScroll:mw,sensors:x,collisionDetection:M,modifiers:g,onDragEnd:T,onDragStart:S,onDragCancel:C,onDragOver:I,children:n}),t[16]=x,t[17]=M,t[18]=g,t[19]=T,t[20]=S,t[21]=C,t[22]=I,t[23]=n,t[24]=O):O=t[24],O}));function gw(e){return"string"==typeof e&&!e.startsWith("tree_")}function vw(e){return"string"==typeof e&&e.startsWith("tree_")}const yw=u.forwardRef((({columnId:e,canDelete:t,canMoveLeft:n,canMoveRight:o,...r},a)=>{const{attributes:i,listeners:s,setNodeRef:l,transform:c,transition:d,isDragging:u,isOver:h}=Qy({id:e}),f={transform:c?pr.Transform.toString({x:c.x,y:0,scaleX:1,scaleY:1}):void 0,transition:d,zIndex:u?2:void 0,position:"relative","--gutter-width":"50px"},m=Ug(a,l),{deleteColumn:p,moveColumn:g,addColumn:v}=q(),y=rn("h-full hover:bg-muted rounded-none"),x=()=>{const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})},b=k.jsxs("div",{className:"h-6 group flex items-center rounded-t-lg border hover:border-border border-[var(--slate-3)] overflow-hidden bg-[var(--slate-1)]",children:[k.jsx(N,{content:"Move column left",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>g({column:e,overColumn:"_left_"}),disabled:!n,children:k.jsx(Ma,{className:"size-4"})})}),k.jsx(N,{content:"Move column right",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>g({column:e,overColumn:"_right_"}),disabled:!o,children:k.jsx(ra,{className:"size-4"})})}),k.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...i,...s,"data-testid":"column-drag-button"}),t&&k.jsx(N,{content:"Delete column",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:"opacity-0 group-hover:opacity-70 group-hover:hover:opacity-100 text-destructive h-full hover:bg-destructive/20 rounded-none",onClick:()=>p({columnId:e}),children:k.jsx(tn,{className:"size-4"})})}),k.jsx(N,{content:"Add column",side:"top",delayDuration:300,children:k.jsx(C,{variant:"text",size:"sm",className:y,onClick:()=>{v({columnId:e}),requestAnimationFrame(x)},children:k.jsx(Bo,{className:"size-4"})})})]});return k.jsxs("div",{tabIndex:-1,ref:m,...r,style:f,"data-is-dragging":u,className:rn(u?"":r.className,u?"z-20":"z-1 hover:z-10 focus-within:z-10",h&&"bg-accent/20"),children:[b,r.children]})}));yw.displayName="SortableColumn";const xw=r.memo(yw),bw=r.memo((e=>{const t=b(15),n=r.useRef(null),o="columns"===e.width&&"w-contentWidth box-content\t min-h-[100px] border border-t-0 border-[var(--slate-3)] rounded-b-lg px-11 py-6 bg-[var(--slate-2)]";let a,i;t[0]!==o?(a=rn("flex flex-col gap-5",o),t[0]=o,t[1]=a):a=t[1],t[2]!==a||t[3]!==e.children?(i=k.jsx("div",{className:a,children:e.children}),t[2]=a,t[3]=e.children,t[4]=i):i=t[4];const s=i;if("columns"===e.width){let o;return t[5]!==e.canDelete||t[6]!==e.columnId||t[7]!==e.canMoveLeft||t[8]!==e.canMoveRight||t[9]!==e.footer||t[10]!==s?(o=k.jsxs(xw,{tabIndex:-1,ref:n,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[s,e.footer]}),t[5]=e.canDelete,t[6]=e.columnId,t[7]=e.canMoveLeft,t[8]=e.canMoveRight,t[9]=e.footer,t[10]=s,t[11]=o):o=t[11],o}let l;return t[12]!==s||t[13]!==e.footer?(l=k.jsxs(k.Fragment,{children:[s,e.footer]}),t[12]=s,t[13]=e.footer,t[14]=l):l=t[14],l}));bw.displayName="Column";const ww=e=>{const t=b(67),{notebook:n,mode:o,userConfig:a,appConfig:i,connStatus:s}=e,l=q(),{theme:c}=Me(),{toggleSidebarPanel:d}=eu(),{invisible:u}=bl(n.cellIds.idLength,o);let h;Cs("global.focusTop",l.focusTopCell),Cs("global.focusBottom",l.focusBottomCell),Cs("global.toggleSidebar",d),Cs("global.foldCode",l.foldAll),Cs("global.unfoldCode",l.unfoldAll),t[0]!==l.updateCellCode?(h=()=>{Pa(l.updateCellCode)},t[0]=l.updateCellCode,t[1]=h):h=t[1],Cs("global.formatAll",h),Cs("cell.hideCode",an.NOOP),Cs("cell.format",an.NOOP);const f=jd(),m=l.scrollToTarget;let p,g,v,y,x,w,S,N,C,E,j,_,I,A,T,M,O,D,P,R,L,z;if(t[2]!==n.scrollKey||t[3]!==m?(p=()=>{null!==n.scrollKey&&m()},t[2]=n.scrollKey,t[3]=m,t[4]=p):p=t[4],t[5]!==n.cellIds||t[6]!==n.scrollKey||t[7]!==m?(g=[n.cellIds,n.scrollKey,m],t[5]=n.cellIds,t[6]=n.scrollKey,t[7]=m,t[8]=g):g=t[8],r.useEffect(p,g),t[9]!==n.cellIds||t[10]!==n.cellData||t[11]!==n.cellRuntime||t[12]!==n.scrollKey||t[13]!==n.cellHandles||t[14]!==u||t[15]!==i||t[16]!==c||t[17]!==o||t[18]!==s.state||t[19]!==a||t[20]!==l||t[21]!==f){const e=n.cellIds.getColumns();let r;t[37]!==n.cellIds?(r=n.cellIds.hasOnlyOneId(),t[37]=n.cellIds,t[38]=r):r=t[38];const d=r;j=wl,_="pb-[40vh]",I=u,A=i,T="pr-4",t[39]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx(aw,{}),t[39]=M):M=t[39],t[40]!==i.width?(O=k.jsx(nw,{width:i.width}),t[40]=i.width,t[41]=O):O=t[41],C=pw,E="columns"===i.width,x=Gy,w="column-container",S=e.map(Sw),N=By;const h="columns"===i.width&&"grid grid-flow-col auto-cols-min gap-6";t[42]!==h?(v=rn(h),t[42]=h,t[43]=v):v=t[43],y=e.map(((t,r)=>k.jsx(bw,{columnId:t.id,canMoveLeft:r>0,canMoveRight:r<e.length-1,width:i.width,canDelete:e.length>1,footer:k.jsx(kw,{columnId:t.id,className:rn("columns"===i.width&&"opacity-0 group-hover/column:opacity-100")}),children:k.jsx(Gy,{id:`column-${r+1}`,items:t.topLevelIds,strategy:Hy,children:t.topLevelIds.map((e=>{const r=n.cellData[e],h=n.cellRuntime[e];return k.jsx(tw,{theme:c,showPlaceholder:d,allowFocus:!u&&!n.scrollKey,id:r.id,code:r.code,outline:h.outline,output:h.output,consoleOutputs:h.consoleOutputs,status:h.status,edited:r.edited,interrupted:h.interrupted,errored:h.errored,stopped:h.stopped,staleInputs:h.staleInputs,runStartTimestamp:h.runStartTimestamp,lastRunStartTimestamp:h.lastRunStartTimestamp,runElapsedTimeMs:h.runElapsedTimeMs??r.lastExecutionTime,serializedEditorState:r.serializedEditorState,canDelete:!d,mode:o,appClosed:s.state!==ll.OPEN,ref:n.cellHandles[e],userConfig:a,debuggerActive:h.debuggerActive,config:r.config,name:r.name,isCollapsed:t.isCollapsed(e),collapseCount:t.getCount(e),canMoveX:"columns"===i.width,...l,deleteCell:f},r.id.toString())}))})},t.id))),t[9]=n.cellIds,t[10]=n.cellData,t[11]=n.cellRuntime,t[12]=n.scrollKey,t[13]=n.cellHandles,t[14]=u,t[15]=i,t[16]=c,t[17]=o,t[18]=s.state,t[19]=a,t[20]=l,t[21]=f,t[22]=v,t[23]=y,t[24]=x,t[25]=w,t[26]=S,t[27]=N,t[28]=C,t[29]=E,t[30]=j,t[31]=_,t[32]=I,t[33]=A,t[34]=T,t[35]=M,t[36]=O}else v=t[22],y=t[23],x=t[24],w=t[25],S=t[26],N=t[27],C=t[28],E=t[29],j=t[30],_=t[31],I=t[32],A=t[33],T=t[34],M=t[35],O=t[36];return t[44]!==v||t[45]!==y?(D=k.jsx("div",{className:v,children:y}),t[44]=v,t[45]=y,t[46]=D):D=t[46],t[47]!==x||t[48]!==w||t[49]!==S||t[50]!==N||t[51]!==D?(P=k.jsx(x,{id:w,items:S,strategy:N,children:D}),t[47]=x,t[48]=w,t[49]=S,t[50]=N,t[51]=D,t[52]=P):P=t[52],t[53]!==C||t[54]!==E||t[55]!==P?(R=k.jsx(C,{multiColumn:E,children:P}),t[53]=C,t[54]=E,t[55]=P,t[56]=R):R=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(L=k.jsx(kl,{}),t[57]=L):L=t[57],t[58]!==j||t[59]!==_||t[60]!==I||t[61]!==A||t[62]!==T||t[63]!==M||t[64]!==O||t[65]!==R?(z=k.jsxs(j,{className:_,invisible:I,appConfig:A,innerClassName:T,children:[M,O,R,L]}),t[58]=j,t[59]=_,t[60]=I,t[61]=A,t[62]=T,t[63]=M,t[64]=O,t[65]=R,t[66]=z):z=t[66],z},kw=e=>{const t=b(18),{columnId:n,className:o}=e,{createNewCell:r}=q(),a=le(ue),[i,s]=Oa(!1),l=le(de),c=le(Da).sql;let d;t[0]===Symbol.for("react.memo_cache_sentinel")?(d=rn("mb-0 rounded-none sm:px-4 md:px-5 lg:px-8 tracking-wide no-wrap whitespace-nowrap","hover:bg-accent hover:text-accent-foreground font-semibold uppercase text-xs"),t[0]=d):d=t[0];const u=d;let h;t[1]!==i||t[2]!==s.toggle||t[3]!==r||t[4]!==n||t[5]!==a||t[6]!==c||t[7]!==l?(h=()=>i?k.jsx(Fb,{onClose:s.toggle}):k.jsxs(k.Fragment,{children:[k.jsxs(C,{className:u,variant:"text",size:"sm",onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[k.jsx(Bc,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),k.jsxs(C,{className:u,variant:"text",size:"sm",onClick:()=>{Id(a,r),r({cellId:{type:"__end__",columnId:n},before:!1,code:(new Uo).defaultCode})},children:[k.jsx(Hc,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),k.jsx(N,{content:c?null:k.jsxs("div",{className:"flex flex-col",children:[k.jsxs("span",{children:["Additional dependencies required:",k.jsx(Ra,{className:"inline",children:"pip install 'marimo[sql]'"}),"."]}),k.jsx("span",{children:"You will need to restart the notebook after installing."})]}),delayDuration:100,asChild:!1,children:k.jsxs(C,{className:u,variant:"text",size:"sm",disabled:!c,onClick:()=>{Id(a,r),r({cellId:{type:"__end__",columnId:n},before:!1,code:(new Vo).defaultCode})},children:[k.jsx(ke,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]})}),k.jsx(N,{content:l?null:k.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:k.jsxs(C,{className:u,variant:"text",size:"sm",disabled:!l,onClick:s.toggle,children:[k.jsx(Fc,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]}),t[1]=i,t[2]=s.toggle,t[3]=r,t[4]=n,t[5]=a,t[6]=c,t[7]=l,t[8]=h):h=t[8];const f=h,m=!i&&"w-fit",p=i&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]";let g,v,y;return t[9]!==m||t[10]!==p||t[11]!==o?(g=rn("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",m,p,o),t[9]=m,t[10]=p,t[11]=o,t[12]=g):g=t[12],t[13]!==f?(v=f(),t[13]=f,t[14]=v):v=t[14],t[15]!==g||t[16]!==v?(y=k.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:k.jsx("div",{className:g,children:v})}),t[15]=g,t[16]=v,t[17]=y):y=t[17],y};function Sw(e){return e.id}async function Nw(){await za({download:!1,includeCode:!0,files:il.INSTANCE.filenames()})}async function Cw(){await Fa({download:!1})}const Ew=e=>{const t=b(117),{userConfig:n,appConfig:o}=e,a=W();Ba(Ya,qa.onCellIdsChange);const{setCells:i,updateCellCode:s,mergeAllColumns:l}=q(),c=le(ht),[d,u]=yt(),[h,f]=r.useState(),m=tl(),{openModal:p,closeModal:g,openAlert:v}=w(),y="edit"===c.mode,x="present"===c.mode,S=le(Ua),N=le(fe);let C;t[0]!==v?(C=function(){v("Failed to save notebook: not connected to a kernel.")},t[0]=v,t[1]=C):C=t[1];const E=C;let j;t[2]===Symbol.for("react.memo_cache_sentinel")?(j=[],t[2]=j):j=t[2],r.useEffect(Iw,j);const _=n.runtime.auto_instantiate;let I,A,T;t[3]!==i?(I=(e,t)=>{i(e);const n=e.map((e=>e.name)),o=e.map((e=>e.code)),r=e.map((e=>e.config));f({names:n,codes:o,configs:r,layout:t})},t[3]=i,t[4]=I):I=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(A=Xa(),t[5]=A):A=t[5],t[6]!==n.runtime.auto_instantiate||t[7]!==I?(T={autoInstantiate:_,setCells:I,sessionId:A},t[6]=n.runtime.auto_instantiate,t[7]=I,t[8]=T):T=t[8];const{connection:M}=Sl(T);let O;t[9]!==M.state||t[10]!==E||t[11]!==u||t[12]!==o.app_title||t[13]!==v?(O=async e=>M.state!==ll.OPEN?(E(),null):(Ka((t=>{null===e?t.delete(Ja.filePath):t.set(Ja.filePath,e)})),Za({filename:e}).then((()=>(u(e),document.title=o.app_title||gt.basename(e)||"Untitled Notebook",e))).catch((e=>(v(e.message),null)))),t[9]=M.state,t[10]=E,t[11]=u,t[12]=o.app_title,t[13]=v,t[14]=O):O=t[14];const D=G(O);let P,R;t[15]!==o.app_title||t[16]!==d?(P=()=>{document.title=o.app_title||gt.basename(d??"")||"Untitled Notebook"},R=[o.app_title,d],t[15]=o.app_title,t[16]=d,t[17]=P,t[18]=R):(P=t[17],R=t[18]),r.useEffect(P,R);const L=a.cellIds.colLength,z=or(o.width);let F,B,U,V,H,$;t[19]!==z||t[20]!==o.width||t[21]!==l?(F=()=>{"columns"===z&&"columns"!==o.width&&l()},t[19]=z,t[20]=o.width,t[21]=l,t[22]=F):F=t[22],t[23]!==o.width||t[24]!==z||t[25]!==l||t[26]!==L?(B=[o.width,z,l,L],t[23]=o.width,t[24]=z,t[25]=l,t[26]=L,t[27]=B):B=t[27],r.useEffect(F,B),t[28]!==a?($=Va(a),H=$.map(Aw),V=$.map(Tw),U=$.map(Mw),t[28]=a,t[29]=U,t[30]=V,t[31]=H,t[32]=$):(U=t[29],V=t[30],H=t[31],$=t[32]);const X=U;let K;t[33]!==a?(K=Ha(a),t[33]=a,t[34]=K):K=t[34];const Z=K;let ee;t[35]!==a||t[36]!==m||t[37]!==h?(ee=$a(a,m,h),t[35]=a,t[36]=m,t[37]=h,t[38]=ee):ee=t[38];const te=ee;let ne;t[39]!==N||t[40]!==V||t[41]!==M.state||t[42]!==E||t[43]!==H||t[44]!==X||t[45]!==Z||t[46]!==n.save.format_on_save||t[47]!==s||t[48]!==m?(ne=(e,t)=>{N||0!==V.length&&(M.state===ll.OPEN?(J.log("saving to ",e),Qa({cellIds:H,codes:V,names:X,filename:e,configs:Z,layout:El(),persist:!0}).then((()=>{t&&(re({title:"Notebook saved"}),n.save.format_on_save&&Pa(s)),f({names:X,codes:V,configs:Z,layout:m})}))):E())},t[39]=N,t[40]=V,t[41]=M.state,t[42]=E,t[43]=H,t[44]=X,t[45]=Z,t[46]=n.save.format_on_save,t[47]=s,t[48]=m,t[49]=ne):ne=t[49];const oe=G(ne);let ae;t[50]!==d||t[51]!==M.state||t[52]!==oe?(ae=e=>{const t=void 0!==e&&e;null!==d&&M.state===ll.OPEN&&oe(d,t)},t[50]=d,t[51]=M.state,t[52]=oe,t[53]=ae):ae=t[53];const ie=G(ae),se=G((()=>{ie(!0),null===d&&M.state!==ll.CLOSED&&p(k.jsx(jw,{onClose:g,onSave:ue}))}));let ce,de;t[54]!==ie||t[55]!==te||t[56]!==V||t[57]!==Z||t[58]!==X||t[59]!==M||t[60]!==n||t[61]!==N?(ce={onSave:ie,needsSave:te,codes:V,cellConfigs:Z,cellNames:X,connStatus:M,config:n,kioskMode:N},t[54]=ie,t[55]=te,t[56]=V,t[57]=Z,t[58]=X,t[59]=M,t[60]=n,t[61]=N,t[62]=ce):ce=t[62],function(e){const t=b(16),{codes:n,cellConfigs:o,config:a,connStatus:i,cellNames:s,needsSave:l,kioskMode:c,onSave:d}=e,u=r.useRef(null);let h,f;t[0]!==c||t[1]!==a.save.autosave||t[2]!==a.save.autosave_delay||t[3]!==l||t[4]!==i.state||t[5]!==d?(h=()=>{if(!c)return"after_delay"===a.save.autosave&&(null!==u.current&&clearTimeout(u.current),l&&i.state===ll.OPEN&&(u.current=setTimeout(d,a.save.autosave_delay))),()=>{null!==u.current&&clearTimeout(u.current)}},t[0]=c,t[1]=a.save.autosave,t[2]=a.save.autosave_delay,t[3]=l,t[4]=i.state,t[5]=d,t[6]=h):h=t[6],t[7]!==n||t[8]!==o||t[9]!==s||t[10]!==a.save||t[11]!==i.state||t[12]!==d||t[13]!==c||t[14]!==l?(f=[n,o,s,a.save,i.state,d,c,l],t[7]=n,t[8]=o,t[9]=s,t[10]=a.save,t[11]=i.state,t[12]=d,t[13]=c,t[14]=l,t[15]=f):f=t[15],r.useEffect(h,f)}(ce),function(){const e=b(4),t=le(La),{state:n}=le(sl),o=t.auto_download.includes("markdown"),r=t.auto_download.includes("html"),a=!o||n!==ll.OPEN,i=!r||n!==ll.OPEN;let s,l;e[0]!==a?(s={delayMs:5e3,whenVisible:!0,disabled:a},e[0]=a,e[1]=s):s=e[1],qs(Cw,s),e[2]!==i?(l={delayMs:5e3,whenVisible:!0,disabled:i},e[2]=i,e[3]=l):l=e[3],qs(Nw,l)}(),t[63]!==te?(de=e=>{if(!ei())return te?(e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to quit?"):void 0},t[63]=te,t[64]=de):de=t[64],Q(window,"beforeunload",de);const ue=e=>{D(e).then((e=>{null!==e&&oe(e,!0)}))},he=function(){const e=b(3),t=W(),n=wd();let o;return e[0]!==n||e[1]!==t?(o=()=>n(Y(t)),e[0]=n,e[1]=t,e[2]=o):o=e[2],G(o)}(),me=nu();let pe,ge,ve;t[65]!==he?(pe=()=>{he()},t[65]=he,t[66]=pe):pe=t[66],Cs("global.runStale",pe),Cs("global.save",se),Cs("global.interrupt",Ow),t[67]!==me?(ge=()=>{me()},t[67]=me,t[68]=ge):ge=t[68],Cs("global.hideCode",ge),t[69]!==d||t[70]!==$?(ve=()=>JSON.stringify({filename:d,cells:$.map((e=>({name:e.name,code:e.code})))},null,2),t[69]=d,t[70]=$,t[71]=ve):ve=t[71];const ye=G(ve);let xe;t[72]!==a||t[73]!==M||t[74]!==c.mode||t[75]!==n||t[76]!==o?(xe=k.jsx(ww,{notebook:a,connStatus:M,mode:c.mode,userConfig:n,appConfig:o}),t[72]=a,t[73]=M,t[74]=c.mode,t[75]=n,t[76]=o,t[77]=xe):xe=t[77];const be=xe,we=o.width;let ke,Se,Ne,Ce,Ee;t[78]===Symbol.for("react.memo_cache_sentinel")?(ke=rn("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),t[78]=ke):ke=t[78],t[79]!==y||t[80]!==d||t[81]!==D?(Se=y&&k.jsx("div",{className:"flex items-center justify-center container",children:k.jsx(Hu,{filename:d,setFilename:D})}),t[79]=y,t[80]=d,t[81]=D,t[82]=Se):Se=t[82],t[83]!==M||t[84]!==Se?(Ne=k.jsx(jl,{connection:M,className:ke,children:Se}),t[83]=M,t[84]=Se,t[85]=Ne):Ne=t[85],t[86]!==$.length||t[87]!==o||t[88]!==c||t[89]!==be?(Ce=$.length>0&&k.jsx(Nl,{appConfig:o,mode:c.mode,children:be}),t[86]=$.length,t[87]=o,t[88]=c,t[89]=be,t[90]=Ce):Ce=t[90],t[91]!==M||t[92]!==S||t[93]!==o.width||t[94]!==Ne||t[95]!==Ce?(Ee=k.jsxs(_l,{connection:M,isRunning:S,width:we,children:[Ne,Ce]}),t[91]=M,t[92]=S,t[93]=o.width,t[94]=Ne,t[95]=Ce,t[96]=Ee):Ee=t[96];const je=M.state===ll.CLOSED;let _e,Ie,Ae,Te;return t[97]!==a?(_e=Wa(a),t[97]=a,t[98]=_e):_e=t[98],t[99]!==a?(Ie=At(a),t[99]=a,t[100]=Ie):Ie=t[100],t[101]!==d||t[102]!==te||t[103]!==se||t[104]!==ye||t[105]!==x||t[106]!==me||t[107]!==he||t[108]!==je||t[109]!==S||t[110]!==_e||t[111]!==Ie||t[112]!==o.width?(Ae=k.jsx(Ru,{filename:d,needsSave:te,onSaveNotebook:se,getCellsAsJSON:ye,presenting:x,onTogglePresenting:me,onInterrupt:aa,onRun:he,closed:je,running:S,needsRun:_e,undoAvailable:Ie,appWidth:o.width}),t[101]=d,t[102]=te,t[103]=se,t[104]=ye,t[105]=x,t[106]=me,t[107]=he,t[108]=je,t[109]=S,t[110]=_e,t[111]=Ie,t[112]=o.width,t[113]=Ae):Ae=t[113],t[114]!==Ee||t[115]!==Ae?(Te=k.jsxs(k.Fragment,{children:[Ee,Ae]}),t[114]=Ee,t[115]=Ae,t[116]=Te):Te=t[116],Te},jw=e=>{const t=b(17),{onClose:n,onSave:o}=e,[a,i]=r.useState();let s;t[0]!==o||t[1]!==n?(s=e=>{i(e),e.trim()&&(o(e),n())},t[0]=o,t[1]=n,t[2]=s):s=t[2];const l=s;let c,d,u,h;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(j,{children:"Save notebook"}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Ae,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=d):d=t[4],t[5]!==l?(u=k.jsxs("div",{className:"flex flex-col",children:[d,k.jsx(Uu,{onNameChange:l,placeholderText:"filename",className:"missing-filename"})]}),t[5]=l,t[6]=u):u=t[6],t[7]!==n?(h=k.jsx(C,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),t[7]=n,t[8]=h):h=t[8];const f=!a;let m,p,g;return t[9]!==f?(m=k.jsx(C,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:f,type:"submit",children:"Save"}),t[9]=f,t[10]=m):m=t[10],t[11]!==h||t[12]!==m?(p=k.jsxs(I,{children:[h,m]}),t[11]=h,t[12]=m,t[13]=p):p=t[13],t[14]!==u||t[15]!==p?(g=k.jsxs(A,{children:[c,u,p]}),t[14]=u,t[15]=p,t[16]=g):g=t[16],g};function _w(){Cl.INSTANCE.stop()}function Iw(){return Cl.INSTANCE.start(Ga),_w}function Aw(e){return e.id}function Tw(e){return e.code}function Mw(e){return e.name}function Ow(){aa()}const{createElement:Dw,createContext:Pw,createRef:Rw,forwardRef:Lw,useCallback:zw,useContext:Fw,useEffect:Bw,useImperativeHandle:Uw,useLayoutEffect:Vw,useMemo:Hw,useRef:$w,useState:Ww}=ti,Gw=ti["useId".toString()],qw=Vw,Yw=Pw(null);Yw.displayName="PanelGroupContext";const Xw=qw,Kw="function"==typeof Gw?Gw:()=>null;let Jw=0;function Zw(e=null){const t=Kw(),n=$w(e||t||null);return null===n.current&&(n.current=""+Jw++),null!=e?e:n.current}function Qw({children:e,className:t="",collapsedSize:n,collapsible:o,defaultSize:r,forwardedRef:a,id:i,maxSize:s,minSize:l,onCollapse:c,onExpand:d,onResize:u,order:h,style:f,tagName:m="div",...p}){const g=Fw(Yw);if(null===g)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:v,expandPanel:y,getPanelSize:x,getPanelStyle:b,groupId:w,isPanelCollapsed:k,reevaluatePanelConstraints:S,registerPanel:N,resizePanel:C,unregisterPanel:E}=g,j=Zw(i),_=$w({callbacks:{onCollapse:c,onExpand:d,onResize:u},constraints:{collapsedSize:n,collapsible:o,defaultSize:r,maxSize:s,minSize:l},id:j,idIsFromProps:void 0!==i,order:h});$w({didLogMissingDefaultSizeWarning:!1}),Xw((()=>{const{callbacks:e,constraints:t}=_.current,a={...t};_.current.id=j,_.current.idIsFromProps=void 0!==i,_.current.order=h,e.onCollapse=c,e.onExpand=d,e.onResize=u,t.collapsedSize=n,t.collapsible=o,t.defaultSize=r,t.maxSize=s,t.minSize=l,a.collapsedSize===t.collapsedSize&&a.collapsible===t.collapsible&&a.maxSize===t.maxSize&&a.minSize===t.minSize||S(_.current,a)})),Xw((()=>{const e=_.current;return N(e),()=>{E(e)}}),[h,j,N,E]),Uw(a,(()=>({collapse:()=>{v(_.current)},expand:e=>{y(_.current,e)},getId:()=>j,getSize:()=>x(_.current),isCollapsed:()=>k(_.current),isExpanded:()=>!k(_.current),resize:e=>{C(_.current,e)}})),[v,y,x,k,j,C]);const I=b(_.current,r);return Dw(m,{...p,children:e,className:t,id:i,style:{...I,...f},"data-panel":"","data-panel-collapsible":o||void 0,"data-panel-group-id":w,"data-panel-id":j,"data-panel-size":parseFloat(""+I.flexGrow).toFixed(1)})}const ek=Lw(((e,t)=>Dw(Qw,{...e,forwardedRef:t})));Qw.displayName="Panel",ek.displayName="forwardRef(Panel)";let tk=null,nk=null;function ok(e,t){const n=function(e,t){if(t){const e=!!(t&gk),n=!!(t&vk);if(t&mk)return e?"se-resize":n?"ne-resize":"e-resize";if(t&pk)return e?"sw-resize":n?"nw-resize":"w-resize";if(e)return"s-resize";if(n)return"n-resize"}switch(e){case"horizontal":return"ew-resize";case"intersection":return"move";case"vertical":return"ns-resize"}}(e,t);tk!==n&&(tk=n,null===nk&&(nk=document.createElement("style"),document.head.appendChild(nk)),nk.innerHTML=`*{cursor: ${n}!important;}`)}function rk(e){return"keydown"===e.type}function ak(e){return e.type.startsWith("pointer")}function ik(e){return e.type.startsWith("mouse")}function sk(e){if(ak(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(ik(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const lk=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function ck(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=fk(e))&&void 0!==t?t:e).display;return"flex"===n||"inline-flex"===n}(e))||(+t.opacity<1||("transform"in t&&"none"!==t.transform||("webkitTransform"in t&&"none"!==t.webkitTransform||("mixBlendMode"in t&&"normal"!==t.mixBlendMode||("filter"in t&&"none"!==t.filter||("webkitFilter"in t&&"none"!==t.webkitFilter||("isolation"in t&&"isolate"===t.isolation||(!!lk.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function dk(e){let t=e.length;for(;t--;){const n=e[t];if(Mk(n,"Missing node"),ck(n))return n}return null}function uk(e){return e&&Number(getComputedStyle(e).zIndex)||0}function hk(e){const t=[];for(;e;)t.push(e),e=fk(e);return t}function fk(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const mk=1,pk=2,gk=4,vk=8,yk="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let xk=[],bk=!1,wk=new Map,kk=new Map;const Sk=new Set;function Nk(e){const{target:t}=e,{x:n,y:o}=sk(e);bk=!0,jk({target:t,x:n,y:o}),Ak(),xk.length>0&&(Tk("down",e),e.preventDefault(),e.stopPropagation())}function Ck(e){const{x:t,y:n}=sk(e);if(!bk){const{target:o}=e;jk({target:o,x:t,y:n})}Tk("move",e),Ik(),xk.length>0&&e.preventDefault()}function Ek(e){const{target:t}=e,{x:n,y:o}=sk(e);kk.clear(),bk=!1,xk.length>0&&e.preventDefault(),Tk("up",e),jk({target:t,x:n,y:o}),Ik(),Ak()}function jk({target:e,x:t,y:n}){xk.splice(0);let o=null;e instanceof HTMLElement&&(o=e),Sk.forEach((e=>{const{element:r,hitAreaMargins:a}=e,i=r.getBoundingClientRect(),{bottom:s,left:l,right:c,top:d}=i,u=yk?a.coarse:a.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=s+u){if(null!==o&&r!==o&&!r.contains(o)&&!o.contains(r)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:hk(e),b:hk(t)};let o;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),o=e;Mk(o,"Stacking order can only be calculated for elements with a common ancestor");const r=uk(dk(n.a)),a=uk(dk(n.b));if(r===a){const e=o.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let r=e.length;for(;r--;){const n=e[r];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(r-a)}(o,r)>0){let e=o,t=!1;for(;e&&!e.contains(r);){if(h=e.getBoundingClientRect(),f=i,h.x<f.x+f.width&&h.x+h.width>f.x&&h.y<f.y+f.height&&h.y+h.height>f.y){t=!0;break}e=e.parentElement}if(t)return}xk.push(e)}var h,f}))}function _k(e,t){kk.set(e,t)}function Ik(){let e=!1,t=!1;xk.forEach((n=>{const{direction:o}=n;"horizontal"===o?e=!0:t=!0}));let n=0;kk.forEach((e=>{n|=e})),e&&t?ok("intersection",n):e?ok("horizontal",n):t?ok("vertical",n):null!==nk&&(document.head.removeChild(nk),tk=null,nk=null)}function Ak(){wk.forEach(((e,t)=>{const{body:n}=t;n.removeEventListener("contextmenu",Ek),n.removeEventListener("pointerdown",Nk),n.removeEventListener("pointerleave",Ck),n.removeEventListener("pointermove",Ck)})),window.removeEventListener("pointerup",Ek),window.removeEventListener("pointercancel",Ek),Sk.size>0&&(bk?(xk.length>0&&wk.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("contextmenu",Ek),n.addEventListener("pointerleave",Ck),n.addEventListener("pointermove",Ck))})),window.addEventListener("pointerup",Ek),window.addEventListener("pointercancel",Ek)):wk.forEach(((e,t)=>{const{body:n}=t;e>0&&(n.addEventListener("pointerdown",Nk,{capture:!0}),n.addEventListener("pointermove",Ck))})))}function Tk(e,t){Sk.forEach((n=>{const{setResizeHandlerState:o}=n,r=xk.includes(n);o(e,r,t)}))}function Mk(e,t){if(!e)throw console.error(t),Error(t)}function Ok(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function Dk(e,t,n=10){return 0===Ok(e,t,n)}function Pk(e,t,n){return 0===Ok(e,t,n)}function Rk({panelConstraints:e,panelIndex:t,size:n}){const o=e[t];Mk(null!=o,`Panel constraints not found for index ${t}`);let{collapsedSize:r=0,collapsible:a,maxSize:i=100,minSize:s=0}=o;if(Ok(n,s)<0)if(a){n=Ok(n,(r+s)/2)<0?r:s}else n=s;return n=Math.min(i,n),n=parseFloat(n.toFixed(10))}function Lk({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:o,prevLayout:r,trigger:a}){if(Pk(e,0))return t;const i=[...t],[s,l]=o;Mk(null!=s,"Invalid first pivot index"),Mk(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===a){{const o=e<0?l:s,r=n[o];Mk(r,`Panel constraints not found for index ${o}`);const{collapsedSize:a=0,collapsible:i,minSize:c=0}=r;if(i){const n=t[o];if(Mk(null!=n,`Previous layout not found for panel index ${o}`),Pk(n,a)){const t=c-n;Ok(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const o=e<0?s:l,r=n[o];Mk(r,`No panel constraints found for index ${o}`);const{collapsedSize:a=0,collapsible:i,minSize:c=0}=r;if(i){const n=t[o];if(Mk(null!=n,`Previous layout not found for panel index ${o}`),Pk(n,c)){const t=n-a;Ok(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const o=e<0?1:-1;let r=e<0?l:s,a=0;for(;;){const e=t[r];Mk(null!=e,`Previous layout not found for panel index ${r}`);if(a+=Rk({panelConstraints:n,panelIndex:r,size:100})-e,r+=o,r<0||r>=n.length)break}const i=Math.min(Math.abs(e),Math.abs(a));e=e<0?0-i:i}{let o=e<0?s:l;for(;o>=0&&o<n.length;){const r=Math.abs(e)-Math.abs(c),a=t[o];Mk(null!=a,`Previous layout not found for panel index ${o}`);const s=Rk({panelConstraints:n,panelIndex:o,size:a-r});if(!Pk(a,s)&&(c+=a-s,i[o]=s,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?o--:o++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let o=0;o<e.length;o++)if(!Pk(e[o],t[o],n))return!1;return!0}(r,i))return r;{const o=e<0?l:s,r=t[o];Mk(null!=r,`Previous layout not found for panel index ${o}`);const a=r+c,d=Rk({panelConstraints:n,panelIndex:o,size:a});if(i[o]=d,!Pk(d,a)){let t=a-d;let o=e<0?l:s;for(;o>=0&&o<n.length;){const r=i[o];Mk(null!=r,`Previous layout not found for panel index ${o}`);const a=Rk({panelConstraints:n,panelIndex:o,size:r+t});if(Pk(r,a)||(t-=a-r,i[o]=a),Pk(t,0))break;e>0?o--:o++}}}return Pk(i.reduce(((e,t)=>t+e),0),100)?i:r}function zk({layout:e,panelsArray:t,pivotIndices:n}){let o=0,r=100,a=0,i=0;const s=n[0];Mk(null!=s,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===s?(o=c,r=l):(a+=c,i+=l)}));return{valueMax:Math.min(r,100-a),valueMin:Math.max(o,100-i),valueNow:e[s]}}function Fk(e,t=document){return Array.from(t.querySelectorAll(`[data-panel-resize-handle-id][data-panel-group-id="${e}"]`))}function Bk(e,t,n=document){const o=Fk(e,n).findIndex((e=>e.getAttribute("data-panel-resize-handle-id")===t));return null!=o?o:null}function Uk(e,t,n){const o=Bk(e,t,n);return null!=o?[o,o+1]:[-1,-1]}function Vk(e,t=document){var n;if(t instanceof HTMLElement&&(null==t||null===(n=t.dataset)||void 0===n?void 0:n.panelGroupId)==e)return t;const o=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return o||null}function Hk(e,t=document){const n=t.querySelector(`[data-panel-resize-handle-id="${e}"]`);return n||null}function $k({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:o,panelDataArray:r,panelGroupElement:a,setLayout:i}){$w({didWarnAboutMissingResizeHandle:!1}),Xw((()=>{if(!a)return;const e=Fk(n,a);for(let t=0;t<r.length-1;t++){const{valueMax:n,valueMin:a,valueNow:i}=zk({layout:o,panelsArray:r,pivotIndices:[t,t+1]}),s=e[t];if(null==s);else{const e=r[t];Mk(e,`No panel data found for index "${t}"`),s.setAttribute("aria-controls",e.id),s.setAttribute("aria-valuemax",""+Math.round(n)),s.setAttribute("aria-valuemin",""+Math.round(a)),s.setAttribute("aria-valuenow",null!=i?""+Math.round(i):"")}}return()=>{e.forEach(((e,t)=>{e.removeAttribute("aria-controls"),e.removeAttribute("aria-valuemax"),e.removeAttribute("aria-valuemin"),e.removeAttribute("aria-valuenow")}))}}),[n,o,r,a]),Bw((()=>{if(!a)return;const e=t.current;Mk(e,"Eager values not found");const{panelDataArray:r}=e;Mk(null!=Vk(n,a),`No group found for id "${n}"`);const s=Fk(n,a);Mk(s,`No resize handles found for group id "${n}"`);const l=s.map((e=>{const t=e.getAttribute("data-panel-resize-handle-id");Mk(t,"Resize handle element has no handle id attribute");const[s,l]=function(e,t,n,o=document){var r,a,i,s;const l=Hk(t,o),c=Fk(e,o),d=l?c.indexOf(l):-1;return[null!==(r=null===(a=n[d])||void 0===a?void 0:a.id)&&void 0!==r?r:null,null!==(i=null===(s=n[d+1])||void 0===s?void 0:s.id)&&void 0!==i?i:null]}(n,t,r,a);if(null==s||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=r.findIndex((e=>e.id===s));if(l>=0){const e=r[l];Mk(e,`No panel data found for index ${l}`);const s=o[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=s&&d){const e=Lk({delta:Pk(s,c)?u-c:c-s,initialLayout:o,panelConstraints:r.map((e=>e.constraints)),pivotIndices:Uk(n,t,a),prevLayout:o,trigger:"keyboard"});o!==e&&i(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[a,e,t,n,o,r,i])}function Wk(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function Gk(e,t){const n="horizontal"===e,{x:o,y:r}=sk(t);return n?o:r}function qk(e,t,n,o,r,a){if(rk(e)){const t="horizontal"===n;let o=0;o=e.shiftKey?100:null!=r?r:10;let a=0;switch(e.key){case"ArrowDown":a=t?0:o;break;case"ArrowLeft":a=t?-o:0;break;case"ArrowRight":a=t?o:0;break;case"ArrowUp":a=t?0:-o;break;case"End":a=100;break;case"Home":a=-100}return a}return null==o?0:function(e,t,n,o,r){const a="horizontal"===n,i=Hk(t,r);Mk(i,`No resize handle element found for id "${t}"`);const s=i.getAttribute("data-panel-group-id");Mk(s,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=o;const c=Gk(n,e),d=Vk(s,r);Mk(d,`No group element found for id "${s}"`);const u=d.getBoundingClientRect();return(c-l)/(a?u.width:u.height)*100}(e,t,n,o,a)}function Yk(e,t,n){t.forEach(((t,o)=>{const r=e[o];Mk(r,`Panel data not found for index ${o}`);const{callbacks:a,constraints:i,id:s}=r,{collapsedSize:l=0,collapsible:c}=i,d=n[s];if(null==d||t!==d){n[s]=t;const{onCollapse:e,onExpand:o,onResize:r}=a;r&&r(t,d),c&&(e||o)&&(!o||null!=d&&!Dk(d,l)||Dk(t,l)||o(),!e||null!=d&&Dk(d,l)||!Dk(t,l)||e())}}))}function Xk(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!=t[n])return!1;return!0}function Kk(e){try{if("undefined"==typeof localStorage)throw new Error("localStorage not supported in this environment");e.getItem=e=>localStorage.getItem(e),e.setItem=(e,t)=>{localStorage.setItem(e,t)}}catch(t){console.error(t),e.getItem=()=>null,e.setItem=()=>{}}}function Jk(e){return`react-resizable-panels:${e}`}function Zk(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:o,order:r}=e;return o?n:r?`${r}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function Qk(e,t){try{const n=Jk(e),o=t.getItem(n);if(o){const e=JSON.parse(o);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function eS(e,t,n,o,r){var a;const i=Jk(e),s=Zk(t),l=null!==(a=Qk(e,r))&&void 0!==a?a:{};l[s]={expandToSizes:Object.fromEntries(n.entries()),layout:o};try{r.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function tS({layout:e,panelConstraints:t}){const n=[...e],o=n.reduce(((e,t)=>e+t),0);if(n.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${n.map((e=>`${e}%`)).join(", ")}`);if(!Pk(o,100))for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const t=100/o*e;n[a]=t}let r=0;for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const o=Rk({panelConstraints:t,panelIndex:a,size:e});e!=o&&(r+=e-o,n[a]=o)}if(!Pk(r,0))for(let a=0;a<t.length;a++){const e=n[a];Mk(null!=e,`No layout data found for index ${a}`);const o=Rk({panelConstraints:t,panelIndex:a,size:e+r});if(e!==o&&(r-=o-e,n[a]=o,Pk(r,0)))break}return n}const nS={getItem:e=>(Kk(nS),nS.getItem(e)),setItem:(e,t)=>{Kk(nS),nS.setItem(e,t)}},oS={};function rS({autoSaveId:e=null,children:t,className:n="",direction:o,forwardedRef:r,id:a=null,onLayout:i=null,keyboardResizeBy:s=null,storage:l=nS,style:c,tagName:d="div",...u}){const h=Zw(a),f=$w(null),[m,p]=Ww(null),[g,v]=Ww([]),y=$w({}),x=$w(new Map),b=$w(0),w=$w({autoSaveId:e,direction:o,dragState:m,id:h,keyboardResizeBy:s,onLayout:i,storage:l}),k=$w({layout:g,panelDataArray:[],panelDataArrayChanged:!1});$w({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),Uw(r,(()=>({getId:()=>w.current.id,getLayout:()=>{const{layout:e}=k.current;return e},setLayout:e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current,r=tS({layout:e,panelConstraints:o.map((e=>e.constraints))});Wk(n,r)||(v(r),k.current.layout=r,t&&t(r),Yk(o,r,y.current))}})),[]),Xw((()=>{w.current.autoSaveId=e,w.current.direction=o,w.current.dragState=m,w.current.id=h,w.current.onLayout=i,w.current.storage=l})),$k({committedValuesRef:w,eagerValuesRef:k,groupId:h,layout:g,panelDataArray:k.current.panelDataArray,setLayout:v,panelGroupElement:f.current}),Bw((()=>{const{panelDataArray:t}=k.current;if(e){if(0===g.length||g.length!==t.length)return;let n=oS[e];null==n&&(n=function(e,t=10){let n=null;return(...o)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...o)}),t)}}(eS,100),oS[e]=n);const o=[...t],r=new Map(x.current);n(e,o,r,g,l)}}),[e,g,l]),Bw((()=>{}));const S=zw((e=>{const{onLayout:t}=w.current,{layout:n,panelDataArray:o}=k.current;if(e.constraints.collapsible){const r=o.map((e=>e.constraints)),{collapsedSize:a=0,panelSize:i,pivotIndices:s}=sS(o,e,n);if(Mk(null!=i,`Panel size not found for panel "${e.id}"`),!Dk(i,a)){x.current.set(e.id,i);const l=Lk({delta:iS(o,e)===o.length-1?i-a:a-i,initialLayout:n,panelConstraints:r,pivotIndices:s,prevLayout:n,trigger:"imperative-api"});Xk(n,l)||(v(l),k.current.layout=l,t&&t(l),Yk(o,l,y.current))}}}),[]),N=zw(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current;if(e.constraints.collapsible){const a=r.map((e=>e.constraints)),{collapsedSize:i=0,panelSize:s=0,minSize:l=0,pivotIndices:c}=sS(r,e,o),d=null!=t?t:l;if(Dk(s,i)){const t=x.current.get(e.id),i=null!=t&&t>=d?t:d,l=Lk({delta:iS(r,e)===r.length-1?s-i:i-s,initialLayout:o,panelConstraints:a,pivotIndices:c,prevLayout:o,trigger:"imperative-api"});Xk(o,l)||(v(l),k.current.layout=l,n&&n(l),Yk(r,l,y.current))}}}),[]),C=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{panelSize:o}=sS(n,e,t);return Mk(null!=o,`Panel size not found for panel "${e.id}"`),o}),[]),E=zw(((e,t)=>{const{panelDataArray:n}=k.current,o=iS(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:o,panelIndex:r,precision:a=3}){const i=n[r];let s;return s=null==i?null!=e?e.toPrecision(a):"1":1===o.length?"1":i.toPrecision(a),{flexBasis:0,flexGrow:s,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:m,layout:g,panelData:n,panelIndex:o})}),[m,g]),j=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=sS(n,e,t);return Mk(null!=a,`Panel size not found for panel "${e.id}"`),!0===r&&Dk(a,o)}),[]),_=zw((e=>{const{layout:t,panelDataArray:n}=k.current,{collapsedSize:o=0,collapsible:r,panelSize:a}=sS(n,e,t);return Mk(null!=a,`Panel size not found for panel "${e.id}"`),!r||Ok(a,o)>0}),[]),I=zw((e=>{const{panelDataArray:t}=k.current;t.push(e),t.sort(((e,t)=>{const n=e.order,o=t.order;return null==n&&null==o?0:null==n?-1:null==o?1:n-o})),k.current.panelDataArrayChanged=!0}),[]);Xw((()=>{if(k.current.panelDataArrayChanged){k.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=w.current,{layout:o,panelDataArray:r}=k.current;let a=null;if(e){const t=function(e,t,n){var o,r;return null!==(r=(null!==(o=Qk(e,n))&&void 0!==o?o:{})[Zk(t)])&&void 0!==r?r:null}(e,r,n);t&&(x.current=new Map(Object.entries(t.expandToSizes)),a=t.layout)}null==a&&(a=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let o=0,r=100;for(let a=0;a<e.length;a++){const e=n[a];Mk(e,`Panel constraints not found for index ${a}`);const{defaultSize:i}=e;null!=i&&(o++,t[a]=i,r-=i)}for(let a=0;a<e.length;a++){const i=n[a];Mk(i,`Panel constraints not found for index ${a}`);const{defaultSize:s}=i;if(null!=s)continue;const l=r/(e.length-o);o++,t[a]=l,r-=l}return t}({panelDataArray:r}));const i=tS({layout:a,panelConstraints:r.map((e=>e.constraints))});Wk(o,i)||(v(i),k.current.layout=i,t&&t(i),Yk(r,i,y.current))}})),Xw((()=>{const e=k.current;return()=>{e.layout=[]}}),[]);const A=zw((e=>function(t){t.preventDefault();const n=f.current;if(!n)return()=>null;const{direction:o,dragState:r,id:a,keyboardResizeBy:i,onLayout:s}=w.current,{layout:l,panelDataArray:c}=k.current,{initialLayout:d}=null!=r?r:{},u=Uk(a,e,n);let h=qk(t,e,o,r,i,n);if(0===h)return;const m="horizontal"===o;"rtl"===document.dir&&m&&(h=-h);const p=Lk({delta:h,initialLayout:null!=d?d:l,panelConstraints:c.map((e=>e.constraints)),pivotIndices:u,prevLayout:l,trigger:rk(t)?"keyboard":"mouse-or-touch"}),g=!Xk(l,p);(ak(t)||ik(t))&&b.current!=h&&(b.current=h,_k(e,g?0:m?h<0?mk:pk:h<0?gk:vk)),g&&(v(p),k.current.layout=p,s&&s(p),Yk(c,p,y.current))}),[]),T=zw(((e,t)=>{const{onLayout:n}=w.current,{layout:o,panelDataArray:r}=k.current,a=r.map((e=>e.constraints)),{panelSize:i,pivotIndices:s}=sS(r,e,o);Mk(null!=i,`Panel size not found for panel "${e.id}"`);const l=Lk({delta:iS(r,e)===r.length-1?i-t:t-i,initialLayout:o,panelConstraints:a,pivotIndices:s,prevLayout:o,trigger:"imperative-api"});Xk(o,l)||(v(l),k.current.layout=l,n&&n(l),Yk(r,l,y.current))}),[]),M=zw(((e,t)=>{const{layout:n,panelDataArray:o}=k.current,{collapsedSize:r=0,collapsible:a}=t,{collapsedSize:i=0,collapsible:s,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=sS(o,e,n);null!=d&&(a&&s&&Dk(d,r)?Dk(r,i)||T(e,i):d<c?T(e,c):d>l&&T(e,l))}),[T]),O=zw(((e,t)=>{const{direction:n}=w.current,{layout:o}=k.current;if(!f.current)return;const r=Hk(e,f.current);Mk(r,`Drag handle element not found for id "${e}"`);const a=Gk(n,t);p({dragHandleId:e,dragHandleRect:r.getBoundingClientRect(),initialCursorPosition:a,initialLayout:o})}),[]),D=zw((()=>{p(null)}),[]),P=zw((e=>{const{panelDataArray:t}=k.current,n=iS(t,e);n>=0&&(t.splice(n,1),delete y.current[e.id],k.current.panelDataArrayChanged=!0)}),[]),R=Hw((()=>({collapsePanel:S,direction:o,dragState:m,expandPanel:N,getPanelSize:C,getPanelStyle:E,groupId:h,isPanelCollapsed:j,isPanelExpanded:_,reevaluatePanelConstraints:M,registerPanel:I,registerResizeHandle:A,resizePanel:T,startDragging:O,stopDragging:D,unregisterPanel:P,panelGroupElement:f.current})),[S,m,o,N,C,E,h,j,_,M,I,A,T,O,D,P]),L={display:"flex",flexDirection:"horizontal"===o?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return Dw(Yw.Provider,{value:R},Dw(d,{...u,children:t,className:n,id:a,ref:f,style:{...L,...c},"data-panel-group":"","data-panel-group-direction":o,"data-panel-group-id":h}))}const aS=Lw(((e,t)=>Dw(rS,{...e,forwardedRef:t})));function iS(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function sS(e,t,n){const o=iS(e,t),r=o===e.length-1?[o-1,o]:[o,o+1],a=n[o];return{...t.constraints,panelSize:a,pivotIndices:r}}function lS({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:o,id:r,onDragging:a,style:i={},tabIndex:s=0,tagName:l="div",...c}){var d,u;const h=$w(null),f=$w({onDragging:a});Bw((()=>{f.current.onDragging=a}));const m=Fw(Yw);if(null===m)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:p,groupId:g,registerResizeHandle:v,startDragging:y,stopDragging:x,panelGroupElement:b}=m,w=Zw(r),[k,S]=Ww("inactive"),[N,C]=Ww(!1),[E,j]=Ww(null),_=$w({state:k});Xw((()=>{_.current.state=k})),Bw((()=>{if(n)j(null);else{const e=v(w);j((()=>e))}}),[n,w,v]);const I=null!==(d=null==o?void 0:o.coarse)&&void 0!==d?d:15,A=null!==(u=null==o?void 0:o.fine)&&void 0!==u?u:5;Bw((()=>{if(n||null==E)return;const e=h.current;Mk(e,"Element ref not attached");return function(e,t,n,o,r){var a;const{ownerDocument:i}=t,s={direction:n,element:t,hitAreaMargins:o,setResizeHandlerState:r},l=null!==(a=wk.get(i))&&void 0!==a?a:0;return wk.set(i,l+1),Sk.add(s),Ak(),function(){var t;kk.delete(e),Sk.delete(s);const n=null!==(t=wk.get(i))&&void 0!==t?t:1;wk.set(i,n-1),Ak(),1===n&&wk.delete(i)}}(w,e,p,{coarse:I,fine:A},((e,t,n)=>{if(t)switch(e){case"down":{S("drag"),y(w,n);const{onDragging:e}=f.current;e&&e(!0);break}case"move":{const{state:e}=_.current;"drag"!==e&&S("hover"),E(n);break}case"up":{S("hover"),x();const{onDragging:e}=f.current;e&&e(!1);break}}else S("inactive")}))}),[I,p,n,A,v,w,E,y,x]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:o}){Bw((()=>{if(e||null==n||null==o)return;const r=Hk(t,o);if(null==r)return;const a=e=>{if(!e.defaultPrevented)switch(e.key){case"ArrowDown":case"ArrowLeft":case"ArrowRight":case"ArrowUp":case"End":case"Home":e.preventDefault(),n(e);break;case"F6":{e.preventDefault();const n=r.getAttribute("data-panel-group-id");Mk(n,`No group element found for id "${n}"`);const a=Fk(n,o),i=Bk(n,t,o);Mk(null!==i,`No resize element found for id "${t}"`),a[e.shiftKey?i>0?i-1:a.length-1:i+1<a.length?i+1:0].focus();break}}};return r.addEventListener("keydown",a),()=>{r.removeEventListener("keydown",a)}}),[o,e,t,n])}({disabled:n,handleId:w,resizeHandler:E,panelGroupElement:b});return Dw(l,{...c,children:e,className:t,id:r,onBlur:()=>C(!1),onFocus:()=>C(!0),ref:h,role:"separator",style:{touchAction:"none",userSelect:"none",...i},tabIndex:s,"data-panel-group-direction":p,"data-panel-group-id":g,"data-resize-handle":"","data-resize-handle-active":"drag"===k?"pointer":N?"keyboard":void 0,"data-resize-handle-state":k,"data-panel-resize-handle-enabled":!n,"data-panel-resize-handle-id":w})}rS.displayName="PanelGroup",aS.displayName="forwardRef(PanelGroup)",lS.displayName="PanelResizeHandle";const cS=e=>{const t=b(3);let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx("path",{d:"M205.28 31.36c14.096 14.88 20.016 35.2 22.512 63.68c6.626 0 12.805 1.47 16.976 7.152l7.792 10.56A17.55 17.55 0 0 1 256 123.2v28.688c-.008 3.704-1.843 7.315-4.832 9.504C215.885 187.222 172.35 208 128 208c-49.066 0-98.19-28.273-123.168-46.608c-2.989-2.189-4.825-5.8-4.832-9.504V123.2c0-3.776 1.2-7.424 3.424-10.464l7.792-10.544c4.173-5.657 10.38-7.152 16.992-7.152c2.496-28.48 8.4-48.8 22.512-63.68C77.331 3.165 112.567.06 127.552 0H128c14.72 0 50.4 2.88 77.28 31.36m-77.264 47.376c-3.04 0-6.544.176-10.272.544c-1.312 4.896-3.248 9.312-6.08 12.128c-11.2 11.2-24.704 12.928-31.936 12.928c-6.802 0-13.927-1.42-19.744-5.088c-5.502 1.808-10.786 4.415-11.136 10.912c-.586 12.28-.637 24.55-.688 36.824c-.026 6.16-.05 12.322-.144 18.488c.024 3.579 2.182 6.903 5.44 8.384C79.936 185.92 104.976 192 128.016 192c23.008 0 48.048-6.08 74.512-18.144c3.258-1.48 5.415-4.805 5.44-8.384c.317-18.418.062-36.912-.816-55.312h.016c-.342-6.534-5.648-9.098-11.168-10.912c-5.82 3.652-12.927 5.088-19.728 5.088c-7.232 0-20.72-1.728-31.936-12.928c-2.832-2.816-4.768-7.232-6.08-12.128a106 106 0 0 0-10.24-.544m-26.941 43.93c5.748 0 10.408 4.66 10.408 10.409v19.183c0 5.749-4.66 10.409-10.408 10.409s-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408m53.333 0c5.749 0 10.409 4.66 10.409 10.409v19.183c0 5.749-4.66 10.409-10.409 10.409c-5.748 0-10.408-4.66-10.408-10.409v-19.183c0-5.748 4.66-10.408 10.408-10.408M81.44 28.32c-11.2 1.12-20.64 4.8-25.44 9.92c-10.4 11.36-8.16 40.16-2.24 46.24c4.32 4.32 12.48 7.2 21.28 7.2c6.72 0 19.52-1.44 30.08-12.16c4.64-4.48 7.52-15.68 7.2-27.04c-.32-9.12-2.88-16.64-6.72-19.84c-4.16-3.68-13.6-5.28-24.16-4.32m68.96 4.32c-3.84 3.2-6.4 10.72-6.72 19.84c-.32 11.36 2.56 22.56 7.2 27.04c10.56 10.72 23.36 12.16 30.08 12.16c8.8 0 16.96-2.88 21.28-7.2c5.92-6.08 8.16-34.88-2.24-46.24c-4.8-5.12-14.24-8.8-25.44-9.92c-10.56-.96-20 .64-24.16 4.32M128 56c-2.56 0-5.6.16-8.96.48c.32 1.76.48 3.68.64 5.76c0 1.44 0 2.88-.16 4.48c3.2-.32 5.92-.32 8.48-.32s5.28 0 8.48.32c-.16-1.6-.16-3.04-.16-4.48c.16-2.08.32-4 .64-5.76c-3.36-.32-6.4-.48-8.96-.48"}),t[0]=n):n=t[0],t[1]!==e?(o=k.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...e,children:n}),t[1]=e,t[2]=o):o=t[2],o},dS=e=>{const t=b(17);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,selected:n,className:o,...r}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=!n&&"hover:bg-[var(--sage-3)]",l=n&&"bg-[var(--sage-4)]";let c,d;t[6]!==s||t[7]!==l||t[8]!==o?(c=rn("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",s,l,o),t[6]=s,t[7]=l,t[8]=o,t[9]=c):c=t[9],t[10]!==c||t[11]!==r||t[12]!==a?(d=k.jsx("div",{className:c,...r,children:a}),t[10]=c,t[11]=r,t[12]=a,t[13]=d):d=t[13];const u=d;if(i){let e;return t[14]!==i||t[15]!==u?(e=k.jsx(N,{content:i,side:"top",delayDuration:200,children:u}),t[14]=i,t[15]=u,t[16]=e):e=t[16],e}return u},uS=()=>{var e;const t=b(10),n=le(fS),o=le(de),r=(null==(e=null==n?void 0:n.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:a}=mS();if(!o){let e,n;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(Fc,{className:"h-4 w-4 opacity-60"}),t[0]=e):e=t[0],t[1]!==a?(n=k.jsx(dS,{tooltip:"Assist is disabled",selected:!1,onClick:a,children:e}),t[1]=a,t[2]=n):n=t[2],n}let i,s,l,c;return t[3]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("b",{children:"Assist model:"}),t[3]=i):i=t[3],t[4]!==r?(s=k.jsxs(k.Fragment,{children:[i," ",r]}),t[4]=r,t[5]=s):s=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Fc,{className:"h-4 w-4"}),t[6]=l):l=t[6],t[7]!==s||t[8]!==a?(c=k.jsx(dS,{tooltip:s,onClick:a,selected:!1,children:l}),t[7]=s,t[8]=a,t[9]=c):c=t[9],c},hS=Z((e=>e(ni).completion.copilot)),fS=Z((e=>e(ni).ai));function mS(){const e=b(5),t=ce(Ys),n=ce(Os);let o;e[0]!==t||e[1]!==n?(o=()=>{t("ai"),n(!0)},e[0]=t,e[1]=n,e[2]=o):o=e[2];const r=o;let a;return e[3]!==r?(a={handleClick:r},e[3]=r,e[4]=a):a=e[4],a}const pS=()=>{const e=b(1);if("github"===le(hS)){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(gS,{}),e[0]=t):t=e[0],t}return null},gS=()=>{const e=b(10),t=le(Xs),n=null!==le(Ks),{handleClick:o}=mS(),r=t?"Ready":"Not connected";let a,i,s,l;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsx("b",{children:"GitHub Copilot:"}),e[0]=a):a=e[0],e[1]!==r?(i=k.jsxs(k.Fragment,{children:[a," ",r]}),e[1]=r,e[2]=i):i=e[2],e[3]!==n||e[4]!==t?(s=k.jsx("span",{children:n?k.jsx(oi,{className:"h-4 w-4"}):k.jsx(cS,{className:rn("h-4 w-4",!t&&"opacity-60")})}),e[3]=n,e[4]=t,e[5]=s):s=e[5],e[6]!==i||e[7]!==o||e[8]!==s?(l=k.jsx(dS,{tooltip:i,selected:!1,onClick:o,children:s}),e[6]=i,e[7]=o,e[8]=s,e[9]=l):l=e[9],l},vS=e=>{const t=b(18),[n,o]=r.useState(0),a=le(sl);let i,s,l,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=()=>o((e=>e+1)),s={delayMs:1e4,whenVisible:!0},t[0]=i,t[1]=s):(i=t[0],s=t[1]),qs(i,s),t[2]!==a.state?(l=async()=>D()||a.state!==ll.OPEN?null:ri(),t[2]=a.state,t[3]=l):l=t[3],t[4]!==n||t[5]!==a.state?(c=[n,a.state],t[4]=n,t[5]=a.state,t[6]=c):c=t[6];const{data:d}=sn(l,c);let u,h,f,m,p;return t[7]!==d?(u=d&&k.jsx(xS,{memory:d.memory,kernel:d.kernel,server:d.server}),t[7]=d,t[8]=u):u=t[8],t[9]!==d?(h=d&&k.jsx(bS,{cpu:d.cpu}),t[9]=d,t[10]=h):h=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(f=k.jsxs("div",{className:"flex items-center",children:[k.jsx(uS,{}),k.jsx(pS,{})]}),t[11]=f):f=t[11],t[12]!==a.state?(m=k.jsx(yS,{connection:a.state}),t[12]=a.state,t[13]=m):m=t[13],t[14]!==u||t[15]!==h||t[16]!==m?(p=k.jsxs("div",{className:"flex gap-2 items-center",children:[u,h,f,m]}),t[14]=u,t[15]=h,t[16]=m,t[17]=p):p=t[17],p},yS=e=>{const t=b(18),{connection:n}=e;let o,r,a,i,s,l,c;return t[0]!==n?(o=O(n.toLowerCase()),t[0]=n,t[1]=o):o=t[1],t[2]!==n?(r=n===ll.OPEN&&k.jsx(Kl,{className:"w-4 h-4"}),t[2]=n,t[3]=r):r=t[3],t[4]!==n?(a=n===ll.CLOSED&&k.jsx(Js,{className:"w-4 h-4"}),t[4]=n,t[5]=a):a=t[5],t[6]!==n?(i=n===ll.CONNECTING&&k.jsx(oi,{size:"small"}),t[6]=n,t[7]=i):i=t[7],t[8]!==n?(s=n===ll.CLOSING&&k.jsx(oi,{className:"text-destructive",size:"small"}),t[8]=n,t[9]=s):s=t[9],t[10]!==r||t[11]!==a||t[12]!==i||t[13]!==s?(l=k.jsxs("div",{children:[r,a,i,s]}),t[10]=r,t[11]=a,t[12]=i,t[13]=s,t[14]=l):l=t[14],t[15]!==o||t[16]!==l?(c=k.jsx(N,{delayDuration:200,content:o,children:l}),t[15]=o,t[16]=l,t[17]=c):c=t[17],c},xS=e=>{const t=b(25),{memory:n,kernel:o,server:r}=e,{percent:a,total:i,used:s}=n;let l;t[0]!==a?(l=Math.round(a),t[0]=a,t[1]=l):l=t[1];const c=l;let d,u,h,f,m,p,g,v,y,x;return t[2]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx("b",{children:"computer memory:"}),t[2]=d):d=t[2],t[3]!==s?(u=SS(s),t[3]=s,t[4]=u):u=t[4],t[5]!==i?(h=SS(i),t[5]=i,t[6]=h):h=t[6],t[7]!==u||t[8]!==h||t[9]!==c?(f=k.jsxs("span",{children:[d," ",u," / ",h," GB (",c,"%)"]}),t[7]=u,t[8]=h,t[9]=c,t[10]=f):f=t[10],t[11]!==(null==r?void 0:r.memory)?(m=(null==r?void 0:r.memory)&&k.jsxs("span",{children:[k.jsx("b",{children:"marimo server:"})," ",kS(r.memory)]}),t[11]=null==r?void 0:r.memory,t[12]=m):m=t[12],t[13]!==(null==o?void 0:o.memory)?(p=(null==o?void 0:o.memory)&&k.jsxs("span",{children:[k.jsx("b",{children:"kernel:"})," ",kS(o.memory)]}),t[13]=null==o?void 0:o.memory,t[14]=p):p=t[14],t[15]!==f||t[16]!==m||t[17]!==p?(g=k.jsxs("div",{className:"flex flex-col gap-1",children:[f,m,p]}),t[15]=f,t[16]=m,t[17]=p,t[18]=g):g=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(bc,{className:"w-4 h-4"}),t[19]=v):v=t[19],t[20]!==c?(y=k.jsxs("div",{className:"flex items-center gap-1",children:[v,k.jsx(wS,{percent:c})]}),t[20]=c,t[21]=y):y=t[21],t[22]!==g||t[23]!==y?(x=k.jsx(N,{delayDuration:200,content:g,children:y}),t[22]=g,t[23]=y,t[24]=x):x=t[24],x},bS=e=>{const t=b(11),{cpu:n}=e,{percent:o}=n;let r;t[0]!==o?(r=Math.round(o),t[0]=o,t[1]=r):r=t[1];const a=r;let i,s,l,c,d;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx("b",{children:"CPU:"}),t[2]=i):i=t[2],t[3]!==a?(s=k.jsxs("span",{children:[i," ",a,"%"]}),t[3]=a,t[4]=s):s=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(Zs,{className:"w-4 h-4"}),t[5]=l):l=t[5],t[6]!==a?(c=k.jsxs("div",{className:"flex items-center gap-1",children:[l,k.jsx(wS,{percent:a})]}),t[6]=a,t[7]=c):c=t[7],t[8]!==s||t[9]!==c?(d=k.jsx(N,{delayDuration:200,content:s,children:c}),t[8]=s,t[9]=c,t[10]=d):d=t[10],d},wS=e=>{const t=b(2),{percent:n}=e,o=`${n}%`;let r;return t[0]!==o?(r=k.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:k.jsx("div",{className:"h-full bg-primary",style:{width:o}})}),t[0]=o,t[1]=r):r=t[1],r};function kS(e){return e>1073741824?`${SS(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function SS(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}const NS=e=>le(Da)[e.capability]?e.children:null,CS=()=>{const e=b(56),{selectedPanel:t,isTerminalOpen:n}=Qd(),{openApplication:o,toggleTerminal:r}=eu(),[a,i]=Oe(),s=le(ai),l=ES,c=tu.find(jS);let d;$t(c,"Error panel not found"),e[0]!==r?(d=()=>{r()},e[0]=r,e[1]=d):d=e[1],Cs("global.toggleTerminal",d);const u=dS,h=c.tooltip,f=t===c.type,m=()=>o(c.type),p=l(c,s>0?"text-destructive":"");let g,v,y,x,w;e[2]!==s?(g=k.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:s}),e[2]=s,e[3]=g):g=e[3],e[4]!==u||e[5]!==c.tooltip||e[6]!==f||e[7]!==m||e[8]!==p||e[9]!==g?(v=k.jsxs(u,{tooltip:h,selected:f,onClick:m,children:[p,g]}),e[4]=u,e[5]=c.tooltip,e[6]=f,e[7]=m,e[8]=p,e[9]=g,e[10]=v):v=e[10],e[11]!==r?(y=()=>r(),e[11]=r,e[12]=y):y=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(x=k.jsx(qc,{className:"h-5 w-5"}),e[13]=x):x=e[13],e[14]!==n||e[15]!==y?(w=k.jsx(NS,{capability:"terminal",children:k.jsx(dS,{tooltip:"Open terminal",selected:n,onClick:y,children:x})}),e[14]=n,e[15]=y,e[16]=w):w=e[16];const S=a.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let C,E,j;e[17]!==a||e[18]!==i?(C=async()=>{const e={...a,runtime:{...a.runtime,auto_instantiate:!a.runtime.auto_instantiate}};await Pe({config:e}).then((()=>i(e)))},e[17]=a,e[18]=i,e[19]=C):C=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(E=k.jsx("span",{children:"on startup: "}),e[20]=E):E=e[20],e[21]!==a.runtime.auto_instantiate?(j=a.runtime.auto_instantiate?k.jsx(td,{size:14}):k.jsx(ed,{size:14}),e[21]=a.runtime.auto_instantiate,e[22]=j):j=e[22];const _=a.runtime.auto_instantiate?"autorun":"lazy";let I,A,T,M;e[23]!==_?(I=k.jsx("span",{children:_}),e[23]=_,e[24]=I):I=e[24],e[25]!==j||e[26]!==I?(A=k.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[E,j,I]}),e[25]=j,e[26]=I,e[27]=A):A=e[27],e[28]!==S||e[29]!==C||e[30]!==A?(T=k.jsx(dS,{tooltip:S,selected:!1,onClick:C,children:A}),e[28]=S,e[29]=C,e[30]=A,e[31]=T):T=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[32]=M):M=e[32];const O="autorun"===a.runtime.on_cell_change?"Disable autorun":"Enable autorun";let P,R,L,z,F,B,U,V,H,$;return e[33]!==a||e[34]!==i?(P=async()=>{const e={...a,runtime:{...a.runtime,on_cell_change:"autorun"===a.runtime.on_cell_change?"lazy":"autorun"}};await Pe({config:e}).then((()=>i(e)))},e[33]=a,e[34]=i,e[35]=P):P=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(R=k.jsx("span",{children:"on cell change: "}),e[36]=R):R=e[36],e[37]!==a.runtime.on_cell_change?(L=k.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[R,"autorun"===a.runtime.on_cell_change?k.jsx(td,{size:14}):k.jsx(ed,{size:14}),k.jsx("span",{children:a.runtime.on_cell_change})]}),e[37]=a.runtime.on_cell_change,e[38]=L):L=e[38],e[39]!==O||e[40]!==P||e[41]!==L?(z=k.jsx(dS,{tooltip:O,selected:!1,onClick:P,children:L}),e[39]=O,e[40]=P,e[41]=L,e[42]=z):z=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(F=k.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[43]=F):F=e[43],e[44]!==a||e[45]!==i?(B=!D()&&k.jsx(dS,{tooltip:null,selected:!1,children:k.jsxs(Bt,{children:[k.jsxs(Dt,{className:"font-prose text-sm flex items-center gap-1",children:[k.jsx("span",{children:"on module change: "}),"off"===a.runtime.auto_reload&&k.jsx(Js,{size:14}),"lazy"===a.runtime.auto_reload&&k.jsx(ed,{size:14}),"autorun"===a.runtime.auto_reload&&k.jsx(td,{size:14}),k.jsx("span",{children:a.runtime.auto_reload}),k.jsx(Ce,{size:14})]}),k.jsx(Ut,{children:["off","lazy","autorun"].map((e=>k.jsxs(Ot,{onClick:async()=>{const t={...a,runtime:{...a.runtime,auto_reload:e}};await Pe({config:t}).then((()=>i(t)))},children:["off"===e&&k.jsx(Js,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&k.jsx(ed,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&k.jsx(td,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),e[44]=a,e[45]=i,e[46]=B):B=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(U=k.jsx("div",{className:"mx-auto"}),e[47]=U):U=e[47],e[48]===Symbol.for("react.memo_cache_sentinel")?(V=k.jsx(Pu,{children:k.jsx(N,{content:k.jsx("div",{className:"w-[200px]",children:"Kiosk mode is enabled. This allows you to view the outputs of the cells without the ability to edit them."}),children:k.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),H=k.jsx(vS,{}),e[48]=V,e[49]=H):(V=e[48],H=e[49]),e[50]!==v||e[51]!==w||e[52]!==T||e[53]!==z||e[54]!==B?($=k.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md pl-1 pr-4 border-t border-border select-none no-print text-sm shadow-[0_0_4px_1px_rgba(0,0,0,0.1)] z-50 print:hidden hide-on-fullscreen",children:[v,w,T,M,z,F,B,U,V,H]}),e[50]=v,e[51]=w,e[52]=T,e[53]=z,e[54]=B,e[55]=$):$=e[55],$};function ES(e,t){const{Icon:n}=e;return k.jsx(n,{className:rn("h-5 w-5",t)})}function jS(e){return"errors"===e.type}const _S=e=>{const t=b(6),{children:n}=e,{openModal:o,closeModal:r}=w();let a,i;return t[0]!==o||t[1]!==r?(a=()=>o(k.jsx(AS,{onClose:r})),t[0]=o,t[1]=r,t[2]=a):a=t[2],t[3]!==a||t[4]!==n?(i=k.jsx(ii,{onClick:a,children:n}),t[3]=a,t[4]=n,t[5]=i):i=t[5],i},IS={"😡":1,"🙁":2,"😐":3,"🙂":4,"😍":5},AS=e=>{const t=b(13),{onClose:n}=e;let o,r,a,i,s,l,c,d;return t[0]!==n?(o=async e=>{e.preventDefault();const t=new FormData(e.target),o=t.get("rating"),r=t.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:o,message:r})}),n(),re({title:"Feedback sent!",description:"Thank you for your feedback!"})},t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(j,{children:"Send Feedback"}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(a=k.jsxs(Ie,{children:[r,k.jsxs(_,{children:["Let us know what you think about marimo! If you have a bug that you would like to report, please use the"," ",k.jsx("a",{href:Ze.issuesPage,target:"_blank",rel:"noreferrer",className:"underline",children:"GitHub issue tracker"}),"."]}),k.jsx(_,{children:"Your feedback is anonymous and will help us improve marimo. Thank you!"})]}),t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[k.jsx("div",{className:"flex gap-5 justify-center",children:Object.entries(IS).map(TS)}),k.jsx(si,{id:"message",name:"message",autoFocus:!0,placeholder:"Your feedback; if you'd like us to respond, please include your email!",rows:5,required:!0,autoComplete:"off"})]}),t[4]=i):i=t[4],t[5]!==n?(s=k.jsx(C,{"data-testid":"feedback-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),t[5]=n,t[6]=s):s=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(C,{"data-testid":"feedback-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[7]=l):l=t[7],t[8]!==s?(c=k.jsxs(I,{children:[s,l]}),t[8]=s,t[9]=c):c=t[9],t[10]!==o||t[11]!==c?(d=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:o,children:[a,i,c]})}),t[10]=o,t[11]=c,t[12]=d):d=t[12],d};function TS(e){const[t,n]=e;return k.jsxs("label",{className:"flex flex-col items-center select-none",children:[k.jsx("input",{type:"radio",className:"peer hidden",name:"rating",value:n,"aria-label":t},t),k.jsx("span",{className:"text-4xl peer-checked:opacity-100 opacity-40 cursor-pointer",children:t})]},t)}const MS=()=>{const e=b(10),{selectedPanel:t}=Qd(),{openApplication:n}=eu(),o=PS;let r,a,i,s,l,c;if(e[0]!==t||e[1]!==n){r="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",a=tu.filter(RS).map((e=>k.jsx(DS,{tooltip:e.tooltip,selected:t===e.type,onClick:()=>n(e.type),children:o(e)},e.type))),e[0]=t,e[1]=n,e[2]=r,e[3]=a}else r=e[2],a=e[3];return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=k.jsx(_S,{children:k.jsx(DS,{tooltip:"Send feedback!",selected:!1,children:k.jsx(wc,{className:"h-5 w-5"})})}),s=k.jsx("div",{className:"flex-1"}),l=k.jsx(OS,{}),e[4]=i,e[5]=s,e[6]=l):(i=e[4],s=e[5],l=e[6]),e[7]!==r||e[8]!==a?(c=k.jsxs("div",{className:r,children:[a,i,s,l]}),e[7]=r,e[8]=a,e[9]=c):c=e[9],c},OS=()=>{const e=b(9),t=le(li);let n,o,r,a;return e[0]!==t?(n=t>0?k.jsxs("span",{children:[t," cell",t>1?"s":""," queued or running"]}):"No cells queued or running",e[0]=t,e[1]=n):n=e[1],e[2]!==t?(o=Array.from({length:t}).map(LS),e[2]=t,e[3]=o):o=e[3],e[4]!==o?(r=k.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:o}),e[4]=o,e[5]=r):r=e[5],e[6]!==n||e[7]!==r?(a=k.jsx(N,{content:n,side:"right",delayDuration:200,children:r}),e[6]=n,e[7]=r,e[8]=a):a=e[8],a},DS=e=>{const t=b(17);let n,o,r,a,i;t[0]!==e?(({children:a,tooltip:i,selected:n,className:o,...r}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a,t[5]=i):(n=t[1],o=t[2],r=t[3],a=t[4],i=t[5]);const s=!n&&"hover:bg-[var(--sage-3)]",l=n&&"bg-[var(--sage-4)]";let c,d,u;return t[6]!==s||t[7]!==l||t[8]!==o?(c=rn("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",s,l,o),t[6]=s,t[7]=l,t[8]=o,t[9]=c):c=t[9],t[10]!==c||t[11]!==r||t[12]!==a?(d=k.jsx("div",{className:c,...r,children:a}),t[10]=c,t[11]=r,t[12]=a,t[13]=d):d=t[13],t[14]!==i||t[15]!==d?(u=k.jsx(N,{content:i,side:"right",delayDuration:200,children:d}),t[14]=i,t[15]=d,t[16]=u):u=t[16],u};function PS(e,t){const{Icon:n}=e;return k.jsx(n,{className:rn("h-5 w-5",t)})}function RS(e){return!e.hidden&&"sidebar"===e.position}function LS(e,t){return k.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())}st.record(st.tuple([st.number(),st.number()]));let zS=null;const FS=e=>{const t=b(12),{title:n,description:o,icon:r}=e;let a,i,s,l,c;return t[0]!==r?(a=r&&u.cloneElement(r,{className:"text-accent-foreground"}),t[0]=r,t[1]=a):a=t[1],t[2]!==n?(i=k.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),t[2]=n,t[3]=i):i=t[3],t[4]!==a||t[5]!==i?(s=k.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[a,i]}),t[4]=a,t[5]=i,t[6]=s):s=t[6],t[7]!==o?(l=k.jsx("span",{className:"text-muted-foreground text-sm",children:o}),t[7]=o,t[8]=l):l=t[8],t[9]!==s||t[10]!==l?(c=k.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[s,l]}),t[9]=s,t[10]=l,t[11]=c):c=t[11],c},BS=()=>{const e=b(5),t=ci();if(0===t.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No errors!",icon:k.jsx(_c,{})}),e[0]=t):t=e[0],t}let n,o;return e[1]!==t?(n=t.map(US),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(o=k.jsx("div",{className:"flex flex-col overflow-auto",children:n}),e[3]=n,e[4]=o):o=e[4],o};function US(e){return k.jsxs("div",{children:[k.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:k.jsx(di,{cellId:e.cellId})}),k.jsx("div",{className:"px-2",children:k.jsx(ui,{errors:e.output.data},e.cellId)},e.cellId)]},e.cellId)}const VS=()=>{const e=b(6),{items:t}=le(hi);let n,o;e[0]!==t?(o=Il(t),e[0]=t,e[1]=o):o=e[1],n=o;const r=n,{activeHeaderId:a}=Al(r);if(0===t.length){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:k.jsx(Lc,{})}),e[2]=t):t=e[2],t}let i;return e[3]!==t||e[4]!==a?(i=k.jsx(Tl,{items:t,activeHeaderId:a}),e[3]=t,e[4]=a,e[5]=i):i=e[5],i};function HS(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,o=0;o<e.length;o++)""!==(n=HS(e[o]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:$S}=u,{useSyncExternalStoreWithSelector:WS}=fi,GS=e=>e;function qS(e,t=GS,n){const o=WS(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return $S(o),o}const YS=(e,t)=>{const n=mi(e),o=(e,o=t)=>qS(n,e,o);return Object.assign(o,n),o};function XS(e,t){if(Object.is(e,t))return!0;if("object"!=typeof e||null===e||"object"!=typeof t||null===t)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[n,o]of e)if(!Object.is(o,t.get(n)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(t,o)||!Object.is(e[o],t[o]))return!1;return!0}function KS(e,t){if(e=function(e){let t;for(;t=e.sourceEvent;)e=t;return e}(e),void 0===t&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=e.clientX,o.y=e.clientY,[(o=o.matrixTransform(t.getScreenCTM().inverse())).x,o.y]}if(t.getBoundingClientRect){var r=t.getBoundingClientRect();return[e.clientX-r.left-t.clientLeft,e.clientY-r.top-t.clientTop]}}return[e.pageX,e.pageY]}const JS={passive:!1},ZS={capture:!0,passive:!1};function QS(e){e.stopImmediatePropagation()}function eN(e){e.preventDefault(),e.stopImmediatePropagation()}function tN(e){var t=e.document.documentElement,n=Ol(e).on("dragstart.drag",eN,ZS);"onselectstart"in t?n.on("selectstart.drag",eN,ZS):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function nN(e,t){var n=e.document.documentElement,o=Ol(e).on("dragstart.drag",null);t&&(o.on("click.drag",eN,ZS),setTimeout((function(){o.on("click.drag",null)}),0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const oN=e=>()=>e;function rN(e,{sourceEvent:t,subject:n,target:o,identifier:r,active:a,x:i,y:s,dx:l,dy:c,dispatch:d}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:a,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:s,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function aN(e){return!e.ctrlKey&&!e.button}function iN(){return this.parentNode}function sN(e,t){return null==t?{x:e.x,y:e.y}:t}function lN(){return navigator.maxTouchPoints||"ontouchstart"in this}rN.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const cN=e=>()=>e;function dN(e,{sourceEvent:t,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function uN(e){e.stopImmediatePropagation()}function hN(e){e.preventDefault(),e.stopImmediatePropagation()}function fN(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function mN(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e).hasAttribute("viewBox")?[[(e=e.viewBox.baseVal).x,e.y],[e.x+e.width,e.y+e.height]]:[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]:[[0,0],[e.clientWidth,e.clientHeight]]}function pN(){return this.__zoom||Dl}function gN(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function vN(){return navigator.maxTouchPoints||"ontouchstart"in this}function yN(e,t,n){var o=e.invertX(t[0][0])-n[0][0],r=e.invertX(t[1][0])-n[1][0],a=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),i>a?(a+i)/2:Math.min(0,a)||Math.max(0,i))}const xN=r.createContext(null),bN=xN.Provider,wN=e=>`Node type "${e}" not found. Using fallback type "default".`,kN=()=>"The React Flow parent container needs a width and a height to render the graph.",SN=()=>"Only child nodes can use a parent extent.",NN=e=>`Marker type "${e}" doesn't exist.`,CN=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,EN=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",jN=e=>`Edge type "${e}" not found. Using fallback type "default".`,_N=e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,IN=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function AN(e,t){const n=r.useContext(xN);if(null===n)throw new Error(IN);return qS(n,e,t)}const TN=()=>{const e=r.useContext(xN);if(null===e)throw new Error(IN);return r.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},MN=e=>e.userSelectionActive?"none":"all";function ON({position:e,children:t,className:n,style:o,...r}){const a=AN(MN),i=`${e}`.split("-");return u.createElement("div",{className:HS(["react-flow__panel",n,...i]),style:{...o,pointerEvents:a},...r},t)}function DN({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:u.createElement(ON,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},u.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var PN=r.memo((({x:e,y:t,label:n,labelStyle:o={},labelShowBg:a=!0,labelBgStyle:i={},labelBgPadding:s=[2,4],labelBgBorderRadius:l=2,children:c,className:d,...h})=>{const f=r.useRef(null),[m,p]=r.useState({x:0,y:0,width:0,height:0}),g=HS(["react-flow__edge-textwrapper",d]);return r.useEffect((()=>{if(f.current){const e=f.current.getBBox();p({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?u.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:g,visibility:m.width?"visible":"hidden",...h},a&&u.createElement("rect",{width:m.width+2*s[0],x:-s[0],y:-s[1],height:m.height+2*s[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),u.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:f,style:o},n),c):null}));const RN=e=>({width:e.offsetWidth,height:e.offsetHeight}),LN=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),zN=(e={x:0,y:0},t)=>({x:LN(e.x,t[0][0],t[1][0]),y:LN(e.y,t[0][1],t[1][1])}),FN=(e,t,n)=>e<t?LN(Math.abs(e-t),1,50)/50:e>n?-LN(Math.abs(e-n),1,50)/50:0,BN=(e,t)=>[20*FN(e.x,35,t.width-35),20*FN(e.y,35,t.height-35)],UN=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},VN=({x:e,y:t,width:n,height:o})=>({x:e,y:t,x2:e+n,y2:t+o}),HN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),$N=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),o=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*o)},WN=e=>!isNaN(e)&&isFinite(e),GN=Symbol.for("internals"),qN=["Enter"," ","Escape"];function YN(e){var t,n;const o=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,r=(null==(n=null==(t=o.composedPath)?void 0:t.call(o))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==r?void 0:r.nodeName)||(null==r?void 0:r.hasAttribute("contenteditable"))||!!(null==r?void 0:r.closest(".nokey"))}const XN=e=>"clientX"in e,KN=(e,t)=>{var n,o;const r=XN(e),a=r?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,i=r?e.clientY:null==(o=e.touches)?void 0:o[0].clientY;return{x:a-((null==t?void 0:t.left)??0),y:i-((null==t?void 0:t.top)??0)}},JN=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},ZN=({id:e,path:t,labelX:n,labelY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m=20})=>u.createElement(u.Fragment,null,u.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&u.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&WN(n)&&WN(o)?u.createElement(PN,{x:n,y:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c}):null);function QN(e,t,n){return void 0===n?n:o=>{const r=t().edges.find((t=>t.id===e));r&&n(o,{...r})}}function eC({sourceX:e,sourceY:t,targetX:n,targetY:o}){const r=Math.abs(n-e)/2,a=n<e?n+r:n-r,i=Math.abs(o-t)/2;return[a,o<t?o+i:o-i,r,i]}function tC({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:r,sourceControlY:a,targetControlX:i,targetControlY:s}){const l=.125*e+.375*r+.375*i+.125*n,c=.125*t+.375*a+.375*s+.125*o;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var nC,oC,rC,aC,iC,sC,lC,cC,dC,uC,hC,fC;function mC({pos:e,x1:t,y1:n,x2:o,y2:r}){return e===hC.Left||e===hC.Right?[.5*(t+o),n]:[t,.5*(n+r)]}function pC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top}){const[i,s]=mC({pos:n,x1:e,y1:t,x2:o,y2:r}),[l,c]=mC({pos:a,x1:o,y1:r,x2:e,y2:t}),[d,u,h,f]=tC({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:i,sourceControlY:s,targetControlX:l,targetControlY:c});return[`M${e},${t} C${i},${s} ${l},${c} ${o},${r}`,d,u,h,f]}ZN.displayName="BaseEdge",(oC=nC||(nC={})).Strict="strict",oC.Loose="loose",(aC=rC||(rC={})).Free="free",aC.Vertical="vertical",aC.Horizontal="horizontal",(sC=iC||(iC={})).Partial="partial",sC.Full="full",(cC=lC||(lC={})).Bezier="default",cC.Straight="straight",cC.Step="step",cC.SmoothStep="smoothstep",cC.SimpleBezier="simplebezier",(uC=dC||(dC={})).Arrow="arrow",uC.ArrowClosed="arrowclosed",(fC=hC||(hC={})).Left="left",fC.Top="top",fC.Right="right",fC.Bottom="bottom";const gC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=hC.Bottom,targetPosition:a=hC.Top,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})=>{const[v,y,x]=pC({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a});return u.createElement(ZN,{path:v,labelX:y,labelY:x,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:g})}));gC.displayName="SimpleBezierEdge";const vC={[hC.Left]:{x:-1,y:0},[hC.Right]:{x:1,y:0},[hC.Top]:{x:0,y:-1},[hC.Bottom]:{x:0,y:1}},yC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xC({source:e,sourcePosition:t=hC.Bottom,target:n,targetPosition:o=hC.Top,center:r,offset:a}){const i=vC[t],s=vC[o],l={x:e.x+i.x*a,y:e.y+i.y*a},c={x:n.x+s.x*a,y:n.y+s.y*a},d=(({source:e,sourcePosition:t=hC.Bottom,target:n})=>t===hC.Left||t===hC.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:t,target:c}),u=0!==d.x?"x":"y",h=d[u];let f,m,p=[];const g={x:0,y:0},v={x:0,y:0},[y,x,b,w]=eC({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[u]*s[u]==-1){f=r.x??y,m=r.y??x;const e=[{x:f,y:l.y},{x:f,y:c.y}],t=[{x:l.x,y:m},{x:c.x,y:m}];p=i[u]===h?"x"===u?e:t:"x"===u?t:e}else{const r=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(p="x"===u?i.x===h?d:r:i.y===h?r:d,t===o){const t=Math.abs(e[u]-n[u]);if(t<=a){const o=Math.min(a-1,a-t);i[u]===h?g[u]=(l[u]>e[u]?-1:1)*o:v[u]=(c[u]>n[u]?-1:1)*o}}if(t!==o){const e="x"===u?"y":"x",t=i[u]===s[e],n=l[e]>c[e],o=l[e]<c[e];(1===i[u]&&(!t&&n||t&&o)||1!==i[u]&&(!t&&o||t&&n))&&(p="x"===u?r:d)}const y={x:l.x+g.x,y:l.y+g.y},x={x:c.x+v.x,y:c.y+v.y};Math.max(Math.abs(y.x-p[0].x),Math.abs(x.x-p[0].x))>=Math.max(Math.abs(y.y-p[0].y),Math.abs(x.y-p[0].y))?(f=(y.x+x.x)/2,m=p[0].y):(f=p[0].x,m=(y.y+x.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...p,{x:c.x+v.x,y:c.y+v.y},n],f,m,b,w]}function bC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top,borderRadius:i=5,centerX:s,centerY:l,offset:c=20}){const[d,u,h,f,m]=xC({source:{x:e,y:t},sourcePosition:n,target:{x:o,y:r},targetPosition:a,center:{x:s,y:l},offset:c});return[d.reduce(((e,t,n)=>{let o="";return o=n>0&&n<d.length-1?function(e,t,n,o){const r=Math.min(yC(e,t)/2,yC(t,n)/2,o),{x:a,y:i}=t;if(e.x===a&&a===n.x||e.y===i&&i===n.y)return`L${a} ${i}`;if(e.y===i)return`L ${a+r*(e.x<n.x?-1:1)},${i}Q ${a},${i} ${a},${i+r*(e.y<n.y?1:-1)}`;const s=e.x<n.x?1:-1;return`L ${a},${i+r*(e.y<n.y?-1:1)}Q ${a},${i} ${a+r*s},${i}`}(d[n-1],t,d[n+1],i):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=o}),""),u,h,f,m]}const wC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:h=hC.Bottom,targetPosition:f=hC.Top,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[y,x,b]=bC({sourceX:e,sourceY:t,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return u.createElement(ZN,{path:y,labelX:x,labelY:b,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:m,markerStart:p,interactionWidth:v})}));wC.displayName="SmoothStepEdge";const kC=r.memo((e=>{var t;return u.createElement(wC,{...e,pathOptions:r.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));kC.displayName="StepEdge";const SC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[p,g,v]=function({sourceX:e,sourceY:t,targetX:n,targetY:o}){const[r,a,i,s]=eC({sourceX:e,sourceY:t,targetX:n,targetY:o});return[`M ${e},${t}L ${n},${o}`,r,a,i,s]}({sourceX:e,sourceY:t,targetX:n,targetY:o});return u.createElement(ZN,{path:p,labelX:g,labelY:v,label:r,labelStyle:a,labelShowBg:i,labelBgStyle:s,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:h,markerStart:f,interactionWidth:m})}));function NC(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function CC({pos:e,x1:t,y1:n,x2:o,y2:r,c:a}){switch(e){case hC.Left:return[t-NC(t-o,a),n];case hC.Right:return[t+NC(o-t,a),n];case hC.Top:return[t,n-NC(n-r,a)];case hC.Bottom:return[t,n+NC(r-n,a)]}}function EC({sourceX:e,sourceY:t,sourcePosition:n=hC.Bottom,targetX:o,targetY:r,targetPosition:a=hC.Top,curvature:i=.25}){const[s,l]=CC({pos:n,x1:e,y1:t,x2:o,y2:r,c:i}),[c,d]=CC({pos:a,x1:o,y1:r,x2:e,y2:t,c:i}),[u,h,f,m]=tC({sourceX:e,sourceY:t,targetX:o,targetY:r,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${s},${l} ${c},${d} ${o},${r}`,u,h,f,m]}SC.displayName="StraightEdge";const jC=r.memo((({sourceX:e,sourceY:t,targetX:n,targetY:o,sourcePosition:r=hC.Bottom,targetPosition:a=hC.Top,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,pathOptions:g,interactionWidth:v})=>{const[y,x,b]=EC({sourceX:e,sourceY:t,sourcePosition:r,targetX:n,targetY:o,targetPosition:a,curvature:null==g?void 0:g.curvature});return u.createElement(ZN,{path:y,labelX:x,labelY:b,label:i,labelStyle:s,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:p,interactionWidth:v})}));jC.displayName="BezierEdge";const _C=r.createContext(null),IC=_C.Provider;_C.Consumer;const AC=({source:e,sourceHandle:t,target:n,targetHandle:o})=>`reactflow__edge-${e}${t||""}-${n}${o||""}`,TC=(e,t)=>{if(void 0===e)return"";if("string"==typeof e)return e;return`${t?`${t}__`:""}${Object.keys(e).sort().map((t=>`${t}=${e[t]}`)).join("&")}`},MC=({x:e,y:t},[n,o,r],a,[i,s])=>{const l={x:(e-n)/r,y:(t-o)/r};return a?{x:i*Math.round(l.x/i),y:s*Math.round(l.y/s)}:l},OC=({x:e,y:t},[n,o,r])=>({x:e*r+n,y:t*r+o}),DC=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],o=(e.height??0)*t[1],r={x:e.position.x-n,y:e.position.y-o};return{...r,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-o}:r}},PC=(e,t=[0,0])=>{if(0===e.length)return{x:0,y:0,width:0,height:0};return(({x:e,y:t,x2:n,y2:o})=>({x:e,y:t,width:n-e,height:o-t}))(e.reduce(((e,n)=>{const{x:o,y:r}=DC(n,t).positionAbsolute;return a=e,i=VN({x:o,y:r,width:n.width||0,height:n.height||0}),{x:Math.min(a.x,i.x),y:Math.min(a.y,i.y),x2:Math.max(a.x2,i.x2),y2:Math.max(a.y2,i.y2)};var a,i}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},RC=(e,t,[n,o,r]=[0,0,1],a=!1,i=!1,s=[0,0])=>{const l={x:(t.x-n)/r,y:(t.y-o)/r,width:t.width/r,height:t.height/r},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:o=!0,hidden:r=!1}=e;if(i&&!o||r)return!1;const{positionAbsolute:d}=DC(e,s),u={x:d.x,y:d.y,width:t||0,height:n||0},h=$N(l,u);(void 0===t||void 0===n||null===t||null===n||a&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},LC=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},zC=(e,t,n,o,r,a=.1)=>{const i=t/(e.width*(1+a)),s=n/(e.height*(1+a)),l=Math.min(i,s),c=LN(l,o,r);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},FC=(e,t=0)=>e.transition().duration(t);function BC(e,t,n,o){return(t[n]||[]).reduce(((t,r)=>{var a,i;return`${e.id}-${r.id}-${n}`!==o&&t.push({id:r.id||null,type:n,nodeId:e.id,x:((null==(a=e.positionAbsolute)?void 0:a.x)??0)+r.x+r.width/2,y:((null==(i=e.positionAbsolute)?void 0:i.y)??0)+r.y+r.height/2}),t}),[])}const UC={source:null,target:null,sourceHandle:null,targetHandle:null},VC=()=>({handleDomNode:null,isValid:!1,connection:UC,endHandle:null});function HC(e,t,n,o,r,a,i){const s="target"===r,l=i.querySelector(`.react-flow__handle[data-id="${null==e?void 0:e.nodeId}-${null==e?void 0:e.id}-${null==e?void 0:e.type}"]`),c={...VC(),handleDomNode:l};if(l){const e=$C(void 0,l),r=l.getAttribute("data-nodeid"),i=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:s?r:n,sourceHandle:s?i:o,target:s?n:r,targetHandle:s?o:i};c.connection=h;d&&u&&(t===nC.Strict?s&&"source"===e||!s&&"target"===e:r!==n||i!==o)&&(c.endHandle={nodeId:r,handleId:i,type:e},c.isValid=a(h))}return c}function $C(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function WC(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function GC(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function qC({event:e,handleId:t,nodeId:n,onConnect:o,isTarget:r,getState:a,setState:i,isValidConnection:s,edgeUpdaterType:l,onReconnectEnd:c}){const d=UN(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:g,getNodes:v,cancelConnection:y}=a();let x,b=0;const{x:w,y:k}=KN(e),S=null==d?void 0:d.elementFromPoint(w,k),N=$C(l,S),C=null==h?void 0:h.getBoundingClientRect();if(!C||!N)return;let E,j=KN(e,C),_=!1,I=null,A=!1,T=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:o}){return e.reduce(((e,r)=>{if(r[GN]){const{handleBounds:a}=r[GN];let i=[],s=[];a&&(i=BC(r,a,"source",`${t}-${n}-${o}`),s=BC(r,a,"target",`${t}-${n}-${o}`)),e.push(...i,...s)}return e}),[])}({nodes:v(),nodeId:n,handleId:t,handleType:N}),O=()=>{if(!f)return;const[e,t]=BN(j,C);g({x:e,y:t}),b=requestAnimationFrame(O)};function D(e){const{transform:o}=a();j=KN(e,C);const{handle:l,validHandleResult:c}=function(e,t,n,o,r,a){const{x:i,y:s}=KN(e),l=t.elementsFromPoint(i,s).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=$C(void 0,l),o=l.getAttribute("data-handleid"),i=a({nodeId:e,id:o,type:t});if(i){const a=r.find((n=>n.nodeId===e&&n.type===t&&n.id===o));return{handle:{id:o,type:t,nodeId:e,x:(null==a?void 0:a.x)||n.x,y:(null==a?void 0:a.y)||n.y},validHandleResult:i}}}}let c=[],d=1/0;if(r.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=o){const n=a(e);t<=d&&(t<d?c=[{handle:e,validHandleResult:n}]:t===d&&c.push({handle:e,validHandleResult:n}),d=t)}})),!c.length)return{handle:null,validHandleResult:VC()};if(1===c.length)return c[0];const u=c.some((({validHandleResult:e})=>e.isValid)),h=c.some((({handle:e})=>"target"===e.type));return c.find((({handle:e,validHandleResult:t})=>h?"target"===e.type:!u||t.isValid))||c[0]}(e,d,MC(j,o,!1,[1,1]),m,M,(e=>HC(e,u,n,t,r?"target":"source",s,d)));if(x=l,_||(O(),_=!0),T=c.handleDomNode,I=c.connection,A=c.isValid,i({connectionPosition:x&&A?OC({x:x.x,y:x.y},o):j,connectionStatus:GC(!!x,A),connectionEndHandle:c.endHandle}),!x&&!A&&!T)return WC(E);I.source!==I.target&&T&&(WC(E),E=T,T.classList.add("connecting","react-flow__handle-connecting"),T.classList.toggle("valid",A),T.classList.toggle("react-flow__handle-valid",A))}function P(e){var t,n;(x||T)&&I&&A&&(null==o||o(I)),null==(n=(t=a()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),WC(E),y(),cancelAnimationFrame(b),_=!1,A=!1,I=null,T=null,d.removeEventListener("mousemove",D),d.removeEventListener("mouseup",P),d.removeEventListener("touchmove",D),d.removeEventListener("touchend",P)}i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:N,connectionStartHandle:{nodeId:n,handleId:t,type:N},connectionEndHandle:null}),null==p||p(e,{nodeId:n,handleId:t,handleType:N}),d.addEventListener("mousemove",D),d.addEventListener("mouseup",P),d.addEventListener("touchmove",D),d.addEventListener("touchend",P)}const YC=()=>!0,XC=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),KC=r.forwardRef((({type:e="source",position:t=hC.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:a=!0,isConnectableEnd:i=!0,id:s,onConnect:l,children:c,className:d,onMouseDown:h,onTouchStart:f,...m},p)=>{var g,v;const y=s||null,x="target"===e,b=TN(),w=r.useContext(_C),{connectOnClick:k,noPanClassName:S}=AN(XC,XS),{connecting:N,clickConnecting:C}=AN(((e,t,n)=>o=>{const{connectionStartHandle:r,connectionEndHandle:a,connectionClickStartHandle:i}=o;return{connecting:(null==r?void 0:r.nodeId)===e&&(null==r?void 0:r.handleId)===t&&(null==r?void 0:r.type)===n||(null==a?void 0:a.nodeId)===e&&(null==a?void 0:a.handleId)===t&&(null==a?void 0:a.type)===n,clickConnecting:(null==i?void 0:i.nodeId)===e&&(null==i?void 0:i.handleId)===t&&(null==i?void 0:i.type)===n}})(w,y,e),XS);w||null==(v=(g=b.getState()).onError)||v.call(g,"010",EN());const E=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:o}=b.getState(),r={...t,...e};if(o){const{edges:e,setEdges:t}=b.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var o;return n="id"in(o=e)&&"source"in o&&"target"in o?{...e}:{...e,id:AC(e)},((e,t)=>t.some((t=>!(t.source!==e.source||t.target!==e.target||t.sourceHandle!==e.sourceHandle&&(t.sourceHandle||e.sourceHandle)||t.targetHandle!==e.targetHandle&&(t.targetHandle||e.targetHandle)))))(n,t)?t:t.concat(n)})(r,e))}null==n||n(r),null==l||l(r)},j=e=>{if(!w)return;const t=XN(e);a&&(t&&0===e.button||!t)&&qC({event:e,handleId:y,nodeId:w,onConnect:E,isTarget:x,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||YC}),t?null==h||h(e):null==f||f(e)};return u.createElement("div",{"data-handleid":y,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${y}-${e}`,className:HS(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,d,{source:!x,target:x,connectable:o,connectablestart:a,connectableend:i,connecting:C,connectionindicator:o&&(a&&!N||i&&N)}]),onMouseDown:j,onTouchStart:j,onClick:k?t=>{const{onClickConnectStart:o,onClickConnectEnd:r,connectionClickStartHandle:i,connectionMode:s,isValidConnection:l}=b.getState();if(!w||!i&&!a)return;if(!i)return null==o||o(t,{nodeId:w,handleId:y,handleType:e}),void b.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:y}});const c=UN(t.target),d=n||l||YC,{connection:u,isValid:h}=HC({nodeId:w,id:y,type:e},s,i.nodeId,i.handleId||null,i.type,d,c);h&&E(u),null==r||r(t),b.setState({connectionClickStartHandle:null})}:void 0,ref:p,...m},c)}));KC.displayName="Handle";var JC=r.memo(KC);const ZC=({data:e,isConnectable:t,targetPosition:n=hC.Top,sourcePosition:o=hC.Bottom})=>u.createElement(u.Fragment,null,u.createElement(JC,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,u.createElement(JC,{type:"source",position:o,isConnectable:t}));ZC.displayName="DefaultNode";var QC=r.memo(ZC);const eE=({data:e,isConnectable:t,sourcePosition:n=hC.Bottom})=>u.createElement(u.Fragment,null,null==e?void 0:e.label,u.createElement(JC,{type:"source",position:n,isConnectable:t}));eE.displayName="InputNode";var tE=r.memo(eE);const nE=({data:e,isConnectable:t,targetPosition:n=hC.Top})=>u.createElement(u.Fragment,null,u.createElement(JC,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);nE.displayName="OutputNode";var oE=r.memo(nE);const rE=()=>null;rE.displayName="GroupNode";const aE=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),iE=e=>e.id;function sE(e,t){return XS(e.selectedNodes.map(iE),t.selectedNodes.map(iE))&&XS(e.selectedEdges.map(iE),t.selectedEdges.map(iE))}const lE=r.memo((({onSelectionChange:e})=>{const t=TN(),{selectedNodes:n,selectedEdges:o}=AN(aE,sE);return r.useEffect((()=>{const r={nodes:n,edges:o};null==e||e(r),t.getState().onSelectionChange.forEach((e=>e(r)))}),[n,o,e]),null}));lE.displayName="SelectionListener";const cE=e=>!!e.onSelectionChange;function dE({onSelectionChange:e}){const t=AN(cE);return e||t?u.createElement(lE,{onSelectionChange:e}):null}const uE=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function hE(e,t){r.useEffect((()=>{void 0!==e&&t(e)}),[e])}function fE(e,t,n){r.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const mE=({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:a,onConnectStart:i,onConnectEnd:s,onClickConnectStart:l,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:p,minZoom:g,maxZoom:v,nodeExtent:y,onNodesChange:x,onEdgesChange:b,elementsSelectable:w,connectionMode:k,snapGrid:S,snapToGrid:N,translateExtent:C,connectOnClick:E,defaultEdgeOptions:j,fitView:_,fitViewOptions:I,onNodesDelete:A,onEdgesDelete:T,onNodeDrag:M,onNodeDragStart:O,onNodeDragStop:D,onSelectionDrag:P,onSelectionDragStart:R,onSelectionDragStop:L,noPanClassName:z,nodeOrigin:F,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:V,onError:H,connectionRadius:$,isValidConnection:W,nodeDragThreshold:G})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:X,setMinZoom:K,setMaxZoom:J,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=AN(uE,XS),te=TN();return r.useEffect((()=>{const e=null==o?void 0:o.map((e=>({...e,...j})));return X(n,e),()=>{ee()}}),[]),fE("defaultEdgeOptions",j,te.setState),fE("connectionMode",k,te.setState),fE("onConnect",a,te.setState),fE("onConnectStart",i,te.setState),fE("onConnectEnd",s,te.setState),fE("onClickConnectStart",l,te.setState),fE("onClickConnectEnd",c,te.setState),fE("nodesDraggable",d,te.setState),fE("nodesConnectable",u,te.setState),fE("nodesFocusable",h,te.setState),fE("edgesFocusable",f,te.setState),fE("edgesUpdatable",m,te.setState),fE("elementsSelectable",w,te.setState),fE("elevateNodesOnSelect",p,te.setState),fE("snapToGrid",N,te.setState),fE("snapGrid",S,te.setState),fE("onNodesChange",x,te.setState),fE("onEdgesChange",b,te.setState),fE("connectOnClick",E,te.setState),fE("fitViewOnInit",_,te.setState),fE("fitViewOnInitOptions",I,te.setState),fE("onNodesDelete",A,te.setState),fE("onEdgesDelete",T,te.setState),fE("onNodeDrag",M,te.setState),fE("onNodeDragStart",O,te.setState),fE("onNodeDragStop",D,te.setState),fE("onSelectionDrag",P,te.setState),fE("onSelectionDragStart",R,te.setState),fE("onSelectionDragStop",L,te.setState),fE("noPanClassName",z,te.setState),fE("nodeOrigin",F,te.setState),fE("rfId",B,te.setState),fE("autoPanOnConnect",U,te.setState),fE("autoPanOnNodeDrag",V,te.setState),fE("onError",H,te.setState),fE("connectionRadius",$,te.setState),fE("isValidConnection",W,te.setState),fE("nodeDragThreshold",G,te.setState),hE(e,q),hE(t,Y),hE(g,K),hE(v,J),hE(C,Z),hE(y,Q),null},pE={display:"none"},gE={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},vE="react-flow__node-desc",yE="react-flow__edge-desc",xE=e=>e.ariaLiveMessage;function bE({rfId:e}){const t=AN(xE);return u.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gE},t)}function wE({rfId:e,disableKeyboardA11y:t}){return u.createElement(u.Fragment,null,u.createElement("div",{id:`${vE}-${e}`,style:pE},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),u.createElement("div",{id:`${yE}-${e}`,style:pE},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&u.createElement(bE,{rfId:e}))}var kE=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,o]=r.useState(!1),a=r.useRef(!1),i=r.useRef(new Set([])),[s,l]=r.useMemo((()=>{if(null!==e){const t=(Array.isArray(e)?e:[e]).filter((e=>"string"==typeof e)).map((e=>e.split("+"))),n=t.reduce(((e,t)=>e.concat(...t)),[]);return[t,n]}return[[],[]]}),[e]);return r.useEffect((()=>{const n="undefined"!=typeof document?document:null,r=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{a.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!a.current||a.current&&!t.actInsideInputWithModifier)&&YN(e))return!1;const n=NE(e.code,l);i.current.add(e[n]),SE(s,i.current,!1)&&(e.preventDefault(),o(!0))},n=e=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&YN(e))return!1;const n=NE(e.code,l);SE(s,i.current,!0)?(o(!1),i.current.clear()):i.current.delete(e[n]),"Meta"===e.key&&i.current.clear(),a.current=!1},c=()=>{i.current.clear(),o(!1)};return null==r||r.addEventListener("keydown",e),null==r||r.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==r||r.removeEventListener("keydown",e),null==r||r.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,o]),n};function SE(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function NE(e,t){return t.includes(e)?"code":"key"}function CE(e,t,n,o){var r,a;const i=e.parentNode||e.parentId;if(!i)return n;const s=t.get(i),l=DC(s,o);return CE(s,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(r=s[GN])?void 0:r.z)??0)>(n.z??0)?(null==(a=s[GN])?void 0:a.z)??0:n.z??0},o)}function EE(e,t,n){e.forEach((o=>{var r;const a=o.parentNode||o.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||(null==n?void 0:n[o.id])){const{x:a,y:i,z:s}=CE(o,e,{...o.position,z:(null==(r=o[GN])?void 0:r.z)??0},t);o.positionAbsolute={x:a,y:i},o[GN].z=s,(null==n?void 0:n[o.id])&&(o[GN].isParent=!0)}}))}function jE(e,t,n,o){const r=new Map,a={},i=o?1e3:0;return e.forEach((e=>{var n;const o=(WN(e.zIndex)?e.zIndex:0)+(e.selected?i:0),s=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(a[c]=!0);const d=(null==s?void 0:s.type)&&(null==s?void 0:s.type)!==e.type;Object.defineProperty(l,GN,{enumerable:!1,value:{handleBounds:d||null==(n=null==s?void 0:s[GN])?void 0:n.handleBounds,z:o}}),r.set(e.id,l)})),EE(r,n,a),r}function _E(e,t={}){const{getNodes:n,width:o,height:r,minZoom:a,maxZoom:i,d3Zoom:s,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(s&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const o=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?o&&t.nodes.some((t=>t.id===e.id)):o})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=PC(e,u),{x:c,y:d,zoom:h}=zC(n,o,r,t.minZoom??a,t.maxZoom??i,t.padding??.1),f=Dl.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?s.transform(FC(l,t.duration),f):s.transform(l,f),!0}}return!1}function IE(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[GN]:n[GN],selected:e.selected})})),new Map(t)}function AE(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function TE({changedNodes:e,changedEdges:t,get:n,set:o}){const{nodeInternals:r,edges:a,onNodesChange:i,onEdgesChange:s,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&o({nodeInternals:IE(e,r)}),null==i||i(e)),(null==t?void 0:t.length)&&(c&&o({edges:AE(t,a)}),null==s||s(t))}const ME=()=>{},OE={zoomIn:ME,zoomOut:ME,zoomTo:ME,getZoom:()=>1,setViewport:ME,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:ME,fitBounds:ME,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},DE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function PE(){const e=(()=>{const e=TN(),{d3Zoom:t,d3Selection:n}=AN(DE,XS);return r.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(FC(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(FC(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,o)=>t.scaleTo(FC(n,null==o?void 0:o.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(o,r)=>{const[a,i,s]=e.getState().transform,l=Dl.translate(o.x??a,o.y??i).scale(o.zoom??s);t.transform(FC(n,null==r?void 0:r.duration),l)},getViewport:()=>{const[t,n,o]=e.getState().transform;return{x:t,y:n,zoom:o}},fitView:t=>_E(e.getState,t),setCenter:(o,r,a)=>{const{width:i,height:s,maxZoom:l}=e.getState(),c=void 0!==(null==a?void 0:a.zoom)?a.zoom:l,d=i/2-o*c,u=s/2-r*c,h=Dl.translate(d,u).scale(c);t.transform(FC(n,null==a?void 0:a.duration),h)},fitBounds:(o,r)=>{const{width:a,height:i,minZoom:s,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=zC(o,a,i,s,l,(null==r?void 0:r.padding)??.1),h=Dl.translate(c,d).scale(u);t.transform(FC(n,null==r?void 0:r.duration),h)},project:t=>{const{transform:n,snapToGrid:o,snapGrid:r}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),MC(t,n,o,r)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:o,snapGrid:r,domNode:a}=e.getState();if(!a)return t;const{x:i,y:s}=a.getBoundingClientRect(),l={x:t.x-i,y:t.y-s};return MC(l,n,o,r)},flowToScreenPosition:t=>{const{transform:n,domNode:o}=e.getState();if(!o)return t;const{x:r,y:a}=o.getBoundingClientRect(),i=OC(t,n);return{x:i.x+r,y:i.y+a}},viewportInitialized:!0}:OE),[t,n])})(),t=TN(),n=r.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),o=r.useCallback((e=>t.getState().nodeInternals.get(e)),[]),a=r.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),i=r.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),s=r.useCallback((e=>{const{getNodes:n,setNodes:o,hasDefaultNodes:r,onNodesChange:a}=t.getState(),i=n(),s="function"==typeof e?e(i):e;if(r)o(s);else if(a){a(0===s.length?i.map((e=>({type:"remove",id:e.id}))):s.map((e=>({item:e,type:"reset"}))))}}),[]),l=r.useCallback((e=>{const{edges:n=[],setEdges:o,hasDefaultEdges:r,onEdgesChange:a}=t.getState(),i="function"==typeof e?e(n):e;if(r)o(i);else if(a){a(0===i.length?n.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),c=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:o,setNodes:r,hasDefaultNodes:a,onNodesChange:i}=t.getState();if(a){r([...o(),...n])}else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),d=r.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:o=[],setEdges:r,hasDefaultEdges:a,onEdgesChange:i}=t.getState();if(a)r([...o,...n]);else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),u=r.useCallback((()=>{const{getNodes:e,edges:n=[],transform:o}=t.getState(),[r,a,i]=o;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:r,y:a,zoom:i}}}),[]),h=r.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:o,getNodes:r,edges:a,hasDefaultNodes:i,hasDefaultEdges:s,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),m=r().reduce(((e,t)=>{const n=t.parentNode||t.parentId,o=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||o)&&e.push(t),e}),[]),p=a.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=p.filter((e=>f.includes(e.id)));if(m||g){const e=LC(m,p),n=[...g,...e],r=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((s||i)&&(s&&t.setState({edges:a.filter((e=>!r.includes(e.id)))}),i&&(m.forEach((e=>{o.delete(e.id)})),t.setState({nodeInternals:new Map(o)}))),r.length>0&&(null==c||c(n),u&&u(r.map((e=>({id:e,type:"remove"}))))),m.length>0&&(null==l||l(m),d)){d(m.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=r.useCallback((e=>{const n=WN((o=e).width)&&WN(o.height)&&WN(o.x)&&WN(o.y);var o;const r=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!r)return[null,null,n];return[n?e:HN(r),r,n]}),[]),m=r.useCallback(((e,n=!0,o)=>{const[r,a,i]=f(e);return r?(o||t.getState().getNodes()).filter((e=>{if(!(i||e.id!==a.id&&e.positionAbsolute))return!1;const t=HN(e),o=$N(t,r);return n&&o>0||o>=r.width*r.height})):[]}),[]),p=r.useCallback(((e,t,n=!0)=>{const[o]=f(e);if(!o)return!1;const r=$N(o,t);return n&&r>0||r>=o.width*o.height}),[]);return r.useMemo((()=>({...e,getNodes:n,getNode:o,getEdges:a,getEdge:i,setNodes:s,setEdges:l,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:p})),[e,n,o,a,i,s,l,c,d,u,h,m,p])}const RE={actInsideInputWithModifier:!1};const LE={position:"absolute",width:"100%",height:"100%",top:0,left:0},zE=e=>({x:e.x,y:e.y,zoom:e.k}),FE=(e,t)=>e.target.closest(`.${t}`),BE=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),UE=e=>{const t=e.ctrlKey&&JN()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},VE=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),HE=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:a=!0,zoomOnPinch:i=!0,panOnScroll:s=!1,panOnScrollSpeed:l=.5,panOnScrollMode:c=rC.Free,zoomOnDoubleClick:d=!0,elementsSelectable:h,panOnDrag:f=!0,defaultViewport:m,translateExtent:p,minZoom:g,maxZoom:v,zoomActivationKeyCode:y,preventScrolling:x=!0,children:b,noWheelClassName:w,noPanClassName:k})=>{const S=r.useRef(),N=TN(),C=r.useRef(!1),E=r.useRef(!1),j=r.useRef(null),_=r.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:A,d3ZoomHandler:T,userSelectionActive:M}=AN(VE,XS),O=kE(y),D=r.useRef(0),P=r.useRef(!1),R=r.useRef();return function(e){const t=TN();r.useEffect((()=>{let n;const o=()=>{var n,o;if(!e.current)return;const r=RN(e.current);0!==r.height&&0!==r.width||null==(o=(n=t.getState()).onError)||o.call(n,"004",kN()),t.setState({width:r.width||500,height:r.height||500})};return o(),window.addEventListener("resize",o),e.current&&(n=new ResizeObserver((()=>o())),n.observe(e.current)),()=>{window.removeEventListener("resize",o),n&&e.current&&n.unobserve(e.current)}}),[])}(j),r.useEffect((()=>{if(j.current){const e=j.current.getBoundingClientRect(),t=function(){var e,t,n,o=fN,r=mN,a=yN,i=gN,s=vN,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=zl,h=Ll("start","zoom","end"),f=0,m=10;function p(e){e.property("__zoom",pN).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",N).filter(s).on("touchstart.zoom",C).on("touchmove.zoom",E).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function g(e,t){return(t=Math.max(l[0],Math.min(l[1],t)))===e.k?e:new Pl(t,e.x,e.y)}function v(e,t,n){var o=t[0]-n[0]*e.k,r=t[1]-n[1]*e.k;return o===e.x&&r===e.y?e:new Pl(e.k,o,r)}function y(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,t,n,o){e.on("start.zoom",(function(){b(this,arguments).event(o).start()})).on("interrupt.zoom end.zoom",(function(){b(this,arguments).event(o).end()})).tween("zoom",(function(){var e=this,a=arguments,i=b(e,a).event(o),s=r.apply(e,a),l=null==n?y(s):"function"==typeof n?n.apply(e,a):n,c=Math.max(s[1][0]-s[0][0],s[1][1]-s[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,a):t,f=u(d.invert(l).concat(c/d.k),h.invert(l).concat(c/h.k));return function(e){if(1===e)e=h;else{var t=f(e),n=c/t[2];e=new Pl(n,l[0]-t[0]*n,l[1]-t[1]*n)}i.zoom(null,e)}}))}function b(e,t,n){return!n&&e.__zooming||new w(e,t)}function w(e,t){this.that=e,this.args=t,this.active=0,this.sourceEvent=null,this.extent=r.apply(e,t),this.taps=0}function k(e,...t){if(o.apply(this,arguments)){var n=b(this,t).event(e),r=this.__zoom,s=Math.max(l[0],Math.min(l[1],r.k*Math.pow(2,i.apply(this,arguments)))),d=KS(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=r.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(r.k===s)return;n.mouse=[d,r.invert(d)],Rl(this),n.start()}hN(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",a(v(g(r,s),n.mouse[0],n.mouse[1]),n.extent,c))}}function S(e,...t){if(!n&&o.apply(this,arguments)){var r=e.currentTarget,i=b(this,t,!0).event(e),s=Ol(e.view).on("mousemove.zoom",(function(e){if(hN(e),!i.moved){var t=e.clientX-d,n=e.clientY-u;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",a(v(i.that.__zoom,i.mouse[0]=KS(e,r),i.mouse[1]),i.extent,c))}),!0).on("mouseup.zoom",(function(e){s.on("mousemove.zoom mouseup.zoom",null),nN(e.view,i.moved),hN(e),i.event(e).end()}),!0),l=KS(e,r),d=e.clientX,u=e.clientY;tN(e.view),uN(e),i.mouse=[l,this.__zoom.invert(l)],Rl(this),i.start()}}function N(e,...t){if(o.apply(this,arguments)){var n=this.__zoom,i=KS(e.changedTouches?e.changedTouches[0]:e,this),s=n.invert(i),l=n.k*(e.shiftKey?.5:2),u=a(v(g(n,l),i,s),r.apply(this,t),c);hN(e),d>0?Ol(this).transition().duration(d).call(x,u,i,e):Ol(this).call(p.transform,u,i,e)}}function C(n,...r){if(o.apply(this,arguments)){var a,i,s,l,c=n.touches,d=c.length,u=b(this,r,n.changedTouches.length===d).event(n);for(uN(n),i=0;i<d;++i)l=[l=KS(s=c[i],this),this.__zoom.invert(l),s.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,a=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),a&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),Rl(this),u.start())}}function E(e,...t){if(this.__zooming){var n,o,r,i,s=b(this,t).event(e),l=e.changedTouches,d=l.length;for(hN(e),n=0;n<d;++n)r=KS(o=l[n],this),s.touch0&&s.touch0[2]===o.identifier?s.touch0[0]=r:s.touch1&&s.touch1[2]===o.identifier&&(s.touch1[0]=r);if(o=s.that.__zoom,s.touch1){var u=s.touch0[0],h=s.touch0[1],f=s.touch1[0],m=s.touch1[1],p=(p=f[0]-u[0])*p+(p=f[1]-u[1])*p,y=(y=m[0]-h[0])*y+(y=m[1]-h[1])*y;o=g(o,Math.sqrt(p/y)),r=[(u[0]+f[0])/2,(u[1]+f[1])/2],i=[(h[0]+m[0])/2,(h[1]+m[1])/2]}else{if(!s.touch0)return;r=s.touch0[0],i=s.touch0[1]}s.zoom("touch",a(v(o,r,i),s.extent,c))}}function j(e,...o){if(this.__zooming){var r,a,i=b(this,o).event(e),s=e.changedTouches,l=s.length;for(uN(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),r=0;r<l;++r)a=s[r],i.touch0&&i.touch0[2]===a.identifier?delete i.touch0:i.touch1&&i.touch1[2]===a.identifier&&delete i.touch1;if(i.touch1&&!i.touch0&&(i.touch0=i.touch1,delete i.touch1),i.touch0)i.touch0[1]=this.__zoom.invert(i.touch0[0]);else if(i.end(),2===i.taps&&(a=KS(a,this),Math.hypot(t[0]-a[0],t[1]-a[1])<m)){var c=Ol(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return p.transform=function(e,t,n,o){var r=e.selection?e.selection():e;r.property("__zoom",pN),e!==r?x(e,t,n,o):r.interrupt().each((function(){b(this,arguments).event(o).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},p.scaleBy=function(e,t,n,o){p.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,o)},p.scaleTo=function(e,t,n,o){p.transform(e,(function(){var e=r.apply(this,arguments),o=this.__zoom,i=null==n?y(e):"function"==typeof n?n.apply(this,arguments):n,s=o.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return a(v(g(o,l),i,s),e,c)}),n,o)},p.translateBy=function(e,t,n,o){p.transform(e,(function(){return a(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),r.apply(this,arguments),c)}),null,o)},p.translateTo=function(e,t,n,o,i){p.transform(e,(function(){var e=r.apply(this,arguments),i=this.__zoom,s=null==o?y(e):"function"==typeof o?o.apply(this,arguments):o;return a(Dl.translate(s[0],s[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),o,i)},w.prototype={event:function(e){return e&&(this.sourceEvent=e),this},start:function(){return 1==++this.active&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(e,t){return this.mouse&&"mouse"!==e&&(this.mouse[1]=t.invert(this.mouse[0])),this.touch0&&"touch"!==e&&(this.touch0[1]=t.invert(this.touch0[0])),this.touch1&&"touch"!==e&&(this.touch1[1]=t.invert(this.touch1[0])),this.that.__zoom=t,this.emit("zoom"),this},end:function(){return 0==--this.active&&(delete this.that.__zooming,this.emit("end")),this},emit:function(e){var t=Ol(this.that).datum();h.call(e,this.that,new dN(e,{sourceEvent:this.sourceEvent,target:p,type:e,transform:this.that.__zoom,dispatch:h}),t)}},p.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:cN(+e),p):i},p.filter=function(e){return arguments.length?(o="function"==typeof e?e:cN(!!e),p):o},p.touchable=function(e){return arguments.length?(s="function"==typeof e?e:cN(!!e),p):s},p.extent=function(e){return arguments.length?(r="function"==typeof e?e:cN([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),p):r},p.scaleExtent=function(e){return arguments.length?(l[0]=+e[0],l[1]=+e[1],p):[l[0],l[1]]},p.translateExtent=function(e){return arguments.length?(c[0][0]=+e[0][0],c[1][0]=+e[1][0],c[0][1]=+e[0][1],c[1][1]=+e[1][1],p):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},p.constrain=function(e){return arguments.length?(a=e,p):a},p.duration=function(e){return arguments.length?(d=+e,p):d},p.interpolate=function(e){return arguments.length?(u=e,p):u},p.on=function(){var e=h.on.apply(h,arguments);return e===h?p:e},p.clickDistance=function(e){return arguments.length?(f=(e=+e)*e,p):Math.sqrt(f)},p.tapDistance=function(e){return arguments.length?(m=+e,p):m},p}().scaleExtent([g,v]).translateExtent(p),n=Ol(j.current).call(t),o=Dl.translate(m.x,m.y).scale(LN(m.zoom,g,v)),r=[[0,0],[e.width,e.height]],a=t.constrain()(o,r,p);t.transform(n,a),t.wheelDelta(UE),N.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[a.x,a.y,a.k],domNode:j.current.closest(".react-flow")})}}),[]),r.useEffect((()=>{A&&I&&(!s||O||M?void 0!==T&&A.on("wheel.zoom",(function(e,t){if(!x&&"wheel"===e.type&&!e.ctrlKey||FE(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):A.on("wheel.zoom",(o=>{if(FE(o,w))return!1;o.preventDefault(),o.stopImmediatePropagation();const r=A.property("__zoom").k||1;if(o.ctrlKey&&i){const e=KS(o),t=UE(o),n=r*Math.pow(2,t);return void I.scaleTo(A,n,e,o)}const a=1===o.deltaMode?20:1;let s=c===rC.Vertical?0:o.deltaX*a,d=c===rC.Horizontal?0:o.deltaY*a;!JN()&&o.shiftKey&&c!==rC.Vertical&&(s=o.deltaY*a,d=0),I.translateBy(A,-s/r*l,-d/r*l,{internal:!0});const u=zE(A.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:m}=N.getState();clearTimeout(R.current),P.current||(P.current=!0,null==t||t(o,u),null==h||h(u)),P.current&&(null==e||e(o,u),null==f||f(u),R.current=setTimeout((()=>{null==n||n(o,u),null==m||m(u),P.current=!1}),150))}),{passive:!1}))}),[M,s,c,A,I,T,O,i,x,w,t,e,n]),r.useEffect((()=>{I&&I.on("start",(e=>{var n,o;if(!e.sourceEvent||e.sourceEvent.internal)return null;D.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:r}=N.getState(),a=zE(e.transform);C.current=!0,_.current=a,"mousedown"===(null==(o=e.sourceEvent)?void 0:o.type)&&N.setState({paneDragging:!0}),null==r||r(a),null==t||t(e.sourceEvent,a)}))}),[I,t]),r.useEffect((()=>{I&&(M&&!C.current?I.on("zoom",null):M||I.on("zoom",(t=>{var n;const{onViewportChange:r}=N.getState();if(N.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),E.current=!(!o||!BE(f,D.current??0)),(e||r)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=zE(t.transform);null==r||r(n),null==e||e(t.sourceEvent,n)}})))}),[M,I,e,f,o]),r.useEffect((()=>{I&&I.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=N.getState();if(C.current=!1,N.setState({paneDragging:!1}),o&&BE(f,D.current??0)&&!E.current&&o(e.sourceEvent),E.current=!1,(n||t)&&(r=_.current,a=e.transform,r.x!==a.x||r.y!==a.y||r.zoom!==a.k)){const o=zE(e.transform);_.current=o,clearTimeout(S.current),S.current=setTimeout((()=>{null==t||t(o),null==n||n(e.sourceEvent,o)}),s?150:0)}var r,a}))}),[I,s,f,n,o]),r.useEffect((()=>{I&&I.filter((e=>{const t=O||a,n=i&&e.ctrlKey;if((!0===f||Array.isArray(f)&&f.includes(1))&&1===e.button&&"mousedown"===e.type&&(FE(e,"react-flow__node")||FE(e,"react-flow__edge")))return!0;if(!(f||t||s||d||i))return!1;if(M)return!1;if(!d&&"dblclick"===e.type)return!1;if(FE(e,w)&&"wheel"===e.type)return!1;if(FE(e,k)&&("wheel"!==e.type||s&&"wheel"===e.type&&!O))return!1;if(!i&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!s&&!n&&"wheel"===e.type)return!1;if(!f&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(f)&&!f.includes(e.button)&&"mousedown"===e.type)return!1;const o=Array.isArray(f)&&f.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&o}))}),[M,I,a,i,s,d,f,h,O]),u.createElement("div",{className:"react-flow__renderer",ref:j,style:LE},b)},$E=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function WE(){const{userSelectionActive:e,userSelectionRect:t}=AN($E,XS);return e&&t?u.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function GE(e,t){const n=t.parentNode||t.parentId,o=e.find((e=>e.id===n));if(o){const e=t.position.x+t.width-o.width,n=t.position.y+t.height-o.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,e>0&&(o.style.width+=e),n>0&&(o.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);o.position.x=o.position.x-e,o.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);o.position.y=o.position.y-e,o.style.height+=e,t.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function qE(e,t){if(e.some((e=>"reset"===e.type)))return e.filter((e=>"reset"===e.type)).map((e=>e.item));const n=e.filter((e=>"add"===e.type)).map((e=>e.item));return t.reduce(((t,n)=>{const o=e.filter((e=>e.id===n.id));if(0===o.length)return t.push(n),t;const r={...n};for(const e of o)if(e)switch(e.type){case"select":r.selected=e.selected;break;case"position":void 0!==e.position&&(r.position=e.position),void 0!==e.positionAbsolute&&(r.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(r.dragging=e.dragging),r.expandParent&&GE(t,r);break;case"dimensions":void 0!==e.dimensions&&(r.width=e.dimensions.width,r.height=e.dimensions.height),void 0!==e.updateStyle&&(r.style={...r.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(r.resizing=e.resizing),r.expandParent&&GE(t,r);break;case"remove":return t}return t.push(r),t}),n)}function YE(e,t){return qE(e,t)}const XE=(e,t)=>({id:e,type:"select",selected:t});function KE(e,t){return e.reduce(((e,n)=>{const o=t.includes(n.id);return!n.selected&&o?(n.selected=!0,e.push(XE(n.id,!0))):n.selected&&!o&&(n.selected=!1,e.push(XE(n.id,!1))),e}),[])}const JE=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},ZE=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),QE=r.memo((({isSelecting:e,selectionMode:t=iC.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:a,onPaneClick:i,onPaneContextMenu:s,onPaneScroll:l,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:h,children:f})=>{const m=r.useRef(null),p=TN(),g=r.useRef(0),v=r.useRef(0),y=r.useRef(),{userSelectionActive:x,elementsSelectable:b,dragging:w}=AN(ZE,XS),k=()=>{p.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,v.current=0},S=e=>{null==i||i(e),p.getState().resetSelectedElements(),p.setState({nodesSelectionActive:!1})},N=l?e=>l(e):void 0,C=b&&(e||x);return u.createElement("div",{className:HS(["react-flow__pane",{dragging:w,selection:e}]),onClick:C?void 0:JE(S,m),onContextMenu:JE((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==s||s(e)}),m),onWheel:JE(N,m),onMouseEnter:C?void 0:c,onMouseDown:C?t=>{const{resetSelectedElements:n,domNode:r}=p.getState();if(y.current=null==r?void 0:r.getBoundingClientRect(),!b||!e||0!==t.button||t.target!==m.current||!y.current)return;const{x:a,y:i}=KN(t,y.current);n(),p.setState({userSelectionRect:{width:0,height:0,startX:a,startY:i,x:a,y:i}}),null==o||o(t)}:void 0,onMouseMove:C?n=>{const{userSelectionRect:o,nodeInternals:r,edges:a,transform:i,onNodesChange:s,onEdgesChange:l,nodeOrigin:c,getNodes:d}=p.getState();if(!e||!y.current||!o)return;p.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=KN(n,y.current),h=o.startX??0,f=o.startY??0,m={...o,x:u.x<h?u.x:h,y:u.y<f?u.y:f,width:Math.abs(u.x-h),height:Math.abs(u.y-f)},x=d(),b=RC(r,m,i,t===iC.Partial,!0,c),w=LC(b,a).map((e=>e.id)),k=b.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=KE(x,k);e.length&&(null==s||s(e))}if(v.current!==w.length){v.current=w.length;const e=KE(a,w);e.length&&(null==l||l(e))}p.setState({userSelectionRect:m})}:d,onMouseUp:C?e=>{if(0!==e.button)return;const{userSelectionRect:t}=p.getState();!x&&t&&e.target===m.current&&(null==S||S(e)),p.setState({nodesSelectionActive:g.current>0}),k(),null==a||a(e)}:void 0,onMouseLeave:C?e=>{x&&(p.setState({nodesSelectionActive:g.current>0}),null==a||a(e)),k()}:h,ref:m,style:LE},f,u.createElement(WE,null))}));function ej(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const o=t.get(n);return!!o&&(!!o.selected||ej(o,t))}function tj(e,t,n){let o=e;do{if(null==o?void 0:o.matches(t))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function nj(e,t,n,o){return Array.from(e.values()).filter((n=>(n.selected||n.id===o)&&(!n.parentNode||n.parentId||!ej(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,o;return{id:e.id,position:e.position||{x:0,y:0},positionAbsolute:e.positionAbsolute||{x:0,y:0},distance:{x:n.x-((null==(t=e.positionAbsolute)?void 0:t.x)??0),y:n.y-((null==(o=e.positionAbsolute)?void 0:o.y)??0)},delta:{x:0,y:0},extent:e.extent,parentNode:e.parentNode||e.parentId,parentId:e.parentNode||e.parentId,width:e.width,height:e.height,expandParent:e.expandParent}}))}function oj(e,t,n,o,r=[0,0],a){const i=function(e,t){return t&&"parent"!==t?[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]:t}(e,e.extent||o);let s=i;const l=e.parentNode||e.parentId;if("parent"!==e.extent||e.expandParent){if(e.extent&&l&&"parent"!==e.extent){const t=n.get(l),{x:o,y:a}=DC(t,r).positionAbsolute;s=[[e.extent[0][0]+o,e.extent[0][1]+a],[e.extent[1][0]+o,e.extent[1][1]+a]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:o,y:a}=DC(t,r).positionAbsolute;s=t&&WN(o)&&WN(a)&&WN(t.width)&&WN(t.height)?[[o+e.width*r[0],a+e.height*r[1]],[o+t.width-e.width+e.width*r[0],a+t.height-e.height+e.height*r[1]]]:s}else null==a||a("005",SN()),s=i;let c={x:0,y:0};if(l){const e=n.get(l);c=DC(e,r).positionAbsolute}const d=s&&"parent"!==s?zN(t,s):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function rj({nodeId:e,dragItems:t,nodeInternals:n}){const o=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?o.find((t=>t.id===e)):o[0],o]}QE.displayName="Pane";const aj=(e,t,n,o)=>{const r=t.querySelectorAll(e);if(!r||!r.length)return null;const a=Array.from(r),i=t.getBoundingClientRect(),s=i.width*o[0],l=i.height*o[1];return a.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-i.left-s)/n,y:(t.top-i.top-l)/n,...RN(e)}}))};function ij(e,t,n){return void 0===n?n:o=>{const r=t().nodeInternals.get(e);r&&n(o,{...r})}}function sj({id:e,store:t,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:a,multiSelectionActive:i,nodeInternals:s,onError:l}=t.getState(),c=s.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(a({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==o?void 0:o.current)?void 0:e.blur()}))):r([e])):null==l||l("012",_N(e))}function lj(e){return(t,n,o)=>null==e?void 0:e(t,o)}function cj({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:o,nodeId:a,isSelectable:i,selectNodesOnDrag:s}){const l=TN(),[c,d]=r.useState(!1),u=r.useRef([]),h=r.useRef({x:null,y:null}),f=r.useRef(0),m=r.useRef(null),p=r.useRef({x:0,y:0}),g=r.useRef(null),v=r.useRef(!1),y=r.useRef(!1),x=r.useRef(!1),b=function(){const e=TN();return r.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:o,snapToGrid:r}=e.getState(),a=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,s={x:(a-n[0])/n[2],y:(i-n[1])/n[2]};return{xSnapped:r?o[0]*Math.round(s.x/o[0]):s.x,ySnapped:r?o[1]*Math.round(s.y/o[1]):s.y,...s}}),[])}();return r.useEffect((()=>{if(null==e?void 0:e.current){const r=Ol(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:o,onSelectionDrag:r,updateNodePositions:i,nodeExtent:s,snapGrid:c,snapToGrid:f,nodeOrigin:m,onError:p}=l.getState();h.current={x:e,y:t};let v=!1,y={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&s){const e=PC(u.current,m);y=VN(e)}if(u.current=u.current.map((o=>{const r={x:e-o.distance.x,y:t-o.distance.y};f&&(r.x=c[0]*Math.round(r.x/c[0]),r.y=c[1]*Math.round(r.y/c[1]));const a=[[s[0][0],s[0][1]],[s[1][0],s[1][1]]];u.current.length>1&&s&&!o.extent&&(a[0][0]=o.positionAbsolute.x-y.x+s[0][0],a[1][0]=o.positionAbsolute.x+(o.width??0)-y.x2+s[1][0],a[0][1]=o.positionAbsolute.y-y.y+s[0][1],a[1][1]=o.positionAbsolute.y+(o.height??0)-y.y2+s[1][1]);const i=oj(o,r,n,a,m,p);return v=v||o.position.x!==i.position.x||o.position.y!==i.position.y,o.position=i.position,o.positionAbsolute=i.positionAbsolute,o})),!v)return;i(u.current,!0,!0),d(!0);const x=a?o:lj(r);if(x&&g.current){const[e,t]=rj({nodeId:a,dragItems:u.current,nodeInternals:n});x(g.current,e,t)}},w=()=>{if(!m.current)return;const[e,t]=BN(p.current,m.current);if(0!==e||0!==t){const{transform:n,panBy:o}=l.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],o({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:o,multiSelectionActive:r,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:m}=l.getState();y.current=!0;const p=a?f:lj(m);s&&i||r||!a||(null==(n=o.get(a))?void 0:n.selected)||d(),a&&i&&s&&sj({id:a,store:l,nodeRef:e});const g=b(t);if(h.current=g,u.current=nj(o,c,g,a),p&&u.current){const[e,n]=rj({nodeId:a,dragItems:u.current,nodeInternals:o});p(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,o,r=aN,a=iN,i=sN,s=lN,l={},c=Ll("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(s).on("touchstart.drag",g).on("touchmove.drag",v,JS).on("touchend.drag touchcancel.drag",y).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,s){if(!o&&r.call(this,i,s)){var l=x(this,a.call(this,i,s),i,s,"mouse");l&&(Ol(i.view).on("mousemove.drag",m,ZS).on("mouseup.drag",p,ZS),tN(i.view),QS(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function m(o){if(eN(o),!n){var r=o.clientX-e,a=o.clientY-t;n=r*r+a*a>u}l.mouse("drag",o)}function p(e){Ol(e.view).on("mousemove.drag mouseup.drag",null),nN(e.view,n),eN(e),l.mouse("end",e)}function g(e,t){if(r.call(this,e,t)){var n,o,i=e.changedTouches,s=a.call(this,e,t),l=i.length;for(n=0;n<l;++n)(o=x(this,s,e,t,i[n].identifier,i[n]))&&(QS(e),o("start",e,i[n]))}}function v(e){var t,n,o=e.changedTouches,r=o.length;for(t=0;t<r;++t)(n=l[o[t].identifier])&&(eN(e),n("drag",e,o[t]))}function y(e){var t,n,r=e.changedTouches,a=r.length;for(o&&clearTimeout(o),o=setTimeout((function(){o=null}),500),t=0;t<a;++t)(n=l[r[t].identifier])&&(QS(e),n("end",e,r[t]))}function x(e,t,n,o,r,a){var s,u,f,m=c.copy(),p=KS(a||n,t);if(null!=(f=i.call(e,new rN("beforestart",{sourceEvent:n,target:h,identifier:r,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:m}),o)))return s=f.x-p[0]||0,u=f.y-p[1]||0,function n(a,i,c){var g,v=p;switch(a){case"start":l[r]=n,g=d++;break;case"end":delete l[r],--d;case"drag":p=KS(c||i,t),g=d}m.call(a,e,new rN(a,{sourceEvent:i,subject:f,target:h,identifier:r,active:g,x:p[0]+s,y:p[1]+u,dx:p[0]-v[0],dy:p[1]-v[1],dispatch:m}),o)}}return h.filter=function(e){return arguments.length?(r="function"==typeof e?e:oN(!!e),h):r},h.container=function(e){return arguments.length?(a="function"==typeof e?e:oN(e),h):a},h.subject=function(e){return arguments.length?(i="function"==typeof e?e:oN(e),h):i},h.touchable=function(e){return arguments.length?(s="function"==typeof e?e:oN(!!e),h):s},h.on=function(){var e=c.on.apply(c,arguments);return e===c?h:e},h.clickDistance=function(e){return arguments.length?(u=(e=+e)*e,h):Math.sqrt(u)},h}().on("start",(e=>{const{domNode:t,nodeDragThreshold:n}=l.getState();0===n&&k(e),x.current=!1;const o=b(e);h.current=o,m.current=(null==t?void 0:t.getBoundingClientRect())||null,p.current=KN(e.sourceEvent,m.current)})).on("drag",(e=>{var t,n;const o=b(e),{autoPanOnNodeDrag:r,nodeDragThreshold:a}=l.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!v.current&&y.current&&r&&(v.current=!0,w()),!y.current){const r=o.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),i=o.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(r*r+i*i)>a&&k(e)}(h.current.x!==o.xSnapped||h.current.y!==o.ySnapped)&&u.current&&y.current&&(g.current=e.sourceEvent,p.current=KN(e.sourceEvent,m.current),c(o))}})).on("end",(e=>{if(y.current&&!x.current&&(d(!1),v.current=!1,y.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:o,onSelectionDragStop:r}=l.getState(),i=a?o:lj(r);if(t(u.current,!1,!1),i){const[t,o]=rj({nodeId:a,dragItems:u.current,nodeInternals:n});i(e.sourceEvent,t,o)}}})).filter((t=>{const r=t.target;return!t.button&&(!n||!tj(r,`.${n}`,e))&&(!o||tj(r,o,e))}));return r.call(t),()=>{r.on(".drag",null)}}r.on(".drag",null)}}),[e,t,n,o,i,l,a,s,b]),c}function dj(){const e=TN();return r.useCallback((t=>{const{nodeInternals:n,nodeExtent:o,updateNodePositions:r,getNodes:a,snapToGrid:i,snapGrid:s,onError:l,nodesDraggable:c}=e.getState(),d=a().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=i?s[0]:5,h=i?s[1]:5,f=t.isShiftPressed?4:1,m=t.x*u*f,p=t.y*h*f;r(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+p};i&&(t.x=s[0]*Math.round(t.x/s[0]),t.y=s[1]*Math.round(t.y/s[1]));const{positionAbsolute:r,position:a}=oj(e,t,n,o,void 0,l);e.position=a,e.positionAbsolute=r}return e})),!0,!1)}),[])}const uj={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var hj=e=>{const t=({id:t,type:n,data:o,xPos:a,yPos:i,xPosOrigin:s,yPosOrigin:l,selected:c,onClick:d,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:p,onDoubleClick:g,style:v,className:y,isDraggable:x,isSelectable:b,isConnectable:w,isFocusable:k,selectNodesOnDrag:S,sourcePosition:N,targetPosition:C,hidden:E,resizeObserver:j,dragHandle:_,zIndex:I,isParent:A,noDragClassName:T,noPanClassName:M,initialized:O,disableKeyboardA11y:D,ariaLabel:P,rfId:R,hasHandleBounds:L})=>{const z=TN(),F=r.useRef(null),B=r.useRef(null),U=r.useRef(N),V=r.useRef(C),H=r.useRef(n),$=b||x||d||h||f||m,W=dj(),G=ij(t,z.getState,h),q=ij(t,z.getState,f),Y=ij(t,z.getState,m),X=ij(t,z.getState,p),K=ij(t,z.getState,g);r.useEffect((()=>()=>{B.current&&(null==j||j.unobserve(B.current),B.current=null)}),[]),r.useEffect((()=>{if(F.current&&!E){const e=F.current;O&&L&&B.current===e||(B.current&&(null==j||j.unobserve(B.current)),null==j||j.observe(e),B.current=e)}}),[E,O,L]),r.useEffect((()=>{const e=H.current!==n,o=U.current!==N,r=V.current!==C;F.current&&(e||o||r)&&(e&&(H.current=n),o&&(U.current=N),r&&(V.current=C),z.getState().updateNodeDimensions([{id:t,nodeElement:F.current,forceUpdate:!0}]))}),[t,n,N,C]);const J=cj({nodeRef:F,disabled:E||!x,noDragClassName:T,handleSelector:_,nodeId:t,isSelectable:b,selectNodesOnDrag:S});return E?null:u.createElement("div",{className:HS(["react-flow__node",`react-flow__node-${n}`,{[M]:x},y,{selected:c,selectable:b,parent:A,dragging:J}]),ref:F,style:{zIndex:I,transform:`translate(${s}px,${l}px)`,pointerEvents:$?"all":"none",visibility:O?"visible":"hidden",...v},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:G,onMouseMove:q,onMouseLeave:Y,onContextMenu:X,onClick:e=>{const{nodeDragThreshold:n}=z.getState();if(b&&(!S||!x||n>0)&&sj({id:t,store:z,nodeRef:F}),d){const n=z.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:K,onKeyDown:k?e=>{if(!YN(e)&&!D)if(qN.includes(e.key)&&b){const n="Escape"===e.key;sj({id:t,store:z,unselect:n,nodeRef:F})}else x&&c&&Object.prototype.hasOwnProperty.call(uj,e.key)&&(z.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~a}, y: ${~~i}`}),W({x:uj[e.key].x,y:uj[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":D?void 0:`${vE}-${R}`,"aria-label":P},u.createElement(IC,{value:t},u.createElement(e,{id:t,data:o,type:n,xPos:a,yPos:i,selected:c,isConnectable:w,sourcePosition:N,targetPosition:C,dragging:J,dragHandle:_,zIndex:I})))};return t.displayName="NodeWrapper",r.memo(t)};const fj=e=>{const t=e.getNodes().filter((e=>e.selected));return{...PC(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var mj=r.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const o=TN(),{width:a,height:i,x:s,y:l,transformString:c,userSelectionActive:d}=AN(fj,XS),h=dj(),f=r.useRef(null);if(r.useEffect((()=>{var e;n||null==(e=f.current)||e.focus({preventScroll:!0})}),[n]),cj({nodeRef:f}),d||!a||!i)return null;const m=e?t=>{const n=o.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return u.createElement("div",{className:HS(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},u.createElement("div",{ref:f,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(uj,e.key)&&h({x:uj[e.key].x,y:uj[e.key].y,isShiftPressed:e.shiftKey})},style:{width:a,height:i,top:l,left:s}}))}));const pj=e=>e.nodesSelectionActive,gj=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,deleteKeyCode:l,onMove:c,onMoveStart:d,onMoveEnd:h,selectionKeyCode:f,selectionOnDrag:m,selectionMode:p,onSelectionStart:g,onSelectionEnd:v,multiSelectionKeyCode:y,panActivationKeyCode:x,zoomActivationKeyCode:b,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:N,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,preventScrolling:O,onSelectionContextMenu:D,noWheelClassName:P,noPanClassName:R,disableKeyboardA11y:L})=>{const z=AN(pj),F=kE(f),B=kE(x),U=B||_,V=B||N,H=F||m&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=TN(),{deleteElements:o}=PE(),a=kE(e,RE),i=kE(t);r.useEffect((()=>{if(a){const{edges:e,getNodes:t}=n.getState(),r=t().filter((e=>e.selected)),a=e.filter((e=>e.selected));o({nodes:r,edges:a}),n.setState({nodesSelectionActive:!1})}}),[a]),r.useEffect((()=>{n.setState({multiSelectionActive:i})}),[i])})({deleteKeyCode:l,multiSelectionKeyCode:y}),u.createElement(HE,{onMove:c,onMoveStart:d,onMoveEnd:h,onPaneContextMenu:i,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:V,panOnScrollSpeed:C,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!F&&U,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,zoomActivationKeyCode:b,preventScrolling:O,noWheelClassName:P,noPanClassName:R},u.createElement(QE,{onSelectionStart:g,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:a,onPaneContextMenu:i,onPaneScroll:s,panOnDrag:U,isSelecting:!!H,selectionMode:p},e,z&&u.createElement(mj,{onSelectionContextMenu:D,noPanClassName:R,disableKeyboardA11y:L})))};gj.displayName="FlowRenderer";var vj=r.memo(gj);function yj(e){return{...{input:hj(e.input||tE),default:hj(e.default||QC),output:hj(e.output||oE),group:hj(e.group||rE)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=hj(e[n]||QC),t)),{})}}const xj=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),bj=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:o,elementsSelectable:a,updateNodeDimensions:i,onError:s}=AN(xj,XS),l=(c=e.onlyRenderVisibleElements,AN(r.useCallback((e=>c?RC(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=r.useRef(),h=r.useMemo((()=>{if("undefined"==typeof ResizeObserver)return null;const e=new ResizeObserver((e=>{const t=e.map((e=>({id:e.target.getAttribute("data-id"),nodeElement:e.target,forceUpdate:!0})));i(t)}));return d.current=e,e}),[]);return r.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),u.createElement("div",{className:"react-flow__nodes",style:LE},l.map((r=>{var i,l,c;let d=r.type||"default";e.nodeTypes[d]||(null==s||s("003",wN(d)),d="default");const f=e.nodeTypes[d]||e.nodeTypes.default,m=!!(r.draggable||t&&void 0===r.draggable),p=!!(r.selectable||a&&void 0===r.selectable),g=!!(r.connectable||n&&void 0===r.connectable),v=!!(r.focusable||o&&void 0===r.focusable),y=e.nodeExtent?zN(r.positionAbsolute,e.nodeExtent):r.positionAbsolute,x=(null==y?void 0:y.x)??0,b=(null==y?void 0:y.y)??0,w=(({x:e,y:t,width:n,height:o,origin:r})=>n&&o?r[0]<0||r[1]<0||r[0]>1||r[1]>1?{x:e,y:t}:{x:e-n*r[0],y:t-o*r[1]}:{x:e,y:t})({x:x,y:b,width:r.width??0,height:r.height??0,origin:e.nodeOrigin});return u.createElement(f,{key:r.id,id:r.id,className:r.className,style:r.style,type:d,data:r.data,sourcePosition:r.sourcePosition||hC.Bottom,targetPosition:r.targetPosition||hC.Top,hidden:r.hidden,xPos:x,yPos:b,xPosOrigin:w.x,yPosOrigin:w.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!r.selected,isDraggable:m,isSelectable:p,isConnectable:g,isFocusable:v,resizeObserver:h,dragHandle:r.dragHandle,zIndex:(null==(i=r[GN])?void 0:i.z)??0,isParent:!!(null==(l=r[GN])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!r.width&&!!r.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:r.ariaLabel,hasHandleBounds:!!(null==(c=r[GN])?void 0:c.handleBounds)})})))};bj.displayName="NodeRenderer";var wj=r.memo(bj);const kj=(e,t,n)=>n===hC.Left?e-t:n===hC.Right?e+t:e,Sj=(e,t,n)=>n===hC.Top?e-t:n===hC.Bottom?e+t:e,Nj="react-flow__edgeupdater",Cj=({position:e,centerX:t,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:a,onMouseOut:i,type:s})=>u.createElement("circle",{onMouseDown:r,onMouseEnter:a,onMouseOut:i,className:HS([Nj,`${Nj}-${s}`]),cx:kj(t,o,e),cy:Sj(n,o,e),r:o,stroke:"transparent",fill:"transparent"}),Ej=()=>!0;var jj=e=>{const t=({id:t,className:n,type:o,data:a,onClick:i,onEdgeDoubleClick:s,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,style:v,source:y,target:x,sourceX:b,sourceY:w,targetX:k,targetY:S,sourcePosition:N,targetPosition:C,elementsSelectable:E,hidden:j,sourceHandleId:_,targetHandleId:I,onContextMenu:A,onMouseEnter:T,onMouseMove:M,onMouseLeave:O,reconnectRadius:D,onReconnect:P,onReconnectStart:R,onReconnectEnd:L,markerEnd:z,markerStart:F,rfId:B,ariaLabel:U,isFocusable:V,isReconnectable:H,pathOptions:$,interactionWidth:W,disableKeyboardA11y:G})=>{const q=r.useRef(null),[Y,X]=r.useState(!1),[K,J]=r.useState(!1),Z=TN(),Q=r.useMemo((()=>`url('#${TC(F,B)}')`),[F,B]),ee=r.useMemo((()=>`url('#${TC(z,B)}')`),[z,B]);if(j)return null;const te=QN(t,Z.getState,s),ne=QN(t,Z.getState,A),oe=QN(t,Z.getState,T),re=QN(t,Z.getState,M),ae=QN(t,Z.getState,O),ie=(e,n)=>{if(0!==e.button)return;const{edges:o,isValidConnection:r}=Z.getState(),a=n?x:y,i=(n?I:_)||null,s=n?"target":"source",l=r||Ej,c=n,d=o.find((e=>e.id===t));J(!0),null==R||R(e,d,s);qC({event:e,handleId:i,nodeId:a,onConnect:e=>null==P?void 0:P(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:s,onReconnectEnd:e=>{J(!1),null==L||L(e,d,s)}})},se=()=>X(!0),le=()=>X(!1),ce=!E&&!i;return u.createElement("g",{className:HS(["react-flow__edge",`react-flow__edge-${o}`,n,{selected:l,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:o,addSelectedEdges:r,unselectNodesAndEdges:a,multiSelectionActive:s}=Z.getState(),l=o.find((e=>e.id===t));l&&(E&&(Z.setState({nodesSelectionActive:!1}),l.selected&&s?(a({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):r([t])),i&&i(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:oe,onMouseMove:re,onMouseLeave:ae,onKeyDown:V?e=>{var n;if(!G&&qN.includes(e.key)&&E){const{unselectNodesAndEdges:o,addSelectedEdges:r,edges:a}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),o({edges:[a.find((e=>e.id===t))]})):r([t])}}:void 0,tabIndex:V?0:void 0,role:V?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${y} to ${x}`,"aria-describedby":V?`${yE}-${B}`:void 0,ref:q},!K&&u.createElement(e,{id:t,source:y,target:x,selected:l,animated:c,label:d,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:p,labelBgBorderRadius:g,data:a,style:v,sourceX:b,sourceY:w,targetX:k,targetY:S,sourcePosition:N,targetPosition:C,sourceHandleId:_,targetHandleId:I,markerStart:Q,markerEnd:ee,pathOptions:$,interactionWidth:W}),H&&u.createElement(u.Fragment,null,("source"===H||!0===H)&&u.createElement(Cj,{position:N,centerX:b,centerY:w,radius:D,onMouseDown:e=>ie(e,!0),onMouseEnter:se,onMouseOut:le,type:"source"}),("target"===H||!0===H)&&u.createElement(Cj,{position:C,centerX:k,centerY:S,radius:D,onMouseDown:e=>ie(e,!1),onMouseEnter:se,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",r.memo(t)};function _j(e){return{...{default:jj(e.default||jC),straight:jj(e.bezier||SC),step:jj(e.step||kC),smoothstep:jj(e.step||wC),simplebezier:jj(e.simplebezier||gC)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=jj(e[n]||jC),t)),{})}}function Ij(e,t,n=null){const o=((null==n?void 0:n.x)||0)+t.x,r=((null==n?void 0:n.y)||0)+t.y,a=(null==n?void 0:n.width)||t.width,i=(null==n?void 0:n.height)||t.height;switch(e){case hC.Top:return{x:o+a/2,y:r};case hC.Right:return{x:o+a,y:r+i/2};case hC.Bottom:return{x:o+a/2,y:r+i};case hC.Left:return{x:o,y:r+i/2}}}function Aj(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function Tj(e){var t,n,o,r,a;const i=(null==(t=null==e?void 0:e[GN])?void 0:t.handleBounds)||null,s=i&&(null==e?void 0:e.width)&&(null==e?void 0:e.height)&&void 0!==(null==(n=null==e?void 0:e.positionAbsolute)?void 0:n.x)&&void 0!==(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.y);return[{x:(null==(r=null==e?void 0:e.positionAbsolute)?void 0:r.x)||0,y:(null==(a=null==e?void 0:e.positionAbsolute)?void 0:a.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},i,!!s]}const Mj=[{level:0,isMaxLevel:!0,edges:[]}];function Oj(e,t,n){return function(e,t,n=!1){let o=-1;const r=e.reduce(((e,r)=>{var a,i;const s=WN(r.zIndex);let l=s?r.zIndex:0;if(n){const e=t.get(r.target),n=t.get(r.source),o=r.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(a=null==n?void 0:n[GN])?void 0:a.z)||0,(null==(i=null==e?void 0:e[GN])?void 0:i.z)||0,1e3);l=(s?r.zIndex:0)+(o?c:0)}return e[l]?e[l].push(r):e[l]=[r],o=l>o?l:o,e}),{}),a=Object.entries(r).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===o}}));return 0===a.length?Mj:a}(AN(r.useCallback((n=>e?n.edges.filter((e=>{const o=t.get(e.source),r=t.get(e.target);return(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:o,targetWidth:r,targetHeight:a,width:i,height:s,transform:l}){const c={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+r),y2:Math.max(e.y+o,t.y+a)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=VN({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:i/l[2],height:s/l[2]}),u=Math.max(0,Math.min(d.x2,c.x2)-Math.max(d.x,c.x)),h=Math.max(0,Math.min(d.y2,c.y2)-Math.max(d.y,c.y));return Math.ceil(u*h)>0}({sourcePos:o.positionAbsolute||{x:0,y:0},targetPos:r.positionAbsolute||{x:0,y:0},sourceWidth:o.width,sourceHeight:o.height,targetWidth:r.width,targetHeight:r.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const Dj={[dC.Arrow]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[dC.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>u.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const Pj=({id:e,type:t,color:n,width:o=12.5,height:a=12.5,markerUnits:i="strokeWidth",strokeWidth:s,orient:l="auto-start-reverse"})=>{const c=function(e){const t=TN();return r.useMemo((()=>{var n,o;return Object.prototype.hasOwnProperty.call(Dj,e)?Dj[e]:(null==(o=(n=t.getState()).onError)||o.call(n,"009",NN(e)),null)}),[e])}(t);return c?u.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${o}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0"},u.createElement(c,{color:n,strokeWidth:s})):null},Rj=({defaultColor:e,rfId:t})=>{const n=AN(r.useCallback((({defaultColor:e,rfId:t})=>n=>{const o=[];return n.edges.reduce(((n,r)=>([r.markerStart,r.markerEnd].forEach((r=>{if(r&&"object"==typeof r){const a=TC(r,t);o.includes(a)||(n.push({id:a,color:r.color||e,...r}),o.push(a))}})),n)),[]).sort(((e,t)=>e.id.localeCompare(t.id)))})({defaultColor:e,rfId:t}),[e,t]),((e,t)=>!(e.length!==t.length||e.some(((e,n)=>e.id!==t[n].id)))));return u.createElement("defs",null,n.map((e=>u.createElement(Pj,{id:e.id,key:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient}))))};Rj.displayName="MarkerDefinitions";var Lj=r.memo(Rj);const zj=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),Fj=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:a,onEdgeContextMenu:i,onEdgeMouseEnter:s,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,children:v,disableKeyboardA11y:y})=>{const{edgesFocusable:x,edgesUpdatable:b,elementsSelectable:w,width:k,height:S,connectionMode:N,nodeInternals:C,onError:E}=AN(zj,XS),j=Oj(t,C,n);return k?u.createElement(u.Fragment,null,j.map((({level:t,edges:n,isMaxLevel:v})=>u.createElement("svg",{key:t,style:{zIndex:t},width:k,height:S,className:"react-flow__edges react-flow__container"},v&&u.createElement(Lj,{defaultColor:e,rfId:o}),u.createElement("g",null,n.map((e=>{const[t,n,v]=Tj(C.get(e.source)),[k,S,j]=Tj(C.get(e.target));if(!v||!j)return null;let _=e.type||"default";r[_]||(null==E||E("011",jN(_)),_="default");const I=r[_]||r.default,A=N===nC.Strict?S.target:(S.target??[]).concat(S.source??[]),T=Aj(n.source,e.sourceHandle),M=Aj(A,e.targetHandle),O=(null==T?void 0:T.position)||hC.Bottom,D=(null==M?void 0:M.position)||hC.Top,P=!!(e.focusable||x&&void 0===e.focusable),R=e.reconnectable||e.updatable,L=void 0!==f&&(R||b&&void 0===R);if(!T||!M)return null==E||E("008",CN(T,e)),null;const{sourceX:z,sourceY:F,targetX:B,targetY:U}=((e,t,n,o,r,a)=>{const i=Ij(n,e,t),s=Ij(a,o,r);return{sourceX:i.x,sourceY:i.y,targetX:s.x,targetY:s.y}})(t,T,O,k,M,D);return u.createElement(I,{key:e.id,id:e.id,className:HS([e.className,a]),type:_,data:e.data,selected:!!e.selected,animated:!!e.animated,hidden:!!e.hidden,label:e.label,labelStyle:e.labelStyle,labelShowBg:e.labelShowBg,labelBgStyle:e.labelBgStyle,labelBgPadding:e.labelBgPadding,labelBgBorderRadius:e.labelBgBorderRadius,style:e.style,source:e.source,target:e.target,sourceHandleId:e.sourceHandle,targetHandleId:e.targetHandle,markerEnd:e.markerEnd,markerStart:e.markerStart,sourceX:z,sourceY:F,targetX:B,targetY:U,sourcePosition:O,targetPosition:D,elementsSelectable:w,onContextMenu:i,onMouseEnter:s,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:p,reconnectRadius:g,rfId:o,ariaLabel:e.ariaLabel,isFocusable:P,isReconnectable:L,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:y})})))))),v):null};Fj.displayName="EdgeRenderer";var Bj=r.memo(Fj);const Uj=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Vj({children:e}){const t=AN(Uj);return u.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const Hj={[hC.Left]:hC.Right,[hC.Right]:hC.Left,[hC.Top]:hC.Bottom,[hC.Bottom]:hC.Top},$j=({nodeId:e,handleType:t,style:n,type:o=lC.Bezier,CustomComponent:a,connectionStatus:i})=>{var s,l,c;const{fromNode:d,handleId:h,toX:f,toY:m,connectionMode:p}=AN(r.useCallback((t=>({fromNode:t.nodeInternals.get(e),handleId:t.connectionHandleId,toX:(t.connectionPosition.x-t.transform[0])/t.transform[2],toY:(t.connectionPosition.y-t.transform[1])/t.transform[2],connectionMode:t.connectionMode})),[e]),XS),g=null==(s=null==d?void 0:d[GN])?void 0:s.handleBounds;let v=null==g?void 0:g[t];if(p===nC.Loose&&(v=v||(null==g?void 0:g["source"===t?"target":"source"])),!d||!v)return null;const y=h?v.find((e=>e.id===h)):v[0],x=y?y.x+y.width/2:(d.width??0)/2,b=y?y.y+y.height/2:d.height??0,w=((null==(l=d.positionAbsolute)?void 0:l.x)??0)+x,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+b,S=null==y?void 0:y.position,N=S?Hj[S]:null;if(!S||!N)return null;if(a)return u.createElement(a,{connectionLineType:o,connectionLineStyle:n,fromNode:d,fromHandle:y,fromX:w,fromY:k,toX:f,toY:m,fromPosition:S,toPosition:N,connectionStatus:i});let C="";const E={sourceX:w,sourceY:k,sourcePosition:S,targetX:f,targetY:m,targetPosition:N};return o===lC.Bezier?[C]=EC(E):o===lC.Step?[C]=bC({...E,borderRadius:0}):o===lC.SmoothStep?[C]=bC(E):o===lC.SimpleBezier?[C]=pC(E):C=`M${w},${k} ${f},${m}`,u.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};$j.displayName="ConnectionLine";const Wj=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Gj({containerStyle:e,style:t,type:n,component:o}){const{nodeId:r,handleType:a,nodesConnectable:i,width:s,height:l,connectionStatus:c}=AN(Wj,XS);return!!(r&&a&&s&&i)?u.createElement("svg",{style:e,width:s,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},u.createElement("g",{className:HS(["react-flow__connection",c])},u.createElement($j,{nodeId:r,handleType:a,style:t,type:n,CustomComponent:o,connectionStatus:c}))):null}function qj(e,t){r.useRef(null),TN();return r.useMemo((()=>t(e)),[e])}const Yj=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:o,onMoveEnd:a,onInit:i,onNodeClick:s,onEdgeClick:l,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,onSelectionContextMenu:g,onSelectionStart:v,onSelectionEnd:y,connectionLineType:x,connectionLineStyle:b,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:S,selectionOnDrag:N,selectionMode:C,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,deleteKeyCode:I,onlyRenderVisibleElements:A,elementsSelectable:T,selectNodesOnDrag:M,defaultViewport:O,translateExtent:D,minZoom:P,maxZoom:R,preventScrolling:L,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:H,zoomOnDoubleClick:$,panOnDrag:W,onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneScroll:K,onPaneContextMenu:J,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,noDragClassName:ie,noWheelClassName:se,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const me=qj(e,yj),pe=qj(t,_j);return function(e){const t=PE(),n=r.useRef(!1);r.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(i),u.createElement(vj,{onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:X,onPaneContextMenu:J,onPaneScroll:K,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:N,selectionMode:C,onSelectionStart:v,onSelectionEnd:y,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,elementsSelectable:T,onMove:n,onMoveStart:o,onMoveEnd:a,zoomOnScroll:F,zoomOnPinch:B,zoomOnDoubleClick:$,panOnScroll:U,panOnScrollSpeed:V,panOnScrollMode:H,panOnDrag:W,defaultViewport:O,translateExtent:D,minZoom:P,maxZoom:R,onSelectionContextMenu:g,preventScrolling:L,noDragClassName:ie,noWheelClassName:se,noPanClassName:le,disableKeyboardA11y:de},u.createElement(Vj,null,u.createElement(Bj,{edgeTypes:pe,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:A,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:re,reconnectRadius:ae,defaultMarkerColor:z,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},u.createElement(Gj,{style:b,type:x,component:w,containerStyle:k})),u.createElement("div",{className:"react-flow__edgelabel-renderer"}),u.createElement(wj,{nodeTypes:me,onNodeClick:s,onNodeDoubleClick:c,onNodeMouseEnter:h,onNodeMouseMove:f,onNodeMouseLeave:m,onNodeContextMenu:p,selectNodesOnDrag:M,onlyRenderVisibleElements:A,noPanClassName:le,noDragClassName:ie,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};Yj.displayName="GraphView";var Xj=r.memo(Yj);const Kj=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Jj={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Kj,nodeExtent:Kj,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:nC.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:(e,t)=>{},isValidConnection:void 0},Zj=()=>{return e=(e,t)=>({...Jj,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:a}=t();e({nodeInternals:jE(n,o,r,a)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=t();e({edges:n.map((e=>({...o,...e})))})},setDefaultNodesAndEdges:(n,o)=>{const r=void 0!==n,a=void 0!==o,i=r?jE(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:a?o:[],hasDefaultNodes:r,hasDefaultEdges:a})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:a,fitViewOnInitDone:i,fitViewOnInitOptions:s,domNode:l,nodeOrigin:c}=t(),d=null==l?void 0:l.querySelector(".react-flow__viewport");if(!d)return;const u=window.getComputedStyle(d),{m22:h}=new window.DOMMatrixReadOnly(u.transform),f=n.reduce(((e,t)=>{const n=r.get(t.id);if(null==n?void 0:n.hidden)r.set(n.id,{...n,[GN]:{...n[GN],handleBounds:void 0}});else if(n){const o=RN(t.nodeElement);o.width&&o.height&&(n.width!==o.width||n.height!==o.height||t.forceUpdate)&&(r.set(n.id,{...n,[GN]:{...n[GN],handleBounds:{source:aj(".source",t.nodeElement,h,c),target:aj(".target",t.nodeElement,h,c)}},...o}),e.push({id:n.id,type:"dimensions",dimensions:o}))}return e}),[]);EE(r,c);const m=i||a&&!i&&_E(t,{initial:!0,...s});e({nodeInternals:new Map(r),fitViewOnInitDone:m}),(null==f?void 0:f.length)>0&&(null==o||o(f))},updateNodePositions:(e,n=!0,o=!1)=>{const{triggerNodeChanges:r}=t();r(e.map((e=>{const t={id:e.id,type:"position",dragging:o};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:a,nodeOrigin:i,getNodes:s,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(a){const t=jE(YE(n,s()),r,i,l);e({nodeInternals:t})}null==o||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let i,s=null;o?i=n.map((e=>XE(e,!0))):(i=KE(a(),n),s=KE(r,[])),TE({changedNodes:i,changedEdges:s,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:a}=t();let i,s=null;o?i=n.map((e=>XE(e,!0))):(i=KE(r,n),s=KE(a(),[])),TE({changedNodes:s,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:a}=t(),i=o||r;TE({changedNodes:(n||a()).map((e=>(e.selected=!1,XE(e.id,!1)))),changedEdges:i.map((e=>XE(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=t();null==o||o.scaleExtent([n,r]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=t();null==o||o.scaleExtent([r,n]),e({maxZoom:n})},setTranslateExtent:n=>{var o;null==(o=t().d3Zoom)||o.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=t();TE({changedNodes:o().filter((e=>e.selected)).map((e=>XE(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>XE(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:o}=t();o.forEach((e=>{e.positionAbsolute=zN(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(o)})},panBy:e=>{const{transform:n,width:o,height:r,d3Zoom:a,d3Selection:i,translateExtent:s}=t();if(!a||!i||!e.x&&!e.y)return!1;const l=Dl.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[o,r]],d=null==a?void 0:a.constrain()(l,c,s);return a.transform(i,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:Jj.connectionNodeId,connectionHandleId:Jj.connectionHandleId,connectionHandleType:Jj.connectionHandleType,connectionStatus:Jj.connectionStatus,connectionStartHandle:Jj.connectionStartHandle,connectionEndHandle:Jj.connectionEndHandle}),reset:()=>e({...Jj})}),t=Object.is,e?YS(e,t):YS;var e,t},Qj=({children:e})=>{const t=r.useRef(null);return t.current||(t.current=Zj()),u.createElement(bN,{value:t.current},e)};Qj.displayName="ReactFlowProvider";const e_=({children:e})=>r.useContext(xN)?u.createElement(u.Fragment,null,e):u.createElement(Qj,null,e);e_.displayName="ReactFlowWrapper";const t_={input:tE,default:QC,output:oE,group:rE},n_={default:jC,straight:SC,step:kC,smoothstep:wC,simplebezier:gC},o_=[0,0],r_=[15,15],a_={x:0,y:0,zoom:1},i_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},s_=r.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:a=t_,edgeTypes:i=n_,onNodeClick:s,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:N,onNodeDrag:C,onNodeDragStop:E,onNodesDelete:j,onEdgesDelete:_,onSelectionChange:I,onSelectionDragStart:A,onSelectionDrag:T,onSelectionDragStop:M,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:P,connectionMode:R=nC.Strict,connectionLineType:L=lC.Bezier,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:V="Shift",selectionOnDrag:H=!1,selectionMode:$=iC.Full,panActivationKeyCode:W="Space",multiSelectionKeyCode:G=(JN()?"Meta":"Control"),zoomActivationKeyCode:q=(JN()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:X=r_,onlyRenderVisibleElements:K=!1,selectNodesOnDrag:J=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=o_,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,defaultViewport:ae=a_,minZoom:ie=.5,maxZoom:se=2,translateExtent:le=Kj,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:me=!1,panOnScrollSpeed:pe=.5,panOnScrollMode:ge=rC.Free,zoomOnDoubleClick:ve=!0,panOnDrag:ye=!0,onPaneClick:xe,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ne,children:Ce,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onEdgeUpdate:Te,onEdgeUpdateStart:Me,onEdgeUpdateEnd:Oe,onReconnect:De,onReconnectStart:Pe,onReconnectEnd:Re,reconnectRadius:Le=10,edgeUpdaterRadius:ze=10,onNodesChange:Fe,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:Ve="nowheel",noPanClassName:He="nopan",fitView:$e=!1,fitViewOptions:We,connectOnClick:Ge=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Xe,elevateNodesOnSelect:Ke=!0,elevateEdgesOnSelect:Je=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:ot,style:rt,id:at,nodeDragThreshold:it,...st},lt)=>{const ct=at||"1";return u.createElement("div",{...st,style:{...rt,...i_},ref:lt,className:HS(["react-flow",r]),"data-testid":"rf__wrapper",id:at},u.createElement(e_,null,u.createElement(Xj,{onInit:c,onMove:d,onMoveStart:h,onMoveEnd:f,onNodeClick:s,onEdgeClick:l,onNodeMouseEnter:x,onNodeMouseMove:b,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:i,connectionLineType:L,connectionLineStyle:z,connectionLineComponent:F,connectionLineContainerStyle:B,selectionKeyCode:V,selectionOnDrag:H,selectionMode:$,deleteKeyCode:U,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:q,onlyRenderVisibleElements:K,selectNodesOnDrag:J,defaultViewport:ae,translateExtent:le,minZoom:ie,maxZoom:se,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ve,panOnScroll:me,panOnScrollSpeed:pe,panOnScrollMode:ge,panOnDrag:ye,onPaneClick:xe,onPaneMouseEnter:be,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ne,onSelectionContextMenu:O,onSelectionStart:D,onSelectionEnd:P,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onReconnect:De??Te,onReconnectStart:Pe??Me,onReconnectEnd:Re??Oe,reconnectRadius:Le??ze,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:Ve,noPanClassName:He,elevateEdgesOnSelect:Je,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),u.createElement(mE,{nodes:e,edges:t,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:p,onConnectEnd:g,onClickConnectStart:v,onClickConnectEnd:y,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:oe,elementsSelectable:re,elevateNodesOnSelect:Ke,minZoom:ie,maxZoom:se,nodeExtent:de,onNodesChange:Fe,onEdgesChange:Be,snapToGrid:Y,snapGrid:X,connectionMode:R,translateExtent:le,connectOnClick:Ge,defaultEdgeOptions:Xe,fitView:$e,fitViewOptions:We,onNodesDelete:j,onEdgesDelete:_,onNodeDragStart:N,onNodeDrag:C,onNodeDragStop:E,onSelectionDrag:T,onSelectionDragStart:A,onSelectionDragStop:M,noPanClassName:He,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:ot,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:it}),u.createElement(dE,{onSelectionChange:I}),Ce,u.createElement(DN,{proOptions:Ye,position:qe}),u.createElement(wE,{rfId:ct,disableKeyboardA11y:Ze})))}));function l_(e){return t=>{const[n,o]=r.useState(t),a=r.useCallback((t=>o((n=>e(t,n)))),[]);return[n,o,a]}}s_.displayName="ReactFlow";const c_=l_(YE),d_=l_((function(e,t){return qE(e,t)}));function u_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},u.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function h_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},u.createElement("path",{d:"M0 0h32v4.2H0z"}))}function f_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},u.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function m_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function p_(){return u.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},u.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const g_=({children:e,className:t,...n})=>u.createElement("button",{type:"button",className:HS(["react-flow__controls-button",t]),...n},e);g_.displayName="ControlButton";const v_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),y_=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:a,onZoomIn:i,onZoomOut:s,onFitView:l,onInteractiveChange:c,className:d,children:h,position:f="bottom-left"})=>{const m=TN(),[p,g]=r.useState(!1),{isInteractive:v,minZoomReached:y,maxZoomReached:x}=AN(v_,XS),{zoomIn:b,zoomOut:w,fitView:k}=PE();if(r.useEffect((()=>{g(!0)}),[]),!p)return null;return u.createElement(ON,{className:HS(["react-flow__controls",d]),position:f,style:e,"data-testid":"rf__controls"},t&&u.createElement(u.Fragment,null,u.createElement(g_,{onClick:()=>{b(),null==i||i()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},u.createElement(u_,null)),u.createElement(g_,{onClick:()=>{w(),null==s||s()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:y},u.createElement(h_,null))),n&&u.createElement(g_,{className:"react-flow__controls-fitview",onClick:()=>{k(a),null==l||l()},title:"fit view","aria-label":"fit view"},u.createElement(f_,null)),o&&u.createElement(g_,{className:"react-flow__controls-interactive",onClick:()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),null==c||c(!v)},title:"toggle interactivity","aria-label":"toggle interactivity"},v?u.createElement(p_,null):u.createElement(m_,null)),h)};y_.displayName="Controls";var x_,b_,w_=r.memo(y_);function k_({color:e,dimensions:t,lineWidth:n}){return u.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function S_({color:e,radius:t}){return u.createElement("circle",{cx:t,cy:t,r:t,fill:e})}(b_=x_||(x_={})).Lines="lines",b_.Dots="dots",b_.Cross="cross";const N_={[x_.Dots]:"#91919a",[x_.Lines]:"#eee",[x_.Cross]:"#e2e2e2"},C_={[x_.Dots]:1,[x_.Lines]:1,[x_.Cross]:6},E_=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function j_({id:e,variant:t=x_.Dots,gap:n=20,size:o,lineWidth:a=1,offset:i=2,color:s,style:l,className:c}){const d=r.useRef(null),{transform:h,patternId:f}=AN(E_,XS),m=s||N_[t],p=o||C_[t],g=t===x_.Dots,v=t===x_.Cross,y=Array.isArray(n)?n:[n,n],x=[y[0]*h[2]||1,y[1]*h[2]||1],b=p*h[2],w=v?[b,b]:x,k=g?[b/i,b/i]:[w[0]/i,w[1]/i];return u.createElement("svg",{className:HS(["react-flow__background",c]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},u.createElement("pattern",{id:f+e,x:h[0]%x[0],y:h[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?u.createElement(S_,{color:m,radius:b/i}):u.createElement(k_,{dimensions:w,color:m,lineWidth:a})),u.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${f+e})`}))}j_.displayName="Background";var __=r.memo(j_);function I_(e){return Math.min(11*e+35,200)}const A_=u.createContext("LR"),T_=r.memo((e=>{const t=b(51),{data:n,selected:o}=e,a=le(n.atom),i=he().inOrderIds.indexOf(a.id),s=o?"var(--gray-9)":"var(--gray-3)",l=AN(O_),c=r.useContext(A_);let d,u,h,f,m;if(t[0]!==a.code||t[1]!==c||t[2]!==s||t[3]!==o){const e=a.code.split("\n").length,n="LR"===c?hC.Left:hC.Top;let r;t[8]!==s?(r={background:s},t[8]=s,t[9]=r):r=t[9],t[10]!==n||t[11]!==r?(h=k.jsx(JC,{type:"target",id:"inputs",position:n,style:r}),t[10]=n,t[11]=r,t[12]=h):h=t[12];const i="LR"===c?hC.Left:hC.Top;let l;t[13]!==s?(l={background:s},t[13]=s,t[14]=l):l=t[14],t[15]!==i||t[16]!==l?(f=k.jsx(JC,{type:"source",id:"inputs",position:i,style:l}),t[15]=i,t[16]=l,t[17]=f):f=t[17];const m=o&&"border-primary";t[18]!==m?(u=rn("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",m),t[18]=m,t[19]=u):u=t[19],d=I_(e),t[0]=a.code,t[1]=c,t[2]=s,t[3]=o,t[4]=d,t[5]=u,t[6]=h,t[7]=f}else d=t[4],u=t[5],h=t[6],f=t[7];var p;let g;t[20]!==n.forceWidth||t[21]!==l?(m=n.forceWidth||(p=l,Math.min(Math.max(p-100,100),400)),t[20]=n.forceWidth,t[21]=l,t[22]=m):m=t[22],t[23]!==d||t[24]!==m?(g={height:d,width:m},t[23]=d,t[24]=m,t[25]=g):g=t[25];const v=pi(a.name,i);let y,x,w;t[26]!==v?(y=k.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:v}),t[26]=v,t[27]=y):y=t[27],t[28]!==a.code?(x=k.jsx(Ml,{code:a.code}),t[28]=a.code,t[29]=x):x=t[29],t[30]!==u||t[31]!==g||t[32]!==y||t[33]!==x?(w=k.jsxs("div",{className:u,style:g,children:[y,x]}),t[30]=u,t[31]=g,t[32]=y,t[33]=x,t[34]=w):w=t[34];const S="LR"===c?hC.Right:hC.Bottom;let N,C;t[35]!==s?(N={background:s},t[35]=s,t[36]=N):N=t[36],t[37]!==S||t[38]!==N?(C=k.jsx(JC,{type:"source",id:"outputs",position:S,style:N}),t[37]=S,t[38]=N,t[39]=C):C=t[39];const E="LR"===c?hC.Right:hC.Bottom;let j,_,I;return t[40]!==s?(j={background:s},t[40]=s,t[41]=j):j=t[41],t[42]!==E||t[43]!==j?(_=k.jsx(JC,{type:"target",id:"outputs",position:E,style:j}),t[42]=E,t[43]=j,t[44]=_):_=t[44],t[45]!==h||t[46]!==f||t[47]!==w||t[48]!==C||t[49]!==_?(I=k.jsxs("div",{children:[h,f,w,C,_]}),t[45]=h,t[46]=f,t[47]=w,t[48]=C,t[49]=_,t[50]=I):I=t[50],I}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));T_.displayName="CustomNode";const M_={custom:T_};function O_(e){const{width:t}=e;return t}const D_=e=>{const t=b(18),{maxCount:n,cellIds:o,onClick:r,skipScroll:a}=e,i=he();let s,l,c,d;if(t[0]!==o||t[1]!==i.inOrderIds||t[2]!==n||t[3]!==a||t[4]!==r){c=Symbol.for("react.early_return_sentinel");e:{let e;t[8]!==i.inOrderIds?(e=(e,t)=>i.inOrderIds.indexOf(e)-i.inOrderIds.indexOf(t),t[8]=i.inOrderIds,t[9]=e):e=t[9];const d=[...o].sort(e);if(0===o.length){let e;t[10]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("div",{className:"text-muted-foreground",children:"--"}),t[10]=e):e=t[10],c=e;break e}let u;t[11]!==a||t[12]!==r||t[13]!==o.length?(u=(e,t)=>k.jsxs("span",{className:"truncate",children:[k.jsx(gi,{variant:"focus",cellId:e,skipScroll:a,className:"whitespace-nowrap",onClick:r?()=>r(e):void 0},e),t<o.length-1&&", "]},e),t[11]=a,t[12]=r,t[13]=o.length,t[14]=u):u=t[14],s=d.slice(0,n).map(u),l=o.length>n&&k.jsxs(fn,{children:[k.jsx(xr,{asChild:!0,children:k.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",o.length-n," more"]})}),k.jsx(hn,{className:"w-auto",children:k.jsx("div",{className:"flex flex-col gap-1 py-1",children:d.slice(n).map((e=>k.jsx(gi,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:r?()=>r(e):void 0},e)))})})]})}t[0]=o,t[1]=i.inOrderIds,t[2]=n,t[3]=a,t[4]=r,t[5]=s,t[6]=l,t[7]=c}else s=t[5],l=t[6],c=t[7];return c!==Symbol.for("react.early_return_sentinel")?c:(t[15]!==s||t[16]!==l?(d=k.jsxs(k.Fragment,{children:[s,l]}),t[15]=s,t[16]=l,t[17]=d):d=t[17],d)},P_=e=>{const t=b(15);let n,o,r,a;t[0]!==e?(({name:r,declaredBy:n,onClick:o,...a}=e),t[0]=e,t[1]=n,t[2]=o,t[3]=r,t[4]=a):(n=t[1],o=t[2],r=t[3],a=t[4]);const i=n.length>1?"destructive":"outline";let s,l,c;return t[5]!==o||t[6]!==r?(s=async e=>{o?o(e):(await et(r),re({title:"Copied to clipboard"}))},t[5]=o,t[6]=r,t[7]=s):s=t[7],t[8]!==r||t[9]!==i||t[10]!==s?(l=k.jsx(vi,{title:r,variant:i,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:s,children:r}),t[8]=r,t[9]=i,t[10]=s,t[11]=l):l=t[11],t[12]!==a||t[13]!==l?(c=k.jsx("div",{className:"max-w-[130px]",...a,children:l}),t[12]=a,t[13]=l,t[14]=c):c=t[14],c},R_=r.memo((e=>{const t=b(38),{onChange:n,view:o,settings:r,onSettingsChange:a}=e;let i;t[0]!==a||t[1]!==r?(i=(e,t)=>{a({...r,[e]:t})},t[0]=a,t[1]=r,t[2]=i):i=t[2];const s=i;let l,c,d,u,h,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(xr,{asChild:!0,children:k.jsx(C,{variant:"text",size:"xs",children:k.jsx(Tt,{className:"w-4 h-4"})})}),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),t[4]=c):c=t[4],t[5]!==s?(d=e=>s("hidePureMarkdown",Boolean(e)),t[5]=s,t[6]=d):d=t[6],t[7]!==r.hidePureMarkdown||t[8]!==d?(u=k.jsx(qr,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:r.hidePureMarkdown,onCheckedChange:d}),t[7]=r.hidePureMarkdown,t[8]=d,t[9]=u):u=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsx(Ae,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),t[10]=h):h=t[10],t[11]!==u?(f=k.jsxs(fn,{children:[l,k.jsxs(hn,{className:"w-auto p-2 text-muted-foreground",children:[c,k.jsxs("div",{className:"flex items-center gap-2",children:[u,h]})]})]}),t[11]=u,t[12]=f):f=t[12];const m=f,p="_minimap_"===o;let g,v,y;t[13]!==n?(g=()=>n("_minimap_"),t[13]=n,t[14]=g):g=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(Dc,{className:"w-4 h-4 mr-1"}),t[15]=v):v=t[15],t[16]!==p||t[17]!==g?(y=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":p,size:"xs",onClick:g,children:[v,"Mini Map"]}),t[16]=p,t[17]=g,t[18]=y):y=t[18];const x="TB"===o;let w,S,N;t[19]!==n?(w=()=>n("TB"),t[19]=n,t[20]=w):w=t[20],t[21]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(kc,{className:"w-4 h-4 mr-1"}),t[21]=S):S=t[21],t[22]!==x||t[23]!==w?(N=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":x,size:"xs",onClick:w,children:[S,"Vertical Tree"]}),t[22]=x,t[23]=w,t[24]=N):N=t[24];const E="LR"===o;let j,_,I,A;t[25]!==n?(j=()=>n("LR"),t[25]=n,t[26]=j):j=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(_=k.jsx(kc,{className:"w-4 h-4 mr-1 transform -rotate-90"}),t[27]=_):_=t[27],t[28]!==E||t[29]!==j?(I=k.jsxs(C,{variant:"outline",className:"bg-background","aria-selected":E,size:"xs",onClick:j,children:[_," ","Horizontal Tree"]}),t[28]=E,t[29]=j,t[30]=I):I=t[30],t[31]!==y||t[32]!==N||t[33]!==I?(A=k.jsxs("div",{className:"flex gap-2",children:[y,N,I]}),t[31]=y,t[32]=N,t[33]=I,t[34]=A):A=t[34];const T="_minimap_"!==o&&m;let M;return t[35]!==A||t[36]!==T?(M=k.jsxs(ON,{position:"top-right",className:"flex flex-col items-end gap-2",children:[A,T]}),t[35]=A,t[36]=T,t[37]=M):M=t[37],M}));R_.displayName="GraphToolbar";const L_=r.memo((e=>{const t=b(11),{selection:n,variables:o,onClearSelection:r}=e;if(!n)return null;const a=z_;let i;t[0]!==n.type||t[1]!==n.id||t[2]!==n.source||t[3]!==n.target||t[4]!==o||t[5]!==r?(i=()=>{if("node"===n.type){const e=Object.values(o).filter((e=>e.usedBy.includes(n.id))),t=Object.values(o).filter((e=>e.declaredBy.includes(n.id))),i=(e,t)=>k.jsxs(k.Fragment,{children:[0===e.length&&k.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),k.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>k.jsxs(u.Fragment,{children:[k.jsx(P_,{declaredBy:e.declaredBy,name:e.name}),k.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,k.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),k.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:k.jsx(D_,{skipScroll:!0,onClick:()=>a("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[k.jsx(ct,{className:"w-5 h-5"}),k.jsx(gi,{cellId:n.id}),k.jsx("div",{className:"flex-1"}),k.jsx(cx,{cellId:n.id,children:k.jsx(C,{variant:"ghost",size:"icon",children:k.jsx(rc,{className:"w-4 h-4"})})}),k.jsx(C,{variant:"text",size:"icon",onClick:()=>{r()},children:k.jsx(tn,{className:"w-4 h-4"})})]}),k.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[k.jsxs("div",{className:"flex flex-col gap-2",children:[k.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[k.jsx(Ul,{className:"w-4 h-4"}),"Outputs"]}),i(t,"out")]}),k.jsx("hr",{className:"border-divider my-3"}),k.jsxs("div",{className:"flex flex-col gap-2",children:[k.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[k.jsx(Vl,{className:"w-4 h-4"}),"Inputs"]}),i(e,"in")]})]})]})}if("edge"===n.type){const e=Object.values(o).filter((e=>e.declaredBy.includes(n.source)&&e.usedBy.includes(n.target)));return k.jsxs(k.Fragment,{children:[k.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[k.jsx(Qc,{className:"w-4 h-4"}),k.jsx(gi,{cellId:n.source}),k.jsx(Hl,{className:"w-4 h-4"}),k.jsx(gi,{cellId:n.target})]}),k.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:e.map((e=>k.jsxs(u.Fragment,{children:[k.jsx(P_,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{a(e.declaredBy[0],e.name)}}),k.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),k.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}},t[0]=n.type,t[1]=n.id,t[2]=n.source,t[3]=n.target,t[4]=o,t[5]=r,t[6]=i):i=t[6];const s=i;let l,c;return t[7]!==s?(l=s(),t[7]=s,t[8]=l):l=t[8],t[9]!==l?(c=k.jsx(ON,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:k.jsx("div",{className:"min-h-[100px] shadow-md rounded-md border max-w-[550px] border-primary/40 my-4 min-w-[240px] bg-[var(--slate-1)] text-muted-foreground/80 flex flex-col overflow-y-auto",children:l})}),t[9]=l,t[10]=c):c=t[10],c}));function z_(e,t){const n=Yr(e);n&&yi(n,t)}function F_(){const e=b(7),t=PE(),n=AN(U_),o=AN(B_);let a;e[0]!==t?(a=()=>{t.fitView({duration:100})},e[0]=t,e[1]=a):a=e[1];const i=xi(a,100);let s,l;e[2]!==n||e[3]!==o||e[4]!==i?(s=()=>{n&&o&&i()},l=[n,o,i],e[2]=n,e[3]=o,e[4]=i,e[5]=s,e[6]=l):(s=e[5],l=e[6]),r.useEffect(s,l)}function B_(e){const{height:t}=e;return t}function U_(e){const{width:t}=e;return t}L_.displayName="GraphSelectionPanel";const V_=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:dC.Arrow},id:`${e}-${t}-${n}`,source:e,sourceHandle:n,targetHandle:n,target:t}}createNode(e,t,n){return{id:e,data:{atom:t},width:250,type:"custom",height:I_(te.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,o){let r=0;const a=[],i=[];for(const[l,c]of Ta.zip(e,t)){const e=this.createNode(l,c,r);a.push(e),r=e.position.y+(e.height||0)}const s=new Set;for(const l of Object.values(n)){const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;s.has(t)||(s.add(t),i.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:a,edges:i}}},H_=e=>{const t=b(37),{cellIds:n,variables:o,cellAtoms:a,children:i}=e;let s;t[0]!==n||t[1]!==a||t[2]!==o?(s=V_.createElements(n,a,o,!1),t[0]=n,t[1]=a,t[2]=o,t[3]=s):s=t[3];const{nodes:l,edges:c}=s;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=[],t[4]=d):d=t[4];const[u,h]=d_(d),[f,m]=c_(l),[p,g]=r.useState(),[v,y]=r.useState(),x=r.useRef(!1);F_();const w=AN($_);let S;t[5]!==m||t[6]!==h?(S=e=>{m(e.nodes),h([])},t[5]=m,t[6]=h,t[7]=S):S=t[7];const N=G(S);let C,E,j,_;t[8]!==N||t[9]!==n||t[10]!==a||t[11]!==o?(C=()=>{x.current?N(V_.createElements(n,a,o,!1)):x.current=!0},E=[n,o,a,N],t[8]=N,t[9]=n,t[10]=a,t[11]=o,t[12]=C,t[13]=E):(C=t[12],E=t[13]),r.useEffect(C,E),t[14]!==p||t[15]!==c||t[16]!==h?(j=()=>{if(p){const e=c.filter((e=>{const{source:t,target:n,data:o}=e;return t===p&&"outputs"===o.direction||n===p&&"inputs"===o.direction}));h(e)}},_=[p,h,c],t[14]=p,t[15]=c,t[16]=h,t[17]=j,t[18]=_):(j=t[17],_=t[18]),r.useEffect(j,_);const I=function(e,t){const n=b(17);let o,r;if(n[0]!==t||n[1]!==e){let o;n[3]!==t?(o=(e,n)=>{const{position:o}=n;return Math.min(e,o.y-t/2-10)},n[3]=t,n[4]=o):o=n[4],r=e.reduce(o,Number.POSITIVE_INFINITY),n[0]=t,n[1]=e,n[2]=r}else r=n[2];const a=r;let i;if(n[5]!==t||n[6]!==e){let o;n[8]!==t?(o=(e,n)=>{const{position:o}=n;return Math.max(e,o.y+t/2+10)},n[8]=t,n[9]=o):o=n[9],i=e.reduce(o,Number.NEGATIVE_INFINITY),n[5]=t,n[6]=e,n[7]=i}else i=n[7];const s=i;let l,c,d;n[10]!==a?(l=[Number.NEGATIVE_INFINITY,a],n[10]=a,n[11]=l):l=n[11];n[12]!==s?(c=[Number.POSITIVE_INFINITY,s],n[12]=s,n[13]=c):c=n[13];n[14]!==l||n[15]!==c?(d=[l,c],n[14]=l,n[15]=c,n[16]=d):d=n[16];return o=d,o}(f,w);let A;t[19]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{g(void 0),y(void 0)},t[19]=A):A=t[19];const T=A;let M;t[20]!==v||t[21]!==o||t[22]!==u||t[23]!==p?(M=()=>v?k.jsx(L_,{selection:{type:"edge",source:v.source,target:v.target},onClearSelection:T,variables:o,edges:u}):p?k.jsx(L_,{selection:{type:"node",id:p},variables:o,edges:u,onClearSelection:T}):null,t[20]=v,t[21]=o,t[22]=u,t[23]=p,t[24]=M):M=t[24];const O=M;let D,P,R,L;return t[25]!==h?(D=(e,t)=>{const n=t.id;g(n),y(void 0),h([])},t[25]=h,t[26]=D):D=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(P=(e,t)=>{y(t)},t[27]=P):P=t[27],t[28]!==O?(R=O(),t[28]=O,t[29]=R):R=t[29],t[30]!==f||t[31]!==u||t[32]!==I||t[33]!==D||t[34]!==R||t[35]!==i?(L=k.jsxs(s_,{nodes:f,edges:u,nodeTypes:M_,translateExtent:I,onNodeClick:D,onNodeDoubleClick:W_,onEdgeClick:P,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:rC.Vertical,zoomOnDoubleClick:!1,nodesDraggable:!1,nodesConnectable:!1,nodesFocusable:!1,edgesFocusable:!1,selectNodesOnDrag:!1,panOnDrag:!1,preventScrolling:!1,zoomOnPinch:!1,panOnScroll:!0,autoPanOnNodeDrag:!1,autoPanOnConnect:!1,children:[R,i]}),t[30]=f,t[31]=u,t[32]=I,t[33]=D,t[34]=R,t[35]=i,t[36]=L):L=t[36],L};function $_(e){const{height:t}=e;return t}function W_(e,t){bi(t.id,"focus")}var G_="\0";function q_(e,t){e[t]?e[t]++:e[t]=1}function Y_(e,t){--e[t]||delete e[t]}function X_(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var i=r;r=a,a=i}return r+""+a+""+(void 0===o?"\0":o)}function K_(e,t){return X_(e,t.v,t.w,t.name)}var J_=class{constructor(e){n(this,"_isDirected",!0),n(this,"_isMultigraph",!1),n(this,"_isCompound",!1),n(this,"_label"),n(this,"_defaultNodeLabelFn",(()=>{})),n(this,"_defaultEdgeLabelFn",(()=>{})),n(this,"_nodes",{}),n(this,"_in",{}),n(this,"_preds",{}),n(this,"_out",{}),n(this,"_sucs",{}),n(this,"_edgeObjs",{}),n(this,"_edgeLabels",{}),n(this,"_nodeCount",0),n(this,"_edgeCount",0),n(this,"_parent"),n(this,"_children"),e&&(this._isDirected=!Object.hasOwn(e,"directed")||e.directed,this._isMultigraph=!!Object.hasOwn(e,"multigraph")&&e.multigraph,this._isCompound=!!Object.hasOwn(e,"compound")&&e.compound),this._isCompound&&(this._parent={},this._children={},this._children[G_]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,"function"!=typeof e&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._in[t]).length))}sinks(){var e=this;return this.nodes().filter((t=>0===Object.keys(e._out[t]).length))}setNodes(e,t){var n=arguments,o=this;return e.forEach((function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=G_,this._children[e]={},this._children[G_][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach((function(e){t.setParent(e)})),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===t)t=G_;else{for(var n=t+="";void 0!==n;n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==G_)return t}}children(e=G_){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else{if(e===G_)return this.nodes();if(this.hasNode(e))return[]}}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){const o=new Set(t);for(var n of this.successors(e))o.add(n);return Array.from(o.values())}}isLeaf(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach((function([n,o]){e(n)&&t.setNode(n,o)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};function r(e){var a=n.parent(e);return void 0===a||t.hasNode(a)?(o[e]=a,a):a in o?o[a]:r(a)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,r(e)))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,"function"!=typeof e&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,o=arguments;return e.reduce((function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this}setEdge(){var e,t,n,o,r=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,t=a.w,n=a.name,2===arguments.length&&(o=arguments[1],r=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],r=!0)),e=""+e,t=""+t,void 0!==n&&(n=""+n);var i=X_(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,i))return r&&(this._edgeLabels[i]=o),this;if(void 0!==n&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[i]=r?o:this._defaultEdgeLabelFn(e,t,n);var s=function(e,t,n,o){var r=""+t,a=""+n;if(!e&&r>a){var i=r;r=a,a=i}var s={v:r,w:a};o&&(s.name=o);return s}(this._isDirected,e,t,n);return e=s.v,t=s.w,Object.freeze(s),this._edgeObjs[i]=s,q_(this._preds[t],e),q_(this._sucs[e],t),this._in[t][i]=s,this._out[e][i]=s,this._edgeCount++,this}edge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n);return this._edgeLabels[o]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,o)}removeEdge(e,t,n){var o=1===arguments.length?K_(this._isDirected,arguments[0]):X_(this._isDirected,e,t,n),r=this._edgeObjs[o];return r&&(e=r.v,t=r.w,delete this._edgeLabels[o],delete this._edgeObjs[o],Y_(this._preds[t],e),Y_(this._sucs[e],t),delete this._in[t][o],delete this._out[e][o],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.v===t)):o}}outEdges(e,t){var n=this._out[e];if(n){var o=Object.values(n);return t?o.filter((e=>e.w===t)):o}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},Z_={Graph:J_,version:"2.2.4"},Q_=J_,eI={write:function(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:tI(e),edges:nI(e)};void 0!==e.graph()&&(t.value=structuredClone(e.graph()));return t},read:function(e){var t=new Q_(e.options).setGraph(e.value);return e.nodes.forEach((function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)})),e.edges.forEach((function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),t}};function tI(e){return e.nodes().map((function(t){var n=e.node(t),o=e.parent(t),r={v:t};return void 0!==n&&(r.value=n),void 0!==o&&(r.parent=o),r}))}function nI(e){return e.edges().map((function(t){var n=e.edge(t),o={v:t.v,w:t.w};return void 0!==t.name&&(o.name=t.name),void 0!==n&&(o.value=n),o}))}var oI=function(e){var t,n={},o=[];function r(o){Object.hasOwn(n,o)||(n[o]=!0,t.push(o),e.successors(o).forEach(r),e.predecessors(o).forEach(r))}return e.nodes().forEach((function(e){t=[],r(e),t.length&&o.push(t)})),o};var rI=class{constructor(){n(this,"_arr",[]),n(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map((function(e){return e.key}))}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(void 0!==t)return this._arr[t].priority}min(){if(0===this.size())throw new Error("Queue underflow");return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var o=this._arr,r=o.length;return n[e]=r,o.push({key:e,priority:t}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+e+" Old: "+this._arr[n].priority+" New: "+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,o=n+1,r=e;n<t.length&&(r=t[n].priority<t[r].priority?n:r,o<t.length&&(r=t[o].priority<t[r].priority?o:r),r!==e&&(this._swap(e,r),this._heapify(r)))}_decrease(e){for(var t,n=this._arr,o=n[e].priority;0!==e&&!(n[t=e>>1].priority<o);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,o=this._keyIndices,r=n[e],a=n[t];n[e]=a,n[t]=r,o[a.key]=e,o[r.key]=t}},aI=rI,iI=function(e,t,n,o){return function(e,t,n,o){var r,a,i={},s=new aI,l=function(e){var t=e.v!==r?e.v:e.w,o=i[t],l=n(e),c=a.distance+l;if(l<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+l);c<o.distance&&(o.distance=c,o.predecessor=r,s.decrease(t,c))};e.nodes().forEach((function(e){var n=e===t?0:Number.POSITIVE_INFINITY;i[e]={distance:n},s.add(e,n)}));for(;s.size()>0&&(r=s.removeMin(),(a=i[r]).distance!==Number.POSITIVE_INFINITY);)o(r).forEach(l);return i}(e,String(t),n||sI,o||function(t){return e.outEdges(t)})},sI=()=>1;var lI=iI,cI=function(e,t,n){return e.nodes().reduce((function(o,r){return o[r]=lI(e,r,t,n),o}),{})};var dI=function(e){var t=0,n=[],o={},r=[];function a(i){var s=o[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach((function(e){Object.hasOwn(o,e)?o[e].onStack&&(s.lowlink=Math.min(s.lowlink,o[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,o[e].lowlink))})),s.lowlink===s.index){var l,c=[];do{l=n.pop(),o[l].onStack=!1,c.push(l)}while(i!==l);r.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(o,e)||a(e)})),r};var uI=dI,hI=function(e){return uI(e).filter((function(t){return t.length>1||1===t.length&&e.hasEdge(t[0],t[0])}))};var fI=function(e,t,n){return function(e,t,n){var o={},r=e.nodes();return r.forEach((function(e){o[e]={},o[e][e]={distance:0},r.forEach((function(t){e!==t&&(o[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var r=n.v===e?n.w:n.v,a=t(n);o[e][r]={distance:a,predecessor:e}}))})),r.forEach((function(e){var t=o[e];r.forEach((function(n){var a=o[n];r.forEach((function(n){var o=a[e],r=t[n],i=a[n],s=o.distance+r.distance;s<i.distance&&(i.distance=s,i.predecessor=r.predecessor)}))}))})),o}(e,t||mI,n||function(t){return e.outEdges(t)})},mI=()=>1;function pI(e){var t={},n={},o=[];if(e.sinks().forEach((function r(a){if(Object.hasOwn(n,a))throw new gI;Object.hasOwn(t,a)||(n[a]=!0,t[a]=!0,e.predecessors(a).forEach(r),delete n[a],o.push(a))})),Object.keys(t).length!==e.nodeCount())throw new gI;return o}class gI extends Error{constructor(){super(...arguments)}}var vI=pI;pI.CycleException=gI;var yI=vI;var xI=function(e,t,n){Array.isArray(t)||(t=[t]);var o=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),r="post"===n?bI:wI,a=[],i={};return t.forEach((t=>{if(!e.hasNode(t))throw new Error("Graph does not have node: "+t);r(t,o,i,a)})),a};function bI(e,t,n,o){for(var r=[[e,!1]];r.length>0;){var a=r.pop();a[1]?o.push(a[0]):Object.hasOwn(n,a[0])||(n[a[0]]=!0,r.push([a[0],!0]),kI(t(a[0]),(e=>r.push([e,!1]))))}}function wI(e,t,n,o){for(var r=[e];r.length>0;){var a=r.pop();Object.hasOwn(n,a)||(n[a]=!0,o.push(a),kI(t(a),(e=>r.push(e))))}}function kI(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}var SI=xI;var NI=xI;var CI=J_,EI=rI;var jI={Graph:Z_.Graph,json:eI,alg:{components:oI,dijkstra:iI,dijkstraAll:cI,findCycles:hI,floydWarshall:fI,isAcyclic:function(e){try{yI(e)}catch(t){if(t instanceof yI.CycleException)return!1;throw t}return!0},postorder:function(e,t){return SI(e,t,"post")},preorder:function(e,t){return NI(e,t,"pre")},prim:function(e,t){var n,o=new CI,r={},a=new EI;function i(e){var o=e.v===n?e.w:e.v,i=a.priority(o);if(void 0!==i){var s=t(e);s<i&&(r[o]=n,a.decrease(o,s))}}if(0===e.nodeCount())return o;e.nodes().forEach((function(e){a.add(e,Number.POSITIVE_INFINITY),o.setNode(e)})),a.decrease(e.nodes()[0],0);var s=!1;for(;a.size()>0;){if(n=a.removeMin(),Object.hasOwn(r,n))o.setEdge(n,r[n]);else{if(s)throw new Error("Input graph is not connected: "+e);s=!0}e.nodeEdges(n).forEach(i)}return o},tarjan:dI,topsort:vI},version:Z_.version};function _I(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function II(e,t){if("_next"!==e&&"_prev"!==e)return t}let AI=jI.Graph,TI=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return _I(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&_I(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,II)),n=n._prev;return"["+e.join(", ")+"]"}};var MI=function(e,t){if(e.nodeCount()<=1)return[];let n=function(e,t){let n=new AI,o=0,r=0;e.nodes().forEach((e=>{n.setNode(e,{v:e,in:0,out:0})})),e.edges().forEach((e=>{let a=n.edge(e.v,e.w)||0,i=t(e),s=a+i;n.setEdge(e.v,e.w,s),r=Math.max(r,n.node(e.v).out+=i),o=Math.max(o,n.node(e.w).in+=i)}));let a=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(r+o+3).map((()=>new TI)),i=o+1;return n.nodes().forEach((e=>{PI(a,i,n.node(e))})),{graph:n,buckets:a,zeroIdx:i}}(e,t||OI);return function(e,t,n){let o,r=[],a=t[t.length-1],i=t[0];for(;e.nodeCount();){for(;o=i.dequeue();)DI(e,t,n,o);for(;o=a.dequeue();)DI(e,t,n,o);if(e.nodeCount())for(let a=t.length-2;a>0;--a)if(o=t[a].dequeue(),o){r=r.concat(DI(e,t,n,o,!0));break}}return r}(n.graph,n.buckets,n.zeroIdx).flatMap((t=>e.outEdges(t.v,t.w)))};let OI=()=>1;function DI(e,t,n,o,r){let a=r?[]:void 0;return e.inEdges(o.v).forEach((o=>{let i=e.edge(o),s=e.node(o.v);r&&a.push({v:o.v,w:o.w}),s.out-=i,PI(t,n,s)})),e.outEdges(o.v).forEach((o=>{let r=e.edge(o),a=o.w,i=e.node(a);i.in-=r,PI(t,n,i)})),e.removeNode(o.v),a}function PI(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}let RI=jI.Graph;var LI={addBorderNode:function(e,t,n,o){let r={width:0,height:0};arguments.length>=4&&(r.rank=n,r.order=o);return zI(e,"border",r,t)},addDummyNode:zI,applyWithChunking:BI,asNonCompoundGraph:function(e){let t=new RI({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach((n=>{e.children(n).length||t.setNode(n,e.node(n))})),e.edges().forEach((n=>{t.setEdge(n,e.edge(n))})),t},buildLayerMatrix:function(e){let t=$I(UI(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let o=e.node(n),r=o.rank;void 0!==r&&(t[r][o.order]=n)})),t},intersectRect:function(e,t){let n,o,r=e.x,a=e.y,i=t.x-r,s=t.y-a,l=e.width/2,c=e.height/2;if(!i&&!s)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(s)*l>Math.abs(i)*c?(s<0&&(c=-c),n=c*i/s,o=c):(i<0&&(l=-l),n=l,o=l*s/i);return{x:r+n,y:a+o}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,o])=>(e[t]=n(o,t),e)),{})},maxRank:UI,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=BI(Math.min,t);e.nodes().forEach((t=>{let o=e.node(t);Object.hasOwn(o,"rank")&&(o.rank-=n)}))},notime:function(e,t){return t()},partition:function(e,t){let n={lhs:[],rhs:[]};return e.forEach((e=>{t(e)?n.lhs.push(e):n.rhs.push(e)})),n},pick:function(e,t){const n={};for(const o of t)void 0!==e[o]&&(n[o]=e[o]);return n},predecessorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.inEdges(t).forEach((t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight})),n}));return WI(e.nodes(),t)},range:$I,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=BI(Math.min,t),o=[];e.nodes().forEach((t=>{let r=e.node(t).rank-n;o[r]||(o[r]=[]),o[r].push(t)}));let r=0,a=e.graph().nodeRankFactor;Array.from(o).forEach(((t,n)=>{void 0===t&&n%a!=0?--r:void 0!==t&&r&&t.forEach((t=>e.node(t).rank+=r))}))},simplify:function(e){let t=(new RI).setGraph(e.graph());return e.nodes().forEach((n=>t.setNode(n,e.node(n)))),e.edges().forEach((n=>{let o=t.edge(n.v,n.w)||{weight:0,minlen:1},r=e.edge(n);t.setEdge(n.v,n.w,{weight:o.weight+r.weight,minlen:Math.max(o.minlen,r.minlen)})})),t},successorWeights:function(e){let t=e.nodes().map((t=>{let n={};return e.outEdges(t).forEach((t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight})),n}));return WI(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:HI,zipObject:WI};function zI(e,t,n,o){let r;do{r=HI(o)}while(e.hasNode(r));return n.dummy=t,e.setNode(r,n),r}const FI=65535;function BI(e,t){if(t.length>FI){const n=function(e,t=FI){const n=[];for(let o=0;o<e.length;o+=t){const r=e.slice(o,o+t);n.push(r)}return n}(t);return e.apply(null,n.map((t=>e.apply(null,t))))}return e.apply(null,t)}function UI(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return BI(Math.max,t)}let VI=0;function HI(e){var t=++VI;return toString(e)+t}function $I(e,t,n=1){null==t&&(t=e,e=0);let o=e=>e<t;n<0&&(o=e=>t<e);const r=[];for(let a=e;o(a);a+=n)r.push(a);return r}function WI(e,t){return e.reduce(((e,n,o)=>(e[n]=t[o],e)),{})}let GI=MI,qI=LI.uniqueId;var YI={run:function(e){("greedy"===e.graph().acyclicer?GI(e,(t=e,e=>t.edge(e).weight)):function(e){let t=[],n={},o={};function r(a){Object.hasOwn(o,a)||(o[a]=!0,n[a]=!0,e.outEdges(a).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):r(e.w)})),delete n[a])}return e.nodes().forEach(r),t}(e)).forEach((t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,qI("rev"))}));var t},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let o=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,o)}}))}};let XI=LI;var KI={run:function(e){e.graph().dummyChains=[],e.edges().forEach((t=>function(e,t){let n,o,r,a=t.v,i=e.node(a).rank,s=t.w,l=e.node(s).rank,c=t.name,d=e.edge(t),u=d.labelRank;if(l===i+1)return;for(e.removeEdge(t),r=0,++i;i<l;++r,++i)d.points=[],o={width:0,height:0,edgeLabel:d,edgeObj:t,rank:i},n=XI.addDummyNode(e,"edge",o,"_d"),i===u&&(o.width=d.width,o.height=d.height,o.dummy="edge-label",o.labelpos=d.labelpos),e.setEdge(a,n,{weight:d.weight},c),0===r&&e.graph().dummyChains.push(n),a=n;e.setEdge(a,s,{weight:d.weight},c)}(e,t)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,o=e.node(t),r=o.edgeLabel;for(e.setEdge(o.edgeObj,r);o.dummy;)n=e.successors(t)[0],e.removeNode(t),r.points.push({x:o.x,y:o.y}),"edge-label"===o.dummy&&(r.x=o.x,r.y=o.y,r.width=o.width,r.height=o.height),t=n,o=e.node(t)}))}};const{applyWithChunking:JI}=LI;var ZI={longestPath:function(e){var t={};e.sources().forEach((function n(o){var r=e.node(o);if(Object.hasOwn(t,o))return r.rank;t[o]=!0;let a=e.outEdges(o).map((t=>null==t?Number.POSITIVE_INFINITY:n(t.w)-e.edge(t).minlen));var i=JI(Math.min,a);return i===Number.POSITIVE_INFINITY&&(i=0),r.rank=i}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}};var QI=jI.Graph,eA=ZI.slack,tA=function(e){var t,n,o=new QI({directed:!1}),r=e.nodes()[0],a=e.nodeCount();o.setNode(r,{});for(;nA(o,e)<a;)t=oA(o,e),n=o.hasNode(t.v)?eA(e,t):-eA(e,t),rA(o,e,n);return o};function nA(e,t){return e.nodes().forEach((function n(o){t.nodeEdges(o).forEach((r=>{var a=r.v,i=o===a?r.w:a;e.hasNode(i)||eA(t,r)||(e.setNode(i,{}),e.setEdge(o,i,{}),n(i))}))})),e.nodeCount()}function oA(e,t){return t.edges().reduce(((n,o)=>{let r=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(r=eA(t,o)),r<n[0]?[r,o]:n}),[Number.POSITIVE_INFINITY,null])[1]}function rA(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}var aA=tA,iA=ZI.slack,sA=ZI.longestPath,lA=jI.alg.preorder,cA=jI.alg.postorder,dA=LI.simplify,uA=hA;function hA(e){e=dA(e),sA(e);var t,n=aA(e);for(pA(n),fA(n,e);t=vA(n);)xA(n,e,t,yA(n,e,t))}function fA(e,t){var n=cA(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var o=e.node(n),r=o.parent;e.edge(n,r).cutvalue=mA(e,t,n)}(e,t,n)))}function mA(e,t,n){var o=e.node(n).parent,r=!0,a=t.edge(n,o),i=0;return a||(r=!1,a=t.edge(o,n)),i=a.weight,t.nodeEdges(n).forEach((a=>{var s,l,c=a.v===n,d=c?a.w:a.v;if(d!==o){var u=c===r,h=t.edge(a).weight;if(i+=u?h:-h,s=n,l=d,e.hasEdge(s,l)){var f=e.edge(n,d).cutvalue;i+=u?-f:f}}})),i}function pA(e,t){arguments.length<2&&(t=e.nodes()[0]),gA(e,{},1,t)}function gA(e,t,n,o,r){var a=n,i=e.node(o);return t[o]=!0,e.neighbors(o).forEach((r=>{Object.hasOwn(t,r)||(n=gA(e,t,n,r,o))})),i.low=a,i.lim=n++,r?i.parent=r:delete i.parent,n}function vA(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function yA(e,t,n){var o=n.v,r=n.w;t.hasEdge(o,r)||(o=n.w,r=n.v);var a=e.node(o),i=e.node(r),s=a,l=!1;return a.lim>i.lim&&(s=i,l=!0),t.edges().filter((t=>l===bA(e,e.node(t.v),s)&&l!==bA(e,e.node(t.w),s))).reduce(((e,n)=>iA(t,n)<iA(t,e)?n:e))}function xA(e,t,n,o){var r=n.v,a=n.w;e.removeEdge(r,a),e.setEdge(o.v,o.w,{}),pA(e),fA(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),o=lA(e,n);(o=o.slice(1)).forEach((n=>{var o=e.node(n).parent,r=t.edge(n,o),a=!1;r||(r=t.edge(o,n),a=!0),t.node(n).rank=t.node(o).rank+(a?r.minlen:-r.minlen)}))}(e,t)}function bA(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}hA.initLowLimValues=pA,hA.initCutValues=fA,hA.calcCutValue=mA,hA.leaveEdge=vA,hA.enterEdge=yA,hA.exchangeEdges=xA;var wA=ZI.longestPath,kA=tA,SA=uA,NA=function(e){switch(e.graph().ranker){case"network-simplex":default:EA(e);break;case"tight-tree":!function(e){wA(e),kA(e)}(e);break;case"longest-path":CA(e)}};var CA=wA;function EA(e){SA(e)}let jA=LI;function _A(e,t,n,o,r,a,i){let s=e.children(i);if(!s.length)return void(i!==t&&e.setEdge(t,i,{weight:0,minlen:n}));let l=jA.addBorderNode(e,"_bt"),c=jA.addBorderNode(e,"_bb"),d=e.node(i);e.setParent(l,i),d.borderTop=l,e.setParent(c,i),d.borderBottom=c,s.forEach((s=>{_A(e,t,n,o,r,a,s);let d=e.node(s),u=d.borderTop?d.borderTop:s,h=d.borderBottom?d.borderBottom:s,f=d.borderTop?o:2*o,m=u!==h?1:r-a[i]+1;e.setEdge(l,u,{weight:f,minlen:m,nestingEdge:!0}),e.setEdge(h,c,{weight:f,minlen:m,nestingEdge:!0})})),e.parent(i)||e.setEdge(t,l,{weight:0,minlen:r+a[i]})}let IA=LI;function AA(e,t,n,o,r,a){let i={width:0,height:0,rank:a,borderType:t},s=r[t][a-1],l=IA.addDummyNode(e,"border",i,n);r[t][a]=l,e.setParent(l,o),s&&e.setEdge(s,l,{weight:1})}function TA(e){e.nodes().forEach((t=>MA(e.node(t)))),e.edges().forEach((t=>MA(e.edge(t))))}function MA(e){let t=e.width;e.width=e.height,e.height=t}function OA(e){e.y=-e.y}function DA(e){let t=e.x;e.x=e.y,e.y=t}let PA=LI;let RA=LI.zipObject;function LA(e,t,n){let o=RA(n,n.map(((e,t)=>t))),r=t.flatMap((t=>e.outEdges(t).map((t=>({pos:o[t.w],weight:e.edge(t).weight}))).sort(((e,t)=>e.pos-t.pos)))),a=1;for(;a<n.length;)a<<=1;let i=2*a-1;a-=1;let s=new Array(i).fill(0),l=0;return r.forEach((e=>{let t=e.pos+a;s[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=s[t+1]),t=t-1>>1,s[t]+=e.weight;l+=e.weight*n})),l}let zA=LI;let FA=LI;function BA(e,t,n){let o;for(;t.length&&(o=t[t.length-1]).i<=n;)t.pop(),e.push(o.vs),n++;return n}let UA=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let o=n.reduce(((t,n)=>{let o=e.edge(n),r=e.node(n.v);return{sum:t.sum+o.weight*r.order,weight:t.weight+o.weight}}),{sum:0,weight:0});return{v:t,barycenter:o.sum/o.weight,weight:o.weight}}return{v:t}}))},VA=function(e,t){let n={};return e.forEach(((e,t)=>{let o=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(o.barycenter=e.barycenter,o.weight=e.weight)})),t.edges().forEach((e=>{let t=n[e.v],o=n[e.w];void 0!==t&&void 0!==o&&(o.indegree++,t.out.push(n[e.w]))})),function(e){let t=[];function n(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,o=0;e.weight&&(n+=e.barycenter*e.weight,o+=e.weight);t.weight&&(n+=t.barycenter*t.weight,o+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/o,e.weight=o,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function o(t){return n=>{n.in.push(t),0==--n.indegree&&e.push(n)}}for(;e.length;){let r=e.pop();t.push(r),r.in.reverse().forEach(n(r)),r.out.forEach(o(r))}return t.filter((e=>!e.merged)).map((e=>zA.pick(e,["vs","i","barycenter","weight"])))}(Object.values(n).filter((e=>!e.indegree)))},HA=function(e,t){let n=FA.partition(e,(e=>Object.hasOwn(e,"barycenter"))),o=n.lhs,r=n.rhs.sort(((e,t)=>t.i-e.i)),a=[],i=0,s=0,l=0;o.sort((c=!!t,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:c?t.i-e.i:e.i-t.i)),l=BA(a,r,l),o.forEach((e=>{l+=e.vs.length,a.push(e.vs),i+=e.barycenter*e.weight,s+=e.weight,l=BA(a,r,l)}));var c;let d={vs:a.flat(!0)};s&&(d.barycenter=i/s,d.weight=s);return d};var $A=function e(t,n,o,r){let a=t.children(n),i=t.node(n),s=i?i.borderLeft:void 0,l=i?i.borderRight:void 0,c={};s&&(a=a.filter((e=>e!==s&&e!==l)));let d=UA(t,a);d.forEach((n=>{if(t.children(n.v).length){let s=e(t,n.v,o,r);c[n.v]=s,Object.hasOwn(s,"barycenter")&&(i=s,void 0!==(a=n).barycenter?(a.barycenter=(a.barycenter*a.weight+i.barycenter*i.weight)/(a.weight+i.weight),a.weight+=i.weight):(a.barycenter=i.barycenter,a.weight=i.weight))}var a,i}));let u=VA(d,o);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(u,c);let h=HA(u,r);if(s&&(h.vs=[s,h.vs,l].flat(!0),t.predecessors(s).length)){let e=t.node(t.predecessors(s)[0]),n=t.node(t.predecessors(l)[0]);Object.hasOwn(h,"barycenter")||(h.barycenter=0,h.weight=0),h.barycenter=(h.barycenter*h.weight+e.order+n.order)/(h.weight+2),h.weight+=2}return h};let WA=jI.Graph,GA=LI;let qA=function(e){let t={},n=e.nodes().filter((t=>!e.children(t).length)),o=n.map((t=>e.node(t).rank)),r=PA.applyWithChunking(Math.max,o),a=PA.range(r+1).map((()=>[]));return n.sort(((t,n)=>e.node(t).rank-e.node(n).rank)).forEach((function n(o){if(t[o])return;t[o]=!0;let r=e.node(o);a[r.rank].push(o),e.successors(o).forEach(n)})),a},YA=function(e,t){let n=0;for(let o=1;o<t.length;++o)n+=LA(e,t[o-1],t[o]);return n},XA=$A,KA=function(e,t,n){let o=function(e){var t;for(;e.hasNode(t=GA.uniqueId("_root")););return t}(e),r=new WA({compound:!0}).setGraph({root:o}).setDefaultNodeLabel((t=>e.node(t)));return e.nodes().forEach((a=>{let i=e.node(a),s=e.parent(a);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(r.setNode(a),r.setParent(a,s||o),e[n](a).forEach((t=>{let n=t.v===a?t.w:t.v,o=r.edge(n,a),i=void 0!==o?o.weight:0;r.setEdge(n,a,{weight:e.edge(t).weight+i})})),Object.hasOwn(i,"minRank")&&r.setNode(a,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))})),r},JA=function(e,t,n){let o,r={};n.forEach((n=>{let a,i,s=e.parent(n);for(;s;){if(a=e.parent(s),a?(i=r[a],r[a]=s):(i=o,o=s),i&&i!==s)return void t.setEdge(i,s);s=a}}))},ZA=jI.Graph,QA=LI;var eT=function e(t,n){if(n&&"function"==typeof n.customOrder)return void n.customOrder(t,e);let o=QA.maxRank(t),r=tT(t,QA.range(1,o+1),"inEdges"),a=tT(t,QA.range(o-1,-1,-1),"outEdges"),i=qA(t);if(oT(t,i),n&&n.disableOptimalOrderHeuristic)return;let s,l=Number.POSITIVE_INFINITY;for(let c=0,d=0;d<4;++c,++d){nT(c%2?r:a,c%4>=2),i=QA.buildLayerMatrix(t);let e=YA(t,i);e<l&&(d=0,s=Object.assign({},i),l=e)}oT(t,s)};function tT(e,t,n){return t.map((function(t){return KA(e,t,n)}))}function nT(e,t){let n=new ZA;e.forEach((function(e){let o=e.graph().root,r=XA(e,o,n,t);r.vs.forEach(((t,n)=>e.node(t).order=n)),JA(e,n,r.vs)}))}function oT(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}let rT=jI.Graph,aT=LI;var iT=function(e){let t,n=aT.buildLayerMatrix(e),o=Object.assign(sT(e,n),lT(e,n)),r={};["u","d"].forEach((a=>{t="u"===a?n:Object.values(n).reverse(),["l","r"].forEach((n=>{"r"===n&&(t=t.map((e=>Object.values(e).reverse())));let i=("u"===a?e.predecessors:e.successors).bind(e),s=uT(e,t,o,i),l=hT(e,t,s.root,s.align,"r"===n);"r"===n&&(l=aT.mapValues(l,(e=>-e))),r[a+n]=l}))}));let a=fT(e,r);return mT(r,a),pT(r,e.graph().align)};function sT(e,t){let n={};return t.length&&t.reduce((function(t,o){let r=0,a=0,i=t.length,s=o[o.length-1];return o.forEach(((t,l)=>{let c=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),d=c?e.node(c).order:i;(c||t===s)&&(o.slice(a,l+1).forEach((t=>{e.predecessors(t).forEach((o=>{let a=e.node(o),i=a.order;!(i<r||d<i)||a.dummy&&e.node(t).dummy||cT(n,o,t)}))})),a=l+1,r=d)})),o})),n}function lT(e,t){let n={};function o(t,o,r,a,i){let s;aT.range(o,r).forEach((o=>{s=t[o],e.node(s).dummy&&e.predecessors(s).forEach((t=>{let o=e.node(t);o.dummy&&(o.order<a||o.order>i)&&cT(n,t,s)}))}))}return t.length&&t.reduce((function(t,n){let r,a=-1,i=0;return n.forEach(((s,l)=>{if("border"===e.node(s).dummy){let t=e.predecessors(s);t.length&&(r=e.node(t[0]).order,o(n,i,l,a,r),i=l,a=r)}o(n,i,n.length,r,t.length)})),n})),n}function cT(e,t,n){if(t>n){let e=t;t=n,n=e}let o=e[t];o||(e[t]=o={}),o[n]=!0}function dT(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function uT(e,t,n,o){let r={},a={},i={};return t.forEach((e=>{e.forEach(((e,t)=>{r[e]=e,a[e]=e,i[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let s=o(e);if(s.length){s=s.sort(((e,t)=>i[e]-i[t]));let o=(s.length-1)/2;for(let l=Math.floor(o),c=Math.ceil(o);l<=c;++l){let o=s[l];a[e]===e&&t<i[o]&&!dT(n,e,o)&&(a[o]=e,a[e]=r[e]=r[o],t=i[o])}}}))})),{root:r,align:a}}function hT(e,t,n,o,r){let a={},i=function(e,t,n,o){let r=new rT,a=e.graph(),i=function(e,t,n){return(o,r,a)=>{let i,s=o.node(r),l=o.node(a),c=0;if(c+=s.width/2,Object.hasOwn(s,"labelpos"))switch(s.labelpos.toLowerCase()){case"l":i=-s.width/2;break;case"r":i=s.width/2}if(i&&(c+=n?i:-i),i=0,c+=(s.dummy?t:e)/2,c+=(l.dummy?t:e)/2,c+=l.width/2,Object.hasOwn(l,"labelpos"))switch(l.labelpos.toLowerCase()){case"l":i=l.width/2;break;case"r":i=-l.width/2}return i&&(c+=n?i:-i),i=0,c}}(a.nodesep,a.edgesep,o);return t.forEach((t=>{let o;t.forEach((t=>{let a=n[t];if(r.setNode(a),o){var s=n[o],l=r.edge(s,a);r.setEdge(s,a,Math.max(i(e,t,o),l||0))}o=t}))})),r}(e,t,n,r),s=r?"borderLeft":"borderRight";function l(e,t){let n=i.nodes(),o=n.pop(),r={};for(;o;)r[o]?e(o):(r[o]=!0,n.push(o),n=n.concat(t(o))),o=n.pop()}return l((function(e){a[e]=i.inEdges(e).reduce(((e,t)=>Math.max(e,a[t.v]+i.edge(t))),0)}),i.predecessors.bind(i)),l((function(t){let n=i.outEdges(t).reduce(((e,t)=>Math.min(e,a[t.w]-i.edge(t))),Number.POSITIVE_INFINITY),o=e.node(t);n!==Number.POSITIVE_INFINITY&&o.borderType!==s&&(a[t]=Math.max(a[t],n))}),i.successors.bind(i)),Object.keys(o).forEach((e=>a[e]=a[n[e]])),a}function fT(e,t){return Object.values(t).reduce(((t,n)=>{let o=Number.NEGATIVE_INFINITY,r=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let a=function(e,t){return e.node(t).width}(e,t)/2;o=Math.max(n+a,o),r=Math.min(n-a,r)}));const a=o-r;return a<t[0]&&(t=[a,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function mT(e,t){let n=Object.values(t),o=aT.applyWithChunking(Math.min,n),r=aT.applyWithChunking(Math.max,n);["u","d"].forEach((n=>{["l","r"].forEach((a=>{let i=n+a,s=e[i];if(s===t)return;let l=Object.values(s),c=o-aT.applyWithChunking(Math.min,l);"l"!==a&&(c=r-aT.applyWithChunking(Math.max,l)),c&&(e[i]=aT.mapValues(s,(e=>e+c)))}))}))}function pT(e,t){return aT.mapValues(e.ul,((n,o)=>{if(t)return e[t.toLowerCase()][o];{let t=Object.values(e).map((e=>e[o])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}let gT=LI,vT=iT;let yT=YI,xT=KI,bT=NA,wT=LI.normalizeRanks,kT=function(e){let t=function(e){let t={},n=0;function o(r){let a=n;e.children(r).forEach(o),t[r]={low:a,lim:n++}}return e.children().forEach(o),t}(e);e.graph().dummyChains.forEach((n=>{let o=e.node(n),r=o.edgeObj,a=function(e,t,n,o){let r,a,i=[],s=[],l=Math.min(t[n].low,t[o].low),c=Math.max(t[n].lim,t[o].lim);r=n;do{r=e.parent(r),i.push(r)}while(r&&(t[r].low>l||c>t[r].lim));a=r,r=o;for(;(r=e.parent(r))!==a;)s.push(r);return{path:i.concat(s.reverse()),lca:a}}(e,t,r.v,r.w),i=a.path,s=a.lca,l=0,c=i[l],d=!0;for(;n!==r.w;){if(o=e.node(n),d){for(;(c=i[l])!==s&&e.node(c).maxRank<o.rank;)l++;c===s&&(d=!1)}if(!d){for(;l<i.length-1&&e.node(c=i[l+1]).minRank<=o.rank;)l++;c=i[l]}e.setParent(n,c),n=e.successors(n)[0]}}))},ST=LI.removeEmptyRanks,NT={run:function(e){let t=jA.addDummyNode(e,"root",{},"_root"),n=function(e){var t={};function n(o,r){var a=e.children(o);a&&a.length&&a.forEach((e=>n(e,r+1))),t[o]=r}return e.children().forEach((e=>n(e,1))),t}(e),o=Object.values(n),r=jA.applyWithChunking(Math.max,o)-1,a=2*r+1;e.graph().nestingRoot=t,e.edges().forEach((t=>e.edge(t).minlen*=a));let i=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(e)+1;e.children().forEach((o=>_A(e,t,a,i,r,n,o))),e.graph().nodeRankFactor=a},cleanup:function(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach((t=>{e.edge(t).nestingEdge&&e.removeEdge(t)}))}},CT=function(e){e.children().forEach((function t(n){let o=e.children(n),r=e.node(n);if(o.length&&o.forEach(t),Object.hasOwn(r,"minRank")){r.borderLeft=[],r.borderRight=[];for(let t=r.minRank,o=r.maxRank+1;t<o;++t)AA(e,"borderLeft","_bl",n,r,t),AA(e,"borderRight","_br",n,r,t)}}))},ET={adjust:function(e){let t=e.graph().rankdir.toLowerCase();"lr"!==t&&"rl"!==t||TA(e)},undo:function(e){let t=e.graph().rankdir.toLowerCase();"bt"!==t&&"rl"!==t||function(e){e.nodes().forEach((t=>OA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(OA),Object.hasOwn(n,"y")&&OA(n)}))}(e);"lr"!==t&&"rl"!==t||(!function(e){e.nodes().forEach((t=>DA(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(DA),Object.hasOwn(n,"x")&&DA(n)}))}(e),TA(e))}},jT=eT,_T=function(e){(function(e){let t=gT.buildLayerMatrix(e),n=e.graph().ranksep,o=0;t.forEach((t=>{const r=t.reduce(((t,n)=>{const o=e.node(n).height;return t>o?t:o}),0);t.forEach((t=>e.node(t).y=o+r/2)),o+=r+n}))})(e=gT.asNonCompoundGraph(e)),Object.entries(vT(e)).forEach((([t,n])=>e.node(t).x=n))},IT=LI,AT=jI.Graph;var TT=function(e,t){let n=t&&t.debugTiming?IT.time:IT.notime;n("layout",(()=>{let o=n(" buildLayoutGraph",(()=>function(e){let t=new AT({multigraph:!0,compound:!0}),n=UT(e.graph());return t.setGraph(Object.assign({},OT,BT(n,MT),IT.pick(n,DT))),e.nodes().forEach((n=>{const o=BT(UT(e.node(n)),PT);Object.keys(RT).forEach((e=>{void 0===o[e]&&(o[e]=RT[e])})),t.setNode(n,o),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let o=UT(e.edge(n));t.setEdge(n,Object.assign({},zT,BT(o,LT),IT.pick(o,FT)))})),t}(e)));n(" runLayout",(()=>function(e,t,n){t(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let o=e.edge(n);o.minlen*=2,"c"!==o.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?o.width+=o.labeloffset:o.height+=o.labeloffset)}))}(e))),t(" removeSelfEdges",(()=>function(e){e.edges().forEach((t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||(n.selfEdges=[]),n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}}))}(e))),t(" acyclic",(()=>yT.run(e))),t(" nestingGraph.run",(()=>NT.run(e))),t(" rank",(()=>bT(IT.asNonCompoundGraph(e)))),t(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),o={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};IT.addDummyNode(e,"edge-proxy",o,"_ep")}}))}(e))),t(" removeEmptyRanks",(()=>ST(e))),t(" nestingGraph.cleanup",(()=>NT.cleanup(e))),t(" normalizeRanks",(()=>wT(e))),t(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let o=e.node(n);o.borderTop&&(o.minRank=e.node(o.borderTop).rank,o.maxRank=e.node(o.borderBottom).rank,t=Math.max(t,o.maxRank))})),e.graph().maxRank=t}(e))),t(" removeEdgeLabelProxies",(()=>function(e){e.nodes().forEach((t=>{let n=e.node(t);"edge-proxy"===n.dummy&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))}))}(e))),t(" normalize.run",(()=>xT.run(e))),t(" parentDummyChains",(()=>kT(e))),t(" addBorderSegments",(()=>CT(e))),t(" order",(()=>jT(e,n))),t(" insertSelfEdges",(()=>function(e){var t=IT.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,o)=>{var r=e.node(t);r.order=o+n,(r.selfEdges||[]).forEach((t=>{IT.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:r.rank,order:o+ ++n,e:t.e,label:t.label},"_se")})),delete r.selfEdges}))}))}(e))),t(" adjustCoordinateSystem",(()=>ET.adjust(e))),t(" position",(()=>_T(e))),t(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var o=e.node(n.e.v),r=o.x+o.width/2,a=o.y,i=n.x-r,s=o.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:r+2*i/3,y:a-s},{x:r+5*i/6,y:a-s},{x:r+i,y:a},{x:r+5*i/6,y:a+s},{x:r+2*i/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}}))}(e))),t(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),o=e.node(n.borderTop),r=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-a.x),n.height=Math.abs(r.y-o.y),n.x=a.x+n.width/2,n.y=o.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(e))),t(" normalize.undo",(()=>xT.undo(e))),t(" fixupEdgeLabelCoords",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(Object.hasOwn(n,"x"))switch("l"!==n.labelpos&&"r"!==n.labelpos||(n.width-=n.labeloffset),n.labelpos){case"l":n.x-=n.width/2+n.labeloffset;break;case"r":n.x+=n.width/2+n.labeloffset}}))}(e))),t(" undoCoordinateSystem",(()=>ET.undo(e))),t(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,o=Number.POSITIVE_INFINITY,r=0,a=e.graph(),i=a.marginx||0,s=a.marginy||0;function l(e){let a=e.x,i=e.y,s=e.width,l=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),o=Math.min(o,i-l/2),r=Math.max(r,i+l/2)}e.nodes().forEach((t=>l(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);Object.hasOwn(n,"x")&&l(n)})),t-=i,o-=s,e.nodes().forEach((n=>{let r=e.node(n);r.x-=t,r.y-=o})),e.edges().forEach((n=>{let r=e.edge(n);r.points.forEach((e=>{e.x-=t,e.y-=o})),Object.hasOwn(r,"x")&&(r.x-=t),Object.hasOwn(r,"y")&&(r.y-=o)})),a.width=n-t+i,a.height=r-o+s}(e))),t(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,o,r=e.edge(t),a=e.node(t.v),i=e.node(t.w);r.points?(n=r.points[0],o=r.points[r.points.length-1]):(r.points=[],n=i,o=a),r.points.unshift(IT.intersectRect(a,n)),r.points.push(IT.intersectRect(i,o))}))}(e))),t(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(e))),t(" acyclic.undo",(()=>yT.undo(e)))}(o,n,t))),n(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let o=e.node(n),r=t.node(n);o&&(o.x=r.x,o.y=r.y,o.rank=r.rank,t.children(n).length&&(o.width=r.width,o.height=r.height))})),e.edges().forEach((n=>{let o=e.edge(n),r=t.edge(n);o.points=r.points,Object.hasOwn(r,"x")&&(o.x=r.x,o.y=r.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(e,o)))}))};let MT=["nodesep","edgesep","ranksep","marginx","marginy"],OT={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},DT=["acyclicer","ranker","rankdir","align"],PT=["width","height"],RT={width:0,height:0},LT=["minlen","weight","width","height","labeloffset"],zT={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},FT=["labelpos"];function BT(e,t){return IT.mapValues(IT.pick(e,t),Number)}function UT(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}let VT=LI,HT=jI.Graph;var $T={graphlib:jI,layout:TT,debug:{debugOrdering:function(e){let t=VT.buildLayerMatrix(e),n=new HT({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach((t=>{n.setNode(t,{label:t}),n.setParent(t,"layer"+e.node(t).rank)})),e.edges().forEach((e=>n.setEdge(e.v,e.w,{},e.name))),t.forEach(((e,t)=>{let o="layer"+t;n.setNode(o,{rank:"same"}),e.reduce(((e,t)=>(n.setEdge(e,t,{style:"invis"}),t)))})),n}},util:{time:LI.time,notime:LI.notime},version:"1.1.4"};const WT=(new $T.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),GT=(e,t,n)=>(WT.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>WT.setEdge(e.source,e.target))),e.forEach((e=>WT.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),$T.layout(WT),{nodes:e.map((e=>{const{x:t,y:n}=WT.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),qT=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:dC.ArrowClosed},id:`${e}-${t}`,style:{strokeWidth:2},source:e,sourceHandle:"outputs",targetHandle:"inputs",target:t}}createNode(e,t){return{id:e,data:{atom:t,forceWidth:300},width:300,type:"custom",height:I_(te.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,o){const r=[],a=[],i=new Set,s=new Set;for(const l of Object.values(n)){if("marimo"===l.value&&"mo"===l.name)continue;const{declaredBy:e,usedBy:t}=l;for(const n of e)for(const e of t){const t=`${n}-${e}`;s.has(t)||(s.add(t),i.add(n),i.add(e),a.push(this.createEdge(n,e)))}}for(const[l,c]of Ta.zip(e,t)){o||r.push(this.createNode(l,c));const e=i.has(l),t=te.get(c).code.trim().startsWith("mo.md");!e&&t||r.push(this.createNode(l,c))}return{nodes:r,edges:a}}},YT=({cellIds:e,variables:t,cellAtoms:n,children:o,layoutDirection:a,settings:i})=>{const s=r.useMemo((()=>{let o=qT.createElements(e,n,t,i.hidePureMarkdown);return o=GT(o.nodes,o.edges,{direction:a}),o}),[]),[l,c,d]=c_(s.nodes),[u,h,f]=d_(s.edges),m=PE(),p=G((e=>{const t=GT(e.nodes,e.edges,{direction:a});c(t.nodes),h(t.edges)}));r.useEffect((()=>{p(qT.createElements(e,n,t,i.hidePureMarkdown))}),[e,t,n,p,i.hidePureMarkdown]);const[g,v]=r.useState();F_();return k.jsx(A_.Provider,{value:a,children:k.jsxs(s_,{nodes:l,edges:u,nodeTypes:M_,minZoom:.2,fitViewOptions:{minZoom:.5,maxZoom:1.5},onNodeClick:(e,t)=>{v({type:"node",id:t.id})},onEdgeClick:(e,t)=>{const{source:n,target:o}=t;v({type:"edge",source:n,target:o})},onNodeDoubleClick:(e,t)=>{bi(t.id,"focus")},fitView:!0,onNodesChange:d,onEdgesChange:f,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[k.jsx(__,{color:"#ccc",variant:x_.Dots}),k.jsx(w_,{position:"bottom-right",showInteractive:!1,children:k.jsx(N,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:k.jsx(g_,{onMouseDown:tt.preventFocus,onClick:()=>{const e=te.get(Pd);if(e){const t=l.find((t=>t.id===e));t&&(m.fitView({padding:1,duration:600,nodes:[t]}),v({type:"node",id:e}))}},children:k.jsx(xc,{className:"size-4"})})})}),k.jsx(L_,{selection:g,variables:t,edges:u,onClearSelection:()=>{v(void 0)}}),o]})})},XT=Z("_minimap_"),KT=Z({hidePureMarkdown:!0}),JT=e=>{const t=b(11),[n,o]=Le(XT),[r,a]=Le(KT);let i;t[0]!==n||t[1]!==e||t[2]!==r||t[3]!==a||t[4]!==o?(i=()=>"_minimap_"===n?k.jsx(H_,{...e,children:k.jsx(R_,{settings:r,onSettingsChange:a,view:n,onChange:o})}):k.jsx(YT,{...e,settings:r,layoutDirection:n,children:k.jsx(R_,{settings:r,onSettingsChange:a,view:n,onChange:o})}),t[0]=n,t[1]=e,t[2]=r,t[3]=a,t[4]=o,t[5]=i):i=t[5];const s=i;let l,c;return t[6]!==s?(l=s(),t[6]=s,t[7]=l):l=t[7],t[8]!==n||t[9]!==l?(c=k.jsx(Qj,{children:l},n),t[8]=n,t[9]=l,t[10]=c):c=t[10],c},ZT=()=>{const e=b(5),t=wi(),n=he(),[o]=ki();let r,a;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=rn("w-full h-full flex-1 mx-auto -mb-4 relative"),e[0]=r):r=e[0],e[1]!==o||e[2]!==t||e[3]!==n.inOrderIds?(a=k.jsx("div",{className:r,children:k.jsx(JT,{cellAtoms:o,variables:t,cellIds:n.inOrderIds})}),e[1]=o,e[2]=t,e[3]=n.inOrderIds,e[4]=a):a=e[4],a};const QT="name",eM="type-value",tM="defs-refs",nM=[{id:QT,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>k.jsx(Li,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return k.jsx(P_,{name:t,declaredBy:n})}},{id:eM,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>k.jsx(Li,{header:k.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsx("span",{children:"Type"}),k.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return k.jsxs("div",{className:"max-w-[150px]",children:[k.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),k.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:tM,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>k.jsx(Li,{header:k.jsxs("div",{className:"flex flex-col gap-1",children:[k.jsx("span",{children:"Declared By"}),k.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,o]=e(),r=e=>{const t=Yr(e);t&&yi(t,o)};return k.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[k.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[k.jsx("span",{title:"Declared by",children:k.jsx(Vc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?k.jsx(gi,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>r(t[0])}):k.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>k.jsxs("span",{className:"flex",children:[k.jsx(gi,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(e)},e),n<t.length-1&&", "]},e)))})]}),k.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[k.jsx("span",{title:"Used by",children:k.jsx(Qc,{className:"w-3.5 h-3.5 text-muted-foreground"})}),k.jsx(D_,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}];const oM=r.memo((({className:e,cellIds:t,variables:n})=>{const[o,a]=u.useState([]),[i,s]=u.useState(""),l=Si(),c=r.useMemo((()=>{const e=e=>{const n=l[e];return n===Ri?`cell-${t.indexOf(e)}`:n??`cell-${t.indexOf(e)}`};return Object.values(n).map((t=>({...t,declaredByNames:t.declaredBy.map(e),usedByNames:t.usedBy.map(e)})))}),[n,l,t]),d=r.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:tM,desc:!1});let o=[];switch(t.id){case QT:o=Fl(e,(e=>e.name));break;case eM:o=Fl(e,(e=>e.dataType));break;case tM:o=Fl(e,(e=>n.get(e.declaredBy[0])))}return t.desc?o.reverse():o}(c,o[0],e)}),[c,o,t]),h=Ni({data:d,columns:nM,getCoreRowModel:Ci(),onGlobalFilterChange:s,getFilteredRowModel:Ei(),enableFilters:!0,enableGlobalFilter:!0,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:a,getSortedRowModel:ji(),state:{sorting:o,globalFilter:i}});return k.jsxs(k.Fragment,{children:[k.jsx(_i,{className:"w-full",placeholder:"Search",value:i,onChange:e=>s(e.target.value)}),k.jsxs(Ii,{className:rn("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[k.jsx(Ai,{children:k.jsx(Ti,{className:"whitespace-nowrap text-xs",children:h.getFlatHeaders().map((e=>k.jsx(Mi,{className:"sticky top-0 bg-background border-b",children:Oi(e.column.columnDef.header,e.getContext())},e.id)))})}),k.jsx(Di,{children:h.getRowModel().rows.map((e=>k.jsx(Ti,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>k.jsx(Pi,{className:"border-b",children:Oi(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));oM.displayName="VariableTable";const rM=()=>{const e=b(4),t=wi(),n=he();if(0===Object.keys(t).length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No variables",description:"Global variables will appear here.",icon:k.jsx(ct,{})}),e[0]=t):t=e[0],t}let o;return e[1]!==n.inOrderIds||e[2]!==t?(o=k.jsx(oM,{className:"flex-1",cellIds:n.inOrderIds,variables:t}),e[1]=n.inOrderIds,e[2]=t,e[3]=o):o=e[3],o},aM=()=>{const e=b(9),t=zi(),{clearLogs:n}=q();if(0===t.length){let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx("code",{className:"border rounded px-1",children:"stdout"}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(FS,{title:"No logs",description:k.jsxs("span",{children:[t," and"," ",k.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:k.jsx(ut,{})}),e[1]=n):n=e[1],n}let o,r,a;return e[2]!==n?(o=k.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:k.jsx("button",{"data-testid":"clear-logs-button",className:"text-xs font-semibold text-accent-foreground",onClick:n,children:"Clear"})}),e[2]=n,e[3]=o):o=e[3],e[4]!==t?(r=k.jsx("div",{className:"overflow-auto flex-1",children:k.jsx(iM,{logs:t,className:"min-w-[300px]"})}),e[4]=t,e[5]=r):r=e[5],e[6]!==o||e[7]!==r?(a=k.jsxs(k.Fragment,{children:[o,r]}),e[6]=o,e[7]=r,e[8]=a):a=e[8],a},iM=e=>{const t=b(11),{logs:n,className:o}=e;let r,a,i,s,l;if(t[0]!==o?(r=rn("flex flex-col",o),t[0]=o,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(a={whiteSpace:"pre-wrap"},t[2]=a):a=t[2],t[3]!==n){let e;t[5]===Symbol.for("react.memo_cache_sentinel")?(e=(e,t)=>k.jsxs("div",{className:"contents group",children:[k.jsx("span",{className:rn("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:t+1}),k.jsx("span",{className:rn("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:sM(e)})]},t),t[5]=e):e=t[5],i=n.map(e),t[3]=n,t[4]=i}else i=t[4];return t[6]!==i?(s=k.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:k.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:a,children:i})}),t[6]=i,t[7]=s):s=t[7],t[8]!==r||t[9]!==s?(l=k.jsx("div",{className:r,children:s}),t[8]=r,t[9]=s,t[10]=l):l=t[10],l};function sM(e){const t=Fi(e.timestamp),n=lM[e.level],o=e.level.toUpperCase();return k.jsxs(k.Fragment,{children:[k.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["[",t,"]"]}),k.jsx("span",{className:rn("flex-shrink-0",n),children:o}),k.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",k.jsx(gi,{cellId:e.cellId}),")"]}),e.message]})}const lM={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"},cM=()=>{const e=b(5),{documentation:t}=le(Bi);if(!t){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:k.jsx(Xc,{})}),e[0]=t):t=e[0],t}let n,o;return e[1]!==t?(n=xa({html:t}),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(o=k.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:n}),e[3]=n,e[4]=o):o=e[4],o};function dM(e,t,n){return e[t]?e[t][0]?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function uM(e){void 0===e&&(e={});var t=e.onResize,n=r.useRef(void 0);n.current=t;var o=e.round||Math.round,a=r.useRef(),i=r.useState({width:void 0,height:void 0}),s=i[0],l=i[1],c=r.useRef(!1);r.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=r.useRef({width:void 0,height:void 0}),u=function(e,t){var n=r.useRef(null),o=r.useRef(null);o.current=t;var a=r.useRef(null);r.useEffect((function(){i()}));var i=r.useCallback((function(){var t=a.current,r=o.current,i=t||(r?r instanceof Element?r:r.current:null);n.current&&n.current.element===i&&n.current.subscriber===e||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:i,subscriber:e,cleanup:i?e(i):void 0})}),[e]);return r.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),r.useCallback((function(e){a.current=e,i()}),[i])}(r.useCallback((function(t){return a.current&&a.current.box===e.box&&a.current.round===o||(a.current={box:e.box,round:o,instance:new ResizeObserver((function(t){var r=t[0],a="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",i=dM(r,a,"inlineSize"),s=dM(r,a,"blockSize"),u=i?o(i):void 0,h=s?o(s):void 0;if(d.current.width!==u||d.current.height!==h){var f={width:u,height:h};d.current.width=u,d.current.height=h,n.current?n.current(f):c.current||l(f)}}))}),a.current.instance.observe(t,{box:e.box}),function(){a.current&&a.current.instance.unobserve(t)}}),[e.box,o]),e.ref);return r.useMemo((function(){return{ref:u,width:s.width,height:s.height}}),[u,s.width,s.height])}const hM=new Map,fM=({file:e,onOpenNotebook:t})=>{const{theme:n}=Me(),o=le(ze),[a,i]=r.useState(""),{data:s,loading:l,error:c,setData:d}=sn((async()=>{const t=await Ui({path:e.path}),n=t.contents||"";return i(hM.get(e.path)||n),t}),[e.path]),u=async()=>{a!==(null==s?void 0:s.contents)&&await Xi({path:e.path,contents:a}).then((e=>{e.success&&(d((e=>e?{...e,contents:a}:void 0)),i(a))}))},h=r.useRef(a);if(h.current=a,r.useEffect((()=>()=>{if(!s)return;const t=h.current;t===s.contents?hM.delete(e.path):hM.set(e.path,t)}),[e.path,null==s?void 0:s.contents]),c)return k.jsx(Vi,{error:c});if(l||!s)return null;const f=s.mimeType||"text/plain",m=f in pM;if(!s.contents&&!m)return k.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[k.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),k.jsx("div",{children:s.file.name}),k.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),k.jsx("div",{children:f})]});const p=k.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!D()&&k.jsx(N,{content:"Open notebook",children:k.jsx(Es,{size:"small",onClick:e=>t(e),children:k.jsx(Hi,{})})}),k.jsx(N,{content:"Download",children:k.jsx(Es,{size:"small",onClick:()=>{if(mM(f)){const e=Ki(s.contents,f);Ji(e,s.file.name)}else E(new Blob([s.contents||a],{type:f}),s.file.name)},children:k.jsx(Nt,{})})}),!mM(f)&&k.jsxs(k.Fragment,{children:[k.jsx(N,{content:"Copy contents to clipboard",children:k.jsx(Es,{size:"small",onClick:async()=>{await et(a)},children:k.jsx(nt,{})})}),k.jsx(N,{content:S("global.save"),children:k.jsx(Es,{size:"small",color:a===s.contents?void 0:"green",onClick:u,disabled:a===s.contents,children:k.jsx(Pc,{})})})]})]});return f.startsWith("image/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx($i,{base64:s.contents,mime:f})})]}):"text/csv"===f&&s.contents?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(Wi,{contents:s.contents})})]}):f.startsWith("audio/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(Gi,{base64:s.contents,mime:f})})]}):f.startsWith("video/")?k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:k.jsx(qi,{base64:s.contents,mime:f})})]}):k.jsxs(k.Fragment,{children:[p,k.jsx("div",{className:"flex-1 overflow-auto",children:k.jsx(Yi,{theme:"dark"===n?"dark":"light",language:pM[f]||pM.default,className:"border-b",extensions:[Yt.lineWrapping,pn.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>a!==s.contents&&(u(),!0)}])],value:a,onChange:i})})]})},mM=e=>!!e&&(e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/")),pM={"application/javascript":"javascript","text/markdown":"markdown","text/html":"html","text/css":"css","text/x-python":"python","application/json":"json","application/xml":"xml","text/x-yaml":"yaml","text/csv":"markdown","text/plain":"markdown",default:"markdown"};const gM=Z(new class{constructor(e){this.callbacks=e,this.delegate=new Qs([]),this.rootPath="",this.onChange=an.NOOP,this.path=new pt("/"),this.initialize=async e=>{if(this.onChange=e,0===this.delegate.data.length)try{const e=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Qs(e.files),this.rootPath=e.root,this.path=pt.guessDeliminator(e.root)}catch(t){re({title:"Failed",description:Vr(t)})}this.onChange(this.delegate.data)},this.refreshAll=async e=>{const t=[this.rootPath,...e.map((e=>{var t;return null==(t=this.delegate.find(e))?void 0:t.data.path}))].filter(Boolean),n=await Promise.all(t.map((e=>this.callbacks.listFiles({path:e}).catch((()=>({files:[]}))))));for(const[o,r]of t.entries()){const e=n[o];r===this.rootPath?this.delegate=new Qs(e.files):this.delegate.update({id:r,changes:{children:e.files}})}this.onChange(this.delegate.data)},this.relativeFromRoot=e=>{const t=function(e){return e.endsWith("/")?e:`${e}/`}(this.rootPath);return e.startsWith(t)?e.slice(t.length):e},this.handleResponse=e=>e.success?e:(re({title:"Failed",description:e.message}),null)}async expand(e){const t=this.delegate.find(e);if(!t)return!1;if(!t.data.isDirectory)return!1;if(t.children&&t.children.length>0)return!0;const n=await this.callbacks.listFiles({path:t.data.path});return this.delegate.update({id:e,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(e,t){const n=this.delegate.find(e);if(!n)return;const o=n.data.path,r=this.path.join(this.path.dirname(o),t);await this.callbacks.renameFileOrFolder({path:o,newPath:r}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath;await Promise.all(e.map((e=>{this.delegate.move({id:e,parentId:t,index:0});const n=this.delegate.find(e);if(!n)return Promise.resolve();const r=this.path.join(o,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:r}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:r}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([o])}async createFile(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"file",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async createFolder(e,t){var n;const o=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,r=await this.callbacks.createFileOrFolder({path:o,type:"directory",name:e}).then(this.handleResponse);(null==r?void 0:r.info)&&(this.delegate.create({parentId:t,index:0,data:r.info}),this.onChange(this.delegate.data),await this.refreshAll([o]))}async delete(e){const t=this.delegate.find(e);t&&(await this.callbacks.deleteFileOrFolder({path:t.data.path}).then(this.handleResponse),this.delegate.drop({id:e}),this.onChange(this.delegate.data))}}({listFiles:cn,createFileOrFolder:Zi,deleteFileOrFolder:Qi,renameFileOrFolder:es})),vM=Z({});function yM(e){const t=b(4);let n;t[0]!==e?(n=void 0===e?{}:e,t[0]=e,t[1]=n):n=t[1];const o=n;let r;return t[2]!==o?(r={multiple:!0,maxSize:104857600,onError:SM,onDropRejected:bM,onDrop:xM,...o},t[2]=o,t[3]=r):r=t[3],ts(r)}async function xM(e){for(const t of e){const e=(await ns(t)).split(",")[1];await Zi({path:"",type:"file",name:t.name,contents:e})}await async function(){await te.get(gM).refreshAll([])}()}function bM(e){re({title:"File upload failed",description:k.jsx("div",{className:"flex flex-col gap-1",children:e.map(wM)}),variant:"danger"})}function wM(e){return k.jsxs("div",{children:[e.file.name," (",e.errors.map(kM).join(", "),")"]},e.file.name)}function kM(e){return e.message}function SM(e){J.error(e),re({title:"File upload failed",description:e.message,variant:"danger"})}const NM=u.createContext(null),CM=e=>{const t=b(60),{height:n}=e,o=r.useRef(null),[a]=Le(gM);let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i=[],t[0]=i):i=t[0];const[s,l]=r.useState(i),[c,d]=r.useState(null),{openPrompt:u}=w(),[h,f]=Le(vM);let m,p;t[1]!==a?(m=()=>a.initialize(l),t[1]=a,t[2]=m):m=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(p=[],t[3]=p):p=t[3];const{loading:g,error:v}=sn(m,p);let y;t[4]!==a||t[5]!==h?(y=()=>{a.refreshAll(Object.keys(h).filter((e=>h[e])))},t[4]=a,t[5]=h,t[6]=y):y=t[6];const x=G(y);let S;t[7]!==u||t[8]!==a?(S=async()=>{u({title:"Folder name",onConfirm:async e=>{a.createFolder(e,null)}})},t[7]=u,t[8]=a,t[9]=S):S=t[9];const N=G(S);let E;t[10]!==u||t[11]!==a?(E=async()=>{u({title:"File name",onConfirm:async e=>{a.createFile(e,null)}})},t[10]=u,t[11]=a,t[12]=E):E=t[12];const j=G(E);let _;t[13]!==f?(_=()=>{var e;null==(e=o.current)||e.closeAll(),f({})},t[13]=f,t[14]=_):_=t[14];const I=G(_);if(g){let e;return t[15]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(oi,{size:"medium",centered:!0}),t[15]=e):e=t[15],e}if(v){let e;return t[16]!==v?(e=k.jsx(Vi,{error:v}),t[16]=v,t[17]=e):e=t[17],e}if(c){let e,n,o,i,s,l;return t[18]===Symbol.for("react.memo_cache_sentinel")?(e=()=>d(null),t[18]=e):e=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(n=k.jsx(C,{onClick:e,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:k.jsx(Bl,{size:16})}),t[19]=n):n=t[19],t[20]!==c.name?(o=k.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[n,k.jsx("span",{className:"font-bold",children:c.name})]}),t[20]=c.name,t[21]=o):o=t[21],t[22]!==a||t[23]!==c.path?(i=e=>MM(e,a.relativeFromRoot(c.path)),t[22]=a,t[23]=c.path,t[24]=i):i=t[24],t[25]!==i||t[26]!==c?(s=k.jsx(r.Suspense,{children:k.jsx(fM,{onOpenNotebook:i,file:c})}),t[25]=i,t[26]=c,t[27]=s):s=t[27],t[28]!==o||t[29]!==s?(l=k.jsxs(k.Fragment,{children:[o,s]}),t[28]=o,t[29]=s,t[30]=l):l=t[30],l}let A;t[31]!==x||t[32]!==j||t[33]!==N||t[34]!==I||t[35]!==a?(A=k.jsx(jM,{onRefresh:x,onCreateFile:j,onCreateFolder:N,onCollapseAll:I,tree:a}),t[31]=x,t[32]=j,t[33]=N,t[34]=I,t[35]=a,t[36]=A):A=t[36];const T=n-33;let M,O,D,P,R,L,z,F;return t[37]!==a?(M=async e=>{const{ids:t}=e;for(const n of t)await a.delete(n)},O=async e=>{const{id:t,name:n}=e;await a.rename(t,n)},D=async e=>{const{dragIds:t,parentId:n}=e;await a.move(t,n)},t[37]=a,t[38]=M,t[39]=O,t[40]=D):(M=t[38],O=t[39],D=t[40]),t[41]===Symbol.for("react.memo_cache_sentinel")?(P=e=>{const t=e[0];t&&(t.data.isDirectory||d(t.data))},t[41]=P):P=t[41],t[42]!==a||t[43]!==h||t[44]!==f?(R=async e=>{if(await a.expand(e)){const t=h[e]??!1;f({...h,[e]:!t})}},t[42]=a,t[43]=h,t[44]=f,t[45]=R):R=t[45],t[46]!==T||t[47]!==s||t[48]!==h||t[49]!==M||t[50]!==O||t[51]!==D||t[52]!==R?(L=k.jsx(el,{width:"100%",ref:o,height:T,className:"h-full",data:s,initialOpenState:h,openByDefault:!1,renderCursor:OM,disableDrop:DM,onDelete:M,onRename:O,onMove:D,onSelect:P,onToggle:R,padding:15,rowHeight:30,indent:EM,overscanCount:1e3,disableMultiSelection:!0,children:AM}),t[46]=T,t[47]=s,t[48]=h,t[49]=M,t[50]=O,t[51]=D,t[52]=R,t[53]=L):L=t[53],t[54]!==a||t[55]!==L?(z=k.jsx(NM.Provider,{value:a,children:L}),t[54]=a,t[55]=L,t[56]=z):z=t[56],t[57]!==A||t[58]!==z?(F=k.jsxs(k.Fragment,{children:[A,z]}),t[57]=A,t[58]=z,t[59]=F):F=t[59],F},EM=15,jM=e=>{const t=b(30),{onRefresh:n,onCreateFile:o,onCreateFolder:r,onCollapseAll:a}=e;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={noDrag:!0,noDragEventsBubbling:!0},t[0]=i):i=t[0];const{getRootProps:s,getInputProps:l}=yM(i);let c,d,u,h,f,m,p,g,v,y,x,w,S,E,j;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(sc,{size:16}),t[1]=c):c=t[1],t[2]!==o?(d=k.jsx(N,{content:"Add file",children:k.jsx(C,{"data-testid":"file-explorer-add-file-button",onClick:o,variant:"text",size:"xs",children:c})}),t[2]=o,t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(cc,{size:16}),t[4]=u):u=t[4],t[5]!==r?(h=k.jsx(N,{content:"Add folder",children:k.jsx(C,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:u})}),t[5]=r,t[6]=h):h=t[6],t[7]!==s?(f=s({}),t[7]=s,t[8]=f):f=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(m=os({variant:"text",size:"xs"}),p=k.jsx(rs,{size:16}),t[9]=m,t[10]=p):(m=t[9],p=t[10]),t[11]!==f?(g=k.jsx(N,{content:"Upload file",children:k.jsx("button",{"data-testid":"file-explorer-upload-button",...f,className:m,children:p})}),t[11]=f,t[12]=g):g=t[12],t[13]!==l?(v=l({}),t[13]=l,t[14]=v):v=t[14],t[15]!==v?(y=k.jsx("input",{...v,type:"file"}),t[15]=v,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(x=k.jsx(oa,{size:16}),t[17]=x):x=t[17],t[18]!==n?(w=k.jsx(N,{content:"Refresh",children:k.jsx(C,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:x})}),t[18]=n,t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(oc,{size:16}),t[20]=S):S=t[20],t[21]!==a?(E=k.jsx(N,{content:"Collapse all folders",children:k.jsx(C,{"data-testid":"file-explorer-collapse-button",onClick:a,variant:"text",size:"xs",children:S})}),t[21]=a,t[22]=E):E=t[22],t[23]!==d||t[24]!==h||t[25]!==g||t[26]!==y||t[27]!==w||t[28]!==E?(j=k.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[d,h,g,y,w,E]}),t[23]=d,t[24]=h,t[25]=g,t[26]=y,t[27]=w,t[28]=E,t[29]=j):j=t[29],j},_M=e=>{const t=b(9),{node:n,onOpenMarimoFile:o}=e;let r,a,i;return t[0]!==n?(r=e=>{n.data.isDirectory||(e.stopPropagation(),n.select())},t[0]=n,t[1]=r):r=t[1],t[2]!==n.data.isMarimoFile||t[3]!==o?(a=n.data.isMarimoFile&&!D()&&k.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:o,children:["open ",k.jsx(Hi,{className:"inline ml-1",size:12})]}),t[2]=n.data.isMarimoFile,t[3]=o,t[4]=a):a=t[4],t[5]!==r||t[6]!==n.data.name||t[7]!==a?(i=k.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:r,children:[n.data.name,a]}),t[5]=r,t[6]=n.data.name,t[7]=a,t[8]=i):i=t[8],i},IM=e=>{const t=b(10),{node:n}=e,o=r.useRef(null);let a,i,s,l,c;return t[0]!==n.data.name?(a=()=>{var e,t;null==(e=o.current)||e.focus(),null==(t=o.current)||t.setSelectionRange(0,n.data.name.lastIndexOf("."))},i=[n.data.name],t[0]=n.data.name,t[1]=a,t[2]=i):(a=t[1],i=t[2]),r.useEffect(a,i),t[3]!==n?(s=()=>n.reset(),l=e=>{"Escape"===e.key&&n.reset(),"Enter"===e.key&&n.submit(e.currentTarget.value)},t[3]=n,t[4]=s,t[5]=l):(s=t[4],l=t[5]),t[6]!==n.data.name||t[7]!==s||t[8]!==l?(c=k.jsx("input",{ref:o,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:PM,onBlur:s,onKeyDown:l}),t[6]=n.data.name,t[7]=s,t[8]=l,t[9]=c):c=t[9],c},AM=e=>{const t=b(52),{node:n,style:o,dragHandle:a}=e;let i;t[0]!==n.data?(i=n.data.isDirectory?"directory":ln(n.data.name),t[0]=n.data,t[1]=i):i=t[1];const s=i,l=dn[s],{openConfirm:c,openPrompt:d}=w(),u=r.useContext(NM);let h;t[2]!==u||t[3]!==n.data.path?(h=async e=>{MM(e,u?u.relativeFromRoot(n.data.path):n.data.path)},t[2]=u,t[3]=n.data.path,t[4]=h):h=t[4];const f=h;let m;t[5]!==c||t[6]!==n.data.name||t[7]!==n.tree||t[8]!==n.id?(m=async e=>{e.stopPropagation(),e.preventDefault(),c({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:k.jsx(ot,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},t[5]=c,t[6]=n.data.name,t[7]=n.tree,t[8]=n.id,t[9]=m):m=t[9];const p=m;let g;t[10]!==n||t[11]!==d||t[12]!==u?(g=async()=>{n.open(),d({title:"Folder name",onConfirm:async e=>{null==u||u.createFolder(e,n.id)}})},t[10]=n,t[11]=d,t[12]=u,t[13]=g):g=t[13];const v=G(g);let y;t[14]!==n||t[15]!==d||t[16]!==u?(y=async()=>{n.open(),d({title:"File name",onConfirm:async e=>{null==u||u.createFile(e,n.id)}})},t[14]=n,t[15]=d,t[16]=u,t[17]=y):y=t[17];const x=G(y);let S;t[18]!==n||t[19]!==x||t[20]!==v||t[21]!==u||t[22]!==s||t[23]!==f||t[24]!==p?(S=()=>{const e={size:14,strokeWidth:1.5,className:"mr-2"};return k.jsxs(Ut,{align:"end",className:"no-print w-[220px]",onClick:e=>e.stopPropagation(),onCloseAutoFocus:e=>e.preventDefault(),children:[!n.data.isDirectory&&k.jsxs(Ot,{onSelect:()=>n.select(),children:[k.jsx(Jc,{...e}),"Open file"]}),n.data.isDirectory&&k.jsxs(k.Fragment,{children:[k.jsxs(Ot,{onSelect:()=>x(),children:[k.jsx(sc,{...e}),"Create file"]}),k.jsxs(Ot,{onSelect:()=>v(),children:[k.jsx(cc,{...e}),"Create folder"]}),k.jsx(Ft,{})]}),k.jsxs(Ot,{onSelect:()=>n.edit(),children:[k.jsx(Ic,{...e}),"Rename"]}),k.jsxs(Ot,{onSelect:async()=>{await et(n.data.path),re({title:"Copied to clipboard"})},children:[k.jsx(nt,{...e}),"Copy path"]}),u&&k.jsxs(Ot,{onSelect:async()=>{await et(u.relativeFromRoot(n.data.path)),re({title:"Copied to clipboard"})},children:[k.jsx(nt,{...e}),"Copy relative path"]}),k.jsxs(Ot,{onSelect:async()=>{re({title:"Copied to clipboard",description:"Code to open the file has been copied to your clipboard. You can also drag and drop this file into the editor"});const{path:e}=n.data,t=as[s](e);await et(t)},children:[k.jsx(is,{...e}),"Copy snippet for reading file"]}),n.data.isMarimoFile&&!D()&&k.jsxs(k.Fragment,{children:[k.jsx(Ft,{}),k.jsxs(Ot,{onSelect:f,children:[k.jsx($c,{...e}),"Open notebook"]})]}),k.jsx(Ft,{}),!n.data.isDirectory&&k.jsxs(k.Fragment,{children:[k.jsxs(Ot,{onSelect:async()=>{const e=(await Ui({path:n.data.path})).contents||"";E(new Blob([e]),n.data.name)},children:[k.jsx(Nt,{...e}),"Download"]}),k.jsx(Ft,{})]}),k.jsxs(Ot,{onSelect:p,variant:"danger",children:[k.jsx(je,{...e}),"Delete"]})]})},t[18]=n,t[19]=x,t[20]=v,t[21]=u,t[22]=s,t[23]=f,t[24]=p,t[25]=S):S=t[25];const N=S;let j,_,I;t[26]===Symbol.for("react.memo_cache_sentinel")?(j=rn("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),t[26]=j):j=t[26],t[27]!==n?(_=e=>{e.stopPropagation(),n.data.isDirectory&&n.toggle()},I=k.jsx(TM,{node:n}),t[27]=n,t[28]=_,t[29]=I):(_=t[28],I=t[29]);const A=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground";let T,M,O,P,R,L,z;return t[30]!==A?(T=rn("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",A),t[30]=A,t[31]=T):T=t[31],t[32]!==n.data.isMarimoFile||t[33]!==l?(M=n.data.isMarimoFile?k.jsx("img",{src:"/favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):k.jsx(l,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),t[32]=n.data.isMarimoFile,t[33]=l,t[34]=M):M=t[34],t[35]!==n||t[36]!==f?(O=n.isEditing?k.jsx(IM,{node:n}):k.jsx(_M,{node:n,onOpenMarimoFile:f}),t[35]=n,t[36]=f,t[37]=O):O=t[37],t[38]===Symbol.for("react.memo_cache_sentinel")?(P=k.jsx(Dt,{asChild:!0,tabIndex:-1,onClick:RM,children:k.jsx(C,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:k.jsx(rc,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),t[38]=P):P=t[38],t[39]!==N?(R=k.jsxs(Bt,{modal:!1,children:[P,N()]}),t[39]=N,t[40]=R):R=t[40],t[41]!==T||t[42]!==M||t[43]!==O||t[44]!==R?(L=k.jsxs("span",{className:T,children:[M,O,R]}),t[41]=T,t[42]=M,t[43]=O,t[44]=R,t[45]=L):L=t[45],t[46]!==o||t[47]!==a||t[48]!==_||t[49]!==I||t[50]!==L?(z=k.jsxs("div",{style:o,ref:a,className:j,draggable:!0,onClick:_,children:[I,L]}),t[46]=o,t[47]=a,t[48]=_,t[49]=I,t[50]=L,t[51]=z):z=t[51],z},TM=e=>{const t=b(3),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"w-5 h-5 flex-shrink-0"}),t[0]=e):e=t[0],e}let o;return t[1]!==n.isOpen?(o=n.isOpen?k.jsx(Ce,{className:"w-5 h-5 flex-shrink-0"}):k.jsx(ra,{className:"w-5 h-5 flex-shrink-0"}),t[1]=n.isOpen,t[2]=o):o=t[2],o};function MM(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}function OM(){return null}function DM(e){const{parentNode:t}=e;return!t.data.isDirectory}function PM(e){return e.stopPropagation()}function RM(e){return e.stopPropagation()}const LM=()=>{const e=b(20),{ref:t,height:n}=uM(),o=void 0===n?1:n;let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r={noClick:!0,noKeyboard:!0},e[0]=r):r=e[0];const{getRootProps:a,getInputProps:i,isDragActive:s}=yM(r);let l,c,d,u,h,f,m,p;return e[1]!==a?(l=a(),e[1]=a,e[2]=l):l=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(c=rn("flex flex-col flex-1 overflow-hidden relative"),e[3]=c):c=e[3],e[4]!==i?(d=i(),e[4]=i,e[5]=d):d=e[5],e[6]!==d?(u=k.jsx("input",{...d}),e[6]=d,e[7]=u):u=e[7],e[8]!==s?(h=s&&k.jsx("div",{className:"absolute inset-0 flex items-center uppercase justify-center text-xl font-bold text-primary/90 bg-accent/85 z-10 border-2 border-dashed border-primary/90 rounded-lg pointer-events-none",children:"Drop files here"}),e[8]=s,e[9]=h):h=e[9],e[10]!==o?(f=k.jsx(CM,{height:o}),e[10]=o,e[11]=f):f=e[11],e[12]!==t||e[13]!==f?(m=k.jsx("div",{ref:t,className:"flex flex-col flex-1 overflow-hidden",children:f}),e[12]=t,e[13]=f,e[14]=m):m=e[14],e[15]!==l||e[16]!==u||e[17]!==h||e[18]!==m?(p=k.jsxs("div",{...l,className:c,children:[u,h,m]}),e[15]=l,e[16]=u,e[17]=h,e[18]=m,e[19]=p):p=e[19],p},zM=e=>{const t=b(6),{children:n}=e,{openModal:o,closeModal:r}=w();let a,i;return t[0]!==o||t[1]!==r?(a=()=>o(k.jsx(BM,{onClose:r})),t[0]=o,t[1]=r,t[2]=a):a=t[2],t[3]!==a||t[4]!==n?(i=k.jsx(ii,{onClick:a,children:n}),t[3]=a,t[4]=n,t[5]=i):i=t[5],i},FM=[Yt.lineWrapping],BM=e=>{const t=b(23),{onClose:n}=e,[o,a]=r.useState(""),{theme:i}=Me();let s,l,c,d,u,h;t[0]!==n?(s=async e=>{e.preventDefault();const t=new FormData(e.target),o=t.get("title"),r=t.get("description"),a=t.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:o,description:r,code:a})}),n(),re({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},t[0]=n,t[1]=s):s=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(j,{children:"Contribute a Snippet"}),t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsxs(Ie,{children:[l,k.jsxs(_,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",k.jsx("a",{href:Ze.githubPage,target:"_blank",rel:"noreferrer",className:"underline",children:"on GitHub"}),"."]})]}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Qe,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),u=k.jsx(si,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),t[4]=d,t[5]=u):(d=t[4],u=t[5]),t[6]!==o?(h=k.jsx("input",{type:"hidden",name:"code",value:o}),t[6]=o,t[7]=h):h=t[7];const f="dark"===i?"dark":"light";let m,p,g,v,y,x;return t[8]!==f||t[9]!==o?(m=k.jsx(Yi,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:FM,value:o,onChange:a}),t[8]=f,t[9]=o,t[10]=m):m=t[10],t[11]!==h||t[12]!==m?(p=k.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[d,u,h,m]}),t[11]=h,t[12]=m,t[13]=p):p=t[13],t[14]!==n?(g=k.jsx(C,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),t[14]=n,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(v=k.jsx(C,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[16]=v):v=t[16],t[17]!==g?(y=k.jsxs(I,{children:[g,v]}),t[17]=g,t[18]=y):y=t[18],t[19]!==s||t[20]!==p||t[21]!==y?(x=k.jsx(A,{className:"w-fit",children:k.jsxs("form",{onSubmit:s,children:[c,p,y]})}),t[19]=s,t[20]=p,t[21]=y,t[22]=x):x=t[22],x},UM=[Yt.lineWrapping],VM=()=>{const e=b(20),[t,n]=u.useState();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:a,error:i,loading:s}=sn(WM,o);if(i){let t;return e[1]!==i?(t=k.jsx(Vi,{error:i}),e[1]=i,e[2]=t):t=e[2],t}if(s||!a){let t;return e[3]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(oi,{size:"medium",centered:!0}),e[3]=t):t=e[3],t}const l=t?"h-1/3":"h-full";let c,d,h,f,m,p,g,v,y;return e[4]!==l?(c=rn("border-b rounded-none",l),e[4]=l,e[5]=c):c=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(Ye,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),e[6]=d):d=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(h=k.jsxs("div",{className:"flex items-center w-full",children:[d,k.jsx(zM,{children:k.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:k.jsx(Bo,{className:"h-4 w-4"})})})]}),f=k.jsx(Ke,{children:"No results"}),e[7]=h,e[8]=f):(h=e[7],f=e[8]),e[9]===Symbol.for("react.memo_cache_sentinel")?(m=e=>n(e),e[9]=m):m=e[9],e[10]!==a.snippets?(p=k.jsx($M,{onSelect:m,snippets:a.snippets}),e[10]=a.snippets,e[11]=p):p=e[11],e[12]!==c||e[13]!==p?(g=k.jsxs(mn,{className:c,children:[h,f,p]}),e[12]=c,e[13]=p,e[14]=g):g=e[14],e[15]!==t?(v=k.jsx(r.Suspense,{children:k.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:t?k.jsx(HM,{snippet:t},t.title):k.jsx(FS,{title:"",description:"Click on a snippet to view its content."})})}),e[15]=t,e[16]=v):v=e[16],e[17]!==g||e[18]!==v?(y=k.jsxs("div",{className:"flex-1 overflow-hidden",children:[g,v]}),e[17]=g,e[18]=v,e[19]=y):y=e[19],y},HM=e=>{const t=b(27),{snippet:n}=e,{theme:o}=Me(),{createNewCell:r}=q(),a=Rd();let i;t[0]!==n.sections||t[1]!==r||t[2]!==a?(i=()=>{for(const e of[...n.sections].reverse())e.code&&r({code:e.code,before:!1,cellId:a??"__end__"})},t[0]=n.sections,t[1]=r,t[2]=a,t[3]=i):i=t[3];const s=i;let l;t[4]!==r||t[5]!==a?(l=e=>{r({code:e,before:!1,cellId:a??"__end__"})},t[4]=r,t[5]=a,t[6]=l):l=t[6];const c=l;let d,u,h,f,m,p;if(t[7]!==n.title?(d=k.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:n.title}),t[7]=n.title,t[8]=d):d=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(u=k.jsx(Wl,{className:"ml-2 h-4 w-4"}),t[9]=u):u=t[9],t[10]!==s?(h=k.jsx("div",{className:"flex justify-end",children:k.jsx(Du,{children:k.jsxs(C,{className:"float-right",size:"xs",variant:"outline",onClick:s,children:["Insert snippet",u]})})}),t[10]=s,t[11]=h):h=t[11],t[12]!==n.title||t[13]!==n.sections||t[14]!==c||t[15]!==o){let e;t[17]!==n.title||t[18]!==c||t[19]!==o?(e=e=>{const{code:t,html:r,id:a}=e;return r?k.jsx("div",{children:xa({html:r})},`${n.title}-${a}`):t?k.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[k.jsx(Du,{children:k.jsx(N,{content:"Insert snippet",children:k.jsx(C,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{c(t)},children:k.jsx(Wl,{className:"h-5 w-5"})})})}),k.jsx(Yi,{theme:"dark"===o?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:UM,value:t,readOnly:!0},`${n.title}-${a}`)]},`${n.title}-${a}`):null},t[17]=n.title,t[18]=c,t[19]=o,t[20]=e):e=t[20],f=n.sections.map(e),t[12]=n.title,t[13]=n.sections,t[14]=c,t[15]=o,t[16]=f}else f=t[16];return t[21]!==h||t[22]!==f?(m=k.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[h,f]}),t[21]=h,t[22]=f,t[23]=m):m=t[23],t[24]!==d||t[25]!==m?(p=k.jsxs(k.Fragment,{children:[d,m]}),t[24]=d,t[25]=m,t[26]=p):p=t[26],p},$M=e=>{const t=b(7),{snippets:n,onSelect:o}=e;let r,a;if(t[0]!==o||t[1]!==n){let e;t[3]!==o?(e=e=>k.jsx($e,{className:"rounded-none",onSelect:()=>o(e),children:k.jsx("div",{className:"flex flex-row gap-2 items-center",children:k.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title),t[3]=o,t[4]=e):e=t[4],r=n.map(e),t[0]=o,t[1]=n,t[2]=r}else r=t[2];return t[5]!==r?(a=k.jsx(yr,{className:"flex flex-col overflow-auto",children:r}),t[5]=r,t[6]=a):a=t[6],a};function WM(){return ss()}const GM=e=>{const t=b(11),{value:n,className:o,tooltip:a}=e,[i,s]=r.useState(!1);let l;t[0]!==n?(l=tt.stopPropagation((async()=>{await et(n).then((()=>{s(!0),setTimeout((()=>s(!1)),2e3)}))})),t[0]=n,t[1]=l):l=t[1];const c=l;let d,u;t[2]!==i||t[3]!==o?(d=i?k.jsx(It,{className:rn(o,"text-[var(--grass-11)]")}):k.jsx(nt,{className:o}),t[2]=i,t[3]=o,t[4]=d):d=t[4],t[5]!==c||t[6]!==d?(u=k.jsx("span",{onClick:c,children:d}),t[5]=c,t[6]=d,t[7]=u):u=t[7];const h=u;if(!1===a)return h;const f=i?"Copied!":a??"Copy to clipboard";let m;return t[8]!==f||t[9]!==h?(m=k.jsx(N,{content:f,delayDuration:400,children:h}),t[8]=f,t[9]=h,t[10]=m):m=t[10],m},qM=Z((e=>{const t=e(Or),n=e(ae),o=e(Ya);return Fl(t,(e=>{if(!e.variable_name)return-1;const t=Object.values(n).find((t=>t.name===e.variable_name));if(!t)return 0;const r=o.inOrderIds.indexOf(t.declaredBy[0]);return-1===r?0:r}))})),YM=()=>{const e=b(43),[t,n]=u.useState(""),o=le(ue),r=Rd(),{expandedColumns:a,expandedTables:i,columnsPreviews:s}=ls(),{toggleTable:l,toggleColumn:c,closeAllColumns:d}=cs(),{createNewCell:h}=q(),f=le(qM);if(0===f.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(FS,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",icon:k.jsx(ke,{})}),e[0]=t):t=e[0],t}let m;e[1]!==o||e[2]!==h||e[3]!==r?(m=e=>{e.includes("alt")&&function(e,t,n){_d("altair","alt",(o=>{const r=se.create();t({cellId:n??"__end__",before:!1,code:o,lastCodeRun:e?o:void 0,newCellId:r,autoFocus:!1}),e&&K({cellIds:[r],codes:[o]})}))}(o,h,r),h({code:e,before:!1,cellId:r??"__end__"})},e[1]=o,e[2]=h,e[3]=r,e[4]=m):m=e[4];const p=m;let g;e[5]!==o||e[6]!==h||e[7]!==r?(g=e=>{Id(o,h,r);let t="";e:switch(e.source_type){case"local":t=`mo.ui.table(${e.name})`;break e;case"duckdb":t=`_df = mo.sql(f"SELECT * FROM ${e.name} LIMIT 100")`;break e;default:T(e.source_type)}h({code:t,before:!1,cellId:r??"__end__"})},e[5]=o,e[6]=h,e[7]=r,e[8]=g):g=e[8];const v=g,y=!!t.trim();let x,w,S,N,C,E,j,_,I,A,M;return e[9]===Symbol.for("react.memo_cache_sentinel")?(x=rn("border-b bg-background rounded-none","h-full"),e[9]=x):x=e[9],e[10]!==d?(w=e=>{e.length>0&&d(),n(e)},e[10]=d,e[11]=w):w=e[11],e[12]!==t||e[13]!==w?(S=k.jsx(Ye,{placeholder:"Search tables...",className:"h-6 m-1",value:t,onValueChange:w,rootClassName:"flex-1 border-r"}),e[12]=t,e[13]=w,e[14]=S):S=e[14],e[15]!==y?(N=y&&k.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:()=>n(""),children:k.jsx(tn,{className:"h-4 w-4"})}),e[15]=y,e[16]=N):N=e[16],e[17]!==S||e[18]!==N?(C=k.jsxs("div",{className:"flex items-center w-full",children:[S,N]}),e[17]=S,e[18]=N,e[19]=C):C=e[19],e[20]!==c||e[21]!==s?(E=(e,t)=>{const n=`${e.name}:${t.name}`;c({table:e.name,column:t.name}),s.has(n)||us({source:e.source,tableName:e.name,columnName:t.name,sourceType:e.source_type})},e[20]=c,e[21]=s,e[22]=E):E=e[22],e[23]!==l?(j=e=>{l(e.name)},e[23]=l,e[24]=j):j=e[24],e[25]!==y||e[26]!==i?(_=e=>!!y||i.has(e.name),e[25]=y,e[26]=i,e[27]=_):_=e[27],e[28]!==a?(I=(e,t)=>{const n=`${e.name}:${t.name}`;return a.has(n)},e[28]=a,e[29]=I):I=e[29],e[30]!==p||e[31]!==v||e[32]!==E||e[33]!==j||e[34]!==s||e[35]!==f||e[36]!==y||e[37]!==_||e[38]!==I?(A=k.jsx(XM,{onAddColumnChart:p,onAddTable:v,onExpandColumn:E,onExpandTable:j,columnPreviews:s,tables:f,isSearching:y,isTableExpanded:_,isColumnExpanded:I}),e[30]=p,e[31]=v,e[32]=E,e[33]=j,e[34]=s,e[35]=f,e[36]=y,e[37]=_,e[38]=I,e[39]=A):A=e[39],e[40]!==C||e[41]!==A?(M=k.jsx("div",{className:"flex-1 overflow-hidden",children:k.jsxs(mn,{className:x,children:[C,A]})}),e[40]=C,e[41]=A,e[42]=M):M=e[42],M},XM=e=>{const t=b(25),{tables:n,isSearching:o,columnPreviews:r,onAddColumnChart:a,onAddTable:i,onExpandTable:s,onExpandColumn:l,isTableExpanded:c,isColumnExpanded:d}=e;let h,f,m,p;if(t[0]!==n||t[1]!==c||t[2]!==o||t[3]!==s||t[4]!==i||t[5]!==l||t[6]!==d||t[7]!==a||t[8]!==r){let e,p;e=Object.entries(Fe.groupBy(n,eO,tO)),e=Fl(e,nO),t[12]!==c||t[13]!==o||t[14]!==s||t[15]!==i||t[16]!==l||t[17]!==d||t[18]!==a||t[19]!==r?(p=e=>{const t=c(e),n=[k.jsx(KM,{table:e,forceMount:o,onExpand:()=>s(e),onAddTable:()=>i(e),isExpanded:t},e.name)];return t&&n.push(...e.columns.map((t=>k.jsxs(u.Fragment,{children:[k.jsx(JM,{table:e,column:t,onExpandColumn:l,isExpanded:d(e,t)},`${e.name}.${t.name}`),d(e,t)&&k.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:k.jsx(hs,{children:k.jsx(QM,{table:e,column:t,onAddColumnChart:a,preview:r.get(`${e.name}:${t.name}`)})})})]},`${e.name}.${t.name}`)))),n},t[12]=c,t[13]=o,t[14]=s,t[15]=i,t[16]=l,t[17]=d,t[18]=a,t[19]=r,t[20]=p):p=t[20];const g=p;h=yr,f="flex flex-col overflow-auto",m=(()=>0===e.length?null:1===e.length?e[0][1].flatMap(g):e.flatMap(((e,t)=>{const[n,o]=e;return[k.jsx("div",{className:rn("font-bold px-2 py-1 text-muted-foreground bg-[var(--slate-2)] border-t text-sm",t>0&&"border-t"),children:"memory"===n?"In-Memory":n},n),...o.flatMap(g)]})))(),t[0]=n,t[1]=c,t[2]=o,t[3]=s,t[4]=i,t[5]=l,t[6]=d,t[7]=a,t[8]=r,t[9]=h,t[10]=f,t[11]=m}else h=t[9],f=t[10],m=t[11];return t[21]!==h||t[22]!==f||t[23]!==m?(p=k.jsx(h,{className:f,children:m}),t[21]=h,t[22]=f,t[23]=m,t[24]=p):p=t[24],p},KM=e=>{const t=b(27),{table:n,onExpand:o,onAddTable:r,isExpanded:a}=e;let i;t[0]!==n.num_rows||t[1]!==n.num_columns?(i=()=>{const e=[];return null!=n.num_rows&&e.push(`${n.num_rows} rows`),null!=n.num_columns&&e.push(`${n.num_columns} columns`),0===e.length?null:k.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:k.jsx("span",{className:"text-xs text-muted-foreground",children:e.join(", ")})})},t[0]=n.num_rows,t[1]=n.num_columns,t[2]=i):i=t[2];const s=i,l=n.name,c=a&&"rotate-90";let d,u,h,f,m,p,g,v,y;return t[3]!==c?(d=rn("h-3 w-3 transition-transform",c),t[3]=c,t[4]=d):d=t[4],t[5]!==d?(u=k.jsx(ra,{className:d}),t[5]=d,t[6]=u):u=t[6],t[7]!==n.name?(h=k.jsx("span",{className:"text-sm",children:n.name}),t[7]=n.name,t[8]=h):h=t[8],t[9]!==u||t[10]!==h?(f=k.jsxs("div",{className:"flex gap-1 items-center flex-1",children:[u,h]}),t[9]=u,t[10]=h,t[11]=f):f=t[11],t[12]!==s?(m=s(),t[12]=s,t[13]=m):m=t[13],t[14]!==r||t[15]!==n?(p=tt.stopPropagation((()=>r(n))),t[14]=r,t[15]=n,t[16]=p):p=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(g=k.jsx(Wc,{className:"h-3 w-3"}),t[17]=g):g=t[17],t[18]!==p?(v=k.jsx(N,{content:"Add table to notebook",delayDuration:400,children:k.jsx(C,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:p,children:g})}),t[18]=p,t[19]=v):v=t[19],t[20]!==n.name||t[21]!==a||t[22]!==o||t[23]!==f||t[24]!==m||t[25]!==v?(y=k.jsxs($e,{className:"rounded-none py-1 group min-h-9 border-t",value:l,"aria-selected":a,forceMount:!0,onSelect:o,children:[f,m,v]}),t[20]=n.name,t[21]=a,t[22]=o,t[23]=f,t[24]=m,t[25]=v,t[26]=y):y=t[26],y},JM=e=>{const t=b(22),{table:n,column:o,onExpandColumn:r}=e,a=fs[o.type],i=`${n.name}.${o.name}`,s=`${n.name}.${o.name}`;let l,c,d,u,h,f,m;return t[0]!==r||t[1]!==n||t[2]!==o?(l=()=>r(n,o),t[0]=r,t[1]=n,t[2]=o,t[3]=l):l=t[3],t[4]!==a?(c=k.jsx(a,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),t[4]=a,t[5]=c):c=t[5],t[6]!==o.name?(d=k.jsx("span",{children:o.name}),t[6]=o.name,t[7]=d):d=t[7],t[8]!==c||t[9]!==d?(u=k.jsxs("div",{className:"flex flex-row gap-2 items-center pl-6 flex-1",children:[c,d]}),t[8]=c,t[9]=d,t[10]=u):u=t[10],t[11]!==o.name?(h=k.jsx(N,{content:"Copy column name",delayDuration:400,children:k.jsx(C,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:k.jsx(GM,{tooltip:!1,value:o.name,className:"h-3 w-3"})})}),t[11]=o.name,t[12]=h):h=t[12],t[13]!==o.external_type?(f=k.jsx("span",{className:"text-xs text-muted-foreground",children:o.external_type}),t[13]=o.external_type,t[14]=f):f=t[14],t[15]!==i||t[16]!==s||t[17]!==l||t[18]!==u||t[19]!==h||t[20]!==f?(m=k.jsxs($e,{className:"rounded-none py-1 group",value:s,onSelect:l,children:[u,h,f]},i),t[15]=i,t[16]=s,t[17]=l,t[18]=u,t[19]=h,t[20]=f,t[21]=m):m=t[21],m},ZM=u.lazy((()=>ds((()=>import("./index-CtO-4MLb.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14]),import.meta.url).then((e=>({default:e.VegaLite}))))),QM=e=>{const t=b(26),{table:n,column:o,preview:r,onAddColumnChart:a}=e,{theme:i}=Me();if(!r){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."}),t[0]=e):e=t[0],e}let s;t[1]!==r.error?(s=r.error&&k.jsx("span",{className:"text-xs text-muted-foreground",children:r.error}),t[1]=r.error,t[2]=s):s=t[2];const l=s;let c;t[3]!==r.summary?(c=r.summary&&k.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(r.summary).map(oO)}),t[3]=r.summary,t[4]=c):c=t[4];const d=c,u=rO;let h;t[5]!==r.chart_spec||t[6]!==i?(h=r.chart_spec&&k.jsx(ZM,{spec:u(JSON.parse(r.chart_spec)),width:"container",height:100,actions:!1,theme:"dark"===i?"dark":"vox"}),t[5]=r.chart_spec,t[6]=i,t[7]=h):h=t[7];const f=h;let m;t[8]!==r.chart_code||t[9]!==n||t[10]!==a?(m=r.chart_code&&"local"===n.source_type&&k.jsx(N,{content:"Add chart to notebook",delayDuration:400,children:k.jsx(C,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:tt.stopPropagation((()=>a(r.chart_code||""))),children:k.jsx(Wc,{className:"h-3 w-3"})})}),t[8]=r.chart_code,t[9]=n,t[10]=a,t[11]=m):m=t[11];const p=m;let g;t[12]!==n||t[13]!==o||t[14]!==a?(g="duckdb"===n.source_type&&k.jsx(N,{content:"Add SQL cell",delayDuration:400,children:k.jsx(C,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:tt.stopPropagation((()=>{const e=`_df = mo.sql(f'SELECT "${o.name}" FROM ${n.name} LIMIT 100')`;a(e)})),children:k.jsx(Wc,{className:"h-3 w-3"})})}),t[12]=n,t[13]=o,t[14]=a,t[15]=g):g=t[15];const v=g;let y;t[16]!==r.chart_max_rows_errors?(y=r.chart_max_rows_errors&&k.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."}),t[16]=r.chart_max_rows_errors,t[17]=y):y=t[17];const x=y;if(!(l||d||f||x)){let e;return t[18]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"}),t[18]=e):e=t[18],e}let w;return t[19]!==l||t[20]!==p||t[21]!==v||t[22]!==x||t[23]!==f||t[24]!==d?(w=k.jsxs("div",{className:"flex flex-col gap-2 relative",children:[l,p,v,x,f,d]}),t[19]=l,t[20]=p,t[21]=v,t[22]=x,t[23]=f,t[24]=d,t[25]=w):w=t[25],w};function eO(e){return e.source}function tO(e){return e}function nO(e){const[t]=e;return"memory"===t?0:1}function oO(e){const[t,n]=e;return null==n?null:k.jsxs("div",{className:"flex items-center gap-1 group",children:[k.jsx(GM,{className:"h-3 w-3 invisible group-hover:visible",value:String(n)}),k.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:t}),k.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:ms(n)})]},t)}function rO(e){return{...e,config:{...e.config,background:"transparent"}}}const aO=e=>{const t=b(4),{isOpen:n,children:o}=e,[r,a]=u.useState(!1);let i,s;return t[0]!==n||t[1]!==r?(i=()=>{n&&!r&&a(!0)},s=[n,r],t[0]=n,t[1]=r,t[2]=i,t[3]=s):(i=t[2],s=t[3]),u.useEffect(i,s),r?o:null},iO=Lr("marimo:scratchpadHistory:v1",[]),sO=Z(!1),lO=Z(null,((e,t,n)=>{if(!(n=n.trim()))return;const o=e(iO),r=[n,...o.filter((e=>e!==n))].slice(0,15);t(iO,r)})),cO={hide_code:!1,disabled:!1},dO=()=>{const e=b(79),t=W(),[n]=Oe(),{theme:o}=Me(),a=r.useRef(null),i=Rd(),{createNewCell:s,updateCellCode:l}=q(),c=t.cellRuntime[Te],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=t.cellData[Te],m=(null==f?void 0:f.code)??"",p=ce(lO),[g,v]=Le(sO),y=le(iO);let x;e[0]!==m||e[1]!==p?(x=()=>{ps({code:m}),p(m)},e[0]=m,e[1]=p,e[2]=x):x=e[2];const w=G(x);let E;e[3]!==m||e[4]!==s||e[5]!==i?(E=()=>{m.trim()&&s({code:m,before:!1,cellId:i??"__end__"})},e[3]=m,e[4]=s,e[5]=i,e[6]=E):E=e[6];const j=G(E);let _;e[7]!==l?(_=()=>{l({cellId:Te,code:"",formattingChange:!1}),ps({code:""});const e=a.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})},e[7]=l,e[8]=_):_=e[8];const I=G(_);let A;e[9]!==v||e[10]!==l?(A=e=>{v(!1),l({cellId:Te,code:e,formattingChange:!1});const t=a.current;t&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},e[9]=v,e[10]=l,e[11]=A):A=e[11];const T=G(A);let M,O,D,P,R,L,z,F;if(e[12]!==o||e[13]!==m||e[14]!==w||e[15]!==l||e[16]!==n||e[17]!==d||e[18]!==h||e[19]!==g||e[20]!==y||e[21]!==T||e[22]!==I||e[23]!==j||e[24]!==u||e[25]!==v){const t=()=>k.jsxs(k.Fragment,{children:[k.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:k.jsx(Yb,{theme:o,allowFocus:!1,showPlaceholder:!1,id:Te,code:m,config:cO,status:"idle",serializedEditorState:null,runCell:w,updateCellCode:l,createNewCell:an.NOOP,deleteCell:an.NOOP,focusCell:an.NOOP,moveCell:an.NOOP,moveToNextCell:void 0,updateCellConfig:an.NOOP,clearSerializedEditorState:an.NOOP,userConfig:n,editorViewRef:a,hidden:!1})}),k.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:k.jsx(fa,{allowExpand:!1,output:d,className:"output-area",cellId:Te,stale:!1})}),k.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:k.jsx(fl,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:Ri,onSubmitDebugger:an.NOOP,cellId:Te,debuggerActive:!1})})]});let r;e[32]!==g||e[33]!==y||e[34]!==T||e[35]!==o?(r=()=>g?k.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:k.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:y.map(((e,t)=>k.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>T(e),children:k.jsx(Yi,{language:"python",theme:o,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:e.trim(),editable:!1,readOnly:!0})},t)))})}):null,e[32]=g,e[33]=y,e[34]=T,e[35]=o,e[36]=r):r=e[36];const i=r;let s,c,f,p,x,b,E,_,A;D="flex flex-col h-full overflow-hidden divide-y",e[37]===Symbol.for("react.memo_cache_sentinel")?(P=ft.create(Te),e[37]=P):P=e[37],e[38]===Symbol.for("react.memo_cache_sentinel")?(s=S("cell.run"),e[38]=s):s=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(c=k.jsx(Ac,{color:"var(--grass-11)",size:16}),e[39]=c):c=e[39],e[40]!==w||e[41]!==g?(f=k.jsx(N,{content:s,children:k.jsx(C,{"data-testid":"scratchpad-run-button",onClick:w,disabled:g,variant:"text",size:"xs",children:c})}),e[40]=w,e[41]=g,e[42]=f):f=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(p=k.jsx(ac,{size:16}),e[43]=p):p=e[43],e[44]!==g||e[45]!==I?(x=k.jsx(N,{content:"Clear code and outputs",children:k.jsx(C,{disabled:g,size:"xs",variant:"text",onClick:I,children:p})}),e[44]=g,e[45]=I,e[46]=x):x=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(b=k.jsx(Wl,{size:16}),e[47]=b):b=e[47],e[48]!==g||e[49]!==j?(E=k.jsx(Du,{children:k.jsx(N,{content:"Insert code",children:k.jsx(C,{disabled:g,size:"xs",variant:"text",onClick:j,children:b})})}),e[48]=g,e[49]=j,e[50]=E):E=e[50],e[51]!==u?(_=("running"===u||"queued"===u)&&k.jsx(oi,{className:"inline",size:"small"}),e[51]=u,e[52]=_):_=e[52],e[53]===Symbol.for("react.memo_cache_sentinel")?(A=k.jsx("div",{className:"flex-1"}),e[53]=A):A=e[53];const z=g&&"bg-[var(--sky-3)] rounded-none";let F,B;e[54]!==z?(F=rn(z),e[54]=z,e[55]=F):F=e[55],e[56]!==v||e[57]!==g?(B=()=>v(!g),e[56]=v,e[57]=g,e[58]=B):B=e[58];const U=0===y.length;let V,H;e[59]===Symbol.for("react.memo_cache_sentinel")?(V=k.jsx(fc,{size:16}),e[59]=V):V=e[59],e[60]!==F||e[61]!==B||e[62]!==U?(H=k.jsx(N,{content:"Toggle history",children:k.jsx(C,{size:"xs",variant:"text",className:F,onClick:B,disabled:U,children:V})}),e[60]=F,e[61]=B,e[62]=U,e[63]=H):H=e[63],e[64]!==f||e[65]!==x||e[66]!==E||e[67]!==_||e[68]!==H?(R=k.jsxs("div",{className:"flex items-center flex-shrink-0",children:[f,x,E,_,A,H]}),e[64]=f,e[65]=x,e[66]=E,e[67]=_,e[68]=H,e[69]=R):R=e[69],M="flex-1 divide-y relative",O=t(),L=i(),e[12]=o,e[13]=m,e[14]=w,e[15]=l,e[16]=n,e[17]=d,e[18]=h,e[19]=g,e[20]=y,e[21]=T,e[22]=I,e[23]=j,e[24]=u,e[25]=v,e[26]=M,e[27]=O,e[28]=D,e[29]=P,e[30]=R,e[31]=L}else M=e[26],O=e[27],D=e[28],P=e[29],R=e[30],L=e[31];return e[70]!==M||e[71]!==O||e[72]!==L?(z=k.jsxs("div",{className:M,children:[O,L]}),e[70]=M,e[71]=O,e[72]=L,e[73]=z):z=e[73],e[74]!==D||e[75]!==P||e[76]!==R||e[77]!==z?(F=k.jsxs("div",{className:D,id:P,children:[R,z]}),e[74]=D,e[75]=P,e[76]=R,e[77]=z,e[78]=F):F=e[78],F},uO=()=>{const e=b(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(dO,{}),e[0]=t):t=e[0],t},hO=()=>{const e=b(16),[t]=Oe(),n=t.package_management.manager;let o;e[0]!==n?(o=[n],e[0]=n,e[1]=o):o=e[1];const{data:r,loading:a,error:i,reload:s}=sn(gO,o);if(a&&!r){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=k.jsx(oi,{size:"medium",centered:!0}),e[2]=t):t=e[2],t}if(i){let t;return e[3]!==i?(t=k.jsx(Vi,{error:i}),e[3]=i,e[4]=t):t=e[4],t}let l;e[5]!==(null==r?void 0:r.packages)?(l=(null==r?void 0:r.packages)||[],e[5]=null==r?void 0:r.packages,e[6]=l):l=e[6];const c=l;let d,u,h;return e[7]!==n||e[8]!==s?(d=k.jsx(fO,{packageManager:n,onSuccess:s}),e[7]=n,e[8]=s,e[9]=d):d=e[9],e[10]!==c||e[11]!==s?(u=k.jsx(mO,{packages:c,onSuccess:s}),e[10]=c,e[11]=s,e[12]=u):u=e[12],e[13]!==d||e[14]!==u?(h=k.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[d,u]}),e[13]=d,e[14]=u,e[15]=h):h=e[15],h},fO=({onSuccess:e,packageManager:t})=>{const[n,o]=u.useState(""),[r,a]=u.useState(!1),i=async()=>{try{a(!0);const t=await ys({package:n});t.success?(e(),re({title:"Package added",description:k.jsxs("span",{children:["The package ",k.jsx(Ra,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):re({title:"Failed to add package",description:t.error,variant:"danger"})}finally{o(""),a(!1)}};return k.jsxs("div",{className:"flex items-center w-full border-b",children:[k.jsx(_i,{placeholder:`Install packages with ${t}...`,icon:r?k.jsx(oi,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):k.jsx(ql,{className:"mr-2 h-4 w-4 shrink-0 opacity-50"}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),i())},onChange:e=>o(e.target.value)}),k.jsx(N,{delayDuration:300,side:"left",align:"start",content:k.jsxs("div",{className:"text-sm flex flex-col w-full max-w-[360px]",children:["Packages are installed using the package manager specified in your user configuration. Depending on your package manager, you can install packages with various formats:",k.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",k.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",k.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",k.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",k.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),k.jsxs("div",{children:[k.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",k.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:k.jsx(gs,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),k.jsx("button",{type:"button",className:rn("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",n&&"bg-accent text-accent-foreground","disabled:cursor-not-allowed disabled:opacity-50"),onClick:i,disabled:!n,children:"Add"})]})},mO=e=>{const t=b(9),{onSuccess:n,packages:o}=e;if(0===o.length){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=k.jsx(FS,{title:"No packages",description:"No packages are installed in this environment.",icon:k.jsx(ql,{})}),t[0]=e):e=t[0],e}let r,a,i;if(t[1]===Symbol.for("react.memo_cache_sentinel")?(r=k.jsx(Ai,{children:k.jsxs(Ti,{children:[k.jsx(Mi,{children:"Name"}),k.jsx(Mi,{children:"Version"}),k.jsx(Mi,{})]})}),t[1]=r):r=t[1],t[2]!==n||t[3]!==o){let e;t[5]!==n?(e=e=>k.jsxs(Ti,{className:"group",onClick:async()=>{await et(`${e.name}==${e.version}`),re({title:"Copied to clipboard"})},children:[k.jsx(Pi,{children:e.name}),k.jsx(Pi,{children:e.version}),k.jsx(Pi,{children:k.jsx(pO,{packageName:e.name,onSuccess:n})})]},e.name),t[5]=n,t[6]=e):e=t[6],a=o.map(e),t[2]=n,t[3]=o,t[4]=a}else a=t[4];return t[7]!==a?(i=k.jsxs(Ii,{className:"overflow-auto flex-1",children:[r,k.jsx(Di,{children:a})]}),t[7]=a,t[8]=i):i=t[8],i},pO=({packageName:e,onSuccess:t})=>{const[n,o]=u.useState(!1);return n?k.jsx(oi,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):k.jsx("button",{type:"button",className:rn("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:tt.stopPropagation((async()=>{try{o(!0);const n=await xs({package:e});n.success?(t(),re({title:"Package removed",description:k.jsxs("span",{children:["The package ",k.jsx(Ra,{className:"inline",children:e})," has been removed from your environment."]})})):re({title:"Failed to add package",description:n.error,variant:"danger"})}finally{o(!1)}})),children:"Remove"})};function gO(){return vs()}function vO(...e){return t=>e.forEach((e=>function(e,t){"function"==typeof e?e(t):null!=e&&(e.current=t)}(e,t)))}function yO(...e){return r.useCallback(vO(...e),e)}var xO=r.forwardRef(((e,t)=>{const{children:n,...o}=e,a=r.Children.toArray(n),i=a.find(kO);if(i){const e=i.props.children,n=a.map((t=>t===i?r.Children.count(e)>1?r.Children.only(null):r.isValidElement(e)?e.props.children:null:t));return k.jsx(bO,{...o,ref:t,children:r.isValidElement(e)?r.cloneElement(e,void 0,n):null})}return k.jsx(bO,{...o,ref:t,children:n})}));xO.displayName="Slot";var bO=r.forwardRef(((e,t)=>{const{children:n,...o}=e;if(r.isValidElement(n)){const e=function(e){var t,n;let o=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=o&&"isReactWarning"in o&&o.isReactWarning;if(r)return e.ref;if(o=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,r=o&&"isReactWarning"in o&&o.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(n);return r.cloneElement(n,{...SO(o,n.props),ref:t?vO(t,e):e})}return r.Children.count(n)>1?r.Children.only(null):null}));bO.displayName="SlotClone";var wO=({children:e})=>k.jsx(k.Fragment,{children:e});function kO(e){return r.isValidElement(e)&&e.type===wO}function SO(e,t){const n={...t};for(const o in t){const r=e[o],a=t[o];/^on[A-Z]/.test(o)?r&&a?n[o]=(...e)=>{a(...e),r(...e)}:r&&(n[o]=r):"style"===o?n[o]={...r,...a}:"className"===o&&(n[o]=[r,a].filter(Boolean).join(" "))}return{...e,...n}}var NO=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"].reduce(((e,t)=>{const n=r.forwardRef(((e,n)=>{const{asChild:o,...r}=e,a=o?xO:t;return"undefined"!=typeof window&&(window[Symbol.for("radix-ui")]=!0),k.jsx(a,{...r,ref:n})}));return n.displayName=`Primitive.${t}`,{...e,[t]:n}}),{}),CO=Boolean(null==globalThis?void 0:globalThis.document)?r.useLayoutEffect:()=>{};var EO=e=>{const{present:t,children:n}=e,o=function(e){const[t,n]=r.useState(),o=r.useRef({}),a=r.useRef(e),i=r.useRef("none"),s=e?"mounted":"unmounted",[l,c]=function(e,t){return r.useReducer(((e,n)=>t[e][n]??e),e)}(s,{mounted:{UNMOUNT:"unmounted",ANIMATION_OUT:"unmountSuspended"},unmountSuspended:{MOUNT:"mounted",ANIMATION_END:"unmounted"},unmounted:{MOUNT:"mounted"}});return r.useEffect((()=>{const e=jO(o.current);i.current="mounted"===l?e:"none"}),[l]),CO((()=>{const t=o.current,n=a.current;if(n!==e){const o=i.current,r=jO(t);if(e)c("MOUNT");else if("none"===r||"none"===(null==t?void 0:t.display))c("UNMOUNT");else{c(n&&o!==r?"ANIMATION_OUT":"UNMOUNT")}a.current=e}}),[e,c]),CO((()=>{if(t){let e;const n=t.ownerDocument.defaultView??window,r=r=>{const i=jO(o.current).includes(r.animationName);if(r.target===t&&i&&(c("ANIMATION_END"),!a.current)){const o=t.style.animationFillMode;t.style.animationFillMode="forwards",e=n.setTimeout((()=>{"forwards"===t.style.animationFillMode&&(t.style.animationFillMode=o)}))}},s=e=>{e.target===t&&(i.current=jO(o.current))};return t.addEventListener("animationstart",s),t.addEventListener("animationcancel",r),t.addEventListener("animationend",r),()=>{n.clearTimeout(e),t.removeEventListener("animationstart",s),t.removeEventListener("animationcancel",r),t.removeEventListener("animationend",r)}}c("ANIMATION_END")}),[t,c]),{isPresent:["mounted","unmountSuspended"].includes(l),ref:r.useCallback((e=>{e&&(o.current=getComputedStyle(e)),n(e)}),[])}}(t),a="function"==typeof n?n({present:o.isPresent}):r.Children.only(n),i=yO(o.ref,function(e){var t,n;let o=null==(t=Object.getOwnPropertyDescriptor(e.props,"ref"))?void 0:t.get,r=o&&"isReactWarning"in o&&o.isReactWarning;if(r)return e.ref;if(o=null==(n=Object.getOwnPropertyDescriptor(e,"ref"))?void 0:n.get,r=o&&"isReactWarning"in o&&o.isReactWarning,r)return e.props.ref;return e.props.ref||e.ref}(a));return"function"==typeof n||o.isPresent?r.cloneElement(a,{ref:i}):null};function jO(e){return(null==e?void 0:e.animationName)||"none"}function _O(...e){const t=e[0];if(1===e.length)return t;const n=()=>{const n=e.map((e=>({useScope:e(),scopeName:e.scopeName})));return function(e){const o=n.reduce(((t,{useScope:n,scopeName:o})=>({...t,...n(e)[`__scope${o}`]})),{});return r.useMemo((()=>({[`__scope${t.scopeName}`]:o})),[o])}};return n.scopeName=t.scopeName,n}function IO(e){const t=r.useRef(e);return r.useEffect((()=>{t.current=e})),r.useMemo((()=>(...e)=>{var n;return null==(n=t.current)?void 0:n.call(t,...e)}),[])}EO.displayName="Presence";var AO=r.createContext(void 0);function TO(e,t,{checkForDefaultPrevented:n=!0}={}){return function(o){if(null==e||e(o),!1===n||!o.defaultPrevented)return null==t?void 0:t(o)}}var MO="ScrollArea",[OO,DO]=function(e,t=[]){let n=[];const o=()=>{const t=n.map((e=>r.createContext(e)));return function(n){const o=(null==n?void 0:n[e])||t;return r.useMemo((()=>({[`__scope${e}`]:{...n,[e]:o}})),[n,o])}};return o.scopeName=e,[function(t,o){const a=r.createContext(o),i=n.length;n=[...n,o];const s=t=>{var n;const{scope:o,children:s,...l}=t,c=(null==(n=null==o?void 0:o[e])?void 0:n[i])||a,d=r.useMemo((()=>l),Object.values(l));return k.jsx(c.Provider,{value:d,children:s})};return s.displayName=t+"Provider",[s,function(n,s){var l;const c=(null==(l=null==s?void 0:s[e])?void 0:l[i])||a,d=r.useContext(c);if(d)return d;if(void 0!==o)return o;throw new Error(`\`${n}\` must be used within \`${t}\``)}]},_O(o,...t)]}(MO),[PO,RO]=OO(MO),LO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,type:o="hover",dir:a,scrollHideDelay:i=600,...s}=e,[l,c]=r.useState(null),[d,u]=r.useState(null),[h,f]=r.useState(null),[m,p]=r.useState(null),[g,v]=r.useState(null),[y,x]=r.useState(0),[b,w]=r.useState(0),[S,N]=r.useState(!1),[C,E]=r.useState(!1),j=yO(t,(e=>c(e))),_=function(e){const t=r.useContext(AO);return e||t||"ltr"}(a);return k.jsx(PO,{scope:n,type:o,dir:_,scrollHideDelay:i,scrollArea:l,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:p,scrollbarXEnabled:S,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:v,scrollbarYEnabled:C,onScrollbarYEnabledChange:E,onCornerWidthChange:x,onCornerHeightChange:w,children:k.jsx(NO.div,{dir:_,...s,ref:j,style:{position:"relative","--radix-scroll-area-corner-width":y+"px","--radix-scroll-area-corner-height":b+"px",...e.style}})})}));LO.displayName=MO;var zO="ScrollAreaViewport",FO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,children:o,nonce:a,...i}=e,s=RO(zO,n),l=yO(t,r.useRef(null),s.onViewportChange);return k.jsxs(k.Fragment,{children:[k.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:a}),k.jsx(NO.div,{"data-radix-scroll-area-viewport":"",...i,ref:l,style:{overflowX:s.scrollbarXEnabled?"scroll":"hidden",overflowY:s.scrollbarYEnabled?"scroll":"hidden",...e.style},children:k.jsx("div",{ref:s.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})}));FO.displayName=zO;var BO="ScrollAreaScrollbar",UO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),{onScrollbarXEnabledChange:i,onScrollbarYEnabledChange:s}=a,l="horizontal"===e.orientation;return r.useEffect((()=>(l?i(!0):s(!0),()=>{l?i(!1):s(!1)})),[l,i,s]),"hover"===a.type?k.jsx(VO,{...o,ref:t,forceMount:n}):"scroll"===a.type?k.jsx(HO,{...o,ref:t,forceMount:n}):"auto"===a.type?k.jsx($O,{...o,ref:t,forceMount:n}):"always"===a.type?k.jsx(WO,{...o,ref:t}):null}));UO.displayName=BO;var VO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),[i,s]=r.useState(!1);return r.useEffect((()=>{const e=a.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),s(!0)},o=()=>{t=window.setTimeout((()=>s(!1)),a.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",o),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",o)}}}),[a.scrollArea,a.scrollHideDelay]),k.jsx(EO,{present:n||i,children:k.jsx($O,{"data-state":i?"visible":"hidden",...o,ref:t})})})),HO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,a=RO(BO,e.__scopeScrollArea),i="horizontal"===e.orientation,s=dD((()=>c("SCROLL_END")),100),[l,c]=(d="hidden",u={hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}},r.useReducer(((e,t)=>u[e][t]??e),d));var d,u;return r.useEffect((()=>{if("idle"===l){const e=window.setTimeout((()=>c("HIDE")),a.scrollHideDelay);return()=>window.clearTimeout(e)}}),[l,a.scrollHideDelay,c]),r.useEffect((()=>{const e=a.viewport,t=i?"scrollLeft":"scrollTop";if(e){let n=e[t];const o=()=>{const o=e[t];n!==o&&(c("SCROLL"),s()),n=o};return e.addEventListener("scroll",o),()=>e.removeEventListener("scroll",o)}}),[a.viewport,i,c,s]),k.jsx(EO,{present:n||"hidden"!==l,children:k.jsx(WO,{"data-state":"hidden"===l?"hidden":"visible",...o,ref:t,onPointerEnter:TO(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:TO(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),$O=r.forwardRef(((e,t)=>{const n=RO(BO,e.__scopeScrollArea),{forceMount:o,...a}=e,[i,s]=r.useState(!1),l="horizontal"===e.orientation,c=dD((()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;s(l?e:t)}}),10);return uD(n.viewport,c),uD(n.content,c),k.jsx(EO,{present:o||i,children:k.jsx(WO,{"data-state":i?"visible":"hidden",...a,ref:t})})})),WO=r.forwardRef(((e,t)=>{const{orientation:n="vertical",...o}=e,a=RO(BO,e.__scopeScrollArea),i=r.useRef(null),s=r.useRef(0),[l,c]=r.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=rD(l.viewport,l.content),u={...o,sizes:l,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>i.current=e,onThumbPointerUp:()=>s.current=0,onThumbPointerDown:e=>s.current=e};function h(e,t){return function(e,t,n,o="ltr"){const r=aD(n),a=r/2,i=t||a,s=r-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-s,d=n.content-n.viewport,u="ltr"===o?[0,d]:[-1*d,0];return sD([l,c],u)(e)}(e,s.current,l,t)}return"horizontal"===n?k.jsx(GO,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const e=iD(a.viewport.scrollLeft,l,a.dir);i.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollLeft=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollLeft=h(e,a.dir))}}):"vertical"===n?k.jsx(qO,{...u,ref:t,onThumbPositionChange:()=>{if(a.viewport&&i.current){const e=iD(a.viewport.scrollTop,l);i.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{a.viewport&&(a.viewport.scrollTop=e)},onDragScroll:e=>{a.viewport&&(a.viewport.scrollTop=h(e))}}):null})),GO=r.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:o,...a}=e,i=RO(BO,e.__scopeScrollArea),[s,l]=r.useState(),c=r.useRef(null),d=yO(t,c,i.onScrollbarXChange);return r.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),k.jsx(KO,{"data-orientation":"horizontal",...a,ref:d,sizes:n,style:{bottom:0,left:"rtl"===i.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===i.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":aD(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(i.viewport){const o=i.viewport.scrollLeft+t.deltaX;e.onWheelScroll(o),lD(o,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&o({content:i.viewport.scrollWidth,viewport:i.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:oD(s.paddingLeft),paddingEnd:oD(s.paddingRight)}})}})})),qO=r.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:o,...a}=e,i=RO(BO,e.__scopeScrollArea),[s,l]=r.useState(),c=r.useRef(null),d=yO(t,c,i.onScrollbarYChange);return r.useEffect((()=>{c.current&&l(getComputedStyle(c.current))}),[c]),k.jsx(KO,{"data-orientation":"vertical",...a,ref:d,sizes:n,style:{top:0,right:"ltr"===i.dir?0:void 0,left:"rtl"===i.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":aD(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(i.viewport){const o=i.viewport.scrollTop+t.deltaY;e.onWheelScroll(o),lD(o,n)&&t.preventDefault()}},onResize:()=>{c.current&&i.viewport&&s&&o({content:i.viewport.scrollHeight,viewport:i.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:oD(s.paddingTop),paddingEnd:oD(s.paddingBottom)}})}})})),[YO,XO]=OO(BO),KO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:a,onThumbChange:i,onThumbPointerUp:s,onThumbPointerDown:l,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,m=RO(BO,n),[p,g]=r.useState(null),v=yO(t,(e=>g(e))),y=r.useRef(null),x=r.useRef(""),b=m.viewport,w=o.content-o.viewport,S=IO(u),N=IO(c),C=dD(h,10);function E(e){if(y.current){const t=e.clientX-y.current.left,n=e.clientY-y.current.top;d({x:t,y:n})}}return r.useEffect((()=>{const e=e=>{const t=e.target;(null==p?void 0:p.contains(t))&&S(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[b,p,w,S]),r.useEffect(N,[o,N]),uD(p,C),uD(m.content,C),k.jsx(YO,{scope:n,scrollbar:p,hasThumb:a,onThumbChange:IO(i),onThumbPointerUp:IO(s),onThumbPositionChange:N,onThumbPointerDown:IO(l),children:k.jsx(NO.div,{...f,ref:v,style:{position:"absolute",...f.style},onPointerDown:TO(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),y.current=p.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),E(e)}})),onPointerMove:TO(e.onPointerMove,E),onPointerUp:TO(e.onPointerUp,(e=>{const t=e.target;t.hasPointerCapture(e.pointerId)&&t.releasePointerCapture(e.pointerId),document.body.style.webkitUserSelect=x.current,m.viewport&&(m.viewport.style.scrollBehavior=""),y.current=null}))})})})),JO="ScrollAreaThumb",ZO=r.forwardRef(((e,t)=>{const{forceMount:n,...o}=e,r=XO(JO,e.__scopeScrollArea);return k.jsx(EO,{present:n||r.hasThumb,children:k.jsx(QO,{ref:t,...o})})})),QO=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,style:o,...a}=e,i=RO(JO,n),s=XO(JO,n),{onThumbPositionChange:l}=s,c=yO(t,(e=>s.onThumbChange(e))),d=r.useRef(),u=dD((()=>{d.current&&(d.current(),d.current=void 0)}),100);return r.useEffect((()=>{const e=i.viewport;if(e){const t=()=>{if(u(),!d.current){const t=cD(e,l);d.current=t,l()}};return l(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[i.viewport,u,l]),k.jsx(NO.div,{"data-state":s.hasThumb?"visible":"hidden",...a,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:TO(e.onPointerDownCapture,(e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,o=e.clientY-t.top;s.onThumbPointerDown({x:n,y:o})})),onPointerUp:TO(e.onPointerUp,s.onThumbPointerUp)})}));ZO.displayName=JO;var eD="ScrollAreaCorner",tD=r.forwardRef(((e,t)=>{const n=RO(eD,e.__scopeScrollArea),o=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&o?k.jsx(nD,{...e,ref:t}):null}));tD.displayName=eD;var nD=r.forwardRef(((e,t)=>{const{__scopeScrollArea:n,...o}=e,a=RO(eD,n),[i,s]=r.useState(0),[l,c]=r.useState(0),d=Boolean(i&&l);return uD(a.scrollbarX,(()=>{var e;const t=(null==(e=a.scrollbarX)?void 0:e.offsetHeight)||0;a.onCornerHeightChange(t),c(t)})),uD(a.scrollbarY,(()=>{var e;const t=(null==(e=a.scrollbarY)?void 0:e.offsetWidth)||0;a.onCornerWidthChange(t),s(t)})),d?k.jsx(NO.div,{...o,ref:t,style:{width:i,height:l,position:"absolute",right:"ltr"===a.dir?0:void 0,left:"rtl"===a.dir?0:void 0,bottom:0,...e.style}}):null}));function oD(e){return e?parseInt(e,10):0}function rD(e,t){const n=e/t;return isNaN(n)?0:n}function aD(e){const t=rD(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,o=(e.scrollbar.size-n)*t;return Math.max(o,18)}function iD(e,t,n="ltr"){const o=aD(t),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,a=t.scrollbar.size-r,i=t.content-t.viewport,s=a-o,l=function(e,[t,n]){return Math.min(n,Math.max(t,e))}(e,"ltr"===n?[0,i]:[-1*i,0]);return sD([0,i],[0,s])(l)}function sD(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const o=(t[1]-t[0])/(e[1]-e[0]);return t[0]+o*(n-e[0])}}function lD(e,t){return e>0&&e<t}var cD=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},o=0;return function r(){const a={left:e.scrollLeft,top:e.scrollTop},i=n.left!==a.left,s=n.top!==a.top;(i||s)&&t(),n=a,o=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(o)};function dD(e,t){const n=IO(e),o=r.useRef(0);return r.useEffect((()=>()=>window.clearTimeout(o.current)),[]),r.useCallback((()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,t)}),[n,t])}function uD(e,t){const n=IO(t);CO((()=>{let t=0;if(e){const o=new ResizeObserver((()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));return o.observe(e),()=>{window.cancelAnimationFrame(t),o.unobserve(e)}}}),[e,n])}var hD=LO,fD=FO,mD=tD;const pD=r.forwardRef(((e,t)=>{const n=b(15);let o,r,a,i,s,l,c,d;return n[0]!==e?(({className:o,children:r,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]),n[4]!==o?(i=rn("relative overflow-hidden",o),n[4]=o,n[5]=i):i=n[5],n[6]!==r?(s=k.jsx(fD,{className:"h-full w-full rounded-[inherit]",children:r}),n[6]=r,n[7]=s):s=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=k.jsx(gD,{}),c=k.jsx(mD,{}),n[8]=l,n[9]=c):(l=n[8],c=n[9]),n[10]!==t||n[11]!==i||n[12]!==a||n[13]!==s?(d=k.jsxs(hD,{ref:t,className:i,...a,children:[s,l,c]}),n[10]=t,n[11]=i,n[12]=a,n[13]=s,n[14]=d):d=n[14],d}));pD.displayName=hD.displayName;const gD=r.forwardRef(((e,t)=>{const n=b(14);let o,r,a;n[0]!==e?(({className:r,orientation:o,...a}=e),n[0]=e,n[1]=o,n[2]=r,n[3]=a):(o=n[1],r=n[2],a=n[3]);const i=void 0===o?"vertical":o,s="vertical"===i&&"h-full w-2.5 border-l border-l-transparent p-[1px]",l="horizontal"===i&&"h-2.5 flex-col border-t border-t-transparent p-[1px]";let c,d,u;return n[4]!==s||n[5]!==l||n[6]!==r?(c=rn("flex touch-none select-none transition-colors",s,l,r),n[4]=s,n[5]=l,n[6]=r,n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=k.jsx(ZO,{className:"relative flex-1 rounded-full bg-border"}),n[8]=d):d=n[8],n[9]!==t||n[10]!==i||n[11]!==c||n[12]!==a?(u=k.jsx(UO,{ref:t,orientation:i,className:c,...a,children:d}),n[9]=t,n[10]=i,n[11]=c,n[12]=a,n[13]=u):u=n[13],u}));gD.displayName=UO.displayName;const vD=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,yD=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,xD={};function bD(e,t){return(xD.jsx?yD:vD).test(e)}const wD=/[ \t\n\f\r]/g;function kD(e){return""===e.replace(wD,"")}class SD{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function ND(e,t){const n={},o={};let r=-1;for(;++r<e.length;)Object.assign(n,e[r].property),Object.assign(o,e[r].normal);return new SD(n,o,t)}function CD(e){return e.toLowerCase()}SD.prototype.property={},SD.prototype.normal={},SD.prototype.space=null;class ED{constructor(e,t){this.property=e,this.attribute=t}}ED.prototype.space=null,ED.prototype.boolean=!1,ED.prototype.booleanish=!1,ED.prototype.overloadedBoolean=!1,ED.prototype.number=!1,ED.prototype.commaSeparated=!1,ED.prototype.spaceSeparated=!1,ED.prototype.commaOrSpaceSeparated=!1,ED.prototype.mustUseProperty=!1,ED.prototype.defined=!1;let jD=0;const _D=PD(),ID=PD(),AD=PD(),TD=PD(),MD=PD(),OD=PD(),DD=PD();function PD(){return 2**++jD}const RD=Object.freeze(Object.defineProperty({__proto__:null,boolean:_D,booleanish:ID,commaOrSpaceSeparated:DD,commaSeparated:OD,number:TD,overloadedBoolean:AD,spaceSeparated:MD},Symbol.toStringTag,{value:"Module"})),LD=Object.keys(RD);class zD extends ED{constructor(e,t,n,o){let r=-1;if(super(e,t),FD(this,"space",o),"number"==typeof n)for(;++r<LD.length;){const e=LD[r];FD(this,LD[r],(n&RD[e])===RD[e])}}}function FD(e,t,n){n&&(e[t]=n)}zD.prototype.defined=!0;const BD={}.hasOwnProperty;function UD(e){const t={},n={};let o;for(o in e.properties)if(BD.call(e.properties,o)){const r=e.properties[o],a=new zD(o,e.transform(e.attributes||{},o),r,e.space);e.mustUseProperty&&e.mustUseProperty.includes(o)&&(a.mustUseProperty=!0),t[o]=a,n[CD(o)]=o,n[CD(a.attribute)]=o}return new SD(t,n,e.space)}const VD=UD({space:"xlink",transform:(e,t)=>"xlink:"+t.slice(5).toLowerCase(),properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null}}),HD=UD({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function $D(e,t){return t in e?e[t]:t}function WD(e,t){return $D(e,t.toLowerCase())}const GD=UD({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:WD,properties:{xmlns:null,xmlnsXLink:null}}),qD=UD({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:ID,ariaAutoComplete:null,ariaBusy:ID,ariaChecked:ID,ariaColCount:TD,ariaColIndex:TD,ariaColSpan:TD,ariaControls:MD,ariaCurrent:null,ariaDescribedBy:MD,ariaDetails:null,ariaDisabled:ID,ariaDropEffect:MD,ariaErrorMessage:null,ariaExpanded:ID,ariaFlowTo:MD,ariaGrabbed:ID,ariaHasPopup:null,ariaHidden:ID,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:MD,ariaLevel:TD,ariaLive:null,ariaModal:ID,ariaMultiLine:ID,ariaMultiSelectable:ID,ariaOrientation:null,ariaOwns:MD,ariaPlaceholder:null,ariaPosInSet:TD,ariaPressed:ID,ariaReadOnly:ID,ariaRelevant:null,ariaRequired:ID,ariaRoleDescription:MD,ariaRowCount:TD,ariaRowIndex:TD,ariaRowSpan:TD,ariaSelected:ID,ariaSetSize:TD,ariaSort:null,ariaValueMax:TD,ariaValueMin:TD,ariaValueNow:TD,ariaValueText:null,role:null}}),YD=UD({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:WD,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:OD,acceptCharset:MD,accessKey:MD,action:null,allow:null,allowFullScreen:_D,allowPaymentRequest:_D,allowUserMedia:_D,alt:null,as:null,async:_D,autoCapitalize:null,autoComplete:MD,autoFocus:_D,autoPlay:_D,blocking:MD,capture:null,charSet:null,checked:_D,cite:null,className:MD,cols:TD,colSpan:null,content:null,contentEditable:ID,controls:_D,controlsList:MD,coords:TD|OD,crossOrigin:null,data:null,dateTime:null,decoding:null,default:_D,defer:_D,dir:null,dirName:null,disabled:_D,download:AD,draggable:ID,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:_D,formTarget:null,headers:MD,height:TD,hidden:_D,high:TD,href:null,hrefLang:null,htmlFor:MD,httpEquiv:MD,id:null,imageSizes:null,imageSrcSet:null,inert:_D,inputMode:null,integrity:null,is:null,isMap:_D,itemId:null,itemProp:MD,itemRef:MD,itemScope:_D,itemType:MD,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:_D,low:TD,manifest:null,max:null,maxLength:TD,media:null,method:null,min:null,minLength:TD,multiple:_D,muted:_D,name:null,nonce:null,noModule:_D,noValidate:_D,onAbort:null,onAfterPrint:null,onAuxClick:null,onBeforeMatch:null,onBeforePrint:null,onBeforeToggle:null,onBeforeUnload:null,onBlur:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onContextLost:null,onContextMenu:null,onContextRestored:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnded:null,onError:null,onFocus:null,onFormData:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLanguageChange:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadEnd:null,onLoadStart:null,onMessage:null,onMessageError:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRejectionHandled:null,onReset:null,onResize:null,onScroll:null,onScrollEnd:null,onSecurityPolicyViolation:null,onSeeked:null,onSeeking:null,onSelect:null,onSlotChange:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnhandledRejection:null,onUnload:null,onVolumeChange:null,onWaiting:null,onWheel:null,open:_D,optimum:TD,pattern:null,ping:MD,placeholder:null,playsInline:_D,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:_D,referrerPolicy:null,rel:MD,required:_D,reversed:_D,rows:TD,rowSpan:TD,sandbox:MD,scope:null,scoped:_D,seamless:_D,selected:_D,shadowRootClonable:_D,shadowRootDelegatesFocus:_D,shadowRootMode:null,shape:null,size:TD,sizes:null,slot:null,span:TD,spellCheck:ID,src:null,srcDoc:null,srcLang:null,srcSet:null,start:TD,step:null,style:null,tabIndex:TD,target:null,title:null,translate:null,type:null,typeMustMatch:_D,useMap:null,value:ID,width:TD,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:MD,axis:null,background:null,bgColor:null,border:TD,borderColor:null,bottomMargin:TD,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:_D,declare:_D,event:null,face:null,frame:null,frameBorder:null,hSpace:TD,leftMargin:TD,link:null,longDesc:null,lowSrc:null,marginHeight:TD,marginWidth:TD,noResize:_D,noHref:_D,noShade:_D,noWrap:_D,object:null,profile:null,prompt:null,rev:null,rightMargin:TD,rules:null,scheme:null,scrolling:ID,standby:null,summary:null,text:null,topMargin:TD,valueType:null,version:null,vAlign:null,vLink:null,vSpace:TD,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:_D,disableRemotePlayback:_D,prefix:null,property:null,results:TD,security:null,unselectable:null}}),XD=UD({space:"svg",attributes:{accentHeight:"accent-height",alignmentBaseline:"alignment-baseline",arabicForm:"arabic-form",baselineShift:"baseline-shift",capHeight:"cap-height",className:"class",clipPath:"clip-path",clipRule:"clip-rule",colorInterpolation:"color-interpolation",colorInterpolationFilters:"color-interpolation-filters",colorProfile:"color-profile",colorRendering:"color-rendering",crossOrigin:"crossorigin",dataType:"datatype",dominantBaseline:"dominant-baseline",enableBackground:"enable-background",fillOpacity:"fill-opacity",fillRule:"fill-rule",floodColor:"flood-color",floodOpacity:"flood-opacity",fontFamily:"font-family",fontSize:"font-size",fontSizeAdjust:"font-size-adjust",fontStretch:"font-stretch",fontStyle:"font-style",fontVariant:"font-variant",fontWeight:"font-weight",glyphName:"glyph-name",glyphOrientationHorizontal:"glyph-orientation-horizontal",glyphOrientationVertical:"glyph-orientation-vertical",hrefLang:"hreflang",horizAdvX:"horiz-adv-x",horizOriginX:"horiz-origin-x",horizOriginY:"horiz-origin-y",imageRendering:"image-rendering",letterSpacing:"letter-spacing",lightingColor:"lighting-color",markerEnd:"marker-end",markerMid:"marker-mid",markerStart:"marker-start",navDown:"nav-down",navDownLeft:"nav-down-left",navDownRight:"nav-down-right",navLeft:"nav-left",navNext:"nav-next",navPrev:"nav-prev",navRight:"nav-right",navUp:"nav-up",navUpLeft:"nav-up-left",navUpRight:"nav-up-right",onAbort:"onabort",onActivate:"onactivate",onAfterPrint:"onafterprint",onBeforePrint:"onbeforeprint",onBegin:"onbegin",onCancel:"oncancel",onCanPlay:"oncanplay",onCanPlayThrough:"oncanplaythrough",onChange:"onchange",onClick:"onclick",onClose:"onclose",onCopy:"oncopy",onCueChange:"oncuechange",onCut:"oncut",onDblClick:"ondblclick",onDrag:"ondrag",onDragEnd:"ondragend",onDragEnter:"ondragenter",onDragExit:"ondragexit",onDragLeave:"ondragleave",onDragOver:"ondragover",onDragStart:"ondragstart",onDrop:"ondrop",onDurationChange:"ondurationchange",onEmptied:"onemptied",onEnd:"onend",onEnded:"onended",onError:"onerror",onFocus:"onfocus",onFocusIn:"onfocusin",onFocusOut:"onfocusout",onHashChange:"onhashchange",onInput:"oninput",onInvalid:"oninvalid",onKeyDown:"onkeydown",onKeyPress:"onkeypress",onKeyUp:"onkeyup",onLoad:"onload",onLoadedData:"onloadeddata",onLoadedMetadata:"onloadedmetadata",onLoadStart:"onloadstart",onMessage:"onmessage",onMouseDown:"onmousedown",onMouseEnter:"onmouseenter",onMouseLeave:"onmouseleave",onMouseMove:"onmousemove",onMouseOut:"onmouseout",onMouseOver:"onmouseover",onMouseUp:"onmouseup",onMouseWheel:"onmousewheel",onOffline:"onoffline",onOnline:"ononline",onPageHide:"onpagehide",onPageShow:"onpageshow",onPaste:"onpaste",onPause:"onpause",onPlay:"onplay",onPlaying:"onplaying",onPopState:"onpopstate",onProgress:"onprogress",onRateChange:"onratechange",onRepeat:"onrepeat",onReset:"onreset",onResize:"onresize",onScroll:"onscroll",onSeeked:"onseeked",onSeeking:"onseeking",onSelect:"onselect",onShow:"onshow",onStalled:"onstalled",onStorage:"onstorage",onSubmit:"onsubmit",onSuspend:"onsuspend",onTimeUpdate:"ontimeupdate",onToggle:"ontoggle",onUnload:"onunload",onVolumeChange:"onvolumechange",onWaiting:"onwaiting",onZoom:"onzoom",overlinePosition:"overline-position",overlineThickness:"overline-thickness",paintOrder:"paint-order",panose1:"panose-1",pointerEvents:"pointer-events",referrerPolicy:"referrerpolicy",renderingIntent:"rendering-intent",shapeRendering:"shape-rendering",stopColor:"stop-color",stopOpacity:"stop-opacity",strikethroughPosition:"strikethrough-position",strikethroughThickness:"strikethrough-thickness",strokeDashArray:"stroke-dasharray",strokeDashOffset:"stroke-dashoffset",strokeLineCap:"stroke-linecap",strokeLineJoin:"stroke-linejoin",strokeMiterLimit:"stroke-miterlimit",strokeOpacity:"stroke-opacity",strokeWidth:"stroke-width",tabIndex:"tabindex",textAnchor:"text-anchor",textDecoration:"text-decoration",textRendering:"text-rendering",transformOrigin:"transform-origin",typeOf:"typeof",underlinePosition:"underline-position",underlineThickness:"underline-thickness",unicodeBidi:"unicode-bidi",unicodeRange:"unicode-range",unitsPerEm:"units-per-em",vAlphabetic:"v-alphabetic",vHanging:"v-hanging",vIdeographic:"v-ideographic",vMathematical:"v-mathematical",vectorEffect:"vector-effect",vertAdvY:"vert-adv-y",vertOriginX:"vert-origin-x",vertOriginY:"vert-origin-y",wordSpacing:"word-spacing",writingMode:"writing-mode",xHeight:"x-height",playbackOrder:"playbackorder",timelineBegin:"timelinebegin"},transform:$D,properties:{about:DD,accentHeight:TD,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:TD,amplitude:TD,arabicForm:null,ascent:TD,attributeName:null,attributeType:null,azimuth:TD,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:TD,by:null,calcMode:null,capHeight:TD,className:MD,clip:null,clipPath:null,clipPathUnits:null,clipRule:null,color:null,colorInterpolation:null,colorInterpolationFilters:null,colorProfile:null,colorRendering:null,content:null,contentScriptType:null,contentStyleType:null,crossOrigin:null,cursor:null,cx:null,cy:null,d:null,dataType:null,defaultAction:null,descent:TD,diffuseConstant:TD,direction:null,display:null,dur:null,divisor:TD,dominantBaseline:null,download:_D,dx:null,dy:null,edgeMode:null,editable:null,elevation:TD,enableBackground:null,end:null,event:null,exponent:TD,externalResourcesRequired:null,fill:null,fillOpacity:TD,fillRule:null,filter:null,filterRes:null,filterUnits:null,floodColor:null,floodOpacity:null,focusable:null,focusHighlight:null,fontFamily:null,fontSize:null,fontSizeAdjust:null,fontStretch:null,fontStyle:null,fontVariant:null,fontWeight:null,format:null,fr:null,from:null,fx:null,fy:null,g1:OD,g2:OD,glyphName:OD,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:TD,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:TD,horizOriginX:TD,horizOriginY:TD,id:null,ideographic:TD,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:TD,k:TD,k1:TD,k2:TD,k3:TD,k4:TD,kernelMatrix:DD,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:TD,local:null,markerEnd:null,markerMid:null,markerStart:null,markerHeight:null,markerUnits:null,markerWidth:null,mask:null,maskContentUnits:null,maskUnits:null,mathematical:null,max:null,media:null,mediaCharacterEncoding:null,mediaContentEncodings:null,mediaSize:TD,mediaTime:null,method:null,min:null,mode:null,name:null,navDown:null,navDownLeft:null,navDownRight:null,navLeft:null,navNext:null,navPrev:null,navRight:null,navUp:null,navUpLeft:null,navUpRight:null,numOctaves:null,observer:null,offset:null,onAbort:null,onActivate:null,onAfterPrint:null,onBeforePrint:null,onBegin:null,onCancel:null,onCanPlay:null,onCanPlayThrough:null,onChange:null,onClick:null,onClose:null,onCopy:null,onCueChange:null,onCut:null,onDblClick:null,onDrag:null,onDragEnd:null,onDragEnter:null,onDragExit:null,onDragLeave:null,onDragOver:null,onDragStart:null,onDrop:null,onDurationChange:null,onEmptied:null,onEnd:null,onEnded:null,onError:null,onFocus:null,onFocusIn:null,onFocusOut:null,onHashChange:null,onInput:null,onInvalid:null,onKeyDown:null,onKeyPress:null,onKeyUp:null,onLoad:null,onLoadedData:null,onLoadedMetadata:null,onLoadStart:null,onMessage:null,onMouseDown:null,onMouseEnter:null,onMouseLeave:null,onMouseMove:null,onMouseOut:null,onMouseOver:null,onMouseUp:null,onMouseWheel:null,onOffline:null,onOnline:null,onPageHide:null,onPageShow:null,onPaste:null,onPause:null,onPlay:null,onPlaying:null,onPopState:null,onProgress:null,onRateChange:null,onRepeat:null,onReset:null,onResize:null,onScroll:null,onSeeked:null,onSeeking:null,onSelect:null,onShow:null,onStalled:null,onStorage:null,onSubmit:null,onSuspend:null,onTimeUpdate:null,onToggle:null,onUnload:null,onVolumeChange:null,onWaiting:null,onZoom:null,opacity:null,operator:null,order:null,orient:null,orientation:null,origin:null,overflow:null,overlay:null,overlinePosition:TD,overlineThickness:TD,paintOrder:null,panose1:null,path:null,pathLength:TD,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:MD,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:TD,pointsAtY:TD,pointsAtZ:TD,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:DD,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:DD,rev:DD,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:DD,requiredFeatures:DD,requiredFonts:DD,requiredFormats:DD,resource:null,restart:null,result:null,rotate:null,rx:null,ry:null,scale:null,seed:null,shapeRendering:null,side:null,slope:null,snapshotTime:null,specularConstant:TD,specularExponent:TD,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:TD,strikethroughThickness:TD,string:null,stroke:null,strokeDashArray:DD,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:TD,strokeOpacity:TD,strokeWidth:null,style:null,surfaceScale:TD,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:DD,tabIndex:TD,tableValues:null,target:null,targetX:TD,targetY:TD,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:DD,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:TD,underlineThickness:TD,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:TD,values:null,vAlphabetic:TD,vMathematical:TD,vectorEffect:null,vHanging:TD,vIdeographic:TD,version:null,vertAdvY:TD,vertOriginX:TD,vertOriginY:TD,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:TD,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),KD=/^data[-\w.:]+$/i,JD=/-[a-z]/g,ZD=/[A-Z]/g;function QD(e){return"-"+e.toLowerCase()}function eP(e){return e.charAt(1).toUpperCase()}const tP={classId:"classID",dataType:"datatype",itemId:"itemID",strokeDashArray:"strokeDasharray",strokeDashOffset:"strokeDashoffset",strokeLineCap:"strokeLinecap",strokeLineJoin:"strokeLinejoin",strokeMiterLimit:"strokeMiterlimit",typeOf:"typeof",xLinkActuate:"xlinkActuate",xLinkArcRole:"xlinkArcrole",xLinkHref:"xlinkHref",xLinkRole:"xlinkRole",xLinkShow:"xlinkShow",xLinkTitle:"xlinkTitle",xLinkType:"xlinkType",xmlnsXLink:"xmlnsXlink"},nP=ND([HD,VD,GD,qD,YD],"html"),oP=ND([HD,VD,GD,qD,XD],"svg");const rP=bs.default||bs,aP=sP("end"),iP=sP("start");function sP(e){return function(t){const n=t&&t.position&&t.position[e]||{};if("number"==typeof n.line&&n.line>0&&"number"==typeof n.column&&n.column>0)return{line:n.line,column:n.column,offset:"number"==typeof n.offset&&n.offset>-1?n.offset:void 0}}}function lP(e){return e&&"object"==typeof e?"position"in e||"type"in e?dP(e.position):"start"in e||"end"in e?dP(e):"line"in e||"column"in e?cP(e):"":""}function cP(e){return uP(e&&e.line)+":"+uP(e&&e.column)}function dP(e){return cP(e&&e.start)+"-"+cP(e&&e.end)}function uP(e){return e&&"number"==typeof e?e:1}class hP extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let o="",r={},a=!1;if(t&&(r="line"in t&&"column"in t||"start"in t&&"end"in t?{place:t}:"type"in t?{ancestors:[t],place:t.position}:{...t}),"string"==typeof e?o=e:!r.cause&&e&&(a=!0,o=e.message,r.cause=e),!r.ruleId&&!r.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?r.ruleId=n:(r.source=n.slice(0,e),r.ruleId=n.slice(e+1))}if(!r.place&&r.ancestors&&r.ancestors){const e=r.ancestors[r.ancestors.length-1];e&&(r.place=e.position)}const i=r.place&&"start"in r.place?r.place.start:r.place;this.ancestors=r.ancestors||void 0,this.cause=r.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file,this.message=o,this.line=i?i.line:void 0,this.name=lP(r.place)||"1:1",this.place=r.place||void 0,this.reason=this.message,this.ruleId=r.ruleId||void 0,this.source=r.source||void 0,this.stack=a&&r.cause&&"string"==typeof r.cause.stack?r.cause.stack:"",this.actual,this.expected,this.note,this.url}}hP.prototype.file="",hP.prototype.name="",hP.prototype.reason="",hP.prototype.message="",hP.prototype.stack="",hP.prototype.column=void 0,hP.prototype.line=void 0,hP.prototype.ancestors=void 0,hP.prototype.cause=void 0,hP.prototype.fatal=void 0,hP.prototype.place=void 0,hP.prototype.ruleId=void 0,hP.prototype.source=void 0;const fP={}.hasOwnProperty,mP=new Map,pP=/[A-Z]/g,gP=/-([a-z])/g,vP=new Set(["table","tbody","thead","tfoot","tr"]),yP=new Set(["td","th"]),xP="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function bP(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let o;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=function(e,t){return n;function n(n,o,r,a){const i=Array.isArray(r.children),s=iP(n);return t(o,r,a,i,{columnNumber:s?s.column-1:void 0,fileName:e,lineNumber:s?s.line:void 0},void 0)}}(n,t.jsxDEV)}else{if("function"!=typeof t.jsx)throw new TypeError("Expected `jsx` in production options");if("function"!=typeof t.jsxs)throw new TypeError("Expected `jsxs` in production options");o=function(e,t,n){return o;function o(e,o,r,a){const i=Array.isArray(r.children)?n:t;return a?i(o,r,a):i(o,r)}}(0,t.jsx,t.jsxs)}const r={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:o,elementAttributeNameCase:t.elementAttributeNameCase||"react",evaluater:t.createEvaluater?t.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:t.ignoreInvalidStyle||!1,passKeys:!1!==t.passKeys,passNode:t.passNode||!1,schema:"svg"===t.space?oP:nP,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},a=wP(r,e,void 0);return a&&"string"!=typeof a?a:r.create(e,r.Fragment,{children:a||void 0},void 0)}function wP(e,t,n){return"element"===t.type?function(e,t,n){const o=e.schema;let r=o;"svg"===t.tagName.toLowerCase()&&"html"===o.space&&(r=oP,e.schema=r);e.ancestors.push(t);const a=EP(e,t.tagName,!1),i=function(e,t){const n={};let o,r;for(r in t.properties)if("children"!==r&&fP.call(t.properties,r)){const a=CP(e,r,t.properties[r]);if(a){const[r,i]=a;e.tableCellAlignToStyle&&"align"===r&&"string"==typeof i&&yP.has(t.tagName)?o=i:n[r]=i}}if(o){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=o}return n}(e,t);let s=NP(e,t);vP.has(t.tagName)&&(s=s.filter((function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&kD(t.value):kD(t));var t})));return kP(e,i,a,t),SP(i,s),e.ancestors.pop(),e.schema=o,e.create(t,a,i,n)}(e,t,n):"mdxFlowExpression"===t.type||"mdxTextExpression"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater){const n=t.data.estree.body[0];return n.type,e.evaluater.evaluateExpression(n.expression)}jP(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const o=e.schema;let r=o;"svg"===t.name&&"html"===o.space&&(r=oP,e.schema=r);e.ancestors.push(t);const a=null===t.name?e.Fragment:EP(e,t.name,!0),i=function(e,t){const n={};for(const o of t.attributes)if("mdxJsxExpressionAttribute"===o.type)if(o.data&&o.data.estree&&e.evaluater){const t=o.data.estree.body[0];t.type;const r=t.expression;r.type;const a=r.properties[0];a.type,Object.assign(n,e.evaluater.evaluateExpression(a.argument))}else jP(e,t.position);else{const r=o.name;let a;if(o.value&&"object"==typeof o.value)if(o.value.data&&o.value.data.estree&&e.evaluater){const t=o.value.data.estree.body[0];t.type,a=e.evaluater.evaluateExpression(t.expression)}else jP(e,t.position);else a=null===o.value||o.value;n[r]=a}return n}(e,t),s=NP(e,t);return kP(e,i,a,t),SP(i,s),e.ancestors.pop(),e.schema=o,e.create(t,a,i,n)}(e,t,n):"mdxjsEsm"===t.type?function(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);jP(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const o={};return SP(o,NP(e,t)),e.create(t,e.Fragment,o,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function kP(e,t,n,o){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=o)}function SP(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function NP(e,t){const n=[];let o=-1;const r=e.passKeys?new Map:mP;for(;++o<t.children.length;){const a=t.children[o];let i;if(e.passKeys){const e="element"===a.type?a.tagName:"mdxJsxFlowElement"===a.type||"mdxJsxTextElement"===a.type?a.name:void 0;if(e){const t=r.get(e)||0;i=e+"-"+t,r.set(e,t+1)}}const s=wP(e,a,i);void 0!==s&&n.push(s)}return n}function CP(e,t,n){const o=function(e,t){const n=CD(t);let o=t,r=ED;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&KD.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(JD,eP);o="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!JD.test(e)){let n=e.replace(ZD,QD);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}r=zD}return new r(o,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=o.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===o.property){let t="object"==typeof n?n:function(e,t){const n={};try{rP(t,o)}catch(r){if(!e.ignoreInvalidStyle){const t=r,n=new hP("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:t,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=xP+"#cannot-parse-style-attribute",n}}return n;function o(e,t){let o=e;"--"!==o.slice(0,2)&&("-ms-"===o.slice(0,4)&&(o="ms-"+o.slice(4)),o=o.replace(gP,IP)),n[o]=t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)fP.call(e,n)&&(t[_P(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&o.space?tP[o.property]||o.property:o.attribute,n]}}function EP(e,t,n){let o;if(n)if(t.includes(".")){const e=t.split(".");let n,r=-1;for(;++r<e.length;){const t=bD(e[r])?{type:"Identifier",name:e[r]}:{type:"Literal",value:e[r]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(r&&"Literal"===t.type),optional:!1}:t}o=n}else o=bD(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else o={type:"Literal",value:t};if("Literal"===o.type){const t=o.value;return fP.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(o);jP(e)}function jP(e,t){const n=new hP("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=xP+"#cannot-handle-mdx-estrees-without-createevaluater",n}function _P(e){let t=e.replace(pP,AP);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function IP(e,t){return t.toUpperCase()}function AP(e){return"-"+e.toLowerCase()}const TP={action:["form"],cite:["blockquote","del","ins","q"],data:["object"],formAction:["button","input"],href:["a","area","base","link"],icon:["menuitem"],itemId:null,manifest:["html"],ping:["a","area"],poster:["video"],src:["audio","embed","iframe","img","input","script","source","track","video"]},MP={};function OP(e,t,n){if(function(e){return Boolean(e&&"object"==typeof e)}(e)){if("value"in e)return"html"!==e.type||n?e.value:"";if(t&&"alt"in e&&e.alt)return e.alt;if("children"in e)return DP(e.children,t,n)}return Array.isArray(e)?DP(e,t,n):""}function DP(e,t,n){const o=[];let r=-1;for(;++r<e.length;)o[r]=OP(e[r],t,n);return o.join("")}const PP=document.createElement("i");function RP(e){const t="&"+e+";";PP.innerHTML=t;const n=PP.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function LP(e,t,n,o){const r=e.length;let a,i=0;if(t=t<0?-t>r?0:r+t:t>r?r:t,n=n>0?n:0,o.length<1e4)a=Array.from(o),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);i<o.length;)a=o.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function zP(e,t){return e.length>0?(LP(e,e.length,0,t),e):t}const FP={}.hasOwnProperty;function BP(e,t){let n;for(n in t){const o=(FP.call(e,n)?e[n]:void 0)||(e[n]={}),r=t[n];let a;if(r)for(a in r){FP.call(o,a)||(o[a]=[]);const e=r[a];UP(o[a],Array.isArray(e)?e:e?[e]:[])}}}function UP(e,t){let n=-1;const o=[];for(;++n<t.length;)("after"===t[n].add?e:o).push(t[n]);LP(e,0,0,o)}function VP(e,t){const n=Number.parseInt(e,t);return n<9||11===n||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||65534==(65535&n)||n>1114111?"�":String.fromCodePoint(n)}function HP(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $P=nR(/[A-Za-z]/),WP=nR(/[\dA-Za-z]/),GP=nR(/[#-'*+\--9=?A-Z^-~]/);function qP(e){return null!==e&&(e<32||127===e)}const YP=nR(/\d/),XP=nR(/[\dA-Fa-f]/),KP=nR(/[!-/:-@[-`{-~]/);function JP(e){return null!==e&&e<-2}function ZP(e){return null!==e&&(e<0||32===e)}function QP(e){return-2===e||-1===e||32===e}const eR=nR(new RegExp("\\p{P}|\\p{S}","u")),tR=nR(/\s/);function nR(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function oR(e){const t=[];let n=-1,o=0,r=0;for(;++n<e.length;){const a=e.charCodeAt(n);let i="";if(37===a&&WP(e.charCodeAt(n+1))&&WP(e.charCodeAt(n+2)))r=2;else if(a<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(a))||(i=String.fromCharCode(a));else if(a>55295&&a<57344){const t=e.charCodeAt(n+1);a<56320&&t>56319&&t<57344?(i=String.fromCharCode(a,t),r=1):i="�"}else i=String.fromCharCode(a);i&&(t.push(e.slice(o,n),encodeURIComponent(i)),o=n+r+1,i=""),r&&(n+=r,r=0)}return t.join("")+e.slice(o)}function rR(e,t,n,o){const r=o?o-1:Number.POSITIVE_INFINITY;let a=0;return function(o){if(QP(o))return e.enter(n),i(o);return t(o)};function i(o){return QP(o)&&a++<r?(e.consume(o),i):(e.exit(n),t(o))}}const aR={tokenize:function(e){const t=e.attempt(this.parser.constructs.contentInitial,(function(n){if(null===n)return void e.consume(n);return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),rR(e,t,"linePrefix")}),(function(t){return e.enter("paragraph"),o(t)}));let n;return t;function o(t){const o=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=o),n=o,r(t)}function r(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):JP(t)?(e.consume(t),e.exit("chunkText"),o):(e.consume(t),r)}}};const iR={tokenize:function(e){const t=this,n=[];let o,r,a,i=0;return s;function s(o){if(i<n.length){const r=n[i];return t.containerState=r[1],e.attempt(r[0].continuation,l,c)(o)}return c(o)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,o&&y();const n=t.events.length;let r,a=n;for(;a--;)if("exit"===t.events[a][0]&&"chunkFlow"===t.events[a][1].type){r=t.events[a][1].end;break}v(i);let s=n;for(;s<t.events.length;)t.events[s][1].end={...r},s++;return LP(t.events,a+1,0,t.events.slice(n)),t.events.length=s,c(e)}return s(e)}function c(r){if(i===n.length){if(!o)return h(r);if(o.currentConstruct&&o.currentConstruct.concrete)return m(r);t.interrupt=Boolean(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(sR,d,u)(r)}function d(e){return o&&y(),v(i),h(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,a=t.now().offset,m(e)}function h(n){return t.containerState={},e.attempt(sR,f,m)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),h(e)}function m(n){return null===n?(o&&y(),v(0),void e.consume(n)):(o=o||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:r}),p(n))}function p(n){return null===n?(g(e.exit("chunkFlow"),!0),v(0),void e.consume(n)):JP(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,s):(e.consume(n),p)}function g(e,n){const s=t.sliceStream(e);if(n&&s.push(null),e.previous=r,r&&(r.next=e),r=e,o.defineSkip(e.start),o.write(s),t.parser.lazy[e.start.line]){let e=o.events.length;for(;e--;)if(o.events[e][1].start.offset<a&&(!o.events[e][1].end||o.events[e][1].end.offset>a))return;const n=t.events.length;let r,s,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(r){s=t.events[l][1].end;break}r=!0}for(v(i),e=n;e<t.events.length;)t.events[e][1].end={...s},e++;LP(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function v(o){let r=n.length;for(;r-- >o;){const o=n[r];t.containerState=o[1],o[0].exit.call(t,e)}n.length=o}function y(){o.write([null]),r=void 0,o=void 0,t.containerState._closeFlow=void 0}}},sR={tokenize:function(e,t,n){return rR(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function lR(e){return null===e||ZP(e)||tR(e)?1:eR(e)?2:void 0}function cR(e,t,n){const o=[];let r=-1;for(;++r<e.length;){const a=e[r].resolveAll;a&&!o.includes(a)&&(t=a(t,n),o.push(a))}return t}const dR={name:"attention",resolveAll:function(e,t){let n,o,r,a,i,s,l,c,d=-1;for(;++d<e.length;)if("enter"===e[d][0]&&"attentionSequence"===e[d][1].type&&e[d][1]._close)for(n=d;n--;)if("exit"===e[n][0]&&"attentionSequence"===e[n][1].type&&e[n][1]._open&&t.sliceSerialize(e[n][1]).charCodeAt(0)===t.sliceSerialize(e[d][1]).charCodeAt(0)){if((e[n][1]._close||e[d][1]._open)&&(e[d][1].end.offset-e[d][1].start.offset)%3&&!((e[n][1].end.offset-e[n][1].start.offset+e[d][1].end.offset-e[d][1].start.offset)%3))continue;s=e[n][1].end.offset-e[n][1].start.offset>1&&e[d][1].end.offset-e[d][1].start.offset>1?2:1;const u={...e[n][1].end},h={...e[d][1].start};uR(u,-s),uR(h,s),a={type:s>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:s>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},r={type:s>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},o={type:s>1?"strong":"emphasis",start:{...a.start},end:{...i.end}},e[n][1].end={...a.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=zP(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=zP(l,[["enter",o,t],["enter",a,t],["exit",a,t],["enter",r,t]]),l=zP(l,cR(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=zP(l,[["exit",r,t],["enter",i,t],["exit",i,t],["exit",o,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=zP(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,LP(e,n-1,d-n+3,l),d=n+l.length-c-2;break}d=-1;for(;++d<e.length;)"attentionSequence"===e[d][1].type&&(e[d][1].type="data");return e},tokenize:function(e,t){const n=this.parser.constructs.attentionMarkers.null,o=this.previous,r=lR(o);let a;return function(t){return a=t,e.enter("attentionSequence"),i(t)};function i(s){if(s===a)return e.consume(s),i;const l=e.exit("attentionSequence"),c=lR(s),d=!c||2===c&&r||n.includes(s),u=!r||2===r&&c||n.includes(o);return l._open=Boolean(42===a?d:d&&(r||!u)),l._close=Boolean(42===a?u:u&&(c||!d)),t(s)}}};function uR(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const hR={name:"autolink",tokenize:function(e,t,n){let o=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),r};function r(t){return $P(t)?(e.consume(t),a):64===t?n(t):l(t)}function a(e){return 43===e||45===e||46===e||WP(e)?(o=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),o=0,s):(43===t||45===t||46===t||WP(t))&&o++<32?(e.consume(t),i):(o=0,l(t))}function s(o){return 62===o?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(o),e.exit("autolinkMarker"),e.exit("autolink"),t):null===o||32===o||60===o||qP(o)?n(o):(e.consume(o),s)}function l(t){return 64===t?(e.consume(t),c):GP(t)?(e.consume(t),l):n(t)}function c(e){return WP(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),o=0,c):62===n?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(n),e.exit("autolinkMarker"),e.exit("autolink"),t):u(n)}function u(t){if((45===t||WP(t))&&o++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const fR={partial:!0,tokenize:function(e,t,n){return function(t){return QP(t)?rR(e,o,"linePrefix")(t):o(t)};function o(e){return null===e||JP(e)?t(e):n(e)}}};const mR={continuation:{tokenize:function(e,t,n){const o=this;return function(t){if(QP(t))return rR(e,r,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return r(t)};function r(o){return e.attempt(mR,t,n)(o)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const o=this;return function(t){if(62===t){const n=o.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),r}return n(t)};function r(n){return QP(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const pR={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),o};function o(o){return KP(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}};const gR={name:"characterReference",tokenize:function(e,t,n){const o=this;let r,a,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),s};function s(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),r=31,a=WP,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),r=6,a=XP,c):(e.enter("characterReferenceValue"),r=7,a=YP,c(t))}function c(s){if(59===s&&i){const r=e.exit("characterReferenceValue");return a!==WP||RP(o.sliceSerialize(r))?(e.enter("characterReferenceMarker"),e.consume(s),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(s)}return a(s)&&i++<r?(e.consume(s),c):n(s)}}};const vR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r};function r(e){return o.parser.lazy[o.now().line]?n(e):t(e)}}},yR={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const o=this,r={partial:!0,tokenize:function(e,t,n){let r=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),QP(t)?rR(e,c,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===a?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===a?(r++,e.consume(t),d):r>=s?(e.exit("codeFencedFenceSequence"),QP(t)?rR(e,u,"whitespace")(t):u(t)):n(t)}function u(o){return null===o||JP(o)?(e.exit("codeFencedFence"),t(o)):n(o)}}};let a,i=0,s=0;return function(t){return function(t){const n=o.events[o.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,a=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===a?(s++,e.consume(t),l):s<3?n(t):(e.exit("codeFencedFenceSequence"),QP(t)?rR(e,c,"whitespace")(t):c(t))}function c(n){return null===n||JP(n)?(e.exit("codeFencedFence"),o.interrupt?t(n):e.check(vR,f,y)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||JP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):QP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),rR(e,u,"whitespace")(t)):96===t&&t===a?n(t):(e.consume(t),d)}function u(t){return null===t||JP(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||JP(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===a?n(t):(e.consume(t),h)}function f(t){return e.attempt(r,y,m)(t)}function m(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return i>0&&QP(t)?rR(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||JP(t)?e.check(vR,f,y)(t):(e.enter("codeFlowValue"),v(t))}function v(t){return null===t||JP(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),v)}function y(n){return e.exit("codeFenced"),t(n)}}};const xR={name:"codeIndented",tokenize:function(e,t,n){const o=this;return function(t){return e.enter("codeIndented"),rR(e,r,"linePrefix",5)(t)};function r(e){const t=o.events[o.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?a(e):n(e)}function a(t){return null===t?s(t):JP(t)?e.attempt(bR,a,s)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||JP(t)?(e.exit("codeFlowValue"),a(t)):(e.consume(t),i)}function s(n){return e.exit("codeIndented"),t(n)}}},bR={partial:!0,tokenize:function(e,t,n){const o=this;return r;function r(t){return o.parser.lazy[o.now().line]?n(t):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r):rR(e,a,"linePrefix",5)(t)}function a(e){const a=o.events[o.events.length-1];return a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(e):JP(e)?r(e):n(e)}}};const wR={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,o=e.length-4,r=3;if(!("lineEnding"!==e[r][1].type&&"space"!==e[r][1].type||"lineEnding"!==e[o][1].type&&"space"!==e[o][1].type))for(t=r;++t<o;)if("codeTextData"===e[t][1].type){e[r][1].type="codeTextPadding",e[o][1].type="codeTextPadding",r+=2,o-=2;break}t=r-1,o++;for(;++t<=o;)void 0===n?t!==o&&"lineEnding"!==e[t][1].type&&(n=t):t!==o&&"lineEnding"!==e[t][1].type||(e[n][1].type="codeTextData",t!==n+2&&(e[n][1].end=e[t-1][1].end,e.splice(n+2,t-n-2),o-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let o,r,a=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),a++,i):(e.exit("codeTextSequence"),s(t))}function s(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),s):96===t?(r=e.enter("codeTextSequence"),o=0,c(t)):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),s):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||JP(t)?(e.exit("codeTextData"),s(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),o++,c):o===a?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(r.type="codeTextData",l(n))}}};class kR{constructor(e){this.left=e?[...e]:[],this.right=[]}get(e){if(e<0||e>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+e+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return e<this.left.length?this.left[e]:this.right[this.right.length-e+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(e,t){const n=null==t?Number.POSITIVE_INFINITY:t;return n<this.left.length?this.left.slice(e,n):e>this.left.length?this.right.slice(this.right.length-n+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-n+this.left.length).reverse())}splice(e,t,n){const o=t||0;this.setCursor(Math.trunc(e));const r=this.right.splice(this.right.length-o,Number.POSITIVE_INFINITY);return n&&SR(this.left,n),r.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(e){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(e)}pushMany(e){this.setCursor(Number.POSITIVE_INFINITY),SR(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),SR(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&0===this.right.length||e<0&&0===this.left.length))if(e<this.left.length){const t=this.left.splice(e,Number.POSITIVE_INFINITY);SR(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);SR(this.left,t.reverse())}}}function SR(e,t){let n=0;if(t.length<1e4)e.push(...t);else for(;n<t.length;)e.push(...t.slice(n,n+1e4)),n+=1e4}function NR(e){const t={};let n,o,r,a,i,s,l,c=-1;const d=new kR(e);for(;++c<d.length;){for(;c in t;)c=t[c];if(n=d.get(c),c&&"chunkFlow"===n[1].type&&"listItemPrefix"===d.get(c-1)[1].type&&(s=n[1]._tokenizer.events,r=0,r<s.length&&"lineEndingBlank"===s[r][1].type&&(r+=2),r<s.length&&"content"===s[r][1].type))for(;++r<s.length&&"content"!==s[r][1].type;)"chunkText"===s[r][1].type&&(s[r][1]._isInFirstContentOfListItem=!0,r++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,CR(d,c)),c=t[c],l=!0);else if(n[1]._container){for(r=c,o=void 0;r--&&(a=d.get(r),"lineEnding"===a[1].type||"lineEndingBlank"===a[1].type);)"enter"===a[0]&&(o&&(d.get(o)[1].type="lineEndingBlank"),a[1].type="lineEnding",o=r);o&&(n[1].end={...d.get(o)[1].start},i=d.slice(o,c),i.unshift(n),d.splice(o,c-o+1,i))}}return LP(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function CR(e,t){const n=e.get(t)[1],o=e.get(t)[2];let r=t-1;const a=[],i=n._tokenizer||o.parser[n.contentType](n.start),s=i.events,l=[],c={};let d,u,h=-1,f=n,m=0,p=0;const g=[p];for(;f;){for(;e.get(++r)[1]!==f;);a.push(r),f._tokenizer||(d=o.sliceStream(f),f.next||d.push(null),u&&i.defineSkip(f.start),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=!0),i.write(d),f._isInFirstContentOfListItem&&(i._gfmTasklistFirstContentOfListItem=void 0)),u=f,f=f.next}for(f=n;++h<s.length;)"exit"===s[h][0]&&"enter"===s[h-1][0]&&s[h][1].type===s[h-1][1].type&&s[h][1].start.line!==s[h][1].end.line&&(p=h+1,g.push(p),f._tokenizer=void 0,f.previous=void 0,f=f.next);for(i.events=[],f?(f._tokenizer=void 0,f.previous=void 0):g.pop(),h=g.length;h--;){const t=s.slice(g[h],g[h+1]),n=a.pop();l.push([n,n+t.length-1]),e.splice(n,2,t)}for(l.reverse(),h=-1;++h<l.length;)c[m+l[h][0]]=m+l[h][1],m+=l[h][1]-l[h][0]-1;return c}const ER={resolve:function(e){return NR(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),o(t)};function o(t){return null===t?r(t):JP(t)?e.check(jR,a,r)(t):(e.consume(t),o)}function r(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function a(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}},jR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),rR(e,r,"linePrefix")};function r(r){if(null===r||JP(r))return n(r);const a=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&a&&"linePrefix"===a[1].type&&a[2].sliceSerialize(a[1],!0).length>=4?t(r):e.interrupt(o.parser.constructs.flow,n,t)(r)}}};function _R(e,t,n,o,r,a,i,s,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(o),e.enter(r),e.enter(a),e.consume(t),e.exit(a),u;if(null===t||32===t||41===t||qP(t))return n(t);return e.enter(o),e.enter(i),e.enter(s),e.enter("chunkString",{contentType:"string"}),m(t)};function u(n){return 62===n?(e.enter(a),e.consume(n),e.exit(a),e.exit(r),e.exit(o),t):(e.enter(s),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(s),u(t)):null===t||60===t||JP(t)?n(t):(e.consume(t),92===t?f:h)}function f(t){return 60===t||62===t||92===t?(e.consume(t),h):h(t)}function m(r){return d||null!==r&&41!==r&&!ZP(r)?d<c&&40===r?(e.consume(r),d++,m):41===r?(e.consume(r),d--,m):null===r||32===r||40===r||qP(r)?n(r):(e.consume(r),92===r?p:m):(e.exit("chunkString"),e.exit(s),e.exit(i),e.exit(o),t(r))}function p(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function IR(e,t,n,o,r,a){const i=this;let s,l=0;return function(t){return e.enter(o),e.enter(r),e.consume(t),e.exit(r),e.enter(a),c};function c(u){return l>999||null===u||91===u||93===u&&!s||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(a),e.enter(r),e.consume(u),e.exit(r),e.exit(o),t):JP(u)?(e.enter("lineEnding"),e.consume(u),e.exit("lineEnding"),c):(e.enter("chunkString",{contentType:"string"}),d(u))}function d(t){return null===t||91===t||93===t||JP(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),s||(s=!QP(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function AR(e,t,n,o,r,a){let i;return function(t){if(34===t||39===t||40===t)return e.enter(o),e.enter(r),e.consume(t),e.exit(r),i=40===t?41:t,s;return n(t)};function s(n){return n===i?(e.enter(r),e.consume(n),e.exit(r),e.exit(o),t):(e.enter(a),l(n))}function l(t){return t===i?(e.exit(a),s(i)):null===t?n(t):JP(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),rR(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||JP(t)?(e.exit("chunkString"),l(t)):(e.consume(t),92===t?d:c)}function d(t){return t===i||92===t?(e.consume(t),c):c(t)}}function TR(e,t){let n;return function o(r){if(JP(r))return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),n=!0,o;if(QP(r))return rR(e,o,n?"linePrefix":"lineSuffix")(r);return t(r)}}const MR={name:"definition",tokenize:function(e,t,n){const o=this;let r;return function(t){return e.enter("definition"),function(t){return IR.call(o,e,a,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function a(t){return r=HP(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),58===t?(e.enter("definitionMarker"),e.consume(t),e.exit("definitionMarker"),i):n(t)}function i(t){return ZP(t)?TR(e,s)(t):s(t)}function s(t){return _R(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(OR,c,c)(t)}function c(t){return QP(t)?rR(e,d,"whitespace")(t):d(t)}function d(a){return null===a||JP(a)?(e.exit("definition"),o.parser.defined.push(r),t(a)):n(a)}}},OR={partial:!0,tokenize:function(e,t,n){return function(t){return ZP(t)?TR(e,o)(t):n(t)};function o(t){return AR(e,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function r(t){return QP(t)?rR(e,a,"whitespace")(t):a(t)}function a(e){return null===e||JP(e)?t(e):n(e)}}};const DR={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),o};function o(o){return JP(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}};const PR={name:"headingAtx",resolve:function(e,t){let n,o,r=e.length-2,a=3;"whitespace"===e[a][1].type&&(a+=2);r-2>a&&"whitespace"===e[r][1].type&&(r-=2);"atxHeadingSequence"===e[r][1].type&&(a===r-1||r-4>a&&"whitespace"===e[r-2][1].type)&&(r-=a+1===r?2:4);r>a&&(n={type:"atxHeadingText",start:e[a][1].start,end:e[r][1].end},o={type:"chunkText",start:e[a][1].start,end:e[r][1].end,contentType:"text"},LP(e,a,r-a+1,[["enter",n,t],["enter",o,t],["exit",o,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let o=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),r(t)}(t)};function r(t){return 35===t&&o++<6?(e.consume(t),r):null===t||ZP(t)?(e.exit("atxHeadingSequence"),a(t)):n(t)}function a(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||JP(n)?(e.exit("atxHeading"),t(n)):QP(n)?rR(e,a,"whitespace")(n):(e.enter("atxHeadingText"),s(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),a(t))}function s(t){return null===t||35===t||ZP(t)?(e.exit("atxHeadingText"),a(t)):(e.consume(t),s)}}};const RR=["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","search","section","summary","table","tbody","td","tfoot","th","thead","title","tr","track","ul"],LR=["pre","script","style","textarea"],zR={concrete:!0,name:"htmlFlow",resolveTo:function(e){let t=e.length;for(;t--&&("enter"!==e[t][0]||"htmlFlow"!==e[t][1].type););t>1&&"linePrefix"===e[t-2][1].type&&(e[t][1].start=e[t-2][1].start,e[t+1][1].start=e[t-2][1].start,e.splice(t-2,2));return e},tokenize:function(e,t,n){const o=this;let r,a,i,s,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(s){return 33===s?(e.consume(s),d):47===s?(e.consume(s),a=!0,f):63===s?(e.consume(s),r=3,o.interrupt?t:D):$P(s)?(e.consume(s),i=String.fromCharCode(s),m):n(s)}function d(a){return 45===a?(e.consume(a),r=2,u):91===a?(e.consume(a),r=5,s=0,h):$P(a)?(e.consume(a),r=4,o.interrupt?t:D):n(a)}function u(r){return 45===r?(e.consume(r),o.interrupt?t:D):n(r)}function h(r){const a="CDATA[";return r===a.charCodeAt(s++)?(e.consume(r),6===s?o.interrupt?t:E:h):n(r)}function f(t){return $P(t)?(e.consume(t),i=String.fromCharCode(t),m):n(t)}function m(s){if(null===s||47===s||62===s||ZP(s)){const l=47===s,c=i.toLowerCase();return l||a||!LR.includes(c)?RR.includes(i.toLowerCase())?(r=6,l?(e.consume(s),p):o.interrupt?t(s):E(s)):(r=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(s):a?g(s):v(s)):(r=1,o.interrupt?t(s):E(s))}return 45===s||WP(s)?(e.consume(s),i+=String.fromCharCode(s),m):n(s)}function p(r){return 62===r?(e.consume(r),o.interrupt?t:E):n(r)}function g(t){return QP(t)?(e.consume(t),g):N(t)}function v(t){return 47===t?(e.consume(t),N):58===t||95===t||$P(t)?(e.consume(t),y):QP(t)?(e.consume(t),v):N(t)}function y(t){return 45===t||46===t||58===t||95===t||WP(t)?(e.consume(t),y):x(t)}function x(t){return 61===t?(e.consume(t),b):QP(t)?(e.consume(t),x):v(t)}function b(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):QP(t)?(e.consume(t),b):k(t)}function w(t){return t===l?(e.consume(t),l=null,S):null===t||JP(t)?n(t):(e.consume(t),w)}function k(t){return null===t||34===t||39===t||47===t||60===t||61===t||62===t||96===t||ZP(t)?x(t):(e.consume(t),k)}function S(e){return 47===e||62===e||QP(e)?v(e):n(e)}function N(t){return 62===t?(e.consume(t),C):n(t)}function C(t){return null===t||JP(t)?E(t):QP(t)?(e.consume(t),C):n(t)}function E(t){return 45===t&&2===r?(e.consume(t),A):60===t&&1===r?(e.consume(t),T):62===t&&4===r?(e.consume(t),P):63===t&&3===r?(e.consume(t),D):93===t&&5===r?(e.consume(t),O):!JP(t)||6!==r&&7!==r?null===t||JP(t)?(e.exit("htmlFlowData"),j(t)):(e.consume(t),E):(e.exit("htmlFlowData"),e.check(FR,R,j)(t))}function j(t){return e.check(BR,_,R)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||JP(t)?j(t):(e.enter("htmlFlowData"),E(t))}function A(t){return 45===t?(e.consume(t),D):E(t)}function T(t){return 47===t?(e.consume(t),i="",M):E(t)}function M(t){if(62===t){const n=i.toLowerCase();return LR.includes(n)?(e.consume(t),P):E(t)}return $P(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),M):E(t)}function O(t){return 93===t?(e.consume(t),D):E(t)}function D(t){return 62===t?(e.consume(t),P):45===t&&2===r?(e.consume(t),D):E(t)}function P(t){return null===t||JP(t)?(e.exit("htmlFlowData"),R(t)):(e.consume(t),P)}function R(n){return e.exit("htmlFlow"),t(n)}}},FR={partial:!0,tokenize:function(e,t,n){return function(o){return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),e.attempt(fR,t,n)}}},BR={partial:!0,tokenize:function(e,t,n){const o=this;return function(t){if(JP(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),r;return n(t)};function r(e){return o.parser.lazy[o.now().line]?n(e):t(e)}}};const UR={name:"htmlText",tokenize:function(e,t,n){const o=this;let r,a,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),s};function s(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),b):63===t?(e.consume(t),y):$P(t)?(e.consume(t),S):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),a=0,f):$P(t)?(e.consume(t),v):n(t)}function c(t){return 45===t?(e.consume(t),h):n(t)}function d(t){return null===t?n(t):45===t?(e.consume(t),u):JP(t)?(i=d,M(t)):(e.consume(t),d)}function u(t){return 45===t?(e.consume(t),h):d(t)}function h(e){return 62===e?T(e):45===e?u(e):d(e)}function f(t){const o="CDATA[";return t===o.charCodeAt(a++)?(e.consume(t),6===a?m:f):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),p):JP(t)?(i=m,M(t)):(e.consume(t),m)}function p(t){return 93===t?(e.consume(t),g):m(t)}function g(t){return 62===t?T(t):93===t?(e.consume(t),g):m(t)}function v(t){return null===t||62===t?T(t):JP(t)?(i=v,M(t)):(e.consume(t),v)}function y(t){return null===t?n(t):63===t?(e.consume(t),x):JP(t)?(i=y,M(t)):(e.consume(t),y)}function x(e){return 62===e?T(e):y(e)}function b(t){return $P(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||WP(t)?(e.consume(t),w):k(t)}function k(t){return JP(t)?(i=k,M(t)):QP(t)?(e.consume(t),k):T(t)}function S(t){return 45===t||WP(t)?(e.consume(t),S):47===t||62===t||ZP(t)?N(t):n(t)}function N(t){return 47===t?(e.consume(t),T):58===t||95===t||$P(t)?(e.consume(t),C):JP(t)?(i=N,M(t)):QP(t)?(e.consume(t),N):T(t)}function C(t){return 45===t||46===t||58===t||95===t||WP(t)?(e.consume(t),C):E(t)}function E(t){return 61===t?(e.consume(t),j):JP(t)?(i=E,M(t)):QP(t)?(e.consume(t),E):N(t)}function j(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),r=t,_):JP(t)?(i=j,M(t)):QP(t)?(e.consume(t),j):(e.consume(t),I)}function _(t){return t===r?(e.consume(t),r=void 0,A):null===t?n(t):JP(t)?(i=_,M(t)):(e.consume(t),_)}function I(t){return null===t||34===t||39===t||60===t||61===t||96===t?n(t):47===t||62===t||ZP(t)?N(t):(e.consume(t),I)}function A(e){return 47===e||62===e||ZP(e)?N(e):n(e)}function T(o){return 62===o?(e.consume(o),e.exit("htmlTextData"),e.exit("htmlText"),t):n(o)}function M(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),O}function O(t){return QP(t)?rR(e,D,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):D(t)}function D(t){return e.enter("htmlTextData"),i(t)}}};const VR={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const o=e[t][1];if(n.push(e[t]),"labelImage"===o.type||"labelLink"===o.type||"labelEnd"===o.type){const e="labelImage"===o.type?4:2;o.type="data",t+=e}}e.length!==n.length&&LP(e,0,e.length,n);return e},resolveTo:function(e,t){let n,o,r,a,i=e.length,s=0;for(;i--;)if(n=e[i][1],o){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(r){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(o=i,"labelLink"!==n.type)){s=2;break}}else"labelEnd"===n.type&&(r=i);const l={type:"labelLink"===e[o][1].type?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[o][1].start},end:{...e[r][1].end}},d={type:"labelText",start:{...e[o+s+2][1].end},end:{...e[r-2][1].start}};return a=[["enter",l,t],["enter",c,t]],a=zP(a,e.slice(o+1,o+s+3)),a=zP(a,[["enter",d,t]]),a=zP(a,cR(t.parser.constructs.insideSpan.null,e.slice(o+s+4,r-3),t)),a=zP(a,[["exit",d,t],e[r-2],e[r-1],["exit",c,t]]),a=zP(a,e.slice(r+1)),a=zP(a,[["exit",l,t]]),LP(e,o,e.length,a),e},tokenize:function(e,t,n){const o=this;let r,a,i=o.events.length;for(;i--;)if(("labelImage"===o.events[i][1].type||"labelLink"===o.events[i][1].type)&&!o.events[i][1]._balanced){r=o.events[i][1];break}return function(t){if(!r)return n(t);if(r._inactive)return d(t);return a=o.parser.defined.includes(HP(o.sliceSerialize({start:r.end,end:o.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),s};function s(t){return 40===t?e.attempt(HR,c,a?c:d)(t):91===t?e.attempt($R,c,a?l:d)(t):a?c(t):d(t)}function l(t){return e.attempt(WR,c,d)(t)}function c(e){return t(e)}function d(e){return r._balanced=!0,n(e)}}},HR={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),o};function o(t){return ZP(t)?TR(e,r)(t):r(t)}function r(t){return 41===t?c(t):_R(e,a,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function a(t){return ZP(t)?TR(e,s)(t):c(t)}function i(e){return n(e)}function s(t){return 34===t||39===t||40===t?AR(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return ZP(t)?TR(e,c)(t):c(t)}function c(o){return 41===o?(e.enter("resourceMarker"),e.consume(o),e.exit("resourceMarker"),e.exit("resource"),t):n(o)}}},$R={tokenize:function(e,t,n){const o=this;return function(t){return IR.call(o,e,r,a,"reference","referenceMarker","referenceString")(t)};function r(e){return o.parser.defined.includes(HP(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function a(e){return n(e)}}},WR={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),o};function o(o){return 93===o?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}};const GR={name:"labelStartImage",resolveAll:VR.resolveAll,tokenize:function(e,t,n){const o=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),r};function r(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),a):n(t)}function a(e){return 94===e&&"_hiddenFootnoteSupport"in o.parser.constructs?n(e):t(e)}}};const qR={name:"labelStartLink",resolveAll:VR.resolveAll,tokenize:function(e,t,n){const o=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),r};function r(e){return 94===e&&"_hiddenFootnoteSupport"in o.parser.constructs?n(e):t(e)}}};const YR={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),rR(e,t,"linePrefix")}}};const XR={name:"thematicBreak",tokenize:function(e,t,n){let o,r=0;return function(t){return e.enter("thematicBreak"),function(e){return o=e,a(e)}(t)};function a(a){return a===o?(e.enter("thematicBreakSequence"),i(a)):r>=3&&(null===a||JP(a))?(e.exit("thematicBreak"),t(a)):n(a)}function i(t){return t===o?(e.consume(t),r++,i):(e.exit("thematicBreakSequence"),QP(t)?rR(e,a,"whitespace")(t):a(t))}}};const KR={continuation:{tokenize:function(e,t,n){const o=this;return o.containerState._closeFlow=void 0,e.check(fR,(function(n){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,rR(e,t,"listItemIndent",o.containerState.size+1)(n)}),(function(n){if(o.containerState.furtherBlankLines||!QP(n))return o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,r(n);return o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,e.attempt(ZR,t,r)(n)}));function r(r){return o.containerState._closeFlow=!0,o.interrupt=void 0,rR(e,e.attempt(KR,t,n),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(r)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const o=this,r=o.events[o.events.length-1];let a=r&&"linePrefix"===r[1].type?r[2].sliceSerialize(r[1],!0).length:0,i=0;return function(t){const r=o.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===r?!o.containerState.marker||t===o.containerState.marker:YP(t)){if(o.containerState.type||(o.containerState.type=r,e.enter(r,{_container:!0})),"listUnordered"===r)return e.enter("listItemPrefix"),42===t||45===t?e.check(XR,n,l)(t):l(t);if(!o.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),s(t)}return n(t)};function s(t){return YP(t)&&++i<10?(e.consume(t),s):(!o.interrupt||i<2)&&(o.containerState.marker?t===o.containerState.marker:41===t||46===t)?(e.exit("listItemValue"),l(t)):n(t)}function l(t){return e.enter("listItemMarker"),e.consume(t),e.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||t,e.check(fR,o.interrupt?n:c,e.attempt(JR,u,d))}function c(e){return o.containerState.initialBlankLine=!0,a++,u(e)}function d(t){return QP(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return o.containerState.size=a+o.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},JR={partial:!0,tokenize:function(e,t,n){const o=this;return rR(e,(function(e){const r=o.events[o.events.length-1];return!QP(e)&&r&&"listItemPrefixWhitespace"===r[1].type?t(e):n(e)}),"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},ZR={partial:!0,tokenize:function(e,t,n){const o=this;return rR(e,(function(e){const r=o.events[o.events.length-1];return r&&"listItemIndent"===r[1].type&&r[2].sliceSerialize(r[1],!0).length===o.containerState.size?t(e):n(e)}),"listItemIndent",o.containerState.size+1)}};const QR={name:"setextUnderline",resolveTo:function(e,t){let n,o,r,a=e.length;for(;a--;)if("enter"===e[a][0]){if("content"===e[a][1].type){n=a;break}"paragraph"===e[a][1].type&&(o=a)}else"content"===e[a][1].type&&e.splice(a,1),r||"definition"!==e[a][1].type||(r=a);const i={type:"setextHeading",start:{...e[o][1].start},end:{...e[e.length-1][1].end}};e[o][1].type="setextHeadingText",r?(e.splice(o,0,["enter",i,t]),e.splice(r+1,0,["exit",e[n][1],t]),e[n][1].end={...e[r][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const o=this;let r;return function(t){let i,s=o.events.length;for(;s--;)if("lineEnding"!==o.events[s][1].type&&"linePrefix"!==o.events[s][1].type&&"content"!==o.events[s][1].type){i="paragraph"===o.events[s][1].type;break}if(!o.parser.lazy[o.now().line]&&(o.interrupt||i))return e.enter("setextHeadingLine"),r=t,function(t){return e.enter("setextHeadingLineSequence"),a(t)}(t);return n(t)};function a(t){return t===r?(e.consume(t),a):(e.exit("setextHeadingLineSequence"),QP(t)?rR(e,i,"lineSuffix")(t):i(t))}function i(o){return null===o||JP(o)?(e.exit("setextHeadingLine"),t(o)):n(o)}}};const eL={tokenize:function(e){const t=this,n=e.attempt(fR,(function(o){if(null===o)return void e.consume(o);return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}),e.attempt(this.parser.constructs.flowInitial,o,rR(e,e.attempt(this.parser.constructs.flow,o,e.attempt(ER,o)),"linePrefix")));return n;function o(o){if(null!==o)return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(o)}}};const tL={resolveAll:aL()},nL=rL("string"),oL=rL("text");function rL(e){return{resolveAll:aL("text"===e?iL:void 0),tokenize:function(t){const n=this,o=this.parser.constructs[e],r=t.attempt(o,a,i);return a;function a(e){return l(e)?r(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),s;t.consume(e)}function s(e){return l(e)?(t.exit("data"),r(e)):(t.consume(e),s)}function l(e){if(null===e)return!0;const t=o[e];let r=-1;if(t)for(;++r<t.length;){const e=t[r];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function aL(e){return function(t,n){let o,r=-1;for(;++r<=t.length;)void 0===o?t[r]&&"data"===t[r][1].type&&(o=r,r++):t[r]&&"data"===t[r][1].type||(r!==o+2&&(t[o][1].end=t[r-1][1].end,t.splice(o+2,r-o-2),r=o+2),o=void 0);return e?e(t,n):t}}function iL(e,t){let n=0;for(;++n<=e.length;)if((n===e.length||"lineEnding"===e[n][1].type)&&"data"===e[n-1][1].type){const o=e[n-1][1],r=t.sliceStream(o);let a,i=r.length,s=-1,l=0;for(;i--;){const e=r[i];if("string"==typeof e){for(s=e.length;32===e.charCodeAt(s-1);)l++,s--;if(s)break;s=-1}else if(-2===e)a=!0,l++;else if(-1!==e){i++;break}}if(l){const r={type:n===e.length||a||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?s:o.start._bufferIndex+s,_index:o.start._index+i,line:o.end.line,column:o.end.column-l,offset:o.end.offset-l},end:{...o.end}};o.end={...r.start},o.start.offset===o.end.offset?Object.assign(o,r):(e.splice(n,0,["enter",r,t],["exit",r,t]),n+=2)}n++}return e}const sL={42:KR,43:KR,45:KR,48:KR,49:KR,50:KR,51:KR,52:KR,53:KR,54:KR,55:KR,56:KR,57:KR,62:mR},lL={91:MR},cL={[-2]:xR,[-1]:xR,32:xR},dL={35:PR,42:XR,45:[QR,XR],60:zR,61:QR,95:XR,96:yR,126:yR},uL={38:gR,92:pR},hL={[-5]:YR,[-4]:YR,[-3]:YR,33:GR,38:gR,42:dR,60:[hR,UR],91:qR,92:[DR,pR],93:VR,95:dR,96:wR},fL={null:[dR,tL]},mL=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:lL,disable:{null:[]},document:sL,flow:dL,flowInitial:cL,insideSpan:fL,string:uL,text:hL},Symbol.toStringTag,{value:"Module"}));function pL(e,t,n){let o={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},a=[];let i=[],s=[];const l={attempt:g((function(e,t){v(e,t.from)})),check:g(p),consume:function(e){JP(e)?(o.line++,o.column=1,o.offset+=-3===e?2:1,y()):-1!==e&&(o.column++,o.offset++);o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===i[o._index].length&&(o._bufferIndex=-1,o._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),s.push(n),n},exit:function(e){const t=s.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:g(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){r[e.line]=e.column,y()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const o=[];let r;for(;++n<e.length;){const a=e[n];let i;if("string"==typeof a)i=a;else switch(a){case-5:i="\r";break;case-4:i="\n";break;case-3:i="\r\n";break;case-2:i=t?" ":"\t";break;case-1:if(!t&&r)continue;i=" ";break;default:i=String.fromCharCode(a)}r=-2===a,o.push(i)}return o.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=zP(i,e),f(),null!==i[i.length-1])return[];return v(t,0),c.events=cR(a,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&a.push(t),c;function u(e){return function(e,t){const n=t.start._index,o=t.start._bufferIndex,r=t.end._index,a=t.end._bufferIndex;let i;if(n===r)i=[e[n].slice(o,a)];else{if(i=e.slice(n,r),o>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(o):i.shift()}a>0&&i.push(e[r].slice(0,a))}return i}(i,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:r,offset:a}=o;return{_bufferIndex:e,_index:t,line:n,column:r,offset:a}}function f(){let e;for(;o._index<i.length;){const t=i[o._index];if("string"==typeof t)for(e=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===e&&o._bufferIndex<t.length;)m(t.charCodeAt(o._bufferIndex));else m(t)}}function m(e){d=d(e)}function p(e,t){t.restore()}function g(e,t){return function(n,r,a){let i,d,u,f;return Array.isArray(n)?m(n):"tokenize"in n?m([n]):function(e){return t;function t(t){const n=null!==t&&e[t],o=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(o)?o:o?[o]:[]])(t)}}(n);function m(e){return i=e,d=0,0===e.length?a:p(e[d])}function p(e){return function(n){f=function(){const e=h(),t=c.previous,n=c.currentConstruct,r=c.events.length,a=Array.from(s);return{from:r,restore:i};function i(){o=e,c.previous=t,c.currentConstruct=n,c.events.length=r,s=a,y()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return v();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,v)(n)}}function g(t){return e(u,f),r}function v(e){return f.restore(),++d<i.length?p(i[d]):a}}}function v(e,t){e.resolveAll&&!a.includes(e)&&a.push(e),e.resolve&&LP(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function y(){o.line in r&&o.column<2&&(o.column=r[o.line],o.offset+=r[o.line]-1)}}function gL(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)BP(t,e[n]);return t}([mL,...(e||{}).extensions||[]]),content:n(aR),defined:[],document:n(iR),flow:n(eL),lazy:{},string:n(nL),text:n(oL)};return t;function n(e){return function(n){return pL(t,e,n)}}}const vL=/[\0\t\n\r]/g;const yL=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function xL(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return VP(n.slice(t?2:1),t?16:10)}return RP(n)||e}const bL={}.hasOwnProperty;function wL(e,t,n){return"string"!=typeof t&&(n=t,t=void 0),function(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:a(te),autolinkProtocol:C,autolinkEmail:C,atxHeading:a(J),blockQuote:a(G),characterEscape:C,characterReference:C,codeFenced:a(q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:a(q,i),codeText:a(Y,i),codeTextData:C,data:C,codeFlowValue:C,definition:a(X),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:a(K),hardBreakEscape:a(Z),hardBreakTrailing:a(Z),htmlFlow:a(Q,i),htmlFlowData:C,htmlText:a(Q,i),htmlTextData:C,image:a(ee),label:i,link:a(te),listItem:a(oe),listItemValue:h,listOrdered:a(ne,u),listUnordered:a(ne),paragraph:a(re),reference:F,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:a(J),strong:a(ae),thematicBreak:a(se)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:W,autolinkProtocol:$,blockQuote:l(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:V,characterReference:H,codeFenced:l(g),codeFencedFence:p,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:l(v),codeText:l(T),codeTextData:E,data:E,definition:l(),definitionDestinationString:b,definitionLabelString:y,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(_),hardBreakTrailing:l(_),htmlFlow:l(I),htmlFlowData:E,htmlText:l(A),htmlTextData:E,image:l(O),label:P,labelText:D,lineEnding:j,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:R,resourceTitleString:L,resource:z,setextHeading:l(N),setextHeadingLineSequence:S,setextHeadingText:k,strong:l(),thematicBreak:l()}};SL(t,(e||{}).mdastExtensions||[]);const n={};return o;function o(e){let o={type:"root",children:[]};const a={stack:[o],tokenStack:[],config:t,enter:s,exit:c,buffer:i,resume:d,data:n},l=[];let u=-1;for(;++u<e.length;)if("listOrdered"===e[u][1].type||"listUnordered"===e[u][1].type)if("enter"===e[u][0])l.push(u);else{u=r(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];bL.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},a),e[u][1])}if(a.tokenStack.length>0){const e=a.tokenStack[a.tokenStack.length-1];(e[1]||CL).call(a,void 0,e[0])}for(o.position={start:kL(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:kL(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)o=t.transforms[u](o)||o;return o}function r(e,t,n){let o,r,a,i,s=t-1,l=-1,c=!1;for(;++s<=n;){const t=e[s];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!o||i||l||a||(a=s),i=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:i=void 0}if(!l&&"enter"===t[0]&&"listItemPrefix"===t[1].type||-1===l&&"exit"===t[0]&&("listUnordered"===t[1].type||"listOrdered"===t[1].type)){if(o){let i=s;for(r=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;r&&(e[r][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",r=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}a&&(!r||a<r)&&(o._spread=!0),o.end=Object.assign({},r?e[r][1].start:t[1].end),e.splice(r||s,0,["exit",o,t[2]]),s++,n++}if("listItemPrefix"===t[1].type){const r={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};o=r,e.splice(s,0,["enter",r,t[2]]),s++,n++,a=void 0,i=!0}}}return e[t][1]._spread=c,n}function a(e,t){return n;function n(n){s.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function s(e,t,n){this.stack[this.stack.length-1].children.push(e),this.stack.push(e),this.tokenStack.push([t,n||void 0]),e.position={start:kL(t.start),end:void 0}}function l(e){return t;function t(t){e&&e.call(this,t),c.call(this,t)}}function c(e,t){const n=this.stack.pop(),o=this.tokenStack.pop();if(!o)throw new Error("Cannot close `"+e.type+"` ("+lP({start:e.start,end:e.end})+"): it’s not open");if(o[0].type!==e.type)if(t)t.call(this,e,o[0]);else{(o[1]||CL).call(this,e,o[0])}n.position.end=kL(e.end)}function d(){return function(e){return OP(e,"boolean"!=typeof MP.includeImageAlt||MP.includeImageAlt,"boolean"!=typeof MP.includeHtml||MP.includeHtml)}(this.stack.pop())}function u(){this.data.expectingFirstListItemValue=!0}function h(e){if(this.data.expectingFirstListItemValue){this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(e),10),this.data.expectingFirstListItemValue=void 0}}function f(){const e=this.resume();this.stack[this.stack.length-1].lang=e}function m(){const e=this.resume();this.stack[this.stack.length-1].meta=e}function p(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function g(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function v(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function y(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HP(this.sliceSerialize(e)).toLowerCase()}function x(){const e=this.resume();this.stack[this.stack.length-1].title=e}function b(){const e=this.resume();this.stack[this.stack.length-1].url=e}function w(e){const t=this.stack[this.stack.length-1];if(!t.depth){const n=this.sliceSerialize(e).length;t.depth=n}}function k(){this.data.setextHeadingSlurpLineEnding=!0}function S(e){this.stack[this.stack.length-1].depth=61===this.sliceSerialize(e).codePointAt(0)?1:2}function N(){this.data.setextHeadingSlurpLineEnding=void 0}function C(e){const t=this.stack[this.stack.length-1].children;let n=t[t.length-1];n&&"text"===n.type||(n=ie(),n.position={start:kL(e.start),end:void 0},t.push(n)),this.stack.push(n)}function E(e){const t=this.stack.pop();t.value+=this.sliceSerialize(e),t.position.end=kL(e.end)}function j(e){const n=this.stack[this.stack.length-1];if(this.data.atHardBreak){return n.children[n.children.length-1].position.end=kL(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(C.call(this,e),E.call(this,e))}function _(){this.data.atHardBreak=!0}function I(){const e=this.resume();this.stack[this.stack.length-1].value=e}function A(){const e=this.resume();this.stack[this.stack.length-1].value=e}function T(){const e=this.resume();this.stack[this.stack.length-1].value=e}function M(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function O(){const e=this.stack[this.stack.length-1];if(this.data.inReference){const t=this.data.referenceType||"shortcut";e.type+="Reference",e.referenceType=t,delete e.url,delete e.title}else delete e.identifier,delete e.label;this.data.referenceType=void 0}function D(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(yL,xL)}(t),n.identifier=HP(t).toLowerCase()}function P(){const e=this.stack[this.stack.length-1],t=this.resume(),n=this.stack[this.stack.length-1];if(this.data.inReference=!0,"link"===n.type){const t=e.children;n.children=t}else n.alt=t}function R(){const e=this.resume();this.stack[this.stack.length-1].url=e}function L(){const e=this.resume();this.stack[this.stack.length-1].title=e}function z(){this.data.inReference=void 0}function F(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=HP(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function V(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let o;if(n)o=VP(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{o=RP(t)}this.stack[this.stack.length-1].value+=o}function H(e){this.stack.pop().position.end=kL(e.end)}function $(e){E.call(this,e);this.stack[this.stack.length-1].url=this.sliceSerialize(e)}function W(e){E.call(this,e);this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(e)}function G(){return{type:"blockquote",children:[]}}function q(){return{type:"code",lang:null,meta:null,value:""}}function Y(){return{type:"inlineCode",value:""}}function X(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function K(){return{type:"emphasis",children:[]}}function J(){return{type:"heading",depth:0,children:[]}}function Z(){return{type:"break"}}function Q(){return{type:"html",value:""}}function ee(){return{type:"image",title:null,url:"",alt:null}}function te(){return{type:"link",title:null,url:"",children:[]}}function ne(e){return{type:"list",ordered:"listOrdered"===e.type,start:null,spread:e._spread,children:[]}}function oe(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function re(){return{type:"paragraph",children:[]}}function ae(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function se(){return{type:"thematicBreak"}}}(n)(function(e){for(;!NR(e););return e}(gL(n).document().write(function(){let e,t=1,n="",o=!0;return function(r,a,i){const s=[];let l,c,d,u,h;for(r=n+("string"==typeof r?r.toString():new TextDecoder(a||void 0).decode(r)),d=0,n="",o&&(65279===r.charCodeAt(0)&&d++,o=void 0);d<r.length;){if(vL.lastIndex=d,l=vL.exec(r),u=l&&void 0!==l.index?l.index:r.length,h=r.charCodeAt(u),!l){n=r.slice(d);break}if(10===h&&d===u&&e)s.push(-3),e=void 0;else switch(e&&(s.push(-5),e=void 0),d<u&&(s.push(r.slice(d,u)),t+=u-d),h){case 0:s.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),s.push(-2);t++<c;)s.push(-1);break;case 10:s.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&s.push(-5),n&&s.push(n),s.push(null)),s}}()(e,t,!0))))}function kL(e){return{line:e.line,column:e.column,offset:e.offset}}function SL(e,t){let n=-1;for(;++n<t.length;){const o=t[n];Array.isArray(o)?SL(e,o):NL(e,o)}}function NL(e,t){let n;for(n in t)if(bL.call(t,n))switch(n){case"canContainEols":{const o=t[n];o&&e[n].push(...o);break}case"transforms":{const o=t[n];o&&e[n].push(...o);break}case"enter":case"exit":{const o=t[n];o&&Object.assign(e[n],o);break}}}function CL(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+lP({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+lP({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+lP({start:t.start,end:t.end})+") is still open")}function EL(e){const t=this;t.parser=function(n){return wL(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function jL(e,t){const n=t.referenceType;let o="]";if("collapsed"===n?o+="[]":"full"===n&&(o+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+o}];const r=e.all(t),a=r[0];a&&"text"===a.type?a.value="["+a.value:r.unshift({type:"text",value:"["});const i=r[r.length-1];return i&&"text"===i.type?i.value+=o:r.push({type:"text",value:o}),r}function _L(e){const t=e.spread;return null==t?e.children.length>1:t}function IL(e){const t=String(e),n=/\r?\n|\r/g;let o=n.exec(t),r=0;const a=[];for(;o;)a.push(AL(t.slice(r,o.index),r>0,!0),o[0]),r=o.index+o[0].length,o=n.exec(t);return a.push(AL(t.slice(r),r>0,!1)),a.join("")}function AL(e,t,n){let o=0,r=e.length;if(t){let t=e.codePointAt(o);for(;9===t||32===t;)o++,t=e.codePointAt(o)}if(n){let t=e.codePointAt(r-1);for(;9===t||32===t;)r--,t=e.codePointAt(r-1)}return r>o?e.slice(o,r):""}const TL={blockquote:function(e,t){const n={type:"element",tagName:"blockquote",properties:{},children:e.wrap(e.all(t),!0)};return e.patch(t,n),e.applyData(t,n)},break:function(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:"\n"}]},code:function(e,t){const n=t.value?t.value+"\n":"",o={};t.lang&&(o.className=["language-"+t.lang]);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:n}]};return t.meta&&(r.data={meta:t.meta}),e.patch(t,r),r=e.applyData(t,r),r={type:"element",tagName:"pre",properties:{},children:[r]},e.patch(t,r),r},delete:function(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},emphasis:function(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},footnoteReference:function(e,t){const n="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",o=String(t.identifier).toUpperCase(),r=oR(o.toLowerCase()),a=e.footnoteOrder.indexOf(o);let i,s=e.footnoteCounts.get(o);void 0===s?(s=0,e.footnoteOrder.push(o),i=e.footnoteOrder.length):i=a+1,s+=1,e.footnoteCounts.set(o,s);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(s>1?"-"+s:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(i)}]};e.patch(t,l);const c={type:"element",tagName:"sup",properties:{},children:[l]};return e.patch(t,c),e.applyData(t,c)},heading:function(e,t){const n={type:"element",tagName:"h"+t.depth,properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},html:function(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}},imageReference:function(e,t){const n=String(t.identifier).toUpperCase(),o=e.definitionById.get(n);if(!o)return jL(e,t);const r={src:oR(o.url||""),alt:t.alt};null!==o.title&&void 0!==o.title&&(r.title=o.title);const a={type:"element",tagName:"img",properties:r,children:[]};return e.patch(t,a),e.applyData(t,a)},image:function(e,t){const n={src:oR(t.url)};null!==t.alt&&void 0!==t.alt&&(n.alt=t.alt),null!==t.title&&void 0!==t.title&&(n.title=t.title);const o={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,o),e.applyData(t,o)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const o={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,o),e.applyData(t,o)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),o=e.definitionById.get(n);if(!o)return jL(e,t);const r={href:oR(o.url||"")};null!==o.title&&void 0!==o.title&&(r.title=o.title);const a={type:"element",tagName:"a",properties:r,children:e.all(t)};return e.patch(t,a),e.applyData(t,a)},link:function(e,t){const n={href:oR(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const o={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)},listItem:function(e,t,n){const o=e.all(t),r=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let o=-1;for(;!t&&++o<n.length;)t=_L(n[o])}return t}(n):_L(t),a={},i=[];if("boolean"==typeof t.checked){const e=o[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},o.unshift(n)),n.children.length>0&&n.children.unshift({type:"text",value:" "}),n.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),a.className=["task-list-item"]}let s=-1;for(;++s<o.length;){const e=o[s];(r||0!==s||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||r?i.push(e):i.push(...e.children)}const l=o[o.length-1];l&&(r||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:a,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},o=e.all(t);let r=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++r<o.length;){const e=o[r];if("element"===e.type&&"li"===e.tagName&&e.properties&&Array.isArray(e.properties.className)&&e.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const a={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(o,!0)};return e.patch(t,a),e.applyData(t,a)},paragraph:function(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},root:function(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)},strong:function(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},table:function(e,t){const n=e.all(t),o=n.shift(),r=[];if(o){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([o],!0)};e.patch(t.children[0],n),r.push(n)}if(n.length>0){const o={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},a=iP(t.children[1]),i=aP(t.children[t.children.length-1]);a&&i&&(o.position={start:a,end:i}),r.push(o)}const a={type:"element",tagName:"table",properties:{},children:e.wrap(r,!0)};return e.patch(t,a),e.applyData(t,a)},tableCell:function(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)},tableRow:function(e,t,n){const o=n?n.children:void 0,r=0===(o?o.indexOf(t):1)?"th":"td",a=n&&"table"===n.type?n.align:void 0,i=a?a.length:t.children.length;let s=-1;const l=[];for(;++s<i;){const n=t.children[s],o={},i=a?a[s]:void 0;i&&(o.align=i);let c={type:"element",tagName:r,properties:o,children:[]};n&&(c.children=e.all(n),e.patch(n,c),c=e.applyData(n,c)),l.push(c)}const c={type:"element",tagName:"tr",properties:{},children:e.wrap(l,!0)};return e.patch(t,c),e.applyData(t,c)},text:function(e,t){const n={type:"text",value:IL(String(t.value))};return e.patch(t,n),e.applyData(t,n)},thematicBreak:function(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)},toml:ML,yaml:ML,definition:ML,footnoteDefinition:ML};function ML(){}const OL="object"==typeof self?self:globalThis,DL=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),o=r=>{if(e.has(r))return e.get(r);const[a,i]=t[r];switch(a){case 0:case-1:return n(i,r);case 1:{const e=n([],r);for(const t of i)e.push(o(t));return e}case 2:{const e=n({},r);for(const[t,n]of i)e[o(t)]=o(n);return e}case 3:return n(new Date(i),r);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),r)}case 5:{const e=n(new Map,r);for(const[t,n]of i)e.set(o(t),o(n));return e}case 6:{const e=n(new Set,r);for(const t of i)e.add(o(t));return e}case 7:{const{name:e,message:t}=i;return n(new OL[e](t),r)}case 8:return n(BigInt(i),r);case"BigInt":return n(Object(BigInt(i)),r)}return n(new OL[a](i),r)};return o})(new Map,e)(0),PL="",{toString:RL}={},{keys:LL}=Object,zL=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=RL.call(e).slice(8,-1);switch(n){case"Array":return[1,PL];case"Object":return[2,PL];case"Date":return[3,PL];case"RegExp":return[4,PL];case"Map":return[5,PL];case"Set":return[6,PL]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},FL=([e,t])=>0===e&&("function"===t||"symbol"===t),BL=(e,{json:t,lossy:n}={})=>{const o=[];return((e,t,n,o)=>{const r=(e,t)=>{const r=o.push(e)-1;return n.set(t,r),r},a=o=>{if(n.has(o))return n.get(o);let[i,s]=zL(o);switch(i){case 0:{let t=o;switch(s){case"bigint":i=8,t=o.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+s);t=null;break;case"undefined":return r([-1],o)}return r([i,t],o)}case 1:{if(s)return r([s,[...o]],o);const e=[],t=r([i,e],o);for(const n of o)e.push(a(n));return t}case 2:{if(s)switch(s){case"BigInt":return r([s,o.toString()],o);case"Boolean":case"Number":case"String":return r([s,o.valueOf()],o)}if(t&&"toJSON"in o)return a(o.toJSON());const n=[],l=r([i,n],o);for(const t of LL(o))!e&&FL(zL(o[t]))||n.push([a(t),a(o[t])]);return l}case 3:return r([i,o.toISOString()],o);case 4:{const{source:e,flags:t}=o;return r([i,{source:e,flags:t}],o)}case 5:{const t=[],n=r([i,t],o);for(const[r,i]of o)(e||!FL(zL(r))&&!FL(zL(i)))&&t.push([a(r),a(i)]);return n}case 6:{const t=[],n=r([i,t],o);for(const r of o)!e&&FL(zL(r))||t.push(a(r));return n}}const{message:l}=o;return r([i,{name:s,message:l}],o)};return a})(!(t||n),!!t,new Map,o)(e),o},UL="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?DL(BL(e,t)):structuredClone(e):(e,t)=>DL(BL(e,t));function VL(e,t){const n=[{type:"text",value:"↩"}];return t>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(t)}]}),n}function HL(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const $L=function(e){if(null==e)return GL;if("function"==typeof e)return WL(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=$L(e[n]);return WL(o);function o(...e){let n=-1;for(;++n<t.length;)if(t[n].apply(this,e))return!0;return!1}}(e):function(e){const t=e;return WL(n);function n(n){const o=n;let r;for(r in e)if(o[r]!==t[r])return!1;return!0}}(e);if("string"==typeof e)return function(e){return WL(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function WL(e){return function(t,n,o){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,o||void 0))}}function GL(){return!0}const qL=[],YL=!0,XL=!1;function KL(e,t,n,o){let r;"function"==typeof t&&"function"!=typeof n?(o=n,n=t):r=t;const a=$L(r),i=o?-1:1;!function e(r,s,l){const c=r&&"object"==typeof r?r:{};if("string"==typeof c.type){const e="string"==typeof c.tagName?c.tagName:"string"==typeof c.name?c.name:void 0;Object.defineProperty(d,"name",{value:"node ("+r.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,h=qL;if((!t||a(r,s,l[l.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[YL,e];return null==e?qL:[e]}(n(r,l)),h[0]===XL))return h;if("children"in r&&r.children){const t=r;if(t.children&&"skip"!==h[0])for(d=(o?t.children.length:-1)+i,u=l.concat(t);d>-1&&d<t.children.length;){const n=t.children[d];if(c=e(n,d,u)(),c[0]===XL)return c;d="number"==typeof c[1]?c[1]:d+i}}return h}}(e,void 0,[])()}function JL(e,t,n,o){let r,a,i;"function"==typeof t&&"function"!=typeof n?(a=void 0,i=t,r=n):(a=t,i=n,r=o),KL(e,a,(function(e,t){const n=t[t.length-1],o=n?n.children.indexOf(e):void 0;return i(e,o,n)}),r)}const ZL={}.hasOwnProperty,QL={};function ez(e,t){e.position&&(t.position=function(e){const t=iP(e),n=aP(e);if(t&&n)return{start:t,end:n}}(e))}function tz(e,t){let n=t;if(e&&e.data){const t=e.data.hName,o=e.data.hChildren,r=e.data.hProperties;if("string"==typeof t)if("element"===n.type)n.tagName=t;else{n={type:"element",tagName:t,properties:{},children:"children"in n?n.children:[n]}}"element"===n.type&&r&&Object.assign(n.properties,UL(r)),"children"in n&&n.children&&null!=o&&(n.children=o)}return n}function nz(e,t){const n=t.data||{},o=!("value"in t)||ZL.call(n,"hProperties")||ZL.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,o),e.applyData(t,o)}function oz(e,t){const n=[];let o=-1;for(t&&n.push({type:"text",value:"\n"});++o<e.length;)o&&n.push({type:"text",value:"\n"}),n.push(e[o]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function rz(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function az(e,t){const n=function(e,t){const n=t||QL,o=new Map,r=new Map,a=new Map,i={...TL,...n.handlers},s={all:function(e){const t=[];if("children"in e){const n=e.children;let o=-1;for(;++o<n.length;){const r=s.one(n[o],e);if(r){if(o&&"break"===n[o-1].type&&(Array.isArray(r)||"text"!==r.type||(r.value=rz(r.value)),!Array.isArray(r)&&"element"===r.type)){const e=r.children[0];e&&"text"===e.type&&(e.value=rz(e.value))}Array.isArray(r)?t.push(...r):t.push(r)}}}return t},applyData:tz,definitionById:o,footnoteById:r,footnoteCounts:a,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,o=s.handlers[n];if(ZL.call(s.handlers,n)&&o)return o(s,e,t);if(s.options.passThrough&&s.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,o=UL(n);return o.children=s.all(e),o}return UL(e)}return(s.options.unknownHandler||nz)(s,e,t)},options:n,patch:ez,wrap:oz};return JL(e,(function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?o:r,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}})),s}(e,t),o=n.one(e,void 0),r=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||VL,o=e.options.footnoteBackLabel||HL,r=e.options.footnoteLabel||"Footnotes",a=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},s=[];let l=-1;for(;++l<e.footnoteOrder.length;){const r=e.footnoteById.get(e.footnoteOrder[l]);if(!r)continue;const a=e.all(r),i=String(r.identifier).toUpperCase(),c=oR(i.toLowerCase());let d=0;const u=[],h=e.footnoteCounts.get(i);for(;void 0!==h&&++d<=h;){u.length>0&&u.push({type:"text",value:" "});let e="string"==typeof n?n:n(l,d);"string"==typeof e&&(e={type:"text",value:e}),u.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+c+(d>1?"-"+d:""),dataFootnoteBackref:"",ariaLabel:"string"==typeof o?o:o(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=a[a.length-1];if(f&&"element"===f.type&&"p"===f.tagName){const e=f.children[f.children.length-1];e&&"text"===e.type?e.value+=" ":f.children.push({type:"text",value:" "}),f.children.push(...u)}else a.push(...u);const m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(a,!0)};e.patch(r,m),s.push(m)}if(0!==s.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:a,properties:{...UL(i),id:"footnote-label"},children:[{type:"text",value:r}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(s,!0)},{type:"text",value:"\n"}]}}(n),a=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return r&&a.children.push({type:"text",value:"\n"},r),a}function iz(e,t){return e&&"run"in e?async function(n,o){const r=az(n,{file:o,...t});await e.run(r,o)}:function(n,o){return az(n,{file:o,...e||t})}}function sz(e){if(e)throw e}var lz=Object.prototype.hasOwnProperty,cz=Object.prototype.toString,dz=Object.defineProperty,uz=Object.getOwnPropertyDescriptor,hz=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===cz.call(e)},fz=function(e){if(!e||"[object Object]"!==cz.call(e))return!1;var t,n=lz.call(e,"constructor"),o=e.constructor&&e.constructor.prototype&&lz.call(e.constructor.prototype,"isPrototypeOf");if(e.constructor&&!n&&!o)return!1;for(t in e);return void 0===t||lz.call(e,t)},mz=function(e,t){dz&&"__proto__"===t.name?dz(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},pz=function(e,t){if("__proto__"===t){if(!lz.call(e,t))return;if(uz)return uz(e,t).value}return e[t]};const gz=ws((function e(){var t,n,o,r,a,i,s=arguments[0],l=1,c=arguments.length,d=!1;for("boolean"==typeof s&&(d=s,s=arguments[1]||{},l=2),(null==s||"object"!=typeof s&&"function"!=typeof s)&&(s={});l<c;++l)if(null!=(t=arguments[l]))for(n in t)o=pz(s,n),s!==(r=pz(t,n))&&(d&&r&&(fz(r)||(a=hz(r)))?(a?(a=!1,i=o&&hz(o)?o:[]):i=o&&fz(o)?o:{},mz(s,{name:n,newValue:e(d,i,r)})):void 0!==r&&mz(s,{name:n,newValue:r}));return s}));function vz(e){if("object"!=typeof e||null===e)return!1;const t=Object.getPrototypeOf(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)}function yz(){const e=[],t={run:function(...t){let n=-1;const o=t.pop();if("function"!=typeof o)throw new TypeError("Expected function as last argument, not "+o);!function r(a,...i){const s=e[++n];let l=-1;if(a)o(a);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,s?function(e,t){let n;return o;function o(...t){const o=e.length>t.length;let s;o&&t.push(r);try{s=e.apply(this,t)}catch(a){if(o&&n)throw a;return r(a)}o||(s&&s.then&&"function"==typeof s.then?s.then(i,r):s instanceof Error?r(s):i(s))}function r(e,...o){n||(n=!0,t(e,...o))}function i(e){r(null,e)}}(s,r)(...i):o(null,...i)}}(null,...t)},use:function(n){if("function"!=typeof n)throw new TypeError("Expected `middelware` to be a function, not "+n);return e.push(n),t}};return t}const xz={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');bz(e);let n,o=0,r=-1,a=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;a--;)if(47===e.codePointAt(a)){if(n){o=a+1;break}}else r<0&&(n=!0,r=a+1);return r<0?"":e.slice(o,r)}if(t===e)return"";let i=-1,s=t.length-1;for(;a--;)if(47===e.codePointAt(a)){if(n){o=a+1;break}}else i<0&&(n=!0,i=a+1),s>-1&&(e.codePointAt(a)===t.codePointAt(s--)?s<0&&(r=a):(s=-1,r=i));o===r?r=i:r<0&&(r=e.length);return e.slice(o,r)},dirname:function(e){if(bz(e),0===e.length)return".";let t,n=-1,o=e.length;for(;--o;)if(47===e.codePointAt(o)){if(t){n=o;break}}else t||(t=!0);return n<0?47===e.codePointAt(0)?"/":".":1===n&&47===e.codePointAt(0)?"//":e.slice(0,n)},extname:function(e){bz(e);let t,n=e.length,o=-1,r=0,a=-1,i=0;for(;n--;){const s=e.codePointAt(n);if(47!==s)o<0&&(t=!0,o=n+1),46===s?a<0?a=n:1!==i&&(i=1):a>-1&&(i=-1);else if(t){r=n+1;break}}if(a<0||o<0||0===i||1===i&&a===o-1&&a===r+1)return"";return e.slice(a,o)},join:function(...e){let t,n=-1;for(;++n<e.length;)bz(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){bz(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,o,r="",a=0,i=-1,s=0,l=-1;for(;++l<=e.length;){if(l<e.length)n=e.codePointAt(l);else{if(47===n)break;n=47}if(47===n){if(i===l-1||1===s);else if(i!==l-1&&2===s){if(r.length<2||2!==a||46!==r.codePointAt(r.length-1)||46!==r.codePointAt(r.length-2))if(r.length>2){if(o=r.lastIndexOf("/"),o!==r.length-1){o<0?(r="",a=0):(r=r.slice(0,o),a=r.length-1-r.lastIndexOf("/")),i=l,s=0;continue}}else if(r.length>0){r="",a=0,i=l,s=0;continue}t&&(r=r.length>0?r+"/..":"..",a=2)}else r.length>0?r+="/"+e.slice(i+1,l):r=e.slice(i+1,l),a=l-i-1;i=l,s=0}else 46===n&&s>-1?s++:s=-1}return r}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function bz(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const wz={cwd:function(){return"/"}};function kz(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function Sz(e){if("string"==typeof e)e=new URL(e);else if(!kz(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if("file:"!==e.protocol){const e=new TypeError("The URL must be of scheme file");throw e.code="ERR_INVALID_URL_SCHEME",e}return function(e){if(""!==e.hostname){const e=new TypeError('File URL host must be "localhost" or empty on darwin');throw e.code="ERR_INVALID_FILE_URL_HOST",e}const t=e.pathname;let n=-1;for(;++n<t.length;)if(37===t.codePointAt(n)&&50===t.codePointAt(n+1)){const e=t.codePointAt(n+2);if(70===e||102===e){const e=new TypeError("File URL path must not include encoded / characters");throw e.code="ERR_INVALID_FILE_URL_PATH",e}}return decodeURIComponent(t)}(e)}const Nz=["history","path","basename","stem","extname","dirname"];class Cz{constructor(e){let t;t=e?kz(e)?{path:e}:"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)?{value:e}:e:{},this.cwd="cwd"in t?"":wz.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,o=-1;for(;++o<Nz.length;){const e=Nz[o];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)Nz.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?xz.basename(this.path):void 0}set basename(e){jz(e,"basename"),Ez(e,"basename"),this.path=xz.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?xz.dirname(this.path):void 0}set dirname(e){_z(this.basename,"dirname"),this.path=xz.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?xz.extname(this.path):void 0}set extname(e){if(Ez(e,"extname"),_z(this.dirname,"extname"),e){if(46!==e.codePointAt(0))throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=xz.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){kz(e)&&(e=Sz(e)),jz(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?xz.basename(this.path,this.extname):void 0}set stem(e){jz(e,"stem"),Ez(e,"stem"),this.path=xz.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const o=this.message(e,t,n);throw o.fatal=!0,o}info(e,t,n){const o=this.message(e,t,n);return o.fatal=void 0,o}message(e,t,n){const o=new hP(e,t,n);return this.path&&(o.name=this.path+":"+o.name,o.file=this.path),o.fatal=!1,this.messages.push(o),o}toString(e){if(void 0===this.value)return"";if("string"==typeof this.value)return this.value;return new TextDecoder(e||void 0).decode(this.value)}}function Ez(e,t){if(e&&e.includes(xz.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+xz.sep+"`")}function jz(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function _z(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const Iz=function(e){const t=this.constructor.prototype,n=t[e],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,t),o},Az={}.hasOwnProperty;class Tz extends Iz{constructor(){super("copy"),this.Compiler=void 0,this.Parser=void 0,this.attachers=[],this.compiler=void 0,this.freezeIndex=-1,this.frozen=void 0,this.namespace={},this.parser=void 0,this.transformers=yz()}copy(){const e=new Tz;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(gz(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(Pz("data",this.frozen),this.namespace[e]=t,this):Az.call(this.namespace,e)&&this.namespace[e]||void 0:e?(Pz("data",this.frozen),this.namespace=e,this):this.namespace}freeze(){if(this.frozen)return this;const e=this;for(;++this.freezeIndex<this.attachers.length;){const[t,...n]=this.attachers[this.freezeIndex];if(!1===n[0])continue;!0===n[0]&&(n[0]=void 0);const o=t.call(e,...n);"function"==typeof o&&this.transformers.use(o)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=zz(e),n=this.parser||this.Parser;return Oz("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),Oz("process",this.parser||this.Parser),Dz("process",this.compiler||this.Compiler),t?o(void 0,t):new Promise(o);function o(o,r){const a=zz(e),i=n.parse(a);function s(e,n){e||!n?r(e):o?o(n):t(void 0,n)}n.run(i,a,(function(e,t,o){if(e||!t||!o)return s(e);const r=t,a=n.stringify(r,o);var i;"string"==typeof(i=a)||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(i)?o.value=a:o.result=a,s(e,o)}))}}processSync(e){let t,n=!1;return this.freeze(),Oz("processSync",this.parser||this.Parser),Dz("processSync",this.compiler||this.Compiler),this.process(e,(function(e,o){n=!0,sz(e),t=o})),Lz("processSync","process",n),t}run(e,t,n){Rz(e),this.freeze();const o=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?r(void 0,n):new Promise(r);function r(r,a){const i=zz(t);o.run(e,i,(function(t,o,i){const s=o||e;t?a(t):r?r(s):n(void 0,s,i)}))}}runSync(e,t){let n,o=!1;return this.run(e,t,(function(e,t){sz(e),n=t,o=!0})),Lz("runSync","run",o),n}stringify(e,t){this.freeze();const n=zz(t),o=this.compiler||this.Compiler;return Dz("stringify",o),Rz(e),o(e,n)}use(e,...t){const n=this.attachers,o=this.namespace;if(Pz("use",this.frozen),null==e);else if("function"==typeof e)s(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):a(e)}return this;function r(e){if("function"==typeof e)s(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;s(t,n)}else a(e)}}function a(e){if(!("plugins"in e)&&!("settings"in e))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");i(e.plugins),e.settings&&(o.settings=gz(!0,o.settings,e.settings))}function i(e){let t=-1;if(null==e);else{if(!Array.isArray(e))throw new TypeError("Expected a list of plugins, not `"+e+"`");for(;++t<e.length;){r(e[t])}}}function s(e,t){let o=-1,r=-1;for(;++o<n.length;)if(n[o][0]===e){r=o;break}if(-1===r)n.push([e,...t]);else if(t.length>0){let[o,...a]=t;const i=n[r][1];vz(i)&&vz(o)&&(o=gz(!0,i,o)),n[r]=[e,o,...a]}}}}const Mz=(new Tz).freeze();function Oz(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function Dz(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function Pz(e,t){if(t)throw new Error("Cannot call `"+e+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Rz(e){if(!vz(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function Lz(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function zz(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new Cz(e)}const Fz=[],Bz={allowDangerousHtml:!0},Uz=/^(https?|ircs?|mailto|xmpp)$/i,Vz=[{from:"astPlugins",id:"remove-buggy-html-in-markdown-parser"},{from:"allowDangerousHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"allowNode",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowElement"},{from:"allowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"allowedElements"},{from:"disallowedTypes",id:"replace-allownode-allowedtypes-and-disallowedtypes",to:"disallowedElements"},{from:"escapeHtml",id:"remove-buggy-html-in-markdown-parser"},{from:"includeElementIndex",id:"#remove-includeelementindex"},{from:"includeNodeIndex",id:"change-includenodeindex-to-includeelementindex"},{from:"linkTarget",id:"remove-linktarget"},{from:"plugins",id:"change-plugins-to-remarkplugins",to:"remarkPlugins"},{from:"rawSourcePos",id:"#remove-rawsourcepos"},{from:"renderers",id:"change-renderers-to-components",to:"components"},{from:"source",id:"change-source-to-children",to:"children"},{from:"sourcePos",id:"#remove-sourcepos"},{from:"transformImageUri",id:"#add-urltransform",to:"urlTransform"},{from:"transformLinkUri",id:"#add-urltransform",to:"urlTransform"}];function Hz(e){const t=e.allowedElements,n=e.allowElement,o=e.children||"",r=e.className,a=e.components,i=e.disallowedElements,s=e.rehypePlugins||Fz,l=e.remarkPlugins||Fz,c=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...Bz}:Bz,d=e.skipHtml,u=e.unwrapDisallowed,h=e.urlTransform||$z,f=Mz().use(EL).use(l).use(iz,c).use(s),m=new Cz;"string"==typeof o&&(m.value=o);for(const v of Vz)Object.hasOwn(e,v.from)&&(v.from,v.to&&v.to,v.id);const p=f.parse(m);let g=f.runSync(p,m);return r&&(g={type:"element",tagName:"div",properties:{className:r},children:"root"===g.type?g.children:[g]}),JL(g,(function(e,o,r){if("raw"===e.type&&r&&"number"==typeof o)return d?r.children.splice(o,1):r.children[o]={type:"text",value:e.value},o;if("element"===e.type){let t;for(t in TP)if(Object.hasOwn(TP,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],o=TP[t];(null===o||o.includes(e.tagName))&&(e.properties[t]=h(String(n||""),t,e))}}if("element"===e.type){let a=t?!t.includes(e.tagName):!!i&&i.includes(e.tagName);if(!a&&n&&"number"==typeof o&&(a=!n(e,o,r)),a&&r&&"number"==typeof o)return u&&e.children?r.children.splice(o,1,...e.children):r.children.splice(o,1),o}})),bP(g,{Fragment:k.Fragment,components:a,ignoreInvalidStyle:!0,jsx:k.jsx,jsxs:k.jsxs,passKeys:!0,passNode:!0})}function $z(e){const t=e.indexOf(":"),n=e.indexOf("?"),o=e.indexOf("#"),r=e.indexOf("/");return t<0||r>-1&&t>r||n>-1&&t>n||o>-1&&t>o||Uz.test(e.slice(0,t))?e:""}const Wz=[Yt.lineWrapping],Gz=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]);const qz=e=>{const t=b(26),{code:n,language:o}=e,{theme:a}=Me(),{createNewCell:i}=q(),s=Rd(),l=le(ue),[c,d]=r.useState(n);let u,h,f;t[0]!==n?(u=()=>{d(n)},h=[n],t[0]=n,t[1]=u,t[2]=h):(u=t[1],h=t[2]),r.useEffect(u,h),t[3]!==o||t[4]!==c||t[5]!==l||t[6]!==i||t[7]!==s?(f=()=>{const e=function(e,t){return e?"python"===e?{language:e,code:t}:"sql"===e?{language:"python",code:Vo.fromQuery(t)}:"markdown"===e?{language:"python",code:Uo.fromMarkdown(t)}:"shell"===e||"bash"===e?{language:"python",code:`import subprocess\nsubprocess.run("${t}")`}:{language:"python",code:`_${e} = """\n${t}\n"""`}:{language:"python",code:t}}(o,c);"sql"===o&&Id(l,i,s),i({code:e.code,before:!1,cellId:s??"__end__"})},t[3]=o,t[4]=c,t[5]=l,t[6]=i,t[7]=s,t[8]=f):f=t[8];const m=f;let p;t[9]!==c?(p=async()=>{await et(c)},t[9]=c,t[10]=p):p=t[10];const g=p,v="dark"===a?"dark":"light",y=o&&Gz.has(o)?o:void 0;let x,w,S,N,E,j;return t[11]!==v||t[12]!==y||t[13]!==c?(x=k.jsx(Yi,{theme:v,language:y,className:"cm border rounded overflow-hidden",extensions:Wz,value:c,onChange:d}),t[11]=v,t[12]=y,t[13]=c,t[14]=x):x=t[14],t[15]!==g?(w=k.jsx(C,{size:"xs",variant:"outline",onClick:g,children:"Copy"}),t[15]=g,t[16]=w):w=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(S=k.jsx(Wl,{className:"ml-2 h-4 w-4"}),t[17]=S):S=t[17],t[18]!==m?(N=k.jsxs(C,{size:"xs",variant:"outline",onClick:m,children:["Add to Notebook",S]}),t[18]=m,t[19]=N):N=t[19],t[20]!==w||t[21]!==N?(E=k.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[w,N]}),t[20]=w,t[21]=N,t[22]=E):E=t[22],t[23]!==x||t[24]!==E?(j=k.jsxs("div",{className:"relative",children:[x,E]}),t[23]=x,t[24]=E,t[25]=j):j=t[25],j},Yz={code:({children:e,className:t})=>{const n=null==t?void 0:t.replace("language-","");return n&&"string"==typeof e?k.jsxs("div",{children:[k.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),k.jsx(qz,{code:e.trim(),language:n})]}):k.jsx("code",{className:t,children:e})}},Xz=e=>{const t=b(2),{content:n}=e;let o;return t[0]!==n?(o=k.jsx(Hz,{components:Yz,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),t[0]=n,t[1]=o):o=t[1],o},Kz=(e,t,n,o)=>t?{...e,chats:e.chats.map((e=>e.id===t?{...e,messages:[...e.messages,{role:n,content:o,timestamp:Date.now()}],updatedAt:Date.now()}:e))}:e,Jz=()=>{const[e,t]=Le(Nd),[n,o]=Le(Cd),[a,i]=r.useState({}),[s,l]=r.useState(""),c=r.useRef(null),d=r.useRef(null),{messages:u,input:h,setInput:f,setMessages:m,append:p,handleSubmit:g,error:v,isLoading:y,reload:x}=ks({keepLastMessageOnError:!0,api:zr("api/ai/chat").toString(),headers:Fr.headers(),body:{...a,includeOtherCode:zs("")},streamProtocol:"text",onFinish:n=>{e.activeChatId?t((e=>Kz(e,e.activeChatId,"assistant",n.content))):J.warn("No active chat")},onError:e=>{J.error("An error occurred:",e)},onResponse:e=>{J.debug("Received HTTP response from server:",e)}}),b=e=>{f(e),i(Pb(e))};r.useEffect((()=>{n&&(m(n.messages.map((({role:e,content:t,timestamp:n})=>({role:e,content:t,id:n.toString()})))),b(""))}),[null==n?void 0:n.id]);return k.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[k.jsxs("div",{className:"flex border-b px-2 py-1 justify-between flex-shrink-0",children:[k.jsx(N,{content:"New chat",children:k.jsx(C,{variant:"text",size:"icon",onClick:()=>{o(null),m([]),b(""),l("")},children:k.jsx(Bo,{className:"h-4 w-4"})})}),k.jsxs(fn,{children:[k.jsx(N,{content:"Previous chats",children:k.jsx(xr,{asChild:!0,children:k.jsx(C,{variant:"text",size:"icon",children:k.jsx(Ss,{className:"h-4 w-4"})})})}),k.jsx(hn,{className:"w-[520px] p-0",align:"start",side:"right",children:k.jsx(pD,{className:"h-[500px] p-4",children:k.jsx("div",{className:"space-y-4",children:e.chats.map((e=>k.jsxs("div",{className:rn("p-3 rounded-md cursor-pointer hover:bg-accent",e.id===(null==n?void 0:n.id)&&"bg-accent"),onClick:()=>{o(e.id),m(e.messages.map((({role:e,content:t,timestamp:n})=>({role:e,content:t,id:n.toString()}))))},children:[k.jsx("div",{className:"font-medium",children:e.title}),k.jsx("div",{className:"text-sm text-muted-foreground",children:new Date(e.updatedAt).toLocaleString()})]},e.id)))})})})]})]}),k.jsxs("div",{className:"flex-1 px-3 bg-[var(--slate-1)] gap-4 py-3 flex flex-col overflow-y-auto",children:[(!u||0===u.length)&&k.jsx("div",{className:"flex rounded-md border px-1 bg-background",children:k.jsx(Bb,{value:s,placeholder:"Ask anything, @ to include context",theme:"light",onClose:()=>{var e,t;return null==(t=null==(e=c.current)?void 0:e.editor)?void 0:t.blur()},onChange:l,onSubmit:()=>s.trim()&&(e=>{const n={id:Ns(),title:`${e.slice(0,30)}...`,messages:[{role:"user",content:e,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()};t((e=>({chats:[...e.chats,n],activeChatId:n.id})));const o=Pb(e);i(o),m([]),p({role:"user",content:e},{body:{...o,includeOtherCode:zs("")}})})(s.trim())},"new-thread-input")}),u.map(((n,o)=>k.jsx("div",{className:rn("flex","user"===n.role?"justify-end":"justify-start"),children:"user"===n.role?k.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:k.jsx(Bb,{value:n.content,theme:"light",placeholder:"Type your message...",onChange:()=>{},onSubmit:(n,r)=>{r.trim()&&(m((e=>e.slice(0,o))),i(Pb(r)),p({role:"user",content:r}),e.activeChatId&&t((t=>Kz(t,e.activeChatId,"user",r))))},onClose:()=>{}},n.id)}):k.jsx("div",{className:"w-[95%]",children:k.jsx(Xz,{content:n.content})})},o))),y&&k.jsx("div",{className:"flex justify-center py-4",children:k.jsx($r,{className:"h-4 w-4 animate-spin"})}),v&&k.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[k.jsx(Vi,{error:v}),k.jsx(C,{variant:"outline",size:"sm",onClick:()=>x(),children:"Retry"})]})]}),u&&u.length>0&&k.jsxs("div",{className:"px-2 py-3 border-t relative flex-shrink-0 min-h-[80px]",children:[y&&k.jsx("div",{className:"flex justify-center mb-2 absolute -top-10 left-0 right-0",children:k.jsx(C,{variant:"secondary",size:"xs",onClick:()=>stop(),className:"text-muted-foreground hover:text-foreground",children:"Cancel"})}),k.jsx(Bb,{value:h,onChange:b,onSubmit:(n,o)=>{o.trim()&&(g(n),e.activeChatId&&t((t=>Kz(t,e.activeChatId,"user",o))))},onClose:()=>{var e,t;return null==(t=null==(e=d.current)?void 0:e.editor)?void 0:t.blur()},theme:"light",placeholder:"Type your message..."})]})]})},Zz=u.lazy((()=>ds((()=>import("./terminal-BLKbWCsr.js")),__vite__mapDeps([15,2,3,16]),import.meta.url))),Qz=e=>{const t=b(113),{children:n}=e,{isSidebarOpen:o,isTerminalOpen:a,selectedPanel:i}=Qd(),{setIsSidebarOpen:s,setIsTerminalOpen:l}=eu(),c=u.useRef(null),d=u.useRef(null);let h,f,m,p,g;t[0]!==o?(h=()=>{if(!c.current)return;const e=c.current.isCollapsed();o&&e&&c.current.expand(),o||e||c.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))},f=[o],t[0]=o,t[1]=h,t[2]=f):(h=t[1],f=t[2]),r.useEffect(h,f),t[3]!==a?(m=()=>{if(!d.current)return;const e=d.current.isCollapsed();a&&e&&d.current.expand(),a||e||d.current.collapse(),requestAnimationFrame((()=>{requestAnimationFrame((()=>{window.dispatchEvent(new Event("resize"))}))}))},p=[a],t[3]=a,t[4]=m,t[5]=p):(m=t[4],p=t[5]),r.useEffect(m,p),t[6]!==n?(g=k.jsx(ek,{id:"app",className:"relative h-full",children:k.jsx(r.Suspense,{children:n})},"app"),t[6]=n,t[7]=g):g=t[7];const v=g,y=eF,x=o?"resize-handle":"resize-handle-collapsed";let w,S;t[8]!==x?(w=rn("border-border no-print z-10",x,"vertical"),t[8]=x,t[9]=w):w=t[9],t[10]!==w?(S=k.jsx(lS,{onDragging:y,className:w}),t[10]=w,t[11]=S):S=t[11];const N=S,E=a?"resize-handle":"resize-handle-collapsed";let j,_;t[12]!==E?(j=rn("border-border no-print z-20",E,"horizontal"),t[12]=E,t[13]=j):j=t[13],t[14]!==j?(_=k.jsx(lS,{onDragging:y,className:j}),t[14]=j,t[15]=_):_=t[15];const I=_;let A,T,M,O,D,P,R,L,z,F,B,U,V,H,$,W,G,q;t[16]!==i?(A=k.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:i}),t[16]=i,t[17]=A):A=t[17],t[18]!==s?(T=()=>s(!1),t[18]=s,t[19]=T):T=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(M=k.jsx(tn,{className:"w-4 h-4"}),t[20]=M):M=t[20],t[21]!==T?(O=k.jsx(C,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:T,children:M}),t[21]=T,t[22]=O):O=t[22],t[23]!==A||t[24]!==O?(D=k.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[A,O]}),t[23]=A,t[24]=O,t[25]=D):D=t[25],t[26]!==i?(P="files"===i&&k.jsx(LM,{}),t[26]=i,t[27]=P):P=t[27],t[28]!==i?(R="errors"===i&&k.jsx(BS,{}),t[28]=i,t[29]=R):R=t[29],t[30]!==i?(L="variables"===i&&k.jsx(rM,{}),t[30]=i,t[31]=L):L=t[31],t[32]!==i?(z="dependencies"===i&&k.jsx(ZT,{}),t[32]=i,t[33]=z):z=t[33],t[34]!==i?(F="packages"===i&&k.jsx(hO,{}),t[34]=i,t[35]=F):F=t[35],t[36]!==i?(B="outline"===i&&k.jsx(VS,{}),t[36]=i,t[37]=B):B=t[37],t[38]!==i?(U="datasources"===i&&k.jsx(YM,{}),t[38]=i,t[39]=U):U=t[39],t[40]!==i?(V="documentation"===i&&k.jsx(cM,{}),t[40]=i,t[41]=V):V=t[41],t[42]!==i?(H="snippets"===i&&k.jsx(VM,{}),t[42]=i,t[43]=H):H=t[43],t[44]!==i?($="scratchpad"===i&&k.jsx(uO,{}),t[44]=i,t[45]=$):$=t[45],t[46]!==i?(W="chat"===i&&k.jsx(Jz,{}),t[46]=i,t[47]=W):W=t[47],t[48]!==i?(G="logs"===i&&k.jsx(aM,{}),t[48]=i,t[49]=G):G=t[49],t[50]!==D||t[51]!==P||t[52]!==R||t[53]!==L||t[54]!==z||t[55]!==F||t[56]!==B||t[57]!==U||t[58]!==V||t[59]!==H||t[60]!==$||t[61]!==W||t[62]!==G?(q=k.jsx(hs,{children:k.jsx(r.Suspense,{children:k.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[D,P,R,L,z,F,B,U,V,H,$,W,G]})})}),t[50]=D,t[51]=P,t[52]=R,t[53]=L,t[54]=z,t[55]=F,t[56]=B,t[57]=U,t[58]=V,t[59]=H,t[60]=$,t[61]=W,t[62]=G,t[63]=q):q=t[63];const Y=q,X=o&&"border-r border-l border-[var(--slate-7)]";let K,J,Z,Q,ee,te;t[64]!==X?(K=rn("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",X),t[64]=X,t[65]=K):K=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(J=(e,t)=>{var n;0===t&&10===e&&(null==(n=c.current)||n.resize(30))},t[66]=J):J=t[66],t[67]!==s?(Z=()=>s(!1),Q=()=>s(!0),t[67]=s,t[68]=Z,t[69]=Q):(Z=t[68],Q=t[69]),t[70]!==Y||t[71]!==N?(ee=k.jsxs("span",{className:"flex flex-row h-full",children:[Y," ",N]}),t[70]=Y,t[71]=N,t[72]=ee):ee=t[72],t[73]!==c||t[74]!==K||t[75]!==Z||t[76]!==Q||t[77]!==ee?(te=k.jsx(ek,{ref:c,id:"helper",collapsedSize:0,collapsible:!0,className:K,minSize:10,defaultSize:0,maxSize:75,onResize:J,onCollapse:Z,onExpand:Q,children:ee},"helper"),t[73]=c,t[74]=K,t[75]=Z,t[76]=Q,t[77]=ee,t[78]=te):te=t[78];const ne=te,oe=a&&"border-[var(--slate-7)]";let re,ae,ie,se,le,ce,de,ue;t[79]!==oe?(re=rn("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",oe),t[79]=oe,t[80]=re):re=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(ae=(e,t)=>{var n;0===t&&10===e&&(null==(n=d.current)||n.resize(30))},t[81]=ae):ae=t[81],t[82]!==l?(ie=()=>l(!1),se=()=>l(!0),t[82]=l,t[83]=ie,t[84]=se):(ie=t[83],se=t[84]),t[85]!==l?(le=()=>l(!1),t[85]=l,t[86]=le):le=t[86],t[87]!==a||t[88]!==le?(ce=k.jsx(Zz,{visible:a,onClose:le}),t[87]=a,t[88]=le,t[89]=ce):ce=t[89],t[90]!==a||t[91]!==ce?(de=k.jsx(aO,{isOpen:a,children:ce}),t[90]=a,t[91]=ce,t[92]=de):de=t[92],t[93]!==d||t[94]!==re||t[95]!==ie||t[96]!==se||t[97]!==I||t[98]!==de?(ue=k.jsxs(ek,{ref:d,id:"terminal",collapsedSize:0,collapsible:!0,className:re,minSize:10,defaultSize:0,maxSize:75,onResize:ae,onCollapse:ie,onExpand:se,children:[I,de]},"terminal"),t[93]=d,t[94]=re,t[95]=ie,t[96]=se,t[97]=I,t[98]=de,t[99]=ue):ue=t[99];const he=ue;let fe,me,pe,ge,ve,ye,xe;return t[100]===Symbol.for("react.memo_cache_sentinel")?(fe={getItem:e=>zS||(zS??null),setItem(e,t){zS=t||null}},me=k.jsx(MS,{}),t[100]=fe,t[101]=me):(fe=t[100],me=t[101]),t[102]!==he?(pe=k.jsx(NS,{capability:"terminal",children:he}),t[102]=he,t[103]=pe):pe=t[103],t[104]!==v||t[105]!==pe?(ge=k.jsx(ek,{children:k.jsxs(aS,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[v,pe]})}),t[104]=v,t[105]=pe,t[106]=ge):ge=t[106],t[107]!==ne||t[108]!==ge?(ve=k.jsxs(aS,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:fe,children:[me,ne,ge]}),t[107]=ne,t[108]=ge,t[109]=ve):ve=t[109],t[110]===Symbol.for("react.memo_cache_sentinel")?(ye=k.jsx(hs,{children:k.jsx(CS,{})}),t[110]=ye):ye=t[110],t[111]!==ve?(xe=k.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[ve,ye]}),t[111]=ve,t[112]=xe):xe=t[112],xe};function eF(e){e||window.dispatchEvent(new Event("resize"))}const tF=e=>{const t=b(5);let n,o,r;return t[0]!==e?(n=k.jsx(Ew,{...e}),t[0]=e,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o=k.jsx(Ud,{}),t[2]=o):o=t[2],t[3]!==n?(r=k.jsxs(Qz,{children:[n,o]}),t[3]=n,t[4]=r):r=t[4],r};export{tF as default};
|