@marimo-team/frontend 0.13.7-dev5 → 0.13.7-dev7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/assets/{ConnectedDataExplorerComponent-D9o6hCFF.js → ConnectedDataExplorerComponent-CsepDyah.js} +1 -1
  2. package/dist/assets/{VegaLite-COeaO8XU.js → VegaLite-C1HXtrMV.js} +1 -1
  3. package/dist/assets/{_baseEach-Dipk4Qfw.js → _baseEach-DD_63bhv.js} +1 -1
  4. package/dist/assets/_baseMap-B4VCibcY.js +1 -0
  5. package/dist/assets/{_baseUniq-CWPdB_dq.js → _baseUniq-CYFxhDYw.js} +1 -1
  6. package/dist/assets/{_createAggregator-CiiGic_e.js → _createAggregator-BzziiCHf.js} +1 -1
  7. package/dist/assets/{any-language-editor-Dvmn1QF2.js → any-language-editor-CzgTNb1K.js} +1 -1
  8. package/dist/assets/{architectureDiagram-IEHRJDOE-CU0QICJs.js → architectureDiagram-IEHRJDOE-C-U-iPbK.js} +1 -1
  9. package/dist/assets/{blockDiagram-JOT3LUYC-CatesY43.js → blockDiagram-JOT3LUYC-wp_uDvyw.js} +1 -1
  10. package/dist/assets/{c4Diagram-VJAJSXHY-C4mhf3Aa.js → c4Diagram-VJAJSXHY-DVvpvjIh.js} +1 -1
  11. package/dist/assets/channel-nBjz4H-G.js +1 -0
  12. package/dist/assets/{chunk-4BMEZGHF-BIy5YQYp.js → chunk-4BMEZGHF-DTOzlx-M.js} +1 -1
  13. package/dist/assets/{chunk-A2AXSNBT-C_xpJ-hN.js → chunk-A2AXSNBT-D0aB6LMu.js} +1 -1
  14. package/dist/assets/{chunk-AEK57VVT-k8f1agAG.js → chunk-AEK57VVT-BXKRbqgm.js} +1 -1
  15. package/dist/assets/{chunk-D6G4REZN--WuDmds7.js → chunk-D6G4REZN-DJIklw-B.js} +1 -1
  16. package/dist/assets/{chunk-RZ5BOZE2-B3GqrIXs.js → chunk-RZ5BOZE2-DbLPmled.js} +1 -1
  17. package/dist/assets/{chunk-XZIHB7SX-Cwjiz9xg.js → chunk-XZIHB7SX-BPf8SbRg.js} +1 -1
  18. package/dist/assets/{circle-play-B3IPtL97.js → circle-play-DJJzVByn.js} +1 -1
  19. package/dist/assets/classDiagram-GIVACNV2-D62d1n5s.js +1 -0
  20. package/dist/assets/classDiagram-v2-COTLJTTW-D62d1n5s.js +1 -0
  21. package/dist/assets/clone-BpRHUGO-.js +1 -0
  22. package/dist/assets/{compile-BVb0Xhkk.js → compile-BrbPA1FV.js} +1 -1
  23. package/dist/assets/{dagre-OKDRZEBW-DE3xoxsa.js → dagre-OKDRZEBW-DMUTu875.js} +1 -1
  24. package/dist/assets/{data-editor-B622NT6D.js → data-editor-BAugqar1.js} +1 -1
  25. package/dist/assets/{diagram-SSKATNLV-DRGoOkB7.js → diagram-SSKATNLV-CgktwEzE.js} +1 -1
  26. package/dist/assets/{diagram-VNBRO52H-j3UmS0Ll.js → diagram-VNBRO52H-DM157GSt.js} +1 -1
  27. package/dist/assets/edit-page-D5MazIt2.js +8 -0
  28. package/dist/assets/{erDiagram-Q7BY3M3F-DWHoCgAJ.js → erDiagram-Q7BY3M3F-CfYnS787.js} +1 -1
  29. package/dist/assets/{flowDiagram-4HSFHLVR-D_rCoypN.js → flowDiagram-4HSFHLVR-BE2xZTx5.js} +1 -1
  30. package/dist/assets/{ganttDiagram-APWFNJXF-CHIT-PcJ.js → ganttDiagram-APWFNJXF-LN8qz0YV.js} +1 -1
  31. package/dist/assets/{gitGraphDiagram-7IBYFJ6S-ErZPaKoV.js → gitGraphDiagram-7IBYFJ6S-BRJVT_zn.js} +1 -1
  32. package/dist/assets/{graph-UJGOb4iX.js → graph-UIDUJmse.js} +1 -1
  33. package/dist/assets/{home-page-CS3aipva.js → home-page-CRQcruYX.js} +1 -1
  34. package/dist/assets/{index-BBlc_oCU.js → index-2SONYAJm.js} +1 -1
  35. package/dist/assets/{index-Z1O8-oVl.js → index-5ldyqPzW.js} +1 -1
  36. package/dist/assets/{index-BKq2imIU.js → index-BJDDQR-b.js} +1 -1
  37. package/dist/assets/index-BbEv2iVN.css +1 -0
  38. package/dist/assets/{index-CDSif2Eo.js → index-BcRkZK42.js} +1 -1
  39. package/dist/assets/{index-C546D0ll.js → index-BeUu3ch_.js} +1 -1
  40. package/dist/assets/index-Bsc9SEYH.js +87 -0
  41. package/dist/assets/{index-57xNO1if.js → index-Bul_n0Oy.js} +1 -1
  42. package/dist/assets/{index-Bl3VaYjI.js → index-BxZz8_b9.js} +1 -1
  43. package/dist/assets/{index-_0tY9ze_.js → index-C4iGahsq.js} +1 -1
  44. package/dist/assets/{index-CnoBeGie.js → index-C8U61zo_.js} +1 -1
  45. package/dist/assets/{index-De2hEZfe.js → index-CE_UMLrN.js} +1 -1
  46. package/dist/assets/{index-6zO4OfLS.js → index-CF6xeTk8.js} +1 -1
  47. package/dist/assets/{index-qlq3rtTI.js → index-CPXRGKlr.js} +1 -1
  48. package/dist/assets/{index-KXLr4M13.js → index-Ce6UaJ0J.js} +1 -1
  49. package/dist/assets/{index-BHXWEyd0.js → index-DYy6_SSS.js} +1 -1
  50. package/dist/assets/{index-BFUZwCtx.js → index-DdDVFm9B.js} +1 -1
  51. package/dist/assets/{index-CvPoYLZ2.js → index-b_tRbrpS.js} +1 -1
  52. package/dist/assets/{index-Br-JkW3g.js → index-bkSNWDvj.js} +1 -1
  53. package/dist/assets/{index-BW8Zm1Wv.js → index-i7xW5_nS.js} +1 -1
  54. package/dist/assets/infoDiagram-PH2N3AL5-HPC1FDCJ.js +1 -0
  55. package/dist/assets/{journeyDiagram-U35MCT3I-DiK9Dw9g.js → journeyDiagram-U35MCT3I-C2DEy4EI.js} +1 -1
  56. package/dist/assets/{kanban-definition-NDS4AKOZ-CjYNE8xn.js → kanban-definition-NDS4AKOZ-B_EEiPWw.js} +1 -1
  57. package/dist/assets/{layout-BjbDeGc_.js → layout-D_LRJAfC.js} +1 -1
  58. package/dist/assets/{linear-O-YCKOSR.js → linear-D5vU7l3E.js} +1 -1
  59. package/dist/assets/{mermaid-DNVHAxFt.js → mermaid-R60l6R69.js} +2 -2
  60. package/dist/assets/{min-W2JRkwEB.js → min-C-OQ4NGo.js} +1 -1
  61. package/dist/assets/{mindmap-definition-ALO5MXBD-Ds099Ktp.js → mindmap-definition-ALO5MXBD-D4QoDDy8.js} +1 -1
  62. package/dist/assets/{pieDiagram-IB7DONF6--fIB0xWO.js → pieDiagram-IB7DONF6-SF9agpbB.js} +1 -1
  63. package/dist/assets/{quadrantDiagram-7GDLP6J5-DrySMa8i.js → quadrantDiagram-7GDLP6J5-BLMHLPC_.js} +1 -1
  64. package/dist/assets/{radar-MK3ICKWK-BJ67P_5r.js → radar-MK3ICKWK-BHuNvtv1.js} +1 -1
  65. package/dist/assets/{react-plotly-DI7dGePo.js → react-plotly-BL5FdwhT.js} +1 -1
  66. package/dist/assets/{requirementDiagram-KVF5MWMF-CrGS2s0Z.js → requirementDiagram-KVF5MWMF-DxjKoyr_.js} +1 -1
  67. package/dist/assets/{run-page-Q-WbWUmv.js → run-page-CmD3K-_E.js} +1 -1
  68. package/dist/assets/{sankeyDiagram-QLVOVGJD-DKjckX4b.js → sankeyDiagram-QLVOVGJD-CstUhZQp.js} +1 -1
  69. package/dist/assets/{sequenceDiagram-X6HHIX6F-C6VC8LOY.js → sequenceDiagram-X6HHIX6F-C0DUaj1h.js} +1 -1
  70. package/dist/assets/{slides-component-BqWYp_FB.js → slides-component-ciQA86ZI.js} +1 -1
  71. package/dist/assets/{sortBy-MHvTYKSP.js → sortBy-DtnQOB1o.js} +1 -1
  72. package/dist/assets/{stateDiagram-DGXRK772-CTMc5Gvb.js → stateDiagram-DGXRK772-DLwZeaFq.js} +1 -1
  73. package/dist/assets/stateDiagram-v2-YXO3MK2T-B0FkKF8G.js +1 -0
  74. package/dist/assets/{terminal-mbvW7Xk5.js → terminal-th4WQMuZ.js} +1 -1
  75. package/dist/assets/{time-B69UfemB.js → time-xufRr6_w.js} +1 -1
  76. package/dist/assets/{timeline-definition-BDJGKUSR-DxC35mOc.js → timeline-definition-BDJGKUSR-bfHyV-7E.js} +1 -1
  77. package/dist/assets/{tracing-DDaw37xD.js → tracing-DVLROVSe.js} +3 -3
  78. package/dist/assets/tree-Bc56h0bS.js +8 -0
  79. package/dist/assets/{useMarimoWebSocket-xQ57O6MQ.js → useMarimoWebSocket-C5cupBS4.js} +3 -3
  80. package/dist/assets/{vega-component-Cw4CVdyb.js → vega-component-BCCNIpr4.js} +1 -1
  81. package/dist/assets/{xychartDiagram-VJFVF3MP-DHps7gn-.js → xychartDiagram-VJFVF3MP-DxMG0q6v.js} +1 -1
  82. package/dist/index.html +2 -2
  83. package/package.json +1 -1
  84. package/dist/assets/_baseMap-d7_s2dxj.js +0 -1
  85. package/dist/assets/channel-DqVPz42W.js +0 -1
  86. package/dist/assets/classDiagram-GIVACNV2-CDT_8kPv.js +0 -1
  87. package/dist/assets/classDiagram-v2-COTLJTTW-CDT_8kPv.js +0 -1
  88. package/dist/assets/clone-Cei_W01Q.js +0 -1
  89. package/dist/assets/edit-page-DBO2lLpw.js +0 -8
  90. package/dist/assets/index-BTHBullW.js +0 -87
  91. package/dist/assets/index-KBPV2vq8.css +0 -1
  92. package/dist/assets/infoDiagram-PH2N3AL5-k9F5eQpB.js +0 -1
  93. package/dist/assets/stateDiagram-v2-YXO3MK2T-DnNajpIH.js +0 -1
  94. package/dist/assets/tree-DxEOaINK.js +0 -8
@@ -1,8 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-De2hEZfe.js","./VegaLite-COeaO8XU.js","./index-BTHBullW.js","./index-KBPV2vq8.css","./compile-BVb0Xhkk.js","./time-B69UfemB.js","./timer-DFzT7np-.js","./linear-O-YCKOSR.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./zoom-COrs4lFh.js","./ordinal-DDUp3AbE.js","./colors-bszWmPJw.js","./arc-Cuwikxov.js","./step-BwsUM5iJ.js","./index-qlq3rtTI.js","./tracing-DDaw37xD.js","./useMarimoWebSocket-xQ57O6MQ.js","./index-Br-JkW3g.js","./index-BBlc_oCU.js","./index-KXLr4M13.js","./index-BFUZwCtx.js","./index-CnoBeGie.js","./index-BKq2imIU.js","./index-CvPoYLZ2.js","./index-Z1O8-oVl.js","./index-C546D0ll.js","./index-_0tY9ze_.js","./index-57xNO1if.js","./index-BW8Zm1Wv.js","./index-Bl3VaYjI.js","./apl-CXdQSnD-.js","./asciiarmor-D5V0T9Cu.js","./asterisk-B46aRdXb.js","./brainfuck-CtZaYBKt.js","./clike-BgBwzOhw.js","./cmake-DXn5xaP-.js","./cobol-stawOqaz.js","./coffeescript-BTDxI-eT.js","./commonlisp-vq6DHwts.js","./crystal-CRzZ78HM.js","./cypher-gJDei3ni.js","./d-BShv7fp-.js","./diff-UJJ5BM9S.js","./dockerfile-knGOOxt4.js","./simple-mode-C3vEBAcb.js","./dtd-DI9Herc-.js","./dylan-CHJ5qNM_.js","./ebnf-B-Df8AvO.js","./ecl-DPFc0Uaf.js","./eiffel-DR5c0IrL.js","./elm-D7xaZ7Da.js","./erlang-BuqgqA5h.js","./factor-CFXhaUWb.js","./fcl-CVaBTCzQ.js","./forth-Dri_5nFc.js","./fortran-DL7KluxX.js","./gas-5kEe4nk0.js","./gherkin-B6X1vGSW.js","./groovy-DnIzCrpZ.js","./haskell-CmdsSjFB.js","./haxe-D25e-2l-.js","./http-BKJkqRj4.js","./idl-pcmmZuaN.js","./jinja2-DhgKlfW7.js","./julia-DjdwvFuI.js","./livescript-HO6ttBFx.js","./lua-8DXOpKDz.js","./mathematica-IIbmv7SK.js","./mbox-DoeuZPxA.js","./mirc-DkvFAiy5.js","./modelica-DSrSSXCg.js","./mscgen-B2igx18G.js","./mumps-zvxmGV4l.js","./nginx-B4hAVlXN.js","./nsis-BvKfQ9lQ.js","./ntriples-FFvkTduk.js","./octave-C4hdQ5Hf.js","./oz-qQq7irPq.js","./pascal-CafrKXZF.js","./perl-tdMlh9QA.js","./pig-CwGJVRC4.js","./powershell-D1ly3AHC.js","./properties-_nPj978X.js","./protobuf-B4y9do6W.js","./puppet-Bc-yJKzi.js","./q-B0kTJ4cI.js","./r-BA4EbLKE.js","./ruby-CR-u2WLS.js","./sas-Bqaci40L.js","./scheme-qjP0V5Ag.js","./shell-BLav31RL.js","./sieve-r025o_jW.js","./smalltalk-C7J3IyEP.js","./solr-78MBEUkU.js","./sparql-BRLJFz69.js","./spreadsheet-CGlWr0eM.js","./stylus-OdhglgkO.js","./swift-B_XXVlXX.js","./tcl-B2fODqDH.js","./textile-BuVhTOzU.js","./tiddlywiki-BgR6AEZu.js","./tiki-CI-ztowC.js","./toml-BQXy8elZ.js","./troff-Ce85hlLp.js","./ttcn-BxnYHtq8.js","./turtle-BkSuIpt-.js","./vb-BHgjm0DN.js","./vbscript-Dawdd5GZ.js","./velocity-BdD_26Jv.js","./verilog-B4LBqg_1.js","./vhdl-CWWH2SUo.js","./webidl-CGwyPRYs.js","./xquery-CVDBqZPY.js","./yacas-I8QjZlxf.js","./z80-D8p3gKXp.js","./useMarimoWebSocket-DcAzAz16.css","./tree-DxEOaINK.js","./tree-C1rhMrxo.css","./circle-play-B3IPtL97.js","./_createAggregator-CiiGic_e.js","./_baseEach-Dipk4Qfw.js","./transform-DjHZbYKP.js","./sortBy-MHvTYKSP.js","./_baseMap-d7_s2dxj.js","./terminal-mbvW7Xk5.js","./terminal-DVzybcfs.css"])))=>i.map(i=>d[i]);
2
- var e,t,n,r=Object.defineProperty,o=e=>{throw TypeError(e)},s=(e,t,n)=>((e,t,n)=>t in e?r(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n),i=(e,t,n)=>(((e,t,n)=>{t.has(e)||o("Cannot "+n)})(e,t,"read from private field"),n?n.call(e):t.get(e));import{u as a,S as l,hZ as c,h_ as d,h$ as u,i0 as h,i1 as f,i2 as m,R as p,i3 as g,i4 as y,i5 as b,i6 as x,i7 as v,i8 as w,i9 as k,ia as S,ib as C,d as N,ac as E,ic as j,j as _,dm as I,dn as A,dp as T,dr as M,dt as D,f0 as O,id as R,dk as P,dl as L,dq as F,ie as z,ig as B,ea as U,aH as $,Q as V,ih as H,dP as W,ii as G,ij as q,ik as Y,il as K,im as J,L as X,aj as Z,cx as Q,a2 as ee,io as te,eb as ne,ip as re,iq as oe,a8 as se,ir as ie,ef as ae,is as le,it as ce,T as de,bs as ue,al as he,iu as fe,iv as me,d$ as pe,iw as ge,ix as ye,iy as be,e8 as xe,iz as ve,iA as we,dH as ke,as as Se,iB as Ce,bg as Ne,iC as Ee,iD as je,aq as _e,ew as Ie,ar as Ae,iE as Te,a7 as Me,iF as De,iG as Oe,a3 as Re,a4 as Pe,a5 as Le,bK as Fe,iH as ze,af as Be,e0 as Ue,gb as $e,fD as Ve,ge as He,bw as We,fB as Ge,aJ as qe,iI as Ye,iJ as Ke,iK as Je,iL as Xe,iM as Ze,fC as Qe,iN as et,iO as tt,fH as nt,iP as rt,iQ as ot,dW as st,Z as it,a6 as at,bI as lt,iR as ct,aM as dt,a9 as ut,ap as ht,eY as ft,bB as mt,eh as pt,iS as gt,eJ as yt,du as bt,iT as xt,bh as vt,iU as wt,iV as kt,e5 as St,iW as Ct,iX as Nt,bN as Et,iY as jt,dN as _t,iZ as It,i_ as At,i$ as Tt,j0 as Mt,j1 as Dt,fi as Ot,bb as Rt,aE as Pt,f$ as Lt,g0 as Ft,g1 as zt,g5 as Bt,g2 as Ut,ag as $t,dG as Vt,bd as Ht,bk as Wt,be as Gt,bi as qt,e9 as Yt,j2 as Kt,g3 as Jt,j3 as Xt,fU as Zt,fW as Qt,j4 as en,j5 as tn,j6 as nn,a1 as rn,a0 as on,e4 as sn,j7 as an,j8 as ln,j9 as cn,ja as dn,jb as un,jc as hn,jd as fn,fG as mn,dI as pn,bE as gn,je as yn,ab as bn,bf as xn,jf as vn,gf as wn,bA as kn,jg as Sn,aa as Cn,dX as Nn,jh as En,$ as jn,fY as _n,ji as In,jj as An,jk as Tn,jl as Mn,jm as Dn,jn as On,di as Rn,jo as Pn,jp as Ln,o as Fn,n as zn,fl as Bn,jq as Un,jr as $n,js as Vn,jt as Hn,ju as Wn,dM as Gn,jv as qn,jw as Yn,by as Kn,bz as Jn,jx as Xn,jy as Zn,gi as Qn,jz as er,bv as tr,gh as nr,jA as rr,jB as or,ec as sr,jC as ir,jD as ar,jE as lr,jF as cr,jG as dr,jH as ur,jI as hr,jJ as fr,jK as mr,jL as pr,jM as gr,ed as yr,jN as br,aI as xr,jO as vr,fk as wr,jP as kr,jQ as Sr,jR as Cr,jS as Nr,jT as Er,fv as jr,jU as _r,jV as Ir,jW as Ar,jX as Tr,jY as Mr,fc as Dr,jZ as Or,j_ as Rr,eI as Pr,r as Lr,j$ as Fr,k0 as zr,k1 as Br,t as Ur,k2 as $r,k3 as Vr,k4 as Hr,fO as Wr,k5 as Gr,fo as qr,aB as Yr,k6 as Kr,k7 as Jr,k8 as Xr,k9 as Zr,ka as Qr,kb as eo,kc as to,kd as no,ke as ro,kf as oo,kg as so,kh as io,ki as ao,kj as lo,kk as co,kl as uo,km as ho,kn as fo,ko as mo,kp as po,kq as go,kr as yo,ks as bo,kt as xo,ku as vo,kv as wo,kw as ko,kx as So,ky as Co,kz as No,kA as Eo,kB as jo,kC as _o,kD as Io,kE as Ao,kF as To,kG as Mo,kH as Do,kI as Oo,kJ as Ro,kK as Po,kL as Lo,kM as Fo,kN as zo,kO as Bo,kP as Uo,kQ as $o,kR as Vo,kS as Ho,kT as Wo,kU as Go,kV as qo,kW as Yo,kX as Ko,ei as Jo,kY as Xo,kZ as Zo,em as Qo,k_ as es,k$ as ts,l0 as ns,l1 as rs,l2 as os,ah as ss,l3 as is,el as as,l4 as ls,l5 as cs,l6 as ds,l7 as us,l8 as hs,l9 as fs,la as ms,lb as ps,lc as gs,ld as ys,le as bs,lf as xs,lg as vs,lh as ws,li as ks,lj as Ss,lk as Cs,ad as Ns,ll as Es,lm as js,eH as _s,ln as Is,lo as As,lp as Ts,lq as Ms,lr as Ds,ls as Os,lt as Rs,lu as Ps,gg as Ls,lv as Fs,lw as zs,lx as Bs,ly as Us,ft as $s,bH as Vs,gj as Hs,lz as Ws,lA as Gs,lB as qs,lC as Ys,lD as Ks,lE as Js,lF as Xs,bx as Zs,lG as Qs,lH as ei,lI as ti,lJ as ni,eB as ri,bJ as oi,e2 as si,W as ii,lK as ai,lL as li,lM as ci,lN as di,lO as ui,lP as hi,lQ as fi,lR as mi,lS as pi,bL as gi,lT as yi,lU as bi,e3 as xi,lV as vi,dE as wi,lW as ki,e7 as Si,f6 as Ci,lX as Ni,lY as Ei,aO as ji,dF as _i,lZ as Ii,l_ as Ai,bG as Ti,l$ as Mi,f2 as Di,fV as Oi,fZ as Ri,g4 as Pi,g7 as Li,m0 as Fi,m1 as zi,m2 as Bi,m3 as Ui,m4 as $i,m5 as Vi,m6 as Hi,m7 as Wi,m8 as Gi,U as qi,m9 as Yi,V as Ki,ma as Ji,mb as Xi,fa as Zi,mc as Qi,dw as ea,bt as ta,md as na,eZ as ra,me as oa,mf as sa,mg as ia,eG as aa,mh as la,mi as ca,d_ as da,mj as ua,mk as ha,an as fa,ml as ma,ao as pa,dz as ga,mm as ya,mn as ba,eg as xa,mo as va,mp as wa,mq as ka,mr as Sa,ms as Ca,mt as Na,mu as Ea,mv as ja,fR as _a,fP as Ia,fK as Aa,fQ as Ta,mw as Ma,fS as Da,fL as Oa,dQ as Ra,mx as Pa,my as La,am as Fa,mz as za,fu as Ba,E as Ua,mA as $a,mB as Va,mC as Ha,mD as Wa,mE as Ga,mF as qa,mG as Ya,mH as Ka,mI as Ja,mJ as Xa,mK as Za,mL as Qa,fj as el,mM as tl,mN as nl,mO as rl,mP as ol,g6 as sl,mQ as il,mR as al,mS as ll,mT as cl,ak as dl,mU as ul,eX as hl,mV as fl,mW as ml,mX as pl,mY as gl,mZ as yl,m_ as bl,m$ as xl,n0 as vl,C as wl,n1 as kl,n2 as Sl,n3 as Cl,bc as Nl,n4 as El,dO as jl,fM as _l,fN as Il,n5 as Al,n6 as Tl,n7 as Ml,n8 as Dl,n9 as Ol,na as Rl,y as Pl,nb as Ll,dc as Fl,nc as zl,eO as Bl,bu as Ul,br as $l}from"./index-BTHBullW.js";import{G as Vl,M as Hl,c as Wl,L as Gl,g as ql,d as Yl,e as Kl,A as Jl,s as Xl,k as Zl,B as Ql,a as ec,b as tc,Y as nc,f as rc,h as oc,u as sc,C as ic,S as ac,K as lc,i as cc,j as dc,l as uc,m as hc,n as fc,o as mc,p as pc,q as gc,r as yc,t as bc,v as xc,w as vc,P as wc,x as kc,y as Sc,T as Cc}from"./tree-DxEOaINK.js";import{c as Nc,d as Ec,L as jc,P as _c,I as Ic,e as Ac,f as Tc,N as Mc,V as Dc,S as Oc,F as Rc,g as Pc,M as Lc,l as Fc,h as zc,E as Bc,i as Uc,j as $c,k as Vc,m as Hc,n as Wc,o as Gc,p as qc,q as Yc,s as Kc,t as Jc,u as Xc,C as Zc,R as Qc,a as ed,A as td,v as nd,w as rd,O as od,T as sd,x as id,y as ad}from"./useMarimoWebSocket-xQ57O6MQ.js";import{c as ld}from"./_createAggregator-CiiGic_e.js";import{s as cd,i as dd,T as ud,a as hd}from"./transform-DjHZbYKP.js";import{g as fd}from"./timer-DFzT7np-.js";import{i as md}from"./zoom-COrs4lFh.js";import{s as pd}from"./sortBy-MHvTYKSP.js";var gd=ld((function(e,t,n){e[n?0:1].push(t)}),(function(){return[[],[]]}));
3
- /**
4
- * @license lucide-react v0.503.0 - ISC
5
- *
6
- * This source code is licensed under the ISC license.
7
- * See the LICENSE file in the root directory of this source tree.
8
- */const yd=a("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),bd=a("arrow-right-from-line",[["path",{d:"M3 5v14",key:"1nt18q"}],["path",{d:"M21 12H7",key:"13ipq5"}],["path",{d:"m15 18 6-6-6-6",key:"6tx3qv"}]]),xd=a("arrow-right-to-line",[["path",{d:"M17 12H3",key:"8awo09"}],["path",{d:"m11 18 6-6-6-6",key:"8c2y43"}],["path",{d:"M21 5v14",key:"nzette"}]]),vd=a("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),wd=a("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),kd=a("between-horizontal-start",[["rect",{width:"13",height:"7",x:"8",y:"3",rx:"1",key:"pkso9a"}],["path",{d:"m2 9 3 3-3 3",key:"1agib5"}],["rect",{width:"13",height:"7",x:"8",y:"14",rx:"1",key:"1q5fc1"}]]),Sd=a("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),Cd=a("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Nd=a("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Ed=a("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),jd=a("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),_d=a("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Id=a("clipboard-copy",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-2",key:"4jdomd"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v4",key:"3hqy98"}],["path",{d:"M21 14H11",key:"1bme5i"}],["path",{d:"m15 10-4 4 4 4",key:"5dvupr"}]]),Ad=a("clipboard-paste",[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]]),Td=a("cloud-download",[["path",{d:"M12 13v8l-4-4",key:"1f5nwf"}],["path",{d:"m12 21 4-4",key:"1lfcce"}],["path",{d:"M4.393 15.269A7 7 0 1 1 15.71 8h1.79a4.5 4.5 0 0 1 2.436 8.284",key:"ui1hmy"}]]),Md=a("code",[["polyline",{points:"16 18 22 12 16 6",key:"z7tu5w"}],["polyline",{points:"8 6 2 12 8 18",key:"1eg1df"}]]),Dd=a("command",[["path",{d:"M15 6v12a3 3 0 1 0 3-3H6a3 3 0 1 0 3 3V6a3 3 0 1 0-3 3h12a3 3 0 1 0-3-3",key:"11bfej"}]]),Od=a("copy-minus",[["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]),Rd=a("diamond-plus",[["path",{d:"M12 8v8",key:"napkw2"}],["path",{d:"M2.7 10.3a2.41 2.41 0 0 0 0 3.41l7.59 7.59a2.41 2.41 0 0 0 3.41 0l7.59-7.59a2.41 2.41 0 0 0 0-3.41L13.7 2.71a2.41 2.41 0 0 0-3.41 0z",key:"1ey20j"}],["path",{d:"M8 12h8",key:"1wcyev"}]]),Pd=a("ellipsis-vertical",[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]]),Ld=a("eraser",[["path",{d:"m7 21-4.3-4.3c-1-1-1-2.5 0-3.4l9.6-9.6c1-1 2.5-1 3.4 0l5.6 5.6c1 1 1 2.5 0 3.4L13 21",key:"182aya"}],["path",{d:"M22 21H7",key:"t4ddhn"}],["path",{d:"m5 11 9 9",key:"1mo9qw"}]]),Fd=a("fast-forward",[["polygon",{points:"13 19 22 12 13 5 13 19",key:"587y9g"}],["polygon",{points:"2 19 11 12 2 5 2 19",key:"3pweh0"}]]),zd=a("file-pen",[["path",{d:"M12.5 22H18a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v9.5",key:"1couwa"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M13.378 15.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z",key:"1y4qbx"}]]),Bd=a("file-plus-2",[["path",{d:"M4 22h14a2 2 0 0 0 2-2V7l-5-5H6a2 2 0 0 0-2 2v4",key:"1pf5j1"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}],["path",{d:"M3 15h6",key:"4e2qda"}],["path",{d:"M6 12v6",key:"1u72j0"}]]),Ud=a("files",[["path",{d:"M20 7h-3a2 2 0 0 1-2-2V2",key:"x099mo"}],["path",{d:"M9 18a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h7l4 4v10a2 2 0 0 1-2 2Z",key:"18t6ie"}],["path",{d:"M3 7.6v12.8A1.6 1.6 0 0 0 4.6 22h9.8",key:"1nja0z"}]]),$d=a("folder-plus",[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]]),Vd=a("folder-tree",[["path",{d:"M20 10a1 1 0 0 0 1-1V6a1 1 0 0 0-1-1h-2.5a1 1 0 0 1-.8-.4l-.9-1.2A1 1 0 0 0 15 3h-2a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"hod4my"}],["path",{d:"M20 21a1 1 0 0 0 1-1v-3a1 1 0 0 0-1-1h-2.9a1 1 0 0 1-.88-.55l-.42-.85a1 1 0 0 0-.92-.6H13a1 1 0 0 0-1 1v5a1 1 0 0 0 1 1Z",key:"w4yl2u"}],["path",{d:"M3 5a2 2 0 0 0 2 2h3",key:"f2jnh7"}],["path",{d:"M3 3v13a2 2 0 0 0 2 2h3",key:"k8epm1"}]]),Hd=a("grip-vertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),Wd=a("hard-drive-download",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m16 6-4 4-4-4",key:"6wukr"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",key:"w68u3i"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M10 18h.01",key:"h775k"}]]),Gd=a("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),qd=a("house",[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"1d0kgt"}]]),Yd=a("key-round",[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]]),Kd=a("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]),Jd=a("keyboard",[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]]),Xd=a("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]),Zd=a("list",[["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 18h.01",key:"1tta3j"}],["path",{d:"M3 6h.01",key:"1rqtza"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 18h13",key:"1lx6n3"}],["path",{d:"M8 6h13",key:"ik3vkj"}]]),Qd=a("map-pin",[["path",{d:"M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0",key:"1r0f0z"}],["circle",{cx:"12",cy:"10",r:"3",key:"ilqhr7"}]]),eu=a("memory-stick",[["path",{d:"M6 19v-3",key:"1nvgqn"}],["path",{d:"M10 19v-3",key:"iu8nkm"}],["path",{d:"M14 19v-3",key:"kcehxu"}],["path",{d:"M18 19v-3",key:"1vh91z"}],["path",{d:"M8 11V9",key:"63erz4"}],["path",{d:"M16 11V9",key:"fru6f3"}],["path",{d:"M12 11V9",key:"ha00sb"}],["path",{d:"M2 15h20",key:"16ne18"}],["path",{d:"M2 7a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v1.1a2 2 0 0 0 0 3.837V17a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-5.1a2 2 0 0 0 0-3.837Z",key:"lhddv3"}]]),tu=a("message-circle-question",[["path",{d:"M7.9 20A9 9 0 1 0 4 16.1L2 22Z",key:"vv11sd"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]),nu=a("microchip",[["path",{d:"M18 12h2",key:"quuxs7"}],["path",{d:"M18 16h2",key:"zsn3lv"}],["path",{d:"M18 20h2",key:"9x5y9y"}],["path",{d:"M18 4h2",key:"1luxfb"}],["path",{d:"M18 8h2",key:"nxqzg"}],["path",{d:"M4 12h2",key:"1ltxp0"}],["path",{d:"M4 16h2",key:"8a5zha"}],["path",{d:"M4 20h2",key:"27dk57"}],["path",{d:"M4 4h2",key:"10groj"}],["path",{d:"M4 8h2",key:"18vq6w"}],["path",{d:"M8 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2h-1.5c-.276 0-.494.227-.562.495a2 2 0 0 1-3.876 0C9.994 2.227 9.776 2 9.5 2z",key:"1681fp"}]]),ru=a("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]),ou=a("octagon-alert",[["path",{d:"M12 16h.01",key:"1drbdi"}],["path",{d:"M12 8v4",key:"1got3b"}],["path",{d:"M15.312 2a2 2 0 0 1 1.414.586l4.688 4.688A2 2 0 0 1 22 8.688v6.624a2 2 0 0 1-.586 1.414l-4.688 4.688a2 2 0 0 1-1.414.586H8.688a2 2 0 0 1-1.414-.586l-4.688-4.688A2 2 0 0 1 2 15.312V8.688a2 2 0 0 1 .586-1.414l4.688-4.688A2 2 0 0 1 8.688 2z",key:"1fd625"}]]),su=a("package-check",[["path",{d:"m16 16 2 2 4-4",key:"gfu2re"}],["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}]]),iu=a("package-x",[["path",{d:"M21 10V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l2-1.14",key:"e7tb2h"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["line",{x1:"12",x2:"12",y1:"22",y2:"12",key:"a4e8g8"}],["path",{d:"m17 13 5 5m-5 0 5-5",key:"im3w4b"}]]),au=a("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),lu=a("party-popper",[["path",{d:"M5.8 11.3 2 22l10.7-3.79",key:"gwxi1d"}],["path",{d:"M4 3h.01",key:"1vcuye"}],["path",{d:"M22 8h.01",key:"1mrtc2"}],["path",{d:"M15 2h.01",key:"1cjtqr"}],["path",{d:"M22 20h.01",key:"1mrys2"}],["path",{d:"m22 2-2.24.75a2.9 2.9 0 0 0-1.96 3.12c.1.86-.57 1.63-1.45 1.63h-.38c-.86 0-1.6.6-1.76 1.44L14 10",key:"hbicv8"}],["path",{d:"m22 13-.82-.33c-.86-.34-1.82.2-1.98 1.11c-.11.7-.72 1.22-1.43 1.22H17",key:"1i94pl"}],["path",{d:"m11 2 .33.82c.34.86-.2 1.82-1.11 1.98C9.52 4.9 9 5.52 9 6.23V7",key:"1cofks"}],["path",{d:"M11 13c1.93 1.93 2.83 4.17 2 5-.83.83-3.07-.07-5-2-1.93-1.93-2.83-4.17-2-5 .83-.83 3.07.07 5 2Z",key:"4kbmks"}]]),cu=a("pen-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]]),du=a("presentation",[["path",{d:"M2 3h20",key:"91anmk"}],["path",{d:"M21 3v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V3",key:"2k9sn8"}],["path",{d:"m7 21 5-5 5 5",key:"bip4we"}]]),uu=a("regex",[["path",{d:"M17 3v10",key:"15fgeh"}],["path",{d:"m12.67 5.5 8.66 5",key:"1gpheq"}],["path",{d:"m12.67 10.5 8.66-5",key:"1dkfa6"}],["path",{d:"M9 17a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2a2 2 0 0 0 2 2h2a2 2 0 0 0 2-2v-2z",key:"swwfx4"}]]),hu=a("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]),fu=a("rows-3",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M21 9H3",key:"1338ky"}],["path",{d:"M21 15H3",key:"9uk58r"}]]),mu=a("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]),pu=a("scissors",[["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M8.12 8.12 12 12",key:"1alkpv"}],["path",{d:"M20 4 8.12 15.88",key:"xgtan2"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M14.8 14.8 20 20",key:"ptml3r"}]]),gu=a("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]),yu=a("share-2",[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]]),bu=a("square-code",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]),xu=a("square-dashed-bottom-code",[["path",{d:"M10 9.5 8 12l2 2.5",key:"3mjy60"}],["path",{d:"M14 21h1",key:"v9vybs"}],["path",{d:"m14 9.5 2 2.5-2 2.5",key:"1bir2l"}],["path",{d:"M5 21a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2",key:"as5y1o"}],["path",{d:"M9 21h1",key:"15o7lz"}]]),vu=a("square-equal",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 10h10",key:"1101jm"}],["path",{d:"M7 14h10",key:"1mhdw3"}]]),wu=a("square-m",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),ku=a("square-play",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"m9 8 6 4-6 4Z",key:"f1r3lt"}]]),Su=a("square-plus",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Cu=a("square-power",[["path",{d:"M12 7v4",key:"xawao1"}],["path",{d:"M7.998 9.003a5 5 0 1 0 8-.005",key:"1pek45"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Nu=a("square-terminal",[["path",{d:"m7 11 2-2-2-2",key:"1lz0vl"}],["path",{d:"M11 13h4",key:"1p7l4v"}],["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}]]),Eu=a("text-cursor-input",[["path",{d:"M12 20h-1a2 2 0 0 1-2-2 2 2 0 0 1-2 2H6",key:"1528k5"}],["path",{d:"M13 8h7a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-7",key:"13ksps"}],["path",{d:"M5 16H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h1",key:"1n9rhb"}],["path",{d:"M6 4h1a2 2 0 0 1 2 2 2 2 0 0 1 2-2h1",key:"1mj8rg"}],["path",{d:"M9 6v12",key:"velyjx"}]]),ju=a("text-search",[["path",{d:"M21 6H3",key:"1jwq7v"}],["path",{d:"M10 12H3",key:"1ulcyk"}],["path",{d:"M10 18H3",key:"13769t"}],["circle",{cx:"17",cy:"15",r:"3",key:"1upz2a"}],["path",{d:"m21 19-1.9-1.9",key:"dwi7p8"}]]),_u=a("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]),Iu=a("view",[["path",{d:"M21 17v2a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-2",key:"mrq65r"}],["path",{d:"M21 7V5a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v2",key:"be3xqs"}],["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["path",{d:"M18.944 12.33a1 1 0 0 0 0-.66 7.5 7.5 0 0 0-13.888 0 1 1 0 0 0 0 .66 7.5 7.5 0 0 0 13.888 0",key:"11ak4c"}]]),Au=a("whole-word",[["circle",{cx:"7",cy:"12",r:"3",key:"12clwm"}],["path",{d:"M10 9v6",key:"17i7lo"}],["circle",{cx:"17",cy:"12",r:"3",key:"gl7c2s"}],["path",{d:"M14 7v8",key:"dl84cr"}],["path",{d:"M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1",key:"lt2kga"}]]),Tu=a("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]),Mu=a("zap-off",[["path",{d:"M10.513 4.856 13.12 2.17a.5.5 0 0 1 .86.46l-1.377 4.317",key:"193nxd"}],["path",{d:"M15.656 10H20a1 1 0 0 1 .78 1.63l-1.72 1.773",key:"27a7lr"}],["path",{d:"M16.273 16.273 10.88 21.83a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14H4a1 1 0 0 1-.78-1.63l4.507-4.643",key:"1e0qe9"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]]),Du=a("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]);const Ou=l.createContext({}),Ru=l.forwardRef((function(e,t){[e,t]=f(e,t,Ou);let{toolbarProps:n}=function(e,t){const{"aria-label":n,"aria-labelledby":r,orientation:o="horizontal"}=e;let[s,i]=l.useState(!1);c((()=>{var e;i(!(!t.current||!(null===(e=t.current.parentElement)||void 0===e?void 0:e.closest('[role="toolbar"]'))))}));const{direction:a}=d(),f="rtl"===a&&"horizontal"===o;let m=h(t);const p=l.useRef(null);return{toolbarProps:{...u(e,{labelable:!0}),role:s?"group":"toolbar","aria-orientation":o,"aria-label":n,"aria-labelledby":null==n?r:void 0,onKeyDownCapture:s?void 0:e=>{if(e.currentTarget.contains(e.target)){if("horizontal"===o&&"ArrowRight"===e.key||"vertical"===o&&"ArrowDown"===e.key)f?m.focusPrevious():m.focusNext();else{if(!("horizontal"===o&&"ArrowLeft"===e.key||"vertical"===o&&"ArrowUp"===e.key))return"Tab"===e.key?(e.stopPropagation(),p.current=document.activeElement,void(e.shiftKey?m.focusFirst():m.focusLast())):void 0;f?m.focusNext():m.focusPrevious()}e.stopPropagation(),e.preventDefault()}},onFocusCapture:s?void 0:e=>{var n,r;p.current&&!e.currentTarget.contains(e.relatedTarget)&&(null===(n=t.current)||void 0===n?void 0:n.contains(e.target))&&(null===(r=p.current)||void 0===r||r.focus(),p.current=null)},onBlurCapture:s?void 0:e=>{e.currentTarget.contains(e.relatedTarget)||p.current||(p.current=e.target)}}}}(e,t),r=m({...e,values:{orientation:e.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),o=u(e);return delete o.id,p.createElement("div",{...g(n,o),...r,ref:t,slot:e.slot||void 0,"data-orientation":e.orientation||"horizontal"},r.children)}));function Pu(e,t){const n=+y(e)-+y(t);return n<0?-1:n>0?1:n}function Lu(e,t){const n=y(e,null==t?void 0:t.in);return+function(e,t){const n=y(e,null==t?void 0:t.in);return n.setHours(23,59,59,999),n}(n,t)==+function(e,t){const n=y(e,null==t?void 0:t.in),r=n.getMonth();return n.setFullYear(n.getFullYear(),r+1,0),n.setHours(23,59,59,999),n}(n,t)}function Fu(e,t,n){const[r,o,s]=x(null==n?void 0:n.in,e,e,t),i=Pu(o,s),a=Math.abs(function(e,t,n){const[r,o]=x(null==n?void 0:n.in,e,t);return 12*(r.getFullYear()-o.getFullYear())+(r.getMonth()-o.getMonth())}(o,s));if(a<1)return 0;1===o.getMonth()&&o.getDate()>27&&o.setDate(30),o.setMonth(o.getMonth()-i*a);let l=Pu(o,s)===-i;Lu(r)&&1===a&&1===Pu(r,s)&&(l=!1);const c=i*(a-+l);return 0===c?0:c}function zu(e,t,n){const r=function(e,t){return+y(e)-+y(t)}(e,t)/1e3;return(e=>{const t=(0,Math.trunc)(e);return 0===t?0:t})(r)}function Bu(e,t){return function(e,t,n){const r=w(),o=(null==n?void 0:n.locale)??r.locale??k,s=Pu(e,t);if(isNaN(s))throw new RangeError("Invalid time value");const i=Object.assign({},n,{addSuffix:null==n?void 0:n.addSuffix,comparison:s}),[a,l]=x(null==n?void 0:n.in,...s>0?[t,e]:[e,t]),c=zu(l,a),d=(v(l)-v(a))/1e3,u=Math.round((c-d)/60);let h;if(u<2)return 0===u?o.formatDistance("lessThanXMinutes",1,i):o.formatDistance("xMinutes",u,i);if(u<45)return o.formatDistance("xMinutes",u,i);if(u<90)return o.formatDistance("aboutXHours",1,i);if(u<S){const e=Math.round(u/60);return o.formatDistance("aboutXHours",e,i)}if(u<2520)return o.formatDistance("xDays",1,i);if(u<C){const e=Math.round(u/S);return o.formatDistance("xDays",e,i)}if(u<2*C)return h=Math.round(u/C),o.formatDistance("aboutXMonths",h,i);if(h=Fu(l,a),h<12){const e=Math.round(u/C);return o.formatDistance("xMonths",e,i)}{const e=h%12,t=Math.trunc(h/12);return e<3?o.formatDistance("aboutXYears",t,i):e<9?o.formatDistance("overXYears",t,i):o.formatDistance("almostXYears",t+1,i)}}(e,function(e){return b(e,Date.now())}(e),t)}const Uu=()=>{const e=N.c(7),{selectedLayout:t}=Nc(),{setLayoutView:n}=Ec();if(E()&&!j("wasm_layouts"))return null;let r,o,s,i;return e[0]!==n?(r=e=>n(e),e[0]=n,e[1]=r):r=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsx(P,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:_.jsx(L,{placeholder:"Select a view"})}),e[2]=o):o=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=_.jsx(I,{children:_.jsxs(A,{children:[_.jsx(T,{children:"View as"}),jc.map(Wu)]})}),e[3]=s):s=e[3],e[4]!==t||e[5]!==r?(i=_.jsxs(F,{"data-testid":"layout-select",value:t,onValueChange:r,children:[o,s]}),e[4]=t,e[5]=r,e[6]=i):i=e[6],i};function $u(e){const t=Vu(e);return _.jsx(t,{className:"h-4 w-4"})}function Vu(e){switch(e){case"vertical":return Zd;case"grid":return Vl;case"slides":return du;default:return O(e),R}}function Hu(e){return D(e)}function Wu(e){return _.jsx(M,{value:e,children:_.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[$u(e),_.jsx("span",{children:Hu(e)})]})},e)}function Gu(){const e=N.c(7);let t;e[0]===Symbol.for("react.memo_cache_sentinel")?(t=[],e[0]=t):t=e[0];const[n,r]=function(e,t){const n=N.c(10);let r;n[0]!==t||n[1]!==e?(r=new z(e,t),n[0]=t,n[1]=e,n[2]=r):r=n[2];const o=r;let s;n[3]!==o?(s=()=>o.get(),n[3]=o,n[4]=s):s=n[4];const[i,a]=l.useState(s);let c;n[5]!==o?(c=e=>{a(e),o.set(e)},n[5]=o,n[6]=c):c=n[6];const d=c;let u;return n[7]!==d||n[8]!==i?(u=[i,d],n[7]=d,n[8]=i,n[9]=u):u=n[9],u}("marimo:commands",t);let o,s;return e[1]!==n||e[2]!==r?(o=e=>{const t=(o=[e,...n],[...new Set(o)]);var o;r(t.slice(0,3))},e[1]=n,e[2]=r,e[3]=o):o=e[3],e[4]!==n||e[5]!==o?(s={recentCommands:n,addRecentCommand:o},e[4]=n,e[5]=o,e[6]=s):s=e[6],s}function qu(e){return void 0!==e.dropdown}function Yu(e,t=""){return e.flatMap((e=>e.label?qu(e)?Yu(e.dropdown,`${t+e.label} > `):{...e,label:t+e.label}:[]))}const Ku=e=>{const t=N.c(8),{children:n,layerTop:r}=e,o=void 0!==r&&r;let s;t[0]!==n?(s=p.Children.toArray(n),t[0]=n,t[1]=s):s=t[1];const[i,a]=s,l=`second-icon absolute ${o?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let c,d;return t[2]!==a||t[3]!==l?(c=_.jsx("div",{className:l,children:a}),t[2]=a,t[3]=l,t[4]=c):c=t[4],t[5]!==i||t[6]!==c?(d=_.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 Ju(e){const t=N.c(3),n=Zu();let r;t[0]!==e||t[1]!==n?(r=()=>{void 0!==e&&n([e])},t[0]=e,t[1]=n,t[2]=r):r=t[2];return $(r)}function Xu(){const e=N.c(2),t=Zu();let n;e[0]!==t?(n=()=>t(G(W())),e[0]=t,e[1]=n):n=e[1];return $(n)}function Zu(){const e=N.c(2),{prepareForRun:t}=V();let n;e[0]!==t?(n=async e=>{var n;if(0===e.length)return;const{cellHandles:r,cellData:o}=W(),s=[];for(const i of e){const e=null==(n=r[i].current)?void 0:n.editorView;let a;e?("markdown"!==q(e)&&Y(e),a=K(e)):a=o[i].code,s.push(a),t({cellId:i})}await J({cellIds:e,codes:s}).catch(Qu)},e[0]=t,e[1]=n):n=e[1];return $(n)}function Qu(e){X.error(e)}const eh=Z(null),th=Z(!1),nh=Z({chats:[],activeChatId:null}),rh=Z((e=>{const t=e(nh);return t.chats.find((e=>e.id===t.activeChatId))}),((e,t,n)=>{t(nh,(e=>({...e,activeChatId:n})))})),oh=e=>{const t=N.c(7);let n,r;t[0]!==e?(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,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r={capture:!0},t[2]=r):r=t[2],Q(window,"keydown",n,r);const o=e.children??"Undo";let s,i;return t[3]===Symbol.for("react.memo_cache_sentinel")?(s=_.jsx(te,{className:"ml-2",shortcut:"cmd-z"}),t[3]=s):s=t[3],t[4]!==o||t[5]!==e?(i=_.jsxs(ee,{"data-testid":"undo-button",size:"sm",variant:"outline",...e,children:[o," ",s]}),t[4]=o,t[5]=e,t[6]=i):i=t[6],i};function sh(){const e=N.c(3),{deleteCell:t,undoDeleteCell:n}=V();let r;return e[0]!==t||e[1]!==n?(r=e=>{if(ne.get(re))return;const{cellId:r}=e;t({cellId:r}),oe({cellId:r}).catch((()=>{n()}));const{dismiss:o}=se({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:_.jsx(oh,{"data-testid":"undo-delete-button",onClick:()=>{n(),s()}})}),s=o},e[0]=t,e[1]=n,e[2]=r):r=e[2],$(r)}function ih(e,t,n,r=ne){if(t in r.get(ie))return!1;const{cellData:o,cellIds:s}=r.get(ae),i=new RegExp(`import[ \t]+${e}[ \t]+as[ \t]+${t}`,"g");for(const a of s.inOrderIds)if(i.test(o[a].code))return!1;return n(`import ${e} as ${t}`),!0}function ah(e,t,n){return ih("marimo","mo",(r=>{const o=le.create();t({cellId:n??"__end__",before:!1,code:r,lastCodeRun:e?r:void 0,newCellId:o,autoFocus:!1}),e&&J({cellIds:[o],codes:[r]})}))}function lh(){const e=N.c(3),{splitCell:t,undoSplitCell:n}=V();let r;return e[0]!==t||e[1]!==n?(r=e=>{const r=ce(e.cellId);if(!r)return;const o=K(r);t(e);const{dismiss:s}=se({title:"Cell split",action:_.jsx(oh,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...e,snapshot:o}),i()},children:"Undo"})}),i=s},e[0]=t,e[1]=n,e[2]=r):r=e[2],$(r)}function ch(e){const t=N.c(49),{cell:n}=e,{createNewCell:r,updateCellConfig:o,updateCellName:s,moveCell:i,sendToTop:a,sendToBottom:l,addColumnBreakpoint:c,clearCellOutput:d}=V(),u=lh(),h=Ju(null==n?void 0:n.cellId),f=!de(re),m=sh(),{openModal:p}=ue(),g=he(eh),y=de(fe),b=de(me),x=de(pe),v=de(ge);if(!n||x){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0],e}const{cellId:w,config:k,getEditorView:S,name:C,hasOutput:E,hasConsoleOutput:j,status:I}=n;let A;t[1]!==w||t[2]!==k.disabled||t[3]!==o?(A=async()=>{const e={disabled:!k.disabled};await Oe({configs:{[w]:e}}),o({cellId:w,config:e})},t[1]=w,t[2]=k.disabled,t[3]=o,t[4]=A):A=t[4];const T=A;let M;t[5]!==w||t[6]!==k.hide_code||t[7]!==S||t[8]!==o?(M=async()=>{const e={hide_code:!k.hide_code};await Oe({configs:{[w]:e}}),o({cellId:w,config:e});const t=S();t&&(e.hide_code?t.contentDOM.blur():t.focus())},t[5]=w,t[6]=k.hide_code,t[7]=S,t[8]=o,t[9]=M):M=t[9];const D=M;let O,R,P,L,F;if(t[10]===Symbol.for("react.memo_cache_sentinel")?(O=_.jsx(Eu,{size:13,strokeWidth:1.5}),t[10]=O):O=t[10],t[11]!==w||t[12]!==C||t[13]!==p||t[14]!==s?(R=()=>{p(_.jsxs(Re,{children:[_.jsx(Pe,{children:_.jsx(Le,{children:"Rename cell"})}),_.jsxs("div",{className:"flex items-center justify-between",children:[_.jsx(Fe,{htmlFor:"cell-name",children:"Cell name"}),_.jsx(Mc,{placeholder:"cell name",value:C,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),e.stopPropagation(),p(null))},onChange:e=>s({cellId:w,name:e})})]})]}))},t[11]=w,t[12]=C,t[13]=p,t[14]=s,t[15]=R):R=t[15],t[16]!==w||t[17]!==s?(P=e=>s({cellId:w,name:e}),t[16]=w,t[17]=s,t[18]=P):P=t[18],t[19]!==C||t[20]!==P?(L=_.jsx(Mc,{placeholder:"cell name",value:C,onChange:P}),t[19]=C,t[20]=P,t[21]=L):L=t[21],t[22]!==c||t[23]!==y||t[24]!==v||t[25]!==b||t[26]!==f||t[27]!==w||t[28]!==d||t[29]!==k.disabled||t[30]!==k.hide_code||t[31]!==r||t[32]!==m||t[33]!==S||t[34]!==j||t[35]!==E||t[36]!==i||t[37]!==C||t[38]!==h||t[39]!==l||t[40]!==a||t[41]!==g||t[42]!==u||t[43]!==I||t[44]!==R||t[45]!==L||t[46]!==T||t[47]!==D){F=[[{icon:O,label:"Name",disableClick:!0,handle:fh,handleHeadless:R,rightElement:L},{icon:_.jsx(_c,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:"running"===I||"queued"===I||"disabled-transitively"===I||k.disabled,handle:()=>h()},{icon:_.jsx(ye,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!y,handle:()=>{g((e=>(null==e?void 0:e.cellId)===w?null:{cellId:w}))},hotkey:"cell.aiCompletion"},{icon:_.jsx(pu,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>u({cellId:w})},{icon:_.jsx(Ic,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!E,handle:()=>function(e){const t=document.getElementById(B.create(e));t&&(t.classList.add("printing-output"),U(t,"result.png").finally((()=>{t.classList.remove("printing-output")})))}(w)},{icon:_.jsx(xe,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const e=S();e&&be({[w]:e})}},{icon:k.hide_code?_.jsx(ve,{size:13,strokeWidth:1.5}):_.jsx(we,{size:13,strokeWidth:1.5}),label:k.hide_code?"Show code":"Hide code",handle:D,hotkey:"cell.hideCode"},{icon:k.disabled?_.jsx(Mu,{size:13,strokeWidth:1.5}):_.jsx(Du,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:_.jsx(ke,{"data-testid":"cell-disable-switch",checked:!k.disabled,size:"sm",onCheckedChange:T}),handle:T},{icon:_.jsx(Se,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(E||j),handle:()=>{d({cellId:w})}}],[{icon:_.jsx(Hl,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const e=S();e&&(ah(b,r),Ce(e,"markdown",{keepCodeAsIs:!0}))}},{icon:_.jsx(Ne,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const e=S();e&&(ah(b,r),Ce(e,"sql",{keepCodeAsIs:!0}))}},{icon:_.jsx(Wl,{}),label:"Toggle as Python",handle:()=>{const e=S();e&&(ah(b,r),Ee(e,"python",{force:!0}))}}],[{icon:_.jsxs(Ku,{children:[_.jsx(_d,{size:13,strokeWidth:1.5}),_.jsx(je,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>r({cellId:w,before:!0})},{icon:_.jsxs(Ku,{children:[_.jsx(_d,{size:13,strokeWidth:1.5}),_.jsx(_e,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>r({cellId:w,before:!1})},{icon:_.jsx(je,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>i({cellId:w,before:!0})},{icon:_.jsx(_e,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>i({cellId:w,before:!1})},{icon:_.jsx(Ie,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>i({cellId:w,direction:"left"}),hidden:"columns"!==v},{icon:_.jsx(Ae,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>i({cellId:w,direction:"right"}),hidden:"columns"!==v},{icon:_.jsx(Cd,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>a({cellId:w})},{icon:_.jsx(Sd,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>l({cellId:w})},{icon:_.jsx(Te,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:"columns"!==v,handle:()=>c({cellId:w})}],[{icon:_.jsx(Gl,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!Tc(C),tooltip:Tc(C)?void 0:"Only named cells can be linked to",handle:async()=>{await Me(Ac(C)),se({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!f,variant:"danger",icon:_.jsx(De,{size:13,strokeWidth:1.5}),handle:()=>{m({cellId:w})}}]].map(uh).filter(dh),t[22]=c,t[23]=y,t[24]=v,t[25]=b,t[26]=f,t[27]=w,t[28]=d,t[29]=k.disabled,t[30]=k.hide_code,t[31]=r,t[32]=m,t[33]=S,t[34]=j,t[35]=E,t[36]=i,t[37]=C,t[38]=h,t[39]=l,t[40]=a,t[41]=g,t[42]=u,t[43]=I,t[44]=R,t[45]=L,t[46]=T,t[47]=D,t[48]=F}else F=t[48];return F}function dh(e){return e.length>0}function uh(e){return e.filter(hh)}function hh(e){return!e.hidden}function fh(e){null==e||e.stopPropagation(),null==e||e.preventDefault()}const mh=Z(null);function ph(){return de(mh)}const gh=Z((e=>{const t=e(mh);return t?t===ze?null:yh(t,e(ae)):null}));function yh(e,t){var n;const{cellData:r,cellHandles:o,cellRuntime:s}=t,i=r[e],a=s[e],l=null==(n=o[e])?void 0:n.current;if(!i||!l)return null;return{cellId:e,name:i.name,config:i.config,status:a?a.status:"idle",getEditorView:()=>l.editorView,hasOutput:null!=(null==a?void 0:a.output),hasConsoleOutput:null!=(null==a?void 0:a.consoleOutputs)}}function bh(e){return!e.hidden}const xh=Z(!1),vh=()=>{const e=N.c(37),[t,n]=We(xh),r=Yl(),o=de(gh),s=de(Ge);let i;e[0]!==o?(i={cell:o},e[0]=o,e[1]=i):i=e[1];let a=ch(i).flat();a=Yu(a);const l=function(){const e=N.c(45),{theme:t}=Be(),[n,r]=Ue(),[o,s]=$e();let i;e[0]!==r?(i=async e=>{await Ve({config:e}).then((()=>{r(e)}))},e[0]=r,e[1]=i):i=e[1];const a=i;let l;e[2]!==s?(l=async e=>{await He({config:e}).then((()=>{s(e)}))},e[2]=s,e[3]=l):l=e[3];const c=l;let d;if(e[4]!==o||e[5]!==n||e[6]!==c||e[7]!==a||e[8]!==t){let r,s,i;e[10]!==o?(r=e=>e!==o.width,e[10]=o,e[11]=r):r=e[11],e[12]!==o||e[13]!==c?(s=e=>({label:`App config > Set width=${e}`,handle:()=>{c({...o,width:e})}}),e[12]=o,e[13]=c,e[14]=s):s=e[14],e[15]!==n||e[16]!==a||e[17]!==t?(i={label:"Config > Toggle dark mode",handle:()=>{a({...n,display:{...n.display,theme:"dark"===t?"light":"dark"}})}},e[15]=n,e[16]=a,e[17]=t,e[18]=i):i=e[18];const l="vim"===n.keymap.preset;let u,h;e[19]!==n||e[20]!==a?(u=()=>{a({...n,keymap:{...n.keymap,preset:"vim"}})},e[19]=n,e[20]=a,e[21]=u):u=e[21],e[22]!==l||e[23]!==u?(h={label:"Config > Switch keymap to VIM",hidden:l,handle:u},e[22]=l,e[23]=u,e[24]=h):h=e[24];const f="default"===n.keymap.preset;let m,p,g;e[25]!==n||e[26]!==a?(m=()=>{a({...n,keymap:{...n.keymap,preset:"default"}})},e[25]=n,e[26]=a,e[27]=m):m=e[27],e[28]!==m||e[29]!==f?(p={label:"Config > Switch keymap to default (current: VIM)",hidden:f,handle:m},e[28]=m,e[29]=f,e[30]=p):p=e[30],e[31]!==n||e[32]!==a?(g=()=>{a({...n,completion:{...n.completion,copilot:!1}})},e[31]=n,e[32]=a,e[33]=g):g=e[33];const y="github"!==n.completion.copilot;let b,x;e[34]!==g||e[35]!==y?(b={label:"Config > Disable GitHub Copilot",handle:g,hidden:y},e[34]=g,e[35]=y,e[36]=b):b=e[36],e[37]!==n||e[38]!==a?(x=()=>{a({...n,completion:{...n.completion,copilot:"github"}})},e[37]=n,e[38]=a,e[39]=x):x=e[39];const v="github"===n.completion.copilot;let w;e[40]!==x||e[41]!==v?(w={label:"Config > Enable GitHub Copilot",handle:x,hidden:v},e[40]=x,e[41]=v,e[42]=w):w=e[42],d=[...ql().filter(r).map(s),i,h,p,b,w],e[4]=o,e[5]=n,e[6]=c,e[7]=a,e[8]=t,e[9]=d}else d=e[9];const u=d;let h;return e[43]!==u?(h=u.filter(bh),e[43]=u,e[44]=h):h=e[44],h}();let c=Hf();c=[...Yu(c),...Yu(l)];const d=c.filter(wh),u=qe.keyBy(d,kh),{recentCommands:h,addRecentCommand:f}=Gu();let m;e[2]!==h?(m=new Set(h),e[2]=h,e[3]=m):m=e[3];const p=m;let g,y;e[4]!==s||e[5]!==n?(g=e=>{Qe(s.getHotkey("global.commandPalette").key)(e)&&(e.preventDefault(),n(Sh))},e[4]=s,e[5]=n,e[6]=g):g=e[6],Q(document,"keydown",g),e[7]!==f||e[8]!==s||e[9]!==r||e[10]!==n?(y=(e,t)=>{const o=r[e];if(!o)return null;const i=s.getHotkey(e);return _.jsxs(et,{disabled:t.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{o()}))},value:i.name,children:[_.jsxs("span",{children:[i.name,t.tooltip&&_.jsx("span",{className:"ml-2",children:t.tooltip})]}),_.jsx(tt,{children:_.jsx(nt,{shortcut:i.key})})]},e)},e[7]=f,e[8]=s,e[9]=r,e[10]=n,e[11]=y):y=e[11];const b=y;let x;e[12]!==f||e[13]!==s||e[14]!==n?(x=(e,t,r,o)=>{const i=void 0===r?{}:r;return _.jsxs(et,{disabled:i.disabled,onSelect:()=>{f(e),n(!1),requestAnimationFrame((()=>{t()}))},value:e,children:[_.jsxs("span",{children:[e,i.tooltip&&_.jsxs("span",{className:"ml-2",children:["(",i.tooltip,")"]})]}),o&&_.jsx(tt,{children:_.jsx(nt,{shortcut:s.getHotkey(o).key})})]},e)},e[12]=f,e[13]=s,e[14]=n,e[15]=x):x=e[15];const v=x,w=Ze;let k;e[16]===Symbol.for("react.memo_cache_sentinel")?(k=_.jsx(rt,{placeholder:"Type to search..."}),e[16]=k):k=e[16];const S=Xe;let C;e[17]===Symbol.for("react.memo_cache_sentinel")?(C=_.jsx(ot,{children:"No results found."}),e[17]=C):C=e[17];const E=h.length>0&&_.jsxs(_.Fragment,{children:[_.jsx(Ye,{heading:"Recently Used",children:h.map((e=>{const t=u[e];return Ke(e)?b(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip}):t&&!qu(t)?v(t.label,t.handleHeadless||t.handle,{disabled:t.disabled,tooltip:t.tooltip}):null}))}),_.jsx(Je,{})]}),j=Ye,I=s.iterate().map((e=>{if(p.has(e))return null;const t=u[e];return b(e,{disabled:null==t?void 0:t.disabled,tooltip:null==t?void 0:t.tooltip})})),A=d.map((e=>p.has(e.label)?null:v(e.label,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip})));let T;e[18]!==p||e[19]!==v?(T=e=>p.has(e.label)?null:v(`Cell > ${e.label}`,e.handleHeadless||e.handle,{disabled:e.disabled,tooltip:e.tooltip}),e[18]=p,e[19]=v,e[20]=T):T=e[20];const M=a.map(T);let D,O,R;return e[21]!==j||e[22]!==A||e[23]!==M||e[24]!==I?(D=_.jsxs(j,{heading:"Commands",children:[I,A,M]}),e[21]=j,e[22]=A,e[23]=M,e[24]=I,e[25]=D):D=e[25],e[26]!==S||e[27]!==D||e[28]!==C||e[29]!==E?(O=_.jsxs(S,{children:[C,E,D]}),e[26]=S,e[27]=D,e[28]=C,e[29]=E,e[30]=O):O=e[30],e[31]!==w||e[32]!==t||e[33]!==n||e[34]!==O||e[35]!==k?(R=_.jsxs(w,{open:t,onOpenChange:n,children:[k,O]}),e[31]=w,e[32]=t,e[33]=n,e[34]=O,e[35]=k,e[36]=R):R=e[36],R};function wh(e){return!e.hotkey}function kh(e){return e.label}function Sh(e){return!e}const Ch="https://static.marimo.app",Nh=e=>{const t=N.c(24),{onClose:n}=e,[r,o]=l.useState("");let s;s=Math.random().toString(36).slice(2,6);const i=`${r}-${s}`,a=`${Ch}/static/${i}`;let c,d,u,h,f,m,p,g,y,b,x;return t[0]!==n||t[1]!==i?(c=async e=>{e.preventDefault(),n();const t=await st({download:!1,includeCode:!0,files:Dc.INSTANCE.filenames()}),r=se({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${Ch}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:t,path:i})}).catch((()=>{r.dismiss(),se({title:"Error uploading static page",description:_.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",_.jsx("a",{href:it.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})})),r.dismiss(),se({title:"Static page uploaded!",description:_.jsxs("div",{children:["The URL has been copied to your clipboard.",_.jsx("br",{}),"You can share it with anyone."]})})},t[0]=n,t[1]=i,t[2]=c):c=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(Le,{children:"Share static notebook"}),t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=_.jsxs(Pe,{children:[d,_.jsxs(at,{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"," ",_.jsx("a",{href:Ch,target:"_blank",children:Ch}),"."]})]}),t[4]=u):u=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(h=e=>{const t=e.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");o(t)},t[5]=h):h=t[5],t[6]!==r?(f=_.jsx(lt,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:r,placeholder:"Notebook slug",onChange:h,required:!0,autoComplete:"off"}),t[6]=r,t[7]=f):f=t[7],t[8]!==a?(m=_.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:",_.jsxs("div",{className:"flex items-center gap-2",children:[_.jsx(Eh,{text:a}),_.jsx("span",{className:"text-primary",children:a})]})]}),t[8]=a,t[9]=m):m=t[9],t[10]!==f||t[11]!==m?(p=_.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[f,m]}),t[10]=f,t[11]=m,t[12]=p):p=t[12],t[13]!==n?(g=_.jsx(ee,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),t[13]=n,t[14]=g):g=t[14],t[15]!==a?(y=_.jsx(ee,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await Me(a)},children:"Create"}),t[15]=a,t[16]=y):y=t[16],t[17]!==y||t[18]!==g?(b=_.jsxs(ct,{children:[g,y]}),t[17]=y,t[18]=g,t[19]=b):b=t[19],t[20]!==b||t[21]!==c||t[22]!==p?(x=_.jsx(Re,{className:"w-fit",children:_.jsxs("form",{onSubmit:c,children:[u,p,b]})}),t[20]=b,t[21]=c,t[22]=p,t[23]=x):x=t[23],x},Eh=e=>{const t=N.c(8),[n,r]=p.useState(!1);let o;t[0]!==e.text?(o=dt.stopPropagation((async t=>{t.preventDefault(),await Me(e.text),r(!0),setTimeout((()=>r(!1)),2e3)})),t[0]=e.text,t[1]=o):o=t[1];const s=o;let i,a,l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx(ut,{size:14,strokeWidth:1.5}),t[2]=i):i=t[2],t[3]!==s?(a=_.jsx(ee,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:i}),t[3]=s,t[4]=a):a=t[4],t[5]!==n||t[6]!==a?(l=_.jsx(ht,{content:"Copied!",open:n,children:a}),t[5]=n,t[6]=a,t[7]=l):l=t[7],l};function jh(){const e=N.c(3),{openConfirm:t}=ue(),n=he(ft);let r;return e[0]!==t||e[1]!==n?(r=()=>{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:_.jsx(mt,{onClick:async()=>{n({state:pt.CLOSING}),await gt(),yt()},"aria-label":"Confirm Restart",children:"Restart"})})},e[0]=t,e[1]=n,e[2]=r):r=e[2],r}const _h=[{type:"files",Icon:Vd,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:bt,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:Ne,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:ru,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Kl,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:gu,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:xt,tooltip:"Chat with AI",position:"sidebar"},{type:"documentation",Icon:ju,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:vt,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:Jl,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:xu,tooltip:"Snippets",position:"sidebar"},{type:"secrets",Icon:Yd,tooltip:"Secrets",hidden:E(),position:"sidebar"},{type:"scratchpad",Icon:wt,tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:Se,tooltip:"View errors",position:"footer"}];function Ih(){const e=N.c(2),t=he(kt);let n;e[0]!==t?(n=()=>{const e=document.getElementsByClassName("output-area"),n=window.innerHeight||document.documentElement.clientHeight;let r;r=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){r=St.parse(t.parentNode.id);break}}t((e=>({mode:Ct(e.mode),cellAnchor:r}))),requestAnimationFrame((()=>{var e;null!==r&&(null==(e=document.getElementById(St.create(r)))||e.scrollIntoView())}))},e[0]=t,e[1]=n):n=e[1];return n}function Ah(){return _t.string().optional().describe(It.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function Th(){return _t.string().optional().describe(It.of({label:"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"}))}function Mh(){return _t.string().optional().describe(It.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function Dh(){return _t.string().optional().describe(It.of({label:"URI",optionRegex:".*uri.*"}))}function Oh(){return _t.string().nonempty().describe(It.of({label:"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function Rh(){return _t.string().describe(It.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function Ph(){return _t.string().nonempty().describe(It.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function Lh(e){const t=_t.coerce.string().describe(It.of({label:"Port",inputType:"number",placeholder:null==e?void 0:e.toString()})).transform(Number).refine((e=>e>=0&&e<=65535),{message:"Port must be between 0 and 65535"});return void 0!==e?t.default(e.toString()):t}function Fh(){return _t.boolean().default(!1).describe(It.of({label:"Read Only"}))}const zh=_t.object({type:_t.literal("postgres"),host:Oh(),port:Lh(5432).optional(),database:Rh(),username:Ph(),password:Ah(),ssl:_t.boolean().default(!1).describe(It.of({label:"Use SSL"}))}).describe(It.of({direction:"two-columns"})),Bh=_t.object({type:_t.literal("mysql"),host:Oh(),port:Lh(3306),database:Rh(),username:Ph(),password:Ah(),ssl:_t.boolean().default(!1).describe(It.of({label:"Use SSL"}))}).describe(It.of({direction:"two-columns"})),Uh=_t.object({type:_t.literal("sqlite"),database:Rh().describe(It.of({label:"Database Path"}))}).describe(It.of({direction:"two-columns"})),$h=_t.object({type:_t.literal("duckdb"),database:Rh().describe(It.of({label:"Database Path"})),read_only:Fh()}).describe(It.of({direction:"two-columns"})),Vh=_t.object({type:_t.literal("motherduck"),database:Rh().default("my_db").describe(It.of({label:"Database Name"})),token:Th()}).describe(It.of({direction:"two-columns"})),Hh=_t.object({type:_t.literal("snowflake"),account:_t.string().nonempty().describe(It.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:_t.string().optional().describe(It.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:Rh(),schema:_t.string().optional().describe(It.of({label:"Schema",optionRegex:".*snowflake.*"})),username:Ph(),password:Ah(),role:_t.string().optional().describe(It.of({label:"Role"}))}).describe(It.of({direction:"two-columns"})),Wh=_t.object({type:_t.literal("bigquery"),project:_t.string().nonempty().describe(It.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:_t.string().nonempty().describe(It.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:_t.string().describe(It.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(It.of({direction:"two-columns"})),Gh=_t.object({type:_t.literal("clickhouse_connect"),host:Oh(),port:Lh(8123).optional(),username:Ph(),password:Ah(),secure:_t.boolean().default(!1).describe(It.of({label:"Use HTTPs"}))}).describe(It.of({direction:"two-columns"})),qh=_t.object({type:_t.literal("timeplus"),host:Oh().default("localhost"),port:Lh(8123).optional(),username:Ph().default("default"),password:Ah().default("")}).describe(It.of({direction:"two-columns"})),Yh=_t.object({type:_t.literal("chdb"),database:Rh().describe(It.of({label:"Database Path"})),read_only:Fh()}).describe(It.of({direction:"two-columns"})),Kh=_t.object({type:_t.literal("trino"),host:Oh(),port:Lh(8080),database:Rh(),schema:_t.string().describe(It.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"})).optional(),username:Ph(),password:Ah(),async_support:_t.boolean().default(!1).describe(It.of({label:"Async Support"}))}).describe(It.of({direction:"two-columns"})),Jh=_t.object({type:_t.literal("iceberg"),name:_t.string().describe(It.of({label:"Catalog Name"})),catalog:_t.discriminatedUnion("type",[_t.object({type:_t.literal("REST"),warehouse:Mh(),uri:_t.string().optional().describe(It.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:Th()}),_t.object({type:_t.literal("SQL"),warehouse:Mh(),uri:_t.string().optional().describe(It.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),_t.object({type:_t.literal("Hive"),warehouse:Mh(),uri:Dh()}),_t.object({type:_t.literal("Glue"),warehouse:Mh(),uri:Dh()}),_t.object({type:_t.literal("DynamoDB"),"dynamodb.profile-name":_t.string().optional().describe(It.of({label:"Profile Name"})),"dynamodb.region":_t.string().optional().describe(It.of({label:"Region"})),"dynamodb.access-key-id":_t.string().optional().describe(It.of({label:"Access Key ID"})),"dynamodb.secret-access-key":_t.string().optional().describe(It.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":_t.string().optional().describe(It.of({label:"Session Token",inputType:"password"}))})]).describe(It.of({special:"tabs"}))}),Xh=_t.object({type:_t.literal("datafusion"),sessionContext:_t.boolean().optional().describe(It.of({label:"Use Session Context"}))}),Zh=_t.object({type:_t.literal("pyspark"),host:Oh().optional(),port:Lh().optional()}),Qh=_t.discriminatedUnion("type",[zh,Bh,Uh,$h,Vh,Hh,Wh,Gh,qh,Yh,Kh,Jh,Xh,Zh]),ef="env:";function tf(e){return"string"==typeof e&&e.startsWith(ef)}function nf(e){return`${ef}${e}`}const rf={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck"};class of{constructor(e,t,n){this.connection=void 0,this.orm=void 0,this.secrets=void 0,this.connection=e,this.orm=t,this.secrets=n}get imports(){const e=new Set(this.generateImports());switch(this.orm){case"sqlalchemy":e.add("import sqlalchemy");break;case"sqlmodel":e.add("import sqlmodel");break;case"duckdb":e.add("import duckdb")}return e}}class sf{constructor(){this.secrets={}}get imports(){return 0===Object.keys(this.secrets).length?new Set:new Set(["import os"])}print(e,t,n){if(e=`_${e}`,tf(t)){const r=t.replace(ef,""),o=n?`os.environ.get("${r}", "${n}")`:`os.environ.get("${r}")`;return this.secrets[e]=o,e}if(null!=n){const r=`os.environ.get("${t}", "${n}")`;return this.secrets[e]=r,e}return"number"==typeof t||"number"==typeof t?`${t}`:"boolean"==typeof t?kf(t):t?`"${t}"`:""}printInFString(e,t,n){if(void 0===t)return"";if("number"==typeof t)return`${t}`;if("boolean"==typeof t)return kf(t);const r=this.print(e,t,n);return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):`{${r}}`}printPassword(e,t,n){const r=n?this.printInFString.bind(this):this.print.bind(this);return tf(e)?r("password",e):r("password",t,e)}getSecrets(){return this.secrets}formatSecrets(){return 0===Object.keys(this.secrets).length?"":Object.entries(this.secrets).map((([e,t])=>`${e} = ${t}`)).join("\n")}}class af extends of{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",t=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0),n=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),o=this.secrets.printInFString("port",this.connection.port),s=this.secrets.printInFString("database",this.connection.database);return Tt(`\n DATABASE_URL = f"postgresql://${n}:${t}@${r}:${o}/${s}"\n engine = ${this.orm}.create_engine(DATABASE_URL${e})\n `)}}class lf extends of{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":"",t=this.secrets.printPassword(this.connection.password,"MYSQL_PASSWORD",!0),n=this.secrets.printInFString("database",this.connection.database),r=this.secrets.printInFString("username",this.connection.username),o=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port);return Tt(`\n DATABASE_URL = f"mysql+pymysql://${r}:${t}@${o}:${s}/${n}"\n engine = ${this.orm}.create_engine(DATABASE_URL${e})\n `)}}class cf extends of{generateImports(){return[]}generateConnectionCode(){const e=this.connection.database?this.secrets.printInFString("database",this.connection.database):"",t=e.startsWith("{")&&e.endsWith("}")?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return Tt(`\n ${t}\n engine = ${this.orm}.create_engine(DATABASE_URL)\n `)}}class df extends of{generateImports(){return["from snowflake.sqlalchemy import URL"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"SNOWFLAKE_PASSWORD",!1),t={account:this.secrets.print("account",this.connection.account),user:this.secrets.print("user",this.connection.username),database:this.secrets.print("database",this.connection.database),warehouse:this.connection.warehouse?this.secrets.print("warehouse",this.connection.warehouse):void 0,schema:this.connection.schema?this.secrets.print("schema",this.connection.schema):void 0,role:this.connection.role?this.secrets.print("role",this.connection.role):void 0,password:e};return Tt(`\n engine = ${this.orm}.create_engine(\n URL(\n${Sf(t,(e=>` ${e}`))},\n )\n )\n `)}}class uf extends of{generateImports(){return["import json"]}generateConnectionCode(){const e=this.secrets.printInFString("project",this.connection.project),t=this.secrets.printInFString("dataset",this.connection.dataset);return Tt(`\n credentials = json.loads("""${this.connection.credentials_json}""")\n engine = ${this.orm}.create_engine(f"bigquery://${e}/${t}", credentials_info=credentials)\n `)}}class hf extends of{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database||":memory:");return Tt(`\n DATABASE_URL = "${e}"\n engine = ${this.orm}.connect(DATABASE_URL, read_only=${kf(this.connection.read_only)})\n `)}}class ff extends of{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database);if(!this.connection.token)return Tt(`\n conn = duckdb.connect("md:${e}")\n `);const t=this.secrets.printPassword(this.connection.token,"MOTHERDUCK_TOKEN",!1);return Tt(`\n conn = duckdb.connect("md:${e}", config={"motherduck_token": ${t}})\n `)}}class mf extends of{generateImports(){return["import clickhouse_connect"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"CLICKHOUSE_PASSWORD",!1),t={host:this.secrets.print("host",this.connection.host),user:this.secrets.print("user",this.connection.username),secure:this.secrets.print("secure",this.connection.secure),port:this.connection.port?this.secrets.print("port",this.connection.port):void 0,password:this.connection.password?e:void 0};return Tt(`\n engine = ${this.orm}.get_client(\n${Sf(t,(e=>` ${e}`))},\n )\n `)}}class pf extends of{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"TIMEPLUS_PASSWORD",!0),t=this.secrets.printInFString("username",this.connection.username),n=this.secrets.printInFString("host",this.connection.host),r=this.secrets.printInFString("port",this.connection.port);return Tt(`\n DATABASE_URL = f"timeplus://${t}:${e}@${n}:${r}"\n engine = ${this.orm}.create_engine(DATABASE_URL)\n `)}}class gf extends of{generateImports(){return["import chdb"]}generateConnectionCode(){const e=this.secrets.print("database",this.connection.database)||'""';return Tt(`\n engine = ${this.orm}.connect(${e}, read_only=${kf(this.connection.read_only)})\n `)}}class yf extends of{generateImports(){return this.connection.async_support?["import aiotrino"]:["import trino.sqlalchemy"]}generateConnectionCode(){const e=this.connection.async_support?"aiotrino":"trino",t=this.connection.schema?`/${this.connection.schema}`:"",n=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),o=this.secrets.printInFString("port",this.connection.port),s=this.secrets.printInFString("database",this.connection.database),i=this.secrets.printPassword(this.connection.password,"TRINO_PASSWORD",!0);return Tt(`\n engine = ${this.orm}.create_engine(f"${e}://${n}:${i}@${r}:${o}/${s}${t}")\n `)}}class bf extends of{generateImports(){switch(this.connection.catalog.type){case"REST":return["from pyiceberg.catalog.rest import RestCatalog"];case"SQL":return["from pyiceberg.catalog.sql import SqlCatalog"];case"Hive":return["from pyiceberg.catalog.hive import HiveCatalog"];case"Glue":return["from pyiceberg.catalog.glue import GlueCatalog"];case"DynamoDB":return["from pyiceberg.catalog.dynamodb import DynamoDBCatalog"];default:At(this.connection.catalog)}}generateConnectionCode(){let e={...this.connection.catalog};e=Object.fromEntries(Object.entries(e).filter((([e,t])=>null!=t&&""!==t&&"type"!==e)));for(const[s,i]of Object.entries(e))tf(i)?e[s]=this.secrets.print(s,i):"string"==typeof i&&(e[s]=`"${i}"`);const t=(n=e,r=e=>` ${e}`,Object.entries(n).filter((([,e])=>null!=e&&""!==e)).map((([e,t])=>{const n=`"${e}"`;return r("boolean"==typeof t?`${n}: ${kf(t)}`:`${n}: ${t}`)})).join(",\n"));var n,r;const o=`"${this.connection.name}"`;switch(this.connection.catalog.type){case"REST":return Tt(`\n catalog = RestCatalog(\n ${o},\n **{\n${t}\n },\n )\n `);case"SQL":return Tt(`\n catalog = SqlCatalog(\n ${o},\n **{\n${t}\n },\n )\n `);case"Hive":return Tt(`\n catalog = HiveCatalog(\n ${o},\n **{\n${t}\n },\n )\n `);case"Glue":return Tt(`\n catalog = GlueCatalog(\n ${o},\n **{\n${t}\n },\n )\n `);case"DynamoDB":return Tt(`\n catalog = DynamoDBCatalog(\n ${o},\n **{\n${t}\n },\n )\n `);default:At(this.connection.catalog)}}}class xf extends of{generateImports(){return["import ibis","from datafusion import SessionContext"]}generateConnectionCode(){return this.connection.sessionContext?Tt('\n ctx = SessionContext()\n # Sample table\n _ = ctx.from_pydict({"a": [1, 2, 3]}, "my_table")\n\n con = ibis.datafusion.connect(ctx)\n '):Tt("\n con = ibis.datafusion.connect()\n ")}}class vf extends of{generateImports(){return["import ibis","from pyspark.sql import SparkSession"]}generateConnectionCode(){if(this.connection.host||this.connection.port){const e=this.secrets.printInFString("host",this.connection.host),t=this.secrets.printInFString("port",this.connection.port);return Tt(`\n session = SparkSession.builder.remote(f"sc://${e}:${t}").getOrCreate()\n con = ibis.pyspark.connect(session)\n `)}return Tt("\n con = ibis.pyspark.connect()\n ")}}class wf{constructor(){this.secrets=new sf}createGenerator(e,t){switch(e.type){case"postgres":return new af(e,t,this.secrets);case"mysql":return new lf(e,t,this.secrets);case"sqlite":return new cf(e,t,this.secrets);case"snowflake":return new df(e,t,this.secrets);case"bigquery":return new uf(e,t,this.secrets);case"duckdb":return new hf(e,t,this.secrets);case"motherduck":return new ff(e,t,this.secrets);case"clickhouse_connect":return new mf(e,t,this.secrets);case"timeplus":return new pf(e,t,this.secrets);case"chdb":return new gf(e,t,this.secrets);case"trino":return new yf(e,t,this.secrets);case"iceberg":return new bf(e,t,this.secrets);case"datafusion":return new xf(e,t,this.secrets);case"pyspark":return new vf(e,t,this.secrets);default:At(e)}}}function kf(e){return e.toString().charAt(0).toUpperCase()+e.toString().slice(1)}function Sf(e,t){return Object.entries(e).filter((([,e])=>null!=e&&""!==e)).map((([e,n])=>t("boolean"==typeof n?`${e}=${kf(n)}`:`${e}=${n}`))).join(",\n")}function Cf(e){return e.sort(((e,t)=>"env"===e.provider?1:"env"===t.provider?-1:0))}const Nf=e=>{const t=N.c(42),{providerNames:n,onClose:r,onSuccess:o}=e,[s,i]=p.useState(""),[a,l]=p.useState(""),[c,d]=p.useState(n[0]);let u;t[0]!==s||t[1]!==c||t[2]!==o||t[3]!==a?(u=async e=>{if(e.preventDefault(),c)if(s&&a&&c)try{await Dt({key:s,value:a,provider:"dotenv",name:c}),se({title:"Secret created",description:"The secret has been created successfully."}),o(s)}catch{se({title:"Error",description:"Failed to create secret. Please try again.",variant:"danger"})}else se({title:"Error",description:"Please fill in all fields.",variant:"danger"});else se({title:"Error",description:"No location selected for the secret.",variant:"danger"})},t[0]=s,t[1]=c,t[2]=o,t[3]=a,t[4]=u):u=t[4];const h=u;let f,m,g,y,b,x,v,w,k,S,C,E,j,A,T,M;t[5]===Symbol.for("react.memo_cache_sentinel")?(f=_.jsxs(Pe,{children:[_.jsx(Le,{children:"Add Secret"}),_.jsx(at,{children:"Add a new secret to your environment variables."})]}),t[5]=f):f=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(m=_.jsx(Fe,{htmlFor:"key",children:"Key"}),t[6]=m):m=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(g=e=>{i(e.target.value.replaceAll(/\W/g,"_"))},t[7]=g):g=t[7],t[8]!==s?(y=_.jsxs("div",{className:"grid gap-2",children:[m,_.jsx(lt,{id:"key",value:s,onChange:g,placeholder:"MY_SECRET_KEY",required:!0})]}),t[8]=s,t[9]=y):y=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(b=_.jsx(Fe,{htmlFor:"value",children:"Value"}),t[10]=b):b=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(x=e=>l(e.target.value),t[11]=x):x=t[11],t[12]!==a?(v=_.jsx(lt,{id:"value",type:"text",value:a,onChange:x,required:!0,autoComplete:"off"}),t[12]=a,t[13]=v):v=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(w=window.location.href.startsWith("http://")&&_.jsx(Mt,{children:"Note: You are sending this key over http."}),t[14]=w):w=t[14],t[15]!==v?(k=_.jsxs("div",{className:"grid gap-2",children:[b,v,w]}),t[15]=v,t[16]=k):k=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(S=_.jsx(Fe,{htmlFor:"location",children:"Location"}),t[17]=S):S=t[17],t[18]!==n.length?(C=0===n.length&&_.jsx("p",{className:"text-sm text-muted-foreground",children:"No dotenv locations configured."}),t[18]=n.length,t[19]=C):C=t[19],t[20]!==c||t[21]!==n?(E=n.length>0&&_.jsxs(F,{value:c,onValueChange:e=>d(e),children:[_.jsx(P,{children:_.jsx(L,{placeholder:"Select a provider"})}),_.jsx(I,{children:n.map(Ef)})]}),t[20]=c,t[21]=n,t[22]=E):E=t[22],t[23]===Symbol.for("react.memo_cache_sentinel")?(j=_.jsxs(Mt,{children:["You can configure the location by setting the"," ",_.jsx(Ot,{href:"https://links.marimo.app/dotenv",children:"dotenv configuration"}),"."]}),t[23]=j):j=t[23],t[24]!==C||t[25]!==E?(A=_.jsxs("div",{className:"grid gap-2",children:[S,C,E,j]}),t[24]=C,t[25]=E,t[26]=A):A=t[26],t[27]!==k||t[28]!==A||t[29]!==y?(T=_.jsxs("div",{className:"grid gap-4 py-4",children:[y,k,A]}),t[27]=k,t[28]=A,t[29]=y,t[30]=T):T=t[30],t[31]!==r?(M=_.jsx(ee,{type:"button",variant:"outline",onClick:r,children:"Cancel"}),t[31]=r,t[32]=M):M=t[32];const D=!s||!a||!c;let O,R,z;return t[33]!==D?(O=_.jsx(ee,{type:"submit",disabled:D,children:"Add Secret"}),t[33]=D,t[34]=O):O=t[34],t[35]!==M||t[36]!==O?(R=_.jsxs(ct,{children:[M,O]}),t[35]=M,t[36]=O,t[37]=R):R=t[37],t[38]!==h||t[39]!==T||t[40]!==R?(z=_.jsx(Re,{children:_.jsxs("form",{onSubmit:h,children:[f,T,R]})}),t[38]=h,t[39]=T,t[40]=R,t[41]=z):z=t[41],z};function Ef(e){return _.jsx(M,{value:e,children:e},e)}const jf=l.createContext({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Rt.NOOP}),_f=e=>{const t=N.c(14),{children:n}=e;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],t[0]=r):r=t[0];const{data:o,loading:s,error:i,reload:a}=Pt(Mf,r);let l,c,d,u;return t[1]!==(null==o?void 0:o.secretKeys)?(l=(null==o?void 0:o.secretKeys)||[],t[1]=null==o?void 0:o.secretKeys,t[2]=l):l=t[2],t[3]!==(null==o?void 0:o.providerNames)?(c=(null==o?void 0:o.providerNames)||[],t[3]=null==o?void 0:o.providerNames,t[4]=c):c=t[4],t[5]!==i||t[6]!==s||t[7]!==a||t[8]!==l||t[9]!==c?(d={secretKeys:l,providerNames:c,loading:s,error:i,refreshSecrets:a},t[5]=i,t[6]=s,t[7]=a,t[8]=l,t[9]=c,t[10]=d):d=t[10],t[11]!==n||t[12]!==d?(u=_.jsx(jf.Provider,{value:d,children:n}),t[11]=n,t[12]=d,t[13]=u):u=t[13],u};function If(e){return"env"!==e.provider}function Af(e){return e.name}function Tf(e){return e.keys}async function Mf(){const e=await Oc.request({}),t=Cf(e.secrets).filter(If).map(Af);return{secretKeys:e.secrets.flatMap(Tf).sort(),providerNames:t}}const Df=[{name:"PostgreSQL",schema:zh,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:Bh,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:Uh,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:$h,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:Vh,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:Hh,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Gh,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:qh,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Wh,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:Yh,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:Kh,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:Xh,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:Zh,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}}],Of=[{name:"Iceberg",schema:Jh,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],Rf=e=>{const t=N.c(14),{onSelect:n}=e;let r;t[0]!==n?(r=e=>{const{name:t,schema:r,color:o,logo:s}=e;return _.jsxs("button",{type:"button",className:"py-3 flex flex-col items-center justify-center gap-1 transition-all hover:scale-105 hover:brightness-110 rounded shadow-smSolid hover:shadow-mdSolid",style:{backgroundColor:o},onClick:()=>n(r),children:[_.jsx(en,{name:s,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),_.jsx("span",{className:"text-white font-medium text-lg",children:t})]},t)},t[0]=n,t[1]=r):r=t[1];const o=r;let s,i,a,l,c,d;return t[2]!==o?(s=Df.map(o),t[2]=o,t[3]=s):s=t[3],t[4]!==s?(i=_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),t[4]=s,t[5]=i):i=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsxs("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",_.jsx("hr",{className:"flex-1"})]}),t[6]=a):a=t[6],t[7]!==o?(l=Of.map(o),t[7]=o,t[8]=l):l=t[8],t[9]!==l?(c=_.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:l}),t[9]=l,t[10]=c):c=t[10],t[11]!==i||t[12]!==c?(d=_.jsxs(_.Fragment,{children:[i,a,c]}),t[11]=i,t[12]=c,t[13]=d):d=t[13],d},Pf=[{isMatch:e=>{if(e instanceof _t.ZodString||e instanceof _t.ZodNumber){const{optionRegex:t}=It.parse(e._def.description||"");return Boolean(t)}return!1},Component:({schema:e,form:t,path:n})=>{const{secretKeys:r,providerNames:o,refreshSecrets:s}=l.useContext(jf),{openModal:i,closeModal:a}=ue(),{label:c,description:d,optionRegex:u=""}=It.parse(e._def.description||""),[h,f]=gd(r,(e=>new RegExp(u,"i").test(e)));return _.jsx(Lt,{control:t.control,name:n,render:({field:t})=>_.jsxs(Ft,{children:[_.jsx(zt,{children:c}),_.jsx(Bt,{children:d}),_.jsx(Ut,{children:_.jsxs("div",{className:"flex gap-2",children:[e instanceof _t.ZodString?_.jsx(lt,{...t,value:t.value,onChange:t.onChange,className:$t("flex-1")}):_.jsx(Vt,{...t,value:t.value,onChange:t.onChange,className:"flex-1"}),_.jsxs(Ht,{children:[_.jsx(Wt,{asChild:!0,children:_.jsx(ee,{variant:"outline",size:"icon",className:$t(tf(t.value)&&"bg-accent"),children:_.jsx(Kd,{className:"h-3 w-3"})})}),_.jsxs(Gt,{align:"end",className:"max-h-60 overflow-y-auto",children:[_.jsxs(qt,{onSelect:()=>{i(_.jsx(Nf,{providerNames:o,onSuccess:e=>{s(),t.onChange(nf(e)),a()},onClose:a}))},children:[_.jsx(_d,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),h.length>0&&_.jsxs(_.Fragment,{children:[_.jsx(Yt,{}),_.jsx(Kt,{children:"Recommended"})]}),h.map((e=>_.jsx(qt,{onSelect:()=>t.onChange(nf(e)),children:e},e))),f.length>0&&_.jsx(Yt,{}),f.map((e=>_.jsx(qt,{onSelect:()=>t.onChange(nf(e)),children:e},e)))]})]})]})}),_.jsx(Jt,{})]})})}}],Lf=e=>{var t;const n=N.c(49),{schema:r,onSubmit:o,onBack:s}=e;let i,a,c;n[0]!==r?(i=Xt(r),n[0]=r,n[1]=i):i=n[1],n[2]!==r?(a=Zt(r),n[2]=r,n[3]=a):a=n[3],n[4]!==i||n[5]!==a?(c={defaultValues:i,resolver:a,reValidateMode:"onChange"},n[4]=i,n[5]=a,n[6]=c):c=n[6];const d=Qt(c),u=null==(t=[...Df,...Of].find((e=>e.schema===r)))?void 0:t.connectionLibraries,[h,f]=l.useState((null==u?void 0:u.preferred)??"sqlalchemy"),{createNewCell:m}=V(),p=ph();let g;n[7]!==m||n[8]!==p?(g=e=>{m({code:e,before:!1,cellId:p??"__end__",skipIfCodeExists:!0,autoFocus:!0})},n[7]=m,n[8]=p,n[9]=g):g=n[9];const y=g;let b;n[10]!==y||n[11]!==o||n[12]!==h?(b=e=>{y(function(e,t){if(!(t in rf))throw new Error(`Unsupported library: ${t}`);Qh.parse(e);const n=new wf,r=n.createGenerator(e,t),o=r.generateConnectionCode(),s=n.secrets,i=[...new Set([...s.imports,...r.imports])].sort();i.push("");const a=s.formatSecrets();return a&&i.push(a),i.push(o.trim()),i.join("\n")}(e,h)),o()},n[10]=y,n[11]=o,n[12]=h,n[13]=b):b=n[13];const x=b;let v;n[14]!==d||n[15]!==x?(v=d.handleSubmit(x),n[14]=d,n[15]=x,n[16]=v):v=n[16];let w,k;n[17]===Symbol.for("react.memo_cache_sentinel")?(w=_.jsx(tn,{}),n[17]=w):w=n[17],n[18]!==d||n[19]!==r?(k=_.jsx(_f,{children:_.jsx(nn,{schema:r,form:d,renderers:Pf,children:w})}),n[18]=d,n[19]=r,n[20]=k):k=n[20];let S;n[21]!==s?(S=_.jsx(ee,{type:"button",variant:"outline",onClick:s,children:"Back"}),n[21]=s,n[22]=S):S=n[22];const C=!d.formState.isValid;let E,j;n[23]!==C?(E=_.jsx(ee,{type:"submit",disabled:C,children:"Add"}),n[23]=C,n[24]=E):E=n[24],n[25]!==S||n[26]!==E?(j=_.jsxs("div",{className:"flex gap-2",children:[S,E]}),n[25]=S,n[26]=E,n[27]=j):j=n[27];const T=F;let M,D;n[28]===Symbol.for("react.memo_cache_sentinel")?(M=e=>f(e),n[28]=M):M=n[28],n[29]===Symbol.for("react.memo_cache_sentinel")?(D=_.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[_.jsx(P,{children:_.jsx(L,{placeholder:"Select a library"})}),_.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),n[29]=D):D=n[29];const O=I,R=A,z=null==u?void 0:u.libraries.map(Uf);let B,U,$,H,W;return n[30]!==R||n[31]!==z?(B=_.jsx(R,{children:z}),n[30]=R,n[31]=z,n[32]=B):B=n[32],n[33]!==O||n[34]!==B?(U=_.jsx(O,{children:B}),n[33]=O,n[34]=B,n[35]=U):U=n[35],n[36]!==T||n[37]!==h||n[38]!==M||n[39]!==D||n[40]!==U?($=_.jsx("div",{children:_.jsxs(T,{value:h,onValueChange:M,children:[D,U]})}),n[36]=T,n[37]=h,n[38]=M,n[39]=D,n[40]=U,n[41]=$):$=n[41],n[42]!==j||n[43]!==$?(H=_.jsxs("div",{className:"flex gap-2 justify-between",children:[j,$]}),n[42]=j,n[43]=$,n[44]=H):H=n[44],n[45]!==H||n[46]!==v||n[47]!==k?(W=_.jsxs("form",{onSubmit:v,className:"space-y-4",children:[k,H]}),n[45]=H,n[46]=v,n[47]=k,n[48]=W):W=n[48],W},Ff=e=>{const t=N.c(5),{onSubmit:n}=e,[r,o]=l.useState(null);if(!r){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(Rf,{onSelect:o}),t[0]=e):e=t[0],e}let s,i;return t[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>o(null),t[1]=s):s=t[1],t[2]!==n||t[3]!==r?(i=_.jsx(Lf,{schema:r,onSubmit:n,onBack:s}),t[2]=n,t[3]=r,t[4]=i):i=t[4],i},zf=e=>{const t=N.c(6),{children:n}=e,[r,o]=l.useState(!1);let s,i,a;return t[0]!==n?(s=_.jsx(rn,{asChild:!0,children:n}),t[0]=n,t[1]=s):s=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx(Bf,{onClose:()=>o(!1)}),t[2]=i):i=t[2],t[3]!==r||t[4]!==s?(a=_.jsxs(on,{open:r,onOpenChange:o,children:[s,i]}),t[3]=r,t[4]=s,t[5]=a):a=t[5],a},Bf=e=>{const t=N.c(4),{onClose:n}=e;let r,o,s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(Le,{children:"Add Connection"}),t[0]=r):r=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsxs(Pe,{className:"mb-4",children:[r,_.jsxs(at,{children:["Connect to your database or data catalog to query data directly from your notebook. Learn more about how to connect to your database in our"," ",_.jsx(Ot,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),t[1]=o):o=t[1],t[2]!==n?(s=_.jsxs(Re,{className:"max-h-[75vh] overflow-y-auto",children:[o,_.jsx(Ff,{onSubmit:()=>n()})]}),t[2]=n,t[3]=s):s=t[3],s};function Uf(e){return _.jsx(M,{value:e,children:rf[e]},e)}const $f=()=>{const e=N.c(2),{updateCellConfig:t}=V();let n;return e[0]!==t?(n=async()=>{const e=new sn,n=W(),r=n.cellIds.inOrderIds,o={};for(const t of r){if(void 0===n.cellData[t])continue;const{code:r,config:s}=n.cellData[t];s.hide_code||e.isSupported(r)&&(o[t]={hide_code:!0})}const s=qe.entries(o);if(0!==s.length){await Oe({configs:o});for(const[e,n]of s)t({cellId:e,config:n})}},e[0]=t,e[1]=n):n=e[1],n},Vf=e=>{null==e||e.preventDefault(),null==e||e.stopPropagation()};function Hf(){const e=N.c(150),t=an(),{openModal:n,closeModal:r}=ue(),{toggleApplication:o}=ln(),{selectedPanel:s}=cn(),[i]=We(kt),a=de(pe),l=$f(),{updateCellConfig:c,undoDeleteCell:d,clearAllCellOutputs:u,upsertSetupCell:h,collapseAllCells:f,expandAllCells:m}=V(),p=jh(),g=Xu(),y=function(e){const t=N.c(4),{openPrompt:n,closeModal:r}=ue();let o;return t[0]!==r||t[1]!==n||t[2]!==e?(o=()=>{if(!e)return null;const t=Nt.guessDeliminator(e),o=Et.basename(e);n({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${o}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:n=>{const o=t.join(Et.dirname(e),n);jt({source:e,destination:o}).then((()=>{r(),se({title:"Notebook copied",description:"A copy of the notebook has been created."}),window.open(`/?file=${o}`,"_blank")}))}})},t[0]=r,t[1]=n,t[2]=e,t[3]=o):o=t[3],o}(t),b=he(xh),x=he(Xl),v=he(Zl),w=de(dn),k=de(un),S=de(hn),{selectedLayout:C}=Nc(),{setLayoutView:j}=Ec(),I=Ih(),A=hm;let T,M,O,R,P,L,F,z,B,U,$,H,q;e[0]===Symbol.for("react.memo_cache_sentinel")?(T=_.jsx(yu,{size:14,strokeWidth:1.5}),e[0]=T):T=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(M=_.jsx(yn,{size:14,strokeWidth:1.5}),e[1]=M):M=e[1],e[2]!==r||e[3]!==n?(O={icon:M,label:"Publish HTML to web",handle:async()=>{n(_.jsx(Nh,{onClose:r}))}},e[2]=r,e[3]=n,e[4]=O):O=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(R={icon:_.jsx(Gl,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",handle:um},e[5]=R):R=e[5],e[6]!==O?(P={icon:T,label:"Share",handle:Vf,dropdown:[O,R]},e[6]=O,e[7]=P):P=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(L=_.jsx(bn,{size:14,strokeWidth:1.5}),e[8]=L):L=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(F=_.jsx(Rc,{size:14,strokeWidth:1.5}),e[9]=F):F=e[9],e[10]!==t?(z={icon:F,label:"Download as HTML",handle:async()=>{t?await Pc({filename:t,includeCode:!0}):se({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},e[10]=t,e[11]=z):z=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(B=_.jsx(Rc,{size:14,strokeWidth:1.5}),e[12]=B):B=e[12],e[13]!==t?(U={icon:B,label:"Download as HTML (exclude code)",handle:async()=>{t?await Pc({filename:t,includeCode:!1}):se({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},e[13]=t,e[14]=U):U=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?($={icon:_.jsx(Hl,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:dm},H={icon:_.jsx(Md,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:cm},e[15]=$,e[16]=H):($=e[15],H=e[16]),e[17]===Symbol.for("react.memo_cache_sentinel")?(q=_.jsx(Ic,{size:14,strokeWidth:1.5}),e[17]=q):q=e[17];const Y="present"!==i.mode;let K,J,X;e[18]!==i.mode?(K="present"===i.mode?void 0:_.jsxs("span",{children:["Only available in app view. ",_.jsx("br",{}),"Toggle with: ",fn("global.hideCode",!1)]}),e[18]=i.mode,e[19]=K):K=e[19],e[20]!==Y||e[21]!==K?(J={divider:!0,icon:q,label:"Download as PNG",disabled:Y,tooltip:K,handle:lm},e[20]=Y,e[21]=K,e[22]=J):J=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(X=_.jsx(xn,{size:14,strokeWidth:1.5}),e[23]=X):X=e[23];const Z="present"!==i.mode;let Q,ee,te,ne,re,oe,ie,ae,le,ce,fe,me,ge,ye,be;if(e[24]!==i.mode?(Q="present"===i.mode?void 0:_.jsxs("span",{children:["Only available in app view. ",_.jsx("br",{}),"Toggle with: ",fn("global.hideCode",!1)]}),e[24]=i.mode,e[25]=Q):Q=e[25],e[26]!==Z||e[27]!==Q?(ee={icon:X,label:"Download as PDF",disabled:Z,tooltip:Q,handle:im},e[26]=Z,e[27]=Q,e[28]=ee):ee=e[28],e[29]!==J||e[30]!==ee||e[31]!==z||e[32]!==U?(te={icon:L,label:"Download",handle:Vf,dropdown:[z,U,$,H,J,ee]},e[29]=J,e[30]=ee,e[31]=z,e[32]=U,e[33]=te):te=e[33],e[34]===Symbol.for("react.memo_cache_sentinel")?(ne=_.jsx(au,{size:14,strokeWidth:1.5}),e[34]=ne):ne=e[34],e[35]!==s||e[36]!==o?(re=_h.flatMap((e=>{const{type:t,Icon:n,hidden:r}=e;return r?[]:{label:D(t),rightElement:A(s===t),icon:_.jsx(n,{size:14,strokeWidth:1.5}),handle:()=>o(t)}})),e[35]=s,e[36]=o,e[37]=re):re=e[37],e[38]!==re?(oe={divider:!0,icon:ne,label:"Helper panel",handle:Vf,dropdown:re},e[38]=re,e[39]=oe):oe=e[39],e[40]===Symbol.for("react.memo_cache_sentinel")?(ie=_.jsx(du,{size:14,strokeWidth:1.5}),e[40]=ie):ie=e[40],e[41]!==i.mode?(ae="present"===i.mode?_.jsx(mn,{size:14,strokeWidth:1.5}):_.jsx(Xd,{size:14,strokeWidth:1.5}),e[41]=i.mode,e[42]=ae):ae=e[42],e[43]!==I?(le=()=>{I()},e[43]=I,e[44]=le):le=e[44],e[45]!==ae||e[46]!==le?(ce={icon:ae,label:"Toggle app view",hotkey:"global.hideCode",handle:le},e[45]=ae,e[46]=le,e[47]=ce):ce=e[47],e[48]!==C||e[49]!==j||e[50]!==ce||e[51]!==I||e[52]!==i.mode){let t;e[54]!==C||e[55]!==j||e[56]!==I||e[57]!==i.mode?(t=(e,t)=>{const n=Vu(e);return{divider:0===t,label:Hu(e),icon:_.jsx(n,{size:14,strokeWidth:1.5}),rightElement:_.jsx("div",{className:"w-8 flex justify-end",children:C===e&&_.jsx(pn,{size:14})}),handle:()=>{j(e),"edit"===i.mode&&I()}}},e[54]=C,e[55]=j,e[56]=I,e[57]=i.mode,e[58]=t):t=e[58],fe={icon:ie,label:"Present as",handle:Vf,dropdown:[ce,...jc.map(t)]},e[48]=C,e[49]=j,e[50]=ce,e[51]=I,e[52]=i.mode,e[53]=fe}else fe=e[53];e[59]===Symbol.for("react.memo_cache_sentinel")?(me=_.jsx(Ud,{size:14,strokeWidth:1.5}),e[59]=me):me=e[59],e[60]!==t?(ge=!t||E(),e[60]=t,e[61]=ge):ge=e[61],e[62]!==y||e[63]!==ge?(ye={icon:me,label:"Create notebook copy",hidden:ge,handle:y},e[62]=y,e[63]=ge,e[64]=ye):ye=e[64],e[65]===Symbol.for("react.memo_cache_sentinel")?(be=_.jsx(Id,{size:14,strokeWidth:1.5}),e[65]=be):be=e[65];const xe=!t;let ve,ke;e[66]!==xe?(ve={icon:be,label:"Copy code to clipboard",hidden:xe,handle:sm},e[66]=xe,e[67]=ve):ve=e[67],e[68]===Symbol.for("react.memo_cache_sentinel")?(ke=_.jsx(Du,{size:14,strokeWidth:1.5}),e[68]=ke):ke=e[68];const Ce=!w||a;let Ee,je,_e;e[69]!==c?(Ee=async()=>{const e=W(),t=vn(e),n=qe.fromEntries(t.map(om));await Oe({configs:n});for(const r of t)c({cellId:r,config:{disabled:!1}})},e[69]=c,e[70]=Ee):Ee=e[70],e[71]!==Ce||e[72]!==Ee?(je={icon:ke,label:"Enable all cells",hidden:Ce,handle:Ee},e[71]=Ce,e[72]=Ee,e[73]=je):je=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(_e=_.jsx(Mu,{size:14,strokeWidth:1.5}),e[74]=_e):_e=e[74];const Ie=!k||a;let Ae,Te,Me,De,Re,Pe,Le,Fe,ze,Be,Ue,$e,Ve,He,Ge;e[75]!==c?(Ae=async()=>{const e=W(),t=G(e),n=qe.fromEntries(t.map(rm));await Oe({configs:n});for(const r of t)c({cellId:r,config:{disabled:!0}})},e[75]=c,e[76]=Ae):Ae=e[76],e[77]!==Ie||e[78]!==Ae?(Te={icon:_e,label:"Disable all cells",hidden:Ie,handle:Ae},e[77]=Ie,e[78]=Ae,e[79]=Te):Te=e[79],e[80]===Symbol.for("react.memo_cache_sentinel")?(Me=_.jsx(we,{size:14,strokeWidth:1.5}),e[80]=Me):Me=e[80],e[81]!==l?(De={icon:Me,label:"Hide all markdown code",handle:l},e[81]=l,e[82]=De):De=e[82],e[83]===Symbol.for("react.memo_cache_sentinel")?(Re=_.jsx(jd,{size:14,strokeWidth:1.5}),e[83]=Re):Re=e[83],e[84]!==f?(Pe={icon:Re,label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:f},e[84]=f,e[85]=Pe):Pe=e[85],e[86]===Symbol.for("react.memo_cache_sentinel")?(Le=_.jsx(Ed,{size:14,strokeWidth:1.5}),e[86]=Le):Le=e[86],e[87]!==m?(Fe={icon:Le,label:"Expand all sections",hotkey:"global.expandAllSections",handle:m},e[87]=m,e[88]=Fe):Fe=e[88],e[89]===Symbol.for("react.memo_cache_sentinel")?(ze=_.jsx(Rd,{size:14,strokeWidth:1.5}),e[89]=ze):ze=e[89],e[90]!==h?(Be={icon:ze,label:"Add setup cell",handle:()=>{h({code:"# Initialization code that runs before all other cells"})}},e[90]=h,e[91]=Be):Be=e[91],e[92]===Symbol.for("react.memo_cache_sentinel")?(Ue=_.jsx(Se,{size:14,strokeWidth:1.5}),e[92]=Ue):Ue=e[92],e[93]!==u?($e={icon:Ue,label:"Clear all outputs",handle:()=>{u()}},e[93]=u,e[94]=$e):$e=e[94],e[95]===Symbol.for("react.memo_cache_sentinel")?(Ve=_.jsx(Fd,{size:14,strokeWidth:1.5}),e[95]=Ve):Ve=e[95],e[96]!==g?(He={icon:Ve,label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{g()}},e[96]=g,e[97]=He):He=e[97],e[98]===Symbol.for("react.memo_cache_sentinel")?(Ge=_.jsx(_u,{size:14,strokeWidth:1.5}),e[98]=Ge):Ge=e[98];const Ye=!S||a;let Ke,Je,Xe,Ze,Qe,et,tt,nt,rt,ot,st,it,at,lt,ct,dt,ut,ht,ft,mt;e[99]!==d?(Ke=()=>{d()},e[99]=d,e[100]=Ke):Ke=e[100],e[101]!==Ye||e[102]!==Ke?(Je={icon:Ge,label:"Undo cell deletion",hidden:Ye,handle:Ke},e[101]=Ye,e[102]=Ke,e[103]=Je):Je=e[103],e[104]===Symbol.for("react.memo_cache_sentinel")?(Xe=_.jsx(Ne,{size:14,strokeWidth:1.5}),e[104]=Xe):Xe=e[104],e[105]!==r||e[106]!==n?(Ze={icon:Xe,label:"Add database connection",handle:()=>{n(_.jsx(Bf,{onClose:r}))}},e[105]=r,e[106]=n,e[107]=Ze):Ze=e[107],e[108]===Symbol.for("react.memo_cache_sentinel")?(Qe=_.jsx(Dd,{size:14,strokeWidth:1.5}),e[108]=Qe):Qe=e[108],e[109]!==b?(et={divider:!0,icon:Qe,label:"Command palette",hotkey:"global.commandPalette",handle:()=>b(nm)},e[109]=b,e[110]=et):et=e[110],e[111]===Symbol.for("react.memo_cache_sentinel")?(tt=_.jsx(wn,{size:14,strokeWidth:1.5}),e[111]=tt):tt=e[111],e[112]!==x?(nt={icon:tt,label:"User settings",handle:()=>x(tm)},e[112]=x,e[113]=nt):nt=e[113],e[114]===Symbol.for("react.memo_cache_sentinel")?(rt=_.jsx(Jd,{size:14,strokeWidth:1.5}),e[114]=rt):rt=e[114],e[115]!==v?(ot={icon:rt,label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>v(em)},e[115]=v,e[116]=ot):ot=e[116],e[117]===Symbol.for("react.memo_cache_sentinel")?(st={icon:_.jsx(Ql,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:Qf},it=_.jsx(kn,{size:14,strokeWidth:1.5}),e[117]=st,e[118]=it):(st=e[117],it=e[118]),e[119]===Symbol.for("react.memo_cache_sentinel")?(at={icon:it,label:"Resources",handle:Vf,dropdown:[{icon:_.jsx(Ql,{size:14,strokeWidth:1.5}),label:"Documentation",handle:Zf},{icon:_.jsx(ec,{size:14,strokeWidth:1.5}),label:"GitHub",handle:Xf},{icon:_.jsx(tc,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:Jf},{icon:_.jsx(nc,{size:14,strokeWidth:1.5}),label:"YouTube",handle:Kf},{icon:_.jsx(vt,{size:14,strokeWidth:1.5}),label:"Changelog",handle:Yf}]},e[119]=at):at=e[119],e[120]===Symbol.for("react.memo_cache_sentinel")?(lt=_.jsx(qd,{size:14,strokeWidth:1.5}),e[120]=lt):lt=e[120],e[121]===Symbol.for("react.memo_cache_sentinel")?(ct={divider:!0,icon:lt,label:"Return home",hidden:!location.search.includes("file"),handle:qf},dt=_.jsx(Bd,{size:14,strokeWidth:1.5}),e[121]=ct,e[122]=dt):(ct=e[121],dt=e[122]),e[123]===Symbol.for("react.memo_cache_sentinel")?(ut={icon:dt,label:"New notebook",hidden:!location.search.includes("file"),handle:Gf},ht=_.jsx(Cu,{size:14,strokeWidth:1.5}),e[123]=ut,e[124]=ht):(ut=e[123],ht=e[124]),e[125]!==p?(ft={icon:ht,label:"Restart kernel",variant:"danger",handle:p},e[125]=p,e[126]=ft):ft=e[126],e[127]!==te||e[128]!==oe||e[129]!==fe||e[130]!==ye||e[131]!==ve||e[132]!==je||e[133]!==P||e[134]!==Te||e[135]!==De||e[136]!==Pe||e[137]!==Fe||e[138]!==Be||e[139]!==$e||e[140]!==He||e[141]!==Je||e[142]!==Ze||e[143]!==et||e[144]!==nt||e[145]!==ot||e[146]!==ft?(mt=[P,te,oe,fe,ye,ve,je,Te,De,Pe,Fe,Be,$e,He,Je,Ze,et,nt,ot,st,at,ct,ut,ft],e[127]=te,e[128]=oe,e[129]=fe,e[130]=ye,e[131]=ve,e[132]=je,e[133]=P,e[134]=Te,e[135]=De,e[136]=Pe,e[137]=Fe,e[138]=Be,e[139]=$e,e[140]=He,e[141]=Je,e[142]=Ze,e[143]=et,e[144]=nt,e[145]=ot,e[146]=ft,e[147]=mt):mt=e[147];const pt=mt;let gt;return e[148]!==pt?(gt=pt.filter(Wf),e[148]=pt,e[149]=gt):gt=e[149],gt}function Wf(e){return!e.hidden}function Gf(){const e=gn();window.open(e,"_blank")}function qf(){const e=document.baseURI.split("?")[0];window.open(e,"_self")}function Yf(){window.open(it.releasesPage,"_blank")}function Kf(){window.open(it.youtube,"_blank")}function Jf(){window.open(it.discordLink,"_blank")}function Xf(){window.open(it.githubPage,"_blank")}function Zf(){window.open(it.docsPage,"_blank")}function Qf(){window.open(it.docsPage,"_blank")}function em(e){return!e}function tm(e){return!e}function nm(e){return!e}function rm(e){return[e,{disabled:!0}]}function om(e){return[e,{disabled:!1}]}async function sm(){const e=await Sn();await Me(e.contents),se({title:"Copied",description:"Code copied to clipboard."})}async function im(){const e=new Event("export-beforeprint"),t=new Event("export-afterprint");window.dispatchEvent(e),setTimeout(am,0),setTimeout((()=>window.dispatchEvent(t)),0)}function am(){return window.print()}async function lm(){const e=document.getElementById("App");e&&await U(e,document.title)}async function cm(){const e=await Sn();Cn(new Blob([e.contents],{type:"text/plain"}),Nn.toPY(document.title))}async function dm(){const e=await En({download:!1});Cn(new Blob([e],{type:"text/plain"}),Nn.toMarkdown(document.title))}async function um(){const e=await Sn(),t=jn({code:e.contents});await Me(t),se({title:"Copied",description:"Link copied to clipboard."})}function hm(e){return _.jsx("div",{className:"w-8 flex justify-end",children:e&&_.jsx(pn,{size:14})})}const fm=()=>{const e=N.c(10),t=Hf();let n;e[0]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(rc,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",color:"hint-green",children:_.jsx(Lc,{strokeWidth:1.8})}),e[0]=n):n=e[0];const r=n,o=mm;let s;e[1]===Symbol.for("react.memo_cache_sentinel")?(s=e=>{const t=_.jsx(qt,{variant:e.variant,disabled:e.disabled,onSelect:t=>e.handle(t),"data-testid":`notebook-menu-dropdown-${e.label}`,children:o(e)},e.label);return e.tooltip?_.jsx(ht,{content:e.tooltip,side:"left",delayDuration:100,children:_.jsx("span",{children:t})},e.label):t},e[1]=s):s=e[1];const i=s;let a,l,c,d,u;if(e[2]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsx(Wt,{asChild:!0,children:r}),e[2]=a):a=e[2],e[3]!==t){let n;e[5]===Symbol.for("react.memo_cache_sentinel")?(n=e=>e.hidden?null:e.dropdown?_.jsxs(In,{children:[_.jsx(An,{"data-testid":`notebook-menu-dropdown-${e.label}`,children:o(e)}),_.jsx(Tn,{children:_.jsx(Mn,{children:e.dropdown.map((e=>_.jsxs(p.Fragment,{children:[e.divider&&_.jsx(Yt,{}),i(e)]},e.label)))})})]},e.label):_.jsxs(p.Fragment,{children:[e.divider&&_.jsx(Yt,{}),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=_.jsx(Yt,{}),e[6]=c):c=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:_.jsxs("span",{children:["Version: ",_n()]})}),e[7]=d):d=e[7],e[8]!==l?(u=_.jsxs(Ht,{modal:!1,children:[a,_.jsxs(Gt,{align:"end",className:"no-print w-[240px]",children:[l,c,d]})]}),e[8]=l,e[9]=u):u=e[9],u};function mm(e){return _.jsxs(_.Fragment,{children:[e.icon&&_.jsx("span",{className:"flex-0 mr-2",children:e.icon}),_.jsx("span",{className:"flex-1",children:e.labelElement||e.label}),e.hotkey&&_.jsx(Dn,{shortcut:e.hotkey,className:"ml-4"}),e.rightElement]})}const pm=On({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 gm(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?(ne.set(pm,{type:"setFind",find:n}),ne.set(pm,{type:"setCurrentView",view:e,range:{from:t.from,to:t.to}})):ne.set(pm,{type:"setCurrentView",view:e,range:{from:0,to:0}})}return ne.get(pm).isOpen?(ne.set(pm,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame((()=>{ne.set(pm,{type:"setIsOpen",isOpen:!0})})),!0):(ne.set(pm,{type:"setIsOpen",isOpen:!0}),!0)}function ym(){return!!ne.get(pm).isOpen&&(ne.set(pm,{type:"setIsOpen",isOpen:!1}),!0)}function bm(e){return Rn("create"in e,'Expected query to have a "create" method'),e}function xm(e){return()=>{const t=ne.get(pm),n=new Pn({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord});return!!n.valid&&e({query:bm(n).create(),search:n})}}const vm=e=>xm((({query:t})=>{const n=Ln(),r=ne.get(pm).currentView||{view:n[0],range:{from:0,to:0}};let o=r.range.to;"prev"===e&&(n.reverse(),o=r.range.from);let s=n.indexOf(r.view);s<0&&(s=0);const i=[...n,...n].slice(s);for(const a of i){const n="next"===e?t.nextMatch(a.state,0,o??0):t.prevMatch(a.state,o??a.state.doc.length,a.state.doc.length);if(!n){o=null,a.dispatch({selection:Fn.single(0)});continue}const r=Fn.single(n.from,n.to);return a.dispatch({selection:r,effects:[zn.scrollIntoView(r.main,{y:"center"})],userEvent:"select.search"}),ne.set(pm,{type:"setCurrentView",view:a,range:{from:n.from,to:n.to}}),n}return!1})),wm=vm("next"),km=vm("prev"),Sm=xm((({query:e})=>{var t;const n=Ln(),r=[];for(const o of n){if(o.state.readOnly)continue;const n=null==(t=e.matchAll(o.state,1e9))?void 0:t.map((t=>{const{from:n,to:r}=t;return{from:n,to:r,insert:e.getReplacement(t)}}));if(!n||0===n.length)continue;const s=o.state.doc.toString();r.push((()=>{o.dispatch({changes:[{from:0,to:o.state.doc.length,insert:s}],userEvent:"input.replace.all"})})),o.dispatch({changes:n,userEvent:"input.replace.all"})}return()=>{for(const e of r)e()}})),Cm=xm((({query:e})=>{const t=Ln(),n=ne.get(pm).currentView||{view:t[0],range:{from:0}};let r=n.range.from,o=t.indexOf(n.view);o<0&&(o=0);const s=[...t,...t].slice(o);for(const i of s){const t=e.nextMatch(i.state,0,r??0);if(!t){r=null,i.dispatch({selection:Fn.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"}),wm()}return!1})),Nm=xm((({query:e})=>{const t=Ln();let n=0;const r=new Map;for(const o of t){const t=e.matchAll(o.state,1e9)||[];for(const e of t){const{from:t,to:s}=e,i=r.get(o)||new Map;i.set(`${t}:${s}`,n++),r.set(o,i)}}return{count:n,position:r}})),Em=Hn.define();function jm(){const e=Ln();for(const t of e)t.state.readOnly||t.dispatch({effects:Em.of(new Pn({search:""}))})}const _m=Un.define({create(){const e=ne.get(pm);return bm(new Pn({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(Em)&&(e=bm(n.value).create());return e}}),Im=$n.mark({class:"cm-searchMatch"}),Am=$n.mark({class:"cm-searchMatch cm-searchMatch-selected"}),Tm=Bn.fromClass(class{constructor(e){this.view=e,this.decorations=void 0,this.decorations=this.highlight(e.state.field(_m))}update(e){const t=e.state.field(_m);(t!==e.startState.field(_m)||e.docChanged||e.selectionSet||e.viewportChanged)&&(this.decorations=this.highlight(t))}highlight(e){if(!e.spec.valid)return $n.none;const{view:t}=this,n=new Vn,r=t.visibleRanges,o=r.length;for(let s=0;s<o;s++){let{to:i}=r[s];const{from:a}=r[s];for(;s<o-1&&i>r[s+1].from-500;)i=r[++s].to;e.highlight(t.state,a,i,((e,r)=>{const o=t.state.selection.ranges.some((t=>t.from===e&&t.to===r));n.add(e,r,o?Am:Im)}))}return n.finish()}},{decorations:e=>e.decorations}),Mm=zn.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"}}),Dm=()=>{var e;const t=N.c(102),[n,r]=l.useState(!1),[o,s]=We(pm),[i,a]=l.useState(),c=l.useRef(null),d=de(Ge);let u,h;t[0]!==n||t[1]!==o.isOpen?(u=()=>(!n||!o.isOpen)&&gm(),t[0]=n,t[1]=o.isOpen,t[2]=u):u=t[2],oc("cell.findAndReplace",u),t[3]===Symbol.for("react.memo_cache_sentinel")?(h=()=>{const e=Nm();a(!1===e?void 0:e)},t[3]=h):h=t[3];const f=h;let m,p,g,y;if(t[4]!==o.isOpen?(m=()=>{o.isOpen&&c.current&&(c.current.focus(),c.current.select())},p=[o.isOpen],t[4]=o.isOpen,t[5]=m,t[6]=p):(m=t[5],p=t[6]),l.useEffect(m,p),t[7]!==o.findText||t[8]!==o.isOpen?(g=()=>{if(o.isOpen){if(""===o.findText)return a(void 0),void jm();f(),function(){const e=ne.get(pm),t=Ln();for(const n of t)n.state.readOnly||n.dispatch({effects:Em.of(new Pn({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord}))})}()}else jm()},t[7]=o.findText,t[8]=o.isOpen,t[9]=g):g=t[9],t[10]!==o.caseSensitive||t[11]!==o.findText||t[12]!==o.isOpen||t[13]!==o.regexp||t[14]!==o.wholeWord?(y=[o.findText,o.isOpen,o.caseSensitive,o.regexp,o.wholeWord],t[10]=o.caseSensitive,t[11]=o.findText,t[12]=o.isOpen,t[13]=o.regexp,t[14]=o.wholeWord,t[15]=y):y=t[15],l.useEffect(g,y),!o.isOpen)return null;const b=o.currentView;let x;t[16]!==i||t[17]!==b?(x=b&&i?null==(e=i.position.get(b.view))?void 0:e.get(`${b.range.from}:${b.range.to}`):void 0,t[16]=i,t[17]=b,t[18]=x):x=t[18];const v=x;let w,k,S,C,E,j,I,A,T,M,D;t[19]===Symbol.for("react.memo_cache_sentinel")?(w=()=>r(!0),t[19]=w):w=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(k=()=>r(!1),t[20]=k):k=t[20],t[21]!==s?(S=e=>{"Escape"===e.key&&s({type:"setIsOpen",isOpen:!1})},t[21]=s,t[22]=S):S=t[22],t[23]!==s?(C=()=>s({type:"setIsOpen",isOpen:!1}),t[23]=s,t[24]=C):C=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(E=_.jsx(Gn,{className:"w-4 h-4"}),t[25]=E):E=t[25],t[26]!==C?(j=_.jsx("div",{className:"absolute top-0 right-0",children:_.jsx(ee,{"data-testid":"close-find-replace-button",onClick:C,size:"xs",variant:"text",children:E})}),t[26]=C,t[27]=j):j=t[27],t[28]!==s?(I=e=>{s({type:"setFind",find:e.target.value})},t[28]=s,t[29]=I):I=t[29],t[30]!==o.findText||t[31]!==I?(A=_.jsx(lt,{ref:c,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:Rm,onChange:I}),t[30]=o.findText,t[31]=I,t[32]=A):A=t[32],t[33]!==s?(T=e=>{s({type:"setReplace",replace:e.target.value})},t[33]=s,t[34]=T):T=t[34],t[35]!==o.replaceText||t[36]!==T?(M=_.jsx(lt,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:T}),t[35]=o.replaceText,t[36]=T,t[37]=M):M=t[37],t[38]!==A||t[39]!==M?(D=_.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[A,M]}),t[38]=A,t[39]=M,t[40]=D):D=t[40];const O=o.caseSensitive?"on":"off";let R,P,L;t[41]!==s?(R=e=>s({type:"setCaseSensitive",caseSensitive:e}),t[41]=s,t[42]=R):R=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(P=_.jsx(qn,{className:"w-4 h-4"}),t[43]=P):P=t[43],t[44]!==o.caseSensitive||t[45]!==O||t[46]!==R?(L=_.jsx(ht,{content:"Case Sensitive",children:_.jsx(Wn,{size:"sm",pressed:o.caseSensitive,"data-state":O,onPressedChange:R,children:P})}),t[44]=o.caseSensitive,t[45]=O,t[46]=R,t[47]=L):L=t[47];const F=o.wholeWord?"on":"off";let z,B,U;t[48]!==s?(z=e=>s({type:"setWholeWord",wholeWord:e}),t[48]=s,t[49]=z):z=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?(B=_.jsx(Au,{className:"w-4 h-4"}),t[50]=B):B=t[50],t[51]!==o.wholeWord||t[52]!==F||t[53]!==z?(U=_.jsx(ht,{content:"Match Whole Word",children:_.jsx(Wn,{size:"sm",pressed:o.wholeWord,"data-state":F,onPressedChange:z,children:B})}),t[51]=o.wholeWord,t[52]=F,t[53]=z,t[54]=U):U=t[54];const $=o.regexp?"on":"off";let V,H,W,G,q;t[55]!==s?(V=e=>s({type:"setRegex",regexp:e}),t[55]=s,t[56]=V):V=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?(H=_.jsx(uu,{className:"w-4 h-4"}),t[57]=H):H=t[57],t[58]!==o.regexp||t[59]!==$||t[60]!==V?(W=_.jsx(ht,{content:"Use Regular Expression",children:_.jsx(Wn,{size:"sm",pressed:o.regexp,"data-state":$,onPressedChange:V,children:H})}),t[58]=o.regexp,t[59]=$,t[60]=V,t[61]=W):W=t[61],t[62]!==L||t[63]!==U||t[64]!==W?(G=_.jsxs("div",{className:"flex items-center gap-[2px]",children:[L,U,W]}),t[62]=L,t[63]=U,t[64]=W,t[65]=G):G=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(q=()=>{Cm()&&f()},t[66]=q):q=t[66];const Y=""===o.findText;let K,J;t[67]!==Y?(K=_.jsx(ee,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:q,disabled:Y,children:"Replace Next"}),t[67]=Y,t[68]=K):K=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(J=()=>{const e=Sm();if(!e)return;f();const{dismiss:t}=se({title:"Replaced all occurrences",action:_.jsx(oh,{"data-testid":"undo-replace-all-button",onClick:()=>{e(),n()}})}),n=t},t[69]=J):J=t[69];const X=""===o.findText;let Z,Q,te,re,oe,ie,ae,le,ce,ue,he,fe;return t[70]!==X?(Z=_.jsx(ee,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:J,disabled:X,children:"Replace All"}),t[70]=X,t[71]=Z):Z=t[71],t[72]!==K||t[73]!==Z?(Q=_.jsxs("div",{className:"flex items-center gap-[2px]",children:[K,Z]}),t[72]=K,t[73]=Z,t[74]=Q):Q=t[74],t[75]!==G||t[76]!==Q?(te=_.jsxs("div",{className:"flex flex-col gap-2",children:[G,Q]}),t[75]=G,t[76]=Q,t[77]=te):te=t[77],t[78]!==D||t[79]!==te?(re=_.jsxs("div",{className:"flex items-center gap-3",children:[D,te]}),t[78]=D,t[79]=te,t[80]=re):re=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(oe=_.jsx(ht,{content:"Find Previous",children:_.jsx(ee,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:Pm,children:_.jsx(yd,{className:"w-4 h-4"})})}),t[81]=oe):oe=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(ie=_.jsx(ht,{content:"Find Next",children:_.jsx(ee,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:Lm,children:_.jsx(vd,{className:"w-4 h-4"})})}),t[82]=ie):ie=t[82],t[83]!==v||t[84]!==i?(ae=null!=i&&null==v&&_.jsxs("span",{className:"text-sm",children:[i.count," matches"]}),t[83]=v,t[84]=i,t[85]=ae):ae=t[85],t[86]!==v||t[87]!==i?(le=null!=i&&null!=v&&_.jsxs("span",{className:"text-sm",children:[v+1," of ",i.count]}),t[86]=v,t[87]=i,t[88]=le):le=t[88],t[89]!==ae||t[90]!==le?(ce=_.jsxs("div",{className:"flex items-center gap-2",children:[oe,ie,ae,le]}),t[89]=ae,t[90]=le,t[91]=ce):ce=t[91],t[92]!==d?(ue=d.getHotkey("cell.findAndReplace"),t[92]=d,t[93]=ue):ue=t[93],t[94]!==ue.key?(he=_.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",_.jsx(nt,{shortcut:ue.key})," ","again to open the native browser search."]}),t[94]=ue.key,t[95]=he):he=t[95],t[96]!==j||t[97]!==re||t[98]!==ce||t[99]!==he||t[100]!==S?(fe=_.jsx(Yn,{restoreFocus:!0,autoFocus:!0,children:_.jsxs("div",{onFocus:w,onClick:Om,onBlur:k,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:[j,re,ce,he]})}),t[96]=j,t[97]=re,t[98]=ce,t[99]=he,t[100]=S,t[101]=fe):fe=t[101],fe};function Om(e){e.stopPropagation(),e.preventDefault()}function Rm(e){"Enter"===e.key&&(e.shiftKey?km():wm())}function Pm(){return km()}function Lm(){return wm()}function Fm(e){const t=N.c(3),[n,r]=l.useState(!1);let o,s;return t[0]!==e?(o=()=>{if(!e)return;r(!1);const t=setTimeout((()=>{r(!0)}),200);return()=>clearTimeout(t)},s=[e],t[0]=e,t[1]=o,t[2]=s):(o=t[1],s=t[2]),l.useEffect(o,s),e&&n}const zm=()=>{const e=N.c(6),t=he(xh);let n;e[0]!==t?(n=()=>t(Bm),e[0]=t,e[1]=n):n=e[1];const r=n;let o,s,i;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=fn("global.commandPalette"),e[2]=o):o=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=_.jsx(Dd,{strokeWidth:1.5,size:18}),e[3]=s):s=e[3],e[4]!==r?(i=_.jsx(ht,{content:o,children:_.jsx(rc,{"data-testid":"command-palette-button",onClick:r,shape:"rectangle",color:"hint-green",children:s})}),e[4]=r,e[5]=i):i=e[5],i};function Bm(e){return!e}const Um=e=>{const{children:t}=e;return de(pe)?null:t},$m=e=>{const{children:t}=e;return de(pe)?t:null},Vm=e=>{const t=N.c(38),{resetOnBlur:n,placeholderText:r,initialValue:o,flexibleWidth:s,onNameChange:i,className:a}=e,c=void 0!==n&&n,d=void 0===o?null:o,u=void 0!==s&&s,[h,f]=l.useState(d);let m;t[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],t[0]=m):m=t[0];const[p,g]=l.useState(m),[y,b]=l.useState(!1),x=l.useRef(null),v=l.useRef(!1);let w,k,S;t[1]!==d?(w=()=>{f(d)},k=[d],t[1]=d,t[2]=w,t[3]=k):(w=t[2],k=t[3]),l.useEffect(w,k),t[4]===Symbol.for("react.memo_cache_sentinel")?(S=()=>{b(!0)},t[4]=S):S=t[4];const C=S;let E;t[5]!==d||t[6]!==c?(E=e=>{var t;(null==(t=e.relatedTarget)?void 0:t.closest(".filename-input"))||(b(!1),c&&f(d))},t[5]=d,t[6]=c,t[7]=E):E=t[7];const I=E;let A;t[8]!==h?(A=Et.dirname(h||""),t[8]=h,t[9]=A):A=t[9];const T=A,M=Et.basename(h||""),D=p.filter((e=>Et.basename(e.path).startsWith(M)));let O,R;t[10]!==T||t[11]!==y?(O=async()=>{if(!y)return void g([]);const e=await Xn({path:T});g(e.files)},R=[T,y],t[10]=T,t[11]=y,t[12]=O,t[13]=R):(O=t[12],R=t[13]);const{loading:P}=Pt(O,R),L=function(e,t,n){if(!e)return;if(e.endsWith("/"))return;(j("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(Et.extension(e))||(e=e.endsWith(".")?`${e}py`:e.endsWith(".p")?`${e}y`:`${e}.py`);if(t.some((t=>t.path===e||Et.basename(t.path)===e)))return;if(n&&(n===e||Et.basename(n)===e))return;return e}(h,p,d),F=(L||D.length>0)&&_.jsxs(Xe,{className:"font-mono",children:[!P&&_.jsx(ot,{children:"No files"}),L&&_.jsxs(et,{variant:"success",className:"py-2 px-3",onSelect:()=>{var e;L&&(v.current=!0,i(L),null==(e=x.current)||e.blur())},children:[_.jsx(zd,{className:"w-4 h-4 mr-2"})," ",_.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",_.jsx("span",{className:"font-medium text-sm",children:Et.basename(L)})]})]},"_rename_"),D.map((e=>{const t=e.isDirectory?"directory":Kn(e.path),n=Jn[t];return _.jsxs(et,{variant:e.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{e.isDirectory?f(`${e.path}/`):f(e.path)},children:[_.jsx(n,{className:"w-4 h-4 mr-2"})," ",Et.basename(e.path)]},e.path)}))]}),z=10*Math.max(20,(null==h?void 0:h.length)||(null==r?void 0:r.length)||0),B=y?h||"":d||"";let U,$,V;t[14]!==u||t[15]!==z?(U=u?{maxWidth:z}:void 0,t[14]=u,t[15]=z,t[16]=U):U=t[16],t[17]!==a?($=$t(a,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),t[17]=a,t[18]=$):$=t[18],t[19]!==r||t[20]!==B||t[21]!==U||t[22]!==$?(V=_.jsx(Zn,{children:_.jsx(rt,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:B,onKeyDown:Hm,icon:null,ref:x,onValueChange:f,placeholder:r,autoComplete:"off",style:U,className:$})}),t[19]=r,t[20]=B,t[21]=U,t[22]=$,t[23]=V):V=t[23];const H=F&&"group-focus-within:block";let W,G,q,Y,K;return t[24]!==H?(W=$t("p-0 w-full min-w-80 max-w-80vw hidden",H),t[24]=H,t[25]=W):W=t[25],t[26]!==F||t[27]!==W?(G=_.jsx(Qn,{side:"bottom",className:W,portal:!1,children:F}),t[26]=F,t[27]=W,t[28]=G):G=t[28],t[29]!==V||t[30]!==G?(q=_.jsxs(Xe,{children:[V,G]}),t[29]=V,t[30]=G,t[31]=q):q=t[31],t[32]!==I||t[33]!==q?(Y=_.jsx(er,{onFocus:C,onBlur:I,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:q}),t[32]=I,t[33]=q,t[34]=Y):Y=t[34],t[35]!==y||t[36]!==Y?(K=_.jsx(tr,{children:_.jsx(nr,{open:y,modal:!1,children:Y})}),t[35]=y,t[36]=Y,t[37]=K):K=t[37],K};function Hm(e){"Escape"===e.key&&e.currentTarget.blur()}function Wm(e){return JSON.stringify(e)}const Gm=Z(void 0),qm=Z((e=>{const t=e(Gm);return function(e,t,n){if(!n)return!1;const{cellIds:r,cellData:o}=e,s=r.inOrderIds.map((e=>o[e])),i=s.map((e=>e.code)),a=s.map((e=>e.config)),l=s.map((e=>e.name));return!(rr(i,n.codes)&&rr(l,n.names)&&or(a,n.configs)&&or(t.selectedLayout,n.layout.selectedLayout)&&or(t.layoutData,n.layout.layoutData))}(e(ae),e(Fc),t)}));const Ym=e=>{const t=N.c(35),n=an(),r=()=>{Cn(new Blob([s()],{type:"text/plain"}),`${e.proposedName}.json`)};let o;t[0]!==n?(o=()=>{const e=W(),t=sr(e);return JSON.stringify({filename:n,cells:t.map(Jm)},null,2)},t[0]=n,t[1]=o):o=t[1];const s=$(o);let i,a,l,c,d,u,h,f,m,p,g,y,b,x,v,w,k;return t[2]!==r||t[3]!==e?(i=t=>{t.preventDefault(),r(),e.closeModal()},t[2]=r,t[3]=e,t[4]=i):i=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")?(l=_.jsx(Le,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),t[7]=l):l=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(c={wordBreak:"break-word"},t[8]=c):c=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx("p",{children:"This app has unsaved changes. To recover:"}),u={paddingBottom:"10px"},t[9]=d,t[10]=u):(d=t[9],u=t[10]),t[11]!==e.proposedName?(h=_.jsxs("li",{style:u,children:['Click the "Download" button. This will download a file called ',_.jsxs("code",{children:[e.proposedName,".json"]}),". This file contains your code."]}),t[11]=e.proposedName,t[12]=h):h=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(f={paddingBottom:"10px"},t[13]=f):f=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(m={display:"block",padding:"10px"},t[14]=m):m=t[14],t[15]!==e.proposedName?(p=_.jsxs("code",{style:m,children:["marimo recover ",e.proposedName,".json ",">"," ",e.proposedName,".py"]}),t[15]=e.proposedName,t[16]=p):p=t[16],t[17]!==e.proposedName?(g=_.jsxs("code",{children:[e.proposedName,".py"]}),t[17]=e.proposedName,t[18]=g):g=t[18],t[19]!==p||t[20]!==g?(y=_.jsxs("li",{style:f,children:["In your terminal, type",p,"to overwrite ",g," with the recovered changes."]}),t[19]=p,t[20]=g,t[21]=y):y=t[21],t[22]!==y||t[23]!==h?(b=_.jsx(at,{className:"markdown break-words",style:c,children:_.jsxs("div",{className:"prose dark:prose-invert",children:[d,_.jsxs("ol",{children:[h,y]})]})}),t[22]=y,t[23]=h,t[24]=b):b=t[24],t[25]!==e.closeModal?(x=_.jsx(ee,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:e.closeModal,children:"Cancel"}),t[25]=e.closeModal,t[26]=x):x=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(v=_.jsx(ee,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),t[27]=v):v=t[27],t[28]!==x?(w=_.jsxs(ct,{children:[x,v]}),t[28]=x,t[29]=w):w=t[29],t[30]!==i||t[31]!==b||t[32]!==w||t[33]!==a?(k=_.jsx(Re,{className:"w-fit",children:_.jsxs("form",{onSubmit:i,onKeyDown:a,children:[l,b,w]})}),t[30]=i,t[31]=b,t[32]=w,t[33]=a,t[34]=k):k=t[34],k},Km=e=>{const t=N.c(12),{filename:n,needsSave:r}=e,{openModal:o,closeModal:s}=ue();let i;t[0]!==n?(i=null===n?"app":n.slice(0,-3),t[0]=n,t[1]=i):i=t[1];const a=i;let l;t[2]!==s||t[3]!==r||t[4]!==o||t[5]!==a?(l=()=>{r&&o(_.jsx(Ym,{proposedName:a,closeModal:s}))},t[2]=s,t[3]=r,t[4]=o,t[5]=a,t[6]=l):l=t[6];const c=l;let d;oc("global.save",c),t[7]===Symbol.for("react.memo_cache_sentinel")?(d=fn("global.save"),t[7]=d):d=t[7];const u=r?"yellow":"gray";let h,f;return t[8]===Symbol.for("react.memo_cache_sentinel")?(h=_.jsx(mu,{strokeWidth:1.5,size:18}),t[8]=h):h=t[8],t[9]!==c||t[10]!==u?(f=_.jsx(ht,{content:d,children:_.jsx(rc,{onClick:c,id:"save-button","aria-label":"Save",className:"rectangle",color:u,children:h})}),t[9]=c,t[10]=u,t[11]=f):f=t[11],f};function Jm(e){return{name:e.name,code:e.code}}const Xm=5e3;async function Zm(){await cr({download:!1})}async function Qm(){await lr({download:!1,includeCode:!0,files:Dc.INSTANCE.filenames()})}async function ep(){await ar({download:!1})}const tp=e=>{const t=N.c(15),{kioskMode:n}=e,r=an(),o=de(qm),s=de(ft).state===pt.CLOSED,{saveOrNameNotebook:i,saveIfNotebookIsPersistent:a}=np();let c,d,u;t[0]!==n||t[1]!==a?(c={onSave:a,kioskMode:n},t[0]=n,t[1]=a,t[2]=c):c=t[2],function(e){const t=N.c(14),n=de(fr),r=yr(),[o]=We(ft),s=de(qm);let i,a;if(t[0]!==r){const e=sr(r);i=e.map(lp),a=e.map(ap),t[0]=r,t[1]=i,t[2]=a}else i=t[1],a=t[2];const c=a;let d;t[3]!==r?(d=hr(r),t[3]=r,t[4]=d):d=t[4];const u=d;let h;t[5]!==n||t[6]!==c||t[7]!==i||t[8]!==u||t[9]!==o||t[10]!==s||t[11]!==e.kioskMode||t[12]!==e.onSave?(h={onSave:e.onSave,needsSave:s,codes:i,cellConfigs:u,cellNames:c,connStatus:o,config:n,kioskMode:e.kioskMode},t[5]=n,t[6]=c,t[7]=i,t[8]=u,t[9]=o,t[10]=s,t[11]=e.kioskMode,t[12]=e.onSave,t[13]=h):h=t[13];!function(e){const t=N.c(21),{codes:n,cellConfigs:r,config:o,connStatus:s,cellNames:i,needsSave:a,kioskMode:c,onSave:d}=e,u=l.useRef(null);let h;t[0]!==n?(h=n.join(":"),t[0]=n,t[1]=h):h=t[1];const f=h;let m;t[2]!==r?(m=r.map(Wm).join(":"),t[2]=r,t[3]=m):m=t[3];const p=m;let g;t[4]!==i?(g=i.join(":"),t[4]=i,t[5]=g):g=t[5];const y=g;let b,x;t[6]!==o||t[7]!==s.state||t[8]!==c||t[9]!==a||t[10]!==d?(b=()=>{if(!c)return"after_delay"===o.autosave&&(null!==u.current&&clearTimeout(u.current),a&&s.state===pt.OPEN&&(u.current=setTimeout(d,o.autosave_delay))),()=>{null!==u.current&&clearTimeout(u.current)}},t[6]=o,t[7]=s.state,t[8]=c,t[9]=a,t[10]=d,t[11]=b):b=t[11],t[12]!==p||t[13]!==y||t[14]!==f||t[15]!==o||t[16]!==s.state||t[17]!==c||t[18]!==a||t[19]!==d?(x=[f,p,y,o,s.state,d,c,a],t[12]=p,t[13]=y,t[14]=f,t[15]=o,t[16]=s.state,t[17]=c,t[18]=a,t[19]=d,t[20]=x):x=t[20],l.useEffect(b,x)}(h)}(c),function(){const e=N.c(6),t=de(ir),{state:n}=de(ft),r=t.auto_download.includes("markdown"),o=t.auto_download.includes("html"),s=t.auto_download.includes("ipynb"),i=!r||n!==pt.OPEN,a=!o||n!==pt.OPEN,l=!s||n!==pt.OPEN;let c,d,u;e[0]!==i?(c={delayMs:Xm,whenVisible:!0,disabled:i},e[0]=i,e[1]=c):c=e[1],sc(ep,c),e[2]!==a?(d={delayMs:Xm,whenVisible:!0,disabled:a},e[2]=a,e[3]=d):d=e[3],sc(Qm,d),e[4]!==l?(u={delayMs:Xm,whenVisible:!0,disabled:l},e[4]=l,e[5]=u):u=e[5],sc(Zm,u)}(),t[3]!==o?(d=e=>{if(o)return e.preventDefault(),e.returnValue="You have unsaved changes. Are you sure you want to leave?",e.returnValue},t[3]=o,t[4]=d):d=t[4],Q(window,"beforeunload",d),t[5]!==i?(u=e=>{e.preventDefault(),e.stopPropagation(),i()},t[5]=i,t[6]=u):u=t[6];const h=u;if(oc("global.save",i),s){let e;return t[7]!==r||t[8]!==o?(e=_.jsx(Km,{filename:r,needsSave:o}),t[7]=r,t[8]=o,t[9]=e):e=t[9],e}let f;t[10]===Symbol.for("react.memo_cache_sentinel")?(f=fn("global.save"),t[10]=f):f=t[10];const m=o?"yellow":"hint-green";let p,g;return t[11]===Symbol.for("react.memo_cache_sentinel")?(p=_.jsx(mu,{strokeWidth:1.5,size:18}),t[11]=p):p=t[11],t[12]!==h||t[13]!==m?(g=_.jsx(ht,{content:f,children:_.jsx(rc,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:m,onClick:h,children:p})}),t[12]=h,t[13]=m,t[14]=g):g=t[14],g};function np(){const e=N.c(19),{openModal:t,closeModal:n,openAlert:r}=ue(),o=he(Gm),s=dr(),i=ur();let a;e[0]!==r||e[1]!==o||e[2]!==i?(a=(e,t)=>{const n=W(),s=sr(n),a=s.map(sp),l=s.map(op),c=s.map(rp),d=hr(n),u=i.get(ft),h=i.get(fr),f=i.get(Fc);i.get(pe)||0!==l.length&&(u.state===pt.OPEN?(X.log("saving to ",e),mr({cellIds:a,codes:l,names:c,filename:e,configs:d,layout:zc(),persist:!0}).then((()=>{t&&h.format_on_save&&pr(),o({names:c,codes:l,configs:d,layout:f})}))):r("Failed to save notebook: not connected to a kernel."))},e[0]=r,e[1]=o,e[2]=i,e[3]=a):a=e[3];const l=$(a);let c;e[4]!==l||e[5]!==i?(c=e=>{const t=void 0!==e&&e,n=i.get(gr),r=i.get(ft);ip(n)&&r.state===pt.OPEN&&l(n,t)},e[4]=l,e[5]=i,e[6]=c):c=e[6];const d=$(c);let u;e[7]!==l||e[8]!==s?(u=e=>{s(e).then((e=>{null!==e&&l(e,!0)}))},e[7]=l,e[8]=s,e[9]=u):u=e[9];const h=u;let f;e[10]!==n||e[11]!==h||e[12]!==t||e[13]!==d||e[14]!==i?(f=()=>{const e=i.get(gr),r=i.get(ft);d(!0),ip(e)||r.state===pt.CLOSED||t(_.jsx(cp,{onClose:n,onSave:h}))},e[10]=n,e[11]=h,e[12]=t,e[13]=d,e[14]=i,e[15]=f):f=e[15];const m=$(f);let p;return e[16]!==d||e[17]!==m?(p={saveOrNameNotebook:m,saveIfNotebookIsPersistent:d},e[16]=d,e[17]=m,e[18]=p):p=e[18],p}function rp(e){return e.name}function op(e){return e.code}function sp(e){return e.id}function ip(e){return null!==e&&!e.startsWith("/tmp")&&!e.startsWith("/var/folders")&&!e.includes("AppData\\Local\\Temp")}function ap(e){return e.name}function lp(e){return e.code}const cp=e=>{const t=N.c(17),{onClose:n,onSave:r}=e,[o,s]=l.useState();let i;t[0]!==n||t[1]!==r?(i=e=>{s(e),e.trim()&&(r(e),n())},t[0]=n,t[1]=r,t[2]=i):i=t[2];const a=i;let c,d,u,h;t[3]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx(Le,{children:"Save notebook"}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(Fe,{className:"text-md pt-6 px-1",children:"Save as"}),t[4]=d):d=t[4],t[5]!==a?(u=_.jsxs("div",{className:"flex flex-col",children:[d,_.jsx(Vm,{onNameChange:a,placeholderText:"filename",className:"missing-filename"})]}),t[5]=a,t[6]=u):u=t[6],t[7]!==n?(h=_.jsx(ee,{"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=!o;let m,p,g;return t[9]!==f?(m=_.jsx(ee,{"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=_.jsxs(ct,{children:[h,m]}),t[11]=h,t[12]=m,t[13]=p):p=t[13],t[14]!==u||t[15]!==p?(g=_.jsxs(Re,{children:[c,u,p]}),t[14]=u,t[15]=p,t[16]=g):g=t[16],g},dp=e=>{const t=N.c(40),{presenting:n,onTogglePresenting:r,onInterrupt:o,onRun:s,closed:i,running:a,appConfig:l}=e,c=l.width,d=de(hn),u=de(br),{undoDeleteCell:h}=V();let f,m,p=null;if(!i&&d){let e,n;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(_u,{size:16,strokeWidth:1.5}),t[0]=e):e=t[0],t[1]!==h?(n=_.jsx(ht,{content:"Undo cell deletion",children:_.jsx(rc,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:h,children:e})}),t[1]=h,t[2]=n):n=t[2],p=n}t[3]!==n?(f=!n&&_.jsx(Dm,{}),t[3]=n,t[4]=f):f=t[4],t[5]!==i||t[6]!==n?(m=!i&&_.jsxs("div",{className:fp,children:[n&&_.jsx(Uu,{}),_.jsx(fm,{}),_.jsx(ic,{}),_.jsx(ac,{description:"This will terminate the Python kernel. You'll lose all data that's in memory."})]}),t[5]=i,t[6]=n,t[7]=m):m=t[7];const g="compact"===c&&"xl:flex-row items-end";let y,b,x,v,w,k,S,C,E,j,I,A,T;return t[8]!==g?(y=$t(mp,g),t[8]=g,t[9]=y):y=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(b=_.jsx(Um,{children:_.jsx(tp,{kioskMode:!1})}),t[10]=b):b=t[10],t[11]===Symbol.for("react.memo_cache_sentinel")?(x=fn("global.hideCode"),t[11]=x):x=t[11],t[12]!==n?(v=n?_.jsx(mn,{strokeWidth:1.5,size:18}):_.jsx(Xd,{strokeWidth:1.5,size:18}),t[12]=n,t[13]=v):v=t[13],t[14]!==r||t[15]!==v?(w=_.jsx(ht,{content:x,children:_.jsx(rc,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:r,children:v})}),t[14]=r,t[15]=v,t[16]=w):w=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(C=_.jsx(zm,{}),k=_.jsx(lc,{}),S=_.jsx("div",{}),t[17]=k,t[18]=S,t[19]=C):(k=t[17],S=t[18],C=t[19]),t[20]!==i||t[21]!==o||t[22]!==a?(E=!i&&_.jsx(hp,{running:a,onInterrupt:o}),t[20]=i,t[21]=o,t[22]=a,t[23]=E):E=t[23],t[24]!==i||t[25]!==u||t[26]!==s?(j=!i&&_.jsx(up,{needsRun:u,onRun:s}),t[24]=i,t[25]=u,t[26]=s,t[27]=j):j=t[27],t[28]!==E||t[29]!==j||t[30]!==p?(I=_.jsx(Um,{children:_.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[p,E,j]})}),t[28]=E,t[29]=j,t[30]=p,t[31]=I):I=t[31],t[32]!==I||t[33]!==y||t[34]!==w?(A=_.jsxs("div",{className:y,children:[b,w,C,k,S,I]}),t[32]=I,t[33]=y,t[34]=w,t[35]=A):A=t[35],t[36]!==f||t[37]!==A||t[38]!==m?(T=_.jsxs(_.Fragment,{children:[f,m,A]}),t[36]=f,t[37]=A,t[38]=m,t[39]=T):T=t[39],T},up=e=>{const t=N.c(5),{needsRun:n,onRun:r}=e;if(n){let e,n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=fn("global.runStale"),t[0]=e):e=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(_c,{strokeWidth:1.5,size:16}),t[1]=n):n=t[1],t[2]!==r?(o=_.jsx(ht,{content:e,children:_.jsx(rc,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:r,children:n})}),t[2]=r,t[3]=o):o=t[3],o}let o;return t[4]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsx(ht,{content:"Nothing to run",children:_.jsx(rc,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",children:_.jsx(_c,{strokeWidth:1.5,size:16})})}),t[4]=o):o=t[4],o},hp=e=>{const t=N.c(8),{running:n,onInterrupt:r}=e,o=Fm(n);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=fn("global.interrupt"),t[0]=s):s=t[0];const i=!o&&"inactive-button active:shadow-xsSolid";let a;t[1]!==i?(a=$t(i),t[1]=i,t[2]=a):a=t[2];const l=o?"yellow":"disabled",c=o?r:Rt.NOOP;let d,u;return t[3]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(R,{strokeWidth:1.5,size:16}),t[3]=d):d=t[3],t[4]!==a||t[5]!==l||t[6]!==c?(u=_.jsx(ht,{content:s,children:_.jsx(rc,{className:a,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:c,children:d})}),t[4]=a,t[5]=l,t[6]=c,t[7]=u):u=t[7],u},fp="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",mp="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",pp=e=>{const t=N.c(7),{filename:n}=e,r=dr();let o;t[0]!==n?(o=n?Et.basename(n):"untitled marimo app",t[0]=n,t[1]=o):o=t[1];const s=null===n?"missing-filename":"filename";let i;return t[2]!==n||t[3]!==r||t[4]!==o||t[5]!==s?(i=_.jsx(Vm,{placeholderText:o,initialValue:n,onNameChange:r,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),t[2]=n,t[3]=r,t[4]=o,t[5]=s,t[6]=i):i=t[6],i},gp=xr(vr,400),yp=(e,t)=>{ne.get(pe)||e.isEmpty()||t.isEmpty()||or(e.inOrderIds,t.inOrderIds)||gp({cell_ids:e.inOrderIds})};function bp(e){return[wr.of([{key:"Escape",preventDefault:!1,run:ym},{key:e.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:Sr},{key:e.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:gm}]),kr(),Tm,_m,Mm]}const xp={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},vp=Cr.define({combine:e=>Nr(e,{onError:console.error,inputDebounceTime:300,keymaps:xp},{onError:(e,t)=>e&&t,inputDebounceTime:(e,t)=>e&&t,keymaps:(e,t)=>e&&t})}),wp=Hn.define(),kp=Un.define({create:()=>({show:!1,lineFrom:0,lineTo:0}),update(e,t){for(const n of t.effects)if(n.is(wp))return n.value;return e}}),Sp=Hn.define(),Cp=Hn.define(),Np=Un.define({create:()=>({shouldFocus:!1,inputValue:""}),update(e,t){let n=e;for(const r of t.effects)r.is(Sp)&&(n={...n,inputValue:r.value}),r.is(Cp)&&(n={...n,shouldFocus:r.value});return n}}),Ep=Hn.define(),jp=Un.define({create:()=>null,update(e,t){for(const n of t.effects)if(n.is(Ep))return n.value;return e}}),_p=Hn.define(),Ip=Un.define({create:()=>!1,update(e,t){for(const n of t.effects)if(n.is(_p))return n.value;return e}}),Ap=e=>{const{state:t}=e,n=t.selection.main;if(n.empty)return!1;const r=t.doc,o=r.lineAt(n.from),s=r.lineAt(n.to);if(t.sliceDoc(o.from,s.to).trim().length<1)return!1;const i=Math.max(1,Math.min(o.number,r.lines)),a=Math.max(1,Math.min(s.number,r.lines));return e.dispatch({effects:[wp.of({show:!0,lineFrom:i,lineTo:a}),Cp.of(!0),Sp.of("")],selection:Fn.cursor(o.from)}),!0},Tp=e=>!!e.state.field(jp)&&(e.dispatch({effects:[Ep.of(null),wp.of({show:!1,lineFrom:0,lineTo:0}),Cp.of(!1),Sp.of(""),_p.of(!1)]}),!0),Mp=e=>{const t=e.state.field(jp);return!!t&&(e.dispatch({changes:{from:t.from,to:t.to,insert:t.oldCode},effects:[Ep.of(null),wp.of({show:!1,lineFrom:0,lineTo:0}),Cp.of(!1),Sp.of(""),_p.of(!1)]}),!0)},Dp=zn.baseTheme({".cm-ai-input-container":{display:"flex",flexDirection:"column",gap:"4px",width:"min(calc(100% + 7px), 500px)",padding:"5px 5px",margin:"0 -6px",backgroundColor:"light-dark(rgb(241, 243, 245), rgb(40, 40, 40))"},".cm-ai-input":{display:"block",width:"100%",padding:"3px 8px",border:"2px solid rgb(51, 154, 240)",borderRadius:"5px",fontSize:"12px"},".cm-ai-help-info-button":{fontSize:"10px",paddingLeft:"10px",height:"18px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",display:"block",marginRight:"auto"},".cm-ai-help-info-button:hover":{color:"light-dark(rgb(89, 97, 105), rgb(190, 190, 190))"},".cm-ai-generate-button":{background:"#0E639C",border:"none",padding:"2px 6px",color:"#ffffff",cursor:"pointer",font:"inherit",borderRadius:"4px","&:hover":{backgroundColor:"#1177bb"}},".cm-line.cm-ai-selection, .cm-line.cm-ai-selection.cm-active-line":{backgroundColor:"light-dark(color-mix(in srgb, rgb(223, 227, 232) 50%, transparent), color-mix(in srgb, rgb(50, 50, 50) 50%, transparent)) !important"},".cm-line:has(.cm-new-code-line)":{backgroundColor:"light-dark(color-mix(in srgb, rgb(183, 235, 143) 50%, transparent), color-mix(in srgb, rgb(40, 100, 40) 50%, transparent)) !important"},".cm-old-code-container":{backgroundColor:"light-dark(rgb(255, 205, 205), rgb(100, 40, 40))",position:"relative",display:"flex",paddingTop:"0",width:"100%",alignItems:"center"},".cm-code-button":{position:"absolute",right:"5px",top:"50%",transform:"translateY(-50%)",background:"none",border:"none",cursor:"pointer",fontSize:"16px"},".cm-floating-buttons":{fontFamily:"sans-serif",position:"absolute",top:"-20px",left:"5px",display:"flex"},".cm-floating-button":{fontFamily:"sans-serif",padding:"2px 5px",fontSize:"10px",cursor:"pointer",fontWeight:"700"},".cm-floating-accept":{backgroundColor:"light-dark(rgb(55, 125, 34), rgb(40, 80, 25))",borderTopLeftRadius:"5px",borderBottomLeftRadius:"5px",color:"white",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".cm-floating-reject":{backgroundColor:"light-dark(rgb(220, 53, 69), rgb(180, 40, 50))",color:"white",borderTopRightRadius:"5px",borderBottomRightRadius:"5px",filter:"brightness(90%)","&:hover":{filter:"brightness(100%)"}},".hotkey":{display:"inline-block",padding:"0 4px",borderRadius:"3px",backgroundColor:"rgba(255, 255, 255, 0.1)",fontSize:"90%"},".cm-ai-loading-indicator":{fontStyle:"italic",fontSize:"10px",paddingLeft:"12px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",opacity:"0",transition:"opacity 0.3s ease-in-out","&::after":{content:'""',display:"inline-block",animation:"ellipsis-pulse 1.5s steps(4, end) infinite"},"&:not(:empty)":{opacity:"1"}},".cm-ai-input:disabled":{opacity:"0.5"},"@keyframes ellipsis-pulse":{"0%":{content:"'.'"},"25%":{content:"'..'"},"50%":{content:"'...'"},"75%":{content:"''"}},".cm-ai-loading-container":{display:"flex",alignItems:"center",padding:"0 8px"},".cm-ai-cancel-button":{padding:"2px 8px",fontSize:"10px",borderRadius:"4px",color:"light-dark(rgb(109, 117, 125), rgb(170, 170, 170))",cursor:"pointer","&:hover":{background:"light-dark(rgb(223, 227, 232), rgb(50, 50, 50))"}},".hidden":{display:"none"}}),Op="⌘",Rp="⊞ Win",Pp="Ctrl";function Lp(e){return e.replace("Mod",navigator.platform.startsWith("Mac")?Op:navigator.platform.startsWith("Win")?Rp:Pp).replace("-"," ").toUpperCase()}function Fp(e,t){const n=document.createElement(e);return n.className=t,n}function zp(e){var t,n;const r=e.state.facet(vp),o={...xp,...r.keymaps},s=Fp("div","cm-ai-tooltip").appendChild(Fp("div","cm-ai-tooltip-button"));return s.innerHTML=`<span>Edit <span class="hotkey">${Lp(o.showInput)}</span></span>`,null==(t=s.querySelector("span"))||t.addEventListener("mousedown",(e=>{e.stopPropagation()})),null==(n=s.querySelector("span"))||n.addEventListener("click",(t=>{t.preventDefault(),Ap(e)})),s}const Bp=Cr.define({combine:e=>Nr(e,{render:zp})}),Up=Bn.fromClass((t=class{constructor(t){var n,r,i;s(this,"view"),s(this,"suppress"),s(this,"dom"),s(this,"mousedown",(()=>{this.suppress=!0})),s(this,"mouseup",(()=>{this.suppress=!1,this.display(this.view)})),n=this,i=e=>{var t;const n=e.state.selection.ranges.find((e=>!e.empty));if(n&&!this.suppress){const r=e.coordsAtPos(n.from);if(!r)return;this.dom.style.display="flex";const o=this.dom.getBoundingClientRect(),s=e.dom.getBoundingClientRect(),i=null==(t=e.dom.parentElement)?void 0:t.getBoundingClientRect(),a=s.width-o.width,l=Math.min(r.left,a);let c=r.top-o.height;c=i?Math.max(i.y,c):c,this.dom.style.left=`${l}px`,this.dom.style.top=`${c}px`,requestAnimationFrame((()=>{this.dom&&(this.dom.ariaHidden="false")}))}else this.dom.style.display="none",this.dom.ariaHidden="true"},(r=e).has(n)?o("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(n):r.set(n,i),this.view=t;const a=t.state.facet(Bp);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup);const l=a.render(t);t.dom.appendChild(l),this.dom=l}update(e){this.display(e.view)}docViewUpdate(e){this.display(e)}display(t){t.state.field(kp).show?this.dom.style.display="none":t.requestMeasure({read:i(this,e)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.dom.remove()}},e=new WeakMap,t)),$p=zn.baseTheme({".cm-ai-tooltip-button":{userSelect:"none",fontFamily:"system-ui, -apple-system, sans-serif",position:"fixed",display:"flex",boxSizing:"border-box",padding:"2px 6px",borderRadius:"4px",fontSize:"12px",backgroundColor:"#0E639C",color:"#ffffff",border:"1px solid transparent",boxShadow:"0 2px 4px rgba(0,0,0,0.1)",zIndex:"999",transition:"opacity 0.5s","&[aria-hidden='true']":{opacity:"0"},"&[aria-hidden='false']":{opacity:"1"},"& > span":{pointerEvents:"auto",cursor:"pointer",display:"inline-block",padding:"2px"},"&:hover":{backgroundColor:"#1177bb"}}});class Vp extends Er{constructor(e){super(),s(this,"oldCode"),this.oldCode=e}toDOM(e){const t=Fp("div","cm-old-code-container");t.setAttribute("role","region"),t.setAttribute("aria-label","Previous code version");const n=Fp("div","cm-old-code cm-line");n.textContent=this.oldCode;const r=Fp("div","cm-floating-buttons"),o=e.state.facet(vp),s={...xp,...o.keymaps},i=Fp("button","cm-floating-button cm-floating-accept");i.innerHTML=`<span class="hotkey">${Lp(s.acceptEdit)}</span> Accept`,i.setAttribute("aria-label","Accept changes"),i.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.focus(),Tp(e)}));const a=Fp("button","cm-floating-button cm-floating-reject");return a.innerHTML=`<span class="hotkey">${Lp(s.rejectEdit)}</span> Reject`,a.setAttribute("aria-label","Reject changes"),a.addEventListener("click",(t=>{t.preventDefault(),t.stopPropagation(),e.focus(),Mp(e)})),r.append(i,a),t.append(n,r),t}updateDOM(e,t){return!0}}class Hp extends Er{constructor(e){super(),s(this,"complete"),s(this,"abortController",null),s(this,"dom",null),s(this,"input",null),s(this,"loadingContainer",null),s(this,"helpInfo",null),s(this,"inputContainer",null),s(this,"form",null),s(this,"view",null),s(this,"onKeyDown",(async e=>{"Enter"!==e.key||e.shiftKey?"Escape"===e.key&&this.onCancel():(e.preventDefault(),await this.handleSubmit())})),s(this,"onCancel",(()=>{this.cleanup();const e=this.view;e&&(e.dispatch({effects:[wp.of({show:!1,lineFrom:0,lineTo:0}),_p.of(!1)]}),e.focus())})),s(this,"handleSubmit",(async e=>{var t;const n=this.view;if(!n)return;const r=n.state.facet(vp);null==e||e.stopPropagation();const o=n.state.field(kp),{input:s}=this;if(!s)return;const i=s.value.trim();if(!o.show||!i)return;const a=n.state.doc.line(o.lineFrom),l=n.state.doc.line(o.lineTo),c=a.from,d=l.to,u=n.state.sliceDoc(c,d),h=n.state.sliceDoc(0,c),f=n.state.sliceDoc(d);this.abortController=new AbortController,n.dispatch({effects:_p.of(!0)}),this.toggleLoading(!0);try{const e=await this.complete({prompt:i,selection:u,codeBefore:h,codeAfter:f,editorView:n,signal:this.abortController.signal});if(!n.state.field(kp).show)return;if(!e||"string"!=typeof e)throw new Error("Invalid completion result");n.dispatch({changes:{from:c,to:d,insert:e},effects:[wp.of({show:!1,lineFrom:0,lineTo:0}),Ep.of({from:c,to:c+e.length,oldCode:u,newCode:e}),_p.of(!1)]})}catch(m){if(m instanceof DOMException&&"AbortError"===m.name)return;null==(t=r.onError)||t.call(r,m)}finally{this.cleanup(),this.toggleLoading(!1),n.focus()}})),this.complete=e}toDOM(e){if(this.dom)return this.dom;this.view=e;const t=e.state.field(Np),n=e.state.field(Ip),r=Fp("div","cm-ai-input-container");this.inputContainer=r,this.dom=r;const o=Fp("form","cm-ai-input-form");this.form=o,o.setAttribute("role","search"),o.setAttribute("aria-label","AI editing instructions"),o.addEventListener("submit",(e=>e.preventDefault()));const s=Fp("input","cm-ai-input");this.input=s,o.append(s),s.placeholder="Editing instructions...",s.setAttribute("aria-label","AI editing instructions"),s.setAttribute("autocomplete","off"),s.setAttribute("spellcheck","true"),s.value=t.inputValue;const i=Fp("div","cm-ai-loading-container");this.loadingContainer=i;const a=Fp("div","cm-ai-loading-indicator");a.setAttribute("role","status"),a.setAttribute("aria-live","polite"),a.textContent="Generating";const l=Fp("button","cm-ai-cancel-button");l.textContent="Cancel",l.setAttribute("aria-label","Cancel code generation"),l.addEventListener("click",this.onCancel),i.append(l,a);const c=Fp("div","cm-ai-help-info");this.helpInfo=c;const d=c.appendChild(document.createElement("button"));d.className="cm-ai-help-info-button",d.textContent="Esc to close",d.addEventListener("click",this.onCancel);const u=Fp("button","cm-ai-generate-button");function h(e){c.replaceChildren(e?u:d)}u.textContent="⏎ Generate",u.setAttribute("aria-label","Generate code"),u.addEventListener("click",this.handleSubmit),this.toggleLoading(n),t.shouldFocus&&requestAnimationFrame((()=>{s.value=t.inputValue,s.focus(),e.dispatch({effects:Cp.of(!1)})})),h(s.value),s.addEventListener("input",(function(){e.dispatch({effects:Sp.of(s.value)});const t=s.value.trim();if(t===f)return;f=t,h(t)})),s.addEventListener("keydown",this.onKeyDown);let f="";return r}toggleLoading(e){var t;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&(null==(t=this.inputContainer)||t.replaceChildren(this.form,e?this.loadingContainer:this.helpInfo))}updateDOM(e,t){return this.dom=e,this.input=e.querySelector(".cm-ai-input"),!0}cleanup(){var e,t,n;null==(e=this.abortController)||e.abort(),this.abortController=null,null==(t=this.dom)||t.remove(),null==(n=this.input)||n.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}}function Wp(e){if(!e.prompt)throw new Error("prompt function is required");return[vp.of(e),kp,Np,jp,Ip,[Up,$p],Dp,wr.of([{key:xp.showInput,run:Ap}]),jr.highest([wr.of([{key:xp.acceptEdit,run:Tp},{key:xp.rejectEdit,run:Mp}])]),Gp,qp,Yp,Kp]}const Gp=zn.updateListener.of((e=>{const t=e.state.field(kp);if(!t.show||!e.docChanged)return;let{lineFrom:n,lineTo:r}=t,o=!1;e.changes.iterChanges(((t,s,i,a)=>{const l=e.state.doc.lineAt(t).number;if(l<n){const t=e.state.doc.lineAt(a).number-e.state.doc.lineAt(i).number;n+=t,r+=t,o=!0}else if(l<=r){const t=e.state.doc.lineAt(a).number-e.state.doc.lineAt(i).number;r+=t,o=!0}})),o&&e.view.dispatch({effects:[wp.of({show:!0,lineFrom:n,lineTo:r})]})})),qp=zn.decorations.of((e=>{const t=e.state.field(jp);return t?$n.set([$n.mark({class:"cm-new-code-line"}).range(t.from,t.to)]):$n.none})),Yp=zn.decorations.compute([kp],(e=>{const t=e.field(kp),n=e.facet(vp),r=[];if(t.show){const o=t.lineFrom,s=t.lineTo;for(let t=o;t<=s;t++){const s=e.doc.line(t).from;r.push($n.line({class:"cm-ai-selection"}).range(s)),t===o&&r.push($n.widget({widget:new Hp(n.prompt),side:-1}).range(s))}}return $n.set(r)})),Kp=Un.define({create:e=>$n.none,update(e,t){const n=t.state.field(jp);return n?$n.set([$n.widget({widget:new Vp(n.oldCode),block:!0}).range(n.from)]):$n.none},provide:e=>zn.decorations.from(e)}),Jp=Un.define({create:()=>({suggestion:null}),update(e,t){const n=t.effects.find((e=>e.is(Xp)));return t.docChanged||n||t.selection?n&&t.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}:e}}),Xp=Hn.define();class Zp extends Er{constructor(e){super(),s(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.setAttribute("role","suggestion"),e.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),e}get lineBreaks(){return this.suggestion.split("\n").length-1}}class Qp{constructor(e){s(this,"cache",new Map),s(this,"timeout"),this.timeout=e}get(e){const t=this.cache.get(e);return t?Date.now()-t.timestamp>this.timeout?(this.cache.delete(e),null):t.result:null}set(e,t){this.cache.set(e,{result:t,timestamp:Date.now()})}}const eg=(e,t)=>Bn.fromClass(class{constructor(){s(this,"abortController",null),s(this,"cache"),this.cache=new Qp(t.cacheTimeout??1e3)}async update(n){var r,o,s,i,a;if(!n.docChanged)return;if(!1===(null==(o=null==(r=t.events)?void 0:r.beforeSuggestionFetch)?void 0:o.call(r,n.view)))return;null==(s=this.abortController)||s.abort(),this.abortController=new AbortController;const l=n.state.doc,c=l.toString(),d=this.cache.get(c);if(d)n.view.dispatch({effects:Xp.of({text:d,doc:l})});else try{const r=await e(n.state,this.abortController.signal);if(this.abortController.signal.aborted)return;if(!1===(null==(a=null==(i=t.events)?void 0:i.shouldShowSuggestion)?void 0:a.call(i,n.view,r)))return;this.cache.set(c,r),n.view.dispatch({effects:Xp.of({text:r,doc:l})})}catch(u){u instanceof Error&&"AbortError"!==u.name&&console.error("Suggestion fetch error:",u)}}destroy(){var e;null==(e=this.abortController)||e.abort()}}),tg=Bn.fromClass(class{constructor(){s(this,"decorations"),this.decorations=$n.none}update(e){var t;const n=null==(t=e.state.field(Jp))?void 0:t.suggestion;this.decorations=n?function(e,t){const n=e.state.selection.main.head,r=[],o=$n.widget({widget:new Zp(t),side:1});return r.push(o.range(n)),$n.set(r)}(e.view,n):$n.none}},{decorations:e=>e.decorations});const ng=wr.of([{key:"Tab",run:e=>{var t,n,r;const o=null==(t=e.state.field(Jp))?void 0:t.suggestion;if(!o)return!1;const s=e.state.facet(rg);var i,a,l,c;return e.dispatch({...(i=e.state,a=o,l=e.state.selection.main.head,c=e.state.selection.main.head,{...i.changeByRange((e=>{if(e===i.selection.main)return{changes:{from:l,to:c,insert:a},range:Fn.cursor(l+a.length)};const t=c-l;return!e.empty||t&&i.sliceDoc(e.from-t,e.from)!==i.sliceDoc(l,c)?{range:e}:{changes:{from:e.from-t,to:e.from,insert:a},range:Fn.cursor(e.from-t+a.length)}})),userEvent:"input.complete"})}),null==(r=null==(n=s.events)?void 0:n.onSuggestionAccepted)||r.call(n,e,o),!0}},{key:"Escape",run:e=>{var t,n,r;const o=null==(t=e.state.field(Jp))?void 0:t.suggestion;if(!o)return!1;const s=e.state.facet(rg);return e.dispatch({effects:Xp.of({text:null,doc:e.state.doc})}),null==(r=null==(n=s.events)?void 0:n.onSuggestionRejected)||r.call(n,e,o),!0}}]),rg=Cr.define({combine:e=>e.at(-1)});function og(e){const{delay:t=500,includeKeymap:n=!0}=e,r=function(e,t,n){let r=()=>{};return(...o)=>(r(),new Promise(((s,i)=>{const a=setTimeout((()=>s(e(...o))),t);r=()=>{clearTimeout(a),void 0!==n&&i(n)}})))}(e.fetchFn,t);return[Jp,rg.of(e),eg(r,e),tg,n?ng:[]]}const sg=Hn.define(),ig=Hn.define(),ag=Hn.define();function lg(e,t){if(!e)throw new Error(t)}function cg(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 dg(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 ug(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 hg=Symbol("@bufbuild/protobuf/enum-type");function fg(e){const t=e[hg];return lg(t,"missing enum type on enum object"),t}function mg(e,t,n,r){e[hg]=pg(t,n.map((t=>({no:t.no,name:t.name,localName:e[t.no]}))))}function pg(e,t,n){const r=Object.create(null),o=Object.create(null),s=[];for(const i of t){const e=yg(i);s.push(e),r[i.name]=e,o[i.no]=e}return{typeName:e,values:s,findName:e=>r[e],findNumber:e=>o[e]}}function gg(e,t,n){const r={};for(const o of t){const e=yg(o);r[e.localName]=e.no,r[e.no]=e.localName}return mg(r,e,t),r}function yg(e){return"localName"in e?e:Object.assign(Object.assign({},e),{localName:e.name})}class bg{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,r=n.makeReadOptions(t);return n.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,t){const n=this.getType(),r=n.runtime.json,o=r.makeReadOptions(t);return r.readMessage(n,e,o,this),this}fromJsonString(e,t){let n;try{n=JSON.parse(e)}catch(r){throw new Error(`cannot decode ${this.getType().typeName} from JSON: ${r instanceof Error?r.message:String(r)}`)}return this.fromJson(n,t)}toBinary(e){const t=this.getType().runtime.bin,n=t.makeWriteOptions(e),r=n.writerFactory();return t.writeMessage(this,r,n),r.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 xg(){let e=0,t=0;for(let r=0;r<28;r+=7){let n=this.buf[this.pos++];if(e|=(127&n)<<r,!(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 r=3;r<=31;r+=7){let n=this.buf[this.pos++];if(t|=(127&n)<<r,!(128&n))return this.assertBounds(),[e,t]}throw new Error("invalid varint")}function vg(e,t,n){for(let s=0;s<28;s+=7){const r=e>>>s,o=!(r>>>7==0&&0==t),i=255&(o?128|r:r);if(n.push(i),!o)return}const r=e>>>28&15|(7&t)<<4,o=!!(t>>3);if(n.push(255&(o?128|r:r)),o){for(let e=3;e<31;e+=7){const r=t>>>e,o=!(r>>>7==0),s=255&(o?128|r:r);if(n.push(s),!o)return}n.push(t>>>31&1)}}const wg=4294967296;function kg(e){const t="-"===e[0];t&&(e=e.slice(1));const n=1e6;let r=0,o=0;function s(t,s){const i=Number(e.slice(t,s));o*=n,r=r*n+i,r>=wg&&(o+=r/wg|0,r%=wg)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),t?Ng(r,o):Cg(r,o)}function Sg(e,t){if(({lo:e,hi:t}=function(e,t){return{lo:e>>>0,hi:t>>>0}}(e,t)),t<=2097151)return String(wg*t+e);const n=16777215&(e>>>24|t<<8),r=t>>16&65535;let o=(16777215&e)+6777216*n+6710656*r,s=n+8147497*r,i=2*r;const a=1e7;return o>=a&&(s+=Math.floor(o/a),o%=a),s>=a&&(i+=Math.floor(s/a),s%=a),i.toString()+Eg(s)+Eg(o)}function Cg(e,t){return{lo:0|e,hi:0|t}}function Ng(e,t){return t=~t,e?e=1+~e:t+=1,Cg(e,t)}const Eg=e=>{const t=String(e);return"0000000".slice(t.length)+t};function jg(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 _g(){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 Ig={};const Ag=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"!==Ig.BUF_BIGINT_DISABLE)){const t=BigInt("-9223372036854775808"),n=BigInt("9223372036854775807"),r=BigInt("0"),o=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(e){const r="bigint"==typeof e?e:BigInt(e);if(r>n||r<t)throw new Error(`int64 invalid: ${e}`);return r},uParse(e){const t="bigint"==typeof e?e:BigInt(e);if(t>o||t<r)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=>lg(/^-?[0-9]+$/.test(e),`int64 invalid: ${e}`),n=e=>lg(/^[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),kg(e)),uEnc:e=>("string"!=typeof e&&(e=e.toString()),n(e),kg(e)),dec:(e,t)=>function(e,t){let n=Cg(e,t);const r=2147483648&n.hi;r&&(n=Ng(n.lo,n.hi));const o=Sg(n.lo,n.hi);return r?"-"+o:o}(e,t),uDec:(e,t)=>Sg(e,t)}}();var Tg,Mg,Dg,Og,Rg,Pg;function Lg(e,t,n){if(t===n)return!0;if(e==Tg.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 Tg.UINT64:case Tg.FIXED64:case Tg.INT64:case Tg.SFIXED64:case Tg.SINT64:return t==n}return!1}function Fg(e,t){switch(e){case Tg.BOOL:return!1;case Tg.UINT64:case Tg.FIXED64:case Tg.INT64:case Tg.SFIXED64:case Tg.SINT64:return 0==t?Ag.zero:"0";case Tg.DOUBLE:case Tg.FLOAT:return 0;case Tg.BYTES:return new Uint8Array(0);case Tg.STRING:return"";default:return 0}}function zg(e,t){switch(e){case Tg.BOOL:return!1===t;case Tg.STRING:return""===t;case Tg.BYTES:return t instanceof Uint8Array&&!t.byteLength;default:return 0==t}}(Mg=Tg||(Tg={}))[Mg.DOUBLE=1]="DOUBLE",Mg[Mg.FLOAT=2]="FLOAT",Mg[Mg.INT64=3]="INT64",Mg[Mg.UINT64=4]="UINT64",Mg[Mg.INT32=5]="INT32",Mg[Mg.FIXED64=6]="FIXED64",Mg[Mg.FIXED32=7]="FIXED32",Mg[Mg.BOOL=8]="BOOL",Mg[Mg.STRING=9]="STRING",Mg[Mg.BYTES=12]="BYTES",Mg[Mg.UINT32=13]="UINT32",Mg[Mg.SFIXED32=15]="SFIXED32",Mg[Mg.SFIXED64=16]="SFIXED64",Mg[Mg.SINT32=17]="SINT32",Mg[Mg.SINT64=18]="SINT64",(Og=Dg||(Dg={}))[Og.BIGINT=0]="BIGINT",Og[Og.STRING=1]="STRING",(Pg=Rg||(Rg={}))[Pg.Varint=0]="Varint",Pg[Pg.Bit64=1]="Bit64",Pg[Pg.LengthDelimited=2]="LengthDelimited",Pg[Pg.StartGroup=3]="StartGroup",Pg[Pg.EndGroup=4]="EndGroup",Pg[Pg.Bit32=5]="Bit32";class Bg{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 r=0;r<this.chunks.length;r++)e+=this.chunks[r].length;let t=new Uint8Array(e),n=0;for(let r=0;r<this.chunks.length;r++)t.set(this.chunks[r],n),n+=this.chunks[r].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(dg(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return cg(e),jg(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){ug(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){dg(e);let t=new Uint8Array(4);return new DataView(t.buffer).setUint32(0,e,!0),this.raw(t)}sfixed32(e){cg(e);let t=new Uint8Array(4);return new DataView(t.buffer).setInt32(0,e,!0),this.raw(t)}sint32(e){return cg(e),jg(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Ag.enc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}fixed64(e){let t=new Uint8Array(8),n=new DataView(t.buffer),r=Ag.uEnc(e);return n.setInt32(0,r.lo,!0),n.setInt32(4,r.hi,!0),this.raw(t)}int64(e){let t=Ag.enc(e);return vg(t.lo,t.hi,this.buf),this}sint64(e){let t=Ag.enc(e),n=t.hi>>31;return vg(t.lo<<1^n,(t.hi<<1|t.lo>>>31)^n,this.buf),this}uint64(e){let t=Ag.uEnc(e);return vg(t.lo,t.hi,this.buf),this}}class Ug{constructor(e,t){this.varint64=xg,this.uint32=_g,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 Rg.Varint:for(;128&this.buf[this.pos++];);break;case Rg.Bit64:this.pos+=4;case Rg.Bit32:this.pos+=4;break;case Rg.LengthDelimited:let n=this.uint32();this.pos+=n;break;case Rg.StartGroup:for(;;){const[e,n]=this.tag();if(n===Rg.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 Ag.dec(...this.varint64())}uint64(){return Ag.uDec(...this.varint64())}sint64(){let[e,t]=this.varint64(),n=-(1&e);return e=(e>>>1|(1&t)<<31)^n,t=t>>>1^n,Ag.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 Ag.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return Ag.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 $g(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 Fg(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 Vg="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Hg=[];for(let IK=0;IK<Vg.length;IK++)Hg[Vg[IK].charCodeAt(0)]=IK;Hg["-".charCodeAt(0)]=Vg.indexOf("+"),Hg["_".charCodeAt(0)]=Vg.indexOf("/");const Wg={dec(e){let t=3*e.length/4;"="==e[e.length-2]?t-=2:"="==e[e.length-1]&&(t-=1);let n,r=new Uint8Array(t),o=0,s=0,i=0;for(let a=0;a<e.length;a++){if(n=Hg[e.charCodeAt(a)],void 0===n)switch(e[a]){case"=":s=0;case"\n":case"\r":case"\t":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:i=n,s=1;break;case 1:r[o++]=i<<2|(48&n)>>4,i=n,s=2;break;case 2:r[o++]=(15&i)<<4|(60&n)>>2,i=n,s=3;break;case 3:r[o++]=(3&i)<<6|n,s=0}}if(1==s)throw Error("invalid base64 string.");return r.subarray(0,o)},enc(e){let t,n="",r=0,o=0;for(let s=0;s<e.length;s++)switch(t=e[s],r){case 0:n+=Vg[t>>2],o=(3&t)<<4,r=1;break;case 1:n+=Vg[o|t>>4],o=(15&t)<<2,r=2;break;case 2:n+=Vg[o|t>>6],n+=Vg[63&t],r=0}return r&&(n+=Vg[o],n+="=",1==r&&(n+="=")),n}};function Gg(e,t,n){Kg(t,e);const r=t.runtime.bin.makeReadOptions(n),o=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),[s,i]=$g(t);for(const a of o)t.runtime.bin.readField(s,r.readerFactory(a.data),t.field,a.wireType,r);return i()}function qg(e,t,n,r){Kg(t,e);const o=t.runtime.bin.makeReadOptions(r),s=t.runtime.bin.makeWriteOptions(r);if(Yg(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=s.writerFactory();let a=t.field;a.opt||a.repeated||"enum"!=a.kind&&"scalar"!=a.kind||(a=Object.assign(Object.assign({},t.field),{opt:!0})),t.runtime.bin.writeField(a,n,i,s);const l=o.readerFactory(i.finish());for(;l.pos<l.len;){const[t,n]=l.tag(),r=l.skip(n,t);e.getType().runtime.bin.onUnknownField(e,t,n,r)}}function Yg(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 Kg(e,t){lg(e.extendee.typeName==t.getType().typeName,`extension ${e.typeName} can only be applied to message ${e.extendee.typeName}`)}function Jg(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:!zg(e.T,t[n]);case"message":return void 0!==t[n];case"map":return Object.keys(t[n]).length>0}}function Xg(e,t){const n=e.localName,r=!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]=r?e.T.values[0].no:void 0;break;case"scalar":t[n]=r?Fg(e.T,e.L):void 0;break;case"message":t[n]=void 0}}function Zg(e,t){if(null===e||"object"!=typeof e)return!1;if(!Object.getOwnPropertyNames(bg.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 Qg(e,t){return Zg(t)||!e.fieldWrapper?t:e.fieldWrapper.wrapField(t)}Tg.DOUBLE,Tg.FLOAT,Tg.INT64,Tg.UINT64,Tg.INT32,Tg.UINT32,Tg.BOOL,Tg.STRING,Tg.BYTES;const ey={ignoreUnknownFields:!1},ty={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function ny(e){return e?Object.assign(Object.assign({},ey),e):ey}function ry(e){return e?Object.assign(Object.assign({},ty),e):ty}const oy=Symbol(),sy=Symbol();function iy(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 ay(e,t,n,r,o){let s=n.localName;if(n.repeated){if(lg("map"!=n.kind),null===t)return;if(!Array.isArray(t))throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: ${iy(t)}`);const a=e[s];for(const e of t){if(null===e)throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: ${iy(e)}`);switch(n.kind){case"message":a.push(n.T.fromJson(e,r));break;case"enum":const t=dy(n.T,e,r.ignoreUnknownFields,!0);t!==sy&&a.push(t);break;case"scalar":try{a.push(cy(n.T,e,n.L,!0))}catch(i){let t=`cannot decode field ${o.typeName}.${n.name} from JSON: ${iy(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 ${o.typeName}.${n.name} from JSON: ${iy(t)}`);const a=e[s];for(const[e,s]of Object.entries(t)){if(null===s)throw new Error(`cannot decode field ${o.typeName}.${n.name} from JSON: map value null`);let l;try{l=ly(n.K,e)}catch(i){let e=`cannot decode map key for field ${o.typeName}.${n.name} from JSON: ${iy(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}switch(n.V.kind){case"message":a[l]=n.V.T.fromJson(s,r);break;case"enum":const e=dy(n.V.T,s,r.ignoreUnknownFields,!0);e!==sy&&(a[l]=e);break;case"scalar":try{a[l]=cy(n.V.T,s,Dg.BIGINT,!0)}catch(i){let e=`cannot decode map value for field ${o.typeName}.${n.name} from JSON: ${iy(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:s},s="value"),n.kind){case"message":const a=n.T;if(null===t&&"google.protobuf.Value"!=a.typeName)return;let l=e[s];Zg(l)?l.fromJson(t,r):(e[s]=l=a.fromJson(t,r),a.fieldWrapper&&!n.oneof&&(e[s]=a.fieldWrapper.unwrapField(l)));break;case"enum":const c=dy(n.T,t,r.ignoreUnknownFields,!1);switch(c){case oy:Xg(n,e);break;case sy:break;default:e[s]=c}break;case"scalar":try{const r=cy(n.T,t,n.L,!1);if(r===oy)Xg(n,e);else e[s]=r}catch(i){let e=`cannot decode field ${o.typeName}.${n.name} from JSON: ${iy(t)}`;throw i instanceof Error&&i.message.length>0&&(e+=`: ${i.message}`),new Error(e)}}}function ly(e,t){if(e===Tg.BOOL)switch(t){case"true":t=!0;break;case"false":t=!1}return cy(e,t,Dg.BIGINT,!0).toString()}function cy(e,t,n,r){if(null===t)return r?Fg(e,n):oy;switch(e){case Tg.DOUBLE:case Tg.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 r=Number(t);if(Number.isNaN(r))break;if(!Number.isFinite(r))break;return e==Tg.FLOAT&&ug(r),r;case Tg.INT32:case Tg.FIXED32:case Tg.SFIXED32:case Tg.SINT32:case Tg.UINT32:let s;if("number"==typeof t?s=t:"string"==typeof t&&t.length>0&&t.trim().length===t.length&&(s=Number(t)),void 0===s)break;return e==Tg.UINT32||e==Tg.FIXED32?dg(s):cg(s),s;case Tg.INT64:case Tg.SFIXED64:case Tg.SINT64:if("number"!=typeof t&&"string"!=typeof t)break;const i=Ag.parse(t);return n?i.toString():i;case Tg.FIXED64:case Tg.UINT64:if("number"!=typeof t&&"string"!=typeof t)break;const a=Ag.uParse(t);return n?a.toString():a;case Tg.BOOL:if("boolean"!=typeof t)break;return t;case Tg.STRING:if("string"!=typeof t)break;try{encodeURIComponent(t)}catch(o){throw new Error("invalid UTF8")}return t;case Tg.BYTES:if(""===t)return new Uint8Array(0);if("string"!=typeof t)break;return Wg.dec(t)}throw new Error}function dy(e,t,n,r){if(null===t)return"google.protobuf.NullValue"==e.typeName?0:r?e.values[0].no:oy;switch(typeof t){case"number":if(Number.isInteger(t))return t;break;case"string":const r=e.findName(t);if(void 0!==r)return r.no;if(n)return sy}throw new Error(`cannot decode enum ${e.typeName} from JSON: ${iy(t)}`)}function uy(e){return!(!e.repeated&&"map"!=e.kind)||!e.oneof&&("message"!=e.kind&&(!e.opt&&!e.req))}function hy(e,t,n){if("map"==e.kind){lg("object"==typeof t&&null!=t);const r={},o=Object.entries(t);switch(e.V.kind){case"scalar":for(const[n,s]of o)r[n.toString()]=my(e.V.T,s);break;case"message":for(const[e,s]of o)r[e.toString()]=s.toJson(n);break;case"enum":const t=e.V.T;for(const[e,s]of o)r[e.toString()]=fy(t,s,n.enumAsInteger)}return n.emitDefaultValues||o.length>0?r:void 0}if(e.repeated){lg(Array.isArray(t));const r=[];switch(e.kind){case"scalar":for(let n=0;n<t.length;n++)r.push(my(e.T,t[n]));break;case"enum":for(let o=0;o<t.length;o++)r.push(fy(e.T,t[o],n.enumAsInteger));break;case"message":for(let e=0;e<t.length;e++)r.push(t[e].toJson(n))}return n.emitDefaultValues||r.length>0?r:void 0}switch(e.kind){case"scalar":return my(e.T,t);case"enum":return fy(e.T,t,n.enumAsInteger);case"message":return Qg(e.T,t).toJson(n)}}function fy(e,t,n){var r;if(lg("number"==typeof t),"google.protobuf.NullValue"==e.typeName)return null;if(n)return t;const o=e.findNumber(t);return null!==(r=null==o?void 0:o.name)&&void 0!==r?r:t}function my(e,t){switch(e){case Tg.INT32:case Tg.SFIXED32:case Tg.SINT32:case Tg.FIXED32:case Tg.UINT32:return lg("number"==typeof t),t;case Tg.FLOAT:case Tg.DOUBLE:return lg("number"==typeof t),Number.isNaN(t)?"NaN":t===Number.POSITIVE_INFINITY?"Infinity":t===Number.NEGATIVE_INFINITY?"-Infinity":t;case Tg.STRING:return lg("string"==typeof t),t;case Tg.BOOL:return lg("boolean"==typeof t),t;case Tg.UINT64:case Tg.FIXED64:case Tg.INT64:case Tg.SFIXED64:case Tg.SINT64:return lg("bigint"==typeof t||"string"==typeof t||"number"==typeof t),t.toString();case Tg.BYTES:return lg(t instanceof Uint8Array),Wg.enc(t)}}const py=Symbol("@bufbuild/protobuf/unknown-fields"),gy={readUnknownFields:!0,readerFactory:e=>new Ug(e)},yy={writeUnknownFields:!0,writerFactory:()=>new Bg};function by(e){return e?Object.assign(Object.assign({},gy),e):gy}function xy(e){return e?Object.assign(Object.assign({},yy),e):yy}function vy(e,t,n,r,o){let{repeated:s,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 a="enum"==n.kind?Tg.INT32:n.T;let l=Sy;if("scalar"==n.kind&&n.L>0&&(l=ky),s){let n=e[i];if(r==Rg.LengthDelimited&&a!=Tg.STRING&&a!=Tg.BYTES){let e=t.uint32()+t.pos;for(;t.pos<e;)n.push(l(t,a))}else n.push(l(t,a))}else e[i]=l(t,a);break;case"message":const c=n.T;s?e[i].push(wy(t,new c,o,n)):Zg(e[i])?wy(t,e[i],o,n):(e[i]=wy(t,new c,o,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 r=t.uint32(),o=t.pos+r;let s,i;for(;t.pos<o;){const[r]=t.tag();switch(r){case 1:s=Sy(t,e.K);break;case 2:switch(e.V.kind){case"scalar":i=Sy(t,e.V.T);break;case"enum":i=t.int32();break;case"message":i=wy(t,new e.V.T,n,void 0)}}}void 0===s&&(s=Fg(e.K,Dg.BIGINT));"string"!=typeof s&&"number"!=typeof s&&(s=s.toString());if(void 0===i)switch(e.V.kind){case"scalar":i=Fg(e.V.T,Dg.BIGINT);break;case"enum":i=e.V.T.values[0].no;break;case"message":i=new e.V.T}return[s,i]}(n,t,o);e[i][d]=u}}function wy(e,t,n,r){const o=t.getType().runtime.bin,s=null==r?void 0:r.delimited;return o.readMessage(t,e,s?r.no:e.uint32(),n,s),t}function ky(e,t){const n=Sy(e,t);return"bigint"==typeof n?n.toString():n}function Sy(e,t){switch(t){case Tg.STRING:return e.string();case Tg.BOOL:return e.bool();case Tg.DOUBLE:return e.double();case Tg.FLOAT:return e.float();case Tg.INT32:return e.int32();case Tg.INT64:return e.int64();case Tg.UINT64:return e.uint64();case Tg.FIXED64:return e.fixed64();case Tg.BYTES:return e.bytes();case Tg.FIXED32:return e.fixed32();case Tg.SFIXED32:return e.sfixed32();case Tg.SFIXED64:return e.sfixed64();case Tg.SINT64:return e.sint64();case Tg.UINT32:return e.uint32();case Tg.SINT32:return e.sint32()}}function Cy(e,t,n,r){lg(void 0!==t);const o=e.repeated;switch(e.kind){case"scalar":case"enum":let s="enum"==e.kind?Tg.INT32:e.T;if(o)if(lg(Array.isArray(t)),e.packed)!function(e,t,n,r){if(!r.length)return;e.tag(n,Rg.LengthDelimited).fork();let[,o]=_y(t);for(let s=0;s<r.length;s++)e[o](r[s]);e.join()}(n,s,e.no,t);else for(const r of t)jy(n,s,e.no,r);else jy(n,s,e.no,t);break;case"message":if(o){lg(Array.isArray(t));for(const o of t)Ey(n,r,e,o)}else Ey(n,r,e,t);break;case"map":lg("object"==typeof t&&null!=t);for(const[o,i]of Object.entries(t))Ny(n,r,e,o,i)}}function Ny(e,t,n,r,o){e.tag(n.no,Rg.LengthDelimited),e.fork();let s=r;switch(n.K){case Tg.INT32:case Tg.FIXED32:case Tg.UINT32:case Tg.SFIXED32:case Tg.SINT32:s=Number.parseInt(r);break;case Tg.BOOL:lg("true"==r||"false"==r),s="true"==r}switch(jy(e,n.K,1,s),n.V.kind){case"scalar":jy(e,n.V.T,2,o);break;case"enum":jy(e,Tg.INT32,2,o);break;case"message":lg(void 0!==o),e.tag(2,Rg.LengthDelimited).bytes(o.toBinary(t))}e.join()}function Ey(e,t,n,r){const o=Qg(n.T,r);n.delimited?e.tag(n.no,Rg.StartGroup).raw(o.toBinary(t)).tag(n.no,Rg.EndGroup):e.tag(n.no,Rg.LengthDelimited).bytes(o.toBinary(t))}function jy(e,t,n,r){lg(void 0!==r);let[o,s]=_y(t);e.tag(n,o)[s](r)}function _y(e){let t=Rg.Varint;switch(e){case Tg.BYTES:case Tg.STRING:t=Rg.LengthDelimited;break;case Tg.DOUBLE:case Tg.FIXED64:case Tg.SFIXED64:t=Rg.Bit64;break;case Tg.FIXED32:case Tg.SFIXED32:case Tg.FLOAT:t=Rg.Bit32}return[t,Tg[e].toLowerCase()]}function Iy(e){if(void 0===e)return e;if(Zg(e))return e.clone();if(e instanceof Uint8Array){const t=new Uint8Array(e.byteLength);return t.set(e),t}return e}function Ay(e){return e instanceof Uint8Array?e:new Uint8Array(e)}class Ty{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 My(e,t){const n=Oy(e);return t?n:zy(Fy(n))}const Dy=Oy;function Oy(e){let t=!1;const n=[];for(let r=0;r<e.length;r++){let o=e.charAt(r);switch(o){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(o),t=!1;break;default:t&&(t=!1,o=o.toUpperCase()),n.push(o)}}return n.join("")}const Ry=new Set(["constructor","toString","toJSON","valueOf"]),Py=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),Ly=e=>`${e}$`,Fy=e=>Py.has(e)?Ly(e):e,zy=e=>Ry.has(e)?Ly(e):e;class By{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=My(e,!1)}addField(e){lg(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 Uy=($y=e=>new Ty(e,(e=>function(e){var t,n,r,o,s,i;const a=[];let l;for(const c of"function"==typeof e?e():e){const e=c;if(e.localName=My(c.name,void 0!==c.oneof),e.jsonName=null!==(t=c.jsonName)&&void 0!==t?t:Dy(c.name),e.repeated=null!==(n=c.repeated)&&void 0!==n&&n,"scalar"==c.kind&&(e.L=null!==(r=c.L)&&void 0!==r?r:Dg.BIGINT),e.delimited=null!==(o=c.delimited)&&void 0!==o&&o,e.req=null!==(s=c.req)&&void 0!==s&&s,e.opt=null!==(i=c.opt)&&void 0!==i&&i,void 0===c.packed&&(e.packed="enum"==c.kind||"scalar"==c.kind&&c.T!=Tg.BYTES&&c.T!=Tg.STRING),void 0!==c.oneof){const t="string"==typeof c.oneof?c.oneof:c.oneof.name;l&&l.name==t||(l=new By(t)),e.oneof=l,l.addField(e)}a.push(e)}return a}(e))),Vy=e=>{for(const t of e.getType().fields.byMember()){if(t.opt)continue;const n=t.localName,r=e;if(t.repeated)r[n]=[];else switch(t.kind){case"oneof":r[n]={case:void 0};break;case"enum":r[n]=0;break;case"map":r[n]={};break;case"scalar":r[n]=Fg(t.T,t.L)}}},{syntax:"proto3",json:{makeReadOptions:ny,makeWriteOptions:ry,readMessage(e,t,n,r){if(null==t||Array.isArray(t)||"object"!=typeof t)throw new Error(`cannot decode message ${e.typeName} from JSON: ${iy(t)}`);r=null!=r?r:new e;const o=new Map,s=n.typeRegistry;for(const[i,a]of Object.entries(t)){const t=e.fields.findJsonName(i);if(t){if(t.oneof){if(null===a&&"scalar"==t.kind)continue;const n=o.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}"`);o.set(t.oneof,i)}ay(r,a,t,n,e)}else{let t=!1;if((null==s?void 0:s.findExtension)&&i.startsWith("[")&&i.endsWith("]")){const o=s.findExtension(i.substring(1,i.length-1));if(o&&o.extendee.typeName==e.typeName){t=!0;const[e,s]=$g(o);ay(e,a,o.field,n,o),qg(r,o,s(),n)}}if(!t&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${e.typeName} from JSON: key "${i}" is unknown`)}}return r},writeMessage(e,t){const n=e.getType(),r={};let o;try{for(o of n.fields.byNumber()){if(!Jg(o,e)){if(o.req)throw"required field not set";if(!t.emitDefaultValues)continue;if(!uy(o))continue}const n=hy(o,o.oneof?e[o.oneof.localName].value:e[o.localName],t);void 0!==n&&(r[t.useProtoFieldName?o.name:o.jsonName]=n)}const s=t.typeRegistry;if(null==s?void 0:s.findExtensionFor)for(const o of n.runtime.bin.listUnknownFields(e)){const i=s.findExtensionFor(n.typeName,o.no);if(i&&Yg(e,i)){const n=Gg(e,i,t),o=hy(i.field,n,t);void 0!==o&&(r[i.field.jsonName]=o)}}}catch(s){const e=o?`cannot encode field ${n.typeName}.${o.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,t=s instanceof Error?s.message:String(s);throw new Error(e+(t.length>0?`: ${t}`:""))}return r},readScalar:(e,t,n)=>cy(e,t,null!=n?n:Dg.BIGINT,!0),writeScalar(e,t,n){if(void 0!==t)return n||zg(e,t)?my(e,t):void 0},debug:iy},bin:{makeReadOptions:by,makeWriteOptions:xy,listUnknownFields(e){var t;return null!==(t=e[py])&&void 0!==t?t:[]},discardUnknownFields(e){delete e[py]},writeUnknownFields(e,t){const n=e[py];if(n)for(const r of n)t.tag(r.no,r.wireType).raw(r.data)},onUnknownField(e,t,n,r){const o=e;Array.isArray(o[py])||(o[py]=[]),o[py].push({no:t,wireType:n,data:r})},readMessage(e,t,n,r,o){const s=e.getType(),i=o?t.len:t.pos+n;let a,l;for(;t.pos<i&&([a,l]=t.tag(),!0!==o||l!=Rg.EndGroup);){const n=s.fields.find(a);if(n)vy(e,t,n,l,r);else{const n=t.skip(l,a);r.readUnknownFields&&this.onUnknownField(e,a,l,n)}}if(o&&(l!=Rg.EndGroup||a!==n))throw new Error("invalid end group tag")},readField:vy,writeMessage(e,t,n){const r=e.getType();for(const o of r.fields.byNumber())if(Jg(o,e))Cy(o,o.oneof?e[o.oneof.localName].value:e[o.localName],t,n);else if(o.req)throw new Error(`cannot encode field ${r.typeName}.${o.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(e,t),t},writeField(e,t,n,r){void 0!==t&&Cy(e,t,n,r)}},util:Object.assign(Object.assign({},{setEnumType:mg,initPartial(e,t){if(void 0===e)return;const n=t.getType();for(const r of n.fields.byMember()){const n=r.localName,o=t,s=e;if(null!=s[n])switch(r.kind){case"oneof":const e=s[n].case;if(void 0===e)continue;const t=r.findField(e);let i=s[n].value;t&&"message"==t.kind&&!Zg(i,t.T)?i=new t.T(i):t&&"scalar"===t.kind&&t.T===Tg.BYTES&&(i=Ay(i)),o[n]={case:e,value:i};break;case"scalar":case"enum":let a=s[n];r.T===Tg.BYTES&&(a=r.repeated?a.map(Ay):Ay(a)),o[n]=a;break;case"map":switch(r.V.kind){case"scalar":case"enum":if(r.V.T===Tg.BYTES)for(const[t,r]of Object.entries(s[n]))o[n][t]=Ay(r);else Object.assign(o[n],s[n]);break;case"message":const e=r.V.T;for(const t of Object.keys(s[n])){let r=s[n][t];e.fieldWrapper||(r=new e(r)),o[n][t]=r}}break;case"message":const l=r.T;if(r.repeated)o[n]=s[n].map((e=>Zg(e,l)?e:new l(e)));else{const e=s[n];l.fieldWrapper?"google.protobuf.BytesValue"===l.typeName?o[n]=Ay(e):o[n]=e:o[n]=Zg(e,l)?e:new l(e)}}}},equals:(e,t,n)=>t===n||!(!t||!n)&&e.fields.byMember().every((e=>{const r=t[e.localName],o=n[e.localName];if(e.repeated){if(r.length!==o.length)return!1;switch(e.kind){case"message":return r.every(((t,n)=>e.T.equals(t,o[n])));case"scalar":return r.every(((t,n)=>Lg(e.T,t,o[n])));case"enum":return r.every(((e,t)=>Lg(Tg.INT32,e,o[t])))}throw new Error(`repeated cannot contain ${e.kind}`)}switch(e.kind){case"message":return e.T.equals(r,o);case"enum":return Lg(Tg.INT32,r,o);case"scalar":return Lg(e.T,r,o);case"oneof":if(r.case!==o.case)return!1;const t=e.findField(r.case);if(void 0===t)return!0;switch(t.kind){case"message":return t.T.equals(r.value,o.value);case"enum":return Lg(Tg.INT32,r.value,o.value);case"scalar":return Lg(t.T,r.value,o.value)}throw new Error(`oneof cannot contain ${t.kind}`);case"map":const n=Object.keys(r).concat(Object.keys(o));switch(e.V.kind){case"message":const t=e.V.T;return n.every((e=>t.equals(r[e],o[e])));case"enum":return n.every((e=>Lg(Tg.INT32,r[e],o[e])));case"scalar":const s=e.V.T;return n.every((e=>Lg(s,r[e],o[e])))}}})),clone(e){const t=e.getType(),n=new t,r=n;for(const o of t.fields.byMember()){const t=e[o.localName];let n;if(o.repeated)n=t.map(Iy);else if("map"==o.kind){n=r[o.localName];for(const[e,r]of Object.entries(t))n[e]=Iy(r)}else n="oneof"==o.kind?o.findField(t.case)?{case:t.case,value:Iy(t.value)}:{case:void 0}:Iy(t);r[o.localName]=n}for(const o of t.runtime.bin.listUnknownFields(e))t.runtime.bin.onUnknownField(r,o.no,o.wireType,o.data);return n}}),{newFieldList:$y,initFields:Vy}),makeMessageType(e,t,n){return function(e,t,n,r){var o;const s=null!==(o=null==r?void 0:r.localName)&&void 0!==o?o:t.substring(t.lastIndexOf(".")+1),i={[s]:function(t){e.util.initFields(this),e.util.initPartial(t,this)}}[s];return Object.setPrototypeOf(i.prototype,new bg),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:gg,makeEnumType:pg,getEnumType:fg,makeExtension(e,t,n){return function(e,t,n,r){let o;return{typeName:t,extendee:n,get field(){if(!o){const n="function"==typeof r?r():r;n.name=t.split(".").pop(),n.jsonName=`[${t}]`,o=e.util.newFieldList([n]).list()[0]}return o},runtime:e}}(this,e,t,n)}});var $y,Vy,Hy,Wy,Gy,qy,Yy,Ky,Jy,Xy,Zy,Qy,eb,tb,nb,rb;(Wy=Hy||(Hy={}))[Wy.Unary=0]="Unary",Wy[Wy.ServerStreaming=1]="ServerStreaming",Wy[Wy.ClientStreaming=2]="ClientStreaming",Wy[Wy.BiDiStreaming=3]="BiDiStreaming",(qy=Gy||(Gy={}))[qy.NoSideEffects=1]="NoSideEffects",qy[qy.Idempotent=2]="Idempotent",(Ky=Yy||(Yy={}))[Ky.UNSPECIFIED=0]="UNSPECIFIED",Ky[Ky.JUPYTER_FORMAT=77]="JUPYTER_FORMAT",Uy.util.setEnumType(Yy,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),(Xy=Jy||(Jy={}))[Xy.CODEIUM=0]="CODEIUM",Uy.util.setEnumType(Jy,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),(Qy=Zy||(Zy={}))[Qy.UNSPECIFIED=0]="UNSPECIFIED",Qy[Qy.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",Qy[Qy.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",Qy[Qy.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",Qy[Qy.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION",Uy.util.setEnumType(Zy,"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"}]),(tb=eb||(eb={}))[tb.UNSPECIFIED=0]="UNSPECIFIED",tb[tb.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",tb[tb.CACHE=2]="CACHE",tb[tb.NETWORK=3]="NETWORK",Uy.util.setEnumType(eb,"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"}]),(rb=nb||(nb={}))[rb.UNSPECIFIED=0]="UNSPECIFIED",rb[rb.C=1]="C",rb[rb.CLOJURE=2]="CLOJURE",rb[rb.COFFEESCRIPT=3]="COFFEESCRIPT",rb[rb.CPP=4]="CPP",rb[rb.CSHARP=5]="CSHARP",rb[rb.CSS=6]="CSS",rb[rb.CUDACPP=7]="CUDACPP",rb[rb.DOCKERFILE=8]="DOCKERFILE",rb[rb.GO=9]="GO",rb[rb.GROOVY=10]="GROOVY",rb[rb.HANDLEBARS=11]="HANDLEBARS",rb[rb.HASKELL=12]="HASKELL",rb[rb.HCL=13]="HCL",rb[rb.HTML=14]="HTML",rb[rb.INI=15]="INI",rb[rb.JAVA=16]="JAVA",rb[rb.JAVASCRIPT=17]="JAVASCRIPT",rb[rb.JSON=18]="JSON",rb[rb.JULIA=19]="JULIA",rb[rb.KOTLIN=20]="KOTLIN",rb[rb.LATEX=21]="LATEX",rb[rb.LESS=22]="LESS",rb[rb.LUA=23]="LUA",rb[rb.MAKEFILE=24]="MAKEFILE",rb[rb.MARKDOWN=25]="MARKDOWN",rb[rb.OBJECTIVEC=26]="OBJECTIVEC",rb[rb.OBJECTIVECPP=27]="OBJECTIVECPP",rb[rb.PERL=28]="PERL",rb[rb.PHP=29]="PHP",rb[rb.PLAINTEXT=30]="PLAINTEXT",rb[rb.PROTOBUF=31]="PROTOBUF",rb[rb.PBTXT=32]="PBTXT",rb[rb.PYTHON=33]="PYTHON",rb[rb.R=34]="R",rb[rb.RUBY=35]="RUBY",rb[rb.RUST=36]="RUST",rb[rb.SASS=37]="SASS",rb[rb.SCALA=38]="SCALA",rb[rb.SCSS=39]="SCSS",rb[rb.SHELL=40]="SHELL",rb[rb.SQL=41]="SQL",rb[rb.STARLARK=42]="STARLARK",rb[rb.SWIFT=43]="SWIFT",rb[rb.TSX=44]="TSX",rb[rb.TYPESCRIPT=45]="TYPESCRIPT",rb[rb.VISUALBASIC=46]="VISUALBASIC",rb[rb.VUE=47]="VUE",rb[rb.XML=48]="XML",rb[rb.XSL=49]="XSL",rb[rb.YAML=50]="YAML",rb[rb.SVELTE=51]="SVELTE",rb[rb.TOML=52]="TOML",rb[rb.DART=53]="DART",rb[rb.RST=54]="RST",rb[rb.OCAML=55]="OCAML",rb[rb.CMAKE=56]="CMAKE",rb[rb.PASCAL=57]="PASCAL",rb[rb.ELIXIR=58]="ELIXIR",rb[rb.FSHARP=59]="FSHARP",rb[rb.LISP=60]="LISP",rb[rb.MATLAB=61]="MATLAB",rb[rb.POWERSHELL=62]="POWERSHELL",rb[rb.SOLIDITY=63]="SOLIDITY",rb[rb.ADA=64]="ADA",rb[rb.OCAML_INTERFACE=65]="OCAML_INTERFACE",Uy.util.setEnumType(nb,"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 ob=class e extends bg{constructor(e){super(),s(this,"completionId",""),s(this,"text",""),s(this,"prefix",""),s(this,"stop",""),s(this,"score",0),s(this,"tokens",[]),s(this,"decodedTokens",[]),s(this,"probabilities",[]),s(this,"adjustedProbabilities",[]),s(this,"generatedLength",Ag.zero),Uy.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 Uy.util.equals(e,t,n)}};s(ob,"runtime",Uy),s(ob,"typeName","exa.codeium_common_pb.Completion"),s(ob,"fields",Uy.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 sb=ob;const ib=class e extends bg{constructor(e){super(),s(this,"ideName",""),s(this,"ideVersion",""),s(this,"extensionName",""),s(this,"extensionVersion",""),s(this,"apiKey",""),s(this,"locale",""),s(this,"sessionId",""),s(this,"requestId",Ag.zero),s(this,"userAgent",""),s(this,"url",""),s(this,"authSource",Jy.CODEIUM),Uy.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 Uy.util.equals(e,t,n)}};s(ib,"runtime",Uy),s(ib,"typeName","exa.codeium_common_pb.Metadata"),s(ib,"fields",Uy.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:Uy.getEnumType(Jy)}])));let ab=ib;const lb=class e extends bg{constructor(e){super(),s(this,"tabSize",Ag.zero),s(this,"insertSpaces",!1),Uy.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 Uy.util.equals(e,t,n)}};s(lb,"runtime",Uy),s(lb,"typeName","exa.codeium_common_pb.EditorOptions"),s(lb,"fields",Uy.util.newFieldList((()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}])));let cb=lb;n=class extends bg{constructor(e){super(),s(this,"eventType",Zy.UNSPECIFIED),s(this,"eventJson",""),s(this,"timestampUnixMs",Ag.zero),Uy.util.initPartial(e,this)}static fromBinary(e,t){return(new n).fromBinary(e,t)}static fromJson(e,t){return(new n).fromJson(e,t)}static fromJsonString(e,t){return(new n).fromJsonString(e,t)}static equals(e,t){return Uy.util.equals(n,e,t)}},s(n,"runtime",Uy),s(n,"typeName","exa.codeium_common_pb.Event"),s(n,"fields",Uy.util.newFieldList((()=>[{no:1,name:"event_type",kind:"enum",T:Uy.getEnumType(Zy)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}])));class db extends Er{constructor(e,t){super(),s(this,"index"),s(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 ub=Cr.define({combine:e=>Nr(e,{language:nb.TYPESCRIPT,timeout:150,widgetClass:db,alwaysOn:!0},{})}),hb=Cr.define({combine:e=>Nr(e,{override:()=>[]},{})}),fb=$n.mark({class:"cm-ghostText"}),mb=Un.define({create:e=>null,update(e,t){var n;const r=t.state.facet(ub);for(const o of t.effects){if(o.is(sg)){const{changeSpecs:e,index:t}=o.value,s=e[t].map((e=>fb.range(e.absoluteStartPos,e.absoluteEndPos))),i=null==(n=s.at(-1))?void 0:n.to;return{index:t,decorations:$n.set([...s,...void 0!==i&&e.length>1&&r.widgetClass?[$n.widget({widget:new r.widgetClass(t,e.length),side:1}).range(i)]:[]]),changeSpecs:e,reverseChangeSet:o.value.reverseChangeSet}}if(o.is(ig))return null;if(o.is(ag))return null}return e?{...e,decorations:e.decorations.map(t.changes),reverseChangeSet:e.reverseChangeSet.map(t.changes)}:e},provide:e=>zn.decorations.from(e,(e=>(null==e?void 0:e.decorations)||$n.none))}),pb=_r.define(),gb=_r.define();var yb,bb;function xb(e){const t=yb[e];return"string"!=typeof t?e.toString():t[0].toLowerCase()+t.substring(1).replace(/[A-Z]/g,(e=>"_"+e.toLowerCase()))}let vb;(bb=yb||(yb={}))[bb.Canceled=1]="Canceled",bb[bb.Unknown=2]="Unknown",bb[bb.InvalidArgument=3]="InvalidArgument",bb[bb.DeadlineExceeded=4]="DeadlineExceeded",bb[bb.NotFound=5]="NotFound",bb[bb.AlreadyExists=6]="AlreadyExists",bb[bb.PermissionDenied=7]="PermissionDenied",bb[bb.ResourceExhausted=8]="ResourceExhausted",bb[bb.FailedPrecondition=9]="FailedPrecondition",bb[bb.Aborted=10]="Aborted",bb[bb.OutOfRange=11]="OutOfRange",bb[bb.Unimplemented=12]="Unimplemented",bb[bb.Internal=13]="Internal",bb[bb.Unavailable=14]="Unavailable",bb[bb.DataLoss=15]="DataLoss",bb[bb.Unauthenticated=16]="Unauthenticated";class wb extends Error{constructor(e,t=yb.Unknown,n,r,o){super(function(e,t){return e.length?`[${xb(t)}] ${e}`:`[${xb(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!=r?r:[],this.cause=o}static from(e,t=yb.Unknown){return e instanceof wb?e:e instanceof Error?"AbortError"==e.name?new wb(e.message,yb.Canceled):new wb(e.message,t,void 0,void 0,e):new wb(String(e),t,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===wb.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 o of this.details){if("getType"in o){t.findMessage(o.getType().typeName)&&n.push(o);continue}const e=t.findMessage(o.type);if(e)try{n.push(e.fromBinary(o.value))}catch(r){}}return n}}var kb=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={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},Sb=function(e){return this instanceof Sb?(this.v=e,this):new Sb(e)},Cb=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof Sb?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};function Nb(e){return Cb(this,arguments,(function*(){yield Sb(yield*function(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:Sb(e[r](t)),done:!1}:o?o(t):t}:o}}(kb(e)))}))}var Eb=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={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,o){(function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)})(r,o,(t=e[n](t)).done,t.value)}))}}},jb=function(e){return this instanceof jb?(this.v=e,this):new jb(e)},_b=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof jb?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};function Ib(e,t){const n=function(){var n,r;return _b(this,arguments,(function*(){const o=yield jb(e);null===(n=null==t?void 0:t.onHeader)||void 0===n||n.call(t,o.header),yield jb(yield*function(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,o){t[r]=e[r]?function(t){return(n=!n)?{value:jb(e[r](t)),done:!1}:o?o(t):t}:o}}(Eb(o.message))),null===(r=null==t?void 0:t.onTrailer)||void 0===r||r.call(t,o.trailer)}))}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Ab(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 Tb(){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 Mb(e,t,n){const r="string"==typeof t?t:t.typeName,o="string"==typeof n?n:n.name;return e.toString().replace(/\/?$/,`/${r}/${o}`)}function Db(e,t){return t instanceof e?t:new e(t)}function Ob(e,t){function n(t){return!0===t.done?t:{done:t.done,value:Db(e,t.value)}}return{[Symbol.asyncIterator](){const e=t[Symbol.asyncIterator](),r={next:()=>e.next().then(n)};return void 0!==e.throw&&(r.throw=t=>e.throw(t).then(n)),void 0!==e.return&&(r.return=t=>e.return(t).then(n)),r}}}function Rb(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 Pb(e){var t;const n=Object.assign({},e);return null!==(t=n.ignoreUnknownFields)&&void 0!==t||(n.ignoreUnknownFields=!0),n}function Lb(e,t,n,r){const o=t?Fb(e.I,r):zb(e.I,n);return{parse:(t?Fb(e.O,r):zb(e.O,n)).parse,serialize:o.serialize}}function Fb(e,t){return{parse(n){try{return e.fromBinary(n,t)}catch(r){const e=r instanceof Error?r.message:String(r);throw new wb(`parse binary: ${e}`,yb.InvalidArgument)}},serialize(e){try{return e.toBinary(t)}catch(n){const e=n instanceof Error?n.message:String(n);throw new wb(`serialize binary: ${e}`,yb.Internal)}}}}function zb(e,t){var n,r;const o=null!==(n=null==t?void 0:t.textEncoder)&&void 0!==n?n:new TextEncoder,s=null!==(r=null==t?void 0:t.textDecoder)&&void 0!==r?r:new TextDecoder,i=Pb(t);return{parse(t){try{const n=s.decode(t);return e.fromJsonString(n,i)}catch(n){throw wb.from(n,yb.InvalidArgument)}},serialize(e){try{const t=e.toJsonString(i);return o.encode(t)}catch(t){throw wb.from(t,yb.Internal)}}}}const Bb=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function Ub(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 r=function(e){if(!vb){vb={};for(const e of Object.values(yb))"string"!=typeof e&&(vb[xb(e)]=e)}return vb[e]}(e.code);if(void 0===r)throw n;const o=e.message;if(null!=o&&"string"!=typeof o)throw n;const s=new wb(null!=o?o:"",r,t);if("details"in e&&Array.isArray(e.details))for(const a of e.details){if(null===a||"object"!=typeof a||Array.isArray(a)||"string"!=typeof a.type||"string"!=typeof a.value||"debug"in a&&"object"!=typeof a.debug)throw n;try{s.details.push({type:a.type,value:Wg.dec(a.value),debug:a.debug})}catch(i){throw n}}return s}function $b(e){const t=new wb("invalid end stream",yb.InvalidArgument);let n;try{n=JSON.parse("string"==typeof e?e:(new TextDecoder).decode(e))}catch(o){throw t}if("object"!=typeof n||null==n||Array.isArray(n))throw t;const r=new Headers;if("metadata"in n){if("object"!=typeof n.metadata||null==n.metadata||Array.isArray(n.metadata))throw t;for(const[e,o]of Object.entries(n.metadata)){if(!Array.isArray(o)||o.some((e=>"string"!=typeof e)))throw t;for(const t of o)r.append(e,t)}}return{metadata:r,error:"error"in n?Ub(n.error,r,t):void 0}}const Vb="Content-Type",Hb="Content-Length",Wb="Content-Encoding",Gb="Accept-Encoding",qb="Connect-Protocol-Version";function Yb(e){const t=new Headers,n=new Headers;return e.forEach(((e,r)=>{r.toLowerCase().startsWith("trailer-")?n.set(r.substring(8),e):t.set(r,e)})),[t,n]}function Kb(e,t,n,r,o){const s=new Headers(null!=r?r:{});return void 0!==n&&s.set("Connect-Timeout-Ms",`${n}`),s.set(Vb,e==Hy.Unary?t?"application/proto":"application/json":t?"application/connect+proto":"application/connect+json"),s.set(qb,"1"),s}function Jb(e,t,n){const r=function(e){const t=null==e?void 0:e.match(Bb);if(!t)return;return{stream:!!t[1],binary:!!t[3]}}(n.get("Content-Type"));if(200!==t){const o=new wb(`HTTP ${t}`,function(e){switch(e){case 400:return yb.InvalidArgument;case 401:return yb.Unauthenticated;case 403:return yb.PermissionDenied;case 404:return yb.Unimplemented;case 408:return yb.DeadlineExceeded;case 409:return yb.Aborted;case 412:return yb.FailedPrecondition;case 413:case 431:return yb.ResourceExhausted;case 415:return yb.Internal;case 429:case 502:case 503:case 504:return yb.Unavailable;default:return yb.Unknown}}(t),n);if(e==Hy.Unary&&r&&!r.binary)return{isUnaryError:!0,unaryError:o};throw o}return{isUnaryError:!1}}const Xb="application/";function Zb(e,t,n){let r="?connect=v1";const o=e.header.get(Vb);0===(null==o?void 0:o.indexOf(Xb))&&(r+="&encoding="+encodeURIComponent(o.slice(12)));const s=e.header.get(Wb);null!==s&&"identity"!==s&&(r+="&compression="+encodeURIComponent(s),n=!0),n&&(r+="&base64=1"),r+="&message="+function(e,t){return t?Wg.enc(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent((new TextDecoder).decode(e))}(t,n);const i=e.url+r,a=new Headers(e.header);return[qb,Vb,Hb,Wb,Gb].forEach((e=>a.delete(e))),Object.assign(Object.assign({},e),{init:Object.assign(Object.assign({},e.init),{method:"GET"}),url:i,header:a})}function Qb(e){const{signal:t,cleanup:n}=function(e){const t=new AbortController,n=()=>{t.abort(new wb("the operation timed out",yb.DeadlineExceeded))};let r;return void 0!==e&&(e<=0?n():r=setTimeout(n,e)),{signal:t.signal,cleanup:()=>clearTimeout(r)}}(e.timeoutMs),r=function(...e){const t=new AbortController,n=e.filter((e=>void 0!==e)).concat(t.signal);for(const o of n){if(o.aborted){r.apply(o);break}o.addEventListener("abort",r)}function r(){t.signal.aborted||t.abort(Ab(this));for(const e of n)e.removeEventListener("abort",r)}return t}(e.signal,t);return[r.signal,function(e){const o=wb.from(t.aborted?Ab(t):e);return r.abort(o),n(),Promise.reject(o)},function(){n(),r.abort()}]}var ex,tx,nx,rx,ox,sx;(tx=ex||(ex={}))[tx.UNSPECIFIED=0]="UNSPECIFIED",tx[tx.INACTIVE=1]="INACTIVE",tx[tx.PROCESSING=2]="PROCESSING",tx[tx.SUCCESS=3]="SUCCESS",tx[tx.WARNING=4]="WARNING",tx[tx.ERROR=5]="ERROR",Uy.util.setEnumType(ex,"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"}]),(rx=nx||(nx={}))[rx.UNSPECIFIED=0]="UNSPECIFIED",rx[rx.SINGLE=1]="SINGLE",rx[rx.MULTI=2]="MULTI",Uy.util.setEnumType(nx,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),(sx=ox||(ox={}))[sx.UNSPECIFIED=0]="UNSPECIFIED",sx[sx.INLINE=1]="INLINE",sx[sx.BLOCK=2]="BLOCK",sx[sx.INLINE_MASK=3]="INLINE_MASK",Uy.util.setEnumType(ox,"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 ix=class e extends bg{constructor(e){super(),s(this,"threshold",0),Uy.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 Uy.util.equals(e,t,n)}};s(ix,"runtime",Uy),s(ix,"typeName","exa.language_server_pb.MultilineConfig"),s(ix,"fields",Uy.util.newFieldList((()=>[{no:1,name:"threshold",kind:"scalar",T:2}])));let ax=ix;const lx=class e extends bg{constructor(e){super(),s(this,"metadata"),s(this,"document"),s(this,"editorOptions"),s(this,"otherDocuments",[]),s(this,"experimentConfig"),s(this,"modelName",""),s(this,"multilineConfig"),Uy.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 Uy.util.equals(e,t,n)}};s(lx,"runtime",Uy),s(lx,"typeName","exa.language_server_pb.GetCompletionsRequest"),s(lx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:ab},{no:2,name:"document",kind:"message",T:Sx},{no:3,name:"editor_options",kind:"message",T:cb},{no:5,name:"other_documents",kind:"message",T:Sx,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Nx},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:ax}])));let cx=lx;const dx=class e extends bg{constructor(e){super(),s(this,"state"),s(this,"completionItems",[]),Uy.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 Uy.util.equals(e,t,n)}};s(dx,"runtime",Uy),s(dx,"typeName","exa.language_server_pb.GetCompletionsResponse"),s(dx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"state",kind:"message",T:jx},{no:2,name:"completion_items",kind:"message",T:Rx,repeated:!0}])));let ux=dx;const hx=class e extends bg{constructor(e){super(),s(this,"metadata"),s(this,"completionId",""),Uy.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 Uy.util.equals(e,t,n)}};s(hx,"runtime",Uy),s(hx,"typeName","exa.language_server_pb.AcceptCompletionRequest"),s(hx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"metadata",kind:"message",T:ab},{no:2,name:"completion_id",kind:"scalar",T:9}])));let fx=hx;const mx=class e extends bg{constructor(e){super(),Uy.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 Uy.util.equals(e,t,n)}};s(mx,"runtime",Uy),s(mx,"typeName","exa.language_server_pb.AcceptCompletionResponse"),s(mx,"fields",Uy.util.newFieldList((()=>[])));let px=mx;const gx=class e extends bg{constructor(e){super(),Uy.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 Uy.util.equals(e,t,n)}};s(gx,"runtime",Uy),s(gx,"typeName","exa.language_server_pb.GetAuthTokenRequest"),s(gx,"fields",Uy.util.newFieldList((()=>[])));let yx=gx;const bx=class e extends bg{constructor(e){super(),s(this,"authToken",""),s(this,"uuid",""),Uy.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 Uy.util.equals(e,t,n)}};s(bx,"runtime",Uy),s(bx,"typeName","exa.language_server_pb.GetAuthTokenResponse"),s(bx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}])));let xx=bx;const vx=class e extends bg{constructor(e){super(),s(this,"row",Ag.zero),s(this,"col",Ag.zero),Uy.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 Uy.util.equals(e,t,n)}};s(vx,"runtime",Uy),s(vx,"typeName","exa.language_server_pb.DocumentPosition"),s(vx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}])));let wx=vx;const kx=class e extends bg{constructor(e){super(),s(this,"absolutePath",""),s(this,"relativePath",""),s(this,"text",""),s(this,"editorLanguage",""),s(this,"language",nb.UNSPECIFIED),s(this,"cursorOffset",Ag.zero),s(this,"cursorPosition"),s(this,"lineEnding",""),Uy.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 Uy.util.equals(e,t,n)}};s(kx,"runtime",Uy),s(kx,"typeName","exa.language_server_pb.Document"),s(kx,"fields",Uy.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:Uy.getEnumType(nb)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:wx},{no:7,name:"line_ending",kind:"scalar",T:9}])));let Sx=kx;const Cx=class e extends bg{constructor(e){super(),s(this,"forceEnableExperiments",[]),Uy.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 Uy.util.equals(e,t,n)}};s(Cx,"runtime",Uy),s(Cx,"typeName","exa.language_server_pb.ExperimentConfig"),s(Cx,"fields",Uy.util.newFieldList((()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:Uy.getEnumType(Yy),repeated:!0}])));let Nx=Cx;const Ex=class e extends bg{constructor(e){super(),s(this,"state",ex.UNSPECIFIED),s(this,"message",""),Uy.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 Uy.util.equals(e,t,n)}};s(Ex,"runtime",Uy),s(Ex,"typeName","exa.language_server_pb.State"),s(Ex,"fields",Uy.util.newFieldList((()=>[{no:1,name:"state",kind:"enum",T:Uy.getEnumType(ex)},{no:2,name:"message",kind:"scalar",T:9}])));let jx=Ex;const _x=class e extends bg{constructor(e){super(),s(this,"startOffset",Ag.zero),s(this,"endOffset",Ag.zero),s(this,"startPosition"),s(this,"endPosition"),Uy.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 Uy.util.equals(e,t,n)}};s(_x,"runtime",Uy),s(_x,"typeName","exa.language_server_pb.Range"),s(_x,"fields",Uy.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:wx},{no:4,name:"end_position",kind:"message",T:wx}])));let Ix=_x;const Ax=class e extends bg{constructor(e){super(),s(this,"text",""),s(this,"deltaCursorOffset",Ag.zero),Uy.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 Uy.util.equals(e,t,n)}};s(Ax,"runtime",Uy),s(Ax,"typeName","exa.language_server_pb.Suffix"),s(Ax,"fields",Uy.util.newFieldList((()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}])));let Tx=Ax;const Mx=class e extends bg{constructor(e){super(),s(this,"text",""),s(this,"offset",Ag.zero),s(this,"type",ox.UNSPECIFIED),s(this,"prefix",""),s(this,"line",Ag.zero),Uy.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 Uy.util.equals(e,t,n)}};s(Mx,"runtime",Uy),s(Mx,"typeName","exa.language_server_pb.CompletionPart"),s(Mx,"fields",Uy.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:Uy.getEnumType(ox)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}])));let Dx=Mx;const Ox=class e extends bg{constructor(e){super(),s(this,"completion"),s(this,"suffix"),s(this,"range"),s(this,"source",eb.UNSPECIFIED),s(this,"completionParts",[]),Uy.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 Uy.util.equals(e,t,n)}};s(Ox,"runtime",Uy),s(Ox,"typeName","exa.language_server_pb.CompletionItem"),s(Ox,"fields",Uy.util.newFieldList((()=>[{no:1,name:"completion",kind:"message",T:sb},{no:5,name:"suffix",kind:"message",T:Tx},{no:2,name:"range",kind:"message",T:Ix},{no:3,name:"source",kind:"enum",T:Uy.getEnumType(eb)},{no:8,name:"completion_parts",kind:"message",T:Dx,repeated:!0}])));let Rx=Ox;const Px={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:cx,O:ux,kind:Hy.Unary},acceptCompletion:{name:"AcceptCompletion",I:fx,O:px,kind:Hy.Unary},getAuthToken:{name:"GetAuthToken",I:yx,O:xx,kind:Hy.Unary}}};var Lx=function(e){return this instanceof Lx?(this.v=e,this):new Lx(e)},Fx=function(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,o=n.apply(e,t||[]),s=[];return r={},i("next"),i("throw"),i("return",(function(e){return function(t){return Promise.resolve(t).then(e,c)}})),r[Symbol.asyncIterator]=function(){return this},r;function i(e,t){o[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))},t&&(r[e]=t(r[e])))}function a(e,t){try{(n=o[e](t)).value instanceof Lx?Promise.resolve(n.value.v).then(l,c):d(s[0][2],n)}catch(r){d(s[0][3],r)}var n}function l(e){a("next",e)}function c(e){a("throw",e)}function d(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}};const zx=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,r,o,s,i,a,l){var c;const{serialize:d,parse:u}=Lb(r,n,e.jsonOptions,e.binaryOptions);return s=void 0===s?e.defaultTimeoutMs:s<=0?void 0:s,await function(e){const t=Rb(e.next,e.interceptors),[n,r,o]=Qb(e);return t(Object.assign(Object.assign({},e.req),{message:Db(e.req.method.I,e.req.message),signal:n})).then((e=>(o(),e)),r)}({interceptors:e.interceptors,signal:o,timeoutMs:s,req:{stream:!1,service:t,method:r,url:Mb(e.baseUrl,t,r),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Kb(r.kind,n,s,i),contextValues:null!=l?l:Tb(),message:a},next:async o=>{var s;let i=null;!0===e.useHttpGet&&r.idempotency===Gy.NoSideEffects?o=Zb(o,d(o.message),n):i=d(o.message);const a=null!==(s=e.fetch)&&void 0!==s?s:globalThis.fetch,l=await a(o.url,Object.assign(Object.assign({},o.init),{headers:o.header,signal:o.signal,body:i})),{isUnaryError:c,unaryError:h}=Jb(r.kind,l.status,l.headers);if(c)throw Ub(await l.json(),function(...e){const t=new Headers;for(const n of e)n.forEach(((e,n)=>{t.append(n,e)}));return t}(...Yb(l.headers)),h);const[f,m]=Yb(l.headers);return{stream:!1,service:t,method:r,header:f,message:n?u(new Uint8Array(await l.arrayBuffer())):r.O.fromJson(await l.json(),Pb(e.jsonOptions)),trailer:m}}})},async stream(t,r,o,s,i,a,l){var c;const{serialize:d,parse:u}=Lb(r,n,e.jsonOptions,e.binaryOptions);function h(e,t,n){return Fx(this,arguments,(function*(){const r=function(e){let t,n=new Uint8Array(0);function r(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 o;for(;;){if(void 0===o&&n.byteLength>=5){let e=0;for(let t=1;t<5;t++)e=(e<<8)+n[t];o={flags:n[0],length:e}}if(void 0!==o&&n.byteLength>=o.length+5)break;const e=await t.read();if(e.done)break;r(e.value)}if(void 0===o)return 0==n.byteLength?void e.close():void e.error(new wb("premature end of stream",yb.DataLoss));const s=n.subarray(5,5+o.length);n=n.subarray(5+o.length),e.enqueue({flags:o.flags,data:s})}})}(e).getReader();let o=!1;for(;;){const e=yield Lx(r.read());if(e.done)break;const{flags:s,data:i}=e.value;if(2&~s)yield yield Lx(u(i));else{o=!0;const e=$b(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(!o)throw"missing EndStreamResponse"}))}async function f(e){if(r.kind!=Hy.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 r=new DataView(n.buffer,n.byteOffset,n.byteLength);return r.setUint8(0,e),r.setUint32(1,t.length),n}(0,d(t.value))}return s=void 0===s?e.defaultTimeoutMs:s<=0?void 0:s,await function(e){const t=Rb(e.next,e.interceptors),[n,r,o]=Qb(e),s=Object.assign(Object.assign({},e.req),{message:Ob(e.req.method.I,e.req.message),signal:n});let i=!1;return n.addEventListener("abort",(function(){var t,n;const r=e.req.message[Symbol.asyncIterator]();i||null===(t=r.throw)||void 0===t||t.call(r,this.reason).catch((()=>{})),null===(n=r.return)||void 0===n||n.call(r).catch((()=>{}))})),t(s).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,o()),e)),r)}}}})),r)}({interceptors:e.interceptors,timeoutMs:s,signal:o,req:{stream:!0,service:t,method:r,url:Mb(e.baseUrl,t,r),init:{method:"POST",credentials:null!==(c=e.credentials)&&void 0!==c?c:"same-origin",redirect:"error",mode:"cors"},header:Kb(r.kind,n,s,i),contextValues:null!=l?l:Tb(),message:a},next:async t=>{var n;const o=null!==(n=e.fetch)&&void 0!==n?n:globalThis.fetch,s=await o(t.url,Object.assign(Object.assign({},t.init),{headers:t.header,signal:t.signal,body:await f(t.message)}));if(Jb(r.kind,s.status,s.headers),null===s.body)throw"missing response body";const i=new Headers;return Object.assign(Object.assign({},t),{header:s.headers,trailer:i,message:h(s.body,i,s.headers)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),Bx=($x=zx,function(e,t){const n={};for(const[r,o]of Object.entries(e.methods)){const s=t(Object.assign(Object.assign({},o),{localName:r,service:e}));null!=s&&(n[r]=s)}return n}(Ux=Px,(e=>{switch(e.kind){case Hy.Unary:return function(e,t,n){return async function(r,o){var s,i;const a=await e.unary(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues);return null===(s=null==o?void 0:o.onHeader)||void 0===s||s.call(o,a.header),null===(i=null==o?void 0:o.onTrailer)||void 0===i||i.call(o,a.trailer),a.message}}($x,Ux,e);case Hy.ServerStreaming:return function(e,t,n){return function(r,o){return Ib(e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,Nb([r]),null==o?void 0:o.contextValues),o)}}($x,Ux,e);case Hy.ClientStreaming:return function(e,t,n){return async function(r,o){var s,i,a,l,c,d;const u=await e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues);let h;null===(c=null==o?void 0:o.onHeader)||void 0===c||c.call(o,u.header);try{for(var f,m=!0,p=Eb(u.message);!(s=(f=await p.next()).done);m=!0)l=f.value,m=!1,h=l}catch(g){i={error:g}}finally{try{m||s||!(a=p.return)||await a.call(p)}finally{if(i)throw i.error}}if(!h)throw new wb("protocol error: missing response message",yb.Internal);return null===(d=null==o?void 0:o.onTrailer)||void 0===d||d.call(o,u.trailer),h}}($x,Ux,e);case Hy.BiDiStreaming:return function(e,t,n){return function(r,o){return Ib(e.stream(t,n,null==o?void 0:o.signal,null==o?void 0:o.timeoutMs,null==o?void 0:o.headers,r,null==o?void 0:o.contextValues),o)}}($x,Ux,e);default:return null}})));var Ux,$x;let Vx;try{Vx=crypto.randomUUID()}catch{Vx=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 Hx(e,t){const n=e.state.facet(ub),{override:r}=e.state.facet(hb),o=await r(),s=e.state,i=s.selection.main.head,a=s.doc.toString();try{const r=await async function({text:e,cursorOffset:t,config:n,otherDocuments:r}){return await Bx.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:n.apiKey,sessionId:Vx,authSource:n.authSource},document:{text:e,cursorOffset:BigInt(t),language:n.language,editorLanguage:"typescript",lineEnding:"\n"},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:r,multilineConfig:void 0},{headers:{Authorization:`Basic ${n.apiKey}-${Vx}`}})}({text:a,cursorOffset:i,config:n,otherDocuments:o});if(!r||0===r.completionItems.length)return;if(void 0!==t&&i!==t||"active"===Ir(e.state)||!e.hasFocus)return;const l=r.completionItems.map((e=>{let t=0;return e.completionParts.filter((e=>3!==e.type)).map((e=>{const n=Number(e.offset),r=2===e.type?`\n${e.text}`:e.text,o={absoluteStartPos:t+n,absoluteEndPos:t+n+r.length,from:n,to:n,insert:r};return t+=r.length,o}))})),c=0,d=l.at(c);if(!d)return;const u=Ar.of(d,s.doc.length),h=u.invert(s.doc);e.dispatch({changes:u,effects:sg.of({index:c,reverseChangeSet:h,changeSpecs:l}),annotations:[gb.of(null),pb.of(null),Tr.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise((e=>setTimeout(e,300)))}}function Wx(){let e=null,t=0;return zn.updateListener.of((n=>{const r=n.view.state.facet(ub);if(!r.alwaysOn)return;if(!function(e){return e.docChanged&&!e.transactions.some((e=>e.effects.some((e=>e.is(ig)||e.is(ag)))))}(n))return;if(e&&clearTimeout(e),function(e){if(!e.view.hasFocus)return!0;if(e.state.field(mb))return!0;if("active"===Ir(e.state))return!0;for(const t of e.transactions)if(void 0!==t.annotation(pb))return!0}(n))return;const o=n.state.selection.main.head;r.shouldComplete&&!r.shouldComplete(new Mr(n.view.state,o,!1))||(e=setTimeout((async()=>{o===t&&await Hx(n.view,t)}),r.timeout),t=o)}))}function Gx(e){var t;const n=e.state.field(mb);if(!n)return!1;const r=null==(t=n.reverseChangeSet)?void 0:t.invert(e.state.doc);e.dispatch({changes:n.reverseChangeSet,effects:ig.of(null),annotations:[gb.of(null),pb.of(null),Tr.addToHistory.of(!1)]});let o=0;return null==r||r.iterChangedRanges(((e,t,n,r)=>{o=r})),e.dispatch({changes:r,selection:Fn.cursor(o),annotations:[pb.of(null),Tr.addToHistory.of(!0)]}),!0}const qx=e=>{const{state:t}=e,n=t.field(mb);if(!n)return!1;const{changeSpecs:r}=n;if(r.length<2)return!1;const o=(n.index+1)%r.length,s=r.at(o);if(!s)return!1;const i=n.reverseChangeSet.apply(t.doc),a=Ar.of(n.reverseChangeSet,t.doc.length).compose(Ar.of(s,i.length)),l=Ar.of(s,i.length).invert(i);return e.dispatch({changes:a,effects:sg.of({index:o,reverseChangeSet:l,changeSpecs:r}),annotations:[gb.of(null),pb.of(null),Tr.addToHistory.of(!1)]}),!0};function Yx(e){const t=e.state.field(mb);return!!t&&(e.dispatch({changes:t.reverseChangeSet,effects:ag.of(null),annotations:[gb.of(null),pb.of(null),Tr.addToHistory.of(!1)]}),!1)}function Kx(){return zn.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(mb)&&("Tab"===t?Gx(e):Yx(e))}(t,e.key)),mouseup(e,t){const n=e.target;return"BUTTON"===n.nodeName&&"codeium-cycle"===n.dataset.action?(qx(t),e.stopPropagation(),e.preventDefault(),!0):function(e){var t,n;let r=!1;const o=null==(t=e.state.selection.asSingle().ranges.at(0))?void 0:t.head,s=e.state.field(mb);return!(void 0===o||!s)&&(null==(n=s.decorations)||n.between(o,o,(()=>{r=!0})),r)}(t)?Gx(t):Yx(t)}})}const Jx=new Or,Xx={delay:500,includeKeymap:!0,events:{shouldShowSuggestion:e=>e.hasFocus,beforeSuggestionFetch:e=>e.hasFocus}},Zx=e=>{const t=[];return"codeium"===e.copilot&&e.codeium_api_key&&t.push(function(e){return[ub.of(e),mb,jr.highest(wr.of([{key:"Ctrl-]",run:qx}])),jr.highest(zn.updateListener.of((e=>{e.focusChanged&&Yx(e.view)}))),jr.high(Kx()),Wx()]}({apiKey:e.codeium_api_key,language:nb.PYTHON}),hb.of({override:async()=>[{text:Dr(""),language:nb.PYTHON,editorLanguage:"python"}]})),"github"===e.copilot&&t.push(og({...Xx,fetchFn:async e=>{if(!dc())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(),r=t.split("\n").length-n.split("\n").length,o=function(e,t){const n=e.lineAt(t);return{line:n.number-1,character:t-n.from}}(e.doc,e.selection.main.head);return o.line+=r,{doc:{source:t,tabSize:e.tabSize,indentSize:1,insertSpaces:!0,path:fc,version:"replace_me",uri:`file://${fc}`,relativePath:fc,languageId:hc,position:o}}}(e,Dr(t)),r=function(e,t,n){if(0===e.completions.length)return"";const{displayText:r,position:o}=e.completions[0],s=o.character-t.character,i=s<0?r.slice(-s):r,a=n.doc.sliceString(n.selection.main.head,n.doc.length);for(let l=0;l<i.length;l++){const e=i.slice(l);if(a.startsWith(e))return i.slice(0,l)}return i}(await uc().getCompletion(n),n.doc.position,e);return r&&X.debug("Copilot suggestion:",r),r}})),"custom"===e.copilot&&t.push(og({...Xx,fetchFn:async e=>{if(0===e.doc.length)return"";const t=e.doc.sliceString(0,e.selection.main.head),n=e.doc.sliceString(e.selection.main.head,e.doc.length);if(0===t.length)return"";const r=e.field(Rr).type;let o=await Pr.post("/ai/inline_completion",{prefix:t,suffix:n,language:r});return t&&o.startsWith(t)&&(o=o.slice(t.length)),n&&o.endsWith(n)&&(o=o.slice(0,-n.length)),o}})),[...t,Jx.of(cc())]};const Qx=$n.mark({class:"underline"}),ev=Hn.define(),tv=Hn.define(),nv=Un.define({create:()=>$n.none,update(e,t){let n=e.map(t.changes);for(const r of t.effects)r.is(ev)?n=e.update({add:[Qx.range(r.value.from,r.value.to)]}):r.is(tv)&&(n=$n.none);return n},provide:e=>zn.decorations.from(e)});class rv{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=Lr(this.view.state).cursorAt(t);if("VariableName"===n.name){const{from:e,to:r}=n;if(this.hoveredRange&&this.hoveredRange.from===e&&this.hoveredRange.to===r)return;this.clearUnderline(),this.hoveredRange={from:e,to:r,position:t},this.view.dispatch({effects:ev.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:tv.of(null)}),this.hoveredRange=null)}}const ov=({variant:e,settings:t,styles:n})=>{const r=zn.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}),o=zr.define(n);return[r,Br(o)]};ov({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:Ur.comment,color:"#404080"},{tag:[Ur.string,Ur.regexp],color:"#999999"},{tag:Ur.number,color:"#7090B0"},{tag:[Ur.bool,Ur.null],color:"#8080A0"},{tag:[Ur.punctuation,Ur.derefOperator],color:"#805080"},{tag:Ur.keyword,color:"#60B0FF"},{tag:Ur.definitionKeyword,color:"#B0FFF0"},{tag:Ur.moduleKeyword,color:"#60B0FF"},{tag:Ur.operator,color:"#A0A0FF"},{tag:[Ur.variableName,Ur.self],color:"#008080"},{tag:Ur.operatorKeyword,color:"#A0A0FF"},{tag:Ur.controlKeyword,color:"#80A0FF"},{tag:Ur.className,color:"#70E080"},{tag:[Ur.function(Ur.propertyName),Ur.propertyName],color:"#50A0A0"},{tag:Ur.tagName,color:"#009090"},{tag:Ur.modifier,color:"#B0FFF0"},{tag:[Ur.squareBracket,Ur.attributeName],color:"#D0D0FF"}]}),ov({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:Ur.comment,color:"#787b8099"},{tag:Ur.string,color:"#86b300"},{tag:Ur.regexp,color:"#4cbf99"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#ffaa33"},{tag:Ur.variableName,color:"#5c6166"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#fa8d3e"},{tag:[Ur.keyword,Ur.special(Ur.brace)],color:"#fa8d3e"},{tag:Ur.operator,color:"#ed9366"},{tag:Ur.separator,color:"#5c6166b3"},{tag:Ur.punctuation,color:"#5c6166"},{tag:[Ur.definition(Ur.propertyName),Ur.function(Ur.variableName)],color:"#f2ae49"},{tag:[Ur.className,Ur.definition(Ur.typeName)],color:"#22a4e6"},{tag:[Ur.tagName,Ur.typeName,Ur.self,Ur.labelName],color:"#55b4d4"},{tag:Ur.angleBracket,color:"#55b4d480"},{tag:Ur.attributeName,color:"#f2ae49"}]}),ov({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:Ur.comment,color:"#6E6E6E"},{tag:[Ur.string,Ur.regexp,Ur.special(Ur.brace)],color:"#5C81B3"},{tag:Ur.number,color:"#C1E1B8"},{tag:Ur.bool,color:"#53667D"},{tag:[Ur.definitionKeyword,Ur.modifier,Ur.function(Ur.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[Ur.keyword,Ur.moduleKeyword,Ur.operatorKeyword,Ur.operator],color:"#697A8E",fontWeight:"bold"},{tag:[Ur.variableName,Ur.attributeName],color:"#708E67"},{tag:[Ur.function(Ur.variableName),Ur.definition(Ur.propertyName),Ur.derefOperator],color:"#fff"},{tag:Ur.tagName,color:"#A3D295"}]}),ov({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:Ur.comment,color:"#666666"},{tag:[Ur.string,Ur.special(Ur.brace)],color:"#54BE0D"},{tag:Ur.regexp,color:"#E9C062"},{tag:Ur.number,color:"#CF6A4C"},{tag:[Ur.keyword,Ur.operator],color:"#5EA6EA"},{tag:Ur.variableName,color:"#7587A6"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#F9EE98"},{tag:[Ur.propertyName,Ur.function(Ur.variableName)],color:"#937121"},{tag:[Ur.typeName,Ur.angleBracket,Ur.tagName],color:"#9B859D"}]}),ov({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:Ur.comment,color:"#6B4E32"},{tag:[Ur.keyword,Ur.operator,Ur.derefOperator],color:"#EF5D32"},{tag:Ur.className,color:"#EFAC32",fontWeight:"bold"},{tag:[Ur.typeName,Ur.propertyName,Ur.function(Ur.variableName),Ur.definition(Ur.variableName)],color:"#EFAC32"},{tag:Ur.definition(Ur.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:Ur.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[Ur.number,Ur.bool],color:"#6C99BB"},{tag:[Ur.variableName,Ur.self],color:"#7DAF9C"},{tag:[Ur.string,Ur.special(Ur.brace),Ur.regexp],color:"#D9D762"},{tag:[Ur.angleBracket,Ur.tagName,Ur.attributeName],color:"#EFCB43"}]}),ov({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:Ur.comment,color:"#404040"},{tag:[Ur.string,Ur.special(Ur.brace),Ur.regexp],color:"#00D8FF"},{tag:Ur.number,color:"#E62286"},{tag:[Ur.variableName,Ur.attributeName,Ur.self],color:"#E62286",fontWeight:"bold"},{tag:Ur.function(Ur.variableName),color:"#fff",fontWeight:"bold"}]}),ov({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:Ur.comment,color:"#BCC8BA"},{tag:[Ur.string,Ur.special(Ur.brace),Ur.regexp],color:"#5D90CD"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#46A609"},{tag:Ur.keyword,color:"#AF956F"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#C52727"},{tag:[Ur.angleBracket,Ur.tagName,Ur.attributeName],color:"#606060"},{tag:Ur.self,color:"#000"}]}),ov({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:Ur.comment,color:"#0088FF"},{tag:Ur.string,color:"#3AD900"},{tag:Ur.regexp,color:"#80FFC2"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#FF628C"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#FFEE80"},{tag:Ur.variableName,color:"#CCCCCC"},{tag:Ur.self,color:"#FF80E1"},{tag:[Ur.className,Ur.definition(Ur.propertyName),Ur.function(Ur.variableName),Ur.definition(Ur.typeName),Ur.labelName],color:"#FFDD00"},{tag:[Ur.keyword,Ur.operator],color:"#FF9D00"},{tag:[Ur.propertyName,Ur.typeName],color:"#80FFBB"},{tag:Ur.special(Ur.brace),color:"#EDEF7D"},{tag:Ur.attributeName,color:"#9EFFFF"},{tag:Ur.derefOperator,color:"#fff"}]}),ov({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:Ur.comment,color:"#AEAEAE"},{tag:[Ur.string,Ur.special(Ur.brace),Ur.regexp],color:"#8DFF8E"},{tag:[Ur.className,Ur.definition(Ur.propertyName),Ur.function(Ur.variableName),Ur.function(Ur.definition(Ur.variableName)),Ur.definition(Ur.typeName)],color:"#A3EBFF"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#62E9BD"},{tag:[Ur.keyword,Ur.operator],color:"#2BF1DC"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#F8FBB1"},{tag:[Ur.variableName,Ur.self],color:"#B683CA"},{tag:[Ur.angleBracket,Ur.tagName,Ur.typeName,Ur.propertyName],color:"#60A4F1"},{tag:Ur.derefOperator,color:"#E0E0E0"},{tag:Ur.attributeName,color:"#7BACCA"}]}),ov({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:Ur.comment,color:"#6272a4"},{tag:[Ur.string,Ur.special(Ur.brace)],color:"#f1fa8c"},{tag:[Ur.number,Ur.self,Ur.bool,Ur.null],color:"#bd93f9"},{tag:[Ur.keyword,Ur.operator],color:"#ff79c6"},{tag:[Ur.definitionKeyword,Ur.typeName],color:"#8be9fd"},{tag:Ur.definition(Ur.typeName),color:"#f8f8f2"},{tag:[Ur.className,Ur.definition(Ur.propertyName),Ur.function(Ur.variableName),Ur.attributeName],color:"#50fa7b"}]}),ov({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:Ur.comment,color:"#AAAAAA"},{tag:[Ur.keyword,Ur.operator,Ur.typeName,Ur.tagName,Ur.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[Ur.attributeName,Ur.definition(Ur.propertyName)],color:"#4F9FD0"},{tag:[Ur.className,Ur.string,Ur.special(Ur.brace)],color:"#CF4F5F"},{tag:Ur.number,color:"#CF4F5F",fontWeight:"bold"},{tag:Ur.variableName,fontWeight:"bold"}]}),ov({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:Ur.comment,color:"#9995b7"},{tag:Ur.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#ff5792"},{tag:[Ur.className,Ur.tagName,Ur.definition(Ur.typeName)],color:"#0094f0"},{tag:[Ur.number,Ur.bool,Ur.null,Ur.special(Ur.brace)],color:"#5842ff"},{tag:[Ur.definition(Ur.propertyName),Ur.function(Ur.variableName)],color:"#0095a8"},{tag:Ur.typeName,color:"#b3694d"},{tag:[Ur.propertyName,Ur.variableName],color:"#fa8900"},{tag:Ur.operator,color:"#ff5792"},{tag:Ur.self,color:"#e64100"},{tag:[Ur.string,Ur.regexp],color:"#00b368"},{tag:[Ur.paren,Ur.bracket],color:"#0431fa"},{tag:Ur.labelName,color:"#00bdd6"},{tag:Ur.attributeName,color:"#e64100"},{tag:Ur.angleBracket,color:"#9995b7"}]}),ov({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:Ur.comment,color:"#9893a5"},{tag:[Ur.bool,Ur.null],color:"#286983"},{tag:Ur.number,color:"#d7827e"},{tag:Ur.className,color:"#d7827e"},{tag:[Ur.angleBracket,Ur.tagName,Ur.typeName],color:"#56949f"},{tag:Ur.attributeName,color:"#907aa9"},{tag:Ur.punctuation,color:"#797593"},{tag:[Ur.keyword,Ur.modifier],color:"#286983"},{tag:[Ur.string,Ur.regexp],color:"#ea9d34"},{tag:Ur.variableName,color:"#d7827e"}]}),ov({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:Ur.comment,color:"#CFCFCF"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#E66C29"},{tag:[Ur.className,Ur.definition(Ur.propertyName),Ur.function(Ur.variableName),Ur.labelName,Ur.definition(Ur.typeName)],color:"#2EB43B"},{tag:Ur.keyword,color:"#D8B229"},{tag:Ur.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#925A47"},{tag:Ur.string,color:"#704D3D"},{tag:Ur.typeName,color:"#2F8996"},{tag:[Ur.variableName,Ur.propertyName],color:"#77ACB0"},{tag:Ur.self,color:"#77ACB0",fontWeight:"bold"},{tag:Ur.regexp,color:"#E3965E"},{tag:[Ur.tagName,Ur.angleBracket],color:"#BAA827"},{tag:Ur.attributeName,color:"#B06520"},{tag:Ur.derefOperator,color:"#000"}]}),ov({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:Ur.comment,color:"#93A1A1"},{tag:Ur.string,color:"#2AA198"},{tag:Ur.regexp,color:"#D30102"},{tag:Ur.number,color:"#D33682"},{tag:Ur.variableName,color:"#268BD2"},{tag:[Ur.keyword,Ur.operator,Ur.punctuation],color:"#859900"},{tag:[Ur.definitionKeyword,Ur.modifier],color:"#073642",fontWeight:"bold"},{tag:[Ur.className,Ur.self,Ur.definition(Ur.propertyName)],color:"#268BD2"},{tag:Ur.function(Ur.variableName),color:"#268BD2"},{tag:[Ur.bool,Ur.null],color:"#B58900"},{tag:Ur.tagName,color:"#268BD2",fontWeight:"bold"},{tag:Ur.angleBracket,color:"#93A1A1"},{tag:Ur.attributeName,color:"#93A1A1"},{tag:Ur.typeName,color:"#859900"}]}),ov({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:Ur.comment,color:"#8E908C"},{tag:[Ur.variableName,Ur.self,Ur.propertyName,Ur.attributeName,Ur.regexp],color:"#C82829"},{tag:[Ur.number,Ur.bool,Ur.null],color:"#F5871F"},{tag:[Ur.className,Ur.typeName,Ur.definition(Ur.typeName)],color:"#C99E00"},{tag:[Ur.string,Ur.special(Ur.brace)],color:"#718C00"},{tag:Ur.operator,color:"#3E999F"},{tag:[Ur.definition(Ur.propertyName),Ur.function(Ur.variableName)],color:"#4271AE"},{tag:Ur.keyword,color:"#8959A8"},{tag:Ur.derefOperator,color:"#4D4D4C"}]});const sv=ov({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:Ur.comment,color:"#708090"},{tag:Ur.variableName,color:"#000000"},{tag:[Ur.string,Ur.special(Ur.brace)],color:"#a11"},{tag:Ur.number,color:"#164"},{tag:Ur.bool,color:"#219"},{tag:Ur.null,color:"#219"},{tag:Ur.keyword,color:"#708",fontWeight:500},{tag:Ur.className,color:"#00f"},{tag:Ur.definition(Ur.typeName),color:"#00f"},{tag:Ur.typeName,color:"#085"},{tag:Ur.angleBracket,color:"#000000"},{tag:Ur.tagName,color:"#170"},{tag:Ur.attributeName,color:"#00c"},{tag:Ur.operator,color:"#a2f",fontWeight:500},{tag:[Ur.function(Ur.variableName)],color:"#00c"},{tag:[Ur.propertyName],color:"#05a"}]}),iv=ov({variant:"dark",settings:{background:"#282c34",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:Ur.comment,color:"#5c6370"},{tag:Ur.variableName,color:"#abb2bf"},{tag:[Ur.string,Ur.special(Ur.brace)],color:"#98c379"},{tag:Ur.number,color:"#d19a66"},{tag:Ur.bool,color:"#d19a66"},{tag:Ur.null,color:"#d19a66"},{tag:Ur.keyword,color:"#c678dd",fontWeight:500},{tag:Ur.className,color:"#61afef"},{tag:Ur.definition(Ur.typeName),color:"#61afef"},{tag:Ur.typeName,color:"#56b6c2"},{tag:Ur.angleBracket,color:"#abb2bf"},{tag:Ur.tagName,color:"#e06c75"},{tag:Ur.attributeName,color:"#d19a66"},{tag:Ur.operator,color:"#56b6c2",fontWeight:500},{tag:[Ur.function(Ur.variableName)],color:"#61afef"},{tag:[Ur.propertyName],color:"#e5c07b"}]});const av="packages-install-input",lv=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let cv;function dv(){const e=async e=>{const t=ne.get(Gr),n={...t,runtime:{...t.runtime,auto_reload:e}};await Ve({config:n}).then((()=>ne.set(Gr,n)))},t=()=>{requestAnimationFrame((()=>{const e=document.getElementById(av);e&&e.focus()}))},n=[{match:"!pip install",onMatch:()=>{ne.set(Hr,(e=>({...e,isSidebarOpen:!0,selectedPanel:"packages"}))),t()},title:"Package Installation",description:_.jsxs(_.Fragment,{children:["The package manager sidebar has been opened.",_.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{ne.set(Hr,(e=>({...e,isSidebarOpen:!0,selectedPanel:"packages"}))),t()},title:"Package Installation",description:_.jsxs(_.Fragment,{children:["The package manager sidebar has been opened.",_.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{ne.set(Hr,(e=>({...e,isSidebarOpen:!0,selectedPanel:"packages"}))),t()},title:"Package Installation",description:_.jsxs(_.Fragment,{children:["The package manager sidebar has been opened.",_.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await e("autorun")},title:"Module reload",description:_.jsxs(_.Fragment,{children:["Module reload mode set to ",_.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await e("lazy")},title:"Module reload",description:_.jsxs(_.Fragment,{children:["Module reload mode set to ",_.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await e("off")},title:"Module reload",description:_.jsx(_.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:_.jsxs(_.Fragment,{children:["Shell commands are not directly supported.",_.jsx("br",{}),"Use ",_.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...lv.map((e=>({match:e,onMatch:()=>{},title:_.jsx(Wr,{className:"inline",children:e}),description:_.jsxs(_.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",_.jsx("a",{href:"https://docs.marimo.io/guides/coming_from/jupyter/#adapting-to-the-absence-of-magic-commands",target:"_blank",className:"text-link underline cursor-pointer",rel:"noopener noreferrer",children:"documentation"}),"."]})})))],r=new Map(n.map((e=>[e.match,e])));return zn.updateListener.of((e=>{if(e.docChanged){const t=e.state.selection.main,n=e.state.doc,o=n.lineAt(t.head),s=n.sliceString(o.from,t.anchor).trim(),i=r.get(s);i&&(i.onMatch(),cv?cv.upsert({title:i.title,description:i.description}):cv=se({title:i.title,description:i.description}))}}))}function uv(){return[zn.domEventHandlers({paste:(e,t)=>{var n;const r=null==(n=e.clipboardData)?void 0:n.getData("text/plain");if(!(null==r?void 0:r.includes("@app.cell")))return!1;const o=function(e){if(!e.includes("@app.cell"))return[];const t=[],n=e.split("\n");let r=[],o=!1,s=0,i=!1,a=!1,l=0;const c=/\(/g,d=/\)/g,u=new Set(["@"]);function h(e){return(e.match(c)||[]).length-(e.match(d)||[]).length}function f(){if(0!==r.length){for(;r.length>0&&r[r.length-1].trim().startsWith("return");)r.pop();r.some((e=>""!==e.trim()))&&t.push(function(e){const t=e.split("\n");if(0===t.length)return"";const n=t.filter((e=>e.trim().length>0));if(0===n.length)return"";const r=/^\s*/,o=Math.min(...n.map((e=>{var t;return(null==(t=e.match(r))?void 0:t[0].length)??Number.POSITIVE_INFINITY})));return 0===o?e.trim():t.map((e=>e.slice(o))).join("\n").trim()}(r.join("\n"))),r=[]}}for(const m of n){const e=m.trim();(e||o)&&(e.startsWith("@app.cell")?(f(),o=!0,s=1):s>0?(e.startsWith("def")&&e.includes("(")&&!e.includes("):")&&(i=!0,l=h(e)),s--):i?(l+=h(e),0===l&&(i=!1)):o&&(u.has(e[0])||e.startsWith("if __name__")?(f(),o=e.startsWith("@")):e.startsWith("return")?e.includes("(")&&!e.endsWith(")")&&(a=!0,l=h(e)):a?(l+=h(e),0===l&&(a=!1)):r.push(m)))}return f(),t}(r);if(0===o.length)return!1;return t.state.facet(qr).createManyBelow(o),!0}})]}function hv(){const e=Kr.filter((e=>"Escape"!==e.key));return jr.highest(wr.of([...e,{key:"Escape",run:e=>(Y(e),!1)}]))}function fv(e){const{showPlaceholder:t,enableAI:n}=e;return t?"marimo-import":n?"ai":"none"}const mv=e=>{const{cellId:t,keymapConfig:n,hotkeys:r,enableAI:o,cellActions:s,completionConfig:i,lspConfig:a,diagnosticsConfig:l}=e,c=fv(e);return[mc(n,r),[zn.domEventHandlers({drop:(e,t)=>{var n,r;const o=null==(n=e.dataTransfer)?void 0:n.files[0];if(null==o?void 0:o.type.startsWith("text/"))return e.preventDefault(),$r(t,o),!0;if(null==o?void 0:o.type.startsWith("image/"))return e.preventDefault(),Vr(t,o),!0;const s=null==(r=e.dataTransfer)?void 0:r.getData("text/plain");if(s){e.preventDefault();const n=t.posAtCoords({x:e.clientX,y:e.clientY});return null!==n&&t.dispatch({changes:{from:n,to:n,insert:s},scrollIntoView:!0}),!0}return!1},dragover:e=>{e.preventDefault()}})],uv(),dv(),Jr(i,r,c,a,l),Xr(t,r,s),pv(e),[nv,(d=(e,t)=>{Fr(e,t)},Bn.define((e=>new rv(e,d)))),zn.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],(null==l?void 0:l.enabled)?Zr():[],o&&j("inline_ai_tooltip")?Wp({prompt:e=>async function(e){var t,n;const r=`\n${e.codeBefore}\n<rewrite_this>\n${e.selection}\n</rewrite_this>\n${e.codeAfter}\n`.trim(),o=await fetch(Yr("api/ai/completion").toString(),{method:"POST",headers:Pr.headers(),body:JSON.stringify({prompt:e.prompt,code:r,selectedText:e.selection,includeOtherCode:"",language:e.language})}),s=(null==(t=e.selection.match(/^\s*/))?void 0:t[0])||"",i=null==(n=o.body)?void 0:n.getReader();if(!i)throw new Error("Failed to get response reader");let a="";for(;;){const{done:e,value:t}=await i.read();if(e)break;a+=(new TextDecoder).decode(t)}return a.startsWith(s)||(a=s+a),a}({prompt:e.prompt,selection:e.selection,codeBefore:e.codeBefore,codeAfter:e.codeAfter,language:q(e.editorView)})}):[]];var d},pv=e=>{const{theme:t,hotkeys:n,completionConfig:r,cellId:o,lspConfig:s,diagnosticsConfig:i}=e,a=fv(e);return[zn.lineWrapping,Qr(),eo(),to(),no(),ro(),oo(),so(),io({position:"fixed",parent:document.querySelector("#App")??void 0}),ao(),"dark"===t?iv:sv,lo(s),Zx(r),co(),uo(),hv(),jr.high(wr.of(bo)),ho(),fo(),mo.of(" "),Br(xo,{fallback:!0}),wr.of(vo),po({placeholderType:a,completionConfig:r,hotkeys:n,cellId:o,lspConfig:{...s,diagnostics:i}}),go.of(wo()),yo.allowMultipleSelections.of(!0),bp(n),wr.of([{key:"Tab",run:e=>ko(e)||(e=>{const{from:t,to:n}=e.state.selection.main;if(t!==n)return!1;const r=e.state.doc.lineAt(n);return""!==r.text.slice(0,n-r.from).trim()&&jo(e)})(e)||So(e),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:e=>null!==Ir(e.state)&&(Co(!0)(e),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:e=>null!==Ir(e.state)&&(Co(!1)(e),!0),preventDefault:!0}]),wr.of([...No,Eo])]};function gv(e){const t=e.current;if(null===t)throw new ReferenceError("Attempting to dereference null object.");return t}var yv="ContextMenu",[bv,xv]=To(yv,[_o]),vv=_o(),[wv,kv]=bv(yv),Sv=e=>{const{__scopeContextMenu:t,children:n,onOpenChange:r,dir:o,modal:s=!0}=e,[i,a]=l.useState(!1),c=vv(t),d=Wo(r),u=l.useCallback((e=>{a(e),d(e)}),[d]);return _.jsx(wv,{scope:t,open:i,onOpenChange:u,modal:s,children:_.jsx(Go,{...c,dir:o,open:i,onOpenChange:u,modal:s,children:n})})};Sv.displayName=yv;var Cv="ContextMenuTrigger",Nv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,disabled:r=!1,...o}=e,s=kv(Cv,n),i=vv(n),a=l.useRef({x:0,y:0}),c=l.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...a.current})}),d=l.useRef(0),u=l.useCallback((()=>window.clearTimeout(d.current)),[]),h=e=>{a.current={x:e.clientX,y:e.clientY},s.onOpenChange(!0)};return l.useEffect((()=>u),[u]),l.useEffect((()=>{r&&u()}),[r,u]),_.jsxs(_.Fragment,{children:[_.jsx(Mo,{...i,virtualRef:c}),_.jsx(Do.span,{"data-state":s.open?"open":"closed","data-disabled":r?"":void 0,...o,ref:t,style:{WebkitTouchCallout:"none",...e.style},onContextMenu:r?e.onContextMenu:Oo(e.onContextMenu,(e=>{u(),h(e),e.preventDefault()})),onPointerDown:r?e.onPointerDown:Oo(e.onPointerDown,Lv((e=>{u(),d.current=window.setTimeout((()=>h(e)),700)}))),onPointerMove:r?e.onPointerMove:Oo(e.onPointerMove,Lv(u)),onPointerCancel:r?e.onPointerCancel:Oo(e.onPointerCancel,Lv(u)),onPointerUp:r?e.onPointerUp:Oo(e.onPointerUp,Lv(u))})]})}));Nv.displayName=Cv;var Ev=e=>{const{__scopeContextMenu:t,...n}=e,r=vv(t);return _.jsx(qo,{...r,...n})};Ev.displayName="ContextMenuPortal";var jv="ContextMenuContent",_v=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=kv(jv,n),s=vv(n),i=l.useRef(!1);return _.jsx(Ro,{...s,...r,ref:t,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:t=>{var n;null==(n=e.onCloseAutoFocus)||n.call(e,t),!t.defaultPrevented&&i.current&&t.preventDefault(),i.current=!1},onInteractOutside:t=>{var n;null==(n=e.onInteractOutside)||n.call(e,t),t.defaultPrevented||o.modal||(i.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)"}})}));_v.displayName=jv;l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Po,{...o,...r,ref:t})})).displayName="ContextMenuGroup";var Iv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Lo,{...o,...r,ref:t})}));Iv.displayName="ContextMenuLabel";var Av=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Ao,{...o,...r,ref:t})}));Av.displayName="ContextMenuItem";var Tv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Fo,{...o,...r,ref:t})}));Tv.displayName="ContextMenuCheckboxItem";l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(zo,{...o,...r,ref:t})})).displayName="ContextMenuRadioGroup";var Mv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Bo,{...o,...r,ref:t})}));Mv.displayName="ContextMenuRadioItem";var Dv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Uo,{...o,...r,ref:t})}));Dv.displayName="ContextMenuItemIndicator";var Ov=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Io,{...o,...r,ref:t})}));Ov.displayName="ContextMenuSeparator";l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx($o,{...o,...r,ref:t})})).displayName="ContextMenuArrow";var Rv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Vo,{...o,...r,ref:t})}));Rv.displayName="ContextMenuSubTrigger";var Pv=l.forwardRef(((e,t)=>{const{__scopeContextMenu:n,...r}=e,o=vv(n);return _.jsx(Ho,{...o,...r,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)"}})}));function Lv(e){return t=>"mouse"!==t.pointerType?e(t):void 0}Pv.displayName="ContextMenuSubContent";var Fv=_v,zv=Iv,Bv=Av,Uv=Tv,$v=Mv,Vv=Dv,Hv=Ov,Wv=Rv,Gv=Pv;const qv=Sv,Yv=Nv,Kv=Jo(Ev);l.forwardRef(((e,t)=>{const n=N.c(14);let r,o,s,i,a,l,c;return n[0]!==e?(({className:o,inset:s,children:r,...i}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==o||n[6]!==s?(a=Xo({className:o,inset:s}),n[5]=o,n[6]=s,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(ns,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==r||n[10]!==i||n[11]!==t||n[12]!==a?(c=_.jsxs(Wv,{ref:t,className:a,...i,children:[r,l]}),n[9]=r,n[10]=i,n[11]=t,n[12]=a,n[13]=c):c=n[13],c})).displayName=Wv.displayName;const Jv="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";l.forwardRef(((e,t)=>{const n=N.c(9);let r,o,s,i;return n[0]!==e?(({className:r,...o}=e),n[0]=e,n[1]=r,n[2]=o):(r=n[1],o=n[2]),n[3]!==r?(s=$t(Zo({subcontent:!0}),Jv,r),n[3]=r,n[4]=s):s=n[4],n[5]!==o||n[6]!==t||n[7]!==s?(i=_.jsx(Gv,{ref:t,className:s,...o}),n[5]=o,n[6]=t,n[7]=s,n[8]=i):i=n[8],i})).displayName=Gv.displayName;const Xv=l.forwardRef(((e,t)=>{const n=N.c(15);let r,o,s;n[0]!==e?(({className:r,scrollable:s,...o}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]);const i=void 0===s||s;let a;n[4]!==r||n[5]!==i?(a=$t(Zo(),Jv,i&&"overflow-auto",r),n[4]=r,n[5]=i,n[6]=a):a=n[6];const l=i?"calc(var(--radix-context-menu-content-available-height) - 30px)":void 0;let c,d;return n[7]!==o.style||n[8]!==l?(c={...o.style,maxHeight:l},n[7]=o.style,n[8]=l,n[9]=c):c=n[9],n[10]!==o||n[11]!==t||n[12]!==a||n[13]!==c?(d=_.jsx(Kv,{children:_.jsx(Qo,{children:_.jsx(Fv,{ref:t,className:a,style:c,...o})})}),n[10]=o,n[11]=t,n[12]=a,n[13]=c,n[14]=d):d=n[14],d}));Xv.displayName=Fv.displayName;const Zv=l.forwardRef(((e,t)=>{const n=N.c(13);let r,o,s,i,a,l;return n[0]!==e?(({className:r,inset:o,variant:i,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==r||n[6]!==o||n[7]!==i?(a=Ko({className:r,inset:o,variant:i}),n[5]=r,n[6]=o,n[7]=i,n[8]=a):a=n[8],n[9]!==s||n[10]!==t||n[11]!==a?(l=_.jsx(Bv,{ref:t,className:a,...s}),n[9]=s,n[10]=t,n[11]=a,n[12]=l):l=n[12],l}));Zv.displayName=Bv.displayName;l.forwardRef(((e,t)=>{const n=N.c(15);let r,o,s,i,a,l,c,d;return n[0]!==e?(({className:s,children:o,checked:r,...i}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i):(r=n[1],o=n[2],s=n[3],i=n[4]),n[5]!==s?(a=es({className:s}),n[5]=s,n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=es(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx("span",{className:l,children:_.jsx(Vv,{children:_.jsx(rs,{className:"h-4 w-4"})})}),n[8]=c):c=n[8],n[9]!==r||n[10]!==o||n[11]!==i||n[12]!==t||n[13]!==a?(d=_.jsxs(Uv,{ref:t,className:a,checked:r,...i,children:[c,o]}),n[9]=r,n[10]=o,n[11]=i,n[12]=t,n[13]=a,n[14]=d):d=n[14],d})).displayName=Uv.displayName;l.forwardRef(((e,t)=>{const n=N.c(13);let r,o,s,i,a,l,c;return n[0]!==e?(({className:o,children:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=es({className:o}),n[4]=o,n[5]=i):i=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(a=es(),n[6]=a):a=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx("span",{className:a,children:_.jsx(Vv,{children:_.jsx(os,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==r||n[9]!==s||n[10]!==t||n[11]!==i?(c=_.jsxs($v,{ref:t,className:i,...s,children:[l,r]}),n[8]=r,n[9]=s,n[10]=t,n[11]=i,n[12]=c):c=n[12],c})).displayName=$v.displayName;l.forwardRef(((e,t)=>{const n=N.c(11);let r,o,s,i,a;return n[0]!==e?(({className:r,inset:o,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==r||n[5]!==o?(i=ts({className:r,inset:o}),n[4]=r,n[5]=o,n[6]=i):i=n[6],n[7]!==s||n[8]!==t||n[9]!==i?(a=_.jsx(zv,{ref:t,className:i,...s}),n[7]=s,n[8]=t,n[9]=i,n[10]=a):a=n[10],a})).displayName=zv.displayName;const Qv=l.forwardRef(((e,t)=>{const n=N.c(9);let r,o,s,i;return n[0]!==e?(({className:r,...o}=e),n[0]=e,n[1]=r,n[2]=o):(r=n[1],o=n[2]),n[3]!==r?(s=$t(Yo({className:r})),n[3]=r,n[4]=s):s=n[4],n[5]!==o||n[6]!==t||n[7]!==s?(i=_.jsx(Hv,{ref:t,className:s,...o}),n[5]=o,n[6]=t,n[7]=s,n[8]=i):i=n[8],i}));Qv.displayName=Hv.displayName;const ew=e=>{const t=N.c(14),{appClosed:n,onClick:r,tooltipContent:o}=e;let s;t[0]!==r?(s=()=>null==r?void 0:r({code:""}),t[0]=r,t[1]=s):s=t[1];const i=n&&" inactive-button";let a,l,c,d,u;return t[2]!==i?(a=$t("shoulder-button hover-action",i),t[2]=i,t[3]=a):a=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(ss,{strokeWidth:1.8}),t[4]=l):l=t[4],t[5]!==s||t[6]!==a?(c=_.jsx(rc,{onClick:s,className:a,onMouseDown:dt.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:l}),t[5]=s,t[6]=a,t[7]=c):c=t[7],t[8]!==c||t[9]!==o?(d=_.jsx(ht,{content:o,usePortal:!1,children:c}),t[8]=c,t[9]=o,t[10]=d):d=t[10],t[11]!==r||t[12]!==d?(u=_.jsx(tw,{onClick:r,children:d}),t[11]=r,t[12]=d,t[13]=u):u=t[13],u},tw=e=>{const t=N.c(24),{children:n,onClick:r}=e;if(!r)return n;let o,s,i,a,l,c,d,u,h,f,m,p;return t[0]!==n?(o=_.jsx(Yv,{children:n}),t[0]=n,t[1]=o):o=t[1],t[2]!==r?(s=e=>{e.stopPropagation(),r({code:""})},t[2]=r,t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx("div",{className:"mr-3 text-muted-foreground",children:_.jsx(Wl,{})}),t[4]=i):i=t[4],t[5]!==s?(a=_.jsxs(Zv,{onSelect:s,children:[i,"Python cell"]},"python"),t[5]=s,t[6]=a):a=t[6],t[7]!==r?(l=e=>{e.stopPropagation(),r({code:(new sn).defaultCode})},t[7]=r,t[8]=l):l=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx("div",{className:"mr-3 text-muted-foreground",children:_.jsx(Hl,{})}),t[9]=c):c=t[9],t[10]!==l?(d=_.jsxs(Zv,{onSelect:l,children:[c,"Markdown cell"]},"markdown"),t[10]=l,t[11]=d):d=t[11],t[12]!==r?(u=e=>{e.stopPropagation(),r({code:(new is).getDefaultCode()})},t[12]=r,t[13]=u):u=t[13],t[14]===Symbol.for("react.memo_cache_sentinel")?(h=_.jsx("div",{className:"mr-3 text-muted-foreground",children:_.jsx(Ne,{size:13,strokeWidth:1.5})}),t[14]=h):h=t[14],t[15]!==u?(f=_.jsxs(Zv,{onSelect:u,children:[h,"SQL cell"]},"sql"),t[15]=u,t[16]=f):f=t[16],t[17]!==a||t[18]!==d||t[19]!==f?(m=_.jsxs(Xv,{children:[a,d,f]}),t[17]=a,t[18]=d,t[19]=f,t[20]=m):m=t[20],t[21]!==o||t[22]!==m?(p=_.jsxs(qv,{children:[o,m]}),t[21]=o,t[22]=m,t[23]=p):p=t[23],p},nw=as("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"}}),rw=e=>{const t=N.c(21);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:s,disabled:o,variant:i,...r}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=void 0!==o&&o;let l,c,d;t[6]!==a||t[7]!==r?(l=e=>{var t;a||null==(t=r.onClick)||t.call(r,e)},t[6]=a,t[7]=r,t[8]=l):l=t[8],t[9]!==r.className||t[10]!==i?(c=$t(nw({variant:i}),r.className),t[9]=r.className,t[10]=i,t[11]=c):c=t[11],t[12]!==n||t[13]!==a||t[14]!==r||t[15]!==l||t[16]!==c?(d=_.jsx("button",{disabled:a,...r,onClick:l,onMouseDown:dt.preventFocus,className:c,children:n}),t[12]=n,t[13]=a,t[14]=r,t[15]=l,t[16]=c,t[17]=d):d=t[17];const u=d;if(s){let e;return t[18]!==u||t[19]!==s?(e=_.jsx(ht,{content:s,side:"top",delayDuration:200,usePortal:!1,children:u}),t[18]=u,t[19]=s,t[20]=e):e=t[20],e}return u},ow=e=>{const t=N.c(5),{children:n,className:r}=e;let o,s;return t[0]!==r?(o=$t("flex items-center gap-1 bg-background m-[2px] rounded-full",r),t[0]=r,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(s=_.jsx(Ru,{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s};const sw=e=>{const t=N.c(22),{onClick:n,appClosed:r,needsRun:o,status:s,config:i,edited:a}=e,l="disabled-transitively"===s,c="running"===s||"queued"===s,d=r||c||!i.disabled&&l&&!a;let u;t[0]!==r||t[1]!==d||t[2]!==c||t[3]!==o?(u=function(e,t,n,r){return e?"disabled":t&&!n?"stale":n||r?"disabled":"green"}(r,o,c,d),t[0]=r,t[1]=d,t[2]=c,t[3]=o,t[4]=u):u=t[4];const h=u;if(i.disabled){let e,r;return t[5]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(Wd,{}),t[5]=e):e=t[5],t[6]!==d||t[7]!==n||t[8]!==h?(r=_.jsx(rw,{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]=r):r=t[9],r}if(!i.disabled&&l&&!a){let e,r;return t[10]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(_c,{strokeWidth:1.2}),t[10]=e):e=t[10],t[11]!==d||t[12]!==n||t[13]!==h?(r=_.jsx(rw,{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]=r):r=t[14],r}let f,m,p;if(r)f="App disconnected";else if("queued"===s)f="This cell is already queued to run";else if("running"===s)f="This cell is already running.";else{let e;t[15]===Symbol.for("react.memo_cache_sentinel")?(e=fn("cell.run"),t[15]=e):e=t[15],f=e}return t[16]===Symbol.for("react.memo_cache_sentinel")?(m=_.jsx(_c,{strokeWidth:1.2}),t[16]=m):m=t[16],t[17]!==d||t[18]!==n||t[19]!==f||t[20]!==h?(p=_.jsx(rw,{tooltip:f,disabled:d,onClick:n,variant:h,"data-testid":"run-button",children:m}),t[17]=d,t[18]=n,t[19]=f,t[20]=h,t[21]=p):p=t[21],p},iw=e=>{const t=N.c(10),{status:n,appClosed:r,onClick:o}=e;let s;s=r?"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=s,a=(r||("running"===n||"queued"===n))&&"inactive-button";let l,c,d,u,h;return t[0]!==a?(l=$t("hover:bg-transparent text-destructive/60 hover:text-destructive",a),t[0]=a,t[1]=l):l=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(c={boxShadow:"none"},d=_.jsx(De,{size:14}),t[2]=c,t[3]=d):(c=t[2],d=t[3]),t[4]!==o||t[5]!==l?(u=_.jsx(ee,{variant:"ghost",size:"icon",onClick:o,"data-testid":"delete-button",onMouseDown:dt.preventFocus,className:l,style:c,children:d}),t[4]=o,t[5]=l,t[6]=u):u=t[6],t[7]!==u||t[8]!==s?(h=_.jsx(ht,{content:i,usePortal:!1,children:u}),t[7]=u,t[8]=s,t[9]=h):h=t[9],h};const aw=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),lw=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),cw=e=>{const t=N.c(79),{editing:n,status:r,disabled:o,staleInputs:s,edited:i,interrupted:a,elapsedTime:l,runStartTimestamp:c,lastRunStartTimestamp:d,uninstantiated:u}=e;if(!n)return null;const h=c??d;let f;t[0]!==h?(f=h?_.jsx(uw,{lastRanTime:h}):null,t[0]=h,t[1]=f):f=t[1];const m=f;if(o&&"running"===r)return X.error("CellStatusComponent: disabled and running"),null;if(o&&s){let e,n,r,o;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=_.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=_.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")?(r=_.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:_.jsxs(Ku,{children:[_.jsx(wd,{className:"h-5 w-5",strokeWidth:1.5}),_.jsx(cs,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[5]=r):r=t[5],t[6]!==n?(o=_.jsx(ht,{content:n,usePortal:!0,children:r}),t[6]=n,t[7]=o):o=t[7],o}if(o){let e,n,r,o;return t[8]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{children:"This cell is disabled"}),t[8]=e):e=t[8],t[9]!==m?(n=_.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")?(r=_.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:_.jsx(wd,{className:"h-5 w-5",strokeWidth:1.5})}),t[11]=r):r=t[11],t[12]!==n?(o=_.jsx(ht,{content:n,usePortal:!0,children:r}),t[12]=n,t[13]=o):o=t[13],o}if(!s&&"disabled-transitively"===r){let e,n,r,o;return t[14]===Symbol.for("react.memo_cache_sentinel")?(e=_.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=_.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")?(r=_.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:_.jsxs(Ku,{layerTop:!0,children:[_.jsx(Tu,{className:"h-5 w-5",strokeWidth:1.5}),_.jsx(wd,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[17]=r):r=t[17],t[18]!==n?(o=_.jsx(ht,{content:n,usePortal:!0,children:r}),t[18]=n,t[19]=o):o=t[19],o}if(s&&"disabled-transitively"===r){let e,n,r,o;return t[20]===Symbol.for("react.memo_cache_sentinel")?(e=_.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=_.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")?(r=_.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:_.jsxs(Ku,{children:[_.jsx(cs,{className:"h-5 w-5",strokeWidth:1}),_.jsx(wd,{className:"h-3 w-3",strokeWidth:2.5})]})}),t[23]=r):r=t[23],t[24]!==n?(o=_.jsx(ht,{content:n,usePortal:!0,children:r}),t[24]=n,t[25]=o):o=t[25],o}if("running"===r){let e,n,r,o,s;return t[26]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{children:"This cell is running"}),t[26]=e):e=t[26],t[27]!==m?(n=_.jsxs("div",{className:"flex flex-col gap-1",children:[e,m]}),t[27]=m,t[28]=n):n=t[28],t[29]!==c?(r=ls.fromSeconds(c)||ls.now(),t[29]=c,t[30]=r):r=t[30],t[31]!==r?(o=_.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:_.jsx(fw,{startTime:r})}),t[31]=r,t[32]=o):o=t[32],t[33]!==n||t[34]!==o?(s=_.jsx(ht,{content:n,usePortal:!0,children:o}),t[33]=n,t[34]=o,t[35]=s):s=t[35],s}if("queued"===r){let e,n,r,o;return t[36]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{children:"This cell is queued to run"}),t[36]=e):e=t[36],t[37]!==m?(n=_.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")?(r=_.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:_.jsx(Bc,{className:"h-5 w-5",strokeWidth:1.5})}),t[39]=r):r=t[39],t[40]!==n?(o=_.jsx(ht,{content:n,usePortal:!0,children:r}),t[40]=n,t[41]=o):o=t[41],o}if(i||a||s||u){let e;t[42]!==l?(e=hw(l),t[42]=l,t[43]=e):e=t[43];const n=e;let r;t[44]!==l||t[45]!==n?(r=l?_.jsx(dw,{elapsedTime:n}):null,t[44]=l,t[45]=n,t[46]=r):r=t[46];const o=r;let s,c,d,h,f,p="";if(u)s="This cell has not yet been run";else if(a){let e;s="This cell was interrupted when it was last run",t[47]!==o?(e=_.jsxs("span",{children:["This cell ran for ",o," before being interrupted"]}),t[47]=o,t[48]=e):e=t[48],p=e}else if(i){let e;s="This cell has been modified since it was last run",t[49]!==o?(e=_.jsxs("span",{children:["This cell took ",o," to run"]}),t[49]=o,t[50]=e):e=t[50],p=e}else{let e;s="This cell has not been run with the latest inputs",t[51]!==o?(e=_.jsxs("span",{children:["This cell took ",o," to run"]}),t[51]=o,t[52]=e):e=t[52],p=e}return t[53]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:_.jsx(cs,{className:"h-5 w-5",strokeWidth:1.5})}),t[53]=c):c=t[53],t[54]!==s?(d=_.jsx(ht,{content:s,usePortal:!0,children:c}),t[54]=s,t[55]=d):d=t[55],t[56]!==l||t[57]!==n||t[58]!==m||t[59]!==p?(h=l&&_.jsx(ht,{content:_.jsxs("div",{className:"flex flex-col gap-1",children:[p,m]}),usePortal:!0,children:_.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:_.jsx("span",{children:n})})}),t[56]=l,t[57]=n,t[58]=m,t[59]=p,t[60]=h):h=t[60],t[61]!==d||t[62]!==h?(f=_.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=hw(l),t[64]=l,t[65]=e):e=t[65];const n=e;let r;t[66]!==l||t[67]!==n?(r=l?_.jsx(dw,{elapsedTime:n}):null,t[66]=l,t[67]=n,t[68]=r):r=t[68];const o=r;let s,i,a,c;return t[69]!==o?(s=_.jsxs("span",{children:["This cell took ",o," to run"]}),t[69]=o,t[70]=s):s=t[70],t[71]!==m||t[72]!==s?(i=_.jsxs("div",{className:"flex flex-col gap-1",children:[s,m]}),t[71]=m,t[72]=s,t[73]=i):i=t[73],t[74]!==n?(a=_.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:_.jsx("span",{children:n})}),t[74]=n,t[75]=a):a=t[75],t[76]!==i||t[77]!==a?(c=_.jsx(ht,{content:i,usePortal:!0,children:a}),t[76]=i,t[77]=a,t[78]=c):c=t[78],c}return null},dw=e=>{const t=N.c(2);let n;return t[0]!==e.elapsedTime?(n=_.jsx("span",{className:"tracking-wide font-semibold",children:e.elapsedTime}),t[0]=e.elapsedTime,t[1]=n):n=t[1],n},uw=e=>{const t=N.c(18),n=1e3*e.lastRanTime;let r,o,s,i,a,l,c,d,u;if(t[0]!==n){const e=new Date(n),d=new Date,u=e.toDateString()===d.toDateString()?aw:lw;i="Ran at",a=" ",l=_.jsx("strong",{className:"tracking-wide font-semibold",children:u.format(e)}),c=" ",r="text-muted-foreground",o="(",s=Bu(e),t[0]=n,t[1]=r,t[2]=o,t[3]=s,t[4]=i,t[5]=a,t[6]=l,t[7]=c}else r=t[1],o=t[2],s=t[3],i=t[4],a=t[5],l=t[6],c=t[7];return t[8]!==r||t[9]!==o||t[10]!==s?(d=_.jsxs("span",{className:r,children:[o,s," ago)"]}),t[8]=r,t[9]=o,t[10]=s,t[11]=d):d=t[11],t[12]!==i||t[13]!==a||t[14]!==l||t[15]!==c||t[16]!==d?(u=_.jsxs("span",{children:[i,a,l,c,d]}),t[12]=i,t[13]=a,t[14]=l,t[15]=c,t[16]=d,t[17]=u):u=t[17],u};function hw(e){if(null===e)return"";const t=e,n=t/1e3;if(n>=60){return`${Math.floor(n/60)}m${Math.floor(n%60)}s`}return n>=1?`${n.toFixed(2).toString()}s`:`${t.toFixed(0).toString()}ms`}const fw=e=>{const t=N.c(6);let n;t[0]!==e.startTime?(n=e.startTime.toMilliseconds(),t[0]=e.startTime,t[1]=n):n=t[1];const r=function(e){const t=l.useRef(e),[n,r]=l.useState(e);return l.useEffect((()=>{const e=setInterval((()=>{r(ls.now().toMilliseconds())}),17);return()=>clearInterval(e)}),[]),n-t.current}(n);let o,s;return t[2]!==r?(o=hw(r),t[2]=r,t[3]=o):o=t[3],t[4]!==o?(s=_.jsx("span",{children:o}),t[4]=o,t[5]=s):s=t[5],s},mw={display:"none"};function pw(e){let{id:t,value:n}=e;return p.createElement("div",{id:t,style:mw},n)}function gw(e){let{id:t,announcement:n,ariaLiveType:r="assertive"}=e;return p.createElement("div",{id:t,style:{position:"fixed",top:0,left:0,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":r,"aria-atomic":!0},n)}const yw=l.createContext(null);const bw={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 "},xw={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 vw(e){let{announcements:t=xw,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=bw}=e;const{announce:s,announcement:i}=function(){const[e,t]=l.useState("");return{announce:l.useCallback((e=>{null!=e&&t(e)}),[]),announcement:e}}(),a=ds("DndLiveRegion"),[c,d]=l.useState(!1);if(l.useEffect((()=>{d(!0)}),[]),function(e){const t=l.useContext(yw);l.useEffect((()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)}),[e,t])}(l.useMemo((()=>({onDragStart(e){let{active:n}=e;s(t.onDragStart({active:n}))},onDragMove(e){let{active:n,over:r}=e;t.onDragMove&&s(t.onDragMove({active:n,over:r}))},onDragOver(e){let{active:n,over:r}=e;s(t.onDragOver({active:n,over:r}))},onDragEnd(e){let{active:n,over:r}=e;s(t.onDragEnd({active:n,over:r}))},onDragCancel(e){let{active:n,over:r}=e;s(t.onDragCancel({active:n,over:r}))}})),[s,t])),!c)return null;const u=p.createElement(p.Fragment,null,p.createElement(pw,{id:r,value:o.draggable}),p.createElement(gw,{id:a,announcement:i}));return n?Ns.createPortal(u,n):u}var ww,kw;function Sw(){}function Cw(e,t){return l.useMemo((()=>({sensor:e,options:null!=t?t:{}})),[e,t])}(kw=ww||(ww={})).DragStart="dragStart",kw.DragMove="dragMove",kw.DragEnd="dragEnd",kw.DragCancel="dragCancel",kw.DragOver="dragOver",kw.RegisterDroppable="registerDroppable",kw.SetDroppableDisabled="setDroppableDisabled",kw.UnregisterDroppable="unregisterDroppable";const Nw=Object.freeze({x:0,y:0});function Ew(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function jw(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return n-r}function _w(e,t){let{data:{value:n}}=e,{data:{value:r}}=t;return r-n}function Iw(e){let{left:t,top:n,height:r,width:o}=e;return[{x:t,y:n},{x:t+o,y:n},{x:t,y:n+r},{x:t+o,y:n+r}]}function Aw(e,t){if(!e||0===e.length)return null;const[n]=e;return t?n[t]:n}function Tw(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 Mw=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Tw(t,t.left,t.top),s=[];for(const i of r){const{id:e}=i,t=n.get(e);if(t){const n=Ew(Tw(t),o);s.push({id:e,data:{droppableContainer:i,value:n}})}}return s.sort(jw)};function Dw(e,t){const n=Math.max(t.top,e.top),r=Math.max(t.left,e.left),o=Math.min(t.left+t.width,e.left+e.width),s=Math.min(t.top+t.height,e.top+e.height),i=o-r,a=s-n;if(r<o&&n<s){const n=t.width*t.height,r=e.width*e.height,o=i*a;return Number((o/(n+r-o)).toFixed(4))}return 0}const Ow=e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=[];for(const s of r){const{id:e}=s,r=n.get(e);if(r){const n=Dw(r,t);n>0&&o.push({id:e,data:{droppableContainer:s,value:n}})}}return o.sort(_w)};function Rw(e,t){const{top:n,left:r,bottom:o,right:s}=t;return n<=e.y&&e.y<=o&&r<=e.x&&e.x<=s}function Pw(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Nw}function Lw(e){return function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.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 Fw=Lw(1);const zw={ignoreTransform:!1};function Bw(e,t){void 0===t&&(t=zw);let n=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:t,transformOrigin:r}=ps(e).getComputedStyle(e);t&&(n=function(e,t,n){const r=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(!r)return e;const{scaleX:o,scaleY:s,x:i,y:a}=r,l=e.left-i-(1-o)*parseFloat(n),c=e.top-a-(1-s)*parseFloat(n.slice(n.indexOf(" ")+1)),d=o?e.width/o:e.width,u=s?e.height/s:e.height;return{width:d,height:u,top:c,right:l+d,bottom:c+u,left:l}}(n,t,r))}const{top:r,left:o,width:s,height:i,bottom:a,right:l}=n;return{top:r,left:o,width:s,height:i,bottom:a,right:l}}function Uw(e){return Bw(e,{ignoreTransform:!0})}function $w(e,t){const n=[];return e?function r(o){if(null!=t&&n.length>=t)return n;if(!o)return n;if(ks(o)&&null!=o.scrollingElement&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!Ss(o)||Cs(o))return n;if(n.includes(o))return n;const s=ps(e).getComputedStyle(o);return o!==e&&function(e,t){void 0===t&&(t=ps(e).getComputedStyle(e));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some((e=>{const r=t[e];return"string"==typeof r&&n.test(r)}))}(o,s)&&n.push(o),function(e,t){return void 0===t&&(t=ps(e).getComputedStyle(e)),"fixed"===t.position}(o,s)?n:r(o.parentNode)}(e):n}function Vw(e){const[t]=$w(e,1);return null!=t?t:null}function Hw(e){return ws&&e?As(e)?e:Ts(e)?ks(e)||e===gs(e).scrollingElement?window:Ss(e)?e:null:null:null}function Ww(e){return As(e)?e.scrollX:e.scrollLeft}function Gw(e){return As(e)?e.scrollY:e.scrollTop}function qw(e){return{x:Ww(e),y:Gw(e)}}var Yw,Kw;function Jw(e){return!(!ws||!e)&&e===document.scrollingElement}function Xw(e){const t={x:0,y:0},n=Jw(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-n.width,y:e.scrollHeight-n.height};return{isTop:e.scrollTop<=t.y,isLeft:e.scrollLeft<=t.x,isBottom:e.scrollTop>=r.y,isRight:e.scrollLeft>=r.x,maxScroll:r,minScroll:t}}(Kw=Yw||(Yw={}))[Kw.Forward=1]="Forward",Kw[Kw.Backward=-1]="Backward";const Zw={x:.2,y:.2};function Qw(e,t,n,r,o){let{top:s,left:i,right:a,bottom:l}=n;void 0===r&&(r=10),void 0===o&&(o=Zw);const{isTop:c,isBottom:d,isLeft:u,isRight:h}=Xw(e),f={x:0,y:0},m={x:0,y:0},p=t.height*o.y,g=t.width*o.x;return!c&&s<=t.top+p?(f.y=Yw.Backward,m.y=r*Math.abs((t.top+p-s)/p)):!d&&l>=t.bottom-p&&(f.y=Yw.Forward,m.y=r*Math.abs((t.bottom-p-l)/p)),!h&&a>=t.right-g?(f.x=Yw.Forward,m.x=r*Math.abs((t.right-g-a)/g)):!u&&i<=t.left+g&&(f.x=Yw.Backward,m.x=r*Math.abs((t.left+g-i)/g)),{direction:f,speed:m}}function ek(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:r,bottom:o}=e.getBoundingClientRect();return{top:t,left:n,right:r,bottom:o,width:e.clientWidth,height:e.clientHeight}}function tk(e){return e.reduce(((e,t)=>xs(e,qw(t))),Nw)}const nk=[["x",["left","right"],function(e){return e.reduce(((e,t)=>e+Ww(t)),0)}],["y",["top","bottom"],function(e){return e.reduce(((e,t)=>e+Gw(t)),0)}]];class rk{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=$w(t),r=tk(n);this.rect={...e},this.width=e.width,this.height=e.height;for(const[o,s,i]of nk)for(const e of s)Object.defineProperty(this,e,{get:()=>{const t=i(n),s=r[o]-t;return this.rect[e]+s},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class ok{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 r;null==(r=this.target)||r.addEventListener(e,t,n),this.listeners.push([e,t,n])}}function sk(e,t){const n=Math.abs(e.x),r=Math.abs(e.y);return"number"==typeof t?Math.sqrt(n**2+r**2)>t:"x"in t&&"y"in t?n>t.x&&r>t.y:"x"in t?n>t.x:"y"in t&&r>t.y}var ik,ak,lk,ck;function dk(e){e.preventDefault()}function uk(e){e.stopPropagation()}(ak=ik||(ik={})).Click="click",ak.DragStart="dragstart",ak.Keydown="keydown",ak.ContextMenu="contextmenu",ak.Resize="resize",ak.SelectionChange="selectionchange",ak.VisibilityChange="visibilitychange",(ck=lk||(lk={})).Space="Space",ck.Down="ArrowDown",ck.Right="ArrowRight",ck.Left="ArrowLeft",ck.Up="ArrowUp",ck.Esc="Escape",ck.Enter="Enter",ck.Tab="Tab";const hk={start:[lk.Space,lk.Enter],cancel:[lk.Esc],end:[lk.Space,lk.Enter,lk.Tab]},fk=(e,t)=>{let{currentCoordinates:n}=t;switch(e.code){case lk.Right:return{...n,x:n.x+25};case lk.Left:return{...n,x:n.x-25};case lk.Down:return{...n,y:n.y+25};case lk.Up:return{...n,y:n.y-25}}};class mk{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 ok(gs(t)),this.windowListeners=new ok(ps(t)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(ik.Resize,this.handleCancel),this.windowListeners.add(ik.VisibilityChange,this.handleCancel),setTimeout((()=>this.listeners.add(ik.Keydown,this.handleKeyDown)))}handleStart(){const{activeNode:e,onStart:t}=this.props,n=e.node.current;n&&function(e,t){if(void 0===t&&(t=Bw),!e)return;const{top:n,left:r,bottom:o,right:s}=t(e);Vw(e)&&(o<=0||s<=0||n>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}(n),t(Nw)}handleKeyDown(e){if(ys(e)){const{active:t,context:n,options:r}=this.props,{keyboardCodes:o=hk,coordinateGetter:s=fk,scrollBehavior:i="smooth"}=r,{code:a}=e;if(o.end.includes(a))return void this.handleEnd(e);if(o.cancel.includes(a))return void this.handleCancel(e);const{collisionRect:l}=n.current,c=l?{x:l.left,y:l.top}:Nw;this.referenceCoordinates||(this.referenceCoordinates=c);const d=s(e,{active:t,context:n.current,currentCoordinates:c});if(d){const t=bs(d,c),r={x:0,y:0},{scrollableAncestors:o}=n.current;for(const n of o){const o=e.code,{isTop:s,isRight:a,isLeft:l,isBottom:c,maxScroll:u,minScroll:h}=Xw(n),f=ek(n),m={x:Math.min(o===lk.Right?f.right-f.width/2:f.right,Math.max(o===lk.Right?f.left:f.left+f.width/2,d.x)),y:Math.min(o===lk.Down?f.bottom-f.height/2:f.bottom,Math.max(o===lk.Down?f.top:f.top+f.height/2,d.y))},p=o===lk.Right&&!a||o===lk.Left&&!l,g=o===lk.Down&&!c||o===lk.Up&&!s;if(p&&m.x!==d.x){const e=n.scrollLeft+t.x,s=o===lk.Right&&e<=u.x||o===lk.Left&&e>=h.x;if(s&&!t.y)return void n.scrollTo({left:e,behavior:i});r.x=s?n.scrollLeft-e:o===lk.Right?n.scrollLeft-u.x:n.scrollLeft-h.x,r.x&&n.scrollBy({left:-r.x,behavior:i});break}if(g&&m.y!==d.y){const e=n.scrollTop+t.y,s=o===lk.Down&&e<=u.y||o===lk.Up&&e>=h.y;if(s&&!t.x)return void n.scrollTo({top:e,behavior:i});r.y=s?n.scrollTop-e:o===lk.Down?n.scrollTop-u.y:n.scrollTop-h.y,r.y&&n.scrollBy({top:-r.y,behavior:i});break}}this.handleMove(e,xs(bs(d,this.referenceCoordinates),r))}}}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 pk(e){return Boolean(e&&"distance"in e)}function gk(e){return Boolean(e&&"delay"in e)}mk.activators=[{eventName:"onKeyDown",handler:(e,t,n)=>{let{keyboardCodes:r=hk,onActivation:o}=t,{active:s}=n;const{code:i}=e.nativeEvent;if(r.start.includes(i)){const t=s.activatorNode.current;return(!t||e.target===t)&&(e.preventDefault(),null==o||o({event:e.nativeEvent}),!0)}return!1}}];class yk{constructor(e,t,n){var r;void 0===n&&(n=function(e){const{EventTarget:t}=ps(e);return e instanceof t?e:gs(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:o}=e,{target:s}=o;this.props=e,this.events=t,this.document=gs(s),this.documentListeners=new ok(this.document),this.listeners=new ok(n),this.windowListeners=new ok(ps(s)),this.initialCoordinates=null!=(r=vs(o))?r:Nw,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),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(ik.Resize,this.handleCancel),this.windowListeners.add(ik.DragStart,dk),this.windowListeners.add(ik.VisibilityChange,this.handleCancel),this.windowListeners.add(ik.ContextMenu,dk),this.documentListeners.add(ik.Keydown,this.handleKeydown),t){if(null!=n&&n({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(gk(t))return this.timeoutId=setTimeout(this.handleStart,t.delay),void this.handlePending(t);if(pk(t))return void this.handlePending(t)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),null!==this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,t){const{active:n,onPending:r}=this.props;r(n,e,this.initialCoordinates,t)}handleStart(){const{initialCoordinates:e}=this,{onStart:t}=this.props;e&&(this.activated=!0,this.documentListeners.add(ik.Click,uk,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(ik.SelectionChange,this.removeTextSelection),t(e))}handleMove(e){var t;const{activated:n,initialCoordinates:r,props:o}=this,{onMove:s,options:{activationConstraint:i}}=o;if(!r)return;const a=null!=(t=vs(e))?t:Nw,l=bs(r,a);if(!n&&i){if(pk(i)){if(null!=i.tolerance&&sk(l,i.tolerance))return this.handleCancel();if(sk(l,i.distance))return this.handleStart()}return gk(i)&&sk(l,i.tolerance)?this.handleCancel():void this.handlePending(i,l)}e.cancelable&&e.preventDefault(),s(a)}handleEnd(){const{onAbort:e,onEnd:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleCancel(){const{onAbort:e,onCancel:t}=this.props;this.detach(),this.activated||e(this.props.active),t()}handleKeydown(e){e.code===lk.Esc&&this.handleCancel()}removeTextSelection(){var e;null==(e=this.document.getSelection())||e.removeAllRanges()}}const bk={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class xk extends yk{constructor(e){const{event:t}=e,n=gs(t.target);super(e,bk,n)}}xk.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return!(!n.isPrimary||0!==n.button)&&(null==r||r({event:n}),!0)}}];const vk={move:{name:"mousemove"},end:{name:"mouseup"}};var wk,kk;(kk=wk||(wk={}))[kk.RightClick=2]="RightClick";(class extends yk{constructor(e){super(e,vk,gs(e.event.target))}}).activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;return n.button!==wk.RightClick&&(null==r||r({event:n}),!0)}}];const Sk={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Ck,Nk,Ek,jk;function _k(e){let{acceleration:t,activator:n=Ck.Pointer,canScroll:r,draggingRect:o,enabled:s,interval:i=5,order:a=Ek.TreeOrder,pointerCoordinates:c,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=e;const m=function(e){let{delta:t,disabled:n}=e;const r=_s(t);return Es((e=>{if(n||!r||!e)return Ik;const o={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[Yw.Backward]:e.x[Yw.Backward]||-1===o.x,[Yw.Forward]:e.x[Yw.Forward]||1===o.x},y:{[Yw.Backward]:e.y[Yw.Backward]||-1===o.y,[Yw.Forward]:e.y[Yw.Forward]||1===o.y}}}),[n,t,r])}({delta:h,disabled:!s}),[p,g]=js(),y=l.useRef({x:0,y:0}),b=l.useRef({x:0,y:0}),x=l.useMemo((()=>{switch(n){case Ck.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case Ck.DraggableRect:return o}}),[n,o,c]),v=l.useRef(null),w=l.useCallback((()=>{const e=v.current;if(!e)return;const t=y.current.x*b.current.x,n=y.current.y*b.current.y;e.scrollBy(t,n)}),[]),k=l.useMemo((()=>a===Ek.TreeOrder?[...d].reverse():d),[a,d]);l.useEffect((()=>{if(s&&d.length&&x){for(const e of k){if(!1===(null==r?void 0:r(e)))continue;const n=d.indexOf(e),o=u[n];if(!o)continue;const{direction:s,speed:a}=Qw(e,o,x,t,f);for(const e of["x","y"])m[e][s[e]]||(a[e]=0,s[e]=0);if(a.x>0||a.y>0)return g(),v.current=e,p(w,i),y.current=a,void(b.current=s)}y.current={x:0,y:0},b.current={x:0,y:0},g()}else g()}),[t,w,r,g,s,i,JSON.stringify(x),JSON.stringify(m),p,d,k,u,JSON.stringify(f)])}(class extends yk{constructor(e){super(e,Sk)}static setup(){return window.addEventListener(Sk.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Sk.move.name,e)};function e(){}}}).activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:n}=e,{onActivation:r}=t;const{touches:o}=n;return!(o.length>1)&&(null==r||r({event:n}),!0)}}],(Nk=Ck||(Ck={}))[Nk.Pointer=0]="Pointer",Nk[Nk.DraggableRect=1]="DraggableRect",(jk=Ek||(Ek={}))[jk.TreeOrder=0]="TreeOrder",jk[jk.ReversedTreeOrder=1]="ReversedTreeOrder";const Ik={x:{[Yw.Backward]:!1,[Yw.Forward]:!1},y:{[Yw.Backward]:!1,[Yw.Forward]:!1}};var Ak,Tk,Mk;(Tk=Ak||(Ak={}))[Tk.Always=0]="Always",Tk[Tk.BeforeDragging=1]="BeforeDragging",Tk[Tk.WhileDragging=2]="WhileDragging",(Mk||(Mk={})).Optimized="optimized";const Dk=new Map;function Ok(e,t){return Es((n=>e?n||("function"==typeof t?t(e):e):null),[t,e])}function Rk(e){let{callback:t,disabled:n}=e;const r=ms(t),o=l.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.ResizeObserver)return;const{ResizeObserver:e}=window;return new e(r)}),[n]);return l.useEffect((()=>()=>null==o?void 0:o.disconnect()),[o]),o}function Pk(e){return new rk(Bw(e),e)}function Lk(e,t,n){void 0===t&&(t=Pk);const[r,o]=l.useState(null);function s(){o((r=>{if(!e)return null;var o;if(!1===e.isConnected)return null!=(o=null!=r?r:n)?o:null;const s=t(e);return JSON.stringify(r)===JSON.stringify(s)?r:s}))}const i=function(e){let{callback:t,disabled:n}=e;const r=ms(t),o=l.useMemo((()=>{if(n||"undefined"==typeof window||void 0===window.MutationObserver)return;const{MutationObserver:e}=window;return new e(r)}),[r,n]);return l.useEffect((()=>()=>null==o?void 0:o.disconnect()),[o]),o}({callback(t){if(e)for(const n of t){const{type:t,target:r}=n;if("childList"===t&&r instanceof HTMLElement&&r.contains(e)){s();break}}}}),a=Rk({callback:s});return fs((()=>{s(),e?(null==a||a.observe(e),null==i||i.observe(document.body,{childList:!0,subtree:!0})):(null==a||a.disconnect(),null==i||i.disconnect())}),[e]),r}const Fk=[];function zk(e,t){void 0===t&&(t=[]);const n=l.useRef(null);return l.useEffect((()=>{n.current=null}),t),l.useEffect((()=>{const t=e!==Nw;t&&!n.current&&(n.current=e),!t&&n.current&&(n.current=null)}),[e]),n.current?bs(e,n.current):Nw}function Bk(e){return l.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 Uk=[];function $k(e){let{measure:t}=e;const[n,r]=l.useState(null),o=Rk({callback:l.useCallback((e=>{for(const{target:n}of e)if(Ss(n)){r((e=>{const r=t(n);return e?{...e,width:r.width,height:r.height}:r}));break}}),[t])}),s=l.useCallback((e=>{const n=function(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ss(t)?t:e}(e);null==o||o.disconnect(),n&&(null==o||o.observe(n)),r(n?t(n):null)}),[t,o]),[i,a]=hs(s);return l.useMemo((()=>({nodeRef:i,rect:n,setRef:a})),[n,i,a])}const Vk=[{sensor:xk,options:{}},{sensor:mk,options:{}}],Hk={current:{}},Wk={draggable:{measure:Uw},droppable:{measure:Uw,strategy:Ak.WhileDragging,frequency:Mk.Optimized},dragOverlay:{measure:Bw}};class Gk 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 qk={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Gk,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Sw},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Wk,measureDroppableContainers:Sw,windowRect:null,measuringScheduled:!1},Yk={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Sw,draggableNodes:new Map,over:null,measureDroppableContainers:Sw},Kk=l.createContext(Yk),Jk=l.createContext(qk);function Xk(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Gk}}}function Zk(e,t){switch(t.type){case ww.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case ww.DragMove:return null==e.draggable.active?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case ww.DragEnd:case ww.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ww.RegisterDroppable:{const{element:n}=t,{id:r}=n,o=new Gk(e.droppable.containers);return o.set(r,n),{...e,droppable:{...e.droppable,containers:o}}}case ww.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=t,s=e.droppable.containers.get(n);if(!s||r!==s.key)return e;const i=new Gk(e.droppable.containers);return i.set(n,{...s,disabled:o}),{...e,droppable:{...e.droppable,containers:i}}}case ww.UnregisterDroppable:{const{id:n,key:r}=t,o=e.droppable.containers.get(n);if(!o||r!==o.key)return e;const s=new Gk(e.droppable.containers);return s.delete(n),{...e,droppable:{...e.droppable,containers:s}}}default:return e}}function Qk(e){let{disabled:t}=e;const{active:n,activatorEvent:r,draggableNodes:o}=l.useContext(Kk),s=_s(r),i=_s(null==n?void 0:n.id);return l.useEffect((()=>{if(!t&&!r&&s&&null!=i){if(!ys(s))return;if(document.activeElement===s.target)return;const e=o.get(i);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=Is(e);if(t){t.focus();break}}}))}}),[r,t,o,i,s]),null}const eS=l.createContext({...Nw,scaleX:1,scaleY:1});var tS,nS;(nS=tS||(tS={}))[nS.Uninitialized=0]="Uninitialized",nS[nS.Initializing=1]="Initializing",nS[nS.Initialized=2]="Initialized";const rS=l.memo((function(e){var t,n,r,o;let{id:s,accessibility:i,autoScroll:a=!0,children:c,sensors:d=Vk,collisionDetection:u=Ow,measuring:h,modifiers:f,...m}=e;const g=l.useReducer(Zk,void 0,Xk),[y,b]=g,[x,v]=function(){const[e]=l.useState((()=>new Set)),t=l.useCallback((t=>(e.add(t),()=>e.delete(t))),[e]);return[l.useCallback((t=>{let{type:n,event:r}=t;e.forEach((e=>{var t;return null==(t=e[n])?void 0:t.call(e,r)}))}),[e]),t]}(),[w,k]=l.useState(tS.Uninitialized),S=w===tS.Initialized,{draggable:{active:C,nodes:N,translate:E},droppable:{containers:j}}=y,_=null!=C?N.get(C):null,I=l.useRef({initial:null,translated:null}),A=l.useMemo((()=>{var e;return null!=C?{id:C,data:null!=(e=null==_?void 0:_.data)?e:Hk,rect:I}:null}),[C,_]),T=l.useRef(null),[M,D]=l.useState(null),[O,R]=l.useState(null),P=us(m,Object.values(m)),L=ds("DndDescribedBy",s),F=l.useMemo((()=>j.getEnabled()),[j]),z=(B=h,l.useMemo((()=>({draggable:{...Wk.draggable,...null==B?void 0:B.draggable},droppable:{...Wk.droppable,...null==B?void 0:B.droppable},dragOverlay:{...Wk.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:$,measuringScheduled:V}=function(e,t){let{dragging:n,dependencies:r,config:o}=t;const[s,i]=l.useState(null),{frequency:a,measure:c,strategy:d}=o,u=l.useRef(e),h=function(){switch(d){case Ak.Always:return!1;case Ak.BeforeDragging:return n;default:return!n}}(),f=us(h),m=l.useCallback((function(e){void 0===e&&(e=[]),f.current||i((t=>null===t?e:t.concat(e.filter((e=>!t.includes(e))))))}),[f]),p=l.useRef(null),g=Es((t=>{if(h&&!n)return Dk;if(!t||t===Dk||u.current!==e||null!=s){const t=new Map;for(let n of e){if(!n)continue;if(s&&s.length>0&&!s.includes(n.id)&&n.rect.current){t.set(n.id,n.rect.current);continue}const e=n.node.current,r=e?new rk(c(e),e):null;n.rect.current=r,r&&t.set(n.id,r)}return t}return t}),[e,s,n,h,c]);return l.useEffect((()=>{u.current=e}),[e]),l.useEffect((()=>{h||m()}),[n,h]),l.useEffect((()=>{s&&s.length>0&&i(null)}),[JSON.stringify(s)]),l.useEffect((()=>{h||"number"!=typeof a||null!==p.current||(p.current=setTimeout((()=>{m(),p.current=null}),a))}),[a,h,m,...r]),{droppableRects:g,measureDroppableContainers:m,measuringScheduled:null!=s}}(F,{dragging:S,dependencies:[E.x,E.y],config:z.droppable}),H=function(e,t){const n=null!=t?e.get(t):void 0,r=n?n.node.current:null;return Es((e=>{var n;return null==t?null:null!=(n=null!=r?r:e)?n:null}),[r,t])}(N,C),W=l.useMemo((()=>O?vs(O):null),[O]),G=function(){const e=!1===(null==M?void 0:M.autoScrollEnabled),t="object"==typeof a?!1===a.enabled:!1===a,n=S&&!e&&!t;if("object"==typeof a)return{...a,enabled:n};return{enabled:n}}(),q=function(e,t){return Ok(e,t)}(H,z.draggable.measure);!function(e){let{activeNode:t,measure:n,initialRect:r,config:o=!0}=e;const s=l.useRef(!1),{x:i,y:a}="boolean"==typeof o?{x:o,y:o}:o;fs((()=>{if(!i&&!a||!t)return void(s.current=!1);if(s.current||!r)return;const e=null==t?void 0:t.node.current;if(!e||!1===e.isConnected)return;const o=Pw(n(e),r);if(i||(o.x=0),a||(o.y=0),s.current=!0,Math.abs(o.x)>0||Math.abs(o.y)>0){const t=Vw(e);t&&t.scrollBy({top:o.y,left:o.x})}}),[t,i,a,r,n])}({activeNode:null!=C?N.get(C):null,config:G.layoutShiftCompensation,initialRect:q,measure:z.draggable.measure});const Y=Lk(H,z.draggable.measure,q),K=Lk(H?H.parentElement:null),J=l.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:U,draggableNodes:N,draggingNode:null,draggingNodeRect:null,droppableContainers:j,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),X=j.getNodeFor(null==(t=J.current.over)?void 0:t.id),Z=$k({measure:z.dragOverlay.measure}),Q=null!=(n=Z.nodeRef.current)?n:H,ee=S?null!=(r=Z.rect)?r:Y:null,te=Boolean(Z.nodeRef.current&&Z.rect),ne=Pw(re=te?null:Y,Ok(re));var re;const oe=Bk(Q?ps(Q):null),se=function(e){const t=l.useRef(e),n=Es((n=>e?n&&n!==Fk&&e&&t.current&&e.parentNode===t.current.parentNode?n:$w(e):Fk),[e]);return l.useEffect((()=>{t.current=e}),[e]),n}(S?null!=X?X:H:null),ie=function(e,t){void 0===t&&(t=Bw);const[n]=e,r=Bk(n?ps(n):null),[o,s]=l.useState(Uk);function i(){s((()=>e.length?e.map((e=>Jw(e)?r:new rk(t(e),e))):Uk))}const a=Rk({callback:i});return fs((()=>{null==a||a.disconnect(),i(),e.forEach((e=>null==a?void 0:a.observe(e)))}),[e]),o}(se),ae=function(e,t){let{transform:n,...r}=t;return null!=e&&e.length?e.reduce(((e,t)=>t({transform:e,...r})),n):n}(f,{transform:{x:E.x-ne.x,y:E.y-ne.y,scaleX:1,scaleY:1},activatorEvent:O,active:A,activeNodeRect:Y,containerNodeRect:K,draggingNodeRect:ee,over:J.current.over,overlayNodeRect:Z.rect,scrollableAncestors:se,scrollableAncestorRects:ie,windowRect:oe}),le=W?xs(W,E):null,ce=function(e){const[t,n]=l.useState(null),r=l.useRef(e),o=l.useCallback((e=>{const t=Hw(e.target);t&&n((e=>e?(e.set(t,qw(t)),new Map(e)):null))}),[]);return l.useEffect((()=>{const t=r.current;if(e!==t){s(t);const i=e.map((e=>{const t=Hw(e);return t?(t.addEventListener("scroll",o,{passive:!0}),[t,qw(t)]):null})).filter((e=>null!=e));n(i.length?new Map(i):null),r.current=e}return()=>{s(e),s(t)};function s(e){e.forEach((e=>{const t=Hw(e);null==t||t.removeEventListener("scroll",o)}))}}),[o,e]),l.useMemo((()=>e.length?t?Array.from(t.values()).reduce(((e,t)=>xs(e,t)),Nw):tk(e):Nw),[e,t])}(se),de=zk(ce),ue=zk(ce,[Y]),he=xs(ae,de),fe=ee?Fw(ee,ae):null,me=A&&fe?u({active:A,collisionRect:fe,droppableRects:U,droppableContainers:F,pointerCoordinates:le}):null,pe=Aw(me,"id"),[ge,ye]=l.useState(null),be=function(e,t,n){return{...e,scaleX:t&&n?t.width/n.width:1,scaleY:t&&n?t.height/n.height:1}}(te?ae:xs(ae,ue),null!=(o=null==ge?void 0:ge.rect)?o:null,Y),xe=l.useRef(null),ve=l.useCallback(((e,t)=>{let{sensor:n,options:r}=t;if(null==T.current)return;const o=N.get(T.current);if(!o)return;const s=e.nativeEvent,i=new n({active:T.current,activeNode:o,event:s,options:r,context:J,onAbort(e){if(!N.get(e))return;const{onDragAbort:t}=P.current,n={id:e};null==t||t(n),x({type:"onDragAbort",event:n})},onPending(e,t,n,r){if(!N.get(e))return;const{onDragPending:o}=P.current,s={id:e,constraint:t,initialCoordinates:n,offset:r};null==o||o(s),x({type:"onDragPending",event:s})},onStart(e){const t=T.current;if(null==t)return;const n=N.get(t);if(!n)return;const{onDragStart:r}=P.current,o={activatorEvent:s,active:{id:t,data:n.data,rect:I}};Ns.unstable_batchedUpdates((()=>{null==r||r(o),k(tS.Initializing),b({type:ww.DragStart,initialCoordinates:e,active:t}),x({type:"onDragStart",event:o}),D(xe.current),R(s)}))},onMove(e){b({type:ww.DragMove,coordinates:e})},onEnd:a(ww.DragEnd),onCancel:a(ww.DragCancel)});function a(e){return async function(){const{active:t,collisions:n,over:r,scrollAdjustedTranslate:o}=J.current;let i=null;if(t&&o){const{cancelDrop:a}=P.current;if(i={activatorEvent:s,active:t,collisions:n,delta:o,over:r},e===ww.DragEnd&&"function"==typeof a){await Promise.resolve(a(i))&&(e=ww.DragCancel)}}T.current=null,Ns.unstable_batchedUpdates((()=>{b({type:e}),k(tS.Uninitialized),ye(null),D(null),R(null),xe.current=null;const t=e===ww.DragEnd?"onDragEnd":"onDragCancel";if(i){const e=P.current[t];null==e||e(i),x({type:t,event:i})}}))}}xe.current=i}),[N]),we=function(e,t){return l.useMemo((()=>e.reduce(((e,n)=>{const{sensor:r}=n;return[...e,...r.activators.map((e=>({eventName:e.eventName,handler:t(e.handler,n)})))]}),[])),[e,t])}(d,l.useCallback(((e,t)=>(n,r)=>{const o=n.nativeEvent,s=N.get(r);if(null!==T.current||!s||o.dndKit||o.defaultPrevented)return;const i={active:s};!0===e(n,t.options,i)&&(o.dndKit={capturedBy:t.sensor},T.current=r,ve(n,t))}),[N,ve]));!function(e){l.useEffect((()=>{if(!ws)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),fs((()=>{Y&&w===tS.Initializing&&k(tS.Initialized)}),[Y,w]),l.useEffect((()=>{const{onDragMove:e}=P.current,{active:t,activatorEvent:n,collisions:r,over:o}=J.current;if(!t||!n)return;const s={active:t,activatorEvent:n,collisions:r,delta:{x:he.x,y:he.y},over:o};Ns.unstable_batchedUpdates((()=>{null==e||e(s),x({type:"onDragMove",event:s})}))}),[he.x,he.y]),l.useEffect((()=>{const{active:e,activatorEvent:t,collisions:n,droppableContainers:r,scrollAdjustedTranslate:o}=J.current;if(!e||null==T.current||!t||!o)return;const{onDragOver:s}=P.current,i=r.get(pe),a=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:o.x,y:o.y},over:a};Ns.unstable_batchedUpdates((()=>{ye(a),null==s||s(l),x({type:"onDragOver",event:l})}))}),[pe]),fs((()=>{J.current={activatorEvent:O,active:A,activeNode:H,collisionRect:fe,collisions:me,droppableRects:U,draggableNodes:N,draggingNode:Q,draggingNodeRect:ee,droppableContainers:j,over:ge,scrollableAncestors:se,scrollAdjustedTranslate:he},I.current={initial:ee,translated:fe}}),[A,H,me,fe,N,Q,ee,U,j,ge,se,he]),_k({...G,delta:E,draggingRect:fe,pointerCoordinates:le,scrollableAncestors:se,scrollableAncestorRects:ie});const ke=l.useMemo((()=>({active:A,activeNode:H,activeNodeRect:Y,activatorEvent:O,collisions:me,containerNodeRect:K,dragOverlay:Z,draggableNodes:N,droppableContainers:j,droppableRects:U,over:ge,measureDroppableContainers:$,scrollableAncestors:se,scrollableAncestorRects:ie,measuringConfiguration:z,measuringScheduled:V,windowRect:oe})),[A,H,Y,O,me,K,Z,N,j,U,ge,$,se,ie,z,V,oe]),Se=l.useMemo((()=>({activatorEvent:O,activators:we,active:A,activeNodeRect:Y,ariaDescribedById:{draggable:L},dispatch:b,draggableNodes:N,over:ge,measureDroppableContainers:$})),[O,we,A,Y,b,L,N,ge,$]);return p.createElement(yw.Provider,{value:v},p.createElement(Kk.Provider,{value:Se},p.createElement(Jk.Provider,{value:ke},p.createElement(eS.Provider,{value:be},c)),p.createElement(Qk,{disabled:!1===(null==i?void 0:i.restoreFocus)})),p.createElement(vw,{...i,hiddenTextDescribedById:L}))})),oS=l.createContext(null),sS="button";function iS(e){let{id:t,data:n,disabled:r=!1,attributes:o}=e;const s=ds("Draggable"),{activators:i,activatorEvent:a,active:c,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=l.useContext(Kk),{role:m=sS,roleDescription:p="draggable",tabIndex:g=0}=null!=o?o:{},y=(null==c?void 0:c.id)===t,b=l.useContext(y?eS:oS),[x,v]=hs(),[w,k]=hs(),S=function(e,t){return l.useMemo((()=>e.reduce(((e,n)=>{let{eventName:r,handler:o}=n;return e[r]=e=>{o(e,t)},e}),{})),[e,t])}(i,t),C=us(n);fs((()=>(h.set(t,{id:t,key:s,node:x,activatorNode:w,data:C}),()=>{const e=h.get(t);e&&e.key===s&&h.delete(t)})),[h,t]);return{active:c,activatorEvent:a,activeNodeRect:d,attributes:l.useMemo((()=>({role:m,tabIndex:g,"aria-disabled":r,"aria-pressed":!(!y||m!==sS)||void 0,"aria-roledescription":p,"aria-describedby":u.draggable})),[r,m,g,y,p,u.draggable]),isDragging:y,listeners:r?void 0:S,node:x,over:f,setNodeRef:v,setActivatorNodeRef:k,transform:b}}const aS={timeout:25};function lS(e,t,n){const r=e.slice();return r.splice(n<0?r.length+n:n,0,r.splice(t,1)[0]),r}function cS(e,t){return e.reduce(((e,n,r)=>{const o=t.get(n);return o&&(e[r]=o),e}),Array(e.length))}function dS(e){return null!==e&&e>=0}const uS={scaleX:1,scaleY:1},hS=e=>{var t;let{rects:n,activeNodeRect:r,activeIndex:o,overIndex:s,index:i}=e;const a=null!=(t=n[o])?t:r;if(!a)return null;const l=function(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];if(!r||!o&&!s)return 0;if(n<t)return o?r.left-(o.left+o.width):s.left-(r.left+r.width);return s?s.left-(r.left+r.width):r.left-(o.left+o.width)}(n,i,o);if(i===o){const e=n[s];return e?{x:o<s?e.left+e.width-(a.left+a.width):e.left-a.left,y:0,...uS}:null}return i>o&&i<=s?{x:-a.width-l,y:0,...uS}:i<o&&i>=s?{x:a.width+l,y:0,...uS}:{x:0,y:0,...uS}};const fS=e=>{let{rects:t,activeIndex:n,overIndex:r,index:o}=e;const s=lS(t,r,n),i=t[o],a=s[o];return a&&i?{x:a.left-i.left,y:a.top-i.top,scaleX:a.width/i.width,scaleY:a.height/i.height}:null},mS={scaleX:1,scaleY:1},pS=e=>{var t;let{activeIndex:n,activeNodeRect:r,index:o,rects:s,overIndex:i}=e;const a=null!=(t=s[n])?t:r;if(!a)return null;if(o===n){const e=s[i];return e?{x:0,y:n<i?e.top+e.height-(a.top+a.height):e.top-a.top,...mS}:null}const l=function(e,t,n){const r=e[t],o=e[t-1],s=e[t+1];if(!r)return 0;if(n<t)return o?r.top-(o.top+o.height):s?s.top-(r.top+r.height):0;return s?s.top-(r.top+r.height):o?r.top-(o.top+o.height):0}(s,o,n);return o>n&&o<=i?{x:0,y:-a.height-l,...mS}:o<n&&o>=i?{x:0,y:a.height+l,...mS}:{x:0,y:0,...mS}};const gS="Sortable",yS=p.createContext({activeIndex:-1,containerId:gS,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:fS,disabled:{draggable:!1,droppable:!1}});function bS(e){let{children:t,id:n,items:r,strategy:o=fS,disabled:s=!1}=e;const{active:i,dragOverlay:a,droppableRects:c,over:d,measureDroppableContainers:u}=l.useContext(Jk),h=ds(gS,n),f=Boolean(null!==a.rect),m=l.useMemo((()=>r.map((e=>"object"==typeof e&&"id"in e?e.id:e))),[r]),g=null!=i,y=i?m.indexOf(i.id):-1,b=d?m.indexOf(d.id):-1,x=l.useRef(m),v=!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}(m,x.current),w=-1!==b&&-1===y||v,k=function(e){return"boolean"==typeof e?{draggable:e,droppable:e}:e}(s);fs((()=>{v&&g&&u(m)}),[v,m,g,u]),l.useEffect((()=>{x.current=m}),[m]);const S=l.useMemo((()=>({activeIndex:y,containerId:h,disabled:k,disableTransforms:w,items:m,overIndex:b,useDragOverlay:f,sortedRects:cS(m,c),strategy:o})),[y,h,k.draggable,k.droppable,w,m,b,c,f,o]);return p.createElement(yS.Provider,{value:S},t)}const xS=e=>{let{id:t,items:n,activeIndex:r,overIndex:o}=e;return lS(n,r,o).indexOf(t)},vS=e=>{let{containerId:t,isSorting:n,wasDragging:r,index:o,items:s,newIndex:i,previousItems:a,previousContainerId:l,transition:c}=e;return!(!c||!r)&&((a===s||o!==i)&&(!!n||i!==o&&t===l))},wS={duration:200,easing:"ease"},kS="transform",SS=Ds.Transition.toString({property:kS,duration:0,easing:"linear"}),CS={roleDescription:"sortable"};function NS(e){let{animateLayoutChanges:t=vS,attributes:n,disabled:r,data:o,getNewIndex:s=xS,id:i,strategy:a,resizeObserverConfig:c,transition:d=wS}=e;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:p,sortedRects:g,overIndex:y,useDragOverlay:b,strategy:x}=l.useContext(yS),v=function(e,t){var n,r;if("boolean"==typeof e)return{draggable:e,droppable:!1};return{draggable:null!=(n=null==e?void 0:e.draggable)?n:t.draggable,droppable:null!=(r=null==e?void 0:e.droppable)?r:t.droppable}}(r,m),w=u.indexOf(i),k=l.useMemo((()=>({sortable:{containerId:h,index:w,items:u},...o})),[h,o,w,u]),S=l.useMemo((()=>u.slice(u.indexOf(i))),[u,i]),{rect:C,node:N,isOver:E,setNodeRef:j}=function(e){let{data:t,disabled:n=!1,id:r,resizeObserverConfig:o}=e;const s=ds("Droppable"),{active:i,dispatch:a,over:c,measureDroppableContainers:d}=l.useContext(Kk),u=l.useRef({disabled:n}),h=l.useRef(!1),f=l.useRef(null),m=l.useRef(null),{disabled:p,updateMeasurementsFor:g,timeout:y}={...aS,...o},b=us(null!=g?g:r),x=Rk({callback:l.useCallback((()=>{h.current?(null!=m.current&&clearTimeout(m.current),m.current=setTimeout((()=>{d(Array.isArray(b.current)?b.current:[b.current]),m.current=null}),y)):h.current=!0}),[y]),disabled:p||!i}),v=l.useCallback(((e,t)=>{x&&(t&&(x.unobserve(t),h.current=!1),e&&x.observe(e))}),[x]),[w,k]=hs(v),S=us(t);return l.useEffect((()=>{x&&w.current&&(x.disconnect(),h.current=!1,x.observe(w.current))}),[w,x]),l.useEffect((()=>(a({type:ww.RegisterDroppable,element:{id:r,key:s,disabled:n,node:w,rect:f,data:S}}),()=>a({type:ww.UnregisterDroppable,key:s,id:r}))),[r]),l.useEffect((()=>{n!==u.current.disabled&&(a({type:ww.SetDroppableDisabled,id:r,key:s,disabled:n}),u.current.disabled=n)}),[r,s,n,a]),{active:i,rect:f,isOver:(null==c?void 0:c.id)===r,node:w,over:c,setNodeRef:k}}({id:i,data:k,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:S,...c}}),{active:_,activatorEvent:I,activeNodeRect:A,attributes:T,setNodeRef:M,listeners:D,isDragging:O,over:R,setActivatorNodeRef:P,transform:L}=iS({id:i,data:k,attributes:{...CS,...n},disabled:v.draggable}),F=Ms(j,M),z=Boolean(_),B=z&&!p&&dS(f)&&dS(y),U=!b&&O,$=U&&B?L:null,V=B?null!=$?$:(null!=a?a:x)({rects:g,activeNodeRect:A,activeIndex:f,overIndex:y,index:w}):null,H=dS(f)&&dS(y)?s({id:i,items:u,activeIndex:f,overIndex:y}):w,W=null==_?void 0:_.id,G=l.useRef({activeId:W,items:u,newIndex:H,containerId:h}),q=u!==G.current.items,Y=t({active:_,containerId:h,isDragging:O,isSorting:z,id:i,index:w,items:u,newIndex:G.current.newIndex,previousItems:G.current.items,previousContainerId:G.current.containerId,transition:d,wasDragging:null!=G.current.activeId}),K=function(e){let{disabled:t,index:n,node:r,rect:o}=e;const[s,i]=l.useState(null),a=l.useRef(n);return fs((()=>{if(!t&&n!==a.current&&r.current){const e=o.current;if(e){const t=Bw(r.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)&&i(n)}}n!==a.current&&(a.current=n)}),[t,n,r,o]),l.useEffect((()=>{s&&i(null)}),[s]),s}({disabled:!Y,index:w,node:N,rect:C});return l.useEffect((()=>{z&&G.current.newIndex!==H&&(G.current.newIndex=H),h!==G.current.containerId&&(G.current.containerId=h),u!==G.current.items&&(G.current.items=u)}),[z,H,h,u]),l.useEffect((()=>{if(W===G.current.activeId)return;if(null!=W&&null==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:C,index:w,newIndex:H,items:u,isOver:E,isSorting:z,isDragging:O,listeners:D,node:N,overIndex:y,over:R,setNodeRef:F,setActivatorNodeRef:P,setDroppableNodeRef:j,setDraggableNodeRef:M,transform:null!=K?K:V,transition:function(){if(K||q&&G.current.newIndex===w)return SS;if(U&&!ys(I)||!d)return;if(z||Y)return Ds.Transition.toString({...d,property:kS});return}()}}function ES(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 jS=[lk.Down,lk.Right,lk.Up,lk.Left],_S=(e,t)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:s,over:i,scrollableAncestors:a}}=t;if(jS.includes(e.code)){if(e.preventDefault(),!n||!r)return;const t=[];s.getEnabled().forEach((n=>{if(!n||null!=n&&n.disabled)return;const s=o.get(n.id);if(s)switch(e.code){case lk.Down:r.top<s.top&&t.push(n);break;case lk.Up:r.top>s.top&&t.push(n);break;case lk.Left:r.left>s.left&&t.push(n);break;case lk.Right:r.left<s.left&&t.push(n)}}));const l=(e=>{let{collisionRect:t,droppableRects:n,droppableContainers:r}=e;const o=Iw(t),s=[];for(const i of r){const{id:e}=i,t=n.get(e);if(t){const n=Iw(t),r=o.reduce(((e,t,r)=>e+Ew(n[r],t)),0),a=Number((r/4).toFixed(4));s.push({id:e,data:{droppableContainer:i,value:a}})}}return s.sort(jw)})({collisionRect:r,droppableRects:o,droppableContainers:t});let c=Aw(l,"id");if(c===(null==i?void 0:i.id)&&l.length>1&&(c=l[1].id),null!=c){const e=s.get(n.id),t=s.get(c),i=t?o.get(t.id):null,l=null==t?void 0:t.node.current;if(l&&i&&e&&t){const n=$w(l).some(((e,t)=>a[t]!==e)),o=IS(e,t),s=function(e,t){if(!ES(e)||!ES(t))return!1;if(!IS(e,t))return!1;return e.data.current.sortable.index<t.data.current.sortable.index}(e,t),c=n||!o?{x:0,y:0}:{x:s?r.width-i.width:0,y:s?r.height-i.height:0},d={x:i.left,y:i.top};return c.x&&c.y?d:bs(d,c)}}}};function IS(e,t){return!(!ES(e)||!ES(t))&&e.data.current.sortable.containerId===t.data.current.sortable.containerId}function AS(...e){return t=>{e.forEach((e=>{"function"==typeof e?e(t):null!=e&&(e.current=t)}))}}const TS=p.createContext(null),MS=l.memo((()=>l.useContext(TS)));MS.displayName="DragHandle";const DS=p.forwardRef(((e,t)=>{const n=N.c(21);let r,o,s,i,a;n[0]!==e?(({cellId:o,canMoveX:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=o.toString(),n[4]=o,n[5]=i):i=n[5],n[6]!==i?(a={id:i},n[6]=i,n[7]=a):a=n[7];const{attributes:l,listeners:c,setNodeRef:d,transform:u,transition:h,isDragging:f}=NS(a);let m;n[8]!==u?(m=function(e){return!e||0===e.x&&0===e.y&&1===e.scaleX&&1===e.scaleY}(u)?null:u,n[8]=u,n[9]=m):m=n[9];const p=m,g=null==p?void 0:h;let y;return n[10]!==l||n[11]!==r||n[12]!==o||n[13]!==f||n[14]!==c||n[15]!==s||n[16]!==t||n[17]!==d||n[18]!==p||n[19]!==g?(y=_.jsx(OS,{ref:t,cellId:o,canMoveX:r,...s,attributes:l,listeners:c,setNodeRef:d,transform:p,transition:g,isDragging:f}),n[10]=l,n[11]=r,n[12]=o,n[13]=f,n[14]=c,n[15]=s,n[16]=t,n[17]=d,n[18]=p,n[19]=g,n[20]=y):y=n[20],y}));DS.displayName="SortableCell";const OS=p.forwardRef(((e,t)=>{const n=N.c(37);let r,o,s,i,a,l,c,d,u,h;if(n[0]!==e){const{cellId:t,canMoveX:h,children:f,attributes:m,listeners:p,setNodeRef:g,transform:y,transition:b,isDragging:x,...v}=e;o=h,s=f,r=m,a=p,c=g,d=y,u=b,i=x,l=v,n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i,n[5]=a,n[6]=l,n[7]=c,n[8]=d,n[9]=u}else r=n[1],o=n[2],s=n[3],i=n[4],a=n[5],l=n[6],c=n[7],d=n[8],u=n[9];n[10]!==o||n[11]!==d?(h=d?Ds.Transform.toString({x:o?d.x:0,y:d.y,scaleX:1,scaleY:1}):void 0,n[10]=o,n[11]=d,n[12]=h):h=n[12];const f=i?2:void 0;let m;n[13]!==h||n[14]!==f||n[15]!==u?(m={transform:h,transition:u,zIndex:f,position:"relative"},n[13]=h,n[14]=f,n[15]=u,n[16]=m):m=n[16];const p=m;let g,y;n[17]===Symbol.for("react.memo_cache_sentinel")?(g=_.jsx(Hd,{strokeWidth:1,size:20}),n[17]=g):g=n[17],n[18]!==r||n[19]!==a?(y=_.jsx("div",{...r,...a,onMouseDown:dt.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:g}),n[18]=r,n[19]=a,n[20]=y):y=n[20];const b=y,x=Boolean(d);let v;n[21]!==t||n[22]!==c?(v=e=>{AS(t,c)(e)},n[21]=t,n[22]=c,n[23]=v):v=n[23];const w=x&&"is-moving";let k,S,C;return n[24]!==l.className||n[25]!==w?(k=$t(l.className,w,"outline-offset-4 outline-primary/40 rounded-lg"),n[24]=l.className,n[25]=w,n[26]=k):k=n[26],n[27]!==s||n[28]!==b?(S=_.jsx(TS.Provider,{value:b,children:s}),n[27]=s,n[28]=b,n[29]=S):S=n[29],n[30]!==i||n[31]!==l||n[32]!==p||n[33]!==v||n[34]!==k||n[35]!==S?(C=_.jsx("div",{tabIndex:-1,ref:v,...l,"data-is-dragging":i,className:k,style:p,children:S}),n[30]=i,n[31]=l,n[32]=p,n[33]=v,n[34]=k,n[35]=S,n[36]=C):C=n[36],C}));OS.displayName="SortableCellInternal";const RS=p.memo(p.forwardRef(((e,t)=>{const n=N.c(34);let r,o,s;n[0]!==e?(({children:r,showTooltip:s,...o}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]);const i=void 0===s||s,[a,c]=l.useState(!1);let d;n[4]!==o?(d={cell:o},n[4]=o,n[5]=d):d=n[5];const u=ch(d),h=Os();let f,m,p,g,y,b;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>c(LS)}),n[6]=f):f=n[6],l.useImperativeHandle(t,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(m=_.jsx(rt,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=m):m=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(p=_.jsx(ot,{children:"No results"}),n[8]=p):p=n[8],n[9]!==u){let e;n[11]!==u.length?(e=(e,t)=>_.jsxs(l.Fragment,{children:[_.jsx(Ye,{children:e.map((e=>{let t=_.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&_.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),_.jsx("div",{className:"flex-1",children:e.label}),_.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&Rs(e.hotkey),e.rightElement]})]});return e.tooltip&&(t=_.jsx(ht,{content:e.tooltip,delayDuration:100,children:t})),_.jsx(et,{className:$t(e.disabled&&"!opacity-50"),onSelect:()=>{e.disableClick||e.disabled||(e.handle(),c(!1))},variant:e.variant,children:t},e.label)}))},t),t<u.length-1&&_.jsx(Je,{})]},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?(y=_.jsxs(er,{children:[m,_.jsxs(Ps,{children:[p,g]})]}),n[13]=g,n[14]=y):y=n[14],n[15]!==h||n[16]!==y?(b=_.jsx(Qn,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...h,children:y}),n[15]=h,n[16]=y,n[17]=b):b=n[17];const x=b;if(!i){let e,t;return n[18]!==r?(e=_.jsx(Ls,{asChild:!0,children:r}),n[18]=r,n[19]=e):e=n[19],n[20]!==x||n[21]!==a||n[22]!==e?(t=_.jsxs(nr,{open:a,onOpenChange:c,children:[e,x]}),n[20]=x,n[21]=a,n[22]=e,n[23]=t):t=n[23],t}let v;n[24]===Symbol.for("react.memo_cache_sentinel")?(v=_.jsx(Fs,{tabIndex:-1,children:fn("cell.cellActions")}),n[24]=v):v=n[24];const w=!a&&v;let k,S,C;return n[25]!==r?(k=_.jsx(zs,{children:_.jsx(Ls,{className:"flex",children:r})}),n[25]=r,n[26]=k):k=n[26],n[27]!==w||n[28]!==k?(S=_.jsxs(Bs,{delayDuration:200,disableHoverableContent:!0,children:[w,k]}),n[27]=w,n[28]=k,n[29]=S):S=n[29],n[30]!==x||n[31]!==a||n[32]!==S?(C=_.jsxs(nr,{open:a,onOpenChange:c,children:[S,x]}),n[30]=x,n[31]=a,n[32]=S,n[33]=C):C=n[33],C}))),PS=p.memo((e=>{const t=N.c(5),{children:n,cellId:r}=e;let o,s;t[0]!==r?(s=function(e){return Z((t=>yh(e,t(ae))))}(r),t[0]=r,t[1]=s):s=t[1],o=s;const i=de(o);if(!i)return null;let a;return t[2]!==n||t[3]!==i?(a=_.jsx(RS,{showTooltip:!1,...i,children:n}),t[2]=n,t[3]=i,t[4]=a):a=t[4],a}));function LS(e){return!e}PS.displayName="ConnectionCellActionsDropdown";const FS=e=>{const t=N.c(32);let n,r,o;t[0]!==e?(({children:n,...r}=e),t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]),t[3]!==r?(o={cell:r},t[3]=r,t[4]=o):o=t[4];const s=ch(o),[i,a]=p.useState(),c=Boolean(i);let d,u,h,f,m,g,y,b,x,v;if(t[5]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(ut,{size:13,strokeWidth:1.5}),t[5]=d):d=t[5],t[6]!==r?(u=async()=>{var e;if(null==(e=window.getSelection())?void 0:e.toString())return void document.execCommand("copy");const t=document.getElementById(B.create(r.cellId));t?await Me(t.textContent??""):X.warn("cell-context-menu: output not found")},t[6]=r,t[7]=u):u=t[7],t[8]!==s||t[9]!==n||t[10]!==i||t[11]!==r||t[12]!==c||t[13]!==u){const e=[[{label:"Copy",hidden:c,icon:d,handle:u},{label:"Cut",hidden:Boolean(i),icon:_.jsx(pu,{size:13,strokeWidth:1.5}),handle:zS},{label:"Paste",hidden:Boolean(i),icon:_.jsx(Ad,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:e}=r,t=e();if(t)try{const e=await navigator.clipboard.readText();if(e){const{from:n,to:r}=t.state.selection.main,o=t.state.update({changes:{from:n,to:r,insert:e}});t.dispatch(o)}}catch(n){const e=n;X.error("Failed to paste from clipboard",e),Us({command:"paste"})}}},{label:"Copy image",hidden:!i,icon:_.jsx(Id,{size:13,strokeWidth:1.5}),handle:async()=>{if(i){const e=await fetch(i.src),t=await e.blob(),n=new ClipboardItem({[t.type]:t});await navigator.clipboard.write([n]).then(BS).catch(US)}}},{icon:_.jsx(Ic,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!i,handle:()=>{if(i){const e=document.createElement("a");e.download="image.png",e.href=i.src,e.click()}}},{label:"Go to Definition",icon:_.jsx(Vs,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:e}=r,t=e();t&&$s(t)}}],...s];let o;f=qv,t[20]===Symbol.for("react.memo_cache_sentinel")?(o=e=>{e.target instanceof HTMLImageElement?a(e.target):a(void 0)},t[20]=o):o=t[20],t[21]!==n?(b=_.jsx(Yv,{onContextMenu:o,asChild:!0,children:n}),t[21]=n,t[22]=b):b=t[22],h=Xv,m="w-[300px]",g=!0,y=e.map(((t,n)=>_.jsxs(l.Fragment,{children:[t.map($S),n<e.length-1&&_.jsx(Qv,{})]},n))),t[8]=s,t[9]=n,t[10]=i,t[11]=r,t[12]=c,t[13]=u,t[14]=h,t[15]=f,t[16]=m,t[17]=g,t[18]=y,t[19]=b}else h=t[14],f=t[15],m=t[16],g=t[17],y=t[18],b=t[19];return t[23]!==h||t[24]!==m||t[25]!==g||t[26]!==y?(x=_.jsx(h,{className:m,scrollable:g,children:y}),t[23]=h,t[24]=m,t[25]=g,t[26]=y,t[27]=x):x=t[27],t[28]!==f||t[29]!==b||t[30]!==x?(v=_.jsxs(f,{children:[b,x]}),t[28]=f,t[29]=b,t[30]=x,t[31]=v):v=t[31],v};function zS(){document.execCommand("cut")}function BS(){se({title:"Copied image to clipboard"})}function US(e){se({title:"Failed to copy image to clipboard. Try downloading instead.",description:e.message}),X.error("Failed to copy image to clipboard",e)}function $S(e){if(e.hidden)return null;let t=_.jsxs("div",{className:"flex items-center flex-1",children:[e.icon&&_.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:e.icon}),_.jsx("div",{className:"flex-1",children:e.label}),_.jsxs("div",{className:"flex-shrink-0 text-sm",children:[e.hotkey&&Rs(e.hotkey),e.rightElement]})]});return e.tooltip&&(t=_.jsx(ht,{delayDuration:100,content:e.tooltip,children:t})),_.jsx(Zv,{className:e.disabled?"!opacity-50":"",onSelect:t=>{e.disableClick||e.disabled||e.handle(t)},variant:e.variant,children:t},e.label)}const VS=e=>{const t=N.c(24),{editorView:n,code:r,currentLanguageAdapter:o,onAfterToggle:s}=e;let i,a;t[0]!==r?(a=(new sn).isSupported(r)||""===r.trim(),t[0]=r,t[1]=a):a=t[1],i=a;const l=i;let c,d;t[2]!==r?(d=(new is).isSupported(r)||""===r.trim(),t[2]=r,t[3]=d):d=t[3],c=d;const u=c&&"python"===o;let h,f;t[4]===Symbol.for("react.memo_cache_sentinel")?(h=_.jsx(Ne,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),t[4]=h):h=t[4],t[5]!==o||t[6]!==n||t[7]!==s||t[8]!==u?(f=_.jsx(HS,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:u,icon:h,toType:"sql",displayName:"SQL",onAfterToggle:s}),t[5]=o,t[6]=n,t[7]=s,t[8]=u,t[9]=f):f=t[9];const m=l&&"python"===o;let p,g,y,b,x;return t[10]===Symbol.for("react.memo_cache_sentinel")?(p=_.jsx(Hl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[10]=p):p=t[10],t[11]!==o||t[12]!==n||t[13]!==s||t[14]!==m?(g=_.jsx(HS,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:m,icon:p,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),t[11]=o,t[12]=n,t[13]=s,t[14]=m,t[15]=g):g=t[15],t[16]===Symbol.for("react.memo_cache_sentinel")?(y=_.jsx(Wl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),t[16]=y):y=t[16],t[17]!==o||t[18]!==n?(b=_.jsx(HS,{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:!0,icon:y,toType:"python",displayName:"Python",onAfterToggle:Rt.NOOP}),t[17]=o,t[18]=n,t[19]=b):b=t[19],t[20]!==g||t[21]!==b||t[22]!==f?(x=_.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[f,g,b]}),t[20]=g,t[21]=b,t[22]=f,t[23]=x):x=t[23],x},HS=e=>{const t=N.c(10),{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:o,icon:s,toType:i,displayName:a,onAfterToggle:l}=e;let c;t[0]!==n||t[1]!==l||t[2]!==i?(c=()=>{n&&(Ce(n,i),l())},t[0]=n,t[1]=l,t[2]=i,t[3]=c):c=t[3];const d=c;if(!o)return null;if(r===i)return null;const u=`View as ${a}`;let h,f;return t[4]!==d||t[5]!==s?(h=_.jsx(ee,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:d,children:s}),t[4]=d,t[5]=s,t[6]=h):h=t[6],t[7]!==u||t[8]!==h?(f=_.jsx(ht,{content:u,children:h}),t[7]=u,t[8]=h,t[9]=f):f=t[9],f};var WS={modified:{doc:""},original:{doc:""}},GS=l.createContext(WS);function qS(e,t){return Hs({},e,t,{modified:Hs({},e.modified,t.modified),original:Hs({},e.original,t.original)})}var YS=()=>l.useContext(GS),KS=e=>{var{children:t,theme:n}=e,[r,o]=l.useReducer(qS,Hs({},WS,{theme:n}));return l.useEffect((()=>o({theme:n})),[n]),_.jsx(GS.Provider,{value:Hs({},r,{dispatch:o}),children:t})},JS=["extensions","value","selection","onChange"],XS=e=>{var{extensions:t=[],value:n,selection:r,onChange:o}=e,s=Ws(e,JS),{theme:i,dispatch:a}=YS(),c=Gs(Hs({},s,{theme:i}));return l.useEffect((()=>a({original:{doc:n,selection:r,extensions:[...c,...t]},originalExtension:{onChange:o,option:s,extension:[t]}})),[e]),null};XS.displayName="CodeMirrorMerge.Original";var ZS=["extensions","value","selection","onChange"],QS=e=>{var{extensions:t=[],value:n,selection:r,onChange:o}=e,s=Ws(e,ZS),{theme:i,dispatch:a}=YS(),c=Gs(Hs({},s,{theme:i}));return l.useEffect((()=>{a({modified:{doc:n,selection:r,extensions:[...c,...t]},modifiedExtension:{onChange:o,option:s,extension:[t]}})}),[e]),null};QS.displayName="CodeMirrorMerge.Modified";class eC{constructor(e,t,n,r){this.fromA=e,this.toA=t,this.fromB=n,this.toB=r}offset(e,t){return new eC(this.fromA+e,this.toA+e,this.fromB+t,this.toB+t)}}function tC(e,t,n,r,o,s){if(e==r)return[];let i=lC(e,t,n,r,o,s),a=cC(e,t+i,n,r,o+i,s),l=(n-=a)-(t+=i),c=(s-=a)-(o+=i);if(!l||!c)return[new eC(t,n,o,s)];if(l>c){let i=e.slice(t,n).indexOf(r.slice(o,s));if(i>-1)return[new eC(t,t+i,o,o),new eC(t+i+c,n,s,s)]}else if(c>l){let i=r.slice(o,s).indexOf(e.slice(t,n));if(i>-1)return[new eC(t,t,o,o+i),new eC(n,n,o+i+l,s)]}if(1==l||1==c)return[new eC(t,n,o,s)];let d=uC(e,t,n,r,o,s);if(d){let[i,a,l]=d;return tC(e,t,i,r,o,a).concat(tC(e,i+l,n,r,a+l,s))}return function(e,t,n,r,o,s){let i=n-t,a=s-o;if(nC<1e9&&Math.min(i,a)>16*nC)return Math.min(i,a)>64*nC?[new eC(t,n,o,s)]:hC(e,t,n,r,o,s);let l=Math.ceil((i+a)/2);oC.reset(l),sC.reset(l);let c=(n,s)=>e.charCodeAt(t+n)==r.charCodeAt(o+s),d=(t,o)=>e.charCodeAt(n-t-1)==r.charCodeAt(s-o-1),u=(i-a)%2!=0?sC:null,h=u?null:oC;for(let f=0;f<l;f++){if(f>nC)return hC(e,t,n,r,o,s);let m=oC.advance(f,i,a,l,u,!1,c)||sC.advance(f,i,a,l,h,!0,d);if(m)return iC(e,t,n,t+m[0],r,o,s,o+m[1])}return[new eC(t,n,o,s)]}(e,t,n,r,o,s)}let nC=1e9;class rC{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,r,o,s,i){for(let a=-e+this.start;a<=e-this.end;a+=2){let l=r+a,c=a==-e||a!=e&&this.vec[l-1]<this.vec[l+1]?this.vec[l+1]:this.vec[l-1]+1,d=c-a;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(o){let e=r+(t-n)-a;if(e>=0&&e<this.len&&-1!=o.vec[e])if(s){let n=o.vec[e];if(n>=t-c)return[n,r+n-e]}else{if(c>=t-o.vec[e])return[c,d]}}}return null}}const oC=new rC,sC=new rC;function iC(e,t,n,r,o,s,i,a){let l=!1;return SC(e,r)||++r!=n||(l=!0),SC(o,a)||++a!=i||(l=!0),l?[new eC(t,n,s,i)]:tC(e,t,r,o,s,a).concat(tC(e,r,n,o,a,i))}function aC(e,t){let n=1,r=Math.min(e,t);for(;n<r;)n<<=1;return n}function lC(e,t,n,r,o,s){if(t==n||t==s||e.charCodeAt(t)!=r.charCodeAt(o))return 0;let i=aC(n-t,s-o);for(let a=t,l=o;;){let o=a+i,c=l+i;if(o>n||c>s||e.slice(a,o)!=r.slice(l,c)){if(1==i)return a-t-(SC(e,a)?0:1);i>>=1}else{if(o==n||c==s)return o-t;a=o,l=c}}}function cC(e,t,n,r,o,s){if(t==n||o==s||e.charCodeAt(n-1)!=r.charCodeAt(s-1))return 0;let i=aC(n-t,s-o);for(let a=n,l=s;;){let s=a-i,c=l-i;if(s<t||c<o||e.slice(s,a)!=r.slice(c,l)){if(1==i)return n-a-(SC(e,a)?0:1);i>>=1}else{if(s==t||c==o)return n-s;a=s,l=c}}}function dC(e,t,n,r,o,s,i,a){let l=r.slice(o,s),c=null;for(;;){if(c||i<a)return c;for(let a=t+i;;){SC(e,a)||a++;let d=a+i;if(SC(e,d)||(d+=d==a+1?1:-1),d>=n)break;let u=e.slice(a,d),h=-1;for(;-1!=(h=l.indexOf(u,h+1));){let i=lC(e,d,n,r,o+h+u.length,s),l=cC(e,t,a,r,o,o+h),f=u.length+i+l;(!c||c[2]<f)&&(c=[a-l,o+h-l,f])}a=d}if(a<0)return c;i>>=1}}function uC(e,t,n,r,o,s){let i=n-t,a=s-o;if(i<a){let i=uC(r,o,s,e,t,n);return i&&[i[1],i[0],i[2]]}return i<4||2*a<i?null:dC(e,t,n,r,o,s,Math.floor(i/4),-1)}function hC(e,t,n,r,o,s){let i,a=n-t,l=s-o;if(a<l){let l=dC(r,o,s,e,t,n,Math.floor(a/6),50);i=l&&[l[1],l[0],l[2]]}else i=dC(e,t,n,r,o,s,Math.floor(l/6),50);if(!i)return[new eC(t,n,o,s)];let[c,d,u]=i;return tC(e,t,c,r,o,d).concat(tC(e,c+u,n,r,d+u,s))}function fC(e,t){for(let n=1;n<e.length;n++){let r=e[n-1],o=e[n];r.toA>o.fromA-t&&r.toB>o.fromB-t&&(e[n-1]=new eC(r.fromA,o.toA,r.fromB,o.toB),e.splice(n--,1))}}let mC;try{mC=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch(jK){}function pC(e){return e>48&&e<58||e>64&&e<91||e>96&&e<123}function gC(e,t){if(t==e.length)return 0;let n=e.charCodeAt(t);return n<192?pC(n)?1:0:mC?wC(n)&&t!=e.length-1?mC.test(e.slice(t,t+2))?2:0:mC.test(String.fromCharCode(n))?1:0:0}function yC(e,t){if(!t)return 0;let n=e.charCodeAt(t-1);return n<192?pC(n)?1:0:mC?kC(n)&&1!=t?mC.test(e.slice(t-2,t))?2:0:mC.test(String.fromCharCode(n))?1:0:0}function bC(e,t,n){if(t==e.length||!yC(e,t))return t;for(let r=t,o=t+n;;){let n=gC(e,r);if(!n)return r;if(r+=n,r>o)return t}}function xC(e,t,n){if(!t||!gC(e,t))return t;for(let r=t,o=t-n;;){let n=yC(e,r);if(!n)return r;if(r-=n,r<o)return t}}function vC(e,t,n){for(let r=t,o=t-n;;){let n=r?e.charCodeAt(r-1):10;if(10==n)return r;if(r--,r<o||32!=n&&9!=n)return t}}const wC=e=>e>=55296&&e<=56319,kC=e=>e>=56320&&e<=57343;function SC(e,t){return!t||t==e.length||!wC(e.charCodeAt(t-1))||!kC(e.charCodeAt(t))}function CC(e,t,n){var r;return nC=(null!==(r=null==n?void 0:n.scanLimit)&&void 0!==r?r:1e9)>>1,function(e,t,n){for(;;){fC(n,1);let r=!1;for(let o=0;o<n.length;o++){let s,i,a=n[o];(s=lC(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new eC(a.fromA+s,a.toA,a.fromB+s,a.toB)),(i=cC(e,a.fromA,a.toA,t,a.fromB,a.toB))&&(a=n[o]=new eC(a.fromA,a.toA-i,a.fromB,a.toB-i));let l=a.toA-a.fromA,c=a.toB-a.fromB;if(l&&c)continue;let d=a.fromA-(o?n[o-1].toA:0),u=(o<n.length-1?n[o+1].fromA:e.length)-a.toA;if(!d||!u)continue;let h=l?e.slice(a.fromA,a.toA):t.slice(a.fromB,a.toB);d<=h.length&&e.slice(a.fromA-d,a.fromA)==h.slice(h.length-d)?(n[o]=new eC(a.fromA-d,a.toA-d,a.fromB-d,a.toB-d),r=!0):u<=h.length&&e.slice(a.toA,a.toA+u)==h.slice(0,u)&&(n[o]=new eC(a.fromA+u,a.toA+u,a.fromB+u,a.toB+u),r=!0)}if(!r)break}return n}(e,t,tC(e,0,e.length,t,0,t.length))}function NC(e,t,n){return function(e,t,n){for(let r=0,o=0;o<e.length;o++){let s=e[o],i=s.toA-s.fromA,a=s.toB-s.fromB;if(i&&a||i>3||a>3){let l=o==e.length-1?t.length:e[o+1].fromA,c=s.fromA-r,d=l-s.toA,u=xC(t,s.fromA,Math.min(c,5)),h=bC(t,s.toA,Math.min(d,5)),f=s.fromA-u,m=h-s.toA;if(!i||!a){let d,p,g=Math.max(i,a),[y,b,x]=i?[t,s.fromA,s.toA]:[n,s.fromB,s.toB];f&&m?(g>f&&t.slice(u,s.fromA)==y.slice(x-f,x)?(s=e[o]=new eC(u,u+i,s.fromB-f,s.toB-f),u=s.fromA,h=bC(t,s.toA,Math.min(l-s.toA,5))):g>m&&t.slice(s.toA,h)==y.slice(b,b+m)&&(s=e[o]=new eC(h-i,h,s.fromB+m,s.toB+m),h=s.toA,u=xC(t,s.fromA,Math.min(s.fromA-r,5))),f=s.fromA-u,m=h-s.toA):f||m||!(p=s.fromA-(d=vC(t,s.fromA,c)))||t.slice(d,s.fromA)!=y.slice(x-p,x)||(s=e[o]=new eC(d,d+i,s.fromB-p,s.toB-p))}(f||m)&&(s=e[o]=new eC(s.fromA-f,s.toA+m,s.fromB-f,s.toB+m)),r=s.toA}}return fC(e,3),e}(CC(e,t,n),e,t)}const EC=Cr.define({combine:e=>e[0]}),jC=Hn.define(),_C=Un.define({create:e=>null,update(e,t){for(let n of t.effects)n.is(jC)&&(e=n.value);return e}});class IC{constructor(e,t,n,r,o){this.changes=e,this.fromA=t,this.toA=n,this.fromB=r,this.toB=o}offset(e,t){return e||t?new IC(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 MC(NC(e.toString(),t.toString(),n),e,t,0,0)}static updateA(e,t,n,r,o){return PC(RC(e,r,!0,n.length),e,t,n,o)}static updateB(e,t,n,r,o){return PC(RC(e,r,!1,t.length),e,t,n,o)}}function AC(e,t,n,r){let o=n.lineAt(e),s=r.lineAt(t);return o.to==e&&s.to==t&&e<n.length&&t<r.length?[e+1,t+1]:[o.from,s.from]}function TC(e,t,n,r){let o=n.lineAt(e),s=r.lineAt(t);return o.from==e&&s.from==t?[e,t]:[o.to+1,s.to+1]}function MC(e,t,n,r,o){let s=[];for(let i=0;i<e.length;i++){let a=e[i],[l,c]=AC(a.fromA+r,a.fromB+o,t,n),[d,u]=TC(a.toA+r,a.toB+o,t,n),h=[a.offset(-l+r,-c+o)];for(;i<e.length-1;){let s=e[i+1],[a,f]=AC(s.fromA+r,s.fromB+o,t,n);if(a>d+1&&f>u+1)break;h.push(s.offset(-l+r,-c+o)),[d,u]=TC(s.toA+r,s.toB+o,t,n),i++}s.push(new IC(h,l,Math.max(l,d),c,Math.max(c,u)))}return s}const DC=1e3;function OC(e,t,n,r){let o=0,s=e.length;for(;;){if(o==s){let r=0,s=0;o&&({toA:r,toB:s}=e[o-1]);let i=t-(n?r:s);return[r+i,s+i]}let i=o+s>>1,a=e[i],[l,c]=n?[a.fromA,a.toA]:[a.fromB,a.toB];if(l>t)s=i;else{if(!(c<=t))return r?[a.fromA,a.fromB]:[a.toA,a.toB];o=i+1}}}function RC(e,t,n,r){let o=[];return t.iterChangedRanges(((s,i,a,l)=>{let c=0,d=n?t.length:r,u=0,h=n?r:t.length;s>DC&&([c,u]=OC(e,s-DC,n,!0)),i<t.length-DC&&([d,h]=OC(e,i+DC,n,!1));let f,m=l-a-(i-s),[p,g]=n?[m,0]:[0,m];o.length&&(f=o[o.length-1]).toA>=c?o[o.length-1]={fromA:f.fromA,fromB:f.fromB,toA:d,toB:h,diffA:f.diffA+p,diffB:f.diffB+g}:o.push({fromA:c,toA:d,fromB:u,toB:h,diffA:p,diffB:g})})),o}function PC(e,t,n,r,o){if(!e.length)return t;let s=0,i=0,a=0,l=[];for(let c of e){let e=c.fromA+i,d=c.toA+i+c.diffA,u=c.fromB+a,h=c.toB+a+c.diffB;for(;s<t.length;){let n=t[s];if(n.toA+i<=e&&n.toB+a<=u)l.push(n.offset(i,a));else if(n.fromA+i>d)break;s++}for(let t of MC(NC(n.sliceString(e,d),r.sliceString(u,h),o),n,r,e,u))l.push(t);for(i+=c.diffA,a+=c.diffB;s<t.length;){let e=t[s];if(e.fromA>d+i&&e.fromB>h+a)break;s++}}for(;s<t.length;)l.push(t[s++].offset(i,a));return l}const LC=Bn.fromClass(class{constructor(e){({deco:this.deco,gutter:this.gutter}=WC(e))}update(e){var t,n;(e.docChanged||e.viewportChanged||(t=e.startState,n=e.state,t.field(_C,!1)!=n.field(_C,!1))||function(e,t){return e.facet(EC)!=t.facet(EC)}(e.startState,e.state))&&({deco:this.deco,gutter:this.gutter}=WC(e.view))}},{decorations:e=>e.deco}),FC=jr.low(Ys({class:"cm-changeGutter",markers:e=>{var t;return(null===(t=e.plugin(LC))||void 0===t?void 0:t.gutter)||Ks.empty}}));const zC=$n.line({class:"cm-changedLine"}),BC=$n.mark({class:"cm-changedText"}),UC=$n.mark({tagName:"ins",class:"cm-insertedLine"}),$C=$n.mark({tagName:"del",class:"cm-deletedLine"}),VC=new class extends Js{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function HC(e,t,n,r,o,s){let i=n?e.fromA:e.fromB,a=n?e.toA:e.toB,l=0;if(i!=a){o.add(i,i,zC),o.add(i,a,n?$C:UC),s&&s.add(i,i,VC);for(let c=t.iterRange(i,a-1),d=i;!c.next().done;){if(c.lineBreak){d++,o.add(d,d,zC),s&&s.add(d,d,VC);continue}let t=d+c.value.length;if(r)for(;l<e.changes.length;){let r=e.changes[l],s=i+(n?r.fromA:r.fromB),a=i+(n?r.toA:r.toB),c=Math.max(d,s),u=Math.min(t,a);if(c<u&&o.add(c,u,BC),!(a<t))break;l++}d=t}}}function WC(e){let t=e.state.field(_C),{side:n,highlightChanges:r,markGutter:o}=e.state.facet(EC),s="a"==n,i=new Vn,a=o?new Vn:null,{from:l,to:c}=e.viewport;for(let d of t){if((s?d.fromA:d.fromB)>=c)break;(s?d.toA:d.toB)>l&&HC(d,e.state.doc,s,r,i,a)}return{deco:i.finish(),gutter:a&&a.finish()}}class GC extends Er{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 qC=Hn.define({map:(e,t)=>e.map(t)}),YC=Un.define({create:()=>$n.none,update:(e,t)=>{for(let n of t.effects)if(n.is(qC))return n.value;return e.map(t.changes)},provide:e=>zn.decorations.from(e)}),KC=.01;const JC=Hn.define({map:(e,t)=>t.mapPos(e)});class XC extends Er{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:JC.of(n)});let{side:r,sibling:o}=e.state.facet(EC);o&&o().dispatch({effects:JC.of(ZC(n,e.state.field(_C),"a"==r))})})),t}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}}function ZC(e,t,n){let r=0,o=0;for(let s=0;;s++){let i=s<t.length?t[s]:null;if(!i||(n?i.fromA:i.fromB)>=e)return o+(e-r);[r,o]=n?[i.toA,i.toB]:[i.toB,i.toA]}}const QC=Un.define({create:e=>$n.none,update(e,t){e=e.map(t.changes);for(let n of t.effects)n.is(JC)&&(e=e.update({filter:e=>e!=n.value}));return e},provide:e=>zn.decorations.from(e)});function eN({margin:e=3,minSize:t=4}){return QC.init((n=>function(e,t,n){let r=new Vn,o="a"==e.facet(EC).side,s=e.field(_C),i=1;for(let a=0;;a++){let l=a<s.length?s[a]:null,c=a?i+t:1,d=l?e.doc.lineAt(o?l.fromA:l.fromB).number-1-t:e.doc.lines,u=d-c+1;if(u>=n&&r.add(e.doc.line(c).from,e.doc.line(d).to,$n.replace({widget:new XC(u),block:!0})),!l)break;i=e.doc.lineAt(Math.min(e.doc.length,o?l.toA:l.toB)).number}return r.finish()}(n,e,t)))}const tN=zn.styleModule.of(new qs({".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"}})),nN=zn.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"}}),rN=new Or,oN=new Or;class sN{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig;let t=[jr.low(LC),nN,tN,YC,zn.updateListener.of((e=>{this.measuring<0&&(e.heightChanged||e.viewportChanged)&&!e.transactions.some((e=>e.effects.some((e=>e.is(qC)))))&&this.measure()}))],n=[EC.of({side:"a",sibling:()=>this.b,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&n.push(FC);let r=yo.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],zn.editorAttributes.of({class:"cm-merge-a"}),oN.of(n),t]}),o=[EC.of({side:"b",sibling:()=>this.a,highlightChanges:!1!==e.highlightChanges,markGutter:!1!==e.gutter})];!1!==e.gutter&&o.push(FC);let s=yo.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],zn.editorAttributes.of({class:"cm-merge-b"}),oN.of(o),t]});this.chunks=IC.build(r.doc,s.doc,this.diffConf);let i=[_C.init((()=>this.chunks)),rN.of(e.collapseUnchanged?eN(e.collapseUnchanged):[])];r=r.update({effects:Hn.appendConfig.of(i)}).state,s=s.update({effects:Hn.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 a=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"==a?l:c),this.editorDOM.appendChild("a-b"==a?c:l),this.a=new zn({state:r,parent:l,root:e.root,dispatchTransactions:e=>this.dispatch(e,this.a)}),this.b=new zn({state:s,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],r=e.reduce(((e,t)=>e.compose(t.changes)),Ar.empty(e[0].startState.doc.length));this.chunks=t==this.a?IC.updateA(this.chunks,n.newDoc,this.b.state.doc,r,this.diffConf):IC.updateB(this.chunks,this.a.state.doc,n.newDoc,r,this.diffConf),t.update([...e,n.state.update({effects:jC.of(this.chunks)})]);let o=t==this.a?this.b:this.a;o.update([o.state.update({effects:jC.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,r=this.renderRevert;"revertControls"in e&&(t=!!e.revertControls,n="b-to-a"==e.revertControls),"renderRevertControl"in e&&(r=e.renderRevertControl),this.setupRevertControls(t,n,r)}let t="highlightChanges"in e,n="gutter"in e,r="collapseUnchanged"in e;if(t||n||r){let o=[],s=[];if(t||n){let r=this.a.state.facet(EC),i=n?!1!==e.gutter:r.markGutter,a=t?!1!==e.highlightChanges:r.highlightChanges;o.push(oN.reconfigure([EC.of({side:"a",sibling:()=>this.b,highlightChanges:a,markGutter:i}),i?FC:[]])),s.push(oN.reconfigure([EC.of({side:"b",sibling:()=>this.a,highlightChanges:a,markGutter:i}),i?FC:[]]))}if(r){let t=rN.reconfigure(e.collapseUnchanged?eN(e.collapseUnchanged):[]);o.push(t),s.push(t)}this.a.dispatch({effects:o}),this.b.dispatch({effects:s})}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 r=new Vn,o=new Vn,s=e.state.field(YC).iter(),i=t.state.field(YC).iter(),a=0,l=0,c=0,d=0;for(let m=0;;m++){let u=m<n.length?n[m]:null;if(a<(u?u.fromA:e.state.doc.length)){let n=e.lineBlockAt(a).top+c-(t.lineBlockAt(l).top+d);n<-.01?(c-=n,r.add(a,a,$n.widget({widget:new GC(-n),block:!0,side:-1}))):n>KC&&(d+=n,o.add(l,l,$n.widget({widget:new GC(n),block:!0,side:-1})))}if(!u)break;for(a=u.toA,l=u.toB;s.value&&s.from<a;)c-=s.value.spec.widget.height,s.next();for(;i.value&&i.from<l;)d-=i.value.spec.widget.height,i.next()}for(;s.value;)c-=s.value.spec.widget.height,s.next();for(;i.value;)d-=i.value.spec.widget.height,i.next();let u=e.contentHeight+c-(t.contentHeight+d);u<KC?r.add(e.state.doc.length,e.state.doc.length,$n.widget({widget:new GC(-u),block:!0,side:1})):u>KC&&o.add(t.state.doc.length,t.state.doc.length,$n.widget({widget:new GC(u),block:!0,side:1}));let h=r.finish(),f=o.finish();Ks.eq([h],[e.state.field(YC)])||e.dispatch({effects:qC.of(h)}),Ks.eq([f],[t.state.field(YC)])||t.dispatch({effects:qC.of(f)})}(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,t=e.firstChild,n=this.a.viewport,r=this.b.viewport;for(let o=0;o<this.chunks.length;o++){let s=this.chunks[o];if(s.fromA>n.to||s.fromB>r.to)break;if(s.fromA<n.from||s.fromB<r.from)continue;let i=this.a.lineBlockAt(s.fromA).top+"px";for(;t&&+t.dataset.chunk<o;)t=iN(t);t&&t.dataset.chunk==String(o)?(t.style.top!=i&&(t.style.top=i),t=t.nextSibling):e.insertBefore(this.renderRevertButton(i,o),t)}for(;t;)t=iN(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,r,o,s,i,a]=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(o,Math.max(o,s-1));o!=s&&a<=r.state.doc.length&&(l+=n.state.lineBreak),r.dispatch({changes:{from:i,to:Math.min(r.state.doc.length,a),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 iN(e){let t=e.nextSibling;return e.remove(),t}var aN=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig"],lN=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],cN=p.forwardRef(((e,t)=>{var{className:n,children:r,orientation:o,revertControls:s,highlightChanges:i,gutter:a,collapseUnchanged:c,destroyRerender:d=!0,renderRevertControl:u,diffConfig:h}=e,f=Ws(e,aN),m=YS(),{modified:p,modifiedExtension:g,original:y,originalExtension:b,theme:x,dispatch:v}=m,w=Ws(m,lN),k=l.useRef(null),S=l.useRef(),C={orientation:o,revertControls:s,highlightChanges:i,gutter:a,collapseUnchanged:c,renderRevertControl:u,diffConfig:h};l.useImperativeHandle(t,(()=>({container:k.current,view:S.current,modified:p,original:y,config:Hs({a:y,b:p,parent:k.current},C)})),[k,S,p,y,C]);var N=zn.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==b?void 0:b.onChange)){var t=e.state.doc.toString();null==b||b.onChange(t,e)}})),E=zn.updateListener.of((e=>{if(e.docChanged&&"function"==typeof(null==g?void 0:g.onChange)){var t=e.state.doc.toString();null==g||g.onChange(t,e)}}));l.useEffect((()=>{!S.current&&k.current&&b&&g&&(S.current=new sN(Hs({a:Hs({},y,{extensions:[...(null==b?void 0:b.extension)||[],...Gs(Hs({},null==b?void 0:b.option,{theme:x})),N]}),b:Hs({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Gs(Hs({},null==g?void 0:g.option,{theme:x})),E]}),parent:k.current},C)),v({view:S.current}))}),[S,k,b,g]),l.useEffect((()=>{if(y&&y.doc&&S.current){var e,t,n=null==(e=S.current)?void 0:e.a.state.doc.toString();if(n!==y.doc)null==(t=S.current)||t.a.dispatch({changes:{from:0,to:n.length,insert:y.doc||""}})}if(p&&p.doc&&S.current){var r,o,s=null==(r=S.current)?void 0:r.b.state.doc.toString();if(s!==p.doc)null==(o=S.current)||o.b.dispatch({changes:{from:0,to:s.length,insert:p.doc||""}})}if(d&&S.current){var i=S.current.a.state.selection.ranges[0].from,a=S.current.b.state.selection.ranges[0].from;S.current.destroy(),S.current=new sN(Hs({a:Hs({},y,{extensions:[...(null==b?void 0:b.extension)||[],...Gs(Hs({},null==b?void 0:b.option,{theme:x}))]}),b:Hs({},p,{extensions:[...(null==g?void 0:g.extension)||[],...Gs(Hs({},null==g?void 0:g.option,{theme:x}))]}),parent:k.current},C)),i&&(S.current.a.focus(),S.current.a.dispatch({selection:{anchor:i,head:i}})),a&&(S.current.b.focus(),S.current.b.dispatch({selection:{anchor:a,head:a}}))}}),[S,x,k.current,y,p,b,g,d]),l.useEffect((()=>()=>S.current&&S.current.destroy()),[]),l.useEffect((()=>{if(S.current){var e={};w.orientation!==o&&(e.orientation=o),w.revertControls!==s&&(e.revertControls=s),w.highlightChanges!==i&&(e.highlightChanges=i),w.gutter!==a&&(e.gutter=a),w.collapseUnchanged!==c&&(e.collapseUnchanged=c),w.renderRevertControl!==u&&(e.collapseUnchanged=c),Object.keys(e).length&&v&&S.current&&(S.current.reconfigure(Hs({},e)),v(Hs({},e)))}}),[v,S,o,s,i,a,c,u]);return _.jsx("div",Hs({ref:k,className:"cm-merge-theme"+(n?" "+n:"")},f,{children:r}))}));cN.displayName="CodeMirrorMerge.Internal";var dN=["theme"],uN=p.forwardRef(((e,t)=>{var{theme:n}=e,r=Ws(e,dN);return _.jsx(KS,{theme:n,children:_.jsx(cN,Hs({},r,{ref:t}))})}));uN.Original=XS,uN.Modified=QS,uN.displayName="CodeMirrorMerge";const hN=uN.Original,fN=uN.Modified,mN=[Qs(),zn.lineWrapping],pN=e=>{const t=N.c(42),{className:n,onChange:r,initialPrompt:o,currentLanguageAdapter:s,currentCode:i,declineChange:a,acceptChange:c,enabled:d,children:u}=e;let h;t[0]===Symbol.for("react.memo_cache_sentinel")?(h={},t[0]=h):h=t[0];const[f,m]=l.useState(h),[g,y]=We(th),{completion:b,input:x,stop:v,isLoading:w,setCompletion:k,setInput:S,handleSubmit:C}=Xs({api:Yr("api/ai/completion").toString(),headers:Pr.headers(),initialInput:o,streamProtocol:"text",experimental_throttle:100,body:{...f,includeOtherCode:g?Dr(i):"",code:i,language:s},onError:gN,onFinish:(e,t)=>{E(t.trimEnd())}}),E=k,j=p.useRef(null);let I,A,T,M;t[1]!==d?(I=()=>{const e=j.current;d&&e&&(requestAnimationFrame((()=>{var t;null==(t=e.view)||t.focus()})),ei(j.current.view))},A=[d],t[1]=d,t[2]=I,t[3]=A):(I=t[2],A=t[3]),l.useEffect(I,A),t[4]!==d||t[5]!==o||t[6]!==S?(T=()=>{d&&S(o||"")},M=[d,o,S],t[4]=d,t[5]=o,t[6]=S,t[7]=T,t[8]=M):(T=t[7],M=t[8]),l.useEffect(T,M);const{theme:D}=Be();let O;t[9]!==n?(O=$t("flex flex-col w-full rounded-[inherit] overflow-hidden",n),t[9]=n,t[10]=O):O=t[10];const R=d&&"max-h-[400px] min-h-11 visible",P=!d&&"max-h-0 min-h-0 invisible";let L,F,z,B;t[11]!==R||t[12]!==P?(L=$t("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300 overflow-hidden",R,P),t[11]=R,t[12]=P,t[13]=L):L=t[13],t[14]!==c||t[15]!==b||t[16]!==a||t[17]!==d||t[18]!==C||t[19]!==g||t[20]!==x||t[21]!==w||t[22]!==E||t[23]!==y||t[24]!==S||t[25]!==v||t[26]!==D?(F=d&&_.jsxs(_.Fragment,{children:[_.jsx(ye,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),_.jsx(ti,{inputRef:j,theme:D,onClose:()=>{a(),E("")},value:x,onChange:e=>{S(e),m(ni({input:e}))},onSubmit:()=>{w||C()}}),w&&_.jsxs(ee,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:v,children:[_.jsx(ri,{className:"animate-spin mr-1",size:14}),"Stop"]}),!w&&b&&_.jsx(ee,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:w,onClick:()=>{c(b),E("")},children:_.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),_.jsx("div",{className:"h-full w-px bg-border mx-2"}),_.jsx(ht,{content:"Include code from other cells",children:_.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[_.jsx(oi,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:g,onCheckedChange:e=>y(Boolean(e))}),_.jsx(Fe,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),_.jsx(ee,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:w,onClick:()=>{v(),a(),E("")},children:_.jsx(Gn,{className:"text-[var(--red-10)]",size:16})})]}),t[14]=c,t[15]=b,t[16]=a,t[17]=d,t[18]=C,t[19]=g,t[20]=x,t[21]=w,t[22]=E,t[23]=y,t[24]=S,t[25]=v,t[26]=D,t[27]=F):F=t[27],t[28]!==L||t[29]!==F?(z=_.jsx("div",{className:L,children:F}),t[28]=L,t[29]=F,t[30]=z):z=t[30],t[31]!==b||t[32]!==i||t[33]!==d||t[34]!==r||t[35]!==D?(B=b&&d&&_.jsxs(uN,{className:"cm",theme:D,children:[_.jsx(hN,{onChange:r,value:i,extensions:mN}),_.jsx(fN,{value:b,editable:!1,readOnly:!0,extensions:mN})]}),t[31]=b,t[32]=i,t[33]=d,t[34]=r,t[35]=D,t[36]=B):B=t[36];const U=(!b||!d)&&u;let $;return t[37]!==z||t[38]!==B||t[39]!==U||t[40]!==O?($=_.jsxs("div",{className:O,children:[z,B,U]}),t[37]=z,t[38]=B,t[39]=U,t[40]=O,t[41]=$):$=t[41],$};function gN(e){se({title:"Completion failed",description:Zs(e)})}const yN=()=>new Map,bN=e=>{const t=yN();return e.forEach(((e,n)=>{t.set(n,e)})),t},xN=(e,t,n)=>{let r=e.get(t);return void 0===r&&e.set(t,r=n()),r},vN=()=>new Set,wN=e=>e[e.length-1],kN=(e,t)=>{for(let n=0;n<t.length;n++)e.push(t[n])},SN=Array.from,CN=Array.isArray;class NN{constructor(){this._observers=yN()}on(e,t){return xN(this._observers,e,vN).add(t),t}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return SN((this._observers.get(e)||yN()).values()).forEach((e=>e(...t)))}destroy(){this._observers=yN()}}class EN{constructor(){this._observers=yN()}on(e,t){xN(this._observers,e,vN).add(t)}once(e,t){const n=(...r)=>{this.off(e,n),t(...r)};this.on(e,n)}off(e,t){const n=this._observers.get(e);void 0!==n&&(n.delete(t),0===n.size&&this._observers.delete(e))}emit(e,t){return SN((this._observers.get(e)||yN()).values()).forEach((e=>e(...t)))}destroy(){this._observers=yN()}}const jN=Math.floor,_N=Math.abs,IN=(e,t)=>e<t?e:t,AN=(e,t)=>e>t?e:t,TN=Math.pow,MN=e=>0!==e?e<0:1/e<0,DN=64,ON=128,RN=127,PN=Number.MAX_SAFE_INTEGER,LN=Number.isInteger||(e=>"number"==typeof e&&isFinite(e)&&jN(e)===e),FN=String.fromCharCode,zN=/^\s*/g,BN=/([A-Z])/g,UN=(e,t)=>(e=>e.replace(zN,""))(e.replace(BN,(e=>`${t}${(e=>e.toLowerCase())(e)}`))),$N="undefined"!=typeof TextEncoder?new TextEncoder:null,VN=$N?e=>$N.encode(e):e=>{const t=unescape(encodeURIComponent(e)),n=t.length,r=new Uint8Array(n);for(let o=0;o<n;o++)r[o]=t.codePointAt(o);return r};let HN="undefined"==typeof TextDecoder?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});HN&&1===HN.decode(new Uint8Array).length&&(HN=null);class WN{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const GN=()=>new WN,qN=e=>{let t=e.cpos;for(let n=0;n<e.bufs.length;n++)t+=e.bufs[n].length;return t},YN=e=>{const t=new Uint8Array(qN(e));let n=0;for(let r=0;r<e.bufs.length;r++){const o=e.bufs[r];t.set(o,n),n+=o.length}return t.set(new Uint8Array(e.cbuf.buffer,0,e.cpos),n),t},KN=(e,t)=>{const n=e.cbuf.length;e.cpos===n&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(2*n),e.cpos=0),e.cbuf[e.cpos++]=t},JN=KN,XN=(e,t)=>{for(;t>RN;)KN(e,ON|RN&t),t=jN(t/128);KN(e,RN&t)},ZN=(e,t)=>{const n=MN(t);for(n&&(t=-t),KN(e,(t>63?ON:0)|(n?DN:0)|63&t),t=jN(t/64);t>0;)KN(e,(t>RN?ON:0)|RN&t),t=jN(t/128)},QN=new Uint8Array(3e4),eE=QN.length/3,tE=$N&&$N.encodeInto?(e,t)=>{if(t.length<eE){const n=$N.encodeInto(t,QN).written||0;XN(e,n);for(let t=0;t<n;t++)KN(e,QN[t])}else rE(e,VN(t))}:(e,t)=>{const n=unescape(encodeURIComponent(t)),r=n.length;XN(e,r);for(let o=0;o<r;o++)KN(e,n.codePointAt(o))},nE=(e,t)=>{const n=e.cbuf.length,r=e.cpos,o=IN(n-r,t.length),s=t.length-o;e.cbuf.set(t.subarray(0,o),r),e.cpos+=o,s>0&&(e.bufs.push(e.cbuf),e.cbuf=new Uint8Array(AN(2*n,s)),e.cbuf.set(t.subarray(o)),e.cpos=s)},rE=(e,t)=>{XN(e,t.byteLength),nE(e,t)},oE=(e,t)=>{((e,t)=>{const n=e.cbuf.length;n-e.cpos<t&&(e.bufs.push(new Uint8Array(e.cbuf.buffer,0,e.cpos)),e.cbuf=new Uint8Array(2*AN(n,t)),e.cpos=0)})(e,t);const n=new DataView(e.cbuf.buffer,e.cpos,t);return e.cpos+=t,n},sE=new DataView(new ArrayBuffer(4)),iE=(e,t)=>{switch(typeof t){case"string":KN(e,119),tE(e,t);break;case"number":LN(t)&&_N(t)<=2147483647?(KN(e,125),ZN(e,t)):(n=t,sE.setFloat32(0,n),sE.getFloat32(0)===n?(KN(e,124),((e,t)=>{oE(e,4).setFloat32(0,t,!1)})(e,t)):(KN(e,123),((e,t)=>{oE(e,8).setFloat64(0,t,!1)})(e,t)));break;case"bigint":KN(e,122),((e,t)=>{oE(e,8).setBigInt64(0,t,!1)})(e,t);break;case"object":if(null===t)KN(e,126);else if(CN(t)){KN(e,117),XN(e,t.length);for(let n=0;n<t.length;n++)iE(e,t[n])}else if(t instanceof Uint8Array)KN(e,116),rE(e,t);else{KN(e,118);const n=Object.keys(t);XN(e,n.length);for(let r=0;r<n.length;r++){const o=n[r];tE(e,o),iE(e,t[o])}}break;case"boolean":KN(e,t?120:121);break;default:KN(e,127)}var n};class aE extends WN{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&XN(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const lE=e=>{e.count>0&&(ZN(e.encoder,1===e.count?e.s:-e.s),e.count>1&&XN(e.encoder,e.count-2))};class cE{constructor(){this.encoder=new WN,this.s=0,this.count=0}write(e){this.s===e?this.count++:(lE(this),this.count=1,this.s=e)}toUint8Array(){return lE(this),YN(this.encoder)}}const dE=e=>{if(e.count>0){const t=2*e.diff+(1===e.count?0:1);ZN(e.encoder,t),e.count>1&&XN(e.encoder,e.count-2)}};class uE{constructor(){this.encoder=new WN,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(dE(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return dE(this),YN(this.encoder)}}class hE{constructor(){this.sarr=[],this.s="",this.lensE=new cE}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new WN;return this.sarr.push(this.s),this.s="",tE(e,this.sarr.join("")),nE(e,this.lensE.toUint8Array()),YN(e)}}const fE=e=>new Error(e),mE=()=>{throw fE("Method unimplemented")},pE=()=>{throw fE("Unexpected case")},gE=fE("Unexpected end of array"),yE=fE("Integer out of Range");class bE{constructor(e){this.arr=e,this.pos=0}}const xE=e=>new bE(e),vE=e=>((e,t)=>{const n=new Uint8Array(e.arr.buffer,e.pos+e.arr.byteOffset,t);return e.pos+=t,n})(e,kE(e)),wE=e=>e.arr[e.pos++],kE=e=>{let t=0,n=1;const r=e.arr.length;for(;e.pos<r;){const r=e.arr[e.pos++];if(t+=(r&RN)*n,n*=128,r<ON)return t;if(t>PN)throw yE}throw gE},SE=e=>{let t=e.arr[e.pos++],n=63&t,r=64;const o=(t&DN)>0?-1:1;if(!(t&ON))return o*n;const s=e.arr.length;for(;e.pos<s;){if(t=e.arr[e.pos++],n+=(t&RN)*r,r*=128,t<ON)return o*n;if(n>PN)throw yE}throw gE},CE=HN?e=>HN.decode(vE(e)):e=>{let t=kE(e);if(0===t)return"";{let n=String.fromCodePoint(wE(e));if(--t<100)for(;t--;)n+=String.fromCodePoint(wE(e));else for(;t>0;){const r=t<1e4?t:1e4,o=e.arr.subarray(e.pos,e.pos+r);e.pos+=r,n+=String.fromCodePoint.apply(null,o),t-=r}return decodeURIComponent(escape(n))}},NE=(e,t)=>{const n=new DataView(e.arr.buffer,e.arr.byteOffset+e.pos,t);return e.pos+=t,n},EE=[e=>{},e=>null,SE,e=>NE(e,4).getFloat32(0,!1),e=>NE(e,8).getFloat64(0,!1),e=>NE(e,8).getBigInt64(0,!1),e=>!1,e=>!0,CE,e=>{const t=kE(e),n={};for(let r=0;r<t;r++){n[CE(e)]=jE(e)}return n},e=>{const t=kE(e),n=[];for(let r=0;r<t;r++)n.push(jE(e));return n},vE],jE=e=>EE[127-wE(e)](e);class _E extends bE{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){var e;return 0===this.count&&(this.s=this.reader(this),(e=this).pos!==e.arr.length?this.count=kE(this)+1:this.count=-1),this.count--,this.s}}class IE extends bE{constructor(e){super(e),this.s=0,this.count=0}read(){if(0===this.count){this.s=SE(this);const e=MN(this.s);this.count=1,e&&(this.s=-this.s,this.count=kE(this)+2)}return this.count--,this.s}}class AE extends bE{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(0===this.count){const e=SE(this),t=1&e;this.diff=jN(e/2),this.count=1,t&&(this.count=kE(this)+2)}return this.s+=this.diff,this.count--,this.s}}class TE{constructor(e){this.decoder=new IE(e),this.str=CE(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const ME=crypto.getRandomValues.bind(crypto),DE=()=>ME(new Uint32Array(1))[0],OE="10000000-1000-4000-8000-100000000000",RE=()=>OE.replace(/[018]/g,(e=>(e^DE()&15>>e/4).toString(16))),PE=Date.now,LE=e=>new Promise(e);Promise.all.bind(Promise);const FE=e=>void 0===e?null:e;let zE=new class{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}},BE=!0;try{"undefined"!=typeof localStorage&&localStorage&&(zE=localStorage,BE=!1)}catch(_K){}const UE=zE,$E=Object.assign,VE=Object.keys,HE=e=>VE(e).length,WE=e=>VE(e).length,GE=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),qE=Object.freeze,YE=e=>{for(const t in e){const n=e[t];"object"!=typeof n&&"function"!=typeof n||YE(e[t])}return qE(e)},KE=(e,t,n=0)=>{try{for(;n<e.length;n++)e[n](...t)}finally{n<e.length&&KE(e,t,n+1)}},JE=e=>e,XE=(e,t)=>{if(null==e||null==t)return((e,t)=>e===t)(e,t);if(e.constructor!==t.constructor)return!1;if(e===t)return!0;switch(e.constructor){case ArrayBuffer:e=new Uint8Array(e),t=new Uint8Array(t);case Uint8Array:if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;break;case Set:if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;break;case Map:if(e.size!==t.size)return!1;for(const n of e.keys())if(!t.has(n)||!XE(e.get(n),t.get(n)))return!1;break;case Object:if(HE(e)!==HE(t))return!1;for(const n in e)if(!GE(e,n)||!XE(e[n],t[n]))return!1;break;case Array:if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!XE(e[n],t[n]))return!1;break;default:return!1}return!0};var ZE={};const QE="undefined"!=typeof process&&process.release&&/node|io\.js/.test(process.release.name)&&"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0),ej="undefined"!=typeof window&&"undefined"!=typeof document&&!QE;let tj;const nj=e=>(()=>{if(void 0===tj)if(QE){tj=yN();const e=process.argv;let t=null;for(let n=0;n<e.length;n++){const r=e[n];"-"===r[0]?(null!==t&&tj.set(t,""),t=r):null!==t&&(tj.set(t,r),t=null)}null!==t&&tj.set(t,"")}else"object"==typeof location?(tj=yN(),(location.search||"?").slice(1).split("&").forEach((e=>{if(0!==e.length){const[t,n]=e.split("=");tj.set(`--${UN(t,"-")}`,n),tj.set(`-${UN(t,"-")}`,n)}}))):tj=yN();return tj})().has(e),rj=e=>FE(QE?ZE[e.toUpperCase().replaceAll("-","_")]:UE.getItem(e)),oj=e=>nj("--"+e)||null!==rj(e);oj("production");const sj=QE&&["true","1","2"].includes(ZE.FORCE_COLOR)||!nj("--no-colors")&&!oj("no-color")&&(!QE||process.stdout.isTTY)&&(!QE||nj("--color")||null!==rj("COLORTERM")||(rj("TERM")||"").includes("color")),ij=e=>new Uint8Array(e),aj=ej?e=>{let t="";for(let n=0;n<e.byteLength;n++)t+=FN(e[n]);return btoa(t)}:e=>Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("base64"),lj=ej?e=>{const t=atob(e),n=ij(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}:e=>{const t=Buffer.from(e,"base64");return n=t.buffer,r=t.byteOffset,o=t.byteLength,new Uint8Array(n,r,o);var n,r,o};class cj{constructor(e,t){this.left=e,this.right=t}}const dj=(e,t)=>new cj(e,t);"undefined"!=typeof DOMParser&&new DOMParser;const uj=Symbol,hj=uj(),fj=uj(),mj=uj(),pj=uj(),gj=uj(),yj=uj(),bj=uj(),xj=uj(),vj=uj(),wj={[hj]:dj("font-weight","bold"),[fj]:dj("font-weight","normal"),[mj]:dj("color","blue"),[gj]:dj("color","green"),[pj]:dj("color","grey"),[yj]:dj("color","red"),[bj]:dj("color","purple"),[xj]:dj("color","orange"),[vj]:dj("color","black")},kj=sj?e=>{var t;1===e.length&&(null==(t=e[0])?void 0:t.constructor)===Function&&(e=e[0]());const n=[],r=[],o=yN();let s=[],i=0;for(;i<e.length;i++){const t=e[i],s=wj[t];if(void 0!==s)o.set(s.left,s.right);else{if(void 0===t)break;if(t.constructor!==String&&t.constructor!==Number)break;{const e=((e,t)=>{const n=[];for(const[r,o]of e)n.push(t(o,r));return n})(o,((e,t)=>`${t}:${e};`)).join("");i>0||e.length>0?(n.push("%c"+t),r.push(e)):n.push(t)}}}for(i>0&&(s=r,s.unshift(n.join("")));i<e.length;i++){const t=e[i];t instanceof Symbol||s.push(t)}return s}:e=>{var t;1===e.length&&(null==(t=e[0])?void 0:t.constructor)===Function&&(e=e[0]());const n=[],r=[];let o=0;for(;o<e.length;o++){const t=e[o];if(void 0===t)break;if(t.constructor===String||t.constructor===Number)n.push(t);else if(t.constructor===Object)break}for(o>0&&r.push(n.join(""));o<e.length;o++){const t=e[o];t instanceof Symbol||r.push(t)}return r},Sj=(...e)=>{console.warn(...kj(e)),e.unshift(xj),Cj.forEach((t=>t.print(e)))},Cj=vN(),Nj=e=>({[Symbol.iterator](){return this},next:e}),Ej=(e,t)=>Nj((()=>{const{done:n,value:r}=e.next();return{done:n,value:n?void 0:t(r)}}));class jj{constructor(e,t){this.clock=e,this.len=t}}class _j{constructor(){this.clients=new Map}}const Ij=(e,t,n)=>t.clients.forEach(((t,r)=>{const o=e.doc.store.clients.get(r);if(null!=o){const r=o[o.length-1],s=r.id.clock+r.length;for(let i=0,a=t[i];i<t.length&&a.clock<s;a=t[++i])__(e,o,a.clock,a.len,n)}})),Aj=(e,t)=>{const n=e.clients.get(t.client);return void 0!==n&&null!==((e,t)=>{let n=0,r=e.length-1;for(;n<=r;){const o=jN((n+r)/2),s=e[o],i=s.clock;if(i<=t){if(t<i+s.len)return o;n=o+1}else r=o-1}return null})(n,t.clock)},Tj=e=>{e.clients.forEach((e=>{let t,n;for(e.sort(((e,t)=>e.clock-t.clock)),t=1,n=1;t<e.length;t++){const r=e[n-1],o=e[t];r.clock+r.len>=o.clock?r.len=AN(r.len,o.clock+o.len-r.clock):(n<t&&(e[n]=o),n++)}e.length=n}))},Mj=e=>{const t=new _j;for(let n=0;n<e.length;n++)e[n].clients.forEach(((r,o)=>{if(!t.clients.has(o)){const s=r.slice();for(let t=n+1;t<e.length;t++)kN(s,e[t].clients.get(o)||[]);t.clients.set(o,s)}}));return Tj(t),t},Dj=(e,t,n,r)=>{xN(e.clients,t,(()=>[])).push(new jj(n,r))},Oj=e=>{const t=new _j;return e.clients.forEach(((e,n)=>{const r=[];for(let t=0;t<e.length;t++){const n=e[t];if(n.deleted){const o=n.id.clock;let s=n.length;if(t+1<e.length)for(let n=e[t+1];t+1<e.length&&n.deleted;n=e[1+ ++t])s+=n.length;r.push(new jj(o,s))}}r.length>0&&t.clients.set(n,r)})),t},Rj=(e,t)=>{XN(e.restEncoder,t.clients.size),SN(t.clients.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,n])=>{e.resetDsCurVal(),XN(e.restEncoder,t);const r=n.length;XN(e.restEncoder,r);for(let o=0;o<r;o++){const t=n[o];e.writeDsClock(t.clock),e.writeDsLen(t.len)}}))},Pj=e=>{const t=new _j,n=kE(e.restDecoder);for(let r=0;r<n;r++){e.resetDsCurVal();const n=kE(e.restDecoder),r=kE(e.restDecoder);if(r>0){const o=xN(t.clients,n,(()=>[]));for(let t=0;t<r;t++)o.push(new jj(e.readDsClock(),e.readDsLen()))}}return t},Lj=(e,t,n)=>{const r=new _j,o=kE(e.restDecoder);for(let s=0;s<o;s++){e.resetDsCurVal();const o=kE(e.restDecoder),s=kE(e.restDecoder),i=n.clients.get(o)||[],a=w_(n,o);for(let n=0;n<s;n++){const n=e.readDsClock(),s=n+e.readDsLen();if(n<a){a<s&&Dj(r,o,a,s-a);let e=S_(i,n),l=i[e];for(!l.deleted&&l.id.clock<n&&(i.splice(e+1,0,yA(t,l,n-l.id.clock)),e++);e<i.length&&(l=i[e++],l.id.clock<s);)l.deleted||(s<l.id.clock+l.length&&i.splice(e,0,yA(t,l,s-l.id.clock)),l.delete(t))}else Dj(r,o,n,s-n)}}if(r.clients.size>0){const e=new qj;return XN(e.restEncoder,0),Rj(e,r),e.toUint8Array()}return null},Fj=DE;class zj extends NN{constructor({guid:e=RE(),collectionid:t=null,gc:n=!0,gcFilter:r=()=>!0,meta:o=null,autoLoad:s=!1,shouldLoad:i=!0}={}){super(),this.gc=n,this.gcFilter=r,this.clientID=Fj(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new x_,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=i,this.autoLoad=s,this.meta=o,this.isLoaded=!1,this.isSynced=!1,this.isDestroyed=!1,this.whenLoaded=LE((e=>{this.on("load",(()=>{this.isLoaded=!0,e(this)}))}));const a=()=>LE((e=>{const t=n=>{void 0!==n&&!0!==n||(this.off("sync",t),e())};this.on("sync",t)}));this.on("sync",(e=>{!1===e&&this.isSynced&&(this.whenSynced=a()),this.isSynced=void 0===e||!0===e,this.isSynced&&!this.isLoaded&&this.emit("load",[this])})),this.whenSynced=a()}load(){const e=this._item;null===e||this.shouldLoad||O_(e.parent.doc,(e=>{e.subdocsLoaded.add(this)}),null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(SN(this.subdocs).map((e=>e.guid)))}transact(e,t=null){return O_(this,e,t)}get(e,t=sI){const n=xN(this.share,e,(()=>{const e=new t;return e._integrate(this,null),e})),r=n.constructor;if(t!==sI&&r!==t){if(r===sI){const r=new t;r._map=n._map,n._map.forEach((e=>{for(;null!==e;e=e.left)e.parent=r})),r._start=n._start;for(let e=r._start;null!==e;e=e.right)e.parent=r;return r._length=n._length,this.share.set(e,r),r._integrate(this,null),r}throw new Error(`Type with the name ${e} has already been defined with a different constructor`)}return n}getArray(e=""){return this.get(e,SI)}getText(e=""){return this.get(e,UI)}getMap(e=""){return this.get(e,NI)}getXmlElement(e=""){return this.get(e,HI)}getXmlFragment(e=""){return this.get(e,VI)}toJSON(){const e={};return this.share.forEach(((t,n)=>{e[n]=t.toJSON()})),e}destroy(){this.isDestroyed=!0,SN(this.subdocs).forEach((e=>e.destroy()));const e=this._item;if(null!==e){this._item=null;const t=e.content;t.doc=new zj({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,O_(e.parent.doc,(n=>{const r=t.doc;e.deleted||n.subdocsAdded.add(r),n.subdocsRemoved.add(this)}),null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class Bj{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return kE(this.restDecoder)}readDsLen(){return kE(this.restDecoder)}}class Uj extends Bj{readLeftID(){return l_(kE(this.restDecoder),kE(this.restDecoder))}readRightID(){return l_(kE(this.restDecoder),kE(this.restDecoder))}readClient(){return kE(this.restDecoder)}readInfo(){return wE(this.restDecoder)}readString(){return CE(this.restDecoder)}readParentInfo(){return 1===kE(this.restDecoder)}readTypeRef(){return kE(this.restDecoder)}readLen(){return kE(this.restDecoder)}readAny(){return jE(this.restDecoder)}readBuf(){return(e=>{const t=ij(e.byteLength);return t.set(e),t})(vE(this.restDecoder))}readJSON(){return JSON.parse(CE(this.restDecoder))}readKey(){return CE(this.restDecoder)}}class $j{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=kE(this.restDecoder),this.dsCurrVal}readDsLen(){const e=kE(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Vj extends $j{constructor(e){super(e),this.keys=[],kE(e),this.keyClockDecoder=new AE(vE(e)),this.clientDecoder=new IE(vE(e)),this.leftClockDecoder=new AE(vE(e)),this.rightClockDecoder=new AE(vE(e)),this.infoDecoder=new _E(vE(e),wE),this.stringDecoder=new TE(vE(e)),this.parentInfoDecoder=new _E(vE(e),wE),this.typeRefDecoder=new IE(vE(e)),this.lenDecoder=new IE(vE(e))}readLeftID(){return new i_(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new i_(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return 1===this.parentInfoDecoder.read()}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return jE(this.restDecoder)}readBuf(){return vE(this.restDecoder)}readJSON(){return jE(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const e=this.stringDecoder.read();return this.keys.push(e),e}}}class Hj{constructor(){this.restEncoder=GN()}toUint8Array(){return YN(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){XN(this.restEncoder,e)}writeDsLen(e){XN(this.restEncoder,e)}}class Wj extends Hj{writeLeftID(e){XN(this.restEncoder,e.client),XN(this.restEncoder,e.clock)}writeRightID(e){XN(this.restEncoder,e.client),XN(this.restEncoder,e.clock)}writeClient(e){XN(this.restEncoder,e)}writeInfo(e){JN(this.restEncoder,e)}writeString(e){tE(this.restEncoder,e)}writeParentInfo(e){XN(this.restEncoder,e?1:0)}writeTypeRef(e){XN(this.restEncoder,e)}writeLen(e){XN(this.restEncoder,e)}writeAny(e){iE(this.restEncoder,e)}writeBuf(e){rE(this.restEncoder,e)}writeJSON(e){tE(this.restEncoder,JSON.stringify(e))}writeKey(e){tE(this.restEncoder,e)}}class Gj{constructor(){this.restEncoder=GN(),this.dsCurrVal=0}toUint8Array(){return YN(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,XN(this.restEncoder,t)}writeDsLen(e){0===e&&pE(),XN(this.restEncoder,e-1),this.dsCurrVal+=e}}class qj extends Gj{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new uE,this.clientEncoder=new cE,this.leftClockEncoder=new uE,this.rightClockEncoder=new uE,this.infoEncoder=new aE(JN),this.stringEncoder=new hE,this.parentInfoEncoder=new aE(JN),this.typeRefEncoder=new cE,this.lenEncoder=new cE}toUint8Array(){const e=GN();return XN(e,0),rE(e,this.keyClockEncoder.toUint8Array()),rE(e,this.clientEncoder.toUint8Array()),rE(e,this.leftClockEncoder.toUint8Array()),rE(e,this.rightClockEncoder.toUint8Array()),rE(e,YN(this.infoEncoder)),rE(e,this.stringEncoder.toUint8Array()),rE(e,YN(this.parentInfoEncoder)),rE(e,this.typeRefEncoder.toUint8Array()),rE(e,this.lenEncoder.toUint8Array()),nE(e,YN(this.restEncoder)),YN(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){iE(this.restEncoder,e)}writeBuf(e){rE(this.restEncoder,e)}writeJSON(e){iE(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);void 0===t?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const Yj=(e,t,n)=>{const r=new Map;n.forEach(((e,n)=>{w_(t,n)>e&&r.set(n,e)})),v_(t).forEach(((e,t)=>{n.has(t)||r.set(t,0)})),XN(e.restEncoder,r.size),SN(r.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([n,r])=>{((e,t,n,r)=>{r=AN(r,t[0].id.clock);const o=S_(t,r);XN(e.restEncoder,t.length-o),e.writeClient(n),XN(e.restEncoder,r);const s=t[o];s.write(e,r-s.id.clock);for(let i=o+1;i<t.length;i++)t[i].write(e,0)})(e,t.clients.get(n),n,r)}))},Kj=(e,t,n,r=new Vj(e))=>O_(t,(e=>{e.local=!1;let t=!1;const n=e.doc,o=n.store,s=((e,t)=>{const n=yN(),r=kE(e.restDecoder);for(let o=0;o<r;o++){const r=kE(e.restDecoder),o=new Array(r),s=e.readClient();let i=kE(e.restDecoder);n.set(s,{i:0,refs:o});for(let n=0;n<r;n++){const r=e.readInfo();switch(31&r){case 0:{const t=e.readLen();o[n]=new KI(l_(s,i),t),i+=t;break}case 10:{const t=kE(e.restDecoder);o[n]=new SA(l_(s,i),t),i+=t;break}default:{const a=!(192&r),l=new vA(l_(s,i),null,(r&ON)===ON?e.readLeftID():null,null,(r&DN)===DN?e.readRightID():null,a?e.readParentInfo()?t.get(e.readString()):e.readLeftID():null,!a||32&~r?null:e.readString(),wA(e,r));o[n]=l,i+=l.length}}}}return n})(r,n),i=((e,t,n)=>{const r=[];let o=SN(n.keys()).sort(((e,t)=>e-t));if(0===o.length)return null;const s=()=>{if(0===o.length)return null;let e=n.get(o[o.length-1]);for(;e.refs.length===e.i;){if(o.pop(),!(o.length>0))return null;e=n.get(o[o.length-1])}return e};let i=s();if(null===i)return null;const a=new x_,l=new Map,c=(e,t)=>{const n=l.get(e);(null==n||n>t)&&l.set(e,t)};let d=i.refs[i.i++];const u=new Map,h=()=>{for(const e of r){const t=e.id.client,r=n.get(t);r?(r.i--,a.clients.set(t,r.refs.slice(r.i)),n.delete(t),r.i=0,r.refs=[]):a.clients.set(t,[e]),o=o.filter((e=>e!==t))}r.length=0};for(;;){if(d.constructor!==SA){const o=xN(u,d.id.client,(()=>w_(t,d.id.client)))-d.id.clock;if(o<0)r.push(d),c(d.id.client,d.id.clock-1),h();else{const s=d.getMissing(e,t);if(null!==s){r.push(d);const e=n.get(s)||{refs:[],i:0};if(e.refs.length!==e.i){d=e.refs[e.i++];continue}c(s,w_(t,s)),h()}else(0===o||o<d.length)&&(d.integrate(e,o),u.set(d.id.client,d.id.clock+d.length))}}if(r.length>0)d=r.pop();else if(null!==i&&i.i<i.refs.length)d=i.refs[i.i++];else{if(i=s(),null===i)break;d=i.refs[i.i++]}}if(a.clients.size>0){const e=new qj;return Yj(e,a,new Map),XN(e.restEncoder,0),{missing:l,update:e.toUint8Array()}}return null})(e,o,s),a=o.pendingStructs;if(a){for(const[e,n]of a.missing)if(n<w_(o,e)){t=!0;break}if(i){for(const[e,t]of i.missing){const n=a.missing.get(e);(null==n||n>t)&&a.missing.set(e,t)}a.update=V_([a.update,i.update])}}else o.pendingStructs=i;const l=Lj(r,e,o);if(o.pendingDs){const t=new Vj(xE(o.pendingDs));kE(t.restDecoder);const n=Lj(t,e,o);o.pendingDs=l&&n?V_([l,n]):l||n}else o.pendingDs=l;if(t){const t=o.pendingStructs.update;o.pendingStructs=null,Jj(e.doc,t)}}),n,!1),Jj=(e,t,n,r=Vj)=>{const o=xE(t);Kj(o,e,n,new r(o))},Xj=(e,t=new Uint8Array([0]),n=new qj)=>{((e,t,n=new Map)=>{Yj(e,t.store,n),Rj(e,Oj(t.store))})(n,e,Zj(t));const r=[n.toUint8Array()];if(e.store.pendingDs&&r.push(e.store.pendingDs),e.store.pendingStructs&&r.push(H_(e.store.pendingStructs.update,t)),r.length>1){if(n.constructor===Wj)return U_(r.map(((e,t)=>0===t?e:Y_(e))));if(n.constructor===qj)return V_(r)}return r[0]},Zj=e=>(e=>{const t=new Map,n=kE(e.restDecoder);for(let r=0;r<n;r++){const n=kE(e.restDecoder),r=kE(e.restDecoder);t.set(n,r)}return t})(new Bj(xE(e))),Qj=(e,t)=>(XN(e.restEncoder,t.size),SN(t.entries()).sort(((e,t)=>t[0]-e[0])).forEach((([t,n])=>{XN(e.restEncoder,t),XN(e.restEncoder,n)})),e),e_=(e,t=new Gj)=>(e instanceof Map?Qj(t,e):((e,t)=>{Qj(e,v_(t.store))})(t,e),t.toUint8Array());class t_{constructor(){this.l=[]}}const n_=()=>new t_,r_=(e,t)=>e.l.push(t),o_=(e,t)=>{const n=e.l,r=n.length;e.l=n.filter((e=>t!==e)),r===e.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},s_=(e,t,n)=>KE(e.l,[t,n]);class i_{constructor(e,t){this.client=e,this.clock=t}}const a_=(e,t)=>e===t||null!==e&&null!==t&&e.client===t.client&&e.clock===t.clock,l_=(e,t)=>new i_(e,t),c_=e=>{for(const[t,n]of e.doc.share.entries())if(n===e)return t;throw pE()},d_=(e,t)=>{for(;null!==t;){if(t.parent===e)return!0;t=t.parent._item}return!1};class u_{constructor(e,t,n,r=0){this.type=e,this.tname=t,this.item=n,this.assoc=r}}const h_=e=>{const t={};return e.type&&(t.type=e.type),e.tname&&(t.tname=e.tname),e.item&&(t.item=e.item),null!=e.assoc&&(t.assoc=e.assoc),t},f_=e=>new u_(null==e.type?null:l_(e.type.client,e.type.clock),e.tname??null,null==e.item?null:l_(e.item.client,e.item.clock),null==e.assoc?0:e.assoc);class m_{constructor(e,t,n=0){this.type=e,this.index=t,this.assoc=n}}const p_=(e,t,n)=>{let r=null,o=null;return null===e._item?o=c_(e):r=l_(e._item.id.client,e._item.id.clock),new u_(r,o,t,n)},g_=(e,t,n=!0)=>{const r=t.store,o=e.item,s=e.type,i=e.tname,a=e.assoc;let l=null,c=0;if(null!==o){if(w_(r,o.client)<=o.clock)return null;const e=n?pA(r,o):((e,t)=>{const n=C_(e,t);return{item:n,diff:t.clock-n.id.clock}})(r,o),t=e.item;if(!(t instanceof vA))return null;if(l=t.parent,null===l._item||!l._item.deleted){c=t.deleted||!t.countable?0:e.diff+(a>=0?0:1);let n=t.left;for(;null!==n;)!n.deleted&&n.countable&&(c+=n.length),n=n.left}}else{if(null!==i)l=t.get(i);else{if(null===s)throw pE();{if(w_(r,s.client)<=s.clock)return null;const{item:e}=n?pA(r,s):{item:C_(r,s)};if(!(e instanceof vA&&e.content instanceof mA))return null;l=e.content.type}}c=a>=0?l._length:0}return((e,t,n=0)=>new m_(e,t,n))(l,c,e.assoc)},y_=(e,t)=>void 0===t?!e.deleted:t.sv.has(e.id.client)&&(t.sv.get(e.id.client)||0)>e.id.clock&&!Aj(t.ds,e.id),b_=(e,t)=>{const n=xN(e.meta,b_,vN),r=e.doc.store;n.has(t)||(t.sv.forEach(((t,n)=>{t<w_(r,n)&&E_(e,l_(n,t))})),Ij(e,t.ds,(e=>{})),n.add(t))};class x_{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const v_=e=>{const t=new Map;return e.clients.forEach(((e,n)=>{const r=e[e.length-1];t.set(n,r.id.clock+r.length)})),t},w_=(e,t)=>{const n=e.clients.get(t);if(void 0===n)return 0;const r=n[n.length-1];return r.id.clock+r.length},k_=(e,t)=>{let n=e.clients.get(t.id.client);if(void 0===n)n=[],e.clients.set(t.id.client,n);else{const e=n[n.length-1];if(e.id.clock+e.length!==t.id.clock)throw pE()}n.push(t)},S_=(e,t)=>{let n=0,r=e.length-1,o=e[r],s=o.id.clock;if(s===t)return r;let i=jN(t/(s+o.length-1)*r);for(;n<=r;){if(o=e[i],s=o.id.clock,s<=t){if(t<s+o.length)return i;n=i+1}else r=i-1;i=jN((n+r)/2)}throw pE()},C_=(e,t)=>{const n=e.clients.get(t.client);return n[S_(n,t.clock)]},N_=(e,t,n)=>{const r=S_(t,n),o=t[r];return o.id.clock<n&&o instanceof vA?(t.splice(r+1,0,yA(e,o,n-o.id.clock)),r+1):r},E_=(e,t)=>{const n=e.doc.store.clients.get(t.client);return n[N_(e,n,t.clock)]},j_=(e,t,n)=>{const r=t.clients.get(n.client),o=S_(r,n.clock),s=r[o];return n.clock!==s.id.clock+s.length-1&&s.constructor!==KI&&r.splice(o+1,0,yA(e,s,n.clock-s.id.clock+1)),s},__=(e,t,n,r,o)=>{if(0===r)return;const s=n+r;let i,a=N_(e,t,n);do{i=t[a++],s<i.id.clock+i.length&&N_(e,t,s),o(i)}while(a<t.length&&t[a].id.clock<s)};class I_{constructor(e,t,n){this.doc=e,this.deleteSet=new _j,this.beforeState=v_(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=n,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}}const A_=(e,t)=>!(0===t.deleteSet.clients.size&&!((e,t)=>{for(const[n,r]of e)if(t(r,n))return!0;return!1})(t.afterState,((e,n)=>t.beforeState.get(n)!==e)))&&(Tj(t.deleteSet),((e,t)=>{Yj(e,t.doc.store,t.beforeState)})(e,t),Rj(e,t.deleteSet),!0),T_=(e,t,n)=>{const r=t._item;(null===r||r.id.clock<(e.beforeState.get(r.id.client)||0)&&!r.deleted)&&xN(e.changed,t,vN).add(n)},M_=(e,t)=>{let n=e[t],r=e[t-1],o=t;for(;o>0&&(r.deleted===n.deleted&&r.constructor===n.constructor&&r.mergeWith(n));n=r,r=e[--o-1])n instanceof vA&&null!==n.parentSub&&n.parent._map.get(n.parentSub)===n&&n.parent._map.set(n.parentSub,r);const s=t-o;return s&&e.splice(t+1-s,s),s},D_=(e,t)=>{if(t<e.length){const n=e[t],r=n.doc,o=r.store,s=n.deleteSet,i=n._mergeStructs;try{Tj(s),n.afterState=v_(n.doc.store),r.emit("beforeObserverCalls",[n,r]);const e=[];n.changed.forEach(((t,r)=>e.push((()=>{null!==r._item&&r._item.deleted||r._callObserver(n,t)})))),e.push((()=>{n.changedParentTypes.forEach(((e,t)=>{t._dEH.l.length>0&&(null===t._item||!t._item.deleted)&&((e=e.filter((e=>null===e.target._item||!e.target._item.deleted))).forEach((e=>{e.currentTarget=t,e._path=null})),e.sort(((e,t)=>e.path.length-t.path.length)),s_(t._dEH,e,n))}))})),e.push((()=>r.emit("afterTransaction",[n,r]))),KE(e,[]),n._needFormattingCleanup&&FI(n)}finally{r.gc&&((e,t,n)=>{for(const[r,o]of e.clients.entries()){const e=t.clients.get(r);for(let r=o.length-1;r>=0;r--){const s=o[r],i=s.clock+s.len;for(let r=S_(e,s.clock),o=e[r];r<e.length&&o.id.clock<i;o=e[++r]){const o=e[r];if(s.clock+s.len<=o.id.clock)break;o instanceof vA&&o.deleted&&!o.keep&&n(o)&&o.gc(t,!1)}}}})(s,o,r.gcFilter),((e,t)=>{e.clients.forEach(((e,n)=>{const r=t.clients.get(n);for(let t=e.length-1;t>=0;t--){const n=e[t];for(let e=IN(r.length-1,1+S_(r,n.clock+n.len-1)),t=r[e];e>0&&t.id.clock>=n.clock;t=r[e])e-=1+M_(r,e)}}))})(s,o),n.afterState.forEach(((e,t)=>{const r=n.beforeState.get(t)||0;if(r!==e){const e=o.clients.get(t),n=AN(S_(e,r),1);for(let t=e.length-1;t>=n;)t-=1+M_(e,t)}}));for(let e=i.length-1;e>=0;e--){const{client:t,clock:n}=i[e].id,r=o.clients.get(t),s=S_(r,n);s+1<r.length&&M_(r,s+1)>1||s>0&&M_(r,s)}if(n.local||n.afterState.get(r.clientID)===n.beforeState.get(r.clientID)||(((...e)=>{console.log(...kj(e)),Cj.forEach((t=>t.print(e)))})(xj,hj,"[yjs] ",fj,yj,"Changed the client-id because another client seems to be using it."),r.clientID=Fj()),r.emit("afterTransactionCleanup",[n,r]),r._observers.has("update")){const e=new Wj;A_(e,n)&&r.emit("update",[e.toUint8Array(),n.origin,r,n])}if(r._observers.has("updateV2")){const e=new qj;A_(e,n)&&r.emit("updateV2",[e.toUint8Array(),n.origin,r,n])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=n;(a.size>0||c.size>0||l.size>0)&&(a.forEach((e=>{e.clientID=r.clientID,null==e.collectionid&&(e.collectionid=r.collectionid),r.subdocs.add(e)})),c.forEach((e=>r.subdocs.delete(e))),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,n]),c.forEach((e=>e.destroy()))),e.length<=t+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,e])):D_(e,t+1)}}},O_=(e,t,n=null,r=!0)=>{const o=e._transactionCleanups;let s=!1,i=null;null===e._transaction&&(s=!0,e._transaction=new I_(e,n,r),o.push(e._transaction),1===o.length&&e.emit("beforeAllTransactions",[e]),e.emit("beforeTransaction",[e._transaction,e]));try{i=t(e._transaction)}finally{if(s){const t=e._transaction===o[0];e._transaction=null,t&&D_(o,0)}}return i};class R_{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const P_=(e,t,n)=>{Ij(e,n.deletions,(n=>{n instanceof vA&&t.scope.some((t=>t===e.doc||d_(t,n)))&&gA(n,!1)}))},L_=(e,t,n)=>{let r=null;const o=e.doc,s=e.scope;O_(o,(n=>{for(;t.length>0&&null===e.currStackItem;){const r=o.store,i=t.pop(),a=new Set,l=[];let c=!1;Ij(n,i.insertions,(e=>{if(e instanceof vA){if(null!==e.redone){let{item:t,diff:o}=pA(r,e.id);o>0&&(t=E_(n,l_(t.id.client,t.id.clock+o))),e=t}!e.deleted&&s.some((t=>t===n.doc||d_(t,e)))&&l.push(e)}})),Ij(n,i.deletions,(e=>{e instanceof vA&&s.some((t=>t===n.doc||d_(t,e)))&&!Aj(i.insertions,e.id)&&a.add(e)})),a.forEach((t=>{c=null!==xA(n,t,a,i.insertions,e.ignoreRemoteMapChanges,e)||c}));for(let t=l.length-1;t>=0;t--){const r=l[t];e.deleteFilter(r)&&(r.delete(n),c=!0)}e.currStackItem=c?i:null}n.changed.forEach(((e,t)=>{e.has(null)&&t._searchMarker&&(t._searchMarker.length=0)})),r=n}),e);const i=e.currStackItem;if(null!=i){const t=r.changedParentTypes;e.emit("stack-item-popped",[{stackItem:i,type:n,changedParentTypes:t,origin:e},e]),e.currStackItem=null}return i};class F_ extends NN{constructor(e,{captureTimeout:t=500,captureTransaction:n=e=>!0,deleteFilter:r=()=>!0,trackedOrigins:o=new Set([null]),ignoreRemoteMapChanges:s=!1,doc:i=(CN(e)?e[0].doc:e instanceof zj?e:e.doc)}={}){super(),this.scope=[],this.doc=i,this.addToScope(e),this.deleteFilter=r,o.add(this),this.trackedOrigins=o,this.captureTransaction=n,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=s,this.captureTimeout=t,this.afterTransactionHandler=e=>{if(!(this.captureTransaction(e)&&this.scope.some((t=>e.changedParentTypes.has(t)||t===this.doc))&&(this.trackedOrigins.has(e.origin)||e.origin&&this.trackedOrigins.has(e.origin.constructor))))return;const t=this.undoing,n=this.redoing,r=t?this.redoStack:this.undoStack;t?this.stopCapturing():n||this.clear(!1,!0);const o=new _j;e.afterState.forEach(((t,n)=>{const r=e.beforeState.get(n)||0,s=t-r;s>0&&Dj(o,n,r,s)}));const s=PE();let i=!1;if(this.lastChange>0&&s-this.lastChange<this.captureTimeout&&r.length>0&&!t&&!n){const t=r[r.length-1];t.deletions=Mj([t.deletions,e.deleteSet]),t.insertions=Mj([t.insertions,o])}else r.push(new R_(e.deleteSet,o)),i=!0;t||n||(this.lastChange=s),Ij(e,e.deleteSet,(t=>{t instanceof vA&&this.scope.some((n=>n===e.doc||d_(n,t)))&&gA(t,!0)}));const a=[{stackItem:r[r.length-1],origin:e.origin,type:t?"redo":"undo",changedParentTypes:e.changedParentTypes},this];i?this.emit("stack-item-added",a):this.emit("stack-item-updated",a)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",(()=>{this.destroy()}))}addToScope(e){const t=new Set(this.scope);(e=CN(e)?e:[e]).forEach((e=>{t.has(e)||(t.add(e),(e instanceof sI?e.doc!==this.doc:e!==this.doc)&&Sj("[yjs#509] Not same Y.Doc"),this.scope.push(e))}))}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact((n=>{e&&(this.undoStack.forEach((e=>P_(n,this,e))),this.undoStack=[]),t&&(this.redoStack.forEach((e=>P_(n,this,e))),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])}))}stopCapturing(){this.lastChange=0}undo(){let e;this.undoing=!0;try{e=L_(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){let e;this.redoing=!0;try{e=L_(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}class z_{constructor(e,t){this.gen=function*(e){const t=kE(e.restDecoder);for(let n=0;n<t;n++){const t=kE(e.restDecoder),n=e.readClient();let r=kE(e.restDecoder);for(let o=0;o<t;o++){const t=e.readInfo();if(10===t){const t=kE(e.restDecoder);yield new SA(l_(n,r),t),r+=t}else if(31&t){const o=!(192&t),s=new vA(l_(n,r),null,(t&ON)===ON?e.readLeftID():null,null,(t&DN)===DN?e.readRightID():null,o?e.readParentInfo()?e.readString():e.readLeftID():null,!o||32&~t?null:e.readString(),wA(e,t));yield s,r+=s.length}else{const t=e.readLen();yield new KI(l_(n,r),t),r+=t}}}}(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do{this.curr=this.gen.next().value||null}while(this.filterSkips&&null!==this.curr&&this.curr.constructor===SA);return this.curr}}class B_{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const U_=e=>V_(e,Uj,Wj),$_=(e,t)=>{if(e.constructor===KI){const{client:n,clock:r}=e.id;return new KI(l_(n,r+t),e.length-t)}if(e.constructor===SA){const{client:n,clock:r}=e.id;return new SA(l_(n,r+t),e.length-t)}{const n=e,{client:r,clock:o}=n.id;return new vA(l_(r,o+t),null,l_(r,o+t-1),null,n.rightOrigin,n.parent,n.parentSub,n.content.splice(t))}},V_=(e,t=Vj,n=qj)=>{if(1===e.length)return e[0];const r=e.map((e=>new t(xE(e))));let o=r.map((e=>new z_(e,!0))),s=null;const i=new n,a=new B_(i);for(;o=o.filter((e=>null!==e.curr)),o.sort(((e,t)=>{if(e.curr.id.client===t.curr.id.client){const n=e.curr.id.clock-t.curr.id.clock;return 0===n?e.curr.constructor===t.curr.constructor?0:e.curr.constructor===SA?1:-1:n}return t.curr.id.client-e.curr.id.client})),0!==o.length;){const e=o[0],t=e.curr.id.client;if(null!==s){let n=e.curr,r=!1;for(;null!==n&&n.id.clock+n.length<=s.struct.id.clock+s.struct.length&&n.id.client>=s.struct.id.client;)n=e.next(),r=!0;if(null===n||n.id.client!==t||r&&n.id.clock>s.struct.id.clock+s.struct.length)continue;if(t!==s.struct.id.client)G_(a,s.struct,s.offset),s={struct:n,offset:0},e.next();else if(s.struct.id.clock+s.struct.length<n.id.clock)if(s.struct.constructor===SA)s.struct.length=n.id.clock+n.length-s.struct.id.clock;else{G_(a,s.struct,s.offset);const e=n.id.clock-s.struct.id.clock-s.struct.length;s={struct:new SA(l_(t,s.struct.id.clock+s.struct.length),e),offset:0}}else{const t=s.struct.id.clock+s.struct.length-n.id.clock;t>0&&(s.struct.constructor===SA?s.struct.length-=t:n=$_(n,t)),s.struct.mergeWith(n)||(G_(a,s.struct,s.offset),s={struct:n,offset:0},e.next())}}else s={struct:e.curr,offset:0},e.next();for(let n=e.curr;null!==n&&n.id.client===t&&n.id.clock===s.struct.id.clock+s.struct.length&&n.constructor!==SA;n=e.next())G_(a,s.struct,s.offset),s={struct:n,offset:0}}null!==s&&(G_(a,s.struct,s.offset),s=null),q_(a);const l=r.map((e=>Pj(e))),c=Mj(l);return Rj(i,c),i.toUint8Array()},H_=(e,t,n=Vj,r=qj)=>{const o=Zj(t),s=new r,i=new B_(s),a=new n(xE(e)),l=new z_(a,!1);for(;l.curr;){const e=l.curr,t=e.id.client,n=o.get(t)||0;if(l.curr.constructor!==SA)if(e.id.clock+e.length>n)for(G_(i,e,AN(n-e.id.clock,0)),l.next();l.curr&&l.curr.id.client===t;)G_(i,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===t&&l.curr.id.clock+l.curr.length<=n;)l.next();else l.next()}q_(i);const c=Pj(a);return Rj(s,c),s.toUint8Array()},W_=e=>{e.written>0&&(e.clientStructs.push({written:e.written,restEncoder:YN(e.encoder.restEncoder)}),e.encoder.restEncoder=GN(),e.written=0)},G_=(e,t,n)=>{e.written>0&&e.currClient!==t.id.client&&W_(e),0===e.written&&(e.currClient=t.id.client,e.encoder.writeClient(t.id.client),XN(e.encoder.restEncoder,t.id.clock+n)),t.write(e.encoder,n),e.written++},q_=e=>{W_(e);const t=e.encoder.restEncoder;XN(t,e.clientStructs.length);for(let n=0;n<e.clientStructs.length;n++){const r=e.clientStructs[n];XN(t,r.written),nE(t,r.restEncoder)}},Y_=e=>((e,t,n,r)=>{const o=new n(xE(e)),s=new z_(o,!1),i=new r,a=new B_(i);for(let c=s.curr;null!==c;c=s.next())G_(a,t(c),0);q_(a);const l=Pj(o);return Rj(i,l),i.toUint8Array()})(e,JE,Vj,Wj),K_="You must not compute changes after the event-handler fired.";class J_{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=X_(this.currentTarget,this.target))}deletes(e){return Aj(this.transaction.deleteSet,e.id)}get keys(){if(null===this._keys){if(0===this.transaction.doc._transactionCleanups.length)throw fE(K_);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach((n=>{if(null!==n){const r=t._map.get(n);let o,s;if(this.adds(r)){let e=r.left;for(;null!==e&&this.adds(e);)e=e.left;if(this.deletes(r)){if(null===e||!this.deletes(e))return;o="delete",s=wN(e.content.getContent())}else null!==e&&this.deletes(e)?(o="update",s=wN(e.content.getContent())):(o="add",s=void 0)}else{if(!this.deletes(r))return;o="delete",s=wN(r.content.getContent())}e.set(n,{action:o,oldValue:s})}})),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(null===e){if(0===this.transaction.doc._transactionCleanups.length)throw fE(K_);const t=this.target,n=vN(),r=vN(),o=[];e={added:n,deleted:r,delta:o,keys:this.keys};if(this.transaction.changed.get(t).has(null)){let e=null;const s=()=>{e&&o.push(e)};for(let o=t._start;null!==o;o=o.right)o.deleted?this.deletes(o)&&!this.adds(o)&&(null!==e&&void 0!==e.delete||(s(),e={delete:0}),e.delete+=o.length,r.add(o)):this.adds(o)?(null!==e&&void 0!==e.insert||(s(),e={insert:[]}),e.insert=e.insert.concat(o.content.getContent()),n.add(o)):(null!==e&&void 0!==e.retain||(s(),e={retain:0}),e.retain+=o.length);null!==e&&void 0===e.retain&&s()}this._changes=e}return e}}const X_=(e,t)=>{const n=[];for(;null!==t._item&&t!==e;){if(null!==t._item.parentSub)n.unshift(t._item.parentSub);else{let e=0,r=t._item.parent._start;for(;r!==t._item&&null!==r;)!r.deleted&&r.countable&&(e+=r.length),r=r.right;n.unshift(e)}t=t._item.parent}return n},Z_=()=>{Sj("Invalid access: Add Yjs type to a document before reading data.")};let Q_=0;class eI{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=Q_++}}const tI=(e,t,n)=>{e.p.marker=!1,e.p=t,t.marker=!0,e.index=n,e.timestamp=Q_++},nI=(e,t)=>{if(null===e._start||0===t||null===e._searchMarker)return null;const n=0===e._searchMarker.length?null:e._searchMarker.reduce(((e,n)=>_N(t-e.index)<_N(t-n.index)?e:n));let r=e._start,o=0;for(null!==n&&(r=n.p,o=n.index,(e=>{e.timestamp=Q_++})(n));null!==r.right&&o<t;){if(!r.deleted&&r.countable){if(t<o+r.length)break;o+=r.length}r=r.right}for(;null!==r.left&&o>t;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);for(;null!==r.left&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(o-=r.length);return null!==n&&_N(n.index-o)<r.parent.length/80?(tI(n,r,o),n):((e,t,n)=>{if(e.length>=80){const r=e.reduce(((e,t)=>e.timestamp<t.timestamp?e:t));return tI(r,t,n),r}{const r=new eI(t,n);return e.push(r),r}})(e._searchMarker,r,o)},rI=(e,t,n)=>{for(let r=e.length-1;r>=0;r--){const o=e[r];if(n>0){let t=o.p;for(t.marker=!1;t&&(t.deleted||!t.countable);)t=t.left,t&&!t.deleted&&t.countable&&(o.index-=t.length);if(null===t||!0===t.marker){e.splice(r,1);continue}o.p=t,t.marker=!0}(t<o.index||n>0&&t===o.index)&&(o.index=AN(t,o.index+n))}},oI=(e,t,n)=>{const r=e,o=t.changedParentTypes;for(;xN(o,e,(()=>[])).push(n),null!==e._item;)e=e._item.parent;s_(r._eH,n,t)};class sI{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=n_(),this._dEH=n_(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw mE()}clone(){throw mE()}_write(e){}get _first(){let e=this._start;for(;null!==e&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){r_(this._eH,e)}observeDeep(e){r_(this._dEH,e)}unobserve(e){o_(this._eH,e)}unobserveDeep(e){o_(this._dEH,e)}toJSON(){}}const iI=(e,t,n)=>{e.doc??Z_(),t<0&&(t=e._length+t),n<0&&(n=e._length+n);let r=n-t;const o=[];let s=e._start;for(;null!==s&&r>0;){if(s.countable&&!s.deleted){const e=s.content.getContent();if(e.length<=t)t-=e.length;else{for(let n=t;n<e.length&&r>0;n++)o.push(e[n]),r--;t=0}}s=s.right}return o},aI=e=>{e.doc??Z_();const t=[];let n=e._start;for(;null!==n;){if(n.countable&&!n.deleted){const e=n.content.getContent();for(let n=0;n<e.length;n++)t.push(e[n])}n=n.right}return t},lI=(e,t)=>{let n=0,r=e._start;for(e.doc??Z_();null!==r;){if(r.countable&&!r.deleted){const o=r.content.getContent();for(let r=0;r<o.length;r++)t(o[r],n++,e)}r=r.right}},cI=(e,t)=>{const n=[];return lI(e,((r,o)=>{n.push(t(r,o,e))})),n},dI=e=>{let t=e._start,n=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(null===n){for(;null!==t&&t.deleted;)t=t.right;if(null===t)return{done:!0,value:void 0};n=t.content.getContent(),r=0,t=t.right}const e=n[r++];return n.length<=r&&(n=null),{done:!1,value:e}}}},uI=(e,t)=>{e.doc??Z_();const n=nI(e,t);let r=e._start;for(null!==n&&(r=n.p,t-=n.index);null!==r;r=r.right)if(!r.deleted&&r.countable){if(t<r.length)return r.content.getContent()[t];t-=r.length}},hI=(e,t,n,r)=>{let o=n;const s=e.doc,i=s.clientID,a=s.store,l=null===n?t._start:n.right;let c=[];const d=()=>{c.length>0&&(o=new vA(l_(i,w_(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new oA(c)),o.integrate(e,0),c=[])};r.forEach((n=>{if(null===n)c.push(n);else switch(n.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(n);break;default:switch(d(),n.constructor){case Uint8Array:case ArrayBuffer:o=new vA(l_(i,w_(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new JI(new Uint8Array(n))),o.integrate(e,0);break;case zj:o=new vA(l_(i,w_(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new QI(n)),o.integrate(e,0);break;default:if(!(n instanceof sI))throw new Error("Unexpected content type in insert operation");o=new vA(l_(i,w_(a,i)),o,o&&o.lastId,l,l&&l.id,t,null,new mA(n)),o.integrate(e,0)}}})),d()},fI=()=>fE("Length exceeded!"),mI=(e,t,n,r)=>{if(n>t._length)throw fI();if(0===n)return t._searchMarker&&rI(t._searchMarker,n,r.length),hI(e,t,null,r);const o=n,s=nI(t,n);let i=t._start;for(null!==s&&(i=s.p,0===(n-=s.index)&&(i=i.prev,n+=i&&i.countable&&!i.deleted?i.length:0));null!==i;i=i.right)if(!i.deleted&&i.countable){if(n<=i.length){n<i.length&&E_(e,l_(i.id.client,i.id.clock+n));break}n-=i.length}return t._searchMarker&&rI(t._searchMarker,o,r.length),hI(e,t,i,r)},pI=(e,t,n,r)=>{if(0===r)return;const o=n,s=r,i=nI(t,n);let a=t._start;for(null!==i&&(a=i.p,n-=i.index);null!==a&&n>0;a=a.right)!a.deleted&&a.countable&&(n<a.length&&E_(e,l_(a.id.client,a.id.clock+n)),n-=a.length);for(;r>0&&null!==a;)a.deleted||(r<a.length&&E_(e,l_(a.id.client,a.id.clock+r)),a.delete(e),r-=a.length),a=a.right;if(r>0)throw fI();t._searchMarker&&rI(t._searchMarker,o,-s+r)},gI=(e,t,n)=>{const r=t._map.get(n);void 0!==r&&r.delete(e)},yI=(e,t,n,r)=>{const o=t._map.get(n)||null,s=e.doc,i=s.clientID;let a;if(null==r)a=new oA([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new oA([r]);break;case Uint8Array:a=new JI(r);break;case zj:a=new QI(r);break;default:if(!(r instanceof sI))throw new Error("Unexpected content type");a=new mA(r)}new vA(l_(i,w_(s.store,i)),o,o&&o.lastId,null,null,t,n,a).integrate(e,0)},bI=(e,t)=>{e.doc??Z_();const n=e._map.get(t);return void 0===n||n.deleted?void 0:n.content.getContent()[n.length-1]},xI=e=>{const t={};return e.doc??Z_(),e._map.forEach(((e,n)=>{e.deleted||(t[n]=e.content.getContent()[e.length-1])})),t},vI=(e,t)=>{e.doc??Z_();const n=e._map.get(t);return void 0!==n&&!n.deleted},wI=e=>{return e.doc??Z_(),t=e._map.entries(),n=e=>!e[1].deleted,Nj((()=>{let e;do{e=t.next()}while(!e.done&&!n(e.value));return e}));var t,n};class kI extends J_{}class SI extends sI{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new SI;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new SI}clone(){const e=new SI;return e.insert(0,this.toArray().map((e=>e instanceof sI?e.clone():e))),e}get length(){return this.doc??Z_(),this._length}_callObserver(e,t){super._callObserver(e,t),oI(this,e,new kI(this,e))}insert(e,t){null!==this.doc?O_(this.doc,(n=>{mI(n,this,e,t)})):this._prelimContent.splice(e,0,...t)}push(e){null!==this.doc?O_(this.doc,(t=>{((e,t,n)=>{let r=(t._searchMarker||[]).reduce(((e,t)=>t.index>e.index?t:e),{index:0,p:t._start}).p;if(r)for(;r.right;)r=r.right;hI(e,t,r,n)})(t,this,e)})):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){null!==this.doc?O_(this.doc,(n=>{pI(n,this,e,t)})):this._prelimContent.splice(e,t)}get(e){return uI(this,e)}toArray(){return aI(this)}slice(e=0,t=this.length){return iI(this,e,t)}toJSON(){return this.map((e=>e instanceof sI?e.toJSON():e))}map(e){return cI(this,e)}forEach(e){lI(this,e)}[Symbol.iterator](){return dI(this)}_write(e){e.writeTypeRef(aA)}}class CI extends J_{constructor(e,t,n){super(e,t),this.keysChanged=n}}class NI extends sI{constructor(e){super(),this._prelimContent=null,this._prelimContent=void 0===e?new Map:new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach(((e,t)=>{this.set(t,e)})),this._prelimContent=null}_copy(){return new NI}clone(){const e=new NI;return this.forEach(((t,n)=>{e.set(n,t instanceof sI?t.clone():t)})),e}_callObserver(e,t){oI(this,e,new CI(this,e,t))}toJSON(){this.doc??Z_();const e={};return this._map.forEach(((t,n)=>{if(!t.deleted){const r=t.content.getContent()[t.length-1];e[n]=r instanceof sI?r.toJSON():r}})),e}get size(){return[...wI(this)].length}keys(){return Ej(wI(this),(e=>e[0]))}values(){return Ej(wI(this),(e=>e[1].content.getContent()[e[1].length-1]))}entries(){return Ej(wI(this),(e=>[e[0],e[1].content.getContent()[e[1].length-1]]))}forEach(e){this.doc??Z_(),this._map.forEach(((t,n)=>{t.deleted||e(t.content.getContent()[t.length-1],n,this)}))}[Symbol.iterator](){return this.entries()}delete(e){null!==this.doc?O_(this.doc,(t=>{gI(t,this,e)})):this._prelimContent.delete(e)}set(e,t){return null!==this.doc?O_(this.doc,(n=>{yI(n,this,e,t)})):this._prelimContent.set(e,t),t}get(e){return bI(this,e)}has(e){return vI(this,e)}clear(){null!==this.doc?O_(this.doc,(e=>{this.forEach((function(t,n,r){gI(e,r,n)}))})):this._prelimContent.clear()}_write(e){e.writeTypeRef(lA)}}const EI=(e,t)=>e===t||"object"==typeof e&&"object"==typeof t&&e&&t&&((e,t)=>e===t||WE(e)===WE(t)&&((e,t)=>{for(const n in e)if(!t(e[n],n))return!1;return!0})(e,((e,n)=>(void 0!==e||GE(t,n))&&t[n]===e)))(e,t);class jI{constructor(e,t,n,r){this.left=e,this.right=t,this.index=n,this.currentAttributes=r}forward(){if(null===this.right&&pE(),this.right.content.constructor===tA)this.right.deleted||TI(this.currentAttributes,this.right.content);else this.right.deleted||(this.index+=this.right.length);this.left=this.right,this.right=this.right.right}}const _I=(e,t,n)=>{for(;null!==t.right&&n>0;){if(t.right.content.constructor===tA)t.right.deleted||TI(t.currentAttributes,t.right.content);else t.right.deleted||(n<t.right.length&&E_(e,l_(t.right.id.client,t.right.id.clock+n)),t.index+=t.right.length,n-=t.right.length);t.left=t.right,t.right=t.right.right}return t},II=(e,t,n,r)=>{const o=new Map,s=r?nI(t,n):null;if(s){const t=new jI(s.p.left,s.p,s.index,o);return _I(e,t,n-s.index)}{const r=new jI(null,t._start,0,o);return _I(e,r,n)}},AI=(e,t,n,r)=>{for(;null!==n.right&&(!0===n.right.deleted||n.right.content.constructor===tA&&EI(r.get(n.right.content.key),n.right.content.value));)n.right.deleted||r.delete(n.right.content.key),n.forward();const o=e.doc,s=o.clientID;r.forEach(((r,i)=>{const a=n.left,l=n.right,c=new vA(l_(s,w_(o.store,s)),a,a&&a.lastId,l,l&&l.id,t,null,new tA(i,r));c.integrate(e,0),n.right=c,n.forward()}))},TI=(e,t)=>{const{key:n,value:r}=t;null===r?e.delete(n):e.set(n,r)},MI=(e,t)=>{for(;null!==e.right&&(e.right.deleted||e.right.content.constructor===tA&&EI(t[e.right.content.key]??null,e.right.content.value));)e.forward()},DI=(e,t,n,r)=>{const o=e.doc,s=o.clientID,i=new Map;for(const a in r){const l=r[a],c=n.currentAttributes.get(a)??null;if(!EI(c,l)){i.set(a,c);const{left:r,right:d}=n;n.right=new vA(l_(s,w_(o.store,s)),r,r&&r.lastId,d,d&&d.id,t,null,new tA(a,l)),n.right.integrate(e,0),n.forward()}}return i},OI=(e,t,n,r,o)=>{n.currentAttributes.forEach(((e,t)=>{void 0===o[t]&&(o[t]=null)}));const s=e.doc,i=s.clientID;MI(n,o);const a=DI(e,t,n,o),l=r.constructor===String?new sA(r):r instanceof sI?new mA(r):new eA(r);let{left:c,right:d,index:u}=n;t._searchMarker&&rI(t._searchMarker,n.index,l.getLength()),d=new vA(l_(i,w_(s.store,i)),c,c&&c.lastId,d,d&&d.id,t,null,l),d.integrate(e,0),n.right=d,n.index=u,n.forward(),AI(e,t,n,a)},RI=(e,t,n,r,o)=>{const s=e.doc,i=s.clientID;MI(n,o);const a=DI(e,t,n,o);e:for(;null!==n.right&&(r>0||a.size>0&&(n.right.deleted||n.right.content.constructor===tA));){if(!n.right.deleted)switch(n.right.content.constructor){case tA:{const{key:t,value:s}=n.right.content,i=o[t];if(void 0!==i){if(EI(i,s))a.delete(t);else{if(0===r)break e;a.set(t,s)}n.right.delete(e)}else n.currentAttributes.set(t,s);break}default:r<n.right.length&&E_(e,l_(n.right.id.client,n.right.id.clock+r)),r-=n.right.length}n.forward()}if(r>0){let o="";for(;r>0;r--)o+="\n";n.right=new vA(l_(i,w_(s.store,i)),n.left,n.left&&n.left.lastId,n.right,n.right&&n.right.id,t,null,new sA(o)),n.right.integrate(e,0),n.forward()}AI(e,t,n,a)},PI=(e,t,n,r,o)=>{let s=t;const i=yN();for(;s&&(!s.countable||s.deleted);){if(!s.deleted&&s.content.constructor===tA){const e=s.content;i.set(e.key,e)}s=s.right}let a=0,l=!1;for(;t!==s;){if(n===t&&(l=!0),!t.deleted){const n=t.content;switch(n.constructor){case tA:{const{key:s,value:c}=n,d=r.get(s)??null;i.get(s)===n&&d!==c||(t.delete(e),a++,l||(o.get(s)??null)!==c||d===c||(null===d?o.delete(s):o.set(s,d))),l||t.deleted||TI(o,n);break}}}t=t.right}return a},LI=e=>{let t=0;return O_(e.doc,(n=>{let r=e._start,o=e._start,s=yN();const i=bN(s);for(;o;){if(!1===o.deleted)if(o.content.constructor===tA)TI(i,o.content);else t+=PI(n,r,o,s,i),s=bN(i),r=o;o=o.right}})),t},FI=e=>{const t=new Set,n=e.doc;for(const[r,o]of e.afterState.entries()){const s=e.beforeState.get(r)||0;o!==s&&__(e,n.store.clients.get(r),s,o,(e=>{e.deleted||e.content.constructor!==tA||e.constructor===KI||t.add(e.parent)}))}O_(n,(n=>{Ij(e,e.deleteSet,(e=>{if(e instanceof KI||!e.parent._hasFormatting||t.has(e.parent))return;const r=e.parent;e.content.constructor===tA?t.add(r):((e,t)=>{for(;t&&t.right&&(t.right.deleted||!t.right.countable);)t=t.right;const n=new Set;for(;t&&(t.deleted||!t.countable);){if(!t.deleted&&t.content.constructor===tA){const r=t.content.key;n.has(r)?t.delete(e):n.add(r)}t=t.left}})(n,e)}));for(const e of t)LI(e)}))},zI=(e,t,n)=>{const r=n,o=bN(t.currentAttributes),s=t.right;for(;n>0&&null!==t.right;){if(!1===t.right.deleted)switch(t.right.content.constructor){case mA:case eA:case sA:n<t.right.length&&E_(e,l_(t.right.id.client,t.right.id.clock+n)),n-=t.right.length,t.right.delete(e)}t.forward()}s&&PI(e,s,t.right,o,t.currentAttributes);const i=(t.left||t.right).parent;return i._searchMarker&&rI(i._searchMarker,t.index,-r+n),t};class BI extends J_{constructor(e,t,n){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,n.forEach((e=>{null===e?this.childListChanged=!0:this.keysChanged.add(e)}))}get changes(){if(null===this._changes){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(null===this._delta){const e=this.target.doc,t=[];O_(e,(e=>{const n=new Map,r=new Map;let o=this.target._start,s=null;const i={};let a="",l=0,c=0;const d=()=>{if(null!==s){let e=null;switch(s){case"delete":c>0&&(e={delete:c}),c=0;break;case"insert":("object"==typeof a||a.length>0)&&(e={insert:a},n.size>0&&(e.attributes={},n.forEach(((t,n)=>{null!==t&&(e.attributes[n]=t)})))),a="";break;case"retain":l>0&&(e={retain:l},(e=>{for(const t in e)return!1;return!0})(i)||(e.attributes=$E({},i))),l=0}e&&t.push(e),s=null}};for(;null!==o;){switch(o.content.constructor){case mA:case eA:this.adds(o)?this.deletes(o)||(d(),s="insert",a=o.content.getContent()[0],d()):this.deletes(o)?("delete"!==s&&(d(),s="delete"),c+=1):o.deleted||("retain"!==s&&(d(),s="retain"),l+=1);break;case sA:this.adds(o)?this.deletes(o)||("insert"!==s&&(d(),s="insert"),a+=o.content.str):this.deletes(o)?("delete"!==s&&(d(),s="delete"),c+=o.length):o.deleted||("retain"!==s&&(d(),s="retain"),l+=o.length);break;case tA:{const{key:t,value:a}=o.content;if(this.adds(o)){if(!this.deletes(o)){const l=n.get(t)??null;EI(l,a)?null!==a&&o.delete(e):("retain"===s&&d(),EI(a,r.get(t)??null)?delete i[t]:i[t]=a)}}else if(this.deletes(o)){r.set(t,a);const e=n.get(t)??null;EI(e,a)||("retain"===s&&d(),i[t]=e)}else if(!o.deleted){r.set(t,a);const n=i[t];void 0!==n&&(EI(n,a)?null!==n&&o.delete(e):("retain"===s&&d(),null===a?delete i[t]:i[t]=a))}o.deleted||("insert"===s&&d(),TI(n,o.content));break}}o=o.right}for(d();t.length>0;){const e=t[t.length-1];if(void 0===e.retain||void 0!==e.attributes)break;t.pop()}})),this._delta=t}return this._delta}}class UI extends sI{constructor(e){super(),this._pending=void 0!==e?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this.doc??Z_(),this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach((e=>e()))}catch(_K){console.error(_K)}this._pending=null}_copy(){return new UI}clone(){const e=new UI;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const n=new BI(this,e,t);oI(this,e,n),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){this.doc??Z_();let e="",t=this._start;for(;null!==t;)!t.deleted&&t.countable&&t.content.constructor===sA&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){null!==this.doc?O_(this.doc,(n=>{const r=new jI(null,this._start,0,new Map);for(let o=0;o<e.length;o++){const s=e[o];if(void 0!==s.insert){const i=t||"string"!=typeof s.insert||o!==e.length-1||null!==r.right||"\n"!==s.insert.slice(-1)?s.insert:s.insert.slice(0,-1);("string"!=typeof i||i.length>0)&&OI(n,this,r,i,s.attributes||{})}else void 0!==s.retain?RI(n,this,r,s.retain,s.attributes||{}):void 0!==s.delete&&zI(n,r,s.delete)}})):this._pending.push((()=>this.applyDelta(e)))}toDelta(e,t,n){this.doc??Z_();const r=[],o=new Map,s=this.doc;let i="",a=this._start;function l(){if(i.length>0){const e={};let t=!1;o.forEach(((n,r)=>{t=!0,e[r]=n}));const n={insert:i};t&&(n.attributes=e),r.push(n),i=""}}const c=()=>{for(;null!==a;){if(y_(a,e)||void 0!==t&&y_(a,t))switch(a.content.constructor){case sA:{const r=o.get("ychange");void 0===e||y_(a,e)?void 0===t||y_(a,t)?void 0!==r&&(l(),o.delete("ychange")):void 0!==r&&r.user===a.id.client&&"added"===r.type||(l(),o.set("ychange",n?n("added",a.id):{type:"added"})):void 0!==r&&r.user===a.id.client&&"removed"===r.type||(l(),o.set("ychange",n?n("removed",a.id):{type:"removed"})),i+=a.content.str;break}case mA:case eA:{l();const e={insert:a.content.getContent()[0]};if(o.size>0){const t={};e.attributes=t,o.forEach(((e,n)=>{t[n]=e}))}r.push(e);break}case tA:y_(a,e)&&(l(),TI(o,a.content))}a=a.right}l()};return e||t?O_(s,(n=>{e&&b_(n,e),t&&b_(n,t),c()}),"cleanup"):c(),r}insert(e,t,n){if(t.length<=0)return;const r=this.doc;null!==r?O_(r,(r=>{const o=II(r,this,e,!n);n||(n={},o.currentAttributes.forEach(((e,t)=>{n[t]=e}))),OI(r,this,o,t,n)})):this._pending.push((()=>this.insert(e,t,n)))}insertEmbed(e,t,n){const r=this.doc;null!==r?O_(r,(r=>{const o=II(r,this,e,!n);OI(r,this,o,t,n||{})})):this._pending.push((()=>this.insertEmbed(e,t,n||{})))}delete(e,t){if(0===t)return;const n=this.doc;null!==n?O_(n,(n=>{zI(n,II(n,this,e,!0),t)})):this._pending.push((()=>this.delete(e,t)))}format(e,t,n){if(0===t)return;const r=this.doc;null!==r?O_(r,(r=>{const o=II(r,this,e,!1);null!==o.right&&RI(r,this,o,t,n)})):this._pending.push((()=>this.format(e,t,n)))}removeAttribute(e){null!==this.doc?O_(this.doc,(t=>{gI(t,this,e)})):this._pending.push((()=>this.removeAttribute(e)))}setAttribute(e,t){null!==this.doc?O_(this.doc,(n=>{yI(n,this,e,t)})):this._pending.push((()=>this.setAttribute(e,t)))}getAttribute(e){return bI(this,e)}getAttributes(){return xI(this)}_write(e){e.writeTypeRef(cA)}}class $I{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0,e.doc??Z_()}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(null!==e&&(!this._firstCall||e.deleted||!this._filter(t)))do{if(t=e.content.type,e.deleted||t.constructor!==HI&&t.constructor!==VI||null===t._start)for(;null!==e;){const t=e.next;if(null!==t){e=t;break}e=e.parent===this._root?null:e.parent._item}else e=t._start}while(null!==e&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,null===e?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class VI extends sI{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new VI}clone(){const e=new VI;return e.insert(0,this.toArray().map((e=>e instanceof sI?e.clone():e))),e}get length(){return this.doc??Z_(),null===this._prelimContent?this._length:this._prelimContent.length}createTreeWalker(e){return new $I(this,e)}querySelector(e){e=e.toUpperCase();const t=new $I(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)).next();return t.done?null:t.value}querySelectorAll(e){return e=e.toUpperCase(),SN(new $I(this,(t=>t.nodeName&&t.nodeName.toUpperCase()===e)))}_callObserver(e,t){oI(this,e,new WI(this,t,e))}toString(){return cI(this,(e=>e.toString())).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},n){const r=e.createDocumentFragment();return void 0!==n&&n._createAssociation(r,this),lI(this,(o=>{r.insertBefore(o.toDOM(e,t,n),null)})),r}insert(e,t){null!==this.doc?O_(this.doc,(n=>{mI(n,this,e,t)})):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(null!==this.doc)O_(this.doc,(n=>{const r=e&&e instanceof sI?e._item:e;hI(n,this,r,t)}));else{const n=this._prelimContent,r=null===e?0:n.findIndex((t=>t===e))+1;if(0===r&&null!==e)throw fE("Reference item not found");n.splice(r,0,...t)}}delete(e,t=1){null!==this.doc?O_(this.doc,(n=>{pI(n,this,e,t)})):this._prelimContent.splice(e,t)}toArray(){return aI(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return uI(this,e)}slice(e=0,t=this.length){return iI(this,e,t)}forEach(e){lI(this,e)}_write(e){e.writeTypeRef(uA)}}class HI extends VI{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach(((e,t)=>{this.setAttribute(t,e)})),this._prelimAttrs=null}_copy(){return new HI(this.nodeName)}clone(){const e=new HI(this.nodeName);return((e,t)=>{for(const n in e)t(e[n],n)})(this.getAttributes(),((t,n)=>{"string"==typeof t&&e.setAttribute(n,t)})),e.insert(0,this.toArray().map((e=>e instanceof sI?e.clone():e))),e}toString(){const e=this.getAttributes(),t=[],n=[];for(const s in e)n.push(s);n.sort();const r=n.length;for(let s=0;s<r;s++){const r=n[s];t.push(r+'="'+e[r]+'"')}const o=this.nodeName.toLocaleLowerCase();return`<${o}${t.length>0?" "+t.join(" "):""}>${super.toString()}</${o}>`}removeAttribute(e){null!==this.doc?O_(this.doc,(t=>{gI(t,this,e)})):this._prelimAttrs.delete(e)}setAttribute(e,t){null!==this.doc?O_(this.doc,(n=>{yI(n,this,e,t)})):this._prelimAttrs.set(e,t)}getAttribute(e){return bI(this,e)}hasAttribute(e){return vI(this,e)}getAttributes(e){return e?((e,t)=>{const n={};return e._map.forEach(((e,r)=>{let o=e;for(;null!==o&&(!t.sv.has(o.id.client)||o.id.clock>=(t.sv.get(o.id.client)||0));)o=o.left;null!==o&&y_(o,t)&&(n[r]=o.content.getContent()[o.length-1])})),n})(this,e):xI(this)}toDOM(e=document,t={},n){const r=e.createElement(this.nodeName),o=this.getAttributes();for(const s in o){const e=o[s];"string"==typeof e&&r.setAttribute(s,e)}return lI(this,(o=>{r.appendChild(o.toDOM(e,t,n))})),void 0!==n&&n._createAssociation(r,this),r}_write(e){e.writeTypeRef(dA),e.writeKey(this.nodeName)}}class WI extends J_{constructor(e,t,n){super(e,n),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach((e=>{null===e?this.childListChanged=!0:this.attributesChanged.add(e)}))}}class GI extends NI{constructor(e){super(),this.hookName=e}_copy(){return new GI(this.hookName)}clone(){const e=new GI(this.hookName);return this.forEach(((t,n)=>{e.set(n,t)})),e}toDOM(e=document,t={},n){const r=t[this.hookName];let o;return o=void 0!==r?r.createDom(this):document.createElement(this.hookName),o.setAttribute("data-yjs-hook",this.hookName),void 0!==n&&n._createAssociation(o,this),o}_write(e){e.writeTypeRef(hA),e.writeKey(this.hookName)}}class qI extends UI{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new qI}clone(){const e=new qI;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,n){const r=e.createTextNode(this.toString());return void 0!==n&&n._createAssociation(r,this),r}toString(){return this.toDelta().map((e=>{const t=[];for(const r in e.attributes){const n=[];for(const t in e.attributes[r])n.push({key:t,value:e.attributes[r][t]});n.sort(((e,t)=>e.key<t.key?-1:1)),t.push({nodeName:r,attrs:n})}t.sort(((e,t)=>e.nodeName<t.nodeName?-1:1));let n="";for(let r=0;r<t.length;r++){const e=t[r];n+=`<${e.nodeName}`;for(let t=0;t<e.attrs.length;t++){const r=e.attrs[t];n+=` ${r.key}="${r.value}"`}n+=">"}n+=e.insert;for(let r=t.length-1;r>=0;r--)n+=`</${t[r].nodeName}>`;return n})).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(fA)}}class YI{constructor(e,t){this.id=e,this.length=t}get deleted(){throw mE()}mergeWith(e){return!1}write(e,t,n){throw mE()}integrate(e,t){throw mE()}}class KI extends YI{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),k_(e.doc.store,this)}write(e,t){e.writeInfo(0),e.writeLen(this.length-t)}getMissing(e,t){return null}}class JI{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new JI(this.content)}splice(e){throw mE()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}class XI{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new XI(this.len)}splice(e){const t=new XI(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){Dj(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const ZI=(e,t)=>new zj({guid:e,...t,shouldLoad:t.shouldLoad||t.autoLoad||!1});class QI{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),null!==e.meta&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new QI(ZI(this.doc.guid,this.opts))}splice(e){throw mE()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}class eA{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new eA(this.embed)}splice(e){throw mE()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}class tA{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new tA(this.key,this.value)}splice(e){throw mE()}mergeWith(e){return!1}integrate(e,t){const n=t.parent;n._searchMarker=null,n._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}class nA{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new nA(this.arr)}splice(e){const t=new nA(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeString(void 0===t?"undefined":JSON.stringify(t))}}getRef(){return 2}}const rA="development"===rj("node_env");class oA{constructor(e){this.arr=e,rA&&YE(e)}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new oA(this.arr)}splice(e){const t=new oA(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const n=this.arr.length;e.writeLen(n-t);for(let r=t;r<n;r++){const t=this.arr[r];e.writeAny(t)}}getRef(){return 8}}class sA{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new sA(this.str)}splice(e){const t=new sA(this.str.slice(e));this.str=this.str.slice(0,e);const n=this.str.charCodeAt(e-1);return n>=55296&&n<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(0===t?this.str:this.str.slice(t))}getRef(){return 4}}const iA=[e=>new SI,e=>new NI,e=>new UI,e=>new HI(e.readKey()),e=>new VI,e=>new GI(e.readKey()),e=>new qI],aA=0,lA=1,cA=2,dA=3,uA=4,hA=5,fA=6;class mA{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new mA(this.type._copy())}splice(e){throw mE()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;null!==t;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach((t=>{t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e)})),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;null!==t;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach((t=>{for(;null!==t;)t.gc(e,!0),t=t.left})),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const pA=(e,t)=>{let n,r=t,o=0;do{o>0&&(r=l_(r.client,r.clock+o)),n=C_(e,r),o=r.clock-n.id.clock,r=n.redone}while(null!==r&&n instanceof vA);return{item:n,diff:o}},gA=(e,t)=>{for(;null!==e&&e.keep!==t;)e.keep=t,e=e.parent._item},yA=(e,t,n)=>{const{client:r,clock:o}=t.id,s=new vA(l_(r,o+n),t,l_(r,o+n-1),t.right,t.rightOrigin,t.parent,t.parentSub,t.content.splice(n));return t.deleted&&s.markDeleted(),t.keep&&(s.keep=!0),null!==t.redone&&(s.redone=l_(t.redone.client,t.redone.clock+n)),t.right=s,null!==s.right&&(s.right.left=s),e._mergeStructs.push(s),null!==s.parentSub&&null===s.right&&s.parent._map.set(s.parentSub,s),t.length=n,s},bA=(e,t)=>((e,t)=>{for(let n=0;n<e.length;n++)if(t(e[n],n,e))return!0;return!1})(e,(e=>Aj(e.deletions,t))),xA=(e,t,n,r,o,s)=>{const i=e.doc,a=i.store,l=i.clientID,c=t.redone;if(null!==c)return E_(e,c);let d,u=t.parent._item,h=null;if(null!==u&&!0===u.deleted){if(null===u.redone&&(!n.has(u)||null===xA(e,u,n,r,o,s)))return null;for(;null!==u.redone;)u=E_(e,u.redone)}const f=null===u?t.parent:u.content.type;if(null===t.parentSub){for(h=t.left,d=t;null!==h;){let t=h;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:E_(e,t.redone);if(null!==t&&t.parent._item===u){h=t;break}h=h.left}for(;null!==d;){let t=d;for(;null!==t&&t.parent._item!==u;)t=null===t.redone?null:E_(e,t.redone);if(null!==t&&t.parent._item===u){d=t;break}d=d.right}}else if(d=null,t.right&&!o){for(h=t;null!==h&&null!==h.right&&(h.right.redone||Aj(r,h.right.id)||bA(s.undoStack,h.right.id)||bA(s.redoStack,h.right.id));)for(h=h.right;h.redone;)h=E_(e,h.redone);if(h&&null!==h.right)return null}else h=f._map.get(t.parentSub)||null;const m=w_(a,l),p=l_(l,m),g=new vA(p,h,h&&h.lastId,d,d&&d.id,f,t.parentSub,t.content.copy());return t.redone=p,gA(g,!0),g.integrate(e,0),g};class vA extends YI{constructor(e,t,n,r,o,s,i,a){super(e,a.getLength()),this.origin=n,this.left=t,this.right=r,this.rightOrigin=o,this.parent=s,this.parentSub=i,this.redone=null,this.content=a,this.info=this.content.isCountable()?2:0}set marker(e){(8&this.info)>0!==e&&(this.info^=8)}get marker(){return(8&this.info)>0}get keep(){return(1&this.info)>0}set keep(e){this.keep!==e&&(this.info^=1)}get countable(){return(2&this.info)>0}get deleted(){return(4&this.info)>0}set deleted(e){this.deleted!==e&&(this.info^=4)}markDeleted(){this.info|=4}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=w_(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=w_(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===i_&&this.id.client!==this.parent.client&&this.parent.clock>=w_(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=j_(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=E_(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===KI||this.right&&this.right.constructor===KI)this.parent=null;else if(this.parent){if(this.parent.constructor===i_){const e=C_(t,this.parent);e.constructor===KI?this.parent=null:this.parent=e.content.type}}else this.left&&this.left.constructor===vA?(this.parent=this.left.parent,this.parentSub=this.left.parentSub):this.right&&this.right.constructor===vA&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=j_(e,e.doc.store,l_(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||null!==this.right.left)||this.left&&this.left.right!==this.right){let t,n=this.left;if(null!==n)t=n.right;else if(null!==this.parentSub)for(t=this.parent._map.get(this.parentSub)||null;null!==t&&null!==t.left;)t=t.left;else t=this.parent._start;const r=new Set,o=new Set;for(;null!==t&&t!==this.right;){if(o.add(t),r.add(t),a_(this.origin,t.origin)){if(t.id.client<this.id.client)n=t,r.clear();else if(a_(this.rightOrigin,t.rightOrigin))break}else{if(null===t.origin||!o.has(C_(e.doc.store,t.origin)))break;r.has(C_(e.doc.store,t.origin))||(n=t,r.clear())}t=t.right}this.left=n}if(null!==this.left){const e=this.left.right;this.right=e,this.left.right=this}else{let e;if(null!==this.parentSub)for(e=this.parent._map.get(this.parentSub)||null;null!==e&&null!==e.left;)e=e.left;else e=this.parent._start,this.parent._start=this;this.right=e}null!==this.right?this.right.left=this:null!==this.parentSub&&(this.parent._map.set(this.parentSub,this),null!==this.left&&this.left.delete(e)),null===this.parentSub&&this.countable&&!this.deleted&&(this.parent._length+=this.length),k_(e.doc.store,this),this.content.integrate(e,this),T_(e,this.parent,this.parentSub),(null!==this.parent._item&&this.parent._item.deleted||null!==this.parentSub&&null!==this.right)&&this.delete(e)}else new KI(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;null!==e&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;null!==e&&e.deleted;)e=e.left;return e}get lastId(){return 1===this.length?this.id:l_(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&a_(e.origin,this.lastId)&&this.right===e&&a_(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&null===this.redone&&null===e.redone&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach((t=>{t.p===e&&(t.p=this,!this.deleted&&this.countable&&(t.index-=this.length))})),e.keep&&(this.keep=!0),this.right=e.right,null!==this.right&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&null===this.parentSub&&(t._length-=this.length),this.markDeleted(),Dj(e.deleteSet,this.id.client,this.id.clock,this.length),T_(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw pE();this.content.gc(e),t?((e,t,n)=>{const r=e.clients.get(t.id.client);r[S_(r,t.id.clock)]=n})(e,this,new KI(this.id,this.length)):this.content=new XI(this.length)}write(e,t){const n=t>0?l_(this.id.client,this.id.clock+t-1):this.origin,r=this.rightOrigin,o=this.parentSub,s=31&this.content.getRef()|(null===n?0:ON)|(null===r?0:DN)|(null===o?0:32);if(e.writeInfo(s),null!==n&&e.writeLeftID(n),null!==r&&e.writeRightID(r),null===n&&null===r){const t=this.parent;if(void 0!==t._item){const n=t._item;if(null===n){const n=c_(t);e.writeParentInfo(!0),e.writeString(n)}else e.writeParentInfo(!1),e.writeLeftID(n.id)}else t.constructor===String?(e.writeParentInfo(!0),e.writeString(t)):t.constructor===i_?(e.writeParentInfo(!1),e.writeLeftID(t)):pE();null!==o&&e.writeString(o)}this.content.write(e,t)}}const wA=(e,t)=>kA[31&t](e),kA=[()=>{pE()},e=>new XI(e.readLen()),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++){const t=e.readString();"undefined"===t?n.push(void 0):n.push(JSON.parse(t))}return new nA(n)},e=>new JI(e.readBuf()),e=>new sA(e.readString()),e=>new eA(e.readJSON()),e=>new tA(e.readKey(),e.readJSON()),e=>new mA(iA[e.readTypeRef()](e)),e=>{const t=e.readLen(),n=[];for(let r=0;r<t;r++)n.push(e.readAny());return new oA(n)},e=>new QI(ZI(e.readString(),e.readAny())),()=>{pE()}];class SA extends YI{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor===e.constructor&&(this.length+=e.length,!0)}integrate(e,t){pE()}write(e,t){e.writeInfo(10),XN(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const CA="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},NA="__ $YJS$ __";!0===CA[NA]&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),CA[NA]=!0;class EA{constructor(e,t){this.yanchor=e,this.yhead=t}toJSON(){return{yanchor:h_(this.yanchor),yhead:h_(this.yhead)}}static fromJSON(e){return new EA(f_(e.yanchor),f_(e.yhead))}}class jA{constructor(e,t){this.ytext=e,this.awareness=t,this.undoManager=new F_(e)}toYPos(e,t=0){return((e,t,n=0)=>{let r=e._start;if(n<0){if(0===t)return p_(e,null,n);t--}for(;null!==r;){if(!r.deleted&&r.countable){if(r.length>t)return p_(e,l_(r.id.client,r.id.clock+t),n);t-=r.length}if(null===r.right&&n<0)return p_(e,r.lastId,n);r=r.right}return p_(e,null,n)})(this.ytext,e,t)}fromYPos(e){const t=g_(f_(e),this.ytext.doc);if(null==t||t.type!==this.ytext)throw new Error("[y-codemirror] The position you want to retrieve was created by a different document");return{pos:t.index,assoc:t.assoc}}toYRange(e){const t=e.assoc,n=this.toYPos(e.anchor,t),r=this.toYPos(e.head,t);return new EA(n,r)}fromYRange(e){const t=this.fromYPos(e.yanchor),n=this.fromYPos(e.yhead);return t.pos===n.pos?Fn.cursor(n.pos,n.assoc):Fn.range(t.pos,n.pos)}}const _A=Cr.define({combine:e=>e[e.length-1]}),IA=_r.define();const AA=Bn.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(_A),this._observer=(t,n)=>{if(n.origin!==this.conf){const n=t.delta,r=[];let o=0;for(let e=0;e<n.length;e++){const t=n[e];null!=t.insert?r.push({from:o,to:o,insert:t.insert}):null!=t.delete?(r.push({from:o,to:o+t.delete,insert:""}),o+=t.delete):o+=t.retain}e.dispatch({changes:r,annotations:[IA.of(this.conf)]})}},this._ytext=this.conf.ytext,this._ytext.observe(this._observer)}update(e){if(!e.docChanged||e.transactions.length>0&&e.transactions[0].annotation(IA)===this.conf)return;const t=this.conf.ytext;t.doc.transact((()=>{let n=0;e.changes.iterChanges(((e,r,o,s,i)=>{const a=i.sliceString(0,i.length,"\n");e!==r&&t.delete(e+n,r-e),a.length>0&&t.insert(e+n,a),n+=a.length-(r-e)}))}),this.conf)}destroy(){this._ytext.unobserve(this._observer)}});class TA{constructor(e){this.undoManager=e}addTrackedOrigin(e){this.undoManager.addTrackedOrigin(e)}removeTrackedOrigin(e){this.undoManager.removeTrackedOrigin(e)}undo(){return null!=this.undoManager.undo()}redo(){return null!=this.undoManager.redo()}}const MA=Cr.define({combine:e=>e[e.length-1]});const DA=Bn.fromClass(class{constructor(e){this.view=e,this.conf=e.state.facet(MA),this._undoManager=this.conf.undoManager,this.syncConf=e.state.facet(_A),this._beforeChangeSelection=null,this._mux=(()=>{let e=!0;return(t,n)=>{if(e){e=!1;try{t()}finally{e=!0}}else void 0!==n&&n()}})(),this._onStackItemAdded=({stackItem:e,changedParentTypes:t})=>{t.has(this.syncConf.ytext)&&this._beforeChangeSelection&&!e.meta.has(this)&&e.meta.set(this,this._beforeChangeSelection)},this._onStackItemPopped=({stackItem:t})=>{const n=t.meta.get(this);if(n){const t=this.syncConf.fromYRange(n);e.dispatch(e.state.update({selection:t,effects:[zn.scrollIntoView(t)]})),this._storeSelection()}},this._storeSelection=()=>{this._beforeChangeSelection=this.syncConf.toYRange(this.view.state.selection.main)},this._undoManager.on("stack-item-added",this._onStackItemAdded),this._undoManager.on("stack-item-popped",this._onStackItemPopped),this._undoManager.addTrackedOrigin(this.syncConf)}update(e){!e.selectionSet||0!==e.transactions.length&&e.transactions[0].annotation(IA)===this.syncConf||this._storeSelection()}destroy(){this._undoManager.off("stack-item-added",this._onStackItemAdded),this._undoManager.off("stack-item-popped",this._onStackItemPopped),this._undoManager.removeTrackedOrigin(this.syncConf)}}),OA=(e,t,{undoManager:n=new F_(e)}={})=>{const r=new jA(e,t),o=[_A.of(r),AA];return!1!==n&&o.push(MA.of(new TA(n)),DA,zn.domEventHandlers({beforeinput:(e,t)=>"historyUndo"===e.inputType?(({state:e,dispatch:t})=>e.facet(MA).undo()||!0)(t):"historyRedo"===e.inputType&&(({state:e,dispatch:t})=>e.facet(MA).redo()||!0)(t)})),o},RA=new Map;const PA="undefined"==typeof BroadcastChannel?class{constructor(e){var t;this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&null!==this.onmessage&&this.onmessage({data:lj(t.newValue||"")}),t=this._onChange,BE||addEventListener("storage",t)}postMessage(e){UE.setItem(this.room,aj(new Uint8Array(e)))}close(){var e;e=this._onChange,BE||removeEventListener("storage",e)}}:BroadcastChannel,LA=e=>xN(RA,e,(()=>{const t=vN(),n=new PA(e);return n.onmessage=e=>t.forEach((t=>t(e.data,"broadcastchannel"))),{bc:n,subs:t}})),FA=(e,t,n=null)=>{const r=LA(e);r.bc.postMessage(t),r.subs.forEach((e=>e(t,n)))},zA=(e,t)=>{XN(e,0);const n=(e=>e_(e,new Hj))(t);rE(e,n)},BA=(e,t,n)=>{XN(e,1),rE(e,((e,t)=>Xj(e,t,new Wj))(t,n))},UA=(e,t,n)=>{try{((e,t,n)=>{Jj(e,t,n,Uj)})(t,vE(e),n)}catch(r){console.error("Caught error while handling a Yjs update",r)}},$A=UA,VA=(e,t,n,r)=>{const o=kE(e);switch(o){case 0:((e,t,n)=>{BA(t,n,vE(e))})(e,t,n);break;case 1:UA(e,n,r);break;case 2:$A(e,n,r);break;default:throw new Error("Unknown message type")}return o},HA=3e4;class WA extends EN{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval((()=>{const e=PE();null!==this.getLocalState()&&15e3<=e-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const t=[];this.meta.forEach(((n,r)=>{r!==this.clientID&&HA<=e-n.lastUpdated&&this.states.has(r)&&t.push(r)})),t.length>0&&GA(this,t,"timeout")}),jN(3e3)),e.on("destroy",(()=>{this.destroy()})),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,n=this.meta.get(t),r=void 0===n?0:n.clock+1,o=this.states.get(t);null===e?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:r,lastUpdated:PE()});const s=[],i=[],a=[],l=[];null===e?l.push(t):null==o?null!=e&&s.push(t):(i.push(t),XE(o,e)||a.push(t)),(s.length>0||a.length>0||l.length>0)&&this.emit("change",[{added:s,updated:a,removed:l},"local"]),this.emit("update",[{added:s,updated:i,removed:l},"local"])}setLocalStateField(e,t){const n=this.getLocalState();null!==n&&this.setLocalState({...n,[e]:t})}getStates(){return this.states}}const GA=(e,t,n)=>{const r=[];for(let o=0;o<t.length;o++){const n=t[o];if(e.states.has(n)){if(e.states.delete(n),n===e.clientID){const t=e.meta.get(n);e.meta.set(n,{clock:t.clock+1,lastUpdated:PE()})}r.push(n)}}r.length>0&&(e.emit("change",[{added:[],updated:[],removed:r},n]),e.emit("update",[{added:[],updated:[],removed:r},n]))},qA=(e,t,n=e.states)=>{const r=t.length,o=GN();XN(o,r);for(let s=0;s<r;s++){const r=t[s],i=n.get(r)||null,a=e.meta.get(r).clock;XN(o,r),XN(o,a),tE(o,JSON.stringify(i))}return YN(o)},YA=[];YA[0]=(e,t,n,r,o)=>{XN(e,0);const s=VA(t,e,n.doc,n);r&&1===s&&!n.synced&&(n.synced=!0)},YA[3]=(e,t,n,r,o)=>{XN(e,1),rE(e,qA(n.awareness,Array.from(n.awareness.getStates().keys())))},YA[1]=(e,t,n,r,o)=>{((e,t,n)=>{const r=xE(t),o=PE(),s=[],i=[],a=[],l=[],c=kE(r);for(let d=0;d<c;d++){const t=kE(r);let n=kE(r);const c=JSON.parse(CE(r)),d=e.meta.get(t),u=e.states.get(t),h=void 0===d?0:d.clock;(h<n||h===n&&null===c&&e.states.has(t))&&(null===c?t===e.clientID&&null!=e.getLocalState()?n++:e.states.delete(t):e.states.set(t,c),e.meta.set(t,{clock:n,lastUpdated:o}),void 0===d&&null!==c?s.push(t):void 0!==d&&null===c?l.push(t):null!==c&&(XE(c,u)||a.push(t),i.push(t)))}(s.length>0||a.length>0||l.length>0)&&e.emit("change",[{added:s,updated:a,removed:l},n]),(s.length>0||i.length>0||l.length>0)&&e.emit("update",[{added:s,updated:i,removed:l},n])})(n.awareness,vE(t),n)},YA[2]=(e,t,n,r,o)=>{((e,t,n)=>{0===kE(e)&&n(t,CE(e))})(t,n.doc,((e,t)=>KA(n,t)))};const KA=(e,t)=>console.warn(`Permission denied to access ${e.url}.\n${t}`),JA=(e,t,n)=>{const r=xE(t),o=GN(),s=kE(r),i=e.messageHandlers[s];return i?i(o,r,e,n,s):console.error("Unable to compute message"),o},XA=(e,t,n)=>{t===e.ws&&(e.emit("connection-close",[n,e]),e.ws=null,t.close(),e.wsconnecting=!1,e.wsconnected?(e.wsconnected=!1,e.synced=!1,GA(e.awareness,Array.from(e.awareness.getStates().keys()).filter((t=>t!==e.doc.clientID)),e),e.emit("status",[{status:"disconnected"}])):e.wsUnsuccessfulReconnects++,setTimeout(ZA,IN(100*TN(2,e.wsUnsuccessfulReconnects),e.maxBackoffTime),e))},ZA=e=>{if(e.shouldConnect&&null===e.ws){const t=new e._WS(e.url,e.protocols);t.binaryType="arraybuffer",e.ws=t,e.wsconnecting=!0,e.wsconnected=!1,e.synced=!1,t.onmessage=n=>{e.wsLastMessageReceived=PE();const r=JA(e,new Uint8Array(n.data),!0);qN(r)>1&&t.send(YN(r))},t.onerror=t=>{e.emit("connection-error",[t,e])},t.onclose=n=>{XA(e,t,n)},t.onopen=()=>{e.wsLastMessageReceived=PE(),e.wsconnecting=!1,e.wsconnected=!0,e.wsUnsuccessfulReconnects=0,e.emit("status",[{status:"connected"}]);const n=GN();if(XN(n,0),zA(n,e.doc),t.send(YN(n)),null!==e.awareness.getLocalState()){const n=GN();XN(n,1),rE(n,qA(e.awareness,[e.doc.clientID])),t.send(YN(n))}},e.emit("status",[{status:"connecting"}])}},QA=(e,t)=>{const n=e.ws;e.wsconnected&&n&&n.readyState===n.OPEN&&n.send(t),e.bcconnected&&FA(e.bcChannel,t,e)};class eT extends NN{constructor(e,t,n,{connect:r=!0,awareness:o=new WA(n),params:s={},protocols:i=[],WebSocketPolyfill:a=WebSocket,resyncInterval:l=-1,maxBackoffTime:c=2500,disableBc:d=!1}={}){for(super();"/"===e[e.length-1];)e=e.slice(0,e.length-1);this.serverUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=c,this.params=s,this.protocols=i,this.roomname=t,this.doc=n,this._WS=a,this.awareness=o,this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=d,this.wsUnsuccessfulReconnects=0,this.messageHandlers=YA.slice(),this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=r,this._resyncInterval=0,l>0&&(this._resyncInterval=setInterval((()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const e=GN();XN(e,0),zA(e,n),this.ws.send(YN(e))}}),l)),this._bcSubscriber=(e,t)=>{if(t!==this){const t=JA(this,new Uint8Array(e),!1);qN(t)>1&&FA(this.bcChannel,YN(t),this)}},this._updateHandler=(e,t)=>{if(t!==this){const t=GN();XN(t,0),((e,t)=>{XN(e,2),rE(e,t)})(t,e),QA(this,YN(t))}},this.doc.on("update",this._updateHandler),this._awarenessUpdateHandler=({added:e,updated:t,removed:n},r)=>{const s=e.concat(t).concat(n),i=GN();XN(i,1),rE(i,qA(o,s)),QA(this,YN(i))},this._exitHandler=()=>{GA(this.awareness,[n.clientID],"app closed")},QE&&"undefined"!=typeof process&&process.on("exit",this._exitHandler),o.on("update",this._awarenessUpdateHandler),this._checkInterval=setInterval((()=>{this.wsconnected&&3e4<PE()-this.wsLastMessageReceived&&XA(this,this.ws,null)}),3e3),r&&this.connect()}get url(){const e=((e,t)=>{const n=[];for(const r in e)n.push(t(e[r],r));return n})(this.params,((e,t)=>`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)).join("&");return this.serverUrl+"/"+this.roomname+(0===e.length?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,this.emit("synced",[e]),this.emit("sync",[e]))}destroy(){0!==this._resyncInterval&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),QE&&"undefined"!=typeof process&&process.off("exit",this._exitHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.doc.off("update",this._updateHandler),super.destroy()}connectBc(){if(this.disableBc)return;var e,t;this.bcconnected||(e=this.bcChannel,t=this._bcSubscriber,LA(e).subs.add(t),this.bcconnected=!0);const n=GN();XN(n,0),zA(n,this.doc),FA(this.bcChannel,YN(n),this);const r=GN();XN(r,0),BA(r,this.doc),FA(this.bcChannel,YN(r),this);const o=GN();XN(o,3),FA(this.bcChannel,YN(o),this);const s=GN();XN(s,1),rE(s,qA(this.awareness,[this.doc.clientID])),FA(this.bcChannel,YN(s),this)}disconnectBc(){const e=GN();XN(e,1),rE(e,qA(this.awareness,[this.doc.clientID],new Map)),QA(this,YN(e)),this.bcconnected&&(((e,t)=>{const n=LA(e),r=n.subs.delete(t);r&&0===n.subs.size&&(n.bc.close(),RA.delete(e))})(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),null!==this.ws&&XA(this,this.ws,null)}connect(){this.shouldConnect=!0,this.wsconnected||null!==this.ws||(ZA(this),this.connectBc())}}const tT="code",nT="language";class rT{constructor(){this.providers=new Map,this.listenForConnectionChanges()}static getInstance(){return rT.instance||(rT.instance=new rT),rT.instance}getOrCreateProvider(e,t=""){const n=this.providers.get(e);if(n)return{provider:n,ytext:n.doc.getText(tT),ylanguage:n.doc.getText(nT)};const r=new zj,o=r.getText(tT),s=r.getText(nT),i={session_id:ii()},a=new URLSearchParams(window.location.search).get(si.filePath);a&&(i.file=a);const l=new eT("ws",e,r,{params:i,resyncInterval:5e3});return this.providers.set(e,l),l.on("connection-close",(()=>{X.warn("RTC: connection closed. This could lead to data loss.")})),l.on("connection-error",(()=>{X.warn("RTC: connection error. This could lead to data loss.")})),{provider:l,ytext:o,ylanguage:s}}listenForConnectionChanges(){ne.sub(ft,(()=>{const e=ne.get(ft);(e.state===pt.CLOSED||e.state===pt.CLOSING)&&this.disconnectAll()}))}disconnect(e){const t=this.providers.get(e);t&&(t.destroy(),this.providers.delete(e))}disconnectAll(){for(const[e]of this.providers)this.disconnect(e)}}function oT(e,t,n=""){if(E())return{extension:[],code:n};const r=rT.getInstance(),{ytext:o,ylanguage:s,provider:i}=r.getOrCreateProvider(e,n),a=Bn.define((e=>{const r=r=>{var s,i;if(X.debug(`RTC sync=${r}, ytext.length=${o.toJSON()}`),!r){const t=o.toJSON();e.dispatch({changes:{from:0,to:e.state.doc.length,insert:t}})}if(r&&(t(o.toJSON()),n&&0===o.length)){(null==(s=o.doc)?void 0:s.getMap("_metadata").get("initialCodeInserted"))||null==(i=o.doc)||i.transact((()=>{var e;o.delete(0,o.length),o.insert(0,n),null==(e=o.doc)||e.getMap("_metadata").set("initialCodeInserted",!0)}))}};return i.on("sync",r),{destroy(){i.off("sync",r)}}})),l=[Bn.define((e=>{const t=()=>{const t=s.toJSON(),n=e.state.field(Rr).type;if(t!==n){X.debug(`[debug] Received language change: ${n} -> ${t}`);const r=li[t]();Ce(e,r.type,{keepCodeAsIs:!0})}};return s.observe(t),{destroy(){s.unobserve(t)}}})),zn.updateListener.of((e=>{var t;for(const n of e.transactions)for(const e of n.effects)if(e.is(ai)){const n=s.toJSON();n!==e.value.type&&(X.debug(`[debug] Setting language: ${n} -> ${e.value.type}`),null==(t=s.doc)||t.transact((()=>{s.delete(0,s.length),s.insert(0,e.value.type)})))}})),a,OA(o,null)];return{code:o.toJSON(),extension:l}}rT.instance=void 0;const sT=({theme:e,showPlaceholder:t,allowFocus:n,id:r,config:o,code:s,status:i,serializedEditorState:a,setEditorView:c,runCell:d,userConfig:u,editorViewRef:h,editorViewParentRef:f,hidden:m,hasOutput:p,temporarilyShowCode:g,languageAdapter:y,setLanguageAdapter:b,showLanguageToggles:x=!0})=>{var v;const[w,k]=We(eh),S=function(){const e=N.c(2),t=he(mh);let n;return e[0]!==t?(n=e=>{ze!==e&&t(e)},e[0]=t,e[1]=n):n=e[1],n}(),C=sh(),{saveOrNameNotebook:E}=np(),I="running"===i||"queued"===i,A=V(),T=lh(),M="markdown"===y,D=$((()=>!I&&(C({cellId:r}),!0))),O=$((()=>!I&&(d(),!0))),R=$((()=>{const e=!o.hide_code;return Oe({configs:{[r]:{hide_code:e}}}),A.updateCellConfig({cellId:r,config:{hide_code:e}}),e})),P=de(me),L=$((()=>{ah(P,A.createNewCell)})),F=ci(u),z=l.useMemo((()=>{const n=mv({cellId:r,showPlaceholder:t,enableAI:F,cellActions:{...A,afterToggleMarkdown:L,onRun:O,deleteCell:D,saveNotebook:E,createManyBelow:e=>{for(const t of[...e].reverse())A.createNewCell({code:t,before:!1,cellId:r,skipIfCodeExists:!0})},splitCell:T,toggleHideCode:R,aiCellCompletion:()=>{let e=!1;return k((t=>(null==t?void 0:t.cellId)===r?(e=!0,null):{cellId:r})),e}},completionConfig:u.completion,keymapConfig:u.keymap,lspConfig:u.language_servers,theme:e,hotkeys:new di(u.keymap.overrides??{}),diagnosticsConfig:u.diagnostics});return n.push(Bn.define((e=>{const t=e.state.field(Rr);return b(t.type),{update(e){const t=e.state.field(Rr);b(t.type)}}})),zn.updateListener.of((e=>{if(e.selectionSet){e.state.selection.ranges.some((e=>e.from!==e.to))&&g({focus:!1})}}))),n}),[r,u.keymap,u.completion,u.language_servers,u.diagnostics,F,e,t,A,T,R,D,O,k,L,b,g,E]),B=$((()=>{if(j("rtc_v2")){const e=oT(r,(e=>{A.updateCellCode({cellId:r,code:e,formattingChange:!0})}),s);z.push(e.extension),s=e.code}const e=new zn({state:yo.create({doc:s,extensions:z})});c(e),Ce(e,ui(e.state).type)})),U=$((()=>{if(Rn(null!==h.current,"Editor view is not initialized"),j("rtc_v2")){const e=oT(r,(e=>{A.updateCellCode({cellId:r,code:e,formattingChange:!0})}));z.push(e.extension)}h.current.dispatch({effects:[Hn.reconfigure.of([z]),hi(h.current,u.completion,new di(u.keymap.overrides??{}),{...u.language_servers,diagnostics:u.diagnostics})]})})),H=$((()=>{if(Rn(a,"Editor view is not initialized"),j("rtc_v2")){const e=oT(r,(e=>{A.updateCellCode({cellId:r,code:e,formattingChange:!0})}),s);z.push(e.extension)}const e=new zn({state:yo.fromJSON(a,{doc:s,extensions:z},{history:fi})});Ce(e,ui(e.state).type),c(e),A.clearSerializedEditorState({cellId:r})}));l.useEffect((()=>{null===a?null===h.current?B():U():H(),null!==h.current&&f&&null!==f.current&&f.current.replaceChildren(h.current.dom)}),[B,U,H,h,f,a,z]);const W=null===h.current||null!==a;l.useEffect((()=>{const e=null!==ne.get(ae).scrollKey;W&&n&&!e&&requestAnimationFrame((()=>{var e,t;null==(e=h.current)||e.focus(),null==(t=h.current)||t.dom.scrollIntoView({behavior:"smooth",block:"nearest"})}))}),[W,n,h]),l.useEffect((()=>{const e=h.current;return()=>{null==e||e.destroy()}}),[h]);const G=m&&!M||m&&M&&!p;let q="";return M&&m&&p?q="h-0 overflow-hidden":m&&(q="opacity-20 h-8 overflow-hidden"),_.jsx(pN,{enabled:(null==w?void 0:w.cellId)===r,initialPrompt:null==w?void 0:w.initialPrompt,currentCode:(null==(v=h.current)?void 0:v.state.doc.toString())??s,currentLanguageAdapter:y,declineChange:$((()=>{var e;k(null),null==(e=h.current)||e.focus()})),onChange:$((e=>{var t;null==(t=h.current)||t.dispatch({changes:{from:0,to:h.current.state.doc.length,insert:e}})})),acceptChange:$((e=>{var t,n;null==(t=h.current)||t.dispatch({changes:{from:0,to:h.current.state.doc.length,insert:e}}),null==(n=h.current)||n.focus(),k(null)})),children:_.jsxs("div",{className:"relative w-full",onFocus:()=>S(r),children:[G&&_.jsx(mi,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:g}),_.jsx(iT,{className:q,editorView:h.current,ref:f}),!m&&x&&_.jsx("div",{className:"absolute top-1 right-5",children:_.jsx(VS,{code:s,editorView:h.current,currentLanguageAdapter:y,onAfterToggle:L})})]})})},iT=p.forwardRef(((e,t)=>{const n=N.c(10),{className:r,editorView:o}=e,s=l.useRef(null);let i,a,c,d,u;return n[0]!==o?(i=()=>{null!==o&&null!==s.current&&0===s.current.children.length&&s.current.append(o.dom)},a=[o,s],n[0]=o,n[1]=i,n[2]=a):(i=n[1],a=n[2]),l.useEffect(i,a),n[3]!==r?(c=$t("cm mathjax_ignore",r),n[3]=r,n[4]=c):c=n[4],n[5]!==t?(d=e=>{t?AS(t,s)(e):AS(s)(e)},n[5]=t,n[6]=d):d=n[6],n[7]!==c||n[8]!==d?(u=_.jsx("div",{className:c,ref:d,"data-testid":"cell-editor"}),n[7]=c,n[8]=d,n[9]=u):u=n[9],u}));iT.displayName="CellCodeMirrorEditor";const aT=j("rtc_v2")?function(e){const t=t=>{const n=N.c(2);if(de(ft).state===pt.CONNECTING)return null;let r;return n[0]!==t?(r=_.jsx(e,{...t}),n[0]=t,n[1]=r):r=n[1],r};return t.displayName=`WithWaitUntilConnected(${e.displayName})`,t}(l.memo(sT)):l.memo(sT),lT=e=>{const t=N.c(10);let n,r,o,s;return t[0]!==e.left?(n=_.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?(r=_.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:e.center}),t[2]=e.center,t[3]=r):r=t[3],t[4]!==e.right?(o=_.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:e.right}),t[4]=e.right,t[5]=o):o=t[5],t[6]!==n||t[7]!==r||t[8]!==o?(s=_.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,r,o]}),t[6]=n,t[7]=r,t[8]=o,t[9]=s):s=t[9],s},cT=e=>{const t=N.c(8);if(!e.canCollapse&&!e.isCollapsed)return null;const n=e.isCollapsed?"Expand":"Collapse";let r,o,s;return t[0]!==e.isCollapsed?(r=_.jsx(dT,{isCollapsed:e.isCollapsed}),t[0]=e.isCollapsed,t[1]=r):r=t[1],t[2]!==n||t[3]!==r?(o=_.jsx(ht,{content:n,children:r}),t[2]=n,t[3]=r,t[4]=o):o=t[4],t[5]!==e.onClick||t[6]!==o?(s=_.jsx(ee,{variant:"text",size:"icon",onClick:e.onClick,children:o}),t[5]=e.onClick,t[6]=o,t[7]=s):s=t[7],s},dT=e=>{const t=N.c(2),{isCollapsed:n}=e;let r;return t[0]!==n?(r=n?_.jsx(Ae,{className:"w-5 h-5 flex-shrink-0"}):_.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}),t[0]=n,t[1]=r):r=t[1],r},uT=l.memo((e=>{const t=N.c(24),{onClick:n,count:r,cellId:o}=e,s=yr();let i;t[0]!==o||t[1]!==s?(i=pi(s,o),t[0]=o,t[1]=s,t[2]=i):i=t[2];const a=i;let l,c;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=$t("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=_.jsx(yi,{className:"w-4 h-4 flex-shrink-0"}),t[4]=c):c=t[4];const d=1===r?"cell":"cells";let u,h,f,m,p,g,y;return t[5]!==r||t[6]!==d?(u=_.jsxs(_.Fragment,{children:[c,_.jsxs("span",{className:"text-sm text-gray-500",children:[r," ",d," collapsed"]})]}),t[5]=r,t[6]=d,t[7]=u):u=t[7],t[8]!==a.errored?(h=a.errored&&_.jsx(ht,{content:"Has errors",delayDuration:100,children:_.jsx(ou,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),t[8]=a.errored,t[9]=h):h=t[9],t[10]!==a.stale?(f=a.stale&&_.jsx(ht,{content:"Has stale cells",delayDuration:100,children:_.jsx(gi,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),t[10]=a.stale,t[11]=f):f=t[11],t[12]!==a.runningOrQueued?(m=a.runningOrQueued&&_.jsx(ht,{content:"Running",delayDuration:100,children:_.jsx(ri,{className:"w-4 h-4 flex-shrink-0 animate-spin"})}),t[12]=a.runningOrQueued,t[13]=m):m=t[13],t[14]!==h||t[15]!==f||t[16]!==m?(p=_.jsxs(_.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=_.jsx(lT,{center:u,right:p}),t[18]=u,t[19]=p,t[20]=g):g=t[20],t[21]!==n||t[22]!==g?(y=_.jsx("div",{onClick:n,className:l,children:g}),t[21]=n,t[22]=g,t[23]=y):y=t[23],y}));uT.displayName="CollapsedCellBanner";const hT=e=>{const t=N.c(6),{appClosed:n,status:r}=e,o=Fm("running"===r);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=fn("global.interrupt"),t[0]=s):s=t[0];const i=n||!o,a=o?bi:Rt.NOOP,l=o?"stale":"disabled";let c,d;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx(R,{strokeWidth:1.5}),t[1]=c):c=t[1],t[2]!==i||t[3]!==a||t[4]!==l?(d=_.jsx(rw,{tooltip:s,disabled:i,onClick:a,variant:l,"data-testid":"run-button",children:c}),t[2]=i,t[3]=a,t[4]=l,t[5]=d):d=t[5],d},fT={width:void 0,height:void 0};function mT(e,t,n){return e[t]?Array.isArray(e[t])?e[t][0][n]:e[t][n]:"contentBoxSize"===t?e.contentRect["inlineSize"===n?"width":"height"]:void 0}function pT(e,t){const n=N.c(9);let r;n[0]!==e.current||n[1]!==t?(r=n=>{null===e.current||e.current.contains(n.relatedTarget)||null===t.current||Y(t.current)},n[0]=e.current,n[1]=t,n[2]=r):r=n[2];const o=$(r);let s;n[3]!==e.current||n[4]!==t?(s=n=>{if(e.current===document.activeElement&&null!==t.current&&"active"===Ir(t.current.state)){for(const e of Kr)if(n.key===e.key&&e.run){e.run(t.current),n.preventDefault(),n.stopPropagation();break}t.current.focus()}},n[3]=e.current,n[4]=t,n[5]=s):s=n[5];const i=$(s);let a;return n[6]!==o||n[7]!==i?(a={closeCompletionHandler:o,resumeCompletionHandler:i},n[6]=o,n[7]=i,n[8]=a):a=n[8],a}function gT(e,t,n,r,o,s,i,a,l){const c=N.c(51);let d,u,h,f,m,p,g,y,b,x,v,w,k,S,C,E;c[0]!==r||c[1]!==t||c[2]!==n?(d=()=>{n(),r.moveToNextCell({cellId:t,before:!1})},u=()=>{n(),r.moveToNextCell({cellId:t,before:!0})},c[0]=r,c[1]=t,c[2]=n,c[3]=d,c[4]=u):(d=c[3],u=c[4]),c[5]!==r||c[6]!==t?(h=()=>r.createNewCell({cellId:t,before:!0}),f=()=>r.createNewCell({cellId:t,before:!1}),m=()=>r.moveCell({cellId:t,before:!0}),p=()=>r.moveCell({cellId:t,before:!1}),c[5]=r,c[6]=t,c[7]=h,c[8]=f,c[9]=m,c[10]=p):(h=c[7],f=c[8],m=c[9],p=c[10]),c[11]!==r||c[12]!==o||c[13]!==t?(g=()=>o?r.moveCell({cellId:t,direction:"left"}):void 0,y=()=>o?r.moveCell({cellId:t,direction:"right"}):void 0,c[11]=r,c[12]=o,c[13]=t,c[14]=g,c[15]=y):(g=c[14],y=c[15]),c[16]!==r||c[17]!==s||c[18]!==t||c[19]!==(null==e?void 0:e.current)||c[20]!==i?(b=()=>{var n,o,a;const l=!s.hide_code;Oe({configs:{[t]:{hide_code:l}}}),r.updateCellConfig({cellId:t,config:{hide_code:l}}),l?(null==(n=i.current)||n.contentDOM.blur(),null==(o=null==e?void 0:e.current)||o.focus()):null==(a=i.current)||a.focus()},c[16]=r,c[17]=s,c[18]=t,c[19]=null==e?void 0:e.current,c[20]=i,c[21]=b):b=c[21],c[22]!==r||c[23]!==t?(k=()=>r.moveToNextCell({cellId:t,before:!1,noCreate:!0}),x=()=>r.moveToNextCell({cellId:t,before:!0,noCreate:!0}),v=()=>r.sendToBottom({cellId:t}),w=()=>r.sendToTop({cellId:t}),c[22]=r,c[23]=t,c[24]=x,c[25]=v,c[26]=w,c[27]=k):(x=c[24],v=c[25],w=c[26],k=c[27]),c[28]!==t||c[29]!==i||c[30]!==a?(S=()=>{let e;e=!1,a((n=>(null==n?void 0:n.cellId)===t?(e=!0,null):{cellId:t})),e&&gv(i).focus()},c[28]=t,c[29]=i,c[30]=a,c[31]=S):S=c[31],c[32]!==l?(C=()=>{var e;null==(e=l.current)||e.toggle()},c[32]=l,c[33]=C):C=c[33],c[34]!==n||c[35]!==d||c[36]!==u||c[37]!==x||c[38]!==v||c[39]!==w||c[40]!==S||c[41]!==C||c[42]!==h||c[43]!==f||c[44]!==m||c[45]!==p||c[46]!==g||c[47]!==y||c[48]!==b||c[49]!==k?(E={"cell.run":n,"cell.runAndNewBelow":d,"cell.runAndNewAbove":u,"cell.createAbove":h,"cell.createBelow":f,"cell.moveUp":m,"cell.moveDown":p,"cell.moveLeft":g,"cell.moveRight":y,"cell.hideCode":b,"cell.focusDown":k,"cell.focusUp":x,"cell.sendToBottom":v,"cell.sendToTop":w,"cell.aiCompletion":S,"cell.cellActions":C},c[34]=n,c[35]=d,c[36]=u,c[37]=x,c[38]=v,c[39]=w,c[40]=S,c[41]=C,c[42]=h,c[43]=f,c[44]=m,c[45]=p,c[46]=g,c[47]=y,c[48]=b,c[49]=k,c[50]=E):E=c[50],pc(e,E)}function yT(e,t,n,r,o,s){const i=N.c(16);let a,l,c,d,u;i[0]!==n||i[1]!==t?(a=e=>(!e||!dt.fromInput(e))&&(n.moveToNextCell({cellId:t,before:!1,noCreate:!0}),!0),l=e=>(!e||!dt.fromInput(e))&&(n.moveToNextCell({cellId:t,before:!0,noCreate:!0}),!0),i[0]=n,i[1]=t,i[2]=a,i[3]=l):(a=i[2],l=i[3]),i[4]!==r?(c=()=>(r(),!1),i[4]=r,i[5]=c):c=i[5],i[6]!==n||i[7]!==t||i[8]!==s||i[9]!==o.keymap.preset?(d="vim"!==o.keymap.preset||s?{}:{j:e=>(!e||!dt.fromInput(e))&&(n.moveToNextCell({cellId:t,before:!1,noCreate:!0}),!0),k:e=>(!e||!dt.fromInput(e))&&(n.moveToNextCell({cellId:t,before:!0,noCreate:!0}),!0)},i[6]=n,i[7]=t,i[8]=s,i[9]=o.keymap.preset,i[10]=d):d=i[10],i[11]!==a||i[12]!==l||i[13]!==c||i[14]!==d?(u={ArrowDown:a,ArrowUp:l,Enter:c,...d},i[11]=a,i[12]=l,i[13]=c,i[14]=d,i[15]=u):u=i[15],gc(e,u)}const bT=l.forwardRef(((e,t)=>{const n=N.c(14),{id:r,output:o,interrupted:s,errored:i,stopped:a,name:l,outputStale:c,outputLoading:d}=e;let u;n[0]===Symbol.for("react.memo_cache_sentinel")?(u=Ci("marimo-cell","hover-actions-parent z-10",{published:!0}),n[0]=u):u=n[0];const h=u;let f;n[1]!==r?(f=St.create(r),n[1]=r,n[2]=f):f=n[2];const m=f,p=Si(null==o?void 0:o.mimetype);if(i||s||a||p)return null;let g,y;return n[3]!==r||n[4]!==o||n[5]!==d||n[6]!==c?(g=_.jsx(_i,{allowExpand:!1,forceExpand:!0,output:o,className:"output-area",cellId:r,stale:c,loading:d}),n[3]=r,n[4]=o,n[5]=d,n[6]=c,n[7]=g):g=n[7],n[8]!==m||n[9]!==r||n[10]!==l||n[11]!==t||n[12]!==g?(y=_.jsx("div",{tabIndex:-1,id:m,ref:t,className:h,"data-cell-id":r,"data-cell-name":l,children:g}),n[8]=m,n[9]=r,n[10]=l,n[11]=t,n[12]=g,n[13]=y):y=n[13],y}));bT.displayName="ReadonlyCellComponent";const xT=({theme:e,showPlaceholder:t,allowFocus:n,id:r,code:o,output:s,consoleOutputs:i,status:a,runStartTimestamp:c,lastRunStartTimestamp:d,runElapsedTimeMs:u,edited:h,interrupted:f,errored:m,stopped:p,staleInputs:g,serializedEditorState:y,serialization:b,debuggerActive:x,appClosed:v,canDelete:w,actions:k,deleteCell:S,userConfig:C,outline:E,isCollapsed:j,collapseCount:I,config:A,canMoveX:T,name:M,editorView:D,setEditorView:O,outputStale:R})=>{const P=l.useRef(null),L=l.useRef(null),F=l.useRef(null),z=l.useRef(null),B=he(eh),U=Ju(r),[V,H]=l.useState(),W=A.disabled||"disabled-transitively"===a,G=Ei({executionTime:u,status:a,errored:m,interrupted:f,stopped:p}),q=h||f||g&&!W,Y=wi(a),K=("queued"===a||h||g)&&!f,J=l.useCallback((()=>D.current),[D]),{closeCompletionHandler:Z,resumeCompletionHandler:Q}=pT(P,D),{isCellCodeShown:ee,isMarkdown:te,isMarkdownCodeHidden:ne,temporarilyShowCode:re,showHiddenMarkdownCode:oe}=function(e,t,n,r){const o=N.c(13),[s,i]=l.useState(!1),a=!e.hide_code||s,c="markdown"===t,d=c&&!a;let u;o[0]!==n||o[1]!==r||o[2]!==a?(u=e=>{var t,o;if(a)return;const s=(null==e?void 0:e.focus)??!0;i(!0),s&&(null==(t=n.current)||t.focus());const l=null==(o=r.current)?void 0:o.parentElement;if(!l)return void X.error("Cell: No parent element found for editor view");const c=()=>{requestAnimationFrame((()=>{var e;l.contains(document.activeElement)||(i(!1),null==(e=n.current)||e.dom.blur(),l.removeEventListener("focusout",c))}))};l.addEventListener("focusout",c)},o[0]=n,o[1]=r,o[2]=a,o[3]=u):u=o[3];const h=$(u);let f;o[4]!==d||o[5]!==h?(f=()=>{d&&h({focus:!0})},o[4]=d,o[5]=h,o[6]=f):f=o[6];const m=$(f);let p;return o[7]!==a||o[8]!==c||o[9]!==d||o[10]!==m||o[11]!==h?(p={isCellCodeShown:a,isMarkdown:c,isMarkdownCodeHidden:d,temporarilyShowCode:h,showHiddenMarkdownCode:m},o[7]=a,o[8]=c,o[9]=d,o[10]=m,o[11]=h,o[12]=p):p=o[12],p}(A,V,D,F);gT(P,r,U,k,T,A,D,B,L),yT(P,r,k,oe,C,ee);const se=Ai(E),ie=!ki(s),ae=i.length>0,le=C.display.cell_output,ce=ie&&"above"===le,de=ie&&"below"===le,[ue,fe]=l.useState(!1),[me,pe]=l.useState(!1);!function(e){const{ref:t,box:n="content-box",skip:r}=e,o=l.useRef({...fT}),s=l.useRef(void 0);s.current=e.onResize,l.useEffect((()=>{if(!t.current||r)return;if("undefined"==typeof window||!("ResizeObserver"in window))return;const e=new ResizeObserver((([e])=>{const t="border-box"===n?"borderBoxSize":"device-pixel-content-box"===n?"devicePixelContentBoxSize":"contentBoxSize",r=mT(e,t,"inlineSize"),i=mT(e,t,"blockSize");if(o.current.width!==r||o.current.height!==i){const e={width:r,height:i};o.current.width=r,o.current.height=i,s.current&&s.current(e)}}));return e.observe(t.current,{box:n}),()=>{e.disconnect()}}),[n,t,r])}({ref:z,skip:!te,onResize:e=>{const t=e.height&&e.height<68,n=ne&&(t||"below"===le);fe(n),se&&n?pe(!0):me&&pe(!1)}});const ge=e=>_.jsx(mi,{tooltip:"Edit markdown",className:$t("z-20 relative",e),onClick:re}),ye=ie&&_.jsxs("div",{className:"relative",onDoubleClick:oe,children:[_.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:_.jsx(cT,{isCollapsed:j,onClick:()=>{j?k.expandCell({cellId:r}):k.collapseCell({cellId:r})},canCollapse:se})}),ne&&de&&ge("top-3"),_.jsx(_i,{allowExpand:!0,forceExpand:ne,output:s,className:"output-area",cellId:r,stale:R,loading:Y}),ne&&ce&&ge("bottom-3")]}),be=Ci("marimo-cell","hover-actions-parent z-10",{interactive:!0,"needs-run":q,"has-error":m,stopped:p,disabled:A.disabled,stale:"disabled-transitively"===a,borderless:ne&&ie}),xe=St.create(r),ve=$((e=>{B({cellId:r,initialPrompt:e.prompt})})),we=!(!b||"valid"!==b.toLowerCase());return _.jsx(Ni,{children:_.jsx(FS,{cellId:r,config:A,status:a,getEditorView:J,hasOutput:ie,hasConsoleOutput:ae,name:M,children:_.jsxs(DS,{tabIndex:-1,ref:P,"data-status":a,onBlur:Z,onKeyDown:Q,cellId:r,canMoveX:T,title:A.disabled?"This cell is disabled":"disabled-transitively"===a?"This cell has a disabled ancestor":void 0,children:[_.jsxs("div",{className:be,id:xe,ref:z,"data-cell-id":r,"data-cell-name":M,children:["above"===le&&ye,_.jsxs("div",{className:$t("tray"),"data-hidden":ne,children:[_.jsx("div",{className:"absolute right-2 -top-4 z-10",children:_.jsx(kT,{edited:h,appClosed:v,status:a,cellConfig:A,needsRun:q,hasOutput:ie,hasConsoleOutput:ae,cellActionDropdownRef:L,cellId:r,name:M,getEditorView:J,onRun:U})}),_.jsx(wT,{cellId:r,className:$t(ne&&ce&&"-top-7",ne&&de&&"-bottom-8",ne&&me&&"-left-[3.8rem]"),appClosed:v,actions:k}),_.jsx(aT,{theme:e,showPlaceholder:t,allowFocus:n,id:r,code:o,config:A,status:a,serializedEditorState:y,runCell:U,setEditorView:O,userConfig:C,editorViewRef:D,editorViewParentRef:F,hidden:!ee,hasOutput:ie,temporarilyShowCode:re,languageAdapter:V,setLanguageAdapter:H}),_.jsx(vT,{className:$t(ne&&"below"===le&&"top-14"),edited:h,status:a,isCellStatusInline:ue,uninstantiated:G,disabled:A.disabled,runElapsedTimeMs:u,runStartTimestamp:c,lastRunStartTimestamp:d,staleInputs:g,interrupted:f}),_.jsx("div",{className:"shoulder-bottom hover-action",children:w&&ee&&_.jsx(iw,{appClosed:v,status:a,onClick:()=>{Y||v||S({cellId:r})}})})]}),"below"===le&&ye,b&&_.jsxs("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",className:"hover:underline py-1 px-2 flex items-center justify-end gap-2 last:rounded-b",children:[we&&_.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"reusable"}),_.jsx(ht,{content:_.jsx("span",{className:"max-w-16 text-xs",children:we?"This function or class can be imported into other Python notebooks or modules.":_.jsxs(_.Fragment,{children:["This definition can't be reused in other Python modules:",_.jsx("br",{}),_.jsx("br",{}),_.jsx("pre",{children:b}),_.jsx("br",{}),"Click this icon to learn more."]})}),children:we&&_.jsx(bt,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})||_.jsx(ji,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),_.jsx(Uc,{consoleOutputs:i,stale:K,cellName:b?"_":M,onRefactorWithAI:ve,onClear:()=>{k.clearCellConsoleOutput({cellId:r})},onSubmitDebugger:(e,t)=>{k.setStdinResponse({cellId:r,response:e,outputIndex:t}),Ii({text:e})},cellId:r,debuggerActive:x})]}),j&&_.jsx(uT,{onClick:()=>k.expandCell({cellId:r}),count:I,cellId:r})]})})})},vT=e=>{const t=N.c(19),{className:n,disabled:r,edited:o,interrupted:s,isCellStatusInline:i,lastRunStartTimestamp:a,runElapsedTimeMs:l,runStartTimestamp:c,staleInputs:d,status:u,uninstantiated:h}=e,f=void 0!==r&&r;let m;t[0]!==f||t[1]!==o||t[2]!==s||t[3]!==a||t[4]!==l||t[5]!==c||t[6]!==d||t[7]!==u||t[8]!==h?(m=_.jsx(cw,{status:u,staleInputs:d,interrupted:s,editing:!0,edited:o,disabled:f,elapsedTime:l,runStartTimestamp:c,uninstantiated:h,lastRunStartTimestamp:a}),t[0]=f,t[1]=o,t[2]=s,t[3]=a,t[4]=l,t[5]=c,t[6]=d,t[7]=u,t[8]=h,t[9]=m):m=t[9];const p=m;let g;t[10]!==n?(g=$t("shoulder-right z-20",n),t[10]=n,t[11]=g):g=t[11];const y=!i&&p;let b;t[12]===Symbol.for("react.memo_cache_sentinel")?(b=_.jsx(MS,{}),t[12]=b):b=t[12];const x=i&&p;let v,w;return t[13]!==x?(v=_.jsxs("div",{className:"flex gap-2 items-end",children:[b,x]}),t[13]=x,t[14]=v):v=t[14],t[15]!==g||t[16]!==y||t[17]!==v?(w=_.jsxs("div",{className:g,children:[y,v]}),t[15]=g,t[16]=y,t[17]=v,t[18]=w):w=t[18],w},wT=e=>{const t=N.c(21),{className:n,appClosed:r,actions:o,cellId:s}=e;let i;t[0]!==o||t[1]!==s?(i=e=>{const t=void 0===e?{}:e;return o.createNewCell({cellId:s,before:!1,...t})},t[0]=o,t[1]=s,t[2]=i):i=t[2];const a=$(i);let l;t[3]!==o||t[4]!==s?(l=e=>{const t=void 0===e?{}:e;return o.createNewCell({cellId:s,before:!0,...t})},t[3]=o,t[4]=s,t[5]=l):l=t[5];const c=$(l);let d,u;t[6]!==n?(d=$t("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",n),t[6]=n,t[7]=d):d=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(u=fn("cell.createAbove"),t[8]=u):u=t[8];const h=r?void 0:c;let f,m,p;t[9]!==r||t[10]!==h?(f=_.jsx(ew,{tooltipContent:u,appClosed:r,onClick:h}),t[9]=r,t[10]=h,t[11]=f):f=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(m=_.jsx("div",{className:"flex-1"}),t[12]=m):m=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(p=fn("cell.createBelow"),t[13]=p):p=t[13];const g=r?void 0:a;let y,b;return t[14]!==r||t[15]!==g?(y=_.jsx(ew,{tooltipContent:p,appClosed:r,onClick:g}),t[14]=r,t[15]=g,t[16]=y):y=t[16],t[17]!==d||t[18]!==f||t[19]!==y?(b=_.jsxs("div",{className:d,children:[f,m,y]}),t[17]=d,t[18]=f,t[19]=y,t[20]=b):b=t[20],b},kT=e=>{const t=N.c(27),{edited:n,appClosed:r,status:o,cellConfig:s,needsRun:i,hasOutput:a,hasConsoleOutput:l,onRun:c,cellActionDropdownRef:d,cellId:u,getEditorView:h,name:f,includeCellActions:m}=e,p=void 0===m||m,g=!i&&"hover-action";let y;t[0]!==g?(y=$t(g),t[0]=g,t[1]=y):y=t[1];const b=r?Rt.NOOP:c;let x,v,w,k;return t[2]!==r||t[3]!==s||t[4]!==n||t[5]!==i||t[6]!==o||t[7]!==b?(x=_.jsx(sw,{edited:n,onClick:b,appClosed:r,status:o,config:s,needsRun:i}),t[2]=r,t[3]=s,t[4]=n,t[5]=i,t[6]=o,t[7]=b,t[8]=x):x=t[8],t[9]!==r||t[10]!==o?(v=_.jsx(hT,{status:o,appClosed:r}),t[9]=r,t[10]=o,t[11]=v):v=t[11],t[12]!==d||t[13]!==s||t[14]!==u||t[15]!==h||t[16]!==l||t[17]!==a||t[18]!==p||t[19]!==f||t[20]!==o?(w=p&&_.jsx(RS,{ref:d,cellId:u,status:o,getEditorView:h,name:f,config:s,hasOutput:a,hasConsoleOutput:l,children:_.jsx(rw,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:_.jsx(Bc,{strokeWidth:1.5})})}),t[12]=d,t[13]=s,t[14]=u,t[15]=h,t[16]=l,t[17]=a,t[18]=p,t[19]=f,t[20]=o,t[21]=w):w=t[21],t[22]!==y||t[23]!==x||t[24]!==v||t[25]!==w?(k=_.jsxs(ow,{className:y,children:[x,v,w]}),t[22]=y,t[23]=x,t[24]=v,t[25]=w,t[26]=k):k=t[26],k},ST=({theme:e,showPlaceholder:t,allowFocus:n,id:r,code:o,output:s,consoleOutputs:i,status:a,runStartTimestamp:c,lastRunStartTimestamp:d,runElapsedTimeMs:u,edited:h,interrupted:f,errored:m,stopped:p,staleInputs:g,serializedEditorState:y,debuggerActive:b,appClosed:x,canDelete:v,actions:w,deleteCell:k,userConfig:S,config:C,canMoveX:N,name:E,editorView:j,setEditorView:I})=>{const A=l.useRef(null),T=l.useRef(null),M=l.useRef(null),D=he(eh),O=Ju(r),R=C.disabled||"disabled-transitively"===a,P=Ei({executionTime:u,status:a,errored:m,interrupted:f,stopped:p}),L=h||f||g&&!R,F="running"===a||"queued"===a,z=("queued"===a||h||g)&&!f,B=l.useCallback((()=>j.current),[j]),{closeCompletionHandler:U,resumeCompletionHandler:V}=pT(A,j);gT(A,r,O,w,N,C,j,D,T),yT(A,r,w,Rt.NOOP,S,!0);const H=!ki(s),W=i.length>0,G=Si(null==s?void 0:s.mimetype),q=Ci("marimo-cell","hover-actions-parent z-10 border shadow-sm","!border-[var(--blue-5)] !rounded-sm",{"needs-run":L,"has-error":m,stopped:p}),Y=St.create(r),K=$((e=>{D({cellId:r,initialPrompt:e.prompt})}));return _.jsx(Ni,{children:_.jsx(FS,{cellId:r,config:C,status:a,getEditorView:B,hasOutput:H,hasConsoleOutput:W,name:E,children:_.jsxs("div",{className:q,"data-status":a,id:Y,ref:A,onBlur:U,onKeyDown:V,title:C.disabled?"This cell is disabled":"disabled-transitively"===a?"This cell has a disabled ancestor":void 0,"data-cell-id":r,"data-cell-name":E,"data-setup-cell":!0,children:[_.jsxs("div",{className:$t("tray"),"data-hidden":!1,children:[_.jsx("div",{className:"absolute right-2 -top-4 z-10",children:_.jsx(kT,{edited:h,appClosed:x,status:a,cellConfig:C,needsRun:L,hasOutput:H,hasConsoleOutput:W,cellActionDropdownRef:T,cellId:r,name:E,getEditorView:B,onRun:O,includeCellActions:!1})}),_.jsx(aT,{theme:e,showPlaceholder:t,allowFocus:n,id:r,code:o,config:C,status:a,serializedEditorState:y,runCell:O,setEditorView:I,userConfig:S,editorViewRef:j,editorViewParentRef:M,hidden:!1,hasOutput:H,temporarilyShowCode:Rt.NOOP,languageAdapter:"python",setLanguageAdapter:Rt.NOOP,showLanguageToggles:!1}),_.jsx(vT,{edited:h,status:a,isCellStatusInline:!1,uninstantiated:P,disabled:C.disabled,runElapsedTimeMs:u,runStartTimestamp:c,lastRunStartTimestamp:d,staleInputs:g,interrupted:f}),_.jsx("div",{className:"shoulder-bottom hover-action",children:v&&_.jsx(iw,{appClosed:x,status:a,onClick:()=>{F||x||k({cellId:r})}})})]}),_.jsxs("div",{className:"py-1 px-2 flex justify-end gap-2 last:rounded-b",children:[_.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"setup cell"}),_.jsx(ht,{content:_.jsxs("span",{className:"max-w-16",children:["This ",_.jsx("b",{children:"setup cell"})," is guaranteed to run before all other cells. Include ",_.jsx("br",{}),"initialization or imports and constants required by top-level functions."]}),children:_.jsx(ji,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),G&&_.jsx(_i,{allowExpand:!0,forceExpand:!0,output:s,className:"output-area",cellId:r,stale:!1,loading:F}),_.jsx(Uc,{consoleOutputs:i,stale:z,cellName:"_",onRefactorWithAI:K,onClear:()=>{w.clearCellConsoleOutput({cellId:r})},onSubmitDebugger:(e,t)=>{w.setStdinResponse({cellId:r,response:e,outputIndex:t}),Ii({text:e})},cellId:r,debuggerActive:b})]})})})},CT=l.memo(l.forwardRef(((e,t)=>{const{status:n,output:r,runStartTimestamp:o,interrupted:s,staleInputs:i,edited:a,id:c,mode:d}=e;X.debug("Rendering Cell",c);const u=l.useRef(null);l.useImperativeHandle(t,(()=>({get editorView(){return gv(u)}})),[u]);const h=xi({status:n,output:r,runStartTimestamp:o,interrupted:s,staleInputs:i},a),f=wi(n);return c===vi?_.jsx(ST,{...e,editorView:u,setEditorView:e=>{u.current=e},outputStale:h}):"edit"===d?_.jsx(xT,{...e,editorView:u,setEditorView:e=>{u.current=e},outputStale:h}):_.jsx(bT,{...e,outputStale:h,outputLoading:f})}))),NT=e=>{const t=N.c(10),{width:n}=e,{banners:r}=$c(),{removeBanner:o}=Vc();if(0===r.length)return null;const s="columns"===n&&"sticky left-12 w-full max-w-[80vw]";let i,a,l;if(t[0]!==s?(i=$t("flex flex-col gap-4 mb-5 print:hidden",s),t[0]=s,t[1]=i):i=t[1],t[2]!==r||t[3]!==o){let e;t[5]!==o?(e=e=>_.jsxs(Ti,{kind:e.variant||"info",className:"flex flex-col rounded p-3",children:[_.jsxs("div",{className:"flex justify-between",children:[_.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[_.jsx(Mi,{className:"w-5 h-5 inline-block mr-2"}),e.title]}),_.jsx(ee,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>o(e.id),children:_.jsx(Gn,{className:"w-5 h-5"})})]}),_.jsxs("div",{className:"flex justify-between items-end",children:[_.jsx("span",{children:Di({html:e.description})}),"restart"===e.action&&_.jsx(ET,{})]})]},e.id),t[5]=o,t[6]=e):e=t[6],a=r.map(e),t[2]=r,t[3]=o,t[4]=a}else a=t[4];return t[7]!==i||t[8]!==a?(l=_.jsx("div",{className:i,children:a}),t[7]=i,t[8]=a,t[9]=l):l=t[9],l},ET=()=>{const e=N.c(3),t=jh();let n,r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(hu,{className:"w-3 h-3 mr-2"}),e[0]=n):n=e[0],e[1]!==t?(r=_.jsxs(ee,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:t,children:[n,"Restart"]}),e[1]=t,e[2]=r):r=e[2],r};const jT=(e,t)=>function(e,t){const n=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,r=e=>{const t=e.match(n);if(!t)return null;const[,r,o,s,i]=t;return{major:Number.parseInt(r,10),minor:Number.parseInt(o,10),patch:Number.parseInt(s,10),preRelease:i||""}};try{const n=r(e),o=r(t);return n&&o?n.major!==o.major?n.major-o.major:n.minor!==o.minor?n.minor-o.minor:n.patch!==o.patch?n.patch-o.patch:""===n.preRelease&&""!==o.preRelease?1:""!==n.preRelease&&""===o.preRelease?-1:n.preRelease.localeCompare(o.preRelease):e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}catch{return e.localeCompare(t,void 0,{numeric:!0,sensitivity:"base"})}}(t,e);const _T=()=>{const e=N.c(66),{packageAlert:t}=Hc(),{clearPackageAlert:n}=Wc(),[r]=Ue();let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={},e[0]=o):o=e[0];const[s,i]=l.useState(o);if(null===t)return null;const a="pixi"!==r.package_management.manager;if(Gc(t)){let o,l,c,d,u,h,f,m,p,g;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[_.jsx(iu,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),e[1]=o):o=e[1],e[2]!==n||e[3]!==t.id?(l=()=>n(t.id),e[2]=n,e[3]=t.id,e[4]=l):l=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx(Gn,{className:"w-5 h-5"}),e[5]=c):c=e[5],e[6]!==l?(d=_.jsxs("div",{className:"flex justify-between",children:[o,_.jsx(ee,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:l,children:c})]}),e[6]=l,e[7]=d):d=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(u=_.jsx("p",{children:"The following packages were not found:"}),e[8]=u):u=e[8],e[9]!==s||e[10]!==a||e[11]!==t.packages){let n;e[13]!==s||e[14]!==a?(n=(e,t)=>_.jsxs("li",{className:"flex items-center gap-1 font-mono text-sm",children:[_.jsx(Kl,{size:"1rem"}),e,a&&_.jsx(MT,{value:s[e]??"latest",onChange:t=>i((n=>({...n,[e]:t}))),packageName:e})]},t),e[13]=s,e[14]=a,e[15]=n):n=e[15],h=t.packages.map(n),e[9]=s,e[10]=a,e[11]=t.packages,e[12]=h}else h=e[12];return e[16]!==h?(f=_.jsxs("div",{children:[u,_.jsx("ul",{className:"list-disc ml-4 mt-1",children:h})]}),e[16]=h,e[17]=f):f=e[17],e[18]!==n||e[19]!==s||e[20]!==t.id||e[21]!==t.isolated||e[22]!==t.packages||e[23]!==r.package_management.manager?(m=_.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:t.isolated?_.jsxs(_.Fragment,{children:[_.jsx(AT,{manager:r.package_management.manager,packages:t.packages,versions:s,clearPackageAlert:()=>n(t.id)}),!E()&&_.jsxs(_.Fragment,{children:[_.jsx("span",{className:"px-2 text-sm",children:"with"})," ",_.jsx(TT,{})]})]}):_.jsxs("p",{children:["If you set up a"," ",_.jsx(Ot,{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",children:"virtual environment"}),", marimo can install these packages for you."]})}),e[18]=n,e[19]=s,e[20]=t.id,e[21]=t.isolated,e[22]=t.packages,e[23]=r.package_management.manager,e[24]=m):m=e[24],e[25]!==f||e[26]!==m?(p=_.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[f,m]}),e[25]=f,e[26]=m,e[27]=p):p=e[27],e[28]!==d||e[29]!==p?(g=_.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:_.jsxs(Ti,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[d,p]})}),e[28]=d,e[29]=p,e[30]=g):g=e[30],g}if(qc(t)){let r;e[31]!==t.packages?(r=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:_.jsx(Td,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"};if("installed"===n)return{status:"installed",title:"All packages installed!",titleIcon:_.jsx(su,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"};return{status:"failed",title:"Some packages failed to install",titleIcon:_.jsx(iu,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(t.packages),e[31]=t.packages,e[32]=r):r=e[32];const{status:o,title:s,titleIcon:i,description:a}=r;"installed"===o&&setTimeout((()=>n(t.id)),1e4);const l="failed"===o?"danger":"info";let c,d,u,h,f;e[33]!==s||e[34]!==i?(c=_.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[i,s]}),e[33]=s,e[34]=i,e[35]=c):c=e[35],e[36]!==n||e[37]!==t.id?(d=()=>n(t.id),e[36]=n,e[37]=t.id,e[38]=d):d=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(u=_.jsx(Gn,{className:"w-5 h-5"}),e[39]=u):u=e[39],e[40]!==d?(h=_.jsx(ee,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:d,children:u}),e[40]=d,e[41]=h):h=e[41],e[42]!==c||e[43]!==h?(f=_.jsxs("div",{className:"flex justify-between",children:[c,h]}),e[42]=c,e[43]=h,e[44]=f):f=e[44];const m="installed"===o&&"text-accent-foreground";let p,g,y,b,x,v,w;if(e[45]!==m?(p=$t("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",m),e[45]=m,e[46]=p):p=e[46],e[47]!==a?(g=_.jsx("p",{children:a}),e[47]=a,e[48]=g):g=e[48],e[49]!==t.packages||e[50]!==o){let n;e[52]!==o?(n=(e,t)=>{const[n,r]=e;return _.jsxs("li",{className:$t("flex items-center gap-1 font-mono text-sm","installing"===r&&"font-semibold","failed"===r&&"text-destructive","installed"===r&&"text-accent-foreground","installed"===r&&"failed"===o&&"text-muted-foreground"),children:[_.jsx(IT,{status:r}),n]},t)},e[52]=o,e[53]=n):n=e[53],y=Object.entries(t.packages).map(n),e[49]=t.packages,e[50]=o,e[51]=y}else y=e[51];return e[54]!==y?(b=_.jsx("ul",{className:"list-disc ml-4 mt-1",children:y}),e[54]=y,e[55]=b):b=e[55],e[56]!==g||e[57]!==b?(x=_.jsxs("div",{children:[g,b]}),e[56]=g,e[57]=b,e[58]=x):x=e[58],e[59]!==x||e[60]!==p?(v=_.jsx("div",{className:p,children:x}),e[59]=x,e[60]=p,e[61]=v):v=e[61],e[62]!==v||e[63]!==l||e[64]!==f?(w=_.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:_.jsxs(Ti,{kind:l,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[f,v]})}),e[62]=v,e[63]=l,e[64]=f,e[65]=w):w=e[65],w}return O(t),null};const IT=e=>{const t=N.c(4),{status:n}=e;switch(n){case"queued":{let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(Kl,{size:"1rem"}),t[0]=e):e=t[0],e}case"installing":{let e;return t[1]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(Td,{size:"1rem"}),t[1]=e):e=t[1],e}case"installed":{let e;return t[2]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(pn,{size:"1rem"}),t[2]=e):e=t[2],e}case"failed":{let e;return t[3]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(Gn,{size:"1rem"}),t[3]=e):e=t[3],e}default:return O(n),null}},AT=e=>{const t=N.c(9),{manager:n,packages:r,versions:o,clearPackageAlert:s}=e;let i,a,l,c;return t[0]!==s||t[1]!==n||t[2]!==r||t[3]!==o?(i=async()=>{s();const e={...o};for(const t of r)e[t]=e[t]??"";await Fi({manager:n,versions:e}).catch(DT)},t[0]=s,t[1]=n,t[2]=r,t[3]=o,t[4]=i):i=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsx(Td,{className:"w-4 h-4 mr-2"}),l=_.jsx("span",{className:"font-semibold",children:"Install"}),t[5]=a,t[6]=l):(a=t[5],l=t[6]),t[7]!==i?(c=_.jsxs(ee,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:i,children:[a,l]}),t[7]=i,t[8]=c):c=t[8],c},TT=()=>{const e=N.c(16),[t,n]=Ue();let r,o;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=Zt(Oi),e[0]=r):r=e[0],e[1]!==t?(o={resolver:r,defaultValues:t},e[1]=t,e[2]=o):o=e[2];const s=Qt(o);let i;e[3]!==n?(i=async e=>{await Ve({config:e}).then((()=>{n(e)}))},e[3]=n,e[4]=i):i=e[4];const a=i;let l,c,d,u;return e[5]!==s||e[6]!==a?(l=s.handleSubmit(a),e[5]=s,e[6]=a,e[7]=l):l=e[7],e[8]!==s.control?(c=_.jsx("div",{className:"flex flex-col gap-3",children:_.jsx(Lt,{control:s.control,name:"package_management.manager",render:RT})}),e[8]=s.control,e[9]=c):c=e[9],e[10]!==l||e[11]!==c?(d=_.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]!==s||e[14]!==d?(u=_.jsx(Ri,{...s,children:d}),e[13]=s,e[14]=d,e[15]=u):u=e[15],u},MT=e=>{const t=N.c(21),{value:n,onChange:r,packageName:o}=e;let s,i;t[0]!==o?(s=async()=>{const e=await fetch(`https://pypi.org/pypi/${t=o,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(jT).slice(0,100)]},i=[o],t[0]=o,t[1]=s,t[2]=i):(s=t[1],i=t[2]);const{data:a,loading:l,error:c}=Pt(s,i);let d;t[3]!==a?(d=void 0===a?[]:a,t[3]=a,t[4]=d):d=t[4];const u=d;if(c){let e,o,s;return t[5]!==r?(e=e=>r(e.target.value),t[5]=r,t[6]=e):e=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsx("option",{value:"latest",children:"latest"}),t[7]=o):o=t[7],t[8]!==e||t[9]!==n?(s=_.jsx(ht,{content:"Failed to fetch package versions",children:_.jsx(Pi,{value:n,onChange:e,disabled:!0,className:"inline-flex ml-2",children:o})}),t[8]=e,t[9]=n,t[10]=s):s=t[10],s}let h,f,m;return t[11]!==r?(h=e=>r(e.target.value),t[11]=r,t[12]=h):h=t[12],t[13]!==u||t[14]!==l?(f=l?_.jsx("option",{value:"latest",children:"latest"}):u.map(PT),t[13]=u,t[14]=l,t[15]=f):f=t[15],t[16]!==l||t[17]!==h||t[18]!==f||t[19]!==n?(m=_.jsx(Pi,{value:n,onChange:h,disabled:l,className:"inline-flex ml-2",children:f}),t[16]=l,t[17]=h,t[18]=f,t[19]=n,t[20]=m):m=t[20],m};function DT(e){X.error(e)}function OT(e){return _.jsx("option",{value:e,children:e},e)}function RT(e){const{field:t}=e;return _.jsxs(Ft,{children:[_.jsx(Ut,{children:_.jsx(Pi,{"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:Li.map(OT)})}),_.jsx(Jt,{})]})}function PT(e){return _.jsx("option",{value:e,children:e},e)}const LT=e=>{let{transform:t}=e;return{...t,x:0}},FT={threshold:{x:0,y:.1}},zT=p.memo((e=>{const t=N.c(23),{children:n,multiColumn:r}=e,{dropCellOverCell:o,dropCellOverColumn:s,moveColumn:i,compactColumns:a}=V(),[c,d]=l.useState(null),[u,h]=l.useState(null),[f]=$e();let m;e:{if("columns"===f.width){m=zi.EMPTY;break e}let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[LT],t[0]=e):e=t[0],m=e}const p=m;let g,y;t[1]===Symbol.for("react.memo_cache_sentinel")?(g={activationConstraint:{distance:8}},t[1]=g):g=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(y={coordinateGetter:_S},t[2]=y):y=t[2];const b=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return l.useMemo((()=>[...t].filter((e=>null!=e))),[...t])}(Cw(xk,g),Cw(mk,y));let x;t[3]===Symbol.for("react.memo_cache_sentinel")?(x=e=>{d(e.active.id);const t=W();h(t.cellIds)},t[3]=x):x=t[3];const v=$(x);let w;t[4]!==u?(w=()=>{d(null),h(null)},t[4]=u,t[5]=w):w=t[5];const k=$(w);let S;t[6]!==c?(S=e=>{const t=e.droppableContainers.filter($T);if(c&&UT(c))return Mw({...e,droppableContainers:t});const n=(e=>{let{droppableContainers:t,droppableRects:n,pointerCoordinates:r}=e;if(!r)return[];const o=[];for(const s of t){const{id:e}=s,t=n.get(e);if(t&&Rw(r,t)){const n=Iw(t).reduce(((e,t)=>e+Ew(r,t)),0),i=Number((n/4).toFixed(4));o.push({id:e,data:{droppableContainer:s,value:i}})}}return o.sort(jw)})({...e,droppableContainers:t}),r=Aw(n.length>0?n:Ow({...e,droppableContainers:t}),"id");if(!r)return[];Rn(UT(r),`Expected column id. Got: ${r}`);const o=W().cellIds.get(r);if(Rn(o,`Expected column. Got: ${r}`),o&&0===o.topLevelIds.length)return[{id:r}];const s=new Set(o.topLevelIds),i=Mw({...e,droppableContainers:e.droppableContainers.filter((e=>e.id!==r&&s.has(e.id)))});if(i.length>0){const e=i[0].id;return Rn(BT(e),`Expected cell id. Got: ${e}`),[{id:e}]}return[]},t[6]=c,t[7]=S):S=t[7];const C=S;let E;t[8]!==o||t[9]!==s||t[10]!==i?(E=e=>{const{active:t,over:n}=e,r=null==n?void 0:n.id;if(null!=r&&t.id!==r){if(BT(t.id)){if(UT(r))return void s({cellId:t.id,columnId:r});if(BT(r))return void o({cellId:t.id,overCellId:r})}UT(t.id)&&UT(r)&&i({column:t.id,overColumn:r})}},t[8]=o,t[9]=s,t[10]=i,t[11]=E):E=t[11];const j=$(E);let I;t[12]!==a?(I=e=>{const{active:t,over:n}=e;null!==n&&t.id!==n.id&&a()},t[12]=a,t[13]=I):I=t[13];const A=$(I),T=r?C:Mw;let M;return t[14]!==n||t[15]!==k||t[16]!==A||t[17]!==j||t[18]!==v||t[19]!==p||t[20]!==b||t[21]!==T?(M=_.jsx(rS,{autoScroll:FT,sensors:b,collisionDetection:T,modifiers:p,onDragEnd:A,onDragStart:v,onDragCancel:k,onDragOver:j,children:n}),t[14]=n,t[15]=k,t[16]=A,t[17]=j,t[18]=v,t[19]=p,t[20]=b,t[21]=T,t[22]=M):M=t[22],M}));function BT(e){return"string"==typeof e&&!e.startsWith("tree_")}function UT(e){return"string"==typeof e&&e.startsWith("tree_")}function $T(e){return UT(e.id)}const VT=p.forwardRef(((e,t)=>{const n=N.c(62);let r,o,s,i,a,l;n[0]!==e?(({columnId:i,canDelete:r,canMoveLeft:o,canMoveRight:s,...a}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s,n[4]=i,n[5]=a):(r=n[1],o=n[2],s=n[3],i=n[4],a=n[5]),n[6]!==i?(l={id:i},n[6]=i,n[7]=l):l=n[7];const{attributes:c,listeners:d,setNodeRef:u,transform:h,transition:f,isDragging:m,isOver:p}=NS(l);let g;n[8]!==h?(g=h?Ds.Transform.toString({x:h.x,y:0,scaleX:1,scaleY:1}):void 0,n[8]=h,n[9]=g):g=n[9];const y=m?2:void 0;let b;n[10]!==g||n[11]!==y||n[12]!==f?(b={transform:g,transition:f,zIndex:y,position:"relative","--gutter-width":"50px"},n[10]=g,n[11]=y,n[12]=f,n[13]=b):b=n[13];const x=b,{deleteColumn:v,moveColumn:w,addColumn:k}=V();let S;n[14]===Symbol.for("react.memo_cache_sentinel")?(S=$t("h-full hover:bg-muted rounded-none"),n[14]=S):S=n[14];const C=S,E=WT;let j;n[15]!==i||n[16]!==w?(j=()=>w({column:i,overColumn:"_left_"}),n[15]=i,n[16]=w,n[17]=j):j=n[17];const I=!o;let A,T,M;n[18]===Symbol.for("react.memo_cache_sentinel")?(A=_.jsx(Ie,{className:"size-4"}),n[18]=A):A=n[18],n[19]!==j||n[20]!==I?(T=_.jsx(ht,{content:"Move column left",side:"top",delayDuration:300,children:_.jsx(ee,{variant:"text",size:"sm",className:C,onClick:j,disabled:I,children:A})}),n[19]=j,n[20]=I,n[21]=T):T=n[21],n[22]!==i||n[23]!==w?(M=()=>w({column:i,overColumn:"_right_"}),n[22]=i,n[23]=w,n[24]=M):M=n[24];const D=!s;let O,R,P,L,F,z,B,U;n[25]===Symbol.for("react.memo_cache_sentinel")?(O=_.jsx(Ae,{className:"size-4"}),n[25]=O):O=n[25],n[26]!==M||n[27]!==D?(R=_.jsx(ht,{content:"Move column right",side:"top",delayDuration:300,children:_.jsx(ee,{variant:"text",size:"sm",className:C,onClick:M,disabled:D,children:O})}),n[26]=M,n[27]=D,n[28]=R):R=n[28],n[29]!==c||n[30]!==d?(P=_.jsx("div",{className:"flex gap-2 h-full flex-grow active:bg-accent cursor-grab",...c,...d,"data-testid":"column-drag-button"}),n[29]=c,n[30]=d,n[31]=P):P=n[31],n[32]!==r||n[33]!==i||n[34]!==v?(L=r&&_.jsx(ht,{content:"Delete column",side:"top",delayDuration:300,children:_.jsx(ee,{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:()=>v({columnId:i}),children:_.jsx(Gn,{className:"size-4"})})}),n[32]=r,n[33]=i,n[34]=v,n[35]=L):L=n[35],n[36]!==k||n[37]!==i?(F=()=>{k({columnId:i}),requestAnimationFrame(E)},n[36]=k,n[37]=i,n[38]=F):F=n[38],n[39]===Symbol.for("react.memo_cache_sentinel")?(z=_.jsx(ss,{className:"size-4"}),n[39]=z):z=n[39],n[40]!==F?(B=_.jsx(ht,{content:"Add column",side:"top",delayDuration:300,children:_.jsx(ee,{variant:"text",size:"sm",className:C,onClick:F,children:z})}),n[40]=F,n[41]=B):B=n[41],n[42]!==R||n[43]!==P||n[44]!==L||n[45]!==B||n[46]!==T?(U=_.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:[T,R,P,L,B]}),n[42]=R,n[43]=P,n[44]=L,n[45]=B,n[46]=T,n[47]=U):U=n[47];const $=U;let H;n[48]!==t||n[49]!==u?(H=e=>{AS(t,u)(e)},n[48]=t,n[49]=u,n[50]=H):H=n[50];const W=m?"":a.className,G=m?"z-20":"z-1 hover:z-10 focus-within:z-10",q=p&&"bg-accent/20";let Y,K;return n[51]!==W||n[52]!==G||n[53]!==q?(Y=$t(W,G,q),n[51]=W,n[52]=G,n[53]=q,n[54]=Y):Y=n[54],n[55]!==$||n[56]!==m||n[57]!==a||n[58]!==x||n[59]!==H||n[60]!==Y?(K=_.jsxs("div",{tabIndex:-1,ref:H,...a,style:x,"data-is-dragging":m,className:Y,children:[$,a.children]}),n[55]=$,n[56]=m,n[57]=a,n[58]=x,n[59]=H,n[60]=Y,n[61]=K):K=n[61],K}));VT.displayName="SortableColumn";const HT=l.memo(VT);function WT(){const e=document.getElementById("App");e&&e.scrollTo({left:e.scrollLeft+1e3,behavior:"smooth"})}const{getColumnWidth:GT,saveColumnWidth:qT}=Bi,YT=l.memo((e=>{const t=N.c(14),n=l.useRef(null);let r;t[0]!==e.children||t[1]!==e.index||t[2]!==e.width?(r="columns"===e.width?_.jsx(KT,{startingWidth:GT(e.index),onResize:t=>{qT(e.index,t)},children:e.children}):_.jsx("div",{className:"flex flex-col gap-5",children:e.children}),t[0]=e.children,t[1]=e.index,t[2]=e.width,t[3]=r):r=t[3];const o=r;if("columns"===e.width){let r;return t[4]!==o||t[5]!==e.canDelete||t[6]!==e.canMoveLeft||t[7]!==e.canMoveRight||t[8]!==e.columnId||t[9]!==e.footer?(r=_.jsxs(HT,{tabIndex:-1,ref:n,canDelete:e.canDelete,columnId:e.columnId,canMoveLeft:e.canMoveLeft,canMoveRight:e.canMoveRight,className:"group/column",children:[o,e.footer]}),t[4]=o,t[5]=e.canDelete,t[6]=e.canMoveLeft,t[7]=e.canMoveRight,t[8]=e.columnId,t[9]=e.footer,t[10]=r):r=t[10],r}let s;return t[11]!==o||t[12]!==e.footer?(s=_.jsxs(_.Fragment,{children:[o,e.footer]}),t[11]=o,t[12]=e.footer,t[13]=s):s=t[13],s}));YT.displayName="Column";const KT=e=>{const t=N.c(15),{startingWidth:n,onResize:r,children:o}=e;let s;t[0]!==r||t[1]!==n?(s={startingWidth:n,onResize:r},t[0]=r,t[1]=n,t[2]=s):s=t[2];const{resizableDivRef:i,handleRefs:a,style:c}=(e=>{const t=N.c(6),{onResize:n,startingWidth:r}=e,o=l.useRef(null),s=l.useRef(null),i=l.useRef(null);let a,c,d;t[0]!==n?(a=()=>{const e=o.current,t=s.current,r=i.current;if(!e||!t&&!r)return;let a,l,c,d;a=Number.parseInt(window.getComputedStyle(e).width),l=0,c=!1,d=null;const u=t=>{if(!e||!c||!d)return;const n=t.clientX-l;l=t.clientX,a="left"===d?a-n:a+n,e.style.width=`${a}px`},h=()=>{c&&(null==n||n(a),c=!1,d=null),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)},f=(e,t)=>{e.preventDefault(),c=!0,d=t,l=e.clientX,document.addEventListener("mousemove",u),document.addEventListener("mouseup",h)},m=e=>f(e,"left"),p=e=>f(e,"right");return t&&t.addEventListener("mousedown",m),r&&r.addEventListener("mousedown",p),()=>{t&&t.removeEventListener("mousedown",m),r&&r.removeEventListener("mousedown",p),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",h)}},c=[n],t[0]=n,t[1]=a,t[2]=c):(a=t[1],c=t[2]),l.useEffect(a,c),t[3]===Symbol.for("react.memo_cache_sentinel")?(d={left:s,right:i},t[3]=d):d=t[3];const u="contentWidth"===r?"var(--content-width-medium)":`${r}px`;let h;return t[4]!==u?(h={resizableDivRef:o,handleRefs:d,style:{width:u}},t[4]=u,t[5]=h):h=t[5],h})(s),d=JT;let u,h,f,m;return t[3]!==a.left?(u=d(a.left,!1),t[3]=a.left,t[4]=u):u=t[4],t[5]!==o||t[6]!==i||t[7]!==c?(h=_.jsx("div",{ref:i,className:"flex flex-col gap-5 box-content min-h-[100px] px-11 py-6 min-w-[500px] z-1",style:c,children:o}),t[5]=o,t[6]=i,t[7]=c,t[8]=h):h=t[8],t[9]!==a.right?(f=d(a.right,!0),t[9]=a.right,t[10]=f):f=t[10],t[11]!==u||t[12]!==h||t[13]!==f?(m=_.jsxs("div",{className:"flex flex-row",children:[u,h,f]}),t[11]=u,t[12]=h,t[13]=f,t[14]=m):m=t[14],m};function JT(e,t){const n=t?"group-hover":"hover";return _.jsx("div",{ref:e,className:`w-1 cursor-col-resize transition-colors duration-200 z-10\n relative before:content-[''] before:absolute before:inset-y-0 before:-left-[4px] before:right-[-4px] before:w-[11px] before:z-[-1]\n ${n}/column:bg-[var(--slate-3)] dark:${n}/column:bg-[var(--slate-5)]\n ${n}/column:hover:bg-primary/60 dark:${n}/column:hover:bg-primary/60`})}const XT=e=>{const t=N.c(8),n=de(Ui),r="columns"===e.appConfig.width;let o,s,i;return t[0]!==e?(o=_.jsx(ZT,{...e}),t[0]=e,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(s=_.jsx(bS,{id:"column-container",items:n,strategy:hS,children:o}),t[2]=n,t[3]=o,t[4]=s):s=t[4],t[5]!==r||t[6]!==s?(i=_.jsx(zT,{multiColumn:r,children:s}),t[5]=r,t[6]=s,t[7]=i):i=t[7],i},ZT=e=>{const t=N.c(47),{mode:n,userConfig:r,appConfig:o,connStatus:s}=e,i=yr(),a=V(),{theme:c}=Be(),{toggleSidebarPanel:d}=ln(),{invisible:u}=Yc(i.cellIds.idLength,n);oc("global.focusTop",a.focusTopCell),oc("global.focusBottom",a.focusBottomCell),oc("global.toggleSidebar",d),oc("global.foldCode",a.foldAll),oc("global.unfoldCode",a.unfoldAll),oc("global.formatAll",tM),oc("cell.hideCode",Rt.NOOP),oc("cell.format",Rt.NOOP);const h=sh(),f=a.scrollToTarget;let m,p,g,y,b,x,v,w,k,S,C,E,j,I;if(t[0]!==i.scrollKey||t[1]!==f?(m=()=>{null!==i.scrollKey&&f()},t[0]=i.scrollKey,t[1]=f,t[2]=m):m=t[2],t[3]!==i.cellIds||t[4]!==i.scrollKey||t[5]!==f?(p=[i.cellIds,i.scrollKey,f],t[3]=i.cellIds,t[4]=i.scrollKey,t[5]=f,t[6]=p):p=t[6],l.useEffect(m,p),t[7]!==a||t[8]!==o||t[9]!==s||t[10]!==u||t[11]!==n||t[12]!==i||t[13]!==h||t[14]!==c||t[15]!==r){const e=i.cellIds.getColumns();let l;t[25]!==i.cellIds?(l=i.cellIds.hasOnlyOneId(),t[25]=i.cellIds,t[26]=l):l=t[26];const d=l;let f;t[27]!==i.cellIds.inOrderIds?(f=i.cellIds.inOrderIds.includes(vi),t[27]=i.cellIds.inOrderIds,t[28]=f):f=t[28];const m=f;g=Kc,v="pb-[40vh]",w=u,k=o,S="pr-4",t[29]===Symbol.for("react.memo_cache_sentinel")?(C=_.jsx(_T,{}),t[29]=C):C=t[29],t[30]!==o.width?(y=_.jsx(NT,{width:o.width}),t[30]=o.width,t[31]=y):y=t[31];const p="columns"===o.width&&"grid grid-flow-col auto-cols-min gap-6";t[32]!==p?(b=$t(p),t[32]=p,t[33]=b):b=t[33],x=e.map(((t,l)=>_.jsx(QT,{column:t,index:l,columnsLength:e.length,appConfig:o,notebook:i,mode:n,userConfig:r,connStatus:s,actions:a,theme:c,hasOnlyOneCell:d,invisible:u,hasSetupCell:m,onDeleteCell:h},t.id))),t[7]=a,t[8]=o,t[9]=s,t[10]=u,t[11]=n,t[12]=i,t[13]=h,t[14]=c,t[15]=r,t[16]=g,t[17]=y,t[18]=b,t[19]=x,t[20]=v,t[21]=w,t[22]=k,t[23]=S,t[24]=C}else g=t[16],y=t[17],b=t[18],x=t[19],v=t[20],w=t[21],k=t[22],S=t[23],C=t[24];return t[34]!==b||t[35]!==x?(E=_.jsx("div",{className:b,children:x}),t[34]=b,t[35]=x,t[36]=E):E=t[36],t[37]===Symbol.for("react.memo_cache_sentinel")?(j=_.jsx(Jc,{}),t[37]=j):j=t[37],t[38]!==g||t[39]!==y||t[40]!==E||t[41]!==v||t[42]!==w||t[43]!==k||t[44]!==S||t[45]!==C?(I=_.jsxs(g,{className:v,invisible:w,appConfig:k,innerClassName:S,children:[C,y,E,j]}),t[38]=g,t[39]=y,t[40]=E,t[41]=v,t[42]=w,t[43]=k,t[44]=S,t[45]=C,t[46]=I):I=t[46],I},QT=e=>{const t=N.c(42),{column:n,index:r,columnsLength:o,appConfig:s,notebook:i,mode:a,userConfig:l,connStatus:c,actions:d,theme:u,hasOnlyOneCell:h,invisible:f,hasSetupCell:m,onDeleteCell:p}=e,g=c.state!==pt.OPEN,y=n.id,b=r>0,x=r<o-1,v=s.width,w=o>1,k=n.id,S="columns"===s.width&&"opacity-0 group-hover/column:opacity-100";let C,E;t[0]!==S?(C=$t(S),t[0]=S,t[1]=C):C=t[1],t[2]!==n.id||t[3]!==C?(E=_.jsx(eM,{columnId:k,className:C}),t[2]=n.id,t[3]=C,t[4]=E):E=t[4];const j=`column-${r+1}`,I=n.topLevelIds;let A,T,M,D;return t[5]!==d||t[6]!==g||t[7]!==m||t[8]!==r||t[9]!==f||t[10]!==a||t[11]!==i||t[12]!==p||t[13]!==u||t[14]!==l?(A=0===r&&m&&_.jsx(CT,{theme:u,showPlaceholder:!1,allowFocus:!f,...i.cellData[vi],...i.cellRuntime[vi],...d,runElapsedTimeMs:i.cellRuntime[vi].runElapsedTimeMs??i.cellData[vi].lastExecutionTime,canDelete:!0,mode:a,appClosed:g,ref:i.cellHandles[vi],userConfig:l,isCollapsed:!1,collapseCount:0,canMoveX:!1,actions:d,deleteCell:p},vi),t[5]=d,t[6]=g,t[7]=m,t[8]=r,t[9]=f,t[10]=a,t[11]=i,t[12]=p,t[13]=u,t[14]=l,t[15]=A):A=t[15],t[16]!==d||t[17]!==g||t[18]!==s.width||t[19]!==n||t[20]!==h||t[21]!==f||t[22]!==a||t[23]!==i||t[24]!==p||t[25]!==u||t[26]!==l?(T=n.topLevelIds.map((e=>{if(e===vi)return null;const t=i.cellData[e],r=i.cellRuntime[e];return _.jsx(CT,{theme:u,showPlaceholder:h,allowFocus:!f,...t,...r,runElapsedTimeMs:r.runElapsedTimeMs??t.lastExecutionTime,canDelete:!h,mode:a,appClosed:g,ref:i.cellHandles[e],userConfig:l,config:t.config,name:t.name,isCollapsed:n.isCollapsed(e),collapseCount:n.getCount(e),canMoveX:"columns"===s.width,actions:d,deleteCell:p},t.id.toString())})),t[16]=d,t[17]=g,t[18]=s.width,t[19]=n,t[20]=h,t[21]=f,t[22]=a,t[23]=i,t[24]=p,t[25]=u,t[26]=l,t[27]=T):T=t[27],t[28]!==n.topLevelIds||t[29]!==j||t[30]!==A||t[31]!==T?(M=_.jsxs(bS,{id:j,items:I,strategy:pS,children:[A,T]}),t[28]=n.topLevelIds,t[29]=j,t[30]=A,t[31]=T,t[32]=M):M=t[32],t[33]!==s.width||t[34]!==n.id||t[35]!==r||t[36]!==M||t[37]!==b||t[38]!==x||t[39]!==w||t[40]!==E?(D=_.jsx(YT,{columnId:y,index:r,canMoveLeft:b,canMoveRight:x,width:v,canDelete:w,footer:E,children:M}),t[33]=s.width,t[34]=n.id,t[35]=r,t[36]=M,t[37]=b,t[38]=x,t[39]=w,t[40]=E,t[41]=D):D=t[41],D},eM=e=>{const t=N.c(17),{columnId:n,className:r}=e,{createNewCell:o}=V(),s=de(me),[i,a]=$i(!1),l=de(fe);let c;t[0]===Symbol.for("react.memo_cache_sentinel")?(c=$t("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]=c):c=t[0];const d=c;let u;t[1]!==l||t[2]!==s||t[3]!==n||t[4]!==o||t[5]!==i||t[6]!==a.toggle?(u=()=>i?_.jsx(Vi,{onClose:a.toggle}):_.jsxs(_.Fragment,{children:[_.jsxs(ee,{className:d,variant:"text",size:"sm",onClick:()=>o({cellId:{type:"__end__",columnId:n},before:!1}),children:[_.jsx(bu,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),_.jsxs(ee,{className:d,variant:"text",size:"sm",onClick:()=>{ah(s,o),o({cellId:{type:"__end__",columnId:n},before:!1,code:(new sn).defaultCode})},children:[_.jsx(wu,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),_.jsxs(ee,{className:d,variant:"text",size:"sm",onClick:()=>{ah(s,o),o({cellId:{type:"__end__",columnId:n},before:!1,code:(new is).getDefaultCode()})},children:[_.jsx(Ne,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]}),_.jsx(ht,{content:l?null:_.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:_.jsxs(ee,{className:d,variant:"text",size:"sm",disabled:!l,onClick:a.toggle,children:[_.jsx(ye,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]}),t[1]=l,t[2]=s,t[3]=n,t[4]=o,t[5]=i,t[6]=a.toggle,t[7]=u):u=t[7];const h=u,f=!i&&"w-fit",m=i&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]";let p,g,y;return t[8]!==r||t[9]!==f||t[10]!==m?(p=$t("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",f,m,r),t[8]=r,t[9]=f,t[10]=m,t[11]=p):p=t[11],t[12]!==h?(g=h(),t[12]=h,t[13]=g):g=t[13],t[14]!==p||t[15]!==g?(y=_.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:_.jsx("div",{className:p,children:g})}),t[14]=p,t[15]=g,t[16]=y):y=t[16],y};function tM(){pr()}const nM=e=>{const t=N.c(65),{userConfig:n,appConfig:r,hideControls:o}=e,s=void 0!==o&&o;Hi(Ji,yp);const{setCells:i,mergeAllColumns:a,collapseAllCells:c,expandAllCells:d}=V(),u=de(kt),h=de(Wi),f=de(Gi),m=an(),p=he(Gm),g="edit"===u.mode,y="present"===u.mode,b=de(qi);let x;t[0]===Symbol.for("react.memo_cache_sentinel")?(x=[],t[0]=x):x=t[0],l.useEffect(oM,x);const v=n.runtime.auto_instantiate;let w,k,S;t[1]!==i||t[2]!==p?(w=(e,t)=>{i(e);const n=e.map(sM),r=e.map(iM),o=e.map(aM);p({names:n,codes:r,configs:o,layout:t})},t[1]=i,t[2]=p,t[3]=w):w=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(k=ii(),t[4]=k):k=t[4],t[5]!==w||t[6]!==n.runtime.auto_instantiate?(S={autoInstantiate:v,setCells:w,sessionId:k},t[5]=w,t[6]=n.runtime.auto_instantiate,t[7]=S):S=t[7];const{connection:C}=Xc(S);let E,j;t[8]!==r.app_title||t[9]!==m?(E=()=>{document.title=r.app_title||Et.basename(m??"")||"Untitled Notebook"},j=[r.app_title,m],t[8]=r.app_title,t[9]=m,t[10]=E,t[11]=j):(E=t[10],j=t[11]),l.useEffect(E,j);const I=_s(r.width);let A,T;t[12]!==r.width||t[13]!==a||t[14]!==I?(A=()=>{"columns"===I&&"columns"!==r.width&&a()},t[12]=r.width,t[13]=a,t[14]=I,t[15]=A):A=t[15],t[16]!==r.width||t[17]!==a||t[18]!==h||t[19]!==I?(T=[r.width,I,a,h],t[16]=r.width,t[17]=a,t[18]=h,t[19]=I,t[20]=T):T=t[20],l.useEffect(A,T);const M=function(){const e=N.c(2),t=Zu();let n;return e[0]!==t?(n=()=>t(H(W())),e[0]=t,e[1]=n):n=e[1],$(n)}(),D=Xu(),O=Ih();let R,P,L,F,z,B;t[21]!==M?(R=()=>{M()},t[21]=M,t[22]=R):R=t[22],oc("global.runStale",R),oc("global.interrupt",lM),t[23]!==O?(P=()=>{O()},t[23]=O,t[24]=P):P=t[24],oc("global.hideCode",P),t[25]!==D?(L=()=>{D()},t[25]=D,t[26]=L):L=t[26],oc("global.runAll",L),t[27]!==c?(F=()=>{c()},t[27]=c,t[28]=F):F=t[28],oc("global.collapseAllSections",F),t[29]!==d?(z=()=>{d()},t[29]=d,t[30]=z):z=t[30],oc("global.expandAllSections",z),t[31]!==r||t[32]!==C||t[33]!==n||t[34]!==u.mode?(B=_.jsx(XT,{connStatus:C,mode:u.mode,userConfig:n,appConfig:r}),t[31]=r,t[32]=C,t[33]=n,t[34]=u.mode,t[35]=B):B=t[35];const U=B,G=r.width;let q,Y,K,J,X,Z,Q;return t[36]===Symbol.for("react.memo_cache_sentinel")?(q=$t("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),t[36]=q):q=t[36],t[37]!==m||t[38]!==g?(Y=g&&_.jsx("div",{className:"flex items-center justify-center container",children:_.jsx(pp,{filename:m})}),t[37]=m,t[38]=g,t[39]=Y):Y=t[39],t[40]!==C||t[41]!==Y?(K=_.jsx(ed,{connection:C,className:q,children:Y}),t[40]=C,t[41]=Y,t[42]=K):K=t[42],t[43]!==r||t[44]!==U||t[45]!==f||t[46]!==u.mode?(J=f&&_.jsx(Zc,{appConfig:r,mode:u.mode,children:U}),t[43]=r,t[44]=U,t[45]=f,t[46]=u.mode,t[47]=J):J=t[47],t[48]!==r.width||t[49]!==C||t[50]!==b||t[51]!==K||t[52]!==J?(X=_.jsxs(td,{connection:C,isRunning:b,width:G,children:[K,J]}),t[48]=r.width,t[49]=C,t[50]=b,t[51]=K,t[52]=J,t[53]=X):X=t[53],t[54]!==r||t[55]!==C||t[56]!==s||t[57]!==y||t[58]!==b||t[59]!==M||t[60]!==O?(Z=!s&&_.jsx(Yi,{children:_.jsx(dp,{presenting:y,onTogglePresenting:O,onInterrupt:bi,onRun:M,closed:C.state===pt.CLOSED,running:b,appConfig:r})}),t[54]=r,t[55]=C,t[56]=s,t[57]=y,t[58]=b,t[59]=M,t[60]=O,t[61]=Z):Z=t[61],t[62]!==X||t[63]!==Z?(Q=_.jsxs(_.Fragment,{children:[X,Z]}),t[62]=X,t[63]=Z,t[64]=Q):Q=t[64],Q};function rM(){Qc.INSTANCE.stop()}function oM(){return Qc.INSTANCE.start(Ki),rM}function sM(e){return e.name}function iM(e){return e.code}function aM(e){return e.config}function lM(){bi()}const cM=l.createContext(null);cM.displayName="PanelGroupContext";const dM="data-panel-group",uM="data-panel-group-direction",hM="data-panel-group-id",fM="data-panel",mM="data-panel-collapsible",pM="data-panel-id",gM="data-panel-size",yM="data-resize-handle",bM="data-resize-handle-active",xM="data-panel-resize-handle-enabled",vM="data-panel-resize-handle-id",wM="data-resize-handle-state",kM=l.useLayoutEffect,SM=Xi["useId".toString()],CM="function"==typeof SM?SM:()=>null;let NM=0;function EM(e=null){const t=CM(),n=l.useRef(e||t||null);return null===n.current&&(n.current=""+NM++),null!=e?e:n.current}function jM({children:e,className:t="",collapsedSize:n,collapsible:r,defaultSize:o,forwardedRef:s,id:i,maxSize:a,minSize:c,onCollapse:d,onExpand:u,onResize:h,order:f,style:m,tagName:p="div",...g}){const y=l.useContext(cM);if(null===y)throw Error("Panel components must be rendered within a PanelGroup container");const{collapsePanel:b,expandPanel:x,getPanelSize:v,getPanelStyle:w,groupId:k,isPanelCollapsed:S,reevaluatePanelConstraints:C,registerPanel:N,resizePanel:E,unregisterPanel:j}=y,_=EM(i),I=l.useRef({callbacks:{onCollapse:d,onExpand:u,onResize:h},constraints:{collapsedSize:n,collapsible:r,defaultSize:o,maxSize:a,minSize:c},id:_,idIsFromProps:void 0!==i,order:f});l.useRef({didLogMissingDefaultSizeWarning:!1}),kM((()=>{const{callbacks:e,constraints:t}=I.current,s={...t};I.current.id=_,I.current.idIsFromProps=void 0!==i,I.current.order=f,e.onCollapse=d,e.onExpand=u,e.onResize=h,t.collapsedSize=n,t.collapsible=r,t.defaultSize=o,t.maxSize=a,t.minSize=c,s.collapsedSize===t.collapsedSize&&s.collapsible===t.collapsible&&s.maxSize===t.maxSize&&s.minSize===t.minSize||C(I.current,s)})),kM((()=>{const e=I.current;return N(e),()=>{j(e)}}),[f,_,N,j]),l.useImperativeHandle(s,(()=>({collapse:()=>{b(I.current)},expand:e=>{x(I.current,e)},getId:()=>_,getSize:()=>v(I.current),isCollapsed:()=>S(I.current),isExpanded:()=>!S(I.current),resize:e=>{E(I.current,e)}})),[b,x,v,S,_,E]);const A=w(I.current,o);return l.createElement(p,{...g,children:e,className:t,id:_,style:{...A,...m},[hM]:k,[fM]:"",[mM]:r||void 0,[pM]:_,[gM]:parseFloat(""+A.flexGrow).toFixed(1)})}const _M=l.forwardRef(((e,t)=>l.createElement(jM,{...e,forwardedRef:t})));jM.displayName="Panel",_M.displayName="forwardRef(Panel)";let IM=null,AM=-1,TM=null;function MM(e,t){var n,r;const o=function(e,t){if(t){const e=!!(t&WM),n=!!(t&GM);if(t&VM)return e?"se-resize":n?"ne-resize":"e-resize";if(t&HM)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);if(IM!==o){var s;if(IM=o,null===TM&&(TM=document.createElement("style"),document.head.appendChild(TM)),AM>=0)null===(s=TM.sheet)||void 0===s||s.removeRule(AM);AM=null!==(n=null===(r=TM.sheet)||void 0===r?void 0:r.insertRule(`*{cursor: ${o} !important;}`))&&void 0!==n?n:-1}}function DM(e){return"keydown"===e.type}function OM(e){return e.type.startsWith("pointer")}function RM(e){return e.type.startsWith("mouse")}function PM(e){if(OM(e)){if(e.isPrimary)return{x:e.clientX,y:e.clientY}}else if(RM(e))return{x:e.clientX,y:e.clientY};return{x:1/0,y:1/0}}const LM=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function FM(e){const t=getComputedStyle(e);return"fixed"===t.position||(!("auto"===t.zIndex||"static"===t.position&&!function(e){var t;const n=getComputedStyle(null!==(t=$M(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||(!!LM.test(t.willChange)||"touch"===t.webkitOverflowScrolling)))))))))}function zM(e){let t=e.length;for(;t--;){const n=e[t];if(cD(n,"Missing node"),FM(n))return n}return null}function BM(e){return e&&Number(getComputedStyle(e).zIndex)||0}function UM(e){const t=[];for(;e;)t.push(e),e=$M(e);return t}function $M(e){const{parentNode:t}=e;return t&&t instanceof ShadowRoot?t.host:t}const VM=1,HM=2,WM=4,GM=8,qM="coarse"===function(){if("function"==typeof matchMedia)return matchMedia("(pointer:coarse)").matches?"coarse":"fine"}();let YM=[],KM=!1,JM=new Map,XM=new Map;const ZM=new Set;function QM(e){const{target:t}=e,{x:n,y:r}=PM(e);KM=!0,rD({target:t,x:n,y:r}),aD(),YM.length>0&&(lD("down",e),e.preventDefault(),nD(t)||e.stopImmediatePropagation())}function eD(e){const{x:t,y:n}=PM(e);if(KM&&0===e.buttons&&(KM=!1,lD("up",e)),!KM){const{target:r}=e;rD({target:r,x:t,y:n})}lD("move",e),sD(),YM.length>0&&e.preventDefault()}function tD(e){const{target:t}=e,{x:n,y:r}=PM(e);XM.clear(),KM=!1,YM.length>0&&(e.preventDefault(),nD(t)||e.stopImmediatePropagation()),lD("up",e),rD({target:t,x:n,y:r}),sD(),aD()}function nD(e){let t=e;for(;t;){if(t.hasAttribute(yM))return!0;t=t.parentElement}return!1}function rD({target:e,x:t,y:n}){YM.splice(0);let r=null;(e instanceof HTMLElement||e instanceof SVGElement)&&(r=e),ZM.forEach((e=>{const{element:o,hitAreaMargins:s}=e,i=o.getBoundingClientRect(),{bottom:a,left:l,right:c,top:d}=i,u=qM?s.coarse:s.fine;if(t>=l-u&&t<=c+u&&n>=d-u&&n<=a+u){if(null!==r&&document.contains(r)&&o!==r&&!o.contains(r)&&!r.contains(o)&&function(e,t){if(e===t)throw new Error("Cannot compare node with itself");const n={a:UM(e),b:UM(t)};let r;for(;n.a.at(-1)===n.b.at(-1);)e=n.a.pop(),t=n.b.pop(),r=e;cD(r,"Stacking order can only be calculated for elements with a common ancestor");const o=BM(zM(n.a)),s=BM(zM(n.b));if(o===s){const e=r.childNodes,t={a:n.a.at(-1),b:n.b.at(-1)};let o=e.length;for(;o--;){const n=e[o];if(n===t.a)return 1;if(n===t.b)return-1}}return Math.sign(o-s)}(r,o)>0){let e=r,t=!1;for(;e&&!e.contains(o);){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}YM.push(e)}var h,f}))}function oD(e,t){XM.set(e,t)}function sD(){let e=!1,t=!1;YM.forEach((n=>{const{direction:r}=n;"horizontal"===r?e=!0:t=!0}));let n=0;XM.forEach((e=>{n|=e})),e&&t?MM("intersection",n):e?MM("horizontal",n):t?MM("vertical",n):null!==TM&&(document.head.removeChild(TM),IM=null,TM=null,AM=-1)}let iD=new AbortController;function aD(){iD.abort(),iD=new AbortController;const e={capture:!0,signal:iD.signal};ZM.size&&(KM?(YM.length>0&&JM.forEach(((t,n)=>{const{body:r}=n;t>0&&(r.addEventListener("contextmenu",tD,e),r.addEventListener("pointerleave",eD,e),r.addEventListener("pointermove",eD,e))})),window.addEventListener("pointerup",tD,e),window.addEventListener("pointercancel",tD,e)):JM.forEach(((t,n)=>{const{body:r}=n;t>0&&(r.addEventListener("pointerdown",QM,e),r.addEventListener("pointermove",eD,e))})))}function lD(e,t){ZM.forEach((n=>{const{setResizeHandlerState:r}=n,o=YM.includes(n);r(e,o,t)}))}function cD(e,t){if(!e)throw console.error(t),Error(t)}function dD(e,t,n=10){return e.toFixed(n)===t.toFixed(n)?0:e>t?1:-1}function uD(e,t,n=10){return 0===dD(e,t,n)}function hD(e,t,n){return 0===dD(e,t,n)}function fD({panelConstraints:e,panelIndex:t,size:n}){const r=e[t];cD(null!=r,`Panel constraints not found for index ${t}`);let{collapsedSize:o=0,collapsible:s,maxSize:i=100,minSize:a=0}=r;if(dD(n,a)<0)if(s){n=dD(n,(o+a)/2)<0?o:a}else n=a;return n=Math.min(i,n),n=parseFloat(n.toFixed(10))}function mD({delta:e,initialLayout:t,panelConstraints:n,pivotIndices:r,prevLayout:o,trigger:s}){if(hD(e,0))return t;const i=[...t],[a,l]=r;cD(null!=a,"Invalid first pivot index"),cD(null!=l,"Invalid second pivot index");let c=0;if("keyboard"===s){{const r=e<0?l:a,o=n[r];cD(o,`Panel constraints not found for index ${r}`);const{collapsedSize:s=0,collapsible:i,minSize:c=0}=o;if(i){const n=t[r];if(cD(null!=n,`Previous layout not found for panel index ${r}`),hD(n,s)){const t=c-n;dD(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}{const r=e<0?a:l,o=n[r];cD(o,`No panel constraints found for index ${r}`);const{collapsedSize:s=0,collapsible:i,minSize:c=0}=o;if(i){const n=t[r];if(cD(null!=n,`Previous layout not found for panel index ${r}`),hD(n,c)){const t=n-s;dD(t,Math.abs(e))>0&&(e=e<0?0-t:t)}}}}{const r=e<0?1:-1;let o=e<0?l:a,s=0;for(;;){const e=t[o];cD(null!=e,`Previous layout not found for panel index ${o}`);if(s+=fD({panelConstraints:n,panelIndex:o,size:100})-e,o+=r,o<0||o>=n.length)break}const i=Math.min(Math.abs(e),Math.abs(s));e=e<0?0-i:i}{let r=e<0?a:l;for(;r>=0&&r<n.length;){const o=Math.abs(e)-Math.abs(c),s=t[r];cD(null!=s,`Previous layout not found for panel index ${r}`);const a=fD({panelConstraints:n,panelIndex:r,size:s-o});if(!hD(s,a)&&(c+=s-a,i[r]=a,c.toPrecision(3).localeCompare(Math.abs(e).toPrecision(3),void 0,{numeric:!0})>=0))break;e<0?r--:r++}}if(function(e,t,n){if(e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!hD(e[r],t[r],n))return!1;return!0}(o,i))return o;{const r=e<0?l:a,o=t[r];cD(null!=o,`Previous layout not found for panel index ${r}`);const s=o+c,d=fD({panelConstraints:n,panelIndex:r,size:s});if(i[r]=d,!hD(d,s)){let t=s-d;let r=e<0?l:a;for(;r>=0&&r<n.length;){const o=i[r];cD(null!=o,`Previous layout not found for panel index ${r}`);const s=fD({panelConstraints:n,panelIndex:r,size:o+t});if(hD(o,s)||(t-=s-o,i[r]=s),hD(t,0))break;e>0?r--:r++}}}return hD(i.reduce(((e,t)=>t+e),0),100)?i:o}function pD({layout:e,panelsArray:t,pivotIndices:n}){let r=0,o=100,s=0,i=0;const a=n[0];cD(null!=a,"No pivot index found"),t.forEach(((e,t)=>{const{constraints:n}=e,{maxSize:l=100,minSize:c=0}=n;t===a?(r=c,o=l):(s+=c,i+=l)}));return{valueMax:Math.min(o,100-s),valueMin:Math.max(r,100-i),valueNow:e[a]}}function gD(e,t=document){return Array.from(t.querySelectorAll(`[${vM}][data-panel-group-id="${e}"]`))}function yD(e,t,n=document){const r=gD(e,n).findIndex((e=>e.getAttribute(vM)===t));return null!=r?r:null}function bD(e,t,n){const r=yD(e,t,n);return null!=r?[r,r+1]:[-1,-1]}function xD(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 r=t.querySelector(`[data-panel-group][data-panel-group-id="${e}"]`);return r||null}function vD(e,t=document){const n=t.querySelector(`[${vM}="${e}"]`);return n||null}function wD({committedValuesRef:e,eagerValuesRef:t,groupId:n,layout:r,panelDataArray:o,panelGroupElement:s,setLayout:i}){l.useRef({didWarnAboutMissingResizeHandle:!1}),kM((()=>{if(!s)return;const e=gD(n,s);for(let t=0;t<o.length-1;t++){const{valueMax:n,valueMin:s,valueNow:i}=pD({layout:r,panelsArray:o,pivotIndices:[t,t+1]}),a=e[t];if(null==a);else{const e=o[t];cD(e,`No panel data found for index "${t}"`),a.setAttribute("aria-controls",e.id),a.setAttribute("aria-valuemax",""+Math.round(n)),a.setAttribute("aria-valuemin",""+Math.round(s)),a.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,r,o,s]),l.useEffect((()=>{if(!s)return;const e=t.current;cD(e,"Eager values not found");const{panelDataArray:o}=e;cD(null!=xD(n,s),`No group found for id "${n}"`);const a=gD(n,s);cD(a,`No resize handles found for group id "${n}"`);const l=a.map((e=>{const t=e.getAttribute(vM);cD(t,"Resize handle element has no handle id attribute");const[a,l]=function(e,t,n,r=document){var o,s,i,a;const l=vD(t,r),c=gD(e,r),d=l?c.indexOf(l):-1;return[null!==(o=null===(s=n[d])||void 0===s?void 0:s.id)&&void 0!==o?o:null,null!==(i=null===(a=n[d+1])||void 0===a?void 0:a.id)&&void 0!==i?i:null]}(n,t,o,s);if(null==a||null==l)return()=>{};const c=e=>{if(!e.defaultPrevented)switch(e.key){case"Enter":{e.preventDefault();const l=o.findIndex((e=>e.id===a));if(l>=0){const e=o[l];cD(e,`No panel data found for index ${l}`);const a=r[l],{collapsedSize:c=0,collapsible:d,minSize:u=0}=e.constraints;if(null!=a&&d){const e=mD({delta:hD(a,c)?u-c:c-a,initialLayout:r,panelConstraints:o.map((e=>e.constraints)),pivotIndices:bD(n,t,s),prevLayout:r,trigger:"keyboard"});r!==e&&i(e)}}break}}};return e.addEventListener("keydown",c),()=>{e.removeEventListener("keydown",c)}}));return()=>{l.forEach((e=>e()))}}),[s,e,t,n,r,o,i])}function kD(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 SD(e,t){const n="horizontal"===e,{x:r,y:o}=PM(t);return n?r:o}function CD(e,t,n,r,o,s){if(DM(e)){const t="horizontal"===n;let r=0;r=e.shiftKey?100:null!=o?o:10;let s=0;switch(e.key){case"ArrowDown":s=t?0:r;break;case"ArrowLeft":s=t?-r:0;break;case"ArrowRight":s=t?r:0;break;case"ArrowUp":s=t?0:-r;break;case"End":s=100;break;case"Home":s=-100}return s}return null==r?0:function(e,t,n,r,o){const s="horizontal"===n,i=vD(t,o);cD(i,`No resize handle element found for id "${t}"`);const a=i.getAttribute(hM);cD(a,"Resize handle element has no group id attribute");let{initialCursorPosition:l}=r;const c=SD(n,e),d=xD(a,o);cD(d,`No group element found for id "${a}"`);const u=d.getBoundingClientRect();return(c-l)/(s?u.width:u.height)*100}(e,t,n,r,s)}function ND(e,t,n){t.forEach(((t,r)=>{const o=e[r];cD(o,`Panel data not found for index ${r}`);const{callbacks:s,constraints:i,id:a}=o,{collapsedSize:l=0,collapsible:c}=i,d=n[a];if(null==d||t!==d){n[a]=t;const{onCollapse:e,onExpand:r,onResize:o}=s;o&&o(t,d),c&&(e||r)&&(!r||null!=d&&!uD(d,l)||uD(t,l)||r(),!e||null!=d&&uD(d,l)||!uD(t,l)||e())}}))}function ED(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 jD(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 _D(e){return`react-resizable-panels:${e}`}function ID(e){return e.map((e=>{const{constraints:t,id:n,idIsFromProps:r,order:o}=e;return r?n:o?`${o}:${JSON.stringify(t)}`:JSON.stringify(t)})).sort(((e,t)=>e.localeCompare(t))).join(",")}function AD(e,t){try{const n=_D(e),r=t.getItem(n);if(r){const e=JSON.parse(r);if("object"==typeof e&&null!=e)return e}}catch(n){}return null}function TD(e,t,n,r,o){var s;const i=_D(e),a=ID(t),l=null!==(s=AD(e,o))&&void 0!==s?s:{};l[a]={expandToSizes:Object.fromEntries(n.entries()),layout:r};try{o.setItem(i,JSON.stringify(l))}catch(c){console.error(c)}}function MD({layout:e,panelConstraints:t}){const n=[...e],r=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(!hD(r,100)&&n.length>0)for(let s=0;s<t.length;s++){const e=n[s];cD(null!=e,`No layout data found for index ${s}`);const t=100/r*e;n[s]=t}let o=0;for(let s=0;s<t.length;s++){const e=n[s];cD(null!=e,`No layout data found for index ${s}`);const r=fD({panelConstraints:t,panelIndex:s,size:e});e!=r&&(o+=e-r,n[s]=r)}if(!hD(o,0))for(let s=0;s<t.length;s++){const e=n[s];cD(null!=e,`No layout data found for index ${s}`);const r=fD({panelConstraints:t,panelIndex:s,size:e+o});if(e!==r&&(o-=r-e,n[s]=r,hD(o,0)))break}return n}const DD={getItem:e=>(jD(DD),DD.getItem(e)),setItem:(e,t)=>{jD(DD),DD.setItem(e,t)}},OD={};function RD({autoSaveId:e=null,children:t,className:n="",direction:r,forwardedRef:o,id:s=null,onLayout:i=null,keyboardResizeBy:a=null,storage:c=DD,style:d,tagName:u="div",...h}){const f=EM(s),m=l.useRef(null),[p,g]=l.useState(null),[y,b]=l.useState([]),x=function(){const[e,t]=l.useState(0);return l.useCallback((()=>t((e=>e+1))),[])}(),v=l.useRef({}),w=l.useRef(new Map),k=l.useRef(0),S=l.useRef({autoSaveId:e,direction:r,dragState:p,id:f,keyboardResizeBy:a,onLayout:i,storage:c}),C=l.useRef({layout:y,panelDataArray:[],panelDataArrayChanged:!1});l.useRef({didLogIdAndOrderWarning:!1,didLogPanelConstraintsWarning:!1,prevPanelIds:[]}),l.useImperativeHandle(o,(()=>({getId:()=>S.current.id,getLayout:()=>{const{layout:e}=C.current;return e},setLayout:e=>{const{onLayout:t}=S.current,{layout:n,panelDataArray:r}=C.current,o=MD({layout:e,panelConstraints:r.map((e=>e.constraints))});kD(n,o)||(b(o),C.current.layout=o,t&&t(o),ND(r,o,v.current))}})),[]),kM((()=>{S.current.autoSaveId=e,S.current.direction=r,S.current.dragState=p,S.current.id=f,S.current.onLayout=i,S.current.storage=c})),wD({committedValuesRef:S,eagerValuesRef:C,groupId:f,layout:y,panelDataArray:C.current.panelDataArray,setLayout:b,panelGroupElement:m.current}),l.useEffect((()=>{const{panelDataArray:t}=C.current;if(e){if(0===y.length||y.length!==t.length)return;let n=OD[e];null==n&&(n=function(e,t=10){let n=null;return(...r)=>{null!==n&&clearTimeout(n),n=setTimeout((()=>{e(...r)}),t)}}(TD,100),OD[e]=n);const r=[...t],o=new Map(w.current);n(e,r,o,y,c)}}),[e,y,c]),l.useEffect((()=>{}));const N=l.useCallback((e=>{const{onLayout:t}=S.current,{layout:n,panelDataArray:r}=C.current;if(e.constraints.collapsible){const o=r.map((e=>e.constraints)),{collapsedSize:s=0,panelSize:i,pivotIndices:a}=FD(r,e,n);if(cD(null!=i,`Panel size not found for panel "${e.id}"`),!uD(i,s)){w.current.set(e.id,i);const l=mD({delta:LD(r,e)===r.length-1?i-s:s-i,initialLayout:n,panelConstraints:o,pivotIndices:a,prevLayout:n,trigger:"imperative-api"});ED(n,l)||(b(l),C.current.layout=l,t&&t(l),ND(r,l,v.current))}}}),[]),E=l.useCallback(((e,t)=>{const{onLayout:n}=S.current,{layout:r,panelDataArray:o}=C.current;if(e.constraints.collapsible){const s=o.map((e=>e.constraints)),{collapsedSize:i=0,panelSize:a=0,minSize:l=0,pivotIndices:c}=FD(o,e,r),d=null!=t?t:l;if(uD(a,i)){const t=w.current.get(e.id),i=null!=t&&t>=d?t:d,l=mD({delta:LD(o,e)===o.length-1?a-i:i-a,initialLayout:r,panelConstraints:s,pivotIndices:c,prevLayout:r,trigger:"imperative-api"});ED(r,l)||(b(l),C.current.layout=l,n&&n(l),ND(o,l,v.current))}}}),[]),j=l.useCallback((e=>{const{layout:t,panelDataArray:n}=C.current,{panelSize:r}=FD(n,e,t);return cD(null!=r,`Panel size not found for panel "${e.id}"`),r}),[]),_=l.useCallback(((e,t)=>{const{panelDataArray:n}=C.current,r=LD(n,e);return function({defaultSize:e,dragState:t,layout:n,panelData:r,panelIndex:o,precision:s=3}){const i=n[o];let a;return a=null==i?null!=e?e.toPrecision(s):"1":1===r.length?"1":i.toPrecision(s),{flexBasis:0,flexGrow:a,flexShrink:1,overflow:"hidden",pointerEvents:null!==t?"none":void 0}}({defaultSize:t,dragState:p,layout:y,panelData:n,panelIndex:r})}),[p,y]),I=l.useCallback((e=>{const{layout:t,panelDataArray:n}=C.current,{collapsedSize:r=0,collapsible:o,panelSize:s}=FD(n,e,t);return cD(null!=s,`Panel size not found for panel "${e.id}"`),!0===o&&uD(s,r)}),[]),A=l.useCallback((e=>{const{layout:t,panelDataArray:n}=C.current,{collapsedSize:r=0,collapsible:o,panelSize:s}=FD(n,e,t);return cD(null!=s,`Panel size not found for panel "${e.id}"`),!o||dD(s,r)>0}),[]),T=l.useCallback((e=>{const{panelDataArray:t}=C.current;t.push(e),t.sort(((e,t)=>{const n=e.order,r=t.order;return null==n&&null==r?0:null==n?-1:null==r?1:n-r})),C.current.panelDataArrayChanged=!0,x()}),[x]);kM((()=>{if(C.current.panelDataArrayChanged){C.current.panelDataArrayChanged=!1;const{autoSaveId:e,onLayout:t,storage:n}=S.current,{layout:r,panelDataArray:o}=C.current;let s=null;if(e){const t=function(e,t,n){var r,o;return null!==(o=(null!==(r=AD(e,n))&&void 0!==r?r:{})[ID(t)])&&void 0!==o?o:null}(e,o,n);t&&(w.current=new Map(Object.entries(t.expandToSizes)),s=t.layout)}null==s&&(s=function({panelDataArray:e}){const t=Array(e.length),n=e.map((e=>e.constraints));let r=0,o=100;for(let s=0;s<e.length;s++){const e=n[s];cD(e,`Panel constraints not found for index ${s}`);const{defaultSize:i}=e;null!=i&&(r++,t[s]=i,o-=i)}for(let s=0;s<e.length;s++){const i=n[s];cD(i,`Panel constraints not found for index ${s}`);const{defaultSize:a}=i;if(null!=a)continue;const l=o/(e.length-r);r++,t[s]=l,o-=l}return t}({panelDataArray:o}));const i=MD({layout:s,panelConstraints:o.map((e=>e.constraints))});kD(r,i)||(b(i),C.current.layout=i,t&&t(i),ND(o,i,v.current))}})),kM((()=>{const e=C.current;return()=>{e.layout=[]}}),[]);const M=l.useCallback((e=>{let t=!1;const n=m.current;if(n){"rtl"===window.getComputedStyle(n,null).getPropertyValue("direction")&&(t=!0)}return function(n){n.preventDefault();const r=m.current;if(!r)return()=>null;const{direction:o,dragState:s,id:i,keyboardResizeBy:a,onLayout:l}=S.current,{layout:c,panelDataArray:d}=C.current,{initialLayout:u}=null!=s?s:{},h=bD(i,e,r);let f=CD(n,e,o,s,a,r);const p="horizontal"===o;p&&t&&(f=-f);const g=mD({delta:f,initialLayout:null!=u?u:c,panelConstraints:d.map((e=>e.constraints)),pivotIndices:h,prevLayout:c,trigger:DM(n)?"keyboard":"mouse-or-touch"}),y=!ED(c,g);(OM(n)||RM(n))&&k.current!=f&&(k.current=f,oD(e,y||0===f?0:p?f<0?VM:HM:f<0?WM:GM)),y&&(b(g),C.current.layout=g,l&&l(g),ND(d,g,v.current))}}),[]),D=l.useCallback(((e,t)=>{const{onLayout:n}=S.current,{layout:r,panelDataArray:o}=C.current,s=o.map((e=>e.constraints)),{panelSize:i,pivotIndices:a}=FD(o,e,r);cD(null!=i,`Panel size not found for panel "${e.id}"`);const l=mD({delta:LD(o,e)===o.length-1?i-t:t-i,initialLayout:r,panelConstraints:s,pivotIndices:a,prevLayout:r,trigger:"imperative-api"});ED(r,l)||(b(l),C.current.layout=l,n&&n(l),ND(o,l,v.current))}),[]),O=l.useCallback(((e,t)=>{const{layout:n,panelDataArray:r}=C.current,{collapsedSize:o=0,collapsible:s}=t,{collapsedSize:i=0,collapsible:a,maxSize:l=100,minSize:c=0}=e.constraints,{panelSize:d}=FD(r,e,n);null!=d&&(s&&a&&uD(d,o)?uD(o,i)||D(e,i):d<c?D(e,c):d>l&&D(e,l))}),[D]),R=l.useCallback(((e,t)=>{const{direction:n}=S.current,{layout:r}=C.current;if(!m.current)return;const o=vD(e,m.current);cD(o,`Drag handle element not found for id "${e}"`);const s=SD(n,t);g({dragHandleId:e,dragHandleRect:o.getBoundingClientRect(),initialCursorPosition:s,initialLayout:r})}),[]),P=l.useCallback((()=>{g(null)}),[]),L=l.useCallback((e=>{const{panelDataArray:t}=C.current,n=LD(t,e);n>=0&&(t.splice(n,1),delete v.current[e.id],C.current.panelDataArrayChanged=!0,x())}),[x]),F=l.useMemo((()=>({collapsePanel:N,direction:r,dragState:p,expandPanel:E,getPanelSize:j,getPanelStyle:_,groupId:f,isPanelCollapsed:I,isPanelExpanded:A,reevaluatePanelConstraints:O,registerPanel:T,registerResizeHandle:M,resizePanel:D,startDragging:R,stopDragging:P,unregisterPanel:L,panelGroupElement:m.current})),[N,p,r,E,j,_,f,I,A,O,T,M,D,R,P,L]),z={display:"flex",flexDirection:"horizontal"===r?"row":"column",height:"100%",overflow:"hidden",width:"100%"};return l.createElement(cM.Provider,{value:F},l.createElement(u,{...h,children:t,className:n,id:s,ref:m,style:{...z,...d},[dM]:"",[uM]:r,[hM]:f}))}const PD=l.forwardRef(((e,t)=>l.createElement(RD,{...e,forwardedRef:t})));function LD(e,t){return e.findIndex((e=>e===t||e.id===t.id))}function FD(e,t,n){const r=LD(e,t),o=r===e.length-1?[r-1,r]:[r,r+1],s=n[r];return{...t.constraints,panelSize:s,pivotIndices:o}}function zD({children:e=null,className:t="",disabled:n=!1,hitAreaMargins:r,id:o,onBlur:s,onClick:i,onDragging:a,onFocus:c,onPointerDown:d,onPointerUp:u,style:h={},tabIndex:f=0,tagName:m="div",...p}){var g,y;const b=l.useRef(null),x=l.useRef({onClick:i,onDragging:a,onPointerDown:d,onPointerUp:u});l.useEffect((()=>{x.current.onClick=i,x.current.onDragging=a,x.current.onPointerDown=d,x.current.onPointerUp=u}));const v=l.useContext(cM);if(null===v)throw Error("PanelResizeHandle components must be rendered within a PanelGroup container");const{direction:w,groupId:k,registerResizeHandle:S,startDragging:C,stopDragging:N,panelGroupElement:E}=v,j=EM(o),[_,I]=l.useState("inactive"),[A,T]=l.useState(!1),[M,D]=l.useState(null),O=l.useRef({state:_});kM((()=>{O.current.state=_})),l.useEffect((()=>{if(n)D(null);else{const e=S(j);D((()=>e))}}),[n,j,S]);const R=null!==(g=null==r?void 0:r.coarse)&&void 0!==g?g:15,P=null!==(y=null==r?void 0:r.fine)&&void 0!==y?y:5;l.useEffect((()=>{if(n||null==M)return;const e=b.current;cD(e,"Element ref not attached");let t=!1;return function(e,t,n,r,o){var s;const{ownerDocument:i}=t,a={direction:n,element:t,hitAreaMargins:r,setResizeHandlerState:o},l=null!==(s=JM.get(i))&&void 0!==s?s:0;return JM.set(i,l+1),ZM.add(a),aD(),function(){var t;XM.delete(e),ZM.delete(a);const n=null!==(t=JM.get(i))&&void 0!==t?t:1;if(JM.set(i,n-1),aD(),1===n&&JM.delete(i),YM.includes(a)){const e=YM.indexOf(a);e>=0&&YM.splice(e,1),sD(),o("up",!0,null)}}}(j,e,w,{coarse:R,fine:P},((e,n,r)=>{if(n)switch(e){case"down":{I("drag"),t=!1,cD(r,'Expected event to be defined for "down" action'),C(j,r);const{onDragging:e,onPointerDown:n}=x.current;null==e||e(!0),null==n||n();break}case"move":{const{state:e}=O.current;t=!0,"drag"!==e&&I("hover"),cD(r,'Expected event to be defined for "move" action'),M(r);break}case"up":{I("hover"),N();const{onClick:e,onDragging:n,onPointerUp:r}=x.current;null==n||n(!1),null==r||r(),t||null==e||e();break}}else I("inactive")}))}),[R,w,n,P,S,j,M,C,N]),function({disabled:e,handleId:t,resizeHandler:n,panelGroupElement:r}){l.useEffect((()=>{if(e||null==n||null==r)return;const o=vD(t,r);if(null==o)return;const s=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=o.getAttribute(hM);cD(n,`No group element found for id "${n}"`);const s=gD(n,r),i=yD(n,t,r);cD(null!==i,`No resize element found for id "${t}"`),s[e.shiftKey?i>0?i-1:s.length-1:i+1<s.length?i+1:0].focus();break}}};return o.addEventListener("keydown",s),()=>{o.removeEventListener("keydown",s)}}),[r,e,t,n])}({disabled:n,handleId:j,resizeHandler:M,panelGroupElement:E});return l.createElement(m,{...p,children:e,className:t,id:o,onBlur:()=>{T(!1),null==s||s()},onFocus:()=>{T(!0),null==c||c()},ref:b,role:"separator",style:{touchAction:"none",userSelect:"none",...h},tabIndex:f,[uM]:w,[hM]:k,[yM]:"",[bM]:"drag"===_?"pointer":A?"keyboard":void 0,[xM]:!n,[vM]:j,[wM]:_})}RD.displayName="PanelGroup",PD.displayName="forwardRef(PanelGroup)",zD.displayName="PanelResizeHandle";const BD=e=>{const t=N.c(3);let n,r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=_.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?(r=_.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]=r):r=t[2],r},UD=e=>{const t=N.c(17);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:i,selected:s,className:r,...o}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=!s&&"hover:bg-[var(--sage-3)]",l=s&&"bg-[var(--sage-4)]";let c,d;t[6]!==r||t[7]!==a||t[8]!==l?(c=$t("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",a,l,r),t[6]=r,t[7]=a,t[8]=l,t[9]=c):c=t[9],t[10]!==n||t[11]!==o||t[12]!==c?(d=_.jsx("div",{className:c,...o,children:n}),t[10]=n,t[11]=o,t[12]=c,t[13]=d):d=t[13];const u=d;if(i){let e;return t[14]!==u||t[15]!==i?(e=_.jsx(ht,{content:i,side:"top",delayDuration:200,children:u}),t[14]=u,t[15]=i,t[16]=e):e=t[16],e}return u},$D=()=>{var e;const t=N.c(14),n=de(Qi),r=de(fe),o=(null==(e=null==n?void 0:n.open_ai)?void 0:e.model)||"gpt-4-turbo",{handleClick:s}=yc();if(!r){let e,n,r;return t[0]!==s?(e=()=>s("ai"),t[0]=s,t[1]=e):e=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(ye,{className:"h-4 w-4 opacity-60"}),t[2]=n):n=t[2],t[3]!==e?(r=_.jsx(UD,{tooltip:"Assist is disabled",selected:!1,onClick:e,children:n}),t[3]=e,t[4]=r):r=t[4],r}let i,a,l,c,d;return t[5]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx("b",{children:"Assist model:"}),t[5]=i):i=t[5],t[6]!==o?(a=_.jsxs(_.Fragment,{children:[i," ",o]}),t[6]=o,t[7]=a):a=t[7],t[8]!==s?(l=()=>s("ai"),t[8]=s,t[9]=l):l=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx(ye,{className:"h-4 w-4"}),t[10]=c):c=t[10],t[11]!==a||t[12]!==l?(d=_.jsx(UD,{tooltip:a,onClick:l,selected:!1,children:c}),t[11]=a,t[12]=l,t[13]=d):d=t[13],d},VD=Z((e=>e(Zi).completion.copilot)),HD=()=>{const e=N.c(1);if("github"===de(VD)){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(WD,{}),e[0]=t):t=e[0],t}return null},WD=()=>{const e=de(bc),t=null!==de(xc),{handleClick:n}=yc(),r=()=>n("ai"),o=e?"Ready":"Not connected",s=he(bc),i=he(vc);return ea((()=>{const e=uc();let t=!0;return(async()=>{try{if(await e.initializePromise.catch((t=>{throw X.error("Copilot#checkConnection: Failed to initialize",t),e.close(),t})),!t)return;const n=await e.signedIn();if(!t)return;s(n),i(n?"signedIn":"signedOut")}catch(n){if(!t)return;X.warn("Copilot#checkConnection: Connection failed",n),s(!1),i("connectionError"),se({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:_.jsx(ee,{variant:"link",onClick:r,children:"Settings"})})}})(),()=>{t=!1}})),_.jsx(UD,{tooltip:_.jsxs(_.Fragment,{children:[_.jsx("b",{children:"GitHub Copilot:"})," ",o]}),selected:!1,onClick:r,children:_.jsx("span",{children:t?_.jsx(ta,{className:"h-4 w-4"}):_.jsx(BD,{className:$t("h-4 w-4",!e&&"opacity-60")})})})},GD=e=>{const t=N.c(21),[n,r]=l.useState(0),o=de(ft);let s,i,a,c;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>r(eO),i={delayMs:1e4,whenVisible:!0},t[0]=s,t[1]=i):(s=t[0],i=t[1]),sc(s,i),t[2]!==o.state?(a=async()=>E()||o.state!==pt.OPEN?null:na(),t[2]=o.state,t[3]=a):a=t[3],t[4]!==o.state||t[5]!==n?(c=[n,o.state],t[4]=o.state,t[5]=n,t[6]=c):c=t[6];const{data:d}=Pt(a,c);let u,h,f,m,p,g;return t[7]!==d?(u=(null==d?void 0:d.gpu)&&d.gpu.length>0&&_.jsx(JD,{gpus:d.gpu}),t[7]=d,t[8]=u):u=t[8],t[9]!==d?(h=d&&_.jsx(YD,{memory:d.memory,kernel:d.kernel,server:d.server}),t[9]=d,t[10]=h):h=t[10],t[11]!==d?(f=d&&_.jsx(KD,{cpu:d.cpu}),t[11]=d,t[12]=f):f=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(m=_.jsxs("div",{className:"flex items-center",children:[_.jsx($D,{}),_.jsx(HD,{})]}),t[13]=m):m=t[13],t[14]!==o.state?(p=_.jsx(qD,{connection:o.state}),t[14]=o.state,t[15]=p):p=t[15],t[16]!==u||t[17]!==h||t[18]!==f||t[19]!==p?(g=_.jsxs("div",{className:"flex gap-2 items-center",children:[u,h,f,m,p]}),t[16]=u,t[17]=h,t[18]=f,t[19]=p,t[20]=g):g=t[20],g},qD=e=>{const t=N.c(18),{connection:n}=e;let r,o,s,i,a,l,c;return t[0]!==n?(r=D(n.toLowerCase()),t[0]=n,t[1]=r):r=t[1],t[2]!==n?(o=n===pt.OPEN&&_.jsx(Nd,{className:"w-4 h-4"}),t[2]=n,t[3]=o):o=t[3],t[4]!==n?(s=n===pt.CLOSED&&_.jsx(wc,{className:"w-4 h-4"}),t[4]=n,t[5]=s):s=t[5],t[6]!==n?(i=n===pt.CONNECTING&&_.jsx(ta,{size:"small"}),t[6]=n,t[7]=i):i=t[7],t[8]!==n?(a=n===pt.CLOSING&&_.jsx(ta,{className:"text-destructive",size:"small"}),t[8]=n,t[9]=a):a=t[9],t[10]!==o||t[11]!==s||t[12]!==i||t[13]!==a?(l=_.jsxs("div",{children:[o,s,i,a]}),t[10]=o,t[11]=s,t[12]=i,t[13]=a,t[14]=l):l=t[14],t[15]!==r||t[16]!==l?(c=_.jsx(ht,{delayDuration:200,content:r,children:l}),t[15]=r,t[16]=l,t[17]=c):c=t[17],c},YD=e=>{const t=N.c(25),{memory:n,kernel:r,server:o}=e,{percent:s,total:i,available:a}=n;let l;t[0]!==s?(l=Math.round(s),t[0]=s,t[1]=l):l=t[1];const c=l;let d;t[2]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx("b",{children:"computer memory:"}),t[2]=d):d=t[2];const u=i-a;let h,f,m,p,g,y,b,x,v;return t[3]!==u?(h=QD(u),t[3]=u,t[4]=h):h=t[4],t[5]!==i?(f=QD(i),t[5]=i,t[6]=f):f=t[6],t[7]!==c||t[8]!==h||t[9]!==f?(m=_.jsxs("span",{children:[d," ",h," / ",f," GB (",c,"%)"]}),t[7]=c,t[8]=h,t[9]=f,t[10]=m):m=t[10],t[11]!==o?(p=(null==o?void 0:o.memory)&&_.jsxs("span",{children:[_.jsx("b",{children:"marimo server:"})," ",ZD(o.memory)]}),t[11]=o,t[12]=p):p=t[12],t[13]!==r?(g=(null==r?void 0:r.memory)&&_.jsxs("span",{children:[_.jsx("b",{children:"kernel:"})," ",ZD(r.memory)]}),t[13]=r,t[14]=g):g=t[14],t[15]!==m||t[16]!==p||t[17]!==g?(y=_.jsxs("div",{className:"flex flex-col gap-1",children:[m,p,g]}),t[15]=m,t[16]=p,t[17]=g,t[18]=y):y=t[18],t[19]===Symbol.for("react.memo_cache_sentinel")?(b=_.jsx(eu,{className:"w-4 h-4"}),t[19]=b):b=t[19],t[20]!==c?(x=_.jsxs("div",{className:"flex items-center gap-1",children:[b,_.jsx(XD,{percent:c,colorClassName:"bg-primary"})]}),t[20]=c,t[21]=x):x=t[21],t[22]!==x||t[23]!==y?(v=_.jsx(ht,{delayDuration:200,content:y,children:x}),t[22]=x,t[23]=y,t[24]=v):v=t[24],v},KD=e=>{const t=N.c(11),{cpu:n}=e,{percent:r}=n;let o;t[0]!==r?(o=Math.round(r),t[0]=r,t[1]=o):o=t[1];const s=o;let i,a,l,c,d;return t[2]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx("b",{children:"CPU:"}),t[2]=i):i=t[2],t[3]!==s?(a=_.jsxs("span",{children:[i," ",s,"%"]}),t[3]=s,t[4]=a):a=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(kc,{className:"w-4 h-4"}),t[5]=l):l=t[5],t[6]!==s?(c=_.jsxs("div",{className:"flex items-center gap-1",children:[l,_.jsx(XD,{percent:s,colorClassName:"bg-primary"})]}),t[6]=s,t[7]=c):c=t[7],t[8]!==a||t[9]!==c?(d=_.jsx(ht,{delayDuration:200,content:a,children:c}),t[8]=a,t[9]=c,t[10]=d):d=t[10],d},JD=e=>{const t=N.c(12),{gpus:n}=e;let r;t[0]!==n?(r=Math.round(n.reduce(tO,0)/n.length),t[0]=n,t[1]=r):r=t[1];const o=r;let s,i,a,l,c;return t[2]!==n?(s=n.map(nO),t[2]=n,t[3]=s):s=t[3],t[4]!==s?(i=_.jsx("div",{className:"flex flex-col gap-1",children:s}),t[4]=s,t[5]=i):i=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsx(nu,{className:"w-4 h-4"}),t[6]=a):a=t[6],t[7]!==o?(l=_.jsxs("div",{className:"flex items-center gap-1",children:[a,_.jsx(XD,{percent:o,colorClassName:"bg-[var(--grass-9)]"})]}),t[7]=o,t[8]=l):l=t[8],t[9]!==i||t[10]!==l?(c=_.jsx(ht,{delayDuration:200,content:i,children:l}),t[9]=i,t[10]=l,t[11]=c):c=t[11],c},XD=e=>{const t=N.c(7),{percent:n,colorClassName:r}=e;let o;t[0]!==r?(o=$t("h-full bg-primary",r),t[0]=r,t[1]=o):o=t[1];const s=`${n}%`;let i,a;return t[2]!==s?(i={width:s},t[2]=s,t[3]=i):i=t[3],t[4]!==o||t[5]!==i?(a=_.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:_.jsx("div",{className:o,style:i})}),t[4]=o,t[5]=i,t[6]=a):a=t[6],a};function ZD(e){return e>1073741824?`${QD(e)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(e)} MB`}function QD(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(e/1073741824)}function eO(e){return e+1}function tO(e,t){return e+t.memory.percent}function nO(e){return _.jsxs("span",{children:[_.jsxs("b",{children:["GPU ",e.index," (",e.name,"):"]})," ",ZD(e.memory.used)," / ",ZD(e.memory.total)," GB (",Math.round(e.memory.percent),"%)"]},e.index)}const rO=e=>de(ra)[e.capability]?e.children:null,oO=()=>{const e=N.c(56),{selectedPanel:t,isTerminalOpen:n}=cn(),{toggleApplication:r,toggleTerminal:o}=ln(),[s,i]=Ue(),a=de(oa),l=sO,c=_h.find(iO);let d;Rn(c,"Error panel not found"),e[0]!==o?(d=()=>{o()},e[0]=o,e[1]=d):d=e[1],oc("global.toggleTerminal",d);const u=UD,h=c.tooltip,f=t===c.type,m=()=>r(c.type),p=l(c,a>0?"text-destructive":"");let g,y,b,x,v;e[2]!==a?(g=_.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:a}),e[2]=a,e[3]=g):g=e[3],e[4]!==u||e[5]!==c||e[6]!==f||e[7]!==m||e[8]!==p||e[9]!==g?(y=_.jsxs(u,{tooltip:h,selected:f,onClick:m,children:[p,g]}),e[4]=u,e[5]=c,e[6]=f,e[7]=m,e[8]=p,e[9]=g,e[10]=y):y=e[10],e[11]!==o?(b=()=>o(),e[11]=o,e[12]=b):b=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(x=_.jsx(Nu,{className:"h-5 w-5"}),e[13]=x):x=e[13],e[14]!==n||e[15]!==b?(v=_.jsx(rO,{capability:"terminal",children:_.jsx(UD,{tooltip:"Open terminal",selected:n,onClick:b,children:x})}),e[14]=n,e[15]=b,e[16]=v):v=e[16];const w=s.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let k,S,C;e[17]!==s||e[18]!==i?(k=async()=>{const e={...s,runtime:{...s.runtime,auto_instantiate:!s.runtime.auto_instantiate}};await Ve({config:e}).then((()=>i(e)))},e[17]=s,e[18]=i,e[19]=k):k=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(S=_.jsx("span",{children:"on startup: "}),e[20]=S):S=e[20],e[21]!==s.runtime.auto_instantiate?(C=s.runtime.auto_instantiate?_.jsx(Du,{size:14}):_.jsx(Mu,{size:14}),e[21]=s.runtime.auto_instantiate,e[22]=C):C=e[22];const j=s.runtime.auto_instantiate?"autorun":"lazy";let I,A,T,M;e[23]!==j?(I=_.jsx("span",{children:j}),e[23]=j,e[24]=I):I=e[24],e[25]!==C||e[26]!==I?(A=_.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[S,C,I]}),e[25]=C,e[26]=I,e[27]=A):A=e[27],e[28]!==w||e[29]!==k||e[30]!==A?(T=_.jsx(UD,{tooltip:w,selected:!1,onClick:k,children:A}),e[28]=w,e[29]=k,e[30]=A,e[31]=T):T=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(M=_.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[32]=M):M=e[32];const D="autorun"===s.runtime.on_cell_change?"Disable autorun":"Enable autorun";let O,R,P,L,F,z,B,U,$,V;return e[33]!==s||e[34]!==i?(O=async()=>{const e={...s,runtime:{...s.runtime,on_cell_change:"autorun"===s.runtime.on_cell_change?"lazy":"autorun"}};await Ve({config:e}).then((()=>i(e)))},e[33]=s,e[34]=i,e[35]=O):O=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(R=_.jsx("span",{children:"on cell change: "}),e[36]=R):R=e[36],e[37]!==s.runtime.on_cell_change?(P=_.jsxs("div",{className:"font-prose text-sm flex items-center gap-1",children:[R,"autorun"===s.runtime.on_cell_change?_.jsx(Du,{size:14}):_.jsx(Mu,{size:14}),_.jsx("span",{children:s.runtime.on_cell_change})]}),e[37]=s.runtime.on_cell_change,e[38]=P):P=e[38],e[39]!==D||e[40]!==O||e[41]!==P?(L=_.jsx(UD,{tooltip:D,selected:!1,onClick:O,children:P}),e[39]=D,e[40]=O,e[41]=P,e[42]=L):L=e[42],e[43]===Symbol.for("react.memo_cache_sentinel")?(F=_.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[43]=F):F=e[43],e[44]!==s||e[45]!==i?(z=!E()&&_.jsx(UD,{tooltip:null,selected:!1,children:_.jsxs(Ht,{children:[_.jsxs(Wt,{className:"font-prose text-sm flex items-center gap-1",children:[_.jsx("span",{children:"on module change: "}),"off"===s.runtime.auto_reload&&_.jsx(wc,{size:14}),"lazy"===s.runtime.auto_reload&&_.jsx(Mu,{size:14}),"autorun"===s.runtime.auto_reload&&_.jsx(Du,{size:14}),_.jsx("span",{children:s.runtime.auto_reload}),_.jsx(_e,{size:14})]}),_.jsx(Gt,{children:["off","lazy","autorun"].map((e=>_.jsxs(qt,{onClick:async()=>{const t={...s,runtime:{...s.runtime,auto_reload:e}};await Ve({config:t}).then((()=>i(t)))},children:["off"===e&&_.jsx(wc,{size:14,className:"mr-2 text-muted-foreground"}),"lazy"===e&&_.jsx(Mu,{size:14,className:"mr-2 text-muted-foreground"}),"autorun"===e&&_.jsx(Du,{size:14,className:"mr-2 text-muted-foreground"}),e]},e)))})]})}),e[44]=s,e[45]=i,e[46]=z):z=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(B=_.jsx("div",{className:"mx-auto"}),e[47]=B):B=e[47],e[48]===Symbol.for("react.memo_cache_sentinel")?(U=_.jsx($m,{children:_.jsx(ht,{content:_.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:_.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),$=_.jsx(GD,{}),e[48]=U,e[49]=$):(U=e[48],$=e[49]),e[50]!==v||e[51]!==T||e[52]!==L||e[53]!==z||e[54]!==y?(V=_.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:[y,v,T,M,L,F,z,B,U,$]}),e[50]=v,e[51]=T,e[52]=L,e[53]=z,e[54]=y,e[55]=V):V=e[55],V};function sO(e,t){const{Icon:n}=e;return _.jsx(n,{className:$t("h-5 w-5",t)})}function iO(e){return"errors"===e.type}const aO=e=>{const t=N.c(6),{children:n}=e,{openModal:r,closeModal:o}=ue();let s,i;return t[0]!==o||t[1]!==r?(s=()=>r(_.jsx(lO,{onClose:o})),t[0]=o,t[1]=r,t[2]=s):s=t[2],t[3]!==n||t[4]!==s?(i=_.jsx(sa,{onClick:s,children:n}),t[3]=n,t[4]=s,t[5]=i):i=t[5],i},lO=e=>{const t=N.c(9),{onClose:n}=e;let r,o,s,i,a,l,c;return t[0]!==n?(r=async e=>{e.preventDefault();const t=new FormData(e.target),r=t.get("rating"),o=t.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:r,message:o})}),n(),se({title:"Feedback sent!",description:"Thank you for your feedback!"})},t[0]=n,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsx(Le,{children:"Send Feedback"}),t[2]=o):o=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=_.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you — from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),t[3]=s):s=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsxs("li",{className:"my-0",children:["Take our"," ",_.jsx("a",{href:it.feedbackForm,target:"_blank",className:"underline",children:"two-minute survey."})]}),t[4]=i):i=t[4],t[5]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsxs("li",{className:"my-0",children:["File a"," ",_.jsx("a",{href:it.issuesPage,target:"_blank",className:"underline",children:"GitHub issue."})]}),t[5]=a):a=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsxs(Pe,{children:[o,_.jsxs(at,{children:[s,_.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[i,a,_.jsxs("li",{className:"my-0",children:["Chat with us on"," ",_.jsx("a",{href:it.discordLink,target:"_blank",className:"underline",children:"Discord."})]})]}),_.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We're excited you're here as we build the future of Python data tooling. Thanks for being part of our community!"})]})]}),t[6]=l):l=t[6],t[7]!==r?(c=_.jsx(Re,{className:"w-fit",children:_.jsx("form",{onSubmit:r,children:l})}),t[7]=r,t[8]=c):c=t[8],c},cO=()=>{const e=N.c(10),{selectedPanel:t}=cn(),{toggleApplication:n}=ln(),r=hO;let o,s,i,a,l,c;if(e[0]!==t||e[1]!==n){o="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",s=_h.filter(fO).map((e=>_.jsx(uO,{tooltip:e.tooltip,selected:t===e.type,onClick:()=>n(e.type),children:r(e)},e.type))),e[0]=t,e[1]=n,e[2]=o,e[3]=s}else o=e[2],s=e[3];return e[4]===Symbol.for("react.memo_cache_sentinel")?(i=_.jsx(aO,{children:_.jsx(uO,{tooltip:"Send feedback!",selected:!1,children:_.jsx(tu,{className:"h-5 w-5"})})}),a=_.jsx("div",{className:"flex-1"}),l=_.jsx(dO,{}),e[4]=i,e[5]=a,e[6]=l):(i=e[4],a=e[5],l=e[6]),e[7]!==o||e[8]!==s?(c=_.jsxs("div",{className:o,children:[s,i,a,l]}),e[7]=o,e[8]=s,e[9]=c):c=e[9],c},dO=()=>{const e=N.c(7),t=de(ia);let n,r,o;return e[0]!==t?(n=t>0?_.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?(r=_.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:Array.from({length:t}).map(mO)}),e[2]=t,e[3]=r):r=e[3],e[4]!==n||e[5]!==r?(o=_.jsx(ht,{content:n,side:"right",delayDuration:200,children:r}),e[4]=n,e[5]=r,e[6]=o):o=e[6],o},uO=e=>{const t=N.c(17);let n,r,o,s,i;t[0]!==e?(({children:n,tooltip:i,selected:s,className:r,...o}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s,t[5]=i):(n=t[1],r=t[2],o=t[3],s=t[4],i=t[5]);const a=!s&&"hover:bg-[var(--sage-3)]",l=s&&"bg-[var(--sage-4)]";let c,d,u;return t[6]!==r||t[7]!==a||t[8]!==l?(c=$t("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",a,l,r),t[6]=r,t[7]=a,t[8]=l,t[9]=c):c=t[9],t[10]!==n||t[11]!==o||t[12]!==c?(d=_.jsx("div",{className:c,...o,children:n}),t[10]=n,t[11]=o,t[12]=c,t[13]=d):d=t[13],t[14]!==d||t[15]!==i?(u=_.jsx(ht,{content:i,side:"right",delayDuration:200,children:d}),t[14]=d,t[15]=i,t[16]=u):u=t[16],u};function hO(e,t){const{Icon:n}=e;return _.jsx(n,{className:$t("h-5 w-5",t)})}function fO(e){return!e.hidden&&"sidebar"===e.position}function mO(e,t){return _.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},t.toString())}_t.record(_t.tuple([_t.number(),_t.number()]));let pO=null;const gO=e=>{const t=N.c(15),{title:n,description:r,icon:o,action:s}=e;let i,a,l,c,d,u;return t[0]!==o?(i=o&&p.cloneElement(o,{className:"text-accent-foreground"}),t[0]=o,t[1]=i):i=t[1],t[2]!==n?(a=_.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),t[2]=n,t[3]=a):a=t[3],t[4]!==i||t[5]!==a?(l=_.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[i,a]}),t[4]=i,t[5]=a,t[6]=l):l=t[6],t[7]!==r?(c=_.jsx("span",{className:"text-muted-foreground text-sm",children:r}),t[7]=r,t[8]=c):c=t[8],t[9]!==s?(d=s&&_.jsx("div",{className:"mt-2",children:s}),t[9]=s,t[10]=d):d=t[10],t[11]!==l||t[12]!==c||t[13]!==d?(u=_.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[l,c,d]}),t[11]=l,t[12]=c,t[13]=d,t[14]=u):u=t[14],u},yO=()=>{const e=N.c(5),t=aa();if(0===t.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"No errors!",icon:_.jsx(lu,{})}),e[0]=t):t=e[0],t}let n,r;return e[1]!==t?(n=t.map(bO),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(r=_.jsx("div",{className:"flex flex-col overflow-auto",children:n}),e[3]=n,e[4]=r):r=e[4],r};function bO(e){return _.jsxs("div",{children:[_.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:_.jsx(la,{cellId:e.cellId})}),_.jsx("div",{className:"px-2",children:_.jsx(ca,{errors:e.output.data,cellId:e.cellId},e.cellId)},e.cellId)]},e.cellId)}const xO=()=>{const e=N.c(6),{items:t}=de(da);let n,r;e[0]!==t?(r=nd(t),e[0]=t,e[1]=r):r=e[1],n=r;const o=n,{activeHeaderId:s}=rd(o);if(0===t.length){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:_.jsx(gu,{})}),e[2]=t):t=e[2],t}let i;return e[3]!==s||e[4]!==t?(i=_.jsx(od,{items:t,activeHeaderId:s}),e[3]=s,e[4]=t,e[5]=i):i=e[5],i};function vO(e){if("string"==typeof e||"number"==typeof e)return""+e;let t="";if(Array.isArray(e))for(let n,r=0;r<e.length;r++)""!==(n=vO(e[r]))&&(t+=(t&&" ")+n);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}const{useDebugValue:wO}=p,{useSyncExternalStoreWithSelector:kO}=ua,SO=e=>e;function CO(e,t=SO,n){const r=kO(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return wO(r),r}const NO=(e,t)=>{const n=ha(e),r=(e,r=t)=>CO(n,e,r);return Object.assign(r,n),r};function EO(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,r]of e)if(!Object.is(r,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 r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}function jO(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 r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,[(r=r.matrixTransform(t.getScreenCTM().inverse())).x,r.y]}if(t.getBoundingClientRect){var o=t.getBoundingClientRect();return[e.clientX-o.left-t.clientLeft,e.clientY-o.top-t.clientTop]}}return[e.pageX,e.pageY]}const _O={passive:!1},IO={capture:!0,passive:!1};function AO(e){e.stopImmediatePropagation()}function TO(e){e.preventDefault(),e.stopImmediatePropagation()}function MO(e){var t=e.document.documentElement,n=cd(e).on("dragstart.drag",TO,IO);"onselectstart"in t?n.on("selectstart.drag",TO,IO):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function DO(e,t){var n=e.document.documentElement,r=cd(e).on("dragstart.drag",null);t&&(r.on("click.drag",TO,IO),setTimeout((function(){r.on("click.drag",null)}),0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const OO=e=>()=>e;function RO(e,{sourceEvent:t,subject:n,target:r,identifier:o,active:s,x:i,y:a,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:r,enumerable:!0,configurable:!0},identifier:{value:o,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:a,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:c,enumerable:!0,configurable:!0},_:{value:d}})}function PO(e){return!e.ctrlKey&&!e.button}function LO(){return this.parentNode}function FO(e,t){return null==t?{x:e.x,y:e.y}:t}function zO(){return navigator.maxTouchPoints||"ontouchstart"in this}RO.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};const BO=e=>()=>e;function UO(e,{sourceEvent:t,target:n,transform:r,dispatch:o}){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:r,enumerable:!0,configurable:!0},_:{value:o}})}function $O(e){e.stopImmediatePropagation()}function VO(e){e.preventDefault(),e.stopImmediatePropagation()}function HO(e){return!(e.ctrlKey&&"wheel"!==e.type||e.button)}function WO(){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 GO(){return this.__zoom||dd}function qO(e){return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function YO(){return navigator.maxTouchPoints||"ontouchstart"in this}function KO(e,t,n){var r=e.invertX(t[0][0])-n[0][0],o=e.invertX(t[1][0])-n[1][0],s=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(o>r?(r+o)/2:Math.min(0,r)||Math.max(0,o),i>s?(s+i)/2:Math.min(0,s)||Math.max(0,i))}const JO=l.createContext(null),XO=JO.Provider,ZO=e=>`Node type "${e}" not found. Using fallback type "default".`,QO=()=>"The React Flow parent container needs a width and a height to render the graph.",eR=()=>"Only child nodes can use a parent extent.",tR=e=>`Marker type "${e}" doesn't exist.`,nR=(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,rR=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",oR=e=>`Edge type "${e}" not found. Using fallback type "default".`,sR=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.`,iR=(()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001")();function aR(e,t){const n=l.useContext(JO);if(null===n)throw new Error(iR);return CO(n,e,t)}const lR=()=>{const e=l.useContext(JO);if(null===e)throw new Error(iR);return l.useMemo((()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy})),[e])},cR=e=>e.userSelectionActive?"none":"all";function dR({position:e,children:t,className:n,style:r,...o}){const s=aR(cR),i=`${e}`.split("-");return p.createElement("div",{className:vO(["react-flow__panel",n,...i]),style:{...r,pointerEvents:s},...o},t)}function uR({proOptions:e,position:t="bottom-right"}){return(null==e?void 0:e.hideAttribution)?null:p.createElement(dR,{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"},p.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var hR=l.memo((({x:e,y:t,label:n,labelStyle:r={},labelShowBg:o=!0,labelBgStyle:s={},labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:c,className:d,...u})=>{const h=l.useRef(null),[f,m]=l.useState({x:0,y:0,width:0,height:0}),g=vO(["react-flow__edge-textwrapper",d]);return l.useEffect((()=>{if(h.current){const e=h.current.getBBox();m({x:e.x,y:e.y,width:e.width,height:e.height})}}),[n]),void 0!==n&&n?p.createElement("g",{transform:`translate(${e-f.width/2} ${t-f.height/2})`,className:g,visibility:f.width?"visible":"hidden",...u},o&&p.createElement("rect",{width:f.width+2*i[0],x:-i[0],y:-i[1],height:f.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),p.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:h,style:r},n),c):null}));const fR=e=>({width:e.offsetWidth,height:e.offsetHeight}),mR=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),pR=(e={x:0,y:0},t)=>({x:mR(e.x,t[0][0],t[1][0]),y:mR(e.y,t[0][1],t[1][1])}),gR=(e,t,n)=>e<t?mR(Math.abs(e-t),1,50)/50:e>n?-mR(Math.abs(e-n),1,50)/50:0,yR=(e,t)=>[20*gR(e.x,35,t.width-35),20*gR(e.y,35,t.height-35)],bR=e=>{var t;return(null==(t=e.getRootNode)?void 0:t.call(e))||(null==window?void 0:window.document)},xR=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),vR=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),wR=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},kR=e=>!isNaN(e)&&isFinite(e),SR=Symbol.for("internals"),CR=["Enter"," ","Escape"];function NR(e){var t,n;const r=(e=>"nativeEvent"in e)(e)?e.nativeEvent:e,o=(null==(n=null==(t=r.composedPath)?void 0:t.call(r))?void 0:n[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(null==o?void 0:o.nodeName)||(null==o?void 0:o.hasAttribute("contenteditable"))||!!(null==o?void 0:o.closest(".nokey"))}const ER=e=>"clientX"in e,jR=(e,t)=>{var n,r;const o=ER(e),s=o?e.clientX:null==(n=e.touches)?void 0:n[0].clientX,i=o?e.clientY:null==(r=e.touches)?void 0:r[0].clientY;return{x:s-((null==t?void 0:t.left)??0),y:i-((null==t?void 0:t.top)??0)}},_R=()=>{var e;return"undefined"!=typeof navigator&&(null==(e=null==navigator?void 0:navigator.userAgent)?void 0:e.indexOf("Mac"))>=0},IR=({id:e,path:t,labelX:n,labelY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:u,markerStart:h,interactionWidth:f=20})=>p.createElement(p.Fragment,null,p.createElement("path",{id:e,style:d,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:u,markerStart:h}),f&&p.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:f,className:"react-flow__edge-interaction"}),o&&kR(n)&&kR(r)?p.createElement(hR,{x:n,y:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null);function AR(e,t,n){return void 0===n?n:r=>{const o=t().edges.find((t=>t.id===e));o&&n(r,{...o})}}function TR({sourceX:e,sourceY:t,targetX:n,targetY:r}){const o=Math.abs(n-e)/2,s=n<e?n+o:n-o,i=Math.abs(r-t)/2;return[s,r<t?r+i:r-i,o,i]}function MR({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:o,sourceControlY:s,targetControlX:i,targetControlY:a}){const l=.125*e+.375*o+.375*i+.125*n,c=.125*t+.375*s+.375*a+.125*r;return[l,c,Math.abs(l-e),Math.abs(c-t)]}var DR,OR,RR,PR,LR,FR,zR,BR,UR,$R,VR,HR;function WR({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===VR.Left||e===VR.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function GR({sourceX:e,sourceY:t,sourcePosition:n=VR.Bottom,targetX:r,targetY:o,targetPosition:s=VR.Top}){const[i,a]=WR({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,c]=WR({pos:s,x1:r,y1:o,x2:e,y2:t}),[d,u,h,f]=MR({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:c});return[`M${e},${t} C${i},${a} ${l},${c} ${r},${o}`,d,u,h,f]}IR.displayName="BaseEdge",(OR=DR||(DR={})).Strict="strict",OR.Loose="loose",(PR=RR||(RR={})).Free="free",PR.Vertical="vertical",PR.Horizontal="horizontal",(FR=LR||(LR={})).Partial="partial",FR.Full="full",(BR=zR||(zR={})).Bezier="default",BR.Straight="straight",BR.Step="step",BR.SmoothStep="smoothstep",BR.SimpleBezier="simplebezier",($R=UR||(UR={})).Arrow="arrow",$R.ArrowClosed="arrowclosed",(HR=VR||(VR={})).Left="left",HR.Top="top",HR.Right="right",HR.Bottom="bottom";const qR=l.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=VR.Bottom,targetPosition:s=VR.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:g})=>{const[y,b,x]=GR({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s});return p.createElement(IR,{path:y,labelX:b,labelY:x,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:g})}));qR.displayName="SimpleBezierEdge";const YR={[VR.Left]:{x:-1,y:0},[VR.Right]:{x:1,y:0},[VR.Top]:{x:0,y:-1},[VR.Bottom]:{x:0,y:1}},KR=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function JR({source:e,sourcePosition:t=VR.Bottom,target:n,targetPosition:r=VR.Top,center:o,offset:s}){const i=YR[t],a=YR[r],l={x:e.x+i.x*s,y:e.y+i.y*s},c={x:n.x+a.x*s,y:n.y+a.y*s},d=(({source:e,sourcePosition:t=VR.Bottom,target:n})=>t===VR.Left||t===VR.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},y={x:0,y:0},[b,x,v,w]=TR({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[u]*a[u]==-1){f=o.x??b,m=o.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 o=[{x:l.x,y:c.y}],d=[{x:c.x,y:l.y}];if(p="x"===u?i.x===h?d:o:i.y===h?o:d,t===r){const t=Math.abs(e[u]-n[u]);if(t<=s){const r=Math.min(s-1,s-t);i[u]===h?g[u]=(l[u]>e[u]?-1:1)*r:y[u]=(c[u]>n[u]?-1:1)*r}}if(t!==r){const e="x"===u?"y":"x",t=i[u]===a[e],n=l[e]>c[e],r=l[e]<c[e];(1===i[u]&&(!t&&n||t&&r)||1!==i[u]&&(!t&&r||t&&n))&&(p="x"===u?o:d)}const b={x:l.x+g.x,y:l.y+g.y},x={x:c.x+y.x,y:c.y+y.y};Math.max(Math.abs(b.x-p[0].x),Math.abs(x.x-p[0].x))>=Math.max(Math.abs(b.y-p[0].y),Math.abs(x.y-p[0].y))?(f=(b.x+x.x)/2,m=p[0].y):(f=p[0].x,m=(b.y+x.y)/2)}return[[e,{x:l.x+g.x,y:l.y+g.y},...p,{x:c.x+y.x,y:c.y+y.y},n],f,m,v,w]}function XR({sourceX:e,sourceY:t,sourcePosition:n=VR.Bottom,targetX:r,targetY:o,targetPosition:s=VR.Top,borderRadius:i=5,centerX:a,centerY:l,offset:c=20}){const[d,u,h,f,m]=JR({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:o},targetPosition:s,center:{x:a,y:l},offset:c});return[d.reduce(((e,t,n)=>{let r="";return r=n>0&&n<d.length-1?function(e,t,n,r){const o=Math.min(KR(e,t)/2,KR(t,n)/2,r),{x:s,y:i}=t;if(e.x===s&&s===n.x||e.y===i&&i===n.y)return`L${s} ${i}`;if(e.y===i)return`L ${s+o*(e.x<n.x?-1:1)},${i}Q ${s},${i} ${s},${i+o*(e.y<n.y?1:-1)}`;const a=e.x<n.x?1:-1;return`L ${s},${i+o*(e.y<n.y?-1:1)}Q ${s},${i} ${s+o*a},${i}`}(d[n-1],t,d[n+1],i):`${0===n?"M":"L"}${t.x} ${t.y}`,e+=r}),""),u,h,f,m]}const ZR=l.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,sourcePosition:u=VR.Bottom,targetPosition:h=VR.Top,markerEnd:f,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,x,v]=XR({sourceX:e,sourceY:t,sourcePosition:u,targetX:n,targetY:r,targetPosition:h,borderRadius:null==g?void 0:g.borderRadius,offset:null==g?void 0:g.offset});return p.createElement(IR,{path:b,labelX:x,labelY:v,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:f,markerStart:m,interactionWidth:y})}));ZR.displayName="SmoothStepEdge";const QR=l.memo((e=>{var t;return p.createElement(ZR,{...e,pathOptions:l.useMemo((()=>{var t;return{borderRadius:0,offset:null==(t=e.pathOptions)?void 0:t.offset}}),[null==(t=e.pathOptions)?void 0:t.offset])})}));QR.displayName="StepEdge";const eP=l.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:u,markerStart:h,interactionWidth:f})=>{const[m,g,y]=function({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[o,s,i,a]=TR({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,o,s,i,a]}({sourceX:e,sourceY:t,targetX:n,targetY:r});return p.createElement(IR,{path:m,labelX:g,labelY:y,label:o,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,style:d,markerEnd:u,markerStart:h,interactionWidth:f})}));function tP(e,t){return e>=0?.5*e:25*t*Math.sqrt(-e)}function nP({pos:e,x1:t,y1:n,x2:r,y2:o,c:s}){switch(e){case VR.Left:return[t-tP(t-r,s),n];case VR.Right:return[t+tP(r-t,s),n];case VR.Top:return[t,n-tP(n-o,s)];case VR.Bottom:return[t,n+tP(o-n,s)]}}function rP({sourceX:e,sourceY:t,sourcePosition:n=VR.Bottom,targetX:r,targetY:o,targetPosition:s=VR.Top,curvature:i=.25}){const[a,l]=nP({pos:n,x1:e,y1:t,x2:r,y2:o,c:i}),[c,d]=nP({pos:s,x1:r,y1:o,x2:e,y2:t,c:i}),[u,h,f,m]=MR({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:d});return[`M${e},${t} C${a},${l} ${c},${d} ${r},${o}`,u,h,f,m]}eP.displayName="StraightEdge";const oP=l.memo((({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:o=VR.Bottom,targetPosition:s=VR.Top,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,pathOptions:g,interactionWidth:y})=>{const[b,x,v]=rP({sourceX:e,sourceY:t,sourcePosition:o,targetX:n,targetY:r,targetPosition:s,curvature:null==g?void 0:g.curvature});return p.createElement(IR,{path:b,labelX:x,labelY:v,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:u,style:h,markerEnd:f,markerStart:m,interactionWidth:y})}));oP.displayName="BezierEdge";const sP=l.createContext(null),iP=sP.Provider;sP.Consumer;const aP=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,lP=(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("&")}`},cP=({x:e,y:t},[n,r,o],s,[i,a])=>{const l={x:(e-n)/o,y:(t-r)/o};return s?{x:i*Math.round(l.x/i),y:a*Math.round(l.y/a)}:l},dP=({x:e,y:t},[n,r,o])=>({x:e*o+n,y:t*o+r}),uP=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],o={x:e.position.x-n,y:e.position.y-r};return{...o,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:o}},hP=(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:r})=>({x:e,y:t,width:n-e,height:r-t}))(e.reduce(((e,n)=>{const{x:r,y:o}=uP(n,t).positionAbsolute;return s=e,i=xR({x:r,y:o,width:n.width||0,height:n.height||0}),{x:Math.min(s.x,i.x),y:Math.min(s.y,i.y),x2:Math.max(s.x2,i.x2),y2:Math.max(s.y2,i.y2)};var s,i}),{x:1/0,y:1/0,x2:-1/0,y2:-1/0}))},fP=(e,t,[n,r,o]=[0,0,1],s=!1,i=!1,a=[0,0])=>{const l={x:(t.x-n)/o,y:(t.y-r)/o,width:t.width/o,height:t.height/o},c=[];return e.forEach((e=>{const{width:t,height:n,selectable:r=!0,hidden:o=!1}=e;if(i&&!r||o)return!1;const{positionAbsolute:d}=uP(e,a),u={x:d.x,y:d.y,width:t||0,height:n||0},h=wR(l,u);(void 0===t||void 0===n||null===t||null===n||s&&h>0||h>=(t||0)*(n||0)||e.dragging)&&c.push(e)})),c},mP=(e,t)=>{const n=e.map((e=>e.id));return t.filter((e=>n.includes(e.source)||n.includes(e.target)))},pP=(e,t,n,r,o,s=.1)=>{const i=t/(e.width*(1+s)),a=n/(e.height*(1+s)),l=Math.min(i,a),c=mR(l,r,o);return{x:t/2-(e.x+e.width/2)*c,y:n/2-(e.y+e.height/2)*c,zoom:c}},gP=(e,t=0)=>e.transition().duration(t);function yP(e,t,n,r){return(t[n]||[]).reduce(((t,o)=>{var s,i;return`${e.id}-${o.id}-${n}`!==r&&t.push({id:o.id||null,type:n,nodeId:e.id,x:((null==(s=e.positionAbsolute)?void 0:s.x)??0)+o.x+o.width/2,y:((null==(i=e.positionAbsolute)?void 0:i.y)??0)+o.y+o.height/2}),t}),[])}const bP={source:null,target:null,sourceHandle:null,targetHandle:null},xP=()=>({handleDomNode:null,isValid:!1,connection:bP,endHandle:null});function vP(e,t,n,r,o,s,i){const a="target"===o,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={...xP(),handleDomNode:l};if(l){const e=wP(void 0,l),o=l.getAttribute("data-nodeid"),i=l.getAttribute("data-handleid"),d=l.classList.contains("connectable"),u=l.classList.contains("connectableend"),h={source:a?o:n,sourceHandle:a?i:r,target:a?n:o,targetHandle:a?r:i};c.connection=h;d&&u&&(t===DR.Strict?a&&"source"===e||!a&&"target"===e:o!==n||i!==r)&&(c.endHandle={nodeId:o,handleId:i,type:e},c.isValid=s(h))}return c}function wP(e,t){return e||((null==t?void 0:t.classList.contains("target"))?"target":(null==t?void 0:t.classList.contains("source"))?"source":null)}function kP(e){null==e||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function SP(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function CP({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:o,getState:s,setState:i,isValidConnection:a,edgeUpdaterType:l,onReconnectEnd:c}){const d=bR(e.target),{connectionMode:u,domNode:h,autoPanOnConnect:f,connectionRadius:m,onConnectStart:p,panBy:g,getNodes:y,cancelConnection:b}=s();let x,v=0;const{x:w,y:k}=jR(e),S=null==d?void 0:d.elementFromPoint(w,k),C=wP(l,S),N=null==h?void 0:h.getBoundingClientRect();if(!N||!C)return;let E,j=jR(e,N),_=!1,I=null,A=!1,T=null;const M=function({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce(((e,o)=>{if(o[SR]){const{handleBounds:s}=o[SR];let i=[],a=[];s&&(i=yP(o,s,"source",`${t}-${n}-${r}`),a=yP(o,s,"target",`${t}-${n}-${r}`)),e.push(...i,...a)}return e}),[])}({nodes:y(),nodeId:n,handleId:t,handleType:C}),D=()=>{if(!f)return;const[e,t]=yR(j,N);g({x:e,y:t}),v=requestAnimationFrame(D)};function O(e){const{transform:r}=s();j=jR(e,N);const{handle:l,validHandleResult:c}=function(e,t,n,r,o,s){const{x:i,y:a}=jR(e),l=t.elementsFromPoint(i,a).find((e=>e.classList.contains("react-flow__handle")));if(l){const e=l.getAttribute("data-nodeid");if(e){const t=wP(void 0,l),r=l.getAttribute("data-handleid"),i=s({nodeId:e,id:r,type:t});if(i){const s=o.find((n=>n.nodeId===e&&n.type===t&&n.id===r));return{handle:{id:r,type:t,nodeId:e,x:(null==s?void 0:s.x)||n.x,y:(null==s?void 0:s.y)||n.y},validHandleResult:i}}}}let c=[],d=1/0;if(o.forEach((e=>{const t=Math.sqrt((e.x-n.x)**2+(e.y-n.y)**2);if(t<=r){const n=s(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:xP()};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,cP(j,r,!1,[1,1]),m,M,(e=>vP(e,u,n,t,o?"target":"source",a,d)));if(x=l,_||(D(),_=!0),T=c.handleDomNode,I=c.connection,A=c.isValid,i({connectionPosition:x&&A?dP({x:x.x,y:x.y},r):j,connectionStatus:SP(!!x,A),connectionEndHandle:c.endHandle}),!x&&!A&&!T)return kP(E);I.source!==I.target&&T&&(kP(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 R(e){var t,n;(x||T)&&I&&A&&(null==r||r(I)),null==(n=(t=s()).onConnectEnd)||n.call(t,e),l&&(null==c||c(e)),kP(E),b(),cancelAnimationFrame(v),_=!1,A=!1,I=null,T=null,d.removeEventListener("mousemove",O),d.removeEventListener("mouseup",R),d.removeEventListener("touchmove",O),d.removeEventListener("touchend",R)}i({connectionPosition:j,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:C,connectionStartHandle:{nodeId:n,handleId:t,type:C},connectionEndHandle:null}),null==p||p(e,{nodeId:n,handleId:t,handleType:C}),d.addEventListener("mousemove",O),d.addEventListener("mouseup",R),d.addEventListener("touchmove",O),d.addEventListener("touchend",R)}const NP=()=>!0,EP=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),jP=l.forwardRef((({type:e="source",position:t=VR.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:c,className:d,onMouseDown:u,onTouchStart:h,...f},m)=>{var g,y;const b=i||null,x="target"===e,v=lR(),w=l.useContext(sP),{connectOnClick:k,noPanClassName:S}=aR(EP,EO),{connecting:C,clickConnecting:N}=aR(((e,t,n)=>r=>{const{connectionStartHandle:o,connectionEndHandle:s,connectionClickStartHandle:i}=r;return{connecting:(null==o?void 0:o.nodeId)===e&&(null==o?void 0:o.handleId)===t&&(null==o?void 0:o.type)===n||(null==s?void 0:s.nodeId)===e&&(null==s?void 0:s.handleId)===t&&(null==s?void 0:s.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,b,e),EO);w||null==(y=(g=v.getState()).onError)||y.call(g,"010",rR());const E=e=>{const{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=v.getState(),o={...t,...e};if(r){const{edges:e,setEdges:t}=v.getState();t(((e,t)=>{if(!e.source||!e.target)return t;let n;var r;return n="id"in(r=e)&&"source"in r&&"target"in r?{...e}:{...e,id:aP(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)})(o,e))}null==n||n(o),null==a||a(o)},j=e=>{if(!w)return;const t=ER(e);o&&(t&&0===e.button||!t)&&CP({event:e,handleId:b,nodeId:w,onConnect:E,isTarget:x,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||NP}),t?null==u||u(e):null==h||h(e)};return p.createElement("div",{"data-handleid":b,"data-nodeid":w,"data-handlepos":t,"data-id":`${w}-${b}-${e}`,className:vO(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,d,{source:!x,target:x,connectable:r,connectablestart:o,connectableend:s,connecting:N,connectionindicator:r&&(o&&!C||s&&C)}]),onMouseDown:j,onTouchStart:j,onClick:k?t=>{const{onClickConnectStart:r,onClickConnectEnd:s,connectionClickStartHandle:i,connectionMode:a,isValidConnection:l}=v.getState();if(!w||!i&&!o)return;if(!i)return null==r||r(t,{nodeId:w,handleId:b,handleType:e}),void v.setState({connectionClickStartHandle:{nodeId:w,type:e,handleId:b}});const c=bR(t.target),d=n||l||NP,{connection:u,isValid:h}=vP({nodeId:w,id:b,type:e},a,i.nodeId,i.handleId||null,i.type,d,c);h&&E(u),null==s||s(t),v.setState({connectionClickStartHandle:null})}:void 0,ref:m,...f},c)}));jP.displayName="Handle";var _P=l.memo(jP);const IP=({data:e,isConnectable:t,targetPosition:n=VR.Top,sourcePosition:r=VR.Bottom})=>p.createElement(p.Fragment,null,p.createElement(_P,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label,p.createElement(_P,{type:"source",position:r,isConnectable:t}));IP.displayName="DefaultNode";var AP=l.memo(IP);const TP=({data:e,isConnectable:t,sourcePosition:n=VR.Bottom})=>p.createElement(p.Fragment,null,null==e?void 0:e.label,p.createElement(_P,{type:"source",position:n,isConnectable:t}));TP.displayName="InputNode";var MP=l.memo(TP);const DP=({data:e,isConnectable:t,targetPosition:n=VR.Top})=>p.createElement(p.Fragment,null,p.createElement(_P,{type:"target",position:n,isConnectable:t}),null==e?void 0:e.label);DP.displayName="OutputNode";var OP=l.memo(DP);const RP=()=>null;RP.displayName="GroupNode";const PP=e=>({selectedNodes:e.getNodes().filter((e=>e.selected)),selectedEdges:e.edges.filter((e=>e.selected)).map((e=>({...e})))}),LP=e=>e.id;function FP(e,t){return EO(e.selectedNodes.map(LP),t.selectedNodes.map(LP))&&EO(e.selectedEdges.map(LP),t.selectedEdges.map(LP))}const zP=l.memo((({onSelectionChange:e})=>{const t=lR(),{selectedNodes:n,selectedEdges:r}=aR(PP,FP);return l.useEffect((()=>{const o={nodes:n,edges:r};null==e||e(o),t.getState().onSelectionChange.forEach((e=>e(o)))}),[n,r,e]),null}));zP.displayName="SelectionListener";const BP=e=>!!e.onSelectionChange;function UP({onSelectionChange:e}){const t=aR(BP);return e||t?p.createElement(zP,{onSelectionChange:e}):null}const $P=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 VP(e,t){l.useEffect((()=>{void 0!==e&&t(e)}),[e])}function HP(e,t,n){l.useEffect((()=>{void 0!==t&&n({[e]:t})}),[t])}const WP=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:o,onConnectStart:s,onConnectEnd:i,onClickConnectStart:a,onClickConnectEnd:c,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:p,minZoom:g,maxZoom:y,nodeExtent:b,onNodesChange:x,onEdgesChange:v,elementsSelectable:w,connectionMode:k,snapGrid:S,snapToGrid:C,translateExtent:N,connectOnClick:E,defaultEdgeOptions:j,fitView:_,fitViewOptions:I,onNodesDelete:A,onEdgesDelete:T,onNodeDrag:M,onNodeDragStart:D,onNodeDragStop:O,onSelectionDrag:R,onSelectionDragStart:P,onSelectionDragStop:L,noPanClassName:F,nodeOrigin:z,rfId:B,autoPanOnConnect:U,autoPanOnNodeDrag:$,onError:V,connectionRadius:H,isValidConnection:W,nodeDragThreshold:G})=>{const{setNodes:q,setEdges:Y,setDefaultNodesAndEdges:K,setMinZoom:J,setMaxZoom:X,setTranslateExtent:Z,setNodeExtent:Q,reset:ee}=aR($P,EO),te=lR();return l.useEffect((()=>{const e=null==r?void 0:r.map((e=>({...e,...j})));return K(n,e),()=>{ee()}}),[]),HP("defaultEdgeOptions",j,te.setState),HP("connectionMode",k,te.setState),HP("onConnect",o,te.setState),HP("onConnectStart",s,te.setState),HP("onConnectEnd",i,te.setState),HP("onClickConnectStart",a,te.setState),HP("onClickConnectEnd",c,te.setState),HP("nodesDraggable",d,te.setState),HP("nodesConnectable",u,te.setState),HP("nodesFocusable",h,te.setState),HP("edgesFocusable",f,te.setState),HP("edgesUpdatable",m,te.setState),HP("elementsSelectable",w,te.setState),HP("elevateNodesOnSelect",p,te.setState),HP("snapToGrid",C,te.setState),HP("snapGrid",S,te.setState),HP("onNodesChange",x,te.setState),HP("onEdgesChange",v,te.setState),HP("connectOnClick",E,te.setState),HP("fitViewOnInit",_,te.setState),HP("fitViewOnInitOptions",I,te.setState),HP("onNodesDelete",A,te.setState),HP("onEdgesDelete",T,te.setState),HP("onNodeDrag",M,te.setState),HP("onNodeDragStart",D,te.setState),HP("onNodeDragStop",O,te.setState),HP("onSelectionDrag",R,te.setState),HP("onSelectionDragStart",P,te.setState),HP("onSelectionDragStop",L,te.setState),HP("noPanClassName",F,te.setState),HP("nodeOrigin",z,te.setState),HP("rfId",B,te.setState),HP("autoPanOnConnect",U,te.setState),HP("autoPanOnNodeDrag",$,te.setState),HP("onError",V,te.setState),HP("connectionRadius",H,te.setState),HP("isValidConnection",W,te.setState),HP("nodeDragThreshold",G,te.setState),VP(e,q),VP(t,Y),VP(g,J),VP(y,X),VP(N,Z),VP(b,Q),null},GP={display:"none"},qP={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},YP="react-flow__node-desc",KP="react-flow__edge-desc",JP=e=>e.ariaLiveMessage;function XP({rfId:e}){const t=aR(JP);return p.createElement("div",{id:`react-flow__aria-live-${e}`,"aria-live":"assertive","aria-atomic":"true",style:qP},t)}function ZP({rfId:e,disableKeyboardA11y:t}){return p.createElement(p.Fragment,null,p.createElement("div",{id:`${YP}-${e}`,style:GP},"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."," "),p.createElement("div",{id:`${KP}-${e}`,style:GP},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&p.createElement(XP,{rfId:e}))}var QP=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=l.useState(!1),o=l.useRef(!1),s=l.useRef(new Set([])),[i,a]=l.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 l.useEffect((()=>{const n="undefined"!=typeof document?document:null,l=(null==t?void 0:t.target)||n;if(null!==e){const e=e=>{o.current=e.ctrlKey||e.metaKey||e.shiftKey;if((!o.current||o.current&&!t.actInsideInputWithModifier)&&NR(e))return!1;const n=tL(e.code,a);s.current.add(e[n]),eL(i,s.current,!1)&&(e.preventDefault(),r(!0))},n=e=>{if((!o.current||o.current&&!t.actInsideInputWithModifier)&&NR(e))return!1;const n=tL(e.code,a);eL(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(e[n]),"Meta"===e.key&&s.current.clear(),o.current=!1},c=()=>{s.current.clear(),r(!1)};return null==l||l.addEventListener("keydown",e),null==l||l.addEventListener("keyup",n),window.addEventListener("blur",c),()=>{null==l||l.removeEventListener("keydown",e),null==l||l.removeEventListener("keyup",n),window.removeEventListener("blur",c)}}}),[e,r]),n};function eL(e,t,n){return e.filter((e=>n||e.length===t.size)).some((e=>e.every((e=>t.has(e)))))}function tL(e,t){return t.includes(e)?"code":"key"}function nL(e,t,n,r){var o,s;const i=e.parentNode||e.parentId;if(!i)return n;const a=t.get(i),l=uP(a,r);return nL(a,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:((null==(o=a[SR])?void 0:o.z)??0)>(n.z??0)?(null==(s=a[SR])?void 0:s.z)??0:n.z??0},r)}function rL(e,t,n){e.forEach((r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||(null==n?void 0:n[r.id])){const{x:s,y:i,z:a}=nL(r,e,{...r.position,z:(null==(o=r[SR])?void 0:o.z)??0},t);r.positionAbsolute={x:s,y:i},r[SR].z=a,(null==n?void 0:n[r.id])&&(r[SR].isParent=!0)}}))}function oL(e,t,n,r){const o=new Map,s={},i=r?1e3:0;return e.forEach((e=>{var n;const r=(kR(e.zIndex)?e.zIndex:0)+(e.selected?i:0),a=t.get(e.id),l={...e,positionAbsolute:{x:e.position.x,y:e.position.y}},c=e.parentNode||e.parentId;c&&(s[c]=!0);const d=(null==a?void 0:a.type)&&(null==a?void 0:a.type)!==e.type;Object.defineProperty(l,SR,{enumerable:!1,value:{handleBounds:d||null==(n=null==a?void 0:a[SR])?void 0:n.handleBounds,z:r}}),o.set(e.id,l)})),rL(o,n,s),o}function sL(e,t={}){const{getNodes:n,width:r,height:o,minZoom:s,maxZoom:i,d3Zoom:a,d3Selection:l,fitViewOnInitDone:c,fitViewOnInit:d,nodeOrigin:u}=e(),h=t.initial&&!c&&d;if(a&&l&&(h||!t.initial)){const e=n().filter((e=>{var n;const r=t.includeHiddenNodes?e.width&&e.height:!e.hidden;return(null==(n=t.nodes)?void 0:n.length)?r&&t.nodes.some((t=>t.id===e.id)):r})),c=e.every((e=>e.width&&e.height));if(e.length>0&&c){const n=hP(e,u),{x:c,y:d,zoom:h}=pP(n,r,o,t.minZoom??s,t.maxZoom??i,t.padding??.1),f=dd.translate(c,d).scale(h);return"number"==typeof t.duration&&t.duration>0?a.transform(gP(l,t.duration),f):a.transform(l,f),!0}}return!1}function iL(e,t){return e.forEach((e=>{const n=t.get(e.id);n&&t.set(n.id,{...n,[SR]:n[SR],selected:e.selected})})),new Map(t)}function aL(e,t){return t.map((t=>{const n=e.find((e=>e.id===t.id));return n&&(t.selected=n.selected),t}))}function lL({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:o,edges:s,onNodesChange:i,onEdgesChange:a,hasDefaultNodes:l,hasDefaultEdges:c}=n();(null==e?void 0:e.length)&&(l&&r({nodeInternals:iL(e,o)}),null==i||i(e)),(null==t?void 0:t.length)&&(c&&r({edges:aL(t,s)}),null==a||a(t))}const cL=()=>{},dL={zoomIn:cL,zoomOut:cL,zoomTo:cL,getZoom:()=>1,setViewport:cL,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:cL,fitBounds:cL,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},uL=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection});function hL(){const e=(()=>{const e=lR(),{d3Zoom:t,d3Selection:n}=aR(uL,EO),r=l.useMemo((()=>n&&t?{zoomIn:e=>t.scaleBy(gP(n,null==e?void 0:e.duration),1.2),zoomOut:e=>t.scaleBy(gP(n,null==e?void 0:e.duration),1/1.2),zoomTo:(e,r)=>t.scaleTo(gP(n,null==r?void 0:r.duration),e),getZoom:()=>e.getState().transform[2],setViewport:(r,o)=>{const[s,i,a]=e.getState().transform,l=dd.translate(r.x??s,r.y??i).scale(r.zoom??a);t.transform(gP(n,null==o?void 0:o.duration),l)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},fitView:t=>sL(e.getState,t),setCenter:(r,o,s)=>{const{width:i,height:a,maxZoom:l}=e.getState(),c=void 0!==(null==s?void 0:s.zoom)?s.zoom:l,d=i/2-r*c,u=a/2-o*c,h=dd.translate(d,u).scale(c);t.transform(gP(n,null==s?void 0:s.duration),h)},fitBounds:(r,o)=>{const{width:s,height:i,minZoom:a,maxZoom:l}=e.getState(),{x:c,y:d,zoom:u}=pP(r,s,i,a,l,(null==o?void 0:o.padding)??.1),h=dd.translate(c,d).scale(u);t.transform(gP(n,null==o?void 0:o.duration),h)},project:t=>{const{transform:n,snapToGrid:r,snapGrid:o}=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"),cP(t,n,r,o)},screenToFlowPosition:t=>{const{transform:n,snapToGrid:r,snapGrid:o,domNode:s}=e.getState();if(!s)return t;const{x:i,y:a}=s.getBoundingClientRect(),l={x:t.x-i,y:t.y-a};return cP(l,n,r,o)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:s}=r.getBoundingClientRect(),i=dP(t,n);return{x:i.x+o,y:i.y+s}},viewportInitialized:!0}:dL),[t,n]);return r})(),t=lR(),n=l.useCallback((()=>t.getState().getNodes().map((e=>({...e})))),[]),r=l.useCallback((e=>t.getState().nodeInternals.get(e)),[]),o=l.useCallback((()=>{const{edges:e=[]}=t.getState();return e.map((e=>({...e})))}),[]),s=l.useCallback((e=>{const{edges:n=[]}=t.getState();return n.find((t=>t.id===e))}),[]),i=l.useCallback((e=>{const{getNodes:n,setNodes:r,hasDefaultNodes:o,onNodesChange:s}=t.getState(),i=n(),a="function"==typeof e?e(i):e;if(o)r(a);else if(s){s(0===a.length?i.map((e=>({type:"remove",id:e.id}))):a.map((e=>({item:e,type:"reset"}))))}}),[]),a=l.useCallback((e=>{const{edges:n=[],setEdges:r,hasDefaultEdges:o,onEdgesChange:s}=t.getState(),i="function"==typeof e?e(n):e;if(o)r(i);else if(s){s(0===i.length?n.map((e=>({type:"remove",id:e.id}))):i.map((e=>({item:e,type:"reset"}))))}}),[]),c=l.useCallback((e=>{const n=Array.isArray(e)?e:[e],{getNodes:r,setNodes:o,hasDefaultNodes:s,onNodesChange:i}=t.getState();if(s){o([...r(),...n])}else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),d=l.useCallback((e=>{const n=Array.isArray(e)?e:[e],{edges:r=[],setEdges:o,hasDefaultEdges:s,onEdgesChange:i}=t.getState();if(s)o([...r,...n]);else if(i){i(n.map((e=>({item:e,type:"add"}))))}}),[]),u=l.useCallback((()=>{const{getNodes:e,edges:n=[],transform:r}=t.getState(),[o,s,i]=r;return{nodes:e().map((e=>({...e}))),edges:n.map((e=>({...e}))),viewport:{x:o,y:s,zoom:i}}}),[]),h=l.useCallback((({nodes:e,edges:n})=>{const{nodeInternals:r,getNodes:o,edges:s,hasDefaultNodes:i,hasDefaultEdges:a,onNodesDelete:l,onEdgesDelete:c,onNodesChange:d,onEdgesChange:u}=t.getState(),h=(e||[]).map((e=>e.id)),f=(n||[]).map((e=>e.id)),m=o().reduce(((e,t)=>{const n=t.parentNode||t.parentId,r=!h.includes(t.id)&&n&&e.find((e=>e.id===n));return("boolean"!=typeof t.deletable||t.deletable)&&(h.includes(t.id)||r)&&e.push(t),e}),[]),p=s.filter((e=>"boolean"!=typeof e.deletable||e.deletable)),g=p.filter((e=>f.includes(e.id)));if(m||g){const e=mP(m,p),n=[...g,...e],o=n.reduce(((e,t)=>(e.includes(t.id)||e.push(t.id),e)),[]);if((a||i)&&(a&&t.setState({edges:s.filter((e=>!o.includes(e.id)))}),i&&(m.forEach((e=>{r.delete(e.id)})),t.setState({nodeInternals:new Map(r)}))),o.length>0&&(null==c||c(n),u&&u(o.map((e=>({id:e,type:"remove"}))))),m.length>0&&(null==l||l(m),d)){d(m.map((e=>({id:e.id,type:"remove"}))))}}}),[]),f=l.useCallback((e=>{const n=kR((r=e).width)&&kR(r.height)&&kR(r.x)&&kR(r.y);var r;const o=n?null:t.getState().nodeInternals.get(e.id);if(!n&&!o)return[null,null,n];return[n?e:vR(o),o,n]}),[]),m=l.useCallback(((e,n=!0,r)=>{const[o,s,i]=f(e);return o?(r||t.getState().getNodes()).filter((e=>{if(!(i||e.id!==s.id&&e.positionAbsolute))return!1;const t=vR(e),r=wR(t,o);return n&&r>0||r>=o.width*o.height})):[]}),[]),p=l.useCallback(((e,t,n=!0)=>{const[r]=f(e);if(!r)return!1;const o=wR(r,t);return n&&o>0||o>=r.width*r.height}),[]);return l.useMemo((()=>({...e,getNodes:n,getNode:r,getEdges:o,getEdge:s,setNodes:i,setEdges:a,addNodes:c,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:p})),[e,n,r,o,s,i,a,c,d,u,h,m,p])}const fL={actInsideInputWithModifier:!1};const mL={position:"absolute",width:"100%",height:"100%",top:0,left:0},pL=e=>({x:e.x,y:e.y,zoom:e.k}),gL=(e,t)=>e.target.closest(`.${t}`),yL=(e,t)=>2===t&&Array.isArray(e)&&e.includes(2),bL=e=>{const t=e.ctrlKey&&_R()?10:1;return-e.deltaY*(1===e.deltaMode?.05:e.deltaMode?1:.002)*t},xL=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),vL=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:o=!0,zoomOnPinch:s=!0,panOnScroll:i=!1,panOnScrollSpeed:a=.5,panOnScrollMode:c=RR.Free,zoomOnDoubleClick:d=!0,elementsSelectable:u,panOnDrag:h=!0,defaultViewport:f,translateExtent:m,minZoom:g,maxZoom:y,zoomActivationKeyCode:b,preventScrolling:x=!0,children:v,noWheelClassName:w,noPanClassName:k})=>{const S=l.useRef(),C=lR(),N=l.useRef(!1),E=l.useRef(!1),j=l.useRef(null),_=l.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:A,d3ZoomHandler:T,userSelectionActive:M}=aR(xL,EO),D=QP(b),O=l.useRef(0),R=l.useRef(!1),P=l.useRef();return function(e){const t=lR();l.useEffect((()=>{let n;const r=()=>{var n,r;if(!e.current)return;const o=fR(e.current);0!==o.height&&0!==o.width||null==(r=(n=t.getState()).onError)||r.call(n,"004",QO()),t.setState({width:o.width||500,height:o.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver((()=>r())),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}}),[])}(j),l.useEffect((()=>{if(j.current){const e=j.current.getBoundingClientRect(),t=function(){var e,t,n,r=HO,o=WO,s=KO,i=qO,a=YO,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],d=250,u=md,h=fd("start","zoom","end"),f=0,m=10;function p(e){e.property("__zoom",GO).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",S).on("dblclick.zoom",C).filter(a).on("touchstart.zoom",N).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 ud(t,e.x,e.y)}function y(e,t,n){var r=t[0]-n[0]*e.k,o=t[1]-n[1]*e.k;return r===e.x&&o===e.y?e:new ud(e.k,r,o)}function b(e){return[(+e[0][0]+ +e[1][0])/2,(+e[0][1]+ +e[1][1])/2]}function x(e,t,n,r){e.on("start.zoom",(function(){v(this,arguments).event(r).start()})).on("interrupt.zoom end.zoom",(function(){v(this,arguments).event(r).end()})).tween("zoom",(function(){var e=this,s=arguments,i=v(e,s).event(r),a=o.apply(e,s),l=null==n?b(a):"function"==typeof n?n.apply(e,s):n,c=Math.max(a[1][0]-a[0][0],a[1][1]-a[0][1]),d=e.__zoom,h="function"==typeof t?t.apply(e,s):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 ud(n,l[0]-t[0]*n,l[1]-t[1]*n)}i.zoom(null,e)}}))}function v(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=o.apply(e,t),this.taps=0}function k(e,...t){if(r.apply(this,arguments)){var n=v(this,t).event(e),o=this.__zoom,a=Math.max(l[0],Math.min(l[1],o.k*Math.pow(2,i.apply(this,arguments)))),d=jO(e);if(n.wheel)n.mouse[0][0]===d[0]&&n.mouse[0][1]===d[1]||(n.mouse[1]=o.invert(n.mouse[0]=d)),clearTimeout(n.wheel);else{if(o.k===a)return;n.mouse=[d,o.invert(d)],hd(this),n.start()}VO(e),n.wheel=setTimeout((function(){n.wheel=null,n.end()}),150),n.zoom("mouse",s(y(g(o,a),n.mouse[0],n.mouse[1]),n.extent,c))}}function S(e,...t){if(!n&&r.apply(this,arguments)){var o=e.currentTarget,i=v(this,t,!0).event(e),a=cd(e.view).on("mousemove.zoom",(function(e){if(VO(e),!i.moved){var t=e.clientX-d,n=e.clientY-u;i.moved=t*t+n*n>f}i.event(e).zoom("mouse",s(y(i.that.__zoom,i.mouse[0]=jO(e,o),i.mouse[1]),i.extent,c))}),!0).on("mouseup.zoom",(function(e){a.on("mousemove.zoom mouseup.zoom",null),DO(e.view,i.moved),VO(e),i.event(e).end()}),!0),l=jO(e,o),d=e.clientX,u=e.clientY;MO(e.view),$O(e),i.mouse=[l,this.__zoom.invert(l)],hd(this),i.start()}}function C(e,...t){if(r.apply(this,arguments)){var n=this.__zoom,i=jO(e.changedTouches?e.changedTouches[0]:e,this),a=n.invert(i),l=n.k*(e.shiftKey?.5:2),u=s(y(g(n,l),i,a),o.apply(this,t),c);VO(e),d>0?cd(this).transition().duration(d).call(x,u,i,e):cd(this).call(p.transform,u,i,e)}}function N(n,...o){if(r.apply(this,arguments)){var s,i,a,l,c=n.touches,d=c.length,u=v(this,o,n.changedTouches.length===d).event(n);for($O(n),i=0;i<d;++i)l=[l=jO(a=c[i],this),this.__zoom.invert(l),a.identifier],u.touch0?u.touch1||u.touch0[2]===l[2]||(u.touch1=l,u.taps=0):(u.touch0=l,s=!0,u.taps=1+!!e);e&&(e=clearTimeout(e)),s&&(u.taps<2&&(t=l[0],e=setTimeout((function(){e=null}),500)),hd(this),u.start())}}function E(e,...t){if(this.__zooming){var n,r,o,i,a=v(this,t).event(e),l=e.changedTouches,d=l.length;for(VO(e),n=0;n<d;++n)o=jO(r=l[n],this),a.touch0&&a.touch0[2]===r.identifier?a.touch0[0]=o:a.touch1&&a.touch1[2]===r.identifier&&(a.touch1[0]=o);if(r=a.that.__zoom,a.touch1){var u=a.touch0[0],h=a.touch0[1],f=a.touch1[0],m=a.touch1[1],p=(p=f[0]-u[0])*p+(p=f[1]-u[1])*p,b=(b=m[0]-h[0])*b+(b=m[1]-h[1])*b;r=g(r,Math.sqrt(p/b)),o=[(u[0]+f[0])/2,(u[1]+f[1])/2],i=[(h[0]+m[0])/2,(h[1]+m[1])/2]}else{if(!a.touch0)return;o=a.touch0[0],i=a.touch0[1]}a.zoom("touch",s(y(r,o,i),a.extent,c))}}function j(e,...r){if(this.__zooming){var o,s,i=v(this,r).event(e),a=e.changedTouches,l=a.length;for($O(e),n&&clearTimeout(n),n=setTimeout((function(){n=null}),500),o=0;o<l;++o)s=a[o],i.touch0&&i.touch0[2]===s.identifier?delete i.touch0:i.touch1&&i.touch1[2]===s.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&&(s=jO(s,this),Math.hypot(t[0]-s[0],t[1]-s[1])<m)){var c=cd(this).on("dblclick.zoom");c&&c.apply(this,arguments)}}}return p.transform=function(e,t,n,r){var o=e.selection?e.selection():e;o.property("__zoom",GO),e!==o?x(e,t,n,r):o.interrupt().each((function(){v(this,arguments).event(r).start().zoom(null,"function"==typeof t?t.apply(this,arguments):t).end()}))},p.scaleBy=function(e,t,n,r){p.scaleTo(e,(function(){return this.__zoom.k*("function"==typeof t?t.apply(this,arguments):t)}),n,r)},p.scaleTo=function(e,t,n,r){p.transform(e,(function(){var e=o.apply(this,arguments),r=this.__zoom,i=null==n?b(e):"function"==typeof n?n.apply(this,arguments):n,a=r.invert(i),l="function"==typeof t?t.apply(this,arguments):t;return s(y(g(r,l),i,a),e,c)}),n,r)},p.translateBy=function(e,t,n,r){p.transform(e,(function(){return s(this.__zoom.translate("function"==typeof t?t.apply(this,arguments):t,"function"==typeof n?n.apply(this,arguments):n),o.apply(this,arguments),c)}),null,r)},p.translateTo=function(e,t,n,r,i){p.transform(e,(function(){var e=o.apply(this,arguments),i=this.__zoom,a=null==r?b(e):"function"==typeof r?r.apply(this,arguments):r;return s(dd.translate(a[0],a[1]).scale(i.k).translate("function"==typeof t?-t.apply(this,arguments):-t,"function"==typeof n?-n.apply(this,arguments):-n),e,c)}),r,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=cd(this.that).datum();h.call(e,this.that,new UO(e,{sourceEvent:this.sourceEvent,target:p,transform:this.that.__zoom,dispatch:h}),t)}},p.wheelDelta=function(e){return arguments.length?(i="function"==typeof e?e:BO(+e),p):i},p.filter=function(e){return arguments.length?(r="function"==typeof e?e:BO(!!e),p):r},p.touchable=function(e){return arguments.length?(a="function"==typeof e?e:BO(!!e),p):a},p.extent=function(e){return arguments.length?(o="function"==typeof e?e:BO([[+e[0][0],+e[0][1]],[+e[1][0],+e[1][1]]]),p):o},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?(s=e,p):s},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,y]).translateExtent(m),n=cd(j.current).call(t),r=dd.translate(f.x,f.y).scale(mR(f.zoom,g,y)),o=[[0,0],[e.width,e.height]],s=t.constrain()(r,o,m);t.transform(n,s),t.wheelDelta(bL),C.setState({d3Zoom:t,d3Selection:n,d3ZoomHandler:n.on("wheel.zoom"),transform:[s.x,s.y,s.k],domNode:j.current.closest(".react-flow")})}}),[]),l.useEffect((()=>{A&&I&&(!i||D||M?void 0!==T&&A.on("wheel.zoom",(function(e,t){if(!x&&"wheel"===e.type&&!e.ctrlKey||gL(e,w))return null;e.preventDefault(),T.call(this,e,t)}),{passive:!1}):A.on("wheel.zoom",(r=>{if(gL(r,w))return!1;r.preventDefault(),r.stopImmediatePropagation();const o=A.property("__zoom").k||1;if(r.ctrlKey&&s){const e=jO(r),t=bL(r),n=o*Math.pow(2,t);return void I.scaleTo(A,n,e,r)}const i=1===r.deltaMode?20:1;let l=c===RR.Vertical?0:r.deltaX*i,d=c===RR.Horizontal?0:r.deltaY*i;!_R()&&r.shiftKey&&c!==RR.Vertical&&(l=r.deltaY*i,d=0),I.translateBy(A,-l/o*a,-d/o*a,{internal:!0});const u=pL(A.property("__zoom")),{onViewportChangeStart:h,onViewportChange:f,onViewportChangeEnd:m}=C.getState();clearTimeout(P.current),R.current||(R.current=!0,null==t||t(r,u),null==h||h(u)),R.current&&(null==e||e(r,u),null==f||f(u),P.current=setTimeout((()=>{null==n||n(r,u),null==m||m(u),R.current=!1}),150))}),{passive:!1}))}),[M,i,c,A,I,T,D,s,x,w,t,e,n]),l.useEffect((()=>{I&&I.on("start",(e=>{var n,r;if(!e.sourceEvent||e.sourceEvent.internal)return null;O.current=null==(n=e.sourceEvent)?void 0:n.button;const{onViewportChangeStart:o}=C.getState(),s=pL(e.transform);N.current=!0,_.current=s,"mousedown"===(null==(r=e.sourceEvent)?void 0:r.type)&&C.setState({paneDragging:!0}),null==o||o(s),null==t||t(e.sourceEvent,s)}))}),[I,t]),l.useEffect((()=>{I&&(M&&!N.current?I.on("zoom",null):M||I.on("zoom",(t=>{var n;const{onViewportChange:o}=C.getState();if(C.setState({transform:[t.transform.x,t.transform.y,t.transform.k]}),E.current=!(!r||!yL(h,O.current??0)),(e||o)&&!(null==(n=t.sourceEvent)?void 0:n.internal)){const n=pL(t.transform);null==o||o(n),null==e||e(t.sourceEvent,n)}})))}),[M,I,e,h,r]),l.useEffect((()=>{I&&I.on("end",(e=>{if(!e.sourceEvent||e.sourceEvent.internal)return null;const{onViewportChangeEnd:t}=C.getState();if(N.current=!1,C.setState({paneDragging:!1}),r&&yL(h,O.current??0)&&!E.current&&r(e.sourceEvent),E.current=!1,(n||t)&&(o=_.current,s=e.transform,o.x!==s.x||o.y!==s.y||o.zoom!==s.k)){const r=pL(e.transform);_.current=r,clearTimeout(S.current),S.current=setTimeout((()=>{null==t||t(r),null==n||n(e.sourceEvent,r)}),i?150:0)}var o,s}))}),[I,i,h,n,r]),l.useEffect((()=>{I&&I.filter((e=>{const t=D||o,n=s&&e.ctrlKey;if((!0===h||Array.isArray(h)&&h.includes(1))&&1===e.button&&"mousedown"===e.type&&(gL(e,"react-flow__node")||gL(e,"react-flow__edge")))return!0;if(!(h||t||i||d||s))return!1;if(M)return!1;if(!d&&"dblclick"===e.type)return!1;if(gL(e,w)&&"wheel"===e.type)return!1;if(gL(e,k)&&("wheel"!==e.type||i&&"wheel"===e.type&&!D))return!1;if(!s&&e.ctrlKey&&"wheel"===e.type)return!1;if(!t&&!i&&!n&&"wheel"===e.type)return!1;if(!h&&("mousedown"===e.type||"touchstart"===e.type))return!1;if(Array.isArray(h)&&!h.includes(e.button)&&"mousedown"===e.type)return!1;const r=Array.isArray(h)&&h.includes(e.button)||!e.button||e.button<=1;return(!e.ctrlKey||"wheel"===e.type)&&r}))}),[M,I,o,s,i,d,h,u,D]),p.createElement("div",{className:"react-flow__renderer",ref:j,style:mL},v)},wL=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function kL(){const{userSelectionActive:e,userSelectionRect:t}=aR(wL,EO);return e&&t?p.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 SL(e,t){const n=t.parentNode||t.parentId,r=e.find((e=>e.id===n));if(r){const e=t.position.x+t.width-r.width,n=t.position.y+t.height-r.height;if(e>0||n>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,e>0&&(r.style.width+=e),n>0&&(r.style.height+=n),t.position.x<0){const e=Math.abs(t.position.x);r.position.x=r.position.x-e,r.style.width+=e,t.position.x=0}if(t.position.y<0){const e=Math.abs(t.position.y);r.position.y=r.position.y-e,r.style.height+=e,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function CL(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 r=e.filter((e=>e.id===n.id));if(0===r.length)return t.push(n),t;const o={...n};for(const e of r)if(e)switch(e.type){case"select":o.selected=e.selected;break;case"position":void 0!==e.position&&(o.position=e.position),void 0!==e.positionAbsolute&&(o.positionAbsolute=e.positionAbsolute),void 0!==e.dragging&&(o.dragging=e.dragging),o.expandParent&&SL(t,o);break;case"dimensions":void 0!==e.dimensions&&(o.width=e.dimensions.width,o.height=e.dimensions.height),void 0!==e.updateStyle&&(o.style={...o.style||{},...e.dimensions}),"boolean"==typeof e.resizing&&(o.resizing=e.resizing),o.expandParent&&SL(t,o);break;case"remove":return t}return t.push(o),t}),n)}function NL(e,t){return CL(e,t)}const EL=(e,t)=>({id:e,type:"select",selected:t});function jL(e,t){return e.reduce(((e,n)=>{const r=t.includes(n.id);return!n.selected&&r?(n.selected=!0,e.push(EL(n.id,!0))):n.selected&&!r&&(n.selected=!1,e.push(EL(n.id,!1))),e}),[])}const _L=(e,t)=>n=>{n.target===t.current&&(null==e||e(n))},IL=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),AL=l.memo((({isSelecting:e,selectionMode:t=LR.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:o,onPaneClick:s,onPaneContextMenu:i,onPaneScroll:a,onPaneMouseEnter:c,onPaneMouseMove:d,onPaneMouseLeave:u,children:h})=>{const f=l.useRef(null),m=lR(),g=l.useRef(0),y=l.useRef(0),b=l.useRef(),{userSelectionActive:x,elementsSelectable:v,dragging:w}=aR(IL,EO),k=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),g.current=0,y.current=0},S=e=>{null==s||s(e),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},C=a?e=>a(e):void 0,N=v&&(e||x);return p.createElement("div",{className:vO(["react-flow__pane",{dragging:w,selection:e}]),onClick:N?void 0:_L(S,f),onContextMenu:_L((e=>{Array.isArray(n)&&(null==n?void 0:n.includes(2))?e.preventDefault():null==i||i(e)}),f),onWheel:_L(C,f),onMouseEnter:N?void 0:c,onMouseDown:N?t=>{const{resetSelectedElements:n,domNode:o}=m.getState();if(b.current=null==o?void 0:o.getBoundingClientRect(),!v||!e||0!==t.button||t.target!==f.current||!b.current)return;const{x:s,y:i}=jR(t,b.current);n(),m.setState({userSelectionRect:{width:0,height:0,startX:s,startY:i,x:s,y:i}}),null==r||r(t)}:void 0,onMouseMove:N?n=>{const{userSelectionRect:r,nodeInternals:o,edges:s,transform:i,onNodesChange:a,onEdgesChange:l,nodeOrigin:c,getNodes:d}=m.getState();if(!e||!b.current||!r)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const u=jR(n,b.current),h=r.startX??0,f=r.startY??0,p={...r,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(),v=fP(o,p,i,t===LR.Partial,!0,c),w=mP(v,s).map((e=>e.id)),k=v.map((e=>e.id));if(g.current!==k.length){g.current=k.length;const e=jL(x,k);e.length&&(null==a||a(e))}if(y.current!==w.length){y.current=w.length;const e=jL(s,w);e.length&&(null==l||l(e))}m.setState({userSelectionRect:p})}:d,onMouseUp:N?e=>{if(0!==e.button)return;const{userSelectionRect:t}=m.getState();!x&&t&&e.target===f.current&&(null==S||S(e)),m.setState({nodesSelectionActive:g.current>0}),k(),null==o||o(e)}:void 0,onMouseLeave:N?e=>{x&&(m.setState({nodesSelectionActive:g.current>0}),null==o||o(e)),k()}:u,ref:f,style:mL},h,p.createElement(kL,null))}));function TL(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return!!r&&(!!r.selected||TL(r,t))}function ML(e,t,n){let r=e;do{if(null==r?void 0:r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function DL(e,t,n,r){return Array.from(e.values()).filter((n=>(n.selected||n.id===r)&&(!n.parentNode||n.parentId||!TL(n,e))&&(n.draggable||t&&void 0===n.draggable))).map((e=>{var t,r;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==(r=e.positionAbsolute)?void 0:r.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 OL(e,t,n,r,o=[0,0],s){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||r);let a=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:r,y:s}=uP(t,o).positionAbsolute;a=[[e.extent[0][0]+r,e.extent[0][1]+s],[e.extent[1][0]+r,e.extent[1][1]+s]]}}else if(l&&e.width&&e.height){const t=n.get(l),{x:r,y:s}=uP(t,o).positionAbsolute;a=t&&kR(r)&&kR(s)&&kR(t.width)&&kR(t.height)?[[r+e.width*o[0],s+e.height*o[1]],[r+t.width-e.width+e.width*o[0],s+t.height-e.height+e.height*o[1]]]:a}else null==s||s("005",eR()),a=i;let c={x:0,y:0};if(l){const e=n.get(l);c=uP(e,o).positionAbsolute}const d=a&&"parent"!==a?pR(t,a):t;return{position:{x:d.x-c.x,y:d.y-c.y},positionAbsolute:d}}function RL({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map((e=>({...n.get(e.id),position:e.position,positionAbsolute:e.positionAbsolute})));return[e?r.find((t=>t.id===e)):r[0],r]}AL.displayName="Pane";const PL=(e,t,n,r)=>{const o=t.querySelectorAll(e);if(!o||!o.length)return null;const s=Array.from(o),i=t.getBoundingClientRect(),a=i.width*r[0],l=i.height*r[1];return s.map((e=>{const t=e.getBoundingClientRect();return{id:e.getAttribute("data-handleid"),position:e.getAttribute("data-handlepos"),x:(t.left-i.left-a)/n,y:(t.top-i.top-l)/n,...fR(e)}}))};function LL(e,t,n){return void 0===n?n:r=>{const o=t().nodeInternals.get(e);o&&n(r,{...o})}}function FL({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeInternals:a,onError:l}=t.getState(),c=a.get(e);c?(t.setState({nodesSelectionActive:!1}),c.selected?(n||c.selected&&i)&&(s({nodes:[c],edges:[]}),requestAnimationFrame((()=>{var e;return null==(e=null==r?void 0:r.current)?void 0:e.blur()}))):o([e])):null==l||l("012",sR(e))}function zL(e){return(t,n,r)=>null==e?void 0:e(t,r)}function BL({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,selectNodesOnDrag:i}){const a=lR(),[c,d]=l.useState(!1),u=l.useRef([]),h=l.useRef({x:null,y:null}),f=l.useRef(0),m=l.useRef(null),p=l.useRef({x:0,y:0}),g=l.useRef(null),y=l.useRef(!1),b=l.useRef(!1),x=l.useRef(!1),v=function(){const e=lR();return l.useCallback((({sourceEvent:t})=>{const{transform:n,snapGrid:r,snapToGrid:o}=e.getState(),s=t.touches?t.touches[0].clientX:t.clientX,i=t.touches?t.touches[0].clientY:t.clientY,a={x:(s-n[0])/n[2],y:(i-n[1])/n[2]};return{xSnapped:o?r[0]*Math.round(a.x/r[0]):a.x,ySnapped:o?r[1]*Math.round(a.y/r[1]):a.y,...a}}),[])}();return l.useEffect((()=>{if(null==e?void 0:e.current){const l=cd(e.current),c=({x:e,y:t})=>{const{nodeInternals:n,onNodeDrag:r,onSelectionDrag:s,updateNodePositions:i,nodeExtent:l,snapGrid:c,snapToGrid:f,nodeOrigin:m,onError:p}=a.getState();h.current={x:e,y:t};let y=!1,b={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&l){const e=hP(u.current,m);b=xR(e)}if(u.current=u.current.map((r=>{const o={x:e-r.distance.x,y:t-r.distance.y};f&&(o.x=c[0]*Math.round(o.x/c[0]),o.y=c[1]*Math.round(o.y/c[1]));const s=[[l[0][0],l[0][1]],[l[1][0],l[1][1]]];u.current.length>1&&l&&!r.extent&&(s[0][0]=r.positionAbsolute.x-b.x+l[0][0],s[1][0]=r.positionAbsolute.x+(r.width??0)-b.x2+l[1][0],s[0][1]=r.positionAbsolute.y-b.y+l[0][1],s[1][1]=r.positionAbsolute.y+(r.height??0)-b.y2+l[1][1]);const i=OL(r,o,n,s,m,p);return y=y||r.position.x!==i.position.x||r.position.y!==i.position.y,r.position=i.position,r.positionAbsolute=i.positionAbsolute,r})),!y)return;i(u.current,!0,!0),d(!0);const x=o?r:zL(s);if(x&&g.current){const[e,t]=RL({nodeId:o,dragItems:u.current,nodeInternals:n});x(g.current,e,t)}},w=()=>{if(!m.current)return;const[e,t]=yR(p.current,m.current);if(0!==e||0!==t){const{transform:n,panBy:r}=a.getState();h.current.x=(h.current.x??0)-e/n[2],h.current.y=(h.current.y??0)-t/n[2],r({x:e,y:t})&&c(h.current)}f.current=requestAnimationFrame(w)},k=t=>{var n;const{nodeInternals:r,multiSelectionActive:l,nodesDraggable:c,unselectNodesAndEdges:d,onNodeDragStart:f,onSelectionDragStart:m}=a.getState();b.current=!0;const p=o?f:zL(m);i&&s||l||!o||(null==(n=r.get(o))?void 0:n.selected)||d(),o&&s&&i&&FL({id:o,store:a,nodeRef:e});const g=v(t);if(h.current=g,u.current=DL(r,c,g,o),p&&u.current){const[e,n]=RL({nodeId:o,dragItems:u.current,nodeInternals:r});p(t.sourceEvent,e,n)}};if(!t){const t=function(){var e,t,n,r,o=PO,s=LO,i=FO,a=zO,l={},c=fd("start","drag","end"),d=0,u=0;function h(e){e.on("mousedown.drag",f).filter(a).on("touchstart.drag",g).on("touchmove.drag",y,_O).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function f(i,a){if(!r&&o.call(this,i,a)){var l=x(this,s.call(this,i,a),i,a,"mouse");l&&(cd(i.view).on("mousemove.drag",m,IO).on("mouseup.drag",p,IO),MO(i.view),AO(i),n=!1,e=i.clientX,t=i.clientY,l("start",i))}}function m(r){if(TO(r),!n){var o=r.clientX-e,s=r.clientY-t;n=o*o+s*s>u}l.mouse("drag",r)}function p(e){cd(e.view).on("mousemove.drag mouseup.drag",null),DO(e.view,n),TO(e),l.mouse("end",e)}function g(e,t){if(o.call(this,e,t)){var n,r,i=e.changedTouches,a=s.call(this,e,t),l=i.length;for(n=0;n<l;++n)(r=x(this,a,e,t,i[n].identifier,i[n]))&&(AO(e),r("start",e,i[n]))}}function y(e){var t,n,r=e.changedTouches,o=r.length;for(t=0;t<o;++t)(n=l[r[t].identifier])&&(TO(e),n("drag",e,r[t]))}function b(e){var t,n,o=e.changedTouches,s=o.length;for(r&&clearTimeout(r),r=setTimeout((function(){r=null}),500),t=0;t<s;++t)(n=l[o[t].identifier])&&(AO(e),n("end",e,o[t]))}function x(e,t,n,r,o,s){var a,u,f,m=c.copy(),p=jO(s||n,t);if(null!=(f=i.call(e,new RO("beforestart",{sourceEvent:n,target:h,identifier:o,active:d,x:p[0],y:p[1],dx:0,dy:0,dispatch:m}),r)))return a=f.x-p[0]||0,u=f.y-p[1]||0,function n(s,i,c){var g,y=p;switch(s){case"start":l[o]=n,g=d++;break;case"end":delete l[o],--d;case"drag":p=jO(c||i,t),g=d}m.call(s,e,new RO(s,{sourceEvent:i,subject:f,target:h,identifier:o,active:g,x:p[0]+a,y:p[1]+u,dx:p[0]-y[0],dy:p[1]-y[1],dispatch:m}),r)}}return h.filter=function(e){return arguments.length?(o="function"==typeof e?e:OO(!!e),h):o},h.container=function(e){return arguments.length?(s="function"==typeof e?e:OO(e),h):s},h.subject=function(e){return arguments.length?(i="function"==typeof e?e:OO(e),h):i},h.touchable=function(e){return arguments.length?(a="function"==typeof e?e:OO(!!e),h):a},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}=a.getState();0===n&&k(e),x.current=!1;const r=v(e);h.current=r,m.current=(null==t?void 0:t.getBoundingClientRect())||null,p.current=jR(e.sourceEvent,m.current)})).on("drag",(e=>{var t,n;const r=v(e),{autoPanOnNodeDrag:o,nodeDragThreshold:s}=a.getState();if("touchmove"===e.sourceEvent.type&&e.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!y.current&&b.current&&o&&(y.current=!0,w()),!b.current){const o=r.xSnapped-((null==(t=null==h?void 0:h.current)?void 0:t.x)??0),i=r.ySnapped-((null==(n=null==h?void 0:h.current)?void 0:n.y)??0);Math.sqrt(o*o+i*i)>s&&k(e)}(h.current.x!==r.xSnapped||h.current.y!==r.ySnapped)&&u.current&&b.current&&(g.current=e.sourceEvent,p.current=jR(e.sourceEvent,m.current),c(r))}})).on("end",(e=>{if(b.current&&!x.current&&(d(!1),y.current=!1,b.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:t,nodeInternals:n,onNodeDragStop:r,onSelectionDragStop:s}=a.getState(),i=o?r:zL(s);if(t(u.current,!1,!1),i){const[t,r]=RL({nodeId:o,dragItems:u.current,nodeInternals:n});i(e.sourceEvent,t,r)}}})).filter((t=>{const o=t.target;return!t.button&&(!n||!ML(o,`.${n}`,e))&&(!r||ML(o,r,e))}));return l.call(t),()=>{l.on(".drag",null)}}l.on(".drag",null)}}),[e,t,n,r,s,a,o,i,v]),c}function UL(){const e=lR();return l.useCallback((t=>{const{nodeInternals:n,nodeExtent:r,updateNodePositions:o,getNodes:s,snapToGrid:i,snapGrid:a,onError:l,nodesDraggable:c}=e.getState(),d=s().filter((e=>e.selected&&(e.draggable||c&&void 0===e.draggable))),u=i?a[0]:5,h=i?a[1]:5,f=t.isShiftPressed?4:1,m=t.x*u*f,p=t.y*h*f;o(d.map((e=>{if(e.positionAbsolute){const t={x:e.positionAbsolute.x+m,y:e.positionAbsolute.y+p};i&&(t.x=a[0]*Math.round(t.x/a[0]),t.y=a[1]*Math.round(t.y/a[1]));const{positionAbsolute:o,position:s}=OL(e,t,n,r,void 0,l);e.position=s,e.positionAbsolute=o}return e})),!0,!1)}),[])}const $L={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var VL=e=>{const t=({id:t,type:n,data:r,xPos:o,yPos:s,xPosOrigin:i,yPosOrigin:a,selected:c,onClick:d,onMouseEnter:u,onMouseMove:h,onMouseLeave:f,onContextMenu:m,onDoubleClick:g,style:y,className:b,isDraggable:x,isSelectable:v,isConnectable:w,isFocusable:k,selectNodesOnDrag:S,sourcePosition:C,targetPosition:N,hidden:E,resizeObserver:j,dragHandle:_,zIndex:I,isParent:A,noDragClassName:T,noPanClassName:M,initialized:D,disableKeyboardA11y:O,ariaLabel:R,rfId:P,hasHandleBounds:L})=>{const F=lR(),z=l.useRef(null),B=l.useRef(null),U=l.useRef(C),$=l.useRef(N),V=l.useRef(n),H=v||x||d||u||h||f,W=UL(),G=LL(t,F.getState,u),q=LL(t,F.getState,h),Y=LL(t,F.getState,f),K=LL(t,F.getState,m),J=LL(t,F.getState,g);l.useEffect((()=>()=>{B.current&&(null==j||j.unobserve(B.current),B.current=null)}),[]),l.useEffect((()=>{if(z.current&&!E){const e=z.current;D&&L&&B.current===e||(B.current&&(null==j||j.unobserve(B.current)),null==j||j.observe(e),B.current=e)}}),[E,D,L]),l.useEffect((()=>{const e=V.current!==n,r=U.current!==C,o=$.current!==N;z.current&&(e||r||o)&&(e&&(V.current=n),r&&(U.current=C),o&&($.current=N),F.getState().updateNodeDimensions([{id:t,nodeElement:z.current,forceUpdate:!0}]))}),[t,n,C,N]);const X=BL({nodeRef:z,disabled:E||!x,noDragClassName:T,handleSelector:_,nodeId:t,isSelectable:v,selectNodesOnDrag:S});return E?null:p.createElement("div",{className:vO(["react-flow__node",`react-flow__node-${n}`,{[M]:x},b,{selected:c,selectable:v,parent:A,dragging:X}]),ref:z,style:{zIndex:I,transform:`translate(${i}px,${a}px)`,pointerEvents:H?"all":"none",visibility:D?"visible":"hidden",...y},"data-id":t,"data-testid":`rf__node-${t}`,onMouseEnter:G,onMouseMove:q,onMouseLeave:Y,onContextMenu:K,onClick:e=>{const{nodeDragThreshold:n}=F.getState();if(v&&(!S||!x||n>0)&&FL({id:t,store:F,nodeRef:z}),d){const n=F.getState().nodeInternals.get(t);n&&d(e,{...n})}},onDoubleClick:J,onKeyDown:k?e=>{if(!NR(e)&&!O)if(CR.includes(e.key)&&v){const n="Escape"===e.key;FL({id:t,store:F,unselect:n,nodeRef:z})}else x&&c&&Object.prototype.hasOwnProperty.call($L,e.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${e.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~s}`}),W({x:$L[e.key].x,y:$L[e.key].y,isShiftPressed:e.shiftKey}))}:void 0,tabIndex:k?0:void 0,role:k?"button":void 0,"aria-describedby":O?void 0:`${YP}-${P}`,"aria-label":R},p.createElement(iP,{value:t},p.createElement(e,{id:t,data:r,type:n,xPos:o,yPos:s,selected:c,isConnectable:w,sourcePosition:C,targetPosition:N,dragging:X,dragHandle:_,zIndex:I})))};return t.displayName="NodeWrapper",l.memo(t)};const HL=e=>{const t=e.getNodes().filter((e=>e.selected));return{...hP(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};var WL=l.memo((function({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=lR(),{width:o,height:s,x:i,y:a,transformString:c,userSelectionActive:d}=aR(HL,EO),u=UL(),h=l.useRef(null);if(l.useEffect((()=>{var e;n||null==(e=h.current)||e.focus({preventScroll:!0})}),[n]),BL({nodeRef:h}),d||!o||!s)return null;const f=e?t=>{const n=r.getState().getNodes().filter((e=>e.selected));e(t,n)}:void 0;return p.createElement("div",{className:vO(["react-flow__nodesselection","react-flow__container",t]),style:{transform:c}},p.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call($L,e.key)&&u({x:$L[e.key].x,y:$L[e.key].y,isShiftPressed:e.shiftKey})},style:{width:o,height:s,top:a,left:i}}))}));const GL=e=>e.nodesSelectionActive,qL=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,deleteKeyCode:a,onMove:c,onMoveStart:d,onMoveEnd:u,selectionKeyCode:h,selectionOnDrag:f,selectionMode:m,onSelectionStart:g,onSelectionEnd:y,multiSelectionKeyCode:b,panActivationKeyCode:x,zoomActivationKeyCode:v,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:C,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:_,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,preventScrolling:D,onSelectionContextMenu:O,noWheelClassName:R,noPanClassName:P,disableKeyboardA11y:L})=>{const F=aR(GL),z=QP(h),B=QP(x),U=B||_,$=B||C,V=z||f&&!0!==U;return(({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=lR(),{deleteElements:r}=hL(),o=QP(e,fL),s=QP(t);l.useEffect((()=>{if(o){const{edges:e,getNodes:t}=n.getState(),o=t().filter((e=>e.selected)),s=e.filter((e=>e.selected));r({nodes:o,edges:s}),n.setState({nodesSelectionActive:!1})}}),[o]),l.useEffect((()=>{n.setState({multiSelectionActive:s})}),[s])})({deleteKeyCode:a,multiSelectionKeyCode:b}),p.createElement(vL,{onMove:c,onMoveStart:d,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:w,zoomOnScroll:k,zoomOnPinch:S,panOnScroll:$,panOnScrollSpeed:N,panOnScrollMode:E,zoomOnDoubleClick:j,panOnDrag:!z&&U,defaultViewport:I,translateExtent:A,minZoom:T,maxZoom:M,zoomActivationKeyCode:v,preventScrolling:D,noWheelClassName:R,noPanClassName:P},p.createElement(AL,{onSelectionStart:g,onSelectionEnd:y,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:U,isSelecting:!!V,selectionMode:m},e,F&&p.createElement(WL,{onSelectionContextMenu:O,noPanClassName:P,disableKeyboardA11y:L})))};qL.displayName="FlowRenderer";var YL=l.memo(qL);function KL(e){return{...{input:VL(e.input||MP),default:VL(e.default||AP),output:VL(e.output||OP),group:VL(e.group||RP)},...Object.keys(e).filter((e=>!["input","default","output","group"].includes(e))).reduce(((t,n)=>(t[n]=VL(e[n]||AP),t)),{})}}const JL=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),XL=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:o,updateNodeDimensions:s,onError:i}=aR(JL,EO),a=(c=e.onlyRenderVisibleElements,aR(l.useCallback((e=>c?fP(e.nodeInternals,{x:0,y:0,width:e.width,height:e.height},e.transform,!0):e.getNodes()),[c])));var c;const d=l.useRef(),u=l.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})));s(t)}));return d.current=e,e}),[]);return l.useEffect((()=>()=>{var e;null==(e=null==d?void 0:d.current)||e.disconnect()}),[]),p.createElement("div",{className:"react-flow__nodes",style:mL},a.map((s=>{var a,l,c;let d=s.type||"default";e.nodeTypes[d]||(null==i||i("003",ZO(d)),d="default");const h=e.nodeTypes[d]||e.nodeTypes.default,f=!!(s.draggable||t&&void 0===s.draggable),m=!!(s.selectable||o&&void 0===s.selectable),g=!!(s.connectable||n&&void 0===s.connectable),y=!!(s.focusable||r&&void 0===s.focusable),b=e.nodeExtent?pR(s.positionAbsolute,e.nodeExtent):s.positionAbsolute,x=(null==b?void 0:b.x)??0,v=(null==b?void 0:b.y)??0,w=(({x:e,y:t,width:n,height:r,origin:o})=>n&&r?o[0]<0||o[1]<0||o[0]>1||o[1]>1?{x:e,y:t}:{x:e-n*o[0],y:t-r*o[1]}:{x:e,y:t})({x:x,y:v,width:s.width??0,height:s.height??0,origin:e.nodeOrigin});return p.createElement(h,{key:s.id,id:s.id,className:s.className,style:s.style,type:d,data:s.data,sourcePosition:s.sourcePosition||VR.Bottom,targetPosition:s.targetPosition||VR.Top,hidden:s.hidden,xPos:x,yPos:v,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:!!s.selected,isDraggable:f,isSelectable:m,isConnectable:g,isFocusable:y,resizeObserver:u,dragHandle:s.dragHandle,zIndex:(null==(a=s[SR])?void 0:a.z)??0,isParent:!!(null==(l=s[SR])?void 0:l.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!s.width&&!!s.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:s.ariaLabel,hasHandleBounds:!!(null==(c=s[SR])?void 0:c.handleBounds)})})))};XL.displayName="NodeRenderer";var ZL=l.memo(XL);const QL=(e,t,n)=>n===VR.Left?e-t:n===VR.Right?e+t:e,eF=(e,t,n)=>n===VR.Top?e-t:n===VR.Bottom?e+t:e,tF="react-flow__edgeupdater",nF=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a})=>p.createElement("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:vO([tF,`${tF}-${a}`]),cx:QL(t,r,e),cy:eF(n,r,e),r:r,stroke:"transparent",fill:"transparent"}),rF=()=>!0;var oF=e=>{const t=({id:t,className:n,type:r,data:o,onClick:s,onEdgeDoubleClick:i,selected:a,animated:c,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,style:y,source:b,target:x,sourceX:v,sourceY:w,targetX:k,targetY:S,sourcePosition:C,targetPosition:N,elementsSelectable:E,hidden:j,sourceHandleId:_,targetHandleId:I,onContextMenu:A,onMouseEnter:T,onMouseMove:M,onMouseLeave:D,reconnectRadius:O,onReconnect:R,onReconnectStart:P,onReconnectEnd:L,markerEnd:F,markerStart:z,rfId:B,ariaLabel:U,isFocusable:$,isReconnectable:V,pathOptions:H,interactionWidth:W,disableKeyboardA11y:G})=>{const q=l.useRef(null),[Y,K]=l.useState(!1),[J,X]=l.useState(!1),Z=lR(),Q=l.useMemo((()=>`url('#${lP(z,B)}')`),[z,B]),ee=l.useMemo((()=>`url('#${lP(F,B)}')`),[F,B]);if(j)return null;const te=AR(t,Z.getState,i),ne=AR(t,Z.getState,A),re=AR(t,Z.getState,T),oe=AR(t,Z.getState,M),se=AR(t,Z.getState,D),ie=(e,n)=>{if(0!==e.button)return;const{edges:r,isValidConnection:o}=Z.getState(),s=n?x:b,i=(n?I:_)||null,a=n?"target":"source",l=o||rF,c=n,d=r.find((e=>e.id===t));X(!0),null==P||P(e,d,a);CP({event:e,handleId:i,nodeId:s,onConnect:e=>null==R?void 0:R(d,e),isTarget:c,getState:Z.getState,setState:Z.setState,isValidConnection:l,edgeUpdaterType:a,onReconnectEnd:e=>{X(!1),null==L||L(e,d,a)}})},ae=()=>K(!0),le=()=>K(!1),ce=!E&&!s;return p.createElement("g",{className:vO(["react-flow__edge",`react-flow__edge-${r}`,n,{selected:a,animated:c,inactive:ce,updating:Y}]),onClick:e=>{var n;const{edges:r,addSelectedEdges:o,unselectNodesAndEdges:i,multiSelectionActive:a}=Z.getState(),l=r.find((e=>e.id===t));l&&(E&&(Z.setState({nodesSelectionActive:!1}),l.selected&&a?(i({nodes:[],edges:[l]}),null==(n=q.current)||n.blur()):o([t])),s&&s(e,l))},onDoubleClick:te,onContextMenu:ne,onMouseEnter:re,onMouseMove:oe,onMouseLeave:se,onKeyDown:$?e=>{var n;if(!G&&CR.includes(e.key)&&E){const{unselectNodesAndEdges:r,addSelectedEdges:o,edges:s}=Z.getState();"Escape"===e.key?(null==(n=q.current)||n.blur(),r({edges:[s.find((e=>e.id===t))]})):o([t])}}:void 0,tabIndex:$?0:void 0,role:$?"button":"img","data-testid":`rf__edge-${t}`,"aria-label":null===U?void 0:U||`Edge from ${b} to ${x}`,"aria-describedby":$?`${KP}-${B}`:void 0,ref:q},!J&&p.createElement(e,{id:t,source:b,target:x,selected:a,animated:c,label:d,labelStyle:u,labelShowBg:h,labelBgStyle:f,labelBgPadding:m,labelBgBorderRadius:g,data:o,style:y,sourceX:v,sourceY:w,targetX:k,targetY:S,sourcePosition:C,targetPosition:N,sourceHandleId:_,targetHandleId:I,markerStart:Q,markerEnd:ee,pathOptions:H,interactionWidth:W}),V&&p.createElement(p.Fragment,null,("source"===V||!0===V)&&p.createElement(nF,{position:C,centerX:v,centerY:w,radius:O,onMouseDown:e=>ie(e,!0),onMouseEnter:ae,onMouseOut:le,type:"source"}),("target"===V||!0===V)&&p.createElement(nF,{position:N,centerX:k,centerY:S,radius:O,onMouseDown:e=>ie(e,!1),onMouseEnter:ae,onMouseOut:le,type:"target"})))};return t.displayName="EdgeWrapper",l.memo(t)};function sF(e){return{...{default:oF(e.default||oP),straight:oF(e.bezier||eP),step:oF(e.step||QR),smoothstep:oF(e.step||ZR),simplebezier:oF(e.simplebezier||qR)},...Object.keys(e).filter((e=>!["default","bezier"].includes(e))).reduce(((t,n)=>(t[n]=oF(e[n]||oP),t)),{})}}function iF(e,t,n=null){const r=((null==n?void 0:n.x)||0)+t.x,o=((null==n?void 0:n.y)||0)+t.y,s=(null==n?void 0:n.width)||t.width,i=(null==n?void 0:n.height)||t.height;switch(e){case VR.Top:return{x:r+s/2,y:o};case VR.Right:return{x:r+s,y:o+i/2};case VR.Bottom:return{x:r+s/2,y:o+i};case VR.Left:return{x:r,y:o+i/2}}}function aF(e,t){return e?1!==e.length&&t?t&&e.find((e=>e.id===t))||null:e[0]:null}function lF(e){var t,n,r,o,s;const i=(null==(t=null==e?void 0:e[SR])?void 0:t.handleBounds)||null,a=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==(r=null==e?void 0:e.positionAbsolute)?void 0:r.y);return[{x:(null==(o=null==e?void 0:e.positionAbsolute)?void 0:o.x)||0,y:(null==(s=null==e?void 0:e.positionAbsolute)?void 0:s.y)||0,width:(null==e?void 0:e.width)||0,height:(null==e?void 0:e.height)||0},i,!!a]}const cF=[{level:0,isMaxLevel:!0,edges:[]}];function dF(e,t,n){return function(e,t,n=!1){let r=-1;const o=e.reduce(((e,o)=>{var s,i;const a=kR(o.zIndex);let l=a?o.zIndex:0;if(n){const e=t.get(o.target),n=t.get(o.source),r=o.selected||(null==e?void 0:e.selected)||(null==n?void 0:n.selected),c=Math.max((null==(s=null==n?void 0:n[SR])?void 0:s.z)||0,(null==(i=null==e?void 0:e[SR])?void 0:i.z)||0,1e3);l=(a?o.zIndex:0)+(r?c:0)}return e[l]?e[l].push(o):e[l]=[o],r=l>r?l:r,e}),{}),s=Object.entries(o).map((([e,t])=>{const n=+e;return{edges:t,level:n,isMaxLevel:n===r}}));return 0===s.length?cF:s}(aR(l.useCallback((n=>e?n.edges.filter((e=>{const r=t.get(e.source),o=t.get(e.target);return(null==r?void 0:r.width)&&(null==r?void 0:r.height)&&(null==o?void 0:o.width)&&(null==o?void 0:o.height)&&function({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:o,targetHeight:s,width:i,height:a,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+o),y2:Math.max(e.y+r,t.y+s)};c.x===c.x2&&(c.x2+=1),c.y===c.y2&&(c.y2+=1);const d=xR({x:(0-l[0])/l[2],y:(0-l[1])/l[2],width:i/l[2],height:a/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:r.positionAbsolute||{x:0,y:0},targetPos:o.positionAbsolute||{x:0,y:0},sourceWidth:r.width,sourceHeight:r.height,targetWidth:o.width,targetHeight:o.height,width:n.width,height:n.height,transform:n.transform})})):n.edges),[e,t])),t,n)}const uF={[UR.Arrow]:({color:e="none",strokeWidth:t=1})=>p.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[UR.ArrowClosed]:({color:e="none",strokeWidth:t=1})=>p.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})};const hF=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const c=function(e){const t=lR();return l.useMemo((()=>{var n,r;return Object.prototype.hasOwnProperty.call(uF,e)?uF[e]:(null==(r=(n=t.getState()).onError)||r.call(n,"009",tR(e)),null)}),[e])}(t);return c?p.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0"},p.createElement(c,{color:n,strokeWidth:i})):null},fF=({defaultColor:e,rfId:t})=>{const n=aR(l.useCallback((({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce(((n,o)=>([o.markerStart,o.markerEnd].forEach((o=>{if(o&&"object"==typeof o){const s=lP(o,t);r.includes(s)||(n.push({id:s,color:o.color||e,...o}),r.push(s))}})),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 p.createElement("defs",null,n.map((e=>p.createElement(hF,{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}))))};fF.displayName="MarkerDefinitions";var mF=l.memo(fF);const pF=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}),gF=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:o,noPanClassName:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:d,onEdgeDoubleClick:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:m,reconnectRadius:g,children:y,disableKeyboardA11y:b})=>{const{edgesFocusable:x,edgesUpdatable:v,elementsSelectable:w,width:k,height:S,connectionMode:C,nodeInternals:N,onError:E}=aR(pF,EO),j=dF(t,N,n);return k?p.createElement(p.Fragment,null,j.map((({level:t,edges:n,isMaxLevel:y})=>p.createElement("svg",{key:t,style:{zIndex:t},width:k,height:S,className:"react-flow__edges react-flow__container"},y&&p.createElement(mF,{defaultColor:e,rfId:r}),p.createElement("g",null,n.map((e=>{const[t,n,y]=lF(N.get(e.source)),[k,S,j]=lF(N.get(e.target));if(!y||!j)return null;let _=e.type||"default";o[_]||(null==E||E("011",oR(_)),_="default");const I=o[_]||o.default,A=C===DR.Strict?S.target:(S.target??[]).concat(S.source??[]),T=aF(n.source,e.sourceHandle),M=aF(A,e.targetHandle),D=(null==T?void 0:T.position)||VR.Bottom,O=(null==M?void 0:M.position)||VR.Top,R=!!(e.focusable||x&&void 0===e.focusable),P=e.reconnectable||e.updatable,L=void 0!==h&&(P||v&&void 0===P);if(!T||!M)return null==E||E("008",nR(T,e)),null;const{sourceX:F,sourceY:z,targetX:B,targetY:U}=((e,t,n,r,o,s)=>{const i=iF(n,e,t),a=iF(s,r,o);return{sourceX:i.x,sourceY:i.y,targetX:a.x,targetY:a.y}})(t,T,D,k,M,O);return p.createElement(I,{key:e.id,id:e.id,className:vO([e.className,s]),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:F,sourceY:z,targetX:B,targetY:U,sourcePosition:D,targetPosition:O,elementsSelectable:w,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:c,onClick:d,onEdgeDoubleClick:u,onReconnect:h,onReconnectStart:f,onReconnectEnd:m,reconnectRadius:g,rfId:r,ariaLabel:e.ariaLabel,isFocusable:R,isReconnectable:L,pathOptions:"pathOptions"in e?e.pathOptions:void 0,interactionWidth:e.interactionWidth,disableKeyboardA11y:b})})))))),y):null};gF.displayName="EdgeRenderer";var yF=l.memo(gF);const bF=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function xF({children:e}){const t=aR(bF);return p.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}const vF={[VR.Left]:VR.Right,[VR.Right]:VR.Left,[VR.Top]:VR.Bottom,[VR.Bottom]:VR.Top},wF=({nodeId:e,handleType:t,style:n,type:r=zR.Bezier,CustomComponent:o,connectionStatus:s})=>{var i,a,c;const{fromNode:d,handleId:u,toX:h,toY:f,connectionMode:m}=aR(l.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]),EO),g=null==(i=null==d?void 0:d[SR])?void 0:i.handleBounds;let y=null==g?void 0:g[t];if(m===DR.Loose&&(y=y||(null==g?void 0:g["source"===t?"target":"source"])),!d||!y)return null;const b=u?y.find((e=>e.id===u)):y[0],x=b?b.x+b.width/2:(d.width??0)/2,v=b?b.y+b.height/2:d.height??0,w=((null==(a=d.positionAbsolute)?void 0:a.x)??0)+x,k=((null==(c=d.positionAbsolute)?void 0:c.y)??0)+v,S=null==b?void 0:b.position,C=S?vF[S]:null;if(!S||!C)return null;if(o)return p.createElement(o,{connectionLineType:r,connectionLineStyle:n,fromNode:d,fromHandle:b,fromX:w,fromY:k,toX:h,toY:f,fromPosition:S,toPosition:C,connectionStatus:s});let N="";const E={sourceX:w,sourceY:k,sourcePosition:S,targetX:h,targetY:f,targetPosition:C};return r===zR.Bezier?[N]=rP(E):r===zR.Step?[N]=XR({...E,borderRadius:0}):r===zR.SmoothStep?[N]=XR(E):r===zR.SimpleBezier?[N]=GR(E):N=`M${w},${k} ${h},${f}`,p.createElement("path",{d:N,fill:"none",className:"react-flow__connection-path",style:n})};wF.displayName="ConnectionLine";const kF=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function SF({containerStyle:e,style:t,type:n,component:r}){const{nodeId:o,handleType:s,nodesConnectable:i,width:a,height:l,connectionStatus:c}=aR(kF,EO);return!!(o&&s&&a&&i)?p.createElement("svg",{style:e,width:a,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},p.createElement("g",{className:vO(["react-flow__connection",c])},p.createElement(wF,{nodeId:o,handleType:s,style:t,type:n,CustomComponent:r,connectionStatus:c}))):null}function CF(e,t){l.useRef(null),lR();return l.useMemo((()=>t(e)),[e])}const NF=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:o,onInit:s,onNodeClick:i,onEdgeClick:a,onNodeDoubleClick:c,onEdgeDoubleClick:d,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:g,onSelectionStart:y,onSelectionEnd:b,connectionLineType:x,connectionLineStyle:v,connectionLineComponent:w,connectionLineContainerStyle:k,selectionKeyCode:S,selectionOnDrag:C,selectionMode:N,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,deleteKeyCode:I,onlyRenderVisibleElements:A,elementsSelectable:T,selectNodesOnDrag:M,defaultViewport:D,translateExtent:O,minZoom:R,maxZoom:P,preventScrolling:L,defaultMarkerColor:F,zoomOnScroll:z,zoomOnPinch:B,panOnScroll:U,panOnScrollSpeed:$,panOnScrollMode:V,zoomOnDoubleClick:H,panOnDrag:W,onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:K,onPaneScroll:J,onPaneContextMenu:X,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:re,onReconnectEnd:oe,reconnectRadius:se,noDragClassName:ie,noWheelClassName:ae,noPanClassName:le,elevateEdgesOnSelect:ce,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})=>{const me=CF(e,KL),pe=CF(t,sF);return function(e){const t=hL(),n=l.useRef(!1);l.useEffect((()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout((()=>e(t)),1),n.current=!0)}),[e,t.viewportInitialized])}(s),p.createElement(YL,{onPaneClick:G,onPaneMouseEnter:q,onPaneMouseMove:Y,onPaneMouseLeave:K,onPaneContextMenu:X,onPaneScroll:J,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:C,selectionMode:N,onSelectionStart:y,onSelectionEnd:b,multiSelectionKeyCode:E,panActivationKeyCode:j,zoomActivationKeyCode:_,elementsSelectable:T,onMove:n,onMoveStart:r,onMoveEnd:o,zoomOnScroll:z,zoomOnPinch:B,zoomOnDoubleClick:H,panOnScroll:U,panOnScrollSpeed:$,panOnScrollMode:V,panOnDrag:W,defaultViewport:D,translateExtent:O,minZoom:R,maxZoom:P,onSelectionContextMenu:g,preventScrolling:L,noDragClassName:ie,noWheelClassName:ae,noPanClassName:le,disableKeyboardA11y:de},p.createElement(xF,null,p.createElement(yF,{edgeTypes:pe,onEdgeClick:a,onEdgeDoubleClick:d,onlyRenderVisibleElements:A,onEdgeContextMenu:Z,onEdgeMouseEnter:Q,onEdgeMouseMove:ee,onEdgeMouseLeave:te,onReconnect:ne,onReconnectStart:re,onReconnectEnd:oe,reconnectRadius:se,defaultMarkerColor:F,noPanClassName:le,elevateEdgesOnSelect:!!ce,disableKeyboardA11y:de,rfId:fe},p.createElement(SF,{style:v,type:x,component:w,containerStyle:k})),p.createElement("div",{className:"react-flow__edgelabel-renderer"}),p.createElement(ZL,{nodeTypes:me,onNodeClick:i,onNodeDoubleClick:c,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,selectNodesOnDrag:M,onlyRenderVisibleElements:A,noPanClassName:le,noDragClassName:ie,disableKeyboardA11y:de,nodeOrigin:ue,nodeExtent:he,rfId:fe})))};NF.displayName="GraphView";var EF=l.memo(NF);const jF=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],_F={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:jF,nodeExtent:jF,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:DR.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},IF=()=>{return e=(e,t)=>({..._F,setNodes:n=>{const{nodeInternals:r,nodeOrigin:o,elevateNodesOnSelect:s}=t();e({nodeInternals:oL(n,r,o,s)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map((e=>({...r,...e})))})},setDefaultNodesAndEdges:(n,r)=>{const o=void 0!==n,s=void 0!==r,i=o?oL(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:s?r:[],hasDefaultNodes:o,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:o,fitViewOnInit:s,fitViewOnInitDone:i,fitViewOnInitOptions:a,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=o.get(t.id);if(null==n?void 0:n.hidden)o.set(n.id,{...n,[SR]:{...n[SR],handleBounds:void 0}});else if(n){const r=fR(t.nodeElement);r.width&&r.height&&(n.width!==r.width||n.height!==r.height||t.forceUpdate)&&(o.set(n.id,{...n,[SR]:{...n[SR],handleBounds:{source:PL(".source",t.nodeElement,h,c),target:PL(".target",t.nodeElement,h,c)}},...r}),e.push({id:n.id,type:"dimensions",dimensions:r}))}return e}),[]);rL(o,c);const m=i||s&&!i&&sL(t,{initial:!0,...a});e({nodeInternals:new Map(o),fitViewOnInitDone:m}),(null==f?void 0:f.length)>0&&(null==r||r(f))},updateNodePositions:(e,n=!0,r=!1)=>{const{triggerNodeChanges:o}=t();o(e.map((e=>{const t={id:e.id,type:"position",dragging:r};return n&&(t.positionAbsolute=e.positionAbsolute,t.position=e.position),t})))},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:o,hasDefaultNodes:s,nodeOrigin:i,getNodes:a,elevateNodesOnSelect:l}=t();if(null==n?void 0:n.length){if(s){const t=oL(NL(n,a()),o,i,l);e({nodeInternals:t})}null==r||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,a=null;r?i=n.map((e=>EL(e,!0))):(i=jL(s(),n),a=jL(o,[])),lL({changedNodes:i,changedEdges:a,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:o,getNodes:s}=t();let i,a=null;r?i=n.map((e=>EL(e,!0))):(i=jL(o,n),a=jL(s(),[])),lL({changedNodes:a,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:o,getNodes:s}=t(),i=r||o;lL({changedNodes:(n||s()).map((e=>(e.selected=!1,EL(e.id,!1)))),changedEdges:i.map((e=>EL(e.id,!1))),get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:o}=t();null==r||r.scaleExtent([n,o]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:o}=t();null==r||r.scaleExtent([o,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;null==(r=t().d3Zoom)||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t();lL({changedNodes:r().filter((e=>e.selected)).map((e=>EL(e.id,!1))),changedEdges:n.filter((e=>e.selected)).map((e=>EL(e.id,!1))),get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach((e=>{e.positionAbsolute=pR(e.position,n)})),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:e=>{const{transform:n,width:r,height:o,d3Zoom:s,d3Selection:i,translateExtent:a}=t();if(!s||!i||!e.x&&!e.y)return!1;const l=dd.translate(n[0]+e.x,n[1]+e.y).scale(n[2]),c=[[0,0],[r,o]],d=null==s?void 0:s.constrain()(l,c,a);return s.transform(i,d),n[0]!==d.x||n[1]!==d.y||n[2]!==d.k},cancelConnection:()=>e({connectionNodeId:_F.connectionNodeId,connectionHandleId:_F.connectionHandleId,connectionHandleType:_F.connectionHandleType,connectionStatus:_F.connectionStatus,connectionStartHandle:_F.connectionStartHandle,connectionEndHandle:_F.connectionEndHandle}),reset:()=>e({..._F})}),t=Object.is,e?NO(e,t):NO;var e,t},AF=({children:e})=>{const t=l.useRef(null);return t.current||(t.current=IF()),p.createElement(XO,{value:t.current},e)};AF.displayName="ReactFlowProvider";const TF=({children:e})=>l.useContext(JO)?p.createElement(p.Fragment,null,e):p.createElement(AF,null,e);TF.displayName="ReactFlowWrapper";const MF={input:MP,default:AP,output:OP,group:RP},DF={default:oP,straight:eP,step:QR,smoothstep:ZR,simplebezier:qR},OF=[0,0],RF=[15,15],PF={x:0,y:0,zoom:1},LF={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},FF=l.forwardRef((({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s=MF,edgeTypes:i=DF,onNodeClick:a,onEdgeClick:l,onInit:c,onMove:d,onMoveStart:u,onMoveEnd:h,onConnect:f,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,onNodeMouseEnter:x,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:N,onNodeDragStop:E,onNodesDelete:j,onEdgesDelete:_,onSelectionChange:I,onSelectionDragStart:A,onSelectionDrag:T,onSelectionDragStop:M,onSelectionContextMenu:D,onSelectionStart:O,onSelectionEnd:R,connectionMode:P=DR.Strict,connectionLineType:L=zR.Bezier,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:B,deleteKeyCode:U="Backspace",selectionKeyCode:$="Shift",selectionOnDrag:V=!1,selectionMode:H=LR.Full,panActivationKeyCode:W="Space",multiSelectionKeyCode:G=(_R()?"Meta":"Control"),zoomActivationKeyCode:q=(_R()?"Meta":"Control"),snapToGrid:Y=!1,snapGrid:K=RF,onlyRenderVisibleElements:J=!1,selectNodesOnDrag:X=!0,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,nodeOrigin:te=OF,edgesFocusable:ne,edgesUpdatable:re,elementsSelectable:oe,defaultViewport:se=PF,minZoom:ie=.5,maxZoom:ae=2,translateExtent:le=jF,preventScrolling:ce=!0,nodeExtent:de,defaultMarkerColor:ue="#b1b1b7",zoomOnScroll:he=!0,zoomOnPinch:fe=!0,panOnScroll:me=!1,panOnScrollSpeed:pe=.5,panOnScrollMode:ge=RR.Free,zoomOnDoubleClick:ye=!0,panOnDrag:be=!0,onPaneClick:xe,onPaneMouseEnter:ve,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ce,children:Ne,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onEdgeUpdate:Te,onEdgeUpdateStart:Me,onEdgeUpdateEnd:De,onReconnect:Oe,onReconnectStart:Re,onReconnectEnd:Pe,reconnectRadius:Le=10,edgeUpdaterRadius:Fe=10,onNodesChange:ze,onEdgesChange:Be,noDragClassName:Ue="nodrag",noWheelClassName:$e="nowheel",noPanClassName:Ve="nopan",fitView:He=!1,fitViewOptions:We,connectOnClick:Ge=!0,attributionPosition:qe,proOptions:Ye,defaultEdgeOptions:Ke,elevateNodesOnSelect:Je=!0,elevateEdgesOnSelect:Xe=!1,disableKeyboardA11y:Ze=!1,autoPanOnConnect:Qe=!0,autoPanOnNodeDrag:et=!0,connectionRadius:tt=20,isValidConnection:nt,onError:rt,style:ot,id:st,nodeDragThreshold:it,...at},lt)=>{const ct=st||"1";return p.createElement("div",{...at,style:{...ot,...LF},ref:lt,className:vO(["react-flow",o]),"data-testid":"rf__wrapper",id:st},p.createElement(TF,null,p.createElement(EF,{onInit:c,onMove:d,onMoveStart:u,onMoveEnd:h,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:x,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:k,onNodeDoubleClick:S,nodeTypes:s,edgeTypes:i,connectionLineType:L,connectionLineStyle:F,connectionLineComponent:z,connectionLineContainerStyle:B,selectionKeyCode:$,selectionOnDrag:V,selectionMode:H,deleteKeyCode:U,multiSelectionKeyCode:G,panActivationKeyCode:W,zoomActivationKeyCode:q,onlyRenderVisibleElements:J,selectNodesOnDrag:X,defaultViewport:se,translateExtent:le,minZoom:ie,maxZoom:ae,preventScrolling:ce,zoomOnScroll:he,zoomOnPinch:fe,zoomOnDoubleClick:ye,panOnScroll:me,panOnScrollSpeed:pe,panOnScrollMode:ge,panOnDrag:be,onPaneClick:xe,onPaneMouseEnter:ve,onPaneMouseMove:we,onPaneMouseLeave:ke,onPaneScroll:Se,onPaneContextMenu:Ce,onSelectionContextMenu:D,onSelectionStart:O,onSelectionEnd:R,onEdgeContextMenu:Ee,onEdgeDoubleClick:je,onEdgeMouseEnter:_e,onEdgeMouseMove:Ie,onEdgeMouseLeave:Ae,onReconnect:Oe??Te,onReconnectStart:Re??Me,onReconnectEnd:Pe??De,reconnectRadius:Le??Fe,defaultMarkerColor:ue,noDragClassName:Ue,noWheelClassName:$e,noPanClassName:Ve,elevateEdgesOnSelect:Xe,rfId:ct,disableKeyboardA11y:Ze,nodeOrigin:te,nodeExtent:de}),p.createElement(WP,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:m,onConnectEnd:g,onClickConnectStart:y,onClickConnectEnd:b,nodesDraggable:Z,nodesConnectable:Q,nodesFocusable:ee,edgesFocusable:ne,edgesUpdatable:re,elementsSelectable:oe,elevateNodesOnSelect:Je,minZoom:ie,maxZoom:ae,nodeExtent:de,onNodesChange:ze,onEdgesChange:Be,snapToGrid:Y,snapGrid:K,connectionMode:P,translateExtent:le,connectOnClick:Ge,defaultEdgeOptions:Ke,fitView:He,fitViewOptions:We,onNodesDelete:j,onEdgesDelete:_,onNodeDragStart:C,onNodeDrag:N,onNodeDragStop:E,onSelectionDrag:T,onSelectionDragStart:A,onSelectionDragStop:M,noPanClassName:Ve,nodeOrigin:te,rfId:ct,autoPanOnConnect:Qe,autoPanOnNodeDrag:et,onError:rt,connectionRadius:tt,isValidConnection:nt,nodeDragThreshold:it}),p.createElement(UP,{onSelectionChange:I}),Ne,p.createElement(uR,{proOptions:Ye,position:qe}),p.createElement(ZP,{rfId:ct,disableKeyboardA11y:Ze})))}));function zF(e){return t=>{const[n,r]=l.useState(t),o=l.useCallback((t=>r((n=>e(t,n)))),[]);return[n,r,o]}}FF.displayName="ReactFlow";const BF=zF(NL),UF=zF((function(e,t){return CL(e,t)}));function $F(){return p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},p.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function VF(){return p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},p.createElement("path",{d:"M0 0h32v4.2H0z"}))}function HF(){return p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},p.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 WF(){return p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},p.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 GF(){return p.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},p.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 qF=({children:e,className:t,...n})=>p.createElement("button",{type:"button",className:vO(["react-flow__controls-button",t]),...n},e);qF.displayName="ControlButton";const YF=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),KF=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:c,className:d,children:u,position:h="bottom-left"})=>{const f=lR(),[m,g]=l.useState(!1),{isInteractive:y,minZoomReached:b,maxZoomReached:x}=aR(YF,EO),{zoomIn:v,zoomOut:w,fitView:k}=hL();if(l.useEffect((()=>{g(!0)}),[]),!m)return null;return p.createElement(dR,{className:vO(["react-flow__controls",d]),position:h,style:e,"data-testid":"rf__controls"},t&&p.createElement(p.Fragment,null,p.createElement(qF,{onClick:()=>{v(),null==s||s()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:x},p.createElement($F,null)),p.createElement(qF,{onClick:()=>{w(),null==i||i()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},p.createElement(VF,null))),n&&p.createElement(qF,{className:"react-flow__controls-fitview",onClick:()=>{k(o),null==a||a()},title:"fit view","aria-label":"fit view"},p.createElement(HF,null)),r&&p.createElement(qF,{className:"react-flow__controls-interactive",onClick:()=>{f.setState({nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!y}),null==c||c(!y)},title:"toggle interactivity","aria-label":"toggle interactivity"},y?p.createElement(GF,null):p.createElement(WF,null)),u)};KF.displayName="Controls";var JF,XF,ZF=l.memo(KF);function QF({color:e,dimensions:t,lineWidth:n}){return p.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function ez({color:e,radius:t}){return p.createElement("circle",{cx:t,cy:t,r:t,fill:e})}(XF=JF||(JF={})).Lines="lines",XF.Dots="dots",XF.Cross="cross";const tz={[JF.Dots]:"#91919a",[JF.Lines]:"#eee",[JF.Cross]:"#e2e2e2"},nz={[JF.Dots]:1,[JF.Lines]:1,[JF.Cross]:6},rz=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function oz({id:e,variant:t=JF.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=2,color:i,style:a,className:c}){const d=l.useRef(null),{transform:u,patternId:h}=aR(rz,EO),f=i||tz[t],m=r||nz[t],g=t===JF.Dots,y=t===JF.Cross,b=Array.isArray(n)?n:[n,n],x=[b[0]*u[2]||1,b[1]*u[2]||1],v=m*u[2],w=y?[v,v]:x,k=g?[v/s,v/s]:[w[0]/s,w[1]/s];return p.createElement("svg",{className:vO(["react-flow__background",c]),style:{...a,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},p.createElement("pattern",{id:h+e,x:u[0]%x[0],y:u[1]%x[1],width:x[0],height:x[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`},g?p.createElement(ez,{color:f,radius:v/s}):p.createElement(QF,{dimensions:w,color:f,lineWidth:o})),p.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+e})`}))}oz.displayName="Background";var sz=l.memo(oz);function iz(e){return Math.min(11*e+35,200)}const az=p.createContext("LR"),lz=l.memo((e=>{const t=N.c(51),{data:n,selected:r}=e,o=de(n.atom),s=fa().inOrderIds.indexOf(o.id),i=r?"var(--gray-9)":"var(--gray-3)",a=aR(dz),c=l.useContext(az);let d,u,h,f,m;if(t[0]!==o.code||t[1]!==i||t[2]!==c||t[3]!==r){const e=o.code.split("\n").length,n="LR"===c?VR.Left:VR.Top;let s;t[8]!==i?(s={background:i},t[8]=i,t[9]=s):s=t[9],t[10]!==n||t[11]!==s?(h=_.jsx(_P,{type:"target",id:"inputs",position:n,style:s}),t[10]=n,t[11]=s,t[12]=h):h=t[12];const a="LR"===c?VR.Left:VR.Top;let l;t[13]!==i?(l={background:i},t[13]=i,t[14]=l):l=t[14],t[15]!==a||t[16]!==l?(f=_.jsx(_P,{type:"source",id:"inputs",position:a,style:l}),t[15]=a,t[16]=l,t[17]=f):f=t[17];const m=r&&"border-primary";t[18]!==m?(u=$t("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=iz(e),t[0]=o.code,t[1]=i,t[2]=c,t[3]=r,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]!==a?(m=n.forceWidth||(p=a,Math.min(Math.max(p-100,100),400)),t[20]=n.forceWidth,t[21]=a,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 y=ma(o.name,s);let b,x,v;t[26]!==y?(b=_.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:y}),t[26]=y,t[27]=b):b=t[27],t[28]!==o.code?(x=_.jsx(sd,{code:o.code}),t[28]=o.code,t[29]=x):x=t[29],t[30]!==u||t[31]!==g||t[32]!==b||t[33]!==x?(v=_.jsxs("div",{className:u,style:g,children:[b,x]}),t[30]=u,t[31]=g,t[32]=b,t[33]=x,t[34]=v):v=t[34];const w="LR"===c?VR.Right:VR.Bottom;let k,S;t[35]!==i?(k={background:i},t[35]=i,t[36]=k):k=t[36],t[37]!==w||t[38]!==k?(S=_.jsx(_P,{type:"source",id:"outputs",position:w,style:k}),t[37]=w,t[38]=k,t[39]=S):S=t[39];const C="LR"===c?VR.Right:VR.Bottom;let E,j,I;return t[40]!==i?(E={background:i},t[40]=i,t[41]=E):E=t[41],t[42]!==C||t[43]!==E?(j=_.jsx(_P,{type:"target",id:"outputs",position:C,style:E}),t[42]=C,t[43]=E,t[44]=j):j=t[44],t[45]!==v||t[46]!==S||t[47]!==j||t[48]!==h||t[49]!==f?(I=_.jsxs("div",{children:[h,f,v,S,j]}),t[45]=v,t[46]=S,t[47]=j,t[48]=h,t[49]=f,t[50]=I):I=t[50],I}),((e,t)=>["data","selected","id"].every((n=>e[n]===t[n]))));lz.displayName="CustomNode";const cz={custom:lz};function dz(e){const{width:t}=e;return t}const uz=e=>{const t=N.c(18),{maxCount:n,cellIds:r,onClick:o,skipScroll:s}=e,i=fa();let a,l,c,d;if(t[0]!==r||t[1]!==i||t[2]!==n||t[3]!==o||t[4]!==s){c=Symbol.for("react.early_return_sentinel");e:{let e;t[8]!==i?(e=(e,t)=>i.inOrderIds.indexOf(e)-i.inOrderIds.indexOf(t),t[8]=i,t[9]=e):e=t[9];const d=[...r].sort(e);if(0===r.length){let e;t[10]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("div",{className:"text-muted-foreground",children:"--"}),t[10]=e):e=t[10],c=e;break e}let u;t[11]!==r.length||t[12]!==o||t[13]!==s?(u=(e,t)=>_.jsxs("span",{className:"truncate",children:[_.jsx(pa,{variant:"focus",cellId:e,skipScroll:s,className:"whitespace-nowrap",onClick:o?()=>o(e):void 0},e),t<r.length-1&&", "]},e),t[11]=r.length,t[12]=o,t[13]=s,t[14]=u):u=t[14],a=d.slice(0,n).map(u),l=r.length>n&&_.jsxs(nr,{children:[_.jsx(Ls,{asChild:!0,children:_.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",r.length-n," more"]})}),_.jsx(Qn,{className:"w-auto",children:_.jsx("div",{className:"flex flex-col gap-1 py-1",children:d.slice(n).map((e=>_.jsx(pa,{variant:"focus",cellId:e,className:"whitespace-nowrap",onClick:o?()=>o(e):void 0},e)))})})]})}t[0]=r,t[1]=i,t[2]=n,t[3]=o,t[4]=s,t[5]=a,t[6]=l,t[7]=c}else a=t[5],l=t[6],c=t[7];return c!==Symbol.for("react.early_return_sentinel")?c:(t[15]!==a||t[16]!==l?(d=_.jsxs(_.Fragment,{children:[a,l]}),t[15]=a,t[16]=l,t[17]=d):d=t[17],d)},hz=e=>{const t=N.c(15);let n,r,o,s;t[0]!==e?(({name:r,declaredBy:n,onClick:o,...s}=e),t[0]=e,t[1]=n,t[2]=r,t[3]=o,t[4]=s):(n=t[1],r=t[2],o=t[3],s=t[4]);const i=n.length>1?"destructive":"outline";let a,l,c;return t[5]!==r||t[6]!==o?(a=async e=>{o?o(e):(await Me(r),se({title:"Copied to clipboard"}))},t[5]=r,t[6]=o,t[7]=a):a=t[7],t[8]!==r||t[9]!==i||t[10]!==a?(l=_.jsx(ga,{title:r,variant:i,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:a,children:r}),t[8]=r,t[9]=i,t[10]=a,t[11]=l):l=t[11],t[12]!==s||t[13]!==l?(c=_.jsx("div",{className:"max-w-[130px]",...s,children:l}),t[12]=s,t[13]=l,t[14]=c):c=t[14],c},fz=l.memo((e=>{const t=N.c(38),{onChange:n,view:r,settings:o,onSettingsChange:s}=e;let i;t[0]!==s||t[1]!==o?(i=(e,t)=>{s({...o,[e]:t})},t[0]=s,t[1]=o,t[2]=i):i=t[2];const a=i;let l,c,d,u,h,f;t[3]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(Ls,{asChild:!0,children:_.jsx(ee,{variant:"text",size:"xs",children:_.jsx(wn,{className:"w-4 h-4"})})}),t[3]=l):l=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),t[4]=c):c=t[4],t[5]!==a?(d=e=>a("hidePureMarkdown",Boolean(e)),t[5]=a,t[6]=d):d=t[6],t[7]!==o.hidePureMarkdown||t[8]!==d?(u=_.jsx(oi,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:o.hidePureMarkdown,onCheckedChange:d}),t[7]=o.hidePureMarkdown,t[8]=d,t[9]=u):u=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(h=_.jsx(Fe,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),t[10]=h):h=t[10],t[11]!==u?(f=_.jsxs(nr,{children:[l,_.jsxs(Qn,{className:"w-auto p-2 text-muted-foreground",children:[c,_.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_"===r;let g,y,b;t[13]!==n?(g=()=>n("_minimap_"),t[13]=n,t[14]=g):g=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(y=_.jsx(fu,{className:"w-4 h-4 mr-1"}),t[15]=y):y=t[15],t[16]!==p||t[17]!==g?(b=_.jsxs(ee,{variant:"outline",className:"bg-background","aria-selected":p,size:"xs",onClick:g,children:[y,"Mini Map"]}),t[16]=p,t[17]=g,t[18]=b):b=t[18];const x="TB"===r;let v,w,k;t[19]!==n?(v=()=>n("TB"),t[19]=n,t[20]=v):v=t[20],t[21]===Symbol.for("react.memo_cache_sentinel")?(w=_.jsx(ru,{className:"w-4 h-4 mr-1"}),t[21]=w):w=t[21],t[22]!==x||t[23]!==v?(k=_.jsxs(ee,{variant:"outline",className:"bg-background","aria-selected":x,size:"xs",onClick:v,children:[w,"Vertical Tree"]}),t[22]=x,t[23]=v,t[24]=k):k=t[24];const S="LR"===r;let C,E,j,I;t[25]!==n?(C=()=>n("LR"),t[25]=n,t[26]=C):C=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(E=_.jsx(ru,{className:"w-4 h-4 mr-1 transform -rotate-90"}),t[27]=E):E=t[27],t[28]!==S||t[29]!==C?(j=_.jsxs(ee,{variant:"outline",className:"bg-background","aria-selected":S,size:"xs",onClick:C,children:[E," ","Horizontal Tree"]}),t[28]=S,t[29]=C,t[30]=j):j=t[30],t[31]!==b||t[32]!==k||t[33]!==j?(I=_.jsxs("div",{className:"flex gap-2",children:[b,k,j]}),t[31]=b,t[32]=k,t[33]=j,t[34]=I):I=t[34];const A="_minimap_"!==r&&m;let T;return t[35]!==I||t[36]!==A?(T=_.jsxs(dR,{position:"top-right",className:"flex flex-col items-end gap-2",children:[I,A]}),t[35]=I,t[36]=A,t[37]=T):T=t[37],T}));fz.displayName="GraphToolbar";const mz=l.memo((e=>{const t=N.c(11),{selection:n,variables:r,onClearSelection:o}=e;if(!n)return null;const s=pz;let i;t[0]!==o||t[1]!==n.id||t[2]!==n.source||t[3]!==n.target||t[4]!==n.type||t[5]!==r?(i=()=>{if("node"===n.type){const e=Object.values(r).filter((e=>e.usedBy.includes(n.id))),t=Object.values(r).filter((e=>e.declaredBy.includes(n.id))),i=(e,t)=>_.jsxs(_.Fragment,{children:[0===e.length&&_.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),_.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:e.map((e=>_.jsxs(p.Fragment,{children:[_.jsx(hz,{declaredBy:e.declaredBy,name:e.name}),_.jsxs("div",{className:"truncate col-span-2",title:e.value??"",children:[e.value,_.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",e.dataType,")"]})]}),_.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:_.jsx(uz,{skipScroll:!0,onClick:()=>s("in"===t?e.declaredBy[0]:e.usedBy[0],e.name),maxCount:3,cellIds:e.usedBy})})]},e.name)))})]});return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[_.jsx(bt,{className:"w-5 h-5"}),_.jsx(pa,{cellId:n.id}),_.jsx("div",{className:"flex-1"}),_.jsx(PS,{cellId:n.id,children:_.jsx(ee,{variant:"ghost",size:"icon",children:_.jsx(Pd,{className:"w-4 h-4"})})}),_.jsx(ee,{variant:"text",size:"icon",onClick:()=>{o()},children:_.jsx(Gn,{className:"w-4 h-4"})})]}),_.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[_.jsx(bd,{className:"w-4 h-4"}),"Outputs"]}),i(t,"out")]}),_.jsx("hr",{className:"border-divider my-3"}),_.jsxs("div",{className:"flex flex-col gap-2",children:[_.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[_.jsx(xd,{className:"w-4 h-4"}),"Inputs"]}),i(e,"in")]})]})]})}if("edge"===n.type){const e=Object.values(r).filter((e=>e.declaredBy.includes(n.source)&&e.usedBy.includes(n.target)));return _.jsxs(_.Fragment,{children:[_.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[_.jsx(Tu,{className:"w-4 h-4"}),_.jsx(pa,{cellId:n.source}),_.jsx(vd,{className:"w-4 h-4"}),_.jsx(pa,{cellId:n.target})]}),_.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:e.map((e=>_.jsxs(p.Fragment,{children:[_.jsx(hz,{declaredBy:e.declaredBy,name:e.name,onClick:()=>{s(e.declaredBy[0],e.name)}}),_.jsx("div",{className:"truncate text-foreground/60 font-mono",children:e.dataType}),_.jsx("div",{className:"truncate col-span-2",title:e.value??"",children:e.value})]},e.name)))})]})}},t[0]=o,t[1]=n.id,t[2]=n.source,t[3]=n.target,t[4]=n.type,t[5]=r,t[6]=i):i=t[6];const a=i;let l,c;return t[7]!==a?(l=a(),t[7]=a,t[8]=l):l=t[8],t[9]!==l?(c=_.jsx(dR,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:_.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 pz(e,t){const n=ce(e);n&&ya(n,t)}function gz(){const e=N.c(7),t=hL(),n=aR(bz),r=aR(yz);let o;e[0]!==t?(o=()=>{t.fitView({duration:100})},e[0]=t,e[1]=o):o=e[1];const s=ba(o,100);let i,a;e[2]!==s||e[3]!==r||e[4]!==n?(i=()=>{n&&r&&s()},a=[n,r,s],e[2]=s,e[3]=r,e[4]=n,e[5]=i,e[6]=a):(i=e[5],a=e[6]),l.useEffect(i,a)}function yz(e){const{height:t}=e;return t}function bz(e){const{width:t}=e;return t}mz.displayName="GraphSelectionPanel";const xz=new class{createEdge(e,t,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:UR.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:iz(ne.get(t).code.trim().split("\n").length),position:{x:0,y:n+20}}}createElements(e,t,n,r){let o=0;const s=[],i=[];for(const[l,c]of zi.zip(e,t)){const e=this.createNode(l,c,o);s.push(e),o=e.position.y+(e.height||0)}const a=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}`;a.has(t)||(a.add(t),i.push(this.createEdge(n,e,"inputs"),this.createEdge(n,e,"outputs")))}}return{nodes:s,edges:i}}},vz=e=>{const t=N.c(37),{cellIds:n,variables:r,cellAtoms:o,children:s}=e;let i;t[0]!==o||t[1]!==n||t[2]!==r?(i=xz.createElements(n,o,r,!1),t[0]=o,t[1]=n,t[2]=r,t[3]=i):i=t[3];const{nodes:a,edges:c}=i;let d;t[4]===Symbol.for("react.memo_cache_sentinel")?(d=[],t[4]=d):d=t[4];const[u,h]=UF(d),[f,m]=BF(a),[p,g]=l.useState(),[y,b]=l.useState(),x=l.useRef(!1);gz();const v=aR(wz);let w;t[5]!==h||t[6]!==m?(w=e=>{m(e.nodes),h([])},t[5]=h,t[6]=m,t[7]=w):w=t[7];const k=$(w);let S,C,E,j;t[8]!==o||t[9]!==n||t[10]!==k||t[11]!==r?(S=()=>{x.current?k(xz.createElements(n,o,r,!1)):x.current=!0},C=[n,r,o,k],t[8]=o,t[9]=n,t[10]=k,t[11]=r,t[12]=S,t[13]=C):(S=t[12],C=t[13]),l.useEffect(S,C),t[14]!==c||t[15]!==p||t[16]!==h?(E=()=>{if(p){const e=c.filter((e=>{const{source:t,target:n,data:r}=e;return t===p&&"outputs"===r.direction||n===p&&"inputs"===r.direction}));h(e)}},j=[p,h,c],t[14]=c,t[15]=p,t[16]=h,t[17]=E,t[18]=j):(E=t[17],j=t[18]),l.useEffect(E,j);const I=function(e,t){const n=N.c(17);let r,o;if(n[0]!==t||n[1]!==e){let r;n[3]!==t?(r=(e,n)=>{const{position:r}=n;return Math.min(e,r.y-t/2-10)},n[3]=t,n[4]=r):r=n[4],o=e.reduce(r,Number.POSITIVE_INFINITY),n[0]=t,n[1]=e,n[2]=o}else o=n[2];const s=o;let i;if(n[5]!==t||n[6]!==e){let r;n[8]!==t?(r=(e,n)=>{const{position:r}=n;return Math.max(e,r.y+t/2+10)},n[8]=t,n[9]=r):r=n[9],i=e.reduce(r,Number.NEGATIVE_INFINITY),n[5]=t,n[6]=e,n[7]=i}else i=n[7];const a=i;let l,c,d;n[10]!==s?(l=[Number.NEGATIVE_INFINITY,s],n[10]=s,n[11]=l):l=n[11];n[12]!==a?(c=[Number.POSITIVE_INFINITY,a],n[12]=a,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 r=d,r}(f,v);let A;t[19]===Symbol.for("react.memo_cache_sentinel")?(A=()=>{g(void 0),b(void 0)},t[19]=A):A=t[19];const T=A;let M;t[20]!==u||t[21]!==y||t[22]!==p||t[23]!==r?(M=()=>y?_.jsx(mz,{selection:{type:"edge",source:y.source,target:y.target},onClearSelection:T,variables:r,edges:u}):p?_.jsx(mz,{selection:{type:"node",id:p},variables:r,edges:u,onClearSelection:T}):null,t[20]=u,t[21]=y,t[22]=p,t[23]=r,t[24]=M):M=t[24];const D=M;let O,R,P,L;return t[25]!==h?(O=(e,t)=>{const n=t.id;g(n),b(void 0),h([])},t[25]=h,t[26]=O):O=t[26],t[27]===Symbol.for("react.memo_cache_sentinel")?(R=(e,t)=>{b(t)},t[27]=R):R=t[27],t[28]!==D?(P=D(),t[28]=D,t[29]=P):P=t[29],t[30]!==s||t[31]!==u||t[32]!==f||t[33]!==O||t[34]!==P||t[35]!==I?(L=_.jsxs(FF,{nodes:f,edges:u,nodeTypes:cz,translateExtent:I,onNodeClick:O,onNodeDoubleClick:kz,onEdgeClick:R,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:RR.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:[P,s]}),t[30]=s,t[31]=u,t[32]=f,t[33]=O,t[34]=P,t[35]=I,t[36]=L):L=t[36],L};function wz(e){const{height:t}=e;return t}function kz(e,t){xa(t.id,"focus")}var Sz,Cz,Nz,Ez,jz,_z,Iz,Az,Tz,Mz,Dz,Oz,Rz,Pz,Lz,Fz,zz,Bz,Uz,$z,Vz,Hz,Wz,Gz,qz,Yz,Kz,Jz,Xz,Zz,Qz,eB,tB,nB,rB,oB,sB,iB,aB,lB,cB,dB,uB,hB,fB,mB,pB,gB,yB,bB,xB,vB,wB,kB,SB,CB,NB,EB,jB,_B,IB,AB,TB,MB,DB,OB,RB,PB,LB,FB,zB,BB,UB,$B,VB,HB,WB,GB,qB,YB,KB,JB,XB,ZB,QB,eU,tU,nU,rU,oU,sU,iU,aU,lU;function cU(){if(Cz)return Sz;Cz=1;var e="\0";function t(e,t){e[t]?e[t]++:e[t]=1}function n(e,t){--e[t]||delete e[t]}function r(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}return o+""+s+""+(void 0===r?"\0":r)}function o(e,t){return r(e,t.v,t.w,t.name)}return Sz=class{constructor(t){s(this,"_isDirected",!0),s(this,"_isMultigraph",!1),s(this,"_isCompound",!1),s(this,"_label"),s(this,"_defaultNodeLabelFn",(()=>{})),s(this,"_defaultEdgeLabelFn",(()=>{})),s(this,"_nodes",{}),s(this,"_in",{}),s(this,"_preds",{}),s(this,"_out",{}),s(this,"_sucs",{}),s(this,"_edgeObjs",{}),s(this,"_edgeLabels",{}),s(this,"_nodeCount",0),s(this,"_edgeCount",0),s(this,"_parent"),s(this,"_children"),t&&(this._isDirected=!Object.hasOwn(t,"directed")||t.directed,this._isMultigraph=!!Object.hasOwn(t,"multigraph")&&t.multigraph,this._isCompound=!!Object.hasOwn(t,"compound")&&t.compound),this._isCompound&&(this._parent={},this._children={},this._children[e]={})}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,r=this;return e.forEach((function(e){n.length>1?r.setNode(e,t):r.setNode(e)})),this}setNode(t,n){return Object.hasOwn(this._nodes,t)?(arguments.length>1&&(this._nodes[t]=n),this):(this._nodes[t]=arguments.length>1?n:this._defaultNodeLabelFn(t),this._isCompound&&(this._parent[t]=e,this._children[t]={},this._children[e][t]=!0),this._in[t]={},this._preds[t]={},this._out[t]={},this._sucs[t]={},++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(t,n){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(void 0===n)n=e;else{for(var r=n+="";void 0!==r;r=this.parent(r))if(r===t)throw new Error("Setting "+n+" as parent of "+t+" would create a cycle");this.setNode(n)}return this.setNode(t),this._removeFromParentsChildList(t),this._parent[t]=n,this._children[n][t]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(t){if(this._isCompound){var n=this._parent[t];if(n!==e)return n}}children(t=e){if(this._isCompound){var n=this._children[t];if(n)return Object.keys(n)}else{if(t===e)return this.nodes();if(this.hasNode(t))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 r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.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,r]){e(n)&&t.setNode(n,r)})),Object.values(this._edgeObjs).forEach((function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var r={};function o(e){var s=n.parent(e);return void 0===s||t.hasNode(s)?(r[e]=s,s):s in r?r[s]:o(s)}return this._isCompound&&t.nodes().forEach((e=>t.setParent(e,o(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,r=arguments;return e.reduce((function(e,o){return r.length>1?n.setEdge(e,o,t):n.setEdge(e,o),o})),this}setEdge(){var e,n,o,s,i=!1,a=arguments[0];"object"==typeof a&&null!==a&&"v"in a?(e=a.v,n=a.w,o=a.name,2===arguments.length&&(s=arguments[1],i=!0)):(e=a,n=arguments[1],o=arguments[3],arguments.length>2&&(s=arguments[2],i=!0)),e=""+e,n=""+n,void 0!==o&&(o=""+o);var l=r(this._isDirected,e,n,o);if(Object.hasOwn(this._edgeLabels,l))return i&&(this._edgeLabels[l]=s),this;if(void 0!==o&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(n),this._edgeLabels[l]=i?s:this._defaultEdgeLabelFn(e,n,o);var c=function(e,t,n,r){var o=""+t,s=""+n;if(!e&&o>s){var i=o;o=s,s=i}var a={v:o,w:s};r&&(a.name=r);return a}(this._isDirected,e,n,o);return e=c.v,n=c.w,Object.freeze(c),this._edgeObjs[l]=c,t(this._preds[n],e),t(this._sucs[e],n),this._in[n][l]=c,this._out[e][l]=c,this._edgeCount++,this}edge(e,t,n){var s=1===arguments.length?o(this._isDirected,arguments[0]):r(this._isDirected,e,t,n);return this._edgeLabels[s]}edgeAsObj(){const e=this.edge(...arguments);return"object"!=typeof e?{label:e}:e}hasEdge(e,t,n){var s=1===arguments.length?o(this._isDirected,arguments[0]):r(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,s)}removeEdge(e,t,s){var i=1===arguments.length?o(this._isDirected,arguments[0]):r(this._isDirected,e,t,s),a=this._edgeObjs[i];return a&&(e=a.v,t=a.w,delete this._edgeLabels[i],delete this._edgeObjs[i],n(this._preds[t],e),n(this._sucs[e],t),delete this._in[t][i],delete this._out[e][i],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter((e=>e.v===t)):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter((e=>e.w===t)):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},Sz}function dU(){if(Az)return Iz;Az=1;var e=cU();function t(e){return e.nodes().map((function(t){var n=e.node(t),r=e.parent(t),o={v:t};return void 0!==n&&(o.value=n),void 0!==r&&(o.parent=r),o}))}function n(e){return e.edges().map((function(t){var n=e.edge(t),r={v:t.v,w:t.w};return void 0!==t.name&&(r.name=t.name),void 0!==n&&(r.value=n),r}))}return Iz={write:function(e){var r={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:t(e),edges:n(e)};void 0!==e.graph()&&(r.value=structuredClone(e.graph()));return r},read:function(t){var n=new e(t.options).setGraph(t.value);return t.nodes.forEach((function(e){n.setNode(e.v,e.value),e.parent&&n.setParent(e.v,e.parent)})),t.edges.forEach((function(e){n.setEdge({v:e.v,w:e.w,name:e.name},e.value)})),n}}}function uU(){if(Mz)return Tz;return Mz=1,Tz=function(e){var t,n={},r=[];function o(r){Object.hasOwn(n,r)||(n[r]=!0,t.push(r),e.successors(r).forEach(o),e.predecessors(r).forEach(o))}return e.nodes().forEach((function(e){t=[],o(e),t.length&&r.push(t)})),r}}function hU(){if(Oz)return Dz;Oz=1;return Dz=class{constructor(){s(this,"_arr",[]),s(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 r=this._arr,o=r.length;return n[e]=o,r.push({key:e,priority:t}),this._decrease(o),!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,r=n+1,o=e;n<t.length&&(o=t[n].priority<t[o].priority?n:o,r<t.length&&(o=t[r].priority<t[o].priority?r:o),o!==e&&(this._swap(e,o),this._heapify(o)))}_decrease(e){for(var t,n=this._arr,r=n[e].priority;0!==e&&!(n[t=e>>1].priority<r);)this._swap(e,t),e=t}_swap(e,t){var n=this._arr,r=this._keyIndices,o=n[e],s=n[t];n[e]=s,n[t]=o,r[s.key]=e,r[o.key]=t}}}function fU(){if(Pz)return Rz;Pz=1;var e=hU();Rz=function(n,r,o,s){return function(t,n,r,o){var s,i,a={},l=new e,c=function(e){var t=e.v!==s?e.v:e.w,n=a[t],o=r(e),c=i.distance+o;if(o<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+e+" Weight: "+o);c<n.distance&&(n.distance=c,n.predecessor=s,l.decrease(t,c))};t.nodes().forEach((function(e){var t=e===n?0:Number.POSITIVE_INFINITY;a[e]={distance:t},l.add(e,t)}));for(;l.size()>0&&(s=l.removeMin(),(i=a[s]).distance!==Number.POSITIVE_INFINITY);)o(s).forEach(c);return a}(n,String(r),o||t,s||function(e){return n.outEdges(e)})};var t=()=>1;return Rz}function mU(){if(Fz)return Lz;Fz=1;var e=fU();return Lz=function(t,n,r){return t.nodes().reduce((function(o,s){return o[s]=e(t,s,n,r),o}),{})}}function pU(){if(Bz)return zz;return Bz=1,zz=function(e){var t=0,n=[],r={},o=[];function s(i){var a=r[i]={onStack:!0,lowlink:t,index:t++};if(n.push(i),e.successors(i).forEach((function(e){Object.hasOwn(r,e)?r[e].onStack&&(a.lowlink=Math.min(a.lowlink,r[e].index)):(s(e),a.lowlink=Math.min(a.lowlink,r[e].lowlink))})),a.lowlink===a.index){var l,c=[];do{l=n.pop(),r[l].onStack=!1,c.push(l)}while(i!==l);o.push(c)}}return e.nodes().forEach((function(e){Object.hasOwn(r,e)||s(e)})),o}}function gU(){if($z)return Uz;$z=1;var e=pU();return Uz=function(t){return e(t).filter((function(e){return e.length>1||1===e.length&&t.hasEdge(e[0],e[0])}))}}function yU(){if(Hz)return Vz;Hz=1,Vz=function(t,n,r){return function(e,t,n){var r={},o=e.nodes();return o.forEach((function(e){r[e]={},r[e][e]={distance:0},o.forEach((function(t){e!==t&&(r[e][t]={distance:Number.POSITIVE_INFINITY})})),n(e).forEach((function(n){var o=n.v===e?n.w:n.v,s=t(n);r[e][o]={distance:s,predecessor:e}}))})),o.forEach((function(e){var t=r[e];o.forEach((function(n){var s=r[n];o.forEach((function(n){var r=s[e],o=t[n],i=s[n],a=r.distance+o.distance;a<i.distance&&(i.distance=a,i.predecessor=o.predecessor)}))}))})),r}(t,n||e,r||function(e){return t.outEdges(e)})};var e=()=>1;return Vz}function bU(){if(Gz)return Wz;function e(e){var n={},r={},o=[];if(e.sinks().forEach((function s(i){if(Object.hasOwn(r,i))throw new t;Object.hasOwn(n,i)||(r[i]=!0,n[i]=!0,e.predecessors(i).forEach(s),delete r[i],o.push(i))})),Object.keys(n).length!==e.nodeCount())throw new t;return o}Gz=1;class t extends Error{constructor(){super(...arguments)}}return Wz=e,e.CycleException=t,Wz}function xU(){if(Yz)return qz;Yz=1;var e=bU();return qz=function(t){try{e(t)}catch(_K){if(_K instanceof e.CycleException)return!1;throw _K}return!0}}function vU(){if(Jz)return Kz;function e(e,t,r,o){for(var s=[[e,!1]];s.length>0;){var i=s.pop();i[1]?o.push(i[0]):Object.hasOwn(r,i[0])||(r[i[0]]=!0,s.push([i[0],!0]),n(t(i[0]),(e=>s.push([e,!1]))))}}function t(e,t,r,o){for(var s=[e];s.length>0;){var i=s.pop();Object.hasOwn(r,i)||(r[i]=!0,o.push(i),n(t(i),(e=>s.push(e))))}}function n(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}return Jz=1,Kz=function(n,r,o){Array.isArray(r)||(r=[r]);var s=n.isDirected()?e=>n.successors(e):e=>n.neighbors(e),i="post"===o?e:t,a=[],l={};return r.forEach((e=>{if(!n.hasNode(e))throw new Error("Graph does not have node: "+e);i(e,s,l,a)})),a}}function wU(){if(Zz)return Xz;Zz=1;var e=vU();return Xz=function(t,n){return e(t,n,"post")}}function kU(){if(eB)return Qz;eB=1;var e=vU();return Qz=function(t,n){return e(t,n,"pre")}}function SU(){if(nB)return tB;nB=1;var e=cU(),t=hU();return tB=function(n,r){var o,s=new e,i={},a=new t;function l(e){var t=e.v===o?e.w:e.v,n=a.priority(t);if(void 0!==n){var s=r(e);s<n&&(i[t]=o,a.decrease(t,s))}}if(0===n.nodeCount())return s;n.nodes().forEach((function(e){a.add(e,Number.POSITIVE_INFINITY),s.setNode(e)})),a.decrease(n.nodes()[0],0);var c=!1;for(;a.size()>0;){if(o=a.removeMin(),Object.hasOwn(i,o))s.setEdge(o,i[o]);else{if(c)throw new Error("Input graph is not connected: "+n);c=!0}n.nodeEdges(o).forEach(l)}return s}}function CU(){if(iB)return sB;iB=1;var e=_z?jz:(_z=1,jz={Graph:cU(),version:Ez?Nz:(Ez=1,Nz="2.2.4")});return sB={Graph:e.Graph,json:dU(),alg:oB?rB:(oB=1,rB={components:uU(),dijkstra:fU(),dijkstraAll:mU(),findCycles:gU(),floydWarshall:yU(),isAcyclic:xU(),postorder:wU(),preorder:kU(),prim:SU(),tarjan:pU(),topsort:bU()}),version:e.version}}function NU(){if(dB)return cB;dB=1;let e=CU().Graph,t=function(){if(lB)return aB;function e(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function t(e,t){if("_next"!==e&&"_prev"!==e)return t}return lB=1,aB=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let t=this._sentinel,n=t._prev;if(n!==t)return e(n),n}enqueue(t){let n=this._sentinel;t._prev&&t._next&&e(t),t._next=n._next,n._next._prev=t,n._next=t,t._prev=n}toString(){let e=[],n=this._sentinel,r=n._prev;for(;r!==n;)e.push(JSON.stringify(r,t)),r=r._prev;return"["+e.join(", ")+"]"}}}();cB=function(s,i){if(s.nodeCount()<=1)return[];let a=function(n,r){let s=new e,i=0,a=0;n.nodes().forEach((e=>{s.setNode(e,{v:e,in:0,out:0})})),n.edges().forEach((e=>{let t=s.edge(e.v,e.w)||0,n=r(e),o=t+n;s.setEdge(e.v,e.w,o),a=Math.max(a,s.node(e.v).out+=n),i=Math.max(i,s.node(e.w).in+=n)}));let l=function(e){const t=[];for(let n=0;n<e;n++)t.push(n);return t}(a+i+3).map((()=>new t)),c=i+1;return s.nodes().forEach((e=>{o(l,c,s.node(e))})),{graph:s,buckets:l,zeroIdx:c}}(s,i||n);return function(e,t,n){let o,s=[],i=t[t.length-1],a=t[0];for(;e.nodeCount();){for(;o=a.dequeue();)r(e,t,n,o);for(;o=i.dequeue();)r(e,t,n,o);if(e.nodeCount())for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){s=s.concat(r(e,t,n,o,!0));break}}return s}(a.graph,a.buckets,a.zeroIdx).flatMap((e=>s.outEdges(e.v,e.w)))};let n=()=>1;function r(e,t,n,r,s){let i=s?[]:void 0;return e.inEdges(r.v).forEach((r=>{let a=e.edge(r),l=e.node(r.v);s&&i.push({v:r.v,w:r.w}),l.out-=a,o(t,n,l)})),e.outEdges(r.v).forEach((r=>{let s=e.edge(r),i=r.w,a=e.node(i);a.in-=s,o(t,n,a)})),e.removeNode(r.v),i}function o(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)}return cB}function EU(){if(hB)return uB;hB=1;let e=CU().Graph;function t(e,t,n,r){let o;do{o=i(r)}while(e.hasNode(o));return n.dummy=t,e.setNode(o,n),o}uB={addBorderNode:function(e,n,r,o){let s={width:0,height:0};arguments.length>=4&&(s.rank=r,s.order=o);return t(e,"border",s,n)},addDummyNode:t,applyWithChunking:r,asNonCompoundGraph:function(t){let n=new e({multigraph:t.isMultigraph()}).setGraph(t.graph());return t.nodes().forEach((e=>{t.children(e).length||n.setNode(e,t.node(e))})),t.edges().forEach((e=>{n.setEdge(e,t.edge(e))})),n},buildLayerMatrix:function(e){let t=a(o(e)+1).map((()=>[]));return e.nodes().forEach((n=>{let r=e.node(n),o=r.rank;void 0!==o&&(t[o][r.order]=n)})),t},intersectRect:function(e,t){let n,r,o=e.x,s=e.y,i=t.x-o,a=t.y-s,l=e.width/2,c=e.height/2;if(!i&&!a)throw new Error("Not possible to find intersection inside of the rectangle");Math.abs(a)*l>Math.abs(i)*c?(a<0&&(c=-c),n=c*i/a,r=c):(i<0&&(l=-l),n=l,r=l*a/i);return{x:o+n,y:s+r}},mapValues:function(e,t){let n=t;"string"==typeof t&&(n=e=>e[t]);return Object.entries(e).reduce(((e,[t,r])=>(e[t]=n(r,t),e)),{})},maxRank:o,normalizeRanks:function(e){let t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MAX_VALUE:n})),n=r(Math.min,t);e.nodes().forEach((t=>{let r=e.node(t);Object.hasOwn(r,"rank")&&(r.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 r of t)void 0!==e[r]&&(n[r]=e[r]);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 l(e.nodes(),t)},range:a,removeEmptyRanks:function(e){let t=e.nodes().map((t=>e.node(t).rank)),n=r(Math.min,t),o=[];e.nodes().forEach((t=>{let r=e.node(t).rank-n;o[r]||(o[r]=[]),o[r].push(t)}));let s=0,i=e.graph().nodeRankFactor;Array.from(o).forEach(((t,n)=>{void 0===t&&n%i!=0?--s:void 0!==t&&s&&t.forEach((t=>e.node(t).rank+=s))}))},simplify:function(t){let n=(new e).setGraph(t.graph());return t.nodes().forEach((e=>n.setNode(e,t.node(e)))),t.edges().forEach((e=>{let r=n.edge(e.v,e.w)||{weight:0,minlen:1},o=t.edge(e);n.setEdge(e.v,e.w,{weight:r.weight+o.weight,minlen:Math.max(r.minlen,o.minlen)})})),n},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 l(e.nodes(),t)},time:function(e,t){let n=Date.now();try{return t()}finally{console.log(e+" time: "+(Date.now()-n)+"ms")}},uniqueId:i,zipObject:l};const n=65535;function r(e,t){if(t.length>n){const r=function(e,t=n){const r=[];for(let n=0;n<e.length;n+=t){const o=e.slice(n,n+t);r.push(o)}return r}(t);return e.apply(null,r.map((t=>e.apply(null,t))))}return e.apply(null,t)}function o(e){const t=e.nodes().map((t=>{let n=e.node(t).rank;return void 0===n?Number.MIN_VALUE:n}));return r(Math.max,t)}let s=0;function i(e){var t=++s;return toString(e)+t}function a(e,t,n=1){null==t&&(t=e,e=0);let r=e=>e<t;n<0&&(r=e=>t<e);const o=[];for(let s=e;r(s);s+=n)o.push(s);return o}function l(e,t){return e.reduce(((e,n,r)=>(e[n]=t[r],e)),{})}return uB}function jU(){if(mB)return fB;mB=1;let e=NU(),t=EU().uniqueId;return fB={run:function(n){("greedy"===n.graph().acyclicer?e(n,(r=n,e=>r.edge(e).weight)):function(e){let t=[],n={},r={};function o(s){Object.hasOwn(r,s)||(r[s]=!0,n[s]=!0,e.outEdges(s).forEach((e=>{Object.hasOwn(n,e.w)?t.push(e):o(e.w)})),delete n[s])}return e.nodes().forEach(o),t}(n)).forEach((e=>{let r=n.edge(e);n.removeEdge(e),r.forwardName=e.name,r.reversed=!0,n.setEdge(e.w,e.v,r,t("rev"))}));var r},undo:function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}}))}}}function _U(){if(gB)return pB;gB=1;let e=EU();return pB={run:function(t){t.graph().dummyChains=[],t.edges().forEach((n=>function(t,n){let r,o,s,i=n.v,a=t.node(i).rank,l=n.w,c=t.node(l).rank,d=n.name,u=t.edge(n),h=u.labelRank;if(c===a+1)return;for(t.removeEdge(n),s=0,++a;a<c;++s,++a)u.points=[],o={width:0,height:0,edgeLabel:u,edgeObj:n,rank:a},r=e.addDummyNode(t,"edge",o,"_d"),a===h&&(o.width=u.width,o.height=u.height,o.dummy="edge-label",o.labelpos=u.labelpos),t.setEdge(i,r,{weight:u.weight},d),0===s&&t.graph().dummyChains.push(r),i=r;t.setEdge(i,l,{weight:u.weight},d)}(t,n)))},undo:function(e){e.graph().dummyChains.forEach((t=>{let n,r=e.node(t),o=r.edgeLabel;for(e.setEdge(r.edgeObj,o);r.dummy;)n=e.successors(t)[0],e.removeNode(t),o.points.push({x:r.x,y:r.y}),"edge-label"===r.dummy&&(o.x=r.x,o.y=r.y,o.width=r.width,o.height=r.height),t=n,r=e.node(t)}))}}}function IU(){if(bB)return yB;bB=1;const{applyWithChunking:e}=EU();return yB={longestPath:function(t){var n={};t.sources().forEach((function r(o){var s=t.node(o);if(Object.hasOwn(n,o))return s.rank;n[o]=!0;let i=t.outEdges(o).map((e=>null==e?Number.POSITIVE_INFINITY:r(e.w)-t.edge(e).minlen));var a=e(Math.min,i);return a===Number.POSITIVE_INFINITY&&(a=0),s.rank=a}))},slack:function(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}}}function AU(){if(vB)return xB;vB=1;var e=CU().Graph,t=IU().slack;function n(e,n){return e.nodes().forEach((function r(o){n.nodeEdges(o).forEach((s=>{var i=s.v,a=o===i?s.w:i;e.hasNode(a)||t(n,s)||(e.setNode(a,{}),e.setEdge(o,a,{}),r(a))}))})),e.nodeCount()}function r(e,n){return n.edges().reduce(((r,o)=>{let s=Number.POSITIVE_INFINITY;return e.hasNode(o.v)!==e.hasNode(o.w)&&(s=t(n,o)),s<r[0]?[s,o]:r}),[Number.POSITIVE_INFINITY,null])[1]}function o(e,t,n){e.nodes().forEach((e=>t.node(e).rank+=n))}return xB=function(s){var i,a,l=new e({directed:!1}),c=s.nodes()[0],d=s.nodeCount();l.setNode(c,{});for(;n(l,s)<d;)i=r(l,s),a=l.hasNode(i.v)?t(s,i):-t(s,i),o(l,s,a);return l}}function TU(){if(kB)return wB;kB=1;var e=AU(),t=IU().slack,n=IU().longestPath,r=CU().alg.preorder,o=CU().alg.postorder,s=EU().simplify;function i(t){t=s(t),n(t);var r,o=e(t);for(c(o),a(o,t);r=u(o);)f(o,t,r,h(o,t,r))}function a(e,t){var n=o(e,e.nodes());(n=n.slice(0,n.length-1)).forEach((n=>function(e,t,n){var r=e.node(n),o=r.parent;e.edge(n,o).cutvalue=l(e,t,n)}(e,t,n)))}function l(e,t,n){var r=e.node(n).parent,o=!0,s=t.edge(n,r),i=0;return s||(o=!1,s=t.edge(r,n)),i=s.weight,t.nodeEdges(n).forEach((s=>{var a,l,c=s.v===n,d=c?s.w:s.v;if(d!==r){var u=c===o,h=t.edge(s).weight;if(i+=u?h:-h,a=n,l=d,e.hasEdge(a,l)){var f=e.edge(n,d).cutvalue;i+=u?-f:f}}})),i}function c(e,t){arguments.length<2&&(t=e.nodes()[0]),d(e,{},1,t)}function d(e,t,n,r,o){var s=n,i=e.node(r);return t[r]=!0,e.neighbors(r).forEach((o=>{Object.hasOwn(t,o)||(n=d(e,t,n,o,r))})),i.low=s,i.lim=n++,o?i.parent=o:delete i.parent,n}function u(e){return e.edges().find((t=>e.edge(t).cutvalue<0))}function h(e,n,r){var o=r.v,s=r.w;n.hasEdge(o,s)||(o=r.w,s=r.v);var i=e.node(o),a=e.node(s),l=i,c=!1;return i.lim>a.lim&&(l=a,c=!0),n.edges().filter((t=>c===m(e,e.node(t.v),l)&&c!==m(e,e.node(t.w),l))).reduce(((e,r)=>t(n,r)<t(n,e)?r:e))}function f(e,t,n,o){var s=n.v,i=n.w;e.removeEdge(s,i),e.setEdge(o.v,o.w,{}),c(e),a(e,t),function(e,t){var n=e.nodes().find((e=>!t.node(e).parent)),o=r(e,n);(o=o.slice(1)).forEach((n=>{var r=e.node(n).parent,o=t.edge(n,r),s=!1;o||(o=t.edge(r,n),s=!0),t.node(n).rank=t.node(r).rank+(s?o.minlen:-o.minlen)}))}(e,t)}function m(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}return wB=i,i.initLowLimValues=c,i.initCutValues=a,i.calcCutValue=l,i.leaveEdge=u,i.enterEdge=h,i.exchangeEdges=f,wB}function MU(){if(CB)return SB;CB=1;var e=IU().longestPath,t=AU(),n=TU();SB=function(n){switch(n.graph().ranker){case"network-simplex":default:o(n);break;case"tight-tree":!function(n){e(n),t(n)}(n);break;case"longest-path":r(n)}};var r=e;function o(e){n(e)}return SB}function DU(){if(EB)return NB;return EB=1,NB=function(e){let t=function(e){let t={},n=0;function r(o){let s=n;e.children(o).forEach(r),t[o]={low:s,lim:n++}}return e.children().forEach(r),t}(e);e.graph().dummyChains.forEach((n=>{let r=e.node(n),o=r.edgeObj,s=function(e,t,n,r){let o,s,i=[],a=[],l=Math.min(t[n].low,t[r].low),c=Math.max(t[n].lim,t[r].lim);o=n;do{o=e.parent(o),i.push(o)}while(o&&(t[o].low>l||c>t[o].lim));s=o,o=r;for(;(o=e.parent(o))!==s;)a.push(o);return{path:i.concat(a.reverse()),lca:s}}(e,t,o.v,o.w),i=s.path,a=s.lca,l=0,c=i[l],d=!0;for(;n!==o.w;){if(r=e.node(n),d){for(;(c=i[l])!==a&&e.node(c).maxRank<r.rank;)l++;c===a&&(d=!1)}if(!d){for(;l<i.length-1&&e.node(c=i[l+1]).minRank<=r.rank;)l++;c=i[l]}e.setParent(n,c),n=e.successors(n)[0]}}))}}function OU(){if(_B)return jB;_B=1;let e=EU();function t(n,r,o,s,i,a,l){let c=n.children(l);if(!c.length)return void(l!==r&&n.setEdge(r,l,{weight:0,minlen:o}));let d=e.addBorderNode(n,"_bt"),u=e.addBorderNode(n,"_bb"),h=n.node(l);n.setParent(d,l),h.borderTop=d,n.setParent(u,l),h.borderBottom=u,c.forEach((e=>{t(n,r,o,s,i,a,e);let c=n.node(e),h=c.borderTop?c.borderTop:e,f=c.borderBottom?c.borderBottom:e,m=c.borderTop?s:2*s,p=h!==f?1:i-a[l]+1;n.setEdge(d,h,{weight:m,minlen:p,nestingEdge:!0}),n.setEdge(f,u,{weight:m,minlen:p,nestingEdge:!0})})),n.parent(l)||n.setEdge(r,d,{weight:0,minlen:i+a[l]})}return jB={run:function(n){let r=e.addDummyNode(n,"root",{},"_root"),o=function(e){var t={};function n(r,o){var s=e.children(r);s&&s.length&&s.forEach((e=>n(e,o+1))),t[r]=o}return e.children().forEach((e=>n(e,1))),t}(n),s=Object.values(o),i=e.applyWithChunking(Math.max,s)-1,a=2*i+1;n.graph().nestingRoot=r,n.edges().forEach((e=>n.edge(e).minlen*=a));let l=function(e){return e.edges().reduce(((t,n)=>t+e.edge(n).weight),0)}(n)+1;n.children().forEach((e=>t(n,r,a,l,i,o,e))),n.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)}))}}}function RU(){if(MB)return TB;function e(e){e.nodes().forEach((n=>t(e.node(n)))),e.edges().forEach((n=>t(e.edge(n))))}function t(e){let t=e.width;e.width=e.height,e.height=t}function n(e){e.y=-e.y}function r(e){let t=e.x;e.x=e.y,e.y=t}return MB=1,TB={adjust:function(t){let n=t.graph().rankdir.toLowerCase();"lr"!==n&&"rl"!==n||e(t)},undo:function(t){let o=t.graph().rankdir.toLowerCase();"bt"!==o&&"rl"!==o||function(e){e.nodes().forEach((t=>n(e.node(t)))),e.edges().forEach((t=>{let r=e.edge(t);r.points.forEach(n),Object.hasOwn(r,"y")&&n(r)}))}(t);"lr"!==o&&"rl"!==o||(!function(e){e.nodes().forEach((t=>r(e.node(t)))),e.edges().forEach((t=>{let n=e.edge(t);n.points.forEach(r),Object.hasOwn(n,"x")&&r(n)}))}(t),e(t))}}}function PU(){if(BB)return zB;BB=1;let e=EU();return zB=function(t,n){let r={};return t.forEach(((e,t)=>{let n=r[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};void 0!==e.barycenter&&(n.barycenter=e.barycenter,n.weight=e.weight)})),n.edges().forEach((e=>{let t=r[e.v],n=r[e.w];void 0!==t&&void 0!==n&&(n.indegree++,t.out.push(r[e.w]))})),function(t){let n=[];function r(e){return t=>{t.merged||(void 0===t.barycenter||void 0===e.barycenter||t.barycenter>=e.barycenter)&&function(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight);t.weight&&(n+=t.barycenter*t.weight,r+=t.weight);e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}(e,t)}}function o(e){return n=>{n.in.push(e),0==--n.indegree&&t.push(n)}}for(;t.length;){let e=t.pop();n.push(e),e.in.reverse().forEach(r(e)),e.out.forEach(o(e))}return n.filter((e=>!e.merged)).map((t=>e.pick(t,["vs","i","barycenter","weight"])))}(Object.values(r).filter((e=>!e.indegree)))}}function LU(){if(HB)return VB;HB=1;let e=FB?LB:(FB=1,LB=function(e,t=[]){return t.map((t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce(((t,n)=>{let r=e.edge(n),o=e.node(n.v);return{sum:t.sum+r.weight*o.order,weight:t.weight+r.weight}}),{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}return{v:t}}))}),t=PU(),n=function(){if($B)return UB;$B=1;let e=EU();function t(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}return UB=function(n,r){let o=e.partition(n,(e=>Object.hasOwn(e,"barycenter"))),s=o.lhs,i=o.rhs.sort(((e,t)=>t.i-e.i)),a=[],l=0,c=0,d=0;var u;s.sort((u=!!r,(e,t)=>e.barycenter<t.barycenter?-1:e.barycenter>t.barycenter?1:u?t.i-e.i:e.i-t.i)),d=t(a,i,d),s.forEach((e=>{d+=e.vs.length,a.push(e.vs),l+=e.barycenter*e.weight,c+=e.weight,d=t(a,i,d)}));let h={vs:a.flat(!0)};return c&&(h.barycenter=l/c,h.weight=c),h}}();return VB=function r(o,s,i,a){let l=o.children(s),c=o.node(s),d=c?c.borderLeft:void 0,u=c?c.borderRight:void 0,h={};d&&(l=l.filter((e=>e!==d&&e!==u)));let f=e(o,l);f.forEach((e=>{if(o.children(e.v).length){let s=r(o,e.v,i,a);h[e.v]=s,Object.hasOwn(s,"barycenter")&&(n=s,void 0!==(t=e).barycenter?(t.barycenter=(t.barycenter*t.weight+n.barycenter*n.weight)/(t.weight+n.weight),t.weight+=n.weight):(t.barycenter=n.barycenter,t.weight=n.weight))}var t,n}));let m=t(f,i);!function(e,t){e.forEach((e=>{e.vs=e.vs.flatMap((e=>t[e]?t[e].vs:e))}))}(m,h);let p=n(m,a);if(d&&(p.vs=[d,p.vs,u].flat(!0),o.predecessors(d).length)){let e=o.node(o.predecessors(d)[0]),t=o.node(o.predecessors(u)[0]);Object.hasOwn(p,"barycenter")||(p.barycenter=0,p.weight=0),p.barycenter=(p.barycenter*p.weight+e.order+t.order)/(p.weight+2),p.weight+=2}return p},VB}function FU(){if(GB)return WB;GB=1;let e=CU().Graph,t=EU();return WB=function(n,r,o){let s=function(e){var n;for(;e.hasNode(n=t.uniqueId("_root")););return n}(n),i=new e({compound:!0}).setGraph({root:s}).setDefaultNodeLabel((e=>n.node(e)));return n.nodes().forEach((e=>{let t=n.node(e),a=n.parent(e);(t.rank===r||t.minRank<=r&&r<=t.maxRank)&&(i.setNode(e),i.setParent(e,a||s),n[o](e).forEach((t=>{let r=t.v===e?t.w:t.v,o=i.edge(r,e),s=void 0!==o?o.weight:0;i.setEdge(r,e,{weight:n.edge(t).weight+s})})),Object.hasOwn(t,"minRank")&&i.setNode(e,{borderLeft:t.borderLeft[r],borderRight:t.borderRight[r]}))})),i}}function zU(){if(JB)return KB;JB=1;let e=function(){if(OB)return DB;OB=1;let e=EU();return DB=function(t){let n={},r=t.nodes().filter((e=>!t.children(e).length)),o=r.map((e=>t.node(e).rank)),s=e.applyWithChunking(Math.max,o),i=e.range(s+1).map((()=>[]));return r.sort(((e,n)=>t.node(e).rank-t.node(n).rank)).forEach((function e(r){if(n[r])return;n[r]=!0;let o=t.node(r);i[o.rank].push(r),t.successors(r).forEach(e)})),i}}(),t=function(){if(PB)return RB;PB=1;let e=EU().zipObject;function t(t,n,r){let o=e(r,r.map(((e,t)=>t))),s=n.flatMap((e=>t.outEdges(e).map((e=>({pos:o[e.w],weight:t.edge(e).weight}))).sort(((e,t)=>e.pos-t.pos)))),i=1;for(;i<r.length;)i<<=1;let a=2*i-1;i-=1;let l=new Array(a).fill(0),c=0;return s.forEach((e=>{let t=e.pos+i;l[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=l[t+1]),t=t-1>>1,l[t]+=e.weight;c+=e.weight*n})),c}return RB=function(e,n){let r=0;for(let o=1;o<n.length;++o)r+=t(e,n[o-1],n[o]);return r}}(),n=LU(),r=FU(),o=YB?qB:(YB=1,qB=function(e,t,n){let r,o={};n.forEach((n=>{let s,i,a=e.parent(n);for(;a;){if(s=e.parent(a),s?(i=o[s],o[s]=a):(i=r,r=a),i&&i!==a)return void t.setEdge(i,a);a=s}}))}),s=CU().Graph,i=EU();function a(e,t,n){return t.map((function(t){return r(e,t,n)}))}function l(e,t){let r=new s;e.forEach((function(e){let s=e.graph().root,i=n(e,s,r,t);i.vs.forEach(((t,n)=>e.node(t).order=n)),o(e,r,i.vs)}))}function c(e,t){Object.values(t).forEach((t=>t.forEach(((t,n)=>e.node(t).order=n))))}return KB=function n(r,o){if(o&&"function"==typeof o.customOrder)return void o.customOrder(r,n);let s=i.maxRank(r),d=a(r,i.range(1,s+1),"inEdges"),u=a(r,i.range(s-1,-1,-1),"outEdges"),h=e(r);if(c(r,h),o&&o.disableOptimalOrderHeuristic)return;let f,m=Number.POSITIVE_INFINITY;for(let e=0,a=0;a<4;++e,++a){l(e%2?d:u,e%4>=2),h=i.buildLayerMatrix(r);let n=t(r,h);n<m&&(a=0,f=Object.assign({},h),m=n)}c(r,f)},KB}function BU(){if(ZB)return XB;ZB=1;let e=CU().Graph,t=EU();function n(e,t){let n={};return t.length&&t.reduce((function(t,r){let s=0,i=0,a=t.length,l=r[r.length-1];return r.forEach(((t,c)=>{let d=function(e,t){if(e.node(t).dummy)return e.predecessors(t).find((t=>e.node(t).dummy))}(e,t),u=d?e.node(d).order:a;(d||t===l)&&(r.slice(i,c+1).forEach((t=>{e.predecessors(t).forEach((r=>{let i=e.node(r),a=i.order;!(a<s||u<a)||i.dummy&&e.node(t).dummy||o(n,r,t)}))})),i=c+1,s=u)})),r})),n}function r(e,n){let r={};function s(n,s,i,a,l){let c;t.range(s,i).forEach((t=>{c=n[t],e.node(c).dummy&&e.predecessors(c).forEach((t=>{let n=e.node(t);n.dummy&&(n.order<a||n.order>l)&&o(r,t,c)}))}))}return n.length&&n.reduce((function(t,n){let r,o=-1,i=0;return n.forEach(((a,l)=>{if("border"===e.node(a).dummy){let t=e.predecessors(a);t.length&&(r=e.node(t[0]).order,s(n,i,l,o,r),i=l,o=r)}s(n,i,n.length,r,t.length)})),n})),r}function o(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function s(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function i(e,t,n,r){let o={},i={},a={};return t.forEach((e=>{e.forEach(((e,t)=>{o[e]=e,i[e]=e,a[e]=t}))})),t.forEach((e=>{let t=-1;e.forEach((e=>{let l=r(e);if(l.length){l=l.sort(((e,t)=>a[e]-a[t]));let r=(l.length-1)/2;for(let c=Math.floor(r),d=Math.ceil(r);c<=d;++c){let r=l[c];i[e]===e&&t<a[r]&&!s(n,e,r)&&(i[r]=e,i[e]=o[e]=o[r],t=a[r])}}}))})),{root:o,align:i}}function a(t,n,r,o,s){let i={},a=function(t,n,r,o){let s=new e,i=t.graph(),a=function(e,t,n){return(r,o,s)=>{let i,a=r.node(o),l=r.node(s),c=0;if(c+=a.width/2,Object.hasOwn(a,"labelpos"))switch(a.labelpos.toLowerCase()){case"l":i=-a.width/2;break;case"r":i=a.width/2}if(i&&(c+=n?i:-i),i=0,c+=(a.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}}(i.nodesep,i.edgesep,o);return n.forEach((e=>{let n;e.forEach((e=>{let o=r[e];if(s.setNode(o),n){var i=r[n],l=s.edge(i,o);s.setEdge(i,o,Math.max(a(t,e,n),l||0))}n=e}))})),s}(t,n,r,s),l=s?"borderLeft":"borderRight";function c(e,t){let n=a.nodes(),r=n.pop(),o={};for(;r;)o[r]?e(r):(o[r]=!0,n.push(r),n=n.concat(t(r))),r=n.pop()}return c((function(e){i[e]=a.inEdges(e).reduce(((e,t)=>Math.max(e,i[t.v]+a.edge(t))),0)}),a.predecessors.bind(a)),c((function(e){let n=a.outEdges(e).reduce(((e,t)=>Math.min(e,i[t.w]-a.edge(t))),Number.POSITIVE_INFINITY),r=t.node(e);n!==Number.POSITIVE_INFINITY&&r.borderType!==l&&(i[e]=Math.max(i[e],n))}),a.successors.bind(a)),Object.keys(o).forEach((e=>i[e]=i[r[e]])),i}function l(e,t){return Object.values(t).reduce(((t,n)=>{let r=Number.NEGATIVE_INFINITY,o=Number.POSITIVE_INFINITY;Object.entries(n).forEach((([t,n])=>{let s=function(e,t){return e.node(t).width}(e,t)/2;r=Math.max(n+s,r),o=Math.min(n-s,o)}));const s=r-o;return s<t[0]&&(t=[s,n]),t}),[Number.POSITIVE_INFINITY,null])[1]}function c(e,n){let r=Object.values(n),o=t.applyWithChunking(Math.min,r),s=t.applyWithChunking(Math.max,r);["u","d"].forEach((r=>{["l","r"].forEach((i=>{let a=r+i,l=e[a];if(l===n)return;let c=Object.values(l),d=o-t.applyWithChunking(Math.min,c);"l"!==i&&(d=s-t.applyWithChunking(Math.max,c)),d&&(e[a]=t.mapValues(l,(e=>e+d)))}))}))}function d(e,n){return t.mapValues(e.ul,((t,r)=>{if(n)return e[n.toLowerCase()][r];{let t=Object.values(e).map((e=>e[r])).sort(((e,t)=>e-t));return(t[1]+t[2])/2}}))}return XB={positionX:function(e){let o,s=t.buildLayerMatrix(e),u=Object.assign(n(e,s),r(e,s)),h={};["u","d"].forEach((n=>{o="u"===n?s:Object.values(s).reverse(),["l","r"].forEach((r=>{"r"===r&&(o=o.map((e=>Object.values(e).reverse())));let s=("u"===n?e.predecessors:e.successors).bind(e),l=i(e,o,u,s),c=a(e,o,l.root,l.align,"r"===r);"r"===r&&(c=t.mapValues(c,(e=>-e))),h[n+r]=c}))}));let f=l(e,h);return c(h,f),d(h,e.graph().align)},findType1Conflicts:n,findType2Conflicts:r,addConflict:o,hasConflict:s,verticalAlignment:i,horizontalCompaction:a,alignCoordinates:c,findSmallestWidthAlignment:l,balance:d}}function UU(){if(eU)return QB;eU=1;let e=EU(),t=BU().positionX;return QB=function(n){(function(t){let n=e.buildLayerMatrix(t),r=t.graph().ranksep,o=0;n.forEach((e=>{const n=e.reduce(((e,n)=>{const r=t.node(n).height;return e>r?e:r}),0);e.forEach((e=>t.node(e).y=o+n/2)),o+=n+r}))})(n=e.asNonCompoundGraph(n)),Object.entries(t(n)).forEach((([e,t])=>n.node(e).x=t))}}function $U(){if(nU)return tU;nU=1;let e=jU(),t=_U(),n=MU(),r=EU().normalizeRanks,o=DU(),s=EU().removeEmptyRanks,i=OU(),a=function(){if(AB)return IB;AB=1;let e=EU();function t(t,n,r,o,s,i){let a={width:0,height:0,rank:i,borderType:n},l=s[n][i-1],c=e.addDummyNode(t,"border",a,r);s[n][i]=c,t.setParent(c,o),l&&t.setEdge(l,c,{weight:1})}return IB=function(e){e.children().forEach((function n(r){let o=e.children(r),s=e.node(r);if(o.length&&o.forEach(n),Object.hasOwn(s,"minRank")){s.borderLeft=[],s.borderRight=[];for(let n=s.minRank,o=s.maxRank+1;n<o;++n)t(e,"borderLeft","_bl",r,s,n),t(e,"borderRight","_br",r,s,n)}}))}}(),l=RU(),c=zU(),d=UU(),u=EU(),h=CU().Graph;tU=function(S,C){let N=C&&C.debugTiming?u.time:u.notime;N("layout",(()=>{let E=N(" buildLayoutGraph",(()=>function(e){let t=new h({multigraph:!0,compound:!0}),n=k(e.graph());return t.setGraph(Object.assign({},m,w(n,f),u.pick(n,p))),e.nodes().forEach((n=>{const r=w(k(e.node(n)),g);Object.keys(y).forEach((e=>{void 0===r[e]&&(r[e]=y[e])})),t.setNode(n,r),t.setParent(n,e.parent(n))})),e.edges().forEach((n=>{let r=k(e.edge(n));t.setEdge(n,Object.assign({},x,w(r,b),u.pick(r,v)))})),t}(S)));N(" runLayout",(()=>function(h,f,m){f(" makeSpaceForEdgeLabels",(()=>function(e){let t=e.graph();t.ranksep/=2,e.edges().forEach((n=>{let r=e.edge(n);r.minlen*=2,"c"!==r.labelpos.toLowerCase()&&("TB"===t.rankdir||"BT"===t.rankdir?r.width+=r.labeloffset:r.height+=r.labeloffset)}))}(h))),f(" 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)}}))}(h))),f(" acyclic",(()=>e.run(h))),f(" nestingGraph.run",(()=>i.run(h))),f(" rank",(()=>n(u.asNonCompoundGraph(h)))),f(" injectEdgeLabelProxies",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};u.addDummyNode(e,"edge-proxy",r,"_ep")}}))}(h))),f(" removeEmptyRanks",(()=>s(h))),f(" nestingGraph.cleanup",(()=>i.cleanup(h))),f(" normalizeRanks",(()=>r(h))),f(" assignRankMinMax",(()=>function(e){let t=0;e.nodes().forEach((n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))})),e.graph().maxRank=t}(h))),f(" 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))}))}(h))),f(" normalize.run",(()=>t.run(h))),f(" parentDummyChains",(()=>o(h))),f(" addBorderSegments",(()=>a(h))),f(" order",(()=>c(h,m))),f(" insertSelfEdges",(()=>function(e){var t=u.buildLayerMatrix(e);t.forEach((t=>{var n=0;t.forEach(((t,r)=>{var o=e.node(t);o.order=r+n,(o.selfEdges||[]).forEach((t=>{u.addDummyNode(e,"selfedge",{width:t.label.width,height:t.label.height,rank:o.rank,order:r+ ++n,e:t.e,label:t.label},"_se")})),delete o.selfEdges}))}))}(h))),f(" adjustCoordinateSystem",(()=>l.adjust(h))),f(" position",(()=>d(h))),f(" positionSelfEdges",(()=>function(e){e.nodes().forEach((t=>{var n=e.node(t);if("selfedge"===n.dummy){var r=e.node(n.e.v),o=r.x+r.width/2,s=r.y,i=n.x-o,a=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:o+2*i/3,y:s-a},{x:o+5*i/6,y:s-a},{x:o+i,y:s},{x:o+5*i/6,y:s+a},{x:o+2*i/3,y:s+a}],n.label.x=n.x,n.label.y=n.y}}))}(h))),f(" removeBorderNodes",(()=>function(e){e.nodes().forEach((t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),o=e.node(n.borderBottom),s=e.node(n.borderLeft[n.borderLeft.length-1]),i=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(i.x-s.x),n.height=Math.abs(o.y-r.y),n.x=s.x+n.width/2,n.y=r.y+n.height/2}})),e.nodes().forEach((t=>{"border"===e.node(t).dummy&&e.removeNode(t)}))}(h))),f(" normalize.undo",(()=>t.undo(h))),f(" 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}}))}(h))),f(" undoCoordinateSystem",(()=>l.undo(h))),f(" translateGraph",(()=>function(e){let t=Number.POSITIVE_INFINITY,n=0,r=Number.POSITIVE_INFINITY,o=0,s=e.graph(),i=s.marginx||0,a=s.marginy||0;function l(e){let s=e.x,i=e.y,a=e.width,l=e.height;t=Math.min(t,s-a/2),n=Math.max(n,s+a/2),r=Math.min(r,i-l/2),o=Math.max(o,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,r-=a,e.nodes().forEach((n=>{let o=e.node(n);o.x-=t,o.y-=r})),e.edges().forEach((n=>{let o=e.edge(n);o.points.forEach((e=>{e.x-=t,e.y-=r})),Object.hasOwn(o,"x")&&(o.x-=t),Object.hasOwn(o,"y")&&(o.y-=r)})),s.width=n-t+i,s.height=o-r+a}(h))),f(" assignNodeIntersects",(()=>function(e){e.edges().forEach((t=>{let n,r,o=e.edge(t),s=e.node(t.v),i=e.node(t.w);o.points?(n=o.points[0],r=o.points[o.points.length-1]):(o.points=[],n=i,r=s),o.points.unshift(u.intersectRect(s,n)),o.points.push(u.intersectRect(i,r))}))}(h))),f(" reversePoints",(()=>function(e){e.edges().forEach((t=>{let n=e.edge(t);n.reversed&&n.points.reverse()}))}(h))),f(" acyclic.undo",(()=>e.undo(h)))}(E,N,C))),N(" updateInputGraph",(()=>function(e,t){e.nodes().forEach((n=>{let r=e.node(n),o=t.node(n);r&&(r.x=o.x,r.y=o.y,r.rank=o.rank,t.children(n).length&&(r.width=o.width,r.height=o.height))})),e.edges().forEach((n=>{let r=e.edge(n),o=t.edge(n);r.points=o.points,Object.hasOwn(o,"x")&&(r.x=o.x,r.y=o.y)})),e.graph().width=t.graph().width,e.graph().height=t.graph().height}(S,E)))}))};let f=["nodesep","edgesep","ranksep","marginx","marginy"],m={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},p=["acyclicer","ranker","rankdir","align"],g=["width","height"],y={width:0,height:0},b=["minlen","weight","width","height","labeloffset"],x={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},v=["labelpos"];function w(e,t){return u.mapValues(u.pick(e,t),Number)}function k(e){var t={};return e&&Object.entries(e).forEach((([e,n])=>{"string"==typeof e&&(e=e.toLowerCase()),t[e]=n})),t}return tU}function VU(){if(oU)return rU;oU=1;let e=EU(),t=CU().Graph;return rU={debugOrdering:function(n){let r=e.buildLayerMatrix(n),o=new t({compound:!0,multigraph:!0}).setGraph({});return n.nodes().forEach((e=>{o.setNode(e,{label:e}),o.setParent(e,"layer"+n.node(e).rank)})),n.edges().forEach((e=>o.setEdge(e.v,e.w,{},e.name))),r.forEach(((e,t)=>{let n="layer"+t;o.setNode(n,{rank:"same"}),e.reduce(((e,t)=>(o.setEdge(e,t,{style:"invis"}),t)))})),o}}}var HU=lU?aU:(lU=1,aU={graphlib:CU(),layout:$U(),debug:VU(),util:{time:EU().time,notime:EU().notime},version:iU?sU:(iU=1,sU="1.1.4")});const WU=(new HU.graphlib.Graph).setDefaultEdgeLabel((()=>({}))),GU=(e,t,n)=>(WU.setGraph({rankdir:n.direction,nodesep:150,ranksep:200,ranker:"longest-path"}),t.forEach((e=>WU.setEdge(e.source,e.target))),e.forEach((e=>WU.setNode(e.id,{...e,width:e.width??0,height:e.height??0}))),HU.layout(WU),{nodes:e.map((e=>{const{x:t,y:n}=WU.node(e.id);return{...e,position:{x:t,y:n}}})),edges:t}),qU=new class{createEdge(e,t){return{animated:!0,markerEnd:{type:UR.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:iz(ne.get(t).code.trim().split("\n").length),position:{x:0,y:0}}}createElements(e,t,n,r){const o=[],s=[],i=new Set,a=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}`;a.has(t)||(a.add(t),i.add(n),i.add(e),s.push(this.createEdge(n,e)))}}for(const[l,c]of zi.zip(e,t)){r||o.push(this.createNode(l,c));const e=i.has(l),t=ne.get(c).code.trim().startsWith("mo.md");!e&&t||o.push(this.createNode(l,c))}return{nodes:o,edges:s}}},YU=e=>{const t=N.c(43),{cellIds:n,variables:r,cellAtoms:o,children:s,layoutDirection:i,settings:a}=e;let c;t[0]!==o||t[1]!==n||t[2]!==i||t[3]!==a.hidePureMarkdown||t[4]!==r?(c=()=>{let e=qU.createElements(n,o,r,a.hidePureMarkdown);return e=GU(e.nodes,e.edges,{direction:i}),e},t[0]=o,t[1]=n,t[2]=i,t[3]=a.hidePureMarkdown,t[4]=r,t[5]=c):c=t[5];const[d]=l.useState(c),[u,h,f]=BF(d.nodes),[m,p,g]=UF(d.edges),y=hL();let b;t[6]!==i||t[7]!==p||t[8]!==h?(b=e=>{const t=GU(e.nodes,e.edges,{direction:i});h(t.nodes),p(t.edges)},t[6]=i,t[7]=p,t[8]=h,t[9]=b):b=t[9];const x=$(b);let v,w;t[10]!==o||t[11]!==n||t[12]!==a.hidePureMarkdown||t[13]!==x||t[14]!==r?(v=()=>{x(qU.createElements(n,o,r,a.hidePureMarkdown))},w=[n,r,o,x,a.hidePureMarkdown],t[10]=o,t[11]=n,t[12]=a.hidePureMarkdown,t[13]=x,t[14]=r,t[15]=v,t[16]=w):(v=t[15],w=t[16]),l.useEffect(v,w);const[k,S]=l.useState();let C;gz(),t[17]===Symbol.for("react.memo_cache_sentinel")?(C=()=>{S(void 0)},t[17]=C):C=t[17];const E=C;let j,I,A,T,M,D,O,R,P,L;return t[18]===Symbol.for("react.memo_cache_sentinel")?(j={minZoom:.5,maxZoom:1.5},I=(e,t)=>{S({type:"node",id:t.id})},A=(e,t)=>{const{source:n,target:r}=t;S({type:"edge",source:n,target:r})},t[18]=j,t[19]=I,t[20]=A):(j=t[18],I=t[19],A=t[20]),t[21]===Symbol.for("react.memo_cache_sentinel")?(T=_.jsx(sz,{color:"#ccc",variant:JF.Dots}),t[21]=T):T=t[21],t[22]!==y||t[23]!==u?(M=()=>{const e=ne.get(mh);if(e){const t=u.find((t=>t.id===e));t&&(y.fitView({padding:1,duration:600,nodes:[t]}),S({type:"node",id:e}))}},t[22]=y,t[23]=u,t[24]=M):M=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(D=_.jsx(Qd,{className:"size-4"}),t[25]=D):D=t[25],t[26]!==M?(O=_.jsx(ZF,{position:"bottom-right",showInteractive:!1,children:_.jsx(ht,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:_.jsx(qF,{onMouseDown:dt.preventFocus,onClick:M,children:D})})}),t[26]=M,t[27]=O):O=t[27],t[28]!==m||t[29]!==k||t[30]!==r?(R=_.jsx(mz,{selection:k,variables:r,edges:m,onClearSelection:E}),t[28]=m,t[29]=k,t[30]=r,t[31]=R):R=t[31],t[32]!==s||t[33]!==m||t[34]!==u||t[35]!==g||t[36]!==f||t[37]!==O||t[38]!==R?(P=_.jsxs(FF,{nodes:u,edges:m,nodeTypes:cz,minZoom:.2,fitViewOptions:j,onNodeClick:I,onEdgeClick:A,onNodeDoubleClick:KU,fitView:!0,onNodesChange:f,onEdgesChange:g,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[T,O,R,s]}),t[32]=s,t[33]=m,t[34]=u,t[35]=g,t[36]=f,t[37]=O,t[38]=R,t[39]=P):P=t[39],t[40]!==i||t[41]!==P?(L=_.jsx(az.Provider,{value:i,children:P}),t[40]=i,t[41]=P,t[42]=L):L=t[42],L};function KU(e,t){xa(t.id,"focus")}const JU=Z("_minimap_"),XU=Z({hidePureMarkdown:!0}),ZU=e=>{const t=N.c(11),[n,r]=We(JU),[o,s]=We(XU);let i;t[0]!==n||t[1]!==e||t[2]!==r||t[3]!==s||t[4]!==o?(i=()=>"_minimap_"===n?_.jsx(vz,{...e,children:_.jsx(fz,{settings:o,onSettingsChange:s,view:n,onChange:r})}):_.jsx(YU,{...e,settings:o,layoutDirection:n,children:_.jsx(fz,{settings:o,onSettingsChange:s,view:n,onChange:r})}),t[0]=n,t[1]=e,t[2]=r,t[3]=s,t[4]=o,t[5]=i):i=t[5];const a=i;let l,c;return t[6]!==a?(l=a(),t[6]=a,t[7]=l):l=t[7],t[8]!==n||t[9]!==l?(c=_.jsx(AF,{children:l},n),t[8]=n,t[9]=l,t[10]=c):c=t[10],c},QU=()=>{const e=N.c(5),t=va(),n=fa(),[r]=wa();let o,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=$t("w-full h-full flex-1 mx-auto -mb-4 relative"),e[0]=o):o=e[0],e[1]!==n.inOrderIds||e[2]!==r||e[3]!==t?(s=_.jsx("div",{className:o,children:_.jsx(ZU,{cellAtoms:r,variables:t,cellIds:n.inOrderIds})}),e[1]=n.inOrderIds,e[2]=r,e[3]=t,e[4]=s):s=e[4],s};const e$="name",t$="type-value",n$="defs-refs",r$=[{id:e$,accessorFn:e=>[e.name,e.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>_.jsx(Pa,{header:"Name",column:e}),cell:({getValue:e})=>{const[t,n]=e();return _.jsx(hz,{name:t,declaredBy:n})}},{id:t$,accessorFn:e=>[e.dataType,e.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:e})=>_.jsx(Pa,{header:_.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsx("span",{children:"Type"}),_.jsx("span",{children:"Value"})]}),column:e}),cell:({getValue:e})=>{const[t,n]=e();return _.jsxs("div",{className:"max-w-[150px]",children:[_.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:t}),_.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:n$,accessorFn:e=>[e.declaredBy,e.usedBy,e.name,e.declaredByNames,e.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:e})=>_.jsx(Pa,{header:_.jsxs("div",{className:"flex flex-col gap-1",children:[_.jsx("span",{children:"Declared By"}),_.jsx("span",{children:"Used By"})]}),column:e}),cell:({getValue:e})=>{const[t,n,r]=e(),o=e=>{const t=ce(e);t&&ya(t,r)};return _.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[_.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[_.jsx("span",{title:"Declared by",children:_.jsx(vu,{className:"w-3.5 h-3.5 text-muted-foreground"})}),1===t.length?_.jsx(pa,{variant:"focus",cellId:t[0],skipScroll:!0,onClick:()=>o(t[0])}):_.jsx("div",{className:"text-destructive flex flex-row gap-2",children:t.slice(0,3).map(((e,n)=>_.jsxs("span",{className:"flex",children:[_.jsx(pa,{variant:"focus",cellId:e,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>o(e)},e),n<t.length-1&&", "]},e)))})]}),_.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[_.jsx("span",{title:"Used by",children:_.jsx(Tu,{className:"w-3.5 h-3.5 text-muted-foreground"})}),_.jsx(uz,{maxCount:3,cellIds:n,skipScroll:!0,onClick:o})]})]})}}];const o$=l.memo((({className:e,cellIds:t,variables:n})=>{const[r,o]=p.useState([]),[s,i]=p.useState(""),a=ka(),c=l.useMemo((()=>{const e=e=>{const n=a[e];return Ra(n)?`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,a,t]),d=l.useMemo((()=>{const e=new Map;return t.forEach(((t,n)=>e.set(t,n))),function(e,t,n){t||(t={id:n$,desc:!1});let r=[];switch(t.id){case e$:r=pd(e,(e=>e.name));break;case t$:r=pd(e,(e=>e.dataType));break;case n$:r=pd(e,(e=>n.get(e.declaredBy[0])))}return t.desc?r.reverse():r}(c,r[0],e)}),[c,r,t]),u=Sa({data:d,columns:r$,getCoreRowModel:Ea(),onGlobalFilterChange:i,getFilteredRowModel:Na(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter:e=>e.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:o,getSortedRowModel:Ca(),state:{sorting:r,globalFilter:s}});return _.jsxs(_.Fragment,{children:[_.jsx(ja,{className:"w-full",placeholder:"Search",value:s,onChange:e=>i(e.target.value)}),_.jsxs(_a,{className:$t("w-full text-sm flex-1 border-separate border-spacing-0",e),children:[_.jsx(Ia,{children:_.jsx(Aa,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map((e=>_.jsx(Ta,{className:"sticky top-0 bg-background border-b",children:Ma(e.column.columnDef.header,e.getContext())},e.id)))})}),_.jsx(Da,{children:u.getRowModel().rows.map((e=>_.jsx(Aa,{className:"hover:bg-accent",children:e.getVisibleCells().map((e=>_.jsx(Oa,{className:"border-b",children:Ma(e.column.columnDef.cell,e.getContext())},e.id)))},e.id)))})]})]})}));o$.displayName="VariableTable";const s$=()=>{const e=N.c(4),t=va(),n=fa();if(0===Object.keys(t).length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"No variables",description:"Global variables will appear here.",icon:_.jsx(bt,{})}),e[0]=t):t=e[0],t}let r;return e[1]!==n.inOrderIds||e[2]!==t?(r=_.jsx(o$,{className:"flex-1",cellIds:n.inOrderIds,variables:t}),e[1]=n.inOrderIds,e[2]=t,e[3]=r):r=e[3],r},i$=e=>{const t=N.c(6),n=e.dataTestId;let r,o;return t[0]!==e.className?(r=$t("text-xs font-semibold text-accent-foreground",e.className),t[0]=e.className,t[1]=r):r=t[1],t[2]!==e.dataTestId||t[3]!==e.onClick||t[4]!==r?(o=_.jsx("button",{type:"button","data-testid":n,className:r,onClick:e.onClick,children:"Clear"}),t[2]=e.dataTestId,t[3]=e.onClick,t[4]=r,t[5]=o):o=t[5],o},a$=()=>{const e=N.c(9),t=La(),{clearLogs:n}=V();if(0===t.length){let t,n;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx("code",{className:"border rounded px-1",children:"stdout"}),e[0]=t):t=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(n=_.jsx(gO,{title:"No logs",description:_.jsxs("span",{children:[t," and"," ",_.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:_.jsx(vt,{})}),e[1]=n):n=e[1],n}let r,o,s;return e[2]!==n?(r=_.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:_.jsx(i$,{dataTestId:"clear-logs-button",onClick:n})}),e[2]=n,e[3]=r):r=e[3],e[4]!==t?(o=_.jsx("div",{className:"overflow-auto flex-1",children:_.jsx(l$,{logs:t,className:"min-w-[300px]"})}),e[4]=t,e[5]=o):o=e[5],e[6]!==r||e[7]!==o?(s=_.jsxs(_.Fragment,{children:[r,o]}),e[6]=r,e[7]=o,e[8]=s):s=e[8],s},l$=e=>{const t=N.c(10),{logs:n,className:r}=e;let o,s,i,a,l;return t[0]!==r?(o=$t("flex flex-col",r),t[0]=r,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(s={whiteSpace:"pre-wrap"},t[2]=s):s=t[2],t[3]!==n?(i=n.map(u$),t[3]=n,t[4]=i):i=t[4],t[5]!==i?(a=_.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:_.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:s,children:i})}),t[5]=i,t[6]=a):a=t[6],t[7]!==o||t[8]!==a?(l=_.jsx("div",{className:o,children:a}),t[7]=o,t[8]=a,t[9]=l):l=t[9],l};function c$(e){const t=Fa(e.timestamp),n=d$[e.level],r=e.level.toUpperCase();return _.jsxs(_.Fragment,{children:[_.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)] dark:text-[var(--gray-11)]",children:["[",t,"]"]}),_.jsx("span",{className:$t("flex-shrink-0",n),children:r}),_.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",_.jsx(pa,{cellId:e.cellId}),")"]}),e.message]})}const d$={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"};function u$(e,t){return _.jsxs("div",{className:"contents group",children:[_.jsx("span",{className:$t("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:t+1}),_.jsx("span",{className:$t("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:c$(e)})]},t)}const h$=()=>{const e=N.c(5),{documentation:t}=de(za);if(!t){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:_.jsx(ju,{})}),e[0]=t):t=e[0],t}let n,r;return e[1]!==t?(n=Di({html:t}),e[1]=t,e[2]=n):n=e[2],e[3]!==n?(r=_.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]=r):r=e[4],r};function f$(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 m$(e){void 0===e&&(e={});var t=e.onResize,n=l.useRef(void 0);n.current=t;var r=e.round||Math.round,o=l.useRef(),s=l.useState({width:void 0,height:void 0}),i=s[0],a=s[1],c=l.useRef(!1);l.useEffect((function(){return c.current=!1,function(){c.current=!0}}),[]);var d=l.useRef({width:void 0,height:void 0}),u=function(e,t){var n=l.useRef(null),r=l.useRef(null);r.current=t;var o=l.useRef(null);l.useEffect((function(){s()}));var s=l.useCallback((function(){var t=o.current,s=r.current,i=t||(s?s instanceof Element?s:s.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 l.useEffect((function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}}),[]),l.useCallback((function(e){o.current=e,s()}),[s])}(l.useCallback((function(t){return o.current&&o.current.box===e.box&&o.current.round===r||(o.current={box:e.box,round:r,instance:new ResizeObserver((function(t){var o=t[0],s="border-box"===e.box?"borderBoxSize":"device-pixel-content-box"===e.box?"devicePixelContentBoxSize":"contentBoxSize",i=f$(o,s,"inlineSize"),l=f$(o,s,"blockSize"),u=i?r(i):void 0,h=l?r(l):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||a(f)}}))}),o.current.instance.observe(t,{box:e.box}),function(){o.current&&o.current.instance.unobserve(t)}}),[e.box,r]),e.ref);return l.useMemo((function(){return{ref:u,width:i.width,height:i.height}}),[u,i.width,i.height])}const p$=new Map,g$=({file:e,onOpenNotebook:t})=>{const{theme:n}=Be(),r=de(Ge),[o,s]=l.useState(""),{data:i,loading:a,error:c,setData:d}=Pt((async()=>{const t=await Ba({path:e.path}),n=t.contents||"";return s(p$.get(e.path)||n),t}),[e.path]),u=async()=>{o!==(null==i?void 0:i.contents)&&await Ka({path:e.path,contents:o}).then((e=>{e.success&&(d((e=>e?{...e,contents:o}:void 0)),s(o))}))},h=l.useRef(o);if(h.current=o,l.useEffect((()=>()=>{if(!(null==i?void 0:i.contents))return;const t=h.current;t===i.contents?p$.delete(e.path):p$.set(e.path,t)}),[e.path,null==i?void 0:i.contents]),c)return _.jsx(Ua,{error:c});if(a||!i)return null;const f=i.mimeType||"text/plain",m=f in b$;if(!i.contents&&!m)return _.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[_.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),_.jsx("div",{children:i.file.name}),_.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),_.jsx("div",{children:f})]});const p=_.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[e.isMarimoFile&&!E()&&_.jsx(ht,{content:"Open notebook",children:_.jsx(rc,{size:"small",onClick:e=>t(e),children:_.jsx(kn,{})})}),_.jsx(ht,{content:"Download",children:_.jsx(rc,{size:"small",onClick:()=>{if(y$(f)){const e=qa(i.contents,f);Ya(e,i.file.name)}else Cn(new Blob([i.contents||o],{type:f}),i.file.name)},children:_.jsx(bn,{})})}),!y$(f)&&_.jsxs(_.Fragment,{children:[_.jsx(ht,{content:"Copy contents to clipboard",children:_.jsx(rc,{size:"small",onClick:async()=>{await Me(o)},children:_.jsx(ut,{})})}),_.jsx(ht,{content:fn("global.save"),children:_.jsx(rc,{size:"small",color:o===i.contents?void 0:"green",onClick:u,disabled:o===i.contents,children:_.jsx(mu,{})})})]})]});return f.startsWith("image/")?_.jsxs(_.Fragment,{children:[p,_.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:_.jsx($a,{base64:i.contents,mime:f})})]}):"text/csv"===f&&i.contents?_.jsxs(_.Fragment,{children:[p,_.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:_.jsx(Va,{contents:i.contents})})]}):f.startsWith("audio/")?_.jsxs(_.Fragment,{children:[p,_.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:_.jsx(Ha,{base64:i.contents,mime:f})})]}):f.startsWith("video/")?_.jsxs(_.Fragment,{children:[p,_.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:_.jsx(Wa,{base64:i.contents,mime:f})})]}):_.jsxs(_.Fragment,{children:[p,_.jsx("div",{className:"flex-1 overflow-auto",children:_.jsx(Ga,{theme:"dark"===n?"dark":"light",language:b$[f]||b$.default,className:"border-b",extensions:[zn.lineWrapping,wr.of([{key:r.getHotkey("global.save").key,stopPropagation:!0,run:()=>o!==i.contents&&(u(),!0)}])],value:o,onChange:s})})]})},y$=e=>e.startsWith("image/")||e.startsWith("audio/")||e.startsWith("video/"),b$={"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 x$=Z(new class{constructor(e){this.callbacks=e,this.delegate=new Sc([]),this.rootPath="",this.onChange=Rt.NOOP,this.path=new Nt("/"),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 Sc(e.files),this.rootPath=e.root,this.path=Nt.guessDeliminator(e.root)}catch(t){se({title:"Failed",description:Zs(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[r,o]of t.entries()){const e=n[r];o===this.rootPath?this.delegate=new Sc(e.files):this.delegate.update({id:o,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:(se({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 r=n.data.path,o=this.path.join(this.path.dirname(r),t);await this.callbacks.renameFileOrFolder({path:r,newPath:o}).then(this.handleResponse),this.delegate.update({id:e,changes:{name:t,path:o}}),this.onChange(this.delegate.data),await this.refreshAll([o])}async move(e,t){var n;const r=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 o=this.path.join(r,this.path.basename(n.data.path));return this.delegate.update({id:e,changes:{path:o}}),this.callbacks.renameFileOrFolder({path:n.data.path,newPath:o}).then(this.handleResponse)}))),this.onChange(this.delegate.data),await this.refreshAll([r])}async createFile(e,t){var n;const r=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,o=await this.callbacks.createFileOrFolder({path:r,type:"file",name:e}).then(this.handleResponse);(null==o?void 0:o.info)&&(this.delegate.create({parentId:t,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}async createFolder(e,t){var n;const r=t?(null==(n=this.delegate.find(t))?void 0:n.data.path)??t:this.rootPath,o=await this.callbacks.createFileOrFolder({path:r,type:"directory",name:e}).then(this.handleResponse);(null==o?void 0:o.info)&&(this.delegate.create({parentId:t,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([r]))}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:Xn,createFileOrFolder:Za,deleteFileOrFolder:Xa,renameFileOrFolder:Ja})),v$=Z({});function w$(e){return new Promise(((t,n)=>{const r=new FileReader;r.onload=e=>{var n;t(null==(n=e.target)?void 0:n.result)},r.onerror=e=>{n(new Error(`Failed to read blob: ${e.type}`))},r.readAsDataURL(e)}))}function k$(e){const t=N.c(4);let n;t[0]!==e?(n=void 0===e?{}:e,t[0]=e,t[1]=n):n=t[1];const r=n;let o;return t[2]!==r?(o={multiple:!0,maxSize:104857600,onError:j$,onDropRejected:C$,onDrop:S$,...r},t[2]=r,t[3]=o):o=t[3],Qa(o)}async function S$(e){for(const t of e){const e=(await w$(t)).split(",")[1];await Za({path:"",type:"file",name:t.name,contents:e})}await async function(){await ne.get(x$).refreshAll([])}()}function C$(e){se({title:"File upload failed",description:_.jsx("div",{className:"flex flex-col gap-1",children:e.map(N$)}),variant:"danger"})}function N$(e){return _.jsxs("div",{children:[e.file.name," (",e.errors.map(E$).join(", "),")"]},e.file.name)}function E$(e){return e.message}function j$(e){X.error(e),se({title:"File upload failed",description:e.message,variant:"danger"})}const _$=p.createContext(null),I$=e=>{const t=N.c(60),{height:n}=e,r=l.useRef(null),[o]=We(x$);let s;t[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],t[0]=s):s=t[0];const[i,a]=l.useState(s),[c,d]=l.useState(null),{openPrompt:u}=ue(),[h,f]=We(v$);let m,p;t[1]!==o?(m=()=>o.initialize(a),t[1]=o,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:y}=Pt(m,p);let b;t[4]!==h||t[5]!==o?(b=()=>{o.refreshAll(Object.keys(h).filter((e=>h[e])))},t[4]=h,t[5]=o,t[6]=b):b=t[6];const x=$(b);let v;t[7]!==u||t[8]!==o?(v=async()=>{u({title:"Folder name",onConfirm:async e=>{o.createFolder(e,null)}})},t[7]=u,t[8]=o,t[9]=v):v=t[9];const w=$(v);let k;t[10]!==u||t[11]!==o?(k=async()=>{u({title:"File name",onConfirm:async e=>{o.createFile(e,null)}})},t[10]=u,t[11]=o,t[12]=k):k=t[12];const S=$(k);let C;t[13]!==f?(C=()=>{var e;null==(e=r.current)||e.closeAll(),f({})},t[13]=f,t[14]=C):C=t[14];const E=$(C);if(g){let e;return t[15]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(ta,{size:"medium",centered:!0}),t[15]=e):e=t[15],e}if(y){let e;return t[16]!==y?(e=_.jsx(Ua,{error:y}),t[16]=y,t[17]=e):e=t[17],e}if(c){let e,n,r,s,i,a;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=_.jsx(ee,{onClick:e,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:_.jsx(yd,{size:16})}),t[19]=n):n=t[19],t[20]!==c.name?(r=_.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[n,_.jsx("span",{className:"font-bold",children:c.name})]}),t[20]=c.name,t[21]=r):r=t[21],t[22]!==c.path||t[23]!==o?(s=e=>P$(e,o.relativeFromRoot(c.path)),t[22]=c.path,t[23]=o,t[24]=s):s=t[24],t[25]!==c||t[26]!==s?(i=_.jsx(l.Suspense,{children:_.jsx(g$,{onOpenNotebook:s,file:c})}),t[25]=c,t[26]=s,t[27]=i):i=t[27],t[28]!==r||t[29]!==i?(a=_.jsxs(_.Fragment,{children:[r,i]}),t[28]=r,t[29]=i,t[30]=a):a=t[30],a}let j;t[31]!==E||t[32]!==S||t[33]!==w||t[34]!==x||t[35]!==o?(j=_.jsx(T$,{onRefresh:x,onCreateFile:S,onCreateFolder:w,onCollapseAll:E,tree:o}),t[31]=E,t[32]=S,t[33]=w,t[34]=x,t[35]=o,t[36]=j):j=t[36];const I=n-33;let A,T,M,D,O,R,P,L;return t[37]!==o?(A=async e=>{const{ids:t}=e;for(const n of t)await o.delete(n)},T=async e=>{const{id:t,name:n}=e;await o.rename(t,n)},M=async e=>{const{dragIds:t,parentId:n}=e;await o.move(t,n)},t[37]=o,t[38]=A,t[39]=T,t[40]=M):(A=t[38],T=t[39],M=t[40]),t[41]===Symbol.for("react.memo_cache_sentinel")?(D=e=>{const t=e[0];t&&(t.data.isDirectory||d(t.data))},t[41]=D):D=t[41],t[42]!==h||t[43]!==f||t[44]!==o?(O=async e=>{if(await o.expand(e)){const t=h[e]??!1;f({...h,[e]:!t})}},t[42]=h,t[43]=f,t[44]=o,t[45]=O):O=t[45],t[46]!==i||t[47]!==h||t[48]!==A||t[49]!==T||t[50]!==M||t[51]!==O||t[52]!==I?(R=_.jsx(Cc,{width:"100%",ref:r,height:I,className:"h-full",data:i,initialOpenState:h,openByDefault:!1,renderCursor:L$,disableDrop:F$,onDelete:A,onRename:T,onMove:M,onSelect:D,onToggle:O,padding:15,rowHeight:30,indent:A$,overscanCount:1e3,disableMultiSelection:!0,children:O$}),t[46]=i,t[47]=h,t[48]=A,t[49]=T,t[50]=M,t[51]=O,t[52]=I,t[53]=R):R=t[53],t[54]!==R||t[55]!==o?(P=_.jsx(_$.Provider,{value:o,children:R}),t[54]=R,t[55]=o,t[56]=P):P=t[56],t[57]!==P||t[58]!==j?(L=_.jsxs(_.Fragment,{children:[j,P]}),t[57]=P,t[58]=j,t[59]=L):L=t[59],L},A$=15,T$=e=>{const t=N.c(30),{onRefresh:n,onCreateFile:r,onCreateFolder:o,onCollapseAll:s}=e;let i;t[0]===Symbol.for("react.memo_cache_sentinel")?(i={noDrag:!0,noDragEventsBubbling:!0},t[0]=i):i=t[0];const{getRootProps:a,getInputProps:l}=k$(i);let c,d,u,h,f,m,p,g,y,b,x,v,w,k,S;return t[1]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsx(Bd,{size:16}),t[1]=c):c=t[1],t[2]!==r?(d=_.jsx(ht,{content:"Add file",children:_.jsx(ee,{"data-testid":"file-explorer-add-file-button",onClick:r,variant:"text",size:"xs",children:c})}),t[2]=r,t[3]=d):d=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(u=_.jsx($d,{size:16}),t[4]=u):u=t[4],t[5]!==o?(h=_.jsx(ht,{content:"Add folder",children:_.jsx(ee,{"data-testid":"file-explorer-add-folder-button",onClick:o,variant:"text",size:"xs",children:u})}),t[5]=o,t[6]=h):h=t[6],t[7]!==a?(f=a({}),t[7]=a,t[8]=f):f=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(m=el({variant:"text",size:"xs"}),p=_.jsx(tl,{size:16}),t[9]=m,t[10]=p):(m=t[9],p=t[10]),t[11]!==f?(g=_.jsx(ht,{content:"Upload file",children:_.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?(y=l({}),t[13]=l,t[14]=y):y=t[14],t[15]!==y?(b=_.jsx("input",{...y,type:"file"}),t[15]=y,t[16]=b):b=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(x=_.jsx(gi,{size:16}),t[17]=x):x=t[17],t[18]!==n?(v=_.jsx(ht,{content:"Refresh",children:_.jsx(ee,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:x})}),t[18]=n,t[19]=v):v=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(w=_.jsx(Od,{size:16}),t[20]=w):w=t[20],t[21]!==s?(k=_.jsx(ht,{content:"Collapse all folders",children:_.jsx(ee,{"data-testid":"file-explorer-collapse-button",onClick:s,variant:"text",size:"xs",children:w})}),t[21]=s,t[22]=k):k=t[22],t[23]!==b||t[24]!==v||t[25]!==k||t[26]!==d||t[27]!==h||t[28]!==g?(S=_.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[d,h,g,b,v,k]}),t[23]=b,t[24]=v,t[25]=k,t[26]=d,t[27]=h,t[28]=g,t[29]=S):S=t[29],S},M$=e=>{const t=N.c(9),{node:n,onOpenMarimoFile:r}=e;let o,s,i;return t[0]!==n?(o=e=>{n.data.isDirectory||(e.stopPropagation(),n.select())},t[0]=n,t[1]=o):o=t[1],t[2]!==n.data.isMarimoFile||t[3]!==r?(s=n.data.isMarimoFile&&!E()&&_.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:r,children:["open ",_.jsx(kn,{className:"inline ml-1",size:12})]}),t[2]=n.data.isMarimoFile,t[3]=r,t[4]=s):s=t[4],t[5]!==n.data.name||t[6]!==o||t[7]!==s?(i=_.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:o,children:[n.data.name,s]}),t[5]=n.data.name,t[6]=o,t[7]=s,t[8]=i):i=t[8],i},D$=e=>{const t=N.c(10),{node:n}=e,r=l.useRef(null);let o,s,i,a,c;return t[0]!==n.data.name?(o=()=>{var e,t;null==(e=r.current)||e.focus(),null==(t=r.current)||t.setSelectionRange(0,n.data.name.lastIndexOf("."))},s=[n.data.name],t[0]=n.data.name,t[1]=o,t[2]=s):(o=t[1],s=t[2]),l.useEffect(o,s),t[3]!==n?(i=()=>n.reset(),a=e=>{"Escape"===e.key&&n.reset(),"Enter"===e.key&&n.submit(e.currentTarget.value)},t[3]=n,t[4]=i,t[5]=a):(i=t[4],a=t[5]),t[6]!==n.data.name||t[7]!==i||t[8]!==a?(c=_.jsx("input",{ref:r,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:z$,onBlur:i,onKeyDown:a}),t[6]=n.data.name,t[7]=i,t[8]=a,t[9]=c):c=t[9],c},O$=e=>{const t=N.c(53),{node:n,style:r,dragHandle:o}=e;let s;t[0]!==n.data.isDirectory||t[1]!==n.data.name?(s=n.data.isDirectory?"directory":Kn(n.data.name),t[0]=n.data.isDirectory,t[1]=n.data.name,t[2]=s):s=t[2];const i=s,a=Jn[i],{openConfirm:c,openPrompt:d}=ue(),u=l.useContext(_$);let h;t[3]!==n.data.path||t[4]!==u?(h=async e=>{P$(e,u?u.relativeFromRoot(n.data.path):n.data.path)},t[3]=n.data.path,t[4]=u,t[5]=h):h=t[5];const f=h;let m;t[6]!==n.data.name||t[7]!==n.id||t[8]!==n.tree||t[9]!==c?(m=async e=>{e.stopPropagation(),e.preventDefault(),c({title:"Delete file",description:`Are you sure you want to delete ${n.data.name}?`,confirmAction:_.jsx(mt,{onClick:async()=>{await n.tree.delete(n.id)},"aria-label":"Confirm",children:"Delete"})})},t[6]=n.data.name,t[7]=n.id,t[8]=n.tree,t[9]=c,t[10]=m):m=t[10];const p=m;let g;t[11]!==n||t[12]!==d||t[13]!==u?(g=async()=>{n.open(),d({title:"Folder name",onConfirm:async e=>{null==u||u.createFolder(e,n.id)}})},t[11]=n,t[12]=d,t[13]=u,t[14]=g):g=t[14];const y=$(g);let b;t[15]!==n||t[16]!==d||t[17]!==u?(b=async()=>{n.open(),d({title:"File name",onConfirm:async e=>{null==u||u.createFile(e,n.id)}})},t[15]=n,t[16]=d,t[17]=u,t[18]=b):b=t[18];const x=$(b);let v;t[19]!==i||t[20]!==x||t[21]!==y||t[22]!==p||t[23]!==f||t[24]!==n||t[25]!==u?(v=()=>{const e={size:14,strokeWidth:1.5,className:"mr-2"};return _.jsxs(Gt,{align:"end",className:"no-print w-[220px]",onClick:B$,onCloseAutoFocus:U$,children:[!n.data.isDirectory&&_.jsxs(qt,{onSelect:()=>n.select(),children:[_.jsx(Iu,{...e}),"Open file"]}),!n.data.isDirectory&&!E()&&_.jsxs(qt,{onSelect:()=>{nl({path:n.data.path})},children:[_.jsx(kn,{...e}),"Open file in external editor"]}),n.data.isDirectory&&_.jsxs(_.Fragment,{children:[_.jsxs(qt,{onSelect:()=>x(),children:[_.jsx(Bd,{...e}),"Create file"]}),_.jsxs(qt,{onSelect:()=>y(),children:[_.jsx($d,{...e}),"Create folder"]}),_.jsx(Yt,{})]}),_.jsxs(qt,{onSelect:()=>n.edit(),children:[_.jsx(cu,{...e}),"Rename"]}),_.jsxs(qt,{onSelect:async()=>{await Me(n.data.path),se({title:"Copied to clipboard"})},children:[_.jsx(ut,{...e}),"Copy path"]}),u&&_.jsxs(qt,{onSelect:async()=>{await Me(u.relativeFromRoot(n.data.path)),se({title:"Copied to clipboard"})},children:[_.jsx(ut,{...e}),"Copy relative path"]}),_.jsxs(qt,{onSelect:async()=>{se({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=ol[i](e);await Me(t)},children:[_.jsx(rl,{...e}),"Copy snippet for reading file"]}),n.data.isMarimoFile&&!E()&&_.jsxs(_.Fragment,{children:[_.jsx(Yt,{}),_.jsxs(qt,{onSelect:f,children:[_.jsx(ku,{...e}),"Open notebook"]})]}),_.jsx(Yt,{}),!n.data.isDirectory&&_.jsxs(_.Fragment,{children:[_.jsxs(qt,{onSelect:async()=>{const e=(await Ba({path:n.data.path})).contents||"";Cn(new Blob([e]),n.data.name)},children:[_.jsx(bn,{...e}),"Download"]}),_.jsx(Yt,{})]}),_.jsxs(qt,{onSelect:p,variant:"danger",children:[_.jsx(De,{...e}),"Delete"]})]})},t[19]=i,t[20]=x,t[21]=y,t[22]=p,t[23]=f,t[24]=n,t[25]=u,t[26]=v):v=t[26];const w=v;let k,S,C;t[27]===Symbol.for("react.memo_cache_sentinel")?(k=$t("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),t[27]=k):k=t[27],t[28]!==n?(S=e=>{e.stopPropagation(),n.data.isDirectory&&n.toggle()},C=_.jsx(R$,{node:n}),t[28]=n,t[29]=S,t[30]=C):(S=t[29],C=t[30]);const j=n.willReceiveDrop&&n.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground";let I,A,T,M,D,O,R;return t[31]!==j?(I=$t("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",j),t[31]=j,t[32]=I):I=t[32],t[33]!==a||t[34]!==n.data.isMarimoFile?(A=n.data.isMarimoFile?_.jsx("img",{src:"./favicon.ico",className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):_.jsx(a,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),t[33]=a,t[34]=n.data.isMarimoFile,t[35]=A):A=t[35],t[36]!==f||t[37]!==n?(T=n.isEditing?_.jsx(D$,{node:n}):_.jsx(M$,{node:n,onOpenMarimoFile:f}),t[36]=f,t[37]=n,t[38]=T):T=t[38],t[39]===Symbol.for("react.memo_cache_sentinel")?(M=_.jsx(Wt,{asChild:!0,tabIndex:-1,onClick:$$,children:_.jsx(ee,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:_.jsx(Pd,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),t[39]=M):M=t[39],t[40]!==w?(D=_.jsxs(Ht,{modal:!1,children:[M,w()]}),t[40]=w,t[41]=D):D=t[41],t[42]!==I||t[43]!==A||t[44]!==T||t[45]!==D?(O=_.jsxs("span",{className:I,children:[A,T,D]}),t[42]=I,t[43]=A,t[44]=T,t[45]=D,t[46]=O):O=t[46],t[47]!==o||t[48]!==r||t[49]!==O||t[50]!==S||t[51]!==C?(R=_.jsxs("div",{style:r,ref:o,className:k,draggable:!0,onClick:S,children:[C,O]}),t[47]=o,t[48]=r,t[49]=O,t[50]=S,t[51]=C,t[52]=R):R=t[52],R},R$=e=>{const t=N.c(3),{node:n}=e;if(!n.data.isDirectory){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{className:"w-5 h-5 flex-shrink-0"}),t[0]=e):e=t[0],e}let r;return t[1]!==n.isOpen?(r=n.isOpen?_.jsx(_e,{className:"w-5 h-5 flex-shrink-0"}):_.jsx(Ae,{className:"w-5 h-5 flex-shrink-0"}),t[1]=n.isOpen,t[2]=r):r=t[2],r};function P$(e,t){e.stopPropagation(),e.preventDefault(),window.open(`/?file=${t}`,"_blank")}function L$(){return null}function F$(e){const{parentNode:t}=e;return!t.data.isDirectory}function z$(e){return e.stopPropagation()}function B$(e){return e.stopPropagation()}function U$(e){return e.preventDefault()}function $$(e){return e.stopPropagation()}const V$=()=>{const e=N.c(20),{ref:t,height:n}=m$(),r=void 0===n?1:n;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o={noClick:!0,noKeyboard:!0},e[0]=o):o=e[0];const{getRootProps:s,getInputProps:i,isDragActive:a}=k$(o);let l,c,d,u,h,f,m,p;return e[1]!==s?(l=s(),e[1]=s,e[2]=l):l=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(c=$t("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=_.jsx("input",{...d}),e[6]=d,e[7]=u):u=e[7],e[8]!==a?(h=a&&_.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]=a,e[9]=h):h=e[9],e[10]!==r?(f=_.jsx(I$,{height:r}),e[10]=r,e[11]=f):f=e[11],e[12]!==t||e[13]!==f?(m=_.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=_.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},H$=e=>{const t=N.c(6),{children:n}=e,{openModal:r,closeModal:o}=ue();let s,i;return t[0]!==o||t[1]!==r?(s=()=>r(_.jsx(G$,{onClose:o})),t[0]=o,t[1]=r,t[2]=s):s=t[2],t[3]!==n||t[4]!==s?(i=_.jsx(sa,{onClick:s,children:n}),t[3]=n,t[4]=s,t[5]=i):i=t[5],i},W$=[zn.lineWrapping],G$=e=>{const t=N.c(23),{onClose:n}=e,[r,o]=l.useState(""),{theme:s}=Be();let i,a,c,d,u,h;t[0]!==n?(i=async e=>{e.preventDefault();const t=new FormData(e.target),r=t.get("title"),o=t.get("description"),s=t.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:r,description:o,code:s})}),n(),se({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},t[0]=n,t[1]=i):i=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(a=_.jsx(Le,{children:"Contribute a Snippet"}),t[2]=a):a=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(c=_.jsxs(Pe,{children:[a,_.jsxs(at,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",_.jsx("a",{href:it.githubPage,target:"_blank",className:"underline",children:"on GitHub"}),"."]})]}),t[3]=c):c=t[3],t[4]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(lt,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),u=_.jsx(sl,{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]!==r?(h=_.jsx("input",{type:"hidden",name:"code",value:r}),t[6]=r,t[7]=h):h=t[7];const f="dark"===s?"dark":"light";let m,p,g,y,b,x;return t[8]!==r||t[9]!==f?(m=_.jsx(Ga,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:W$,value:r,onChange:o}),t[8]=r,t[9]=f,t[10]=m):m=t[10],t[11]!==h||t[12]!==m?(p=_.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=_.jsx(ee,{"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")?(y=_.jsx(ee,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),t[16]=y):y=t[16],t[17]!==g?(b=_.jsxs(ct,{children:[g,y]}),t[17]=g,t[18]=b):b=t[18],t[19]!==i||t[20]!==b||t[21]!==p?(x=_.jsx(Re,{className:"w-fit",children:_.jsxs("form",{onSubmit:i,children:[c,p,b]})}),t[19]=i,t[20]=b,t[21]=p,t[22]=x):x=t[22],x},q$=[zn.lineWrapping],Y$=()=>{const e=N.c(20),[t,n]=p.useState();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0];const{data:o,error:s,loading:i}=Pt(X$,r);if(s){let t;return e[1]!==s?(t=_.jsx(Ua,{error:s}),e[1]=s,e[2]=t):t=e[2],t}if(i||!o){let t;return e[3]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(ta,{size:"medium",centered:!0}),e[3]=t):t=e[3],t}const a=t?"h-1/3":"h-full";let c,d,u,h,f,m,g,y,b;return e[4]!==a?(c=$t("border-b rounded-none",a),e[4]=a,e[5]=c):c=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(rt,{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")?(u=_.jsxs("div",{className:"flex items-center w-full",children:[d,_.jsx(H$,{children:_.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:_.jsx(ss,{className:"h-4 w-4"})})})]}),h=_.jsx(ot,{children:"No results"}),e[7]=u,e[8]=h):(u=e[7],h=e[8]),e[9]===Symbol.for("react.memo_cache_sentinel")?(f=e=>n(e),e[9]=f):f=e[9],e[10]!==o.snippets?(m=_.jsx(J$,{onSelect:f,snippets:o.snippets}),e[10]=o.snippets,e[11]=m):m=e[11],e[12]!==c||e[13]!==m?(g=_.jsxs(er,{className:c,children:[u,h,m]}),e[12]=c,e[13]=m,e[14]=g):g=e[14],e[15]!==t?(y=_.jsx(l.Suspense,{children:_.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:t?_.jsx(K$,{snippet:t},t.title):_.jsx(gO,{title:"",description:"Click on a snippet to view its content."})})}),e[15]=t,e[16]=y):y=e[16],e[17]!==g||e[18]!==y?(b=_.jsxs("div",{className:"flex-1 overflow-hidden",children:[g,y]}),e[17]=g,e[18]=y,e[19]=b):b=e[19],b},K$=e=>{const t=N.c(27),{snippet:n}=e,{theme:r}=Be(),{createNewCell:o}=V(),s=ph();let i;t[0]!==o||t[1]!==s||t[2]!==n.sections?(i=()=>{for(const e of[...n.sections].reverse())e.code&&o({code:e.code,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},t[0]=o,t[1]=s,t[2]=n.sections,t[3]=i):i=t[3];const a=i;let l;t[4]!==o||t[5]!==s?(l=e=>{o({code:e,before:!1,cellId:s??"__end__"})},t[4]=o,t[5]=s,t[6]=l):l=t[6];const c=l;let d,u,h,f,m,p;if(t[7]!==n.title?(d=_.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=_.jsx(kd,{className:"ml-2 h-4 w-4"}),t[9]=u):u=t[9],t[10]!==a?(h=_.jsx("div",{className:"flex justify-end",children:_.jsx(Um,{children:_.jsxs(ee,{className:"float-right",size:"xs",variant:"outline",onClick:a,children:["Insert snippet",u]})})}),t[10]=a,t[11]=h):h=t[11],t[12]!==c||t[13]!==n.sections||t[14]!==n.title||t[15]!==r){let e;t[17]!==c||t[18]!==n.title||t[19]!==r?(e=e=>{const{code:t,html:o,id:s}=e;return o?_.jsx("div",{children:Di({html:o})},`${n.title}-${s}`):t?_.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[_.jsx(Um,{children:_.jsx(ht,{content:"Insert snippet",children:_.jsx(ee,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{c(t)},children:_.jsx(kd,{className:"h-5 w-5"})})})}),_.jsx(Ga,{theme:"dark"===r?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:q$,value:t,readOnly:!0},`${n.title}-${s}`)]},`${n.title}-${s}`):null},t[17]=c,t[18]=n.title,t[19]=r,t[20]=e):e=t[20],f=n.sections.map(e),t[12]=c,t[13]=n.sections,t[14]=n.title,t[15]=r,t[16]=f}else f=t[16];return t[21]!==h||t[22]!==f?(m=_.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=_.jsxs(_.Fragment,{children:[d,m]}),t[24]=d,t[25]=m,t[26]=p):p=t[26],p},J$=e=>{const t=N.c(7),{snippets:n,onSelect:r}=e;let o,s;if(t[0]!==r||t[1]!==n){let e;t[3]!==r?(e=e=>_.jsx(et,{className:"rounded-none",onSelect:()=>r(e),children:_.jsx("div",{className:"flex flex-row gap-2 items-center",children:_.jsx("span",{className:"mt-1 text-accent-foreground",children:e.title})})},e.title),t[3]=r,t[4]=e):e=t[4],o=n.map(e),t[0]=r,t[1]=n,t[2]=o}else o=t[2];return t[5]!==o?(s=_.jsx(Ps,{className:"flex flex-col overflow-auto",children:o}),t[5]=o,t[6]=s):s=t[6],s};function X$(){return il()}const Z$=e=>{const t=N.c(8),{variableName:n,className:r}=e;let o;t[0]!==n?(o=()=>{const e=function(e){const t=ne.get(ie)[e];if(!t)return;return t.declaredBy[0]}(n);if(!e)return;const t=ce(e);t&&ya(t,n)},t[0]=n,t[1]=o):o=t[1];const s=o;let i,a;return t[2]!==r?(i=$t("text-link opacity-80 hover:opacity-100 hover:underline",r),t[2]=r,t[3]=i):i=t[3],t[4]!==s||t[5]!==i||t[6]!==n?(a=_.jsx("button",{type:"button",onClick:s,className:i,children:n}),t[4]=s,t[5]=i,t[6]=n,t[7]=a):a=t[7],a};const Q$=e=>{const t=N.c(4),{isExpanded:n}=e,r=n&&"rotate-90";let o,s;return t[0]!==r?(o=$t("h-3 w-3 transition-transform",r),t[0]=r,t[1]=o):o=t[1],t[2]!==o?(s=_.jsx(Ae,{className:o}),t[2]=o,t[3]=s):s=t[3],s},eV=e=>{const t=N.c(2),{children:n}=e;let r;return t[0]!==n?(r=_.jsx("div",{className:"flex gap-1 items-center font-bold px-2 py-1.5 text-muted-foreground bg-[var(--slate-2)] text-sm",children:n}),t[0]=n,t[1]=r):r=t[1],r},tV=e=>{const t=N.c(5),{content:n,className:r}=e;let o,s;return t[0]!==r?(o=$t("text-sm text-muted-foreground py-1",r),t[0]=r,t[1]=o):o=t[1],t[2]!==n||t[3]!==o?(s=_.jsx("div",{className:o,children:n}),t[2]=n,t[3]=o,t[4]=s):s=t[4],s},nV=e=>{const t=N.c(3),{error:n}=e;let r,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(Gn,{className:"h-4 w-4"}),t[0]=r):r=t[0],t[1]!==n.message?(o=_.jsxs("div",{className:"pl-12 text-sm bg-red-50 dark:bg-red-900 text-red-600 dark:text-red-50 flex items-center gap-2 p-2 h-8",children:[r,n.message]}),t[1]=n.message,t[2]=o):o=t[2],o},rV=e=>{const t=N.c(3),{message:n}=e;let r,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(ri,{className:"h-4 w-4 animate-spin"}),t[0]=r):r=t[0],t[1]!==n?(o=_.jsxs("div",{className:"pl-12 text-sm bg-blue-50 dark:bg-[var(--accent)] text-blue-500 dark:text-blue-50 flex items-center gap-2 p-2 h-8",children:[r,n]}),t[1]=n,t[2]=o):o=t[2],o},oV=Z(null),sV=e=>{const t=N.c(9),{packages:n}=e,r=ln(),o=he(oV);if(!n||0===n.length)return null;let s;t[0]!==r||t[1]!==n||t[2]!==o?(s=()=>{const e=n.join(", ");o(e),r.toggleApplication("packages")},t[0]=r,t[1]=n,t[2]=o,t[3]=s):s=t[3];const i=s;let a,l;return t[4]!==n?(a=n.join(", "),t[4]=n,t[5]=a):a=t[5],t[6]!==i||t[7]!==a?(l=_.jsxs(ee,{variant:"outline",size:"xs",onClick:i,className:"ml-2",children:["Install ",a]}),t[6]=i,t[7]=a,t[8]=l):l=t[8],l},iV=Z((e=>{const t=e(al),n=e(ie),r=e(Ji);return pd(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 o=r.inOrderIds.indexOf(t.declaredBy[0]);return-1===o?0:o}))})),aV=Z((e=>{const t=new Map(e(ll));for(const n of cl){const e=t.get(n);e&&0===e.databases.length&&t.delete(n)}return pd([...t.values()],(e=>cl.has(e.name)?1:0))})),lV=()=>{const e=N.c(32),[t,n]=p.useState(""),r=he(ul),o=de(iV),s=de(aV);if(0===o.length&&0===s.length){let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:_.jsx(zf,{children:_.jsxs(ee,{variant:"outline",size:"sm",children:["Add database or catalog",_.jsx(ss,{className:"h-4 w-4 ml-2"})]})}),icon:_.jsx(Ne,{})}),e[0]=t):t=e[0],t}const i=!!t.trim();let a,l,c,d,u,h,f,m,g,y;if(e[1]!==r?(a=e=>{r(e.length>0),n(e)},e[1]=r,e[2]=a):a=e[2],e[3]!==t||e[4]!==a?(l=_.jsx(rt,{placeholder:"Search tables...",className:"h-6 m-1",value:t,onValueChange:a,rootClassName:"flex-1 border-r"}),e[3]=t,e[4]=a,e[5]=l):l=e[5],e[6]!==i?(c=i&&_.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:_.jsx(Gn,{className:"h-4 w-4"})}),e[6]=i,e[7]=c):c=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(zf,{children:_.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:_.jsx(ss,{className:"h-4 w-4"})})}),e[8]=d):d=e[8],e[9]!==l||e[10]!==c?(u=_.jsxs("div",{className:"flex items-center w-full",children:[l,c,d]}),e[9]=l,e[10]=c,e[11]=u):u=e[11],e[12]!==s||e[13]!==i||e[14]!==t){let n;e[16]!==i||e[17]!==t?(n=e=>_.jsx(cV,{connection:e,hasChildren:e.databases.length>0,children:e.databases.map((n=>_.jsx(dV,{engineName:e.name,database:n,hasSearch:i,children:_.jsx(uV,{schemas:n.schemas,defaultSchema:e.default_schema,defaultDatabase:e.default_database,engineName:e.name,databaseName:n.name,hasSearch:i,searchValue:t})},n.name)))},e.name),e[16]=i,e[17]=t,e[18]=n):n=e[18],h=s.map(n),e[12]=s,e[13]=i,e[14]=t,e[15]=h}else h=e[15];return e[19]!==s.length||e[20]!==o.length?(f=s.length>0&&o.length>0&&_.jsxs(eV,{children:[_.jsx(Wl,{className:"h-4 w-4 text-muted-foreground"}),_.jsx("span",{children:"Python"})]}),e[19]=s.length,e[20]=o.length,e[21]=f):f=e[21],e[22]!==t||e[23]!==o?(m=o.length>0&&_.jsx(fV,{tables:o,searchValue:t}),e[22]=t,e[23]=o,e[24]=m):m=e[24],e[25]!==h||e[26]!==f||e[27]!==m?(g=_.jsxs(Ps,{className:"flex flex-col",children:[h,f,m]}),e[25]=h,e[26]=f,e[27]=m,e[28]=g):g=e[28],e[29]!==u||e[30]!==g?(y=_.jsxs(er,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-none",shouldFilter:!1,children:[u,g]}),e[29]=u,e[30]=g,e[31]=y):y=e[31],y},cV=e=>{var t;const n=N.c(24),{connection:r,children:o,hasChildren:s}=e,i=0===r.databases.length||!(null==(t=r.databases[0])?void 0:t.engine),a=i?"In-Memory":r.name,[l,c]=p.useState(!1);let d;n[0]!==r.name?(d=async()=>{c(!0),await pl({engine:r.name}),setTimeout((()=>c(!1)),500)},n[0]=r.name,n[1]=d):d=n[1];const u=d;let h,f,m;n[2]!==r.dialect?(h=_.jsx(en,{className:"h-4 w-4 text-muted-foreground",name:r.dialect}),f=fl(r.dialect),n[2]=r.dialect,n[3]=h,n[4]=f):(h=n[3],f=n[4]),n[5]!==f?(m=_.jsx("span",{children:f}),n[5]=f,n[6]=m):m=n[6];const g=a;let y,b,x,v,w;return n[7]!==g?(y=_.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",_.jsx(Z$,{variableName:g}),")"]}),n[7]=g,n[8]=y):y=n[8],n[9]!==u||n[10]!==i||n[11]!==l?(b=!i&&_.jsx(ht,{content:"Refresh connection",children:_.jsx(ee,{variant:"ghost",size:"icon",className:"ml-auto hover:bg-transparent hover:shadow-none",onClick:u,children:_.jsx(cs,{className:$t("h-4 w-4 text-muted-foreground hover:text-foreground",l&&"animate-[spin_0.5s]")})})}),n[9]=u,n[10]=i,n[11]=l,n[12]=b):b=n[12],n[13]!==h||n[14]!==m||n[15]!==y||n[16]!==b?(x=_.jsxs(eV,{children:[h,m,y,b]}),n[13]=h,n[14]=m,n[15]=y,n[16]=b,n[17]=x):x=n[17],n[18]!==o||n[19]!==s?(v=s?o:_.jsx(tV,{content:"No databases available",className:"pl-2"}),n[18]=o,n[19]=s,n[20]=v):v=n[20],n[21]!==x||n[22]!==v?(w=_.jsxs(_.Fragment,{children:[x,v]}),n[21]=x,n[22]=v,n[23]=w):w=n[23],w},dV=e=>{const t=N.c(28),{hasSearch:n,engineName:r,database:o,children:s}=e,[i,a]=p.useState(!1),[l,c]=p.useState(!1);let d,u,h;t[0]!==n?(d=()=>{a(n)},u=[n],t[0]=n,t[1]=d,t[2]=u):(d=t[1],u=t[2]),p.useEffect(d,u),t[3]!==i||t[4]!==l?(h=()=>{a(!i),c(!l)},t[3]=i,t[4]=l,t[5]=h):h=t[5];const f=`${r}:${o.name}`;let m;t[6]!==i?(m=_.jsx(Q$,{isExpanded:i}),t[6]=i,t[7]=m):m=t[7];const g=l&&i?"text-foreground":"text-muted-foreground";let y,b;t[8]!==g?(y=$t("h-4 w-4",g),t[8]=g,t[9]=y):y=t[9],t[10]!==y?(b=_.jsx(Ne,{className:y}),t[10]=y,t[11]=b):b=t[11];const x=l&&i&&"font-semibold";let v,w,k,S;t[12]!==x?(v=$t(x),t[12]=x,t[13]=v):v=t[13],t[14]!==o.name?(w=""===o.name?_.jsx("i",{children:"Not connected"}):o.name,t[14]=o.name,t[15]=w):w=t[15],t[16]!==v||t[17]!==w?(k=_.jsx("span",{className:v,children:w}),t[16]=v,t[17]=w,t[18]=k):k=t[18],t[19]!==k||t[20]!==h||t[21]!==f||t[22]!==m||t[23]!==b?(S=_.jsxs(et,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",onSelect:h,value:f,children:[m,b,k]}),t[19]=k,t[20]=h,t[21]=f,t[22]=m,t[23]=b,t[24]=S):S=t[24];const C=i&&s;let E;return t[25]!==S||t[26]!==C?(E=_.jsxs(_.Fragment,{children:[S,C]}),t[25]=S,t[26]=C,t[27]=E):E=t[27],E},uV=e=>{const t=N.c(20),{schemas:n,defaultSchema:r,defaultDatabase:o,engineName:s,databaseName:i,hasSearch:a,searchValue:l}=e;if(0===n.length){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(tV,{content:"No schemas available",className:"pl-6"}),t[0]=e):e=t[0],e}let c,d;if(t[1]!==i||t[2]!==o||t[3]!==r||t[4]!==s||t[5]!==a||t[6]!==n||t[7]!==l){let e;t[9]!==l?(e=e=>!l||e.tables.some((e=>e.name.toLowerCase().includes(l.toLowerCase()))),t[9]=l,t[10]=e):e=t[10];const d=n.filter(e);let u;t[11]!==i||t[12]!==o||t[13]!==r||t[14]!==s||t[15]!==a||t[16]!==l?(u=e=>_.jsx(hV,{databaseName:i,schema:e,hasSearch:a,children:_.jsx(fV,{tables:e.tables,searchValue:l,sqlTableContext:{engine:s,database:i,schema:e.name,defaultSchema:r,defaultDatabase:o}})},e.name),t[11]=i,t[12]=o,t[13]=r,t[14]=s,t[15]=a,t[16]=l,t[17]=u):u=t[17],c=d.map(u),t[1]=i,t[2]=o,t[3]=r,t[4]=s,t[5]=a,t[6]=n,t[7]=l,t[8]=c}else c=t[8];return t[18]!==c?(d=_.jsx(_.Fragment,{children:c}),t[18]=c,t[19]=d):d=t[19],d},hV=e=>{const t=N.c(26),{databaseName:n,schema:r,children:o,hasSearch:s}=e,[i,a]=p.useState(!1),[l,c]=p.useState(!1),d=`${n}:${r.name}`;let u,h,f,m;if(t[0]!==s?(u=()=>{a(s)},h=[s],t[0]=s,t[1]=u,t[2]=h):(u=t[1],h=t[2]),p.useEffect(u,h),ml(r.name))return o;t[3]!==i||t[4]!==l?(f=()=>{a(!i),c(!l)},t[3]=i,t[4]=l,t[5]=f):f=t[5],t[6]!==i?(m=_.jsx(Q$,{isExpanded:i}),t[6]=i,t[7]=m):m=t[7];const g=l&&i&&"text-foreground";let y,b;t[8]!==g?(y=$t("h-4 w-4 text-muted-foreground",g),t[8]=g,t[9]=y):y=t[9],t[10]!==y?(b=_.jsx(Sl,{className:y}),t[10]=y,t[11]=b):b=t[11];const x=l&&i&&"font-semibold";let v,w,k;t[12]!==x?(v=$t(x),t[12]=x,t[13]=v):v=t[13],t[14]!==r.name||t[15]!==v?(w=_.jsx("span",{className:v,children:r.name}),t[14]=r.name,t[15]=v,t[16]=w):w=t[16],t[17]!==w||t[18]!==f||t[19]!==m||t[20]!==b||t[21]!==d?(k=_.jsxs(et,{className:"text-sm flex flex-row gap-1 items-center pl-5 cursor-pointer rounded-none",onSelect:f,value:d,children:[m,b,w]}),t[17]=w,t[18]=f,t[19]=m,t[20]=b,t[21]=d,t[22]=k):k=t[22];const S=i&&o;let C;return t[23]!==k||t[24]!==S?(C=_.jsxs(_.Fragment,{children:[k,S]}),t[23]=k,t[24]=S,t[25]=C):C=t[25],C},fV=e=>{const t=N.c(24),{tables:n,sqlTableContext:r,searchValue:o}=e,{addTableList:s}=hl(),[i,a]=p.useState(!1),[l,c]=p.useState(!1);let d,u;t[0]!==s||t[1]!==r||t[2]!==n.length||t[3]!==i?(d=async()=>{if(0===n.length&&r&&!i){a(!0),c(!0);const{engine:e,database:t,schema:n}=r,o=await id.request({engine:e,database:t,schema:n});if(!(null==o?void 0:o.tables))throw c(!1),new Error("No tables available");s({tables:o.tables,sqlTableContext:r}),c(!1)}},t[0]=s,t[1]=r,t[2]=n.length,t[3]=i,t[4]=d):d=t[4],t[5]!==r||t[6]!==n.length||t[7]!==i?(u=[n.length,r,i],t[5]=r,t[6]=n.length,t[7]=i,t[8]=u):u=t[8];const{loading:h,error:f}=Pt(d,u);if(h||l){let e;return t[9]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(rV,{message:"Loading tables..."}),t[9]=e):e=t[9],e}if(f){let e;return t[10]!==f?(e=_.jsx(nV,{error:f}),t[10]=f,t[11]=e):e=t[11],e}if(0===n.length){let e;return t[12]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(tV,{content:"No tables found",className:"pl-9"}),t[12]=e):e=t[12],e}let m,g;if(t[13]!==o||t[14]!==r||t[15]!==n){let e;t[17]!==o?(e=e=>!o||e.name.toLowerCase().includes(o.toLowerCase()),t[17]=o,t[18]=e):e=t[18];const s=n.filter(e);let i;t[19]!==o||t[20]!==r?(i=e=>_.jsx(mV,{table:e,sqlTableContext:r,isSearching:!!o},e.name),t[19]=o,t[20]=r,t[21]=i):i=t[21],m=s.map(i),t[13]=o,t[14]=r,t[15]=n,t[16]=m}else m=t[16];return t[22]!==m?(g=_.jsx(_.Fragment,{children:m}),t[22]=m,t[23]=g):g=t[23],g},mV=e=>{const t=N.c(62),{table:n,sqlTableContext:r,isSearching:o}=e,{addTable:s}=hl(),[i,a]=p.useState(!1),[l,c]=p.useState(!1),d=n.columns.length>0;let u,h;t[0]!==s||t[1]!==i||t[2]!==r||t[3]!==n.name||t[4]!==d||t[5]!==l?(u=async()=>{if(i&&!d&&r&&!l){c(!0);const{engine:e,database:t,schema:o}=r,i=await ad.request({engine:e,database:t,schema:o,tableName:n.name});if(!(null==i?void 0:i.table))throw new Error("No table details available");s({table:i.table,sqlTableContext:r})}},t[0]=s,t[1]=i,t[2]=r,t[3]=n.name,t[4]=d,t[5]=l,t[6]=u):u=t[6],t[7]!==i||t[8]!==d?(h=[i,d],t[7]=i,t[8]=d,t[9]=h):h=t[9];const{loading:f,error:m}=Pt(u,h),g=de(me),y=ph(),{createNewCell:b}=V();let x;t[10]!==g||t[11]!==b||t[12]!==y||t[13]!==r||t[14]!==n?(x=()=>{ah(g,b,y);b({code:(()=>{if("catalog"===n.source_type){const e=(null==r?void 0:r.database)?`${r.database}.${n.name}`:n.name;return`${n.engine}.load_table("${e}")`}if(r)return yl(n,"*",r);switch(n.source_type){case"local":return`mo.ui.table(${n.name})`;case"duckdb":case"connection":return yl(n,"*",r);default:return O(n.source_type),""}})(),before:!1,cellId:y??"__end__"})},t[10]=g,t[11]=b,t[12]=y,t[13]=r,t[14]=n,t[15]=x):x=t[15];const v=x;let w;t[16]!==n.num_columns||t[17]!==n.num_rows?(w=()=>{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:_.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:_.jsx("span",{className:"text-xs text-muted-foreground",children:e.join(", ")})})},t[16]=n.num_columns,t[17]=n.num_rows,t[18]=w):w=t[18];const k=w;let S;t[19]!==m||t[20]!==f||t[21]!==r||t[22]!==n?(S=()=>{if(f)return _.jsx(rV,{message:"Loading columns..."});if(m)return _.jsx(nV,{error:m});return n.columns.map((e=>_.jsx(pV,{table:n,column:e,sqlTableContext:r},e.name)))},t[19]=m,t[20]=f,t[21]=r,t[22]=n,t[23]=S):S=t[23];const C=S;let E;t[24]!==i||t[25]!==o||t[26]!==n.source_type||t[27]!==n.type?(E=()=>{if("local"===n.source_type)return;const e="table"===n.type?gl:ve;return _.jsx(e,{className:"h-3 w-3",strokeWidth:i||o?2.5:void 0})},t[24]=i,t[25]=o,t[26]=n.source_type,t[27]=n.type,t[28]=E):E=t[28];const j=E,I=r?`${r.database}.${r.schema}.${n.name}`:n.name,A=r&&(ml(r.schema)?"pl-9":"pl-12"),T=(i||o)&&"font-semibold";let M,D,R,P,L,F,z,B,U,$,H,W;return t[29]!==A||t[30]!==T?(M=$t("rounded-none group h-8 cursor-pointer",A,T),t[29]=A,t[30]=T,t[31]=M):M=t[31],t[32]!==i?(D=()=>a(!i),t[32]=i,t[33]=D):D=t[33],t[34]!==j?(R=j(),t[34]=j,t[35]=R):R=t[35],t[36]!==n.name?(P=_.jsx("span",{className:"text-sm",children:n.name}),t[36]=n.name,t[37]=P):P=t[37],t[38]!==R||t[39]!==P?(L=_.jsxs("div",{className:"flex gap-2 items-center flex-1",children:[R,P]}),t[38]=R,t[39]=P,t[40]=L):L=t[40],t[41]!==k?(F=k(),t[41]=k,t[42]=F):F=t[42],t[43]!==v?(z=dt.stopPropagation((()=>v())),t[43]=v,t[44]=z):z=t[44],t[45]===Symbol.for("react.memo_cache_sentinel")?(B=_.jsx(Su,{className:"h-3 w-3"}),t[45]=B):B=t[45],t[46]!==z?(U=_.jsx(ht,{content:"Add table to notebook",delayDuration:400,children:_.jsx(ee,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:z,children:B})}),t[46]=z,t[47]=U):U=t[47],t[48]!==i||t[49]!==D||t[50]!==L||t[51]!==F||t[52]!==U||t[53]!==M||t[54]!==I?($=_.jsxs(et,{className:M,value:I,"aria-selected":i,forceMount:!0,onSelect:D,children:[L,F,U]}),t[48]=i,t[49]=D,t[50]=L,t[51]=F,t[52]=U,t[53]=M,t[54]=I,t[55]=$):$=t[55],t[56]!==i||t[57]!==C?(H=i&&C(),t[56]=i,t[57]=C,t[58]=H):H=t[58],t[59]!==$||t[60]!==H?(W=_.jsxs(_.Fragment,{children:[$,H]}),t[59]=$,t[60]=H,t[61]=W):W=t[61],W},pV=e=>{var t,n;const r=N.c(52),{table:o,column:s,sqlTableContext:i}=e,[a,l]=p.useState(!1),c=de(ul),d=he(bl);let u,h;r[0]!==c?(u=()=>{c&&l(!1)},h=[c],r[0]=c,r[1]=u,r[2]=h):(u=r[1],h=r[2]),p.useEffect(u,h),d(a?e=>new Set([...e,`${o.name}:${s.name}`]):e=>(e.delete(`${o.name}:${s.name}`),new Set(e)));const f=xl[s.type],m=de(me),g=ph(),{createNewCell:y}=V(),{columnsPreviews:b}=vl();let x;r[3]!==s.name||r[4]!==o.primary_keys?(x=(null==(t=o.primary_keys)?void 0:t.includes(s.name))||!1,r[3]=s.name,r[4]=o.primary_keys,r[5]=x):x=r[5];const v=x;let w;r[6]!==s.name||r[7]!==o.indexes?(w=(null==(n=o.indexes)?void 0:n.includes(s.name))||!1,r[6]=s.name,r[7]=o.indexes,r[8]=w):w=r[8];const k=w;let S;r[9]!==m||r[10]!==y||r[11]!==g?(S=e=>{e.includes("alt")&&function(e,t,n){ih("altair","alt",(r=>{const o=le.create();t({cellId:n??"__end__",before:!1,code:r,lastCodeRun:e?r:void 0,newCellId:o,autoFocus:!1}),e&&J({cellIds:[o],codes:[r]})}))}(m,y,g),y({code:e,before:!1,cellId:g??"__end__"})},r[9]=m,r[10]=y,r[11]=g,r[12]=S):S=r[12];const C=S,E=bV,j=`${o.name}.${s.name}`,I=`${o.name}.${s.name}`;let A;r[13]!==a?(A=()=>l(!a),r[13]=a,r[14]=A):A=r[14];const T=i?"pl-14":"pl-7";let M,D,O,R,P,L,F,z,B,U,$;return r[15]!==T?(M=$t("flex flex-row gap-2 items-center flex-1",T),r[15]=T,r[16]=M):M=r[16],r[17]!==f?(D=_.jsx(f,{className:"flex-shrink-0 h-3 w-3",strokeWidth:1.5}),r[17]=f,r[18]=D):D=r[18],r[19]!==s.name?(O=_.jsx("span",{children:s.name}),r[19]=s.name,r[20]=O):O=r[20],r[21]!==v?(R=v&&E({tooltipContent:"Primary key",content:"PK"}),r[21]=v,r[22]=R):R=r[22],r[23]!==k?(P=k&&E({tooltipContent:"Indexed",content:"IDX"}),r[23]=k,r[24]=P):P=r[24],r[25]!==M||r[26]!==D||r[27]!==O||r[28]!==R||r[29]!==P?(L=_.jsxs("div",{className:M,children:[D,O,R,P]}),r[25]=M,r[26]=D,r[27]=O,r[28]=R,r[29]=P,r[30]=L):L=r[30],r[31]!==s.name?(F=_.jsx(ht,{content:"Copy column name",delayDuration:400,children:_.jsx(ee,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:_.jsx(wl,{tooltip:!1,value:s.name,className:"h-3 w-3"})})}),r[31]=s.name,r[32]=F):F=r[32],r[33]!==s.external_type?(z=_.jsx("span",{className:"text-xs text-muted-foreground",children:s.external_type}),r[33]=s.external_type,r[34]=z):z=r[34],r[35]!==L||r[36]!==F||r[37]!==z||r[38]!==j||r[39]!==I||r[40]!==A?(B=_.jsxs(et,{className:"rounded-none py-1 group cursor-pointer",value:I,onSelect:A,children:[L,F,z]},j),r[35]=L,r[36]=F,r[37]=z,r[38]=j,r[39]=I,r[40]=A,r[41]=B):B=r[41],r[42]!==s||r[43]!==b||r[44]!==C||r[45]!==a||r[46]!==i||r[47]!==o?(U=a&&_.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:_.jsx(tr,{children:_.jsx(yV,{table:o,column:s,onAddColumnChart:C,preview:b.get(i?`${i.database}.${i.schema}.${o.name}:${s.name}`:`${o.name}:${s.name}`),sqlTableContext:i})})}),r[42]=s,r[43]=b,r[44]=C,r[45]=a,r[46]=i,r[47]=o,r[48]=U):U=r[48],r[49]!==B||r[50]!==U?($=_.jsxs(_.Fragment,{children:[B,U]}),r[49]=B,r[50]=U,r[51]=$):$=r[51],$},gV=p.lazy((()=>dl((()=>import("./index-De2hEZfe.js")),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url).then((e=>({default:e.VegaLite}))))),yV=e=>{const t=N.c(50),{table:n,column:r,preview:o,onAddColumnChart:s,sqlTableContext:i}=e,{theme:a}=Be();let l,c;if(t[0]!==r||t[1]!==o||t[2]!==i||t[3]!==n.name||t[4]!==n.source||t[5]!==n.source_type?(l=()=>{o||Cl({source:n.source,tableName:n.name,columnName:r.name,sourceType:n.source_type,fullyQualifiedTableName:i?`${i.database}.${i.schema}.${n.name}`:n.name})},t[0]=r,t[1]=o,t[2]=i,t[3]=n.name,t[4]=n.source,t[5]=n.source_type,t[6]=l):l=t[6],ea(l),"connection"===n.source_type){const e=r.name,o=r.external_type;let a,l,c,d;return t[7]!==r.name||t[8]!==s||t[9]!==i||t[10]!==n?(a=dt.stopPropagation((()=>{s(yl(n,r.name,i))})),t[7]=r.name,t[8]=s,t[9]=i,t[10]=n,t[11]=a):a=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(Su,{className:"h-3 w-3 mr-1"}),t[12]=l):l=t[12],t[13]!==a?(c=_.jsxs(ee,{variant:"outline",size:"xs",onClick:a,children:[l," Add SQL cell"]}),t[13]=a,t[14]=c):c=t[14],t[15]!==r.external_type||t[16]!==r.name||t[17]!==c?(d=_.jsxs("span",{className:"text-xs text-muted-foreground gap-2 flex items-center justify-between pl-7",children:[e," (",o,")",c]}),t[15]=r.external_type,t[16]=r.name,t[17]=c,t[18]=d):d=t[18],d}if("catalog"===n.source_type){let e;return t[19]!==r.external_type||t[20]!==r.name?(e=_.jsxs("span",{className:"text-xs text-muted-foreground gap-2 flex items-center justify-between pl-7",children:[r.name," (",r.external_type,")"]}),t[19]=r.external_type,t[20]=r.name,t[21]=e):e=t[21],e}if(!o){let e;return t[22]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{className:"text-xs text-muted-foreground",children:"Loading..."}),t[22]=e):e=t[22],e}t[23]!==o.error||t[24]!==o.missing_packages?(c=o.error&&_.jsxs("div",{className:"text-xs text-muted-foreground p-2 border border-muted rounded flex items-center",children:[_.jsx("span",{children:o.error}),o.missing_packages&&_.jsx(sV,{packages:o.missing_packages})]}),t[23]=o.error,t[24]=o.missing_packages,t[25]=c):c=t[25];const d=c;let u;t[26]!==o.summary?(u=o.summary&&_.jsx("div",{className:"gap-x-16 gap-y-1 grid grid-cols-2-fit border rounded p-2 empty:hidden",children:Object.entries(o.summary).map(xV)}),t[26]=o.summary,t[27]=u):u=t[27];const h=u,f=vV;let m;t[28]!==o.chart_spec||t[29]!==a?(m=o.chart_spec&&_.jsx(gV,{spec:f(JSON.parse(o.chart_spec)),width:"container",height:100,actions:!1,theme:"dark"===a?"dark":"vox"}),t[28]=o.chart_spec,t[29]=a,t[30]=m):m=t[30];const p=m;let g;t[31]!==s||t[32]!==o.chart_code||t[33]!==n.source_type?(g=o.chart_code&&"local"===n.source_type&&_.jsx(ht,{content:"Add chart to notebook",delayDuration:400,children:_.jsx(ee,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:dt.stopPropagation((()=>s(o.chart_code||""))),children:_.jsx(Su,{className:"h-3 w-3"})})}),t[31]=s,t[32]=o.chart_code,t[33]=n.source_type,t[34]=g):g=t[34];const y=g;let b;t[35]!==r||t[36]!==s||t[37]!==i||t[38]!==n?(b="duckdb"===n.source_type&&_.jsx(ht,{content:"Add SQL cell",delayDuration:400,children:_.jsx(ee,{variant:"outline",size:"icon",className:"z-10 bg-background absolute right-1 -top-1",onClick:dt.stopPropagation((()=>{s(yl(n,r.name,i))})),children:_.jsx(Su,{className:"h-3 w-3"})})}),t[35]=r,t[36]=s,t[37]=i,t[38]=n,t[39]=b):b=t[39];const x=b;let v;t[40]!==o.chart_max_rows_errors?(v=o.chart_max_rows_errors&&_.jsx("span",{className:"text-xs text-muted-foreground",children:"Too many rows to render the chart."}),t[40]=o.chart_max_rows_errors,t[41]=v):v=t[41];const w=v;if(!(d||h||p||w)){let e;return t[42]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx("span",{className:"text-xs text-muted-foreground",children:"No data"}),t[42]=e):e=t[42],e}let k;return t[43]!==y||t[44]!==x||t[45]!==p||t[46]!==w||t[47]!==d||t[48]!==h?(k=_.jsxs("div",{className:"flex flex-col gap-2 relative",children:[d,y,x,w,p,h]}),t[43]=y,t[44]=x,t[45]=p,t[46]=w,t[47]=d,t[48]=h,t[49]=k):k=t[49],k};function bV(e){const{tooltipContent:t,content:n}=e;return _.jsx(ht,{content:t,delayDuration:100,children:_.jsx("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:n})})}function xV(e){const[t,n]=e;return null==n?null:_.jsxs("div",{className:"flex items-center gap-1 group",children:[_.jsx(wl,{className:"h-3 w-3 invisible group-hover:visible",value:String(n)}),_.jsx("span",{className:"text-xs min-w-[60px] uppercase",children:t}),_.jsx("span",{className:"text-xs font-bold text-muted-foreground tracking-wide",children:kl(n)})]},t)}function vV(e){return{...e,config:{...e.config,background:"transparent"}}}const wV=()=>{const e=N.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(lV,{}),e[0]=t):t=e[0],t},kV=e=>{const t=N.c(4),{isOpen:n,children:r}=e,[o,s]=p.useState(!1);let i,a;return t[0]!==o||t[1]!==n?(i=()=>{n&&!o&&s(!0)},a=[n,o],t[0]=o,t[1]=n,t[2]=i,t[3]=a):(i=t[2],a=t[3]),p.useEffect(i,a),o?r:null},SV=Nl("marimo:scratchpadHistory:v1",[]),CV=Z(!1),NV=Z(null,((e,t,n)=>{if(!(n=n.trim()))return;const r=e(SV),o=[n,...r.filter((e=>e!==n))].slice(0,15);t(SV,o)})),EV={hide_code:!1,disabled:!1},jV=()=>{const e=N.c(69),t=yr(),[n]=Ue(),{theme:r}=Be(),o=l.useRef(null),s=ph(),{createNewCell:i,updateCellCode:a}=V(),c=t.cellRuntime[ze],d=null==c?void 0:c.output,u=null==c?void 0:c.status,h=null==c?void 0:c.consoleOutputs,f=t.cellData[ze],m=(null==f?void 0:f.code)??"",p=he(NV),[g,y]=We(CV),b=de(SV);let x;e[0]!==p||e[1]!==m?(x=()=>{El({code:m}),p(m)},e[0]=p,e[1]=m,e[2]=x):x=e[2];const v=$(x);let w;e[3]!==m||e[4]!==i||e[5]!==s?(w=()=>{m.trim()&&i({code:m,before:!1,cellId:s??"__end__"})},e[3]=m,e[4]=i,e[5]=s,e[6]=w):w=e[6];const k=$(w);let S;e[7]!==a?(S=()=>{a({cellId:ze,code:"",formattingChange:!1}),El({code:""});const e=o.current;e&&e.dispatch({changes:{from:0,to:e.state.doc.length,insert:""}})},e[7]=a,e[8]=S):S=e[8];const C=$(S);let E;e[9]!==y||e[10]!==a?(E=e=>{y(!1),a({cellId:ze,code:e,formattingChange:!1});const t=o.current;t&&t.dispatch({changes:{from:0,to:t.state.doc.length,insert:e}})},e[9]=y,e[10]=a,e[11]=E):E=e[11];const j=$(E),[I,A]=l.useState();let T;e[12]!==m||e[13]!==h||e[14]!==v||e[15]!==I||e[16]!==d||e[17]!==r||e[18]!==n?(T=()=>_.jsxs(_.Fragment,{children:[_.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:_.jsx(aT,{theme:r,allowFocus:!1,showPlaceholder:!1,id:ze,code:m,config:EV,status:"idle",serializedEditorState:null,runCell:v,userConfig:n,editorViewRef:o,setEditorView:e=>{o.current=e},hidden:!1,temporarilyShowCode:Rt.NOOP,languageAdapter:I,setLanguageAdapter:A})}),_.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:_.jsx(_i,{allowExpand:!1,output:d,className:"output-area",cellId:ze,stale:!1,loading:!1})}),_.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:_.jsx(Uc,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:jl,onSubmitDebugger:Rt.NOOP,cellId:ze,debuggerActive:!1})})]}),e[12]=m,e[13]=h,e[14]=v,e[15]=I,e[16]=d,e[17]=r,e[18]=n,e[19]=T):T=e[19];const M=T;let D;e[20]!==j||e[21]!==b||e[22]!==g||e[23]!==r?(D=()=>g?_.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:_.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:b.map(((e,t)=>_.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>j(e),children:_.jsx(Ga,{language:"python",theme:r,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:e.trim(),editable:!1,readOnly:!0})},t)))})}):null,e[20]=j,e[21]=b,e[22]=g,e[23]=r,e[24]=D):D=e[24];const O=D;let R,P,L,F,z,B,U,H,W,G,q;e[25]===Symbol.for("react.memo_cache_sentinel")?(R=St.create(ze),P=_.jsx("p",{className:"mx-2 my-2 text-muted-foreground text-sm",children:"Use this scratchpad cell to experiment with code without restrictions on variable names. Scratchpad code is ephemeral: variables defined in the scratchpad aren't saved to notebook memory, and the code is not saved in the notebook file."}),e[25]=R,e[26]=P):(R=e[25],P=e[26]),e[27]===Symbol.for("react.memo_cache_sentinel")?(L=fn("cell.run"),e[27]=L):L=e[27],e[28]===Symbol.for("react.memo_cache_sentinel")?(F=_.jsx(_c,{color:"var(--grass-11)",size:16}),e[28]=F):F=e[28],e[29]!==v||e[30]!==g?(z=_.jsx(ht,{content:L,children:_.jsx(ee,{"data-testid":"scratchpad-run-button",onClick:v,disabled:g,variant:"text",size:"xs",children:F})}),e[29]=v,e[30]=g,e[31]=z):z=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(B=_.jsx(Ld,{size:16}),e[32]=B):B=e[32],e[33]!==C||e[34]!==g?(U=_.jsx(ht,{content:"Clear code and outputs",children:_.jsx(ee,{disabled:g,size:"xs",variant:"text",onClick:C,children:B})}),e[33]=C,e[34]=g,e[35]=U):U=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(H=_.jsx(kd,{size:16}),e[36]=H):H=e[36],e[37]!==k||e[38]!==g?(W=_.jsx(Um,{children:_.jsx(ht,{content:"Insert code",children:_.jsx(ee,{disabled:g,size:"xs",variant:"text",onClick:k,children:H})})}),e[37]=k,e[38]=g,e[39]=W):W=e[39],e[40]!==u?(G=("running"===u||"queued"===u)&&_.jsx(ta,{className:"inline",size:"small"}),e[40]=u,e[41]=G):G=e[41],e[42]===Symbol.for("react.memo_cache_sentinel")?(q=_.jsx("div",{className:"flex-1"}),e[42]=q):q=e[42];const Y=g&&"bg-[var(--sky-3)] rounded-none";let K,J;e[43]!==Y?(K=$t(Y),e[43]=Y,e[44]=K):K=e[44],e[45]!==g||e[46]!==y?(J=()=>y(!g),e[45]=g,e[46]=y,e[47]=J):J=e[47];const X=0===b.length;let Z,Q,te,ne,re,oe,se;return e[48]===Symbol.for("react.memo_cache_sentinel")?(Z=_.jsx(Gd,{size:16}),e[48]=Z):Z=e[48],e[49]!==K||e[50]!==J||e[51]!==X?(Q=_.jsx(ht,{content:"Toggle history",children:_.jsx(ee,{size:"xs",variant:"text",className:K,onClick:J,disabled:X,children:Z})}),e[49]=K,e[50]=J,e[51]=X,e[52]=Q):Q=e[52],e[53]!==z||e[54]!==U||e[55]!==W||e[56]!==G||e[57]!==Q?(te=_.jsxs("div",{className:"flex items-center flex-shrink-0",children:[z,U,W,G,q,Q]}),e[53]=z,e[54]=U,e[55]=W,e[56]=G,e[57]=Q,e[58]=te):te=e[58],e[59]!==M?(ne=M(),e[59]=M,e[60]=ne):ne=e[60],e[61]!==O?(re=O(),e[61]=O,e[62]=re):re=e[62],e[63]!==ne||e[64]!==re?(oe=_.jsxs("div",{className:"flex-1 divide-y relative overflow-hidden flex flex-col",children:[ne,re]}),e[63]=ne,e[64]=re,e[65]=oe):oe=e[65],e[66]!==te||e[67]!==oe?(se=_.jsxs("div",{className:"flex flex-col h-full overflow-hidden divide-y",id:R,children:[P,te,oe]}),e[66]=te,e[67]=oe,e[68]=se):se=e[68],se},_V=()=>{const e=N.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(jV,{}),e[0]=t):t=e[0],t},IV=()=>{const e=N.c(16),[t]=Ue(),n=t.package_management.manager;let r;e[0]!==n?(r=[n],e[0]=n,e[1]=r):r=e[1];const{data:o,loading:s,error:i,reload:a}=Pt(DV,r);if(s&&!o){let t;return e[2]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(ta,{size:"medium",centered:!0}),e[2]=t):t=e[2],t}if(i){let t;return e[3]!==i?(t=_.jsx(Ua,{error:i}),e[3]=i,e[4]=t):t=e[4],t}let l;e[5]!==(null==o?void 0:o.packages)?(l=(null==o?void 0:o.packages)||[],e[5]=null==o?void 0:o.packages,e[6]=l):l=e[6];const c=l;let d,u,h;return e[7]!==n||e[8]!==a?(d=_.jsx(AV,{packageManager:n,onSuccess:a}),e[7]=n,e[8]=a,e[9]=d):d=e[9],e[10]!==c||e[11]!==a?(u=_.jsx(TV,{packages:c,onSuccess:a}),e[10]=c,e[11]=a,e[12]=u):u=e[12],e[13]!==d||e[14]!==u?(h=_.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},AV=({onSuccess:e,packageManager:t})=>{const[n,r]=p.useState(""),[o,s]=p.useState(!1),{handleClick:i}=yc(),a=de(oV),l=he(oV);p.useEffect((()=>{a&&(r(a),l(null))}),[a,l]);const c=async()=>{try{s(!0);const t=await Il({package:n});t.success?(e(),se({title:"Package added",description:_.jsxs("span",{children:["The package ",_.jsx(Wr,{className:"inline",children:n})," and its dependencies has been added to your environment."]})})):se({title:"Failed to add package",description:t.error,variant:"danger"})}finally{r(""),s(!1)}};return _.jsxs("div",{className:"flex items-center w-full border-b",children:[_.jsx(ja,{placeholder:`Install packages with ${t}...`,id:av,icon:o?_.jsx(ta,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):_.jsx(ht,{content:"Change package manager",children:_.jsx(Kl,{onClick:()=>i("packageManagement"),className:"mr-2 h-4 w-4 shrink-0 opacity-50 hover:opacity-80 cursor-pointer"})}),rootClassName:"flex-1 border-none",value:n,onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),c())},onChange:e=>r(e.target.value)}),_.jsx(ht,{delayDuration:300,side:"left",align:"start",content:_.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:",_.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[_.jsxs("div",{children:[_.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"})," A package name; this will install the latest version.",_.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),_.jsxs("div",{children:[_.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"})," ","A package with a specific version or version range.",_.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),_.jsxs("div",{children:[_.jsx("span",{className:"font-bold tracking-wide",children:"Git:"})," A Git repository",_.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),_.jsxs("div",{children:[_.jsx("span",{className:"font-bold tracking-wide",children:"URL:"})," A remote wheel or source distribution.",_.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),_.jsxs("div",{children:[_.jsx("span",{className:"font-bold tracking-wide",children:"Path:"})," A local wheel, source distribution, or project directory.",_.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:_.jsx(ji,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),_.jsx("button",{type:"button",className:$t("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:c,disabled:!n,children:"Add"})]})},TV=e=>{const t=N.c(9),{onSuccess:n,packages:r}=e;if(0===r.length){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=_.jsx(gO,{title:"No packages",description:"No packages are installed in this environment.",icon:_.jsx(Kl,{})}),t[0]=e):e=t[0],e}let o,s,i;if(t[1]===Symbol.for("react.memo_cache_sentinel")?(o=_.jsx(Ia,{children:_.jsxs(Aa,{children:[_.jsx(Ta,{children:"Name"}),_.jsx(Ta,{children:"Version"}),_.jsx(Ta,{})]})}),t[1]=o):o=t[1],t[2]!==n||t[3]!==r){let e;t[5]!==n?(e=e=>_.jsxs(Aa,{className:"group",onClick:async()=>{await Me(`${e.name}==${e.version}`),se({title:"Copied to clipboard"})},children:[_.jsx(Oa,{children:e.name}),_.jsx(Oa,{children:e.version}),_.jsx(Oa,{children:_.jsx(MV,{packageName:e.name,onSuccess:n})})]},e.name),t[5]=n,t[6]=e):e=t[6],s=r.map(e),t[2]=n,t[3]=r,t[4]=s}else s=t[4];return t[7]!==s?(i=_.jsxs(_a,{className:"overflow-auto flex-1",children:[o,_.jsx(Da,{children:s})]}),t[7]=s,t[8]=i):i=t[8],i},MV=({packageName:e,onSuccess:t})=>{const[n,r]=p.useState(!1);return n?_.jsx(ta,{size:"small",className:"float-right mr-2 h-4 w-4 shrink-0 opacity-50"}):_.jsx("button",{type:"button",className:$t("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible"),onClick:dt.stopPropagation((async()=>{try{r(!0);const n=await Al({package:e});n.success?(t(),se({title:"Package removed",description:_.jsxs("span",{children:["The package ",_.jsx(Wr,{className:"inline",children:e})," has been removed from your environment."]})})):se({title:"Failed to add package",description:n.error,variant:"danger"})}finally{r(!1)}})),children:"Remove"})};function DV(){return _l()}var OV="ScrollArea",[RV,PV]=To(OV),[LV,FV]=RV(OV),zV=l.forwardRef(((e,t)=>{const{__scopeScrollArea:n,type:r="hover",dir:o,scrollHideDelay:s=600,...i}=e,[a,c]=l.useState(null),[d,u]=l.useState(null),[h,f]=l.useState(null),[m,p]=l.useState(null),[g,y]=l.useState(null),[b,x]=l.useState(0),[v,w]=l.useState(0),[k,S]=l.useState(!1),[C,N]=l.useState(!1),E=Tl(t,(e=>c(e))),j=Ml(o);return _.jsx(LV,{scope:n,type:r,dir:j,scrollHideDelay:s,scrollArea:a,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:p,scrollbarXEnabled:k,onScrollbarXEnabledChange:S,scrollbarY:g,onScrollbarYChange:y,scrollbarYEnabled:C,onScrollbarYEnabledChange:N,onCornerWidthChange:x,onCornerHeightChange:w,children:_.jsx(Do.div,{dir:j,...i,ref:E,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":v+"px",...e.style}})})}));zV.displayName=OV;var BV="ScrollAreaViewport",UV=l.forwardRef(((e,t)=>{const{__scopeScrollArea:n,children:r,nonce:o,...s}=e,i=FV(BV,n),a=l.useRef(null),c=Tl(t,a,i.onViewportChange);return _.jsxs(_.Fragment,{children:[_.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:o}),_.jsx(Do.div,{"data-radix-scroll-area-viewport":"",...s,ref:c,style:{overflowX:i.scrollbarXEnabled?"scroll":"hidden",overflowY:i.scrollbarYEnabled?"scroll":"hidden",...e.style},children:_.jsx("div",{ref:i.onContentChange,style:{minWidth:"100%",display:"table"},children:r})})]})}));UV.displayName=BV;var $V="ScrollAreaScrollbar",VV=l.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=FV($V,e.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:i}=o,a="horizontal"===e.orientation;return l.useEffect((()=>(a?s(!0):i(!0),()=>{a?s(!1):i(!1)})),[a,s,i]),"hover"===o.type?_.jsx(HV,{...r,ref:t,forceMount:n}):"scroll"===o.type?_.jsx(WV,{...r,ref:t,forceMount:n}):"auto"===o.type?_.jsx(GV,{...r,ref:t,forceMount:n}):"always"===o.type?_.jsx(qV,{...r,ref:t}):null}));VV.displayName=$V;var HV=l.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=FV($V,e.__scopeScrollArea),[s,i]=l.useState(!1);return l.useEffect((()=>{const e=o.scrollArea;let t=0;if(e){const n=()=>{window.clearTimeout(t),i(!0)},r=()=>{t=window.setTimeout((()=>i(!1)),o.scrollHideDelay)};return e.addEventListener("pointerenter",n),e.addEventListener("pointerleave",r),()=>{window.clearTimeout(t),e.removeEventListener("pointerenter",n),e.removeEventListener("pointerleave",r)}}}),[o.scrollArea,o.scrollHideDelay]),_.jsx(Dl,{present:n||s,children:_.jsx(GV,{"data-state":s?"visible":"hidden",...r,ref:t})})})),WV=l.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=FV($V,e.__scopeScrollArea),s="horizontal"===e.orientation,i=hH((()=>c("SCROLL_END")),100),[a,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"}},l.useReducer(((e,t)=>u[e][t]??e),d));var d,u;return l.useEffect((()=>{if("idle"===a){const e=window.setTimeout((()=>c("HIDE")),o.scrollHideDelay);return()=>window.clearTimeout(e)}}),[a,o.scrollHideDelay,c]),l.useEffect((()=>{const e=o.viewport,t=s?"scrollLeft":"scrollTop";if(e){let n=e[t];const r=()=>{const r=e[t];n!==r&&(c("SCROLL"),i()),n=r};return e.addEventListener("scroll",r),()=>e.removeEventListener("scroll",r)}}),[o.viewport,s,c,i]),_.jsx(Dl,{present:n||"hidden"!==a,children:_.jsx(qV,{"data-state":"hidden"===a?"hidden":"visible",...r,ref:t,onPointerEnter:Oo(e.onPointerEnter,(()=>c("POINTER_ENTER"))),onPointerLeave:Oo(e.onPointerLeave,(()=>c("POINTER_LEAVE")))})})})),GV=l.forwardRef(((e,t)=>{const n=FV($V,e.__scopeScrollArea),{forceMount:r,...o}=e,[s,i]=l.useState(!1),a="horizontal"===e.orientation,c=hH((()=>{if(n.viewport){const e=n.viewport.offsetWidth<n.viewport.scrollWidth,t=n.viewport.offsetHeight<n.viewport.scrollHeight;i(a?e:t)}}),10);return fH(n.viewport,c),fH(n.content,c),_.jsx(Dl,{present:r||s,children:_.jsx(qV,{"data-state":s?"visible":"hidden",...o,ref:t})})})),qV=l.forwardRef(((e,t)=>{const{orientation:n="vertical",...r}=e,o=FV($V,e.__scopeScrollArea),s=l.useRef(null),i=l.useRef(0),[a,c]=l.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=iH(a.viewport,a.content),u={...r,sizes:a,onSizesChange:c,hasThumb:Boolean(d>0&&d<1),onThumbChange:e=>s.current=e,onThumbPointerUp:()=>i.current=0,onThumbPointerDown:e=>i.current=e};function h(e,t){return function(e,t,n,r="ltr"){const o=aH(n),s=o/2,i=t||s,a=o-i,l=n.scrollbar.paddingStart+i,c=n.scrollbar.size-n.scrollbar.paddingEnd-a,d=n.content-n.viewport,u="ltr"===r?[0,d]:[-1*d,0];return cH([l,c],u)(e)}(e,i.current,a,t)}return"horizontal"===n?_.jsx(YV,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=lH(o.viewport.scrollLeft,a,o.dir);s.current.style.transform=`translate3d(${e}px, 0, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollLeft=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollLeft=h(e,o.dir))}}):"vertical"===n?_.jsx(KV,{...u,ref:t,onThumbPositionChange:()=>{if(o.viewport&&s.current){const e=lH(o.viewport.scrollTop,a);s.current.style.transform=`translate3d(0, ${e}px, 0)`}},onWheelScroll:e=>{o.viewport&&(o.viewport.scrollTop=e)},onDragScroll:e=>{o.viewport&&(o.viewport.scrollTop=h(e))}}):null})),YV=l.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=FV($V,e.__scopeScrollArea),[i,a]=l.useState(),c=l.useRef(null),d=Tl(t,c,s.onScrollbarXChange);return l.useEffect((()=>{c.current&&a(getComputedStyle(c.current))}),[c]),_.jsx(ZV,{"data-orientation":"horizontal",...o,ref:d,sizes:n,style:{bottom:0,left:"rtl"===s.dir?"var(--radix-scroll-area-corner-width)":0,right:"ltr"===s.dir?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":aH(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.x),onDragScroll:t=>e.onDragScroll(t.x),onWheelScroll:(t,n)=>{if(s.viewport){const r=s.viewport.scrollLeft+t.deltaX;e.onWheelScroll(r),dH(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:c.current.clientWidth,paddingStart:sH(i.paddingLeft),paddingEnd:sH(i.paddingRight)}})}})})),KV=l.forwardRef(((e,t)=>{const{sizes:n,onSizesChange:r,...o}=e,s=FV($V,e.__scopeScrollArea),[i,a]=l.useState(),c=l.useRef(null),d=Tl(t,c,s.onScrollbarYChange);return l.useEffect((()=>{c.current&&a(getComputedStyle(c.current))}),[c]),_.jsx(ZV,{"data-orientation":"vertical",...o,ref:d,sizes:n,style:{top:0,right:"ltr"===s.dir?0:void 0,left:"rtl"===s.dir?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":aH(n)+"px",...e.style},onThumbPointerDown:t=>e.onThumbPointerDown(t.y),onDragScroll:t=>e.onDragScroll(t.y),onWheelScroll:(t,n)=>{if(s.viewport){const r=s.viewport.scrollTop+t.deltaY;e.onWheelScroll(r),dH(r,n)&&t.preventDefault()}},onResize:()=>{c.current&&s.viewport&&i&&r({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:c.current.clientHeight,paddingStart:sH(i.paddingTop),paddingEnd:sH(i.paddingBottom)}})}})})),[JV,XV]=RV($V),ZV=l.forwardRef(((e,t)=>{const{__scopeScrollArea:n,sizes:r,hasThumb:o,onThumbChange:s,onThumbPointerUp:i,onThumbPointerDown:a,onThumbPositionChange:c,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=e,m=FV($V,n),[p,g]=l.useState(null),y=Tl(t,(e=>g(e))),b=l.useRef(null),x=l.useRef(""),v=m.viewport,w=r.content-r.viewport,k=Wo(u),S=Wo(c),C=hH(h,10);function N(e){if(b.current){const t=e.clientX-b.current.left,n=e.clientY-b.current.top;d({x:t,y:n})}}return l.useEffect((()=>{const e=e=>{const t=e.target;(null==p?void 0:p.contains(t))&&k(e,w)};return document.addEventListener("wheel",e,{passive:!1}),()=>document.removeEventListener("wheel",e,{passive:!1})}),[v,p,w,k]),l.useEffect(S,[r,S]),fH(p,C),fH(m.content,C),_.jsx(JV,{scope:n,scrollbar:p,hasThumb:o,onThumbChange:Wo(s),onThumbPointerUp:Wo(i),onThumbPositionChange:S,onThumbPointerDown:Wo(a),children:_.jsx(Do.div,{...f,ref:y,style:{position:"absolute",...f.style},onPointerDown:Oo(e.onPointerDown,(e=>{if(0===e.button){e.target.setPointerCapture(e.pointerId),b.current=p.getBoundingClientRect(),x.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),N(e)}})),onPointerMove:Oo(e.onPointerMove,N),onPointerUp:Oo(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=""),b.current=null}))})})})),QV="ScrollAreaThumb",eH=l.forwardRef(((e,t)=>{const{forceMount:n,...r}=e,o=XV(QV,e.__scopeScrollArea);return _.jsx(Dl,{present:n||o.hasThumb,children:_.jsx(tH,{ref:t,...r})})})),tH=l.forwardRef(((e,t)=>{const{__scopeScrollArea:n,style:r,...o}=e,s=FV(QV,n),i=XV(QV,n),{onThumbPositionChange:a}=i,c=Tl(t,(e=>i.onThumbChange(e))),d=l.useRef(void 0),u=hH((()=>{d.current&&(d.current(),d.current=void 0)}),100);return l.useEffect((()=>{const e=s.viewport;if(e){const t=()=>{if(u(),!d.current){const t=uH(e,a);d.current=t,a()}};return a(),e.addEventListener("scroll",t),()=>e.removeEventListener("scroll",t)}}),[s.viewport,u,a]),_.jsx(Do.div,{"data-state":i.hasThumb?"visible":"hidden",...o,ref:c,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...r},onPointerDownCapture:Oo(e.onPointerDownCapture,(e=>{const t=e.target.getBoundingClientRect(),n=e.clientX-t.left,r=e.clientY-t.top;i.onThumbPointerDown({x:n,y:r})})),onPointerUp:Oo(e.onPointerUp,i.onThumbPointerUp)})}));eH.displayName=QV;var nH="ScrollAreaCorner",rH=l.forwardRef(((e,t)=>{const n=FV(nH,e.__scopeScrollArea),r=Boolean(n.scrollbarX&&n.scrollbarY);return"scroll"!==n.type&&r?_.jsx(oH,{...e,ref:t}):null}));rH.displayName=nH;var oH=l.forwardRef(((e,t)=>{const{__scopeScrollArea:n,...r}=e,o=FV(nH,n),[s,i]=l.useState(0),[a,c]=l.useState(0),d=Boolean(s&&a);return fH(o.scrollbarX,(()=>{var e;const t=(null==(e=o.scrollbarX)?void 0:e.offsetHeight)||0;o.onCornerHeightChange(t),c(t)})),fH(o.scrollbarY,(()=>{var e;const t=(null==(e=o.scrollbarY)?void 0:e.offsetWidth)||0;o.onCornerWidthChange(t),i(t)})),d?_.jsx(Do.div,{...r,ref:t,style:{width:s,height:a,position:"absolute",right:"ltr"===o.dir?0:void 0,left:"rtl"===o.dir?0:void 0,bottom:0,...e.style}}):null}));function sH(e){return e?parseInt(e,10):0}function iH(e,t){const n=e/t;return isNaN(n)?0:n}function aH(e){const t=iH(e.viewport,e.content),n=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,r=(e.scrollbar.size-n)*t;return Math.max(r,18)}function lH(e,t,n="ltr"){const r=aH(t),o=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=t.scrollbar.size-o,i=t.content-t.viewport,a=s-r,l=Rl(e,"ltr"===n?[0,i]:[-1*i,0]);return cH([0,i],[0,a])(l)}function cH(e,t){return n=>{if(e[0]===e[1]||t[0]===t[1])return t[0];const r=(t[1]-t[0])/(e[1]-e[0]);return t[0]+r*(n-e[0])}}function dH(e,t){return e>0&&e<t}var uH=(e,t=()=>{})=>{let n={left:e.scrollLeft,top:e.scrollTop},r=0;return function o(){const s={left:e.scrollLeft,top:e.scrollTop},i=n.left!==s.left,a=n.top!==s.top;(i||a)&&t(),n=s,r=window.requestAnimationFrame(o)}(),()=>window.cancelAnimationFrame(r)};function hH(e,t){const n=Wo(e),r=l.useRef(0);return l.useEffect((()=>()=>window.clearTimeout(r.current)),[]),l.useCallback((()=>{window.clearTimeout(r.current),r.current=window.setTimeout(n,t)}),[n,t])}function fH(e,t){const n=Wo(t);Ol((()=>{let t=0;if(e){const r=new ResizeObserver((()=>{cancelAnimationFrame(t),t=window.requestAnimationFrame(n)}));return r.observe(e),()=>{window.cancelAnimationFrame(t),r.unobserve(e)}}}),[e,n])}var mH=zV,pH=UV,gH=rH;const yH=l.forwardRef(((e,t)=>{const n=N.c(15);let r,o,s,i,a,l,c,d;return n[0]!==e?(({className:o,children:r,...s}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]),n[4]!==o?(i=$t("relative overflow-hidden",o),n[4]=o,n[5]=i):i=n[5],n[6]!==r?(a=_.jsx(pH,{className:"h-full w-full rounded-[inherit]",children:r}),n[6]=r,n[7]=a):a=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=_.jsx(bH,{}),c=_.jsx(gH,{}),n[8]=l,n[9]=c):(l=n[8],c=n[9]),n[10]!==s||n[11]!==t||n[12]!==i||n[13]!==a?(d=_.jsxs(mH,{ref:t,className:i,...s,children:[a,l,c]}),n[10]=s,n[11]=t,n[12]=i,n[13]=a,n[14]=d):d=n[14],d}));yH.displayName=mH.displayName;const bH=l.forwardRef(((e,t)=>{const n=N.c(14);let r,o,s;n[0]!==e?(({className:r,orientation:s,...o}=e),n[0]=e,n[1]=r,n[2]=o,n[3]=s):(r=n[1],o=n[2],s=n[3]);const i=void 0===s?"vertical":s,a="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]!==r||n[5]!==a||n[6]!==l?(c=$t("flex touch-none select-none transition-colors",a,l,r),n[4]=r,n[5]=a,n[6]=l,n[7]=c):c=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=_.jsx(eH,{className:"relative flex-1 rounded-full bg-border"}),n[8]=d):d=n[8],n[9]!==i||n[10]!==o||n[11]!==t||n[12]!==c?(u=_.jsx(VV,{ref:t,orientation:i,className:c,...o,children:d}),n[9]=i,n[10]=o,n[11]=t,n[12]=c,n[13]=u):u=n[13],u}));bH.displayName=VV.displayName;const xH=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,vH=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,wH={};function kH(e,t){return(wH.jsx?vH:xH).test(e)}const SH=/[ \t\n\f\r]/g;function CH(e){return""===e.replace(SH,"")}class NH{constructor(e,t,n){this.property=e,this.normal=t,n&&(this.space=n)}}function EH(e,t){const n={},r={};let o=-1;for(;++o<e.length;)Object.assign(n,e[o].property),Object.assign(r,e[o].normal);return new NH(n,r,t)}function jH(e){return e.toLowerCase()}NH.prototype.property={},NH.prototype.normal={},NH.prototype.space=null;class _H{constructor(e,t){this.property=e,this.attribute=t}}_H.prototype.space=null,_H.prototype.boolean=!1,_H.prototype.booleanish=!1,_H.prototype.overloadedBoolean=!1,_H.prototype.number=!1,_H.prototype.commaSeparated=!1,_H.prototype.spaceSeparated=!1,_H.prototype.commaOrSpaceSeparated=!1,_H.prototype.mustUseProperty=!1,_H.prototype.defined=!1;let IH=0;const AH=LH(),TH=LH(),MH=LH(),DH=LH(),OH=LH(),RH=LH(),PH=LH();function LH(){return 2**++IH}const FH=Object.freeze(Object.defineProperty({__proto__:null,boolean:AH,booleanish:TH,commaOrSpaceSeparated:PH,commaSeparated:RH,number:DH,overloadedBoolean:MH,spaceSeparated:OH},Symbol.toStringTag,{value:"Module"})),zH=Object.keys(FH);class BH extends _H{constructor(e,t,n,r){let o=-1;if(super(e,t),UH(this,"space",r),"number"==typeof n)for(;++o<zH.length;){const e=zH[o];UH(this,zH[o],(n&FH[e])===FH[e])}}}function UH(e,t,n){n&&(e[t]=n)}BH.prototype.defined=!0;const $H={}.hasOwnProperty;function VH(e){const t={},n={};let r;for(r in e.properties)if($H.call(e.properties,r)){const o=e.properties[r],s=new BH(r,e.transform(e.attributes||{},r),o,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(s.mustUseProperty=!0),t[r]=s,n[jH(r)]=r,n[jH(s.attribute)]=r}return new NH(t,n,e.space)}const HH=VH({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}}),WH=VH({space:"xml",transform:(e,t)=>"xml:"+t.slice(3).toLowerCase(),properties:{xmlLang:null,xmlBase:null,xmlSpace:null}});function GH(e,t){return t in e?e[t]:t}function qH(e,t){return GH(e,t.toLowerCase())}const YH=VH({space:"xmlns",attributes:{xmlnsxlink:"xmlns:xlink"},transform:qH,properties:{xmlns:null,xmlnsXLink:null}}),KH=VH({transform:(e,t)=>"role"===t?t:"aria-"+t.slice(4).toLowerCase(),properties:{ariaActiveDescendant:null,ariaAtomic:TH,ariaAutoComplete:null,ariaBusy:TH,ariaChecked:TH,ariaColCount:DH,ariaColIndex:DH,ariaColSpan:DH,ariaControls:OH,ariaCurrent:null,ariaDescribedBy:OH,ariaDetails:null,ariaDisabled:TH,ariaDropEffect:OH,ariaErrorMessage:null,ariaExpanded:TH,ariaFlowTo:OH,ariaGrabbed:TH,ariaHasPopup:null,ariaHidden:TH,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:OH,ariaLevel:DH,ariaLive:null,ariaModal:TH,ariaMultiLine:TH,ariaMultiSelectable:TH,ariaOrientation:null,ariaOwns:OH,ariaPlaceholder:null,ariaPosInSet:DH,ariaPressed:TH,ariaReadOnly:TH,ariaRelevant:null,ariaRequired:TH,ariaRoleDescription:OH,ariaRowCount:DH,ariaRowIndex:DH,ariaRowSpan:DH,ariaSelected:TH,ariaSetSize:DH,ariaSort:null,ariaValueMax:DH,ariaValueMin:DH,ariaValueNow:DH,ariaValueText:null,role:null}}),JH=VH({space:"html",attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},transform:qH,mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:RH,acceptCharset:OH,accessKey:OH,action:null,allow:null,allowFullScreen:AH,allowPaymentRequest:AH,allowUserMedia:AH,alt:null,as:null,async:AH,autoCapitalize:null,autoComplete:OH,autoFocus:AH,autoPlay:AH,blocking:OH,capture:null,charSet:null,checked:AH,cite:null,className:OH,cols:DH,colSpan:null,content:null,contentEditable:TH,controls:AH,controlsList:OH,coords:DH|RH,crossOrigin:null,data:null,dateTime:null,decoding:null,default:AH,defer:AH,dir:null,dirName:null,disabled:AH,download:MH,draggable:TH,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:AH,formTarget:null,headers:OH,height:DH,hidden:AH,high:DH,href:null,hrefLang:null,htmlFor:OH,httpEquiv:OH,id:null,imageSizes:null,imageSrcSet:null,inert:AH,inputMode:null,integrity:null,is:null,isMap:AH,itemId:null,itemProp:OH,itemRef:OH,itemScope:AH,itemType:OH,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:AH,low:DH,manifest:null,max:null,maxLength:DH,media:null,method:null,min:null,minLength:DH,multiple:AH,muted:AH,name:null,nonce:null,noModule:AH,noValidate:AH,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:AH,optimum:DH,pattern:null,ping:OH,placeholder:null,playsInline:AH,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:AH,referrerPolicy:null,rel:OH,required:AH,reversed:AH,rows:DH,rowSpan:DH,sandbox:OH,scope:null,scoped:AH,seamless:AH,selected:AH,shadowRootClonable:AH,shadowRootDelegatesFocus:AH,shadowRootMode:null,shape:null,size:DH,sizes:null,slot:null,span:DH,spellCheck:TH,src:null,srcDoc:null,srcLang:null,srcSet:null,start:DH,step:null,style:null,tabIndex:DH,target:null,title:null,translate:null,type:null,typeMustMatch:AH,useMap:null,value:TH,width:DH,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:OH,axis:null,background:null,bgColor:null,border:DH,borderColor:null,bottomMargin:DH,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:AH,declare:AH,event:null,face:null,frame:null,frameBorder:null,hSpace:DH,leftMargin:DH,link:null,longDesc:null,lowSrc:null,marginHeight:DH,marginWidth:DH,noResize:AH,noHref:AH,noShade:AH,noWrap:AH,object:null,profile:null,prompt:null,rev:null,rightMargin:DH,rules:null,scheme:null,scrolling:TH,standby:null,summary:null,text:null,topMargin:DH,valueType:null,version:null,vAlign:null,vLink:null,vSpace:DH,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:AH,disableRemotePlayback:AH,prefix:null,property:null,results:DH,security:null,unselectable:null}}),XH=VH({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:GH,properties:{about:PH,accentHeight:DH,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:DH,amplitude:DH,arabicForm:null,ascent:DH,attributeName:null,attributeType:null,azimuth:DH,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:DH,by:null,calcMode:null,capHeight:DH,className:OH,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:DH,diffuseConstant:DH,direction:null,display:null,dur:null,divisor:DH,dominantBaseline:null,download:AH,dx:null,dy:null,edgeMode:null,editable:null,elevation:DH,enableBackground:null,end:null,event:null,exponent:DH,externalResourcesRequired:null,fill:null,fillOpacity:DH,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:RH,g2:RH,glyphName:RH,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:DH,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:DH,horizOriginX:DH,horizOriginY:DH,id:null,ideographic:DH,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:DH,k:DH,k1:DH,k2:DH,k3:DH,k4:DH,kernelMatrix:PH,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:DH,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:DH,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:DH,overlineThickness:DH,paintOrder:null,panose1:null,path:null,pathLength:DH,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:OH,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:DH,pointsAtY:DH,pointsAtZ:DH,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:PH,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:PH,rev:PH,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:PH,requiredFeatures:PH,requiredFonts:PH,requiredFormats:PH,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:DH,specularExponent:DH,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:DH,strikethroughThickness:DH,string:null,stroke:null,strokeDashArray:PH,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:DH,strokeOpacity:DH,strokeWidth:null,style:null,surfaceScale:DH,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:PH,tabIndex:DH,tableValues:null,target:null,targetX:DH,targetY:DH,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:PH,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:DH,underlineThickness:DH,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:DH,values:null,vAlphabetic:DH,vMathematical:DH,vectorEffect:null,vHanging:DH,vIdeographic:DH,version:null,vertAdvY:DH,vertOriginX:DH,vertOriginY:DH,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:DH,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null}}),ZH=/^data[-\w.:]+$/i,QH=/-[a-z]/g,eW=/[A-Z]/g;function tW(e){return"-"+e.toLowerCase()}function nW(e){return e.charAt(1).toUpperCase()}const rW={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"},oW=EH([WH,HH,YH,KH,JH],"html"),sW=EH([WH,HH,YH,KH,XH],"svg");const iW=Pl(Ll()),aW=iW.default||iW,lW=dW("end"),cW=dW("start");function dW(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 uW(e){return e&&"object"==typeof e?"position"in e||"type"in e?fW(e.position):"start"in e||"end"in e?fW(e):"line"in e||"column"in e?hW(e):"":""}function hW(e){return mW(e&&e.line)+":"+mW(e&&e.column)}function fW(e){return hW(e&&e.start)+"-"+hW(e&&e.end)}function mW(e){return e&&"number"==typeof e?e:1}class pW extends Error{constructor(e,t,n){super(),"string"==typeof t&&(n=t,t=void 0);let r="",o={},s=!1;if(t&&(o="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?r=e:!o.cause&&e&&(s=!0,r=e.message,o.cause=e),!o.ruleId&&!o.source&&"string"==typeof n){const e=n.indexOf(":");-1===e?o.ruleId=n:(o.source=n.slice(0,e),o.ruleId=n.slice(e+1))}if(!o.place&&o.ancestors&&o.ancestors){const e=o.ancestors[o.ancestors.length-1];e&&(o.place=e.position)}const i=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=i?i.column:void 0,this.fatal=void 0,this.file,this.message=r,this.line=i?i.line:void 0,this.name=uW(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=s&&o.cause&&"string"==typeof o.cause.stack?o.cause.stack:"",this.actual,this.expected,this.note,this.url}}pW.prototype.file="",pW.prototype.name="",pW.prototype.reason="",pW.prototype.message="",pW.prototype.stack="",pW.prototype.column=void 0,pW.prototype.line=void 0,pW.prototype.ancestors=void 0,pW.prototype.cause=void 0,pW.prototype.fatal=void 0,pW.prototype.place=void 0,pW.prototype.ruleId=void 0,pW.prototype.source=void 0;const gW={}.hasOwnProperty,yW=new Map,bW=/[A-Z]/g,xW=/-([a-z])/g,vW=new Set(["table","tbody","thead","tfoot","tr"]),wW=new Set(["td","th"]),kW="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function SW(e,t){if(!t||void 0===t.Fragment)throw new TypeError("Expected `Fragment` in options");const n=t.filePath||void 0;let r;if(t.development){if("function"!=typeof t.jsxDEV)throw new TypeError("Expected `jsxDEV` in options when `development: true`");r=function(e,t){return n;function n(n,r,o,s){const i=Array.isArray(o.children),a=cW(n);return t(r,o,s,i,{columnNumber:a?a.column-1:void 0,fileName:e,lineNumber:a?a.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");r=function(e,t,n){return r;function r(e,r,o,s){const i=Array.isArray(o.children)?n:t;return s?i(r,o,s):i(r,o)}}(0,t.jsx,t.jsxs)}const o={Fragment:t.Fragment,ancestors:[],components:t.components||{},create:r,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?sW:oW,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:!1!==t.tableCellAlignToStyle},s=CW(o,e,void 0);return s&&"string"!=typeof s?s:o.create(e,o.Fragment,{children:s||void 0},void 0)}function CW(e,t,n){return"element"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.tagName.toLowerCase()&&"html"===r.space&&(o=sW,e.schema=o);e.ancestors.push(t);const s=IW(e,t.tagName,!1),i=function(e,t){const n={};let r,o;for(o in t.properties)if("children"!==o&&gW.call(t.properties,o)){const s=_W(e,o,t.properties[o]);if(s){const[o,i]=s;e.tableCellAlignToStyle&&"align"===o&&"string"==typeof i&&wW.has(t.tagName)?r=i:n[o]=i}}if(r){(n.style||(n.style={}))["css"===e.stylePropertyNameCase?"text-align":"textAlign"]=r}return n}(e,t);let a=jW(e,t);vW.has(t.tagName)&&(a=a.filter((function(e){return"string"!=typeof e||!("object"==typeof(t=e)?"text"===t.type&&CH(t.value):CH(t));var t})));return NW(e,i,s,t),EW(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,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)}AW(e,t.position)}(e,t):"mdxJsxFlowElement"===t.type||"mdxJsxTextElement"===t.type?function(e,t,n){const r=e.schema;let o=r;"svg"===t.name&&"html"===r.space&&(o=sW,e.schema=o);e.ancestors.push(t);const s=null===t.name?e.Fragment:IW(e,t.name,!0),i=function(e,t){const n={};for(const r of t.attributes)if("mdxJsxExpressionAttribute"===r.type)if(r.data&&r.data.estree&&e.evaluater){const t=r.data.estree.body[0];t.type;const o=t.expression;o.type;const s=o.properties[0];s.type,Object.assign(n,e.evaluater.evaluateExpression(s.argument))}else AW(e,t.position);else{const o=r.name;let s;if(r.value&&"object"==typeof r.value)if(r.value.data&&r.value.data.estree&&e.evaluater){const t=r.value.data.estree.body[0];t.type,s=e.evaluater.evaluateExpression(t.expression)}else AW(e,t.position);else s=null===r.value||r.value;n[o]=s}return n}(e,t),a=jW(e,t);return NW(e,i,s,t),EW(i,a),e.ancestors.pop(),e.schema=r,e.create(t,s,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);AW(e,t.position)}(e,t):"root"===t.type?function(e,t,n){const r={};return EW(r,jW(e,t)),e.create(t,e.Fragment,r,n)}(e,t,n):"text"===t.type?function(e,t){return t.value}(0,t):void 0}function NW(e,t,n,r){"string"!=typeof n&&n!==e.Fragment&&e.passNode&&(t.node=r)}function EW(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function jW(e,t){const n=[];let r=-1;const o=e.passKeys?new Map:yW;for(;++r<t.children.length;){const s=t.children[r];let i;if(e.passKeys){const e="element"===s.type?s.tagName:"mdxJsxFlowElement"===s.type||"mdxJsxTextElement"===s.type?s.name:void 0;if(e){const t=o.get(e)||0;i=e+"-"+t,o.set(e,t+1)}}const a=CW(e,s,i);void 0!==a&&n.push(a)}return n}function _W(e,t,n){const r=function(e,t){const n=jH(t);let r=t,o=_H;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&"data"===n.slice(0,4)&&ZH.test(t)){if("-"===t.charAt(4)){const e=t.slice(5).replace(QH,nW);r="data"+e.charAt(0).toUpperCase()+e.slice(1)}else{const e=t.slice(4);if(!QH.test(e)){let n=e.replace(eW,tW);"-"!==n.charAt(0)&&(n="-"+n),t="data"+n}}o=BH}return new o(r,t)}(e.schema,t);if(!(null==n||"number"==typeof n&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?function(e){const t={};return(""===e[e.length-1]?[...e,""]:e).join((t.padRight?" ":"")+","+(!1===t.padLeft?"":" ")).trim()}(n):n.join(" ").trim()),"style"===r.property){let t="object"==typeof n?n:function(e,t){const n={};try{aW(t,r)}catch(o){if(!e.ignoreInvalidStyle){const t=o,n=new pW("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=kW+"#cannot-parse-style-attribute",n}}return n;function r(e,t){let r=e;"--"!==r.slice(0,2)&&("-ms-"===r.slice(0,4)&&(r="ms-"+r.slice(4)),r=r.replace(xW,MW)),n[r]=t}}(e,String(n));return"css"===e.stylePropertyNameCase&&(t=function(e){const t={};let n;for(n in e)gW.call(e,n)&&(t[TW(n)]=e[n]);return t}(t)),["style",t]}return["react"===e.elementAttributeNameCase&&r.space?rW[r.property]||r.property:r.attribute,n]}}function IW(e,t,n){let r;if(n)if(t.includes(".")){const e=t.split(".");let n,o=-1;for(;++o<e.length;){const t=kH(e[o])?{type:"Identifier",name:e[o]}:{type:"Literal",value:e[o]};n=n?{type:"MemberExpression",object:n,property:t,computed:Boolean(o&&"Literal"===t.type),optional:!1}:t}r=n}else r=kH(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};else r={type:"Literal",value:t};if("Literal"===r.type){const t=r.value;return gW.call(e.components,t)?e.components[t]:t}if(e.evaluater)return e.evaluater.evaluateExpression(r);AW(e)}function AW(e,t){const n=new pW("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=kW+"#cannot-handle-mdx-estrees-without-createevaluater",n}function TW(e){let t=e.replace(bW,DW);return"ms-"===t.slice(0,3)&&(t="-"+t),t}function MW(e,t){return t.toUpperCase()}function DW(e){return"-"+e.toLowerCase()}const OW={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"]},RW={};function PW(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 LW(e.children,t,n)}return Array.isArray(e)?LW(e,t,n):""}function LW(e,t,n){const r=[];let o=-1;for(;++o<e.length;)r[o]=PW(e[o],t,n);return r.join("")}const FW=document.createElement("i");function zW(e){const t="&"+e+";";FW.innerHTML=t;const n=FW.textContent;return(59!==n.charCodeAt(n.length-1)||"semi"===e)&&(n!==t&&n)}function BW(e,t,n,r){const o=e.length;let s,i=0;if(t=t<0?-t>o?0:o+t:t>o?o:t,n=n>0?n:0,r.length<1e4)s=Array.from(r),s.unshift(t,n),e.splice(...s);else for(n&&e.splice(t,n);i<r.length;)s=r.slice(i,i+1e4),s.unshift(t,0),e.splice(...s),i+=1e4,t+=1e4}function UW(e,t){return e.length>0?(BW(e,e.length,0,t),e):t}const $W={}.hasOwnProperty;function VW(e,t){let n;for(n in t){const r=($W.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let s;if(o)for(s in o){$W.call(r,s)||(r[s]=[]);const e=o[s];HW(r[s],Array.isArray(e)?e:e?[e]:[])}}}function HW(e,t){let n=-1;const r=[];for(;++n<t.length;)("after"===t[n].add?e:r).push(t[n]);BW(e,0,0,r)}function WW(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 GW(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const qW=sG(/[A-Za-z]/),YW=sG(/[\dA-Za-z]/),KW=sG(/[#-'*+\--9=?A-Z^-~]/);function JW(e){return null!==e&&(e<32||127===e)}const XW=sG(/\d/),ZW=sG(/[\dA-Fa-f]/),QW=sG(/[!-/:-@[-`{-~]/);function eG(e){return null!==e&&e<-2}function tG(e){return null!==e&&(e<0||32===e)}function nG(e){return-2===e||-1===e||32===e}const rG=sG(new RegExp("\\p{P}|\\p{S}","u")),oG=sG(/\s/);function sG(e){return function(t){return null!==t&&t>-1&&e.test(String.fromCharCode(t))}}function iG(e){const t=[];let n=-1,r=0,o=0;for(;++n<e.length;){const s=e.charCodeAt(n);let i="";if(37===s&&YW(e.charCodeAt(n+1))&&YW(e.charCodeAt(n+2)))o=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(i=String.fromCharCode(s));else if(s>55295&&s<57344){const t=e.charCodeAt(n+1);s<56320&&t>56319&&t<57344?(i=String.fromCharCode(s,t),o=1):i="�"}else i=String.fromCharCode(s);i&&(t.push(e.slice(r,n),encodeURIComponent(i)),r=n+o+1,i=""),o&&(n+=o,o=0)}return t.join("")+e.slice(r)}function aG(e,t,n,r){const o=r?r-1:Number.POSITIVE_INFINITY;let s=0;return function(r){if(nG(r))return e.enter(n),i(r);return t(r)};function i(r){return nG(r)&&s++<o?(e.consume(r),i):(e.exit(n),t(r))}}const lG={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"),aG(e,t,"linePrefix")}),(function(t){return e.enter("paragraph"),r(t)}));let n;return t;function r(t){const r=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=r),n=r,o(t)}function o(t){return null===t?(e.exit("chunkText"),e.exit("paragraph"),void e.consume(t)):eG(t)?(e.consume(t),e.exit("chunkText"),r):(e.consume(t),o)}}};const cG={tokenize:function(e){const t=this,n=[];let r,o,s,i=0;return a;function a(r){if(i<n.length){const o=n[i];return t.containerState=o[1],e.attempt(o[0].continuation,l,c)(r)}return c(r)}function l(e){if(i++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,r&&b();const n=t.events.length;let o,s=n;for(;s--;)if("exit"===t.events[s][0]&&"chunkFlow"===t.events[s][1].type){o=t.events[s][1].end;break}y(i);let a=n;for(;a<t.events.length;)t.events[a][1].end={...o},a++;return BW(t.events,s+1,0,t.events.slice(n)),t.events.length=a,c(e)}return a(e)}function c(o){if(i===n.length){if(!r)return h(o);if(r.currentConstruct&&r.currentConstruct.concrete)return m(o);t.interrupt=Boolean(r.currentConstruct&&!r._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(dG,d,u)(o)}function d(e){return r&&b(),y(i),h(e)}function u(e){return t.parser.lazy[t.now().line]=i!==n.length,s=t.now().offset,m(e)}function h(n){return t.containerState={},e.attempt(dG,f,m)(n)}function f(e){return i++,n.push([t.currentConstruct,t.containerState]),h(e)}function m(n){return null===n?(r&&b(),y(0),void e.consume(n)):(r=r||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:r,contentType:"flow",previous:o}),p(n))}function p(n){return null===n?(g(e.exit("chunkFlow"),!0),y(0),void e.consume(n)):eG(n)?(e.consume(n),g(e.exit("chunkFlow")),i=0,t.interrupt=void 0,a):(e.consume(n),p)}function g(e,n){const a=t.sliceStream(e);if(n&&a.push(null),e.previous=o,o&&(o.next=e),o=e,r.defineSkip(e.start),r.write(a),t.parser.lazy[e.start.line]){let e=r.events.length;for(;e--;)if(r.events[e][1].start.offset<s&&(!r.events[e][1].end||r.events[e][1].end.offset>s))return;const n=t.events.length;let o,a,l=n;for(;l--;)if("exit"===t.events[l][0]&&"chunkFlow"===t.events[l][1].type){if(o){a=t.events[l][1].end;break}o=!0}for(y(i),e=n;e<t.events.length;)t.events[e][1].end={...a},e++;BW(t.events,l+1,0,t.events.slice(n)),t.events.length=e}}function y(r){let o=n.length;for(;o-- >r;){const r=n[o];t.containerState=r[1],r[0].exit.call(t,e)}n.length=r}function b(){r.write([null]),o=void 0,r=void 0,t.containerState._closeFlow=void 0}}},dG={tokenize:function(e,t,n){return aG(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function uG(e){return null===e||tG(e)||oG(e)?1:rG(e)?2:void 0}function hG(e,t,n){const r=[];let o=-1;for(;++o<e.length;){const s=e[o].resolveAll;s&&!r.includes(s)&&(t=s(t,n),r.push(s))}return t}const fG={name:"attention",resolveAll:function(e,t){let n,r,o,s,i,a,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;a=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};mG(u,-a),mG(h,a),s={type:a>1?"strongSequence":"emphasisSequence",start:u,end:{...e[n][1].end}},i={type:a>1?"strongSequence":"emphasisSequence",start:{...e[d][1].start},end:h},o={type:a>1?"strongText":"emphasisText",start:{...e[n][1].end},end:{...e[d][1].start}},r={type:a>1?"strong":"emphasis",start:{...s.start},end:{...i.end}},e[n][1].end={...s.start},e[d][1].start={...i.end},l=[],e[n][1].end.offset-e[n][1].start.offset&&(l=UW(l,[["enter",e[n][1],t],["exit",e[n][1],t]])),l=UW(l,[["enter",r,t],["enter",s,t],["exit",s,t],["enter",o,t]]),l=UW(l,hG(t.parser.constructs.insideSpan.null,e.slice(n+1,d),t)),l=UW(l,[["exit",o,t],["enter",i,t],["exit",i,t],["exit",r,t]]),e[d][1].end.offset-e[d][1].start.offset?(c=2,l=UW(l,[["enter",e[d][1],t],["exit",e[d][1],t]])):c=0,BW(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,r=this.previous,o=uG(r);let s;return function(t){return s=t,e.enter("attentionSequence"),i(t)};function i(a){if(a===s)return e.consume(a),i;const l=e.exit("attentionSequence"),c=uG(a),d=!c||2===c&&o||n.includes(a),u=!o||2===o&&c||n.includes(r);return l._open=Boolean(42===s?d:d&&(o||!u)),l._close=Boolean(42===s?u:u&&(c||!d)),t(a)}}};function mG(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const pG={name:"autolink",tokenize:function(e,t,n){let r=0;return function(t){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(t),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o};function o(t){return qW(t)?(e.consume(t),s):64===t?n(t):l(t)}function s(e){return 43===e||45===e||46===e||YW(e)?(r=1,i(e)):l(e)}function i(t){return 58===t?(e.consume(t),r=0,a):(43===t||45===t||46===t||YW(t))&&r++<32?(e.consume(t),i):(r=0,l(t))}function a(r){return 62===r?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(r),e.exit("autolinkMarker"),e.exit("autolink"),t):null===r||32===r||60===r||JW(r)?n(r):(e.consume(r),a)}function l(t){return 64===t?(e.consume(t),c):KW(t)?(e.consume(t),l):n(t)}function c(e){return YW(e)?d(e):n(e)}function d(n){return 46===n?(e.consume(n),r=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||YW(t))&&r++<63){const n=45===t?u:d;return e.consume(t),n}return n(t)}}};const gG={partial:!0,tokenize:function(e,t,n){return function(t){return nG(t)?aG(e,r,"linePrefix")(t):r(t)};function r(e){return null===e||eG(e)?t(e):n(e)}}};const yG={continuation:{tokenize:function(e,t,n){const r=this;return function(t){if(nG(t))return aG(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t);return o(t)};function o(r){return e.attempt(yG,t,n)(r)}}},exit:function(e){e.exit("blockQuote")},name:"blockQuote",tokenize:function(e,t,n){const r=this;return function(t){if(62===t){const n=r.containerState;return n.open||(e.enter("blockQuote",{_container:!0}),n.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(t),e.exit("blockQuoteMarker"),o}return n(t)};function o(n){return nG(n)?(e.enter("blockQuotePrefixWhitespace"),e.consume(n),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(n))}}};const bG={name:"characterEscape",tokenize:function(e,t,n){return function(t){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(t),e.exit("escapeMarker"),r};function r(r){return QW(r)?(e.enter("characterEscapeValue"),e.consume(r),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(r)}}};const xG={name:"characterReference",tokenize:function(e,t,n){const r=this;let o,s,i=0;return function(t){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(t),e.exit("characterReferenceMarker"),a};function a(t){return 35===t?(e.enter("characterReferenceMarkerNumeric"),e.consume(t),e.exit("characterReferenceMarkerNumeric"),l):(e.enter("characterReferenceValue"),o=31,s=YW,c(t))}function l(t){return 88===t||120===t?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(t),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,s=ZW,c):(e.enter("characterReferenceValue"),o=7,s=XW,c(t))}function c(a){if(59===a&&i){const o=e.exit("characterReferenceValue");return s!==YW||zW(r.sliceSerialize(o))?(e.enter("characterReferenceMarker"),e.consume(a),e.exit("characterReferenceMarker"),e.exit("characterReference"),t):n(a)}return s(a)&&i++<o?(e.consume(a),c):n(a)}}};const vG={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(null===t)return n(t);return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}},wG={concrete:!0,name:"codeFenced",tokenize:function(e,t,n){const r=this,o={partial:!0,tokenize:function(e,t,n){let o=0;return i;function i(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),l}function l(t){return e.enter("codeFencedFence"),nG(t)?aG(e,c,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):c(t)}function c(t){return t===s?(e.enter("codeFencedFenceSequence"),d(t)):n(t)}function d(t){return t===s?(o++,e.consume(t),d):o>=a?(e.exit("codeFencedFenceSequence"),nG(t)?aG(e,u,"whitespace")(t):u(t)):n(t)}function u(r){return null===r||eG(r)?(e.exit("codeFencedFence"),t(r)):n(r)}}};let s,i=0,a=0;return function(t){return function(t){const n=r.events[r.events.length-1];return i=n&&"linePrefix"===n[1].type?n[2].sliceSerialize(n[1],!0).length:0,s=t,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),l(t)}(t)};function l(t){return t===s?(a++,e.consume(t),l):a<3?n(t):(e.exit("codeFencedFenceSequence"),nG(t)?aG(e,c,"whitespace")(t):c(t))}function c(n){return null===n||eG(n)?(e.exit("codeFencedFence"),r.interrupt?t(n):e.check(vG,f,b)(n)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(n))}function d(t){return null===t||eG(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(t)):nG(t)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),aG(e,u,"whitespace")(t)):96===t&&t===s?n(t):(e.consume(t),d)}function u(t){return null===t||eG(t)?c(t):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),h(t))}function h(t){return null===t||eG(t)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(t)):96===t&&t===s?n(t):(e.consume(t),h)}function f(t){return e.attempt(o,b,m)(t)}function m(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),p}function p(t){return i>0&&nG(t)?aG(e,g,"linePrefix",i+1)(t):g(t)}function g(t){return null===t||eG(t)?e.check(vG,f,b)(t):(e.enter("codeFlowValue"),y(t))}function y(t){return null===t||eG(t)?(e.exit("codeFlowValue"),g(t)):(e.consume(t),y)}function b(n){return e.exit("codeFenced"),t(n)}}};const kG={name:"codeIndented",tokenize:function(e,t,n){const r=this;return function(t){return e.enter("codeIndented"),aG(e,o,"linePrefix",5)(t)};function o(e){const t=r.events[r.events.length-1];return t&&"linePrefix"===t[1].type&&t[2].sliceSerialize(t[1],!0).length>=4?s(e):n(e)}function s(t){return null===t?a(t):eG(t)?e.attempt(SG,s,a)(t):(e.enter("codeFlowValue"),i(t))}function i(t){return null===t||eG(t)?(e.exit("codeFlowValue"),s(t)):(e.consume(t),i)}function a(n){return e.exit("codeIndented"),t(n)}}},SG={partial:!0,tokenize:function(e,t,n){const r=this;return o;function o(t){return r.parser.lazy[r.now().line]?n(t):eG(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o):aG(e,s,"linePrefix",5)(t)}function s(e){const s=r.events[r.events.length-1];return s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(e):eG(e)?o(e):n(e)}}};const CG={name:"codeText",previous:function(e){return 96!==e||"characterEscape"===this.events[this.events.length-1][1].type},resolve:function(e){let t,n,r=e.length-4,o=3;if(!("lineEnding"!==e[o][1].type&&"space"!==e[o][1].type||"lineEnding"!==e[r][1].type&&"space"!==e[r][1].type))for(t=o;++t<r;)if("codeTextData"===e[t][1].type){e[o][1].type="codeTextPadding",e[r][1].type="codeTextPadding",o+=2,r-=2;break}t=o-1,r++;for(;++t<=r;)void 0===n?t!==r&&"lineEnding"!==e[t][1].type&&(n=t):t!==r&&"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),r-=t-n-2,t=n+2),n=void 0);return e},tokenize:function(e,t,n){let r,o,s=0;return function(t){return e.enter("codeText"),e.enter("codeTextSequence"),i(t)};function i(t){return 96===t?(e.consume(t),s++,i):(e.exit("codeTextSequence"),a(t))}function a(t){return null===t?n(t):32===t?(e.enter("space"),e.consume(t),e.exit("space"),a):96===t?(o=e.enter("codeTextSequence"),r=0,c(t)):eG(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),a):(e.enter("codeTextData"),l(t))}function l(t){return null===t||32===t||96===t||eG(t)?(e.exit("codeTextData"),a(t)):(e.consume(t),l)}function c(n){return 96===n?(e.consume(n),r++,c):r===s?(e.exit("codeTextSequence"),e.exit("codeText"),t(n)):(o.type="codeTextData",l(n))}}};class NG{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 r=t||0;this.setCursor(Math.trunc(e));const o=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return n&&EG(this.left,n),o.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),EG(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),EG(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);EG(this.right,t.reverse())}else{const t=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);EG(this.left,t.reverse())}}}function EG(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 jG(e){const t={};let n,r,o,s,i,a,l,c=-1;const d=new NG(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&&(a=n[1]._tokenizer.events,o=0,o<a.length&&"lineEndingBlank"===a[o][1].type&&(o+=2),o<a.length&&"content"===a[o][1].type))for(;++o<a.length&&"content"!==a[o][1].type;)"chunkText"===a[o][1].type&&(a[o][1]._isInFirstContentOfListItem=!0,o++);if("enter"===n[0])n[1].contentType&&(Object.assign(t,_G(d,c)),c=t[c],l=!0);else if(n[1]._container){for(o=c,r=void 0;o--&&(s=d.get(o),"lineEnding"===s[1].type||"lineEndingBlank"===s[1].type);)"enter"===s[0]&&(r&&(d.get(r)[1].type="lineEndingBlank"),s[1].type="lineEnding",r=o);r&&(n[1].end={...d.get(r)[1].start},i=d.slice(r,c),i.unshift(n),d.splice(r,c-r+1,i))}}return BW(e,0,Number.POSITIVE_INFINITY,d.slice(0)),!l}function _G(e,t){const n=e.get(t)[1],r=e.get(t)[2];let o=t-1;const s=[],i=n._tokenizer||r.parser[n.contentType](n.start),a=i.events,l=[],c={};let d,u,h=-1,f=n,m=0,p=0;const g=[p];for(;f;){for(;e.get(++o)[1]!==f;);s.push(o),f._tokenizer||(d=r.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<a.length;)"exit"===a[h][0]&&"enter"===a[h-1][0]&&a[h][1].type===a[h-1][1].type&&a[h][1].start.line!==a[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=a.slice(g[h],g[h+1]),n=s.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 IG={resolve:function(e){return jG(e),e},tokenize:function(e,t){let n;return function(t){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),r(t)};function r(t){return null===t?o(t):eG(t)?e.check(AG,s,o)(t):(e.consume(t),r)}function o(n){return e.exit("chunkContent"),e.exit("content"),t(n)}function s(t){return e.consume(t),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,r}}},AG={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),aG(e,o,"linePrefix")};function o(o){if(null===o||eG(o))return n(o);const s=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&s&&"linePrefix"===s[1].type&&s[2].sliceSerialize(s[1],!0).length>=4?t(o):e.interrupt(r.parser.constructs.flow,n,t)(o)}}};function TG(e,t,n,r,o,s,i,a,l){const c=l||Number.POSITIVE_INFINITY;let d=0;return function(t){if(60===t)return e.enter(r),e.enter(o),e.enter(s),e.consume(t),e.exit(s),u;if(null===t||32===t||41===t||JW(t))return n(t);return e.enter(r),e.enter(i),e.enter(a),e.enter("chunkString",{contentType:"string"}),m(t)};function u(n){return 62===n?(e.enter(s),e.consume(n),e.exit(s),e.exit(o),e.exit(r),t):(e.enter(a),e.enter("chunkString",{contentType:"string"}),h(n))}function h(t){return 62===t?(e.exit("chunkString"),e.exit(a),u(t)):null===t||60===t||eG(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(o){return d||null!==o&&41!==o&&!tG(o)?d<c&&40===o?(e.consume(o),d++,m):41===o?(e.consume(o),d--,m):null===o||32===o||40===o||JW(o)?n(o):(e.consume(o),92===o?p:m):(e.exit("chunkString"),e.exit(a),e.exit(i),e.exit(r),t(o))}function p(t){return 40===t||41===t||92===t?(e.consume(t),m):m(t)}}function MG(e,t,n,r,o,s){const i=this;let a,l=0;return function(t){return e.enter(r),e.enter(o),e.consume(t),e.exit(o),e.enter(s),c};function c(u){return l>999||null===u||91===u||93===u&&!a||94===u&&!l&&"_hiddenFootnoteSupport"in i.parser.constructs?n(u):93===u?(e.exit(s),e.enter(o),e.consume(u),e.exit(o),e.exit(r),t):eG(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||eG(t)||l++>999?(e.exit("chunkString"),c(t)):(e.consume(t),a||(a=!nG(t)),92===t?u:d)}function u(t){return 91===t||92===t||93===t?(e.consume(t),l++,d):d(t)}}function DG(e,t,n,r,o,s){let i;return function(t){if(34===t||39===t||40===t)return e.enter(r),e.enter(o),e.consume(t),e.exit(o),i=40===t?41:t,a;return n(t)};function a(n){return n===i?(e.enter(o),e.consume(n),e.exit(o),e.exit(r),t):(e.enter(s),l(n))}function l(t){return t===i?(e.exit(s),a(i)):null===t?n(t):eG(t)?(e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),aG(e,l,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),c(t))}function c(t){return t===i||null===t||eG(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 OG(e,t){let n;return function r(o){if(eG(o))return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),n=!0,r;if(nG(o))return aG(e,r,n?"linePrefix":"lineSuffix")(o);return t(o)}}const RG={name:"definition",tokenize:function(e,t,n){const r=this;let o;return function(t){return e.enter("definition"),function(t){return MG.call(r,e,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(t)}(t)};function s(t){return o=GW(r.sliceSerialize(r.events[r.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 tG(t)?OG(e,a)(t):a(t)}function a(t){return TG(e,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(t)}function l(t){return e.attempt(PG,c,c)(t)}function c(t){return nG(t)?aG(e,d,"whitespace")(t):d(t)}function d(s){return null===s||eG(s)?(e.exit("definition"),r.parser.defined.push(o),t(s)):n(s)}}},PG={partial:!0,tokenize:function(e,t,n){return function(t){return tG(t)?OG(e,r)(t):n(t)};function r(t){return DG(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(t)}function o(t){return nG(t)?aG(e,s,"whitespace")(t):s(t)}function s(e){return null===e||eG(e)?t(e):n(e)}}};const LG={name:"hardBreakEscape",tokenize:function(e,t,n){return function(t){return e.enter("hardBreakEscape"),e.consume(t),r};function r(r){return eG(r)?(e.exit("hardBreakEscape"),t(r)):n(r)}}};const FG={name:"headingAtx",resolve:function(e,t){let n,r,o=e.length-2,s=3;"whitespace"===e[s][1].type&&(s+=2);o-2>s&&"whitespace"===e[o][1].type&&(o-=2);"atxHeadingSequence"===e[o][1].type&&(s===o-1||o-4>s&&"whitespace"===e[o-2][1].type)&&(o-=s+1===o?2:4);o>s&&(n={type:"atxHeadingText",start:e[s][1].start,end:e[o][1].end},r={type:"chunkText",start:e[s][1].start,end:e[o][1].end,contentType:"text"},BW(e,s,o-s+1,[["enter",n,t],["enter",r,t],["exit",r,t],["exit",n,t]]));return e},tokenize:function(e,t,n){let r=0;return function(t){return e.enter("atxHeading"),function(t){return e.enter("atxHeadingSequence"),o(t)}(t)};function o(t){return 35===t&&r++<6?(e.consume(t),o):null===t||tG(t)?(e.exit("atxHeadingSequence"),s(t)):n(t)}function s(n){return 35===n?(e.enter("atxHeadingSequence"),i(n)):null===n||eG(n)?(e.exit("atxHeading"),t(n)):nG(n)?aG(e,s,"whitespace")(n):(e.enter("atxHeadingText"),a(n))}function i(t){return 35===t?(e.consume(t),i):(e.exit("atxHeadingSequence"),s(t))}function a(t){return null===t||35===t||tG(t)?(e.exit("atxHeadingText"),s(t)):(e.consume(t),a)}}};const zG=["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"],BG=["pre","script","style","textarea"],UG={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 r=this;let o,s,i,a,l;return function(t){return function(t){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(t),c}(t)};function c(a){return 33===a?(e.consume(a),d):47===a?(e.consume(a),s=!0,f):63===a?(e.consume(a),o=3,r.interrupt?t:O):qW(a)?(e.consume(a),i=String.fromCharCode(a),m):n(a)}function d(s){return 45===s?(e.consume(s),o=2,u):91===s?(e.consume(s),o=5,a=0,h):qW(s)?(e.consume(s),o=4,r.interrupt?t:O):n(s)}function u(o){return 45===o?(e.consume(o),r.interrupt?t:O):n(o)}function h(o){const s="CDATA[";return o===s.charCodeAt(a++)?(e.consume(o),6===a?r.interrupt?t:E:h):n(o)}function f(t){return qW(t)?(e.consume(t),i=String.fromCharCode(t),m):n(t)}function m(a){if(null===a||47===a||62===a||tG(a)){const l=47===a,c=i.toLowerCase();return l||s||!BG.includes(c)?zG.includes(i.toLowerCase())?(o=6,l?(e.consume(a),p):r.interrupt?t(a):E(a)):(o=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(a):s?g(a):y(a)):(o=1,r.interrupt?t(a):E(a))}return 45===a||YW(a)?(e.consume(a),i+=String.fromCharCode(a),m):n(a)}function p(o){return 62===o?(e.consume(o),r.interrupt?t:E):n(o)}function g(t){return nG(t)?(e.consume(t),g):C(t)}function y(t){return 47===t?(e.consume(t),C):58===t||95===t||qW(t)?(e.consume(t),b):nG(t)?(e.consume(t),y):C(t)}function b(t){return 45===t||46===t||58===t||95===t||YW(t)?(e.consume(t),b):x(t)}function x(t){return 61===t?(e.consume(t),v):nG(t)?(e.consume(t),x):y(t)}function v(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),l=t,w):nG(t)?(e.consume(t),v):k(t)}function w(t){return t===l?(e.consume(t),l=null,S):null===t||eG(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||tG(t)?x(t):(e.consume(t),k)}function S(e){return 47===e||62===e||nG(e)?y(e):n(e)}function C(t){return 62===t?(e.consume(t),N):n(t)}function N(t){return null===t||eG(t)?E(t):nG(t)?(e.consume(t),N):n(t)}function E(t){return 45===t&&2===o?(e.consume(t),A):60===t&&1===o?(e.consume(t),T):62===t&&4===o?(e.consume(t),R):63===t&&3===o?(e.consume(t),O):93===t&&5===o?(e.consume(t),D):!eG(t)||6!==o&&7!==o?null===t||eG(t)?(e.exit("htmlFlowData"),j(t)):(e.consume(t),E):(e.exit("htmlFlowData"),e.check($G,P,j)(t))}function j(t){return e.check(VG,_,P)(t)}function _(t){return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),I}function I(t){return null===t||eG(t)?j(t):(e.enter("htmlFlowData"),E(t))}function A(t){return 45===t?(e.consume(t),O):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 BG.includes(n)?(e.consume(t),R):E(t)}return qW(t)&&i.length<8?(e.consume(t),i+=String.fromCharCode(t),M):E(t)}function D(t){return 93===t?(e.consume(t),O):E(t)}function O(t){return 62===t?(e.consume(t),R):45===t&&2===o?(e.consume(t),O):E(t)}function R(t){return null===t||eG(t)?(e.exit("htmlFlowData"),P(t)):(e.consume(t),R)}function P(n){return e.exit("htmlFlow"),t(n)}}},$G={partial:!0,tokenize:function(e,t,n){return function(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),e.attempt(gG,t,n)}}},VG={partial:!0,tokenize:function(e,t,n){const r=this;return function(t){if(eG(t))return e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),o;return n(t)};function o(e){return r.parser.lazy[r.now().line]?n(e):t(e)}}};const HG={name:"htmlText",tokenize:function(e,t,n){const r=this;let o,s,i;return function(t){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(t),a};function a(t){return 33===t?(e.consume(t),l):47===t?(e.consume(t),v):63===t?(e.consume(t),b):qW(t)?(e.consume(t),S):n(t)}function l(t){return 45===t?(e.consume(t),c):91===t?(e.consume(t),s=0,f):qW(t)?(e.consume(t),y):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):eG(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 r="CDATA[";return t===r.charCodeAt(s++)?(e.consume(t),6===s?m:f):n(t)}function m(t){return null===t?n(t):93===t?(e.consume(t),p):eG(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 y(t){return null===t||62===t?T(t):eG(t)?(i=y,M(t)):(e.consume(t),y)}function b(t){return null===t?n(t):63===t?(e.consume(t),x):eG(t)?(i=b,M(t)):(e.consume(t),b)}function x(e){return 62===e?T(e):b(e)}function v(t){return qW(t)?(e.consume(t),w):n(t)}function w(t){return 45===t||YW(t)?(e.consume(t),w):k(t)}function k(t){return eG(t)?(i=k,M(t)):nG(t)?(e.consume(t),k):T(t)}function S(t){return 45===t||YW(t)?(e.consume(t),S):47===t||62===t||tG(t)?C(t):n(t)}function C(t){return 47===t?(e.consume(t),T):58===t||95===t||qW(t)?(e.consume(t),N):eG(t)?(i=C,M(t)):nG(t)?(e.consume(t),C):T(t)}function N(t){return 45===t||46===t||58===t||95===t||YW(t)?(e.consume(t),N):E(t)}function E(t){return 61===t?(e.consume(t),j):eG(t)?(i=E,M(t)):nG(t)?(e.consume(t),E):C(t)}function j(t){return null===t||60===t||61===t||62===t||96===t?n(t):34===t||39===t?(e.consume(t),o=t,_):eG(t)?(i=j,M(t)):nG(t)?(e.consume(t),j):(e.consume(t),I)}function _(t){return t===o?(e.consume(t),o=void 0,A):null===t?n(t):eG(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||tG(t)?C(t):(e.consume(t),I)}function A(e){return 47===e||62===e||tG(e)?C(e):n(e)}function T(r){return 62===r?(e.consume(r),e.exit("htmlTextData"),e.exit("htmlText"),t):n(r)}function M(t){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(t),e.exit("lineEnding"),D}function D(t){return nG(t)?aG(e,O,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(t):O(t)}function O(t){return e.enter("htmlTextData"),i(t)}}};const WG={name:"labelEnd",resolveAll:function(e){let t=-1;const n=[];for(;++t<e.length;){const r=e[t][1];if(n.push(e[t]),"labelImage"===r.type||"labelLink"===r.type||"labelEnd"===r.type){const e="labelImage"===r.type?4:2;r.type="data",t+=e}}e.length!==n.length&&BW(e,0,e.length,n);return e},resolveTo:function(e,t){let n,r,o,s,i=e.length,a=0;for(;i--;)if(n=e[i][1],r){if("link"===n.type||"labelLink"===n.type&&n._inactive)break;"enter"===e[i][0]&&"labelLink"===n.type&&(n._inactive=!0)}else if(o){if("enter"===e[i][0]&&("labelImage"===n.type||"labelLink"===n.type)&&!n._balanced&&(r=i,"labelLink"!==n.type)){a=2;break}}else"labelEnd"===n.type&&(o=i);const l={type:"labelLink"===e[r][1].type?"link":"image",start:{...e[r][1].start},end:{...e[e.length-1][1].end}},c={type:"label",start:{...e[r][1].start},end:{...e[o][1].end}},d={type:"labelText",start:{...e[r+a+2][1].end},end:{...e[o-2][1].start}};return s=[["enter",l,t],["enter",c,t]],s=UW(s,e.slice(r+1,r+a+3)),s=UW(s,[["enter",d,t]]),s=UW(s,hG(t.parser.constructs.insideSpan.null,e.slice(r+a+4,o-3),t)),s=UW(s,[["exit",d,t],e[o-2],e[o-1],["exit",c,t]]),s=UW(s,e.slice(o+1)),s=UW(s,[["exit",l,t]]),BW(e,r,e.length,s),e},tokenize:function(e,t,n){const r=this;let o,s,i=r.events.length;for(;i--;)if(("labelImage"===r.events[i][1].type||"labelLink"===r.events[i][1].type)&&!r.events[i][1]._balanced){o=r.events[i][1];break}return function(t){if(!o)return n(t);if(o._inactive)return d(t);return s=r.parser.defined.includes(GW(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelEnd"),a};function a(t){return 40===t?e.attempt(GG,c,s?c:d)(t):91===t?e.attempt(qG,c,s?l:d)(t):s?c(t):d(t)}function l(t){return e.attempt(YG,c,d)(t)}function c(e){return t(e)}function d(e){return o._balanced=!0,n(e)}}},GG={tokenize:function(e,t,n){return function(t){return e.enter("resource"),e.enter("resourceMarker"),e.consume(t),e.exit("resourceMarker"),r};function r(t){return tG(t)?OG(e,o)(t):o(t)}function o(t){return 41===t?c(t):TG(e,s,i,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(t)}function s(t){return tG(t)?OG(e,a)(t):c(t)}function i(e){return n(e)}function a(t){return 34===t||39===t||40===t?DG(e,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(t):c(t)}function l(t){return tG(t)?OG(e,c)(t):c(t)}function c(r){return 41===r?(e.enter("resourceMarker"),e.consume(r),e.exit("resourceMarker"),e.exit("resource"),t):n(r)}}},qG={tokenize:function(e,t,n){const r=this;return function(t){return MG.call(r,e,o,s,"reference","referenceMarker","referenceString")(t)};function o(e){return r.parser.defined.includes(GW(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(e):n(e)}function s(e){return n(e)}}},YG={tokenize:function(e,t,n){return function(t){return e.enter("reference"),e.enter("referenceMarker"),e.consume(t),e.exit("referenceMarker"),r};function r(r){return 93===r?(e.enter("referenceMarker"),e.consume(r),e.exit("referenceMarker"),e.exit("reference"),t):n(r)}}};const KG={name:"labelStartImage",resolveAll:WG.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(t),e.exit("labelImageMarker"),o};function o(t){return 91===t?(e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelImage"),s):n(t)}function s(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const JG={name:"labelStartLink",resolveAll:WG.resolveAll,tokenize:function(e,t,n){const r=this;return function(t){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(t),e.exit("labelMarker"),e.exit("labelLink"),o};function o(e){return 94===e&&"_hiddenFootnoteSupport"in r.parser.constructs?n(e):t(e)}}};const XG={name:"lineEnding",tokenize:function(e,t){return function(n){return e.enter("lineEnding"),e.consume(n),e.exit("lineEnding"),aG(e,t,"linePrefix")}}};const ZG={name:"thematicBreak",tokenize:function(e,t,n){let r,o=0;return function(t){return e.enter("thematicBreak"),function(e){return r=e,s(e)}(t)};function s(s){return s===r?(e.enter("thematicBreakSequence"),i(s)):o>=3&&(null===s||eG(s))?(e.exit("thematicBreak"),t(s)):n(s)}function i(t){return t===r?(e.consume(t),o++,i):(e.exit("thematicBreakSequence"),nG(t)?aG(e,s,"whitespace")(t):s(t))}}};const QG={continuation:{tokenize:function(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(gG,(function(n){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,aG(e,t,"listItemIndent",r.containerState.size+1)(n)}),(function(n){if(r.containerState.furtherBlankLines||!nG(n))return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,o(n);return r.containerState.furtherBlankLines=void 0,r.containerState.initialBlankLine=void 0,e.attempt(tq,t,o)(n)}));function o(o){return r.containerState._closeFlow=!0,r.interrupt=void 0,aG(e,e.attempt(QG,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(o)}}},exit:function(e){e.exit(this.containerState.type)},name:"list",tokenize:function(e,t,n){const r=this,o=r.events[r.events.length-1];let s=o&&"linePrefix"===o[1].type?o[2].sliceSerialize(o[1],!0).length:0,i=0;return function(t){const o=r.containerState.type||(42===t||43===t||45===t?"listUnordered":"listOrdered");if("listUnordered"===o?!r.containerState.marker||t===r.containerState.marker:XW(t)){if(r.containerState.type||(r.containerState.type=o,e.enter(o,{_container:!0})),"listUnordered"===o)return e.enter("listItemPrefix"),42===t||45===t?e.check(ZG,n,l)(t):l(t);if(!r.interrupt||49===t)return e.enter("listItemPrefix"),e.enter("listItemValue"),a(t)}return n(t)};function a(t){return XW(t)&&++i<10?(e.consume(t),a):(!r.interrupt||i<2)&&(r.containerState.marker?t===r.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"),r.containerState.marker=r.containerState.marker||t,e.check(gG,r.interrupt?n:c,e.attempt(eq,u,d))}function c(e){return r.containerState.initialBlankLine=!0,s++,u(e)}function d(t){return nG(t)?(e.enter("listItemPrefixWhitespace"),e.consume(t),e.exit("listItemPrefixWhitespace"),u):n(t)}function u(n){return r.containerState.size=s+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(n)}}},eq={partial:!0,tokenize:function(e,t,n){const r=this;return aG(e,(function(e){const o=r.events[r.events.length-1];return!nG(e)&&o&&"listItemPrefixWhitespace"===o[1].type?t(e):n(e)}),"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},tq={partial:!0,tokenize:function(e,t,n){const r=this;return aG(e,(function(e){const o=r.events[r.events.length-1];return o&&"listItemIndent"===o[1].type&&o[2].sliceSerialize(o[1],!0).length===r.containerState.size?t(e):n(e)}),"listItemIndent",r.containerState.size+1)}};const nq={name:"setextUnderline",resolveTo:function(e,t){let n,r,o,s=e.length;for(;s--;)if("enter"===e[s][0]){if("content"===e[s][1].type){n=s;break}"paragraph"===e[s][1].type&&(r=s)}else"content"===e[s][1].type&&e.splice(s,1),o||"definition"!==e[s][1].type||(o=s);const i={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};e[r][1].type="setextHeadingText",o?(e.splice(r,0,["enter",i,t]),e.splice(o+1,0,["exit",e[n][1],t]),e[n][1].end={...e[o][1].end}):e[n][1]=i;return e.push(["exit",i,t]),e},tokenize:function(e,t,n){const r=this;let o;return function(t){let i,a=r.events.length;for(;a--;)if("lineEnding"!==r.events[a][1].type&&"linePrefix"!==r.events[a][1].type&&"content"!==r.events[a][1].type){i="paragraph"===r.events[a][1].type;break}if(!r.parser.lazy[r.now().line]&&(r.interrupt||i))return e.enter("setextHeadingLine"),o=t,function(t){return e.enter("setextHeadingLineSequence"),s(t)}(t);return n(t)};function s(t){return t===o?(e.consume(t),s):(e.exit("setextHeadingLineSequence"),nG(t)?aG(e,i,"lineSuffix")(t):i(t))}function i(r){return null===r||eG(r)?(e.exit("setextHeadingLine"),t(r)):n(r)}}};const rq={tokenize:function(e){const t=this,n=e.attempt(gG,(function(r){if(null===r)return void e.consume(r);return e.enter("lineEndingBlank"),e.consume(r),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}),e.attempt(this.parser.constructs.flowInitial,r,aG(e,e.attempt(this.parser.constructs.flow,r,e.attempt(IG,r)),"linePrefix")));return n;function r(r){if(null!==r)return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),t.currentConstruct=void 0,n;e.consume(r)}}};const oq={resolveAll:lq()},sq=aq("string"),iq=aq("text");function aq(e){return{resolveAll:lq("text"===e?cq:void 0),tokenize:function(t){const n=this,r=this.parser.constructs[e],o=t.attempt(r,s,i);return s;function s(e){return l(e)?o(e):i(e)}function i(e){if(null!==e)return t.enter("data"),t.consume(e),a;t.consume(e)}function a(e){return l(e)?(t.exit("data"),o(e)):(t.consume(e),a)}function l(e){if(null===e)return!0;const t=r[e];let o=-1;if(t)for(;++o<t.length;){const e=t[o];if(!e.previous||e.previous.call(n,n.previous))return!0}return!1}}}}function lq(e){return function(t,n){let r,o=-1;for(;++o<=t.length;)void 0===r?t[o]&&"data"===t[o][1].type&&(r=o,o++):t[o]&&"data"===t[o][1].type||(o!==r+2&&(t[r][1].end=t[o-1][1].end,t.splice(r+2,o-r-2),o=r+2),r=void 0);return e?e(t,n):t}}function cq(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 r=e[n-1][1],o=t.sliceStream(r);let s,i=o.length,a=-1,l=0;for(;i--;){const e=o[i];if("string"==typeof e){for(a=e.length;32===e.charCodeAt(a-1);)l++,a--;if(a)break;a=-1}else if(-2===e)s=!0,l++;else if(-1!==e){i++;break}}if(l){const o={type:n===e.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...o.start},r.start.offset===r.end.offset?Object.assign(r,o):(e.splice(n,0,["enter",o,t],["exit",o,t]),n+=2)}n++}return e}const dq={42:QG,43:QG,45:QG,48:QG,49:QG,50:QG,51:QG,52:QG,53:QG,54:QG,55:QG,56:QG,57:QG,62:yG},uq={91:RG},hq={[-2]:kG,[-1]:kG,32:kG},fq={35:FG,42:ZG,45:[nq,ZG],60:UG,61:nq,95:ZG,96:wG,126:wG},mq={38:xG,92:bG},pq={[-5]:XG,[-4]:XG,[-3]:XG,33:KG,38:xG,42:fG,60:[pG,HG],91:JG,92:[LG,bG],93:WG,95:fG,96:CG},gq={null:[fG,oq]},yq=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:uq,disable:{null:[]},document:dq,flow:fq,flowInitial:hq,insideSpan:gq,string:mq,text:pq},Symbol.toStringTag,{value:"Module"}));function bq(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const o={},s=[];let i=[],a=[];const l={attempt:g((function(e,t){y(e,t.from)})),check:g(p),consume:function(e){eG(e)?(r.line++,r.column=1,r.offset+=-3===e?2:1,b()):-1!==e&&(r.column++,r.offset++);r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===i[r._index].length&&(r._bufferIndex=-1,r._index++));c.previous=e},enter:function(e,t){const n=t||{};return n.type=e,n.start=h(),c.events.push(["enter",n,c]),a.push(n),n},exit:function(e){const t=a.pop();return t.end=h(),c.events.push(["exit",t,c]),t},interrupt:g(p,{interrupt:!0})},c={code:null,containerState:{},defineSkip:function(e){o[e.line]=e.column,b()},events:[],now:h,parser:e,previous:null,sliceSerialize:function(e,t){return function(e,t){let n=-1;const r=[];let o;for(;++n<e.length;){const s=e[n];let i;if("string"==typeof s)i=s;else switch(s){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&&o)continue;i=" ";break;default:i=String.fromCharCode(s)}o=-2===s,r.push(i)}return r.join("")}(u(e),t)},sliceStream:u,write:function(e){if(i=UW(i,e),f(),null!==i[i.length-1])return[];return y(t,0),c.events=hG(s,c.events,c),c.events}};let d=t.tokenize.call(c,l);return t.resolveAll&&s.push(t),c;function u(e){return function(e,t){const n=t.start._index,r=t.start._bufferIndex,o=t.end._index,s=t.end._bufferIndex;let i;if(n===o)i=[e[n].slice(r,s)];else{if(i=e.slice(n,o),r>-1){const e=i[0];"string"==typeof e?i[0]=e.slice(r):i.shift()}s>0&&i.push(e[o].slice(0,s))}return i}(i,e)}function h(){const{_bufferIndex:e,_index:t,line:n,column:o,offset:s}=r;return{_bufferIndex:e,_index:t,line:n,column:o,offset:s}}function f(){let e;for(;r._index<i.length;){const t=i[r._index];if("string"==typeof t)for(e=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===e&&r._bufferIndex<t.length;)m(t.charCodeAt(r._bufferIndex));else m(t)}}function m(e){d=d(e)}function p(e,t){t.restore()}function g(e,t){return function(n,o,s){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],r=null!==t&&e.null;return m([...Array.isArray(n)?n:n?[n]:[],...Array.isArray(r)?r:r?[r]:[]])(t)}}(n);function m(e){return i=e,d=0,0===e.length?s:p(e[d])}function p(e){return function(n){f=function(){const e=h(),t=c.previous,n=c.currentConstruct,o=c.events.length,s=Array.from(a);return{from:o,restore:i};function i(){r=e,c.previous=t,c.currentConstruct=n,c.events.length=o,a=s,b()}}(),u=e,e.partial||(c.currentConstruct=e);if(e.name&&c.parser.constructs.disable.null.includes(e.name))return y();return e.tokenize.call(t?Object.assign(Object.create(c),t):c,l,g,y)(n)}}function g(t){return e(u,f),o}function y(e){return f.restore(),++d<i.length?p(i[d]):s}}}function y(e,t){e.resolveAll&&!s.includes(e)&&s.push(e),e.resolve&&BW(c.events,t,c.events.length-t,e.resolve(c.events.slice(t),c)),e.resolveTo&&(c.events=e.resolveTo(c.events,c))}function b(){r.line in o&&r.column<2&&(r.column=o[r.line],r.offset+=o[r.line]-1)}}function xq(e){const t={constructs:function(e){const t={};let n=-1;for(;++n<e.length;)VW(t,e[n]);return t}([yq,...(e||{}).extensions||[]]),content:n(lG),defined:[],document:n(cG),flow:n(rq),lazy:{},string:n(sq),text:n(iq)};return t;function n(e){return function(n){return bq(t,e,n)}}}const vq=/[\0\t\n\r]/g;const wq=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function kq(e,t,n){if(t)return t;if(35===n.charCodeAt(0)){const e=n.charCodeAt(1),t=120===e||88===e;return WW(n.slice(t?2:1),t?16:10)}return zW(n)||e}const Sq={}.hasOwnProperty;function Cq(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:s(te),autolinkProtocol:N,autolinkEmail:N,atxHeading:s(X),blockQuote:s(G),characterEscape:N,characterReference:N,codeFenced:s(q),codeFencedFenceInfo:i,codeFencedFenceMeta:i,codeIndented:s(q,i),codeText:s(Y,i),codeTextData:N,data:N,codeFlowValue:N,definition:s(K),definitionDestinationString:i,definitionLabelString:i,definitionTitleString:i,emphasis:s(J),hardBreakEscape:s(Z),hardBreakTrailing:s(Z),htmlFlow:s(Q,i),htmlFlowData:N,htmlText:s(Q,i),htmlTextData:N,image:s(ee),label:i,link:s(te),listItem:s(re),listItemValue:h,listOrdered:s(ne,u),listUnordered:s(ne),paragraph:s(oe),reference:z,referenceString:i,resourceDestinationString:i,resourceTitleString:i,setextHeading:s(X),strong:s(se),thematicBreak:s(ae)},exit:{atxHeading:l(),atxHeadingSequence:w,autolink:l(),autolinkEmail:W,autolinkProtocol:H,blockQuote:l(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:U,characterReferenceMarkerNumeric:U,characterReferenceValue:$,characterReference:V,codeFenced:l(g),codeFencedFence:p,codeFencedFenceInfo:f,codeFencedFenceMeta:m,codeFlowValue:E,codeIndented:l(y),codeText:l(T),codeTextData:E,data:E,definition:l(),definitionDestinationString:v,definitionLabelString:b,definitionTitleString:x,emphasis:l(),hardBreakEscape:l(_),hardBreakTrailing:l(_),htmlFlow:l(I),htmlFlowData:E,htmlText:l(A),htmlTextData:E,image:l(D),label:R,labelText:O,lineEnding:j,link:l(M),listItem:l(),listOrdered:l(),listUnordered:l(),paragraph:l(),referenceString:B,resourceDestinationString:P,resourceTitleString:L,resource:F,setextHeading:l(C),setextHeadingLineSequence:S,setextHeadingText:k,strong:l(),thematicBreak:l()}};Eq(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(e){let r={type:"root",children:[]};const s={stack:[r],tokenStack:[],config:t,enter:a,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=o(e,l.pop(),u)}for(u=-1;++u<e.length;){const n=t[e[u][0]];Sq.call(n,e[u][1].type)&&n[e[u][1].type].call(Object.assign({sliceSerialize:e[u][2].sliceSerialize},s),e[u][1])}if(s.tokenStack.length>0){const e=s.tokenStack[s.tokenStack.length-1];(e[1]||_q).call(s,void 0,e[0])}for(r.position={start:Nq(e.length>0?e[0][1].start:{line:1,column:1,offset:0}),end:Nq(e.length>0?e[e.length-2][1].end:{line:1,column:1,offset:0})},u=-1;++u<t.transforms.length;)r=t.transforms[u](r)||r;return r}function o(e,t,n){let r,o,s,i,a=t-1,l=-1,c=!1;for(;++a<=n;){const t=e[a];switch(t[1].type){case"listUnordered":case"listOrdered":case"blockQuote":"enter"===t[0]?l++:l--,i=void 0;break;case"lineEndingBlank":"enter"===t[0]&&(!r||i||l||s||(s=a),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(r){let i=a;for(o=void 0;i--;){const t=e[i];if("lineEnding"===t[1].type||"lineEndingBlank"===t[1].type){if("exit"===t[0])continue;o&&(e[o][1].type="lineEndingBlank",c=!0),t[1].type="lineEnding",o=i}else if("linePrefix"!==t[1].type&&"blockQuotePrefix"!==t[1].type&&"blockQuotePrefixWhitespace"!==t[1].type&&"blockQuoteMarker"!==t[1].type&&"listItemIndent"!==t[1].type)break}s&&(!o||s<o)&&(r._spread=!0),r.end=Object.assign({},o?e[o][1].start:t[1].end),e.splice(o||a,0,["exit",r,t[2]]),a++,n++}if("listItemPrefix"===t[1].type){const o={type:"listItem",_spread:!1,start:Object.assign({},t[1].start),end:void 0};r=o,e.splice(a,0,["enter",o,t[2]]),a++,n++,s=void 0,i=!0}}}return e[t][1]._spread=c,n}function s(e,t){return n;function n(n){a.call(this,e(n),n),t&&t.call(this,n)}}function i(){this.stack.push({type:"fragment",children:[]})}function a(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:Nq(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(),r=this.tokenStack.pop();if(!r)throw new Error("Cannot close `"+e.type+"` ("+uW({start:e.start,end:e.end})+"): it’s not open");if(r[0].type!==e.type)if(t)t.call(this,e,r[0]);else{(r[1]||_q).call(this,e,r[0])}n.position.end=Nq(e.end)}function d(){return function(e){return PW(e,"boolean"!=typeof RW.includeImageAlt||RW.includeImageAlt,"boolean"!=typeof RW.includeHtml||RW.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 y(){const e=this.resume();this.stack[this.stack.length-1].value=e.replace(/(\r?\n|\r)$/g,"")}function b(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=GW(this.sliceSerialize(e)).toLowerCase()}function x(){const e=this.resume();this.stack[this.stack.length-1].title=e}function v(){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 C(){this.data.setextHeadingSlurpLineEnding=void 0}function N(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:Nq(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=Nq(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=Nq(e.end),void(this.data.atHardBreak=void 0)}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(n.type)&&(N.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 D(){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(e){const t=this.sliceSerialize(e),n=this.stack[this.stack.length-2];n.label=function(e){return e.replace(wq,kq)}(t),n.identifier=GW(t).toLowerCase()}function R(){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 P(){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 F(){this.data.inReference=void 0}function z(){this.data.referenceType="collapsed"}function B(e){const t=this.resume(),n=this.stack[this.stack.length-1];n.label=t,n.identifier=GW(this.sliceSerialize(e)).toLowerCase(),this.data.referenceType="full"}function U(e){this.data.characterReferenceType=e.type}function $(e){const t=this.sliceSerialize(e),n=this.data.characterReferenceType;let r;if(n)r=WW(t,"characterReferenceMarkerNumeric"===n?10:16),this.data.characterReferenceType=void 0;else{r=zW(t)}this.stack[this.stack.length-1].value+=r}function V(e){this.stack.pop().position.end=Nq(e.end)}function H(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 K(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function J(){return{type:"emphasis",children:[]}}function X(){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 re(e){return{type:"listItem",spread:e._spread,checked:null,children:[]}}function oe(){return{type:"paragraph",children:[]}}function se(){return{type:"strong",children:[]}}function ie(){return{type:"text",value:""}}function ae(){return{type:"thematicBreak"}}}(n)(function(e){for(;!jG(e););return e}(xq(n).document().write(function(){let e,t=1,n="",r=!0;return function(o,s,i){const a=[];let l,c,d,u,h;for(o=n+("string"==typeof o?o.toString():new TextDecoder(s||void 0).decode(o)),d=0,n="",r&&(65279===o.charCodeAt(0)&&d++,r=void 0);d<o.length;){if(vq.lastIndex=d,l=vq.exec(o),u=l&&void 0!==l.index?l.index:o.length,h=o.charCodeAt(u),!l){n=o.slice(d);break}if(10===h&&d===u&&e)a.push(-3),e=void 0;else switch(e&&(a.push(-5),e=void 0),d<u&&(a.push(o.slice(d,u)),t+=u-d),h){case 0:a.push(65533),t++;break;case 9:for(c=4*Math.ceil(t/4),a.push(-2);t++<c;)a.push(-1);break;case 10:a.push(-4),t=1;break;default:e=!0,t=1}d=u+1}return i&&(e&&a.push(-5),n&&a.push(n),a.push(null)),a}}()(e,t,!0))))}function Nq(e){return{line:e.line,column:e.column,offset:e.offset}}function Eq(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?Eq(e,r):jq(e,r)}}function jq(e,t){let n;for(n in t)if(Sq.call(t,n))switch(n){case"canContainEols":{const r=t[n];r&&e[n].push(...r);break}case"transforms":{const r=t[n];r&&e[n].push(...r);break}case"enter":case"exit":{const r=t[n];r&&Object.assign(e[n],r);break}}}function _q(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+uW({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+uW({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+uW({start:t.start,end:t.end})+") is still open")}function Iq(e){const t=this;t.parser=function(n){return Cq(n,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Aq(e,t){const n=t.referenceType;let r="]";if("collapsed"===n?r+="[]":"full"===n&&(r+="["+(t.label||t.identifier)+"]"),"imageReference"===t.type)return[{type:"text",value:"!["+t.alt+r}];const o=e.all(t),s=o[0];s&&"text"===s.type?s.value="["+s.value:o.unshift({type:"text",value:"["});const i=o[o.length-1];return i&&"text"===i.type?i.value+=r:o.push({type:"text",value:r}),o}function Tq(e){const t=e.spread;return null==t?e.children.length>1:t}function Mq(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),o=0;const s=[];for(;r;)s.push(Dq(t.slice(o,r.index),o>0,!0),r[0]),o=r.index+r[0].length,r=n.exec(t);return s.push(Dq(t.slice(o),o>0,!1)),s.join("")}function Dq(e,t,n){let r=0,o=e.length;if(t){let t=e.codePointAt(r);for(;9===t||32===t;)r++,t=e.codePointAt(r)}if(n){let t=e.codePointAt(o-1);for(;9===t||32===t;)o--,t=e.codePointAt(o-1)}return o>r?e.slice(r,o):""}const Oq={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":"",r={};t.lang&&(r.className=["language-"+t.lang]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o},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-",r=String(t.identifier).toUpperCase(),o=iG(r.toLowerCase()),s=e.footnoteOrder.indexOf(r);let i,a=e.footnoteCounts.get(r);void 0===a?(a=0,e.footnoteOrder.push(r),i=e.footnoteOrder.length):i=s+1,a+=1,e.footnoteCounts.set(r,a);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+o,id:n+"fnref-"+o+(a>1?"-"+a:""),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(),r=e.definitionById.get(n);if(!r)return Aq(e,t);const o={src:iG(r.url||""),alt:t.alt};null!==r.title&&void 0!==r.title&&(o.title=r.title);const s={type:"element",tagName:"img",properties:o,children:[]};return e.patch(t,s),e.applyData(t,s)},image:function(e,t){const n={src:iG(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 r={type:"element",tagName:"img",properties:n,children:[]};return e.patch(t,r),e.applyData(t,r)},inlineCode:function(e,t){const n={type:"text",value:t.value.replace(/\r?\n|\r/g," ")};e.patch(t,n);const r={type:"element",tagName:"code",properties:{},children:[n]};return e.patch(t,r),e.applyData(t,r)},linkReference:function(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return Aq(e,t);const o={href:iG(r.url||"")};null!==r.title&&void 0!==r.title&&(o.title=r.title);const s={type:"element",tagName:"a",properties:o,children:e.all(t)};return e.patch(t,s),e.applyData(t,s)},link:function(e,t){const n={href:iG(t.url)};null!==t.title&&void 0!==t.title&&(n.title=t.title);const r={type:"element",tagName:"a",properties:n,children:e.all(t)};return e.patch(t,r),e.applyData(t,r)},listItem:function(e,t,n){const r=e.all(t),o=n?function(e){let t=!1;if("list"===e.type){t=e.spread||!1;const n=e.children;let r=-1;for(;!t&&++r<n.length;)t=Tq(n[r])}return t}(n):Tq(t),s={},i=[];if("boolean"==typeof t.checked){const e=r[0];let n;e&&"element"===e.type&&"p"===e.tagName?n=e:(n={type:"element",tagName:"p",properties:{},children:[]},r.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:[]}),s.className=["task-list-item"]}let a=-1;for(;++a<r.length;){const e=r[a];(o||0!==a||"element"!==e.type||"p"!==e.tagName)&&i.push({type:"text",value:"\n"}),"element"!==e.type||"p"!==e.tagName||o?i.push(e):i.push(...e.children)}const l=r[r.length-1];l&&(o||"element"!==l.type||"p"!==l.tagName)&&i.push({type:"text",value:"\n"});const c={type:"element",tagName:"li",properties:s,children:i};return e.patch(t,c),e.applyData(t,c)},list:function(e,t){const n={},r=e.all(t);let o=-1;for("number"==typeof t.start&&1!==t.start&&(n.start=t.start);++o<r.length;){const e=r[o];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 s={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,s),e.applyData(t,s)},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),r=n.shift(),o=[];if(r){const n={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],n),o.push(n)}if(n.length>0){const r={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},s=cW(t.children[1]),i=lW(t.children[t.children.length-1]);s&&i&&(r.position={start:s,end:i}),o.push(r)}const s={type:"element",tagName:"table",properties:{},children:e.wrap(o,!0)};return e.patch(t,s),e.applyData(t,s)},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 r=n?n.children:void 0,o=0===(r?r.indexOf(t):1)?"th":"td",s=n&&"table"===n.type?n.align:void 0,i=s?s.length:t.children.length;let a=-1;const l=[];for(;++a<i;){const n=t.children[a],r={},i=s?s[a]:void 0;i&&(r.align=i);let c={type:"element",tagName:o,properties:r,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:Mq(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:Rq,yaml:Rq,definition:Rq,footnoteDefinition:Rq};function Rq(){}const Pq="object"==typeof self?self:globalThis,Lq=e=>((e,t)=>{const n=(t,n)=>(e.set(n,t),t),r=o=>{if(e.has(o))return e.get(o);const[s,i]=t[o];switch(s){case 0:case-1:return n(i,o);case 1:{const e=n([],o);for(const t of i)e.push(r(t));return e}case 2:{const e=n({},o);for(const[t,n]of i)e[r(t)]=r(n);return e}case 3:return n(new Date(i),o);case 4:{const{source:e,flags:t}=i;return n(new RegExp(e,t),o)}case 5:{const e=n(new Map,o);for(const[t,n]of i)e.set(r(t),r(n));return e}case 6:{const e=n(new Set,o);for(const t of i)e.add(r(t));return e}case 7:{const{name:e,message:t}=i;return n(new Pq[e](t),o)}case 8:return n(BigInt(i),o);case"BigInt":return n(Object(BigInt(i)),o)}return n(new Pq[s](i),o)};return r})(new Map,e)(0),Fq="",{toString:zq}={},{keys:Bq}=Object,Uq=e=>{const t=typeof e;if("object"!==t||!e)return[0,t];const n=zq.call(e).slice(8,-1);switch(n){case"Array":return[1,Fq];case"Object":return[2,Fq];case"Date":return[3,Fq];case"RegExp":return[4,Fq];case"Map":return[5,Fq];case"Set":return[6,Fq]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},$q=([e,t])=>0===e&&("function"===t||"symbol"===t),Vq=(e,{json:t,lossy:n}={})=>{const r=[];return((e,t,n,r)=>{const o=(e,t)=>{const o=r.push(e)-1;return n.set(t,o),o},s=r=>{if(n.has(r))return n.get(r);let[i,a]=Uq(r);switch(i){case 0:{let t=r;switch(a){case"bigint":i=8,t=r.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+a);t=null;break;case"undefined":return o([-1],r)}return o([i,t],r)}case 1:{if(a)return o([a,[...r]],r);const e=[],t=o([i,e],r);for(const n of r)e.push(s(n));return t}case 2:{if(a)switch(a){case"BigInt":return o([a,r.toString()],r);case"Boolean":case"Number":case"String":return o([a,r.valueOf()],r)}if(t&&"toJSON"in r)return s(r.toJSON());const n=[],l=o([i,n],r);for(const t of Bq(r))!e&&$q(Uq(r[t]))||n.push([s(t),s(r[t])]);return l}case 3:return o([i,r.toISOString()],r);case 4:{const{source:e,flags:t}=r;return o([i,{source:e,flags:t}],r)}case 5:{const t=[],n=o([i,t],r);for(const[o,i]of r)(e||!$q(Uq(o))&&!$q(Uq(i)))&&t.push([s(o),s(i)]);return n}case 6:{const t=[],n=o([i,t],r);for(const o of r)!e&&$q(Uq(o))||t.push(s(o));return n}}const{message:l}=r;return o([i,{name:a,message:l}],r)};return s})(!(t||n),!!t,new Map,r)(e),r},Hq="function"==typeof structuredClone?(e,t)=>t&&("json"in t||"lossy"in t)?Lq(Vq(e,t)):structuredClone(e):(e,t)=>Lq(Vq(e,t));function Wq(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 Gq(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}const qq=function(e){if(null==e)return Kq;if("function"==typeof e)return Yq(e);if("object"==typeof e)return Array.isArray(e)?function(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=qq(e[n]);return Yq(r);function r(...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 Yq(n);function n(n){const r=n;let o;for(o in e)if(r[o]!==t[o])return!1;return!0}}(e);if("string"==typeof e)return function(e){return Yq(t);function t(t){return t&&t.type===e}}(e);throw new Error("Expected function, string, or object as test")};function Yq(e){return function(t,n,r){return Boolean(function(e){return null!==e&&"object"==typeof e&&"type"in e}(t)&&e.call(this,t,"number"==typeof n?n:void 0,r||void 0))}}function Kq(){return!0}const Jq=[],Xq=!0,Zq=!1;function Qq(e,t,n,r){let o;"function"==typeof t&&"function"!=typeof n?(r=n,n=t):o=t;const s=qq(o),i=r?-1:1;!function e(o,a,l){const c=o&&"object"==typeof o?o:{};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 ("+o.type+(e?"<"+e+">":"")+")"})}return d;function d(){let c,d,u,h=Jq;if((!t||s(o,a,l[l.length-1]||void 0))&&(h=function(e){if(Array.isArray(e))return e;if("number"==typeof e)return[Xq,e];return null==e?Jq:[e]}(n(o,l)),h[0]===Zq))return h;if("children"in o&&o.children){const t=o;if(t.children&&"skip"!==h[0])for(d=(r?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]===Zq)return c;d="number"==typeof c[1]?c[1]:d+i}}return h}}(e,void 0,[])()}function eY(e,t,n,r){let o,s,i;"function"==typeof t?(s=void 0,i=t,o=n):(s=t,i=n,o=r),Qq(e,s,(function(e,t){const n=t[t.length-1],r=n?n.children.indexOf(e):void 0;return i(e,r,n)}),o)}const tY={}.hasOwnProperty,nY={};function rY(e,t){e.position&&(t.position=function(e){const t=cW(e),n=lW(e);if(t&&n)return{start:t,end:n}}(e))}function oY(e,t){let n=t;if(e&&e.data){const t=e.data.hName,r=e.data.hChildren,o=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&&o&&Object.assign(n.properties,Hq(o)),"children"in n&&n.children&&null!=r&&(n.children=r)}return n}function sY(e,t){const n=t.data||{},r=!("value"in t)||tY.call(n,"hProperties")||tY.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:e.all(t)}:{type:"text",value:t.value};return e.patch(t,r),e.applyData(t,r)}function iY(e,t){const n=[];let r=-1;for(t&&n.push({type:"text",value:"\n"});++r<e.length;)r&&n.push({type:"text",value:"\n"}),n.push(e[r]);return t&&e.length>0&&n.push({type:"text",value:"\n"}),n}function aY(e){let t=0,n=e.charCodeAt(t);for(;9===n||32===n;)t++,n=e.charCodeAt(t);return e.slice(t)}function lY(e,t){const n=function(e,t){const n=t||nY,r=new Map,o=new Map,s=new Map,i={...Oq,...n.handlers},a={all:function(e){const t=[];if("children"in e){const n=e.children;let r=-1;for(;++r<n.length;){const o=a.one(n[r],e);if(o){if(r&&"break"===n[r-1].type&&(Array.isArray(o)||"text"!==o.type||(o.value=aY(o.value)),!Array.isArray(o)&&"element"===o.type)){const e=o.children[0];e&&"text"===e.type&&(e.value=aY(e.value))}Array.isArray(o)?t.push(...o):t.push(o)}}}return t},applyData:oY,definitionById:r,footnoteById:o,footnoteCounts:s,footnoteOrder:[],handlers:i,one:function(e,t){const n=e.type,r=a.handlers[n];if(tY.call(a.handlers,n)&&r)return r(a,e,t);if(a.options.passThrough&&a.options.passThrough.includes(n)){if("children"in e){const{children:t,...n}=e,r=Hq(n);return r.children=a.all(e),r}return Hq(e)}return(a.options.unknownHandler||sY)(a,e,t)},options:n,patch:rY,wrap:iY};return eY(e,(function(e){if("definition"===e.type||"footnoteDefinition"===e.type){const t="definition"===e.type?r:o,n=String(e.identifier).toUpperCase();t.has(n)||t.set(n,e)}})),a}(e,t),r=n.one(e,void 0),o=function(e){const t="string"==typeof e.options.clobberPrefix?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||Wq,r=e.options.footnoteBackLabel||Gq,o=e.options.footnoteLabel||"Footnotes",s=e.options.footnoteLabelTagName||"h2",i=e.options.footnoteLabelProperties||{className:["sr-only"]},a=[];let l=-1;for(;++l<e.footnoteOrder.length;){const o=e.footnoteById.get(e.footnoteOrder[l]);if(!o)continue;const s=e.all(o),i=String(o.identifier).toUpperCase(),c=iG(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 r?r:r(l,d),className:["data-footnote-backref"]},children:Array.isArray(e)?e:[e]})}const f=s[s.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 s.push(...u);const m={type:"element",tagName:"li",properties:{id:t+"fn-"+c},children:e.wrap(s,!0)};e.patch(o,m),a.push(m)}if(0!==a.length)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:s,properties:{...Hq(i),id:"footnote-label"},children:[{type:"text",value:o}]},{type:"text",value:"\n"},{type:"element",tagName:"ol",properties:{},children:e.wrap(a,!0)},{type:"text",value:"\n"}]}}(n),s=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return o&&s.children.push({type:"text",value:"\n"},o),s}function cY(e,t){return e&&"run"in e?async function(n,r){const o=lY(n,{file:r,...t});await e.run(o,r)}:function(n,r){return lY(n,{file:r,...e||t})}}function dY(e){if(e)throw e}var uY,hY;var fY=function(){if(hY)return uY;hY=1;var e=Object.prototype.hasOwnProperty,t=Object.prototype.toString,n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,o=function(e){return"function"==typeof Array.isArray?Array.isArray(e):"[object Array]"===t.call(e)},s=function(n){if(!n||"[object Object]"!==t.call(n))return!1;var r,o=e.call(n,"constructor"),s=n.constructor&&n.constructor.prototype&&e.call(n.constructor.prototype,"isPrototypeOf");if(n.constructor&&!o&&!s)return!1;for(r in n);return void 0===r||e.call(n,r)},i=function(e,t){n&&"__proto__"===t.name?n(e,t.name,{enumerable:!0,configurable:!0,value:t.newValue,writable:!0}):e[t.name]=t.newValue},a=function(t,n){if("__proto__"===n){if(!e.call(t,n))return;if(r)return r(t,n).value}return t[n]};return uY=function e(){var t,n,r,l,c,d,u=arguments[0],h=1,f=arguments.length,m=!1;for("boolean"==typeof u&&(m=u,u=arguments[1]||{},h=2),(null==u||"object"!=typeof u&&"function"!=typeof u)&&(u={});h<f;++h)if(null!=(t=arguments[h]))for(n in t)r=a(u,n),u!==(l=a(t,n))&&(m&&l&&(s(l)||(c=o(l)))?(c?(c=!1,d=r&&o(r)?r:[]):d=r&&s(r)?r:{},i(u,{name:n,newValue:e(m,d,l)})):void 0!==l&&i(u,{name:n,newValue:l}));return u},uY}();const mY=Pl(fY);function pY(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 gY(){const e=[],t={run:function(...t){let n=-1;const r=t.pop();if("function"!=typeof r)throw new TypeError("Expected function as last argument, not "+r);!function o(s,...i){const a=e[++n];let l=-1;if(s)r(s);else{for(;++l<t.length;)null!==i[l]&&void 0!==i[l]||(i[l]=t[l]);t=i,a?function(e,t){let n;return r;function r(...t){const r=e.length>t.length;let a;r&&t.push(o);try{a=e.apply(this,t)}catch(s){if(r&&n)throw s;return o(s)}r||(a&&a.then&&"function"==typeof a.then?a.then(i,o):a instanceof Error?o(a):i(a))}function o(e,...r){n||(n=!0,t(e,...r))}function i(e){o(null,e)}}(a,o)(...i):r(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 yY={basename:function(e,t){if(void 0!==t&&"string"!=typeof t)throw new TypeError('"ext" argument must be a string');bY(e);let n,r=0,o=-1,s=e.length;if(void 0===t||0===t.length||t.length>e.length){for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else o<0&&(n=!0,o=s+1);return o<0?"":e.slice(r,o)}if(t===e)return"";let i=-1,a=t.length-1;for(;s--;)if(47===e.codePointAt(s)){if(n){r=s+1;break}}else i<0&&(n=!0,i=s+1),a>-1&&(e.codePointAt(s)===t.codePointAt(a--)?a<0&&(o=s):(a=-1,o=i));r===o?o=i:o<0&&(o=e.length);return e.slice(r,o)},dirname:function(e){if(bY(e),0===e.length)return".";let t,n=-1,r=e.length;for(;--r;)if(47===e.codePointAt(r)){if(t){n=r;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){bY(e);let t,n=e.length,r=-1,o=0,s=-1,i=0;for(;n--;){const a=e.codePointAt(n);if(47!==a)r<0&&(t=!0,r=n+1),46===a?s<0?s=n:1!==i&&(i=1):s>-1&&(i=-1);else if(t){o=n+1;break}}if(s<0||r<0||0===i||1===i&&s===r-1&&s===o+1)return"";return e.slice(s,r)},join:function(...e){let t,n=-1;for(;++n<e.length;)bY(e[n]),e[n]&&(t=void 0===t?e[n]:t+"/"+e[n]);return void 0===t?".":function(e){bY(e);const t=47===e.codePointAt(0);let n=function(e,t){let n,r,o="",s=0,i=-1,a=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===a);else if(i!==l-1&&2===a){if(o.length<2||2!==s||46!==o.codePointAt(o.length-1)||46!==o.codePointAt(o.length-2))if(o.length>2){if(r=o.lastIndexOf("/"),r!==o.length-1){r<0?(o="",s=0):(o=o.slice(0,r),s=o.length-1-o.lastIndexOf("/")),i=l,a=0;continue}}else if(o.length>0){o="",s=0,i=l,a=0;continue}t&&(o=o.length>0?o+"/..":"..",s=2)}else o.length>0?o+="/"+e.slice(i+1,l):o=e.slice(i+1,l),s=l-i-1;i=l,a=0}else 46===n&&a>-1?a++:a=-1}return o}(e,!t);0!==n.length||t||(n=".");n.length>0&&47===e.codePointAt(e.length-1)&&(n+="/");return t?"/"+n:n}(t)},sep:"/"};function bY(e){if("string"!=typeof e)throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const xY={cwd:function(){return"/"}};function vY(e){return Boolean(null!==e&&"object"==typeof e&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&void 0===e.auth)}function wY(e){if("string"==typeof e)e=new URL(e);else if(!vY(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 kY=["history","path","basename","stem","extname","dirname"];class SY{constructor(e){let t;t=e?vY(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?"":xY.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let n,r=-1;for(;++r<kY.length;){const e=kY[r];e in t&&void 0!==t[e]&&null!==t[e]&&(this[e]="history"===e?[...t[e]]:t[e])}for(n in t)kY.includes(n)||(this[n]=t[n])}get basename(){return"string"==typeof this.path?yY.basename(this.path):void 0}set basename(e){NY(e,"basename"),CY(e,"basename"),this.path=yY.join(this.dirname||"",e)}get dirname(){return"string"==typeof this.path?yY.dirname(this.path):void 0}set dirname(e){EY(this.basename,"dirname"),this.path=yY.join(e||"",this.basename)}get extname(){return"string"==typeof this.path?yY.extname(this.path):void 0}set extname(e){if(CY(e,"extname"),EY(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=yY.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){vY(e)&&(e=wY(e)),NY(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return"string"==typeof this.path?yY.basename(this.path,this.extname):void 0}set stem(e){NY(e,"stem"),CY(e,"stem"),this.path=yY.join(this.dirname||"",e+(this.extname||""))}fail(e,t,n){const r=this.message(e,t,n);throw r.fatal=!0,r}info(e,t,n){const r=this.message(e,t,n);return r.fatal=void 0,r}message(e,t,n){const r=new pW(e,t,n);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}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 CY(e,t){if(e&&e.includes(yY.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+yY.sep+"`")}function NY(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function EY(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}const jY=function(e){const t=this.constructor.prototype,n=t[e],r=function(){return n.apply(r,arguments)};return Object.setPrototypeOf(r,t),r},_Y={}.hasOwnProperty;class IY extends jY{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=gY()}copy(){const e=new IY;let t=-1;for(;++t<this.attachers.length;){const n=this.attachers[t];e.use(...n)}return e.data(mY(!0,{},this.namespace)),e}data(e,t){return"string"==typeof e?2===arguments.length?(DY("data",this.frozen),this.namespace[e]=t,this):_Y.call(this.namespace,e)&&this.namespace[e]||void 0:e?(DY("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 r=t.call(e,...n);"function"==typeof r&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const t=PY(e),n=this.parser||this.Parser;return TY("parse",n),n(String(t),t)}process(e,t){const n=this;return this.freeze(),TY("process",this.parser||this.Parser),MY("process",this.compiler||this.Compiler),t?r(void 0,t):new Promise(r);function r(r,o){const s=PY(e),i=n.parse(s);function a(e,n){e||!n?o(e):r?r(n):t(void 0,n)}n.run(i,s,(function(e,t,r){if(e||!t||!r)return a(e);const o=t,s=n.stringify(o,r);!function(e){return"string"==typeof e||function(e){return Boolean(e&&"object"==typeof e&&"byteLength"in e&&"byteOffset"in e)}(e)}(s)?r.result=s:r.value=s,a(e,r)}))}}processSync(e){let t,n=!1;return this.freeze(),TY("processSync",this.parser||this.Parser),MY("processSync",this.compiler||this.Compiler),this.process(e,(function(e,r){n=!0,dY(e),t=r})),RY("processSync","process",n),t}run(e,t,n){OY(e),this.freeze();const r=this.transformers;return n||"function"!=typeof t||(n=t,t=void 0),n?o(void 0,n):new Promise(o);function o(o,s){const i=PY(t);r.run(e,i,(function(t,r,i){const a=r||e;t?s(t):o?o(a):n(void 0,a,i)}))}}runSync(e,t){let n,r=!1;return this.run(e,t,(function(e,t){dY(e),n=t,r=!0})),RY("runSync","run",r),n}stringify(e,t){this.freeze();const n=PY(t),r=this.compiler||this.Compiler;return MY("stringify",r),OY(e),r(e,n)}use(e,...t){const n=this.attachers,r=this.namespace;if(DY("use",this.frozen),null==e);else if("function"==typeof e)a(e,t);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):s(e)}return this;function o(e){if("function"==typeof e)a(e,[]);else{if("object"!=typeof e)throw new TypeError("Expected usable value, not `"+e+"`");if(Array.isArray(e)){const[t,...n]=e;a(t,n)}else s(e)}}function s(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&&(r.settings=mY(!0,r.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;){o(e[t])}}}function a(e,t){let r=-1,o=-1;for(;++r<n.length;)if(n[r][0]===e){o=r;break}if(-1===o)n.push([e,...t]);else if(t.length>0){let[r,...s]=t;const i=n[o][1];pY(i)&&pY(r)&&(r=mY(!0,i,r)),n[o]=[e,r,...s]}}}}const AY=(new IY).freeze();function TY(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `parser`")}function MY(e,t){if("function"!=typeof t)throw new TypeError("Cannot `"+e+"` without `compiler`")}function DY(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 OY(e){if(!pY(e)||"string"!=typeof e.type)throw new TypeError("Expected node, got `"+e+"`")}function RY(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function PY(e){return function(e){return Boolean(e&&"object"==typeof e&&"message"in e&&"messages"in e)}(e)?e:new SY(e)}const LY=[],FY={allowDangerousHtml:!0},zY=/^(https?|ircs?|mailto|xmpp)$/i,BY=[{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 UY(e){const t=function(e){const t=e.rehypePlugins||LY,n=e.remarkPlugins||LY,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...FY}:FY,o=AY().use(Iq).use(n).use(cY,r).use(t);return o}(e),n=function(e){const t=e.children||"",n=new SY;"string"==typeof t&&(n.value=t);return n}(e);return function(e,t){const n=t.allowedElements,r=t.allowElement,o=t.components,s=t.disallowedElements,i=t.skipHtml,a=t.unwrapDisallowed,l=t.urlTransform||$Y;for(const d of BY)Object.hasOwn(t,d.from)&&(d.from,d.to&&d.to,d.id);t.className&&(e={type:"element",tagName:"div",properties:{className:t.className},children:"root"===e.type?e.children:[e]});return eY(e,c),SW(e,{Fragment:_.Fragment,components:o,ignoreInvalidStyle:!0,jsx:_.jsx,jsxs:_.jsxs,passKeys:!0,passNode:!0});function c(e,t,o){if("raw"===e.type&&o&&"number"==typeof t)return i?o.children.splice(t,1):o.children[t]={type:"text",value:e.value},t;if("element"===e.type){let t;for(t in OW)if(Object.hasOwn(OW,t)&&Object.hasOwn(e.properties,t)){const n=e.properties[t],r=OW[t];(null===r||r.includes(e.tagName))&&(e.properties[t]=l(String(n||""),t,e))}}if("element"===e.type){let i=n?!n.includes(e.tagName):!!s&&s.includes(e.tagName);if(!i&&r&&"number"==typeof t&&(i=!r(e,t,o)),i&&o&&"number"==typeof t)return a&&e.children?o.children.splice(t,1,...e.children):o.children.splice(t,1),t}}}(t.runSync(t.parse(n),n),e)}function $Y(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),o=e.indexOf("/");return-1===t||-1!==o&&t>o||-1!==n&&t>n||-1!==r&&t>r||zY.test(e.slice(0,t))?e:""}const VY=[zn.lineWrapping],HY=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]);const WY=e=>{const t=N.c(26),{code:n,language:r}=e,{theme:o}=Be(),{createNewCell:s}=V(),i=ph(),a=de(me),[c,d]=l.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]),l.useEffect(u,h),t[3]!==a||t[4]!==s||t[5]!==r||t[6]!==i||t[7]!==c?(f=()=>{const e=function(e,t){return e?"python"===e?{language:e,code:t}:"sql"===e?{language:"python",code:is.fromQuery(t)}:"markdown"===e?{language:"python",code:sn.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}}(r,c);"sql"===r&&ah(a,s,i),s({code:e.code,before:!1,cellId:i??"__end__"})},t[3]=a,t[4]=s,t[5]=r,t[6]=i,t[7]=c,t[8]=f):f=t[8];const m=f;let p;t[9]!==c?(p=async()=>{await Me(c)},t[9]=c,t[10]=p):p=t[10];const g=p,y="dark"===o?"dark":"light",b=r&&HY.has(r)?r:void 0;let x,v,w,k,S,C;return t[11]!==y||t[12]!==b||t[13]!==c?(x=_.jsx(Ga,{theme:y,language:b,className:"cm border rounded overflow-hidden",extensions:VY,value:c,onChange:d}),t[11]=y,t[12]=b,t[13]=c,t[14]=x):x=t[14],t[15]!==g?(v=_.jsx(GY,{size:"xs",variant:"outline",onClick:g,children:"Copy"}),t[15]=g,t[16]=v):v=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(w=_.jsx(kd,{className:"ml-2 h-4 w-4"}),t[17]=w):w=t[17],t[18]!==m?(k=_.jsxs(ee,{size:"xs",variant:"outline",onClick:m,children:["Add to Notebook",w]}),t[18]=m,t[19]=k):k=t[19],t[20]!==k||t[21]!==v?(S=_.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[v,k]}),t[20]=k,t[21]=v,t[22]=S):S=t[22],t[23]!==S||t[24]!==x?(C=_.jsxs("div",{className:"relative",children:[x,S]}),t[23]=S,t[24]=x,t[25]=C):C=t[25],C},GY=e=>{const t=N.c(12);let n,r;t[0]!==e?(({onClick:n,...r}=e),t[0]=e,t[1]=n,t[2]=r):(n=t[1],r=t[2]);const[o,s]=l.useState(!1);let i,a,c;t[3]!==o?(i=()=>{o&&setTimeout((()=>s(!1)),1e3)},a=[o],t[3]=o,t[4]=i,t[5]=a):(i=t[4],a=t[5]),l.useEffect(i,a),t[6]!==n?(c=e=>{null==n||n(e),s(!0)},t[6]=n,t[7]=c):c=t[7];const d=o?"Copied":"Copy";let u;return t[8]!==r||t[9]!==c||t[10]!==d?(u=_.jsx(ee,{...r,onClick:c,children:d}),t[8]=r,t[9]=c,t[10]=d,t[11]=u):u=t[11],u},qY={code:({children:e,className:t})=>{const n=null==t?void 0:t.replace("language-","");return n&&"string"==typeof e?_.jsxs("div",{children:[_.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),_.jsx(WY,{code:e.trim(),language:n})]}):_.jsx("code",{className:t,children:e})}};const YY=l.memo((e=>{const t=N.c(2),{content:n}=e;let r;return t[0]!==n?(r=_.jsx(UY,{components:qY,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),t[0]=n,t[1]=r):r=t[1],r}),((e,t)=>e.content===t.content));YY.displayName="MemoizedMarkdownBlock";const KY=l.memo((({content:e})=>{const t=l.useMemo((()=>{return t=e,Fl.lexer(t).map((e=>e.raw));var t}),[e]);return _.jsx(_.Fragment,{children:t.map(((e,t)=>_.jsx(YY,{content:e},`markdown-block-${t}`)))})}));KY.displayName="MarkdownRenderer";const JY=(e,t,n,r)=>t?{...e,chats:e.chats.map((e=>e.id===t?{...e,messages:[...e.messages,{role:n,content:r,timestamp:Date.now()}],updatedAt:Date.now()}:e))}:e,XY=e=>{var t;const n=N.c(29),{onNewChat:r,activeChatId:o,setActiveChat:s,chats:i,setMessages:a}=e,l=de(Qi),{handleClick:c}=yc(),d=(null==(t=null==l?void 0:l.open_ai)?void 0:t.model)||"gpt-4-turbo";let u,h,f,m,p,g,y,b,x,v;if(n[0]===Symbol.for("react.memo_cache_sentinel")?(u=_.jsx(ss,{className:"h-4 w-4"}),n[0]=u):u=n[0],n[1]!==r?(h=_.jsx(ht,{content:"New chat",children:_.jsx(ee,{variant:"text",size:"icon",onClick:r,children:u})}),n[1]=r,n[2]=h):h=n[2],n[3]!==c?(f=()=>c("ai"),n[3]=c,n[4]=f):f=n[4],n[5]!==d||n[6]!==f?(m=_.jsx(ee,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:f,children:d}),n[5]=d,n[6]=f,n[7]=m):m=n[7],n[8]!==h||n[9]!==m?(p=_.jsxs("div",{className:"flex items-center gap-2",children:[h,m]}),n[8]=h,n[9]=m,n[10]=p):p=n[10],n[11]===Symbol.for("react.memo_cache_sentinel")?(g=_.jsx(ht,{content:"Previous chats",children:_.jsx(Ls,{asChild:!0,children:_.jsx(ee,{variant:"text",size:"icon",children:_.jsx(Ul,{className:"h-4 w-4"})})})}),n[11]=g):g=n[11],n[12]!==i.length?(y=0===i.length&&_.jsx(gO,{title:"No chats yet",description:"Start a new chat to get started",icon:_.jsx(xt,{})}),n[12]=i.length,n[13]=y):y=n[13],n[14]!==o||n[15]!==i||n[16]!==s||n[17]!==a){let e;n[19]!==o||n[20]!==s||n[21]!==a?(e=e=>_.jsxs("div",{className:$t("p-3 rounded-md cursor-pointer hover:bg-accent",e.id===o&&"bg-accent"),onClick:()=>{s(e.id),a(e.messages.map(nK))},children:[_.jsx("div",{className:"font-medium",children:e.title}),_.jsx("div",{className:"text-sm text-muted-foreground",children:$l(e.updatedAt)})]},e.id),n[19]=o,n[20]=s,n[21]=a,n[22]=e):e=n[22],b=i.map(e),n[14]=o,n[15]=i,n[16]=s,n[17]=a,n[18]=b}else b=n[18];return n[23]!==y||n[24]!==b?(x=_.jsxs(nr,{children:[g,_.jsx(Qn,{className:"w-[520px] p-0",align:"start",side:"right",children:_.jsx(yH,{className:"h-[500px] p-4",children:_.jsxs("div",{className:"space-y-4",children:[y,b]})})})]}),n[23]=y,n[24]=b,n[25]=x):x=n[25],n[26]!==p||n[27]!==x?(v=_.jsxs("div",{className:"flex border-b px-2 py-1 justify-between flex-shrink-0 items-center",children:[p,x]}),n[26]=p,n[27]=x,n[28]=v):v=n[28],v},ZY=l.memo((e=>{const t=N.c(14),{message:n,index:r,theme:o,onEdit:s,setChatState:i,chatState:a}=e,l="user"===n.role?"justify-end":"justify-start";let c,d,u;return t[0]!==l?(c=$t("flex group relative",l),t[0]=l,t[1]=c):c=t[1],t[2]!==a||t[3]!==r||t[4]!==n.content||t[5]!==n.id||t[6]!==n.role||t[7]!==s||t[8]!==i||t[9]!==o?(d="user"===n.role?_.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:_.jsx(ti,{value:n.content,theme:o,placeholder:"Type your message...",onChange:rK,onSubmit:(e,t)=>{t.trim()&&(s(r,t),a.activeChatId&&i((e=>JY(e,a.activeChatId,"user",t))))},onClose:oK},n.id)}):_.jsxs("div",{className:"w-[95%]",children:[_.jsx("div",{className:"absolute right-1 top-1 opacity-0 group-hover:opacity-100 transition-opacity",children:_.jsx(wl,{className:"h-3 w-3",value:n.content})}),_.jsx(KY,{content:n.content})]}),t[2]=a,t[3]=r,t[4]=n.content,t[5]=n.id,t[6]=n.role,t[7]=s,t[8]=i,t[9]=o,t[10]=d):d=t[10],t[11]!==c||t[12]!==d?(u=_.jsx("div",{className:c,children:d}),t[11]=c,t[12]=d,t[13]=u):u=t[13],u}));ZY.displayName="ChatMessage";const QY=l.memo((e=>{var t,n;const r=N.c(8),{input:o,setInput:s,onSubmit:i,theme:a,inputRef:l}=e;let c,d;return r[0]!==(null==(t=l.current)?void 0:t.editor)?(c=()=>{var e,t;return null==(t=null==(e=l.current)?void 0:e.editor)?void 0:t.blur()},r[0]=null==(n=l.current)?void 0:n.editor,r[1]=c):c=r[1],r[2]!==o||r[3]!==i||r[4]!==s||r[5]!==c||r[6]!==a?(d=_.jsx("div",{className:"px-2 py-3 border-t relative flex-shrink-0 min-h-[80px]",children:_.jsx(ti,{value:o,onChange:s,onSubmit:i,onClose:c,theme:a,placeholder:"Type your message..."})}),r[2]=o,r[3]=i,r[4]=s,r[5]=c,r[6]=a,r[7]=d):d=r[7],d}));QY.displayName="ChatInput";const eK=()=>{const e=N.c(6),t=de(fe),{handleClick:n}=yc();if(!t){let t,r,o;return e[0]!==n?(t=_.jsx(ee,{variant:"outline",size:"sm",onClick:()=>n("ai"),children:"Edit AI settings"}),e[0]=n,e[1]=t):t=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(xt,{}),e[2]=r):r=e[2],e[3]!==t?(o=_.jsx(gO,{title:"Chat with AI",description:"AI is currently disabled. Add your API key to enable.",action:t,icon:r}),e[3]=t,e[4]=o):o=e[4],o}let r;return e[5]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(tK,{}),e[5]=r):r=e[5],r},tK=()=>{const e=N.c(70),[t,n]=We(nh),[r,o]=We(rh),[s,i]=l.useState(""),a=l.useRef(null),c=l.useRef(null),d=l.useRef(null),{theme:u}=Be();let h,f,m;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=Yr("api/ai/chat").toString(),f=Pr.headers(),e[0]=h,e[1]=f):(h=e[0],f=e[1]),e[2]!==t.activeChatId||e[3]!==n?(m={keepLastMessageOnError:!0,experimental_throttle:100,api:h,headers:f,experimental_prepareRequestBody:iK,streamProtocol:"text",onFinish:e=>{t.activeChatId?n((t=>JY(t,t.activeChatId,"assistant",e.content))):X.warn("No active chat")},onError:aK,onResponse:lK},e[2]=t.activeChatId,e[3]=n,e[4]=m):m=e[4];const{messages:p,input:g,setInput:y,setMessages:b,append:x,handleSubmit:v,error:w,isLoading:k,reload:S}=zl(m);let C;e[5]!==x||e[6]!==n||e[7]!==y||e[8]!==b?(C=e=>{const t={id:Bl(),title:`${e.slice(0,30)}...`,messages:[{role:"user",content:e,timestamp:Date.now()}],createdAt:Date.now(),updatedAt:Date.now()};n((e=>({chats:[...e.chats,t],activeChatId:t.id}))),b([]),y(""),x({role:"user",content:e})},e[5]=x,e[6]=n,e[7]=y,e[8]=b,e[9]=C):C=e[9];const E=C;let j;e[10]!==o||e[11]!==y||e[12]!==b?(j=()=>{o(null),b([]),y(""),i("")},e[10]=o,e[11]=y,e[12]=b,e[13]=j):j=e[13];const I=j;let A;e[14]!==x||e[15]!==b?(A=(e,t)=>{b((t=>t.slice(0,e))),x({role:"user",content:t})},e[14]=x,e[15]=b,e[16]=A):A=e[16];const T=A;let M;e[17]!==t.activeChatId||e[18]!==v||e[19]!==n?(M=(e,r)=>{r.trim()&&(v(e),t.activeChatId&&n((e=>JY(e,t.activeChatId,"user",r))))},e[17]=t.activeChatId,e[18]=v,e[19]=n,e[20]=M):M=e[20];const D=M;let O;e[21]!==S?(O=()=>{S()},e[21]=S,e[22]=O):O=e[22];const R=O;let P;e[23]!==E||e[24]!==s?(P=()=>{s.trim()&&E(s.trim())},e[23]=E,e[24]=s,e[25]=P):P=e[25];const L=P;let F;e[26]===Symbol.for("react.memo_cache_sentinel")?(F=()=>{var e,t;return null==(t=null==(e=a.current)?void 0:e.editor)?void 0:t.blur()},e[26]=F):F=e[26];const z=F,B=null==r?void 0:r.id;let U,$,V,H,W,G,q,Y,K;if(e[27]!==t.chats||e[28]!==I||e[29]!==o||e[30]!==b||e[31]!==B?(U=_.jsx(Ni,{children:_.jsx(XY,{onNewChat:I,activeChatId:B,setActiveChat:o,chats:t.chats,setMessages:b})}),e[27]=t.chats,e[28]=I,e[29]=o,e[30]=b,e[31]=B,e[32]=U):U=e[32],e[33]!==L||e[34]!==p||e[35]!==s||e[36]!==u?($=(!p||0===p.length)&&_.jsx("div",{className:"flex rounded-md border px-1 bg-background",children:_.jsx(ti,{value:s,placeholder:"Ask anything, @ to include context about tables or dataframes",theme:u,onClose:z,onChange:i,onSubmit:L},"new-thread-input")}),e[33]=L,e[34]=p,e[35]=s,e[36]=u,e[37]=$):$=e[37],e[38]!==t||e[39]!==T||e[40]!==p||e[41]!==n||e[42]!==u){let r;e[44]!==t||e[45]!==T||e[46]!==n||e[47]!==u?(r=(e,r)=>_.jsx(ZY,{message:e,index:r,theme:u,onEdit:T,setChatState:n,chatState:t},r),e[44]=t,e[45]=T,e[46]=n,e[47]=u,e[48]=r):r=e[48],V=p.map(r),e[38]=t,e[39]=T,e[40]=p,e[41]=n,e[42]=u,e[43]=V}else V=e[43];return e[49]!==k?(H=k&&_.jsx("div",{className:"flex justify-center py-4",children:_.jsx(ri,{className:"h-4 w-4 animate-spin"})}),e[49]=k,e[50]=H):H=e[50],e[51]!==w||e[52]!==R?(W=w&&_.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[_.jsx(Ua,{error:w}),_.jsx(ee,{variant:"outline",size:"sm",onClick:R,children:"Retry"})]}),e[51]=w,e[52]=R,e[53]=W):W=e[53],e[54]===Symbol.for("react.memo_cache_sentinel")?(G=_.jsx("div",{ref:d}),e[54]=G):G=e[54],e[55]!==$||e[56]!==V||e[57]!==H||e[58]!==W?(q=_.jsxs("div",{className:"flex-1 px-3 bg-[var(--slate-1)] gap-4 py-3 flex flex-col overflow-y-auto",children:[$,V,H,W,G]}),e[55]=$,e[56]=V,e[57]=H,e[58]=W,e[59]=q):q=e[59],e[60]!==D||e[61]!==g||e[62]!==p||e[63]!==y||e[64]!==u?(Y=p&&p.length>0&&_.jsx(QY,{input:g,setInput:y,onSubmit:D,theme:u,inputRef:c}),e[60]=D,e[61]=g,e[62]=p,e[63]=y,e[64]=u,e[65]=Y):Y=e[65],e[66]!==U||e[67]!==q||e[68]!==Y?(K=_.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[U,q,Y]}),e[66]=U,e[67]=q,e[68]=Y,e[69]=K):K=e[69],K};function nK(e){const{role:t,content:n,timestamp:r}=e;return{role:t,content:n,id:r.toString()}}function rK(){}function oK(){}function sK(e){return e.content}function iK(e){return{...e,...ni({input:e.messages.map(sK).join("\n")}),includeOtherCode:Dr("")}}function aK(e){X.error("An error occurred:",e)}function lK(e){X.debug("Received HTTP response from server:",e)}const cK=p.lazy((()=>dl((()=>import("./tracing-DDaw37xD.js")),__vite__mapDeps([16,2,3,4,5,6,7,8,9,10,11,12,13,14,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,15,118,119,120,121,122,123,124]),import.meta.url).then((e=>({default:e.Tracing}))))),dK=()=>{const e=N.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(p.Suspense,{fallback:_.jsx(uK,{}),children:_.jsx(cK,{})}),e[0]=t):t=e[0],t},uK=()=>{const e=N.c(1);let t;return e[0]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:_.jsx(ta,{})}),e[0]=t):t=e[0],t},hK=()=>{const e=N.c(25),{openModal:t,closeModal:n}=ue();let r;e[0]===Symbol.for("react.memo_cache_sentinel")?(r=[],e[0]=r):r=e[0];const{data:o,loading:s,error:i,reload:a}=Pt(mK,r);let l;e[1]!==o?(l=void 0===o?[]:o,e[1]=o,e[2]=l):l=e[2];const c=l;let d;e[3]!==c?(d=c.filter(pK).map(gK),e[3]=c,e[4]=d):d=e[4];const u=d;if(s&&0===c.length){let t;return e[5]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(ta,{size:"medium",centered:!0}),e[5]=t):t=e[5],t}if(i){let t;return e[6]!==i?(t=_.jsx(Ua,{error:i}),e[6]=i,e[7]=t):t=e[7],t}if(0===c.length){let t;return e[8]===Symbol.for("react.memo_cache_sentinel")?(t=_.jsx(gO,{title:"No environment variables",description:"No environment variables are available in this notebook.",icon:_.jsx(Kd,{})}),e[8]=t):t=e[8],t}let h,f,m,p,g,y,b;return e[9]!==n||e[10]!==t||e[11]!==u||e[12]!==a?(h=()=>t(_.jsx(Nf,{providerNames:u,onSuccess:()=>{a(),n()},onClose:n})),e[9]=n,e[10]=t,e[11]=u,e[12]=a,e[13]=h):h=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(f=_.jsx(ss,{className:"h-4 w-4"}),e[14]=f):f=e[14],e[15]!==h?(m=_.jsx("div",{className:"flex justify-end h-8 border-b",children:_.jsx("button",{type:"button",className:"float-right border-l px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:h,children:f})}),e[15]=h,e[16]=m):m=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(p=_.jsx(Ia,{children:_.jsxs(Aa,{children:[_.jsx(Ta,{children:"Environment Variable"}),_.jsx(Ta,{children:"Source"}),_.jsx(Ta,{})]})}),e[17]=p):p=e[17],e[18]!==c?(g=c.map(yK),e[18]=c,e[19]=g):g=e[19],e[20]!==g?(y=_.jsxs(_a,{className:"overflow-auto flex-1 mb-16",children:[p,_.jsx(Da,{children:g})]}),e[20]=g,e[21]=y):y=e[21],e[22]!==m||e[23]!==y?(b=_.jsxs("div",{className:"flex flex-col h-full",children:[m,y]}),e[22]=m,e[23]=y,e[24]=b):b=e[24],b},fK=e=>{const t=N.c(9),{className:n,ariaLabel:r,onCopy:o}=e,[s,i]=p.useState(!1);let a;t[0]!==o?(a=()=>{o(),i(!0),setTimeout((()=>i(!1)),1e3)},t[0]=o,t[1]=a):a=t[1];const l=a;let c,d;return t[2]!==s?(c=s?_.jsx(pn,{className:"w-3 h-3 text-green-700 rounded"}):_.jsx(ut,{className:"w-3 h-3 hover:bg-muted rounded"}),t[2]=s,t[3]=c):c=t[3],t[4]!==r||t[5]!==n||t[6]!==l||t[7]!==c?(d=_.jsx("button",{type:"button",className:n,onClick:l,"aria-label":r,children:c}),t[4]=r,t[5]=n,t[6]=l,t[7]=c,t[8]=d):d=t[8],d};async function mK(){return Cf((await Oc.request({})).secrets)}function pK(e){return"env"!==e.provider}function gK(e){return e.name}function yK(e){return e.keys.map((t=>_.jsxs(Aa,{className:"group",children:[_.jsx(Oa,{children:t}),_.jsx(Oa,{children:"env"!==e.provider&&_.jsx(ga,{variant:"outline",className:"select-none",children:e.name})}),_.jsx(Oa,{children:_.jsx(fK,{ariaLabel:`Copy ${t}`,onCopy:async()=>{await Me(`os.environ["${t}"]`),se({title:"Copied to clipboard",description:`os.environ["${t}"] has been copied to your clipboard.`})},className:$t("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible")})})]},`${e.name}-${t}`)))}const bK=p.lazy((()=>dl((()=>import("./terminal-mbvW7Xk5.js")),__vite__mapDeps([125,2,3,126]),import.meta.url))),xK=e=>{const t=N.c(119),{children:n}=e,{isSidebarOpen:r,isTerminalOpen:o,selectedPanel:s}=cn(),{setIsSidebarOpen:i,setIsTerminalOpen:a}=ln(),c=p.useRef(null),d=p.useRef(null);let u,h,f,m,g;t[0]!==r?(u=()=>{if(!c.current)return;const e=c.current.isCollapsed();r&&e&&c.current.expand(),r||e||c.current.collapse(),requestAnimationFrame(wK)},h=[r],t[0]=r,t[1]=u,t[2]=h):(u=t[1],h=t[2]),l.useEffect(u,h),t[3]!==o?(f=()=>{if(!d.current)return;const e=d.current.isCollapsed();o&&e&&d.current.expand(),o||e||d.current.collapse(),requestAnimationFrame(SK)},m=[o],t[3]=o,t[4]=f,t[5]=m):(f=t[4],m=t[5]),l.useEffect(f,m),t[6]!==n?(g=_.jsx(_M,{id:"app",className:"relative h-full",children:_.jsx(l.Suspense,{children:n})},"app"),t[6]=n,t[7]=g):g=t[7];const y=g,b=CK,x=r?"resize-handle":"resize-handle-collapsed";let v,w;t[8]!==x?(v=$t("border-border no-print z-10",x,"vertical"),t[8]=x,t[9]=v):v=t[9],t[10]!==v?(w=_.jsx(zD,{onDragging:b,className:v}),t[10]=v,t[11]=w):w=t[11];const k=w,S=o?"resize-handle":"resize-handle-collapsed";let C,E;t[12]!==S?(C=$t("border-border no-print z-20",S,"horizontal"),t[12]=S,t[13]=C):C=t[13],t[14]!==C?(E=_.jsx(zD,{onDragging:b,className:C}),t[14]=C,t[15]=E):E=t[15];const j=E;let I,A,T,M,D,O,R,P,L,F,z,B,U,$,V,H,W,G,q,Y,K;t[16]!==s?(I=_.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:s}),t[16]=s,t[17]=I):I=t[17],t[18]!==i?(A=()=>i(!1),t[18]=i,t[19]=A):A=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(T=_.jsx(Gn,{className:"w-4 h-4"}),t[20]=T):T=t[20],t[21]!==A?(M=_.jsx(ee,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:A,children:T}),t[21]=A,t[22]=M):M=t[22],t[23]!==I||t[24]!==M?(D=_.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[I,M]}),t[23]=I,t[24]=M,t[25]=D):D=t[25],t[26]!==s?(O="files"===s&&_.jsx(V$,{}),t[26]=s,t[27]=O):O=t[27],t[28]!==s?(R="errors"===s&&_.jsx(yO,{}),t[28]=s,t[29]=R):R=t[29],t[30]!==s?(P="variables"===s&&_.jsx(s$,{}),t[30]=s,t[31]=P):P=t[31],t[32]!==s?(L="dependencies"===s&&_.jsx(QU,{}),t[32]=s,t[33]=L):L=t[33],t[34]!==s?(F="packages"===s&&_.jsx(IV,{}),t[34]=s,t[35]=F):F=t[35],t[36]!==s?(z="outline"===s&&_.jsx(xO,{}),t[36]=s,t[37]=z):z=t[37],t[38]!==s?(B="datasources"===s&&_.jsx(wV,{}),t[38]=s,t[39]=B):B=t[39],t[40]!==s?(U="documentation"===s&&_.jsx(h$,{}),t[40]=s,t[41]=U):U=t[41],t[42]!==s?($="snippets"===s&&_.jsx(Y$,{}),t[42]=s,t[43]=$):$=t[43],t[44]!==s?(V="scratchpad"===s&&_.jsx(_V,{}),t[44]=s,t[45]=V):V=t[45],t[46]!==s?(H="chat"===s&&_.jsx(eK,{}),t[46]=s,t[47]=H):H=t[47],t[48]!==s?(W="logs"===s&&_.jsx(a$,{}),t[48]=s,t[49]=W):W=t[49],t[50]!==s?(G="tracing"===s&&_.jsx(dK,{}),t[50]=s,t[51]=G):G=t[51],t[52]!==s?(q="secrets"===s&&_.jsx(hK,{}),t[52]=s,t[53]=q):q=t[53],t[54]!==O||t[55]!==R||t[56]!==P||t[57]!==L||t[58]!==F||t[59]!==z||t[60]!==B||t[61]!==U||t[62]!==$||t[63]!==V||t[64]!==H||t[65]!==W||t[66]!==G||t[67]!==q?(Y=_.jsx(l.Suspense,{children:_.jsxs(Yi,{children:[O,R,P,L,F,z,B,U,$,V,H,W,G,q]})}),t[54]=O,t[55]=R,t[56]=P,t[57]=L,t[58]=F,t[59]=z,t[60]=B,t[61]=U,t[62]=$,t[63]=V,t[64]=H,t[65]=W,t[66]=G,t[67]=q,t[68]=Y):Y=t[68],t[69]!==D||t[70]!==Y?(K=_.jsx(tr,{children:_.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[D,Y]})}),t[69]=D,t[70]=Y,t[71]=K):K=t[71];const J=K,X=r&&"border-r border-l border-[var(--slate-7)]";let Z,Q,te,ne,re,oe;t[72]!==X?(Z=$t("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",X),t[72]=X,t[73]=Z):Z=t[73],t[74]===Symbol.for("react.memo_cache_sentinel")?(Q=(e,t)=>{var n;0===t&&10===e&&(null==(n=c.current)||n.resize(30))},t[74]=Q):Q=t[74],t[75]!==i?(te=()=>i(!1),ne=()=>i(!0),t[75]=i,t[76]=te,t[77]=ne):(te=t[76],ne=t[77]),t[78]!==J||t[79]!==k?(re=_.jsxs("span",{className:"flex flex-row h-full",children:[J," ",k]}),t[78]=J,t[79]=k,t[80]=re):re=t[80],t[81]!==Z||t[82]!==te||t[83]!==ne||t[84]!==re?(oe=_.jsx(_M,{ref:c,id:"helper",collapsedSize:0,collapsible:!0,className:Z,minSize:10,defaultSize:0,maxSize:75,onResize:Q,onCollapse:te,onExpand:ne,children:re},"helper"),t[81]=Z,t[82]=te,t[83]=ne,t[84]=re,t[85]=oe):oe=t[85];const se=oe,ie=o&&"border-[var(--slate-7)]";let ae,le,ce,de,ue,he,fe,me;t[86]!==ie?(ae=$t("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",ie),t[86]=ie,t[87]=ae):ae=t[87],t[88]===Symbol.for("react.memo_cache_sentinel")?(le=(e,t)=>{var n;0===t&&10===e&&(null==(n=d.current)||n.resize(30))},t[88]=le):le=t[88],t[89]!==a?(ce=()=>a(!1),de=()=>a(!0),t[89]=a,t[90]=ce,t[91]=de):(ce=t[90],de=t[91]),t[92]!==a?(ue=()=>a(!1),t[92]=a,t[93]=ue):ue=t[93],t[94]!==o||t[95]!==ue?(he=_.jsx(bK,{visible:o,onClose:ue}),t[94]=o,t[95]=ue,t[96]=he):he=t[96],t[97]!==o||t[98]!==he?(fe=_.jsx(kV,{isOpen:o,children:he}),t[97]=o,t[98]=he,t[99]=fe):fe=t[99],t[100]!==ae||t[101]!==ce||t[102]!==de||t[103]!==fe||t[104]!==j?(me=_.jsxs(_M,{ref:d,id:"terminal",collapsedSize:0,collapsible:!0,className:ae,minSize:10,defaultSize:0,maxSize:75,onResize:le,onCollapse:ce,onExpand:de,children:[j,fe]},"terminal"),t[100]=ae,t[101]=ce,t[102]=de,t[103]=fe,t[104]=j,t[105]=me):me=t[105];const pe=me;let ge,ye,be,xe,ve,we,ke;return t[106]===Symbol.for("react.memo_cache_sentinel")?(ge={getItem:e=>pO||(pO??null),setItem(e,t){pO=t||null}},t[106]=ge):ge=t[106],t[107]===Symbol.for("react.memo_cache_sentinel")?(ye=_.jsx(Yi,{children:_.jsx(cO,{})}),t[107]=ye):ye=t[107],t[108]!==pe?(be=_.jsx(rO,{capability:"terminal",children:pe}),t[108]=pe,t[109]=be):be=t[109],t[110]!==y||t[111]!==be?(xe=_.jsx(_M,{children:_.jsxs(PD,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[y,be]})}),t[110]=y,t[111]=be,t[112]=xe):xe=t[112],t[113]!==se||t[114]!==xe?(ve=_.jsxs(PD,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:ge,children:[ye,se,xe]}),t[113]=se,t[114]=xe,t[115]=ve):ve=t[115],t[116]===Symbol.for("react.memo_cache_sentinel")?(we=_.jsx(tr,{children:_.jsx(Yi,{children:_.jsx(oO,{})})}),t[116]=we):we=t[116],t[117]!==ve?(ke=_.jsxs("div",{className:"flex flex-col flex-1 overflow-hidden absolute inset-0 print:relative",children:[ve,we]}),t[117]=ve,t[118]=ke):ke=t[118],ke};function vK(){window.dispatchEvent(new Event("resize"))}function wK(){requestAnimationFrame(vK)}function kK(){window.dispatchEvent(new Event("resize"))}function SK(){requestAnimationFrame(kK)}function CK(e){e||window.dispatchEvent(new Event("resize"))}const NK="false"===new URL(window.location.href).searchParams.get(si.showChrome),EK=Object.freeze(Object.defineProperty({__proto__:null,default:e=>{const t=N.c(10);if(NK){let n,r,o;return t[0]!==e?(n=_.jsx(nM,{hideControls:!0,...e}),t[0]=e,t[1]=n):n=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(vh,{}),t[2]=r):r=t[2],t[3]!==n?(o=_.jsxs(_.Fragment,{children:[n,r]}),t[3]=n,t[4]=o):o=t[4],o}let n,r,o;return t[5]!==e?(n=_.jsx(nM,{...e}),t[5]=e,t[6]=n):n=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(r=_.jsx(vh,{}),t[7]=r):r=t[7],t[8]!==n?(o=_.jsxs(xK,{children:[n,r]}),t[8]=n,t[9]=o):o=t[9],o}},Symbol.toStringTag,{value:"Module"}));export{i$ as C,dw as E,gO as P,Nd as a,EK as e,hw as f,m$ as u};