@marimo-team/frontend 0.14.17-dev13 → 0.14.17-dev33

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 (97) hide show
  1. package/dist/assets/{ConnectedDataExplorerComponent-CgW-m6YR.js → ConnectedDataExplorerComponent-9KtMofOB.js} +1 -1
  2. package/dist/assets/{ImageComparisonComponent-C2dtckhh.js → ImageComparisonComponent-bSOOoc37.js} +1 -1
  3. package/dist/assets/{VegaLite-uAoiyfLQ.js → VegaLite-Cd6eJIzz.js} +1 -1
  4. package/dist/assets/{_baseEach-ZE9AMpSU.js → _baseEach-Cgi4FNGp.js} +1 -1
  5. package/dist/assets/_baseMap-QO-iXrLM.js +1 -0
  6. package/dist/assets/{_baseUniq-DdHtPsXj.js → _baseUniq-C4IYFvPL.js} +1 -1
  7. package/dist/assets/{_createAggregator-BIy4_sE9.js → _createAggregator-CaI6CBu9.js} +1 -1
  8. package/dist/assets/{any-language-editor-COZ8vBu5.js → any-language-editor-C1-XOXvT.js} +1 -1
  9. package/dist/assets/{architectureDiagram-SUXI7LT5-CR5yu87_.js → architectureDiagram-SUXI7LT5-D4MpYvy9.js} +1 -1
  10. package/dist/assets/{blockDiagram-6J76NXCF-DqKfOhO0.js → blockDiagram-6J76NXCF-43bvjTpE.js} +1 -1
  11. package/dist/assets/{c4Diagram-6F6E4RAY-BQjWgLmY.js → c4Diagram-6F6E4RAY-GWtJZLve.js} +1 -1
  12. package/dist/assets/channel-CEOashIq.js +1 -0
  13. package/dist/assets/{chunk-353BL4L5-CFDTVJhH.js → chunk-353BL4L5-CiCS15pl.js} +1 -1
  14. package/dist/assets/{chunk-67H74DCK-VhZRabDn.js → chunk-67H74DCK-B67vD_N3.js} +1 -1
  15. package/dist/assets/{chunk-AACKK3MU-Dk_at3YA.js → chunk-AACKK3MU-D3mddDq4.js} +1 -1
  16. package/dist/assets/{chunk-BFAMUDN2-h9xem7x_.js → chunk-BFAMUDN2-H5YbZXAk.js} +1 -1
  17. package/dist/assets/{chunk-E2GYISFI-DF98TFRL.js → chunk-E2GYISFI-ZQxFpRvf.js} +1 -1
  18. package/dist/assets/{chunk-OW32GOEJ-7u1X00FD.js → chunk-OW32GOEJ-CZY3TLnL.js} +1 -1
  19. package/dist/assets/{chunk-SKB7J2MH-BbttyZen.js → chunk-SKB7J2MH-B_rSt2ZS.js} +1 -1
  20. package/dist/assets/{chunk-SZ463SBG-Covo2rsE.js → chunk-SZ463SBG-C99ji8O5.js} +1 -1
  21. package/dist/assets/{circle-play-B3mgDKeP.js → circle-play-D18XSqlX.js} +1 -1
  22. package/dist/assets/classDiagram-M3E45YP4-DjAqKD4f.js +1 -0
  23. package/dist/assets/classDiagram-v2-YAWTLIQI-DjAqKD4f.js +1 -0
  24. package/dist/assets/clone-BK3AmMpN.js +1 -0
  25. package/dist/assets/{compile-C0Bg4TiA.js → compile-BfcLZqJI.js} +1 -1
  26. package/dist/assets/{dagre-JOIXM2OF-Bw0Tnf6w.js → dagre-JOIXM2OF-DHC4-3gA.js} +1 -1
  27. package/dist/assets/{data-grid-overlay-editor-TJG-GTGY.js → data-grid-overlay-editor-B3CKmB66.js} +1 -1
  28. package/dist/assets/{diagram-5UYTHUR4-BAO5fC6Y.js → diagram-5UYTHUR4-DF45goIs.js} +1 -1
  29. package/dist/assets/{diagram-VMROVX33-DQ_kKkkq.js → diagram-VMROVX33-CINWTJ4W.js} +1 -1
  30. package/dist/assets/{diagram-ZTM2IBQH-TUQKXzuI.js → diagram-ZTM2IBQH-CKkHFfZG.js} +1 -1
  31. package/dist/assets/edit-page-BzSvzY9d.js +148 -0
  32. package/dist/assets/{erDiagram-3M52JZNH-Dd_alZr8.js → erDiagram-3M52JZNH-B40CHv2S.js} +1 -1
  33. package/dist/assets/{flowDiagram-KYDEHFYC-CHY9eEr-.js → flowDiagram-KYDEHFYC-DEuJDVcg.js} +1 -1
  34. package/dist/assets/{ganttDiagram-EK5VF46D-DT8nsrvw.js → ganttDiagram-EK5VF46D-Dx1VoHGj.js} +1 -1
  35. package/dist/assets/{gitGraphDiagram-GW3U2K7C-8IuoFxxw.js → gitGraphDiagram-GW3U2K7C-bWRS1xbC.js} +1 -1
  36. package/dist/assets/{glide-data-editor-Bg_LgY6L.js → glide-data-editor-Dr9kVXyU.js} +4 -4
  37. package/dist/assets/{graph-KISq2l_H.js → graph-Bdh0OPOA.js} +1 -1
  38. package/dist/assets/{home-page-Anjt2rzZ.js → home-page-skkC73Qf.js} +1 -1
  39. package/dist/assets/{index-gcTqjUpZ.js → index-4b2-0YJU.js} +1 -1
  40. package/dist/assets/{index-DQBOjJaq.js → index-B1a8EFVn.js} +130 -130
  41. package/dist/assets/{index-D5AYgsjz.js → index-BdmWycvn.js} +1 -1
  42. package/dist/assets/{index-CaaYw831.js → index-BeAScruc.js} +1 -1
  43. package/dist/assets/{index-CzMMvqbC.js → index-BsPaH1qX.js} +1 -1
  44. package/dist/assets/{index-Cz0Czo4u.js → index-C3P2YWrR.js} +1 -1
  45. package/dist/assets/{index-Dwr7cpoq.js → index-CKH5aUT7.js} +1 -1
  46. package/dist/assets/{index-DlcLC-KS.js → index-CVFA24vV.js} +1 -1
  47. package/dist/assets/{index-T63CqPBW.js → index-CqyXO7I6.js} +1 -1
  48. package/dist/assets/{index-DK8nvYXV.js → index-Cs9dJOS9.js} +1 -1
  49. package/dist/assets/{index-BYueSq_t.js → index-DAjN5Ppm.js} +1 -1
  50. package/dist/assets/{index-_qwxdYob.js → index-D_nfSav3.js} +1 -1
  51. package/dist/assets/{index-Ba-4NFyt.js → index-Da7Uag8h.js} +1 -1
  52. package/dist/assets/{index-CGLOpJQC.js → index-DhZxMKbQ.js} +1 -1
  53. package/dist/assets/{index-TaRScTng.js → index-DqRUCQ6K.js} +1 -1
  54. package/dist/assets/{index-Dzrqf-25.js → index-Y4Tere19.js} +1 -1
  55. package/dist/assets/{index-C0wVJJgB.js → index-eCXf5fRn.js} +1 -1
  56. package/dist/assets/{index-Bffu0yRk.js → index-vGkKoMjm.js} +1 -1
  57. package/dist/assets/{index-D0RKjoS9.js → index-zaQlwulc.js} +1 -1
  58. package/dist/assets/infoDiagram-LHK5PUON-k9AsmX5a.js +2 -0
  59. package/dist/assets/{journeyDiagram-EWQZEKCU-DSCZYRLm.js → journeyDiagram-EWQZEKCU-CW9bdfu1.js} +1 -1
  60. package/dist/assets/{kanban-definition-ZSS6B67P-BiR2h68T.js → kanban-definition-ZSS6B67P-DggDlsAw.js} +1 -1
  61. package/dist/assets/{layout-Bt-oEHFo.js → layout-DZefkj35.js} +1 -1
  62. package/dist/assets/{linear-N02ZcVri.js → linear-BFRQ6hU1.js} +1 -1
  63. package/dist/assets/{links-BNvyHFtk.js → links-DCdjfErk.js} +2 -2
  64. package/dist/assets/{mermaid-Dal2C2K1.js → mermaid-BXOoaPps.js} +4 -4
  65. package/dist/assets/{min-77BOo96E.js → min-CookSAy9.js} +1 -1
  66. package/dist/assets/{mindmap-definition-6CBA2TL7-3ym71T1e.js → mindmap-definition-6CBA2TL7-CeOhtUUk.js} +1 -1
  67. package/dist/assets/{number-overlay-editor-B3HWHBVb.js → number-overlay-editor-CsSzDXf6.js} +1 -1
  68. package/dist/assets/{pieDiagram-NIOCPIFQ-BTIoURAj.js → pieDiagram-NIOCPIFQ-DTEQCbgC.js} +1 -1
  69. package/dist/assets/{quadrantDiagram-2OG54O6I-DDw0KGr3.js → quadrantDiagram-2OG54O6I-DhoL8SVt.js} +1 -1
  70. package/dist/assets/{react-plotly-DDyl9i43.js → react-plotly-pau-l3ec.js} +1 -1
  71. package/dist/assets/{requirementDiagram-QOLK2EJ7-Cck7S4rM.js → requirementDiagram-QOLK2EJ7-8Hqk6Tbu.js} +1 -1
  72. package/dist/assets/{run-page-BgTghANp.js → run-page-BBiLSoh7.js} +1 -1
  73. package/dist/assets/{sankeyDiagram-4UZDY2LN-CSK1Vk6S.js → sankeyDiagram-4UZDY2LN-DBt0c5cN.js} +1 -1
  74. package/dist/assets/{sequenceDiagram-SKLFT4DO-BiO5mcJU.js → sequenceDiagram-SKLFT4DO-BufMbI1V.js} +1 -1
  75. package/dist/assets/{slides-component-BIgjuHQ6.js → slides-component-CaoicUla.js} +1 -1
  76. package/dist/assets/{sortBy-cdRL-gQe.js → sortBy-Ba_59Lzu.js} +1 -1
  77. package/dist/assets/{stateDiagram-MI5ZYTHO-B6YvpXya.js → stateDiagram-MI5ZYTHO-CycgUXpN.js} +1 -1
  78. package/dist/assets/stateDiagram-v2-5AN5P6BG-CRT7xmEs.js +1 -0
  79. package/dist/assets/{storage-DQeEcyla.js → storage-SntoxCrv.js} +3 -3
  80. package/dist/assets/{terminal-DY_Rl00-.js → terminal-DrACt1mz.js} +1 -1
  81. package/dist/assets/{time-BlYu1ZY-.js → time-B3zMyx1p.js} +1 -1
  82. package/dist/assets/{timeline-definition-MYPXXCX6-zPmOL9k9.js → timeline-definition-MYPXXCX6-ByTMRZHJ.js} +1 -1
  83. package/dist/assets/{tracing-Bp8ya33S.js → tracing-XsxIot4u.js} +2 -2
  84. package/dist/assets/{trash--_qcSEIy.js → trash-9WGYvBsN.js} +1 -1
  85. package/dist/assets/{treemap-75Q7IDZK-BShdryah.js → treemap-75Q7IDZK-B2QtzDzJ.js} +1 -1
  86. package/dist/assets/{vega-component--vHx5Vin.js → vega-component-BtzJ0j5r.js} +1 -1
  87. package/dist/assets/{xychartDiagram-H2YORKM3-CIQCu7L2.js → xychartDiagram-H2YORKM3-cnRq2Q_I.js} +1 -1
  88. package/dist/index.html +1 -1
  89. package/package.json +1 -1
  90. package/dist/assets/_baseMap-DeKeDW2c.js +0 -1
  91. package/dist/assets/channel-D2xXwH0o.js +0 -1
  92. package/dist/assets/classDiagram-M3E45YP4-D2cg6_Gt.js +0 -1
  93. package/dist/assets/classDiagram-v2-YAWTLIQI-D2cg6_Gt.js +0 -1
  94. package/dist/assets/clone-C4yf2FaK.js +0 -1
  95. package/dist/assets/edit-page-BYtqQLGY.js +0 -148
  96. package/dist/assets/infoDiagram-LHK5PUON-BsAtSRNN.js +0 -2
  97. package/dist/assets/stateDiagram-v2-5AN5P6BG-uojc_0tM.js +0 -1
@@ -1,148 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./tracing-Bp8ya33S.js","./index-DQBOjJaq.js","./index-B-OhZVlA.css","./compile-C0Bg4TiA.js","./time-BlYu1ZY-.js","./timer-Bqd5yn_a.js","./linear-N02ZcVri.js","./init-DLRA0X12.js","./range-CtcPcB_L.js","./zoom-COrs4lFh.js","./ordinal-DDUp3AbE.js","./colors-bszWmPJw.js","./step-BwsUM5iJ.js","./arc-ZB5pDULS.js","./index-BEQfoZiP.js","./storage-DQeEcyla.js","./index-DK8nvYXV.js","./index-TaRScTng.js","./index-CzMMvqbC.js","./index-_qwxdYob.js","./index-C0wVJJgB.js","./index-CGLOpJQC.js","./index-Ba-4NFyt.js","./index-Bffu0yRk.js","./index-Dwr7cpoq.js","./index-D5AYgsjz.js","./index-Dzrqf-25.js","./index-T63CqPBW.js","./index-D0RKjoS9.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-DkEP81N9.js","./ebnf-B-Df8AvO.js","./ecl-DPFc0Uaf.js","./eiffel-DR5c0IrL.js","./elm-DompmV0j.js","./erlang-BuqgqA5h.js","./factor-CFXhaUWb.js","./fcl-CVaBTCzQ.js","./forth-POgR1ypr.js","./fortran-DL7KluxX.js","./gas-bV0CklSb.js","./gherkin-B6X1vGSW.js","./groovy-DnIzCrpZ.js","./haskell-CLQs6EAM.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-z_N2Mo3d.js","./mirc-DkvFAiy5.js","./modelica-DSrSSXCg.js","./mscgen-B2igx18G.js","./mumps-zvxmGV4l.js","./nginx-B4hAVlXN.js","./nsis-BvKfQ9lQ.js","./ntriples-BSwWqoLa.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-Bdo_Aemu.js","./swift-B_XXVlXX.js","./tcl-B2fODqDH.js","./textile-BuVhTOzU.js","./tiddlywiki-BgR6AEZu.js","./tiki-CI-ztowC.js","./toml-wcPdHu67.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","./trash--_qcSEIy.js","./storage-De8XnUVS.css","./links-BNvyHFtk.js","./index-CaaYw831.js","./links-C1rhMrxo.css","./circle-play-B3mgDKeP.js","./_createAggregator-BIy4_sE9.js","./_baseEach-ZE9AMpSU.js","./loro_wasm_bg-C3hKWL9L.js","./transform-CDNfLgV5.js","./sortBy-cdRL-gQe.js","./_baseMap-DeKeDW2c.js","./terminal-DY_Rl00-.js","./terminal-WqMRJt5Z.css"])))=>i.map(i=>d[i]);
2
- var J7=Object.defineProperty;var ck=Tt=>{throw TypeError(Tt)};var Z7=(Tt,vt,Zt)=>vt in Tt?J7(Tt,vt,{enumerable:!0,configurable:!0,writable:!0,value:Zt}):Tt[vt]=Zt;var Z=(Tt,vt,Zt)=>Z7(Tt,typeof vt!="symbol"?vt+"":vt,Zt),Q7=(Tt,vt,Zt)=>vt.has(Tt)||ck("Cannot "+Zt);var dk=(Tt,vt,Zt)=>(Q7(Tt,vt,"read from private field"),Zt?Zt.call(Tt):vt.get(Tt)),uk=(Tt,vt,Zt)=>vt.has(Tt)?ck("Cannot add the same private member more than once"):vt instanceof WeakSet?vt.add(Tt):vt.set(Tt,Zt);import{c as Ce,T as O,iH as e9,iI as t9,iJ as hk,iK as n9,dM as o9,dP as r9,b as G,dK as Rf,iL as ur,iM as s9,iN as Lf,iO as fk,iP as a9,iQ as i9,iR as mk,iS as zl,a as H,eN as l9,ac as Xe,j as c,a1 as On,a9 as $o,a8 as rs,aa as ss,bs as Vo,a6 as ke,ab as nn,iT as ja,a7 as Ho,aS as Dn,ad as Ca,at as Ne,ao as kt,e1 as Ff,eR as Ea,iU as c9,aN as Fe,S as it,iV as d9,f3 as mn,iW as pk,iX as gk,iY as Bl,iZ as xk,i_ as u9,L as ht,dC as Ul,aZ as Wo,i$ as $l,a$ as zf,ag as Jt,j0 as h9,aw as _a,j1 as f9,j2 as bk,f2 as yk,al as mt,b5 as vk,j3 as wk,cF as Vl,j4 as m9,dU as Qe,j5 as Hl,d$ as pn,j6 as kk,j7 as Ia,U as Ie,bd as jn,j8 as Wl,j9 as ql,eU as as,ja as p9,jb as Aa,jc as Sk,f0 as Nk,jd as Bf,je as Uf,eu as $f,jf as qn,jg as hr,aX as Gl,jh as g9,ji as Yl,jj as Kl,au as wo,ei as jk,av as Ta,jk as x9,jl as Xl,jm as qo,bu as fr,eV as mr,fC as Ck,gp as pr,fR as b9,bg as St,jn as y9,jo as v9,gl as Jl,aP as Zl,jp as Vf,jq as w9,jr as Ek,js as Hf,jt as k9,ju as Wf,jv as Gn,jw as _k,gn as qf,jx as Ma,jy as Ql,ez as dt,eB as is,jz as pt,jA as ze,jB as st,jC as Gf,jD as S9,jE as Yf,jF as gt,jG as Ik,dw as Oa,ds as Da,dt as Pa,du as Ra,dr as ls,jH as N9,fP as Kf,b4 as Pn,aJ as Cn,fF as Ak,fH as Tk,fI as j9,fN as C9,fJ as Mk,jI as Ok,ar as ge,et as E9,aV as ko,b2 as So,aW as No,b0 as It,f1 as on,jJ as Dk,fL as Pk,jK as _9,jL as I9,fD as Rk,fE as Lk,jM as cs,dv as Fk,jN as zk,jO as A9,jP as T9,a5 as M9,a4 as O9,jQ as Xf,dz as D9,dB as Jf,fq as ec,jR as tc,jS as nc,bx as gn,jT as P9,eY as La,fn as Yn,bl as Bk,e2 as Ft,jU as R9,eo as L9,a2 as Zf,jV as Fa,jW as oc,jX as F9,jY as z9,jZ as Uk,j_ as Ht,aY as B9,af as Qf,gr as $k,ev as rc,j$ as U9,gN as em,bk as sc,k0 as tm,a3 as $9,k1 as V9,ae as za,eO as Vk,bo as H9,k2 as W9,k3 as Hk,gY as q9,gW as G9,gZ as Y9,g_ as K9,k4 as nm,dx as jo,k5 as X9,k6 as ac,k7 as ds,q as Kn,o as Ve,g5 as Rn,k8 as xn,k9 as tt,ka as us,kb as At,gm as Ot,kc as om,ey as En,kd as J9,ke as rm,bi as Wk,bj as qk,kf as Gk,kg as Z9,gP as hs,kh as ic,bf as lc,gQ as gr,f4 as sm,ki as Q9,kj as eO,kk as tO,kl as nO,km as Yk,kn as Ba,ko as Kk,kp as am,kq as Xk,kr as Jk,ks as oO,kt as Zk,ku as Qk,f5 as fs,kv as rO,kw as Xn,kx as cc,ky as e3,kz as dc,dy as sO,gK as im,kA as Ua,kB as $a,kC as Va,kD as uc,kE as Go,kF as t3,kG as Co,kH as ms,kI as lm,kJ as Ha,kK as ps,kL as cm,kM as dm,kN as n3,kO as hc,kP as aO,ay as Wa,kQ as qa,kR as iO,d_ as fc,kS as lO,kT as um,kU as cO,kV as dO,kW as mc,e7 as uO,kX as hm,kY as xr,kZ as pc,k_ as gs,g4 as _n,gf as Eo,g0 as o3,cq as r3,k$ as fm,fO as s3,l0 as a3,l1 as Ga,l2 as i3,l3 as gc,l4 as mm,l5 as xs,l6 as Ya,l7 as Ka,l8 as hO,fY as xc,l9 as pm,la as bc,en as fO,fZ as mO,lb as pO,lc as gO,ld as xO,le as bO,u as yO,lf as vO,lg as wO,lh as kO,g8 as SO,li as NO,lj as l3,t as z,lk as jO,ll as CO,lm as EO,ln as _O,lo as IO,lp as AO,lq as TO,lr as MO,ls as OO,lt as DO,lu as PO,lv as RO,lw as LO,lx as FO,ly as zO,lz as BO,lA as UO,lB as $O,lC as VO,lD as HO,lE as WO,lF as qO,lG as Xa,lH as GO,lI as YO,lJ as KO,lK as XO,lL as JO,lM as ZO,lN as QO,lO as eD,lP as gm,lQ as yc,lR as c3,lS as tD,lT as nD,lU as d3,lV as oD,lW as bs,lX as In,lY as rD,lZ as sD,l_ as aD,l$ as iD,m0 as lD,m1 as cD,m2 as dD,m3 as uD,m4 as hD,m5 as fD,m6 as Yo,m7 as mD,m8 as pD,m9 as gD,ma as xD,e4 as bD,mb as yD,mc as u3,e8 as vD,md as vc,me as wD,mf as kD,mg as SD,mh as ND,g$ as Ko,mi as wc,mj as jD,mk as CD,ml as h3,mm as xm,gO as ys,mn as ED,mo as _D,mp as ID,mq as AD,gd as TD,br as MD,an as bm,mr as f3,ms as OD,mt as DD,mu as ym,mv as vm,mw as PD,mx as m3,my as p3,mz as kc,f$ as RD,Y as g3,dS as LD,mA as x3,fA as yt,mB as Ja,mC as vs,mD as FD,mE as zD,mF as BD,mG as UD,cp as wm,mH as $D,am as Xo,bh as b3,mI as VD,mJ as HD,mK as WD,mL as Sc,mM as y3,dQ as Nc,bt as v3,eA as qD,mN as w3,mO as k3,mP as S3,mQ as GD,mR as N3,mS as j3,mT as jc,mU as YD,mV as C3,mW as KD,mX as XD,mY as E3,Z as Cc,mZ as JD,bv as _3,m_ as ZD,as as _o,eX as QD,m$ as Io,n0 as eP,er as I3,e$ as A3,e_ as T3,fS as Ec,n1 as km,n2 as M3,aU as Sm,es as _c,n3 as O3,n4 as tP,n5 as nP,n6 as D3,fz as oP,n7 as rP,gF as sP,fG as aP,fK as Nm,gI as iP,bq as Za,n8 as lP,n9 as P3,na as jm,nb as cP,nc as dP,nd as uP,_ as bn,ew as hP,ne as fP,nf as mP,ng as R3,fs as Cm,dE as L3,nh as pP,ni as gP,nj as xP,aO as bP,nk as yP,nl as vP,nm as wP,nn as kP,V as SP,no as Ic,X as NP,fo as jP,np as F3,fW as CP,nq as EP,gv as _P,nr as IP,ns as z3,nt as AP,nu as ws,nv as TP,nw as Ac,nx as MP,ny as OP,nz as DP,z as B3,gU as PP,nA as Qa,nB as U3,nC as $3,nD as V3,nE as H3,nF as RP,C as W3,nG as LP,nH as FP,nI as zP,nJ as BP,E as br,fa as q3,be as UP,bc as $P,nK as VP,nL as HP,aq as Tc,nM as WP,dH as G3,nN as Em,nO as qP,e0 as Y3,nP as GP,nQ as _m,nR as YP,nS as KP,nT as XP,nU as K3,nV as X3,nW as J3,fm as Z3,nX as JP,nY as ZP,nZ as Q3,n_ as eS,n$ as Mc,o0 as tS,o1 as nS,o2 as QP,o3 as oS,o4 as eR,o5 as tR,o6 as rS,o7 as nR,o8 as oR,o9 as rR,oa as sR,ob as aR,oc as iR,dZ as lR,od as cR,oe as dR,ge as Im,of as uR,og as hR,oh as fR,oi as mR,oj as pR,ok as gR,ol as xR,om as bR,on as yR,oo as vR,op as Am,oq as wR,g2 as kR,or as SR,os as NR,ot as jR,ou as sS,ov as CR,ax as ER,ow as _R,ap as IR,eQ as AR,gy as TR,ox as MR,oy as OR,gA as Tm,gw as ks,gB as yr,gx as vr,gC as Mm,gD as Om,oz as aS,gz as DR,oA as iS,oB as PR,oC as lS,oD as Jo,oE as cS,gH as RR,oF as LR,oG as FR,oH as zR,oI as BR,oJ as UR,oK as $R,oL as dS,eF as VR,oM as Dm,oN as HR,ah as Oc,oO as uS,oP as hS,aj as fS,ai as WR,dY as qR,__tla as GR}from"./index-DQBOjJaq.js";import{b as Ss,A as YR,L as mS,g as KR,G as XR,o as pS,s as JR,k as ZR,B as gS,a as QR,M as eL,Y as tL,c as rn,u as ei,C as nL,S as oL,K as rL,d as sL,i as aL,e as xS,f as iL,h as lL,j as ti,P as ni,l as bS,m as cL,n as dL,p as uL,D as Ns,q as hL,r as yS,t as Pm,T as fL}from"./links-BNvyHFtk.js";import{V as vS,d as wr,I as Rm,N as wS,S as kS,e as SS,f as NS,L as jS,g as CS,F as ES,M as mL,l as _S,h as pL,E as Dc,i as gL,j as Lm,k as Fm,n as xL,o as bL,p as yL,q as vL,s as wL,t as kL,v as SL,w as NL,u as jL,C as CL,R as IS,A as EL,a as _L,T as IL,x as AL,y as TL,m as ML,z as OL,B as DL,O as PL,c as RL,P as LL,__tla as FL}from"./storage-DQeEcyla.js";import{c as zL}from"./_createAggregator-BIy4_sE9.js";import{_ as AS,a as TS,i as BL,w as UL,L as MS,A as $L,C as OS,b as zm,c as DS,__tla as VL}from"./loro_wasm_bg-C3hKWL9L.js";import{s as Ln,i as Zo,T as Bm,a as Um}from"./transform-CDNfLgV5.js";import{g as PS}from"./timer-Bqd5yn_a.js";import{i as HL}from"./zoom-COrs4lFh.js";import{s as oi}from"./sortBy-cdRL-gQe.js";let $m,Pc,sn,Rc,RS,js,WL=Promise.all([(()=>{try{return GR}catch{}})(),(()=>{try{return FL}catch{}})(),(()=>{try{return VL}catch{}})()]).then(async()=>{var Fl,ak;var Tt=zL(function(t,e,n){t[n?0:1].push(e)},function(){return[[],[]]});let vt,Zt,Vm,Lc,Cs,kr,Fc,zc,Hm,Wm,ri,Bc,qm,si,Gm,Uc,Ym,Km,$c,Xm,Jm,Zm,ai,Qm,Vc,ep,tp,np,op,rp,sp,Hc,ap,Wc,qc,ip,lp,cp,dp,up,hp,ii,fp,mp,Gc,pp,gp,xp,Yc,bp,yp,vp,li,Kc,Xc,wp,kp,Sp,Np,jp,Cp,Ep,_p,Ip,Jc,Zc,Ap,Tp,Mp,ci,an,ln;vt=Ce("arrow-left",[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]]),Zt=Ce("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"}]]),Vm=Ce("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"}]]),Lc=Ce("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]),Cs=Ce("ban",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m4.9 4.9 14.2 14.2",key:"1m5liu"}]]),kr=Ce("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"}]]),Fc=Ce("chevrons-down",[["path",{d:"m7 6 5 5 5-5",key:"1lc07p"}],["path",{d:"m7 13 5 5 5-5",key:"1d48rs"}]]),zc=Ce("chevrons-up",[["path",{d:"m17 11-5-5-5 5",key:"e8nh98"}],["path",{d:"m17 18-5-5-5 5",key:"2avn1x"}]]),Rc=Ce("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]),Hm=Ce("circle-chevron-down",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m16 10-4 4-4-4",key:"894hmk"}]]),Wm=Ce("circle-chevron-right",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m10 8 4 4-4 4",key:"1wy4r4"}]]),ri=Ce("circle-plus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),Bc=Ce("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"}]]),qm=Ce("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"}]]),si=Ce("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"}]]),Gm=Ce("code",[["path",{d:"m16 18 6-6-6-6",key:"eg8j8"}],["path",{d:"m8 6-6 6 6 6",key:"ppft3o"}]]),Uc=Ce("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"}]]),Ym=Ce("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"}]]),Km=Ce("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"}]]),$c=Ce("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"}]]),Xm=Ce("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]),Jm=Ce("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"}]]),Zm=Ce("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"}]]),ai=Ce("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"}]]),Qm=Ce("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"}]]),Vc=Ce("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"}]]),ep=Ce("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"}]]),tp=Ce("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"}]]),np=Ce("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"}]]),op=Ce("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"}]]),rp=Ce("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"}]]),sp=Ce("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"}]]),Hc=Ce("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"}]]),ap=Ce("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"}]]),Wc=Ce("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"}]]),qc=Ce("list-tree",[["path",{d:"M21 12h-8",key:"1bmf0i"}],["path",{d:"M21 6H8",key:"1pqkrb"}],["path",{d:"M21 18h-8",key:"1tm79t"}],["path",{d:"M3 6v4c0 1.1.9 2 2 2h3",key:"1ywdgy"}],["path",{d:"M3 10v6c0 1.1.9 2 2 2h3",key:"2wc746"}]]),ip=Ce("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"}]]),lp=Ce("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"}]]),cp=Ce("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]),dp=Ce("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"}]]),up=Ce("message-circle-question-mark",[["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"}]]),hp=Ce("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"}]]),ii=Ce("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"}]]),fp=Ce("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"}]]),mp=Ce("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"}]]),Gc=Ce("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"}]]),pp=Ce("panel-left",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}]]),gp=Ce("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"}]]),xp=Ce("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"}]]),Yc=Ce("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"}]]),bp=Ce("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"}]]),yp=Ce("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"}]]),vp=Ce("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"}]]),li=Ce("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"}]]),Kc=Ce("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"}]]),Xc=Ce("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"}]]),wp=Ce("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"}]]),kp=Ce("square-code",[["path",{d:"m10 9-3 3 3 3",key:"1oro0q"}],["path",{d:"m14 15 3-3-3-3",key:"bz13h7"}],["rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",key:"h1oib"}]]),Sp=Ce("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"}]]),Np=Ce("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"}]]),jp=Ce("square-m",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M8 16V8l4 4 4-4v8",key:"141u4e"}]]),Cp=Ce("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"}]]),Ep=Ce("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"}]]),_p=Ce("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"}]]),Ip=Ce("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"}]]),Jc=Ce("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"}]]),Zc=Ce("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"}]]),Ap=Ce("users",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["path",{d:"M16 3.128a4 4 0 0 1 0 7.744",key:"16gr8j"}],["path",{d:"M22 21v-2a4 4 0 0 0-3-3.87",key:"kshegd"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}]]),Tp=Ce("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"}]]),Mp=Ce("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"}]]),ci=Ce("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"}]]),an=Ce("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"}]]),ln=Ce("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 LS=O.createContext({}),FS=O.forwardRef(function(t,e){[t,e]=o9(t,e,LS);let{toolbarProps:n}=function(s,a){const{"aria-label":i,"aria-labelledby":l,orientation:d="horizontal"}=s;let[u,h]=O.useState(!1);e9(()=>{var p;h(!(!a.current||!(!((p=a.current.parentElement)===null||p===void 0)&&p.closest('[role="toolbar"]'))))});const{direction:f}=t9(),m=f==="rtl"&&d==="horizontal";let x=n9(a);const g=O.useRef(null);return{toolbarProps:{...hk(s,{labelable:!0}),role:u?"group":"toolbar","aria-orientation":d,"aria-label":i,"aria-labelledby":i==null?l:void 0,onKeyDownCapture:u?void 0:p=>{if(p.currentTarget.contains(p.target)){if(d==="horizontal"&&p.key==="ArrowRight"||d==="vertical"&&p.key==="ArrowDown")m?x.focusPrevious():x.focusNext();else{if(!(d==="horizontal"&&p.key==="ArrowLeft"||d==="vertical"&&p.key==="ArrowUp"))return p.key==="Tab"?(p.stopPropagation(),g.current=document.activeElement,void(p.shiftKey?x.focusFirst():x.focusLast())):void 0;m?x.focusNext():x.focusPrevious()}p.stopPropagation(),p.preventDefault()}},onFocusCapture:u?void 0:p=>{var b,y;g.current&&!p.currentTarget.contains(p.relatedTarget)&&(!((b=a.current)===null||b===void 0)&&b.contains(p.target))&&((y=g.current)===null||y===void 0||y.focus(),g.current=null)},onBlurCapture:u?void 0:p=>{p.currentTarget.contains(p.relatedTarget)||g.current||(g.current=p.target)}}}}(t,e),o=r9({...t,values:{orientation:t.orientation||"horizontal"},defaultClassName:"react-aria-Toolbar"}),r=hk(t);return delete r.id,G.createElement("div",{...Rf(n,r),...o,ref:e,slot:t.slot||void 0,"data-orientation":t.orientation||"horizontal"},o.children)});function di(t,e){const n=+ur(t)-+ur(e);return n<0?-1:n>0?1:n}function zS(t,e){const n=ur(t,e==null?void 0:e.in);return+function(o,r){const s=ur(o,r==null?void 0:r.in);return s.setHours(23,59,59,999),s}(n,e)==+function(o,r){const s=ur(o,r==null?void 0:r.in),a=s.getMonth();return s.setFullYear(s.getFullYear(),a+1,0),s.setHours(23,59,59,999),s}(n,e)}function BS(t,e,n){const[o,r,s]=Lf(n==null?void 0:n.in,t,t,e),a=di(r,s),i=Math.abs(function(u,h,f){const[m,x]=Lf(f==null?void 0:f.in,u,h);return 12*(m.getFullYear()-x.getFullYear())+(m.getMonth()-x.getMonth())}(r,s));if(i<1)return 0;r.getMonth()===1&&r.getDate()>27&&r.setDate(30),r.setMonth(r.getMonth()-a*i);let l=di(r,s)===-a;zS(o)&&i===1&&di(o,s)===1&&(l=!1);const d=a*(i-+l);return d===0?0:d}function US(t,e,n){const o=function(r,s){return+ur(r)-+ur(s)}(t,e)/1e3;return(r=>{const s=(0,Math.trunc)(r);return s===0?0:s})(o)}function $S(t,e){return function(n,o,r){const s=a9(),a=(r==null?void 0:r.locale)??s.locale??i9,i=di(n,o);if(isNaN(i))throw new RangeError("Invalid time value");const l=Object.assign({},r,{addSuffix:r==null?void 0:r.addSuffix,comparison:i}),[d,u]=Lf(r==null?void 0:r.in,...i>0?[o,n]:[n,o]),h=US(u,d),f=(fk(u)-fk(d))/1e3,m=Math.round((h-f)/60);let x;if(m<2)return m===0?a.formatDistance("lessThanXMinutes",1,l):a.formatDistance("xMinutes",m,l);if(m<45)return a.formatDistance("xMinutes",m,l);if(m<90)return a.formatDistance("aboutXHours",1,l);if(m<mk){const g=Math.round(m/60);return a.formatDistance("aboutXHours",g,l)}if(m<2520)return a.formatDistance("xDays",1,l);if(m<zl){const g=Math.round(m/mk);return a.formatDistance("xDays",g,l)}if(m<2*zl)return x=Math.round(m/zl),a.formatDistance("aboutXMonths",x,l);if(x=BS(u,d),x<12){const g=Math.round(m/zl);return a.formatDistance("xMonths",g,l)}{const g=x%12,p=Math.trunc(x/12);return g<3?a.formatDistance("aboutXYears",p,l):g<9?a.formatDistance("overXYears",p,l):a.formatDistance("almostXYears",p+1,l)}}(t,function(n){return s9(n,Date.now())}(t),e)}const ui="https://static.marimo.app",VS=t=>{const e=H.c(24),{onClose:n}=t,[o,r]=O.useState("");let s;s=Math.random().toString(36).slice(2,6);const a=`${o}-${s}`,i=`${ui}/static/${a}`;let l,d,u,h,f,m,x,g,p,b,y;return e[0]!==n||e[1]!==a?(l=async v=>{v.preventDefault(),n();const w=await l9({download:!1,includeCode:!0,files:vS.INSTANCE.filenames()}),S=Xe({title:"Uploading static notebook...",description:"Please wait."});await fetch(`${ui}/api/static`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:w,path:a})}).catch(()=>{S.dismiss(),Xe({title:"Error uploading static page",description:c.jsxs("div",{children:["Please try again later. If the problem persists, please file a bug report on"," ",c.jsx("a",{href:On.issuesPage,target:"_blank",className:"underline",children:"GitHub"}),"."]})})}),S.dismiss(),Xe({title:"Static page uploaded!",description:c.jsxs("div",{children:["The URL has been copied to your clipboard.",c.jsx("br",{}),"You can share it with anyone."]})})},e[0]=n,e[1]=a,e[2]=l):l=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx($o,{children:"Share static notebook"}),e[3]=d):d=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsxs(rs,{children:[d,c.jsxs(ss,{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"," ",c.jsx("a",{href:ui,target:"_blank",children:ui}),"."]})]}),e[4]=u):u=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=v=>{const w=v.target.value.toLowerCase().replaceAll(/\s/g,"-").replaceAll(/[^\da-z-]/g,"");r(w)},e[5]=h):h=e[5],e[6]!==o?(f=c.jsx(Vo,{"data-testid":"slug-input",id:"slug",autoFocus:!0,value:o,placeholder:"Notebook slug",onChange:h,required:!0,autoComplete:"off"}),e[6]=o,e[7]=f):f=e[7],e[8]!==i?(m=c.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:",c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(HS,{text:i}),c.jsx("span",{className:"text-primary",children:i})]})]}),e[8]=i,e[9]=m):m=e[9],e[10]!==f||e[11]!==m?(x=c.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[f,m]}),e[10]=f,e[11]=m,e[12]=x):x=e[12],e[13]!==n?(g=c.jsx(ke,{"data-testid":"cancel-share-static-notebook-button",variant:"secondary",onClick:n,children:"Cancel"}),e[13]=n,e[14]=g):g=e[14],e[15]!==i?(p=c.jsx(ke,{"data-testid":"share-static-notebook-button","aria-label":"Save",variant:"default",type:"submit",onClick:async()=>{await nn(i)},children:"Create"}),e[15]=i,e[16]=p):p=e[16],e[17]!==p||e[18]!==g?(b=c.jsxs(ja,{children:[g,p]}),e[17]=p,e[18]=g,e[19]=b):b=e[19],e[20]!==b||e[21]!==l||e[22]!==x?(y=c.jsx(Ho,{className:"w-fit",children:c.jsxs("form",{onSubmit:l,children:[u,x,b]})}),e[20]=b,e[21]=l,e[22]=x,e[23]=y):y=e[23],y},HS=t=>{const e=H.c(8),[n,o]=G.useState(!1);let r;e[0]!==t.text?(r=Dn.stopPropagation(async d=>{d.preventDefault(),await nn(t.text),o(!0),setTimeout(()=>o(!1),2e3)}),e[0]=t.text,e[1]=r):r=e[1];const s=r;let a,i,l;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(Ca,{size:14,strokeWidth:1.5}),e[2]=a):a=e[2],e[3]!==s?(i=c.jsx(ke,{"data-testid":"copy-static-notebook-url-button",onClick:s,size:"xs",variant:"secondary",children:a}),e[3]=s,e[4]=i):i=e[4],e[5]!==n||e[6]!==i?(l=c.jsx(Ne,{content:"Copied!",open:n,children:i}),e[5]=n,e[6]=i,e[7]=l):l=e[7],l};function Op(){const t=H.c(2),e=kt(Ff);let n;return t[0]!==e?(n=()=>{const o=document.getElementsByClassName("output-area"),r=window.innerHeight||document.documentElement.clientHeight;let s=null;for(const a of Array.from(o)){const i=a.getBoundingClientRect();if(i.top>=0&&i.top<=r||i.bottom>=0&&i.bottom<=r){s=Ea.parse(a.parentNode.id);break}}e(a=>({mode:c9(a.mode),cellAnchor:s})),requestAnimationFrame(()=>{var a;s!==null&&((a=document.getElementById(Ea.create(s)))==null||a.scrollIntoView())})},t[0]=e,t[1]=n):n=t[1],n}function Qc(t){const e=H.c(3),n=Es();let o;return e[0]!==t||e[1]!==n?(o=()=>{t!==void 0&&n([t])},e[0]=t,e[1]=n,e[2]=o):o=e[2],Fe(o)}function Dp(){const t=H.c(2),e=Es();let n;return t[0]!==e?(n=()=>e(pk(mn())),t[0]=e,t[1]=n):n=t[1],Fe(n)}function Es(){const t=H.c(2),{prepareForRun:e}=it();let n;return t[0]!==e?(n=async o=>{var i,l;if(o.length===0)return;const{cellHandles:r,cellData:s}=mn(),a=[];for(const d of o){const u=r[d],h=(i=u==null?void 0:u.current)==null?void 0:i.editorView;let f;h?(gk(h)!=="markdown"&&Bl(h),f=xk(h)):f=((l=s[d])==null?void 0:l.code)||"",a.push(f),e({cellId:d})}await u9({cellIds:o,codes:a}).catch(WS)},t[0]=e,t[1]=n):n=t[1],Fe(n)}function WS(t){ht.error(t)}const ed=[{type:"files",Icon:ep,tooltip:"View files",position:"sidebar"},{type:"variables",Icon:Ul,tooltip:"Explore variables",position:"sidebar"},{type:"datasources",Icon:Wo,tooltip:"Explore data sources",position:"sidebar"},{type:"dependencies",Icon:ii,tooltip:"Explore dependencies",position:"sidebar"},{type:"packages",Icon:Ss,tooltip:"Manage packages",position:"sidebar"},{type:"outline",Icon:Xc,tooltip:"View outline",position:"sidebar"},{type:"chat",Icon:$l,tooltip:"Chat with AI",position:"sidebar"},{type:"documentation",Icon:Jc,tooltip:"View live docs",position:"sidebar"},{type:"logs",Icon:zf,tooltip:"Notebook logs",position:"sidebar"},{type:"tracing",Icon:YR,tooltip:"Tracing",position:"sidebar"},{type:"snippets",Icon:Sp,tooltip:"Snippets",position:"sidebar"},{type:"secrets",Icon:sp,tooltip:"Secrets",hidden:Jt(),position:"sidebar"},{type:"scratchpad",Icon:h9,tooltip:"Scratchpad",position:"sidebar"},{type:"errors",Icon:_a,tooltip:"View errors",position:"footer"}];function qS(){const t=H.c(7);let e;t[0]===Symbol.for("react.memo_cache_sentinel")?(e=[],t[0]=e):e=t[0];const[n,o]=function(a,i){const l=H.c(11);let d;l[0]!==i?(d=new f9(i),l[0]=i,l[1]=d):d=l[1];const u=d;let h;l[2]!==a||l[3]!==u?(h=()=>u.get(a),l[2]=a,l[3]=u,l[4]=h):h=l[4];const[f,m]=O.useState(h);let x;l[5]!==a||l[6]!==u?(x=b=>{m(b),u.set(a,b)},l[5]=a,l[6]=u,l[7]=x):x=l[7];const g=x;let p;return l[8]!==g||l[9]!==f?(p=[f,g],l[8]=g,l[9]=f,l[10]=p):p=l[10],p}("marimo:commands",e);let r,s;return t[1]!==n||t[2]!==o?(r=a=>{const i=(l=[a,...n],[...new Set(l)]);var l;o(i.slice(0,3))},t[1]=n,t[2]=o,t[3]=r):r=t[3],t[4]!==n||t[5]!==r?(s={recentCommands:n,addRecentCommand:r},t[4]=n,t[5]=r,t[6]=s):s=t[6],s}function Pp(t){return t.dropdown!==void 0}function hi(t,e=""){return t.flatMap(n=>n.label?Pp(n)?hi(n.dropdown,`${e+n.label} > `):{...n,label:e+n.label}:[])}const _s=t=>{const e=H.c(8),{children:n,layerTop:o}=t,r=o!==void 0&&o;let s;e[0]!==n?(s=G.Children.toArray(n),e[0]=n,e[1]=s):s=e[1];const[a,i]=s,l=`second-icon absolute ${r?"top-[-2px] left-[-2px]":"bottom-[-2px] right-[-2px]"} rounded-full`;let d,u;return e[2]!==i||e[3]!==l?(d=c.jsx("div",{className:l,children:i}),e[2]=i,e[3]=l,e[4]=d):d=e[4],e[5]!==a||e[6]!==d?(u=c.jsxs("div",{className:"multi-icon relative w-fit",children:[a,d]}),e[5]=a,e[6]=d,e[7]=u):u=e[7],u},Is=mt(null),GS=mt(!1),td=vk("marimo:ai:chatState:v3",{chats:[],activeChatId:null}),YS=mt(t=>{const e=t(td);return e.chats.find(n=>n.id===e.activeChatId)},(t,e,n)=>{e(td,o=>({...o,activeChatId:n}))});function Rp(t){return t!==wk&&!!(t&&t.trim().length>0)}const fi=t=>{const e=H.c(7);let n,o;e[0]!==t?(n=i=>{var l;(i.ctrlKey||i.metaKey)&&i.key==="z"&&(i.preventDefault(),i.stopPropagation(),(l=t.onClick)==null||l.call(t,i))},e[0]=t,e[1]=n):n=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(o={capture:!0},e[2]=o):o=e[2],Vl(window,"keydown",n,o);const r=t.children??"Undo";let s,a;return e[3]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx(m9,{className:"ml-2",shortcut:"cmd-z"}),e[3]=s):s=e[3],e[4]!==r||e[5]!==t?(a=c.jsxs(ke,{"data-testid":"undo-button",size:"sm",variant:"outline",...t,children:[r," ",s]}),e[4]=r,e[5]=t,e[6]=a):a=e[6],a};function mi(){const t=H.c(3),{deleteCell:e,undoDeleteCell:n}=it();let o;return t[0]!==e||t[1]!==n?(o=r=>{var l;if(Qe.get(Hl))return;const{cellId:s}=r,a=Qe.get(pn),i=(((l=a.cellData[s])==null?void 0:l.code)??"").trim()==="";if(e({cellId:s}),kk({cellId:s}).catch(()=>{n()}),!i){const{dismiss:d}=Xe({title:"Cell deleted",description:"You can bring it back by clicking undo or through the command palette.",action:c.jsx(fi,{"data-testid":"undo-delete-button",onClick:()=>{n(),u()}})}),u=d}},t[0]=e,t[1]=n,t[2]=o):o=t[2],Fe(o)}function pi(){const t=H.c(3),{deleteCell:e,undoDeleteCell:n}=it();let o;return t[0]!==e||t[1]!==n?(o=async r=>{if(Qe.get(Hl))return;const{cellIds:s}=r;for(const l of s)await kk({cellId:l}).then(()=>{e({cellId:l})});const{dismiss:a}=Xe({title:"Cells deleted",action:c.jsx(fi,{"data-testid":"undo-delete-button",onClick:()=>{for(const l of s)n();i()}})}),i=a},t[0]=e,t[1]=n,t[2]=o):o=t[2],Fe(o)}function Lp(){const t=H.c(3),{splitCell:e,undoSplitCell:n}=it();let o;return t[0]!==e||t[1]!==n?(o=r=>{const s=Ia(r.cellId);if(!s)return;const a=xk(s);e(r);const{dismiss:i}=Xe({title:"Cell split",action:c.jsx(fi,{"data-testid":"undo-split-button",size:"sm",variant:"outline",onClick:()=>{n({...r,snapshot:a}),l()},children:"Undo"})}),l=i},t[0]=e,t[1]=n,t[2]=o):o=t[2],Fe(o)}function nd(t){const e=H.c(49),{cell:n}=t,{createNewCell:o,updateCellConfig:r,updateCellName:s,moveCell:a,sendToTop:i,sendToBottom:l,addColumnBreakpoint:d,clearCellOutput:u}=it(),h=Lp(),f=Qc(n==null?void 0:n.cellId),m=!Ie(Hl),x=mi(),{openModal:g}=jn(),p=kt(Is),b=Ie(Wl),y=Ie(ql),v=Ie(as),w=Ie(p9);if(!n||v){let E;return e[0]===Symbol.for("react.memo_cache_sentinel")?(E=[],e[0]=E):E=e[0],E}const{cellId:S,config:N,getEditorView:j,name:C,hasOutput:_,hasConsoleOutput:A,status:I}=n;let P;e[1]!==S||e[2]!==N.disabled||e[3]!==r?(P=async()=>{const E={disabled:!N.disabled};await qo({configs:{[S]:E}}),r({cellId:S,config:E})},e[1]=S,e[2]=N.disabled,e[3]=r,e[4]=P):P=e[4];const R=P;let M;e[5]!==S||e[6]!==N.hide_code||e[7]!==j||e[8]!==r?(M=async()=>{const E={hide_code:!N.hide_code};await qo({configs:{[S]:E}}),r({cellId:S,config:E});const U=j();U&&(E.hide_code?U.contentDOM.blur():U.focus())},e[5]=S,e[6]=N.hide_code,e[7]=j,e[8]=r,e[9]=M):M=e[9];const L=M;let F,D,T,k,B;return e[10]===Symbol.for("react.memo_cache_sentinel")?(F=c.jsx(Ip,{size:13,strokeWidth:1.5}),e[10]=F):F=e[10],e[11]!==S||e[12]!==C||e[13]!==g||e[14]!==s?(D=()=>{g(c.jsxs(Ho,{children:[c.jsx(rs,{children:c.jsx($o,{children:"Rename cell"})}),c.jsxs("div",{className:"flex items-center justify-between",children:[c.jsx(fr,{htmlFor:"cell-name",children:"Cell name"}),c.jsx(wS,{placeholder:"cell name",value:C,onKeyDown:E=>{E.key==="Enter"&&(E.preventDefault(),E.stopPropagation(),g(null))},onChange:E=>s({cellId:S,name:E})})]})]}))},e[11]=S,e[12]=C,e[13]=g,e[14]=s,e[15]=D):D=e[15],e[16]!==S||e[17]!==s?(T=E=>s({cellId:S,name:E}),e[16]=S,e[17]=s,e[18]=T):T=e[18],e[19]!==C||e[20]!==T?(k=c.jsx(wS,{placeholder:"cell name",value:C,onChange:T}),e[19]=C,e[20]=T,e[21]=k):k=e[21],e[22]!==d||e[23]!==b||e[24]!==w||e[25]!==y||e[26]!==m||e[27]!==S||e[28]!==u||e[29]!==N.disabled||e[30]!==N.hide_code||e[31]!==o||e[32]!==x||e[33]!==j||e[34]!==A||e[35]!==_||e[36]!==a||e[37]!==C||e[38]!==f||e[39]!==l||e[40]!==i||e[41]!==p||e[42]!==h||e[43]!==I||e[44]!==D||e[45]!==k||e[46]!==R||e[47]!==L?(B=[[{icon:F,label:"Name",disableClick:!0,handle:ZS,handleHeadless:D,rightElement:k},{icon:c.jsx(wr,{size:13,strokeWidth:1.5}),label:"Run cell",hotkey:"cell.run",hidden:I==="running"||I==="queued"||I==="disabled-transitively"||N.disabled,handle:()=>f()},{icon:c.jsx(Aa,{size:13,strokeWidth:1.5}),label:"AI completion",hidden:!b,handle:()=>{p(E=>(E==null?void 0:E.cellId)===S?null:{cellId:S})},hotkey:"cell.aiCompletion"},{icon:c.jsx(Kc,{size:13,strokeWidth:1.5}),label:"Split cell",hotkey:"cell.splitCell",handle:()=>h({cellId:S})},{icon:c.jsx(Rm,{size:13,strokeWidth:1.5}),label:"Export output as PNG",hidden:!_,handle:()=>function(E){const U=document.getElementById(bk.create(E));U&&(U.classList.add("printing-output"),yk(U,"result.png").finally(()=>{U.classList.remove("printing-output")}))}(S)},{icon:c.jsx(Nk,{size:13,strokeWidth:1.5}),label:"Format cell",hotkey:"cell.format",handle:()=>{const E=j();E&&Sk({[S]:E})}},{icon:N.hide_code?c.jsx(Bf,{size:13,strokeWidth:1.5}):c.jsx(Uf,{size:13,strokeWidth:1.5}),label:N.hide_code?"Show code":"Hide code",handle:L,hotkey:"cell.hideCode"},{icon:N.disabled?c.jsx(an,{size:13,strokeWidth:1.5}):c.jsx(ln,{size:13,strokeWidth:1.5}),label:"Reactive execution",rightElement:c.jsx($f,{"data-testid":"cell-disable-switch",checked:!N.disabled,size:"sm",onCheckedChange:R}),handle:R},{icon:c.jsx(_a,{size:13,strokeWidth:1.5}),label:"Clear output",hidden:!(_||A),handle:()=>{u({cellId:S})}}],[{icon:c.jsx(Gl,{}),label:"Convert to Markdown",hotkey:"cell.viewAsMarkdown",handle:()=>{const E=j();E&&(qn({autoInstantiate:y,createNewCell:o}),hr(E,{language:"markdown",keepCodeAsIs:!1}))}},{icon:c.jsx(Wo,{size:13,strokeWidth:1.5}),label:"Convert to SQL",handle:()=>{const E=j();E&&(qn({autoInstantiate:y,createNewCell:o}),hr(E,{language:"sql",keepCodeAsIs:!1}))}},{icon:c.jsx(Yl,{}),label:"Toggle as Python",handle:()=>{const E=j();E&&(qn({autoInstantiate:y,createNewCell:o}),g9(E,"python",{force:!0}))}}],[{icon:c.jsxs(_s,{children:[c.jsx(ri,{size:13,strokeWidth:1.5}),c.jsx(Kl,{size:8,strokeWidth:2})]}),label:"Create cell above",hotkey:"cell.createAbove",handle:()=>o({cellId:S,before:!0})},{icon:c.jsxs(_s,{children:[c.jsx(ri,{size:13,strokeWidth:1.5}),c.jsx(wo,{size:8,strokeWidth:2})]}),label:"Create cell below",hotkey:"cell.createBelow",handle:()=>o({cellId:S,before:!1})},{icon:c.jsx(Kl,{size:13,strokeWidth:1.5}),label:"Move cell up",hotkey:"cell.moveUp",handle:()=>a({cellId:S,before:!0})},{icon:c.jsx(wo,{size:13,strokeWidth:1.5}),label:"Move cell down",hotkey:"cell.moveDown",handle:()=>a({cellId:S,before:!1})},{icon:c.jsx(jk,{size:13,strokeWidth:1.5}),label:"Move cell left",hotkey:"cell.moveLeft",handle:()=>a({cellId:S,direction:"left"}),hidden:w!=="columns"},{icon:c.jsx(Ta,{size:13,strokeWidth:1.5}),label:"Move cell right",hotkey:"cell.moveRight",handle:()=>a({cellId:S,direction:"right"}),hidden:w!=="columns"},{icon:c.jsx(zc,{size:13,strokeWidth:1.5}),label:"Send to top",hotkey:"cell.sendToTop",handle:()=>i({cellId:S,scroll:!1})},{icon:c.jsx(Fc,{size:13,strokeWidth:1.5}),label:"Send to bottom",hotkey:"cell.sendToBottom",handle:()=>l({cellId:S,scroll:!1})},{icon:c.jsx(x9,{size:13,strokeWidth:1.5}),label:"Break into new column",hotkey:"cell.addColumnBreakpoint",hidden:w!=="columns",handle:()=>d({cellId:S})}],[{icon:c.jsx(mS,{size:13,strokeWidth:1.5}),label:"Copy link to cell",disabled:!Rp(C),tooltip:Rp(C)?void 0:"Only named cells can be linked to",handle:async()=>{await nn(function(E){const U=new URL(window.location.href);return U.hash=`scrollTo=${encodeURIComponent(E)}`,U.toString()}(C)),Xe({description:"Link copied to clipboard"})}}],[{label:"Delete",hidden:!m,variant:"danger",icon:c.jsx(Xl,{size:13,strokeWidth:1.5}),handle:()=>{x({cellId:S})}}]].map(XS).filter(KS),e[22]=d,e[23]=b,e[24]=w,e[25]=y,e[26]=m,e[27]=S,e[28]=u,e[29]=N.disabled,e[30]=N.hide_code,e[31]=o,e[32]=x,e[33]=j,e[34]=A,e[35]=_,e[36]=a,e[37]=C,e[38]=f,e[39]=l,e[40]=i,e[41]=p,e[42]=h,e[43]=I,e[44]=D,e[45]=k,e[46]=R,e[47]=L,e[48]=B):B=e[48],B}function KS(t){return t.length>0}function XS(t){return t.filter(JS)}function JS(t){return!t.hidden}function ZS(t){t==null||t.stopPropagation(),t==null||t.preventDefault()}function QS(t){return!t.hidden}const od=mt(!1),Fp=()=>{const t=H.c(37),[e,n]=St(od),o=y9(),r=Ie(v9),s=Ie(Jl);let a;t[0]!==r?(a={cell:r},t[0]=r,t[1]=a):a=t[1];let i=nd(a).flat();i=hi(i);const l=function(){const T=H.c(73),[k,B]=mr(),[E,U]=Ck();let V;T[0]!==B?(V=async K=>{await pr({config:K}).then(()=>{B(K)})},T[0]=B,T[1]=V):V=T[1];const $=V;let X;T[2]!==U?(X=async K=>{await b9({config:K}).then(()=>{U(K)})},T[2]=U,T[3]=X):X=T[3];const Y=X;let J;if(T[4]!==E||T[5]!==k||T[6]!==Y||T[7]!==$){let K,re,oe,ne,se;T[9]!==E?(K=Oe=>Oe!==E.width,T[9]=E,T[10]=K):K=T[10],T[11]!==E||T[12]!==Y?(re=Oe=>({label:`App config > Set width=${Oe}`,handle:()=>{Y({...E,width:Oe})}}),T[11]=E,T[12]=Y,T[13]=re):re=T[13],T[14]!==k||T[15]!==$?(oe={label:"Config > Set theme: dark",handle:()=>{$({...k,display:{...k.display,theme:"dark"}})}},T[14]=k,T[15]=$,T[16]=oe):oe=T[16],T[17]!==k||T[18]!==$?(ne={label:"Config > Set theme: light",handle:()=>{$({...k,display:{...k.display,theme:"light"}})}},T[17]=k,T[18]=$,T[19]=ne):ne=T[19],T[20]!==k||T[21]!==$?(se={label:"Config > Set theme: system",handle:()=>{$({...k,display:{...k.display,theme:"system"}})}},T[20]=k,T[21]=$,T[22]=se):se=T[22];const te=k.keymap.preset==="vim";let pe,he;T[23]!==k||T[24]!==$?(pe=()=>{$({...k,keymap:{...k.keymap,preset:"vim"}})},T[23]=k,T[24]=$,T[25]=pe):pe=T[25],T[26]!==te||T[27]!==pe?(he={label:"Config > Switch keymap to VIM",hidden:te,handle:pe},T[26]=te,T[27]=pe,T[28]=he):he=T[28];const ae=k.keymap.preset==="default";let ye,fe,Se;T[29]!==k||T[30]!==$?(ye=()=>{$({...k,keymap:{...k.keymap,preset:"default"}})},T[29]=k,T[30]=$,T[31]=ye):ye=T[31],T[32]!==ae||T[33]!==ye?(fe={label:"Config > Switch keymap to default (current: VIM)",hidden:ae,handle:ye},T[32]=ae,T[33]=ye,T[34]=fe):fe=T[34],T[35]!==k||T[36]!==$?(Se=()=>{$({...k,completion:{...k.completion,copilot:!1}})},T[35]=k,T[36]=$,T[37]=Se):Se=T[37];const Me=k.completion.copilot!=="github";let Ee,Le;T[38]!==Se||T[39]!==Me?(Ee={label:"Config > Disable GitHub Copilot",handle:Se,hidden:Me},T[38]=Se,T[39]=Me,T[40]=Ee):Ee=T[40],T[41]!==k||T[42]!==$?(Le=()=>{$({...k,completion:{...k.completion,copilot:"github"}})},T[41]=k,T[42]=$,T[43]=Le):Le=T[43];const Te=k.completion.copilot==="github";let Ze;T[44]!==Le||T[45]!==Te?(Ze={label:"Config > Enable GitHub Copilot",handle:Le,hidden:Te},T[44]=Le,T[45]=Te,T[46]=Ze):Ze=T[46];const He=!k.display.reference_highlighting;let Ge,ee,be,we;T[47]!==k||T[48]!==$?(Ge=()=>{$({...k,display:{...k.display,reference_highlighting:!1}})},T[47]=k,T[48]=$,T[49]=Ge):Ge=T[49],T[50]!==He||T[51]!==Ge?(ee={label:"Config > Disable reference highlighting",hidden:He,handle:Ge},T[50]=He,T[51]=Ge,T[52]=ee):ee=T[52],T[53]!==k||T[54]!==$?(be=()=>{$({...k,display:{...k.display,reference_highlighting:!0}})},T[53]=k,T[54]=$,T[55]=be):be=T[55],T[56]!==k.display.reference_highlighting||T[57]!==be?(we={label:"Config > Enable reference highlighting",hidden:k.display.reference_highlighting,handle:be},T[56]=k.display.reference_highlighting,T[57]=be,T[58]=we):we=T[58];const Ae=k.display.cell_output==="above";let W,de;T[59]!==k||T[60]!==$?(W=()=>{$({...k,display:{...k.display,cell_output:"above"}})},T[59]=k,T[60]=$,T[61]=W):W=T[61],T[62]!==Ae||T[63]!==W?(de={label:"Config > Set cell output area: above",hidden:Ae,handle:W},T[62]=Ae,T[63]=W,T[64]=de):de=T[64];const ue=k.display.cell_output==="below";let ce,ve;T[65]!==k||T[66]!==$?(ce=()=>{$({...k,display:{...k.display,cell_output:"below"}})},T[65]=k,T[66]=$,T[67]=ce):ce=T[67],T[68]!==ue||T[69]!==ce?(ve={label:"Config > Set cell output area: below",hidden:ue,handle:ce},T[68]=ue,T[69]=ce,T[70]=ve):ve=T[70],J=[...KR().filter(K).map(re),oe,ne,se,he,fe,Ee,Ze,ee,we,de,ve],T[4]=E,T[5]=k,T[6]=Y,T[7]=$,T[8]=J}else J=T[8];const Q=J;let q;return T[71]!==Q?(q=Q.filter(QS),T[71]=Q,T[72]=q):q=T[72],q}();let d=mg();d=[...hi(d),...hi(l)];const u=d.filter(eN),h=Zl.keyBy(u,tN),{recentCommands:f,addRecentCommand:m}=qS();let x;t[2]!==f?(x=new Set(f),t[2]=f,t[3]=x):x=t[3];const g=x;let p,b;t[4]!==s||t[5]!==n?(p=T=>{Wf(s.getHotkey("global.commandPalette").key)(T)&&(T.preventDefault(),n(nN))},t[4]=s,t[5]=n,t[6]=p):p=t[6],Vl(document,"keydown",p),t[7]!==m||t[8]!==s||t[9]!==o||t[10]!==n?(b=(T,k)=>{const B=o[T];if(!B)return null;const E=s.getHotkey(T);return c.jsxs(Gn,{disabled:k.disabled,onSelect:()=>{m(T),n(!1),requestAnimationFrame(()=>{B()})},value:E.name,children:[c.jsxs("span",{children:[E.name,k.tooltip&&c.jsx("span",{className:"ml-2",children:k.tooltip})]}),c.jsx(_k,{children:c.jsx(qf,{shortcut:E.key})})]},T)},t[7]=m,t[8]=s,t[9]=o,t[10]=n,t[11]=b):b=t[11];const y=b;let v;t[12]!==m||t[13]!==s||t[14]!==n?(v=T=>{const{label:k,handle:B,props:E,hotkey:U}=T,V=E===void 0?{}:E;return c.jsxs(Gn,{disabled:V.disabled,onSelect:()=>{m(k),n(!1),requestAnimationFrame(()=>{B()})},value:k,children:[c.jsxs("span",{children:[k,V.tooltip&&c.jsxs("span",{className:"ml-2",children:["(",V.tooltip,")"]})]}),U&&c.jsx(_k,{children:c.jsx(qf,{shortcut:s.getHotkey(U).key})})]},k)},t[12]=m,t[13]=s,t[14]=n,t[15]=v):v=t[15];const w=v,S=k9;let N;t[16]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsx(Ma,{placeholder:"Type to search..."}),t[16]=N):N=t[16];const j=Hf;let C;t[17]===Symbol.for("react.memo_cache_sentinel")?(C=c.jsx(Ql,{children:"No results found."}),t[17]=C):C=t[17];const _=f.length>0&&c.jsxs(c.Fragment,{children:[c.jsx(Vf,{heading:"Recently Used",children:f.map(T=>{const k=h[T];return w9(T)?y(T,{disabled:k==null?void 0:k.disabled,tooltip:k==null?void 0:k.tooltip}):k&&!Pp(k)?w({label:k.label,handle:k.handleHeadless||k.handle,props:{disabled:k.disabled,tooltip:k.tooltip}}):null})}),c.jsx(Ek,{})]}),A=Vf,I=s.iterate().map(T=>{if(g.has(T))return null;const k=h[T];return y(T,{disabled:k==null?void 0:k.disabled,tooltip:k==null?void 0:k.tooltip})}),P=u.map(T=>g.has(T.label)?null:w({label:T.label,handle:T.handleHeadless||T.handle,props:{disabled:T.disabled,tooltip:T.tooltip}}));let R;t[18]!==g||t[19]!==w?(R=T=>g.has(T.label)?null:w({label:`Cell > ${T.label}`,handle:T.handleHeadless||T.handle,props:{disabled:T.disabled,tooltip:T.tooltip}}),t[18]=g,t[19]=w,t[20]=R):R=t[20];const M=i.map(R);let L,F,D;return t[21]!==A||t[22]!==P||t[23]!==M||t[24]!==I?(L=c.jsxs(A,{heading:"Commands",children:[I,P,M]}),t[21]=A,t[22]=P,t[23]=M,t[24]=I,t[25]=L):L=t[25],t[26]!==j||t[27]!==L||t[28]!==C||t[29]!==_?(F=c.jsxs(j,{children:[C,_,L]}),t[26]=j,t[27]=L,t[28]=C,t[29]=_,t[30]=F):F=t[30],t[31]!==S||t[32]!==e||t[33]!==n||t[34]!==F||t[35]!==N?(D=c.jsxs(S,{open:e,onOpenChange:n,children:[N,F]}),t[31]=S,t[32]=e,t[33]=n,t[34]=F,t[35]=N,t[36]=D):D=t[36],D};function eN(t){return!t.hotkey}function tN(t){return t.label}function nN(t){return!t}function Qo(){return st().optional().describe(ze.of({label:"Password",inputType:"password",placeholder:"password",optionRegex:".*password.*"}))}function zp(){return st().optional().describe(ze.of({label:"Token",inputType:"password",placeholder:"token",optionRegex:".*token.*"}))}function gi(){return st().optional().describe(ze.of({label:"Warehouse Name",placeholder:"warehouse",optionRegex:".*warehouse.*"}))}function Bp(){return st().optional().describe(ze.of({label:"URI",optionRegex:".*uri.*"}))}function er(){return st().nonempty().describe(ze.of({label:"Host",placeholder:"localhost",optionRegex:".*host.*"}))}function Jn(){return st().describe(ze.of({label:"Database",placeholder:"db name",optionRegex:".*database.*"}))}function tr(){return st().nonempty().describe(ze.of({label:"Username",placeholder:"username",optionRegex:".*username.*"}))}function nr(t){const e=S9.string().describe(ze.of({label:"Port",inputType:"number",placeholder:t==null?void 0:t.toString()})).transform(Number).refine(n=>n>=0&&n<=65535,{message:"Port must be between 0 and 65535"});return t!==void 0?e.default(t.toString()):e}function Up(){return is().default(!1).describe(ze.of({label:"Read Only"}))}const $p=dt({type:pt("postgres"),host:er(),port:nr(5432).optional(),database:Jn(),username:tr(),password:Qo(),ssl:is().default(!1).describe(ze.of({label:"Use SSL"}))}).describe(ze.of({direction:"two-columns"})),Vp=dt({type:pt("mysql"),host:er(),port:nr(3306),database:Jn(),username:tr(),password:Qo(),ssl:is().default(!1).describe(ze.of({label:"Use SSL"}))}).describe(ze.of({direction:"two-columns"})),Hp=dt({type:pt("sqlite"),database:Jn().describe(ze.of({label:"Database Path"}))}).describe(ze.of({direction:"two-columns"})),Wp=dt({type:pt("duckdb"),database:Jn().describe(ze.of({label:"Database Path"})),read_only:Up()}).describe(ze.of({direction:"two-columns"})),qp=dt({type:pt("motherduck"),database:Jn().default("my_db").describe(ze.of({label:"Database Name"})),token:zp()}).describe(ze.of({direction:"two-columns"})),Gp=dt({type:pt("snowflake"),account:st().nonempty().describe(ze.of({label:"Account",optionRegex:".*snowflake.*"})),warehouse:st().optional().describe(ze.of({label:"Warehouse",optionRegex:".*snowflake.*"})),database:Jn(),schema:st().optional().describe(ze.of({label:"Schema",optionRegex:".*snowflake.*"})),username:tr(),password:Qo(),role:st().optional().describe(ze.of({label:"Role"}))}).describe(ze.of({direction:"two-columns"})),Yp=dt({type:pt("bigquery"),project:st().nonempty().describe(ze.of({label:"Project ID",optionRegex:".*bigquery.*"})),dataset:st().nonempty().describe(ze.of({label:"Dataset",optionRegex:".*bigquery.*"})),credentials_json:st().describe(ze.of({label:"Credentials JSON",inputType:"textarea"}))}).describe(ze.of({direction:"two-columns"})),Kp=dt({type:pt("clickhouse_connect"),host:er(),port:nr(8123).optional(),username:tr(),password:Qo(),secure:is().default(!1).describe(ze.of({label:"Use HTTPs"}))}).describe(ze.of({direction:"two-columns"})),Xp=dt({type:pt("timeplus"),host:er().default("localhost"),port:nr(8123).optional(),username:tr().default("default"),password:Qo().default("")}).describe(ze.of({direction:"two-columns"})),Jp=dt({type:pt("chdb"),database:Jn().describe(ze.of({label:"Database Path"})),read_only:Up()}).describe(ze.of({direction:"two-columns"})),Zp=dt({type:pt("trino"),host:er(),port:nr(8080),database:Jn(),schema:st().describe(ze.of({label:"Schema",placeholder:"schema name",optionRegex:".*schema.*"})).optional(),username:tr(),password:Qo(),async_support:is().default(!1).describe(ze.of({label:"Async Support"}))}).describe(ze.of({direction:"two-columns"})),Qp=dt({type:pt("iceberg"),name:st().describe(ze.of({label:"Catalog Name"})),catalog:Gf("type",[dt({type:pt("REST"),warehouse:gi(),uri:st().optional().describe(ze.of({label:"URI",placeholder:"https://",optionRegex:".*uri.*"})),token:zp()}),dt({type:pt("SQL"),warehouse:gi(),uri:st().optional().describe(ze.of({label:"URI",placeholder:"jdbc:iceberg://host:port/database",optionRegex:".*uri.*"}))}),dt({type:pt("Hive"),warehouse:gi(),uri:Bp()}),dt({type:pt("Glue"),warehouse:gi(),uri:Bp()}),dt({type:pt("DynamoDB"),"dynamodb.profile-name":st().optional().describe(ze.of({label:"Profile Name"})),"dynamodb.region":st().optional().describe(ze.of({label:"Region"})),"dynamodb.access-key-id":st().optional().describe(ze.of({label:"Access Key ID"})),"dynamodb.secret-access-key":st().optional().describe(ze.of({label:"Secret Access Key",inputType:"password"})),"dynamodb.session-token":st().optional().describe(ze.of({label:"Session Token",inputType:"password"}))})]).default({type:"REST"}).describe(ze.of({special:"tabs"}))}),eg=dt({type:pt("datafusion"),sessionContext:is().optional().describe(ze.of({label:"Use Session Context"}))}),tg=dt({type:pt("pyspark"),host:er().optional(),port:nr().optional()}),ng=dt({type:pt("redshift"),host:er(),port:nr(5439),connectionType:Gf("type",[dt({type:pt("IAM credentials"),region:st().describe(ze.of({label:"Region"})),aws_access_key_id:st().nonempty().describe(ze.of({label:"AWS Access Key ID",inputType:"password",optionRegex:".*aws_access_key_id.*"})),aws_secret_access_key:st().nonempty().describe(ze.of({label:"AWS Secret Access Key",inputType:"password",optionRegex:".*aws_secret_access_key.*"})),aws_session_token:st().optional().describe(ze.of({label:"AWS Session Token",inputType:"password",optionRegex:".*aws_session_token.*"}))}),dt({type:pt("DB credentials"),user:tr(),password:Qo()})]).default({type:"IAM credentials",aws_access_key_id:"",aws_secret_access_key:"",region:""}),database:Jn()}).describe(ze.of({direction:"two-columns"})),oN=Gf("type",[$p,Vp,Hp,Wp,qp,Gp,Yp,Kp,Xp,Jp,Zp,Qp,eg,tg,ng]),rd="env:";function xi(t){return typeof t=="string"&&t.startsWith(rd)}function sd(t){return`${rd}${t}`}const og={sqlmodel:"SQLModel",sqlalchemy:"SQLAlchemy",duckdb:"DuckDB",clickhouse_connect:"ClickHouse Connect",chdb:"chDB",pyiceberg:"PyIceberg",ibis:"Ibis",motherduck:"MotherDuck",redshift:"Redshift"};class Wt{constructor(e,n,o){this.connection=void 0,this.orm=void 0,this.secrets=void 0,this.connection=e,this.orm=n,this.secrets=o}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 rN{constructor(){this.secrets={}}get imports(){return Object.keys(this.secrets).length===0?new Set:new Set(["import os"])}print(e,n,o){if(e=(r=>`_${r}`)(e),xi(n)){const r=n.replace(rd,""),s=o?`os.environ.get("${r}", "${o}")`:`os.environ.get("${r}")`;return this.secrets[e]=s,e}if(o!=null){const r=`os.environ.get("${n}", "${o}")`;return this.secrets[e]=r,e}return typeof n=="number"||typeof n=="number"?`${n}`:typeof n=="boolean"?Sr(n):n?`"${n}"`:""}printInFString(e,n,o){if(n===void 0)return"";if(typeof n=="number")return`${n}`;if(typeof n=="boolean")return Sr(n);const r=this.print(e,n,o);return r.startsWith('"')&&r.endsWith('"')?r.slice(1,-1):`{${r}}`}printPassword(e,n,o){const r=o?this.printInFString.bind(this):this.print.bind(this);return xi(e)?r("password",e):r("password",n,e)}getSecrets(){return this.secrets}formatSecrets(){return Object.keys(this.secrets).length===0?"":Object.entries(this.secrets).map(([e,n])=>`${e} = ${n}`).join(`
3
- `)}}class sN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'sslmode': 'require'}":"",n=this.secrets.printPassword(this.connection.password,"POSTGRES_PASSWORD",!0),o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database);return gt(`
4
- DATABASE_URL = f"postgresql://${o}:${n}@${r}:${s}/${a}"
5
- engine = ${this.orm}.create_engine(DATABASE_URL${e})
6
- `)}}class aN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.ssl?", connect_args={'ssl': {'ssl-mode': 'preferred'}}":"",n=this.secrets.printPassword(this.connection.password,"MYSQL_PASSWORD",!0),o=this.secrets.printInFString("database",this.connection.database),r=this.secrets.printInFString("username",this.connection.username),s=this.secrets.printInFString("host",this.connection.host),a=this.secrets.printInFString("port",this.connection.port);return gt(`
7
- DATABASE_URL = f"mysql+pymysql://${r}:${n}@${s}:${a}/${o}"
8
- engine = ${this.orm}.create_engine(DATABASE_URL${e})
9
- `)}}class iN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.connection.database?this.secrets.printInFString("database",this.connection.database):"",n=e.startsWith("{")&&e.endsWith("}")?`DATABASE_URL = f"sqlite:///${e}"`:`DATABASE_URL = "sqlite:///${e}"`;return gt(`
10
- ${n}
11
- engine = ${this.orm}.create_engine(DATABASE_URL)
12
- `)}}class lN extends Wt{generateImports(){return["from snowflake.sqlalchemy import URL"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"SNOWFLAKE_PASSWORD",!1),n={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 gt(`
13
- engine = ${this.orm}.create_engine(
14
- URL(
15
- ${bi(n,o=>` ${o}`)},
16
- )
17
- )
18
- `)}}class cN extends Wt{generateImports(){return["import json"]}generateConnectionCode(){const e=this.secrets.printInFString("project",this.connection.project),n=this.secrets.printInFString("dataset",this.connection.dataset);return gt(`
19
- credentials = json.loads("""${this.connection.credentials_json}""")
20
- engine = ${this.orm}.create_engine(f"bigquery://${e}/${n}", credentials_info=credentials)
21
- `)}}class dN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database||":memory:");return gt(`
22
- DATABASE_URL = "${e}"
23
- engine = ${this.orm}.connect(DATABASE_URL, read_only=${Sr(this.connection.read_only)})
24
- `)}}class uN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printInFString("database",this.connection.database);if(!this.connection.token)return gt(`
25
- conn = duckdb.connect("md:${e}")
26
- `);const n=this.secrets.printPassword(this.connection.token,"MOTHERDUCK_TOKEN",!1);return gt(`
27
- conn = duckdb.connect("md:${e}", config={"motherduck_token": ${n}})
28
- `)}}class hN extends Wt{generateImports(){return["import clickhouse_connect"]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"CLICKHOUSE_PASSWORD",!1),n={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 gt(`
29
- engine = ${this.orm}.get_client(
30
- ${bi(n,o=>` ${o}`)},
31
- )
32
- `)}}class fN extends Wt{generateImports(){return[]}generateConnectionCode(){const e=this.secrets.printPassword(this.connection.password,"TIMEPLUS_PASSWORD",!0),n=this.secrets.printInFString("username",this.connection.username),o=this.secrets.printInFString("host",this.connection.host),r=this.secrets.printInFString("port",this.connection.port);return gt(`
33
- DATABASE_URL = f"timeplus://${n}:${e}@${o}:${r}"
34
- engine = ${this.orm}.create_engine(DATABASE_URL)
35
- `)}}class mN extends Wt{generateImports(){return["import chdb"]}generateConnectionCode(){const e=this.secrets.print("database",this.connection.database)||'""';return gt(`
36
- engine = ${this.orm}.connect(${e}, read_only=${Sr(this.connection.read_only)})
37
- `)}}class pN extends Wt{generateImports(){return this.connection.async_support?["import aiotrino"]:["import trino.sqlalchemy"]}generateConnectionCode(){const e=this.connection.async_support?"aiotrino":"trino",n=this.connection.schema?`/${this.connection.schema}`:"",o=this.secrets.printInFString("username",this.connection.username),r=this.secrets.printInFString("host",this.connection.host),s=this.secrets.printInFString("port",this.connection.port),a=this.secrets.printInFString("database",this.connection.database),i=this.secrets.printPassword(this.connection.password,"TRINO_PASSWORD",!0);return gt(`
38
- engine = ${this.orm}.create_engine(f"${e}://${o}:${i}@${r}:${s}/${a}${n}")
39
- `)}}class gN extends Wt{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:Yf(this.connection.catalog)}}generateConnectionCode(){let e={...this.connection.catalog};e=Object.fromEntries(Object.entries(e).filter(([a,i])=>i!=null&&i!==""&&a!=="type"));for(const[a,i]of Object.entries(e))xi(i)?e[a]=this.secrets.print(a,i):typeof i=="string"&&(e[a]=`"${i}"`);const n=(o=e,r=a=>` ${a}`,Object.entries(o).filter(([,a])=>a!=null&&a!=="").map(([a,i])=>{const l=`"${a}"`;return r(typeof i=="boolean"?`${l}: ${Sr(i)}`:`${l}: ${i}`)}).join(`,
40
- `));var o,r;const s=`"${this.connection.name}"`;switch(this.connection.catalog.type){case"REST":return gt(`
41
- catalog = RestCatalog(
42
- ${s},
43
- **{
44
- ${n}
45
- },
46
- )
47
- `);case"SQL":return gt(`
48
- catalog = SqlCatalog(
49
- ${s},
50
- **{
51
- ${n}
52
- },
53
- )
54
- `);case"Hive":return gt(`
55
- catalog = HiveCatalog(
56
- ${s},
57
- **{
58
- ${n}
59
- },
60
- )
61
- `);case"Glue":return gt(`
62
- catalog = GlueCatalog(
63
- ${s},
64
- **{
65
- ${n}
66
- },
67
- )
68
- `);case"DynamoDB":return gt(`
69
- catalog = DynamoDBCatalog(
70
- ${s},
71
- **{
72
- ${n}
73
- },
74
- )
75
- `);default:Yf(this.connection.catalog)}}}class xN extends Wt{generateImports(){return["import ibis","from datafusion import SessionContext"]}generateConnectionCode(){return this.connection.sessionContext?gt(`
76
- ctx = SessionContext()
77
- # Sample table
78
- _ = ctx.from_pydict({"a": [1, 2, 3]}, "my_table")
79
-
80
- con = ibis.datafusion.connect(ctx)
81
- `):gt(`
82
- con = ibis.datafusion.connect()
83
- `)}}class bN extends Wt{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),n=this.secrets.printInFString("port",this.connection.port);return gt(`
84
- session = SparkSession.builder.remote(f"sc://${e}:${n}").getOrCreate()
85
- con = ibis.pyspark.connect(session)
86
- `)}return gt(`
87
- con = ibis.pyspark.connect()
88
- `)}}class yN extends Wt{generateImports(){return["import redshift_connector"]}generateConnectionCode(){const e=this.secrets.print("host",this.connection.host),n=this.secrets.print("port",this.connection.port),o=this.secrets.print("database",this.connection.database);if(this.connection.connectionType.type==="IAM credentials"){const i=this.secrets.print("aws_access_key_id",this.connection.connectionType.aws_access_key_id),l=this.secrets.print("aws_secret_access_key",this.connection.connectionType.aws_secret_access_key),d=this.connection.connectionType.aws_session_token?this.secrets.print("aws_session_token",this.connection.connectionType.aws_session_token):void 0,u={iam:!0,host:e,port:n,region:`"${this.connection.connectionType.region}"`,database:o,access_key_id:i,secret_access_key:l,...d&&{session_token:d}};return gt(`
89
- con = redshift_connector.connect(
90
- ${bi(u,h=>` ${h}`)},
91
- )
92
- `)}const r=this.connection.connectionType.user?this.secrets.print("user",this.connection.connectionType.user):void 0,s=this.connection.connectionType.password?this.secrets.printPassword(this.connection.connectionType.password,"REDSHIFT_PASSWORD",!1):void 0,a={host:e,port:n,database:o,...r&&{user:r},...s&&{password:s}};return gt(`
93
- con = redshift_connector.connect(
94
- ${bi(a,i=>` ${i}`)},
95
- )
96
- `)}}class vN{constructor(){this.secrets=new rN}createGenerator(e,n){switch(e.type){case"postgres":return new sN(e,n,this.secrets);case"mysql":return new aN(e,n,this.secrets);case"sqlite":return new iN(e,n,this.secrets);case"snowflake":return new lN(e,n,this.secrets);case"bigquery":return new cN(e,n,this.secrets);case"duckdb":return new dN(e,n,this.secrets);case"motherduck":return new uN(e,n,this.secrets);case"clickhouse_connect":return new hN(e,n,this.secrets);case"timeplus":return new fN(e,n,this.secrets);case"chdb":return new mN(e,n,this.secrets);case"trino":return new pN(e,n,this.secrets);case"iceberg":return new gN(e,n,this.secrets);case"datafusion":return new xN(e,n,this.secrets);case"pyspark":return new bN(e,n,this.secrets);case"redshift":return new yN(e,n,this.secrets);default:Yf(e)}}}function Sr(t){return t.toString().charAt(0).toUpperCase()+t.toString().slice(1)}function bi(t,e){return Object.entries(t).filter(([,n])=>n!=null&&n!=="").map(([n,o])=>e(typeof o=="boolean"?`${n}=${Sr(o)}`:`${n}=${o}`)).join(`,
97
- `)}function rg(t){return t.sort((e,n)=>e.provider==="env"?1:n.provider==="env"?-1:0)}const sg=t=>{const e=H.c(42),{providerNames:n,onClose:o,onSuccess:r}=t,[s,a]=G.useState(""),[i,l]=G.useState(""),[d,u]=G.useState(n[0]);let h;e[0]!==s||e[1]!==d||e[2]!==r||e[3]!==i?(h=async D=>{if(D.preventDefault(),d)if(s&&i&&d)try{await N9({key:s,value:i,provider:"dotenv",name:d}),Xe({title:"Secret created",description:"The secret has been created successfully."}),r(s)}catch{Xe({title:"Error",description:"Failed to create secret. Please try again.",variant:"danger"})}else Xe({title:"Error",description:"Please fill in all fields.",variant:"danger"});else Xe({title:"Error",description:"No location selected for the secret.",variant:"danger"})},e[0]=s,e[1]=d,e[2]=r,e[3]=i,e[4]=h):h=e[4];const f=h;let m,x,g,p,b,y,v,w,S,N,j,C,_,A,I,P;e[5]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsxs(rs,{children:[c.jsx($o,{children:"Add Secret"}),c.jsx(ss,{children:"Add a new secret to your environment variables."})]}),e[5]=m):m=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(fr,{htmlFor:"key",children:"Key"}),e[6]=x):x=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(g=D=>{a(D.target.value.replaceAll(/\W/g,"_"))},e[7]=g):g=e[7],e[8]!==s?(p=c.jsxs("div",{className:"grid gap-2",children:[x,c.jsx(Vo,{id:"key",value:s,onChange:g,placeholder:"MY_SECRET_KEY",required:!0})]}),e[8]=s,e[9]=p):p=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(fr,{htmlFor:"value",children:"Value"}),e[10]=b):b=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(y=D=>l(D.target.value),e[11]=y):y=e[11],e[12]!==i?(v=c.jsx(Vo,{id:"value",type:"text",value:i,onChange:y,required:!0,autoComplete:"off"}),e[12]=i,e[13]=v):v=e[13],e[14]===Symbol.for("react.memo_cache_sentinel")?(w=window.location.href.startsWith("http://")&&c.jsx(Ik,{children:"Note: You are sending this key over http."}),e[14]=w):w=e[14],e[15]!==v?(S=c.jsxs("div",{className:"grid gap-2",children:[b,v,w]}),e[15]=v,e[16]=S):S=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsx(fr,{htmlFor:"location",children:"Location"}),e[17]=N):N=e[17],e[18]!==n.length?(j=n.length===0&&c.jsx("p",{className:"text-sm text-muted-foreground",children:"No dotenv locations configured."}),e[18]=n.length,e[19]=j):j=e[19],e[20]!==d||e[21]!==n?(C=n.length>0&&c.jsxs(Oa,{value:d,onValueChange:D=>u(D),children:[c.jsx(Da,{children:c.jsx(Pa,{placeholder:"Select a provider"})}),c.jsx(Ra,{children:n.map(wN)})]}),e[20]=d,e[21]=n,e[22]=C):C=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsxs(Ik,{children:["You can configure the location by setting the"," ",c.jsx(Kf,{href:"https://links.marimo.app/dotenv",children:"dotenv configuration"}),"."]}),e[23]=_):_=e[23],e[24]!==j||e[25]!==C?(A=c.jsxs("div",{className:"grid gap-2",children:[N,j,C,_]}),e[24]=j,e[25]=C,e[26]=A):A=e[26],e[27]!==S||e[28]!==A||e[29]!==p?(I=c.jsxs("div",{className:"grid gap-4 py-4",children:[p,S,A]}),e[27]=S,e[28]=A,e[29]=p,e[30]=I):I=e[30],e[31]!==o?(P=c.jsx(ke,{type:"button",variant:"outline",onClick:o,children:"Cancel"}),e[31]=o,e[32]=P):P=e[32];const R=!s||!i||!d;let M,L,F;return e[33]!==R?(M=c.jsx(ke,{type:"submit",disabled:R,children:"Add Secret"}),e[33]=R,e[34]=M):M=e[34],e[35]!==P||e[36]!==M?(L=c.jsxs(ja,{children:[P,M]}),e[35]=P,e[36]=M,e[37]=L):L=e[37],e[38]!==f||e[39]!==I||e[40]!==L?(F=c.jsx(Ho,{children:c.jsxs("form",{onSubmit:f,children:[m,I,L]})}),e[38]=f,e[39]=I,e[40]=L,e[41]=F):F=e[41],F};function wN(t){return c.jsx(ls,{value:t,children:t},t)}const ag=O.createContext({providerNames:[],secretKeys:[],loading:!1,error:void 0,refreshSecrets:Pn.NOOP}),kN=t=>{const e=H.c(14),{children:n}=t;let o;e[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],e[0]=o):o=e[0];const{data:r,isPending:s,error:a,refetch:i}=Cn(CN,o);let l,d,u,h;return e[1]!==(r==null?void 0:r.secretKeys)?(l=(r==null?void 0:r.secretKeys)||[],e[1]=r==null?void 0:r.secretKeys,e[2]=l):l=e[2],e[3]!==(r==null?void 0:r.providerNames)?(d=(r==null?void 0:r.providerNames)||[],e[3]=r==null?void 0:r.providerNames,e[4]=d):d=e[4],e[5]!==a||e[6]!==s||e[7]!==i||e[8]!==l||e[9]!==d?(u={secretKeys:l,providerNames:d,loading:s,error:a,refreshSecrets:i},e[5]=a,e[6]=s,e[7]=i,e[8]=l,e[9]=d,e[10]=u):u=e[10],e[11]!==n||e[12]!==u?(h=c.jsx(ag,{value:u,children:n}),e[11]=n,e[12]=u,e[13]=h):h=e[13],h};function SN(t){return t.provider!=="env"}function NN(t){return t.name}function jN(t){return t.keys}async function CN(){const t=await kS.request({}),e=rg(t.secrets).filter(SN).map(NN);return{secretKeys:t.secrets.flatMap(jN).sort(),providerNames:e}}const ig=[{name:"PostgreSQL",schema:$p,color:"#336791",logo:"postgres",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"MySQL",schema:Vp,color:"#00758F",logo:"mysql",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"SQLite",schema:Hp,color:"#003B57",logo:"sqlite",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DuckDB",schema:Wp,color:"#FFD700",logo:"duckdb",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"MotherDuck",schema:qp,color:"#ff9538",logo:"motherduck",connectionLibraries:{libraries:["duckdb"],preferred:"duckdb"}},{name:"Snowflake",schema:Gp,color:"#29B5E8",logo:"snowflake",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse",schema:Kp,color:"#2C2C1D",logo:"clickhouse",connectionLibraries:{libraries:["clickhouse_connect"],preferred:"clickhouse_connect"}},{name:"Timeplus",schema:Xp,color:"#B83280",logo:"timeplus",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"BigQuery",schema:Yp,color:"#4285F4",logo:"bigquery",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"ClickHouse Embedded",schema:Jp,color:"#f2b611",logo:"clickhouse",connectionLibraries:{libraries:["chdb"],preferred:"chdb"}},{name:"Trino",schema:Zp,color:"#d466b6",logo:"trino",connectionLibraries:{libraries:["sqlalchemy","sqlmodel"],preferred:"sqlalchemy"}},{name:"DataFusion",schema:eg,color:"#202A37",logo:"datafusion",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"PySpark",schema:tg,color:"#1C5162",logo:"pyspark",connectionLibraries:{libraries:["ibis"],preferred:"ibis"}},{name:"Redshift",schema:ng,color:"#522BAE",logo:"redshift",connectionLibraries:{libraries:["redshift"],preferred:"redshift"}}],lg=[{name:"Iceberg",schema:Qp,color:"#000000",logo:"iceberg",connectionLibraries:{libraries:["pyiceberg"],preferred:"pyiceberg"}}],EN=t=>{const e=H.c(14),{onSelect:n}=t;let o;e[0]!==n?(o=h=>{const{name:f,schema:m,color:x,logo:g}=h;return c.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:x},onClick:()=>n(m),children:[c.jsx(zk,{name:g,className:"w-8 h-8 text-white brightness-0 invert dark:invert"}),c.jsx("span",{className:"text-white font-medium text-lg",children:f})]},f)},e[0]=n,e[1]=o):o=e[1];const r=o;let s,a,i,l,d,u;return e[2]!==r?(s=ig.map(r),e[2]=r,e[3]=s):s=e[3],e[4]!==s?(a=c.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:s}),e[4]=s,e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsxs("h4",{className:"font-semibold text-muted-foreground text-lg flex items-center gap-4",children:["Data Catalogs",c.jsx("hr",{className:"flex-1"})]}),e[6]=i):i=e[6],e[7]!==r?(l=lg.map(r),e[7]=r,e[8]=l):l=e[8],e[9]!==l?(d=c.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 gap-4",children:l}),e[9]=l,e[10]=d):d=e[10],e[11]!==a||e[12]!==d?(u=c.jsxs(c.Fragment,{children:[a,i,d]}),e[11]=a,e[12]=d,e[13]=u):u=e[13],u},_N=[{isMatch:t=>{if(t instanceof Ok||t instanceof _9){const{optionRegex:e}=ze.parse(t._def.description||"");return!!e}return!1},Component:({schema:t,form:e,path:n})=>{const{secretKeys:o,providerNames:r,refreshSecrets:s}=O.use(ag),{openModal:a,closeModal:i}=jn(),{label:l,description:d,optionRegex:u=""}=ze.parse(t._def.description||""),[h,f]=Tt(o,m=>new RegExp(u,"i").test(m));return c.jsx(Ak,{control:e.control,name:n,render:({field:m})=>c.jsxs(Tk,{children:[c.jsx(j9,{children:l}),c.jsx(C9,{children:d}),c.jsx(Mk,{children:c.jsxs("div",{className:"flex gap-2",children:[t instanceof Ok?c.jsx(Vo,{...m,value:m.value,onChange:m.onChange,className:ge("flex-1")}):c.jsx(E9,{...m,value:m.value,onChange:m.onChange,className:"flex-1"}),c.jsxs(ko,{children:[c.jsx(So,{asChild:!0,children:c.jsx(ke,{variant:"outline",size:"icon",className:ge(xi(m.value)&&"bg-accent"),children:c.jsx(Hc,{className:"h-3 w-3"})})}),c.jsxs(No,{align:"end",className:"max-h-60 overflow-y-auto",children:[c.jsxs(It,{onSelect:()=>{a(c.jsx(sg,{providerNames:r,onSuccess:x=>{s(),m.onChange(sd(x)),i()},onClose:i}))},children:[c.jsx(ri,{className:"mr-2 h-3.5 w-3.5"}),"Create a new secret"]}),h.length>0&&c.jsxs(c.Fragment,{children:[c.jsx(on,{}),c.jsx(Dk,{children:"Recommended"})]}),h.map(x=>c.jsx(It,{onSelect:()=>m.onChange(sd(x)),children:x},x)),f.length>0&&c.jsx(on,{}),f.map(x=>c.jsx(It,{onSelect:()=>m.onChange(sd(x)),children:x},x))]})]})]})}),c.jsx(Pk,{})]})})}}],IN=t=>{var B;const e=H.c(49),{schema:n,onSubmit:o,onBack:r}=t;let s,a,i;e[0]!==n?(s=I9(n),e[0]=n,e[1]=s):s=e[1],e[2]!==n?(a=Rk(n),e[2]=n,e[3]=a):a=e[3],e[4]!==s||e[5]!==a?(i={defaultValues:s,resolver:a,reValidateMode:"onChange"},e[4]=s,e[5]=a,e[6]=i):i=e[6];const l=Lk(i),d=(B=[...ig,...lg].find(E=>E.schema===n))==null?void 0:B.connectionLibraries,[u,h]=O.useState((d==null?void 0:d.preferred)??"sqlalchemy"),{createNewCell:f}=it(),m=cs();let x;e[7]!==f||e[8]!==m?(x=E=>{f({code:E,before:!1,cellId:m??"__end__",skipIfCodeExists:!0})},e[7]=f,e[8]=m,e[9]=x):x=e[9];const g=x;let p;e[10]!==g||e[11]!==o||e[12]!==u?(p=E=>{g(function(U,V){if(!(V in og))throw new Error(`Unsupported library: ${V}`);oN.parse(U);const $=new vN,X=$.createGenerator(U,V),Y=X.generateConnectionCode(),J=$.secrets,Q=[...new Set([...J.imports,...X.imports])].sort();Q.push("");const q=J.formatSecrets();return q&&Q.push(q),Q.push(Y.trim()),Q.join(`
98
- `)}(E,u)),o()},e[10]=g,e[11]=o,e[12]=u,e[13]=p):p=e[13];const b=p;let y;e[14]!==l||e[15]!==b?(y=l.handleSubmit(b),e[14]=l,e[15]=b,e[16]=y):y=e[16];let v,w;e[17]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsx(A9,{}),e[17]=v):v=e[17],e[18]!==l||e[19]!==n?(w=c.jsx(kN,{children:c.jsx(T9,{schema:n,form:l,renderers:_N,children:v})}),e[18]=l,e[19]=n,e[20]=w):w=e[20];let S;e[21]!==r?(S=c.jsx(ke,{type:"button",variant:"outline",onClick:r,children:"Back"}),e[21]=r,e[22]=S):S=e[22];const N=!l.formState.isValid;let j,C;e[23]!==N?(j=c.jsx(ke,{type:"submit",disabled:N,children:"Add"}),e[23]=N,e[24]=j):j=e[24],e[25]!==S||e[26]!==j?(C=c.jsxs("div",{className:"flex gap-2",children:[S,j]}),e[25]=S,e[26]=j,e[27]=C):C=e[27];const _=Oa;let A,I;e[28]===Symbol.for("react.memo_cache_sentinel")?(A=E=>h(E),e[28]=A):A=e[28],e[29]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsxs("div",{className:"flex flex-col gap-1 items-end",children:[c.jsx(Da,{children:c.jsx(Pa,{placeholder:"Select a library"})}),c.jsx("span",{className:"text-xs text-muted-foreground",children:"Preferred connection library"})]}),e[29]=I):I=e[29];const P=Ra,R=Fk,M=d==null?void 0:d.libraries.map(TN);let L,F,D,T,k;return e[30]!==R||e[31]!==M?(L=c.jsx(R,{children:M}),e[30]=R,e[31]=M,e[32]=L):L=e[32],e[33]!==P||e[34]!==L?(F=c.jsx(P,{children:L}),e[33]=P,e[34]=L,e[35]=F):F=e[35],e[36]!==_||e[37]!==u||e[38]!==A||e[39]!==I||e[40]!==F?(D=c.jsx("div",{children:c.jsxs(_,{value:u,onValueChange:A,children:[I,F]})}),e[36]=_,e[37]=u,e[38]=A,e[39]=I,e[40]=F,e[41]=D):D=e[41],e[42]!==C||e[43]!==D?(T=c.jsxs("div",{className:"flex gap-2 justify-between",children:[C,D]}),e[42]=C,e[43]=D,e[44]=T):T=e[44],e[45]!==T||e[46]!==y||e[47]!==w?(k=c.jsxs("form",{onSubmit:y,className:"space-y-4",children:[w,T]}),e[45]=T,e[46]=y,e[47]=w,e[48]=k):k=e[48],k},AN=t=>{const e=H.c(5),{onSubmit:n}=t,[o,r]=O.useState(null);if(!o){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(EN,{onSelect:r}),e[0]=i):i=e[0],i}let s,a;return e[1]===Symbol.for("react.memo_cache_sentinel")?(s=()=>r(null),e[1]=s):s=e[1],e[2]!==n||e[3]!==o?(a=c.jsx(IN,{schema:o,onSubmit:n,onBack:s}),e[2]=n,e[3]=o,e[4]=a):a=e[4],a},cg=t=>{const e=H.c(6),{children:n}=t,[o,r]=O.useState(!1);let s,a,i;return e[0]!==n?(s=c.jsx(M9,{asChild:!0,children:n}),e[0]=n,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(dg,{onClose:()=>r(!1)}),e[2]=a):a=e[2],e[3]!==o||e[4]!==s?(i=c.jsxs(O9,{open:o,onOpenChange:r,children:[s,a]}),e[3]=o,e[4]=s,e[5]=i):i=e[5],i},dg=t=>{const e=H.c(4),{onClose:n}=t;let o,r,s;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx($o,{children:"Add Connection"}),e[0]=o):o=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsxs(rs,{className:"mb-4",children:[o,c.jsxs(ss,{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"," ",c.jsx(Kf,{href:"https://docs.marimo.io/guides/working_with_data/sql/#connecting-to-a-custom-database",children:"docs."})]})]}),e[1]=r):r=e[1],e[2]!==n?(s=c.jsxs(Ho,{className:"max-h-[75vh] overflow-y-auto",children:[r,c.jsx(AN,{onSubmit:()=>n()})]}),e[2]=n,e[3]=s):s=e[3],s};function TN(t){return c.jsx(ls,{value:t,children:og[t]},t)}const MN=()=>{const t=H.c(7),{selectedLayout:e}=SS(),{setLayoutView:n}=NS();if(Jt()&&!Xf("wasm_layouts"))return null;let o,r,s,a;return t[0]!==n?(o=i=>n(i),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(Da,{className:"min-w-[110px] border-border bg-background","data-testid":"layout-select",children:c.jsx(Pa,{placeholder:"Select a view"})}),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx(Ra,{children:c.jsxs(Fk,{children:[c.jsx(D9,{children:"View as"}),jS.map(DN)]})}),t[3]=s):s=t[3],t[4]!==e||t[5]!==o?(a=c.jsxs(Oa,{"data-testid":"layout-select",value:e,onValueChange:o,children:[r,s]}),t[4]=e,t[5]=o,t[6]=a):a=t[6],a};function ON(t){const e=ug(t);return c.jsx(e,{className:"h-4 w-4"})}function ug(t){switch(t){case"vertical":return ip;case"grid":return XR;case"slides":return Yc;default:return ec(t),tc}}function hg(t){return Jf(t)}function DN(t){return c.jsx(ls,{value:t,children:c.jsxs("div",{className:"flex items-center gap-1.5 leading-5",children:[ON(t),c.jsx("span",{children:hg(t)})]})},t)}const PN=()=>{const t=H.c(2),{updateCellConfig:e}=it();let n;return t[0]!==e?(n=async()=>{const o=new La,r=mn(),s=r.cellIds.inOrderIds,a={};for(const l of s){if(r.cellData[l]===void 0)continue;const{code:d,config:u}=r.cellData[l];u.hide_code||o.isSupported(d)&&(a[l]={hide_code:!0})}const i=Zl.entries(a);if(i.length!==0){await qo({configs:a});for(const[l,d]of i)e({cellId:l,config:d})}},t[0]=e,t[1]=n):n=t[1],n};function fg(){const t=H.c(3),{openConfirm:e}=jn(),n=kt(Yn);let o;return t[0]!==e||t[1]!==n?(o=()=>{e({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:c.jsx(Bk,{onClick:async()=>{n({state:Ft.CLOSING}),await R9(),L9()},"aria-label":"Confirm Restart",children:"Restart"})})},t[0]=e,t[1]=n,t[2]=o):o=t[2],o}const As=t=>{t==null||t.preventDefault(),t==null||t.stopPropagation()};function mg(){var E,U;const t=H.c(36),e=Zf(),{openModal:n,closeModal:o}=jn(),{toggleApplication:r}=Fa(),{selectedPanel:s}=oc(),[a]=St(Ff),i=Ie(as),l=PN(),[d]=mr(),{updateCellConfig:u,undoDeleteCell:h,clearAllCellOutputs:f,upsertSetupCell:m,collapseAllCells:x,expandAllCells:g}=it(),p=fg(),b=Dp(),y=function(V){const $=H.c(4),{openPrompt:X,closeModal:Y}=jn();let J;return $[0]!==Y||$[1]!==X||$[2]!==V?(J=()=>{if(!V)return null;const Q=nc.guessDeliminator(V),q=gn.basename(V);X({title:"Copy notebook",description:"Enter a new filename for the notebook copy.",defaultValue:`_${q}`,confirmText:"Copy notebook",spellCheck:!1,onConfirm:K=>{const re=Q.join(gn.dirname(V),K);P9({source:V,destination:re}).then(()=>{Y(),Xe({title:"Notebook copied",description:"A copy of the notebook has been created."}),pS(re)})}})},$[0]=Y,$[1]=X,$[2]=V,$[3]=J):J=$[3],J}(e),v=kt(od),w=kt(JR),S=kt(ZR),N=Ie(F9),j=Ie(z9),C=Ie(Uk),{selectedLayout:_}=SS(),{setLayoutView:A}=NS(),I=Op(),P=((E=d.sharing)==null?void 0:E.html)??!0,R=((U=d.sharing)==null?void 0:U.wasm)??!0,M=sj;let L;t[0]===Symbol.for("react.memo_cache_sentinel")?(L=c.jsx(wp,{size:14,strokeWidth:1.5}),t[0]=L):L=t[0];const F=!P&&!R;let D;t[1]===Symbol.for("react.memo_cache_sentinel")?(D=c.jsx(W9,{size:14,strokeWidth:1.5}),t[1]=D):D=t[1];const T=!P;let k,B;return t[2]!==o||t[3]!==n?(k=async()=>{n(c.jsx(VS,{onClose:o}))},t[2]=o,t[3]=n,t[4]=k):k=t[4],t[5]!==C||t[6]!==f||t[7]!==o||t[8]!==x||t[9]!==y||t[10]!==g||t[11]!==e||t[12]!==N||t[13]!==j||t[14]!==l||t[15]!==i||t[16]!==n||t[17]!==p||t[18]!==b||t[19]!==_||t[20]!==s||t[21]!==v||t[22]!==S||t[23]!==A||t[24]!==w||t[25]!==R||t[26]!==F||t[27]!==T||t[28]!==k||t[29]!==r||t[30]!==I||t[31]!==h||t[32]!==u||t[33]!==m||t[34]!==a.mode?(B=[{icon:L,label:"Share",handle:As,hidden:F,dropdown:[{icon:D,label:"Publish HTML to web",hidden:T,handle:k},{icon:c.jsx(mS,{size:14,strokeWidth:1.5}),label:"Create WebAssembly link",hidden:!R,handle:rj}]},{icon:c.jsx(Qf,{size:14,strokeWidth:1.5}),label:"Download",handle:As,dropdown:[{icon:c.jsx(ES,{size:14,strokeWidth:1.5}),label:"Download as HTML",handle:async()=>{e?await CS({filename:e,includeCode:!0}):Xe({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:c.jsx(ES,{size:14,strokeWidth:1.5}),label:"Download as HTML (exclude code)",handle:async()=>{e?await CS({filename:e,includeCode:!1}):Xe({variant:"danger",title:"Error",description:"Notebooks must be named to be exported."})}},{icon:c.jsx(Gl,{strokeWidth:1.5,style:{width:14,height:14}}),label:"Download as Markdown",handle:oj},{icon:c.jsx(Gm,{size:14,strokeWidth:1.5}),label:"Download Python code",handle:nj},{divider:!0,icon:c.jsx(Rm,{size:14,strokeWidth:1.5}),label:"Download as PNG",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:c.jsxs("span",{children:["Only available in app view. ",c.jsx("br",{}),"Toggle with: ",Ht("global.hideCode",!1)]}),handle:tj},{icon:c.jsx(B9,{size:14,strokeWidth:1.5}),label:"Download as PDF",disabled:a.mode!=="present",tooltip:a.mode==="present"?void 0:c.jsxs("span",{children:["Only available in app view. ",c.jsx("br",{}),"Toggle with: ",Ht("global.hideCode",!1)]}),handle:QN}]},{divider:!0,icon:c.jsx(pp,{size:14,strokeWidth:1.5}),label:"Helper panel",handle:As,dropdown:ed.flatMap(V=>{const{type:$,Icon:X,hidden:Y}=V;return Y?[]:{label:Jf($),rightElement:M(s===$),icon:c.jsx(X,{size:14,strokeWidth:1.5}),handle:()=>r($)}})},{icon:c.jsx(Yc,{size:14,strokeWidth:1.5}),label:"Present as",handle:As,dropdown:[{icon:a.mode==="present"?c.jsx($k,{size:14,strokeWidth:1.5}):c.jsx(Wc,{size:14,strokeWidth:1.5}),label:"Toggle app view",hotkey:"global.hideCode",handle:()=>{I()}},...jS.map((V,$)=>{const X=ug(V);return{divider:$===0,label:hg(V),icon:c.jsx(X,{size:14,strokeWidth:1.5}),rightElement:c.jsx("div",{className:"w-8 flex justify-end",children:_===V&&c.jsx(rc,{size:14})}),handle:()=>{A(V),a.mode==="edit"&&I()}}})]},{icon:c.jsx(Qm,{size:14,strokeWidth:1.5}),label:"Create notebook copy",hidden:!e||Jt(),handle:y},{icon:c.jsx(Bc,{size:14,strokeWidth:1.5}),label:"Copy code to clipboard",hidden:!e,handle:ZN},{icon:c.jsx(ln,{size:14,strokeWidth:1.5}),label:"Enable all cells",hidden:!N||i,handle:async()=>{const V=mn(),$=U9(V),X=Zl.fromEntries($.map(JN));await qo({configs:X});for(const Y of $)u({cellId:Y,config:{disabled:!1}})}},{icon:c.jsx(an,{size:14,strokeWidth:1.5}),label:"Disable all cells",hidden:!j||i,handle:async()=>{const V=mn(),$=pk(V),X=Zl.fromEntries($.map(XN));await qo({configs:X});for(const Y of $)u({cellId:Y,config:{disabled:!0}})}},{icon:c.jsx(Uf,{size:14,strokeWidth:1.5}),label:"Hide all markdown code",handle:l},{icon:c.jsx(Wm,{size:14,strokeWidth:1.5}),label:"Collapse all sections",hotkey:"global.collapseAllSections",handle:x},{icon:c.jsx(Hm,{size:14,strokeWidth:1.5}),label:"Expand all sections",hotkey:"global.expandAllSections",handle:g},{icon:c.jsx(Km,{size:14,strokeWidth:1.5}),label:"Add setup cell",handle:()=>{m({code:"# Initialization code that runs before all other cells"})}},{icon:c.jsx(_a,{size:14,strokeWidth:1.5}),label:"Clear all outputs",handle:()=>{f()}},{icon:c.jsx(Jm,{size:14,strokeWidth:1.5}),label:"Re-run all cells",hotkey:"global.runAll",handle:async()=>{b()}},{icon:c.jsx(Zc,{size:14,strokeWidth:1.5}),label:"Undo cell deletion",hidden:!C||i,handle:()=>{h()}},{icon:c.jsx(Wo,{size:14,strokeWidth:1.5}),label:"Add database connection",handle:()=>{n(c.jsx(dg,{onClose:o}))}},{divider:!0,icon:c.jsx(Uc,{size:14,strokeWidth:1.5}),label:"Command palette",hotkey:"global.commandPalette",handle:()=>v(KN)},{icon:c.jsx(em,{size:14,strokeWidth:1.5}),label:"User settings",handle:()=>w(YN)},{icon:c.jsx(ap,{size:14,strokeWidth:1.5}),label:"Keyboard shortcuts",hotkey:"global.showHelp",handle:()=>S(GN)},{icon:c.jsx(gS,{size:14,strokeWidth:1.5}),label:"Open documentation",handle:qN},{icon:c.jsx(sc,{size:14,strokeWidth:1.5}),label:"Resources",handle:As,dropdown:[{icon:c.jsx(gS,{size:14,strokeWidth:1.5}),label:"Documentation",handle:WN},{icon:c.jsx(QR,{size:14,strokeWidth:1.5}),label:"GitHub",handle:HN},{icon:c.jsx(eL,{size:14,strokeWidth:1.5}),label:"Discord Community",handle:VN},{icon:c.jsx(tL,{size:14,strokeWidth:1.5}),label:"YouTube",handle:$N},{icon:c.jsx(zf,{size:14,strokeWidth:1.5}),label:"Changelog",handle:UN}]},{divider:!0,icon:c.jsx(rp,{size:14,strokeWidth:1.5}),label:"Return home",hidden:!location.search.includes("file"),handle:BN},{icon:c.jsx(ai,{size:14,strokeWidth:1.5}),label:"New notebook",hidden:!location.search.includes("file"),handle:zN},{icon:c.jsx(Ep,{size:14,strokeWidth:1.5}),label:"Restart kernel",variant:"danger",handle:p}].filter(FN).map(RN),t[5]=C,t[6]=f,t[7]=o,t[8]=x,t[9]=y,t[10]=g,t[11]=e,t[12]=N,t[13]=j,t[14]=l,t[15]=i,t[16]=n,t[17]=p,t[18]=b,t[19]=_,t[20]=s,t[21]=v,t[22]=S,t[23]=A,t[24]=w,t[25]=R,t[26]=F,t[27]=T,t[28]=k,t[29]=r,t[30]=I,t[31]=h,t[32]=u,t[33]=m,t[34]=a.mode,t[35]=B):B=t[35],B}function RN(t){return t.dropdown?{...t,dropdown:t.dropdown.filter(LN)}:t}function LN(t){return!t.hidden}function FN(t){return!t.hidden}function zN(){const t=H9();window.open(t,"_blank")}function BN(){const t=document.baseURI.split("?")[0];window.open(t,"_self")}function UN(){window.open(On.releasesPage,"_blank")}function $N(){window.open(On.youtube,"_blank")}function VN(){window.open(On.discordLink,"_blank")}function HN(){window.open(On.githubPage,"_blank")}function WN(){window.open(On.docsPage,"_blank")}function qN(){window.open(On.docsPage,"_blank")}function GN(t){return!t}function YN(t){return!t}function KN(t){return!t}function XN(t){return[t,{disabled:!0}]}function JN(t){return[t,{disabled:!1}]}async function ZN(){const t=await tm();await nn(t.contents),Xe({title:"Copied",description:"Code copied to clipboard."})}async function QN(){const t=new Event("export-beforeprint"),e=new Event("export-afterprint");window.dispatchEvent(t),setTimeout(ej,0),setTimeout(()=>window.dispatchEvent(e),0)}function ej(){return window.print()}async function tj(){const t=document.getElementById("App");t&&await yk(t,document.title)}async function nj(){const t=await tm();za(new Blob([t.contents],{type:"text/plain"}),Vk.toPY(document.title))}async function oj(){const t=await V9({download:!1});za(new Blob([t],{type:"text/plain"}),Vk.toMarkdown(document.title))}async function rj(){const t=await tm(),e=$9({code:t.contents});await nn(e),Xe({title:"Copied",description:"Link copied to clipboard."})}function sj(t){return c.jsx("div",{className:"w-8 flex justify-end",children:t&&c.jsx(rc,{size:14})})}const aj=t=>{const e=H.c(28),{disabled:n,tooltip:o}=t,r=n!==void 0&&n,s=o===void 0?"Actions":o,a=mg();let i,l,d;e[0]!==s?(i=c.jsx("div",{children:s}),e[0]=s,e[1]=i):i=e[1],e[2]!==r?(l=!r&&c.jsxs("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border flex items-center gap-2",children:[c.jsx("span",{children:"Open command palette"}),Ht("global.commandPalette",!1)]}),e[2]=r,e[3]=l):l=e[3],e[4]!==i||e[5]!==l?(d=c.jsxs("div",{className:"flex flex-col gap-2",children:[i,l]}),e[4]=i,e[5]=l,e[6]=d):d=e[6];const u=d,h=r?"disabled":"hint-green";let f,m,x;e[7]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(mL,{strokeWidth:1.8}),e[7]=f):f=e[7],e[8]!==u?(m=c.jsx(Ne,{content:u,children:f}),e[8]=u,e[9]=m):m=e[9],e[10]!==r||e[11]!==h||e[12]!==m?(x=c.jsx(rn,{"aria-label":"Config",shape:"circle",size:"small",className:"h-[27px] w-[27px]","data-testid":"notebook-menu-dropdown",disabled:r,color:h,children:m}),e[10]=r,e[11]=h,e[12]=m,e[13]=x):x=e[13];const g=x,p=ij;let b;e[14]===Symbol.for("react.memo_cache_sentinel")?(b=_=>{const A=c.jsx(It,{variant:_.variant,disabled:_.disabled,onSelect:I=>_.handle(I),"data-testid":`notebook-menu-dropdown-${_.label}`,children:p(_)},_.label);return _.tooltip?c.jsx(Ne,{content:_.tooltip,side:"left",delayDuration:100,children:c.jsx("span",{children:A})},_.label):A},e[14]=b):b=e[14];const y=b;let v,w,S,N,j,C;if(e[15]!==g||e[16]!==r?(v=c.jsx(So,{asChild:!0,disabled:r,children:g}),e[15]=g,e[16]=r,e[17]=v):v=e[17],e[18]!==a){let _;e[20]===Symbol.for("react.memo_cache_sentinel")?(_=A=>A.hidden?null:A.dropdown?c.jsxs(q9,{children:[c.jsx(G9,{"data-testid":`notebook-menu-dropdown-${A.label}`,children:p(A)}),c.jsx(Y9,{children:c.jsx(K9,{children:A.dropdown.map(I=>c.jsxs(G.Fragment,{children:[I.divider&&c.jsx(on,{}),y(I)]},I.label))})})]},A.label):c.jsxs(G.Fragment,{children:[A.divider&&c.jsx(on,{}),y(A)]},A.label),e[20]=_):_=e[20],w=a.map(_),e[18]=a,e[19]=w}else w=e[19];return e[21]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx(on,{}),e[21]=S):S=e[21],e[22]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsx("div",{className:"flex-1 px-2 text-xs text-muted-foreground",children:c.jsxs("span",{children:["Version: ",Hk()]})}),e[22]=N):N=e[22],e[23]!==w?(j=c.jsxs(No,{align:"end",className:"no-print w-[240px]",children:[w,S,N]}),e[23]=w,e[24]=j):j=e[24],e[25]!==v||e[26]!==j?(C=c.jsxs(ko,{modal:!1,children:[v,j]}),e[25]=v,e[26]=j,e[27]=C):C=e[27],C};function ij(t){return c.jsxs(c.Fragment,{children:[t.icon&&c.jsx("span",{className:"flex-0 mr-2",children:t.icon}),c.jsx("span",{className:"flex-1",children:t.labelElement||t.label}),t.hotkey&&c.jsx(nm,{shortcut:t.hotkey,className:"ml-4"}),t.rightElement]})}function ad(t){return jo("create"in t,'Expected query to have a "create" method'),t}const Bt=X9({findText:"",replaceText:"",caseSensitive:!1,wholeWord:!1,regexp:!1,isOpen:!1,currentView:void 0},(t,e)=>{if(e===void 0)return t;switch(e.type){case"setFind":return{...t,findText:e.find};case"setReplace":return{...t,replaceText:e.replace};case"setCaseSensitive":return{...t,caseSensitive:e.caseSensitive};case"setWholeWord":return{...t,wholeWord:e.wholeWord};case"setRegex":return{...t,regexp:e.regexp};case"setIsOpen":return{...t,isOpen:e.isOpen};case"setCurrentView":return{...t,currentView:{view:e.view,range:e.range}};case"clearCurrentView":return{...t,currentView:void 0}}});function pg(t){if([...document.querySelectorAll('[role="dialog"][data-state="open"]')].some(e=>e instanceof HTMLElement&&e.childNodes.length>0))return!1;if(t){const e=t.state.selection.main,n=t.state.sliceDoc(e.from,e.to);n?(Qe.set(Bt,{type:"setFind",find:n}),Qe.set(Bt,{type:"setCurrentView",view:t,range:{from:e.from,to:e.to}})):Qe.set(Bt,{type:"setCurrentView",view:t,range:{from:0,to:0}})}return Qe.get(Bt).isOpen?(Qe.set(Bt,{type:"setIsOpen",isOpen:!1}),requestAnimationFrame(()=>{Qe.set(Bt,{type:"setIsOpen",isOpen:!0})}),!0):(Qe.set(Bt,{type:"setIsOpen",isOpen:!0}),!0)}function lj(){return!!Qe.get(Bt).isOpen&&(Qe.set(Bt,{type:"setIsOpen",isOpen:!1}),!0)}function yi(t){return()=>{const e=Qe.get(Bt),n=new ac({search:e.findText,caseSensitive:e.caseSensitive,regexp:e.regexp,replace:e.replaceText,wholeWord:e.wholeWord});return!!n.valid&&t({query:ad(n).create(),search:n})}}const gg=t=>yi(({query:e})=>{const n=ds(),o=Qe.get(Bt).currentView||{view:n[0],range:{from:0,to:0}};let r=o.range.to;t==="prev"&&(n.reverse(),r=o.range.from);let s=n.indexOf(o.view);s<0&&(s=0);const a=[...n,...n].slice(s);for(const i of a){const l=t==="next"?e.nextMatch(i.state,0,r??0):e.prevMatch(i.state,r??i.state.doc.length,i.state.doc.length);if(!l){r=null,i.dispatch({selection:Kn.single(0)});continue}const d=Kn.single(l.from,l.to);return i.dispatch({selection:d,effects:[Ve.scrollIntoView(d.main,{y:"center"})],userEvent:"select.search"}),Qe.set(Bt,{type:"setCurrentView",view:i,range:{from:l.from,to:l.to}}),l}return!1}),id=gg("next"),xg=gg("prev"),cj=yi(({query:t})=>{var o;const e=ds(),n=[];for(const r of e){if(r.state.readOnly)continue;const s=(o=t.matchAll(r.state,1e9))==null?void 0:o.map(i=>{const{from:l,to:d}=i;return{from:l,to:d,insert:t.getReplacement(i)}});if(!s||s.length===0)continue;const a=r.state.doc.toString();n.push(()=>{r.dispatch({changes:[{from:0,to:r.state.doc.length,insert:a}],userEvent:"input.replace.all"})}),r.dispatch({changes:s,userEvent:"input.replace.all"})}return()=>{for(const r of n)r()}}),dj=yi(({query:t})=>{const e=ds(),n=Qe.get(Bt).currentView||{view:e[0],range:{from:0}};let o=n.range.from,r=e.indexOf(n.view);r<0&&(r=0);const s=[...e,...e].slice(r);for(const a of s){const i=t.nextMatch(a.state,0,o??0);if(!i){o=null,a.dispatch({selection:Kn.single(0)});continue}const l=a.state.toText(t.getReplacement(i));return a.dispatch({changes:[{from:i.from,to:i.to,insert:l}],userEvent:"input.replace"}),id()}return!1}),uj=yi(({query:t})=>{const e=ds();let n=0;const o=new Map;for(const r of e){const s=t.matchAll(r.state,1e9)||[];for(const a of s){const{from:i,to:l}=a,d=o.get(r)||new Map;d.set(`${i}:${l}`,n++),o.set(r,d)}}return{count:n,position:o}}),ld=At.define();function bg(){const t=ds();for(const e of t)e.state.readOnly||e.dispatch({effects:ld.of(new ac({search:""}))})}const vi=xn.define({create(){const t=Qe.get(Bt);return ad(new ac({search:t.findText,caseSensitive:t.caseSensitive,regexp:t.regexp,replace:t.replaceText,wholeWord:t.wholeWord})).create()},update(t,e){for(const n of e.effects)n.is(ld)&&(t=ad(n.value).create());return t}}),hj=tt.mark({class:"cm-searchMatch"}),fj=tt.mark({class:"cm-searchMatch cm-searchMatch-selected"}),mj=Rn.fromClass(class{constructor(t){this.view=t,this.decorations=void 0,this.decorations=this.highlight(t.state.field(vi))}update(t){const e=t.state.field(vi);(e!==t.startState.field(vi)||t.docChanged||t.selectionSet||t.viewportChanged)&&(this.decorations=this.highlight(e))}highlight(t){if(!t.spec.valid)return tt.none;const{view:e}=this,n=new us,o=e.visibleRanges,r=o.length;for(let s=0;s<r;s++){let{to:a}=o[s];const{from:i}=o[s];for(;s<r-1&&a>o[s+1].from-500;)a=o[++s].to;t.highlight(e.state,i,a,(l,d)=>{const u=e.state.selection.ranges.some(h=>h.from===l&&h.to===d);n.add(l,d,u?fj:hj)})}return n.finish()}},{decorations:t=>t.decorations}),pj=Ve.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"}}),gj=()=>{var Le;const t=H.c(102),[e,n]=O.useState(!1),[o,r]=St(Bt),[s,a]=O.useState(),i=O.useRef(null),l=Ie(Jl);let d,u;t[0]!==e||t[1]!==o.isOpen?(d=()=>(!e||!o.isOpen)&&pg(),t[0]=e,t[1]=o.isOpen,t[2]=d):d=t[2],Ot("cell.findAndReplace",d),t[3]===Symbol.for("react.memo_cache_sentinel")?(u=()=>{const Te=uj();a(Te===!1?void 0:Te)},t[3]=u):u=t[3];const h=u;let f,m,x,g;if(t[4]!==o.isOpen?(f=()=>{o.isOpen&&i.current&&(i.current.focus(),i.current.select())},m=[o.isOpen],t[4]=o.isOpen,t[5]=f,t[6]=m):(f=t[5],m=t[6]),O.useEffect(f,m),t[7]!==o.findText||t[8]!==o.isOpen?(x=()=>{if(o.isOpen){if(o.findText==="")return a(void 0),void bg();h(),function(){const Te=Qe.get(Bt),Ze=ds();for(const He of Ze)He.state.readOnly||He.dispatch({effects:ld.of(new ac({search:Te.findText,caseSensitive:Te.caseSensitive,regexp:Te.regexp,replace:Te.replaceText,wholeWord:Te.wholeWord}))})}()}else bg()},t[7]=o.findText,t[8]=o.isOpen,t[9]=x):x=t[9],t[10]!==o.caseSensitive||t[11]!==o.findText||t[12]!==o.isOpen||t[13]!==o.regexp||t[14]!==o.wholeWord?(g=[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]=g):g=t[15],O.useEffect(x,g),!o.isOpen)return null;const p=o.currentView;let b;t[16]!==s||t[17]!==p?(b=p&&s?(Le=s.position.get(p.view))==null?void 0:Le.get(`${p.range.from}:${p.range.to}`):void 0,t[16]=s,t[17]=p,t[18]=b):b=t[18];const y=b;let v,w,S,N,j,C,_,A,I,P,R;t[19]===Symbol.for("react.memo_cache_sentinel")?(v=()=>n(!0),t[19]=v):v=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(w=()=>n(!1),t[20]=w):w=t[20],t[21]!==r?(S=Te=>{Te.key==="Escape"&&r({type:"setIsOpen",isOpen:!1})},t[21]=r,t[22]=S):S=t[22],t[23]!==r?(N=()=>r({type:"setIsOpen",isOpen:!1}),t[23]=r,t[24]=N):N=t[24],t[25]===Symbol.for("react.memo_cache_sentinel")?(j=c.jsx(En,{className:"w-4 h-4"}),t[25]=j):j=t[25],t[26]!==N?(C=c.jsx("div",{className:"absolute top-0 right-0",children:c.jsx(ke,{"data-testid":"close-find-replace-button",onClick:N,size:"xs",variant:"text",children:j})}),t[26]=N,t[27]=C):C=t[27],t[28]!==r?(_=Te=>{r({type:"setFind",find:Te.target.value})},t[28]=r,t[29]=_):_=t[29],t[30]!==o.findText||t[31]!==_?(A=c.jsx(Vo,{ref:i,"data-testid":"find-input",value:o.findText,autoFocus:!0,className:"mr-2 mb-0",placeholder:"Find",onKeyDown:bj,onChange:_}),t[30]=o.findText,t[31]=_,t[32]=A):A=t[32],t[33]!==r?(I=Te=>{r({type:"setReplace",replace:Te.target.value})},t[33]=r,t[34]=I):I=t[34],t[35]!==o.replaceText||t[36]!==I?(P=c.jsx(Vo,{"data-testid":"replace-input",value:o.replaceText,placeholder:"Replace",onChange:I}),t[35]=o.replaceText,t[36]=I,t[37]=P):P=t[37],t[38]!==A||t[39]!==P?(R=c.jsxs("div",{className:"flex flex-col flex-2 gap-2 w-[55%]",children:[A,P]}),t[38]=A,t[39]=P,t[40]=R):R=t[40];const M=o.caseSensitive?"on":"off";let L,F,D;t[41]!==r?(L=Te=>r({type:"setCaseSensitive",caseSensitive:Te}),t[41]=r,t[42]=L):L=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(F=c.jsx(J9,{className:"w-4 h-4"}),t[43]=F):F=t[43],t[44]!==o.caseSensitive||t[45]!==M||t[46]!==L?(D=c.jsx(Ne,{content:"Case Sensitive",children:c.jsx(om,{size:"sm",pressed:o.caseSensitive,"data-state":M,onPressedChange:L,children:F})}),t[44]=o.caseSensitive,t[45]=M,t[46]=L,t[47]=D):D=t[47];const T=o.wholeWord?"on":"off";let k,B,E;t[48]!==r?(k=Te=>r({type:"setWholeWord",wholeWord:Te}),t[48]=r,t[49]=k):k=t[49],t[50]===Symbol.for("react.memo_cache_sentinel")?(B=c.jsx(Mp,{className:"w-4 h-4"}),t[50]=B):B=t[50],t[51]!==o.wholeWord||t[52]!==T||t[53]!==k?(E=c.jsx(Ne,{content:"Match Whole Word",children:c.jsx(om,{size:"sm",pressed:o.wholeWord,"data-state":T,onPressedChange:k,children:B})}),t[51]=o.wholeWord,t[52]=T,t[53]=k,t[54]=E):E=t[54];const U=o.regexp?"on":"off";let V,$,X,Y,J;t[55]!==r?(V=Te=>r({type:"setRegex",regexp:Te}),t[55]=r,t[56]=V):V=t[56],t[57]===Symbol.for("react.memo_cache_sentinel")?($=c.jsx(bp,{className:"w-4 h-4"}),t[57]=$):$=t[57],t[58]!==o.regexp||t[59]!==U||t[60]!==V?(X=c.jsx(Ne,{content:"Use Regular Expression",children:c.jsx(om,{size:"sm",pressed:o.regexp,"data-state":U,onPressedChange:V,children:$})}),t[58]=o.regexp,t[59]=U,t[60]=V,t[61]=X):X=t[61],t[62]!==D||t[63]!==E||t[64]!==X?(Y=c.jsxs("div",{className:"flex items-center gap-[2px]",children:[D,E,X]}),t[62]=D,t[63]=E,t[64]=X,t[65]=Y):Y=t[65],t[66]===Symbol.for("react.memo_cache_sentinel")?(J=()=>{dj()&&h()},t[66]=J):J=t[66];const Q=o.findText==="";let q,K;t[67]!==Q?(q=c.jsx(ke,{"data-testid":"replace-next-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:J,disabled:Q,children:"Replace Next"}),t[67]=Q,t[68]=q):q=t[68],t[69]===Symbol.for("react.memo_cache_sentinel")?(K=()=>{const Te=cj();if(!Te)return;h();const{dismiss:Ze}=Xe({title:"Replaced all occurrences",action:c.jsx(fi,{"data-testid":"undo-replace-all-button",onClick:()=>{Te(),He()}})}),He=Ze},t[69]=K):K=t[69];const re=o.findText==="";let oe,ne,se,te,pe,he,ae,ye,fe,Se,Me,Ee;return t[70]!==re?(oe=c.jsx(ke,{"data-testid":"replace-all-button",size:"xs",variant:"outline",className:"h-6 text-xs",onClick:K,disabled:re,children:"Replace All"}),t[70]=re,t[71]=oe):oe=t[71],t[72]!==q||t[73]!==oe?(ne=c.jsxs("div",{className:"flex items-center gap-[2px]",children:[q,oe]}),t[72]=q,t[73]=oe,t[74]=ne):ne=t[74],t[75]!==Y||t[76]!==ne?(se=c.jsxs("div",{className:"flex flex-col gap-2",children:[Y,ne]}),t[75]=Y,t[76]=ne,t[77]=se):se=t[77],t[78]!==R||t[79]!==se?(te=c.jsxs("div",{className:"flex items-center gap-3",children:[R,se]}),t[78]=R,t[79]=se,t[80]=te):te=t[80],t[81]===Symbol.for("react.memo_cache_sentinel")?(pe=c.jsx(Ne,{content:"Find Previous",children:c.jsx(ke,{"data-testid":"find-prev-button",size:"xs",variant:"secondary",onClick:yj,children:c.jsx(vt,{className:"w-4 h-4"})})}),t[81]=pe):pe=t[81],t[82]===Symbol.for("react.memo_cache_sentinel")?(he=c.jsx(Ne,{content:"Find Next",children:c.jsx(ke,{"data-testid":"find-next-button",size:"xs",variant:"secondary",onClick:vj,children:c.jsx(Lc,{className:"w-4 h-4"})})}),t[82]=he):he=t[82],t[83]!==y||t[84]!==s?(ae=s!=null&&y==null&&c.jsxs("span",{className:"text-sm",children:[s.count," matches"]}),t[83]=y,t[84]=s,t[85]=ae):ae=t[85],t[86]!==y||t[87]!==s?(ye=s!=null&&y!=null&&c.jsxs("span",{className:"text-sm",children:[y+1," of ",s.count]}),t[86]=y,t[87]=s,t[88]=ye):ye=t[88],t[89]!==ae||t[90]!==ye?(fe=c.jsxs("div",{className:"flex items-center gap-2",children:[pe,he,ae,ye]}),t[89]=ae,t[90]=ye,t[91]=fe):fe=t[91],t[92]!==l?(Se=l.getHotkey("cell.findAndReplace"),t[92]=l,t[93]=Se):Se=t[93],t[94]!==Se.key?(Me=c.jsxs("div",{className:"text-xs text-muted-foreground flex gap-1 mt-2",children:["Press"," ",c.jsx(qf,{shortcut:Se.key})," ","again to open the native browser search."]}),t[94]=Se.key,t[95]=Me):Me=t[95],t[96]!==C||t[97]!==te||t[98]!==fe||t[99]!==Me||t[100]!==S?(Ee=c.jsx(rm,{restoreFocus:!0,autoFocus:!0,children:c.jsxs("div",{onFocus:v,onClick:xj,onBlur:w,className:"fixed top-0 right-0 w-[500px] flex flex-col bg-[var(--sage-1)] p-4 z-50 mt-2 mr-3 rounded-md shadow-lg border gap-2 print:hidden",onKeyDown:S,children:[C,te,fe,Me]})}),t[96]=C,t[97]=te,t[98]=fe,t[99]=Me,t[100]=S,t[101]=Ee):Ee=t[101],Ee};function xj(t){t.stopPropagation(),t.preventDefault()}function bj(t){t.key==="Enter"&&(t.shiftKey?xg():id())}function yj(){return xg()}function vj(){return id()}const yg=t=>{const e=H.c(38),{resetOnBlur:n,placeholderText:o,initialValue:r,flexibleWidth:s,onNameChange:a,className:i}=t,l=n!==void 0&&n,d=r===void 0?null:r,u=s!==void 0&&s,[h,f]=O.useState(d);let m;e[0]===Symbol.for("react.memo_cache_sentinel")?(m=[],e[0]=m):m=e[0];const[x,g]=O.useState(m),[p,b]=O.useState(!1),y=O.useRef(null),v=O.useRef(!1);let w,S,N;e[1]!==d?(w=()=>{f(d)},S=[d],e[1]=d,e[2]=w,e[3]=S):(w=e[2],S=e[3]),O.useEffect(w,S),e[4]===Symbol.for("react.memo_cache_sentinel")?(N=()=>{b(!0)},e[4]=N):N=e[4];const j=N;let C;e[5]!==d||e[6]!==l?(C=K=>{var re;(re=K.relatedTarget)!=null&&re.closest(".filename-input")||(b(!1),l&&f(d))},e[5]=d,e[6]=l,e[7]=C):C=e[7];const _=C;let A;e[8]!==h?(A=gn.dirname(h||""),e[8]=h,e[9]=A):A=e[9];const I=A,P=gn.basename(h||""),R=x.filter(K=>gn.basename(K.path).startsWith(P));let M,L;e[10]!==I||e[11]!==p?(M=async()=>{if(!p)return void g([]);const K=await Gk({path:I});g(K.files)},L=[I,p],e[10]=I,e[11]=p,e[12]=M,e[13]=L):(M=e[12],L=e[13]);const{isPending:F}=Cn(M,L),D=function(K,re,oe){if(K&&!K.endsWith("/")&&((Xf("markdown")?new Set(["py","md","markdown","qmd"]):new Set(["py"])).has(gn.extension(K))||(K=K.endsWith(".")?`${K}py`:K.endsWith(".p")?`${K}y`:`${K}.py`),!re.some(ne=>ne.path===K||gn.basename(ne.path)===K)&&!(oe&&(oe===K||gn.basename(oe)===K))))return K}(h,x,d),T=(D||R.length>0)&&c.jsxs(Hf,{className:"font-mono",children:[!F&&c.jsx(Ql,{children:"No files"}),D&&c.jsxs(Gn,{variant:"success",className:"py-2 px-3",onSelect:()=>{var K;D&&(v.current=!0,a(D),(K=y.current)==null||K.blur())},children:[c.jsx(Zm,{className:"w-4 h-4 mr-2"})," ",c.jsxs("span",{className:"text-sm",children:[d?"Rename to: ":"Save as: ",c.jsx("span",{className:"font-medium text-sm",children:gn.basename(D)})]})]},"_rename_"),R.map(K=>{const re=K.isDirectory?"directory":Wk(K.path),oe=qk[re];return c.jsxs(Gn,{variant:K.isDirectory?"default":"muted",className:"py-2 px-3",onSelect:()=>{K.isDirectory?f(`${K.path}/`):f(K.path)},children:[c.jsx(oe,{className:"w-4 h-4 mr-2"})," ",gn.basename(K.path)]},K.path)})]}),k=10*Math.max(20,(h==null?void 0:h.length)||(o==null?void 0:o.length)||0),B=p?h||"":d||"";let E,U,V;e[14]!==u||e[15]!==k?(E=u?{maxWidth:k}:void 0,e[14]=u,e[15]=k,e[16]=E):E=e[16],e[17]!==i?(U=ge(i,"w-full px-4 py-1 my-1 h-9 font-mono text-foreground/60"),e[17]=i,e[18]=U):U=e[18],e[19]!==o||e[20]!==B||e[21]!==E||e[22]!==U?(V=c.jsx(Z9,{children:c.jsx(Ma,{"data-testid":"dir-completion-input",tabIndex:-1,rootClassName:"border-none justify-center px-1",spellCheck:"false",value:B,onKeyDown:wj,icon:null,ref:y,onValueChange:f,placeholder:o,autoComplete:"off",style:E,className:U})}),e[19]=o,e[20]=B,e[21]=E,e[22]=U,e[23]=V):V=e[23];const $=T&&"group-focus-within:block";let X,Y,J,Q,q;return e[24]!==$?(X=ge("p-0 w-full min-w-80 max-w-80vw hidden",$),e[24]=$,e[25]=X):X=e[25],e[26]!==T||e[27]!==X?(Y=c.jsx(hs,{side:"bottom",className:X,portal:!1,children:T}),e[26]=T,e[27]=X,e[28]=Y):Y=e[28],e[29]!==V||e[30]!==Y?(J=c.jsxs(Hf,{children:[V,Y]}),e[29]=V,e[30]=Y,e[31]=J):J=e[31],e[32]!==_||e[33]!==J?(Q=c.jsx(ic,{onFocus:j,onBlur:_,shouldFilter:!1,id:"filename-input",className:"bg-transparent group filename-input",children:J}),e[32]=_,e[33]=J,e[34]=Q):Q=e[34],e[35]!==p||e[36]!==Q?(q=c.jsx(lc,{children:c.jsx(gr,{open:p,modal:!1,children:Q})}),e[35]=p,e[36]=Q,e[37]=q):q=e[37],q};function wj(t){t.key==="Escape"&&t.currentTarget.blur()}const kj=t=>{const e=H.c(33),n=()=>{za(new Blob([o()],{type:"text/plain"}),`${t.proposedName}.json`)},o=Fe(jj);let r,s,a,i,l,d,u,h,f,m,x,g,p,b,y,v,w;return e[0]!==n||e[1]!==t?(r=S=>{S.preventDefault(),n(),t.closeModal()},e[0]=n,e[1]=t,e[2]=r):r=e[2],e[3]!==t?(s=S=>{S.key==="Escape"&&t.closeModal()},e[3]=t,e[4]=s):s=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx($o,{className:"text-accent-foreground mb-6",children:"Download unsaved changes?"}),e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(i={wordBreak:"break-word"},e[6]=i):i=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx("p",{children:"This app has unsaved changes. To recover:"}),d={paddingBottom:"10px"},e[7]=l,e[8]=d):(l=e[7],d=e[8]),e[9]!==t.proposedName?(u=c.jsxs("li",{style:d,children:['Click the "Download" button. This will download a file called\xA0',c.jsxs("code",{children:[t.proposedName,".json"]}),". This file contains your code."]}),e[9]=t.proposedName,e[10]=u):u=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(h={paddingBottom:"10px"},e[11]=h):h=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(f={display:"block",padding:"10px"},e[12]=f):f=e[12],e[13]!==t.proposedName?(m=c.jsxs("code",{style:f,children:["marimo recover ",t.proposedName,".json ",">"," ",t.proposedName,".py"]}),e[13]=t.proposedName,e[14]=m):m=e[14],e[15]!==t.proposedName?(x=c.jsxs("code",{children:[t.proposedName,".py"]}),e[15]=t.proposedName,e[16]=x):x=e[16],e[17]!==x||e[18]!==m?(g=c.jsxs("li",{style:h,children:["In your terminal, type",m,"to overwrite ",x," with the recovered changes."]}),e[17]=x,e[18]=m,e[19]=g):g=e[19],e[20]!==g||e[21]!==u?(p=c.jsx(ss,{className:"markdown break-words",style:i,children:c.jsxs("div",{className:"prose dark:prose-invert",children:[l,c.jsxs("ol",{children:[u,g]})]})}),e[20]=g,e[21]=u,e[22]=p):p=e[22],e[23]!==t.closeModal?(b=c.jsx(ke,{"aria-label":"Cancel",variant:"secondary","data-testid":"cancel-recovery-button",onClick:t.closeModal,children:"Cancel"}),e[23]=t.closeModal,e[24]=b):b=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(y=c.jsx(ke,{"data-testid":"download-recovery-button","aria-label":"Download",variant:"default",type:"submit",children:"Download"}),e[25]=y):y=e[25],e[26]!==b?(v=c.jsxs(ja,{children:[b,y]}),e[26]=b,e[27]=v):v=e[27],e[28]!==r||e[29]!==s||e[30]!==p||e[31]!==v?(w=c.jsx(Ho,{className:"w-fit",children:c.jsxs("form",{onSubmit:r,onKeyDown:s,children:[a,p,v]})}),e[28]=r,e[29]=s,e[30]=p,e[31]=v,e[32]=w):w=e[32],w},Sj=t=>{const e=H.c(12),{filename:n,needsSave:o}=t,{openModal:r,closeModal:s}=jn();let a;e[0]!==n?(a=n===null?"app":gn.basename(n).split(".")[0],e[0]=n,e[1]=a):a=e[1];const i=a;let l;e[2]!==s||e[3]!==o||e[4]!==r||e[5]!==i?(l=()=>{o&&r(c.jsx(kj,{proposedName:i,closeModal:s}))},e[2]=s,e[3]=o,e[4]=r,e[5]=i,e[6]=l):l=e[6];const d=l;let u;Ot("global.save",d),e[7]===Symbol.for("react.memo_cache_sentinel")?(u=Ht("global.save"),e[7]=u):u=e[7];const h=o?"yellow":"gray";let f,m;return e[8]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(li,{strokeWidth:1.5,size:18}),e[8]=f):f=e[8],e[9]!==d||e[10]!==h?(m=c.jsx(Ne,{content:u,children:c.jsx(rn,{onClick:d,id:"save-button","aria-label":"Save",className:"rectangle",color:h,children:f})}),e[9]=d,e[10]=h,e[11]=m):m=e[11],m};function Nj(t){return{id:t.id,name:t.name,code:t.code,code_hash:null,config:{column:0,...t.config}}}function jj(){const t=mn(),e=sm(t),n={version:"1",metadata:{marimo_version:Hk()},cells:e.map(Nj)};return JSON.stringify(n,null,2)}const cd=5e3;async function Cj(){await nO({download:!1})}async function Ej(){await tO({download:!1,includeCode:!0,files:vS.INSTANCE.filenames()})}async function _j(){await eO({download:!1})}const dd=mt(void 0),vg=mt(t=>{const e=t(dd);return function({state:n,layout:o,lastSavedNotebook:r}){if(!r)return!1;const{cellIds:s,cellData:a}=n,i=s.inOrderIds.map(h=>a[h]),l=i.map(h=>h.code),d=i.map(h=>h.config),u=i.map(h=>h.name);return!(Yk(l,r.codes)&&Yk(u,r.names)&&Ba(d,r.configs)&&Ba(o.selectedLayout,r.layout.selectedLayout)&&Ba(o.layoutData,r.layout.layoutData))}({state:t(pn),layout:t(_S),lastSavedNotebook:e})});function Ij(t){return JSON.stringify(t)}const Aj=t=>{const e=H.c(15),{kioskMode:n}=t,o=Zf(),r=Ie(vg),s=Ie(Yn).state===Ft.CLOSED,{saveOrNameNotebook:a,saveIfNotebookIsPersistent:i}=ud();let l,d,u;e[0]!==n||e[1]!==i?(l={onSave:i,kioskMode:n},e[0]=n,e[1]=i,e[2]=l):l=e[2],function(p){const b=H.c(14),y=Ie(Jk),v=fs(),[w]=St(Yn),S=Ie(vg);let N,j;if(b[0]!==v){const P=sm(v);N=P.map(Pj),j=P.map(Dj),b[0]=v,b[1]=N,b[2]=j}else N=b[1],j=b[2];const C=j;let _;b[3]!==v?(_=Xk(v),b[3]=v,b[4]=_):_=b[4];const A=_;let I;b[5]!==y||b[6]!==C||b[7]!==N||b[8]!==A||b[9]!==w||b[10]!==S||b[11]!==p.kioskMode||b[12]!==p.onSave?(I={onSave:p.onSave,needsSave:S,codes:N,cellConfigs:A,cellNames:C,connStatus:w,config:y,kioskMode:p.kioskMode},b[5]=y,b[6]=C,b[7]=N,b[8]=A,b[9]=w,b[10]=S,b[11]=p.kioskMode,b[12]=p.onSave,b[13]=I):I=b[13],function(P){const R=H.c(21),{codes:M,cellConfigs:L,config:F,connStatus:D,cellNames:T,needsSave:k,kioskMode:B,onSave:E}=P,U=O.useRef(null);let V;R[0]!==M?(V=M.join(":"),R[0]=M,R[1]=V):V=R[1];const $=V;let X;R[2]!==L?(X=L.map(Ij).join(":"),R[2]=L,R[3]=X):X=R[3];const Y=X;let J;R[4]!==T?(J=T.join(":"),R[4]=T,R[5]=J):J=R[5];const Q=J;let q,K;R[6]!==F||R[7]!==D.state||R[8]!==B||R[9]!==k||R[10]!==E?(q=()=>{if(!B)return F.autosave==="after_delay"&&(U.current!==null&&clearTimeout(U.current),k&&D.state===Ft.OPEN&&(U.current=setTimeout(E,F.autosave_delay))),()=>{U.current!==null&&clearTimeout(U.current)}},R[6]=F,R[7]=D.state,R[8]=B,R[9]=k,R[10]=E,R[11]=q):q=R[11],R[12]!==Y||R[13]!==Q||R[14]!==$||R[15]!==F||R[16]!==D.state||R[17]!==B||R[18]!==k||R[19]!==E?(K=[$,Y,Q,F,D.state,E,B,k],R[12]=Y,R[13]=Q,R[14]=$,R[15]=F,R[16]=D.state,R[17]=B,R[18]=k,R[19]=E,R[20]=K):K=R[20],O.useEffect(q,K)}(I)}(l),function(){const p=H.c(6),b=Ie(Q9),{state:y}=Ie(Yn),v=b.auto_download.includes("markdown"),w=b.auto_download.includes("html"),S=b.auto_download.includes("ipynb"),N=!v||y!==Ft.OPEN,j=!w||y!==Ft.OPEN,C=!S||y!==Ft.OPEN;let _,A,I;p[0]!==N?(_={delayMs:cd,whenVisible:!0,disabled:N},p[0]=N,p[1]=_):_=p[1],ei(_j,_),p[2]!==j?(A={delayMs:cd,whenVisible:!0,disabled:j},p[2]=j,p[3]=A):A=p[3],ei(Ej,A),p[4]!==C?(I={delayMs:cd,whenVisible:!0,disabled:C},p[4]=C,p[5]=I):I=p[5],ei(Cj,I)}(),e[3]!==r?(d=p=>{if(r)return p.preventDefault(),p.returnValue="You have unsaved changes. Are you sure you want to leave?",p.returnValue},e[3]=r,e[4]=d):d=e[4],Vl(window,"beforeunload",d),e[5]!==a?(u=p=>{p.preventDefault(),p.stopPropagation(),a()},e[5]=a,e[6]=u):u=e[6];const h=u;if(Ot("global.save",a),s){let p;return e[7]!==o||e[8]!==r?(p=c.jsx(Sj,{filename:o,needsSave:r}),e[7]=o,e[8]=r,e[9]=p):p=e[9],p}let f;e[10]===Symbol.for("react.memo_cache_sentinel")?(f=Ht("global.save"),e[10]=f):f=e[10];const m=r?"yellow":"hint-green";let x,g;return e[11]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(li,{strokeWidth:1.5,size:18}),e[11]=x):x=e[11],e[12]!==h||e[13]!==m?(g=c.jsx(Ne,{content:f,children:c.jsx(rn,{"data-testid":"save-button",id:"save-button",shape:"rectangle",color:m,onClick:h,children:x})}),e[12]=h,e[13]=m,e[14]=g):g=e[14],g};function ud(){const t=H.c(19),{openModal:e,closeModal:n,openAlert:o}=jn(),r=kt(dd),s=Kk(),a=am();let i;t[0]!==o||t[1]!==r||t[2]!==a?(i=(p,b)=>{const y=mn(),v=sm(y),w=v.map(Oj),S=v.map(Mj),N=v.map(Tj),j=Xk(y),C=a.get(Yn),_=a.get(Jk),A=a.get(_S);a.get(as)||S.length!==0&&(C.state===Ft.OPEN?(ht.log("saving to ",p),oO({cellIds:w,codes:S,names:N,filename:p,configs:j,layout:pL(),persist:!0}).then(()=>{b&&_.format_on_save&&Zk(),r({names:N,codes:S,configs:j,layout:A})})):o("Failed to save notebook: not connected to a kernel."))},t[0]=o,t[1]=r,t[2]=a,t[3]=i):i=t[3];const l=Fe(i);let d;t[4]!==l||t[5]!==a?(d=p=>{const b=p!==void 0&&p,y=a.get(Qk),v=a.get(Yn);wg(y)&&v.state===Ft.OPEN&&l(y,b)},t[4]=l,t[5]=a,t[6]=d):d=t[6];const u=Fe(d);let h;t[7]!==l||t[8]!==s?(h=p=>{s(p).then(b=>{b!==null&&l(b,!0)})},t[7]=l,t[8]=s,t[9]=h):h=t[9];const f=h;let m;t[10]!==n||t[11]!==f||t[12]!==e||t[13]!==u||t[14]!==a?(m=()=>{const p=a.get(Qk),b=a.get(Yn);u(!0),wg(p)||b.state===Ft.CLOSED||e(c.jsx(Rj,{onClose:n,onSave:f}))},t[10]=n,t[11]=f,t[12]=e,t[13]=u,t[14]=a,t[15]=m):m=t[15];const x=Fe(m);let g;return t[16]!==u||t[17]!==x?(g={saveOrNameNotebook:x,saveIfNotebookIsPersistent:u},t[16]=u,t[17]=x,t[18]=g):g=t[18],g}function Tj(t){return t.name}function Mj(t){return t.code}function Oj(t){return t.id}function wg(t){return t!==null&&!t.startsWith("/tmp")&&!t.startsWith("/var/folders")&&!t.includes("AppData\\Local\\Temp")}function Dj(t){return t.name}function Pj(t){return t.code}const Rj=t=>{const e=H.c(17),{onClose:n,onSave:o}=t,[r,s]=O.useState();let a;e[0]!==n||e[1]!==o?(a=p=>{s(p),p.trim()&&(o(p),n())},e[0]=n,e[1]=o,e[2]=a):a=e[2];const i=a;let l,d,u,h;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx($o,{children:"Save notebook"}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(fr,{className:"text-md pt-6 px-1",children:"Save as"}),e[4]=d):d=e[4],e[5]!==i?(u=c.jsxs("div",{className:"flex flex-col",children:[d,c.jsx(yg,{onNameChange:i,placeholderText:"filename",className:"missing-filename"})]}),e[5]=i,e[6]=u):u=e[6],e[7]!==n?(h=c.jsx(ke,{"data-testid":"cancel-save-dialog-button","aria-label":"Cancel",variant:"secondary",onClick:n,children:"Cancel"}),e[7]=n,e[8]=h):h=e[8];const f=!r;let m,x,g;return e[9]!==f?(m=c.jsx(ke,{"data-testid":"submit-save-dialog-button","aria-label":"Save",variant:"default",disabled:f,type:"submit",children:"Save"}),e[9]=f,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(x=c.jsxs(ja,{children:[h,m]}),e[11]=h,e[12]=m,e[13]=x):x=e[13],e[14]!==u||e[15]!==x?(g=c.jsxs(Ho,{children:[l,u,x]}),e[14]=u,e[15]=x,e[16]=g):g=e[16],g};function kg(t){const e=H.c(3),[n,o]=O.useState(!1);let r,s;return e[0]!==t?(r=()=>{if(!t)return;o(!1);const a=setTimeout(()=>{o(!0)},200);return()=>clearTimeout(a)},s=[t],e[0]=t,e[1]=r,e[2]=s):(r=e[1],s=e[2]),O.useEffect(r,s),t&&n}const Ts=t=>{const{children:e}=t;return Ie(as)?null:e},Lj=t=>{const{children:e}=t;return Ie(as)?e:null},Fj=()=>{const t=H.c(6),e=kt(od);let n;t[0]!==e?(n=()=>e(zj),t[0]=e,t[1]=n):n=t[1];const o=n;let r,s,a;return t[2]===Symbol.for("react.memo_cache_sentinel")?(r=Ht("global.commandPalette"),t[2]=r):r=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx(Uc,{strokeWidth:1.5,size:18}),t[3]=s):s=t[3],t[4]!==o?(a=c.jsx(Ne,{content:r,children:c.jsx(rn,{"data-testid":"command-palette-button",onClick:o,shape:"rectangle",color:"hint-green",children:s})}),t[4]=o,t[5]=a):a=t[5],a};function zj(t){return!t}const Bj=t=>{const e=H.c(47),{presenting:n,onTogglePresenting:o,onInterrupt:r,onRun:s,connectionState:a,running:i,appConfig:l}=t,d=l.width,u=Ie(Uk),h=Ie(rO),{undoDeleteCell:f}=it(),m=a===Ft.CLOSED;let x,g=null;if(!m&&u){let k,B;e[0]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(Zc,{size:16,strokeWidth:1.5}),e[0]=k):k=e[0],e[1]!==f?(B=c.jsx(Ne,{content:"Undo cell deletion",children:c.jsx(rn,{"data-testid":"undo-delete-cell",size:"medium",color:"hint-green",shape:"circle",onClick:f,children:k})}),e[1]=f,e[2]=B):B=e[2],g=B}e[3]!==a?(x=Xn(a),e[3]=a,e[4]=x):x=e[4];const p=x;let b;e[5]!==a||e[6]!==p?(b=p?cc(a):void 0,e[5]=a,e[6]=p,e[7]=b):b=e[7];const y=b;let v,w;e[8]!==n?(v=!n&&c.jsx(gj,{}),e[8]=n,e[9]=v):v=e[9],e[10]!==m||e[11]!==y||e[12]!==p||e[13]!==n?(w=!m&&c.jsxs("div",{className:Vj,children:[n&&c.jsx(MN,{}),c.jsx(aj,{disabled:p,tooltip:y}),c.jsx(nL,{disabled:p,tooltip:y}),c.jsx(oL,{description:"This will terminate the Python kernel. You'll lose all data that's in memory.",disabled:p,tooltip:y})]}),e[10]=m,e[11]=y,e[12]=p,e[13]=n,e[14]=w):w=e[14];const S=d==="compact"&&"xl:flex-row items-end";let N,j,C,_,A,I,P,R,M,L,F,D,T;return e[15]!==S?(N=ge(Hj,S),e[15]=S,e[16]=N):N=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(j=c.jsx(Ts,{children:c.jsx(Aj,{kioskMode:!1})}),e[17]=j):j=e[17],e[18]===Symbol.for("react.memo_cache_sentinel")?(C=Ht("global.hideCode"),e[18]=C):C=e[18],e[19]!==n?(_=n?c.jsx($k,{strokeWidth:1.5,size:18}):c.jsx(Wc,{strokeWidth:1.5,size:18}),e[19]=n,e[20]=_):_=e[20],e[21]!==o||e[22]!==_?(A=c.jsx(Ne,{content:C,children:c.jsx(rn,{"data-testid":"hide-code-button",id:"preview-button",shape:"rectangle",color:"hint-green",onClick:o,children:_})}),e[21]=o,e[22]=_,e[23]=A):A=e[23],e[24]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsx(Fj,{}),P=c.jsx(rL,{}),R=c.jsx("div",{}),e[24]=I,e[25]=P,e[26]=R):(I=e[24],P=e[25],R=e[26]),e[27]!==m||e[28]!==r||e[29]!==i?(M=!m&&c.jsx($j,{running:i,onInterrupt:r}),e[27]=m,e[28]=r,e[29]=i,e[30]=M):M=e[30],e[31]!==m||e[32]!==h||e[33]!==s?(L=!m&&c.jsx(Uj,{needsRun:h,onRun:s}),e[31]=m,e[32]=h,e[33]=s,e[34]=L):L=e[34],e[35]!==M||e[36]!==L||e[37]!==g?(F=c.jsx(Ts,{children:c.jsxs("div",{className:"flex flex-col gap-2 items-center",children:[g,M,L]})}),e[35]=M,e[36]=L,e[37]=g,e[38]=F):F=e[38],e[39]!==A||e[40]!==F||e[41]!==N?(D=c.jsxs("div",{className:N,children:[j,A,I,P,R,F]}),e[39]=A,e[40]=F,e[41]=N,e[42]=D):D=e[42],e[43]!==D||e[44]!==v||e[45]!==w?(T=c.jsxs(c.Fragment,{children:[v,w,D]}),e[43]=D,e[44]=v,e[45]=w,e[46]=T):T=e[46],T},Uj=t=>{const e=H.c(8),{needsRun:n,onRun:o}=t,r=Ie(e3);if(n){let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=Ht("global.runStale"),e[0]=l):l=e[0];const d=r?o:void 0,u=!r;let h,f;return e[1]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(wr,{strokeWidth:1.5,size:16}),e[1]=h):h=e[1],e[2]!==d||e[3]!==u?(f=c.jsx(Ne,{content:l,children:c.jsx(rn,{"data-testid":"run-button",size:"medium",color:"yellow",shape:"circle",onClick:d,disabled:u,children:h})}),e[2]=d,e[3]=u,e[4]=f):f=e[4],f}const s=!r;let a,i;return e[5]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(wr,{strokeWidth:1.5,size:16}),e[5]=a):a=e[5],e[6]!==s?(i=c.jsx(Ne,{content:"Nothing to run",children:c.jsx(rn,{"data-testid":"run-button",className:"inactive-button",color:"disabled",size:"medium",shape:"circle",disabled:s,children:a})}),e[6]=s,e[7]=i):i=e[7],i},$j=t=>{const e=H.c(8),{running:n,onInterrupt:o}=t,r=kg(n);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Ht("global.interrupt"),e[0]=s):s=e[0];const a=!r&&"inactive-button active:shadow-xsSolid";let i;e[1]!==a?(i=ge(a),e[1]=a,e[2]=i):i=e[2];const l=r?"yellow":"disabled",d=r?o:Pn.NOOP;let u,h;return e[3]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(tc,{strokeWidth:1.5,size:16}),e[3]=u):u=e[3],e[4]!==i||e[5]!==l||e[6]!==d?(h=c.jsx(Ne,{content:s,children:c.jsx(rn,{className:i,"data-testid":"interrupt-button",size:"medium",color:l,shape:"circle",onClick:d,children:u})}),e[4]=i,e[5]=l,e[6]=d,e[7]=h):h=e[7],h},Vj="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",Hj="absolute bottom-5 right-5 flex flex-col gap-2 items-center no-print pointer-events-auto z-30 print:hidden",Wj=t=>{const e=H.c(7),{filename:n}=t,o=Kk();let r;e[0]!==n?(r=n?gn.basename(n):"untitled marimo notebook",e[0]=n,e[1]=r):r=e[1];const s=n===null?"missing-filename":"filename";let a;return e[2]!==n||e[3]!==o||e[4]!==r||e[5]!==s?(a=c.jsx(yg,{placeholderText:r,initialValue:n,onNameChange:o,flexibleWidth:!0,resetOnBlur:!0,"data-testid":"filename-input",className:s}),e[2]=n,e[3]=o,e[4]=r,e[5]=s,e[6]=a):a=e[6],a},Sg=mt(new Map);function Ms(){const t=H.c(10),[e,n]=St(Sg),o=am();let r;t[0]!==n||t[1]!==o?(r=h=>{const f=o.get(pn),m=o.get(dc),x=new Set(f.cellIds.inOrderIds.filter(p=>f.cellData[p].code.trim()==="")),g=new Map;for(const p of h){if(x.has(p)){g.set(p,{cellId:p,type:"simple"});continue}const b=f.cellRuntime[p],y=new Map;for(const w of Object.values(m)){const S=w.declaredBy.includes(p),N=w.usedBy.some(j=>!x.has(j));S&&N&&y.set(w.name,w.usedBy)}let v;b!=null&&b.runElapsedTimeMs&&b.runElapsedTimeMs>2e3&&(v=b.runElapsedTimeMs),y.size===0&&v===void 0?g.set(p,{cellId:p,type:"simple"}):g.set(p,{cellId:p,type:"expensive",executionDurationMs:v,defs:y})}n(g)},t[0]=n,t[1]=o,t[2]=r):r=t[2];const s=r;let a;t[3]!==n?(a=()=>{n(new Map)},t[3]=n,t[4]=a):a=t[4];const i=a,l=e.size===0,d=e.size>1;let u;return t[5]!==i||t[6]!==s||t[7]!==l||t[8]!==d?(u={idle:l,shouldConfirmDelete:d,submit:s,clear:i},t[5]=i,t[6]=s,t[7]=l,t[8]=d,t[9]=u):u=t[9],u}function qj(t){return t.cellId}function Gj(t){return t.cellId}function Yj(t){return t.type==="simple"}function Ng(){return{selectionStart:null,selectionEnd:null,selected:new Set}}const{valueAtom:hd,useActions:Kj}=sO(Ng,{select:(t,e)=>({selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])}),extend:(t,e)=>{if(!t.selectionStart)return{selectionStart:e.cellId,selectionEnd:e.cellId,selected:new Set([e.cellId])};const{cellId:n,allCellIds:o}=e;try{const r=o.findWithId(t.selectionStart),s=r.indexOfOrThrow(t.selectionStart),a=r.indexOfOrThrow(n),[i,l]=s<a?[s,a]:[a,s],d=r.slice(i,l+1);return{selectionStart:t.selectionStart,selectionEnd:n,selected:new Set(d)}}catch{return{selectionStart:n,selectionEnd:n,selected:new Set([n])}}},clear:t=>t.selected.size===0?t:Ng()});function wi(){return Kj()}const Xj=t=>{const e=H.c(14),{actions:n,cellIds:o,disabled:r}=t;let s,a,i,l,d;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx(Dc,{size:13,strokeWidth:1.5}),e[0]=s):s=e[0],e[1]!==r?(a=c.jsx(So,{asChild:!0,children:c.jsx(ke,{variant:"ghost",size:"sm",className:"h-8 px-2 gap-1",title:"More actions",disabled:r,children:s})}),e[1]=r,e[2]=a):a=e[2],e[3]!==n||e[4]!==o){let u;e[6]!==n.length||e[7]!==o?(u=(h,f)=>{const m=h.map(x=>c.jsx(It,{onSelect:()=>x.handle(o),className:"flex items-center gap-2",children:c.jsxs("div",{className:"flex items-center flex-1",children:[x.icon&&c.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:x.icon}),c.jsx("div",{className:"flex-1",children:x.label}),x.hotkey&&c.jsx(nm,{shortcut:x.hotkey,className:"ml-4"})]})},x.label));return c.jsxs(G.Fragment,{children:[m,f<n.length-1&&c.jsx(on,{})]},f)},e[6]=n.length,e[7]=o,e[8]=u):u=e[8],i=n.flatMap(u),e[3]=n,e[4]=o,e[5]=i}else i=e[5];return e[9]!==i?(l=c.jsx(No,{align:"start","data-keep-cell-selection":!0,children:i}),e[9]=i,e[10]=l):l=e[10],e[11]!==a||e[12]!==l?(d=c.jsxs(ko,{children:[a,l]}),e[11]=a,e[12]=l,e[13]=d):d=e[13],d};function Jj(t){return t.length>0}function Zj(t){return t.filter(Qj)}function Qj(t){return!t.hidden}function e4(t){return t.length>0}function t4(t){return t.filter(n4)}function n4(t){return!t.hidden}function o4(t){const e={};t.forEach(n=>{const o=Ia(n);o&&(e[n]=o)}),Sk(e)}const r4=()=>{const t=H.c(4),e=Ie(hd);let n;t[0]!==e.selected?(n=[...e.selected],t[0]=e.selected,t[1]=n):n=t[1];const o=n;if(o.length<2)return null;let r;return t[2]!==o?(r=c.jsxs(c.Fragment,{children:[c.jsx(a4,{cellIds:o}),c.jsx(s4,{cellIds:o})]}),t[2]=o,t[3]=r):r=t[3],r},fd=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:"h-4 w-px bg-border mx-1"}),t[0]=e):e=t[0],e},s4=t=>{const e=H.c(12),{cellIds:n}=t,o=Ms(),r=pi(),s=wi();if(!o.shouldConfirmDelete)return null;let a,i,l,d,u;return e[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(im,{className:"w-4 h-4 text-[var(--amber-11)] mt-0.5 flex-shrink-0"}),e[0]=a):a=e[0],e[1]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[c.jsx("p",{className:"text-[var(--amber-11)] font-medium",children:"Some cells in selection may contain expensive operations."}),c.jsx("p",{className:"text-[var(--amber-11)] mt-1",children:"Are you sure you want to delete?"})]}),e[1]=i):i=e[1],e[2]!==o?(l=c.jsx(ke,{size:"xs",variant:"ghost",onClick:()=>o.clear(),className:"text-[var(--amber-11)] hover:bg-[var(--amber-4)] hover:text-[var(--amber-11)]",children:"Cancel"}),e[2]=o,e[3]=l):l=e[3],e[4]!==n||e[5]!==r||e[6]!==o||e[7]!==s?(d=c.jsx(ke,{size:"xs",variant:"secondary",onClick:()=>{r({cellIds:n}),o.clear(),s.clear()},className:"bg-[var(--amber-11)] hover:bg-[var(--amber-12)] text-white border-[var(--amber-11)]",children:"Delete"}),e[4]=n,e[5]=r,e[6]=o,e[7]=s,e[8]=d):d=e[8],e[9]!==l||e[10]!==d?(u=c.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:c.jsx("div",{className:"mx-20",children:c.jsx("div",{className:"bg-[var(--amber-2)] border border-[var(--amber-6)] rounded-lg shadow-lg mt-14 px-4 py-3 animate-in slide-in-from-top-2 duration-200",children:c.jsxs("div",{className:"flex items-start gap-3",children:[a,c.jsxs("div",{className:"flex-1",children:[i,c.jsx(rm,{restoreFocus:!0,autoFocus:!0,children:c.jsxs("div",{className:"flex items-center gap-2 mt-3",onKeyDown:i4,children:[l,d]})})]})]})})})}),e[9]=l,e[10]=d,e[11]=u):u=e[11],u},a4=t=>{const e=H.c(23),{cellIds:n}=t,o=wi(),r=Ms(),{actions:s,moreActions:a}=function(p){const b=H.c(30),{updateCellConfig:y,moveCell:v,clearCellOutput:w,sendToTop:S,sendToBottom:N}=it(),j=pi(),C=Ie(Hl),_=wi(),A=Es(),I=Ms(),P=Ie(Ua),R=p.length,M=!C||R<p.length;let L;b[0]!==j||b[1]!==I||b[2]!==_||b[3]!==P?(L=re=>{I.idle&&P.keymap.destructive_delete?I.submit(re):(j({cellIds:re}),I.clear(),_.clear())},b[0]=j,b[1]=I,b[2]=_,b[3]=P,b[4]=L):L=b[4];const F=Fe(L);let D;b[5]!==v?(D=(re,oe)=>{if(oe==="down"){const ne=re[re.length-1];if(Qe.get(pn).cellIds.findWithId(ne).last()===ne)return}if(oe==="up"){const ne=re[0];if(Qe.get(pn).cellIds.findWithId(ne).first()===ne)return}(oe==="up"?re:[...re].reverse()).forEach(ne=>{v({cellId:ne,before:oe==="up"})})},b[5]=v,b[6]=D):D=b[6];const T=Fe(D);let k;b[7]!==S?(k=re=>{[...re].reverse().forEach(oe=>{S({cellId:oe})})},b[7]=S,b[8]=k):k=b[8];const B=Fe(k);let E;b[9]!==N?(E=re=>{re.forEach(oe=>{N({cellId:oe})})},b[9]=N,b[10]=E):E=b[10];const U=Fe(E),V=Fe(o4);let $;b[11]!==w?($=re=>{re.forEach(oe=>{w({cellId:oe})})},b[11]=w,b[12]=$):$=b[12];const X=Fe($);let Y;b[13]!==y?(Y=async(re,oe,ne)=>{const se={};re.forEach(te=>{se[te]={[oe]:ne}}),await qo({configs:se}),re.forEach(te=>{y({cellId:te,config:se[te]})})},b[13]=y,b[14]=Y):Y=b[14];const J=Fe(Y);let Q,q,K;if(b[15]===Symbol.for("react.memo_cache_sentinel")?(Q=c.jsx(wr,{size:13,strokeWidth:1.5}),b[15]=Q):Q=b[15],b[16]!==A?(q=re=>A(re),b[16]=A,b[17]=q):q=b[17],b[18]!==M||b[19]!==X||b[20]!==F||b[21]!==V||b[22]!==T||b[23]!==U||b[24]!==B||b[25]!==q||b[26]!==J){const re=[[{icon:Q,label:"Run cells",handle:q,hotkey:"cell.run"}],[{icon:c.jsx(Kl,{size:13,strokeWidth:1.5}),label:"Move up",handle:te=>T(te,"up"),hotkey:"cell.moveUp"},{icon:c.jsx(wo,{size:13,strokeWidth:1.5}),label:"Move down",handle:te=>T(te,"down"),hotkey:"cell.moveDown"}],[{icon:c.jsx(Xl,{size:13,strokeWidth:1.5}),label:"Delete cells",variant:"danger",hidden:!M,handle:F}]],oe=[[{icon:c.jsx(Nk,{size:13,strokeWidth:1.5}),label:"Format cells",handle:V,hotkey:"cell.format"},{icon:c.jsx(_a,{size:13,strokeWidth:1.5}),label:"Clear outputs",handle:X}],[{icon:c.jsx(Uf,{size:13,strokeWidth:1.5}),label:"Hide code",handle:te=>J(te,"hide_code",!0),hotkey:"cell.hideCode"},{icon:c.jsx(Bf,{size:13,strokeWidth:1.5}),label:"Show code",handle:te=>J(te,"hide_code",!1),hotkey:"cell.hideCode"}],[{icon:c.jsx(Kl,{size:13,strokeWidth:1.5}),label:"Move up",handle:te=>T(te,"up"),hotkey:"cell.moveUp"},{icon:c.jsx(wo,{size:13,strokeWidth:1.5}),label:"Move down",handle:te=>T(te,"down"),hotkey:"cell.moveDown"},{icon:c.jsx(zc,{size:13,strokeWidth:1.5}),label:"Send to top",handle:B,hotkey:"cell.sendToTop"},{icon:c.jsx(Fc,{size:13,strokeWidth:1.5}),label:"Send to bottom",handle:U,hotkey:"cell.sendToBottom"}],[{icon:c.jsx(an,{size:13,strokeWidth:1.5}),label:"Disable cells",handle:te=>J(te,"disabled",!0)},{icon:c.jsx(ln,{size:13,strokeWidth:1.5}),label:"Enable cells",handle:te=>J(te,"disabled",!1)}]],ne=re.map(t4);let se;b[28]!==ne?(se=ne.filter(e4),b[28]=ne,b[29]=se):se=b[29],K={actions:se,moreActions:oe.map(Zj).filter(Jj)},b[18]=M,b[19]=X,b[20]=F,b[21]=V,b[22]=T,b[23]=U,b[24]=B,b[25]=q,b[26]=J,b[27]=K}else K=b[27];return K}(n),i=n.length;let l;e[0]!==r||e[1]!==o?(l=p=>{(p.target instanceof HTMLElement||p.target instanceof SVGElement)&&p.target.closest("[data-keep-cell-selection]")!==null||p.target instanceof HTMLHtmlElement||(r.clear(),o.clear())},e[0]=r,e[1]=o,e[2]=l):l=e[2],Vl(window,"mousedown",l);const d=!r.idle;let u,h,f,m,x,g;if(e[3]!==i?(u=c.jsxs("span",{className:"text-sm font-medium text-muted-foreground px-2 flex-shrink-0",children:[i," cells selected"]}),e[3]=i,e[4]=u):u=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(fd,{}),e[5]=h):h=e[5],e[6]!==s||e[7]!==n||e[8]!==d){let p;e[10]!==s.length||e[11]!==n||e[12]!==d?(p=(b,y)=>c.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[b.map(v=>c.jsxs(ke,{variant:v.variant==="danger"?"linkDestructive":"ghost",size:"sm",onClick:()=>v.handle(n),className:"h-8 px-2 gap-1 flex-shrink-0 flex items-center",title:v.label,disabled:d&&v.label!=="Delete cells",children:[v.icon,c.jsx("span",{className:"text-xs",children:v.label}),v.hotkey&&c.jsx("div",{className:"ml-1 border bg-muted rounded-md px-1",children:c.jsx(nm,{shortcut:v.hotkey})})]},v.label)),y<s.length-1&&c.jsx(fd,{})]},y),e[10]=s.length,e[11]=n,e[12]=d,e[13]=p):p=e[13],f=s.map(p),e[6]=s,e[7]=n,e[8]=d,e[9]=f}else f=e[9];return e[14]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(fd,{}),e[14]=m):m=e[14],e[15]!==n||e[16]!==d||e[17]!==a?(x=c.jsx(Xj,{actions:a,cellIds:n,disabled:d}),e[15]=n,e[16]=d,e[17]=a,e[18]=x):x=e[18],e[19]!==u||e[20]!==f||e[21]!==x?(g=c.jsx("div",{className:"absolute top-12 justify-center flex w-full left-0 right-0 z-50","data-keep-cell-selection":!0,children:c.jsx("div",{className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border border-[var(--slate-7)] rounded-lg shadow-lg p-2 overflow-x-auto overflow-y-hidden mx-20 scrollbar-thin",children:c.jsxs("div",{className:"flex items-center gap-1",children:[u,h,f,m,x]})})}),e[19]=u,e[20]=f,e[21]=x,e[22]=g):g=e[22],g};function i4(t){t.stopPropagation()}const l4={display:"none"};function c4(t){let{id:e,value:n}=t;return G.createElement("div",{id:e,style:l4},n)}function d4(t){let{id:e,announcement:n,ariaLiveType:o="assertive"}=t;return G.createElement("div",{id:e,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":o,"aria-atomic":!0},n)}const jg=O.createContext(null),u4={draggable:`
99
- To pick up a draggable item, press the space bar.
100
- While dragging, use the arrow keys to move the item.
101
- Press space again to drop the item in its new position, or press escape to cancel.
102
- `},h4={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function f4(t){let{announcements:e=h4,container:n,hiddenTextDescribedById:o,screenReaderInstructions:r=u4}=t;const{announce:s,announcement:a}=function(){const[h,f]=O.useState("");return{announce:O.useCallback(m=>{m!=null&&f(m)},[]),announcement:h}}(),i=$a("DndLiveRegion"),[l,d]=O.useState(!1);if(O.useEffect(()=>{d(!0)},[]),function(h){const f=O.useContext(jg);O.useEffect(()=>{if(!f)throw new Error("useDndMonitor must be used within a children of <DndContext>");return f(h)},[h,f])}(O.useMemo(()=>({onDragStart(h){let{active:f}=h;s(e.onDragStart({active:f}))},onDragMove(h){let{active:f,over:m}=h;e.onDragMove&&s(e.onDragMove({active:f,over:m}))},onDragOver(h){let{active:f,over:m}=h;s(e.onDragOver({active:f,over:m}))},onDragEnd(h){let{active:f,over:m}=h;s(e.onDragEnd({active:f,over:m}))},onDragCancel(h){let{active:f,over:m}=h;s(e.onDragCancel({active:f,over:m}))}}),[s,e])),!l)return null;const u=G.createElement(G.Fragment,null,G.createElement(c4,{id:o,value:r.draggable}),G.createElement(d4,{id:i,announcement:a}));return n?Wa.createPortal(u,n):u}var Mt;function ki(){}function Cg(t,e){return O.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Mt||(Mt={}));const An=Object.freeze({x:0,y:0});function md(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function pd(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return n-o}function m4(t,e){let{data:{value:n}}=t,{data:{value:o}}=e;return o-n}function gd(t){let{left:e,top:n,height:o,width:r}=t;return[{x:e,y:n},{x:e+r,y:n},{x:e,y:n+o},{x:e+r,y:n+o}]}function xd(t,e){if(!t||t.length===0)return null;const[n]=t;return e?n[e]:n}function Eg(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+.5*t.width,y:n+.5*t.height}}const bd=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=Eg(e,e.left,e.top),s=[];for(const a of o){const{id:i}=a,l=n.get(i);if(l){const d=md(Eg(l),r);s.push({id:i,data:{droppableContainer:a,value:d}})}}return s.sort(pd)};function p4(t,e){const n=Math.max(e.top,t.top),o=Math.max(e.left,t.left),r=Math.min(e.left+e.width,t.left+t.width),s=Math.min(e.top+e.height,t.top+t.height),a=r-o,i=s-n;if(o<r&&n<s){const l=e.width*e.height,d=t.width*t.height,u=a*i;return Number((u/(l+d-u)).toFixed(4))}return 0}const _g=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:o}=t;const r=[];for(const s of o){const{id:a}=s,i=n.get(a);if(i){const l=p4(i,e);l>0&&r.push({id:a,data:{droppableContainer:s,value:l}})}}return r.sort(m4)};function g4(t,e){const{top:n,left:o,bottom:r,right:s}=e;return n<=t.y&&t.y<=r&&o<=t.x&&t.x<=s}function Ig(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:An}function x4(t){return function(e){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...e})}}const b4=x4(1),y4={ignoreTransform:!1};function Nr(t,e){e===void 0&&(e=y4);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:d,transformOrigin:u}=Co(t).getComputedStyle(t);d&&(n=function(h,f,m){const x=function(j){if(j.startsWith("matrix3d(")){const C=j.slice(9,-1).split(/, /);return{x:+C[12],y:+C[13],scaleX:+C[0],scaleY:+C[5]}}if(j.startsWith("matrix(")){const C=j.slice(7,-1).split(/, /);return{x:+C[4],y:+C[5],scaleX:+C[0],scaleY:+C[3]}}return null}(f);if(!x)return h;const{scaleX:g,scaleY:p,x:b,y}=x,v=h.left-b-(1-g)*parseFloat(m),w=h.top-y-(1-p)*parseFloat(m.slice(m.indexOf(" ")+1)),S=g?h.width/g:h.width,N=p?h.height/p:h.height;return{width:S,height:N,top:w,right:v+S,bottom:w+N,left:v}}(n,d,u))}const{top:o,left:r,width:s,height:a,bottom:i,right:l}=n;return{top:o,left:r,width:s,height:a,bottom:i,right:l}}function Ag(t){return Nr(t,{ignoreTransform:!0})}function Si(t,e){const n=[];return t?function o(r){if(e!=null&&n.length>=e||!r)return n;if(n3(r)&&r.scrollingElement!=null&&!n.includes(r.scrollingElement))return n.push(r.scrollingElement),n;if(!hc(r)||aO(r)||n.includes(r))return n;const s=Co(t).getComputedStyle(r);return r!==t&&function(a,i){i===void 0&&(i=Co(a).getComputedStyle(a));const l=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(d=>{const u=i[d];return typeof u=="string"&&l.test(u)})}(r,s)&&n.push(r),function(a,i){return i===void 0&&(i=Co(a).getComputedStyle(a)),i.position==="fixed"}(r,s)?n:o(r.parentNode)}(t):n}function Tg(t){const[e]=Si(t,1);return e??null}function yd(t){return dm&&t?um(t)?t:cO(t)?n3(t)||t===ms(t).scrollingElement?window:hc(t)?t:null:null:null}function Mg(t){return um(t)?t.scrollX:t.scrollLeft}function Og(t){return um(t)?t.scrollY:t.scrollTop}function vd(t){return{x:Mg(t),y:Og(t)}}var Dt;function Dg(t){return!(!dm||!t)&&t===document.scrollingElement}function Pg(t){const e={x:0,y:0},n=Dg(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},o={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height};return{isTop:t.scrollTop<=e.y,isLeft:t.scrollLeft<=e.x,isBottom:t.scrollTop>=o.y,isRight:t.scrollLeft>=o.x,maxScroll:o,minScroll:e}}(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(Dt||(Dt={}));const v4={x:.2,y:.2};function w4(t,e,n,o,r){let{top:s,left:a,right:i,bottom:l}=n;o===void 0&&(o=10),r===void 0&&(r=v4);const{isTop:d,isBottom:u,isLeft:h,isRight:f}=Pg(t),m={x:0,y:0},x={x:0,y:0},g=e.height*r.y,p=e.width*r.x;return!d&&s<=e.top+g?(m.y=Dt.Backward,x.y=o*Math.abs((e.top+g-s)/g)):!u&&l>=e.bottom-g&&(m.y=Dt.Forward,x.y=o*Math.abs((e.bottom-g-l)/g)),!f&&i>=e.right-p?(m.x=Dt.Forward,x.x=o*Math.abs((e.right-p-i)/p)):!h&&a<=e.left+p&&(m.x=Dt.Backward,x.x=o*Math.abs((e.left+p-a)/p)),{direction:m,speed:x}}function k4(t){if(t===document.scrollingElement){const{innerWidth:s,innerHeight:a}=window;return{top:0,left:0,right:s,bottom:a,width:s,height:a}}const{top:e,left:n,right:o,bottom:r}=t.getBoundingClientRect();return{top:e,left:n,right:o,bottom:r,width:t.clientWidth,height:t.clientHeight}}function Rg(t){return t.reduce((e,n)=>ps(e,vd(n)),An)}const S4=[["x",["left","right"],function(t){return t.reduce((e,n)=>e+Mg(n),0)}],["y",["top","bottom"],function(t){return t.reduce((e,n)=>e+Og(n),0)}]];class wd{constructor(e,n){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 o=Si(n),r=Rg(o);this.rect={...e},this.width=e.width,this.height=e.height;for(const[s,a,i]of S4)for(const l of a)Object.defineProperty(this,l,{get:()=>{const d=i(o),u=r[s]-d;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class Os{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...n)})},this.target=e}add(e,n,o){var r;(r=this.target)==null||r.addEventListener(e,n,o),this.listeners.push([e,n,o])}}function kd(t,e){const n=Math.abs(t.x),o=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+o**2)>e:"x"in e&&"y"in e?n>e.x&&o>e.y:"x"in e?n>e.x:"y"in e&&o>e.y}var yn,et;function Lg(t){t.preventDefault()}function N4(t){t.stopPropagation()}(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(yn||(yn={})),function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"}(et||(et={}));const Fg={start:[et.Space,et.Enter],cancel:[et.Esc],end:[et.Space,et.Enter,et.Tab]},j4=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case et.Right:return{...n,x:n.x+25};case et.Left:return{...n,x:n.x-25};case et.Down:return{...n,y:n.y+25};case et.Up:return{...n,y:n.y-25}}};class Sd{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:n}}=e;this.props=e,this.listeners=new Os(ms(n)),this.windowListeners=new Os(Co(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(yn.Resize,this.handleCancel),this.windowListeners.add(yn.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(yn.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,o=e.node.current;o&&function(r,s){if(s===void 0&&(s=Nr),!r)return;const{top:a,left:i,bottom:l,right:d}=s(r);Tg(r)&&(l<=0||d<=0||a>=window.innerHeight||i>=window.innerWidth)&&r.scrollIntoView({block:"center",inline:"center"})}(o),n(An)}handleKeyDown(e){if(lm(e)){const{active:n,context:o,options:r}=this.props,{keyboardCodes:s=Fg,coordinateGetter:a=j4,scrollBehavior:i="smooth"}=r,{code:l}=e;if(s.end.includes(l))return void this.handleEnd(e);if(s.cancel.includes(l))return void this.handleCancel(e);const{collisionRect:d}=o.current,u=d?{x:d.left,y:d.top}:An;this.referenceCoordinates||(this.referenceCoordinates=u);const h=a(e,{active:n,context:o.current,currentCoordinates:u});if(h){const f=Ha(h,u),m={x:0,y:0},{scrollableAncestors:x}=o.current;for(const g of x){const p=e.code,{isTop:b,isRight:y,isLeft:v,isBottom:w,maxScroll:S,minScroll:N}=Pg(g),j=k4(g),C={x:Math.min(p===et.Right?j.right-j.width/2:j.right,Math.max(p===et.Right?j.left:j.left+j.width/2,h.x)),y:Math.min(p===et.Down?j.bottom-j.height/2:j.bottom,Math.max(p===et.Down?j.top:j.top+j.height/2,h.y))},_=p===et.Right&&!y||p===et.Left&&!v,A=p===et.Down&&!w||p===et.Up&&!b;if(_&&C.x!==h.x){const I=g.scrollLeft+f.x,P=p===et.Right&&I<=S.x||p===et.Left&&I>=N.x;if(P&&!f.y)return void g.scrollTo({left:I,behavior:i});m.x=P?g.scrollLeft-I:p===et.Right?g.scrollLeft-S.x:g.scrollLeft-N.x,m.x&&g.scrollBy({left:-m.x,behavior:i});break}if(A&&C.y!==h.y){const I=g.scrollTop+f.y,P=p===et.Down&&I<=S.y||p===et.Up&&I>=N.y;if(P&&!f.x)return void g.scrollTo({top:I,behavior:i});m.y=P?g.scrollTop-I:p===et.Down?g.scrollTop-S.y:g.scrollTop-N.y,m.y&&g.scrollBy({top:-m.y,behavior:i});break}}this.handleMove(e,ps(Ha(h,this.referenceCoordinates),m))}}}handleMove(e,n){const{onMove:o}=this.props;e.preventDefault(),o(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}function zg(t){return!!(t&&"distance"in t)}function Bg(t){return!!(t&&"delay"in t)}Sd.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:o=Fg,onActivation:r}=e,{active:s}=n;const{code:a}=t.nativeEvent;if(o.start.includes(a)){const i=s.activatorNode.current;return(!i||t.target===i)&&(t.preventDefault(),r==null||r({event:t.nativeEvent}),!0)}return!1}}];class Nd{constructor(e,n,o){var r;o===void 0&&(o=function(i){const{EventTarget:l}=Co(i);return i instanceof l?i:ms(i)}(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=n;const{event:s}=e,{target:a}=s;this.props=e,this.events=n,this.document=ms(a),this.documentListeners=new Os(this.document),this.listeners=new Os(o),this.windowListeners=new Os(Co(a)),this.initialCoordinates=(r=cm(s))!=null?r:An,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:n,bypassActivationConstraint:o}}}=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(yn.Resize,this.handleCancel),this.windowListeners.add(yn.DragStart,Lg),this.windowListeners.add(yn.VisibilityChange,this.handleCancel),this.windowListeners.add(yn.ContextMenu,Lg),this.documentListeners.add(yn.Keydown,this.handleKeydown),n){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Bg(n))return this.timeoutId=setTimeout(this.handleStart,n.delay),void this.handlePending(n);if(zg(n))return void this.handlePending(n)}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:o,onPending:r}=this.props;r(o,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(yn.Click,N4,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(yn.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:o,initialCoordinates:r,props:s}=this,{onMove:a,options:{activationConstraint:i}}=s;if(!r)return;const l=(n=cm(e))!=null?n:An,d=Ha(r,l);if(!o&&i){if(zg(i)){if(i.tolerance!=null&&kd(d,i.tolerance))return this.handleCancel();if(kd(d,i.distance))return this.handleStart()}return Bg(i)&&kd(d,i.tolerance)?this.handleCancel():void this.handlePending(i,d)}e.cancelable&&e.preventDefault(),a(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===et.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const C4={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class jd extends Nd{constructor(e){const{event:n}=e,o=ms(n.target);super(e,C4,o)}}jd.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return!(!n.isPrimary||n.button!==0)&&(o==null||o({event:n}),!0)}}];const E4={move:{name:"mousemove"},end:{name:"mouseup"}};var Cd;(function(t){t[t.RightClick=2]="RightClick"})(Cd||(Cd={})),(class extends Nd{constructor(t){super(t,E4,ms(t.event.target))}}).activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;return n.button!==Cd.RightClick&&(o==null||o({event:n}),!0)}}];const Ed={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};var Ds,Ni;function _4(t){let{acceleration:e,activator:n=Ds.Pointer,canScroll:o,draggingRect:r,enabled:s,interval:a=5,order:i=Ni.TreeOrder,pointerCoordinates:l,scrollableAncestors:d,scrollableAncestorRects:u,delta:h,threshold:f}=t;const m=function(N){let{delta:j,disabled:C}=N;const _=fc(j);return qa(A=>{if(C||!_||!A)return I4;const I={x:Math.sign(j.x-_.x),y:Math.sign(j.y-_.y)};return{x:{[Dt.Backward]:A.x[Dt.Backward]||I.x===-1,[Dt.Forward]:A.x[Dt.Forward]||I.x===1},y:{[Dt.Backward]:A.y[Dt.Backward]||I.y===-1,[Dt.Forward]:A.y[Dt.Forward]||I.y===1}}},[C,j,_])}({delta:h,disabled:!s}),[x,g]=iO(),p=O.useRef({x:0,y:0}),b=O.useRef({x:0,y:0}),y=O.useMemo(()=>{switch(n){case Ds.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case Ds.DraggableRect:return r}},[n,r,l]),v=O.useRef(null),w=O.useCallback(()=>{const N=v.current;if(!N)return;const j=p.current.x*b.current.x,C=p.current.y*b.current.y;N.scrollBy(j,C)},[]),S=O.useMemo(()=>i===Ni.TreeOrder?[...d].reverse():d,[i,d]);O.useEffect(()=>{if(s&&d.length&&y){for(const N of S){if((o==null?void 0:o(N))===!1)continue;const j=d.indexOf(N),C=u[j];if(!C)continue;const{direction:_,speed:A}=w4(N,C,y,e,f);for(const I of["x","y"])m[I][_[I]]||(A[I]=0,_[I]=0);if(A.x>0||A.y>0)return g(),v.current=N,x(w,a),p.current=A,void(b.current=_)}p.current={x:0,y:0},b.current={x:0,y:0},g()}else g()},[e,w,o,g,s,a,JSON.stringify(y),JSON.stringify(m),x,d,S,u,JSON.stringify(f)])}(class extends Nd{constructor(t){super(t,Ed)}static setup(){return window.addEventListener(Ed.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ed.move.name,t)};function t(){}}}).activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:o}=e;const{touches:r}=n;return!(r.length>1)&&(o==null||o({event:n}),!0)}}],function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"}(Ds||(Ds={})),function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"}(Ni||(Ni={}));const I4={x:{[Dt.Backward]:!1,[Dt.Forward]:!1},y:{[Dt.Backward]:!1,[Dt.Forward]:!1}};var Ps,_d;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(Ps||(Ps={})),function(t){t.Optimized="optimized"}(_d||(_d={}));const Ug=new Map;function $g(t,e){return qa(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function ji(t){let{callback:e,disabled:n}=t;const o=t3(e),r=O.useMemo(()=>{if(n||typeof window>"u"||window.ResizeObserver===void 0)return;const{ResizeObserver:s}=window;return new s(o)},[n]);return O.useEffect(()=>()=>r==null?void 0:r.disconnect(),[r]),r}function A4(t){return new wd(Nr(t),t)}function Vg(t,e,n){e===void 0&&(e=A4);const[o,r]=O.useState(null);function s(){r(l=>{if(!t)return null;var d;if(t.isConnected===!1)return(d=l??n)!=null?d:null;const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const a=function(l){let{callback:d,disabled:u}=l;const h=t3(d),f=O.useMemo(()=>{if(u||typeof window>"u"||window.MutationObserver===void 0)return;const{MutationObserver:m}=window;return new m(h)},[h,u]);return O.useEffect(()=>()=>f==null?void 0:f.disconnect(),[f]),f}({callback(l){if(t)for(const d of l){const{type:u,target:h}=d;if(u==="childList"&&h instanceof HTMLElement&&h.contains(t)){s();break}}}}),i=ji({callback:s});return Go(()=>{s(),t?(i==null||i.observe(t),a==null||a.observe(document.body,{childList:!0,subtree:!0})):(i==null||i.disconnect(),a==null||a.disconnect())},[t]),o}const Hg=[];function Wg(t,e){e===void 0&&(e=[]);const n=O.useRef(null);return O.useEffect(()=>{n.current=null},e),O.useEffect(()=>{const o=t!==An;o&&!n.current&&(n.current=t),!o&&n.current&&(n.current=null)},[t]),n.current?Ha(t,n.current):An}function qg(t){return O.useMemo(()=>t?function(e){const n=e.innerWidth,o=e.innerHeight;return{top:0,left:0,right:n,bottom:o,width:n,height:o}}(t):null,[t])}const Gg=[];function T4(t){let{measure:e}=t;const[n,o]=O.useState(null),r=O.useCallback(d=>{for(const{target:u}of d)if(hc(u)){o(h=>{const f=e(u);return h?{...h,width:f.width,height:f.height}:f});break}},[e]),s=ji({callback:r}),a=O.useCallback(d=>{const u=function(h){if(!h)return null;if(h.children.length>1)return h;const f=h.children[0];return hc(f)?f:h}(d);s==null||s.disconnect(),u&&(s==null||s.observe(u)),o(u?e(u):null)},[e,s]),[i,l]=uc(a);return O.useMemo(()=>({nodeRef:i,rect:n,setRef:l}),[n,i,l])}const M4=[{sensor:jd,options:{}},{sensor:Sd,options:{}}],O4={current:{}},Ci={draggable:{measure:Ag},droppable:{measure:Ag,strategy:Ps.WhileDragging,frequency:_d.Optimized},dragOverlay:{measure:Nr}};class Rs extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,o;return(n=(o=this.get(e))==null?void 0:o.node.current)!=null?n:void 0}}const D4={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new Rs,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ki},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ci,measureDroppableContainers:ki,windowRect:null,measuringScheduled:!1},P4={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ki,draggableNodes:new Map,over:null,measureDroppableContainers:ki},Ei=O.createContext(P4),Yg=O.createContext(D4);function R4(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new Rs}}}function L4(t,e){switch(e.type){case Mt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case Mt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case Mt.DragEnd:case Mt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case Mt.RegisterDroppable:{const{element:n}=e,{id:o}=n,r=new Rs(t.droppable.containers);return r.set(o,n),{...t,droppable:{...t.droppable,containers:r}}}case Mt.SetDroppableDisabled:{const{id:n,key:o,disabled:r}=e,s=t.droppable.containers.get(n);if(!s||o!==s.key)return t;const a=new Rs(t.droppable.containers);return a.set(n,{...s,disabled:r}),{...t,droppable:{...t.droppable,containers:a}}}case Mt.UnregisterDroppable:{const{id:n,key:o}=e,r=t.droppable.containers.get(n);if(!r||o!==r.key)return t;const s=new Rs(t.droppable.containers);return s.delete(n),{...t,droppable:{...t.droppable,containers:s}}}default:return t}}function F4(t){let{disabled:e}=t;const{active:n,activatorEvent:o,draggableNodes:r}=O.useContext(Ei),s=fc(o),a=fc(n==null?void 0:n.id);return O.useEffect(()=>{if(!e&&!o&&s&&a!=null){if(!lm(s)||document.activeElement===s.target)return;const i=r.get(a);if(!i)return;const{activatorNode:l,node:d}=i;if(!l.current&&!d.current)return;requestAnimationFrame(()=>{for(const u of[l.current,d.current]){if(!u)continue;const h=lO(u);if(h){h.focus();break}}})}},[o,e,r,a,s]),null}const Kg=O.createContext({...An,scaleX:1,scaleY:1});var Ao;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Ao||(Ao={}));const z4=O.memo(function(t){var e,n,o,r;let{id:s,accessibility:a,autoScroll:i=!0,children:l,sensors:d=M4,collisionDetection:u=_g,measuring:h,modifiers:f,...m}=t;const x=O.useReducer(L4,void 0,R4),[g,p]=x,[b,y]=function(){const[ie]=O.useState(()=>new Set),je=O.useCallback(_e=>(ie.add(_e),()=>ie.delete(_e)),[ie]);return[O.useCallback(_e=>{let{type:Be,event:We}=_e;ie.forEach(Pe=>{var $e;return($e=Pe[Be])==null?void 0:$e.call(Pe,We)})},[ie]),je]}(),[v,w]=O.useState(Ao.Uninitialized),S=v===Ao.Initialized,{draggable:{active:N,nodes:j,translate:C},droppable:{containers:_}}=g,A=N!=null?j.get(N):null,I=O.useRef({initial:null,translated:null}),P=O.useMemo(()=>{var ie;return N!=null?{id:N,data:(ie=A==null?void 0:A.data)!=null?ie:O4,rect:I}:null},[N,A]),R=O.useRef(null),[M,L]=O.useState(null),[F,D]=O.useState(null),T=Va(m,Object.values(m)),k=$a("DndDescribedBy",s),B=O.useMemo(()=>_.getEnabled(),[_]),E=(U=h,O.useMemo(()=>({draggable:{...Ci.draggable,...U==null?void 0:U.draggable},droppable:{...Ci.droppable,...U==null?void 0:U.droppable},dragOverlay:{...Ci.dragOverlay,...U==null?void 0:U.dragOverlay}}),[U==null?void 0:U.draggable,U==null?void 0:U.droppable,U==null?void 0:U.dragOverlay]));var U;const{droppableRects:V,measureDroppableContainers:$,measuringScheduled:X}=function(ie,je){let{dragging:_e,dependencies:Be,config:We}=je;const[Pe,$e]=O.useState(null),{frequency:nt,measure:Ke,strategy:rt}=We,zt=O.useRef(ie),Vt=function(){switch(rt){case Ps.Always:return!1;case Ps.BeforeDragging:return _e;default:return!_e}}(),fn=Va(Vt),Xt=O.useCallback(function(Wn){Wn===void 0&&(Wn=[]),fn.current||$e(vo=>vo===null?Wn:vo.concat(Wn.filter(Nn=>!vo.includes(Nn))))},[fn]),Mn=O.useRef(null),ns=qa(Wn=>{if(Vt&&!_e)return Ug;if(!Wn||Wn===Ug||zt.current!==ie||Pe!=null){const vo=new Map;for(let Nn of ie){if(!Nn)continue;if(Pe&&Pe.length>0&&!Pe.includes(Nn.id)&&Nn.rect.current){vo.set(Nn.id,Nn.rect.current);continue}const os=Nn.node.current,Na=os?new wd(Ke(os),os):null;Nn.rect.current=Na,Na&&vo.set(Nn.id,Na)}return vo}return Wn},[ie,Pe,_e,Vt,Ke]);return O.useEffect(()=>{zt.current=ie},[ie]),O.useEffect(()=>{Vt||Xt()},[_e,Vt]),O.useEffect(()=>{Pe&&Pe.length>0&&$e(null)},[JSON.stringify(Pe)]),O.useEffect(()=>{Vt||typeof nt!="number"||Mn.current!==null||(Mn.current=setTimeout(()=>{Xt(),Mn.current=null},nt))},[nt,Vt,Xt,...Be]),{droppableRects:ns,measureDroppableContainers:Xt,measuringScheduled:Pe!=null}}(B,{dragging:S,dependencies:[C.x,C.y],config:E.droppable}),Y=function(ie,je){const _e=je!=null?ie.get(je):void 0,Be=_e?_e.node.current:null;return qa(We=>{var Pe;return je==null?null:(Pe=Be??We)!=null?Pe:null},[Be,je])}(j,N),J=O.useMemo(()=>F?cm(F):null,[F]),Q=function(){const ie=(M==null?void 0:M.autoScrollEnabled)===!1,je=typeof i=="object"?i.enabled===!1:i===!1,_e=S&&!ie&&!je;return typeof i=="object"?{...i,enabled:_e}:{enabled:_e}}(),q=function(ie,je){return $g(ie,je)}(Y,E.draggable.measure);(function(ie){let{activeNode:je,measure:_e,initialRect:Be,config:We=!0}=ie;const Pe=O.useRef(!1),{x:$e,y:nt}=typeof We=="boolean"?{x:We,y:We}:We;Go(()=>{if(!$e&&!nt||!je)return void(Pe.current=!1);if(Pe.current||!Be)return;const Ke=je==null?void 0:je.node.current;if(!Ke||Ke.isConnected===!1)return;const rt=Ig(_e(Ke),Be);if($e||(rt.x=0),nt||(rt.y=0),Pe.current=!0,Math.abs(rt.x)>0||Math.abs(rt.y)>0){const zt=Tg(Ke);zt&&zt.scrollBy({top:rt.y,left:rt.x})}},[je,$e,nt,Be,_e])})({activeNode:N!=null?j.get(N):null,config:Q.layoutShiftCompensation,initialRect:q,measure:E.draggable.measure});const K=Vg(Y,E.draggable.measure,q),re=Vg(Y?Y.parentElement:null),oe=O.useRef({activatorEvent:null,active:null,activeNode:Y,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:j,draggingNode:null,draggingNodeRect:null,droppableContainers:_,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ne=_.getNodeFor((e=oe.current.over)==null?void 0:e.id),se=T4({measure:E.dragOverlay.measure}),te=(n=se.nodeRef.current)!=null?n:Y,pe=S?(o=se.rect)!=null?o:K:null,he=!!(se.nodeRef.current&&se.rect),ae=Ig(ye=he?null:K,$g(ye));var ye;const fe=qg(te?Co(te):null),Se=function(ie){const je=O.useRef(ie),_e=qa(Be=>ie?Be&&Be!==Hg&&ie&&je.current&&ie.parentNode===je.current.parentNode?Be:Si(ie):Hg,[ie]);return O.useEffect(()=>{je.current=ie},[ie]),_e}(S?ne??Y:null),Me=function(ie,je){je===void 0&&(je=Nr);const[_e]=ie,Be=qg(_e?Co(_e):null),[We,Pe]=O.useState(Gg);function $e(){Pe(()=>ie.length?ie.map(Ke=>Dg(Ke)?Be:new wd(je(Ke),Ke)):Gg)}const nt=ji({callback:$e});return Go(()=>{nt==null||nt.disconnect(),$e(),ie.forEach(Ke=>nt==null?void 0:nt.observe(Ke))},[ie]),We}(Se),Ee=function(ie,je){let{transform:_e,...Be}=je;return ie!=null&&ie.length?ie.reduce((We,Pe)=>Pe({transform:We,...Be}),_e):_e}(f,{transform:{x:C.x-ae.x,y:C.y-ae.y,scaleX:1,scaleY:1},activatorEvent:F,active:P,activeNodeRect:K,containerNodeRect:re,draggingNodeRect:pe,over:oe.current.over,overlayNodeRect:se.rect,scrollableAncestors:Se,scrollableAncestorRects:Me,windowRect:fe}),Le=J?ps(J,C):null,Te=function(ie){const[je,_e]=O.useState(null),Be=O.useRef(ie),We=O.useCallback(Pe=>{const $e=yd(Pe.target);$e&&_e(nt=>nt?(nt.set($e,vd($e)),new Map(nt)):null)},[]);return O.useEffect(()=>{const Pe=Be.current;if(ie!==Pe){$e(Pe);const nt=ie.map(Ke=>{const rt=yd(Ke);return rt?(rt.addEventListener("scroll",We,{passive:!0}),[rt,vd(rt)]):null}).filter(Ke=>Ke!=null);_e(nt.length?new Map(nt):null),Be.current=ie}return()=>{$e(ie),$e(Pe)};function $e(nt){nt.forEach(Ke=>{const rt=yd(Ke);rt==null||rt.removeEventListener("scroll",We)})}},[We,ie]),O.useMemo(()=>ie.length?je?Array.from(je.values()).reduce((Pe,$e)=>ps(Pe,$e),An):Rg(ie):An,[ie,je])}(Se),Ze=Wg(Te),He=Wg(Te,[K]),Ge=ps(Ee,Ze),ee=pe?b4(pe,Ee):null,be=P&&ee?u({active:P,collisionRect:ee,droppableRects:V,droppableContainers:B,pointerCoordinates:Le}):null,we=xd(be,"id"),[Ae,W]=O.useState(null),de=function(ie,je,_e){return{...ie,scaleX:je&&_e?je.width/_e.width:1,scaleY:je&&_e?je.height/_e.height:1}}(he?Ee:ps(Ee,He),(r=Ae==null?void 0:Ae.rect)!=null?r:null,K),ue=O.useRef(null),ce=O.useCallback((ie,je)=>{let{sensor:_e,options:Be}=je;if(R.current==null)return;const We=j.get(R.current);if(!We)return;const Pe=ie.nativeEvent,$e=new _e({active:R.current,activeNode:We,event:Pe,options:Be,context:oe,onAbort(Ke){if(!j.get(Ke))return;const{onDragAbort:rt}=T.current,zt={id:Ke};rt==null||rt(zt),b({type:"onDragAbort",event:zt})},onPending(Ke,rt,zt,Vt){if(!j.get(Ke))return;const{onDragPending:fn}=T.current,Xt={id:Ke,constraint:rt,initialCoordinates:zt,offset:Vt};fn==null||fn(Xt),b({type:"onDragPending",event:Xt})},onStart(Ke){const rt=R.current;if(rt==null)return;const zt=j.get(rt);if(!zt)return;const{onDragStart:Vt}=T.current,fn={activatorEvent:Pe,active:{id:rt,data:zt.data,rect:I}};Wa.unstable_batchedUpdates(()=>{Vt==null||Vt(fn),w(Ao.Initializing),p({type:Mt.DragStart,initialCoordinates:Ke,active:rt}),b({type:"onDragStart",event:fn}),L(ue.current),D(Pe)})},onMove(Ke){p({type:Mt.DragMove,coordinates:Ke})},onEnd:nt(Mt.DragEnd),onCancel:nt(Mt.DragCancel)});function nt(Ke){return async function(){const{active:rt,collisions:zt,over:Vt,scrollAdjustedTranslate:fn}=oe.current;let Xt=null;if(rt&&fn){const{cancelDrop:Mn}=T.current;Xt={activatorEvent:Pe,active:rt,collisions:zt,delta:fn,over:Vt},Ke===Mt.DragEnd&&typeof Mn=="function"&&await Promise.resolve(Mn(Xt))&&(Ke=Mt.DragCancel)}R.current=null,Wa.unstable_batchedUpdates(()=>{p({type:Ke}),w(Ao.Uninitialized),W(null),L(null),D(null),ue.current=null;const Mn=Ke===Mt.DragEnd?"onDragEnd":"onDragCancel";if(Xt){const ns=T.current[Mn];ns==null||ns(Xt),b({type:Mn,event:Xt})}})}}ue.current=$e},[j]),ve=O.useCallback((ie,je)=>(_e,Be)=>{const We=_e.nativeEvent,Pe=j.get(Be);if(R.current!==null||!Pe||We.dndKit||We.defaultPrevented)return;const $e={active:Pe};ie(_e,je.options,$e)===!0&&(We.dndKit={capturedBy:je.sensor},R.current=Be,ce(_e,je))},[j,ce]),Oe=function(ie,je){return O.useMemo(()=>ie.reduce((_e,Be)=>{const{sensor:We}=Be;return[..._e,...We.activators.map(Pe=>({eventName:Pe.eventName,handler:je(Pe.handler,Be)}))]},[]),[ie,je])}(d,ve);(function(ie){O.useEffect(()=>{if(!dm)return;const je=ie.map(_e=>{let{sensor:Be}=_e;return Be.setup==null?void 0:Be.setup()});return()=>{for(const _e of je)_e==null||_e()}},ie.map(je=>{let{sensor:_e}=je;return _e}))})(d),Go(()=>{K&&v===Ao.Initializing&&w(Ao.Initialized)},[K,v]),O.useEffect(()=>{const{onDragMove:ie}=T.current,{active:je,activatorEvent:_e,collisions:Be,over:We}=oe.current;if(!je||!_e)return;const Pe={active:je,activatorEvent:_e,collisions:Be,delta:{x:Ge.x,y:Ge.y},over:We};Wa.unstable_batchedUpdates(()=>{ie==null||ie(Pe),b({type:"onDragMove",event:Pe})})},[Ge.x,Ge.y]),O.useEffect(()=>{const{active:ie,activatorEvent:je,collisions:_e,droppableContainers:Be,scrollAdjustedTranslate:We}=oe.current;if(!ie||R.current==null||!je||!We)return;const{onDragOver:Pe}=T.current,$e=Be.get(we),nt=$e&&$e.rect.current?{id:$e.id,rect:$e.rect.current,data:$e.data,disabled:$e.disabled}:null,Ke={active:ie,activatorEvent:je,collisions:_e,delta:{x:We.x,y:We.y},over:nt};Wa.unstable_batchedUpdates(()=>{W(nt),Pe==null||Pe(Ke),b({type:"onDragOver",event:Ke})})},[we]),Go(()=>{oe.current={activatorEvent:F,active:P,activeNode:Y,collisionRect:ee,collisions:be,droppableRects:V,draggableNodes:j,draggingNode:te,draggingNodeRect:pe,droppableContainers:_,over:Ae,scrollableAncestors:Se,scrollAdjustedTranslate:Ge},I.current={initial:pe,translated:ee}},[P,Y,be,ee,j,te,pe,V,_,Ae,Se,Ge]),_4({...Q,delta:C,draggingRect:ee,pointerCoordinates:Le,scrollableAncestors:Se,scrollableAncestorRects:Me});const Re=O.useMemo(()=>({active:P,activeNode:Y,activeNodeRect:K,activatorEvent:F,collisions:be,containerNodeRect:re,dragOverlay:se,draggableNodes:j,droppableContainers:_,droppableRects:V,over:Ae,measureDroppableContainers:$,scrollableAncestors:Se,scrollableAncestorRects:Me,measuringConfiguration:E,measuringScheduled:X,windowRect:fe}),[P,Y,K,F,be,re,se,j,_,V,Ae,$,Se,Me,E,X,fe]),Ye=O.useMemo(()=>({activatorEvent:F,activators:Oe,active:P,activeNodeRect:K,ariaDescribedById:{draggable:k},dispatch:p,draggableNodes:j,over:Ae,measureDroppableContainers:$}),[F,Oe,P,K,p,k,j,Ae,$]);return G.createElement(jg.Provider,{value:y},G.createElement(Ei.Provider,{value:Ye},G.createElement(Yg.Provider,{value:Re},G.createElement(Kg.Provider,{value:de},l)),G.createElement(F4,{disabled:(a==null?void 0:a.restoreFocus)===!1})),G.createElement(f4,{...a,hiddenTextDescribedById:k}))}),B4=O.createContext(null),Xg="button";function U4(t){let{id:e,data:n,disabled:o=!1,attributes:r}=t;const s=$a("Draggable"),{activators:a,activatorEvent:i,active:l,activeNodeRect:d,ariaDescribedById:u,draggableNodes:h,over:f}=O.useContext(Ei),{role:m=Xg,roleDescription:x="draggable",tabIndex:g=0}=r??{},p=(l==null?void 0:l.id)===e,b=O.useContext(p?Kg:B4),[y,v]=uc(),[w,S]=uc(),N=function(C,_){return O.useMemo(()=>C.reduce((A,I)=>{let{eventName:P,handler:R}=I;return A[P]=M=>{R(M,_)},A},{}),[C,_])}(a,e),j=Va(n);return Go(()=>(h.set(e,{id:e,key:s,node:y,activatorNode:w,data:j}),()=>{const C=h.get(e);C&&C.key===s&&h.delete(e)}),[h,e]),{active:l,activatorEvent:i,activeNodeRect:d,attributes:O.useMemo(()=>({role:m,tabIndex:g,"aria-disabled":o,"aria-pressed":!(!p||m!==Xg)||void 0,"aria-roledescription":x,"aria-describedby":u.draggable}),[o,m,g,p,x,u.draggable]),isDragging:p,listeners:o?void 0:N,node:y,over:f,setNodeRef:v,setActivatorNodeRef:S,transform:b}}const $4={timeout:25};function Jg(t,e,n){const o=t.slice();return o.splice(n<0?o.length+n:n,0,o.splice(e,1)[0]),o}function V4(t,e){return t.reduce((n,o,r)=>{const s=e.get(o);return s&&(n[r]=s),n},Array(t.length))}function _i(t){return t!==null&&t>=0}const Ii={scaleX:1,scaleY:1},H4=t=>{var e;let{rects:n,activeNodeRect:o,activeIndex:r,overIndex:s,index:a}=t;const i=(e=n[r])!=null?e:o;if(!i)return null;const l=function(d,u,h){const f=d[u],m=d[u-1],x=d[u+1];return!f||!m&&!x?0:h<u?m?f.left-(m.left+m.width):x.left-(f.left+f.width):x?x.left-(f.left+f.width):f.left-(m.left+m.width)}(n,a,r);if(a===r){const d=n[s];return d?{x:r<s?d.left+d.width-(i.left+i.width):d.left-i.left,y:0,...Ii}:null}return a>r&&a<=s?{x:-i.width-l,y:0,...Ii}:a<r&&a>=s?{x:i.width+l,y:0,...Ii}:{x:0,y:0,...Ii}},Zg=t=>{let{rects:e,activeIndex:n,overIndex:o,index:r}=t;const s=Jg(e,o,n),a=e[r],i=s[r];return i&&a?{x:i.left-a.left,y:i.top-a.top,scaleX:i.width/a.width,scaleY:i.height/a.height}:null},Ai={scaleX:1,scaleY:1},W4=t=>{var e;let{activeIndex:n,activeNodeRect:o,index:r,rects:s,overIndex:a}=t;const i=(e=s[n])!=null?e:o;if(!i)return null;if(r===n){const d=s[a];return d?{x:0,y:n<a?d.top+d.height-(i.top+i.height):d.top-i.top,...Ai}:null}const l=function(d,u,h){const f=d[u],m=d[u-1],x=d[u+1];return f?h<u?m?f.top-(m.top+m.height):x?x.top-(f.top+f.height):0:x?x.top-(f.top+f.height):m?f.top-(m.top+m.height):0:0}(s,r,n);return r>n&&r<=a?{x:0,y:-i.height-l,...Ai}:r<n&&r>=a?{x:0,y:i.height+l,...Ai}:{x:0,y:0,...Ai}},Qg="Sortable",e1=G.createContext({activeIndex:-1,containerId:Qg,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:Zg,disabled:{draggable:!1,droppable:!1}});function t1(t){let{children:e,id:n,items:o,strategy:r=Zg,disabled:s=!1}=t;const{active:a,dragOverlay:i,droppableRects:l,over:d,measureDroppableContainers:u}=O.useContext(Yg),h=$a(Qg,n),f=i.rect!==null,m=O.useMemo(()=>o.map(N=>typeof N=="object"&&"id"in N?N.id:N),[o]),x=a!=null,g=a?m.indexOf(a.id):-1,p=d?m.indexOf(d.id):-1,b=O.useRef(m),y=!function(N,j){if(N===j)return!0;if(N.length!==j.length)return!1;for(let C=0;C<N.length;C++)if(N[C]!==j[C])return!1;return!0}(m,b.current),v=p!==-1&&g===-1||y,w=function(N){return typeof N=="boolean"?{draggable:N,droppable:N}:N}(s);Go(()=>{y&&x&&u(m)},[y,m,x,u]),O.useEffect(()=>{b.current=m},[m]);const S=O.useMemo(()=>({activeIndex:g,containerId:h,disabled:w,disableTransforms:v,items:m,overIndex:p,useDragOverlay:f,sortedRects:V4(m,l),strategy:r}),[g,h,w.draggable,w.droppable,v,m,p,l,f,r]);return G.createElement(e1.Provider,{value:S},e)}const q4=t=>{let{id:e,items:n,activeIndex:o,overIndex:r}=t;return Jg(n,o,r).indexOf(e)},G4=t=>{let{containerId:e,isSorting:n,wasDragging:o,index:r,items:s,newIndex:a,previousItems:i,previousContainerId:l,transition:d}=t;return!(!d||!o)&&(i===s||r!==a)&&(!!n||a!==r&&e===l)},Y4={duration:200,easing:"ease"},n1="transform",K4=mc.Transition.toString({property:n1,duration:0,easing:"linear"}),X4={roleDescription:"sortable"};function o1(t){let{animateLayoutChanges:e=G4,attributes:n,disabled:o,data:r,getNewIndex:s=q4,id:a,strategy:i,resizeObserverConfig:l,transition:d=Y4}=t;const{items:u,containerId:h,activeIndex:f,disabled:m,disableTransforms:x,sortedRects:g,overIndex:p,useDragOverlay:b,strategy:y}=O.useContext(e1),v=function(ne,se){var te,pe;return typeof ne=="boolean"?{draggable:ne,droppable:!1}:{draggable:(te=ne==null?void 0:ne.draggable)!=null?te:se.draggable,droppable:(pe=ne==null?void 0:ne.droppable)!=null?pe:se.droppable}}(o,m),w=u.indexOf(a),S=O.useMemo(()=>({sortable:{containerId:h,index:w,items:u},...r}),[h,r,w,u]),N=O.useMemo(()=>u.slice(u.indexOf(a)),[u,a]),{rect:j,node:C,isOver:_,setNodeRef:A}=function(ne){let{data:se,disabled:te=!1,id:pe,resizeObserverConfig:he}=ne;const ae=$a("Droppable"),{active:ye,dispatch:fe,over:Se,measureDroppableContainers:Me}=O.useContext(Ei),Ee=O.useRef({disabled:te}),Le=O.useRef(!1),Te=O.useRef(null),Ze=O.useRef(null),{disabled:He,updateMeasurementsFor:Ge,timeout:ee}={...$4,...he},be=Va(Ge??pe),we=ji({callback:O.useCallback(()=>{Le.current?(Ze.current!=null&&clearTimeout(Ze.current),Ze.current=setTimeout(()=>{Me(Array.isArray(be.current)?be.current:[be.current]),Ze.current=null},ee)):Le.current=!0},[ee]),disabled:He||!ye}),Ae=O.useCallback((ce,ve)=>{we&&(ve&&(we.unobserve(ve),Le.current=!1),ce&&we.observe(ce))},[we]),[W,de]=uc(Ae),ue=Va(se);return O.useEffect(()=>{we&&W.current&&(we.disconnect(),Le.current=!1,we.observe(W.current))},[W,we]),O.useEffect(()=>(fe({type:Mt.RegisterDroppable,element:{id:pe,key:ae,disabled:te,node:W,rect:Te,data:ue}}),()=>fe({type:Mt.UnregisterDroppable,key:ae,id:pe})),[pe]),O.useEffect(()=>{te!==Ee.current.disabled&&(fe({type:Mt.SetDroppableDisabled,id:pe,key:ae,disabled:te}),Ee.current.disabled=te)},[pe,ae,te,fe]),{active:ye,rect:Te,isOver:(Se==null?void 0:Se.id)===pe,node:W,over:Se,setNodeRef:de}}({id:a,data:S,disabled:v.droppable,resizeObserverConfig:{updateMeasurementsFor:N,...l}}),{active:I,activatorEvent:P,activeNodeRect:R,attributes:M,setNodeRef:L,listeners:F,isDragging:D,over:T,setActivatorNodeRef:k,transform:B}=U4({id:a,data:S,attributes:{...X4,...n},disabled:v.draggable}),E=dO(A,L),U=!!I,V=U&&!x&&_i(f)&&_i(p),$=!b&&D,X=$&&V?B:null,Y=V?X??(i??y)({rects:g,activeNodeRect:R,activeIndex:f,overIndex:p,index:w}):null,J=_i(f)&&_i(p)?s({id:a,items:u,activeIndex:f,overIndex:p}):w,Q=I==null?void 0:I.id,q=O.useRef({activeId:Q,items:u,newIndex:J,containerId:h}),K=u!==q.current.items,re=e({active:I,containerId:h,isDragging:D,isSorting:U,id:a,index:w,items:u,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:d,wasDragging:q.current.activeId!=null}),oe=function(ne){let{disabled:se,index:te,node:pe,rect:he}=ne;const[ae,ye]=O.useState(null),fe=O.useRef(te);return Go(()=>{if(!se&&te!==fe.current&&pe.current){const Se=he.current;if(Se){const Me=Nr(pe.current,{ignoreTransform:!0}),Ee={x:Se.left-Me.left,y:Se.top-Me.top,scaleX:Se.width/Me.width,scaleY:Se.height/Me.height};(Ee.x||Ee.y)&&ye(Ee)}}te!==fe.current&&(fe.current=te)},[se,te,pe,he]),O.useEffect(()=>{ae&&ye(null)},[ae]),ae}({disabled:!re,index:w,node:C,rect:j});return O.useEffect(()=>{U&&q.current.newIndex!==J&&(q.current.newIndex=J),h!==q.current.containerId&&(q.current.containerId=h),u!==q.current.items&&(q.current.items=u)},[U,J,h,u]),O.useEffect(()=>{if(Q===q.current.activeId)return;if(Q!=null&&q.current.activeId==null)return void(q.current.activeId=Q);const ne=setTimeout(()=>{q.current.activeId=Q},50);return()=>clearTimeout(ne)},[Q]),{active:I,activeIndex:f,attributes:M,data:S,rect:j,index:w,newIndex:J,items:u,isOver:_,isSorting:U,isDragging:D,listeners:F,node:C,overIndex:p,over:T,setNodeRef:E,setActivatorNodeRef:k,setDroppableNodeRef:A,setDraggableNodeRef:L,transform:oe??Y,transition:function(){if(oe||K&&q.current.newIndex===w)return K4;if(!($&&!lm(P)||!d)&&(U||re))return mc.Transition.toString({...d,property:n1})}()}}function Ti(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const J4=[et.Down,et.Right,et.Up,et.Left],Z4=(t,e)=>{let{context:{active:n,collisionRect:o,droppableRects:r,droppableContainers:s,over:a,scrollableAncestors:i}}=e;if(J4.includes(t.code)){if(t.preventDefault(),!n||!o)return;const l=[];s.getEnabled().forEach(h=>{if(!h||h!=null&&h.disabled)return;const f=r.get(h.id);if(f)switch(t.code){case et.Down:o.top<f.top&&l.push(h);break;case et.Up:o.top>f.top&&l.push(h);break;case et.Left:o.left>f.left&&l.push(h);break;case et.Right:o.left<f.left&&l.push(h)}});const d=(h=>{let{collisionRect:f,droppableRects:m,droppableContainers:x}=h;const g=gd(f),p=[];for(const b of x){const{id:y}=b,v=m.get(y);if(v){const w=gd(v),S=g.reduce((j,C,_)=>j+md(w[_],C),0),N=Number((S/4).toFixed(4));p.push({id:y,data:{droppableContainer:b,value:N}})}}return p.sort(pd)})({collisionRect:o,droppableRects:r,droppableContainers:l});let u=xd(d,"id");if(u===(a==null?void 0:a.id)&&d.length>1&&(u=d[1].id),u!=null){const h=s.get(n.id),f=s.get(u),m=f?r.get(f.id):null,x=f==null?void 0:f.node.current;if(x&&m&&h&&f){const g=Si(x).some((w,S)=>i[S]!==w),p=r1(h,f),b=function(w,S){return!Ti(w)||!Ti(S)||!r1(w,S)?!1:w.data.current.sortable.index<S.data.current.sortable.index}(h,f),y=g||!p?{x:0,y:0}:{x:b?o.width-m.width:0,y:b?o.height-m.height:0},v={x:m.left,y:m.top};return y.x&&y.y?v:Ha(v,y)}}}};function r1(t,e){return!(!Ti(t)||!Ti(e))&&t.data.current.sortable.containerId===e.data.current.sortable.containerId}const Q4=uO("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"}}),Ls=t=>{const e=H.c(21);let n,o,r,s,a;e[0]!==t?({children:n,tooltip:s,disabled:r,variant:a,...o}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a):(n=e[1],o=e[2],r=e[3],s=e[4],a=e[5]);const i=r!==void 0&&r;let l,d,u;e[6]!==i||e[7]!==o?(l=f=>{var m;i||((m=o.onClick)==null||m.call(o,f))},e[6]=i,e[7]=o,e[8]=l):l=e[8],e[9]!==o.className||e[10]!==a?(d=ge(Q4({variant:a}),o.className),e[9]=o.className,e[10]=a,e[11]=d):d=e[11],e[12]!==n||e[13]!==i||e[14]!==o||e[15]!==l||e[16]!==d?(u=c.jsx("button",{disabled:i,...o,onClick:l,onMouseDown:Dn.preventFocus,className:d,children:n}),e[12]=n,e[13]=i,e[14]=o,e[15]=l,e[16]=d,e[17]=u):u=e[17];const h=u;if(s){let f;return e[18]!==h||e[19]!==s?(f=c.jsx(Ne,{content:s,side:"top",delayDuration:200,usePortal:!1,children:h}),e[18]=h,e[19]=s,e[20]=f):f=e[20],f}return h},eC=t=>{const e=H.c(5),{children:n,className:o}=t;let r,s;return e[0]!==o?(r=ge("flex items-center gap-1 bg-background m-[2px] rounded-full",o),e[0]=o,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=c.jsx(FS,{className:r,children:n}),e[2]=n,e[3]=r,e[4]=s):s=e[4],s},tC=t=>{const e=H.c(9),{connectionState:n,status:o}=t,r=kg(o==="running");let s,a;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=Ht("global.interrupt"),e[0]=s):s=e[0],e[1]!==n||e[2]!==r?(a=Xn(n)||!r,e[1]=n,e[2]=r,e[3]=a):a=e[3];const i=r?hm:Pn.NOOP,l=r?"stale":"disabled";let d,u;return e[4]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(tc,{strokeWidth:1.5}),e[4]=d):d=e[4],e[5]!==a||e[6]!==i||e[7]!==l?(u=c.jsx(Ls,{tooltip:s,disabled:a,onClick:i,variant:l,"data-testid":"run-button",children:d}),e[5]=a,e[6]=i,e[7]=l,e[8]=u):u=e[8],u},jr={showInput:"Mod-l",acceptEdit:"Mod-y",rejectEdit:"Mod-u"},Fs=xr.define({combine:t=>pc(t,{onError:console.error,inputDebounceTime:300,keymaps:jr},{onError:(e,n)=>e&&n,inputDebounceTime:(e,n)=>e&&n,keymaps:(e,n)=>e&&n})}),or=At.define(),rr=xn.define({create:()=>({show:!1,lineFrom:0,lineTo:0}),update(t,e){for(const n of e.effects)if(n.is(or))return n.value;return t}}),zs=At.define(),Bs=At.define(),s1=xn.define({create:()=>({shouldFocus:!1,inputValue:""}),update(t,e){let n=t;for(const o of e.effects)o.is(zs)&&(n={...n,inputValue:o.value}),o.is(Bs)&&(n={...n,shouldFocus:o.value});return n}}),Mi=At.define(),Us=xn.define({create:()=>null,update(t,e){for(const n of e.effects)if(n.is(Mi))return n.value;return t}}),Cr=At.define(),a1=xn.define({create:()=>!1,update(t,e){for(const n of e.effects)if(n.is(Cr))return n.value;return t}}),i1=t=>{const{state:e}=t,n=e.selection.main;if(n.empty)return!1;const o=e.doc,r=o.lineAt(n.from),s=o.lineAt(n.to);if(e.sliceDoc(r.from,s.to).trim().length<1)return!1;const a=Math.max(1,Math.min(r.number,o.lines)),i=Math.max(1,Math.min(s.number,o.lines));return t.dispatch({effects:[or.of({show:!0,lineFrom:a,lineTo:i}),Bs.of(!0),zs.of("")],selection:Kn.cursor(r.from)}),!0},l1=t=>!!t.state.field(Us)&&(t.dispatch({effects:[Mi.of(null),or.of({show:!1,lineFrom:0,lineTo:0}),Bs.of(!1),zs.of(""),Cr.of(!1)]}),!0),c1=t=>{const e=t.state.field(Us);return!!e&&(t.dispatch({changes:{from:e.from,to:e.to,insert:e.oldCode},effects:[Mi.of(null),or.of({show:!1,lineFrom:0,lineTo:0}),Bs.of(!1),zs.of(""),Cr.of(!1)]}),!0)},nC=Ve.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"}}),oC="\u2318",rC="\u229E Win",sC="Ctrl";function Id(t){return t.replace("Mod",navigator.platform.startsWith("Mac")?oC:navigator.platform.startsWith("Win")?rC:sC).replace("-"," ").toUpperCase()}function qt(t,e){const n=document.createElement(t);return n.className=e,n}function aC(t){var r,s;const e=t.state.facet(Fs),n={...jr,...e.keymaps},o=qt("div","cm-ai-tooltip").appendChild(qt("div","cm-ai-tooltip-button"));return o.innerHTML=`<span>Edit <span class="hotkey">${Id(n.showInput)}</span></span>`,(r=o.querySelector("span"))==null||r.addEventListener("mousedown",a=>{a.stopPropagation()}),(s=o.querySelector("span"))==null||s.addEventListener("click",a=>{a.preventDefault(),i1(t)}),o}const iC=xr.define({combine:t=>pc(t,{render:aC})}),lC=Rn.fromClass((ak=class{constructor(t){Z(this,"view");Z(this,"suppress");Z(this,"dom");Z(this,"mousedown",()=>{this.suppress=!0});Z(this,"mouseup",()=>{this.suppress=!1,this.display(this.view)});uk(this,Fl,t=>{var n;const e=t.state.selection.ranges.find(o=>!o.empty);if(e&&!this.suppress){const o=t.coordsAtPos(e.from);if(!o)return;this.dom.style.display="flex";const r=this.dom.getBoundingClientRect(),s=t.dom.getBoundingClientRect(),a=(n=t.dom.parentElement)==null?void 0:n.getBoundingClientRect(),i=s.width-r.width,l=Math.min(o.left,i);let d=o.top-r.height;d=a?Math.max(a.y,d):d,this.dom.style.left=`${l}px`,this.dom.style.top=`${d}px`,requestAnimationFrame(()=>{this.dom&&(this.dom.ariaHidden="false")})}else this.dom.style.display="none",this.dom.ariaHidden="true"});this.view=t;const e=t.state.facet(iC);this.suppress=!1,document.addEventListener("mousedown",this.mousedown),document.addEventListener("mouseup",this.mouseup);const n=e.render(t);t.dom.appendChild(n),this.dom=n}update(t){this.display(t.view)}docViewUpdate(t){this.display(t)}display(t){t.state.field(rr).show?this.dom.style.display="none":t.requestMeasure({read:dk(this,Fl)})}destroy(){document.removeEventListener("mousedown",this.mousedown),document.removeEventListener("mouseup",this.mouseup),this.dom.remove()}},Fl=new WeakMap,ak)),cC=Ve.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 dC extends gs{constructor(n){super();Z(this,"oldCode");this.oldCode=n}toDOM(n){const o=qt("div","cm-old-code-container");o.setAttribute("role","region"),o.setAttribute("aria-label","Previous code version");const r=qt("div","cm-old-code cm-line");r.textContent=this.oldCode;const s=qt("div","cm-floating-buttons"),a=n.state.facet(Fs),i={...jr,...a.keymaps},l=qt("button","cm-floating-button cm-floating-accept");l.innerHTML=`<span class="hotkey">${Id(i.acceptEdit)}</span> Accept`,l.setAttribute("aria-label","Accept changes"),l.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),l1(n)});const d=qt("button","cm-floating-button cm-floating-reject");return d.innerHTML=`<span class="hotkey">${Id(i.rejectEdit)}</span> Reject`,d.setAttribute("aria-label","Reject changes"),d.addEventListener("click",u=>{u.preventDefault(),u.stopPropagation(),n.focus(),c1(n)}),s.append(l,d),o.append(r,s),o}updateDOM(n,o){return!0}}class uC extends gs{constructor(n){super();Z(this,"complete");Z(this,"abortController",null);Z(this,"dom",null);Z(this,"input",null);Z(this,"loadingContainer",null);Z(this,"helpInfo",null);Z(this,"inputContainer",null);Z(this,"form",null);Z(this,"view",null);Z(this,"onKeyDown",async n=>{n.key!=="Enter"||n.shiftKey?n.key==="Escape"&&this.onCancel():(n.preventDefault(),await this.handleSubmit())});Z(this,"onCancel",()=>{this.cleanup();const n=this.view;n&&(n.dispatch({effects:[or.of({show:!1,lineFrom:0,lineTo:0}),Cr.of(!1)]}),n.focus())});Z(this,"handleSubmit",async n=>{var g;const o=this.view;if(!o)return;const r=o.state.facet(Fs);n==null||n.stopPropagation();const s=o.state.field(rr),{input:a}=this;if(!a)return;const i=a.value.trim();if(!s.show||!i)return;const l=o.state.doc.line(s.lineFrom),d=o.state.doc.line(s.lineTo),u=l.from,h=d.to,f=o.state.sliceDoc(u,h),m=o.state.sliceDoc(0,u),x=o.state.sliceDoc(h);this.abortController=new AbortController,o.dispatch({effects:Cr.of(!0)}),this.toggleLoading(!0);try{const p=await this.complete({prompt:i,selection:f,codeBefore:m,codeAfter:x,editorView:o,signal:this.abortController.signal});if(!o.state.field(rr).show)return;if(!p||typeof p!="string")throw new Error("Invalid completion result");o.dispatch({changes:{from:u,to:h,insert:p},effects:[or.of({show:!1,lineFrom:0,lineTo:0}),Mi.of({from:u,to:u+p.length,oldCode:f,newCode:p}),Cr.of(!1)]})}catch(p){if(p instanceof DOMException&&p.name==="AbortError")return;(g=r.onError)==null||g.call(r,p)}finally{this.cleanup(),this.toggleLoading(!1),o.focus()}});this.complete=n}toDOM(n){if(this.dom)return this.dom;this.view=n;const o=n.state.field(s1),r=n.state.field(a1),s=qt("div","cm-ai-input-container");this.inputContainer=s,this.dom=s;const a=qt("form","cm-ai-input-form");this.form=a,a.setAttribute("role","search"),a.setAttribute("aria-label","AI editing instructions"),a.addEventListener("submit",p=>p.preventDefault());const i=qt("input","cm-ai-input");this.input=i,a.append(i),i.placeholder="Editing instructions...",i.setAttribute("aria-label","AI editing instructions"),i.setAttribute("autocomplete","off"),i.setAttribute("spellcheck","true"),i.value=o.inputValue;const l=qt("div","cm-ai-loading-container");this.loadingContainer=l;const d=qt("div","cm-ai-loading-indicator");d.setAttribute("role","status"),d.setAttribute("aria-live","polite"),d.textContent="Generating";const u=qt("button","cm-ai-cancel-button");u.textContent="Cancel",u.setAttribute("aria-label","Cancel code generation"),u.addEventListener("click",this.onCancel),l.append(u,d);const h=qt("div","cm-ai-help-info");this.helpInfo=h;const f=h.appendChild(document.createElement("button"));f.className="cm-ai-help-info-button",f.textContent="Esc to close",f.addEventListener("click",this.onCancel);const m=qt("button","cm-ai-generate-button");function x(p){h.replaceChildren(p?m:f)}m.textContent="\u23CE Generate",m.setAttribute("aria-label","Generate code"),m.addEventListener("click",this.handleSubmit),this.toggleLoading(r),o.shouldFocus&&requestAnimationFrame(()=>{i.value=o.inputValue,i.focus(),n.dispatch({effects:Bs.of(!1)})}),x(i.value),i.addEventListener("input",function(){n.dispatch({effects:zs.of(i.value)});const p=i.value.trim();p!==g&&(g=p,x(p))}),i.addEventListener("keydown",this.onKeyDown);let g="";return s}toggleLoading(n){var o;this.inputContainer&&this.form&&this.loadingContainer&&this.helpInfo&&((o=this.inputContainer)==null||o.replaceChildren(this.form,n?this.loadingContainer:this.helpInfo))}updateDOM(n,o){return this.dom=n,this.input=n.querySelector(".cm-ai-input"),!0}cleanup(){var n,o,r;(n=this.abortController)==null||n.abort(),this.abortController=null,(o=this.dom)==null||o.remove(),(r=this.input)==null||r.remove(),this.dom=null,this.input=null}destroy(){this.cleanup()}}function hC(t){if(!t.prompt)throw new Error("prompt function is required");return[Fs.of(t),rr,s1,Us,a1,[lC,cC],nC,_n.of([{key:jr.showInput,run:i1}]),Eo.highest([_n.of([{key:jr.acceptEdit,run:l1},{key:jr.rejectEdit,run:c1}])]),fC,mC,pC,gC]}const fC=Ve.updateListener.of(t=>{const e=t.state.field(rr);if(!e.show||!t.docChanged)return;let{lineFrom:n,lineTo:o}=e,r=!1;t.changes.iterChanges((s,a,i,l)=>{const d=t.state.doc.lineAt(s).number;if(d<n){const u=t.state.doc.lineAt(l).number-t.state.doc.lineAt(i).number;n+=u,o+=u,r=!0}else if(d<=o){const u=t.state.doc.lineAt(l).number-t.state.doc.lineAt(i).number;o+=u,r=!0}}),r&&t.view.dispatch({effects:[or.of({show:!0,lineFrom:n,lineTo:o})]})}),mC=Ve.decorations.of(t=>{const e=t.state.field(Us);return e?tt.set([tt.mark({class:"cm-new-code-line"}).range(e.from,e.to)]):tt.none}),pC=Ve.decorations.compute([rr],t=>{const e=t.field(rr),n=t.facet(Fs),o=[];if(e.show){const r=e.lineFrom,s=e.lineTo;for(let a=r;a<=s;a++){const i=t.doc.line(a).from;o.push(tt.line({class:"cm-ai-selection"}).range(i)),a===r&&o.push(tt.widget({widget:new uC(n.prompt),side:-1}).range(i))}}return tt.set(o)}),gC=xn.define({create:t=>tt.none,update(t,e){const n=e.state.field(Us);return n?tt.set([tt.widget({widget:new dC(n.oldCode),block:!0}).range(n.from)]):tt.none},provide:t=>Ve.decorations.from(t)}),Oi=xn.define({create:()=>({suggestion:null}),update(t,e){const n=e.effects.find(o=>o.is(Di));return e.docChanged||n||e.selection?n&&e.state.doc===n.value.doc?{suggestion:n.value.text}:{suggestion:null}:t}}),Di=At.define();class xC extends gs{constructor(n){super();Z(this,"suggestion");this.suggestion=n}toDOM(){const n=document.createElement("span");return n.style.opacity="0.4",n.className="cm-inline-suggestion",n.textContent=this.suggestion,n.setAttribute("role","suggestion"),n.setAttribute("aria-label",`Suggestion: ${this.suggestion}`),n}get lineBreaks(){return this.suggestion.split(`
103
- `).length-1}}class bC{constructor(e){Z(this,"cache",new Map);Z(this,"timeout");this.timeout=e}get(e){const n=this.cache.get(e);return n?Date.now()-n.timestamp>this.timeout?(this.cache.delete(e),null):n.result:null}set(e,n){this.cache.set(e,{result:n,timestamp:Date.now()})}}const yC=(t,e)=>Rn.fromClass(class{constructor(){Z(this,"abortController",null);Z(this,"cache");this.cache=new bC(e.cacheTimeout??1e3)}async update(n){var a,i,l,d,u;if(!n.docChanged||((i=(a=e.events)==null?void 0:a.beforeSuggestionFetch)==null?void 0:i.call(a,n.view))===!1)return;(l=this.abortController)==null||l.abort(),this.abortController=new AbortController;const o=n.state.doc,r=o.toString(),s=this.cache.get(r);if(s)n.view.dispatch({effects:Di.of({text:s,doc:o})});else try{const h=await t(n.state,this.abortController.signal);if(this.abortController.signal.aborted||((u=(d=e.events)==null?void 0:d.shouldShowSuggestion)==null?void 0:u.call(d,n.view,h))===!1)return;this.cache.set(r,h),n.view.dispatch({effects:Di.of({text:h,doc:o})})}catch(h){h instanceof Error&&h.name!=="AbortError"&&console.error("Suggestion fetch error:",h)}}destroy(){var n;(n=this.abortController)==null||n.abort()}}),vC=Rn.fromClass(class{constructor(){Z(this,"decorations");this.decorations=tt.none}update(t){var n;const e=(n=t.state.field(Oi))==null?void 0:n.suggestion;this.decorations=e?function(o,r){const s=o.state.selection.main.head,a=[],i=tt.widget({widget:new xC(r),side:1});return a.push(i.range(s)),tt.set(a)}(t.view,e):tt.none}},{decorations:t=>t.decorations});function wC(t,e,n,o){return{...t.changeByRange(r=>{if(r===t.selection.main)return{changes:{from:n,to:o,insert:e},range:Kn.cursor(n+e.length)};const s=o-n;return!r.empty||s&&t.sliceDoc(r.from-s,r.from)!==t.sliceDoc(n,o)?{range:r}:{changes:{from:r.from-s,to:r.from,insert:e},range:Kn.cursor(r.from-s+e.length)}}),userEvent:"input.complete"}}const d1=t=>{var o,r,s;const e=(o=t.state.field(Oi))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Ad);return t.dispatch({effects:Di.of({text:null,doc:t.state.doc})}),(s=(r=n.events)==null?void 0:r.onSuggestionRejected)==null||s.call(r,t,e),!0},kC=_n.of([{key:"Tab",run:t=>{var o,r,s;const e=(o=t.state.field(Oi))==null?void 0:o.suggestion;if(!e)return!1;const n=t.state.facet(Ad);return t.dispatch({...wC(t.state,e,t.state.selection.main.head,t.state.selection.main.head)}),(s=(r=n.events)==null?void 0:r.onSuggestionAccepted)==null||s.call(r,t,e),!0}},{key:"Escape",run:d1}]),Ad=xr.define({combine:t=>t.at(-1)});function u1(t){const{delay:e=500,includeKeymap:n=!0}=t,o=function(r,s,a){let i=()=>{};return(...l)=>(i(),new Promise((d,u)=>{const h=setTimeout(()=>d(r(...l)),s);i=()=>{clearTimeout(h),a!==void 0&&u(a)}}))}(t.fetchFn,e);return[Oi,Ad.of(t),yC(o,t),vC,n?kC:[]]}const h1="packages-install-input",SC=["%alias","%cd","%clear","%debug","%env","%load","%load_ext","%lsmagic","%matplotlib","%pwd","%who_ls","%system","%%time","%%timeit","%%writefile","%%capture","%%html","%%latex"];let Td;function NC(){const t=async r=>{const s=Qe.get(Ua),a={...s,runtime:{...s.runtime,auto_reload:r}};await pr({config:a}).then(()=>Qe.set(Ua,a))},e=()=>{requestAnimationFrame(()=>{const r=document.getElementById(h1);r&&r.focus()})},n=[{match:"!pip install",onMatch:()=>{Qe.set(fm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:c.jsxs(c.Fragment,{children:["The package manager sidebar has been opened.",c.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv pip install",onMatch:()=>{Qe.set(fm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:c.jsxs(c.Fragment,{children:["The package manager sidebar has been opened.",c.jsx("br",{}),"Install packages directly from there instead."]})},{match:"!uv add",onMatch:()=>{Qe.set(fm,r=>({...r,isSidebarOpen:!0,selectedPanel:"packages"})),e()},title:"Package Installation",description:c.jsxs(c.Fragment,{children:["The package manager sidebar has been opened.",c.jsx("br",{}),"Install packages directly from there instead."]})},{match:"%autoreload 2",onMatch:async()=>{await t("autorun")},title:"Module reload",description:c.jsxs(c.Fragment,{children:["Module reload mode set to ",c.jsx("b",{children:"autorun"})," - module changes will re-run the cells that import them."]})},{match:"%autoreload 1",onMatch:async()=>{await t("lazy")},title:"Module reload",description:c.jsxs(c.Fragment,{children:["Module reload mode set to ",c.jsx("b",{children:"lazy"})," - module changes will mark the cells that import them as stale."]})},{match:"%autoreload 0",onMatch:async()=>{await t("off")},title:"Module reload",description:c.jsx(c.Fragment,{children:"Module reload disabled - module changes will not be detected."})},{match:"!ls",onMatch:()=>{},title:"Listing files",description:c.jsxs(c.Fragment,{children:["Shell commands are not directly supported.",c.jsx("br",{}),"Use ",c.jsx("code",{children:"import subprocess; subprocess.run(['ls'])"})," instead."]})},...SC.map(r=>({match:r,onMatch:()=>{},title:c.jsx(s3,{className:"inline",children:r}),description:c.jsxs(c.Fragment,{children:["Magic commands are not supported in marimo. Read more about replacements in the"," ",c.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"}),"."]})}))],o=new Map(n.map(r=>[r.match,r]));return Ve.updateListener.of(r=>{if(r.docChanged){const s=r.state.selection.main,a=r.state.doc,i=a.lineAt(s.head),l=a.sliceString(i.from,s.anchor).trim(),d=o.get(l);d&&(d.onMatch(),Td?Td.upsert({title:d.title,description:d.description}):Td=Xe({title:d.title,description:d.description}))}})}const jC=new Set(["Escape","Alt-`"]);function CC(){const t=a3.filter(e=>!jC.has(e.key));return Eo.highest(_n.of([...t,{key:"Escape",run:e=>{const n=Bl(e);return!Ga(e)&&n}},{key:"Ctrl-y",run:e=>!!Ga(e)&&i3(e)},{key:"Ctrl-n",run:e=>!!Ga(e)&&gc(!0)(e)},{key:"Ctrl-p",run:e=>!!Ga(e)&&gc(!1)(e)}]))}const Md=At.define(),Od=At.define(),Dd=At.define();function xt(t,e){if(!t)throw new Error(e)}function Pi(t){if(typeof t!="number")throw new Error("invalid int 32: "+typeof t);if(!Number.isInteger(t)||t>2147483647||t<-2147483648)throw new Error("invalid int 32: "+t)}function Pd(t){if(typeof t!="number")throw new Error("invalid uint 32: "+typeof t);if(!Number.isInteger(t)||t>4294967295||t<0)throw new Error("invalid uint 32: "+t)}function f1(t){if(typeof t!="number")throw new Error("invalid float 32: "+typeof t);if(Number.isFinite(t)&&(t>3402823466385289e23||t<-3402823466385289e23))throw new Error("invalid float 32: "+t)}const m1=Symbol("@bufbuild/protobuf/enum-type");function EC(t){const e=t[m1];return xt(e,"missing enum type on enum object"),e}function p1(t,e,n,o){t[m1]=g1(e,n.map(r=>({no:r.no,name:r.name,localName:t[r.no]})))}function g1(t,e,n){const o=Object.create(null),r=Object.create(null),s=[];for(const a of e){const i=x1(a);s.push(i),o[a.name]=i,r[a.no]=i}return{typeName:t,values:s,findName:a=>o[a],findNumber:a=>r[a]}}function _C(t,e,n){const o={};for(const r of e){const s=x1(r);o[s.localName]=s.no,o[s.no]=s.localName}return p1(o,t,e),o}function x1(t){return"localName"in t?t:Object.assign(Object.assign({},t),{localName:t.name})}class Nt{equals(e){return this.getType().runtime.util.equals(this.getType(),this,e)}clone(){return this.getType().runtime.util.clone(this)}fromBinary(e,n){const o=this.getType().runtime.bin,r=o.makeReadOptions(n);return o.readMessage(this,r.readerFactory(e),e.byteLength,r),this}fromJson(e,n){const o=this.getType(),r=o.runtime.json,s=r.makeReadOptions(n);return r.readMessage(o,e,s,this),this}fromJsonString(e,n){let o;try{o=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(o,n)}toBinary(e){const n=this.getType().runtime.bin,o=n.makeWriteOptions(e),r=o.writerFactory();return n.writeMessage(this,r,o),r.finish()}toJson(e){const n=this.getType().runtime.json,o=n.makeWriteOptions(e);return n.writeMessage(this,o)}toJsonString(e){var n;const o=this.toJson(e);return JSON.stringify(o,null,(n=e==null?void 0:e.prettySpaces)!==null&&n!==void 0?n:0)}toJSON(){return this.toJson({emitDefaultValues:!0})}getType(){return Object.getPrototypeOf(this).constructor}}function IC(){let t=0,e=0;for(let o=0;o<28;o+=7){let r=this.buf[this.pos++];if(t|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}let n=this.buf[this.pos++];if(t|=(15&n)<<28,e=(112&n)>>4,!(128&n))return this.assertBounds(),[t,e];for(let o=3;o<=31;o+=7){let r=this.buf[this.pos++];if(e|=(127&r)<<o,!(128&r))return this.assertBounds(),[t,e]}throw new Error("invalid varint")}function Rd(t,e,n){for(let s=0;s<28;s+=7){const a=t>>>s,i=!(!(a>>>7)&&e==0),l=255&(i?128|a:a);if(n.push(l),!i)return}const o=t>>>28&15|(7&e)<<4,r=!!(e>>3);if(n.push(255&(r?128|o:o)),r){for(let s=3;s<31;s+=7){const a=e>>>s,i=!!(a>>>7),l=255&(i?128|a:a);if(n.push(l),!i)return}n.push(e>>>31&1)}}const Ri=4294967296;function b1(t){const e=t[0]==="-";e&&(t=t.slice(1));const n=1e6;let o=0,r=0;function s(a,i){const l=Number(t.slice(a,i));r*=n,o=o*n+l,o>=Ri&&(r+=o/Ri|0,o%=Ri)}return s(-24,-18),s(-18,-12),s(-12,-6),s(-6),e?v1(o,r):Ld(o,r)}function y1(t,e){if({lo:t,hi:e}=function(l,d){return{lo:l>>>0,hi:d>>>0}}(t,e),e<=2097151)return String(Ri*e+t);const n=16777215&(t>>>24|e<<8),o=e>>16&65535;let r=(16777215&t)+6777216*n+6710656*o,s=n+8147497*o,a=2*o;const i=1e7;return r>=i&&(s+=Math.floor(r/i),r%=i),s>=i&&(a+=Math.floor(s/i),s%=i),a.toString()+w1(s)+w1(r)}function Ld(t,e){return{lo:0|t,hi:0|e}}function v1(t,e){return e=~e,t?t=1+~t:e+=1,Ld(t,e)}const w1=t=>{const e=String(t);return"0000000".slice(e.length)+e};function k1(t,e){if(t>=0){for(;t>127;)e.push(127&t|128),t>>>=7;e.push(t)}else{for(let n=0;n<9;n++)e.push(127&t|128),t>>=7;e.push(1)}}function AC(){let t=this.buf[this.pos++],e=127&t;if(!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<7,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<14,!(128&t))return this.assertBounds(),e;if(t=this.buf[this.pos++],e|=(127&t)<<21,!(128&t))return this.assertBounds(),e;t=this.buf[this.pos++],e|=(15&t)<<28;for(let n=5;128&t&&n<10;n++)t=this.buf[this.pos++];if(128&t)throw new Error("invalid varint");return this.assertBounds(),e>>>0}var TC={};const ft=function(){const t=new DataView(new ArrayBuffer(8));if(typeof BigInt=="function"&&typeof t.getBigInt64=="function"&&typeof t.getBigUint64=="function"&&typeof t.setBigInt64=="function"&&typeof t.setBigUint64=="function"&&(typeof process!="object"||TC.BUF_BIGINT_DISABLE!=="1")){const o=BigInt("-9223372036854775808"),r=BigInt("9223372036854775807"),s=BigInt("0"),a=BigInt("18446744073709551615");return{zero:BigInt(0),supported:!0,parse(i){const l=typeof i=="bigint"?i:BigInt(i);if(l>r||l<o)throw new Error(`int64 invalid: ${i}`);return l},uParse(i){const l=typeof i=="bigint"?i:BigInt(i);if(l>a||l<s)throw new Error(`uint64 invalid: ${i}`);return l},enc(i){return t.setBigInt64(0,this.parse(i),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},uEnc(i){return t.setBigInt64(0,this.uParse(i),!0),{lo:t.getInt32(0,!0),hi:t.getInt32(4,!0)}},dec:(i,l)=>(t.setInt32(0,i,!0),t.setInt32(4,l,!0),t.getBigInt64(0,!0)),uDec:(i,l)=>(t.setInt32(0,i,!0),t.setInt32(4,l,!0),t.getBigUint64(0,!0))}}const e=o=>xt(/^-?[0-9]+$/.test(o),`int64 invalid: ${o}`),n=o=>xt(/^[0-9]+$/.test(o),`uint64 invalid: ${o}`);return{zero:"0",supported:!1,parse:o=>(typeof o!="string"&&(o=o.toString()),e(o),o),uParse:o=>(typeof o!="string"&&(o=o.toString()),n(o),o),enc:o=>(typeof o!="string"&&(o=o.toString()),e(o),b1(o)),uEnc:o=>(typeof o!="string"&&(o=o.toString()),n(o),b1(o)),dec:(o,r)=>function(s,a){let i=Ld(s,a);const l=2147483648&i.hi;l&&(i=v1(i.lo,i.hi));const d=y1(i.lo,i.hi);return l?"-"+d:d}(o,r),uDec:(o,r)=>y1(o,r)}}();var le,To,wt;function Mo(t,e,n){if(e===n)return!0;if(t==le.BYTES){if(!(e instanceof Uint8Array&&n instanceof Uint8Array)||e.length!==n.length)return!1;for(let o=0;o<e.length;o++)if(e[o]!==n[o])return!1;return!0}switch(t){case le.UINT64:case le.FIXED64:case le.INT64:case le.SFIXED64:case le.SINT64:return e==n}return!1}function Er(t,e){switch(t){case le.BOOL:return!1;case le.UINT64:case le.FIXED64:case le.INT64:case le.SFIXED64:case le.SINT64:return e==0?ft.zero:"0";case le.DOUBLE:case le.FLOAT:return 0;case le.BYTES:return new Uint8Array(0);case le.STRING:return"";default:return 0}}function S1(t,e){switch(t){case le.BOOL:return e===!1;case le.STRING:return e==="";case le.BYTES:return e instanceof Uint8Array&&!e.byteLength;default:return e==0}}(function(t){t[t.DOUBLE=1]="DOUBLE",t[t.FLOAT=2]="FLOAT",t[t.INT64=3]="INT64",t[t.UINT64=4]="UINT64",t[t.INT32=5]="INT32",t[t.FIXED64=6]="FIXED64",t[t.FIXED32=7]="FIXED32",t[t.BOOL=8]="BOOL",t[t.STRING=9]="STRING",t[t.BYTES=12]="BYTES",t[t.UINT32=13]="UINT32",t[t.SFIXED32=15]="SFIXED32",t[t.SFIXED64=16]="SFIXED64",t[t.SINT32=17]="SINT32",t[t.SINT64=18]="SINT64"})(le||(le={})),function(t){t[t.BIGINT=0]="BIGINT",t[t.STRING=1]="STRING"}(To||(To={})),function(t){t[t.Varint=0]="Varint",t[t.Bit64=1]="Bit64",t[t.LengthDelimited=2]="LengthDelimited",t[t.StartGroup=3]="StartGroup",t[t.EndGroup=4]="EndGroup",t[t.Bit32=5]="Bit32"}(wt||(wt={}));class MC{constructor(e){this.stack=[],this.textEncoder=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 n=new Uint8Array(e),o=0;for(let r=0;r<this.chunks.length;r++)n.set(this.chunks[r],o),o+=this.chunks[r].length;return this.chunks=[],n}fork(){return this.stack.push({chunks:this.chunks,buf:this.buf}),this.chunks=[],this.buf=[],this}join(){let e=this.finish(),n=this.stack.pop();if(!n)throw new Error("invalid state, fork stack empty");return this.chunks=n.chunks,this.buf=n.buf,this.uint32(e.byteLength),this.raw(e)}tag(e,n){return this.uint32((e<<3|n)>>>0)}raw(e){return this.buf.length&&(this.chunks.push(new Uint8Array(this.buf)),this.buf=[]),this.chunks.push(e),this}uint32(e){for(Pd(e);e>127;)this.buf.push(127&e|128),e>>>=7;return this.buf.push(e),this}int32(e){return Pi(e),k1(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 n=this.textEncoder.encode(e);return this.uint32(n.byteLength),this.raw(n)}float(e){f1(e);let n=new Uint8Array(4);return new DataView(n.buffer).setFloat32(0,e,!0),this.raw(n)}double(e){let n=new Uint8Array(8);return new DataView(n.buffer).setFloat64(0,e,!0),this.raw(n)}fixed32(e){Pd(e);let n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,e,!0),this.raw(n)}sfixed32(e){Pi(e);let n=new Uint8Array(4);return new DataView(n.buffer).setInt32(0,e,!0),this.raw(n)}sint32(e){return Pi(e),k1(e=(e<<1^e>>31)>>>0,this.buf),this}sfixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=ft.enc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}fixed64(e){let n=new Uint8Array(8),o=new DataView(n.buffer),r=ft.uEnc(e);return o.setInt32(0,r.lo,!0),o.setInt32(4,r.hi,!0),this.raw(n)}int64(e){let n=ft.enc(e);return Rd(n.lo,n.hi,this.buf),this}sint64(e){let n=ft.enc(e),o=n.hi>>31;return Rd(n.lo<<1^o,(n.hi<<1|n.lo>>>31)^o,this.buf),this}uint64(e){let n=ft.uEnc(e);return Rd(n.lo,n.hi,this.buf),this}}class OC{constructor(e,n){this.varint64=IC,this.uint32=AC,this.buf=e,this.len=e.length,this.pos=0,this.view=new DataView(e.buffer,e.byteOffset,e.byteLength),this.textDecoder=n??new TextDecoder}tag(){let e=this.uint32(),n=e>>>3,o=7&e;if(n<=0||o<0||o>5)throw new Error("illegal tag: field no "+n+" wire type "+o);return[n,o]}skip(e,n){let o=this.pos;switch(e){case wt.Varint:for(;128&this.buf[this.pos++];);break;case wt.Bit64:this.pos+=4;case wt.Bit32:this.pos+=4;break;case wt.LengthDelimited:let r=this.uint32();this.pos+=r;break;case wt.StartGroup:for(;;){const[s,a]=this.tag();if(a===wt.EndGroup){if(n!==void 0&&s!==n)throw new Error("invalid end group tag");break}this.skip(a,s)}break;default:throw new Error("cant skip wire type "+e)}return this.assertBounds(),this.buf.subarray(o,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 ft.dec(...this.varint64())}uint64(){return ft.uDec(...this.varint64())}sint64(){let[e,n]=this.varint64(),o=-(1&e);return e=(e>>>1|(1&n)<<31)^o,n=n>>>1^o,ft.dec(e,n)}bool(){let[e,n]=this.varint64();return e!==0||n!==0}fixed32(){return this.view.getUint32((this.pos+=4)-4,!0)}sfixed32(){return this.view.getInt32((this.pos+=4)-4,!0)}fixed64(){return ft.uDec(this.sfixed32(),this.sfixed32())}sfixed64(){return ft.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(),n=this.pos;return this.pos+=e,this.assertBounds(),this.buf.subarray(n,n+e)}string(){return this.textDecoder.decode(this.bytes())}}function N1(t){const e=t.field.localName,n=Object.create(null);return n[e]=function(o){const r=o.field;if(r.repeated)return[];if(r.default!==void 0)return r.default;switch(r.kind){case"enum":return r.T.values[0].no;case"scalar":return Er(r.T,r.L);case"message":const s=r.T,a=new s;return s.fieldWrapper?s.fieldWrapper.unwrapField(a):a;case"map":throw"map fields are not allowed to be extensions"}}(t),[n,()=>n[e]]}let Zn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".split(""),Li=[];for(let t=0;t<Zn.length;t++)Li[Zn[t].charCodeAt(0)]=t;Li[45]=Zn.indexOf("+"),Li[95]=Zn.indexOf("/");const Fi={dec(t){let e=3*t.length/4;t[t.length-2]=="="?e-=2:t[t.length-1]=="="&&(e-=1);let n,o=new Uint8Array(e),r=0,s=0,a=0;for(let i=0;i<t.length;i++){if(n=Li[t.charCodeAt(i)],n===void 0)switch(t[i]){case"=":s=0;case`
104
- `:case"\r":case" ":case" ":continue;default:throw Error("invalid base64 string.")}switch(s){case 0:a=n,s=1;break;case 1:o[r++]=a<<2|(48&n)>>4,a=n,s=2;break;case 2:o[r++]=(15&a)<<4|(60&n)>>2,a=n,s=3;break;case 3:o[r++]=(3&a)<<6|n,s=0}}if(s==1)throw Error("invalid base64 string.");return o.subarray(0,r)},enc(t){let e,n="",o=0,r=0;for(let s=0;s<t.length;s++)switch(e=t[s],o){case 0:n+=Zn[e>>2],r=(3&e)<<4,o=1;break;case 1:n+=Zn[r|e>>4],r=(15&e)<<2,o=2;break;case 2:n+=Zn[r|e>>6],n+=Zn[63&e],o=0}return o&&(n+=Zn[r],n+="=",o==1&&(n+="=")),n}};function DC(t,e,n){C1(e,t);const o=e.runtime.bin.makeReadOptions(n),r=function(i,l){if(!l.repeated&&(l.kind=="enum"||l.kind=="scalar")){for(let d=i.length-1;d>=0;--d)if(i[d].no==l.no)return[i[d]];return[]}return i.filter(d=>d.no===l.no)}(t.getType().runtime.bin.listUnknownFields(t),e.field),[s,a]=N1(e);for(const i of r)e.runtime.bin.readField(s,o.readerFactory(i.data),e.field,i.wireType,o);return a()}function PC(t,e,n,o){C1(e,t);const r=e.runtime.bin.makeReadOptions(o),s=e.runtime.bin.makeWriteOptions(o);if(j1(t,e)){const d=t.getType().runtime.bin.listUnknownFields(t).filter(u=>u.no!=e.field.no);t.getType().runtime.bin.discardUnknownFields(t);for(const u of d)t.getType().runtime.bin.onUnknownField(t,u.no,u.wireType,u.data)}const a=s.writerFactory();let i=e.field;i.opt||i.repeated||i.kind!="enum"&&i.kind!="scalar"||(i=Object.assign(Object.assign({},e.field),{opt:!0})),e.runtime.bin.writeField(i,n,a,s);const l=r.readerFactory(a.finish());for(;l.pos<l.len;){const[d,u]=l.tag(),h=l.skip(u,d);t.getType().runtime.bin.onUnknownField(t,d,u,h)}}function j1(t,e){const n=t.getType();return e.extendee.typeName===n.typeName&&!!n.runtime.bin.listUnknownFields(t).find(o=>o.no==e.field.no)}function C1(t,e){xt(t.extendee.typeName==e.getType().typeName,`extension ${t.typeName} can only be applied to message ${t.extendee.typeName}`)}function E1(t,e){const n=t.localName;if(t.repeated)return e[n].length>0;if(t.oneof)return e[t.oneof.localName].case===n;switch(t.kind){case"enum":case"scalar":return t.opt||t.req?e[n]!==void 0:t.kind=="enum"?e[n]!==t.T.values[0].no:!S1(t.T,e[n]);case"message":return e[n]!==void 0;case"map":return Object.keys(e[n]).length>0}}function _1(t,e){const n=t.localName,o=!t.opt&&!t.req;if(t.repeated)e[n]=[];else if(t.oneof)e[t.oneof.localName]={case:void 0};else switch(t.kind){case"map":e[n]={};break;case"enum":e[n]=o?t.T.values[0].no:void 0;break;case"scalar":e[n]=o?Er(t.T,t.L):void 0;break;case"message":e[n]=void 0}}function Qn(t,e){if(t===null||typeof t!="object"||!Object.getOwnPropertyNames(Nt.prototype).every(o=>o in t&&typeof t[o]=="function"))return!1;const n=t.getType();return n!==null&&typeof n=="function"&&"typeName"in n&&typeof n.typeName=="string"&&(e===void 0||n.typeName==e.typeName)}function I1(t,e){return Qn(e)||!t.fieldWrapper?e:t.fieldWrapper.wrapField(e)}le.DOUBLE,le.FLOAT,le.INT64,le.UINT64,le.INT32,le.UINT32,le.BOOL,le.STRING,le.BYTES;const A1={ignoreUnknownFields:!1},T1={emitDefaultValues:!1,enumAsInteger:!1,useProtoFieldName:!1,prettySpaces:0};function RC(t){return t?Object.assign(Object.assign({},A1),t):A1}function LC(t){return t?Object.assign(Object.assign({},T1),t):T1}const zi=Symbol(),Bi=Symbol();function Fn(t){if(t===null)return"null";switch(typeof t){case"object":return Array.isArray(t)?"array":"object";case"string":return t.length>100?"string":`"${t.split('"').join('\\"')}"`;default:return String(t)}}function M1(t,e,n,o,r){let s=n.localName;if(n.repeated){if(xt(n.kind!="map"),e===null)return;if(!Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Fn(e)}`);const a=t[s];for(const i of e){if(i===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Fn(i)}`);switch(n.kind){case"message":a.push(n.T.fromJson(i,o));break;case"enum":const l=Fd(n.T,i,o.ignoreUnknownFields,!0);l!==Bi&&a.push(l);break;case"scalar":try{a.push($s(n.T,i,n.L,!0))}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Fn(i)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}}else if(n.kind=="map"){if(e===null)return;if(typeof e!="object"||Array.isArray(e))throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: ${Fn(e)}`);const a=t[s];for(const[i,l]of Object.entries(e)){if(l===null)throw new Error(`cannot decode field ${r.typeName}.${n.name} from JSON: map value null`);let d;try{d=FC(n.K,i)}catch(u){let h=`cannot decode map key for field ${r.typeName}.${n.name} from JSON: ${Fn(e)}`;throw u instanceof Error&&u.message.length>0&&(h+=`: ${u.message}`),new Error(h)}switch(n.V.kind){case"message":a[d]=n.V.T.fromJson(l,o);break;case"enum":const u=Fd(n.V.T,l,o.ignoreUnknownFields,!0);u!==Bi&&(a[d]=u);break;case"scalar":try{a[d]=$s(n.V.T,l,To.BIGINT,!0)}catch(h){let f=`cannot decode map value for field ${r.typeName}.${n.name} from JSON: ${Fn(e)}`;throw h instanceof Error&&h.message.length>0&&(f+=`: ${h.message}`),new Error(f)}}}}else switch(n.oneof&&(t=t[n.oneof.localName]={case:s},s="value"),n.kind){case"message":const a=n.T;if(e===null&&a.typeName!="google.protobuf.Value")return;let i=t[s];Qn(i)?i.fromJson(e,o):(t[s]=i=a.fromJson(e,o),a.fieldWrapper&&!n.oneof&&(t[s]=a.fieldWrapper.unwrapField(i)));break;case"enum":const l=Fd(n.T,e,o.ignoreUnknownFields,!1);switch(l){case zi:_1(n,t);break;case Bi:break;default:t[s]=l}break;case"scalar":try{const d=$s(n.T,e,n.L,!1);d===zi?_1(n,t):t[s]=d}catch(d){let u=`cannot decode field ${r.typeName}.${n.name} from JSON: ${Fn(e)}`;throw d instanceof Error&&d.message.length>0&&(u+=`: ${d.message}`),new Error(u)}}}function FC(t,e){if(t===le.BOOL)switch(e){case"true":e=!0;break;case"false":e=!1}return $s(t,e,To.BIGINT,!0).toString()}function $s(t,e,n,o){if(e===null)return o?Er(t,n):zi;switch(t){case le.DOUBLE:case le.FLOAT:if(e==="NaN")return Number.NaN;if(e==="Infinity")return Number.POSITIVE_INFINITY;if(e==="-Infinity")return Number.NEGATIVE_INFINITY;if(e===""||typeof e=="string"&&e.trim().length!==e.length||typeof e!="string"&&typeof e!="number")break;const r=Number(e);if(Number.isNaN(r)||!Number.isFinite(r))break;return t==le.FLOAT&&f1(r),r;case le.INT32:case le.FIXED32:case le.SFIXED32:case le.SINT32:case le.UINT32:let s;if(typeof e=="number"?s=e:typeof e=="string"&&e.length>0&&e.trim().length===e.length&&(s=Number(e)),s===void 0)break;return t==le.UINT32||t==le.FIXED32?Pd(s):Pi(s),s;case le.INT64:case le.SFIXED64:case le.SINT64:if(typeof e!="number"&&typeof e!="string")break;const a=ft.parse(e);return n?a.toString():a;case le.FIXED64:case le.UINT64:if(typeof e!="number"&&typeof e!="string")break;const i=ft.uParse(e);return n?i.toString():i;case le.BOOL:if(typeof e!="boolean")break;return e;case le.STRING:if(typeof e!="string")break;try{encodeURIComponent(e)}catch{throw new Error("invalid UTF8")}return e;case le.BYTES:if(e==="")return new Uint8Array(0);if(typeof e!="string")break;return Fi.dec(e)}throw new Error}function Fd(t,e,n,o){if(e===null)return t.typeName=="google.protobuf.NullValue"?0:o?t.values[0].no:zi;switch(typeof e){case"number":if(Number.isInteger(e))return e;break;case"string":const r=t.findName(e);if(r!==void 0)return r.no;if(n)return Bi}throw new Error(`cannot decode enum ${t.typeName} from JSON: ${Fn(e)}`)}function zC(t){return!(!t.repeated&&t.kind!="map")||!t.oneof&&t.kind!="message"&&!t.opt&&!t.req}function O1(t,e,n){if(t.kind=="map"){xt(typeof e=="object"&&e!=null);const o={},r=Object.entries(e);switch(t.V.kind){case"scalar":for(const[a,i]of r)o[a.toString()]=Ui(t.V.T,i);break;case"message":for(const[a,i]of r)o[a.toString()]=i.toJson(n);break;case"enum":const s=t.V.T;for(const[a,i]of r)o[a.toString()]=zd(s,i,n.enumAsInteger)}return n.emitDefaultValues||r.length>0?o:void 0}if(t.repeated){xt(Array.isArray(e));const o=[];switch(t.kind){case"scalar":for(let r=0;r<e.length;r++)o.push(Ui(t.T,e[r]));break;case"enum":for(let r=0;r<e.length;r++)o.push(zd(t.T,e[r],n.enumAsInteger));break;case"message":for(let r=0;r<e.length;r++)o.push(e[r].toJson(n))}return n.emitDefaultValues||o.length>0?o:void 0}switch(t.kind){case"scalar":return Ui(t.T,e);case"enum":return zd(t.T,e,n.enumAsInteger);case"message":return I1(t.T,e).toJson(n)}}function zd(t,e,n){var o;if(xt(typeof e=="number"),t.typeName=="google.protobuf.NullValue")return null;if(n)return e;const r=t.findNumber(e);return(o=r==null?void 0:r.name)!==null&&o!==void 0?o:e}function Ui(t,e){switch(t){case le.INT32:case le.SFIXED32:case le.SINT32:case le.FIXED32:case le.UINT32:return xt(typeof e=="number"),e;case le.FLOAT:case le.DOUBLE:return xt(typeof e=="number"),Number.isNaN(e)?"NaN":e===Number.POSITIVE_INFINITY?"Infinity":e===Number.NEGATIVE_INFINITY?"-Infinity":e;case le.STRING:return xt(typeof e=="string"),e;case le.BOOL:return xt(typeof e=="boolean"),e;case le.UINT64:case le.FIXED64:case le.INT64:case le.SFIXED64:case le.SINT64:return xt(typeof e=="bigint"||typeof e=="string"||typeof e=="number"),e.toString();case le.BYTES:return xt(e instanceof Uint8Array),Fi.enc(e)}}const _r=Symbol("@bufbuild/protobuf/unknown-fields"),D1={readUnknownFields:!0,readerFactory:t=>new OC(t)},P1={writeUnknownFields:!0,writerFactory:()=>new MC};function BC(t){return t?Object.assign(Object.assign({},D1),t):D1}function UC(t){return t?Object.assign(Object.assign({},P1),t):P1}function R1(t,e,n,o,r){let{repeated:s,localName:a}=n;switch(n.oneof&&((t=t[n.oneof.localName]).case!=a&&delete t.value,t.case=a,a="value"),n.kind){case"scalar":case"enum":const i=n.kind=="enum"?le.INT32:n.T;let l=Vi;if(n.kind=="scalar"&&n.L>0&&(l=$C),s){let f=t[a];if(o==wt.LengthDelimited&&i!=le.STRING&&i!=le.BYTES){let m=e.uint32()+e.pos;for(;e.pos<m;)f.push(l(e,i))}else f.push(l(e,i))}else t[a]=l(e,i);break;case"message":const d=n.T;s?t[a].push($i(e,new d,r,n)):Qn(t[a])?$i(e,t[a],r,n):(t[a]=$i(e,new d,r,n),!d.fieldWrapper||n.oneof||n.repeated||(t[a]=d.fieldWrapper.unwrapField(t[a])));break;case"map":let[u,h]=function(f,m,x){const g=m.uint32(),p=m.pos+g;let b,y;for(;m.pos<p;){const[v]=m.tag();switch(v){case 1:b=Vi(m,f.K);break;case 2:switch(f.V.kind){case"scalar":y=Vi(m,f.V.T);break;case"enum":y=m.int32();break;case"message":y=$i(m,new f.V.T,x,void 0)}}}if(b===void 0&&(b=Er(f.K,To.BIGINT)),typeof b!="string"&&typeof b!="number"&&(b=b.toString()),y===void 0)switch(f.V.kind){case"scalar":y=Er(f.V.T,To.BIGINT);break;case"enum":y=f.V.T.values[0].no;break;case"message":y=new f.V.T}return[b,y]}(n,e,r);t[a][u]=h}}function $i(t,e,n,o){const r=e.getType().runtime.bin,s=o==null?void 0:o.delimited;return r.readMessage(e,t,s?o.no:t.uint32(),n,s),e}function $C(t,e){const n=Vi(t,e);return typeof n=="bigint"?n.toString():n}function Vi(t,e){switch(e){case le.STRING:return t.string();case le.BOOL:return t.bool();case le.DOUBLE:return t.double();case le.FLOAT:return t.float();case le.INT32:return t.int32();case le.INT64:return t.int64();case le.UINT64:return t.uint64();case le.FIXED64:return t.fixed64();case le.BYTES:return t.bytes();case le.FIXED32:return t.fixed32();case le.SFIXED32:return t.sfixed32();case le.SFIXED64:return t.sfixed64();case le.SINT64:return t.sint64();case le.UINT32:return t.uint32();case le.SINT32:return t.sint32()}}function L1(t,e,n,o){xt(e!==void 0);const r=t.repeated;switch(t.kind){case"scalar":case"enum":let s=t.kind=="enum"?le.INT32:t.T;if(r)if(xt(Array.isArray(e)),t.packed)(function(a,i,l,d){if(!d.length)return;a.tag(l,wt.LengthDelimited).fork();let[,u]=z1(i);for(let h=0;h<d.length;h++)a[u](d[h]);a.join()})(n,s,t.no,e);else for(const a of e)Vs(n,s,t.no,a);else Vs(n,s,t.no,e);break;case"message":if(r){xt(Array.isArray(e));for(const a of e)F1(n,o,t,a)}else F1(n,o,t,e);break;case"map":xt(typeof e=="object"&&e!=null);for(const[a,i]of Object.entries(e))VC(n,o,t,a,i)}}function VC(t,e,n,o,r){t.tag(n.no,wt.LengthDelimited),t.fork();let s=o;switch(n.K){case le.INT32:case le.FIXED32:case le.UINT32:case le.SFIXED32:case le.SINT32:s=Number.parseInt(o);break;case le.BOOL:xt(o=="true"||o=="false"),s=o=="true"}switch(Vs(t,n.K,1,s),n.V.kind){case"scalar":Vs(t,n.V.T,2,r);break;case"enum":Vs(t,le.INT32,2,r);break;case"message":xt(r!==void 0),t.tag(2,wt.LengthDelimited).bytes(r.toBinary(e))}t.join()}function F1(t,e,n,o){const r=I1(n.T,o);n.delimited?t.tag(n.no,wt.StartGroup).raw(r.toBinary(e)).tag(n.no,wt.EndGroup):t.tag(n.no,wt.LengthDelimited).bytes(r.toBinary(e))}function Vs(t,e,n,o){xt(o!==void 0);let[r,s]=z1(e);t.tag(n,r)[s](o)}function z1(t){let e=wt.Varint;switch(t){case le.BYTES:case le.STRING:e=wt.LengthDelimited;break;case le.DOUBLE:case le.FIXED64:case le.SFIXED64:e=wt.Bit64;break;case le.FIXED32:case le.SFIXED32:case le.FLOAT:e=wt.Bit32}return[e,le[t].toLowerCase()]}function Hi(t){if(t===void 0)return t;if(Qn(t))return t.clone();if(t instanceof Uint8Array){const e=new Uint8Array(t.byteLength);return e.set(t),e}return t}function Hs(t){return t instanceof Uint8Array?t:new Uint8Array(t)}class HC{constructor(e,n){this._fields=e,this._normalizer=n}findJsonName(e){if(!this.jsonNames){const n={};for(const o of this.list())n[o.jsonName]=n[o.name]=o;this.jsonNames=n}return this.jsonNames[e]}find(e){if(!this.numbers){const n={};for(const o of this.list())n[o.no]=o;this.numbers=n}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,n)=>e.no-n.no)),this.numbersAsc}byMember(){if(!this.members){this.members=[];const e=this.members;let n;for(const o of this.list())o.oneof?o.oneof!==n&&(n=o.oneof,e.push(n)):e.push(o)}return this.members}}function B1(t,e){const n=U1(t);return e?n:KC(YC(n))}const WC=U1;function U1(t){let e=!1;const n=[];for(let o=0;o<t.length;o++){let r=t.charAt(o);switch(r){case"_":e=!0;break;case"0":case"1":case"2":case"3":case"4":case"5":case"6":case"7":case"8":case"9":n.push(r),e=!1;break;default:e&&(e=!1,r=r.toUpperCase()),n.push(r)}}return n.join("")}const qC=new Set(["constructor","toString","toJSON","valueOf"]),GC=new Set(["getType","clone","equals","fromBinary","fromJson","fromJsonString","toBinary","toJson","toJsonString","toObject"]),$1=t=>`${t}$`,YC=t=>GC.has(t)?$1(t):t,KC=t=>qC.has(t)?$1(t):t;class XC{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=B1(e,!1)}addField(e){xt(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 n=0;n<this.fields.length;n++)this._lookup[this.fields[n].localName]=this.fields[n]}return this._lookup[e]}}const xe=(V1=t=>new HC(t,e=>function(n){var o,r,s,a,i,l;const d=[];let u;for(const h of typeof n=="function"?n():n){const f=h;if(f.localName=B1(h.name,h.oneof!==void 0),f.jsonName=(o=h.jsonName)!==null&&o!==void 0?o:WC(h.name),f.repeated=(r=h.repeated)!==null&&r!==void 0&&r,h.kind=="scalar"&&(f.L=(s=h.L)!==null&&s!==void 0?s:To.BIGINT),f.delimited=(a=h.delimited)!==null&&a!==void 0&&a,f.req=(i=h.req)!==null&&i!==void 0&&i,f.opt=(l=h.opt)!==null&&l!==void 0&&l,h.packed===void 0&&(f.packed=h.kind=="enum"||h.kind=="scalar"&&h.T!=le.BYTES&&h.T!=le.STRING),h.oneof!==void 0){const m=typeof h.oneof=="string"?h.oneof:h.oneof.name;u&&u.name==m||(u=new XC(m)),f.oneof=u,u.addField(f)}d.push(f)}return d}(e)),H1=t=>{for(const e of t.getType().fields.byMember()){if(e.opt)continue;const n=e.localName,o=t;if(e.repeated)o[n]=[];else switch(e.kind){case"oneof":o[n]={case:void 0};break;case"enum":o[n]=0;break;case"map":o[n]={};break;case"scalar":o[n]=Er(e.T,e.L)}}},{syntax:"proto3",json:{makeReadOptions:RC,makeWriteOptions:LC,readMessage(t,e,n,o){if(e==null||Array.isArray(e)||typeof e!="object")throw new Error(`cannot decode message ${t.typeName} from JSON: ${Fn(e)}`);o=o??new t;const r=new Map,s=n.typeRegistry;for(const[a,i]of Object.entries(e)){const l=t.fields.findJsonName(a);if(l){if(l.oneof){if(i===null&&l.kind=="scalar")continue;const d=r.get(l.oneof);if(d!==void 0)throw new Error(`cannot decode message ${t.typeName} from JSON: multiple keys for oneof "${l.oneof.name}" present: "${d}", "${a}"`);r.set(l.oneof,a)}M1(o,i,l,n,t)}else{let d=!1;if(s!=null&&s.findExtension&&a.startsWith("[")&&a.endsWith("]")){const u=s.findExtension(a.substring(1,a.length-1));if(u&&u.extendee.typeName==t.typeName){d=!0;const[h,f]=N1(u);M1(h,i,u.field,n,u),PC(o,u,f(),n)}}if(!d&&!n.ignoreUnknownFields)throw new Error(`cannot decode message ${t.typeName} from JSON: key "${a}" is unknown`)}}return o},writeMessage(t,e){const n=t.getType(),o={};let r;try{for(r of n.fields.byNumber()){if(!E1(r,t)){if(r.req)throw"required field not set";if(!e.emitDefaultValues||!zC(r))continue}const a=O1(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e);a!==void 0&&(o[e.useProtoFieldName?r.name:r.jsonName]=a)}const s=e.typeRegistry;if(s!=null&&s.findExtensionFor)for(const a of n.runtime.bin.listUnknownFields(t)){const i=s.findExtensionFor(n.typeName,a.no);if(i&&j1(t,i)){const l=DC(t,i,e),d=O1(i.field,l,e);d!==void 0&&(o[i.field.jsonName]=d)}}}catch(s){const a=r?`cannot encode field ${n.typeName}.${r.name} to JSON`:`cannot encode message ${n.typeName} to JSON`,i=s instanceof Error?s.message:String(s);throw new Error(a+(i.length>0?`: ${i}`:""))}return o},readScalar:(t,e,n)=>$s(t,e,n??To.BIGINT,!0),writeScalar(t,e,n){if(e!==void 0)return n||S1(t,e)?Ui(t,e):void 0},debug:Fn},bin:{makeReadOptions:BC,makeWriteOptions:UC,listUnknownFields(t){var e;return(e=t[_r])!==null&&e!==void 0?e:[]},discardUnknownFields(t){delete t[_r]},writeUnknownFields(t,e){const n=t[_r];if(n)for(const o of n)e.tag(o.no,o.wireType).raw(o.data)},onUnknownField(t,e,n,o){const r=t;Array.isArray(r[_r])||(r[_r]=[]),r[_r].push({no:e,wireType:n,data:o})},readMessage(t,e,n,o,r){const s=t.getType(),a=r?e.len:e.pos+n;let i,l;for(;e.pos<a&&([i,l]=e.tag(),r!==!0||l!=wt.EndGroup);){const d=s.fields.find(i);if(!d){const u=e.skip(l,i);o.readUnknownFields&&this.onUnknownField(t,i,l,u);continue}R1(t,e,d,l,o)}if(r&&(l!=wt.EndGroup||i!==n))throw new Error("invalid end group tag")},readField:R1,writeMessage(t,e,n){const o=t.getType();for(const r of o.fields.byNumber())if(E1(r,t))L1(r,r.oneof?t[r.oneof.localName].value:t[r.localName],e,n);else if(r.req)throw new Error(`cannot encode field ${o.typeName}.${r.name} to binary: required field not set`);return n.writeUnknownFields&&this.writeUnknownFields(t,e),e},writeField(t,e,n,o){e!==void 0&&L1(t,e,n,o)}},util:Object.assign(Object.assign({},{setEnumType:p1,initPartial(t,e){if(t===void 0)return;const n=e.getType();for(const o of n.fields.byMember()){const r=o.localName,s=e,a=t;if(a[r]!=null)switch(o.kind){case"oneof":const i=a[r].case;if(i===void 0)continue;const l=o.findField(i);let d=a[r].value;l&&l.kind=="message"&&!Qn(d,l.T)?d=new l.T(d):l&&l.kind==="scalar"&&l.T===le.BYTES&&(d=Hs(d)),s[r]={case:i,value:d};break;case"scalar":case"enum":let u=a[r];o.T===le.BYTES&&(u=o.repeated?u.map(Hs):Hs(u)),s[r]=u;break;case"map":switch(o.V.kind){case"scalar":case"enum":if(o.V.T===le.BYTES)for(const[m,x]of Object.entries(a[r]))s[r][m]=Hs(x);else Object.assign(s[r],a[r]);break;case"message":const f=o.V.T;for(const m of Object.keys(a[r])){let x=a[r][m];f.fieldWrapper||(x=new f(x)),s[r][m]=x}}break;case"message":const h=o.T;if(o.repeated)s[r]=a[r].map(f=>Qn(f,h)?f:new h(f));else{const f=a[r];h.fieldWrapper?h.typeName==="google.protobuf.BytesValue"?s[r]=Hs(f):s[r]=f:s[r]=Qn(f,h)?f:new h(f)}}}},equals:(t,e,n)=>e===n||!(!e||!n)&&t.fields.byMember().every(o=>{const r=e[o.localName],s=n[o.localName];if(o.repeated){if(r.length!==s.length)return!1;switch(o.kind){case"message":return r.every((a,i)=>o.T.equals(a,s[i]));case"scalar":return r.every((a,i)=>Mo(o.T,a,s[i]));case"enum":return r.every((a,i)=>Mo(le.INT32,a,s[i]))}throw new Error(`repeated cannot contain ${o.kind}`)}switch(o.kind){case"message":let a=r,i=s;return o.T.fieldWrapper&&(a===void 0||Qn(a)||(a=o.T.fieldWrapper.wrapField(a)),i===void 0||Qn(i)||(i=o.T.fieldWrapper.wrapField(i))),o.T.equals(a,i);case"enum":return Mo(le.INT32,r,s);case"scalar":return Mo(o.T,r,s);case"oneof":if(r.case!==s.case)return!1;const l=o.findField(r.case);if(l===void 0)return!0;switch(l.kind){case"message":return l.T.equals(r.value,s.value);case"enum":return Mo(le.INT32,r.value,s.value);case"scalar":return Mo(l.T,r.value,s.value)}throw new Error(`oneof cannot contain ${l.kind}`);case"map":const d=Object.keys(r).concat(Object.keys(s));switch(o.V.kind){case"message":const u=o.V.T;return d.every(f=>u.equals(r[f],s[f]));case"enum":return d.every(f=>Mo(le.INT32,r[f],s[f]));case"scalar":const h=o.V.T;return d.every(f=>Mo(h,r[f],s[f]))}}}),clone(t){const e=t.getType(),n=new e,o=n;for(const r of e.fields.byMember()){const s=t[r.localName];let a;if(r.repeated)a=s.map(Hi);else if(r.kind=="map"){a=o[r.localName];for(const[i,l]of Object.entries(s))a[i]=Hi(l)}else a=r.kind=="oneof"?r.findField(s.case)?{case:s.case,value:Hi(s.value)}:{case:void 0}:Hi(s);o[r.localName]=a}for(const r of e.runtime.bin.listUnknownFields(t))e.runtime.bin.onUnknownField(o,r.no,r.wireType,r.data);return n}}),{newFieldList:V1,initFields:H1}),makeMessageType(t,e,n){return function(o,r,s,a){var i;const l=(i=a==null?void 0:a.localName)!==null&&i!==void 0?i:r.substring(r.lastIndexOf(".")+1),d={[l]:function(u){o.util.initFields(this),o.util.initPartial(u,this)}}[l];return Object.setPrototypeOf(d.prototype,new Nt),Object.assign(d,{runtime:o,typeName:r,fields:o.util.newFieldList(s),fromBinary:(u,h)=>new d().fromBinary(u,h),fromJson:(u,h)=>new d().fromJson(u,h),fromJsonString:(u,h)=>new d().fromJsonString(u,h),equals:(u,h)=>o.util.equals(d,u,h)}),d}(this,t,e,n)},makeEnum:_C,makeEnumType:g1,getEnumType:EC,makeExtension(t,e,n){return function(o,r,s,a){let i;return{typeName:r,extendee:s,get field(){if(!i){const l=typeof a=="function"?a():a;l.name=r.split(".").pop(),l.jsonName=`[${r}]`,i=o.util.newFieldList([l]).list()[0]}return i},runtime:o}}(this,t,e,n)}});var V1,H1,cn,Bd,Wi,Ws,qi,qs,Oo;(function(t){t[t.Unary=0]="Unary",t[t.ServerStreaming=1]="ServerStreaming",t[t.ClientStreaming=2]="ClientStreaming",t[t.BiDiStreaming=3]="BiDiStreaming"})(cn||(cn={})),function(t){t[t.NoSideEffects=1]="NoSideEffects",t[t.Idempotent=2]="Idempotent"}(Bd||(Bd={})),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.JUPYTER_FORMAT=77]="JUPYTER_FORMAT"}(Wi||(Wi={})),xe.util.setEnumType(Wi,"exa.codeium_common_pb.ExperimentKey",[{no:0,name:"UNSPECIFIED"},{no:77,name:"JUPYTER_FORMAT"}]),function(t){t[t.CODEIUM=0]="CODEIUM"}(Ws||(Ws={})),xe.util.setEnumType(Ws,"exa.codeium_common_pb.AuthSource",[{no:0,name:"AUTH_SOURCE_CODEIUM"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.ENABLE_CODEIUM=1]="ENABLE_CODEIUM",t[t.DISABLE_CODEIUM=2]="DISABLE_CODEIUM",t[t.SHOW_PREVIOUS_COMPLETION=3]="SHOW_PREVIOUS_COMPLETION",t[t.SHOW_NEXT_COMPLETION=4]="SHOW_NEXT_COMPLETION"}(qi||(qi={})),xe.util.setEnumType(qi,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.TYPING_AS_SUGGESTED=1]="TYPING_AS_SUGGESTED",t[t.CACHE=2]="CACHE",t[t.NETWORK=3]="NETWORK"}(qs||(qs={})),xe.util.setEnumType(qs,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.C=1]="C",t[t.CLOJURE=2]="CLOJURE",t[t.COFFEESCRIPT=3]="COFFEESCRIPT",t[t.CPP=4]="CPP",t[t.CSHARP=5]="CSHARP",t[t.CSS=6]="CSS",t[t.CUDACPP=7]="CUDACPP",t[t.DOCKERFILE=8]="DOCKERFILE",t[t.GO=9]="GO",t[t.GROOVY=10]="GROOVY",t[t.HANDLEBARS=11]="HANDLEBARS",t[t.HASKELL=12]="HASKELL",t[t.HCL=13]="HCL",t[t.HTML=14]="HTML",t[t.INI=15]="INI",t[t.JAVA=16]="JAVA",t[t.JAVASCRIPT=17]="JAVASCRIPT",t[t.JSON=18]="JSON",t[t.JULIA=19]="JULIA",t[t.KOTLIN=20]="KOTLIN",t[t.LATEX=21]="LATEX",t[t.LESS=22]="LESS",t[t.LUA=23]="LUA",t[t.MAKEFILE=24]="MAKEFILE",t[t.MARKDOWN=25]="MARKDOWN",t[t.OBJECTIVEC=26]="OBJECTIVEC",t[t.OBJECTIVECPP=27]="OBJECTIVECPP",t[t.PERL=28]="PERL",t[t.PHP=29]="PHP",t[t.PLAINTEXT=30]="PLAINTEXT",t[t.PROTOBUF=31]="PROTOBUF",t[t.PBTXT=32]="PBTXT",t[t.PYTHON=33]="PYTHON",t[t.R=34]="R",t[t.RUBY=35]="RUBY",t[t.RUST=36]="RUST",t[t.SASS=37]="SASS",t[t.SCALA=38]="SCALA",t[t.SCSS=39]="SCSS",t[t.SHELL=40]="SHELL",t[t.SQL=41]="SQL",t[t.STARLARK=42]="STARLARK",t[t.SWIFT=43]="SWIFT",t[t.TSX=44]="TSX",t[t.TYPESCRIPT=45]="TYPESCRIPT",t[t.VISUALBASIC=46]="VISUALBASIC",t[t.VUE=47]="VUE",t[t.XML=48]="XML",t[t.XSL=49]="XSL",t[t.YAML=50]="YAML",t[t.SVELTE=51]="SVELTE",t[t.TOML=52]="TOML",t[t.DART=53]="DART",t[t.RST=54]="RST",t[t.OCAML=55]="OCAML",t[t.CMAKE=56]="CMAKE",t[t.PASCAL=57]="PASCAL",t[t.ELIXIR=58]="ELIXIR",t[t.FSHARP=59]="FSHARP",t[t.LISP=60]="LISP",t[t.MATLAB=61]="MATLAB",t[t.POWERSHELL=62]="POWERSHELL",t[t.SOLIDITY=63]="SOLIDITY",t[t.ADA=64]="ADA",t[t.OCAML_INTERFACE=65]="OCAML_INTERFACE"}(Oo||(Oo={})),xe.util.setEnumType(Oo,"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 to=class to extends Nt{constructor(n){super();Z(this,"completionId","");Z(this,"text","");Z(this,"prefix","");Z(this,"stop","");Z(this,"score",0);Z(this,"tokens",[]);Z(this,"decodedTokens",[]);Z(this,"probabilities",[]);Z(this,"adjustedProbabilities",[]);Z(this,"generatedLength",ft.zero);xe.util.initPartial(n,this)}static fromBinary(n,o){return new to().fromBinary(n,o)}static fromJson(n,o){return new to().fromJson(n,o)}static fromJsonString(n,o){return new to().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(to,n,o)}};Z(to,"runtime",xe),Z(to,"typeName","exa.codeium_common_pb.Completion"),Z(to,"fields",xe.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 Ud=to;const no=class no extends Nt{constructor(n){super();Z(this,"ideName","");Z(this,"ideVersion","");Z(this,"extensionName","");Z(this,"extensionVersion","");Z(this,"apiKey","");Z(this,"locale","");Z(this,"sessionId","");Z(this,"requestId",ft.zero);Z(this,"userAgent","");Z(this,"url","");Z(this,"authSource",Ws.CODEIUM);xe.util.initPartial(n,this)}static fromBinary(n,o){return new no().fromBinary(n,o)}static fromJson(n,o){return new no().fromJson(n,o)}static fromJsonString(n,o){return new no().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(no,n,o)}};Z(no,"runtime",xe),Z(no,"typeName","exa.codeium_common_pb.Metadata"),Z(no,"fields",xe.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:xe.getEnumType(Ws)}]));let Gi=no;const oo=class oo extends Nt{constructor(n){super();Z(this,"tabSize",ft.zero);Z(this,"insertSpaces",!1);xe.util.initPartial(n,this)}static fromBinary(n,o){return new oo().fromBinary(n,o)}static fromJson(n,o){return new oo().fromJson(n,o)}static fromJsonString(n,o){return new oo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(oo,n,o)}};Z(oo,"runtime",xe),Z(oo,"typeName","exa.codeium_common_pb.EditorOptions"),Z(oo,"fields",xe.util.newFieldList(()=>[{no:1,name:"tab_size",kind:"scalar",T:4},{no:2,name:"insert_spaces",kind:"scalar",T:8}]));let $d=oo;xe.util.newFieldList(()=>[{no:1,name:"event_type",kind:"enum",T:xe.getEnumType(qi)},{no:2,name:"event_json",kind:"scalar",T:9},{no:3,name:"timestamp_unix_ms",kind:"scalar",T:3}]);class JC extends gs{constructor(n,o){super();Z(this,"index");Z(this,"total");this.index=n,this.total=o}toDOM(){const n=document.createElement("span");n.setAttribute("aria-hidden","true"),n.className="cm-codeium-cycle";const o=n.appendChild(document.createElement("span"));o.className="cm-codeium-cycle-explanation",o.innerText=`${this.index+1}/${this.total}`;const r=n.appendChild(document.createElement("button"));return r.className="cm-codeium-cycle-key",r.innerText="\u2192 (Ctrl ])",r.dataset.action="codeium-cycle",n}ignoreEvent(){return!1}}const Yi=xr.define({combine:t=>pc(t,{language:Oo.TYPESCRIPT,timeout:150,widgetClass:JC,alwaysOn:!0},{})}),W1=xr.define({combine:t=>pc(t,{override:()=>[]},{})}),ZC=tt.mark({class:"cm-ghostText"}),sr=xn.define({create:t=>null,update(t,e){var o;const n=e.state.facet(Yi);for(const r of e.effects){if(r.is(Md)){const{changeSpecs:s,index:a}=r.value,i=s[a].map(d=>ZC.range(d.absoluteStartPos,d.absoluteEndPos)),l=(o=i.at(-1))==null?void 0:o.to;return{index:a,decorations:tt.set([...i,...l!==void 0&&s.length>1&&n.widgetClass?[tt.widget({widget:new n.widgetClass(a,s.length),side:1}).range(l)]:[]]),changeSpecs:s,reverseChangeSet:r.value.reverseChangeSet}}if(r.is(Od)||r.is(Dd))return null}return t&&{...t,decorations:t.decorations.map(e.changes),reverseChangeSet:t.reverseChangeSet.map(e.changes)}},provide:t=>Ve.decorations.from(t,e=>(e==null?void 0:e.decorations)||tt.none)}),Ir=mm.define(),Ki=mm.define();var ut;function Vd(t){const e=ut[t];return typeof e!="string"?t.toString():e[0].toLowerCase()+e.substring(1).replace(/[A-Z]/g,n=>"_"+n.toLowerCase())}let Xi;(function(t){t[t.Canceled=1]="Canceled",t[t.Unknown=2]="Unknown",t[t.InvalidArgument=3]="InvalidArgument",t[t.DeadlineExceeded=4]="DeadlineExceeded",t[t.NotFound=5]="NotFound",t[t.AlreadyExists=6]="AlreadyExists",t[t.PermissionDenied=7]="PermissionDenied",t[t.ResourceExhausted=8]="ResourceExhausted",t[t.FailedPrecondition=9]="FailedPrecondition",t[t.Aborted=10]="Aborted",t[t.OutOfRange=11]="OutOfRange",t[t.Unimplemented=12]="Unimplemented",t[t.Internal=13]="Internal",t[t.Unavailable=14]="Unavailable",t[t.DataLoss=15]="DataLoss",t[t.Unauthenticated=16]="Unauthenticated"})(ut||(ut={}));class jt extends Error{constructor(e,n=ut.Unknown,o,r,s){super(function(a,i){return a.length?`[${Vd(i)}] ${a}`:`[${Vd(i)}]`}(e,n)),this.name="ConnectError",Object.setPrototypeOf(this,new.target.prototype),this.rawMessage=e,this.code=n,this.metadata=new Headers(o??{}),this.details=r??[],this.cause=s}static from(e,n=ut.Unknown){return e instanceof jt?e:e instanceof Error?e.name=="AbortError"?new jt(e.message,ut.Canceled):new jt(e.message,n,void 0,void 0,e):new jt(String(e),n,void 0,void 0,e)}static[Symbol.hasInstance](e){return e instanceof Error&&(Object.getPrototypeOf(e)===jt.prototype||e.name==="ConnectError"&&"code"in e&&typeof e.code=="number"&&"metadata"in e&&"details"in e&&Array.isArray(e.details)&&"rawMessage"in e&&typeof e.rawMessage=="string"&&"cause"in e)}findDetails(e){const n="typeName"in e?{findMessage:r=>r===e.typeName?e:void 0}:e,o=[];for(const r of this.details){if("getType"in r){n.findMessage(r.getType().typeName)&&o.push(r);continue}const s=n.findMessage(r.type);if(s)try{o.push(s.fromBinary(r.value))}catch{}}return o}}var QC=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,i){(function(l,d,u,h){Promise.resolve(h).then(function(f){l({value:f,done:u})},d)})(a,i,(s=t[r](s)).done,s.value)})}}},Gs=function(t){return this instanceof Gs?(this.v=t,this):new Gs(t)},eE=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(f){return Promise.resolve(f).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,f){r[h]&&(o[h]=function(m){return new Promise(function(x,g){s.push([h,m,x,g])>1||i(h,m)})},f&&(o[h]=f(o[h])))}function i(h,f){try{(m=r[h](f)).value instanceof Gs?Promise.resolve(m.value.v).then(l,d):u(s[0][2],m)}catch(x){u(s[0][3],x)}var m}function l(h){i("next",h)}function d(h){i("throw",h)}function u(h,f){h(f),s.shift(),s.length&&i(s[0][0],s[0][1])}},tE=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:Gs(t[r](a)),done:!1}:s?s(a):a}:s}},q1=function(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e,n=t[Symbol.asyncIterator];return n?n.call(t):(t=typeof __values=="function"?__values(t):t[Symbol.iterator](),e={},o("next"),o("throw"),o("return"),e[Symbol.asyncIterator]=function(){return this},e);function o(r){e[r]=t[r]&&function(s){return new Promise(function(a,i){(function(l,d,u,h){Promise.resolve(h).then(function(f){l({value:f,done:u})},d)})(a,i,(s=t[r](s)).done,s.value)})}}},Ar=function(t){return this instanceof Ar?(this.v=t,this):new Ar(t)},nE=function(t){var e,n;return e={},o("next"),o("throw",function(r){throw r}),o("return"),e[Symbol.iterator]=function(){return this},e;function o(r,s){e[r]=t[r]?function(a){return(n=!n)?{value:Ar(t[r](a)),done:!1}:s?s(a):a}:s}},oE=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(f){return Promise.resolve(f).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,f){r[h]&&(o[h]=function(m){return new Promise(function(x,g){s.push([h,m,x,g])>1||i(h,m)})},f&&(o[h]=f(o[h])))}function i(h,f){try{(m=r[h](f)).value instanceof Ar?Promise.resolve(m.value.v).then(l,d):u(s[0][2],m)}catch(x){u(s[0][3],x)}var m}function l(h){i("next",h)}function d(h){i("throw",h)}function u(h,f){h(f),s.shift(),s.length&&i(s[0][0],s[0][1])}};function rE(t,e){return function(n,o){const r={};for(const[s,a]of Object.entries(n.methods)){const i=o(Object.assign(Object.assign({},a),{localName:s,service:n}));i!=null&&(r[s]=i)}return r}(t,n=>{switch(n.kind){case cn.Unary:return function(o,r,s){return async function(a,i){var l,d;const u=await o.unary(r,s,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,a,i==null?void 0:i.contextValues);return(l=i==null?void 0:i.onHeader)===null||l===void 0||l.call(i,u.header),(d=i==null?void 0:i.onTrailer)===null||d===void 0||d.call(i,u.trailer),u.message}}(e,t,n);case cn.ServerStreaming:return function(o,r,s){return function(a,i){return G1(o.stream(r,s,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,function(l){return eE(this,arguments,function*(){yield Gs(yield*tE(QC(l)))})}([a]),i==null?void 0:i.contextValues),i)}}(e,t,n);case cn.ClientStreaming:return function(o,r,s){return async function(a,i){var l,d,u,h,f,m;const x=await o.stream(r,s,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,a,i==null?void 0:i.contextValues);let g;(f=i==null?void 0:i.onHeader)===null||f===void 0||f.call(i,x.header);let p=0;try{for(var b,y=!0,v=q1(x.message);!(l=(b=await v.next()).done);y=!0)h=b.value,y=!1,g=h,p++}catch(w){d={error:w}}finally{try{y||l||!(u=v.return)||await u.call(v)}finally{if(d)throw d.error}}if(!g)throw new jt("protocol error: missing response message",ut.Unimplemented);if(p>1)throw new jt("protocol error: received extra messages for client streaming method",ut.Unimplemented);return(m=i==null?void 0:i.onTrailer)===null||m===void 0||m.call(i,x.trailer),g}}(e,t,n);case cn.BiDiStreaming:return function(o,r,s){return function(a,i){return G1(o.stream(r,s,i==null?void 0:i.signal,i==null?void 0:i.timeoutMs,i==null?void 0:i.headers,a,i==null?void 0:i.contextValues),i)}}(e,t,n);default:return null}})}function G1(t,e){const n=function(){return oE(this,arguments,function*(){var o,r;const s=yield Ar(t);(o=e==null?void 0:e.onHeader)===null||o===void 0||o.call(e,s.header),yield Ar(yield*nE(q1(s.message))),(r=e==null?void 0:e.onTrailer)===null||r===void 0||r.call(e,s.trailer)})}()[Symbol.asyncIterator]();return{[Symbol.asyncIterator]:()=>({next:()=>n.next()})}}function Y1(t){if(!t.aborted)return;if(t.reason!==void 0)return t.reason;const e=new Error("This operation was aborted");return e.name="AbortError",e}function K1(){return{get(t){return t.id in this?this[t.id]:t.defaultValue},set(t,e){return this[t.id]=e,this},delete(t){return delete this[t.id],this}}}function X1(t,e,n){const o=typeof e=="string"?e:e.typeName,r=typeof n=="string"?n:n.name;return t.toString().replace(/\/?$/,`/${o}/${r}`)}function J1(t,e){return e instanceof t?e:new t(e)}function sE(t,e){function n(o){return o.done===!0?o:{done:o.done,value:J1(t,o.value)}}return{[Symbol.asyncIterator](){const o=e[Symbol.asyncIterator](),r={next:()=>o.next().then(n)};return o.throw!==void 0&&(r.throw=s=>o.throw(s).then(n)),o.return!==void 0&&(r.return=s=>o.return(s).then(n)),r}}}function Z1(t,e){var n;return(n=e==null?void 0:e.concat().reverse().reduce((o,r)=>r(o),t))!==null&&n!==void 0?n:t}function Q1(t){var e;const n=Object.assign({},t);return(e=n.ignoreUnknownFields)!==null&&e!==void 0||(n.ignoreUnknownFields=!0),n}function e0(t,e,n,o){const r=e?t0(t.I,o):n0(t.I,n);return{parse:(e?t0(t.O,o):n0(t.O,n)).parse,serialize:r.serialize}}function t0(t,e){return{parse(n){try{return t.fromBinary(n,e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new jt(`parse binary: ${r}`,ut.Internal)}},serialize(n){try{return n.toBinary(e)}catch(o){const r=o instanceof Error?o.message:String(o);throw new jt(`serialize binary: ${r}`,ut.Internal)}}}}function n0(t,e){var n,o;const r=(n=e==null?void 0:e.textEncoder)!==null&&n!==void 0?n:new TextEncoder,s=(o=e==null?void 0:e.textDecoder)!==null&&o!==void 0?o:new TextDecoder,a=Q1(e);return{parse(i){try{const l=s.decode(i);return t.fromJsonString(l,a)}catch(l){throw jt.from(l,ut.InvalidArgument)}},serialize(i){try{const l=i.toJsonString(a);return r.encode(l)}catch(l){throw jt.from(l,ut.Internal)}}}}const aE=/^application\/(connect\+)?(?:(json)(?:; ?charset=utf-?8)?|(proto))$/i;function o0(t,e,n){var o;if(e&&new Headers(e).forEach((i,l)=>n.metadata.append(l,i)),typeof t!="object"||t==null||Array.isArray(t))throw n;let r=n.code;"code"in t&&typeof t.code=="string"&&(r=(o=function(i){if(!Xi){Xi={};for(const l of Object.values(ut))typeof l!="string"&&(Xi[Vd(l)]=l)}return Xi[i]}(t.code))!==null&&o!==void 0?o:r);const s=t.message;if(s!=null&&typeof s!="string")throw n;const a=new jt(s??"",r,e);if("details"in t&&Array.isArray(t.details))for(const i of t.details){if(i===null||typeof i!="object"||Array.isArray(i)||typeof i.type!="string"||typeof i.value!="string")throw n;try{a.details.push({type:i.type,value:Fi.dec(i.value),debug:i.debug})}catch{throw n}}return a}function iE(t){const e=new jt("invalid end stream",ut.Unknown);let n;try{n=JSON.parse(typeof t=="string"?t:new TextDecoder().decode(t))}catch{throw e}if(typeof n!="object"||n==null||Array.isArray(n))throw e;const o=new Headers;if("metadata"in n){if(typeof n.metadata!="object"||n.metadata==null||Array.isArray(n.metadata))throw e;for(const[r,s]of Object.entries(n.metadata)){if(!Array.isArray(s)||s.some(a=>typeof a!="string"))throw e;for(const a of s)o.append(r,a)}}return{metadata:o,error:"error"in n&&n.error!=null?o0(n.error,o,e):void 0}}const Ji="Content-Type",lE="Content-Length",r0="Content-Encoding",cE="Accept-Encoding",s0="Connect-Protocol-Version";function a0(t){const e=new Headers,n=new Headers;return t.forEach((o,r)=>{r.toLowerCase().startsWith("trailer-")?n.append(r.substring(8),o):e.append(r,o)}),[e,n]}function i0(t,e,n,o,r){const s=new Headers(o??{});return n!==void 0&&s.set("Connect-Timeout-Ms",`${n}`),s.set(Ji,t==cn.Unary?e?"application/proto":"application/json":e?"application/connect+proto":"application/connect+json"),s.set(s0,"1"),s}function l0(t,e,n,o){const r=o.get(Ji),s=function(l){const d=l==null?void 0:l.match(aE);if(d)return{stream:!!d[1],binary:!!d[3]}}(r);if(n!==200){const l=new jt(`HTTP ${n}`,function(d){switch(d){case 400:return ut.Internal;case 401:return ut.Unauthenticated;case 403:return ut.PermissionDenied;case 404:return ut.Unimplemented;case 429:case 502:case 503:case 504:return ut.Unavailable;default:return ut.Unknown}}(n),o);if(t==cn.Unary&&s&&!s.binary)return{isUnaryError:!0,unaryError:l};throw l}const a=e,i=t!==cn.Unary;if((s==null?void 0:s.binary)!==a||s.stream!==i)throw new jt(`unsupported content type ${r}`,s===void 0?ut.Unknown:ut.Internal,o);return{isUnaryError:!1}}const dE="application/";function uE(t,e,n){let o="?connect=v1";const r=t.header.get(Ji);(r==null?void 0:r.indexOf(dE))===0&&(o+="&encoding="+encodeURIComponent(r.slice(12)));const s=t.header.get(r0);s!==null&&s!=="identity"&&(o+="&compression="+encodeURIComponent(s),n=!0),n&&(o+="&base64=1"),o+="&message="+function(l,d){return d?Fi.enc(l).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,""):encodeURIComponent(new TextDecoder().decode(l))}(e,n);const a=t.url+o,i=new Headers(t.header);return[s0,Ji,lE,r0,cE].forEach(l=>i.delete(l)),Object.assign(Object.assign({},t),{init:Object.assign(Object.assign({},t.init),{method:"GET"}),url:a,header:i})}function c0(t){const{signal:e,cleanup:n}=function(r){const s=new AbortController,a=()=>{s.abort(new jt("the operation timed out",ut.DeadlineExceeded))};let i;return r!==void 0&&(r<=0?a():i=setTimeout(a,r)),{signal:s.signal,cleanup:()=>clearTimeout(i)}}(t.timeoutMs),o=function(...r){const s=new AbortController,a=r.filter(l=>l!==void 0).concat(s.signal);for(const l of a){if(l.aborted){i.apply(l);break}l.addEventListener("abort",i)}function i(){s.signal.aborted||s.abort(Y1(this));for(const l of a)l.removeEventListener("abort",i)}return s}(t.signal,e);return[o.signal,function(r){const s=jt.from(e.aborted?Y1(e):r);return o.abort(s),n(),Promise.reject(s)},function(){n(),o.abort()}]}var Ys,Hd,Ks;(function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INACTIVE=1]="INACTIVE",t[t.PROCESSING=2]="PROCESSING",t[t.SUCCESS=3]="SUCCESS",t[t.WARNING=4]="WARNING",t[t.ERROR=5]="ERROR"})(Ys||(Ys={})),xe.util.setEnumType(Ys,"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"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.SINGLE=1]="SINGLE",t[t.MULTI=2]="MULTI"}(Hd||(Hd={})),xe.util.setEnumType(Hd,"exa.language_server_pb.LineType",[{no:0,name:"LINE_TYPE_UNSPECIFIED"},{no:1,name:"LINE_TYPE_SINGLE"},{no:2,name:"LINE_TYPE_MULTI"}]),function(t){t[t.UNSPECIFIED=0]="UNSPECIFIED",t[t.INLINE=1]="INLINE",t[t.BLOCK=2]="BLOCK",t[t.INLINE_MASK=3]="INLINE_MASK"}(Ks||(Ks={})),xe.util.setEnumType(Ks,"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 ro=class ro extends Nt{constructor(n){super();Z(this,"threshold",0);xe.util.initPartial(n,this)}static fromBinary(n,o){return new ro().fromBinary(n,o)}static fromJson(n,o){return new ro().fromJson(n,o)}static fromJsonString(n,o){return new ro().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(ro,n,o)}};Z(ro,"runtime",xe),Z(ro,"typeName","exa.language_server_pb.MultilineConfig"),Z(ro,"fields",xe.util.newFieldList(()=>[{no:1,name:"threshold",kind:"scalar",T:2}]));let Wd=ro;const so=class so extends Nt{constructor(n){super();Z(this,"metadata");Z(this,"document");Z(this,"editorOptions");Z(this,"otherDocuments",[]);Z(this,"experimentConfig");Z(this,"modelName","");Z(this,"multilineConfig");xe.util.initPartial(n,this)}static fromBinary(n,o){return new so().fromBinary(n,o)}static fromJson(n,o){return new so().fromJson(n,o)}static fromJsonString(n,o){return new so().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(so,n,o)}};Z(so,"runtime",xe),Z(so,"typeName","exa.language_server_pb.GetCompletionsRequest"),Z(so,"fields",xe.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Gi},{no:2,name:"document",kind:"message",T:Zi},{no:3,name:"editor_options",kind:"message",T:$d},{no:5,name:"other_documents",kind:"message",T:Zi,repeated:!0},{no:7,name:"experiment_config",kind:"message",T:Zd},{no:10,name:"model_name",kind:"scalar",T:9},{no:13,name:"multiline_config",kind:"message",T:Wd}]));let qd=so;const ao=class ao extends Nt{constructor(n){super();Z(this,"state");Z(this,"completionItems",[]);xe.util.initPartial(n,this)}static fromBinary(n,o){return new ao().fromBinary(n,o)}static fromJson(n,o){return new ao().fromJson(n,o)}static fromJsonString(n,o){return new ao().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(ao,n,o)}};Z(ao,"runtime",xe),Z(ao,"typeName","exa.language_server_pb.GetCompletionsResponse"),Z(ao,"fields",xe.util.newFieldList(()=>[{no:1,name:"state",kind:"message",T:Qd},{no:2,name:"completion_items",kind:"message",T:ou,repeated:!0}]));let Gd=ao;const io=class io extends Nt{constructor(n){super();Z(this,"metadata");Z(this,"completionId","");xe.util.initPartial(n,this)}static fromBinary(n,o){return new io().fromBinary(n,o)}static fromJson(n,o){return new io().fromJson(n,o)}static fromJsonString(n,o){return new io().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(io,n,o)}};Z(io,"runtime",xe),Z(io,"typeName","exa.language_server_pb.AcceptCompletionRequest"),Z(io,"fields",xe.util.newFieldList(()=>[{no:1,name:"metadata",kind:"message",T:Gi},{no:2,name:"completion_id",kind:"scalar",T:9}]));let Yd=io;const lo=class lo extends Nt{constructor(e){super(),xe.util.initPartial(e,this)}static fromBinary(e,n){return new lo().fromBinary(e,n)}static fromJson(e,n){return new lo().fromJson(e,n)}static fromJsonString(e,n){return new lo().fromJsonString(e,n)}static equals(e,n){return xe.util.equals(lo,e,n)}};Z(lo,"runtime",xe),Z(lo,"typeName","exa.language_server_pb.AcceptCompletionResponse"),Z(lo,"fields",xe.util.newFieldList(()=>[]));let Kd=lo;const co=class co extends Nt{constructor(e){super(),xe.util.initPartial(e,this)}static fromBinary(e,n){return new co().fromBinary(e,n)}static fromJson(e,n){return new co().fromJson(e,n)}static fromJsonString(e,n){return new co().fromJsonString(e,n)}static equals(e,n){return xe.util.equals(co,e,n)}};Z(co,"runtime",xe),Z(co,"typeName","exa.language_server_pb.GetAuthTokenRequest"),Z(co,"fields",xe.util.newFieldList(()=>[]));let Xd=co;const uo=class uo extends Nt{constructor(n){super();Z(this,"authToken","");Z(this,"uuid","");xe.util.initPartial(n,this)}static fromBinary(n,o){return new uo().fromBinary(n,o)}static fromJson(n,o){return new uo().fromJson(n,o)}static fromJsonString(n,o){return new uo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(uo,n,o)}};Z(uo,"runtime",xe),Z(uo,"typeName","exa.language_server_pb.GetAuthTokenResponse"),Z(uo,"fields",xe.util.newFieldList(()=>[{no:1,name:"auth_token",kind:"scalar",T:9},{no:2,name:"uuid",kind:"scalar",T:9}]));let Jd=uo;const ho=class ho extends Nt{constructor(n){super();Z(this,"row",ft.zero);Z(this,"col",ft.zero);xe.util.initPartial(n,this)}static fromBinary(n,o){return new ho().fromBinary(n,o)}static fromJson(n,o){return new ho().fromJson(n,o)}static fromJsonString(n,o){return new ho().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(ho,n,o)}};Z(ho,"runtime",xe),Z(ho,"typeName","exa.language_server_pb.DocumentPosition"),Z(ho,"fields",xe.util.newFieldList(()=>[{no:1,name:"row",kind:"scalar",T:4},{no:2,name:"col",kind:"scalar",T:4}]));let Xs=ho;const fo=class fo extends Nt{constructor(n){super();Z(this,"absolutePath","");Z(this,"relativePath","");Z(this,"text","");Z(this,"editorLanguage","");Z(this,"language",Oo.UNSPECIFIED);Z(this,"cursorOffset",ft.zero);Z(this,"cursorPosition");Z(this,"lineEnding","");xe.util.initPartial(n,this)}static fromBinary(n,o){return new fo().fromBinary(n,o)}static fromJson(n,o){return new fo().fromJson(n,o)}static fromJsonString(n,o){return new fo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(fo,n,o)}};Z(fo,"runtime",xe),Z(fo,"typeName","exa.language_server_pb.Document"),Z(fo,"fields",xe.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:xe.getEnumType(Oo)},{no:6,name:"cursor_offset",kind:"scalar",T:4},{no:8,name:"cursor_position",kind:"message",T:Xs},{no:7,name:"line_ending",kind:"scalar",T:9}]));let Zi=fo;const mo=class mo extends Nt{constructor(n){super();Z(this,"forceEnableExperiments",[]);xe.util.initPartial(n,this)}static fromBinary(n,o){return new mo().fromBinary(n,o)}static fromJson(n,o){return new mo().fromJson(n,o)}static fromJsonString(n,o){return new mo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(mo,n,o)}};Z(mo,"runtime",xe),Z(mo,"typeName","exa.language_server_pb.ExperimentConfig"),Z(mo,"fields",xe.util.newFieldList(()=>[{no:1,name:"force_enable_experiments",kind:"enum",T:xe.getEnumType(Wi),repeated:!0}]));let Zd=mo;const po=class po extends Nt{constructor(n){super();Z(this,"state",Ys.UNSPECIFIED);Z(this,"message","");xe.util.initPartial(n,this)}static fromBinary(n,o){return new po().fromBinary(n,o)}static fromJson(n,o){return new po().fromJson(n,o)}static fromJsonString(n,o){return new po().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(po,n,o)}};Z(po,"runtime",xe),Z(po,"typeName","exa.language_server_pb.State"),Z(po,"fields",xe.util.newFieldList(()=>[{no:1,name:"state",kind:"enum",T:xe.getEnumType(Ys)},{no:2,name:"message",kind:"scalar",T:9}]));let Qd=po;const go=class go extends Nt{constructor(n){super();Z(this,"startOffset",ft.zero);Z(this,"endOffset",ft.zero);Z(this,"startPosition");Z(this,"endPosition");xe.util.initPartial(n,this)}static fromBinary(n,o){return new go().fromBinary(n,o)}static fromJson(n,o){return new go().fromJson(n,o)}static fromJsonString(n,o){return new go().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(go,n,o)}};Z(go,"runtime",xe),Z(go,"typeName","exa.language_server_pb.Range"),Z(go,"fields",xe.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:Xs},{no:4,name:"end_position",kind:"message",T:Xs}]));let eu=go;const xo=class xo extends Nt{constructor(n){super();Z(this,"text","");Z(this,"deltaCursorOffset",ft.zero);xe.util.initPartial(n,this)}static fromBinary(n,o){return new xo().fromBinary(n,o)}static fromJson(n,o){return new xo().fromJson(n,o)}static fromJsonString(n,o){return new xo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(xo,n,o)}};Z(xo,"runtime",xe),Z(xo,"typeName","exa.language_server_pb.Suffix"),Z(xo,"fields",xe.util.newFieldList(()=>[{no:1,name:"text",kind:"scalar",T:9},{no:2,name:"delta_cursor_offset",kind:"scalar",T:3}]));let tu=xo;const bo=class bo extends Nt{constructor(n){super();Z(this,"text","");Z(this,"offset",ft.zero);Z(this,"type",Ks.UNSPECIFIED);Z(this,"prefix","");Z(this,"line",ft.zero);xe.util.initPartial(n,this)}static fromBinary(n,o){return new bo().fromBinary(n,o)}static fromJson(n,o){return new bo().fromJson(n,o)}static fromJsonString(n,o){return new bo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(bo,n,o)}};Z(bo,"runtime",xe),Z(bo,"typeName","exa.language_server_pb.CompletionPart"),Z(bo,"fields",xe.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:xe.getEnumType(Ks)},{no:4,name:"prefix",kind:"scalar",T:9},{no:5,name:"line",kind:"scalar",T:4}]));let nu=bo;const yo=class yo extends Nt{constructor(n){super();Z(this,"completion");Z(this,"suffix");Z(this,"range");Z(this,"source",qs.UNSPECIFIED);Z(this,"completionParts",[]);xe.util.initPartial(n,this)}static fromBinary(n,o){return new yo().fromBinary(n,o)}static fromJson(n,o){return new yo().fromJson(n,o)}static fromJsonString(n,o){return new yo().fromJsonString(n,o)}static equals(n,o){return xe.util.equals(yo,n,o)}};Z(yo,"runtime",xe),Z(yo,"typeName","exa.language_server_pb.CompletionItem"),Z(yo,"fields",xe.util.newFieldList(()=>[{no:1,name:"completion",kind:"message",T:Ud},{no:5,name:"suffix",kind:"message",T:tu},{no:2,name:"range",kind:"message",T:eu},{no:3,name:"source",kind:"enum",T:xe.getEnumType(qs)},{no:8,name:"completion_parts",kind:"message",T:nu,repeated:!0}]));let ou=yo;const hE={typeName:"exa.language_server_pb.LanguageServerService",methods:{getCompletions:{name:"GetCompletions",I:qd,O:Gd,kind:cn.Unary},acceptCompletion:{name:"AcceptCompletion",I:Yd,O:Kd,kind:cn.Unary},getAuthToken:{name:"GetAuthToken",I:Xd,O:Jd,kind:cn.Unary}}};var Js=function(t){return this instanceof Js?(this.v=t,this):new Js(t)},fE=function(t,e,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var o,r=n.apply(t,e||[]),s=[];return o={},a("next"),a("throw"),a("return",function(h){return function(f){return Promise.resolve(f).then(h,d)}}),o[Symbol.asyncIterator]=function(){return this},o;function a(h,f){r[h]&&(o[h]=function(m){return new Promise(function(x,g){s.push([h,m,x,g])>1||i(h,m)})},f&&(o[h]=f(o[h])))}function i(h,f){try{(m=r[h](f)).value instanceof Js?Promise.resolve(m.value.v).then(l,d):u(s[0][2],m)}catch(x){u(s[0][3],x)}var m}function l(h){i("next",h)}function d(h){i("throw",h)}function u(h,f){h(f),s.shift(),s.length&&i(s[0][0],s[0][1])}};const mE=function(t){var e;(function(){try{new Headers}catch{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=(e=t.useBinaryFormat)!==null&&e!==void 0&&e;return{async unary(o,r,s,a,i,l,d){var u;const{serialize:h,parse:f}=e0(r,n,t.jsonOptions,t.binaryOptions);return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await function(m){const x=Z1(m.next,m.interceptors),[g,p,b]=c0(m);return x(Object.assign(Object.assign({},m.req),{message:J1(m.req.method.I,m.req.message),signal:g})).then(y=>(b(),y),p)}({interceptors:t.interceptors,signal:s,timeoutMs:a,req:{stream:!1,service:o,method:r,url:X1(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:i0(r.kind,n,a,i),contextValues:d??K1(),message:l},next:async m=>{var x;let g=null;t.useHttpGet===!0&&r.idempotency===Bd.NoSideEffects?m=uE(m,h(m.message),n):g=h(m.message);const p=(x=t.fetch)!==null&&x!==void 0?x:globalThis.fetch,b=await p(m.url,Object.assign(Object.assign({},m.init),{headers:m.header,signal:m.signal,body:g})),{isUnaryError:y,unaryError:v}=l0(r.kind,n,b.status,b.headers);if(y)throw o0(await b.json(),function(...N){const j=new Headers;for(const C of N)C.forEach((_,A)=>{j.append(A,_)});return j}(...a0(b.headers)),v);const[w,S]=a0(b.headers);return{stream:!1,service:o,method:r,header:w,message:n?f(new Uint8Array(await b.arrayBuffer())):r.O.fromJson(await b.json(),Q1(t.jsonOptions)),trailer:S}}})},async stream(o,r,s,a,i,l,d){var u;const{serialize:h,parse:f}=e0(r,n,t.jsonOptions,t.binaryOptions);function m(g,p,b,y){return fE(this,arguments,function*(){const v=function(S){let N,j=new Uint8Array(0);function C(_){const A=new Uint8Array(j.length+_.length);A.set(j),A.set(_,j.length),j=A}return new ReadableStream({start(){N=S.getReader()},async pull(_){let A;for(;;){if(A===void 0&&j.byteLength>=5){let R=0;for(let M=1;M<5;M++)R=(R<<8)+j[M];A={flags:j[0],length:R}}if(A!==void 0&&j.byteLength>=A.length+5)break;const P=await N.read();if(P.done)break;C(P.value)}if(A===void 0)return j.byteLength==0?void _.close():void _.error(new jt("premature end of stream",ut.DataLoss));const I=j.subarray(5,5+A.length);j=j.subarray(5+A.length),_.enqueue({flags:A.flags,data:I})}})}(g).getReader();let w=!1;for(;;){const S=yield Js(v.read());if(S.done)break;const{flags:N,data:j}=S.value;if(!(1&~N))throw new jt("protocol error: received unsupported compressed output",ut.Internal);if(!(2&~N)){w=!0;const C=iE(j);if(C.error){const _=C.error;throw b.forEach((A,I)=>{_.metadata.append(I,A)}),_}C.metadata.forEach((_,A)=>p.set(A,_));continue}yield yield Js(f(j))}if("throwIfAborted"in y&&y.throwIfAborted(),!w)throw"missing EndStreamResponse"})}async function x(g){if(r.kind!=cn.ServerStreaming)throw"The fetch API does not support streaming request bodies";const p=await g[Symbol.asyncIterator]().next();if(p.done==1)throw"missing request message";return function(b,y){const v=new Uint8Array(y.length+5);v.set(y,5);const w=new DataView(v.buffer,v.byteOffset,v.byteLength);return w.setUint8(0,b),w.setUint32(1,y.length),v}(0,h(p.value))}return a=a===void 0?t.defaultTimeoutMs:a<=0?void 0:a,await function(g){const p=Z1(g.next,g.interceptors),[b,y,v]=c0(g),w=Object.assign(Object.assign({},g.req),{message:sE(g.req.method.I,g.req.message),signal:b});let S=!1;return b.addEventListener("abort",function(){var N,j;const C=g.req.message[Symbol.asyncIterator]();S||(N=C.throw)===null||N===void 0||N.call(C,this.reason).catch(()=>{}),(j=C.return)===null||j===void 0||j.call(C).catch(()=>{})}),p(w).then(N=>Object.assign(Object.assign({},N),{message:{[Symbol.asyncIterator](){const j=N.message[Symbol.asyncIterator]();return{next:()=>j.next().then(C=>(C.done==1&&(S=!0,v()),C),y)}}}}),y)}({interceptors:t.interceptors,timeoutMs:a,signal:s,req:{stream:!0,service:o,method:r,url:X1(t.baseUrl,o,r),init:{method:"POST",credentials:(u=t.credentials)!==null&&u!==void 0?u:"same-origin",redirect:"error",mode:"cors"},header:i0(r.kind,n,a,i),contextValues:d??K1(),message:l},next:async g=>{var p;const b=(p=t.fetch)!==null&&p!==void 0?p:globalThis.fetch,y=await b(g.url,Object.assign(Object.assign({},g.init),{headers:g.header,signal:g.signal,body:await x(g.message)}));if(l0(r.kind,n,y.status,y.headers),y.body===null)throw"missing response body";const v=new Headers;return Object.assign(Object.assign({},g),{header:y.headers,trailer:v,message:m(y.body,v,y.headers,g.signal)})}})}}}({baseUrl:"https://web-backend.codeium.com",useBinaryFormat:!0}),pE=function(t,e){return rE(t,e)}(hE,mE);let Qi;try{Qi=crypto.randomUUID()}catch{Qi="10000000-1000-4000-8000-100000000000".replace(/[018]/g,t=>(+t^(crypto.getRandomValues(new Uint8Array(1))[0]??0)&15>>+t/4).toString(16))}async function gE(t,e){const n=t.state.facet(Yi),{override:o}=t.state.facet(W1),r=await o(),s=t.state,a=s.selection.main.head,i=s.doc.toString();try{const l=await async function({text:x,cursorOffset:g,config:p,otherDocuments:b}){return await pE.getCompletions({metadata:{ideName:"web",ideVersion:"0.0.5",extensionName:"@valtown/codemirror-codeium",extensionVersion:"1.0.0",apiKey:p.apiKey,sessionId:Qi,authSource:p.authSource},document:{text:x,cursorOffset:BigInt(g),language:p.language,editorLanguage:"typescript",lineEnding:`
105
- `},editorOptions:{tabSize:2n,insertSpaces:!0},otherDocuments:b,multilineConfig:void 0},{headers:{Authorization:`Basic ${p.apiKey}-${Qi}`}})}({text:i,cursorOffset:a,config:n,otherDocuments:r});if(!l||l.completionItems.length===0||e!==void 0&&a!==e||xs(t.state)==="active"||!t.hasFocus)return;const d=l.completionItems.map(x=>{let g=0;return x.completionParts.filter(p=>p.type!==3).map(p=>{const b=Number(p.offset),y=p.type===2?`
106
- ${p.text}`:p.text,v={absoluteStartPos:g+b,absoluteEndPos:g+b+y.length,from:b,to:b,insert:y};return g+=y.length,v})}),u=0,h=d.at(u);if(!h)return;const f=Ya.of(h,s.doc.length),m=f.invert(s.doc);t.dispatch({changes:f,effects:Md.of({index:u,reverseChangeSet:m,changeSpecs:d}),annotations:[Ki.of(null),Ir.of(null),Ka.addToHistory.of(!1)]})}catch(l){console.warn("copilot completion failed",l),await new Promise(d=>setTimeout(d,300))}}function xE(){let t=null,e=0;return Ve.updateListener.of(n=>{const o=n.view.state.facet(Yi);if(!o.alwaysOn||!function(s){return s.docChanged&&!s.transactions.some(a=>a.effects.some(i=>i.is(Od)||i.is(Dd)))}(n)||(t&&clearTimeout(t),function(s){if(!s.view.hasFocus||s.state.field(sr)||xs(s.state)==="active")return!0;for(const a of s.transactions)if(a.annotation(Ir)!==void 0)return!0}(n)))return;const r=n.state.selection.main.head;o.shouldComplete&&!o.shouldComplete(new hO(n.view.state,r,!1))||(t=setTimeout(async()=>{r===e&&await gE(n.view,e)},o.timeout),e=r)})}function d0(t){var r;const e=t.state.field(sr);if(!e)return!1;const n=(r=e.reverseChangeSet)==null?void 0:r.invert(t.state.doc);t.dispatch({changes:e.reverseChangeSet,effects:Od.of(null),annotations:[Ki.of(null),Ir.of(null),Ka.addToHistory.of(!1)]});let o=0;return n==null||n.iterChangedRanges((s,a,i,l)=>{o=l}),t.dispatch({changes:n,selection:Kn.cursor(o),annotations:[Ir.of(null),Ka.addToHistory.of(!0)]}),!0}const u0=t=>{const{state:e}=t,n=e.field(sr);if(!n)return!1;const{changeSpecs:o}=n;if(o.length<2)return!1;const r=(n.index+1)%o.length,s=o.at(r);if(!s)return!1;const a=n.reverseChangeSet.apply(e.doc),i=Ya.of(n.reverseChangeSet,e.doc.length).compose(Ya.of(s,a.length)),l=Ya.of(s,a.length).invert(a);return t.dispatch({changes:i,effects:Md.of({index:r,reverseChangeSet:l,changeSpecs:o}),annotations:[Ki.of(null),Ir.of(null),Ka.addToHistory.of(!1)]}),!0};function ru(t){const e=t.state.field(sr);return!!e&&(t.dispatch({changes:e.reverseChangeSet,effects:Dd.of(null),annotations:[Ki.of(null),Ir.of(null),Ka.addToHistory.of(!1)]}),!1)}function bE(){return Ve.domEventHandlers({keydown:(t,e)=>(t.key!=="]"||!t.ctrlKey)&&t.key!=="Shift"&&t.key!=="Control"&&t.key!=="Alt"&&t.key!=="Meta"&&function(n,o){return!!n.state.field(sr)&&(o==="Tab"?d0(n):ru(n))}(e,t.key),mouseup(t,e){const n=t.target;return n.nodeName==="BUTTON"&&n.dataset.action==="codeium-cycle"?(u0(e),t.stopPropagation(),t.preventDefault(),!0):function(o){var i,l;let r=!1;const s=(i=o.state.selection.asSingle().ranges.at(0))==null?void 0:i.head,a=o.state.field(sr);return!(s===void 0||!a)&&((l=a.decorations)==null||l.between(s,s,()=>{r=!0}),r)}(e)?d0(e):ru(e)}})}const yE=new pm,su=ht.get("@github/copilot-language-server"),h0={delay:500,includeKeymap:!0,events:{shouldShowSuggestion:t=>t.hasFocus,beforeSuggestionFetch:t=>t.hasFocus}},vE=t=>{const e=[];return t.copilot==="codeium"&&t.codeium_api_key&&e.push(function(n){return[Yi.of(n),sr,Eo.highest(_n.of([{key:"Ctrl-]",run:u0}])),Eo.highest(Ve.updateListener.of(o=>{o.focusChanged&&ru(o.view)})),Eo.high(bE()),xE()]}({apiKey:t.codeium_api_key,language:Oo.PYTHON}),W1.of({override:async()=>[{text:xc(""),language:Oo.PYTHON,editorLanguage:"python"}]})),t.copilot==="github"&&e.push(u1({...h0,fetchFn:async n=>{if(!aL()||n.doc.length===0)return"";await new Promise(a=>setTimeout(a,20));const o=n.doc.toString(),r=function(a,i){const l=a.doc.toString(),d=i.split(`
107
- `).length-l.split(`
108
- `).length,u=function(h,f){const m=h.lineAt(f);return{line:m.number-1,character:f-m.from}}(a.doc,a.selection.main.head);return u.line+=d,{textDocument:{uri:`file://${iL}`,version:"replace_me"},position:u,context:{triggerKind:mO.InlineCompletionTriggerKind.Automatic},formattingOptions:{tabSize:a.tabSize,insertSpaces:!0}}}(n,xc(o));return function(a,i,l){if(!a)return su.debug("No response from copilot"),"";const d=Array.isArray(a)?a[0]:a.items[0];if(!d)return su.debug("No response from copilot"),"";const{insertText:u,range:h}=d,f=String(u);if(!h)return su.error("No range from copilot"),f;const m=h.start.character-i.character,x=m<0?f.slice(-m):f,g=l.doc.sliceString(l.selection.main.head,l.doc.length);for(let p=0;p<x.length;p++){const b=x.slice(p);if(g.startsWith(b))return x.slice(0,p)}return x}(await xS().getCompletion(r),r.position,n)}})),t.copilot==="custom"&&e.push(u1({...h0,fetchFn:async n=>{if(n.doc.length===0)return"";const o=n.doc.sliceString(0,n.selection.main.head),r=n.doc.sliceString(n.selection.main.head,n.doc.length);if(o.length===0)return"";const s=n.field(bc).type;let a=await fO.post("/ai/inline_completion",{prefix:o,suffix:r,language:s});return o&&a.startsWith(o)&&(a=a.slice(o.length)),r&&a.endsWith(r)&&(a=a.slice(0,-r.length)),a}})),[...e,Eo.highest(_n.of([{key:"Escape",run:n=>{const o=d1(n);return!Ga(n)&&o}}])),yE.of(sL())]};function wE(t){return[_n.of([{key:"Escape",preventDefault:!1,run:lj},{key:t.getHotkey("cell.selectNextOccurrence").key,preventDefault:!0,run:gO},{key:t.getHotkey("cell.findAndReplace").key,preventDefault:!0,run:pg}]),pO(),mj,vi,pj]}const kE=tt.mark({class:"underline"}),f0=At.define(),m0=At.define(),p0=At.define(),SE=xn.define({create:()=>tt.none,update(t,e){let n=t.map(e.changes);for(const o of e.effects)o.is(f0)?n=t.update({add:[kE.range(o.value.from,o.value.to)]}):o.is(m0)?n=t.update({add:[xO.range(o.value.from,o.value.to)]}):o.is(p0)&&(n=tt.none);return n},provide:t=>Ve.decorations.from(t)});class NE{constructor(e,n){this.view=void 0,this.commandClickMode=void 0,this.hoveredRange=void 0,this.onClick=void 0,this.keydown=o=>{o.key!=="Meta"&&o.key!=="Control"||(this.commandClickMode=!0,this.view.dom.addEventListener("mousemove",this.mousemove),this.view.dom.addEventListener("click",this.click))},this.keyup=o=>{o.key!=="Meta"&&o.key!=="Control"||this.exitCommandClickMode()},this.windowBlur=()=>{this.commandClickMode&&this.exitCommandClickMode()},this.mousemove=o=>{if(!o.metaKey&&!o.ctrlKey)return void this.exitCommandClickMode();if(!this.commandClickMode)return void this.clearUnderline();const r=this.view.posAtCoords({x:o.clientX,y:o.clientY});if(r==null)return void this.clearUnderline();const s=this.view.state.field(bO,!1),a=s==null?void 0:s.ranges.find(l=>r>=l.from&&r<=l.to);if(a){const{from:l,to:d}=a;return this.hoveredRange&&this.hoveredRange.from===l&&this.hoveredRange.to===d?void 0:(this.clearUnderline(),this.hoveredRange={from:l,to:d,position:r},void this.view.dispatch({effects:m0.of(this.hoveredRange)}))}const i=yO(this.view.state).cursorAt(r);if(i.name==="VariableName"){const{from:l,to:d}=i;if(this.hoveredRange&&this.hoveredRange.from===l&&this.hoveredRange.to===d)return;this.clearUnderline(),this.hoveredRange={from:l,to:d,position:r},this.view.dispatch({effects:f0.of(this.hoveredRange)})}else this.clearUnderline()},this.click=o=>{if(this.hoveredRange){const r=this.view.state.doc.sliceString(this.hoveredRange.from,this.hoveredRange.to);o.preventDefault(),o.stopPropagation(),this.onClick(this.view,r),this.view.dispatch({selection:{head:this.hoveredRange.position,anchor:this.hoveredRange.position}})}},this.view=e,this.commandClickMode=!1,this.hoveredRange=null,this.onClick=n,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:p0.of(null)}),this.hoveredRange=null)}}function jE(){return[Ve.domEventHandlers({paste:(t,e)=>{var r;const n=(r=t.clipboardData)==null?void 0:r.getData("text/plain");if(!(n!=null&&n.includes("@app.cell")))return!1;const o=function(s){if(!s.includes("@app.cell"))return[];const a=[],i=s.split(`
109
- `);let l=[],d=!1,u=0,h=!1,f=!1,m=0;const x=/\(/g,g=/\)/g,p=new Set(["@"]);function b(v){return(v.match(x)||[]).length-(v.match(g)||[]).length}function y(){if(l.length!==0){for(;l.length>0&&l[l.length-1].trim().startsWith("return");)l.pop();l.some(v=>v.trim()!=="")&&a.push(function(v){const w=v.split(`
110
- `);if(w.length===0)return"";const S=w.filter(C=>C.trim().length>0);if(S.length===0)return"";const N=/^\s*/,j=Math.min(...S.map(C=>{var _;return((_=C.match(N))==null?void 0:_[0].length)??Number.POSITIVE_INFINITY}));return j===0?v.trim():w.map(C=>C.slice(j)).join(`
111
- `).trim()}(l.join(`
112
- `))),l=[]}}for(const v of i){const w=v.trim();(w||d)&&(w.startsWith("@app.cell")?(y(),d=!0,u=1):u>0?(w.startsWith("def")&&w.includes("(")&&!w.includes("):")&&(h=!0,m=b(w)),u--):h?(m+=b(w),m===0&&(h=!1)):d&&(p.has(w[0])||w.startsWith("if __name__")?(y(),d=w.startsWith("@")):w.startsWith("return")?w.includes("(")&&!w.endsWith(")")&&(f=!0,m=b(w)):f?(m+=b(w),m===0&&(f=!1)):l.push(v)))}return y(),a}(n);return o.length===0?!1:(e.state.facet(SO).createManyBelow(o),!0)}})]}const Pt=({variant:t,settings:e,styles:n})=>{const o=Ve.theme({"&":{backgroundColor:e.background,color:e.foreground},".cm-content":{caretColor:e.caret},".cm-cursor, .cm-dropCursor":{borderLeftColor:e.caret},"&.cm-focused .cm-selectionBackgroundm .cm-selectionBackground, .cm-content ::selection":{backgroundColor:e.selection},".cm-activeLine":{backgroundColor:e.lineHighlight},".cm-gutters":{backgroundColor:e.gutterBackground,color:e.gutterForeground},".cm-activeLineGutter":{backgroundColor:e.lineHighlight}},{dark:t==="dark"}),r=NO.define(n);return[o,l3(r)]};Pt({variant:"dark",settings:{background:"#200020",foreground:"#D0D0FF",caret:"#7070FF",selection:"#80000080",gutterBackground:"#200020",gutterForeground:"#C080C0",lineHighlight:"#80000040"},styles:[{tag:z.comment,color:"#404080"},{tag:[z.string,z.regexp],color:"#999999"},{tag:z.number,color:"#7090B0"},{tag:[z.bool,z.null],color:"#8080A0"},{tag:[z.punctuation,z.derefOperator],color:"#805080"},{tag:z.keyword,color:"#60B0FF"},{tag:z.definitionKeyword,color:"#B0FFF0"},{tag:z.moduleKeyword,color:"#60B0FF"},{tag:z.operator,color:"#A0A0FF"},{tag:[z.variableName,z.self],color:"#008080"},{tag:z.operatorKeyword,color:"#A0A0FF"},{tag:z.controlKeyword,color:"#80A0FF"},{tag:z.className,color:"#70E080"},{tag:[z.function(z.propertyName),z.propertyName],color:"#50A0A0"},{tag:z.tagName,color:"#009090"},{tag:z.modifier,color:"#B0FFF0"},{tag:[z.squareBracket,z.attributeName],color:"#D0D0FF"}]}),Pt({variant:"light",settings:{background:"#fcfcfc",foreground:"#5c6166",caret:"#ffaa33",selection:"#036dd626",gutterBackground:"#fcfcfc",gutterForeground:"#8a919966",lineHighlight:"#8a91991a"},styles:[{tag:z.comment,color:"#787b8099"},{tag:z.string,color:"#86b300"},{tag:z.regexp,color:"#4cbf99"},{tag:[z.number,z.bool,z.null],color:"#ffaa33"},{tag:z.variableName,color:"#5c6166"},{tag:[z.definitionKeyword,z.modifier],color:"#fa8d3e"},{tag:[z.keyword,z.special(z.brace)],color:"#fa8d3e"},{tag:z.operator,color:"#ed9366"},{tag:z.separator,color:"#5c6166b3"},{tag:z.punctuation,color:"#5c6166"},{tag:[z.definition(z.propertyName),z.function(z.variableName)],color:"#f2ae49"},{tag:[z.className,z.definition(z.typeName)],color:"#22a4e6"},{tag:[z.tagName,z.typeName,z.self,z.labelName],color:"#55b4d4"},{tag:z.angleBracket,color:"#55b4d480"},{tag:z.attributeName,color:"#f2ae49"}]}),Pt({variant:"dark",settings:{background:"#15191EFA",foreground:"#EEF2F7",caret:"#C4C4C4",selection:"#90B2D557",gutterBackground:"#15191EFA",gutterForeground:"#aaaaaa95",lineHighlight:"#57575712"},styles:[{tag:z.comment,color:"#6E6E6E"},{tag:[z.string,z.regexp,z.special(z.brace)],color:"#5C81B3"},{tag:z.number,color:"#C1E1B8"},{tag:z.bool,color:"#53667D"},{tag:[z.definitionKeyword,z.modifier,z.function(z.propertyName)],color:"#A3D295",fontWeight:"bold"},{tag:[z.keyword,z.moduleKeyword,z.operatorKeyword,z.operator],color:"#697A8E",fontWeight:"bold"},{tag:[z.variableName,z.attributeName],color:"#708E67"},{tag:[z.function(z.variableName),z.definition(z.propertyName),z.derefOperator],color:"#fff"},{tag:z.tagName,color:"#A3D295"}]}),Pt({variant:"dark",settings:{background:"#2e241d",foreground:"#BAAE9E",caret:"#A7A7A7",selection:"#DDF0FF33",gutterBackground:"#28211C",gutterForeground:"#BAAE9E90",lineHighlight:"#FFFFFF08"},styles:[{tag:z.comment,color:"#666666"},{tag:[z.string,z.special(z.brace)],color:"#54BE0D"},{tag:z.regexp,color:"#E9C062"},{tag:z.number,color:"#CF6A4C"},{tag:[z.keyword,z.operator],color:"#5EA6EA"},{tag:z.variableName,color:"#7587A6"},{tag:[z.definitionKeyword,z.modifier],color:"#F9EE98"},{tag:[z.propertyName,z.function(z.variableName)],color:"#937121"},{tag:[z.typeName,z.angleBracket,z.tagName],color:"#9B859D"}]}),Pt({variant:"dark",settings:{background:"#3b2627",foreground:"#E6E1C4",caret:"#E6E1C4",selection:"#16120E",gutterBackground:"#3b2627",gutterForeground:"#E6E1C490",lineHighlight:"#1F1611"},styles:[{tag:z.comment,color:"#6B4E32"},{tag:[z.keyword,z.operator,z.derefOperator],color:"#EF5D32"},{tag:z.className,color:"#EFAC32",fontWeight:"bold"},{tag:[z.typeName,z.propertyName,z.function(z.variableName),z.definition(z.variableName)],color:"#EFAC32"},{tag:z.definition(z.typeName),color:"#EFAC32",fontWeight:"bold"},{tag:z.labelName,color:"#EFAC32",fontWeight:"bold"},{tag:[z.number,z.bool],color:"#6C99BB"},{tag:[z.variableName,z.self],color:"#7DAF9C"},{tag:[z.string,z.special(z.brace),z.regexp],color:"#D9D762"},{tag:[z.angleBracket,z.tagName,z.attributeName],color:"#EFCB43"}]}),Pt({variant:"dark",settings:{background:"#000205",foreground:"#FFFFFF",caret:"#E60065",selection:"#E60C6559",gutterBackground:"#000205",gutterForeground:"#ffffff90",lineHighlight:"#4DD7FC1A"},styles:[{tag:z.comment,color:"#404040"},{tag:[z.string,z.special(z.brace),z.regexp],color:"#00D8FF"},{tag:z.number,color:"#E62286"},{tag:[z.variableName,z.attributeName,z.self],color:"#E62286",fontWeight:"bold"},{tag:z.function(z.variableName),color:"#fff",fontWeight:"bold"}]}),Pt({variant:"light",settings:{background:"#fff",foreground:"#000",caret:"#000",selection:"#BDD5FC",gutterBackground:"#fff",gutterForeground:"#00000070",lineHighlight:"#FFFBD1"},styles:[{tag:z.comment,color:"#BCC8BA"},{tag:[z.string,z.special(z.brace),z.regexp],color:"#5D90CD"},{tag:[z.number,z.bool,z.null],color:"#46A609"},{tag:z.keyword,color:"#AF956F"},{tag:[z.definitionKeyword,z.modifier],color:"#C52727"},{tag:[z.angleBracket,z.tagName,z.attributeName],color:"#606060"},{tag:z.self,color:"#000"}]}),Pt({variant:"dark",settings:{background:"#00254b",foreground:"#FFFFFF",caret:"#FFFFFF",selection:"#B36539BF",gutterBackground:"#00254b",gutterForeground:"#FFFFFF70",lineHighlight:"#00000059"},styles:[{tag:z.comment,color:"#0088FF"},{tag:z.string,color:"#3AD900"},{tag:z.regexp,color:"#80FFC2"},{tag:[z.number,z.bool,z.null],color:"#FF628C"},{tag:[z.definitionKeyword,z.modifier],color:"#FFEE80"},{tag:z.variableName,color:"#CCCCCC"},{tag:z.self,color:"#FF80E1"},{tag:[z.className,z.definition(z.propertyName),z.function(z.variableName),z.definition(z.typeName),z.labelName],color:"#FFDD00"},{tag:[z.keyword,z.operator],color:"#FF9D00"},{tag:[z.propertyName,z.typeName],color:"#80FFBB"},{tag:z.special(z.brace),color:"#EDEF7D"},{tag:z.attributeName,color:"#9EFFFF"},{tag:z.derefOperator,color:"#fff"}]}),Pt({variant:"dark",settings:{background:"#060521",foreground:"#E0E0E0",caret:"#FFFFFFA6",selection:"#122BBB",gutterBackground:"#060521",gutterForeground:"#E0E0E090",lineHighlight:"#FFFFFF0F"},styles:[{tag:z.comment,color:"#AEAEAE"},{tag:[z.string,z.special(z.brace),z.regexp],color:"#8DFF8E"},{tag:[z.className,z.definition(z.propertyName),z.function(z.variableName),z.function(z.definition(z.variableName)),z.definition(z.typeName)],color:"#A3EBFF"},{tag:[z.number,z.bool,z.null],color:"#62E9BD"},{tag:[z.keyword,z.operator],color:"#2BF1DC"},{tag:[z.definitionKeyword,z.modifier],color:"#F8FBB1"},{tag:[z.variableName,z.self],color:"#B683CA"},{tag:[z.angleBracket,z.tagName,z.typeName,z.propertyName],color:"#60A4F1"},{tag:z.derefOperator,color:"#E0E0E0"},{tag:z.attributeName,color:"#7BACCA"}]}),Pt({variant:"dark",settings:{background:"#2d2f3f",foreground:"#f8f8f2",caret:"#f8f8f0",selection:"#44475a",gutterBackground:"#282a36",gutterForeground:"rgb(144, 145, 148)",lineHighlight:"#44475a"},styles:[{tag:z.comment,color:"#6272a4"},{tag:[z.string,z.special(z.brace)],color:"#f1fa8c"},{tag:[z.number,z.self,z.bool,z.null],color:"#bd93f9"},{tag:[z.keyword,z.operator],color:"#ff79c6"},{tag:[z.definitionKeyword,z.typeName],color:"#8be9fd"},{tag:z.definition(z.typeName),color:"#f8f8f2"},{tag:[z.className,z.definition(z.propertyName),z.function(z.variableName),z.attributeName],color:"#50fa7b"}]}),Pt({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#80C7FF",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#C1E2F8"},styles:[{tag:z.comment,color:"#AAAAAA"},{tag:[z.keyword,z.operator,z.typeName,z.tagName,z.propertyName],color:"#2F6F9F",fontWeight:"bold"},{tag:[z.attributeName,z.definition(z.propertyName)],color:"#4F9FD0"},{tag:[z.className,z.string,z.special(z.brace)],color:"#CF4F5F"},{tag:z.number,color:"#CF4F5F",fontWeight:"bold"},{tag:z.variableName,fontWeight:"bold"}]}),Pt({variant:"light",settings:{background:"#f2f1f8",foreground:"#0c006b",caret:"#5c49e9",selection:"#d5d1f2",gutterBackground:"#f2f1f8",gutterForeground:"#0c006b70",lineHighlight:"#e1def3"},styles:[{tag:z.comment,color:"#9995b7"},{tag:z.keyword,color:"#ff5792",fontWeight:"bold"},{tag:[z.definitionKeyword,z.modifier],color:"#ff5792"},{tag:[z.className,z.tagName,z.definition(z.typeName)],color:"#0094f0"},{tag:[z.number,z.bool,z.null,z.special(z.brace)],color:"#5842ff"},{tag:[z.definition(z.propertyName),z.function(z.variableName)],color:"#0095a8"},{tag:z.typeName,color:"#b3694d"},{tag:[z.propertyName,z.variableName],color:"#fa8900"},{tag:z.operator,color:"#ff5792"},{tag:z.self,color:"#e64100"},{tag:[z.string,z.regexp],color:"#00b368"},{tag:[z.paren,z.bracket],color:"#0431fa"},{tag:z.labelName,color:"#00bdd6"},{tag:z.attributeName,color:"#e64100"},{tag:z.angleBracket,color:"#9995b7"}]}),Pt({variant:"light",settings:{background:"#faf4ed",foreground:"#575279",caret:"#575279",selection:"#6e6a8614",gutterBackground:"#faf4ed",gutterForeground:"#57527970",lineHighlight:"#6e6a860d"},styles:[{tag:z.comment,color:"#9893a5"},{tag:[z.bool,z.null],color:"#286983"},{tag:z.number,color:"#d7827e"},{tag:z.className,color:"#d7827e"},{tag:[z.angleBracket,z.tagName,z.typeName],color:"#56949f"},{tag:z.attributeName,color:"#907aa9"},{tag:z.punctuation,color:"#797593"},{tag:[z.keyword,z.modifier],color:"#286983"},{tag:[z.string,z.regexp],color:"#ea9d34"},{tag:z.variableName,color:"#d7827e"}]}),Pt({variant:"light",settings:{background:"#FFFFFF",foreground:"#000000",caret:"#000000",selection:"#FFFD0054",gutterBackground:"#FFFFFF",gutterForeground:"#00000070",lineHighlight:"#00000008"},styles:[{tag:z.comment,color:"#CFCFCF"},{tag:[z.number,z.bool,z.null],color:"#E66C29"},{tag:[z.className,z.definition(z.propertyName),z.function(z.variableName),z.labelName,z.definition(z.typeName)],color:"#2EB43B"},{tag:z.keyword,color:"#D8B229"},{tag:z.operator,color:"#4EA44E",fontWeight:"bold"},{tag:[z.definitionKeyword,z.modifier],color:"#925A47"},{tag:z.string,color:"#704D3D"},{tag:z.typeName,color:"#2F8996"},{tag:[z.variableName,z.propertyName],color:"#77ACB0"},{tag:z.self,color:"#77ACB0",fontWeight:"bold"},{tag:z.regexp,color:"#E3965E"},{tag:[z.tagName,z.angleBracket],color:"#BAA827"},{tag:z.attributeName,color:"#B06520"},{tag:z.derefOperator,color:"#000"}]}),Pt({variant:"light",settings:{background:"#fef7e5",foreground:"#586E75",caret:"#000000",selection:"#073642",gutterBackground:"#fef7e5",gutterForeground:"#586E7580",lineHighlight:"#EEE8D5"},styles:[{tag:z.comment,color:"#93A1A1"},{tag:z.string,color:"#2AA198"},{tag:z.regexp,color:"#D30102"},{tag:z.number,color:"#D33682"},{tag:z.variableName,color:"#268BD2"},{tag:[z.keyword,z.operator,z.punctuation],color:"#859900"},{tag:[z.definitionKeyword,z.modifier],color:"#073642",fontWeight:"bold"},{tag:[z.className,z.self,z.definition(z.propertyName)],color:"#268BD2"},{tag:z.function(z.variableName),color:"#268BD2"},{tag:[z.bool,z.null],color:"#B58900"},{tag:z.tagName,color:"#268BD2",fontWeight:"bold"},{tag:z.angleBracket,color:"#93A1A1"},{tag:z.attributeName,color:"#93A1A1"},{tag:z.typeName,color:"#859900"}]}),Pt({variant:"light",settings:{background:"#FFFFFF",foreground:"#4D4D4C",caret:"#AEAFAD",selection:"#D6D6D6",gutterBackground:"#FFFFFF",gutterForeground:"#4D4D4C80",lineHighlight:"#EFEFEF"},styles:[{tag:z.comment,color:"#8E908C"},{tag:[z.variableName,z.self,z.propertyName,z.attributeName,z.regexp],color:"#C82829"},{tag:[z.number,z.bool,z.null],color:"#F5871F"},{tag:[z.className,z.typeName,z.definition(z.typeName)],color:"#C99E00"},{tag:[z.string,z.special(z.brace)],color:"#718C00"},{tag:z.operator,color:"#3E999F"},{tag:[z.definition(z.propertyName),z.function(z.variableName)],color:"#4271AE"},{tag:z.keyword,color:"#8959A8"},{tag:z.derefOperator,color:"#4D4D4C"}]});const CE=[Pt({variant:"dark",settings:{background:"#282c34",foreground:"#abb2bf",caret:"#528bff",selection:"#3E4451",lineHighlight:"#2c313c",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:z.comment,color:"#5c6370"},{tag:z.variableName,color:"#abb2bf"},{tag:[z.string,z.special(z.brace)],color:"#98c379"},{tag:z.number,color:"#d19a66"},{tag:z.bool,color:"#d19a66"},{tag:z.null,color:"#d19a66"},{tag:z.keyword,color:"#c678dd",fontWeight:500},{tag:z.className,color:"#61afef"},{tag:z.definition(z.typeName),color:"#61afef"},{tag:z.typeName,color:"#56b6c2"},{tag:z.angleBracket,color:"#abb2bf"},{tag:z.tagName,color:"#e06c75"},{tag:z.attributeName,color:"#d19a66"},{tag:z.operator,color:"#56b6c2",fontWeight:500},{tag:[z.function(z.variableName)],color:"#61afef"},{tag:[z.propertyName],color:"#e5c07b"}]}),Ve.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#2a7aa5",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px",borderBottomColor:"#4a90a5"}})],EE=[Pt({variant:"light",settings:{background:"#ffffff",foreground:"#000000",caret:"#000000",selection:"#d7d4f0",lineHighlight:"#cceeff44",gutterBackground:"var(--color-background)",gutterForeground:"var(--gray-10)"},styles:[{tag:z.comment,color:"#708090"},{tag:z.variableName,color:"#000000"},{tag:[z.string,z.special(z.brace)],color:"#a11"},{tag:z.number,color:"#164"},{tag:z.bool,color:"#219"},{tag:z.null,color:"#219"},{tag:z.keyword,color:"#708",fontWeight:500},{tag:z.className,color:"#00f"},{tag:z.definition(z.typeName),color:"#00f"},{tag:z.typeName,color:"#085"},{tag:z.angleBracket,color:"#000000"},{tag:z.tagName,color:"#170"},{tag:z.attributeName,color:"#00c"},{tag:z.operator,color:"#a2f",fontWeight:500},{tag:[z.function(z.variableName)],color:"#00c"},{tag:[z.propertyName],color:"#05a"}]}),Ve.theme({".mo-cm-reactive-reference":{fontWeight:"400",color:"#005f87",borderBottom:"2px solid #bad3de"},".mo-cm-reactive-reference-hover":{cursor:"pointer",borderBottomWidth:"3px"}})];function g0(t){const{showPlaceholder:e,enableAI:n}=t;return e?"marimo-import":n?"ai":"none"}const _E=t=>{const{cellId:e,keymapConfig:n,hotkeys:o,enableAI:r,cellActions:s,completionConfig:a,lspConfig:i,diagnosticsConfig:l,displayConfig:d}=t,u=g0(t);return[lL(n,o),[Ve.domEventHandlers({drop:(f,m)=>{var p,b;const x=(p=f.dataTransfer)==null?void 0:p.files[0];if(x!=null&&x.type.startsWith("text/"))return f.preventDefault(),wO(m,x),!0;if(x!=null&&x.type.startsWith("image/"))return f.preventDefault(),kO(m,x),!0;const g=(b=f.dataTransfer)==null?void 0:b.getData("text/plain");if(g){f.preventDefault();const y=m.posAtCoords({x:f.clientX,y:f.clientY});return y!==null&&m.dispatch({changes:{from:y,to:y,insert:g},scrollIntoView:!0}),!0}return!1},dragover:f=>{f.preventDefault()}})],jE(),NC(),jO({completionConfig:a,hotkeys:o,placeholderType:u,lspConfig:i,diagnosticsConfig:l}),CO({cellId:e,hotkeys:o,cellActions:s}),IE(t),[SE,(h=(f,m)=>{vO(f,m)},Rn.define(f=>new NE(f,h))),Ve.baseTheme({".underline":{textDecoration:"underline",cursor:"pointer",color:"var(--link)"}})],l!=null&&l.enabled?EO():[],r&&Xf("inline_ai_tooltip")?hC({prompt:f=>async function(m){var w,S;const x=`
113
- ${m.codeBefore}
114
- <rewrite_this>
115
- ${m.selection}
116
- </rewrite_this>
117
- ${m.codeAfter}
118
- `.trim(),g=o3();await r3();const p=await fetch(g.getAiURL("completion").toString(),{method:"POST",headers:g.headers(),body:JSON.stringify({prompt:m.prompt,code:x,selectedText:m.selection,includeOtherCode:"",language:m.language})}),b=((w=m.selection.match(/^\s*/))==null?void 0:w[0])||"",y=(S=p.body)==null?void 0:S.getReader();if(!y)throw new Error("Failed to get response reader");let v="";for(;;){const{done:N,value:j}=await y.read();if(N)break;v+=new TextDecoder().decode(j)}return v.startsWith(b)||(v=b+v),v}({prompt:f.prompt,selection:f.selection,codeBefore:f.codeBefore,codeAfter:f.codeAfter,language:gk(f.editorView)})}):[],_O(Qe),IO(e,d.reference_highlighting??!1)];var h},IE=t=>{const{theme:e,hotkeys:n,completionConfig:o,cellId:r,lspConfig:s,diagnosticsConfig:a}=t,i=g0(t);return[Ve.lineWrapping,AO(),TO(),MO(),OO(),DO(),PO(),RO(),LO({position:"fixed",parent:document.querySelector("#App")??void 0}),FO(),e==="dark"?CE:EE,zO(s),vE(o),BO(),UO(),CC(),Eo.high(_n.of(GO)),$O(),VO(),HO.of(" "),l3(YO,{fallback:!0}),_n.of(KO),WO({placeholderType:i,completionConfig:o,hotkeys:n,cellId:r,lspConfig:{...s,diagnostics:a}}),qO.of(XO()),Xa.allowMultipleSelections.of(!0),wE(n),_n.of([{key:"Tab",run:l=>i3(l)||(d=>{const{from:u,to:h}=d.state.selection.main;if(u!==h)return!1;const f=d.state.doc.lineAt(h);return f.text.slice(0,h-f.from).trim()!==""&&eD(d)})(l)||JO(l),preventDefault:!0},{key:n.getHotkey("completion.moveDown").key,run:l=>xs(l.state)!==null&&(gc(!0)(l),!0),preventDefault:!0},{key:n.getHotkey("completion.moveUp").key,run:l=>xs(l.state)!==null&&(gc(!1)(l),!0),preventDefault:!0}]),_n.of([...ZO,QO])]},AE={width:void 0,height:void 0};function x0(t,e,n){return t[e]?Array.isArray(t[e])?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}let b0,y0,v0,w0;b0=new Intl.DateTimeFormat("en-US",{hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),y0=new Intl.DateTimeFormat("en-US",{month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3,hour12:!0}),v0=t=>{const e=H.c(79),{editing:n,status:o,disabled:r,staleInputs:s,edited:a,interrupted:i,elapsedTime:l,runStartTimestamp:d,lastRunStartTimestamp:u,uninstantiated:h}=t;if(!n)return null;const f=d??u;let m;e[0]!==f?(m=f?c.jsx(w0,{lastRanTime:f}):null,e[0]=f,e[1]=m):m=e[1];const x=m;if(r&&o==="running")return ht.error("CellStatusComponent: disabled and running"),null;if(r&&s){let g,p,b,y;return e[2]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"This cell is stale, but it's disabled and can't be run"}),e[2]=g):g=e[2],e[3]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[3]=x,e[4]=p):p=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:c.jsxs(_s,{children:[c.jsx(Cs,{className:"h-5 w-5",strokeWidth:1.5}),c.jsx(yc,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[5]=b):b=e[5],e[6]!==p?(y=c.jsx(Ne,{content:p,usePortal:!0,children:b}),e[6]=p,e[7]=y):y=e[7],y}if(r){let g,p,b,y;return e[8]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"This cell is disabled"}),e[8]=g):g=e[8],e[9]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[9]=x,e[10]=p):p=e[10],e[11]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx("div",{className:"cell-status-icon cell-status-disabled","data-testid":"cell-status","data-status":"disabled",children:c.jsx(Cs,{className:"h-5 w-5",strokeWidth:1.5})}),e[11]=b):b=e[11],e[12]!==p?(y=c.jsx(Ne,{content:p,usePortal:!0,children:b}),e[12]=p,e[13]=y):y=e[13],y}if(!s&&o==="disabled-transitively"){let g,p,b,y;return e[14]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"An ancestor of this cell is disabled, so it can't be run"}),e[14]=g):g=e[14],e[15]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[15]=x,e[16]=p):p=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"disabled-transitively",children:c.jsxs(_s,{layerTop:!0,children:[c.jsx(ci,{className:"h-5 w-5",strokeWidth:1.5}),c.jsx(Cs,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[17]=b):b=e[17],e[18]!==p?(y=c.jsx(Ne,{content:p,usePortal:!0,children:b}),e[18]=p,e[19]=y):y=e[19],y}if(s&&o==="disabled-transitively"){let g,p,b,y;return e[20]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"This cell is stale, but an ancestor is disabled so it can't be run"}),e[20]=g):g=e[20],e[21]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[21]=x,e[22]=p):p=e[22],e[23]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx("div",{className:"cell-status-icon cell-status-stale","data-testid":"cell-status","data-status":"stale",children:c.jsxs(_s,{children:[c.jsx(yc,{className:"h-5 w-5",strokeWidth:1}),c.jsx(Cs,{className:"h-3 w-3",strokeWidth:2.5})]})}),e[23]=b):b=e[23],e[24]!==p?(y=c.jsx(Ne,{content:p,usePortal:!0,children:b}),e[24]=p,e[25]=y):y=e[25],y}if(o==="running"){let g,p,b,y,v;return e[26]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"This cell is running"}),e[26]=g):g=e[26],e[27]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[27]=x,e[28]=p):p=e[28],e[29]!==d?(b=gm.fromSeconds(d)||gm.now(),e[29]=d,e[30]=b):b=e[30],e[31]!==b?(y=c.jsx("div",{className:"cell-status-icon elapsed-time running","data-testid":"cell-status","data-status":"running",children:c.jsx(TE,{startTime:b})}),e[31]=b,e[32]=y):y=e[32],e[33]!==p||e[34]!==y?(v=c.jsx(Ne,{content:p,usePortal:!0,children:y}),e[33]=p,e[34]=y,e[35]=v):v=e[35],v}if(o==="queued"){let g,p,b,y;return e[36]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("span",{children:"This cell is queued to run"}),e[36]=g):g=e[36],e[37]!==x?(p=c.jsxs("div",{className:"flex flex-col gap-1",children:[g,x]}),e[37]=x,e[38]=p):p=e[38],e[39]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx("div",{className:"cell-status-icon cell-status-queued","data-testid":"cell-status","data-status":"queued",children:c.jsx(Dc,{className:"h-5 w-5",strokeWidth:1.5})}),e[39]=b):b=e[39],e[40]!==p?(y=c.jsx(Ne,{content:p,usePortal:!0,children:b}),e[40]=p,e[41]=y):y=e[41],y}if(a||i||s||h){let g;e[42]!==l?(g=js(l),e[42]=l,e[43]=g):g=e[43];const p=g;let b;e[44]!==l||e[45]!==p?(b=l?c.jsx(Pc,{elapsedTime:p}):null,e[44]=l,e[45]=p,e[46]=b):b=e[46];const y=b;let v,w,S,N,j,C="";if(h)v="This cell has not yet been run";else if(i){let _;v="This cell was interrupted when it was last run",e[47]!==y?(_=c.jsxs("span",{children:["This cell ran for ",y," before being interrupted"]}),e[47]=y,e[48]=_):_=e[48],C=_}else if(a){let _;v="This cell has been modified since it was last run",e[49]!==y?(_=c.jsxs("span",{children:["This cell took ",y," to run"]}),e[49]=y,e[50]=_):_=e[50],C=_}else{let _;v="This cell has not been run with the latest inputs",e[51]!==y?(_=c.jsxs("span",{children:["This cell took ",y," to run"]}),e[51]=y,e[52]=_):_=e[52],C=_}return e[53]===Symbol.for("react.memo_cache_sentinel")?(w=c.jsx("div",{className:"cell-status-stale","data-testid":"cell-status","data-status":"outdated",children:c.jsx(yc,{className:"h-5 w-5",strokeWidth:1.5})}),e[53]=w):w=e[53],e[54]!==v?(S=c.jsx(Ne,{content:v,usePortal:!0,children:w}),e[54]=v,e[55]=S):S=e[55],e[56]!==l||e[57]!==p||e[58]!==x||e[59]!==C?(N=l&&c.jsx(Ne,{content:c.jsxs("div",{className:"flex flex-col gap-1",children:[C,x]}),usePortal:!0,children:c.jsx("div",{className:"elapsed-time hover-action","data-testid":"cell-status","data-status":"outdated",children:c.jsx("span",{children:p})})}),e[56]=l,e[57]=p,e[58]=x,e[59]=C,e[60]=N):N=e[60],e[61]!==S||e[62]!==N?(j=c.jsxs("div",{className:"cell-status-icon flex items-center gap-2",children:[S,N]}),e[61]=S,e[62]=N,e[63]=j):j=e[63],j}if(l!==null){let g;e[64]!==l?(g=js(l),e[64]=l,e[65]=g):g=e[65];const p=g;let b;e[66]!==l||e[67]!==p?(b=l?c.jsx(Pc,{elapsedTime:p}):null,e[66]=l,e[67]=p,e[68]=b):b=e[68];const y=b;let v,w,S,N;return e[69]!==y?(v=c.jsxs("span",{children:["This cell took ",y," to run"]}),e[69]=y,e[70]=v):v=e[70],e[71]!==x||e[72]!==v?(w=c.jsxs("div",{className:"flex flex-col gap-1",children:[v,x]}),e[71]=x,e[72]=v,e[73]=w):w=e[73],e[74]!==p?(S=c.jsx("div",{className:"cell-status-icon elapsed-time hover-action","data-testid":"cell-status","data-status":"idle",children:c.jsx("span",{children:p})}),e[74]=p,e[75]=S):S=e[75],e[76]!==w||e[77]!==S?(N=c.jsx(Ne,{content:w,usePortal:!0,children:S}),e[76]=w,e[77]=S,e[78]=N):N=e[78],N}return null},Pc=t=>{const e=H.c(2);let n;return e[0]!==t.elapsedTime?(n=c.jsx("span",{className:"tracking-wide font-semibold",children:t.elapsedTime}),e[0]=t.elapsedTime,e[1]=n):n=e[1],n},w0=t=>{const e=H.c(18),n=1e3*t.lastRanTime;let o,r,s,a,i,l,d,u,h;if(e[0]!==n){const f=new Date(n),m=new Date,x=f.toDateString()===m.toDateString()?b0:y0;a="Ran at",i=" ",l=c.jsx("strong",{className:"tracking-wide font-semibold",children:x.format(f)}),d=" ",o="text-muted-foreground",r="(",s=$S(f),e[0]=n,e[1]=o,e[2]=r,e[3]=s,e[4]=a,e[5]=i,e[6]=l,e[7]=d}else o=e[1],r=e[2],s=e[3],a=e[4],i=e[5],l=e[6],d=e[7];return e[8]!==o||e[9]!==r||e[10]!==s?(u=c.jsxs("span",{className:o,children:[r,s," ago)"]}),e[8]=o,e[9]=r,e[10]=s,e[11]=u):u=e[11],e[12]!==a||e[13]!==i||e[14]!==l||e[15]!==d||e[16]!==u?(h=c.jsxs("span",{children:[a,i,l,d,u]}),e[12]=a,e[13]=i,e[14]=l,e[15]=d,e[16]=u,e[17]=h):h=e[17],h},js=function(t){if(t===null)return"";const e=t,n=e/1e3;return n>=60?`${Math.floor(n/60)}m${Math.floor(n%60)}s`:n>=1?`${n.toFixed(2).toString()}s`:`${e.toFixed(0).toString()}ms`};const TE=t=>{const e=H.c(6);let n;e[0]!==t.startTime?(n=t.startTime.toMilliseconds(),e[0]=t.startTime,e[1]=n):n=e[1];const o=function(a){const i=O.useRef(a),[l,d]=O.useState(a);return O.useEffect(()=>{const u=setInterval(()=>{d(gm.now().toMilliseconds())},17);return()=>clearInterval(u)},[]),l-i.current}(n);let r,s;return e[2]!==o?(r=js(o),e[2]=o,e[3]=r):r=e[3],e[4]!==r?(s=c.jsx("span",{children:r}),e[4]=r,e[5]=s):s=e[5],s};var au="ContextMenu",[ME,qL]=d3(au,[c3]),Gt=c3(),[OE,k0]=ME(au),S0=t=>{const{__scopeContextMenu:e,children:n,onOpenChange:o,dir:r,modal:s=!0}=t,[a,i]=O.useState(!1),l=Gt(e),d=Yo(o),u=O.useCallback(h=>{i(h),d(h)},[d]);return c.jsx(OE,{scope:e,open:a,onOpenChange:u,modal:s,children:c.jsx(mD,{...l,dir:r,open:a,onOpenChange:u,modal:s,children:n})})};S0.displayName=au;var N0="ContextMenuTrigger",j0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,disabled:o=!1,...r}=t,s=k0(N0,n),a=Gt(n),i=O.useRef({x:0,y:0}),l=O.useRef({getBoundingClientRect:()=>DOMRect.fromRect({width:0,height:0,...i.current})}),d=O.useRef(0),u=O.useCallback(()=>window.clearTimeout(d.current),[]),h=f=>{i.current={x:f.clientX,y:f.clientY},s.onOpenChange(!0)};return O.useEffect(()=>u,[u]),O.useEffect(()=>{o&&u()},[o,u]),c.jsxs(c.Fragment,{children:[c.jsx(oD,{...a,virtualRef:l}),c.jsx(bs.span,{"data-state":s.open?"open":"closed","data-disabled":o?"":void 0,...r,ref:e,style:{WebkitTouchCallout:"none",...t.style},onContextMenu:o?t.onContextMenu:In(t.onContextMenu,f=>{u(),h(f),f.preventDefault()}),onPointerDown:o?t.onPointerDown:In(t.onPointerDown,el(f=>{u(),d.current=window.setTimeout(()=>h(f),700)})),onPointerMove:o?t.onPointerMove:In(t.onPointerMove,el(u)),onPointerCancel:o?t.onPointerCancel:In(t.onPointerCancel,el(u)),onPointerUp:o?t.onPointerUp:In(t.onPointerUp,el(u))})]})});j0.displayName=N0;var C0=t=>{const{__scopeContextMenu:e,...n}=t,o=Gt(e);return c.jsx(pD,{...o,...n})};C0.displayName="ContextMenuPortal";var E0="ContextMenuContent",_0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=k0(E0,n),s=Gt(n),a=O.useRef(!1);return c.jsx(rD,{...s,...o,ref:e,side:"right",sideOffset:2,align:"start",onCloseAutoFocus:i=>{var l;(l=t.onCloseAutoFocus)==null||l.call(t,i),!i.defaultPrevented&&a.current&&i.preventDefault(),a.current=!1},onInteractOutside:i=>{var l;(l=t.onInteractOutside)==null||l.call(t,i),i.defaultPrevented||r.modal||(a.current=!0)},style:{...t.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)"}})});_0.displayName=E0,O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(sD,{...r,...o,ref:e})}).displayName="ContextMenuGroup";var I0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(aD,{...r,...o,ref:e})});I0.displayName="ContextMenuLabel";var A0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(nD,{...r,...o,ref:e})});A0.displayName="ContextMenuItem";var T0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(iD,{...r,...o,ref:e})});T0.displayName="ContextMenuCheckboxItem",O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(lD,{...r,...o,ref:e})}).displayName="ContextMenuRadioGroup";var M0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(cD,{...r,...o,ref:e})});M0.displayName="ContextMenuRadioItem";var O0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(dD,{...r,...o,ref:e})});O0.displayName="ContextMenuItemIndicator";var D0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(tD,{...r,...o,ref:e})});D0.displayName="ContextMenuSeparator",O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(uD,{...r,...o,ref:e})}).displayName="ContextMenuArrow";var P0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(hD,{...r,...o,ref:e})});P0.displayName="ContextMenuSubTrigger";var R0=O.forwardRef((t,e)=>{const{__scopeContextMenu:n,...o}=t,r=Gt(n);return c.jsx(fD,{...r,...o,ref:e,style:{...t.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 el(t){return e=>e.pointerType!=="mouse"?t(e):void 0}R0.displayName="ContextMenuSubContent";var L0=_0,F0=I0,z0=A0,B0=T0,U0=M0,$0=O0,V0=D0,H0=P0,W0=R0;const q0=S0,G0=j0,DE=bD(C0);O.forwardRef((t,e)=>{const n=H.c(14);let o,r,s,a,i,l,d;return n[0]!==t?({className:r,inset:s,children:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==r||n[6]!==s?(i=yD({className:r,inset:s}),n[5]=r,n[6]=s,n[7]=i):i=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(kD,{className:"ml-auto h-4 w-4"}),n[8]=l):l=n[8],n[9]!==o||n[10]!==a||n[11]!==e||n[12]!==i?(d=c.jsxs(H0,{ref:e,className:i,...a,children:[o,l]}),n[9]=o,n[10]=a,n[11]=e,n[12]=i,n[13]=d):d=n[13],d}).displayName=H0.displayName;const Y0="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";O.forwardRef((t,e)=>{const n=H.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=ge(u3({subcontent:!0}),Y0,o),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=c.jsx(W0,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a}).displayName=W0.displayName;const iu=O.forwardRef((t,e)=>{const n=H.c(15);let o,r,s;n[0]!==t?({className:o,scrollable:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s;let i;n[4]!==o||n[5]!==a?(i=ge(u3(),Y0,a&&"overflow-auto",o),n[4]=o,n[5]=a,n[6]=i):i=n[6];const l=a?"calc(var(--radix-context-menu-content-available-height) - 30px)":void 0;let d,u;return n[7]!==r.style||n[8]!==l?(d={...r.style,maxHeight:l},n[7]=r.style,n[8]=l,n[9]=d):d=n[9],n[10]!==r||n[11]!==e||n[12]!==i||n[13]!==d?(u=c.jsx(DE,{children:c.jsx(vD,{children:c.jsx(L0,{ref:e,className:i,style:d,...r})})}),n[10]=r,n[11]=e,n[12]=i,n[13]=d,n[14]=u):u=n[14],u});iu.displayName=L0.displayName;const Zs=O.forwardRef((t,e)=>{const n=H.c(13);let o,r,s,a,i,l;return n[0]!==t?({className:o,inset:r,variant:a,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==o||n[6]!==r||n[7]!==a?(i=xD({className:o,inset:r,variant:a}),n[5]=o,n[6]=r,n[7]=a,n[8]=i):i=n[8],n[9]!==s||n[10]!==e||n[11]!==i?(l=c.jsx(z0,{ref:e,className:i,...s}),n[9]=s,n[10]=e,n[11]=i,n[12]=l):l=n[12],l});Zs.displayName=z0.displayName,O.forwardRef((t,e)=>{const n=H.c(15);let o,r,s,a,i,l,d,u;return n[0]!==t?({className:s,children:r,checked:o,...a}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a):(o=n[1],r=n[2],s=n[3],a=n[4]),n[5]!==s?(i=vc({className:s}),n[5]=s,n[6]=i):i=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=vc(),n[7]=l):l=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx("span",{className:l,children:c.jsx($0,{children:c.jsx(SD,{className:"h-4 w-4"})})}),n[8]=d):d=n[8],n[9]!==o||n[10]!==r||n[11]!==a||n[12]!==e||n[13]!==i?(u=c.jsxs(B0,{ref:e,className:i,checked:o,...a,children:[d,r]}),n[9]=o,n[10]=r,n[11]=a,n[12]=e,n[13]=i,n[14]=u):u=n[14],u}).displayName=B0.displayName,O.forwardRef((t,e)=>{const n=H.c(13);let o,r,s,a,i,l,d;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=vc({className:r}),n[4]=r,n[5]=a):a=n[5],n[6]===Symbol.for("react.memo_cache_sentinel")?(i=vc(),n[6]=i):i=n[6],n[7]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx("span",{className:i,children:c.jsx($0,{children:c.jsx(ND,{className:"h-4 w-4 fill-current"})})}),n[7]=l):l=n[7],n[8]!==o||n[9]!==s||n[10]!==e||n[11]!==a?(d=c.jsxs(U0,{ref:e,className:a,...s,children:[l,o]}),n[8]=o,n[9]=s,n[10]=e,n[11]=a,n[12]=d):d=n[12],d}).displayName=U0.displayName,O.forwardRef((t,e)=>{const n=H.c(11);let o,r,s,a,i;return n[0]!==t?({className:o,inset:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==o||n[5]!==r?(a=wD({className:o,inset:r}),n[4]=o,n[5]=r,n[6]=a):a=n[6],n[7]!==s||n[8]!==e||n[9]!==a?(i=c.jsx(F0,{ref:e,className:a,...s}),n[7]=s,n[8]=e,n[9]=a,n[10]=i):i=n[10],i}).displayName=F0.displayName;const K0=O.forwardRef((t,e)=>{const n=H.c(9);let o,r,s,a;return n[0]!==t?({className:o,...r}=t,n[0]=t,n[1]=o,n[2]=r):(o=n[1],r=n[2]),n[3]!==o?(s=ge(gD({className:o})),n[3]=o,n[4]=s):s=n[4],n[5]!==r||n[6]!==e||n[7]!==s?(a=c.jsx(V0,{ref:e,className:s,...r}),n[5]=r,n[6]=e,n[7]=s,n[8]=a):a=n[8],a});K0.displayName=V0.displayName;const X0=t=>{const e=H.c(20),{connectionState:n,onClick:o,tooltipContent:r}=t;let s;e[0]!==n||e[1]!==r?(s=cc(n)||r,e[0]=n,e[1]=r,e[2]=s):s=e[2];const a=s;let i;e[3]!==a||e[4]!==n?(i=Xn(n)?a:c.jsxs("div",{className:"flex flex-col gap-4",children:[c.jsx("div",{children:a}),c.jsx("div",{className:"text-xs text-muted-foreground font-medium pt-1 -mt-2 border-t border-border",children:"Right-click for cell types"})]}),e[3]=a,e[4]=n,e[5]=i):i=e[5];const l=i;let d,u,h,f,m,x;return e[6]!==o?(d=()=>o==null?void 0:o({code:""}),e[6]=o,e[7]=d):d=e[7],e[8]!==n?(u=ge("shoulder-button hover-action",Xn(n)&&" inactive-button"),e[8]=n,e[9]=u):u=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Ko,{strokeWidth:1.8}),e[10]=h):h=e[10],e[11]!==d||e[12]!==u?(f=c.jsx(rn,{onClick:d,className:u,onMouseDown:Dn.preventFocus,shape:"circle",size:"small",color:"hint-green","data-testid":"create-cell-button",children:h}),e[11]=d,e[12]=u,e[13]=f):f=e[13],e[14]!==l||e[15]!==f?(m=c.jsx(Ne,{content:l,children:f}),e[14]=l,e[15]=f,e[16]=m):m=e[16],e[17]!==o||e[18]!==m?(x=c.jsx(PE,{onClick:o,children:m}),e[17]=o,e[18]=m,e[19]=x):x=e[19],x},PE=t=>{const e=H.c(26),{children:n,onClick:o}=t,{createNewCell:r}=it();if(!o)return n;let s,a,i,l,d,u,h,f,m,x,g,p;return e[0]!==n?(s=c.jsx(G0,{children:n}),e[0]=n,e[1]=s):s=e[1],e[2]!==o?(a=b=>{b.stopPropagation(),o({code:""})},e[2]=o,e[3]=a):a=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx("div",{className:"mr-3 text-muted-foreground",children:c.jsx(Yl,{})}),e[4]=i):i=e[4],e[5]!==a?(l=c.jsxs(Zs,{onSelect:a,children:[i,"Python cell"]},"python"),e[5]=a,e[6]=l):l=e[6],e[7]!==r||e[8]!==o?(d=b=>{b.stopPropagation(),qn({autoInstantiate:!0,createNewCell:r}),o({code:new La().defaultCode,hideCode:!0})},e[7]=r,e[8]=o,e[9]=d):d=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("div",{className:"mr-3 text-muted-foreground",children:c.jsx(Gl,{})}),e[10]=u):u=e[10],e[11]!==d?(h=c.jsxs(Zs,{onSelect:d,children:[u,"Markdown cell"]},"markdown"),e[11]=d,e[12]=h):h=e[12],e[13]!==r||e[14]!==o?(f=b=>{b.stopPropagation(),qn({autoInstantiate:!0,createNewCell:r}),o({code:new wc().defaultCode})},e[13]=r,e[14]=o,e[15]=f):f=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx("div",{className:"mr-3 text-muted-foreground",children:c.jsx(Wo,{size:13,strokeWidth:1.5})}),e[16]=m):m=e[16],e[17]!==f?(x=c.jsxs(Zs,{onSelect:f,children:[m,"SQL cell"]},"sql"),e[17]=f,e[18]=x):x=e[18],e[19]!==l||e[20]!==h||e[21]!==x?(g=c.jsxs(iu,{children:[l,h,x]}),e[19]=l,e[20]=h,e[21]=x,e[22]=g):g=e[22],e[23]!==s||e[24]!==g?(p=c.jsxs(q0,{children:[s,g]}),e[23]=s,e[24]=g,e[25]=p):p=e[25],p},J0=G.memo(G.forwardRef((t,e)=>{const n=H.c(34);let o,r,s;n[0]!==t?({children:o,showTooltip:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0||s,[i,l]=O.useState(!1);let d;n[4]!==r?(d={cell:r},n[4]=r,n[5]=d):d=n[5];const u=nd(d),h=CD();let f,m,x,g,p,b;if(n[6]===Symbol.for("react.memo_cache_sentinel")?(f=()=>({toggle:()=>l(RE)}),n[6]=f):f=n[6],O.useImperativeHandle(e,f),n[7]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(Ma,{placeholder:"Search actions...",className:"h-6 m-1"}),n[7]=m):m=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(Ql,{children:"No results"}),n[8]=x):x=n[8],n[9]!==u){let C;n[11]!==u.length?(C=(_,A)=>c.jsxs(O.Fragment,{children:[c.jsx(Vf,{children:_.map(I=>{let P=c.jsxs("div",{className:"flex items-center flex-1",children:[I.icon&&c.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:I.icon}),c.jsx("div",{className:"flex-1",children:I.label}),c.jsxs("div",{className:"flex-shrink-0 text-sm",children:[I.hotkey&&h3(I.hotkey),I.rightElement]})]});return I.tooltip&&(P=c.jsx(Ne,{content:I.tooltip,delayDuration:100,children:P})),c.jsx(Gn,{className:ge(I.disabled&&"!opacity-50"),onSelect:()=>{I.disableClick||I.disabled||(I.handle(),l(!1))},variant:I.variant,children:P},I.label)})},A),A<u.length-1&&c.jsx(Ek,{})]},A),n[11]=u.length,n[12]=C):C=n[12],g=u.map(C),n[9]=u,n[10]=g}else g=n[10];n[13]!==g?(p=c.jsxs(ic,{children:[m,c.jsxs(xm,{children:[x,g]})]}),n[13]=g,n[14]=p):p=n[14],n[15]!==h||n[16]!==p?(b=c.jsx(hs,{className:"w-[300px] p-0 pt-1 overflow-auto",scrollable:!0,...h,children:p}),n[15]=h,n[16]=p,n[17]=b):b=n[17];const y=b;if(!a){let C,_;return n[18]!==o?(C=c.jsx(ys,{asChild:!0,children:o}),n[18]=o,n[19]=C):C=n[19],n[20]!==y||n[21]!==i||n[22]!==C?(_=c.jsxs(gr,{open:i,onOpenChange:l,children:[C,y]}),n[20]=y,n[21]=i,n[22]=C,n[23]=_):_=n[23],_}let v;n[24]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsx(ED,{tabIndex:-1,children:Ht("cell.cellActions")}),n[24]=v):v=n[24];const w=!i&&v;let S,N,j;return n[25]!==o?(S=c.jsx(_D,{children:c.jsx(ys,{className:"flex",children:o})}),n[25]=o,n[26]=S):S=n[26],n[27]!==w||n[28]!==S?(N=c.jsxs(ID,{delayDuration:200,disableHoverableContent:!0,children:[w,S]}),n[27]=w,n[28]=S,n[29]=N):N=n[29],n[30]!==y||n[31]!==i||n[32]!==N?(j=c.jsxs(gr,{open:i,onOpenChange:l,children:[N,y]}),n[30]=y,n[31]=i,n[32]=N,n[33]=j):j=n[33],j})),Z0=G.memo(t=>{const e=H.c(5),{children:n,cellId:o}=t;let r,s;e[0]!==o?(s=jD(o),e[0]=o,e[1]=s):s=e[1],r=s;const a=Ie(r);if(!a)return null;let i;return e[2]!==n||e[3]!==a?(i=c.jsx(J0,{showTooltip:!1,...a,children:n}),e[2]=n,e[3]=a,e[4]=i):i=e[4],i});function RE(t){return!t}Z0.displayName="ConnectionCellActionsDropdown";const Q0=t=>{const e=H.c(32);let n,o,r;e[0]!==t?({children:n,...o}=t,e[0]=t,e[1]=n,e[2]=o):(n=e[1],o=e[2]),e[3]!==o?(r={cell:o},e[3]=o,e[4]=r):r=e[4];const s=nd(r),[a,i]=G.useState(),l=!!a;let d,u,h,f,m,x,g,p,b,y;if(e[5]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(Ca,{size:13,strokeWidth:1.5}),e[5]=d):d=e[5],e[6]!==o?(u=async()=>{var S;if((S=window.getSelection())==null?void 0:S.toString())return void document.execCommand("copy");const w=document.getElementById(bk.create(o.cellId));w?await nn(w.textContent??""):ht.warn("cell-context-menu: output not found")},e[6]=o,e[7]=u):u=e[7],e[8]!==s||e[9]!==n||e[10]!==a||e[11]!==o||e[12]!==l||e[13]!==u){const v=[{label:"Copy",hidden:l,icon:d,handle:u},{label:"Cut",hidden:!!a,icon:c.jsx(Kc,{size:13,strokeWidth:1.5}),handle:LE},{label:"Paste",hidden:!!a,icon:c.jsx(qm,{size:13,strokeWidth:1.5}),handle:async()=>{const{getEditorView:N}=o,j=N();if(j)try{const C=await navigator.clipboard.readText();if(C){const{from:_,to:A}=j.state.selection.main,I=j.state.update({changes:{from:_,to:A,insert:C}});j.dispatch(I)}}catch(C){const _=C;ht.error("Failed to paste from clipboard",_),AD({command:"paste"})}}},{label:"Copy image",hidden:!a,icon:c.jsx(Bc,{size:13,strokeWidth:1.5}),handle:async()=>{if(a){const N=await fetch(a.src),j=await N.blob(),C=new ClipboardItem({[j.type]:j});await navigator.clipboard.write([C]).then(FE).catch(zE)}}},{icon:c.jsx(Rm,{size:13,strokeWidth:1.5}),label:"Download image",hidden:!a,handle:()=>{if(a){const N=document.createElement("a");N.download="image.png",N.href=a.src,N.click()}}},{label:"Go to Definition",icon:c.jsx(MD,{size:13,strokeWidth:1.5}),handle:()=>{const{getEditorView:N}=o,j=N();j&&TD(j)}}],w=[v,...s];let S;f=q0,e[20]===Symbol.for("react.memo_cache_sentinel")?(S=N=>{N.target instanceof HTMLImageElement?i(N.target):i(void 0)},e[20]=S):S=e[20],e[21]!==n?(p=c.jsx(G0,{onContextMenu:S,asChild:!0,children:n}),e[21]=n,e[22]=p):p=e[22],h=iu,m="w-[300px]",x=!0,g=w.map((N,j)=>c.jsxs(O.Fragment,{children:[N.map(BE),j<w.length-1&&c.jsx(K0,{})]},j)),e[8]=s,e[9]=n,e[10]=a,e[11]=o,e[12]=l,e[13]=u,e[14]=h,e[15]=f,e[16]=m,e[17]=x,e[18]=g,e[19]=p}else h=e[14],f=e[15],m=e[16],x=e[17],g=e[18],p=e[19];return e[23]!==h||e[24]!==m||e[25]!==x||e[26]!==g?(b=c.jsx(h,{className:m,scrollable:x,children:g}),e[23]=h,e[24]=m,e[25]=x,e[26]=g,e[27]=b):b=e[27],e[28]!==f||e[29]!==p||e[30]!==b?(y=c.jsxs(f,{children:[p,b]}),e[28]=f,e[29]=p,e[30]=b,e[31]=y):y=e[31],y};function LE(){document.execCommand("cut")}function FE(){Xe({title:"Copied image to clipboard"})}function zE(t){Xe({title:"Failed to copy image to clipboard. Try downloading instead.",description:t.message}),ht.error("Failed to copy image to clipboard",t)}function BE(t){if(t.hidden)return null;let e=c.jsxs("div",{className:"flex items-center flex-1",children:[t.icon&&c.jsx("div",{className:"mr-2 w-5 text-muted-foreground",children:t.icon}),c.jsx("div",{className:"flex-1",children:t.label}),c.jsxs("div",{className:"flex-shrink-0 text-sm",children:[t.hotkey&&h3(t.hotkey),t.rightElement]})]});return t.tooltip&&(e=c.jsx(Ne,{delayDuration:100,content:t.tooltip,children:e})),c.jsx(Zs,{className:t.disabled?"!opacity-50":"",onSelect:n=>{t.disableClick||t.disabled||t.handle(n)},variant:t.variant,children:e},t.label)}if(AS)TS(UL),AS();else{const t=await bm(()=>import("./loro_wasm_bg-C3hKWL9L.js").then(async e=>(await e.__tla,e)).then(e=>e.w),[],import.meta.url);TS(new WebAssembly.Instance(t.default,{"./loro_wasm_bg.js":BL}).exports)}const UE=["Map","Text","List","Tree","MovableList","Counter"];function ex(t){if(typeof t!="object"||t==null)return!1;const e=Object.getPrototypeOf(t);return e!=null&&typeof e=="object"&&typeof e.kind=="function"&&UE.includes(t.kind())}MS.prototype.toJsonWithReplacer=function(t){const e=new Set,n=this,o=(a,i)=>{if(typeof i=="string"&&i.startsWith("cid:")&&!e.has(i)){e.add(i);const d=n.getContainerById(i);if(d==null)throw new Error(`ContainerID not found: ${i}`);const u=t(a,d);if(u===d){const h=d.getShallowValue();return typeof h=="object"?r(h):h}if(ex(u))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof u=="object"&&u!=null?r(u):u}if(typeof i=="object"&&i!=null)return r(i);const l=t(a,i);if(ex(l))throw new Error("Using new container is not allowed in toJsonWithReplacer");return l},r=a=>{if(Array.isArray(a))return a.map((l,d)=>o(d,l)).filter(l=>l!==void 0);const i={};for(const[l,d]of Object.entries(a)){const u=o(l,d);u!==void 0&&(i[l]=u)}return i},s=n.getShallowValue();return r(s)};const $E=Ve.baseTheme({".loro-cursor":{position:"absolute",width:"2px",display:"inline-block",height:"1.2em"},".loro-cursor::before":{position:"absolute",top:"1.3em",left:"0",content:"var(--rtc-name)",padding:"2px 6px",fontSize:"12px",borderRadius:"3px",whiteSpace:"nowrap",userSelect:"none",backgroundColor:"inherit",opacity:"0.7"},".loro-selection":{opacity:"0.5"}}),Qs=At.define(),lu=xn.define({create:()=>({remoteCursors:new Map,isCheckout:!1}),update(t,e){for(const n of e.effects)if(n.is(Qs))switch(n.value.type){case"update":{const{peer:o,user:r,cursor:s}=n.value;t.remoteCursors.set(o,{uid:o,cursor:s,user:r});break}case"delete":t.remoteCursors.delete(n.value.peer);break;case"checkout":t.isCheckout=n.value.checkout}return t}}),tx=t=>{const e=t.transactions.flatMap(n=>n.effects).filter(n=>n.is(Qs));return t.docChanged||t.viewportChanged||e.length>0};class tl{constructor(e,n,o,r,s){this.left=e,this.top=n,this.height=o,this.name=r,this.colorClassName=s}draw(){const e=document.createElement("div");return this.adjust(e),e}update(e){return this.adjust(e),!0}adjust(e){e.style.left=`${this.left}px`,e.style.top=`${this.top}px`,e.style.height=`${this.height}px`,e.className=`loro-cursor ${this.colorClassName}`,e.style.setProperty("--rtc-name",`"${this.name}"`)}eq(e){return this.left===e.left&&this.top===e.top&&this.height===e.height&&this.name===e.name}static createCursor(e,n,o,r){const s=tl.calculateAbsoluteCursorPosition(n,e);if(!s)return[];const a=e.scrollDOM.getBoundingClientRect(),i=(e.textDirection===DD.LTR?a.left:a.right-e.scrollDOM.clientWidth)-e.scrollDOM.scrollLeft,l=a.top-e.scrollDOM.scrollTop;return[new tl(s.left-i,s.top-l,s.bottom-s.top,o,r)]}static calculateAbsoluteCursorPosition(e,n){const o=Math.max(0,Math.min(n.state.doc.length,e.anchor));return n.coordsAtPos(o,e.assoc||1)}}const VE=(t,e,n,o)=>{const r=[],{updated:s,added:a}=n;for(const i of[...s,...a]){const l=nx(t,e,i,o);l&&r.push(l)}return r},nx=(t,e,n,o)=>{const r=e.getAllStates()[n];if(!r||n===t.peerIdStr||r.scopeId!==o)return;if(r.type==="delete")return Qs.of({type:"delete",peer:r.uid,scopeId:r.scopeId});const s=OS.decode(r.cursor.anchor),a=t.getCursorPos(s).offset;let i=a;if(r.cursor.head){const l=OS.decode(r.cursor.head);i=t.getCursorPos(l).offset}return Qs.of({type:"update",peer:r.uid,scopeId:r.scopeId,cursor:{anchor:a,head:i},user:r.user})};class HE{constructor(e,n,o,r,s,a,i){this.view=e,this.doc=n,this.user=o,this.awareness=r,this.getTextFromDoc=s,this.scopeId=a,this.getUserId=i,this.sub=void 0,this.sub=this.doc.subscribe(l=>{if(l.by==="local"){const d=[];for(const u of this.awareness.peers()){const h=nx(this.doc,this.awareness,u,this.scopeId);h&&d.push(h)}this.view.dispatch({effects:d})}else l.by==="checkout"&&this.view.dispatch({effects:[Qs.of({type:"checkout",checkout:this.doc.isDetached()})]})})}update(e){if(!e.selectionSet&&!e.focusChanged&&!e.docChanged)return;const n=e.state.selection.main;if(this.view.hasFocus&&!this.doc.isDetached()){const o=qE({doc:this.doc,getTextFromDoc:this.getTextFromDoc,anchor:n.anchor,head:n.head});this.awareness.setLocalState({type:"update",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId,cursor:o,user:this.user})}else this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}destroy(){var e;(e=this.sub)==null||e.call(this),this.awareness.setLocalState({type:"delete",uid:this.getUserId?this.getUserId():this.doc.peerIdStr,scopeId:this.scopeId})}}class WE{constructor(e,n,o,r){this.view=e,this.doc=n,this.awareness=o,this.scopeId=r,this._awarenessListener=void 0;const s=async(a,i)=>{i!=="local"&&this.view.dispatch({effects:VE(this.doc,this.awareness,a,this.scopeId)})};this._awarenessListener=s,this.awareness.addListener(s)}destroy(){this._awarenessListener&&this.awareness.removeListener(this._awarenessListener)}}const qE=({doc:t,getTextFromDoc:e,anchor:n,head:o})=>{var a,i;n===o&&(o=void 0);const r=(a=e(t).getCursor(n))==null?void 0:a.encode();if(!r)throw new Error("cursor head not found");let s;return o!==void 0&&(s=(i=e(t).getCursor(o))==null?void 0:i.encode()),{anchor:r,head:s}},nl=["bg-[var(--amber-6)]","bg-[var(--blue-6)]","bg-[var(--crimson-6)]","bg-[var(--cyan-6)]","bg-[var(--grass-6)]","bg-[var(--gray-6)]","bg-[var(--green-6)]","bg-[var(--lime-6)]","bg-[var(--orange-6)]","bg-[var(--purple-6)]","bg-[var(--red-6)]","bg-[var(--sage-6)]","bg-[var(--sky-6)]","bg-[var(--slate-6)]"],GE=(t,e,n)=>Rn.define(o=>new YE(o,t,e,n)),Tr=mm.define();class YE{constructor(e,n,o,r){this.view=e,this.doc=n,this.docPath=o,this.getTextFromDoc=r,this.sub=void 0,this.isInitDispatch=!1,this.onRemoteUpdate=s=>{if(s.by!=="local")if(s.by!=="checkout"){if(s.by==="import"){const a=[];let i=0;for(const{diff:l,path:d}of s.events){if(d.join("/")!==this.docPath.join("/")||l.type!=="text")continue;const u=l.diff;for(const h of u)h.insert?a.push({from:i,to:i,insert:h.insert}):h.delete?(a.push({from:i,to:i+h.delete}),i+=h.delete):h.retain!=null&&(i+=h.retain);a.length>0&&this.view.dispatch({changes:a,annotations:[Tr.of(this)]})}}}else this.view.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:this.getTextFromDoc(this.doc).toString()}],annotations:[Tr.of(this)]})},this.sub=n.subscribe(this.onRemoteUpdate),Promise.resolve().then(()=>{this.isInitDispatch=!0;const s=this.view.state.doc.toString(),a=this.getTextFromDoc(this.doc);s!==a.toString()&&e.dispatch({changes:[{from:0,to:this.view.state.doc.length,insert:a.toString()}]})})}update(e){if(this.isInitDispatch)return void(this.isInitDispatch=!1);if(!e.docChanged||e.transactions.length>0&&(e.transactions[0].annotation(Tr)===this||e.transactions[0].annotation(Tr)==="undo"))return;let n=0;e.changes.iterChanges((o,r,s,a,i)=>{const l=i.sliceString(0,i.length,`
119
- `);o!==r&&this.getTextFromDoc(this.doc).delete(o+n,r-o),l.length>0&&this.getTextFromDoc(this.doc).insert(o+n,l),n+=l.length-(r-o)}),this.doc.commit()}destroy(){var e;(e=this.sub)==null||e.call(this),this.sub=void 0}}const Yt=ht.get("rtc"),ox=Yt.get("awareness").disabled(),cu="awareness:",Mr=mt(void 0),Rt=new MS,ol=new class{constructor(t,e=3e4){this.listeners=new Set,this.inner=new $L(t,e),this.peer=t,this.timeout=e}apply(t,e="remote"){const{updated:n,added:o}=this.inner.apply(t);this.listeners.forEach(r=>{r({updated:n,added:o,removed:[]},e)}),this.startTimerIfNotEmpty()}setLocalState(t){const e=this.inner.getState(this.peer)==null;this.inner.setLocalState(t),e?this.listeners.forEach(n=>{n({updated:[],added:[this.inner.peer()],removed:[]},"local")}):this.listeners.forEach(n=>{n({updated:[this.inner.peer()],added:[],removed:[]},"local")}),this.startTimerIfNotEmpty()}getLocalState(){return this.inner.getState(this.peer)}getAllStates(){return this.inner.getAllStates()}encode(t){return this.inner.encode(t)}encodeAll(){return this.inner.encodeAll()}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}peers(){return this.inner.peers()}destroy(){clearInterval(this.timer),this.listeners.clear()}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{const t=this.inner.removeOutdated();t.length>0&&this.listeners.forEach(e=>{e({updated:[],added:[],removed:t},"timeout")}),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}(Rt.peerIdStr),du=RD(()=>{Yt.debug("creating websocket");const t=o3().getWsSyncURL(g3()).toString(),e=new gL(t,void 0,{maxRetries:10,debug:!1,startClosed:!0,connectionTimeout:1e4});return Promise.resolve().then(async()=>{await r3(),LD()==="edit"&&e.reconnect()}),e.addEventListener("message",async n=>{const o=n.data,r=await o.arrayBuffer(),s=new Uint8Array(r);if(function(a,i){return new TextDecoder().decode(a.slice(0,i.length))===i}(s,cu)){const a=function(i,l){return i.slice(l.length)}(s,cu);return ol.apply(a),void ox.debug("applied awareness update")}Rt.import(s),Yt.debug("imported doc change. new doc:",Rt.toJSON()),Qe.get(Mr)!==Rt&&Qe.set(Mr,Rt)}),e.addEventListener("open",()=>{Yt.debug("websocket open")}),e.addEventListener("close",n=>{Yt.warn("websocket close",n),Qe.get(Mr)===Rt&&Qe.set(Mr,void 0)}),e});function uu(t,e,n=""){if(Jt())return{extension:[],code:n};const o=Rt.getByPath(`codes/${t}`)!==void 0,r=Rt.getMap("codes").getOrCreateContainer(t,new zm);o||(Yt.log("initializing code for new cell",n),r.insert(0,n));const s={get name(){return Qe.get(x3)||"Anonymous"},get colorClassName(){return(a=>{if(typeof a=="string"){let i=0;for(let l=0;l<a.length;l++)i=(i<<5)-i+a.charCodeAt(l),i=Math.trunc(i);return nl[Math.abs(i)%nl.length]}return nl[a%nl.length]})(this.name)}};return{code:n.toString(),extension:[KE(t),XE(t),JE(Rt,ol,s,()=>r,t),GE(Rt,["codes",t],()=>r)]}}function KE(t){const e=(o,r)=>{const s=o.state.field(bc).type,a=r.toString();a&&a!==s&&(Yt.debug(`[incoming] setting language type: ${s} -> ${a}`),hr(o,{language:a,keepCodeAsIs:!0}))},n=(o,r)=>{const s=o.state.field(vm),a=r.toJSON();Ba(s,a)||o.dispatch({effects:[m3.of(a)],annotations:[Tr.of(!0)]})};return Rn.define(o=>{let r;return Promise.resolve().then(()=>{const s=Rt.getByPath(`languages/${t}`);if(!s)return void Yt.error("no language container found for cell",t);jo(s instanceof zm,"language type is not a LoroText");const a=Rt.getByPath(`language_metadata/${t}`);a?(jo(a instanceof DS,"language metadata is not a LoroMap"),e(o,s),n(o,a),r=Rt.subscribe(i=>{if(i.origin==="local")return;const l=i.events.some(u=>u.target===s.id),d=i.events.some(u=>u.target===a.id);l&&e(o,s),d&&n(o,a)})):Yt.error("no language metadata container found for cell",t)}),{destroy(){r()}}})}function XE(t){const e=Rt.getMap("languages").getOrCreateContainer(t,new zm),n=Rt.getMap("language_metadata").getOrCreateContainer(t,new DS);return Ve.updateListener.of(o=>{const r=e.toString()!=="";if(!o.docChanged&&r)return;if(!r){const a=ym(o.state).type;hr(o.view,{language:a}),Yt.debug("no initial language, setting default to",a),e.delete(0,e.length),e.insert(0,a),Yt.debug("no initial language metadata, setting default to",o.state.field(vm));const i=o.state.field(vm);for(const l of Object.keys(i))n.set(l,i[l]);return void Rt.commit()}let s=!1;for(const a of o.transactions)if(!a.annotation(Tr)){for(const i of a.effects)if(i.is(PD)&&e.toString()!==i.value.type&&(Yt.debug(`[outgoing] language change: ${e} -> ${i.value.type}`),e.delete(0,e.length),e.insert(0,i.value.type),s=!0),i.is(m3)||i.is(p3)){const l=i.value;i.is(p3)?(Yt.debug("[outgoing] setting language metadata: ",l),n.clear()):Yt.debug("[outgoing] updating language metadata: ",l);for(const d of Object.keys(l))n.set(d,l[d]);s=!0}}s&&Rt.commit()})}function JE(t,e,n,o,r,s){const a=`loro:cell:${r}`;return[lu,f3({above:!0,class:"loro-cursor-layer",update:tx,markers:i=>{const{remoteCursors:l,isCheckout:d}=i.state.field(lu);return d?[]:[...l.values()].flatMap(u=>{var f,m;const h=Kn.cursor(u.cursor.anchor);return tl.createCursor(i,h,((f=u.user)==null?void 0:f.name)||"unknown",((m=u.user)==null?void 0:m.colorClassName)||"")})}}),f3({above:!1,class:"loro-selection-layer",update:tx,markers:i=>{const{remoteCursors:l,isCheckout:d}=i.state.field(lu);return d?[]:[...l.entries()].filter(([,u])=>u.cursor.head!==void 0&&u.cursor.anchor!==u.cursor.head).flatMap(([,u])=>{var f;const h=Kn.range(u.cursor.anchor,u.cursor.head);return OD.forRange(i,`loro-selection ${((f=u.user)==null?void 0:f.colorClassName)||""}`,h)})}}),Rn.define(i=>new HE(i,t,n,e,o,a,s)),Rn.define(i=>new WE(i,t,e,a)),$E]}function rl(...t){return e=>{t.forEach(n=>{typeof n=="function"?n(e):n!=null&&(n.current=e)})}}kc()&&du(),Rt.subscribeLocalUpdates(t=>{Yt.debug("local update, sending to server"),du().send(t)}),ol.addListener((t,e)=>{const n=[...t.added,...t.removed,...t.updated];e==="local"&&(ox.debug("awareness changes",n),du().send(function(o,r){const s=new TextEncoder().encode(o);return new Uint8Array([...s,...r])}(cu,ol.encode(n))))});var rx={modified:{doc:""},original:{doc:""}},sx=O.createContext(rx);function ZE(t,e){return yt({},t,e,{modified:yt({},t.modified,e.modified),original:yt({},t.original,e.original)})}var hu=()=>O.useContext(sx),QE=t=>{var{children:e,theme:n}=t,[o,r]=O.useReducer(ZE,yt({},rx,{theme:n}));return O.useEffect(()=>r({theme:n}),[n]),c.jsx(sx.Provider,{value:yt({},o,{dispatch:r}),children:e})},e5=["extensions","value","selection","onChange"],ax=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Ja(t,e5),{theme:a,dispatch:i}=hu(),l=vs(yt({},s,{theme:a}));return O.useEffect(()=>i({original:{doc:n,selection:o,extensions:[...l,...e]},originalExtension:{onChange:r,option:s,extension:[e]}}),[t]),null};ax.displayName="CodeMirrorMerge.Original";var t5=["extensions","value","selection","onChange"],ix=t=>{var{extensions:e=[],value:n,selection:o,onChange:r}=t,s=Ja(t,t5),{theme:a,dispatch:i}=hu(),l=vs(yt({},s,{theme:a}));return O.useEffect(()=>{i({modified:{doc:n,selection:o,extensions:[...l,...e]},modifiedExtension:{onChange:r,option:s,extension:[e]}})},[t]),null};ix.displayName="CodeMirrorMerge.Modified";class Ct{constructor(e,n,o,r){this.fromA=e,this.toA=n,this.fromB=o,this.toB=r}offset(e,n=e){return new Ct(this.fromA+e,this.toA+e,this.fromB+n,this.toB+n)}}function ar(t,e,n,o,r,s){if(t==o)return[];let a=gu(t,e,n,o,r,s),i=xu(t,e+a,n,o,r+a,s),l=(n-=i)-(e+=a),d=(s-=i)-(r+=a);if(!l||!d)return[new Ct(e,n,r,s)];if(l>d){let h=t.slice(e,n).indexOf(o.slice(r,s));if(h>-1)return[new Ct(e,e+h,r,r),new Ct(e+h+d,n,s,s)]}else if(d>l){let h=o.slice(r,s).indexOf(t.slice(e,n));if(h>-1)return[new Ct(e,e,r,r+h),new Ct(n,n,r+h+l,s)]}if(l==1||d==1)return[new Ct(e,n,r,s)];let u=dx(t,e,n,o,r,s);if(u){let[h,f,m]=u;return ar(t,e,h,o,r,f).concat(ar(t,h+m,n,o,f+m,s))}return function(h,f,m,x,g,p){let b=m-f,y=p-g;if(ea<1e9&&Math.min(b,y)>16*ea||ta>0&&Date.now()>ta)return Math.min(b,y)>64*ea?[new Ct(f,m,g,p)]:ux(h,f,m,x,g,p);let v=Math.ceil((b+y)/2);mu.reset(v),pu.reset(v);let w=(C,_)=>h.charCodeAt(f+C)==x.charCodeAt(g+_),S=(C,_)=>h.charCodeAt(m-C-1)==x.charCodeAt(p-_-1),N=(b-y)%2!=0?pu:null,j=N?null:mu;for(let C=0;C<v;C++){if(C>ea||ta>0&&!(63&C)&&Date.now()>ta)return ux(h,f,m,x,g,p);let _=mu.advance(C,b,y,v,N,!1,w)||pu.advance(C,b,y,v,j,!0,S);if(_)return n5(h,f,m,f+_[0],x,g,p,g+_[1])}return[new Ct(f,m,g,p)]}(t,e,n,o,r,s)}let ea=1e9,ta=0,fu=!1;class lx{constructor(){this.vec=[]}reset(e){this.len=e<<1;for(let n=0;n<this.len;n++)this.vec[n]=-1;this.vec[e+1]=0,this.start=this.end=0}advance(e,n,o,r,s,a,i){for(let l=-e+this.start;l<=e-this.end;l+=2){let d=r+l,u=l==-e||l!=e&&this.vec[d-1]<this.vec[d+1]?this.vec[d+1]:this.vec[d-1]+1,h=u-l;for(;u<n&&h<o&&i(u,h);)u++,h++;if(this.vec[d]=u,u>n)this.end+=2;else if(h>o)this.start+=2;else if(s){let f=r+(n-o)-l;if(f>=0&&f<this.len&&s.vec[f]!=-1){if(a){let m=s.vec[f];if(m>=n-u)return[m,r+m-f]}else if(u>=n-s.vec[f])return[u,h]}}}return null}}const mu=new lx,pu=new lx;function n5(t,e,n,o,r,s,a,i){let l=!1;return Or(t,o)||++o!=n||(l=!0),Or(r,i)||++i!=a||(l=!0),l?[new Ct(e,n,s,a)]:ar(t,e,o,r,s,i).concat(ar(t,o,n,r,i,a))}function cx(t,e){let n=1,o=Math.min(t,e);for(;n<o;)n<<=1;return n}function gu(t,e,n,o,r,s){if(e==n||e==s||t.charCodeAt(e)!=o.charCodeAt(r))return 0;let a=cx(n-e,s-r);for(let i=e,l=r;;){let d=i+a,u=l+a;if(d>n||u>s||t.slice(i,d)!=o.slice(l,u)){if(a==1)return i-e-(Or(t,i)?0:1);a>>=1}else{if(d==n||u==s)return d-e;i=d,l=u}}}function xu(t,e,n,o,r,s){if(e==n||r==s||t.charCodeAt(n-1)!=o.charCodeAt(s-1))return 0;let a=cx(n-e,s-r);for(let i=n,l=s;;){let d=i-a,u=l-a;if(d<e||u<r||t.slice(d,i)!=o.slice(u,l)){if(a==1)return n-i-(Or(t,i)?0:1);a>>=1}else{if(d==e||u==r)return n-d;i=d,l=u}}}function bu(t,e,n,o,r,s,a,i){let l=o.slice(r,s),d=null;for(;;){if(d||a<i)return d;for(let u=e+a;;){Or(t,u)||u++;let h=u+a;if(Or(t,h)||(h+=h==u+1?1:-1),h>=n)break;let f=t.slice(u,h),m=-1;for(;(m=l.indexOf(f,m+1))!=-1;){let x=gu(t,h,n,o,r+m+f.length,s),g=xu(t,e,u,o,r,r+m),p=f.length+x+g;(!d||d[2]<p)&&(d=[u-g,r+m-g,p])}u=h}if(i<0)return d;a>>=1}}function dx(t,e,n,o,r,s){let a=n-e,i=s-r;if(a<i){let l=dx(o,r,s,t,e,n);return l&&[l[1],l[0],l[2]]}return a<4||2*i<a?null:bu(t,e,n,o,r,s,Math.floor(a/4),-1)}function ux(t,e,n,o,r,s){fu=!0;let a,i=n-e,l=s-r;if(i<l){let f=bu(o,r,s,t,e,n,Math.floor(i/6),50);a=f&&[f[1],f[0],f[2]]}else a=bu(t,e,n,o,r,s,Math.floor(l/6),50);if(!a)return[new Ct(e,n,r,s)];let[d,u,h]=a;return ar(t,e,d,o,r,u).concat(ar(t,d+h,n,o,u+h,s))}function hx(t,e){for(let n=1;n<t.length;n++){let o=t[n-1],r=t[n];o.toA>r.fromA-e&&o.toB>r.fromB-e&&(t[n-1]=new Ct(o.fromA,r.toA,o.fromB,r.toB),t.splice(n--,1))}}let ir;try{ir=new RegExp("[\\p{Alphabetic}\\p{Number}]","u")}catch{}function fx(t){return t>48&&t<58||t>64&&t<91||t>96&&t<123}function mx(t,e){if(e==t.length)return 0;let n=t.charCodeAt(e);return n<192?fx(n)?1:0:ir?wx(n)&&e!=t.length-1?ir.test(t.slice(e,e+2))?2:0:ir.test(String.fromCharCode(n))?1:0:0}function px(t,e){if(!e)return 0;let n=t.charCodeAt(e-1);return n<192?fx(n)?1:0:ir?kx(n)&&e!=1?ir.test(t.slice(e-2,e))?2:0:ir.test(String.fromCharCode(n))?1:0:0}const gx=8;function xx(t,e,n){if(e==t.length||!px(t,e))return e;for(let o=e,r=e+n,s=0;s<gx;s++){let a=mx(t,o);if(!a||o+a>r)return o;o+=a}return e}function bx(t,e,n){if(!e||!mx(t,e))return e;for(let o=e,r=e-n,s=0;s<gx;s++){let a=px(t,o);if(!a||o-a<r)return o;o-=a}return e}function yx(t,e,n){for(;e!=n;e--)if(t.charCodeAt(e-1)==10)return e;return-1}function vx(t,e,n){for(;e!=n;e++)if(t.charCodeAt(e)==10)return e;return-1}const wx=t=>t>=55296&&t<=56319,kx=t=>t>=56320&&t<=57343;function Or(t,e){return!e||e==t.length||!wx(t.charCodeAt(e-1))||!kx(t.charCodeAt(e))}function o5(t,e,n){var o;return ea=((o=n==null?void 0:n.scanLimit)!==null&&o!==void 0?o:1e9)>>1,ta=n!=null&&n.timeout?Date.now()+n.timeout:0,fu=!1,function(r,s,a){for(;;){hx(a,1);let i=!1;for(let l=0;l<a.length;l++){let d,u,h=a[l];(d=gu(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[l]=new Ct(h.fromA+d,h.toA,h.fromB+d,h.toB)),(u=xu(r,h.fromA,h.toA,s,h.fromB,h.toB))&&(h=a[l]=new Ct(h.fromA,h.toA-u,h.fromB,h.toB-u));let f=h.toA-h.fromA,m=h.toB-h.fromB;if(f&&m)continue;let x=h.fromA-(l?a[l-1].toA:0),g=(l<a.length-1?a[l+1].fromA:r.length)-h.toA;if(!x||!g)continue;let p=f?r.slice(h.fromA,h.toA):s.slice(h.fromB,h.toB);x<=p.length&&r.slice(h.fromA-x,h.fromA)==p.slice(p.length-x)?(a[l]=new Ct(h.fromA-x,h.toA-x,h.fromB-x,h.toB-x),i=!0):g<=p.length&&r.slice(h.toA,h.toA+g)==p.slice(0,g)&&(a[l]=new Ct(h.fromA+g,h.toA+g,h.fromB+g,h.toB+g),i=!0)}if(!i)break}return a}(t,e,ar(t,0,t.length,e,0,e.length))}function Sx(){return!fu}function Nx(t,e,n){return function(o,r,s){for(let a=0,i=0;i<o.length;i++){let l=o[i],d=l.toA-l.fromA,u=l.toB-l.fromB;if(d&&u||d>3||u>3){let h=i==o.length-1?r.length:o[i+1].fromA,f=l.fromA-a,m=h-l.toA,x=bx(r,l.fromA,f),g=xx(r,l.toA,m),p=l.fromA-x,b=g-l.toA;if((!d||!u)&&p&&b){let y=Math.max(d,u),[v,w,S]=d?[r,l.fromA,l.toA]:[s,l.fromB,l.toB];y>p&&r.slice(x,l.fromA)==v.slice(S-p,S)?(l=o[i]=new Ct(x,x+d,l.fromB-p,l.toB-p),x=l.fromA,g=xx(r,l.toA,h-l.toA)):y>b&&r.slice(l.toA,g)==v.slice(w,w+b)&&(l=o[i]=new Ct(g-d,g,l.fromB+b,l.toB+b),g=l.toA,x=bx(r,l.fromA,l.fromA-a)),p=l.fromA-x,b=g-l.toA}if(p||b)l=o[i]=new Ct(l.fromA-p,l.toA+b,l.fromB-p,l.toB+b);else if(d){if(!u){let y,v=vx(r,l.fromA,l.toA),w=v<0?-1:yx(r,l.toA,l.fromA);v>-1&&(y=v-l.fromA)<=m&&r.slice(l.fromA,v)==r.slice(l.toA,l.toA+y)?l=o[i]=l.offset(y):w>-1&&(y=l.toA-w)<=f&&r.slice(l.fromA-y,l.fromA)==r.slice(w,l.toA)&&(l=o[i]=l.offset(-y))}}else{let y,v=vx(s,l.fromB,l.toB),w=v<0?-1:yx(s,l.toB,l.fromB);v>-1&&(y=v-l.fromB)<=m&&s.slice(l.fromB,v)==s.slice(l.toB,l.toB+y)?l=o[i]=l.offset(y):w>-1&&(y=l.toB-w)<=f&&s.slice(l.fromB-y,l.fromB)==s.slice(w,l.toB)&&(l=o[i]=l.offset(-y))}}a=l.toA}return hx(o,3),o}(o5(t,e,n),t,e)}const zn=xr.define({combine:t=>t[0]}),yu=At.define(),r5=xr.define(),Dr=xn.define({create:t=>null,update(t,e){for(let n of e.effects)n.is(yu)&&(t=n.value);for(let n of e.state.facet(r5))t=n(t,e);return t}});class Pr{constructor(e,n,o,r,s,a=!0){this.changes=e,this.fromA=n,this.toA=o,this.fromB=r,this.toB=s,this.precise=a}offset(e,n){return e||n?new Pr(this.changes,this.fromA+e,this.toA+e,this.fromB+n,this.toB+n,this.precise):this}get endA(){return Math.max(this.fromA,this.toA-1)}get endB(){return Math.max(this.fromB,this.toB-1)}static build(e,n,o){return Ex(Nx(e.toString(),n.toString(),o),e,n,0,0,Sx())}static updateA(e,n,o,r,s){return Ax(Ix(e,r,!0,o.length),e,n,o,s)}static updateB(e,n,o,r,s){return Ax(Ix(e,r,!1,n.length),e,n,o,s)}}function jx(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.to==t&&s.to==e&&t<n.length&&e<o.length?[t+1,e+1]:[r.from,s.from]}function Cx(t,e,n,o){let r=n.lineAt(t),s=o.lineAt(e);return r.from==t&&s.from==e?[t,e]:[r.to+1,s.to+1]}function Ex(t,e,n,o,r,s){let a=[];for(let i=0;i<t.length;i++){let l=t[i],[d,u]=jx(l.fromA+o,l.fromB+r,e,n),[h,f]=Cx(l.toA+o,l.toB+r,e,n),m=[l.offset(-d+o,-u+r)];for(;i<t.length-1;){let x=t[i+1],[g,p]=jx(x.fromA+o,x.fromB+r,e,n);if(g>h+1&&p>f+1)break;m.push(x.offset(-d+o,-u+r)),[h,f]=Cx(x.toA+o,x.toB+r,e,n),i++}a.push(new Pr(m,d,Math.max(d,h),u,Math.max(u,f),s))}return a}const sl=1e3;function _x(t,e,n,o){let r=0,s=t.length;for(;;){if(r==s){let u=0,h=0;r&&({toA:u,toB:h}=t[r-1]);let f=e-(n?u:h);return[u+f,h+f]}let a=r+s>>1,i=t[a],[l,d]=n?[i.fromA,i.toA]:[i.fromB,i.toB];if(l>e)s=a;else{if(!(d<=e))return o?[i.fromA,i.fromB]:[i.toA,i.toB];r=a+1}}}function Ix(t,e,n,o){let r=[];return e.iterChangedRanges((s,a,i,l)=>{let d=0,u=n?e.length:o,h=0,f=n?o:e.length;s>sl&&([d,h]=_x(t,s-sl,n,!0)),a<e.length-sl&&([u,f]=_x(t,a+sl,n,!1));let m,x=l-i-(a-s),[g,p]=n?[x,0]:[0,x];r.length&&(m=r[r.length-1]).toA>=d?r[r.length-1]={fromA:m.fromA,fromB:m.fromB,toA:u,toB:f,diffA:m.diffA+g,diffB:m.diffB+p}:r.push({fromA:d,toA:u,fromB:h,toB:f,diffA:g,diffB:p})}),r}function Ax(t,e,n,o,r){if(!t.length)return e;let s=[];for(let a=0,i=0,l=0,d=0;;a++){let u=a==t.length?null:t[a],h=u?u.fromA+i:n.length,f=u?u.fromB+l:o.length;for(;d<e.length;){let p=e[d];if(p.toA+i>h||p.toB+l>f)break;s.push(p.offset(i,l)),d++}if(!u)break;let m=u.toA+i+u.diffA,x=u.toB+l+u.diffB,g=Nx(n.sliceString(h,m),o.sliceString(f,x),r);for(let p of Ex(g,n,o,h,f,Sx()))s.push(p);for(i+=u.diffA,l+=u.diffB;d<e.length;){let p=e[d];if(p.fromA+i>m&&p.fromB+l>x)break;d++}}return s}const s5={scanLimit:500},Tx=Rn.fromClass(class{constructor(t){({deco:this.deco,gutter:this.gutter}=Dx(t))}update(t){var e,n;(t.docChanged||t.viewportChanged||(e=t.startState,n=t.state,e.field(Dr,!1)!=n.field(Dr,!1))||function(o,r){return o.facet(zn)!=r.facet(zn)}(t.startState,t.state))&&({deco:this.deco,gutter:this.gutter}=Dx(t.view))}},{decorations:t=>t.deco}),al=Eo.low(zD({class:"cm-changeGutter",markers:t=>{var e;return((e=t.plugin(Tx))===null||e===void 0?void 0:e.gutter)||BD.empty}})),Mx=tt.line({class:"cm-changedLine"}),a5=tt.mark({class:"cm-changedText"}),i5=tt.mark({tagName:"ins",class:"cm-insertedLine"}),l5=tt.mark({tagName:"del",class:"cm-deletedLine"}),Ox=new class extends UD{constructor(){super(...arguments),this.elementClass="cm-changedLineGutter"}};function c5(t,e,n,o,r,s){let a=n?t.fromA:t.fromB,i=n?t.toA:t.toB,l=0;if(a!=i){r.add(a,a,Mx),r.add(a,i,n?l5:i5),s&&s.add(a,a,Ox);for(let d=e.iterRange(a,i-1),u=a;!d.next().done;){if(d.lineBreak){u++,r.add(u,u,Mx),s&&s.add(u,u,Ox);continue}let h=u+d.value.length;if(o)for(;l<t.changes.length;){let f=t.changes[l],m=a+(n?f.fromA:f.fromB),x=a+(n?f.toA:f.toB),g=Math.max(u,m),p=Math.min(h,x);if(g<p&&r.add(g,p,a5),!(x<h))break;l++}u=h}}}function Dx(t){let e=t.state.field(Dr),{side:n,highlightChanges:o,markGutter:r,overrideChunk:s}=t.state.facet(zn),a=n=="a",i=new us,l=r?new us:null,{from:d,to:u}=t.viewport;for(let h of e){if((a?h.fromA:h.fromB)>=u)break;(a?h.toA:h.toB)>d&&(s&&s(t.state,h,i,l)||c5(h,t.state.doc,a,o,i,l))}return{deco:i.finish(),gutter:l&&l.finish()}}class il extends gs{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 ll=At.define({map:(t,e)=>t.map(e)}),na=xn.define({create:()=>tt.none,update:(t,e)=>{for(let n of e.effects)if(n.is(ll))return n.value;return t.map(e.changes)},provide:t=>Ve.decorations.from(t)}),vu=.01;function Px(t,e){if(t.size!=e.size)return!1;let n=t.iter(),o=e.iter();for(;n.value;){if(n.from!=o.from||Math.abs(n.value.spec.widget.height-o.value.spec.widget.height)>1)return!1;n.next(),o.next()}return!0}const wu=At.define({map:(t,e)=>e.mapPos(t)});class d5 extends gs{constructor(e){super(),this.lines=e}eq(e){return this.lines==e.lines}toDOM(e){let n=document.createElement("div");return n.className="cm-collapsedLines",n.textContent=e.state.phrase("$ unchanged lines",this.lines),n.addEventListener("click",o=>{let r=e.posAtDOM(o.target);e.dispatch({effects:wu.of(r)});let{side:s,sibling:a}=e.state.facet(zn);a&&a().dispatch({effects:wu.of(u5(r,e.state.field(Dr),s=="a"))})}),n}ignoreEvent(e){return e instanceof MouseEvent}get estimatedHeight(){return 27}get type(){return"collapsed-unchanged-code"}}function u5(t,e,n){let o=0,r=0;for(let s=0;;s++){let a=s<e.length?e[s]:null;if(!a||(n?a.fromA:a.fromB)>=t)return r+(t-o);[o,r]=n?[a.toA,a.toB]:[a.toB,a.toA]}}const h5=xn.define({create:t=>tt.none,update(t,e){t=t.map(e.changes);for(let n of e.effects)n.is(wu)&&(t=t.update({filter:o=>o!=n.value}));return t},provide:t=>Ve.decorations.from(t)});function Rx({margin:t=3,minSize:e=4}){return h5.init(n=>function(o,r,s){let a=new us,i=o.facet(zn).side=="a",l=o.field(Dr),d=1;for(let u=0;;u++){let h=u<l.length?l[u]:null,f=u?d+r:1,m=h?o.doc.lineAt(i?h.fromA:h.fromB).number-1-r:o.doc.lines,x=m-f+1;if(x>=s&&a.add(o.doc.line(f).from,o.doc.line(m).to,tt.replace({widget:new d5(x),block:!0})),!h)break;d=o.doc.lineAt(Math.min(o.doc.length,i?h.toA:h.toB)).number}return a.finish()}(n,t,e))}const f5=Ve.styleModule.of(new FD({".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"}})),m5=Ve.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, .cm-inlineChangedLine":{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(#22bb22aa, #22bb22aa) bottom/100% 2px no-repeat"},"&dark.cm-merge-b .cm-changedText":{background:"linear-gradient(#88ff88aa, #88ff88aa) bottom/100% 2px no-repeat"},"&.cm-merge-b .cm-deletedText":{background:"#ff000033"},".cm-insertedLine, .cm-deletedLine, .cm-deletedLine del":{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","&:before":{content:'"\u299A"',marginInlineEnd:"7px"},"&:after":{content:'"\u299A"',marginInlineStart:"7px"}},"&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"},".cm-inlineChangedLineGutter":{background:"#75d"}}),Lx=new pm,cl=new pm;class Fx{constructor(e){this.revertDOM=null,this.revertToA=!1,this.revertToLeft=!1,this.measuring=-1,this.diffConf=e.diffConfig||s5;let n=[Eo.low(Tx),m5,f5,na,Ve.updateListener.of(h=>{this.measuring<0&&(h.heightChanged||h.viewportChanged)&&!h.transactions.some(f=>f.effects.some(m=>m.is(ll)))&&this.measure()})],o=[zn.of({side:"a",sibling:()=>this.b,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&o.push(al);let r=Xa.create({doc:e.a.doc,selection:e.a.selection,extensions:[e.a.extensions||[],Ve.editorAttributes.of({class:"cm-merge-a"}),cl.of(o),n]}),s=[zn.of({side:"b",sibling:()=>this.a,highlightChanges:e.highlightChanges!==!1,markGutter:e.gutter!==!1})];e.gutter!==!1&&s.push(al);let a=Xa.create({doc:e.b.doc,selection:e.b.selection,extensions:[e.b.extensions||[],Ve.editorAttributes.of({class:"cm-merge-b"}),cl.of(s),n]});this.chunks=Pr.build(r.doc,a.doc,this.diffConf);let i=[Dr.init(()=>this.chunks),Lx.of(e.collapseUnchanged?Rx(e.collapseUnchanged):[])];r=r.update({effects:At.appendConfig.of(i)}).state,a=a.update({effects:At.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 l=e.orientation||"a-b",d=document.createElement("div");d.className="cm-mergeViewEditor";let u=document.createElement("div");u.className="cm-mergeViewEditor",this.editorDOM.appendChild(l=="a-b"?d:u),this.editorDOM.appendChild(l=="a-b"?u:d),this.a=new Ve({state:r,parent:d,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.a)}),this.b=new Ve({state:a,parent:u,root:e.root,dispatchTransactions:h=>this.dispatch(h,this.b)}),this.setupRevertControls(!!e.revertControls,e.revertControls=="b-to-a",e.renderRevertControl),e.parent&&e.parent.appendChild(this.dom),this.scheduleMeasure()}dispatch(e,n){if(e.some(o=>o.docChanged)){let o=e[e.length-1],r=e.reduce((a,i)=>a.compose(i.changes),Ya.empty(e[0].startState.doc.length));this.chunks=n==this.a?Pr.updateA(this.chunks,o.newDoc,this.b.state.doc,r,this.diffConf):Pr.updateB(this.chunks,this.a.state.doc,o.newDoc,r,this.diffConf),n.update([...e,o.state.update({effects:yu.of(this.chunks)})]);let s=n==this.a?this.b:this.a;s.update([s.state.update({effects:yu.of(this.chunks)})]),this.scheduleMeasure()}else n.update(e)}reconfigure(e){if("diffConfig"in e&&(this.diffConf=e.diffConfig),"orientation"in e){let s=e.orientation!="b-a";if(s!=(this.editorDOM.firstChild==this.a.dom.parentNode)){let a=this.a.dom.parentNode,i=this.b.dom.parentNode;a.remove(),i.remove(),this.editorDOM.insertBefore(s?a:i,this.editorDOM.firstChild),this.editorDOM.appendChild(s?i:a),this.revertToLeft=!this.revertToLeft,this.revertDOM&&(this.revertDOM.textContent="")}}if("revertControls"in e||"renderRevertControl"in e){let s=!!this.revertDOM,a=this.revertToA,i=this.renderRevert;"revertControls"in e&&(s=!!e.revertControls,a=e.revertControls=="b-to-a"),"renderRevertControl"in e&&(i=e.renderRevertControl),this.setupRevertControls(s,a,i)}let n="highlightChanges"in e,o="gutter"in e,r="collapseUnchanged"in e;if(n||o||r){let s=[],a=[];if(n||o){let i=this.a.state.facet(zn),l=o?e.gutter!==!1:i.markGutter,d=n?e.highlightChanges!==!1:i.highlightChanges;s.push(cl.reconfigure([zn.of({side:"a",sibling:()=>this.b,highlightChanges:d,markGutter:l}),l?al:[]])),a.push(cl.reconfigure([zn.of({side:"b",sibling:()=>this.a,highlightChanges:d,markGutter:l}),l?al:[]]))}if(r){let i=Lx.reconfigure(e.collapseUnchanged?Rx(e.collapseUnchanged):[]);s.push(i),a.push(i)}this.a.dispatch({effects:s}),this.b.dispatch({effects:a})}this.scheduleMeasure()}setupRevertControls(e,n,o){this.revertToA=n,this.revertToLeft=this.revertToA==(this.editorDOM.firstChild==this.a.dom.parentNode),this.renderRevert=o,!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",r=>this.revertClicked(r)),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,n,o){let r=new us,s=new us,a=e.state.field(na).iter(),i=n.state.field(na).iter(),l=0,d=0,u=0,h=0,f=e.viewport,m=n.viewport;for(let b=0;;b++){let y=b<o.length?o[b]:null,v=y?y.fromA:e.state.doc.length,w=y?y.fromB:n.state.doc.length;if(l<v){let S=e.lineBlockAt(l).top+u-(n.lineBlockAt(d).top+h);S<-.01?(u-=S,r.add(l,l,tt.widget({widget:new il(-S),block:!0,side:-1}))):S>vu&&(h+=S,s.add(d,d,tt.widget({widget:new il(S),block:!0,side:-1})))}if(v>l+1e3&&l<f.from&&v>f.from&&d<m.from&&w>m.from){let S=Math.min(f.from-l,m.from-d);l+=S,d+=S,b--}else{if(!y)break;l=y.toA,d=y.toB}for(;a.value&&a.from<l;)u-=a.value.spec.widget.height,a.next();for(;i.value&&i.from<d;)h-=i.value.spec.widget.height,i.next()}for(;a.value;)u-=a.value.spec.widget.height,a.next();for(;i.value;)h-=i.value.spec.widget.height,i.next();let x=e.contentHeight+u-(n.contentHeight+h);x<vu?r.add(e.state.doc.length,e.state.doc.length,tt.widget({widget:new il(-x),block:!0,side:1})):x>vu&&s.add(n.state.doc.length,n.state.doc.length,tt.widget({widget:new il(x),block:!0,side:1}));let g=r.finish(),p=s.finish();Px(g,e.state.field(na))||e.dispatch({effects:ll.of(g)}),Px(p,n.state.field(na))||n.dispatch({effects:ll.of(p)})})(this.a,this.b,this.chunks),this.revertDOM&&this.updateRevertButtons()}updateRevertButtons(){let e=this.revertDOM,n=e.firstChild,o=this.a.viewport,r=this.b.viewport;for(let s=0;s<this.chunks.length;s++){let a=this.chunks[s];if(a.fromA>o.to||a.fromB>r.to)break;if(a.fromA<o.from||a.fromB<r.from)continue;let i=this.a.lineBlockAt(a.fromA).top+"px";for(;n&&+n.dataset.chunk<s;)n=zx(n);n&&n.dataset.chunk==String(s)?(n.style.top!=i&&(n.style.top=i),n=n.nextSibling):e.insertBefore(this.renderRevertButton(i,s),n)}for(;n;)n=zx(n)}renderRevertButton(e,n){let o;if(this.renderRevert)o=this.renderRevert();else{o=document.createElement("button");let r=this.a.state.phrase("Revert this chunk");o.setAttribute("aria-label",r),o.setAttribute("title",r),o.textContent=this.revertToLeft?"\u21DC":"\u21DD"}return o.style.top=e,o.setAttribute("data-chunk",String(n)),o}revertClicked(e){let n,o=e.target;for(;o&&o.parentNode!=this.revertDOM;)o=o.parentNode;if(o&&(n=this.chunks[o.dataset.chunk])){let[r,s,a,i,l,d]=this.revertToA?[this.b,this.a,n.fromB,n.toB,n.fromA,n.toA]:[this.a,this.b,n.fromA,n.toA,n.fromB,n.toB],u=r.state.sliceDoc(a,Math.max(a,i-1));a!=i&&d<=s.state.doc.length&&(u+=r.state.lineBreak),s.dispatch({changes:{from:l,to:Math.min(s.state.doc.length,d),insert:u},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 zx(t){let e=t.nextSibling;return t.remove(),e}var p5=["className","children","orientation","revertControls","highlightChanges","gutter","collapseUnchanged","destroyRerender","renderRevertControl","diffConfig","root"],g5=["modified","modifiedExtension","original","originalExtension","theme","dispatch"],Bx=G.forwardRef((t,e)=>{var{className:n,children:o,orientation:r,revertControls:s,highlightChanges:a,gutter:i,collapseUnchanged:l,destroyRerender:d=!0,renderRevertControl:u,diffConfig:h,root:f}=t,m=Ja(t,p5),x=hu(),{modified:g,modifiedExtension:p,original:b,originalExtension:y,theme:v,dispatch:w}=x,S=Ja(x,g5),N=O.useRef(null),j=O.useRef(),C={orientation:r,revertControls:s,highlightChanges:a,gutter:i,collapseUnchanged:l,renderRevertControl:u,diffConfig:h,root:f};O.useImperativeHandle(e,()=>({container:N.current,view:j.current,modified:g,original:b,config:yt({a:b,b:g,parent:N.current},C)}),[N,j,g,b,C]);var _=Ve.updateListener.of(I=>{if(I.docChanged&&typeof(y==null?void 0:y.onChange)=="function"){var P=I.state.doc.toString();y==null||y.onChange(P,I)}}),A=Ve.updateListener.of(I=>{if(I.docChanged&&typeof(p==null?void 0:p.onChange)=="function"){var P=I.state.doc.toString();p==null||p.onChange(P,I)}});return O.useEffect(()=>{!j.current&&N.current&&y&&p&&(j.current=new Fx(yt({a:yt({},b,{extensions:[...(y==null?void 0:y.extension)||[],...vs(yt({},y==null?void 0:y.option,{theme:v})),_]}),b:yt({},g,{extensions:[...(p==null?void 0:p.extension)||[],...vs(yt({},p==null?void 0:p.option,{theme:v})),A]}),parent:N.current},C)),w({view:j.current}))},[j,N,y,p]),O.useEffect(()=>{if(b&&b.doc&&j.current){var I,P,R=(I=j.current)==null?void 0:I.a.state.doc.toString();R!==b.doc&&((P=j.current)==null||P.a.dispatch({changes:{from:0,to:R.length,insert:b.doc||""}}))}if(g&&g.doc&&j.current){var M,L,F=(M=j.current)==null?void 0:M.b.state.doc.toString();F!==g.doc&&((L=j.current)==null||L.b.dispatch({changes:{from:0,to:F.length,insert:g.doc||""}}))}if(d&&j.current){var D=j.current.a.state.selection.ranges[0].from,T=j.current.b.state.selection.ranges[0].from;j.current.destroy(),j.current=new Fx(yt({a:yt({},b,{extensions:[...(y==null?void 0:y.extension)||[],...vs(yt({},y==null?void 0:y.option,{theme:v}))]}),b:yt({},g,{extensions:[...(p==null?void 0:p.extension)||[],...vs(yt({},p==null?void 0:p.option,{theme:v}))]}),parent:N.current},C)),D&&(j.current.a.focus(),j.current.a.dispatch({selection:{anchor:D,head:D}})),T&&(j.current.b.focus(),j.current.b.dispatch({selection:{anchor:T,head:T}}))}},[j,v,N.current,b,g,y,p,d]),O.useEffect(()=>()=>j.current&&j.current.destroy(),[]),O.useEffect(()=>{if(j.current){var I={};S.orientation!==r&&(I.orientation=r),S.revertControls!==s&&(I.revertControls=s),S.highlightChanges!==a&&(I.highlightChanges=a),S.gutter!==i&&(I.gutter=i),S.collapseUnchanged!==l&&(I.collapseUnchanged=l),S.renderRevertControl!==u&&(I.collapseUnchanged=l),Object.keys(I).length&&w&&j.current&&(j.current.reconfigure(yt({},I)),w(yt({},I)))}},[w,j,r,s,a,i,l,u]),c.jsx("div",yt({ref:N,className:"cm-merge-theme"+(n?" "+n:"")},m,{children:o}))});Bx.displayName="CodeMirrorMerge.Internal";var x5=["theme"],Rr=G.forwardRef((t,e)=>{var{theme:n}=t,o=Ja(t,x5);return c.jsx(QE,{theme:n,children:c.jsx(Bx,yt({},o,{ref:e}))})});Rr.Original=ax,Rr.Modified=ix,Rr.displayName="CodeMirrorMerge";const b5=Rr.Original,y5=Rr.Modified,Ux=[VD(),Ve.lineWrapping],v5=t=>{const e=H.c(44),{className:n,onChange:o,initialPrompt:r,currentLanguageAdapter:s,currentCode:a,declineChange:i,acceptChange:l,enabled:d,children:u}=t;let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h={},e[0]=h):h=e[0];const[f,m]=O.useState(h),[x,g]=St(GS),p=wm(),{completion:b,input:y,stop:v,isLoading:w,setCompletion:S,setInput:N,handleSubmit:j}=$D({api:p.getAiURL("completion").toString(),headers:p.headers(),initialInput:r,streamProtocol:"text",experimental_throttle:100,body:{...f,includeOtherCode:x?xc(a):"",code:a,language:s},onError:w5,onFinish:(Y,J)=>{C(J.trimEnd())}}),C=S,_=G.useRef(null);let A;e[1]!==b?(A=b.trimEnd(),e[1]=b,e[2]=A):A=e[2];const I=A;let P,R,M,L;e[3]!==d?(P=()=>{var Y;d&&(HD(()=>{const J=_.current;return!!(J!=null&&J.view)&&(J.view.focus(),!0)},{retries:3,delay:100,initialDelay:100}),WD((Y=_.current)==null?void 0:Y.view))},R=[d],e[3]=d,e[4]=P,e[5]=R):(P=e[4],R=e[5]),O.useEffect(P,R),e[6]!==d||e[7]!==r||e[8]!==N?(M=()=>{d&&N(r||"")},L=[d,r,N],e[6]=d,e[7]=r,e[8]=N,e[9]=M,e[10]=L):(M=e[9],L=e[10]),O.useEffect(M,L);const{theme:F}=Xo();let D;e[11]!==n?(D=ge("flex flex-col w-full rounded-[inherit]",n),e[11]=n,e[12]=D):D=e[12];const T=d&&"max-h-[400px] min-h-11 visible",k=!d&&"max-h-0 min-h-0 invisible";let B,E,U,V;e[13]!==k||e[14]!==T?(B=ge("flex items-center gap-2 border-b px-3 transition-all rounded-[inherit] rounded-b-none duration-300",T,k),e[13]=k,e[14]=T,e[15]=B):B=e[15],e[16]!==l||e[17]!==I||e[18]!==i||e[19]!==d||e[20]!==j||e[21]!==x||e[22]!==y||e[23]!==w||e[24]!==C||e[25]!==g||e[26]!==N||e[27]!==v||e[28]!==F?(E=d&&c.jsxs(c.Fragment,{children:[c.jsx(Aa,{className:"text-[var(--blue-10)] flex-shrink-0",size:16}),c.jsx(Sc,{inputRef:_,theme:F,onClose:()=>{i(),C("")},value:y,onChange:Y=>{N(Y),m(y3({input:Y}))},onSubmit:()=>{w||j()}}),w&&c.jsxs(ke,{"data-testid":"stop-completion-button",variant:"text",size:"xs",className:"mb-0",onClick:v,children:[c.jsx(Nc,{className:"animate-spin mr-1",size:14}),"Stop"]}),!w&&I&&c.jsx(ke,{"data-testid":"accept-completion-button",variant:"text",size:"xs",className:"mb-0",disabled:w,onClick:()=>{l(I),C("")},children:c.jsx("span",{className:"text-[var(--grass-11)] opacity-100",children:"Accept"})}),c.jsx("div",{className:"h-full w-px bg-border mx-2"}),c.jsx(Ne,{content:"Include code from other cells",children:c.jsxs("div",{className:"flex flex-row items-start gap-1 overflow-hidden",children:[c.jsx(v3,{"data-testid":"include-other-cells-checkbox",id:"include-other-cells",checked:x,onCheckedChange:Y=>g(!!Y)}),c.jsx(fr,{htmlFor:"include-other-cells",className:"text-muted-foreground text-xs whitespace-nowrap ellipsis",children:"Include all code"})]})}),c.jsx(ke,{"data-testid":"decline-completion-button",variant:"text",size:"icon",disabled:w,onClick:()=>{v(),i(),C("")},children:c.jsx(En,{className:"text-[var(--red-10)]",size:16})})]}),e[16]=l,e[17]=I,e[18]=i,e[19]=d,e[20]=j,e[21]=x,e[22]=y,e[23]=w,e[24]=C,e[25]=g,e[26]=N,e[27]=v,e[28]=F,e[29]=E):E=e[29],e[30]!==B||e[31]!==E?(U=c.jsx("div",{className:B,children:E}),e[30]=B,e[31]=E,e[32]=U):U=e[32],e[33]!==I||e[34]!==a||e[35]!==d||e[36]!==o||e[37]!==F?(V=I&&d&&c.jsxs(Rr,{className:"cm",theme:F,children:[c.jsx(b5,{onChange:o,value:a,extensions:Ux}),c.jsx(y5,{value:I,editable:!1,readOnly:!0,extensions:Ux})]}),e[33]=I,e[34]=a,e[35]=d,e[36]=o,e[37]=F,e[38]=V):V=e[38];const $=(!I||!d)&&u;let X;return e[39]!==U||e[40]!==V||e[41]!==$||e[42]!==D?(X=c.jsxs("div",{className:D,children:[U,V,$]}),e[39]=U,e[40]=V,e[41]=$,e[42]=D,e[43]=X):X=e[43],X};function w5(t){Xe({title:"Completion failed",description:b3(t)})}const ku="web application/x-marimo-cell",k5=dt({cells:qD(dt({code:st()})),version:pt("1.0")}),$x=t=>{const e=t===1?"Cell":`${t} cells`;Xe({title:`${e} copied`,description:`${e} ${t===1?"has":"have"} been copied to clipboard.`})},S5=()=>{Xe({title:"Copy failed",description:"Failed to copy cells to clipboard.",variant:"danger"})},N5=()=>{Xe({title:"Nothing to paste",description:"No cell or text found in clipboard.",variant:"danger"})},j5=()=>{Xe({title:"Paste failed",description:"Failed to read from clipboard",variant:"danger"})};class C5{constructor(){this.items={}}add(e,n){return ClipboardItem.supports(e)?typeof n=="string"?(this.items[e]=new Blob([n],{type:e}),this):(this.items[e]=new Blob([JSON.stringify(n)],{type:e}),this):(ht.warn(`ClipboardItem does not support ${e}`),this)}build(){return new ClipboardItem(this.items)}}const oa=mt(!1),ra=new WeakMap;function Vx(t){return{handle:e=>t(e),bulkHandle:e=>{let n=!0;try{for(const o of e)n=n&&t(o);return n}catch{return!1}}}}function eo(t){return{handle:e=>t([e]),bulkHandle:e=>t(e)}}function Hx(t,e){const n=H.c(29),{canMoveX:o,editorView:r,cellActionDropdownRef:s}=e,{saveOrNameNotebook:a}=ud(),i=kt(Is),l=it(),d=am(),u=kt(oa),h=Es(),f=Ie(w3),{copyCells:m,pasteAtCell:x}=function(){const R=it(),M=Fe(async F=>{const D=mn(),T=F.map(k=>D.cellData[k]).filter(Boolean);if(T.length!==0)try{const k={cells:T.map(U=>({code:U.code})),version:"1.0"},B=T.map(U=>U.code).join(`
120
-
121
- `),E=new C5().add(ku,k).add("text/plain",B).build();await navigator.clipboard.write([E]),$x(T.length)}catch(k){ht.error("Failed to copy cells to clipboard",k);try{const B=T.map(E=>E.code).join(`
122
-
123
- `);await navigator.clipboard.writeText(B),$x(T.length)}catch{S5()}}}),L=Fe(async(F,D)=>{const{before:T=!1}=D??{};try{const k=await navigator.clipboard.read();for(const E of k)if(E.types.includes(ku)){const U=await E.getType(ku),V=await U.text();try{const $=k5.parse(JSON.parse(V));if($.cells.length===0)break;const X=F,Y=$.cells.reverse();for(const J of Y)R.createNewCell({cellId:X,before:T,code:J.code,autoFocus:!0});return}catch($){ht.warn("Failed to parse clipboard cell data",$)}}const B=await navigator.clipboard.readText();B.trim()?R.createNewCell({cellId:F,before:T,code:B,autoFocus:!0}):N5()}catch(k){ht.error("Failed to paste from clipboard",k),j5()}});return{copyCells:M,pasteAtCell:L}}(),g=wi(),p=function(R){const M=H.c(2);let L,F;return M[0]!==R?(F=mt(D=>D(hd).selected.has(R)),M[0]=R,M[1]=F):F=M[1],L=F,Ie(L)}(t),b=Ms(),y=pi(),v=Ie(Ua);let w;n[0]!==b||n[1]!==g?(w={clear:()=>{b.clear(),g.clear()},extend:R=>{b.clear(),g.extend(R)},select:R=>{b.clear(),g.select(R)}},n[0]=b,n[1]=g,n[2]=w):w=n[2];const S=w,N=Ie(Jl);let j;n[3]!==N?(j=(R,M)=>Wf(N.getHotkey(R).key)(M.nativeEvent||M),n[3]=N,n[4]=j):j=n[4];const C=j,_=function(R){const M=H.c(11),L=S3(),F=it(),D=kt(oa);let T,k,B;M[0]!==R||M[1]!==L?(T=()=>{L.focusCell({cellId:R})},M[0]=R,M[1]=L,M[2]=T):T=M[2],M[3]!==F||M[4]!==R||M[5]!==L||M[6]!==D?(k=()=>{D(!1),F.markTouched({cellId:R}),L.blurCell()},M[3]=F,M[4]=R,M[5]=L,M[6]=D,M[7]=k):k=M[7],M[8]!==T||M[9]!==k?(B={onFocusWithin:T,onBlurWithin:k},M[8]=T,M[9]=k,M[10]=B):B=M[10];const{focusWithinProps:E}=GD(B);return E}(t);let A;n[5]!==l||n[6]!==o||n[7]!==s||n[8]!==t||n[9]!==m||n[10]!==y||n[11]!==r||n[12]!==p||n[13]!==C||n[14]!==f||n[15]!==x||n[16]!==b||n[17]!==h||n[18]!==a||n[19]!==S||n[20]!==i||n[21]!==u||n[22]!==d||n[23]!==v?(A={onKeyDown:R=>{if(Dn.fromInput(R))return void R.continuePropagation();const M={"Mod+ArrowUp":()=>(l.focusTopCell(),S.clear(),!0),"Mod+ArrowDown":()=>(l.focusBottomCell(),S.clear(),!0),ArrowUp:()=>(l.focusCell({cellId:t,where:"before"}),S.clear(),!0),ArrowDown:()=>(l.focusCell({cellId:t,where:"after"}),S.clear(),!0),ArrowLeft:()=>{if(o){const D=d.get(pn),T=D.cellIds.findWithId(t),k=D.cellIds.indexOf(T),B=D.cellIds.at(k-1);if(B&&B.length>0){const E=Wx(t,B);return l.focusCell({cellId:E,where:"exact"}),S.clear(),!0}}return!1},ArrowRight:()=>{if(o){const D=d.get(pn),T=D.cellIds.findWithId(t),k=D.cellIds.indexOf(T),B=D.cellIds.at(k+1);if(B&&B.length>0){const E=Wx(t,B);return l.focusCell({cellId:E,where:"exact"}),S.clear(),!0}}return!1},"Shift+ArrowUp":()=>{const D=d.get(jc);S.extend({cellId:t,allCellIds:D});const T=D.findWithId(t).before(t);return T&&S.extend({cellId:T,allCellIds:D}),l.focusCell({cellId:t,where:"before"}),!0},"Shift+ArrowDown":()=>{const D=d.get(jc);S.extend({cellId:t,allCellIds:D});const T=D.findWithId(t).after(t);return T&&S.extend({cellId:T,allCellIds:D}),l.focusCell({cellId:t,where:"after"}),!0},Escape:()=>!!p&&(S.clear(),!0),Enter:()=>(u(!0),j3(d,t),S.clear(),!0),s:()=>(a(),!0)};for(const[D,T]of Object.entries(M))if(Wf(D)(R)&&T())return void R.preventDefault();const L={"cell.run":eo(D=>(h(D),!0)),"cell.runAndNewBelow":eo(D=>{h(D);const T=D[D.length-1];return l.moveToNextCell({cellId:T,before:!1}),!0}),"cell.runAndNewAbove":eo(D=>{h(D);const T=D[0];return l.moveToNextCell({cellId:T,before:!0}),!0}),"cell.createAbove":D=>(l.createNewCell({cellId:D,before:!0}),!0),"cell.createBelow":D=>(l.createNewCell({cellId:D,before:!1}),!0),"cell.moveUp":eo(D=>{const T=D[0];return d.get(pn).cellIds.findWithId(T).first()!==T&&(D.forEach(k=>{l.moveCell({cellId:k,before:!0})}),!0)}),"cell.moveDown":eo(D=>{const T=D[D.length-1];return d.get(pn).cellIds.findWithId(T).last()!==T&&([...D].reverse().forEach(k=>{l.moveCell({cellId:k,before:!1})}),!0)}),"cell.moveLeft":Vx(D=>!!o&&(l.moveCell({cellId:D,direction:"left"}),!0)),"cell.moveRight":Vx(D=>!!o&&(l.moveCell({cellId:D,direction:"right"}),!0)),"cell.hideCode":eo(D=>{var k;const T=!D.map(B=>{var U;return((U=d.get(pn).cellData[B])==null?void 0:U.config)||null}).every(E5);qo({configs:Object.fromEntries(D.map(B=>[B,{hide_code:T}]))});for(const B of D)l.updateCellConfig({cellId:B,config:{hide_code:T}});if(D.length===1){const B=D[0];l.focusCell({cellId:B,where:"after"}),T?((k=r.current)==null||k.contentDOM.blur(),N3(B)):j3(d,B)}return!0}),"cell.focusDown":D=>(l.focusCell({cellId:D,where:"after"}),!0),"cell.focusUp":D=>(l.focusCell({cellId:D,where:"before"}),!0),"cell.sendToBottom":eo(D=>(D.forEach(T=>{l.sendToBottom({cellId:T})}),!0)),"cell.sendToTop":eo(D=>([...D].reverse().forEach(T=>{l.sendToTop({cellId:T})}),!0)),"cell.aiCompletion":D=>{var k;let T=!1;return i(B=>(B==null?void 0:B.cellId)===D?(T=!0,null):{cellId:D}),T&&((k=r.current)==null||k.focus()),!0},"cell.cellActions":()=>{var D;return(D=s.current)==null||D.toggle(),!0},"command.copyCell":eo(D=>(m(D),!0)),"command.pasteCell":D=>(x(D),!0),"command.createCellBefore":D=>!Dn.hasModifier(R)&&(l.createNewCell({cellId:D,before:!0,autoFocus:!0}),!0),"command.createCellAfter":D=>!Dn.hasModifier(R)&&(l.createNewCell({cellId:D,before:!1,autoFocus:!0}),!0),"cell.delete":()=>{if(!v.keymap.destructive_delete)return!1;const D=F.size>=2?[...F]:[t],T=d.get(pn);return!D.some(k=>{const{status:B}=T.cellRuntime[k];return B==="running"||B==="queued"})&&(b.idle?(b.submit(D),!0):(y({cellIds:D}),b.clear(),!0))}},F=function(D){return D.get(hd).selected}(d);if(f==="vim"&&function(D,T){const k=function($){if($.ctrlKey||$.metaKey||$.altKey)return"";const X=$.key.toLowerCase();return $.shiftKey?`shift+${X}`:X}(D),B=D.target;if(!k||!B)return!1;const E=ra.get(B);let U=k;E!=null&&E.timeout&&clearTimeout(E.timeout),E&&(U=`${E.sequence} ${k}`);const V=T[U];if(V)return ra.delete(B),V();if(!E){const $=T[k];if($)return $()}if(Object.keys(T).some($=>$.startsWith(`${U} `))){const $=window.setTimeout(()=>{ra.delete(B)},500);return ra.set(B,{sequence:U,timeout:$}),!0}return ra.delete(B),!1}(R.nativeEvent||R,{j:M.ArrowDown,k:M.ArrowUp,h:M.ArrowLeft,l:M.ArrowRight,i:M.Enter,"shift+j":M["Shift+ArrowDown"],"shift+k":M["Shift+ArrowUp"],"g g":M["Mod+ArrowUp"],"shift+g":M["Mod+ArrowDown"],"d d":()=>L["cell.delete"](),"y y":()=>(m(F.size>=2?[...F]:[t]),!0),p:()=>(x(t,{before:!1}),!0),"shift+p":()=>(x(t,{before:!0}),!0),o:()=>(l.createNewCell({cellId:t,before:!1,autoFocus:!0}),!0),"shift+o":()=>(l.createNewCell({cellId:t,before:!0,autoFocus:!0}),!0),u:()=>(l.undoDeleteCell(),!0)}))R.preventDefault();else{for(const[D,T]of Object.entries(L))if(C(D,R)){if(T instanceof Function){if(T(t))return void R.preventDefault()}else if(F.size>=2?T.bulkHandle([...F]):T.handle(t))return void R.preventDefault();return}R.continuePropagation()}}},n[5]=l,n[6]=o,n[7]=s,n[8]=t,n[9]=m,n[10]=y,n[11]=r,n[12]=p,n[13]=C,n[14]=f,n[15]=x,n[16]=b,n[17]=h,n[18]=a,n[19]=S,n[20]=i,n[21]=u,n[22]=d,n[23]=v,n[24]=A):A=n[24];const{keyboardProps:I}=k3(A);let P;return n[25]!==_||n[26]!==p||n[27]!==I?(P=Rf(_,I,{"data-selected":p,className:"data-[selected=true]:ring-1 data-[selected=true]:ring-[var(--blue-8)] data-[selected=true]:ring-offset-1"}),n[25]=_,n[26]=p,n[27]=I,n[28]=P):P=n[28],P}function E5(t){return t==null?void 0:t.hide_code}function Wx(t,e){const n=document.getElementById(Ea.create(t));if(!n)return e.first();const o=n.getBoundingClientRect();for(const r of e.topLevelIds){const s=document.getElementById(Ea.create(r));if(s){const a=s.getBoundingClientRect();if(o.top<=a.bottom&&o.bottom>=a.top)return r}}return e.last()}const _5=t=>{const e=H.c(24),{editorView:n,code:o,currentLanguageAdapter:r,onAfterToggle:s}=t;let a,i;e[0]!==o?(i=new La().isSupported(o)||o.trim()==="",e[0]=o,e[1]=i):i=e[1],a=i;const l=a;let d,u;e[2]!==o?(u=new wc().isSupported(o)||o.trim()==="",e[2]=o,e[3]=u):u=e[3],d=u;const h=d&&r==="python";let f,m;e[4]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(Wo,{color:"var(--sky-11)",strokeWidth:2.5,className:"w-4 h-4"}),e[4]=f):f=e[4],e[5]!==r||e[6]!==n||e[7]!==s||e[8]!==h?(m=c.jsx(Su,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:h,icon:f,toType:"sql",displayName:"SQL",onAfterToggle:s}),e[5]=r,e[6]=n,e[7]=s,e[8]=h,e[9]=m):m=e[9];const x=l&&r==="python";let g,p,b,y,v;return e[10]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Gl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[10]=g):g=e[10],e[11]!==r||e[12]!==n||e[13]!==s||e[14]!==x?(p=c.jsx(Su,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:x,icon:g,toType:"markdown",displayName:"Markdown",onAfterToggle:s}),e[11]=r,e[12]=n,e[13]=s,e[14]=x,e[15]=p):p=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(Yl,{fill:"var(--sky-11)",color:"black",className:"w-4 h-4"}),e[16]=b):b=e[16],e[17]!==r||e[18]!==n?(y=c.jsx(Su,{editorView:n,currentLanguageAdapter:r,canSwitchToLanguage:!0,icon:b,toType:"python",displayName:"Python",onAfterToggle:Pn.NOOP}),e[17]=r,e[18]=n,e[19]=y):y=e[19],e[20]!==p||e[21]!==y||e[22]!==m?(v=c.jsxs("div",{className:"absolute right-3 top-2 z-20 flex hover-action gap-1",children:[m,p,y]}),e[20]=p,e[21]=y,e[22]=m,e[23]=v):v=e[23],v},Su=t=>{const e=H.c(10),{editorView:n,currentLanguageAdapter:o,canSwitchToLanguage:r,icon:s,toType:a,displayName:i,onAfterToggle:l}=t;let d;e[0]!==n||e[1]!==l||e[2]!==a?(d=()=>{n&&(hr(n,{language:a}),l())},e[0]=n,e[1]=l,e[2]=a,e[3]=d):d=e[3];const u=d;if(!r||o===a)return null;const h=`View as ${i}`;let f,m;return e[4]!==u||e[5]!==s?(f=c.jsx(ke,{"data-testid":"language-toggle-button",variant:"text",size:"xs",className:"opacity-80 px-1",onClick:u,children:s}),e[4]=u,e[5]=s,e[6]=f):f=e[6],e[7]!==h||e[8]!==f?(m=c.jsx(Ne,{content:h,children:f}),e[7]=h,e[8]=f,e[9]=m):m=e[9],m},qx=({theme:t,showPlaceholder:e,id:n,config:o,code:r,status:s,serializedEditorState:a,setEditorView:i,runCell:l,userConfig:d,editorViewRef:u,editorViewParentRef:h,hidden:f,hasOutput:m,showHiddenCode:x,languageAdapter:g,setLanguageAdapter:p,showLanguageToggles:b=!0})=>{var X;const[y,v]=St(Is),w=mi(),{saveOrNameNotebook:S}=ud(),N=Ms(),j=s==="running"||s==="queued",C=it(),_=Lp(),A=g==="markdown",I=Fe(()=>!j&&(N.idle&&d.keymap.destructive_delete?(N.submit([n]),!0):(w({cellId:n}),!0))),P=Fe(()=>!j&&(l(),!0)),R=Fe(()=>{const Y=!o.hide_code;return qo({configs:{[n]:{hide_code:Y}}}),C.updateCellConfig({cellId:n,config:{hide_code:Y}}),Y}),M=Ie(ql),L=Fe(()=>{qn({autoInstantiate:M,createNewCell:C.createNewCell})}),F=YD(d),D=O.useMemo(()=>{const Y=_E({cellId:n,showPlaceholder:e,enableAI:F,cellActions:{...C,afterToggleMarkdown:L,onRun:P,deleteCell:I,saveNotebook:S,createManyBelow:J=>{for(const Q of[...J].reverse())C.createNewCell({code:Q,before:!1,cellId:n,skipIfCodeExists:!0})},splitCell:_,toggleHideCode:R,aiCellCompletion:()=>{let J=!1;return v(Q=>(Q==null?void 0:Q.cellId)===n?(J=!0,null):{cellId:n}),J}},completionConfig:d.completion,keymapConfig:d.keymap,lspConfig:d.language_servers,theme:t,hotkeys:new C3(d.keymap.overrides??{}),diagnosticsConfig:d.diagnostics,displayConfig:d.display});return Y.push(Rn.define(J=>{const Q=J.state.field(bc);return p(Q.type),{update(q){const K=q.state.field(bc);p(K.type)}}}),Ve.updateListener.of(J=>{J.selectionSet&&J.state.selection.ranges.some(Q=>Q.from!==Q.to)&&x({focus:!1})}),Ve.domEventHandlers({focus:()=>{x({focus:!1})}})),Y},[n,d.keymap,d.completion,d.language_servers,d.display,d.diagnostics,F,t,e,C,_,R,I,P,v,L,p,x,S]),T=kc(),k=Fe(()=>{if(T){const J=uu(n,0,r);D.push(J.extension),r=J.code}const Y=new Ve({state:Xa.create({doc:r,extensions:D})});i(Y),T||hr(Y,{language:ym(Y.state).type})}),B=Fe(()=>{if(jo(u.current!==null,"Editor view is not initialized"),T){const Y=uu(n);D.push(Y.extension)}u.current.dispatch({effects:[At.reconfigure.of([D]),KD(u.current,{completionConfig:d.completion,hotkeysProvider:new C3(d.keymap.overrides??{}),lspConfig:{...d.language_servers,diagnostics:d.diagnostics}})]})}),E=Fe(()=>{if(jo(a,"Editor view is not initialized"),T){const J=uu(n,0,r);D.push(J.extension),r=J.code}const Y=new Ve({state:Xa.fromJSON(a,{doc:r,extensions:D},{history:XD})});T||hr(Y,{language:ym(Y.state).type}),i(Y),C.clearSerializedEditorState({cellId:n})});O.useEffect(()=>{a===null?u.current===null?k():B():E(),u.current!==null&&h&&h.current!==null&&h.current.replaceChildren(u.current.dom)},[k,B,E,u,h,a,D]),O.useEffect(()=>{const Y=u.current;return()=>{Y==null||Y.destroy()}},[u]);const U=function(Y,J){const Q=H.c(9),q=kt(oa),K=Ie(w3);let re;Q[0]!==Y||Q[1]!==q?(re=()=>{q(!1),N3(Y)},Q[0]=Y,Q[1]=q,Q[2]=re):re=Q[2];const oe=re;let ne;Q[3]!==J||Q[4]!==oe?(ne=()=>{if(!J.current)return void oe();const he=J.current,ae=he.state;ae.selection.main.from===ae.selection.main.to?xs(ae)!==null?Bl(he):oe():he.dispatch({selection:Kn.single(ae.selection.main.from)})},Q[3]=J,Q[4]=oe,Q[5]=ne):ne=Q[5];const se=ne;let te;Q[6]!==se||Q[7]!==K?(te={onKeyDown:he=>{K==="vim"?he.key==="Escape"&&(he.ctrlKey||he.metaKey)&&se():he.key==="Escape"&&se(),he.continuePropagation()}},Q[6]=se,Q[7]=K,Q[8]=te):te=Q[8];const{keyboardProps:pe}=k3(te);return pe}(n,u),V=f&&!A||f&&A&&!m;let $="";return A&&f&&m?$="h-0 overflow-hidden":f&&($="opacity-20 h-8 [&>div.cm-editor]:h-full [&>div.cm-editor]:overflow-hidden [&_.cm-panels]:hidden"),c.jsx(v5,{enabled:(y==null?void 0:y.cellId)===n,initialPrompt:y==null?void 0:y.initialPrompt,currentCode:((X=u.current)==null?void 0:X.state.doc.toString())??r,currentLanguageAdapter:g,declineChange:Fe(()=>{var Y;v(null),(Y=u.current)==null||Y.focus()}),onChange:Fe(Y=>{var J;(J=u.current)==null||J.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:Y}})}),acceptChange:Fe(Y=>{var J,Q;(J=u.current)==null||J.dispatch({changes:{from:0,to:u.current.state.doc.length,insert:Y}}),(Q=u.current)==null||Q.focus(),v(null)}),children:c.jsxs("div",{className:"relative w-full",...U,children:[V&&c.jsx(E3,{tooltip:"Edit code",className:"absolute inset-0 z-10",onClick:x}),c.jsx(Gx,{className:$,editorView:u.current,ref:h}),!f&&b&&c.jsx("div",{className:"absolute top-1 right-5",children:c.jsx(_5,{code:r,editorView:u.current,currentLanguageAdapter:g,onAfterToggle:L})})]})})},Gx=G.forwardRef((t,e)=>{const n=H.c(10),{className:o,editorView:r}=t,s=O.useRef(null);let a,i,l,d,u;return n[0]!==r?(a=()=>{r!==null&&s.current!==null&&s.current.children.length===0&&s.current.append(r.dom)},i=[r,s],n[0]=r,n[1]=a,n[2]=i):(a=n[1],i=n[2]),O.useEffect(a,i),n[3]!==o?(l=ge("cm mathjax_ignore",o),n[3]=o,n[4]=l):l=n[4],n[5]!==e?(d=h=>{e?rl(e,s)(h):rl(s)(h)},n[5]=e,n[6]=d):d=n[6],n[7]!==l||n[8]!==d?(u=c.jsx("div",{className:l,ref:d,"data-testid":"cell-editor"}),n[7]=l,n[8]=d,n[9]=u):u=n[9],u});Gx.displayName="CellCodeMirrorEditor";const Nu=kc()?function(t){const e=n=>{const o=H.c(5),r=Ie(Yn),[s,a]=St(Mr);if(r.state===Ft.CONNECTING||s===void 0){let l,d;return o[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx("span",{children:"Waiting for real-time collaboration connection..."}),o[0]=l):l=o[0],o[1]!==a?(d=c.jsx("div",{className:"flex h-full w-full items-baseline p-4",children:c.jsxs(Cc,{milliseconds:1e3,fallback:null,children:[l,c.jsx(ke,{variant:"link",onClick:()=>{a("disabled")},children:"Turn off real-time collaboration"})]})}),o[1]=a,o[2]=d):d=o[2],d}let i;return o[3]!==n?(i=c.jsx(t,{...n}),o[3]=n,o[4]=i):i=o[4],i};return e.displayName=`WithWaitUntilConnected(${t.displayName})`,e}(O.memo(qx)):O.memo(qx),I5=t=>{const e=H.c(10);let n,o,r,s;return e[0]!==t.left?(n=c.jsx("div",{className:"flex-1 flex item-center gap-2",children:t.left}),e[0]=t.left,e[1]=n):n=e[1],e[2]!==t.center?(o=c.jsx("div",{className:"flex-1 flex item-center gap-2 justify-center",children:t.center}),e[2]=t.center,e[3]=o):o=e[3],e[4]!==t.right?(r=c.jsx("div",{className:"flex-1 flex item-center gap-2 justify-end",children:t.right}),e[4]=t.right,e[5]=r):r=e[5],e[6]!==n||e[7]!==o||e[8]!==r?(s=c.jsxs("div",{className:"flex items-center gap-2 w-full px-3",children:[n,o,r]}),e[6]=n,e[7]=o,e[8]=r,e[9]=s):s=e[9],s},A5=t=>{const e=H.c(8);if(!t.canCollapse&&!t.isCollapsed)return null;const n=t.isCollapsed?"Expand":"Collapse";let o,r,s;return e[0]!==t.isCollapsed?(o=c.jsx("span",{children:c.jsx(T5,{isCollapsed:t.isCollapsed})}),e[0]=t.isCollapsed,e[1]=o):o=e[1],e[2]!==n||e[3]!==o?(r=c.jsx(Ne,{content:n,children:o}),e[2]=n,e[3]=o,e[4]=r):r=e[4],e[5]!==t.onClick||e[6]!==r?(s=c.jsx(ke,{variant:"text",size:"icon",onClick:t.onClick,children:r}),e[5]=t.onClick,e[6]=r,e[7]=s):s=e[7],s},T5=t=>{const e=H.c(2),{isCollapsed:n}=t;let o;return e[0]!==n?(o=n?c.jsx(Ta,{className:"w-5 h-5 flex-shrink-0"}):c.jsx(wo,{className:"w-5 h-5 flex-shrink-0"}),e[0]=n,e[1]=o):o=e[1],o},Yx=O.memo(t=>{const e=H.c(24),{onClick:n,count:o,cellId:r}=t,s=fs();let a;e[0]!==r||e[1]!==s?(a=JD(s,r),e[0]=r,e[1]=s,e[2]=a):a=e[2];const i=a;let l,d;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=ge("flex items-center justify-between w-[calc(100%-2rem)] h-9 bg-muted rounded-b mx-4 opacity-80 hover:opacity-100 cursor-pointer"),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(ZD,{className:"w-4 h-4 flex-shrink-0"}),e[4]=d):d=e[4];const u=o===1?"cell":"cells";let h,f,m,x,g,p,b;return e[5]!==o||e[6]!==u?(h=c.jsxs(c.Fragment,{children:[d,c.jsxs("span",{className:"text-sm text-gray-500",children:[o," ",u," collapsed"]})]}),e[5]=o,e[6]=u,e[7]=h):h=e[7],e[8]!==i.errored?(f=i.errored&&c.jsx(Ne,{content:"Has errors",delayDuration:100,children:c.jsx(fp,{className:"w-4 h-4 flex-shrink-0 text-destructive"})}),e[8]=i.errored,e[9]=f):f=e[9],e[10]!==i.stale?(m=i.stale&&c.jsx(Ne,{content:"Has stale cells",delayDuration:100,children:c.jsx(_3,{className:"w-4 h-4 flex-shrink-0 text-[var(--yellow-11)]"})}),e[10]=i.stale,e[11]=m):m=e[11],e[12]!==i.runningOrQueued?(x=i.runningOrQueued&&c.jsx(Ne,{content:"Running",delayDuration:100,children:c.jsx(Nc,{className:"w-4 h-4 flex-shrink-0 animate-spin"})}),e[12]=i.runningOrQueued,e[13]=x):x=e[13],e[14]!==f||e[15]!==m||e[16]!==x?(g=c.jsxs(c.Fragment,{children:[f,m,x]}),e[14]=f,e[15]=m,e[16]=x,e[17]=g):g=e[17],e[18]!==h||e[19]!==g?(p=c.jsx(I5,{center:h,right:g}),e[18]=h,e[19]=g,e[20]=p):p=e[20],e[21]!==n||e[22]!==p?(b=c.jsx("div",{onClick:n,className:l,children:p}),e[21]=n,e[22]=p,e[23]=b):b=e[23],b});Yx.displayName="CollapsedCellBanner";const Kx=t=>{const e=H.c(31),{status:n,connectionState:o,onClick:r}=t,s=n==="running"||n==="queued";let a,i,l,d,u,h,f,m,x,g,p,b,y,v;if(e[0]!==o||e[1]!==s||e[2]!==r||e[3]!==n){const w=Xn(o);let S;if(w){let N;e[14]!==o?(N=cc(o),e[14]=o,e[15]=N):N=e[15],S=N}else S=n==="running"?"A cell can't be deleted when it's running":n==="queued"?"A cell can't be deleted when it's queued to run":"Delete";i=Ne,x=S,g=!1,a=ke,l="ghost",d="icon",u=r,h="delete-button",f=Dn.preventFocus,m=ge("hover:bg-transparent text-destructive/60 hover:text-destructive",(w||s)&&"inactive-button"),e[0]=o,e[1]=s,e[2]=r,e[3]=n,e[4]=a,e[5]=i,e[6]=l,e[7]=d,e[8]=u,e[9]=h,e[10]=f,e[11]=m,e[12]=x,e[13]=g}else a=e[4],i=e[5],l=e[6],d=e[7],u=e[8],h=e[9],f=e[10],m=e[11],x=e[12],g=e[13];return e[16]===Symbol.for("react.memo_cache_sentinel")?(p={boxShadow:"none"},b=c.jsx(Xl,{size:14}),e[16]=p,e[17]=b):(p=e[16],b=e[17]),e[18]!==a||e[19]!==l||e[20]!==d||e[21]!==u||e[22]!==h||e[23]!==f||e[24]!==m?(y=c.jsx(a,{variant:l,size:d,onClick:u,"data-testid":h,onMouseDown:f,className:m,style:p,children:b}),e[18]=a,e[19]=l,e[20]=d,e[21]=u,e[22]=h,e[23]=f,e[24]=m,e[25]=y):y=e[25],e[26]!==i||e[27]!==y||e[28]!==x||e[29]!==g?(v=c.jsx(i,{content:x,usePortal:g,children:y}),e[26]=i,e[27]=y,e[28]=x,e[29]=g,e[30]=v):v=e[30],v},M5=t=>{const e=H.c(22),{cellId:n}=t,o=function(b){const y=H.c(22),[v,w]=St(Sg),S=mi(),N=pi();let j;y[0]!==b||y[1]!==v?(j=v.get(b),y[0]=b,y[1]=v,y[2]=j):j=y[2];const C=j;let _,A,I,P,R;if(y[3]!==S||y[4]!==N||y[5]!==w||y[6]!==v?(_=()=>{if(v.size===0)return;const M=[...v.values()];M.every(Yj)&&w(()=>(v.size===1?S({cellId:M[0].cellId}):N({cellIds:M.map(Gj)}),new Map))},A=[v,S,N,w],y[3]=S,y[4]=N,y[5]=w,y[6]=v,y[7]=_,y[8]=A):(_=y[7],A=y[8]),O.useEffect(_,A),!C){let M;return y[9]===Symbol.for("react.memo_cache_sentinel")?(M={isPending:!1},y[9]=M):M=y[9],M}if(v.size!==1){let M;return y[10]!==C?(M={isPending:!0,shouldConfirmDelete:!1,...C},y[10]=C,y[11]=M):M=y[11],M}return y[12]!==N||y[13]!==w||y[14]!==v?(I=()=>{N({cellIds:[...v.values()].map(qj)}),w(new Map)},y[12]=N,y[13]=w,y[14]=v,y[15]=I):I=y[15],y[16]!==w?(P=()=>w(new Map),y[16]=w,y[17]=P):P=y[17],y[18]!==C||y[19]!==I||y[20]!==P?(R={isPending:!0,...C,shouldConfirmDelete:!0,confirm:I,cancel:P},y[18]=C,y[19]=I,y[20]=P,y[21]=R):R=y[21],R}(n);if(!o.isPending)return null;if(o.type==="simple"){let b;e[0]===Symbol.for("react.memo_cache_sentinel")?(b=ge("px-3 py-1.5","bg-[var(--amber-2)] border-t border-[var(--amber-6)]","animate-in slide-in-from-top-2 duration-200"),e[0]=b):b=e[0];const y=`pending-delete-${n}`;let v,w;return e[1]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(im,{className:"w-3 h-3 text-[var(--amber-11)] flex-shrink-0"}),c.jsx("span",{className:"text-[var(--amber-11)] text-xs",children:"Pending deletion"})]}),e[1]=v):v=e[1],e[2]!==y?(w=c.jsx("div",{className:b,"data-testid":y,children:v}),e[2]=y,e[3]=w):w=e[3],w}const r=o.executionDurationMs!==void 0,s=o.defs.size>0,a=js(o.executionDurationMs??0);let i,l="Pending deletion";r&&s?l=`This cell took ${a} to run and contains variables referenced by other cells.`:r?l=`This cell took ${a} to run.`:s&&(l="This cell contains variables referenced by other cells."),e[4]===Symbol.for("react.memo_cache_sentinel")?(i=ge("px-4 py-3","bg-[var(--amber-2)] border-t border-[var(--amber-6)]","animate-in slide-in-from-top-2 duration-200"),e[4]=i):i=e[4];const d=`pending-delete-${n}`;let u,h,f,m,x,g,p;return e[5]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(im,{className:"w-4 h-4 text-[var(--amber-11)] mt-0.5 flex-shrink-0"}),e[5]=u):u=e[5],e[6]!==l?(h=c.jsx("p",{className:"text-[var(--amber-11)] font-medium",children:l}),e[6]=l,e[7]=h):h=e[7],e[8]!==s||e[9]!==o.defs?(f=s&&[...o.defs.entries()].map(D5),e[8]=s,e[9]=o.defs,e[10]=f):f=e[10],e[11]!==h||e[12]!==f?(m=c.jsxs("div",{className:"font-code text-sm text-[0.84375rem]",children:[h,f]}),e[11]=h,e[12]=f,e[13]=m):m=e[13],e[14]!==o?(x=o.shouldConfirmDelete&&c.jsxs(c.Fragment,{children:[c.jsx("p",{className:"text-[var(--amber-11)] mt-2 mb-3",children:"Are you sure you want to delete?"}),c.jsx(rm,{autoFocus:!0,children:c.jsxs("div",{className:"flex items-center gap-2",onKeyDown:P5,children:[c.jsx(ke,{size:"xs",variant:"ghost",onClick:()=>o.cancel(),className:"text-[var(--amber-11)] hover:bg-[var(--amber-4)] hover:text-[var(--amber-11)]",children:"Cancel"}),c.jsx(ke,{size:"xs",variant:"secondary",onClick:()=>o.confirm(),className:"bg-[var(--amber-11)] hover:bg-[var(--amber-12)] text-white border-[var(--amber-11)]",children:"Delete"})]})})]}),e[14]=o,e[15]=x):x=e[15],e[16]!==m||e[17]!==x?(g=c.jsxs("div",{className:"flex items-start gap-3",children:[u,c.jsxs("div",{className:"flex-1",children:[m,x]})]}),e[16]=m,e[17]=x,e[18]=g):g=e[18],e[19]!==d||e[20]!==g?(p=c.jsx("div",{className:i,"data-testid":d,children:g}),e[19]=d,e[20]=g,e[21]=p):p=e[21],p};function O5(t){return c.jsx("li",{className:"my-0.5 ml-8 text-[var(--amber-11)]/60",children:c.jsx(_o,{cellId:t})},t)}function D5(t){const[e,n]=t;return c.jsxs("div",{children:[c.jsxs("p",{className:"text-[var(--amber-11)] mt-2",children:["'",c.jsx("span",{className:"font-mono",children:e}),"' is referenced by:"]}),c.jsx("ul",{className:"list-disc",children:n.map(O5)})]},e)}function P5(t){t.stopPropagation()}const R5=t=>{const e=H.c(27),{onClick:n,connectionState:o,needsRun:r,status:s,config:a,edited:i}=t,l=s==="disabled-transitively",d=s==="running"||s==="queued";let u,h;e[0]!==l||e[1]!==a.disabled||e[2]!==o||e[3]!==i||e[4]!==d||e[5]!==r?(u=Xn(o)||d||!a.disabled&&l&&!i,h=function({connectionState:p,needsRun:b,loading:y,inactive:v}){return Xn(p)?"disabled":b&&!y?"stale":y||v?"disabled":"green"}({connectionState:o,needsRun:r,loading:d,inactive:u}),e[0]=l,e[1]=a.disabled,e[2]=o,e[3]=i,e[4]=d,e[5]=r,e[6]=u,e[7]=h):(u=e[6],h=e[7]);const f=h;if(a.disabled){let p,b;return e[8]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(np,{}),e[8]=p):p=e[8],e[9]!==u||e[10]!==n||e[11]!==f?(b=c.jsx(Ls,{tooltip:"Add code to notebook",disabled:u,onClick:n,variant:f,"data-testid":"run-button",children:p}),e[9]=u,e[10]=n,e[11]=f,e[12]=b):b=e[12],b}if(!a.disabled&&l&&!i){let p,b;return e[13]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(wr,{strokeWidth:1.2}),e[13]=p):p=e[13],e[14]!==u||e[15]!==n||e[16]!==f?(b=c.jsx(Ls,{disabled:u,tooltip:"This cell can't be run because it has a disabled ancestor",onClick:n,variant:f,"data-testid":"run-button",children:p}),e[14]=u,e[15]=n,e[16]=f,e[17]=b):b=e[17],b}let m,x,g;if(Xn(o)){let p;e[18]!==o?(p=cc(o),e[18]=o,e[19]=p):p=e[19],m=p}else if(s==="queued")m="This cell is already queued to run";else if(s==="running")m="This cell is already running.";else{let p;e[20]===Symbol.for("react.memo_cache_sentinel")?(p=Ht("cell.run"),e[20]=p):p=e[20],m=p}return e[21]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(wr,{strokeWidth:1.2}),e[21]=x):x=e[21],e[22]!==u||e[23]!==n||e[24]!==m||e[25]!==f?(g=c.jsx(Ls,{tooltip:m,disabled:u,onClick:n,variant:f,"data-testid":"run-button",children:x}),e[22]=u,e[23]=n,e[24]=m,e[25]=f,e[26]=g):g=e[26],g},Xx=G.createContext(null),Jx=O.memo(()=>O.use(Xx));Jx.displayName="DragHandle";const Zx=G.forwardRef((t,e)=>{const n=H.c(21);let o,r,s,a,i;n[0]!==t?({cellId:r,canMoveX:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=r.toString(),n[4]=r,n[5]=a):a=n[5],n[6]!==a?(i={id:a},n[6]=a,n[7]=i):i=n[7];const{attributes:l,listeners:d,setNodeRef:u,transform:h,transition:f,isDragging:m}=o1(i);let x;n[8]!==h?(x=function(y){return!y||y.x===0&&y.y===0&&y.scaleX===1&&y.scaleY===1}(h)?null:h,n[8]=h,n[9]=x):x=n[9];const g=x,p=g==null?void 0:f;let b;return n[10]!==l||n[11]!==o||n[12]!==r||n[13]!==m||n[14]!==d||n[15]!==s||n[16]!==e||n[17]!==u||n[18]!==g||n[19]!==p?(b=c.jsx(Qx,{ref:e,cellId:r,canMoveX:o,...s,attributes:l,listeners:d,setNodeRef:u,transform:g,transition:p,isDragging:m}),n[10]=l,n[11]=o,n[12]=r,n[13]=m,n[14]=d,n[15]=s,n[16]=e,n[17]=u,n[18]=g,n[19]=p,n[20]=b):b=n[20],b});Zx.displayName="SortableCell";const Qx=G.forwardRef((t,e)=>{const n=H.c(37);let o,r,s,a,i,l,d,u,h,f;if(n[0]!==t){const{cellId:_,canMoveX:A,children:I,attributes:P,listeners:R,setNodeRef:M,transform:L,transition:F,isDragging:D,...T}=t;r=A,s=I,o=P,i=R,d=M,u=L,h=F,a=D,l=T,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a,n[5]=i,n[6]=l,n[7]=d,n[8]=u,n[9]=h}else o=n[1],r=n[2],s=n[3],a=n[4],i=n[5],l=n[6],d=n[7],u=n[8],h=n[9];n[10]!==r||n[11]!==u?(f=u?mc.Transform.toString({x:r?u.x:0,y:u.y,scaleX:1,scaleY:1}):void 0,n[10]=r,n[11]=u,n[12]=f):f=n[12];const m=a?2:void 0;let x;n[13]!==f||n[14]!==m||n[15]!==h?(x={transform:f,transition:h,zIndex:m,position:"relative"},n[13]=f,n[14]=m,n[15]=h,n[16]=x):x=n[16];const g=x;let p,b;n[17]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(tp,{strokeWidth:1,size:20}),n[17]=p):p=n[17],n[18]!==o||n[19]!==i?(b=c.jsx("div",{...o,...i,onMouseDown:Dn.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:p}),n[18]=o,n[19]=i,n[20]=b):b=n[20];const y=b,v=!!u;let w;n[21]!==e||n[22]!==d?(w=_=>{rl(e,d)(_)},n[21]=e,n[22]=d,n[23]=w):w=n[23];const S=v&&"is-moving";let N,j,C;return n[24]!==l.className||n[25]!==S?(N=ge(l.className,S,"outline-none rounded-lg"),n[24]=l.className,n[25]=S,n[26]=N):N=n[26],n[27]!==s||n[28]!==y?(j=c.jsx(Xx.Provider,{value:y,children:s}),n[27]=s,n[28]=y,n[29]=j):j=n[29],n[30]!==a||n[31]!==l||n[32]!==g||n[33]!==w||n[34]!==N||n[35]!==j?(C=c.jsx("div",{tabIndex:-1,ref:w,...l,"data-is-dragging":a,className:N,style:g,children:j}),n[30]=a,n[31]=l,n[32]=g,n[33]=w,n[34]=N,n[35]=j,n[36]=C):C=n[36],C});function eb(t,e){const n=H.c(9);let o;n[0]!==t.current||n[1]!==e?(o=l=>{t.current===null||t.current.contains(l.relatedTarget)||e.current===null||Bl(e.current)},n[0]=t.current,n[1]=e,n[2]=o):o=n[2];const r=Fe(o);let s;n[3]!==t.current||n[4]!==e?(s=l=>{if(t.current===document.activeElement&&e.current!==null&&xs(e.current.state)==="active"){for(const d of a3)if(l.key===d.key&&d.run){d.run(e.current),l.preventDefault(),l.stopPropagation();break}e.current.focus()}},n[3]=t.current,n[4]=e,n[5]=s):s=n[5];const a=Fe(s);let i;return n[6]!==r||n[7]!==a?(i={closeCompletionHandler:r,resumeCompletionHandler:a},n[6]=r,n[7]=a,n[8]=i):i=n[8],i}function tb(t){const e=H.c(15),{cellId:n,cellConfig:o,languageAdapter:r,editorView:s}=t,[a,i]=St(oa);let l,d;e[0]!==n?(d=nP(n),e[0]=n,e[1]=d):d=e[1],l=d;const u=Ie(l),h=!o.hide_code||a||u,f=r==="markdown",m=f&&!h;let x;e[2]!==s||e[3]!==h||e[4]!==i?(x=v=>{var S;if(h)return;const w=(v==null?void 0:v.focus)??!0;i(!0),w&&((S=s.current)==null||S.focus())},e[2]=s,e[3]=h,e[4]=i,e[5]=x):x=e[5];const g=Fe(x);let p;e[6]!==m||e[7]!==g?(p=()=>{m&&g({focus:!0})},e[6]=m,e[7]=g,e[8]=p):p=e[8];const b=Fe(p);let y;return e[9]!==h||e[10]!==f||e[11]!==m||e[12]!==g||e[13]!==b?(y={isCellCodeShown:h,isMarkdown:f,isMarkdownCodeHidden:m,showHiddenCode:g,showHiddenCodeIfMarkdown:b},e[9]=h,e[10]=f,e[11]=m,e[12]=g,e[13]=b,e[14]=y):y=e[14],y}Qx.displayName="SortableCellInternal";const nb=O.forwardRef((t,e)=>{const n=H.c(13),{id:o,output:r,interrupted:s,errored:a,stopped:i,name:l,outputStale:d,outputLoading:u}=t;let h;n[0]===Symbol.for("react.memo_cache_sentinel")?(h=Ec("marimo-cell","hover-actions-parent z-10",{published:!0}),n[0]=h):h=n[0];const f=h,m=T3(r==null?void 0:r.mimetype);if(a||s||i||m)return null;let x,g,p;return n[1]!==o||n[2]!==l?(x=Lm(o,l),n[1]=o,n[2]=l,n[3]=x):x=n[3],n[4]!==o||n[5]!==r||n[6]!==u||n[7]!==d?(g=c.jsx(_c,{allowExpand:!1,forceExpand:!0,output:r,className:"output-area",cellId:o,stale:d,loading:u}),n[4]=o,n[5]=r,n[6]=u,n[7]=d,n[8]=g):g=n[8],n[9]!==e||n[10]!==x||n[11]!==g?(p=c.jsx("div",{tabIndex:-1,ref:e,className:f,...x,children:g}),n[9]=e,n[10]=x,n[11]=g,n[12]=p):p=n[12],p});nb.displayName="ReadonlyCellComponent";const L5=({theme:t,showPlaceholder:e,id:n,code:o,output:r,consoleOutputs:s,status:a,runStartTimestamp:i,lastRunStartTimestamp:l,runElapsedTimeMs:d,edited:u,interrupted:h,errored:f,stopped:m,staleInputs:x,serializedEditorState:g,serialization:p,debuggerActive:b,connectionState:y,canDelete:v,actions:w,deleteCell:S,userConfig:N,outline:j,isCollapsed:C,collapseCount:_,config:A,canMoveX:I,name:P,editorView:R,setEditorView:M,outputStale:L})=>{const F=O.useRef(null),D=O.useRef(null),T=O.useRef(null),k=O.useRef(null),B=kt(Is),E=Qc(n),[U,V]=O.useState(),$=A.disabled||a==="disabled-transitively",X=M3({executionTime:d,status:a,errored:f,interrupted:h,stopped:m}),Y=u||h||x&&!$,J=I3(a),Q=(a==="queued"||u||x)&&!h,q=O.useCallback(()=>R.current,[R]),{closeCompletionHandler:K,resumeCompletionHandler:re}=eb(F,R),{isCellCodeShown:oe,isMarkdown:ne,isMarkdownCodeHidden:se,showHiddenCode:te,showHiddenCodeIfMarkdown:pe}=tb({cellId:n,cellConfig:A,languageAdapter:U,editorView:R}),he=Hx(n,{canMoveX:I,editorView:R,cellActionDropdownRef:D}),ae=tP(j),ye=!A3(r),fe=s.length>0,Se=N.display.cell_output,Me=ye&&Se==="above",Ee=ye&&Se==="below",[Le,Te]=O.useState(!1),[Ze,He]=O.useState(!1);(function(W){const{ref:de,box:ue="content-box",skip:ce}=W,ve=O.useRef({...AE}),Oe=O.useRef(void 0);Oe.current=W.onResize,O.useEffect(()=>{if(!de.current||ce||typeof window>"u"||!("ResizeObserver"in window))return;const Re=new ResizeObserver(([Ye])=>{const ie=ue==="border-box"?"borderBoxSize":ue==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",je=x0(Ye,ie,"inlineSize"),_e=x0(Ye,ie,"blockSize");if(ve.current.width!==je||ve.current.height!==_e){const Be={width:je,height:_e};ve.current.width=je,ve.current.height=_e,Oe.current&&Oe.current(Be)}});return Re.observe(de.current,{box:ue}),()=>{Re.disconnect()}},[ue,de,ce])})({ref:k,skip:!ne,onResize:W=>{const de=W.height&&W.height<68,ue=se&&(de||Se==="below");Te(ue),ae&&ue?He(!0):Ze&&He(!1)}});const Ge=W=>c.jsx(E3,{tooltip:"Edit markdown",className:ge("z-20 relative",W),onClick:te}),ee=ye&&c.jsxs("div",{className:"relative",onDoubleClick:pe,children:[c.jsx("div",{className:"absolute top-5 -left-8 z-10 print:hidden",children:c.jsx(A5,{isCollapsed:C,onClick:()=>{C?w.expandCell({cellId:n}):w.collapseCell({cellId:n})},canCollapse:ae})}),se&&Ee&&Ge("top-3"),c.jsx(_c,{allowExpand:!0,forceExpand:se,output:r,className:"output-area",cellId:n,stale:L,loading:J}),se&&Me&&Ge("bottom-3")]}),be=Ec("marimo-cell","hover-actions-parent z-10",{interactive:!0,"needs-run":Y,"has-error":f,stopped:m,disabled:A.disabled,stale:a==="disabled-transitively",borderless:se&&ye&&!he["data-selected"]}),we=Fe(W=>{B({cellId:n,initialPrompt:W.prompt})}),Ae=!(!p||p.toLowerCase()!=="valid");return c.jsx(km,{children:c.jsx(Q0,{cellId:n,config:A,status:a,getEditorView:q,hasOutput:ye,hasConsoleOutput:fe,name:P,children:c.jsxs(Zx,{tabIndex:-1,ref:F,"data-status":a,onBlur:K,onKeyDown:re,cellId:n,canMoveX:I,title:A.disabled?"This cell is disabled":a==="disabled-transitively"?"This cell has a disabled ancestor":void 0,children:[c.jsxs("div",{tabIndex:-1,...he,className:ge(be,he.className,"focus:ring-1 focus:ring-[var(--blue-7)] focus:ring-offset-0"),ref:k,...Lm(n,P),children:[Se==="above"&&ee,c.jsxs("div",{className:ge("tray"),"data-hidden":se,children:[c.jsx("div",{className:"absolute right-2 -top-4 z-10",children:c.jsx(rb,{edited:u,connectionState:y,status:a,cellConfig:A,needsRun:Y,hasOutput:ye,hasConsoleOutput:fe,cellActionDropdownRef:D,cellId:n,name:P,getEditorView:q,onRun:E})}),c.jsx(F5,{cellId:n,className:ge(se&&Me&&"-top-7",se&&Ee&&"-bottom-8",se&&Ze&&"-left-[3.8rem]"),connectionState:y,actions:w}),c.jsx(Nu,{theme:t,showPlaceholder:e,id:n,code:o,config:A,status:a,serializedEditorState:g,runCell:E,setEditorView:M,userConfig:N,editorViewRef:R,editorViewParentRef:T,hidden:!oe,hasOutput:ye,showHiddenCode:te,languageAdapter:U,setLanguageAdapter:V}),c.jsx(ob,{className:ge(se&&Se==="below"&&"top-14"),edited:u,status:a,isCellStatusInline:Le,uninstantiated:X,disabled:A.disabled,runElapsedTimeMs:d,runStartTimestamp:i,lastRunStartTimestamp:l,staleInputs:x,interrupted:h}),c.jsx("div",{className:"shoulder-bottom hover-action",children:v&&oe&&c.jsx(Kx,{connectionState:y,status:a,onClick:()=>{J||Xn(y)||S({cellId:n})}})})]}),Se==="below"&&ee,p&&c.jsxs("div",{className:"py-1 px-2 flex items-center justify-end gap-2 last:rounded-b",children:[Ae&&c.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",className:"hover:underline text-muted-foreground text-xs font-bold",rel:"noopener",children:"reusable"}),c.jsx(Ne,{content:c.jsx("span",{className:"max-w-16 text-xs",children:Ae?"This function or class can be imported into other Python notebooks or modules.":c.jsxs(c.Fragment,{children:["This definition can't be reused in other Python modules:",c.jsx("br",{}),c.jsx("br",{}),c.jsx("pre",{children:p}),c.jsx("br",{}),"Click this icon to learn more."]})}),children:Ae?c.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:c.jsx(Ul,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})}):c.jsx("a",{href:"https://links.marimo.app/reusable-definitions",target:"_blank",rel:"noopener",children:c.jsx(Sm,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})})]}),c.jsx(Fm,{consoleOutputs:s,stale:Q,cellName:p?"_":P,onRefactorWithAI:we,onClear:()=>{w.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(W,de)=>{w.setStdinResponse({cellId:n,response:W,outputIndex:de}),O3({text:W})},cellId:n,debuggerActive:b}),c.jsx(M5,{cellId:n})]}),C&&c.jsx(Yx,{onClick:()=>w.expandCell({cellId:n}),count:_,cellId:n})]})})})},ob=t=>{const e=H.c(19),{className:n,disabled:o,edited:r,interrupted:s,isCellStatusInline:a,lastRunStartTimestamp:i,runElapsedTimeMs:l,runStartTimestamp:d,staleInputs:u,status:h,uninstantiated:f}=t,m=o!==void 0&&o;let x;e[0]!==m||e[1]!==r||e[2]!==s||e[3]!==i||e[4]!==l||e[5]!==d||e[6]!==u||e[7]!==h||e[8]!==f?(x=c.jsx(v0,{status:h,staleInputs:u,interrupted:s,editing:!0,edited:r,disabled:m,elapsedTime:l,runStartTimestamp:d,uninstantiated:f,lastRunStartTimestamp:i}),e[0]=m,e[1]=r,e[2]=s,e[3]=i,e[4]=l,e[5]=d,e[6]=u,e[7]=h,e[8]=f,e[9]=x):x=e[9];const g=x;let p;e[10]!==n?(p=ge("shoulder-right z-20",n),e[10]=n,e[11]=p):p=e[11];const b=!a&&g;let y;e[12]===Symbol.for("react.memo_cache_sentinel")?(y=c.jsx(Jx,{}),e[12]=y):y=e[12];const v=a&&g;let w,S;return e[13]!==v?(w=c.jsxs("div",{className:"flex gap-2 items-end",children:[y,v]}),e[13]=v,e[14]=w):w=e[14],e[15]!==p||e[16]!==b||e[17]!==w?(S=c.jsxs("div",{className:p,children:[b,w]}),e[15]=p,e[16]=b,e[17]=w,e[18]=S):S=e[18],S},F5=t=>{const e=H.c(21),{className:n,connectionState:o,actions:r,cellId:s}=t;let a;e[0]!==r||e[1]!==s?(a=w=>{const S=w===void 0?{}:w;return r.createNewCell({cellId:s,before:!1,...S})},e[0]=r,e[1]=s,e[2]=a):a=e[2];const i=Fe(a);let l;e[3]!==r||e[4]!==s?(l=w=>{const S=w===void 0?{}:w;return r.createNewCell({cellId:s,before:!0,...S})},e[3]=r,e[4]=s,e[5]=l):l=e[5];const d=Fe(l),u=D3(o);let h,f;e[6]!==n?(h=ge("absolute flex flex-col gap-[2px] justify-center h-full left-[-34px] z-20",n),e[6]=n,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=Ht("cell.createAbove"),e[8]=f):f=e[8];const m=u?d:void 0;let x,g,p;e[9]!==o||e[10]!==m?(x=c.jsx(X0,{tooltipContent:f,connectionState:o,onClick:m}),e[9]=o,e[10]=m,e[11]=x):x=e[11],e[12]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("div",{className:"flex-1"}),e[12]=g):g=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(p=Ht("cell.createBelow"),e[13]=p):p=e[13];const b=u?i:void 0;let y,v;return e[14]!==o||e[15]!==b?(y=c.jsx(X0,{tooltipContent:p,connectionState:o,onClick:b}),e[14]=o,e[15]=b,e[16]=y):y=e[16],e[17]!==h||e[18]!==x||e[19]!==y?(v=c.jsxs("div",{className:h,children:[x,g,y]}),e[17]=h,e[18]=x,e[19]=y,e[20]=v):v=e[20],v},rb=t=>{const e=H.c(27),{edited:n,connectionState:o,status:r,cellConfig:s,needsRun:a,hasOutput:i,hasConsoleOutput:l,onRun:d,cellActionDropdownRef:u,cellId:h,getEditorView:f,name:m,includeCellActions:x}=t,g=x===void 0||x,p=D3(o),b=!a&&"hover-action";let y;e[0]!==b?(y=ge(b),e[0]=b,e[1]=y):y=e[1];const v=p?d:Pn.NOOP;let w,S,N,j;return e[2]!==s||e[3]!==o||e[4]!==n||e[5]!==a||e[6]!==r||e[7]!==v?(w=c.jsx(R5,{edited:n,onClick:v,connectionState:o,status:r,config:s,needsRun:a}),e[2]=s,e[3]=o,e[4]=n,e[5]=a,e[6]=r,e[7]=v,e[8]=w):w=e[8],e[9]!==o||e[10]!==r?(S=c.jsx(tC,{status:r,connectionState:o}),e[9]=o,e[10]=r,e[11]=S):S=e[11],e[12]!==u||e[13]!==s||e[14]!==h||e[15]!==f||e[16]!==l||e[17]!==i||e[18]!==g||e[19]!==m||e[20]!==r?(N=g&&c.jsx(J0,{ref:u,cellId:h,status:r,getEditorView:f,name:m,config:s,hasOutput:i,hasConsoleOutput:l,children:c.jsx(Ls,{variant:"green",tooltip:null,"data-testid":"cell-actions-button",children:c.jsx(Dc,{strokeWidth:1.5})})}),e[12]=u,e[13]=s,e[14]=h,e[15]=f,e[16]=l,e[17]=i,e[18]=g,e[19]=m,e[20]=r,e[21]=N):N=e[21],e[22]!==y||e[23]!==w||e[24]!==S||e[25]!==N?(j=c.jsxs(eC,{className:y,children:[w,S,N]}),e[22]=y,e[23]=w,e[24]=S,e[25]=N,e[26]=j):j=e[26],j},z5=({theme:t,showPlaceholder:e,id:n,code:o,output:r,consoleOutputs:s,status:a,runStartTimestamp:i,lastRunStartTimestamp:l,runElapsedTimeMs:d,edited:u,interrupted:h,errored:f,stopped:m,staleInputs:x,serializedEditorState:g,debuggerActive:p,connectionState:b,canDelete:y,actions:v,deleteCell:w,userConfig:S,config:N,canMoveX:j,name:C,editorView:_,setEditorView:A})=>{const I=O.useRef(null),P=O.useRef(null),R=O.useRef(null),M=kt(Is),L=Qc(n),F=N.disabled||a==="disabled-transitively",D=M3({executionTime:d,status:a,errored:f,interrupted:h,stopped:m}),T=u||h||x&&!F,k=a==="running"||a==="queued",B=(a==="queued"||u||x)&&!h,E=O.useCallback(()=>_.current,[_]),{isCellCodeShown:U,showHiddenCode:V}=tb({cellId:n,cellConfig:N,languageAdapter:"python",editorView:_}),{closeCompletionHandler:$,resumeCompletionHandler:X}=eb(I,_),Y=Hx(n,{canMoveX:j,editorView:_,cellActionDropdownRef:P}),J=!A3(r),Q=s.length>0,q=T3(r==null?void 0:r.mimetype),K=Ec("marimo-cell","hover-actions-parent z-10 border shadow-sm","!border-[var(--blue-5)] !rounded-sm",{"needs-run":T,"has-error":f,stopped:m}),re=Fe(oe=>{M({cellId:n,initialPrompt:oe.prompt})});return c.jsx(km,{children:c.jsx(Q0,{cellId:n,config:N,status:a,getEditorView:E,hasOutput:J,hasConsoleOutput:Q,name:C,children:c.jsxs("div",{"data-status":a,ref:I,...Rf(Y,{className:K,onBlur:$,onKeyDown:X}),...Lm(n,C),title:N.disabled?"This cell is disabled":a==="disabled-transitively"?"This cell has a disabled ancestor":void 0,"data-setup-cell":!0,children:[c.jsxs("div",{className:ge("tray"),"data-hidden":!U,children:[c.jsx("div",{className:"absolute right-2 -top-4 z-10",children:c.jsx(rb,{edited:u,connectionState:b,status:a,cellConfig:N,needsRun:T,hasOutput:J,hasConsoleOutput:Q,cellActionDropdownRef:P,cellId:n,name:C,getEditorView:E,onRun:L,includeCellActions:!0})}),c.jsx(Nu,{theme:t,showPlaceholder:e,id:n,code:o,config:N,status:a,serializedEditorState:g,runCell:L,setEditorView:A,userConfig:S,editorViewRef:_,editorViewParentRef:R,hidden:!U,hasOutput:J,showHiddenCode:V,languageAdapter:"python",setLanguageAdapter:Pn.NOOP,showLanguageToggles:!1}),c.jsx(ob,{edited:u,status:a,isCellStatusInline:!1,uninstantiated:D,disabled:N.disabled,runElapsedTimeMs:d,runStartTimestamp:i,lastRunStartTimestamp:l,staleInputs:x,interrupted:h}),c.jsx("div",{className:"shoulder-bottom hover-action",children:y&&c.jsx(Kx,{connectionState:b,status:a,onClick:()=>{k||Xn(b)||w({cellId:n})}})})]}),c.jsxs("div",{className:"py-1 px-2 flex justify-end gap-2 last:rounded-b",children:[c.jsx("span",{className:"text-muted-foreground text-xs font-bold",children:"setup cell"}),c.jsx(Ne,{content:c.jsxs("span",{className:"max-w-16",children:["This ",c.jsx("b",{children:"setup cell"})," is guaranteed to run before all other cells. Include ",c.jsx("br",{}),"initialization or imports and constants required by top-level functions."]}),children:c.jsx(Sm,{size:16,strokeWidth:1.5,className:"rounded-lg text-muted-foreground"})})]}),q&&c.jsx(_c,{allowExpand:!0,forceExpand:!0,output:r,className:"output-area",cellId:n,stale:!1,loading:k}),c.jsx(Fm,{consoleOutputs:s,stale:B,cellName:"_",onRefactorWithAI:re,onClear:()=>{v.clearCellConsoleOutput({cellId:n})},onSubmitDebugger:(oe,ne)=>{v.setStdinResponse({cellId:n,response:oe,outputIndex:ne}),O3({text:oe})},cellId:n,debuggerActive:p})]})})})},sb=O.memo(O.forwardRef((t,e)=>{const{status:n,output:o,runStartTimestamp:r,interrupted:s,staleInputs:a,edited:i,id:l,mode:d}=t;ht.debug("Rendering Cell",l);const u=O.useRef(null);O.useImperativeHandle(e,()=>({get editorView(){return function(m){const x=m.current;if(x===null)throw new ReferenceError("Attempting to dereference null object.");return x}(u)},get editorViewOrNull(){return u.current}}),[u]);const h=QD({status:n,output:o,runStartTimestamp:r,interrupted:s,staleInputs:a},i),f=I3(n);return l===Io?c.jsx(z5,{...t,editorView:u,setEditorView:m=>{u.current=m},outputStale:h}):d==="edit"?c.jsx(eP,{atoms:[oa],children:c.jsx(L5,{...t,editorView:u,setEditorView:m=>{u.current=m},outputStale:h})}):c.jsx(nb,{...t,outputStale:h,outputLoading:f})})),B5=(t,e)=>function(n,o){const r=/^(\d+)\.(\d+)\.(\d+)(?:-([\w.-]+))?(?:\+([\w.-]+))?$/,s=a=>{const i=a.match(r);if(!i)return null;const[,l,d,u,h]=i;return{major:Number.parseInt(l,10),minor:Number.parseInt(d,10),patch:Number.parseInt(u,10),preRelease:h||""}};try{const a=s(n),i=s(o);return a&&i?a.major!==i.major?a.major-i.major:a.minor!==i.minor?a.minor-i.minor:a.patch!==i.patch?a.patch-i.patch:a.preRelease===""&&i.preRelease!==""?1:a.preRelease!==""&&i.preRelease===""?-1:a.preRelease.localeCompare(i.preRelease):n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}catch{return n.localeCompare(o,void 0,{numeric:!0,sensitivity:"base"})}}(e,t),ab=new class{constructor(t){this.ttl=void 0,this.cache=new Map,this.ttl=t.ttl}cleanupExpiredEntries(){const t=Date.now();for(const[e,n]of this.cache.entries())t-n.timestamp>this.ttl&&this.cache.delete(e)}get(t){this.cleanupExpiredEntries();const e=this.cache.get(t);if(e){if(!(Date.now()-e.timestamp>this.ttl))return e.data;this.cache.delete(t)}}set(t,e){this.cache.set(t,{data:e,timestamp:Date.now()})}clear(){this.cache.clear()}}({ttl:3e5}),U5=dt({info:dt({provides_extra:st().array().nullable()}),releases:oP(st(),rP())});function ib(t){const e=H.c(5);let n;e[0]!==t?(n=function(a){return a.replaceAll(/\[.*]/g,"").trim()}(t),e[0]=t,e[1]=n):n=e[1];const o=n;let r,s;return e[2]!==o?(r=async()=>{const a=ab.get(o);if(a)return a;const i=await fetch(`https://pypi.org/pypi/${o}/json`,{method:"GET"});if(!i.ok)throw new Error(`HTTP ${i.status}: ${i.statusText}`);const l=U5.transform($5).parse(await i.json());return ab.set(o,l),l},s=[o],e[2]=o,e[3]=r,e[4]=s):(r=e[3],s=e[4]),Cn(r,s)}function $5(t){return{versions:Object.keys(t.releases).toSorted(B5),extras:t.info.provides_extra??[]}}function lb(t){const e=t.match(/^([^[]+)(?:\[([^\]]+)])?$/);if(!e)return{name:t,extras:[]};const[,n,o]=e;return{name:n,extras:o?o.split(",").map(r=>r.trim()):[]}}const V5=()=>{const t=H.c(70),{packageAlert:e}=xL(),{clearPackageAlert:n}=bL(),[o]=mr();let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={},t[0]=r):r=t[0];const[s,a]=O.useState(r);let i;t[1]===Symbol.for("react.memo_cache_sentinel")?(i={},t[1]=i):i=t[1];const[l,d]=O.useState(i);if(e===null)return null;const u=o.package_management.manager!=="pixi";if(yL(e)){let h,f,m,x,g,p,b,y,v,w;if(t[2]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[c.jsx(Gc,{className:"w-5 h-5 inline-block mr-2"}),"Missing packages"]}),t[2]=h):h=t[2],t[3]!==n||t[4]!==e.id?(f=()=>n(e.id),t[3]=n,t[4]=e.id,t[5]=f):f=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(En,{className:"w-5 h-5"}),t[6]=m):m=t[6],t[7]!==f?(x=c.jsxs("div",{className:"flex justify-between",children:[h,c.jsx(ke,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:f,children:m})]}),t[7]=f,t[8]=x):x=t[8],t[9]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx("p",{children:"The following packages were not found:"}),t[9]=g):g=t[9],t[10]!==s||t[11]!==u||t[12]!==e.packages||t[13]!==l){let S;t[15]!==s||t[16]!==u||t[17]!==l?(S=(N,j)=>{const C=lb(N),_=l[N]||C.extras;return c.jsxs("li",{className:"flex items-center gap-2 font-mono text-sm",children:[c.jsx(Ss,{size:"1rem"}),c.jsx(G5,{packageName:C.name,selectedExtras:_,onExtrasChange:A=>d(I=>({...I,[N]:A}))}),u&&c.jsx(Y5,{value:s[N]??"latest",onChange:A=>a(I=>({...I,[N]:A})),packageName:C.name})]},j)},t[15]=s,t[16]=u,t[17]=l,t[18]=S):S=t[18],p=e.packages.map(S),t[10]=s,t[11]=u,t[12]=e.packages,t[13]=l,t[14]=p}else p=t[14];return t[19]!==p?(b=c.jsxs("div",{children:[g,c.jsx("ul",{className:"list-disc ml-4 mt-1",children:p})]}),t[19]=p,t[20]=b):b=t[20],t[21]!==n||t[22]!==s||t[23]!==e.id||t[24]!==e.isolated||t[25]!==e.packages||t[26]!==l||t[27]!==o.package_management.manager?(y=c.jsx("div",{className:"ml-auto flex flex-row items-baseline",children:e.isolated?c.jsxs(c.Fragment,{children:[c.jsx(W5,{manager:o.package_management.manager,packages:e.packages.map(S=>{const N=lb(S),j=l[S]||N.extras;return function(C,_){return _.length===0?C:`${C}[${_.join(",")}]`}(N.name,j)}),versions:s,clearPackageAlert:()=>n(e.id)}),!Jt()&&c.jsxs(c.Fragment,{children:[c.jsx("span",{className:"px-2 text-sm",children:"with"})," ",c.jsx(q5,{})]})]}):c.jsxs("p",{children:["If you set up a"," ",c.jsx(Kf,{href:"https://docs.python.org/3/tutorial/venv.html#creating-virtual-environments",children:"virtual environment"}),", marimo can install these packages for you."]})}),t[21]=n,t[22]=s,t[23]=e.id,t[24]=e.isolated,t[25]=e.packages,t[26]=l,t[27]=o.package_management.manager,t[28]=y):y=t[28],t[29]!==b||t[30]!==y?(v=c.jsxs("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:[b,y]}),t[29]=b,t[30]=y,t[31]=v):v=t[31],t[32]!==v||t[33]!==x?(w=c.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:c.jsxs(Za,{kind:"danger",className:"flex flex-col rounded py-3 px-5 animate-in slide-in-from-left",children:[x,v]})}),t[32]=v,t[33]=x,t[34]=w):w=t[34],w}if(vL(e)){let h;t[35]!==e.packages?(h=function(M){const L=new Set(Object.values(M)),F=L.has("queued")||L.has("installing")?"installing":L.has("failed")?"failed":"installed";return F==="installing"?{status:"installing",title:"Installing packages",titleIcon:c.jsx(si,{className:"w-5 h-5 inline-block mr-2"}),description:"Installing packages:"}:F==="installed"?{status:"installed",title:"All packages installed!",titleIcon:c.jsx(mp,{className:"w-5 h-5 inline-block mr-2"}),description:"Installed packages:"}:{status:"failed",title:"Some packages failed to install",titleIcon:c.jsx(Gc,{className:"w-5 h-5 inline-block mr-2"}),description:"See terminal for error logs."}}(e.packages),t[35]=e.packages,t[36]=h):h=t[36];const{status:f,title:m,titleIcon:x,description:g}=h;f==="installed"&&setTimeout(()=>n(e.id),1e4);const p=f==="failed"?"danger":"info";let b,y,v,w,S;t[37]!==m||t[38]!==x?(b=c.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[x,m]}),t[37]=m,t[38]=x,t[39]=b):b=t[39],t[40]!==n||t[41]!==e.id?(y=()=>n(e.id),t[40]=n,t[41]=e.id,t[42]=y):y=t[42],t[43]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsx(En,{className:"w-5 h-5"}),t[43]=v):v=t[43],t[44]!==y?(w=c.jsx(ke,{variant:"text","data-testid":"remove-banner-button",size:"icon",onClick:y,children:v}),t[44]=y,t[45]=w):w=t[45],t[46]!==b||t[47]!==w?(S=c.jsxs("div",{className:"flex justify-between",children:[b,w]}),t[46]=b,t[47]=w,t[48]=S):S=t[48];const N=f==="installed"&&"text-accent-foreground";let j,C,_,A,I,P,R;if(t[49]!==N?(j=ge("flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",N),t[49]=N,t[50]=j):j=t[50],t[51]!==g?(C=c.jsx("p",{children:g}),t[51]=g,t[52]=C):C=t[52],t[53]!==e.packages||t[54]!==f){let M;t[56]!==f?(M=(L,F)=>{const[D,T]=L;return c.jsxs("li",{className:ge("flex items-center gap-1 font-mono text-sm",T==="installing"&&"font-semibold",T==="failed"&&"text-destructive",T==="installed"&&"text-accent-foreground",T==="installed"&&f==="failed"&&"text-muted-foreground"),children:[c.jsx(H5,{status:T}),D]},F)},t[56]=f,t[57]=M):M=t[57],_=Object.entries(e.packages).map(M),t[53]=e.packages,t[54]=f,t[55]=_}else _=t[55];return t[58]!==_?(A=c.jsx("ul",{className:"list-disc ml-4 mt-1",children:_}),t[58]=_,t[59]=A):A=t[59],t[60]!==C||t[61]!==A?(I=c.jsxs("div",{children:[C,A]}),t[60]=C,t[61]=A,t[62]=I):I=t[62],t[63]!==j||t[64]!==I?(P=c.jsx("div",{className:j,children:I}),t[63]=j,t[64]=I,t[65]=P):P=t[65],t[66]!==P||t[67]!==p||t[68]!==S?(R=c.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-12 min-w-[400px] z-[200] opacity-95",children:c.jsxs(Za,{kind:p,className:"flex flex-col rounded pt-3 pb-4 px-5",children:[S,P]})}),t[66]=P,t[67]=p,t[68]=S,t[69]=R):R=t[69],R}return ec(e),null},H5=t=>{const e=H.c(4),{status:n}=t;switch(n){case"queued":{let o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(Ss,{size:"1rem"}),e[0]=o):o=e[0],o}case"installing":{let o;return e[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(si,{size:"1rem"}),e[1]=o):o=e[1],o}case"installed":{let o;return e[2]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(rc,{size:"1rem"}),e[2]=o):o=e[2],o}case"failed":{let o;return e[3]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(En,{size:"1rem"}),e[3]=o):o=e[3],o}default:return ec(n),null}},W5=t=>{const e=H.c(9),{manager:n,packages:o,versions:r,clearPackageAlert:s}=t;let a,i,l,d;return e[0]!==s||e[1]!==n||e[2]!==o||e[3]!==r?(a=async()=>{s();const u={...r};for(const h of o)u[h]=u[h]??"";await lP({manager:n,versions:u}).catch(K5)},e[0]=s,e[1]=n,e[2]=o,e[3]=r,e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(si,{className:"w-4 h-4 mr-2"}),l=c.jsx("span",{className:"font-semibold",children:"Install"}),e[5]=i,e[6]=l):(i=e[5],l=e[6]),e[7]!==a?(d=c.jsxs(ke,{variant:"outline","data-testid":"install-packages-button",size:"sm",onClick:a,children:[i,l]}),e[7]=a,e[8]=d):d=e[8],d},q5=()=>{const t=H.c(16),[e,n]=mr();let o,r;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=Rk(sP),t[0]=o):o=t[0],t[1]!==e?(r={resolver:o,defaultValues:e},t[1]=e,t[2]=r):r=t[2];const s=Lk(r);let a;t[3]!==n?(a=async f=>{await pr({config:f}).then(()=>{n(f)})},t[3]=n,t[4]=a):a=t[4];const i=a;let l,d,u,h;return t[5]!==s||t[6]!==i?(l=s.handleSubmit(i),t[5]=s,t[6]=i,t[7]=l):l=t[7],t[8]!==s.control?(d=c.jsx("div",{className:"flex flex-col gap-3",children:c.jsx(Ak,{control:s.control,name:"package_management.manager",render:J5})}),t[8]=s.control,t[9]=d):d=t[9],t[10]!==l||t[11]!==d?(u=c.jsx("form",{onChange:l,className:"flex flex-col gap-5",children:d}),t[10]=l,t[11]=d,t[12]=u):u=t[12],t[13]!==s||t[14]!==u?(h=c.jsx(aP,{...s,children:u}),t[13]=s,t[14]=u,t[15]=h):h=t[15],h},G5=t=>{const e=H.c(14),{packageName:n,selectedExtras:o,onExtrasChange:r}=t,[s,a]=O.useState(!1),{isPending:i,error:l,data:d}=ib(n);let u;e[0]!==r||e[1]!==o?(u=(g,p)=>{r(p?[...o,g]:o.filter(b=>b!==g))},e[0]=r,e[1]=o,e[2]=u):u=e[2];const h=u,f=!i&&!l;let m,x;if(e[3]!==(d==null?void 0:d.extras)?(m=(d==null?void 0:d.extras)??[],e[3]=d==null?void 0:d.extras,e[4]=m):m=e[4],e[5]!==f||e[6]!==h||e[7]!==s||e[8]!==n||e[9]!==o||e[10]!==m){const g=m.filter(Z5);let p;e[12]!==n?(p=c.jsx("span",{className:"shrink-0",children:n}),e[12]=n,e[13]=p):p=e[13],x=c.jsxs("div",{className:"flex items-center max-w-72",children:[p,o.length>0?c.jsxs("span",{className:"flex items-center min-w-0 flex-1",children:[c.jsx("span",{className:"shrink-0",children:"["}),c.jsxs(ko,{open:s&&f,onOpenChange:b=>{f&&a(b)},children:[c.jsx(So,{asChild:!0,children:c.jsx("button",{className:"hover:bg-muted/50 rounded text-sm px-1 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 min-w-0 flex-1 truncate text-left",title:`Selected extras: ${o.join(", ")}`,children:o.join(",")})}),c.jsxs(No,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[o.length>0&&c.jsx("div",{className:"p-2 bg-popover border-b border-border",children:c.jsx("div",{className:"flex flex-wrap gap-1 p-1 min-h-[24px]",children:o.map(b=>c.jsxs("span",{className:"inline-flex items-center gap-1 px-1 py-0.5 text-sm font-mono border border-muted-foreground/30 hover:border-muted-foreground/60 rounded-sm cursor-pointer group transition-colors",onClick:()=>h(b,!1),children:[b,c.jsx(En,{className:"w-3 h-3 opacity-60 group-hover:opacity-100"})]},b))})}),c.jsx("div",{className:"overflow-y-auto flex-1",children:g.map(b=>c.jsx(P3,{checked:o.includes(b),onCheckedChange:y=>{h(b,y)},className:"font-mono text-sm",onSelect:Q5,children:b},b))})]})]}),c.jsx("span",{className:"shrink-0",children:"]"})]}):g.length>0?c.jsxs(ko,{open:s&&f,onOpenChange:b=>{f&&a(b)},children:[c.jsx(So,{asChild:!0,children:c.jsx("button",{disabled:!f,className:ge("hover:bg-muted/50 rounded text-sm ml-2 transition-colors border border-muted-foreground/30 hover:border-muted-foreground/60 h-5 w-5 flex items-center justify-center p-0",!f&&"opacity-50 cursor-not-allowed"),title:f?"Add extras":"Loading extras...",children:c.jsx(Ko,{className:"w-3 h-3 flex-shrink-0"})})}),c.jsxs(No,{align:"start",className:"w-64 p-0 max-h-96 flex flex-col",children:[c.jsx("div",{className:"p-2 bg-popover border-b border-border",children:c.jsx("span",{className:"text-muted-foreground italic text-sm",children:"Package extras"})}),c.jsx("div",{className:"overflow-y-auto flex-1",children:g.map(b=>c.jsx(P3,{checked:o.includes(b),onCheckedChange:y=>{h(b,y)},className:"font-mono text-sm",onSelect:e_,children:b},b))})]})]}):null]}),e[5]=f,e[6]=h,e[7]=s,e[8]=n,e[9]=o,e[10]=m,e[11]=x}else x=e[11];return x},Y5=t=>{const e=H.c(16),{value:n,onChange:o,packageName:r}=t,{error:s,isPending:a,data:i}=ib(r);if(s){let h,f,m;return e[0]!==o?(h=x=>o(x.target.value),e[0]=o,e[1]=h):h=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx("option",{value:"latest",children:"latest"}),e[2]=f):f=e[2],e[3]!==h||e[4]!==n?(m=c.jsx(Ne,{content:"Failed to fetch package versions",children:c.jsx(Nm,{value:n,onChange:h,disabled:!0,className:"inline-flex ml-2 w-24 text-ellipsis",children:f})}),e[3]=h,e[4]=n,e[5]=m):m=e[5],m}let l,d,u;return e[6]!==o?(l=h=>o(h.target.value),e[6]=o,e[7]=l):l=e[7],e[8]!==a||e[9]!==i?(d=a?c.jsx("option",{value:"latest",children:"latest"}):["latest",...i.versions.slice(0,100)].map(t_),e[8]=a,e[9]=i,e[10]=d):d=e[10],e[11]!==a||e[12]!==l||e[13]!==d||e[14]!==n?(u=c.jsx(Nm,{value:n,onChange:l,disabled:a,className:"inline-flex ml-2 w-24 text-ellipsis",children:d}),e[11]=a,e[12]=l,e[13]=d,e[14]=n,e[15]=u):u=e[15],u};function K5(t){ht.error(t)}function X5(t){return c.jsx("option",{value:t,children:t},t)}function J5(t){const{field:e}=t;return c.jsxs(Tk,{children:[c.jsx(Mk,{children:c.jsx(Nm,{"data-testid":"install-package-manager-select",onChange:n=>e.onChange(n.target.value),value:e.value,disabled:e.disabled,className:"inline-flex mr-2",children:iP.map(X5)})}),c.jsx(Pk,{})]})}function Z5(t){return!/^(dev|test|testing)$/i.test(t)}function Q5(t){return t.preventDefault()}function e_(t){return t.preventDefault()}function t_(t){return c.jsx("option",{value:t,children:t},t)}const n_=t=>{let{transform:e}=t;return{...e,x:0}},o_={threshold:{x:0,y:.1}},r_=G.memo(t=>{const e=H.c(23),{children:n,multiColumn:o}=t,{dropCellOverCell:r,dropCellOverColumn:s,moveColumn:a,compactColumns:i}=it(),[l,d]=O.useState(null),[u,h]=O.useState(null),[f]=Ck();let m;e:{if(f.width==="columns"){m=jm.EMPTY;break e}let M;e[0]===Symbol.for("react.memo_cache_sentinel")?(M=[n_],e[0]=M):M=e[0],m=M}const x=m;let g,p;e[1]===Symbol.for("react.memo_cache_sentinel")?(g={activationConstraint:{distance:8}},e[1]=g):g=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(p={coordinateGetter:Z4},e[2]=p):p=e[2];const b=function(){for(var M=arguments.length,L=new Array(M),F=0;F<M;F++)L[F]=arguments[F];return O.useMemo(()=>[...L].filter(D=>D!=null),[...L])}(Cg(jd,g),Cg(Sd,p));let y;e[3]===Symbol.for("react.memo_cache_sentinel")?(y=M=>{d(M.active.id);const L=mn();h(L.cellIds)},e[3]=y):y=e[3];const v=Fe(y);let w;e[4]!==u?(w=()=>{d(null),h(null)},e[4]=u,e[5]=w):w=e[5];const S=Fe(w);let N;e[6]!==l?(N=M=>{const L=M.droppableContainers.filter(s_);if(l&&Lr(l))return bd({...M,droppableContainers:L});const F=(E=>{let{droppableContainers:U,droppableRects:V,pointerCoordinates:$}=E;if(!$)return[];const X=[];for(const Y of U){const{id:J}=Y,Q=V.get(J);if(Q&&g4($,Q)){const q=gd(Q).reduce((re,oe)=>re+md($,oe),0),K=Number((q/4).toFixed(4));X.push({id:J,data:{droppableContainer:Y,value:K}})}}return X.sort(pd)})({...M,droppableContainers:L}),D=xd(F.length>0?F:_g({...M,droppableContainers:L}),"id");if(!D)return[];jo(Lr(D),`Expected column id. Got: ${D}`);const T=mn().cellIds.get(D);if(jo(T,`Expected column. Got: ${D}`),T&&T.topLevelIds.length===0)return[{id:D}];const k=new Set(T.topLevelIds),B=bd({...M,droppableContainers:M.droppableContainers.filter(E=>E.id!==D&&k.has(E.id))});if(B.length>0){const E=B[0].id;return jo(ju(E),`Expected cell id. Got: ${E}`),[{id:E}]}return[]},e[6]=l,e[7]=N):N=e[7];const j=N;let C;e[8]!==r||e[9]!==s||e[10]!==a?(C=M=>{const{active:L,over:F}=M,D=F==null?void 0:F.id;if(D!=null&&L.id!==D){if(ju(L.id)){if(Lr(D))return void s({cellId:L.id,columnId:D});if(ju(D))return void r({cellId:L.id,overCellId:D})}Lr(L.id)&&Lr(D)&&a({column:L.id,overColumn:D})}},e[8]=r,e[9]=s,e[10]=a,e[11]=C):C=e[11];const _=Fe(C);let A;e[12]!==i?(A=M=>{const{active:L,over:F}=M;F!==null&&L.id!==F.id&&i()},e[12]=i,e[13]=A):A=e[13];const I=Fe(A),P=o?j:bd;let R;return e[14]!==n||e[15]!==S||e[16]!==I||e[17]!==_||e[18]!==v||e[19]!==x||e[20]!==b||e[21]!==P?(R=c.jsx(z4,{autoScroll:o_,sensors:b,collisionDetection:P,modifiers:x,onDragEnd:I,onDragStart:v,onDragCancel:S,onDragOver:_,children:n}),e[14]=n,e[15]=S,e[16]=I,e[17]=_,e[18]=v,e[19]=x,e[20]=b,e[21]=P,e[22]=R):R=e[22],R});function ju(t){return typeof t=="string"&&!t.startsWith("tree_")}function Lr(t){return typeof t=="string"&&t.startsWith("tree_")}function s_(t){return Lr(t.id)}const a_=t=>{const e=H.c(13),{className:n,size:o,gap:r,durationMs:s}=t,a=o===void 0?8:o,i=r===void 0?"gap-1":r,l=s===void 0?1200:s,d=`${l}ms`;let u;e[0]!==d?(u={animationDuration:d},e[0]=d,e[1]=u):u=e[1];const h=u;let f,m,x,g;return e[2]!==n||e[3]!==i?(f=Ec("flex",i,n),e[2]=n,e[3]=i,e[4]=f):f=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(m=[0,1,2],e[5]=m):m=e[5],e[6]!==h||e[7]!==l||e[8]!==a?(x=m.map(p=>c.jsx(cP,{width:a,height:a,className:"fill-current text-current animate-ellipsis-dot",style:{...h,animationDelay:l/3*p+"ms"}},p)),e[6]=h,e[7]=l,e[8]=a,e[9]=x):x=e[9],e[10]!==f||e[11]!==x?(g=c.jsx("div",{className:f,"aria-label":"Loading",children:x}),e[10]=f,e[11]=x,e[12]=g):g=e[12],g},cb=t=>{const e=H.c(11),{title:n,children:o,show:r,delayMs:s,kind:a}=t,i=s===void 0?2e3:s,l=a===void 0?"info":a;if(!r)return null;let d,u,h;e[0]!==n?(d=n&&c.jsx("div",{className:"flex justify-between",children:c.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:n})}),e[0]=n,e[1]=d):d=e[1],e[2]!==o?(u=c.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:c.jsx("div",{children:o})}),e[2]=o,e[3]=u):u=e[3],e[4]!==l||e[5]!==d||e[6]!==u?(h=c.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-[200] opacity-95",children:c.jsxs(Za,{kind:l,className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[d,u]})}),e[4]=l,e[5]=d,e[6]=u,e[7]=h):h=e[7];const f=h;let m;return e[8]!==f||e[9]!==i?(m=c.jsx(Cc,{milliseconds:i,children:f}),e[8]=f,e[9]=i,e[10]=m):m=e[10],m},i_=()=>{const t=H.c(3),e=Ie(dP),n=Ie(uP);let o;return t[0]!==n||t[1]!==e?(o=e&&c.jsxs(c.Fragment,{children:[c.jsx(Cc,{milliseconds:1e3,children:c.jsx("div",{className:"absolute top-4 m-0 flex items-center min-h-[28px] left-1/2 transform -translate-x-1/2 z-[200] ",children:c.jsx(Ne,{content:"Connecting to a marimo runtime",children:c.jsx("div",{className:"flex items-center",children:c.jsx(a_,{size:5,className:"text-yellow-500"})})})})}),c.jsx(cb,{show:e,delayMs:5e3,children:c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx(bn,{className:"h-4 w-4"}),c.jsx("p",{children:"Connecting to a marimo runtime ..."})]})})]})||n&&c.jsx(cb,{show:n,kind:"danger",children:c.jsx("div",{className:"flex items-center gap-2",children:c.jsx("p",{children:"Failed to connect."})})}),t[0]=n,t[1]=e,t[2]=o):o=t[2],o},db=G.forwardRef((t,e)=>{const n=H.c(71);let o,r,s,a,i,l,d;n[0]!==t?({columnId:a,canDelete:o,canMoveLeft:r,canMoveRight:s,footer:i,...l}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a,n[5]=i,n[6]=l):(o=n[1],r=n[2],s=n[3],a=n[4],i=n[5],l=n[6]),n[7]!==a?(d={id:a},n[7]=a,n[8]=d):d=n[8];const{attributes:u,listeners:h,setNodeRef:f,transform:m,transition:x,isDragging:g,isOver:p}=o1(d);let b;n[9]!==m?(b=m?mc.Transform.toString({x:m.x,y:0,scaleX:1,scaleY:1}):void 0,n[9]=m,n[10]=b):b=n[10];const y=g?2:void 0;let v;n[11]!==b||n[12]!==y||n[13]!==x?(v={transform:b,transition:x,zIndex:y,position:"relative","--gutter-width":"50px"},n[11]=b,n[12]=y,n[13]=x,n[14]=v):v=n[14];const w=v,{deleteColumn:S,moveColumn:N,addColumn:j}=it(),C=c_;let _;n[15]!==a||n[16]!==N?(_=()=>N({column:a,overColumn:"_left_"}),n[15]=a,n[16]=N,n[17]=_):_=n[17];const A=!r;let I,P,R;n[18]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsx(jk,{className:"size-4"}),n[18]=I):I=n[18],n[19]!==_||n[20]!==A?(P=c.jsx(Ne,{content:"Move column left",side:"top",delayDuration:300,children:c.jsx(ke,{variant:"text",size:"xs",className:"hover:bg-[var(--gray-3)] aspect-square p-0 w-7 h-7",onClick:_,disabled:A,children:I})}),n[19]=_,n[20]=A,n[21]=P):P=n[21],n[22]!==a||n[23]!==N?(R=()=>N({column:a,overColumn:"_right_"}),n[22]=a,n[23]=N,n[24]=R):R=n[24];const M=!s;let L,F,D,T,k,B;n[25]===Symbol.for("react.memo_cache_sentinel")?(L=c.jsx(Ta,{className:"size-4"}),n[25]=L):L=n[25],n[26]!==M||n[27]!==R?(F=c.jsx(Ne,{content:"Move column right",side:"top",delayDuration:300,children:c.jsx(ke,{variant:"text",size:"xs",className:"hover:bg-[var(--gray-3)] aspect-square p-0 w-7 h-7",onClick:R,disabled:M,children:L})}),n[26]=M,n[27]=R,n[28]=F):F=n[28],n[29]===Symbol.for("react.memo_cache_sentinel")?(D=c.jsx(hP,{className:"size-4 opacity-0 group-hover:opacity-50 transition-opacity duration-200"}),n[29]=D):D=n[29],n[30]!==u||n[31]!==h?(T=c.jsx("div",{className:"flex gap-2 h-full flex-grow cursor-grab active:cursor-grabbing items-center justify-center","data-testid":"column-drag-spacer",...u,...h,children:D}),n[30]=u,n[31]=h,n[32]=T):T=n[32],n[33]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(So,{asChild:!0,children:c.jsx(ke,{variant:"text",size:"xs",className:"hover:bg-[var(--gray-3)] aspect-square p-0 w-7 h-7",children:c.jsx(Dc,{className:"size-4"})})}),n[33]=k):k=n[33],n[34]!==a||n[35]!==S?(B=()=>S({columnId:a}),n[34]=a,n[35]=S,n[36]=B):B=n[36];const E=!o;let U,V,$,X,Y,J;n[37]===Symbol.for("react.memo_cache_sentinel")?(U=c.jsx(En,{className:"mr-2 size-4"}),n[37]=U):U=n[37],n[38]!==B||n[39]!==E?(V=c.jsxs(ko,{children:[k,c.jsx(No,{align:"end",children:c.jsxs(It,{onClick:B,disabled:E,children:[U,"Delete column"]})})]}),n[38]=B,n[39]=E,n[40]=V):V=n[40],n[41]!==j||n[42]!==a?($=()=>{j({columnId:a}),requestAnimationFrame(C)},n[41]=j,n[42]=a,n[43]=$):$=n[43],n[44]===Symbol.for("react.memo_cache_sentinel")?(X=c.jsx(Ko,{className:"size-4"}),n[44]=X):X=n[44],n[45]!==$?(Y=c.jsx(Ne,{content:"Add column",side:"top",delayDuration:300,children:c.jsx(ke,{variant:"text",size:"xs",className:"hover:bg-[var(--gray-3)] aspect-square p-0 w-7 h-7",onClick:$,children:X})}),n[45]=$,n[46]=Y):Y=n[46],n[47]!==F||n[48]!==T||n[49]!==V||n[50]!==Y||n[51]!==P?(J=c.jsxs("div",{className:"px-2 pt-3 pb-0 group flex items-center rounded-t-lg overflow-hidden",children:[P,F,T,V,Y]}),n[47]=F,n[48]=T,n[49]=V,n[50]=Y,n[51]=P,n[52]=J):J=n[52];const Q=J;let q;n[53]!==e||n[54]!==f?(q=pe=>{rl(e,f)(pe)},n[53]=e,n[54]=f,n[55]=q):q=n[55];const K=g?"":l.className,re=g?"z-20":"z-1 hover:z-10 focus-within:z-10",oe=p&&"bg-accent/20";let ne,se,te;return n[56]!==K||n[57]!==re||n[58]!==oe?(ne=ge(K,re,oe),n[56]=K,n[57]=re,n[58]=oe,n[59]=ne):ne=n[59],n[60]!==Q||n[61]!==l.children?(se=c.jsxs("div",{className:"bg-[var(--slate-1)] rounded-lg",children:[Q,l.children]}),n[60]=Q,n[61]=l.children,n[62]=se):se=n[62],n[63]!==i||n[64]!==g||n[65]!==l||n[66]!==w||n[67]!==q||n[68]!==ne||n[69]!==se?(te=c.jsxs("div",{tabIndex:-1,ref:q,...l,style:w,"data-is-dragging":g,className:ne,children:[se,i]}),n[63]=i,n[64]=g,n[65]=l,n[66]=w,n[67]=q,n[68]=ne,n[69]=se,n[70]=te):te=n[70],te});db.displayName="SortableColumn";const l_=O.memo(db);function c_(){const t=document.getElementById("App");t&&t.scrollTo({left:t.scrollLeft+1e3,behavior:"smooth"})}const{getColumnWidth:d_,saveColumnWidth:u_}=fP,ub=O.memo(t=>{const e=H.c(20),n=O.useRef(null);if(t.width==="columns"){const s=t.canDelete,a=t.columnId,i=t.canMoveLeft,l=t.canMoveRight,d=t.footer;let u,h,f,m;return e[0]!==t.index?(u=d_(t.index),e[0]=t.index,e[1]=u):u=e[1],e[2]!==t.index?(h=x=>{u_(t.index,x)},e[2]=t.index,e[3]=h):h=e[3],e[4]!==t.children||e[5]!==u||e[6]!==h?(f=c.jsx(h_,{startingWidth:u,onResize:h,children:t.children}),e[4]=t.children,e[5]=u,e[6]=h,e[7]=f):f=e[7],e[8]!==t.canDelete||e[9]!==t.canMoveLeft||e[10]!==t.canMoveRight||e[11]!==t.columnId||e[12]!==t.footer||e[13]!==f?(m=c.jsx(l_,{tabIndex:-1,ref:n,canDelete:s,columnId:a,canMoveLeft:i,canMoveRight:l,className:"group/column",footer:d,children:f}),e[8]=t.canDelete,e[9]=t.canMoveLeft,e[10]=t.canMoveRight,e[11]=t.columnId,e[12]=t.footer,e[13]=f,e[14]=m):m=e[14],m}let o,r;return e[15]!==t.children?(o=c.jsx("div",{"data-testid":"cell-column",className:"flex flex-col gap-5",children:t.children}),e[15]=t.children,e[16]=o):o=e[16],e[17]!==t.footer||e[18]!==o?(r=c.jsxs(c.Fragment,{children:[o,t.footer]}),e[17]=t.footer,e[18]=o,e[19]=r):r=e[19],r});ub.displayName="Column";const h_=t=>{const e=H.c(15),{startingWidth:n,onResize:o,children:r}=t;let s;e[0]!==o||e[1]!==n?(s={startingWidth:n,onResize:o},e[0]=o,e[1]=n,e[2]=s):s=e[2];const{resizableDivRef:a,handleRefs:i,style:l}=mP(s),d=f_;let u,h,f,m;return e[3]!==i.left?(u=d(i.left),e[3]=i.left,e[4]=u):u=e[4],e[5]!==r||e[6]!==a||e[7]!==l?(h=c.jsx("div",{ref:a,className:"flex flex-col gap-5 box-content min-h-[100px] px-11 pt-3 pb-6 min-w-[500px] z-1",style:l,children:r}),e[5]=r,e[6]=a,e[7]=l,e[8]=h):h=e[8],e[9]!==i.right?(f=d(i.right),e[9]=i.right,e[10]=f):f=e[10],e[11]!==u||e[12]!==h||e[13]!==f?(m=c.jsxs("div",{className:"flex flex-row",children:[u,h,f]}),e[11]=u,e[12]=h,e[13]=f,e[14]=m):m=e[14],m};function f_(t){return c.jsx("div",{ref:t,className:`w-[3px] cursor-col-resize transition-colors duration-200 z-[100]
124
- relative before:content-[''] before:absolute before:inset-y-0 before:-left-[3px]
125
- before:right-[-3px] before:w-[9px] before:z-[-1]
126
- hover/column:bg-[var(--slate-3)] dark:hover/column:bg-[var(--slate-5)]
127
- hover/column:hover:bg-primary/60 dark:hover/column:hover:bg-primary/60`})}const m_=t=>{const e=H.c(10),{width:n}=t,{banners:o}=wL(),{removeBanner:r}=kL();if(o.length===0)return null;const s=n==="columns"&&"sticky left-12 w-full max-w-[80vw]";let a,i,l;if(e[0]!==s?(a=ge("flex flex-col gap-4 mb-5 print:hidden",s),e[0]=s,e[1]=a):a=e[1],e[2]!==o||e[3]!==r){let d;e[5]!==r?(d=u=>c.jsxs(Za,{kind:u.variant||"info",className:"flex flex-col rounded p-3",children:[c.jsxs("div",{className:"flex justify-between",children:[c.jsxs("span",{className:"font-bold text-lg flex items-center mb-2",children:[c.jsx(R3,{className:"w-5 h-5 inline-block mr-2"}),u.title]}),c.jsx(ke,{"data-testid":"remove-banner-button",variant:"text",size:"icon",onClick:()=>r(u.id),children:c.jsx(En,{className:"w-5 h-5"})})]}),c.jsxs("div",{className:"flex justify-between items-end",children:[c.jsx("span",{children:Cm({html:u.description})}),u.action==="restart"&&c.jsx(p_,{})]})]},u.id),e[5]=r,e[6]=d):d=e[6],i=o.map(d),e[2]=o,e[3]=r,e[4]=i}else i=e[4];return e[7]!==a||e[8]!==i?(l=c.jsx("div",{className:a,children:i}),e[7]=a,e[8]=i,e[9]=l):l=e[9],l},p_=()=>{const t=H.c(3),e=fg();let n,o;return t[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx(yp,{className:"w-3 h-3 mr-2"}),t[0]=n):n=t[0],t[1]!==e?(o=c.jsxs(ke,{"data-testid":"restart-session-button",variant:"link",size:"xs",onClick:e,children:[n,"Restart"]}),t[1]=e,t[2]=o):o=t[2],o},g_=mt(t=>{const e=t(pn);for(const n of e.cellIds.inOrderIds){const o=e.cellRuntime[n];if(o.status==="idle"&&o.consoleOutputs.some(r=>r.channel==="stdin"&&r.response===void 0))return!0}return!1}),x_=()=>{const t=H.c(3),e=b_;if(!Ie(g_))return null;let n,o,r;if(t[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.jsx("div",{className:"flex justify-between",children:c.jsx("span",{className:"font-bold text-lg flex items-center mb-1",children:"Program waiting for input"})}),t[0]=n):n=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(s3,{className:"inline",children:"stdin"}),t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")){const s=c.jsx("div",{className:"flex flex-col gap-4 mb-5 fixed top-5 left-1/2 transform -translate-x-1/2 z-[200] opacity-95",children:c.jsxs(Za,{kind:"info",className:"flex flex-col rounded py-2 px-4 animate-in slide-in-from-top w-fit",children:[n,c.jsx("div",{className:"flex flex-col gap-4 justify-between items-start text-muted-foreground text-base",children:c.jsx("div",{children:c.jsxs("p",{children:["The program is still running, but blocked on"," ",o,".",c.jsx(ke,{variant:"link",className:"h-auto font-normal",onClick:e,children:"Jump to the cell"})]})})})]})});r=c.jsx(Cc,{milliseconds:2e3,children:s}),t[2]=r}else r=t[2];return r};function b_(){const t=document.querySelector("[data-stdin-blocking]");t?(t.scrollIntoView({behavior:"smooth",block:"center"}),requestAnimationFrame(()=>{t.focus()})):ht.error("No element with data-stdin-blocking found")}function y_(){const t=setTimeout(v_,100);return()=>clearTimeout(t)}function v_(){requestAnimationFrame(w_)}function w_(){const t=function(e){const n=e.match(/scrollTo=([^&]+)/),o=n==null?void 0:n[1];return o?decodeURIComponent(o.split("&")[0]):null}(window.location.hash);if(t)(function(e){var o,r;if(fb)return;const n=document.querySelector(`[data-cell-name="${e}"]`);if(n){if(n.scrollIntoView({behavior:"smooth",block:"start"}),fb=!0,n instanceof HTMLElement){n.focus();const{cellHandles:s}=mn(),a=n.dataset.cellId;if(!a)return void ht.error(`Missing cellId for cell with name ${e}`);const i=(r=(o=s[a])==null?void 0:o.current)==null?void 0:r.editorView;i&&i.focus()}}else ht.warn(`Cannot focus cell with name ${e} because it was not found`),hb()})(t);else try{hb()}catch(e){const n=e;ht.warn("Error focusing first editor",n)}}function hb(){var o,r;const{cellIds:t,cellData:e,cellHandles:n}=mn();for(const s of t.iterateTopLevelIds){const a=n[s];if(!((o=e[s])==null?void 0:o.config.hide_code)&&((r=a==null?void 0:a.current)!=null&&r.editorView))return void a.current.editorView.focus()}}let fb=!1;const k_=t=>{const e=H.c(8),n=Ie(pP),o=t.appConfig.width==="columns";let r,s,a;return e[0]!==t?(r=c.jsx(S_,{...t}),e[0]=t,e[1]=r):r=e[1],e[2]!==n||e[3]!==r?(s=c.jsx(t1,{id:"column-container",items:n,strategy:H4,children:r}),e[2]=n,e[3]=r,e[4]=s):s=e[4],e[5]!==o||e[6]!==s?(a=c.jsx(r_,{multiColumn:o,children:s}),e[5]=o,e[6]=s,e[7]=a):a=e[7],a},S_=t=>{const e=H.c(52),{mode:n,userConfig:o,appConfig:r,connStatus:s}=t,a=fs(),i=it(),{theme:l}=Xo(),{toggleSidebarPanel:d}=Fa();L3(y_),Ot("global.focusTop",i.focusTopCell),Ot("global.focusBottom",i.focusBottomCell),Ot("global.toggleSidebar",d),Ot("global.foldCode",i.foldAll),Ot("global.unfoldCode",i.unfoldAll),Ot("global.formatAll",C_),Ot("cell.hideCode",Pn.NOOP),Ot("cell.format",Pn.NOOP);const u=mi(),h=i.scrollToTarget;let f,m,x,g,p,b,y,v,w,S,N,j,C,_,A,I;if(e[0]!==a.scrollKey||e[1]!==h?(f=()=>{a.scrollKey!==null&&h()},e[0]=a.scrollKey,e[1]=h,e[2]=f):f=e[2],e[3]!==a.cellIds||e[4]!==a.scrollKey||e[5]!==h?(m=[a.cellIds,a.scrollKey,h],e[3]=a.cellIds,e[4]=a.scrollKey,e[5]=h,e[6]=m):m=e[6],O.useEffect(f,m),e[7]!==i||e[8]!==r||e[9]!==s||e[10]!==n||e[11]!==a||e[12]!==u||e[13]!==l||e[14]!==o){const P=a.cellIds.getColumns();let R;e[26]!==a.cellIds?(R=a.cellIds.hasOnlyOneId(),e[26]=a.cellIds,e[27]=R):R=e[27];const M=R;let L;e[28]!==a.cellIds.inOrderIds?(L=a.cellIds.inOrderIds.includes(Io),e[28]=a.cellIds.inOrderIds,e[29]=L):L=e[29];const F=L;x=SL,w="pb-[40vh]",S=!1,N=r,j="pr-4",e[30]===Symbol.for("react.memo_cache_sentinel")?(C=c.jsx(V5,{}),g=c.jsx(x_,{}),p=c.jsx(i_,{}),e[30]=g,e[31]=p,e[32]=C):(g=e[30],p=e[31],C=e[32]),e[33]!==r.width?(b=c.jsx(m_,{width:r.width}),e[33]=r.width,e[34]=b):b=e[34];const D=r.width==="columns"&&"grid grid-flow-col auto-cols-min gap-6";e[35]!==D?(y=ge(D),e[35]=D,e[36]=y):y=e[36],v=P.map((T,k)=>c.jsx(N_,{column:T,index:k,columnsLength:P.length,appConfig:r,notebook:a,mode:n,userConfig:o,connStatus:s,actions:i,theme:l,hasOnlyOneCell:M,hasSetupCell:F,onDeleteCell:u},T.id)),e[7]=i,e[8]=r,e[9]=s,e[10]=n,e[11]=a,e[12]=u,e[13]=l,e[14]=o,e[15]=x,e[16]=g,e[17]=p,e[18]=b,e[19]=y,e[20]=v,e[21]=w,e[22]=S,e[23]=N,e[24]=j,e[25]=C}else x=e[15],g=e[16],p=e[17],b=e[18],y=e[19],v=e[20],w=e[21],S=e[22],N=e[23],j=e[24],C=e[25];return e[37]!==y||e[38]!==v?(_=c.jsx("div",{className:y,children:v}),e[37]=y,e[38]=v,e[39]=_):_=e[39],e[40]===Symbol.for("react.memo_cache_sentinel")?(A=c.jsx(NL,{}),e[40]=A):A=e[40],e[41]!==x||e[42]!==g||e[43]!==p||e[44]!==b||e[45]!==_||e[46]!==w||e[47]!==S||e[48]!==N||e[49]!==j||e[50]!==C?(I=c.jsxs(x,{className:w,invisible:S,appConfig:N,innerClassName:j,children:[C,g,p,b,_,A]}),e[41]=x,e[42]=g,e[43]=p,e[44]=b,e[45]=_,e[46]=w,e[47]=S,e[48]=N,e[49]=j,e[50]=C,e[51]=I):I=e[51],I},N_=t=>{const e=H.c(40),{column:n,index:o,columnsLength:r,appConfig:s,notebook:a,mode:i,userConfig:l,connStatus:d,actions:u,theme:h,hasOnlyOneCell:f,hasSetupCell:m,onDeleteCell:x}=t,g=d.state,p=n.id,b=o>0,y=o<r-1,v=s.width,w=r>1,S=n.id,N=s.width==="columns"&&"opacity-0 group-hover/column:opacity-100";let j,C;e[0]!==N?(j=ge(N),e[0]=N,e[1]=j):j=e[1],e[2]!==n.id||e[3]!==j?(C=c.jsx(j_,{columnId:S,className:j}),e[2]=n.id,e[3]=j,e[4]=C):C=e[4];const _=`column-${o+1}`,A=n.topLevelIds;let I,P,R,M;return e[5]!==u||e[6]!==g||e[7]!==m||e[8]!==o||e[9]!==i||e[10]!==a||e[11]!==x||e[12]!==h||e[13]!==l?(I=o===0&&m&&c.jsx(sb,{theme:h,showPlaceholder:!1,...a.cellData[Io],...a.cellRuntime[Io],...u,runElapsedTimeMs:a.cellRuntime[Io].runElapsedTimeMs??a.cellData[Io].lastExecutionTime,canDelete:!0,mode:i,connectionState:g,ref:a.cellHandles[Io],userConfig:l,isCollapsed:!1,collapseCount:0,canMoveX:!1,actions:u,deleteCell:x},Io),e[5]=u,e[6]=g,e[7]=m,e[8]=o,e[9]=i,e[10]=a,e[11]=x,e[12]=h,e[13]=l,e[14]=I):I=e[14],e[15]!==u||e[16]!==s.width||e[17]!==n||e[18]!==g||e[19]!==f||e[20]!==i||e[21]!==a||e[22]!==x||e[23]!==h||e[24]!==l?(P=n.topLevelIds.map(L=>{if(L===Io)return null;const F=a.cellData[L],D=a.cellRuntime[L];return c.jsx(sb,{theme:h,showPlaceholder:f,...F,...D,runElapsedTimeMs:D.runElapsedTimeMs??F.lastExecutionTime,canDelete:!f,mode:i,connectionState:g,ref:a.cellHandles[L],userConfig:l,config:F.config,name:F.name,isCollapsed:n.isCollapsed(L),collapseCount:n.getCount(L),canMoveX:s.width==="columns",actions:u,deleteCell:x},F.id.toString())}),e[15]=u,e[16]=s.width,e[17]=n,e[18]=g,e[19]=f,e[20]=i,e[21]=a,e[22]=x,e[23]=h,e[24]=l,e[25]=P):P=e[25],e[26]!==n.topLevelIds||e[27]!==_||e[28]!==I||e[29]!==P?(R=c.jsxs(t1,{id:_,items:A,strategy:W4,children:[I,P]}),e[26]=n.topLevelIds,e[27]=_,e[28]=I,e[29]=P,e[30]=R):R=e[30],e[31]!==s.width||e[32]!==n.id||e[33]!==o||e[34]!==R||e[35]!==b||e[36]!==y||e[37]!==w||e[38]!==C?(M=c.jsx(ub,{columnId:p,index:o,canMoveLeft:b,canMoveRight:y,width:v,canDelete:w,footer:C,children:R}),e[31]=s.width,e[32]=n.id,e[33]=o,e[34]=R,e[35]=b,e[36]=y,e[37]=w,e[38]=C,e[39]=M):M=e[39],M},j_=t=>{const e=H.c(17),{columnId:n,className:o}=t,{createNewCell:r}=it(),[s,a]=gP(!1),i=Ie(Wl),l=Ie(e3);let d;e[0]===Symbol.for("react.memo_cache_sentinel")?(d=ge("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"),e[0]=d):d=e[0];const u=d;let h;e[1]!==i||e[2]!==n||e[3]!==r||e[4]!==s||e[5]!==a.toggle||e[6]!==l?(h=()=>s?c.jsx(xP,{onClose:a.toggle}):c.jsxs(c.Fragment,{children:[c.jsxs(ke,{className:u,variant:"text",size:"sm",disabled:!l,onClick:()=>r({cellId:{type:"__end__",columnId:n},before:!1}),children:[c.jsx(kp,{className:"mr-2 size-4 flex-shrink-0"}),"Python"]}),c.jsxs(ke,{className:u,variant:"text",size:"sm",disabled:!l,onClick:()=>{qn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:new La().defaultCode,hideCode:!0})},children:[c.jsx(jp,{className:"mr-2 size-4 flex-shrink-0"}),"Markdown"]}),c.jsxs(ke,{className:u,variant:"text",size:"sm",disabled:!l,onClick:()=>{qn({autoInstantiate:!0,createNewCell:r}),r({cellId:{type:"__end__",columnId:n},before:!1,code:new wc().defaultCode})},children:[c.jsx(Wo,{className:"mr-2 size-4 flex-shrink-0"}),"SQL"]}),c.jsx(Ne,{content:i?null:c.jsx("span",{children:"Enable via settings under AI Assist"}),delayDuration:100,asChild:!1,children:c.jsxs(ke,{className:u,variant:"text",size:"sm",disabled:!i||!l,onClick:a.toggle,children:[c.jsx(Aa,{className:"mr-2 size-4 flex-shrink-0"}),"Generate with AI"]})})]}),e[1]=i,e[2]=n,e[3]=r,e[4]=s,e[5]=a.toggle,e[6]=l,e[7]=h):h=e[7];const f=h,m=!s&&"w-fit",x=s&&"opacity-100 w-full max-w-4xl shadow-lg shadow-[var(--blue-3)]";let g,p,b;return e[8]!==o||e[9]!==m||e[10]!==x?(g=ge("shadow-sm border border-border rounded transition-all duration-200 overflow-hidden divide-x divide-border flex",m,x,o),e[8]=o,e[9]=m,e[10]=x,e[11]=g):g=e[11],e[12]!==f?(p=f(),e[12]=f,e[13]=p):p=e[13],e[14]!==g||e[15]!==p?(b=c.jsx("div",{className:"flex justify-center mt-4 pt-6 pb-32 group gap-4 w-full print:hidden",children:c.jsx("div",{className:g,children:p})}),e[14]=g,e[15]=p,e[16]=b):b=e[16],b};function C_(){Zk()}const E_=bP(yP,400),__=(t,e)=>{Qe.get(as)||t.isEmpty()||e.isEmpty()||Ba(t.inOrderIds,e.inOrderIds)||E_({cell_ids:t.inOrderIds})},mb=t=>{const e=H.c(66),{userConfig:n,appConfig:o,hideControls:r}=t,s=r!==void 0&&r;vP(jc,__);const{setCells:a,mergeAllColumns:i,collapseAllCells:l,expandAllCells:d}=it(),u=Ie(Ff),h=Ie(wP),f=Ie(kP),m=Zf(),x=kt(dd),g=u.mode==="edit",p=u.mode==="present",b=Ie(SP);let y;e[0]===Symbol.for("react.memo_cache_sentinel")?(y=[],e[0]=y):y=e[0],O.useEffect(A_,y);const v=n.runtime.auto_instantiate;let w,S,N;e[1]!==a||e[2]!==x?(w=(oe,ne)=>{a(oe);const se=oe.map(T_),te=oe.map(M_),pe=oe.map(O_);x({names:se,codes:te,configs:pe,layout:ne})},e[1]=a,e[2]=x,e[3]=w):w=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(S=g3(),e[4]=S):S=e[4],e[5]!==w||e[6]!==n.runtime.auto_instantiate?(N={autoInstantiate:v,setCells:w,sessionId:S},e[5]=w,e[6]=n.runtime.auto_instantiate,e[7]=N):N=e[7];const{connection:j}=jL(N);let C,_;e[8]!==o.app_title||e[9]!==m?(C=()=>{document.title=o.app_title||gn.basename(m??"")||"Untitled Notebook"},_=[o.app_title,m],e[8]=o.app_title,e[9]=m,e[10]=C,e[11]=_):(C=e[10],_=e[11]),O.useEffect(C,_);const A=fc(o.width);let I,P;e[12]!==o.width||e[13]!==i||e[14]!==A?(I=()=>{A==="columns"&&o.width!=="columns"&&i()},e[12]=o.width,e[13]=i,e[14]=A,e[15]=I):I=e[15],e[16]!==o.width||e[17]!==i||e[18]!==h||e[19]!==A?(P=[o.width,A,i,h],e[16]=o.width,e[17]=i,e[18]=h,e[19]=A,e[20]=P):P=e[20],O.useEffect(I,P);const R=function(){const oe=H.c(2),ne=Es();let se;return oe[0]!==ne?(se=()=>ne(d9(mn())),oe[0]=ne,oe[1]=se):se=oe[1],Fe(se)}(),M=Dp(),L=Op();let F,D,T,k,B,E;e[21]!==R?(F=()=>{R()},e[21]=R,e[22]=F):F=e[22],Ot("global.runStale",F),Ot("global.interrupt",D_),e[23]!==L?(D=()=>{L()},e[23]=L,e[24]=D):D=e[24],Ot("global.hideCode",D),e[25]!==M?(T=()=>{M()},e[25]=M,e[26]=T):T=e[26],Ot("global.runAll",T),e[27]!==l?(k=()=>{l()},e[27]=l,e[28]=k):k=e[28],Ot("global.collapseAllSections",k),e[29]!==d?(B=()=>{d()},e[29]=d,e[30]=B):B=e[30],Ot("global.expandAllSections",B),e[31]!==o||e[32]!==j||e[33]!==n||e[34]!==u.mode?(E=c.jsx(k_,{connStatus:j,mode:u.mode,userConfig:n,appConfig:o}),e[31]=o,e[32]=j,e[33]=n,e[34]=u.mode,e[35]=E):E=e[35];const U=E,V=o.width;let $,X,Y,J,Q,q,K,re;return e[36]===Symbol.for("react.memo_cache_sentinel")?($=ge("pt-4 sm:pt-12 pb-2 mb-4 print:hidden z-50","sticky left-0"),e[36]=$):$=e[36],e[37]!==m||e[38]!==g?(X=g&&c.jsx("div",{className:"flex items-center justify-center container",children:c.jsx(Wj,{filename:m})}),e[37]=m,e[38]=g,e[39]=X):X=e[39],e[40]!==j||e[41]!==X?(Y=c.jsx(EL,{connection:j,className:$,children:X}),e[40]=j,e[41]=X,e[42]=Y):Y=e[42],e[43]!==o||e[44]!==U||e[45]!==f||e[46]!==u.mode?(J=f&&c.jsx(CL,{appConfig:o,mode:u.mode,children:U}),e[43]=o,e[44]=U,e[45]=f,e[46]=u.mode,e[47]=J):J=e[47],e[48]!==o.width||e[49]!==j||e[50]!==b||e[51]!==Y||e[52]!==J?(Q=c.jsxs(_L,{connection:j,isRunning:b,width:V,children:[Y,J]}),e[48]=o.width,e[49]=j,e[50]=b,e[51]=Y,e[52]=J,e[53]=Q):Q=e[53],e[54]===Symbol.for("react.memo_cache_sentinel")?(q=c.jsx(r4,{}),e[54]=q):q=e[54],e[55]!==o||e[56]!==j||e[57]!==s||e[58]!==p||e[59]!==b||e[60]!==R||e[61]!==L?(K=!s&&c.jsx(Ic,{children:c.jsx(Bj,{presenting:p,onTogglePresenting:L,onInterrupt:hm,onRun:R,connectionState:j.state,running:b,appConfig:o})}),e[55]=o,e[56]=j,e[57]=s,e[58]=p,e[59]=b,e[60]=R,e[61]=L,e[62]=K):K=e[62],e[63]!==Q||e[64]!==K?(re=c.jsxs(c.Fragment,{children:[Q,q,K]}),e[63]=Q,e[64]=K,e[65]=re):re=e[65],re};function I_(){IS.INSTANCE.stop()}function A_(){return IS.INSTANCE.start(NP),I_}function T_(t){return t.name}function M_(t){return t.code}function O_(t){return t.config}function D_(){hm()}const pb=t=>Ie(jP)[t.capability]?t.children:null,dn=O.forwardRef((t,e)=>{const n=H.c(18);let o,r,s,a,i;n[0]!==t?({children:o,tooltip:i,selected:a,className:r,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s,n[4]=a,n[5]=i):(o=n[1],r=n[2],s=n[3],a=n[4],i=n[5]);const l=!a&&"hover:bg-[var(--sage-3)]",d=a&&"bg-[var(--sage-4)]";let u,h;n[6]!==r||n[7]!==l||n[8]!==d?(u=ge("h-full flex items-center p-2 text-sm shadow-inset font-mono cursor-pointer rounded",l,d,r),n[6]=r,n[7]=l,n[8]=d,n[9]=u):u=n[9],n[10]!==o||n[11]!==e||n[12]!==s||n[13]!==u?(h=c.jsx("div",{ref:e,className:u,...s,children:o}),n[10]=o,n[11]=e,n[12]=s,n[13]=u,n[14]=h):h=n[14];const f=h;if(i){let m;return n[15]!==f||n[16]!==i?(m=c.jsx(Ne,{content:i,side:"top",delayDuration:200,children:f}),n[15]=f,n[16]=i,n[17]=m):m=n[17],m}return f});dn.displayName="FooterItem";const P_=()=>{var u;const t=H.c(14),e=Ie(F3),n=Ie(Wl),o=((u=e==null?void 0:e.open_ai)==null?void 0:u.model)||"gpt-4-turbo",{handleClick:r}=ti();if(!n){let h,f,m;return t[0]!==r?(h=()=>r("ai"),t[0]=r,t[1]=h):h=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(Aa,{className:"h-4 w-4 opacity-60"}),t[2]=f):f=t[2],t[3]!==h?(m=c.jsx(dn,{tooltip:"Assist is disabled",selected:!1,onClick:h,"data-testid":"footer-ai-disabled",children:f}),t[3]=h,t[4]=m):m=t[4],m}let s,a,i,l,d;return t[5]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx("b",{children:"Assist model:"}),t[5]=s):s=t[5],t[6]!==o?(a=c.jsxs(c.Fragment,{children:[s," ",o]}),t[6]=o,t[7]=a):a=t[7],t[8]!==r?(i=()=>r("ai"),t[8]=r,t[9]=i):i=t[9],t[10]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Aa,{className:"h-4 w-4"}),t[10]=l):l=t[10],t[11]!==a||t[12]!==i?(d=c.jsx(dn,{tooltip:a,onClick:i,selected:!1,"data-testid":"footer-ai-enabled",children:l}),t[11]=a,t[12]=i,t[13]=d):d=t[13],d},R_=()=>{const t=H.c(26),e=Ie(Yn).state,n=wm();let o,r;t[0]!==e||t[1]!==n?(o=async()=>{if(e===Ft.OPEN){if(Jt())return{isHealthy:!0,lastChecked:new Date,error:void 0};try{return{isHealthy:await n.isHealthy(),lastChecked:new Date,error:void 0}}catch(w){const S=w;return{isHealthy:!1,lastChecked:new Date,error:S instanceof Error?S.message:"Unknown error"}}}},r=[n,e],t[0]=e,t[1]=n,t[2]=o,t[3]=r):(o=t[2],r=t[3]);const{isFetching:s,error:a,data:i,refetch:l}=Cn(o,r),d=e===Ft.OPEN?3e4:null;let u,h;t[4]!==d?(u={delayMs:d,whenVisible:!0},t[4]=d,t[5]=u):u=t[5],ei(l,u),t[6]!==e||t[7]!==i||t[8]!==a?(h=()=>[Jf(e.toLowerCase()),i!=null&&i.lastChecked?i.isHealthy?"\u2713 Healthy":"\u2717 Unhealthy":"Health: Unknown",a?`Error: ${a}`:""].filter(Boolean).join(`
128
- `),t[6]=e,t[7]=i,t[8]=a,t[9]=h):h=t[9];const f=h;let m;t[10]!==e||t[11]!==(i==null?void 0:i.isHealthy)||t[12]!==(i==null?void 0:i.lastChecked)||t[13]!==s?(m=()=>s||e===Ft.CONNECTING?c.jsx(bn,{size:"small"}):e===Ft.CLOSING?c.jsx(bn,{className:"text-destructive",size:"small"}):e===Ft.OPEN?i!=null&&i.isHealthy?c.jsx(Rc,{className:"w-4 h-4 text-[var(--green-9)]"}):i!=null&&i.lastChecked?c.jsx(R3,{className:"w-4 h-4 text-[var(--yellow-9)]"}):c.jsx(Rc,{className:"w-4 h-4"}):c.jsx(ni,{className:"w-4 h-4 text-red-500"}),t[10]=e,t[11]=i==null?void 0:i.isHealthy,t[12]=i==null?void 0:i.lastChecked,t[13]=s,t[14]=m):m=t[14];const x=m,g=f();let p,b,y,v;return t[15]!==e?(p=e===Ft.OPEN&&c.jsx("div",{className:"mt-2 text-xs text-muted-foreground",children:"Click to refresh health status"}),t[15]=e,t[16]=p):p=t[16],t[17]!==g||t[18]!==p?(b=c.jsxs("div",{className:"text-sm whitespace-pre-line",children:[g,p]}),t[17]=g,t[18]=p,t[19]=b):b=t[19],t[20]!==x?(y=x(),t[20]=x,t[21]=y):y=t[21],t[22]!==l||t[23]!==b||t[24]!==y?(v=c.jsx(dn,{tooltip:b,selected:!1,onClick:l,"data-testid":"footer-backend-status",children:y}),t[22]=l,t[23]=b,t[24]=y,t[25]=v):v=t[25],v},L_=t=>{const e=H.c(3);let n,o;return e[0]===Symbol.for("react.memo_cache_sentinel")?(n=c.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"}),e[0]=n):n=e[0],e[1]!==t?(o=c.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1.24em",height:"1em",viewBox:"0 0 256 208",fill:"currentColor",...t,children:n}),e[1]=t,e[2]=o):o=e[2],o},F_=mt(t=>t(CP).completion.copilot),z_=()=>{const t=H.c(1);if(Ie(F_)==="github"){let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(B_,{}),t[0]=e):e=t[0],e}return null},gb=ht.get("[copilot-status-bar]"),B_=()=>{const t=Ie(bS),e=Ie(cL)!==null,{handleClick:n}=ti(),o=()=>n("ai"),r=t?"Ready":"Not connected",s=kt(bS),a=kt(dL);return L3(()=>{const i=xS();let l=!0;return(async()=>{try{if(await i.initializePromise.catch(u=>{throw gb.error("Failed to initialize",u),i.close(),u}),!l)return;const d=await i.signedIn();if(!l)return;s(d),a(d?"signedIn":"signedOut")}catch(d){if(!l)return;gb.warn("Connection failed",d),s(!1),a("connectionError"),Xe({title:"GitHub Copilot Connection Error",description:"Failed to connect to GitHub Copilot. Check settings and try again.",variant:"danger",action:c.jsx(ke,{variant:"link",onClick:o,children:"Settings"})})}})(),()=>{l=!1}}),c.jsx(dn,{tooltip:c.jsxs(c.Fragment,{children:[c.jsx("b",{children:"GitHub Copilot:"})," ",r]}),selected:!1,onClick:o,"data-testid":"footer-copilot-status",children:c.jsx("span",{children:e?c.jsx(bn,{className:"h-4 w-4"}):c.jsx(L_,{className:ge("h-4 w-4",!t&&"opacity-60")})})})},U_=t=>{const e=H.c(17),[n,o]=O.useState(0),r=Ie(Yn);let s,a,i,l;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=()=>o(W_),a={delayMs:1e4,whenVisible:!0},e[0]=s,e[1]=a):(s=e[0],a=e[1]),ei(s,a),e[2]!==r.state?(i=async()=>Jt()||r.state!==Ft.OPEN?null:EP(),e[2]=r.state,e[3]=i):i=e[3],e[4]!==r.state||e[5]!==n?(l=[n,r.state],e[4]=r.state,e[5]=n,e[6]=l):l=e[6];const{data:d}=Cn(i,l);let u,h,f,m;return e[7]!==d?(u=(d==null?void 0:d.gpu)&&d.gpu.length>0&&c.jsx(H_,{gpus:d.gpu}),e[7]=d,e[8]=u):u=e[8],e[9]!==d?(h=d&&c.jsx($_,{memory:d.memory,kernel:d.kernel,server:d.server}),e[9]=d,e[10]=h):h=e[10],e[11]!==d?(f=d&&c.jsx(V_,{cpu:d.cpu}),e[11]=d,e[12]=f):f=e[12],e[13]!==u||e[14]!==h||e[15]!==f?(m=c.jsxs("div",{className:"flex gap-2 items-center px-1",children:[u,h,f]}),e[13]=u,e[14]=h,e[15]=f,e[16]=m):m=e[16],m},$_=t=>{const e=H.c(25),{memory:n,kernel:o,server:r}=t,{percent:s,total:a,available:i}=n;let l;e[0]!==s?(l=Math.round(s),e[0]=s,e[1]=l):l=e[1];const d=l;let u;e[2]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("b",{children:"computer memory:"}),e[2]=u):u=e[2];const h=a-i;let f,m,x,g,p,b,y,v,w;return e[3]!==h?(f=Eu(h),e[3]=h,e[4]=f):f=e[4],e[5]!==a?(m=Eu(a),e[5]=a,e[6]=m):m=e[6],e[7]!==d||e[8]!==f||e[9]!==m?(x=c.jsxs("span",{children:[u," ",f," / ",m," GB (",d,"%)"]}),e[7]=d,e[8]=f,e[9]=m,e[10]=x):x=e[10],e[11]!==r?(g=(r==null?void 0:r.memory)&&c.jsxs("span",{children:[c.jsx("b",{children:"marimo server:"})," ",dl(r.memory)]}),e[11]=r,e[12]=g):g=e[12],e[13]!==o?(p=(o==null?void 0:o.memory)&&c.jsxs("span",{children:[c.jsx("b",{children:"kernel:"})," ",dl(o.memory)]}),e[13]=o,e[14]=p):p=e[14],e[15]!==x||e[16]!==g||e[17]!==p?(b=c.jsxs("div",{className:"flex flex-col gap-1",children:[x,g,p]}),e[15]=x,e[16]=g,e[17]=p,e[18]=b):b=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(y=c.jsx(dp,{className:"w-4 h-4"}),e[19]=y):y=e[19],e[20]!==d?(v=c.jsxs("div",{className:"flex items-center gap-1","data-testid":"memory-usage-bar",children:[y,c.jsx(Cu,{percent:d,colorClassName:"bg-primary"})]}),e[20]=d,e[21]=v):v=e[21],e[22]!==v||e[23]!==b?(w=c.jsx(Ne,{delayDuration:200,content:b,children:v}),e[22]=v,e[23]=b,e[24]=w):w=e[24],w},V_=t=>{const e=H.c(11),{cpu:n}=t,{percent:o}=n;let r;e[0]!==o?(r=Math.round(o),e[0]=o,e[1]=r):r=e[1];const s=r;let a,i,l,d,u;return e[2]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("b",{children:"CPU:"}),e[2]=a):a=e[2],e[3]!==s?(i=c.jsxs("span",{children:[a," ",s,"%"]}),e[3]=s,e[4]=i):i=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(uL,{className:"w-4 h-4"}),e[5]=l):l=e[5],e[6]!==s?(d=c.jsxs("div",{className:"flex items-center gap-1","data-testid":"cpu-bar",children:[l,c.jsx(Cu,{percent:s,colorClassName:"bg-primary"})]}),e[6]=s,e[7]=d):d=e[7],e[8]!==i||e[9]!==d?(u=c.jsx(Ne,{delayDuration:200,content:i,children:d}),e[8]=i,e[9]=d,e[10]=u):u=e[10],u},H_=t=>{const e=H.c(12),{gpus:n}=t;let o;e[0]!==n?(o=Math.round(n.reduce(q_,0)/n.length),e[0]=n,e[1]=o):o=e[1];const r=o;let s,a,i,l,d;return e[2]!==n?(s=n.map(G_),e[2]=n,e[3]=s):s=e[3],e[4]!==s?(a=c.jsx("div",{className:"flex flex-col gap-1",children:s}),e[4]=s,e[5]=a):a=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(hp,{className:"w-4 h-4"}),e[6]=i):i=e[6],e[7]!==r?(l=c.jsxs("div",{className:"flex items-center gap-1","data-testid":"gpu-bar",children:[i,c.jsx(Cu,{percent:r,colorClassName:"bg-[var(--grass-9)]"})]}),e[7]=r,e[8]=l):l=e[8],e[9]!==a||e[10]!==l?(d=c.jsx(Ne,{delayDuration:200,content:a,children:l}),e[9]=a,e[10]=l,e[11]=d):d=e[11],d},Cu=t=>{const e=H.c(7),{percent:n,colorClassName:o}=t;let r;e[0]!==o?(r=ge("h-full bg-primary",o),e[0]=o,e[1]=r):r=e[1];const s=`${n}%`;let a,i;return e[2]!==s?(a={width:s},e[2]=s,e[3]=a):a=e[3],e[4]!==r||e[5]!==a?(i=c.jsx("div",{className:"h-3 w-20 bg-[var(--slate-4)] rounded-lg overflow-hidden border",children:c.jsx("div",{className:r,style:a})}),e[4]=r,e[5]=a,e[6]=i):i=e[6],i};function dl(t){return t>1073741824?`${Eu(t)} GB`:`${function(e){return new Intl.NumberFormat("en-US",{maximumFractionDigits:0}).format(e/1048576)}(t)} MB`}function Eu(t){return new Intl.NumberFormat("en-US",{maximumFractionDigits:2}).format(t/1073741824)}function W_(t){return t+1}function q_(t,e){return t+e.memory.percent}function G_(t){return c.jsxs("span",{children:[c.jsxs("b",{children:["GPU ",t.index," (",t.name,"):"]})," ",dl(t.memory.used)," / ",dl(t.memory.total)," GB (",Math.round(t.memory.percent),"%)"]},t.index)}const xb=mt(!1);function _u(t,e,n=new Set){if(n.has(t))return new Set;n.add(t);const o=new Set;for(const r of e(t)){o.add(r);for(const s of _u(r,e,n))o.add(s)}return o}const Y_=mt(t=>{const e=t(pn),n=t(dc);return function(o,r){var i,l,d;const s=new Map;for(const u of o)s.set(u,{variables:new Set,parents:new Set,children:new Set});for(const u of Object.values(r))if(u.dataType!=="module")for(const h of u.declaredBy){(i=s.get(h))==null||i.variables.add(u.name);for(const f of u.usedBy)h!==f&&((l=s.get(f))==null||l.parents.add(h),(d=s.get(h))==null||d.children.add(f))}const a={};for(const[u,h]of s.entries())a[u]={parents:h.parents,children:h.children,variables:[...h.variables],ancestors:_u(u,f=>{var m;return((m=s.get(f))==null?void 0:m.parents)??new Set}),descendants:_u(u,f=>{var m;return((m=s.get(f))==null?void 0:m.children)??new Set})};return a}(e.cellIds.inOrderIds,n)});function K_(t,e){return e?t.usedBy.includes(e.id)||t.declaredBy.includes(e.id)?!0:t.declaredBy.some(n=>e.graph.parents.has(n))?t.usedBy.some(n=>e.graph.parents.has(n)):!!t.declaredBy.some(n=>e.graph.children.has(n)):!1}const X_=()=>{const t=H.c(6),[e,n]=St(xb);let o,r,s;return t[0]!==n?(o=()=>n(J_),t[0]=n,t[1]=o):o=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(cp,{className:"h-4 w-4"}),t[2]=r):r=t[2],t[3]!==e||t[4]!==o?(s=c.jsx(dn,{tooltip:"Toggle Minimap",selected:e,onClick:o,"data-testid":"footer-minimap",children:r}),t[3]=e,t[4]=o,t[5]=s):s=t[5],s};function J_(t){return!t}const Z_=()=>{const t=H.c(13),e=Ie(Mr),[n,o]=St(x3),[r,s]=O.useState(!1);if(!kc()||e==="disabled")return null;const a=e?"Real-time collaboration active":"Connecting to real-time collaboration";let i,l,d,u,h,f;return t[0]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(Ap,{className:"w-4 h-4"}),t[0]=i):i=t[0],t[1]!==a?(l=c.jsx(ys,{asChild:!0,children:c.jsx(dn,{tooltip:a,selected:!1,"data-testid":"footer-rtc-status",children:i})}),t[1]=a,t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsxs("div",{className:"space-y-2",children:[c.jsx("h4",{className:"font-medium leading-none",children:"Username"}),c.jsx("p",{className:"text-sm text-muted-foreground",children:"Set your username for real-time collaboration"})]}),t[3]=d):d=t[3],t[4]!==o?(u=m=>o(m.target.value),t[4]=o,t[5]=u):u=t[5],t[6]!==u||t[7]!==n?(h=c.jsx(hs,{className:"w-80",children:c.jsxs("div",{className:"space-y-4",children:[d,c.jsx(Vo,{value:n,autoCapitalize:"off",autoComplete:"off",autoCorrect:"off",onChange:u,placeholder:"Enter your username"})]})}),t[6]=u,t[7]=n,t[8]=h):h=t[8],t[9]!==r||t[10]!==l||t[11]!==h?(f=c.jsxs(gr,{open:r,onOpenChange:s,children:[l,h]}),t[9]=r,t[10]=l,t[11]=h,t[12]=f):f=t[12],f},Q_=t=>{const e=H.c(101),{className:n}=t,[o,r]=_P(),s=mr()[0],[a,i]=O.useState(!1);let l,d,u;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{const Ee=window.matchMedia("(min-width: 768px)"),Le=()=>{Ee.matches&&i(!1)};return Ee.addEventListener("change",Le),()=>Ee.removeEventListener("change",Le)},d=[],e[0]=l,e[1]=d):(l=e[0],d=e[1]),O.useEffect(l,d),e[2]!==s||e[3]!==r?(u=async Ee=>{const Le={...s,runtime:{...s.runtime,auto_instantiate:Ee}};await pr({config:Le}).then(()=>r(Le))},e[2]=s,e[3]=r,e[4]=u):u=e[4];const h=u;let f;e[5]!==r||e[6]!==o?(f=async Ee=>{const Le={...o,runtime:{...o.runtime,on_cell_change:Ee?"autorun":"lazy"}};await pr({config:Le}).then(()=>r(Le))},e[5]=r,e[6]=o,e[7]=f):f=e[7];const m=f;let x;e[8]!==r||e[9]!==o?(x=async Ee=>{const Le={...o,runtime:{...o.runtime,auto_reload:Ee}};await pr({config:Le}).then(()=>r(Le))},e[8]=r,e[9]=o,e[10]=x):x=e[10];const g=x;let p;e[11]!==s.runtime.auto_instantiate||e[12]!==s.runtime.auto_reload||e[13]!==s.runtime.on_cell_change?(p=!s.runtime.auto_instantiate&&s.runtime.on_cell_change==="lazy"&&(Jt()||s.runtime.auto_reload!=="autorun"),e[11]=s.runtime.auto_instantiate,e[12]=s.runtime.auto_reload,e[13]=s.runtime.on_cell_change,e[14]=p):p=e[14];const b=p;let y;e[15]!==n?(y=ge("flex items-center",n),e[15]=n,e[16]=y):y=e[16];const v=s.runtime.auto_instantiate?"Disable autorun on startup":"Enable autorun on startup";let w,S,N;e[17]!==s.runtime.auto_instantiate||e[18]!==h?(w=()=>h(!s.runtime.auto_instantiate),e[17]=s.runtime.auto_instantiate,e[18]=h,e[19]=w):w=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx("span",{children:"on startup: "}),e[20]=S):S=e[20],e[21]!==s.runtime.auto_instantiate?(N=s.runtime.auto_instantiate?c.jsx(ln,{size:14}):c.jsx(an,{size:14}),e[21]=s.runtime.auto_instantiate,e[22]=N):N=e[22];const j=s.runtime.auto_instantiate?"autorun":"lazy";let C,_,A,I;e[23]!==j?(C=c.jsx("span",{children:j}),e[23]=j,e[24]=C):C=e[24],e[25]!==N||e[26]!==C?(_=c.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[S,N,C]}),e[25]=N,e[26]=C,e[27]=_):_=e[27],e[28]!==_||e[29]!==v||e[30]!==w?(A=c.jsx(Ns,{name:"runtime.auto_instantiate",children:c.jsx(dn,{tooltip:v,selected:!1,onClick:w,"data-testid":"footer-autorun-startup",children:_})}),e[28]=_,e[29]=v,e[30]=w,e[31]=A):A=e[31],e[32]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsx("div",{className:"border-r border-border h-6 mx-1"}),e[32]=I):I=e[32];const P=s.runtime.on_cell_change==="autorun"?"Disable autorun":"Enable autorun";let R,M,L,F,D,T,k,B,E,U,V,$,X;e[33]!==s.runtime.on_cell_change||e[34]!==m?(R=()=>m(s.runtime.on_cell_change!=="autorun"),e[33]=s.runtime.on_cell_change,e[34]=m,e[35]=R):R=e[35],e[36]===Symbol.for("react.memo_cache_sentinel")?(M=c.jsx("span",{children:"on cell change: "}),e[36]=M):M=e[36],e[37]!==s.runtime.on_cell_change?(L=c.jsxs("div",{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[M,s.runtime.on_cell_change==="autorun"?c.jsx(ln,{size:14}):c.jsx(an,{size:14}),c.jsx("span",{children:s.runtime.on_cell_change})]}),e[37]=s.runtime.on_cell_change,e[38]=L):L=e[38],e[39]!==P||e[40]!==R||e[41]!==L?(F=c.jsx(Ns,{name:"runtime.on_cell_change",children:c.jsx(dn,{tooltip:P,selected:!1,onClick:R,"data-testid":"footer-autorun-cell-change",children:L})}),e[39]=P,e[40]=R,e[41]=L,e[42]=F):F=e[42],e[43]!==s.runtime.auto_reload||e[44]!==g?(D=!Jt()&&c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"border-r border-border h-6 mx-1"}),c.jsx(Ns,{name:"runtime.auto_reload",children:c.jsx(dn,{tooltip:null,selected:!1,"data-testid":"footer-module-reload",children:c.jsxs(ko,{children:[c.jsxs(So,{className:"font-prose text-sm flex items-center gap-1 whitespace-nowrap",children:[c.jsx("span",{children:"on module change: "}),s.runtime.auto_reload==="off"&&c.jsx(ni,{size:14}),s.runtime.auto_reload==="lazy"&&c.jsx(an,{size:14}),s.runtime.auto_reload==="autorun"&&c.jsx(ln,{size:14}),c.jsx("span",{children:s.runtime.auto_reload}),c.jsx(wo,{size:14})]}),c.jsx(No,{children:["off","lazy","autorun"].map(Ee=>c.jsxs(It,{onClick:()=>g(Ee),children:[Ee==="off"&&c.jsx(ni,{size:14,className:"mr-2 text-muted-foreground"}),Ee==="lazy"&&c.jsx(an,{size:14,className:"mr-2 text-muted-foreground"}),Ee==="autorun"&&c.jsx(ln,{size:14,className:"mr-2 text-muted-foreground"}),Ee]},Ee))})]})})})]}),e[43]=s.runtime.auto_reload,e[44]=g,e[45]=D):D=e[45],e[46]!==A||e[47]!==F||e[48]!==D?(T=c.jsxs("div",{className:"hidden md:flex md:items-center",children:[A,I,F,D]}),e[46]=A,e[47]=F,e[48]=D,e[49]=T):T=e[49],e[50]!==b?(k=b?c.jsx(an,{size:16,className:"text-muted-foreground"}):c.jsx(ln,{size:16,className:"text-amber-500"}),e[50]=b,e[51]=k):k=e[51],e[52]===Symbol.for("react.memo_cache_sentinel")?(B=c.jsx(wo,{size:14}),e[52]=B):B=e[52],e[53]!==k?(E=c.jsx(So,{asChild:!0,children:c.jsx(dn,{tooltip:"Runtime reactivity",selected:!1,"data-testid":"footer-runtime-settings",children:c.jsxs("div",{className:"flex items-center gap-1",children:[k,B]})})}),e[53]=k,e[54]=E):E=e[54],e[55]===Symbol.for("react.memo_cache_sentinel")?(U=c.jsx(Dk,{children:"Runtime reactivity"}),V=c.jsx(on,{}),e[55]=U,e[56]=V):(U=e[55],V=e[56]),e[57]!==s.runtime.auto_instantiate?($=s.runtime.auto_instantiate?c.jsx(ln,{size:14,className:"text-amber-500"}):c.jsx(an,{size:14,className:"text-muted-foreground"}),e[57]=s.runtime.auto_instantiate,e[58]=$):$=e[58],e[59]===Symbol.for("react.memo_cache_sentinel")?(X=c.jsx("div",{className:"text-sm font-medium",children:"On startup"}),e[59]=X):X=e[59];const Y=s.runtime.auto_instantiate?"autorun":"lazy";let J,Q,q,K,re,oe,ne,se,te;e[60]!==Y?(J=c.jsxs("div",{children:[X,c.jsx("div",{className:"text-xs text-muted-foreground",children:Y})]}),e[60]=Y,e[61]=J):J=e[61],e[62]!==$||e[63]!==J?(Q=c.jsxs("div",{className:"flex items-center space-x-2",children:[$,J]}),e[62]=$,e[63]=J,e[64]=Q):Q=e[64],e[65]!==s.runtime.auto_instantiate||e[66]!==h?(q=c.jsx($f,{checked:s.runtime.auto_instantiate,onCheckedChange:h,size:"sm"}),e[65]=s.runtime.auto_instantiate,e[66]=h,e[67]=q):q=e[67],e[68]!==Q||e[69]!==q?(K=c.jsx(Ns,{name:"runtime.auto_instantiate",children:c.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[Q,q]})}),e[68]=Q,e[69]=q,e[70]=K):K=e[70],e[71]===Symbol.for("react.memo_cache_sentinel")?(re=c.jsx(on,{}),e[71]=re):re=e[71],e[72]!==s.runtime.on_cell_change?(oe=s.runtime.on_cell_change==="autorun"?c.jsx(ln,{size:14,className:"text-amber-500"}):c.jsx(an,{size:14,className:"text-muted-foreground"}),e[72]=s.runtime.on_cell_change,e[73]=oe):oe=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(ne=c.jsx("div",{className:"text-sm font-medium",children:"On cell change"}),e[74]=ne):ne=e[74],e[75]!==s.runtime.on_cell_change?(se=c.jsxs("div",{children:[ne,c.jsx("div",{className:"text-xs text-muted-foreground",children:s.runtime.on_cell_change})]}),e[75]=s.runtime.on_cell_change,e[76]=se):se=e[76],e[77]!==oe||e[78]!==se?(te=c.jsxs("div",{className:"flex items-center space-x-2",children:[oe,se]}),e[77]=oe,e[78]=se,e[79]=te):te=e[79];const pe=s.runtime.on_cell_change==="autorun";let he,ae,ye,fe,Se,Me;return e[80]!==m||e[81]!==pe?(he=c.jsx($f,{checked:pe,onCheckedChange:m,size:"sm"}),e[80]=m,e[81]=pe,e[82]=he):he=e[82],e[83]!==te||e[84]!==he?(ae=c.jsx(Ns,{name:"runtime.on_cell_change",children:c.jsxs("div",{className:"flex items-center justify-between px-2 py-2",children:[te,he]})}),e[83]=te,e[84]=he,e[85]=ae):ae=e[85],e[86]!==s.runtime.auto_reload||e[87]!==g?(ye=!Jt()&&c.jsxs(c.Fragment,{children:[c.jsx(on,{}),c.jsx(Ns,{name:"runtime.auto_reload",children:c.jsxs("div",{className:"px-2 py-1",children:[c.jsxs("div",{className:"flex items-center space-x-2 mb-2",children:[s.runtime.auto_reload==="off"&&c.jsx(ni,{size:14,className:"text-muted-foreground"}),s.runtime.auto_reload==="lazy"&&c.jsx(an,{size:14,className:"text-muted-foreground"}),s.runtime.auto_reload==="autorun"&&c.jsx(ln,{size:14,className:"text-amber-500"}),c.jsxs("div",{children:[c.jsx("div",{className:"text-sm font-medium",children:"On module change"}),c.jsx("div",{className:"text-xs text-muted-foreground",children:s.runtime.auto_reload})]})]}),c.jsx("div",{className:"space-y-1",children:["off","lazy","autorun"].map(Ee=>c.jsxs("button",{onClick:()=>g(Ee),className:ge("w-full flex items-center px-2 py-1 text-sm rounded hover:bg-accent",Ee===s.runtime.auto_reload&&"bg-accent"),children:[Ee==="off"&&c.jsx(ni,{size:12,className:"mr-2"}),Ee==="lazy"&&c.jsx(an,{size:12,className:"mr-2"}),Ee==="autorun"&&c.jsx(ln,{size:12,className:"mr-2"}),c.jsx("span",{className:"capitalize",children:Ee}),Ee===s.runtime.auto_reload&&c.jsx("span",{className:"ml-auto",children:"\u2713"})]},Ee))})]})})]}),e[86]=s.runtime.auto_reload,e[87]=g,e[88]=ye):ye=e[88],e[89]!==K||e[90]!==ae||e[91]!==ye?(fe=c.jsxs(No,{align:"start",className:"w-64",children:[U,V,K,re,ae,ye]}),e[89]=K,e[90]=ae,e[91]=ye,e[92]=fe):fe=e[92],e[93]!==a||e[94]!==E||e[95]!==fe?(Se=c.jsx("div",{className:"flex md:hidden",children:c.jsxs(ko,{open:a,onOpenChange:i,children:[E,fe]})}),e[93]=a,e[94]=E,e[95]=fe,e[96]=Se):Se=e[96],e[97]!==T||e[98]!==Se||e[99]!==y?(Me=c.jsxs("div",{className:y,children:[T,Se]}),e[97]=T,e[98]=Se,e[99]=y,e[100]=Me):Me=e[100],Me},e6=()=>{const t=H.c(24),{selectedPanel:e,isTerminalOpen:n}=oc(),{toggleApplication:o,toggleTerminal:r}=Fa(),s=Ie(IP),a=t6,i=ed.find(n6);let l;jo(i,"Error panel not found"),t[0]!==r?(l=()=>{r()},t[0]=r,t[1]=l):l=t[1],Ot("global.toggleTerminal",l);const d=dn,u=i.tooltip,h=e===i.type,f=()=>o(i.type),m=a(i,s>0?"text-destructive":"");let x,g,p,b,y,v,w,S,N,j;return t[2]!==s?(x=c.jsx("span",{className:"ml-1 font-mono mt-[0.125rem]",children:s}),t[2]=s,t[3]=x):x=t[3],t[4]!==d||t[5]!==i||t[6]!==h||t[7]!==f||t[8]!==m||t[9]!==x?(g=c.jsxs(d,{tooltip:u,selected:h,onClick:f,"data-testid":"footer-errors",children:[m,x]}),t[4]=d,t[5]=i,t[6]=h,t[7]=f,t[8]=m,t[9]=x,t[10]=g):g=t[10],t[11]!==r?(p=()=>r(),t[11]=r,t[12]=p):p=t[12],t[13]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(_p,{className:"h-5 w-5"}),t[13]=b):b=t[13],t[14]!==n||t[15]!==p?(y=c.jsx(pb,{capability:"terminal",children:c.jsx(dn,{tooltip:"Open terminal",selected:n,onClick:p,"data-testid":"footer-terminal",children:b})}),t[14]=n,t[15]=p,t[16]=y):y=t[16],t[17]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsx(Q_,{}),w=c.jsx("div",{className:"mx-auto"}),t[17]=v,t[18]=w):(v=t[17],w=t[18]),t[19]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx(Lj,{children:c.jsx(Ne,{content:c.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:c.jsx("span",{className:"text-muted-foreground text-sm mr-4",children:"kiosk mode"})})}),t[19]=S):S=t[19],t[20]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsxs("div",{className:"flex items-center flex-shrink-0 min-w-0",children:[c.jsx(U_,{}),c.jsx(X_,{}),c.jsx(P_,{}),c.jsx(z_,{}),c.jsx(Z_,{}),c.jsx(R_,{})]}),t[20]=N):N=t[20],t[21]!==y||t[22]!==g?(j=c.jsxs("footer",{className:"h-10 py-2 bg-background flex items-center text-muted-foreground text-md px-1 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 overflow-x-auto overflow-y-hidden scrollbar-thin",children:[g,y,v,w,S,N]}),t[21]=y,t[22]=g,t[23]=j):j=t[23],j};function t6(t,e){const{Icon:n}=t;return c.jsx(n,{className:ge("h-5 w-5",e)})}function n6(t){return t.type==="errors"}const o6=t=>{const e=H.c(6),{children:n}=t,{openModal:o,closeModal:r}=jn();let s,a;return e[0]!==r||e[1]!==o?(s=()=>o(c.jsx(r6,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(a=c.jsx(z3,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=a):a=e[5],a},r6=t=>{const e=H.c(9),{onClose:n}=t;let o,r,s,a,i,l,d;return e[0]!==n?(o=async u=>{u.preventDefault();const h=new FormData(u.target),f=h.get("rating"),m=h.get("message");fetch("https://marimo.io/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({rating:f,message:m})}),n(),Xe({title:"Feedback sent!",description:"Thank you for your feedback!"})},e[0]=n,e[1]=o):o=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx($o,{children:"Send Feedback"}),e[2]=r):r=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx("p",{className:"my-2 prose dark:prose-invert",children:"We want to hear from you \u2014 from minor bug reports to wishlist features and everything in between. Here are some ways you can get in touch:"}),e[3]=s):s=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsxs("li",{className:"my-0",children:["Take our"," ",c.jsx("a",{href:On.feedbackForm,target:"_blank",className:"underline",children:"two-minute survey."})]}),e[4]=a):a=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsxs("li",{className:"my-0",children:["File a"," ",c.jsx("a",{href:On.issuesPage,target:"_blank",className:"underline",children:"GitHub issue."})]}),e[5]=i):i=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsxs(rs,{children:[r,c.jsxs(ss,{children:[s,c.jsxs("ul",{className:"list-disc ml-8 my-2 prose dark:prose-invert",children:[a,i,c.jsxs("li",{className:"my-0",children:["Chat with us on"," ",c.jsx("a",{href:On.discordLink,target:"_blank",className:"underline",children:"Discord."})]})]}),c.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!"})]})]}),e[6]=l):l=e[6],e[7]!==o?(d=c.jsx(Ho,{className:"w-fit",children:c.jsx("form",{onSubmit:o,children:l})}),e[7]=o,e[8]=d):d=e[8],d},s6=()=>{const t=H.c(10),{selectedPanel:e}=oc(),{toggleApplication:n}=Fa(),o=i6;let r,s,a,i,l,d;return t[0]!==e||t[1]!==n?(r="h-full pt-4 pb-1 px-1 flex flex-col items-start text-muted-foreground text-md select-none no-print text-sm z-50 dark:bg-background print:hidden hide-on-fullscreen",s=ed.filter(l6).map(u=>c.jsx(bb,{tooltip:u.tooltip,selected:e===u.type,onClick:()=>n(u.type),children:o(u)},u.type)),t[0]=e,t[1]=n,t[2]=r,t[3]=s):(r=t[2],s=t[3]),t[4]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(o6,{children:c.jsx(bb,{tooltip:"Send feedback!",selected:!1,children:c.jsx(up,{className:"h-5 w-5"})})}),i=c.jsx("div",{className:"flex-1"}),l=c.jsx(a6,{}),t[4]=a,t[5]=i,t[6]=l):(a=t[4],i=t[5],l=t[6]),t[7]!==r||t[8]!==s?(d=c.jsxs("div",{className:r,children:[s,a,i,l]}),t[7]=r,t[8]=s,t[9]=d):d=t[9],d},a6=()=>{const t=H.c(7),e=Ie(AP);let n,o,r;return t[0]!==e?(n=e>0?c.jsxs("span",{children:[e," cell",e>1?"s":""," queued or running"]}):"No cells queued or running",t[0]=e,t[1]=n):n=t[1],t[2]!==e?(o=c.jsx("div",{className:"flex flex-col-reverse gap-[1px] overflow-hidden",children:Array.from({length:e}).map(c6)}),t[2]=e,t[3]=o):o=t[3],t[4]!==n||t[5]!==o?(r=c.jsx(Ne,{content:n,side:"right",delayDuration:200,children:o}),t[4]=n,t[5]=o,t[6]=r):r=t[6],r},bb=t=>{const e=H.c(17);let n,o,r,s,a;e[0]!==t?({children:n,tooltip:a,selected:s,className:o,...r}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s,e[5]=a):(n=e[1],o=e[2],r=e[3],s=e[4],a=e[5]);const i=!s&&"hover:bg-[var(--sage-3)]",l=s&&"bg-[var(--sage-4)]";let d,u,h;return e[6]!==o||e[7]!==i||e[8]!==l?(d=ge("flex items-center p-2 text-sm mx-[1px] shadow-inset font-mono cursor-pointer rounded",i,l,o),e[6]=o,e[7]=i,e[8]=l,e[9]=d):d=e[9],e[10]!==n||e[11]!==r||e[12]!==d?(u=c.jsx("button",{className:d,...r,children:n}),e[10]=n,e[11]=r,e[12]=d,e[13]=u):u=e[13],e[14]!==u||e[15]!==a?(h=c.jsx(Ne,{content:a,side:"right",delayDuration:200,children:u}),e[14]=u,e[15]=a,e[16]=h):h=e[16],h};function i6(t,e){const{Icon:n}=t;return c.jsx(n,{className:ge("h-5 w-5",e)})}function l6(t){return!t.hidden&&t.position==="sidebar"}function c6(t,e){return c.jsx("div",{className:"flex-shrink-0 h-1 w-2 bg-[var(--grass-6)] border border-[var(--grass-7)]"},e.toString())}var Iu="ScrollArea",[yb,GL]=d3(Iu),[d6,vn]=yb(Iu),vb=O.forwardRef((t,e)=>{const{__scopeScrollArea:n,type:o="hover",dir:r,scrollHideDelay:s=600,...a}=t,[i,l]=O.useState(null),[d,u]=O.useState(null),[h,f]=O.useState(null),[m,x]=O.useState(null),[g,p]=O.useState(null),[b,y]=O.useState(0),[v,w]=O.useState(0),[S,N]=O.useState(!1),[j,C]=O.useState(!1),_=ws(e,I=>l(I)),A=TP(r);return c.jsx(d6,{scope:n,type:o,dir:A,scrollHideDelay:s,scrollArea:i,viewport:d,onViewportChange:u,content:h,onContentChange:f,scrollbarX:m,onScrollbarXChange:x,scrollbarXEnabled:S,onScrollbarXEnabledChange:N,scrollbarY:g,onScrollbarYChange:p,scrollbarYEnabled:j,onScrollbarYEnabledChange:C,onCornerWidthChange:y,onCornerHeightChange:w,children:c.jsx(bs.div,{dir:A,...a,ref:_,style:{position:"relative","--radix-scroll-area-corner-width":b+"px","--radix-scroll-area-corner-height":v+"px",...t.style}})})});vb.displayName=Iu;var wb="ScrollAreaViewport",kb=O.forwardRef((t,e)=>{const{__scopeScrollArea:n,children:o,nonce:r,...s}=t,a=vn(wb,n),i=O.useRef(null),l=ws(e,i,a.onViewportChange);return c.jsxs(c.Fragment,{children:[c.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:r}),c.jsx(bs.div,{"data-radix-scroll-area-viewport":"",...s,ref:l,style:{overflowX:a.scrollbarXEnabled?"scroll":"hidden",overflowY:a.scrollbarYEnabled?"scroll":"hidden",...t.style},children:c.jsx("div",{ref:a.onContentChange,style:{minWidth:"100%",display:"table"},children:o})})]})});kb.displayName=wb;var Bn="ScrollAreaScrollbar",Au=O.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=vn(Bn,t.__scopeScrollArea),{onScrollbarXEnabledChange:s,onScrollbarYEnabledChange:a}=r,i=t.orientation==="horizontal";return O.useEffect(()=>(i?s(!0):a(!0),()=>{i?s(!1):a(!1)}),[i,s,a]),r.type==="hover"?c.jsx(u6,{...o,ref:e,forceMount:n}):r.type==="scroll"?c.jsx(h6,{...o,ref:e,forceMount:n}):r.type==="auto"?c.jsx(Sb,{...o,ref:e,forceMount:n}):r.type==="always"?c.jsx(Tu,{...o,ref:e}):null});Au.displayName=Bn;var u6=O.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=vn(Bn,t.__scopeScrollArea),[s,a]=O.useState(!1);return O.useEffect(()=>{const i=r.scrollArea;let l=0;if(i){const d=()=>{window.clearTimeout(l),a(!0)},u=()=>{l=window.setTimeout(()=>a(!1),r.scrollHideDelay)};return i.addEventListener("pointerenter",d),i.addEventListener("pointerleave",u),()=>{window.clearTimeout(l),i.removeEventListener("pointerenter",d),i.removeEventListener("pointerleave",u)}}},[r.scrollArea,r.scrollHideDelay]),c.jsx(Ac,{present:n||s,children:c.jsx(Sb,{"data-state":s?"visible":"hidden",...o,ref:e})})}),h6=O.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=vn(Bn,t.__scopeScrollArea),s=t.orientation==="horizontal",a=ml(()=>l("SCROLL_END"),100),[i,l]=function(d,u){return O.useReducer((h,f)=>u[h][f]??h,d)}("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return O.useEffect(()=>{if(i==="idle"){const d=window.setTimeout(()=>l("HIDE"),r.scrollHideDelay);return()=>window.clearTimeout(d)}},[i,r.scrollHideDelay,l]),O.useEffect(()=>{const d=r.viewport,u=s?"scrollLeft":"scrollTop";if(d){let h=d[u];const f=()=>{const m=d[u];h!==m&&(l("SCROLL"),a()),h=m};return d.addEventListener("scroll",f),()=>d.removeEventListener("scroll",f)}},[r.viewport,s,l,a]),c.jsx(Ac,{present:n||i!=="hidden",children:c.jsx(Tu,{"data-state":i==="hidden"?"hidden":"visible",...o,ref:e,onPointerEnter:In(t.onPointerEnter,()=>l("POINTER_ENTER")),onPointerLeave:In(t.onPointerLeave,()=>l("POINTER_LEAVE"))})})}),Sb=O.forwardRef((t,e)=>{const n=vn(Bn,t.__scopeScrollArea),{forceMount:o,...r}=t,[s,a]=O.useState(!1),i=t.orientation==="horizontal",l=ml(()=>{if(n.viewport){const d=n.viewport.offsetWidth<n.viewport.scrollWidth,u=n.viewport.offsetHeight<n.viewport.scrollHeight;a(i?d:u)}},10);return Fr(n.viewport,l),Fr(n.content,l),c.jsx(Ac,{present:o||s,children:c.jsx(Tu,{"data-state":s?"visible":"hidden",...r,ref:e})})}),Tu=O.forwardRef((t,e)=>{const{orientation:n="vertical",...o}=t,r=vn(Bn,t.__scopeScrollArea),s=O.useRef(null),a=O.useRef(0),[i,l]=O.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),d=_b(i.viewport,i.content),u={...o,sizes:i,onSizesChange:l,hasThumb:d>0&&d<1,onThumbChange:f=>s.current=f,onThumbPointerUp:()=>a.current=0,onThumbPointerDown:f=>a.current=f};function h(f,m){return function(x,g,p,b="ltr"){const y=fl(p),v=y/2,w=g||v,S=y-w,N=p.scrollbar.paddingStart+w,j=p.scrollbar.size-p.scrollbar.paddingEnd-S,C=p.content-p.viewport,_=b==="ltr"?[0,C]:[-1*C,0];return Ab([N,j],_)(x)}(f,a.current,i,m)}return n==="horizontal"?c.jsx(f6,{...u,ref:e,onThumbPositionChange:()=>{if(r.viewport&&s.current){const f=Ib(r.viewport.scrollLeft,i,r.dir);s.current.style.transform=`translate3d(${f}px, 0, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollLeft=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollLeft=h(f,r.dir))}}):n==="vertical"?c.jsx(m6,{...u,ref:e,onThumbPositionChange:()=>{if(r.viewport&&s.current){const f=Ib(r.viewport.scrollTop,i);s.current.style.transform=`translate3d(0, ${f}px, 0)`}},onWheelScroll:f=>{r.viewport&&(r.viewport.scrollTop=f)},onDragScroll:f=>{r.viewport&&(r.viewport.scrollTop=h(f))}}):null}),f6=O.forwardRef((t,e)=>{const{sizes:n,onSizesChange:o,...r}=t,s=vn(Bn,t.__scopeScrollArea),[a,i]=O.useState(),l=O.useRef(null),d=ws(e,l,s.onScrollbarXChange);return O.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),c.jsx(jb,{"data-orientation":"horizontal",...r,ref:d,sizes:n,style:{bottom:0,left:s.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:s.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":fl(n)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.x),onDragScroll:u=>t.onDragScroll(u.x),onWheelScroll:(u,h)=>{if(s.viewport){const f=s.viewport.scrollLeft+u.deltaX;t.onWheelScroll(f),Tb(f,h)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&o({content:s.viewport.scrollWidth,viewport:s.viewport.offsetWidth,scrollbar:{size:l.current.clientWidth,paddingStart:hl(a.paddingLeft),paddingEnd:hl(a.paddingRight)}})}})}),m6=O.forwardRef((t,e)=>{const{sizes:n,onSizesChange:o,...r}=t,s=vn(Bn,t.__scopeScrollArea),[a,i]=O.useState(),l=O.useRef(null),d=ws(e,l,s.onScrollbarYChange);return O.useEffect(()=>{l.current&&i(getComputedStyle(l.current))},[l]),c.jsx(jb,{"data-orientation":"vertical",...r,ref:d,sizes:n,style:{top:0,right:s.dir==="ltr"?0:void 0,left:s.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":fl(n)+"px",...t.style},onThumbPointerDown:u=>t.onThumbPointerDown(u.y),onDragScroll:u=>t.onDragScroll(u.y),onWheelScroll:(u,h)=>{if(s.viewport){const f=s.viewport.scrollTop+u.deltaY;t.onWheelScroll(f),Tb(f,h)&&u.preventDefault()}},onResize:()=>{l.current&&s.viewport&&a&&o({content:s.viewport.scrollHeight,viewport:s.viewport.offsetHeight,scrollbar:{size:l.current.clientHeight,paddingStart:hl(a.paddingTop),paddingEnd:hl(a.paddingBottom)}})}})}),[p6,Nb]=yb(Bn),jb=O.forwardRef((t,e)=>{const{__scopeScrollArea:n,sizes:o,hasThumb:r,onThumbChange:s,onThumbPointerUp:a,onThumbPointerDown:i,onThumbPositionChange:l,onDragScroll:d,onWheelScroll:u,onResize:h,...f}=t,m=vn(Bn,n),[x,g]=O.useState(null),p=ws(e,_=>g(_)),b=O.useRef(null),y=O.useRef(""),v=m.viewport,w=o.content-o.viewport,S=Yo(u),N=Yo(l),j=ml(h,10);function C(_){if(b.current){const A=_.clientX-b.current.left,I=_.clientY-b.current.top;d({x:A,y:I})}}return O.useEffect(()=>{const _=A=>{const I=A.target;(x==null?void 0:x.contains(I))&&S(A,w)};return document.addEventListener("wheel",_,{passive:!1}),()=>document.removeEventListener("wheel",_,{passive:!1})},[v,x,w,S]),O.useEffect(N,[o,N]),Fr(x,j),Fr(m.content,j),c.jsx(p6,{scope:n,scrollbar:x,hasThumb:r,onThumbChange:Yo(s),onThumbPointerUp:Yo(a),onThumbPositionChange:N,onThumbPointerDown:Yo(i),children:c.jsx(bs.div,{...f,ref:p,style:{position:"absolute",...f.style},onPointerDown:In(t.onPointerDown,_=>{_.button===0&&(_.target.setPointerCapture(_.pointerId),b.current=x.getBoundingClientRect(),y.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",m.viewport&&(m.viewport.style.scrollBehavior="auto"),C(_))}),onPointerMove:In(t.onPointerMove,C),onPointerUp:In(t.onPointerUp,_=>{const A=_.target;A.hasPointerCapture(_.pointerId)&&A.releasePointerCapture(_.pointerId),document.body.style.webkitUserSelect=y.current,m.viewport&&(m.viewport.style.scrollBehavior=""),b.current=null})})})}),ul="ScrollAreaThumb",Cb=O.forwardRef((t,e)=>{const{forceMount:n,...o}=t,r=Nb(ul,t.__scopeScrollArea);return c.jsx(Ac,{present:n||r.hasThumb,children:c.jsx(g6,{ref:e,...o})})}),g6=O.forwardRef((t,e)=>{const{__scopeScrollArea:n,style:o,...r}=t,s=vn(ul,n),a=Nb(ul,n),{onThumbPositionChange:i}=a,l=ws(e,h=>a.onThumbChange(h)),d=O.useRef(void 0),u=ml(()=>{d.current&&(d.current(),d.current=void 0)},100);return O.useEffect(()=>{const h=s.viewport;if(h){const f=()=>{if(u(),!d.current){const m=b6(h,i);d.current=m,i()}};return i(),h.addEventListener("scroll",f),()=>h.removeEventListener("scroll",f)}},[s.viewport,u,i]),c.jsx(bs.div,{"data-state":a.hasThumb?"visible":"hidden",...r,ref:l,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...o},onPointerDownCapture:In(t.onPointerDownCapture,h=>{const f=h.target.getBoundingClientRect(),m=h.clientX-f.left,x=h.clientY-f.top;a.onThumbPointerDown({x:m,y:x})}),onPointerUp:In(t.onPointerUp,a.onThumbPointerUp)})});Cb.displayName=ul;var Mu="ScrollAreaCorner",Eb=O.forwardRef((t,e)=>{const n=vn(Mu,t.__scopeScrollArea),o=!!(n.scrollbarX&&n.scrollbarY);return n.type!=="scroll"&&o?c.jsx(x6,{...t,ref:e}):null});Eb.displayName=Mu;var x6=O.forwardRef((t,e)=>{const{__scopeScrollArea:n,...o}=t,r=vn(Mu,n),[s,a]=O.useState(0),[i,l]=O.useState(0),d=!!(s&&i);return Fr(r.scrollbarX,()=>{var h;const u=((h=r.scrollbarX)==null?void 0:h.offsetHeight)||0;r.onCornerHeightChange(u),l(u)}),Fr(r.scrollbarY,()=>{var h;const u=((h=r.scrollbarY)==null?void 0:h.offsetWidth)||0;r.onCornerWidthChange(u),a(u)}),d?c.jsx(bs.div,{...o,ref:e,style:{width:s,height:i,position:"absolute",right:r.dir==="ltr"?0:void 0,left:r.dir==="rtl"?0:void 0,bottom:0,...t.style}}):null});function hl(t){return t?parseInt(t,10):0}function _b(t,e){const n=t/e;return isNaN(n)?0:n}function fl(t){const e=_b(t.viewport,t.content),n=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,o=(t.scrollbar.size-n)*e;return Math.max(o,18)}function Ib(t,e,n="ltr"){const o=fl(e),r=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,s=e.scrollbar.size-r,a=e.content-e.viewport,i=s-o,l=OP(t,n==="ltr"?[0,a]:[-1*a,0]);return Ab([0,a],[0,i])(l)}function Ab(t,e){return n=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const o=(e[1]-e[0])/(t[1]-t[0]);return e[0]+o*(n-t[0])}}function Tb(t,e){return t>0&&t<e}var b6=(t,e=()=>{})=>{let n={left:t.scrollLeft,top:t.scrollTop},o=0;return function r(){const s={left:t.scrollLeft,top:t.scrollTop},a=n.left!==s.left,i=n.top!==s.top;(a||i)&&e(),n=s,o=window.requestAnimationFrame(r)}(),()=>window.cancelAnimationFrame(o)};function ml(t,e){const n=Yo(t),o=O.useRef(0);return O.useEffect(()=>()=>window.clearTimeout(o.current),[]),O.useCallback(()=>{window.clearTimeout(o.current),o.current=window.setTimeout(n,e)},[n,e])}function Fr(t,e){const n=Yo(e);MP(()=>{let o=0;if(t){const r=new ResizeObserver(()=>{cancelAnimationFrame(o),o=window.requestAnimationFrame(n)});return r.observe(t),()=>{window.cancelAnimationFrame(o),r.unobserve(t)}}},[t,n])}var Mb=vb,y6=kb,v6=Eb;const Ob=O.forwardRef((t,e)=>{const n=H.c(15);let o,r,s,a,i,l,d,u;return n[0]!==t?({className:r,children:o,...s}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]),n[4]!==r?(a=ge("relative overflow-hidden",r),n[4]=r,n[5]=a):a=n[5],n[6]!==o?(i=c.jsx(y6,{className:"h-full w-full rounded-[inherit]",children:o}),n[6]=o,n[7]=i):i=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(Db,{}),d=c.jsx(v6,{}),n[8]=l,n[9]=d):(l=n[8],d=n[9]),n[10]!==s||n[11]!==e||n[12]!==a||n[13]!==i?(u=c.jsxs(Mb,{ref:e,className:a,...s,children:[i,l,d]}),n[10]=s,n[11]=e,n[12]=a,n[13]=i,n[14]=u):u=n[14],u});Ob.displayName=Mb.displayName;const Db=O.forwardRef((t,e)=>{const n=H.c(14);let o,r,s;n[0]!==t?({className:o,orientation:s,...r}=t,n[0]=t,n[1]=o,n[2]=r,n[3]=s):(o=n[1],r=n[2],s=n[3]);const a=s===void 0?"vertical":s,i=a==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",l=a==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]";let d,u,h;return n[4]!==o||n[5]!==i||n[6]!==l?(d=ge("flex touch-none select-none transition-colors",i,l,o),n[4]=o,n[5]=i,n[6]=l,n[7]=d):d=n[7],n[8]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(Cb,{className:"relative flex-1 rounded-full bg-border"}),n[8]=u):u=n[8],n[9]!==a||n[10]!==r||n[11]!==e||n[12]!==d?(h=c.jsx(Au,{ref:e,orientation:a,className:d,...r,children:u}),n[9]=a,n[10]=r,n[11]=e,n[12]=d,n[13]=h):h=n[13],h});Db.displayName=Au.displayName;let Ou;Ou=(t,e,n,o,r,s)=>{if(!e)return ht.warn("No active chat"),t;const a=t.chats.findIndex(h=>h.id===e);if(a===-1)return ht.warn("No active chat"),t;const i=t.chats[a],l=i.messages.findIndex(h=>h.id===n),d=[...t.chats],u=Date.now();if(l===-1)d[a]={...i,messages:[...i.messages,{id:n,role:o,content:r,timestamp:u,parts:s}],updatedAt:u};else{const h=[...i.messages];h[l]={...h[l],content:r,parts:s},d[a]={...i,messages:h,updatedAt:u}}return{...t,chats:d}},sn=t=>{const e=H.c(15),{title:n,description:o,icon:r,action:s}=t;let a,i,l,d,u,h;return e[0]!==r?(a=r&&G.cloneElement(r,{className:"text-accent-foreground"}),e[0]=r,e[1]=a):a=e[1],e[2]!==n?(i=c.jsx("span",{className:"mt-1 text-accent-foreground",children:n}),e[2]=n,e[3]=i):i=e[3],e[4]!==a||e[5]!==i?(l=c.jsxs("div",{className:"flex flex-row gap-2 items-center",children:[a,i]}),e[4]=a,e[5]=i,e[6]=l):l=e[6],e[7]!==o?(d=c.jsx("span",{className:"text-muted-foreground text-sm",children:o}),e[7]=o,e[8]=d):d=e[8],e[9]!==s?(u=s&&c.jsx("div",{className:"mt-2",children:s}),e[9]=s,e[10]=u):u=e[10],e[11]!==l||e[12]!==d||e[13]!==u?(h=c.jsxs("div",{className:"mx-6 my-6 flex flex-col gap-2",children:[l,d,u]}),e[11]=l,e[12]=d,e[13]=u,e[14]=h):h=e[14],h};function YL(){}function KL(){}const w6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,k6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,S6={};function Pb(t,e){return(S6.jsx?k6:w6).test(t)}const N6=/[ \t\n\f\r]/g;function Rb(t){return t.replace(N6,"")===""}class sa{constructor(e,n,o){this.normal=n,this.property=e,o&&(this.space=o)}}function Lb(t,e){const n={},o={};for(const r of t)Object.assign(n,r.property),Object.assign(o,r.normal);return new sa(n,o,e)}function Du(t){return t.toLowerCase()}sa.prototype.normal={},sa.prototype.property={},sa.prototype.space=void 0;class Qt{constructor(e,n){this.attribute=n,this.property=e}}Qt.prototype.attribute="",Qt.prototype.booleanish=!1,Qt.prototype.boolean=!1,Qt.prototype.commaOrSpaceSeparated=!1,Qt.prototype.commaSeparated=!1,Qt.prototype.defined=!1,Qt.prototype.mustUseProperty=!1,Qt.prototype.number=!1,Qt.prototype.overloadedBoolean=!1,Qt.prototype.property="",Qt.prototype.spaceSeparated=!1,Qt.prototype.space=void 0;let j6=0;const qe=lr(),Et=lr(),Pu=lr(),me=lr(),lt=lr(),zr=lr(),un=lr();function lr(){return 2**++j6}const Ru=Object.freeze(Object.defineProperty({__proto__:null,boolean:qe,booleanish:Et,commaOrSpaceSeparated:un,commaSeparated:zr,number:me,overloadedBoolean:Pu,spaceSeparated:lt},Symbol.toStringTag,{value:"Module"})),Lu=Object.keys(Ru);class Fu extends Qt{constructor(e,n,o,r){let s=-1;if(super(e,n),Fb(this,"space",r),typeof o=="number")for(;++s<Lu.length;){const a=Lu[s];Fb(this,Lu[s],(o&Ru[a])===Ru[a])}}}function Fb(t,e,n){n&&(t[e]=n)}function Br(t){const e={},n={};for(const[o,r]of Object.entries(t.properties)){const s=new Fu(o,t.transform(t.attributes||{},o),r,t.space);t.mustUseProperty&&t.mustUseProperty.includes(o)&&(s.mustUseProperty=!0),e[o]=s,n[Du(o)]=o,n[Du(s.attribute)]=o}return new sa(e,n,t.space)}Fu.prototype.defined=!0;const zb=Br({properties:{ariaActiveDescendant:null,ariaAtomic:Et,ariaAutoComplete:null,ariaBusy:Et,ariaChecked:Et,ariaColCount:me,ariaColIndex:me,ariaColSpan:me,ariaControls:lt,ariaCurrent:null,ariaDescribedBy:lt,ariaDetails:null,ariaDisabled:Et,ariaDropEffect:lt,ariaErrorMessage:null,ariaExpanded:Et,ariaFlowTo:lt,ariaGrabbed:Et,ariaHasPopup:null,ariaHidden:Et,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:lt,ariaLevel:me,ariaLive:null,ariaModal:Et,ariaMultiLine:Et,ariaMultiSelectable:Et,ariaOrientation:null,ariaOwns:lt,ariaPlaceholder:null,ariaPosInSet:me,ariaPressed:Et,ariaReadOnly:Et,ariaRelevant:null,ariaRequired:Et,ariaRoleDescription:lt,ariaRowCount:me,ariaRowIndex:me,ariaRowSpan:me,ariaSelected:Et,ariaSetSize:me,ariaSort:null,ariaValueMax:me,ariaValueMin:me,ariaValueNow:me,ariaValueText:null,role:null},transform:(t,e)=>e==="role"?e:"aria-"+e.slice(4).toLowerCase()});function Bb(t,e){return e in t?t[e]:e}function Ub(t,e){return Bb(t,e.toLowerCase())}const C6=Br({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:zr,acceptCharset:lt,accessKey:lt,action:null,allow:null,allowFullScreen:qe,allowPaymentRequest:qe,allowUserMedia:qe,alt:null,as:null,async:qe,autoCapitalize:null,autoComplete:lt,autoFocus:qe,autoPlay:qe,blocking:lt,capture:null,charSet:null,checked:qe,cite:null,className:lt,cols:me,colSpan:null,content:null,contentEditable:Et,controls:qe,controlsList:lt,coords:me|zr,crossOrigin:null,data:null,dateTime:null,decoding:null,default:qe,defer:qe,dir:null,dirName:null,disabled:qe,download:Pu,draggable:Et,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:qe,formTarget:null,headers:lt,height:me,hidden:Pu,high:me,href:null,hrefLang:null,htmlFor:lt,httpEquiv:lt,id:null,imageSizes:null,imageSrcSet:null,inert:qe,inputMode:null,integrity:null,is:null,isMap:qe,itemId:null,itemProp:lt,itemRef:lt,itemScope:qe,itemType:lt,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:qe,low:me,manifest:null,max:null,maxLength:me,media:null,method:null,min:null,minLength:me,multiple:qe,muted:qe,name:null,nonce:null,noModule:qe,noValidate:qe,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:qe,optimum:me,pattern:null,ping:lt,placeholder:null,playsInline:qe,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:qe,referrerPolicy:null,rel:lt,required:qe,reversed:qe,rows:me,rowSpan:me,sandbox:lt,scope:null,scoped:qe,seamless:qe,selected:qe,shadowRootClonable:qe,shadowRootDelegatesFocus:qe,shadowRootMode:null,shape:null,size:me,sizes:null,slot:null,span:me,spellCheck:Et,src:null,srcDoc:null,srcLang:null,srcSet:null,start:me,step:null,style:null,tabIndex:me,target:null,title:null,translate:null,type:null,typeMustMatch:qe,useMap:null,value:Et,width:me,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:lt,axis:null,background:null,bgColor:null,border:me,borderColor:null,bottomMargin:me,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:qe,declare:qe,event:null,face:null,frame:null,frameBorder:null,hSpace:me,leftMargin:me,link:null,longDesc:null,lowSrc:null,marginHeight:me,marginWidth:me,noResize:qe,noHref:qe,noShade:qe,noWrap:qe,object:null,profile:null,prompt:null,rev:null,rightMargin:me,rules:null,scheme:null,scrolling:Et,standby:null,summary:null,text:null,topMargin:me,valueType:null,version:null,vAlign:null,vLink:null,vSpace:me,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:qe,disableRemotePlayback:qe,prefix:null,property:null,results:me,security:null,unselectable:null},space:"html",transform:Ub}),E6=Br({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"},properties:{about:un,accentHeight:me,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:me,amplitude:me,arabicForm:null,ascent:me,attributeName:null,attributeType:null,azimuth:me,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:me,by:null,calcMode:null,capHeight:me,className:lt,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:me,diffuseConstant:me,direction:null,display:null,dur:null,divisor:me,dominantBaseline:null,download:qe,dx:null,dy:null,edgeMode:null,editable:null,elevation:me,enableBackground:null,end:null,event:null,exponent:me,externalResourcesRequired:null,fill:null,fillOpacity:me,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:zr,g2:zr,glyphName:zr,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:me,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:me,horizOriginX:me,horizOriginY:me,id:null,ideographic:me,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:me,k:me,k1:me,k2:me,k3:me,k4:me,kernelMatrix:un,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:me,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:me,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:me,overlineThickness:me,paintOrder:null,panose1:null,path:null,pathLength:me,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:lt,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:me,pointsAtY:me,pointsAtZ:me,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:un,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:un,rev:un,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:un,requiredFeatures:un,requiredFonts:un,requiredFormats:un,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:me,specularExponent:me,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:me,strikethroughThickness:me,string:null,stroke:null,strokeDashArray:un,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:me,strokeOpacity:me,strokeWidth:null,style:null,surfaceScale:me,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:un,tabIndex:me,tableValues:null,target:null,targetX:me,targetY:me,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:un,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:me,underlineThickness:me,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:me,values:null,vAlphabetic:me,vMathematical:me,vectorEffect:null,vHanging:me,vIdeographic:me,version:null,vertAdvY:me,vertOriginX:me,vertOriginY:me,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:me,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:Bb}),$b=Br({properties:{xLinkActuate:null,xLinkArcRole:null,xLinkHref:null,xLinkRole:null,xLinkShow:null,xLinkTitle:null,xLinkType:null},space:"xlink",transform:(t,e)=>"xlink:"+e.slice(5).toLowerCase()}),Vb=Br({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:Ub}),Hb=Br({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform:(t,e)=>"xml:"+e.slice(3).toLowerCase()}),_6={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"},I6=/[A-Z]/g,Wb=/-[a-z]/g,A6=/^data[-\w.:]+$/i;function T6(t){return"-"+t.toLowerCase()}function M6(t){return t.charAt(1).toUpperCase()}const O6=Lb([zb,C6,$b,Vb,Hb],"html"),zu=Lb([zb,E6,$b,Vb,Hb],"svg");var qb,Ur={},Gb,pl,Yb,aa={};function D6(){if(Gb)return aa;Gb=1,Object.defineProperty(aa,"__esModule",{value:!0}),aa.camelCase=void 0;var t=/^--[a-zA-Z0-9_-]+$/,e=/-([a-z])/g,n=/^[^-]+$/,o=/^-(webkit|moz|ms|o|khtml)-/,r=/^-(ms)-/,s=function(i,l){return l.toUpperCase()},a=function(i,l){return"".concat(l,"-")};return aa.camelCase=function(i,l){return l===void 0&&(l={}),function(d){return!d||n.test(d)||t.test(d)}(i)?i:(i=i.toLowerCase(),(i=l.reactCompat?i.replace(r,a):i.replace(o,a)).replace(e,s))},aa}var P6=function(){if(Yb)return pl;Yb=1;var t=(pl&&pl.__importDefault||function(o){return o&&o.__esModule?o:{default:o}})(function(){if(qb)return Ur;qb=1;var o=Ur&&Ur.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(Ur,"__esModule",{value:!0}),Ur.default=function(s,a){var i=null;if(!s||typeof s!="string")return i;var l=(0,r.default)(s),d=typeof a=="function";return l.forEach(function(u){if(u.type==="declaration"){var h=u.property,f=u.value;d?a(h,f,u):f&&((i=i||{})[h]=f)}}),i};var r=o(DP());return Ur}()),e=D6();function n(o,r){var s={};return o&&typeof o=="string"&&(0,t.default)(o,function(a,i){a&&i&&(s[(0,e.camelCase)(a,r)]=i)}),s}return n.default=n,pl=n}();const R6=B3(P6),Kb=Xb("end"),Bu=Xb("start");function Xb(t){return function(e){const n=e&&e.position&&e.position[t]||{};if(typeof n.line=="number"&&n.line>0&&typeof n.column=="number"&&n.column>0)return{line:n.line,column:n.column,offset:typeof n.offset=="number"&&n.offset>-1?n.offset:void 0}}}function ia(t){return t&&typeof t=="object"?"position"in t||"type"in t?Jb(t.position):"start"in t||"end"in t?Jb(t):"line"in t||"column"in t?Uu(t):"":""}function Uu(t){return Zb(t&&t.line)+":"+Zb(t&&t.column)}function Jb(t){return Uu(t&&t.start)+"-"+Uu(t&&t.end)}function Zb(t){return t&&typeof t=="number"?t:1}class Ut extends Error{constructor(e,n,o){super(),typeof n=="string"&&(o=n,n=void 0);let r="",s={},a=!1;if(n&&(s="line"in n&&"column"in n||"start"in n&&"end"in n?{place:n}:"type"in n?{ancestors:[n],place:n.position}:{...n}),typeof e=="string"?r=e:!s.cause&&e&&(a=!0,r=e.message,s.cause=e),!s.ruleId&&!s.source&&typeof o=="string"){const l=o.indexOf(":");l===-1?s.ruleId=o:(s.source=o.slice(0,l),s.ruleId=o.slice(l+1))}if(!s.place&&s.ancestors&&s.ancestors){const l=s.ancestors[s.ancestors.length-1];l&&(s.place=l.position)}const i=s.place&&"start"in s.place?s.place.start:s.place;this.ancestors=s.ancestors||void 0,this.cause=s.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=ia(s.place)||"1:1",this.place=s.place||void 0,this.reason=this.message,this.ruleId=s.ruleId||void 0,this.source=s.source||void 0,this.stack=a&&s.cause&&typeof s.cause.stack=="string"?s.cause.stack:"",this.actual,this.expected,this.note,this.url}}Ut.prototype.file="",Ut.prototype.name="",Ut.prototype.reason="",Ut.prototype.message="",Ut.prototype.stack="",Ut.prototype.column=void 0,Ut.prototype.line=void 0,Ut.prototype.ancestors=void 0,Ut.prototype.cause=void 0,Ut.prototype.fatal=void 0,Ut.prototype.place=void 0,Ut.prototype.ruleId=void 0,Ut.prototype.source=void 0;const $u={}.hasOwnProperty,L6=new Map,F6=/[A-Z]/g,z6=new Set(["table","tbody","thead","tfoot","tr"]),B6=new Set(["td","th"]),Qb="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function U6(t,e){if(!e||e.Fragment===void 0)throw new TypeError("Expected `Fragment` in options");const n=e.filePath||void 0;let o;if(e.development){if(typeof e.jsxDEV!="function")throw new TypeError("Expected `jsxDEV` in options when `development: true`");o=function(a,i){return l;function l(d,u,h,f){const m=Array.isArray(h.children),x=Bu(d);return i(u,h,f,m,{columnNumber:x?x.column-1:void 0,fileName:a,lineNumber:x?x.line:void 0},void 0)}}(n,e.jsxDEV)}else{if(typeof e.jsx!="function")throw new TypeError("Expected `jsx` in production options");if(typeof e.jsxs!="function")throw new TypeError("Expected `jsxs` in production options");o=function(a,i,l){return d;function d(u,h,f,m){const x=Array.isArray(f.children)?l:i;return m?x(h,f,m):x(h,f)}}(0,e.jsx,e.jsxs)}const r={Fragment:e.Fragment,ancestors:[],components:e.components||{},create:o,elementAttributeNameCase:e.elementAttributeNameCase||"react",evaluater:e.createEvaluater?e.createEvaluater():void 0,filePath:n,ignoreInvalidStyle:e.ignoreInvalidStyle||!1,passKeys:e.passKeys!==!1,passNode:e.passNode||!1,schema:e.space==="svg"?zu:O6,stylePropertyNameCase:e.stylePropertyNameCase||"dom",tableCellAlignToStyle:e.tableCellAlignToStyle!==!1},s=ey(r,t,void 0);return s&&typeof s!="string"?s:r.create(t,r.Fragment,{children:s||void 0},void 0)}function ey(t,e,n){return e.type==="element"?function(o,r,s){const a=o.schema;let i=a;r.tagName.toLowerCase()==="svg"&&a.space==="html"&&(i=zu,o.schema=i),o.ancestors.push(r);const l=ny(o,r.tagName,!1),d=function(h,f){const m={};let x,g;for(g in f.properties)if(g!=="children"&&$u.call(f.properties,g)){const p=$6(h,g,f.properties[g]);if(p){const[b,y]=p;h.tableCellAlignToStyle&&b==="align"&&typeof y=="string"&&B6.has(f.tagName)?x=y:m[b]=y}}return x&&((m.style||(m.style={}))[h.stylePropertyNameCase==="css"?"text-align":"textAlign"]=x),m}(o,r);let u=Hu(o,r);return z6.has(r.tagName)&&(u=u.filter(function(h){return typeof h!="string"||!(typeof(f=h)=="object"?f.type==="text"&&Rb(f.value):Rb(f));var f})),ty(o,d,l,r),Vu(d,u),o.ancestors.pop(),o.schema=a,o.create(r,l,d,s)}(t,e,n):e.type==="mdxFlowExpression"||e.type==="mdxTextExpression"?function(o,r){if(r.data&&r.data.estree&&o.evaluater){const s=r.data.estree.body[0];return s.type,o.evaluater.evaluateExpression(s.expression)}la(o,r.position)}(t,e):e.type==="mdxJsxFlowElement"||e.type==="mdxJsxTextElement"?function(o,r,s){const a=o.schema;let i=a;r.name==="svg"&&a.space==="html"&&(i=zu,o.schema=i),o.ancestors.push(r);const l=r.name===null?o.Fragment:ny(o,r.name,!0),d=function(h,f){const m={};for(const x of f.attributes)if(x.type==="mdxJsxExpressionAttribute")if(x.data&&x.data.estree&&h.evaluater){const g=x.data.estree.body[0];g.type;const p=g.expression;p.type;const b=p.properties[0];b.type,Object.assign(m,h.evaluater.evaluateExpression(b.argument))}else la(h,f.position);else{const g=x.name;let p;if(x.value&&typeof x.value=="object")if(x.value.data&&x.value.data.estree&&h.evaluater){const b=x.value.data.estree.body[0];b.type,p=h.evaluater.evaluateExpression(b.expression)}else la(h,f.position);else p=x.value===null||x.value;m[g]=p}return m}(o,r),u=Hu(o,r);return ty(o,d,l,r),Vu(d,u),o.ancestors.pop(),o.schema=a,o.create(r,l,d,s)}(t,e,n):e.type==="mdxjsEsm"?function(o,r){if(r.data&&r.data.estree&&o.evaluater)return o.evaluater.evaluateProgram(r.data.estree);la(o,r.position)}(t,e):e.type==="root"?function(o,r,s){const a={};return Vu(a,Hu(o,r)),o.create(r,o.Fragment,a,s)}(t,e,n):e.type==="text"?function(o,r){return r.value}(0,e):void 0}function ty(t,e,n,o){typeof n!="string"&&n!==t.Fragment&&t.passNode&&(e.node=o)}function Vu(t,e){if(e.length>0){const n=e.length>1?e:e[0];n&&(t.children=n)}}function Hu(t,e){const n=[];let o=-1;const r=t.passKeys?new Map:L6;for(;++o<e.children.length;){const s=e.children[o];let a;if(t.passKeys){const l=s.type==="element"?s.tagName:s.type==="mdxJsxFlowElement"||s.type==="mdxJsxTextElement"?s.name:void 0;if(l){const d=r.get(l)||0;a=l+"-"+d,r.set(l,d+1)}}const i=ey(t,s,a);i!==void 0&&n.push(i)}return n}function $6(t,e,n){const o=function(r,s){const a=Du(s);let i=s,l=Qt;if(a in r.normal)return r.property[r.normal[a]];if(a.length>4&&a.slice(0,4)==="data"&&A6.test(s)){if(s.charAt(4)==="-"){const d=s.slice(5).replace(Wb,M6);i="data"+d.charAt(0).toUpperCase()+d.slice(1)}else{const d=s.slice(4);if(!Wb.test(d)){let u=d.replace(I6,T6);u.charAt(0)!=="-"&&(u="-"+u),s="data"+u}}l=Fu}return new l(i,s)}(t.schema,e);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=o.commaSeparated?function(r){const s={};return(r[r.length-1]===""?[...r,""]:r).join((s.padRight?" ":"")+","+(s.padLeft===!1?"":" ")).trim()}(n):n.join(" ").trim()),o.property==="style"){let r=typeof n=="object"?n:function(s,a){try{return R6(a,{reactCompat:!0})}catch(i){if(s.ignoreInvalidStyle)return{};const l=i,d=new Ut("Cannot parse `style` attribute",{ancestors:s.ancestors,cause:l,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw d.file=s.filePath||void 0,d.url=Qb+"#cannot-parse-style-attribute",d}}(t,String(n));return t.stylePropertyNameCase==="css"&&(r=function(s){const a={};let i;for(i in s)$u.call(s,i)&&(a[V6(i)]=s[i]);return a}(r)),["style",r]}return[t.elementAttributeNameCase==="react"&&o.space?_6[o.property]||o.property:o.attribute,n]}}function ny(t,e,n){let o;if(n)if(e.includes(".")){const r=e.split(".");let s,a=-1;for(;++a<r.length;){const i=Pb(r[a])?{type:"Identifier",name:r[a]}:{type:"Literal",value:r[a]};s=s?{type:"MemberExpression",object:s,property:i,computed:!!(a&&i.type==="Literal"),optional:!1}:i}o=s}else o=Pb(e)&&!/^[a-z]/.test(e)?{type:"Identifier",name:e}:{type:"Literal",value:e};else o={type:"Literal",value:e};if(o.type==="Literal"){const r=o.value;return $u.call(t.components,r)?t.components[r]:r}if(t.evaluater)return t.evaluater.evaluateExpression(o);la(t)}function la(t,e){const n=new Ut("Cannot handle MDX estrees without `createEvaluater`",{ancestors:t.ancestors,place:e,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=t.filePath||void 0,n.url=Qb+"#cannot-handle-mdx-estrees-without-createevaluater",n}function V6(t){let e=t.replace(F6,H6);return e.slice(0,3)==="ms-"&&(e="-"+e),e}function H6(t){return"-"+t.toLowerCase()}const Wu={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"]},gl={};function oy(t,e,n){if(function(o){return!!(o&&typeof o=="object")}(t)){if("value"in t)return t.type!=="html"||n?t.value:"";if(e&&"alt"in t&&t.alt)return t.alt;if("children"in t)return ry(t.children,e,n)}return Array.isArray(t)?ry(t,e,n):""}function ry(t,e,n){const o=[];let r=-1;for(;++r<t.length;)o[r]=oy(t[r],e,n);return o.join("")}const sy=document.createElement("i");function qu(t){const e="&"+t+";";sy.innerHTML=e;const n=sy.textContent;return(n.charCodeAt(n.length-1)!==59||t==="semi")&&n!==e&&n}function Un(t,e,n,o){const r=t.length;let s,a=0;if(e=e<0?-e>r?0:r+e:e>r?r:e,n=n>0?n:0,o.length<1e4)s=Array.from(o),s.unshift(e,n),t.splice(...s);else for(n&&t.splice(e,n);a<o.length;)s=o.slice(a,a+1e4),s.unshift(e,0),t.splice(...s),a+=1e4,e+=1e4}function wn(t,e){return t.length>0?(Un(t,t.length,0,e),t):e}const ay={}.hasOwnProperty;function W6(t,e){let n;for(n in e){const o=(ay.call(t,n)?t[n]:void 0)||(t[n]={}),r=e[n];let s;if(r)for(s in r){ay.call(o,s)||(o[s]=[]);const a=r[s];q6(o[s],Array.isArray(a)?a:a?[a]:[])}}}function q6(t,e){let n=-1;const o=[];for(;++n<e.length;)(e[n].add==="after"?t:o).push(e[n]);Un(t,0,0,o)}function iy(t,e){const n=Number.parseInt(t,e);return n<9||n===11||n>13&&n<32||n>126&&n<160||n>55295&&n<57344||n>64975&&n<65008||!(65535&~n)||(65535&n)==65534||n>1114111?"\uFFFD":String.fromCodePoint(n)}function $r(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const $n=Do(/[A-Za-z]/),hn=Do(/[\dA-Za-z]/),G6=Do(/[#-'*+\--9=?A-Z^-~]/);function Gu(t){return t!==null&&(t<32||t===127)}const Yu=Do(/\d/),Y6=Do(/[\dA-Fa-f]/),K6=Do(/[!-/:-@[-`{-~]/);function Ue(t){return t!==null&&t<-2}function en(t){return t!==null&&(t<0||t===32)}function ot(t){return t===-2||t===-1||t===32}const X6=Do(new RegExp("\\p{P}|\\p{S}","u")),J6=Do(/\s/);function Do(t){return function(e){return e!==null&&e>-1&&t.test(String.fromCharCode(e))}}function Vr(t){const e=[];let n=-1,o=0,r=0;for(;++n<t.length;){const s=t.charCodeAt(n);let a="";if(s===37&&hn(t.charCodeAt(n+1))&&hn(t.charCodeAt(n+2)))r=2;else if(s<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(s))||(a=String.fromCharCode(s));else if(s>55295&&s<57344){const i=t.charCodeAt(n+1);s<56320&&i>56319&&i<57344?(a=String.fromCharCode(s,i),r=1):a="\uFFFD"}else a=String.fromCharCode(s);a&&(e.push(t.slice(o,n),encodeURIComponent(a)),o=n+r+1,a=""),r&&(n+=r,r=0)}return e.join("")+t.slice(o)}function ct(t,e,n,o){const r=o?o-1:Number.POSITIVE_INFINITY;let s=0;return function(i){return ot(i)?(t.enter(n),a(i)):e(i)};function a(i){return ot(i)&&s++<r?(t.consume(i),a):(t.exit(n),e(i))}}const Z6={tokenize:function(t){const e=t.attempt(this.parser.constructs.contentInitial,function(s){return s===null?void t.consume(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),ct(t,e,"linePrefix"))},function(s){return t.enter("paragraph"),o(s)});let n;return e;function o(s){const a=t.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=a),n=a,r(s)}function r(s){return s===null?(t.exit("chunkText"),t.exit("paragraph"),void t.consume(s)):Ue(s)?(t.consume(s),t.exit("chunkText"),o):(t.consume(s),r)}}},Q6={tokenize:function(t){const e=this,n=[];let o,r,s,a=0;return i;function i(v){if(a<n.length){const w=n[a];return e.containerState=w[1],t.attempt(w[0].continuation,l,d)(v)}return d(v)}function l(v){if(a++,e.containerState._closeFlow){e.containerState._closeFlow=void 0,o&&y();const w=e.events.length;let S,N=w;for(;N--;)if(e.events[N][0]==="exit"&&e.events[N][1].type==="chunkFlow"){S=e.events[N][1].end;break}b(a);let j=w;for(;j<e.events.length;)e.events[j][1].end={...S},j++;return Un(e.events,N+1,0,e.events.slice(w)),e.events.length=j,d(v)}return i(v)}function d(v){if(a===n.length){if(!o)return f(v);if(o.currentConstruct&&o.currentConstruct.concrete)return x(v);e.interrupt=!!(o.currentConstruct&&!o._gfmTableDynamicInterruptHack)}return e.containerState={},t.check(ly,u,h)(v)}function u(v){return o&&y(),b(a),f(v)}function h(v){return e.parser.lazy[e.now().line]=a!==n.length,s=e.now().offset,x(v)}function f(v){return e.containerState={},t.attempt(ly,m,x)(v)}function m(v){return a++,n.push([e.currentConstruct,e.containerState]),f(v)}function x(v){return v===null?(o&&y(),b(0),void t.consume(v)):(o=o||e.parser.flow(e.now()),t.enter("chunkFlow",{_tokenizer:o,contentType:"flow",previous:r}),g(v))}function g(v){return v===null?(p(t.exit("chunkFlow"),!0),b(0),void t.consume(v)):Ue(v)?(t.consume(v),p(t.exit("chunkFlow")),a=0,e.interrupt=void 0,i):(t.consume(v),g)}function p(v,w){const S=e.sliceStream(v);if(w&&S.push(null),v.previous=r,r&&(r.next=v),r=v,o.defineSkip(v.start),o.write(S),e.parser.lazy[v.start.line]){let N=o.events.length;for(;N--;)if(o.events[N][1].start.offset<s&&(!o.events[N][1].end||o.events[N][1].end.offset>s))return;const j=e.events.length;let C,_,A=j;for(;A--;)if(e.events[A][0]==="exit"&&e.events[A][1].type==="chunkFlow"){if(C){_=e.events[A][1].end;break}C=!0}for(b(a),N=j;N<e.events.length;)e.events[N][1].end={..._},N++;Un(e.events,A+1,0,e.events.slice(j)),e.events.length=N}}function b(v){let w=n.length;for(;w-- >v;){const S=n[w];e.containerState=S[1],S[0].exit.call(e,t)}n.length=v}function y(){o.write([null]),r=void 0,o=void 0,e.containerState._closeFlow=void 0}}},ly={tokenize:function(t,e,n){return ct(t,t.attempt(this.parser.constructs.document,e,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}};function cy(t){return t===null||en(t)||J6(t)?1:X6(t)?2:void 0}function Ku(t,e,n){const o=[];let r=-1;for(;++r<t.length;){const s=t[r].resolveAll;s&&!o.includes(s)&&(e=s(e,n),o.push(s))}return e}const Xu={name:"attention",resolveAll:function(t,e){let n,o,r,s,a,i,l,d,u=-1;for(;++u<t.length;)if(t[u][0]==="enter"&&t[u][1].type==="attentionSequence"&&t[u][1]._close){for(n=u;n--;)if(t[n][0]==="exit"&&t[n][1].type==="attentionSequence"&&t[n][1]._open&&e.sliceSerialize(t[n][1]).charCodeAt(0)===e.sliceSerialize(t[u][1]).charCodeAt(0)){if((t[n][1]._close||t[u][1]._open)&&(t[u][1].end.offset-t[u][1].start.offset)%3&&!((t[n][1].end.offset-t[n][1].start.offset+t[u][1].end.offset-t[u][1].start.offset)%3))continue;i=t[n][1].end.offset-t[n][1].start.offset>1&&t[u][1].end.offset-t[u][1].start.offset>1?2:1;const h={...t[n][1].end},f={...t[u][1].start};dy(h,-i),dy(f,i),s={type:i>1?"strongSequence":"emphasisSequence",start:h,end:{...t[n][1].end}},a={type:i>1?"strongSequence":"emphasisSequence",start:{...t[u][1].start},end:f},r={type:i>1?"strongText":"emphasisText",start:{...t[n][1].end},end:{...t[u][1].start}},o={type:i>1?"strong":"emphasis",start:{...s.start},end:{...a.end}},t[n][1].end={...s.start},t[u][1].start={...a.end},l=[],t[n][1].end.offset-t[n][1].start.offset&&(l=wn(l,[["enter",t[n][1],e],["exit",t[n][1],e]])),l=wn(l,[["enter",o,e],["enter",s,e],["exit",s,e],["enter",r,e]]),l=wn(l,Ku(e.parser.constructs.insideSpan.null,t.slice(n+1,u),e)),l=wn(l,[["exit",r,e],["enter",a,e],["exit",a,e],["exit",o,e]]),t[u][1].end.offset-t[u][1].start.offset?(d=2,l=wn(l,[["enter",t[u][1],e],["exit",t[u][1],e]])):d=0,Un(t,n-1,u-n+3,l),u=n+l.length-d-2;break}}for(u=-1;++u<t.length;)t[u][1].type==="attentionSequence"&&(t[u][1].type="data");return t},tokenize:function(t,e){const n=this.parser.constructs.attentionMarkers.null,o=this.previous,r=cy(o);let s;return function(i){return s=i,t.enter("attentionSequence"),a(i)};function a(i){if(i===s)return t.consume(i),a;const l=t.exit("attentionSequence"),d=cy(i),u=!d||d===2&&r||n.includes(i),h=!r||r===2&&d||n.includes(o);return l._open=!!(s===42?u:u&&(r||!h)),l._close=!!(s===42?h:h&&(d||!u)),e(i)}}};function dy(t,e){t.column+=e,t.offset+=e,t._bufferIndex+=e}const eI={name:"autolink",tokenize:function(t,e,n){let o=0;return function(f){return t.enter("autolink"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.enter("autolinkProtocol"),r};function r(f){return $n(f)?(t.consume(f),s):f===64?n(f):l(f)}function s(f){return f===43||f===45||f===46||hn(f)?(o=1,a(f)):l(f)}function a(f){return f===58?(t.consume(f),o=0,i):(f===43||f===45||f===46||hn(f))&&o++<32?(t.consume(f),a):(o=0,l(f))}function i(f){return f===62?(t.exit("autolinkProtocol"),t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):f===null||f===32||f===60||Gu(f)?n(f):(t.consume(f),i)}function l(f){return f===64?(t.consume(f),d):G6(f)?(t.consume(f),l):n(f)}function d(f){return hn(f)?u(f):n(f)}function u(f){return f===46?(t.consume(f),o=0,d):f===62?(t.exit("autolinkProtocol").type="autolinkEmail",t.enter("autolinkMarker"),t.consume(f),t.exit("autolinkMarker"),t.exit("autolink"),e):h(f)}function h(f){if((f===45||hn(f))&&o++<63){const m=f===45?h:u;return t.consume(f),m}return n(f)}}},xl={partial:!0,tokenize:function(t,e,n){return function(r){return ot(r)?ct(t,o,"linePrefix")(r):o(r)};function o(r){return r===null||Ue(r)?e(r):n(r)}}},uy={continuation:{tokenize:function(t,e,n){const o=this;return function(s){return ot(s)?ct(t,r,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(s):r(s)};function r(s){return t.attempt(uy,e,n)(s)}}},exit:function(t){t.exit("blockQuote")},name:"blockQuote",tokenize:function(t,e,n){const o=this;return function(s){if(s===62){const a=o.containerState;return a.open||(t.enter("blockQuote",{_container:!0}),a.open=!0),t.enter("blockQuotePrefix"),t.enter("blockQuoteMarker"),t.consume(s),t.exit("blockQuoteMarker"),r}return n(s)};function r(s){return ot(s)?(t.enter("blockQuotePrefixWhitespace"),t.consume(s),t.exit("blockQuotePrefixWhitespace"),t.exit("blockQuotePrefix"),e):(t.exit("blockQuotePrefix"),e(s))}}},hy={name:"characterEscape",tokenize:function(t,e,n){return function(r){return t.enter("characterEscape"),t.enter("escapeMarker"),t.consume(r),t.exit("escapeMarker"),o};function o(r){return K6(r)?(t.enter("characterEscapeValue"),t.consume(r),t.exit("characterEscapeValue"),t.exit("characterEscape"),e):n(r)}}},fy={name:"characterReference",tokenize:function(t,e,n){const o=this;let r,s,a=0;return function(u){return t.enter("characterReference"),t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),i};function i(u){return u===35?(t.enter("characterReferenceMarkerNumeric"),t.consume(u),t.exit("characterReferenceMarkerNumeric"),l):(t.enter("characterReferenceValue"),r=31,s=hn,d(u))}function l(u){return u===88||u===120?(t.enter("characterReferenceMarkerHexadecimal"),t.consume(u),t.exit("characterReferenceMarkerHexadecimal"),t.enter("characterReferenceValue"),r=6,s=Y6,d):(t.enter("characterReferenceValue"),r=7,s=Yu,d(u))}function d(u){if(u===59&&a){const h=t.exit("characterReferenceValue");return s!==hn||qu(o.sliceSerialize(h))?(t.enter("characterReferenceMarker"),t.consume(u),t.exit("characterReferenceMarker"),t.exit("characterReference"),e):n(u)}return s(u)&&a++<r?(t.consume(u),d):n(u)}}},my={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return s===null?n(s):(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r)};function r(s){return o.parser.lazy[o.now().line]?n(s):e(s)}}},py={concrete:!0,name:"codeFenced",tokenize:function(t,e,n){const o=this,r={partial:!0,tokenize:function(v,w,S){let N=0;return j;function j(P){return v.enter("lineEnding"),v.consume(P),v.exit("lineEnding"),C}function C(P){return v.enter("codeFencedFence"),ot(P)?ct(v,_,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(P):_(P)}function _(P){return P===s?(v.enter("codeFencedFenceSequence"),A(P)):S(P)}function A(P){return P===s?(N++,v.consume(P),A):N>=i?(v.exit("codeFencedFenceSequence"),ot(P)?ct(v,I,"whitespace")(P):I(P)):S(P)}function I(P){return P===null||Ue(P)?(v.exit("codeFencedFence"),w(P)):S(P)}}};let s,a=0,i=0;return function(v){return function(w){const S=o.events[o.events.length-1];return a=S&&S[1].type==="linePrefix"?S[2].sliceSerialize(S[1],!0).length:0,s=w,t.enter("codeFenced"),t.enter("codeFencedFence"),t.enter("codeFencedFenceSequence"),l(w)}(v)};function l(v){return v===s?(i++,t.consume(v),l):i<3?n(v):(t.exit("codeFencedFenceSequence"),ot(v)?ct(t,d,"whitespace")(v):d(v))}function d(v){return v===null||Ue(v)?(t.exit("codeFencedFence"),o.interrupt?e(v):t.check(my,m,y)(v)):(t.enter("codeFencedFenceInfo"),t.enter("chunkString",{contentType:"string"}),u(v))}function u(v){return v===null||Ue(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),d(v)):ot(v)?(t.exit("chunkString"),t.exit("codeFencedFenceInfo"),ct(t,h,"whitespace")(v)):v===96&&v===s?n(v):(t.consume(v),u)}function h(v){return v===null||Ue(v)?d(v):(t.enter("codeFencedFenceMeta"),t.enter("chunkString",{contentType:"string"}),f(v))}function f(v){return v===null||Ue(v)?(t.exit("chunkString"),t.exit("codeFencedFenceMeta"),d(v)):v===96&&v===s?n(v):(t.consume(v),f)}function m(v){return t.attempt(r,y,x)(v)}function x(v){return t.enter("lineEnding"),t.consume(v),t.exit("lineEnding"),g}function g(v){return a>0&&ot(v)?ct(t,p,"linePrefix",a+1)(v):p(v)}function p(v){return v===null||Ue(v)?t.check(my,m,y)(v):(t.enter("codeFlowValue"),b(v))}function b(v){return v===null||Ue(v)?(t.exit("codeFlowValue"),p(v)):(t.consume(v),b)}function y(v){return t.exit("codeFenced"),e(v)}}},Ju={name:"codeIndented",tokenize:function(t,e,n){const o=this;return function(l){return t.enter("codeIndented"),ct(t,r,"linePrefix",5)(l)};function r(l){const d=o.events[o.events.length-1];return d&&d[1].type==="linePrefix"&&d[2].sliceSerialize(d[1],!0).length>=4?s(l):n(l)}function s(l){return l===null?i(l):Ue(l)?t.attempt(tI,s,i)(l):(t.enter("codeFlowValue"),a(l))}function a(l){return l===null||Ue(l)?(t.exit("codeFlowValue"),s(l)):(t.consume(l),a)}function i(l){return t.exit("codeIndented"),e(l)}}},tI={partial:!0,tokenize:function(t,e,n){const o=this;return r;function r(a){return o.parser.lazy[o.now().line]?n(a):Ue(a)?(t.enter("lineEnding"),t.consume(a),t.exit("lineEnding"),r):ct(t,s,"linePrefix",5)(a)}function s(a){const i=o.events[o.events.length-1];return i&&i[1].type==="linePrefix"&&i[2].sliceSerialize(i[1],!0).length>=4?e(a):Ue(a)?r(a):n(a)}}},nI={name:"codeText",previous:function(t){return t!==96||this.events[this.events.length-1][1].type==="characterEscape"},resolve:function(t){let e,n,o=t.length-4,r=3;if(!(t[r][1].type!=="lineEnding"&&t[r][1].type!=="space"||t[o][1].type!=="lineEnding"&&t[o][1].type!=="space")){for(e=r;++e<o;)if(t[e][1].type==="codeTextData"){t[r][1].type="codeTextPadding",t[o][1].type="codeTextPadding",r+=2,o-=2;break}}for(e=r-1,o++;++e<=o;)n===void 0?e!==o&&t[e][1].type!=="lineEnding"&&(n=e):e!==o&&t[e][1].type!=="lineEnding"||(t[n][1].type="codeTextData",e!==n+2&&(t[n][1].end=t[e-1][1].end,t.splice(n+2,e-n-2),o-=e-n-2,e=n+2),n=void 0);return t},tokenize:function(t,e,n){let o,r,s=0;return function(u){return t.enter("codeText"),t.enter("codeTextSequence"),a(u)};function a(u){return u===96?(t.consume(u),s++,a):(t.exit("codeTextSequence"),i(u))}function i(u){return u===null?n(u):u===32?(t.enter("space"),t.consume(u),t.exit("space"),i):u===96?(r=t.enter("codeTextSequence"),o=0,d(u)):Ue(u)?(t.enter("lineEnding"),t.consume(u),t.exit("lineEnding"),i):(t.enter("codeTextData"),l(u))}function l(u){return u===null||u===32||u===96||Ue(u)?(t.exit("codeTextData"),i(u)):(t.consume(u),l)}function d(u){return u===96?(t.consume(u),o++,d):o===s?(t.exit("codeTextSequence"),t.exit("codeText"),e(u)):(r.type="codeTextData",l(u))}}};class oI{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,n){const o=n??Number.POSITIVE_INFINITY;return o<this.left.length?this.left.slice(e,o):e>this.left.length?this.right.slice(this.right.length-o+this.left.length,this.right.length-e+this.left.length).reverse():this.left.slice(e).concat(this.right.slice(this.right.length-o+this.left.length).reverse())}splice(e,n,o){const r=n||0;this.setCursor(Math.trunc(e));const s=this.right.splice(this.right.length-r,Number.POSITIVE_INFINITY);return o&&ca(this.left,o),s.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),ca(this.left,e)}unshift(e){this.setCursor(0),this.right.push(e)}unshiftMany(e){this.setCursor(0),ca(this.right,e.reverse())}setCursor(e){if(!(e===this.left.length||e>this.left.length&&this.right.length===0||e<0&&this.left.length===0))if(e<this.left.length){const n=this.left.splice(e,Number.POSITIVE_INFINITY);ca(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-e,Number.POSITIVE_INFINITY);ca(this.left,n.reverse())}}}function ca(t,e){let n=0;if(e.length<1e4)t.push(...e);else for(;n<e.length;)t.push(...e.slice(n,n+1e4)),n+=1e4}function gy(t){const e={};let n,o,r,s,a,i,l,d=-1;const u=new oI(t);for(;++d<u.length;){for(;d in e;)d=e[d];if(n=u.get(d),d&&n[1].type==="chunkFlow"&&u.get(d-1)[1].type==="listItemPrefix"&&(i=n[1]._tokenizer.events,r=0,r<i.length&&i[r][1].type==="lineEndingBlank"&&(r+=2),r<i.length&&i[r][1].type==="content"))for(;++r<i.length&&i[r][1].type!=="content";)i[r][1].type==="chunkText"&&(i[r][1]._isInFirstContentOfListItem=!0,r++);if(n[0]==="enter")n[1].contentType&&(Object.assign(e,rI(u,d)),d=e[d],l=!0);else if(n[1]._container){for(r=d,o=void 0;r--;)if(s=u.get(r),s[1].type==="lineEnding"||s[1].type==="lineEndingBlank")s[0]==="enter"&&(o&&(u.get(o)[1].type="lineEndingBlank"),s[1].type="lineEnding",o=r);else if(s[1].type!=="linePrefix"&&s[1].type!=="listItemIndent")break;o&&(n[1].end={...u.get(o)[1].start},a=u.slice(o,d),a.unshift(n),u.splice(o,d-o+1,a))}}return Un(t,0,Number.POSITIVE_INFINITY,u.slice(0)),!l}function rI(t,e){const n=t.get(e)[1],o=t.get(e)[2];let r=e-1;const s=[];let a=n._tokenizer;a||(a=o.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const i=a.events,l=[],d={};let u,h,f=-1,m=n,x=0,g=0;const p=[g];for(;m;){for(;t.get(++r)[1]!==m;);s.push(r),m._tokenizer||(u=o.sliceStream(m),m.next||u.push(null),h&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(u),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),h=m,m=m.next}for(m=n;++f<i.length;)i[f][0]==="exit"&&i[f-1][0]==="enter"&&i[f][1].type===i[f-1][1].type&&i[f][1].start.line!==i[f][1].end.line&&(g=f+1,p.push(g),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):p.pop(),f=p.length;f--;){const b=i.slice(p[f],p[f+1]),y=s.pop();l.push([y,y+b.length-1]),t.splice(y,2,b)}for(l.reverse(),f=-1;++f<l.length;)d[x+l[f][0]]=x+l[f][1],x+=l[f][1]-l[f][0]-1;return d}const sI={resolve:function(t){return gy(t),t},tokenize:function(t,e){let n;return function(a){return t.enter("content"),n=t.enter("chunkContent",{contentType:"content"}),o(a)};function o(a){return a===null?r(a):Ue(a)?t.check(aI,s,r)(a):(t.consume(a),o)}function r(a){return t.exit("chunkContent"),t.exit("content"),e(a)}function s(a){return t.consume(a),t.exit("chunkContent"),n.next=t.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,o}}},aI={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return t.exit("chunkContent"),t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),ct(t,r,"linePrefix")};function r(s){if(s===null||Ue(s))return n(s);const a=o.events[o.events.length-1];return!o.parser.constructs.disable.null.includes("codeIndented")&&a&&a[1].type==="linePrefix"&&a[2].sliceSerialize(a[1],!0).length>=4?e(s):t.interrupt(o.parser.constructs.flow,n,e)(s)}}};function xy(t,e,n,o,r,s,a,i,l){const d=l||Number.POSITIVE_INFINITY;let u=0;return function(p){return p===60?(t.enter(o),t.enter(r),t.enter(s),t.consume(p),t.exit(s),h):p===null||p===32||p===41||Gu(p)?n(p):(t.enter(o),t.enter(a),t.enter(i),t.enter("chunkString",{contentType:"string"}),x(p))};function h(p){return p===62?(t.enter(s),t.consume(p),t.exit(s),t.exit(r),t.exit(o),e):(t.enter(i),t.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===62?(t.exit("chunkString"),t.exit(i),h(p)):p===null||p===60||Ue(p)?n(p):(t.consume(p),p===92?m:f)}function m(p){return p===60||p===62||p===92?(t.consume(p),f):f(p)}function x(p){return u||p!==null&&p!==41&&!en(p)?u<d&&p===40?(t.consume(p),u++,x):p===41?(t.consume(p),u--,x):p===null||p===32||p===40||Gu(p)?n(p):(t.consume(p),p===92?g:x):(t.exit("chunkString"),t.exit(i),t.exit(a),t.exit(o),e(p))}function g(p){return p===40||p===41||p===92?(t.consume(p),x):x(p)}}function by(t,e,n,o,r,s){const a=this;let i,l=0;return function(f){return t.enter(o),t.enter(r),t.consume(f),t.exit(r),t.enter(s),d};function d(f){return l>999||f===null||f===91||f===93&&!i||f===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(f):f===93?(t.exit(s),t.enter(r),t.consume(f),t.exit(r),t.exit(o),e):Ue(f)?(t.enter("lineEnding"),t.consume(f),t.exit("lineEnding"),d):(t.enter("chunkString",{contentType:"string"}),u(f))}function u(f){return f===null||f===91||f===93||Ue(f)||l++>999?(t.exit("chunkString"),d(f)):(t.consume(f),i||(i=!ot(f)),f===92?h:u)}function h(f){return f===91||f===92||f===93?(t.consume(f),l++,u):u(f)}}function yy(t,e,n,o,r,s){let a;return function(h){return h===34||h===39||h===40?(t.enter(o),t.enter(r),t.consume(h),t.exit(r),a=h===40?41:h,i):n(h)};function i(h){return h===a?(t.enter(r),t.consume(h),t.exit(r),t.exit(o),e):(t.enter(s),l(h))}function l(h){return h===a?(t.exit(s),i(a)):h===null?n(h):Ue(h)?(t.enter("lineEnding"),t.consume(h),t.exit("lineEnding"),ct(t,l,"linePrefix")):(t.enter("chunkString",{contentType:"string"}),d(h))}function d(h){return h===a||h===null||Ue(h)?(t.exit("chunkString"),l(h)):(t.consume(h),h===92?u:d)}function u(h){return h===a||h===92?(t.consume(h),d):d(h)}}function da(t,e){let n;return function o(r){return Ue(r)?(t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),n=!0,o):ot(r)?ct(t,o,n?"linePrefix":"lineSuffix")(r):e(r)}}const iI={name:"definition",tokenize:function(t,e,n){const o=this;let r;return function(h){return t.enter("definition"),function(f){return by.call(o,t,s,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(f)}(h)};function s(h){return r=$r(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)),h===58?(t.enter("definitionMarker"),t.consume(h),t.exit("definitionMarker"),a):n(h)}function a(h){return en(h)?da(t,i)(h):i(h)}function i(h){return xy(t,l,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function l(h){return t.attempt(lI,d,d)(h)}function d(h){return ot(h)?ct(t,u,"whitespace")(h):u(h)}function u(h){return h===null||Ue(h)?(t.exit("definition"),o.parser.defined.push(r),e(h)):n(h)}}},lI={partial:!0,tokenize:function(t,e,n){return function(a){return en(a)?da(t,o)(a):n(a)};function o(a){return yy(t,r,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(a)}function r(a){return ot(a)?ct(t,s,"whitespace")(a):s(a)}function s(a){return a===null||Ue(a)?e(a):n(a)}}},cI={name:"hardBreakEscape",tokenize:function(t,e,n){return function(r){return t.enter("hardBreakEscape"),t.consume(r),o};function o(r){return Ue(r)?(t.exit("hardBreakEscape"),e(r)):n(r)}}},dI={name:"headingAtx",resolve:function(t,e){let n,o,r=t.length-2,s=3;return t[s][1].type==="whitespace"&&(s+=2),r-2>s&&t[r][1].type==="whitespace"&&(r-=2),t[r][1].type==="atxHeadingSequence"&&(s===r-1||r-4>s&&t[r-2][1].type==="whitespace")&&(r-=s+1===r?2:4),r>s&&(n={type:"atxHeadingText",start:t[s][1].start,end:t[r][1].end},o={type:"chunkText",start:t[s][1].start,end:t[r][1].end,contentType:"text"},Un(t,s,r-s+1,[["enter",n,e],["enter",o,e],["exit",o,e],["exit",n,e]])),t},tokenize:function(t,e,n){let o=0;return function(l){return t.enter("atxHeading"),function(d){return t.enter("atxHeadingSequence"),r(d)}(l)};function r(l){return l===35&&o++<6?(t.consume(l),r):l===null||en(l)?(t.exit("atxHeadingSequence"),s(l)):n(l)}function s(l){return l===35?(t.enter("atxHeadingSequence"),a(l)):l===null||Ue(l)?(t.exit("atxHeading"),e(l)):ot(l)?ct(t,s,"whitespace")(l):(t.enter("atxHeadingText"),i(l))}function a(l){return l===35?(t.consume(l),a):(t.exit("atxHeadingSequence"),s(l))}function i(l){return l===null||l===35||en(l)?(t.exit("atxHeadingText"),s(l)):(t.consume(l),i)}}},uI=["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"],vy=["pre","script","style","textarea"],hI={concrete:!0,name:"htmlFlow",resolveTo:function(t){let e=t.length;for(;e--&&(t[e][0]!=="enter"||t[e][1].type!=="htmlFlow"););return e>1&&t[e-2][1].type==="linePrefix"&&(t[e][1].start=t[e-2][1].start,t[e+1][1].start=t[e-2][1].start,t.splice(e-2,2)),t},tokenize:function(t,e,n){const o=this;let r,s,a,i,l;return function(E){return function(U){return t.enter("htmlFlow"),t.enter("htmlFlowData"),t.consume(U),d}(E)};function d(E){return E===33?(t.consume(E),u):E===47?(t.consume(E),s=!0,m):E===63?(t.consume(E),r=3,o.interrupt?e:T):$n(E)?(t.consume(E),a=String.fromCharCode(E),x):n(E)}function u(E){return E===45?(t.consume(E),r=2,h):E===91?(t.consume(E),r=5,i=0,f):$n(E)?(t.consume(E),r=4,o.interrupt?e:T):n(E)}function h(E){return E===45?(t.consume(E),o.interrupt?e:T):n(E)}function f(E){return E==="CDATA[".charCodeAt(i++)?(t.consume(E),i===6?o.interrupt?e:A:f):n(E)}function m(E){return $n(E)?(t.consume(E),a=String.fromCharCode(E),x):n(E)}function x(E){if(E===null||E===47||E===62||en(E)){const U=E===47,V=a.toLowerCase();return U||s||!vy.includes(V)?uI.includes(a.toLowerCase())?(r=6,U?(t.consume(E),g):o.interrupt?e(E):A(E)):(r=7,o.interrupt&&!o.parser.lazy[o.now().line]?n(E):s?p(E):b(E)):(r=1,o.interrupt?e(E):A(E))}return E===45||hn(E)?(t.consume(E),a+=String.fromCharCode(E),x):n(E)}function g(E){return E===62?(t.consume(E),o.interrupt?e:A):n(E)}function p(E){return ot(E)?(t.consume(E),p):C(E)}function b(E){return E===47?(t.consume(E),C):E===58||E===95||$n(E)?(t.consume(E),y):ot(E)?(t.consume(E),b):C(E)}function y(E){return E===45||E===46||E===58||E===95||hn(E)?(t.consume(E),y):v(E)}function v(E){return E===61?(t.consume(E),w):ot(E)?(t.consume(E),v):b(E)}function w(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(t.consume(E),l=E,S):ot(E)?(t.consume(E),w):N(E)}function S(E){return E===l?(t.consume(E),l=null,j):E===null||Ue(E)?n(E):(t.consume(E),S)}function N(E){return E===null||E===34||E===39||E===47||E===60||E===61||E===62||E===96||en(E)?v(E):(t.consume(E),N)}function j(E){return E===47||E===62||ot(E)?b(E):n(E)}function C(E){return E===62?(t.consume(E),_):n(E)}function _(E){return E===null||Ue(E)?A(E):ot(E)?(t.consume(E),_):n(E)}function A(E){return E===45&&r===2?(t.consume(E),M):E===60&&r===1?(t.consume(E),L):E===62&&r===4?(t.consume(E),k):E===63&&r===3?(t.consume(E),T):E===93&&r===5?(t.consume(E),D):!Ue(E)||r!==6&&r!==7?E===null||Ue(E)?(t.exit("htmlFlowData"),I(E)):(t.consume(E),A):(t.exit("htmlFlowData"),t.check(fI,B,I)(E))}function I(E){return t.check(mI,P,B)(E)}function P(E){return t.enter("lineEnding"),t.consume(E),t.exit("lineEnding"),R}function R(E){return E===null||Ue(E)?I(E):(t.enter("htmlFlowData"),A(E))}function M(E){return E===45?(t.consume(E),T):A(E)}function L(E){return E===47?(t.consume(E),a="",F):A(E)}function F(E){if(E===62){const U=a.toLowerCase();return vy.includes(U)?(t.consume(E),k):A(E)}return $n(E)&&a.length<8?(t.consume(E),a+=String.fromCharCode(E),F):A(E)}function D(E){return E===93?(t.consume(E),T):A(E)}function T(E){return E===62?(t.consume(E),k):E===45&&r===2?(t.consume(E),T):A(E)}function k(E){return E===null||Ue(E)?(t.exit("htmlFlowData"),B(E)):(t.consume(E),k)}function B(E){return t.exit("htmlFlow"),e(E)}}},fI={partial:!0,tokenize:function(t,e,n){return function(o){return t.enter("lineEnding"),t.consume(o),t.exit("lineEnding"),t.attempt(xl,e,n)}}},mI={partial:!0,tokenize:function(t,e,n){const o=this;return function(s){return Ue(s)?(t.enter("lineEnding"),t.consume(s),t.exit("lineEnding"),r):n(s)};function r(s){return o.parser.lazy[o.now().line]?n(s):e(s)}}},pI={name:"htmlText",tokenize:function(t,e,n){const o=this;let r,s,a;return function(k){return t.enter("htmlText"),t.enter("htmlTextData"),t.consume(k),i};function i(k){return k===33?(t.consume(k),l):k===47?(t.consume(k),w):k===63?(t.consume(k),y):$n(k)?(t.consume(k),j):n(k)}function l(k){return k===45?(t.consume(k),d):k===91?(t.consume(k),s=0,m):$n(k)?(t.consume(k),b):n(k)}function d(k){return k===45?(t.consume(k),f):n(k)}function u(k){return k===null?n(k):k===45?(t.consume(k),h):Ue(k)?(a=u,F(k)):(t.consume(k),u)}function h(k){return k===45?(t.consume(k),f):u(k)}function f(k){return k===62?L(k):k===45?h(k):u(k)}function m(k){return k==="CDATA[".charCodeAt(s++)?(t.consume(k),s===6?x:m):n(k)}function x(k){return k===null?n(k):k===93?(t.consume(k),g):Ue(k)?(a=x,F(k)):(t.consume(k),x)}function g(k){return k===93?(t.consume(k),p):x(k)}function p(k){return k===62?L(k):k===93?(t.consume(k),p):x(k)}function b(k){return k===null||k===62?L(k):Ue(k)?(a=b,F(k)):(t.consume(k),b)}function y(k){return k===null?n(k):k===63?(t.consume(k),v):Ue(k)?(a=y,F(k)):(t.consume(k),y)}function v(k){return k===62?L(k):y(k)}function w(k){return $n(k)?(t.consume(k),S):n(k)}function S(k){return k===45||hn(k)?(t.consume(k),S):N(k)}function N(k){return Ue(k)?(a=N,F(k)):ot(k)?(t.consume(k),N):L(k)}function j(k){return k===45||hn(k)?(t.consume(k),j):k===47||k===62||en(k)?C(k):n(k)}function C(k){return k===47?(t.consume(k),L):k===58||k===95||$n(k)?(t.consume(k),_):Ue(k)?(a=C,F(k)):ot(k)?(t.consume(k),C):L(k)}function _(k){return k===45||k===46||k===58||k===95||hn(k)?(t.consume(k),_):A(k)}function A(k){return k===61?(t.consume(k),I):Ue(k)?(a=A,F(k)):ot(k)?(t.consume(k),A):C(k)}function I(k){return k===null||k===60||k===61||k===62||k===96?n(k):k===34||k===39?(t.consume(k),r=k,P):Ue(k)?(a=I,F(k)):ot(k)?(t.consume(k),I):(t.consume(k),R)}function P(k){return k===r?(t.consume(k),r=void 0,M):k===null?n(k):Ue(k)?(a=P,F(k)):(t.consume(k),P)}function R(k){return k===null||k===34||k===39||k===60||k===61||k===96?n(k):k===47||k===62||en(k)?C(k):(t.consume(k),R)}function M(k){return k===47||k===62||en(k)?C(k):n(k)}function L(k){return k===62?(t.consume(k),t.exit("htmlTextData"),t.exit("htmlText"),e):n(k)}function F(k){return t.exit("htmlTextData"),t.enter("lineEnding"),t.consume(k),t.exit("lineEnding"),D}function D(k){return ot(k)?ct(t,T,"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(k):T(k)}function T(k){return t.enter("htmlTextData"),a(k)}}},Zu={name:"labelEnd",resolveAll:function(t){let e=-1;const n=[];for(;++e<t.length;){const o=t[e][1];if(n.push(t[e]),o.type==="labelImage"||o.type==="labelLink"||o.type==="labelEnd"){const r=o.type==="labelImage"?4:2;o.type="data",e+=r}}return t.length!==n.length&&Un(t,0,t.length,n),t},resolveTo:function(t,e){let n,o,r,s,a=t.length,i=0;for(;a--;)if(n=t[a][1],o){if(n.type==="link"||n.type==="labelLink"&&n._inactive)break;t[a][0]==="enter"&&n.type==="labelLink"&&(n._inactive=!0)}else if(r){if(t[a][0]==="enter"&&(n.type==="labelImage"||n.type==="labelLink")&&!n._balanced&&(o=a,n.type!=="labelLink")){i=2;break}}else n.type==="labelEnd"&&(r=a);const l={type:t[o][1].type==="labelLink"?"link":"image",start:{...t[o][1].start},end:{...t[t.length-1][1].end}},d={type:"label",start:{...t[o][1].start},end:{...t[r][1].end}},u={type:"labelText",start:{...t[o+i+2][1].end},end:{...t[r-2][1].start}};return s=[["enter",l,e],["enter",d,e]],s=wn(s,t.slice(o+1,o+i+3)),s=wn(s,[["enter",u,e]]),s=wn(s,Ku(e.parser.constructs.insideSpan.null,t.slice(o+i+4,r-3),e)),s=wn(s,[["exit",u,e],t[r-2],t[r-1],["exit",d,e]]),s=wn(s,t.slice(r+1)),s=wn(s,[["exit",l,e]]),Un(t,o,t.length,s),t},tokenize:function(t,e,n){const o=this;let r,s,a=o.events.length;for(;a--;)if((o.events[a][1].type==="labelImage"||o.events[a][1].type==="labelLink")&&!o.events[a][1]._balanced){r=o.events[a][1];break}return function(h){return r?r._inactive?u(h):(s=o.parser.defined.includes($r(o.sliceSerialize({start:r.end,end:o.now()}))),t.enter("labelEnd"),t.enter("labelMarker"),t.consume(h),t.exit("labelMarker"),t.exit("labelEnd"),i):n(h)};function i(h){return h===40?t.attempt(gI,d,s?d:u)(h):h===91?t.attempt(xI,d,s?l:u)(h):s?d(h):u(h)}function l(h){return t.attempt(bI,d,u)(h)}function d(h){return e(h)}function u(h){return r._balanced=!0,n(h)}}},gI={tokenize:function(t,e,n){return function(u){return t.enter("resource"),t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),o};function o(u){return en(u)?da(t,r)(u):r(u)}function r(u){return u===41?d(u):xy(t,s,a,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(u)}function s(u){return en(u)?da(t,i)(u):d(u)}function a(u){return n(u)}function i(u){return u===34||u===39||u===40?yy(t,l,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(u):d(u)}function l(u){return en(u)?da(t,d)(u):d(u)}function d(u){return u===41?(t.enter("resourceMarker"),t.consume(u),t.exit("resourceMarker"),t.exit("resource"),e):n(u)}}},xI={tokenize:function(t,e,n){const o=this;return function(a){return by.call(o,t,r,s,"reference","referenceMarker","referenceString")(a)};function r(a){return o.parser.defined.includes($r(o.sliceSerialize(o.events[o.events.length-1][1]).slice(1,-1)))?e(a):n(a)}function s(a){return n(a)}}},bI={tokenize:function(t,e,n){return function(r){return t.enter("reference"),t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),o};function o(r){return r===93?(t.enter("referenceMarker"),t.consume(r),t.exit("referenceMarker"),t.exit("reference"),e):n(r)}}},yI={name:"labelStartImage",resolveAll:Zu.resolveAll,tokenize:function(t,e,n){const o=this;return function(a){return t.enter("labelImage"),t.enter("labelImageMarker"),t.consume(a),t.exit("labelImageMarker"),r};function r(a){return a===91?(t.enter("labelMarker"),t.consume(a),t.exit("labelMarker"),t.exit("labelImage"),s):n(a)}function s(a){return a===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(a):e(a)}}},vI={name:"labelStartLink",resolveAll:Zu.resolveAll,tokenize:function(t,e,n){const o=this;return function(s){return t.enter("labelLink"),t.enter("labelMarker"),t.consume(s),t.exit("labelMarker"),t.exit("labelLink"),r};function r(s){return s===94&&"_hiddenFootnoteSupport"in o.parser.constructs?n(s):e(s)}}},Qu={name:"lineEnding",tokenize:function(t,e){return function(n){return t.enter("lineEnding"),t.consume(n),t.exit("lineEnding"),ct(t,e,"linePrefix")}}},bl={name:"thematicBreak",tokenize:function(t,e,n){let o,r=0;return function(i){return t.enter("thematicBreak"),function(l){return o=l,s(l)}(i)};function s(i){return i===o?(t.enter("thematicBreakSequence"),a(i)):r>=3&&(i===null||Ue(i))?(t.exit("thematicBreak"),e(i)):n(i)}function a(i){return i===o?(t.consume(i),r++,a):(t.exit("thematicBreakSequence"),ot(i)?ct(t,s,"whitespace")(i):s(i))}}},tn={continuation:{tokenize:function(t,e,n){const o=this;return o.containerState._closeFlow=void 0,t.check(xl,r,s);function r(i){return o.containerState.furtherBlankLines=o.containerState.furtherBlankLines||o.containerState.initialBlankLine,ct(t,e,"listItemIndent",o.containerState.size+1)(i)}function s(i){return o.containerState.furtherBlankLines||!ot(i)?(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,a(i)):(o.containerState.furtherBlankLines=void 0,o.containerState.initialBlankLine=void 0,t.attempt(kI,e,a)(i))}function a(i){return o.containerState._closeFlow=!0,o.interrupt=void 0,ct(t,t.attempt(tn,e,n),"linePrefix",o.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(i)}}},exit:function(t){t.exit(this.containerState.type)},name:"list",tokenize:function(t,e,n){const o=this,r=o.events[o.events.length-1];let s=r&&r[1].type==="linePrefix"?r[2].sliceSerialize(r[1],!0).length:0,a=0;return function(f){const m=o.containerState.type||(f===42||f===43||f===45?"listUnordered":"listOrdered");if(m==="listUnordered"?!o.containerState.marker||f===o.containerState.marker:Yu(f)){if(o.containerState.type||(o.containerState.type=m,t.enter(m,{_container:!0})),m==="listUnordered")return t.enter("listItemPrefix"),f===42||f===45?t.check(bl,n,l)(f):l(f);if(!o.interrupt||f===49)return t.enter("listItemPrefix"),t.enter("listItemValue"),i(f)}return n(f)};function i(f){return Yu(f)&&++a<10?(t.consume(f),i):(!o.interrupt||a<2)&&(o.containerState.marker?f===o.containerState.marker:f===41||f===46)?(t.exit("listItemValue"),l(f)):n(f)}function l(f){return t.enter("listItemMarker"),t.consume(f),t.exit("listItemMarker"),o.containerState.marker=o.containerState.marker||f,t.check(xl,o.interrupt?n:d,t.attempt(wI,h,u))}function d(f){return o.containerState.initialBlankLine=!0,s++,h(f)}function u(f){return ot(f)?(t.enter("listItemPrefixWhitespace"),t.consume(f),t.exit("listItemPrefixWhitespace"),h):n(f)}function h(f){return o.containerState.size=s+o.sliceSerialize(t.exit("listItemPrefix"),!0).length,e(f)}}},wI={partial:!0,tokenize:function(t,e,n){const o=this;return ct(t,function(r){const s=o.events[o.events.length-1];return!ot(r)&&s&&s[1].type==="listItemPrefixWhitespace"?e(r):n(r)},"listItemPrefixWhitespace",o.parser.constructs.disable.null.includes("codeIndented")?void 0:5)}},kI={partial:!0,tokenize:function(t,e,n){const o=this;return ct(t,function(r){const s=o.events[o.events.length-1];return s&&s[1].type==="listItemIndent"&&s[2].sliceSerialize(s[1],!0).length===o.containerState.size?e(r):n(r)},"listItemIndent",o.containerState.size+1)}},wy={name:"setextUnderline",resolveTo:function(t,e){let n,o,r,s=t.length;for(;s--;)if(t[s][0]==="enter"){if(t[s][1].type==="content"){n=s;break}t[s][1].type==="paragraph"&&(o=s)}else t[s][1].type==="content"&&t.splice(s,1),r||t[s][1].type!=="definition"||(r=s);const a={type:"setextHeading",start:{...t[n][1].start},end:{...t[t.length-1][1].end}};return t[o][1].type="setextHeadingText",r?(t.splice(o,0,["enter",a,e]),t.splice(r+1,0,["exit",t[n][1],e]),t[n][1].end={...t[r][1].end}):t[n][1]=a,t.push(["exit",a,e]),t},tokenize:function(t,e,n){const o=this;let r;return function(i){let l,d=o.events.length;for(;d--;)if(o.events[d][1].type!=="lineEnding"&&o.events[d][1].type!=="linePrefix"&&o.events[d][1].type!=="content"){l=o.events[d][1].type==="paragraph";break}return!o.parser.lazy[o.now().line]&&(o.interrupt||l)?(t.enter("setextHeadingLine"),r=i,function(u){return t.enter("setextHeadingLineSequence"),s(u)}(i)):n(i)};function s(i){return i===r?(t.consume(i),s):(t.exit("setextHeadingLineSequence"),ot(i)?ct(t,a,"lineSuffix")(i):a(i))}function a(i){return i===null||Ue(i)?(t.exit("setextHeadingLine"),e(i)):n(i)}}},SI={tokenize:function(t){const e=this,n=t.attempt(xl,function(r){return r===null?void t.consume(r):(t.enter("lineEndingBlank"),t.consume(r),t.exit("lineEndingBlank"),e.currentConstruct=void 0,n)},t.attempt(this.parser.constructs.flowInitial,o,ct(t,t.attempt(this.parser.constructs.flow,o,t.attempt(sI,o)),"linePrefix")));return n;function o(r){if(r!==null)return t.enter("lineEnding"),t.consume(r),t.exit("lineEnding"),e.currentConstruct=void 0,n;t.consume(r)}}},NI={resolveAll:Sy()},jI=ky("string"),CI=ky("text");function ky(t){return{resolveAll:Sy(t==="text"?EI:void 0),tokenize:function(e){const n=this,o=this.parser.constructs[t],r=e.attempt(o,s,a);return s;function s(d){return l(d)?r(d):a(d)}function a(d){if(d!==null)return e.enter("data"),e.consume(d),i;e.consume(d)}function i(d){return l(d)?(e.exit("data"),r(d)):(e.consume(d),i)}function l(d){if(d===null)return!0;const u=o[d];let h=-1;if(u)for(;++h<u.length;){const f=u[h];if(!f.previous||f.previous.call(n,n.previous))return!0}return!1}}}}function Sy(t){return function(e,n){let o,r=-1;for(;++r<=e.length;)o===void 0?e[r]&&e[r][1].type==="data"&&(o=r,r++):e[r]&&e[r][1].type==="data"||(r!==o+2&&(e[o][1].end=e[r-1][1].end,e.splice(o+2,r-o-2),r=o+2),o=void 0);return t?t(e,n):e}}function EI(t,e){let n=0;for(;++n<=t.length;)if((n===t.length||t[n][1].type==="lineEnding")&&t[n-1][1].type==="data"){const o=t[n-1][1],r=e.sliceStream(o);let s,a=r.length,i=-1,l=0;for(;a--;){const d=r[a];if(typeof d=="string"){for(i=d.length;d.charCodeAt(i-1)===32;)l++,i--;if(i)break;i=-1}else if(d===-2)s=!0,l++;else if(d!==-1){a++;break}}if(e._contentTypeTextTrailing&&n===t.length&&(l=0),l){const d={type:n===t.length||s||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:a?i:o.start._bufferIndex+i,_index:o.start._index+a,line:o.end.line,column:o.end.column-l,offset:o.end.offset-l},end:{...o.end}};o.end={...d.start},o.start.offset===o.end.offset?Object.assign(o,d):(t.splice(n,0,["enter",d,e],["exit",d,e]),n+=2)}n++}return t}const _I={42:tn,43:tn,45:tn,48:tn,49:tn,50:tn,51:tn,52:tn,53:tn,54:tn,55:tn,56:tn,57:tn,62:uy},II={91:iI},AI={[-2]:Ju,[-1]:Ju,32:Ju},TI={35:dI,42:bl,45:[wy,bl],60:hI,61:wy,95:bl,96:py,126:py},MI={38:fy,92:hy},OI={[-5]:Qu,[-4]:Qu,[-3]:Qu,33:yI,38:fy,42:Xu,60:[eI,pI],91:vI,92:[cI,hy],93:Zu,95:Xu,96:nI},DI={null:[Xu,NI]},PI=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:{null:[42,95]},contentInitial:II,disable:{null:[]},document:_I,flow:TI,flowInitial:AI,insideSpan:DI,string:MI,text:OI},Symbol.toStringTag,{value:"Module"}));function RI(t,e,n){let o={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const r={},s=[];let a=[],i=[];const l={attempt:p(function(v,w){b(v,w.from)}),check:p(g),consume:function(v){Ue(v)?(o.line++,o.column=1,o.offset+=v===-3?2:1,y()):v!==-1&&(o.column++,o.offset++),o._bufferIndex<0?o._index++:(o._bufferIndex++,o._bufferIndex===a[o._index].length&&(o._bufferIndex=-1,o._index++)),d.previous=v},enter:function(v,w){const S=w||{};return S.type=v,S.start=f(),d.events.push(["enter",S,d]),i.push(S),S},exit:function(v){const w=i.pop();return w.end=f(),d.events.push(["exit",w,d]),w},interrupt:p(g,{interrupt:!0})},d={code:null,containerState:{},defineSkip:function(v){r[v.line]=v.column,y()},events:[],now:f,parser:t,previous:null,sliceSerialize:function(v,w){return function(S,N){let j=-1;const C=[];let _;for(;++j<S.length;){const A=S[j];let I;if(typeof A=="string")I=A;else switch(A){case-5:I="\r";break;case-4:I=`
129
- `;break;case-3:I=`\r
130
- `;break;case-2:I=N?" ":" ";break;case-1:if(!N&&_)continue;I=" ";break;default:I=String.fromCharCode(A)}_=A===-2,C.push(I)}return C.join("")}(h(v),w)},sliceStream:h,write:function(v){return a=wn(a,v),m(),a[a.length-1]!==null?[]:(b(e,0),d.events=Ku(s,d.events,d),d.events)}};let u=e.tokenize.call(d,l);return e.resolveAll&&s.push(e),d;function h(v){return function(w,S){const N=S.start._index,j=S.start._bufferIndex,C=S.end._index,_=S.end._bufferIndex;let A;if(N===C)A=[w[N].slice(j,_)];else{if(A=w.slice(N,C),j>-1){const I=A[0];typeof I=="string"?A[0]=I.slice(j):A.shift()}_>0&&A.push(w[C].slice(0,_))}return A}(a,v)}function f(){const{_bufferIndex:v,_index:w,line:S,column:N,offset:j}=o;return{_bufferIndex:v,_index:w,line:S,column:N,offset:j}}function m(){let v;for(;o._index<a.length;){const w=a[o._index];if(typeof w=="string")for(v=o._index,o._bufferIndex<0&&(o._bufferIndex=0);o._index===v&&o._bufferIndex<w.length;)x(w.charCodeAt(o._bufferIndex));else x(w)}}function x(v){u=u(v)}function g(v,w){w.restore()}function p(v,w){return function(S,N,j){let C,_,A,I;return Array.isArray(S)?P(S):"tokenize"in S?P([S]):function(F){return D;function D(T){const k=T!==null&&F[T],B=T!==null&&F.null;return P([...Array.isArray(k)?k:k?[k]:[],...Array.isArray(B)?B:B?[B]:[]])(T)}}(S);function P(F){return C=F,_=0,F.length===0?j:R(F[_])}function R(F){return function(D){return I=function(){const T=f(),k=d.previous,B=d.currentConstruct,E=d.events.length,U=Array.from(i);return{from:E,restore:V};function V(){o=T,d.previous=k,d.currentConstruct=B,d.events.length=E,i=U,y()}}(),A=F,F.partial||(d.currentConstruct=F),F.name&&d.parser.constructs.disable.null.includes(F.name)?L():F.tokenize.call(w?Object.assign(Object.create(d),w):d,l,M,L)(D)}}function M(F){return v(A,I),N}function L(F){return I.restore(),++_<C.length?R(C[_]):j}}}function b(v,w){v.resolveAll&&!s.includes(v)&&s.push(v),v.resolve&&Un(d.events,w,d.events.length-w,v.resolve(d.events.slice(w),d)),v.resolveTo&&(d.events=v.resolveTo(d.events,d))}function y(){o.line in r&&o.column<2&&(o.column=r[o.line],o.offset+=r[o.line]-1)}}function LI(t){const e=function(r){const s={};let a=-1;for(;++a<r.length;)W6(s,r[a]);return s}([PI,...(t||{}).extensions||[]]),n={constructs:e,content:o(Z6),defined:[],document:o(Q6),flow:o(SI),lazy:{},string:o(jI),text:o(CI)};return n;function o(r){return function(s){return RI(n,r,s)}}}const Ny=/[\0\t\n\r]/g,FI=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function zI(t,e,n){if(e)return e;if(n.charCodeAt(0)===35){const o=n.charCodeAt(1),r=o===120||o===88;return iy(n.slice(r?2:1),r?16:10)}return qu(n)||t}const jy={}.hasOwnProperty;function BI(t,e,n){return typeof e!="string"&&(n=e,e=void 0),function(o){const r={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:l(Me),autolinkProtocol:P,autolinkEmail:P,atxHeading:l(ae),blockQuote:l(ne),characterEscape:P,characterReference:P,codeFenced:l(se),codeFencedFenceInfo:d,codeFencedFenceMeta:d,codeIndented:l(se,d),codeText:l(te,d),codeTextData:P,data:P,codeFlowValue:P,definition:l(pe),definitionDestinationString:d,definitionLabelString:d,definitionTitleString:d,emphasis:l(he),hardBreakEscape:l(ye),hardBreakTrailing:l(ye),htmlFlow:l(fe,d),htmlFlowData:P,htmlText:l(fe,d),htmlTextData:P,image:l(Se),label:d,link:l(Me),listItem:l(Le),listItemValue:g,listOrdered:l(Ee,x),listUnordered:l(Ee),paragraph:l(Te),reference:Y,referenceString:d,resourceDestinationString:d,resourceTitleString:d,setextHeading:l(ae),strong:l(Ze),thematicBreak:l(Ge)},exit:{atxHeading:h(),atxHeadingSequence:C,autolink:h(),autolinkEmail:oe,autolinkProtocol:re,blockQuote:h(),characterEscapeValue:R,characterReferenceMarkerHexadecimal:Q,characterReferenceMarkerNumeric:Q,characterReferenceValue:q,characterReference:K,codeFenced:h(v),codeFencedFence:y,codeFencedFenceInfo:p,codeFencedFenceMeta:b,codeFlowValue:R,codeIndented:h(w),codeText:h(T),codeTextData:R,data:R,definition:h(),definitionDestinationString:j,definitionLabelString:S,definitionTitleString:N,emphasis:h(),hardBreakEscape:h(L),hardBreakTrailing:h(L),htmlFlow:h(F),htmlFlowData:R,htmlText:h(D),htmlTextData:R,image:h(B),label:U,labelText:E,lineEnding:M,link:h(k),listItem:h(),listOrdered:h(),listUnordered:h(),paragraph:h(),referenceString:J,resourceDestinationString:V,resourceTitleString:$,resource:X,setextHeading:h(I),setextHeadingLineSequence:A,setextHeadingText:_,strong:h(),thematicBreak:h()}};Cy(r,(o||{}).mdastExtensions||[]);const s={};return a;function a(ee){let be={type:"root",children:[]};const we={stack:[be],tokenStack:[],config:r,enter:u,exit:f,buffer:d,resume:m,data:s},Ae=[];let W=-1;for(;++W<ee.length;)(ee[W][1].type==="listOrdered"||ee[W][1].type==="listUnordered")&&(ee[W][0]==="enter"?Ae.push(W):W=i(ee,Ae.pop(),W));for(W=-1;++W<ee.length;){const de=r[ee[W][0]];jy.call(de,ee[W][1].type)&&de[ee[W][1].type].call(Object.assign({sliceSerialize:ee[W][2].sliceSerialize},we),ee[W][1])}if(we.tokenStack.length>0){const de=we.tokenStack[we.tokenStack.length-1];(de[1]||Ey).call(we,void 0,de[0])}for(be.position={start:Po(ee.length>0?ee[0][1].start:{line:1,column:1,offset:0}),end:Po(ee.length>0?ee[ee.length-2][1].end:{line:1,column:1,offset:0})},W=-1;++W<r.transforms.length;)be=r.transforms[W](be)||be;return be}function i(ee,be,we){let Ae,W,de,ue,ce=be-1,ve=-1,Oe=!1;for(;++ce<=we;){const Re=ee[ce];switch(Re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":Re[0]==="enter"?ve++:ve--,ue=void 0;break;case"lineEndingBlank":Re[0]==="enter"&&(!Ae||ue||ve||de||(de=ce),ue=void 0);break;case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ue=void 0}if(!ve&&Re[0]==="enter"&&Re[1].type==="listItemPrefix"||ve===-1&&Re[0]==="exit"&&(Re[1].type==="listUnordered"||Re[1].type==="listOrdered")){if(Ae){let Ye=ce;for(W=void 0;Ye--;){const ie=ee[Ye];if(ie[1].type==="lineEnding"||ie[1].type==="lineEndingBlank"){if(ie[0]==="exit")continue;W&&(ee[W][1].type="lineEndingBlank",Oe=!0),ie[1].type="lineEnding",W=Ye}else if(ie[1].type!=="linePrefix"&&ie[1].type!=="blockQuotePrefix"&&ie[1].type!=="blockQuotePrefixWhitespace"&&ie[1].type!=="blockQuoteMarker"&&ie[1].type!=="listItemIndent")break}de&&(!W||de<W)&&(Ae._spread=!0),Ae.end=Object.assign({},W?ee[W][1].start:Re[1].end),ee.splice(W||ce,0,["exit",Ae,Re[2]]),ce++,we++}if(Re[1].type==="listItemPrefix"){const Ye={type:"listItem",_spread:!1,start:Object.assign({},Re[1].start),end:void 0};Ae=Ye,ee.splice(ce,0,["enter",Ye,Re[2]]),ce++,we++,de=void 0,ue=!0}}}return ee[be][1]._spread=Oe,we}function l(ee,be){return we;function we(Ae){u.call(this,ee(Ae),Ae),be&&be.call(this,Ae)}}function d(){this.stack.push({type:"fragment",children:[]})}function u(ee,be,we){this.stack[this.stack.length-1].children.push(ee),this.stack.push(ee),this.tokenStack.push([be,we||void 0]),ee.position={start:Po(be.start),end:void 0}}function h(ee){return be;function be(we){ee&&ee.call(this,we),f.call(this,we)}}function f(ee,be){const we=this.stack.pop(),Ae=this.tokenStack.pop();if(!Ae)throw new Error("Cannot close `"+ee.type+"` ("+ia({start:ee.start,end:ee.end})+"): it\u2019s not open");Ae[0].type!==ee.type&&(be?be.call(this,ee,Ae[0]):(Ae[1]||Ey).call(this,ee,Ae[0])),we.position.end=Po(ee.end)}function m(){return function(ee){return oy(ee,typeof gl.includeImageAlt!="boolean"||gl.includeImageAlt,typeof gl.includeHtml!="boolean"||gl.includeHtml)}(this.stack.pop())}function x(){this.data.expectingFirstListItemValue=!0}function g(ee){this.data.expectingFirstListItemValue&&(this.stack[this.stack.length-2].start=Number.parseInt(this.sliceSerialize(ee),10),this.data.expectingFirstListItemValue=void 0)}function p(){const ee=this.resume();this.stack[this.stack.length-1].lang=ee}function b(){const ee=this.resume();this.stack[this.stack.length-1].meta=ee}function y(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function v(){const ee=this.resume();this.stack[this.stack.length-1].value=ee.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function w(){const ee=this.resume();this.stack[this.stack.length-1].value=ee.replace(/(\r?\n|\r)$/g,"")}function S(ee){const be=this.resume(),we=this.stack[this.stack.length-1];we.label=be,we.identifier=$r(this.sliceSerialize(ee)).toLowerCase()}function N(){const ee=this.resume();this.stack[this.stack.length-1].title=ee}function j(){const ee=this.resume();this.stack[this.stack.length-1].url=ee}function C(ee){const be=this.stack[this.stack.length-1];if(!be.depth){const we=this.sliceSerialize(ee).length;be.depth=we}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function A(ee){this.stack[this.stack.length-1].depth=this.sliceSerialize(ee).codePointAt(0)===61?1:2}function I(){this.data.setextHeadingSlurpLineEnding=void 0}function P(ee){const be=this.stack[this.stack.length-1].children;let we=be[be.length-1];we&&we.type==="text"||(we=He(),we.position={start:Po(ee.start),end:void 0},be.push(we)),this.stack.push(we)}function R(ee){const be=this.stack.pop();be.value+=this.sliceSerialize(ee),be.position.end=Po(ee.end)}function M(ee){const be=this.stack[this.stack.length-1];if(this.data.atHardBreak)return be.children[be.children.length-1].position.end=Po(ee.end),void(this.data.atHardBreak=void 0);!this.data.setextHeadingSlurpLineEnding&&r.canContainEols.includes(be.type)&&(P.call(this,ee),R.call(this,ee))}function L(){this.data.atHardBreak=!0}function F(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function D(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function T(){const ee=this.resume();this.stack[this.stack.length-1].value=ee}function k(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=be,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function B(){const ee=this.stack[this.stack.length-1];if(this.data.inReference){const be=this.data.referenceType||"shortcut";ee.type+="Reference",ee.referenceType=be,delete ee.url,delete ee.title}else delete ee.identifier,delete ee.label;this.data.referenceType=void 0}function E(ee){const be=this.sliceSerialize(ee),we=this.stack[this.stack.length-2];we.label=function(Ae){return Ae.replace(FI,zI)}(be),we.identifier=$r(be).toLowerCase()}function U(){const ee=this.stack[this.stack.length-1],be=this.resume(),we=this.stack[this.stack.length-1];if(this.data.inReference=!0,we.type==="link"){const Ae=ee.children;we.children=Ae}else we.alt=be}function V(){const ee=this.resume();this.stack[this.stack.length-1].url=ee}function $(){const ee=this.resume();this.stack[this.stack.length-1].title=ee}function X(){this.data.inReference=void 0}function Y(){this.data.referenceType="collapsed"}function J(ee){const be=this.resume(),we=this.stack[this.stack.length-1];we.label=be,we.identifier=$r(this.sliceSerialize(ee)).toLowerCase(),this.data.referenceType="full"}function Q(ee){this.data.characterReferenceType=ee.type}function q(ee){const be=this.sliceSerialize(ee),we=this.data.characterReferenceType;let Ae;we?(Ae=iy(be,we==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ae=qu(be),this.stack[this.stack.length-1].value+=Ae}function K(ee){this.stack.pop().position.end=Po(ee.end)}function re(ee){R.call(this,ee),this.stack[this.stack.length-1].url=this.sliceSerialize(ee)}function oe(ee){R.call(this,ee),this.stack[this.stack.length-1].url="mailto:"+this.sliceSerialize(ee)}function ne(){return{type:"blockquote",children:[]}}function se(){return{type:"code",lang:null,meta:null,value:""}}function te(){return{type:"inlineCode",value:""}}function pe(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function he(){return{type:"emphasis",children:[]}}function ae(){return{type:"heading",depth:0,children:[]}}function ye(){return{type:"break"}}function fe(){return{type:"html",value:""}}function Se(){return{type:"image",title:null,url:"",alt:null}}function Me(){return{type:"link",title:null,url:"",children:[]}}function Ee(ee){return{type:"list",ordered:ee.type==="listOrdered",start:null,spread:ee._spread,children:[]}}function Le(ee){return{type:"listItem",spread:ee._spread,checked:null,children:[]}}function Te(){return{type:"paragraph",children:[]}}function Ze(){return{type:"strong",children:[]}}function He(){return{type:"text",value:""}}function Ge(){return{type:"thematicBreak"}}}(n)(function(o){for(;!gy(o););return o}(LI(n).document().write(function(){let o,r=1,s="",a=!0;return function(i,l,d){const u=[];let h,f,m,x,g;for(i=s+(typeof i=="string"?i.toString():new TextDecoder(l||void 0).decode(i)),m=0,s="",a&&(i.charCodeAt(0)===65279&&m++,a=void 0);m<i.length;){if(Ny.lastIndex=m,h=Ny.exec(i),x=h&&h.index!==void 0?h.index:i.length,g=i.charCodeAt(x),!h){s=i.slice(m);break}if(g===10&&m===x&&o)u.push(-3),o=void 0;else switch(o&&(u.push(-5),o=void 0),m<x&&(u.push(i.slice(m,x)),r+=x-m),g){case 0:u.push(65533),r++;break;case 9:for(f=4*Math.ceil(r/4),u.push(-2);r++<f;)u.push(-1);break;case 10:u.push(-4),r=1;break;default:o=!0,r=1}m=x+1}return d&&(o&&u.push(-5),s&&u.push(s),u.push(null)),u}}()(t,e,!0))))}function Po(t){return{line:t.line,column:t.column,offset:t.offset}}function Cy(t,e){let n=-1;for(;++n<e.length;){const o=e[n];Array.isArray(o)?Cy(t,o):UI(t,o)}}function UI(t,e){let n;for(n in e)if(jy.call(e,n))switch(n){case"canContainEols":{const o=e[n];o&&t[n].push(...o);break}case"transforms":{const o=e[n];o&&t[n].push(...o);break}case"enter":case"exit":{const o=e[n];o&&Object.assign(t[n],o);break}}}function Ey(t,e){throw t?new Error("Cannot close `"+t.type+"` ("+ia({start:t.start,end:t.end})+"): a different token (`"+e.type+"`, "+ia({start:e.start,end:e.end})+") is open"):new Error("Cannot close document, a token (`"+e.type+"`, "+ia({start:e.start,end:e.end})+") is still open")}function $I(t){const e=this;e.parser=function(n){return BI(n,{...e.data("settings"),...t,extensions:e.data("micromarkExtensions")||[],mdastExtensions:e.data("fromMarkdownExtensions")||[]})}}function _y(t,e){const n=e.referenceType;let o="]";if(n==="collapsed"?o+="[]":n==="full"&&(o+="["+(e.label||e.identifier)+"]"),e.type==="imageReference")return[{type:"text",value:"!["+e.alt+o}];const r=t.all(e),s=r[0];s&&s.type==="text"?s.value="["+s.value:r.unshift({type:"text",value:"["});const a=r[r.length-1];return a&&a.type==="text"?a.value+=o:r.push({type:"text",value:o}),r}function Iy(t){const e=t.spread;return e??t.children.length>1}function VI(t){const e=String(t),n=/\r?\n|\r/g;let o=n.exec(e),r=0;const s=[];for(;o;)s.push(Ay(e.slice(r,o.index),r>0,!0),o[0]),r=o.index+o[0].length,o=n.exec(e);return s.push(Ay(e.slice(r),r>0,!1)),s.join("")}function Ay(t,e,n){let o=0,r=t.length;if(e){let s=t.codePointAt(o);for(;s===9||s===32;)o++,s=t.codePointAt(o)}if(n){let s=t.codePointAt(r-1);for(;s===9||s===32;)r--,s=t.codePointAt(r-1)}return r>o?t.slice(o,r):""}const HI={blockquote:function(t,e){const n={type:"element",tagName:"blockquote",properties:{},children:t.wrap(t.all(e),!0)};return t.patch(e,n),t.applyData(e,n)},break:function(t,e){const n={type:"element",tagName:"br",properties:{},children:[]};return t.patch(e,n),[t.applyData(e,n),{type:"text",value:`
131
- `}]},code:function(t,e){const n=e.value?e.value+`
132
- `:"",o={};e.lang&&(o.className=["language-"+e.lang]);let r={type:"element",tagName:"code",properties:o,children:[{type:"text",value:n}]};return e.meta&&(r.data={meta:e.meta}),t.patch(e,r),r=t.applyData(e,r),r={type:"element",tagName:"pre",properties:{},children:[r]},t.patch(e,r),r},delete:function(t,e){const n={type:"element",tagName:"del",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},emphasis:function(t,e){const n={type:"element",tagName:"em",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},footnoteReference:function(t,e){const n=typeof t.options.clobberPrefix=="string"?t.options.clobberPrefix:"user-content-",o=String(e.identifier).toUpperCase(),r=Vr(o.toLowerCase()),s=t.footnoteOrder.indexOf(o);let a,i=t.footnoteCounts.get(o);i===void 0?(i=0,t.footnoteOrder.push(o),a=t.footnoteOrder.length):a=s+1,i+=1,t.footnoteCounts.set(o,i);const l={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+r,id:n+"fnref-"+r+(i>1?"-"+i:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};t.patch(e,l);const d={type:"element",tagName:"sup",properties:{},children:[l]};return t.patch(e,d),t.applyData(e,d)},heading:function(t,e){const n={type:"element",tagName:"h"+e.depth,properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},html:function(t,e){if(t.options.allowDangerousHtml){const n={type:"raw",value:e.value};return t.patch(e,n),t.applyData(e,n)}},imageReference:function(t,e){const n=String(e.identifier).toUpperCase(),o=t.definitionById.get(n);if(!o)return _y(t,e);const r={src:Vr(o.url||""),alt:e.alt};o.title!==null&&o.title!==void 0&&(r.title=o.title);const s={type:"element",tagName:"img",properties:r,children:[]};return t.patch(e,s),t.applyData(e,s)},image:function(t,e){const n={src:Vr(e.url)};e.alt!==null&&e.alt!==void 0&&(n.alt=e.alt),e.title!==null&&e.title!==void 0&&(n.title=e.title);const o={type:"element",tagName:"img",properties:n,children:[]};return t.patch(e,o),t.applyData(e,o)},inlineCode:function(t,e){const n={type:"text",value:e.value.replace(/\r?\n|\r/g," ")};t.patch(e,n);const o={type:"element",tagName:"code",properties:{},children:[n]};return t.patch(e,o),t.applyData(e,o)},linkReference:function(t,e){const n=String(e.identifier).toUpperCase(),o=t.definitionById.get(n);if(!o)return _y(t,e);const r={href:Vr(o.url||"")};o.title!==null&&o.title!==void 0&&(r.title=o.title);const s={type:"element",tagName:"a",properties:r,children:t.all(e)};return t.patch(e,s),t.applyData(e,s)},link:function(t,e){const n={href:Vr(e.url)};e.title!==null&&e.title!==void 0&&(n.title=e.title);const o={type:"element",tagName:"a",properties:n,children:t.all(e)};return t.patch(e,o),t.applyData(e,o)},listItem:function(t,e,n){const o=t.all(e),r=n?function(u){let h=!1;if(u.type==="list"){h=u.spread||!1;const f=u.children;let m=-1;for(;!h&&++m<f.length;)h=Iy(f[m])}return h}(n):Iy(e),s={},a=[];if(typeof e.checked=="boolean"){const u=o[0];let h;u&&u.type==="element"&&u.tagName==="p"?h=u:(h={type:"element",tagName:"p",properties:{},children:[]},o.unshift(h)),h.children.length>0&&h.children.unshift({type:"text",value:" "}),h.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:e.checked,disabled:!0},children:[]}),s.className=["task-list-item"]}let i=-1;for(;++i<o.length;){const u=o[i];(r||i!==0||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
133
- `}),u.type!=="element"||u.tagName!=="p"||r?a.push(u):a.push(...u.children)}const l=o[o.length-1];l&&(r||l.type!=="element"||l.tagName!=="p")&&a.push({type:"text",value:`
134
- `});const d={type:"element",tagName:"li",properties:s,children:a};return t.patch(e,d),t.applyData(e,d)},list:function(t,e){const n={},o=t.all(e);let r=-1;for(typeof e.start=="number"&&e.start!==1&&(n.start=e.start);++r<o.length;){const a=o[r];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const s={type:"element",tagName:e.ordered?"ol":"ul",properties:n,children:t.wrap(o,!0)};return t.patch(e,s),t.applyData(e,s)},paragraph:function(t,e){const n={type:"element",tagName:"p",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},root:function(t,e){const n={type:"root",children:t.wrap(t.all(e))};return t.patch(e,n),t.applyData(e,n)},strong:function(t,e){const n={type:"element",tagName:"strong",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},table:function(t,e){const n=t.all(e),o=n.shift(),r=[];if(o){const a={type:"element",tagName:"thead",properties:{},children:t.wrap([o],!0)};t.patch(e.children[0],a),r.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:t.wrap(n,!0)},i=Bu(e.children[1]),l=Kb(e.children[e.children.length-1]);i&&l&&(a.position={start:i,end:l}),r.push(a)}const s={type:"element",tagName:"table",properties:{},children:t.wrap(r,!0)};return t.patch(e,s),t.applyData(e,s)},tableCell:function(t,e){const n={type:"element",tagName:"td",properties:{},children:t.all(e)};return t.patch(e,n),t.applyData(e,n)},tableRow:function(t,e,n){const o=n?n.children:void 0,r=(o?o.indexOf(e):1)===0?"th":"td",s=n&&n.type==="table"?n.align:void 0,a=s?s.length:e.children.length;let i=-1;const l=[];for(;++i<a;){const u=e.children[i],h={},f=s?s[i]:void 0;f&&(h.align=f);let m={type:"element",tagName:r,properties:h,children:[]};u&&(m.children=t.all(u),t.patch(u,m),m=t.applyData(u,m)),l.push(m)}const d={type:"element",tagName:"tr",properties:{},children:t.wrap(l,!0)};return t.patch(e,d),t.applyData(e,d)},text:function(t,e){const n={type:"text",value:VI(String(e.value))};return t.patch(e,n),t.applyData(e,n)},thematicBreak:function(t,e){const n={type:"element",tagName:"hr",properties:{},children:[]};return t.patch(e,n),t.applyData(e,n)},toml:yl,yaml:yl,definition:yl,footnoteDefinition:yl};function yl(){}const Ty=typeof self=="object"?self:globalThis,My=t=>((e,n)=>{const o=(s,a)=>(e.set(a,s),s),r=s=>{if(e.has(s))return e.get(s);const[a,i]=n[s];switch(a){case 0:case-1:return o(i,s);case 1:{const l=o([],s);for(const d of i)l.push(r(d));return l}case 2:{const l=o({},s);for(const[d,u]of i)l[r(d)]=r(u);return l}case 3:return o(new Date(i),s);case 4:{const{source:l,flags:d}=i;return o(new RegExp(l,d),s)}case 5:{const l=o(new Map,s);for(const[d,u]of i)l.set(r(d),r(u));return l}case 6:{const l=o(new Set,s);for(const d of i)l.add(r(d));return l}case 7:{const{name:l,message:d}=i;return o(new Ty[l](d),s)}case 8:return o(BigInt(i),s);case"BigInt":return o(Object(BigInt(i)),s);case"ArrayBuffer":return o(new Uint8Array(i).buffer,i);case"DataView":{const{buffer:l}=new Uint8Array(i);return o(new DataView(l),i)}}return o(new Ty[a](i),s)};return r})(new Map,t)(0),Hr="",{toString:WI}={},{keys:qI}=Object,ua=t=>{const e=typeof t;if(e!=="object"||!t)return[0,e];const n=WI.call(t).slice(8,-1);switch(n){case"Array":return[1,Hr];case"Object":return[2,Hr];case"Date":return[3,Hr];case"RegExp":return[4,Hr];case"Map":return[5,Hr];case"Set":return[6,Hr];case"DataView":return[1,n]}return n.includes("Array")?[1,n]:n.includes("Error")?[7,n]:[2,n]},vl=([t,e])=>t===0&&(e==="function"||e==="symbol"),Oy=(t,{json:e,lossy:n}={})=>{const o=[];return((r,s,a,i)=>{const l=(u,h)=>{const f=i.push(u)-1;return a.set(h,f),f},d=u=>{if(a.has(u))return a.get(u);let[h,f]=ua(u);switch(h){case 0:{let x=u;switch(f){case"bigint":h=8,x=u.toString();break;case"function":case"symbol":if(r)throw new TypeError("unable to serialize "+f);x=null;break;case"undefined":return l([-1],u)}return l([h,x],u)}case 1:{if(f){let p=u;return f==="DataView"?p=new Uint8Array(u.buffer):f==="ArrayBuffer"&&(p=new Uint8Array(u)),l([f,[...p]],u)}const x=[],g=l([h,x],u);for(const p of u)x.push(d(p));return g}case 2:{if(f)switch(f){case"BigInt":return l([f,u.toString()],u);case"Boolean":case"Number":case"String":return l([f,u.valueOf()],u)}if(s&&"toJSON"in u)return d(u.toJSON());const x=[],g=l([h,x],u);for(const p of qI(u))!r&&vl(ua(u[p]))||x.push([d(p),d(u[p])]);return g}case 3:return l([h,u.toISOString()],u);case 4:{const{source:x,flags:g}=u;return l([h,{source:x,flags:g}],u)}case 5:{const x=[],g=l([h,x],u);for(const[p,b]of u)(r||!vl(ua(p))&&!vl(ua(b)))&&x.push([d(p),d(b)]);return g}case 6:{const x=[],g=l([h,x],u);for(const p of u)!r&&vl(ua(p))||x.push(d(p));return g}}const{message:m}=u;return l([h,{name:f,message:m}],u)};return d})(!(e||n),!!e,new Map,o)(t),o},wl=typeof structuredClone=="function"?(t,e)=>e&&("json"in e||"lossy"in e)?My(Oy(t,e)):structuredClone(t):(t,e)=>My(Oy(t,e));function GI(t,e){const n=[{type:"text",value:"\u21A9"}];return e>1&&n.push({type:"element",tagName:"sup",properties:{},children:[{type:"text",value:String(e)}]}),n}function YI(t,e){return"Back to reference "+(t+1)+(e>1?"-"+e:"")}const Dy=function(t){if(t==null)return KI;if(typeof t=="function")return kl(t);if(typeof t=="object")return Array.isArray(t)?function(e){const n=[];let o=-1;for(;++o<e.length;)n[o]=Dy(e[o]);return kl(r);function r(...s){let a=-1;for(;++a<n.length;)if(n[a].apply(this,s))return!0;return!1}}(t):function(e){const n=e;return kl(o);function o(r){const s=r;let a;for(a in e)if(s[a]!==n[a])return!1;return!0}}(t);if(typeof t=="string")return function(e){return kl(n);function n(o){return o&&o.type===e}}(t);throw new Error("Expected function, string, or object as test")};function kl(t){return function(e,n,o){return!!(function(r){return r!==null&&typeof r=="object"&&"type"in r}(e)&&t.call(this,e,typeof n=="number"?n:void 0,o||void 0))}}function KI(){return!0}const Py=[],XI=!0,Ry=!1;function JI(t,e,n,o){let r;typeof e=="function"&&typeof n!="function"?(o=n,n=e):r=e;const s=Dy(r),a=o?-1:1;(function i(l,d,u){const h=l&&typeof l=="object"?l:{};if(typeof h.type=="string"){const m=typeof h.tagName=="string"?h.tagName:typeof h.name=="string"?h.name:void 0;Object.defineProperty(f,"name",{value:"node ("+l.type+(m?"<"+m+">":"")+")"})}return f;function f(){let m,x,g,p=Py;if((!e||s(l,d,u[u.length-1]||void 0))&&(p=function(b){return Array.isArray(b)?b:typeof b=="number"?[XI,b]:b==null?Py:[b]}(n(l,u)),p[0]===Ry))return p;if("children"in l&&l.children){const b=l;if(b.children&&p[0]!=="skip")for(x=(o?b.children.length:-1)+a,g=u.concat(b);x>-1&&x<b.children.length;){const y=b.children[x];if(m=i(y,x,g)(),m[0]===Ry)return m;x=typeof m[1]=="number"?m[1]:x+a}}return p}})(t,void 0,[])()}function Ly(t,e,n,o){let r,s,a;typeof e=="function"&&typeof n!="function"?(s=void 0,a=e,r=n):(s=e,a=n,r=o),JI(t,s,function(i,l){const d=l[l.length-1],u=d?d.children.indexOf(i):void 0;return a(i,u,d)},r)}const eh={}.hasOwnProperty,ZI={};function QI(t,e){t.position&&(e.position=function(n){const o=Bu(n),r=Kb(n);if(o&&r)return{start:o,end:r}}(t))}function e8(t,e){let n=e;if(t&&t.data){const o=t.data.hName,r=t.data.hChildren,s=t.data.hProperties;typeof o=="string"&&(n.type==="element"?n.tagName=o:n={type:"element",tagName:o,properties:{},children:"children"in n?n.children:[n]}),n.type==="element"&&s&&Object.assign(n.properties,wl(s)),"children"in n&&n.children&&r!=null&&(n.children=r)}return n}function t8(t,e){const n=e.data||{},o=!("value"in e)||eh.call(n,"hProperties")||eh.call(n,"hChildren")?{type:"element",tagName:"div",properties:{},children:t.all(e)}:{type:"text",value:e.value};return t.patch(e,o),t.applyData(e,o)}function n8(t,e){const n=[];let o=-1;for(e&&n.push({type:"text",value:`
135
- `});++o<t.length;)o&&n.push({type:"text",value:`
136
- `}),n.push(t[o]);return e&&t.length>0&&n.push({type:"text",value:`
137
- `}),n}function Fy(t){let e=0,n=t.charCodeAt(e);for(;n===9||n===32;)e++,n=t.charCodeAt(e);return t.slice(e)}function zy(t,e){const n=function(a,i){const l=i||ZI,d=new Map,u=new Map,h=new Map,f={...HI,...l.handlers},m={all:function(x){const g=[];if("children"in x){const p=x.children;let b=-1;for(;++b<p.length;){const y=m.one(p[b],x);if(y){if(b&&p[b-1].type==="break"&&(Array.isArray(y)||y.type!=="text"||(y.value=Fy(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=Fy(v.value))}Array.isArray(y)?g.push(...y):g.push(y)}}}return g},applyData:e8,definitionById:d,footnoteById:u,footnoteCounts:h,footnoteOrder:[],handlers:f,one:function(x,g){const p=x.type,b=m.handlers[p];if(eh.call(m.handlers,p)&&b)return b(m,x,g);if(m.options.passThrough&&m.options.passThrough.includes(p)){if("children"in x){const{children:y,...v}=x,w=wl(v);return w.children=m.all(x),w}return wl(x)}return(m.options.unknownHandler||t8)(m,x,g)},options:l,patch:QI,wrap:n8};return Ly(a,function(x){if(x.type==="definition"||x.type==="footnoteDefinition"){const g=x.type==="definition"?d:u,p=String(x.identifier).toUpperCase();g.has(p)||g.set(p,x)}}),m}(t,e),o=n.one(t,void 0),r=function(a){const i=typeof a.options.clobberPrefix=="string"?a.options.clobberPrefix:"user-content-",l=a.options.footnoteBackContent||GI,d=a.options.footnoteBackLabel||YI,u=a.options.footnoteLabel||"Footnotes",h=a.options.footnoteLabelTagName||"h2",f=a.options.footnoteLabelProperties||{className:["sr-only"]},m=[];let x=-1;for(;++x<a.footnoteOrder.length;){const g=a.footnoteById.get(a.footnoteOrder[x]);if(!g)continue;const p=a.all(g),b=String(g.identifier).toUpperCase(),y=Vr(b.toLowerCase());let v=0;const w=[],S=a.footnoteCounts.get(b);for(;S!==void 0&&++v<=S;){w.length>0&&w.push({type:"text",value:" "});let C=typeof l=="string"?l:l(x,v);typeof C=="string"&&(C={type:"text",value:C}),w.push({type:"element",tagName:"a",properties:{href:"#"+i+"fnref-"+y+(v>1?"-"+v:""),dataFootnoteBackref:"",ariaLabel:typeof d=="string"?d:d(x,v),className:["data-footnote-backref"]},children:Array.isArray(C)?C:[C]})}const N=p[p.length-1];if(N&&N.type==="element"&&N.tagName==="p"){const C=N.children[N.children.length-1];C&&C.type==="text"?C.value+=" ":N.children.push({type:"text",value:" "}),N.children.push(...w)}else p.push(...w);const j={type:"element",tagName:"li",properties:{id:i+"fn-"+y},children:a.wrap(p,!0)};a.patch(g,j),m.push(j)}if(m.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:h,properties:{...wl(f),id:"footnote-label"},children:[{type:"text",value:u}]},{type:"text",value:`
138
- `},{type:"element",tagName:"ol",properties:{},children:a.wrap(m,!0)},{type:"text",value:`
139
- `}]}}(n),s=Array.isArray(o)?{type:"root",children:o}:o||{type:"root",children:[]};return r&&s.children.push({type:"text",value:`
140
- `},r),s}function o8(t,e){return t&&"run"in t?async function(n,o){const r=zy(n,{file:o,...e});await t.run(r,o)}:function(n,o){return zy(n,{file:o,...t||e})}}function By(t){if(t)throw t}var th,Uy,r8=function(){if(Uy)return th;Uy=1;var t=Object.prototype.hasOwnProperty,e=Object.prototype.toString,n=Object.defineProperty,o=Object.getOwnPropertyDescriptor,r=function(l){return typeof Array.isArray=="function"?Array.isArray(l):e.call(l)==="[object Array]"},s=function(l){if(!l||e.call(l)!=="[object Object]")return!1;var d,u=t.call(l,"constructor"),h=l.constructor&&l.constructor.prototype&&t.call(l.constructor.prototype,"isPrototypeOf");if(l.constructor&&!u&&!h)return!1;for(d in l);return d===void 0||t.call(l,d)},a=function(l,d){n&&d.name==="__proto__"?n(l,d.name,{enumerable:!0,configurable:!0,value:d.newValue,writable:!0}):l[d.name]=d.newValue},i=function(l,d){if(d==="__proto__"){if(!t.call(l,d))return;if(o)return o(l,d).value}return l[d]};return th=function l(){var d,u,h,f,m,x,g=arguments[0],p=1,b=arguments.length,y=!1;for(typeof g=="boolean"&&(y=g,g=arguments[1]||{},p=2),(g==null||typeof g!="object"&&typeof g!="function")&&(g={});p<b;++p)if((d=arguments[p])!=null)for(u in d)h=i(g,u),g!==(f=i(d,u))&&(y&&f&&(s(f)||(m=r(f)))?(m?(m=!1,x=h&&r(h)?h:[]):x=h&&s(h)?h:{},a(g,{name:u,newValue:l(y,x,f)})):f!==void 0&&a(g,{name:u,newValue:f}));return g},th}();const nh=B3(r8);function oh(t){if(typeof t!="object"||t===null)return!1;const e=Object.getPrototypeOf(t);return!(e!==null&&e!==Object.prototype&&Object.getPrototypeOf(e)!==null||Symbol.toStringTag in t||Symbol.iterator in t)}function s8(){const t=[],e={run:function(...n){let o=-1;const r=n.pop();if(typeof r!="function")throw new TypeError("Expected function as last argument, not "+r);(function s(a,...i){const l=t[++o];let d=-1;if(a)r(a);else{for(;++d<n.length;)i[d]!==null&&i[d]!==void 0||(i[d]=n[d]);n=i,l?function(u,h){let f;return m;function m(...p){const b=u.length>p.length;let y;b&&p.push(x);try{y=u.apply(this,p)}catch(v){if(b&&f)throw v;return x(v)}b||(y&&y.then&&typeof y.then=="function"?y.then(g,x):y instanceof Error?x(y):g(y))}function x(p,...b){f||(f=!0,h(p,...b))}function g(p){x(null,p)}}(l,s)(...i):r(null,...i)}})(null,...n)},use:function(n){if(typeof n!="function")throw new TypeError("Expected `middelware` to be a function, not "+n);return t.push(n),e}};return e}const Vn={basename:function(t,e){if(e!==void 0&&typeof e!="string")throw new TypeError('"ext" argument must be a string');ha(t);let n,o=0,r=-1,s=t.length;if(e===void 0||e.length===0||e.length>t.length){for(;s--;)if(t.codePointAt(s)===47){if(n){o=s+1;break}}else r<0&&(n=!0,r=s+1);return r<0?"":t.slice(o,r)}if(e===t)return"";let a=-1,i=e.length-1;for(;s--;)if(t.codePointAt(s)===47){if(n){o=s+1;break}}else a<0&&(n=!0,a=s+1),i>-1&&(t.codePointAt(s)===e.codePointAt(i--)?i<0&&(r=s):(i=-1,r=a));return o===r?r=a:r<0&&(r=t.length),t.slice(o,r)},dirname:function(t){if(ha(t),t.length===0)return".";let e,n=-1,o=t.length;for(;--o;)if(t.codePointAt(o)===47){if(e){n=o;break}}else e||(e=!0);return n<0?t.codePointAt(0)===47?"/":".":n===1&&t.codePointAt(0)===47?"//":t.slice(0,n)},extname:function(t){ha(t);let e,n=t.length,o=-1,r=0,s=-1,a=0;for(;n--;){const i=t.codePointAt(n);if(i!==47)o<0&&(e=!0,o=n+1),i===46?s<0?s=n:a!==1&&(a=1):s>-1&&(a=-1);else if(e){r=n+1;break}}return s<0||o<0||a===0||a===1&&s===o-1&&s===r+1?"":t.slice(s,o)},join:function(...t){let e,n=-1;for(;++n<t.length;)ha(t[n]),t[n]&&(e=e===void 0?t[n]:e+"/"+t[n]);return e===void 0?".":function(o){ha(o);const r=o.codePointAt(0)===47;let s=function(a,i){let l,d,u="",h=0,f=-1,m=0,x=-1;for(;++x<=a.length;){if(x<a.length)l=a.codePointAt(x);else{if(l===47)break;l=47}if(l===47){if(!(f===x-1||m===1))if(f!==x-1&&m===2){if(u.length<2||h!==2||u.codePointAt(u.length-1)!==46||u.codePointAt(u.length-2)!==46){if(u.length>2){if(d=u.lastIndexOf("/"),d!==u.length-1){d<0?(u="",h=0):(u=u.slice(0,d),h=u.length-1-u.lastIndexOf("/")),f=x,m=0;continue}}else if(u.length>0){u="",h=0,f=x,m=0;continue}}i&&(u=u.length>0?u+"/..":"..",h=2)}else u.length>0?u+="/"+a.slice(f+1,x):u=a.slice(f+1,x),h=x-f-1;f=x,m=0}else l===46&&m>-1?m++:m=-1}return u}(o,!r);return s.length!==0||r||(s="."),s.length>0&&o.codePointAt(o.length-1)===47&&(s+="/"),r?"/"+s:s}(e)},sep:"/"};function ha(t){if(typeof t!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}const a8={cwd:function(){return"/"}};function rh(t){return!!(t!==null&&typeof t=="object"&&"href"in t&&t.href&&"protocol"in t&&t.protocol&&t.auth===void 0)}function i8(t){if(typeof t=="string")t=new URL(t);else if(!rh(t)){const e=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+t+"`");throw e.code="ERR_INVALID_ARG_TYPE",e}if(t.protocol!=="file:"){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 r=new TypeError('File URL host must be "localhost" or empty on darwin');throw r.code="ERR_INVALID_FILE_URL_HOST",r}const n=e.pathname;let o=-1;for(;++o<n.length;)if(n.codePointAt(o)===37&&n.codePointAt(o+1)===50){const r=n.codePointAt(o+2);if(r===70||r===102){const s=new TypeError("File URL path must not include encoded / characters");throw s.code="ERR_INVALID_FILE_URL_PATH",s}}return decodeURIComponent(n)}(t)}const sh=["history","path","basename","stem","extname","dirname"];class $y{constructor(e){let n;n=e?rh(e)?{path:e}:typeof e=="string"||function(s){return!!(s&&typeof s=="object"&&"byteLength"in s&&"byteOffset"in s)}(e)?{value:e}:e:{},this.cwd="cwd"in n?"":a8.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let o,r=-1;for(;++r<sh.length;){const s=sh[r];s in n&&n[s]!==void 0&&n[s]!==null&&(this[s]=s==="history"?[...n[s]]:n[s])}for(o in n)sh.includes(o)||(this[o]=n[o])}get basename(){return typeof this.path=="string"?Vn.basename(this.path):void 0}set basename(e){ih(e,"basename"),ah(e,"basename"),this.path=Vn.join(this.dirname||"",e)}get dirname(){return typeof this.path=="string"?Vn.dirname(this.path):void 0}set dirname(e){Vy(this.basename,"dirname"),this.path=Vn.join(e||"",this.basename)}get extname(){return typeof this.path=="string"?Vn.extname(this.path):void 0}set extname(e){if(ah(e,"extname"),Vy(this.dirname,"extname"),e){if(e.codePointAt(0)!==46)throw new Error("`extname` must start with `.`");if(e.includes(".",1))throw new Error("`extname` cannot contain multiple dots")}this.path=Vn.join(this.dirname,this.stem+(e||""))}get path(){return this.history[this.history.length-1]}set path(e){rh(e)&&(e=i8(e)),ih(e,"path"),this.path!==e&&this.history.push(e)}get stem(){return typeof this.path=="string"?Vn.basename(this.path,this.extname):void 0}set stem(e){ih(e,"stem"),ah(e,"stem"),this.path=Vn.join(this.dirname||"",e+(this.extname||""))}fail(e,n,o){const r=this.message(e,n,o);throw r.fatal=!0,r}info(e,n,o){const r=this.message(e,n,o);return r.fatal=void 0,r}message(e,n,o){const r=new Ut(e,n,o);return this.path&&(r.name=this.path+":"+r.name,r.file=this.path),r.fatal=!1,this.messages.push(r),r}toString(e){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(e||void 0).decode(this.value)}}function ah(t,e){if(t&&t.includes(Vn.sep))throw new Error("`"+e+"` cannot be a path: did not expect `"+Vn.sep+"`")}function ih(t,e){if(!t)throw new Error("`"+e+"` cannot be empty")}function Vy(t,e){if(!t)throw new Error("Setting `"+e+"` requires `path` to be set too")}const l8=function(t){const e=this.constructor.prototype,n=e[t],o=function(){return n.apply(o,arguments)};return Object.setPrototypeOf(o,e),o},c8={}.hasOwnProperty;class lh extends l8{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=s8()}copy(){const e=new lh;let n=-1;for(;++n<this.attachers.length;){const o=this.attachers[n];e.use(...o)}return e.data(nh(!0,{},this.namespace)),e}data(e,n){return typeof e=="string"?arguments.length===2?(uh("data",this.frozen),this.namespace[e]=n,this):c8.call(this.namespace,e)&&this.namespace[e]||void 0:e?(uh("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[n,...o]=this.attachers[this.freezeIndex];if(o[0]===!1)continue;o[0]===!0&&(o[0]=void 0);const r=n.call(e,...o);typeof r=="function"&&this.transformers.use(r)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(e){this.freeze();const n=Sl(e),o=this.parser||this.Parser;return ch("parse",o),o(String(n),n)}process(e,n){const o=this;return this.freeze(),ch("process",this.parser||this.Parser),dh("process",this.compiler||this.Compiler),n?r(void 0,n):new Promise(r);function r(s,a){const i=Sl(e),l=o.parse(i);function d(u,h){u||!h?a(u):s?s(h):n(void 0,h)}o.run(l,i,function(u,h,f){if(u||!h||!f)return d(u);const m=h,x=o.stringify(m,f);var g;typeof(g=x)=="string"||function(p){return!!(p&&typeof p=="object"&&"byteLength"in p&&"byteOffset"in p)}(g)?f.value=x:f.result=x,d(u,f)})}}processSync(e){let n,o=!1;return this.freeze(),ch("processSync",this.parser||this.Parser),dh("processSync",this.compiler||this.Compiler),this.process(e,function(r,s){o=!0,By(r),n=s}),Wy("processSync","process",o),n}run(e,n,o){Hy(e),this.freeze();const r=this.transformers;return o||typeof n!="function"||(o=n,n=void 0),o?s(void 0,o):new Promise(s);function s(a,i){const l=Sl(n);r.run(e,l,function(d,u,h){const f=u||e;d?i(d):a?a(f):o(void 0,f,h)})}}runSync(e,n){let o,r=!1;return this.run(e,n,function(s,a){By(s),o=a,r=!0}),Wy("runSync","run",r),o}stringify(e,n){this.freeze();const o=Sl(n),r=this.compiler||this.Compiler;return dh("stringify",r),Hy(e),r(e,o)}use(e,...n){const o=this.attachers,r=this.namespace;if(uh("use",this.frozen),e!=null)if(typeof e=="function")l(e,n);else{if(typeof e!="object")throw new TypeError("Expected usable value, not `"+e+"`");Array.isArray(e)?i(e):a(e)}return this;function s(d){if(typeof d=="function")l(d,[]);else{if(typeof d!="object")throw new TypeError("Expected usable value, not `"+d+"`");if(Array.isArray(d)){const[u,...h]=d;l(u,h)}else a(d)}}function a(d){if(!("plugins"in d)&&!("settings"in d))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(d.plugins),d.settings&&(r.settings=nh(!0,r.settings,d.settings))}function i(d){let u=-1;if(d!=null){if(!Array.isArray(d))throw new TypeError("Expected a list of plugins, not `"+d+"`");for(;++u<d.length;)s(d[u])}}function l(d,u){let h=-1,f=-1;for(;++h<o.length;)if(o[h][0]===d){f=h;break}if(f===-1)o.push([d,...u]);else if(u.length>0){let[m,...x]=u;const g=o[f][1];oh(g)&&oh(m)&&(m=nh(!0,g,m)),o[f]=[d,m,...x]}}}}const d8=new lh().freeze();function ch(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `parser`")}function dh(t,e){if(typeof e!="function")throw new TypeError("Cannot `"+t+"` without `compiler`")}function uh(t,e){if(e)throw new Error("Cannot call `"+t+"` on a frozen processor.\nCreate a new processor first, by calling it: use `processor()` instead of `processor`.")}function Hy(t){if(!oh(t)||typeof t.type!="string")throw new TypeError("Expected node, got `"+t+"`")}function Wy(t,e,n){if(!n)throw new Error("`"+t+"` finished async. Use `"+e+"` instead")}function Sl(t){return function(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}(t)?t:new $y(t)}const qy=[],Gy={allowDangerousHtml:!0},u8=/^(https?|ircs?|mailto|xmpp)$/i,h8=[{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 f8(t){const e=function(o){const r=o.rehypePlugins||qy,s=o.remarkPlugins||qy,a=o.remarkRehypeOptions?{...o.remarkRehypeOptions,...Gy}:Gy;return d8().use($I).use(s).use(o8,a).use(r)}(t),n=function(o){const r=o.children||"",s=new $y;return typeof r=="string"&&(s.value=r),s}(t);return function(o,r){const s=r.allowedElements,a=r.allowElement,i=r.components,l=r.disallowedElements,d=r.skipHtml,u=r.unwrapDisallowed,h=r.urlTransform||m8;for(const m of h8)Object.hasOwn(r,m.from)&&(m.from,m.to&&m.to,m.id,void 0);return r.className&&(o={type:"element",tagName:"div",properties:{className:r.className},children:o.type==="root"?o.children:[o]}),Ly(o,f),U6(o,{Fragment:c.Fragment,components:i,ignoreInvalidStyle:!0,jsx:c.jsx,jsxs:c.jsxs,passKeys:!0,passNode:!0});function f(m,x,g){if(m.type==="raw"&&g&&typeof x=="number")return d?g.children.splice(x,1):g.children[x]={type:"text",value:m.value},x;if(m.type==="element"){let p;for(p in Wu)if(Object.hasOwn(Wu,p)&&Object.hasOwn(m.properties,p)){const b=m.properties[p],y=Wu[p];(y===null||y.includes(m.tagName))&&(m.properties[p]=h(String(b||""),p,m))}}if(m.type==="element"){let p=s?!s.includes(m.tagName):!!l&&l.includes(m.tagName);if(!p&&a&&typeof x=="number"&&(p=!a(m,x,g)),p&&g&&typeof x=="number")return u&&m.children?g.children.splice(x,1,...m.children):g.children.splice(x,1),x}}}(e.runSync(e.parse(n),n),t)}function m8(t){const e=t.indexOf(":"),n=t.indexOf("?"),o=t.indexOf("#"),r=t.indexOf("/");return e===-1||r!==-1&&e>r||n!==-1&&e>n||o!==-1&&e>o||u8.test(t.slice(0,e))?t:""}const p8=[Ve.lineWrapping],g8=new Set(["python","markdown","sql","json","yaml","toml","shell","javascript","typescript","jsx","tsx","css","html"]),x8=t=>{const e=H.c(26),{code:n,language:o}=t,{theme:r}=Xo(),{createNewCell:s}=it(),a=cs(),i=Ie(ql),[l,d]=O.useState(n);let u,h,f;e[0]!==n?(u=()=>{d(n)},h=[n],e[0]=n,e[1]=u,e[2]=h):(u=e[1],h=e[2]),O.useEffect(u,h),e[3]!==i||e[4]!==s||e[5]!==o||e[6]!==a||e[7]!==l?(f=()=>{const C=function(_,A){return _?_==="python"?{language:_,code:A}:_==="sql"?{language:"python",code:wc.fromQuery(A)}:_==="markdown"?{language:"python",code:La.fromMarkdown(A)}:_==="shell"||_==="bash"?{language:"python",code:`import subprocess
141
- subprocess.run("${A}")`}:{language:"python",code:`_${_} = """
142
- ${A}
143
- """`}:{language:"python",code:A}}(o,l);o==="sql"&&qn({autoInstantiate:i,createNewCell:s,fromCellId:a}),s({code:C.code,before:!1,cellId:a??"__end__"})},e[3]=i,e[4]=s,e[5]=o,e[6]=a,e[7]=l,e[8]=f):f=e[8];const m=f;let x;e[9]!==l?(x=async()=>{await nn(l)},e[9]=l,e[10]=x):x=e[10];const g=x,p=r==="dark"?"dark":"light",b=o&&g8.has(o)?o:void 0;let y,v,w,S,N,j;return e[11]!==p||e[12]!==b||e[13]!==l?(y=c.jsx(O.Suspense,{children:c.jsx(Qa,{theme:p,language:b,className:"cm border rounded overflow-hidden",extensions:p8,value:l,onChange:d})}),e[11]=p,e[12]=b,e[13]=l,e[14]=y):y=e[14],e[15]!==g?(v=c.jsx(b8,{size:"xs",variant:"outline",onClick:g,children:"Copy"}),e[15]=g,e[16]=v):v=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(w=c.jsx(kr,{className:"ml-2 h-4 w-4"}),e[17]=w):w=e[17],e[18]!==m?(S=c.jsxs(ke,{size:"xs",variant:"outline",onClick:m,children:["Add to Notebook",w]}),e[18]=m,e[19]=S):S=e[19],e[20]!==S||e[21]!==v?(N=c.jsxs("div",{className:"flex justify-end mt-2 space-x-2",children:[v,S]}),e[20]=S,e[21]=v,e[22]=N):N=e[22],e[23]!==N||e[24]!==y?(j=c.jsxs("div",{className:"relative",children:[y,N]}),e[23]=N,e[24]=y,e[25]=j):j=e[25],j},b8=t=>{const e=H.c(12);let n,o;e[0]!==t?({onClick:n,...o}=t,e[0]=t,e[1]=n,e[2]=o):(n=e[1],o=e[2]);const[r,s]=O.useState(!1);let a,i,l;e[3]!==r?(a=()=>{r&&setTimeout(()=>s(!1),1e3)},i=[r],e[3]=r,e[4]=a,e[5]=i):(a=e[4],i=e[5]),O.useEffect(a,i),e[6]!==n?(l=h=>{n==null||n(h),s(!0)},e[6]=n,e[7]=l):l=e[7];const d=r?"Copied":"Copy";let u;return e[8]!==o||e[9]!==l||e[10]!==d?(u=c.jsx(ke,{...o,onClick:l,children:d}),e[8]=o,e[9]=l,e[10]=d,e[11]=u):u=e[11],u},y8={code:({children:t,className:e})=>{const n=e==null?void 0:e.replace("language-","");return n&&typeof t=="string"?c.jsxs("div",{children:[c.jsx("div",{className:"text-xs text-muted-foreground pl-1",children:n}),c.jsx(x8,{code:t.trim(),language:n})]}):c.jsx("code",{className:e,children:t})}},Yy=O.memo(t=>{const e=H.c(2),{content:n}=t;let o;return e[0]!==n?(o=c.jsx(f8,{components:y8,className:"prose dark:prose-invert max-w-none prose-pre:pl-0",children:n}),e[0]=n,e[1]=o):o=e[1],o},(t,e)=>t.content===e.content);Yy.displayName="MemoizedMarkdownBlock";const hh=O.memo(({content:t})=>{const e=O.useMemo(()=>{return n=t,PP.lexer(n).map(o=>o.raw);var n},[t]);return c.jsx(c.Fragment,{children:e.map((n,o)=>c.jsx(Yy,{content:n},`markdown-block-${o}`))})});hh.displayName="MarkdownRenderer";const v8=t=>{const e=H.c(13),{reasoning:n,index:o,isStreaming:r}=t,s=o===void 0?0:o,a=r!==void 0&&r,i=a?"reasoning":void 0;let l;e[0]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx($l,{className:"h-3 w-3"}),e[0]=l):l=e[0];const d=a?"Thinking":"View reasoning";let u,h,f,m;return e[1]!==n.length||e[2]!==d?(u=c.jsx(U3,{className:"text-xs text-muted-foreground hover:bg-muted/50 px-2 py-1 h-auto rounded-sm [&[data-state=open]>svg]:rotate-180",children:c.jsxs("span",{className:"flex items-center gap-2",children:[l,d," (",n.length," ","chars)"]})}),e[1]=n.length,e[2]=d,e[3]=u):u=e[3],e[4]!==n?(h=c.jsx($3,{className:"pb-2 px-2",children:c.jsx("div",{className:"bg-muted/30 border border-muted/50 rounded-md p-3 italic text-muted-foreground/90 relative",children:c.jsx("div",{className:"pr-6",children:c.jsx(hh,{content:n})})})}),e[4]=n,e[5]=h):h=e[5],e[6]!==u||e[7]!==h?(f=c.jsxs(V3,{value:"reasoning",className:"border-0",children:[u,h]}),e[6]=u,e[7]=h,e[8]=f):f=e[8],e[9]!==s||e[10]!==i||e[11]!==f?(m=c.jsx(H3,{type:"single",collapsible:!0,className:"w-full mb-2",value:i,children:f},s),e[9]=s,e[10]=i,e[11]=f,e[12]=m):m=e[12],m},w8=t=>{const e=H.c(32),{toolName:n,result:o,error:r,index:s,state:a}=t,i=s===void 0?0:s,l=a==="result"&&(o||r),d=r?"error":l?"success":"loading";let u;e[0]!==d?(u=()=>{switch(d){case"loading":return c.jsx(Nc,{className:"h-3 w-3 animate-spin"});case"error":return c.jsx(_a,{className:"h-3 w-3 text-destructive"});case"success":return c.jsx(hL,{className:"h-3 w-3 text-green-600"});default:return c.jsx(RP,{className:"h-3 w-3"})}},e[0]=d,e[1]=u):u=e[1];const h=u;let f;e[2]!==r||e[3]!==l||e[4]!==d?(f=()=>d==="loading"?"Running: ":r?"Failed: ":l?"Done: ":"Tool call",e[2]=r,e[3]=l,e[4]=d,e[5]=f):f=e[5];const m=f,x=`tool-${i}`,g=d==="error"&&"text-destructive/80",p=d==="success"&&"text-green-600/80";let b,y;e[6]!==g||e[7]!==p?(b=ge("h-6 text-xs border-border !shadow-none !ring-0 bg-muted hover:bg-muted/30 py-0 px-2 gap-1 rounded-sm [&[data-state=open]>svg]:rotate-180",g,p),e[6]=g,e[7]=p,e[8]=b):b=e[8],e[9]!==h?(y=h(),e[9]=h,e[10]=y):y=e[10];const v=m();let w,S,N,j,C,_,A;return e[11]!==n?(w=c.jsx("code",{className:"font-mono text-xs",children:n}),e[11]=n,e[12]=w):w=e[12],e[13]!==w||e[14]!==y||e[15]!==v?(S=c.jsxs("span",{className:"flex items-center gap-1",children:[y,v,":"," ",w]}),e[13]=w,e[14]=y,e[15]=v,e[16]=S):S=e[16],e[17]!==S||e[18]!==b?(N=c.jsx(U3,{className:b,children:S}),e[17]=S,e[18]=b,e[19]=N):N=e[19],e[20]!==r||e[21]!==l||e[22]!==o?(j=l&&c.jsxs("div",{className:"space-y-3",children:[o&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-medium text-muted-foreground mt-2 mb-1",children:"Result:"}),c.jsx("div",{className:"text-xs font-medium text-muted-foreground mb-1",children:typeof o=="string"?o:JSON.stringify(o,null,2)})]}),r&&c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-medium text-destructive mb-1",children:"Error:"}),c.jsx("div",{className:"bg-destructive/10 border border-destructive/20 rounded-md p-3 text-sm text-destructive",children:r})]})]}),e[20]=r,e[21]=l,e[22]=o,e[23]=j):j=e[23],e[24]!==j?(C=c.jsx($3,{className:"pb-2 px-2",children:j}),e[24]=j,e[25]=C):C=e[25],e[26]!==N||e[27]!==C?(_=c.jsxs(V3,{value:"tool-call",className:"border-0",children:[N,C]}),e[26]=N,e[27]=C,e[28]=_):_=e[28],e[29]!==_||e[30]!==x?(A=c.jsx(H3,{type:"single",collapsible:!0,className:"w-full my-4",children:_},x),e[29]=_,e[30]=x,e[31]=A):A=e[31],A},k8=t=>{const e=H.c(27),{onNewChat:n,activeChatId:o,setActiveChat:r,chats:s}=t,{handleClick:a}=ti();let i,l,d,u,h,f,m,x,g,p,b;if(e[0]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(Ko,{className:"h-4 w-4"}),e[0]=i):i=e[0],e[1]!==n?(l=c.jsx(Ne,{content:"New chat",children:c.jsx(ke,{variant:"text",size:"icon",onClick:n,children:i})}),e[1]=n,e[2]=l):l=e[2],e[3]!==a?(d=()=>a("ai"),e[3]=a,e[4]=d):d=e[4],e[5]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(em,{className:"h-4 w-4"}),e[5]=u):u=e[5],e[6]!==d?(h=c.jsx(Ne,{content:"AI Settings",children:c.jsx(ke,{variant:"text",size:"xs",className:"hover:bg-foreground/10 py-2",onClick:d,children:u})}),e[6]=d,e[7]=h):h=e[7],e[8]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(Ne,{content:"Previous chats",children:c.jsx(ys,{asChild:!0,children:c.jsx(ke,{variant:"text",size:"icon",children:c.jsx(UP,{className:"h-4 w-4"})})})}),e[8]=f):f=e[8],e[9]!==s.length?(m=s.length===0&&c.jsx(sn,{title:"No chats yet",description:"Start a new chat to get started",icon:c.jsx($l,{})}),e[9]=s.length,e[10]=m):m=e[10],e[11]!==o||e[12]!==s||e[13]!==r){let y;e[15]!==o||e[16]!==r?(y=v=>c.jsxs("button",{className:ge("w-full p-3 rounded-md cursor-pointer hover:bg-accent text-left",v.id===o&&"bg-accent"),onClick:()=>{r(v.id)},type:"button",children:[c.jsx("div",{className:"font-medium",children:v.title}),c.jsx("div",{className:"text-sm text-muted-foreground",children:$P(v.updatedAt)})]},v.id),e[15]=o,e[16]=r,e[17]=y):y=e[17],x=s.map(y),e[11]=o,e[12]=s,e[13]=r,e[14]=x}else x=e[14];return e[18]!==m||e[19]!==x?(g=c.jsxs(gr,{children:[f,c.jsx(hs,{className:"w-[520px] p-0",align:"start",side:"right",children:c.jsx(Ob,{className:"h-[500px] p-4",children:c.jsxs("div",{className:"space-y-4",children:[m,x]})})})]}),e[18]=m,e[19]=x,e[20]=g):g=e[20],e[21]!==h||e[22]!==g?(p=c.jsxs("div",{className:"flex items-center gap-2",children:[h,g]}),e[21]=h,e[22]=g,e[23]=p):p=e[23],e[24]!==p||e[25]!==l?(b=c.jsxs("div",{className:"flex border-b px-2 py-1 justify-between flex-shrink-0 items-center",children:[l,p]}),e[24]=p,e[25]=l,e[26]=b):b=e[26],b},Ky=O.memo(t=>{var f;const e=H.c(15),{message:n,index:o,theme:r,onEdit:s,isStreamingReasoning:a,totalMessages:i}=t,l=n.role==="user"?"justify-end":"justify-start";let d,u,h;return e[0]!==l?(d=ge("flex group relative",l),e[0]=l,e[1]=d):d=e[1],e[2]!==o||e[3]!==a||e[4]!==n.content||e[5]!==n.id||e[6]!==n.parts||e[7]!==n.role||e[8]!==s||e[9]!==r||e[10]!==i?(u=n.role==="user"?c.jsx("div",{className:"w-[95%] bg-background border p-1 rounded-sm",children:c.jsx(Sc,{value:n.content,theme:r,placeholder:"Type your message...",onChange:j8,onSubmit:(m,x)=>{x.trim()&&s(o,x)},onClose:C8},n.id)}):c.jsxs("div",{className:"w-[95%] break-words",children:[c.jsx("div",{className:"absolute right-1 top-1 opacity-0 group-hover:opacity-100 transition-opacity",children:c.jsx(W3,{className:"h-3 w-3",value:n.content})}),(f=n.parts)==null?void 0:f.map((m,x)=>{var g;switch(m.type){case"text":return c.jsx(hh,{content:m.text},x);case"reasoning":return c.jsx(v8,{reasoning:m.reasoning,index:x,isStreaming:o===i-1&&a&&x===(((g=n.parts)==null?void 0:g.length)||0)-1},x);case"tool-invocation":return c.jsx(w8,{index:x,toolName:m.toolInvocation.toolName,result:m.toolInvocation.state==="result"?m.toolInvocation.result:null,state:m.toolInvocation.state},x);default:return null}})]}),e[2]=o,e[3]=a,e[4]=n.content,e[5]=n.id,e[6]=n.parts,e[7]=n.role,e[8]=s,e[9]=r,e[10]=i,e[11]=u):u=e[11],e[12]!==d||e[13]!==u?(h=c.jsx("div",{className:d,children:u}),e[12]=d,e[13]=u,e[14]=h):h=e[14],h});Ky.displayName="ChatMessage";const fh=O.memo(t=>{var R;const e=H.c(32),{input:n,onSendClick:o,isLoading:r,onStop:s}=t,a=Ie(F3),[i,l]=St(Ua),d=(a==null?void 0:a.mode)||"manual",u=((R=a==null?void 0:a.open_ai)==null?void 0:R.model)||"o4-mini";let h;e[0]===Symbol.for("react.memo_cache_sentinel")?(h=[{value:"ask",label:"Ask",subtitle:"Read-only tools"},{value:"manual",label:"Manual",subtitle:"No tools"}],e[0]=h):h=e[0];const f=h;let m,x,g,p,b,y,v,w,S,N,j;if(e[1]!==l||e[2]!==i){m=async L=>{const F={...i,ai:{...i.ai,mode:L}};M(F)},x=async L=>{var D;const F={...i,ai:{...i.ai,open_ai:{...(D=i.ai)==null?void 0:D.open_ai,model:L}}};M(F)};const M=async L=>{await pr({config:L}).then(()=>{l(L)})};e[1]=l,e[2]=i,e[3]=m,e[4]=x}else m=e[3],x=e[4];e[5]===Symbol.for("react.memo_cache_sentinel")?(g=c.jsx(Da,{className:"h-6 text-xs border-border !shadow-none !ring-0 bg-muted hover:bg-muted/30 py-0 px-2 gap-1",children:c.jsx(Pa,{placeholder:"manual"})}),e[5]=g):g=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(Ra,{children:f.map(E8)}),e[6]=p):p=e[6],e[7]!==d||e[8]!==m?(b=c.jsx(LP,{feature:"mcp_docs",children:c.jsxs(Oa,{value:d,onValueChange:m,children:[g,p]})}),e[7]=d,e[8]=m,e[9]=b):b=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(y=c.jsx(Da,{className:"h-6 text-xs border-border !shadow-none !ring-0 bg-muted hover:bg-muted/30 py-0 px-2 gap-1",children:c.jsx(Pa,{placeholder:"Model"})}),e[10]=y):y=e[10],e[11]!==u?(v=!yS.includes(u)&&c.jsx(ls,{value:u,className:"text-sm",children:u},u),e[11]=u,e[12]=v):v=e[12],e[13]===Symbol.for("react.memo_cache_sentinel")?(w=yS.map(_8),e[13]=w):w=e[13],e[14]!==v?(S=c.jsxs(Ra,{children:[v,w]}),e[14]=v,e[15]=S):S=e[15],e[16]!==u||e[17]!==x||e[18]!==S?(N=c.jsxs(Oa,{value:u,onValueChange:x,children:[y,S]}),e[16]=u,e[17]=x,e[18]=S,e[19]=N):N=e[19],e[20]!==b||e[21]!==N?(j=c.jsxs("div",{className:"flex items-center gap-2",children:[b,N]}),e[20]=b,e[21]=N,e[22]=j):j=e[22];const C=r?s:o,_=!r&&!n.trim();let A,I,P;return e[23]!==r?(A=r?c.jsx(tc,{className:"h-3 w-3 fill-current"}):c.jsx(FP,{className:"h-3 w-3"}),e[23]=r,e[24]=A):A=e[24],e[25]!==C||e[26]!==_||e[27]!==A?(I=c.jsx(ke,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 hover:bg-muted/30",onClick:C,disabled:_,children:A}),e[25]=C,e[26]=_,e[27]=A,e[28]=I):I=e[28],e[29]!==j||e[30]!==I?(P=c.jsxs("div",{className:"px-3 py-2 border-t border-border/20 flex items-center justify-between",children:[j,I]}),e[29]=j,e[30]=I,e[31]=P):P=e[31],P});fh.displayName="ChatInputFooter";const Xy=O.memo(t=>{var g,p;const e=H.c(19),{input:n,setInput:o,onSubmit:r,theme:s,inputRef:a,isLoading:i,onStop:l}=t;let d;e[0]!==n||e[1]!==r?(d=()=>{n.trim()&&r(void 0,n)},e[0]=n,e[1]=r,e[2]=d):d=e[2];const u=d;let h,f,m,x;return e[3]!==((g=a.current)==null?void 0:g.editor)?(h=()=>{var b,y;return(y=(b=a.current)==null?void 0:b.editor)==null?void 0:y.blur()},e[3]=(p=a.current)==null?void 0:p.editor,e[4]=h):h=e[4],e[5]!==n||e[6]!==r||e[7]!==o||e[8]!==h||e[9]!==s?(f=c.jsx("div",{className:"px-2 py-3 flex-1",children:c.jsx(Sc,{value:n,onChange:o,onSubmit:r,onClose:h,theme:s,placeholder:"Type your message..."})}),e[5]=n,e[6]=r,e[7]=o,e[8]=h,e[9]=s,e[10]=f):f=e[10],e[11]!==u||e[12]!==n||e[13]!==i||e[14]!==l?(m=c.jsx(fh,{input:n,onSendClick:u,isLoading:i,onStop:l}),e[11]=u,e[12]=n,e[13]=i,e[14]=l,e[15]=m):m=e[15],e[16]!==f||e[17]!==m?(x=c.jsxs("div",{className:"border-t relative flex-shrink-0 min-h-[80px] flex flex-col",children:[f,m]}),e[16]=f,e[17]=m,e[18]=x):x=e[18],x});Xy.displayName="ChatInput";const S8=()=>{const t=H.c(6),e=Ie(Wl),{handleClick:n}=ti();if(!e){let r,s,a;return t[0]!==n?(r=c.jsx(ke,{variant:"outline",size:"sm",onClick:()=>n("ai"),children:"Edit AI settings"}),t[0]=n,t[1]=r):r=t[1],t[2]===Symbol.for("react.memo_cache_sentinel")?(s=c.jsx($l,{}),t[2]=s):s=t[2],t[3]!==r?(a=c.jsx(sn,{title:"Chat with AI",description:"AI is currently disabled. Add your API key to enable.",action:r,icon:s}),t[3]=r,t[4]=a):a=t[4],a}let o;return t[5]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(N8,{}),t[5]=o):o=t[5],o},N8=()=>{const[t,e]=St(td),[n,o]=St(YS),[r,s]=O.useState(""),a=O.useRef(null),i=O.useRef(null),l=O.useRef(null),d=O.useRef(null),{theme:u}=Xo(),h=wm(),{messages:f,input:m,setInput:x,setMessages:g,append:p,handleSubmit:b,error:y,status:v,reload:w,stop:S}=zP({id:n==null?void 0:n.id,maxSteps:10,initialMessages:(n==null?void 0:n.messages)||[],keepLastMessageOnError:!0,api:h.getAiURL("chat").toString(),headers:h.headers(),experimental_prepareRequestBody:A=>({...A,...y3({input:A.messages.map(I=>I.content).join(`
144
- `)}),includeOtherCode:xc("")}),onFinish:A=>{e(I=>Ou(I,I.activeChatId,A.id,"assistant",A.content,A.parts))},onToolCall:async({toolCall:A})=>{try{const I=await BP({toolName:A.toolName,arguments:A.args});return I.result||I.error}catch(I){return ht.error("Tool call failed:",I),`Error: ${I instanceof Error?I.message:String(I)}`}},onError:A=>{ht.error("An error occurred:",A)},onResponse:A=>{ht.debug("Received HTTP response from server:",A)}}),N=v==="submitted"||v==="streaming";O.useEffect(()=>{if(!t.activeChatId||f.length===0)return;const A=f[f.length-1];if((A==null?void 0:A.role)!=="user")return;const I=t.chats.find(M=>M.id===t.activeChatId);if(!I)return;const P=new Set(I.messages.map(M=>M.id)),R=f.filter(M=>M.role==="user"&&!P.has(M.id));R.length>0&&e(M=>{let L=M;for(const F of R)L=Ou(L,M.activeChatId,F.id,"user",F.content);return L})},[f,t.activeChatId,t.chats,e]);const j=N&&f.length>0&&(A=>{if(A.length===0)return!1;const I=A.at(-1);if(!I||I.role!=="assistant"||!I.parts)return!1;const P=I.parts;return P.length===0?!1:P[P.length-1].type==="reasoning"})(f);O.useEffect(()=>{requestAnimationFrame(()=>{if(l.current){const A=l.current;A.scrollTop=A.scrollHeight}})},[t.activeChatId]);const C=(A,I)=>{g(P=>P.slice(0,A)),t.activeChatId&&e(P=>({...P,chats:P.chats.map(R=>R.id===t.activeChatId?{...R,messages:R.messages.slice(0,A),updatedAt:Date.now()}:R)})),p({role:"user",content:I})},_=()=>{r.trim()&&(A=>{const I=Date.now(),P={id:q3(),title:A.length>50?`${A.slice(0,50)}...`:A,messages:[],createdAt:I,updatedAt:I};e(M=>({...M,chats:[...M.chats,P],activeChatId:P.id}));const R=q3();p({id:R,role:"user",content:A}),x("")})(r.trim())};return c.jsxs("div",{className:"flex flex-col h-[calc(100%-53px)]",children:[c.jsx(km,{children:c.jsx(k8,{onNewChat:()=>{o(null),x(""),s("")},activeChatId:n==null?void 0:n.id,setActiveChat:o,chats:[...t.chats].sort((A,I)=>I.updatedAt-A.updatedAt)})}),c.jsxs("div",{className:"flex-1 px-3 bg-[var(--slate-1)] gap-4 py-3 flex flex-col overflow-y-auto",ref:l,children:[(!f||f.length===0)&&c.jsxs("div",{className:"flex flex-col rounded-md border bg-background",children:[c.jsx("div",{className:"px-1",children:c.jsx(Sc,{value:r,placeholder:"Ask anything, @ to include context about tables or dataframes",theme:u,onClose:()=>{var A,I;return(I=(A=a.current)==null?void 0:A.editor)==null?void 0:I.blur()},onChange:s,onSubmit:_},"new-thread-input")}),c.jsx(fh,{input:r,onSendClick:_,isLoading:N,onStop:S})]}),f.map((A,I)=>c.jsx(Ky,{message:A,index:I,theme:u,onEdit:C,setChatState:e,chatState:t,isStreamingReasoning:j,totalMessages:f.length},I)),N&&c.jsx("div",{className:"flex justify-center py-4",children:c.jsx(Nc,{className:"h-4 w-4 animate-spin"})}),y&&c.jsxs("div",{className:"flex items-center justify-center space-x-2 mb-4",children:[c.jsx(br,{error:y}),c.jsx(ke,{variant:"outline",size:"sm",onClick:()=>{w()},children:"Retry"})]}),c.jsx("div",{ref:d})]}),N&&c.jsx("div",{className:"w-full flex justify-center items-center z-20 border-t",children:c.jsx(ke,{variant:"linkDestructive",size:"sm",onClick:S,children:"Stop"})}),f&&f.length>0&&c.jsx(Xy,{input:m,setInput:x,onSubmit:(A,I)=>{I.trim()&&b(A)},theme:u,inputRef:i,isLoading:N,onStop:S})]})};function j8(){}function C8(){}function E8(t){return c.jsx(ls,{value:t.value,className:"text-xs",subtitle:c.jsx("div",{className:"text-muted-foreground text-xs pl-2",children:t.subtitle}),children:t.label},t.value)}function _8(t){return c.jsx(ls,{value:t,className:"text-sm",children:t},t)}function Kt(t){if(typeof t=="string"||typeof t=="number")return""+t;let e="";if(Array.isArray(t))for(let n,o=0;o<t.length;o++)(n=Kt(t[o]))!==""&&(e+=(e&&" ")+n);else for(let n in t)t[n]&&(e+=(e&&" ")+n);return e}const{useDebugValue:I8}=G,{useSyncExternalStoreWithSelector:A8}=VP,T8=t=>t;function Jy(t,e=T8,n){const o=A8(t.subscribe,t.getState,t.getServerState||t.getInitialState,e,n);return I8(o),o}const Zy=(t,e)=>{const n=HP(t),o=(r,s=e)=>Jy(n,r,s);return Object.assign(o,n),o};function $t(t,e){if(Object.is(t,e))return!0;if(typeof t!="object"||t===null||typeof e!="object"||e===null)return!1;if(t instanceof Map&&e instanceof Map){if(t.size!==e.size)return!1;for(const[o,r]of t)if(!Object.is(r,e.get(o)))return!1;return!0}if(t instanceof Set&&e instanceof Set){if(t.size!==e.size)return!1;for(const o of t)if(!e.has(o))return!1;return!0}const n=Object.keys(t);if(n.length!==Object.keys(e).length)return!1;for(const o of n)if(!Object.prototype.hasOwnProperty.call(e,o)||!Object.is(t[o],e[o]))return!1;return!0}function Hn(t,e){if(t=function(s){let a;for(;a=s.sourceEvent;)s=a;return s}(t),e===void 0&&(e=t.currentTarget),e){var n=e.ownerSVGElement||e;if(n.createSVGPoint){var o=n.createSVGPoint();return o.x=t.clientX,o.y=t.clientY,[(o=o.matrixTransform(e.getScreenCTM().inverse())).x,o.y]}if(e.getBoundingClientRect){var r=e.getBoundingClientRect();return[t.clientX-r.left-e.clientLeft,t.clientY-r.top-e.clientTop]}}return[t.pageX,t.pageY]}const M8={passive:!1},fa={capture:!0,passive:!1};function mh(t){t.stopImmediatePropagation()}function Wr(t){t.preventDefault(),t.stopImmediatePropagation()}function Qy(t){var e=t.document.documentElement,n=Ln(t).on("dragstart.drag",Wr,fa);"onselectstart"in e?n.on("selectstart.drag",Wr,fa):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function ev(t,e){var n=t.document.documentElement,o=Ln(t).on("dragstart.drag",null);e&&(o.on("click.drag",Wr,fa),setTimeout(function(){o.on("click.drag",null)},0)),"onselectstart"in n?o.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Nl=t=>()=>t;function ph(t,{sourceEvent:e,subject:n,target:o,identifier:r,active:s,x:a,y:i,dx:l,dy:d,dispatch:u}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:o,enumerable:!0,configurable:!0},identifier:{value:r,enumerable:!0,configurable:!0},active:{value:s,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:i,enumerable:!0,configurable:!0},dx:{value:l,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:u}})}function O8(t){return!t.ctrlKey&&!t.button}function D8(){return this.parentNode}function P8(t,e){return e??{x:t.x,y:t.y}}function R8(){return navigator.maxTouchPoints||"ontouchstart"in this}ph.prototype.on=function(){var t=this._.on.apply(this._,arguments);return t===this._?this:t};const jl=t=>()=>t;function L8(t,{sourceEvent:e,target:n,transform:o,dispatch:r}){Object.defineProperties(this,{type:{value:t,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:o,enumerable:!0,configurable:!0},_:{value:r}})}function gh(t){t.stopImmediatePropagation()}function ma(t){t.preventDefault(),t.stopImmediatePropagation()}function F8(t){return!(t.ctrlKey&&t.type!=="wheel"||t.button)}function z8(){var t=this;return t instanceof SVGElement?(t=t.ownerSVGElement||t).hasAttribute("viewBox")?[[(t=t.viewBox.baseVal).x,t.y],[t.x+t.width,t.y+t.height]]:[[0,0],[t.width.baseVal.value,t.height.baseVal.value]]:[[0,0],[t.clientWidth,t.clientHeight]]}function tv(){return this.__zoom||Zo}function B8(t){return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*(t.ctrlKey?10:1)}function U8(){return navigator.maxTouchPoints||"ontouchstart"in this}function $8(t,e,n){var o=t.invertX(e[0][0])-n[0][0],r=t.invertX(e[1][0])-n[1][0],s=t.invertY(e[0][1])-n[0][1],a=t.invertY(e[1][1])-n[1][1];return t.translate(r>o?(o+r)/2:Math.min(0,o)||Math.max(0,r),a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a))}const Cl=O.createContext(null),V8=Cl.Provider,H8=t=>`Node type "${t}" not found. Using fallback type "default".`,W8=()=>"The React Flow parent container needs a width and a height to render the graph.",q8=()=>"Only child nodes can use a parent extent.",G8=t=>`Marker type "${t}" doesn't exist.`,Y8=(t,e)=>`Couldn't create edge for ${t?"target":"source"} handle id: "${t?e.targetHandle:e.sourceHandle}", edge id: ${e.id}.`,K8=()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",X8=t=>`Edge type "${t}" not found. Using fallback type "default".`,J8=t=>`Node with id "${t}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`,nv="[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001";function at(t,e){const n=O.useContext(Cl);if(n===null)throw new Error(nv);return Jy(n,t,e)}const Lt=()=>{const t=O.useContext(Cl);if(t===null)throw new Error(nv);return O.useMemo(()=>({getState:t.getState,setState:t.setState,subscribe:t.subscribe,destroy:t.destroy}),[t])},Z8=t=>t.userSelectionActive?"none":"all";function El({position:t,children:e,className:n,style:o,...r}){const s=at(Z8),a=`${t}`.split("-");return G.createElement("div",{className:Kt(["react-flow__panel",n,...a]),style:{...o,pointerEvents:s},...r},e)}function Q8({proOptions:t,position:e="bottom-right"}){return t!=null&&t.hideAttribution?null:G.createElement(El,{position:e,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},G.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}var eA=O.memo(({x:t,y:e,label:n,labelStyle:o={},labelShowBg:r=!0,labelBgStyle:s={},labelBgPadding:a=[2,4],labelBgBorderRadius:i=2,children:l,className:d,...u})=>{const h=O.useRef(null),[f,m]=O.useState({x:0,y:0,width:0,height:0}),x=Kt(["react-flow__edge-textwrapper",d]);return O.useEffect(()=>{if(h.current){const g=h.current.getBBox();m({x:g.x,y:g.y,width:g.width,height:g.height})}},[n]),n!==void 0&&n?G.createElement("g",{transform:`translate(${t-f.width/2} ${e-f.height/2})`,className:x,visibility:f.width?"visible":"hidden",...u},r&&G.createElement("rect",{width:f.width+2*a[0],x:-a[0],y:-a[1],height:f.height+2*a[1],className:"react-flow__edge-textbg",style:s,rx:i,ry:i}),G.createElement("text",{className:"react-flow__edge-text",y:f.height/2,dy:"0.3em",ref:h,style:o},n),l):null});const xh=t=>({width:t.offsetWidth,height:t.offsetHeight}),qr=(t,e=0,n=1)=>Math.min(Math.max(t,e),n),bh=(t={x:0,y:0},e)=>({x:qr(t.x,e[0][0],e[1][0]),y:qr(t.y,e[0][1],e[1][1])}),ov=(t,e,n)=>t<e?qr(Math.abs(t-e),1,50)/50:t>n?-qr(Math.abs(t-n),1,50)/50:0,rv=(t,e)=>[20*ov(t.x,35,e.width-35),20*ov(t.y,35,e.height-35)],sv=t=>{var e;return((e=t.getRootNode)==null?void 0:e.call(t))||(window==null?void 0:window.document)},yh=({x:t,y:e,width:n,height:o})=>({x:t,y:e,x2:t+n,y2:e+o}),av=t=>({...t.positionAbsolute||{x:0,y:0},width:t.width||0,height:t.height||0}),vh=(t,e)=>{const n=Math.max(0,Math.min(t.x+t.width,e.x+e.width)-Math.max(t.x,e.x)),o=Math.max(0,Math.min(t.y+t.height,e.y+e.height)-Math.max(t.y,e.y));return Math.ceil(n*o)},kn=t=>!isNaN(t)&&isFinite(t),bt=Symbol.for("internals"),iv=["Enter"," ","Escape"];function wh(t){var o,r;const e=(s=>"nativeEvent"in s)(t)?t.nativeEvent:t,n=((r=(o=e.composedPath)==null?void 0:o.call(e))==null?void 0:r[0])||t.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const lv=t=>"clientX"in t,Ro=(t,e)=>{var s,a;const n=lv(t),o=n?t.clientX:(s=t.touches)==null?void 0:s[0].clientX,r=n?t.clientY:(a=t.touches)==null?void 0:a[0].clientY;return{x:o-((e==null?void 0:e.left)??0),y:r-((e==null?void 0:e.top)??0)}},_l=()=>{var t;return typeof navigator<"u"&&((t=navigator==null?void 0:navigator.userAgent)==null?void 0:t.indexOf("Mac"))>=0},pa=({id:t,path:e,labelX:n,labelY:o,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d,style:u,markerEnd:h,markerStart:f,interactionWidth:m=20})=>G.createElement(G.Fragment,null,G.createElement("path",{id:t,style:u,d:e,fill:"none",className:"react-flow__edge-path",markerEnd:h,markerStart:f}),m&&G.createElement("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:m,className:"react-flow__edge-interaction"}),r&&kn(n)&&kn(o)?G.createElement(eA,{x:n,y:o,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d}):null);function ga(t,e,n){return n===void 0?n:o=>{const r=e().edges.find(s=>s.id===t);r&&n(o,{...r})}}function cv({sourceX:t,sourceY:e,targetX:n,targetY:o}){const r=Math.abs(n-t)/2,s=n<t?n+r:n-r,a=Math.abs(o-e)/2;return[s,o<e?o+a:o-a,r,a]}function dv({sourceX:t,sourceY:e,targetX:n,targetY:o,sourceControlX:r,sourceControlY:s,targetControlX:a,targetControlY:i}){const l=.125*t+.375*r+.375*a+.125*n,d=.125*e+.375*s+.375*i+.125*o;return[l,d,Math.abs(l-t),Math.abs(d-e)]}var cr,uv,Lo,kh,xa,hv,Fo,ba,Gr,fv,De,Il;function mv({pos:t,x1:e,y1:n,x2:o,y2:r}){return t===De.Left||t===De.Right?[.5*(e+o),n]:[e,.5*(n+r)]}function pv({sourceX:t,sourceY:e,sourcePosition:n=De.Bottom,targetX:o,targetY:r,targetPosition:s=De.Top}){const[a,i]=mv({pos:n,x1:t,y1:e,x2:o,y2:r}),[l,d]=mv({pos:s,x1:o,y1:r,x2:t,y2:e}),[u,h,f,m]=dv({sourceX:t,sourceY:e,targetX:o,targetY:r,sourceControlX:a,sourceControlY:i,targetControlX:l,targetControlY:d});return[`M${t},${e} C${a},${i} ${l},${d} ${o},${r}`,u,h,f,m]}pa.displayName="BaseEdge",(uv=cr||(cr={})).Strict="strict",uv.Loose="loose",(kh=Lo||(Lo={})).Free="free",kh.Vertical="vertical",kh.Horizontal="horizontal",(hv=xa||(xa={})).Partial="partial",hv.Full="full",(ba=Fo||(Fo={})).Bezier="default",ba.Straight="straight",ba.Step="step",ba.SmoothStep="smoothstep",ba.SimpleBezier="simplebezier",(fv=Gr||(Gr={})).Arrow="arrow",fv.ArrowClosed="arrowclosed",(Il=De||(De={})).Left="left",Il.Top="top",Il.Right="right",Il.Bottom="bottom";const Sh=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,sourcePosition:r=De.Bottom,targetPosition:s=De.Top,label:a,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:x,interactionWidth:g})=>{const[p,b,y]=pv({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:o,targetPosition:s});return G.createElement(pa,{path:p,labelX:b,labelY:y,label:a,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:x,interactionWidth:g})});Sh.displayName="SimpleBezierEdge";const gv={[De.Left]:{x:-1,y:0},[De.Right]:{x:1,y:0},[De.Top]:{x:0,y:-1},[De.Bottom]:{x:0,y:1}},xv=(t,e)=>Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2));function tA({source:t,sourcePosition:e=De.Bottom,target:n,targetPosition:o=De.Top,center:r,offset:s}){const a=gv[e],i=gv[o],l={x:t.x+a.x*s,y:t.y+a.y*s},d={x:n.x+i.x*s,y:n.y+i.y*s},u=(({source:N,sourcePosition:j=De.Bottom,target:C})=>j===De.Left||j===De.Right?N.x<C.x?{x:1,y:0}:{x:-1,y:0}:N.y<C.y?{x:0,y:1}:{x:0,y:-1})({source:l,sourcePosition:e,target:d}),h=u.x!==0?"x":"y",f=u[h];let m,x,g=[];const p={x:0,y:0},b={x:0,y:0},[y,v,w,S]=cv({sourceX:t.x,sourceY:t.y,targetX:n.x,targetY:n.y});if(a[h]*i[h]===-1){m=r.x??y,x=r.y??v;const N=[{x:m,y:l.y},{x:m,y:d.y}],j=[{x:l.x,y:x},{x:d.x,y:x}];g=a[h]===f?h==="x"?N:j:h==="x"?j:N}else{const N=[{x:l.x,y:d.y}],j=[{x:d.x,y:l.y}];if(g=h==="x"?a.x===f?j:N:a.y===f?N:j,e===o){const A=Math.abs(t[h]-n[h]);if(A<=s){const I=Math.min(s-1,s-A);a[h]===f?p[h]=(l[h]>t[h]?-1:1)*I:b[h]=(d[h]>n[h]?-1:1)*I}}if(e!==o){const A=h==="x"?"y":"x",I=a[h]===i[A],P=l[A]>d[A],R=l[A]<d[A];(a[h]===1&&(!I&&P||I&&R)||a[h]!==1&&(!I&&R||I&&P))&&(g=h==="x"?N:j)}const C={x:l.x+p.x,y:l.y+p.y},_={x:d.x+b.x,y:d.y+b.y};Math.max(Math.abs(C.x-g[0].x),Math.abs(_.x-g[0].x))>=Math.max(Math.abs(C.y-g[0].y),Math.abs(_.y-g[0].y))?(m=(C.x+_.x)/2,x=g[0].y):(m=g[0].x,x=(C.y+_.y)/2)}return[[t,{x:l.x+p.x,y:l.y+p.y},...g,{x:d.x+b.x,y:d.y+b.y},n],m,x,w,S]}function Nh({sourceX:t,sourceY:e,sourcePosition:n=De.Bottom,targetX:o,targetY:r,targetPosition:s=De.Top,borderRadius:a=5,centerX:i,centerY:l,offset:d=20}){const[u,h,f,m,x]=tA({source:{x:t,y:e},sourcePosition:n,target:{x:o,y:r},targetPosition:s,center:{x:i,y:l},offset:d});return[u.reduce((g,p,b)=>{let y="";return y=b>0&&b<u.length-1?function(v,w,S,N){const j=Math.min(xv(v,w)/2,xv(w,S)/2,N),{x:C,y:_}=w;if(v.x===C&&C===S.x||v.y===_&&_===S.y)return`L${C} ${_}`;if(v.y===_)return`L ${C+j*(v.x<S.x?-1:1)},${_}Q ${C},${_} ${C},${_+j*(v.y<S.y?1:-1)}`;const A=v.x<S.x?1:-1;return`L ${C},${_+j*(v.y<S.y?-1:1)}Q ${C},${_} ${C+j*A},${_}`}(u[b-1],p,u[b+1],a):`${b===0?"M":"L"}${p.x} ${p.y}`,g+=y},""),h,f,m,x]}const Al=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d,style:u,sourcePosition:h=De.Bottom,targetPosition:f=De.Top,markerEnd:m,markerStart:x,pathOptions:g,interactionWidth:p})=>{const[b,y,v]=Nh({sourceX:t,sourceY:e,sourcePosition:h,targetX:n,targetY:o,targetPosition:f,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset});return G.createElement(pa,{path:b,labelX:y,labelY:v,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d,style:u,markerEnd:m,markerStart:x,interactionWidth:p})});Al.displayName="SmoothStepEdge";const jh=O.memo(t=>{var e;return G.createElement(Al,{...t,pathOptions:O.useMemo(()=>{var n;return{borderRadius:0,offset:(n=t.pathOptions)==null?void 0:n.offset}},[(e=t.pathOptions)==null?void 0:e.offset])})});jh.displayName="StepEdge";const Ch=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d,style:u,markerEnd:h,markerStart:f,interactionWidth:m})=>{const[x,g,p]=function({sourceX:b,sourceY:y,targetX:v,targetY:w}){const[S,N,j,C]=cv({sourceX:b,sourceY:y,targetX:v,targetY:w});return[`M ${b},${y}L ${v},${w}`,S,N,j,C]}({sourceX:t,sourceY:e,targetX:n,targetY:o});return G.createElement(pa,{path:x,labelX:g,labelY:p,label:r,labelStyle:s,labelShowBg:a,labelBgStyle:i,labelBgPadding:l,labelBgBorderRadius:d,style:u,markerEnd:h,markerStart:f,interactionWidth:m})});function Tl(t,e){return t>=0?.5*t:25*e*Math.sqrt(-t)}function bv({pos:t,x1:e,y1:n,x2:o,y2:r,c:s}){switch(t){case De.Left:return[e-Tl(e-o,s),n];case De.Right:return[e+Tl(o-e,s),n];case De.Top:return[e,n-Tl(n-r,s)];case De.Bottom:return[e,n+Tl(r-n,s)]}}function yv({sourceX:t,sourceY:e,sourcePosition:n=De.Bottom,targetX:o,targetY:r,targetPosition:s=De.Top,curvature:a=.25}){const[i,l]=bv({pos:n,x1:t,y1:e,x2:o,y2:r,c:a}),[d,u]=bv({pos:s,x1:o,y1:r,x2:t,y2:e,c:a}),[h,f,m,x]=dv({sourceX:t,sourceY:e,targetX:o,targetY:r,sourceControlX:i,sourceControlY:l,targetControlX:d,targetControlY:u});return[`M${t},${e} C${i},${l} ${d},${u} ${o},${r}`,h,f,m,x]}Ch.displayName="StraightEdge";const Ml=O.memo(({sourceX:t,sourceY:e,targetX:n,targetY:o,sourcePosition:r=De.Bottom,targetPosition:s=De.Top,label:a,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:x,pathOptions:g,interactionWidth:p})=>{const[b,y,v]=yv({sourceX:t,sourceY:e,sourcePosition:r,targetX:n,targetY:o,targetPosition:s,curvature:g==null?void 0:g.curvature});return G.createElement(pa,{path:b,labelX:y,labelY:v,label:a,labelStyle:i,labelShowBg:l,labelBgStyle:d,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:m,markerStart:x,interactionWidth:p})});Ml.displayName="BezierEdge";const Eh=O.createContext(null),nA=Eh.Provider;Eh.Consumer;const oA=({source:t,sourceHandle:e,target:n,targetHandle:o})=>`reactflow__edge-${t}${e||""}-${n}${o||""}`,_h=(t,e)=>t===void 0?"":typeof t=="string"?t:`${e?`${e}__`:""}${Object.keys(t).sort().map(n=>`${n}=${t[n]}`).join("&")}`,Ih=({x:t,y:e},[n,o,r],s,[a,i])=>{const l={x:(t-n)/r,y:(e-o)/r};return s?{x:a*Math.round(l.x/a),y:i*Math.round(l.y/i)}:l},vv=({x:t,y:e},[n,o,r])=>({x:t*r+n,y:e*r+o}),Yr=(t,e=[0,0])=>{if(!t)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(t.width??0)*e[0],o=(t.height??0)*e[1],r={x:t.position.x-n,y:t.position.y-o};return{...r,positionAbsolute:t.positionAbsolute?{x:t.positionAbsolute.x-n,y:t.positionAbsolute.y-o}:r}},Ah=(t,e=[0,0])=>{if(t.length===0)return{x:0,y:0,width:0,height:0};const n=t.reduce((o,r)=>{const{x:s,y:a}=Yr(r,e).positionAbsolute;return i=o,l=yh({x:s,y:a,width:r.width||0,height:r.height||0}),{x:Math.min(i.x,l.x),y:Math.min(i.y,l.y),x2:Math.max(i.x2,l.x2),y2:Math.max(i.y2,l.y2)};var i,l},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return(({x:o,y:r,x2:s,y2:a})=>({x:o,y:r,width:s-o,height:a-r}))(n)},wv=(t,e,[n,o,r]=[0,0,1],s=!1,a=!1,i=[0,0])=>{const l={x:(e.x-n)/r,y:(e.y-o)/r,width:e.width/r,height:e.height/r},d=[];return t.forEach(u=>{const{width:h,height:f,selectable:m=!0,hidden:x=!1}=u;if(a&&!m||x)return!1;const{positionAbsolute:g}=Yr(u,i),p={x:g.x,y:g.y,width:h||0,height:f||0},b=vh(l,p);(h===void 0||f===void 0||h===null||f===null||s&&b>0||b>=(h||0)*(f||0)||u.dragging)&&d.push(u)}),d},kv=(t,e)=>{const n=t.map(o=>o.id);return e.filter(o=>n.includes(o.source)||n.includes(o.target))},Sv=(t,e,n,o,r,s=.1)=>{const a=e/(t.width*(1+s)),i=n/(t.height*(1+s)),l=Math.min(a,i),d=qr(l,o,r);return{x:e/2-(t.x+t.width/2)*d,y:n/2-(t.y+t.height/2)*d,zoom:d}},dr=(t,e=0)=>t.transition().duration(e);function Nv(t,e,n,o){return(e[n]||[]).reduce((r,s)=>{var a,i;return`${t.id}-${s.id}-${n}`!==o&&r.push({id:s.id||null,type:n,nodeId:t.id,x:(((a=t.positionAbsolute)==null?void 0:a.x)??0)+s.x+s.width/2,y:(((i=t.positionAbsolute)==null?void 0:i.y)??0)+s.y+s.height/2}),r},[])}const rA={source:null,target:null,sourceHandle:null,targetHandle:null},jv=()=>({handleDomNode:null,isValid:!1,connection:rA,endHandle:null});function Cv(t,e,n,o,r,s,a){const i=r==="target",l=a.querySelector(`.react-flow__handle[data-id="${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`),d={...jv(),handleDomNode:l};if(l){const u=Th(void 0,l),h=l.getAttribute("data-nodeid"),f=l.getAttribute("data-handleid"),m=l.classList.contains("connectable"),x=l.classList.contains("connectableend"),g={source:i?h:n,sourceHandle:i?f:o,target:i?n:h,targetHandle:i?o:f};d.connection=g,m&&x&&(e===cr.Strict?i&&u==="source"||!i&&u==="target":h!==n||f!==o)&&(d.endHandle={nodeId:h,handleId:f,type:u},d.isValid=s(g))}return d}function Th(t,e){return t||(e!=null&&e.classList.contains("target")?"target":e!=null&&e.classList.contains("source")?"source":null)}function Mh(t){t==null||t.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function sA(t,e){let n=null;return e?n="valid":t&&!e&&(n="invalid"),n}function Ev({event:t,handleId:e,nodeId:n,onConnect:o,isTarget:r,getState:s,setState:a,isValidConnection:i,edgeUpdaterType:l,onReconnectEnd:d}){const u=sv(t.target),{connectionMode:h,domNode:f,autoPanOnConnect:m,connectionRadius:x,onConnectStart:g,panBy:p,getNodes:b,cancelConnection:y}=s();let v,w=0;const{x:S,y:N}=Ro(t),j=u==null?void 0:u.elementFromPoint(S,N),C=Th(l,j),_=f==null?void 0:f.getBoundingClientRect();if(!_||!C)return;let A,I=Ro(t,_),P=!1,R=null,M=!1,L=null;const F=function({nodes:B,nodeId:E,handleId:U,handleType:V}){return B.reduce(($,X)=>{if(X[bt]){const{handleBounds:Y}=X[bt];let J=[],Q=[];Y&&(J=Nv(X,Y,"source",`${E}-${U}-${V}`),Q=Nv(X,Y,"target",`${E}-${U}-${V}`)),$.push(...J,...Q)}return $},[])}({nodes:b(),nodeId:n,handleId:e,handleType:C}),D=()=>{if(!m)return;const[B,E]=rv(I,_);p({x:B,y:E}),w=requestAnimationFrame(D)};function T(B){const{transform:E}=s();I=Ro(B,_);const{handle:U,validHandleResult:V}=function($,X,Y,J,Q,q){const{x:K,y:re}=Ro($),oe=X.elementsFromPoint(K,re).find(he=>he.classList.contains("react-flow__handle"));if(oe){const he=oe.getAttribute("data-nodeid");if(he){const ae=Th(void 0,oe),ye=oe.getAttribute("data-handleid"),fe=q({nodeId:he,id:ye,type:ae});if(fe){const Se=Q.find(Me=>Me.nodeId===he&&Me.type===ae&&Me.id===ye);return{handle:{id:ye,type:ae,nodeId:he,x:(Se==null?void 0:Se.x)||Y.x,y:(Se==null?void 0:Se.y)||Y.y},validHandleResult:fe}}}}let ne=[],se=1/0;if(Q.forEach(he=>{const ae=Math.sqrt((he.x-Y.x)**2+(he.y-Y.y)**2);if(ae<=J){const ye=q(he);ae<=se&&(ae<se?ne=[{handle:he,validHandleResult:ye}]:ae===se&&ne.push({handle:he,validHandleResult:ye}),se=ae)}}),!ne.length)return{handle:null,validHandleResult:jv()};if(ne.length===1)return ne[0];const te=ne.some(({validHandleResult:he})=>he.isValid),pe=ne.some(({handle:he})=>he.type==="target");return ne.find(({handle:he,validHandleResult:ae})=>pe?he.type==="target":!te||ae.isValid)||ne[0]}(B,u,Ih(I,E,!1,[1,1]),x,F,$=>Cv($,h,n,e,r?"target":"source",i,u));if(v=U,P||(D(),P=!0),L=V.handleDomNode,R=V.connection,M=V.isValid,a({connectionPosition:v&&M?vv({x:v.x,y:v.y},E):I,connectionStatus:sA(!!v,M),connectionEndHandle:V.endHandle}),!v&&!M&&!L)return Mh(A);R.source!==R.target&&L&&(Mh(A),A=L,L.classList.add("connecting","react-flow__handle-connecting"),L.classList.toggle("valid",M),L.classList.toggle("react-flow__handle-valid",M))}function k(B){var E,U;(v||L)&&R&&M&&(o==null||o(R)),(U=(E=s()).onConnectEnd)==null||U.call(E,B),l&&(d==null||d(B)),Mh(A),y(),cancelAnimationFrame(w),P=!1,M=!1,R=null,L=null,u.removeEventListener("mousemove",T),u.removeEventListener("mouseup",k),u.removeEventListener("touchmove",T),u.removeEventListener("touchend",k)}a({connectionPosition:I,connectionStatus:null,connectionNodeId:n,connectionHandleId:e,connectionHandleType:C,connectionStartHandle:{nodeId:n,handleId:e,type:C},connectionEndHandle:null}),g==null||g(t,{nodeId:n,handleId:e,handleType:C}),u.addEventListener("mousemove",T),u.addEventListener("mouseup",k),u.addEventListener("touchmove",T),u.addEventListener("touchend",k)}const _v=()=>!0,aA=t=>({connectionStartHandle:t.connectionStartHandle,connectOnClick:t.connectOnClick,noPanClassName:t.noPanClassName}),Iv=O.forwardRef(({type:t="source",position:e=De.Top,isValidConnection:n,isConnectable:o=!0,isConnectableStart:r=!0,isConnectableEnd:s=!0,id:a,onConnect:i,children:l,className:d,onMouseDown:u,onTouchStart:h,...f},m)=>{var C,_;const x=a||null,g=t==="target",p=Lt(),b=O.useContext(Eh),{connectOnClick:y,noPanClassName:v}=at(aA,$t),{connecting:w,clickConnecting:S}=at(((A,I,P)=>R=>{const{connectionStartHandle:M,connectionEndHandle:L,connectionClickStartHandle:F}=R;return{connecting:(M==null?void 0:M.nodeId)===A&&(M==null?void 0:M.handleId)===I&&(M==null?void 0:M.type)===P||(L==null?void 0:L.nodeId)===A&&(L==null?void 0:L.handleId)===I&&(L==null?void 0:L.type)===P,clickConnecting:(F==null?void 0:F.nodeId)===A&&(F==null?void 0:F.handleId)===I&&(F==null?void 0:F.type)===P}})(b,x,t),$t);b||((_=(C=p.getState()).onError)==null||_.call(C,"010",K8()));const N=A=>{const{defaultEdgeOptions:I,onConnect:P,hasDefaultEdges:R}=p.getState(),M={...I,...A};if(R){const{edges:L,setEdges:F}=p.getState();F(((D,T)=>{if(!D.source||!D.target)return T;let k;return k=(B=>"id"in B&&"source"in B&&"target"in B)(D)?{...D}:{...D,id:oA(D)},((B,E)=>E.some(U=>!(U.source!==B.source||U.target!==B.target||U.sourceHandle!==B.sourceHandle&&(U.sourceHandle||B.sourceHandle)||U.targetHandle!==B.targetHandle&&(U.targetHandle||B.targetHandle))))(k,T)?T:T.concat(k)})(M,L))}P==null||P(M),i==null||i(M)},j=A=>{if(!b)return;const I=lv(A);r&&(I&&A.button===0||!I)&&Ev({event:A,handleId:x,nodeId:b,onConnect:N,isTarget:g,getState:p.getState,setState:p.setState,isValidConnection:n||p.getState().isValidConnection||_v}),I?u==null||u(A):h==null||h(A)};return G.createElement("div",{"data-handleid":x,"data-nodeid":b,"data-handlepos":e,"data-id":`${b}-${x}-${t}`,className:Kt(["react-flow__handle",`react-flow__handle-${e}`,"nodrag",v,d,{source:!g,target:g,connectable:o,connectablestart:r,connectableend:s,connecting:S,connectionindicator:o&&(r&&!w||s&&w)}]),onMouseDown:j,onTouchStart:j,onClick:y?A=>{const{onClickConnectStart:I,onClickConnectEnd:P,connectionClickStartHandle:R,connectionMode:M,isValidConnection:L}=p.getState();if(!b||!R&&!r)return;if(!R)return I==null||I(A,{nodeId:b,handleId:x,handleType:t}),void p.setState({connectionClickStartHandle:{nodeId:b,type:t,handleId:x}});const F=sv(A.target),D=n||L||_v,{connection:T,isValid:k}=Cv({nodeId:b,id:x,type:t},M,R.nodeId,R.handleId||null,R.type,D,F);k&&N(T),P==null||P(A),p.setState({connectionClickStartHandle:null})}:void 0,ref:m,...f},l)});Iv.displayName="Handle";var zo=O.memo(Iv);const Av=({data:t,isConnectable:e,targetPosition:n=De.Top,sourcePosition:o=De.Bottom})=>G.createElement(G.Fragment,null,G.createElement(zo,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label,G.createElement(zo,{type:"source",position:o,isConnectable:e}));Av.displayName="DefaultNode";var Oh=O.memo(Av);const Tv=({data:t,isConnectable:e,sourcePosition:n=De.Bottom})=>G.createElement(G.Fragment,null,t==null?void 0:t.label,G.createElement(zo,{type:"source",position:n,isConnectable:e}));Tv.displayName="InputNode";var Mv=O.memo(Tv);const Ov=({data:t,isConnectable:e,targetPosition:n=De.Top})=>G.createElement(G.Fragment,null,G.createElement(zo,{type:"target",position:n,isConnectable:e}),t==null?void 0:t.label);Ov.displayName="OutputNode";var Dv=O.memo(Ov);const Dh=()=>null;Dh.displayName="GroupNode";const iA=t=>({selectedNodes:t.getNodes().filter(e=>e.selected),selectedEdges:t.edges.filter(e=>e.selected).map(e=>({...e}))}),Ol=t=>t.id;function lA(t,e){return $t(t.selectedNodes.map(Ol),e.selectedNodes.map(Ol))&&$t(t.selectedEdges.map(Ol),e.selectedEdges.map(Ol))}const Pv=O.memo(({onSelectionChange:t})=>{const e=Lt(),{selectedNodes:n,selectedEdges:o}=at(iA,lA);return O.useEffect(()=>{const r={nodes:n,edges:o};t==null||t(r),e.getState().onSelectionChange.forEach(s=>s(r))},[n,o,t]),null});Pv.displayName="SelectionListener";const cA=t=>!!t.onSelectionChange;function dA({onSelectionChange:t}){const e=at(cA);return t||e?G.createElement(Pv,{onSelectionChange:t}):null}const uA=t=>({setNodes:t.setNodes,setEdges:t.setEdges,setDefaultNodesAndEdges:t.setDefaultNodesAndEdges,setMinZoom:t.setMinZoom,setMaxZoom:t.setMaxZoom,setTranslateExtent:t.setTranslateExtent,setNodeExtent:t.setNodeExtent,reset:t.reset});function Kr(t,e){O.useEffect(()=>{t!==void 0&&e(t)},[t])}function Je(t,e,n){O.useEffect(()=>{e!==void 0&&n({[t]:e})},[e])}const hA=({nodes:t,edges:e,defaultNodes:n,defaultEdges:o,onConnect:r,onConnectStart:s,onConnectEnd:a,onClickConnectStart:i,onClickConnectEnd:l,nodesDraggable:d,nodesConnectable:u,nodesFocusable:h,edgesFocusable:f,edgesUpdatable:m,elevateNodesOnSelect:x,minZoom:g,maxZoom:p,nodeExtent:b,onNodesChange:y,onEdgesChange:v,elementsSelectable:w,connectionMode:S,snapGrid:N,snapToGrid:j,translateExtent:C,connectOnClick:_,defaultEdgeOptions:A,fitView:I,fitViewOptions:P,onNodesDelete:R,onEdgesDelete:M,onNodeDrag:L,onNodeDragStart:F,onNodeDragStop:D,onSelectionDrag:T,onSelectionDragStart:k,onSelectionDragStop:B,noPanClassName:E,nodeOrigin:U,rfId:V,autoPanOnConnect:$,autoPanOnNodeDrag:X,onError:Y,connectionRadius:J,isValidConnection:Q,nodeDragThreshold:q})=>{const{setNodes:K,setEdges:re,setDefaultNodesAndEdges:oe,setMinZoom:ne,setMaxZoom:se,setTranslateExtent:te,setNodeExtent:pe,reset:he}=at(uA,$t),ae=Lt();return O.useEffect(()=>{const ye=o==null?void 0:o.map(fe=>({...fe,...A}));return oe(n,ye),()=>{he()}},[]),Je("defaultEdgeOptions",A,ae.setState),Je("connectionMode",S,ae.setState),Je("onConnect",r,ae.setState),Je("onConnectStart",s,ae.setState),Je("onConnectEnd",a,ae.setState),Je("onClickConnectStart",i,ae.setState),Je("onClickConnectEnd",l,ae.setState),Je("nodesDraggable",d,ae.setState),Je("nodesConnectable",u,ae.setState),Je("nodesFocusable",h,ae.setState),Je("edgesFocusable",f,ae.setState),Je("edgesUpdatable",m,ae.setState),Je("elementsSelectable",w,ae.setState),Je("elevateNodesOnSelect",x,ae.setState),Je("snapToGrid",j,ae.setState),Je("snapGrid",N,ae.setState),Je("onNodesChange",y,ae.setState),Je("onEdgesChange",v,ae.setState),Je("connectOnClick",_,ae.setState),Je("fitViewOnInit",I,ae.setState),Je("fitViewOnInitOptions",P,ae.setState),Je("onNodesDelete",R,ae.setState),Je("onEdgesDelete",M,ae.setState),Je("onNodeDrag",L,ae.setState),Je("onNodeDragStart",F,ae.setState),Je("onNodeDragStop",D,ae.setState),Je("onSelectionDrag",T,ae.setState),Je("onSelectionDragStart",k,ae.setState),Je("onSelectionDragStop",B,ae.setState),Je("noPanClassName",E,ae.setState),Je("nodeOrigin",U,ae.setState),Je("rfId",V,ae.setState),Je("autoPanOnConnect",$,ae.setState),Je("autoPanOnNodeDrag",X,ae.setState),Je("onError",Y,ae.setState),Je("connectionRadius",J,ae.setState),Je("isValidConnection",Q,ae.setState),Je("nodeDragThreshold",q,ae.setState),Kr(t,K),Kr(e,re),Kr(g,ne),Kr(p,se),Kr(C,te),Kr(b,pe),null},Rv={display:"none"},fA={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Lv="react-flow__node-desc",Fv="react-flow__edge-desc",mA=t=>t.ariaLiveMessage;function pA({rfId:t}){const e=at(mA);return G.createElement("div",{id:`react-flow__aria-live-${t}`,"aria-live":"assertive","aria-atomic":"true",style:fA},e)}function gA({rfId:t,disableKeyboardA11y:e}){return G.createElement(G.Fragment,null,G.createElement("div",{id:`${Lv}-${t}`,style:Rv},"Press enter or space to select a node.",!e&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),G.createElement("div",{id:`${Fv}-${t}`,style:Rv},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!e&&G.createElement(pA,{rfId:t}))}var ya=(t=null,e={actInsideInputWithModifier:!0})=>{const[n,o]=O.useState(!1),r=O.useRef(!1),s=O.useRef(new Set([])),[a,i]=O.useMemo(()=>{if(t!==null){const l=(Array.isArray(t)?t:[t]).filter(u=>typeof u=="string").map(u=>u.split("+")),d=l.reduce((u,h)=>u.concat(...h),[]);return[l,d]}return[[],[]]},[t]);return O.useEffect(()=>{const l=typeof document<"u"?document:null,d=(e==null?void 0:e.target)||l;if(t!==null){const u=m=>{if(r.current=m.ctrlKey||m.metaKey||m.shiftKey,(!r.current||r.current&&!e.actInsideInputWithModifier)&&wh(m))return!1;const x=Bv(m.code,i);s.current.add(m[x]),zv(a,s.current,!1)&&(m.preventDefault(),o(!0))},h=m=>{if((!r.current||r.current&&!e.actInsideInputWithModifier)&&wh(m))return!1;const x=Bv(m.code,i);zv(a,s.current,!0)?(o(!1),s.current.clear()):s.current.delete(m[x]),m.key==="Meta"&&s.current.clear(),r.current=!1},f=()=>{s.current.clear(),o(!1)};return d==null||d.addEventListener("keydown",u),d==null||d.addEventListener("keyup",h),window.addEventListener("blur",f),()=>{d==null||d.removeEventListener("keydown",u),d==null||d.removeEventListener("keyup",h),window.removeEventListener("blur",f)}}},[t,o]),n};function zv(t,e,n){return t.filter(o=>n||o.length===e.size).some(o=>o.every(r=>e.has(r)))}function Bv(t,e){return e.includes(t)?"code":"key"}function Uv(t,e,n,o){var i,l;const r=t.parentNode||t.parentId;if(!r)return n;const s=e.get(r),a=Yr(s,o);return Uv(s,e,{x:(n.x??0)+a.x,y:(n.y??0)+a.y,z:(((i=s[bt])==null?void 0:i.z)??0)>(n.z??0)?((l=s[bt])==null?void 0:l.z)??0:n.z??0},o)}function $v(t,e,n){t.forEach(o=>{var s;const r=o.parentNode||o.parentId;if(r&&!t.has(r))throw new Error(`Parent node ${r} not found`);if(r||n!=null&&n[o.id]){const{x:a,y:i,z:l}=Uv(o,t,{...o.position,z:((s=o[bt])==null?void 0:s.z)??0},e);o.positionAbsolute={x:a,y:i},o[bt].z=l,n!=null&&n[o.id]&&(o[bt].isParent=!0)}})}function Ph(t,e,n,o){const r=new Map,s={},a=o?1e3:0;return t.forEach(i=>{var m;const l=(kn(i.zIndex)?i.zIndex:0)+(i.selected?a:0),d=e.get(i.id),u={...i,positionAbsolute:{x:i.position.x,y:i.position.y}},h=i.parentNode||i.parentId;h&&(s[h]=!0);const f=(d==null?void 0:d.type)&&(d==null?void 0:d.type)!==i.type;Object.defineProperty(u,bt,{enumerable:!1,value:{handleBounds:f||(m=d==null?void 0:d[bt])==null?void 0:m.handleBounds,z:l}}),r.set(i.id,u)}),$v(r,n,s),r}function Vv(t,e={}){const{getNodes:n,width:o,height:r,minZoom:s,maxZoom:a,d3Zoom:i,d3Selection:l,fitViewOnInitDone:d,fitViewOnInit:u,nodeOrigin:h}=t(),f=e.initial&&!d&&u;if(i&&l&&(f||!e.initial)){const m=n().filter(g=>{var b;const p=e.includeHiddenNodes?g.width&&g.height:!g.hidden;return(b=e.nodes)!=null&&b.length?p&&e.nodes.some(y=>y.id===g.id):p}),x=m.every(g=>g.width&&g.height);if(m.length>0&&x){const g=Ah(m,h),{x:p,y:b,zoom:y}=Sv(g,o,r,e.minZoom??s,e.maxZoom??a,e.padding??.1),v=Zo.translate(p,b).scale(y);return typeof e.duration=="number"&&e.duration>0?i.transform(dr(l,e.duration),v):i.transform(l,v),!0}}return!1}function xA(t,e){return t.forEach(n=>{const o=e.get(n.id);o&&e.set(o.id,{...o,[bt]:o[bt],selected:n.selected})}),new Map(e)}function bA(t,e){return e.map(n=>{const o=t.find(r=>r.id===n.id);return o&&(n.selected=o.selected),n})}function Dl({changedNodes:t,changedEdges:e,get:n,set:o}){const{nodeInternals:r,edges:s,onNodesChange:a,onEdgesChange:i,hasDefaultNodes:l,hasDefaultEdges:d}=n();t!=null&&t.length&&(l&&o({nodeInternals:xA(t,r)}),a==null||a(t)),e!=null&&e.length&&(d&&o({edges:bA(e,s)}),i==null||i(e))}const Xr=()=>{},yA={zoomIn:Xr,zoomOut:Xr,zoomTo:Xr,getZoom:()=>1,setViewport:Xr,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Xr,fitBounds:Xr,project:t=>t,screenToFlowPosition:t=>t,flowToScreenPosition:t=>t,viewportInitialized:!1},vA=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection});function va(){const t=(()=>{const g=Lt(),{d3Zoom:p,d3Selection:b}=at(vA,$t);return O.useMemo(()=>b&&p?{zoomIn:v=>p.scaleBy(dr(b,v==null?void 0:v.duration),1.2),zoomOut:v=>p.scaleBy(dr(b,v==null?void 0:v.duration),1/1.2),zoomTo:(v,w)=>p.scaleTo(dr(b,w==null?void 0:w.duration),v),getZoom:()=>g.getState().transform[2],setViewport:(v,w)=>{const[S,N,j]=g.getState().transform,C=Zo.translate(v.x??S,v.y??N).scale(v.zoom??j);p.transform(dr(b,w==null?void 0:w.duration),C)},getViewport:()=>{const[v,w,S]=g.getState().transform;return{x:v,y:w,zoom:S}},fitView:v=>Vv(g.getState,v),setCenter:(v,w,S)=>{const{width:N,height:j,maxZoom:C}=g.getState(),_=(S==null?void 0:S.zoom)!==void 0?S.zoom:C,A=N/2-v*_,I=j/2-w*_,P=Zo.translate(A,I).scale(_);p.transform(dr(b,S==null?void 0:S.duration),P)},fitBounds:(v,w)=>{const{width:S,height:N,minZoom:j,maxZoom:C}=g.getState(),{x:_,y:A,zoom:I}=Sv(v,S,N,j,C,(w==null?void 0:w.padding)??.1),P=Zo.translate(_,A).scale(I);p.transform(dr(b,w==null?void 0:w.duration),P)},project:v=>{const{transform:w,snapToGrid:S,snapGrid:N}=g.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"),Ih(v,w,S,N)},screenToFlowPosition:v=>{const{transform:w,snapToGrid:S,snapGrid:N,domNode:j}=g.getState();if(!j)return v;const{x:C,y:_}=j.getBoundingClientRect(),A={x:v.x-C,y:v.y-_};return Ih(A,w,S,N)},flowToScreenPosition:v=>{const{transform:w,domNode:S}=g.getState();if(!S)return v;const{x:N,y:j}=S.getBoundingClientRect(),C=vv(v,w);return{x:C.x+N,y:C.y+j}},viewportInitialized:!0}:yA,[p,b])})(),e=Lt(),n=O.useCallback(()=>e.getState().getNodes().map(g=>({...g})),[]),o=O.useCallback(g=>e.getState().nodeInternals.get(g),[]),r=O.useCallback(()=>{const{edges:g=[]}=e.getState();return g.map(p=>({...p}))},[]),s=O.useCallback(g=>{const{edges:p=[]}=e.getState();return p.find(b=>b.id===g)},[]),a=O.useCallback(g=>{const{getNodes:p,setNodes:b,hasDefaultNodes:y,onNodesChange:v}=e.getState(),w=p(),S=typeof g=="function"?g(w):g;if(y)b(S);else if(v){const N=S.length===0?w.map(j=>({type:"remove",id:j.id})):S.map(j=>({item:j,type:"reset"}));v(N)}},[]),i=O.useCallback(g=>{const{edges:p=[],setEdges:b,hasDefaultEdges:y,onEdgesChange:v}=e.getState(),w=typeof g=="function"?g(p):g;y?b(w):v&&v(w.length===0?p.map(S=>({type:"remove",id:S.id})):w.map(S=>({item:S,type:"reset"})))},[]),l=O.useCallback(g=>{const p=Array.isArray(g)?g:[g],{getNodes:b,setNodes:y,hasDefaultNodes:v,onNodesChange:w}=e.getState();if(v)y([...b(),...p]);else if(w){const S=p.map(N=>({item:N,type:"add"}));w(S)}},[]),d=O.useCallback(g=>{const p=Array.isArray(g)?g:[g],{edges:b=[],setEdges:y,hasDefaultEdges:v,onEdgesChange:w}=e.getState();v?y([...b,...p]):w&&w(p.map(S=>({item:S,type:"add"})))},[]),u=O.useCallback(()=>{const{getNodes:g,edges:p=[],transform:b}=e.getState(),[y,v,w]=b;return{nodes:g().map(S=>({...S})),edges:p.map(S=>({...S})),viewport:{x:y,y:v,zoom:w}}},[]),h=O.useCallback(({nodes:g,edges:p})=>{const{nodeInternals:b,getNodes:y,edges:v,hasDefaultNodes:w,hasDefaultEdges:S,onNodesDelete:N,onEdgesDelete:j,onNodesChange:C,onEdgesChange:_}=e.getState(),A=(g||[]).map(L=>L.id),I=(p||[]).map(L=>L.id),P=y().reduce((L,F)=>{const D=F.parentNode||F.parentId,T=!A.includes(F.id)&&D&&L.find(k=>k.id===D);return(typeof F.deletable!="boolean"||F.deletable)&&(A.includes(F.id)||T)&&L.push(F),L},[]),R=v.filter(L=>typeof L.deletable!="boolean"||L.deletable),M=R.filter(L=>I.includes(L.id));if(P||M){const L=kv(P,R),F=[...M,...L],D=F.reduce((T,k)=>(T.includes(k.id)||T.push(k.id),T),[]);(S||w)&&(S&&e.setState({edges:v.filter(T=>!D.includes(T.id))}),w&&(P.forEach(T=>{b.delete(T.id)}),e.setState({nodeInternals:new Map(b)}))),D.length>0&&(j==null||j(F),_&&_(D.map(T=>({id:T,type:"remove"})))),P.length>0&&(N==null||N(P),C)&&C(P.map(T=>({id:T.id,type:"remove"})))}},[]),f=O.useCallback(g=>{const p=kn((b=g).width)&&kn(b.height)&&kn(b.x)&&kn(b.y);var b;const y=p?null:e.getState().nodeInternals.get(g.id);return!p&&!y?[null,null,p]:[p?g:av(y),y,p]},[]),m=O.useCallback((g,p=!0,b)=>{const[y,v,w]=f(g);return y?(b||e.getState().getNodes()).filter(S=>{if(!(w||S.id!==v.id&&S.positionAbsolute))return!1;const N=av(S),j=vh(N,y);return p&&j>0||j>=y.width*y.height}):[]},[]),x=O.useCallback((g,p,b=!0)=>{const[y]=f(g);if(!y)return!1;const v=vh(y,p);return b&&v>0||v>=y.width*y.height},[]);return O.useMemo(()=>({...t,getNodes:n,getNode:o,getEdges:r,getEdge:s,setNodes:a,setEdges:i,addNodes:l,addEdges:d,toObject:u,deleteElements:h,getIntersectingNodes:m,isNodeIntersecting:x}),[t,n,o,r,s,a,i,l,d,u,h,m,x])}const wA={actInsideInputWithModifier:!1},Rh={position:"absolute",width:"100%",height:"100%",top:0,left:0},Pl=t=>({x:t.x,y:t.y,zoom:t.k}),Jr=(t,e)=>t.target.closest(`.${e}`),Hv=(t,e)=>e===2&&Array.isArray(t)&&t.includes(2),Wv=t=>{const e=t.ctrlKey&&_l()?10:1;return-t.deltaY*(t.deltaMode===1?.05:t.deltaMode?1:.002)*e},kA=t=>({d3Zoom:t.d3Zoom,d3Selection:t.d3Selection,d3ZoomHandler:t.d3ZoomHandler,userSelectionActive:t.userSelectionActive}),SA=({onMove:t,onMoveStart:e,onMoveEnd:n,onPaneContextMenu:o,zoomOnScroll:r=!0,zoomOnPinch:s=!0,panOnScroll:a=!1,panOnScrollSpeed:i=.5,panOnScrollMode:l=Lo.Free,zoomOnDoubleClick:d=!0,elementsSelectable:u,panOnDrag:h=!0,defaultViewport:f,translateExtent:m,minZoom:x,maxZoom:g,zoomActivationKeyCode:p,preventScrolling:b=!0,children:y,noWheelClassName:v,noPanClassName:w})=>{const S=O.useRef(),N=Lt(),j=O.useRef(!1),C=O.useRef(!1),_=O.useRef(null),A=O.useRef({x:0,y:0,zoom:0}),{d3Zoom:I,d3Selection:P,d3ZoomHandler:R,userSelectionActive:M}=at(kA,$t),L=ya(p),F=O.useRef(0),D=O.useRef(!1),T=O.useRef();return function(k){const B=Lt();O.useEffect(()=>{let E;const U=()=>{var $,X;if(!k.current)return;const V=xh(k.current);V.height!==0&&V.width!==0||((X=($=B.getState()).onError)==null||X.call($,"004",W8())),B.setState({width:V.width||500,height:V.height||500})};return U(),window.addEventListener("resize",U),k.current&&(E=new ResizeObserver(()=>U()),E.observe(k.current)),()=>{window.removeEventListener("resize",U),E&&k.current&&E.unobserve(k.current)}},[])}(_),O.useEffect(()=>{if(_.current){const k=_.current.getBoundingClientRect(),B=function(){var X,Y,J,Q=F8,q=z8,K=$8,re=B8,oe=U8,ne=[0,1/0],se=[[-1/0,-1/0],[1/0,1/0]],te=250,pe=HL,he=PS("start","zoom","end"),ae=0,ye=10;function fe(W){W.property("__zoom",tv).on("wheel.zoom",He,{passive:!1}).on("mousedown.zoom",Ge).on("dblclick.zoom",ee).filter(oe).on("touchstart.zoom",be).on("touchmove.zoom",we).on("touchend.zoom touchcancel.zoom",Ae).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function Se(W,de){return(de=Math.max(ne[0],Math.min(ne[1],de)))===W.k?W:new Bm(de,W.x,W.y)}function Me(W,de,ue){var ce=de[0]-ue[0]*W.k,ve=de[1]-ue[1]*W.k;return ce===W.x&&ve===W.y?W:new Bm(W.k,ce,ve)}function Ee(W){return[(+W[0][0]+ +W[1][0])/2,(+W[0][1]+ +W[1][1])/2]}function Le(W,de,ue,ce){W.on("start.zoom",function(){Te(this,arguments).event(ce).start()}).on("interrupt.zoom end.zoom",function(){Te(this,arguments).event(ce).end()}).tween("zoom",function(){var ve=this,Oe=arguments,Re=Te(ve,Oe).event(ce),Ye=q.apply(ve,Oe),ie=ue==null?Ee(Ye):typeof ue=="function"?ue.apply(ve,Oe):ue,je=Math.max(Ye[1][0]-Ye[0][0],Ye[1][1]-Ye[0][1]),_e=ve.__zoom,Be=typeof de=="function"?de.apply(ve,Oe):de,We=pe(_e.invert(ie).concat(je/_e.k),Be.invert(ie).concat(je/Be.k));return function(Pe){if(Pe===1)Pe=Be;else{var $e=We(Pe),nt=je/$e[2];Pe=new Bm(nt,ie[0]-$e[0]*nt,ie[1]-$e[1]*nt)}Re.zoom(null,Pe)}})}function Te(W,de,ue){return!ue&&W.__zooming||new Ze(W,de)}function Ze(W,de){this.that=W,this.args=de,this.active=0,this.sourceEvent=null,this.extent=q.apply(W,de),this.taps=0}function He(W,...de){if(Q.apply(this,arguments)){var ue=Te(this,de).event(W),ce=this.__zoom,ve=Math.max(ne[0],Math.min(ne[1],ce.k*Math.pow(2,re.apply(this,arguments)))),Oe=Hn(W);if(ue.wheel)ue.mouse[0][0]===Oe[0]&&ue.mouse[0][1]===Oe[1]||(ue.mouse[1]=ce.invert(ue.mouse[0]=Oe)),clearTimeout(ue.wheel);else{if(ce.k===ve)return;ue.mouse=[Oe,ce.invert(Oe)],Um(this),ue.start()}ma(W),ue.wheel=setTimeout(function(){ue.wheel=null,ue.end()},150),ue.zoom("mouse",K(Me(Se(ce,ve),ue.mouse[0],ue.mouse[1]),ue.extent,se))}}function Ge(W,...de){if(!J&&Q.apply(this,arguments)){var ue=W.currentTarget,ce=Te(this,de,!0).event(W),ve=Ln(W.view).on("mousemove.zoom",function(ie){if(ma(ie),!ce.moved){var je=ie.clientX-Re,_e=ie.clientY-Ye;ce.moved=je*je+_e*_e>ae}ce.event(ie).zoom("mouse",K(Me(ce.that.__zoom,ce.mouse[0]=Hn(ie,ue),ce.mouse[1]),ce.extent,se))},!0).on("mouseup.zoom",function(ie){ve.on("mousemove.zoom mouseup.zoom",null),ev(ie.view,ce.moved),ma(ie),ce.event(ie).end()},!0),Oe=Hn(W,ue),Re=W.clientX,Ye=W.clientY;Qy(W.view),gh(W),ce.mouse=[Oe,this.__zoom.invert(Oe)],Um(this),ce.start()}}function ee(W,...de){if(Q.apply(this,arguments)){var ue=this.__zoom,ce=Hn(W.changedTouches?W.changedTouches[0]:W,this),ve=ue.invert(ce),Oe=ue.k*(W.shiftKey?.5:2),Re=K(Me(Se(ue,Oe),ce,ve),q.apply(this,de),se);ma(W),te>0?Ln(this).transition().duration(te).call(Le,Re,ce,W):Ln(this).call(fe.transform,Re,ce,W)}}function be(W,...de){if(Q.apply(this,arguments)){var ue,ce,ve,Oe,Re=W.touches,Ye=Re.length,ie=Te(this,de,W.changedTouches.length===Ye).event(W);for(gh(W),ce=0;ce<Ye;++ce)Oe=[Oe=Hn(ve=Re[ce],this),this.__zoom.invert(Oe),ve.identifier],ie.touch0?ie.touch1||ie.touch0[2]===Oe[2]||(ie.touch1=Oe,ie.taps=0):(ie.touch0=Oe,ue=!0,ie.taps=1+!!X);X&&(X=clearTimeout(X)),ue&&(ie.taps<2&&(Y=Oe[0],X=setTimeout(function(){X=null},500)),Um(this),ie.start())}}function we(W,...de){if(this.__zooming){var ue,ce,ve,Oe,Re=Te(this,de).event(W),Ye=W.changedTouches,ie=Ye.length;for(ma(W),ue=0;ue<ie;++ue)ve=Hn(ce=Ye[ue],this),Re.touch0&&Re.touch0[2]===ce.identifier?Re.touch0[0]=ve:Re.touch1&&Re.touch1[2]===ce.identifier&&(Re.touch1[0]=ve);if(ce=Re.that.__zoom,Re.touch1){var je=Re.touch0[0],_e=Re.touch0[1],Be=Re.touch1[0],We=Re.touch1[1],Pe=(Pe=Be[0]-je[0])*Pe+(Pe=Be[1]-je[1])*Pe,$e=($e=We[0]-_e[0])*$e+($e=We[1]-_e[1])*$e;ce=Se(ce,Math.sqrt(Pe/$e)),ve=[(je[0]+Be[0])/2,(je[1]+Be[1])/2],Oe=[(_e[0]+We[0])/2,(_e[1]+We[1])/2]}else{if(!Re.touch0)return;ve=Re.touch0[0],Oe=Re.touch0[1]}Re.zoom("touch",K(Me(ce,ve,Oe),Re.extent,se))}}function Ae(W,...de){if(this.__zooming){var ue,ce,ve=Te(this,de).event(W),Oe=W.changedTouches,Re=Oe.length;for(gh(W),J&&clearTimeout(J),J=setTimeout(function(){J=null},500),ue=0;ue<Re;++ue)ce=Oe[ue],ve.touch0&&ve.touch0[2]===ce.identifier?delete ve.touch0:ve.touch1&&ve.touch1[2]===ce.identifier&&delete ve.touch1;if(ve.touch1&&!ve.touch0&&(ve.touch0=ve.touch1,delete ve.touch1),ve.touch0)ve.touch0[1]=this.__zoom.invert(ve.touch0[0]);else if(ve.end(),ve.taps===2&&(ce=Hn(ce,this),Math.hypot(Y[0]-ce[0],Y[1]-ce[1])<ye)){var Ye=Ln(this).on("dblclick.zoom");Ye&&Ye.apply(this,arguments)}}}return fe.transform=function(W,de,ue,ce){var ve=W.selection?W.selection():W;ve.property("__zoom",tv),W!==ve?Le(W,de,ue,ce):ve.interrupt().each(function(){Te(this,arguments).event(ce).start().zoom(null,typeof de=="function"?de.apply(this,arguments):de).end()})},fe.scaleBy=function(W,de,ue,ce){fe.scaleTo(W,function(){return this.__zoom.k*(typeof de=="function"?de.apply(this,arguments):de)},ue,ce)},fe.scaleTo=function(W,de,ue,ce){fe.transform(W,function(){var ve=q.apply(this,arguments),Oe=this.__zoom,Re=ue==null?Ee(ve):typeof ue=="function"?ue.apply(this,arguments):ue,Ye=Oe.invert(Re),ie=typeof de=="function"?de.apply(this,arguments):de;return K(Me(Se(Oe,ie),Re,Ye),ve,se)},ue,ce)},fe.translateBy=function(W,de,ue,ce){fe.transform(W,function(){return K(this.__zoom.translate(typeof de=="function"?de.apply(this,arguments):de,typeof ue=="function"?ue.apply(this,arguments):ue),q.apply(this,arguments),se)},null,ce)},fe.translateTo=function(W,de,ue,ce,ve){fe.transform(W,function(){var Oe=q.apply(this,arguments),Re=this.__zoom,Ye=ce==null?Ee(Oe):typeof ce=="function"?ce.apply(this,arguments):ce;return K(Zo.translate(Ye[0],Ye[1]).scale(Re.k).translate(typeof de=="function"?-de.apply(this,arguments):-de,typeof ue=="function"?-ue.apply(this,arguments):-ue),Oe,se)},ce,ve)},Ze.prototype={event:function(W){return W&&(this.sourceEvent=W),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(W,de){return this.mouse&&W!=="mouse"&&(this.mouse[1]=de.invert(this.mouse[0])),this.touch0&&W!=="touch"&&(this.touch0[1]=de.invert(this.touch0[0])),this.touch1&&W!=="touch"&&(this.touch1[1]=de.invert(this.touch1[0])),this.that.__zoom=de,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(W){var de=Ln(this.that).datum();he.call(W,this.that,new L8(W,{sourceEvent:this.sourceEvent,target:fe,transform:this.that.__zoom,dispatch:he}),de)}},fe.wheelDelta=function(W){return arguments.length?(re=typeof W=="function"?W:jl(+W),fe):re},fe.filter=function(W){return arguments.length?(Q=typeof W=="function"?W:jl(!!W),fe):Q},fe.touchable=function(W){return arguments.length?(oe=typeof W=="function"?W:jl(!!W),fe):oe},fe.extent=function(W){return arguments.length?(q=typeof W=="function"?W:jl([[+W[0][0],+W[0][1]],[+W[1][0],+W[1][1]]]),fe):q},fe.scaleExtent=function(W){return arguments.length?(ne[0]=+W[0],ne[1]=+W[1],fe):[ne[0],ne[1]]},fe.translateExtent=function(W){return arguments.length?(se[0][0]=+W[0][0],se[1][0]=+W[1][0],se[0][1]=+W[0][1],se[1][1]=+W[1][1],fe):[[se[0][0],se[0][1]],[se[1][0],se[1][1]]]},fe.constrain=function(W){return arguments.length?(K=W,fe):K},fe.duration=function(W){return arguments.length?(te=+W,fe):te},fe.interpolate=function(W){return arguments.length?(pe=W,fe):pe},fe.on=function(){var W=he.on.apply(he,arguments);return W===he?fe:W},fe.clickDistance=function(W){return arguments.length?(ae=(W=+W)*W,fe):Math.sqrt(ae)},fe.tapDistance=function(W){return arguments.length?(ye=+W,fe):ye},fe}().scaleExtent([x,g]).translateExtent(m),E=Ln(_.current).call(B),U=Zo.translate(f.x,f.y).scale(qr(f.zoom,x,g)),V=[[0,0],[k.width,k.height]],$=B.constrain()(U,V,m);B.transform(E,$),B.wheelDelta(Wv),N.setState({d3Zoom:B,d3Selection:E,d3ZoomHandler:E.on("wheel.zoom"),transform:[$.x,$.y,$.k],domNode:_.current.closest(".react-flow")})}},[]),O.useEffect(()=>{P&&I&&(!a||L||M?R!==void 0&&P.on("wheel.zoom",function(k,B){if(!b&&k.type==="wheel"&&!k.ctrlKey||Jr(k,v))return null;k.preventDefault(),R.call(this,k,B)},{passive:!1}):P.on("wheel.zoom",k=>{if(Jr(k,v))return!1;k.preventDefault(),k.stopImmediatePropagation();const B=P.property("__zoom").k||1;if(k.ctrlKey&&s){const Q=Hn(k),q=Wv(k),K=B*Math.pow(2,q);return void I.scaleTo(P,K,Q,k)}const E=k.deltaMode===1?20:1;let U=l===Lo.Vertical?0:k.deltaX*E,V=l===Lo.Horizontal?0:k.deltaY*E;!_l()&&k.shiftKey&&l!==Lo.Vertical&&(U=k.deltaY*E,V=0),I.translateBy(P,-U/B*i,-V/B*i,{internal:!0});const $=Pl(P.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=N.getState();clearTimeout(T.current),D.current||(D.current=!0,e==null||e(k,$),X==null||X($)),D.current&&(t==null||t(k,$),Y==null||Y($),T.current=setTimeout(()=>{n==null||n(k,$),J==null||J($),D.current=!1},150))},{passive:!1}))},[M,a,l,P,I,R,L,s,b,v,e,t,n]),O.useEffect(()=>{I&&I.on("start",k=>{var U,V;if(!k.sourceEvent||k.sourceEvent.internal)return null;F.current=(U=k.sourceEvent)==null?void 0:U.button;const{onViewportChangeStart:B}=N.getState(),E=Pl(k.transform);j.current=!0,A.current=E,((V=k.sourceEvent)==null?void 0:V.type)==="mousedown"&&N.setState({paneDragging:!0}),B==null||B(E),e==null||e(k.sourceEvent,E)})},[I,e]),O.useEffect(()=>{I&&(M&&!j.current?I.on("zoom",null):M||I.on("zoom",k=>{var E;const{onViewportChange:B}=N.getState();if(N.setState({transform:[k.transform.x,k.transform.y,k.transform.k]}),C.current=!(!o||!Hv(h,F.current??0)),(t||B)&&!((E=k.sourceEvent)!=null&&E.internal)){const U=Pl(k.transform);B==null||B(U),t==null||t(k.sourceEvent,U)}}))},[M,I,t,h,o]),O.useEffect(()=>{I&&I.on("end",k=>{if(!k.sourceEvent||k.sourceEvent.internal)return null;const{onViewportChangeEnd:B}=N.getState();if(j.current=!1,N.setState({paneDragging:!1}),o&&Hv(h,F.current??0)&&!C.current&&o(k.sourceEvent),C.current=!1,(n||B)&&(E=A.current,U=k.transform,E.x!==U.x||E.y!==U.y||E.zoom!==U.k)){const V=Pl(k.transform);A.current=V,clearTimeout(S.current),S.current=setTimeout(()=>{B==null||B(V),n==null||n(k.sourceEvent,V)},a?150:0)}var E,U})},[I,a,h,n,o]),O.useEffect(()=>{I&&I.filter(k=>{const B=L||r,E=s&&k.ctrlKey;if((h===!0||Array.isArray(h)&&h.includes(1))&&k.button===1&&k.type==="mousedown"&&(Jr(k,"react-flow__node")||Jr(k,"react-flow__edge")))return!0;if(!(h||B||a||d||s)||M||!d&&k.type==="dblclick"||Jr(k,v)&&k.type==="wheel"||Jr(k,w)&&(k.type!=="wheel"||a&&k.type==="wheel"&&!L)||!s&&k.ctrlKey&&k.type==="wheel"||!B&&!a&&!E&&k.type==="wheel"||!h&&(k.type==="mousedown"||k.type==="touchstart")||Array.isArray(h)&&!h.includes(k.button)&&k.type==="mousedown")return!1;const U=Array.isArray(h)&&h.includes(k.button)||!k.button||k.button<=1;return(!k.ctrlKey||k.type==="wheel")&&U})},[M,I,r,s,a,d,h,u,L]),G.createElement("div",{className:"react-flow__renderer",ref:_,style:Rh},y)},NA=t=>({userSelectionActive:t.userSelectionActive,userSelectionRect:t.userSelectionRect});function jA(){const{userSelectionActive:t,userSelectionRect:e}=at(NA,$t);return t&&e?G.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:e.width,height:e.height,transform:`translate(${e.x}px, ${e.y}px)`}}):null}function qv(t,e){const n=e.parentNode||e.parentId,o=t.find(r=>r.id===n);if(o){const r=e.position.x+e.width-o.width,s=e.position.y+e.height-o.height;if(r>0||s>0||e.position.x<0||e.position.y<0){if(o.style={...o.style},o.style.width=o.style.width??o.width,o.style.height=o.style.height??o.height,r>0&&(o.style.width+=r),s>0&&(o.style.height+=s),e.position.x<0){const a=Math.abs(e.position.x);o.position.x=o.position.x-a,o.style.width+=a,e.position.x=0}if(e.position.y<0){const a=Math.abs(e.position.y);o.position.y=o.position.y-a,o.style.height+=a,e.position.y=0}o.width=o.style.width,o.height=o.style.height}}}function Gv(t,e){if(t.some(o=>o.type==="reset"))return t.filter(o=>o.type==="reset").map(o=>o.item);const n=t.filter(o=>o.type==="add").map(o=>o.item);return e.reduce((o,r)=>{const s=t.filter(i=>i.id===r.id);if(s.length===0)return o.push(r),o;const a={...r};for(const i of s)if(i)switch(i.type){case"select":a.selected=i.selected;break;case"position":i.position!==void 0&&(a.position=i.position),i.positionAbsolute!==void 0&&(a.positionAbsolute=i.positionAbsolute),i.dragging!==void 0&&(a.dragging=i.dragging),a.expandParent&&qv(o,a);break;case"dimensions":i.dimensions!==void 0&&(a.width=i.dimensions.width,a.height=i.dimensions.height),i.updateStyle!==void 0&&(a.style={...a.style||{},...i.dimensions}),typeof i.resizing=="boolean"&&(a.resizing=i.resizing),a.expandParent&&qv(o,a);break;case"remove":return o}return o.push(a),o},n)}function Yv(t,e){return Gv(t,e)}const Bo=(t,e)=>({id:t,type:"select",selected:e});function Zr(t,e){return t.reduce((n,o)=>{const r=e.includes(o.id);return!o.selected&&r?(o.selected=!0,n.push(Bo(o.id,!0))):o.selected&&!r&&(o.selected=!1,n.push(Bo(o.id,!1))),n},[])}const Lh=(t,e)=>n=>{n.target===e.current&&(t==null||t(n))},CA=t=>({userSelectionActive:t.userSelectionActive,elementsSelectable:t.elementsSelectable,dragging:t.paneDragging}),Kv=O.memo(({isSelecting:t,selectionMode:e=xa.Full,panOnDrag:n,onSelectionStart:o,onSelectionEnd:r,onPaneClick:s,onPaneContextMenu:a,onPaneScroll:i,onPaneMouseEnter:l,onPaneMouseMove:d,onPaneMouseLeave:u,children:h})=>{const f=O.useRef(null),m=Lt(),x=O.useRef(0),g=O.useRef(0),p=O.useRef(),{userSelectionActive:b,elementsSelectable:y,dragging:v}=at(CA,$t),w=()=>{m.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,g.current=0},S=C=>{s==null||s(C),m.getState().resetSelectedElements(),m.setState({nodesSelectionActive:!1})},N=i?C=>i(C):void 0,j=y&&(t||b);return G.createElement("div",{className:Kt(["react-flow__pane",{dragging:v,selection:t}]),onClick:j?void 0:Lh(S,f),onContextMenu:Lh(C=>{Array.isArray(n)&&(n!=null&&n.includes(2))?C.preventDefault():a==null||a(C)},f),onWheel:Lh(N,f),onMouseEnter:j?void 0:l,onMouseDown:j?C=>{const{resetSelectedElements:_,domNode:A}=m.getState();if(p.current=A==null?void 0:A.getBoundingClientRect(),!y||!t||C.button!==0||C.target!==f.current||!p.current)return;const{x:I,y:P}=Ro(C,p.current);_(),m.setState({userSelectionRect:{width:0,height:0,startX:I,startY:P,x:I,y:P}}),o==null||o(C)}:void 0,onMouseMove:j?C=>{const{userSelectionRect:_,nodeInternals:A,edges:I,transform:P,onNodesChange:R,onEdgesChange:M,nodeOrigin:L,getNodes:F}=m.getState();if(!t||!p.current||!_)return;m.setState({userSelectionActive:!0,nodesSelectionActive:!1});const D=Ro(C,p.current),T=_.startX??0,k=_.startY??0,B={..._,x:D.x<T?D.x:T,y:D.y<k?D.y:k,width:Math.abs(D.x-T),height:Math.abs(D.y-k)},E=F(),U=wv(A,B,P,e===xa.Partial,!0,L),V=kv(U,I).map(X=>X.id),$=U.map(X=>X.id);if(x.current!==$.length){x.current=$.length;const X=Zr(E,$);X.length&&(R==null||R(X))}if(g.current!==V.length){g.current=V.length;const X=Zr(I,V);X.length&&(M==null||M(X))}m.setState({userSelectionRect:B})}:d,onMouseUp:j?C=>{if(C.button!==0)return;const{userSelectionRect:_}=m.getState();!b&&_&&C.target===f.current&&(S==null||S(C)),m.setState({nodesSelectionActive:x.current>0}),w(),r==null||r(C)}:void 0,onMouseLeave:j?C=>{b&&(m.setState({nodesSelectionActive:x.current>0}),r==null||r(C)),w()}:u,ref:f,style:Rh},h,G.createElement(jA,null))});function Xv(t,e){const n=t.parentNode||t.parentId;if(!n)return!1;const o=e.get(n);return!!o&&(!!o.selected||Xv(o,e))}function Jv(t,e,n){let o=t;do{if(o!=null&&o.matches(e))return!0;if(o===n.current)return!1;o=o.parentElement}while(o);return!1}function EA(t,e,n,o){return Array.from(t.values()).filter(r=>(r.selected||r.id===o)&&(!r.parentNode||r.parentId||!Xv(r,t))&&(r.draggable||e&&r.draggable===void 0)).map(r=>{var s,a;return{id:r.id,position:r.position||{x:0,y:0},positionAbsolute:r.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((s=r.positionAbsolute)==null?void 0:s.x)??0),y:n.y-(((a=r.positionAbsolute)==null?void 0:a.y)??0)},delta:{x:0,y:0},extent:r.extent,parentNode:r.parentNode||r.parentId,parentId:r.parentNode||r.parentId,width:r.width,height:r.height,expandParent:r.expandParent}})}function Zv(t,e,n,o,r=[0,0],s){const a=function(h,f){return f&&f!=="parent"?[f[0],[f[1][0]-(h.width||0),f[1][1]-(h.height||0)]]:f}(t,t.extent||o);let i=a;const l=t.parentNode||t.parentId;if(t.extent!=="parent"||t.expandParent){if(t.extent&&l&&t.extent!=="parent"){const h=n.get(l),{x:f,y:m}=Yr(h,r).positionAbsolute;i=[[t.extent[0][0]+f,t.extent[0][1]+m],[t.extent[1][0]+f,t.extent[1][1]+m]]}}else if(l&&t.width&&t.height){const h=n.get(l),{x:f,y:m}=Yr(h,r).positionAbsolute;i=h&&kn(f)&&kn(m)&&kn(h.width)&&kn(h.height)?[[f+t.width*r[0],m+t.height*r[1]],[f+h.width-t.width+t.width*r[0],m+h.height-t.height+t.height*r[1]]]:i}else s==null||s("005",q8()),i=a;let d={x:0,y:0};if(l){const h=n.get(l);d=Yr(h,r).positionAbsolute}const u=i&&i!=="parent"?bh(e,i):e;return{position:{x:u.x-d.x,y:u.y-d.y},positionAbsolute:u}}function Fh({nodeId:t,dragItems:e,nodeInternals:n}){const o=e.map(r=>({...n.get(r.id),position:r.position,positionAbsolute:r.positionAbsolute}));return[t?o.find(r=>r.id===t):o[0],o]}Kv.displayName="Pane";const Qv=(t,e,n,o)=>{const r=e.querySelectorAll(t);if(!r||!r.length)return null;const s=Array.from(r),a=e.getBoundingClientRect(),i=a.width*o[0],l=a.height*o[1];return s.map(d=>{const u=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(u.left-a.left-i)/n,y:(u.top-a.top-l)/n,...xh(d)}})};function wa(t,e,n){return n===void 0?n:o=>{const r=e().nodeInternals.get(t);r&&n(o,{...r})}}function zh({id:t,store:e,unselect:n=!1,nodeRef:o}){const{addSelectedNodes:r,unselectNodesAndEdges:s,multiSelectionActive:a,nodeInternals:i,onError:l}=e.getState(),d=i.get(t);d?(e.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(s({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var u;return(u=o==null?void 0:o.current)==null?void 0:u.blur()})):r([t])):l==null||l("012",J8(t))}function Bh(t){return(e,n,o)=>t==null?void 0:t(e,o)}function e2({nodeRef:t,disabled:e=!1,noDragClassName:n,handleSelector:o,nodeId:r,isSelectable:s,selectNodesOnDrag:a}){const i=Lt(),[l,d]=O.useState(!1),u=O.useRef([]),h=O.useRef({x:null,y:null}),f=O.useRef(0),m=O.useRef(null),x=O.useRef({x:0,y:0}),g=O.useRef(null),p=O.useRef(!1),b=O.useRef(!1),y=O.useRef(!1),v=function(){const w=Lt();return O.useCallback(({sourceEvent:N})=>{const{transform:j,snapGrid:C,snapToGrid:_}=w.getState(),A=N.touches?N.touches[0].clientX:N.clientX,I=N.touches?N.touches[0].clientY:N.clientY,P={x:(A-j[0])/j[2],y:(I-j[1])/j[2]};return{xSnapped:_?C[0]*Math.round(P.x/C[0]):P.x,ySnapped:_?C[1]*Math.round(P.y/C[1]):P.y,...P}},[])}();return O.useEffect(()=>{if(t!=null&&t.current){const w=Ln(t.current),S=({x:C,y:_})=>{const{nodeInternals:A,onNodeDrag:I,onSelectionDrag:P,updateNodePositions:R,nodeExtent:M,snapGrid:L,snapToGrid:F,nodeOrigin:D,onError:T}=i.getState();h.current={x:C,y:_};let k=!1,B={x:0,y:0,x2:0,y2:0};if(u.current.length>1&&M){const U=Ah(u.current,D);B=yh(U)}if(u.current=u.current.map(U=>{const V={x:C-U.distance.x,y:_-U.distance.y};F&&(V.x=L[0]*Math.round(V.x/L[0]),V.y=L[1]*Math.round(V.y/L[1]));const $=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];u.current.length>1&&M&&!U.extent&&($[0][0]=U.positionAbsolute.x-B.x+M[0][0],$[1][0]=U.positionAbsolute.x+(U.width??0)-B.x2+M[1][0],$[0][1]=U.positionAbsolute.y-B.y+M[0][1],$[1][1]=U.positionAbsolute.y+(U.height??0)-B.y2+M[1][1]);const X=Zv(U,V,A,$,D,T);return k=k||U.position.x!==X.position.x||U.position.y!==X.position.y,U.position=X.position,U.positionAbsolute=X.positionAbsolute,U}),!k)return;R(u.current,!0,!0),d(!0);const E=r?I:Bh(P);if(E&&g.current){const[U,V]=Fh({nodeId:r,dragItems:u.current,nodeInternals:A});E(g.current,U,V)}},N=()=>{if(!m.current)return;const[C,_]=rv(x.current,m.current);if(C!==0||_!==0){const{transform:A,panBy:I}=i.getState();h.current.x=(h.current.x??0)-C/A[2],h.current.y=(h.current.y??0)-_/A[2],I({x:C,y:_})&&S(h.current)}f.current=requestAnimationFrame(N)},j=C=>{var D;const{nodeInternals:_,multiSelectionActive:A,nodesDraggable:I,unselectNodesAndEdges:P,onNodeDragStart:R,onSelectionDragStart:M}=i.getState();b.current=!0;const L=r?R:Bh(M);a&&s||A||!r||(D=_.get(r))!=null&&D.selected||P(),r&&s&&a&&zh({id:r,store:i,nodeRef:t});const F=v(C);if(h.current=F,u.current=EA(_,I,F,r),L&&u.current){const[T,k]=Fh({nodeId:r,dragItems:u.current,nodeInternals:_});L(C.sourceEvent,T,k)}};if(!e){const C=function(){var _,A,I,P,R=O8,M=D8,L=P8,F=R8,D={},T=PS("start","drag","end"),k=0,B=0;function E(q){q.on("mousedown.drag",U).filter(F).on("touchstart.drag",X).on("touchmove.drag",Y,M8).on("touchend.drag touchcancel.drag",J).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function U(q,K){if(!P&&R.call(this,q,K)){var re=Q(this,M.call(this,q,K),q,K,"mouse");re&&(Ln(q.view).on("mousemove.drag",V,fa).on("mouseup.drag",$,fa),Qy(q.view),mh(q),I=!1,_=q.clientX,A=q.clientY,re("start",q))}}function V(q){if(Wr(q),!I){var K=q.clientX-_,re=q.clientY-A;I=K*K+re*re>B}D.mouse("drag",q)}function $(q){Ln(q.view).on("mousemove.drag mouseup.drag",null),ev(q.view,I),Wr(q),D.mouse("end",q)}function X(q,K){if(R.call(this,q,K)){var re,oe,ne=q.changedTouches,se=M.call(this,q,K),te=ne.length;for(re=0;re<te;++re)(oe=Q(this,se,q,K,ne[re].identifier,ne[re]))&&(mh(q),oe("start",q,ne[re]))}}function Y(q){var K,re,oe=q.changedTouches,ne=oe.length;for(K=0;K<ne;++K)(re=D[oe[K].identifier])&&(Wr(q),re("drag",q,oe[K]))}function J(q){var K,re,oe=q.changedTouches,ne=oe.length;for(P&&clearTimeout(P),P=setTimeout(function(){P=null},500),K=0;K<ne;++K)(re=D[oe[K].identifier])&&(mh(q),re("end",q,oe[K]))}function Q(q,K,re,oe,ne,se){var te,pe,he,ae=T.copy(),ye=Hn(se||re,K);if((he=L.call(q,new ph("beforestart",{sourceEvent:re,target:E,identifier:ne,active:k,x:ye[0],y:ye[1],dx:0,dy:0,dispatch:ae}),oe))!=null)return te=he.x-ye[0]||0,pe=he.y-ye[1]||0,function fe(Se,Me,Ee){var Le,Te=ye;switch(Se){case"start":D[ne]=fe,Le=k++;break;case"end":delete D[ne],--k;case"drag":ye=Hn(Ee||Me,K),Le=k}ae.call(Se,q,new ph(Se,{sourceEvent:Me,subject:he,target:E,identifier:ne,active:Le,x:ye[0]+te,y:ye[1]+pe,dx:ye[0]-Te[0],dy:ye[1]-Te[1],dispatch:ae}),oe)}}return E.filter=function(q){return arguments.length?(R=typeof q=="function"?q:Nl(!!q),E):R},E.container=function(q){return arguments.length?(M=typeof q=="function"?q:Nl(q),E):M},E.subject=function(q){return arguments.length?(L=typeof q=="function"?q:Nl(q),E):L},E.touchable=function(q){return arguments.length?(F=typeof q=="function"?q:Nl(!!q),E):F},E.on=function(){var q=T.on.apply(T,arguments);return q===T?E:q},E.clickDistance=function(q){return arguments.length?(B=(q=+q)*q,E):Math.sqrt(B)},E}().on("start",_=>{const{domNode:A,nodeDragThreshold:I}=i.getState();I===0&&j(_),y.current=!1;const P=v(_);h.current=P,m.current=(A==null?void 0:A.getBoundingClientRect())||null,x.current=Ro(_.sourceEvent,m.current)}).on("drag",_=>{var R,M;const A=v(_),{autoPanOnNodeDrag:I,nodeDragThreshold:P}=i.getState();if(_.sourceEvent.type==="touchmove"&&_.sourceEvent.touches.length>1&&(y.current=!0),!y.current){if(!p.current&&b.current&&I&&(p.current=!0,N()),!b.current){const L=A.xSnapped-(((R=h==null?void 0:h.current)==null?void 0:R.x)??0),F=A.ySnapped-(((M=h==null?void 0:h.current)==null?void 0:M.y)??0);Math.sqrt(L*L+F*F)>P&&j(_)}(h.current.x!==A.xSnapped||h.current.y!==A.ySnapped)&&u.current&&b.current&&(g.current=_.sourceEvent,x.current=Ro(_.sourceEvent,m.current),S(A))}}).on("end",_=>{if(b.current&&!y.current&&(d(!1),p.current=!1,b.current=!1,cancelAnimationFrame(f.current),u.current)){const{updateNodePositions:A,nodeInternals:I,onNodeDragStop:P,onSelectionDragStop:R}=i.getState(),M=r?P:Bh(R);if(A(u.current,!1,!1),M){const[L,F]=Fh({nodeId:r,dragItems:u.current,nodeInternals:I});M(_.sourceEvent,L,F)}}}).filter(_=>{const A=_.target;return!_.button&&(!n||!Jv(A,`.${n}`,t))&&(!o||Jv(A,o,t))});return w.call(C),()=>{w.on(".drag",null)}}w.on(".drag",null)}},[t,e,n,o,s,i,r,a,v]),l}function t2(){const t=Lt();return O.useCallback(n=>{const{nodeInternals:o,nodeExtent:r,updateNodePositions:s,getNodes:a,snapToGrid:i,snapGrid:l,onError:d,nodesDraggable:u}=t.getState(),h=a().filter(y=>y.selected&&(y.draggable||u&&y.draggable===void 0)),f=i?l[0]:5,m=i?l[1]:5,x=n.isShiftPressed?4:1,g=n.x*f*x,p=n.y*m*x,b=h.map(y=>{if(y.positionAbsolute){const v={x:y.positionAbsolute.x+g,y:y.positionAbsolute.y+p};i&&(v.x=l[0]*Math.round(v.x/l[0]),v.y=l[1]*Math.round(v.y/l[1]));const{positionAbsolute:w,position:S}=Zv(y,v,o,r,void 0,d);y.position=S,y.positionAbsolute=w}return y});s(b,!0,!1)},[])}const Qr={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ka=t=>{const e=({id:n,type:o,data:r,xPos:s,yPos:a,xPosOrigin:i,yPosOrigin:l,selected:d,onClick:u,onMouseEnter:h,onMouseMove:f,onMouseLeave:m,onContextMenu:x,onDoubleClick:g,style:p,className:b,isDraggable:y,isSelectable:v,isConnectable:w,isFocusable:S,selectNodesOnDrag:N,sourcePosition:j,targetPosition:C,hidden:_,resizeObserver:A,dragHandle:I,zIndex:P,isParent:R,noDragClassName:M,noPanClassName:L,initialized:F,disableKeyboardA11y:D,ariaLabel:T,rfId:k,hasHandleBounds:B})=>{const E=Lt(),U=O.useRef(null),V=O.useRef(null),$=O.useRef(j),X=O.useRef(C),Y=O.useRef(o),J=v||y||u||h||f||m,Q=t2(),q=wa(n,E.getState,h),K=wa(n,E.getState,f),re=wa(n,E.getState,m),oe=wa(n,E.getState,x),ne=wa(n,E.getState,g);O.useEffect(()=>()=>{V.current&&(A==null||A.unobserve(V.current),V.current=null)},[]),O.useEffect(()=>{if(U.current&&!_){const te=U.current;F&&B&&V.current===te||(V.current&&(A==null||A.unobserve(V.current)),A==null||A.observe(te),V.current=te)}},[_,F,B]),O.useEffect(()=>{const te=Y.current!==o,pe=$.current!==j,he=X.current!==C;U.current&&(te||pe||he)&&(te&&(Y.current=o),pe&&($.current=j),he&&(X.current=C),E.getState().updateNodeDimensions([{id:n,nodeElement:U.current,forceUpdate:!0}]))},[n,o,j,C]);const se=e2({nodeRef:U,disabled:_||!y,noDragClassName:M,handleSelector:I,nodeId:n,isSelectable:v,selectNodesOnDrag:N});return _?null:G.createElement("div",{className:Kt(["react-flow__node",`react-flow__node-${o}`,{[L]:y},b,{selected:d,selectable:v,parent:R,dragging:se}]),ref:U,style:{zIndex:P,transform:`translate(${i}px,${l}px)`,pointerEvents:J?"all":"none",visibility:F?"visible":"hidden",...p},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:q,onMouseMove:K,onMouseLeave:re,onContextMenu:oe,onClick:te=>{const{nodeDragThreshold:pe}=E.getState();if(v&&(!N||!y||pe>0)&&zh({id:n,store:E,nodeRef:U}),u){const he=E.getState().nodeInternals.get(n);he&&u(te,{...he})}},onDoubleClick:ne,onKeyDown:S?te=>{if(!wh(te)&&!D)if(iv.includes(te.key)&&v){const pe=te.key==="Escape";zh({id:n,store:E,unselect:pe,nodeRef:U})}else y&&d&&Object.prototype.hasOwnProperty.call(Qr,te.key)&&(E.setState({ariaLiveMessage:`Moved selected node ${te.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~s}, y: ${~~a}`}),Q({x:Qr[te.key].x,y:Qr[te.key].y,isShiftPressed:te.shiftKey}))}:void 0,tabIndex:S?0:void 0,role:S?"button":void 0,"aria-describedby":D?void 0:`${Lv}-${k}`,"aria-label":T},G.createElement(nA,{value:n},G.createElement(t,{id:n,data:r,type:o,xPos:s,yPos:a,selected:d,isConnectable:w,sourcePosition:j,targetPosition:C,dragging:se,dragHandle:I,zIndex:P})))};return e.displayName="NodeWrapper",O.memo(e)};const _A=t=>{const e=t.getNodes().filter(n=>n.selected);return{...Ah(e,t.nodeOrigin),transformString:`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`,userSelectionActive:t.userSelectionActive}};var IA=O.memo(function({onSelectionContextMenu:t,noPanClassName:e,disableKeyboardA11y:n}){const o=Lt(),{width:r,height:s,x:a,y:i,transformString:l,userSelectionActive:d}=at(_A,$t),u=t2(),h=O.useRef(null);if(O.useEffect(()=>{var m;n||((m=h.current)==null||m.focus({preventScroll:!0}))},[n]),e2({nodeRef:h}),d||!r||!s)return null;const f=t?m=>{const x=o.getState().getNodes().filter(g=>g.selected);t(m,x)}:void 0;return G.createElement("div",{className:Kt(["react-flow__nodesselection","react-flow__container",e]),style:{transform:l}},G.createElement("div",{ref:h,className:"react-flow__nodesselection-rect",onContextMenu:f,tabIndex:n?void 0:-1,onKeyDown:n?void 0:m=>{Object.prototype.hasOwnProperty.call(Qr,m.key)&&u({x:Qr[m.key].x,y:Qr[m.key].y,isShiftPressed:m.shiftKey})},style:{width:r,height:s,top:i,left:a}}))});const AA=t=>t.nodesSelectionActive,n2=({children:t,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,deleteKeyCode:i,onMove:l,onMoveStart:d,onMoveEnd:u,selectionKeyCode:h,selectionOnDrag:f,selectionMode:m,onSelectionStart:x,onSelectionEnd:g,multiSelectionKeyCode:p,panActivationKeyCode:b,zoomActivationKeyCode:y,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:S,panOnScroll:N,panOnScrollSpeed:j,panOnScrollMode:C,zoomOnDoubleClick:_,panOnDrag:A,defaultViewport:I,translateExtent:P,minZoom:R,maxZoom:M,preventScrolling:L,onSelectionContextMenu:F,noWheelClassName:D,noPanClassName:T,disableKeyboardA11y:k})=>{const B=at(AA),E=ya(h),U=ya(b),V=U||A,$=U||N,X=E||f&&V!==!0;return(({deleteKeyCode:Y,multiSelectionKeyCode:J})=>{const Q=Lt(),{deleteElements:q}=va(),K=ya(Y,wA),re=ya(J);O.useEffect(()=>{if(K){const{edges:oe,getNodes:ne}=Q.getState(),se=ne().filter(pe=>pe.selected),te=oe.filter(pe=>pe.selected);q({nodes:se,edges:te}),Q.setState({nodesSelectionActive:!1})}},[K]),O.useEffect(()=>{Q.setState({multiSelectionActive:re})},[re])})({deleteKeyCode:i,multiSelectionKeyCode:p}),G.createElement(SA,{onMove:l,onMoveStart:d,onMoveEnd:u,onPaneContextMenu:s,elementsSelectable:v,zoomOnScroll:w,zoomOnPinch:S,panOnScroll:$,panOnScrollSpeed:j,panOnScrollMode:C,zoomOnDoubleClick:_,panOnDrag:!E&&V,defaultViewport:I,translateExtent:P,minZoom:R,maxZoom:M,zoomActivationKeyCode:y,preventScrolling:L,noWheelClassName:D,noPanClassName:T},G.createElement(Kv,{onSelectionStart:x,onSelectionEnd:g,onPaneClick:e,onPaneMouseEnter:n,onPaneMouseMove:o,onPaneMouseLeave:r,onPaneContextMenu:s,onPaneScroll:a,panOnDrag:V,isSelecting:!!X,selectionMode:m},t,B&&G.createElement(IA,{onSelectionContextMenu:F,noPanClassName:T,disableKeyboardA11y:k})))};n2.displayName="FlowRenderer";var TA=O.memo(n2);function MA(t){return{input:ka(t.input||Mv),default:ka(t.default||Oh),output:ka(t.output||Dv),group:ka(t.group||Dh),...Object.keys(t).filter(e=>!["input","default","output","group"].includes(e)).reduce((e,n)=>(e[n]=ka(t[n]||Oh),e),{})}}const OA=t=>({nodesDraggable:t.nodesDraggable,nodesConnectable:t.nodesConnectable,nodesFocusable:t.nodesFocusable,elementsSelectable:t.elementsSelectable,updateNodeDimensions:t.updateNodeDimensions,onError:t.onError}),o2=t=>{const{nodesDraggable:e,nodesConnectable:n,nodesFocusable:o,elementsSelectable:r,updateNodeDimensions:s,onError:a}=at(OA,$t),i=(l=t.onlyRenderVisibleElements,at(O.useCallback(h=>l?wv(h.nodeInternals,{x:0,y:0,width:h.width,height:h.height},h.transform,!0):h.getNodes(),[l])));var l;const d=O.useRef(),u=O.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(f=>{const m=f.map(x=>({id:x.target.getAttribute("data-id"),nodeElement:x.target,forceUpdate:!0}));s(m)});return d.current=h,h},[]);return O.useEffect(()=>()=>{var h;(h=d==null?void 0:d.current)==null||h.disconnect()},[]),G.createElement("div",{className:"react-flow__nodes",style:Rh},i.map(h=>{var N,j,C;let f=h.type||"default";t.nodeTypes[f]||(a==null||a("003",H8(f)),f="default");const m=t.nodeTypes[f]||t.nodeTypes.default,x=!!(h.draggable||e&&h.draggable===void 0),g=!!(h.selectable||r&&h.selectable===void 0),p=!!(h.connectable||n&&h.connectable===void 0),b=!!(h.focusable||o&&h.focusable===void 0),y=t.nodeExtent?bh(h.positionAbsolute,t.nodeExtent):h.positionAbsolute,v=(y==null?void 0:y.x)??0,w=(y==null?void 0:y.y)??0,S=(({x:_,y:A,width:I,height:P,origin:R})=>I&&P?R[0]<0||R[1]<0||R[0]>1||R[1]>1?{x:_,y:A}:{x:_-I*R[0],y:A-P*R[1]}:{x:_,y:A})({x:v,y:w,width:h.width??0,height:h.height??0,origin:t.nodeOrigin});return G.createElement(m,{key:h.id,id:h.id,className:h.className,style:h.style,type:f,data:h.data,sourcePosition:h.sourcePosition||De.Bottom,targetPosition:h.targetPosition||De.Top,hidden:h.hidden,xPos:v,yPos:w,xPosOrigin:S.x,yPosOrigin:S.y,selectNodesOnDrag:t.selectNodesOnDrag,onClick:t.onNodeClick,onMouseEnter:t.onNodeMouseEnter,onMouseMove:t.onNodeMouseMove,onMouseLeave:t.onNodeMouseLeave,onContextMenu:t.onNodeContextMenu,onDoubleClick:t.onNodeDoubleClick,selected:!!h.selected,isDraggable:x,isSelectable:g,isConnectable:p,isFocusable:b,resizeObserver:u,dragHandle:h.dragHandle,zIndex:((N=h[bt])==null?void 0:N.z)??0,isParent:!!((j=h[bt])!=null&&j.isParent),noDragClassName:t.noDragClassName,noPanClassName:t.noPanClassName,initialized:!!h.width&&!!h.height,rfId:t.rfId,disableKeyboardA11y:t.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((C=h[bt])!=null&&C.handleBounds)})}))};o2.displayName="NodeRenderer";var DA=O.memo(o2);const PA=(t,e,n)=>n===De.Left?t-e:n===De.Right?t+e:t,RA=(t,e,n)=>n===De.Top?t-e:n===De.Bottom?t+e:t,r2="react-flow__edgeupdater",s2=({position:t,centerX:e,centerY:n,radius:o=10,onMouseDown:r,onMouseEnter:s,onMouseOut:a,type:i})=>G.createElement("circle",{onMouseDown:r,onMouseEnter:s,onMouseOut:a,className:Kt([r2,`${r2}-${i}`]),cx:PA(e,o,t),cy:RA(n,o,t),r:o,stroke:"transparent",fill:"transparent"}),LA=()=>!0;var es=t=>{const e=({id:n,className:o,type:r,data:s,onClick:a,onEdgeDoubleClick:i,selected:l,animated:d,label:u,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:x,labelBgBorderRadius:g,style:p,source:b,target:y,sourceX:v,sourceY:w,targetX:S,targetY:N,sourcePosition:j,targetPosition:C,elementsSelectable:_,hidden:A,sourceHandleId:I,targetHandleId:P,onContextMenu:R,onMouseEnter:M,onMouseMove:L,onMouseLeave:F,reconnectRadius:D,onReconnect:T,onReconnectStart:k,onReconnectEnd:B,markerEnd:E,markerStart:U,rfId:V,ariaLabel:$,isFocusable:X,isReconnectable:Y,pathOptions:J,interactionWidth:Q,disableKeyboardA11y:q})=>{const K=O.useRef(null),[re,oe]=O.useState(!1),[ne,se]=O.useState(!1),te=Lt(),pe=O.useMemo(()=>`url('#${_h(U,V)}')`,[U,V]),he=O.useMemo(()=>`url('#${_h(E,V)}')`,[E,V]);if(A)return null;const ae=ga(n,te.getState,i),ye=ga(n,te.getState,R),fe=ga(n,te.getState,M),Se=ga(n,te.getState,L),Me=ga(n,te.getState,F),Ee=(He,Ge)=>{if(He.button!==0)return;const{edges:ee,isValidConnection:be}=te.getState(),we=Ge?y:b,Ae=(Ge?P:I)||null,W=Ge?"target":"source",de=be||LA,ue=Ge,ce=ee.find(ve=>ve.id===n);se(!0),k==null||k(He,ce,W),Ev({event:He,handleId:Ae,nodeId:we,onConnect:ve=>T==null?void 0:T(ce,ve),isTarget:ue,getState:te.getState,setState:te.setState,isValidConnection:de,edgeUpdaterType:W,onReconnectEnd:ve=>{se(!1),B==null||B(ve,ce,W)}})},Le=()=>oe(!0),Te=()=>oe(!1),Ze=!_&&!a;return G.createElement("g",{className:Kt(["react-flow__edge",`react-flow__edge-${r}`,o,{selected:l,animated:d,inactive:Ze,updating:re}]),onClick:He=>{var W;const{edges:Ge,addSelectedEdges:ee,unselectNodesAndEdges:be,multiSelectionActive:we}=te.getState(),Ae=Ge.find(de=>de.id===n);Ae&&(_&&(te.setState({nodesSelectionActive:!1}),Ae.selected&&we?(be({nodes:[],edges:[Ae]}),(W=K.current)==null||W.blur()):ee([n])),a&&a(He,Ae))},onDoubleClick:ae,onContextMenu:ye,onMouseEnter:fe,onMouseMove:Se,onMouseLeave:Me,onKeyDown:X?He=>{var Ge;if(!q&&iv.includes(He.key)&&_){const{unselectNodesAndEdges:ee,addSelectedEdges:be,edges:we}=te.getState();He.key==="Escape"?((Ge=K.current)==null||Ge.blur(),ee({edges:[we.find(Ae=>Ae.id===n)]})):be([n])}}:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":$===null?void 0:$||`Edge from ${b} to ${y}`,"aria-describedby":X?`${Fv}-${V}`:void 0,ref:K},!ne&&G.createElement(t,{id:n,source:b,target:y,selected:l,animated:d,label:u,labelStyle:h,labelShowBg:f,labelBgStyle:m,labelBgPadding:x,labelBgBorderRadius:g,data:s,style:p,sourceX:v,sourceY:w,targetX:S,targetY:N,sourcePosition:j,targetPosition:C,sourceHandleId:I,targetHandleId:P,markerStart:pe,markerEnd:he,pathOptions:J,interactionWidth:Q}),Y&&G.createElement(G.Fragment,null,(Y==="source"||Y===!0)&&G.createElement(s2,{position:j,centerX:v,centerY:w,radius:D,onMouseDown:He=>Ee(He,!0),onMouseEnter:Le,onMouseOut:Te,type:"source"}),(Y==="target"||Y===!0)&&G.createElement(s2,{position:C,centerX:S,centerY:N,radius:D,onMouseDown:He=>Ee(He,!1),onMouseEnter:Le,onMouseOut:Te,type:"target"})))};return e.displayName="EdgeWrapper",O.memo(e)};function FA(t){return{default:es(t.default||Ml),straight:es(t.bezier||Ch),step:es(t.step||jh),smoothstep:es(t.step||Al),simplebezier:es(t.simplebezier||Sh),...Object.keys(t).filter(e=>!["default","bezier"].includes(e)).reduce((e,n)=>(e[n]=es(t[n]||Ml),e),{})}}function a2(t,e,n=null){const o=((n==null?void 0:n.x)||0)+e.x,r=((n==null?void 0:n.y)||0)+e.y,s=(n==null?void 0:n.width)||e.width,a=(n==null?void 0:n.height)||e.height;switch(t){case De.Top:return{x:o+s/2,y:r};case De.Right:return{x:o+s,y:r+a/2};case De.Bottom:return{x:o+s/2,y:r+a};case De.Left:return{x:o,y:r+a/2}}}function i2(t,e){return t?t.length!==1&&e?e&&t.find(n=>n.id===e)||null:t[0]:null}function l2(t){var o,r,s,a,i;const e=((o=t==null?void 0:t[bt])==null?void 0:o.handleBounds)||null,n=e&&(t==null?void 0:t.width)&&(t==null?void 0:t.height)&&((r=t==null?void 0:t.positionAbsolute)==null?void 0:r.x)!==void 0&&((s=t==null?void 0:t.positionAbsolute)==null?void 0:s.y)!==void 0;return[{x:((a=t==null?void 0:t.positionAbsolute)==null?void 0:a.x)||0,y:((i=t==null?void 0:t.positionAbsolute)==null?void 0:i.y)||0,width:(t==null?void 0:t.width)||0,height:(t==null?void 0:t.height)||0},e,!!n]}const zA=[{level:0,isMaxLevel:!0,edges:[]}];function BA(t,e,n){return function(o,r,s=!1){let a=-1;const i=o.reduce((d,u)=>{var m,x;const h=kn(u.zIndex);let f=h?u.zIndex:0;if(s){const g=r.get(u.target),p=r.get(u.source),b=u.selected||(g==null?void 0:g.selected)||(p==null?void 0:p.selected),y=Math.max(((m=p==null?void 0:p[bt])==null?void 0:m.z)||0,((x=g==null?void 0:g[bt])==null?void 0:x.z)||0,1e3);f=(h?u.zIndex:0)+(b?y:0)}return d[f]?d[f].push(u):d[f]=[u],a=f>a?f:a,d},{}),l=Object.entries(i).map(([d,u])=>{const h=+d;return{edges:u,level:h,isMaxLevel:h===a}});return l.length===0?zA:l}(at(O.useCallback(o=>t?o.edges.filter(r=>{const s=e.get(r.source),a=e.get(r.target);return(s==null?void 0:s.width)&&(s==null?void 0:s.height)&&(a==null?void 0:a.width)&&(a==null?void 0:a.height)&&function({sourcePos:i,targetPos:l,sourceWidth:d,sourceHeight:u,targetWidth:h,targetHeight:f,width:m,height:x,transform:g}){const p={x:Math.min(i.x,l.x),y:Math.min(i.y,l.y),x2:Math.max(i.x+d,l.x+h),y2:Math.max(i.y+u,l.y+f)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const b=yh({x:(0-g[0])/g[2],y:(0-g[1])/g[2],width:m/g[2],height:x/g[2]}),y=Math.max(0,Math.min(b.x2,p.x2)-Math.max(b.x,p.x)),v=Math.max(0,Math.min(b.y2,p.y2)-Math.max(b.y,p.y));return Math.ceil(y*v)>0}({sourcePos:s.positionAbsolute||{x:0,y:0},targetPos:a.positionAbsolute||{x:0,y:0},sourceWidth:s.width,sourceHeight:s.height,targetWidth:a.width,targetHeight:a.height,width:o.width,height:o.height,transform:o.transform})}):o.edges,[t,e])),e,n)}const c2={[Gr.Arrow]:({color:t="none",strokeWidth:e=1})=>G.createElement("polyline",{style:{stroke:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),[Gr.ArrowClosed]:({color:t="none",strokeWidth:e=1})=>G.createElement("polyline",{style:{stroke:t,fill:t,strokeWidth:e},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},UA=({id:t,type:e,color:n,width:o=12.5,height:r=12.5,markerUnits:s="strokeWidth",strokeWidth:a,orient:i="auto-start-reverse"})=>{const l=function(d){const u=Lt();return O.useMemo(()=>{var h,f;return Object.prototype.hasOwnProperty.call(c2,d)?c2[d]:((f=(h=u.getState()).onError)==null||f.call(h,"009",G8(d)),null)},[d])}(e);return l?G.createElement("marker",{className:"react-flow__arrowhead",id:t,markerWidth:`${o}`,markerHeight:`${r}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:i,refX:"0",refY:"0"},G.createElement(l,{color:n,strokeWidth:a})):null},d2=({defaultColor:t,rfId:e})=>{const n=at(O.useCallback((({defaultColor:o,rfId:r})=>s=>{const a=[];return s.edges.reduce((i,l)=>([l.markerStart,l.markerEnd].forEach(d=>{if(d&&typeof d=="object"){const u=_h(d,r);a.includes(u)||(i.push({id:u,color:d.color||o,...d}),a.push(u))}}),i),[]).sort((i,l)=>i.id.localeCompare(l.id))})({defaultColor:t,rfId:e}),[t,e]),(o,r)=>!(o.length!==r.length||o.some((s,a)=>s.id!==r[a].id)));return G.createElement("defs",null,n.map(o=>G.createElement(UA,{id:o.id,key:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient})))};d2.displayName="MarkerDefinitions";var $A=O.memo(d2);const VA=t=>({nodesConnectable:t.nodesConnectable,edgesFocusable:t.edgesFocusable,edgesUpdatable:t.edgesUpdatable,elementsSelectable:t.elementsSelectable,width:t.width,height:t.height,connectionMode:t.connectionMode,nodeInternals:t.nodeInternals,onError:t.onError}),u2=({defaultMarkerColor:t,onlyRenderVisibleElements:e,elevateEdgesOnSelect:n,rfId:o,edgeTypes:r,noPanClassName:s,onEdgeContextMenu:a,onEdgeMouseEnter:i,onEdgeMouseMove:l,onEdgeMouseLeave:d,onEdgeClick:u,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:x,reconnectRadius:g,children:p,disableKeyboardA11y:b})=>{const{edgesFocusable:y,edgesUpdatable:v,elementsSelectable:w,width:S,height:N,connectionMode:j,nodeInternals:C,onError:_}=at(VA,$t),A=BA(e,C,n);return S?G.createElement(G.Fragment,null,A.map(({level:I,edges:P,isMaxLevel:R})=>G.createElement("svg",{key:I,style:{zIndex:I},width:S,height:N,className:"react-flow__edges react-flow__container"},R&&G.createElement($A,{defaultColor:t,rfId:o}),G.createElement("g",null,P.map(M=>{const[L,F,D]=l2(C.get(M.source)),[T,k,B]=l2(C.get(M.target));if(!D||!B)return null;let E=M.type||"default";r[E]||(_==null||_("011",X8(E)),E="default");const U=r[E]||r.default,V=j===cr.Strict?k.target:(k.target??[]).concat(k.source??[]),$=i2(F.source,M.sourceHandle),X=i2(V,M.targetHandle),Y=($==null?void 0:$.position)||De.Bottom,J=(X==null?void 0:X.position)||De.Top,Q=!!(M.focusable||y&&M.focusable===void 0),q=M.reconnectable||M.updatable,K=f!==void 0&&(q||v&&q===void 0);if(!$||!X)return _==null||_("008",Y8($,M)),null;const{sourceX:re,sourceY:oe,targetX:ne,targetY:se}=((te,pe,he,ae,ye,fe)=>{const Se=a2(he,te,pe),Me=a2(fe,ae,ye);return{sourceX:Se.x,sourceY:Se.y,targetX:Me.x,targetY:Me.y}})(L,$,Y,T,X,J);return G.createElement(U,{key:M.id,id:M.id,className:Kt([M.className,s]),type:E,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:re,sourceY:oe,targetX:ne,targetY:se,sourcePosition:Y,targetPosition:J,elementsSelectable:w,onContextMenu:a,onMouseEnter:i,onMouseMove:l,onMouseLeave:d,onClick:u,onEdgeDoubleClick:h,onReconnect:f,onReconnectStart:m,onReconnectEnd:x,reconnectRadius:g,rfId:o,ariaLabel:M.ariaLabel,isFocusable:Q,isReconnectable:K,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:b})})))),p):null};u2.displayName="EdgeRenderer";var HA=O.memo(u2);const WA=t=>`translate(${t.transform[0]}px,${t.transform[1]}px) scale(${t.transform[2]})`;function qA({children:t}){const e=at(WA);return G.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:e}},t)}const GA={[De.Left]:De.Right,[De.Right]:De.Left,[De.Top]:De.Bottom,[De.Bottom]:De.Top},h2=({nodeId:t,handleType:e,style:n,type:o=Fo.Bezier,CustomComponent:r,connectionStatus:s})=>{var N,j,C;const{fromNode:a,handleId:i,toX:l,toY:d,connectionMode:u}=at(O.useCallback(_=>({fromNode:_.nodeInternals.get(t),handleId:_.connectionHandleId,toX:(_.connectionPosition.x-_.transform[0])/_.transform[2],toY:(_.connectionPosition.y-_.transform[1])/_.transform[2],connectionMode:_.connectionMode}),[t]),$t),h=(N=a==null?void 0:a[bt])==null?void 0:N.handleBounds;let f=h==null?void 0:h[e];if(u===cr.Loose&&(f=f||(h==null?void 0:h[e==="source"?"target":"source"])),!a||!f)return null;const m=i?f.find(_=>_.id===i):f[0],x=m?m.x+m.width/2:(a.width??0)/2,g=m?m.y+m.height/2:a.height??0,p=(((j=a.positionAbsolute)==null?void 0:j.x)??0)+x,b=(((C=a.positionAbsolute)==null?void 0:C.y)??0)+g,y=m==null?void 0:m.position,v=y?GA[y]:null;if(!y||!v)return null;if(r)return G.createElement(r,{connectionLineType:o,connectionLineStyle:n,fromNode:a,fromHandle:m,fromX:p,fromY:b,toX:l,toY:d,fromPosition:y,toPosition:v,connectionStatus:s});let w="";const S={sourceX:p,sourceY:b,sourcePosition:y,targetX:l,targetY:d,targetPosition:v};return o===Fo.Bezier?[w]=yv(S):o===Fo.Step?[w]=Nh({...S,borderRadius:0}):o===Fo.SmoothStep?[w]=Nh(S):o===Fo.SimpleBezier?[w]=pv(S):w=`M${p},${b} ${l},${d}`,G.createElement("path",{d:w,fill:"none",className:"react-flow__connection-path",style:n})};h2.displayName="ConnectionLine";const YA=t=>({nodeId:t.connectionNodeId,handleType:t.connectionHandleType,nodesConnectable:t.nodesConnectable,connectionStatus:t.connectionStatus,width:t.width,height:t.height});function KA({containerStyle:t,style:e,type:n,component:o}){const{nodeId:r,handleType:s,nodesConnectable:a,width:i,height:l,connectionStatus:d}=at(YA,$t);return r&&s&&i&&a?G.createElement("svg",{style:t,width:i,height:l,className:"react-flow__edges react-flow__connectionline react-flow__container"},G.createElement("g",{className:Kt(["react-flow__connection",d])},G.createElement(h2,{nodeId:r,handleType:s,style:e,type:n,CustomComponent:o,connectionStatus:d}))):null}function f2(t,e){return O.useRef(null),Lt(),O.useMemo(()=>e(t),[t])}const m2=({nodeTypes:t,edgeTypes:e,onMove:n,onMoveStart:o,onMoveEnd:r,onInit:s,onNodeClick:a,onEdgeClick:i,onNodeDoubleClick:l,onEdgeDoubleClick:d,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,onSelectionContextMenu:x,onSelectionStart:g,onSelectionEnd:p,connectionLineType:b,connectionLineStyle:y,connectionLineComponent:v,connectionLineContainerStyle:w,selectionKeyCode:S,selectionOnDrag:N,selectionMode:j,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:A,deleteKeyCode:I,onlyRenderVisibleElements:P,elementsSelectable:R,selectNodesOnDrag:M,defaultViewport:L,translateExtent:F,minZoom:D,maxZoom:T,preventScrolling:k,defaultMarkerColor:B,zoomOnScroll:E,zoomOnPinch:U,panOnScroll:V,panOnScrollSpeed:$,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:J,onPaneClick:Q,onPaneMouseEnter:q,onPaneMouseMove:K,onPaneMouseLeave:re,onPaneScroll:oe,onPaneContextMenu:ne,onEdgeContextMenu:se,onEdgeMouseEnter:te,onEdgeMouseMove:pe,onEdgeMouseLeave:he,onReconnect:ae,onReconnectStart:ye,onReconnectEnd:fe,reconnectRadius:Se,noDragClassName:Me,noWheelClassName:Ee,noPanClassName:Le,elevateEdgesOnSelect:Te,disableKeyboardA11y:Ze,nodeOrigin:He,nodeExtent:Ge,rfId:ee})=>{const be=f2(t,MA),we=f2(e,FA);return function(Ae){const W=va(),de=O.useRef(!1);O.useEffect(()=>{!de.current&&W.viewportInitialized&&Ae&&(setTimeout(()=>Ae(W),1),de.current=!0)},[Ae,W.viewportInitialized])}(s),G.createElement(TA,{onPaneClick:Q,onPaneMouseEnter:q,onPaneMouseMove:K,onPaneMouseLeave:re,onPaneContextMenu:ne,onPaneScroll:oe,deleteKeyCode:I,selectionKeyCode:S,selectionOnDrag:N,selectionMode:j,onSelectionStart:g,onSelectionEnd:p,multiSelectionKeyCode:C,panActivationKeyCode:_,zoomActivationKeyCode:A,elementsSelectable:R,onMove:n,onMoveStart:o,onMoveEnd:r,zoomOnScroll:E,zoomOnPinch:U,zoomOnDoubleClick:Y,panOnScroll:V,panOnScrollSpeed:$,panOnScrollMode:X,panOnDrag:J,defaultViewport:L,translateExtent:F,minZoom:D,maxZoom:T,onSelectionContextMenu:x,preventScrolling:k,noDragClassName:Me,noWheelClassName:Ee,noPanClassName:Le,disableKeyboardA11y:Ze},G.createElement(qA,null,G.createElement(HA,{edgeTypes:we,onEdgeClick:i,onEdgeDoubleClick:d,onlyRenderVisibleElements:P,onEdgeContextMenu:se,onEdgeMouseEnter:te,onEdgeMouseMove:pe,onEdgeMouseLeave:he,onReconnect:ae,onReconnectStart:ye,onReconnectEnd:fe,reconnectRadius:Se,defaultMarkerColor:B,noPanClassName:Le,elevateEdgesOnSelect:!!Te,disableKeyboardA11y:Ze,rfId:ee},G.createElement(KA,{style:y,type:b,component:v,containerStyle:w})),G.createElement("div",{className:"react-flow__edgelabel-renderer"}),G.createElement(DA,{nodeTypes:be,onNodeClick:a,onNodeDoubleClick:l,onNodeMouseEnter:u,onNodeMouseMove:h,onNodeMouseLeave:f,onNodeContextMenu:m,selectNodesOnDrag:M,onlyRenderVisibleElements:P,noPanClassName:Le,noDragClassName:Me,disableKeyboardA11y:Ze,nodeOrigin:He,nodeExtent:Ge,rfId:ee})))};m2.displayName="GraphView";var XA=O.memo(m2);const Uh=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Uo={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:Uh,nodeExtent:Uh,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:cr.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:(t,e)=>{},isValidConnection:void 0},JA=()=>((t,e)=>t?Zy(t,e):Zy)((t,e)=>({...Uo,setNodes:n=>{const{nodeInternals:o,nodeOrigin:r,elevateNodesOnSelect:s}=e();t({nodeInternals:Ph(n,o,r,s)})},getNodes:()=>Array.from(e().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:o={}}=e();t({edges:n.map(r=>({...o,...r}))})},setDefaultNodesAndEdges:(n,o)=>{const r=n!==void 0,s=o!==void 0,a=r?Ph(n,new Map,e().nodeOrigin,e().elevateNodesOnSelect):new Map;t({nodeInternals:a,edges:s?o:[],hasDefaultNodes:r,hasDefaultEdges:s})},updateNodeDimensions:n=>{const{onNodesChange:o,nodeInternals:r,fitViewOnInit:s,fitViewOnInitDone:a,fitViewOnInitOptions:i,domNode:l,nodeOrigin:d}=e(),u=l==null?void 0:l.querySelector(".react-flow__viewport");if(!u)return;const h=window.getComputedStyle(u),{m22:f}=new window.DOMMatrixReadOnly(h.transform),m=n.reduce((g,p)=>{const b=r.get(p.id);if(b!=null&&b.hidden)r.set(b.id,{...b,[bt]:{...b[bt],handleBounds:void 0}});else if(b){const y=xh(p.nodeElement);!(!y.width||!y.height||b.width===y.width&&b.height===y.height&&!p.forceUpdate)&&(r.set(b.id,{...b,[bt]:{...b[bt],handleBounds:{source:Qv(".source",p.nodeElement,f,d),target:Qv(".target",p.nodeElement,f,d)}},...y}),g.push({id:b.id,type:"dimensions",dimensions:y}))}return g},[]);$v(r,d);const x=a||s&&!a&&Vv(e,{initial:!0,...i});t({nodeInternals:new Map(r),fitViewOnInitDone:x}),(m==null?void 0:m.length)>0&&(o==null||o(m))},updateNodePositions:(n,o=!0,r=!1)=>{const{triggerNodeChanges:s}=e(),a=n.map(i=>{const l={id:i.id,type:"position",dragging:r};return o&&(l.positionAbsolute=i.positionAbsolute,l.position=i.position),l});s(a)},triggerNodeChanges:n=>{const{onNodesChange:o,nodeInternals:r,hasDefaultNodes:s,nodeOrigin:a,getNodes:i,elevateNodesOnSelect:l}=e();if(n!=null&&n.length){if(s){const d=Ph(Yv(n,i()),r,a,l);t({nodeInternals:d})}o==null||o(n)}},addSelectedNodes:n=>{const{multiSelectionActive:o,edges:r,getNodes:s}=e();let a,i=null;o?a=n.map(l=>Bo(l,!0)):(a=Zr(s(),n),i=Zr(r,[])),Dl({changedNodes:a,changedEdges:i,get:e,set:t})},addSelectedEdges:n=>{const{multiSelectionActive:o,edges:r,getNodes:s}=e();let a,i=null;o?a=n.map(l=>Bo(l,!0)):(a=Zr(r,n),i=Zr(s(),[])),Dl({changedNodes:i,changedEdges:a,get:e,set:t})},unselectNodesAndEdges:({nodes:n,edges:o}={})=>{const{edges:r,getNodes:s}=e(),a=o||r;Dl({changedNodes:(n||s()).map(i=>(i.selected=!1,Bo(i.id,!1))),changedEdges:a.map(i=>Bo(i.id,!1)),get:e,set:t})},setMinZoom:n=>{const{d3Zoom:o,maxZoom:r}=e();o==null||o.scaleExtent([n,r]),t({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:o,minZoom:r}=e();o==null||o.scaleExtent([r,n]),t({maxZoom:n})},setTranslateExtent:n=>{var o;(o=e().d3Zoom)==null||o.translateExtent(n),t({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:o}=e();Dl({changedNodes:o().filter(r=>r.selected).map(r=>Bo(r.id,!1)),changedEdges:n.filter(r=>r.selected).map(r=>Bo(r.id,!1)),get:e,set:t})},setNodeExtent:n=>{const{nodeInternals:o}=e();o.forEach(r=>{r.positionAbsolute=bh(r.position,n)}),t({nodeExtent:n,nodeInternals:new Map(o)})},panBy:n=>{const{transform:o,width:r,height:s,d3Zoom:a,d3Selection:i,translateExtent:l}=e();if(!a||!i||!n.x&&!n.y)return!1;const d=Zo.translate(o[0]+n.x,o[1]+n.y).scale(o[2]),u=[[0,0],[r,s]],h=a==null?void 0:a.constrain()(d,u,l);return a.transform(i,h),o[0]!==h.x||o[1]!==h.y||o[2]!==h.k},cancelConnection:()=>t({connectionNodeId:Uo.connectionNodeId,connectionHandleId:Uo.connectionHandleId,connectionHandleType:Uo.connectionHandleType,connectionStatus:Uo.connectionStatus,connectionStartHandle:Uo.connectionStartHandle,connectionEndHandle:Uo.connectionEndHandle}),reset:()=>t({...Uo})}),Object.is),$h=({children:t})=>{const e=O.useRef(null);return e.current||(e.current=JA()),G.createElement(V8,{value:e.current},t)};$h.displayName="ReactFlowProvider";const p2=({children:t})=>O.useContext(Cl)?G.createElement(G.Fragment,null,t):G.createElement($h,null,t);p2.displayName="ReactFlowWrapper";const ZA={input:Mv,default:Oh,output:Dv,group:Dh},QA={default:Ml,straight:Ch,step:jh,smoothstep:Al,simplebezier:Sh},eT=[0,0],tT=[15,15],nT={x:0,y:0,zoom:1},oT={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},Vh=O.forwardRef(({nodes:t,edges:e,defaultNodes:n,defaultEdges:o,className:r,nodeTypes:s=ZA,edgeTypes:a=QA,onNodeClick:i,onEdgeClick:l,onInit:d,onMove:u,onMoveStart:h,onMoveEnd:f,onConnect:m,onConnectStart:x,onConnectEnd:g,onClickConnectStart:p,onClickConnectEnd:b,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:N,onNodeDragStart:j,onNodeDrag:C,onNodeDragStop:_,onNodesDelete:A,onEdgesDelete:I,onSelectionChange:P,onSelectionDragStart:R,onSelectionDrag:M,onSelectionDragStop:L,onSelectionContextMenu:F,onSelectionStart:D,onSelectionEnd:T,connectionMode:k=cr.Strict,connectionLineType:B=Fo.Bezier,connectionLineStyle:E,connectionLineComponent:U,connectionLineContainerStyle:V,deleteKeyCode:$="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=xa.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:q=_l()?"Meta":"Control",zoomActivationKeyCode:K=_l()?"Meta":"Control",snapToGrid:re=!1,snapGrid:oe=tT,onlyRenderVisibleElements:ne=!1,selectNodesOnDrag:se=!0,nodesDraggable:te,nodesConnectable:pe,nodesFocusable:he,nodeOrigin:ae=eT,edgesFocusable:ye,edgesUpdatable:fe,elementsSelectable:Se,defaultViewport:Me=nT,minZoom:Ee=.5,maxZoom:Le=2,translateExtent:Te=Uh,preventScrolling:Ze=!0,nodeExtent:He,defaultMarkerColor:Ge="#b1b1b7",zoomOnScroll:ee=!0,zoomOnPinch:be=!0,panOnScroll:we=!1,panOnScrollSpeed:Ae=.5,panOnScrollMode:W=Lo.Free,zoomOnDoubleClick:de=!0,panOnDrag:ue=!0,onPaneClick:ce,onPaneMouseEnter:ve,onPaneMouseMove:Oe,onPaneMouseLeave:Re,onPaneScroll:Ye,onPaneContextMenu:ie,children:je,onEdgeContextMenu:_e,onEdgeDoubleClick:Be,onEdgeMouseEnter:We,onEdgeMouseMove:Pe,onEdgeMouseLeave:$e,onEdgeUpdate:nt,onEdgeUpdateStart:Ke,onEdgeUpdateEnd:rt,onReconnect:zt,onReconnectStart:Vt,onReconnectEnd:fn,reconnectRadius:Xt=10,edgeUpdaterRadius:Mn=10,onNodesChange:ns,onEdgesChange:Wn,noDragClassName:vo="nodrag",noWheelClassName:Nn="nowheel",noPanClassName:os="nopan",fitView:Na=!1,fitViewOptions:P7,connectOnClick:R7=!0,attributionPosition:L7,proOptions:F7,defaultEdgeOptions:z7,elevateNodesOnSelect:B7=!0,elevateEdgesOnSelect:U7=!1,disableKeyboardA11y:ik=!1,autoPanOnConnect:$7=!0,autoPanOnNodeDrag:V7=!0,connectionRadius:H7=20,isValidConnection:W7,onError:q7,style:G7,id:lk,nodeDragThreshold:Y7,...K7},X7)=>{const Pf=lk||"1";return G.createElement("div",{...K7,style:{...G7,...oT},ref:X7,className:Kt(["react-flow",r]),"data-testid":"rf__wrapper",id:lk},G.createElement(p2,null,G.createElement(XA,{onInit:d,onMove:u,onMoveStart:h,onMoveEnd:f,onNodeClick:i,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:v,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:N,nodeTypes:s,edgeTypes:a,connectionLineType:B,connectionLineStyle:E,connectionLineComponent:U,connectionLineContainerStyle:V,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:J,deleteKeyCode:$,multiSelectionKeyCode:q,panActivationKeyCode:Q,zoomActivationKeyCode:K,onlyRenderVisibleElements:ne,selectNodesOnDrag:se,defaultViewport:Me,translateExtent:Te,minZoom:Ee,maxZoom:Le,preventScrolling:Ze,zoomOnScroll:ee,zoomOnPinch:be,zoomOnDoubleClick:de,panOnScroll:we,panOnScrollSpeed:Ae,panOnScrollMode:W,panOnDrag:ue,onPaneClick:ce,onPaneMouseEnter:ve,onPaneMouseMove:Oe,onPaneMouseLeave:Re,onPaneScroll:Ye,onPaneContextMenu:ie,onSelectionContextMenu:F,onSelectionStart:D,onSelectionEnd:T,onEdgeContextMenu:_e,onEdgeDoubleClick:Be,onEdgeMouseEnter:We,onEdgeMouseMove:Pe,onEdgeMouseLeave:$e,onReconnect:zt??nt,onReconnectStart:Vt??Ke,onReconnectEnd:fn??rt,reconnectRadius:Xt??Mn,defaultMarkerColor:Ge,noDragClassName:vo,noWheelClassName:Nn,noPanClassName:os,elevateEdgesOnSelect:U7,rfId:Pf,disableKeyboardA11y:ik,nodeOrigin:ae,nodeExtent:He}),G.createElement(hA,{nodes:t,edges:e,defaultNodes:n,defaultEdges:o,onConnect:m,onConnectStart:x,onConnectEnd:g,onClickConnectStart:p,onClickConnectEnd:b,nodesDraggable:te,nodesConnectable:pe,nodesFocusable:he,edgesFocusable:ye,edgesUpdatable:fe,elementsSelectable:Se,elevateNodesOnSelect:B7,minZoom:Ee,maxZoom:Le,nodeExtent:He,onNodesChange:ns,onEdgesChange:Wn,snapToGrid:re,snapGrid:oe,connectionMode:k,translateExtent:Te,connectOnClick:R7,defaultEdgeOptions:z7,fitView:Na,fitViewOptions:P7,onNodesDelete:A,onEdgesDelete:I,onNodeDragStart:j,onNodeDrag:C,onNodeDragStop:_,onSelectionDrag:M,onSelectionDragStart:R,onSelectionDragStop:L,noPanClassName:os,nodeOrigin:ae,rfId:Pf,autoPanOnConnect:$7,autoPanOnNodeDrag:V7,onError:q7,connectionRadius:H7,isValidConnection:W7,nodeDragThreshold:Y7}),G.createElement(dA,{onSelectionChange:P}),je,G.createElement(Q8,{proOptions:F7,position:L7}),G.createElement(gA,{rfId:Pf,disableKeyboardA11y:ik})))});function g2(t){return e=>{const[n,o]=O.useState(e),r=O.useCallback(s=>o(a=>t(s,a)),[]);return[n,o,r]}}Vh.displayName="ReactFlow";const x2=g2(Yv),b2=g2(function(t,e){return Gv(t,e)});function rT(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},G.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function sT(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},G.createElement("path",{d:"M0 0h32v4.2H0z"}))}function aT(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},G.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 iT(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},G.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 lT(){return G.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},G.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 ts=({children:t,className:e,...n})=>G.createElement("button",{type:"button",className:Kt(["react-flow__controls-button",e]),...n},t);ts.displayName="ControlButton";const cT=t=>({isInteractive:t.nodesDraggable||t.nodesConnectable||t.elementsSelectable,minZoomReached:t.transform[2]<=t.minZoom,maxZoomReached:t.transform[2]>=t.maxZoom}),y2=({style:t,showZoom:e=!0,showFitView:n=!0,showInteractive:o=!0,fitViewOptions:r,onZoomIn:s,onZoomOut:a,onFitView:i,onInteractiveChange:l,className:d,children:u,position:h="bottom-left"})=>{const f=Lt(),[m,x]=O.useState(!1),{isInteractive:g,minZoomReached:p,maxZoomReached:b}=at(cT,$t),{zoomIn:y,zoomOut:v,fitView:w}=va();return O.useEffect(()=>{x(!0)},[]),m?G.createElement(El,{className:Kt(["react-flow__controls",d]),position:h,style:t,"data-testid":"rf__controls"},e&&G.createElement(G.Fragment,null,G.createElement(ts,{onClick:()=>{y(),s==null||s()},className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},G.createElement(rT,null)),G.createElement(ts,{onClick:()=>{v(),a==null||a()},className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:p},G.createElement(sT,null))),n&&G.createElement(ts,{className:"react-flow__controls-fitview",onClick:()=>{w(r),i==null||i()},title:"fit view","aria-label":"fit view"},G.createElement(aT,null)),o&&G.createElement(ts,{className:"react-flow__controls-interactive",onClick:()=>{f.setState({nodesDraggable:!g,nodesConnectable:!g,elementsSelectable:!g}),l==null||l(!g)},title:"toggle interactivity","aria-label":"toggle interactivity"},g?G.createElement(lT,null):G.createElement(iT,null)),u):null};y2.displayName="Controls";var Sn,dT=O.memo(y2);function uT({color:t,dimensions:e,lineWidth:n}){return G.createElement("path",{stroke:t,strokeWidth:n,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`})}function hT({color:t,radius:e}){return G.createElement("circle",{cx:e,cy:e,r:e,fill:t})}(function(t){t.Lines="lines",t.Dots="dots",t.Cross="cross"})(Sn||(Sn={}));const fT={[Sn.Dots]:"#91919a",[Sn.Lines]:"#eee",[Sn.Cross]:"#e2e2e2"},mT={[Sn.Dots]:1,[Sn.Lines]:1,[Sn.Cross]:6},pT=t=>({transform:t.transform,patternId:`pattern-${t.rfId}`});function v2({id:t,variant:e=Sn.Dots,gap:n=20,size:o,lineWidth:r=1,offset:s=2,color:a,style:i,className:l}){const d=O.useRef(null),{transform:u,patternId:h}=at(pT,$t),f=a||fT[e],m=o||mT[e],x=e===Sn.Dots,g=e===Sn.Cross,p=Array.isArray(n)?n:[n,n],b=[p[0]*u[2]||1,p[1]*u[2]||1],y=m*u[2],v=g?[y,y]:b,w=x?[y/s,y/s]:[v[0]/s,v[1]/s];return G.createElement("svg",{className:Kt(["react-flow__background",l]),style:{...i,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},G.createElement("pattern",{id:h+t,x:u[0]%b[0],y:u[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${w[0]},-${w[1]})`},x?G.createElement(hT,{color:f,radius:y/s}):G.createElement(uT,{dimensions:v,color:f,lineWidth:r})),G.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${h+t})`}))}v2.displayName="Background";var gT=O.memo(v2);function Hh(t){return Math.min(11*t+35,200)}const w2=G.createContext("LR"),k2=O.memo(t=>{const e=H.c(51),{data:n,selected:o}=t,r=Ie(n.atom),s=Tc().inOrderIds.indexOf(r.id),a=o?"var(--gray-9)":"var(--gray-3)",i=at(xT),l=O.use(w2);let d,u,h,f,m;if(e[0]!==r.code||e[1]!==a||e[2]!==l||e[3]!==o){const I=r.code.split(`
145
- `).length,P=l==="LR"?De.Left:De.Top;let R;e[8]!==a?(R={background:a},e[8]=a,e[9]=R):R=e[9],e[10]!==P||e[11]!==R?(h=c.jsx(zo,{type:"target",id:"inputs",position:P,style:R}),e[10]=P,e[11]=R,e[12]=h):h=e[12];const M=l==="LR"?De.Left:De.Top;let L;e[13]!==a?(L={background:a},e[13]=a,e[14]=L):L=e[14],e[15]!==M||e[16]!==L?(f=c.jsx(zo,{type:"source",id:"inputs",position:M,style:L}),e[15]=M,e[16]=L,e[17]=f):f=e[17];const F=o&&"border-primary";e[18]!==F?(u=ge("flex flex-col bg-card border border-input/50 rounded-md mx-[2px] overflow-hidden",F),e[18]=F,e[19]=u):u=e[19],d=Hh(I),e[0]=r.code,e[1]=a,e[2]=l,e[3]=o,e[4]=d,e[5]=u,e[6]=h,e[7]=f}else d=e[4],u=e[5],h=e[6],f=e[7];var x;let g;e[20]!==n.forceWidth||e[21]!==i?(m=n.forceWidth||(x=i,Math.min(Math.max(x-100,100),400)),e[20]=n.forceWidth,e[21]=i,e[22]=m):m=e[22],e[23]!==d||e[24]!==m?(g={height:d,width:m},e[23]=d,e[24]=m,e[25]=g):g=e[25];const p=WP(r.name,s);let b,y,v;e[26]!==p?(b=c.jsx("div",{className:"text-muted-foreground font-semibold text-xs py-1 px-2 bg-muted border-b",children:p}),e[26]=p,e[27]=b):b=e[27],e[28]!==r.code?(y=c.jsx(IL,{code:r.code}),e[28]=r.code,e[29]=y):y=e[29],e[30]!==u||e[31]!==g||e[32]!==b||e[33]!==y?(v=c.jsxs("div",{className:u,style:g,children:[b,y]}),e[30]=u,e[31]=g,e[32]=b,e[33]=y,e[34]=v):v=e[34];const w=l==="LR"?De.Right:De.Bottom;let S,N;e[35]!==a?(S={background:a},e[35]=a,e[36]=S):S=e[36],e[37]!==w||e[38]!==S?(N=c.jsx(zo,{type:"source",id:"outputs",position:w,style:S}),e[37]=w,e[38]=S,e[39]=N):N=e[39];const j=l==="LR"?De.Right:De.Bottom;let C,_,A;return e[40]!==a?(C={background:a},e[40]=a,e[41]=C):C=e[41],e[42]!==j||e[43]!==C?(_=c.jsx(zo,{type:"target",id:"outputs",position:j,style:C}),e[42]=j,e[43]=C,e[44]=_):_=e[44],e[45]!==v||e[46]!==N||e[47]!==_||e[48]!==h||e[49]!==f?(A=c.jsxs("div",{children:[h,f,v,N,_]}),e[45]=v,e[46]=N,e[47]=_,e[48]=h,e[49]=f,e[50]=A):A=e[50],A},(t,e)=>["data","selected","id"].every(n=>t[n]===e[n]));k2.displayName="CustomNode";const S2={custom:k2};function xT(t){const{width:e}=t;return e}const N2=t=>{const e=H.c(18),{maxCount:n,cellIds:o,onClick:r,skipScroll:s}=t,a=Tc();let i,l,d,u;if(e[0]!==o||e[1]!==a||e[2]!==n||e[3]!==r||e[4]!==s){d=Symbol.for("react.early_return_sentinel");e:{let h;e[8]!==a?(h=(x,g)=>a.inOrderIds.indexOf(x)-a.inOrderIds.indexOf(g),e[8]=a,e[9]=h):h=e[9];const f=[...o].sort(h);if(o.length===0){let x;e[10]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx("div",{className:"text-muted-foreground",children:"--"}),e[10]=x):x=e[10],d=x;break e}let m;e[11]!==o.length||e[12]!==r||e[13]!==s?(m=(x,g)=>c.jsxs("span",{className:"truncate",children:[c.jsx(_o,{variant:"focus",cellId:x,skipScroll:s,className:"whitespace-nowrap",onClick:r?()=>r(x):void 0},x),g<o.length-1&&", "]},x),e[11]=o.length,e[12]=r,e[13]=s,e[14]=m):m=e[14],i=f.slice(0,n).map(m),l=o.length>n&&c.jsxs(gr,{children:[c.jsx(ys,{asChild:!0,children:c.jsxs("span",{className:"whitespace-nowrap text-muted-foreground text-xs hover:underline cursor-pointer",children:["+",o.length-n," more"]})}),c.jsx(hs,{className:"w-auto",children:c.jsx("div",{className:"flex flex-col gap-1 py-1",children:f.slice(n).map(x=>c.jsx(_o,{variant:"focus",cellId:x,className:"whitespace-nowrap",onClick:r?()=>r(x):void 0},x))})})]})}e[0]=o,e[1]=a,e[2]=n,e[3]=r,e[4]=s,e[5]=i,e[6]=l,e[7]=d}else i=e[5],l=e[6],d=e[7];return d!==Symbol.for("react.early_return_sentinel")?d:(e[15]!==i||e[16]!==l?(u=c.jsxs(c.Fragment,{children:[i,l]}),e[15]=i,e[16]=l,e[17]=u):u=e[17],u)},Wh=t=>{const e=H.c(15);let n,o,r,s;e[0]!==t?({name:o,declaredBy:n,onClick:r,...s}=t,e[0]=t,e[1]=n,e[2]=o,e[3]=r,e[4]=s):(n=e[1],o=e[2],r=e[3],s=e[4]);const a=n.length>1?"destructive":"outline";let i,l,d;return e[5]!==o||e[6]!==r?(i=async u=>{r?r(u):(await nn(o),Xe({title:"Copied to clipboard"}))},e[5]=o,e[6]=r,e[7]=i):i=e[7],e[8]!==o||e[9]!==a||e[10]!==i?(l=c.jsx(G3,{title:o,variant:a,className:"rounded-sm text-ellipsis block overflow-hidden max-w-fit cursor-pointer font-medium",onClick:i,children:o}),e[8]=o,e[9]=a,e[10]=i,e[11]=l):l=e[11],e[12]!==s||e[13]!==l?(d=c.jsx("div",{className:"max-w-[130px]",...s,children:l}),e[12]=s,e[13]=l,e[14]=d):d=e[14],d},qh=O.memo(t=>{const e=H.c(38),{onChange:n,view:o,settings:r,onSettingsChange:s}=t;let a;e[0]!==s||e[1]!==r?(a=(M,L)=>{s({...r,[M]:L})},e[0]=s,e[1]=r,e[2]=a):a=e[2];const i=a;let l,d,u,h,f,m;e[3]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(ys,{asChild:!0,children:c.jsx(ke,{variant:"text",size:"xs",children:c.jsx(em,{className:"w-4 h-4"})})}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx("div",{className:"font-semibold pb-4",children:"Settings"}),e[4]=d):d=e[4],e[5]!==i?(u=M=>i("hidePureMarkdown",!!M),e[5]=i,e[6]=u):u=e[6],e[7]!==r.hidePureMarkdown||e[8]!==u?(h=c.jsx(v3,{"data-testid":"hide-pure-markdown-checkbox",id:"hide-pure-markdown",checked:r.hidePureMarkdown,onCheckedChange:u}),e[7]=r.hidePureMarkdown,e[8]=u,e[9]=h):h=e[9],e[10]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(fr,{htmlFor:"hide-pure-markdown",children:"Hide pure markdown"}),e[10]=f):f=e[10],e[11]!==h?(m=c.jsxs(gr,{children:[l,c.jsxs(hs,{className:"w-auto p-2 text-muted-foreground",children:[d,c.jsxs("div",{className:"flex items-center gap-2",children:[h,f]})]})]}),e[11]=h,e[12]=m):m=e[12];const x=m,g=o==="_minimap_";let p,b,y;e[13]!==n?(p=()=>n("_minimap_"),e[13]=n,e[14]=p):p=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(vp,{className:"w-4 h-4 mr-1"}),e[15]=b):b=e[15],e[16]!==g||e[17]!==p?(y=c.jsxs(ke,{variant:"outline",className:"bg-background","aria-selected":g,size:"xs",onClick:p,children:[b,"Mini Map"]}),e[16]=g,e[17]=p,e[18]=y):y=e[18];const v=o==="TB";let w,S,N;e[19]!==n?(w=()=>n("TB"),e[19]=n,e[20]=w):w=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx(ii,{className:"w-4 h-4 mr-1"}),e[21]=S):S=e[21],e[22]!==v||e[23]!==w?(N=c.jsxs(ke,{variant:"outline",className:"bg-background","aria-selected":v,size:"xs",onClick:w,children:[S,"Vertical Tree"]}),e[22]=v,e[23]=w,e[24]=N):N=e[24];const j=o==="LR";let C,_,A,I;e[25]!==n?(C=()=>n("LR"),e[25]=n,e[26]=C):C=e[26],e[27]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsx(ii,{className:"w-4 h-4 mr-1 transform -rotate-90"}),e[27]=_):_=e[27],e[28]!==j||e[29]!==C?(A=c.jsxs(ke,{variant:"outline",className:"bg-background","aria-selected":j,size:"xs",onClick:C,children:[_," ","Horizontal Tree"]}),e[28]=j,e[29]=C,e[30]=A):A=e[30],e[31]!==y||e[32]!==N||e[33]!==A?(I=c.jsxs("div",{className:"flex gap-2",children:[y,N,A]}),e[31]=y,e[32]=N,e[33]=A,e[34]=I):I=e[34];const P=o!=="_minimap_"&&x;let R;return e[35]!==I||e[36]!==P?(R=c.jsxs(El,{position:"top-right",className:"flex flex-col items-end gap-2",children:[I,P]}),e[35]=I,e[36]=P,e[37]=R):R=e[37],R});qh.displayName="GraphToolbar";const Rl=O.memo(t=>{const e=H.c(11),{selection:n,variables:o,onClearSelection:r}=t;if(!n)return null;const s=bT;let a;e[0]!==r||e[1]!==n.id||e[2]!==n.source||e[3]!==n.target||e[4]!==n.type||e[5]!==o?(a=()=>{if(n.type==="node"){const u=Object.values(o).filter(m=>m.usedBy.includes(n.id)),h=Object.values(o).filter(m=>m.declaredBy.includes(n.id)),f=(m,x)=>c.jsxs(c.Fragment,{children:[m.length===0&&c.jsx("div",{className:"text-muted-foreground text-sm text-center",children:"--"}),c.jsx("div",{className:"grid grid-cols-5 gap-3 items-center text-sm py-1 flex-1 empty:hidden",children:m.map(g=>c.jsxs(G.Fragment,{children:[c.jsx(Wh,{declaredBy:g.declaredBy,name:g.name}),c.jsxs("div",{className:"truncate col-span-2",title:g.value??"",children:[g.value,c.jsxs("span",{className:"ml-1 truncate text-foreground/60 font-mono",children:["(",g.dataType,")"]})]}),c.jsx("div",{className:"truncate col-span-2 gap-1 items-center",children:c.jsx(N2,{skipScroll:!0,onClick:()=>s(x==="in"?g.declaredBy[0]:g.usedBy[0],g.name),maxCount:3,cellIds:g.usedBy})})]},g.name))})]});return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[c.jsx(Ul,{className:"w-5 h-5"}),c.jsx(_o,{cellId:n.id}),c.jsx("div",{className:"flex-1"}),c.jsx(Z0,{cellId:n.id,children:c.jsx(ke,{variant:"ghost",size:"icon",children:c.jsx($c,{className:"w-4 h-4"})})}),c.jsx(ke,{variant:"text",size:"icon",onClick:()=>{r()},children:c.jsx(En,{className:"w-4 h-4"})})]}),c.jsxs("div",{className:"text-sm flex flex-col py-3 pl-2 pr-4 flex-1 justify-center",children:[c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[c.jsx(Vm,{className:"w-4 h-4"}),"Outputs"]}),f(h,"out")]}),c.jsx("hr",{className:"border-divider my-3"}),c.jsxs("div",{className:"flex flex-col gap-2",children:[c.jsxs("span",{className:"flex items-center gap-2 font-semibold",children:[c.jsx(Zt,{className:"w-4 h-4"}),"Inputs"]}),f(u,"in")]})]})]})}if(n.type==="edge"){const u=Object.values(o).filter(h=>h.declaredBy.includes(n.source)&&h.usedBy.includes(n.target));return c.jsxs(c.Fragment,{children:[c.jsxs("div",{className:"font-bold py-2 flex items-center gap-2 border-b px-3",children:[c.jsx(ci,{className:"w-4 h-4"}),c.jsx(_o,{cellId:n.source}),c.jsx(Lc,{className:"w-4 h-4"}),c.jsx(_o,{cellId:n.target})]}),c.jsx("div",{className:"grid grid-cols-4 gap-3 max-w-[350px] items-center text-sm p-3 flex-1",children:u.map(h=>c.jsxs(G.Fragment,{children:[c.jsx(Wh,{declaredBy:h.declaredBy,name:h.name,onClick:()=>{s(h.declaredBy[0],h.name)}}),c.jsx("div",{className:"truncate text-foreground/60 font-mono",children:h.dataType}),c.jsx("div",{className:"truncate col-span-2",title:h.value??"",children:h.value})]},h.name))})]})}},e[0]=r,e[1]=n.id,e[2]=n.source,e[3]=n.target,e[4]=n.type,e[5]=o,e[6]=a):a=e[6];const i=a;let l,d;return e[7]!==i?(l=i(),e[7]=i,e[8]=l):l=e[8],e[9]!==l?(d=c.jsx(El,{position:"bottom-left",className:"max-h-[90%] flex flex-col w-[calc(100%-5rem)]",children:c.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})}),e[9]=l,e[10]=d):d=e[10],d});function bT(t,e){const n=Ia(t);n&&Em(n,e)}function j2(){const t=H.c(7),e=va(),n=at(vT),o=at(yT);let r;t[0]!==e?(r=()=>{e.fitView({duration:100})},t[0]=e,t[1]=r):r=t[1];const s=qP(r,100);let a,i;t[2]!==s||t[3]!==o||t[4]!==n?(a=()=>{n&&o&&s()},i=[n,o,s],t[2]=s,t[3]=o,t[4]=n,t[5]=a,t[6]=i):(a=t[5],i=t[6]),O.useEffect(a,i)}function yT(t){const{height:e}=t;return e}function vT(t){const{width:e}=t;return e}Rl.displayName="GraphSelectionPanel";const C2=new class{createEdge(t,e,n){return{type:"smoothstep",pathOptions:{offset:20,borderRadius:100},data:{direction:n},markerEnd:{type:Gr.Arrow},id:`${t}-${e}-${n}`,source:t,sourceHandle:n,targetHandle:n,target:e}}createNode(t,e,n){return{id:t,data:{atom:e},width:250,type:"custom",height:Hh(Qe.get(e).code.trim().split(`
146
- `).length),position:{x:0,y:n+20}}}createElements(t,e,n,o){let r=0;const s=[],a=[];for(const[l,d]of jm.zip(t,e)){const u=this.createNode(l,d,r);s.push(u),r=u.position.y+(u.height||0)}const i=new Set;for(const l of Object.values(n)){const{declaredBy:d,usedBy:u}=l;for(const h of d)for(const f of u){const m=`${h}-${f}`;i.has(m)||(i.add(m),a.push(this.createEdge(h,f,"inputs"),this.createEdge(h,f,"outputs")))}}return{nodes:s,edges:a}}},wT=t=>{const e=H.c(37),{cellIds:n,variables:o,cellAtoms:r,children:s}=t;let a;e[0]!==r||e[1]!==n||e[2]!==o?(a=C2.createElements(n,r,o,!1),e[0]=r,e[1]=n,e[2]=o,e[3]=a):a=e[3];const{nodes:i,edges:l}=a;let d;e[4]===Symbol.for("react.memo_cache_sentinel")?(d=[],e[4]=d):d=e[4];const[u,h]=b2(d),[f,m]=x2(i),[x,g]=O.useState(),[p,b]=O.useState(),y=O.useRef(!1);j2();const v=at(kT);let w;e[5]!==h||e[6]!==m?(w=k=>{m(k.nodes),h([])},e[5]=h,e[6]=m,e[7]=w):w=e[7];const S=Fe(w);let N,j,C,_;e[8]!==r||e[9]!==n||e[10]!==S||e[11]!==o?(N=()=>{y.current?S(C2.createElements(n,r,o,!1)):y.current=!0},j=[n,o,r,S],e[8]=r,e[9]=n,e[10]=S,e[11]=o,e[12]=N,e[13]=j):(N=e[12],j=e[13]),O.useEffect(N,j),e[14]!==l||e[15]!==x||e[16]!==h?(C=()=>{if(x){const k=l.filter(B=>{const{source:E,target:U,data:V}=B;return E===x&&V.direction==="outputs"||U===x&&V.direction==="inputs"});h(k)}},_=[x,h,l],e[14]=l,e[15]=x,e[16]=h,e[17]=C,e[18]=_):(C=e[17],_=e[18]),O.useEffect(C,_);const A=function(k,B){const E=H.c(17);let U,V;if(E[0]!==B||E[1]!==k){let K;E[3]!==B?(K=(re,oe)=>{const{position:ne}=oe;return Math.min(re,ne.y-B/2-10)},E[3]=B,E[4]=K):K=E[4],V=k.reduce(K,Number.POSITIVE_INFINITY),E[0]=B,E[1]=k,E[2]=V}else V=E[2];const $=V;let X;if(E[5]!==B||E[6]!==k){let K;E[8]!==B?(K=(re,oe)=>{const{position:ne}=oe;return Math.max(re,ne.y+B/2+10)},E[8]=B,E[9]=K):K=E[9],X=k.reduce(K,Number.NEGATIVE_INFINITY),E[5]=B,E[6]=k,E[7]=X}else X=E[7];const Y=X;let J,Q,q;return E[10]!==$?(J=[Number.NEGATIVE_INFINITY,$],E[10]=$,E[11]=J):J=E[11],E[12]!==Y?(Q=[Number.POSITIVE_INFINITY,Y],E[12]=Y,E[13]=Q):Q=E[13],E[14]!==J||E[15]!==Q?(q=[J,Q],E[14]=J,E[15]=Q,E[16]=q):q=E[16],U=q,U}(f,v);let I;e[19]===Symbol.for("react.memo_cache_sentinel")?(I=()=>{g(void 0),b(void 0)},e[19]=I):I=e[19];const P=I;let R;e[20]!==u||e[21]!==p||e[22]!==x||e[23]!==o?(R=()=>p?c.jsx(Rl,{selection:{type:"edge",source:p.source,target:p.target},onClearSelection:P,variables:o,edges:u}):x?c.jsx(Rl,{selection:{type:"node",id:x},variables:o,edges:u,onClearSelection:P}):null,e[20]=u,e[21]=p,e[22]=x,e[23]=o,e[24]=R):R=e[24];const M=R;let L,F,D,T;return e[25]!==h?(L=(k,B)=>{const E=B.id;g(E),b(void 0),h([])},e[25]=h,e[26]=L):L=e[26],e[27]===Symbol.for("react.memo_cache_sentinel")?(F=(k,B)=>{b(B)},e[27]=F):F=e[27],e[28]!==M?(D=M(),e[28]=M,e[29]=D):D=e[29],e[30]!==s||e[31]!==u||e[32]!==f||e[33]!==L||e[34]!==D||e[35]!==A?(T=c.jsxs(Vh,{nodes:f,edges:u,nodeTypes:S2,translateExtent:A,onNodeClick:L,onNodeDoubleClick:ST,onEdgeClick:F,snapToGrid:!0,fitView:!0,elementsSelectable:!0,minZoom:1,maxZoom:1,draggable:!1,panOnScrollMode:Lo.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:[D,s]}),e[30]=s,e[31]=u,e[32]=f,e[33]=L,e[34]=D,e[35]=A,e[36]=T):T=e[36],T};function kT(t){const{height:e}=t;return e}function ST(t,e){Y3(e.id,"focus")}var Gh,E2,_2,I2,A2,T2,Yh,M2,Kh,O2,Xh,D2,Jh,P2,Zh,R2,Qh,L2,ef,F2,tf,z2,nf,B2,of,U2,rf,$2,sf,V2,af,H2,lf,W2,q2,G2,Y2,K2,X2,J2,cf,Z2,df,Q2,uf,ew,hf,tw,ff,nw,mf,ow,pf,rw,gf,sw,xf,aw,bf,iw,yf,lw,vf,cw,wf,dw,kf,uw,hw,fw,mw,pw,gw,xw,Sf,bw,Nf,yw,vw,ww,jf,kw,Cf,Sw,Ef,Nw,_f,jw,If,Cw,Ew,_w,Iw,Aw;function Af(){if(E2)return Gh;E2=1;var t="\0";function e(s,a){s[a]?s[a]++:s[a]=1}function n(s,a){--s[a]||delete s[a]}function o(s,a,i,l){var d=""+a,u=""+i;if(!s&&d>u){var h=d;d=u,u=h}return d+""+u+""+(l===void 0?"\0":l)}function r(s,a){return o(s,a.v,a.w,a.name)}return Gh=class{constructor(s){Z(this,"_isDirected",!0);Z(this,"_isMultigraph",!1);Z(this,"_isCompound",!1);Z(this,"_label");Z(this,"_defaultNodeLabelFn",()=>{});Z(this,"_defaultEdgeLabelFn",()=>{});Z(this,"_nodes",{});Z(this,"_in",{});Z(this,"_preds",{});Z(this,"_out",{});Z(this,"_sucs",{});Z(this,"_edgeObjs",{});Z(this,"_edgeLabels",{});Z(this,"_nodeCount",0);Z(this,"_edgeCount",0);Z(this,"_parent");Z(this,"_children");s&&(this._isDirected=!Object.hasOwn(s,"directed")||s.directed,this._isMultigraph=!!Object.hasOwn(s,"multigraph")&&s.multigraph,this._isCompound=!!Object.hasOwn(s,"compound")&&s.compound),this._isCompound&&(this._parent={},this._children={},this._children[t]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(s){return this._label=s,this}graph(){return this._label}setDefaultNodeLabel(s){return this._defaultNodeLabelFn=s,typeof s!="function"&&(this._defaultNodeLabelFn=()=>s),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var s=this;return this.nodes().filter(a=>Object.keys(s._in[a]).length===0)}sinks(){var s=this;return this.nodes().filter(a=>Object.keys(s._out[a]).length===0)}setNodes(s,a){var i=arguments,l=this;return s.forEach(function(d){i.length>1?l.setNode(d,a):l.setNode(d)}),this}setNode(s,a){return Object.hasOwn(this._nodes,s)?(arguments.length>1&&(this._nodes[s]=a),this):(this._nodes[s]=arguments.length>1?a:this._defaultNodeLabelFn(s),this._isCompound&&(this._parent[s]=t,this._children[s]={},this._children[t][s]=!0),this._in[s]={},this._preds[s]={},this._out[s]={},this._sucs[s]={},++this._nodeCount,this)}node(s){return this._nodes[s]}hasNode(s){return Object.hasOwn(this._nodes,s)}removeNode(s){var a=this;if(Object.hasOwn(this._nodes,s)){var i=l=>a.removeEdge(a._edgeObjs[l]);delete this._nodes[s],this._isCompound&&(this._removeFromParentsChildList(s),delete this._parent[s],this.children(s).forEach(function(l){a.setParent(l)}),delete this._children[s]),Object.keys(this._in[s]).forEach(i),delete this._in[s],delete this._preds[s],Object.keys(this._out[s]).forEach(i),delete this._out[s],delete this._sucs[s],--this._nodeCount}return this}setParent(s,a){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(a===void 0)a=t;else{for(var i=a+="";i!==void 0;i=this.parent(i))if(i===s)throw new Error("Setting "+a+" as parent of "+s+" would create a cycle");this.setNode(a)}return this.setNode(s),this._removeFromParentsChildList(s),this._parent[s]=a,this._children[a][s]=!0,this}_removeFromParentsChildList(s){delete this._children[this._parent[s]][s]}parent(s){if(this._isCompound){var a=this._parent[s];if(a!==t)return a}}children(s=t){if(this._isCompound){var a=this._children[s];if(a)return Object.keys(a)}else{if(s===t)return this.nodes();if(this.hasNode(s))return[]}}predecessors(s){var a=this._preds[s];if(a)return Object.keys(a)}successors(s){var a=this._sucs[s];if(a)return Object.keys(a)}neighbors(s){var a=this.predecessors(s);if(a){const l=new Set(a);for(var i of this.successors(s))l.add(i);return Array.from(l.values())}}isLeaf(s){return(this.isDirected()?this.successors(s):this.neighbors(s)).length===0}filterNodes(s){var a=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});a.setGraph(this.graph());var i=this;Object.entries(this._nodes).forEach(function([u,h]){s(u)&&a.setNode(u,h)}),Object.values(this._edgeObjs).forEach(function(u){a.hasNode(u.v)&&a.hasNode(u.w)&&a.setEdge(u,i.edge(u))});var l={};function d(u){var h=i.parent(u);return h===void 0||a.hasNode(h)?(l[u]=h,h):h in l?l[h]:d(h)}return this._isCompound&&a.nodes().forEach(u=>a.setParent(u,d(u))),a}setDefaultEdgeLabel(s){return this._defaultEdgeLabelFn=s,typeof s!="function"&&(this._defaultEdgeLabelFn=()=>s),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(s,a){var i=this,l=arguments;return s.reduce(function(d,u){return l.length>1?i.setEdge(d,u,a):i.setEdge(d,u),u}),this}setEdge(){var s,a,i,l,d=!1,u=arguments[0];typeof u=="object"&&u!==null&&"v"in u?(s=u.v,a=u.w,i=u.name,arguments.length===2&&(l=arguments[1],d=!0)):(s=u,a=arguments[1],i=arguments[3],arguments.length>2&&(l=arguments[2],d=!0)),s=""+s,a=""+a,i!==void 0&&(i=""+i);var h=o(this._isDirected,s,a,i);if(Object.hasOwn(this._edgeLabels,h))return d&&(this._edgeLabels[h]=l),this;if(i!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(s),this.setNode(a),this._edgeLabels[h]=d?l:this._defaultEdgeLabelFn(s,a,i);var f=function(m,x,g,p){var b=""+x,y=""+g;if(!m&&b>y){var v=b;b=y,y=v}var w={v:b,w:y};return p&&(w.name=p),w}(this._isDirected,s,a,i);return s=f.v,a=f.w,Object.freeze(f),this._edgeObjs[h]=f,e(this._preds[a],s),e(this._sucs[s],a),this._in[a][h]=f,this._out[s][h]=f,this._edgeCount++,this}edge(s,a,i){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,a,i);return this._edgeLabels[l]}edgeAsObj(){const s=this.edge(...arguments);return typeof s!="object"?{label:s}:s}hasEdge(s,a,i){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,a,i);return Object.hasOwn(this._edgeLabels,l)}removeEdge(s,a,i){var l=arguments.length===1?r(this._isDirected,arguments[0]):o(this._isDirected,s,a,i),d=this._edgeObjs[l];return d&&(s=d.v,a=d.w,delete this._edgeLabels[l],delete this._edgeObjs[l],n(this._preds[a],s),n(this._sucs[s],a),delete this._in[a][l],delete this._out[s][l],this._edgeCount--),this}inEdges(s,a){var i=this._in[s];if(i){var l=Object.values(i);return a?l.filter(d=>d.v===a):l}}outEdges(s,a){var i=this._out[s];if(i){var l=Object.values(i);return a?l.filter(d=>d.w===a):l}}nodeEdges(s,a){var i=this.inEdges(s,a);if(i)return i.concat(this.outEdges(s,a))}},Gh}function NT(){return T2?A2:(T2=1,A2={Graph:Af(),version:I2?_2:(I2=1,_2="2.2.4")})}function jT(){if(M2)return Yh;M2=1;var t=Af();function e(o){return o.nodes().map(function(r){var s=o.node(r),a=o.parent(r),i={v:r};return s!==void 0&&(i.value=s),a!==void 0&&(i.parent=a),i})}function n(o){return o.edges().map(function(r){var s=o.edge(r),a={v:r.v,w:r.w};return r.name!==void 0&&(a.name=r.name),s!==void 0&&(a.value=s),a})}return Yh={write:function(o){var r={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:e(o),edges:n(o)};return o.graph()!==void 0&&(r.value=structuredClone(o.graph())),r},read:function(o){var r=new t(o.options).setGraph(o.value);return o.nodes.forEach(function(s){r.setNode(s.v,s.value),s.parent&&r.setParent(s.v,s.parent)}),o.edges.forEach(function(s){r.setEdge({v:s.v,w:s.w,name:s.name},s.value)}),r}},Yh}function CT(){return O2||(O2=1,Kh=function(t){var e,n={},o=[];function r(s){Object.hasOwn(n,s)||(n[s]=!0,e.push(s),t.successors(s).forEach(r),t.predecessors(s).forEach(r))}return t.nodes().forEach(function(s){e=[],r(s),e.length&&o.push(e)}),o}),Kh}function Tw(){return D2?Xh:(D2=1,Xh=class{constructor(){Z(this,"_arr",[]);Z(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(t){return t.key})}has(t){return Object.hasOwn(this._keyIndices,t)}priority(t){var e=this._keyIndices[t];if(e!==void 0)return this._arr[e].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(t,e){var n=this._keyIndices;if(t=String(t),!Object.hasOwn(n,t)){var o=this._arr,r=o.length;return n[t]=r,o.push({key:t,priority:e}),this._decrease(r),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key}decrease(t,e){var n=this._keyIndices[t];if(e>this._arr[n].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[n].priority+" New: "+e);this._arr[n].priority=e,this._decrease(n)}_heapify(t){var e=this._arr,n=2*t,o=n+1,r=t;n<e.length&&(r=e[n].priority<e[r].priority?n:r,o<e.length&&(r=e[o].priority<e[r].priority?o:r),r!==t&&(this._swap(t,r),this._heapify(r)))}_decrease(t){for(var e,n=this._arr,o=n[t].priority;t!==0&&!(n[e=t>>1].priority<o);)this._swap(t,e),t=e}_swap(t,e){var n=this._arr,o=this._keyIndices,r=n[t],s=n[e];n[t]=s,n[e]=r,o[s.key]=t,o[r.key]=e}},Xh)}function Mw(){if(P2)return Jh;P2=1;var t=Tw();Jh=function(n,o,r,s){return function(a,i,l,d){var u,h,f={},m=new t,x=function(g){var p=g.v!==u?g.v:g.w,b=f[p],y=l(g),v=h.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+y);v<b.distance&&(b.distance=v,b.predecessor=u,m.decrease(p,v))};for(a.nodes().forEach(function(g){var p=g===i?0:Number.POSITIVE_INFINITY;f[g]={distance:p},m.add(g,p)});m.size()>0&&(u=m.removeMin(),(h=f[u]).distance!==Number.POSITIVE_INFINITY);)d(u).forEach(x);return f}(n,String(o),r||e,s||function(a){return n.outEdges(a)})};var e=()=>1;return Jh}function ET(){if(R2)return Zh;R2=1;var t=Mw();return Zh=function(e,n,o){return e.nodes().reduce(function(r,s){return r[s]=t(e,s,n,o),r},{})},Zh}function Ow(){return L2||(L2=1,Qh=function(t){var e=0,n=[],o={},r=[];function s(a){var i=o[a]={onStack:!0,lowlink:e,index:e++};if(n.push(a),t.successors(a).forEach(function(u){Object.hasOwn(o,u)?o[u].onStack&&(i.lowlink=Math.min(i.lowlink,o[u].index)):(s(u),i.lowlink=Math.min(i.lowlink,o[u].lowlink))}),i.lowlink===i.index){var l,d=[];do l=n.pop(),o[l].onStack=!1,d.push(l);while(a!==l);r.push(d)}}return t.nodes().forEach(function(a){Object.hasOwn(o,a)||s(a)}),r}),Qh}function _T(){if(F2)return ef;F2=1;var t=Ow();return ef=function(e){return t(e).filter(function(n){return n.length>1||n.length===1&&e.hasEdge(n[0],n[0])})},ef}function IT(){if(z2)return tf;z2=1,tf=function(e,n,o){return function(r,s,a){var i={},l=r.nodes();return l.forEach(function(d){i[d]={},i[d][d]={distance:0},l.forEach(function(u){d!==u&&(i[d][u]={distance:Number.POSITIVE_INFINITY})}),a(d).forEach(function(u){var h=u.v===d?u.w:u.v,f=s(u);i[d][h]={distance:f,predecessor:d}})}),l.forEach(function(d){var u=i[d];l.forEach(function(h){var f=i[h];l.forEach(function(m){var x=f[d],g=u[m],p=f[m],b=x.distance+g.distance;b<p.distance&&(p.distance=b,p.predecessor=g.predecessor)})})}),i}(e,n||t,o||function(r){return e.outEdges(r)})};var t=()=>1;return tf}function Dw(){if(B2)return nf;function t(n){var o={},r={},s=[];if(n.sinks().forEach(function a(i){if(Object.hasOwn(r,i))throw new e;Object.hasOwn(o,i)||(r[i]=!0,o[i]=!0,n.predecessors(i).forEach(a),delete r[i],s.push(i))}),Object.keys(o).length!==n.nodeCount())throw new e;return s}B2=1;class e extends Error{constructor(){super(...arguments)}}return nf=t,t.CycleException=e,nf}function AT(){if(U2)return of;U2=1;var t=Dw();return of=function(e){try{t(e)}catch(n){if(n instanceof t.CycleException)return!1;throw n}return!0},of}function Pw(){if($2)return rf;function t(o,r,s,a){for(var i=[[o,!1]];i.length>0;){var l=i.pop();l[1]?a.push(l[0]):Object.hasOwn(s,l[0])||(s[l[0]]=!0,i.push([l[0],!0]),n(r(l[0]),d=>i.push([d,!1])))}}function e(o,r,s,a){for(var i=[o];i.length>0;){var l=i.pop();Object.hasOwn(s,l)||(s[l]=!0,a.push(l),n(r(l),d=>i.push(d)))}}function n(o,r){for(var s=o.length;s--;)r(o[s],s,o);return o}return $2=1,rf=function(o,r,s){Array.isArray(r)||(r=[r]);var a=o.isDirected()?u=>o.successors(u):u=>o.neighbors(u),i=s==="post"?t:e,l=[],d={};return r.forEach(u=>{if(!o.hasNode(u))throw new Error("Graph does not have node: "+u);i(u,a,d,l)}),l},rf}function TT(){if(V2)return sf;V2=1;var t=Pw();return sf=function(e,n){return t(e,n,"post")},sf}function MT(){if(H2)return af;H2=1;var t=Pw();return af=function(e,n){return t(e,n,"pre")},af}function OT(){if(W2)return lf;W2=1;var t=Af(),e=Tw();return lf=function(n,o){var r,s=new t,a={},i=new e;function l(u){var h=u.v===r?u.w:u.v,f=i.priority(h);if(f!==void 0){var m=o(u);m<f&&(a[h]=r,i.decrease(h,m))}}if(n.nodeCount()===0)return s;n.nodes().forEach(function(u){i.add(u,Number.POSITIVE_INFINITY),s.setNode(u)}),i.decrease(n.nodes()[0],0);for(var d=!1;i.size()>0;){if(r=i.removeMin(),Object.hasOwn(a,r))s.setEdge(r,a[r]);else{if(d)throw new Error("Input graph is not connected: "+n);d=!0}n.nodeEdges(r).forEach(l)}return s},lf}function Tn(){if(K2)return Y2;K2=1;var t=NT();return Y2={Graph:t.Graph,json:jT(),alg:G2?q2:(G2=1,q2={components:CT(),dijkstra:Mw(),dijkstraAll:ET(),findCycles:_T(),floydWarshall:IT(),isAcyclic:AT(),postorder:TT(),preorder:MT(),prim:OT(),tarjan:Ow(),topsort:Dw()}),version:t.version}}function DT(){if(Z2)return cf;Z2=1;let t=Tn().Graph,e=function(){if(J2)return X2;function s(i){i._prev._next=i._next,i._next._prev=i._prev,delete i._next,delete i._prev}function a(i,l){if(i!=="_next"&&i!=="_prev")return l}return J2=1,X2=class{constructor(){let i={};i._next=i._prev=i,this._sentinel=i}dequeue(){let i=this._sentinel,l=i._prev;if(l!==i)return s(l),l}enqueue(i){let l=this._sentinel;i._prev&&i._next&&s(i),i._next=l._next,l._next._prev=i,l._next=i,i._prev=l}toString(){let i=[],l=this._sentinel,d=l._prev;for(;d!==l;)i.push(JSON.stringify(d,a)),d=d._prev;return"["+i.join(", ")+"]"}}}();cf=function(s,a){if(s.nodeCount()<=1)return[];let i=function(l,d){let u=new t,h=0,f=0;l.nodes().forEach(g=>{u.setNode(g,{v:g,in:0,out:0})}),l.edges().forEach(g=>{let p=u.edge(g.v,g.w)||0,b=d(g),y=p+b;u.setEdge(g.v,g.w,y),f=Math.max(f,u.node(g.v).out+=b),h=Math.max(h,u.node(g.w).in+=b)});let m=function(g){const p=[];for(let b=0;b<g;b++)p.push(b);return p}(f+h+3).map(()=>new e),x=h+1;return u.nodes().forEach(g=>{r(m,x,u.node(g))}),{graph:u,buckets:m,zeroIdx:x}}(s,a||n);return function(l,d,u){let h,f=[],m=d[d.length-1],x=d[0];for(;l.nodeCount();){for(;h=x.dequeue();)o(l,d,u,h);for(;h=m.dequeue();)o(l,d,u,h);if(l.nodeCount()){for(let g=d.length-2;g>0;--g)if(h=d[g].dequeue(),h){f=f.concat(o(l,d,u,h,!0));break}}}return f}(i.graph,i.buckets,i.zeroIdx).flatMap(l=>s.outEdges(l.v,l.w))};let n=()=>1;function o(s,a,i,l,d){let u=d?[]:void 0;return s.inEdges(l.v).forEach(h=>{let f=s.edge(h),m=s.node(h.v);d&&u.push({v:h.v,w:h.w}),m.out-=f,r(a,i,m)}),s.outEdges(l.v).forEach(h=>{let f=s.edge(h),m=h.w,x=s.node(m);x.in-=f,r(a,i,x)}),s.removeNode(l.v),u}function r(s,a,i){i.out?i.in?s[i.out-i.in+a].enqueue(i):s[s.length-1].enqueue(i):s[0].enqueue(i)}return cf}function _t(){if(Q2)return df;Q2=1;let t=Tn().Graph;function e(d,u,h,f){for(var m=f;d.hasNode(m);)m=a(f);return h.dummy=u,d.setNode(m,h),m}df={addBorderNode:function(d,u,h,f){let m={width:0,height:0};return arguments.length>=4&&(m.rank=h,m.order=f),e(d,"border",m,u)},addDummyNode:e,applyWithChunking:o,asNonCompoundGraph:function(d){let u=new t({multigraph:d.isMultigraph()}).setGraph(d.graph());return d.nodes().forEach(h=>{d.children(h).length||u.setNode(h,d.node(h))}),d.edges().forEach(h=>{u.setEdge(h,d.edge(h))}),u},buildLayerMatrix:function(d){let u=i(r(d)+1).map(()=>[]);return d.nodes().forEach(h=>{let f=d.node(h),m=f.rank;m!==void 0&&(u[m][f.order]=h)}),u},intersectRect:function(d,u){let h,f,m=d.x,x=d.y,g=u.x-m,p=u.y-x,b=d.width/2,y=d.height/2;if(!g&&!p)throw new Error("Not possible to find intersection inside of the rectangle");return Math.abs(p)*b>Math.abs(g)*y?(p<0&&(y=-y),h=y*g/p,f=y):(g<0&&(b=-b),h=b,f=b*p/g),{x:m+h,y:x+f}},mapValues:function(d,u){let h=u;return typeof u=="string"&&(h=f=>f[u]),Object.entries(d).reduce((f,[m,x])=>(f[m]=h(x,m),f),{})},maxRank:r,normalizeRanks:function(d){let u=d.nodes().map(f=>{let m=d.node(f).rank;return m===void 0?Number.MAX_VALUE:m}),h=o(Math.min,u);d.nodes().forEach(f=>{let m=d.node(f);Object.hasOwn(m,"rank")&&(m.rank-=h)})},notime:function(d,u){return u()},partition:function(d,u){let h={lhs:[],rhs:[]};return d.forEach(f=>{u(f)?h.lhs.push(f):h.rhs.push(f)}),h},pick:function(d,u){const h={};for(const f of u)d[f]!==void 0&&(h[f]=d[f]);return h},predecessorWeights:function(d){let u=d.nodes().map(h=>{let f={};return d.inEdges(h).forEach(m=>{f[m.v]=(f[m.v]||0)+d.edge(m).weight}),f});return l(d.nodes(),u)},range:i,removeEmptyRanks:function(d){let u=d.nodes().map(g=>d.node(g).rank),h=o(Math.min,u),f=[];d.nodes().forEach(g=>{let p=d.node(g).rank-h;f[p]||(f[p]=[]),f[p].push(g)});let m=0,x=d.graph().nodeRankFactor;Array.from(f).forEach((g,p)=>{g===void 0&&p%x!==0?--m:g!==void 0&&m&&g.forEach(b=>d.node(b).rank+=m)})},simplify:function(d){let u=new t().setGraph(d.graph());return d.nodes().forEach(h=>u.setNode(h,d.node(h))),d.edges().forEach(h=>{let f=u.edge(h.v,h.w)||{weight:0,minlen:1},m=d.edge(h);u.setEdge(h.v,h.w,{weight:f.weight+m.weight,minlen:Math.max(f.minlen,m.minlen)})}),u},successorWeights:function(d){let u=d.nodes().map(h=>{let f={};return d.outEdges(h).forEach(m=>{f[m.w]=(f[m.w]||0)+d.edge(m).weight}),f});return l(d.nodes(),u)},time:function(d,u){let h=Date.now();try{return u()}finally{console.log(d+" time: "+(Date.now()-h)+"ms")}},uniqueId:a,zipObject:l};const n=65535;function o(d,u){if(u.length>n){const h=function(f,m=n){const x=[];for(let g=0;g<f.length;g+=m){const p=f.slice(g,g+m);x.push(p)}return x}(u);return d.apply(null,h.map(f=>d.apply(null,f)))}return d.apply(null,u)}function r(d){const u=d.nodes().map(h=>{let f=d.node(h).rank;return f===void 0?Number.MIN_VALUE:f});return o(Math.max,u)}let s=0;function a(d){return d+""+ ++s}function i(d,u,h=1){u==null&&(u=d,d=0);let f=x=>x<u;h<0&&(f=x=>u<x);const m=[];for(let x=d;f(x);x+=h)m.push(x);return m}function l(d,u){return d.reduce((h,f,m)=>(h[f]=u[m],h),{})}return df}function PT(){if(ew)return uf;ew=1;let t=DT(),e=_t().uniqueId;return uf={run:function(n){(n.graph().acyclicer==="greedy"?t(n,function(r){return s=>r.edge(s).weight}(n)):function(r){let s=[],a={},i={};function l(d){Object.hasOwn(i,d)||(i[d]=!0,a[d]=!0,r.outEdges(d).forEach(u=>{Object.hasOwn(a,u.w)?s.push(u):l(u.w)}),delete a[d])}return r.nodes().forEach(l),s}(n)).forEach(r=>{let s=n.edge(r);n.removeEdge(r),s.forwardName=r.name,s.reversed=!0,n.setEdge(r.w,r.v,s,e("rev"))})},undo:function(n){n.edges().forEach(o=>{let r=n.edge(o);if(r.reversed){n.removeEdge(o);let s=r.forwardName;delete r.reversed,delete r.forwardName,n.setEdge(o.w,o.v,r,s)}})}},uf}function RT(){if(tw)return hf;tw=1;let t=_t();return hf={run:function(e){e.graph().dummyChains=[],e.edges().forEach(n=>function(o,r){let s,a,i,l=r.v,d=o.node(l).rank,u=r.w,h=o.node(u).rank,f=r.name,m=o.edge(r),x=m.labelRank;if(h!==d+1){for(o.removeEdge(r),i=0,++d;d<h;++i,++d)m.points=[],a={width:0,height:0,edgeLabel:m,edgeObj:r,rank:d},s=t.addDummyNode(o,"edge",a,"_d"),d===x&&(a.width=m.width,a.height=m.height,a.dummy="edge-label",a.labelpos=m.labelpos),o.setEdge(l,s,{weight:m.weight},f),i===0&&o.graph().dummyChains.push(s),l=s;o.setEdge(l,u,{weight:m.weight},f)}}(e,n))},undo:function(e){e.graph().dummyChains.forEach(n=>{let o,r=e.node(n),s=r.edgeLabel;for(e.setEdge(r.edgeObj,s);r.dummy;)o=e.successors(n)[0],e.removeNode(n),s.points.push({x:r.x,y:r.y}),r.dummy==="edge-label"&&(s.x=r.x,s.y=r.y,s.width=r.width,s.height=r.height),n=o,r=e.node(n)})}},hf}function Ll(){if(nw)return ff;nw=1;const{applyWithChunking:t}=_t();return ff={longestPath:function(e){var n={};e.sources().forEach(function o(r){var s=e.node(r);if(Object.hasOwn(n,r))return s.rank;n[r]=!0;let a=e.outEdges(r).map(l=>l==null?Number.POSITIVE_INFINITY:o(l.w)-e.edge(l).minlen);var i=t(Math.min,a);return i===Number.POSITIVE_INFINITY&&(i=0),s.rank=i})},slack:function(e,n){return e.node(n.w).rank-e.node(n.v).rank-e.edge(n).minlen}},ff}function Rw(){if(ow)return mf;ow=1;var t=Tn().Graph,e=Ll().slack;function n(s,a){return s.nodes().forEach(function i(l){a.nodeEdges(l).forEach(d=>{var u=d.v,h=l===u?d.w:u;s.hasNode(h)||e(a,d)||(s.setNode(h,{}),s.setEdge(l,h,{}),i(h))})}),s.nodeCount()}function o(s,a){return a.edges().reduce((i,l)=>{let d=Number.POSITIVE_INFINITY;return s.hasNode(l.v)!==s.hasNode(l.w)&&(d=e(a,l)),d<i[0]?[d,l]:i},[Number.POSITIVE_INFINITY,null])[1]}function r(s,a,i){s.nodes().forEach(l=>a.node(l).rank+=i)}return mf=function(s){var a,i,l=new t({directed:!1}),d=s.nodes()[0],u=s.nodeCount();for(l.setNode(d,{});n(l,s)<u;)a=o(l,s),i=l.hasNode(a.v)?e(s,a):-e(s,a),r(l,s,i);return l},mf}function LT(){if(rw)return pf;rw=1;var t=Rw(),e=Ll().slack,n=Ll().longestPath,o=Tn().alg.preorder,r=Tn().alg.postorder,s=_t().simplify;function a(g){g=s(g),n(g);var p,b=t(g);for(d(b),i(b,g);p=h(b);)m(b,g,p,f(b,g,p))}function i(g,p){var b=r(g,g.nodes());(b=b.slice(0,b.length-1)).forEach(y=>function(v,w,S){var N=v.node(S),j=N.parent;v.edge(S,j).cutvalue=l(v,w,S)}(g,p,y))}function l(g,p,b){var y=g.node(b).parent,v=!0,w=p.edge(b,y),S=0;return w||(v=!1,w=p.edge(y,b)),S=w.weight,p.nodeEdges(b).forEach(N=>{var j,C,_=N.v===b,A=_?N.w:N.v;if(A!==y){var I=_===v,P=p.edge(N).weight;if(S+=I?P:-P,j=b,C=A,g.hasEdge(j,C)){var R=g.edge(b,A).cutvalue;S+=I?-R:R}}}),S}function d(g,p){arguments.length<2&&(p=g.nodes()[0]),u(g,{},1,p)}function u(g,p,b,y,v){var w=b,S=g.node(y);return p[y]=!0,g.neighbors(y).forEach(N=>{Object.hasOwn(p,N)||(b=u(g,p,b,N,y))}),S.low=w,S.lim=b++,v?S.parent=v:delete S.parent,b}function h(g){return g.edges().find(p=>g.edge(p).cutvalue<0)}function f(g,p,b){var y=b.v,v=b.w;p.hasEdge(y,v)||(y=b.w,v=b.v);var w=g.node(y),S=g.node(v),N=w,j=!1;w.lim>S.lim&&(N=S,j=!0);var C=p.edges().filter(_=>j===x(g,g.node(_.v),N)&&j!==x(g,g.node(_.w),N));return C.reduce((_,A)=>e(p,A)<e(p,_)?A:_)}function m(g,p,b,y){var v=b.v,w=b.w;g.removeEdge(v,w),g.setEdge(y.v,y.w,{}),d(g),i(g,p),function(S,N){var j=S.nodes().find(_=>!N.node(_).parent),C=o(S,j);(C=C.slice(1)).forEach(_=>{var A=S.node(_).parent,I=N.edge(_,A),P=!1;I||(I=N.edge(A,_),P=!0),N.node(_).rank=N.node(A).rank+(P?I.minlen:-I.minlen)})}(g,p)}function x(g,p,b){return b.low<=p.lim&&p.lim<=b.lim}return pf=a,a.initLowLimValues=d,a.initCutValues=i,a.calcCutValue=l,a.leaveEdge=h,a.enterEdge=f,a.exchangeEdges=m,pf}function FT(){if(sw)return gf;sw=1;var t=Ll().longestPath,e=Rw(),n=LT();gf=function(s){var a=s.graph().ranker;if(a instanceof Function)return a(s);switch(s.graph().ranker){case"network-simplex":default:r(s);break;case"tight-tree":(function(i){t(i),e(i)})(s);break;case"longest-path":o(s);case"none":}};var o=t;function r(s){n(s)}return gf}function zT(){return aw||(aw=1,xf=function(t){let e=function(n){let o={},r=0;function s(a){let i=r;n.children(a).forEach(s),o[a]={low:i,lim:r++}}return n.children().forEach(s),o}(t);t.graph().dummyChains.forEach(n=>{let o=t.node(n),r=o.edgeObj,s=function(h,f,m,x){let g,p,b=[],y=[],v=Math.min(f[m].low,f[x].low),w=Math.max(f[m].lim,f[x].lim);g=m;do g=h.parent(g),b.push(g);while(g&&(f[g].low>v||w>f[g].lim));for(p=g,g=x;(g=h.parent(g))!==p;)y.push(g);return{path:b.concat(y.reverse()),lca:p}}(t,e,r.v,r.w),a=s.path,i=s.lca,l=0,d=a[l],u=!0;for(;n!==r.w;){if(o=t.node(n),u){for(;(d=a[l])!==i&&t.node(d).maxRank<o.rank;)l++;d===i&&(u=!1)}if(!u){for(;l<a.length-1&&t.node(d=a[l+1]).minRank<=o.rank;)l++;d=a[l]}t.setParent(n,d),n=t.successors(n)[0]}})}),xf}function BT(){if(iw)return bf;iw=1;let t=_t();function e(n,o,r,s,a,i,l){let d=n.children(l);if(!d.length)return void(l!==o&&n.setEdge(o,l,{weight:0,minlen:r}));let u=t.addBorderNode(n,"_bt"),h=t.addBorderNode(n,"_bb"),f=n.node(l);n.setParent(u,l),f.borderTop=u,n.setParent(h,l),f.borderBottom=h,d.forEach(m=>{e(n,o,r,s,a,i,m);let x=n.node(m),g=x.borderTop?x.borderTop:m,p=x.borderBottom?x.borderBottom:m,b=x.borderTop?s:2*s,y=g!==p?1:a-i[l]+1;n.setEdge(u,g,{weight:b,minlen:y,nestingEdge:!0}),n.setEdge(p,h,{weight:b,minlen:y,nestingEdge:!0})}),n.parent(l)||n.setEdge(o,u,{weight:0,minlen:a+i[l]})}return bf={run:function(n){let o=t.addDummyNode(n,"root",{},"_root"),r=function(d){var u={};function h(f,m){var x=d.children(f);x&&x.length&&x.forEach(g=>h(g,m+1)),u[f]=m}return d.children().forEach(f=>h(f,1)),u}(n),s=Object.values(r),a=t.applyWithChunking(Math.max,s)-1,i=2*a+1;n.graph().nestingRoot=o,n.edges().forEach(d=>n.edge(d).minlen*=i);let l=function(d){return d.edges().reduce((u,h)=>u+d.edge(h).weight,0)}(n)+1;n.children().forEach(d=>e(n,o,i,l,a,r,d)),n.graph().nodeRankFactor=i},cleanup:function(n){var o=n.graph();n.removeNode(o.nestingRoot),delete o.nestingRoot,n.edges().forEach(r=>{n.edge(r).nestingEdge&&n.removeEdge(r)})}},bf}function UT(){if(cw)return vf;function t(r){r.nodes().forEach(s=>e(r.node(s))),r.edges().forEach(s=>e(r.edge(s)))}function e(r){let s=r.width;r.width=r.height,r.height=s}function n(r){r.y=-r.y}function o(r){let s=r.x;r.x=r.y,r.y=s}return cw=1,vf={adjust:function(r){let s=r.graph().rankdir.toLowerCase();s!=="lr"&&s!=="rl"||t(r)},undo:function(r){let s=r.graph().rankdir.toLowerCase();s!=="bt"&&s!=="rl"||function(a){a.nodes().forEach(i=>n(a.node(i))),a.edges().forEach(i=>{let l=a.edge(i);l.points.forEach(n),Object.hasOwn(l,"y")&&n(l)})}(r),s!=="lr"&&s!=="rl"||(function(a){a.nodes().forEach(i=>o(a.node(i))),a.edges().forEach(i=>{let l=a.edge(i);l.points.forEach(o),Object.hasOwn(l,"x")&&o(l)})}(r),t(r))}},vf}function $T(){if(pw)return mw;pw=1;let t=_t();return mw=function(e,n){let o={};return e.forEach((r,s)=>{let a=o[r.v]={indegree:0,in:[],out:[],vs:[r.v],i:s};r.barycenter!==void 0&&(a.barycenter=r.barycenter,a.weight=r.weight)}),n.edges().forEach(r=>{let s=o[r.v],a=o[r.w];s!==void 0&&a!==void 0&&(a.indegree++,s.out.push(o[r.w]))}),function(r){let s=[];function a(l){return d=>{d.merged||(d.barycenter===void 0||l.barycenter===void 0||d.barycenter>=l.barycenter)&&function(u,h){let f=0,m=0;u.weight&&(f+=u.barycenter*u.weight,m+=u.weight),h.weight&&(f+=h.barycenter*h.weight,m+=h.weight),u.vs=h.vs.concat(u.vs),u.barycenter=f/m,u.weight=m,u.i=Math.min(h.i,u.i),h.merged=!0}(l,d)}}function i(l){return d=>{d.in.push(l),--d.indegree===0&&r.push(d)}}for(;r.length;){let l=r.pop();s.push(l),l.in.reverse().forEach(a(l)),l.out.forEach(i(l))}return s.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}(Object.values(o).filter(r=>!r.indegree))}}function VT(){if(bw)return Sf;bw=1;let t=(fw||(fw=1,hw=function(o,r=[]){return r.map(s=>{let a=o.inEdges(s);if(a.length){let i=a.reduce((l,d)=>{let u=o.edge(d),h=o.node(d.v);return{sum:l.sum+u.weight*h.order,weight:l.weight+u.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}return{v:s}})}),hw),e=$T(),n=function(){if(xw)return gw;xw=1;let o=_t();function r(s,a,i){let l;for(;a.length&&(l=a[a.length-1]).i<=i;)a.pop(),s.push(l.vs),i++;return i}return gw=function(s,a){let i=o.partition(s,p=>Object.hasOwn(p,"barycenter")),l=i.lhs,d=i.rhs.sort((p,b)=>b.i-p.i),u=[],h=0,f=0,m=0;var x;l.sort((x=!!a,(p,b)=>p.barycenter<b.barycenter?-1:p.barycenter>b.barycenter?1:x?b.i-p.i:p.i-b.i)),m=r(u,d,m),l.forEach(p=>{m+=p.vs.length,u.push(p.vs),h+=p.barycenter*p.weight,f+=p.weight,m=r(u,d,m)});let g={vs:u.flat(!0)};return f&&(g.barycenter=h/f,g.weight=f),g}}();return Sf=function o(r,s,a,i){let l=r.children(s),d=r.node(s),u=d?d.borderLeft:void 0,h=d?d.borderRight:void 0,f={};u&&(l=l.filter(p=>p!==u&&p!==h));let m=t(r,l);m.forEach(p=>{if(r.children(p.v).length){let v=o(r,p.v,a,i);f[p.v]=v,Object.hasOwn(v,"barycenter")&&(y=v,(b=p).barycenter!==void 0?(b.barycenter=(b.barycenter*b.weight+y.barycenter*y.weight)/(b.weight+y.weight),b.weight+=y.weight):(b.barycenter=y.barycenter,b.weight=y.weight))}var b,y});let x=e(m,a);(function(p,b){p.forEach(y=>{y.vs=y.vs.flatMap(v=>b[v]?b[v].vs:v)})})(x,f);let g=n(x,i);if(u&&(g.vs=[u,g.vs,h].flat(!0),r.predecessors(u).length)){let p=r.node(r.predecessors(u)[0]),b=r.node(r.predecessors(h)[0]);Object.hasOwn(g,"barycenter")||(g.barycenter=0,g.weight=0),g.barycenter=(g.barycenter*g.weight+p.order+b.order)/(g.weight+2),g.weight+=2}return g},Sf}function HT(){if(yw)return Nf;yw=1;let t=Tn().Graph,e=_t();return Nf=function(n,o,r){let s=function(i){for(var l;i.hasNode(l=e.uniqueId("_root")););return l}(n),a=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(i=>n.node(i));return n.nodes().forEach(i=>{let l=n.node(i),d=n.parent(i);(l.rank===o||l.minRank<=o&&o<=l.maxRank)&&(a.setNode(i),a.setParent(i,d||s),n[r](i).forEach(u=>{let h=u.v===i?u.w:u.v,f=a.edge(h,i),m=f!==void 0?f.weight:0;a.setEdge(h,i,{weight:n.edge(u).weight+m})}),Object.hasOwn(l,"minRank")&&a.setNode(i,{borderLeft:l.borderLeft[o],borderRight:l.borderRight[o]}))}),a},Nf}function WT(){if(kw)return jf;kw=1;let t=function(){if(dw)return wf;dw=1;let u=_t();return wf=function(h){let f={},m=h.nodes().filter(y=>!h.children(y).length),x=m.map(y=>h.node(y).rank),g=u.applyWithChunking(Math.max,x),p=u.range(g+1).map(()=>[]);function b(y){if(f[y])return;f[y]=!0;let v=h.node(y);p[v.rank].push(y),h.successors(y).forEach(b)}return m.sort((y,v)=>h.node(y).rank-h.node(v).rank).forEach(b),p},wf}(),e=function(){if(uw)return kf;uw=1;let u=_t().zipObject;function h(f,m,x){let g=u(x,x.map((S,N)=>N)),p=m.flatMap(S=>f.outEdges(S).map(N=>({pos:g[N.w],weight:f.edge(N).weight})).sort((N,j)=>N.pos-j.pos)),b=1;for(;b<x.length;)b<<=1;let y=2*b-1;b-=1;let v=new Array(y).fill(0),w=0;return p.forEach(S=>{let N=S.pos+b;v[N]+=S.weight;let j=0;for(;N>0;)N%2&&(j+=v[N+1]),N=N-1>>1,v[N]+=S.weight;w+=S.weight*j}),w}return kf=function(f,m){let x=0;for(let g=1;g<m.length;++g)x+=h(f,m[g-1],m[g]);return x},kf}(),n=VT(),o=HT(),r=(ww||(ww=1,vw=function(u,h,f){let m,x={};f.forEach(g=>{let p,b,y=u.parent(g);for(;y;){if(p=u.parent(y),p?(b=x[p],x[p]=y):(b=m,m=y),b&&b!==y)return void h.setEdge(b,y);y=p}})}),vw),s=Tn().Graph,a=_t();function i(u,h,f){return h.map(function(m){return o(u,m,f)})}function l(u,h){let f=new s;u.forEach(function(m){let x=m.graph().root,g=n(m,x,f,h);g.vs.forEach((p,b)=>m.node(p).order=b),r(m,f,g.vs)})}function d(u,h){Object.values(h).forEach(f=>f.forEach((m,x)=>u.node(m).order=x))}return jf=function u(h,f){if(f&&typeof f.customOrder=="function")return void f.customOrder(h,u);let m=a.maxRank(h),x=i(h,a.range(1,m+1),"inEdges"),g=i(h,a.range(m-1,-1,-1),"outEdges"),p=t(h);if(d(h,p),f&&f.disableOptimalOrderHeuristic)return;let b,y=Number.POSITIVE_INFINITY;for(let v=0,w=0;w<4;++v,++w){l(v%2?x:g,v%4>=2),p=a.buildLayerMatrix(h);let S=e(h,p);S<y&&(w=0,b=Object.assign({},p),y=S)}d(h,b)},jf}function qT(){if(Sw)return Cf;Sw=1;let t=Tn().Graph,e=_t();function n(h,f){let m={};return f.length&&f.reduce(function(x,g){let p=0,b=0,y=x.length,v=g[g.length-1];return g.forEach((w,S)=>{let N=function(C,_){if(C.node(_).dummy)return C.predecessors(_).find(A=>C.node(A).dummy)}(h,w),j=N?h.node(N).order:y;(N||w===v)&&(g.slice(b,S+1).forEach(C=>{h.predecessors(C).forEach(_=>{let A=h.node(_),I=A.order;!(I<p||j<I)||A.dummy&&h.node(C).dummy||r(m,_,C)})}),b=S+1,p=j)}),g}),m}function o(h,f){let m={};function x(g,p,b,y,v){let w;e.range(p,b).forEach(S=>{w=g[S],h.node(w).dummy&&h.predecessors(w).forEach(N=>{let j=h.node(N);j.dummy&&(j.order<y||j.order>v)&&r(m,N,w)})})}return f.length&&f.reduce(function(g,p){let b,y=-1,v=0;return p.forEach((w,S)=>{if(h.node(w).dummy==="border"){let N=h.predecessors(w);N.length&&(b=h.node(N[0]).order,x(p,v,S,y,b),v=S,y=b)}x(p,v,p.length,b,g.length)}),p}),m}function r(h,f,m){if(f>m){let g=f;f=m,m=g}let x=h[f];x||(h[f]=x={}),x[m]=!0}function s(h,f,m){if(f>m){let x=f;f=m,m=x}return!!h[f]&&Object.hasOwn(h[f],m)}function a(h,f,m,x){let g={},p={},b={};return f.forEach(y=>{y.forEach((v,w)=>{g[v]=v,p[v]=v,b[v]=w})}),f.forEach(y=>{let v=-1;y.forEach(w=>{let S=x(w);if(S.length){S=S.sort((j,C)=>b[j]-b[C]);let N=(S.length-1)/2;for(let j=Math.floor(N),C=Math.ceil(N);j<=C;++j){let _=S[j];p[w]===w&&v<b[_]&&!s(m,w,_)&&(p[_]=w,p[w]=g[w]=g[_],v=b[_])}}})}),{root:g,align:p}}function i(h,f,m,x,g){let p={},b=function(w,S,N,j){let C=new t,_=w.graph(),A=function(I,P,R){return(M,L,F)=>{let D,T=M.node(L),k=M.node(F),B=0;if(B+=T.width/2,Object.hasOwn(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":D=-T.width/2;break;case"r":D=T.width/2}if(D&&(B+=R?D:-D),D=0,B+=(T.dummy?P:I)/2,B+=(k.dummy?P:I)/2,B+=k.width/2,Object.hasOwn(k,"labelpos"))switch(k.labelpos.toLowerCase()){case"l":D=k.width/2;break;case"r":D=-k.width/2}return D&&(B+=R?D:-D),D=0,B}}(_.nodesep,_.edgesep,j);return S.forEach(I=>{let P;I.forEach(R=>{let M=N[R];if(C.setNode(M),P){var L=N[P],F=C.edge(L,M);C.setEdge(L,M,Math.max(A(w,R,P),F||0))}P=R})}),C}(h,f,m,g),y=g?"borderLeft":"borderRight";function v(w,S){let N=b.nodes(),j=N.pop(),C={};for(;j;)C[j]?w(j):(C[j]=!0,N.push(j),N=N.concat(S(j))),j=N.pop()}return v(function(w){p[w]=b.inEdges(w).reduce((S,N)=>Math.max(S,p[N.v]+b.edge(N)),0)},b.predecessors.bind(b)),v(function(w){let S=b.outEdges(w).reduce((j,C)=>Math.min(j,p[C.w]-b.edge(C)),Number.POSITIVE_INFINITY),N=h.node(w);S!==Number.POSITIVE_INFINITY&&N.borderType!==y&&(p[w]=Math.max(p[w],S))},b.successors.bind(b)),Object.keys(x).forEach(w=>p[w]=p[m[w]]),p}function l(h,f){return Object.values(f).reduce((m,x)=>{let g=Number.NEGATIVE_INFINITY,p=Number.POSITIVE_INFINITY;Object.entries(x).forEach(([y,v])=>{let w=function(S,N){return S.node(N).width}(h,y)/2;g=Math.max(v+w,g),p=Math.min(v-w,p)});const b=g-p;return b<m[0]&&(m=[b,x]),m},[Number.POSITIVE_INFINITY,null])[1]}function d(h,f){let m=Object.values(f),x=e.applyWithChunking(Math.min,m),g=e.applyWithChunking(Math.max,m);["u","d"].forEach(p=>{["l","r"].forEach(b=>{let y=p+b,v=h[y];if(v===f)return;let w=Object.values(v),S=x-e.applyWithChunking(Math.min,w);b!=="l"&&(S=g-e.applyWithChunking(Math.max,w)),S&&(h[y]=e.mapValues(v,N=>N+S))})})}function u(h,f){return e.mapValues(h.ul,(m,x)=>{if(f)return h[f.toLowerCase()][x];{let g=Object.values(h).map(p=>p[x]).sort((p,b)=>p-b);return(g[1]+g[2])/2}})}return Cf={positionX:function(h){let f,m=e.buildLayerMatrix(h),x=Object.assign(n(h,m),o(h,m)),g={};["u","d"].forEach(b=>{f=b==="u"?m:Object.values(m).reverse(),["l","r"].forEach(y=>{y==="r"&&(f=f.map(N=>Object.values(N).reverse()));let v=(b==="u"?h.predecessors:h.successors).bind(h),w=a(h,f,x,v),S=i(h,f,w.root,w.align,y==="r");y==="r"&&(S=e.mapValues(S,N=>-N)),g[b+y]=S})});let p=l(h,g);return d(g,p),u(g,h.graph().align)},findType1Conflicts:n,findType2Conflicts:o,addConflict:r,hasConflict:s,verticalAlignment:a,horizontalCompaction:i,alignCoordinates:d,findSmallestWidthAlignment:l,balance:u},Cf}function GT(){if(Nw)return Ef;Nw=1;let t=_t(),e=qT().positionX;return Ef=function(n){n=t.asNonCompoundGraph(n),function(o){let r=t.buildLayerMatrix(o),s=o.graph().ranksep,a=0;r.forEach(i=>{const l=i.reduce((d,u)=>{const h=o.node(u).height;return d>h?d:h},0);i.forEach(d=>o.node(d).y=a+l/2),a+=l+s})}(n),Object.entries(e(n)).forEach(([o,r])=>n.node(o).x=r)},Ef}function YT(){if(jw)return _f;jw=1;let t=PT(),e=RT(),n=FT(),o=_t().normalizeRanks,r=zT(),s=_t().removeEmptyRanks,a=BT(),i=function(){if(lw)return yf;lw=1;let j=_t();function C(_,A,I,P,R,M){let L={width:0,height:0,rank:M,borderType:A},F=R[A][M-1],D=j.addDummyNode(_,"border",L,I);R[A][M]=D,_.setParent(D,P),F&&_.setEdge(F,D,{weight:1})}return yf=function(_){_.children().forEach(function A(I){let P=_.children(I),R=_.node(I);if(P.length&&P.forEach(A),Object.hasOwn(R,"minRank")){R.borderLeft=[],R.borderRight=[];for(let M=R.minRank,L=R.maxRank+1;M<L;++M)C(_,"borderLeft","_bl",I,R,M),C(_,"borderRight","_br",I,R,M)}})},yf}(),l=UT(),d=WT(),u=GT(),h=_t(),f=Tn().Graph;_f=function(j,C){let _=C&&C.debugTiming?h.time:h.notime;_("layout",()=>{let A=_(" buildLayoutGraph",()=>function(I){let P=new f({multigraph:!0,compound:!0}),R=N(I.graph());return P.setGraph(Object.assign({},x,S(R,m),h.pick(R,g))),I.nodes().forEach(M=>{const L=S(N(I.node(M)),p);Object.keys(b).forEach(F=>{L[F]===void 0&&(L[F]=b[F])}),P.setNode(M,L),P.setParent(M,I.parent(M))}),I.edges().forEach(M=>{let L=N(I.edge(M));P.setEdge(M,Object.assign({},v,S(L,y),h.pick(L,w)))}),P}(j));_(" runLayout",()=>function(I,P,R){P(" makeSpaceForEdgeLabels",()=>function(M){let L=M.graph();L.ranksep/=2,M.edges().forEach(F=>{let D=M.edge(F);D.minlen*=2,D.labelpos.toLowerCase()!=="c"&&(L.rankdir==="TB"||L.rankdir==="BT"?D.width+=D.labeloffset:D.height+=D.labeloffset)})}(I)),P(" removeSelfEdges",()=>function(M){M.edges().forEach(L=>{if(L.v===L.w){var F=M.node(L.v);F.selfEdges||(F.selfEdges=[]),F.selfEdges.push({e:L,label:M.edge(L)}),M.removeEdge(L)}})}(I)),P(" acyclic",()=>t.run(I)),P(" nestingGraph.run",()=>a.run(I)),P(" rank",()=>n(h.asNonCompoundGraph(I))),P(" injectEdgeLabelProxies",()=>function(M){M.edges().forEach(L=>{let F=M.edge(L);if(F.width&&F.height){let D=M.node(L.v),T={rank:(M.node(L.w).rank-D.rank)/2+D.rank,e:L};h.addDummyNode(M,"edge-proxy",T,"_ep")}})}(I)),P(" removeEmptyRanks",()=>s(I)),P(" nestingGraph.cleanup",()=>a.cleanup(I)),P(" normalizeRanks",()=>o(I)),P(" assignRankMinMax",()=>function(M){let L=0;M.nodes().forEach(F=>{let D=M.node(F);D.borderTop&&(D.minRank=M.node(D.borderTop).rank,D.maxRank=M.node(D.borderBottom).rank,L=Math.max(L,D.maxRank))}),M.graph().maxRank=L}(I)),P(" removeEdgeLabelProxies",()=>function(M){M.nodes().forEach(L=>{let F=M.node(L);F.dummy==="edge-proxy"&&(M.edge(F.e).labelRank=F.rank,M.removeNode(L))})}(I)),P(" normalize.run",()=>e.run(I)),P(" parentDummyChains",()=>r(I)),P(" addBorderSegments",()=>i(I)),P(" order",()=>d(I,R)),P(" insertSelfEdges",()=>function(M){var L=h.buildLayerMatrix(M);L.forEach(F=>{var D=0;F.forEach((T,k)=>{var B=M.node(T);B.order=k+D,(B.selfEdges||[]).forEach(E=>{h.addDummyNode(M,"selfedge",{width:E.label.width,height:E.label.height,rank:B.rank,order:k+ ++D,e:E.e,label:E.label},"_se")}),delete B.selfEdges})})}(I)),P(" adjustCoordinateSystem",()=>l.adjust(I)),P(" position",()=>u(I)),P(" positionSelfEdges",()=>function(M){M.nodes().forEach(L=>{var F=M.node(L);if(F.dummy==="selfedge"){var D=M.node(F.e.v),T=D.x+D.width/2,k=D.y,B=F.x-T,E=D.height/2;M.setEdge(F.e,F.label),M.removeNode(L),F.label.points=[{x:T+2*B/3,y:k-E},{x:T+5*B/6,y:k-E},{x:T+B,y:k},{x:T+5*B/6,y:k+E},{x:T+2*B/3,y:k+E}],F.label.x=F.x,F.label.y=F.y}})}(I)),P(" removeBorderNodes",()=>function(M){M.nodes().forEach(L=>{if(M.children(L).length){let F=M.node(L),D=M.node(F.borderTop),T=M.node(F.borderBottom),k=M.node(F.borderLeft[F.borderLeft.length-1]),B=M.node(F.borderRight[F.borderRight.length-1]);F.width=Math.abs(B.x-k.x),F.height=Math.abs(T.y-D.y),F.x=k.x+F.width/2,F.y=D.y+F.height/2}}),M.nodes().forEach(L=>{M.node(L).dummy==="border"&&M.removeNode(L)})}(I)),P(" normalize.undo",()=>e.undo(I)),P(" fixupEdgeLabelCoords",()=>function(M){M.edges().forEach(L=>{let F=M.edge(L);if(Object.hasOwn(F,"x"))switch(F.labelpos!=="l"&&F.labelpos!=="r"||(F.width-=F.labeloffset),F.labelpos){case"l":F.x-=F.width/2+F.labeloffset;break;case"r":F.x+=F.width/2+F.labeloffset}})}(I)),P(" undoCoordinateSystem",()=>l.undo(I)),P(" translateGraph",()=>function(M){let L=Number.POSITIVE_INFINITY,F=0,D=Number.POSITIVE_INFINITY,T=0,k=M.graph(),B=k.marginx||0,E=k.marginy||0;function U(V){let $=V.x,X=V.y,Y=V.width,J=V.height;L=Math.min(L,$-Y/2),F=Math.max(F,$+Y/2),D=Math.min(D,X-J/2),T=Math.max(T,X+J/2)}M.nodes().forEach(V=>U(M.node(V))),M.edges().forEach(V=>{let $=M.edge(V);Object.hasOwn($,"x")&&U($)}),L-=B,D-=E,M.nodes().forEach(V=>{let $=M.node(V);$.x-=L,$.y-=D}),M.edges().forEach(V=>{let $=M.edge(V);$.points.forEach(X=>{X.x-=L,X.y-=D}),Object.hasOwn($,"x")&&($.x-=L),Object.hasOwn($,"y")&&($.y-=D)}),k.width=F-L+B,k.height=T-D+E}(I)),P(" assignNodeIntersects",()=>function(M){M.edges().forEach(L=>{let F,D,T=M.edge(L),k=M.node(L.v),B=M.node(L.w);T.points?(F=T.points[0],D=T.points[T.points.length-1]):(T.points=[],F=B,D=k),T.points.unshift(h.intersectRect(k,F)),T.points.push(h.intersectRect(B,D))})}(I)),P(" reversePoints",()=>function(M){M.edges().forEach(L=>{let F=M.edge(L);F.reversed&&F.points.reverse()})}(I)),P(" acyclic.undo",()=>t.undo(I))}(A,_,C)),_(" updateInputGraph",()=>function(I,P){I.nodes().forEach(R=>{let M=I.node(R),L=P.node(R);M&&(M.x=L.x,M.y=L.y,M.rank=L.rank,P.children(R).length&&(M.width=L.width,M.height=L.height))}),I.edges().forEach(R=>{let M=I.edge(R),L=P.edge(R);M.points=L.points,Object.hasOwn(L,"x")&&(M.x=L.x,M.y=L.y)}),I.graph().width=P.graph().width,I.graph().height=P.graph().height}(j,A))})};let m=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},g=["acyclicer","ranker","rankdir","align"],p=["width","height","rank"],b={width:0,height:0},y=["minlen","weight","width","height","labeloffset"],v={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},w=["labelpos"];function S(j,C){return h.mapValues(h.pick(j,C),Number)}function N(j){var C={};return j&&Object.entries(j).forEach(([_,A])=>{typeof _=="string"&&(_=_.toLowerCase()),C[_]=A}),C}return _f}function KT(){if(Cw)return If;Cw=1;let t=_t(),e=Tn().Graph;return If={debugOrdering:function(n){let o=t.buildLayerMatrix(n),r=new e({compound:!0,multigraph:!0}).setGraph({});return n.nodes().forEach(s=>{r.setNode(s,{label:s}),r.setParent(s,"layer"+n.node(s).rank)}),n.edges().forEach(s=>r.setEdge(s.v,s.w,{},s.name)),o.forEach((s,a)=>{let i="layer"+a;r.setNode(i,{rank:"same"}),s.reduce((l,d)=>(r.setEdge(l,d,{style:"invis"}),d))}),r}},If}var Lw=Aw?Iw:(Aw=1,Iw={graphlib:Tn(),layout:YT(),debug:KT(),util:{time:_t().time,notime:_t().notime},version:_w?Ew:(_w=1,Ew="1.1.5")});const Sa=new Lw.graphlib.Graph().setDefaultEdgeLabel(()=>({})),Fw=({nodes:t,edges:e,direction:n})=>(Sa.setGraph({rankdir:n,nodesep:150,ranksep:200,ranker:"longest-path"}),e.forEach(o=>Sa.setEdge(o.source,o.target)),t.forEach(o=>Sa.setNode(o.id,{...o,width:o.width??0,height:o.height??0})),Lw.layout(Sa),{nodes:t.map(o=>{const{x:r,y:s}=Sa.node(o.id);return{...o,position:{x:r,y:s}}}),edges:e}),zw=new class{createEdge(t,e){return{animated:!0,markerEnd:{type:Gr.ArrowClosed},id:`${t}-${e}`,style:{strokeWidth:2},source:t,sourceHandle:"outputs",targetHandle:"inputs",target:e}}createNode(t,e){return{id:t,data:{atom:e,forceWidth:300},width:300,type:"custom",height:Hh(Qe.get(e).code.trim().split(`
147
- `).length),position:{x:0,y:0}}}createElements(t,e,n,o){const r=[],s=[],a=new Set,i=new Set;for(const l of Object.values(n)){if(l.value==="marimo"&&l.name==="mo")continue;const{declaredBy:d,usedBy:u}=l;for(const h of d)for(const f of u){const m=`${h}-${f}`;i.has(m)||(i.add(m),a.add(h),a.add(f),s.push(this.createEdge(h,f)))}}for(const[l,d]of jm.zip(t,e)){o||r.push(this.createNode(l,d));const u=a.has(l),h=Qe.get(d).code.trim().startsWith("mo.md");!u&&h||r.push(this.createNode(l,d))}return{nodes:r,edges:s}}},XT=t=>{const e=H.c(43),{cellIds:n,variables:o,cellAtoms:r,children:s,layoutDirection:a,settings:i}=t;let l;e[0]!==r||e[1]!==n||e[2]!==a||e[3]!==i.hidePureMarkdown||e[4]!==o?(l=()=>{let k=zw.createElements(n,r,o,i.hidePureMarkdown);return k=Fw({nodes:k.nodes,edges:k.edges,direction:a}),k},e[0]=r,e[1]=n,e[2]=a,e[3]=i.hidePureMarkdown,e[4]=o,e[5]=l):l=e[5];const[d]=O.useState(l),[u,h,f]=x2(d.nodes),[m,x,g]=b2(d.edges),p=va();let b;e[6]!==a||e[7]!==x||e[8]!==h?(b=k=>{const B=Fw({nodes:k.nodes,edges:k.edges,direction:a});h(B.nodes),x(B.edges)},e[6]=a,e[7]=x,e[8]=h,e[9]=b):b=e[9];const y=Fe(b);let v,w;e[10]!==r||e[11]!==n||e[12]!==i.hidePureMarkdown||e[13]!==y||e[14]!==o?(v=()=>{y(zw.createElements(n,r,o,i.hidePureMarkdown))},w=[n,o,r,y,i.hidePureMarkdown],e[10]=r,e[11]=n,e[12]=i.hidePureMarkdown,e[13]=y,e[14]=o,e[15]=v,e[16]=w):(v=e[15],w=e[16]),O.useEffect(v,w);const[S,N]=O.useState();let j;j2(),e[17]===Symbol.for("react.memo_cache_sentinel")?(j=()=>{N(void 0)},e[17]=j):j=e[17];const C=j;let _,A,I,P,R,M,L,F,D,T;return e[18]===Symbol.for("react.memo_cache_sentinel")?(_={minZoom:.5,maxZoom:1.5},A=(k,B)=>{N({type:"node",id:B.id})},I=(k,B)=>{const{source:E,target:U}=B;N({type:"edge",source:E,target:U})},e[18]=_,e[19]=A,e[20]=I):(_=e[18],A=e[19],I=e[20]),e[21]===Symbol.for("react.memo_cache_sentinel")?(P=c.jsx(gT,{color:"#ccc",variant:Sn.Dots}),e[21]=P):P=e[21],e[22]!==p||e[23]!==u?(R=()=>{const k=Qe.get(GP);if(k){const B=u.find(E=>E.id===k);B&&(p.fitView({padding:1,duration:600,nodes:[B]}),N({type:"node",id:k}))}},e[22]=p,e[23]=u,e[24]=R):R=e[24],e[25]===Symbol.for("react.memo_cache_sentinel")?(M=c.jsx(lp,{className:"size-4"}),e[25]=M):M=e[25],e[26]!==R?(L=c.jsx(dT,{position:"bottom-right",showInteractive:!1,children:c.jsx(Ne,{content:"Jump to focused cell",delayDuration:200,side:"left",asChild:!1,children:c.jsx(ts,{onMouseDown:Dn.preventFocus,onClick:R,children:M})})}),e[26]=R,e[27]=L):L=e[27],e[28]!==m||e[29]!==S||e[30]!==o?(F=c.jsx(Rl,{selection:S,variables:o,edges:m,onClearSelection:C}),e[28]=m,e[29]=S,e[30]=o,e[31]=F):F=e[31],e[32]!==s||e[33]!==m||e[34]!==u||e[35]!==g||e[36]!==f||e[37]!==L||e[38]!==F?(D=c.jsxs(Vh,{nodes:u,edges:m,nodeTypes:S2,minZoom:.2,fitViewOptions:_,onNodeClick:A,onEdgeClick:I,onNodeDoubleClick:JT,fitView:!0,onNodesChange:f,onEdgesChange:g,zoomOnDoubleClick:!1,nodesConnectable:!1,children:[P,L,F,s]}),e[32]=s,e[33]=m,e[34]=u,e[35]=g,e[36]=f,e[37]=L,e[38]=F,e[39]=D):D=e[39],e[40]!==a||e[41]!==D?(T=c.jsx(w2,{value:a,children:D}),e[40]=a,e[41]=D,e[42]=T):T=e[42],T};function JT(t,e){Y3(e.id,"focus")}const ZT=mt("_minimap_"),QT=mt({hidePureMarkdown:!0}),eM=t=>{const e=H.c(11),[n,o]=St(ZT),[r,s]=St(QT);let a;e[0]!==n||e[1]!==t||e[2]!==o||e[3]!==s||e[4]!==r?(a=()=>n==="_minimap_"?c.jsx(wT,{...t,children:c.jsx(qh,{settings:r,onSettingsChange:s,view:n,onChange:o})}):c.jsx(XT,{...t,settings:r,layoutDirection:n,children:c.jsx(qh,{settings:r,onSettingsChange:s,view:n,onChange:o})}),e[0]=n,e[1]=t,e[2]=o,e[3]=s,e[4]=r,e[5]=a):a=e[5];const i=a;let l,d;return e[6]!==i?(l=i(),e[6]=i,e[7]=l):l=e[7],e[8]!==n||e[9]!==l?(d=c.jsx($h,{children:l},n),e[8]=n,e[9]=l,e[10]=d):d=e[10],d},tM=()=>{const t=H.c(5),e=_m(),n=Tc(),[o]=YP();let r,s;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=ge("w-full h-full flex-1 mx-auto -mb-4 relative"),t[0]=r):r=t[0],t[1]!==n.inOrderIds||t[2]!==o||t[3]!==e?(s=c.jsx("div",{className:r,children:c.jsx(eM,{cellAtoms:o,variables:e,cellIds:n.inOrderIds})}),t[1]=n.inOrderIds,t[2]=o,t[3]=e,t[4]=s):s=t[4],s},nM=t=>{const e=H.c(4),{isOpen:n,children:o}=t,[r,s]=G.useState(!1);let a,i;return e[0]!==r||e[1]!==n?(a=()=>{n&&!r&&s(!0)},i=[n,r],e[0]=r,e[1]=n,e[2]=a,e[3]=i):(a=e[2],i=e[3]),G.useEffect(a,i),r?o:null},oM=t=>{const e=H.c(8),{variableName:n,className:o}=t;let r;e[0]!==n?(r=()=>{const l=function(u){const h=Qe.get(dc)[u];if(h)return h.declaredBy[0]}(n);if(!l)return;const d=Ia(l);d&&Em(d,n)},e[0]=n,e[1]=r):r=e[1];const s=r;let a,i;return e[2]!==o?(a=ge("text-link opacity-80 hover:opacity-100 hover:underline",o),e[2]=o,e[3]=a):a=e[3],e[4]!==s||e[5]!==a||e[6]!==n?(i=c.jsx("button",{type:"button",onClick:s,className:a,children:n}),e[4]=s,e[5]=a,e[6]=n,e[7]=i):i=e[7],i},rM=mt(t=>{const e=t(KP),n=t(dc),o=t(jc);return oi(e,r=>{if(!r.variable_name)return-1;const s=Object.values(n).find(i=>i.name===r.variable_name);if(!s)return 0;const a=o.inOrderIds.indexOf(s.declaredBy[0]);return a===-1?0:a})}),sM=mt(t=>{const e=new Map(t(XP));for(const n of K3){const o=e.get(n);o&&o.databases.length===0&&e.delete(n)}return oi([...e.values()],n=>K3.has(n.name)?1:0)}),aM=()=>{const t=H.c(32),[e,n]=G.useState(""),o=kt(X3),r=Ie(rM),s=Ie(sM);if(r.length===0&&s.length===0){let b;return t[0]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(sn,{title:"No tables found",description:"Any datasets/dataframes in the global scope will be shown here.",action:c.jsx(cg,{children:c.jsxs(ke,{variant:"outline",size:"sm",children:["Add database or catalog",c.jsx(Ko,{className:"h-4 w-4 ml-2"})]})}),icon:c.jsx(Wo,{})}),t[0]=b):b=t[0],b}const a=!!e.trim();let i,l,d,u,h,f,m,x,g,p;if(t[1]!==o?(i=b=>{o(b.length>0),n(b)},t[1]=o,t[2]=i):i=t[2],t[3]!==e||t[4]!==i?(l=c.jsx(Ma,{placeholder:"Search tables...",className:"h-6 m-1",value:e,onValueChange:i,rootClassName:"flex-1 border-r"}),t[3]=e,t[4]=i,t[5]=l):l=t[5],t[6]!==a?(d=a&&c.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:c.jsx(En,{className:"h-4 w-4"})}),t[6]=a,t[7]=d):d=t[7],t[8]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx(cg,{children:c.jsx("button",{type:"button",className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:c.jsx(Ko,{className:"h-4 w-4"})})}),t[8]=u):u=t[8],t[9]!==l||t[10]!==d?(h=c.jsxs("div",{className:"flex items-center w-full",children:[l,d,u]}),t[9]=l,t[10]=d,t[11]=h):h=t[11],t[12]!==s||t[13]!==a||t[14]!==e){let b;t[16]!==a||t[17]!==e?(b=y=>c.jsx(iM,{connection:y,hasChildren:y.databases.length>0,children:y.databases.map(v=>c.jsx(lM,{engineName:y.name,database:v,hasSearch:a,children:c.jsx(cM,{schemas:v.schemas,defaultSchema:y.default_schema,defaultDatabase:y.default_database,engineName:y.name,databaseName:v.name,hasSearch:a,searchValue:e})},v.name))},y.name),t[16]=a,t[17]=e,t[18]=b):b=t[18],f=s.map(b),t[12]=s,t[13]=a,t[14]=e,t[15]=f}else f=t[15];return t[19]!==s.length||t[20]!==r.length?(m=s.length>0&&r.length>0&&c.jsxs(J3,{children:[c.jsx(Yl,{className:"h-4 w-4 text-muted-foreground"}),c.jsx("span",{className:"text-xs",children:"Python"})]}),t[19]=s.length,t[20]=r.length,t[21]=m):m=t[21],t[22]!==e||t[23]!==r?(x=r.length>0&&c.jsx(Bw,{tables:r,searchValue:e}),t[22]=e,t[23]=r,t[24]=x):x=t[24],t[25]!==f||t[26]!==m||t[27]!==x?(g=c.jsxs(xm,{className:"flex flex-col",children:[f,m,x]}),t[25]=f,t[26]=m,t[27]=x,t[28]=g):g=t[28],t[29]!==h||t[30]!==g?(p=c.jsxs(ic,{className:"border-b bg-background rounded-none h-full pb-10 overflow-auto outline-none",shouldFilter:!1,children:[h,g]}),t[29]=h,t[30]=g,t[31]=p):p=t[31],p},iM=t=>{const e=H.c(25),{connection:n,children:o,hasChildren:r}=t,s=n.name===JP,a=s?"In-Memory":n.name,[i,l]=G.useState(!1);let d;e[0]!==n.name?(d=async()=>{l(!0),await QP({engine:n.name}),setTimeout(()=>l(!1),500)},e[0]=n.name,e[1]=d):d=e[1];const u=d;let h,f,m;e[2]!==n.dialect?(h=c.jsx(zk,{className:"h-4 w-4 text-muted-foreground",name:n.dialect}),e[2]=n.dialect,e[3]=h):h=e[3],e[4]!==n.dialect?(f=ZP(n.dialect),e[4]=n.dialect,e[5]=f):f=e[5],e[6]!==f?(m=c.jsx("span",{className:"text-xs",children:f}),e[6]=f,e[7]=m):m=e[7];const x=a;let g,p,b,y,v;return e[8]!==x?(g=c.jsxs("span",{className:"text-xs text-muted-foreground",children:["(",c.jsx(oM,{variableName:x}),")"]}),e[8]=x,e[9]=g):g=e[9],e[10]!==u||e[11]!==s||e[12]!==i?(p=!s&&c.jsx(Ne,{content:"Refresh connection",children:c.jsx(ke,{variant:"ghost",size:"icon",className:"ml-auto hover:bg-transparent hover:shadow-none",onClick:u,children:c.jsx(yc,{className:ge("h-4 w-4 text-muted-foreground hover:text-foreground",i&&"animate-[spin_0.5s]")})})}),e[10]=u,e[11]=s,e[12]=i,e[13]=p):p=e[13],e[14]!==h||e[15]!==m||e[16]!==g||e[17]!==p?(b=c.jsxs(J3,{children:[h,m,g,p]}),e[14]=h,e[15]=m,e[16]=g,e[17]=p,e[18]=b):b=e[18],e[19]!==o||e[20]!==r?(y=r?o:c.jsx(Mc,{content:"No databases available",className:"pl-2"}),e[19]=o,e[20]=r,e[21]=y):y=e[21],e[22]!==b||e[23]!==y?(v=c.jsxs(c.Fragment,{children:[b,y]}),e[22]=b,e[23]=y,e[24]=v):v=e[24],v},lM=t=>{const e=H.c(28),{hasSearch:n,engineName:o,database:r,children:s}=t,[a,i]=G.useState(!1),[l,d]=G.useState(!1);let u,h,f;e[0]!==n?(u=()=>{i(n)},h=[n],e[0]=n,e[1]=u,e[2]=h):(u=e[1],h=e[2]),G.useEffect(u,h),e[3]!==a||e[4]!==l?(f=()=>{i(!a),d(!l)},e[3]=a,e[4]=l,e[5]=f):f=e[5];const m=`${o}:${r.name}`;let x;e[6]!==a?(x=c.jsx(oS,{isExpanded:a}),e[6]=a,e[7]=x):x=e[7];const g=l&&a?"text-foreground":"text-muted-foreground";let p,b;e[8]!==g?(p=ge("h-4 w-4",g),e[8]=g,e[9]=p):p=e[9],e[10]!==p?(b=c.jsx(Wo,{className:p}),e[10]=p,e[11]=b):b=e[11];const y=l&&a&&"font-semibold";let v,w,S,N;e[12]!==y?(v=ge(y),e[12]=y,e[13]=v):v=e[13],e[14]!==r.name?(w=r.name===""?c.jsx("i",{children:"Not connected"}):r.name,e[14]=r.name,e[15]=w):w=e[15],e[16]!==v||e[17]!==w?(S=c.jsx("span",{className:v,children:w}),e[16]=v,e[17]=w,e[18]=S):S=e[18],e[19]!==S||e[20]!==f||e[21]!==m||e[22]!==x||e[23]!==b?(N=c.jsxs(Gn,{className:"text-sm flex flex-row gap-1 items-center cursor-pointer rounded-none",onSelect:f,value:m,children:[x,b,S]}),e[19]=S,e[20]=f,e[21]=m,e[22]=x,e[23]=b,e[24]=N):N=e[24];const j=a&&s;let C;return e[25]!==N||e[26]!==j?(C=c.jsxs(c.Fragment,{children:[N,j]}),e[25]=N,e[26]=j,e[27]=C):C=e[27],C},cM=t=>{const e=H.c(20),{schemas:n,defaultSchema:o,defaultDatabase:r,engineName:s,databaseName:a,hasSearch:i,searchValue:l}=t;if(n.length===0){let h;return e[0]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Mc,{content:"No schemas available",className:"pl-6"}),e[0]=h):h=e[0],h}let d,u;if(e[1]!==a||e[2]!==r||e[3]!==o||e[4]!==s||e[5]!==i||e[6]!==n||e[7]!==l){let h;e[9]!==l?(h=x=>!l||x.tables.some(g=>g.name.toLowerCase().includes(l.toLowerCase())),e[9]=l,e[10]=h):h=e[10];const f=n.filter(h);let m;e[11]!==a||e[12]!==r||e[13]!==o||e[14]!==s||e[15]!==i||e[16]!==l?(m=x=>c.jsx(dM,{databaseName:a,schema:x,hasSearch:i,children:c.jsx(Bw,{tables:x.tables,searchValue:l,sqlTableContext:{engine:s,database:a,schema:x.name,defaultSchema:o,defaultDatabase:r}})},x.name),e[11]=a,e[12]=r,e[13]=o,e[14]=s,e[15]=i,e[16]=l,e[17]=m):m=e[17],d=f.map(m),e[1]=a,e[2]=r,e[3]=o,e[4]=s,e[5]=i,e[6]=n,e[7]=l,e[8]=d}else d=e[8];return e[18]!==d?(u=c.jsx(c.Fragment,{children:d}),e[18]=d,e[19]=u):u=e[19],u},dM=t=>{const e=H.c(26),{databaseName:n,schema:o,children:r,hasSearch:s}=t,[a,i]=G.useState(!1),[l,d]=G.useState(!1),u=`${n}:${o.name}`;let h,f,m,x;if(e[0]!==s?(h=()=>{i(s)},f=[s],e[0]=s,e[1]=h,e[2]=f):(h=e[1],f=e[2]),G.useEffect(h,f),nS(o.name))return r;e[3]!==a||e[4]!==l?(m=()=>{i(!a),d(!l)},e[3]=a,e[4]=l,e[5]=m):m=e[5],e[6]!==a?(x=c.jsx(oS,{isExpanded:a}),e[6]=a,e[7]=x):x=e[7];const g=l&&a&&"text-foreground";let p,b;e[8]!==g?(p=ge("h-4 w-4 text-muted-foreground",g),e[8]=g,e[9]=p):p=e[9],e[10]!==p?(b=c.jsx(aR,{className:p}),e[10]=p,e[11]=b):b=e[11];const y=l&&a&&"font-semibold";let v,w,S;e[12]!==y?(v=ge(y),e[12]=y,e[13]=v):v=e[13],e[14]!==o.name||e[15]!==v?(w=c.jsx("span",{className:v,children:o.name}),e[14]=o.name,e[15]=v,e[16]=w):w=e[16],e[17]!==w||e[18]!==m||e[19]!==x||e[20]!==b||e[21]!==u?(S=c.jsxs(Gn,{className:"text-sm flex flex-row gap-1 items-center pl-5 cursor-pointer rounded-none",onSelect:m,value:u,children:[x,b,w]}),e[17]=w,e[18]=m,e[19]=x,e[20]=b,e[21]=u,e[22]=S):S=e[22];const N=a&&r;let j;return e[23]!==S||e[24]!==N?(j=c.jsxs(c.Fragment,{children:[S,N]}),e[23]=S,e[24]=N,e[25]=j):j=e[25],j},Bw=t=>{const e=H.c(24),{tables:n,sqlTableContext:o,searchValue:r}=t,{addTableList:s}=Z3(),[a,i]=G.useState(!1),[l,d]=G.useState(!1);let u,h;e[0]!==s||e[1]!==o||e[2]!==n.length||e[3]!==a?(u=async()=>{if(n.length===0&&o&&!a){i(!0),d(!0);const{engine:p,database:b,schema:y}=o,v=await AL.request({engine:p,database:b,schema:y});if(!(v!=null&&v.tables))throw d(!1),new Error("No tables available");s({tables:v.tables,sqlTableContext:o}),d(!1)}},e[0]=s,e[1]=o,e[2]=n.length,e[3]=a,e[4]=u):u=e[4],e[5]!==o||e[6]!==n.length||e[7]!==a?(h=[n.length,o,a],e[5]=o,e[6]=n.length,e[7]=a,e[8]=h):h=e[8];const{isPending:f,error:m}=Cn(u,h);if(f||l){let p;return e[9]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(Q3,{message:"Loading tables...",className:"pl-12"}),e[9]=p):p=e[9],p}if(m){let p;return e[10]!==m?(p=c.jsx(eS,{error:m,className:"pl-12"}),e[10]=m,e[11]=p):p=e[11],p}if(n.length===0){let p;return e[12]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(Mc,{content:"No tables found",className:"pl-9"}),e[12]=p):p=e[12],p}let x,g;if(e[13]!==r||e[14]!==o||e[15]!==n){let p;e[17]!==r?(p=v=>!r||v.name.toLowerCase().includes(r.toLowerCase()),e[17]=r,e[18]=p):p=e[18];const b=n.filter(p);let y;e[19]!==r||e[20]!==o?(y=v=>c.jsx(uM,{table:v,sqlTableContext:o,isSearching:!!r},v.name),e[19]=r,e[20]=o,e[21]=y):y=e[21],x=b.map(y),e[13]=r,e[14]=o,e[15]=n,e[16]=x}else x=e[16];return e[22]!==x?(g=c.jsx(c.Fragment,{children:x}),e[22]=x,e[23]=g):g=e[23],g},uM=t=>{const e=H.c(64),{table:n,sqlTableContext:o,isSearching:r}=t,{addTable:s}=Z3(),[a,i]=G.useState(!1),[l,d]=G.useState(!1),u=n.columns.length>0;let h,f;e[0]!==s||e[1]!==a||e[2]!==o||e[3]!==n.name||e[4]!==u||e[5]!==l?(h=async()=>{if(a&&!u&&o&&!l){d(!0);const{engine:J,database:Q,schema:q}=o,K=await TL.request({engine:J,database:Q,schema:q,tableName:n.name});if(!(K!=null&&K.table))throw new Error("No table details available");s({table:K.table,sqlTableContext:o})}},e[0]=s,e[1]=a,e[2]=o,e[3]=n.name,e[4]=u,e[5]=l,e[6]=h):h=e[6],e[7]!==a||e[8]!==u?(f=[a,u],e[7]=a,e[8]=u,e[9]=f):f=e[9];const{isFetching:m,isPending:x,error:g}=Cn(h,f),p=Ie(ql),b=cs(),{createNewCell:y}=it(),v=tS();let w;e[10]!==v||e[11]!==p||e[12]!==y||e[13]!==b||e[14]!==o||e[15]!==n?(w=()=>{qn({autoInstantiate:p,createNewCell:y,fromCellId:b}),v((()=>{if(n.source_type==="catalog"){const J=o!=null&&o.database?`${o.database}.${n.name}`:n.name;return`${n.engine}.load_table("${J}")`}if(o)return rS({table:n,columnName:"*",sqlTableContext:o});switch(n.source_type){case"local":return`mo.ui.table(${n.name})`;case"duckdb":case"connection":return rS({table:n,columnName:"*",sqlTableContext:o});default:return ec(n.source_type),""}})())},e[10]=v,e[11]=p,e[12]=y,e[13]=b,e[14]=o,e[15]=n,e[16]=w):w=e[16];const S=w;let N;e[17]!==n.num_columns||e[18]!==n.num_rows?(N=()=>{const J=[];return n.num_rows!=null&&J.push(`${n.num_rows} rows`),n.num_columns!=null&&J.push(`${n.num_columns} columns`),J.length===0?null:c.jsx("div",{className:"flex flex-row gap-2 items-center pl-6 group-hover:hidden",children:c.jsx("span",{className:"text-xs text-muted-foreground",children:J.join(", ")})})},e[17]=n.num_columns,e[18]=n.num_rows,e[19]=N):N=e[19];const j=N;let C;e[20]!==g||e[21]!==m||e[22]!==x||e[23]!==o||e[24]!==n?(C=()=>{if(x||m)return c.jsx(Q3,{message:"Loading columns...",className:"pl-12"});if(g)return c.jsx(eS,{error:g,className:"pl-12"});const J=n.columns;return J.length===0?c.jsx(Mc,{content:"No columns found",className:"pl-12"}):J.map(Q=>c.jsx(hM,{table:n,column:Q,sqlTableContext:o},Q.name))},e[20]=g,e[21]=m,e[22]=x,e[23]=o,e[24]=n,e[25]=C):C=e[25];const _=C;let A;e[26]!==a||e[27]!==r||e[28]!==n.source_type||e[29]!==n.type?(A=()=>{if(n.source_type==="local")return;const J=n.type==="table"?eR:Bf;return c.jsx(J,{className:"h-3 w-3",strokeWidth:a||r?2.5:void 0})},e[26]=a,e[27]=r,e[28]=n.source_type,e[29]=n.type,e[30]=A):A=e[30];const I=A,P=o?`${o.database}.${o.schema}.${n.name}`:n.name,R=o&&(nS(o.schema)?"pl-9":"pl-12"),M=(a||r)&&"font-semibold";let L,F,D,T,k,B,E,U,V,$,X,Y;return e[31]!==R||e[32]!==M?(L=ge("rounded-none group h-8 cursor-pointer",R,M),e[31]=R,e[32]=M,e[33]=L):L=e[33],e[34]!==a?(F=()=>i(!a),e[34]=a,e[35]=F):F=e[35],e[36]!==I?(D=I(),e[36]=I,e[37]=D):D=e[37],e[38]!==n.name?(T=c.jsx("span",{className:"text-sm",children:n.name}),e[38]=n.name,e[39]=T):T=e[39],e[40]!==D||e[41]!==T?(k=c.jsxs("div",{className:"flex gap-2 items-center flex-1",children:[D,T]}),e[40]=D,e[41]=T,e[42]=k):k=e[42],e[43]!==j?(B=j(),e[43]=j,e[44]=B):B=e[44],e[45]!==S?(E=Dn.stopPropagation(()=>S()),e[45]=S,e[46]=E):E=e[46],e[47]===Symbol.for("react.memo_cache_sentinel")?(U=c.jsx(tR,{className:"h-3 w-3"}),e[47]=U):U=e[47],e[48]!==E?(V=c.jsx(Ne,{content:"Add table to notebook",delayDuration:400,children:c.jsx(ke,{className:"group-hover:inline-flex hidden",variant:"text",size:"icon",onClick:E,children:U})}),e[48]=E,e[49]=V):V=e[49],e[50]!==a||e[51]!==F||e[52]!==k||e[53]!==B||e[54]!==V||e[55]!==L||e[56]!==P?($=c.jsxs(Gn,{className:L,value:P,"aria-selected":a,forceMount:!0,onSelect:F,children:[k,B,V]}),e[50]=a,e[51]=F,e[52]=k,e[53]=B,e[54]=V,e[55]=L,e[56]=P,e[57]=$):$=e[57],e[58]!==a||e[59]!==_?(X=a&&_(),e[58]=a,e[59]=_,e[60]=X):X=e[60],e[61]!==$||e[62]!==X?(Y=c.jsxs(c.Fragment,{children:[$,X]}),e[61]=$,e[62]=X,e[63]=Y):Y=e[63],Y},hM=t=>{var E,U;const e=H.c(51),{table:n,column:o,sqlTableContext:r}=t,[s,a]=G.useState(!1),i=Ie(X3),l=kt(nR);let d,u;e[0]!==i?(d=()=>{i&&a(!1)},u=[i],e[0]=i,e[1]=d,e[2]=u):(d=e[1],u=e[2]),G.useEffect(d,u),l(s?V=>new Set([...V,`${n.name}:${o.name}`]):V=>(V.delete(`${n.name}:${o.name}`),new Set(V)));const h=tS(),{columnsPreviews:f}=oR();let m;e[3]!==o.name||e[4]!==n.primary_keys?(m=((E=n.primary_keys)==null?void 0:E.includes(o.name))||!1,e[3]=o.name,e[4]=n.primary_keys,e[5]=m):m=e[5];const x=m;let g;e[6]!==o.name||e[7]!==n.indexes?(g=((U=n.indexes)==null?void 0:U.includes(o.name))||!1,e[6]=o.name,e[7]=n.indexes,e[8]=g):g=e[8];const p=g;let b;e[9]!==h?(b=V=>{h(V)},e[9]=h,e[10]=b):b=e[10];const y=b,v=fM,w=s?"font-semibold":"";let S;e[11]!==o.name||e[12]!==w?(S=c.jsx("span",{className:w,children:o.name}),e[11]=o.name,e[12]=w,e[13]=S):S=e[13];const N=S,j=`${n.name}.${o.name}`,C=`${n.name}.${o.name}`;let _;e[14]!==s?(_=()=>a(!s),e[14]=s,e[15]=_):_=e[15];const A=r?"pl-14":"pl-7";let I,P,R,M,L,F,D,T,k,B;return e[16]!==A?(I=ge("flex flex-row gap-2 items-center flex-1",A),e[16]=A,e[17]=I):I=e[17],e[18]!==o.type||e[19]!==N?(P=c.jsx(rR,{columnName:N,dataType:o.type}),e[18]=o.type,e[19]=N,e[20]=P):P=e[20],e[21]!==x?(R=x&&v({tooltipContent:"Primary key",content:"PK"}),e[21]=x,e[22]=R):R=e[22],e[23]!==p?(M=p&&v({tooltipContent:"Indexed",content:"IDX"}),e[23]=p,e[24]=M):M=e[24],e[25]!==I||e[26]!==P||e[27]!==R||e[28]!==M?(L=c.jsxs("div",{className:I,children:[P,R,M]}),e[25]=I,e[26]=P,e[27]=R,e[28]=M,e[29]=L):L=e[29],e[30]!==o.name?(F=c.jsx(Ne,{content:"Copy column name",delayDuration:400,children:c.jsx(ke,{variant:"text",size:"icon",className:"group-hover:opacity-100 opacity-0 hover:bg-muted text-muted-foreground hover:text-foreground",children:c.jsx(W3,{tooltip:!1,value:o.name,className:"h-3 w-3"})})}),e[30]=o.name,e[31]=F):F=e[31],e[32]!==o.external_type?(D=c.jsx("span",{className:"text-xs text-muted-foreground",children:o.external_type}),e[32]=o.external_type,e[33]=D):D=e[33],e[34]!==_||e[35]!==L||e[36]!==F||e[37]!==D||e[38]!==j||e[39]!==C?(T=c.jsxs(Gn,{className:"rounded-none py-1 group cursor-pointer",value:C,onSelect:_,children:[L,F,D]},j),e[34]=_,e[35]=L,e[36]=F,e[37]=D,e[38]=j,e[39]=C,e[40]=T):T=e[40],e[41]!==o||e[42]!==f||e[43]!==y||e[44]!==s||e[45]!==r||e[46]!==n?(k=s&&c.jsx("div",{className:"pl-10 pr-2 py-2 bg-[var(--slate-1)] shadow-inner border-b",children:c.jsx(lc,{children:c.jsx(sR,{table:n,column:o,onAddColumnChart:y,preview:f.get(r?`${r.database}.${r.schema}.${n.name}:${o.name}`:`${n.name}:${o.name}`),sqlTableContext:r})})}),e[41]=o,e[42]=f,e[43]=y,e[44]=s,e[45]=r,e[46]=n,e[47]=k):k=e[47],e[48]!==T||e[49]!==k?(B=c.jsxs(c.Fragment,{children:[T,k]}),e[48]=T,e[49]=k,e[50]=B):B=e[50],B};function fM(t){const{tooltipContent:e,content:n}=t;return c.jsx(Ne,{content:e,delayDuration:100,children:c.jsx("span",{className:"text-xs text-black bg-gray-100 dark:invert rounded px-1",children:n})})}const mM=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(aM,{}),t[0]=e):e=t[0],e},pM=()=>{const t=H.c(5),{documentation:e}=Ie(iR);if(!e){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(sn,{title:"View docs as you type",description:"Move your text cursor over a symbol to see its documentation.",icon:c.jsx(Jc,{})}),t[0]=r):r=t[0],r}let n,o;return t[1]!==e?(n=Cm({html:e}),t[1]=e,t[2]=n):n=t[2],t[3]!==n?(o=c.jsx("div",{className:"p-3 overflow-y-auto overflow-x-hidden h-full docs-documentation flex flex-col gap-4",children:n}),t[3]=n,t[4]=o):o=t[4],o},gM=()=>{const t=H.c(5),e=lR();if(e.length===0){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(sn,{title:"No errors!",icon:c.jsx(gp,{})}),t[0]=r):r=t[0],r}let n,o;return t[1]!==e?(n=e.map(xM),t[1]=e,t[2]=n):n=t[2],t[3]!==n?(o=c.jsx("div",{className:"flex flex-col overflow-auto",children:n}),t[3]=n,t[4]=o):o=t[4],o};function xM(t){return c.jsxs("div",{children:[c.jsx("div",{className:"text-xs font-mono font-semibold bg-muted border-y px-2 py-1",children:c.jsx(cR,{cellId:t.cellId})}),c.jsx("div",{className:"px-2",children:c.jsx(dR,{errors:t.output.data,cellId:t.cellId},t.cellId)},t.cellId)]},t.cellId)}const Tf=new Map,bM=({file:t,onOpenNotebook:e})=>{const{theme:n}=Xo(),o=Ie(Jl),[r,s]=O.useState(""),{data:a,isPending:i,error:l,setData:d}=Cn(async()=>{const g=await Im({path:t.path}),p=g.contents||"";return s(Tf.get(t.path)||p),g},[t.path]),u=async()=>{r!==(a==null?void 0:a.contents)&&await bR({path:t.path,contents:r}).then(g=>{g.success&&(d(p=>({...p,contents:r})),s(r))})},h=O.useRef(r);if(h.current=r,O.useEffect(()=>()=>{if(!(a!=null&&a.contents))return;const g=h.current;g===a.contents?Tf.delete(t.path):Tf.set(t.path,g)},[t.path,a==null?void 0:a.contents]),l)return c.jsx(br,{error:l});if(i||!a)return null;const f=a.mimeType||"text/plain",m=f in Mf;if(!a.contents&&!m)return c.jsxs("div",{className:"grid grid-cols-2 gap-2 p-6",children:[c.jsx("div",{className:"font-bold text-muted-foreground",children:"Name"}),c.jsx("div",{children:a.file.name}),c.jsx("div",{className:"font-bold text-muted-foreground",children:"Type"}),c.jsx("div",{children:f})]});const x=c.jsxs("div",{className:"text-xs text-muted-foreground p-1 flex justify-end gap-2 border-b",children:[t.isMarimoFile&&!Jt()&&c.jsx(Ne,{content:"Open notebook",children:c.jsx(rn,{size:"small",onClick:g=>e(g),children:c.jsx(sc,{})})}),c.jsx(Ne,{content:"Download",children:c.jsx(rn,{size:"small",onClick:()=>{if(Uw(f)){const g=gR(a.contents,f);return void xR(g,a.file.name)}za(new Blob([a.contents||r],{type:f}),a.file.name)},children:c.jsx(Qf,{})})}),!Uw(f)&&c.jsxs(c.Fragment,{children:[c.jsx(Ne,{content:"Copy contents to clipboard",children:c.jsx(rn,{size:"small",onClick:async()=>{await nn(r)},children:c.jsx(Ca,{})})}),c.jsx(Ne,{content:Ht("global.save"),children:c.jsx(rn,{size:"small",color:r===a.contents?void 0:"green",onClick:u,disabled:r===a.contents,children:c.jsx(li,{})})})]})]});return f.startsWith("image/")?c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:c.jsx(uR,{base64:a.contents,mime:f})})]}):f==="text/csv"&&a.contents?c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:c.jsx(hR,{contents:a.contents})})]}):f.startsWith("audio/")?c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:c.jsx(fR,{base64:a.contents,mime:f})})]}):f.startsWith("video/")?c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:c.jsx(mR,{base64:a.contents,mime:f})})]}):f.startsWith("application/pdf")?c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-hidden flex flex-col",children:c.jsx(pR,{base64:a.contents,mime:f})})]}):c.jsxs(c.Fragment,{children:[x,c.jsx("div",{className:"flex-1 overflow-auto",children:c.jsx(O.Suspense,{children:c.jsx(Qa,{theme:n==="dark"?"dark":"light",language:Mf[f]||Mf.default,className:"border-b",extensions:[Ve.lineWrapping,_n.of([{key:o.getHotkey("global.save").key,stopPropagation:!0,run:()=>r!==a.contents&&(u(),!0)}])],value:r,onChange:s})})})]})},Uw=t=>t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t.startsWith("application/pdf"),Mf={"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"},$w=mt(new class{constructor(t){this.callbacks=t,this.delegate=new Pm([]),this.rootPath="",this.onChange=Pn.NOOP,this.path=new nc("/"),this.initialize=async e=>{if(this.onChange=e,this.delegate.data.length===0)try{const n=await this.callbacks.listFiles({path:this.rootPath});this.delegate=new Pm(n.files),this.rootPath=n.root,this.path=nc.guessDeliminator(n.root)}catch(n){Xe({title:"Failed",description:b3(n)})}this.onChange(this.delegate.data)},this.refreshAll=async e=>{const n=[this.rootPath,...e.map(r=>{var s;return(s=this.delegate.find(r))==null?void 0:s.data.path})].filter(Boolean),o=await Promise.all(n.map(r=>this.callbacks.listFiles({path:r}).catch(()=>({files:[]}))));for(const[r,s]of n.entries()){const a=o[r];s===this.rootPath?this.delegate=new Pm(a.files):this.delegate.update({id:s,changes:{children:a.files}})}this.onChange(this.delegate.data)},this.relativeFromRoot=e=>{const n=this.rootPath.endsWith(this.path.deliminator)?this.rootPath:`${this.rootPath}${this.path.deliminator}`;return e.startsWith(n)?e.slice(n.length):e},this.handleResponse=e=>e.success?e:(Xe({title:"Failed",description:e.message}),null)}async expand(t){const e=this.delegate.find(t);if(!e||!e.data.isDirectory)return!1;if(e.children&&e.children.length>0)return!0;const n=await this.callbacks.listFiles({path:e.data.path});return this.delegate.update({id:t,changes:{children:n.files}}),this.onChange(this.delegate.data),!0}async rename(t,e){const n=this.delegate.find(t);if(!n)return;const o=n.data.path,r=this.path.join(this.path.dirname(o),e);await this.callbacks.renameFileOrFolder({path:o,newPath:r}).then(this.handleResponse),this.delegate.update({id:t,changes:{name:e,path:r}}),this.onChange(this.delegate.data),await this.refreshAll([r])}async move(t,e){var o;const n=e?((o=this.delegate.find(e))==null?void 0:o.data.path)??e:this.rootPath;await Promise.all(t.map(r=>{this.delegate.move({id:r,parentId:e,index:0});const s=this.delegate.find(r);if(!s)return Promise.resolve();const a=this.path.join(n,this.path.basename(s.data.path));return this.delegate.update({id:r,changes:{path:a}}),this.callbacks.renameFileOrFolder({path:s.data.path,newPath:a}).then(this.handleResponse)})),this.onChange(this.delegate.data),await this.refreshAll([n])}async createFile(t,e){var r;const n=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath,o=await this.callbacks.createFileOrFolder({path:n,type:"file",name:t}).then(this.handleResponse);o!=null&&o.info&&(this.delegate.create({parentId:e,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async createFolder(t,e){var r;const n=e?((r=this.delegate.find(e))==null?void 0:r.data.path)??e:this.rootPath,o=await this.callbacks.createFileOrFolder({path:n,type:"directory",name:t}).then(this.handleResponse);o!=null&&o.info&&(this.delegate.create({parentId:e,index:0,data:o.info}),this.onChange(this.delegate.data),await this.refreshAll([n]))}async delete(t){const e=this.delegate.find(t);e&&(await this.callbacks.deleteFileOrFolder({path:e.data.path}).then(this.handleResponse),this.delegate.drop({id:t}),this.onChange(this.delegate.data))}}({listFiles:Gk,createFileOrFolder:Am,deleteFileOrFolder:vR,renameFileOrFolder:yR})),yM=mt({});function vM(t){return new Promise((e,n)=>{const o=new FileReader;o.onload=r=>{var s;e((s=r.target)==null?void 0:s.result)},o.onerror=r=>{n(new Error(`Failed to read blob: ${r.type}`))},o.readAsDataURL(t)})}function Vw(t){const e=H.c(4);let n;e[0]!==t?(n=t===void 0?{}:t,e[0]=t,e[1]=n):n=e[1];const o=n;let r;return e[2]!==o?(r={multiple:!0,maxSize:104857600,onError:jM,onDropRejected:kM,onDrop:wM,...o},e[2]=o,e[3]=r):r=e[3],wR(r)}async function wM(t){for(const e of t){const n=EM(CM(e));let o="";n&&(o=nc.guessDeliminator(n).dirname(n));const r=(await vM(e)).split(",")[1];await Am({path:o,type:"file",name:e.name,contents:r})}await async function(){await Qe.get($w).refreshAll([])}()}function kM(t){Xe({title:"File upload failed",description:c.jsx("div",{className:"flex flex-col gap-1",children:t.map(SM)}),variant:"danger"})}function SM(t){return c.jsxs("div",{children:[t.file.name," (",t.errors.map(NM).join(", "),")"]},t.file.name)}function NM(t){return t.message}function jM(t){ht.error(t),Xe({title:"File upload failed",description:t.message,variant:"danger"})}function CM(t){return t.webkitRelativePath?t.webkitRelativePath:"path"in t&&typeof t.path=="string"?t.path:"relativePath"in t&&typeof t.relativePath=="string"?t.relativePath:void 0}function EM(t){if(t)return t.replace(/^\/+/,"")}const Hw=G.createContext(null),_M=t=>{const e=H.c(60),{height:n}=t,o=O.useRef(null),[r]=St($w);let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=[],e[0]=s):s=e[0];const[a,i]=O.useState(s),[l,d]=O.useState(null),{openPrompt:u}=jn(),[h,f]=St(yM);let m,x;e[1]!==r?(m=()=>r.initialize(i),e[1]=r,e[2]=m):m=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(x=[],e[3]=x):x=e[3];const{isPending:g,error:p}=Cn(m,x);let b;e[4]!==h||e[5]!==r?(b=()=>{r.refreshAll(Object.keys(h).filter(k=>h[k]))},e[4]=h,e[5]=r,e[6]=b):b=e[6];const y=Fe(b);let v;e[7]!==u||e[8]!==r?(v=async()=>{u({title:"Folder name",onConfirm:async k=>{r.createFolder(k,null)}})},e[7]=u,e[8]=r,e[9]=v):v=e[9];const w=Fe(v);let S;e[10]!==u||e[11]!==r?(S=async()=>{u({title:"File name",onConfirm:async k=>{r.createFile(k,null)}})},e[10]=u,e[11]=r,e[12]=S):S=e[12];const N=Fe(S);let j;e[13]!==f?(j=()=>{var k;(k=o.current)==null||k.closeAll(),f({})},e[13]=f,e[14]=j):j=e[14];const C=Fe(j);if(g){let k;return e[15]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(bn,{size:"medium",centered:!0}),e[15]=k):k=e[15],k}if(p){let k;return e[16]!==p?(k=c.jsx(br,{error:p}),e[16]=p,e[17]=k):k=e[17],k}if(l){let k,B,E,U,V,$;return e[18]===Symbol.for("react.memo_cache_sentinel")?(k=()=>d(null),e[18]=k):k=e[18],e[19]===Symbol.for("react.memo_cache_sentinel")?(B=c.jsx(ke,{onClick:k,"data-testid":"file-explorer-back-button",variant:"text",size:"xs",className:"mb-0",children:c.jsx(vt,{size:16})}),e[19]=B):B=e[19],e[20]!==l.name?(E=c.jsxs("div",{className:"flex items-center pl-1 pr-3 flex-shrink-0 border-b justify-between",children:[B,c.jsx("span",{className:"font-bold",children:l.name})]}),e[20]=l.name,e[21]=E):E=e[21],e[22]!==l.path||e[23]!==r?(U=X=>Ww(X,r.relativeFromRoot(l.path)),e[22]=l.path,e[23]=r,e[24]=U):U=e[24],e[25]!==l||e[26]!==U?(V=c.jsx(O.Suspense,{children:c.jsx(bM,{onOpenNotebook:U,file:l})}),e[25]=l,e[26]=U,e[27]=V):V=e[27],e[28]!==E||e[29]!==V?($=c.jsxs(c.Fragment,{children:[E,V]}),e[28]=E,e[29]=V,e[30]=$):$=e[30],$}let _;e[31]!==C||e[32]!==N||e[33]!==w||e[34]!==y||e[35]!==r?(_=c.jsx(AM,{onRefresh:y,onCreateFile:N,onCreateFolder:w,onCollapseAll:C,tree:r}),e[31]=C,e[32]=N,e[33]=w,e[34]=y,e[35]=r,e[36]=_):_=e[36];const A=n-33;let I,P,R,M,L,F,D,T;return e[37]!==r?(I=async k=>{const{ids:B}=k;for(const E of B)await r.delete(E)},P=async k=>{const{id:B,name:E}=k;await r.rename(B,E)},R=async k=>{const{dragIds:B,parentId:E}=k;await r.move(B,E)},e[37]=r,e[38]=I,e[39]=P,e[40]=R):(I=e[38],P=e[39],R=e[40]),e[41]===Symbol.for("react.memo_cache_sentinel")?(M=k=>{const B=k[0];B&&(B.data.isDirectory||d(B.data))},e[41]=M):M=e[41],e[42]!==h||e[43]!==f||e[44]!==r?(L=async k=>{if(await r.expand(k)){const B=h[k]??!1;f({...h,[k]:!B})}},e[42]=h,e[43]=f,e[44]=r,e[45]=L):L=e[45],e[46]!==a||e[47]!==h||e[48]!==I||e[49]!==P||e[50]!==R||e[51]!==L||e[52]!==A?(F=c.jsx(fL,{width:"100%",ref:o,height:A,className:"h-full",data:a,initialOpenState:h,openByDefault:!1,renderCursor:PM,disableDrop:RM,onDelete:I,onRename:P,onMove:R,onSelect:M,onToggle:L,padding:15,rowHeight:30,indent:IM,overscanCount:1e3,disableMultiSelection:!0,children:OM}),e[46]=a,e[47]=h,e[48]=I,e[49]=P,e[50]=R,e[51]=L,e[52]=A,e[53]=F):F=e[53],e[54]!==F||e[55]!==r?(D=c.jsx(Hw,{value:r,children:F}),e[54]=F,e[55]=r,e[56]=D):D=e[56],e[57]!==D||e[58]!==_?(T=c.jsxs(c.Fragment,{children:[_,D]}),e[57]=D,e[58]=_,e[59]=T):T=e[59],T},IM=15,AM=t=>{const e=H.c(30),{onRefresh:n,onCreateFile:o,onCreateFolder:r,onCollapseAll:s}=t;let a;e[0]===Symbol.for("react.memo_cache_sentinel")?(a={noDrag:!0,noDragEventsBubbling:!0},e[0]=a):a=e[0];const{getRootProps:i,getInputProps:l}=Vw(a);let d,u,h,f,m,x,g,p,b,y,v,w,S,N,j;return e[1]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(ai,{size:16}),e[1]=d):d=e[1],e[2]!==o?(u=c.jsx(Ne,{content:"Add file",children:c.jsx(ke,{"data-testid":"file-explorer-add-file-button",onClick:o,variant:"text",size:"xs",children:d})}),e[2]=o,e[3]=u):u=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Vc,{size:16}),e[4]=h):h=e[4],e[5]!==r?(f=c.jsx(Ne,{content:"Add folder",children:c.jsx(ke,{"data-testid":"file-explorer-add-folder-button",onClick:r,variant:"text",size:"xs",children:h})}),e[5]=r,e[6]=f):f=e[6],e[7]!==i?(m=i({}),e[7]=i,e[8]=m):m=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(x=kR({variant:"text",size:"xs"}),g=c.jsx(NR,{size:16}),e[9]=x,e[10]=g):(x=e[9],g=e[10]),e[11]!==m?(p=c.jsx(Ne,{content:"Upload file",children:c.jsx("button",{"data-testid":"file-explorer-upload-button",...m,className:x,children:g})}),e[11]=m,e[12]=p):p=e[12],e[13]!==l?(b=l({}),e[13]=l,e[14]=b):b=e[14],e[15]!==b?(y=c.jsx("input",{...b,type:"file"}),e[15]=b,e[16]=y):y=e[16],e[17]===Symbol.for("react.memo_cache_sentinel")?(v=c.jsx(_3,{size:16}),e[17]=v):v=e[17],e[18]!==n?(w=c.jsx(Ne,{content:"Refresh",children:c.jsx(ke,{"data-testid":"file-explorer-refresh-button",onClick:n,variant:"text",size:"xs",children:v})}),e[18]=n,e[19]=w):w=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(S=c.jsx(Ym,{size:16}),e[20]=S):S=e[20],e[21]!==s?(N=c.jsx(Ne,{content:"Collapse all folders",children:c.jsx(ke,{"data-testid":"file-explorer-collapse-button",onClick:s,variant:"text",size:"xs",children:S})}),e[21]=s,e[22]=N):N=e[22],e[23]!==y||e[24]!==w||e[25]!==N||e[26]!==u||e[27]!==f||e[28]!==p?(j=c.jsxs("div",{className:"flex items-center justify-end px-2 flex-shrink-0 border-b",children:[u,f,p,y,w,N]}),e[23]=y,e[24]=w,e[25]=N,e[26]=u,e[27]=f,e[28]=p,e[29]=j):j=e[29],j},TM=t=>{const e=H.c(9),{node:n,onOpenMarimoFile:o}=t;let r,s,a;return e[0]!==n?(r=i=>{n.data.isDirectory||(i.stopPropagation(),n.select())},e[0]=n,e[1]=r):r=e[1],e[2]!==n.data.isMarimoFile||e[3]!==o?(s=n.data.isMarimoFile&&!Jt()&&c.jsxs("span",{className:"flex-shrink-0 ml-2 text-sm hidden group-hover:inline hover:underline",onClick:o,children:["open ",c.jsx(sc,{className:"inline ml-1",size:12})]}),e[2]=n.data.isMarimoFile,e[3]=o,e[4]=s):s=e[4],e[5]!==n.data.name||e[6]!==r||e[7]!==s?(a=c.jsxs("span",{className:"flex-1 overflow-hidden text-ellipsis",onClick:r,children:[n.data.name,s]}),e[5]=n.data.name,e[6]=r,e[7]=s,e[8]=a):a=e[8],a},MM=t=>{const e=H.c(10),{node:n}=t,o=O.useRef(null);let r,s,a,i,l;return e[0]!==n.data.name?(r=()=>{var d,u;(d=o.current)==null||d.focus(),(u=o.current)==null||u.setSelectionRange(0,n.data.name.lastIndexOf("."))},s=[n.data.name],e[0]=n.data.name,e[1]=r,e[2]=s):(r=e[1],s=e[2]),O.useEffect(r,s),e[3]!==n?(a=()=>n.reset(),i=d=>{d.key==="Escape"&&n.reset(),d.key==="Enter"&&n.submit(d.currentTarget.value)},e[3]=n,e[4]=a,e[5]=i):(a=e[4],i=e[5]),e[6]!==n.data.name||e[7]!==a||e[8]!==i?(l=c.jsx("input",{ref:o,className:"flex-1 bg-transparent border border-border text-muted-foreground",defaultValue:n.data.name,onClick:LM,onBlur:a,onKeyDown:i}),e[6]=n.data.name,e[7]=a,e[8]=i,e[9]=l):l=e[9],l},OM=({node:t,style:e,dragHandle:n})=>{const o=t.data.isDirectory?"directory":Wk(t.data.name),r=qk[o],{openConfirm:s,openPrompt:a}=jn(),{createNewCell:i}=it(),l=cs(),d=O.use(Hw),u=async g=>{Ww(g,d?d.relativeFromRoot(t.data.path):t.data.path)},h=async g=>{g.stopPropagation(),g.preventDefault(),s({title:"Delete file",description:`Are you sure you want to delete ${t.data.name}?`,confirmAction:c.jsx(Bk,{onClick:async()=>{await t.tree.delete(t.id)},"aria-label":"Confirm",children:"Delete"})})},f=Fe(async()=>{t.open(),a({title:"Folder name",onConfirm:async g=>{d==null||d.createFolder(g,t.id)}})}),m=Fe(async()=>{t.open(),a({title:"File name",onConfirm:async g=>{d==null||d.createFile(g,t.id)}})}),x=Fe(async()=>{var y;if(!d||t.data.isDirectory)return;const[g,p]=SR(t.data.name),b=`${g}_copy${p}`;try{const v=await Im({path:t.data.path}),w=((y=t.parent)==null?void 0:y.data.path)||"";await Am({path:w,type:"file",name:b,contents:v.contents?btoa(v.contents):void 0}),await d.refreshAll([w])}catch{Xe({title:"Failed to duplicate file",description:"Unable to create a duplicate of the file",variant:"danger"})}});return c.jsxs("div",{style:e,ref:n,className:ge("flex items-center cursor-pointer ml-1 text-muted-foreground whitespace-nowrap group"),draggable:!0,onClick:g=>{g.stopPropagation(),t.data.isDirectory&&t.toggle()},children:[c.jsx(DM,{node:t}),c.jsxs("span",{className:ge("flex items-center pl-1 py-1 cursor-pointer hover:bg-accent/50 hover:text-accent-foreground rounded-l flex-1 overflow-hidden group",t.willReceiveDrop&&t.data.isDirectory&&"bg-accent/80 hover:bg-accent/80 text-accent-foreground"),children:[t.data.isMarimoFile?c.jsx("img",{src:ML,className:"w-5 h-5 flex-shrink-0 mr-2 filter grayscale",alt:"Marimo"}):c.jsx(r,{className:"w-5 h-5 flex-shrink-0 mr-2",strokeWidth:1.5}),t.isEditing?c.jsx(MM,{node:t}):c.jsx(TM,{node:t,onOpenMarimoFile:u}),c.jsxs(ko,{modal:!1,children:[c.jsx(So,{asChild:!0,tabIndex:-1,onClick:g=>g.stopPropagation(),children:c.jsx(ke,{"data-testid":"file-explorer-more-button",variant:"text",tabIndex:-1,size:"xs",className:"mb-0","aria-label":"More options",children:c.jsx($c,{strokeWidth:2,className:"w-5 h-5 hidden group-hover:block"})})}),(()=>{const g={size:14,strokeWidth:1.5,className:"mr-2"};return c.jsxs(No,{align:"end",className:"no-print w-[220px]",onClick:p=>p.stopPropagation(),onCloseAutoFocus:p=>p.preventDefault(),children:[!t.data.isDirectory&&c.jsxs(It,{onSelect:()=>t.select(),children:[c.jsx(Tp,{...g}),"Open file"]}),!t.data.isDirectory&&!Jt()&&c.jsxs(It,{onSelect:()=>{jR({path:t.data.path})},children:[c.jsx(sc,{...g}),"Open file in external editor"]}),t.data.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsxs(It,{onSelect:()=>m(),children:[c.jsx(ai,{...g}),"Create file"]}),c.jsxs(It,{onSelect:()=>f(),children:[c.jsx(Vc,{...g}),"Create folder"]}),c.jsx(on,{})]}),c.jsxs(It,{onSelect:()=>t.edit(),children:[c.jsx(xp,{...g}),"Rename"]}),!t.data.isDirectory&&c.jsxs(It,{onSelect:x,children:[c.jsx(Ca,{...g}),"Duplicate"]}),c.jsxs(It,{onSelect:async()=>{await nn(t.data.path),Xe({title:"Copied to clipboard"})},children:[c.jsx(qc,{...g}),"Copy path"]}),d&&c.jsxs(It,{onSelect:async()=>{await nn(d.relativeFromRoot(t.data.path)),Xe({title:"Copied to clipboard"})},children:[c.jsx(qc,{...g}),"Copy relative path"]}),c.jsx(on,{}),c.jsxs(It,{onSelect:()=>{const{path:p}=t.data;(b=>{i({code:b,before:!1,cellId:l??"__end__"})})(sS[o](p))},children:[c.jsx(kr,{...g}),"Insert snippet for reading file"]}),c.jsxs(It,{onSelect:async()=>{Xe({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:p}=t.data,b=sS[o](p);await nn(b)},children:[c.jsx(CR,{...g}),"Copy snippet for reading file"]}),t.data.isMarimoFile&&!Jt()&&c.jsxs(c.Fragment,{children:[c.jsx(on,{}),c.jsxs(It,{onSelect:u,children:[c.jsx(Cp,{...g}),"Open notebook"]})]}),c.jsx(on,{}),!t.data.isDirectory&&c.jsxs(c.Fragment,{children:[c.jsxs(It,{onSelect:async()=>{const p=(await Im({path:t.data.path})).contents||"";za(new Blob([p]),t.data.name)},children:[c.jsx(Qf,{...g}),"Download"]}),c.jsx(on,{})]}),c.jsxs(It,{onSelect:h,variant:"danger",children:[c.jsx(Xl,{...g}),"Delete"]})]})})()]})]})]})},DM=t=>{const e=H.c(3),{node:n}=t;if(!n.data.isDirectory){let r;return e[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx("span",{className:"w-5 h-5 flex-shrink-0"}),e[0]=r):r=e[0],r}let o;return e[1]!==n.isOpen?(o=n.isOpen?c.jsx(wo,{className:"w-5 h-5 flex-shrink-0"}):c.jsx(Ta,{className:"w-5 h-5 flex-shrink-0"}),e[1]=n.isOpen,e[2]=o):o=e[2],o};function Ww(t,e){t.stopPropagation(),t.preventDefault(),pS(e)}function PM(){return null}function RM(t){const{parentNode:e}=t;return!e.data.isDirectory}function LM(t){return t.stopPropagation()}let qw,Gw,Yw;qw=()=>{const t=H.c(20),{ref:e,height:n}=ER(),o=n===void 0?1:n;let r;t[0]===Symbol.for("react.memo_cache_sentinel")?(r={noClick:!0,noKeyboard:!0},t[0]=r):r=t[0];const{getRootProps:s,getInputProps:a,isDragActive:i}=Vw(r);let l,d,u,h,f,m,x,g;return t[1]!==s?(l=s(),t[1]=s,t[2]=l):l=t[2],t[3]===Symbol.for("react.memo_cache_sentinel")?(d=ge("flex flex-col flex-1 overflow-hidden relative"),t[3]=d):d=t[3],t[4]!==a?(u=a(),t[4]=a,t[5]=u):u=t[5],t[6]!==u?(h=c.jsx("input",{...u}),t[6]=u,t[7]=h):h=t[7],t[8]!==i?(f=i&&c.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"}),t[8]=i,t[9]=f):f=t[9],t[10]!==o?(m=c.jsx(_M,{height:o}),t[10]=o,t[11]=m):m=t[11],t[12]!==e||t[13]!==m?(x=c.jsx("div",{ref:e,className:"flex flex-col flex-1 overflow-hidden",children:m}),t[12]=e,t[13]=m,t[14]=x):x=t[14],t[15]!==l||t[16]!==h||t[17]!==f||t[18]!==x?(g=c.jsxs("div",{...l,className:d,children:[h,f,x]}),t[15]=l,t[16]=h,t[17]=f,t[18]=x,t[19]=g):g=t[19],g},$m=t=>{const e=H.c(6),n=t.dataTestId;let o,r;return e[0]!==t.className?(o=ge("text-xs font-semibold text-accent-foreground",t.className),e[0]=t.className,e[1]=o):o=e[1],e[2]!==t.dataTestId||e[3]!==t.onClick||e[4]!==o?(r=c.jsx("button",{type:"button","data-testid":n,className:o,onClick:t.onClick,children:"Clear"}),e[2]=t.dataTestId,e[3]=t.onClick,e[4]=o,e[5]=r):r=e[5],r},Gw=()=>{const t=H.c(9),e=_R(),{clearLogs:n}=it();if(e.length===0){let a,i;return t[0]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx("code",{className:"border rounded px-1",children:"stdout"}),t[0]=a):a=t[0],t[1]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(sn,{title:"No logs",description:c.jsxs("span",{children:[a," and"," ",c.jsx("code",{className:"border rounded px-1",children:"stderr"})," logs will appear here."]}),icon:c.jsx(zf,{})}),t[1]=i):i=t[1],i}let o,r,s;return t[2]!==n?(o=c.jsx("div",{className:"flex flex-row justify-end px-2 py-1",children:c.jsx($m,{dataTestId:"clear-logs-button",onClick:n})}),t[2]=n,t[3]=o):o=t[3],t[4]!==e?(r=c.jsx("div",{className:"overflow-auto flex-1",children:c.jsx(Yw,{logs:e,className:"min-w-[300px]"})}),t[4]=e,t[5]=r):r=t[5],t[6]!==o||t[7]!==r?(s=c.jsxs(c.Fragment,{children:[o,r]}),t[6]=o,t[7]=r,t[8]=s):s=t[8],s},Yw=t=>{const e=H.c(10),{logs:n,className:o}=t;let r,s,a,i,l;return e[0]!==o?(r=ge("flex flex-col",o),e[0]=o,e[1]=r):r=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(s={whiteSpace:"pre-wrap"},e[2]=s):s=e[2],e[3]!==n?(a=n.map(BM),e[3]=n,e[4]=a):a=e[4],e[5]!==a?(i=c.jsx("pre",{className:"grid text-xs font-mono gap-1 whitespace-break-spaces font-semibold align-left",children:c.jsx("div",{className:"grid grid-cols-[30px,1fr]",style:s,children:a})}),e[5]=a,e[6]=i):i=e[6],e[7]!==r||e[8]!==i?(l=c.jsx("div",{className:r,children:i}),e[7]=r,e[8]=i,e[9]=l):l=e[9],l};function FM(t){const e=IR(t.timestamp),n=zM[t.level],o=t.level.toUpperCase();return c.jsxs(c.Fragment,{children:[c.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)] dark:text-[var(--gray-11)]",children:["[",e,"]"]}),c.jsx("span",{className:ge("flex-shrink-0",n),children:o}),c.jsxs("span",{className:"flex-shrink-0 text-[var(--gray-10)]",children:["(",c.jsx(_o,{cellId:t.cellId}),")"]}),t.message]})}const zM={stdout:"text-[var(--grass-9)]",stderr:"text-[var(--red-9)]"};function BM(t,e){return c.jsxs("div",{className:"contents group",children:[c.jsx("span",{className:ge("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","text-right col-span-1 py-1 pr-1"),children:e+1}),c.jsx("span",{className:ge("opacity-70 group-hover:bg-[var(--gray-3)] group-hover:opacity-100","px-2 flex gap-x-1.5 py-1 flex-wrap"),children:FM(t)})]},e)}const UM=()=>{const t=H.c(7),{items:e}=Ie(AR);let n,o;t[0]!==e?(o=OL(e),t[0]=e,t[1]=o):o=t[1],n=o;const r=n,{activeHeaderId:s,activeOccurrences:a}=DL(r);if(e.length===0){let l;return t[2]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsx(sn,{title:"No outline",description:"Add markdown headings to your notebook to create an outline.",icon:c.jsx(Xc,{})}),t[2]=l):l=t[2],l}let i;return t[3]!==s||t[4]!==a||t[5]!==e?(i=c.jsx(PL,{items:e,activeHeaderId:s,activeOccurrences:a}),t[3]=s,t[4]=a,t[5]=e,t[6]=i):i=t[6],i},Kw=mt(null),Xw=t=>{const e=H.c(9),{onClick:n,loading:o,children:r,className:s}=t;if(o){let d;return e[0]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(bn,{size:"small",className:"h-4 w-4 shrink-0 opacity-50"}),e[0]=d):d=e[0],d}let a,i,l;return e[1]!==s?(a=ge("px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible",s),e[1]=s,e[2]=a):a=e[2],e[3]!==n?(i=Dn.stopPropagation(n),e[3]=n,e[4]=i):i=e[4],e[5]!==r||e[6]!==a||e[7]!==i?(l=c.jsx("button",{type:"button",className:a,onClick:i,children:r}),e[5]=r,e[6]=a,e[7]=i,e[8]=l):l=e[8],l},$M=()=>{var w,S;const t=H.c(27),[e]=mr(),n=e.package_management.manager,[o,r]=G.useState(null);let s;t[0]!==n?(s=[n],t[0]=n,t[1]=s):s=t[1];const{data:a,error:i,refetch:l,isPending:d}=Cn(qM,s);if(d){let N;return t[2]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsx(bn,{size:"medium",centered:!0}),t[2]=N):N=t[2],N}if(i){let N;return t[3]!==i?(N=c.jsx(br,{error:i}),t[3]=i,t[4]=N):N=t[4],N}const u=a.tree!=null;let h;t[5]!==u||t[6]!==o?(h=function(N,j){return N==="list"?"list":j?N||"tree":"list"}(o,u),t[5]=u,t[6]=o,t[7]=h):h=t[7];const f=h,m=(w=a.tree)==null?void 0:w.name,x=(S=a==null?void 0:a.tree)==null?void 0:S.version,g=m==="<root>";let p,b,y,v;return t[8]!==n||t[9]!==l?(p=c.jsx(VM,{packageManager:n,onSuccess:l}),t[8]=n,t[9]=l,t[10]=p):p=t[10],t[11]!==g||t[12]!==u||t[13]!==m||t[14]!==x||t[15]!==f?(b=u&&c.jsxs("div",{className:"flex items-center justify-between px-2 py-1 border-b",children:[c.jsxs("div",{className:"flex gap-1",children:[c.jsx("button",{type:"button",className:ge("px-2 py-1 text-xs rounded",f==="list"?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>r("list"),children:"List"}),c.jsx("button",{type:"button",className:ge("px-2 py-1 text-xs rounded",f==="tree"?"bg-accent text-accent-foreground":"text-muted-foreground hover:text-foreground"),onClick:()=>r("tree"),children:"Tree"})]}),c.jsxs("div",{className:"flex items-center gap-2",children:[c.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium",title:g?"sandbox":"project",children:g?"sandbox":"project"}),m&&!g&&c.jsxs("span",{className:"text-xs text-muted-foreground",children:[m,x&&` v${x}`]})]})]}),t[11]=g,t[12]=u,t[13]=m,t[14]=x,t[15]=f,t[16]=b):b=t[16],t[17]!==a.list||t[18]!==a.tree||t[19]!==i||t[20]!==l||t[21]!==f?(y=f==="list"?c.jsx(HM,{packages:a.list,onSuccess:l}):c.jsx(WM,{tree:a.tree,error:i,onSuccess:l}),t[17]=a.list,t[18]=a.tree,t[19]=i,t[20]=l,t[21]=f,t[22]=y):y=t[22],t[23]!==p||t[24]!==b||t[25]!==y?(v=c.jsxs("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p,b,y]}),t[23]=p,t[24]=b,t[25]=y,t[26]=v):v=t[26],v},VM=t=>{const e=H.c(40),{onSuccess:n,packageManager:o}=t,[r,s]=G.useState(""),{handleClick:a}=ti(),i=Ie(Kw),l=kt(Kw);let d,u;e[0]!==i||e[1]!==l?(d=()=>{i&&(s(i),l(null))},u=[i,l],e[0]=i,e[1]=l,e[2]=d,e[3]=u):(d=e[2],u=e[3]),G.useEffect(d,u);const{loading:h,handleInstallPackages:f}=OR();let m;e[4]!==n?(m=()=>{n(),s("")},e[4]=n,e[5]=m):m=e[5];const x=m;let g;e[6]!==f||e[7]!==r||e[8]!==x?(g=()=>{f(r.split(",").map(GM),x)},e[6]=f,e[7]=r,e[8]=x,e[9]=g):g=e[9];const p=g,b=`Install packages with ${o}...`;let y,v,w,S,N,j,C,_,A,I,P,R,M,L;e[10]!==h||e[11]!==a?(y=h?c.jsx(bn,{size:"small",className:"mr-2 h-4 w-4 shrink-0 opacity-50"}):c.jsx(Ne,{content:"Change package manager",children:c.jsx(Ss,{onClick:()=>a("packageManagement"),className:"mr-2 h-4 w-4 shrink-0 opacity-50 hover:opacity-80 cursor-pointer"})}),e[10]=h,e[11]=a,e[12]=y):y=e[12],e[13]!==p?(v=E=>{E.key==="Enter"&&(E.preventDefault(),p())},e[13]=p,e[14]=v):v=e[14],e[15]===Symbol.for("react.memo_cache_sentinel")?(w=E=>s(E.target.value),e[15]=w):w=e[15],e[16]!==r||e[17]!==b||e[18]!==y||e[19]!==v?(S=c.jsx(aS,{placeholder:b,id:h1,icon:y,rootClassName:"flex-1 border-none",value:r,onKeyDown:v,onChange:w}),e[16]=r,e[17]=b,e[18]=y,e[19]=v,e[20]=S):S=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(N=c.jsx("span",{className:"font-bold tracking-wide",children:"Package name:"}),e[21]=N):N=e[21],e[22]===Symbol.for("react.memo_cache_sentinel")?(j=c.jsxs("div",{children:[N," A package name; this will install the latest version.",c.jsx("div",{className:"text-muted-foreground",children:"Example: httpx"})]}),C=c.jsx("span",{className:"font-bold tracking-wide",children:"Package and version:"}),e[22]=j,e[23]=C):(j=e[22],C=e[23]),e[24]===Symbol.for("react.memo_cache_sentinel")?(_=c.jsxs("div",{children:[C," ","A package with a specific version or version range.",c.jsx("div",{className:"text-muted-foreground",children:"Examples: httpx==0.27.0, httpx>=0.27.0"})]}),A=c.jsx("span",{className:"font-bold tracking-wide",children:"Git:"}),e[24]=_,e[25]=A):(_=e[24],A=e[25]),e[26]===Symbol.for("react.memo_cache_sentinel")?(I=c.jsxs("div",{children:[A," A Git repository",c.jsx("div",{className:"text-muted-foreground",children:"Example: git+https://github.com/encode/httpx"})]}),P=c.jsx("span",{className:"font-bold tracking-wide",children:"URL:"}),e[26]=I,e[27]=P):(I=e[26],P=e[27]),e[28]===Symbol.for("react.memo_cache_sentinel")?(R=c.jsxs("div",{children:[P," A remote wheel or source distribution.",c.jsx("div",{className:"text-muted-foreground",children:"Example: https://example.com/httpx-0.27.0.tar.gz"})]}),M=c.jsx("span",{className:"font-bold tracking-wide",children:"Path:"}),e[28]=R,e[29]=M):(R=e[28],M=e[29]),e[30]===Symbol.for("react.memo_cache_sentinel")?(L=c.jsx(Ne,{delayDuration:300,side:"left",align:"start",content:c.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:",c.jsxs("div",{className:"flex flex-col gap-2 mt-2",children:[j,_,I,R,c.jsxs("div",{children:[M," A local wheel, source distribution, or project directory.",c.jsx("div",{className:"text-muted-foreground",children:"Example: /example/foo-0.1.0-py3-none-any.whl"})]})]})]}),children:c.jsx(Sm,{className:"h-4 w-4 cursor-help text-muted-foreground hover:text-foreground bg-transparent"})}),e[30]=L):L=e[30];const F=r&&"bg-accent text-accent-foreground";let D;e[31]!==F?(D=ge("float-right px-2 m-0 h-full text-sm text-secondary-foreground ml-2",F,"disabled:cursor-not-allowed disabled:opacity-50"),e[31]=F,e[32]=D):D=e[32];const T=!r;let k,B;return e[33]!==p||e[34]!==D||e[35]!==T?(k=c.jsx("button",{type:"button",className:D,onClick:p,disabled:T,children:"Add"}),e[33]=p,e[34]=D,e[35]=T,e[36]=k):k=e[36],e[37]!==k||e[38]!==S?(B=c.jsxs("div",{className:"flex items-center w-full border-b",children:[S,L,k]}),e[37]=k,e[38]=S,e[39]=B):B=e[39],B},HM=t=>{const e=H.c(9),{onSuccess:n,packages:o}=t;if(o.length===0){let i;return e[0]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx(sn,{title:"No packages",description:"No packages are installed in this environment.",icon:c.jsx(Ss,{})}),e[0]=i):i=e[0],i}let r,s,a;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(Tm,{children:c.jsxs(ks,{children:[c.jsx(yr,{children:"Name"}),c.jsx(yr,{children:"Version"}),c.jsx(yr,{})]})}),e[1]=r):r=e[1],e[2]!==n||e[3]!==o){let i;e[5]!==n?(i=l=>c.jsxs(ks,{className:"group",onClick:async()=>{await nn(`${l.name}==${l.version}`),Xe({title:"Copied to clipboard"})},children:[c.jsx(vr,{children:l.name}),c.jsx(vr,{children:l.version}),c.jsxs(vr,{className:"flex justify-end",children:[c.jsx(Jw,{packageName:l.name,onSuccess:n}),c.jsx(Zw,{packageName:l.name,onSuccess:n})]})]},l.name),e[5]=n,e[6]=i):i=e[6],s=o.map(i),e[2]=n,e[3]=o,e[4]=s}else s=e[4];return e[7]!==s?(a=c.jsxs(Mm,{className:"overflow-auto flex-1",children:[r,c.jsx(Om,{children:s})]}),e[7]=s,e[8]=a):a=e[8],a},Jw=({packageName:t,onSuccess:e})=>{const[n,o]=G.useState(!1);return Jt()?null:c.jsx(Xw,{onClick:async()=>{try{o(!0);const r=await DR({package:t,upgrade:!0});r.success?(e(),iS(t)):iS(t,r.error)}finally{o(!1)}},loading:n,children:"Upgrade"})},Zw=({packageName:t,onSuccess:e})=>{const[n,o]=G.useState(!1);return c.jsx(Xw,{onClick:async()=>{try{o(!0);const r=await PR({package:t});r.success?(e(),lS(t)):lS(t,r.error)}finally{o(!1)}},loading:n,children:"Remove"})},WM=t=>{const e=H.c(18),{tree:n,error:o,onSuccess:r}=t;let s;e[0]===Symbol.for("react.memo_cache_sentinel")?(s=new Set,e[0]=s):s=e[0];const[a,i]=G.useState(s);let l,d,u;if(e[1]===Symbol.for("react.memo_cache_sentinel")?(l=()=>{i(new Set)},e[1]=l):l=e[1],e[2]!==n?(d=[n],e[2]=n,e[3]=d):d=e[3],G.useEffect(l,d),o){let x;return e[4]!==o?(x=c.jsx(br,{error:o}),e[4]=o,e[5]=x):x=e[5],x}if(!n){let x;return e[6]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(bn,{size:"medium",centered:!0}),e[6]=x):x=e[6],x}if(n.dependencies.length===0){let x;return e[7]===Symbol.for("react.memo_cache_sentinel")?(x=c.jsx(sn,{title:"No dependencies",description:"No package dependencies found in this environment.",icon:c.jsx(Ss,{})}),e[7]=x):x=e[7],x}e[8]===Symbol.for("react.memo_cache_sentinel")?(u=x=>{i(g=>{const p=new Set(g);return p.has(x)?p.delete(x):p.add(x),p})},e[8]=u):u=e[8];const h=u;let f,m;if(e[9]!==a||e[10]!==r||e[11]!==n.dependencies){let x;e[13]!==a||e[14]!==r?(x=(g,p)=>c.jsx("div",{className:"border-b",children:c.jsx(Qw,{nodeId:`root-${p}`,node:g,level:0,isTopLevel:!0,expandedNodes:a,onToggle:h,onSuccess:r})},`${g.name}-${p}`),e[13]=a,e[14]=r,e[15]=x):x=e[15],f=n.dependencies.map(x),e[9]=a,e[10]=r,e[11]=n.dependencies,e[12]=f}else f=e[12];return e[16]!==f?(m=c.jsx("div",{className:"flex-1 overflow-auto",children:c.jsx("div",{children:f})}),e[16]=f,e[17]=m):m=e[17],m},Qw=t=>{const e=H.c(57),{nodeId:n,node:o,level:r,isTopLevel:s,expandedNodes:a,onToggle:i,onSuccess:l}=t,d=s!==void 0&&s,u=o.dependencies.length>0;let h;e[0]!==a||e[1]!==n?(h=a.has(n),e[0]=a,e[1]=n,e[2]=h):h=e[2];const f=h,m=d?0:16+16*r;let x;e[3]!==u||e[4]!==n||e[5]!==i?(x=D=>{D.key!=="Enter"&&D.key!==" "||(D.preventDefault(),u&&i(n))},e[3]=u,e[4]=n,e[5]=i,e[6]=x):x=e[6];const g=x;let p;e[7]!==u||e[8]!==n||e[9]!==i?(p=D=>{D.stopPropagation(),u&&i(n)},e[7]=u,e[8]=n,e[9]=i,e[10]=p):p=e[10];const b=p,y=u&&"select-none",v=d?"px-2 py-0.5":"";let w,S;e[11]!==y||e[12]!==v?(w=ge("flex items-center group cursor-pointer text-sm whitespace-nowrap","hover:bg-[var(--slate-2)] focus:bg-[var(--slate-2)] focus:outline-none",y,v),e[11]=y,e[12]=v,e[13]=w):w=e[13],e[14]!==m||e[15]!==d?(S=d?{}:{paddingLeft:`${m}px`},e[14]=m,e[15]=d,e[16]=S):S=e[16];const N=u?f:void 0;let j,C,_,A,I,P,R,M,L,F;return e[17]!==u||e[18]!==f?(j=u?f?c.jsx(wo,{className:"w-4 h-4 mr-2 flex-shrink-0"}):c.jsx(Ta,{className:"w-4 h-4 mr-2 flex-shrink-0"}):c.jsx("div",{className:"w-4 mr-2 flex-shrink-0"}),e[17]=u,e[18]=f,e[19]=j):j=e[19],e[20]!==o.name?(C=c.jsx("span",{className:"font-medium truncate",children:o.name}),e[20]=o.name,e[21]=C):C=e[21],e[22]!==o.version?(_=o.version&&c.jsxs("span",{className:"text-muted-foreground text-xs",children:["v",o.version]}),e[22]=o.version,e[23]=_):_=e[23],e[24]!==C||e[25]!==_?(A=c.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0 py-1.5",children:[C,_]}),e[24]=C,e[25]=_,e[26]=A):A=e[26],e[27]!==o.tags?(I=o.tags.map(YM),e[27]=o.tags,e[28]=I):I=e[28],e[29]!==I?(P=c.jsx("div",{className:"flex items-center gap-1 ml-2",children:I}),e[29]=I,e[30]=P):P=e[30],e[31]!==d||e[32]!==o.name||e[33]!==l?(R=d&&c.jsxs("div",{className:"flex gap-1 invisible group-hover:visible",children:[c.jsx(Jw,{packageName:o.name,onSuccess:l}),c.jsx(Zw,{packageName:o.name,onSuccess:l})]}),e[31]=d,e[32]=o.name,e[33]=l,e[34]=R):R=e[34],e[35]!==b||e[36]!==g||e[37]!==j||e[38]!==A||e[39]!==P||e[40]!==R||e[41]!==w||e[42]!==S||e[43]!==N?(M=c.jsxs("div",{className:w,style:S,onClick:b,onKeyDown:g,tabIndex:0,role:"treeitem","aria-selected":!1,"aria-expanded":N,children:[j,A,P,R]}),e[35]=b,e[36]=g,e[37]=j,e[38]=A,e[39]=P,e[40]=R,e[41]=w,e[42]=S,e[43]=N,e[44]=M):M=e[44],e[45]!==a||e[46]!==u||e[47]!==f||e[48]!==r||e[49]!==o.dependencies||e[50]!==n||e[51]!==l||e[52]!==i?(L=u&&f&&c.jsx("div",{role:"group",children:o.dependencies.map((D,T)=>c.jsx(Qw,{nodeId:`${n}-${T}`,node:D,level:r+1,isTopLevel:!1,expandedNodes:a,onToggle:i,onSuccess:l},`${D.name}-${T}`))}),e[45]=a,e[46]=u,e[47]=f,e[48]=r,e[49]=o.dependencies,e[50]=n,e[51]=l,e[52]=i,e[53]=L):L=e[53],e[54]!==M||e[55]!==L?(F=c.jsxs("div",{children:[M,L]}),e[54]=M,e[55]=L,e[56]=F):F=e[56],F};async function qM(){const[t,e]=await Promise.all([TR(),MR()]);return{list:t.packages,tree:e.tree}}function GM(t){return t.trim()}function YM(t,e){return t.kind==="cycle"?c.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-orange-300 dark:border-orange-700 text-orange-700 dark:text-orange-300",title:"cycle",children:"cycle"},e):t.kind==="extra"?c.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-blue-300 dark:border-blue-700 text-blue-700 dark:text-blue-300",title:t.value,children:t.value},e):t.kind==="group"?c.jsx("div",{className:"items-center border px-2 py-0.5 text-xs transition-colors focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 text-foreground rounded-sm text-ellipsis block overflow-hidden max-w-fit font-medium border-green-300 dark:border-green-700 text-green-700 dark:text-green-300",title:t.value,children:t.value},e):null}const Of=vk("marimo:scratchpadHistory:v1",[]),KM=mt(!1),XM=mt(null,(t,e,n)=>{if(!(n=n.trim()))return;const o=t(Of),r=[n,...o.filter(s=>s!==n)].slice(0,15);e(Of,r)}),JM={hide_code:!1,disabled:!1},ZM=()=>{const t=H.c(69),e=fs(),[n]=mr(),{theme:o}=Xo(),r=O.useRef(null),s=cs(),{createNewCell:a,updateCellCode:i}=it(),l=e.cellRuntime[Jo],d=l==null?void 0:l.output,u=l==null?void 0:l.status,h=l==null?void 0:l.consoleOutputs,f=e.cellData[Jo],m=(f==null?void 0:f.code)??"",x=kt(XM),[g,p]=St(KM),b=Ie(Of);let y;t[0]!==x||t[1]!==m?(y=()=>{cS({code:m}),x(m)},t[0]=x,t[1]=m,t[2]=y):y=t[2];const v=Fe(y);let w;t[3]!==m||t[4]!==a||t[5]!==s?(w=()=>{m.trim()&&a({code:m,before:!1,cellId:s??"__end__"})},t[3]=m,t[4]=a,t[5]=s,t[6]=w):w=t[6];const S=Fe(w);let N;t[7]!==i?(N=()=>{i({cellId:Jo,code:"",formattingChange:!1}),cS({code:""});const ae=r.current;ae&&ae.dispatch({changes:{from:0,to:ae.state.doc.length,insert:""}})},t[7]=i,t[8]=N):N=t[8];const j=Fe(N);let C;t[9]!==p||t[10]!==i?(C=ae=>{p(!1),i({cellId:Jo,code:ae,formattingChange:!1});const ye=r.current;ye&&ye.dispatch({changes:{from:0,to:ye.state.doc.length,insert:ae}})},t[9]=p,t[10]=i,t[11]=C):C=t[11];const _=Fe(C),[A,I]=O.useState();let P;t[12]!==m||t[13]!==h||t[14]!==v||t[15]!==A||t[16]!==d||t[17]!==o||t[18]!==n?(P=()=>c.jsxs(c.Fragment,{children:[c.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[40%]",children:c.jsx(Nu,{theme:o,showPlaceholder:!1,id:Jo,code:m,config:JM,status:"idle",serializedEditorState:null,runCell:v,userConfig:n,editorViewRef:r,setEditorView:ae=>{r.current=ae},hidden:!1,showHiddenCode:Pn.NOOP,languageAdapter:A,setLanguageAdapter:I})}),c.jsx("div",{className:"flex-1 overflow-auto flex-shrink-0",children:c.jsx(_c,{allowExpand:!1,output:d,className:"output-area",cellId:Jo,stale:!1,loading:!1})}),c.jsx("div",{className:"overflow-auto flex-shrink-0 max-h-[35%]",children:c.jsx(Fm,{consoleOutputs:h,className:"overflow-auto",stale:!1,cellName:wk,onSubmitDebugger:Pn.NOOP,cellId:Jo,debuggerActive:!1})})]}),t[12]=m,t[13]=h,t[14]=v,t[15]=A,t[16]=d,t[17]=o,t[18]=n,t[19]=P):P=t[19];const R=P;let M;t[20]!==_||t[21]!==b||t[22]!==g||t[23]!==o?(M=()=>g?c.jsx("div",{className:"absolute inset-0 z-100 bg-background p-3 border-none overflow-auto",children:c.jsx("div",{className:"overflow-auto flex flex-col gap-3",children:b.map((ae,ye)=>c.jsx("div",{className:"border rounded-md hover:shadow-sm cursor-pointer hover:border-input overflow-hidden",onClick:()=>_(ae),children:c.jsx(O.Suspense,{children:c.jsx(Qa,{language:"python",theme:o,basicSetup:{highlightActiveLine:!1,highlightActiveLineGutter:!1},value:ae.trim(),editable:!1,readOnly:!0})})},ye))})}):null,t[20]=_,t[21]=b,t[22]=g,t[23]=o,t[24]=M):M=t[24];const L=M;let F,D,T,k,B,E,U,V,$,X,Y;t[25]===Symbol.for("react.memo_cache_sentinel")?(F=Ea.create(Jo),D=c.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."}),t[25]=F,t[26]=D):(F=t[25],D=t[26]),t[27]===Symbol.for("react.memo_cache_sentinel")?(T=Ht("cell.run"),t[27]=T):T=t[27],t[28]===Symbol.for("react.memo_cache_sentinel")?(k=c.jsx(wr,{color:"var(--grass-11)",size:16}),t[28]=k):k=t[28],t[29]!==v||t[30]!==g?(B=c.jsx(Ne,{content:T,children:c.jsx(ke,{"data-testid":"scratchpad-run-button",onClick:v,disabled:g,variant:"text",size:"xs",children:k})}),t[29]=v,t[30]=g,t[31]=B):B=t[31],t[32]===Symbol.for("react.memo_cache_sentinel")?(E=c.jsx(Xm,{size:16}),t[32]=E):E=t[32],t[33]!==j||t[34]!==g?(U=c.jsx(Ne,{content:"Clear code and outputs",children:c.jsx(ke,{disabled:g,size:"xs",variant:"text",onClick:j,children:E})}),t[33]=j,t[34]=g,t[35]=U):U=t[35],t[36]===Symbol.for("react.memo_cache_sentinel")?(V=c.jsx(kr,{size:16}),t[36]=V):V=t[36],t[37]!==S||t[38]!==g?($=c.jsx(Ts,{children:c.jsx(Ne,{content:"Insert code",children:c.jsx(ke,{disabled:g,size:"xs",variant:"text",onClick:S,children:V})})}),t[37]=S,t[38]=g,t[39]=$):$=t[39],t[40]!==u?(X=(u==="running"||u==="queued")&&c.jsx(bn,{className:"inline",size:"small"}),t[40]=u,t[41]=X):X=t[41],t[42]===Symbol.for("react.memo_cache_sentinel")?(Y=c.jsx("div",{className:"flex-1"}),t[42]=Y):Y=t[42];const J=g&&"bg-[var(--sky-3)] rounded-none";let Q,q;t[43]!==J?(Q=ge(J),t[43]=J,t[44]=Q):Q=t[44],t[45]!==g||t[46]!==p?(q=()=>p(!g),t[45]=g,t[46]=p,t[47]=q):q=t[47];const K=b.length===0;let re,oe,ne,se,te,pe,he;return t[48]===Symbol.for("react.memo_cache_sentinel")?(re=c.jsx(op,{size:16}),t[48]=re):re=t[48],t[49]!==Q||t[50]!==q||t[51]!==K?(oe=c.jsx(Ne,{content:"Toggle history",children:c.jsx(ke,{size:"xs",variant:"text",className:Q,onClick:q,disabled:K,children:re})}),t[49]=Q,t[50]=q,t[51]=K,t[52]=oe):oe=t[52],t[53]!==B||t[54]!==U||t[55]!==$||t[56]!==X||t[57]!==oe?(ne=c.jsxs("div",{className:"flex items-center flex-shrink-0",children:[B,U,$,X,Y,oe]}),t[53]=B,t[54]=U,t[55]=$,t[56]=X,t[57]=oe,t[58]=ne):ne=t[58],t[59]!==R?(se=R(),t[59]=R,t[60]=se):se=t[60],t[61]!==L?(te=L(),t[61]=L,t[62]=te):te=t[62],t[63]!==se||t[64]!==te?(pe=c.jsxs("div",{className:"flex-1 divide-y relative overflow-hidden flex flex-col",children:[se,te]}),t[63]=se,t[64]=te,t[65]=pe):pe=t[65],t[66]!==ne||t[67]!==pe?(he=c.jsxs("div",{className:"flex flex-col h-full overflow-hidden divide-y",id:F,children:[D,ne,pe]}),t[66]=ne,t[67]=pe,t[68]=he):he=t[68],he},QM=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(ZM,{}),t[0]=e):e=t[0],e},e7=()=>{const t=H.c(23),{openModal:e,closeModal:n}=jn();let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const{data:r,isPending:s,error:a,refetch:i}=Cn(n7,o);if(s){let b;return t[1]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(bn,{size:"medium",centered:!0}),t[1]=b):b=t[1],b}if(a){let b;return t[2]!==a?(b=c.jsx(br,{error:a}),t[2]=a,t[3]=b):b=t[3],b}let l;t[4]!==r?(l=r.filter(o7).map(r7),t[4]=r,t[5]=l):l=t[5];const d=l;if(r.length===0){let b;return t[6]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(sn,{title:"No environment variables",description:"No environment variables are available in this notebook.",icon:c.jsx(Hc,{})}),t[6]=b):b=t[6],b}let u,h,f,m,x,g,p;return t[7]!==n||t[8]!==e||t[9]!==d||t[10]!==i?(u=()=>e(c.jsx(sg,{providerNames:d,onSuccess:()=>{i(),n()},onClose:n})),t[7]=n,t[8]=e,t[9]=d,t[10]=i,t[11]=u):u=t[11],t[12]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(Ko,{className:"h-4 w-4"}),t[12]=h):h=t[12],t[13]!==u?(f=c.jsx("div",{className:"flex justify-end h-8 border-b",children:c.jsx("button",{type:"button",className:"float-right border-l px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",onClick:u,children:h})}),t[13]=u,t[14]=f):f=t[14],t[15]===Symbol.for("react.memo_cache_sentinel")?(m=c.jsx(Tm,{children:c.jsxs(ks,{children:[c.jsx(yr,{children:"Environment Variable"}),c.jsx(yr,{children:"Source"}),c.jsx(yr,{})]})}),t[15]=m):m=t[15],t[16]!==r?(x=r.map(s7),t[16]=r,t[17]=x):x=t[17],t[18]!==x?(g=c.jsxs(Mm,{className:"overflow-auto flex-1 mb-16",children:[m,c.jsx(Om,{children:x})]}),t[18]=x,t[19]=g):g=t[19],t[20]!==f||t[21]!==g?(p=c.jsxs("div",{className:"flex flex-col h-full",children:[f,g]}),t[20]=f,t[21]=g,t[22]=p):p=t[22],p},t7=t=>{const e=H.c(9),{className:n,ariaLabel:o,onCopy:r}=t,[s,a]=G.useState(!1);let i;e[0]!==r?(i=()=>{r(),a(!0),setTimeout(()=>a(!1),1e3)},e[0]=r,e[1]=i):i=e[1];const l=i;let d,u;return e[2]!==s?(d=s?c.jsx(rc,{className:"w-3 h-3 text-green-700 rounded"}):c.jsx(Ca,{className:"w-3 h-3 hover:bg-muted rounded"}),e[2]=s,e[3]=d):d=e[3],e[4]!==o||e[5]!==n||e[6]!==l||e[7]!==d?(u=c.jsx("button",{type:"button",className:n,onClick:l,"aria-label":o,children:d}),e[4]=o,e[5]=n,e[6]=l,e[7]=d,e[8]=u):u=e[8],u};async function n7(){return rg((await kS.request({})).secrets)}function o7(t){return t.provider!=="env"}function r7(t){return t.name}function s7(t){return t.keys.map(e=>c.jsxs(ks,{className:"group",children:[c.jsx(vr,{children:e}),c.jsx(vr,{children:t.provider!=="env"&&c.jsx(G3,{variant:"outline",className:"select-none",children:t.name})}),c.jsx(vr,{children:c.jsx(t7,{ariaLabel:`Copy ${e}`,onCopy:async()=>{await nn(`os.environ["${e}"]`),Xe({title:"Copied to clipboard",description:`os.environ["${e}"] has been copied to your clipboard.`})},className:ge("float-right px-2 h-full text-xs text-muted-foreground hover:text-foreground","invisible group-hover:visible")})})]},`${t.name}-${e}`))}const a7=t=>{const e=H.c(6),{children:n}=t,{openModal:o,closeModal:r}=jn();let s,a;return e[0]!==r||e[1]!==o?(s=()=>o(c.jsx(l7,{onClose:r})),e[0]=r,e[1]=o,e[2]=s):s=e[2],e[3]!==n||e[4]!==s?(a=c.jsx(z3,{onClick:s,children:n}),e[3]=n,e[4]=s,e[5]=a):a=e[5],a},i7=[Ve.lineWrapping],l7=t=>{const e=H.c(23),{onClose:n}=t,[o,r]=O.useState(""),{theme:s}=Xo();let a,i,l,d,u,h;e[0]!==n?(a=async v=>{v.preventDefault();const w=new FormData(v.target),S=w.get("title"),N=w.get("description"),j=w.get("code");fetch("https://marimo.io/api/suggest-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:S,description:N,code:j})}),n(),Xe({title:"Snippet Submitted",description:"Thank you for contributing! We will review your snippet shortly."})},e[0]=n,e[1]=a):a=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(i=c.jsx($o,{children:"Contribute a Snippet"}),e[2]=i):i=e[2],e[3]===Symbol.for("react.memo_cache_sentinel")?(l=c.jsxs(rs,{children:[i,c.jsxs(ss,{children:["Have a useful snippet you want to share with the community? Submit it here or make a pull request"," ",c.jsx("a",{href:On.githubPage,target:"_blank",className:"underline",children:"on GitHub"}),"."]})]}),e[3]=l):l=e[3],e[4]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(Vo,{id:"title",name:"title",autoFocus:!0,placeholder:"Title",required:!0,autoComplete:"off"}),u=c.jsx(RR,{id:"description",name:"description",autoFocus:!0,placeholder:"Description",rows:5,required:!0,autoComplete:"off"}),e[4]=d,e[5]=u):(d=e[4],u=e[5]),e[6]!==o?(h=c.jsx("input",{type:"hidden",name:"code",value:o}),e[6]=o,e[7]=h):h=e[7];const f=s==="dark"?"dark":"light";let m,x,g,p,b,y;return e[8]!==o||e[9]!==f?(m=c.jsx(Qa,{theme:f,language:"python",className:"cm border rounded overflow-hidden",extensions:i7,value:o,onChange:r}),e[8]=o,e[9]=f,e[10]=m):m=e[10],e[11]!==h||e[12]!==m?(x=c.jsxs("div",{className:"flex flex-col gap-6 py-4",children:[d,u,h,m]}),e[11]=h,e[12]=m,e[13]=x):x=e[13],e[14]!==n?(g=c.jsx(ke,{"data-testid":"snippet-cancel-button",variant:"secondary",onClick:n,children:"Cancel"}),e[14]=n,e[15]=g):g=e[15],e[16]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx(ke,{"data-testid":"snippet-send-button","aria-label":"Save",variant:"default",type:"submit",children:"Send"}),e[16]=p):p=e[16],e[17]!==g?(b=c.jsxs(ja,{children:[g,p]}),e[17]=g,e[18]=b):b=e[18],e[19]!==a||e[20]!==b||e[21]!==x?(y=c.jsx(Ho,{className:"w-fit",children:c.jsxs("form",{onSubmit:a,children:[l,x,b]})}),e[19]=a,e[20]=b,e[21]=x,e[22]=y):y=e[22],y},c7=[Ve.lineWrapping],d7=()=>{const t=H.c(20),[e,n]=G.useState();let o;t[0]===Symbol.for("react.memo_cache_sentinel")?(o=[],t[0]=o):o=t[0];const{data:r,error:s,isPending:a}=Cn(f7,o);if(s){let b;return t[1]!==s?(b=c.jsx(br,{error:s}),t[1]=s,t[2]=b):b=t[2],b}if(a||!r){let b;return t[3]===Symbol.for("react.memo_cache_sentinel")?(b=c.jsx(bn,{size:"medium",centered:!0}),t[3]=b):b=t[3],b}const i=e?"h-1/3":"h-full";let l,d,u,h,f,m,x,g,p;return t[4]!==i?(l=ge("border-b rounded-none",i),t[4]=i,t[5]=l):l=t[5],t[6]===Symbol.for("react.memo_cache_sentinel")?(d=c.jsx(Ma,{placeholder:"Search snippets...",className:"h-6 m-1",rootClassName:"flex-1 border-r"}),t[6]=d):d=t[6],t[7]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsxs("div",{className:"flex items-center w-full",children:[d,c.jsx(a7,{children:c.jsx("button",{className:"float-right border-b px-2 m-0 h-full hover:bg-accent hover:text-accent-foreground",children:c.jsx(Ko,{className:"h-4 w-4"})})})]}),h=c.jsx(Ql,{children:"No results"}),t[7]=u,t[8]=h):(u=t[7],h=t[8]),t[9]===Symbol.for("react.memo_cache_sentinel")?(f=b=>n(b),t[9]=f):f=t[9],t[10]!==r.snippets?(m=c.jsx(h7,{onSelect:f,snippets:r.snippets}),t[10]=r.snippets,t[11]=m):m=t[11],t[12]!==l||t[13]!==m?(x=c.jsxs(ic,{className:l,children:[u,h,m]}),t[12]=l,t[13]=m,t[14]=x):x=t[14],t[15]!==e?(g=c.jsx(O.Suspense,{children:c.jsx("div",{className:"h-2/3 snippet-viewer flex flex-col",children:e?c.jsx(u7,{snippet:e},e.title):c.jsx(sn,{title:"",description:"Click on a snippet to view its content."})})}),t[15]=e,t[16]=g):g=t[16],t[17]!==x||t[18]!==g?(p=c.jsxs("div",{className:"flex-1 overflow-hidden",children:[x,g]}),t[17]=x,t[18]=g,t[19]=p):p=t[19],p},u7=t=>{const e=H.c(27),{snippet:n}=t,{theme:o}=Xo(),{createNewCell:r}=it(),s=cs();let a;e[0]!==r||e[1]!==s||e[2]!==n.sections?(a=()=>{for(const p of[...n.sections].reverse())p.code&&r({code:p.code,before:!1,cellId:s??"__end__",skipIfCodeExists:!0})},e[0]=r,e[1]=s,e[2]=n.sections,e[3]=a):a=e[3];const i=a;let l;e[4]!==r||e[5]!==s?(l=p=>{r({code:p,before:!1,cellId:s??"__end__"})},e[4]=r,e[5]=s,e[6]=l):l=e[6];const d=l;let u,h,f,m,x,g;if(e[7]!==n.title?(u=c.jsx("div",{className:"text-sm font-semibold bg-muted border-y px-2 py-1",children:n.title}),e[7]=n.title,e[8]=u):u=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(h=c.jsx(kr,{className:"ml-2 h-4 w-4"}),e[9]=h):h=e[9],e[10]!==i?(f=c.jsx("div",{className:"flex justify-end",children:c.jsx(Ts,{children:c.jsxs(ke,{className:"float-right",size:"xs",variant:"outline",onClick:i,children:["Insert snippet",h]})})}),e[10]=i,e[11]=f):f=e[11],e[12]!==d||e[13]!==n.sections||e[14]!==n.title||e[15]!==o){let p;e[17]!==d||e[18]!==n.title||e[19]!==o?(p=b=>{const{code:y,html:v,id:w}=b;return v?c.jsx("div",{children:Cm({html:v})},`${n.title}-${w}`):y?c.jsxs("div",{className:"relative hover-actions-parent pr-2",children:[c.jsx(Ts,{children:c.jsx(Ne,{content:"Insert snippet",children:c.jsx(ke,{className:"absolute -top-2 -right-1 z-10 hover-action px-2 bg-background",size:"sm",variant:"outline",onClick:()=>{d(y)},children:c.jsx(kr,{className:"h-5 w-5"})})})}),c.jsx(O.Suspense,{children:c.jsx(Qa,{theme:o==="dark"?"dark":"light",language:"python",className:"cm border rounded overflow-hidden",extensions:c7,value:y,readOnly:!0},`${n.title}-${w}`)})]},`${n.title}-${w}`):null},e[17]=d,e[18]=n.title,e[19]=o,e[20]=p):p=e[20],m=n.sections.map(p),e[12]=d,e[13]=n.sections,e[14]=n.title,e[15]=o,e[16]=m}else m=e[16];return e[21]!==f||e[22]!==m?(x=c.jsxs("div",{className:"px-2 py-2 space-y-4 overflow-auto flex-1",children:[f,m]}),e[21]=f,e[22]=m,e[23]=x):x=e[23],e[24]!==u||e[25]!==x?(g=c.jsxs(c.Fragment,{children:[u,x]}),e[24]=u,e[25]=x,e[26]=g):g=e[26],g},h7=t=>{const e=H.c(7),{snippets:n,onSelect:o}=t;let r,s;if(e[0]!==o||e[1]!==n){let a;e[3]!==o?(a=i=>c.jsx(Gn,{className:"rounded-none",onSelect:()=>o(i),children:c.jsx("div",{className:"flex flex-row gap-2 items-center",children:c.jsx("span",{className:"mt-1 text-accent-foreground",children:i.title})})},i.title),e[3]=o,e[4]=a):a=e[4],r=n.map(a),e[0]=o,e[1]=n,e[2]=r}else r=e[2];return e[5]!==r?(s=c.jsx(xm,{className:"flex flex-col overflow-auto",children:r}),e[5]=r,e[6]=s):s=e[6],s};function f7(){return LR()}const m7=G.lazy(()=>bm(()=>import("./tracing-Bp8ya33S.js").then(async t=>(await t.__tla,t)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,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,118,119,120,121,122,123,124,125]),import.meta.url).then(t=>({default:t.Tracing}))),p7=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx(G.Suspense,{fallback:c.jsx(g7,{}),children:c.jsx(m7,{})}),t[0]=e):e=t[0],e},g7=()=>{const t=H.c(1);let e;return t[0]===Symbol.for("react.memo_cache_sentinel")?(e=c.jsx("div",{className:"flex flex-col items-center justify-center h-full",children:c.jsx(bn,{})}),t[0]=e):e=t[0],e},ek="name",tk="type-value",Df="defs-refs",x7=[{id:ek,accessorFn:t=>[t.name,t.declaredBy],enableSorting:!0,sortingFn:"alphanumeric",header:({column:t})=>c.jsx(Dm,{header:"Name",column:t}),cell:({getValue:t})=>{const[e,n]=t();return c.jsx(Wh,{name:e,declaredBy:n})}},{id:tk,accessorFn:t=>[t.dataType,t.value],enableSorting:!0,sortingFn:"alphanumeric",header:({column:t})=>c.jsx(Dm,{header:c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{children:"Type"}),c.jsx("span",{children:"Value"})]}),column:t}),cell:({getValue:t})=>{const[e,n]=t();return c.jsxs("div",{className:"max-w-[150px]",children:[c.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap text-muted-foreground font-mono text-xs",children:e}),c.jsx("div",{className:"text-ellipsis overflow-hidden whitespace-nowrap",title:n??"",children:n})]})}},{id:Df,accessorFn:t=>[t.declaredBy,t.usedBy,t.name,t.declaredByNames,t.usedByNames],enableSorting:!0,sortingFn:"basic",header:({column:t})=>c.jsx(Dm,{header:c.jsxs("div",{className:"flex flex-col gap-1",children:[c.jsx("span",{children:"Declared By"}),c.jsx("span",{children:"Used By"})]}),column:t}),cell:({getValue:t})=>{const[e,n,o]=t(),r=s=>{const a=Ia(s);a&&Em(a,o)};return c.jsxs("div",{className:"flex flex-col gap-1 py-1",children:[c.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-center",children:[c.jsx("span",{title:"Declared by",children:c.jsx(Np,{className:"w-3.5 h-3.5 text-muted-foreground"})}),e.length===1?c.jsx(_o,{variant:"focus",cellId:e[0],skipScroll:!0,onClick:()=>r(e[0])}):c.jsx("div",{className:"text-destructive flex flex-row gap-2",children:e.slice(0,3).map((s,a)=>c.jsxs("span",{className:"flex",children:[c.jsx(_o,{variant:"focus",cellId:s,skipScroll:!0,className:"whitespace-nowrap text-destructive",onClick:()=>r(s)},s),a<e.length-1&&", "]},s))})]}),c.jsxs("div",{className:"flex flex-row overflow-auto gap-2 items-baseline",children:[c.jsx("span",{title:"Used by",children:c.jsx(ci,{className:"w-3.5 h-3.5 text-muted-foreground"})}),c.jsx(N2,{maxCount:3,cellIds:n,skipScroll:!0,onClick:r})]})]})}}],nk=O.memo(({className:t,cellIds:e,variables:n})=>{const[o,r]=G.useState([]),[s,a]=G.useState(""),i=FR(),l=O.useMemo(()=>{const h=f=>{const m=i[f];return VR(m)?`cell-${e.indexOf(f)}`:m??`cell-${e.indexOf(f)}`};return Object.values(n).map(f=>({...f,declaredByNames:f.declaredBy.map(h),usedByNames:f.usedBy.map(h)}))},[n,i,e]),d=O.useMemo(()=>{const h=new Map;return e.forEach((f,m)=>h.set(f,m)),function({variables:f,sort:m,cellIdToIndex:x}){m||(m={id:Df,desc:!1});let g=[];switch(m.id){case ek:g=oi(f,p=>p.name);break;case tk:g=oi(f,p=>p.dataType);break;case Df:g=oi(f,p=>x.get(p.declaredBy[0]))}return m.desc?g.reverse():g}({variables:l,sort:o[0],cellIdToIndex:h})},[l,o,e]),u=zR({data:d,columns:x7,getCoreRowModel:$R(),onGlobalFilterChange:a,getFilteredRowModel:UR(),enableFilters:!0,enableGlobalFilter:!0,enableColumnPinning:!1,getColumnCanGlobalFilter:h=>h.columnDef.enableGlobalFilter??!0,globalFilterFn:"auto",manualSorting:!0,onSortingChange:r,getSortedRowModel:BR(),state:{sorting:o,globalFilter:s}});return c.jsxs(c.Fragment,{children:[c.jsx(aS,{className:"w-full",placeholder:"Search",value:s,onChange:h=>a(h.target.value)}),c.jsxs(Mm,{className:ge("w-full text-sm flex-1 border-separate border-spacing-0",t),children:[c.jsx(Tm,{children:c.jsx(ks,{className:"whitespace-nowrap text-xs",children:u.getFlatHeaders().map(h=>c.jsx(yr,{className:"sticky top-0 bg-background border-b",children:dS(h.column.columnDef.header,h.getContext())},h.id))})}),c.jsx(Om,{children:u.getRowModel().rows.map(h=>c.jsx(ks,{className:"hover:bg-accent",children:h.getVisibleCells().map(f=>c.jsx(vr,{className:"border-b",children:dS(f.column.columnDef.cell,f.getContext())},f.id))},h.id))})]})]})});nk.displayName="VariableTable";const b7=()=>{const t=H.c(4),e=_m(),n=Tc();if(Object.keys(e).length===0){let r;return t[0]===Symbol.for("react.memo_cache_sentinel")?(r=c.jsx(sn,{title:"No variables",description:"Global variables will appear here.",icon:c.jsx(Ul,{})}),t[0]=r):r=t[0],r}let o;return t[1]!==n.inOrderIds||t[2]!==e?(o=c.jsx(nk,{className:"flex-1",cellIds:n.inOrderIds,variables:e}),t[1]=n.inOrderIds,t[2]=e,t[3]=o):o=t[3],o},y7=t=>{const e=H.c(54),n=fs(),o=Ie(HR),r=Ie(Y_),s=it(),a=S3(),i=r[t.cellId],l=n.cellData[t.cellId],d=n.cellRuntime[t.cellId];let u,h,f,m,x,g,p,b,y,v,w,S,N,j;if(e[0]!==s||e[1]!==a||e[2]!==o.focusedCellId||e[3]!==r||e[4]!==t.cellId||e[5]!==i||e[6]!==l.code||e[7]!==d.errored){if(u={id:t.cellId,graph:i,code:l.code,hasError:d.errored},o.focusedCellId&&r[o.focusedCellId]){const F=r[o.focusedCellId];let D;e[20]!==o.focusedCellId||e[21]!==F?(D={id:o.focusedCellId,graph:F},e[20]=o.focusedCellId,e[21]=F,e[22]=D):D=e[22],m=D}f=(m==null?void 0:m.id)===u.id,h=rk(u.graph)?1.5:3;const R=()=>{f?a.blurCell():(s.focusCell({cellId:u.id,where:"exact"}),a.focusCell({cellId:u.id}))};v=u.id;const M=f?"text-primary-foreground":"text-[var(--gray-8)] hover:text-[var(--gray-9)]";e[23]!==M?(w=ge("group bg-transparent text-left w-full flex relative justify-between items-center","border-none rounded cursor-pointer","h-[21px] pl-[51px] font-inherit",M),e[23]=M,e[24]=w):w=e[24],S=R,x=C7;const L=f&&"bg-primary group-hover:bg-primary";e[25]!==L?(y=ge("group-hover:bg-[var(--gray-2)] flex h-full w-full px-0.5 items-center rounded",L),e[25]=L,e[26]=y):y=e[26],g="truncate px-1 font-mono text-sm flex gap-1",p=u.code,b=u.graph.variables.length>0?c.jsx(S7,{cell:u,selectedCell:m}):c.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap max-w-full",children:k7(u.code)??c.jsx("span",{className:"italic",children:"empty"})}),e[0]=s,e[1]=a,e[2]=o.focusedCellId,e[3]=r,e[4]=t.cellId,e[5]=i,e[6]=l.code,e[7]=d.errored,e[8]=u,e[9]=h,e[10]=f,e[11]=m,e[12]=x,e[13]=g,e[14]=p,e[15]=b,e[16]=y,e[17]=v,e[18]=w,e[19]=S}else u=e[8],h=e[9],f=e[10],m=e[11],x=e[12],g=e[13],p=e[14],b=e[15],y=e[16],v=e[17],w=e[18],S=e[19];e[27]!==g||e[28]!==p||e[29]!==b?(N=c.jsx("div",{className:g,title:p,children:b}),e[27]=g,e[28]=p,e[29]=b,e[30]=N):N=e[30],e[31]!==N||e[32]!==y?(j=c.jsx("div",{className:y,children:N}),e[31]=N,e[32]=y,e[33]=j):j=e[33];const C=f?"z-30":"z-20";let _,A,I,P;return e[34]!==u||e[35]!==m||e[36]!==C?(_=ge("absolute overflow-visible top-[10.5px] left-[calc(var(--spacing-extra-small,8px)_+_17px)] pointer-events-none",C,function({cell:R,selectedCell:M}){return R.hasError?"text-destructive":!M&&!rk(R.graph)?"text-foreground":(M==null?void 0:M.id)===R.id||M!=null&&M.graph.parents.has(R.id)||M!=null&&M.graph.children.has(R.id)?"text-primary":"text-[var(--gray-8)]"}({cell:u,selectedCell:m})),e[34]=u,e[35]=m,e[36]=C,e[37]=_):_=e[37],e[38]!==u||e[39]!==h||e[40]!==f||e[41]!==t.cellPositions||e[42]!==m?(A=f?c.jsx(N7,{cell:u,cellPositions:t.cellPositions,circleRadius:h}):c.jsx(j7,{cell:u,selectedCell:m,circleRadius:h}),e[38]=u,e[39]=h,e[40]=f,e[41]=t.cellPositions,e[42]=m,e[43]=A):A=e[43],e[44]!==_||e[45]!==A?(I=c.jsx("svg",{className:_,width:"1",height:"1",children:A}),e[44]=_,e[45]=A,e[46]=I):I=e[46],e[47]!==x||e[48]!==j||e[49]!==I||e[50]!==v||e[51]!==w||e[52]!==S?(P=c.jsxs("button",{"data-node-id":v,className:w,onClick:S,onMouseDown:x,children:[j,I]}),e[47]=x,e[48]=j,e[49]=I,e[50]=v,e[51]=w,e[52]=S,e[53]=P):P=e[53],P},v7=t=>{const e=H.c(28),{open:n,setOpen:o}=t,r=fs();let s;e[0]!==r.cellIds.inOrderIds?(s=Object.fromEntries(r.cellIds.inOrderIds.map(E7)),e[0]=r.cellIds.inOrderIds,e[1]=s):s=e[1];const a=s;let i;if(e[2]!==r.cellIds){i=[];let v=0;for(const[w,S]of r.cellIds.getColumns().entries())w>0&&i.push(v),v+=S.inOrderIds.length;e[2]=r.cellIds,e[3]=i}else i=e[3];const l=n?"translate-x-0":"translate-x-[calc(100%+20px)]";let d,u,h,f,m,x,g,p,b,y;if(e[4]!==l?(d=ge("fixed top-14 right-5 z-50 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 rounded-lg border shadow-lg w-64 flex flex-col max-h-[58vh]","motion-safe:transition-transform motion-safe:duration-200 motion-safe:ease-in-out",l),e[4]=l,e[5]=d):d=e[5],e[6]===Symbol.for("react.memo_cache_sentinel")?(u=c.jsx("span",{className:"text-sm font-semibold",children:"Minimap"}),e[6]=u):u=e[6],e[7]!==o?(h=()=>o(!1),e[7]=o,e[8]=h):h=e[8],e[9]===Symbol.for("react.memo_cache_sentinel")?(f=c.jsx(En,{className:"h-4 w-4"}),e[9]=f):f=e[9],e[10]!==h?(m=c.jsxs("div",{className:"flex items-center justify-between p-4 border-b",children:[u,c.jsx(ke,{variant:"ghost",size:"icon",className:"h-6 w-6",onClick:h,children:f})]}),e[10]=h,e[11]=m):m=e[11],e[12]!==a||e[13]!==i||e[14]!==r.cellIds.inOrderIds){let v;e[16]!==a||e[17]!==i?(v=(w,S)=>{const N=i.includes(S);return c.jsxs(O.Fragment,{children:[N&&c.jsx("div",{className:"absolute left-5 w-[36px] h-px bg-[var(--gray-4)] pointer-events-none","aria-hidden":"true"}),c.jsx(y7,{cellId:w,cellPositions:a})]},w)},e[16]=a,e[17]=i,e[18]=v):v=e[18],x=r.cellIds.inOrderIds.map(v),e[12]=a,e[13]=i,e[14]=r.cellIds.inOrderIds,e[15]=x}else x=e[15];return e[19]!==x?(g=c.jsx("div",{className:"py-3 pl-3 pr-4 relative min-h-full",children:x}),e[19]=x,e[20]=g):g=e[20],e[21]===Symbol.for("react.memo_cache_sentinel")?(p=c.jsx("div",{className:"h-0 overflow-hidden","aria-hidden":"true"}),e[21]=p):p=e[21],e[22]!==g?(b=c.jsxs("div",{className:"overflow-y-auto overflow-x-hidden flex-1 scrollbar-none",children:[g,p]}),e[22]=g,e[23]=b):b=e[23],e[24]!==b||e[25]!==d||e[26]!==m?(y=c.jsxs("div",{className:d,children:[m,b]}),e[24]=b,e[25]=d,e[26]=m,e[27]=y):y=e[27],y},w7=()=>{const t=H.c(5),[e,n]=St(xb);let o,r;return t[0]!==n?(o=()=>n(_7),t[0]=n,t[1]=o):o=t[1],Ot("global.toggleMinimap",o),t[2]!==e||t[3]!==n?(r=c.jsx(v7,{open:e,setOpen:n}),t[2]=e,t[3]=n,t[4]=r):r=t[4],r};function k7(t){return t.split(`
148
- `)[0].trim()||void 0}const S7=t=>{const e=H.c(11),{cell:n,selectedCell:o}=t,r=_m(),s=n.id===(o==null?void 0:o.id);let a,i;if(e[0]!==n.graph.variables||e[1]!==s||e[2]!==o||e[3]!==r){let l;e[5]!==s||e[6]!==o||e[7]!==r?(l=(d,u)=>{const h=r[d];return c.jsxs(O.Fragment,{children:[u>0&&", ",c.jsx("span",{className:ge({"font-bold":s,"text-foreground":o===void 0,"text-primary font-medium":!s&&K_(h,o)}),children:d})]},d)},e[5]=s,e[6]=o,e[7]=r,e[8]=l):l=e[8],a=n.graph.variables.map(l),e[0]=n.graph.variables,e[1]=s,e[2]=o,e[3]=r,e[4]=a}else a=e[4];return e[9]!==a?(i=c.jsx(c.Fragment,{children:a}),e[9]=a,e[10]=i):i=e[10],i},N7=t=>{const e=H.c(12),{cell:n,cellPositions:o,circleRadius:r}=t;let s,a,i,l;if(e[0]!==n.graph.children||e[1]!==n.graph.parents||e[2]!==n.id||e[3]!==o){s=[];const d=o[n.id]??0,u=new Set;for(const h of n.graph.parents)n.graph.children.has(h)&&u.add(h);for(const h of u){const f=o[h];if(f!==void 0){const m=21*(f-d);s.push(c.jsx("path",{d:`M -3 0 H -7 v ${m} h 14 v ${-m} H 3`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-cycle-${h}`))}}for(const h of n.graph.parents){if(u.has(h))continue;const f=o[h];if(f!==void 0){const m=21*(f-d);s.push(c.jsx("path",{d:`M -3 0 H -7 v ${m} h -4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-up-${h}`))}}for(const h of n.graph.children){if(u.has(h))continue;const f=o[h];if(f!==void 0){const m=21*(f-d);s.push(c.jsx("path",{d:`M 3 0 H 7 v ${m} h 4`,fill:"none",strokeWidth:"2",stroke:"currentColor"},`${n.id}-down-${h}`))}}e[0]=n.graph.children,e[1]=n.graph.parents,e[2]=n.id,e[3]=o,e[4]=s}else s=e[4];return e[5]!==r?(a=c.jsx("circle",{r,fill:"currentColor",className:"pointer-events-auto"}),e[5]=r,e[6]=a):a=e[6],e[7]!==s?(i=c.jsx("g",{className:"pen pointer-events-auto",children:s}),e[7]=s,e[8]=i):i=e[8],e[9]!==a||e[10]!==i?(l=c.jsxs("g",{transform:"translate(0, 0)",children:[a,i]}),e[9]=a,e[10]=i,e[11]=l):l=e[11],l};function j7(t){const{cell:e,selectedCell:n,circleRadius:o}=t,r=e.graph.ancestors.size>0,s=e.graph.descendants.size>0;if(!n)return ok({circleRadius:o,leftWisker:r,rightWisker:s});const a=n.graph.ancestors.has(e.id),i=n.graph.descendants.has(e.id);return ok(a||i?{circleRadius:o,leftWisker:r,rightWisker:s,shift:a&&i?void 0:a?"left":"right"}:{circleRadius:o,leftWisker:!1,rightWisker:!1})}function ok(t){const{circleRadius:e,leftWisker:n,rightWisker:o,shift:r}=t,s=r===void 0?0:r==="left"?-14:14;return c.jsxs("g",{transform:`translate(${s}, 0)`,children:[c.jsxs("g",{children:[n&&c.jsx("path",{d:"M 0 0 h -8",fill:"none",strokeWidth:"2",stroke:"currentColor"}),o&&c.jsx("path",{d:"M 0 0 h 8",fill:"none",strokeWidth:"2",stroke:"currentColor"})]}),c.jsx("circle",{r:e,fill:"currentColor",className:"pointer-events-auto"})]})}function rk(t){return t.variables.length===0&&t.ancestors.size===0&&t.descendants.size===0}function C7(t){return t.preventDefault()}function E7(t,e){return[t,e]}function _7(t){return!t}const I7=G.lazy(()=>bm(()=>import("./terminal-DY_Rl00-.js"),__vite__mapDeps([126,1,2,127]),import.meta.url)),A7=t=>{const e=H.c(122),{children:n}=t,{isSidebarOpen:o,isTerminalOpen:r,selectedPanel:s}=oc(),{setIsSidebarOpen:a,setIsTerminalOpen:i}=Fa(),l=G.useRef(null),d=G.useRef(null);let u,h,f,m,x;e[0]!==o?(u=()=>{if(!l.current)return;const Oe=l.current.isCollapsed();o&&Oe&&l.current.expand(),o||Oe||l.current.collapse(),requestAnimationFrame(M7)},h=[o],e[0]=o,e[1]=u,e[2]=h):(u=e[1],h=e[2]),O.useEffect(u,h),e[3]!==r?(f=()=>{if(!d.current)return;const Oe=d.current.isCollapsed();r&&Oe&&d.current.expand(),r||Oe||d.current.collapse(),requestAnimationFrame(D7)},m=[r],e[3]=r,e[4]=f,e[5]=m):(f=e[4],m=e[5]),O.useEffect(f,m),e[6]!==n?(x=c.jsx(Oc,{id:"app",className:"relative h-full",children:c.jsx(O.Suspense,{children:n})},"app"),e[6]=n,e[7]=x):x=e[7];const g=x,p=o?"resize-handle":"resize-handle-collapsed";let b,y;e[8]!==p?(b=ge("border-border no-print z-10",p,"vertical"),e[8]=p,e[9]=b):b=e[9],e[10]!==b?(y=c.jsx(uS,{onDragging:hS,className:b}),e[10]=b,e[11]=y):y=e[11];const v=y,w=r?"resize-handle":"resize-handle-collapsed";let S,N;e[12]!==w?(S=ge("border-border no-print z-20",w,"horizontal"),e[12]=w,e[13]=S):S=e[13],e[14]!==S?(N=c.jsx(uS,{onDragging:hS,className:S}),e[14]=S,e[15]=N):N=e[15];const j=N;let C,_,A,I,P,R,M,L,F,D,T,k,B,E,U,V,$,X,Y,J,Q;e[16]!==s?(C=c.jsx("div",{className:"text-sm text-[var(--slate-11)] uppercase tracking-wide font-semibold flex-1",children:s}),e[16]=s,e[17]=C):C=e[17],e[18]!==a?(_=()=>a(!1),e[18]=a,e[19]=_):_=e[19],e[20]===Symbol.for("react.memo_cache_sentinel")?(A=c.jsx(En,{className:"w-4 h-4"}),e[20]=A):A=e[20],e[21]!==_?(I=c.jsx(ke,{"data-testid":"close-helper-pane",className:"m-0",size:"xs",variant:"text",onClick:_,children:A}),e[21]=_,e[22]=I):I=e[22],e[23]!==C||e[24]!==I?(P=c.jsxs("div",{className:"p-3 border-b flex justify-between items-center",children:[C,I]}),e[23]=C,e[24]=I,e[25]=P):P=e[25],e[26]!==s?(R=s==="files"&&c.jsx(qw,{}),e[26]=s,e[27]=R):R=e[27],e[28]!==s?(M=s==="errors"&&c.jsx(gM,{}),e[28]=s,e[29]=M):M=e[29],e[30]!==s?(L=s==="variables"&&c.jsx(b7,{}),e[30]=s,e[31]=L):L=e[31],e[32]!==s?(F=s==="dependencies"&&c.jsx(tM,{}),e[32]=s,e[33]=F):F=e[33],e[34]!==s?(D=s==="packages"&&c.jsx($M,{}),e[34]=s,e[35]=D):D=e[35],e[36]!==s?(T=s==="outline"&&c.jsx(UM,{}),e[36]=s,e[37]=T):T=e[37],e[38]!==s?(k=s==="datasources"&&c.jsx(mM,{}),e[38]=s,e[39]=k):k=e[39],e[40]!==s?(B=s==="documentation"&&c.jsx(pM,{}),e[40]=s,e[41]=B):B=e[41],e[42]!==s?(E=s==="snippets"&&c.jsx(d7,{}),e[42]=s,e[43]=E):E=e[43],e[44]!==s?(U=s==="scratchpad"&&c.jsx(QM,{}),e[44]=s,e[45]=U):U=e[45],e[46]!==s?(V=s==="chat"&&c.jsx(S8,{}),e[46]=s,e[47]=V):V=e[47],e[48]!==s?($=s==="logs"&&c.jsx(Gw,{}),e[48]=s,e[49]=$):$=e[49],e[50]!==s?(X=s==="tracing"&&c.jsx(p7,{}),e[50]=s,e[51]=X):X=e[51],e[52]!==s?(Y=s==="secrets"&&c.jsx(e7,{}),e[52]=s,e[53]=Y):Y=e[53],e[54]!==R||e[55]!==M||e[56]!==L||e[57]!==F||e[58]!==D||e[59]!==T||e[60]!==k||e[61]!==B||e[62]!==E||e[63]!==U||e[64]!==V||e[65]!==$||e[66]!==X||e[67]!==Y?(J=c.jsx(O.Suspense,{children:c.jsxs(Ic,{children:[R,M,L,F,D,T,k,B,E,U,V,$,X,Y]})}),e[54]=R,e[55]=M,e[56]=L,e[57]=F,e[58]=D,e[59]=T,e[60]=k,e[61]=B,e[62]=E,e[63]=U,e[64]=V,e[65]=$,e[66]=X,e[67]=Y,e[68]=J):J=e[68],e[69]!==P||e[70]!==J?(Q=c.jsx(lc,{children:c.jsxs("div",{className:"flex flex-col h-full flex-1 overflow-hidden mr-[-4px]",children:[P,J]})}),e[69]=P,e[70]=J,e[71]=Q):Q=e[71];const q=Q,K=o&&"border-r border-l border-[var(--slate-7)]";let re,oe,ne,se,te,pe;e[72]!==K?(re=ge("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",K),e[72]=K,e[73]=re):re=e[73],e[74]===Symbol.for("react.memo_cache_sentinel")?(oe=(Oe,Re)=>{var Ye;Re===0&&Oe===10&&((Ye=l.current)==null||Ye.resize(30))},e[74]=oe):oe=e[74],e[75]!==a?(ne=()=>a(!1),se=()=>a(!0),e[75]=a,e[76]=ne,e[77]=se):(ne=e[76],se=e[77]),e[78]!==q||e[79]!==v?(te=c.jsxs("span",{className:"flex flex-row h-full",children:[q," ",v]}),e[78]=q,e[79]=v,e[80]=te):te=e[80],e[81]!==re||e[82]!==ne||e[83]!==se||e[84]!==te?(pe=c.jsx(Oc,{ref:l,id:"helper",collapsedSize:0,collapsible:!0,className:re,minSize:10,defaultSize:0,maxSize:75,onResize:oe,onCollapse:ne,onExpand:se,children:te},"helper"),e[81]=re,e[82]=ne,e[83]=se,e[84]=te,e[85]=pe):pe=e[85];const he=pe,ae=r&&"border-[var(--slate-7)]";let ye,fe,Se,Me,Ee,Le,Te,Ze,He;e[86]!==ae?(ye=ge("dark:bg-[var(--slate-1)] no-print print:hidden hide-on-fullscreen",ae),e[86]=ae,e[87]=ye):ye=e[87],e[88]===Symbol.for("react.memo_cache_sentinel")?(fe=(Oe,Re)=>{var Ye;Re===0&&Oe===10&&((Ye=d.current)==null||Ye.resize(30))},e[88]=fe):fe=e[88],e[89]!==i?(Se=()=>i(!1),Me=()=>i(!0),e[89]=i,e[90]=Se,e[91]=Me):(Se=e[90],Me=e[91]),e[92]===Symbol.for("react.memo_cache_sentinel")?(Ee=c.jsx("div",{}),e[92]=Ee):Ee=e[92],e[93]!==i?(Le=()=>i(!1),e[93]=i,e[94]=Le):Le=e[94],e[95]!==r||e[96]!==Le?(Te=c.jsx(O.Suspense,{fallback:Ee,children:c.jsx(I7,{visible:r,onClose:Le})}),e[95]=r,e[96]=Le,e[97]=Te):Te=e[97],e[98]!==r||e[99]!==Te?(Ze=c.jsx(nM,{isOpen:r,children:Te}),e[98]=r,e[99]=Te,e[100]=Ze):Ze=e[100],e[101]!==ye||e[102]!==Se||e[103]!==Me||e[104]!==Ze||e[105]!==j?(He=c.jsxs(Oc,{ref:d,id:"terminal",collapsedSize:0,collapsible:!0,className:ye,minSize:10,defaultSize:0,maxSize:75,onResize:fe,onCollapse:Se,onExpand:Me,children:[j,Ze]},"terminal"),e[101]=ye,e[102]=Se,e[103]=Me,e[104]=Ze,e[105]=j,e[106]=He):He=e[106];const Ge=He;let ee,be,we,Ae,W,de,ue,ce,ve;return e[107]===Symbol.for("react.memo_cache_sentinel")?(ee=RL(),e[107]=ee):ee=e[107],e[108]===Symbol.for("react.memo_cache_sentinel")?(be=c.jsx(Ic,{children:c.jsx(s6,{})}),e[108]=be):be=e[108],e[109]!==Ge?(we=c.jsx(pb,{capability:"terminal",children:Ge}),e[109]=Ge,e[110]=we):we=e[110],e[111]!==g||e[112]!==we?(Ae=c.jsx(Oc,{children:c.jsxs(fS,{autoSaveId:"marimo:chrome:v1:l1",direction:"vertical",children:[g,we]})}),e[111]=g,e[112]=we,e[113]=Ae):Ae=e[113],e[114]===Symbol.for("react.memo_cache_sentinel")?(W=c.jsx(WR,{}),e[114]=W):W=e[114],e[115]!==he||e[116]!==Ae?(de=c.jsxs(fS,{autoSaveId:"marimo:chrome:v1:l2",direction:"horizontal",storage:ee,children:[be,he,Ae,W]}),e[115]=he,e[116]=Ae,e[117]=de):de=e[117],e[118]===Symbol.for("react.memo_cache_sentinel")?(ue=c.jsx(w7,{}),e[118]=ue):ue=e[118],e[119]===Symbol.for("react.memo_cache_sentinel")?(ce=c.jsx(lc,{children:c.jsx(Ic,{children:c.jsx(e6,{})})}),e[119]=ce):ce=e[119],e[120]!==de?(ve=c.jsxs(LL,{children:[de,ue,ce]}),e[120]=de,e[121]=ve):ve=e[121],ve};function T7(){window.dispatchEvent(new Event("resize"))}function M7(){requestAnimationFrame(T7)}function O7(){window.dispatchEvent(new Event("resize"))}function D7(){requestAnimationFrame(O7)}let sk;sk=new URL(window.location.href).searchParams.get(qR.showChrome)==="false",RS=Object.freeze(Object.defineProperty({__proto__:null,default:t=>{const e=H.c(10);if(sk){let s,a,i;return e[0]!==t?(s=c.jsx(mb,{hideControls:!0,...t}),e[0]=t,e[1]=s):s=e[1],e[2]===Symbol.for("react.memo_cache_sentinel")?(a=c.jsx(Fp,{}),e[2]=a):a=e[2],e[3]!==s?(i=c.jsxs(c.Fragment,{children:[s,a]}),e[3]=s,e[4]=i):i=e[4],i}let n,o,r;return e[5]!==t?(n=c.jsx(mb,{...t}),e[5]=t,e[6]=n):n=e[6],e[7]===Symbol.for("react.memo_cache_sentinel")?(o=c.jsx(Fp,{}),e[7]=o):o=e[7],e[8]!==n?(r=c.jsxs(A7,{children:[n,o]}),e[8]=n,e[9]=r):r=e[9],r}},Symbol.toStringTag,{value:"Module"}))});export{$m as C,Pc as E,sn as P,WL as __tla,Rc as a,RS as e,js as f};