@datalayer/agent-runtimes 1.5.21 → 1.5.23

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 (236) hide show
  1. package/dist-embed/chunks/{AgentDetails-C7tCazwB.js → AgentDetails-Xvq2IvHg.js} +1 -1
  2. package/dist-embed/chunks/{AgentDetailsDialog-Cwps4GeH.js → AgentDetailsDialog-DmtKB_5z.js} +1 -1
  3. package/dist-embed/chunks/{AgentInspector-Gk7jbg8t.js → AgentInspector-EiBHJgc9.js} +1 -1
  4. package/dist-embed/chunks/{AgentInspectorDialog-BSSDOFrT.js → AgentInspectorDialog-3fbLXnLP.js} +1 -1
  5. package/dist-embed/chunks/{CellSidebarExtension-p2BAkwis.js → CellSidebarExtension-CDnzN9Cb.js} +8 -8
  6. package/dist-embed/chunks/ChatView-BjZ993Ch.js +32 -0
  7. package/dist-embed/chunks/{ContextPie-bd_YOjzP.js → ContextPie-DdsXl5s7.js} +1 -1
  8. package/dist-embed/chunks/{DeckComponent-4gxuEH4A.js → DeckComponent-Cb4_dZpN.js} +2 -2
  9. package/dist-embed/chunks/{DocumentView-BZSYqTh_.js → DocumentView-Caxb2xz-.js} +1 -1
  10. package/dist-embed/chunks/{EphemeralDocument-Cevnk5OF.js → EphemeralDocument-DIHjR5l8.js} +1 -1
  11. package/dist-embed/chunks/{EphemeralNotebook-JvALIbK2.js → EphemeralNotebook-1Rwa3anx.js} +1 -1
  12. package/dist-embed/chunks/{ExcalidrawComponent-CbghNk-F.js → ExcalidrawComponent-vJQwgcUt.js} +1 -1
  13. package/dist-embed/chunks/{ExcalidrawModal-BOVvWzYQ.js → ExcalidrawModal-BDgjdSz2.js} +1 -1
  14. package/dist-embed/chunks/{JupyterLexicalExtension-CRccZ2h7.js → JupyterLexicalExtension-_7FM5Om8.js} +28 -28
  15. package/dist-embed/chunks/{KernelVariables-ompObBEM.js → KernelVariables-CKIqy599.js} +1 -1
  16. package/dist-embed/chunks/{LexicalToolRegistry-BlBEZPP4.js → LexicalToolRegistry-8wJyLumb.js} +1 -1
  17. package/dist-embed/chunks/{NotebookToolSurfaces-DP8sWqVy.js → NotebookToolSurfaces-YAM1bvZS.js} +1 -1
  18. package/dist-embed/chunks/{NotebookView-DC6BDVEp.js → NotebookView-C8RCvsR1.js} +1 -1
  19. package/dist-embed/chunks/{Output-C4hBhZ5k.js → Output-BWClePP-.js} +1 -1
  20. package/dist-embed/chunks/{SandboxDetailsDialog-CX8wvCLJ.js → SandboxDetailsDialog-CDSxIC0-.js} +1 -1
  21. package/dist-embed/chunks/{SchemaForm-BuhXDyz6.js → SchemaForm-CO_2yGg2.js} +1 -1
  22. package/dist-embed/chunks/{WidgetVariableView-C2X5Ehcg.js → WidgetVariableView--osoOLv8.js} +1 -1
  23. package/dist-embed/chunks/{YouTubePlugin-CjgOnMCz.js → YouTubePlugin-BB7Z7INn.js} +1 -1
  24. package/dist-embed/chunks/{abnfDiagram-VCTEODGH-kzVu7pzT.js → abnfDiagram-VCTEODGH-faK2fyHC.js} +1 -1
  25. package/dist-embed/chunks/{ar-SA-G6X2FPQ2-ArgZTGSp.js → ar-SA-G6X2FPQ2-D6Ko4I2x.js} +1 -1
  26. package/dist-embed/chunks/{architectureDiagram-5GKGNRK7-DVZUrWEx.js → architectureDiagram-5GKGNRK7-DBMLRsbO.js} +1 -1
  27. package/dist-embed/chunks/{az-AZ-76LH7QW2-DQgz6n32.js → az-AZ-76LH7QW2-B3UhxnSz.js} +1 -1
  28. package/dist-embed/chunks/{bg-BG-XCXSNQG7-Cx0dPt6-.js → bg-BG-XCXSNQG7-BS-QRZjB.js} +1 -1
  29. package/dist-embed/chunks/{blockDiagram-868be97b-DEQh5CUO.js → blockDiagram-868be97b-BXBoGds2.js} +1 -1
  30. package/dist-embed/chunks/{blockDiagram-I7D4REHJ-C6gbEBfg.js → blockDiagram-I7D4REHJ-BNkBA3Vb.js} +1 -1
  31. package/dist-embed/chunks/{bn-BD-2XOGV67Q-BkekmuYO.js → bn-BD-2XOGV67Q-DNg0uIV0.js} +1 -1
  32. package/dist-embed/chunks/{c4Diagram-3f4bdde3-CUcRctJE.js → c4Diagram-3f4bdde3-4OdTwU_t.js} +1 -1
  33. package/dist-embed/chunks/{c4Diagram-7LVT6UL2-DSQiEaxC.js → c4Diagram-7LVT6UL2-BGpBMrvl.js} +1 -1
  34. package/dist-embed/chunks/{ca-ES-6MX7JW3Y-Yr14RtMP.js → ca-ES-6MX7JW3Y-Bn4yHfTY.js} +1 -1
  35. package/dist-embed/chunks/{celltoolbartracker-Bx9x9aeh.js → celltoolbartracker-DcYHi8Du.js} +1 -1
  36. package/dist-embed/chunks/{chunk-2Q5K7J3B-DbzMjK_L.js → chunk-2Q5K7J3B-P4f8Cifn.js} +1 -1
  37. package/dist-embed/chunks/{chunk-5VM5RSS4-rEZEdbpi.js → chunk-5VM5RSS4-BVaSZr_4.js} +1 -1
  38. package/dist-embed/chunks/{chunk-F27PBJKO-BH7lDumP.js → chunk-F27PBJKO-C-90E7AT.js} +1 -1
  39. package/dist-embed/chunks/{chunk-IMKFNOWR-BA-vmq_V.js → chunk-IMKFNOWR--OZX7QCt.js} +1 -1
  40. package/dist-embed/chunks/{chunk-JWPE2WC7-BfRI4eJ2.js → chunk-JWPE2WC7-OHowekj4.js} +1 -1
  41. package/dist-embed/chunks/{chunk-POPQ4Y6H-B7pT6rUf.js → chunk-POPQ4Y6H-BgLsR3l7.js} +1 -1
  42. package/dist-embed/chunks/{chunk-SVP7TREG-BxpYXJab.js → chunk-SVP7TREG-kM9Erqyf.js} +1 -1
  43. package/dist-embed/chunks/{chunk-TICWLB2K-LCiyX33a.js → chunk-TICWLB2K-pVdCft0o.js} +1 -1
  44. package/dist-embed/chunks/{chunk-XXDRQBXY-islJGiCO.js → chunk-XXDRQBXY-BSfKSQ7y.js} +1 -1
  45. package/dist-embed/chunks/{classDiagram-ZZMXUADV-C7-Ca_nP.js → classDiagram-ZZMXUADV-Dq0Eb9fh.js} +1 -1
  46. package/dist-embed/chunks/{classDiagram-f62afe4f-BaJUb6H9.js → classDiagram-f62afe4f-C8j4XsQw.js} +1 -1
  47. package/dist-embed/chunks/{classDiagram-v2-604399ef-s6LKeK41.js → classDiagram-v2-604399ef-BVT78aGU.js} +1 -1
  48. package/dist-embed/chunks/{classDiagram-v2-VYDZK3BY-C7-Ca_nP.js → classDiagram-v2-VYDZK3BY-Dq0Eb9fh.js} +1 -1
  49. package/dist-embed/chunks/{code-block-IT6T5CEO-BieLU8ls.js → code-block-IT6T5CEO-Dbm1cj5T.js} +1 -1
  50. package/dist-embed/chunks/{component-p2xkjXeh.js → component-CsXw-w1P.js} +1 -1
  51. package/dist-embed/chunks/{cose-bilkent-JH36ORCC-BkezndW_.js → cose-bilkent-JH36ORCC-DEGpy0W8.js} +1 -1
  52. package/dist-embed/chunks/{createText-aed3d8b3-Dw8k7JC8.js → createText-aed3d8b3-BukHQ1P8.js} +1 -1
  53. package/dist-embed/chunks/{cs-CZ-2BRQDIVT-DYR-S6bD.js → cs-CZ-2BRQDIVT-DUGnyonZ.js} +1 -1
  54. package/dist-embed/chunks/{cynefinDiagram-5FMLGOSQ-DqoI6t3s.js → cynefinDiagram-5FMLGOSQ-CnZ3wqXe.js} +1 -1
  55. package/dist-embed/chunks/{da-DK-5WZEPLOC-DhaHIgKI.js → da-DK-5WZEPLOC-Is8nybqO.js} +1 -1
  56. package/dist-embed/chunks/{dagre-GXQ25YYZ-pcAHu_bK.js → dagre-GXQ25YYZ-Dbp_O7kO.js} +1 -1
  57. package/dist-embed/chunks/{de-DE-XR44H4JA-CJpRH2Fy.js → de-DE-XR44H4JA-D54sMa4L.js} +1 -1
  58. package/dist-embed/chunks/{diagram-S7CK7UJ4-W17wgXHY.js → diagram-S7CK7UJ4-DHPFd83P.js} +1 -1
  59. package/dist-embed/chunks/{diagram-UQ7AKVKN-mH7QBO8y.js → diagram-UQ7AKVKN-BqXFRP10.js} +1 -1
  60. package/dist-embed/chunks/{diagram-VSXAHHWV-CFHqpDaB.js → diagram-VSXAHHWV-DO0toZBQ.js} +1 -1
  61. package/dist-embed/chunks/{diagram-VX7I27RA-DQ6XlKLw.js → diagram-VX7I27RA-Diuc1eIf.js} +1 -1
  62. package/dist-embed/chunks/{diagram-Z3DM3KII-Cenqf76m.js → diagram-Z3DM3KII-DtauJWd2.js} +1 -1
  63. package/dist-embed/chunks/{ebnfDiagram-PWID7BFC-Cqmnghct.js → ebnfDiagram-PWID7BFC-SU3uN2_2.js} +1 -1
  64. package/dist-embed/chunks/{edges-b2856ca0-ChO7JKaP.js → edges-b2856ca0-DbD0XDJS.js} +1 -1
  65. package/dist-embed/chunks/{el-GR-BZB4AONW-DPGB1p8K.js → el-GR-BZB4AONW-CvM3SWat.js} +1 -1
  66. package/dist-embed/chunks/{erDiagram-5d81789a-jzhAXdZi.js → erDiagram-5d81789a-C-Tzt4MD.js} +1 -1
  67. package/dist-embed/chunks/{erDiagram-RLTQ6QDP-hAbP0vV0.js → erDiagram-RLTQ6QDP-C_c-qnRZ.js} +1 -1
  68. package/dist-embed/chunks/{es-ES-U4NZUMDT-CLztgM3g.js → es-ES-U4NZUMDT-BZDRRuRf.js} +1 -1
  69. package/dist-embed/chunks/{eu-ES-A7QVB2H4--ffZf65_.js → eu-ES-A7QVB2H4-DAmknI9y.js} +1 -1
  70. package/dist-embed/chunks/{fa-IR-HGAKTJCU-Cwwej6FC.js → fa-IR-HGAKTJCU-CQhKri4O.js} +1 -1
  71. package/dist-embed/chunks/{fi-FI-Z5N7JZ37-Tw-dUSxy.js → fi-FI-Z5N7JZ37-DzEDoP64.js} +1 -1
  72. package/dist-embed/chunks/{flowDb-185abca5-DDUaXZ_Q.js → flowDb-185abca5-Di4aD0Mg.js} +1 -1
  73. package/dist-embed/chunks/{flowDiagram-1629c991-DpvDtFPK.js → flowDiagram-1629c991-fImernS2.js} +1 -1
  74. package/dist-embed/chunks/{flowDiagram-HODETNUW-DENY4Bvt.js → flowDiagram-HODETNUW-DzoskzA4.js} +1 -1
  75. package/dist-embed/chunks/{flowDiagram-v2-1d953310-TxFSXMN7.js → flowDiagram-v2-1d953310-P1qDfDo-.js} +1 -1
  76. package/dist-embed/chunks/{flowchart-elk-definition-6df44142-BGFxwidp.js → flowchart-elk-definition-6df44142-CXebTCvX.js} +1 -1
  77. package/dist-embed/chunks/{fr-FR-RHASNOE6-CT1NyjSV.js → fr-FR-RHASNOE6-DiSkyvEB.js} +1 -1
  78. package/dist-embed/chunks/{ganttDiagram-3b0b3873-DJqKtGUz.js → ganttDiagram-3b0b3873-Bupos8HO.js} +1 -1
  79. package/dist-embed/chunks/{ganttDiagram-EL5Y4UJY-Ddh9hVkO.js → ganttDiagram-EL5Y4UJY-e3WDalFj.js} +1 -1
  80. package/dist-embed/chunks/{gitGraphDiagram-WWUBYQGX-B3BVHs36.js → gitGraphDiagram-WWUBYQGX-Ck49f0H9.js} +1 -1
  81. package/dist-embed/chunks/{gitGraphDiagram-f01e8bc2-vOvP_sU8.js → gitGraphDiagram-f01e8bc2-DM8FMetI.js} +1 -1
  82. package/dist-embed/chunks/{gl-ES-HMX3MZ6V-BKTaXj_2.js → gl-ES-HMX3MZ6V-3AJMzY-I.js} +1 -1
  83. package/dist-embed/chunks/{he-IL-6SHJWFNN-BJ5SwTG5.js → he-IL-6SHJWFNN-Cuh5an4X.js} +1 -1
  84. package/dist-embed/chunks/{hi-IN-IWLTKZ5I-D5ZQxogx.js → hi-IN-IWLTKZ5I-BbeuFB83.js} +1 -1
  85. package/dist-embed/chunks/{hu-HU-A5ZG7DT2-CoAAAzpy.js → hu-HU-A5ZG7DT2-C1OMfhob.js} +1 -1
  86. package/dist-embed/chunks/{id-ID-SAP4L64H-DFWbGjYj.js → id-ID-SAP4L64H-BzKILJTZ.js} +1 -1
  87. package/dist-embed/chunks/{index-9bae90f3-YA-Pbv-C.js → index-9bae90f3-l9tb84fw.js} +1 -1
  88. package/dist-embed/chunks/{index-CIDdX0nc.js → index-BFdE0KFI.js} +1 -1
  89. package/dist-embed/chunks/{index-Db1qHC1a.js → index-BMandbJB.js} +1 -1
  90. package/dist-embed/chunks/{index-BTeNnRc_.js → index-BO6VQLH6.js} +4 -4
  91. package/dist-embed/chunks/{index-1MXuxaax.js → index-BTnG8qrO.js} +1 -1
  92. package/dist-embed/chunks/{index-BVzIb3Wy.js → index-BktUM85c.js} +1 -1
  93. package/dist-embed/chunks/{index-BuyZwxeT.js → index-CAd5YQQl.js} +1 -1
  94. package/dist-embed/chunks/{index-DMf0f7ny.js → index-CFP9psRB.js} +2 -2
  95. package/dist-embed/chunks/{index-DPzPvDBn.js → index-CKFrz1es.js} +1 -1
  96. package/dist-embed/chunks/{index-DTCcg1ap.js → index-CM7xo08K.js} +1 -1
  97. package/dist-embed/chunks/{index-8Jy3Vws8.js → index-CPpm1tqJ.js} +6 -6
  98. package/dist-embed/chunks/{index-B0MhQWhs.js → index-CRZ1qthh.js} +1 -1
  99. package/dist-embed/chunks/{index-FbZJIbu_.js → index-CWwj0zW9.js} +1 -1
  100. package/dist-embed/chunks/{index-CCA_V9Td.js → index-Cu0bp_EI.js} +1 -1
  101. package/dist-embed/chunks/{index-BfMo5nXi.js → index-CyQgE_Es.js} +2 -2
  102. package/dist-embed/chunks/{index-BzQxauhZ.js → index-D4QM3qbA.js} +1 -1
  103. package/dist-embed/chunks/{index-D62kZnWZ.js → index-D64QvG43.js} +5 -5
  104. package/dist-embed/chunks/{index-JhvHCMRQ.js → index-DEjLPUAD.js} +1 -1
  105. package/dist-embed/chunks/{index-CkOZcvYl.js → index-DLimRfHQ.js} +1 -1
  106. package/dist-embed/chunks/{index-B0omKuYl.js → index-DN-cizG6.js} +1 -1
  107. package/dist-embed/chunks/{index-C7os26P7.js → index-DSN70XMH.js} +2 -2
  108. package/dist-embed/chunks/{index-CxIZHPCc.js → index-DY8mjz1l.js} +1 -1
  109. package/dist-embed/chunks/{index-BgWf1G8H.js → index-Dobs-OKl.js} +1 -1
  110. package/dist-embed/chunks/index-DyVR0igi.js +34 -0
  111. package/dist-embed/chunks/{index-6feFd5AZ.js → index-PqsSImlj.js} +1 -1
  112. package/dist-embed/chunks/{index-BNFZYAJT.js → index-SbFvdBPQ.js} +1 -1
  113. package/dist-embed/chunks/{index-B9vBhR-p.js → index-dYwQAVs_.js} +1 -1
  114. package/dist-embed/chunks/{index-DTbF6Y7O.js → index-f418CYn7.js} +1 -1
  115. package/dist-embed/chunks/{index-BL4KuFQP.js → index-f9WZsG2n.js} +1 -1
  116. package/dist-embed/chunks/{index-DSgHh0-i.js → index-noRoZrq5.js} +1 -1
  117. package/dist-embed/chunks/{index-B8y71UkT.js → index-wk9vl2uW.js} +1 -1
  118. package/dist-embed/chunks/{index-Dw1P-H6s.js → index-x45cMPwN.js} +1 -1
  119. package/dist-embed/chunks/{index.esm-B6P80s3J.js → index.esm-p0OnSU9h.js} +1 -1
  120. package/dist-embed/chunks/{infoDiagram-27XIBGKW-CZPNcDbH.js → infoDiagram-27XIBGKW-BjyM865y.js} +1 -1
  121. package/dist-embed/chunks/{infoDiagram-a29d40f1-Di_kmyTC.js → infoDiagram-a29d40f1-DXYFLipl.js} +1 -1
  122. package/dist-embed/chunks/{isEqual-D0eOPSLC.js → isEqual-Cwjr2skl.js} +1 -1
  123. package/dist-embed/chunks/{ishikawaDiagram-5VMMS53U-DD5TaPvH.js → ishikawaDiagram-5VMMS53U-Bb5g5HNe.js} +1 -1
  124. package/dist-embed/chunks/{it-IT-JPQ66NNP-C7p9bCWQ.js → it-IT-JPQ66NNP-DuG05fUR.js} +1 -1
  125. package/dist-embed/chunks/{ja-JP-DBVTYXUO-DupAM7Cv.js → ja-JP-DBVTYXUO-DeDfL3Bk.js} +1 -1
  126. package/dist-embed/chunks/{journeyDiagram-3NMN7TZE-1NqbTyL4.js → journeyDiagram-3NMN7TZE-96VNFopN.js} +1 -1
  127. package/dist-embed/chunks/{journeyDiagram-95396277-xr9Xk_mL.js → journeyDiagram-95396277-CQ_kN2gp.js} +1 -1
  128. package/dist-embed/chunks/{kaa-6HZHGXH3-DrthOcPY.js → kaa-6HZHGXH3-BRKFVG6s.js} +1 -1
  129. package/dist-embed/chunks/{kab-KAB-ZGHBKWFO-C4hr0kbU.js → kab-KAB-ZGHBKWFO-Uqakmhz5.js} +1 -1
  130. package/dist-embed/chunks/{kanban-definition-UXKFOSKX-DlSwjr3b.js → kanban-definition-UXKFOSKX-BPsXEKm4.js} +1 -1
  131. package/dist-embed/chunks/{kk-KZ-P5N5QNE5-CrjDkh9r.js → kk-KZ-P5N5QNE5-DWMXMIAK.js} +1 -1
  132. package/dist-embed/chunks/{km-KH-HSX4SM5Z-JHWf7VZ6.js → km-KH-HSX4SM5Z-BXNl9QnV.js} +1 -1
  133. package/dist-embed/chunks/{ko-KR-MTYHY66A-CJ4JxKMG.js → ko-KR-MTYHY66A-BZgIqTuN.js} +1 -1
  134. package/dist-embed/chunks/{ku-TR-6OUDTVRD-YSlLPag_.js → ku-TR-6OUDTVRD-CQNa5i5U.js} +1 -1
  135. package/dist-embed/chunks/{layout-5FOjTADt.js → layout-Dq0J6INj.js} +1 -1
  136. package/dist-embed/chunks/{lexicalHooks-eqXJbnX9.js → lexicalHooks-Pqoe8h_O.js} +1 -1
  137. package/dist-embed/chunks/{lt-LT-XHIRWOB4-2v6r2YYq.js → lt-LT-XHIRWOB4-BQW2k7iv.js} +1 -1
  138. package/dist-embed/chunks/{lv-LV-5QDEKY6T-DVGd68q4.js → lv-LV-5QDEKY6T-B0HRRCC4.js} +1 -1
  139. package/dist-embed/chunks/{mermaid.core-BU1Nkb56.js → mermaid.core-B9dEBs01.js} +4 -4
  140. package/dist-embed/chunks/{mermaid.core-DY5DKOtx.js → mermaid.core-pflA3DMC.js} +2 -2
  141. package/dist-embed/chunks/{mindmap-definition-YA3MSWOX-sSfUfKt8.js → mindmap-definition-YA3MSWOX-DwLQYAqQ.js} +1 -1
  142. package/dist-embed/chunks/{mindmap-definition-e4c1d938-btrk6STt.js → mindmap-definition-e4c1d938-CDWIPlcb.js} +1 -1
  143. package/dist-embed/chunks/{mr-IN-CRQNXWMA-D1q8zjMr.js → mr-IN-CRQNXWMA-DXR6sWSH.js} +1 -1
  144. package/dist-embed/chunks/{my-MM-5M5IBNSE-CCWuEpIN.js → my-MM-5M5IBNSE-BZ5_9oCm.js} +1 -1
  145. package/dist-embed/chunks/{nb-NO-T6EIAALU-eJ92wx2h.js → nb-NO-T6EIAALU-CBtv36wZ.js} +1 -1
  146. package/dist-embed/chunks/{nl-NL-IS3SIHDZ-DmkMgsvp.js → nl-NL-IS3SIHDZ-CcqE3cY8.js} +1 -1
  147. package/dist-embed/chunks/{nn-NO-6E72VCQL-CWYEaXBn.js → nn-NO-6E72VCQL-Cl9wPgpU.js} +1 -1
  148. package/dist-embed/chunks/{oc-FR-POXYY2M6-CayriaEZ.js → oc-FR-POXYY2M6-CQEkV2p1.js} +1 -1
  149. package/dist-embed/chunks/{pa-IN-N4M65BXN-CydiKcR8.js → pa-IN-N4M65BXN-CaE6yG0U.js} +1 -1
  150. package/dist-embed/chunks/{pegDiagram-XKGWAZYB--dcG-x2B.js → pegDiagram-XKGWAZYB-Cwo6HzRh.js} +1 -1
  151. package/dist-embed/chunks/{percentages-BXMCSKIN-fzYCDL7m.js → percentages-BXMCSKIN-Bk5xifLL.js} +3 -3
  152. package/dist-embed/chunks/{pieDiagram-E7YTZNPT-D-uncTun.js → pieDiagram-E7YTZNPT-BvBHesgq.js} +1 -1
  153. package/dist-embed/chunks/{pieDiagram-c941bede-BoVaJIdw.js → pieDiagram-c941bede-Bsn1Bxk5.js} +1 -1
  154. package/dist-embed/chunks/{pl-PL-T2D74RX3-DhiK4YSC.js → pl-PL-T2D74RX3-M1pQcF2j.js} +1 -1
  155. package/dist-embed/chunks/{pt-BR-5N22H2LF-CwSVxIqs.js → pt-BR-5N22H2LF-BFDHu72z.js} +1 -1
  156. package/dist-embed/chunks/{pt-PT-UZXXM6DQ-BnxquNJT.js → pt-PT-UZXXM6DQ-DFcZY1Gz.js} +1 -1
  157. package/dist-embed/chunks/{quadrantDiagram-AXDQQJYC-ClE_bWPS.js → quadrantDiagram-AXDQQJYC-AaQ_WgXa.js} +1 -1
  158. package/dist-embed/chunks/{quadrantDiagram-cf8b8fe0-V_e2KgDu.js → quadrantDiagram-cf8b8fe0-BhaNj-gz.js} +1 -1
  159. package/dist-embed/chunks/{railroadDiagram-O6MQD6OU-CkhmY0tS.js → railroadDiagram-O6MQD6OU-BlWFu3pn.js} +1 -1
  160. package/dist-embed/chunks/{renderer-BwlsmtXF.js → renderer-Dy4lZ1KZ.js} +1 -1
  161. package/dist-embed/chunks/{requirementDiagram-53bda41b-BZw7Ipej.js → requirementDiagram-53bda41b-C2WctYyl.js} +1 -1
  162. package/dist-embed/chunks/{requirementDiagram-BXWQKSXE-BXwXUXrr.js → requirementDiagram-BXWQKSXE-BpWNFdrw.js} +1 -1
  163. package/dist-embed/chunks/{ro-RO-JPDTUUEW-D3G2f_fQ.js → ro-RO-JPDTUUEW-BGm_Xwik.js} +1 -1
  164. package/dist-embed/chunks/{ru-RU-B4JR7IUQ-SnVfNwaW.js → ru-RU-B4JR7IUQ-BsrZ_x8p.js} +1 -1
  165. package/dist-embed/chunks/{sankeyDiagram-P5KCCOFB-0B_Kvjm2.js → sankeyDiagram-P5KCCOFB-DnT5kYW5.js} +1 -1
  166. package/dist-embed/chunks/{sankeyDiagram-c3ef121a-e1QLivkZ.js → sankeyDiagram-c3ef121a-3FD4GIJS.js} +1 -1
  167. package/dist-embed/chunks/{sequenceDiagram-82a5b84f-N-16oABv.js → sequenceDiagram-82a5b84f-CZQmoHAd.js} +1 -1
  168. package/dist-embed/chunks/{sequenceDiagram-WJ2MYXX4-CtbkJYCv.js → sequenceDiagram-WJ2MYXX4-0HHgJN0L.js} +1 -1
  169. package/dist-embed/chunks/{sessions-C9DBCyZI.js → sessions-BRALW9Yv.js} +1 -1
  170. package/dist-embed/chunks/{si-LK-N5RQ5JYF-Da7Bfexz.js → si-LK-N5RQ5JYF-BfaYS44g.js} +1 -1
  171. package/dist-embed/chunks/{sizeCapture-INFHLROL-B3xt8UaI.js → sizeCapture-INFHLROL-CIF2j9e_.js} +1 -1
  172. package/dist-embed/chunks/{sk-SK-C5VTKIMK-BB-Ks1b-.js → sk-SK-C5VTKIMK-D-K9yMTN.js} +1 -1
  173. package/dist-embed/chunks/{sl-SI-NN7IZMDC-DF3fUKHX.js → sl-SI-NN7IZMDC-B48XvZUw.js} +1 -1
  174. package/dist-embed/chunks/{stateDiagram-43e79a5f-BJcJNr41.js → stateDiagram-43e79a5f-CMlUXY1x.js} +1 -1
  175. package/dist-embed/chunks/{stateDiagram-D77RDMKH-LjWP-fRB.js → stateDiagram-D77RDMKH-CkICPC-C.js} +1 -1
  176. package/dist-embed/chunks/{stateDiagram-v2-2041ed4f-DTEruWg2.js → stateDiagram-v2-2041ed4f-BcO6vvJA.js} +1 -1
  177. package/dist-embed/chunks/{stateDiagram-v2-MP3YSRHH-_xCQcvgo.js → stateDiagram-v2-MP3YSRHH-BFlXwfgz.js} +1 -1
  178. package/dist-embed/chunks/{styles-455b33cd-OIhmfs6N.js → styles-455b33cd-BfyZJvzN.js} +1 -1
  179. package/dist-embed/chunks/{styles-f932cba9-CwLjreIv.js → styles-f932cba9-k2wfF-9Q.js} +1 -1
  180. package/dist-embed/chunks/{styles-fcc2142b-DP74dQpR.js → styles-fcc2142b-z3csTkbW.js} +1 -1
  181. package/dist-embed/chunks/{subset-shared.chunk-Cf9zgTA9.js → subset-shared.chunk-DzA7mJjZ.js} +1 -1
  182. package/dist-embed/chunks/{subset-worker.chunk-WYW3AHku.js → subset-worker.chunk-CsTEdHAt.js} +1 -1
  183. package/dist-embed/chunks/{sv-SE-XGPEYMSR-CeR-pJHy.js → sv-SE-XGPEYMSR-DfhLO_Vt.js} +1 -1
  184. package/dist-embed/chunks/{svgDrawCommon-148a3cd9-CgE5QJIv.js → svgDrawCommon-148a3cd9-NqUFgQ9x.js} +1 -1
  185. package/dist-embed/chunks/{swimlanes-42K2YHIH-CZyflHYJ.js → swimlanes-42K2YHIH-B6pxWv6a.js} +1 -1
  186. package/dist-embed/chunks/{swimlanesDiagram-VR7AAH4N-Bmr6N4fj.js → swimlanesDiagram-VR7AAH4N-B9ThT6OH.js} +1 -1
  187. package/dist-embed/chunks/{ta-IN-2NMHFXQM-lmsodGuU.js → ta-IN-2NMHFXQM-EZA_oxSt.js} +1 -1
  188. package/dist-embed/chunks/{th-TH-HPSO5L25-DQCWr96I.js → th-TH-HPSO5L25-G9vy_zQH.js} +1 -1
  189. package/dist-embed/chunks/{timeline-definition-24CTP7MA-DqY5EM6p.js → timeline-definition-24CTP7MA-DVcslyxd.js} +1 -1
  190. package/dist-embed/chunks/{timeline-definition-7545f45a-B8wMEyZY.js → timeline-definition-7545f45a-IhzNtIcW.js} +1 -1
  191. package/dist-embed/chunks/{tr-TR-DEFEU3FU-CqnvlGZW.js → tr-TR-DEFEU3FU-DBj_G5CD.js} +1 -1
  192. package/dist-embed/chunks/{uk-UA-QMV73CPH-DdWFjbHe.js → uk-UA-QMV73CPH-DN7lMu5H.js} +1 -1
  193. package/dist-embed/chunks/{vennDiagram-4TSXK5OY-63-O_xI8.js → vennDiagram-4TSXK5OY-KKysbuVs.js} +1 -1
  194. package/dist-embed/chunks/{vi-VN-M7AON7JQ-CydTT0Fi.js → vi-VN-M7AON7JQ-LoT02qgd.js} +1 -1
  195. package/dist-embed/chunks/{wardleyDiagram-VM6X3IG4-C9vLUvHf.js → wardleyDiagram-VM6X3IG4-CTed9ps7.js} +1 -1
  196. package/dist-embed/chunks/{xychartDiagram-3f383b91-BfoQg8n9.js → xychartDiagram-3f383b91-CsxcWMT8.js} +1 -1
  197. package/dist-embed/chunks/{xychartDiagram-S5SC5T6Z-BZr3T3n_.js → xychartDiagram-S5SC5T6Z-Kpqryflz.js} +1 -1
  198. package/dist-embed/chunks/{zh-CN-LNUGB5OW-DEn1TFfK.js → zh-CN-LNUGB5OW-CjexwOqT.js} +1 -1
  199. package/dist-embed/chunks/{zh-HK-E62DVLB3-DJQRmOHH.js → zh-HK-E62DVLB3-B0ys_HV6.js} +1 -1
  200. package/dist-embed/chunks/{zh-TW-RAJ6MFWO-B7s9vmSf.js → zh-TW-RAJ6MFWO-tQJWLJuU.js} +1 -1
  201. package/dist-embed/datalayer-app-main.js +19 -19
  202. package/lib/apps/apps/records.d.ts +0 -29
  203. package/lib/apps/apps/records.js +11 -34
  204. package/lib/apps/apps/threads.d.ts +2 -21
  205. package/lib/apps/apps/threads.js +0 -75
  206. package/lib/apps/embed/embedSession.d.ts +0 -8
  207. package/lib/apps/embed/embedSession.js +1 -38
  208. package/lib/apps/embed/visitorApp.d.ts +22 -3
  209. package/lib/apps/embed/visitorApp.js +42 -4
  210. package/lib/apps/plugins/chat/ChatView.js +2 -1
  211. package/lib/chat/base/ChatBase.js +1 -1
  212. package/lib/chat/base/fullContextMessages.js +1 -1
  213. package/lib/hooks/useAgUi.js +1 -1
  214. package/lib/hooks/useToolApprovals.d.ts +1 -1
  215. package/lib/hooks/useToolApprovals.js +1 -1
  216. package/lib/{protocols → portable}/agUiRefusal.d.ts +1 -1
  217. package/lib/{protocols → portable}/agUiRefusal.js +1 -1
  218. package/lib/portable/agui.d.ts +72 -0
  219. package/lib/portable/agui.js +174 -0
  220. package/lib/portable/conversation.d.ts +124 -0
  221. package/lib/portable/conversation.js +357 -0
  222. package/lib/portable/index.d.ts +11 -6
  223. package/lib/portable/index.js +14 -11
  224. package/lib/portable/records.d.ts +27 -0
  225. package/lib/portable/records.js +46 -0
  226. package/lib/portable/sessions.d.ts +92 -0
  227. package/lib/portable/sessions.js +134 -0
  228. package/lib/portable/thread.d.ts +41 -0
  229. package/lib/portable/thread.js +102 -0
  230. package/lib/protocols/AGUIAdapter.d.ts +0 -2
  231. package/lib/protocols/AGUIAdapter.js +39 -74
  232. package/package.json +1 -1
  233. package/dist-embed/chunks/ChatView-fHb_i4kH.js +0 -32
  234. package/dist-embed/chunks/index-DpJpQnPn.js +0 -34
  235. /package/lib/{utils → portable}/approvals.d.ts +0 -0
  236. /package/lib/{utils → portable}/approvals.js +0 -0
@@ -1,21 +1,21 @@
1
- import{r as S,ar as Gb,as as Xb,j as x,bi as Y,co as vn,T as Le,d2 as Zb,bj as bd,gq as Qb,nY as ey,B as co,I as Ft,e4 as Rp,nZ as kl,bd as St,aq as pe,n_ as Oe,n$ as Je,o0 as Ie,o1 as $t,l4 as F,o2 as Ot,o3 as kr,kL as q,kQ as oe,kR as It,o4 as Bt,aD as se,c as ft,aw as Ap,d4 as Zs,d1 as ty,eQ as Mt,_ as me,jB as Mp,eS as ny,D as $p,o5 as ry,o6 as _o,o7 as Tc,o8 as zo,kT as bt,o9 as Kn,kK as vt,aE as ne,oa as js,bS as de,ob as oy,l6 as zr,l3 as D,bV as ee,oc as ln,od as Dp,oe as sy,of as Fs,lh as cn,lk as ke,kS as ue,og as Ye,oh as Ge,oi as Pp,oj as yd,ok as gt,ol as iy,l8 as Kr,l2 as wn,om as Tl,l7 as Dt,on as un,oo as Tr,op as pt,oq as Vt,or as Ir,os as xs,ot as jp,ou as Ri,ov as ay,ow as mi,ox as Jn,oy as ly,oz as cy,bW as Q,oA as uy,kH as $e,ez as Fp,n as br,lj as Ae,oB as dy,oC as fy,oD as gy,oE as zt,oF as Eo,oG as tr,oH as nr,oI as Cs,oJ as xn,oK as Bs,oL as rr,oM as mn,oN as Us,lc as ve,l9 as re,oO as V,oP as Bp,oQ as Ic,oR as uo,bU as No,oS as py,oT as fo,oU as wd,oV as Up,oW as zp,oX as Il,oY as hy,oZ as Kp,o_ as Ec,o$ as _y,p0 as my,p1 as Nc,p2 as El,p3 as Wp,p4 as by,p5 as Hp,p6 as yy,p7 as Lc,p8 as Ss,l0 as Ee,p9 as wy,le as Nn,pa as xd,pb as xy,pc as Cy,pd as Cd,pe as Nl,l1 as Lo,pf as Oc,pg as bi,ph as sa,pi as Jp,pj as Rc,pk as ia,pl as Qs,pm as Sd,pn as vd,po as zs,pp as kd,pq as Bn,pr as Sy,ps as vy,pt as Xe,pu as ky,pv as Ty,pw as qp,px as Vp,py as Yp,bT as Ks,pz as Ac,pA as Iy,pB as he,pC as Gp,pD as vs,pE as Ra,pF as Xp,pG as Mc,pH as Ll,pI as Ey,pJ as Er,pK as wt,ld as or,pL as aa,pM as Ny,pN as $c,pO as Zp,pP as Dc,pQ as ps,pR as Td,pS as it,kI as ht,pT as Id,pU as Jt,pV as la,pW as Qp,pX as eh,pY as th,pZ as Wn,p_ as Ly,p$ as Oy,q0 as Ai,q1 as Ry,q2 as Ay,q3 as My,q4 as Ol,q5 as hr,q6 as nh,q7 as $y,q8 as Rl,q9 as Mi,qa as rh,la as Ht,qb as Oo,l5 as qe,qc as oh,qd as Dy,qe as Py,kG as jy,qf as mo,qg as sr,qh as sh,qi as Fy,qj as By,qk as Pc,ql as ih,qm as Uy,qn as Ed,qo as zy,qp as Nd,qq as Ky,qr as Wy,qs as jc,qt as Hy,qu as Ld,k_ as Jy,kZ as qy,kY as Vy,qv as Od,k$ as Yy,qw as Rd,qx as ah,K as fe,lf as Gy,qy as Xy,qz as Zy,qA as Qy,qB as Ad,qC as ew,qD as tw,qE as Md,qF as $d,qG as qn,qH as nw,qI as rw,qJ as ow,qK as sw,qL as Fc,qM as iw,qN as aw,je as Al,ee as ks,lb as bo,qO as lh,qP as $i,kJ as ch,kO as Bc,kN as Uc,kM as uh,kP as dh,qQ as fh,qR as Ml,qS as Dd,qT as lw,qU as $l,qV as ca,qW as gh,qX as ph,qY as cw,qZ as hh,q_ as _h,q$ as $n,r0 as uw,mf as dw,ml as Pd,mm as Dl,mo as fw,mp as gw,r1 as mh,r2 as bh,r3 as yh,r4 as wh,r5 as jd,C as xh,f as pw,r6 as hw,r7 as _w,H as mw,r8 as bw,r9 as yw,av as ww,ax as xw,k as Ch,ra as Cw,aF as Sh,rb as Sw,aB as vw,rc as kw,rd as Tw,jH as Lt,jP as Ke,jN as yr,jK as Qe,jO as wr,jM as Zt,jR as Iw,e7 as Ew,ek as Aa,i as Nw,re as yi,rf as Un,el as vh,rg as Lw,bf as zc,bX as Ow,rh as Kc,eI as Rw,ri as Aw,rj as Mw,rk as $w,rl as Dw,rm as Pw,rn as kh,ro as we,d6 as yo,b6 as Te,rp as Th,m as Di,rq as jw,rr as Fw,rs as ei,gv as Bw,rt as Uw,ru as Ko}from"../datalayer-app-main.js";import{d as zw,b as Kw,E as Ww,u as Hw,c as Jw,e as qw,f as Vw}from"./NotebookSkeleton-CI7ovjNW.js";import{p as is,e as Yw,s as Gw,u as Xw}from"./url-DuKx0yk0.js";import{r as Zw,a as Qw}from"./isSymbol-BLtK9CV6.js";import{t as Fd}from"./toNumber-B1wj8-wx.js";import{V as Ws,P as ex,C as Pi,D as Wc,T as Ih,H as tx,L as Eh,F as hs,Q as Nh,a as ji,M as nx,b as rx,B as Lh,I as Oh,S as Rh,R as ox,c as sx,d as ix}from"./VideoIcon-BjP_LDa4.js";import{L as Ah}from"./LinkIcon-DUI0jw25.js";import{A as ax}from"./Avatar-9MpXENSs.js";import{a as lx,T as cx}from"./Toolbar-CGQDY041.js";import{A as ux,a as dx}from"./ArrowUpIcon-BUCpIXDR.js";import{S as fx}from"./SortDescIcon-CS4EzHeS.js";import{P as gx}from"./PaintbrushIcon-CLU8RilX.js";import{P as Pl,p as px}from"./PrismCss-CcU1ChRk.js";import{j as jl,O as hx,C as _x}from"./Output-C4hBhZ5k.js";import{d as ge,l as go}from"./LexicalToolRegistry-BlBEZPP4.js";const Fi=(n,e,t)=>Math.min(t,Math.max(e,n));function ts(n){const e=n.trim(),t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);if(t){const[,o,s,i]=t;return{r:Number(o),g:Number(s),b:Number(i)}}let r=e.replace(/^#/,"");return r.length===3&&(r=r.split("").map(o=>o+o).join("")),/^[0-9a-f]{6}$/i.test(r)?{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}:{r:0,g:0,b:0}}function lr({r:n,g:e,b:t}){const r=o=>Fi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function Ma({r:n,g:e,b:t}){const r=n/255,o=e/255,s=t/255,i=Math.max(r,o,s),a=Math.min(r,o,s),l=i-a;let c=0;return l!==0&&(i===r?c=60*((o-s)/l%6):i===o?c=60*((s-r)/l+2):c=60*((r-o)/l+4)),c<0&&(c+=360),{h:c,s:i===0?0:l/i*100,v:i*100}}function ti({h:n,s:e,v:t}){const r=e/100,o=t/100,s=o*r,i=s*(1-Math.abs(n/60%2-1)),a=o-s,l=Math.floor((n%360+360)%360/60),[c,u,f]=[[s,i,0],[i,s,0],[0,s,i],[0,i,s],[i,0,s],[s,0,i]][l];return{r:Math.round((c+a)*255),g:Math.round((u+a)*255),b:Math.round((f+a)*255)}}function Bd(n){const e=n.trim();return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)||/^rgba?\(\s*\d+[,\s]+\d+[,\s]+\d+/i.test(e)}const mx=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function bx(n="datalayer",e="light"){const t=Zb(n,e),r=bd[n]??bd.datalayer,s=(e==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e)==="dark"?r.themeStyles.dark:r.themeStyles.light,i=a=>s[a];return{label:r.label,colors:[i("--bgColor-default"),i("--bgColor-muted"),i("--fgColor-default"),i("--fgColor-muted"),i("--fgColor-accent"),i("--fgColor-success"),i("--fgColor-attention"),i("--fgColor-danger"),t.glow,t.pop,t.spark,t.blaze,t.surge,t.flame,t.gold].filter(Boolean)}}function yx(n="datalayer",e="dark"){return{label:"Collaborators",colors:zw(n,e)}}const wx=150,xx=12;function Ud(n){const e=S.useRef(null),t=S.useRef(!1),r=S.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(Fi((s.clientX-a.left)/a.width,0,1),Fi((s.clientY-a.top)/a.height,0,1))},[n]);return S.useEffect(()=>{const s=a=>t.current&&r(a),i=()=>{t.current=!1};return window.addEventListener("pointermove",s),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[r]),{ref:e,onPointerDown:s=>{t.current=!0,r(s)}}}function Cx({color:n,onChange:e,presets:t=mx,showPresets:r=!0,presetGroups:o,showThemeColors:s=!0,showCollaboratorColors:i=!1,showInput:a=!0,width:l=232,"aria-label":c="Colour picker"}){const[u,f]=S.useState(()=>Ma(ts(n))),[d,g]=S.useState(()=>lr(ts(n))),h=S.useRef(!1);S.useEffect(()=>{if(h.current){h.current=!1;return}const L=ts(n);f(Ma(L)),g(lr(L))},[n]);const _=S.useMemo(()=>ti(u),[u]),m=S.useMemo(()=>lr(_),[_]),b=S.useCallback(L=>{h.current=!0,f(L);const A=lr(ti(L));g(A),e?.(A)},[e]),w=Ud(S.useCallback((L,A)=>b({...u,s:L*100,v:(1-A)*100}),[b,u])),C=Ud(S.useCallback(L=>b({...u,h:L*360}),[b,u])),{theme:v,colorMode:k}=Gb(),I=Xb(),E=k==="auto"?I:k,N=S.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(bx(v,E)),i&&L.push(yx(v,E)),L.concat(o??[])},[v,o,t,E,i,r,s]),O=S.useId(),M=L=>{if(g(L),Bd(L)){const A=Ma(ts(L));h.current=!0,f(A),e?.(lr(ts(L)))}},R=(L,A)=>{const B=L.shiftKey?10:1,j=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!j&&!U)return;L.preventDefault();const z=U?B:-B,K=A==="h"?360:100;b({...u,[A]:Fi(u[A]+z,0,K)})},$={position:"absolute",width:14,height:14,borderRadius:"50%",border:"2px solid #ffffff",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.35)",transform:"translate(-50%, -50%)",pointerEvents:"none"};return x.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[x.jsx(Y,{ref:w.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:w.onPointerDown,onKeyDown:L=>R(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:wx,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:lr(ti({h:u.h,s:100,v:100})),backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",backgroundOrigin:"border-box","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:x.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),x.jsx(Y,{ref:C.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:C.onPointerDown,onKeyDown:L=>R(L,"h"),sx:{position:"relative",height:xx,borderRadius:"var(--theme-radius-control)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"ew-resize",touchAction:"none",backgroundImage:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:x.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:lr(ti({h:u.h,s:100,v:100}))}})}),a?x.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[x.jsx(Y,{"aria-hidden":"true",sx:{width:28,height:28,flex:"0 0 auto",borderRadius:"var(--borderRadius-medium)",border:"1px solid",borderColor:"var(--borderColor-default)",backgroundColor:m}}),x.jsx(vn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>g(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:Bd(d)?void 0:"error"})]}):null,N.map(L=>x.jsxs(Y,{children:[x.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),x.jsx(Y,{role:"group","aria-labelledby":`${O}-${L.label}`,sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22px, 1fr))",gap:1},children:L.colors.map((A,B)=>{const j=A.toLowerCase()===m.toLowerCase();return x.jsx(Y,{as:"button",type:"button","aria-label":A,"aria-pressed":j,onClick:()=>M(A),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:A,border:"1px solid",borderColor:j?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:j?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${A}-${B}`)})})]},L.label))]})}const Sx=n=>{const{closeButtonRef:e,content:t,direction:r,headingRef:o,isOpen:s,openButtonRef:i,setIsOpen:a,width:l,zIndex:c}=n,{theme:u,colorMode:f}=Qb(),[d,g]=S.useState(r),[h,_]=S.useState(0);S.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),b=C=>{C.target instanceof HTMLElement&&C.target.closest('[role="dialog"]')||m()},w=x.jsx(ey,{theme:u,colorMode:f,children:x.jsxs(co,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[x.jsx(co,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:x.jsx(Ft,{variant:"invisible",ref:e,onClick:m,icon:Rp,"aria-label":"Close"})}),t]})});return e&&i?x.jsx(x.Fragment,{children:s?d==="left"?x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:w})}):x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:w})}):x.jsx(x.Fragment,{})}):x.jsx(x.Fragment,{})},vx=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>x.jsx(Sx,{width:n,direction:e,zIndex:t,...r});function kx(n,e,t,r=10,o=5){if(n===null){e.style.opacity="0",e.style.transform="translateY(-4px)",e.style.top="-10000px",e.style.left="-10000px";return}const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();let a=n.top-i.top-s.height-r,l=n.left-i.left-o;a<0&&(a=n.bottom-i.top+r),l+s.width>i.width&&(l=i.width-s.width-o),l<o&&(l=o),e.style.opacity="1",e.style.transform="translateY(0)",e.style.top=`${a}px`,e.style.left=`${l}px`}function Tx({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=S.useRef(null),c=S.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=S.useCallback(()=>{const g=l.current;if(!g||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){g.style.opacity="0",g.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();kx(m,g,t)},[t,r]);if(S.useEffect(()=>{if(!r)return;const g=()=>u();window.addEventListener("resize",g),window.addEventListener("scroll",g,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",g),g(),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),h&&h.removeEventListener("scroll",g)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=x.jsx(co,{ref:l,className:o,role:"toolbar","aria-label":i,sx:{display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"var(--overlay-bgColor, var(--bgColor-default))",border:"1px solid",borderColor:"var(--borderColor-muted, transparent)",borderRadius:2,boxShadow:"shadow.large",position:"absolute",zIndex:10,top:"-10000px",left:"-10000px",opacity:0,transition:"opacity 0.15s ease, transform 0.15s ease",transform:"translateY(-4px)"},children:x.jsx(lx,{items:c,disabled:s,size:"small"})});return St.createPortal(d,f)}var $a=function(){return Zw.Date.now()},Ix="Expected a function",Ex=Math.max,Nx=Math.min;function Lx(n,e,t){var r,o,s,i,a,l,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(Ix);e=Fd(e)||0,Qw(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Ex(Fd(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function g(I){var E=r,N=o;return r=o=void 0,c=I,i=n.apply(N,E),i}function h(I){return c=I,a=setTimeout(b,e),u?g(I):i}function _(I){var E=I-l,N=I-c,O=e-E;return f?Nx(O,s-N):O}function m(I){var E=I-l,N=I-c;return l===void 0||E>=e||E<0||f&&N>=s}function b(){var I=$a();if(m(I))return w(I);a=setTimeout(b,_(I))}function w(I){return a=void 0,d&&r?g(I):(r=o=void 0,i)}function C(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:w($a())}function k(){var I=$a(),E=m(I);if(r=arguments,o=this,l=I,E){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(b,e),g(l)}return a===void 0&&(a=setTimeout(b,e)),i}return k.cancel=C,k.flush=v,k}const Mh=[];let Ts=class extends Oe{__ids;$config(){return this.config("mark",{extends:Oe})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=Mh,t){super(t),this.__ids=e}createDOM(e){const t=Je().createElement("mark");return Ie(t,e.theme.mark),this.__ids.length>1&&Ie(t,e.theme.markOverlap),t}updateDOM(e,t,r){const o=e.__ids,s=this.__ids,i=o.length,a=s.length,l=r.theme.markOverlap;return i!==a&&(i===1?a===2&&Ie(t,l):a===1&&$t(t,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(r===-1)return t;const o=Array.from(t.__ids);return o.splice(r,1),t.setIDs(o)}insertNewAfter(e,t=!0){const r=Hc(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!F(t)||r==="html")return!1;const o=t.anchor,s=t.focus,i=o.getNode(),a=s.getNode(),l=t.isBackward()?o.offset-s.offset:s.offset-o.offset;return this.isParentOf(i)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return e!=="clone"}};function Hc(n=Mh){return Ot(new Ts(n))}function Ro(n){return n instanceof Ts}function Ox(n){const e=n.getChildren();let t=null;for(let r=0;r<e.length;r++){const o=e[r];t===null?n.insertBefore(o):t.insertAfter(o),t=o}n.remove()}function Rx(n,e,t,r){const o=kr(),[s,i]=n.isBackward()?[n.focus,n.anchor]:[n.anchor,n.focus];let a,l;o.anchor.set(s.key,s.offset,s.type),o.focus.set(i.key,i.offset,i.type);const c=o.extract();for(const u of c){if(q(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(Ro(u))continue;(q(u)||It(u))&&u.isInline()&&(f=u)}if(f!==null){if(f&&f.is(a))continue;const d=f.getParent();d!=null&&d.is(a)||(l=void 0),a=d,l===void 0&&(l=Hc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}q(l)&&(e?l.selectStart():l.selectEnd())}function Ax(n,e){let t=n;for(;t!==null;){if(Ro(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(Ro(r))return r.getIDs()}t=t.getParent()}return null}const Mx=pe({name:"@lexical/mark",nodes:()=>[Ts]});class Ao extends Bt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new Ao(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new Ao(e.id,e.quote,e.comments)}exportJSON(){return{type:"comment-thread",version:1,id:this.__id,quote:this.__quote,comments:this.__comments}}constructor(e,t,r,o){super(o),this.__id=e,this.__quote=t,this.__comments=r}createDOM(e){const t=document.createElement("div");return t.style.display="none",t}updateDOM(){return!1}isInline(){return!1}getId(){return this.__id}getQuote(){return this.__quote}getComments(){return this.__comments}addComment(e){const t=this.getWritable();t.__comments=[...t.__comments,e]}deleteComment(e){const t=this.getWritable();t.__comments=t.__comments.map(r=>r.id===e?{...r,deleted:!0,content:"[Deleted Comment]"}:r)}decorate(e){return x.jsx(x.Fragment,{})}}function $x(n,e,t){return new Ao(n,e,t)}function ni(n){return n instanceof Ao}const wo=n=>n.name||n.handle||n.uid,Jc=n=>n.name||n.handle||n.uid||"Anonymous",qc=n=>({kind:"anonymous",name:n||"Anonymous"}),Dx=n=>n.authorPrincipal??qc(n.author);function $h(n,e){const t=[];for(const r of e)n.includes(`@${wo(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Dh(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ph(n,e,t,r,o,s){const i=typeof e=="string"?qc(e):e;return{author:Jc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Dh():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Px(n,e,t){return{comments:e,id:t===void 0?Dh():t,quote:n,type:"thread"}}function jx(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Fx(n){const e=n._changeListeners;for(const t of e)t()}class Bx{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Fx(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(ni(r)){const o=r;e.push({type:"thread",id:o.getId(),quote:o.getQuote(),comments:o.getComments()})}})}),e}addComment(e,t,r){this._editor.update(()=>{if(t!==void 0&&e.type==="comment")se().getChildren().forEach(s=>{if(ni(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=$x(e.id,e.quote,e.comments);se().append(o)}})}deleteComment(e,t){const r=this.deleteCommentOrThread(e,t);r!==null&&this.addComment(r.markedComment,t,r.index)}deleteThread(e){this.deleteCommentOrThread(e)}deleteCommentOrThread(e,t){let r=null;return this._editor.update(()=>{t!==void 0&&e.type==="comment"?se().getChildren().forEach(s=>{if(ni(s)){const i=s;i.getId()===t.id&&(r=i.getComments().findIndex(l=>l.id===e.id),i.deleteComment(e.id))}}):se().getChildren().forEach(s=>{ni(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:jx(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function Ux(n){const[e,t]=S.useState(n.getComments());return S.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const xr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>x.jsx(ft,{disabled:o,onClick:r,title:i,"aria-label":i,size:s?"small":"medium",variant:"default",className:t,...n&&{"data-test-id":n},children:e}),zx=({className:n,style:e})=>x.jsx(Ap,{className:n||"ContentEditable__root",style:e});function IM({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return x.jsxs(Kw,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?x.jsx(Ww,{}):null,x.jsxs(co,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[x.jsx(Zs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),x.jsx(Zs,{size:"bodyMedium",lines:3}),x.jsx(Zs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),x.jsx(ty,{width:"100%",height:"120px"}),x.jsx(Zs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Kx({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?x.jsx(Wx,{...s,inputRef:r}):x.jsx(Hx,{...s,inputRef:r})}function Wx({equation:n,onChange:e,inputRef:t}){return x.jsxs("span",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),x.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Hx({equation:n,onChange:e,inputRef:t}){return x.jsxs("div",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
1
+ import{r as S,ar as Xb,as as Gb,j as x,bi as Y,co as vn,T as Le,d2 as Zb,bj as bd,gr as Qb,nZ as ey,B as co,I as Ft,e4 as Rp,n_ as kl,bd as St,aq as pe,n$ as Oe,o0 as Je,o1 as Ie,o2 as $t,l5 as F,o3 as Ot,o4 as kr,kM as q,kR as oe,kS as It,o5 as Bt,aD as se,c as ft,aw as Ap,d4 as Zs,d1 as ty,eQ as Mt,_ as me,jC as Mp,eS as ny,D as $p,o6 as ry,o7 as _o,o8 as Tc,o9 as zo,kU as bt,oa as Kn,kL as vt,aE as ne,ob as js,bS as de,oc as oy,l7 as zr,l4 as D,bV as ee,od as ln,oe as Dp,of as sy,og as Fs,li as cn,ll as ke,kT as ue,oh as Ye,oi as Xe,oj as Pp,ok as yd,ol as gt,om as iy,l9 as Kr,l3 as wn,on as Tl,l8 as Dt,oo as un,op as Tr,oq as pt,or as Vt,os as Ir,ot as xs,ou as jp,ov as Ri,ow as ay,ox as mi,oy as Jn,oz as ly,oA as cy,bW as Q,oB as uy,kI as $e,ez as Fp,n as br,lk as Ae,oC as dy,oD as fy,oE as gy,oF as zt,oG as Eo,oH as tr,oI as nr,oJ as Cs,oK as xn,oL as Bs,oM as rr,oN as mn,oO as Us,ld as ve,la as re,oP as V,oQ as Bp,oR as Ic,oS as uo,bU as No,oT as py,oU as fo,oV as wd,oW as Up,oX as zp,oY as Il,oZ as hy,o_ as Kp,o$ as Ec,p0 as _y,p1 as my,p2 as Nc,p3 as El,p4 as Wp,p5 as by,p6 as Hp,p7 as yy,p8 as Lc,p9 as Ss,l1 as Ee,pa as wy,lf as Nn,pb as xd,pc as xy,pd as Cy,pe as Cd,pf as Nl,l2 as Lo,pg as Oc,ph as bi,pi as sa,pj as Jp,pk as Rc,pl as ia,pm as Qs,pn as Sd,po as vd,pp as zs,pq as kd,pr as Bn,ps as Sy,pt as vy,pu as Ge,pv as ky,pw as Ty,px as qp,py as Vp,pz as Yp,bT as Ks,pA as Ac,pB as Iy,pC as he,pD as Xp,pE as vs,pF as Ra,pG as Gp,pH as Mc,pI as Ll,pJ as Ey,pK as Er,pL as wt,le as or,pM as aa,pN as Ny,pO as $c,pP as Zp,pQ as Dc,pR as ps,pS as Td,pT as it,kJ as ht,pU as Id,pV as Jt,pW as la,pX as Qp,pY as eh,pZ as th,p_ as Wn,p$ as Ly,q0 as Oy,q1 as Ai,q2 as Ry,q3 as Ay,q4 as My,q5 as Ol,q6 as hr,q7 as nh,q8 as $y,q9 as Rl,qa as Mi,qb as rh,lb as Ht,qc as Oo,l6 as qe,qd as oh,qe as Dy,qf as Py,kH as jy,qg as mo,qh as sr,qi as sh,qj as Fy,qk as By,ql as Pc,qm as ih,qn as Uy,qo as Ed,qp as zy,qq as Nd,qr as Ky,qs as Wy,qt as jc,qu as Hy,qv as Ld,k$ as Jy,k_ as qy,kZ as Vy,qw as Od,l0 as Yy,qx as Rd,qy as ah,K as fe,lg as Xy,qz as Gy,qA as Zy,qB as Qy,qC as Ad,qD as ew,qE as tw,qF as Md,qG as $d,qH as qn,qI as nw,qJ as rw,qK as ow,qL as sw,qM as Fc,qN as iw,qO as aw,jf as Al,ee as ks,lc as bo,qP as lh,qQ as $i,kK as ch,kP as Bc,kO as Uc,kN as uh,kQ as dh,qR as fh,qS as Ml,qT as Dd,qU as lw,qV as $l,qW as ca,qX as gh,qY as ph,qZ as cw,q_ as hh,q$ as _h,r0 as $n,r1 as uw,mg as dw,mm as Pd,mn as Dl,mp as fw,mq as gw,r2 as mh,r3 as bh,r4 as yh,r5 as wh,r6 as jd,C as xh,f as pw,r7 as hw,r8 as _w,H as mw,r9 as bw,ra as yw,av as ww,ax as xw,k as Ch,rb as Cw,aF as Sh,rc as Sw,aB as vw,rd as kw,re as Tw,jI as Lt,jQ as Ke,jO as yr,jL as Qe,jP as wr,jN as Zt,jS as Iw,e7 as Ew,ek as Aa,i as Nw,rf as yi,rg as Un,el as vh,rh as Lw,bf as zc,bX as Ow,ri as Kc,eI as Rw,rj as Aw,rk as Mw,rl as $w,rm as Dw,rn as Pw,ro as kh,rp as we,d6 as yo,b6 as Te,rq as Th,m as Di,rr as jw,rs as Fw,rt as ei,gw as Bw,ru as Uw,rv as Ko}from"../datalayer-app-main.js";import{d as zw,b as Kw,E as Ww,u as Hw,c as Jw,e as qw,f as Vw}from"./NotebookSkeleton-CI7ovjNW.js";import{p as is,e as Yw,s as Xw,u as Gw}from"./url-DuKx0yk0.js";import{r as Zw,a as Qw}from"./isSymbol-BLtK9CV6.js";import{t as Fd}from"./toNumber-B1wj8-wx.js";import{V as Ws,P as ex,C as Pi,D as Wc,T as Ih,H as tx,L as Eh,F as hs,Q as Nh,a as ji,M as nx,b as rx,B as Lh,I as Oh,S as Rh,R as ox,c as sx,d as ix}from"./VideoIcon-BjP_LDa4.js";import{L as Ah}from"./LinkIcon-DUI0jw25.js";import{A as ax}from"./Avatar-9MpXENSs.js";import{a as lx,T as cx}from"./Toolbar-CGQDY041.js";import{A as ux,a as dx}from"./ArrowUpIcon-BUCpIXDR.js";import{S as fx}from"./SortDescIcon-CS4EzHeS.js";import{P as gx}from"./PaintbrushIcon-CLU8RilX.js";import{P as Pl,p as px}from"./PrismCss-CcU1ChRk.js";import{j as jl,O as hx,C as _x}from"./Output-BWClePP-.js";import{d as ge,l as go}from"./LexicalToolRegistry-8wJyLumb.js";const Fi=(n,e,t)=>Math.min(t,Math.max(e,n));function ts(n){const e=n.trim(),t=/^rgba?\(\s*(\d+)[,\s]+(\d+)[,\s]+(\d+)/i.exec(e);if(t){const[,o,s,i]=t;return{r:Number(o),g:Number(s),b:Number(i)}}let r=e.replace(/^#/,"");return r.length===3&&(r=r.split("").map(o=>o+o).join("")),/^[0-9a-f]{6}$/i.test(r)?{r:parseInt(r.slice(0,2),16),g:parseInt(r.slice(2,4),16),b:parseInt(r.slice(4,6),16)}:{r:0,g:0,b:0}}function lr({r:n,g:e,b:t}){const r=o=>Fi(Math.round(o),0,255).toString(16).padStart(2,"0");return`#${r(n)}${r(e)}${r(t)}`}function Ma({r:n,g:e,b:t}){const r=n/255,o=e/255,s=t/255,i=Math.max(r,o,s),a=Math.min(r,o,s),l=i-a;let c=0;return l!==0&&(i===r?c=60*((o-s)/l%6):i===o?c=60*((s-r)/l+2):c=60*((r-o)/l+4)),c<0&&(c+=360),{h:c,s:i===0?0:l/i*100,v:i*100}}function ti({h:n,s:e,v:t}){const r=e/100,o=t/100,s=o*r,i=s*(1-Math.abs(n/60%2-1)),a=o-s,l=Math.floor((n%360+360)%360/60),[c,u,f]=[[s,i,0],[i,s,0],[0,s,i],[0,i,s],[i,0,s],[s,0,i]][l];return{r:Math.round((c+a)*255),g:Math.round((u+a)*255),b:Math.round((f+a)*255)}}function Bd(n){const e=n.trim();return/^#([0-9a-f]{3}|[0-9a-f]{6})$/i.test(e)||/^rgba?\(\s*\d+[,\s]+\d+[,\s]+\d+/i.test(e)}const mx=["#cf222e","#bc4c00","#9a6700","#1a7f37","#0969da","#8250df","#bf3989","#24292f","#57606a","#8c959f","#d0d7de","#ffffff"];function bx(n="datalayer",e="light"){const t=Zb(n,e),r=bd[n]??bd.datalayer,s=(e==="auto"?typeof window<"u"&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light":e)==="dark"?r.themeStyles.dark:r.themeStyles.light,i=a=>s[a];return{label:r.label,colors:[i("--bgColor-default"),i("--bgColor-muted"),i("--fgColor-default"),i("--fgColor-muted"),i("--fgColor-accent"),i("--fgColor-success"),i("--fgColor-attention"),i("--fgColor-danger"),t.glow,t.pop,t.spark,t.blaze,t.surge,t.flame,t.gold].filter(Boolean)}}function yx(n="datalayer",e="dark"){return{label:"Collaborators",colors:zw(n,e)}}const wx=150,xx=12;function Ud(n){const e=S.useRef(null),t=S.useRef(!1),r=S.useCallback(s=>{const i=e.current;if(!i)return;const a=i.getBoundingClientRect();n(Fi((s.clientX-a.left)/a.width,0,1),Fi((s.clientY-a.top)/a.height,0,1))},[n]);return S.useEffect(()=>{const s=a=>t.current&&r(a),i=()=>{t.current=!1};return window.addEventListener("pointermove",s),window.addEventListener("pointerup",i),window.addEventListener("pointercancel",i),()=>{window.removeEventListener("pointermove",s),window.removeEventListener("pointerup",i),window.removeEventListener("pointercancel",i)}},[r]),{ref:e,onPointerDown:s=>{t.current=!0,r(s)}}}function Cx({color:n,onChange:e,presets:t=mx,showPresets:r=!0,presetGroups:o,showThemeColors:s=!0,showCollaboratorColors:i=!1,showInput:a=!0,width:l=232,"aria-label":c="Colour picker"}){const[u,f]=S.useState(()=>Ma(ts(n))),[d,g]=S.useState(()=>lr(ts(n))),h=S.useRef(!1);S.useEffect(()=>{if(h.current){h.current=!1;return}const L=ts(n);f(Ma(L)),g(lr(L))},[n]);const _=S.useMemo(()=>ti(u),[u]),m=S.useMemo(()=>lr(_),[_]),b=S.useCallback(L=>{h.current=!0,f(L);const A=lr(ti(L));g(A),e?.(A)},[e]),w=Ud(S.useCallback((L,A)=>b({...u,s:L*100,v:(1-A)*100}),[b,u])),C=Ud(S.useCallback(L=>b({...u,h:L*360}),[b,u])),{theme:v,colorMode:k}=Xb(),I=Gb(),E=k==="auto"?I:k,N=S.useMemo(()=>{const L=[];return r&&t.length>0&&L.push({label:"Presets",colors:t}),s&&L.push(bx(v,E)),i&&L.push(yx(v,E)),L.concat(o??[])},[v,o,t,E,i,r,s]),O=S.useId(),M=L=>{if(g(L),Bd(L)){const A=Ma(ts(L));h.current=!0,f(A),e?.(lr(ts(L)))}},R=(L,A)=>{const B=L.shiftKey?10:1,j=L.key==="ArrowLeft"||L.key==="ArrowDown",U=L.key==="ArrowRight"||L.key==="ArrowUp";if(!j&&!U)return;L.preventDefault();const z=U?B:-B,K=A==="h"?360:100;b({...u,[A]:Fi(u[A]+z,0,K)})},$={position:"absolute",width:14,height:14,borderRadius:"50%",border:"2px solid #ffffff",boxShadow:"0 0 0 1px rgba(0, 0, 0, 0.35)",transform:"translate(-50%, -50%)",pointerEvents:"none"};return x.jsxs(Y,{role:"group","aria-label":c,sx:{display:"grid",gap:2,width:l,minWidth:0},children:[x.jsx(Y,{ref:w.ref,role:"slider",tabIndex:0,"aria-label":"Saturation and brightness","aria-valuetext":`saturation ${Math.round(u.s)}%, brightness ${Math.round(u.v)}%`,onPointerDown:w.onPointerDown,onKeyDown:L=>R(L,L.key==="ArrowUp"||L.key==="ArrowDown"?"v":"s"),sx:{position:"relative",height:wx,borderRadius:"var(--theme-radius-card)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"crosshair",touchAction:"none",backgroundColor:lr(ti({h:u.h,s:100,v:100})),backgroundImage:"linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent)",backgroundOrigin:"border-box","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:x.jsx(Y,{sx:{...$,left:`${u.s}%`,top:`${100-u.v}%`,backgroundColor:m}})}),x.jsx(Y,{ref:C.ref,role:"slider",tabIndex:0,"aria-label":"Hue","aria-valuemin":0,"aria-valuemax":360,"aria-valuenow":Math.round(u.h),onPointerDown:C.onPointerDown,onKeyDown:L=>R(L,"h"),sx:{position:"relative",height:xx,borderRadius:"var(--theme-radius-control)",border:"1px solid",borderColor:"var(--borderColor-default)",cursor:"ew-resize",touchAction:"none",backgroundImage:"linear-gradient(to right, #f00 0%, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00 100%)","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}},children:x.jsx(Y,{sx:{...$,left:`${u.h/360*100}%`,top:"50%",backgroundColor:lr(ti({h:u.h,s:100,v:100}))}})}),a?x.jsxs(Y,{sx:{display:"flex",gap:2,alignItems:"center"},children:[x.jsx(Y,{"aria-hidden":"true",sx:{width:28,height:28,flex:"0 0 auto",borderRadius:"var(--borderRadius-medium)",border:"1px solid",borderColor:"var(--borderColor-default)",backgroundColor:m}}),x.jsx(vn,{"aria-label":"Colour, as hex",value:d,onChange:L=>M(L.target.value),onBlur:()=>g(m),size:"small",sx:{flex:"1 1 auto",fontFamily:"mono"},validationStatus:Bd(d)?void 0:"error"})]}):null,N.map(L=>x.jsxs(Y,{children:[x.jsx(Le,{id:`${O}-${L.label}`,sx:{fontSize:0,color:"var(--fgColor-muted)",display:"block",mb:1},children:L.label}),x.jsx(Y,{role:"group","aria-labelledby":`${O}-${L.label}`,sx:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(22px, 1fr))",gap:1},children:L.colors.map((A,B)=>{const j=A.toLowerCase()===m.toLowerCase();return x.jsx(Y,{as:"button",type:"button","aria-label":A,"aria-pressed":j,onClick:()=>M(A),sx:{height:22,borderRadius:"var(--theme-radius-control)",cursor:"pointer",backgroundColor:A,border:"1px solid",borderColor:j?"var(--borderColor-accent-emphasis)":"var(--borderColor-default)",boxShadow:j?"inset 0 0 0 2px var(--bgColor-default)":"none","&:focus-visible":{outline:"2px solid var(--borderColor-accent-emphasis)",outlineOffset:"1px"}}},`${A}-${B}`)})})]},L.label))]})}const Sx=n=>{const{closeButtonRef:e,content:t,direction:r,headingRef:o,isOpen:s,openButtonRef:i,setIsOpen:a,width:l,zIndex:c}=n,{theme:u,colorMode:f}=Qb(),[d,g]=S.useState(r),[h,_]=S.useState(0);S.useEffect(()=>{_(o?.current?.getBoundingClientRect().bottom??0)},[o]);const m=()=>a(!1),b=C=>{C.target instanceof HTMLElement&&C.target.closest('[role="dialog"]')||m()},w=x.jsx(ey,{theme:u,colorMode:f,children:x.jsxs(co,{sx:{height:`calc(100vh - ${h}px - 8px)`,width:l,display:"flex",flexDirection:"column",alignItems:"center",padding:"4px"},children:[x.jsx(co,{sx:{display:"flex",justifyContent:"right",width:"100%"},children:x.jsx(Ft,{variant:"invisible",ref:e,onClick:m,icon:Rp,"aria-label":"Close"})}),t]})});return e&&i?x.jsx(x.Fragment,{children:s?d==="left"?x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-right",left:0,position:"fixed",top:h,children:w})}):x.jsx(co,{sx:{zIndex:c},children:x.jsx(kl,{initialFocusRef:e,returnFocusRef:i,ignoreClickRefs:[i],onEscape:m,onClickOutside:b,width:"auto",anchorSide:"inside-left",right:0,position:"fixed",top:h,children:w})}):x.jsx(x.Fragment,{})}):x.jsx(x.Fragment,{})},vx=({width:n="500px",direction:e="left",zIndex:t=100,...r})=>x.jsx(Sx,{width:n,direction:e,zIndex:t,...r});function kx(n,e,t,r=10,o=5){if(n===null){e.style.opacity="0",e.style.transform="translateY(-4px)",e.style.top="-10000px",e.style.left="-10000px";return}const s=e.getBoundingClientRect(),i=t.getBoundingClientRect();let a=n.top-i.top-s.height-r,l=n.left-i.left-o;a<0&&(a=n.bottom-i.top+r),l+s.width>i.width&&(l=i.width-s.width-o),l<o&&(l=o),e.style.opacity="1",e.style.transform="translateY(0)",e.style.top=`${a}px`,e.style.left=`${l}px`}function Tx({items:n,extraItems:e,anchorElement:t,isVisible:r,className:o,disabled:s,ariaLabel:i="Floating toolbar",portalContainer:a}){const l=S.useRef(null),c=S.useMemo(()=>e?.length?[...n,...e]:n,[n,e]),u=S.useCallback(()=>{const g=l.current;if(!g||!t)return;const h=window.getSelection();if(!h||h.isCollapsed||!r){g.style.opacity="0",g.style.transform="translateY(-4px)";return}const m=h.getRangeAt(0).getBoundingClientRect();kx(m,g,t)},[t,r]);if(S.useEffect(()=>{if(!r)return;const g=()=>u();window.addEventListener("resize",g),window.addEventListener("scroll",g,!0);const h=t?.parentElement;return h&&h.addEventListener("scroll",g),g(),()=>{window.removeEventListener("resize",g),window.removeEventListener("scroll",g,!0),h&&h.removeEventListener("scroll",g)}},[r,u,t]),!r||c.length===0)return null;const f=a||t||document.body,d=x.jsx(co,{ref:l,className:o,role:"toolbar","aria-label":i,sx:{display:"flex",alignItems:"center",gap:"2px",px:1,py:"4px",bg:"var(--overlay-bgColor, var(--bgColor-default))",border:"1px solid",borderColor:"var(--borderColor-muted, transparent)",borderRadius:2,boxShadow:"shadow.large",position:"absolute",zIndex:10,top:"-10000px",left:"-10000px",opacity:0,transition:"opacity 0.15s ease, transform 0.15s ease",transform:"translateY(-4px)"},children:x.jsx(lx,{items:c,disabled:s,size:"small"})});return St.createPortal(d,f)}var $a=function(){return Zw.Date.now()},Ix="Expected a function",Ex=Math.max,Nx=Math.min;function Lx(n,e,t){var r,o,s,i,a,l,c=0,u=!1,f=!1,d=!0;if(typeof n!="function")throw new TypeError(Ix);e=Fd(e)||0,Qw(t)&&(u=!!t.leading,f="maxWait"in t,s=f?Ex(Fd(t.maxWait)||0,e):s,d="trailing"in t?!!t.trailing:d);function g(I){var E=r,N=o;return r=o=void 0,c=I,i=n.apply(N,E),i}function h(I){return c=I,a=setTimeout(b,e),u?g(I):i}function _(I){var E=I-l,N=I-c,O=e-E;return f?Nx(O,s-N):O}function m(I){var E=I-l,N=I-c;return l===void 0||E>=e||E<0||f&&N>=s}function b(){var I=$a();if(m(I))return w(I);a=setTimeout(b,_(I))}function w(I){return a=void 0,d&&r?g(I):(r=o=void 0,i)}function C(){a!==void 0&&clearTimeout(a),c=0,r=l=o=a=void 0}function v(){return a===void 0?i:w($a())}function k(){var I=$a(),E=m(I);if(r=arguments,o=this,l=I,E){if(a===void 0)return h(l);if(f)return clearTimeout(a),a=setTimeout(b,e),g(l)}return a===void 0&&(a=setTimeout(b,e)),i}return k.cancel=C,k.flush=v,k}const Mh=[];let Ts=class extends Oe{__ids;$config(){return this.config("mark",{extends:Oe})}afterCloneFrom(e){super.afterCloneFrom(e),this.__ids=e.__ids}updateFromJSON(e){return super.updateFromJSON(e).setIDs(e.ids)}exportJSON(){return{...super.exportJSON(),ids:this.getIDs()}}constructor(e=Mh,t){super(t),this.__ids=e}createDOM(e){const t=Je().createElement("mark");return Ie(t,e.theme.mark),this.__ids.length>1&&Ie(t,e.theme.markOverlap),t}updateDOM(e,t,r){const o=e.__ids,s=this.__ids,i=o.length,a=s.length,l=r.theme.markOverlap;return i!==a&&(i===1?a===2&&Ie(t,l):a===1&&$t(t,l)),!1}hasID(e){return this.getIDs().includes(e)}getIDs(){return Array.from(this.getLatest().__ids)}setIDs(e){const t=this.getWritable();return t.__ids=e,t}addID(e){const t=this.getWritable();return t.__ids.includes(e)?t:t.setIDs([...t.__ids,e])}deleteID(e){const t=this.getWritable(),r=t.__ids.indexOf(e);if(r===-1)return t;const o=Array.from(t.__ids);return o.splice(r,1),t.setIDs(o)}insertNewAfter(e,t=!0){const r=Hc(this.__ids);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!F(t)||r==="html")return!1;const o=t.anchor,s=t.focus,i=o.getNode(),a=s.getNode(),l=t.isBackward()?o.offset-s.offset:s.offset-o.offset;return this.isParentOf(i)&&this.isParentOf(a)&&this.getTextContent().length===l}excludeFromCopy(e){return e!=="clone"}};function Hc(n=Mh){return Ot(new Ts(n))}function Ro(n){return n instanceof Ts}function Ox(n){const e=n.getChildren();let t=null;for(let r=0;r<e.length;r++){const o=e[r];t===null?n.insertBefore(o):t.insertAfter(o),t=o}n.remove()}function Rx(n,e,t,r){const o=kr(),[s,i]=n.isBackward()?[n.focus,n.anchor]:[n.anchor,n.focus];let a,l;o.anchor.set(s.key,s.offset,s.type),o.focus.set(i.key,i.offset,i.type);const c=o.extract();for(const u of c){if(q(l)&&l.isParentOf(u))continue;let f=null;if(oe(u))f=u;else{if(Ro(u))continue;(q(u)||It(u))&&u.isInline()&&(f=u)}if(f!==null){if(f&&f.is(a))continue;const d=f.getParent();d!=null&&d.is(a)||(l=void 0),a=d,l===void 0&&(l=Hc([t]),f.insertBefore(l)),l.append(f)}else a=void 0,l=void 0}q(l)&&(e?l.selectStart():l.selectEnd())}function Ax(n,e){let t=n;for(;t!==null;){if(Ro(t))return t.getIDs();if(oe(t)&&e===t.getTextContentSize()){const r=t.getNextSibling();if(Ro(r))return r.getIDs()}t=t.getParent()}return null}const Mx=pe({name:"@lexical/mark",nodes:()=>[Ts]});class Ao extends Bt{__id;__quote;__comments;static getType(){return"comment-thread"}static clone(e){return new Ao(e.__id,e.__quote,e.__comments,e.__key)}static importJSON(e){return new Ao(e.id,e.quote,e.comments)}exportJSON(){return{type:"comment-thread",version:1,id:this.__id,quote:this.__quote,comments:this.__comments}}constructor(e,t,r,o){super(o),this.__id=e,this.__quote=t,this.__comments=r}createDOM(e){const t=document.createElement("div");return t.style.display="none",t}updateDOM(){return!1}isInline(){return!1}getId(){return this.__id}getQuote(){return this.__quote}getComments(){return this.__comments}addComment(e){const t=this.getWritable();t.__comments=[...t.__comments,e]}deleteComment(e){const t=this.getWritable();t.__comments=t.__comments.map(r=>r.id===e?{...r,deleted:!0,content:"[Deleted Comment]"}:r)}decorate(e){return x.jsx(x.Fragment,{})}}function $x(n,e,t){return new Ao(n,e,t)}function ni(n){return n instanceof Ao}const wo=n=>n.name||n.handle||n.uid,Jc=n=>n.name||n.handle||n.uid||"Anonymous",qc=n=>({kind:"anonymous",name:n||"Anonymous"}),Dx=n=>n.authorPrincipal??qc(n.author);function $h(n,e){const t=[];for(const r of e)n.includes(`@${wo(r)}`)&&!t.includes(r.uid)&&t.push(r.uid);return t}function Dh(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ph(n,e,t,r,o,s){const i=typeof e=="string"?qc(e):e;return{author:Jc(i),authorPrincipal:i,content:n,deleted:o===void 0?!1:o,id:t===void 0?Dh():t,...s&&s.length>0?{mentions:s}:{},timeStamp:r===void 0?Date.now():r,type:"comment"}}function Px(n,e,t){return{comments:e,id:t===void 0?Dh():t,quote:n,type:"thread"}}function jx(n){return{author:n.author,...n.authorPrincipal?{authorPrincipal:n.authorPrincipal}:{},content:"[Deleted Comment]",deleted:!0,id:n.id,timeStamp:n.timeStamp,type:"comment"}}function Fx(n){const e=n._changeListeners;for(const t of e)t()}class Bx{_editor;_changeListeners;constructor(e){this._editor=e,this._changeListeners=new Set,this._editor.registerUpdateListener(()=>{Fx(this)})}getComments(){const e=[];return this._editor.getEditorState().read(()=>{se().getChildren().forEach(r=>{if(ni(r)){const o=r;e.push({type:"thread",id:o.getId(),quote:o.getQuote(),comments:o.getComments()})}})}),e}addComment(e,t,r){this._editor.update(()=>{if(t!==void 0&&e.type==="comment")se().getChildren().forEach(s=>{if(ni(s)){const i=s;i.getId()===t.id&&i.addComment(e)}});else if(e.type==="thread"){const o=$x(e.id,e.quote,e.comments);se().append(o)}})}deleteComment(e,t){const r=this.deleteCommentOrThread(e,t);r!==null&&this.addComment(r.markedComment,t,r.index)}deleteThread(e){this.deleteCommentOrThread(e)}deleteCommentOrThread(e,t){let r=null;return this._editor.update(()=>{t!==void 0&&e.type==="comment"?se().getChildren().forEach(s=>{if(ni(s)){const i=s;i.getId()===t.id&&(r=i.getComments().findIndex(l=>l.id===e.id),i.deleteComment(e.id))}}):se().getChildren().forEach(s=>{ni(s)&&s.getId()===e.id&&s.remove()})}),e.type==="comment"?{index:r!==null?r:0,markedComment:jx(e)}:null}registerOnChange(e){const t=this._changeListeners;return t.add(e),()=>{t.delete(e)}}}function Ux(n){const[e,t]=S.useState(n.getComments());return S.useEffect(()=>(t(n.getComments()),n.registerOnChange(()=>{t(n.getComments())})),[n]),e}const xr=({"data-test-id":n,children:e,className:t,onClick:r,disabled:o,small:s,title:i})=>x.jsx(ft,{disabled:o,onClick:r,title:i,"aria-label":i,size:s?"small":"medium",variant:"default",className:t,...n&&{"data-test-id":n},children:e}),zx=({className:n,style:e})=>x.jsx(Ap,{className:n||"ContentEditable__root",style:e});function IM({label:n="Loading the document",header:e=!1,maxWidth:t=760}={}){return x.jsxs(Kw,{label:n,sx:{flex:1,minHeight:0,width:"100%",overflow:"hidden"},children:[e?x.jsx(Ww,{}):null,x.jsxs(co,{sx:{px:4,py:e?0:4,pb:4,display:"grid",gap:4,maxWidth:t,mx:"auto",width:"100%"},children:[x.jsx(Zs,{size:"titleLarge",lines:1,maxWidth:"22rem"}),x.jsx(Zs,{size:"bodyMedium",lines:3}),x.jsx(Zs,{size:"bodyMedium",lines:4,maxWidth:"92%"}),x.jsx(ty,{width:"100%",height:"120px"}),x.jsx(Zs,{size:"bodyMedium",lines:3,maxWidth:"88%"})]})]})}function Kx({equation:n,setEquation:e,inline:t,inputRef:r}){const s={equation:n,inputRef:r,onChange:i=>{e(i.target.value)}};return t?x.jsx(Wx,{...s,inputRef:r}):x.jsx(Hx,{...s,inputRef:r})}function Wx({equation:n,onChange:e,inputRef:t}){return x.jsxs("span",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"}),x.jsx("input",{className:"EquationEditor_inlineEditor",value:n,onChange:e,autoFocus:!0,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:"$"})]})}function Hx({equation:n,onChange:e,inputRef:t}){return x.jsxs("div",{className:"EquationEditor_inputBackground",children:[x.jsx("span",{className:"EquationEditor_dollarSign",children:`$$
2
2
  `}),x.jsx("textarea",{className:"EquationEditor_blockEditor",value:n,onChange:e,ref:t}),x.jsx("span",{className:"EquationEditor_dollarSign",children:`
3
- $$`})]})}const Jx=({accept:n,label:e,onChange:t,"data-test-id":r})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:e}),x.jsx(vn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function Da(n,e,t){return Math.min(Math.max(n,e),t)}const Re={east:1,north:8,south:2,west:4},qx=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=S.useRef(null),c=S.useRef({priority:"",value:"default"}),u=S.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=s.getRootElement(),d=o||(f!==null?f.getBoundingClientRect().width-20:100),g=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=k=>{const I=k===Re.east||k===Re.west,E=k===Re.north||k===Re.south,N=k&Re.north&&k&Re.west||k&Re.south&&k&Re.east,O=I?"ew":E?"ns":N?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${O}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${O}-resize`,"important"),c.current.value=document.body.style.getPropertyValue("-webkit-user-select"),c.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},b=()=>{f!==null&&f.style.setProperty("cursor","default"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",c.current.value,c.current.priority))},w=(k,I)=>{const E=r.current,N=l.current;if(E!==null&&N!==null){const{width:O,height:M}=E.getBoundingClientRect(),R=u.current;R.startWidth=O,R.startHeight=M,R.ratio=O/M,R.currentWidth=O,R.currentHeight=M,R.startX=k.clientX,R.startY=k.clientY,R.isResizing=!0,R.direction=I,m(I),n(),N.classList.add("image-control-wrapper--resizing"),E.style.height=`${M}px`,E.style.width=`${O}px`,document.addEventListener("pointermove",C),document.addEventListener("pointerup",v)}},C=k=>{const I=r.current,E=u.current,N=E.direction&(Re.east|Re.west),O=E.direction&(Re.south|Re.north);if(I!==null&&E.isResizing)if(N&&O){let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d),$=R/E.ratio;I.style.width=`${R}px`,I.style.height=`${$}px`,E.currentHeight=$,E.currentWidth=R}else if(O){let M=Math.floor(E.startY-k.clientY);M=E.direction&Re.south?-M:M;const R=Da(E.startHeight+M,_,g);I.style.height=`${R}px`,E.currentHeight=R}else{let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d);I.style.width=`${R}px`,E.currentWidth=R}},v=()=>{const k=r.current,I=u.current,E=l.current;if(k!==null&&E!==null&&I.isResizing){const N=I.currentWidth,O=I.currentHeight;I.startWidth=0,I.startHeight=0,I.ratio=0,I.startX=0,I.startY=0,I.currentWidth=0,I.currentHeight=0,I.isResizing=!1,E.classList.remove("image-control-wrapper--resizing"),b(),e(N,O),document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",v)}};return x.jsxs("div",{ref:l,children:[!i&&x.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),x.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:k=>{w(k,Re.north)}}),x.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:k=>{w(k,Re.north|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:k=>{w(k,Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:k=>{w(k,Re.south|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:k=>{w(k,Re.south)}}),x.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:k=>{w(k,Re.south|Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:k=>{w(k,Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:k=>{w(k,Re.north|Re.west)}})]})};let ri;function jh(){return ri||(ri=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.tA),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw ri=void 0,n})),ri}function Fh({equation:n,inline:e,onClick:t}){const r=S.useRef(null);return S.useEffect(()=>{let o=!1;return jh().then(s=>{const i=r.current;o||i===null||s.render(n,i,{displayMode:!e,errorColor:"var(--fgColor-danger, #cc0000)",output:"html",strict:"warn",throwOnError:!1,trust:!1})}).catch(s=>{console.debug("KaTeX could not be loaded",s)}),()=>{o=!0}},[n,e]),x.jsxs(x.Fragment,{children:[x.jsx("span",{children:" "}),x.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),x.jsx("span",{children:" "})]})}const Vx=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=S.useState(e),[o,s]=S.useState(!0),i=S.useCallback(()=>{n(t,o)},[n,t,o]),a=S.useCallback(()=>{s(!o)},[s,o]);return x.jsxs(x.Fragment,{children:[x.jsx(Y,{sx:{mb:2},children:x.jsxs(Mt,{children:[x.jsx(Mp,{checked:o,onChange:a}),x.jsx(Mt.Label,{children:"Inline"})]})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),x.jsx(Y,{sx:{mb:2},children:o?x.jsx(vn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):x.jsx(ny,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),x.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:x.jsx(Fh,{equation:t,inline:!1,onClick:()=>null})}),x.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:x.jsx(xr,{onClick:i,children:"Confirm"})})]})},Yx=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>x.jsx($p,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Bh=({children:n,className:e})=>x.jsx("div",{className:e||"Placeholder__root",children:n});function ua(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Uh(n,e){let t=n;for(let r=gt(n,e);r&&(Ve(r.origin)||bt(r.origin));r=r.getAdjacentCaret())t=r.origin;return t}function Cr(n){return Uh(n,"previous")}function xo(n){return Uh(n,"next")}function Gx(n){const e=Cr(n),t=xo(n);let r=e;for(;r!==null;){if(Ve(r)){const s=cy(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(q(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Xx(n,e){let t=null,r=null,o=n,s=e,i=n.getTextContent();for(;;){if(s===0){const c=o.getPreviousSibling();if(c===null){o=null;break}if(Ve(c)||bt(c)||ue(c)||ua(167),o=c,ue(o)){t={node:o,offset:1};break}s=Math.max(0,o.getTextContentSize()-1),i=o.getTextContent()}else s--;const l=i[s];Ve(o)&&l!==" "&&(r={node:o,offset:s})}if(r!==null)return r;let a=null;if(e<n.getTextContentSize())Ve(n)&&(a=n.getTextContent()[e]);else{const l=n.getNextSibling();Ve(l)&&(a=l.getTextContent()[0])}if(a!==null&&a!==" ")return t;{const l=(function(c,u){let f=c,d=u,g=c.getTextContent(),h=c.getTextContentSize();for(;;){if(!Ve(f)||d===h){if(f=f.getNextSibling(),f===null||ue(f))return null;Ve(f)&&(d=0,g=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(g[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Zx(n){const e=xo(n);return ue(e)&&ua(168),e}function Qx(n){const e=[];return jp(n,{linebreak:()=>e.push(vt()),tab:()=>e.push(Kn()),text:t=>e.push(Vc(t))}),e}const e0="javascript";function zh(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||zh(t,e))return!0;return!1}const as="data-language",ns="data-highlight-language",oi="data-theme";class dn extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||zh(e,"BR"))?{conversion:zd,priority:1}:null,div:()=>({conversion:t0,priority:1}),pre:()=>({conversion:zd,priority:0}),table:e=>Pa(e)?{conversion:n0,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&Pa(r)?{conversion:Kd,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pa(t)?{conversion:Kd,priority:3}:null}}})}constructor(e=void 0,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=Je().createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(as,o):s&&t.removeAttribute(as);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(ns,o):t.removeAttribute(ns):i&&o&&t.setAttribute(ns,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(oi,a):l&&t.removeAttribute(oi);const c=this.__style,u=e.__style;return c!==u&&_o(t.style,c,u),!1}exportDOM(e){const t=Je().createElement("pre");Ie(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!Tc(zo(),"@lexical/code")){const i=Kh(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=Cr(s);const a=[];for(;;)if(bt(i))a.push(Kn()),i=i.getNextSibling();else{if(!Ve(i))break;{let h=0;const _=i.getTextContent(),m=i.getTextContentSize();for(;h<m&&_[h]===" ";)h++;if(h!==0&&a.push(Vc(" ".repeat(h))),h!==m)break;i=i.getNextSibling()}}const l=s.splitText(r.offset)[0],c=r.offset===0?0:1,u=l.getIndexWithinParent()+c,f=s.getParentOrThrow(),d=[vt(),...a];f.splice(u,0,d);const g=a[a.length-1];g?g.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[vt()]),s.select(i+1,i+1)}return null}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function Ze(n,e){return ry(dn).setLanguage(n).setTheme(e)}function je(n){return n instanceof dn}function zd(n){return{node:Ze(n.getAttribute(as))}}function t0(n){const e=n,t=Wd(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(Wd(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function n0(){return{node:Ze()}}function Kd(){return{node:null}}function Wd(n){return n.style.fontFamily.match("monospace")!==null}function Pa(n){return n.classList.contains("js-file-line-container")}function Kh(n){const{anchor:e}=n;if(n.isCollapsed()&&e.type==="element"){const t=e.getNode();if(je(t)){const r=t.getChildrenSize();if(r>=2&&e.offset===r){const o=t.getLastChild();if(ue(o)&&ue(o.getPreviousSibling())){const s=ne();return t.splice(r-2,2,[]).insertAfter(s,!1),s.select(),s}}}}return null}class Hs extends cn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:cn})}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),r=ja(e.theme,this.__highlightType);return Ie(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ja(r.theme,e.__highlightType),i=ja(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(t,i)),o}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Ze()}}function ja(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Vc(n="",e){return Ot(new Hs(n,e))}function Ve(n){return n instanceof Hs}const Wh="data-language";function Hh(n){return n.style.fontFamily.match("monospace")!==null}function Fl(n){let e=n.parentElement;for(;e!==null;){if(Hh(e))return!0;e=e.parentElement}return!1}const r0=Pp([Ye({$import:(n,e)=>n.$importChildren(e),match:Ge.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),o0=Ye({$import:(n,e)=>[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))],match:Ge.tag("pre"),name:"@lexical/code/pre"}),s0=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))]:t()},match:Ge.tag("code"),name:"@lexical/code/code-multiline"});function po(n){if(!ke(n))return!1;const e=n.style.fontFamily,t=n.style.whiteSpace;return typeof e=="string"&&/monospace/i.test(e)&&typeof t=="string"&&t.startsWith("pre")}function Jh(n){let e=!1;const t=[];let r="",o=!1;const s=()=>{o&&(t.push(r),r="",o=!1)};for(const i of Array.from(n.childNodes))if(ke(i))i.tagName==="DIV"?(s(),t.push(i.textContent||""),e=!0):i.tagName==="BR"?(s(),t.push(""),e=!0):(r+=i.textContent||"",o=!0);else if(iy(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function qh(n){for(const e of Array.from(n.children)){if(ke(e)&&po(e)){if(Jh(e)!==null)return!0;const t=e.nextElementSibling;if(t&&po(t))return!0;continue}if(qh(e))return!0}return!1}const i0=Pp([Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=Jh(e);return r===null||r.length===0?t():[Ze().splice(0,0,yd(r.join(`
4
- `)))]},match:Ge.tag("div"),name:"@lexical/code/vscode-wrapper"}),Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=e.previousElementSibling;if(r&&po(r))return[];const o=[];let s=e;for(;s&&po(s);)o.push(s.tagName==="BR"?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?t():[Ze().splice(0,0,yd(o.join(`
5
- `)))]},match:Ge.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),a0=Ye({$import:(n,e,t)=>Hh(e)?[Ze().splice(0,0,n.$importChildren(e))]:Fl(e)?n.$importChildren(e):t(),match:Ge.tag("div"),name:"@lexical/code/div"}),l0=[Ye({$import:(n,e)=>[Ze().splice(0,0,n.$importChildren(e,{rules:r0}))],match:Ge.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Ye({$import:(n,e)=>n.$importChildren(e),match:Ge.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),s0,o0,a0],Vh=pe({dependencies:[js,ln(Fs,{preprocess:[(n,e,t)=>{qh(Dp(n)?n.body:n)&&e.session.update(sy,r=>[...r,i0]),t()}],rules:l0})],name:"@lexical/code",nodes:()=>[dn,Hs],register:n=>de(n.registerCommand(zr,e=>{const t=D();return!(!F(t)||!Kh(t))&&(e!==null&&e.preventDefault(),!0)},ee),n.registerNodeTransform(oy,e=>{e.getFormat()!==0&&je(e.getParent())&&e.setFormat(0)}))});function _r(n){if(!F(n))return!1;const e=n.anchor.getNode(),t=je(e)?e:e.getParent(),r=n.focus.getNode(),o=je(r)?r:r.getParent();return je(t)&&t.is(o)}function Yh(n){const e=n.getNodes(),t=[];if(e.length===1&&je(e[0]))return t;let r=[];for(let o=0;o<e.length;o++){const s=e[o];Ve(s)||bt(s)||ue(s)||ua(169),ue(s)?r.length>0&&(t.push(r),r=[]):r.push(s)}if(r.length>0){const o=n.isBackward()?n.anchor:n.focus,s=un(r[0].getKey(),0,"text");o.is(s)||t.push(r)}return t}function Hd(n,e){const t=D();if(!F(t)||!_r(t))return!1;const r=Yh(t),o=r.length;if(o===0&&t.isCollapsed())return n===Dt&&t.insertNodes([Kn()]),!0;if(o===0&&n===Dt&&t.getTextContent()===`
6
- `){const s=Kn(),i=vt(),a=t.isBackward()?"previous":"next";return t.insertNodes([s,i]),Ri(ay(mi(ly(s,"next",0),Jn(gt(i,"next"))),a)),!0}for(let s=0;s<o;s++){const i=r[s];if(i.length>0){let a=i[0];if(s===0&&(a=Cr(a)),n===Dt){const l=Kn();if(a.insertBefore(l),s===0){const c=t.isBackward()?"focus":"anchor",u=un(a.getKey(),0,"text");t[c].is(u)&&t[c].set(l.getKey(),0,"text")}}else bt(a)&&a.remove()}}return!0}function Jd(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.offset,i=o.offset,a=r.getNode(),l=o.getNode(),c=n===pt;if(!_r(t)||!Ve(a)&&!bt(a)||!Ve(l)&&!bt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const b=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!1}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!1}return!1}let u,f;if(a.isBefore(l)?(u=Cr(a),f=xo(l)):(u=Cr(l),f=xo(a)),u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let b=0;b<d.length;b++){const w=d[b];if(!Ve(w)&&!bt(w)&&!ue(w))return!1}e.preventDefault(),e.stopPropagation();const g=c?u.getPreviousSibling():f.getNextSibling();if(!ue(g))return!0;const h=c?g.getPreviousSibling():g.getNextSibling();if(h==null)return!0;const _=Ve(h)||bt(h)||ue(h)?c?Cr(h):xo(h):null;let m=_??h;return g.remove(),d.forEach(b=>b.remove()),n===pt?(d.forEach(b=>m.insertBefore(b)),m.insertBefore(g)):(m.insertAfter(g),m=g,d.forEach(b=>{m.insertAfter(b),m=b})),t.setTextNodeRange(a,s,l,i),!0}function qd(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===Ir;if(!_r(t)||!Ve(s)&&!bt(s)||!Ve(i)&&!bt(i))return!1;const l=i,c=Gx(l)==="rtl"?!a:a,u=r.key,f=r.offset,d=r.type;if(c){const g=Xx(l,o.offset);if(g!==null){const{node:h,offset:_}=g;ue(h)?h.selectNext(0,0):t.setTextNodeRange(h,_,h,_)}else l.getParentOrThrow().selectStart()}else Zx(l).select();return e.shiftKey&&t.anchor.set(u,f,d),e.preventDefault(),e.stopPropagation(),!0}function c0(n,e,t){return de(n.registerCommand(Kr,r=>{const o=(function(s){const i=D();if(!F(i)||!_r(i))return null;const a=s?wn:Dt,l=s?wn:Tl,c=i.anchor,u=i.focus;if(c.is(u))return l;const f=Yh(i);if(f.length!==1)return a;const d=f[0];let g,h;d.length===0&&ua(285),i.isBackward()?(g=u,h=c):(g=c,h=u);const _=Cr(d[0]),m=xo(d[0]),b=un(_.getKey(),0,"text"),w=un(m.getKey(),m.getTextContentSize(),"text");return g.isBefore(b)||w.isBefore(h)?a:b.isBefore(g)||h.isBefore(w)?l:a})(r.shiftKey);return o!==null&&(r.preventDefault(),n.dispatchCommand(o),!0)},ee),n.registerCommand(Tl,()=>!!_r(D())&&(Tr([Kn()]),!0),ee),n.registerCommand(Dt,()=>Hd(Dt),ee),n.registerCommand(wn,()=>Hd(wn,e),ee),n.registerCommand(pt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();if(!_r(o))return!1;const a=i.getParent();return o.isCollapsed()&&s.offset===0&&i.getPreviousSibling()===null&&je(a)&&a.getPreviousSibling()===null?(r.preventDefault(),!0):Jd(pt,r)},ee),n.registerCommand(Vt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();return!!_r(o)&&(o.isCollapsed()&&s.offset===i.getTextContentSize()&&i.getNextSibling()===null&&je(i.getParentOrThrow())&&i.getParentOrThrow().getNextSibling()===null?(r.preventDefault(),!0):Jd(Vt,r))},ee),n.registerCommand(Ir,r=>qd(Ir,r),ee),n.registerCommand(xs,r=>qd(xs,r),ee))}(function(n){n.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(t){var r=e[t],o=[];/^\w+$/.test(t)||o.push(/\w+/.exec(t)[0]),t==="diff"&&o.push("bold"),n.languages.diff[t]={pattern:RegExp("^(?:["+r+`].*(?:\r
3
+ $$`})]})}const Jx=({accept:n,label:e,onChange:t,"data-test-id":r})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:e}),x.jsx(vn,{type:"file",accept:n,onChange:o=>t(o.target.files),"data-test-id":r,block:!0})]});function Da(n,e,t){return Math.min(Math.max(n,e),t)}const Re={east:1,north:8,south:2,west:4},qx=({onResizeStart:n,onResizeEnd:e,buttonRef:t,imageRef:r,maxWidth:o,editor:s,showCaption:i,setShowCaption:a})=>{const l=S.useRef(null),c=S.useRef({priority:"",value:"default"}),u=S.useRef({currentHeight:0,currentWidth:0,direction:0,isResizing:!1,ratio:0,startHeight:0,startWidth:0,startX:0,startY:0}),f=s.getRootElement(),d=o||(f!==null?f.getBoundingClientRect().width-20:100),g=f!==null?f.getBoundingClientRect().height-20:100,h=100,_=100,m=k=>{const I=k===Re.east||k===Re.west,E=k===Re.north||k===Re.south,N=k&Re.north&&k&Re.west||k&Re.south&&k&Re.east,O=I?"ew":E?"ns":N?"nwse":"nesw";f!==null&&f.style.setProperty("cursor",`${O}-resize`,"important"),document.body!==null&&(document.body.style.setProperty("cursor",`${O}-resize`,"important"),c.current.value=document.body.style.getPropertyValue("-webkit-user-select"),c.current.priority=document.body.style.getPropertyPriority("-webkit-user-select"),document.body.style.setProperty("-webkit-user-select","none","important"))},b=()=>{f!==null&&f.style.setProperty("cursor","default"),document.body!==null&&(document.body.style.setProperty("cursor","default"),document.body.style.setProperty("-webkit-user-select",c.current.value,c.current.priority))},w=(k,I)=>{const E=r.current,N=l.current;if(E!==null&&N!==null){const{width:O,height:M}=E.getBoundingClientRect(),R=u.current;R.startWidth=O,R.startHeight=M,R.ratio=O/M,R.currentWidth=O,R.currentHeight=M,R.startX=k.clientX,R.startY=k.clientY,R.isResizing=!0,R.direction=I,m(I),n(),N.classList.add("image-control-wrapper--resizing"),E.style.height=`${M}px`,E.style.width=`${O}px`,document.addEventListener("pointermove",C),document.addEventListener("pointerup",v)}},C=k=>{const I=r.current,E=u.current,N=E.direction&(Re.east|Re.west),O=E.direction&(Re.south|Re.north);if(I!==null&&E.isResizing)if(N&&O){let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d),$=R/E.ratio;I.style.width=`${R}px`,I.style.height=`${$}px`,E.currentHeight=$,E.currentWidth=R}else if(O){let M=Math.floor(E.startY-k.clientY);M=E.direction&Re.south?-M:M;const R=Da(E.startHeight+M,_,g);I.style.height=`${R}px`,E.currentHeight=R}else{let M=Math.floor(E.startX-k.clientX);M=E.direction&Re.east?-M:M;const R=Da(E.startWidth+M,h,d);I.style.width=`${R}px`,E.currentWidth=R}},v=()=>{const k=r.current,I=u.current,E=l.current;if(k!==null&&E!==null&&I.isResizing){const N=I.currentWidth,O=I.currentHeight;I.startWidth=0,I.startHeight=0,I.ratio=0,I.startX=0,I.startY=0,I.currentWidth=0,I.currentHeight=0,I.isResizing=!1,E.classList.remove("image-control-wrapper--resizing"),b(),e(N,O),document.removeEventListener("pointermove",C),document.removeEventListener("pointerup",v)}};return x.jsxs("div",{ref:l,children:[!i&&x.jsx(ft,{ref:t,size:"small",sx:{position:"absolute",bottom:12,left:"50%",transform:"translateX(-50%)",zIndex:10},onClick:()=>{a(!i)},children:"Add Caption"}),x.jsx("div",{className:"image-resizer image-resizer-n",onPointerDown:k=>{w(k,Re.north)}}),x.jsx("div",{className:"image-resizer image-resizer-ne",onPointerDown:k=>{w(k,Re.north|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-e",onPointerDown:k=>{w(k,Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-se",onPointerDown:k=>{w(k,Re.south|Re.east)}}),x.jsx("div",{className:"image-resizer image-resizer-s",onPointerDown:k=>{w(k,Re.south)}}),x.jsx("div",{className:"image-resizer image-resizer-sw",onPointerDown:k=>{w(k,Re.south|Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-w",onPointerDown:k=>{w(k,Re.west)}}),x.jsx("div",{className:"image-resizer image-resizer-nw",onPointerDown:k=>{w(k,Re.north|Re.west)}})]})};let ri;function jh(){return ri||(ri=Promise.all([me(()=>import("../datalayer-app-main.js").then(n=>n.tA),[],import.meta.url),me(()=>Promise.resolve({}),[],import.meta.url)]).then(([n])=>n.default,n=>{throw ri=void 0,n})),ri}function Fh({equation:n,inline:e,onClick:t}){const r=S.useRef(null);return S.useEffect(()=>{let o=!1;return jh().then(s=>{const i=r.current;o||i===null||s.render(n,i,{displayMode:!e,errorColor:"var(--fgColor-danger, #cc0000)",output:"html",strict:"warn",throwOnError:!1,trust:!1})}).catch(s=>{console.debug("KaTeX could not be loaded",s)}),()=>{o=!0}},[n,e]),x.jsxs(x.Fragment,{children:[x.jsx("span",{children:" "}),x.jsx("span",{role:"button",tabIndex:-1,onClick:t,ref:r}),x.jsx("span",{children:" "})]})}const Vx=({onConfirm:n,initialEquation:e=""})=>{const[t,r]=S.useState(e),[o,s]=S.useState(!0),i=S.useCallback(()=>{n(t,o)},[n,t,o]),a=S.useCallback(()=>{s(!o)},[s,o]);return x.jsxs(x.Fragment,{children:[x.jsx(Y,{sx:{mb:2},children:x.jsxs(Mt,{children:[x.jsx(Mp,{checked:o,onChange:a}),x.jsx(Mt.Label,{children:"Inline"})]})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Equation"}),x.jsx(Y,{sx:{mb:2},children:o?x.jsx(vn,{onChange:l=>{r(l.target.value)},value:t,block:!0}):x.jsx(ny,{onChange:l=>{r(l.target.value)},value:t,block:!0,rows:6})}),x.jsx(Le,{sx:{fontSize:1,fontWeight:"bold",mb:1},children:"Visualization"}),x.jsx(Y,{sx:{mb:2,p:2,border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,textAlign:"center"},children:x.jsx(Fh,{equation:t,inline:!1,onClick:()=>null})}),x.jsx(Y,{sx:{display:"flex",justifyContent:"flex-end"},children:x.jsx(xr,{onClick:i,children:"Confirm"})})]})},Yx=({onClose:n,children:e,title:t,closeOnClickOutside:r=!1})=>x.jsx($p,{title:t,onClose:()=>n(),width:"medium",height:"auto",children:e}),Bh=({children:n,className:e})=>x.jsx("div",{className:e||"Placeholder__root",children:n});function ua(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Uh(n,e){let t=n;for(let r=gt(n,e);r&&(Ve(r.origin)||bt(r.origin));r=r.getAdjacentCaret())t=r.origin;return t}function Cr(n){return Uh(n,"previous")}function xo(n){return Uh(n,"next")}function Xx(n){const e=Cr(n),t=xo(n);let r=e;for(;r!==null;){if(Ve(r)){const s=cy(r.getTextContent());if(s!==null)return s}if(r===t)break;r=r.getNextSibling()}const o=e.getParent();if(q(o)){const s=o.getDirection();if(s==="ltr"||s==="rtl")return s}return null}function Gx(n,e){let t=null,r=null,o=n,s=e,i=n.getTextContent();for(;;){if(s===0){const c=o.getPreviousSibling();if(c===null){o=null;break}if(Ve(c)||bt(c)||ue(c)||ua(167),o=c,ue(o)){t={node:o,offset:1};break}s=Math.max(0,o.getTextContentSize()-1),i=o.getTextContent()}else s--;const l=i[s];Ve(o)&&l!==" "&&(r={node:o,offset:s})}if(r!==null)return r;let a=null;if(e<n.getTextContentSize())Ve(n)&&(a=n.getTextContent()[e]);else{const l=n.getNextSibling();Ve(l)&&(a=l.getTextContent()[0])}if(a!==null&&a!==" ")return t;{const l=(function(c,u){let f=c,d=u,g=c.getTextContent(),h=c.getTextContentSize();for(;;){if(!Ve(f)||d===h){if(f=f.getNextSibling(),f===null||ue(f))return null;Ve(f)&&(d=0,g=f.getTextContent(),h=f.getTextContentSize())}if(Ve(f)){if(g[d]!==" ")return{node:f,offset:d};d++}}})(n,e);return l!==null?l:t}}function Zx(n){const e=xo(n);return ue(e)&&ua(168),e}function Qx(n){const e=[];return jp(n,{linebreak:()=>e.push(vt()),tab:()=>e.push(Kn()),text:t=>e.push(Vc(t))}),e}const e0="javascript";function zh(n,e){for(const t of n.childNodes)if(ke(t)&&t.tagName===e||zh(t,e))return!0;return!1}const as="data-language",ns="data-highlight-language",oi="data-theme";class dn extends Oe{__language;__theme;__isSyntaxHighlightSupported;$config(){return this.config("code",{extends:Oe,importDOM:{code:e=>e.textContent!=null&&(/\r?\n/.test(e.textContent)||zh(e,"BR"))?{conversion:zd,priority:1}:null,div:()=>({conversion:t0,priority:1}),pre:()=>({conversion:zd,priority:0}),table:e=>Pa(e)?{conversion:n0,priority:3}:null,td:e=>{const t=e,r=t.closest("table");return t.classList.contains("js-file-line")||r&&Pa(r)?{conversion:Kd,priority:3}:null},tr:e=>{const t=e.closest("table");return t&&Pa(t)?{conversion:Kd,priority:3}:null}}})}constructor(e=void 0,t){super(t),this.__language=e||void 0,this.__isSyntaxHighlightSupported=!1,this.__theme=void 0}afterCloneFrom(e){super.afterCloneFrom(e),this.__language=e.__language,this.__theme=e.__theme,this.__isSyntaxHighlightSupported=e.__isSyntaxHighlightSupported}createDOM(e){const t=Je().createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),t}updateDOM(e,t,r){const o=this.__language,s=e.__language;o?o!==s&&t.setAttribute(as,o):s&&t.removeAttribute(as);const i=this.__isSyntaxHighlightSupported;e.__isSyntaxHighlightSupported&&s?i&&o?o!==s&&t.setAttribute(ns,o):t.removeAttribute(ns):i&&o&&t.setAttribute(ns,o);const a=this.__theme,l=e.__theme;a?a!==l&&t.setAttribute(oi,a):l&&t.removeAttribute(oi);const c=this.__style,u=e.__style;return c!==u&&_o(t.style,c,u),!1}exportDOM(e){const t=Je().createElement("pre");Ie(t,e._config.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();r&&(t.setAttribute(as,r),this.getIsSyntaxHighlightSupported()&&t.setAttribute(ns,r));const o=this.getTheme();o&&t.setAttribute(oi,o);const s=this.getStyle();return s&&_o(t.style,s),{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setLanguage(e.language).setTheme(e.theme)}exportJSON(){return{...super.exportJSON(),language:this.getLanguage(),theme:this.getTheme()}}insertNewAfter(e,t=!0){if(!Tc(zo(),"@lexical/code")){const i=Kh(e);if(i)return i}const{anchor:r,focus:o}=e,s=(r.isBefore(o)?r:o).getNode();if(oe(s)){let i=Cr(s);const a=[];for(;;)if(bt(i))a.push(Kn()),i=i.getNextSibling();else{if(!Ve(i))break;{let h=0;const _=i.getTextContent(),m=i.getTextContentSize();for(;h<m&&_[h]===" ";)h++;if(h!==0&&a.push(Vc(" ".repeat(h))),h!==m)break;i=i.getNextSibling()}}const l=s.splitText(r.offset)[0],c=r.offset===0?0:1,u=l.getIndexWithinParent()+c,f=s.getParentOrThrow(),d=[vt(),...a];f.splice(u,0,d);const g=a[a.length-1];g?g.select():r.offset===0?l.selectPrevious():l.getNextSibling().selectNext(0,0)}if(je(s)){const{offset:i}=e.anchor;s.splice(i,0,[vt()]),s.select(i+1,i+1)}return null}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();return t.__language=e||void 0,t}getLanguage(){return this.getLatest().__language}setIsSyntaxHighlightSupported(e){const t=this.getWritable();return t.__isSyntaxHighlightSupported=e,t}getIsSyntaxHighlightSupported(){return this.getLatest().__isSyntaxHighlightSupported}setTheme(e){const t=this.getWritable();return t.__theme=e||void 0,t}getTheme(){return this.getLatest().__theme}}function Ze(n,e){return ry(dn).setLanguage(n).setTheme(e)}function je(n){return n instanceof dn}function zd(n){return{node:Ze(n.getAttribute(as))}}function t0(n){const e=n,t=Wd(e);return t||(function(r){let o=r.parentElement;for(;o!==null;){if(Wd(o))return!0;o=o.parentElement}return!1})(e)?{node:t?Ze():null}:{node:null}}function n0(){return{node:Ze()}}function Kd(){return{node:null}}function Wd(n){return n.style.fontFamily.match("monospace")!==null}function Pa(n){return n.classList.contains("js-file-line-container")}function Kh(n){const{anchor:e}=n;if(n.isCollapsed()&&e.type==="element"){const t=e.getNode();if(je(t)){const r=t.getChildrenSize();if(r>=2&&e.offset===r){const o=t.getLastChild();if(ue(o)&&ue(o.getPreviousSibling())){const s=ne();return t.splice(r-2,2,[]).insertAfter(s,!1),s.select(),s}}}}return null}class Hs extends cn{__highlightType;constructor(e="",t,r){super(e,r),this.__highlightType=t}$config(){return this.config("code-highlight",{extends:cn})}afterCloneFrom(e){super.afterCloneFrom(e),this.__highlightType=e.__highlightType}getHighlightType(){return this.getLatest().__highlightType}setHighlightType(e){const t=this.getWritable();return t.__highlightType=e||void 0,t}canHaveFormat(){return!1}createDOM(e){const t=super.createDOM(e),r=ja(e.theme,this.__highlightType);return Ie(t,r),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=ja(r.theme,e.__highlightType),i=ja(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(t,i)),o}updateFromJSON(e){return super.updateFromJSON(e).setHighlightType(e.highlightType)}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType()}}setFormat(e){return this}isParentRequired(){return!0}createParentElementNode(){return Ze()}}function ja(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Vc(n="",e){return Ot(new Hs(n,e))}function Ve(n){return n instanceof Hs}const Wh="data-language";function Hh(n){return n.style.fontFamily.match("monospace")!==null}function Fl(n){let e=n.parentElement;for(;e!==null;){if(Hh(e))return!0;e=e.parentElement}return!1}const r0=Pp([Ye({$import:(n,e)=>n.$importChildren(e),match:Xe.tag("tr","td"),name:"@lexical/code/github-code-table/unwrap"})]),o0=Ye({$import:(n,e)=>[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))],match:Xe.tag("pre"),name:"@lexical/code/pre"}),s0=Ye({$import:(n,e,t)=>{const r=e.textContent||"";return/\r?\n/.test(r)||e.querySelector("br")!==null?[Ze(e.getAttribute(Wh)).splice(0,0,n.$importChildren(e))]:t()},match:Xe.tag("code"),name:"@lexical/code/code-multiline"});function po(n){if(!ke(n))return!1;const e=n.style.fontFamily,t=n.style.whiteSpace;return typeof e=="string"&&/monospace/i.test(e)&&typeof t=="string"&&t.startsWith("pre")}function Jh(n){let e=!1;const t=[];let r="",o=!1;const s=()=>{o&&(t.push(r),r="",o=!1)};for(const i of Array.from(n.childNodes))if(ke(i))i.tagName==="DIV"?(s(),t.push(i.textContent||""),e=!0):i.tagName==="BR"?(s(),t.push(""),e=!0):(r+=i.textContent||"",o=!0);else if(iy(i)){const a=i.textContent||"";a.length>0&&(r+=a,o=!0)}return s(),e?t:null}function qh(n){for(const e of Array.from(n.children)){if(ke(e)&&po(e)){if(Jh(e)!==null)return!0;const t=e.nextElementSibling;if(t&&po(t))return!0;continue}if(qh(e))return!0}return!1}const i0=Pp([Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=Jh(e);return r===null||r.length===0?t():[Ze().splice(0,0,yd(r.join(`
4
+ `)))]},match:Xe.tag("div"),name:"@lexical/code/vscode-wrapper"}),Ye({$import:(n,e,t)=>{if(!po(e)||Fl(e))return t();const r=e.previousElementSibling;if(r&&po(r))return[];const o=[];let s=e;for(;s&&po(s);)o.push(s.tagName==="BR"?"":s.textContent||""),s=s.nextElementSibling;return o.length<2?t():[Ze().splice(0,0,yd(o.join(`
5
+ `)))]},match:Xe.tag("div","br"),name:"@lexical/code/vscode-line-run"})]),a0=Ye({$import:(n,e,t)=>Hh(e)?[Ze().splice(0,0,n.$importChildren(e))]:Fl(e)?n.$importChildren(e):t(),match:Xe.tag("div"),name:"@lexical/code/div"}),l0=[Ye({$import:(n,e)=>[Ze().splice(0,0,n.$importChildren(e,{rules:r0}))],match:Xe.tag("table").classAll("js-file-line-container"),name:"@lexical/code/github-code-table"}),Ye({$import:(n,e)=>n.$importChildren(e),match:Xe.tag("td").classAll("js-file-line"),name:"@lexical/code/github-code-cell-by-class"}),s0,o0,a0],Vh=pe({dependencies:[js,ln(Fs,{preprocess:[(n,e,t)=>{qh(Dp(n)?n.body:n)&&e.session.update(sy,r=>[...r,i0]),t()}],rules:l0})],name:"@lexical/code",nodes:()=>[dn,Hs],register:n=>de(n.registerCommand(zr,e=>{const t=D();return!(!F(t)||!Kh(t))&&(e!==null&&e.preventDefault(),!0)},ee),n.registerNodeTransform(oy,e=>{e.getFormat()!==0&&je(e.getParent())&&e.setFormat(0)}))});function _r(n){if(!F(n))return!1;const e=n.anchor.getNode(),t=je(e)?e:e.getParent(),r=n.focus.getNode(),o=je(r)?r:r.getParent();return je(t)&&t.is(o)}function Yh(n){const e=n.getNodes(),t=[];if(e.length===1&&je(e[0]))return t;let r=[];for(let o=0;o<e.length;o++){const s=e[o];Ve(s)||bt(s)||ue(s)||ua(169),ue(s)?r.length>0&&(t.push(r),r=[]):r.push(s)}if(r.length>0){const o=n.isBackward()?n.anchor:n.focus,s=un(r[0].getKey(),0,"text");o.is(s)||t.push(r)}return t}function Hd(n,e){const t=D();if(!F(t)||!_r(t))return!1;const r=Yh(t),o=r.length;if(o===0&&t.isCollapsed())return n===Dt&&t.insertNodes([Kn()]),!0;if(o===0&&n===Dt&&t.getTextContent()===`
6
+ `){const s=Kn(),i=vt(),a=t.isBackward()?"previous":"next";return t.insertNodes([s,i]),Ri(ay(mi(ly(s,"next",0),Jn(gt(i,"next"))),a)),!0}for(let s=0;s<o;s++){const i=r[s];if(i.length>0){let a=i[0];if(s===0&&(a=Cr(a)),n===Dt){const l=Kn();if(a.insertBefore(l),s===0){const c=t.isBackward()?"focus":"anchor",u=un(a.getKey(),0,"text");t[c].is(u)&&t[c].set(l.getKey(),0,"text")}}else bt(a)&&a.remove()}}return!0}function Jd(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.offset,i=o.offset,a=r.getNode(),l=o.getNode(),c=n===pt;if(!_r(t)||!Ve(a)&&!bt(a)||!Ve(l)&&!bt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const b=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!1}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!1}return!1}let u,f;if(a.isBefore(l)?(u=Cr(a),f=xo(l)):(u=Cr(l),f=xo(a)),u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let b=0;b<d.length;b++){const w=d[b];if(!Ve(w)&&!bt(w)&&!ue(w))return!1}e.preventDefault(),e.stopPropagation();const g=c?u.getPreviousSibling():f.getNextSibling();if(!ue(g))return!0;const h=c?g.getPreviousSibling():g.getNextSibling();if(h==null)return!0;const _=Ve(h)||bt(h)||ue(h)?c?Cr(h):xo(h):null;let m=_??h;return g.remove(),d.forEach(b=>b.remove()),n===pt?(d.forEach(b=>m.insertBefore(b)),m.insertBefore(g)):(m.insertAfter(g),m=g,d.forEach(b=>{m.insertAfter(b),m=b})),t.setTextNodeRange(a,s,l,i),!0}function qd(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===Ir;if(!_r(t)||!Ve(s)&&!bt(s)||!Ve(i)&&!bt(i))return!1;const l=i,c=Xx(l)==="rtl"?!a:a,u=r.key,f=r.offset,d=r.type;if(c){const g=Gx(l,o.offset);if(g!==null){const{node:h,offset:_}=g;ue(h)?h.selectNext(0,0):t.setTextNodeRange(h,_,h,_)}else l.getParentOrThrow().selectStart()}else Zx(l).select();return e.shiftKey&&t.anchor.set(u,f,d),e.preventDefault(),e.stopPropagation(),!0}function c0(n,e,t){return de(n.registerCommand(Kr,r=>{const o=(function(s){const i=D();if(!F(i)||!_r(i))return null;const a=s?wn:Dt,l=s?wn:Tl,c=i.anchor,u=i.focus;if(c.is(u))return l;const f=Yh(i);if(f.length!==1)return a;const d=f[0];let g,h;d.length===0&&ua(285),i.isBackward()?(g=u,h=c):(g=c,h=u);const _=Cr(d[0]),m=xo(d[0]),b=un(_.getKey(),0,"text"),w=un(m.getKey(),m.getTextContentSize(),"text");return g.isBefore(b)||w.isBefore(h)?a:b.isBefore(g)||h.isBefore(w)?l:a})(r.shiftKey);return o!==null&&(r.preventDefault(),n.dispatchCommand(o),!0)},ee),n.registerCommand(Tl,()=>!!_r(D())&&(Tr([Kn()]),!0),ee),n.registerCommand(Dt,()=>Hd(Dt),ee),n.registerCommand(wn,()=>Hd(wn,e),ee),n.registerCommand(pt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();if(!_r(o))return!1;const a=i.getParent();return o.isCollapsed()&&s.offset===0&&i.getPreviousSibling()===null&&je(a)&&a.getPreviousSibling()===null?(r.preventDefault(),!0):Jd(pt,r)},ee),n.registerCommand(Vt,r=>{const o=D();if(!F(o))return!1;const{anchor:s}=o,i=s.getNode();return!!_r(o)&&(o.isCollapsed()&&s.offset===i.getTextContentSize()&&i.getNextSibling()===null&&je(i.getParentOrThrow())&&i.getParentOrThrow().getNextSibling()===null?(r.preventDefault(),!0):Jd(Vt,r))},ee),n.registerCommand(Ir,r=>qd(Ir,r),ee),n.registerCommand(xs,r=>qd(xs,r),ee))}(function(n){n.languages.diff={coord:[/^(?:\*{3}|-{3}|\+{3}).*$/m,/^@@.*@@$/m,/^\d.*$/m]};var e={"deleted-sign":"-","deleted-arrow":"<","inserted-sign":"+","inserted-arrow":">",unchanged:" ",diff:"!"};Object.keys(e).forEach(function(t){var r=e[t],o=[];/^\w+$/.test(t)||o.push(/\w+/.exec(t)[0]),t==="diff"&&o.push("bold"),n.languages.diff[t]={pattern:RegExp("^(?:["+r+`].*(?:\r
7
7
  ?|
8
- |(?![\\s\\S])))+`,"m"),alias:o,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(t)[0]}}}}),Object.defineProperty(n.languages.diff,"PREFIXES",{value:e})})(Prism),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];const rn=globalThis.Prism||window.Prism,Gh={c:"C",clike:"C-like",cpp:"C++",css:"CSS",go:"Go",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},u0={cpp:"cpp",golang:"go",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function Yc(n){return u0[n]||n}function d0(n){const e=Yc(n);return Gh[e]||e}function f0(){const n=[];for(const[e,t]of Object.entries(Gh))n.push([e,t]);return n}function g0(n){const e=(function(r){const o=/^diff-([\w-]+)/i.exec(r);return o?o[1]:null})(n),t=e||n;try{return!!t&&rn.languages.hasOwnProperty(t)}catch{return!1}}async function p0(n,e,t){}function Bl(n){return typeof n=="string"?n:Array.isArray(n)?n.map(Bl).join(""):Bl(n.content)}function h0(n,e){const t=/^diff-([\w-]+)/i.exec(e),r=n.getTextContent();let o=rn.tokenize(r,rn.languages[t?"diff":e]);return t&&(o=(function(s,i){const a=i,l=rn.languages[a],c={tokens:s},u=rn.languages.diff.PREFIXES;for(const f of c.tokens){if(typeof f=="string"||!(f.type in u)||!Array.isArray(f.content))continue;const d=f.type;let g=0;const h=()=>(g++,new rn.Token("prefix",u[d],d.replace(/^(\w+).*/,"$1"))),_=f.content.filter(k=>typeof k=="string"||k.type!=="prefix"),m=f.content.length-_.length,b=rn.tokenize(Bl(_),l);b.unshift(h());const w=/\r\n|\n/g,C=k=>{const I=[];w.lastIndex=0;let E,N=0;for(;g<m&&(E=w.exec(k));){const O=E.index+E[0].length;I.push(k.slice(N,O)),N=O,I.push(h())}if(I.length!==0)return N<k.length&&I.push(k.slice(N)),I},v=k=>{for(let I=0;I<k.length&&g<m;I++){const E=k[I];if(typeof E=="string"){const N=C(E);N&&(k.splice(I,1,...N),I+=N.length-1)}else if(typeof E.content=="string"){const N=C(E.content);N&&(E.content=N)}else Array.isArray(E.content)?v(E.content):v([E.content])}};v(b),g<m&&b.push(h()),f.content=b}return c.tokens})(o,t[1])),Ul(o)}function Ul(n,e){const t=[];for(const r of n)if(typeof r=="string")jp(r,{linebreak:()=>t.push(vt()),tab:()=>t.push(Kn()),text:o=>t.push(Vc(o,e))});else{const{content:o,alias:s}=r;typeof o=="string"?t.push(...Ul([o],r.type==="prefix"&&typeof s=="string"?s:r.type)):Array.isArray(o)&&t.push(...Ul(o,r.type==="unchanged"?void 0:r.type))}return t}const _0={$tokenize(n,e){const t=e||this.defaultLanguage;return t===null?Qx(n.getTextContent()):h0(n,t)},defaultLanguage:e0,tokenize(n,e){const t=this.defaultLanguage;return rn.tokenize(n,rn.languages[e||""]||(t===null?void 0:rn.languages[t]))}};function Vd(n,e,t,r){const o=r.getParent();je(o)?Xh(n,e,t,o):Ve(r)&&r.replace($e(r.__text))}function m0(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
9
- `+ ++i);t.setAttribute("data-gutter",s)}function Xh(n,e,t,r){const{nodesCurrentlyHighlighting:o}=t,s=r.getKey();r.getLanguage()===void 0&&e.defaultLanguage!==null&&r.setLanguage(e.defaultLanguage);const i=r.getLanguage()||e.defaultLanguage;if(i){if(!g0(i))return r.getIsSyntaxHighlightSupported()&&r.setIsSyntaxHighlightSupported(!1),void p0();r.getIsSyntaxHighlightSupported()||r.setIsSyntaxHighlightSupported(!0)}else r.getIsSyntaxHighlightSupported()&&r.setIsSyntaxHighlightSupported(!1);o.has(s)||(o.add(s),t.didTransform||(t.didTransform=!0,uy(()=>{t.didTransform=!1,o.clear()})),(function(a,l){const c=Q(a);if(!je(c)||!c.isAttached())return;const u=D();if(!F(u))return void l();const f=u.anchor,d=f.offset,g=f.type==="element"&&ue(c.getChildAtIndex(f.offset-1));let h=0;if(!g){const _=f.getNode();h=d+_.getPreviousSiblings().reduce((m,b)=>m+b.getTextContentSize(),0)}if(l()){if(g)return void f.getNode().select(d,d);c.getChildren().some(_=>{const m=oe(_);if(m||ue(_)){const b=_.getTextContentSize();if(m&&b>=h)return _.select(h,h),!0;h-=b}return!1})}})(s,()=>{const a=Q(s);if(!je(a)||!a.isAttached())return!1;const l=a.getLanguage()||e.defaultLanguage,c=e.$tokenize(a,l??void 0),u=(function(h,_){let m=0;for(;m<h.length&&Yd(h[m],_[m]);)m++;const b=h.length,w=_.length,C=Math.min(b,w)-m;let v=0;for(;v<C;)if(v++,!Yd(h[b-v],_[w-v])){v--;break}const k=m,I=b-v,E=_.slice(m,w-v);return{from:k,nodesForReplacement:E,to:I}})(a.getChildren(),c),{from:f,to:d,nodesForReplacement:g}=u;return!(f===d&&!g.length)&&(r.splice(f,d-f,g),!0)}))}function Yd(n,e){return Ve(n)&&Ve(e)&&n.__text===e.__text&&n.__highlightType===e.__highlightType||bt(n)&&bt(e)||ue(n)&&ue(e)}function b0(n,e){const t=[];n._headless!==!0&&t.push(n.registerMutationListener(dn,o=>{n.read("latest",()=>{for(const[s,i]of o)if(i!=="destroyed"){const a=Q(s);a!==null&&m0(a,n)}})},{skipInitialization:!1}));const r={didTransform:!1,nodesCurrentlyHighlighting:new Set};return t.push(n.registerNodeTransform(dn,Xh.bind(null,n,e,r)),n.registerNodeTransform(cn,Vd.bind(null,n,e,r)),n.registerNodeTransform(Hs,Vd.bind(null,n,e,r))),de(...t)}function y0(n,e=_0){if(!n.hasNodes([dn,Hs]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return de(b0(n,e),c0(n))}const w0=f0,x0=d0,C0=Yc,zl=Yc,S0=y0,v0={css:[()=>me(()=>import("./postcss-BeaNGZ2L.js").then(n=>n.p),[],import.meta.url)],html:[()=>me(()=>import("./html-DZBHODiV.js").then(n=>n.h),[],import.meta.url)],js:[()=>me(()=>import("./babel-RKmSF9zr.js").then(n=>n.b),[],import.meta.url),()=>me(()=>import("./estree-C_HWBWad.js"),[],import.meta.url)],markdown:[()=>me(()=>import("./markdown-DR6D7d1u.js").then(n=>n.m),[],import.meta.url)],typescript:[()=>me(()=>import("./typescript-9PkMzh3x.js").then(n=>n.t),[],import.meta.url),()=>me(()=>import("./estree-C_HWBWad.js"),[],import.meta.url)]};async function k0(n){const e=v0[n];return await Promise.all(e.map(r=>r()))}async function T0(){const{format:n}=await me(async()=>{const{format:e}=await import("./standalone-DyCMuq_1.js");return{format:e}},[],import.meta.url);return n}const Zh={css:{parser:"css"},html:{parser:"html"},js:{parser:"babel"},markdown:{parser:"markdown"},typescript:{parser:"typescript"}},I0=Object.keys(Zh);function E0(n){return I0.includes(n)}function N0(n){const e=Zh[n];if(!e)throw new Error(`CodeActionMenuPlugin: Prettier does not support this language: ${n}`);return e}function L0({lang:n,editor:e,getCodeDOMNode:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1);async function a(){const f=t();if(!f)return;let d="";if(e.update(()=>{const g=Ae(f);je(g)&&(d=g.getTextContent())}),d!=="")try{const g=await T0(),h=N0(n),_=await k0(n);h.plugins=_.map(b=>b.default||b);const m=await g(d,h);e.update(()=>{const b=Ae(f);je(b)&&(b.select(0).insertText(m),o(""),i(!1))})}catch(g){l(g)}}function l(f){f instanceof Error?(o(f.message),i(!0)):console.error("Unexpected error: ",f)}function c(){r!==""&&i(!0)}function u(){r!==""&&i(!1)}return x.jsxs(Y,{sx:{position:"relative",display:"inline-flex"},children:[x.jsx(Ft,{icon:r?Fp:br,size:"small",variant:"invisible",onClick:a,onMouseEnter:c,onMouseLeave:u,"aria-label":"prettier",sx:r?{color:"var(--fgColor-danger)"}:void 0}),s?x.jsx(Y,{as:"pre",sx:{position:"absolute",top:"100%",left:0,zIndex:10,p:2,mt:1,fontSize:0,bg:"var(--bgColor-danger-muted)",color:"var(--fgColor-danger)",borderRadius:2,borderWidth:1,borderStyle:"solid",borderColor:"var(--bgColor-danger-muted)",maxWidth:"300px",whiteSpace:"pre-wrap"},children:r}):null]})}const Kl=({label:n,value:e,onChange:t,placeholder:r="","data-test-id":o})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:n}),x.jsx(vn,{type:"text",placeholder:r,value:e,onChange:s=>{t(s.target.value)},"data-test-id":o,block:!0})]}),Qh=S.createContext(void 0),EM=({children:n})=>{const[e,t]=S.useState(!1),r=()=>t(o=>!o);return x.jsx(Qh.Provider,{value:{showComments:e,toggleComments:r,setShowComments:t},children:n})},e_=()=>{const n=S.useContext(Qh);if(!n)throw new Error("useComments must be used within CommentsProvider");return n},O0=S.createContext({});function R0(){return S.useContext(O0)}const Gc=S.createContext(void 0);function A0(){const n=S.useContext(Gc);if(!n)throw new Error("useLexicalConfig must be used within a LexicalConfigProvider");return n}function M0(){return S.useContext(Gc)}function NM({lexicalId:n,serviceManager:e,children:t}){return x.jsx(Gc.Provider,{value:{lexicalId:n,serviceManager:e},children:t})}const $0=S.createContext({});function D0(){return S.useContext($0)}const Gd=window.location.hostname,P0=Gd!=="playground.lexical.dev"&&Gd!=="lexical-playground.vercel.app",t_={disableBeforeInput:!1,emptyEditor:P0,hasLinkAttributes:!1,isAutocomplete:!1,isCharLimit:!1,isCharLimitUtf8:!1,isCodeHighlighted:!0,isCodeShiki:!1,isCollab:!1,isMaxLength:!1,isRichText:!0,listStrictIndent:!1,measureTypingPerf:!1,selectionAlwaysOnDisplay:!1,shouldAllowHighlightingWithBrackets:!1,shouldPreserveNewLinesInMarkdown:!1,shouldUseLexicalContextMenu:!1,showNestedEditorTreeView:!1,showTableOfContents:!1,showTreeView:!0,tableCellBackgroundColor:!0,tableCellMerge:!0,tableHorizontalScroll:!0},n_={...t_},r_=S.createContext({setOption:(n,e)=>{},settings:n_}),LM=({children:n})=>{const[e,t]=S.useState(n_),r=S.useCallback((s,i)=>{t(a=>({...a,[s]:i})),F0(s,i)},[]),o=S.useMemo(()=>({setOption:r,settings:e}),[r,e]);return x.jsx(r_.Provider,{value:o,children:n})},j0=()=>S.useContext(r_);function F0(n,e){const t=new URL(window.location.href),r=new URLSearchParams(t.search);e!==t_[n]?r.set(n,String(e)):r.delete(n),t.search=r.toString(),window.history.pushState(null,"",t.toString())}const Fa=8,Ba=72,Wl=15,Ua={bullet:"Bulleted List",check:"Check List",code:"Code Block",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",number:"Numbered List",paragraph:"Normal",quote:"Quote"},B0={bgColor:"#fff",blockType:"paragraph",canRedo:!1,canUndo:!1,codeLanguage:"",codeTheme:"",elementFormat:"left",fontColor:"#000",fontFamily:"Arial",fontSize:`${Wl}px`,fontSizeInputValue:`${Wl}`,isBold:!1,isCode:!1,isHighlight:!1,isImageCaption:!1,isItalic:!1,isLink:!1,isRTL:!1,isStrikethrough:!1,isSubscript:!1,isSuperscript:!1,isUnderline:!1,isLowercase:!1,isUppercase:!1,isCapitalize:!1,rootType:"root",listStartNumber:null},o_=S.createContext(void 0),OM=({children:n})=>{const[e,t]=S.useState(B0),r=e.fontSize,o=S.useCallback((i,a)=>{t(l=>({...l,[i]:a}))},[]);S.useEffect(()=>{o("fontSizeInputValue",r.slice(0,-2))},[r,o]);const s=S.useMemo(()=>({toolbarState:e,updateToolbarState:o}),[e,o]);return x.jsx(o_.Provider,{value:s,children:n})},U0=()=>{const n=S.useContext(o_);if(n===void 0)throw new Error("useToolbarState must be used within a ToolbarProvider");return n},z0=Ye({$import:(n,e)=>{const t=fn(e.nodeName.toLowerCase());return Bs(e,t),rr(t,e),mn(t,e),[t.splice(0,0,n.$importChildren(e))]},match:Ge.tag("h1","h2","h3","h4","h5","h6"),name:"@lexical/rich-text/heading"}),K0=Ye({$import:(n,e)=>{const t=Ln();return rr(t,e),Bs(e,t),mn(t,e),[t.splice(0,0,n.$importChildren(e))]},match:Ge.tag("blockquote"),name:"@lexical/rich-text/blockquote"});Ge.tag("blockquote");const W0=[z0,K0,Ye({$import:(n,e,t)=>{const r=e.firstChild;return r&&ke(o=r)&&o.nodeName==="SPAN"&&o.style.fontSize==="26pt"?n.$importChildren(e):t();var o},match:Ge.tag("p"),name:"@lexical/rich-text/google-docs-title-p"}),Ye({$import:(n,e,t)=>e.style.fontSize!=="26pt"?t():[fn("h1").splice(0,0,n.$importChildren(e))],match:Ge.tag("span"),name:"@lexical/rich-text/google-docs-title-span"})];function H0(n,e){return n&&e!==null?Eo(n,e):e}const s_=pe({build:(n,e)=>nr(e),config:tr({escapeFormatTriggers:{capitalize:{enter:!0,space:!0,tab:!0},lowercase:{enter:!0,space:!0,tab:!0},uppercase:{enter:!0,space:!0,tab:!0}}}),conflictsWith:["@lexical/plain-text"],dependencies:[dy,fy,gy,js,ln(Fs,{rules:W0})],mergeConfig:function(n,e){const t=Eo(n,e);return e.escapeFormatTriggers&&(t.escapeFormatTriggers=(function(r,o){const s=Eo(r,o);for(const i of Object.keys(o))s[i]=H0(r[i],o[i]);return s})(n.escapeFormatTriggers,e.escapeFormatTriggers)),t},name:"@lexical/rich-text",nodes:()=>[qs,Js],register:(n,e,t)=>zt(()=>i_(n,t.getOutput().escapeFormatTriggers))}),Xd=he("DRAG_DROP_PASTE_FILE"),za=Us("shadowRoot",{parse:Boolean});let Js=class extends Oe{$config(){return this.config("quote",{extends:Oe,importDOM:{blockquote:()=>({conversion:J0,priority:0})},stateConfigs:[{flat:!0,stateConfig:za}]})}isShadowRoot(){return Cs(this,za)}setIsShadowRoot(e){return xn(this,za,e)}createDOM(e){const t=Je().createElement("blockquote");return Ie(t,e.theme.quote),t}updateDOM(e,t,r){return!1}exportDOM(e){const{element:t}=super.exportDOM(e);if(ke(t)){this.isEmpty()&&t.append(Je().createElement("br"));const r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();o&&(t.dir=o)}return{element:t}}exportJSON(){return super.exportJSON()}static importJSON(e){return Ln().updateFromJSON(e)}insertNewAfter(e,t){const r=ne(),o=this.getDirection();return r.setDirection(o),this.insertAfter(r,t),r}collapseAtStart(){if(this.isShadowRoot()){for(const t of this.getChildren())this.insertBefore(t);return this.remove(),!0}const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function Ln(n){const e=Ot(new Js);return n&&n.shadowRoot?e.setIsShadowRoot(!0):e}function Vn(n){return n instanceof Js}let qs=class extends Oe{__tag;$config(){return this.config("heading",{extends:Oe,importDOM:{h1:()=>({conversion:to,priority:0}),h2:()=>({conversion:to,priority:0}),h3:()=>({conversion:to,priority:0}),h4:()=>({conversion:to,priority:0}),h5:()=>({conversion:to,priority:0}),h6:()=>({conversion:to,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Zd(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Zd(e)?{conversion:()=>({node:fn("h1")}),priority:3}:null}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__tag=e.__tag}constructor(e="h1",t){super(t),this.__tag=e}getTag(){return this.getLatest().__tag}setTag(e){const t=this.getWritable();return t.__tag=e,t}createDOM(e){const t=this.__tag,r=Je().createElement(t),o=e.theme.heading;if(o!==void 0){const s=o[t];Ie(r,s)}return r}updateDOM(e,t,r){return e.__tag!==this.__tag}exportDOM(e){const{element:t}=super.exportDOM(e);if(ke(t)){this.isEmpty()&&t.append(Je().createElement("br"));const r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();o&&(t.dir=o)}return{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const r=e?e.anchor.offset:0,o=this.getLastDescendant(),s=!o||e&&e.anchor.key===o.getKey()&&r===o.getTextContentSize()||!e?ne():fn(this.getTag()),i=this.getDirection();if(s.setDirection(i),this.insertAfter(s,t),r===0&&!this.isEmpty()&&e){const a=ne();a.select(),this.replace(a,!0)}return s}collapseAtStart(){if(this.isEmpty()){const e=ne();this.getChildren().forEach(t=>e.append(t)),this.replace(e)}return!0}extractWithChild(){return!0}};function Zd(n){return n.nodeName.toLowerCase()==="span"&&n.style.fontSize==="26pt"}function to(n){const e=n.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=fn(e),Bs(n,t),rr(t,n),mn(t,n)),{node:t}}function J0(n){const e=Ln();return rr(e,n),Bs(n,e),mn(e,n),{node:e}}function fn(n="h1"){return Ot(new qs(n))}function Wr(n){return n instanceof qs}function Qd(n){const e=Ae(n);return It(e)}function no(n,e,t,r){let o=!1,s=null;if(n.isCollapsed()&&n.anchor.type==="text"){const a=n.anchor.getNode();if(oe(a)){s=a;const l=n.anchor.offset,c=l===a.getTextContentSize()&&a.getNextSibling()===null,u=l===0&&a.getPreviousSibling()===null;o=t==="end"&&c||t==="start"&&u||t==="both"&&(c||u)}}let i=!1;for(const[a,l]of Object.entries(r)){if(l==null||!l[e])continue;const c=a;if(l.onlyAtBoundary){if(!(o&&s&&oe(s)&&s.hasFormat(c)))continue;i=!0}n.hasFormat(c)&&n.toggleFormat(c)}i&&n.setStyle("")}const q0={capitalize:{enter:!0,space:!0,tab:!0},lowercase:{enter:!0,space:!0,tab:!0},uppercase:{enter:!0,space:!0,tab:!0}};function si(n,e){return(function(t,r){if(!t.isCollapsed())return!1;const o=vs(t.focus,r),s=re(o.origin,Ra);if(!s)return!1;const i=t.focus.getNode();if(!s.is(i)&&!Xp(i,s))return!1;const a=mi(o,gt(s,r));if(a.getTextSlices().some(f=>f&&f.getTextContentSize()>0))return!1;const l=mi(a.anchor.getSiblingCaret(),a.focus);let c=l.anchor.origin;for(const f of l){if(!Mc(f)||!f.origin.is(c.getParent()))return!1;c=f.origin}let u=s;for(const f of Ll(gt(s,r))){if(!f.origin.is(u.getParent())){if(Ey(f.origin)){const d=gt(u,r);return Ri(mi(d,d)),!0}break}if(!Ra(f.origin))break;u=f.origin}return!1})(n,e)||(function(t,r){if(!t.isCollapsed()||t.anchor.type!=="element")return!1;const o=vs(t.anchor,r).getNodeAtCaret();return!(!Ra(o)||o.isInline()||(Ri(Gp(Jn(Er(o,r)))),0))})(n,e)}function ef(n){return It(n)&&!n.isInline()&&!n.isIsolated()&&n.isKeyboardSelectable()}function ii(n){const e=aa();e.add(n),Ee(e)}function tf(n,e){if(!n.isCollapsed())return!1;const t=n.focus,r=t.getNode(),o=e?"previous":"next",s=vs(t,o);if(t.type==="element"&&q(r)&&wt(r)){const b=s.getNodeAtCaret();return!(b===null||!ef(b))&&(ii(b.__key),!0)}const i=re(q(r)?r:r.getParentOrThrow(),b=>q(b)&&!b.isInline()&&wt(b.getParent()));if(i===null)return!1;const a=gt(i,o).getNodeAtCaret();if(a===null||!ef(a))return!1;if(i.getTextContentSize()===0)return ii(a.__key),!0;const l=zo().getRootElement();if(l===null)return!1;const c=or(l.ownerDocument.defaultView);if(c===null||c.rangeCount===0)return!1;const u=c.anchorNode,f=c.anchorOffset,d=c.focusNode,g=c.focusOffset;c.modify("move",e?"backward":"forward","line");const h=c.anchorNode,_=c.anchorOffset;if(h===null)return nf(c,u,f,d,g),!1;const m=Ae(h);return nf(c,u,f,d,g),m===null?!1:(h===u&&_===f||!m.is(i)&&!Xp(m,i))&&(ii(a.__key),!0)}function nf(n,e,t,r,o){e!==null&&r!==null&&n.setBaseAndExtent(e,t,r,o)}function rf(n,e){if(!n.isCollapsed())return!1;const t=n.focus.getNode(),r=re(q(t)?t:t.getParentOrThrow(),m=>q(m)&&!m.isInline());if(r===null)return!1;const o=zo(),s=o.getRootElement();if(s===null)return!1;const i=s.ownerDocument.defaultView;if(i===null)return!1;let a=!1;for(const m of r.getChildren())if(q(m)&&m.isInline()){const b=o.getElementByKey(m.getKey());if(b!==null){const w=i.getComputedStyle(b).display;if(w==="inline-grid"||w==="inline-flex"){a=!0;break}}}if(!a)return!1;const l=gt(r,e?"previous":"next").getNodeAtCaret();if(l===null||!q(l)){if(e){const m=r.getFirstDescendant();oe(m)?m.select(0,0):r.select(0,0)}else{const m=r.getLastDescendant();if(oe(m)){const b=m.getTextContentSize();m.select(b,b)}else{const b=r.getChildrenSize();r.select(b,b)}}return!0}const c=o.getElementByKey(l.getKey());if(c===null)return!1;const u=or(i);if(u===null||u.rangeCount===0)return!1;const f=u.getRangeAt(0).cloneRange();f.collapse(!0);const d=f.getBoundingClientRect(),g=c.getBoundingClientRect(),h=g.top+g.height/2;if(d.height>0){const m=El(d.left,h,s);if(m!==null&&c.contains(m.node)){const b=s.ownerDocument.createRange();return b.setStart(m.node,m.offset),b.collapse(!0),n.applyDOMRange(b),n.dirty=!0,!0}}const _=e?l.getLastDescendant():l.getFirstDescendant();if(oe(_)){const m=e?_.getTextContentSize():0;_.select(m,m)}else{const m=l.getChildrenSize();l.select(e?m:0,e?m:0)}return!0}function ai(n,e){const t=gt(n,e),r=t.getAdjacentCaret();r!==null&&q(r.origin)&&!r.origin.isInline()&&r.origin.isShadowRoot()?Ri(Gp(t)):e==="next"?n.selectNext(0,0):n.selectPrevious()}function of(n,e,t){t.preventDefault(),t.stopPropagation();const r=n.getNodes();if(r.length===0)return!0;const o=r.map(l=>gt(l,"next")).sort(Iy),s=(e?o[0]:o[o.length-1]).origin,i=re(s,l=>l!==s&&q(l)&&!l.isInline())??se(),a=e?0:i.getChildrenSize();return i.select(a,a),!0}function i_(n,e=Ac(q0)){return de(n.registerCommand(Ks,()=>{const t=D();return ve(t)?(t.clear(),!0):(F(t)&&no(t,"click","both",e.peek()),!1)},V),n.registerCommand(bi,t=>{const r=D();return F(r)?(r.deleteCharacter(t),!0):!!ve(r)&&(r.deleteNodes(),!0)},V),n.registerCommand(Yp,t=>{const r=D();return!!F(r)&&(r.deleteWord(t),!0)},V),n.registerCommand(Vp,t=>{const r=D();return!!F(r)&&(r.deleteLine(t),!0)},V),n.registerCommand(qp,t=>{const r=D();if(typeof t=="string")r!==null&&r.insertText(t);else{if(r===null)return!1;const o=t.dataTransfer;if(o!=null)wd(o,r);else if(F(r)){const s=t.data;return s&&r.insertText(s),!0}}return!0},V),n.registerCommand(Ty,()=>{const t=D();return!!F(t)&&(t.removeText(),!0)},V),n.registerCommand(Xe,t=>{const r=D();return!(!F(r)&&!ve(r))&&(ky(r,t),!0)},V),n.registerCommand(Sy,t=>{const r=D();return!(!F(r)&&!ve(r))&&(vy(r,t),!0)},V),n.registerCommand(Bn,t=>{const r=D();if(!F(r)&&!ve(r))return!1;const o=r.getNodes();for(const s of o){const i=re(s,a=>q(a)&&!a.isInline());i!==null&&i.setFormat(t)}return!0},V),n.registerCommand(Nl,t=>{const r=D();return!!F(r)&&(r.insertLineBreak(t),!0)},V),n.registerCommand(Lo,()=>{const t=D();return!!F(t)&&(t.insertParagraph(),!0)},V),n.registerCommand(Tl,()=>{const t=Kn(),r=D();return F(r)&&(t.setFormat(r.format),t.setStyle(r.style)),Tr([t]),!0},V),n.registerCommand(Dt,()=>kd(t=>{const r=t.getIndent();t.setIndent(r+1)}),V),n.registerCommand(wn,()=>kd(t=>{const r=t.getIndent();r>0&&t.setIndent(Math.max(0,r-1))}),V),n.registerCommand(pt,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],"previous"),!0}else if(F(r)&&((function(o){const s=o.focus;return s.key==="root"&&s.offset===0})(r)||!t.shiftKey&&si(r,"previous")||!t.shiftKey&&tf(r,!0)||!t.shiftKey&&rf(r,!0)))return t.preventDefault(),!0;return!1},V),n.registerCommand(Vt,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],"next"),!0}else if(F(r)&&((function(o){const s=o.focus;return s.key==="root"&&s.offset===se().getChildrenSize()})(r)||!t.shiftKey&&si(r,"next")||!t.shiftKey&&tf(r,!1)||!t.shiftKey&&rf(r,!1)))return t.preventDefault(),!0;return!1},V),n.registerCommand(zs,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],Qs(o[0])?"next":"previous"),!0}if(!F(r))return!1;if(!t.shiftKey&&si(r,Qs(r.anchor.getNode())?"next":"previous"))return t.preventDefault(),!0;if(t.shiftKey||no(r,"arrow","start",e.peek()),Sd(r,!0)){const o=t.shiftKey;return t.preventDefault(),vd(r,o,!0),!0}return!1},V),n.registerCommand(ia,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],Qs(o[0])?"previous":"next"),!0}if(!F(r))return!1;if(!t.shiftKey&&si(r,Qs(r.anchor.getNode())?"previous":"next"))return t.preventDefault(),!0;if(t.shiftKey||no(r,"arrow","end",e.peek()),Sd(r,!1)){const o=t.shiftKey;return t.preventDefault(),vd(r,o,!1),!0}return!1},V),n.registerCommand(sa,t=>{const r=D();if(!ve(r)&&Qd(t.target))return!1;if(F(r)){if((function(o){if(!o.isCollapsed())return!1;const{anchor:s}=o;if(s.offset!==0)return!1;const i=s.getNode();if(Jp(i))return!1;const a=Rc(i);return a.getIndent()>0&&(a.is(i)||i.is(a.getFirstDescendant()))})(r))return t.preventDefault(),n.dispatchCommand(wn);if(xd&&Cd)return!1}else if(!ve(r))return!1;return t.preventDefault(),n.dispatchCommand(bi,!0)},V),n.registerCommand(Oc,t=>{const r=D();return!(!ve(r)&&Qd(t.target))&&!(!F(r)&&!ve(r))&&(t.preventDefault(),n.dispatchCommand(bi,!1))},V),n.registerCommand(zr,t=>{let r=D();if(ve(r)){const o=r.getNodes();o.length===1&&It(o[0])&&!o[0].isInline()&&(r=o[0].selectNext())}if(!F(r))return!1;if(no(r,"enter","both",e.peek()),t!==null){if((xd||xy||Cy)&&Cd)return!1;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(Nl,!1)}return n.dispatchCommand(Lo)},V),n.registerCommand(Nn,()=>{const t=D();return!!F(t)&&(n.blur(),!0)},V),n.registerCommand(Lc,t=>{const[,r]=uo(t);if(r.length>0){const o=t.clientX,s=t.clientY,i=El(o,s,n.getRootElement());if(i!==null){const{offset:a,node:l}=i,c=Ae(l);if(c!==null){const u=kr();if(oe(c))u.anchor.set(c.getKey(),a,"text"),u.focus.set(c.getKey(),a,"text");else{const d=c.getParentOrThrow().getKey(),g=c.getIndexWithinParent()+1;u.anchor.set(d,g,"element"),u.focus.set(d,g,"element")}const f=Ss(u);Ee(f)}n.dispatchCommand(Xd,r)}return t.preventDefault(),!0}return wy(t,n)},V),n.registerCommand(Wp,t=>{const[r]=uo(t),o=D();return!(r&&!F(o))&&(F(o)&&!o.isCollapsed()&&t.dataTransfer!==null&&(by(t.dataTransfer,Hp(o)),yy(t.dataTransfer,n)),!0)},V),n.registerCommand(Nc,t=>{const[r]=uo(t),o=D();if(r&&!F(o))return!1;const s=t.clientX,i=t.clientY,a=El(s,i,n.getRootElement());if(a!==null){const l=Ae(a.node);It(l)&&t.preventDefault()}return!0},V),n.registerCommand(Ec,()=>{const t=D();return _y(F(t)&&my(t.anchor.getNode())!==null?t:null),!0},V),n.registerCommand(Kp,t=>(Il(n,fo(t,ClipboardEvent)?t:null),!0),V),n.registerCommand(zp,t=>((async function(r,o){await Il(o,fo(r,ClipboardEvent)?r:null),o.update(()=>{const s=D();F(s)?s.removeText():ve(s)&&s.getNodes().forEach(i=>i.remove())},{tag:hy})})(t,n),!0),V),n.registerCommand(Ic,t=>{const[,r,o]=uo(t);return r.length>0&&!o?(n.dispatchCommand(Xd,r),!0):No(t.target)&&py(t.target)?!1:D()!==null&&((function(s,i){s.preventDefault(),i.update(()=>{const a=D(),l=fo(s,InputEvent)||fo(s,KeyboardEvent)?null:s.clipboardData;l!=null&&a!==null&&wd(l,a)},{tag:Up})})(t,n),!0)},V),n.registerCommand(Bp,()=>{const t=D();return F(t)&&no(t,"space","both",e.peek()),!1},V),n.registerCommand(Kr,()=>{const t=D();return F(t)&&no(t,"tab","both",e.peek()),!1},V),n.registerCommand(xs,t=>{const r=D();if(ve(r))return of(r,!1,t);if(!F(r))return!1;const{anchor:o}=r;if(o.type!=="element"||o.offset!==0)return!1;const s=o.getNode();if(!q(s))return!1;const i=s.getFirstChild();if(!It(i)||!i.isInline())return!1;const a=s.getKey(),l=s.selectEnd();return t.shiftKey&&l.anchor.set(a,0,"element"),t.preventDefault(),t.stopPropagation(),!0},V),n.registerCommand(Ir,t=>{const r=D();if(ve(r))return of(r,!0,t);if(!F(r))return!1;const{anchor:o,focus:s}=r,i=re(s.getNode(),c=>q(c)&&!c.isInline());if(i===null)return!1;const a=i.getFirstChild();if(!It(a)||!a.isInline()||re(o.getNode(),c=>q(c)&&!c.isInline())!==i)return!1;const l=i.getKey();return(s.type!=="element"||s.key!==l||s.offset!==0)&&(r.focus.set(l,0,"element"),t.shiftKey||r.anchor.set(l,0,"element"),t.preventDefault(),t.stopPropagation(),!0)},V))}function jn(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Is(n){let e=1,t=n.getParent();for(;t!=null;){if(le(t)){const r=t.getParent();if(Z(r)){e++,t=r.getParent();continue}jn(40)}return e}return e}function Hl(n){const e=n.getParent();Z(e)||jn(40);let t=e,r=e;for(;r!==null;)r=r.getParent(),Z(r)&&(t=r);return t}function a_(n){let e=[];const t=n.getChildren().filter(le);for(let r=0;r<t.length;r++){const o=t[r],s=o.getFirstChild();Z(s)?e=e.concat(a_(s)):e.push(o)}return e}function Rt(n){return le(n)&&Z(n.getFirstChild())}function l_(n,e){return le(n)&&(e.length===0||e.length===1&&n.is(e[0])&&n.getChildrenSize()===0)}function Jl(n){const e=D();if(e!==null){let t=e.getNodes();if(F(e)){const[o]=e.getStartEndPoints(),s=o.getNode(),i=s.getParent();if(wt(s)){const a=s.getFirstChild();if(a)t=a.selectStart().getNodes();else{const l=ne();s.append(l),t=l.select().getNodes()}}else if(l_(s,t)){const a=Et(n);if(wt(i)){s.replace(a);const l=xt();q(s)&&(l.setFormat(s.getFormatType()),l.setIndent(s.getIndent())),a.append(l)}else if(le(s)){const l=s.getParentOrThrow();Nr(a,l.getChildren()),l.replace(a)}return}}const r=new Set;for(let o=0;o<t.length;o++){const s=t[o];if(q(s)&&s.isEmpty()&&!le(s)&&!r.has(s.getKey())){sf(s,n);continue}let i=Qp(s)?s.getParent():le(s)&&s.isEmpty()?s:null;for(;i!=null;){const a=i.getKey();if(Z(i)){if(!r.has(a)){const l=Et(n);Nr(l,i.getChildren()),i.replace(l),r.add(a)}break}{const l=i.getParent();if(wt(l)&&!r.has(a)){r.add(a),sf(i,n);break}i=l}}}}}function Nr(n,e){n.splice(n.getChildrenSize(),0,e)}function sf(n,e){if(Z(n))return n;const t=n.getPreviousSibling(),r=n.getNextSibling(),o=xt();let s;if(Nr(o,n.getChildren()),Z(t)&&e===t.getListType())t.append(o),Z(r)&&e===r.getListType()&&(Nr(t,r.getChildren()),r.remove()),s=t;else if(Z(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(o),s=r;else{const a=Et(e);a.append(o),n.replace(a),s=a}o.setFormat(n.getFormatType()),o.setIndent(n.getIndent());const i=D();return F(i)&&(s.getKey()===i.anchor.key&&i.anchor.set(o.getKey(),i.anchor.offset,"element"),s.getKey()===i.focus.key&&i.focus.set(o.getKey(),i.focus.offset,"element")),n.remove(),s}function Xc(n,e){const t=n.getLastChild(),r=e.getFirstChild();t&&r&&Rt(t)&&Rt(r)&&(Xc(t.getFirstChild(),r.getFirstChild()),r.remove());const o=e.getChildren();o.length>0&&n.append(...o),e.remove()}function V0(){const n=D();if(F(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(l_(r,t))e.add(Hl(r));else for(let o=0;o<t.length;o++){const s=t[o];if(Qp(s)){const i=Ol(s,bn);i!=null&&e.add(Hl(i))}}for(const o of e){let s=o;const i=a_(o);for(const a of i){const l=ne().setTextStyle(n.style).setTextFormat(n.format);Nr(l,a.getChildren()),s.insertAfter(l),s=l,a.__key===n.anchor.key&&hr(n.anchor,Jn(Er(l,"next"))),a.__key===n.focus.key&&hr(n.focus,Jn(Er(l,"next"))),a.remove()}o.remove()}}}function c_(n){const e=n.getListType()!=="check";let t=n.getStart();for(const r of n.getChildren())le(r)&&(r.getValue()!==t&&r.setValue(t),e&&r.getLatest().__checked!=null&&r.setChecked(void 0),Z(r.getFirstChild())||t++)}function Y0(n){const e=new Set;if(Rt(n)||e.has(n.getKey()))return;const t=n.getParent(),r=n.getNextSibling(),o=n.getPreviousSibling();if(Rt(r)&&Rt(o)){const s=o.getFirstChild();if(Z(s)){s.append(n);const i=r.getFirstChild();Z(i)&&(Nr(s,i.getChildren()),r.remove(),e.add(r.getKey()))}}else if(Rt(r)){const s=r.getFirstChild();if(Z(s)){const i=s.getFirstChild();i!==null&&i.insertBefore(n)}}else if(Rt(o)){const s=o.getFirstChild();Z(s)&&s.append(n)}else if(Z(t)){const s=it(n),i=it(t);s.append(i),i.append(n),o?o.insertAfter(s):r?r.insertBefore(s):t.append(s)}}function af(n){if(Rt(n))return;const e=n.getParent(),t=e?e.getParent():void 0;if(Z(t?t.getParent():void 0)&&le(t)&&Z(e)){const r=e?e.getFirstChild():void 0,o=e?e.getLastChild():void 0;if(n.is(r))t.insertBefore(n),e.isEmpty()&&t.remove();else if(n.is(o))t.insertAfter(n),e.isEmpty()&&t.remove();else{const s=it(n),i=it(e);s.append(i),n.getPreviousSiblings().forEach(c=>i.append(c));const a=it(n),l=it(e);a.append(l),Nr(l,n.getNextSiblings()),t.insertBefore(s),t.insertAfter(a),t.replace(n)}}}function G0(n=!1){const e=D();if(!F(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();let r=null;if(le(t)&&t.getChildrenSize()===0)r=t;else if(oe(t)){const c=t.getParent();le(c)&&c.getChildren().every(u=>oe(u)&&u.getTextContent().trim()==="")&&(r=c)}if(r===null)return!1;const o=Hl(r),s=r.getParent();Z(s)||jn(40);const i=s.getParent();let a;if(wt(i))a=ne(),o.insertAfter(a);else{if(!le(i))return!1;a=it(i),i.insertAfter(a)}a.setTextStyle(e.style).setTextFormat(e.format).select();const l=r.getNextSiblings();if(l.length>0){const c=n?(function(f,d){return f.getStart()+d.getIndexWithinParent()})(s,r):1,u=it(s).setStart(c);if(le(a)){const f=it(a);f.append(u),a.insertAfter(f)}else a.insertAfter(u);u.append(...l)}return(function(c){let u=c;for(;u.getNextSibling()==null&&u.getPreviousSibling()==null;){const f=u.getParent();if(f==null||!le(f)&&!Z(f))break;u=f}u.remove()})(r),!0}let bn=class extends Oe{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const t=e.getParent();if(Z(t))t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0);else if(t){const r=e.createParentElementNode();Z(r)||jn(340);const o=[e];for(const s of["previous","next"]){o.reverse();for(const{origin:i}of gt(e,s)){if(!le(i))break;o.push(i)}}e.insertBefore(r),r.splice(0,0,o),wt(t)||(Zp(r,Dc(gt(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),t.isEmpty()&&t.isAttached()&&t.remove())}},extends:Oe,importDOM:$c({li:()=>({conversion:X0,priority:0})})})}constructor(e=1,t=void 0,r){super(r),this.__value=e===void 0?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=Je().createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,r){(function(i,a){const l=a.getParent();!Z(l)||l.getListType()!=="check"||Z(a.getFirstChild())?(i.removeAttribute("role"),i.removeAttribute("tabIndex"),i.removeAttribute("aria-checked")):(i.setAttribute("role","checkbox"),i.setAttribute("tabIndex","-1"),i.setAttribute("aria-checked",a.getChecked()?"true":"false"))})(t,this),t.value=this.__value,(function(i,a,l){const c=a.list;if(!c)return;const u=c.listitem,f=c.nested&&c.nested.listitem,d=l.getParent(),g=Z(d)&&d.getListType()==="check",h=l.getChecked(),_=l.getChildren().some(w=>Z(w)),m=[];c.listitemChecked!==void 0&&m.push(c.listitemChecked),c.listitemUnchecked!==void 0&&m.push(c.listitemUnchecked),f!==void 0&&m.push(...ps(f)),m.length>0&&$t(i,...m);const b=[];if(u!==void 0&&b.push(...ps(u)),g){const w=h?c.listitemChecked:c.listitemUnchecked;w!==void 0&&b.push(w)}f!==void 0&&_&&b.push(...ps(f)),b.length>0&&Ie(i,...b)})(t,r.theme,this);const o=e?e.__style:"",s=this.__style;o!==s&&_o(t.style,s,o),(function(i,a,l){const c=a.__textStyle,u=l?l.__textStyle:"";if(l!==null&&u===c)return;const f=Td(c);for(const d in f)i.style.setProperty(`--listitem-marker-${d}`,f[d]);if(u!=="")for(const d in Td(u))d in f||i.style.removeProperty(`--listitem-marker-${d}`)})(t,this,e)}updateDOM(e,t,r){const o=t;return this.updateListItemDOM(e,o,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();return o&&(t.dir=o),Rt(this)?{after(s){if(ke(s)){const i=s.previousElementSibling;if(ke(i)&&i.nodeName==="LI"){for(;s.firstChild;)i.append(s.firstChild);s.remove()}}return s},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const r=e[t];if(q(r)&&this.canMergeWith(r)){const o=r.getChildren();this.append(...o),r.remove()}else super.append(r)}return this}replace(e,t){if(le(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!Z(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const i=it(r);let a=this.getNextSibling();for(;a;){const l=a;a=a.getNextSibling(),i.append(l)}r.insertAfter(e),e.insertAfter(i)}const o=this.__key;let s=0;if(t&&(q(e)||jn(139),s=e.getChildrenSize(),e.splice(s,0,this.getChildren())),t&&q(e)){const i=D();if(F(i))for(const a of i.getStartEndPoints())a.key===o&&a.type==="element"&&a.set(e.getKey(),s+a.offset,"element")}return this.remove(),r.getChildrenSize()===0&&r.remove(),e}insertAfter(e,t=!0){const r=this.getParentOrThrow();if(Z(r)||jn(39),le(e))return super.insertAfter(e,t);const o=this.getNextSiblings();if(r.insertAfter(e,t),o.length!==0){const s=it(r);o.forEach(i=>s.append(i)),e.insertAfter(s,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&Rt(t)&&Rt(r)&&(Xc(t.getFirstChild(),r.getFirstChild()),r.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const r=it(this);return this.insertAfter(r,t),r}collapseAtStart(e){if(Rt(this))return!1;const t=this.getParentOrThrow();if(le(t.getParentOrThrow()))return af(this),!0;const r=ne().append(...this.getChildren()),o=this.getNextSiblings();if(o.length>0){const s=it(t);s.append(...o),t.insertAfter(s)}return t.insertAfter(r),this.remove(),t.getChildrenSize()===0&&t.remove(),r.selectStart(),!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const r=this.getParent();return Z(r)&&(t=r.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(e===null||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),r=0;for(;le(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){typeof e!="number"&&jn(117),(e=Math.floor(e))>=0||jn(199);let t=this.getIndent();for(;t!==e;)t<e?(Y0(this),t++):(af(this),t--);return this}canInsertAfter(e){return le(e)}canReplaceWith(e){return le(e)}canMergeWith(e){return le(e)||ht(e)}extractWithChild(e,t){if(!F(t))return!1;const r=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(o)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Et("bullet")}canMergeWhenEmpty(){return!0}};function X0(n){if(n.classList.contains("task-list-item")){for(const r of n.children)if(r.tagName==="INPUT")return lf(r)}if(n.classList.contains("joplin-checkbox")){for(const r of n.children)if(r.classList.contains("checkbox-wrapper")&&r.children.length>0&&r.children[0].tagName==="INPUT")return lf(r.children[0])}const e=n.getAttribute("aria-checked"),t=xt(e==="true"||e!=="false"&&void 0);return rr(t,n),{after:u_.bind(null,t),node:mn(t,n)}}function lf(n){if(n.getAttribute("type")!=="checkbox")return{node:null};const e=xt(n.hasAttribute("checked"));return{after:u_.bind(null,e),node:e}}function u_(n,e){const t=e[0];return e.length===1&&ht(t)&&!n.getFormatType()&&t.getFormatType()?(n.setFormat(t.getFormatType()),t.getChildren()):e}function xt(n){return Ot(new bn(void 0,n))}function le(n){return n instanceof bn}let Yt=class extends Oe{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{(function(t){const r=t.getNextSibling();Z(r)&&t.getListType()===r.getListType()&&Xc(t,r)})(e),c_(e)},extends:Oe,importDOM:$c({ol:()=>({conversion:uf,priority:0}),ul:()=>({conversion:uf,priority:0})})})}constructor(e="number",t=1,r){super(r);const o=Z0[e]||e;this.__listType=o,this.__tag=o==="number"?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag=e==="number"?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const r=this.__tag,o=Je().createElement(r);return this.__start!==1&&o.setAttribute("start",String(this.__start)),o.__lexicalListType=this.__listType,cf(o,e.theme,this),o}updateDOM(e,t,r){return e.__tag!==this.__tag||e.__listType!==this.__listType||(cf(t,r.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return ke(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,r){let o=r;for(let s=0;s<r.length;s++){const i=r[s];le(i)||(o===r&&(o=[...r]),o[s]=this.createListItemNode().append(!q(i)||Z(i)||i.isInline()?i:$e(i.getTextContent())))}return super.splice(e,t,o)}extractWithChild(e){return le(e)}createListItemNode(){return xt()}};function cf(n,e,t){const r=[],o=[],s=e.list;if(s!==void 0){const i=s[`${t.__tag}Depth`]||[],a=Is(t)-1,l=a%i.length,c=i[l],u=s[t.__tag];let f;const d=s.nested,g=s.checklist;if(d!==void 0&&d.list&&(f=d.list),u!==void 0&&r.push(u),g!==void 0&&t.__listType==="check"&&r.push(g),c!==void 0){r.push(...ps(c));for(let h=0;h<i.length;h++)h!==l&&o.push(t.__tag+h)}if(f!==void 0){const h=ps(f);a>1?r.push(...h):o.push(...h)}}o.length>0&&$t(n,...o),r.length>0&&Ie(n,...r)}function uf(n){let e;if((function(t){return ke(t)&&t.nodeName.toLowerCase()==="ol"})(n)){const t=n.start;e=Et("number",t)}else e=(function(t){if(t.getAttribute("__lexicallisttype")==="check"||t.classList.contains("contains-task-list")||t.getAttribute("data-is-checklist")==="1")return!0;for(const r of t.childNodes)if(ke(r)&&r.hasAttribute("aria-checked"))return!0;return!1})(n)?Et("check"):Et("bullet");return mn(e,n),{after:t=>(function(r,o){const s=o.createListItemNode.bind(o),i=[];for(let a=0;a<r.length;a++){const l=r[a];if(le(l)){i.push(l);const c=l.getChildren();c.length>1&&c.forEach(u=>{Z(u)&&i.push(s().append(u))})}else i.push(s().append(l))}return i})(t,e),node:e}}const Z0={ol:"number",ul:"bullet"};function Et(n="number",e=1){return Ot(new Yt(n,e))}function Z(n){return n instanceof Yt}const Zc=he("INSERT_CHECK_LIST_COMMAND");function Q0(n,e){const t=e&&e.disableTakeFocusOnClick||!1,r=typeof t=="boolean"?()=>t:t.peek.bind(t),o=c=>{const u=c.target;if(!ke(u))return!1;const f=u.__lexicalCheckListLastHandled;return f!==void 0&&c.timeStamp-f<500},s=c=>{const u=c.target;ke(u)&&(u.__lexicalCheckListLastHandled=c.timeStamp)},i=c=>{o(c)||(s(c),df(c,r()))},a=c=>{c.pointerType==="touch"&&(o(c)||(s(c),df(c,r())))},l=c=>{(function(u,f){d_(u,()=>{u.preventDefault(),f&&u.stopPropagation()})})(c,r())};return de(n.registerCommand(Zc,()=>(Jl("check"),!0),ee),n.registerCommand(Vt,c=>ff(c,n,!1),ee),n.registerCommand(pt,c=>ff(c,n,!0),ee),n.registerCommand(Nn,()=>{if(ql(n)!=null){const c=n.getRootElement();return c?.focus(),!0}return!1},ee),n.registerCommand(Bp,c=>{const u=ql(n);return!(u==null||!n.isEditable())&&(n.update(()=>{const f=Ae(u);le(f)&&(c.preventDefault(),f.toggleChecked())}),!0)},ee),n.registerCommand(zs,c=>n.read("latest",()=>{const u=D();if(F(u)&&u.isCollapsed()){const{anchor:f}=u,d=f.type==="element";if(d||f.offset===0){const g=f.getNode(),h=re(g,_=>q(_)&&!_.isInline());if(le(h)){const _=h.getParent();if(Z(_)&&_.getListType()==="check"&&(d||h.getFirstDescendant()===g)){const m=n.getElementByKey(h.__key);if(m!=null&&la(m)!==m)return m.focus(),c.preventDefault(),!0}}}}return!1}),ee),n.registerRootListener(c=>{if(c!==null)return de(Id(c,{click:i,pointerup:a}),Id(c,{mousedown:l,pointerdown:l},{capture:!0}),Jt(c,"touchstart",l,{capture:!0,passive:!1}))}))}function d_(n,e){const t=n.target;if(!ke(t))return;const r=t.firstChild;if(ke(r)&&(r.tagName==="UL"||r.tagName==="OL"))return;const o=t.parentNode;if(!o||o.__lexicalListType!=="check")return;let s=null,i=null;if("clientX"in n)s=n.clientX;else if("touches"in n){const g=n.touches;g.length>0&&(s=g[0].clientX,i="touch")}if(s==null)return;const a=t.getBoundingClientRect(),l=s/Wn(t),c=t.ownerDocument.defaultView,u=c?c.getComputedStyle(t,"::before"):{width:"0px"},f=parseFloat(u.width),d=i==="touch"||"pointerType"in n&&n.pointerType==="touch"?32:0;(t.dir==="rtl"?l<a.right+d&&l>a.right-f-d:l>a.left-d&&l<a.left+f+d)&&e()}function df(n,e){d_(n,()=>{if(ke(n.target)){const t=n.target,r=Oy(t);r!=null&&r.isEditable()&&r.update(()=>{const o=Ae(t);le(o)&&(e?(Ai(Ry),Ai(Ay)):t.focus(),o.toggleChecked())})}})}function ql(n){const e=n.getRootElement(),t=e?la(e):null;return ke(t)&&t.tagName==="LI"&&t.parentNode!=null&&t.parentNode.__lexicalListType==="check"?t:null}function ff(n,e,t){const r=ql(e);return r!=null&&e.update(()=>{const o=Ae(r);if(!le(o))return;const s=(function(i,a){let l=a?i.getPreviousSibling():i.getNextSibling(),c=i;for(;l==null&&le(c);)c=c.getParentOrThrow().getParent(),c!=null&&(l=a?c.getPreviousSibling():c.getNextSibling());for(;le(l);){const u=a?l.getLastChild():l.getFirstChild();if(!Z(u))return l;l=a?u.getLastChild():u.getFirstChild()}return null})(o,t);if(s!=null){s.selectStart();const i=e.getElementByKey(s.__key);i!=null&&(n.preventDefault(),setTimeout(()=>{i.focus()},0))}}),!1}function eC(n){const e=[];for(const t of n)if(le(t)){e.push(t);const r=t.getChildren();if(r.length>1)for(const o of r)Z(o)&&e.push(xt().append(o))}else e.push(xt().append(t));return e}const tC=Ye({$import:(n,e)=>{let t;var r;return eh(e,"ol")?t=Et("number",e.start):t=(r=e).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||r.querySelector(":scope > [aria-checked]")!==null?Et("check"):Et("bullet"),mn(t,e),[t.splice(0,0,th(eC(n.$importChildren(e)),e))]},match:Ge.tag("ol","ul"),name:"@lexical/list/list"});function f_(n,e){if(e.length!==1)return e;const t=e[0];return ht(t)&&!n.getFormatType()&&t.getFormatType()?(n.setFormat(t.getFormatType()),t.getChildren()):e}function g_(n){const e=i=>Ly(i)&&!Z(i);if(!n.some(e))return n;const t=[];let r=[];const o=()=>{r.length>0&&(t.push(r),r=[])};for(const i of n)e(i)?(o(),t.push(q(i)?i.getChildren():[i])):r.push(i);o();const s=[];for(const i of t)s.length>0&&s.push(vt()),s.push(...i);return s}const nC=Ye({$import:(n,e)=>{const t=e.getAttribute("aria-checked"),r=xt(t==="true"||t!=="false"&&void 0);return rr(r,e),mn(r,e),[r.splice(0,0,g_(f_(r,n.$importChildren(e))))]},match:Ge.tag("li"),name:"@lexical/list/li"});function gf(n,e,t){const r=eh(t,"input")?t:t.querySelector('input[type="checkbox"]');if(!r||r.getAttribute("type")!=="checkbox")return[];const o=xt(r.hasAttribute("checked"));return rr(o,e),mn(o,e),[o.splice(0,0,g_(f_(o,n.$importChildren(e))))]}const rC=[Ye({$import:(n,e,t)=>{const r=e.querySelector(':scope > input[type="checkbox"]');return r?gf(n,e,r):t()},match:Ge.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),Ye({$import:(n,e,t)=>{const r=e.querySelector(":scope > .checkbox-wrapper");if(!r)return t();const o=r.querySelector(':scope > input[type="checkbox"]');return o?gf(n,e,o):t()},match:Ge.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),tC,nC],oC=he("UPDATE_LIST_START_COMMAND"),Qc=he("INSERT_UNORDERED_LIST_COMMAND"),eu=he("INSERT_ORDERED_LIST_COMMAND"),sC=he("REMOVE_LIST_COMMAND");function iC(n,e){return de(n.registerCommand(eu,()=>(Jl("number"),!0),ee),n.registerCommand(oC,t=>{const{listNodeKey:r,newStart:o}=t,s=Q(r);return!!Z(s)&&(s.getListType()==="number"&&(s.setStart(o),c_(s)),!0)},ee),n.registerCommand(Qc,()=>(Jl("bullet"),!0),ee),n.registerCommand(sC,()=>(V0(),!0),ee),n.registerCommand(Lo,()=>G0(!!(e&&e.restoreNumbering)),ee),n.registerCommand(sa,t=>{const r=D();if(!F(r)||!r.isCollapsed())return!1;const{anchor:o}=r;if(o.offset!==0)return!1;let s=o.getNode();for(;!le(s);){if(s.getPreviousSibling()!==null)return!1;const i=s.getParent();if(i===null)return!1;s=i}return!(!le(s)||!s.collapseAtStart(r))&&(t.preventDefault(),!0)},My),n.registerNodeTransform(bn,t=>{const r=t.getFirstChild();if(r){if(oe(r)){const o=r.getStyle(),s=r.getFormat();t.getTextStyle()!==o&&t.setTextStyle(o),t.getTextFormat()!==s&&t.setTextFormat(s)}}else{const o=D();F(o)&&(o.style!==t.getTextStyle()||o.format!==t.getTextFormat())&&o.isCollapsed()&&t.is(o.anchor.getNode())&&t.setTextStyle(o.style).setTextFormat(o.format)}}),n.registerNodeTransform(cn,t=>{const r=t.getParent();if(le(r)&&t.is(r.getFirstChild())){const o=t.getStyle(),s=t.getFormat();o===r.getTextStyle()&&s===r.getTextFormat()||r.setTextStyle(o).setTextFormat(s)}}))}function aC(n){const e=t=>{const r=t.getParent();if(Z(t.getFirstChild())||!Z(r))return;const o=re(t,s=>le(s)&&Z(s.getParent())&&le(s.getPreviousSibling()));if(o===null&&t.getIndent()>0)t.setIndent(0);else if(le(o)){const s=o.getPreviousSibling();if(le(s)){const i=(function(l){let c=l,u=c.getFirstChild();for(;Z(u);){const f=u.getLastChild();if(!le(f))break;c=f,u=c.getFirstChild()}return c})(s),a=i.getParent();if(Z(a)){const l=Is(a);l+1<Is(r)&&t.setIndent(l)}}}};return n.registerNodeTransform(Yt,t=>{const r=[t];for(;r.length>0;){const o=r.shift();if(Z(o)){for(const s of o.getChildren())if(le(s)){e(s);const i=s.getFirstChild();Z(i)&&r.push(i)}}}})}const da=pe({build:(n,e,t)=>nr(e),config:tr({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[js,ln(Fs,{rules:rC})],name:"@lexical/list/List",nodes:()=>[Yt,bn],register(n,e,t){const r=t.getOutput();return de(zt(()=>iC(n,{restoreNumbering:r.shouldPreserveNumbering.value})),zt(()=>r.hasStrictIndent.value?aC(n):void 0))}}),lC=pe({build:(n,e)=>nr(e),config:tr({disableTakeFocusOnClick:!1}),dependencies:[da],name:"@lexical/list/CheckList",register:(n,e,t)=>Q0(n,t.getOutput())}),pf=new Set(["http:","https:","mailto:","sms:","tel:"]);class gn extends Oe{__url;__target;__rel;__title;$config(){return this.config("link",{extends:Oe,importDOM:{a:()=>({conversion:uC,priority:1})}})}constructor(e="",t={},r){super(r);const{target:o=null,rel:s=null,title:i=null}=t;this.__url=e,this.__target=o,this.__rel=s,this.__title=i}afterCloneFrom(e){super.afterCloneFrom(e),this.__url=e.__url,this.__rel=e.__rel,this.__target=e.__target,this.__title=e.__title}createDOM(e){const t=Je().createElement("a");return this.updateLinkDOM(null,t,e),Ie(t,e.theme.link),t}updateLinkDOM(e,t,r){if(nh(t)){e&&e.__url===this.__url||(t.href=this.sanitizeUrl(this.__url));for(const o of["target","rel","title"]){const s=`__${o}`,i=this[s];e&&e[s]===i||(i?t[o]=i:t.removeAttribute(o))}}}updateDOM(e,t,r){return this.updateLinkDOM(e,t,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){const t=e;e=bf(e);try{const r=new URL(bf(e));if(!pf.has(r.protocol))return"about:blank"}catch{const o=t.replace(/[\u0000-\u001F\u007F\s]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);if(o!=null&&!pf.has(`${o[1].toLowerCase()}:`))return"about:blank"}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const t=this.getWritable();return t.__url=e,t}getTarget(){return this.getLatest().__target}setTarget(e){const t=this.getWritable();return t.__target=e,t}getRel(){return this.getLatest().__rel}setRel(e){const t=this.getWritable();return t.__rel=e,t}getTitle(){return this.getLatest().__title}setTitle(e){const t=this.getWritable();return t.__title=e,t}insertNewAfter(e,t=!0){const r=it(this);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!F(t))return!1;const o=t.anchor.getNode(),s=t.focus.getNode();return(this.is(o)||this.isParentOf(o))&&(this.is(s)||this.isParentOf(s))&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}shouldMergeAdjacentLink(e){return this.getType()===e.getType()&&this.__url===e.__url&&this.__target===e.__target&&this.__rel===e.__rel&&this.__title===e.__title}}function hf(n){const e=vs(n,"next");return[e,e.getFlipped()]}function _f(n,e){for(const t of e)if(t.origin.isAttached()){const r=Jn(t);return void hr(n,r)}}function cC(n){const e=D();let t=null,r=null;function o(){F(e)&&(_f(e.anchor,t),_f(e.focus,r),Ss(e))}F(e)&&(t=hf(e.anchor),r=hf(e.focus));let s=!1;for(const a of Er(n,"next")){const l=a.origin;if(q(l)&&!l.isInline()){const c=l.getChildren();if(c.length>0){const u=it(n);u.append(...c),l.append(u),s=!0}Zp(l,Dc(a),{$shouldSplit:()=>!1})}}function i(a,l,c){const[u,f]=a,d=h=>Mc(h)&&h.origin.is(l);if(!d(u)&&!d(f))return a;const g=Jn(Er(c,"next"));return[g,g.getFlipped()]}if(n.isAttached()){const a=n.getPreviousSibling();if(Pe(a)&&a.shouldMergeAdjacentLink(n))return t&&(t=i(t,a,n)),r&&(r=i(r,a,n)),a.append(...n.getChildren()),n.remove(),void o();const l=n.getNextSibling();Pe(l)&&n.shouldMergeAdjacentLink(l)&&(t&&(t=i(t,n,l)),r&&(r=i(r,n,l)),n.append(...l.getChildren()),l.remove(),s=!0)}if(s){if(!n.canBeEmpty()&&n.isEmpty()){const a=n.getParent();n.remove(),a&&a.isEmpty()&&a.remove()}o()}}function uC(n){let e=null;if(nh(n)){const t=n.textContent;(t!==null&&t!==""||n.children.length>0)&&(e=Mo(n.getAttribute("href")||"",{rel:n.getAttribute("rel"),target:n.getAttribute("target"),title:n.getAttribute("title")}))}return{node:e}}function Mo(n="",e){return Ot(new gn(n,e))}function Pe(n){return n instanceof gn}let fa=class extends gn{__isUnlinked;constructor(e="",t={},r){super(e,t,r),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}afterCloneFrom(e){super.afterCloneFrom(e),this.__isUnlinked=e.__isUnlinked}$config(){return this.config("autolink",{extends:gn})}shouldMergeAdjacentLink(e){return!1}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?Je().createElement("span"):super.createDOM(e)}updateDOM(e,t,r){return super.updateDOM(e,t,r)||e.__isUnlinked!==this.__isUnlinked}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,t=!0){const r=p_(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,t),r}};function p_(n="",e){return Ot(new fa(n,e))}function _t(n){return n instanceof fa}const Lr=he("TOGGLE_LINK_COMMAND");function mf(n,e){if(n.type==="element"){const t=n.getNode();return q(t)||(function(r,...o){const s=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",r);for(const a of o)i.append("v",a);throw s.search=i.toString(),Error(`Minified Lexical error #${r}; visit ${s.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(252),t.getChildren()[n.offset+e]||null}return null}function Ka(n,e={}){let t;if(n&&typeof n=="object"){const{url:u,...f}=n;t=u,e={...f,...e}}else t=n;const{target:r,title:o}=e,s=e.rel===void 0?"noreferrer":e.rel,i=D();if(i===null||!F(i)&&!ve(i))return;if(ve(i)){const u=i.getNodes();return u.length===0?void 0:void u.forEach(f=>{if(t===null){const d=re(f,g=>!_t(g)&&Pe(g));d&&(d.insertBefore(f),d.getChildren().length===0&&d.remove())}else{const d=re(f,g=>!_t(g)&&Pe(g));if(d)d.setURL(t),r!==void 0&&d.setTarget(r),s!==void 0&&d.setRel(s);else{const g=Mo(t,{rel:s,target:r});f.insertBefore(g),g.append(f)}}})}if(i.isCollapsed()&&t===null)for(const u of i.getNodes()){const f=re(u,d=>!_t(d)&&Pe(d));return void(f!==null&&(f.getParentOrThrow().splice(f.getIndexWithinParent(),0,f.getChildren()),f.remove()))}const a=i.extract();if(t===null){const u=new Set;return void a.forEach(f=>{const d=re(f,g=>!_t(g)&&Pe(g));if(d!==null){const g=d.getKey();if(u.has(g))return;(function(h,_){const m=new Set(_.filter(N=>h.isParentOf(N)).map(N=>N.getKey())),b=h.getChildren(),w=N=>m.has(N.getKey())||q(N)&&_.some(O=>h.isParentOf(O)&&N.isParentOf(O)),C=b.filter(w);if(C.length===b.length)return b.forEach(N=>h.insertBefore(N)),void h.remove();const v=b.findIndex(w),k=b.findLastIndex(w),I=v===0,E=k===b.length-1;if(I)C.forEach(N=>h.insertBefore(N));else if(E)for(let N=C.length-1;N>=0;N--)h.insertAfter(C[N]);else{for(let O=C.length-1;O>=0;O--)h.insertAfter(C[O]);const N=b.slice(k+1);if(N.length>0){const O=it(h);C[C.length-1].insertAfter(O),N.forEach(M=>O.append(M))}}})(d,a),u.add(g)}})}const l=new Set,c=u=>{l.has(u.getKey())||(l.add(u.getKey()),u.setURL(t),r!==void 0&&u.setTarget(r),s!==void 0&&u.setRel(s),o!==void 0&&u.setTitle(o))};if(a.length===1){const u=a[0],f=re(u,Pe);if(f!==null)return c(f)}(function(u){const f=D();if(!F(f))return u();const d=Ss(f),g=d.isBackward(),h=mf(d.anchor,g?-1:0),_=mf(d.focus,g?0:-1);if(u(),h||_){const m=D();if(F(m)){const b=m.clone();if(h){const w=h.getParent();w&&b.anchor.set(w.getKey(),h.getIndexWithinParent()+(g?1:0),"element")}if(_){const w=_.getParent();w&&b.focus.set(w.getKey(),_.getIndexWithinParent()+(g?0:1),"element")}Ee(Ss(b))}}})(()=>{let u=null;for(const f of a){if(!f.isAttached())continue;const d=re(f,Pe);if(d){c(d);continue}if(q(f)){if(!f.isInline())continue;if(Pe(f)){if(!(_t(f)||u!==null&&u.getParentOrThrow().isParentOf(f))){c(f),u=f;continue}for(const h of f.getChildren())f.insertBefore(h);f.remove();continue}}const g=f.getPreviousSibling();Pe(g)&&g.is(u)?g.append(f):(u=Mo(t,{rel:s,target:r,title:o}),f.insertAfter(u),u.append(f))}})}const dC=/^\+?[0-9\s()-]{5,}$/;function bf(n){return n.match(/^[a-z][a-z0-9+.-]*:/i)||n.match(/^[/#.]/)?n:n.includes("@")?`mailto:${n}`:dC.test(n)?`tel:${n}`:`https://${n}`}const fC=[Ye({$import:(n,e)=>{if(!e.textContent&&e.children.length===0)return[];const t=e.getAttribute("href")||"",r={rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")};return $y(n.$importChildren(e),()=>Mo(t,r))},match:Ge.tag("a"),name:"@lexical/link/a"})];function h_(n,e){return de(n.registerNodeTransform(gn,cC),n.registerCommand(Lr,t=>{const r=e.validateUrl.peek(),o=e.attributes.peek();if(t===null)return Ka(null),!0;if(typeof t=="string")return!(r!==void 0&&!r(t))&&(Ka(t,o),!0);{const{url:s,target:i,rel:a,title:l}=t;return Ka(s,{...o,rel:a,target:i,title:l}),!0}},V),zt(()=>{const t=e.validateUrl.value;if(!t)return;const r=e.attributes.value;return n.registerCommand(Ic,o=>{const s=D();if(!F(s)||s.isCollapsed()||!fo(o,ClipboardEvent)||o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return t(i)?!s.getNodes().some(a=>q(a)||oe(a)&&!a.isSimpleText())&&(n.dispatchCommand(Lr,{...r,url:i}),o.preventDefault(),!0):!1},ee)}))}const tu=pe({build:(n,e,t)=>nr(e),config:{attributes:void 0,validateUrl:void 0},dependencies:[js,ln(Fs,{rules:fC})],mergeConfig(n,e){const t=Eo(n,e);return n.attributes&&(t.attributes=Eo(n.attributes,t.attributes)),t},name:"@lexical/link/Link",nodes:()=>[gn],register:(n,e,t)=>h_(n,t.getOutput())});function Vl(n,e){for(let t=0;t<e.length;t++){const r=e[t](n);if(r)return r}return null}const __=/[.,;\s]/;function Bi(n,e){return e.test(n)}function m_(n,e){return Bi(n[n.length-1],e)}function Yl(n,e){return Bi(n[0],e)}function b_(n,e){let t=n.getPreviousSibling();return q(t)&&(t=t.getLastDescendant()),t===null||ue(t)||oe(t)&&m_(t.getTextContent(),e)}function y_(n,e){let t=n.getNextSibling();return q(t)&&(t=t.getFirstDescendant()),t===null||ue(t)||oe(t)&&Yl(t.getTextContent(),e)}function gC(n,e,t,r,o){return(n>0?Bi(r[n-1],t):b_(o[0],t))?e<r.length?Bi(r[e],t):y_(o[o.length-1],t):!1}function pC(n,e,t){const r=[],o=[],s=[];let i=0,a=0;const l=[...n];for(;l.length>0;){const c=l[0],u=c.getTextContent().length,f=a;a+u<=e?(r.push(c),i+=u):f>=t?s.push(c):o.push(c),a+=u,l.shift()}return[i,r,o,s]}function hC(n,e,t,r){const o=p_(r.url,r.attributes);if(n.length===1){let s,i=n[0];e===0?[s,i]=i.splitText(t):[,s,i]=i.splitText(e,t);const a=$e(r.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),o.append(a),s.replace(o),i}if(n.length>1){const s=n[0];let i,a=s.getTextContent().length;e===0?i=s:[,i]=s.splitText(e);const l=[];let c;for(let g=1;g<n.length;g++){const h=n[g],_=h.getTextContent().length,m=a;if(m<t)if(a+_<=t)l.push(h);else{const[b,w]=h.splitText(t-m);l.push(b),c=w}a+=_}const u=D(),f=u?u.getNodes().find(oe):void 0,d=$e(i.getTextContent());return d.setFormat(i.getFormat()),d.setDetail(i.getDetail()),d.setStyle(i.getStyle()),o.append(d,...l),f&&f===i&&(F(u)?d.select(u.anchor.offset,u.focus.offset):ve(u)&&d.select(0,d.getTextContent().length)),i.replace(o),c}}function yf(n,e,t,r){const o=n.getChildren(),s=o.length;for(let c=0;c<s;c++){const u=o[c];if(!oe(u)||!u.isSimpleText())return _s(n),void t(null,n.getURL())}const i=n.getTextContent(),a=Vl(i,e);if(a===null||a.text!==i||!b_(n,r)||!y_(n,r))return _s(n),void t(null,n.getURL());const l=n.getURL();if(l!==a.url&&(n.setURL(a.url),t(a.url,l)),a.attributes){const c=n.getRel();c!==a.attributes.rel&&(n.setRel(a.attributes.rel||null),t(a.attributes.rel||null,c));const u=n.getTarget();u!==a.attributes.target&&(n.setTarget(a.attributes.target||null),t(a.attributes.target||null,u))}}function _s(n){const e=n.getChildren();for(let t=e.length-1;t>=0;t--)n.insertAfter(e[t]);return n.remove(),e.map(t=>t.getLatest())}const w_={changeHandlers:[],excludeParents:[],matchers:[],separatorRegex:__};function _C(n,e=w_){const{matchers:t,changeHandlers:r,excludeParents:o,separatorRegex:s=__}=e,i=(a,l)=>{for(const c of r)c(a,l)};return de(n.registerNodeTransform(cn,a=>{const l=a.getParentOrThrow(),c=a.getPreviousSibling();if(_t(l))yf(l,t,i,s);else if(!Pe(l)&&!o.some(u=>u(l))){if(a.isSimpleText()&&(Yl(a.getTextContent(),s)||!_t(c))){const u=(function(f){const d=[f];let g=f.getNextSibling();for(;g!==null&&oe(g)&&g.isSimpleText()&&(d.push(g),!/[\s]/.test(g.getTextContent()));)g=g.getNextSibling();return d})(a);(function(f,d,g,h){for(const v of f){const k=v.getParent();if(_t(k)&&!k.getIsUnlinked())return}let _=[...f];const m=_.map(v=>v.getTextContent()).join("");let b,w=m,C=0;for(;(b=Vl(w,d))&&b!==null;){const v=b.index,k=v+b.length;if(gC(C+v,C+k,h,m,_)){const[I,,E,N]=pC(_,C+v,C+k);let O=!1;for(const R of E){const $=R.getParent();if(_t($)&&!$.getIsUnlinked()){O=!0;break}}if(O){C+=k,w=w.substring(k);continue}const M=hC(E,C+v-I,C+k-I,b);_=M?[M,...N]:N,g(b.url,null),C=0}else C+=k;w=w.substring(k)}})(u,t,i,s)}(function(u,f,d,g){const h=u.getParent(),_=u.getPreviousSibling(),m=u.getNextSibling(),b=u.getTextContent();if(!_t(h)||h.getIsUnlinked()){if(_t(_)&&!_.getIsUnlinked()&&_.is(u.getPreviousSibling())&&u.getParent()===_.getParent()){if(!Yl(b,g))return _s(_),void d(null,_.getURL());if(w=b,_.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(w):/^\.[a-zA-Z0-9]{1,}/.test(w)){const C=_.getTextContent()+b,v=Vl(C,f);v!==null&&v.text===C&&(_.append(u),yf(_,f,d,g),d(null,_.getURL()))}}var w;!_t(m)||m.getIsUnlinked()||m_(b,g)||m.is(u.getNextSibling())&&u.getParent()===m.getParent()&&(_s(m),d(null,m.getURL()))}})(a,t,i,s)}}),n.registerCommand(Lr,a=>{const l=D();return a!==null||!F(l)||l.extract().forEach(c=>{const u=c.getParent();_t(u)&&(u.setIsUnlinked(!u.getIsUnlinked()),u.markDirty())}),!1},ee))}const mC=pe({config:w_,dependencies:[tu],mergeConfig(n,e){const t=Eo(n,e);for(const r of["matchers","changeHandlers","excludeParents"]){const o=e[r];Array.isArray(o)&&(t[r]=[...n[r],...o])}return t},name:"@lexical/link/AutoLink",nodes:[fa],register:_C}),Co=/^(\d+(?:\.\d+)?)px$/,te={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};let Gt=class extends Oe{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;$config(){return this.config("tablecell",{extends:Oe,importDOM:{td:()=>({conversion:wf,priority:0}),th:()=>({conversion:wf,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign,this.__colSpan=e.__colSpan,this.__headerState=e.__headerState,this.__width=e.__width}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=te.NO_STATUS,t=1,r,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=r,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(e){const t=Je().createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),Gl(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),Ie(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){const t=super.exportDOM(e);if(ke(t.element)){const r=t.element;r.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),r.style.border="1px solid black",this.__colSpan>1&&(r.colSpan=this.__colSpan),this.__rowSpan>1&&(r.rowSpan=this.__rowSpan),r.style.width=`${this.getWidth()||75}px`,r.style.verticalAlign=this.getVerticalAlign()||"top",r.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(r.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Gl(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=te.BOTH){const r=this.getWritable();return r.__headerState=e&t|r.__headerState&~t,r}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==te.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function Gl(n){return n==="middle"||n==="bottom"}function wf(n){const e=n,t=n.nodeName.toLowerCase();let r;Co.test(e.style.width)&&(r=parseFloat(e.style.width));let o=te.NO_STATUS;if(t==="th"){const _=e.getAttribute("scope");if(_==="col")o=te.COLUMN;else if(_==="row")o=te.ROW;else{const m=e.parentElement,b=ke(m)&&m.nodeName.toLowerCase()==="tr"&&ke(m.parentElement)&&(m.parentElement.nodeName.toLowerCase()==="thead"||m.rowIndex===0),w=e.cellIndex===0;b&&(o|=te.ROW),w&&(o|=te.COLUMN),o===te.NO_STATUS&&(o=te.ROW)}}const s=lt(o,e.colSpan,r);s.__rowSpan=e.rowSpan;const i=e.style.backgroundColor;i!==""&&(s.__backgroundColor=i);const a=e.style.verticalAlign;Gl(a)&&(s.__verticalAlign=a);const l=e.style,c=(l&&l.textDecoration||"").split(" "),u=l.fontWeight==="700"||l.fontWeight==="bold",f=c.includes("line-through"),d=l.fontStyle==="italic",g=c.includes("underline"),h=l.color;return{after:_=>{const m=[];let b=null;const w=()=>{if(b){const C=b.getFirstChild();ue(C)&&b.getChildrenSize()===1&&C.remove()}};for(const C of _)if(sh(C)||oe(C)||ue(C)){if(oe(C)&&(u&&C.toggleFormat("bold"),f&&C.toggleFormat("strikethrough"),d&&C.toggleFormat("italic"),g&&C.toggleFormat("underline"),h)){const v=C.getStyle();v.includes("color:")||C.setStyle(v+`color: ${h};`)}b?b.append(C):(b=ne().append(C),m.push(b))}else m.push(C),w(),b=null;return w(),m.length===0&&m.push(ne()),m},node:s}}function lt(n=te.NO_STATUS,e=1,t){return Ot(new Gt(n,e,t))}function J(n){return n instanceof Gt}const nu=he("INSERT_TABLE_COMMAND");function G(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class Wo extends Oe{__height;$config(){return this.config("tablerow",{extends:Oe,importDOM:{tr:()=>({conversion:bC,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__height=e.__height}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e=void 0,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){const t=Je().createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),Ie(t,e.theme.tableRow),t}extractWithChild(e,t,r){return r==="html"}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function bC(n){const e=n;let t;return Co.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:r=>Mi(r,J),node:pn(t)}}function pn(n){return Ot(new Wo(n))}function ce(n){return n instanceof Wo}function x_(n,e,t=!0){const r=Ho();for(let o=0;o<n;o++){const s=pn();for(let i=0;i<e;i++){let a=te.NO_STATUS;typeof t=="object"?(o===0&&t.rows&&(a|=te.ROW),i===0&&t.columns&&(a|=te.COLUMN)):t&&(o===0&&(a|=te.ROW),i===0&&(a|=te.COLUMN));const l=lt(a),c=ne();c.append($e()),l.append(c),s.append(l)}r.append(s)}return r}function Xl(n){const e=re(n,t=>J(t));return J(e)?e:null}function ru(n){const e=re(n,t=>ce(t));if(ce(e))return e;throw new Error("Expected table cell to be inside of table row.")}function ot(n){const e=re(n,t=>be(t));if(be(e))return e;throw new Error("Expected table cell to be inside of table.")}function ou(n){const e=ru(n);return ot(e).getChildren().findIndex(t=>t.is(e))}function C_(n){return ru(n).getChildren().findIndex(e=>e.is(n))}function S_(n,e){const t=ot(n),{x:r,y:o}=t.getCordsFromCellNode(n,e);return{above:t.getCellNodeFromCords(r,o-1,e),below:t.getCellNodeFromCords(r,o+1,e),left:t.getCellNodeFromCords(r-1,o,e),right:t.getCellNodeFromCords(r+1,o,e)}}function yC(n,e){const t=n.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),n}function wC(n,e,t=!0,r,o){const s=n.getChildren();if(e>=s.length||e<0)throw new Error("Table row target index out of range");const i=s[e];if(!ce(i))throw new Error("Row before insertion index does not exist.");for(let a=0;a<r;a++){const l=i.getChildren(),c=l.length,u=pn();for(let f=0;f<c;f++){const d=l[f];J(d)||G(12);const{above:g,below:h}=S_(d,o);let _=te.NO_STATUS;const m=g&&g.getWidth()||h&&h.getWidth()||void 0;(g&&g.hasHeaderState(te.COLUMN)||h&&h.hasHeaderState(te.COLUMN))&&(_|=te.COLUMN);const b=lt(_,1,m);b.append(ne()),u.append(b)}t?i.insertAfter(u):i.insertBefore(u)}return n}const Zl=(n,e)=>n===te.BOTH||n===e?e:te.NO_STATUS;function ga(n=!0){const e=D();F(e)||ae(e)||G(188);const t=e.anchor.getNode(),r=e.focus.getNode(),[o]=We(t),[s,,i]=We(r),[,a,l]=ct(i,s,o),{startRow:c}=l,{startRow:u}=a;return n?Ui(c+o.__rowSpan>u+s.__rowSpan?o:s,!0):Ui(u<c?s:o,!1)}const xC=ga;function Ui(n,e=!0){const[,,t]=We(n),[r,o]=ct(t,n,n),s=r[0].length,{startRow:i}=o;let a=null;if(e){const l=i+n.__rowSpan-1,c=r[l],u=pn();for(let d=0;d<s;d++){const{cell:g,startRow:h}=c[d];if(h+g.__rowSpan-1<=l){const _=c[d].cell.__headerState,m=Zl(_,te.COLUMN);u.append(lt(m).append(ne()))}else g.setRowSpan(g.__rowSpan+1)}const f=t.getChildAtIndex(l);ce(f)||G(256),f.insertAfter(u),a=u}else{const l=i,c=r[l],u=pn();for(let d=0;d<s;d++){const{cell:g,startRow:h}=c[d];if(h===l){const _=c[d].cell.__headerState,m=Zl(_,te.COLUMN);u.append(lt(m).append(ne()))}else g.setRowSpan(g.__rowSpan+1)}const f=t.getChildAtIndex(l);ce(f)||G(257),f.insertBefore(u),a=u}return a}function CC(n,e,t=!0,r,o){const s=n.getChildren(),i=[];for(let a=0;a<s.length;a++){const l=s[a];if(ce(l))for(let c=0;c<r;c++){const u=l.getChildren();if(e>=u.length||e<0)throw new Error("Table column target index out of range");const f=u[e];J(f)||G(12);const{left:d,right:g}=S_(f,o);let h=te.NO_STATUS;(d&&d.hasHeaderState(te.ROW)||g&&g.hasHeaderState(te.ROW))&&(h|=te.ROW);const _=lt(h);_.append(ne()),i.push({newTableCell:_,targetCell:f})}}return i.forEach(({newTableCell:a,targetCell:l})=>{t?l.insertAfter(a):l.insertBefore(a)}),n}function pa(n=!0){const e=D();F(e)||ae(e)||G(188);const t=e.anchor.getNode(),r=e.focus.getNode(),[o]=We(t),[s,,i]=We(r),[,a,l]=ct(i,s,o),{startColumn:c}=l,{startColumn:u}=a;return n?zi(c+o.__colSpan>u+s.__colSpan?o:s,!0):zi(u<c?s:o,!1)}const SC=pa;function zi(n,e=!0,t=!0){const[,,r]=We(n),[o,s]=ct(r,n,n),i=o.length,{startColumn:a}=s,l=e?a+n.__colSpan-1:a-1,c=r.getFirstChild();ce(c)||G(120);let u=null;function f(h=te.NO_STATUS){const _=lt(h).append(ne());return u===null&&(u=_),_}let d=c;e:for(let h=0;h<i;h++){if(h!==0){const k=d.getNextSibling();ce(k)||G(121),d=k}const _=o[h],m=_[l<0?0:l].cell.__headerState,b=Zl(m,te.ROW);if(l<0){au(d,f(b));continue}const{cell:w,startColumn:C,startRow:v}=_[l];if(C+w.__colSpan-1<=l){let k=w,I=v,E=l;for(;I!==h&&k.__rowSpan>1;){if(E-=w.__colSpan,!(E>=0)){d.append(f(b));continue e}{const{cell:N,startRow:O}=_[E];k=N,I=O}}k.insertAfter(f(b))}else w.setColSpan(w.__colSpan+1)}u!==null&&t&&Es(u);const g=r.getColWidths();if(g){const h=[...g],_=l<0?0:l,m=h[_];h.splice(_,0,m),r.setColWidths(h)}return u}function vC(n,e){const t=n.getChildren();for(let r=0;r<t.length;r++){const o=t[r];if(ce(o)){const s=o.getChildren();if(e>=s.length||e<0)throw new Error("Table column target index out of range");s[e].remove()}}return n}function su(){const n=D();F(n)||ae(n)||G(188);const[e,t]=n.isBackward()?[n.focus.getNode(),n.anchor.getNode()]:[n.anchor.getNode(),n.focus.getNode()],[r,,o]=We(e),[s]=We(t),[i,a,l]=ct(o,r,s),{startRow:c}=a,{startRow:u}=l,f=u+s.__rowSpan-1;if(i.length===f-c+1)return void o.remove();const d=i[0].length,g=i[f+1],h=o.getChildAtIndex(f+1);for(let _=f;_>=c;_--){for(let b=d-1;b>=0;b--){const{cell:w,startRow:C,startColumn:v}=i[_][b];if(v===b){if(C<c||C+w.__rowSpan-1>f){const k=Math.max(C,c),I=Math.min(w.__rowSpan+C-1,f),E=k<=I?I-k+1:0;w.setRowSpan(w.__rowSpan-E)}if(C>=c&&C+w.__rowSpan-1>f&&_===f){ce(h)||G(387);let k=null;for(let I=0;I<b;I++){const E=g[I],N=E.cell;E.startRow===_+1&&(k=N),N.__colSpan>1&&(I+=N.__colSpan-1)}k===null?au(h,w):k.insertAfter(w)}}}const m=o.getChildAtIndex(_);ce(m)||G(206,String(_)),m.remove()}if(g!==void 0){const{cell:_}=g[0];Es(_)}else{const _=i[c-1],{cell:m}=_[0];Es(m)}}const kC=su;function iu(){const n=D();F(n)||ae(n)||G(188);const e=n.anchor.getNode(),t=n.focus.getNode(),[r,,o]=We(e),[s]=We(t),[i,a,l]=ct(o,r,s),{startColumn:c}=a,{startRow:u,startColumn:f}=l,d=Math.min(c,f),g=Math.max(c+r.__colSpan-1,f+s.__colSpan-1),h=g-d+1;if(i[0].length===g-d+1)return o.selectPrevious(),void o.remove();const _=i.length;for(let C=0;C<_;C++)for(let v=d;v<=g;v++){const{cell:k,startColumn:I}=i[C][v];if(I<d){if(v===d){const E=d-I;k.setColSpan(k.__colSpan-Math.min(h,k.__colSpan-E))}}else if(I+k.__colSpan-1>g){if(v===g){const E=g-I+1;k.setColSpan(k.__colSpan-E)}}else k.remove()}const m=i[u],b=c>f?m[c+r.__colSpan]:m[f+s.__colSpan];if(b!==void 0){const{cell:C}=b;Es(C)}else{const C=f<c?m[f-1]:m[c-1],{cell:v}=C;Es(v)}const w=o.getColWidths();if(w){const C=[...w];C.splice(d,h),o.setColWidths(C)}}const TC=iu;function Es(n){const e=n.getFirstDescendant();e==null?n.selectStart():e.getParentOrThrow().selectStart()}function au(n,e){const t=n.getFirstChild();t!==null?t.insertBefore(e):n.append(e)}function lu(n){if(n.length===0)return null;const e=ot(n[0]),[t]=at(e,null,null);let r=1/0,o=-1/0,s=1/0,i=-1/0;const a=new Set;for(const g of t)for(const h of g){if(!h||!h.cell)continue;const _=h.cell.getKey();if(!a.has(_)&&n.some(m=>m.is(h.cell))){a.add(_);const m=h.startRow,b=h.startColumn,w=h.cell.__rowSpan||1,C=h.cell.__colSpan||1;r=Math.min(r,m),o=Math.max(o,m+w-1),s=Math.min(s,b),i=Math.max(i,b+C-1)}}if(r===1/0||s===1/0)return null;const l=o-r+1,c=i-s+1,u=t[r][s];if(!u.cell)return null;const f=u.cell;f.setColSpan(c),f.setRowSpan(l);const d=new Set([f.getKey()]);for(let g=r;g<=o;g++)for(let h=s;h<=i;h++){const _=t[g][h];if(!_.cell)continue;const m=_.cell,b=m.getKey();d.has(b)||(d.add(b),IC(m)||f.append(...m.getChildren()),m.remove())}return f.getChildrenSize()===0&&f.append(ne()),f}function IC(n){if(n.getChildrenSize()!==1)return!1;const e=n.getFirstChildOrThrow();return!(!ht(e)||!e.isEmpty())}function v_(){const n=D();F(n)||ae(n)||G(188);const e=n.anchor.getNode(),t=re(e,J);return J(t)||G(148),cu(t)}function cu(n){const[e,t,r]=We(n),o=e.__colSpan,s=e.__rowSpan;if(o===1&&s===1)return;const[i,a]=ct(r,e,e),{startColumn:l,startRow:c}=a,u=e.__headerState&te.COLUMN,f=Array.from({length:o},(h,_)=>{let m=u;for(let b=0;m!==0&&b<i.length;b++)m&=i[b][_+l].cell.__headerState;return m}),d=e.__headerState&te.ROW,g=Array.from({length:s},(h,_)=>{let m=d;for(let b=0;m!==0&&b<i[0].length;b++)m&=i[_+c][b].cell.__headerState;return m});if(o>1){for(let h=1;h<o;h++)e.insertAfter(lt(f[h]|g[0]).append(ne()));e.setColSpan(1)}if(s>1){let h;for(let _=1;_<s;_++){const m=c+_,b=i[m];h=(h||t).getNextSibling(),ce(h)||G(125);let w=null;for(let C=0;C<l;C++){const v=b[C],k=v.cell;v.startRow===m&&(w=k),k.__colSpan>1&&(C+=k.__colSpan-1)}if(w===null)for(let C=o-1;C>=0;C--)au(h,lt(f[C]|g[_]).append(ne()));else for(let C=o-1;C>=0;C--)w.insertAfter(lt(f[C]|g[_]).append(ne()))}e.setRowSpan(1)}}function ct(n,e,t){const[r,o,s]=at(n,e,t);return o===null&&G(207),s===null&&G(208),[r,o,s]}function at(n,e,t){const r=[];let o=null,s=null;function i(l){let c=r[l];return c===void 0&&(r[l]=c=[]),c}const a=n.getChildren();for(let l=0;l<a.length;l++){const c=a[l];ce(c)||G(209);const u=i(l);for(let f=c.getFirstChild(),d=0;f!=null;f=f.getNextSibling()){for(J(f)||G(147);u[d]!==void 0;)d++;const g={cell:f,startColumn:d,startRow:l},{__rowSpan:h,__colSpan:_}=f;for(let m=0;m<h&&!(l+m>=a.length);m++){const b=i(l+m);for(let w=0;w<_;w++)b[d+w]=g}e!==null&&o===null&&e.is(f)&&(o=g),t!==null&&s===null&&t.is(f)&&(s=g)}}return[r,o,s]}function We(n){let e;if(n instanceof Gt)e=n;else if("__type"in n){const o=re(n,J);J(o)||G(148),e=o}else{const o=re(n.getNode(),J);J(o)||G(148),e=o}const t=e.getParent();ce(t)||G(149);const r=t.getParent();return be(r)||G(210),[e,t,r]}function Ns(n,e,t){let r,o=Math.min(e.startColumn,t.startColumn),s=Math.min(e.startRow,t.startRow),i=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),a=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);do{r=!1;for(let l=0;l<n.length;l++)for(let c=0;c<n[0].length;c++){const u=n[l][c];if(!u)continue;const f=u.startColumn+u.cell.__colSpan-1,d=u.startRow+u.cell.__rowSpan-1,g=u.startColumn<=i&&f>=o,h=u.startRow<=a&&d>=s;if(g&&h){const _=Math.min(o,u.startColumn),m=Math.max(i,f),b=Math.min(s,u.startRow),w=Math.max(a,d);_===o&&m===i&&b===s&&w===a||(o=_,i=m,s=b,a=w,r=!0)}}}while(r);return{maxColumn:i,maxRow:a,minColumn:o,minRow:s}}function uu(n){const e=n.getChildren();let t=null;for(const r of e){if(!ce(r)||(t===null&&(t=r.getChildrenSize()),r.getChildrenSize()!==t))return!1;const o=r.getChildren();for(const s of o)if(!J(s)||s.getRowSpan()!==1||s.getColSpan()!==1)return!1}return(t||0)>0}function EC(n,e,t){if(e===t)return;const r=n.getColumnCount();if(e<0||e>=r||t<0||t>=r||!uu(n))return;n.getChildren().filter(ce).forEach(s=>{const i=s.getChildren(),[a]=i.splice(e,1);i.splice(t,0,a),s.splice(0,i.length,i)});const o=n.getColWidths();if(o&&o.length===r){const s=[...o],[i]=s.splice(e,1);s.splice(t,0,i),n.setColWidths(s)}}function NC(n,e,t){if(e===t)return;const r=n.getChildren().filter(ce),o=r.length;if(e<0||e>=o||t<0||t>=o||!uu(n))return;const s=r[e],i=r[t];t>e?i.insertAfter(s):i.insertBefore(s)}function Ql(n){const[e,,t]=We(n),r=t.getChildren().filter(ce),o=r.length,s=r[0].getChildren().length,i=new Array(o);for(let a=0;a<o;a++)i[a]=new Array(s);for(let a=0;a<o;a++){const l=r[a].getChildren().filter(J);let c=0;for(let u=0;u<l.length;u++){for(;i[a][c];)c++;const f=l[u],d=f.__rowSpan||1,g=f.__colSpan||1;for(let h=0;h<d;h++)for(let _=0;_<g;_++)i[a+h][c+_]=f;if(e===f)return{colSpan:g,columnIndex:c,rowIndex:a,rowSpan:d};c+=g}}return null}function k_(n,e){const t=e.getStartEndPoints(),r=ae(e);if(t===null)return!1;const[o,s]=t,[i,a,l]=We(o),c=re(s.getNode(),R=>J(R));if(!(J(i)&&J(c)&&ce(a)&&be(l)))return!1;const[u,f,d]=ct(l,i,c),[g]=at(n,null,null),h=u.length,_=h>0?u[0].length:0;let m=f.startRow,b=f.startColumn,w=g.length,C=w>0?g[0].length:0;if(r){const R=Ns(u,f,d),$=R.maxRow-R.minRow+1,L=R.maxColumn-R.minColumn+1;m=R.minRow,b=R.minColumn,w=Math.min(w,$),C=Math.min(C,L)}let v=!1;const k=Math.min(h,m+w)-1,I=Math.min(_,b+C)-1,E=new Set;for(let R=m;R<=k;R++)for(let $=b;$<=I;$++){const L=u[R][$];E.has(L.cell.getKey())||L.cell.__rowSpan===1&&L.cell.__colSpan===1||(cu(L.cell),E.add(L.cell.getKey()),v=!0)}let[N]=at(l.getWritable(),null,null);const O=w-h+m;for(let R=0;R<O;R++)Ui(N[h-1][0].cell);const M=C-_+b;for(let R=0;R<M;R++)zi(N[0][_-1].cell,!0,!1);[N]=at(l.getWritable(),null,null);for(let R=m;R<m+w;R++)for(let $=b;$<b+C;$++){const L=R-m,A=$-b,B=g[L][A];if(B.startRow!==L||B.startColumn!==A)continue;const j=B.cell;if(j.__rowSpan!==1||j.__colSpan!==1){const H=[],ie=Math.min(R+j.__rowSpan,m+w)-1,Ne=Math.min($+j.__colSpan,b+C)-1;for(let Ce=R;Ce<=ie;Ce++)for(let ut=$;ut<=Ne;ut++){const Mn=N[Ce][ut];H.push(Mn.cell)}lu(H),v=!0}const{cell:U}=N[R][$],z=j.getBackgroundColor();z!=null&&U.setBackgroundColor(z);const K=U.getChildren();j.getChildren().forEach(H=>{oe(H)&&ne().append(H),U.append(H)}),K.forEach(H=>H.remove())}if(r&&v){const[R]=at(l.getWritable(),null,null);R[f.startRow][f.startColumn].cell.selectEnd()}return!0}function LC(n,e,t){const[r]=at(n,null,null);e>=0&&e<r.length||G(396,String(e));const o=r[e],s=t?te.ROW:te.NO_STATUS,i=new Set;for(let a=0;a<o.length;a++){const l=o[a];l!=null&&(i.has(l.cell)||(i.add(l.cell),l.cell.setHeaderStyles(s,te.ROW)))}}function OC(n,e,t){const[r]=at(n,null,null);r.length>0&&e>=0&&e<r[0].length||G(397,String(e));const o=t?te.COLUMN:te.NO_STATUS,s=new Set;for(let i=0;i<r.length;i++){const a=r[i][e];a!=null&&(s.has(a.cell)||(s.add(a.cell),a.cell.setHeaderStyles(o,te.COLUMN)))}}function Wa(n){const[[e,t,r,o],[s,i,a,l]]=["anchor","focus"].map(c=>{const u=n[c].getNode(),f=re(u,J);J(f)||G(238,c,u.getKey(),u.getType());const d=f.getParent();ce(d)||G(239,c);const g=d.getParent();return be(g)||G(240,c),[u,f,d,g]});return o.is(l)||G(241),{anchorCell:t,anchorNode:e,anchorRow:r,anchorTable:o,focusCell:i,focusNode:s,focusRow:a,focusTable:l}}class Vs{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,r){this.anchor=t,this.focus=r,t._selection=this,r._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return!1;const e=Q(this.tableKey),t=Q(this.anchor.key),r=Q(this.focus.key);return e!==null&&t!==null&&r!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return ae(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,r){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||r!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=r,this._cachedNodes=null}clone(){return new Vs(this.tableKey,un(this.anchor.key,this.anchor.offset,this.anchor.type),un(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){if(e==="")return;const t=(e.endsWith(`
8
+ |(?![\\s\\S])))+`,"m"),alias:o,inside:{line:{pattern:/(.)(?=[\s\S]).*(?:\r\n?|\n)?/,lookbehind:!0},prefix:{pattern:/[\s\S]/,alias:/\w+/.exec(t)[0]}}}}),Object.defineProperty(n.languages.diff,"PREFIXES",{value:e})})(Prism),Prism.languages.go=Prism.languages.extend("clike",{string:{pattern:/(^|[^\\])"(?:\\.|[^"\\\r\n])*"|`[^`]*`/,lookbehind:!0,greedy:!0},keyword:/\b(?:break|case|chan|const|continue|default|defer|else|fallthrough|for|func|go(?:to)?|if|import|interface|map|package|range|return|select|struct|switch|type|var)\b/,boolean:/\b(?:_|false|iota|nil|true)\b/,number:[/\b0(?:b[01_]+|o[0-7_]+)i?\b/i,/\b0x(?:[a-f\d_]+(?:\.[a-f\d_]*)?|\.[a-f\d_]+)(?:p[+-]?\d+(?:_\d+)*)?i?(?!\w)/i,/(?:\b\d[\d_]*(?:\.[\d_]*)?|\B\.\d[\d_]*)(?:e[+-]?[\d_]+)?i?(?!\w)/i],operator:/[*\/%^!=]=?|\+[=+]?|-[=-]?|\|[=|]?|&(?:=|&|\^=?)?|>(?:>=?|=)?|<(?:<=?|=|-)?|:=|\.\.\./,builtin:/\b(?:append|bool|byte|cap|close|complex|complex(?:64|128)|copy|delete|error|float(?:32|64)|u?int(?:8|16|32|64)?|imag|len|make|new|panic|print(?:ln)?|real|recover|rune|string|uintptr)\b/}),Prism.languages.insertBefore("go","string",{char:{pattern:/'(?:\\.|[^'\\\r\n]){0,10}'/,greedy:!0}}),delete Prism.languages.go["class-name"];const rn=globalThis.Prism||window.Prism,Xh={c:"C",clike:"C-like",cpp:"C++",css:"CSS",go:"Go",html:"HTML",java:"Java",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",powershell:"PowerShell",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",typescript:"TypeScript",xml:"XML"},u0={cpp:"cpp",golang:"go",java:"java",javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain",ts:"typescript"};function Yc(n){return u0[n]||n}function d0(n){const e=Yc(n);return Xh[e]||e}function f0(){const n=[];for(const[e,t]of Object.entries(Xh))n.push([e,t]);return n}function g0(n){const e=(function(r){const o=/^diff-([\w-]+)/i.exec(r);return o?o[1]:null})(n),t=e||n;try{return!!t&&rn.languages.hasOwnProperty(t)}catch{return!1}}async function p0(n,e,t){}function Bl(n){return typeof n=="string"?n:Array.isArray(n)?n.map(Bl).join(""):Bl(n.content)}function h0(n,e){const t=/^diff-([\w-]+)/i.exec(e),r=n.getTextContent();let o=rn.tokenize(r,rn.languages[t?"diff":e]);return t&&(o=(function(s,i){const a=i,l=rn.languages[a],c={tokens:s},u=rn.languages.diff.PREFIXES;for(const f of c.tokens){if(typeof f=="string"||!(f.type in u)||!Array.isArray(f.content))continue;const d=f.type;let g=0;const h=()=>(g++,new rn.Token("prefix",u[d],d.replace(/^(\w+).*/,"$1"))),_=f.content.filter(k=>typeof k=="string"||k.type!=="prefix"),m=f.content.length-_.length,b=rn.tokenize(Bl(_),l);b.unshift(h());const w=/\r\n|\n/g,C=k=>{const I=[];w.lastIndex=0;let E,N=0;for(;g<m&&(E=w.exec(k));){const O=E.index+E[0].length;I.push(k.slice(N,O)),N=O,I.push(h())}if(I.length!==0)return N<k.length&&I.push(k.slice(N)),I},v=k=>{for(let I=0;I<k.length&&g<m;I++){const E=k[I];if(typeof E=="string"){const N=C(E);N&&(k.splice(I,1,...N),I+=N.length-1)}else if(typeof E.content=="string"){const N=C(E.content);N&&(E.content=N)}else Array.isArray(E.content)?v(E.content):v([E.content])}};v(b),g<m&&b.push(h()),f.content=b}return c.tokens})(o,t[1])),Ul(o)}function Ul(n,e){const t=[];for(const r of n)if(typeof r=="string")jp(r,{linebreak:()=>t.push(vt()),tab:()=>t.push(Kn()),text:o=>t.push(Vc(o,e))});else{const{content:o,alias:s}=r;typeof o=="string"?t.push(...Ul([o],r.type==="prefix"&&typeof s=="string"?s:r.type)):Array.isArray(o)&&t.push(...Ul(o,r.type==="unchanged"?void 0:r.type))}return t}const _0={$tokenize(n,e){const t=e||this.defaultLanguage;return t===null?Qx(n.getTextContent()):h0(n,t)},defaultLanguage:e0,tokenize(n,e){const t=this.defaultLanguage;return rn.tokenize(n,rn.languages[e||""]||(t===null?void 0:rn.languages[t]))}};function Vd(n,e,t,r){const o=r.getParent();je(o)?Gh(n,e,t,o):Ve(r)&&r.replace($e(r.__text))}function m0(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
9
+ `+ ++i);t.setAttribute("data-gutter",s)}function Gh(n,e,t,r){const{nodesCurrentlyHighlighting:o}=t,s=r.getKey();r.getLanguage()===void 0&&e.defaultLanguage!==null&&r.setLanguage(e.defaultLanguage);const i=r.getLanguage()||e.defaultLanguage;if(i){if(!g0(i))return r.getIsSyntaxHighlightSupported()&&r.setIsSyntaxHighlightSupported(!1),void p0();r.getIsSyntaxHighlightSupported()||r.setIsSyntaxHighlightSupported(!0)}else r.getIsSyntaxHighlightSupported()&&r.setIsSyntaxHighlightSupported(!1);o.has(s)||(o.add(s),t.didTransform||(t.didTransform=!0,uy(()=>{t.didTransform=!1,o.clear()})),(function(a,l){const c=Q(a);if(!je(c)||!c.isAttached())return;const u=D();if(!F(u))return void l();const f=u.anchor,d=f.offset,g=f.type==="element"&&ue(c.getChildAtIndex(f.offset-1));let h=0;if(!g){const _=f.getNode();h=d+_.getPreviousSiblings().reduce((m,b)=>m+b.getTextContentSize(),0)}if(l()){if(g)return void f.getNode().select(d,d);c.getChildren().some(_=>{const m=oe(_);if(m||ue(_)){const b=_.getTextContentSize();if(m&&b>=h)return _.select(h,h),!0;h-=b}return!1})}})(s,()=>{const a=Q(s);if(!je(a)||!a.isAttached())return!1;const l=a.getLanguage()||e.defaultLanguage,c=e.$tokenize(a,l??void 0),u=(function(h,_){let m=0;for(;m<h.length&&Yd(h[m],_[m]);)m++;const b=h.length,w=_.length,C=Math.min(b,w)-m;let v=0;for(;v<C;)if(v++,!Yd(h[b-v],_[w-v])){v--;break}const k=m,I=b-v,E=_.slice(m,w-v);return{from:k,nodesForReplacement:E,to:I}})(a.getChildren(),c),{from:f,to:d,nodesForReplacement:g}=u;return!(f===d&&!g.length)&&(r.splice(f,d-f,g),!0)}))}function Yd(n,e){return Ve(n)&&Ve(e)&&n.__text===e.__text&&n.__highlightType===e.__highlightType||bt(n)&&bt(e)||ue(n)&&ue(e)}function b0(n,e){const t=[];n._headless!==!0&&t.push(n.registerMutationListener(dn,o=>{n.read("latest",()=>{for(const[s,i]of o)if(i!=="destroyed"){const a=Q(s);a!==null&&m0(a,n)}})},{skipInitialization:!1}));const r={didTransform:!1,nodesCurrentlyHighlighting:new Set};return t.push(n.registerNodeTransform(dn,Gh.bind(null,n,e,r)),n.registerNodeTransform(cn,Vd.bind(null,n,e,r)),n.registerNodeTransform(Hs,Vd.bind(null,n,e,r))),de(...t)}function y0(n,e=_0){if(!n.hasNodes([dn,Hs]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return de(b0(n,e),c0(n))}const w0=f0,x0=d0,C0=Yc,zl=Yc,S0=y0,v0={css:[()=>me(()=>import("./postcss-BeaNGZ2L.js").then(n=>n.p),[],import.meta.url)],html:[()=>me(()=>import("./html-DZBHODiV.js").then(n=>n.h),[],import.meta.url)],js:[()=>me(()=>import("./babel-RKmSF9zr.js").then(n=>n.b),[],import.meta.url),()=>me(()=>import("./estree-C_HWBWad.js"),[],import.meta.url)],markdown:[()=>me(()=>import("./markdown-DR6D7d1u.js").then(n=>n.m),[],import.meta.url)],typescript:[()=>me(()=>import("./typescript-9PkMzh3x.js").then(n=>n.t),[],import.meta.url),()=>me(()=>import("./estree-C_HWBWad.js"),[],import.meta.url)]};async function k0(n){const e=v0[n];return await Promise.all(e.map(r=>r()))}async function T0(){const{format:n}=await me(async()=>{const{format:e}=await import("./standalone-DyCMuq_1.js");return{format:e}},[],import.meta.url);return n}const Zh={css:{parser:"css"},html:{parser:"html"},js:{parser:"babel"},markdown:{parser:"markdown"},typescript:{parser:"typescript"}},I0=Object.keys(Zh);function E0(n){return I0.includes(n)}function N0(n){const e=Zh[n];if(!e)throw new Error(`CodeActionMenuPlugin: Prettier does not support this language: ${n}`);return e}function L0({lang:n,editor:e,getCodeDOMNode:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1);async function a(){const f=t();if(!f)return;let d="";if(e.update(()=>{const g=Ae(f);je(g)&&(d=g.getTextContent())}),d!=="")try{const g=await T0(),h=N0(n),_=await k0(n);h.plugins=_.map(b=>b.default||b);const m=await g(d,h);e.update(()=>{const b=Ae(f);je(b)&&(b.select(0).insertText(m),o(""),i(!1))})}catch(g){l(g)}}function l(f){f instanceof Error?(o(f.message),i(!0)):console.error("Unexpected error: ",f)}function c(){r!==""&&i(!0)}function u(){r!==""&&i(!1)}return x.jsxs(Y,{sx:{position:"relative",display:"inline-flex"},children:[x.jsx(Ft,{icon:r?Fp:br,size:"small",variant:"invisible",onClick:a,onMouseEnter:c,onMouseLeave:u,"aria-label":"prettier",sx:r?{color:"var(--fgColor-danger)"}:void 0}),s?x.jsx(Y,{as:"pre",sx:{position:"absolute",top:"100%",left:0,zIndex:10,p:2,mt:1,fontSize:0,bg:"var(--bgColor-danger-muted)",color:"var(--fgColor-danger)",borderRadius:2,borderWidth:1,borderStyle:"solid",borderColor:"var(--bgColor-danger-muted)",maxWidth:"300px",whiteSpace:"pre-wrap"},children:r}):null]})}const Kl=({label:n,value:e,onChange:t,placeholder:r="","data-test-id":o})=>x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:n}),x.jsx(vn,{type:"text",placeholder:r,value:e,onChange:s=>{t(s.target.value)},"data-test-id":o,block:!0})]}),Qh=S.createContext(void 0),EM=({children:n})=>{const[e,t]=S.useState(!1),r=()=>t(o=>!o);return x.jsx(Qh.Provider,{value:{showComments:e,toggleComments:r,setShowComments:t},children:n})},e_=()=>{const n=S.useContext(Qh);if(!n)throw new Error("useComments must be used within CommentsProvider");return n},O0=S.createContext({});function R0(){return S.useContext(O0)}const Xc=S.createContext(void 0);function A0(){const n=S.useContext(Xc);if(!n)throw new Error("useLexicalConfig must be used within a LexicalConfigProvider");return n}function M0(){return S.useContext(Xc)}function NM({lexicalId:n,serviceManager:e,children:t}){return x.jsx(Xc.Provider,{value:{lexicalId:n,serviceManager:e},children:t})}const $0=S.createContext({});function D0(){return S.useContext($0)}const Xd=window.location.hostname,P0=Xd!=="playground.lexical.dev"&&Xd!=="lexical-playground.vercel.app",t_={disableBeforeInput:!1,emptyEditor:P0,hasLinkAttributes:!1,isAutocomplete:!1,isCharLimit:!1,isCharLimitUtf8:!1,isCodeHighlighted:!0,isCodeShiki:!1,isCollab:!1,isMaxLength:!1,isRichText:!0,listStrictIndent:!1,measureTypingPerf:!1,selectionAlwaysOnDisplay:!1,shouldAllowHighlightingWithBrackets:!1,shouldPreserveNewLinesInMarkdown:!1,shouldUseLexicalContextMenu:!1,showNestedEditorTreeView:!1,showTableOfContents:!1,showTreeView:!0,tableCellBackgroundColor:!0,tableCellMerge:!0,tableHorizontalScroll:!0},n_={...t_},r_=S.createContext({setOption:(n,e)=>{},settings:n_}),LM=({children:n})=>{const[e,t]=S.useState(n_),r=S.useCallback((s,i)=>{t(a=>({...a,[s]:i})),F0(s,i)},[]),o=S.useMemo(()=>({setOption:r,settings:e}),[r,e]);return x.jsx(r_.Provider,{value:o,children:n})},j0=()=>S.useContext(r_);function F0(n,e){const t=new URL(window.location.href),r=new URLSearchParams(t.search);e!==t_[n]?r.set(n,String(e)):r.delete(n),t.search=r.toString(),window.history.pushState(null,"",t.toString())}const Fa=8,Ba=72,Wl=15,Ua={bullet:"Bulleted List",check:"Check List",code:"Code Block",h1:"Heading 1",h2:"Heading 2",h3:"Heading 3",h4:"Heading 4",h5:"Heading 5",h6:"Heading 6",number:"Numbered List",paragraph:"Normal",quote:"Quote"},B0={bgColor:"#fff",blockType:"paragraph",canRedo:!1,canUndo:!1,codeLanguage:"",codeTheme:"",elementFormat:"left",fontColor:"#000",fontFamily:"Arial",fontSize:`${Wl}px`,fontSizeInputValue:`${Wl}`,isBold:!1,isCode:!1,isHighlight:!1,isImageCaption:!1,isItalic:!1,isLink:!1,isRTL:!1,isStrikethrough:!1,isSubscript:!1,isSuperscript:!1,isUnderline:!1,isLowercase:!1,isUppercase:!1,isCapitalize:!1,rootType:"root",listStartNumber:null},o_=S.createContext(void 0),OM=({children:n})=>{const[e,t]=S.useState(B0),r=e.fontSize,o=S.useCallback((i,a)=>{t(l=>({...l,[i]:a}))},[]);S.useEffect(()=>{o("fontSizeInputValue",r.slice(0,-2))},[r,o]);const s=S.useMemo(()=>({toolbarState:e,updateToolbarState:o}),[e,o]);return x.jsx(o_.Provider,{value:s,children:n})},U0=()=>{const n=S.useContext(o_);if(n===void 0)throw new Error("useToolbarState must be used within a ToolbarProvider");return n},z0=Ye({$import:(n,e)=>{const t=fn(e.nodeName.toLowerCase());return Bs(e,t),rr(t,e),mn(t,e),[t.splice(0,0,n.$importChildren(e))]},match:Xe.tag("h1","h2","h3","h4","h5","h6"),name:"@lexical/rich-text/heading"}),K0=Ye({$import:(n,e)=>{const t=Ln();return rr(t,e),Bs(e,t),mn(t,e),[t.splice(0,0,n.$importChildren(e))]},match:Xe.tag("blockquote"),name:"@lexical/rich-text/blockquote"});Xe.tag("blockquote");const W0=[z0,K0,Ye({$import:(n,e,t)=>{const r=e.firstChild;return r&&ke(o=r)&&o.nodeName==="SPAN"&&o.style.fontSize==="26pt"?n.$importChildren(e):t();var o},match:Xe.tag("p"),name:"@lexical/rich-text/google-docs-title-p"}),Ye({$import:(n,e,t)=>e.style.fontSize!=="26pt"?t():[fn("h1").splice(0,0,n.$importChildren(e))],match:Xe.tag("span"),name:"@lexical/rich-text/google-docs-title-span"})];function H0(n,e){return n&&e!==null?Eo(n,e):e}const s_=pe({build:(n,e)=>nr(e),config:tr({escapeFormatTriggers:{capitalize:{enter:!0,space:!0,tab:!0},lowercase:{enter:!0,space:!0,tab:!0},uppercase:{enter:!0,space:!0,tab:!0}}}),conflictsWith:["@lexical/plain-text"],dependencies:[dy,fy,gy,js,ln(Fs,{rules:W0})],mergeConfig:function(n,e){const t=Eo(n,e);return e.escapeFormatTriggers&&(t.escapeFormatTriggers=(function(r,o){const s=Eo(r,o);for(const i of Object.keys(o))s[i]=H0(r[i],o[i]);return s})(n.escapeFormatTriggers,e.escapeFormatTriggers)),t},name:"@lexical/rich-text",nodes:()=>[qs,Js],register:(n,e,t)=>zt(()=>i_(n,t.getOutput().escapeFormatTriggers))}),Gd=he("DRAG_DROP_PASTE_FILE"),za=Us("shadowRoot",{parse:Boolean});let Js=class extends Oe{$config(){return this.config("quote",{extends:Oe,importDOM:{blockquote:()=>({conversion:J0,priority:0})},stateConfigs:[{flat:!0,stateConfig:za}]})}isShadowRoot(){return Cs(this,za)}setIsShadowRoot(e){return xn(this,za,e)}createDOM(e){const t=Je().createElement("blockquote");return Ie(t,e.theme.quote),t}updateDOM(e,t,r){return!1}exportDOM(e){const{element:t}=super.exportDOM(e);if(ke(t)){this.isEmpty()&&t.append(Je().createElement("br"));const r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();o&&(t.dir=o)}return{element:t}}exportJSON(){return super.exportJSON()}static importJSON(e){return Ln().updateFromJSON(e)}insertNewAfter(e,t){const r=ne(),o=this.getDirection();return r.setDirection(o),this.insertAfter(r,t),r}collapseAtStart(){if(this.isShadowRoot()){for(const t of this.getChildren())this.insertBefore(t);return this.remove(),!0}const e=ne();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}};function Ln(n){const e=Ot(new Js);return n&&n.shadowRoot?e.setIsShadowRoot(!0):e}function Vn(n){return n instanceof Js}let qs=class extends Oe{__tag;$config(){return this.config("heading",{extends:Oe,importDOM:{h1:()=>({conversion:to,priority:0}),h2:()=>({conversion:to,priority:0}),h3:()=>({conversion:to,priority:0}),h4:()=>({conversion:to,priority:0}),h5:()=>({conversion:to,priority:0}),h6:()=>({conversion:to,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Zd(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Zd(e)?{conversion:()=>({node:fn("h1")}),priority:3}:null}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__tag=e.__tag}constructor(e="h1",t){super(t),this.__tag=e}getTag(){return this.getLatest().__tag}setTag(e){const t=this.getWritable();return t.__tag=e,t}createDOM(e){const t=this.__tag,r=Je().createElement(t),o=e.theme.heading;if(o!==void 0){const s=o[t];Ie(r,s)}return r}updateDOM(e,t,r){return e.__tag!==this.__tag}exportDOM(e){const{element:t}=super.exportDOM(e);if(ke(t)){this.isEmpty()&&t.append(Je().createElement("br"));const r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();o&&(t.dir=o)}return{element:t}}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,t=!0){const r=e?e.anchor.offset:0,o=this.getLastDescendant(),s=!o||e&&e.anchor.key===o.getKey()&&r===o.getTextContentSize()||!e?ne():fn(this.getTag()),i=this.getDirection();if(s.setDirection(i),this.insertAfter(s,t),r===0&&!this.isEmpty()&&e){const a=ne();a.select(),this.replace(a,!0)}return s}collapseAtStart(){if(this.isEmpty()){const e=ne();this.getChildren().forEach(t=>e.append(t)),this.replace(e)}return!0}extractWithChild(){return!0}};function Zd(n){return n.nodeName.toLowerCase()==="span"&&n.style.fontSize==="26pt"}function to(n){const e=n.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=fn(e),Bs(n,t),rr(t,n),mn(t,n)),{node:t}}function J0(n){const e=Ln();return rr(e,n),Bs(n,e),mn(e,n),{node:e}}function fn(n="h1"){return Ot(new qs(n))}function Wr(n){return n instanceof qs}function Qd(n){const e=Ae(n);return It(e)}function no(n,e,t,r){let o=!1,s=null;if(n.isCollapsed()&&n.anchor.type==="text"){const a=n.anchor.getNode();if(oe(a)){s=a;const l=n.anchor.offset,c=l===a.getTextContentSize()&&a.getNextSibling()===null,u=l===0&&a.getPreviousSibling()===null;o=t==="end"&&c||t==="start"&&u||t==="both"&&(c||u)}}let i=!1;for(const[a,l]of Object.entries(r)){if(l==null||!l[e])continue;const c=a;if(l.onlyAtBoundary){if(!(o&&s&&oe(s)&&s.hasFormat(c)))continue;i=!0}n.hasFormat(c)&&n.toggleFormat(c)}i&&n.setStyle("")}const q0={capitalize:{enter:!0,space:!0,tab:!0},lowercase:{enter:!0,space:!0,tab:!0},uppercase:{enter:!0,space:!0,tab:!0}};function si(n,e){return(function(t,r){if(!t.isCollapsed())return!1;const o=vs(t.focus,r),s=re(o.origin,Ra);if(!s)return!1;const i=t.focus.getNode();if(!s.is(i)&&!Gp(i,s))return!1;const a=mi(o,gt(s,r));if(a.getTextSlices().some(f=>f&&f.getTextContentSize()>0))return!1;const l=mi(a.anchor.getSiblingCaret(),a.focus);let c=l.anchor.origin;for(const f of l){if(!Mc(f)||!f.origin.is(c.getParent()))return!1;c=f.origin}let u=s;for(const f of Ll(gt(s,r))){if(!f.origin.is(u.getParent())){if(Ey(f.origin)){const d=gt(u,r);return Ri(mi(d,d)),!0}break}if(!Ra(f.origin))break;u=f.origin}return!1})(n,e)||(function(t,r){if(!t.isCollapsed()||t.anchor.type!=="element")return!1;const o=vs(t.anchor,r).getNodeAtCaret();return!(!Ra(o)||o.isInline()||(Ri(Xp(Jn(Er(o,r)))),0))})(n,e)}function ef(n){return It(n)&&!n.isInline()&&!n.isIsolated()&&n.isKeyboardSelectable()}function ii(n){const e=aa();e.add(n),Ee(e)}function tf(n,e){if(!n.isCollapsed())return!1;const t=n.focus,r=t.getNode(),o=e?"previous":"next",s=vs(t,o);if(t.type==="element"&&q(r)&&wt(r)){const b=s.getNodeAtCaret();return!(b===null||!ef(b))&&(ii(b.__key),!0)}const i=re(q(r)?r:r.getParentOrThrow(),b=>q(b)&&!b.isInline()&&wt(b.getParent()));if(i===null)return!1;const a=gt(i,o).getNodeAtCaret();if(a===null||!ef(a))return!1;if(i.getTextContentSize()===0)return ii(a.__key),!0;const l=zo().getRootElement();if(l===null)return!1;const c=or(l.ownerDocument.defaultView);if(c===null||c.rangeCount===0)return!1;const u=c.anchorNode,f=c.anchorOffset,d=c.focusNode,g=c.focusOffset;c.modify("move",e?"backward":"forward","line");const h=c.anchorNode,_=c.anchorOffset;if(h===null)return nf(c,u,f,d,g),!1;const m=Ae(h);return nf(c,u,f,d,g),m===null?!1:(h===u&&_===f||!m.is(i)&&!Gp(m,i))&&(ii(a.__key),!0)}function nf(n,e,t,r,o){e!==null&&r!==null&&n.setBaseAndExtent(e,t,r,o)}function rf(n,e){if(!n.isCollapsed())return!1;const t=n.focus.getNode(),r=re(q(t)?t:t.getParentOrThrow(),m=>q(m)&&!m.isInline());if(r===null)return!1;const o=zo(),s=o.getRootElement();if(s===null)return!1;const i=s.ownerDocument.defaultView;if(i===null)return!1;let a=!1;for(const m of r.getChildren())if(q(m)&&m.isInline()){const b=o.getElementByKey(m.getKey());if(b!==null){const w=i.getComputedStyle(b).display;if(w==="inline-grid"||w==="inline-flex"){a=!0;break}}}if(!a)return!1;const l=gt(r,e?"previous":"next").getNodeAtCaret();if(l===null||!q(l)){if(e){const m=r.getFirstDescendant();oe(m)?m.select(0,0):r.select(0,0)}else{const m=r.getLastDescendant();if(oe(m)){const b=m.getTextContentSize();m.select(b,b)}else{const b=r.getChildrenSize();r.select(b,b)}}return!0}const c=o.getElementByKey(l.getKey());if(c===null)return!1;const u=or(i);if(u===null||u.rangeCount===0)return!1;const f=u.getRangeAt(0).cloneRange();f.collapse(!0);const d=f.getBoundingClientRect(),g=c.getBoundingClientRect(),h=g.top+g.height/2;if(d.height>0){const m=El(d.left,h,s);if(m!==null&&c.contains(m.node)){const b=s.ownerDocument.createRange();return b.setStart(m.node,m.offset),b.collapse(!0),n.applyDOMRange(b),n.dirty=!0,!0}}const _=e?l.getLastDescendant():l.getFirstDescendant();if(oe(_)){const m=e?_.getTextContentSize():0;_.select(m,m)}else{const m=l.getChildrenSize();l.select(e?m:0,e?m:0)}return!0}function ai(n,e){const t=gt(n,e),r=t.getAdjacentCaret();r!==null&&q(r.origin)&&!r.origin.isInline()&&r.origin.isShadowRoot()?Ri(Xp(t)):e==="next"?n.selectNext(0,0):n.selectPrevious()}function of(n,e,t){t.preventDefault(),t.stopPropagation();const r=n.getNodes();if(r.length===0)return!0;const o=r.map(l=>gt(l,"next")).sort(Iy),s=(e?o[0]:o[o.length-1]).origin,i=re(s,l=>l!==s&&q(l)&&!l.isInline())??se(),a=e?0:i.getChildrenSize();return i.select(a,a),!0}function i_(n,e=Ac(q0)){return de(n.registerCommand(Ks,()=>{const t=D();return ve(t)?(t.clear(),!0):(F(t)&&no(t,"click","both",e.peek()),!1)},V),n.registerCommand(bi,t=>{const r=D();return F(r)?(r.deleteCharacter(t),!0):!!ve(r)&&(r.deleteNodes(),!0)},V),n.registerCommand(Yp,t=>{const r=D();return!!F(r)&&(r.deleteWord(t),!0)},V),n.registerCommand(Vp,t=>{const r=D();return!!F(r)&&(r.deleteLine(t),!0)},V),n.registerCommand(qp,t=>{const r=D();if(typeof t=="string")r!==null&&r.insertText(t);else{if(r===null)return!1;const o=t.dataTransfer;if(o!=null)wd(o,r);else if(F(r)){const s=t.data;return s&&r.insertText(s),!0}}return!0},V),n.registerCommand(Ty,()=>{const t=D();return!!F(t)&&(t.removeText(),!0)},V),n.registerCommand(Ge,t=>{const r=D();return!(!F(r)&&!ve(r))&&(ky(r,t),!0)},V),n.registerCommand(Sy,t=>{const r=D();return!(!F(r)&&!ve(r))&&(vy(r,t),!0)},V),n.registerCommand(Bn,t=>{const r=D();if(!F(r)&&!ve(r))return!1;const o=r.getNodes();for(const s of o){const i=re(s,a=>q(a)&&!a.isInline());i!==null&&i.setFormat(t)}return!0},V),n.registerCommand(Nl,t=>{const r=D();return!!F(r)&&(r.insertLineBreak(t),!0)},V),n.registerCommand(Lo,()=>{const t=D();return!!F(t)&&(t.insertParagraph(),!0)},V),n.registerCommand(Tl,()=>{const t=Kn(),r=D();return F(r)&&(t.setFormat(r.format),t.setStyle(r.style)),Tr([t]),!0},V),n.registerCommand(Dt,()=>kd(t=>{const r=t.getIndent();t.setIndent(r+1)}),V),n.registerCommand(wn,()=>kd(t=>{const r=t.getIndent();r>0&&t.setIndent(Math.max(0,r-1))}),V),n.registerCommand(pt,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],"previous"),!0}else if(F(r)&&((function(o){const s=o.focus;return s.key==="root"&&s.offset===0})(r)||!t.shiftKey&&si(r,"previous")||!t.shiftKey&&tf(r,!0)||!t.shiftKey&&rf(r,!0)))return t.preventDefault(),!0;return!1},V),n.registerCommand(Vt,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],"next"),!0}else if(F(r)&&((function(o){const s=o.focus;return s.key==="root"&&s.offset===se().getChildrenSize()})(r)||!t.shiftKey&&si(r,"next")||!t.shiftKey&&tf(r,!1)||!t.shiftKey&&rf(r,!1)))return t.preventDefault(),!0;return!1},V),n.registerCommand(zs,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],Qs(o[0])?"next":"previous"),!0}if(!F(r))return!1;if(!t.shiftKey&&si(r,Qs(r.anchor.getNode())?"next":"previous"))return t.preventDefault(),!0;if(t.shiftKey||no(r,"arrow","start",e.peek()),Sd(r,!0)){const o=t.shiftKey;return t.preventDefault(),vd(r,o,!0),!0}return!1},V),n.registerCommand(ia,t=>{const r=D();if(ve(r)){const o=r.getNodes();if(o.length>0)return t.preventDefault(),ai(o[0],Qs(o[0])?"previous":"next"),!0}if(!F(r))return!1;if(!t.shiftKey&&si(r,Qs(r.anchor.getNode())?"previous":"next"))return t.preventDefault(),!0;if(t.shiftKey||no(r,"arrow","end",e.peek()),Sd(r,!1)){const o=t.shiftKey;return t.preventDefault(),vd(r,o,!1),!0}return!1},V),n.registerCommand(sa,t=>{const r=D();if(!ve(r)&&Qd(t.target))return!1;if(F(r)){if((function(o){if(!o.isCollapsed())return!1;const{anchor:s}=o;if(s.offset!==0)return!1;const i=s.getNode();if(Jp(i))return!1;const a=Rc(i);return a.getIndent()>0&&(a.is(i)||i.is(a.getFirstDescendant()))})(r))return t.preventDefault(),n.dispatchCommand(wn);if(xd&&Cd)return!1}else if(!ve(r))return!1;return t.preventDefault(),n.dispatchCommand(bi,!0)},V),n.registerCommand(Oc,t=>{const r=D();return!(!ve(r)&&Qd(t.target))&&!(!F(r)&&!ve(r))&&(t.preventDefault(),n.dispatchCommand(bi,!1))},V),n.registerCommand(zr,t=>{let r=D();if(ve(r)){const o=r.getNodes();o.length===1&&It(o[0])&&!o[0].isInline()&&(r=o[0].selectNext())}if(!F(r))return!1;if(no(r,"enter","both",e.peek()),t!==null){if((xd||xy||Cy)&&Cd)return!1;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(Nl,!1)}return n.dispatchCommand(Lo)},V),n.registerCommand(Nn,()=>{const t=D();return!!F(t)&&(n.blur(),!0)},V),n.registerCommand(Lc,t=>{const[,r]=uo(t);if(r.length>0){const o=t.clientX,s=t.clientY,i=El(o,s,n.getRootElement());if(i!==null){const{offset:a,node:l}=i,c=Ae(l);if(c!==null){const u=kr();if(oe(c))u.anchor.set(c.getKey(),a,"text"),u.focus.set(c.getKey(),a,"text");else{const d=c.getParentOrThrow().getKey(),g=c.getIndexWithinParent()+1;u.anchor.set(d,g,"element"),u.focus.set(d,g,"element")}const f=Ss(u);Ee(f)}n.dispatchCommand(Gd,r)}return t.preventDefault(),!0}return wy(t,n)},V),n.registerCommand(Wp,t=>{const[r]=uo(t),o=D();return!(r&&!F(o))&&(F(o)&&!o.isCollapsed()&&t.dataTransfer!==null&&(by(t.dataTransfer,Hp(o)),yy(t.dataTransfer,n)),!0)},V),n.registerCommand(Nc,t=>{const[r]=uo(t),o=D();if(r&&!F(o))return!1;const s=t.clientX,i=t.clientY,a=El(s,i,n.getRootElement());if(a!==null){const l=Ae(a.node);It(l)&&t.preventDefault()}return!0},V),n.registerCommand(Ec,()=>{const t=D();return _y(F(t)&&my(t.anchor.getNode())!==null?t:null),!0},V),n.registerCommand(Kp,t=>(Il(n,fo(t,ClipboardEvent)?t:null),!0),V),n.registerCommand(zp,t=>((async function(r,o){await Il(o,fo(r,ClipboardEvent)?r:null),o.update(()=>{const s=D();F(s)?s.removeText():ve(s)&&s.getNodes().forEach(i=>i.remove())},{tag:hy})})(t,n),!0),V),n.registerCommand(Ic,t=>{const[,r,o]=uo(t);return r.length>0&&!o?(n.dispatchCommand(Gd,r),!0):No(t.target)&&py(t.target)?!1:D()!==null&&((function(s,i){s.preventDefault(),i.update(()=>{const a=D(),l=fo(s,InputEvent)||fo(s,KeyboardEvent)?null:s.clipboardData;l!=null&&a!==null&&wd(l,a)},{tag:Up})})(t,n),!0)},V),n.registerCommand(Bp,()=>{const t=D();return F(t)&&no(t,"space","both",e.peek()),!1},V),n.registerCommand(Kr,()=>{const t=D();return F(t)&&no(t,"tab","both",e.peek()),!1},V),n.registerCommand(xs,t=>{const r=D();if(ve(r))return of(r,!1,t);if(!F(r))return!1;const{anchor:o}=r;if(o.type!=="element"||o.offset!==0)return!1;const s=o.getNode();if(!q(s))return!1;const i=s.getFirstChild();if(!It(i)||!i.isInline())return!1;const a=s.getKey(),l=s.selectEnd();return t.shiftKey&&l.anchor.set(a,0,"element"),t.preventDefault(),t.stopPropagation(),!0},V),n.registerCommand(Ir,t=>{const r=D();if(ve(r))return of(r,!0,t);if(!F(r))return!1;const{anchor:o,focus:s}=r,i=re(s.getNode(),c=>q(c)&&!c.isInline());if(i===null)return!1;const a=i.getFirstChild();if(!It(a)||!a.isInline()||re(o.getNode(),c=>q(c)&&!c.isInline())!==i)return!1;const l=i.getKey();return(s.type!=="element"||s.key!==l||s.offset!==0)&&(r.focus.set(l,0,"element"),t.shiftKey||r.anchor.set(l,0,"element"),t.preventDefault(),t.stopPropagation(),!0)},V))}function jn(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function Is(n){let e=1,t=n.getParent();for(;t!=null;){if(le(t)){const r=t.getParent();if(Z(r)){e++,t=r.getParent();continue}jn(40)}return e}return e}function Hl(n){const e=n.getParent();Z(e)||jn(40);let t=e,r=e;for(;r!==null;)r=r.getParent(),Z(r)&&(t=r);return t}function a_(n){let e=[];const t=n.getChildren().filter(le);for(let r=0;r<t.length;r++){const o=t[r],s=o.getFirstChild();Z(s)?e=e.concat(a_(s)):e.push(o)}return e}function Rt(n){return le(n)&&Z(n.getFirstChild())}function l_(n,e){return le(n)&&(e.length===0||e.length===1&&n.is(e[0])&&n.getChildrenSize()===0)}function Jl(n){const e=D();if(e!==null){let t=e.getNodes();if(F(e)){const[o]=e.getStartEndPoints(),s=o.getNode(),i=s.getParent();if(wt(s)){const a=s.getFirstChild();if(a)t=a.selectStart().getNodes();else{const l=ne();s.append(l),t=l.select().getNodes()}}else if(l_(s,t)){const a=Et(n);if(wt(i)){s.replace(a);const l=xt();q(s)&&(l.setFormat(s.getFormatType()),l.setIndent(s.getIndent())),a.append(l)}else if(le(s)){const l=s.getParentOrThrow();Nr(a,l.getChildren()),l.replace(a)}return}}const r=new Set;for(let o=0;o<t.length;o++){const s=t[o];if(q(s)&&s.isEmpty()&&!le(s)&&!r.has(s.getKey())){sf(s,n);continue}let i=Qp(s)?s.getParent():le(s)&&s.isEmpty()?s:null;for(;i!=null;){const a=i.getKey();if(Z(i)){if(!r.has(a)){const l=Et(n);Nr(l,i.getChildren()),i.replace(l),r.add(a)}break}{const l=i.getParent();if(wt(l)&&!r.has(a)){r.add(a),sf(i,n);break}i=l}}}}}function Nr(n,e){n.splice(n.getChildrenSize(),0,e)}function sf(n,e){if(Z(n))return n;const t=n.getPreviousSibling(),r=n.getNextSibling(),o=xt();let s;if(Nr(o,n.getChildren()),Z(t)&&e===t.getListType())t.append(o),Z(r)&&e===r.getListType()&&(Nr(t,r.getChildren()),r.remove()),s=t;else if(Z(r)&&e===r.getListType())r.getFirstChildOrThrow().insertBefore(o),s=r;else{const a=Et(e);a.append(o),n.replace(a),s=a}o.setFormat(n.getFormatType()),o.setIndent(n.getIndent());const i=D();return F(i)&&(s.getKey()===i.anchor.key&&i.anchor.set(o.getKey(),i.anchor.offset,"element"),s.getKey()===i.focus.key&&i.focus.set(o.getKey(),i.focus.offset,"element")),n.remove(),s}function Gc(n,e){const t=n.getLastChild(),r=e.getFirstChild();t&&r&&Rt(t)&&Rt(r)&&(Gc(t.getFirstChild(),r.getFirstChild()),r.remove());const o=e.getChildren();o.length>0&&n.append(...o),e.remove()}function V0(){const n=D();if(F(n)){const e=new Set,t=n.getNodes(),r=n.anchor.getNode();if(l_(r,t))e.add(Hl(r));else for(let o=0;o<t.length;o++){const s=t[o];if(Qp(s)){const i=Ol(s,bn);i!=null&&e.add(Hl(i))}}for(const o of e){let s=o;const i=a_(o);for(const a of i){const l=ne().setTextStyle(n.style).setTextFormat(n.format);Nr(l,a.getChildren()),s.insertAfter(l),s=l,a.__key===n.anchor.key&&hr(n.anchor,Jn(Er(l,"next"))),a.__key===n.focus.key&&hr(n.focus,Jn(Er(l,"next"))),a.remove()}o.remove()}}}function c_(n){const e=n.getListType()!=="check";let t=n.getStart();for(const r of n.getChildren())le(r)&&(r.getValue()!==t&&r.setValue(t),e&&r.getLatest().__checked!=null&&r.setChecked(void 0),Z(r.getFirstChild())||t++)}function Y0(n){const e=new Set;if(Rt(n)||e.has(n.getKey()))return;const t=n.getParent(),r=n.getNextSibling(),o=n.getPreviousSibling();if(Rt(r)&&Rt(o)){const s=o.getFirstChild();if(Z(s)){s.append(n);const i=r.getFirstChild();Z(i)&&(Nr(s,i.getChildren()),r.remove(),e.add(r.getKey()))}}else if(Rt(r)){const s=r.getFirstChild();if(Z(s)){const i=s.getFirstChild();i!==null&&i.insertBefore(n)}}else if(Rt(o)){const s=o.getFirstChild();Z(s)&&s.append(n)}else if(Z(t)){const s=it(n),i=it(t);s.append(i),i.append(n),o?o.insertAfter(s):r?r.insertBefore(s):t.append(s)}}function af(n){if(Rt(n))return;const e=n.getParent(),t=e?e.getParent():void 0;if(Z(t?t.getParent():void 0)&&le(t)&&Z(e)){const r=e?e.getFirstChild():void 0,o=e?e.getLastChild():void 0;if(n.is(r))t.insertBefore(n),e.isEmpty()&&t.remove();else if(n.is(o))t.insertAfter(n),e.isEmpty()&&t.remove();else{const s=it(n),i=it(e);s.append(i),n.getPreviousSiblings().forEach(c=>i.append(c));const a=it(n),l=it(e);a.append(l),Nr(l,n.getNextSiblings()),t.insertBefore(s),t.insertAfter(a),t.replace(n)}}}function X0(n=!1){const e=D();if(!F(e)||!e.isCollapsed())return!1;const t=e.anchor.getNode();let r=null;if(le(t)&&t.getChildrenSize()===0)r=t;else if(oe(t)){const c=t.getParent();le(c)&&c.getChildren().every(u=>oe(u)&&u.getTextContent().trim()==="")&&(r=c)}if(r===null)return!1;const o=Hl(r),s=r.getParent();Z(s)||jn(40);const i=s.getParent();let a;if(wt(i))a=ne(),o.insertAfter(a);else{if(!le(i))return!1;a=it(i),i.insertAfter(a)}a.setTextStyle(e.style).setTextFormat(e.format).select();const l=r.getNextSiblings();if(l.length>0){const c=n?(function(f,d){return f.getStart()+d.getIndexWithinParent()})(s,r):1,u=it(s).setStart(c);if(le(a)){const f=it(a);f.append(u),a.insertAfter(f)}else a.insertAfter(u);u.append(...l)}return(function(c){let u=c;for(;u.getNextSibling()==null&&u.getPreviousSibling()==null;){const f=u.getParent();if(f==null||!le(f)&&!Z(f))break;u=f}u.remove()})(r),!0}let bn=class extends Oe{__value;__checked;$config(){return this.config("listitem",{$transform:e=>{const t=e.getParent();if(Z(t))t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0);else if(t){const r=e.createParentElementNode();Z(r)||jn(340);const o=[e];for(const s of["previous","next"]){o.reverse();for(const{origin:i}of gt(e,s)){if(!le(i))break;o.push(i)}}e.insertBefore(r),r.splice(0,0,o),wt(t)||(Zp(r,Dc(gt(r,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),t.isEmpty()&&t.isAttached()&&t.remove())}},extends:Oe,importDOM:$c({li:()=>({conversion:G0,priority:0})})})}constructor(e=1,t=void 0,r){super(r),this.__value=e===void 0?1:e,this.__checked=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const t=Je().createElement("li");return this.updateListItemDOM(null,t,e),t}updateListItemDOM(e,t,r){(function(i,a){const l=a.getParent();!Z(l)||l.getListType()!=="check"||Z(a.getFirstChild())?(i.removeAttribute("role"),i.removeAttribute("tabIndex"),i.removeAttribute("aria-checked")):(i.setAttribute("role","checkbox"),i.setAttribute("tabIndex","-1"),i.setAttribute("aria-checked",a.getChecked()?"true":"false"))})(t,this),t.value=this.__value,(function(i,a,l){const c=a.list;if(!c)return;const u=c.listitem,f=c.nested&&c.nested.listitem,d=l.getParent(),g=Z(d)&&d.getListType()==="check",h=l.getChecked(),_=l.getChildren().some(w=>Z(w)),m=[];c.listitemChecked!==void 0&&m.push(c.listitemChecked),c.listitemUnchecked!==void 0&&m.push(c.listitemUnchecked),f!==void 0&&m.push(...ps(f)),m.length>0&&$t(i,...m);const b=[];if(u!==void 0&&b.push(...ps(u)),g){const w=h?c.listitemChecked:c.listitemUnchecked;w!==void 0&&b.push(w)}f!==void 0&&_&&b.push(...ps(f)),b.length>0&&Ie(i,...b)})(t,r.theme,this);const o=e?e.__style:"",s=this.__style;o!==s&&_o(t.style,s,o),(function(i,a,l){const c=a.__textStyle,u=l?l.__textStyle:"";if(l!==null&&u===c)return;const f=Td(c);for(const d in f)i.style.setProperty(`--listitem-marker-${d}`,f[d]);if(u!=="")for(const d in Td(u))d in f||i.style.removeProperty(`--listitem-marker-${d}`)})(t,this,e)}updateDOM(e,t,r){const o=t;return this.updateListItemDOM(e,o,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const t=this.createDOM(e._config),r=this.getFormatType();r&&(t.style.textAlign=r);const o=this.getDirection();return o&&(t.dir=o),Rt(this)?{after(s){if(ke(s)){const i=s.previousElementSibling;if(ke(i)&&i.nodeName==="LI"){for(;s.firstChild;)i.append(s.firstChild);s.remove()}}return s},element:t}:{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let t=0;t<e.length;t++){const r=e[t];if(q(r)&&this.canMergeWith(r)){const o=r.getChildren();this.append(...o),r.remove()}else super.append(r)}return this}replace(e,t){if(le(e))return super.replace(e);this.setIndent(0);const r=this.getParentOrThrow();if(!Z(r))return e;if(r.__first===this.getKey())r.insertBefore(e);else if(r.__last===this.getKey())r.insertAfter(e);else{const i=it(r);let a=this.getNextSibling();for(;a;){const l=a;a=a.getNextSibling(),i.append(l)}r.insertAfter(e),e.insertAfter(i)}const o=this.__key;let s=0;if(t&&(q(e)||jn(139),s=e.getChildrenSize(),e.splice(s,0,this.getChildren())),t&&q(e)){const i=D();if(F(i))for(const a of i.getStartEndPoints())a.key===o&&a.type==="element"&&a.set(e.getKey(),s+a.offset,"element")}return this.remove(),r.getChildrenSize()===0&&r.remove(),e}insertAfter(e,t=!0){const r=this.getParentOrThrow();if(Z(r)||jn(39),le(e))return super.insertAfter(e,t);const o=this.getNextSiblings();if(r.insertAfter(e,t),o.length!==0){const s=it(r);o.forEach(i=>s.append(i)),e.insertAfter(s,t)}return e}remove(e){const t=this.getPreviousSibling(),r=this.getNextSibling();super.remove(e),t&&r&&Rt(t)&&Rt(r)&&(Gc(t.getFirstChild(),r.getFirstChild()),r.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,t=!0){const r=it(this);return this.insertAfter(r,t),r}collapseAtStart(e){if(Rt(this))return!1;const t=this.getParentOrThrow();if(le(t.getParentOrThrow()))return af(this),!0;const r=ne().append(...this.getChildren()),o=this.getNextSiblings();if(o.length>0){const s=it(t);s.append(...o),t.insertAfter(s)}return t.insertAfter(r),this.remove(),t.getChildrenSize()===0&&t.remove(),r.selectStart(),!0}getValue(){return this.getLatest().__value}setValue(e){const t=this.getWritable();return t.__value=e,t}getChecked(){const e=this.getLatest();let t;const r=this.getParent();return Z(r)&&(t=r.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){const t=this.getWritable();return t.__checked=e,t}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(e===null||!this.isAttached())return this.getLatest().__indent;let t=e.getParentOrThrow(),r=0;for(;le(t);)t=t.getParentOrThrow().getParentOrThrow(),r++;return r}setIndent(e){typeof e!="number"&&jn(117),(e=Math.floor(e))>=0||jn(199);let t=this.getIndent();for(;t!==e;)t<e?(Y0(this),t++):(af(this),t--);return this}canInsertAfter(e){return le(e)}canReplaceWith(e){return le(e)}canMergeWith(e){return le(e)||ht(e)}extractWithChild(e,t){if(!F(t))return!1;const r=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(r)&&this.isParentOf(o)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Et("bullet")}canMergeWhenEmpty(){return!0}};function G0(n){if(n.classList.contains("task-list-item")){for(const r of n.children)if(r.tagName==="INPUT")return lf(r)}if(n.classList.contains("joplin-checkbox")){for(const r of n.children)if(r.classList.contains("checkbox-wrapper")&&r.children.length>0&&r.children[0].tagName==="INPUT")return lf(r.children[0])}const e=n.getAttribute("aria-checked"),t=xt(e==="true"||e!=="false"&&void 0);return rr(t,n),{after:u_.bind(null,t),node:mn(t,n)}}function lf(n){if(n.getAttribute("type")!=="checkbox")return{node:null};const e=xt(n.hasAttribute("checked"));return{after:u_.bind(null,e),node:e}}function u_(n,e){const t=e[0];return e.length===1&&ht(t)&&!n.getFormatType()&&t.getFormatType()?(n.setFormat(t.getFormatType()),t.getChildren()):e}function xt(n){return Ot(new bn(void 0,n))}function le(n){return n instanceof bn}let Yt=class extends Oe{__tag;__start;__listType;$config(){return this.config("list",{$transform:e=>{(function(t){const r=t.getNextSibling();Z(r)&&t.getListType()===r.getListType()&&Gc(t,r)})(e),c_(e)},extends:Oe,importDOM:$c({ol:()=>({conversion:uf,priority:0}),ul:()=>({conversion:uf,priority:0})})})}constructor(e="number",t=1,r){super(r);const o=Z0[e]||e;this.__listType=o,this.__tag=o==="number"?"ol":"ul",this.__start=t}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const t=this.getWritable();return t.__listType=e,t.__tag=e==="number"?"ol":"ul",t}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const t=this.getWritable();return t.__start=e,t}createDOM(e,t){const r=this.__tag,o=Je().createElement(r);return this.__start!==1&&o.setAttribute("start",String(this.__start)),o.__lexicalListType=this.__listType,cf(o,e.theme,this),o}updateDOM(e,t,r){return e.__tag!==this.__tag||e.__listType!==this.__listType||(cf(t,r.theme,this),e.__start!==this.__start&&t.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const t=this.createDOM(e._config,e);return ke(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,t,r){let o=r;for(let s=0;s<r.length;s++){const i=r[s];le(i)||(o===r&&(o=[...r]),o[s]=this.createListItemNode().append(!q(i)||Z(i)||i.isInline()?i:$e(i.getTextContent())))}return super.splice(e,t,o)}extractWithChild(e){return le(e)}createListItemNode(){return xt()}};function cf(n,e,t){const r=[],o=[],s=e.list;if(s!==void 0){const i=s[`${t.__tag}Depth`]||[],a=Is(t)-1,l=a%i.length,c=i[l],u=s[t.__tag];let f;const d=s.nested,g=s.checklist;if(d!==void 0&&d.list&&(f=d.list),u!==void 0&&r.push(u),g!==void 0&&t.__listType==="check"&&r.push(g),c!==void 0){r.push(...ps(c));for(let h=0;h<i.length;h++)h!==l&&o.push(t.__tag+h)}if(f!==void 0){const h=ps(f);a>1?r.push(...h):o.push(...h)}}o.length>0&&$t(n,...o),r.length>0&&Ie(n,...r)}function uf(n){let e;if((function(t){return ke(t)&&t.nodeName.toLowerCase()==="ol"})(n)){const t=n.start;e=Et("number",t)}else e=(function(t){if(t.getAttribute("__lexicallisttype")==="check"||t.classList.contains("contains-task-list")||t.getAttribute("data-is-checklist")==="1")return!0;for(const r of t.childNodes)if(ke(r)&&r.hasAttribute("aria-checked"))return!0;return!1})(n)?Et("check"):Et("bullet");return mn(e,n),{after:t=>(function(r,o){const s=o.createListItemNode.bind(o),i=[];for(let a=0;a<r.length;a++){const l=r[a];if(le(l)){i.push(l);const c=l.getChildren();c.length>1&&c.forEach(u=>{Z(u)&&i.push(s().append(u))})}else i.push(s().append(l))}return i})(t,e),node:e}}const Z0={ol:"number",ul:"bullet"};function Et(n="number",e=1){return Ot(new Yt(n,e))}function Z(n){return n instanceof Yt}const Zc=he("INSERT_CHECK_LIST_COMMAND");function Q0(n,e){const t=e&&e.disableTakeFocusOnClick||!1,r=typeof t=="boolean"?()=>t:t.peek.bind(t),o=c=>{const u=c.target;if(!ke(u))return!1;const f=u.__lexicalCheckListLastHandled;return f!==void 0&&c.timeStamp-f<500},s=c=>{const u=c.target;ke(u)&&(u.__lexicalCheckListLastHandled=c.timeStamp)},i=c=>{o(c)||(s(c),df(c,r()))},a=c=>{c.pointerType==="touch"&&(o(c)||(s(c),df(c,r())))},l=c=>{(function(u,f){d_(u,()=>{u.preventDefault(),f&&u.stopPropagation()})})(c,r())};return de(n.registerCommand(Zc,()=>(Jl("check"),!0),ee),n.registerCommand(Vt,c=>ff(c,n,!1),ee),n.registerCommand(pt,c=>ff(c,n,!0),ee),n.registerCommand(Nn,()=>{if(ql(n)!=null){const c=n.getRootElement();return c?.focus(),!0}return!1},ee),n.registerCommand(Bp,c=>{const u=ql(n);return!(u==null||!n.isEditable())&&(n.update(()=>{const f=Ae(u);le(f)&&(c.preventDefault(),f.toggleChecked())}),!0)},ee),n.registerCommand(zs,c=>n.read("latest",()=>{const u=D();if(F(u)&&u.isCollapsed()){const{anchor:f}=u,d=f.type==="element";if(d||f.offset===0){const g=f.getNode(),h=re(g,_=>q(_)&&!_.isInline());if(le(h)){const _=h.getParent();if(Z(_)&&_.getListType()==="check"&&(d||h.getFirstDescendant()===g)){const m=n.getElementByKey(h.__key);if(m!=null&&la(m)!==m)return m.focus(),c.preventDefault(),!0}}}}return!1}),ee),n.registerRootListener(c=>{if(c!==null)return de(Id(c,{click:i,pointerup:a}),Id(c,{mousedown:l,pointerdown:l},{capture:!0}),Jt(c,"touchstart",l,{capture:!0,passive:!1}))}))}function d_(n,e){const t=n.target;if(!ke(t))return;const r=t.firstChild;if(ke(r)&&(r.tagName==="UL"||r.tagName==="OL"))return;const o=t.parentNode;if(!o||o.__lexicalListType!=="check")return;let s=null,i=null;if("clientX"in n)s=n.clientX;else if("touches"in n){const g=n.touches;g.length>0&&(s=g[0].clientX,i="touch")}if(s==null)return;const a=t.getBoundingClientRect(),l=s/Wn(t),c=t.ownerDocument.defaultView,u=c?c.getComputedStyle(t,"::before"):{width:"0px"},f=parseFloat(u.width),d=i==="touch"||"pointerType"in n&&n.pointerType==="touch"?32:0;(t.dir==="rtl"?l<a.right+d&&l>a.right-f-d:l>a.left-d&&l<a.left+f+d)&&e()}function df(n,e){d_(n,()=>{if(ke(n.target)){const t=n.target,r=Oy(t);r!=null&&r.isEditable()&&r.update(()=>{const o=Ae(t);le(o)&&(e?(Ai(Ry),Ai(Ay)):t.focus(),o.toggleChecked())})}})}function ql(n){const e=n.getRootElement(),t=e?la(e):null;return ke(t)&&t.tagName==="LI"&&t.parentNode!=null&&t.parentNode.__lexicalListType==="check"?t:null}function ff(n,e,t){const r=ql(e);return r!=null&&e.update(()=>{const o=Ae(r);if(!le(o))return;const s=(function(i,a){let l=a?i.getPreviousSibling():i.getNextSibling(),c=i;for(;l==null&&le(c);)c=c.getParentOrThrow().getParent(),c!=null&&(l=a?c.getPreviousSibling():c.getNextSibling());for(;le(l);){const u=a?l.getLastChild():l.getFirstChild();if(!Z(u))return l;l=a?u.getLastChild():u.getFirstChild()}return null})(o,t);if(s!=null){s.selectStart();const i=e.getElementByKey(s.__key);i!=null&&(n.preventDefault(),setTimeout(()=>{i.focus()},0))}}),!1}function eC(n){const e=[];for(const t of n)if(le(t)){e.push(t);const r=t.getChildren();if(r.length>1)for(const o of r)Z(o)&&e.push(xt().append(o))}else e.push(xt().append(t));return e}const tC=Ye({$import:(n,e)=>{let t;var r;return eh(e,"ol")?t=Et("number",e.start):t=(r=e).matches('[__lexicallisttype="check"], .contains-task-list, [data-is-checklist="1"]')||r.querySelector(":scope > [aria-checked]")!==null?Et("check"):Et("bullet"),mn(t,e),[t.splice(0,0,th(eC(n.$importChildren(e)),e))]},match:Xe.tag("ol","ul"),name:"@lexical/list/list"});function f_(n,e){if(e.length!==1)return e;const t=e[0];return ht(t)&&!n.getFormatType()&&t.getFormatType()?(n.setFormat(t.getFormatType()),t.getChildren()):e}function g_(n){const e=i=>Ly(i)&&!Z(i);if(!n.some(e))return n;const t=[];let r=[];const o=()=>{r.length>0&&(t.push(r),r=[])};for(const i of n)e(i)?(o(),t.push(q(i)?i.getChildren():[i])):r.push(i);o();const s=[];for(const i of t)s.length>0&&s.push(vt()),s.push(...i);return s}const nC=Ye({$import:(n,e)=>{const t=e.getAttribute("aria-checked"),r=xt(t==="true"||t!=="false"&&void 0);return rr(r,e),mn(r,e),[r.splice(0,0,g_(f_(r,n.$importChildren(e))))]},match:Xe.tag("li"),name:"@lexical/list/li"});function gf(n,e,t){const r=eh(t,"input")?t:t.querySelector('input[type="checkbox"]');if(!r||r.getAttribute("type")!=="checkbox")return[];const o=xt(r.hasAttribute("checked"));return rr(o,e),mn(o,e),[o.splice(0,0,g_(f_(o,n.$importChildren(e))))]}const rC=[Ye({$import:(n,e,t)=>{const r=e.querySelector(':scope > input[type="checkbox"]');return r?gf(n,e,r):t()},match:Xe.tag("li").classAll("task-list-item"),name:"@lexical/list/li-task-list-item"}),Ye({$import:(n,e,t)=>{const r=e.querySelector(":scope > .checkbox-wrapper");if(!r)return t();const o=r.querySelector(':scope > input[type="checkbox"]');return o?gf(n,e,o):t()},match:Xe.tag("li").classAll("joplin-checkbox"),name:"@lexical/list/li-joplin-checkbox"}),tC,nC],oC=he("UPDATE_LIST_START_COMMAND"),Qc=he("INSERT_UNORDERED_LIST_COMMAND"),eu=he("INSERT_ORDERED_LIST_COMMAND"),sC=he("REMOVE_LIST_COMMAND");function iC(n,e){return de(n.registerCommand(eu,()=>(Jl("number"),!0),ee),n.registerCommand(oC,t=>{const{listNodeKey:r,newStart:o}=t,s=Q(r);return!!Z(s)&&(s.getListType()==="number"&&(s.setStart(o),c_(s)),!0)},ee),n.registerCommand(Qc,()=>(Jl("bullet"),!0),ee),n.registerCommand(sC,()=>(V0(),!0),ee),n.registerCommand(Lo,()=>X0(!!(e&&e.restoreNumbering)),ee),n.registerCommand(sa,t=>{const r=D();if(!F(r)||!r.isCollapsed())return!1;const{anchor:o}=r;if(o.offset!==0)return!1;let s=o.getNode();for(;!le(s);){if(s.getPreviousSibling()!==null)return!1;const i=s.getParent();if(i===null)return!1;s=i}return!(!le(s)||!s.collapseAtStart(r))&&(t.preventDefault(),!0)},My),n.registerNodeTransform(bn,t=>{const r=t.getFirstChild();if(r){if(oe(r)){const o=r.getStyle(),s=r.getFormat();t.getTextStyle()!==o&&t.setTextStyle(o),t.getTextFormat()!==s&&t.setTextFormat(s)}}else{const o=D();F(o)&&(o.style!==t.getTextStyle()||o.format!==t.getTextFormat())&&o.isCollapsed()&&t.is(o.anchor.getNode())&&t.setTextStyle(o.style).setTextFormat(o.format)}}),n.registerNodeTransform(cn,t=>{const r=t.getParent();if(le(r)&&t.is(r.getFirstChild())){const o=t.getStyle(),s=t.getFormat();o===r.getTextStyle()&&s===r.getTextFormat()||r.setTextStyle(o).setTextFormat(s)}}))}function aC(n){const e=t=>{const r=t.getParent();if(Z(t.getFirstChild())||!Z(r))return;const o=re(t,s=>le(s)&&Z(s.getParent())&&le(s.getPreviousSibling()));if(o===null&&t.getIndent()>0)t.setIndent(0);else if(le(o)){const s=o.getPreviousSibling();if(le(s)){const i=(function(l){let c=l,u=c.getFirstChild();for(;Z(u);){const f=u.getLastChild();if(!le(f))break;c=f,u=c.getFirstChild()}return c})(s),a=i.getParent();if(Z(a)){const l=Is(a);l+1<Is(r)&&t.setIndent(l)}}}};return n.registerNodeTransform(Yt,t=>{const r=[t];for(;r.length>0;){const o=r.shift();if(Z(o)){for(const s of o.getChildren())if(le(s)){e(s);const i=s.getFirstChild();Z(i)&&r.push(i)}}}})}const da=pe({build:(n,e,t)=>nr(e),config:tr({hasStrictIndent:!1,shouldPreserveNumbering:!1}),dependencies:[js,ln(Fs,{rules:rC})],name:"@lexical/list/List",nodes:()=>[Yt,bn],register(n,e,t){const r=t.getOutput();return de(zt(()=>iC(n,{restoreNumbering:r.shouldPreserveNumbering.value})),zt(()=>r.hasStrictIndent.value?aC(n):void 0))}}),lC=pe({build:(n,e)=>nr(e),config:tr({disableTakeFocusOnClick:!1}),dependencies:[da],name:"@lexical/list/CheckList",register:(n,e,t)=>Q0(n,t.getOutput())}),pf=new Set(["http:","https:","mailto:","sms:","tel:"]);class gn extends Oe{__url;__target;__rel;__title;$config(){return this.config("link",{extends:Oe,importDOM:{a:()=>({conversion:uC,priority:1})}})}constructor(e="",t={},r){super(r);const{target:o=null,rel:s=null,title:i=null}=t;this.__url=e,this.__target=o,this.__rel=s,this.__title=i}afterCloneFrom(e){super.afterCloneFrom(e),this.__url=e.__url,this.__rel=e.__rel,this.__target=e.__target,this.__title=e.__title}createDOM(e){const t=Je().createElement("a");return this.updateLinkDOM(null,t,e),Ie(t,e.theme.link),t}updateLinkDOM(e,t,r){if(nh(t)){e&&e.__url===this.__url||(t.href=this.sanitizeUrl(this.__url));for(const o of["target","rel","title"]){const s=`__${o}`,i=this[s];e&&e[s]===i||(i?t[o]=i:t.removeAttribute(o))}}}updateDOM(e,t,r){return this.updateLinkDOM(e,t,r),!1}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){const t=e;e=bf(e);try{const r=new URL(bf(e));if(!pf.has(r.protocol))return"about:blank"}catch{const o=t.replace(/[\u0000-\u001F\u007F\s]/g,"").match(/^([a-z][a-z0-9+.-]*):/i);if(o!=null&&!pf.has(`${o[1].toLowerCase()}:`))return"about:blank"}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const t=this.getWritable();return t.__url=e,t}getTarget(){return this.getLatest().__target}setTarget(e){const t=this.getWritable();return t.__target=e,t}getRel(){return this.getLatest().__rel}setRel(e){const t=this.getWritable();return t.__rel=e,t}getTitle(){return this.getLatest().__title}setTitle(e){const t=this.getWritable();return t.__title=e,t}insertNewAfter(e,t=!0){const r=it(this);return this.insertAfter(r,t),r}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,r){if(!F(t))return!1;const o=t.anchor.getNode(),s=t.focus.getNode();return(this.is(o)||this.isParentOf(o))&&(this.is(s)||this.isParentOf(s))&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}shouldMergeAdjacentLink(e){return this.getType()===e.getType()&&this.__url===e.__url&&this.__target===e.__target&&this.__rel===e.__rel&&this.__title===e.__title}}function hf(n){const e=vs(n,"next");return[e,e.getFlipped()]}function _f(n,e){for(const t of e)if(t.origin.isAttached()){const r=Jn(t);return void hr(n,r)}}function cC(n){const e=D();let t=null,r=null;function o(){F(e)&&(_f(e.anchor,t),_f(e.focus,r),Ss(e))}F(e)&&(t=hf(e.anchor),r=hf(e.focus));let s=!1;for(const a of Er(n,"next")){const l=a.origin;if(q(l)&&!l.isInline()){const c=l.getChildren();if(c.length>0){const u=it(n);u.append(...c),l.append(u),s=!0}Zp(l,Dc(a),{$shouldSplit:()=>!1})}}function i(a,l,c){const[u,f]=a,d=h=>Mc(h)&&h.origin.is(l);if(!d(u)&&!d(f))return a;const g=Jn(Er(c,"next"));return[g,g.getFlipped()]}if(n.isAttached()){const a=n.getPreviousSibling();if(Pe(a)&&a.shouldMergeAdjacentLink(n))return t&&(t=i(t,a,n)),r&&(r=i(r,a,n)),a.append(...n.getChildren()),n.remove(),void o();const l=n.getNextSibling();Pe(l)&&n.shouldMergeAdjacentLink(l)&&(t&&(t=i(t,n,l)),r&&(r=i(r,n,l)),n.append(...l.getChildren()),l.remove(),s=!0)}if(s){if(!n.canBeEmpty()&&n.isEmpty()){const a=n.getParent();n.remove(),a&&a.isEmpty()&&a.remove()}o()}}function uC(n){let e=null;if(nh(n)){const t=n.textContent;(t!==null&&t!==""||n.children.length>0)&&(e=Mo(n.getAttribute("href")||"",{rel:n.getAttribute("rel"),target:n.getAttribute("target"),title:n.getAttribute("title")}))}return{node:e}}function Mo(n="",e){return Ot(new gn(n,e))}function Pe(n){return n instanceof gn}let fa=class extends gn{__isUnlinked;constructor(e="",t={},r){super(e,t,r),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}afterCloneFrom(e){super.afterCloneFrom(e),this.__isUnlinked=e.__isUnlinked}$config(){return this.config("autolink",{extends:gn})}shouldMergeAdjacentLink(e){return!1}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?Je().createElement("span"):super.createDOM(e)}updateDOM(e,t,r){return super.updateDOM(e,t,r)||e.__isUnlinked!==this.__isUnlinked}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,t=!0){const r=p_(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(r,t),r}};function p_(n="",e){return Ot(new fa(n,e))}function _t(n){return n instanceof fa}const Lr=he("TOGGLE_LINK_COMMAND");function mf(n,e){if(n.type==="element"){const t=n.getNode();return q(t)||(function(r,...o){const s=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",r);for(const a of o)i.append("v",a);throw s.search=i.toString(),Error(`Minified Lexical error #${r}; visit ${s.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(252),t.getChildren()[n.offset+e]||null}return null}function Ka(n,e={}){let t;if(n&&typeof n=="object"){const{url:u,...f}=n;t=u,e={...f,...e}}else t=n;const{target:r,title:o}=e,s=e.rel===void 0?"noreferrer":e.rel,i=D();if(i===null||!F(i)&&!ve(i))return;if(ve(i)){const u=i.getNodes();return u.length===0?void 0:void u.forEach(f=>{if(t===null){const d=re(f,g=>!_t(g)&&Pe(g));d&&(d.insertBefore(f),d.getChildren().length===0&&d.remove())}else{const d=re(f,g=>!_t(g)&&Pe(g));if(d)d.setURL(t),r!==void 0&&d.setTarget(r),s!==void 0&&d.setRel(s);else{const g=Mo(t,{rel:s,target:r});f.insertBefore(g),g.append(f)}}})}if(i.isCollapsed()&&t===null)for(const u of i.getNodes()){const f=re(u,d=>!_t(d)&&Pe(d));return void(f!==null&&(f.getParentOrThrow().splice(f.getIndexWithinParent(),0,f.getChildren()),f.remove()))}const a=i.extract();if(t===null){const u=new Set;return void a.forEach(f=>{const d=re(f,g=>!_t(g)&&Pe(g));if(d!==null){const g=d.getKey();if(u.has(g))return;(function(h,_){const m=new Set(_.filter(N=>h.isParentOf(N)).map(N=>N.getKey())),b=h.getChildren(),w=N=>m.has(N.getKey())||q(N)&&_.some(O=>h.isParentOf(O)&&N.isParentOf(O)),C=b.filter(w);if(C.length===b.length)return b.forEach(N=>h.insertBefore(N)),void h.remove();const v=b.findIndex(w),k=b.findLastIndex(w),I=v===0,E=k===b.length-1;if(I)C.forEach(N=>h.insertBefore(N));else if(E)for(let N=C.length-1;N>=0;N--)h.insertAfter(C[N]);else{for(let O=C.length-1;O>=0;O--)h.insertAfter(C[O]);const N=b.slice(k+1);if(N.length>0){const O=it(h);C[C.length-1].insertAfter(O),N.forEach(M=>O.append(M))}}})(d,a),u.add(g)}})}const l=new Set,c=u=>{l.has(u.getKey())||(l.add(u.getKey()),u.setURL(t),r!==void 0&&u.setTarget(r),s!==void 0&&u.setRel(s),o!==void 0&&u.setTitle(o))};if(a.length===1){const u=a[0],f=re(u,Pe);if(f!==null)return c(f)}(function(u){const f=D();if(!F(f))return u();const d=Ss(f),g=d.isBackward(),h=mf(d.anchor,g?-1:0),_=mf(d.focus,g?0:-1);if(u(),h||_){const m=D();if(F(m)){const b=m.clone();if(h){const w=h.getParent();w&&b.anchor.set(w.getKey(),h.getIndexWithinParent()+(g?1:0),"element")}if(_){const w=_.getParent();w&&b.focus.set(w.getKey(),_.getIndexWithinParent()+(g?0:1),"element")}Ee(Ss(b))}}})(()=>{let u=null;for(const f of a){if(!f.isAttached())continue;const d=re(f,Pe);if(d){c(d);continue}if(q(f)){if(!f.isInline())continue;if(Pe(f)){if(!(_t(f)||u!==null&&u.getParentOrThrow().isParentOf(f))){c(f),u=f;continue}for(const h of f.getChildren())f.insertBefore(h);f.remove();continue}}const g=f.getPreviousSibling();Pe(g)&&g.is(u)?g.append(f):(u=Mo(t,{rel:s,target:r,title:o}),f.insertAfter(u),u.append(f))}})}const dC=/^\+?[0-9\s()-]{5,}$/;function bf(n){return n.match(/^[a-z][a-z0-9+.-]*:/i)||n.match(/^[/#.]/)?n:n.includes("@")?`mailto:${n}`:dC.test(n)?`tel:${n}`:`https://${n}`}const fC=[Ye({$import:(n,e)=>{if(!e.textContent&&e.children.length===0)return[];const t=e.getAttribute("href")||"",r={rel:e.getAttribute("rel"),target:e.getAttribute("target"),title:e.getAttribute("title")};return $y(n.$importChildren(e),()=>Mo(t,r))},match:Xe.tag("a"),name:"@lexical/link/a"})];function h_(n,e){return de(n.registerNodeTransform(gn,cC),n.registerCommand(Lr,t=>{const r=e.validateUrl.peek(),o=e.attributes.peek();if(t===null)return Ka(null),!0;if(typeof t=="string")return!(r!==void 0&&!r(t))&&(Ka(t,o),!0);{const{url:s,target:i,rel:a,title:l}=t;return Ka(s,{...o,rel:a,target:i,title:l}),!0}},V),zt(()=>{const t=e.validateUrl.value;if(!t)return;const r=e.attributes.value;return n.registerCommand(Ic,o=>{const s=D();if(!F(s)||s.isCollapsed()||!fo(o,ClipboardEvent)||o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return t(i)?!s.getNodes().some(a=>q(a)||oe(a)&&!a.isSimpleText())&&(n.dispatchCommand(Lr,{...r,url:i}),o.preventDefault(),!0):!1},ee)}))}const tu=pe({build:(n,e,t)=>nr(e),config:{attributes:void 0,validateUrl:void 0},dependencies:[js,ln(Fs,{rules:fC})],mergeConfig(n,e){const t=Eo(n,e);return n.attributes&&(t.attributes=Eo(n.attributes,t.attributes)),t},name:"@lexical/link/Link",nodes:()=>[gn],register:(n,e,t)=>h_(n,t.getOutput())});function Vl(n,e){for(let t=0;t<e.length;t++){const r=e[t](n);if(r)return r}return null}const __=/[.,;\s]/;function Bi(n,e){return e.test(n)}function m_(n,e){return Bi(n[n.length-1],e)}function Yl(n,e){return Bi(n[0],e)}function b_(n,e){let t=n.getPreviousSibling();return q(t)&&(t=t.getLastDescendant()),t===null||ue(t)||oe(t)&&m_(t.getTextContent(),e)}function y_(n,e){let t=n.getNextSibling();return q(t)&&(t=t.getFirstDescendant()),t===null||ue(t)||oe(t)&&Yl(t.getTextContent(),e)}function gC(n,e,t,r,o){return(n>0?Bi(r[n-1],t):b_(o[0],t))?e<r.length?Bi(r[e],t):y_(o[o.length-1],t):!1}function pC(n,e,t){const r=[],o=[],s=[];let i=0,a=0;const l=[...n];for(;l.length>0;){const c=l[0],u=c.getTextContent().length,f=a;a+u<=e?(r.push(c),i+=u):f>=t?s.push(c):o.push(c),a+=u,l.shift()}return[i,r,o,s]}function hC(n,e,t,r){const o=p_(r.url,r.attributes);if(n.length===1){let s,i=n[0];e===0?[s,i]=i.splitText(t):[,s,i]=i.splitText(e,t);const a=$e(r.text);return a.setFormat(s.getFormat()),a.setDetail(s.getDetail()),a.setStyle(s.getStyle()),o.append(a),s.replace(o),i}if(n.length>1){const s=n[0];let i,a=s.getTextContent().length;e===0?i=s:[,i]=s.splitText(e);const l=[];let c;for(let g=1;g<n.length;g++){const h=n[g],_=h.getTextContent().length,m=a;if(m<t)if(a+_<=t)l.push(h);else{const[b,w]=h.splitText(t-m);l.push(b),c=w}a+=_}const u=D(),f=u?u.getNodes().find(oe):void 0,d=$e(i.getTextContent());return d.setFormat(i.getFormat()),d.setDetail(i.getDetail()),d.setStyle(i.getStyle()),o.append(d,...l),f&&f===i&&(F(u)?d.select(u.anchor.offset,u.focus.offset):ve(u)&&d.select(0,d.getTextContent().length)),i.replace(o),c}}function yf(n,e,t,r){const o=n.getChildren(),s=o.length;for(let c=0;c<s;c++){const u=o[c];if(!oe(u)||!u.isSimpleText())return _s(n),void t(null,n.getURL())}const i=n.getTextContent(),a=Vl(i,e);if(a===null||a.text!==i||!b_(n,r)||!y_(n,r))return _s(n),void t(null,n.getURL());const l=n.getURL();if(l!==a.url&&(n.setURL(a.url),t(a.url,l)),a.attributes){const c=n.getRel();c!==a.attributes.rel&&(n.setRel(a.attributes.rel||null),t(a.attributes.rel||null,c));const u=n.getTarget();u!==a.attributes.target&&(n.setTarget(a.attributes.target||null),t(a.attributes.target||null,u))}}function _s(n){const e=n.getChildren();for(let t=e.length-1;t>=0;t--)n.insertAfter(e[t]);return n.remove(),e.map(t=>t.getLatest())}const w_={changeHandlers:[],excludeParents:[],matchers:[],separatorRegex:__};function _C(n,e=w_){const{matchers:t,changeHandlers:r,excludeParents:o,separatorRegex:s=__}=e,i=(a,l)=>{for(const c of r)c(a,l)};return de(n.registerNodeTransform(cn,a=>{const l=a.getParentOrThrow(),c=a.getPreviousSibling();if(_t(l))yf(l,t,i,s);else if(!Pe(l)&&!o.some(u=>u(l))){if(a.isSimpleText()&&(Yl(a.getTextContent(),s)||!_t(c))){const u=(function(f){const d=[f];let g=f.getNextSibling();for(;g!==null&&oe(g)&&g.isSimpleText()&&(d.push(g),!/[\s]/.test(g.getTextContent()));)g=g.getNextSibling();return d})(a);(function(f,d,g,h){for(const v of f){const k=v.getParent();if(_t(k)&&!k.getIsUnlinked())return}let _=[...f];const m=_.map(v=>v.getTextContent()).join("");let b,w=m,C=0;for(;(b=Vl(w,d))&&b!==null;){const v=b.index,k=v+b.length;if(gC(C+v,C+k,h,m,_)){const[I,,E,N]=pC(_,C+v,C+k);let O=!1;for(const R of E){const $=R.getParent();if(_t($)&&!$.getIsUnlinked()){O=!0;break}}if(O){C+=k,w=w.substring(k);continue}const M=hC(E,C+v-I,C+k-I,b);_=M?[M,...N]:N,g(b.url,null),C=0}else C+=k;w=w.substring(k)}})(u,t,i,s)}(function(u,f,d,g){const h=u.getParent(),_=u.getPreviousSibling(),m=u.getNextSibling(),b=u.getTextContent();if(!_t(h)||h.getIsUnlinked()){if(_t(_)&&!_.getIsUnlinked()&&_.is(u.getPreviousSibling())&&u.getParent()===_.getParent()){if(!Yl(b,g))return _s(_),void d(null,_.getURL());if(w=b,_.isEmailURI()?/^\.[a-zA-Z]{2,}/.test(w):/^\.[a-zA-Z0-9]{1,}/.test(w)){const C=_.getTextContent()+b,v=Vl(C,f);v!==null&&v.text===C&&(_.append(u),yf(_,f,d,g),d(null,_.getURL()))}}var w;!_t(m)||m.getIsUnlinked()||m_(b,g)||m.is(u.getNextSibling())&&u.getParent()===m.getParent()&&(_s(m),d(null,m.getURL()))}})(a,t,i,s)}}),n.registerCommand(Lr,a=>{const l=D();return a!==null||!F(l)||l.extract().forEach(c=>{const u=c.getParent();_t(u)&&(u.setIsUnlinked(!u.getIsUnlinked()),u.markDirty())}),!1},ee))}const mC=pe({config:w_,dependencies:[tu],mergeConfig(n,e){const t=Eo(n,e);for(const r of["matchers","changeHandlers","excludeParents"]){const o=e[r];Array.isArray(o)&&(t[r]=[...n[r],...o])}return t},name:"@lexical/link/AutoLink",nodes:[fa],register:_C}),Co=/^(\d+(?:\.\d+)?)px$/,te={BOTH:3,COLUMN:2,NO_STATUS:0,ROW:1};let Xt=class extends Oe{__colSpan;__rowSpan;__headerState;__width;__backgroundColor;__verticalAlign;$config(){return this.config("tablecell",{extends:Oe,importDOM:{td:()=>({conversion:wf,priority:0}),th:()=>({conversion:wf,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__rowSpan=e.__rowSpan,this.__backgroundColor=e.__backgroundColor,this.__verticalAlign=e.__verticalAlign,this.__colSpan=e.__colSpan,this.__headerState=e.__headerState,this.__width=e.__width}updateFromJSON(e){return super.updateFromJSON(e).setHeaderStyles(e.headerState).setColSpan(e.colSpan||1).setRowSpan(e.rowSpan||1).setWidth(e.width||void 0).setBackgroundColor(e.backgroundColor||null).setVerticalAlign(e.verticalAlign||void 0)}constructor(e=te.NO_STATUS,t=1,r,o){super(o),this.__colSpan=t,this.__rowSpan=1,this.__headerState=e,this.__width=r,this.__backgroundColor=null,this.__verticalAlign=void 0}createDOM(e){const t=Je().createElement(this.getTag());return this.__width&&(t.style.width=`${this.__width}px`),this.__colSpan>1&&(t.colSpan=this.__colSpan),this.__rowSpan>1&&(t.rowSpan=this.__rowSpan),this.__backgroundColor!==null&&(t.style.backgroundColor=this.__backgroundColor),Xl(this.__verticalAlign)&&(t.style.verticalAlign=this.__verticalAlign),Ie(t,e.theme.tableCell,this.hasHeader()&&e.theme.tableCellHeader),t}exportDOM(e){const t=super.exportDOM(e);if(ke(t.element)){const r=t.element;r.setAttribute("data-temporary-table-cell-lexical-key",this.getKey()),r.style.border="1px solid black",this.__colSpan>1&&(r.colSpan=this.__colSpan),this.__rowSpan>1&&(r.rowSpan=this.__rowSpan),r.style.width=`${this.getWidth()||75}px`,r.style.verticalAlign=this.getVerticalAlign()||"top",r.style.textAlign="start",this.__backgroundColor===null&&this.hasHeader()&&(r.style.backgroundColor="#f2f3f5")}return t}exportJSON(){return{...super.exportJSON(),...Xl(this.__verticalAlign)&&{verticalAlign:this.__verticalAlign},backgroundColor:this.getBackgroundColor(),colSpan:this.__colSpan,headerState:this.__headerState,rowSpan:this.__rowSpan,width:this.getWidth()}}getColSpan(){return this.getLatest().__colSpan}setColSpan(e){const t=this.getWritable();return t.__colSpan=e,t}getRowSpan(){return this.getLatest().__rowSpan}setRowSpan(e){const t=this.getWritable();return t.__rowSpan=e,t}getTag(){return this.hasHeader()?"th":"td"}setHeaderStyles(e,t=te.BOTH){const r=this.getWritable();return r.__headerState=e&t|r.__headerState&~t,r}getHeaderStyles(){return this.getLatest().__headerState}setWidth(e){const t=this.getWritable();return t.__width=e,t}getWidth(){return this.getLatest().__width}getBackgroundColor(){return this.getLatest().__backgroundColor}setBackgroundColor(e){const t=this.getWritable();return t.__backgroundColor=e,t}getVerticalAlign(){return this.getLatest().__verticalAlign}setVerticalAlign(e){const t=this.getWritable();return t.__verticalAlign=e||void 0,t}toggleHeaderStyle(e){const t=this.getWritable();return(t.__headerState&e)===e?t.__headerState-=e:t.__headerState+=e,t}hasHeaderState(e){return(this.getHeaderStyles()&e)===e}hasHeader(){return this.getLatest().__headerState!==te.NO_STATUS}updateDOM(e){return e.__headerState!==this.__headerState||e.__width!==this.__width||e.__colSpan!==this.__colSpan||e.__rowSpan!==this.__rowSpan||e.__backgroundColor!==this.__backgroundColor||e.__verticalAlign!==this.__verticalAlign}isShadowRoot(){return!0}collapseAtStart(){return!0}canBeEmpty(){return!1}canIndent(){return!1}};function Xl(n){return n==="middle"||n==="bottom"}function wf(n){const e=n,t=n.nodeName.toLowerCase();let r;Co.test(e.style.width)&&(r=parseFloat(e.style.width));let o=te.NO_STATUS;if(t==="th"){const _=e.getAttribute("scope");if(_==="col")o=te.COLUMN;else if(_==="row")o=te.ROW;else{const m=e.parentElement,b=ke(m)&&m.nodeName.toLowerCase()==="tr"&&ke(m.parentElement)&&(m.parentElement.nodeName.toLowerCase()==="thead"||m.rowIndex===0),w=e.cellIndex===0;b&&(o|=te.ROW),w&&(o|=te.COLUMN),o===te.NO_STATUS&&(o=te.ROW)}}const s=lt(o,e.colSpan,r);s.__rowSpan=e.rowSpan;const i=e.style.backgroundColor;i!==""&&(s.__backgroundColor=i);const a=e.style.verticalAlign;Xl(a)&&(s.__verticalAlign=a);const l=e.style,c=(l&&l.textDecoration||"").split(" "),u=l.fontWeight==="700"||l.fontWeight==="bold",f=c.includes("line-through"),d=l.fontStyle==="italic",g=c.includes("underline"),h=l.color;return{after:_=>{const m=[];let b=null;const w=()=>{if(b){const C=b.getFirstChild();ue(C)&&b.getChildrenSize()===1&&C.remove()}};for(const C of _)if(sh(C)||oe(C)||ue(C)){if(oe(C)&&(u&&C.toggleFormat("bold"),f&&C.toggleFormat("strikethrough"),d&&C.toggleFormat("italic"),g&&C.toggleFormat("underline"),h)){const v=C.getStyle();v.includes("color:")||C.setStyle(v+`color: ${h};`)}b?b.append(C):(b=ne().append(C),m.push(b))}else m.push(C),w(),b=null;return w(),m.length===0&&m.push(ne()),m},node:s}}function lt(n=te.NO_STATUS,e=1,t){return Ot(new Xt(n,e,t))}function J(n){return n instanceof Xt}const nu=he("INSERT_TABLE_COMMAND");function X(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}class Wo extends Oe{__height;$config(){return this.config("tablerow",{extends:Oe,importDOM:{tr:()=>({conversion:bC,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__height=e.__height}updateFromJSON(e){return super.updateFromJSON(e).setHeight(e.height)}constructor(e=void 0,t){super(t),this.__height=e}exportJSON(){const e=this.getHeight();return{...super.exportJSON(),...e===void 0?void 0:{height:e}}}createDOM(e){const t=Je().createElement("tr");return this.__height&&(t.style.height=`${this.__height}px`),Ie(t,e.theme.tableRow),t}extractWithChild(e,t,r){return r==="html"}isShadowRoot(){return!0}setHeight(e){const t=this.getWritable();return t.__height=e,t}getHeight(){return this.getLatest().__height}updateDOM(e){return e.__height!==this.__height}canBeEmpty(){return!1}canIndent(){return!1}}function bC(n){const e=n;let t;return Co.test(e.style.height)&&(t=parseFloat(e.style.height)),{after:r=>Mi(r,J),node:pn(t)}}function pn(n){return Ot(new Wo(n))}function ce(n){return n instanceof Wo}function x_(n,e,t=!0){const r=Ho();for(let o=0;o<n;o++){const s=pn();for(let i=0;i<e;i++){let a=te.NO_STATUS;typeof t=="object"?(o===0&&t.rows&&(a|=te.ROW),i===0&&t.columns&&(a|=te.COLUMN)):t&&(o===0&&(a|=te.ROW),i===0&&(a|=te.COLUMN));const l=lt(a),c=ne();c.append($e()),l.append(c),s.append(l)}r.append(s)}return r}function Gl(n){const e=re(n,t=>J(t));return J(e)?e:null}function ru(n){const e=re(n,t=>ce(t));if(ce(e))return e;throw new Error("Expected table cell to be inside of table row.")}function ot(n){const e=re(n,t=>be(t));if(be(e))return e;throw new Error("Expected table cell to be inside of table.")}function ou(n){const e=ru(n);return ot(e).getChildren().findIndex(t=>t.is(e))}function C_(n){return ru(n).getChildren().findIndex(e=>e.is(n))}function S_(n,e){const t=ot(n),{x:r,y:o}=t.getCordsFromCellNode(n,e);return{above:t.getCellNodeFromCords(r,o-1,e),below:t.getCellNodeFromCords(r,o+1,e),left:t.getCellNodeFromCords(r-1,o,e),right:t.getCellNodeFromCords(r+1,o,e)}}function yC(n,e){const t=n.getChildren();if(e>=t.length||e<0)throw new Error("Expected table cell to be inside of table row.");return t[e].remove(),n}function wC(n,e,t=!0,r,o){const s=n.getChildren();if(e>=s.length||e<0)throw new Error("Table row target index out of range");const i=s[e];if(!ce(i))throw new Error("Row before insertion index does not exist.");for(let a=0;a<r;a++){const l=i.getChildren(),c=l.length,u=pn();for(let f=0;f<c;f++){const d=l[f];J(d)||X(12);const{above:g,below:h}=S_(d,o);let _=te.NO_STATUS;const m=g&&g.getWidth()||h&&h.getWidth()||void 0;(g&&g.hasHeaderState(te.COLUMN)||h&&h.hasHeaderState(te.COLUMN))&&(_|=te.COLUMN);const b=lt(_,1,m);b.append(ne()),u.append(b)}t?i.insertAfter(u):i.insertBefore(u)}return n}const Zl=(n,e)=>n===te.BOTH||n===e?e:te.NO_STATUS;function ga(n=!0){const e=D();F(e)||ae(e)||X(188);const t=e.anchor.getNode(),r=e.focus.getNode(),[o]=We(t),[s,,i]=We(r),[,a,l]=ct(i,s,o),{startRow:c}=l,{startRow:u}=a;return n?Ui(c+o.__rowSpan>u+s.__rowSpan?o:s,!0):Ui(u<c?s:o,!1)}const xC=ga;function Ui(n,e=!0){const[,,t]=We(n),[r,o]=ct(t,n,n),s=r[0].length,{startRow:i}=o;let a=null;if(e){const l=i+n.__rowSpan-1,c=r[l],u=pn();for(let d=0;d<s;d++){const{cell:g,startRow:h}=c[d];if(h+g.__rowSpan-1<=l){const _=c[d].cell.__headerState,m=Zl(_,te.COLUMN);u.append(lt(m).append(ne()))}else g.setRowSpan(g.__rowSpan+1)}const f=t.getChildAtIndex(l);ce(f)||X(256),f.insertAfter(u),a=u}else{const l=i,c=r[l],u=pn();for(let d=0;d<s;d++){const{cell:g,startRow:h}=c[d];if(h===l){const _=c[d].cell.__headerState,m=Zl(_,te.COLUMN);u.append(lt(m).append(ne()))}else g.setRowSpan(g.__rowSpan+1)}const f=t.getChildAtIndex(l);ce(f)||X(257),f.insertBefore(u),a=u}return a}function CC(n,e,t=!0,r,o){const s=n.getChildren(),i=[];for(let a=0;a<s.length;a++){const l=s[a];if(ce(l))for(let c=0;c<r;c++){const u=l.getChildren();if(e>=u.length||e<0)throw new Error("Table column target index out of range");const f=u[e];J(f)||X(12);const{left:d,right:g}=S_(f,o);let h=te.NO_STATUS;(d&&d.hasHeaderState(te.ROW)||g&&g.hasHeaderState(te.ROW))&&(h|=te.ROW);const _=lt(h);_.append(ne()),i.push({newTableCell:_,targetCell:f})}}return i.forEach(({newTableCell:a,targetCell:l})=>{t?l.insertAfter(a):l.insertBefore(a)}),n}function pa(n=!0){const e=D();F(e)||ae(e)||X(188);const t=e.anchor.getNode(),r=e.focus.getNode(),[o]=We(t),[s,,i]=We(r),[,a,l]=ct(i,s,o),{startColumn:c}=l,{startColumn:u}=a;return n?zi(c+o.__colSpan>u+s.__colSpan?o:s,!0):zi(u<c?s:o,!1)}const SC=pa;function zi(n,e=!0,t=!0){const[,,r]=We(n),[o,s]=ct(r,n,n),i=o.length,{startColumn:a}=s,l=e?a+n.__colSpan-1:a-1,c=r.getFirstChild();ce(c)||X(120);let u=null;function f(h=te.NO_STATUS){const _=lt(h).append(ne());return u===null&&(u=_),_}let d=c;e:for(let h=0;h<i;h++){if(h!==0){const k=d.getNextSibling();ce(k)||X(121),d=k}const _=o[h],m=_[l<0?0:l].cell.__headerState,b=Zl(m,te.ROW);if(l<0){au(d,f(b));continue}const{cell:w,startColumn:C,startRow:v}=_[l];if(C+w.__colSpan-1<=l){let k=w,I=v,E=l;for(;I!==h&&k.__rowSpan>1;){if(E-=w.__colSpan,!(E>=0)){d.append(f(b));continue e}{const{cell:N,startRow:O}=_[E];k=N,I=O}}k.insertAfter(f(b))}else w.setColSpan(w.__colSpan+1)}u!==null&&t&&Es(u);const g=r.getColWidths();if(g){const h=[...g],_=l<0?0:l,m=h[_];h.splice(_,0,m),r.setColWidths(h)}return u}function vC(n,e){const t=n.getChildren();for(let r=0;r<t.length;r++){const o=t[r];if(ce(o)){const s=o.getChildren();if(e>=s.length||e<0)throw new Error("Table column target index out of range");s[e].remove()}}return n}function su(){const n=D();F(n)||ae(n)||X(188);const[e,t]=n.isBackward()?[n.focus.getNode(),n.anchor.getNode()]:[n.anchor.getNode(),n.focus.getNode()],[r,,o]=We(e),[s]=We(t),[i,a,l]=ct(o,r,s),{startRow:c}=a,{startRow:u}=l,f=u+s.__rowSpan-1;if(i.length===f-c+1)return void o.remove();const d=i[0].length,g=i[f+1],h=o.getChildAtIndex(f+1);for(let _=f;_>=c;_--){for(let b=d-1;b>=0;b--){const{cell:w,startRow:C,startColumn:v}=i[_][b];if(v===b){if(C<c||C+w.__rowSpan-1>f){const k=Math.max(C,c),I=Math.min(w.__rowSpan+C-1,f),E=k<=I?I-k+1:0;w.setRowSpan(w.__rowSpan-E)}if(C>=c&&C+w.__rowSpan-1>f&&_===f){ce(h)||X(387);let k=null;for(let I=0;I<b;I++){const E=g[I],N=E.cell;E.startRow===_+1&&(k=N),N.__colSpan>1&&(I+=N.__colSpan-1)}k===null?au(h,w):k.insertAfter(w)}}}const m=o.getChildAtIndex(_);ce(m)||X(206,String(_)),m.remove()}if(g!==void 0){const{cell:_}=g[0];Es(_)}else{const _=i[c-1],{cell:m}=_[0];Es(m)}}const kC=su;function iu(){const n=D();F(n)||ae(n)||X(188);const e=n.anchor.getNode(),t=n.focus.getNode(),[r,,o]=We(e),[s]=We(t),[i,a,l]=ct(o,r,s),{startColumn:c}=a,{startRow:u,startColumn:f}=l,d=Math.min(c,f),g=Math.max(c+r.__colSpan-1,f+s.__colSpan-1),h=g-d+1;if(i[0].length===g-d+1)return o.selectPrevious(),void o.remove();const _=i.length;for(let C=0;C<_;C++)for(let v=d;v<=g;v++){const{cell:k,startColumn:I}=i[C][v];if(I<d){if(v===d){const E=d-I;k.setColSpan(k.__colSpan-Math.min(h,k.__colSpan-E))}}else if(I+k.__colSpan-1>g){if(v===g){const E=g-I+1;k.setColSpan(k.__colSpan-E)}}else k.remove()}const m=i[u],b=c>f?m[c+r.__colSpan]:m[f+s.__colSpan];if(b!==void 0){const{cell:C}=b;Es(C)}else{const C=f<c?m[f-1]:m[c-1],{cell:v}=C;Es(v)}const w=o.getColWidths();if(w){const C=[...w];C.splice(d,h),o.setColWidths(C)}}const TC=iu;function Es(n){const e=n.getFirstDescendant();e==null?n.selectStart():e.getParentOrThrow().selectStart()}function au(n,e){const t=n.getFirstChild();t!==null?t.insertBefore(e):n.append(e)}function lu(n){if(n.length===0)return null;const e=ot(n[0]),[t]=at(e,null,null);let r=1/0,o=-1/0,s=1/0,i=-1/0;const a=new Set;for(const g of t)for(const h of g){if(!h||!h.cell)continue;const _=h.cell.getKey();if(!a.has(_)&&n.some(m=>m.is(h.cell))){a.add(_);const m=h.startRow,b=h.startColumn,w=h.cell.__rowSpan||1,C=h.cell.__colSpan||1;r=Math.min(r,m),o=Math.max(o,m+w-1),s=Math.min(s,b),i=Math.max(i,b+C-1)}}if(r===1/0||s===1/0)return null;const l=o-r+1,c=i-s+1,u=t[r][s];if(!u.cell)return null;const f=u.cell;f.setColSpan(c),f.setRowSpan(l);const d=new Set([f.getKey()]);for(let g=r;g<=o;g++)for(let h=s;h<=i;h++){const _=t[g][h];if(!_.cell)continue;const m=_.cell,b=m.getKey();d.has(b)||(d.add(b),IC(m)||f.append(...m.getChildren()),m.remove())}return f.getChildrenSize()===0&&f.append(ne()),f}function IC(n){if(n.getChildrenSize()!==1)return!1;const e=n.getFirstChildOrThrow();return!(!ht(e)||!e.isEmpty())}function v_(){const n=D();F(n)||ae(n)||X(188);const e=n.anchor.getNode(),t=re(e,J);return J(t)||X(148),cu(t)}function cu(n){const[e,t,r]=We(n),o=e.__colSpan,s=e.__rowSpan;if(o===1&&s===1)return;const[i,a]=ct(r,e,e),{startColumn:l,startRow:c}=a,u=e.__headerState&te.COLUMN,f=Array.from({length:o},(h,_)=>{let m=u;for(let b=0;m!==0&&b<i.length;b++)m&=i[b][_+l].cell.__headerState;return m}),d=e.__headerState&te.ROW,g=Array.from({length:s},(h,_)=>{let m=d;for(let b=0;m!==0&&b<i[0].length;b++)m&=i[_+c][b].cell.__headerState;return m});if(o>1){for(let h=1;h<o;h++)e.insertAfter(lt(f[h]|g[0]).append(ne()));e.setColSpan(1)}if(s>1){let h;for(let _=1;_<s;_++){const m=c+_,b=i[m];h=(h||t).getNextSibling(),ce(h)||X(125);let w=null;for(let C=0;C<l;C++){const v=b[C],k=v.cell;v.startRow===m&&(w=k),k.__colSpan>1&&(C+=k.__colSpan-1)}if(w===null)for(let C=o-1;C>=0;C--)au(h,lt(f[C]|g[_]).append(ne()));else for(let C=o-1;C>=0;C--)w.insertAfter(lt(f[C]|g[_]).append(ne()))}e.setRowSpan(1)}}function ct(n,e,t){const[r,o,s]=at(n,e,t);return o===null&&X(207),s===null&&X(208),[r,o,s]}function at(n,e,t){const r=[];let o=null,s=null;function i(l){let c=r[l];return c===void 0&&(r[l]=c=[]),c}const a=n.getChildren();for(let l=0;l<a.length;l++){const c=a[l];ce(c)||X(209);const u=i(l);for(let f=c.getFirstChild(),d=0;f!=null;f=f.getNextSibling()){for(J(f)||X(147);u[d]!==void 0;)d++;const g={cell:f,startColumn:d,startRow:l},{__rowSpan:h,__colSpan:_}=f;for(let m=0;m<h&&!(l+m>=a.length);m++){const b=i(l+m);for(let w=0;w<_;w++)b[d+w]=g}e!==null&&o===null&&e.is(f)&&(o=g),t!==null&&s===null&&t.is(f)&&(s=g)}}return[r,o,s]}function We(n){let e;if(n instanceof Xt)e=n;else if("__type"in n){const o=re(n,J);J(o)||X(148),e=o}else{const o=re(n.getNode(),J);J(o)||X(148),e=o}const t=e.getParent();ce(t)||X(149);const r=t.getParent();return be(r)||X(210),[e,t,r]}function Ns(n,e,t){let r,o=Math.min(e.startColumn,t.startColumn),s=Math.min(e.startRow,t.startRow),i=Math.max(e.startColumn+e.cell.__colSpan-1,t.startColumn+t.cell.__colSpan-1),a=Math.max(e.startRow+e.cell.__rowSpan-1,t.startRow+t.cell.__rowSpan-1);do{r=!1;for(let l=0;l<n.length;l++)for(let c=0;c<n[0].length;c++){const u=n[l][c];if(!u)continue;const f=u.startColumn+u.cell.__colSpan-1,d=u.startRow+u.cell.__rowSpan-1,g=u.startColumn<=i&&f>=o,h=u.startRow<=a&&d>=s;if(g&&h){const _=Math.min(o,u.startColumn),m=Math.max(i,f),b=Math.min(s,u.startRow),w=Math.max(a,d);_===o&&m===i&&b===s&&w===a||(o=_,i=m,s=b,a=w,r=!0)}}}while(r);return{maxColumn:i,maxRow:a,minColumn:o,minRow:s}}function uu(n){const e=n.getChildren();let t=null;for(const r of e){if(!ce(r)||(t===null&&(t=r.getChildrenSize()),r.getChildrenSize()!==t))return!1;const o=r.getChildren();for(const s of o)if(!J(s)||s.getRowSpan()!==1||s.getColSpan()!==1)return!1}return(t||0)>0}function EC(n,e,t){if(e===t)return;const r=n.getColumnCount();if(e<0||e>=r||t<0||t>=r||!uu(n))return;n.getChildren().filter(ce).forEach(s=>{const i=s.getChildren(),[a]=i.splice(e,1);i.splice(t,0,a),s.splice(0,i.length,i)});const o=n.getColWidths();if(o&&o.length===r){const s=[...o],[i]=s.splice(e,1);s.splice(t,0,i),n.setColWidths(s)}}function NC(n,e,t){if(e===t)return;const r=n.getChildren().filter(ce),o=r.length;if(e<0||e>=o||t<0||t>=o||!uu(n))return;const s=r[e],i=r[t];t>e?i.insertAfter(s):i.insertBefore(s)}function Ql(n){const[e,,t]=We(n),r=t.getChildren().filter(ce),o=r.length,s=r[0].getChildren().length,i=new Array(o);for(let a=0;a<o;a++)i[a]=new Array(s);for(let a=0;a<o;a++){const l=r[a].getChildren().filter(J);let c=0;for(let u=0;u<l.length;u++){for(;i[a][c];)c++;const f=l[u],d=f.__rowSpan||1,g=f.__colSpan||1;for(let h=0;h<d;h++)for(let _=0;_<g;_++)i[a+h][c+_]=f;if(e===f)return{colSpan:g,columnIndex:c,rowIndex:a,rowSpan:d};c+=g}}return null}function k_(n,e){const t=e.getStartEndPoints(),r=ae(e);if(t===null)return!1;const[o,s]=t,[i,a,l]=We(o),c=re(s.getNode(),R=>J(R));if(!(J(i)&&J(c)&&ce(a)&&be(l)))return!1;const[u,f,d]=ct(l,i,c),[g]=at(n,null,null),h=u.length,_=h>0?u[0].length:0;let m=f.startRow,b=f.startColumn,w=g.length,C=w>0?g[0].length:0;if(r){const R=Ns(u,f,d),$=R.maxRow-R.minRow+1,L=R.maxColumn-R.minColumn+1;m=R.minRow,b=R.minColumn,w=Math.min(w,$),C=Math.min(C,L)}let v=!1;const k=Math.min(h,m+w)-1,I=Math.min(_,b+C)-1,E=new Set;for(let R=m;R<=k;R++)for(let $=b;$<=I;$++){const L=u[R][$];E.has(L.cell.getKey())||L.cell.__rowSpan===1&&L.cell.__colSpan===1||(cu(L.cell),E.add(L.cell.getKey()),v=!0)}let[N]=at(l.getWritable(),null,null);const O=w-h+m;for(let R=0;R<O;R++)Ui(N[h-1][0].cell);const M=C-_+b;for(let R=0;R<M;R++)zi(N[0][_-1].cell,!0,!1);[N]=at(l.getWritable(),null,null);for(let R=m;R<m+w;R++)for(let $=b;$<b+C;$++){const L=R-m,A=$-b,B=g[L][A];if(B.startRow!==L||B.startColumn!==A)continue;const j=B.cell;if(j.__rowSpan!==1||j.__colSpan!==1){const H=[],ie=Math.min(R+j.__rowSpan,m+w)-1,Ne=Math.min($+j.__colSpan,b+C)-1;for(let Ce=R;Ce<=ie;Ce++)for(let ut=$;ut<=Ne;ut++){const Mn=N[Ce][ut];H.push(Mn.cell)}lu(H),v=!0}const{cell:U}=N[R][$],z=j.getBackgroundColor();z!=null&&U.setBackgroundColor(z);const K=U.getChildren();j.getChildren().forEach(H=>{oe(H)&&ne().append(H),U.append(H)}),K.forEach(H=>H.remove())}if(r&&v){const[R]=at(l.getWritable(),null,null);R[f.startRow][f.startColumn].cell.selectEnd()}return!0}function LC(n,e,t){const[r]=at(n,null,null);e>=0&&e<r.length||X(396,String(e));const o=r[e],s=t?te.ROW:te.NO_STATUS,i=new Set;for(let a=0;a<o.length;a++){const l=o[a];l!=null&&(i.has(l.cell)||(i.add(l.cell),l.cell.setHeaderStyles(s,te.ROW)))}}function OC(n,e,t){const[r]=at(n,null,null);r.length>0&&e>=0&&e<r[0].length||X(397,String(e));const o=t?te.COLUMN:te.NO_STATUS,s=new Set;for(let i=0;i<r.length;i++){const a=r[i][e];a!=null&&(s.has(a.cell)||(s.add(a.cell),a.cell.setHeaderStyles(o,te.COLUMN)))}}function Wa(n){const[[e,t,r,o],[s,i,a,l]]=["anchor","focus"].map(c=>{const u=n[c].getNode(),f=re(u,J);J(f)||X(238,c,u.getKey(),u.getType());const d=f.getParent();ce(d)||X(239,c);const g=d.getParent();return be(g)||X(240,c),[u,f,d,g]});return o.is(l)||X(241),{anchorCell:t,anchorNode:e,anchorRow:r,anchorTable:o,focusCell:i,focusNode:s,focusRow:a,focusTable:l}}class Vs{tableKey;anchor;focus;_cachedNodes;dirty;constructor(e,t,r){this.anchor=t,this.focus=r,t._selection=this,r._selection=this,this._cachedNodes=null,this.dirty=!1,this.tableKey=e}getStartEndPoints(){return[this.anchor,this.focus]}isValid(){if(this.tableKey==="root"||this.anchor.key==="root"||this.anchor.type!=="element"||this.focus.key==="root"||this.focus.type!=="element")return!1;const e=Q(this.tableKey),t=Q(this.anchor.key),r=Q(this.focus.key);return e!==null&&t!==null&&r!==null}isBackward(){return this.focus.isBefore(this.anchor)}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return ae(e)&&this.tableKey===e.tableKey&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)}set(e,t,r){this.dirty=this.dirty||e!==this.tableKey||t!==this.anchor.key||r!==this.focus.key,this.tableKey=e,this.anchor.key=t,this.focus.key=r,this._cachedNodes=null}clone(){return new Vs(this.tableKey,un(this.anchor.key,this.anchor.offset,this.anchor.type),un(this.focus.key,this.focus.offset,this.focus.type))}isCollapsed(){return!1}extract(){return this.getNodes()}insertRawText(e){if(e==="")return;const t=(e.endsWith(`
10
10
  `)?e.slice(0,-1):e).split(`
11
- `).map(s=>s.split(" ")),r=Ho();for(const s of t){const i=pn();for(const a of s){const l=lt(te.NO_STATUS),c=ne();a&&c.append($e(a)),l.append(c),i.append(l)}r.append(i)}const{anchorCell:o}=Wa(this);k_(r,o.select(0,o.getChildrenSize()))}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(J).forEach(o=>{const s=o.getFirstChild();ht(s)&&(t|=s.getTextFormat())});const r=rh[e];return(t&r)!==0}insertNodes(e){const t=this.focus.getNode();q(t)||G(151),Ss(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=Wa(this),r=Ql(e);r===null&&G(153);const o=Ql(t);o===null&&G(155);const s=Math.min(r.columnIndex,o.columnIndex),i=Math.max(r.columnIndex+r.colSpan-1,o.columnIndex+o.colSpan-1),a=Math.min(r.rowIndex,o.rowIndex),l=Math.max(r.rowIndex+r.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(s,i),fromY:Math.min(a,l),toX:Math.max(s,i),toY:Math.max(a,l)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(e!==null)return e;const{anchorTable:t,anchorCell:r,focusCell:o}=Wa(this),s=o.getParents()[1];if(s!==t){if(t.isParentOf(o)){const m=s.getParent();m==null&&G(159),this.set(this.tableKey,o.getKey(),m.getKey())}else{const m=t.getParent();m==null&&G(158),this.set(this.tableKey,m.getKey(),o.getKey())}return this.getNodes()}const[i,a,l]=ct(t,r,o),{minColumn:c,maxColumn:u,minRow:f,maxRow:d}=Ns(i,a,l),g=new Map([[t.getKey(),t]]);let h=null;for(let m=f;m<=d;m++)for(let b=c;b<=u;b++){const{cell:w}=i[m][b],C=w.getParent();ce(C)||G(160),C!==h&&(g.set(C.getKey(),C),h=C),g.has(w.getKey())||AC(w,v=>{g.set(v.getKey(),v)})}const _=Array.from(g.values());return Fy()||(this._cachedNodes=_),_}getTextContent(){const e=this.getNodes().filter(r=>J(r));let t="";for(let r=0;r<e.length;r++){const o=e[r],s=o.__parent,i=(e[r+1]||{}).__parent;t+=o.getTextContent()+(i!==s?`
12
- `:" ")}return t}}function ae(n){return n instanceof Vs}function RC(){const n=un("root",0,"element"),e=un("root",0,"element");return new Vs("root",n,e)}function Ki(n,e,t){n.getKey(),e.getKey(),t.getKey();const r=D(),o=ae(r)?r.clone():new Vs("root",un("root",0,"element"),un("root",0,"element"));return o.set(n.getKey(),e.getKey(),t.getKey()),o}function AC(n,e){const t=[[n]];for(let r=t.at(-1);r!==void 0&&t.length>0;r=t.at(-1)){const o=r.pop();o===void 0?t.pop():e(o)!==!1&&q(o)&&t.push(o.getChildren())}}function du(n,e=zo()){const t=Q(n);be(t)||G(231,n);const r=kt(t,e.getElementByKey(n));return r===null&&G(232,n),{tableElement:r,tableNode:t}}class MC{observers;nextFocus;shouldCheckSelectionForTable;constructor(){this.observers=new Map,this.nextFocus=null,this.shouldCheckSelectionForTable=null}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}setShouldCheckSelectionForTable(e){this.shouldCheckSelectionForTable=e}getAndClearShouldCheckSelectionForTable(){const{shouldCheckSelectionForTable:e}=this;return e?(this.shouldCheckSelectionForTable=null,e):null}removeObserver(e){const t=this.observers.get(e);return t!==void 0&&(t[0].removeListeners(),this.observers.delete(e),!0)}removeAllObservers(){for(const e of Array.from(this.observers.keys()))this.removeObserver(e)}$getTableNodesAndObservers(){const e=[];for(const[t,[r]]of Array.from(this.observers.entries())){const o=Q(t);be(o)?e.push([o,r]):this.removeObserver(t)}return e}}class T_{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;abortController;listenerOptions;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return du(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(t=>{this.editor.read("latest",()=>{let r=!1;for(let i=0;i<t.length;i++){const a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){r=!0;break}}if(!r)return;const{tableNode:o,tableElement:s}=this.$lookup();this.table=vo(o,s)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:r}=this.$lookup();this.table=vo(t,r),e.observe(r,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(e=!0){const t=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:r,tableElement:o}=this.$lookup();li(t,vo(r,o),null),e&&D()!==null&&(Ee(null),t.dispatchCommand(Ht))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();$t(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();Ie(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&G(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),li(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){const e=or(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const r=this.editor,{tableNode:o}=this.$lookup(),s=e.x,i=e.y;if(this.focusCell=e,!this.isHighlightingCells&&(t||this.anchorX!==s||this.anchorY!==i||this.tableSelection!=null&&this.anchorCellNodeKey!=null)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle()),this.focusX!==-1&&this.focusY!==-1&&s===this.focusX&&i===this.focusY)return!1;if(this.focusX=s,this.focusY=i,this.isHighlightingCells){const a=tc(o,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null){let l=a;if(l===null&&t&&(l=o.getCellNodeFromCords(s,i,this.table)),l!==null){const c=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=l.getKey(),this.tableSelection=Ki(o,c,l),Ee(this.tableSelection),r.dispatchCommand(Ht),li(r,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const e=this.anchorCellNodeKey?Q(this.anchorCellNodeKey):null;return J(e)?e:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return e===null&&G(234),e}$getFocusTableCell(){const e=this.focusCellNodeKey?Q(this.focusCellNodeKey):null;return J(e)?e:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return e===null&&G(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.focusX=-1,this.focusY=-1,this.focusCell=null,this.focusCellNodeKey=null;const{tableNode:t}=this.$lookup(),r=tc(t,e.elem);if(r!==null){const o=r.getKey();this.tableSelection!=null?(this.tableSelection=this.tableSelection.clone(),this.tableSelection.set(t.getKey(),o,o)):this.tableSelection=Ki(t,r,r),this.anchorCellNodeKey=o}}$formatCells(e){const t=D();ae(t)||G(236);const r=kr(),o=r.anchor,s=r.focus,i=t.getNodes().filter(J);i.length>0||G(237);const a=i[0].getFirstChild(),l=ht(a)?a.getFormatFlags(e,null):null;i.forEach(c=>{o.set(c.getKey(),0,"element"),s.set(c.getKey(),c.getChildrenSize(),"element"),r.formatText(e,l)}),Ee(t),this.editor.dispatchCommand(Ht)}$clearText(){const{editor:e}=this,t=Q(this.tableNodeKey);if(!be(t))throw new Error("Expected TableNode.");const r=D();ae(r)||G(253);const o=r.getNodes().filter(J),s=t.getFirstChild(),i=t.getLastChild();if(o.length>0&&s!==null&&i!==null&&ce(s)&&ce(i)&&o[0]===s.getFirstChild()&&o[o.length-1]===i.getLastChild()){t.selectPrevious();const a=t.getParent();return t.remove(),void(Jp(a)&&a.isEmpty()&&e.dispatchCommand(Lo))}o.forEach(a=>{if(q(a)){const l=ne(),c=$e();l.append(c),a.append(l),a.getChildren().forEach(u=>{u!==l&&u.remove()})}}),li(e,this.table,null),Ee(null),e.dispatchCommand(Ht)}}const So="__lexicalTableSelection";function I_(n){const e=Wy(n);return be(e)||G(386,n),e}const ro=40;function Ha(n,e,t){const r=o=>Math.max(1,Math.ceil(Math.min(ro,o)/ro*18));return n<=e+ro?-r(e+ro-n):n>=t-ro?r(n-(t-ro)):0}function Fn(n){return ke(n)&&n.nodeName==="TABLE"}function kt(n,e){if(!e)return e;const t=Fn(e)?e:e.querySelector("table");return Fn(t)||G(341,n.constructor.name,n.getType(),n.getKey(),e.nodeName),t}function ha(n){return n._window}function _a(n,e){for(let t=e,r=null;t!==null;t=t.getParent()){if(n.is(t))return r;J(t)&&(r=t)}return null}const $C=[[Vt,"down"],[pt,"up"],[zs,"backward"],[ia,"forward"]],DC=[Yp,Vp,bi],PC=[sa,Oc];function jC(n,e){return n.registerRootListener(t=>{if(t===null)return;const r=n._window;if(r!==null)return Jt(r,"pointerdown",o=>{const s=Oo(o);if(o.button!==0||!No(s)||!t.contains(s))return;const i=(function(a){const l=Do(a);if(l===null)return null;let c=l.elem;for(;c!=null;){if(c.nodeName==="TABLE"&&So in c&&c[So])return{cellElement:l,tableElement:c,tableObserver:c[So]};c=c.parentNode}return null})(s);n.update(()=>{if(ae(D())){for(const[u]of e.observers.values())u.$clearHighlight(!1);Ee(null),n.dispatchCommand(Ht)}if(!i)return;const{tableObserver:a,tableElement:l,cellElement:c}=i;(function(u,f,d,g,h,_){const m=u._window;if(!m)return;const b=v=>{if(h.isSelecting)return;h.isSelecting=!0,v!==null&&h.anchorCell===null&&u.update(()=>{h.$setAnchorCellForSelection(v)});let k=f.clientX,I=f.clientY,E=null;const N=()=>{h.isSelecting=!1,E!==null&&(m.cancelAnimationFrame(E),E=null),m.removeEventListener("pointerup",U),m.removeEventListener("pointermove",z)},O=(K,H)=>{const ie=g.getRootNode();if(!Dp(ie)&&!jc(ie))return null;for(const Ne of ie.elementsFromPoint(K,H)){const Ce=xf(g,Ne);if(Ce)return Ce}return null},M=(K,H)=>{h.anchorCell===null&&u.update(()=>{h.$setAnchorCellForSelection(K)}),h.focusCell!==null&&K.elem===h.focusCell.elem||(_.setNextFocus({focusCell:K,override:H,tableKey:h.tableNodeKey}),u.dispatchCommand(Ht))},R=K=>{for(let H=g.parentElement;H;H=H.parentElement)if(K==="x"?H.scrollWidth>H.clientWidth:H.scrollHeight>H.clientHeight){const ie=m.getComputedStyle(H),Ne=K==="x"?ie.overflowX:ie.overflowY;if(Ne==="auto"||Ne==="scroll")return H}return null},$=(K,H,ie)=>{let Ne,Ce;if(K===null)Ne=0,Ce=ie==="x"?m.innerWidth:m.innerHeight;else{const nn=K.getBoundingClientRect();Ne=ie==="x"?nn.left:nn.top,Ce=ie==="x"?nn.right:nn.bottom}const ut=Ha(H,Ne,Ce);if(ut===0)return!1;if(K===null){const nn=ie==="x"?m.scrollX:m.scrollY;return m.scrollBy(ie==="x"?ut:0,ie==="x"?0:ut),(ie==="x"?m.scrollX:m.scrollY)!==nn}if(ie==="x"){const nn=K.scrollLeft;return K.scrollLeft+=ut,K.scrollLeft!==nn}const Mn=K.scrollTop;return K.scrollTop+=ut,K.scrollTop!==Mn},L=(K,H)=>{let ie=k,Ne=I;if(K===null)ie=Math.min(Math.max(ie,1),m.innerWidth-1);else{const Ce=K.getBoundingClientRect();ie=Math.min(Math.max(ie,Ce.left+1),Ce.right-1)}if(H===null)Ne=Math.min(Math.max(Ne,1),m.innerHeight-1);else{const Ce=H.getBoundingClientRect();Ne=Math.min(Math.max(Ne,Ce.top+1),Ce.bottom-1)}return[ie,Ne]},A=()=>{const K=R("x");if(K!==null){const Ce=K.getBoundingClientRect();if(Ha(k,Ce.left,Ce.right)!==0)return!0}const H=R("y"),ie=H===null?0:H.getBoundingClientRect().top,Ne=H===null?m.innerHeight:H.getBoundingClientRect().bottom;return Ha(I,ie,Ne)!==0},B=()=>{if(E=null,!h.isSelecting)return;const K=R("x"),H=R("y"),ie=K!==null&&$(K,k,"x"),Ne=$(H,I,"y");if(ie||Ne){const[Ce,ut]=L(K,H),Mn=O(Ce,ut);Mn&&M(Mn,!1),E=m.requestAnimationFrame(B)}},j=()=>{E===null&&h.pointerType!=="touch"&&A()&&(E=m.requestAnimationFrame(B))},U=()=>{N()},z=K=>{if(!(Ce=>!(1&~Ce.buttons))(K)&&h.isSelecting)return void N();const H=Oo(K);if(!No(H))return;k=K.clientX,I=K.clientY;let ie=null;const Ne=!(Ed||g.contains(H));ie=Ne?xf(g,H):O(K.clientX,K.clientY),ie&&M(ie,Ne),j()};m.addEventListener("pointerup",U,h.listenerOptions),m.addEventListener("pointermove",z,h.listenerOptions)};h.pointerType=f.pointerType;const w=I_(h.tableNodeKey),C=mo();if(Ed&&f.shiftKey&&Ut(C,w)&&(F(C)||ae(C))){const v=C.anchor.getNode(),k=_a(w,C.anchor.getNode());k?(h.$setAnchorCellForSelection(mr(h,k)),h.$setFocusCellForSelection(d),yn(f)):(w.isBefore(v)?w.selectStart():w.selectEnd()).anchor.set(C.anchor.key,C.anchor.offset,C.anchor.type)}else f.pointerType!=="touch"&&h.$setAnchorCellForSelection(d);b(d)})(n,o,c,l,a,e)})})})}function E_(n,e,t,r,o){const s=t.getRootElement(),i=ha(t);s!==null&&i!==null||G(246);const a=new T_(t,n.getKey()),l=kt(n,e);(function(d,g){$o(d)!==null&&G(205),d[So]=g})(l,a),a.listenersToRemove.add(()=>(function(d,g){$o(d)===g&&delete d[So]})(l,a)),a.listenersToRemove.add(Jt(l,"mousedown",d=>{const g=Oo(d);d.detail>=3&&No(g)&&Do(g)!==null&&d.preventDefault()},a.listenerOptions));for(const[d,g]of $C)a.listenersToRemove.add(t.registerCommand(d,h=>O_(t,h,g,n,a,o),qe));a.listenersToRemove.add(t.registerCommand(Nn,d=>{const g=D();if(ae(g)){const h=_a(n,g.focus.getNode());if(h!==null)return yn(d),h.selectEnd(),!0}return!1},qe));const c=()=>{const d=D();return!!Ut(d,n)&&!!ae(d)&&(a.$clearText(),!0)};for(const d of DC)a.listenersToRemove.add(t.registerCommand(d,c,qe));const u=d=>{const g=D();if(!ae(g)&&!F(g))return!1;const h=n.isParentOf(g.anchor.getNode());if(h!==n.isParentOf(g.focus.getNode())){const _=h?"anchor":"focus",m=h?"focus":"anchor",{key:b,offset:w,type:C}=g[m];return n[g[_].isBefore(g[m])?"selectPrevious":"selectNext"]()[m].set(b,w,C),!1}return!!Ut(g,n)&&!!ae(g)&&(d&&(d.preventDefault(),d.stopPropagation()),a.$clearText(),!0)};for(const d of PC)a.listenersToRemove.add(t.registerCommand(d,u,qe));a.listenersToRemove.add(t.registerCommand(zp,d=>{const g=D();if(g){if(!ae(g)&&!F(g))return!1;Il(t,fo(d,ClipboardEvent)?d:null,Hp(g));const h=u(d);return F(g)?(g.removeText(),!0):h}return!1},qe));const f=s.ownerDocument;return a.listenersToRemove.add(Jt(f,"paste",d=>{d.defaultPrevented||t.read("latest",()=>{const g=D();return s.contains(f.activeElement)&&ae(g)&&Ut(g,n)})&&(d.preventDefault(),t.dispatchCommand(Ic,d))})),a.listenersToRemove.add(Jt(f,"copy",d=>{if(d.defaultPrevented)return;const g=Oo(d);g===s||No(g)&&s.contains(g)||t.read("latest",()=>{const h=D();return s.contains(la(s))&&ae(h)&&Ut(h,n)})&&(d.preventDefault(),t.dispatchCommand(Kp,d))})),a.listenersToRemove.add(t.registerCommand(Xe,d=>{const g=D();return!!Ut(g,n)&&!!ae(g)&&(a.$formatCells(d),!0)},qe)),a.listenersToRemove.add(t.registerCommand(Bn,d=>{const g=D();if(!ae(g)||!Ut(g,n))return!1;const h=g.anchor.getNode(),_=g.focus.getNode();if(!J(h)||!J(_))return!1;const[m,b,w]=ct(n,h,_),C=Math.max(b.startRow+b.cell.__rowSpan-1,w.startRow+w.cell.__rowSpan-1),v=Math.max(b.startColumn+b.cell.__colSpan-1,w.startColumn+w.cell.__colSpan-1),k=Math.min(b.startRow,w.startRow),I=Math.min(b.startColumn,w.startColumn);if(k===0&&I===0&&C===m.length-1&&v===m[0].length-1)return n.setFormat(d),!0;const E=new Set;for(let N=k;N<=C;N++)for(let O=I;O<=v;O++){const M=m[N][O].cell;if(E.has(M))continue;E.add(M),M.setFormat(d);const R=M.getChildren();for(let $=0;$<R.length;$++){const L=R[$];q(L)&&!L.isInline()&&L.setFormat(d)}}return!0},qe)),a.listenersToRemove.add(t.registerCommand(qp,d=>{const g=D();if(!Ut(g,n))return!1;if(ae(g))return a.$clearHighlight(),!1;if(F(g)){const h=re(g.anchor.getNode(),_=>J(_));if(!J(h))return!1;if(typeof d=="string"){const _=Sf(t,g,n);if(_)return Cf(_,n,[$e(d)]),!0}}return!1},qe)),r&&a.listenersToRemove.add(t.registerCommand(Kr,d=>{const g=D();if(!F(g)||!g.isCollapsed()||!Ut(g,n))return!1;const h=ho(g.anchor.getNode());return!(h===null||!n.is(Or(h)))&&(yn(d),(function(_,m){const b=m==="next"?"getNextSibling":"getPreviousSibling",w=m==="next"?"getFirstChild":"getLastChild",C=_[b]();if(q(C))return C.selectEnd();const v=re(_,ce);v===null&&G(247);for(let I=v[b]();ce(I);I=I[b]()){const E=I[w]();if(q(E))return E.selectEnd()}const k=re(v,be);k===null&&G(248),m==="next"?k.selectNext():k.selectPrevious()})(h,d.shiftKey?"previous":"next"),!0)},qe)),a.listenersToRemove.add(t.registerCommand(oh,d=>n.isSelected(),qe)),a.listenersToRemove.add(t.registerCommand(Lo,()=>{const d=D();if(!F(d)||!d.isCollapsed()||!Ut(d,n))return!1;const g=Sf(t,d,n);return!!g&&(Cf(g,n),!0)},qe)),a}function FC(n,e){const t=D(),r=mo(),o=n.getAndClearNextFocus();if(o!==null){const{tableKey:i,focusCell:a}=o,l=n.observers.get(i);l||G(335,i);const[c]=l;if(ae(t)&&t.tableKey===c.tableNodeKey)return(a.x!==c.focusX||a.y!==c.focusY)&&(c.$setFocusCellForSelection(a),!0);if(c.anchorCell!==null&&c.anchorCellNodeKey!==null&&a.elem!==c.anchorCell.elem&&c.tableSelection!==null)return c.$setFocusCellForSelection(a,!0),!0}const s=n.getAndClearShouldCheckSelectionForTable();if(s&&F(r)&&F(t)&&t.isCollapsed()){const i=Q(s);if(be(i)){const a=t.anchor.getNode(),l=i.getFirstChild(),c=ho(a);if(c!==null&&ce(l)){const u=l.getFirstChild();if(J(u)&&i.is(re(c,f=>f.is(i)||f.is(u))))return u.selectStart(),!0}}}ae(t)&&(function(i,a){const l=ha(i),c=mo();if(!a.is(c))return;const u=I_(a.tableKey),f=or(l),d=f&&Pc(f,i.getRootElement());if(f&&d&&d.anchorNode&&d.focusNode){const g=Ae(d.focusNode),h=g&&!u.isParentOf(g),_=Ae(d.anchorNode),m=_&&u.isParentOf(_);if(h&&m&&f.rangeCount>0){const b=Uy(f,i);b&&(b.anchor.set(u.getKey(),a.isBackward()?u.getChildrenSize():0,"element"),f.removeAllRanges(),Ee(b))}}})(e,t),F(t)&&(function(i,a){const l=mo(),{anchor:c,focus:u}=i,f=c.getNode(),d=u.getNode(),g=ho(f),h=ho(d),_=g?Or(g):null,m=h?Or(h):null,b=i.isBackward(),w=g&&h&&_&&m&&_.is(m),C=m&&(!_||_.isParentOf(m)),v=_&&(!m||m.isParentOf(_));if(C){const k=i.clone(),[I]=ct(m,h,h),E=I[0][0].cell,N=I[I.length-1].at(-1).cell;k.focus.set(b?E.getKey():N.getKey(),b?0:N.getChildrenSize(),"element"),Ee(k)}else if(v){const k=i.clone(),[I]=ct(_,g,g),E=I[0][0].cell,N=I[I.length-1].at(-1).cell;k.anchor.set(b?N.getKey():E.getKey(),b?N.getChildrenSize():0,"element"),Ee(k)}else if(w){const k=a.observers.get(_.getKey());k||G(335,_.getKey());const[I]=k;if(g.is(h)||(I.$setAnchorCellForSelection(mr(I,g)),I.$setFocusCellForSelection(mr(I,h),!0)),I.pointerType==="touch"&&I.isSelecting&&i.isCollapsed()&&F(l)&&l.isCollapsed()){const E=ho(l.anchor.getNode());E&&!E.is(h)&&(I.$setAnchorCellForSelection(mr(I,E)),I.$setFocusCellForSelection(mr(I,h),!0),I.pointerType=null)}}})(t,n);for(const[i,a]of n.$getTableNodesAndObservers())BC(e,i,a);return!1}function BC(n,e,t){const r=D(),o=mo();r&&!r.is(o)&&(ae(r)||ae(o))&&t.tableSelection&&!t.tableSelection.is(o)&&(ae(r)&&r.tableKey===t.tableNodeKey?t.$updateTableTableSelection(r):!ae(r)&&ae(o)&&o.tableKey===t.tableNodeKey&&t.$updateTableTableSelection(null)),t.hasHijackedSelectionStyles&&!e.isSelected()?(function(s,i){i.$enableHighlightStyle(),ec(i.table,a=>{const l=a.elem;a.highlighted=!1,L_(s,a),l.getAttribute("style")||l.removeAttribute("style")})})(n,t):!t.hasHijackedSelectionStyles&&e.isSelected()&&(function(s,i){i.$disableHighlightStyle(),ec(i.table,a=>{a.highlighted=!0,N_(s,a)})})(n,t)}function $o(n){return n[So]||null}function Do(n){let e=n;for(;e!=null;){const t=e.nodeName;if(t==="TD"||t==="TH"){const r=e._cell;return r===void 0?null:r}e=e.parentNode}return null}function xf(n,e){if(!n.contains(e))return null;let t=null;for(let r=e;r!=null;r=r.parentNode){if(r===n)return t;const o=r.nodeName;o!=="TD"&&o!=="TH"||(t=r._cell||null)}return null}function vo(n,e){const t=[],r={columns:0,domRows:t,rows:0};let o=kt(n,e).querySelector("tr"),s=0,i=0;for(t.length=0;o!=null;){const a=o.nodeName;if(a==="TD"||a==="TH"){const u={elem:o,hasBackgroundColor:o.style.backgroundColor!=="",highlighted:!1,x:s,y:i};o._cell=u;let f=t[i];f===void 0&&(f=t[i]=[]),f[s]=u}else{const u=o.firstChild;if(u!=null){o=u;continue}}const l=o.nextSibling;if(l!=null){s++,o=l;continue}const c=o.parentNode;if(c!=null){const u=c.nextSibling;if(u==null)break;i++,s=0,o=u}}return r.columns=s+1,r.rows=i+1,r}function li(n,e,t){const r=new Set(t?t.getNodes():[]);ec(e,(o,s)=>{const i=o.elem;r.has(s)?(o.highlighted=!0,N_(n,o)):(o.highlighted=!1,L_(n,o),i.getAttribute("style")||i.removeAttribute("style"))})}function ec(n,e){const{domRows:t}=n;for(let r=0;r<t.length;r++){const o=t[r];if(o)for(let s=0;s<o.length;s++){const i=o[s];if(!i)continue;const a=Ae(i.elem);a!==null&&e(i,a,{x:s,y:r})}}}const UC=(n,e,t,r,o)=>{const s=o==="forward";switch(o){case"backward":case"forward":return t!==(s?n.table.columns-1:0)?ui(e.getCellNodeFromCordsOrThrow(t+(s?1:-1),r,n.table),s):r!==(s?n.table.rows-1:0)?ui(e.getCellNodeFromCordsOrThrow(s?0:n.table.columns-1,r+(s?1:-1),n.table),s):s?e.selectNext():e.selectPrevious(),!0;case"up":return r!==0?ui(e.getCellNodeFromCordsOrThrow(t,r-1,n.table),!1):e.selectPrevious(),!0;case"down":return r!==n.table.rows-1?ui(e.getCellNodeFromCordsOrThrow(t,r+1,n.table),!0):e.selectNext(),!0;default:return!1}};function Ja(n,e){let t,r;if(e.startColumn===n.minColumn)t="minColumn";else{if(e.startColumn+e.cell.__colSpan-1!==n.maxColumn)return null;t="maxColumn"}if(e.startRow===n.minRow)r="minRow";else{if(e.startRow+e.cell.__rowSpan-1!==n.maxRow)return null;r="maxRow"}return[t,r]}function ci([n,e]){return[n==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function oo(n,e,[t,r]){const o=e[r],s=n[o];s===void 0&&G(250,r,String(o));const i=e[t],a=s[i];return a===void 0&&G(250,t,String(i)),a}function zC(n,e,t,r,o){const s=Ns(e,t,r),i=(function(I,E){const{minColumn:N,maxColumn:O,minRow:M,maxRow:R}=E;let $=1,L=1,A=1,B=1;const j=I[M],U=I[R];for(let z=N;z<=O;z++)$=Math.max($,j[z].cell.__rowSpan),B=Math.max(B,U[z].cell.__rowSpan);for(let z=M;z<=R;z++)L=Math.max(L,I[z][N].cell.__colSpan),A=Math.max(A,I[z][O].cell.__colSpan);return{bottomSpan:B,leftSpan:L,rightSpan:A,topSpan:$}})(e,s),{topSpan:a,leftSpan:l,bottomSpan:c,rightSpan:u}=i,f=(function(I,E){const N=Ja(I,E);return N===null&&G(249,E.cell.getKey()),N})(s,t),[d,g]=ci(f);let h=s[d],_=s[g];o==="forward"?h+=d==="maxColumn"?1:l:o==="backward"?h-=d==="minColumn"?1:u:o==="down"?_+=g==="maxRow"?1:a:o==="up"&&(_-=g==="minRow"?1:c);const m=e[_];if(m===void 0)return!1;const b=m[h];if(b===void 0)return!1;const[w,C]=(function(I,E,N){const O=Ns(I,E,N),M=Ja(O,E);if(M)return[oo(I,O,M),oo(I,O,ci(M))];const R=Ja(O,N);if(R)return[oo(I,O,ci(R)),oo(I,O,R)];const $=["minColumn","minRow"];return[oo(I,O,$),oo(I,O,ci($))]})(e,t,b),v=mr(n,w.cell),k=mr(n,C.cell);return n.$setAnchorCellForSelection(v),n.$setFocusCellForSelection(k,!0),!0}function Ut(n,e){if(F(n)||ae(n)){const t=e.isParentOf(n.anchor.getNode()),r=e.isParentOf(n.focus.getNode());return t&&r}return!1}function ui(n,e){e?n.selectStart():n.selectEnd()}function N_(n,e){const t=e.elem,r=n._config.theme;J(Ae(t))||G(131),Ie(t,r.tableCellSelected)}function L_(n,e){const t=e.elem;J(Ae(t))||G(131);const r=n._config.theme;$t(t,r.tableCellSelected)}function ho(n){const e=re(n,J);return J(e)?e:null}function Or(n){const e=re(n,be);return be(e)?e:null}function KC(n,e,t,r,o,s,i){const a=vs(t.focus,o?"previous":"next");if(zy(a))return!1;let l=a;for(const m of Ll(a).iterNodeCarets("shadowRoot")){if(!Mc(m)||!q(m.origin))return!1;l=m}const c=l.getParentAtCaret();if(!J(c))return!1;const u=c,f=(function(m){for(const b of Ll(m).iterNodeCarets("root")){const{origin:w}=b;if(J(w)){if(Nd(b))return Er(w,m.direction)}else if(!ce(w))break}return null})(gt(u,l.direction)),d=re(u,be);if(!d||!d.is(s))return!1;const g=n.getElementByKey(u.getKey()),h=Do(g);if(!g||!h)return!1;const _=A_(n,d);if(i.table=_,f)if(r==="extend"){const m=Do(n.getElementByKey(f.origin.getKey()));if(!m)return!1;i.$setAnchorCellForSelection(h),i.$setFocusCellForSelection(m,!0)}else{const m=Jn(f);hr(t.anchor,m),hr(t.focus,m)}else if(r==="extend")i.$setAnchorCellForSelection(h),i.$setFocusCellForSelection(h,!0);else{const m=(function(b){const w=Ky(b);return Nd(w)?Jn(w):b})(gt(d,a.direction));hr(t.anchor,m),hr(t.focus,m)}return yn(e),!0}function O_(n,e,t,r,o,s){if((t==="up"||t==="down")&&(function(a){const l=a.getRootElement();return l?l.hasAttribute("aria-controls")&&l.getAttribute("aria-controls")==="typeahead-menu":!1})(n))return!1;const i=D();if(!Ut(i,r)){if(F(i)){if(t==="backward"){if(i.focus.offset>0)return!1;const a=(function(c){for(let u=c,f=c;f!==null;u=f,f=f.getParent())if(q(f)){if(f!==u&&f.getFirstChild()!==u)return null;if(!f.isInline())return f}return null})(i.focus.getNode());if(!a)return!1;const l=a.getPreviousSibling();return!!be(l)&&(yn(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),!0)}if(e.shiftKey&&(t==="up"||t==="down")){const a=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let l=re(a,g=>be(g));if(J(l)&&(l=re(l,be)),l!==r||!l)return!1;const c=t==="down"?l.getNextSibling():l.getPreviousSibling();if(!c)return!1;let u=0;t==="up"&&q(c)&&(u=c.getChildrenSize());let f=c;t==="up"&&q(c)&&(f=c.getLastChild()||c,u=oe(f)?f.getTextContentSize():0);const d=i.clone();return d.focus.set(f.getKey(),u,oe(f)?"text":"element"),Ee(d),yn(e),!0}if(wt(a)){const l=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(l&&_a(r,l)!==null){const c=r.getFirstDescendant(),u=r.getLastDescendant();if(!c||!u)return!1;const[f]=We(c),[d]=We(u),g=r.getCordsFromCellNode(f,o.table),h=r.getCordsFromCellNode(d,o.table),_=r.getDOMCellFromCordsOrThrow(g.x,g.y,o.table),m=r.getDOMCellFromCordsOrThrow(h.x,h.y,o.table);return o.$setAnchorCellForSelection(_),o.$setFocusCellForSelection(m,!0),!0}return!1}{let l=re(a,u=>q(u)&&!u.isInline());if(J(l)&&(l=re(l,be)),!l)return!1;const c=t==="down"?l.getNextSibling():l.getPreviousSibling();if(be(c)&&o.tableNodeKey===c.getKey()){const u=c.getFirstDescendant(),f=c.getLastDescendant();if(!u||!f)return!1;const[d]=We(u),[g]=We(f),h=i.clone();return h.focus.set((t==="up"?d:g).getKey(),t==="up"?0:g.getChildrenSize(),"element"),yn(e),Ee(h),!0}}}}return t==="down"&&Po(n)&&s.setShouldCheckSelectionForTable(r.getKey()),!1}if(F(i)){if(t==="backward"||t==="forward")return KC(n,e,i,e.shiftKey?"extend":"move",t==="backward",r,o);if(i.isCollapsed()){const{anchor:a,focus:l}=i,c=re(a.getNode(),J),u=re(l.getNode(),J);if(!J(c)||!c.is(u))return!1;const f=Or(c);if(f!==r&&f!=null){const w=kt(f,n.getElementByKey(f.getKey()));if(w!=null)return o.table=vo(f,w),O_(n,e,t,f,o,s)}const d=n.getElementByKey(c.__key),g=n.getElementByKey(a.key);if(g==null||d==null)return!1;let h;if(a.type==="element")h=g.getBoundingClientRect();else{const w=or(ha(n));if(w===null||w.rangeCount===0)return!1;const C=By(w,n.getRootElement());if(C===null)return!1;h=C.getBoundingClientRect()}const _=t==="up"?c.getFirstChild():c.getLastChild();if(_==null)return!1;const m=n.getElementByKey(_.__key);if(m==null)return!1;const b=m.getBoundingClientRect();if(t==="up"?b.top>h.top-h.height:h.bottom+h.height>b.bottom){yn(e);const w=r.getCordsFromCellNode(c,o.table);if(!e.shiftKey)return UC(o,r,w.x,w.y,t);{const C=r.getDOMCellFromCordsOrThrow(w.x,w.y,o.table);o.$setAnchorCellForSelection(C),o.$setFocusCellForSelection(C,!0)}return!0}}}else if(ae(i)){const{anchor:a,focus:l,tableKey:c}=i;if(c!==r.getKey())return!1;const u=re(a.getNode(),J),f=re(l.getNode(),J),[d]=i.getNodes();be(d)||G(251);const g=kt(d,n.getElementByKey(d.getKey()));if(!J(u)||!J(f)||!be(d)||g==null)return!1;o.$updateTableTableSelection(i);const h=vo(d,g),_=r.getCordsFromCellNode(u,h),m=r.getDOMCellFromCordsOrThrow(_.x,_.y,h);if(o.$setAnchorCellForSelection(m),yn(e),e.shiftKey){const[b,w,C]=ct(r,u,f);return zC(o,b,w,C,t)}return f.selectEnd(),!0}return!1}function yn(n){n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation()}function Cf(n,e,t){const r=ne();n==="first"?e.insertBefore(r):e.insertAfter(r),r.append(...t||[]),r.selectEnd()}function Sf(n,e,t){const r=t.getParent();if(!r)return;const o=or(ha(n));if(!o)return;const s=Pc(o,n.getRootElement()).anchorNode,i=n.getElementByKey(r.getKey()),a=kt(t,n.getElementByKey(t.getKey()));if(!s||!i||!a||!i.contains(s)||a.contains(s))return;const l=re(e.anchor.getNode(),w=>J(w));if(!l)return;const c=re(l,w=>be(w));if(!be(c)||!c.is(t))return;const[u,f]=ct(t,l,l),d=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:h,startColumn:_}=f,m=h===d.startRow&&_===d.startColumn,b=h===g.startRow&&_===g.startColumn;return m?"first":b?"last":void 0}function mr(n,e){const{tableNode:t}=n.$lookup(),r=t.getCordsFromCellNode(e,n.table);return t.getDOMCellFromCordsOrThrow(r.x,r.y,n.table)}function tc(n,e,t){return _a(n,Ae(e,t))}function Wi(n){return ke(n)&&n.nodeName==="DIV"}function vf(n,e,t){let r=n.querySelector(":scope > colgroup");if(!t)return void(r&&r.remove());r||(r=Je().createElement("colgroup"),Rl(r),n.insertBefore(r,n.firstChild));const o=[];for(let s=0;s<e;s++){const i=Je().createElement("col"),a=t[s];a&&(i.style.width=`${a}px`),o.push(i)}r.replaceChildren(...o)}function kf(n,e,t){if(!e.theme.tableAlignment)return;const r=[],o=[];for(const s of["center","right"]){const i=e.theme.tableAlignment[s];i&&(s===t?o:r).push(i)}$t(n,...r),Ie(n,...o)}const R_=new WeakSet;function WC(n){const{scrollable:e,scrollbar:t,tableElement:r}=n;if(t.classList.length===0&&(function(a){const l=a.style.display;a.style.display="";const c=a.offsetHeight-a.clientHeight;return a.style.display=l,c})(t)===0)return R_.add(t),t.style.display="none",e.style.scrollbarWidth="auto",()=>{};const o=()=>{t.scrollLeft!==e.scrollLeft&&(t.scrollLeft=e.scrollLeft)},s=()=>{e.scrollLeft!==t.scrollLeft&&(e.scrollLeft=t.scrollLeft)};e.addEventListener("scroll",o,{passive:!0}),t.addEventListener("scroll",s,{passive:!0});let i=null;return typeof ResizeObserver<"u"&&(i=new ResizeObserver(()=>{nc(e,t)}),i.observe(e),i.observe(r)),nc(e,t),()=>{e.removeEventListener("scroll",o),t.removeEventListener("scroll",s),i&&i.disconnect()}}function nc(n,e){if(R_.has(e))return;const t=e.firstElementChild;if(!t||!ke(t)||!n.isConnected)return;const r=n.ownerDocument.defaultView;if(!r)return void(e.style.display="none");const o=r.getComputedStyle(n).overflowX,s=o==="auto"||o==="scroll",i=n.scrollWidth,a=n.clientWidth,l=i+"px";t.style.width!==l&&(t.style.width=l);const c=s&&i>a;e.style.display=c?"":"none"}function HC(n){if(!n.hasAttribute("data-lexical-sticky-scrollbar"))return null;const e=n.firstElementChild;if(!Wi(e))return null;const t=e.querySelector(":scope > table");if(!Fn(t))return null;const r=e.nextElementSibling;return Wi(r)?{scrollable:e,scrollbar:r,tableElement:t}:null}const rc=new WeakSet;function Po(n=zo()){return rc.has(n)}function oc(n=zo()){const e=Tc(n,"@lexical/table/Table");return!!e&&e.output.hasStickyScrollbar.peek()&&e.output.hasHorizontalScroll.peek()}function fu(n,e){e?rc.add(n):rc.delete(n)}class Xt extends Oe{__rowStriping=!1;__frozenColumnCount=0;__frozenRowCount=0;__colWidths=void 0;$config(){return this.config("table",{extends:Oe,importDOM:{table:()=>({conversion:JC,priority:1})}})}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,r){return r==="html"}getDOMSlot(e){const t=Fn(e)?e:e.querySelector("table");return Fn(t)||G(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector(":scope > colgroup"))}createDOM(e,t){const r=Je().createElement("table");if(this.__style&&_o(r.style,this.__style),this.getColWidths()){const o=Je().createElement("colgroup");r.appendChild(o),Rl(o)}if(Ie(r,e.theme.table),this.updateTableElement(null,r,e),Po(t)){const o=oc(t),s=(function(i,a,l){const c=Je().createElement("div"),u=a.theme.tableScrollableWrapper;return u?Ie(c,u):c.style.overflowX="auto",l&&(c.style.scrollbarWidth="none"),c.appendChild(i),c})(r,e,o);if(this.updateTableWrapper(null,s,r,e),o){const i=(function(l){const c=Je(),u=c.createElement("div"),f=l.theme.tableStickyScrollbar;f?Ie(u,f):(u.style.position="sticky",u.style.bottom="0",u.style.overflowX="scroll",u.style.overflowY="hidden"),u.style.display="none",u.setAttribute("aria-hidden","true"),u.tabIndex=-1;const d=c.createElement("div");return d.style.height="1px",d.style.width="0px",u.appendChild(d),u})(e),a=Je().createElement("div");return a.setAttribute("data-lexical-sticky-scrollbar","true"),a.appendChild(s),a.appendChild(i),Rl(i),a}return s}return r}updateTableWrapper(e,t,r,o){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&(function(s,i,a,l){l>0?(Ie(s,a.theme.tableFrozenColumn),i.setAttribute("data-lexical-frozen-column","true")):($t(s,a.theme.tableFrozenColumn),i.removeAttribute("data-lexical-frozen-column"))})(t,r,o,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&(function(s,i,a,l){l>0?(Ie(s,a.theme.tableFrozenRow),i.setAttribute("data-lexical-frozen-row","true")):($t(s,a.theme.tableFrozenRow),i.removeAttribute("data-lexical-frozen-row"))})(t,r,o,this.__frozenRowCount)}updateTableElement(e,t,r){this.__style!==(e?e.__style:"")&&_o(t.style,this.__style,e?e.__style:""),this.__rowStriping!==(!!e&&e.__rowStriping)&&(function(i,a,l){l?(Ie(i,a.theme.tableRowStriping),i.setAttribute("data-lexical-row-striping","true")):($t(i,a.theme.tableRowStriping),i.removeAttribute("data-lexical-row-striping"))})(t,r,this.__rowStriping);const o=e?e.getColumnCount():0,s=e?e.__colWidths:void 0;this.getColumnCount()===o&&this.getColWidths()===s||vf(t,this.getColumnCount(),this.getColWidths()),kf(t,r,this.getFormatType())}updateDOM(e,t,r){const o=kt(this,t);if(t===o===Po())return!0;if(Wi(t)){if(t.hasAttribute("data-lexical-sticky-scrollbar")!==oc())return!0;const s=o.parentElement;Wi(s)&&this.updateTableWrapper(e,s,o,r)}return this.updateTableElement(e,o,r),!1}scaleDOMColWidths(e,t){const r=this.getColWidths();r&&vf(kt(this,e),this.getColumnCount(),r.map(o=>o*t))}exportDOM(e){const t=super.exportDOM(e),{element:r}=t;return{after:o=>{if(t.after&&(o=t.after(o)),!Fn(o)&&ke(o)&&(o=o.querySelector("table")),!Fn(o))return null;kf(o,e._config,this.getFormatType());const[s]=at(this,null,null),i=new Map;for(const u of s)for(const f of u){const d=f.cell.getKey();i.has(d)||i.set(d,{colSpan:f.cell.getColSpan(),startColumn:f.startColumn})}const a=new Set;for(const u of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const f=u.getAttribute("data-temporary-table-cell-lexical-key");if(f){const d=i.get(f);if(u.removeAttribute("data-temporary-table-cell-lexical-key"),d){i.delete(f);for(let g=0;g<d.colSpan;g++)a.add(g+d.startColumn)}}}const l=o.querySelector(":scope > colgroup");if(l){const u=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter((f,d)=>a.has(d));l.replaceChildren(...u)}const c=o.querySelectorAll(":scope > tr");if(c.length>0){const u=Je().createElement("tbody");for(const f of c)u.appendChild(f);o.append(u)}return o},element:!Fn(r)&&ke(r)?r.querySelector("table"):r}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:r,domRows:o}=t;for(let s=0;s<r;s++){const i=o[s];if(i!=null)for(let a=0;a<i.length;a++){const l=i[a];if(l==null)continue;const{elem:c}=l,u=tc(this,c);if(u!==null&&e.is(u))return{x:a,y:s}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,r){const{domRows:o}=r,s=o[t];if(s==null)return null;const i=s[e<s.length?e:s.length-1];return i??null}getDOMCellFromCordsOrThrow(e,t,r){const o=this.getDOMCellFromCords(e,t,r);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,r){const o=this.getDOMCellFromCords(e,t,r);if(o==null)return null;const s=Ae(o.elem);return J(s)?s:null}getCellNodeFromCordsOrThrow(e,t,r){const o=this.getCellNodeFromCords(e,t,r);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!ce(e))return 0;let t=0;return e.getChildren().forEach(r=>{J(r)&&(t+=r.getColSpan())}),t}}function A_(n,e){const t=n.getElementByKey(e.getKey());return t===null&&G(230),vo(e,t)}function JC(n){const e=Ho();n.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(!0),n.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),n.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);const t=n.querySelector(":scope > colgroup");if(t){let r=[];for(const o of t.querySelectorAll(":scope > col")){let s=o.style.width||"";if(!Co.test(s)&&(s=o.getAttribute("width")||"",!/^\d+$/.test(s))){r=void 0;break}r.push(parseFloat(s))}r&&e.setColWidths(r)}return{after:r=>Mi(r,ce),node:e}}function Ho(){return Ot(new Xt)}function be(n){return n instanceof Xt}function qC(n){ce(n.getParent())?n.isEmpty()&&n.append(ne()):n.remove()}function VC(n){be(n.getParent())?ih(n,J):n.remove()}function YC(n){ih(n,ce);const[e]=at(n,null,null),t=e.reduce((i,a)=>Math.max(i,a.length),0),r=n.getChildren();for(let i=0;i<e.length;++i){const a=r[i];if(!a)continue;ce(a)||G(254,a.constructor.name,a.getType());const l=e[i].reduce((c,u)=>u?1+c:c,0);if(l!==t)for(let c=l;c<t;++c){const u=lt();u.append(ne()),a.append(u)}}const o=n.getColWidths(),s=n.getColumnCount();if(o&&o.length!==s){let i;if(s<o.length)i=o.slice(0,s);else if(o.length>0){const a=o[o.length-1];i=[...o,...Array(s-o.length).fill(a)]}n.setColWidths(i)}}function GC(n){if(n.detail<3||!No(n.target))return!1;const e=Ae(n.target);if(e===null)return!1;const t=re(e,r=>q(r)&&!r.isInline());return t===null?!1:!!J(t.getParent())&&(t.select(0),!0)}function XC(){const n=D();if(!F(n))return!1;const e=Or(n.anchor.getNode());if(e===null)return!1;const t=se();if(!t.is(e.getParent())||t.getChildrenSize()!==1)return!1;const[r]=at(e,null,null);if(r.length===0||r[0].length===0)return!1;const o=r[0][0];if(!o||!o.cell)return!1;const s=r[r.length-1],i=s[s.length-1];if(!i||!i.cell)return!1;const a=Ki(e,o.cell,i.cell);return Ee(a),!0}function gu(n){return n.registerNodeTransform(Gt,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=We(e),[r]=ct(t,e,e),o=r.length,s=r[0].length;let i=t.getFirstChild();ce(i)||G(175);const a=[];for(let l=0;l<o;l++){l!==0&&(i=i.getNextSibling(),ce(i)||G(175));let c=null;for(let u=0;u<s;u++){const f=r[l][u],d=f.cell;if(f.startRow===l&&f.startColumn===u)c=d,a.push(d);else if(d.getColSpan()>1||d.getRowSpan()>1){J(d)||G(176);const g=lt(d.__headerState);c!==null?c.insertAfter(g):Dy(i,g)}}}for(const l of a)l.setColSpan(1),l.setRowSpan(1)}})}function pu(n,e=!0){const t=new MC,r=(o,s,i)=>{const a=kt(o,i),l=E_(o,a,n,e,t);t.observers.set(s,[l,a])};return de(jC(n,t),n.registerCommand(Ht,()=>FC(t,n),qe),n.registerMutationListener(Xt,o=>{n.read("latest",()=>{for(const[s,i]of o){const a=t.observers.get(s);if(i==="created"||i==="updated"){const{tableNode:l,tableElement:c}=du(s);a===void 0?r(l,s,c):c!==a[1]&&(t.removeObserver(s),r(l,s,c))}else i==="destroyed"&&t.removeObserver(s)}})},{skipInitialization:!1}),()=>{t.removeAllObservers()})}function hu(n,e){n.hasNodes([Xt])||G(255);const{hasNestedTables:t=Ac(!1)}=e??{};return de(n.registerCommand(nu,r=>(function({rows:o,columns:s,includeHeaders:i},a){const l=D()||mo();if(!l||!F(l)||!a&&Or(l.anchor.getNode()))return!1;const c=x_(Number(o),Number(s),i);sr(c);const u=c.getFirstDescendant();return oe(u)&&u.select(),!0})(r,t.peek()),V),n.registerCommand(Py,(r,o)=>n===o&&(function(s,i){const{nodes:a,selection:l}=s;if(!a.some(f=>be(f)||jy(f).some(d=>be(d.node)))){if(ae(l)){let f="",d=!1;for(const g of a){const h=q(g)&&!g.isInline();f.length>0&&(h||d)&&(f+=`
13
- `),f+=g.getTextContent(),d=h}return l.insertRawText(f),!0}return!1}const c=ae(l),u=F(l);return u&&re(l.anchor.getNode(),f=>J(f))!==null&&re(l.focus.getNode(),f=>J(f))!==null||c?a.length===1&&be(a[0])?k_(a[0],l):!(u&&i.peek()&&!(function(f){return!!(ae(f)&&!f.focus.getNode().is(f.anchor.getNode())||F(f)&&J(f.anchor.getNode())&&!f.anchor.getNode().is(f.focus.getNode()))})(l)):!1})(r,t),V),n.registerCommand(Ec,XC,ee),n.registerCommand(Ks,GC,V),n.registerNodeTransform(Xt,YC),n.registerNodeTransform(Wo,VC),n.registerNodeTransform(Gt,qC))}const ZC={$accepts:ce,$packageRun:n=>n.every(J)?[pn().splice(0,0,n)]:[],name:"TableSchema"},QC={$accepts:J,name:"TableRowSchema"},M_=[Ye({$import:(n,e)=>{const t=Ho();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const r=e.querySelector(":scope > colgroup");if(r){let o=[];for(const s of r.querySelectorAll(":scope > col")){let i=s.style.width||"";if(!Co.test(i)&&(i=s.getAttribute("width")||"",!/^\d+$/.test(i))){o=void 0;break}o.push(parseFloat(i))}o&&t.setColWidths(o)}return[t.splice(0,0,Mi(n.$importChildren(e),ce))]},match:Ge.tag("table"),name:"@lexical/table/table"}),Ye({$import:(n,e)=>[pn(Co.test(e.style.height)?parseFloat(e.style.height):void 0).splice(0,0,Mi(n.$importChildren(e),J))],match:Ge.tag("tr"),name:"@lexical/table/tr"}),Ye({$import:(n,e)=>{const t=e.nodeName==="TH",r=Co.test(e.style.width)?parseFloat(e.style.width):void 0;let o=te.NO_STATUS;if(t){const m=e.getAttribute("scope");if(m==="col")o=te.COLUMN;else if(m==="row")o=te.ROW;else{const b=e.parentElement,w=Hy(b)&&(b.parentElement&&b.parentElement.nodeName==="THEAD"||b.rowIndex===0),C=e.cellIndex===0;w&&(o|=te.ROW),C&&(o|=te.COLUMN),o===te.NO_STATUS&&(o=te.ROW)}}const s=lt(o,e.colSpan,r);s.__rowSpan=e.rowSpan;const i=e.style.backgroundColor;i!==""&&(s.__backgroundColor=i);const a=e.style.verticalAlign;(function(m){return m==="middle"||m==="bottom"})(a)&&(s.__verticalAlign=a);const l=n.get(Ld),c=l|(function(m){let b=0;const w=m.fontWeight;w!=="700"&&w!=="bold"||(b|=Yy),m.fontStyle==="italic"&&(b|=Jy);const C=(m.textDecoration||"").split(" ");return C.includes("underline")&&(b|=qy),C.includes("line-through")&&(b|=Vy),b})(e.style),u=n.get(Od),f=e.style.color,d=f?{...u,color:f}:u,g=[];c!==l&&g.push(Rd(Ld,c)),d!==u&&g.push(Rd(Od,d));const h=(function(m){const b=[];let w=null;const C=()=>{if(w!==null){const v=w.getFirstChild();ue(v)&&w.getChildrenSize()===1&&v.remove()}};for(const v of m)sh(v)||oe(v)||ue(v)?w!==null?w.append(v):(w=ne().append(v),b.push(w)):(C(),w=null,b.push(v));return C(),b.length===0&&b.push(ne()),b})(n.$importChildren(e,{context:g})),_=t?h:th(h,e);return[s.splice(0,0,_)]},match:Ge.tag("td","th"),name:"@lexical/table/cell"})],ma=pe({build:(n,e,t)=>nr(e),config:tr({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasStickyScrollbar:!1,hasTabHandler:!0}),dependencies:[js,ln(Fs,{rules:M_})],name:"@lexical/table/Table",nodes:()=>[Xt,Wo,Gt],register(n,e,t){const r=t.getOutput();let o=!1;return de(zt(()=>{const s=r.hasHorizontalScroll.value,i=r.hasStickyScrollbar.value&&s,a=Po(n);a!==s&&fu(n,s),a===s&&o===i||n.update(ah),o=i}),hu(n,r),zt(()=>pu(n,r.hasTabHandler.value)),zt(()=>{if(r.hasStickyScrollbar.value&&r.hasHorizontalScroll.value)return n.registerRootListener(s=>{if(s)return(function(i){const a=new Map;return de(()=>{for(const{cleanup:l}of a.values())l();a.clear()},i.registerMutationListener(Xt,l=>{for(const[c,u]of l){const f=a.get(c);if(u==="destroyed"){f&&(f.cleanup(),a.delete(c));continue}const d=i.getElementByKey(c),g=d&&ke(d)?HC(d):null;f&&g&&f.parts.scrollable===g.scrollable&&f.parts.scrollbar===g.scrollbar&&f.parts.tableElement===g.tableElement?nc(g.scrollable,g.scrollbar):(f&&(f.cleanup(),a.delete(c)),g&&a.set(c,{cleanup:WC(g),parts:g}))}},{skipInitialization:!1}))})(n)})}),zt(()=>r.hasCellMerge.value?void 0:gu(n)),zt(()=>r.hasCellBackgroundColor.value?void 0:n.registerNodeTransform(Gt,s=>{s.getBackgroundColor()!==null&&s.setBackgroundColor(null)})))}}),eS=pe({dependencies:[ma],name:"@lexical/table/Import"}),Tf=Object.freeze(Object.defineProperty({__proto__:null,$computeTableCellRectBoundary:Ns,$computeTableMap:ct,$computeTableMapSkipCellCheck:at,$createTableCellNode:lt,$createTableNode:Ho,$createTableNodeWithDimensions:x_,$createTableRowNode:pn,$createTableSelection:RC,$createTableSelectionFrom:Ki,$deleteTableColumn:vC,$deleteTableColumnAtSelection:iu,$deleteTableColumn__EXPERIMENTAL:TC,$deleteTableRowAtSelection:su,$deleteTableRow__EXPERIMENTAL:kC,$findCellNode:ho,$findTableNode:Or,$getElementForTableNode:A_,$getNodeTriplet:We,$getTableAndElementByKey:du,$getTableCellNodeFromLexicalNode:Xl,$getTableCellNodeRect:Ql,$getTableColumnIndexFromTableCellNode:C_,$getTableNodeFromLexicalNodeOrThrow:ot,$getTableRowIndexFromTableCellNode:ou,$getTableRowNodeFromTableCellNodeOrThrow:ru,$insertTableColumn:CC,$insertTableColumnAtNode:zi,$insertTableColumnAtSelection:pa,$insertTableColumn__EXPERIMENTAL:SC,$insertTableRow:wC,$insertTableRowAtNode:Ui,$insertTableRowAtSelection:ga,$insertTableRow__EXPERIMENTAL:xC,$isScrollableTablesActive:Po,$isSimpleTable:uu,$isStickyScrollbarActive:oc,$isTableCellNode:J,$isTableNode:be,$isTableRowNode:ce,$isTableSelection:ae,$mergeCells:lu,$moveTableColumn:EC,$moveTableRow:NC,$removeTableRowAtIndex:yC,$setTableColumnIsHeader:OC,$setTableRowIsHeader:LC,$unmergeCell:v_,$unmergeCellNode:cu,INSERT_TABLE_COMMAND:nu,TableCellHeaderStates:te,TableCellNode:Gt,TableExtension:ma,TableImportExtension:eS,TableImportRules:M_,TableNode:Xt,TableObserver:T_,TableRowNode:Wo,TableRowSchema:QC,TableSchema:ZC,applyTableHandlers:E_,getDOMCellFromTarget:Do,getTableElement:kt,getTableObserverFromTableElement:$o,registerTableCellUnmergeTransform:gu,registerTablePlugin:hu,registerTableSelectionObserver:pu,setScrollableTablesActive:fu},Symbol.toStringTag,{value:"Module"}));function If(n,e){return n.read("latest",()=>{const t=Q(e);return t!==null&&t.isSelected()})}function _u(n){const[e]=fe(),[t,r]=S.useState(()=>If(e,n));return S.useEffect(()=>{let o=!0;const s=e.registerUpdateListener(()=>{o&&r(If(e,n))});return()=>{o=!1,s()}},[e,n]),[t,S.useCallback(o=>{e.update(()=>{let s=D();ve(s)||(s=aa(),Ee(s)),ve(s)&&(o?s.add(n):s.delete(n))})},[e,n]),S.useCallback(()=>{e.update(()=>{const o=D();ve(o)&&o.clear()})},[e])]}function tS({nodeKey:n}){const[e]=fe(),[t,r,o]=_u(n);return S.useEffect(()=>de(e.registerCommand(Ks,s=>{const i=e.getElementByKey(n);return Oo(s)===i&&(s.shiftKey||o(),r(!t),!0)},ee)),[o,e,t,n,r]),S.useEffect(()=>{const s=e.getElementByKey(n),i=e._config.theme.hrSelected??"selected";s!==null&&(t?Ie(s,i):$t(s,i))},[e,t,n]),null}class mu extends Gy{$config(){return this.config("horizontalrule",{importDOM:{hr:()=>({conversion:nS,priority:0})}})}decorate(){return x.jsx(tS,{nodeKey:this.__key})}}function nS(){return{node:ba()}}function ba(){return Ot(new mu)}function rS({equation:n,inline:e,nodeKey:t}){const[r]=fe(),[o,s]=S.useState(n),[i,a]=S.useState(!1),l=S.useRef(null),c=S.useCallback(u=>{a(!1),r.update(()=>{const f=Q(t);Rr(f)&&(f.setEquation(o),u&&f.selectNext(0,0))})},[r,o,t]);return S.useEffect(()=>{!i&&o!==n&&s(n)},[i,n,o]),S.useEffect(()=>i?de(r.registerCommand(Ht,u=>{const f=document.activeElement;return l.current!==f&&c(),!1},qe),r.registerCommand(Nn,u=>{const f=document.activeElement;return l.current===f?(c(!0),!0):!1},qe)):r.registerUpdateListener(({editorState:u})=>{u.read(()=>{const d=D();return ve(d)&&d.has(t)&&d.getNodes().length===1})&&a(!0)}),[r,t,c,i]),x.jsx(x.Fragment,{children:i?x.jsx(Kx,{equation:o,setEquation:s,inline:e,inputRef:l}):x.jsx(Fh,{equation:o,inline:e,onClick:()=>{a(!0)}})})}class ir extends Bt{__equation;__inline;static getType(){return"equation"}static clone(e){return new ir(e.__equation,e.__inline,e.__key)}constructor(e,t,r){super(r),this.__equation=e,this.__inline=t??!1}static importJSON(e){return ya(e.equation,e.inline)}exportJSON(){return{equation:this.getEquation(),inline:this.__inline,type:"equation",version:1}}createDOM(e){return document.createElement(this.__inline?"span":"div")}updateDOM(e){return this.__inline!==e.__inline}getEquation(){return this.__equation}setEquation(e){const t=this.getWritable();t.__equation=e}decorate(){return x.jsx(rS,{equation:this.__equation,inline:this.__inline,nodeKey:this.__key})}}function ya(n="",e=!1){return new ir(n,e)}function Rr(n){return n instanceof ir}function oS({defaultSelection:n}){const[e]=fe();return S.useEffect(()=>{e.focus(()=>{const t=e.getRootElement(),r=t!==null?la(t):null;t===null||r!==null&&t.contains(r)||t.focus({preventScroll:!0})},{defaultSelection:n})},[n,e]),null}class wa extends cn{$config(){return this.config("hashtag",{extends:cn})}createDOM(e){const t=super.createDOM(e);return Ie(t,e.theme.hashtag),t}canInsertTextBefore(){return!1}isTextEntity(){return!0}}function sS(n=""){return Ot(new wa(n))}const iS=new RegExp((function(){const{alpha:n,alphanumeric:e,hashChars:t}=(function(){const o=String.fromCharCode,s="A-Za-zªµºÀ-ÖØ-öø-Ɂɐ-ˁˆ-ˑˠ-ˤˮͺΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϵϷ-ҁҊ-ӎӐ-ӹԀ-ԏԱ-Ֆՙա-ևא-תװ-ײء-غـ-يٮ-ٯٱ-ۓەۥ-ۦۮ-ۯۺ-ۼۿܐܒ-ܯݍ-ݭހ-ޥޱऄ-हऽॐक़-ॡॽঅ-ঌএ-ঐও-নপ-রলশ-হঽৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽૐૠ-ૡଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽଡ଼-ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡඅ-ඖක-නඳ-රලව-ෆก-ะา-ำเ-ๆກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ະາ-ຳຽເ-ໄໆໜ-ໝༀཀ-ཇཉ-ཪྈ-ྋက-အဣ-ဧဩ-ဪၐ-ၕႠ-Ⴥა-ჺჼᄀ-ᅙᅟ-ᆢᆨ-ᇹሀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙶᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦩᧁ-ᧇᨀ-ᨖᴀ-ᶿḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₔℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℱℳ-ℹℼ-ℿⅅ-ⅉⰀ-Ⱞⰰ-ⱞⲀ-ⳤⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄬㄱ-ㆎㆠ-ㆷㇰ-ㇿ㐀-䶵一-龻ꀀ-ꒌꠀ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢ가-힣豈-鶴侮-頻並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵÀ-ÖØ-öø-ÿĀ-ɏɓ-ɔɖ-ɗəɛɣɨɯɲʉʋʻ̀-ͯḀ-ỿЀ-ӿԀ-ԧⷠ-ⷿꙀ-֑ꚟ-ֿׁ-ׂׄ-ׇׅא-תװ-״﬒-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﭏؐ-ؚؠ-ٟٮ-ۓە-ۜ۞-۪ۨ-ۯۺ-ۼۿݐ-ݿࢠࢢ-ࢬࣤ-ࣾﭐ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼ‌-‌ก-ฺเ-๎ᄀ-ᇿ㄰-ㆅꥠ-꥿가-힯ힰ-퟿ᄀ-ᅵァ-ヺー-ヾヲ-゚0-9A-Za-zぁ-ゖ゙-ゞ㐀-䶿一-鿿"+o(173824)+"-"+o(177983)+o(177984)+"-"+o(178207)+o(194560)+"-"+o(195103)+"〃々〻";return{alpha:s,alphanumeric:s+"̀-ͯ҃-֑҆-ֹֻ-ֽֿׁ-ׂׄ-ׇׅؐ-ًؕ-ٰٞۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ްँ-ः़ा-्॑-॔ॢ-ॣঁ-ঃ়া-ৄে-ৈো-্ৗৢ-ৣਁ-ਃ਼ਾ-ੂੇ-ੈੋ-੍ੰ-ੱઁ-ઃ઼ા-ૅે-ૉો-્ૢ-ૣଁ-ଃ଼ା-ୃେ-ୈୋ-୍ୖ-ୗஂா-ூெ-ைொ-்ௗఁ-ఃా-ౄె-ైొ-్ౕ-ౖಂ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕ-ೖം-ഃാ-ൃെ-ൈൊ-്ൗං-ඃ්ා-ුූෘ-ෟෲ-ෳัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-༹༙༵༷༾-༿ཱ-྄྆-྇ྐ-ྗྙ-ྼ࿆ာ-ဲံ-္ၖ-ၙ፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳា-៓៝᠋-᠍ᢩᤠ-ᤫᤰ-᤻ᦰ-ᧀᧈ-ᧉᨗ-ᨛ᷀-᷃⃐-⃥⃜⃡-⃫〪-゙〯-゚ꠂ꠆ꠋꠣ-ꠧﬞ︀-️︠-︣0-9٠-٩۰-۹०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉០-៩᠐-᠙᥆-᥏᧐-᧙0-9_",hashChars:"#\\uFF03"}})(),r="["+e+"]";return"("+("^|$|[^&/"+e+"]")+")("+("["+t+"]")+")("+r+"*"+("["+n+"]")+r+"*)"})(),"i"),$_={getHashtagMatch:function(n){const e=iS.exec(n);if(e===null)return null;const t=e[3].length+1,r=e.index+e[1].length;return{end:r+t,start:r}}};function D_(n,e=$_){return de(...Xy(n,e.getHashtagMatch,wa,t=>sS(t.getTextContent())))}const aS=pe({config:$_,name:"@lexical/hashtag/Hashtag",nodes:()=>[wa],register:D_});function lS(){const[n]=fe();return S.useEffect(()=>{if(!n.hasNodes([wa]))throw new Error("HashtagPlugin: HashtagNode not registered on editor");return D_(n)},[n]),null}function cS({delay:n,externalHistoryState:e}){const[t]=fe();return(function(r,o,s=1e3){const i=S.useMemo(()=>o||Zy(),[o]);S.useEffect(()=>Qy(r,i,s),[s,r,i])})(t,e,n),null}function uS({validateUrl:n,attributes:e}){const[t]=fe();return S.useEffect(()=>{if(!t.hasNodes([gn]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),S.useEffect(()=>h_(t,nr({attributes:e,validateUrl:n})),[t,n,e]),null}const Ef=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],Nf=Ef[Math.floor(Math.random()*Ef.length)],dS=S.createContext(null);function fS(){return{color:Nf[1],isCollabActive:!1,name:Nf[0],yjsDocMap:new Map}}fS();function gS({initialEditor:n,children:e,initialNodes:t,initialTheme:r,skipCollabChecks:o,skipEditableListener:s}){const i=S.useRef(!1),a=S.useContext(Ad);a==null&&(function(_,...m){const b=new URL("https://lexical.dev/docs/error"),w=new URLSearchParams;w.append("code",_);for(const C of m)w.append("v",C);throw b.search=w.toString(),Error(`Minified Lexical error #${_}; visit ${b.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(9);const[l,{getTheme:c}]=a,u=S.useMemo(()=>{const _=r||c()||void 0,m=ew(a,_);_!==void 0&&(n._config.theme=_),n._parentEditor=n._parentEditor||l;const b=n._createEditorArgs,w=b&&b.namespace;if(t){w||(n._config.namespace=l._config.namespace);for(let C of t){let v=null,k=null;if(typeof C!="function"){const E=C;C=E.replace,v=E.with,k=E.withKlass||null}const I=tw(n,C.getType());n._nodes.set(C.getType(),{exportDOM:I?I.exportDOM:void 0,klass:C,replace:v,replaceWithKlass:k,sharedNodeState:$d(C),transforms:Md(C)})}}else if(b&&b.nodes)w||(n._config.namespace=l._config.namespace);else{const C=n._nodes=new Map(l._nodes);w||(n._config.namespace=l._config.namespace);for(const[v,k]of C)n._nodes.set(v,{exportDOM:k.exportDOM,klass:k.klass,replace:k.replace,replaceWithKlass:k.replaceWithKlass,sharedNodeState:$d(k.klass),transforms:Md(k.klass)})}return[n,m]},[]),f=S.useContext(dS),{isCollabActive:d,yjsDocMap:g}=f??{},h=o||i.current||g&&g.has(n.getKey());return S.useEffect(()=>{h&&(i.current=!0)},[h]),S.useEffect(()=>{if(!s){const _=m=>n.setEditable(m);return _(l.isEditable()),l.registerEditableListener(_)}},[n,l,s]),x.jsx(Ad.Provider,{value:u,children:!d||h?e:null})}const pS=qn?S.useLayoutEffect:S.useEffect;function hS(n){return{initialValueFn:()=>n.isEditable(),subscribe:e=>n.registerEditableListener(e)}}function Hr(){return(function(n){const[e]=fe(),t=S.useMemo(()=>n(e),[e,n]),[r,o]=S.useState(()=>t.initialValueFn()),s=S.useRef(r);return pS(()=>{const{initialValueFn:i,subscribe:a}=t,l=i();return s.current!==l&&(s.current=l,o(l)),a(c=>{s.current=c,o(c)})},[t,n]),r})(hS)}function _S(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const bu=qn?S.useLayoutEffect:S.useEffect;function mS({editor:n,ErrorBoundary:e}){return(function(t,r){const[o,s]=S.useState(()=>t.getDecorators());return bu(()=>t.registerDecoratorListener(i=>{St.flushSync(()=>{s(i)})}),[t]),S.useEffect(()=>{s(t.getDecorators())},[t]),S.useMemo(()=>{const i=[],a=Object.keys(o);for(let l=0;l<a.length;l++){const c=a[l],u=x.jsx(r,{onError:d=>t._onError(d),children:x.jsx(S.Suspense,{fallback:null,children:o[c]})}),f=t.getElementByKey(c);f!==null&&i.push(St.createPortal(u,f,c))}return i},[r,o,t])})(n,e)}function bS({editor:n,ErrorBoundary:e}){return(function(t){const r=rw.maybeFromEditor(t);if(r&&r.hasExtensionByName(ow.name)){for(const o of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(o)&&_S(320,o);return!0}return!1})(n)?null:x.jsx(mS,{editor:n,ErrorBoundary:e})}function Lf(n){return n.read("latest",sw(n.isComposing()))}function yS({contentEditable:n,placeholder:e=null,ErrorBoundary:t}){const[r]=fe();return(function(o){bu(()=>de(i_(o),nw(o)),[o])})(r),x.jsxs(x.Fragment,{children:[n,x.jsx(wS,{content:e}),x.jsx(bS,{editor:r,ErrorBoundary:t})]})}function wS({content:n}){const[e]=fe(),t=(function(o){const[s,i]=S.useState(()=>Lf(o));return bu(()=>{function a(){const l=Lf(o);i(l)}return a(),de(o.registerUpdateListener(()=>{a()}),o.registerEditableListener(()=>{a()}))},[o]),s})(e),r=Hr();return t?typeof n=="function"?n(r):n:null}function P_({hasCellMerge:n=!0,hasCellBackgroundColor:e=!0,hasTabHandler:t=!0,hasHorizontalScroll:r=!1,hasNestedTables:o=!1}){const[s]=fe();S.useEffect(()=>{Po(s)!==r&&(fu(s,r),s.update(ah))},[s,r]);const i=(function(a){const[l]=S.useState(()=>Ac(a));return l.peek()!==a&&(l.value=a),l})(o);return S.useEffect(()=>hu(s,{hasNestedTables:i}),[s,i]),S.useEffect(()=>pu(s,t),[s,t]),S.useEffect(()=>{if(!n)return gu(s)},[s,n]),S.useEffect(()=>{if(!e)return s.registerNodeTransform(Gt,a=>{a.getBackgroundColor()!==null&&a.setBackgroundColor(null)})},[s,e,n]),null}const xS="Gc7131jiJuvI7IdN0HZ1D7nh0ow5BU6g",CS=`https://api.giphy.com/v1/gifs/trending?api_key=${xS}&limit=50&rating=g`;async function yu(){try{const t=(await(await fetch(CS)).json())?.data;if(!Array.isArray(t)||t.length===0)return null;const r=t[Math.floor(Math.random()*t.length)],o=r.images?.downsized_medium?.url||r.images?.original?.url||r.images?.fixed_height?.url;return o?{altText:r.title||"Random GIF",src:o}:null}catch{return null}}const j_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ys=he("INSERT_IMAGE_COMMAND"),SS=n=>j_?(n||window).getSelection():null;function F_(n){if(!n.hasNodes([Jr]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return de(n.registerCommand(Ys,e=>{const t=xa(e);return Tr([t]),wt(t.getParentOrThrow())&&Fc(t,ne).selectEnd(),!0},V),n.registerCommand(Wp,e=>TS(e),qe),n.registerCommand(Nc,e=>IS(e),ee),n.registerCommand(Lc,e=>ES(e,n),qe))}const B_=pe({name:"@datalayer/jupyter-lexical/Images",nodes:()=>[Jr],register:F_}),vS="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";let di=null;function kS(){return di===null&&(di=document.createElement("img"),di.src=vS),di}function TS(n){const e=wu();if(!e)return!1;const t=n.dataTransfer;return t?(t.setData("text/plain","_"),t.setDragImage(kS(),0,0),t.setData("application/x-lexical-drag",JSON.stringify({data:{altText:e.__altText,caption:e.__caption,height:e.__height,key:e.getKey(),maxWidth:e.__maxWidth,showCaption:e.__showCaption,src:e.__src,width:e.__width},type:"image"})),!0):!1}function IS(n){return wu()?(U_(n)||n.preventDefault(),!0):!1}function ES(n,e){const t=wu();if(!t)return!1;const r=NS(n);if(!r)return!1;if(n.preventDefault(),U_(n)){const o=LS(n);t.remove();const s=kr();o!=null&&s.applyDOMRange(o),Ee(s),e.dispatchCommand(Ys,r)}return!0}function wu(){const n=D();if(!ve(n))return null;const t=n.getNodes()[0];return Hn(t)?t:null}function NS(n){const e=n.dataTransfer?.getData("application/x-lexical-drag");if(!e)return null;const{type:t,data:r}=JSON.parse(e);return t!=="image"?null:r}function U_(n){const e=n.target;return!!(e&&e instanceof HTMLElement&&!e.closest("code, span.editor-image")&&e.parentElement&&e.parentElement.closest("div.ContentEditable__root"))}function LS(n){let e;const t=n.target,r=t==null?null:t.nodeType===9?t.defaultView:t.ownerDocument.defaultView,o=SS(r);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(n.clientX,n.clientY);else if(n.rangeParent&&o!==null)o.collapse(n.rangeParent,n.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}function OS({children:n}){return x.jsx(Y,{sx:{display:"flex",flexDirection:"column",gap:2,mt:3},children:n})}function xu({"data-test-id":n,children:e}){return x.jsx(Y,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:2,mt:3},"data-test-id":n,children:e})}function RS({onClick:n}){const[e,t]=S.useState(""),[r,o]=S.useState(""),s=e==="";return x.jsxs(x.Fragment,{children:[x.jsx(Kl,{label:"Image URL",placeholder:"i.e. https://source.unsplash.com/random",onChange:t,value:e,"data-test-id":"image-modal-url-input"}),x.jsx(Kl,{label:"Alt Text",placeholder:"Random unsplash image",onChange:o,value:r,"data-test-id":"image-modal-alt-text-input"}),x.jsx(xu,{children:x.jsx(xr,{"data-test-id":"image-modal-confirm-btn",disabled:s,onClick:()=>n({altText:r,src:e}),children:"Confirm"})})]})}function AS({onClick:n}){const[e,t]=S.useState(""),[r,o]=S.useState(""),s=e==="",i=a=>{const l=new FileReader;l.onload=function(){return typeof l.result=="string"&&t(l.result),""},a!==null&&l.readAsDataURL(a[0])};return x.jsxs(x.Fragment,{children:[x.jsx(Jx,{label:"Image Upload",onChange:i,accept:"image/*","data-test-id":"image-modal-file-upload"}),x.jsx(Kl,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:o,value:r,"data-test-id":"image-modal-alt-text-input"}),x.jsx(xu,{children:x.jsx(xr,{"data-test-id":"image-modal-file-upload-btn",disabled:s,onClick:()=>n({altText:r,src:e}),children:"Confirm"})})]})}function z_({activeEditor:n,onClose:e}){const[t,r]=S.useState(null),o=S.useRef(!1);S.useEffect(()=>{o.current=!1;const i=a=>{o.current=a.altKey};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[n]);const s=i=>{n.dispatchCommand(Ys,i),e()};return x.jsxs(x.Fragment,{children:[!t&&x.jsxs(OS,{children:[x.jsx(xr,{"data-test-id":"image-modal-option-sample",onClick:()=>{yu().then(i=>{i&&s(i)})},children:"Sample"}),x.jsx(xr,{"data-test-id":"image-modal-option-url",onClick:()=>r("url"),children:"URL"}),x.jsx(xr,{"data-test-id":"image-modal-option-file",onClick:()=>r("file"),children:"File"})]}),t==="url"&&x.jsx(RS,{onClick:s}),t==="file"&&x.jsx(AS,{onClick:s})]})}const MS=({captionsEnabled:n})=>{const[e]=fe();return S.useEffect(()=>F_(e),[e]),null},Of=new Set;function $S(n){if(!Of.has(n))throw new Promise(e=>{const t=new Image;t.src=n,t.onload=()=>{Of.add(n),e(null)}})}function DS(n){if(n instanceof HTMLImageElement){const{alt:e,src:t}=n;return{node:xa({altText:e,src:t})}}return null}function PS({altText:n,className:e,imageRef:t,src:r,width:o,height:s,maxWidth:i}){return $S(r),x.jsx("img",{className:e||void 0,src:r,alt:n,ref:t,style:{height:s,maxWidth:i,width:o},draggable:"false"})}function jS({src:n,altText:e,nodeKey:t,width:r,height:o,maxWidth:s,resizable:i,showCaption:a,caption:l}){const c=S.useRef(null),u=S.useRef(null),[f,d,g]=_u(t),[h,_]=S.useState(!1),[m]=fe(),[b]=S.useState(null),w=S.useRef(null),C=S.useCallback(R=>{if(f&&ve(D())){R.preventDefault();const L=Q(t);Hn(L)&&L.remove(),d(!1)}return!1},[f,t,d]),v=S.useCallback(R=>{const $=D(),L=u.current;if(f&&ve($)&&$.getNodes().length===1){if(a)return Ee(null),R.preventDefault(),l.focus(),!0;if(L!==null&&L!==document.activeElement)return R.preventDefault(),L.focus(),!0}return!1},[l,f,a]),k=S.useCallback(R=>w.current===l||u.current===R.target?(Ee(null),m.update(()=>{const $=aa();$.add(t);const L=m.getRootElement();L!==null&&L.focus(),Ee($)}),!0):!1,[l,m,t]);S.useEffect(()=>de(m.registerUpdateListener(({editorState:R})=>{}),m.registerCommand(Ht,(R,$)=>(w.current=$,!1),ee),m.registerCommand(Ks,R=>{const $=R;return h?!0:$.target===c.current?($.shiftKey||g(),d(!f),!0):!1},ee),m.registerCommand(Oc,C,ee),m.registerCommand(sa,C,ee),m.registerCommand(zr,v,ee),m.registerCommand(Nn,k,ee)),[g,m,h,f,t,C,v,k,d]);const I=()=>{m.update(()=>{const R=Q(t);Hn(R)&&R.setShowCaption(!0)})},E=(R,$)=>{setTimeout(()=>{_(!1)},200),m.update(()=>{const L=Q(t);Hn(L)&&L.setWidthAndHeight(R,$)})},N=()=>{_(!0)},O=f&&ve(b),M=f||h;return x.jsx(S.Suspense,{fallback:null,children:x.jsxs(x.Fragment,{children:[x.jsx("div",{draggable:O,children:x.jsx(PS,{className:M?`focused ${ve(b)?"draggable":""}`:null,src:n,altText:e,imageRef:c,width:r,height:o,maxWidth:s})}),a&&x.jsx("div",{className:"image-caption-container",children:x.jsxs(gS,{initialEditor:l,children:[x.jsx(oS,{}),x.jsx(P_,{}),x.jsx(MS,{}),x.jsx(uS,{}),x.jsx(lS,{}),x.jsx(cS,{}),x.jsx(yS,{contentEditable:x.jsx(zx,{className:"ImageNode__contentEditable"}),placeholder:x.jsx(Bh,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:aw})]})}),i&&ve(b)&&M&&x.jsx(qx,{showCaption:a,setShowCaption:I,editor:m,buttonRef:u,imageRef:c,maxWidth:s,onResizeStart:N,onResizeEnd:E})]})})}class Jr extends Bt{__src;__altText;__width;__height;__maxWidth;__showCaption;__caption;static getType(){return"image"}static clone(e){return new Jr(e.__src,e.__altText,e.__maxWidth,e.__width,e.__height,e.__showCaption,e.__caption,e.__key)}static importJSON(e){const{altText:t,height:r,width:o,maxWidth:s,caption:i,src:a,showCaption:l}=e,c=xa({altText:t,height:r,maxWidth:s,showCaption:l,src:a,width:o}),u=c.__caption,f=u.parseEditorState(i.editorState);return f.isEmpty()||u.setEditorState(f),c}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),{element:e}}static importDOM(){return{img:e=>({conversion:DS,priority:0})}}constructor(e,t,r,o,s,i,a,l){super(l),this.__src=e,this.__altText=t,this.__maxWidth=r,this.__width=o||"inherit",this.__height=s||"inherit",this.__showCaption=i||!1,this.__caption=a||iw()}exportJSON(){return{altText:this.getAltText(),caption:this.__caption.toJSON(),height:this.__height==="inherit"?0:this.__height,maxWidth:this.__maxWidth,showCaption:this.__showCaption,src:this.getSrc(),type:"image",version:1,width:this.__width==="inherit"?0:this.__width}}setWidthAndHeight(e,t){const r=this.getWritable();r.__width=e,r.__height=t}setShowCaption(e){const t=this.getWritable();t.__showCaption=e}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__altText}decorate(){return x.jsx(jS,{src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,maxWidth:this.__maxWidth,nodeKey:this.getKey(),showCaption:this.__showCaption,caption:this.__caption,resizable:!0})}}function xa({altText:n,height:e,maxWidth:t=500,src:r,width:o,showCaption:s,caption:i,key:a}){return new Jr(r,n,t,o,e,s,i,a)}function Hn(n){return n instanceof Jr}class Jo extends Bt{__format;constructor(e,t){super(t),this.__format=e||""}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format}exportJSON(){return{...super.exportJSON(),format:this.__format||""}}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format||"")}canIndent(){return!1}createDOM(){return Je().createElement("div")}updateDOM(){return!1}setFormat(e){const t=this.getWritable();return t.__format=e,t}getFormat(){return this.getLatest().__format}isInline(){return!1}}function sc(n){return n instanceof Jo}function Ls({children:n,format:e,nodeKey:t,className:r}){const[o]=fe(),[s,i,a]=_u(t),l=S.useRef(null);return S.useEffect(()=>de(o.registerCommand(Bn,c=>{if(s){const u=D();if(ve(u)){const f=Q(t);sc(f)&&f.setFormat(c)}else if(F(u)){const f=u.getNodes();for(const d of f)sc(d)?d.setFormat(c):Rc(d).setFormat(c)}return!0}return!1},ee),o.registerCommand(Ks,c=>Oo(c)===l.current&&(c.preventDefault(),c.shiftKey||a(),i(!s),!0),ee)),[a,o,s,t,i]),x.jsx("div",{className:[r.base,s?r.focus:null].filter(Boolean).join(" "),ref:l,style:{textAlign:e||void 0},children:n})}function FS({videoID:n,onClick:e}){const[t,r]=S.useState(`https://img.youtube.com/vi/${n}/maxresdefault.jpg`);return S.useEffect(()=>{const o=new Image;o.onload=()=>{o.width===120&&o.height===90&&r(`https://img.youtube.com/vi/${n}/mqdefault.jpg`)},o.src=t},[n,t]),x.jsxs("div",{onClick:e,style:{position:"relative",width:"560px",height:"315px",cursor:"pointer",backgroundColor:"#000",display:"flex",alignItems:"center",justifyContent:"center"},children:[x.jsx("img",{src:t,alt:"YouTube video thumbnail",style:{width:"100%",height:"100%",objectFit:"cover"}}),x.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"68px",height:"48px",backgroundColor:"rgba(255, 0, 0, 0.8)",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},onMouseEnter:o=>{o.currentTarget.style.backgroundColor="rgba(255, 0, 0, 1)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="rgba(255, 0, 0, 0.8)"},children:x.jsx("div",{style:{width:0,height:0,borderLeft:"20px solid white",borderTop:"12px solid transparent",borderBottom:"12px solid transparent",marginLeft:"4px"}})})]})}function BS({className:n,format:e,nodeKey:t,videoID:r}){const{onYouTubeClick:o}=R0();return o?x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx(FS,{videoID:r,onClick:()=>o(r)})}):x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx("iframe",{width:"560",height:"315",src:`https://www.youtube.com/embed/${r}`,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"YouTube video"})})}class qo extends Jo{__id;static getType(){return"youtube"}static clone(e){return new qo(e.__id,e.__format,e.__key)}static importJSON(e){const t=K_(e.videoID);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"youtube",version:1,videoID:this.__id}}constructor(e,t,r){super(t,r),this.__id=e}updateDOM(){return!1}getId(){return this.__id}decorate(e,t){const r=t.theme.embedBlock||{},o={base:r.base||"",focus:r.focus||""};return x.jsx(BS,{className:o,format:this.__format,nodeKey:this.getKey(),videoID:this.__id})}isTopLevel(){return!0}}function K_(n){return new qo(n)}function W_(n){return n instanceof qo}const wi="python",US={c:"C",clike:"C-like",css:"CSS",html:"HTML",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",xml:"XML"},zS={javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain"};function KS(n){return zS[n]||n}function jM(n){const e=KS(n);return US[e]||e}const FM=()=>wi,BM=()=>Object.keys(Pl.languages).filter(n=>typeof Pl.languages[n]!="function").sort();class Ar extends cn{__highlightType;constructor(e,t,r){super(e,r),this.__highlightType=t}static getType(){return"jupyter-input-highlight"}static clone(e){return new Ar(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(e){const t=super.createDOM(e),r=qa(e.theme,this.__highlightType);return Ie(t,r),this.__highlightType&&t.classList.add("token",this.__highlightType),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=qa(r.theme,e.__highlightType),i=qa(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(t,i)),e.__highlightType!==this.__highlightType&&(e.__highlightType&&t.classList.remove("token",e.__highlightType),this.__highlightType?t.classList.add("token",this.__highlightType):t.classList.remove("token")),o}static importJSON(e){const t=Sr(e.text,e.highlightType);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"jupyter-input-highlight",version:1}}setFormat(e){return this}}function qa(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Sr(n,e){return new Ar(n,e)}function tt(n){return n instanceof Ar}function Hi(n){let e=null;const t=n.getPreviousSiblings();for(t.push(n);t.length>0;){const r=t.pop();if(tt(r)&&(e=r),ue(r))break}return e}function Rf(n){let e=null;const t=n.getNextSiblings();for(t.unshift(n);t.length>0;){const r=t.shift();if(tt(r)&&(e=r),ue(r))break}return e}function WS(){return{output_type:"stream",name:"stderr",text:[`⚠️ No runtime connected. Please connect to a runtime to execute code.
11
+ `).map(s=>s.split(" ")),r=Ho();for(const s of t){const i=pn();for(const a of s){const l=lt(te.NO_STATUS),c=ne();a&&c.append($e(a)),l.append(c),i.append(l)}r.append(i)}const{anchorCell:o}=Wa(this);k_(r,o.select(0,o.getChildrenSize()))}insertText(){}hasFormat(e){let t=0;this.getNodes().filter(J).forEach(o=>{const s=o.getFirstChild();ht(s)&&(t|=s.getTextFormat())});const r=rh[e];return(t&r)!==0}insertNodes(e){const t=this.focus.getNode();q(t)||X(151),Ss(t.select(0,t.getChildrenSize())).insertNodes(e)}getShape(){const{anchorCell:e,focusCell:t}=Wa(this),r=Ql(e);r===null&&X(153);const o=Ql(t);o===null&&X(155);const s=Math.min(r.columnIndex,o.columnIndex),i=Math.max(r.columnIndex+r.colSpan-1,o.columnIndex+o.colSpan-1),a=Math.min(r.rowIndex,o.rowIndex),l=Math.max(r.rowIndex+r.rowSpan-1,o.rowIndex+o.rowSpan-1);return{fromX:Math.min(s,i),fromY:Math.min(a,l),toX:Math.max(s,i),toY:Math.max(a,l)}}getNodes(){if(!this.isValid())return[];const e=this._cachedNodes;if(e!==null)return e;const{anchorTable:t,anchorCell:r,focusCell:o}=Wa(this),s=o.getParents()[1];if(s!==t){if(t.isParentOf(o)){const m=s.getParent();m==null&&X(159),this.set(this.tableKey,o.getKey(),m.getKey())}else{const m=t.getParent();m==null&&X(158),this.set(this.tableKey,m.getKey(),o.getKey())}return this.getNodes()}const[i,a,l]=ct(t,r,o),{minColumn:c,maxColumn:u,minRow:f,maxRow:d}=Ns(i,a,l),g=new Map([[t.getKey(),t]]);let h=null;for(let m=f;m<=d;m++)for(let b=c;b<=u;b++){const{cell:w}=i[m][b],C=w.getParent();ce(C)||X(160),C!==h&&(g.set(C.getKey(),C),h=C),g.has(w.getKey())||AC(w,v=>{g.set(v.getKey(),v)})}const _=Array.from(g.values());return Fy()||(this._cachedNodes=_),_}getTextContent(){const e=this.getNodes().filter(r=>J(r));let t="";for(let r=0;r<e.length;r++){const o=e[r],s=o.__parent,i=(e[r+1]||{}).__parent;t+=o.getTextContent()+(i!==s?`
12
+ `:" ")}return t}}function ae(n){return n instanceof Vs}function RC(){const n=un("root",0,"element"),e=un("root",0,"element");return new Vs("root",n,e)}function Ki(n,e,t){n.getKey(),e.getKey(),t.getKey();const r=D(),o=ae(r)?r.clone():new Vs("root",un("root",0,"element"),un("root",0,"element"));return o.set(n.getKey(),e.getKey(),t.getKey()),o}function AC(n,e){const t=[[n]];for(let r=t.at(-1);r!==void 0&&t.length>0;r=t.at(-1)){const o=r.pop();o===void 0?t.pop():e(o)!==!1&&q(o)&&t.push(o.getChildren())}}function du(n,e=zo()){const t=Q(n);be(t)||X(231,n);const r=kt(t,e.getElementByKey(n));return r===null&&X(232,n),{tableElement:r,tableNode:t}}class MC{observers;nextFocus;shouldCheckSelectionForTable;constructor(){this.observers=new Map,this.nextFocus=null,this.shouldCheckSelectionForTable=null}setNextFocus(e){this.nextFocus=e}getAndClearNextFocus(){const{nextFocus:e}=this;return e!==null&&(this.nextFocus=null),e}setShouldCheckSelectionForTable(e){this.shouldCheckSelectionForTable=e}getAndClearShouldCheckSelectionForTable(){const{shouldCheckSelectionForTable:e}=this;return e?(this.shouldCheckSelectionForTable=null,e):null}removeObserver(e){const t=this.observers.get(e);return t!==void 0&&(t[0].removeListeners(),this.observers.delete(e),!0)}removeAllObservers(){for(const e of Array.from(this.observers.keys()))this.removeObserver(e)}$getTableNodesAndObservers(){const e=[];for(const[t,[r]]of Array.from(this.observers.entries())){const o=Q(t);be(o)?e.push([o,r]):this.removeObserver(t)}return e}}class T_{focusX;focusY;listenersToRemove;table;isHighlightingCells;anchorX;anchorY;tableNodeKey;anchorCell;focusCell;anchorCellNodeKey;focusCellNodeKey;editor;tableSelection;hasHijackedSelectionStyles;isSelecting;pointerType;abortController;listenerOptions;constructor(e,t){this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.listenersToRemove=new Set,this.tableNodeKey=t,this.editor=e,this.table={columns:0,domRows:[],rows:0},this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.isSelecting=!1,this.pointerType=null,this.abortController=new AbortController,this.listenerOptions={signal:this.abortController.signal},this.trackTable()}getTable(){return this.table}removeListeners(){this.abortController.abort("removeListeners"),Array.from(this.listenersToRemove).forEach(e=>e()),this.listenersToRemove.clear()}$lookup(){return du(this.tableNodeKey,this.editor)}trackTable(){const e=new MutationObserver(t=>{this.editor.read("latest",()=>{let r=!1;for(let i=0;i<t.length;i++){const a=t[i].target.nodeName;if(a==="TABLE"||a==="TBODY"||a==="THEAD"||a==="TR"){r=!0;break}}if(!r)return;const{tableNode:o,tableElement:s}=this.$lookup();this.table=vo(o,s)})});this.editor.read("latest",()=>{const{tableNode:t,tableElement:r}=this.$lookup();this.table=vo(t,r),e.observe(r,{attributes:!0,childList:!0,subtree:!0})})}$clearHighlight(e=!0){const t=this.editor;this.isHighlightingCells=!1,this.anchorX=-1,this.anchorY=-1,this.focusX=-1,this.focusY=-1,this.tableSelection=null,this.anchorCellNodeKey=null,this.focusCellNodeKey=null,this.anchorCell=null,this.focusCell=null,this.hasHijackedSelectionStyles=!1,this.$enableHighlightStyle();const{tableNode:r,tableElement:o}=this.$lookup();li(t,vo(r,o),null),e&&D()!==null&&(Ee(null),t.dispatchCommand(Ht))}$enableHighlightStyle(){const e=this.editor,{tableElement:t}=this.$lookup();$t(t,e._config.theme.tableSelection),t.classList.remove("disable-selection"),this.hasHijackedSelectionStyles=!1}$disableHighlightStyle(){const{tableElement:e}=this.$lookup();Ie(e,this.editor._config.theme.tableSelection),this.hasHijackedSelectionStyles=!0}$updateTableTableSelection(e){if(e!==null){e.tableKey!==this.tableNodeKey&&X(233,e.tableKey,this.tableNodeKey);const t=this.editor;this.tableSelection=e,this.isHighlightingCells=!0,this.$disableHighlightStyle(),this.updateDOMSelection(),li(t,this.table,this.tableSelection)}else this.$clearHighlight()}updateDOMSelection(){if(this.anchorCell!==null&&this.focusCell!==null){const e=or(this.editor._window);e&&e.rangeCount>0&&e.removeAllRanges()}}$setFocusCellForSelection(e,t=!1){const r=this.editor,{tableNode:o}=this.$lookup(),s=e.x,i=e.y;if(this.focusCell=e,!this.isHighlightingCells&&(t||this.anchorX!==s||this.anchorY!==i||this.tableSelection!=null&&this.anchorCellNodeKey!=null)&&(this.isHighlightingCells=!0,this.$disableHighlightStyle()),this.focusX!==-1&&this.focusY!==-1&&s===this.focusX&&i===this.focusY)return!1;if(this.focusX=s,this.focusY=i,this.isHighlightingCells){const a=tc(o,e.elem);if(this.tableSelection!=null&&this.anchorCellNodeKey!=null){let l=a;if(l===null&&t&&(l=o.getCellNodeFromCords(s,i,this.table)),l!==null){const c=this.$getAnchorTableCellOrThrow();return this.focusCellNodeKey=l.getKey(),this.tableSelection=Ki(o,c,l),Ee(this.tableSelection),r.dispatchCommand(Ht),li(r,this.table,this.tableSelection),!0}}}return!1}$getAnchorTableCell(){const e=this.anchorCellNodeKey?Q(this.anchorCellNodeKey):null;return J(e)?e:null}$getAnchorTableCellOrThrow(){const e=this.$getAnchorTableCell();return e===null&&X(234),e}$getFocusTableCell(){const e=this.focusCellNodeKey?Q(this.focusCellNodeKey):null;return J(e)?e:null}$getFocusTableCellOrThrow(){const e=this.$getFocusTableCell();return e===null&&X(235),e}$setAnchorCellForSelection(e){this.isHighlightingCells=!1,this.anchorCell=e,this.anchorX=e.x,this.anchorY=e.y,this.focusX=-1,this.focusY=-1,this.focusCell=null,this.focusCellNodeKey=null;const{tableNode:t}=this.$lookup(),r=tc(t,e.elem);if(r!==null){const o=r.getKey();this.tableSelection!=null?(this.tableSelection=this.tableSelection.clone(),this.tableSelection.set(t.getKey(),o,o)):this.tableSelection=Ki(t,r,r),this.anchorCellNodeKey=o}}$formatCells(e){const t=D();ae(t)||X(236);const r=kr(),o=r.anchor,s=r.focus,i=t.getNodes().filter(J);i.length>0||X(237);const a=i[0].getFirstChild(),l=ht(a)?a.getFormatFlags(e,null):null;i.forEach(c=>{o.set(c.getKey(),0,"element"),s.set(c.getKey(),c.getChildrenSize(),"element"),r.formatText(e,l)}),Ee(t),this.editor.dispatchCommand(Ht)}$clearText(){const{editor:e}=this,t=Q(this.tableNodeKey);if(!be(t))throw new Error("Expected TableNode.");const r=D();ae(r)||X(253);const o=r.getNodes().filter(J),s=t.getFirstChild(),i=t.getLastChild();if(o.length>0&&s!==null&&i!==null&&ce(s)&&ce(i)&&o[0]===s.getFirstChild()&&o[o.length-1]===i.getLastChild()){t.selectPrevious();const a=t.getParent();return t.remove(),void(Jp(a)&&a.isEmpty()&&e.dispatchCommand(Lo))}o.forEach(a=>{if(q(a)){const l=ne(),c=$e();l.append(c),a.append(l),a.getChildren().forEach(u=>{u!==l&&u.remove()})}}),li(e,this.table,null),Ee(null),e.dispatchCommand(Ht)}}const So="__lexicalTableSelection";function I_(n){const e=Wy(n);return be(e)||X(386,n),e}const ro=40;function Ha(n,e,t){const r=o=>Math.max(1,Math.ceil(Math.min(ro,o)/ro*18));return n<=e+ro?-r(e+ro-n):n>=t-ro?r(n-(t-ro)):0}function Fn(n){return ke(n)&&n.nodeName==="TABLE"}function kt(n,e){if(!e)return e;const t=Fn(e)?e:e.querySelector("table");return Fn(t)||X(341,n.constructor.name,n.getType(),n.getKey(),e.nodeName),t}function ha(n){return n._window}function _a(n,e){for(let t=e,r=null;t!==null;t=t.getParent()){if(n.is(t))return r;J(t)&&(r=t)}return null}const $C=[[Vt,"down"],[pt,"up"],[zs,"backward"],[ia,"forward"]],DC=[Yp,Vp,bi],PC=[sa,Oc];function jC(n,e){return n.registerRootListener(t=>{if(t===null)return;const r=n._window;if(r!==null)return Jt(r,"pointerdown",o=>{const s=Oo(o);if(o.button!==0||!No(s)||!t.contains(s))return;const i=(function(a){const l=Do(a);if(l===null)return null;let c=l.elem;for(;c!=null;){if(c.nodeName==="TABLE"&&So in c&&c[So])return{cellElement:l,tableElement:c,tableObserver:c[So]};c=c.parentNode}return null})(s);n.update(()=>{if(ae(D())){for(const[u]of e.observers.values())u.$clearHighlight(!1);Ee(null),n.dispatchCommand(Ht)}if(!i)return;const{tableObserver:a,tableElement:l,cellElement:c}=i;(function(u,f,d,g,h,_){const m=u._window;if(!m)return;const b=v=>{if(h.isSelecting)return;h.isSelecting=!0,v!==null&&h.anchorCell===null&&u.update(()=>{h.$setAnchorCellForSelection(v)});let k=f.clientX,I=f.clientY,E=null;const N=()=>{h.isSelecting=!1,E!==null&&(m.cancelAnimationFrame(E),E=null),m.removeEventListener("pointerup",U),m.removeEventListener("pointermove",z)},O=(K,H)=>{const ie=g.getRootNode();if(!Dp(ie)&&!jc(ie))return null;for(const Ne of ie.elementsFromPoint(K,H)){const Ce=xf(g,Ne);if(Ce)return Ce}return null},M=(K,H)=>{h.anchorCell===null&&u.update(()=>{h.$setAnchorCellForSelection(K)}),h.focusCell!==null&&K.elem===h.focusCell.elem||(_.setNextFocus({focusCell:K,override:H,tableKey:h.tableNodeKey}),u.dispatchCommand(Ht))},R=K=>{for(let H=g.parentElement;H;H=H.parentElement)if(K==="x"?H.scrollWidth>H.clientWidth:H.scrollHeight>H.clientHeight){const ie=m.getComputedStyle(H),Ne=K==="x"?ie.overflowX:ie.overflowY;if(Ne==="auto"||Ne==="scroll")return H}return null},$=(K,H,ie)=>{let Ne,Ce;if(K===null)Ne=0,Ce=ie==="x"?m.innerWidth:m.innerHeight;else{const nn=K.getBoundingClientRect();Ne=ie==="x"?nn.left:nn.top,Ce=ie==="x"?nn.right:nn.bottom}const ut=Ha(H,Ne,Ce);if(ut===0)return!1;if(K===null){const nn=ie==="x"?m.scrollX:m.scrollY;return m.scrollBy(ie==="x"?ut:0,ie==="x"?0:ut),(ie==="x"?m.scrollX:m.scrollY)!==nn}if(ie==="x"){const nn=K.scrollLeft;return K.scrollLeft+=ut,K.scrollLeft!==nn}const Mn=K.scrollTop;return K.scrollTop+=ut,K.scrollTop!==Mn},L=(K,H)=>{let ie=k,Ne=I;if(K===null)ie=Math.min(Math.max(ie,1),m.innerWidth-1);else{const Ce=K.getBoundingClientRect();ie=Math.min(Math.max(ie,Ce.left+1),Ce.right-1)}if(H===null)Ne=Math.min(Math.max(Ne,1),m.innerHeight-1);else{const Ce=H.getBoundingClientRect();Ne=Math.min(Math.max(Ne,Ce.top+1),Ce.bottom-1)}return[ie,Ne]},A=()=>{const K=R("x");if(K!==null){const Ce=K.getBoundingClientRect();if(Ha(k,Ce.left,Ce.right)!==0)return!0}const H=R("y"),ie=H===null?0:H.getBoundingClientRect().top,Ne=H===null?m.innerHeight:H.getBoundingClientRect().bottom;return Ha(I,ie,Ne)!==0},B=()=>{if(E=null,!h.isSelecting)return;const K=R("x"),H=R("y"),ie=K!==null&&$(K,k,"x"),Ne=$(H,I,"y");if(ie||Ne){const[Ce,ut]=L(K,H),Mn=O(Ce,ut);Mn&&M(Mn,!1),E=m.requestAnimationFrame(B)}},j=()=>{E===null&&h.pointerType!=="touch"&&A()&&(E=m.requestAnimationFrame(B))},U=()=>{N()},z=K=>{if(!(Ce=>!(1&~Ce.buttons))(K)&&h.isSelecting)return void N();const H=Oo(K);if(!No(H))return;k=K.clientX,I=K.clientY;let ie=null;const Ne=!(Ed||g.contains(H));ie=Ne?xf(g,H):O(K.clientX,K.clientY),ie&&M(ie,Ne),j()};m.addEventListener("pointerup",U,h.listenerOptions),m.addEventListener("pointermove",z,h.listenerOptions)};h.pointerType=f.pointerType;const w=I_(h.tableNodeKey),C=mo();if(Ed&&f.shiftKey&&Ut(C,w)&&(F(C)||ae(C))){const v=C.anchor.getNode(),k=_a(w,C.anchor.getNode());k?(h.$setAnchorCellForSelection(mr(h,k)),h.$setFocusCellForSelection(d),yn(f)):(w.isBefore(v)?w.selectStart():w.selectEnd()).anchor.set(C.anchor.key,C.anchor.offset,C.anchor.type)}else f.pointerType!=="touch"&&h.$setAnchorCellForSelection(d);b(d)})(n,o,c,l,a,e)})})})}function E_(n,e,t,r,o){const s=t.getRootElement(),i=ha(t);s!==null&&i!==null||X(246);const a=new T_(t,n.getKey()),l=kt(n,e);(function(d,g){$o(d)!==null&&X(205),d[So]=g})(l,a),a.listenersToRemove.add(()=>(function(d,g){$o(d)===g&&delete d[So]})(l,a)),a.listenersToRemove.add(Jt(l,"mousedown",d=>{const g=Oo(d);d.detail>=3&&No(g)&&Do(g)!==null&&d.preventDefault()},a.listenerOptions));for(const[d,g]of $C)a.listenersToRemove.add(t.registerCommand(d,h=>O_(t,h,g,n,a,o),qe));a.listenersToRemove.add(t.registerCommand(Nn,d=>{const g=D();if(ae(g)){const h=_a(n,g.focus.getNode());if(h!==null)return yn(d),h.selectEnd(),!0}return!1},qe));const c=()=>{const d=D();return!!Ut(d,n)&&!!ae(d)&&(a.$clearText(),!0)};for(const d of DC)a.listenersToRemove.add(t.registerCommand(d,c,qe));const u=d=>{const g=D();if(!ae(g)&&!F(g))return!1;const h=n.isParentOf(g.anchor.getNode());if(h!==n.isParentOf(g.focus.getNode())){const _=h?"anchor":"focus",m=h?"focus":"anchor",{key:b,offset:w,type:C}=g[m];return n[g[_].isBefore(g[m])?"selectPrevious":"selectNext"]()[m].set(b,w,C),!1}return!!Ut(g,n)&&!!ae(g)&&(d&&(d.preventDefault(),d.stopPropagation()),a.$clearText(),!0)};for(const d of PC)a.listenersToRemove.add(t.registerCommand(d,u,qe));a.listenersToRemove.add(t.registerCommand(zp,d=>{const g=D();if(g){if(!ae(g)&&!F(g))return!1;Il(t,fo(d,ClipboardEvent)?d:null,Hp(g));const h=u(d);return F(g)?(g.removeText(),!0):h}return!1},qe));const f=s.ownerDocument;return a.listenersToRemove.add(Jt(f,"paste",d=>{d.defaultPrevented||t.read("latest",()=>{const g=D();return s.contains(f.activeElement)&&ae(g)&&Ut(g,n)})&&(d.preventDefault(),t.dispatchCommand(Ic,d))})),a.listenersToRemove.add(Jt(f,"copy",d=>{if(d.defaultPrevented)return;const g=Oo(d);g===s||No(g)&&s.contains(g)||t.read("latest",()=>{const h=D();return s.contains(la(s))&&ae(h)&&Ut(h,n)})&&(d.preventDefault(),t.dispatchCommand(Kp,d))})),a.listenersToRemove.add(t.registerCommand(Ge,d=>{const g=D();return!!Ut(g,n)&&!!ae(g)&&(a.$formatCells(d),!0)},qe)),a.listenersToRemove.add(t.registerCommand(Bn,d=>{const g=D();if(!ae(g)||!Ut(g,n))return!1;const h=g.anchor.getNode(),_=g.focus.getNode();if(!J(h)||!J(_))return!1;const[m,b,w]=ct(n,h,_),C=Math.max(b.startRow+b.cell.__rowSpan-1,w.startRow+w.cell.__rowSpan-1),v=Math.max(b.startColumn+b.cell.__colSpan-1,w.startColumn+w.cell.__colSpan-1),k=Math.min(b.startRow,w.startRow),I=Math.min(b.startColumn,w.startColumn);if(k===0&&I===0&&C===m.length-1&&v===m[0].length-1)return n.setFormat(d),!0;const E=new Set;for(let N=k;N<=C;N++)for(let O=I;O<=v;O++){const M=m[N][O].cell;if(E.has(M))continue;E.add(M),M.setFormat(d);const R=M.getChildren();for(let $=0;$<R.length;$++){const L=R[$];q(L)&&!L.isInline()&&L.setFormat(d)}}return!0},qe)),a.listenersToRemove.add(t.registerCommand(qp,d=>{const g=D();if(!Ut(g,n))return!1;if(ae(g))return a.$clearHighlight(),!1;if(F(g)){const h=re(g.anchor.getNode(),_=>J(_));if(!J(h))return!1;if(typeof d=="string"){const _=Sf(t,g,n);if(_)return Cf(_,n,[$e(d)]),!0}}return!1},qe)),r&&a.listenersToRemove.add(t.registerCommand(Kr,d=>{const g=D();if(!F(g)||!g.isCollapsed()||!Ut(g,n))return!1;const h=ho(g.anchor.getNode());return!(h===null||!n.is(Or(h)))&&(yn(d),(function(_,m){const b=m==="next"?"getNextSibling":"getPreviousSibling",w=m==="next"?"getFirstChild":"getLastChild",C=_[b]();if(q(C))return C.selectEnd();const v=re(_,ce);v===null&&X(247);for(let I=v[b]();ce(I);I=I[b]()){const E=I[w]();if(q(E))return E.selectEnd()}const k=re(v,be);k===null&&X(248),m==="next"?k.selectNext():k.selectPrevious()})(h,d.shiftKey?"previous":"next"),!0)},qe)),a.listenersToRemove.add(t.registerCommand(oh,d=>n.isSelected(),qe)),a.listenersToRemove.add(t.registerCommand(Lo,()=>{const d=D();if(!F(d)||!d.isCollapsed()||!Ut(d,n))return!1;const g=Sf(t,d,n);return!!g&&(Cf(g,n),!0)},qe)),a}function FC(n,e){const t=D(),r=mo(),o=n.getAndClearNextFocus();if(o!==null){const{tableKey:i,focusCell:a}=o,l=n.observers.get(i);l||X(335,i);const[c]=l;if(ae(t)&&t.tableKey===c.tableNodeKey)return(a.x!==c.focusX||a.y!==c.focusY)&&(c.$setFocusCellForSelection(a),!0);if(c.anchorCell!==null&&c.anchorCellNodeKey!==null&&a.elem!==c.anchorCell.elem&&c.tableSelection!==null)return c.$setFocusCellForSelection(a,!0),!0}const s=n.getAndClearShouldCheckSelectionForTable();if(s&&F(r)&&F(t)&&t.isCollapsed()){const i=Q(s);if(be(i)){const a=t.anchor.getNode(),l=i.getFirstChild(),c=ho(a);if(c!==null&&ce(l)){const u=l.getFirstChild();if(J(u)&&i.is(re(c,f=>f.is(i)||f.is(u))))return u.selectStart(),!0}}}ae(t)&&(function(i,a){const l=ha(i),c=mo();if(!a.is(c))return;const u=I_(a.tableKey),f=or(l),d=f&&Pc(f,i.getRootElement());if(f&&d&&d.anchorNode&&d.focusNode){const g=Ae(d.focusNode),h=g&&!u.isParentOf(g),_=Ae(d.anchorNode),m=_&&u.isParentOf(_);if(h&&m&&f.rangeCount>0){const b=Uy(f,i);b&&(b.anchor.set(u.getKey(),a.isBackward()?u.getChildrenSize():0,"element"),f.removeAllRanges(),Ee(b))}}})(e,t),F(t)&&(function(i,a){const l=mo(),{anchor:c,focus:u}=i,f=c.getNode(),d=u.getNode(),g=ho(f),h=ho(d),_=g?Or(g):null,m=h?Or(h):null,b=i.isBackward(),w=g&&h&&_&&m&&_.is(m),C=m&&(!_||_.isParentOf(m)),v=_&&(!m||m.isParentOf(_));if(C){const k=i.clone(),[I]=ct(m,h,h),E=I[0][0].cell,N=I[I.length-1].at(-1).cell;k.focus.set(b?E.getKey():N.getKey(),b?0:N.getChildrenSize(),"element"),Ee(k)}else if(v){const k=i.clone(),[I]=ct(_,g,g),E=I[0][0].cell,N=I[I.length-1].at(-1).cell;k.anchor.set(b?N.getKey():E.getKey(),b?N.getChildrenSize():0,"element"),Ee(k)}else if(w){const k=a.observers.get(_.getKey());k||X(335,_.getKey());const[I]=k;if(g.is(h)||(I.$setAnchorCellForSelection(mr(I,g)),I.$setFocusCellForSelection(mr(I,h),!0)),I.pointerType==="touch"&&I.isSelecting&&i.isCollapsed()&&F(l)&&l.isCollapsed()){const E=ho(l.anchor.getNode());E&&!E.is(h)&&(I.$setAnchorCellForSelection(mr(I,E)),I.$setFocusCellForSelection(mr(I,h),!0),I.pointerType=null)}}})(t,n);for(const[i,a]of n.$getTableNodesAndObservers())BC(e,i,a);return!1}function BC(n,e,t){const r=D(),o=mo();r&&!r.is(o)&&(ae(r)||ae(o))&&t.tableSelection&&!t.tableSelection.is(o)&&(ae(r)&&r.tableKey===t.tableNodeKey?t.$updateTableTableSelection(r):!ae(r)&&ae(o)&&o.tableKey===t.tableNodeKey&&t.$updateTableTableSelection(null)),t.hasHijackedSelectionStyles&&!e.isSelected()?(function(s,i){i.$enableHighlightStyle(),ec(i.table,a=>{const l=a.elem;a.highlighted=!1,L_(s,a),l.getAttribute("style")||l.removeAttribute("style")})})(n,t):!t.hasHijackedSelectionStyles&&e.isSelected()&&(function(s,i){i.$disableHighlightStyle(),ec(i.table,a=>{a.highlighted=!0,N_(s,a)})})(n,t)}function $o(n){return n[So]||null}function Do(n){let e=n;for(;e!=null;){const t=e.nodeName;if(t==="TD"||t==="TH"){const r=e._cell;return r===void 0?null:r}e=e.parentNode}return null}function xf(n,e){if(!n.contains(e))return null;let t=null;for(let r=e;r!=null;r=r.parentNode){if(r===n)return t;const o=r.nodeName;o!=="TD"&&o!=="TH"||(t=r._cell||null)}return null}function vo(n,e){const t=[],r={columns:0,domRows:t,rows:0};let o=kt(n,e).querySelector("tr"),s=0,i=0;for(t.length=0;o!=null;){const a=o.nodeName;if(a==="TD"||a==="TH"){const u={elem:o,hasBackgroundColor:o.style.backgroundColor!=="",highlighted:!1,x:s,y:i};o._cell=u;let f=t[i];f===void 0&&(f=t[i]=[]),f[s]=u}else{const u=o.firstChild;if(u!=null){o=u;continue}}const l=o.nextSibling;if(l!=null){s++,o=l;continue}const c=o.parentNode;if(c!=null){const u=c.nextSibling;if(u==null)break;i++,s=0,o=u}}return r.columns=s+1,r.rows=i+1,r}function li(n,e,t){const r=new Set(t?t.getNodes():[]);ec(e,(o,s)=>{const i=o.elem;r.has(s)?(o.highlighted=!0,N_(n,o)):(o.highlighted=!1,L_(n,o),i.getAttribute("style")||i.removeAttribute("style"))})}function ec(n,e){const{domRows:t}=n;for(let r=0;r<t.length;r++){const o=t[r];if(o)for(let s=0;s<o.length;s++){const i=o[s];if(!i)continue;const a=Ae(i.elem);a!==null&&e(i,a,{x:s,y:r})}}}const UC=(n,e,t,r,o)=>{const s=o==="forward";switch(o){case"backward":case"forward":return t!==(s?n.table.columns-1:0)?ui(e.getCellNodeFromCordsOrThrow(t+(s?1:-1),r,n.table),s):r!==(s?n.table.rows-1:0)?ui(e.getCellNodeFromCordsOrThrow(s?0:n.table.columns-1,r+(s?1:-1),n.table),s):s?e.selectNext():e.selectPrevious(),!0;case"up":return r!==0?ui(e.getCellNodeFromCordsOrThrow(t,r-1,n.table),!1):e.selectPrevious(),!0;case"down":return r!==n.table.rows-1?ui(e.getCellNodeFromCordsOrThrow(t,r+1,n.table),!0):e.selectNext(),!0;default:return!1}};function Ja(n,e){let t,r;if(e.startColumn===n.minColumn)t="minColumn";else{if(e.startColumn+e.cell.__colSpan-1!==n.maxColumn)return null;t="maxColumn"}if(e.startRow===n.minRow)r="minRow";else{if(e.startRow+e.cell.__rowSpan-1!==n.maxRow)return null;r="maxRow"}return[t,r]}function ci([n,e]){return[n==="minColumn"?"maxColumn":"minColumn",e==="minRow"?"maxRow":"minRow"]}function oo(n,e,[t,r]){const o=e[r],s=n[o];s===void 0&&X(250,r,String(o));const i=e[t],a=s[i];return a===void 0&&X(250,t,String(i)),a}function zC(n,e,t,r,o){const s=Ns(e,t,r),i=(function(I,E){const{minColumn:N,maxColumn:O,minRow:M,maxRow:R}=E;let $=1,L=1,A=1,B=1;const j=I[M],U=I[R];for(let z=N;z<=O;z++)$=Math.max($,j[z].cell.__rowSpan),B=Math.max(B,U[z].cell.__rowSpan);for(let z=M;z<=R;z++)L=Math.max(L,I[z][N].cell.__colSpan),A=Math.max(A,I[z][O].cell.__colSpan);return{bottomSpan:B,leftSpan:L,rightSpan:A,topSpan:$}})(e,s),{topSpan:a,leftSpan:l,bottomSpan:c,rightSpan:u}=i,f=(function(I,E){const N=Ja(I,E);return N===null&&X(249,E.cell.getKey()),N})(s,t),[d,g]=ci(f);let h=s[d],_=s[g];o==="forward"?h+=d==="maxColumn"?1:l:o==="backward"?h-=d==="minColumn"?1:u:o==="down"?_+=g==="maxRow"?1:a:o==="up"&&(_-=g==="minRow"?1:c);const m=e[_];if(m===void 0)return!1;const b=m[h];if(b===void 0)return!1;const[w,C]=(function(I,E,N){const O=Ns(I,E,N),M=Ja(O,E);if(M)return[oo(I,O,M),oo(I,O,ci(M))];const R=Ja(O,N);if(R)return[oo(I,O,ci(R)),oo(I,O,R)];const $=["minColumn","minRow"];return[oo(I,O,$),oo(I,O,ci($))]})(e,t,b),v=mr(n,w.cell),k=mr(n,C.cell);return n.$setAnchorCellForSelection(v),n.$setFocusCellForSelection(k,!0),!0}function Ut(n,e){if(F(n)||ae(n)){const t=e.isParentOf(n.anchor.getNode()),r=e.isParentOf(n.focus.getNode());return t&&r}return!1}function ui(n,e){e?n.selectStart():n.selectEnd()}function N_(n,e){const t=e.elem,r=n._config.theme;J(Ae(t))||X(131),Ie(t,r.tableCellSelected)}function L_(n,e){const t=e.elem;J(Ae(t))||X(131);const r=n._config.theme;$t(t,r.tableCellSelected)}function ho(n){const e=re(n,J);return J(e)?e:null}function Or(n){const e=re(n,be);return be(e)?e:null}function KC(n,e,t,r,o,s,i){const a=vs(t.focus,o?"previous":"next");if(zy(a))return!1;let l=a;for(const m of Ll(a).iterNodeCarets("shadowRoot")){if(!Mc(m)||!q(m.origin))return!1;l=m}const c=l.getParentAtCaret();if(!J(c))return!1;const u=c,f=(function(m){for(const b of Ll(m).iterNodeCarets("root")){const{origin:w}=b;if(J(w)){if(Nd(b))return Er(w,m.direction)}else if(!ce(w))break}return null})(gt(u,l.direction)),d=re(u,be);if(!d||!d.is(s))return!1;const g=n.getElementByKey(u.getKey()),h=Do(g);if(!g||!h)return!1;const _=A_(n,d);if(i.table=_,f)if(r==="extend"){const m=Do(n.getElementByKey(f.origin.getKey()));if(!m)return!1;i.$setAnchorCellForSelection(h),i.$setFocusCellForSelection(m,!0)}else{const m=Jn(f);hr(t.anchor,m),hr(t.focus,m)}else if(r==="extend")i.$setAnchorCellForSelection(h),i.$setFocusCellForSelection(h,!0);else{const m=(function(b){const w=Ky(b);return Nd(w)?Jn(w):b})(gt(d,a.direction));hr(t.anchor,m),hr(t.focus,m)}return yn(e),!0}function O_(n,e,t,r,o,s){if((t==="up"||t==="down")&&(function(a){const l=a.getRootElement();return l?l.hasAttribute("aria-controls")&&l.getAttribute("aria-controls")==="typeahead-menu":!1})(n))return!1;const i=D();if(!Ut(i,r)){if(F(i)){if(t==="backward"){if(i.focus.offset>0)return!1;const a=(function(c){for(let u=c,f=c;f!==null;u=f,f=f.getParent())if(q(f)){if(f!==u&&f.getFirstChild()!==u)return null;if(!f.isInline())return f}return null})(i.focus.getNode());if(!a)return!1;const l=a.getPreviousSibling();return!!be(l)&&(yn(e),e.shiftKey?i.focus.set(l.getParentOrThrow().getKey(),l.getIndexWithinParent(),"element"):l.selectEnd(),!0)}if(e.shiftKey&&(t==="up"||t==="down")){const a=i.focus.getNode();if(!i.isCollapsed()&&(t==="up"&&!i.isBackward()||t==="down"&&i.isBackward())){let l=re(a,g=>be(g));if(J(l)&&(l=re(l,be)),l!==r||!l)return!1;const c=t==="down"?l.getNextSibling():l.getPreviousSibling();if(!c)return!1;let u=0;t==="up"&&q(c)&&(u=c.getChildrenSize());let f=c;t==="up"&&q(c)&&(f=c.getLastChild()||c,u=oe(f)?f.getTextContentSize():0);const d=i.clone();return d.focus.set(f.getKey(),u,oe(f)?"text":"element"),Ee(d),yn(e),!0}if(wt(a)){const l=t==="up"?i.getNodes()[i.getNodes().length-1]:i.getNodes()[0];if(l&&_a(r,l)!==null){const c=r.getFirstDescendant(),u=r.getLastDescendant();if(!c||!u)return!1;const[f]=We(c),[d]=We(u),g=r.getCordsFromCellNode(f,o.table),h=r.getCordsFromCellNode(d,o.table),_=r.getDOMCellFromCordsOrThrow(g.x,g.y,o.table),m=r.getDOMCellFromCordsOrThrow(h.x,h.y,o.table);return o.$setAnchorCellForSelection(_),o.$setFocusCellForSelection(m,!0),!0}return!1}{let l=re(a,u=>q(u)&&!u.isInline());if(J(l)&&(l=re(l,be)),!l)return!1;const c=t==="down"?l.getNextSibling():l.getPreviousSibling();if(be(c)&&o.tableNodeKey===c.getKey()){const u=c.getFirstDescendant(),f=c.getLastDescendant();if(!u||!f)return!1;const[d]=We(u),[g]=We(f),h=i.clone();return h.focus.set((t==="up"?d:g).getKey(),t==="up"?0:g.getChildrenSize(),"element"),yn(e),Ee(h),!0}}}}return t==="down"&&Po(n)&&s.setShouldCheckSelectionForTable(r.getKey()),!1}if(F(i)){if(t==="backward"||t==="forward")return KC(n,e,i,e.shiftKey?"extend":"move",t==="backward",r,o);if(i.isCollapsed()){const{anchor:a,focus:l}=i,c=re(a.getNode(),J),u=re(l.getNode(),J);if(!J(c)||!c.is(u))return!1;const f=Or(c);if(f!==r&&f!=null){const w=kt(f,n.getElementByKey(f.getKey()));if(w!=null)return o.table=vo(f,w),O_(n,e,t,f,o,s)}const d=n.getElementByKey(c.__key),g=n.getElementByKey(a.key);if(g==null||d==null)return!1;let h;if(a.type==="element")h=g.getBoundingClientRect();else{const w=or(ha(n));if(w===null||w.rangeCount===0)return!1;const C=By(w,n.getRootElement());if(C===null)return!1;h=C.getBoundingClientRect()}const _=t==="up"?c.getFirstChild():c.getLastChild();if(_==null)return!1;const m=n.getElementByKey(_.__key);if(m==null)return!1;const b=m.getBoundingClientRect();if(t==="up"?b.top>h.top-h.height:h.bottom+h.height>b.bottom){yn(e);const w=r.getCordsFromCellNode(c,o.table);if(!e.shiftKey)return UC(o,r,w.x,w.y,t);{const C=r.getDOMCellFromCordsOrThrow(w.x,w.y,o.table);o.$setAnchorCellForSelection(C),o.$setFocusCellForSelection(C,!0)}return!0}}}else if(ae(i)){const{anchor:a,focus:l,tableKey:c}=i;if(c!==r.getKey())return!1;const u=re(a.getNode(),J),f=re(l.getNode(),J),[d]=i.getNodes();be(d)||X(251);const g=kt(d,n.getElementByKey(d.getKey()));if(!J(u)||!J(f)||!be(d)||g==null)return!1;o.$updateTableTableSelection(i);const h=vo(d,g),_=r.getCordsFromCellNode(u,h),m=r.getDOMCellFromCordsOrThrow(_.x,_.y,h);if(o.$setAnchorCellForSelection(m),yn(e),e.shiftKey){const[b,w,C]=ct(r,u,f);return zC(o,b,w,C,t)}return f.selectEnd(),!0}return!1}function yn(n){n.preventDefault(),n.stopImmediatePropagation(),n.stopPropagation()}function Cf(n,e,t){const r=ne();n==="first"?e.insertBefore(r):e.insertAfter(r),r.append(...t||[]),r.selectEnd()}function Sf(n,e,t){const r=t.getParent();if(!r)return;const o=or(ha(n));if(!o)return;const s=Pc(o,n.getRootElement()).anchorNode,i=n.getElementByKey(r.getKey()),a=kt(t,n.getElementByKey(t.getKey()));if(!s||!i||!a||!i.contains(s)||a.contains(s))return;const l=re(e.anchor.getNode(),w=>J(w));if(!l)return;const c=re(l,w=>be(w));if(!be(c)||!c.is(t))return;const[u,f]=ct(t,l,l),d=u[0][0],g=u[u.length-1][u[0].length-1],{startRow:h,startColumn:_}=f,m=h===d.startRow&&_===d.startColumn,b=h===g.startRow&&_===g.startColumn;return m?"first":b?"last":void 0}function mr(n,e){const{tableNode:t}=n.$lookup(),r=t.getCordsFromCellNode(e,n.table);return t.getDOMCellFromCordsOrThrow(r.x,r.y,n.table)}function tc(n,e,t){return _a(n,Ae(e,t))}function Wi(n){return ke(n)&&n.nodeName==="DIV"}function vf(n,e,t){let r=n.querySelector(":scope > colgroup");if(!t)return void(r&&r.remove());r||(r=Je().createElement("colgroup"),Rl(r),n.insertBefore(r,n.firstChild));const o=[];for(let s=0;s<e;s++){const i=Je().createElement("col"),a=t[s];a&&(i.style.width=`${a}px`),o.push(i)}r.replaceChildren(...o)}function kf(n,e,t){if(!e.theme.tableAlignment)return;const r=[],o=[];for(const s of["center","right"]){const i=e.theme.tableAlignment[s];i&&(s===t?o:r).push(i)}$t(n,...r),Ie(n,...o)}const R_=new WeakSet;function WC(n){const{scrollable:e,scrollbar:t,tableElement:r}=n;if(t.classList.length===0&&(function(a){const l=a.style.display;a.style.display="";const c=a.offsetHeight-a.clientHeight;return a.style.display=l,c})(t)===0)return R_.add(t),t.style.display="none",e.style.scrollbarWidth="auto",()=>{};const o=()=>{t.scrollLeft!==e.scrollLeft&&(t.scrollLeft=e.scrollLeft)},s=()=>{e.scrollLeft!==t.scrollLeft&&(e.scrollLeft=t.scrollLeft)};e.addEventListener("scroll",o,{passive:!0}),t.addEventListener("scroll",s,{passive:!0});let i=null;return typeof ResizeObserver<"u"&&(i=new ResizeObserver(()=>{nc(e,t)}),i.observe(e),i.observe(r)),nc(e,t),()=>{e.removeEventListener("scroll",o),t.removeEventListener("scroll",s),i&&i.disconnect()}}function nc(n,e){if(R_.has(e))return;const t=e.firstElementChild;if(!t||!ke(t)||!n.isConnected)return;const r=n.ownerDocument.defaultView;if(!r)return void(e.style.display="none");const o=r.getComputedStyle(n).overflowX,s=o==="auto"||o==="scroll",i=n.scrollWidth,a=n.clientWidth,l=i+"px";t.style.width!==l&&(t.style.width=l);const c=s&&i>a;e.style.display=c?"":"none"}function HC(n){if(!n.hasAttribute("data-lexical-sticky-scrollbar"))return null;const e=n.firstElementChild;if(!Wi(e))return null;const t=e.querySelector(":scope > table");if(!Fn(t))return null;const r=e.nextElementSibling;return Wi(r)?{scrollable:e,scrollbar:r,tableElement:t}:null}const rc=new WeakSet;function Po(n=zo()){return rc.has(n)}function oc(n=zo()){const e=Tc(n,"@lexical/table/Table");return!!e&&e.output.hasStickyScrollbar.peek()&&e.output.hasHorizontalScroll.peek()}function fu(n,e){e?rc.add(n):rc.delete(n)}class Gt extends Oe{__rowStriping=!1;__frozenColumnCount=0;__frozenRowCount=0;__colWidths=void 0;$config(){return this.config("table",{extends:Oe,importDOM:{table:()=>({conversion:JC,priority:1})}})}getColWidths(){return this.getLatest().__colWidths}setColWidths(e){const t=this.getWritable();return t.__colWidths=e,t}afterCloneFrom(e){super.afterCloneFrom(e),this.__colWidths=e.__colWidths,this.__rowStriping=e.__rowStriping,this.__frozenColumnCount=e.__frozenColumnCount,this.__frozenRowCount=e.__frozenRowCount}updateFromJSON(e){return super.updateFromJSON(e).setRowStriping(e.rowStriping||!1).setFrozenColumns(e.frozenColumnCount||0).setFrozenRows(e.frozenRowCount||0).setColWidths(e.colWidths)}exportJSON(){return{...super.exportJSON(),colWidths:this.getColWidths(),frozenColumnCount:this.__frozenColumnCount?this.__frozenColumnCount:void 0,frozenRowCount:this.__frozenRowCount?this.__frozenRowCount:void 0,rowStriping:this.__rowStriping?this.__rowStriping:void 0}}extractWithChild(e,t,r){return r==="html"}getDOMSlot(e){const t=Fn(e)?e:e.querySelector("table");return Fn(t)||X(229),super.getDOMSlot(e).withElement(t).withAfter(t.querySelector(":scope > colgroup"))}createDOM(e,t){const r=Je().createElement("table");if(this.__style&&_o(r.style,this.__style),this.getColWidths()){const o=Je().createElement("colgroup");r.appendChild(o),Rl(o)}if(Ie(r,e.theme.table),this.updateTableElement(null,r,e),Po(t)){const o=oc(t),s=(function(i,a,l){const c=Je().createElement("div"),u=a.theme.tableScrollableWrapper;return u?Ie(c,u):c.style.overflowX="auto",l&&(c.style.scrollbarWidth="none"),c.appendChild(i),c})(r,e,o);if(this.updateTableWrapper(null,s,r,e),o){const i=(function(l){const c=Je(),u=c.createElement("div"),f=l.theme.tableStickyScrollbar;f?Ie(u,f):(u.style.position="sticky",u.style.bottom="0",u.style.overflowX="scroll",u.style.overflowY="hidden"),u.style.display="none",u.setAttribute("aria-hidden","true"),u.tabIndex=-1;const d=c.createElement("div");return d.style.height="1px",d.style.width="0px",u.appendChild(d),u})(e),a=Je().createElement("div");return a.setAttribute("data-lexical-sticky-scrollbar","true"),a.appendChild(s),a.appendChild(i),Rl(i),a}return s}return r}updateTableWrapper(e,t,r,o){this.__frozenColumnCount!==(e?e.__frozenColumnCount:0)&&(function(s,i,a,l){l>0?(Ie(s,a.theme.tableFrozenColumn),i.setAttribute("data-lexical-frozen-column","true")):($t(s,a.theme.tableFrozenColumn),i.removeAttribute("data-lexical-frozen-column"))})(t,r,o,this.__frozenColumnCount),this.__frozenRowCount!==(e?e.__frozenRowCount:0)&&(function(s,i,a,l){l>0?(Ie(s,a.theme.tableFrozenRow),i.setAttribute("data-lexical-frozen-row","true")):($t(s,a.theme.tableFrozenRow),i.removeAttribute("data-lexical-frozen-row"))})(t,r,o,this.__frozenRowCount)}updateTableElement(e,t,r){this.__style!==(e?e.__style:"")&&_o(t.style,this.__style,e?e.__style:""),this.__rowStriping!==(!!e&&e.__rowStriping)&&(function(i,a,l){l?(Ie(i,a.theme.tableRowStriping),i.setAttribute("data-lexical-row-striping","true")):($t(i,a.theme.tableRowStriping),i.removeAttribute("data-lexical-row-striping"))})(t,r,this.__rowStriping);const o=e?e.getColumnCount():0,s=e?e.__colWidths:void 0;this.getColumnCount()===o&&this.getColWidths()===s||vf(t,this.getColumnCount(),this.getColWidths()),kf(t,r,this.getFormatType())}updateDOM(e,t,r){const o=kt(this,t);if(t===o===Po())return!0;if(Wi(t)){if(t.hasAttribute("data-lexical-sticky-scrollbar")!==oc())return!0;const s=o.parentElement;Wi(s)&&this.updateTableWrapper(e,s,o,r)}return this.updateTableElement(e,o,r),!1}scaleDOMColWidths(e,t){const r=this.getColWidths();r&&vf(kt(this,e),this.getColumnCount(),r.map(o=>o*t))}exportDOM(e){const t=super.exportDOM(e),{element:r}=t;return{after:o=>{if(t.after&&(o=t.after(o)),!Fn(o)&&ke(o)&&(o=o.querySelector("table")),!Fn(o))return null;kf(o,e._config,this.getFormatType());const[s]=at(this,null,null),i=new Map;for(const u of s)for(const f of u){const d=f.cell.getKey();i.has(d)||i.set(d,{colSpan:f.cell.getColSpan(),startColumn:f.startColumn})}const a=new Set;for(const u of o.querySelectorAll(":scope > tr > [data-temporary-table-cell-lexical-key]")){const f=u.getAttribute("data-temporary-table-cell-lexical-key");if(f){const d=i.get(f);if(u.removeAttribute("data-temporary-table-cell-lexical-key"),d){i.delete(f);for(let g=0;g<d.colSpan;g++)a.add(g+d.startColumn)}}}const l=o.querySelector(":scope > colgroup");if(l){const u=Array.from(o.querySelectorAll(":scope > colgroup > col")).filter((f,d)=>a.has(d));l.replaceChildren(...u)}const c=o.querySelectorAll(":scope > tr");if(c.length>0){const u=Je().createElement("tbody");for(const f of c)u.appendChild(f);o.append(u)}return o},element:!Fn(r)&&ke(r)?r.querySelector("table"):r}}canBeEmpty(){return!1}isShadowRoot(){return!0}getCordsFromCellNode(e,t){const{rows:r,domRows:o}=t;for(let s=0;s<r;s++){const i=o[s];if(i!=null)for(let a=0;a<i.length;a++){const l=i[a];if(l==null)continue;const{elem:c}=l,u=tc(this,c);if(u!==null&&e.is(u))return{x:a,y:s}}}throw new Error("Cell not found in table.")}getDOMCellFromCords(e,t,r){const{domRows:o}=r,s=o[t];if(s==null)return null;const i=s[e<s.length?e:s.length-1];return i??null}getDOMCellFromCordsOrThrow(e,t,r){const o=this.getDOMCellFromCords(e,t,r);if(!o)throw new Error("Cell not found at cords.");return o}getCellNodeFromCords(e,t,r){const o=this.getDOMCellFromCords(e,t,r);if(o==null)return null;const s=Ae(o.elem);return J(s)?s:null}getCellNodeFromCordsOrThrow(e,t,r){const o=this.getCellNodeFromCords(e,t,r);if(!o)throw new Error("Node at cords not TableCellNode.");return o}getRowStriping(){return!!this.getLatest().__rowStriping}setRowStriping(e){const t=this.getWritable();return t.__rowStriping=e,t}setFrozenColumns(e){const t=this.getWritable();return t.__frozenColumnCount=e,t}getFrozenColumns(){return this.getLatest().__frozenColumnCount}setFrozenRows(e){const t=this.getWritable();return t.__frozenRowCount=e,t}getFrozenRows(){return this.getLatest().__frozenRowCount}canSelectBefore(){return!0}canIndent(){return!1}getColumnCount(){const e=this.getFirstChild();if(!ce(e))return 0;let t=0;return e.getChildren().forEach(r=>{J(r)&&(t+=r.getColSpan())}),t}}function A_(n,e){const t=n.getElementByKey(e.getKey());return t===null&&X(230),vo(e,t)}function JC(n){const e=Ho();n.hasAttribute("data-lexical-row-striping")&&e.setRowStriping(!0),n.hasAttribute("data-lexical-frozen-column")&&e.setFrozenColumns(1),n.hasAttribute("data-lexical-frozen-row")&&e.setFrozenRows(1);const t=n.querySelector(":scope > colgroup");if(t){let r=[];for(const o of t.querySelectorAll(":scope > col")){let s=o.style.width||"";if(!Co.test(s)&&(s=o.getAttribute("width")||"",!/^\d+$/.test(s))){r=void 0;break}r.push(parseFloat(s))}r&&e.setColWidths(r)}return{after:r=>Mi(r,ce),node:e}}function Ho(){return Ot(new Gt)}function be(n){return n instanceof Gt}function qC(n){ce(n.getParent())?n.isEmpty()&&n.append(ne()):n.remove()}function VC(n){be(n.getParent())?ih(n,J):n.remove()}function YC(n){ih(n,ce);const[e]=at(n,null,null),t=e.reduce((i,a)=>Math.max(i,a.length),0),r=n.getChildren();for(let i=0;i<e.length;++i){const a=r[i];if(!a)continue;ce(a)||X(254,a.constructor.name,a.getType());const l=e[i].reduce((c,u)=>u?1+c:c,0);if(l!==t)for(let c=l;c<t;++c){const u=lt();u.append(ne()),a.append(u)}}const o=n.getColWidths(),s=n.getColumnCount();if(o&&o.length!==s){let i;if(s<o.length)i=o.slice(0,s);else if(o.length>0){const a=o[o.length-1];i=[...o,...Array(s-o.length).fill(a)]}n.setColWidths(i)}}function XC(n){if(n.detail<3||!No(n.target))return!1;const e=Ae(n.target);if(e===null)return!1;const t=re(e,r=>q(r)&&!r.isInline());return t===null?!1:!!J(t.getParent())&&(t.select(0),!0)}function GC(){const n=D();if(!F(n))return!1;const e=Or(n.anchor.getNode());if(e===null)return!1;const t=se();if(!t.is(e.getParent())||t.getChildrenSize()!==1)return!1;const[r]=at(e,null,null);if(r.length===0||r[0].length===0)return!1;const o=r[0][0];if(!o||!o.cell)return!1;const s=r[r.length-1],i=s[s.length-1];if(!i||!i.cell)return!1;const a=Ki(e,o.cell,i.cell);return Ee(a),!0}function gu(n){return n.registerNodeTransform(Xt,e=>{if(e.getColSpan()>1||e.getRowSpan()>1){const[,,t]=We(e),[r]=ct(t,e,e),o=r.length,s=r[0].length;let i=t.getFirstChild();ce(i)||X(175);const a=[];for(let l=0;l<o;l++){l!==0&&(i=i.getNextSibling(),ce(i)||X(175));let c=null;for(let u=0;u<s;u++){const f=r[l][u],d=f.cell;if(f.startRow===l&&f.startColumn===u)c=d,a.push(d);else if(d.getColSpan()>1||d.getRowSpan()>1){J(d)||X(176);const g=lt(d.__headerState);c!==null?c.insertAfter(g):Dy(i,g)}}}for(const l of a)l.setColSpan(1),l.setRowSpan(1)}})}function pu(n,e=!0){const t=new MC,r=(o,s,i)=>{const a=kt(o,i),l=E_(o,a,n,e,t);t.observers.set(s,[l,a])};return de(jC(n,t),n.registerCommand(Ht,()=>FC(t,n),qe),n.registerMutationListener(Gt,o=>{n.read("latest",()=>{for(const[s,i]of o){const a=t.observers.get(s);if(i==="created"||i==="updated"){const{tableNode:l,tableElement:c}=du(s);a===void 0?r(l,s,c):c!==a[1]&&(t.removeObserver(s),r(l,s,c))}else i==="destroyed"&&t.removeObserver(s)}})},{skipInitialization:!1}),()=>{t.removeAllObservers()})}function hu(n,e){n.hasNodes([Gt])||X(255);const{hasNestedTables:t=Ac(!1)}=e??{};return de(n.registerCommand(nu,r=>(function({rows:o,columns:s,includeHeaders:i},a){const l=D()||mo();if(!l||!F(l)||!a&&Or(l.anchor.getNode()))return!1;const c=x_(Number(o),Number(s),i);sr(c);const u=c.getFirstDescendant();return oe(u)&&u.select(),!0})(r,t.peek()),V),n.registerCommand(Py,(r,o)=>n===o&&(function(s,i){const{nodes:a,selection:l}=s;if(!a.some(f=>be(f)||jy(f).some(d=>be(d.node)))){if(ae(l)){let f="",d=!1;for(const g of a){const h=q(g)&&!g.isInline();f.length>0&&(h||d)&&(f+=`
13
+ `),f+=g.getTextContent(),d=h}return l.insertRawText(f),!0}return!1}const c=ae(l),u=F(l);return u&&re(l.anchor.getNode(),f=>J(f))!==null&&re(l.focus.getNode(),f=>J(f))!==null||c?a.length===1&&be(a[0])?k_(a[0],l):!(u&&i.peek()&&!(function(f){return!!(ae(f)&&!f.focus.getNode().is(f.anchor.getNode())||F(f)&&J(f.anchor.getNode())&&!f.anchor.getNode().is(f.focus.getNode()))})(l)):!1})(r,t),V),n.registerCommand(Ec,GC,ee),n.registerCommand(Ks,XC,V),n.registerNodeTransform(Gt,YC),n.registerNodeTransform(Wo,VC),n.registerNodeTransform(Xt,qC))}const ZC={$accepts:ce,$packageRun:n=>n.every(J)?[pn().splice(0,0,n)]:[],name:"TableSchema"},QC={$accepts:J,name:"TableRowSchema"},M_=[Ye({$import:(n,e)=>{const t=Ho();e.hasAttribute("data-lexical-row-striping")&&t.setRowStriping(!0),e.hasAttribute("data-lexical-frozen-column")&&t.setFrozenColumns(1),e.hasAttribute("data-lexical-frozen-row")&&t.setFrozenRows(1);const r=e.querySelector(":scope > colgroup");if(r){let o=[];for(const s of r.querySelectorAll(":scope > col")){let i=s.style.width||"";if(!Co.test(i)&&(i=s.getAttribute("width")||"",!/^\d+$/.test(i))){o=void 0;break}o.push(parseFloat(i))}o&&t.setColWidths(o)}return[t.splice(0,0,Mi(n.$importChildren(e),ce))]},match:Xe.tag("table"),name:"@lexical/table/table"}),Ye({$import:(n,e)=>[pn(Co.test(e.style.height)?parseFloat(e.style.height):void 0).splice(0,0,Mi(n.$importChildren(e),J))],match:Xe.tag("tr"),name:"@lexical/table/tr"}),Ye({$import:(n,e)=>{const t=e.nodeName==="TH",r=Co.test(e.style.width)?parseFloat(e.style.width):void 0;let o=te.NO_STATUS;if(t){const m=e.getAttribute("scope");if(m==="col")o=te.COLUMN;else if(m==="row")o=te.ROW;else{const b=e.parentElement,w=Hy(b)&&(b.parentElement&&b.parentElement.nodeName==="THEAD"||b.rowIndex===0),C=e.cellIndex===0;w&&(o|=te.ROW),C&&(o|=te.COLUMN),o===te.NO_STATUS&&(o=te.ROW)}}const s=lt(o,e.colSpan,r);s.__rowSpan=e.rowSpan;const i=e.style.backgroundColor;i!==""&&(s.__backgroundColor=i);const a=e.style.verticalAlign;(function(m){return m==="middle"||m==="bottom"})(a)&&(s.__verticalAlign=a);const l=n.get(Ld),c=l|(function(m){let b=0;const w=m.fontWeight;w!=="700"&&w!=="bold"||(b|=Yy),m.fontStyle==="italic"&&(b|=Jy);const C=(m.textDecoration||"").split(" ");return C.includes("underline")&&(b|=qy),C.includes("line-through")&&(b|=Vy),b})(e.style),u=n.get(Od),f=e.style.color,d=f?{...u,color:f}:u,g=[];c!==l&&g.push(Rd(Ld,c)),d!==u&&g.push(Rd(Od,d));const h=(function(m){const b=[];let w=null;const C=()=>{if(w!==null){const v=w.getFirstChild();ue(v)&&w.getChildrenSize()===1&&v.remove()}};for(const v of m)sh(v)||oe(v)||ue(v)?w!==null?w.append(v):(w=ne().append(v),b.push(w)):(C(),w=null,b.push(v));return C(),b.length===0&&b.push(ne()),b})(n.$importChildren(e,{context:g})),_=t?h:th(h,e);return[s.splice(0,0,_)]},match:Xe.tag("td","th"),name:"@lexical/table/cell"})],ma=pe({build:(n,e,t)=>nr(e),config:tr({hasCellBackgroundColor:!0,hasCellMerge:!0,hasHorizontalScroll:!0,hasNestedTables:!1,hasStickyScrollbar:!1,hasTabHandler:!0}),dependencies:[js,ln(Fs,{rules:M_})],name:"@lexical/table/Table",nodes:()=>[Gt,Wo,Xt],register(n,e,t){const r=t.getOutput();let o=!1;return de(zt(()=>{const s=r.hasHorizontalScroll.value,i=r.hasStickyScrollbar.value&&s,a=Po(n);a!==s&&fu(n,s),a===s&&o===i||n.update(ah),o=i}),hu(n,r),zt(()=>pu(n,r.hasTabHandler.value)),zt(()=>{if(r.hasStickyScrollbar.value&&r.hasHorizontalScroll.value)return n.registerRootListener(s=>{if(s)return(function(i){const a=new Map;return de(()=>{for(const{cleanup:l}of a.values())l();a.clear()},i.registerMutationListener(Gt,l=>{for(const[c,u]of l){const f=a.get(c);if(u==="destroyed"){f&&(f.cleanup(),a.delete(c));continue}const d=i.getElementByKey(c),g=d&&ke(d)?HC(d):null;f&&g&&f.parts.scrollable===g.scrollable&&f.parts.scrollbar===g.scrollbar&&f.parts.tableElement===g.tableElement?nc(g.scrollable,g.scrollbar):(f&&(f.cleanup(),a.delete(c)),g&&a.set(c,{cleanup:WC(g),parts:g}))}},{skipInitialization:!1}))})(n)})}),zt(()=>r.hasCellMerge.value?void 0:gu(n)),zt(()=>r.hasCellBackgroundColor.value?void 0:n.registerNodeTransform(Xt,s=>{s.getBackgroundColor()!==null&&s.setBackgroundColor(null)})))}}),eS=pe({dependencies:[ma],name:"@lexical/table/Import"}),Tf=Object.freeze(Object.defineProperty({__proto__:null,$computeTableCellRectBoundary:Ns,$computeTableMap:ct,$computeTableMapSkipCellCheck:at,$createTableCellNode:lt,$createTableNode:Ho,$createTableNodeWithDimensions:x_,$createTableRowNode:pn,$createTableSelection:RC,$createTableSelectionFrom:Ki,$deleteTableColumn:vC,$deleteTableColumnAtSelection:iu,$deleteTableColumn__EXPERIMENTAL:TC,$deleteTableRowAtSelection:su,$deleteTableRow__EXPERIMENTAL:kC,$findCellNode:ho,$findTableNode:Or,$getElementForTableNode:A_,$getNodeTriplet:We,$getTableAndElementByKey:du,$getTableCellNodeFromLexicalNode:Gl,$getTableCellNodeRect:Ql,$getTableColumnIndexFromTableCellNode:C_,$getTableNodeFromLexicalNodeOrThrow:ot,$getTableRowIndexFromTableCellNode:ou,$getTableRowNodeFromTableCellNodeOrThrow:ru,$insertTableColumn:CC,$insertTableColumnAtNode:zi,$insertTableColumnAtSelection:pa,$insertTableColumn__EXPERIMENTAL:SC,$insertTableRow:wC,$insertTableRowAtNode:Ui,$insertTableRowAtSelection:ga,$insertTableRow__EXPERIMENTAL:xC,$isScrollableTablesActive:Po,$isSimpleTable:uu,$isStickyScrollbarActive:oc,$isTableCellNode:J,$isTableNode:be,$isTableRowNode:ce,$isTableSelection:ae,$mergeCells:lu,$moveTableColumn:EC,$moveTableRow:NC,$removeTableRowAtIndex:yC,$setTableColumnIsHeader:OC,$setTableRowIsHeader:LC,$unmergeCell:v_,$unmergeCellNode:cu,INSERT_TABLE_COMMAND:nu,TableCellHeaderStates:te,TableCellNode:Xt,TableExtension:ma,TableImportExtension:eS,TableImportRules:M_,TableNode:Gt,TableObserver:T_,TableRowNode:Wo,TableRowSchema:QC,TableSchema:ZC,applyTableHandlers:E_,getDOMCellFromTarget:Do,getTableElement:kt,getTableObserverFromTableElement:$o,registerTableCellUnmergeTransform:gu,registerTablePlugin:hu,registerTableSelectionObserver:pu,setScrollableTablesActive:fu},Symbol.toStringTag,{value:"Module"}));function If(n,e){return n.read("latest",()=>{const t=Q(e);return t!==null&&t.isSelected()})}function _u(n){const[e]=fe(),[t,r]=S.useState(()=>If(e,n));return S.useEffect(()=>{let o=!0;const s=e.registerUpdateListener(()=>{o&&r(If(e,n))});return()=>{o=!1,s()}},[e,n]),[t,S.useCallback(o=>{e.update(()=>{let s=D();ve(s)||(s=aa(),Ee(s)),ve(s)&&(o?s.add(n):s.delete(n))})},[e,n]),S.useCallback(()=>{e.update(()=>{const o=D();ve(o)&&o.clear()})},[e])]}function tS({nodeKey:n}){const[e]=fe(),[t,r,o]=_u(n);return S.useEffect(()=>de(e.registerCommand(Ks,s=>{const i=e.getElementByKey(n);return Oo(s)===i&&(s.shiftKey||o(),r(!t),!0)},ee)),[o,e,t,n,r]),S.useEffect(()=>{const s=e.getElementByKey(n),i=e._config.theme.hrSelected??"selected";s!==null&&(t?Ie(s,i):$t(s,i))},[e,t,n]),null}class mu extends Xy{$config(){return this.config("horizontalrule",{importDOM:{hr:()=>({conversion:nS,priority:0})}})}decorate(){return x.jsx(tS,{nodeKey:this.__key})}}function nS(){return{node:ba()}}function ba(){return Ot(new mu)}function rS({equation:n,inline:e,nodeKey:t}){const[r]=fe(),[o,s]=S.useState(n),[i,a]=S.useState(!1),l=S.useRef(null),c=S.useCallback(u=>{a(!1),r.update(()=>{const f=Q(t);Rr(f)&&(f.setEquation(o),u&&f.selectNext(0,0))})},[r,o,t]);return S.useEffect(()=>{!i&&o!==n&&s(n)},[i,n,o]),S.useEffect(()=>i?de(r.registerCommand(Ht,u=>{const f=document.activeElement;return l.current!==f&&c(),!1},qe),r.registerCommand(Nn,u=>{const f=document.activeElement;return l.current===f?(c(!0),!0):!1},qe)):r.registerUpdateListener(({editorState:u})=>{u.read(()=>{const d=D();return ve(d)&&d.has(t)&&d.getNodes().length===1})&&a(!0)}),[r,t,c,i]),x.jsx(x.Fragment,{children:i?x.jsx(Kx,{equation:o,setEquation:s,inline:e,inputRef:l}):x.jsx(Fh,{equation:o,inline:e,onClick:()=>{a(!0)}})})}class ir extends Bt{__equation;__inline;static getType(){return"equation"}static clone(e){return new ir(e.__equation,e.__inline,e.__key)}constructor(e,t,r){super(r),this.__equation=e,this.__inline=t??!1}static importJSON(e){return ya(e.equation,e.inline)}exportJSON(){return{equation:this.getEquation(),inline:this.__inline,type:"equation",version:1}}createDOM(e){return document.createElement(this.__inline?"span":"div")}updateDOM(e){return this.__inline!==e.__inline}getEquation(){return this.__equation}setEquation(e){const t=this.getWritable();t.__equation=e}decorate(){return x.jsx(rS,{equation:this.__equation,inline:this.__inline,nodeKey:this.__key})}}function ya(n="",e=!1){return new ir(n,e)}function Rr(n){return n instanceof ir}function oS({defaultSelection:n}){const[e]=fe();return S.useEffect(()=>{e.focus(()=>{const t=e.getRootElement(),r=t!==null?la(t):null;t===null||r!==null&&t.contains(r)||t.focus({preventScroll:!0})},{defaultSelection:n})},[n,e]),null}class wa extends cn{$config(){return this.config("hashtag",{extends:cn})}createDOM(e){const t=super.createDOM(e);return Ie(t,e.theme.hashtag),t}canInsertTextBefore(){return!1}isTextEntity(){return!0}}function sS(n=""){return Ot(new wa(n))}const iS=new RegExp((function(){const{alpha:n,alphanumeric:e,hashChars:t}=(function(){const o=String.fromCharCode,s="A-Za-zªµºÀ-ÖØ-öø-Ɂɐ-ˁˆ-ˑˠ-ˤˮͺΆΈ-ΊΌΎ-ΡΣ-ώϐ-ϵϷ-ҁҊ-ӎӐ-ӹԀ-ԏԱ-Ֆՙա-ևא-תװ-ײء-غـ-يٮ-ٯٱ-ۓەۥ-ۦۮ-ۯۺ-ۼۿܐܒ-ܯݍ-ݭހ-ޥޱऄ-हऽॐक़-ॡॽঅ-ঌএ-ঐও-নপ-রলশ-হঽৎড়-ঢ়য়-ৡৰ-ৱਅ-ਊਏ-ਐਓ-ਨਪ-ਰਲ-ਲ਼ਵ-ਸ਼ਸ-ਹਖ਼-ੜਫ਼ੲ-ੴઅ-ઍએ-ઑઓ-નપ-રલ-ળવ-હઽૐૠ-ૡଅ-ଌଏ-ଐଓ-ନପ-ରଲ-ଳଵ-ହଽଡ଼-ଢ଼ୟ-ୡୱஃஅ-ஊஎ-ஐஒ-கங-சஜஞ-டண-தந-பம-ஹఅ-ఌఎ-ఐఒ-నప-ళవ-హౠ-ౡಅ-ಌಎ-ಐಒ-ನಪ-ಳವ-ಹಽೞೠ-ೡഅ-ഌഎ-ഐഒ-നപ-ഹൠ-ൡඅ-ඖක-නඳ-රලව-ෆก-ะา-ำเ-ๆກ-ຂຄງ-ຈຊຍດ-ທນ-ຟມ-ຣລວສ-ຫອ-ະາ-ຳຽເ-ໄໆໜ-ໝༀཀ-ཇཉ-ཪྈ-ྋက-အဣ-ဧဩ-ဪၐ-ၕႠ-Ⴥა-ჺჼᄀ-ᅙᅟ-ᆢᆨ-ᇹሀ-ቈቊ-ቍቐ-ቖቘቚ-ቝበ-ኈኊ-ኍነ-ኰኲ-ኵኸ-ኾዀዂ-ዅወ-ዖዘ-ጐጒ-ጕጘ-ፚᎀ-ᎏᎠ-Ᏼᐁ-ᙬᙯ-ᙶᚁ-ᚚᚠ-ᛪᜀ-ᜌᜎ-ᜑᜠ-ᜱᝀ-ᝑᝠ-ᝬᝮ-ᝰក-ឳៗៜᠠ-ᡷᢀ-ᢨᤀ-ᤜᥐ-ᥭᥰ-ᥴᦀ-ᦩᧁ-ᧇᨀ-ᨖᴀ-ᶿḀ-ẛẠ-ỹἀ-ἕἘ-Ἕἠ-ὅὈ-Ὅὐ-ὗὙὛὝὟ-ώᾀ-ᾴᾶ-ᾼιῂ-ῄῆ-ῌῐ-ΐῖ-Ίῠ-Ῥῲ-ῴῶ-ῼⁱⁿₐ-ₔℂℇℊ-ℓℕℙ-ℝℤΩℨK-ℭℯ-ℱℳ-ℹℼ-ℿⅅ-ⅉⰀ-Ⱞⰰ-ⱞⲀ-ⳤⴀ-ⴥⴰ-ⵥⵯⶀ-ⶖⶠ-ⶦⶨ-ⶮⶰ-ⶶⶸ-ⶾⷀ-ⷆⷈ-ⷎⷐ-ⷖⷘ-ⷞ々-〆〱-〵〻-〼ぁ-ゖゝ-ゟァ-ヺー-ヿㄅ-ㄬㄱ-ㆎㆠ-ㆷㇰ-ㇿ㐀-䶵一-龻ꀀ-ꒌꠀ-ꠁꠃ-ꠅꠇ-ꠊꠌ-ꠢ가-힣豈-鶴侮-頻並-龎ff-stﬓ-ﬗיִײַ-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼA-Za-zヲ-하-ᅦᅧ-ᅬᅭ-ᅲᅳ-ᅵÀ-ÖØ-öø-ÿĀ-ɏɓ-ɔɖ-ɗəɛɣɨɯɲʉʋʻ̀-ͯḀ-ỿЀ-ӿԀ-ԧⷠ-ⷿꙀ-֑ꚟ-ֿׁ-ׂׄ-ׇׅא-תװ-״﬒-ﬨשׁ-זּטּ-לּמּנּ-סּףּ-פּצּ-ﭏؐ-ؚؠ-ٟٮ-ۓە-ۜ۞-۪ۨ-ۯۺ-ۼۿݐ-ݿࢠࢢ-ࢬࣤ-ࣾﭐ-ﮱﯓ-ﴽﵐ-ﶏﶒ-ﷇﷰ-ﷻﹰ-ﹴﹶ-ﻼ‌-‌ก-ฺเ-๎ᄀ-ᇿ㄰-ㆅꥠ-꥿가-힯ힰ-퟿ᄀ-ᅵァ-ヺー-ヾヲ-゚0-9A-Za-zぁ-ゖ゙-ゞ㐀-䶿一-鿿"+o(173824)+"-"+o(177983)+o(177984)+"-"+o(178207)+o(194560)+"-"+o(195103)+"〃々〻";return{alpha:s,alphanumeric:s+"̀-ͯ҃-֑҆-ֹֻ-ֽֿׁ-ׂׄ-ׇׅؐ-ًؕ-ٰٞۖ-ۜ۟-ۤۧ-۪ۨ-ܑۭܰ-݊ަ-ްँ-ः़ा-्॑-॔ॢ-ॣঁ-ঃ়া-ৄে-ৈো-্ৗৢ-ৣਁ-ਃ਼ਾ-ੂੇ-ੈੋ-੍ੰ-ੱઁ-ઃ઼ા-ૅે-ૉો-્ૢ-ૣଁ-ଃ଼ା-ୃେ-ୈୋ-୍ୖ-ୗஂா-ூெ-ைொ-்ௗఁ-ఃా-ౄె-ైొ-్ౕ-ౖಂ-ಃ಼ಾ-ೄೆ-ೈೊ-್ೕ-ೖം-ഃാ-ൃെ-ൈൊ-്ൗං-ඃ්ා-ුූෘ-ෟෲ-ෳัิ-ฺ็-๎ັິ-ູົ-ຼ່-ໍ༘-༹༙༵༷༾-༿ཱ-྄྆-྇ྐ-ྗྙ-ྼ࿆ာ-ဲံ-္ၖ-ၙ፟ᜒ-᜔ᜲ-᜴ᝒ-ᝓᝲ-ᝳា-៓៝᠋-᠍ᢩᤠ-ᤫᤰ-᤻ᦰ-ᧀᧈ-ᧉᨗ-ᨛ᷀-᷃⃐-⃥⃜⃡-⃫〪-゙〯-゚ꠂ꠆ꠋꠣ-ꠧﬞ︀-️︠-︣0-9٠-٩۰-۹०-९০-৯੦-੯૦-૯୦-୯௦-௯౦-౯೦-೯൦-൯๐-๙໐-໙༠-༩၀-၉០-៩᠐-᠙᥆-᥏᧐-᧙0-9_",hashChars:"#\\uFF03"}})(),r="["+e+"]";return"("+("^|$|[^&/"+e+"]")+")("+("["+t+"]")+")("+r+"*"+("["+n+"]")+r+"*)"})(),"i"),$_={getHashtagMatch:function(n){const e=iS.exec(n);if(e===null)return null;const t=e[3].length+1,r=e.index+e[1].length;return{end:r+t,start:r}}};function D_(n,e=$_){return de(...Gy(n,e.getHashtagMatch,wa,t=>sS(t.getTextContent())))}const aS=pe({config:$_,name:"@lexical/hashtag/Hashtag",nodes:()=>[wa],register:D_});function lS(){const[n]=fe();return S.useEffect(()=>{if(!n.hasNodes([wa]))throw new Error("HashtagPlugin: HashtagNode not registered on editor");return D_(n)},[n]),null}function cS({delay:n,externalHistoryState:e}){const[t]=fe();return(function(r,o,s=1e3){const i=S.useMemo(()=>o||Zy(),[o]);S.useEffect(()=>Qy(r,i,s),[s,r,i])})(t,e,n),null}function uS({validateUrl:n,attributes:e}){const[t]=fe();return S.useEffect(()=>{if(!t.hasNodes([gn]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),S.useEffect(()=>h_(t,nr({attributes:e,validateUrl:n})),[t,n,e]),null}const Ef=[["Cat","rgb(125, 50, 0)"],["Dog","rgb(100, 0, 0)"],["Rabbit","rgb(150, 0, 0)"],["Frog","rgb(200, 0, 0)"],["Fox","rgb(200, 75, 0)"],["Hedgehog","rgb(0, 75, 0)"],["Pigeon","rgb(0, 125, 0)"],["Squirrel","rgb(75, 100, 0)"],["Bear","rgb(125, 100, 0)"],["Tiger","rgb(0, 0, 150)"],["Leopard","rgb(0, 0, 200)"],["Zebra","rgb(0, 0, 250)"],["Wolf","rgb(0, 100, 150)"],["Owl","rgb(0, 100, 100)"],["Gull","rgb(100, 0, 100)"],["Squid","rgb(150, 0, 150)"]],Nf=Ef[Math.floor(Math.random()*Ef.length)],dS=S.createContext(null);function fS(){return{color:Nf[1],isCollabActive:!1,name:Nf[0],yjsDocMap:new Map}}fS();function gS({initialEditor:n,children:e,initialNodes:t,initialTheme:r,skipCollabChecks:o,skipEditableListener:s}){const i=S.useRef(!1),a=S.useContext(Ad);a==null&&(function(_,...m){const b=new URL("https://lexical.dev/docs/error"),w=new URLSearchParams;w.append("code",_);for(const C of m)w.append("v",C);throw b.search=w.toString(),Error(`Minified Lexical error #${_}; visit ${b.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)})(9);const[l,{getTheme:c}]=a,u=S.useMemo(()=>{const _=r||c()||void 0,m=ew(a,_);_!==void 0&&(n._config.theme=_),n._parentEditor=n._parentEditor||l;const b=n._createEditorArgs,w=b&&b.namespace;if(t){w||(n._config.namespace=l._config.namespace);for(let C of t){let v=null,k=null;if(typeof C!="function"){const E=C;C=E.replace,v=E.with,k=E.withKlass||null}const I=tw(n,C.getType());n._nodes.set(C.getType(),{exportDOM:I?I.exportDOM:void 0,klass:C,replace:v,replaceWithKlass:k,sharedNodeState:$d(C),transforms:Md(C)})}}else if(b&&b.nodes)w||(n._config.namespace=l._config.namespace);else{const C=n._nodes=new Map(l._nodes);w||(n._config.namespace=l._config.namespace);for(const[v,k]of C)n._nodes.set(v,{exportDOM:k.exportDOM,klass:k.klass,replace:k.replace,replaceWithKlass:k.replaceWithKlass,sharedNodeState:$d(k.klass),transforms:Md(k.klass)})}return[n,m]},[]),f=S.useContext(dS),{isCollabActive:d,yjsDocMap:g}=f??{},h=o||i.current||g&&g.has(n.getKey());return S.useEffect(()=>{h&&(i.current=!0)},[h]),S.useEffect(()=>{if(!s){const _=m=>n.setEditable(m);return _(l.isEditable()),l.registerEditableListener(_)}},[n,l,s]),x.jsx(Ad.Provider,{value:u,children:!d||h?e:null})}const pS=qn?S.useLayoutEffect:S.useEffect;function hS(n){return{initialValueFn:()=>n.isEditable(),subscribe:e=>n.registerEditableListener(e)}}function Hr(){return(function(n){const[e]=fe(),t=S.useMemo(()=>n(e),[e,n]),[r,o]=S.useState(()=>t.initialValueFn()),s=S.useRef(r);return pS(()=>{const{initialValueFn:i,subscribe:a}=t,l=i();return s.current!==l&&(s.current=l,o(l)),a(c=>{s.current=c,o(c)})},[t,n]),r})(hS)}function _S(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}const bu=qn?S.useLayoutEffect:S.useEffect;function mS({editor:n,ErrorBoundary:e}){return(function(t,r){const[o,s]=S.useState(()=>t.getDecorators());return bu(()=>t.registerDecoratorListener(i=>{St.flushSync(()=>{s(i)})}),[t]),S.useEffect(()=>{s(t.getDecorators())},[t]),S.useMemo(()=>{const i=[],a=Object.keys(o);for(let l=0;l<a.length;l++){const c=a[l],u=x.jsx(r,{onError:d=>t._onError(d),children:x.jsx(S.Suspense,{fallback:null,children:o[c]})}),f=t.getElementByKey(c);f!==null&&i.push(St.createPortal(u,f,c))}return i},[r,o,t])})(n,e)}function bS({editor:n,ErrorBoundary:e}){return(function(t){const r=rw.maybeFromEditor(t);if(r&&r.hasExtensionByName(ow.name)){for(const o of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(o)&&_S(320,o);return!0}return!1})(n)?null:x.jsx(mS,{editor:n,ErrorBoundary:e})}function Lf(n){return n.read("latest",sw(n.isComposing()))}function yS({contentEditable:n,placeholder:e=null,ErrorBoundary:t}){const[r]=fe();return(function(o){bu(()=>de(i_(o),nw(o)),[o])})(r),x.jsxs(x.Fragment,{children:[n,x.jsx(wS,{content:e}),x.jsx(bS,{editor:r,ErrorBoundary:t})]})}function wS({content:n}){const[e]=fe(),t=(function(o){const[s,i]=S.useState(()=>Lf(o));return bu(()=>{function a(){const l=Lf(o);i(l)}return a(),de(o.registerUpdateListener(()=>{a()}),o.registerEditableListener(()=>{a()}))},[o]),s})(e),r=Hr();return t?typeof n=="function"?n(r):n:null}function P_({hasCellMerge:n=!0,hasCellBackgroundColor:e=!0,hasTabHandler:t=!0,hasHorizontalScroll:r=!1,hasNestedTables:o=!1}){const[s]=fe();S.useEffect(()=>{Po(s)!==r&&(fu(s,r),s.update(ah))},[s,r]);const i=(function(a){const[l]=S.useState(()=>Ac(a));return l.peek()!==a&&(l.value=a),l})(o);return S.useEffect(()=>hu(s,{hasNestedTables:i}),[s,i]),S.useEffect(()=>pu(s,t),[s,t]),S.useEffect(()=>{if(!n)return gu(s)},[s,n]),S.useEffect(()=>{if(!e)return s.registerNodeTransform(Xt,a=>{a.getBackgroundColor()!==null&&a.setBackgroundColor(null)})},[s,e,n]),null}const xS="Gc7131jiJuvI7IdN0HZ1D7nh0ow5BU6g",CS=`https://api.giphy.com/v1/gifs/trending?api_key=${xS}&limit=50&rating=g`;async function yu(){try{const t=(await(await fetch(CS)).json())?.data;if(!Array.isArray(t)||t.length===0)return null;const r=t[Math.floor(Math.random()*t.length)],o=r.images?.downsized_medium?.url||r.images?.original?.url||r.images?.fixed_height?.url;return o?{altText:r.title||"Random GIF",src:o}:null}catch{return null}}const j_=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u",Ys=he("INSERT_IMAGE_COMMAND"),SS=n=>j_?(n||window).getSelection():null;function F_(n){if(!n.hasNodes([Jr]))throw new Error("ImagesPlugin: ImageNode not registered on editor");return de(n.registerCommand(Ys,e=>{const t=xa(e);return Tr([t]),wt(t.getParentOrThrow())&&Fc(t,ne).selectEnd(),!0},V),n.registerCommand(Wp,e=>TS(e),qe),n.registerCommand(Nc,e=>IS(e),ee),n.registerCommand(Lc,e=>ES(e,n),qe))}const B_=pe({name:"@datalayer/jupyter-lexical/Images",nodes:()=>[Jr],register:F_}),vS="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7";let di=null;function kS(){return di===null&&(di=document.createElement("img"),di.src=vS),di}function TS(n){const e=wu();if(!e)return!1;const t=n.dataTransfer;return t?(t.setData("text/plain","_"),t.setDragImage(kS(),0,0),t.setData("application/x-lexical-drag",JSON.stringify({data:{altText:e.__altText,caption:e.__caption,height:e.__height,key:e.getKey(),maxWidth:e.__maxWidth,showCaption:e.__showCaption,src:e.__src,width:e.__width},type:"image"})),!0):!1}function IS(n){return wu()?(U_(n)||n.preventDefault(),!0):!1}function ES(n,e){const t=wu();if(!t)return!1;const r=NS(n);if(!r)return!1;if(n.preventDefault(),U_(n)){const o=LS(n);t.remove();const s=kr();o!=null&&s.applyDOMRange(o),Ee(s),e.dispatchCommand(Ys,r)}return!0}function wu(){const n=D();if(!ve(n))return null;const t=n.getNodes()[0];return Hn(t)?t:null}function NS(n){const e=n.dataTransfer?.getData("application/x-lexical-drag");if(!e)return null;const{type:t,data:r}=JSON.parse(e);return t!=="image"?null:r}function U_(n){const e=n.target;return!!(e&&e instanceof HTMLElement&&!e.closest("code, span.editor-image")&&e.parentElement&&e.parentElement.closest("div.ContentEditable__root"))}function LS(n){let e;const t=n.target,r=t==null?null:t.nodeType===9?t.defaultView:t.ownerDocument.defaultView,o=SS(r);if(document.caretRangeFromPoint)e=document.caretRangeFromPoint(n.clientX,n.clientY);else if(n.rangeParent&&o!==null)o.collapse(n.rangeParent,n.rangeOffset||0),e=o.getRangeAt(0);else throw Error("Cannot get the selection when dragging");return e}function OS({children:n}){return x.jsx(Y,{sx:{display:"flex",flexDirection:"column",gap:2,mt:3},children:n})}function xu({"data-test-id":n,children:e}){return x.jsx(Y,{sx:{display:"flex",flexDirection:"row",justifyContent:"flex-end",gap:2,mt:3},"data-test-id":n,children:e})}function RS({onClick:n}){const[e,t]=S.useState(""),[r,o]=S.useState(""),s=e==="";return x.jsxs(x.Fragment,{children:[x.jsx(Kl,{label:"Image URL",placeholder:"i.e. https://source.unsplash.com/random",onChange:t,value:e,"data-test-id":"image-modal-url-input"}),x.jsx(Kl,{label:"Alt Text",placeholder:"Random unsplash image",onChange:o,value:r,"data-test-id":"image-modal-alt-text-input"}),x.jsx(xu,{children:x.jsx(xr,{"data-test-id":"image-modal-confirm-btn",disabled:s,onClick:()=>n({altText:r,src:e}),children:"Confirm"})})]})}function AS({onClick:n}){const[e,t]=S.useState(""),[r,o]=S.useState(""),s=e==="",i=a=>{const l=new FileReader;l.onload=function(){return typeof l.result=="string"&&t(l.result),""},a!==null&&l.readAsDataURL(a[0])};return x.jsxs(x.Fragment,{children:[x.jsx(Jx,{label:"Image Upload",onChange:i,accept:"image/*","data-test-id":"image-modal-file-upload"}),x.jsx(Kl,{label:"Alt Text",placeholder:"Descriptive alternative text",onChange:o,value:r,"data-test-id":"image-modal-alt-text-input"}),x.jsx(xu,{children:x.jsx(xr,{"data-test-id":"image-modal-file-upload-btn",disabled:s,onClick:()=>n({altText:r,src:e}),children:"Confirm"})})]})}function z_({activeEditor:n,onClose:e}){const[t,r]=S.useState(null),o=S.useRef(!1);S.useEffect(()=>{o.current=!1;const i=a=>{o.current=a.altKey};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[n]);const s=i=>{n.dispatchCommand(Ys,i),e()};return x.jsxs(x.Fragment,{children:[!t&&x.jsxs(OS,{children:[x.jsx(xr,{"data-test-id":"image-modal-option-sample",onClick:()=>{yu().then(i=>{i&&s(i)})},children:"Sample"}),x.jsx(xr,{"data-test-id":"image-modal-option-url",onClick:()=>r("url"),children:"URL"}),x.jsx(xr,{"data-test-id":"image-modal-option-file",onClick:()=>r("file"),children:"File"})]}),t==="url"&&x.jsx(RS,{onClick:s}),t==="file"&&x.jsx(AS,{onClick:s})]})}const MS=({captionsEnabled:n})=>{const[e]=fe();return S.useEffect(()=>F_(e),[e]),null},Of=new Set;function $S(n){if(!Of.has(n))throw new Promise(e=>{const t=new Image;t.src=n,t.onload=()=>{Of.add(n),e(null)}})}function DS(n){if(n instanceof HTMLImageElement){const{alt:e,src:t}=n;return{node:xa({altText:e,src:t})}}return null}function PS({altText:n,className:e,imageRef:t,src:r,width:o,height:s,maxWidth:i}){return $S(r),x.jsx("img",{className:e||void 0,src:r,alt:n,ref:t,style:{height:s,maxWidth:i,width:o},draggable:"false"})}function jS({src:n,altText:e,nodeKey:t,width:r,height:o,maxWidth:s,resizable:i,showCaption:a,caption:l}){const c=S.useRef(null),u=S.useRef(null),[f,d,g]=_u(t),[h,_]=S.useState(!1),[m]=fe(),[b]=S.useState(null),w=S.useRef(null),C=S.useCallback(R=>{if(f&&ve(D())){R.preventDefault();const L=Q(t);Hn(L)&&L.remove(),d(!1)}return!1},[f,t,d]),v=S.useCallback(R=>{const $=D(),L=u.current;if(f&&ve($)&&$.getNodes().length===1){if(a)return Ee(null),R.preventDefault(),l.focus(),!0;if(L!==null&&L!==document.activeElement)return R.preventDefault(),L.focus(),!0}return!1},[l,f,a]),k=S.useCallback(R=>w.current===l||u.current===R.target?(Ee(null),m.update(()=>{const $=aa();$.add(t);const L=m.getRootElement();L!==null&&L.focus(),Ee($)}),!0):!1,[l,m,t]);S.useEffect(()=>de(m.registerUpdateListener(({editorState:R})=>{}),m.registerCommand(Ht,(R,$)=>(w.current=$,!1),ee),m.registerCommand(Ks,R=>{const $=R;return h?!0:$.target===c.current?($.shiftKey||g(),d(!f),!0):!1},ee),m.registerCommand(Oc,C,ee),m.registerCommand(sa,C,ee),m.registerCommand(zr,v,ee),m.registerCommand(Nn,k,ee)),[g,m,h,f,t,C,v,k,d]);const I=()=>{m.update(()=>{const R=Q(t);Hn(R)&&R.setShowCaption(!0)})},E=(R,$)=>{setTimeout(()=>{_(!1)},200),m.update(()=>{const L=Q(t);Hn(L)&&L.setWidthAndHeight(R,$)})},N=()=>{_(!0)},O=f&&ve(b),M=f||h;return x.jsx(S.Suspense,{fallback:null,children:x.jsxs(x.Fragment,{children:[x.jsx("div",{draggable:O,children:x.jsx(PS,{className:M?`focused ${ve(b)?"draggable":""}`:null,src:n,altText:e,imageRef:c,width:r,height:o,maxWidth:s})}),a&&x.jsx("div",{className:"image-caption-container",children:x.jsxs(gS,{initialEditor:l,children:[x.jsx(oS,{}),x.jsx(P_,{}),x.jsx(MS,{}),x.jsx(uS,{}),x.jsx(lS,{}),x.jsx(cS,{}),x.jsx(yS,{contentEditable:x.jsx(zx,{className:"ImageNode__contentEditable"}),placeholder:x.jsx(Bh,{className:"ImageNode__placeholder",children:"Enter a caption..."}),ErrorBoundary:aw})]})}),i&&ve(b)&&M&&x.jsx(qx,{showCaption:a,setShowCaption:I,editor:m,buttonRef:u,imageRef:c,maxWidth:s,onResizeStart:N,onResizeEnd:E})]})})}class Jr extends Bt{__src;__altText;__width;__height;__maxWidth;__showCaption;__caption;static getType(){return"image"}static clone(e){return new Jr(e.__src,e.__altText,e.__maxWidth,e.__width,e.__height,e.__showCaption,e.__caption,e.__key)}static importJSON(e){const{altText:t,height:r,width:o,maxWidth:s,caption:i,src:a,showCaption:l}=e,c=xa({altText:t,height:r,maxWidth:s,showCaption:l,src:a,width:o}),u=c.__caption,f=u.parseEditorState(i.editorState);return f.isEmpty()||u.setEditorState(f),c}exportDOM(){const e=document.createElement("img");return e.setAttribute("src",this.__src),e.setAttribute("alt",this.__altText),{element:e}}static importDOM(){return{img:e=>({conversion:DS,priority:0})}}constructor(e,t,r,o,s,i,a,l){super(l),this.__src=e,this.__altText=t,this.__maxWidth=r,this.__width=o||"inherit",this.__height=s||"inherit",this.__showCaption=i||!1,this.__caption=a||iw()}exportJSON(){return{altText:this.getAltText(),caption:this.__caption.toJSON(),height:this.__height==="inherit"?0:this.__height,maxWidth:this.__maxWidth,showCaption:this.__showCaption,src:this.getSrc(),type:"image",version:1,width:this.__width==="inherit"?0:this.__width}}setWidthAndHeight(e,t){const r=this.getWritable();r.__width=e,r.__height=t}setShowCaption(e){const t=this.getWritable();t.__showCaption=e}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}getSrc(){return this.__src}getAltText(){return this.__altText}decorate(){return x.jsx(jS,{src:this.__src,altText:this.__altText,width:this.__width,height:this.__height,maxWidth:this.__maxWidth,nodeKey:this.getKey(),showCaption:this.__showCaption,caption:this.__caption,resizable:!0})}}function xa({altText:n,height:e,maxWidth:t=500,src:r,width:o,showCaption:s,caption:i,key:a}){return new Jr(r,n,t,o,e,s,i,a)}function Hn(n){return n instanceof Jr}class Jo extends Bt{__format;constructor(e,t){super(t),this.__format=e||""}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format}exportJSON(){return{...super.exportJSON(),format:this.__format||""}}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format||"")}canIndent(){return!1}createDOM(){return Je().createElement("div")}updateDOM(){return!1}setFormat(e){const t=this.getWritable();return t.__format=e,t}getFormat(){return this.getLatest().__format}isInline(){return!1}}function sc(n){return n instanceof Jo}function Ls({children:n,format:e,nodeKey:t,className:r}){const[o]=fe(),[s,i,a]=_u(t),l=S.useRef(null);return S.useEffect(()=>de(o.registerCommand(Bn,c=>{if(s){const u=D();if(ve(u)){const f=Q(t);sc(f)&&f.setFormat(c)}else if(F(u)){const f=u.getNodes();for(const d of f)sc(d)?d.setFormat(c):Rc(d).setFormat(c)}return!0}return!1},ee),o.registerCommand(Ks,c=>Oo(c)===l.current&&(c.preventDefault(),c.shiftKey||a(),i(!s),!0),ee)),[a,o,s,t,i]),x.jsx("div",{className:[r.base,s?r.focus:null].filter(Boolean).join(" "),ref:l,style:{textAlign:e||void 0},children:n})}function FS({videoID:n,onClick:e}){const[t,r]=S.useState(`https://img.youtube.com/vi/${n}/maxresdefault.jpg`);return S.useEffect(()=>{const o=new Image;o.onload=()=>{o.width===120&&o.height===90&&r(`https://img.youtube.com/vi/${n}/mqdefault.jpg`)},o.src=t},[n,t]),x.jsxs("div",{onClick:e,style:{position:"relative",width:"560px",height:"315px",cursor:"pointer",backgroundColor:"#000",display:"flex",alignItems:"center",justifyContent:"center"},children:[x.jsx("img",{src:t,alt:"YouTube video thumbnail",style:{width:"100%",height:"100%",objectFit:"cover"}}),x.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",width:"68px",height:"48px",backgroundColor:"rgba(255, 0, 0, 0.8)",borderRadius:"8px",display:"flex",alignItems:"center",justifyContent:"center",transition:"background-color 0.2s"},onMouseEnter:o=>{o.currentTarget.style.backgroundColor="rgba(255, 0, 0, 1)"},onMouseLeave:o=>{o.currentTarget.style.backgroundColor="rgba(255, 0, 0, 0.8)"},children:x.jsx("div",{style:{width:0,height:0,borderLeft:"20px solid white",borderTop:"12px solid transparent",borderBottom:"12px solid transparent",marginLeft:"4px"}})})]})}function BS({className:n,format:e,nodeKey:t,videoID:r}){const{onYouTubeClick:o}=R0();return o?x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx(FS,{videoID:r,onClick:()=>o(r)})}):x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx("iframe",{width:"560",height:"315",src:`https://www.youtube.com/embed/${r}`,frameBorder:"0",allow:"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",allowFullScreen:!0,title:"YouTube video"})})}class qo extends Jo{__id;static getType(){return"youtube"}static clone(e){return new qo(e.__id,e.__format,e.__key)}static importJSON(e){const t=K_(e.videoID);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"youtube",version:1,videoID:this.__id}}constructor(e,t,r){super(t,r),this.__id=e}updateDOM(){return!1}getId(){return this.__id}decorate(e,t){const r=t.theme.embedBlock||{},o={base:r.base||"",focus:r.focus||""};return x.jsx(BS,{className:o,format:this.__format,nodeKey:this.getKey(),videoID:this.__id})}isTopLevel(){return!0}}function K_(n){return new qo(n)}function W_(n){return n instanceof qo}const wi="python",US={c:"C",clike:"C-like",css:"CSS",html:"HTML",js:"JavaScript",markdown:"Markdown",objc:"Objective-C",plain:"Plain Text",py:"Python",rust:"Rust",sql:"SQL",swift:"Swift",xml:"XML"},zS={javascript:"js",md:"markdown",plaintext:"plain",python:"py",text:"plain"};function KS(n){return zS[n]||n}function jM(n){const e=KS(n);return US[e]||e}const FM=()=>wi,BM=()=>Object.keys(Pl.languages).filter(n=>typeof Pl.languages[n]!="function").sort();class Ar extends cn{__highlightType;constructor(e,t,r){super(e,r),this.__highlightType=t}static getType(){return"jupyter-input-highlight"}static clone(e){return new Ar(e.__text,e.__highlightType||void 0,e.__key)}getHighlightType(){return this.getLatest().__highlightType}createDOM(e){const t=super.createDOM(e),r=qa(e.theme,this.__highlightType);return Ie(t,r),this.__highlightType&&t.classList.add("token",this.__highlightType),t}updateDOM(e,t,r){const o=super.updateDOM(e,t,r),s=qa(r.theme,e.__highlightType),i=qa(r.theme,this.__highlightType);return s!==i&&(s&&$t(t,s),i&&Ie(t,i)),e.__highlightType!==this.__highlightType&&(e.__highlightType&&t.classList.remove("token",e.__highlightType),this.__highlightType?t.classList.add("token",this.__highlightType):t.classList.remove("token")),o}static importJSON(e){const t=Sr(e.text,e.highlightType);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),highlightType:this.getHighlightType(),type:"jupyter-input-highlight",version:1}}setFormat(e){return this}}function qa(n,e){return e&&n&&n.codeHighlight&&n.codeHighlight[e]}function Sr(n,e){return new Ar(n,e)}function tt(n){return n instanceof Ar}function Hi(n){let e=null;const t=n.getPreviousSiblings();for(t.push(n);t.length>0;){const r=t.pop();if(tt(r)&&(e=r),ue(r))break}return e}function Rf(n){let e=null;const t=n.getNextSiblings();for(t.unshift(n);t.length>0;){const r=t.shift();if(tt(r)&&(e=r),ue(r))break}return e}function WS(){return{output_type:"stream",name:"stderr",text:[`⚠️ No runtime connected. Please connect to a runtime to execute code.
14
14
  `]}}function Af(n){return n===" "||n===" "}function Ji(n,e){const t=n.length;let r=-1;if(e)for(let o=0;o<t;o++){const s=n[o];if(!Af(s)){r=o;break}}else for(let o=t-1;o>-1;o--){const s=n[o];if(!Af(s)){r=o;break}}return r}function HS(n){let e=null,t=-1;const r=n.getPreviousSiblings();for(r.push(n);r.length>0;){const o=r.pop();if(tt(o)){const s=o.getTextContent(),i=Ji(s,!0);i!==-1&&(e=o,t=i)}if(ue(o))break}if(e===null){const o=n.getNextSiblings();for(;o.length>0;){const s=o.shift();if(tt(s)){const i=s.getTextContent(),a=Ji(i,!0);if(a!==-1){e=s,t=a;break}}if(ue(s))break}}return{node:e,offset:t}}function JS(n){let e=null,t=-1;const r=n.getNextSiblings();for(r.unshift(n);r.length>0;){const o=r.shift();if(tt(o)){const s=o.getTextContent(),i=Ji(s,!1);i!==-1&&(e=o,t=i+1)}if(ue(o))break}if(e===null){const o=n.getPreviousSiblings();for(;o.length>0;){const s=o.pop();if(tt(s)){const i=s.getTextContent(),a=Ji(i,!1);if(a!==-1){e=s,t=a+1;break}}if(ue(s))break}}return{node:e,offset:t}}function Mf(n,e){const t=n.getParent();t&&st(t)?H_(t,e):tt(n)&&n.replace($e(n.__text))}function qS(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
15
15
  `+ ++i);t.setAttribute("data-gutter",s)}let Va=!1;function H_(n,e){Va||(Va=!0,n.getLanguage()===void 0&&n.setLanguage(wi),e.update(()=>{VS(n,()=>{const t=n.getTextContent(),r=globalThis.Prism||Pl,o=n.getLanguage()||wi,s=r?.languages?.[o]||r?.languages?.[wi],i=r&&s?r.tokenize(t,s):[t],a=J_(i),l=YS(n.getChildren(),a),{from:c,to:u,nodesForReplacement:f}=l;return c!==u||f.length?(n.splice(c,u-c,f),!0):!1})},{onUpdate:()=>{Va=!1},skipTransforms:!0}))}function J_(n){const e=[];return n.forEach(t=>{if(typeof t=="string"){const r=t.split(`
16
- `);for(let o=0;o<r.length;o++){const s=r[o];s.length&&e.push(Sr(s)),o<r.length-1&&e.push(vt())}}else{const{content:r}=t;typeof r=="string"?e.push(Sr(r,t.type)):Array.isArray(r)&&r.length===1&&typeof r[0]=="string"?e.push(Sr(r[0],t.type)):Array.isArray(r)&&e.push(...J_(r))}}),e}function VS(n,e){const t=D();if(!F(t)||!t.anchor)return;const r=t.anchor,o=r.offset,s=r.type==="element"&&ue(n.getChildAtIndex(r.offset-1));let i=0;if(!s){const l=r.getNode();i=o+l.getPreviousSiblings().reduce((c,u)=>c+(ue(u)?0:u.getTextContentSize()),0)}if(e()){if(s){r.getNode().select(o,o);return}n.getChildren().some(l=>{if(oe(l)){const c=l.getTextContentSize();if(c>=i)return l.select(i,i),!0;i-=c}return!1})}}function YS(n,e){let t=0;for(;t<n.length&&$f(n[t],e[t]);)t++;const r=n.length,o=e.length,s=Math.min(r,o)-t;let i=0;for(;i<s;)if(i++,!$f(n[r-i],e[o-i])){i--;break}const a=t,l=r-i,c=e.slice(t,o-i);return{from:a,nodesForReplacement:c,to:l}}function $f(n,e){return tt(n)&&tt(e)?n.__text===e.__text&&n.__highlightType===e.__highlightType:!!(ue(n)&&ue(e))}function Df(n){const e=D();if(!F(e)||e.isCollapsed())return!1;const t=e.getNodes();for(let o=0;o<t.length;o++){const s=t[o];if(!tt(s)&&!ue(s))return!1}const r=Hi(t[0]);r!=null&&Pf(r,n);for(let o=1;o<t.length;o++){const s=t[o];ue(t[o-1])&&tt(s)&&Pf(s,n)}return!0}function Pf(n,e){const t=n.getTextContent();if(e===Dt)if(t.length>0&&/\s/.test(t[0]))n.setTextContent(" "+t);else{const r=Sr(" ");n.insertBefore(r)}else t.indexOf(" ")===0&&(t.length===1?n.remove():n.setTextContent(t.substring(1)))}function jf(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.offset,i=o.offset,a=r.getNode(),l=o.getNode(),c=n===pt;if(!tt(a)||!tt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const b=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!0}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!0}return!1}const u=Hi(a),f=Rf(l);if(u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let b=0;b<d.length;b++){const w=d[b];if(!tt(w)&&!ue(w))return!1}e.preventDefault(),e.stopPropagation();const g=c?u.getPreviousSibling():f.getNextSibling();if(!ue(g))return!0;const h=c?g.getPreviousSibling():g.getNextSibling();if(h==null)return!0;const _=c?Hi(h):Rf(h);let m=_??h;return g.remove(),d.forEach(b=>b.remove()),n===pt?(d.forEach(b=>m.insertBefore(b)),m.insertBefore(g)):(m.insertAfter(g),m=g,d.forEach(b=>{m.insertAfter(b),m=b})),t.setTextNodeRange(a,s,l,i),!0}function Ff(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===Ir;if(!tt(s)||!tt(i))return!1;let l,c;return a?{node:l,offset:c}=HS(i):{node:l,offset:c}=JS(i),l!==null&&c!==-1&&t.setTextNodeRange(l,c,l,c),e.preventDefault(),e.stopPropagation(),!0}function GS(n){if(!n.hasNodes([Nt,Ar]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return de(n.registerMutationListener(Nt,e=>{n.update(()=>{for(const[t,r]of e)if(r!=="destroyed"){const o=Q(t);o!==null&&qS(o,n)}})}),n.registerNodeTransform(Nt,e=>H_(e,n)),n.registerNodeTransform(cn,e=>Mf(e,n)),n.registerNodeTransform(Ar,e=>Mf(e,n)),n.registerCommand(Dt,e=>Df(Dt),ee),n.registerCommand(wn,e=>Df(wn),ee),n.registerCommand(pt,e=>jf(pt,e),ee),n.registerCommand(Vt,e=>jf(Vt,e),ee),n.registerCommand(xs,e=>Ff(xs,e),ee),n.registerCommand(Ir,e=>Ff(Ir,e),ee))}function Bf(n){return ku(n.getJupyterInputNodeUuid())===null||!n.getParent()}class Kt extends Bt{__code;__outputs;__autoRun;__outputAdapter;__jupyterInputNodeUuid;__jupyterOutputNodeUuid;__executeTrigger;__variant;__renderTrigger;static getType(){return"jupyter-output"}static clone(e){const t=new Kt(e.getJupyterInput(),e.__outputAdapter,e.__outputs,e.__autoRun,e.__jupyterInputNodeUuid,e.__jupyterOutputNodeUuid,e.__key,e.__variant);return t.__executeTrigger=e.__executeTrigger,t.__renderTrigger=e.__renderTrigger,t}static importJSON(e){return ic(e.source,new jl(Al(),void 0,e.outputs,void 0,!1,e.variant),e.outputs,!1,e.jupyterInputNodeUuid,e.jupyterOutputNodeUuid,e.variant).updateFromJSON(e)}constructor(e,t,r,o,s,i,a,l){super(a),this.__variant=l,this.__jupyterInputNodeUuid=s||ks.uuid4(),this.__jupyterOutputNodeUuid=i||ks.uuid4(),this.__code=e,this.__outputs=r,this.__outputAdapter=t,this.__executeTrigger=0,this.__renderTrigger=0,this.__autoRun=o,Su.set(this.__jupyterOutputNodeUuid,this.__jupyterInputNodeUuid),Ca.set(this.__jupyterInputNodeUuid,this.__key),qi.set(this.__jupyterInputNodeUuid,this.__jupyterOutputNodeUuid),vu.set(this.__jupyterOutputNodeUuid,this.__key)}setJupyterInput(e){const t=this.getWritable();t.__code=e}getJupyterInput(){return this.getLatest().__code}setJupyterInputNodeUuid(e){const t=this.getWritable();t.__jupyterInputNodeUuid=e}getJupyterInputNodeUuid(){return this.getLatest().__jupyterInputNodeUuid}setJupyterOutputNodeUuid(e){const t=this.getWritable();t.__jupyterOutputNodeUuid=e}getJupyterOutputNodeUuid(){return this.getLatest().__jupyterOutputNodeUuid}setExecuteTrigger(e){const t=this.getWritable();t.__executeTrigger=e}getExecuteTrigger(){return this.getLatest().__executeTrigger}setAutoRun(e){const t=this.getWritable();t.__autoRun=e}getAutoRun(){return this.getLatest().__autoRun}setOutputs(e){const t=this.getWritable();t.__outputs=e}getOutputs(){return this.getLatest().__outputs}createDOM(){return document.createElement("span")}updateDOM(){return!1}isTopLevel(){return!0}isInline(){return!1}isIsolated(){return Bf(this)}decorate(e,t){const r=this.__outputAdapter?.outputArea?.model?.toJSON();let o=this.__outputs||[];return r&&r.length>0&&(o=r),x.jsx(hx,{code:this.getJupyterInput(),outputs:o,adapter:this.__outputAdapter,id:this.__jupyterOutputNodeUuid,executeTrigger:this.getExecuteTrigger(),renderTrigger:this.__renderTrigger,autoRun:this.__autoRun,lumino:!0,variant:this.__variant})}exportJSON(){return{...super.exportJSON(),type:"jupyter-output",source:this.getJupyterInput(),outputs:this.__outputAdapter.outputArea.model.toJSON(),jupyterInputNodeUuid:this.getJupyterInputNodeUuid(),jupyterOutputNodeUuid:this.getJupyterOutputNodeUuid(),variant:this.__variant,version:1}}updateFromJSON(e){const t=super.updateFromJSON(e);return e.source!==void 0&&(t.__code=e.source),e.outputs!==void 0&&(t.__outputs=e.outputs,t.__outputAdapter.setOutputs(e.outputs),t.__renderTrigger++),t}remove(e){Bf(this)&&super.remove(!1)}removeForce(){super.remove(!1)}executeCode(e){const t=this.getWritable();t.__code=e,t.__outputAdapter.kernel&&t.__outputAdapter.execute(e)}updateKernel(e){const t=this.getLatest();if(t.__outputAdapter&&t.__outputAdapter.kernel!==e){const r=this.getWritable();r.__outputAdapter.kernel=e,r.__renderTrigger++}}}function ic(n,e,t,r,o,s,i){return new Kt(n,e,t,r,o,s,void 0,i)}function Cu(n){return n instanceof Kt}const Ca=new Map,Sa=new Map,qi=new Map,Su=new Map,vu=new Map;function dr(n){const e=lh(Kt).filter(s=>s.getJupyterInputNodeUuid()===n);if(e.length===0)return null;const t=e.find(s=>{const i=s.getPreviousSibling();return i!==null&&st(i)&&i.getJupyterInputNodeUuid()===n});if(t)return t;const r=Ca.get(n),o=r?Q(r):null;return o&&Cu(o)&&o.getJupyterInputNodeUuid()===n?o:e[0]}function ku(n){const e=Sa.get(n),t=e?Q(e):null;return t&&st(t)&&t.getJupyterInputNodeUuid()===n?t:lh(Nt).find(r=>r.getJupyterInputNodeUuid()===n)??null}const ac=[{output_type:"execute_result",data:{"text/html":['<div style="color: #888; font-size: 11px; font-style: italic; padding: 0; margin: 0;">','Press <kbd style="font-size: 10px; padding: 1px 4px; background: #f0f0f0; border: 1px solid #ccc; border-radius: 3px;">Shift+Enter</kbd> to execute.',"</div>"]},execution_count:0,metadata:{}}],Vi=he(),q_=he(),V_=he(),Y_=he(),G_=he(),lc=n=>{const{kernel:e,onSessionConnection:t}=n||{},[r]=fe(),o=S.useRef(!1),s=S.useRef(!1),i=S.useRef(!0);S.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const a=S.useCallback(()=>{o.current||(o.current=!0,queueMicrotask(()=>{if(!i.current||r.getRootElement()==null){o.current=!1;return}r.update(()=>{const c=D();if(F(c)){const u=Q(c.anchor.key),f=Q(c.focus.key);(!u||!f)&&Ee(null)}r.getEditorState()._nodeMap.forEach(u=>{u instanceof Kt&&u.updateKernel(e)})},{discrete:!0}),o.current=!1}))},[e,r]);S.useEffect(()=>{a()},[e,a]),S.useEffect(()=>r.registerMutationListener(Nt,(c,{prevEditorState:u})=>{if(!s.current)for(const[f,d]of c)d==="destroyed"?queueMicrotask(()=>r.update(()=>{const g=u.read(()=>{const _=Q(f);return _&&st(_)?_.getJupyterInputNodeUuid():void 0}),h=g?qi.get(g):void 0;if(g&&h){const _=dr(g);_&&(_.markDirty(),_.removeForce()),Sa.delete(g),Ca.delete(g),qi.delete(g),Su.delete(h),vu.delete(h)}},{discrete:!0})):d==="updated"&&queueMicrotask(()=>r.update(()=>{const g=Q(f);if(g&&st(g)){const h=g.getJupyterInputNodeUuid(),_=dr(h);if(_&&g.getNextSibling()!==_){s.current=!0;try{_.remove(!1),g.insertAfter(_)}finally{s.current=!1}}}},{discrete:!0}))}),[r]),S.useEffect(()=>r.registerMutationListener(Kt,c=>{if(!s.current)for(const[u,f]of c)f==="updated"&&queueMicrotask(()=>r.update(()=>{const d=Q(u);if(d&&Cu(d)){const g=d,h=g.getJupyterInputNodeUuid(),_=ku(h);if(_&&dr(h)===g&&_.getNextSibling()!==g){s.current=!0;try{g.remove(!1),_.insertAfter(g)}finally{s.current=!1}}}},{discrete:!0}))}),[r]),S.useEffect(()=>{t&&(e?(t(e.session),e.session&&(e.session.statusChanged.connect((c,u)=>{t(c)}),e.session.connectionStatusChanged.connect((c,u)=>{t(c)}))):t(void 0))},[e,e?.session,t]),S.useEffect(()=>GS(r),[r]),S.useEffect(()=>{if(!r.hasNodes([Kt]))throw new Error("JupyterInputOutputPlugin: JupyterOutputNode not registered on editor");if(!r.hasNodes([Nt]))throw new Error("JupyterInputOutputPlugin: JupyterInputNode not registered on editor")},[r]),S.useEffect(()=>r.registerCommand(Nl,c=>{const f=D()?.getNodes()[0];if(f?.__parent){const d=Q(f?.__parent);if(d&&st(d))return!1}return!1},qe),[r]),S.useEffect(()=>r.registerCommand(zr,c=>{if(!c)return!1;const f=D()?.getNodes()[0];if(f?.__parent){const d=Q(f?.__parent);if(d&&st(d)){if(c.shiftKey){c.preventDefault();const h=d.getTextContent(),_=d.getJupyterInputNodeUuid(),m=dr(_);if(m){const v=m.__outputAdapter,k=m.getWritable();if(v.kernel!==e&&(v.kernel=e),k.__code=h,v.kernel)v.execute(h);else{const I=WS();k.__outputs=[I],v.setOutputs([I]),k.__renderTrigger++}return!0}const b=new jl(Al(),e,[]),w=ic(h,b,[],!0,_,ks.uuid4());d.insertAfter(w);const C=aa();return C.add(d.__key),Ee(C),!0}const g=D();if(F(g)){const h=vt();return g.insertNodes([h]),c.preventDefault(),!0}return!1}}return!1},ee),[r,e]),S.useEffect(()=>r.registerCommand(Ec,c=>{const u=D();if(!F(u))return!1;let f=u.anchor.getNode(),d=null,g=0;const h=20;for(;f&&g<h;){if(st(f)){d=f;break}f=f.getParent(),g++}if(d){c.preventDefault(),c.stopPropagation();const _=u.isCollapsed(),m=d.getKey(),b=d.getChildrenSize();let w=!1;if(!_){const C=u.anchor.getNode(),v=u.focus.getNode(),k=C.getKey()===m||C.getParent()?.getKey()===m,I=v.getKey()===m||v.getParent()?.getKey()===m;if(k&&I){const E=u.getTextContent(),N=d.getTextContent();w=E===N}}if(console.warn("[SELECT_ALL] Check:",{isCollapsed:_,selectionCoversEntireCell:w,selectedText:u.getTextContent().substring(0,50),cellText:d.getTextContent().substring(0,50)}),w){console.warn("[SELECT_ALL] Second press - selecting entire document");const C=se(),v=kr();return v.anchor.set(C.getKey(),0,"element"),v.focus.set(C.getKey(),C.getChildrenSize(),"element"),Ee(v),!0}else{console.warn("[SELECT_ALL] First press - selecting current cell");const C=kr();return C.anchor.set(d.getKey(),0,"element"),C.focus.set(d.getKey(),b,"element"),Ee(C),!0}}return!1},bo),[r]),S.useEffect(()=>r.registerCommand(Vi,c=>{ge("[JupyterInputOutputPlugin] 🔵 INSERT_JUPYTER_INPUT_OUTPUT_COMMAND triggered"),ge("[JupyterInputOutputPlugin] Props:",c);const{code:u,outputs:f,variant:d}=c,g=D();if(ge("[JupyterInputOutputPlugin] Selection exists?",!!g),ge("[JupyterInputOutputPlugin] Is RangeSelection?",F(g)),F(g)){const h=qr("python"),_=h.getJupyterInputNodeUuid();if(ge("[JupyterInputOutputPlugin] ✅ Created JupyterInputNode"),ge("[JupyterInputOutputPlugin] Node UUID:",_),ge("[JupyterInputOutputPlugin] Node type:",h.getType()),ge("[JupyterInputOutputPlugin] Node children before append:",h.getChildrenSize()),u){ge("[JupyterInputOutputPlugin] 📝 Code provided, length:",u.length),ge("[JupyterInputOutputPlugin] Code content:",u.substring(0,100));const v=Sr(u);ge("[JupyterInputOutputPlugin] ✅ Created JupyterInputHighlightNode"),ge("[JupyterInputOutputPlugin] CodeNode type:",v.getType()),ge("[JupyterInputOutputPlugin] CodeNode text length:",v.getTextContent().length),h.append(v),ge("[JupyterInputOutputPlugin] ✅ Appended code to JupyterInputNode"),ge("[JupyterInputOutputPlugin] Node children after append:",h.getChildrenSize()),ge("[JupyterInputOutputPlugin] Node text content:",h.getTextContent())}else ge("[JupyterInputOutputPlugin] ⚠️ No code provided");ge("[JupyterInputOutputPlugin] 🚀 Inserting node into document..."),ge("[JupyterInputOutputPlugin] Selection before insert:",{anchorKey:g.anchor.key,anchorOffset:g.anchor.offset,focusKey:g.focus.key,focusOffset:g.focus.offset}),g.insertNodes([h]),ge("[JupyterInputOutputPlugin] ✅ Node inserted"),ge("[JupyterInputOutputPlugin] Node key after insert:",h.getKey()),ge("[JupyterInputOutputPlugin] Node parent:",h.getParent()?.getType()),ge("[JupyterInputOutputPlugin] 📤 Creating output node..."),ge("[JupyterInputOutputPlugin] Kernel available?",!!e),ge("[JupyterInputOutputPlugin] Outputs:",f);const m=new jl(Al(),e,f,void 0,!1,d),b=ic(u,m,f||[],!0,_,ks.uuid4(),d);ge("[JupyterInputOutputPlugin] ✅ Created JupyterOutputNode"),ge("[JupyterInputOutputPlugin] Output node type:",b.getType());const w=b.getKey();m.outputArea.model.changed.connect((v,k)=>{queueMicrotask(()=>{const I=v.toJSON();r.update(()=>{const E=Q(w);if(!(E instanceof Kt))return;const N=E.getOutputs();(N.length!==I.length||JSON.stringify(N)!==JSON.stringify(I))&&E.setOutputs(I),E.getAutoRun()&&E.setAutoRun(!1)},{discrete:!0})})});const C=h.getParent();ge("[JupyterInputOutputPlugin] Parent node:",C?.getType()),C?(ge("[JupyterInputOutputPlugin] 🚀 Inserting output node after input node..."),h.insertAfter(b),ge("[JupyterInputOutputPlugin] ✅ Output node inserted")):ge("[JupyterInputOutputPlugin] ⚠️ No parent found, cannot insert output node"),ge("[JupyterInputOutputPlugin] 📍 Positioning cursor..."),h.selectStart(),ge("[JupyterInputOutputPlugin] 🎉 INSERT_JUPYTER_INPUT_OUTPUT_COMMAND completed successfully")}else ge("[JupyterInputOutputPlugin] ❌ Selection is not a RangeSelection");return!0},V),[r,e]);const l=S.useCallback((c,u)=>{const f=c.getTextContent(),d=c.getJupyterInputNodeUuid(),g=dr(d);return g?(g.updateKernel(u),g.executeCode(f),!0):!1},[]);return S.useEffect(()=>r.registerCommand(q_,()=>{if(!e)return console.warn("❌ No kernel available for cell execution"),!1;const c=D();if(!c)return!1;const d=c.getNodes()[0]?.getParent();return d&&st(d)?l(d,e):!1},V),[r,e,l]),S.useEffect(()=>r.registerCommand(V_,()=>{if(!e)return console.warn("❌ No kernel available for running all cells"),!1;const c=[];function u(d){if(st(d)&&c.push(d),q(d)){const g=d.getChildren();for(const h of g)u(h)}}const f=se();return u(f),c.length===0?(console.warn("❌ No Jupyter cells found to execute"),!1):(ge(`🚀 Executing ${c.length} cells in document order`),c.forEach(d=>{l(d,e)}),!0)},V),[r,e,l]),S.useEffect(()=>r.registerCommand(Y_,()=>e?.session?.kernel?((async()=>{try{if(!e.session.kernel){console.error("❌ Kernel became null during restart");return}ge("🔄 Restarting kernel..."),await e.session.kernel.restart(),ge("✅ Kernel restarted successfully")}catch(c){console.error("❌ Failed to restart kernel:",c)}})(),!0):(console.warn("❌ No kernel session available to restart"),!1),V),[r,e]),S.useEffect(()=>r.registerCommand(G_,()=>{let c=0;function u(d){if(d instanceof Kt&&d.__outputAdapter&&(d.__outputAdapter.clear(),c++),q(d)){const g=d.getChildren();for(const h of g)u(h)}}const f=se();return u(f),c>0?ge(`✅ Cleared outputs from ${c} cells`):console.warn("❌ No Jupyter cells found to clear"),!0},V),[r]),null},Uf=Object.freeze(Object.defineProperty({__proto__:null,$jupyterInputNodeFor:ku,$jupyterOutputNodeFor:dr,CLEAR_ALL_OUTPUTS_COMMAND:G_,DEFAULT_INITIAL_OUTPUTS:ac,INPUT_UUID_TO_CODE_KEY:Sa,INPUT_UUID_TO_OUTPUT_KEY:Ca,INPUT_UUID_TO_OUTPUT_UUID:qi,INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:Vi,JupyterInputOutputPlugin:lc,OUTPUT_UUID_TO_CODE_UUID:Su,OUTPUT_UUID_TO_OUTPUT_KEY:vu,RESTART_JUPYTER_KERNEL_COMMAND:Y_,RUN_ALL_JUPYTER_CELLS_COMMAND:V_,RUN_JUPYTER_CELL_COMMAND:q_,default:lc},Symbol.toStringTag,{value:"Module"})),zf=n=>{const e=px.languages;return n!=null&&e&&e.hasOwnProperty(n)?n:void 0},Ya="data-highlight-language";class Nt extends Oe{__language;__jupyterInputNodeUuid;static getType(){return"jupyter-input"}static clone(e){return new Nt(e.__language,e.__jupyterInputNodeUuid,e.__key)}constructor(e,t,r){super(r),this.__language=zf(e),this.__jupyterInputNodeUuid=t||ks.uuid4(),Sa.set(this.__jupyterInputNodeUuid,this.__key)}setJupyterInputNodeUuid(e){const t=this.getWritable();t.__jupyterInputNodeUuid=e}getJupyterInputNodeUuid(){return this.getLatest().__jupyterInputNodeUuid}createDOM(e){const t=document.createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&t.setAttribute(Ya,r),t}updateDOM(e,t){const r=this.__language,o=e.__language;return r?r!==o&&t.setAttribute(Ya,r):o&&t.removeAttribute(Ya),!1}static importDOM(){return{code:e=>e.textContent!=null&&/\r?\n/.test(e.textContent)?{conversion:Kf,priority:1}:null,div:e=>({conversion:XS,priority:1}),pre:e=>({conversion:Kf,priority:0}),table:e=>Ga(e)?{conversion:ZS,priority:4}:null,td:e=>{const t=e,r=t.closest("table");return tv(t)?{conversion:QS,priority:4}:r&&Ga(r)?{conversion:Wf,priority:4}:null},tr:e=>{const r=e.closest("table");return r&&Ga(r)?{conversion:Wf,priority:4}:null}}}static importJSON(e){const t=qr(e.language,e.jupyterInputNodeUuid);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"jupyter-input",language:this.getLanguage(),jupyterInputNodeUuid:this.getJupyterInputNodeUuid(),version:1}}insertNewAfter(e){const t=this.getChildren(),r=t.length;if(r>=2&&t[r-1].getTextContent()===`
16
+ `);for(let o=0;o<r.length;o++){const s=r[o];s.length&&e.push(Sr(s)),o<r.length-1&&e.push(vt())}}else{const{content:r}=t;typeof r=="string"?e.push(Sr(r,t.type)):Array.isArray(r)&&r.length===1&&typeof r[0]=="string"?e.push(Sr(r[0],t.type)):Array.isArray(r)&&e.push(...J_(r))}}),e}function VS(n,e){const t=D();if(!F(t)||!t.anchor)return;const r=t.anchor,o=r.offset,s=r.type==="element"&&ue(n.getChildAtIndex(r.offset-1));let i=0;if(!s){const l=r.getNode();i=o+l.getPreviousSiblings().reduce((c,u)=>c+(ue(u)?0:u.getTextContentSize()),0)}if(e()){if(s){r.getNode().select(o,o);return}n.getChildren().some(l=>{if(oe(l)){const c=l.getTextContentSize();if(c>=i)return l.select(i,i),!0;i-=c}return!1})}}function YS(n,e){let t=0;for(;t<n.length&&$f(n[t],e[t]);)t++;const r=n.length,o=e.length,s=Math.min(r,o)-t;let i=0;for(;i<s;)if(i++,!$f(n[r-i],e[o-i])){i--;break}const a=t,l=r-i,c=e.slice(t,o-i);return{from:a,nodesForReplacement:c,to:l}}function $f(n,e){return tt(n)&&tt(e)?n.__text===e.__text&&n.__highlightType===e.__highlightType:!!(ue(n)&&ue(e))}function Df(n){const e=D();if(!F(e)||e.isCollapsed())return!1;const t=e.getNodes();for(let o=0;o<t.length;o++){const s=t[o];if(!tt(s)&&!ue(s))return!1}const r=Hi(t[0]);r!=null&&Pf(r,n);for(let o=1;o<t.length;o++){const s=t[o];ue(t[o-1])&&tt(s)&&Pf(s,n)}return!0}function Pf(n,e){const t=n.getTextContent();if(e===Dt)if(t.length>0&&/\s/.test(t[0]))n.setTextContent(" "+t);else{const r=Sr(" ");n.insertBefore(r)}else t.indexOf(" ")===0&&(t.length===1?n.remove():n.setTextContent(t.substring(1)))}function jf(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.offset,i=o.offset,a=r.getNode(),l=o.getNode(),c=n===pt;if(!tt(a)||!tt(l))return!1;if(!e.altKey){if(t.isCollapsed()){const b=a.getParentOrThrow();if(c&&s===0&&a.getPreviousSibling()===null){if(b.getPreviousSibling()===null)return b.selectPrevious(),e.preventDefault(),!0}else if(!c&&s===a.getTextContentSize()&&a.getNextSibling()===null&&b.getNextSibling()===null)return b.selectNext(),e.preventDefault(),!0}return!1}const u=Hi(a),f=Rf(l);if(u==null||f==null)return!1;const d=u.getNodesBetween(f);for(let b=0;b<d.length;b++){const w=d[b];if(!tt(w)&&!ue(w))return!1}e.preventDefault(),e.stopPropagation();const g=c?u.getPreviousSibling():f.getNextSibling();if(!ue(g))return!0;const h=c?g.getPreviousSibling():g.getNextSibling();if(h==null)return!0;const _=c?Hi(h):Rf(h);let m=_??h;return g.remove(),d.forEach(b=>b.remove()),n===pt?(d.forEach(b=>m.insertBefore(b)),m.insertBefore(g)):(m.insertAfter(g),m=g,d.forEach(b=>{m.insertAfter(b),m=b})),t.setTextNodeRange(a,s,l,i),!0}function Ff(n,e){const t=D();if(!F(t))return!1;const{anchor:r,focus:o}=t,s=r.getNode(),i=o.getNode(),a=n===Ir;if(!tt(s)||!tt(i))return!1;let l,c;return a?{node:l,offset:c}=HS(i):{node:l,offset:c}=JS(i),l!==null&&c!==-1&&t.setTextNodeRange(l,c,l,c),e.preventDefault(),e.stopPropagation(),!0}function XS(n){if(!n.hasNodes([Nt,Ar]))throw new Error("CodeHighlightPlugin: CodeNode or CodeHighlightNode not registered on editor");return de(n.registerMutationListener(Nt,e=>{n.update(()=>{for(const[t,r]of e)if(r!=="destroyed"){const o=Q(t);o!==null&&qS(o,n)}})}),n.registerNodeTransform(Nt,e=>H_(e,n)),n.registerNodeTransform(cn,e=>Mf(e,n)),n.registerNodeTransform(Ar,e=>Mf(e,n)),n.registerCommand(Dt,e=>Df(Dt),ee),n.registerCommand(wn,e=>Df(wn),ee),n.registerCommand(pt,e=>jf(pt,e),ee),n.registerCommand(Vt,e=>jf(Vt,e),ee),n.registerCommand(xs,e=>Ff(xs,e),ee),n.registerCommand(Ir,e=>Ff(Ir,e),ee))}function Bf(n){return ku(n.getJupyterInputNodeUuid())===null||!n.getParent()}class Kt extends Bt{__code;__outputs;__autoRun;__outputAdapter;__jupyterInputNodeUuid;__jupyterOutputNodeUuid;__executeTrigger;__variant;__renderTrigger;static getType(){return"jupyter-output"}static clone(e){const t=new Kt(e.getJupyterInput(),e.__outputAdapter,e.__outputs,e.__autoRun,e.__jupyterInputNodeUuid,e.__jupyterOutputNodeUuid,e.__key,e.__variant);return t.__executeTrigger=e.__executeTrigger,t.__renderTrigger=e.__renderTrigger,t}static importJSON(e){return ic(e.source,new jl(Al(),void 0,e.outputs,void 0,!1,e.variant),e.outputs,!1,e.jupyterInputNodeUuid,e.jupyterOutputNodeUuid,e.variant).updateFromJSON(e)}constructor(e,t,r,o,s,i,a,l){super(a),this.__variant=l,this.__jupyterInputNodeUuid=s||ks.uuid4(),this.__jupyterOutputNodeUuid=i||ks.uuid4(),this.__code=e,this.__outputs=r,this.__outputAdapter=t,this.__executeTrigger=0,this.__renderTrigger=0,this.__autoRun=o,Su.set(this.__jupyterOutputNodeUuid,this.__jupyterInputNodeUuid),Ca.set(this.__jupyterInputNodeUuid,this.__key),qi.set(this.__jupyterInputNodeUuid,this.__jupyterOutputNodeUuid),vu.set(this.__jupyterOutputNodeUuid,this.__key)}setJupyterInput(e){const t=this.getWritable();t.__code=e}getJupyterInput(){return this.getLatest().__code}setJupyterInputNodeUuid(e){const t=this.getWritable();t.__jupyterInputNodeUuid=e}getJupyterInputNodeUuid(){return this.getLatest().__jupyterInputNodeUuid}setJupyterOutputNodeUuid(e){const t=this.getWritable();t.__jupyterOutputNodeUuid=e}getJupyterOutputNodeUuid(){return this.getLatest().__jupyterOutputNodeUuid}setExecuteTrigger(e){const t=this.getWritable();t.__executeTrigger=e}getExecuteTrigger(){return this.getLatest().__executeTrigger}setAutoRun(e){const t=this.getWritable();t.__autoRun=e}getAutoRun(){return this.getLatest().__autoRun}setOutputs(e){const t=this.getWritable();t.__outputs=e}getOutputs(){return this.getLatest().__outputs}createDOM(){return document.createElement("span")}updateDOM(){return!1}isTopLevel(){return!0}isInline(){return!1}isIsolated(){return Bf(this)}decorate(e,t){const r=this.__outputAdapter?.outputArea?.model?.toJSON();let o=this.__outputs||[];return r&&r.length>0&&(o=r),x.jsx(hx,{code:this.getJupyterInput(),outputs:o,adapter:this.__outputAdapter,id:this.__jupyterOutputNodeUuid,executeTrigger:this.getExecuteTrigger(),renderTrigger:this.__renderTrigger,autoRun:this.__autoRun,lumino:!0,variant:this.__variant})}exportJSON(){return{...super.exportJSON(),type:"jupyter-output",source:this.getJupyterInput(),outputs:this.__outputAdapter.outputArea.model.toJSON(),jupyterInputNodeUuid:this.getJupyterInputNodeUuid(),jupyterOutputNodeUuid:this.getJupyterOutputNodeUuid(),variant:this.__variant,version:1}}updateFromJSON(e){const t=super.updateFromJSON(e);return e.source!==void 0&&(t.__code=e.source),e.outputs!==void 0&&(t.__outputs=e.outputs,t.__outputAdapter.setOutputs(e.outputs),t.__renderTrigger++),t}remove(e){Bf(this)&&super.remove(!1)}removeForce(){super.remove(!1)}executeCode(e){const t=this.getWritable();t.__code=e,t.__outputAdapter.kernel&&t.__outputAdapter.execute(e)}updateKernel(e){const t=this.getLatest();if(t.__outputAdapter&&t.__outputAdapter.kernel!==e){const r=this.getWritable();r.__outputAdapter.kernel=e,r.__renderTrigger++}}}function ic(n,e,t,r,o,s,i){return new Kt(n,e,t,r,o,s,void 0,i)}function Cu(n){return n instanceof Kt}const Ca=new Map,Sa=new Map,qi=new Map,Su=new Map,vu=new Map;function dr(n){const e=lh(Kt).filter(s=>s.getJupyterInputNodeUuid()===n);if(e.length===0)return null;const t=e.find(s=>{const i=s.getPreviousSibling();return i!==null&&st(i)&&i.getJupyterInputNodeUuid()===n});if(t)return t;const r=Ca.get(n),o=r?Q(r):null;return o&&Cu(o)&&o.getJupyterInputNodeUuid()===n?o:e[0]}function ku(n){const e=Sa.get(n),t=e?Q(e):null;return t&&st(t)&&t.getJupyterInputNodeUuid()===n?t:lh(Nt).find(r=>r.getJupyterInputNodeUuid()===n)??null}const ac=[{output_type:"execute_result",data:{"text/html":['<div style="color: #888; font-size: 11px; font-style: italic; padding: 0; margin: 0;">','Press <kbd style="font-size: 10px; padding: 1px 4px; background: #f0f0f0; border: 1px solid #ccc; border-radius: 3px;">Shift+Enter</kbd> to execute.',"</div>"]},execution_count:0,metadata:{}}],Vi=he(),q_=he(),V_=he(),Y_=he(),X_=he(),lc=n=>{const{kernel:e,onSessionConnection:t}=n||{},[r]=fe(),o=S.useRef(!1),s=S.useRef(!1),i=S.useRef(!0);S.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const a=S.useCallback(()=>{o.current||(o.current=!0,queueMicrotask(()=>{if(!i.current||r.getRootElement()==null){o.current=!1;return}r.update(()=>{const c=D();if(F(c)){const u=Q(c.anchor.key),f=Q(c.focus.key);(!u||!f)&&Ee(null)}r.getEditorState()._nodeMap.forEach(u=>{u instanceof Kt&&u.updateKernel(e)})},{discrete:!0}),o.current=!1}))},[e,r]);S.useEffect(()=>{a()},[e,a]),S.useEffect(()=>r.registerMutationListener(Nt,(c,{prevEditorState:u})=>{if(!s.current)for(const[f,d]of c)d==="destroyed"?queueMicrotask(()=>r.update(()=>{const g=u.read(()=>{const _=Q(f);return _&&st(_)?_.getJupyterInputNodeUuid():void 0}),h=g?qi.get(g):void 0;if(g&&h){const _=dr(g);_&&(_.markDirty(),_.removeForce()),Sa.delete(g),Ca.delete(g),qi.delete(g),Su.delete(h),vu.delete(h)}},{discrete:!0})):d==="updated"&&queueMicrotask(()=>r.update(()=>{const g=Q(f);if(g&&st(g)){const h=g.getJupyterInputNodeUuid(),_=dr(h);if(_&&g.getNextSibling()!==_){s.current=!0;try{_.remove(!1),g.insertAfter(_)}finally{s.current=!1}}}},{discrete:!0}))}),[r]),S.useEffect(()=>r.registerMutationListener(Kt,c=>{if(!s.current)for(const[u,f]of c)f==="updated"&&queueMicrotask(()=>r.update(()=>{const d=Q(u);if(d&&Cu(d)){const g=d,h=g.getJupyterInputNodeUuid(),_=ku(h);if(_&&dr(h)===g&&_.getNextSibling()!==g){s.current=!0;try{g.remove(!1),_.insertAfter(g)}finally{s.current=!1}}}},{discrete:!0}))}),[r]),S.useEffect(()=>{t&&(e?(t(e.session),e.session&&(e.session.statusChanged.connect((c,u)=>{t(c)}),e.session.connectionStatusChanged.connect((c,u)=>{t(c)}))):t(void 0))},[e,e?.session,t]),S.useEffect(()=>XS(r),[r]),S.useEffect(()=>{if(!r.hasNodes([Kt]))throw new Error("JupyterInputOutputPlugin: JupyterOutputNode not registered on editor");if(!r.hasNodes([Nt]))throw new Error("JupyterInputOutputPlugin: JupyterInputNode not registered on editor")},[r]),S.useEffect(()=>r.registerCommand(Nl,c=>{const f=D()?.getNodes()[0];if(f?.__parent){const d=Q(f?.__parent);if(d&&st(d))return!1}return!1},qe),[r]),S.useEffect(()=>r.registerCommand(zr,c=>{if(!c)return!1;const f=D()?.getNodes()[0];if(f?.__parent){const d=Q(f?.__parent);if(d&&st(d)){if(c.shiftKey){c.preventDefault();const h=d.getTextContent(),_=d.getJupyterInputNodeUuid(),m=dr(_);if(m){const v=m.__outputAdapter,k=m.getWritable();if(v.kernel!==e&&(v.kernel=e),k.__code=h,v.kernel)v.execute(h);else{const I=WS();k.__outputs=[I],v.setOutputs([I]),k.__renderTrigger++}return!0}const b=new jl(Al(),e,[]),w=ic(h,b,[],!0,_,ks.uuid4());d.insertAfter(w);const C=aa();return C.add(d.__key),Ee(C),!0}const g=D();if(F(g)){const h=vt();return g.insertNodes([h]),c.preventDefault(),!0}return!1}}return!1},ee),[r,e]),S.useEffect(()=>r.registerCommand(Ec,c=>{const u=D();if(!F(u))return!1;let f=u.anchor.getNode(),d=null,g=0;const h=20;for(;f&&g<h;){if(st(f)){d=f;break}f=f.getParent(),g++}if(d){c.preventDefault(),c.stopPropagation();const _=u.isCollapsed(),m=d.getKey(),b=d.getChildrenSize();let w=!1;if(!_){const C=u.anchor.getNode(),v=u.focus.getNode(),k=C.getKey()===m||C.getParent()?.getKey()===m,I=v.getKey()===m||v.getParent()?.getKey()===m;if(k&&I){const E=u.getTextContent(),N=d.getTextContent();w=E===N}}if(console.warn("[SELECT_ALL] Check:",{isCollapsed:_,selectionCoversEntireCell:w,selectedText:u.getTextContent().substring(0,50),cellText:d.getTextContent().substring(0,50)}),w){console.warn("[SELECT_ALL] Second press - selecting entire document");const C=se(),v=kr();return v.anchor.set(C.getKey(),0,"element"),v.focus.set(C.getKey(),C.getChildrenSize(),"element"),Ee(v),!0}else{console.warn("[SELECT_ALL] First press - selecting current cell");const C=kr();return C.anchor.set(d.getKey(),0,"element"),C.focus.set(d.getKey(),b,"element"),Ee(C),!0}}return!1},bo),[r]),S.useEffect(()=>r.registerCommand(Vi,c=>{ge("[JupyterInputOutputPlugin] 🔵 INSERT_JUPYTER_INPUT_OUTPUT_COMMAND triggered"),ge("[JupyterInputOutputPlugin] Props:",c);const{code:u,outputs:f,variant:d}=c,g=D();if(ge("[JupyterInputOutputPlugin] Selection exists?",!!g),ge("[JupyterInputOutputPlugin] Is RangeSelection?",F(g)),F(g)){const h=qr("python"),_=h.getJupyterInputNodeUuid();if(ge("[JupyterInputOutputPlugin] ✅ Created JupyterInputNode"),ge("[JupyterInputOutputPlugin] Node UUID:",_),ge("[JupyterInputOutputPlugin] Node type:",h.getType()),ge("[JupyterInputOutputPlugin] Node children before append:",h.getChildrenSize()),u){ge("[JupyterInputOutputPlugin] 📝 Code provided, length:",u.length),ge("[JupyterInputOutputPlugin] Code content:",u.substring(0,100));const v=Sr(u);ge("[JupyterInputOutputPlugin] ✅ Created JupyterInputHighlightNode"),ge("[JupyterInputOutputPlugin] CodeNode type:",v.getType()),ge("[JupyterInputOutputPlugin] CodeNode text length:",v.getTextContent().length),h.append(v),ge("[JupyterInputOutputPlugin] ✅ Appended code to JupyterInputNode"),ge("[JupyterInputOutputPlugin] Node children after append:",h.getChildrenSize()),ge("[JupyterInputOutputPlugin] Node text content:",h.getTextContent())}else ge("[JupyterInputOutputPlugin] ⚠️ No code provided");ge("[JupyterInputOutputPlugin] 🚀 Inserting node into document..."),ge("[JupyterInputOutputPlugin] Selection before insert:",{anchorKey:g.anchor.key,anchorOffset:g.anchor.offset,focusKey:g.focus.key,focusOffset:g.focus.offset}),g.insertNodes([h]),ge("[JupyterInputOutputPlugin] ✅ Node inserted"),ge("[JupyterInputOutputPlugin] Node key after insert:",h.getKey()),ge("[JupyterInputOutputPlugin] Node parent:",h.getParent()?.getType()),ge("[JupyterInputOutputPlugin] 📤 Creating output node..."),ge("[JupyterInputOutputPlugin] Kernel available?",!!e),ge("[JupyterInputOutputPlugin] Outputs:",f);const m=new jl(Al(),e,f,void 0,!1,d),b=ic(u,m,f||[],!0,_,ks.uuid4(),d);ge("[JupyterInputOutputPlugin] ✅ Created JupyterOutputNode"),ge("[JupyterInputOutputPlugin] Output node type:",b.getType());const w=b.getKey();m.outputArea.model.changed.connect((v,k)=>{queueMicrotask(()=>{const I=v.toJSON();r.update(()=>{const E=Q(w);if(!(E instanceof Kt))return;const N=E.getOutputs();(N.length!==I.length||JSON.stringify(N)!==JSON.stringify(I))&&E.setOutputs(I),E.getAutoRun()&&E.setAutoRun(!1)},{discrete:!0})})});const C=h.getParent();ge("[JupyterInputOutputPlugin] Parent node:",C?.getType()),C?(ge("[JupyterInputOutputPlugin] 🚀 Inserting output node after input node..."),h.insertAfter(b),ge("[JupyterInputOutputPlugin] ✅ Output node inserted")):ge("[JupyterInputOutputPlugin] ⚠️ No parent found, cannot insert output node"),ge("[JupyterInputOutputPlugin] 📍 Positioning cursor..."),h.selectStart(),ge("[JupyterInputOutputPlugin] 🎉 INSERT_JUPYTER_INPUT_OUTPUT_COMMAND completed successfully")}else ge("[JupyterInputOutputPlugin] ❌ Selection is not a RangeSelection");return!0},V),[r,e]);const l=S.useCallback((c,u)=>{const f=c.getTextContent(),d=c.getJupyterInputNodeUuid(),g=dr(d);return g?(g.updateKernel(u),g.executeCode(f),!0):!1},[]);return S.useEffect(()=>r.registerCommand(q_,()=>{if(!e)return console.warn("❌ No kernel available for cell execution"),!1;const c=D();if(!c)return!1;const d=c.getNodes()[0]?.getParent();return d&&st(d)?l(d,e):!1},V),[r,e,l]),S.useEffect(()=>r.registerCommand(V_,()=>{if(!e)return console.warn("❌ No kernel available for running all cells"),!1;const c=[];function u(d){if(st(d)&&c.push(d),q(d)){const g=d.getChildren();for(const h of g)u(h)}}const f=se();return u(f),c.length===0?(console.warn("❌ No Jupyter cells found to execute"),!1):(ge(`🚀 Executing ${c.length} cells in document order`),c.forEach(d=>{l(d,e)}),!0)},V),[r,e,l]),S.useEffect(()=>r.registerCommand(Y_,()=>e?.session?.kernel?((async()=>{try{if(!e.session.kernel){console.error("❌ Kernel became null during restart");return}ge("🔄 Restarting kernel..."),await e.session.kernel.restart(),ge("✅ Kernel restarted successfully")}catch(c){console.error("❌ Failed to restart kernel:",c)}})(),!0):(console.warn("❌ No kernel session available to restart"),!1),V),[r,e]),S.useEffect(()=>r.registerCommand(X_,()=>{let c=0;function u(d){if(d instanceof Kt&&d.__outputAdapter&&(d.__outputAdapter.clear(),c++),q(d)){const g=d.getChildren();for(const h of g)u(h)}}const f=se();return u(f),c>0?ge(`✅ Cleared outputs from ${c} cells`):console.warn("❌ No Jupyter cells found to clear"),!0},V),[r]),null},Uf=Object.freeze(Object.defineProperty({__proto__:null,$jupyterInputNodeFor:ku,$jupyterOutputNodeFor:dr,CLEAR_ALL_OUTPUTS_COMMAND:X_,DEFAULT_INITIAL_OUTPUTS:ac,INPUT_UUID_TO_CODE_KEY:Sa,INPUT_UUID_TO_OUTPUT_KEY:Ca,INPUT_UUID_TO_OUTPUT_UUID:qi,INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:Vi,JupyterInputOutputPlugin:lc,OUTPUT_UUID_TO_CODE_UUID:Su,OUTPUT_UUID_TO_OUTPUT_KEY:vu,RESTART_JUPYTER_KERNEL_COMMAND:Y_,RUN_ALL_JUPYTER_CELLS_COMMAND:V_,RUN_JUPYTER_CELL_COMMAND:q_,default:lc},Symbol.toStringTag,{value:"Module"})),zf=n=>{const e=px.languages;return n!=null&&e&&e.hasOwnProperty(n)?n:void 0},Ya="data-highlight-language";class Nt extends Oe{__language;__jupyterInputNodeUuid;static getType(){return"jupyter-input"}static clone(e){return new Nt(e.__language,e.__jupyterInputNodeUuid,e.__key)}constructor(e,t,r){super(r),this.__language=zf(e),this.__jupyterInputNodeUuid=t||ks.uuid4(),Sa.set(this.__jupyterInputNodeUuid,this.__key)}setJupyterInputNodeUuid(e){const t=this.getWritable();t.__jupyterInputNodeUuid=e}getJupyterInputNodeUuid(){return this.getLatest().__jupyterInputNodeUuid}createDOM(e){const t=document.createElement("code");Ie(t,e.theme.code),t.setAttribute("spellcheck","false");const r=this.getLanguage();return r&&t.setAttribute(Ya,r),t}updateDOM(e,t){const r=this.__language,o=e.__language;return r?r!==o&&t.setAttribute(Ya,r):o&&t.removeAttribute(Ya),!1}static importDOM(){return{code:e=>e.textContent!=null&&/\r?\n/.test(e.textContent)?{conversion:Kf,priority:1}:null,div:e=>({conversion:GS,priority:1}),pre:e=>({conversion:Kf,priority:0}),table:e=>Xa(e)?{conversion:ZS,priority:4}:null,td:e=>{const t=e,r=t.closest("table");return tv(t)?{conversion:QS,priority:4}:r&&Xa(r)?{conversion:Wf,priority:4}:null},tr:e=>{const r=e.closest("table");return r&&Xa(r)?{conversion:Wf,priority:4}:null}}}static importJSON(e){const t=qr(e.language,e.jupyterInputNodeUuid);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"jupyter-input",language:this.getLanguage(),jupyterInputNodeUuid:this.getJupyterInputNodeUuid(),version:1}}insertNewAfter(e){const t=this.getChildren(),r=t.length;if(r>=2&&t[r-1].getTextContent()===`
17
17
  `&&t[r-2].getTextContent()===`
18
- `&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){t[r-1].remove(),t[r-2].remove();const i=ne();return this.insertAfter(i),i}const o=e.anchor.getNode(),s=Hi(o);if(s!=null){let i=0;const a=s.getTextContent();for(;i<a.length&&/[\t ]/.test(a[i]);)i+=1;if(i>0){const l=a.substring(0,i),c=Sr(l);return o.insertAfter(c),e.insertNodes([vt()]),c.select(),c}}return null}canInsertTab(){const e=D();return!(!F(e)||!e.isCollapsed())}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(r=>e.append(r)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();t.__language=zf(e)}getLanguage(){return this.getLatest().__language}}function qr(n,e){return new Nt(n,e)}function st(n){return n instanceof Nt}function Kf(n){return{node:qr("python")}}function XS(n){return{after:t=>{const r=n.parentNode;return r!=null&&n!==r.lastChild&&t.push(vt()),t},node:ev(n)?qr("python"):null}}function ZS(){return{node:qr("python")}}function Wf(){return{node:null}}function QS(n){const e=n;return{after:t=>(e.parentNode&&e.parentNode.nextSibling&&t.push(vt()),t),node:null}}function ev(n){return n.style.fontFamily.match("monospace")!==null}function tv(n){return n.classList.contains("js-file-line")}function Ga(n){return n.classList.contains("js-file-line-container")}function X_(n){n.hidden="until-found"}function nv(n,e){n.addEventListener("beforematch",e)}const Hf="datalayer-collapsible-styles",rv=`
18
+ `&&e.isCollapsed()&&e.anchor.key===this.__key&&e.anchor.offset===r){t[r-1].remove(),t[r-2].remove();const i=ne();return this.insertAfter(i),i}const o=e.anchor.getNode(),s=Hi(o);if(s!=null){let i=0;const a=s.getTextContent();for(;i<a.length&&/[\t ]/.test(a[i]);)i+=1;if(i>0){const l=a.substring(0,i),c=Sr(l);return o.insertAfter(c),e.insertNodes([vt()]),c.select(),c}}return null}canInsertTab(){const e=D();return!(!F(e)||!e.isCollapsed())}canIndent(){return!1}collapseAtStart(){const e=ne();return this.getChildren().forEach(r=>e.append(r)),this.replace(e),!0}setLanguage(e){const t=this.getWritable();t.__language=zf(e)}getLanguage(){return this.getLatest().__language}}function qr(n,e){return new Nt(n,e)}function st(n){return n instanceof Nt}function Kf(n){return{node:qr("python")}}function GS(n){return{after:t=>{const r=n.parentNode;return r!=null&&n!==r.lastChild&&t.push(vt()),t},node:ev(n)?qr("python"):null}}function ZS(){return{node:qr("python")}}function Wf(){return{node:null}}function QS(n){const e=n;return{after:t=>(e.parentNode&&e.parentNode.nextSibling&&t.push(vt()),t),node:null}}function ev(n){return n.style.fontFamily.match("monospace")!==null}function tv(n){return n.classList.contains("js-file-line")}function Xa(n){return n.classList.contains("js-file-line-container")}function G_(n){n.hidden="until-found"}function nv(n,e){n.addEventListener("beforematch",e)}const Hf="datalayer-collapsible-styles",rv=`
19
19
  /* Collapsible title hover */
20
20
  .Collapsible__title:hover {
21
21
  background-color: var(--bgColor-neutral-muted, rgba(0, 0, 0, 0.04));
@@ -81,15 +81,15 @@ summary.Collapsible__title::marker {
81
81
  display: none;
82
82
  user-select: none;
83
83
  }
84
- `;let Xa=!1;function Tu(){if(Xa||typeof document>"u")return;if(document.getElementById(Hf)){Xa=!0;return}const n=document.createElement("style");n.id=Hf,n.textContent=rv,document.head.appendChild(n),Xa=!0}const ov={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},sv={cursor:"pointer",padding:"12px 12px 12px 36px",position:"relative",fontWeight:"600",fontSize:"14px",listStyle:"none",display:"block",outline:"none",color:"var(--fgColor-default, #333)",userSelect:"none",transition:"background-color 0.15s ease",margin:"0",WebkitAppearance:"none"},iv={padding:"12px 16px 16px 36px"};function Iu(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function av(n){const e=n.open!==void 0?n.open:!0;return{node:Eu(e)}}class Mr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Mr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())q(s)&&t.push(...s.getChildren());Dc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Tu();let r;if($i)r=document.createElement("div"),r.setAttribute("open","");else{const o=document.createElement("details");o.open=this.__open,o.addEventListener("toggle",()=>{t.getEditorState().read(()=>this.getOpen())!==o.open&&t.update(()=>this.toggleOpen())}),r=o}return r.classList.add("Collapsible__container"),Iu(r,ov),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if($i){const o=t.children[1];if(!ke(o))throw new Error("Expected contentDom to be an HTMLElement");r?(t.setAttribute("open",""),o.hidden=!1):(t.removeAttribute("open"),X_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:av,priority:1})}}static importJSON(e){return Eu(e.open).updateFromJSON(e)}exportDOM(){const e=document.createElement("details");return e.classList.add("Collapsible__container"),e.setAttribute("open",this.__open.toString()),{element:e}}exportJSON(){return{...super.exportJSON(),open:this.__open}}setOpen(e){const t=this.getWritable();t.__open=e}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function Eu(n){return new Mr(n)}function Pt(n){return n instanceof Mr}function lv(n){return{node:Nu()}}class $r extends Oe{static getType(){return"collapsible-content"}static clone(e){return new $r(e.__key)}createDOM(e,t){Tu();const r=document.createElement("div");return r.classList.add("Collapsible__content"),Iu(r,iv),$i&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||X_(r)}),nv(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||o.toggleOpen()})})),r}updateDOM(e,t){return!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-collapsible-content")?{conversion:lv,priority:2}:null}}exportDOM(){const e=document.createElement("div");return e.classList.add("Collapsible__content"),e.setAttribute("data-lexical-collapsible-content","true"),{element:e}}static importJSON(e){return Nu().updateFromJSON(e)}isShadowRoot(){return!0}}function Nu(){return new $r}function Lu(n){return n instanceof $r}function cv(n){return{node:Z_()}}class Os extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:$c({summary:()=>({conversion:cv,priority:1})})})}createDOM(e,t){Tu();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),Iu(r,sv),$i&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.toggleOpen()})}),r}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){const r=this.getParentOrThrow();if(!Pt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Lu(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(q(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function Z_(){return new Os}function xi(n){return n instanceof Os}function uv(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Ou(t)}:null}class Dr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new Dr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Ie(t,e.theme.layoutContainer),t}exportDOM(){const e=document.createElement("div");return e.style.gridTemplateColumns=this.__templateColumns,e.setAttribute("data-lexical-layout-container","true"),{element:e}}updateDOM(e,t){return e.__templateColumns!==this.__templateColumns&&(t.style.gridTemplateColumns=this.__templateColumns),!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-container")?{conversion:uv,priority:2}:null}}static importJSON(e){return Ou().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTemplateColumns(e.templateColumns)}isShadowRoot(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),templateColumns:this.__templateColumns}}getTemplateColumns(){return this.getLatest().__templateColumns}setTemplateColumns(e){const t=this.getWritable();return t.__templateColumns=e,t}}function Ou(n=""){return new Dr(n)}function Ci(n){return n instanceof Dr}function dv(){return{node:Ru()}}function fv(n){if(!Au(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class Pr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new Pr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Ie(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(fv)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:dv,priority:2}:null}}static importJSON(e){return Ru().updateFromJSON(e)}isShadowRoot(){return!0}}function Ru(){return new Pr}function Au(n){return n instanceof Pr}const Q_="@datalayer/jupyter-lexical/Loom",ls=new WeakMap;function UM(n,e){return e?ls.set(n,e):ls.delete(n),()=>{ls.get(n)===e&&ls.delete(n)}}function gv(n){return ls.get(n)}const pv=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function kn(n){const e=pv.exec(n.trim());return e?e[1].toLowerCase():null}function Mu(n){return`https://www.loom.com/share/${n}`}function em(n){return`https://www.loom.com/embed/${n}`}async function tm(n){const e=kn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=Mu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./index-BSpvs9Ep.js");return{oembed:a}},[],import.meta.url),{title:o,width:s,height:i}=await r(t);return{url:t,title:o||void 0,width:Number(s)||void 0,height:Number(i)||void 0}}catch{return{url:t}}}const Za=new Map;function hv(n){const e=n instanceof Error?n.message:String(n),t=e.toLowerCase(),r=t.indexOf("is not a function");return t.includes("render is not a function")||r>=0&&t.includes("render",r)?"The Loom recorder needs React 18 and this page runs React 19. See the Loom notes in the jupyter-lexical README to give it one.":`Loom could not start recording: ${e}`}function _v(n){let e=Za.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-dYYctHET.js");return{isSupported:f}},[],import.meta.url),{supported:r,error:o}=await t();if(!r)throw new Error(`this browser cannot record with Loom (${o})`);const{setup:s}=await me(async()=>{const{setup:f}=await import("./index-B0MhQWhs.js");return{setup:f}},[],import.meta.url),{configureButton:i}=await s({publicAppId:n}),a=i();let l;const c=new Map,u=f=>{let d=c.get(f.id);!d&&l&&(d=l,c.set(f.id,d)),d?.(f)};return a.on("recording-complete",u),a.on("upload-complete",u),a.on("insert-click",u),{record:f=>{l=f,a.openPreRecordPanel()}}})(),e.catch(()=>Za.delete(n)),Za.set(n,e)),e}function mv({video:n}){const e=kn(n.url);return e?x.jsx("div",{"data-lexical-loom-player":e,style:{position:"relative",width:"100%",aspectRatio:`${n.width||16} / ${n.height||9}`,borderRadius:6,overflow:"hidden",background:"var(--bgColor-muted, #f6f8fa)"},children:x.jsx("iframe",{src:em(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function bv({nodeKey:n}){const[e]=fe(),t=Hr(),[r,o]=S.useState(""),[s,i]=S.useState(),[a,l]=S.useState(),c=Tc(e,Q_)?.config.publicAppId??gv(e),u=S.useCallback(g=>{e.update(()=>{const h=Q(n);Du(h)&&h.setVideo(g)})},[e,n]),f=S.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await _v(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(g){l(hv(g))}finally{i(void 0)}}},[c,u]),d=S.useCallback(async()=>{if(!kn(r)){l("That is not the address of a Loom video: it looks like https://www.loom.com/share/…");return}l(void 0),i("embedding");try{u(await tm(r))}finally{i(void 0)}},[r,u]);return t?x.jsxs(Y,{"data-lexical-loom-placeholder":"",sx:{display:"grid",gap:2,p:3,border:"1px dashed",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Ws,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:0},children:"Recorded with Loom: Loom asks you to sign in to your Loom account, and the video is saved there, so it stays in the document."}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[x.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),x.jsx(vn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:g=>o(g.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),d())},sx:{flex:"1 1 240px"}}),x.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&x.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[x.jsx(Fp,{size:16}),x.jsxs(Le,{children:["Recording with Loom is off in this editor: it was given no Loom public app id, and without one Loom cannot open to let you sign in. Its host passes the id to ",x.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function yv({className:n,format:e,nodeKey:t,video:r}){return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:kn(r.url)?x.jsx(mv,{video:r}):x.jsx(bv,{nodeKey:t})})}function wv(n){const e=n.getAttribute("data-lexical-loom"),t=kn(e||n.getAttribute("src")||"");return t?{node:$u({url:Mu(t),title:n.getAttribute("title")||void 0})}:null}class Vo extends Jo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Vo({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=$u({url:e.url,title:e.title,width:e.width,height:e.height});return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"loom",version:1,url:this.__url,...this.__title?{title:this.__title}:{},...this.__width?{width:this.__width}:{},...this.__height?{height:this.__height}:{}}}static importDOM(){return{iframe:e=>e.hasAttribute("data-lexical-loom")||kn(e.getAttribute("src")||"")?{conversion:wv,priority:1}:null}}exportDOM(){const e=kn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",em(e)),t.setAttribute("title",this.__title||"Loom video"),t.setAttribute("width",String(this.__width||640)),t.setAttribute("height",String(this.__height||360)),t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),{element:t}}constructor(e={url:""},t,r){super(t,r),this.__url=e.url,this.__title=e.title,this.__width=e.width,this.__height=e.height}getVideo(){const e=this.getLatest();return{url:e.__url,title:e.__title,width:e.__width,height:e.__height}}setVideo(e){const t=this.getWritable();t.__url=e.url,t.__title=e.title,t.__width=e.width,t.__height=e.height}getTextContent(){return this.__url}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(yv,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),video:{url:this.__url,title:this.__title,width:this.__width,height:this.__height}})}isTopLevel(){return!0}}function $u(n){return new Vo(n)}function Du(n){return n instanceof Vo}function xv(n,e){const t={};for(const r of n){const o=e(r);t[o]?t[o].push(r):t[o]=[r]}return t}function Cv(n){const e=xv(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const Jf=/[!-/:-@[-`{-~\s]/,Sv=/^\s{0,3}$/,qf=/^```(\w{1,10})?\s?$/;function vv(n){const e=Cv(n),t=Nv(e.textFormat);return r=>{const o=r.split(`
84
+ `;let Ga=!1;function Tu(){if(Ga||typeof document>"u")return;if(document.getElementById(Hf)){Ga=!0;return}const n=document.createElement("style");n.id=Hf,n.textContent=rv,document.head.appendChild(n),Ga=!0}const ov={background:"var(--bgColor-muted, #f8f8f8)",border:"1px solid var(--borderColor-default, #e0e0e0)",borderRadius:"6px",margin:"12px 0",padding:"0",overflow:"hidden"},sv={cursor:"pointer",padding:"12px 12px 12px 36px",position:"relative",fontWeight:"600",fontSize:"14px",listStyle:"none",display:"block",outline:"none",color:"var(--fgColor-default, #333)",userSelect:"none",transition:"background-color 0.15s ease",margin:"0",WebkitAppearance:"none"},iv={padding:"12px 16px 16px 36px"};function Iu(n,e){for(const[t,r]of Object.entries(e))r!=null&&(n.style[t]=r)}function av(n){const e=n.open!==void 0?n.open:!0;return{node:Eu(e)}}class Mr extends Oe{__open;constructor(e,t){super(t),this.__open=e}static getType(){return"collapsible-container"}static clone(e){return new Mr(e.__open,e.__key)}isShadowRoot(){return!0}collapseAtStart(e){const t=[];for(const s of this.getChildren())q(s)&&t.push(...s.getChildren());Dc(gt(this,"previous")).splice(1,t);const[o]=t;return o&&o.selectStart().deleteCharacter(!0),!0}createDOM(e,t){Tu();let r;if($i)r=document.createElement("div"),r.setAttribute("open","");else{const o=document.createElement("details");o.open=this.__open,o.addEventListener("toggle",()=>{t.getEditorState().read(()=>this.getOpen())!==o.open&&t.update(()=>this.toggleOpen())}),r=o}return r.classList.add("Collapsible__container"),Iu(r,ov),r}updateDOM(e,t){const r=this.__open;if(e.__open!==r)if($i){const o=t.children[1];if(!ke(o))throw new Error("Expected contentDom to be an HTMLElement");r?(t.setAttribute("open",""),o.hidden=!1):(t.removeAttribute("open"),G_(o))}else t.open=this.__open;return!1}static importDOM(){return{details:e=>({conversion:av,priority:1})}}static importJSON(e){return Eu(e.open).updateFromJSON(e)}exportDOM(){const e=document.createElement("details");return e.classList.add("Collapsible__container"),e.setAttribute("open",this.__open.toString()),{element:e}}exportJSON(){return{...super.exportJSON(),open:this.__open}}setOpen(e){const t=this.getWritable();t.__open=e}getOpen(){return this.getLatest().__open}toggleOpen(){this.setOpen(!this.getOpen())}}function Eu(n){return new Mr(n)}function Pt(n){return n instanceof Mr}function lv(n){return{node:Nu()}}class $r extends Oe{static getType(){return"collapsible-content"}static clone(e){return new $r(e.__key)}createDOM(e,t){Tu();const r=document.createElement("div");return r.classList.add("Collapsible__content"),Iu(r,iv),$i&&(t.getEditorState().read(()=>{const o=this.getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||G_(r)}),nv(r,()=>{t.update(()=>{const o=this.getParentOrThrow().getLatest();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.__open||o.toggleOpen()})})),r}updateDOM(e,t){return!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-collapsible-content")?{conversion:lv,priority:2}:null}}exportDOM(){const e=document.createElement("div");return e.classList.add("Collapsible__content"),e.setAttribute("data-lexical-collapsible-content","true"),{element:e}}static importJSON(e){return Nu().updateFromJSON(e)}isShadowRoot(){return!0}}function Nu(){return new $r}function Lu(n){return n instanceof $r}function cv(n){return{node:Z_()}}class Os extends Oe{$config(){return this.config("collapsible-title",{$transform(e){e.isEmpty()&&e.remove()},extends:Oe,importDOM:$c({summary:()=>({conversion:cv,priority:1})})})}createDOM(e,t){Tu();const r=document.createElement("summary");return r.classList.add("Collapsible__title"),Iu(r,sv),$i&&r.addEventListener("click",()=>{t.update(()=>{const o=this.getLatest().getParentOrThrow();if(!Pt(o))throw new Error("Expected parent node to be a CollapsibleContainerNode");o.toggleOpen()})}),r}updateDOM(e,t){return!1}insertNewAfter(e,t=!0){const r=this.getParentOrThrow();if(!Pt(r))throw new Error("CollapsibleTitleNode expects to be child of CollapsibleContainerNode");if(r.getOpen()){const o=this.getNextSibling();if(!Lu(o))throw new Error("CollapsibleTitleNode expects to have CollapsibleContentNode sibling");const s=o.getFirstChild();if(q(s))return s;{const i=ne();return o.append(i),i}}else{const o=ne();return r.insertAfter(o,t),o}}}function Z_(){return new Os}function xi(n){return n instanceof Os}function uv(n){const t=window.getComputedStyle(n).getPropertyValue("grid-template-columns");return t?{node:Ou(t)}:null}class Dr extends Oe{__templateColumns;constructor(e,t){super(t),this.__templateColumns=e}static getType(){return"layout-container"}static clone(e){return new Dr(e.__templateColumns,e.__key)}createDOM(e){const t=document.createElement("div");return t.style.gridTemplateColumns=this.__templateColumns,typeof e.theme.layoutContainer=="string"&&Ie(t,e.theme.layoutContainer),t}exportDOM(){const e=document.createElement("div");return e.style.gridTemplateColumns=this.__templateColumns,e.setAttribute("data-lexical-layout-container","true"),{element:e}}updateDOM(e,t){return e.__templateColumns!==this.__templateColumns&&(t.style.gridTemplateColumns=this.__templateColumns),!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-container")?{conversion:uv,priority:2}:null}}static importJSON(e){return Ou().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTemplateColumns(e.templateColumns)}isShadowRoot(){return!0}canBeEmpty(){return!1}exportJSON(){return{...super.exportJSON(),templateColumns:this.__templateColumns}}getTemplateColumns(){return this.getLatest().__templateColumns}setTemplateColumns(e){const t=this.getWritable();return t.__templateColumns=e,t}}function Ou(n=""){return new Dr(n)}function Ci(n){return n instanceof Dr}function dv(){return{node:Ru()}}function fv(n){if(!Au(n)||n.getChildrenSize()!==1)return!1;const e=n.getFirstChild();return ht(e)&&e.isEmpty()}class Pr extends Oe{constructor(e){super(e)}static getType(){return"layout-item"}static clone(e){return new Pr(e.__key)}createDOM(e){const t=document.createElement("div");return t.setAttribute("data-lexical-layout-item","true"),typeof e.theme.layoutItem=="string"&&Ie(t,e.theme.layoutItem),t}updateDOM(){return!1}collapseAtStart(){const e=this.getParentOrThrow();return this.is(e.getFirstChild())&&e.getChildren().every(fv)?(e.remove(),!0):!1}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-layout-item")?{conversion:dv,priority:2}:null}}static importJSON(e){return Ru().updateFromJSON(e)}isShadowRoot(){return!0}}function Ru(){return new Pr}function Au(n){return n instanceof Pr}const Q_="@datalayer/jupyter-lexical/Loom",ls=new WeakMap;function UM(n,e){return e?ls.set(n,e):ls.delete(n),()=>{ls.get(n)===e&&ls.delete(n)}}function gv(n){return ls.get(n)}const pv=/^https?:\/\/(?:www\.)?loom\.com\/(?:share|embed)\/(?:[^/?#]*-)?([0-9a-f]{32})(?:[/?#].*)?$/i;function kn(n){const e=pv.exec(n.trim());return e?e[1].toLowerCase():null}function Mu(n){return`https://www.loom.com/share/${n}`}function em(n){return`https://www.loom.com/embed/${n}`}async function tm(n){const e=kn(n);if(!e)throw new Error(`Not a Loom video address: ${n}`);const t=Mu(e);try{const{oembed:r}=await me(async()=>{const{oembed:a}=await import("./index-BSpvs9Ep.js");return{oembed:a}},[],import.meta.url),{title:o,width:s,height:i}=await r(t);return{url:t,title:o||void 0,width:Number(s)||void 0,height:Number(i)||void 0}}catch{return{url:t}}}const Za=new Map;function hv(n){const e=n instanceof Error?n.message:String(n),t=e.toLowerCase(),r=t.indexOf("is not a function");return t.includes("render is not a function")||r>=0&&t.includes("render",r)?"The Loom recorder needs React 18 and this page runs React 19. See the Loom notes in the jupyter-lexical README to give it one.":`Loom could not start recording: ${e}`}function _v(n){let e=Za.get(n);return e||(e=(async()=>{const{isSupported:t}=await me(async()=>{const{isSupported:f}=await import("./is-supported-dYYctHET.js");return{isSupported:f}},[],import.meta.url),{supported:r,error:o}=await t();if(!r)throw new Error(`this browser cannot record with Loom (${o})`);const{setup:s}=await me(async()=>{const{setup:f}=await import("./index-CRZ1qthh.js");return{setup:f}},[],import.meta.url),{configureButton:i}=await s({publicAppId:n}),a=i();let l;const c=new Map,u=f=>{let d=c.get(f.id);!d&&l&&(d=l,c.set(f.id,d)),d?.(f)};return a.on("recording-complete",u),a.on("upload-complete",u),a.on("insert-click",u),{record:f=>{l=f,a.openPreRecordPanel()}}})(),e.catch(()=>Za.delete(n)),Za.set(n,e)),e}function mv({video:n}){const e=kn(n.url);return e?x.jsx("div",{"data-lexical-loom-player":e,style:{position:"relative",width:"100%",aspectRatio:`${n.width||16} / ${n.height||9}`,borderRadius:6,overflow:"hidden",background:"var(--bgColor-muted, #f6f8fa)"},children:x.jsx("iframe",{src:em(e),title:n.title||"Loom video",allow:"fullscreen; picture-in-picture",style:{position:"absolute",inset:0,width:"100%",height:"100%",border:0}})}):null}function bv({nodeKey:n}){const[e]=fe(),t=Hr(),[r,o]=S.useState(""),[s,i]=S.useState(),[a,l]=S.useState(),c=Tc(e,Q_)?.config.publicAppId??gv(e),u=S.useCallback(g=>{e.update(()=>{const h=Q(n);Du(h)&&h.setVideo(g)})},[e,n]),f=S.useCallback(async()=>{if(c){l(void 0),i("recording");try{(await _v(c)).record(h=>u({url:h.sharedUrl,title:h.title,width:h.width,height:h.height}))}catch(g){l(hv(g))}finally{i(void 0)}}},[c,u]),d=S.useCallback(async()=>{if(!kn(r)){l("That is not the address of a Loom video: it looks like https://www.loom.com/share/…");return}l(void 0),i("embedding");try{u(await tm(r))}finally{i(void 0)}},[r,u]);return t?x.jsxs(Y,{"data-lexical-loom-placeholder":"",sx:{display:"grid",gap:2,p:3,border:"1px dashed",borderColor:"border.default",borderRadius:2,bg:"canvas.subtle"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Ws,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Loom Video"})]}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:0},children:"Recorded with Loom: Loom asks you to sign in to your Loom account, and the video is saved there, so it stays in the document."}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",gap:2,alignItems:"center"},children:[x.jsx(ft,{variant:"primary",onClick:()=>{f()},disabled:!c||s!==void 0,children:s==="recording"?"Starting…":"Record"}),x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"or"}),x.jsx(vn,{"aria-label":"Address of a Loom video",placeholder:"https://www.loom.com/share/…",value:r,onChange:g=>o(g.target.value),onFocus:()=>e.update(()=>Ee(null)),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),d())},sx:{flex:"1 1 240px"}}),x.jsx(ft,{onClick:()=>{d()},disabled:!r.trim()||s!==void 0,children:s==="embedding"?"Embedding…":"Embed"})]}),!c&&x.jsxs(Y,{"data-lexical-loom-no-app-id":"",sx:{display:"flex",gap:2,alignItems:"flex-start",color:"attention.fg",fontSize:1},children:[x.jsx(Fp,{size:16}),x.jsxs(Le,{children:["Recording with Loom is off in this editor: it was given no Loom public app id, and without one Loom cannot open to let you sign in. Its host passes the id to ",x.jsx("code",{children:"LoomExtension"}),". A Loom video can still be embedded by its address."]})]}),a&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a})]}):x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A Loom video goes here."})}function yv({className:n,format:e,nodeKey:t,video:r}){return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:kn(r.url)?x.jsx(mv,{video:r}):x.jsx(bv,{nodeKey:t})})}function wv(n){const e=n.getAttribute("data-lexical-loom"),t=kn(e||n.getAttribute("src")||"");return t?{node:$u({url:Mu(t),title:n.getAttribute("title")||void 0})}:null}class Vo extends Jo{__url;__title;__width;__height;static getType(){return"loom"}static clone(e){return new Vo({url:e.__url,title:e.__title,width:e.__width,height:e.__height},e.__format,e.__key)}static importJSON(e){const t=$u({url:e.url,title:e.title,width:e.width,height:e.height});return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"loom",version:1,url:this.__url,...this.__title?{title:this.__title}:{},...this.__width?{width:this.__width}:{},...this.__height?{height:this.__height}:{}}}static importDOM(){return{iframe:e=>e.hasAttribute("data-lexical-loom")||kn(e.getAttribute("src")||"")?{conversion:wv,priority:1}:null}}exportDOM(){const e=kn(this.__url);if(!e)return{element:null};const t=document.createElement("iframe");return t.setAttribute("data-lexical-loom",this.__url),t.setAttribute("src",em(e)),t.setAttribute("title",this.__title||"Loom video"),t.setAttribute("width",String(this.__width||640)),t.setAttribute("height",String(this.__height||360)),t.setAttribute("frameborder","0"),t.setAttribute("allowfullscreen","true"),{element:t}}constructor(e={url:""},t,r){super(t,r),this.__url=e.url,this.__title=e.title,this.__width=e.width,this.__height=e.height}getVideo(){const e=this.getLatest();return{url:e.__url,title:e.__title,width:e.__width,height:e.__height}}setVideo(e){const t=this.getWritable();t.__url=e.url,t.__title=e.title,t.__width=e.width,t.__height=e.height}getTextContent(){return this.__url}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(yv,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),video:{url:this.__url,title:this.__title,width:this.__width,height:this.__height}})}isTopLevel(){return!0}}function $u(n){return new Vo(n)}function Du(n){return n instanceof Vo}function xv(n,e){const t={};for(const r of n){const o=e(r);t[o]?t[o].push(r):t[o]=[r]}return t}function Cv(n){const e=xv(n,t=>t.type);return{element:e.element||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const Jf=/[!-/:-@[-`{-~\s]/,Sv=/^\s{0,3}$/,qf=/^```(\w{1,10})?\s?$/;function vv(n){const e=Cv(n),t=Nv(e.textFormat);return r=>{const o=r.split(`
85
85
  `),s=o.length,i=se();for(let l=0;l<s;l++){const c=o[l],[u,f]=Iv(o,l,i);if(u!=null){l=f;continue}Tv(c,i,e.element,t,e.textMatch)}const a=i.getChildren();for(const l of a)kv(l)&&l.remove();i.selectEnd()}}function kv(n){if(!ht(n))return!1;const e=n.getFirstChild();return e==null||n.getChildrenSize()===1&&oe(e)&&Sv.test(e.getTextContent())}function Tv(n,e,t,r,o){const s=n.trim(),i=$e(s),a=ne();a.append(i),e.append(a);for(const{regExp:l,replace:c}of t){const u=n.match(l);if(u){i.setTextContent(n.slice(u[0].length)),c(a,[i],u,!0);break}}if(Si(i,r,o),a.isAttached()&&s.length>0){const l=a.getPreviousSibling();if(ht(l)||Vn(l)||Z(l)){let c=l;if(Z(l)){const u=l.getLastDescendant();u==null?c=null:c=re(u,le)}c!=null&&c.getTextContentSize()>0&&(c.splice(c.getChildrenSize(),0,[vt(),...a.getChildren()]),a.remove())}}}function Iv(n,e,t){const r=n[e].match(qf);if(r){let o=e;const s=n.length;for(;++o<s;)if(n[o].match(qf)){const a=qr(r[1]),l=$e(n.slice(e+1,o).join(`
86
86
  `));return a.append(l),t.append(a),[a,o]}}return[null,e]}function Si(n,e,t){const r=n.getTextContent(),o=Ev(r,e);if(!o){nm(n,t);return}let s,i,a;if(o[0]===r)s=n;else{const c=o.index||0,u=c+o[0].length;c===0?[s,i]=n.splitText(u):[a,s,i]=n.splitText(c,u)}s.setTextContent(o[2]);const l=e.transformersByTag[o[1]];if(l)for(const c of l.format)s.hasFormat(c)||s.toggleFormat(c);s.hasFormat("code")||Si(s,e,t),a&&Si(a,e,t),i&&Si(i,e,t)}function nm(n,e){let t=n;e:for(;t;){for(const r of e){const o=t.getTextContent().match(r.importRegExp);if(!o)continue;const s=o.index||0,i=s+o[0].length;let a,l;s===0?[a,t]=t.splitText(i):[,a,l]=t.splitText(s,i),l&&nm(l,e),r.replace(a,o);continue e}break}}function Ev(n,e){const t=n.match(e.openTagsRegExp);if(t==null)return null;for(const r of t){const o=r.replace(/^\s/,""),s=e.fullMatchRegExpByTag[o];if(s==null)continue;const i=n.match(s),a=e.transformersByTag[o];if(i!=null&&a!=null){if(a.intraword!==!1)return i;const{index:l=0}=i,c=n[l-1],u=n[l+i[0].length];if((!c||Jf.test(c))&&(!u||Jf.test(u)))return i}}return null}function Nv(n){const e={},t={},r=[];for(const o of n){const{tag:s}=o;e[s]=o;const i=s.replace(/(\*|\^)/g,"\\$1");r.push(i),t[s]=new RegExp(`(${i})(?![${i}\\s])(.*?[^${i}\\s])${i}(?!${i})`)}return{fullMatchRegExpByTag:t,openTagsRegExp:new RegExp("("+r.join("|")+")","g"),transformersByTag:e}}const rm=n=>(e,t,r)=>{const o=n(r);o.append(...t),e.replace(o),o.select(0,0)},om=4,Pu=n=>(e,t,r)=>{const o=e.getPreviousSibling(),s=xt(n==="check"?r[3]==="x":void 0);if(Z(o)&&o.getListType()===n)o.append(s),e.remove();else{const a=Et(n,n==="number"?Number(r[2]):void 0);a.append(s),e.replace(a)}s.append(...t),s.select(0,0);const i=Math.floor(r[1].length/om);i&&s.setIndent(i)},va=(n,e,t)=>{const r=[],o=n.getChildren();let s=0;for(const i of o)if(le(i)){if(i.getChildrenSize()===1){const u=i.getFirstChild();if(Z(u)){r.push(va(u,e,t+1));continue}}const a=" ".repeat(t*om),l=n.getListType(),c=l==="number"?`${n.getStart()+s}. `:l==="check"?`- [${i.getChecked()?"x":" "}] `:"- ";r.push(a+c+e(i)),s++}return r.join(`
87
87
  `)},Lv={dependencies:[qs],export:(n,e)=>{if(!Wr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:/^(#{1,6})\s/,replace:rm(n=>{const e="h"+n[1].length;return fn(e)}),type:"element"},Ov={dependencies:[Js],export:(n,e)=>{if(!Vn(n))return null;const t=e(n).split(`
88
88
  `),r=[];for(const o of t)r.push("> "+o);return r.join(`
89
89
  `)},regExp:/^>\s/,replace:(n,e,t,r)=>{if(r){const s=n.getPreviousSibling();if(Vn(s)){s.splice(s.getChildrenSize(),0,[vt(),...e]),s.select(0,0),n.remove();return}}const o=Ln();o.append(...e),n.replace(o),o.select(0,0)},type:"element"},Rv={dependencies:[Nt],export:n=>{if(!st(n))return null;const e=n.getTextContent();return"```"+(n.getLanguage()||"")+(e?`
90
- `+e:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:rm(n=>qr(n?n[1]:void 0)),type:"element"},Av={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Pu("bullet"),type:"element"},Mv={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Pu("check"),type:"element"},$v={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:Pu("number"),type:"element"},Dv={format:["code"],tag:"`",type:"text-format"},Pv={format:["bold","italic"],tag:"***",type:"text-format"},jv={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Fv={format:["bold"],tag:"**",type:"text-format"},Bv={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Uv={format:["strikethrough"],tag:"~~",type:"text-format"},zv={format:["italic"],tag:"*",type:"text-format"},Kv={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Wv={dependencies:[gn],export:(n,e,t)=>{if(!Pe(n))return null;const r=`[${n.getTextContent()}](${n.getURL()})`,o=n.getFirstChild();return n.getChildrenSize()===1&&oe(o)?t(o,r):r},importRegExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))/,regExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=Mo(r),s=$e(t);s.setFormat(n.getFormat()),o.append(s),n.replace(o)},trigger:")",type:"text-match"},sm=[Lv,Ov,Rv,Av,$v],im=[Dv,Pv,jv,Fv,Bv,zv,Kv,Uv],am=[Wv],Hv=[...sm,...im,...am];function zM(n,e=Hv){return vv(e)(n)}const Jv={dependencies:[mu],export:n=>ch(n)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const o=ba();r||n.getNextSibling()!=null?n.replace(o):n.insertBefore(o)},type:"element"},qv={dependencies:[Jr],export:(n,e,t)=>Hn(n)?`![${n.getAltText()}](${n.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=xa({altText:t,maxWidth:800,src:r});n.replace(o)},trigger:")",type:"text-match"},Vv={dependencies:[ir],export:n=>{if(!ht(n)||n.getChildrenSize()!==1)return null;const e=n.getFirstChild();return!Rr(e)||e.__inline?null:`$$${e.getEquation()}$$`},regExp:/^\$\$(.+?)\$\$\s?$/,replace:(n,e,t)=>{const r=ne();r.append(ya(t[1].trim(),!1)),n.replace(r)},type:"element"},Yv={dependencies:[ir],export:(n,e,t)=>Rr(n)?`$${n.getEquation()}$`:null,importRegExp:/\$([^$].+?)\$/,regExp:/\$([^$].+?)\$$/,replace:(n,e)=>{const[,t]=e,r=ya(t,!0);n.replace(r)},trigger:"$",type:"text-match"},lm=/^(?:\|)(.+)(?:\|)\s?$/,Gv=/^:?-+:?$/,Xv={dependencies:[Xt,Wo,Gt],export:(n,e)=>{if(!be(n))return null;const t=[];for(const r of n.getChildren()){const o=[];if(ce(r))for(const s of r.getChildren())q(s)&&o.push(e(s));t.push(`| ${o.join(" | ")} |`),t.length===1&&ce(r)&&r.getChildrenSize()>0&&r.getChildren().every(s=>J(s)&&s.hasHeader())&&t.push(`| ${o.map(()=>"---").join(" | ")} |`)}return t.join(`
91
- `)},regExp:lm,replace:(n,e,t)=>{const r=Vf(t[0]);if(r==null)return;const o=[r];let s=n.getPreviousSibling(),i=r.length;for(;s&&!(!ht(s)||s.getChildrenSize()!==1);){const f=s.getFirstChild();if(!oe(f))break;const d=Vf(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const g=s.getPreviousSibling();s.remove(),s=g}const a=o.findIndex(f=>f.every(d=>Gv.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(g=>{J(g)&&g.setHeaderStyles(te.ROW,te.ROW)}),n.remove();return}}const l=a>0?a:0;if(a>=0&&o.splice(a,1),o.length===0){n.remove();return}const c=Ho();for(const[f,d]of o.entries()){const g=pn();c.append(g);for(let h=0;h<i;h++){const _=h<d.length?d[h]:cm(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),g.append(_)}}const u=n.getPreviousSibling();be(u)&&Zv(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function Zv(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const cm=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append($e(n.trim())),e.append(t),e},Vf=n=>{const e=n.match(lm);return!e||!e[1]?null:e[1].split("|").map(t=>cm(t))},Qv=[Vv,Xv,Jv,qv,Yv,Mv,...sm,...im,...am],e1=S.lazy(()=>me(()=>import("./ExcalidrawComponent-CbghNk-F.js"),[],import.meta.url));function t1(n){const e=n.getAttribute("data-lexical-excalidraw-json"),t=window.getComputedStyle(n),r=t.getPropertyValue("height"),o=t.getPropertyValue("width"),s=!r||r==="inherit"?"inherit":parseInt(r,10),i=!o||o==="inherit"?"inherit":parseInt(o,10);return e?{node:ju(e,i,s)}:null}class Yn extends Bt{__data;__width;__height;static getType(){return"excalidraw"}static clone(e){return new Yn(e.__data,e.__width,e.__height,e.__key)}static importJSON(e){return new Yn(e.data,e.width??"inherit",e.height??"inherit").updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),data:this.__data,height:this.__height==="inherit"?void 0:this.__height,width:this.__width==="inherit"?void 0:this.__width}}constructor(e="[]",t="inherit",r="inherit",o){super(o),this.__data=e,this.__width=t,this.__height=r}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}static importDOM(){return{span:e=>e.hasAttribute("data-lexical-excalidraw-json")?{conversion:t1,priority:1}:null}}exportDOM(e){const t=document.createElement("span");t.style.display="inline-block";const r=e.getElementByKey(this.getKey());if(r!==null){const o=r.querySelector("svg");o!==null&&(t.innerHTML=o.outerHTML)}return t.style.width=this.__width==="inherit"?"inherit":`${this.__width}px`,t.style.height=this.__height==="inherit"?"inherit":`${this.__height}px`,t.setAttribute("data-lexical-excalidraw-json",this.__data),{element:t}}setData(e){const t=this.getWritable();t.__data=e}getWidth(){return this.getLatest().__width}setWidth(e){const t=this.getWritable();t.__width=e}getHeight(){return this.getLatest().__height}setHeight(e){const t=this.getWritable();t.__height=e}decorate(e,t){return x.jsx(e1,{nodeKey:this.getKey(),data:this.__data,width:this.__width,height:this.__height})}}function ju(n="[]",e="inherit",t="inherit"){return new Yn(n,e,t)}function Fu(n){return n instanceof Yn}const n1=Object.freeze(Object.defineProperty({__proto__:null,$createExcalidrawNode:ju,$isExcalidrawNode:Fu,ExcalidrawNode:Yn},Symbol.toStringTag,{value:"Module"}));function r1(n,e){const t=n.split(/\s+/).map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r)&&r>0);return t.length===e?t:Array.from({length:e},()=>1)}function cc(n){const e=n.getFormatType();return e==="center"||e==="right"||e==="justify"?e:"left"}function fr(n,e){return Bu(n.getChildren(),e)}function Bu(n,e){const t=[];for(const r of n)if(ue(r))t.push({kind:"break"});else if(bt(r))t.push({kind:"text",text:" ",link:e});else if(oe(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,bold:r.hasFormat("bold"),italic:r.hasFormat("italic"),code:r.hasFormat("code"),underline:r.hasFormat("underline"),strikethrough:r.hasFormat("strikethrough"),subscript:r.hasFormat("subscript"),superscript:r.hasFormat("superscript"),highlight:r.hasFormat("highlight"),link:e})}else if(Pe(r))t.push(...fr(r,r.getURL()));else if(Rr(r))t.push({kind:"equation",equation:r.getEquation(),key:r.getKey()});else if(q(r))t.push(...fr(r,e));else if(It(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,link:e})}return t}function vi(n){const e=[],t=r=>{e.length&&r.length&&e.push({kind:"break"}),e.push(...r)};for(const r of n)switch(r.kind){case"heading":t(r.inlines.map(o=>o.kind==="text"?{...o,bold:!0}:o));break;case"paragraph":t(r.inlines);break;case"quote":case"collapsible":t(vi(r.blocks));break;case"list":r.items.forEach((o,s)=>{const i=r.ordered?`${r.start+s}. `:"• ";t([{kind:"text",text:i},...vi(o.blocks)])});break;case"code":t([{kind:"text",text:r.text,code:!0}]);break;case"equation":t([{kind:"equation",equation:r.equation,key:r.key}]);break;case"image":t([{kind:"text",text:r.alt||"[image]",italic:!0}]);break;case"embed":t([{kind:"text",text:r.label,link:r.url}]);break;case"table":r.rows.forEach(o=>t(o.flatMap((s,i)=>[...i?[{kind:"text",text:" | "}]:[],...s.inlines])));break;case"columns":r.columns.forEach(o=>t(vi(o)));break}return e}function o1(n){const e=[];for(const t of n.getChildren()){if(!le(t))continue;const r=t.getFirstChild();if(t.getChildrenSize()===1&&Z(r)){const i=Yi(r),a=e[e.length-1];a&&i?a.blocks.push(i):i&&e.push({checked:null,blocks:[i]});continue}const o=[],s=[];for(const i of t.getChildren()){if(q(i)&&!Pe(i)){const a=Yi(i);if(a&&a.kind!=="paragraph"){s.length&&(o.push({kind:"paragraph",inlines:[...s],align:"left",indent:0}),s.length=0),o.push(a);continue}}s.push(...Bu([i]))}(s.length||o.length===0)&&o.unshift({kind:"paragraph",inlines:s,align:"left",indent:0}),e.push({checked:n.getListType()==="check"?t.getChecked()===!0:null,blocks:o})}return e}function Yi(n){if(Wr(n))return{kind:"heading",level:Math.min(6,Math.max(1,Number(n.getTag().slice(1))||1)),inlines:fr(n),align:cc(n),indent:n.getIndent()};if(Vn(n))return{kind:"quote",blocks:[{kind:"paragraph",inlines:fr(n),align:"left",indent:0}]};if(Z(n))return{kind:"list",ordered:n.getListType()==="number",start:n.getStart(),items:o1(n)};if(st(n))return{kind:"code",language:n.getLanguage()??"python",text:n.getTextContent(),executable:!0,key:n.getKey()};if(je(n))return{kind:"code",language:n.getLanguage()??null,text:n.getTextContent(),executable:!1,key:n.getKey()};if(Cu(n))return{kind:"outputs",outputs:n.getOutputs(),key:n.getKey()};if(be(n)){const e=[];for(const t of n.getChildren()){if(!ce(t))continue;const r=[];for(const o of t.getChildren())J(o)&&r.push({header:o.hasHeader(),colSpan:Math.max(1,o.getColSpan()),inlines:vi(cs(o.getChildren()))});e.push(r)}return{kind:"table",rows:e}}if(Ci(n)){const e=n.getChildren().filter(Au),t=n.getTemplateColumns().trim(),r=Math.max(e.length,t?t.split(/\s+/).length:0);return{kind:"columns",weights:r1(n.getTemplateColumns(),r).slice(0,e.length),columns:e.map(o=>cs(o.getChildren()))}}if(Pt(n)){const e=n.getChildren().find(xi),t=n.getChildren().find(Lu);return{kind:"collapsible",title:e?fr(e):[],blocks:t?cs(t.getChildren()):[],open:n.getOpen()}}if(ch(n))return{kind:"rule"};if(Hn(n))return{kind:"image",src:n.getSrc(),alt:n.getAltText(),key:n.getKey()};if(Rr(n))return{kind:"equation",equation:n.getEquation(),key:n.getKey()};if(W_(n)){const e=n.getId();return{kind:"embed",label:`YouTube video ${e}`,url:`https://www.youtube.com/watch?v=${e}`,key:n.getKey()}}if(Fu(n))return{kind:"drawing",key:n.getKey(),label:"Drawing"};if(Du(n)){const{url:e,title:t}=n.getVideo();return kn(e)?{kind:"embed",label:t?`Loom video: ${t}`:"Loom video",url:e,key:n.getKey()}:null}if(ht(n)){const e=fr(n),t=n.getChildrenSize()===1?n.getFirstChild():null;return t&&Rr(t)&&!t.__inline?{kind:"equation",equation:t.getEquation(),key:t.getKey()}:t&&Hn(t)?{kind:"image",src:t.getSrc(),alt:t.getAltText(),key:t.getKey()}:{kind:"paragraph",inlines:e,align:cc(n),indent:n.getIndent()}}if(q(n)){const e=cs(n.getChildren());if(e.length)return e.length===1?e[0]:{kind:"quote",blocks:e};const t=fr(n);return t.length?{kind:"paragraph",inlines:t,align:"left",indent:0}:null}return It(n)?{kind:"drawing",key:n.getKey(),label:n.getTextContent()||n.getType()}:null}function um(n){return q(n)&&!Pe(n)&&!n.isInline()&&!ht(n)||be(n)||Z(n)||je(n)||Hn(n)||Fu(n)||W_(n)||Du(n)||Rr(n)&&!n.__inline}function s1(n){const e=[];let t=[];const r=()=>{if(t.length){const o=Bu(t);o.length&&e.push({kind:"paragraph",inlines:o,align:cc(n),indent:n.getIndent()}),t=[]}};for(const o of n.getChildren())if(um(o)){r();const s=Yi(o);s&&e.push(s)}else t.push(o);return r(),e}function cs(n){const e=[];for(const t of n){if(ht(t)&&t.getChildren().some(um)){e.push(...s1(t));continue}const r=Yi(t);r&&e.push(r)}return e}function dm(n){return n.map(e=>e.kind==="text"?e.text:e.kind==="break"?`
92
- `:e.equation).join("")}function i1(){const n=cs(se().getChildren()),e=n.find(t=>t.kind==="heading");return{blocks:n,title:e&&e.kind==="heading"?dm(e.inlines):null}}function Uu(n){return n.getEditorState().read(i1)}const fi=["Helvetica","Helvetica-Bold","Helvetica-Oblique","Helvetica-BoldOblique","Courier","Courier-Bold"],Yf=[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],Gf=[278,333,474,556,556,889,722,238,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,333,333,584,584,584,611,975,722,722,722,722,667,611,778,722,278,556,722,611,833,722,778,667,778,722,667,611,722,667,944,667,667,611,333,278,333,584,556,333,556,611,556,611,556,333,611,611,278,278,556,278,889,611,611,611,611,389,556,333,611,556,778,556,556,500,389,280,389,584],a1={"—":[1e3,1e3],"–":[556,556],"•":[350,350],"‘":[222,278],"’":[222,278],"“":[333,500],"”":[333,500],"…":[1e3,1e3],"€":[556,556],"·":[278,278],"×":[584,584],"°":[400,400],"±":[584,584]," ":[278,278],"©":[737,737],"®":[737,737],"™":[1e3,1e3],"«":[556,556],"»":[556,556],"§":[556,556],"¶":[537,556]},l1={"−":"-","→":"->","←":"<-","⇒":"=>","≤":"<=","≥":">=","≠":"!=","≈":"~","∎":"#","■":"#","□":"[ ]","☐":"[ ]","☑":"[x]","☒":"[x]","✓":"v","✔":"v","▸":">","▾":"v"," ":" "," ":" "," ":" ","​":"","\uFEFF":"","­":""},Xf={"€":128,"‚":130,ƒ:131,"„":132,"…":133,"†":134,"‡":135,"ˆ":136,"‰":137,Š:138,"‹":139,Œ:140,Ž:142,"‘":145,"’":146,"“":147,"”":148,"•":149,"–":150,"—":151,"˜":152,"™":153,š:154,"›":155,œ:156,ž:158,Ÿ:159};function c1(n){const e=[];let t="";for(const r of n){const o=l1[r],s=o!==void 0?o:r;for(const i of s){const a=i.codePointAt(0)??63;if(a<128||a>=160&&a<=255)e.push(a),t+=i;else if(Xf[i]!==void 0)e.push(Xf[i]),t+=i;else{const l=i.normalize("NFD").replace(/[̀-ͯ]/g,""),c=l.codePointAt(0)??63;l.length===1&&c<128?(e.push(c),t+=l):(e.push(63),t+="?")}}}return{bytes:e,text:t}}function u1(n){return n==="Helvetica-Bold"||n==="Helvetica-BoldOblique"}function d1(n,e){if(e==="Courier"||e==="Courier-Bold")return 600;const t=u1(e),r=n.codePointAt(0)??32;if(r>=32&&r<=126)return(t?Gf:Yf)[r-32];const o=a1[n];if(o)return o[t?1:0];const s=n.normalize("NFD").replace(/[̀-ͯ]/g,""),i=s.codePointAt(0)??32;return s.length===1&&i>=32&&i<=126?(t?Gf:Yf)[i-32]:t?611:556}function cr(n,e,t){let r=0;for(const o of n)r+=d1(o,e);return r*t/1e3}function Zf(n){return n.code?n.bold?"Courier-Bold":"Courier":n.bold&&n.italic?"Helvetica-BoldOblique":n.bold?"Helvetica-Bold":n.italic?"Helvetica-Oblique":"Helvetica"}const Rs={a4:{width:595.28,height:841.89},letter:{width:612,height:792}};function gi(n){if(typeof n=="string"){const e=n.replace("#",""),t=e.length===3?e.split("").map(a=>a+a).join(""):e,r=parseInt(t,16),o=(r>>16&255)/255,s=(r>>8&255)/255,i=(r&255)/255;return`${Fe(o)} ${Fe(s)} ${Fe(i)}`}return n.map(Fe).join(" ")}function Fe(n){return Number.isInteger(n)?String(n):n.toFixed(3).replace(/\.?0+$/,"")}function fm(n){let e="";for(const t of n)e+=t.toString(16).padStart(2,"0");return e}function rs(n){const e=[254,255];for(let t=0;t<n.length;t++){const r=n.charCodeAt(t);e.push(r>>8,r&255)}return`<${fm(e)}>`}function f1(n){const e=t=>String(t).padStart(2,"0");return`D:${n.getUTCFullYear()}${e(n.getUTCMonth()+1)}${e(n.getUTCDate())}${e(n.getUTCHours())}${e(n.getUTCMinutes())}${e(n.getUTCSeconds())}Z`}class g1{index;width;height;fontName;ops=[];links=[];images=new Set;constructor(e,t,r,o){this.index=e,this.width=t,this.height=r,this.fontName=o}text(e,t,r,o,s,i="#000000"){const{bytes:a}=c1(r);a.length!==0&&this.ops.push(`BT ${gi(i)} rg /${this.fontName(o)} ${Fe(s)} Tf 1 0 0 1 ${Fe(e)} ${Fe(this.height-t)} Tm <${fm(a)}> Tj ET`)}rect(e,t,r,o,s){const i=["q"];s.fill&&i.push(`${gi(s.fill)} rg`),s.stroke&&i.push(`${gi(s.stroke)} RG ${Fe(s.lineWidth??.5)} w`),i.push(`${Fe(e)} ${Fe(this.height-t-o)} ${Fe(r)} ${Fe(o)} re`),i.push(s.fill&&s.stroke?"B":s.fill?"f":"S","Q"),this.ops.push(i.join(" "))}line(e,t,r,o,s="#000000",i=.5){this.ops.push(`q ${gi(s)} RG ${Fe(i)} w ${Fe(e)} ${Fe(this.height-t)} m ${Fe(r)} ${Fe(this.height-o)} l S Q`)}image(e,t,r,o,s){this.images.add(e.id),this.ops.push(`q ${Fe(o)} 0 0 ${Fe(s)} ${Fe(t)} ${Fe(this.height-r-s)} cm /Im${e.id} Do Q`)}link(e,t,r,o,s){this.links.push({rect:[e,this.height-t-o,e+r,this.height-t],url:s})}}class gm{options;pages=[];size;images=[];fonts=new Map;constructor(e={}){this.options=e,this.size=e.size??Rs.a4,fi.forEach((t,r)=>this.fonts.set(t,`F${r+1}`))}addPage(){const e=new g1(this.pages.length,this.size.width,this.size.height,t=>this.fonts.get(t)??"F1");return this.pages.push(e),e}addJpeg(e,t,r){const o={id:this.images.length+1,width:t,height:r,bytes:e};return this.images.push(o),o}build(){const e=new TextEncoder,t=[];let r=0;const o=C=>{const v=typeof C=="string"?p1(C):C;t.push(v),r+=v.length},s=[],i=(C,v)=>{s[C]=r,o(`${C} 0 obj
90
+ `+e:"")+"\n```"},regExp:/^```(\w{1,10})?\s/,replace:rm(n=>qr(n?n[1]:void 0)),type:"element"},Av={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)[-*+]\s/,replace:Pu("bullet"),type:"element"},Mv={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(?:-\s)?\s?(\[(\s|x)?\])\s/i,replace:Pu("check"),type:"element"},$v={dependencies:[Yt,bn],export:(n,e)=>Z(n)?va(n,e,0):null,regExp:/^(\s*)(\d{1,})\.\s/,replace:Pu("number"),type:"element"},Dv={format:["code"],tag:"`",type:"text-format"},Pv={format:["bold","italic"],tag:"***",type:"text-format"},jv={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},Fv={format:["bold"],tag:"**",type:"text-format"},Bv={format:["bold"],intraword:!1,tag:"__",type:"text-format"},Uv={format:["strikethrough"],tag:"~~",type:"text-format"},zv={format:["italic"],tag:"*",type:"text-format"},Kv={format:["italic"],intraword:!1,tag:"_",type:"text-format"},Wv={dependencies:[gn],export:(n,e,t)=>{if(!Pe(n))return null;const r=`[${n.getTextContent()}](${n.getURL()})`,o=n.getFirstChild();return n.getChildrenSize()===1&&oe(o)?t(o,r):r},importRegExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))/,regExp:/(?:\[([^[]+)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=Mo(r),s=$e(t);s.setFormat(n.getFormat()),o.append(s),n.replace(o)},trigger:")",type:"text-match"},sm=[Lv,Ov,Rv,Av,$v],im=[Dv,Pv,jv,Fv,Bv,zv,Kv,Uv],am=[Wv],Hv=[...sm,...im,...am];function zM(n,e=Hv){return vv(e)(n)}const Jv={dependencies:[mu],export:n=>ch(n)?"***":null,regExp:/^(---|\*\*\*|___)\s?$/,replace:(n,e,t,r)=>{const o=ba();r||n.getNextSibling()!=null?n.replace(o):n.insertBefore(o)},type:"element"},qv={dependencies:[Jr],export:(n,e,t)=>Hn(n)?`![${n.getAltText()}](${n.getSrc()})`:null,importRegExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))/,regExp:/!(?:\[([^[]*)\])(?:\(([^(]+)\))$/,replace:(n,e)=>{const[,t,r]=e,o=xa({altText:t,maxWidth:800,src:r});n.replace(o)},trigger:")",type:"text-match"},Vv={dependencies:[ir],export:n=>{if(!ht(n)||n.getChildrenSize()!==1)return null;const e=n.getFirstChild();return!Rr(e)||e.__inline?null:`$$${e.getEquation()}$$`},regExp:/^\$\$(.+?)\$\$\s?$/,replace:(n,e,t)=>{const r=ne();r.append(ya(t[1].trim(),!1)),n.replace(r)},type:"element"},Yv={dependencies:[ir],export:(n,e,t)=>Rr(n)?`$${n.getEquation()}$`:null,importRegExp:/\$([^$].+?)\$/,regExp:/\$([^$].+?)\$$/,replace:(n,e)=>{const[,t]=e,r=ya(t,!0);n.replace(r)},trigger:"$",type:"text-match"},lm=/^(?:\|)(.+)(?:\|)\s?$/,Xv=/^:?-+:?$/,Gv={dependencies:[Gt,Wo,Xt],export:(n,e)=>{if(!be(n))return null;const t=[];for(const r of n.getChildren()){const o=[];if(ce(r))for(const s of r.getChildren())q(s)&&o.push(e(s));t.push(`| ${o.join(" | ")} |`),t.length===1&&ce(r)&&r.getChildrenSize()>0&&r.getChildren().every(s=>J(s)&&s.hasHeader())&&t.push(`| ${o.map(()=>"---").join(" | ")} |`)}return t.join(`
91
+ `)},regExp:lm,replace:(n,e,t)=>{const r=Vf(t[0]);if(r==null)return;const o=[r];let s=n.getPreviousSibling(),i=r.length;for(;s&&!(!ht(s)||s.getChildrenSize()!==1);){const f=s.getFirstChild();if(!oe(f))break;const d=Vf(f.getTextContent());if(d==null)break;i=Math.max(i,d.length),o.unshift(d);const g=s.getPreviousSibling();s.remove(),s=g}const a=o.findIndex(f=>f.every(d=>Xv.test(d.getTextContent().trim())));if(a===0){const f=n.getPreviousSibling();if(be(f)){const d=f.getLastChild();ce(d)&&d.getChildren().forEach(g=>{J(g)&&g.setHeaderStyles(te.ROW,te.ROW)}),n.remove();return}}const l=a>0?a:0;if(a>=0&&o.splice(a,1),o.length===0){n.remove();return}const c=Ho();for(const[f,d]of o.entries()){const g=pn();c.append(g);for(let h=0;h<i;h++){const _=h<d.length?d[h]:cm(null);f<l&&_.setHeaderStyles(te.ROW,te.ROW),g.append(_)}}const u=n.getPreviousSibling();be(u)&&Zv(u)===i?(u.append(...c.getChildren()),n.remove()):n.replace(c),c.selectEnd()},type:"element"};function Zv(n){const e=n.getFirstChild();return ce(e)?e.getChildrenSize():0}const cm=n=>{const e=lt(te.NO_STATUS),t=ne();return n!=null&&t.append($e(n.trim())),e.append(t),e},Vf=n=>{const e=n.match(lm);return!e||!e[1]?null:e[1].split("|").map(t=>cm(t))},Qv=[Vv,Gv,Jv,qv,Yv,Mv,...sm,...im,...am],e1=S.lazy(()=>me(()=>import("./ExcalidrawComponent-vJQwgcUt.js"),[],import.meta.url));function t1(n){const e=n.getAttribute("data-lexical-excalidraw-json"),t=window.getComputedStyle(n),r=t.getPropertyValue("height"),o=t.getPropertyValue("width"),s=!r||r==="inherit"?"inherit":parseInt(r,10),i=!o||o==="inherit"?"inherit":parseInt(o,10);return e?{node:ju(e,i,s)}:null}class Yn extends Bt{__data;__width;__height;static getType(){return"excalidraw"}static clone(e){return new Yn(e.__data,e.__width,e.__height,e.__key)}static importJSON(e){return new Yn(e.data,e.width??"inherit",e.height??"inherit").updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),data:this.__data,height:this.__height==="inherit"?void 0:this.__height,width:this.__width==="inherit"?void 0:this.__width}}constructor(e="[]",t="inherit",r="inherit",o){super(o),this.__data=e,this.__width=t,this.__height=r}createDOM(e){const t=document.createElement("span"),o=e.theme.image;return o!==void 0&&(t.className=o),t}updateDOM(){return!1}static importDOM(){return{span:e=>e.hasAttribute("data-lexical-excalidraw-json")?{conversion:t1,priority:1}:null}}exportDOM(e){const t=document.createElement("span");t.style.display="inline-block";const r=e.getElementByKey(this.getKey());if(r!==null){const o=r.querySelector("svg");o!==null&&(t.innerHTML=o.outerHTML)}return t.style.width=this.__width==="inherit"?"inherit":`${this.__width}px`,t.style.height=this.__height==="inherit"?"inherit":`${this.__height}px`,t.setAttribute("data-lexical-excalidraw-json",this.__data),{element:t}}setData(e){const t=this.getWritable();t.__data=e}getWidth(){return this.getLatest().__width}setWidth(e){const t=this.getWritable();t.__width=e}getHeight(){return this.getLatest().__height}setHeight(e){const t=this.getWritable();t.__height=e}decorate(e,t){return x.jsx(e1,{nodeKey:this.getKey(),data:this.__data,width:this.__width,height:this.__height})}}function ju(n="[]",e="inherit",t="inherit"){return new Yn(n,e,t)}function Fu(n){return n instanceof Yn}const n1=Object.freeze(Object.defineProperty({__proto__:null,$createExcalidrawNode:ju,$isExcalidrawNode:Fu,ExcalidrawNode:Yn},Symbol.toStringTag,{value:"Module"}));function r1(n,e){const t=n.split(/\s+/).map(r=>parseFloat(r)).filter(r=>!Number.isNaN(r)&&r>0);return t.length===e?t:Array.from({length:e},()=>1)}function cc(n){const e=n.getFormatType();return e==="center"||e==="right"||e==="justify"?e:"left"}function fr(n,e){return Bu(n.getChildren(),e)}function Bu(n,e){const t=[];for(const r of n)if(ue(r))t.push({kind:"break"});else if(bt(r))t.push({kind:"text",text:" ",link:e});else if(oe(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,bold:r.hasFormat("bold"),italic:r.hasFormat("italic"),code:r.hasFormat("code"),underline:r.hasFormat("underline"),strikethrough:r.hasFormat("strikethrough"),subscript:r.hasFormat("subscript"),superscript:r.hasFormat("superscript"),highlight:r.hasFormat("highlight"),link:e})}else if(Pe(r))t.push(...fr(r,r.getURL()));else if(Rr(r))t.push({kind:"equation",equation:r.getEquation(),key:r.getKey()});else if(q(r))t.push(...fr(r,e));else if(It(r)){const o=r.getTextContent();o&&t.push({kind:"text",text:o,link:e})}return t}function vi(n){const e=[],t=r=>{e.length&&r.length&&e.push({kind:"break"}),e.push(...r)};for(const r of n)switch(r.kind){case"heading":t(r.inlines.map(o=>o.kind==="text"?{...o,bold:!0}:o));break;case"paragraph":t(r.inlines);break;case"quote":case"collapsible":t(vi(r.blocks));break;case"list":r.items.forEach((o,s)=>{const i=r.ordered?`${r.start+s}. `:"• ";t([{kind:"text",text:i},...vi(o.blocks)])});break;case"code":t([{kind:"text",text:r.text,code:!0}]);break;case"equation":t([{kind:"equation",equation:r.equation,key:r.key}]);break;case"image":t([{kind:"text",text:r.alt||"[image]",italic:!0}]);break;case"embed":t([{kind:"text",text:r.label,link:r.url}]);break;case"table":r.rows.forEach(o=>t(o.flatMap((s,i)=>[...i?[{kind:"text",text:" | "}]:[],...s.inlines])));break;case"columns":r.columns.forEach(o=>t(vi(o)));break}return e}function o1(n){const e=[];for(const t of n.getChildren()){if(!le(t))continue;const r=t.getFirstChild();if(t.getChildrenSize()===1&&Z(r)){const i=Yi(r),a=e[e.length-1];a&&i?a.blocks.push(i):i&&e.push({checked:null,blocks:[i]});continue}const o=[],s=[];for(const i of t.getChildren()){if(q(i)&&!Pe(i)){const a=Yi(i);if(a&&a.kind!=="paragraph"){s.length&&(o.push({kind:"paragraph",inlines:[...s],align:"left",indent:0}),s.length=0),o.push(a);continue}}s.push(...Bu([i]))}(s.length||o.length===0)&&o.unshift({kind:"paragraph",inlines:s,align:"left",indent:0}),e.push({checked:n.getListType()==="check"?t.getChecked()===!0:null,blocks:o})}return e}function Yi(n){if(Wr(n))return{kind:"heading",level:Math.min(6,Math.max(1,Number(n.getTag().slice(1))||1)),inlines:fr(n),align:cc(n),indent:n.getIndent()};if(Vn(n))return{kind:"quote",blocks:[{kind:"paragraph",inlines:fr(n),align:"left",indent:0}]};if(Z(n))return{kind:"list",ordered:n.getListType()==="number",start:n.getStart(),items:o1(n)};if(st(n))return{kind:"code",language:n.getLanguage()??"python",text:n.getTextContent(),executable:!0,key:n.getKey()};if(je(n))return{kind:"code",language:n.getLanguage()??null,text:n.getTextContent(),executable:!1,key:n.getKey()};if(Cu(n))return{kind:"outputs",outputs:n.getOutputs(),key:n.getKey()};if(be(n)){const e=[];for(const t of n.getChildren()){if(!ce(t))continue;const r=[];for(const o of t.getChildren())J(o)&&r.push({header:o.hasHeader(),colSpan:Math.max(1,o.getColSpan()),inlines:vi(cs(o.getChildren()))});e.push(r)}return{kind:"table",rows:e}}if(Ci(n)){const e=n.getChildren().filter(Au),t=n.getTemplateColumns().trim(),r=Math.max(e.length,t?t.split(/\s+/).length:0);return{kind:"columns",weights:r1(n.getTemplateColumns(),r).slice(0,e.length),columns:e.map(o=>cs(o.getChildren()))}}if(Pt(n)){const e=n.getChildren().find(xi),t=n.getChildren().find(Lu);return{kind:"collapsible",title:e?fr(e):[],blocks:t?cs(t.getChildren()):[],open:n.getOpen()}}if(ch(n))return{kind:"rule"};if(Hn(n))return{kind:"image",src:n.getSrc(),alt:n.getAltText(),key:n.getKey()};if(Rr(n))return{kind:"equation",equation:n.getEquation(),key:n.getKey()};if(W_(n)){const e=n.getId();return{kind:"embed",label:`YouTube video ${e}`,url:`https://www.youtube.com/watch?v=${e}`,key:n.getKey()}}if(Fu(n))return{kind:"drawing",key:n.getKey(),label:"Drawing"};if(Du(n)){const{url:e,title:t}=n.getVideo();return kn(e)?{kind:"embed",label:t?`Loom video: ${t}`:"Loom video",url:e,key:n.getKey()}:null}if(ht(n)){const e=fr(n),t=n.getChildrenSize()===1?n.getFirstChild():null;return t&&Rr(t)&&!t.__inline?{kind:"equation",equation:t.getEquation(),key:t.getKey()}:t&&Hn(t)?{kind:"image",src:t.getSrc(),alt:t.getAltText(),key:t.getKey()}:{kind:"paragraph",inlines:e,align:cc(n),indent:n.getIndent()}}if(q(n)){const e=cs(n.getChildren());if(e.length)return e.length===1?e[0]:{kind:"quote",blocks:e};const t=fr(n);return t.length?{kind:"paragraph",inlines:t,align:"left",indent:0}:null}return It(n)?{kind:"drawing",key:n.getKey(),label:n.getTextContent()||n.getType()}:null}function um(n){return q(n)&&!Pe(n)&&!n.isInline()&&!ht(n)||be(n)||Z(n)||je(n)||Hn(n)||Fu(n)||W_(n)||Du(n)||Rr(n)&&!n.__inline}function s1(n){const e=[];let t=[];const r=()=>{if(t.length){const o=Bu(t);o.length&&e.push({kind:"paragraph",inlines:o,align:cc(n),indent:n.getIndent()}),t=[]}};for(const o of n.getChildren())if(um(o)){r();const s=Yi(o);s&&e.push(s)}else t.push(o);return r(),e}function cs(n){const e=[];for(const t of n){if(ht(t)&&t.getChildren().some(um)){e.push(...s1(t));continue}const r=Yi(t);r&&e.push(r)}return e}function dm(n){return n.map(e=>e.kind==="text"?e.text:e.kind==="break"?`
92
+ `:e.equation).join("")}function i1(){const n=cs(se().getChildren()),e=n.find(t=>t.kind==="heading");return{blocks:n,title:e&&e.kind==="heading"?dm(e.inlines):null}}function Uu(n){return n.getEditorState().read(i1)}const fi=["Helvetica","Helvetica-Bold","Helvetica-Oblique","Helvetica-BoldOblique","Courier","Courier-Bold"],Yf=[278,278,355,556,556,889,667,191,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,278,278,584,584,584,556,1015,667,667,722,722,667,611,778,722,278,500,667,556,833,722,778,667,778,722,667,611,722,667,944,667,667,611,278,278,278,469,556,333,556,556,500,556,556,278,556,556,222,222,500,222,833,556,556,556,556,333,500,278,556,500,722,500,500,500,334,260,334,584],Xf=[278,333,474,556,556,889,722,238,333,333,389,584,278,333,278,278,556,556,556,556,556,556,556,556,556,556,333,333,584,584,584,611,975,722,722,722,722,667,611,778,722,278,556,722,611,833,722,778,667,778,722,667,611,722,667,944,667,667,611,333,278,333,584,556,333,556,611,556,611,556,333,611,611,278,278,556,278,889,611,611,611,611,389,556,333,611,556,778,556,556,500,389,280,389,584],a1={"—":[1e3,1e3],"–":[556,556],"•":[350,350],"‘":[222,278],"’":[222,278],"“":[333,500],"”":[333,500],"…":[1e3,1e3],"€":[556,556],"·":[278,278],"×":[584,584],"°":[400,400],"±":[584,584]," ":[278,278],"©":[737,737],"®":[737,737],"™":[1e3,1e3],"«":[556,556],"»":[556,556],"§":[556,556],"¶":[537,556]},l1={"−":"-","→":"->","←":"<-","⇒":"=>","≤":"<=","≥":">=","≠":"!=","≈":"~","∎":"#","■":"#","□":"[ ]","☐":"[ ]","☑":"[x]","☒":"[x]","✓":"v","✔":"v","▸":">","▾":"v"," ":" "," ":" "," ":" ","​":"","\uFEFF":"","­":""},Gf={"€":128,"‚":130,ƒ:131,"„":132,"…":133,"†":134,"‡":135,"ˆ":136,"‰":137,Š:138,"‹":139,Œ:140,Ž:142,"‘":145,"’":146,"“":147,"”":148,"•":149,"–":150,"—":151,"˜":152,"™":153,š:154,"›":155,œ:156,ž:158,Ÿ:159};function c1(n){const e=[];let t="";for(const r of n){const o=l1[r],s=o!==void 0?o:r;for(const i of s){const a=i.codePointAt(0)??63;if(a<128||a>=160&&a<=255)e.push(a),t+=i;else if(Gf[i]!==void 0)e.push(Gf[i]),t+=i;else{const l=i.normalize("NFD").replace(/[̀-ͯ]/g,""),c=l.codePointAt(0)??63;l.length===1&&c<128?(e.push(c),t+=l):(e.push(63),t+="?")}}}return{bytes:e,text:t}}function u1(n){return n==="Helvetica-Bold"||n==="Helvetica-BoldOblique"}function d1(n,e){if(e==="Courier"||e==="Courier-Bold")return 600;const t=u1(e),r=n.codePointAt(0)??32;if(r>=32&&r<=126)return(t?Xf:Yf)[r-32];const o=a1[n];if(o)return o[t?1:0];const s=n.normalize("NFD").replace(/[̀-ͯ]/g,""),i=s.codePointAt(0)??32;return s.length===1&&i>=32&&i<=126?(t?Xf:Yf)[i-32]:t?611:556}function cr(n,e,t){let r=0;for(const o of n)r+=d1(o,e);return r*t/1e3}function Zf(n){return n.code?n.bold?"Courier-Bold":"Courier":n.bold&&n.italic?"Helvetica-BoldOblique":n.bold?"Helvetica-Bold":n.italic?"Helvetica-Oblique":"Helvetica"}const Rs={a4:{width:595.28,height:841.89},letter:{width:612,height:792}};function gi(n){if(typeof n=="string"){const e=n.replace("#",""),t=e.length===3?e.split("").map(a=>a+a).join(""):e,r=parseInt(t,16),o=(r>>16&255)/255,s=(r>>8&255)/255,i=(r&255)/255;return`${Fe(o)} ${Fe(s)} ${Fe(i)}`}return n.map(Fe).join(" ")}function Fe(n){return Number.isInteger(n)?String(n):n.toFixed(3).replace(/\.?0+$/,"")}function fm(n){let e="";for(const t of n)e+=t.toString(16).padStart(2,"0");return e}function rs(n){const e=[254,255];for(let t=0;t<n.length;t++){const r=n.charCodeAt(t);e.push(r>>8,r&255)}return`<${fm(e)}>`}function f1(n){const e=t=>String(t).padStart(2,"0");return`D:${n.getUTCFullYear()}${e(n.getUTCMonth()+1)}${e(n.getUTCDate())}${e(n.getUTCHours())}${e(n.getUTCMinutes())}${e(n.getUTCSeconds())}Z`}class g1{index;width;height;fontName;ops=[];links=[];images=new Set;constructor(e,t,r,o){this.index=e,this.width=t,this.height=r,this.fontName=o}text(e,t,r,o,s,i="#000000"){const{bytes:a}=c1(r);a.length!==0&&this.ops.push(`BT ${gi(i)} rg /${this.fontName(o)} ${Fe(s)} Tf 1 0 0 1 ${Fe(e)} ${Fe(this.height-t)} Tm <${fm(a)}> Tj ET`)}rect(e,t,r,o,s){const i=["q"];s.fill&&i.push(`${gi(s.fill)} rg`),s.stroke&&i.push(`${gi(s.stroke)} RG ${Fe(s.lineWidth??.5)} w`),i.push(`${Fe(e)} ${Fe(this.height-t-o)} ${Fe(r)} ${Fe(o)} re`),i.push(s.fill&&s.stroke?"B":s.fill?"f":"S","Q"),this.ops.push(i.join(" "))}line(e,t,r,o,s="#000000",i=.5){this.ops.push(`q ${gi(s)} RG ${Fe(i)} w ${Fe(e)} ${Fe(this.height-t)} m ${Fe(r)} ${Fe(this.height-o)} l S Q`)}image(e,t,r,o,s){this.images.add(e.id),this.ops.push(`q ${Fe(o)} 0 0 ${Fe(s)} ${Fe(t)} ${Fe(this.height-r-s)} cm /Im${e.id} Do Q`)}link(e,t,r,o,s){this.links.push({rect:[e,this.height-t-o,e+r,this.height-t],url:s})}}class gm{options;pages=[];size;images=[];fonts=new Map;constructor(e={}){this.options=e,this.size=e.size??Rs.a4,fi.forEach((t,r)=>this.fonts.set(t,`F${r+1}`))}addPage(){const e=new g1(this.pages.length,this.size.width,this.size.height,t=>this.fonts.get(t)??"F1");return this.pages.push(e),e}addJpeg(e,t,r){const o={id:this.images.length+1,width:t,height:r,bytes:e};return this.images.push(o),o}build(){const e=new TextEncoder,t=[];let r=0;const o=C=>{const v=typeof C=="string"?p1(C):C;t.push(v),r+=v.length},s=[],i=(C,v)=>{s[C]=r,o(`${C} 0 obj
93
93
  `),typeof v=="string"?o(v):v.forEach(o),o(`
94
94
  endobj
95
95
  `)};let a=4;const l=new Map;for(const C of fi)l.set(C,a++);const c=new Map;for(const C of this.images)c.set(C.id,a++);const u=this.pages.map(()=>{const C=a;return a+=2,C}),f=this.pages.map(C=>C.links.map(()=>a++));o(`%PDF-1.4
@@ -179,7 +179,7 @@ ${s} `)}`)}}return i.join(`
179
179
  `)}}async function wm(n,e={}){const t=Uu(n),r=new H1(e,n),o=await r.blocks(t.blocks);return{main:`${r.preamble(t)}
180
180
 
181
181
  ${o}
182
- `,files:r.files}}const xm="0.7.0",J1=`https://cdn.jsdelivr.net/npm/@myriaddreamin/typst.ts@${xm}/dist/esm/contrib/snippet.mjs/+esm`,q1=`https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@${xm}/pkg/typst_ts_web_compiler_bg.wasm`,tl=new Map;function V1(n){return new Function("url","return import(url)")(n)}function Y1(n={}){const e=n.moduleUrl??J1,t=n.wasmUrl??q1,r=tl.get(e);if(r)return r;const o=V1(e).then(({$typst:s})=>{s.setCompilerInitOptions({getModule:()=>t});let i=Promise.resolve();return{compile(l,c){const u=i.then(async()=>{if(s.resetShadow(),c)for(const[f,d]of c)await s.mapShadow(f.startsWith("/")?f:`/${f}`,d);return s.pdf({mainContent:l})});return i=u.catch(()=>{}),u}}});return o.catch(()=>tl.delete(e)),tl.set(e,o),o}function G1(n){return typeof n=="object"&&n!==null&&typeof n.compile=="function"}function X1(n,e,...t){if(!n)throw new Error("Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: "+e)}function Z1(n,e,t){const r=n.length,o=e.length;let s=0,i=0;for(;s<r&&s<o&&n[s]===e[s]&&s<t;)s++;for(;i+s<r&&i+s<o&&n[r-i-1]===e[o-i-1];)i++;for(;i+s<r&&i+s<o&&n[s]===e[s];)s++;return{index:s,insert:e.slice(s,o-i),remove:r-s-i}}const Q1="lexical-tree";function Wt(n){return Number(n.peerId)}function ek(){return Math.floor(Math.random()*2147483647)}function tk(n,e=Q1){return n.getTree(e)}function so(n,e){return!!(n===e||n.name===e.name||n.prototype&&Object.prototype.isPrototypeOf.call(e,n))}function nk(n,e,t,r){const o=D();let s=r.length;if(F(o)&&o.isCollapsed()){const a=o.anchor;a.key===e&&(s=Math.min(a.offset,r.length))}const i=Z1(t,r,s);n.getTextContent(),n.spliceText(i.index,i.remove,i.insert),n.getTextContent()}function ng(n){const e=n.anchor,t=n.focus;let r=!1;try{const o=e.getNode(),s=t.getNode();(!o.isAttached()||!s.isAttached()||oe(o)&&e.offset>o.getTextContentSize()||oe(s)&&t.offset>s.getTextContentSize())&&(r=!0)}catch{r=!0}return r}function Cm(n,e){const t=e._nodeMap.get(n);if(!t){se().selectStart();return}const r=t.__prev;let o=null;if(r&&(o=Q(r)),o===null&&t.__parent!==null&&(o=Q(t.__parent)),o===null){se().selectStart();return}if(o!==null&&o.isAttached()){o.selectEnd();return}else Cm(o.__key,e)}function qt(n,e){if(!n||!e)return!1;try{return n.has(e)&&!n.isNodeDeleted(e)}catch{return!1}}function Se(n,e,t){const r=n.data.get(e);return e==="createdAt"&&r!==void 0||r!==void 0&&rk(r,t)?!1:(n.data.set(e,t),!0)}function Gi(n,e,t,r){const o=n.getNodeByID(e);if(o){const s=o.parent(),i=s?String(s.id):void 0,a=t===void 0?void 0:String(t);if(i===a&&(r===void 0||(s?s.children()??[]:n.roots()).findIndex(u=>String(u.id)===String(e))===r))return!1}return n.move(e,t,r),!0}function rk(n,e){if(n===e)return!0;try{const t=r=>r&&typeof r.toJSON=="function"?r.toJSON():r;return JSON.stringify(t(n))===JSON.stringify(t(e))}catch{return!1}}function dt(n,e,t){if(!n){const r=t?` ${JSON.stringify(t)}`:"";throw new Error(`[loro-collab] Invariant failed: ${e}${r}`)}}let nl;function ye(...n){nl===void 0&&(nl=Sm()),nl&&console.log(...n)}function Sm(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("debug")==="true"}function ok(n){window.debugLoro={binding:null,logStructure:()=>{const e=window.debugLoro.binding;if(e){console.log("=== LORO TREE STRUCTURE DEBUG ===");const r=e.tree.nodes();console.log(`Total nodes in tree: ${r.length}`);const o=(i,a="",l=!0,c=0)=>{const u=Object.fromEntries(i.data.entries()),f=i.id,d=e.nodeMapper?.getLexicalKeyByLoroId(f)||"no-key",g=u.elementType||"no-type",h=c===0?"":l?"└── ":"├── ",_=`TreeID(${f.slice(0,8)}...) → ${d} [${g}]`;console.log(`${a}${h}${_}`);const m=i.children();m&&m.length>0&&m.forEach((b,w)=>{const C=w===m.length-1,v=a+(c===0?"":l?" ":"│ ");o(b,v,C,c+1)})},s=r.filter(i=>{const a=i.parent(),l=Object.fromEntries(i.data.entries());return!a||l.isRoot});console.log(`Root nodes: ${s.length}`),console.log(""),s.length===0?console.log(" No root nodes found!"):s.forEach((i,a)=>{const l=a===s.length-1;o(i,"",l,0)}),console.log("=== END LORO DEBUG ===")}else console.log("Loro binding not available yet")},verifyStructure:()=>{const e=window.debugLoro.binding;if(!e)return console.log(" Loro Binding not available");console.log(" LORO TREE VERIFICATION:");const r=e.tree.nodes();console.log("Total nodes:",r.length),console.log("Peer ID:",e.doc.peerIdStr),console.log("Client ID:",e.clientID),e.nodeMapper,console.log(`
182
+ `,files:r.files}}const xm="0.7.0",J1=`https://cdn.jsdelivr.net/npm/@myriaddreamin/typst.ts@${xm}/dist/esm/contrib/snippet.mjs/+esm`,q1=`https://cdn.jsdelivr.net/npm/@myriaddreamin/typst-ts-web-compiler@${xm}/pkg/typst_ts_web_compiler_bg.wasm`,tl=new Map;function V1(n){return new Function("url","return import(url)")(n)}function Y1(n={}){const e=n.moduleUrl??J1,t=n.wasmUrl??q1,r=tl.get(e);if(r)return r;const o=V1(e).then(({$typst:s})=>{s.setCompilerInitOptions({getModule:()=>t});let i=Promise.resolve();return{compile(l,c){const u=i.then(async()=>{if(s.resetShadow(),c)for(const[f,d]of c)await s.mapShadow(f.startsWith("/")?f:`/${f}`,d);return s.pdf({mainContent:l})});return i=u.catch(()=>{}),u}}});return o.catch(()=>tl.delete(e)),tl.set(e,o),o}function X1(n){return typeof n=="object"&&n!==null&&typeof n.compile=="function"}function G1(n,e,...t){if(!n)throw new Error("Internal Lexical error: invariant() is meant to be replaced at compile time. There is no runtime version. Error: "+e)}function Z1(n,e,t){const r=n.length,o=e.length;let s=0,i=0;for(;s<r&&s<o&&n[s]===e[s]&&s<t;)s++;for(;i+s<r&&i+s<o&&n[r-i-1]===e[o-i-1];)i++;for(;i+s<r&&i+s<o&&n[s]===e[s];)s++;return{index:s,insert:e.slice(s,o-i),remove:r-s-i}}const Q1="lexical-tree";function Wt(n){return Number(n.peerId)}function ek(){return Math.floor(Math.random()*2147483647)}function tk(n,e=Q1){return n.getTree(e)}function so(n,e){return!!(n===e||n.name===e.name||n.prototype&&Object.prototype.isPrototypeOf.call(e,n))}function nk(n,e,t,r){const o=D();let s=r.length;if(F(o)&&o.isCollapsed()){const a=o.anchor;a.key===e&&(s=Math.min(a.offset,r.length))}const i=Z1(t,r,s);n.getTextContent(),n.spliceText(i.index,i.remove,i.insert),n.getTextContent()}function ng(n){const e=n.anchor,t=n.focus;let r=!1;try{const o=e.getNode(),s=t.getNode();(!o.isAttached()||!s.isAttached()||oe(o)&&e.offset>o.getTextContentSize()||oe(s)&&t.offset>s.getTextContentSize())&&(r=!0)}catch{r=!0}return r}function Cm(n,e){const t=e._nodeMap.get(n);if(!t){se().selectStart();return}const r=t.__prev;let o=null;if(r&&(o=Q(r)),o===null&&t.__parent!==null&&(o=Q(t.__parent)),o===null){se().selectStart();return}if(o!==null&&o.isAttached()){o.selectEnd();return}else Cm(o.__key,e)}function qt(n,e){if(!n||!e)return!1;try{return n.has(e)&&!n.isNodeDeleted(e)}catch{return!1}}function Se(n,e,t){const r=n.data.get(e);return e==="createdAt"&&r!==void 0||r!==void 0&&rk(r,t)?!1:(n.data.set(e,t),!0)}function Xi(n,e,t,r){const o=n.getNodeByID(e);if(o){const s=o.parent(),i=s?String(s.id):void 0,a=t===void 0?void 0:String(t);if(i===a&&(r===void 0||(s?s.children()??[]:n.roots()).findIndex(u=>String(u.id)===String(e))===r))return!1}return n.move(e,t,r),!0}function rk(n,e){if(n===e)return!0;try{const t=r=>r&&typeof r.toJSON=="function"?r.toJSON():r;return JSON.stringify(t(n))===JSON.stringify(t(e))}catch{return!1}}function dt(n,e,t){if(!n){const r=t?` ${JSON.stringify(t)}`:"";throw new Error(`[loro-collab] Invariant failed: ${e}${r}`)}}let nl;function ye(...n){nl===void 0&&(nl=Sm()),nl&&console.log(...n)}function Sm(){return typeof window>"u"?!1:new URLSearchParams(window.location.search).get("debug")==="true"}function ok(n){window.debugLoro={binding:null,logStructure:()=>{const e=window.debugLoro.binding;if(e){console.log("=== LORO TREE STRUCTURE DEBUG ===");const r=e.tree.nodes();console.log(`Total nodes in tree: ${r.length}`);const o=(i,a="",l=!0,c=0)=>{const u=Object.fromEntries(i.data.entries()),f=i.id,d=e.nodeMapper?.getLexicalKeyByLoroId(f)||"no-key",g=u.elementType||"no-type",h=c===0?"":l?"└── ":"├── ",_=`TreeID(${f.slice(0,8)}...) → ${d} [${g}]`;console.log(`${a}${h}${_}`);const m=i.children();m&&m.length>0&&m.forEach((b,w)=>{const C=w===m.length-1,v=a+(c===0?"":l?" ":"│ ");o(b,v,C,c+1)})},s=r.filter(i=>{const a=i.parent(),l=Object.fromEntries(i.data.entries());return!a||l.isRoot});console.log(`Root nodes: ${s.length}`),console.log(""),s.length===0?console.log(" No root nodes found!"):s.forEach((i,a)=>{const l=a===s.length-1;o(i,"",l,0)}),console.log("=== END LORO DEBUG ===")}else console.log("Loro binding not available yet")},verifyStructure:()=>{const e=window.debugLoro.binding;if(!e)return console.log(" Loro Binding not available");console.log(" LORO TREE VERIFICATION:");const r=e.tree.nodes();console.log("Total nodes:",r.length),console.log("Peer ID:",e.doc.peerIdStr),console.log("Client ID:",e.clientID),e.nodeMapper,console.log(`
183
183
  Node Mappings:`),r.forEach((s,i)=>{const a=Object.fromEntries(s.data.entries()),l=s.id,c=e.nodeMapper?.getLexicalKeyByLoroId(l)||"no-key";console.log(`
184
184
  Node ${i}:`),console.log(" TreeID:",l),console.log(" Lexical Key:",c),console.log(" Element Type:",a.elementType||"N/A"),console.log(" Created At:",a.createdAt&&typeof a.createdAt=="number"?new Date(a.createdAt).toLocaleTimeString():"N/A"),console.log(" Has Lexical Data:",a.lexical?"Yes":"No");const u=s.parent();console.log(" Parent:",u?u.id:"None (Root)");const f=s.children();if(console.log(" Children Count:",f?f.length:0),a.lexical&&typeof a.lexical=="string")try{const d=JSON.parse(a.lexical);console.log(" Lexical Type:",d.lexicalNode?.type||"Unknown")}catch{console.log(" Lexical Data: Invalid JSON")}});const o=r.filter(s=>{const i=s.parent(),a=Object.fromEntries(s.data.entries());return!i&&!a.isRoot});o.length>0&&(console.log(`
185
185
  WARNING: Found orphaned nodes (no parent, not root):`),o.forEach(s=>{const i=Object.fromEntries(s.data.entries()),a=e.nodeMapper?.getLexicalKeyByLoroId(s.id)||"no-key";console.log(` - ${s.id} (${a}, ${i.elementType})`)})),console.log(`
@@ -203,20 +203,20 @@ ${o}
203
203
  <span onclick="document.getElementById('debug-loro').remove()" style="color: #ff0066; cursor: pointer; text-decoration: underline;"> Close</span>
204
204
  </div>
205
205
  </div>
206
- `,document.body.appendChild(a)},cleanupEphemeralStore:e=>{if(!e){console.log(" No provider passed. Usage: window.debugLoro.cleanupEphemeralStore(provider)"),console.log("You can get the provider from your useCollaboration hook");return}if(typeof e.cleanupStaleStates!="function"){console.log(" Provider does not have cleanupStaleStates method");return}console.log(" Cleaning up stale ephemeral states..."),e.cleanupStaleStates()},resetGlobalEphemeralStore:()=>{try{console.log(" Attempting to reset global EphemeralStore..."),console.log(" You can also refresh the browser to clear the global store"),alert("To reset the global ephemeral store and clear all collaborators, please refresh the browser page.")}catch(e){console.warn(" Reset failed:",e.message)}}},window.debugLoro.binding=n,setTimeout(()=>{window.debugLoro.addDebugToPage()},2e3)}class sk{lexicalToLoro=new Map;loroToLexical=new Map;tree;constructor(e){this.tree=e.tree}createMapping(e,t){this.lexicalToLoro.set(e,t),this.loroToLexical.set(t,e)}removeMapping(e,t){this.lexicalToLoro.delete(e),this.loroToLexical.delete(t)}getLoroNodeByLexicalKey(e,t,r,o){const s=this.lexicalToLoro.get(e);if(s&&qt(this.tree,s))return this.tree.getNodeByID(s);if(e==="root"){const a=this.tree.roots()[0];if(a)return this.createMapping(e,a.id),a;const l=this.createLoroNode(e,t,void 0,0),c=this.tree.getNodeByID(l);return Se(c,"elementType","root"),c}if(!r&&t){const a=t.getParent();if(a){const l=a.getKey();r=this.lexicalToLoro.get(l),r||(r=this.getLoroNodeByLexicalKey(l,a,void 0,void 0).id)}}o===void 0&&t&&(o=t.getIndexWithinParent());const i=this.createLoroNode(e,t,r,o);return this.tree.getNodeByID(i)}getLexicalKeyByLoroId(e){const t=this.loroToLexical.get(e);return t||null}getLexicalNodeByLoroId(e,t){const r=this.getLexicalKeyByLoroId(e);return r&&t._nodeMap.get(r)||null}getLexicalParentByLoroId(e,t){return null}setMapping(e,t){this.lexicalToLoro.set(e,t),this.loroToLexical.set(t,e)}aliasLoroId(e,t){this.loroToLexical.set(e,t)}createLoroNode(e,t,r,o){const s=o;if(s!==void 0){const l=r!==void 0?this.tree.getNodeByID(r):null,c=l?l.children()?.length??0:this.tree.roots().length;dt(s>=0&&s<=c,"createLoroNode: insertion index out of range",{nodeKey:e,parentTreeID:r,insertionIndex:s,childrenLength:c})}const i=this.tree.createNode(r,s),a=i.id;if(r){const l=i.parent();dt(l!=null&&l.id===r,"createLoroNode: parent relationship not established",{nodeKey:e,expected:r,actual:l?.id??null})}if(Se(i,"createdAt",Date.now()),t)try{const l=t.exportJSON();if("key"in l||"__key"in l||"lexicalKey"in l){const{key:c,__key:u,lexicalKey:f,children:d,...g}=l;Se(i,"lexical",g)}else{const{children:c,...u}=l;Se(i,"lexical",u)}}catch(l){console.warn("Failed to export lexical node JSON in NodesMapper:",l)}return this.createMapping(e,a),a}updateMapping(e,t){const r=this.lexicalToLoro.get(e);r&&(this.removeMapping(e,r),this.createMapping(t,r),this.tree.getNodeByID(r))}deleteMapping(e){const t=this.lexicalToLoro.get(e);t&&(this.removeMapping(e,t),qt(this.tree,t)&&this.tree.delete(t))}removeMappingForKey(e){const t=this.lexicalToLoro.get(e);t&&this.removeMapping(e,t)}getTreeIDByLexicalKey(e){return this.lexicalToLoro.get(e)}hasLexicalMapping(e){return this.lexicalToLoro.has(e)}hasLoroMapping(e){return this.loroToLexical.has(e)}getAllMappings(){return{lexicalToLoro:new Map(this.lexicalToLoro),loroToLexical:new Map(this.loroToLexical)}}clearMappings(){this.lexicalToLoro.clear(),this.loroToLexical.clear()}syncExistingNodes(e){ye(" syncExistingNodes: Skipping sync - mappings established through TreeIntegrator")}}let vr=null;function ik(n){return vr=new sk(n),vr}function ak(n,e){const t=vr;vr=n;try{return e()}finally{vr=t}}function Ue(){if(!vr)throw new Error("NodeMapper not initialized. Call initializeNodeMapper() first.");return vr}function lk({binding:n,currentUserName:e="Me",currentUserColor:t}){const[r,o]=S.useState(0);S.useEffect(()=>{const g=setInterval(()=>{o(h=>h+1)},1e3);return()=>clearInterval(g)},[]);const s=n.clientID;Array.from(n.cursors.entries()).map(([g,h])=>({clientId:g,name:h.name,color:h.color,isCurrentUser:g===s}));const i=Array.from(n.cursors.entries()).map(([g,h])=>({clientId:g,cursor:h,isCurrentUser:g===s})),a=n.cursors.get(s),l=a?.name||e,c=Hw(l),u=a?.color||t||c,f=i.find(({isCurrentUser:g})=>g),d=i.filter(({isCurrentUser:g})=>!g);return x.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",backgroundColor:"var(--bgColor-muted, #f8f9fa)",borderBottom:"1px solid var(--borderColor-default, #e1e5e9)",fontSize:"14px",fontFamily:"system-ui, -apple-system, sans-serif",gap:"8px",flexWrap:"wrap",color:"var(--fgColor-default, inherit)"},children:[f&&x.jsx(rl,{name:`${f.cursor.name} (me)`,color:u,isCurrentUser:!0,clientId:s}),!f&&x.jsx(rl,{name:`${l} (me)`,color:u,isCurrentUser:!0,clientId:s}),d.length>0&&x.jsx("div",{style:{width:"1px",height:"20px",backgroundColor:"var(--borderColor-muted, #d1d5db)",margin:"0 4px"}}),d.map(({clientId:g,cursor:h})=>x.jsx(rl,{name:h.name,color:h.color,isCurrentUser:!1,clientId:g},g)),d.length===0&&x.jsx("span",{style:{color:"var(--fgColor-muted, #6b7280)",fontStyle:"italic",marginLeft:"8px"},children:"No other collaborators"})]})}function rl({name:n,color:e,isCurrentUser:t,clientId:r}){const o=e,s=e,i=String(r).slice(0,4);return x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},title:`${n} (Client ID: ${r})`,children:[x.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:o,border:t?"2px solid var(--bgColor-default, #ffffff)":"none",boxShadow:t?"0 0 0 1px var(--borderColor-default, #d1d5db)":"none",flexShrink:0}}),x.jsx("span",{style:{backgroundColor:s,color:"var(--fgColor-onEmphasis, #ffffff)",padding:"3px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",lineHeight:"1.2",whiteSpace:"nowrap",textShadow:"0 1px 2px rgba(0,0,0,0.1)",boxShadow:t?"0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2)":"0 1px 2px rgba(0,0,0,0.1)",opacity:1},children:`${n} ${i}`})]})}function ck({binding:n,cursorsContainer:e,currentUserName:t="You",currentUserColor:r,showCollaborators:o=!0}){return x.jsxs(x.Fragment,{children:[o&&x.jsx(lk,{binding:n,currentUserName:t,currentUserColor:r}),e]})}function uk(n,e,t,r,o,s){X1(r!=null,"createBinding: doc is null or undefined");const i=tk(r);ye(" Loro tree initialized, content will be populated via server sync");const a=Wt(r);ye("- Creating binding:",{bindingId:t,localPeerId:r.peerId,generatedClientID:a,docPeerIdType:typeof r.peerId,awarenessKey:a.toString()});const l={clientID:a,cursors:new Map,cursorsContainer:null,doc:r,docMap:o,editor:n,tree:i,excludedProperties:s||new Map,id:t,nodeProperties:new Map,nodeMapper:null,commitTimeout:null,pendingCommit:!1};return l.nodeMapper=ik(l),Sm()&&(ok(l),ye(" Loro debugging enabled via ?debug=true URL parameter")),l}function vm(n){const e=n.awarenessData;if(!e||typeof e!="object")return n.name;const t=e,r=t.user,o=r&&typeof r=="object"?r:void 0,s=[o?.display_name,o?.displayName,o?.name,o?.username,o?.handle,t.display_name,t.displayName,t.name,t.username,t.handle,n.name];for(const i of s)if(typeof i=="string"&&i.trim().length>0)return i;return n.name}function rg(n,e){try{const t=Q(n.key);if(!t)return null;const r=e.nodeMapper;if(oe(t)){const s=r.getTreeIDByLexicalKey(n.key);if(!s)return null;const i=t.getTextContent(),a=Math.min(n.offset,i.length);return{treeId:s,offset:a,pointType:"text"}}if(q(t)){const s=t.getChildren();if(s.length===0){const a=r.getTreeIDByLexicalKey(n.key);return a?{treeId:a,offset:n.offset,pointType:"element"}:null}if(n.offset<s.length){const a=s[n.offset];if(a){const l=r.getTreeIDByLexicalKey(a.getKey());if(l)return{treeId:l,offset:0,pointType:oe(a)?"text":"element"}}}const i=r.getTreeIDByLexicalKey(n.key);return i?{treeId:i,offset:n.offset,pointType:"element"}:null}const o=r.getTreeIDByLexicalKey(n.key);return o?{treeId:o,offset:n.offset,pointType:"element"}:null}catch(t){return console.warn("Failed to convert Lexical point to Loro cursor:",t),null}}function km(n,e,t){try{if(!n||!e)return null;const r=n,o=e,s=t.nodeMapper;let i=null,a=null;return r.treeId&&(i=s.getLexicalKeyByLoroId(r.treeId)),o.treeId&&(a=s.getLexicalKeyByLoroId(o.treeId)),!i||!a?null:{anchorKey:i,anchorOffset:r.offset||0,focusKey:a,focusOffset:o.offset||0}}catch(r){return console.warn("Failed to convert Loro cursors to Lexical selection:",r),null}}function og(n,e,t){if(n.key!==e||n.offset!==t){let r=Q(e);if(r!==null&&!q(r)&&!oe(r)){const o=r.getParentOrThrow();e=o.getKey(),t=r.getIndexWithinParent(),r=o}n.set(e,t,q(r)?"element":"text")}}function dk(n,e){return{color:e,name:n,selection:null}}function fk(n,e,t,r,o,s=!1){const i=n.color,a=i,l=i,c=document.createElement("span");c.style.cssText=`position:absolute;top:0;bottom:0;right:-1px;width:2px;background-color:${a};z-index:10;${s?"opacity:0.8;":""}`;const u=document.createElement("span");return u.textContent=n.name,u.style.cssText=`position:absolute;left:-2px;top:-16px;background-color:${l};color:var(--fgColor-onEmphasis,#fff);line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;${s?"opacity:0.9;":""}`,c.appendChild(u),{anchor:{key:e,offset:t},focus:{key:r,offset:o},caret:c,color:n.color,name:u,selections:[]}}function gk(n,e){const t=e.selection;t!==null&&(Tm(n,t),e.selection=null)}function Tm(n,e){const t=n.cursorsContainer;if(t!==null){const r=e.selections,o=r.length;for(let s=0;s<o;s++)t.removeChild(r[s])}}function Im(n,e,t){const{getAwarenessStates:r=pk}=t??{},o=Array.from(r(n,e)),s=n.clientID,i=n.cursors,l=n.editor._editorState._nodeMap,c=new Set;for(let f=0;f<o.length;f++){const d=o[f],[g,h]=d;c.add(g);const{color:_}=h,m=vm(h),b=g===s;let w=null,C=i.get(g);if(C===void 0){const I=b?`${m} (Me)`:m;C=dk(I,_),i.set(g,C)}else C.name!==m&&(C.name=m,C.selection&&(C.selection.name.textContent=b?`${m} (Me)`:m));const{anchorPos:v,focusPos:k}=h;if(v!==null&&k!==null){const I=km(v,k,n);if(I){const{anchorKey:E,anchorOffset:N,focusKey:O,focusOffset:M}=I;if(w=C.selection,w===null)w=fk(C,E,N,O,M,b);else{const R=w.anchor,$=w.focus;R.key=E,R.offset=N,$.key=O,$.offset=M}}}hk(n,C,w,l,b)}const u=Array.from(i.keys());for(let f=0;f<u.length;f++){const d=u[f];if(!c.has(d)){const g=i.get(d);g!==void 0&&(gk(n,g),i.delete(d))}}}function pk(n,e){return e.awareness.getStates()}function hk(n,e,t,r,o=!1){const s=n.editor,i=s.getRootElement(),a=n.cursorsContainer;if(a===null||i===null)return;const l=a.getBoundingClientRect(),c=e.selection;if(t===null){if(c===null)return;e.selection=null,Tm(n,c);return}else e.selection=t;const u=t.caret,f=t.color,d=t.selections,g=t.anchor,h=t.focus,_=g.key,m=h.key,b=r.get(_),w=r.get(m);if(b==null||w==null)return;const C=_===m&&g.offset===h.offset;let v;if(b===w&&ue(b)){const E=s.getElementByKey(_);E?v=[E.getBoundingClientRect()]:v=[]}else{const E=fh(s,b,g.offset,w,h.offset);if(E===null)return;if(C){if(v=Ml(s,E),v.length===0){const N=E.getBoundingClientRect();N.height>0&&(v=[N])}}else v=Ml(s,E)}const k=d.length,I=v.length;for(let E=0;E<I;E++){const N=v[E];let O=d[E];if(O===void 0){O=document.createElement("span"),d[E]=O;const A=document.createElement("span");O.appendChild(A),a.appendChild(O)}const M=N.top-l.top,R=N.left-l.left,$=C?Math.max(N.width,4):N.width,L=`position:absolute;top:${M}px;left:${R}px;height:${N.height}px;width:${$}px;pointer-events:none;z-index:10;overflow:visible;`;O.style.cssText=L,C?(O.firstChild.style.cssText="position:absolute;left:0;top:0;width:0;height:0;",u.style.cssText=`position:absolute;top:0;left:0;width:2px;height:${N.height}px;background-color:${f};z-index:10;`):o?O.firstChild.style.cssText=`position:absolute;left:0;top:0;width:${N.width}px;height:${N.height}px;background-color:${f};opacity:0.08;border-radius:2px;pointer-events:none;`:O.firstChild.style.cssText=`position:absolute;left:0;top:0;width:${N.width}px;height:${N.height}px;background-color:${f};opacity:0.25;border-radius:2px;pointer-events:none;`,E===I-1&&u.parentNode!==O&&O.appendChild(u)}for(let E=k-1;E>=I;E--){const N=d[E];a.removeChild(N),d.pop()}}function Em(n,e,t,r){const o=e.awareness,s=o.getLocalState();if(s===null)return;const{anchorPos:i,focusPos:a,name:l,color:c,focusing:u,awarenessData:f}=s;let d=null,g=null;if(F(r))d=rg(r.anchor,n),g=rg(r.focus,n);else if(r!==null)return;if(!(sg(i,d)||sg(a,g)))return;const _=d!==null&&g!==null?!0:u;o.setLocalState({...s,anchorPos:d,awarenessData:f,color:c,focusPos:g,focusing:_,name:l})}function sg(n,e){if(n==null)return e!=null;if(e==null)return!0;{const t=n,r=e;return t.treeId!==r.treeId||t.offset!==r.offset||t.pointType!==r.pointType}}function ig(n,e){const r=e.awareness.getLocalState();if(r===null)return;const{anchorPos:o,focusPos:s}=r;if(o!==null&&s!==null){const i=km(o,s,n);if(i){const{anchorKey:a,anchorOffset:l,focusKey:c,focusOffset:u}=i,f=D();if(!F(f))return;og(f.anchor,a,l),og(f.focus,c,u)}}}const _k=(n,e)=>{const t=n.encode(),r=e.encode();return t.length===r.length&&t.every((o,s)=>o===r[s])},mk=n=>{const e=n.awarenessData,t=e&&e.user&&typeof e.user=="object"?e.user:void 0,r=t?.id??t?.uid;return typeof r=="string"&&r.length>0?r:void 0};function bk(n,e){const t=[];for(const[r,o]of n){const s=o.anchorPos,i=o.focusPos;t.push({clientId:r,uid:mk(o),name:vm(o),color:o.color,isCurrentUser:r===e,focusing:!!o.focusing,selecting:s!==null&&i!==null&&!_k(s,i)})}return t.sort((r,o)=>Number(o.isCurrentUser)-Number(r.isCurrentUser)||r.clientId-o.clientId)}const ag=["Cat","Dog","Rabbit","Frog","Fox","Hedgehog","Pigeon","Squirrel","Bear","Tiger","Leopard","Zebra","Wolf","Owl","Gull","Squid","Panda","Lion","Eagle","Shark","Dolphin","Penguin","Koala","Kangaroo"];function Nm(n){const e=Math.abs(n)%ag.length,t=Math.abs(n).toString().slice(-4),r=`${ag[e]}-${t}`,o=Jw(r);return{name:r,color:o}}const lg=Nm(Math.floor(Math.random()*1e5)),yk=S.createContext({clientID:0,color:lg.color,isCollabActive:!1,name:lg.name,docMap:new Map});function Lm(n,e){const t=S.useContext(yk);return n!=null&&(t.name=n),e!=null&&(t.color=e),t}const zu=["Map","List","MovableList","Text","Tree","Counter"];function wk(n,e){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("Invalid toContainerTree options");for(const t of Object.keys(n))if(t!=="text"&&!(e&&t==="roots"))throw new Error("Unknown toContainerTree option: "+t);if(e&&n.roots!==void 0&&!Array.isArray(n.roots))throw new Error("roots must be an array");return n}function xk(n,e,t){return{cid:n.cid,start:e,totalLength:t,items:n.value}}function Ck(n,e,t){return{type:zu[n],cid:e,value:t}}function Sk(n,e,t){return"cid:"+e+"@"+n+":"+zu[t]}function vk(n,e){return"cid:root-"+n+":"+zu[e]}function kk(n){return{type:"Value",value:n}}function Tk(n){return n.slice()}function Ik(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Ek(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}let p;function Nk(n){p=n}const Be=new Array(128).fill(void 0);Be.push(void 0,null,!0,!1);function W(n){return Be[n]}let X=0,hi=null;function ko(){return(hi===null||hi.byteLength===0)&&(hi=new Uint8Array(p.memory.buffer)),hi}const Lk=typeof TextEncoder>"u"?(0,module.require)("util").TextEncoder:TextEncoder;let Ti=new Lk("utf-8");const Ok=typeof Ti.encodeInto=="function"?function(n,e){return Ti.encodeInto(n,e)}:function(n,e){const t=Ti.encode(n);return e.set(t),{read:n.length,written:t.length}};function _e(n,e,t){if(t===void 0){const a=Ti.encode(n),l=e(a.length,1)>>>0;return ko().subarray(l,l+a.length).set(a),X=a.length,l}let r=n.length,o=e(r,1)>>>0;const s=ko();let i=0;for(;i<r;i++){const a=n.charCodeAt(i);if(a>127)break;s[o+i]=a}if(i!==r){i!==0&&(n=n.slice(i)),o=t(o,r,r=i+n.length*3,1)>>>0;const a=ko().subarray(o+i,o+r),l=Ok(n,a);i+=l.written,o=t(o,r,i,1)>>>0}return X=i,o}let io=null;function y(){return(io===null||io.buffer.detached===!0||io.buffer.detached===void 0&&io.buffer!==p.memory.buffer)&&(io=new DataView(p.memory.buffer)),io}let bs=Be.length;function P(n){bs===Be.length&&Be.push(Be.length+1);const e=bs;return bs=Be[e],Be[e]=n,e}function nt(n,e){try{return n.apply(this,e)}catch(t){p.__wbindgen_exn_store(P(t))}}const Rk=typeof TextDecoder>"u"?(0,module.require)("util").TextDecoder:TextDecoder;let Om=new Rk("utf-8",{ignoreBOM:!0,fatal:!0});Om.decode();function He(n,e){return n=n>>>0,Om.decode(ko().subarray(n,n+e))}function Ak(n){n<132||(Be[n]=bs,bs=n)}function T(n){const e=W(n);return Ak(n),e}function Tn(n,e){return n=n>>>0,ko().subarray(n/1,n/1+e)}function De(n){return n==null}const cg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>{p.__wbindgen_export_4.get(n.dtor)(n.a,n.b)});function Rm(n,e,t,r){const o={a:n,b:e,cnt:1,dtor:t},s=(...i)=>{o.cnt++;const a=o.a;o.a=0;try{return r(a,o.b,...i)}finally{--o.cnt===0?(p.__wbindgen_export_4.get(o.dtor)(a,o.b),cg.unregister(o)):o.a=a}};return s.original=o,cg.register(s,o,o),s}function dc(n){const e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){const o=n.description;return o==null?"Symbol":`Symbol(${o})`}if(e=="function"){const o=n.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(n)){const o=n.length;let s="[";o>0&&(s+=dc(n[0]));for(let i=1;i<o;i++)s+=", "+dc(n[i]);return s+="]",s}const t=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(t&&t.length>1)r=t[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}
207
- ${n.stack}`:r}function Mk(){let n,e;try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.LORO_VERSION(o);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);return n=t,e=r,He(t,r)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(n,e,1)}}function Gn(n,e){const t=e(n.length*1,1)>>>0;return ko().set(n,t/1),X=n.length,t}function fc(n,e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(n,p.__wbindgen_malloc),a=X;p.decodeImportBlobMeta(s,i,a,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function gc(){p.callPendingEvents()}function $k(n,e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.redactJsonUpdates(s,P(n),P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function Am(n){const e=_e(n,p.__wbindgen_malloc,p.__wbindgen_realloc),t=X;return p.isValidContainerId(e,t)!==0}function Dk(){p.run()}function Tt(n,e){const t=e(n.length*4,4)>>>0,r=y();for(let o=0;o<n.length;o++)r.setUint32(t+4*o,P(n[o]),!0);return X=n.length,t}function Pk(n){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(n,p.__wbindgen_malloc),l=X;p.encodeFrontiers(i,a,l);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}function jk(n){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Gn(n,p.__wbindgen_malloc),i=X;p.decodeFrontiers(o,s,i);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function Fk(){p.setDebug()}let et=128;function mt(n){if(et==1)throw new Error("out of js stack");return Be[--et]=n,et}function jo(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`)}function jt(n,e){n=n>>>0;const t=y(),r=[];for(let o=n;o<n+4*e;o+=4)r.push(T(t.getUint32(o,!0)));return r}function Bk(n,e,t){p._dyn_core_ed718c3d60ebd546___ops__function__FnMut_______Output______as_wasm_bindgen_cfd5deec16e3bd1c___closure__WasmClosure___describe__invoke___wasm_bindgen_cfd5deec16e3bd1c___JsValue_____(n,e,P(t))}function Uk(n,e){p._dyn_core_ed718c3d60ebd546___ops__function__FnMut_____Output______as_wasm_bindgen_cfd5deec16e3bd1c___closure__WasmClosure___describe__invoke______(n,e)}const ug=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_awarenesswasm_free(n>>>0,1));class zk{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ug.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_awarenesswasm_free(e,0)}getAllStates(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_getAllStates(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getTimestamp(e){try{const i=p.__wbindgen_add_to_stack_pointer(-32);p.awarenesswasm_getTimestamp(i,this.__wbg_ptr,P(e));var t=y().getInt32(i+0,!0),r=y().getFloat64(i+8,!0),o=y().getInt32(i+16,!0),s=y().getInt32(i+20,!0);if(s)throw T(o);return t===0?void 0:r}finally{p.__wbindgen_add_to_stack_pointer(32)}}setLocalState(e){p.awarenesswasm_setLocalState(this.__wbg_ptr,P(e))}removeOutdated(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_removeOutdated(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_new(i,P(e),t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return this.__wbg_ptr=r>>>0,ug.register(this,this.__wbg_ptr,this),this}finally{p.__wbindgen_add_to_stack_pointer(16)}}peer(){const e=p.awarenesswasm_peer(this.__wbg_ptr);return T(e)}apply(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(e,p.__wbindgen_malloc),a=X;p.awarenesswasm_apply(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}peers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_peers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_encode(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}length(){return p.awarenesswasm_length(this.__wbg_ptr)}isEmpty(){return p.awarenesswasm_isEmpty(this.__wbg_ptr)!==0}getState(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_getState(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encodeAll(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_encodeAll(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const dg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_changemodifier_free(n>>>0,1));class To{static __wrap(e){e=e>>>0;const t=Object.create(To.prototype);return t.__wbg_ptr=e,dg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,dg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_changemodifier_free(e,0)}setMessage(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X,o=p.changemodifier_setMessage(this.__wbg_ptr,t,r);return To.__wrap(o)}setTimestamp(e){const t=p.changemodifier_setTimestamp(this.__wbg_ptr,e);return To.__wrap(t)}}const fg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_cursor_free(n>>>0,1));class In{static __wrap(e){e=e>>>0;const t=Object.create(In.prototype);return t.__wbg_ptr=e,fg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_cursor_free(e,0)}containerId(){const e=p.cursor_containerId(this.__wbg_ptr);return T(e)}pos(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.cursor_pos(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.cursor_kind(this.__wbg_ptr);return T(e)}side(){const e=p.cursor_side(this.__wbg_ptr);return T(e)}static decode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(e,p.__wbindgen_malloc),a=X;p.cursor_decode(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return In.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.cursor_encode(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const gg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_ephemeralstorewasm_free(n>>>0,1));class Ku{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,gg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_ephemeralstorewasm_free(e,0)}getAllStates(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_getAllStates(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}removeOutdated(){p.ephemeralstorewasm_removeOutdated(this.__wbg_ptr)}subscribeLocalUpdates(e){const t=p.ephemeralstorewasm_subscribeLocalUpdates(this.__wbg_ptr,P(e));return T(t)}get(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X,o=p.ephemeralstorewasm_get(this.__wbg_ptr,t,r);return T(o)}constructor(e){const t=p.ephemeralstorewasm_new(e);return this.__wbg_ptr=t>>>0,gg.register(this,this.__wbg_ptr,this),this}set(e,t){const r=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),o=X;p.ephemeralstorewasm_set(this.__wbg_ptr,r,o,P(t))}keys(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_keys(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}apply(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Gn(e,p.__wbindgen_malloc),i=X;p.ephemeralstorewasm_apply(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X;p.ephemeralstorewasm_delete(this.__wbg_ptr,t,r)}encode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.ephemeralstorewasm_encode(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),o}finally{p.__wbindgen_add_to_stack_pointer(16)}}isEmpty(){return p.ephemeralstorewasm_isEmpty(this.__wbg_ptr)!==0}encodeAll(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_encodeAll(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){const t=p.ephemeralstorewasm_subscribe(this.__wbg_ptr,P(e));return T(t)}}const ol=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorocounter_free(n>>>0,1));class Vr{static __wrap(e){e=e>>>0;const t=Object.create(Vr.prototype);return t.__wbg_ptr=e,ol.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ol.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorocounter_free(e,0)}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isAttached(){return p.lorocounter_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorocounter_id(this.__wbg_ptr);return T(e)}constructor(){const e=p.lorocounter_new();return this.__wbg_ptr=e>>>0,ol.register(this,this.__wbg_ptr,this),this}kind(){const e=p.lorocounter_kind(this.__wbg_ptr);return T(e)}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}decrement(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_decrement(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get value(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}increment(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_increment(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const sl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorodoc_free(n>>>0,1));class sn{static __wrap(e){e=e>>>0;const t=Object.create(sn.prototype);return t.__wbg_ptr=e,sl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,sl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorodoc_free(e,0)}applyDiff(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_applyDiff(s,this.__wbg_ptr,P(e),De(t)?0:P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isShallow(){return p.lorodoc_isShallow(this.__wbg_ptr)!==0}changeCount(){return p.lorodoc_changeCount(this.__wbg_ptr)>>>0}getByPath(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorodoc_getByPath(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCounter(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getCounter(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Vr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}isDetached(){return p.lorodoc_isDetached(this.__wbg_ptr)!==0}get peerIdStr(){const e=p.lorodoc_peerIdStr(this.__wbg_ptr);return T(e)}setPeerId(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setPeerId(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursorPos(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);jo(e,In),p.lorodoc_getCursorPos(s,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}hasContainer(e){return p.lorodoc_hasContainer(this.__wbg_ptr,P(e))!==0}importBatch(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importBatch(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}cmpFrontiers(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(e,p.__wbindgen_malloc),l=X,c=Tt(t,p.__wbindgen_malloc),u=X;p.lorodoc_cmpFrontiers(i,this.__wbg_ptr,a,l,c,u);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}debugHistory(){p.lorodoc_debugHistory(this.__wbg_ptr)}static fromSnapshot(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(e,p.__wbindgen_malloc),a=X;p.lorodoc_fromSnapshot(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return sn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangeAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getChangeAt(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}oplogVersion(){const e=p.lorodoc_oplogVersion(this.__wbg_ptr);return At.__wrap(e)}getMovableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getMovableList(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}frontiersToVV(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=X;p.lorodoc_frontiersToVV(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getAllChanges(){const e=p.lorodoc_getAllChanges(this.__wbg_ptr);return T(e)}oplogFrontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_oplogFrontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}vvToFrontiers(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);jo(e,At),p.lorodoc_vvToFrontiers(s,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}shallowSinceVV(){const e=p.lorodoc_shallowSinceVV(this.__wbg_ptr);return At.__wrap(e)}configTextStyle(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_configTextStyle(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getOpsInChange(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getOpsInChange(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=jt(t,r).slice();return p.__wbindgen_free(t,r*4,4),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getShallowValue(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}checkoutToLatest(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_checkoutToLatest(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}cmpWithFrontiers(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=X;p.lorodoc_cmpWithFrontiers(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return t}finally{p.__wbindgen_add_to_stack_pointer(16)}}exportJsonInIdSpan(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_exportJsonInIdSpan(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribeJsonpath(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=X;p.lorodoc_subscribeJsonpath(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}deleteRootContainer(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_deleteRootContainer(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}exportJsonUpdates(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_exportJsonUpdates(a,this.__wbg_ptr,P(e),P(t),De(r)?16777215:r?1:0);var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getContainerById(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getContainerById(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getPendingTxnLength(){return p.lorodoc_getPendingTxnLength(this.__wbg_ptr)>>>0}importJsonUpdates(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importJsonUpdates(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}importUpdateBatch(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importBatch(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setDetachedEditing(e){p.lorodoc_setDetachedEditing(this.__wbg_ptr,e)}setRecordTimestamp(e){p.lorodoc_setRecordTimestamp(this.__wbg_ptr,e)}subscribePreCommit(e){const t=p.lorodoc_subscribePreCommit(this.__wbg_ptr,P(e));return T(t)}findIdSpansBetween(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(e,p.__wbindgen_malloc),l=X,c=Tt(t,p.__wbindgen_malloc),u=X;p.lorodoc_findIdSpansBetween(i,this.__wbg_ptr,a,l,c,u);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangeAtLamport(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=X;p.lorodoc_getChangeAtLamport(i,this.__wbg_ptr,a,l,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getPathToContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getPathToContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangedContainersIn(e,t){try{const l=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getChangedContainersIn(l,this.__wbg_ptr,P(e),t);var r=y().getInt32(l+0,!0),o=y().getInt32(l+4,!0),s=y().getInt32(l+8,!0),i=y().getInt32(l+12,!0);if(i)throw T(s);var a=jt(r,o).slice();return p.__wbindgen_free(r,o*4,4),a}finally{p.__wbindgen_add_to_stack_pointer(16)}}getDeepValueWithID(){const e=p.lorodoc_getDeepValueWithID(this.__wbg_ptr);return T(e)}setNextCommitOrigin(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X;p.lorodoc_setNextCommitOrigin(this.__wbg_ptr,t,r)}getUncommittedOpsAsJson(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getUncommittedOpsAsJson(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setNextCommitMessage(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X;p.lorodoc_setNextCommitMessage(this.__wbg_ptr,t,r)}setNextCommitOptions(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setNextCommitOptions(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}shallowSinceFrontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_shallowSinceFrontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribeLocalUpdates(e){const t=p.lorodoc_subscribeLocalUpdates(this.__wbg_ptr,P(e));return T(t)}travelChangeAncestors(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=X;p.lorodoc_travelChangeAncestors(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clearNextCommitOptions(){p.lorodoc_clearNextCommitOptions(this.__wbg_ptr)}configDefaultTextStyle(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_configDefaultTextStyle(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setChangeMergeInterval(e){p.lorodoc_setChangeMergeInterval(this.__wbg_ptr,e)}setNextCommitTimestamp(e){p.lorodoc_setNextCommitTimestamp(this.__wbg_ptr,e)}setHideEmptyRootContainers(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setHideEmptyRootContainers(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDetachedEditingEnabled(){return p.lorodoc_isDetachedEditingEnabled(this.__wbg_ptr)!==0}subscribeFirstCommitFromPeer(e){const t=p.lorodoc_subscribeFirstCommitFromPeer(this.__wbg_ptr,P(e));return T(t)}constructor(){const e=p.lorodoc_new();return this.__wbg_ptr=e>>>0,sl.register(this,this.__wbg_ptr,this),this}diff(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16),l=Tt(e,p.__wbindgen_malloc),c=X,u=Tt(t,p.__wbindgen_malloc),f=X;p.lorodoc_diff(a,this.__wbg_ptr,l,c,u,f,De(r)?16777215:r?1:0);var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}fork(){const e=p.lorodoc_fork(this.__wbg_ptr);return sn.__wrap(e)}attach(){p.lorodoc_attach(this.__wbg_ptr)}commit(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_commit(o,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}detach(){p.lorodoc_detach(this.__wbg_ptr)}export(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_export(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}import(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(e,p.__wbindgen_malloc),a=X;p.lorodoc_import(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}forkAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=X;p.lorodoc_forkAt(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return sn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getMap(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getMap(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}opCount(){return p.lorodoc_opCount(this.__wbg_ptr)>>>0}get peerId(){const e=p.lorodoc_peerId(this.__wbg_ptr);return BigInt.asUintN(64,e)}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_toJSON(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}version(){const e=p.lorodoc_version(this.__wbg_ptr);return At.__wrap(e)}checkout(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Tt(e,p.__wbindgen_malloc),i=X;p.lorodoc_checkout(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getList(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Yr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getText(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getText(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getTree(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Zr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}frontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_frontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}JSONPath(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorodoc_JSONPath(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}revertTo(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Tt(e,p.__wbindgen_malloc),i=X;p.lorodoc_revertTo(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){const t=p.lorodoc_subscribe(this.__wbg_ptr,P(e));return T(t)}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const il=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorolist_free(n>>>0,1));class Yr{static __wrap(e){e=e>>>0;const t=Object.create(Yr.prototype);return t.__wbg_ptr=e,il.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,il.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorolist_free(e,0)}isAttached(){return p.lorolist_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}pushContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_pushContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeValue(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getRangeValue(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insertContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_insertContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.lorolist_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeDeepValueWithID(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getRangeDeepValueWithID(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorolist_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_get(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.lorolist_new();return this.__wbg_ptr=e>>>0,il.register(this,this.__wbg_ptr,this),this}pop(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_pop(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.lorolist_kind(this.__wbg_ptr);return T(e)}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_push(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_insert(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.lorolist_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getIdAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getIdAt(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorolist_toJSON(this.__wbg_ptr);return T(e)}toArray(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toArray(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorolist_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTreeSlice(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toContainerTreeSlice(a,this.__wbg_ptr,e,t,De(r)?0:P(r));var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const al=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_loromap_free(n>>>0,1));class Xn{static __wrap(e){e=e>>>0;const t=Object.create(Xn.prototype);return t.__wbg_ptr=e,al.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,al.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_loromap_free(e,0)}isAttached(){return p.loromap_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastEditor(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X,o=p.loromap_getLastEditor(this.__wbg_ptr,t,r);return T(o)}setContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=X;p.loromap_setContainer(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.loromap_getShallowValue(this.__wbg_ptr);return T(e)}ensureMergeableMap(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableMap(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableList(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Yr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableText(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableText(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableTree(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Zr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getOrCreateContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=X;p.loromap_getOrCreateContainer(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableCounter(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableCounter(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Vr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableMovableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_ensureMergeableMovableList(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.loromap_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_get(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.loromap_new();return this.__wbg_ptr=e>>>0,al.register(this,this.__wbg_ptr,this),this}keys(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_keys(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.loromap_kind(this.__wbg_ptr);return T(e)}get size(){return p.loromap_size(this.__wbg_ptr)>>>0}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),i=X;p.loromap_delete(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}set(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.loromap_set(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}values(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_values(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}entries(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_entries(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.loromap_toJSON(this.__wbg_ptr);return T(e)}isDeleted(){return p.loromap_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const ll=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_loromovablelist_free(n>>>0,1));class Gr{static __wrap(e){e=e>>>0;const t=Object.create(Gr.prototype);return t.__wbg_ptr=e,ll.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ll.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_loromovablelist_free(e,0)}isAttached(){return p.loromovablelist_isAttached(this.__wbg_ptr)!==0}getCreatorAt(e){const t=p.loromovablelist_getCreatorAt(this.__wbg_ptr,e);return T(t)}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_setContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastMoverAt(e){const t=p.loromovablelist_getLastMoverAt(this.__wbg_ptr,e);return T(t)}pushContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_pushContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastEditorAt(e){const t=p.loromovablelist_getLastEditorAt(this.__wbg_ptr,e);return T(t)}getRangeValue(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getRangeValue(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insertContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_insertContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.loromovablelist_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeDeepValueWithID(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getRangeDeepValueWithID(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.loromovablelist_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_get(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}move(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_move(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.loromovablelist_new();return this.__wbg_ptr=e>>>0,ll.register(this,this.__wbg_ptr,this),this}pop(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_pop(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}set(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_set(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.loromovablelist_kind(this.__wbg_ptr);return T(e)}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_push(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_insert(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.loromovablelist_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.loromovablelist_toJSON(this.__wbg_ptr);return T(e)}toArray(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toArray(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.loromovablelist_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTreeSlice(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toContainerTreeSlice(a,this.__wbg_ptr,e,t,De(r)?0:P(r));var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const cl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotext_free(n>>>0,1));class Xr{static __wrap(e){e=e>>>0;const t=Object.create(Xr.prototype);return t.__wbg_ptr=e,cl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,cl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotext_free(e,0)}applyDelta(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_applyDelta(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}convertPos(e,t,r){const o=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),s=X,i=_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X,l=p.lorotext_convertPos(this.__wbg_ptr,e,o,s,i,a);return T(l)}deleteUtf8(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_deleteUtf8(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getEditorOf(e){const t=p.lorotext_getEditorOf(this.__wbg_ptr,e);return T(t)}insertUtf8(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorotext_insertUtf8(s,this.__wbg_ptr,e,i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isAttached(){return p.lorotext_isAttached(this.__wbg_ptr)!==0}sliceDelta(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_sliceDelta(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}updateByLine(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorotext_updateByLine(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}sliceDeltaUtf8(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_sliceDeltaUtf8(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getShallowValue(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorotext_id(this.__wbg_ptr);return T(e)}constructor(){const e=p.lorotext_new();return this.__wbg_ptr=e>>>0,cl.register(this,this.__wbg_ptr,this),this}iter(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_iter(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.lorotext_kind(this.__wbg_ptr);return T(e)}mark(e,t,r){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),l=X;p.lorotext_mark(i,this.__wbg_ptr,P(e),a,l,P(r));var o=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0);if(s)throw T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),i=X;p.lorotext_push(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}slice(e,t){let r,o;try{const f=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_slice(f,this.__wbg_ptr,e,t);var s=y().getInt32(f+0,!0),i=y().getInt32(f+4,!0),a=y().getInt32(f+8,!0),l=y().getInt32(f+12,!0),c=s,u=i;if(l)throw c=0,u=0,T(a);return r=c,o=u,He(c,u)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(r,o,1)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorotext_insert(s,this.__wbg_ptr,e,i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.lorotext_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}splice(e,t,r){let o,s;try{const d=p.__wbindgen_add_to_stack_pointer(-16),g=_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),h=X;p.lorotext_splice(d,this.__wbg_ptr,e,t,g,h);var i=y().getInt32(d+0,!0),a=y().getInt32(d+4,!0),l=y().getInt32(d+8,!0),c=y().getInt32(d+12,!0),u=i,f=a;if(c)throw u=0,f=0,T(l);return o=u,s=f,He(u,f)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(o,s,1)}}unmark(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorotext_unmark(s,this.__wbg_ptr,P(e),i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}update(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=X;p.lorotext_update(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}charAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_charAt(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return String.fromCodePoint(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorotext_toJSON(this.__wbg_ptr);return T(e)}toDelta(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toDelta(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorotext_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toString(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toString(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const ul=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotree_free(n>>>0,1));class Zr{static __wrap(e){e=e>>>0;const t=Object.create(Zr.prototype);return t.__wbg_ptr=e,ul.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ul.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotree_free(e,0)}createNode(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_createNode(i,this.__wbg_ptr,mt(e),De(t)?4294967297:t>>>0);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return on.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}isAttached(){return p.lorotree_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getNodeByID(e){try{const t=p.lorotree_getNodeByID(this.__wbg_ptr,mt(e));return t===0?void 0:on.__wrap(t)}finally{Be[et++]=void 0}}isNodeDeleted(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_isNodeDeleted(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return t!==0}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getShallowValue(){const e=p.lorotree_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}enableFractionalIndex(e){p.lorotree_enableFractionalIndex(this.__wbg_ptr,e)}disableFractionalIndex(){p.lorotree_disableFractionalIndex(this.__wbg_ptr)}isFractionalIndexEnabled(){return p.lorotree_isFractionalIndexEnabled(this.__wbg_ptr)!==0}get id(){const e=p.lorotree_id(this.__wbg_ptr);return T(e)}move(e,t,r){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_move(i,this.__wbg_ptr,mt(e),mt(t),De(r)?4294967297:r>>>0);var o=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0);if(s)throw T(o)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0,Be[et++]=void 0}}constructor(){const e=p.lorotree_new();return this.__wbg_ptr=e>>>0,ul.register(this,this.__wbg_ptr,this),this}kind(){const e=p.lorotree_kind(this.__wbg_ptr);return T(e)}nodes(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_nodes(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}roots(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_roots(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_delete(o,this.__wbg_ptr,mt(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorotree_toJSON(this.__wbg_ptr);return T(e)}has(e){try{return p.lorotree_has(this.__wbg_ptr,mt(e))!==0}finally{Be[et++]=void 0}}toArray(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_toArray(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getNodes(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getNodes(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorotree_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const pg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotreenode_free(n>>>0,1));class on{static __wrap(e){e=e>>>0;const t=Object.create(on.prototype);return t.__wbg_ptr=e,pg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,pg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotreenode_free(e,0)}__getClassname(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode___getClassname(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}creationId(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_creationId(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_isDeleted(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}moveBefore(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);jo(e,on),p.lorotreenode_moveBefore(o,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}createNode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_createNode(s,this.__wbg_ptr,De(e)?4294967297:e>>>0);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return on.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastMoveId(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_getLastMoveId(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_toJSON(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}fractionalIndex(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_fractionalIndex(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorotreenode_id(this.__wbg_ptr);return T(e)}move(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_move(s,this.__wbg_ptr,mt(e),De(t)?4294967297:t>>>0);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}get data(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_data(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return Xn.__wrap(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}index(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_index(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e===4294967297?void 0:e}finally{p.__wbindgen_add_to_stack_pointer(16)}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e===0?void 0:on.__wrap(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}creator(){const e=p.lorotreenode_creator(this.__wbg_ptr);return T(e)}children(){const e=p.lorotreenode_children(this.__wbg_ptr);return T(e)}moveAfter(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);jo(e,on),p.lorotreenode_moveAfter(o,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const hg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_undomanager_free(n>>>0,1));class Wu{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,hg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_undomanager_free(e,0)}groupStart(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_groupStart(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}topRedoValue(){const e=p.undomanager_topRedoValue(this.__wbg_ptr);return T(e)}topUndoValue(){const e=p.undomanager_topUndoValue(this.__wbg_ptr);return T(e)}setMaxUndoSteps(e){p.undomanager_setMaxUndoSteps(this.__wbg_ptr,e)}setMergeInterval(e){p.undomanager_setMergeInterval(this.__wbg_ptr,e)}addExcludeOriginPrefix(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=X;p.undomanager_addExcludeOriginPrefix(this.__wbg_ptr,t,r)}constructor(e,t){jo(e,sn);const r=p.undomanager_new(e.__wbg_ptr,P(t));return this.__wbg_ptr=r>>>0,hg.register(this,this.__wbg_ptr,this),this}peer(){const e=p.undomanager_peer(this.__wbg_ptr);return T(e)}redo(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_redo(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}undo(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_undo(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){p.undomanager_clear(this.__wbg_ptr)}pause(){p.undomanager_pause(this.__wbg_ptr)}resume(){p.undomanager_resume(this.__wbg_ptr)}canRedo(){return p.undomanager_canRedo(this.__wbg_ptr)!==0}canUndo(){return p.undomanager_canUndo(this.__wbg_ptr)!==0}groupEnd(){p.undomanager_groupEnd(this.__wbg_ptr)}isPaused(){return p.undomanager_isPaused(this.__wbg_ptr)!==0}setOnPop(e){p.undomanager_setOnPop(this.__wbg_ptr,P(e))}clearRedo(){p.undomanager_clearRedo(this.__wbg_ptr)}clearUndo(){p.undomanager_clearUndo(this.__wbg_ptr)}setOnPush(e){p.undomanager_setOnPush(this.__wbg_ptr,P(e))}}const dl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_versionvector_free(n>>>0,1));class At{static __wrap(e){e=e>>>0;const t=Object.create(At.prototype);return t.__wbg_ptr=e,dl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,dl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_versionvector_free(e,0)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_get(s,this.__wbg_ptr,P(e));var t=y().getFloat64(s+0,!0),r=y().getInt32(s+8,!0),o=y().getInt32(s+12,!0);if(o)throw T(r);return t===4294967297?void 0:t}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_new(s,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return this.__wbg_ptr=t>>>0,dl.register(this,this.__wbg_ptr,this),this}finally{p.__wbindgen_add_to_stack_pointer(16)}}static decode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Gn(e,p.__wbindgen_malloc),a=X;p.versionvector_decode(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_encode(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}length(){return p.versionvector_length(this.__wbg_ptr)>>>0}remove(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_remove(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setEnd(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_setEnd(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}compare(e){jo(e,At);const t=p.versionvector_compare(this.__wbg_ptr,e.__wbg_ptr);return t===4294967297?void 0:t}setLast(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_setLast(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.versionvector_toJSON(this.__wbg_ptr);return T(e)}static parseJSON(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_parseJSON(s,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}function Kk(n,e){const t=String(W(e)),r=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=X;y().setInt32(n+4,o,!0),y().setInt32(n+0,r,!0)}function Wk(){return nt(function(n,e,t){const r=W(n).apply(W(e),W(t));return P(r)},arguments)}function Hk(){return nt(function(n,e,t){const r=Reflect.apply(W(n),W(e),W(t));return P(r)},arguments)}function Jk(n){const e=W(n).buffer;return P(e)}function qk(){return nt(function(n,e){const t=W(n).call(W(e));return P(t)},arguments)}function Vk(){return nt(function(n,e,t){const r=W(n).call(W(e),W(t));return P(r)},arguments)}function Yk(){return nt(function(n,e,t,r){const o=W(n).call(W(e),W(t),W(r));return P(o)},arguments)}function Gk(){return nt(function(n,e,t,r,o){const s=W(n).call(W(e),W(t),W(r),W(o));return P(s)},arguments)}function Xk(n){const e=To.__wrap(n);return P(e)}function Zk(n){const e=W(n).crypto;return P(e)}function Qk(n){const e=In.__wrap(n);return P(e)}function eT(n){return W(n).done}function tT(n){const e=Object.entries(W(n));return P(e)}function nT(n){const e=W(n).entries();return P(e)}function rT(n,e){console.error(He(n,e))}function oT(n){const e=Array.from(W(n));return P(e)}function sT(n){const e=Object.getOwnPropertySymbols(W(n));return P(e)}function iT(){return nt(function(n,e){W(n).getRandomValues(W(e))},arguments)}function aT(){return nt(function(n,e){const t=Reflect.get(W(n),W(e));return P(t)},arguments)}function lT(n,e){const t=W(n)[e>>>0];return P(t)}function cT(n,e){return W(n)[e>>>0]}function uT(n,e){const t=W(n)[W(e)];return P(t)}function dT(n){let e;try{e=W(n)instanceof ArrayBuffer}catch{e=!1}return e}function fT(n){let e;try{e=W(n)instanceof Map}catch{e=!1}return e}function gT(n){let e;try{e=W(n)instanceof Object}catch{e=!1}return e}function pT(n){let e;try{e=W(n)instanceof Uint8Array}catch{e=!1}return e}function hT(n){return Array.isArray(W(n))}function _T(n){return Number.isSafeInteger(W(n))}function mT(){return P(Symbol.iterator)}function bT(n){return W(n).length}function yT(n){return W(n).length}function wT(n,e,t,r,o,s,i,a){let l,c;try{l=n,c=e,console.log(He(n,e),He(t,r),He(o,s),He(i,a))}finally{p.__wbindgen_free(l,c,1)}}function xT(n,e){let t,r;try{t=n,r=e,console.log(He(n,e))}finally{p.__wbindgen_free(t,r,1)}}function CT(n,e){console.log(He(n,e))}function ST(n){const e=Vr.__wrap(n);return P(e)}function vT(n){const e=Yr.__wrap(n);return P(e)}function kT(n){const e=Xn.__wrap(n);return P(e)}function TT(n){const e=Gr.__wrap(n);return P(e)}function IT(n){const e=Xr.__wrap(n);return P(e)}function ET(n){const e=Zr.__wrap(n);return P(e)}function NT(n){const e=on.__wrap(n);return P(e)}function LT(n,e){performance.mark(He(n,e))}function OT(){return nt(function(n,e,t,r){let o,s,i,a;try{o=n,s=e,i=t,a=r,performance.measure(He(n,e),He(t,r))}finally{p.__wbindgen_free(o,s,1),p.__wbindgen_free(i,a,1)}},arguments)}function RT(n){const e=W(n).msCrypto;return P(e)}function AT(){const n=new Object;return P(n)}function MT(){return P(new Map)}function $T(){const n=new Array;return P(n)}function DT(n){const e=new Uint8Array(W(n));return P(e)}function PT(n,e){const t=new Error(He(n,e));return P(t)}function jT(n,e){const t=new Function(He(n,e));return P(t)}function FT(n,e,t){const r=new Uint8Array(W(n),e>>>0,t>>>0);return P(r)}function BT(n){const e=new Uint8Array(n>>>0);return P(e)}function UT(n){const e=new Array(n>>>0);return P(e)}function zT(n){const e=W(n).next;return P(e)}function KT(){return nt(function(n){const e=W(n).next();return P(e)},arguments)}function WT(n){const e=W(n).node;return P(e)}function HT(){return Date.now()}function JT(){return nt(function(n){const e=Reflect.ownKeys(W(n));return P(e)},arguments)}function qT(n){const e=W(n).process;return P(e)}function VT(n,e){return W(n).push(W(e))}function YT(){return nt(function(n,e){W(n).randomFillSync(T(e))},arguments)}function GT(){return nt(function(){const n=module.require;return P(n)},arguments)}function XT(n){const e=Promise.resolve(W(n));return P(e)}function ZT(n,e,t){W(n)[e>>>0]=T(t)}function QT(n,e,t){W(n)[T(e)]=T(t)}function eI(n,e,t){W(n).set(W(e),t>>>0)}function tI(n,e,t){const r=W(n).set(W(e),W(t));return P(r)}function nI(){return nt(function(n,e,t){return Reflect.set(W(n),W(e),W(t))},arguments)}function rI(n,e,t){W(n)[e>>>0]=t}function oI(n,e){const t=Tk(Tn(n,e));return P(t)}function sI(n,e,t){const r=Sk(W(n),e,t);return P(r)}function iI(n,e,t){const r=Ck(n,W(e),T(t));return P(r)}function aI(){return nt(function(n,e,t){Ik(W(n),e>>>0,W(t))},arguments)}function lI(){return nt(function(n,e){const t=wk(T(n),e!==0);return P(t)},arguments)}function cI(n,e,t){const r=vk(He(n,e),t);return P(r)}function uI(){return nt(function(n,e,t){Ek(W(n),W(e),W(t))},arguments)}function dI(n,e,t){const r=xk(T(n),e>>>0,t>>>0);return P(r)}function fI(n){const e=kk(T(n));return P(e)}function gI(){const n=typeof globalThis>"u"?null:globalThis;return De(n)?0:P(n)}function pI(){const n=typeof globalThis>"u"?null:globalThis;return De(n)?0:P(n)}function hI(){const n=typeof self>"u"?null:self;return De(n)?0:P(n)}function _I(){const n=typeof window>"u"?null:window;return De(n)?0:P(n)}function mI(n,e,t){const r=W(n).subarray(e>>>0,t>>>0);return P(r)}function bI(n,e){const t=W(n).then(W(e));return P(t)}function yI(n){const e=W(n).value;return P(e)}function wI(n){const e=W(n).versions;return P(e)}function xI(n){const e=At.__wrap(n);return P(e)}function CI(n,e){console.warn(He(n,e))}function SI(n){return+W(n)}function vI(n){return P(n)}function kI(n){const e=BigInt.asUintN(64,n);return P(e)}function TI(n,e){const t=W(e),r=typeof t=="bigint"?t:void 0;y().setBigInt64(n+8,De(r)?BigInt(0):r,!0),y().setInt32(n+0,!De(r),!0)}function II(n){const e=W(n);return typeof e=="boolean"?e?1:0:2}function EI(n){const e=T(n).original;return e.cnt--==1?(e.a=0,!0):!1}function NI(n,e,t){const r=Rm(n,e,15,Bk);return P(r)}function LI(n,e,t){const r=Rm(n,e,15,Uk);return P(r)}function OI(n,e){const t=dc(W(e)),r=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=X;y().setInt32(n+4,o,!0),y().setInt32(n+0,r,!0)}function RI(n,e){const t=new Error(He(n,e));return P(t)}function AI(n,e){return W(n)in W(e)}function MI(n){return Array.isArray(W(n))}function $I(n){return typeof W(n)=="bigint"}function DI(n){return typeof W(n)=="function"}function PI(n){return W(n)===null}function jI(n){const e=W(n);return typeof e=="object"&&e!==null}function FI(n){return typeof W(n)=="string"}function BI(n){return W(n)===void 0}function UI(n,e){return W(n)===W(e)}function zI(n,e){return W(n)==W(e)}function KI(){const n=p.memory;return P(n)}function WI(n,e){const t=W(e),r=typeof t=="number"?t:void 0;y().setFloat64(n+8,De(r)?0:r,!0),y().setInt32(n+0,!De(r),!0)}function HI(n){return P(n)}function JI(n){const e=W(n);return P(e)}function qI(n){T(n)}function VI(n){throw T(n)}function YI(n,e){const t=W(e),r=typeof t=="string"?t:void 0;var o=De(r)?0:_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),s=X;y().setInt32(n+4,s,!0),y().setInt32(n+0,o,!0)}function GI(n,e){const t=He(n,e);return P(t)}function XI(n,e){throw new Error(He(n,e))}function ZI(n){const e=typeof W(n);return P(e)}const fl=Symbol("loroContainerId");function QI(n){const e=n.prototype,t=Object.getOwnPropertyDescriptor(e,"id"),r=t&&t.get,o=Object.getOwnPropertyDescriptor(e,"__destroy_into_raw"),s=o&&o.value;if(!r||!o||!s)throw new Error("Unexpected wasm-bindgen container wrapper shape");Object.defineProperty(e,"id",{...t,get(){if(this.__wbg_ptr===0)return r.call(this);const i=this[fl];if(i!==void 0)return i;const a=r.call(this);try{Object.defineProperty(this,fl,{configurable:!0,value:a})}catch{}return a}}),Object.defineProperty(e,"__destroy_into_raw",{...o,value(){try{delete this[fl]}catch{}return s.call(this)}})}function eE(n){const e=n.prototype,t=Object.getOwnPropertyDescriptor(e,"kind"),r=t&&t.value;if(typeof r!="function")throw new Error("Unexpected wasm-bindgen container wrapper shape");let o;Object.defineProperty(e,"kind",{...t,value(){return this.__wbg_ptr===0?r.call(this):(o===void 0&&(o=r.call(this)),o)}})}for(const n of[Xn,Xr,Yr,Zr,Gr,Vr])QI(n),eE(n);const Mm={AwarenessWasm:zk,ChangeModifier:To,Cursor:In,EphemeralStoreWasm:Ku,LORO_VERSION:Mk,LoroCounter:Vr,LoroDoc:sn,LoroList:Yr,LoroMap:Xn,LoroMovableList:Gr,LoroText:Xr,LoroTree:Zr,LoroTreeNode:on,UndoManager:Wu,VersionVector:At,__wbg_String_8f0eb39a4a4c2f66:Kk,__wbg_apply_36be6a55257c99bf:Wk,__wbg_apply_eb9e9b97497f91e4:Hk,__wbg_buffer_609cc3eee51ed158:Jk,__wbg_call_672a4d21634d4a24:qk,__wbg_call_7cccdd69e0791ae2:Vk,__wbg_call_833bed5770ea2041:Yk,__wbg_call_b8adc8b1d0a0d8eb:Gk,__wbg_changemodifier_new:Xk,__wbg_crypto_574e78ad8b13b65f:Zk,__wbg_cursor_new:Qk,__wbg_done_769e5ede4b31c67b:eT,__wbg_entries_3265d4158b33e5dc:tT,__wbg_entries_c8a90a7ed73e84ce:nT,__wbg_error_1d6f2b3f2c5a33ec:rT,__wbg_from_2a5d3e218e67aa85:oT,__wbg_getOwnPropertySymbols_97eebed6fe6e08be:sT,__wbg_getRandomValues_b8f5dbd5f3995a9e:iT,__wbg_get_67b2ba62fc30de12:aT,__wbg_get_b9b93047fe3cf45b:lT,__wbg_getindex_5b00c274b05714aa:cT,__wbg_getwithrefkey_1dc361bd10053bfe:uT,__wbg_instanceof_ArrayBuffer_e14585432e3737fc:dT,__wbg_instanceof_Map_f3469ce2244d2430:fT,__wbg_instanceof_Object_7f2dcef8f78644a4:gT,__wbg_instanceof_Uint8Array_17156bcf118086a9:pT,__wbg_isArray_a1eab7e0d067391b:hT,__wbg_isSafeInteger_343e2beeeece1bb0:_T,__wbg_iterator_9a24c88df860dc65:mT,__wbg_length_a446193dc22c12f8:bT,__wbg_length_e2d2a49132c1b256:yT,__wbg_log_0cc1b7768397bcfe:wT,__wbg_log_cb9e190acc5753fb:xT,__wbg_log_f665cabe523a97df:CT,__wbg_lorocounter_new:ST,__wbg_lorolist_new:vT,__wbg_loromap_new:kT,__wbg_loromovablelist_new:TT,__wbg_lorotext_new:IT,__wbg_lorotree_new:ET,__wbg_lorotreenode_new:NT,__wbg_mark_7438147ce31e9d4b:LT,__wbg_measure_fb7825c11612c823:OT,__wbg_msCrypto_a61aeb35a24c1329:RT,__wbg_new_405e22f390576ce2:AT,__wbg_new_5e0be73521bc8c17:MT,__wbg_new_78feb108b6472713:$T,__wbg_new_a12002a7f91c75be:DT,__wbg_new_c68d7209be747379:PT,__wbg_newnoargs_105ed471475aaf50:jT,__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a:FT,__wbg_newwithlength_a381634e90c276d4:BT,__wbg_newwithlength_c4c419ef0bc8a1f8:UT,__wbg_next_25feadfc0913fea9:zT,__wbg_next_6574e1a8a62d1055:KT,__wbg_node_905d3e251edff8a2:WT,__wbg_now_454cbad00d40f177:HT,__wbg_ownKeys_3930041068756f1f:JT,__wbg_process_dc0fbacc7c1c06f7:qT,__wbg_push_737cfc8c1432c2c6:VT,__wbg_randomFillSync_ac0988aba3254290:YT,__wbg_require_60cc747a6bc5215a:GT,__wbg_resolve_4851785c9c5f573d:XT,__wbg_set_37837023f3d740e8:ZT,__wbg_set_3f1d0b984ed272ed:QT,__wbg_set_65595bdd868b3009:eI,__wbg_set_8fc6bf8a5b1071d1:tI,__wbg_set_bb8cecf6a62b9f46:nI,__wbg_set_wasm:Nk,__wbg_setindex_dcd71eabf405bde1:rI,__wbg_stateBinary_9e1da8a4daa74bc6:oI,__wbg_stateCid_c43ea762fb462319:sI,__wbg_stateContainer_cd983f42c6fe987d:iI,__wbg_stateIndex_1fbac6394e58cff9:aI,__wbg_stateOptions_dcb483514d1b925d:lI,__wbg_stateRootCid_9198769cdd9f37d5:cI,__wbg_stateSet_a3e74b27d3d26f9d:uI,__wbg_stateSlice_aafffe8ecba122b8:dI,__wbg_stateValue_8ed644fcdb61558c:fI,__wbg_static_accessor_GLOBAL_88a902d13a557d07:gI,__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0:pI,__wbg_static_accessor_SELF_37c5d418e4bf5819:hI,__wbg_static_accessor_WINDOW_5de37043a91a9c40:_I,__wbg_subarray_aa9065fa9dc5df96:mI,__wbg_then_44b73946d2fb3e7d:bI,__wbg_value_cd1ffa7b1ab794f1:yI,__wbg_versions_c01dfd4722a88165:wI,__wbg_versionvector_new:xI,__wbg_warn_52b319b1b6be3d2f:CI,__wbindgen_as_number:SI,__wbindgen_bigint_from_i64:vI,__wbindgen_bigint_from_u64:kI,__wbindgen_bigint_get_as_i64:TI,__wbindgen_boolean_get:II,__wbindgen_cb_drop:EI,__wbindgen_closure_wrapper285:NI,__wbindgen_closure_wrapper544:LI,__wbindgen_debug_string:OI,__wbindgen_error_new:RI,__wbindgen_in:AI,__wbindgen_is_array:MI,__wbindgen_is_bigint:$I,__wbindgen_is_function:DI,__wbindgen_is_null:PI,__wbindgen_is_object:jI,__wbindgen_is_string:FI,__wbindgen_is_undefined:BI,__wbindgen_jsval_eq:UI,__wbindgen_jsval_loose_eq:zI,__wbindgen_memory:KI,__wbindgen_number_get:WI,__wbindgen_number_new:HI,__wbindgen_object_clone_ref:JI,__wbindgen_object_drop_ref:qI,__wbindgen_rethrow:VI,__wbindgen_string_get:YI,__wbindgen_string_new:GI,__wbindgen_throw:XI,__wbindgen_typeof:ZI,callPendingEvents:gc,decodeFrontiers:jk,decodeImportBlobMeta:fc,encodeFrontiers:Pk,isValidContainerId:Am,redactJsonUpdates:$k,run:Dk,setDebug:Fk},tE={"./loro_wasm_bg.js":Mm},nE=n=>{Mm.__wbg_set_wasm(n),rE(n)};function rE(n){typeof n.__wbindgen_start=="function"&&n.__wbindgen_start()}function oE(n){if(typeof XMLHttpRequest!="function")throw new Error("loro-crdt browser build requires XMLHttpRequest for synchronous WASM loading. Use the nodejs, web, base64, or bundler entry for this runtime.");const e=new XMLHttpRequest;if(e.open("GET",n,!1),e.overrideMimeType("text/plain; charset=x-user-defined"),e.send(null),e.status!==0&&(e.status<200||e.status>=300))throw new Error(`Failed to load loro-crdt WASM from ${n}: ${e.status} ${e.statusText}`);const t=e.responseText,r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o)&255;return r}function sE(n,e){const t=new WebAssembly.Module(n);return new WebAssembly.Instance(t,e)}const iE=new URL(""+new URL("../assets/loro_wasm_bg-BjoaHtGs.wasm",import.meta.url).href,import.meta.url),aE=sE(oE(iE.href),tE);nE(aE.exports);const lE=["Map","Text","List","Tree","MovableList","Counter"];function cE(n){return Am(n)}function _g(n){if(typeof n!="object"||n==null)return!1;const e=Object.getPrototypeOf(n);return e==null||typeof e!="object"||typeof e.kind!="function"?!1:lE.includes(n.kind())}class uE{constructor(e=3e4){this.inner=new Ku(e),this.timeout=e}apply(e){this.inner.apply(e),this.startTimerIfNotEmpty()}set(e,t){this.inner.set(e,t),this.startTimerIfNotEmpty()}delete(e){this.inner.delete(e)}get(e){return this.inner.get(e)}getAllStates(){return this.inner.getAllStates()}encode(e){return this.inner.encode(e)}encodeAll(){return this.inner.encodeAll()}keys(){return this.inner.keys()}destroy(){clearInterval(this.timer)}subscribe(e){return this.inner.subscribe(e)}subscribeLocalUpdates(e){return this.inner.subscribeLocalUpdates(e)}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{this.inner.removeOutdated(),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}sn.prototype.toJsonWithReplacer=function(n){const e=new Set,t=this,r=(i,a)=>{if(typeof a=="string"&&cE(a)&&!e.has(a)){e.add(a);const c=t.getContainerById(a);if(c==null)throw new Error(`ContainerID not found: ${a}`);const u=n(i,c);if(u===c){const f=c.getShallowValue();return typeof f=="object"?o(f):f}if(_g(u))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof u=="object"&&u!=null?o(u):u}if(typeof a=="object"&&a!=null)return o(a);const l=n(i,a);if(_g(l))throw new Error("Using new container is not allowed in toJsonWithReplacer");return l},o=i=>{if(Array.isArray(i))return i.map((l,c)=>r(c,l)).filter(l=>l!==void 0);const a={};for(const[l,c]of Object.entries(i)){const u=r(l,c);u!==void 0&&(a[l]=u)}return a},s=t.getShallowValue();return o(s)};const mg=Symbol("loro.callPendingEventsWrapped");function dE(n,e){const t=Object.getOwnPropertyDescriptor(n,e);if(!t||typeof t.value!="function")return;const r=t.value;if(r[mg])return;const o=function(...s){let i;try{return i=r.apply(this,s),i}finally{i&&typeof i.then=="function"?i.finally(()=>{gc()}):gc()}};o[mg]=!0,Object.defineProperty(n,e,{...t,value:o})}function Hu(n,e){for(const t of e)dE(n,t)}Hu(sn.prototype,["setDetachedEditing","attach","detach","fork","forkAt","checkoutToLatest","checkout","commit","getCursorPos","revertTo","export","exportJsonUpdates","exportJsonInIdSpan","importJsonUpdates","import","importUpdateBatch","importBatch","travelChangeAncestors","getChangedContainersIn","diff","applyDiff","setPeerId"]);Hu(Ku.prototype,["set","delete","apply","removeOutdated"]);Hu(Wu.prototype,["undo","redo"]);const fE=he("CONNECTED_COMMAND"),gE=he("TOGGLE_CONNECT_COMMAND");function pE(n){return new Wu(n.doc,{mergeInterval:1e3,maxUndoSteps:100,excludeOriginPrefixes:["collab-","sync-"]})}function hE(n,e,t,r,o){n.awareness.setLocalState({anchorPos:null,awarenessData:o,color:t,focusPos:null,focusing:r,name:e})}function bg(n,e,t,r,o){const{awareness:s}=n;let i=s.getLocalState();i===null&&(i={anchorPos:null,awarenessData:o,color:t,focusPos:null,focusing:r,name:e}),i.name=e,i.color=t,i.focusing=r,s.setLocalState(i)}function _E(n,e,t){const{awareness:r}=n;let o=r.getLocalState();o===null?o={anchorPos:null,awarenessData:{},color:t,focusPos:null,focusing:!1,name:e}:(o.name=e,o.color=t),r.setLocalState(o)}function mE(n,e,t){const o=Ue().getLoroNodeByLexicalKey(n,void 0,void 0,0);if(e)try{if("key"in e||"__key"in e||"lexicalKey"in e){const{key:s,__key:i,lexicalKey:a,children:l,...c}=e;Se(o,"lexical",c)}else{const{children:s,...i}=e;Se(o,"lexical",i)}}catch(s){console.warn("Failed to store lexical node JSON for RootNode:",s)}return Se(o,"elementType","root"),Se(o,"createdAt",Date.now()),o.id}function bE(n,e,t){const o=Ue().getLoroNodeByLexicalKey(n,void 0);if(e)try{if("key"in e||"__key"in e||"lexicalKey"in e){const{key:s,__key:i,lexicalKey:a,children:l,...c}=e;Se(o,"lexical",c)}else{const{children:s,...i}=e;Se(o,"lexical",i)}}catch(s){console.warn("Failed to store lexical node JSON for RootNode update:",s)}Se(o,"elementType","root")}function yE(n,e){Ue().deleteMapping(n)}function wE(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o){let s;n.editorState.read(()=>{if(o.getType()==="root")try{s=o.exportJSON()}catch(i){console.warn("Failed to export root node JSON:",i)}}),s&&mE(t,s)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o){let s;n.editorState.read(()=>{if(o.getType()==="root")try{s=o.exportJSON()}catch(i){console.warn("Failed to export root node JSON for update:",i)}}),s&&bE(t,s)}break}case"destroyed":{yE(t);break}}}function xE(n,e,t,r,o){const i=Ue().getLoroNodeByLexicalKey(n,void 0,e,t);if(r){const{key:a,__key:l,lexicalKey:c,children:u,...f}=r;Se(i,"lexical",f)}return Se(i,"elementType","linebreak"),Se(i,"createdAt",Date.now()),i.id}function CE(n,e,t,r,o){const s=Ue(),{tree:i}=o,a=s.getLoroNodeByLexicalKey(n,void 0);if(!a)return;const l=a.id;if(r){const{key:c,__key:u,lexicalKey:f,children:d,...g}=r;Se(a,"lexical",g)}(e!==void 0||t!==void 0)&&Gi(i,l,e,t),Se(a,"elementType","linebreak")}function SE(n,e){Ue().deleteMapping(n)}function vE(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o&&ue(o)){const{parentId:s,index:i,lexicalNodeJSON:a}=n.editorState.read(()=>{const l=o.getParent(),c=Ue(),u=l?c.getTreeIDByLexicalKey(l.getKey()):void 0,f=o.getIndexWithinParent();let d;try{d=o.exportJSON()}catch(g){console.warn("Failed to export node JSON in propagateLineBreakNode created:",g)}return{parentId:u,index:f,lexicalNodeJSON:d}});xE(t,s,i,a)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o&&ue(o)){const{parentId:s,index:i,lexicalNodeJSON:a}=n.editorState.read(()=>{const l=o.getParent(),c=Ue(),u=l?c.getTreeIDByLexicalKey(l.getKey()):void 0,f=o.getIndexWithinParent();let d;try{d=o.exportJSON()}catch(g){console.warn("Failed to export node data in propagateLineBreakNode updated:",g)}return{parentId:u,index:f,lexicalNodeJSON:d}});CE(t,s,i,a,r)}break}case"destroyed":{SE(t);break}}}function kE(n,e,t,r,o,s,i){const l=Ue().getLoroNodeByLexicalKey(n,void 0,t,r);if(s){const{key:c,__key:u,lexicalKey:f,children:d,...g}=s;Se(l,"lexical",g)}return Se(l,"elementType",e),Se(l,"createdAt",Date.now()),l.id}function TE(n,e,t,r,o,s,i,a,l){const u=Ue().getLoroNodeByLexicalKey(n,void 0);if(a){const{key:f,__key:d,lexicalKey:g,children:h,..._}=a;Se(u,"lexical",_)}if(e!==void 0&&Se(u,"elementType",e),t!==void 0||r!==void 0){const{tree:f}=l;dt(!(t&&u.id===t),"updateElementNodeInLoro: cycle move (node is its own parent)",{nodeKey:n,treeId:u.id});const d=u.parent(),g=d?d.id:void 0,_=(d?d.children()??[]:f.roots()).findIndex(w=>w.id===u.id),m=g===t;if(!m||r!==void 0&&r!==_){const w=t?f.getNodeByID(t):null,C=w?w.children()?.length??0:f.roots().length;if(r!==void 0){let v=r;const k=m?Math.max(C-1,0):C;if(v<0||v>k){const I=w?w.children()??[]:f.roots();if(o){const E=I.findIndex(N=>N.id===o);E>=0&&(v=E+1)}if((v<0||v>k)&&s){const E=I.findIndex(N=>N.id===s);E>=0&&(v=E)}if(v<0||v>k){const E=Math.min(Math.max(v,0),k);console.warn("[loro-collab] updateElementNodeInLoro: clamping out-of-range move index",{nodeKey:n,treeId:u.id,index:r,targetIndex:v,clamped:E,maxIndex:k,sameParent:m,previousSiblingId:o,nextSiblingId:s}),v=E}}Gi(f,u.id,t,v)}else Gi(f,u.id,t,C)}}}function IE(n,e){Ue().deleteMapping(n)}function EE(n,e,t,r){const{tree:o}=r;switch(e){case"created":{const s=n.editorState._nodeMap.get(t);if(s&&q(s)){let i,a,l,c;const u={};let f;n.editorState.read(()=>{i=s.getParent();const d=Ue();a=i?d.getTreeIDByLexicalKey(i.getKey()):void 0,l=s.getIndexWithinParent(),a&&d.getTreeIDByLexicalKey(t)===a&&(a=void 0),c=s.getType(),i&&!a&&console.warn(` ElementNodePropagator: parent mapping missing for ${c} nodeKey=${t}, parentKey=${i.getKey()}`),typeof s.getFormat=="function"&&(u.format=s.getFormat()),typeof s.getStyle=="function"&&(u.style=s.getStyle()),typeof s.getDirection=="function"&&(u.direction=s.getDirection()),f=s.exportJSON()}),kE(t,c,a,l,u,f)}break}case"updated":{const s=n.editorState._nodeMap.get(t);if(s&&q(s)){let i,a,l,c,u,f;const d={};let g;n.editorState.read(()=>{i=s.getParent();const h=Ue();if(a=i?h.getTreeIDByLexicalKey(i.getKey()):void 0,l=s.getIndexWithinParent(),i){const _=i.getChildren();for(let m=l-1;m>=0;m--){const b=_[m],w=h.getTreeIDByLexicalKey(b.getKey());if(w&&qt(o,w)){c=w;break}}for(let m=l+1;m<_.length;m++){const b=_[m],w=h.getTreeIDByLexicalKey(b.getKey());if(w&&qt(o,w)){u=w;break}}}f=s.getType(),typeof s.getFormat=="function"&&(d.format=s.getFormat()),typeof s.getStyle=="function"&&(d.style=s.getStyle()),typeof s.getDirection=="function"&&(d.direction=s.getDirection()),g=s.exportJSON()}),TE(t,f,a,l,c,u,d,g,r)}break}case"destroyed":{IE(t);break}}}function gl(n,e,t,r,o,s,i,a){const l=Ue();dt(o!==void 0,"createTextNodeInLoro: text node has no parent in Loro tree",{nodeKey:n});const c=l.getLoroNodeByLexicalKey(n,void 0,o,s);if(i)try{if("key"in i||"__key"in i||"lexicalKey"in i){const{key:u,__key:f,lexicalKey:d,children:g,...h}=i;Se(c,"lexical",h)}else{const{children:u,...f}=i;Se(c,"lexical",f)}}catch(u){console.warn("Failed to store lexical node JSON for TextNode:",u)}return Se(c,"elementType","text"),Se(c,"createdAt",Date.now()),c.id}function NE(n,e,t,r,o,s){const a=Ue().getTreeIDByLexicalKey(n);if(!a||!qt(s?.tree,a))return;const l=s.tree.getNodeByID(a);if(l){if(o)if("key"in o||"__key"in o||"lexicalKey"in o){const{key:c,__key:u,lexicalKey:f,children:d,...g}=o;Se(l,"lexical",g)}else{const{children:c,...u}=o;Se(l,"lexical",u)}Se(l,"elementType","text")}}function LE(n,e){Ue().deleteMapping(n)}function OE(n,e,t,r){const{tree:o}=r;switch(e){case"created":{const s=n.editorState._nodeMap.get(t),i=Ue(),a=i.getTreeIDByLexicalKey(t);if(a&&s&&oe(s)){const{currentParentId:l,expectedParentId:c}=n.editorState.read(()=>{const u=s.getParent(),f=u?i.getTreeIDByLexicalKey(u.getKey()):void 0;let d;try{const g=o.getNodeByID(a);if(g){const h=g.parent();d=h?h.id.toString():void 0}}catch(g){console.warn(` Failed to get parent for existing TreeID ${a}:`,g)}return{currentParentId:d,expectedParentId:f}});if(l===c)return;{let u=a;try{const f=o.getNodeByID(a);f&&(u=f.id)}catch(f){console.warn(` Could not get TreeNode for ${a} during creation:`,f)}i.deleteMapping(t);try{qt(o,u)&&o.delete(u)}catch(f){console.warn(` Failed to delete TreeNode ${u} during creation:`,f)}}}if(s&&oe(s)){const{parent:l,parentId:c,index:u,textContent:f,format:d,mode:g,lexicalNodeJSON:h}=n.editorState.read(()=>{const _=s.getParent(),m=Ue(),b=_?m.getTreeIDByLexicalKey(_.getKey()):void 0,w=s.getIndexWithinParent(),C=s.getTextContent(),v=s.getFormat(),k=s.getMode();let I;try{I=s.exportJSON()}catch(E){console.warn("Failed to export node JSON in propagateTextNode created:",E)}return{parent:_,parentId:b,index:w,textContent:C,format:v,mode:k,lexicalNodeJSON:I}});gl(t,f,d,g,c,u,h)}break}case"updated":{const s=n.editorState._nodeMap.get(t);if(s&&oe(s)){const i=Ue(),a=i.getTreeIDByLexicalKey(t);if(a){const{currentParentId:d,expectedParentId:g,parent:h}=n.editorState.read(()=>{const _=s.getParent(),m=_?i.getTreeIDByLexicalKey(_.getKey()):void 0;let b;try{const w=o.getNodeByID(a);if(w){const C=w.parent();b=C?C.id.toString():void 0}}catch(w){console.warn(` Failed to get parent for existing TreeID ${a} during update:`,w)}return{currentParentId:b,expectedParentId:m,parent:_}});if(d!==g){let _=a;try{const I=o.getNodeByID(a);I&&(_=I.id)}catch(I){console.warn(` Could not get TreeNode for ${a}:`,I)}i.deleteMapping(t);try{qt(o,_)&&o.delete(_)}catch(I){console.warn(` Failed to delete TreeNode ${_} during update:`,I)}const{parentId:m,index:b,textContent:w,format:C,mode:v,lexicalNodeJSON:k}=n.editorState.read(()=>{const I=h?i.getTreeIDByLexicalKey(h.getKey()):void 0,E=s.getIndexWithinParent(),N=s.getTextContent(),O=s.getFormat(),M=s.getMode();let R;try{R=s.exportJSON()}catch($){console.warn("Failed to export node JSON during TextNode recreation:",$)}return{parentId:I,index:E,textContent:N,format:O,mode:M,lexicalNodeJSON:R}});gl(t,w,C,v,m,b,k);return}}if(!a){const{parent:d,parentId:g,index:h,textContent:_,format:m,mode:b,lexicalNodeJSON:w}=n.editorState.read(()=>{const C=s.getParent(),v=C?i.getTreeIDByLexicalKey(C.getKey()):void 0,k=s.getIndexWithinParent(),I=s.getTextContent(),E=s.getFormat(),N=s.getMode();let O;try{O=s.exportJSON()}catch(M){console.warn("Failed to export node JSON in propagateTextNode updated(create fallback):",M)}return{parent:C,parentId:v,index:k,textContent:I,format:E,mode:N,lexicalNodeJSON:O}});g!==void 0&&gl(t,_,m,b,g,h,w);return}const{textContent:l,format:c,mode:u,lexicalNodeJSON:f}=n.editorState.read(()=>{const d=s.getTextContent(),g=s.getFormat(),h=s.getMode();let _;try{_=s.exportJSON()}catch(m){console.warn("Failed to export node JSON in propagateTextNode updated:",m)}return{textContent:d,format:g,mode:h,lexicalNodeJSON:_}});NE(t,l,c,u,f,r)}break}case"destroyed":{LE(t);break}}}function RE(n,e,t,r,o,s,i,a){const c=Ue().getLoroNodeByLexicalKey(n,void 0,r,o);if(i){const{key:u,__key:f,lexicalKey:d,children:g,...h}=i;Se(c,"lexical",h)}return Se(c,"elementType","decorator"),Se(c,"createdAt",Date.now()),c.id}function AE(n,e,t,r,o,s,i,a){const c=Ue().getLoroNodeByLexicalKey(n,void 0);if(!c)return;const{tree:u}=a,f=c.id;if(i){const{key:d,__key:g,lexicalKey:h,children:_,...m}=i;Se(c,"lexical",m)}(r!==void 0||o!==void 0)&&Gi(u,f,r,o),Se(c,"elementType","decorator")}function ME(n,e){Ue().deleteMapping(n)}function $E(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o&&It(o)){const{parentId:s,index:i,decoratorType:a,decoratorData:l,metadata:c,lexicalNodeJSON:u}=n.editorState.read(()=>{const f=o.getParent(),d=Ue(),g=f?d.getTreeIDByLexicalKey(f.getKey()):void 0,h=o.getIndexWithinParent(),_=o.getType(),m=o.__decoratorData||{},b={};typeof o.isInline=="function"&&(b.isInline=o.isInline());let w;try{w=o.exportJSON()}catch(C){console.warn("Failed to export node data in propagateDecoratorNode created:",C)}return{parentId:g,index:h,decoratorType:_,decoratorData:m,metadata:b,lexicalNodeJSON:w}});RE(t,a,l,s,i,c,u)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o&&It(o)){const{parentId:s,index:i,decoratorType:a,decoratorData:l,metadata:c,lexicalNodeJSON:u}=n.editorState.read(()=>{const f=o.getParent(),d=Ue(),g=f?d.getTreeIDByLexicalKey(f.getKey()):void 0,h=o.getIndexWithinParent(),_=o.getType(),m=o.__decoratorData||{},b={};typeof o.isInline=="function"&&(b.isInline=o.isInline());let w;try{w=o.exportJSON()}catch(C){console.warn("Failed to export node data in propagateDecoratorNode updated:",C)}return{parentId:g,index:h,decoratorType:_,decoratorData:m,metadata:b,lexicalNodeJSON:w}});AE(t,a,l,s,i,c,u,r)}break}case"destroyed":{ME(t);break}}}function DE(n,e,t){ak(n.nodeMapper,()=>PE(n,e,t))}function PE(n,e,t){const{prevEditorState:r,editorState:o}=t,{dirtyElements:s,dirtyLeaves:i}=t,a=s.size===0&&i.size===0?null:t.mutatedNodes??jE(t);let l=0;if(a&&a.forEach(c=>{l+=c.size}),ye("[SEED-DEBUG] syncLexicalToLoro: mutatedNodes=",a?"map":"null","totalMutations=",l,"tags=",Array.from(t.tags)),a){const c=n.tree;Wt(n.doc);const u={tree:c};let f=!1;if(a.forEach(d=>{d.size>0&&(f=!0)}),f){a.forEach((h,_)=>{so(_,Dd)&&h.forEach((m,b)=>{wE(t,m,b)})});const d=[];a.forEach((h,_)=>{let m=null;if(so(_,Dd)||(so(_,Oe)?m="element":so(_,cn)?m="text":so(_,lw)?m="linebreak":so(_,Bt)&&(m="decorator"),m===null))return;const b=m;h.forEach((w,C)=>{let v=0,k=0;o.read(()=>{const I=Q(C);if(I){k=I.getIndexWithinParent();let E=I.getParent();for(;E;)v++,E=E.getParent()}}),d.push({mutation:w,nodeKey:C,depth:v,index:k,category:b})})});const g=h=>{switch(h.category){case"element":EE(t,h.mutation,h.nodeKey,u);break;case"text":OE(t,h.mutation,h.nodeKey,u);break;case"linebreak":vE(t,h.mutation,h.nodeKey,u);break;case"decorator":$E(t,h.mutation,h.nodeKey,u);break}};d.filter(h=>h.mutation==="destroyed").sort((h,_)=>_.depth-h.depth).forEach(g),d.filter(h=>h.mutation==="created").sort((h,_)=>h.depth-_.depth||h.index-_.index).forEach(g),d.filter(h=>h.mutation==="updated").sort((h,_)=>h.depth-_.depth||h.index-_.index).forEach(g),n.doc.commit({origin:n.doc.peerIdStr})}}o.read(()=>{const c=D(),u=r._selection;Em(n,e,u,c)})}function jE(n){const{dirtyElements:e,dirtyLeaves:t,prevEditorState:r,editorState:o}=n;if(e.size===0&&t.size===0)return null;const s=r._nodeMap,i=o._nodeMap,a=new Map,l=(c,u)=>{const f=c.constructor;let d=a.get(f);d||(d=new Map,a.set(f,d)),d.set(c.getKey(),u)};return i.forEach((c,u)=>{s.has(u)?(e.has(u)||t.has(u))&&l(c,"updated"):l(c,"created")}),s.forEach((c,u)=>{i.has(u)||l(c,"destroyed")}),a}function yg(n){return n&&typeof n=="object"&&typeof n.toJSON=="function"?n.toJSON():n}function FE(n,e,t,r,o){dt(qt(e,n),"NodeFactory: TreeID not live in Loro tree",{treeId:n});const s=e.getNodeByID(n);let i=yg(o?.lexical);if(i||(i=yg(s?.data.get("lexical"))),!i||typeof i!="object"){const f=s?.data.get("elementType")||s?.data.get("nodeType");dt(typeof f=="string"&&f.length>0,"NodeFactory: no lexical data or elementType for TreeID",{treeId:n}),i={type:f,version:1}}const a=i.type||i.__type;dt(!!a,"NodeFactory: no type field in lexical data for TreeID",{treeId:n});const c=t.editor._nodes.get(a);dt(c!=null,"NodeFactory: node type is not registered in the editor",{treeId:n,nodeType:a});const u={...i};return u.type||(u.type=a),u.version===void 0&&(u.version=1),"children"in u||(u.children=[]),c.klass.importJSON(u)}class BE{integrate(e,t,r){t.editor.update(()=>{this.integrateInternal(e,t,r)})}integrateInternal(e,t,r){const o=[],s=[],i=[];for(const _ of e.diff)switch(_.action){case"delete":o.push(_);break;case"create":s.push(_);break;case"move":i.push(_);break}const a=new Map;for(const _ of i)a.set(String(_.target),_);const l=new Set;for(const _ of s)if(_.parent===void 0){const m=a.get(String(_.target));m&&m.parent!==void 0&&(_.parent=m.parent,_.index=m.index,l.add(String(_.target)))}let c=i.filter(_=>!l.has(String(_.target)));const u=new Set;for(const _ of s)qt(t.tree,_.target)||u.add(String(_.target));for(let _=!0;_;){_=!1;for(const m of s){const b=String(m.target);!u.has(b)&&m.parent!==void 0&&u.has(String(m.parent))&&(u.add(b),_=!0)}}const f=u.size===0?s:s.filter(_=>!u.has(String(_.target)));u.size>0&&(c=c.filter(_=>!u.has(String(_.target))));const d=this.topologicalSortCreates(f,t);o.forEach(_=>this.integrateDelete(_,t,r));const g=new Map;let h=d;for(;h.length>0;){const _=[];for(const m of h)this.integrateCreate(m,t,r,g)==="deferred"&&_.push(m);_.length===h.length&&dt(!1,"TreeIntegrator: create operations reference parents missing from the batch",{pending:_.map(m=>({target:String(m.target),parent:m.parent?String(m.parent):null,parentInTree:m.parent?qt(t.tree,m.parent):null,parentMapped:m.parent?t.nodeMapper.getLexicalKeyByLoroId(m.parent)??null:null})),roots:t.tree.roots().map(m=>String(m.id))}),h=_}c.forEach(_=>this.integrateMove(_,t,r))}integrateCreate(e,t,r,o){if(e.parent==null){const l=t.tree.getNodeByID(e.target),c=l?.data.get("elementType"),u=l?.data.get("lexical")?.type;if(c==="root"||u==="root"||!c){const f=se(),d=t.nodeMapper.getTreeIDByLexicalKey(f.getKey());if(d===void 0||!qt(t.tree,d)){t.nodeMapper.setMapping(f.getKey(),e.target);for(const g of f.getChildren())t.nodeMapper.hasLexicalMapping(g.getKey())||g.remove()}else d!==e.target&&t.nodeMapper.aliasLoroId(e.target,f.getKey());return"created"}}const s=t.nodeMapper.getLexicalKeyByLoroId(e.target);if(s!==null&&Q(s)!==null)return"created";const i=String(e.target);let a=o.get(i);if(a===void 0&&(a=FE(e.target,t.tree,t),o.set(i,a)),dt(a!=null,"integrateCreate: failed to materialise Lexical node from Loro data",{target:i}),e.parent){const l=t.nodeMapper.getLexicalKeyByLoroId(e.parent),c=l?Q(l):null;if(!(c&&q(c)))return"deferred";this.insertChild(c,a,e.index)}else dt(this.canBeRootChild(a),"integrateCreate: inline node has no parent (cannot live at root)",{target:i,nodeType:a.getType()}),this.insertChild(se(),a,e.index);return t.nodeMapper.setMapping(a.getKey(),e.target),"created"}canBeRootChild(e){return q(e)||It(e)}insertChild(e,t,r){r!==void 0?e.splice(r,0,[t]):e.append(t)}integrateMove(e,t,r){const o=t.nodeMapper.getLexicalKeyByLoroId(e.target);dt(o!=null,"integrateMove: no Lexical key for move target",{target:String(e.target)});const s=Q(o);dt(s!=null,"integrateMove: node to move not found",{lexicalKey:o});let i;if(e.parent){const a=t.nodeMapper.getLexicalKeyByLoroId(e.parent),l=a?Q(a):null;dt(l!=null&&q(l),"integrateMove: move target parent is not a mapped element",{target:String(e.target),parent:String(e.parent)}),i=l}else dt(this.canBeRootChild(s),"integrateMove: inline node cannot be moved to the root",{lexicalKey:o,nodeType:s.getType()}),i=se();s.remove(),s.isAttached()&&wg(s),e.index!==void 0?i.splice(e.index,0,[s]):i.append(s)}integrateDelete(e,t,r){const o=t.nodeMapper.getLexicalKeyByLoroId(e.target);if(!o)return;const s=Q(o);if(!s){t.nodeMapper.removeMappingForKey(o);return}if(s===se())return;const i=this.collectDescendantKeys(s);for(const a of i)t.nodeMapper.removeMappingForKey(a);s.remove(),s.isAttached()&&wg(s),t.nodeMapper.removeMappingForKey(o)}collectDescendantKeys(e){if(!q(e))return[];const t=[],r=[...e.getChildren()];for(;r.length>0;){const o=r.pop();t.push(o.getKey()),q(o)&&r.push(...o.getChildren())}return t}topologicalSortCreates(e,t){if(e.length<=1)return e;const r=new Set(e.map(l=>String(l.target))),o=new Map;for(const l of e)l.parent&&o.set(String(l.target),String(l.parent));const s=new Map,i=l=>{if(s.has(l))return s.get(l);let c=0,u=l;const f=new Set;for(;o.has(u);){const d=o.get(u);if(f.has(d))break;if(f.add(d),r.has(d))c++,u=d;else break}return s.set(l,c),c},a=e.map((l,c)=>({op:l,depth:i(String(l.target)),idx:c}));return a.sort((l,c)=>l.depth-c.depth||l.idx-c.idx),a.map(l=>l.op)}}function wg(n){Bt.prototype.remove.call(n,!1)}class UE{integrate(e,t,r){e.updated&&Object.entries(e.updated).forEach(([o,s])=>{this.integratePropertyUpdate(o,s,t,r)}),e.deleted&&e.deleted.forEach(o=>{this.integratePropertyDelete(o,t,r)})}integrateWithContext(e,t,r,o){this.integrateWithContextInternal(e,t,r,o)}integrateInternal(e,t,r){e.updated&&Object.entries(e.updated).forEach(([o,s])=>{this.integratePropertyUpdate(o,s,t,r)}),e.deleted&&e.deleted.forEach(o=>{this.integratePropertyDelete(o,t,r)})}integrateWithContextInternal(e,t,r,o){e.updated&&Object.entries(e.updated).forEach(([s,i])=>{this.integratePropertyUpdateWithContextInternal(s,i,t,r,o)}),e.deleted&&e.deleted.forEach(s=>{this.integratePropertyDelete(s,r,o)})}integratePropertyUpdateWithContext(e,t,r,o,s){e==="lexical"&&this.integrateLexicalDataUpdateWithContext(t,r,o)}integratePropertyUpdateWithContextInternal(e,t,r,o,s){switch(e){case"lexical":let i=r;if(typeof r=="string"&&r.startsWith("cid:")){const l=r.split(":");l.length>=3&&(i=l[1])}const a=o.nodeMapper.getLexicalKeyByLoroId(i);a&&this.integrateLexicalDataUpdateInternal(t,a,i,o);break}}integratePropertyUpdate(e,t,r,o){}integratePropertyDelete(e,t,r){}integrateLexicalDataUpdateWithContext(e,t,r){let o=t;if(typeof t=="string"&&t.startsWith("cid:")){const i=t.split(":");i.length>=3&&(o=i[1])}const s=r.nodeMapper.getLexicalKeyByLoroId(o);s&&e&&typeof e=="object"&&r.editor.update(()=>{this.integrateLexicalDataUpdateInternal(e,s,o,r)})}integrateLexicalDataUpdateInternal(e,t,r,o){let s=e;s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON());const i=Q(t);if(!i)return;const a=i.getType();if(zE(i,s,a))return;const l=s.__text||s.text||s.textContent;if(a==="text"&&l!==void 0){const c=i,u=c.getTextContent();u!==l&&nk(c,t,u,l),s.format!==void 0&&c.setFormat(s.format),s.style!==void 0&&c.setStyle(s.style)}else if(It(i))try{const u=o.editor._nodes.get(a);if(!u){console.warn(` MapIntegrator: Node type '${a}' not registered`);return}const f={...s};if(f.type||(f.type=a),f.version===void 0&&(f.version=1),"children"in f||(f.children=[]),u.klass.prototype.updateFromJSON!==Bt.prototype.updateFromJSON){i.getWritable().updateFromJSON(f);return}const d=u.klass.importJSON(f);i.replace(d),o.nodeMapper.removeMappingForKey(t),o.nodeMapper.setMapping(d.getKey(),r)}catch(c){console.warn(` MapIntegrator: importJSON+replace failed for decorator ${a} node ${t}:`,c)}else try{const c={...s};c.type||(c.type=a),c.version===void 0&&(c.version=1),"children"in c||(c.children=[]),i.getWritable().updateFromJSON(c)}catch(c){console.warn(` MapIntegrator: updateFromJSON failed for ${a} node ${t}:`,c)}}}function zE(n,e,t){try{const r=n.exportJSON(),o=s=>{const{key:i,__key:a,lexicalKey:l,children:c,...u}=s;return{...u,type:u.type??t,version:u.version??1}};return JSON.stringify(o(r))===JSON.stringify(o(e))}catch{return!1}}class KE{integrate(e,t,r){ye(" Handling ListDiff:",e),this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.diff&&e.diff.forEach(o=>{switch(o.type){case"insert":this.integrateInsert(o,t,r);break;case"delete":this.integrateDelete(o,t,r);break;case"retain":this.integrateRetain(o,t,r);break;default:console.warn(` Unknown list change type: ${o.type}`)}})}integrateInsert(e,t,r){}integrateDelete(e,t,r){}integrateRetain(e,t,r){e.attributes&&ye(` List retain with attributes at ${e.index}, length: ${e.length}`,e.attributes)}}class WE{integrate(e,t,r){this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.diff&&e.diff.forEach(o=>{switch(o.type){case"insert":this.integrateTextInsert(o,t,r);break;case"delete":this.integrateTextDelete(o,t,r);break;case"retain":this.integrateTextRetain(o,t,r);break;default:console.warn(` Unknown text change type: ${o.type}`)}})}integrateTextInsert(e,t,r){}integrateTextDelete(e,t,r){}integrateTextRetain(e,t,r){e.attributes&&this.applyTextFormatting({...e,attributes:e.attributes},t,r)}applyTextFormatting(e,t,r){}}class HE{integrate(e,t,r){this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.increment!==void 0&&this.integrateIncrement(e.increment,t,r),e.value!==void 0&&this.integrateSetValue(e.value,t,r)}integrateIncrement(e,t,r){}integrateSetValue(e,t,r){}updateNodeCounter(e,t,r,o,s){}}const JE=new BE,xg=new UE,qE=new KE,VE=new WE,YE=new HE;function GE(n,e,t,r,o=Im){const s=n.editor,i=s._editorState;n.editor.update(()=>{D()&&Ee(null),t.events.forEach((c,u)=>{try{switch(c.diff.type){case"tree":JE.integrateInternal(c.diff,n,e);break;case"map":c.target?xg.integrateWithContextInternal(c.diff,c.target,n,e):xg.integrateInternal(c.diff,n,e);break;case"list":qE.integrateInternal(c.diff,n,e);break;case"text":VE.integrateInternal(c.diff,n,e);break;case"counter":YE.integrateInternal(c.diff,n,e);break;default:throw new Error(`Unsupported event diff type: ${c.diff.type}. Supported types are: 'tree', 'map', 'list', 'text', 'counter'.`)}}catch(f){console.error("[loro-collab] syncLoroToLexical: integrator threw for event",u,"diffType=",c.diff?.type,"target=",String(c?.target),"diff=",JSON.stringify(c.diff),f)}});const l=D();if(F(l))if(ng(l)){const c=i._selection;if(F(c)&&(ig(n,e),ng(l))){const u=l.anchor.key;Cm(u,i)}Em(n,e,c,D())}else ig(n,e);Ai($l)},{onUpdate:()=>{o(n,e),queueMicrotask(()=>{s.update(()=>{se().getChildrenSize()===0&&se().append(ne())})})},skipTransforms:!0,tag:ca})}function XE(n,e,t,r,o,s,i,a,l,c,u,f,d=Im,g){const h=S.useRef(!1),_=S.useCallback(()=>t.connect(),[t]),m=S.useCallback(()=>{try{t.disconnect()}catch{}},[t]);S.useEffect(()=>{const{awareness:w}=t,C=({status:A})=>{n.dispatchCommand(fE,A==="connected")};let v=!1;const k=A=>{A&&!v&&(v=!0,eN(n,a,u)),ye("[SEED-DEBUG] onSync: isSynced=",A,"shouldBootstrap=",i,"isReloadingDoc=",h.current),i&&A&&h.current===!1&&(tN(n,u),g&&g(!0)),h.current=!1},I=()=>{d(a,t)};hE(t,o,s,document.activeElement===n.getRootElement(),f||{});const E=A=>{nN(n,a),l(A),r.set(e,A),h.current=!0};t.on("reload",E),t.on("status",C),t.on("sync",k),w.on("update",I);const N=A=>{A.origin!==a.doc.peerIdStr&&GE(a,t,A,!1,d)},O=a.doc.subscribe(N),M=[],R=n._nodes;ye("[SEED-DEBUG] registering mutation listeners; registeredNodes=",R?R.size:"undefined"),R&&R.forEach(A=>{A&&A.klass&&M.push(n.registerMutationListener(A.klass,()=>{},{skipInitialization:!0}))}),ye("[SEED-DEBUG] mutation listeners registered=",M.length,"editor._listeners.mutation.size=",n._listeners?.mutation?.size);const $=n.registerUpdateListener(A=>{let B=0;A.mutatedNodes&&A.mutatedNodes.forEach(j=>{B+=j.size}),ye("[SEED-DEBUG] updateListener fired; tags=",Array.from(A.tags),"mutatedNodes=",A.mutatedNodes?"map":"null","count=",B,"dirtyElements=",A.dirtyElements?.size,"dirtyLeaves=",A.dirtyLeaves?.size),v&&A.tags.has(ca)===!1&&DE(a,t,A)}),L=_();return()=>{h.current===!1&&(L?L.then(m):m()),t.off("sync",k),t.off("status",C),t.off("reload",E),w.off("update",I),O?.(),r.delete(e),$(),M.forEach(A=>A())}},[a,s,_,m,r,n,e,u,o,t,i,f,l,d,g]);const b=S.useMemo(()=>{const w=C=>{a.cursorsContainer=C};return St.createPortal(x.jsx("div",{ref:w,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:1e3,overflow:"visible"}}),c&&c.current||document.body)},[a,c]);return S.useEffect(()=>n.registerCommand(gE,w=>(w?_():m(),!0),V),[_,m,n]),b}function ZE(n,e,t,r,o){S.useEffect(()=>de(n.registerCommand(oh,()=>(bg(e,t,r,!0,o||{}),!1),V),n.registerCommand(cw,()=>(bg(e,t,r,!1,o||{}),!1),V)),[r,n,t,e,o])}function QE(n,e){const t=S.useMemo(()=>pE(e),[e]);S.useEffect(()=>{const o=()=>{t.undo()},s=()=>{t.redo()};return de(n.registerCommand(ph,()=>(o(),!0),V),n.registerCommand(gh,()=>(s(),!0),V))});const r=S.useCallback(()=>{t.clear()},[t]);return S.useEffect(()=>(n.dispatchCommand(hh,t.canUndo()),n.dispatchCommand(_h,t.canRedo()),()=>{}),[n,t]),r}function eN(n,e,t){n.update(()=>{const r=se();for(const o of r.getChildren())e.nodeMapper.hasLexicalMapping(o.getKey())||o.remove();r.isEmpty()&&!t&&r.append(ne())},{discrete:!0,tag:ca})}function tN(n,e){const t=new Set(["Lexical with Loro","Welcome to Lexical with Loro","Type something..."]),r=()=>{const i=se().getChildren();if(i.length===0)return!1;for(const a of i){const l=a.getType(),c=a.getTextContent().trim();if(c.length>0){if(!t.has(c))return!0;continue}if(l!=="paragraph"&&l!=="jupyter-output")return!0}return!1};let o=!1;if(n.getEditorState().read(()=>{o=!r()}),ye("[SEED-DEBUG] initializeEditor: shouldSeed=",o,"hasInitialState=",!!e,"type=",typeof e),!(!o||!e)){if(typeof e=="string"){let s=[];try{s=JSON.parse(e)?.root?.children??[]}catch{n.update(()=>{n.setEditorState(n.parseEditorState(e),{tag:$n})},{tag:$n});return}n.update(()=>{},{tag:$n,discrete:!0}),n.update(()=>{Ee(null)},{tag:$n,discrete:!0});let i=[];n.getEditorState().read(()=>{i=se().getChildren().map(l=>l.getKey())}),ye("[SEED-DEBUG] initializeEditor: seeding",s.length,"blocks, removing",i.length,"scaffold blocks first");for(const l of i)n.update(()=>{const c=Q(l);c&&c.remove()},{tag:$n,discrete:!0});let a=0;for(const l of s){const c=a++,u=l?.type,f=Array.isArray(l?.children)?l.children.map(d=>d?.type):[];n.update(()=>{se().append(uw(l))},{tag:$n,discrete:!0}),ye("[SEED-DEBUG] appended block",c,"type=",u,"children=",f)}return}n.update(()=>{r()||(typeof e=="object"?n.setEditorState(e,{tag:$n}):typeof e=="function"&&e(n))},{tag:$n})}}function nN(n,e){if(n.update(()=>{const s=se();s.clear(),s.select()},{tag:ca}),e.cursors==null)return;const t=e.cursors;if(t==null)return;const r=e.cursorsContainer;if(r==null)return;const o=Array.from(t.values());for(let s=0;s<o.length;s++){const a=o[s].selection;if(a&&a.selections!=null){const l=a.selections;for(let c=0;c<l.length;c++)r.removeChild(l[s])}}}function Cg(n,e){if(!n||typeof n!="object")return;const t=n,r=t.user,o=r&&typeof r=="object"?r:void 0;for(const s of e){const i=t[s];if(typeof i=="string"&&i.trim().length>0)return i;if(o){const a=o[s];if(typeof a=="string"&&a.trim().length>0)return a}}}function WM({id:n,providerFactory:e,shouldBootstrap:t,username:r,cursorColor:o,cursorsContainerRef:s,initialEditorState:i,excludedProperties:a,awarenessData:l,syncCursorPositionsFn:c,showCollaborators:u=!0,websocketUrl:f="ws://localhost:3002",onInitialization:d,onIdentityResolved:g,onCollaboratorsChange:h}){const _=S.useRef(!1),m=S.useRef(!1),b=Lm(r,o),w=qw(),C=S.useRef(w);C.current=w;const{docMap:v,name:k,color:I}=b,[E]=fe();S.useEffect(()=>(b.isCollabActive=!0,()=>{E._parentEditor==null&&(b.isCollabActive=!1)}),[b,E]);const[N,O]=S.useState(),[M,R]=S.useState();S.useEffect(()=>{if(m.current)return;m.current=!0;const A=e(n,v,f);return O(A),R(v.get(n)),()=>{A.disconnect()}},[n,e,v,f]);const[$,L]=S.useState();return S.useEffect(()=>{if(!N||_.current)return;_.current=!0;const A=uk(E,N,n,M||v.get(n),v,a),B=Nm(A.clientID),j=Cg(l,["display_name","displayName","name","username","handle"]),U=Cg(l,["color"]),z=r||j||B.name,K=C.current[Vw(z)%C.current.length],H=o||U||K;return b.name=z,b.color=H,b.clientID=A.clientID,g?.({name:z,color:H,clientID:A.clientID}),_E(N,z,H),L(A),()=>{}},[E,N,n,v,M,a,b,r,o,l]),!N||!$?x.jsx(x.Fragment,{}):x.jsx(rN,{awarenessData:l,binding:$,collabContext:b,color:I,cursorsContainerRef:s,editor:E,id:n,initialEditorState:i,name:k,provider:N,setDoc:R,shouldBootstrap:t,docMap:v,syncCursorPositionsFn:c,showCollaborators:u,onInitialization:d,onCollaboratorsChange:h})}function rN({editor:n,id:e,provider:t,docMap:r,name:o,color:s,shouldBootstrap:i,cursorsContainerRef:a,initialEditorState:l,awarenessData:c,collabContext:u,binding:f,setDoc:d,syncCursorPositionsFn:g,showCollaborators:h=!1,onInitialization:_,onCollaboratorsChange:m}){const b=XE(n,e,t,r,o,s,i,f,d,a,l,c,g,_);return u.clientID=f.clientID,QE(n,f),ZE(n,t,o,s,c),S.useEffect(()=>{if(!m)return;const{awareness:w}=t,C=()=>m(bk(w.getStates(),f.clientID));return C(),w.on("update",C),()=>{w.off("update",C)}},[f,m,t]),h?x.jsx(ck,{binding:f,cursorsContainer:b,currentUserName:o,currentUserColor:s,showCollaborators:!0}):b}const Sg=30*1e3,oN="update",sN="ephemeral",iN="query-ephemeral";class aN{ephemeralStore;localClientId;eventHandlers=new Map;constructor(e,t){this.ephemeralStore=e,this.localClientId=t?Wt(t):ek(),ye(" AwarenessAdapter created:",{localClientId:this.localClientId,docPeerId:t?t.peerId:"no-doc",existingStatesCount:Object.keys(e.getAllStates()).length}),this.ephemeralStore.subscribe(r=>{(this.eventHandlers.get("update")||[]).forEach(s=>s())})}getLocalState(){const e=this.localClientId.toString();try{const t=this.ephemeralStore.get(e);return t||null}catch(t){throw console.warn("[Client] AwarenessAdapter.getLocalState() - ephemeralStore.get() FAILED:",{error:t.message,stack:t.stack,localKey:e,peerId:this.localClientId,storeExists:!!this.ephemeralStore}),t}}getStates(){const e=new Map;try{const t=this.ephemeralStore.getAllStates();Math.random()<.001&&this.cleanupStaleStates(t);for(const[r,o]of Object.entries(t)){const s=parseInt(r,10);!isNaN(s)&&o&&e.set(s,o)}}catch(t){console.warn("[Client] AwarenessAdapter.getStates() - ERROR:",t.message);const r=this.getLocalState();r&&e.set(this.localClientId,r)}return e}cleanupStaleStates(e){const t=Date.now(),r=300*1e3;try{for(const[o,s]of Object.entries(e)){const i=parseInt(o,10);if(!isNaN(i)&&s&&typeof s=="object"){const a=s,l=typeof a.lastActivity=="number"?a.lastActivity:0;typeof l=="number"&&t-l>r&&(ye("Cleaning up stale user state:",o,"last activity:",new Date(l).toISOString()),this.ephemeralStore.delete(o))}}}catch(o){console.warn("Error during stale state cleanup:",o.message)}}setLocalState(e){const t=this.localClientId.toString(),r={...e,lastActivity:Date.now()};try{this.ephemeralStore.set(t,r)}catch(o){throw console.warn("[Client] AwarenessAdapter.setLocalState() - ephemeralStore.set() FAILED:",{error:o.message,stack:o.stack,localKey:t,peerId:this.localClientId,stateKeys:Object.keys(e||{}),storeExists:!!this.ephemeralStore}),o}}setLocalStateField(e,t){const r=this.getLocalState()||{anchorPos:null,awarenessData:{},color:"#000000",focusPos:null,focusing:!1,name:"Anonymous"};r[e]=t,this.setLocalState(r)}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(t)}off(e,t){const r=this.eventHandlers.get(e);if(r){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}forceCleanupStaleStates(){try{const e=this.ephemeralStore.getAllStates();ye("Force cleanup - total keys before:",Object.keys(e).length),this.cleanupStaleStates(e);const t=this.ephemeralStore.getAllStates();ye("Force cleanup - total keys after:",Object.keys(t).length)}catch(e){console.warn("Force cleanup failed:",e.message)}}}const Ms={};Ms[iN]=(n,e,t)=>{try{const r=n.ephemeralStore.encodeAll(),o={type:"ephemeral",ephemeral:Array.from(r),docId:e.docId};return JSON.stringify(o)}catch(r){return console.warn("Error in messageQueryEphemeral integrater:",r.message),null}};Ms[sN]=(n,e,t)=>{try{if(!e.ephemeral||e.ephemeral.length===0)return console.warn("[Client] messageHandlers[messageEphemeral] - Skipping empty ephemeral data"),null;if(e.ephemeral.length<8)return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting suspiciously small ephemeral data:",e.ephemeral.length),null;if(e.ephemeral.length===1)return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting single-byte ephemeral data (likely corrupted):",e.ephemeral),null;const r=e.ephemeral.slice(0,4);if(r.every(s=>s===0)||r.every(s=>s===255))return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting ephemeral data with suspicious pattern:",r),null;const o=new Uint8Array(e.ephemeral);try{n.ephemeralStore.apply(o)}catch(s){if(console.warn("[Client] messageHandlers[messageEphemeral] - WASM apply() failed:",{error:s.message,ephemeralLength:o.length,ephemeralSample:Array.from(o.slice(0,20))}),s.message&&s.message.includes("memory access out of bounds"))return console.warn("[Client] messageHandlers[messageEphemeral] - CRITICAL: WASM memory corruption in apply(). Stopping ephemeral processing."),null;throw s}return null}catch(r){return console.warn("[Client] messageHandlers[messageEphemeral] - ERROR in ephemeral message integrater:",{error:r.message,stack:r.stack,messageLength:e.ephemeral?.length,ephemeralSample:e.ephemeral?.slice(0,10)}),null}};Ms[oN]=(n,e,t)=>{try{const r=new Uint8Array(e.update),o=n.doc.import(r),s=n.doc.version();return ye("[SEED-DEBUG] messageUpdate: imported",r.length,"bytes; importStatus=",JSON.stringify(o)),n._lastExportedVersion=s,t&&n.snapshotLoaded&&!n._synced&&(n.synced=!0),null}catch(r){return console.warn(" [LORO-UPDATE-ERROR] Failed to apply Loro update:",r),null}};const $m=(n,e,t)=>{if(e instanceof ArrayBuffer)try{const r=new Uint8Array(e),o=fc(r,!1).partialEndVersionVector;n.doc.import(r),n.snapshotLoaded=!0;const s=n.doc.export({mode:"update",from:o});if(fc(s,!1).changeNum>0&&n.ws){const i={type:"update",update:Array.from(s),docId:n.docId};zn(n.ws,i)}return t&&!n._synced&&(n.synced=!0),null}catch(r){return console.warn("Failed to process binary Loro update:",r),null}else if(typeof e=="string")try{const r=JSON.parse(e),o=Ms[r.type];return o?o(n,r,t):(console.warn("Unknown message type:",r.type),null)}catch(r){return console.warn("Failed to process JSON message:",r),null}else if(typeof e=="object"&&e!==null)try{const r=e,o=Ms[r.type];return o?o(n,r,t):(console.warn("Unknown message type:",r.type),null)}catch(r){return console.warn("Failed to process object message:",r),null}return console.warn("Unknown message format:",typeof e),null},pc=(n,e,t)=>{if(e===n.ws){if(n.emit("connection-close",[t,n]),n.ws=null,e.close(),n.wsconnecting=!1,n.wsconnected){n.wsconnected=!1,n.synced=!1,n.ephemeralStore.delete("presence"),n.ephemeralStore.delete("cursor");try{const o=Wt(n.doc).toString();n.ephemeralStore.delete(o),ye("Disconnect cleanup: removed user key:",o)}catch(r){console.warn("Disconnect cleanup failed:",r.message)}n.emit("status",[{status:"disconnected"}])}else n.wsUnsuccessfulReconnects++;setTimeout(Dm,fw(gw(2,n.wsUnsuccessfulReconnects)*100,n.maxBackoffTime),n)}},zn=(n,e)=>{if(n&&n.readyState===n.OPEN)try{const t=JSON.stringify(e);n.send(t)}catch(t){console.warn("Failed to send message over WebSocket:",t)}else console.warn("WebSocket not open, cannot send message")},Dm=n=>{if(n.shouldConnect&&n.ws===null){const e=new n._WS(n.url,n.protocols);e.binaryType="arraybuffer",n.ws=e,n.wsconnecting=!0,n.wsconnected=!1,n.synced=!1,e.onmessage=t=>{n.wsLastMessageReceived=Dl(),$m(n,t.data,!0)},e.onerror=t=>{n.emit("connection-error",[t,n])},e.onclose=t=>{n.snapshotLoaded=!1,pc(n,e,t)},e.onopen=()=>{if(n.wsLastMessageReceived=Dl(),n.wsconnecting=!1,n.wsconnected=!0,n.wsUnsuccessfulReconnects=0,n.emit("status",[{status:"connected"}]),ye(" WebSocket connection established, requesting initial data"),n.snapshotLoaded)ye(" Snapshot already loaded, skipping request");else{const s=Math.random().toString(36).substr(2,9),i=Wt(n.doc).toString(),a={type:"query-snapshot",docId:n.docId,clientId:i};ye(` Requesting initial snapshot from server (ID: ${s}, clientId: ${i}):`,a),ye(` Provider instance ID: ${n.wsServerUrl}/${n.docId}, snapshotLoaded: ${n.snapshotLoaded}`),zn(e,a)}const t=Wt(n.doc).toString(),r={type:"query-ephemeral",docId:n.docId,clientId:t};zn(e,r);const o=n.ephemeralStore.getAllStates();if(Object.keys(o).length>0)try{const s=n.ephemeralStore.encodeAll(),i={type:"ephemeral",ephemeral:Array.from(s),docId:n.docId};zn(e,i)}catch(s){console.warn("[Client] setupWS - MAJOR ERROR in ephemeral process:",{error:s.message,stack:s.stack,localStateKeys:Object.keys(o),storeExists:!!n.ephemeralStore})}if(n._pendingUpdates.length>0){const s=n._pendingUpdates;n._pendingUpdates=[],ye("[SEED-DEBUG] ws.onopen: flushing",s.length,"buffered local updates");for(const i of s)zn(e,{type:"update",update:Array.from(i),docId:n.docId})}},n.emit("status",[{status:"connecting"}])}},vg=(n,e)=>{const t=n.ws;n.wsconnected&&t&&t.readyState===t.OPEN?zn(t,e):ye(" [BROADCAST] WebSocket not ready for sending"),n.bcconnected?is(n.bcChannel,JSON.stringify(e),n):ye(" [BROADCAST] BroadcastChannel not connected")};class gr extends dw{static globalEphemeralStore=null;wsServerUrl="";docId="";doc=null;_WS=null;protocols=[];params={};ephemeralStore=null;awareness=null;ws=null;wsconnected=!1;wsconnecting=!1;bcconnected=!1;disableBc=!1;bcChannel="";maxBackoffTime=2500;wsUnsuccessfulReconnects=0;messageHandlers=[];_synced=!1;wsLastMessageReceived=0;shouldConnect=!1;snapshotLoaded=!1;_checkInterval=null;_resyncInterval=null;_updateHandler=null;_ephemeralUpdateIntegrator=null;_exitIntegrator=null;_bcSubscriber=null;_lastExportedVersion=null;_pendingUpdates=[];constructor(e,t,r,{connect:o=!0,ephemeralStore:s=void 0,params:i={},protocols:a=[],WebSocketPolyfill:l=WebSocket,resyncInterval:c=-1,maxBackoffTime:u=2500,disableBc:f=!1}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.wsServerUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=u,this.params=i,this.protocols=a,this.docId=t,this.doc=r,this._WS=l;try{if(s)this.ephemeralStore=s;else{if(!gr.globalEphemeralStore)gr.globalEphemeralStore=new uE(3e5),ye("🆕 Created new global EphemeralStore");else{ye(" Reusing existing global EphemeralStore - cleaning up stale user states");const d=gr.globalEphemeralStore.getAllStates();Object.keys(d).forEach(g=>{const h=parseInt(g,10);isNaN(h)||(gr.globalEphemeralStore.delete(g),ye(" Cleaned up stale user state:",g))})}this.ephemeralStore=gr.globalEphemeralStore}}catch(d){throw console.warn("[Client] WebsocketProvider constructor - ERROR setting up EphemeralStore:",{error:d.message,stack:d.stack,docId:t}),d}this.awareness=new aN(this.ephemeralStore,this.doc),this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=f,this.wsUnsuccessfulReconnects=0,this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=o,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=Wt(this.doc).toString(),g={type:"query-ephemeral",docId:this.docId,clientId:d};zn(this.ws,g)}},c)),this._bcSubscriber=(d,g)=>{if(g!==this){const h=$m(this,d,!1);h&&is(this.bcChannel,h,this)}},this._updateHandler=d=>{const g={type:"update",update:Array.from(d),docId:this.docId},h=this.ws;this.wsconnected&&h&&h.readyState===h.OPEN?(ye("[SEED-DEBUG] _updateHandler: sending local update over WS",d.length,"bytes"),zn(h,g)):(ye("[SEED-DEBUG] _updateHandler: WS not ready, buffering local update",d.length,"bytes (pending now",this._pendingUpdates.length+1,")"),this._pendingUpdates.push(d)),this.bcconnected&&is(this.bcChannel,JSON.stringify(g),this)},this._ephemeralUpdateIntegrator=d=>{if(d.added.length>0||d.updated.length>0||d.removed.length>0)try{const g=this.ephemeralStore.encodeAll(),h={type:"ephemeral",ephemeral:Array.from(g),docId:this.docId};vg(this,h)}catch(g){console.warn("[Client] _ephemeralUpdateIntegrator - ERROR:",g.message)}},this._exitIntegrator=()=>{if(this.ephemeralStore&&this.awareness)try{const g=Wt(this.doc).toString();this.ephemeralStore.delete(g)}catch(d){console.warn("[Client] Process exit - Could not clear user state:",d.message)}},Pd&&typeof process<"u"&&process.on("exit",this._exitIntegrator),this.ephemeralStore.subscribe(this._ephemeralUpdateIntegrator),this._lastExportedVersion=this.doc.version();try{this.doc.subscribeLocalUpdates(d=>{try{this._updateHandler(d)}catch(g){console.warn("[WEBSOCKET-PROVIDER] Error exporting incremental update:",g)}})}catch(d){console.warn("[Client] ERROR setting up Loro document subscription:",d)}this._checkInterval=setInterval(()=>{this.wsconnected&&Sg<Dl()-this.wsLastMessageReceived&&pc(this,this.ws,null)},Sg/10),o&&this.connect()}get url(){const e=Yw(this.params);return this.wsServerUrl+"/"+this.docId+(e.length===0?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,super.emit("synced",[e]),super.emit("sync",[e]))}destroy(){if(this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Pd&&typeof process<"u"&&process.off("exit",this._exitIntegrator),this.ephemeralStore&&this.awareness)try{const t=Wt(this.doc).toString();this.ephemeralStore.delete(t)}catch(e){console.warn("[Client] WebsocketProvider.destroy - Could not clear user state:",e.message)}super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Gw(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Wt(this.doc).toString(),t={type:"query-ephemeral",docId:this.docId,clientId:e};is(this.bcChannel,JSON.stringify(t),this);const r=this.ephemeralStore.getAllStates();if(Object.keys(r).length>0)try{const o=this.ephemeralStore.encodeAll(),s={type:"ephemeral",ephemeral:Array.from(o),docId:this.docId};is(this.bcChannel,JSON.stringify(s),this)}catch(o){console.warn("Error broadcasting ephemeral state in connectBc:",o.message)}}disconnectBc(){this.ephemeralStore.delete("presence"),this.ephemeralStore.delete("cursor");try{const t=Wt(this.doc).toString();this.ephemeralStore.delete(t),ye("Broadcast disconnect cleanup: removed user key:",t)}catch(e){console.warn("Broadcast disconnect cleanup failed:",e.message)}try{const e=this.ephemeralStore.encodeAll(),t={type:"ephemeral",ephemeral:Array.from(e),docId:this.docId};vg(this,t)}catch(e){console.warn("Error broadcasting disconnect in disconnectBc:",e.message)}this.bcconnected&&(Xw(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&pc(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Dm(this),this.connectBc())}sendUpdate(e){this._updateHandler(e,null)}cleanupStaleStates(){this.awareness&&typeof this.awareness.forceCleanupStaleStates=="function"?this.awareness.forceCleanupStaleStates():console.warn("Cleanup method not available on awareness provider")}}const lN=new URL(window.location.href),cN=new URLSearchParams(lN.search),kg=parseInt(cN.get("resyncInterval")||"30000",10);function HM(n,e,t){let r=e.get(n);r===void 0&&(r=new sn,e.set(n,r));const o=Math.random().toString(36).substr(2,9);ye(` Creating WebsocketProvider instance (ID: ${o}) for docId: ${n}`);let i=t||(()=>{const u=new URL(window.location.href);return new URLSearchParams(u.search).get("collabEndpoint")||"ws://localhost:3002"})();const a={},l=i.indexOf("?");if(l!==-1){const u=i.slice(l+1);i=i.slice(0,l),new URLSearchParams(u).forEach((f,d)=>{a[d]=f})}const c=new gr(i,n,r,{connect:!1,params:a,resyncInterval:kg});return ye(` WebsocketProvider created for: ${i}/${n} with resyncInterval: ${kg}ms`),c}const uN=qn?S.useLayoutEffect:S.useEffect;class dN{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Tg=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Ig(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}const Eg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function fN({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,x.jsx("span",{className:"text",children:o.title})]},o.key)}function gN({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(fN,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),uN(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Eg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Tg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Eg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Tg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Ng(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function pN(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Ng(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return(function(f,d,g,h){const[_]=fe();S.useEffect(()=>{if(d!=null&&f!=null){const m=_.getRootElement(),b=m!=null?bh(m,!1):document.body;let w=!1,C=Ig(d,b);const v=function(){w||(window.requestAnimationFrame(function(){g(),w=!1}),w=!0);const E=Ig(d,b);E!==C&&(C=E,h?.(E))},k=new ResizeObserver(g),I=yh(m??d);return k.observe(d),de(Jt(window,"resize",g),Jt(document,"scroll",v,{capture:!0,passive:!0}),...I.map(E=>Jt(E,"scroll",v,{capture:!0,passive:!0})),()=>k.unobserve(d))}},[d,_,h,g,f])})(n,l.current,c,u),a!=null&&a===l.current&&(Ng(a,t),i?.append(a)),l}function hN({options:n,nodeKey:e,onClose:t,onOpen:r,onSelectOption:o,menuRenderFn:s,anchorClassName:i,commandPriority:a=ee,parent:l}){const[c]=fe(),[u,f]=S.useState(null),d=pN(u,f,i,l),g=S.useCallback(()=>{f(null),t!=null&&u!==null&&t()},[t,u]),h=S.useCallback(m=>{f(m),r!=null&&u===null&&r(m)},[r,u]),_=S.useCallback(()=>{e?c.update(()=>{const m=Q(e),b=c.getElementByKey(e);m!=null&&b!=null&&u==null&&S.startTransition(()=>h({getRect:()=>b.getBoundingClientRect()}))}):e==null&&u!=null&&g()},[g,c,e,h,u]);return S.useEffect(()=>{_()},[_,e]),S.useEffect(()=>{if(e!=null)return c.registerUpdateListener(({dirtyElements:m})=>{m.get(e)&&_()})},[c,_,e]),d.current===null||u===null||c===null?null:x.jsx(gN,{close:g,resolution:u,editor:c,anchorElementRef:d,options:n,menuRenderFn:s,onSelectOption:o,commandPriority:a})}const _N=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,Ju=he("INSERT_EMBED_COMMAND");let Lg=class extends dN{title;onSelect;constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}};function mN({embedConfigs:n,onOpenEmbedModalForConfig:e,getMenuOptions:t,menuRenderFn:r,menuCommandPriority:o=ee}){const[s]=fe(),[i,a]=S.useState(null),[l,c]=S.useState(null),u=S.useCallback(()=>{a(null),c(null)},[]),f=S.useCallback(async _=>{const m=s.read("latest",function(){const b=Q(_);if(Pe(b))return b.getURL()});if(m!==void 0)for(const b of n)await Promise.resolve(b.parseUrl(m))!=null&&(c(b),a(_))},[s,n]);S.useEffect(()=>de(...[gn,fa].map(_=>s.registerMutationListener(_,(...m)=>((b,{updateTags:w,dirtyLeaves:C})=>{for(const[v,k]of b)k==="created"&&w.has(Up)&&C.size<=3?f(v):v===i&&u()})(...m),{skipInitialization:!0}))),[f,s,i,u]),S.useEffect(()=>{if(e)return s.registerCommand(Ju,_=>{const m=n.find(({type:b})=>b===_);return!!m&&(e(m),!0)},V)},[s,n,e]);const d=S.useCallback(async function(){if(l!=null&&i!=null){const _=s.read("latest",()=>{const m=Q(i);return Pe(m)?m:null});if(Pe(_)){const m=await Promise.resolve(l.parseUrl(_.__url));m!=null&&s.update(()=>{D()||_.selectEnd(),l.insertNode(s,m),_.isAttached()&&_.remove()})}}},[l,s,i]),g=S.useMemo(()=>l!=null&&i!=null?t(l,d,u):[],[l,d,t,i,u]),h=S.useCallback((_,m,b)=>{s.update(()=>{_.onSelect(m),b()})},[s]);return i!=null?x.jsx(hN,{nodeKey:i,onClose:u,onSelectOption:h,options:g,menuRenderFn:r,commandPriority:o}):null}const Go=()=>{const[n,e]=S.useState(null),t=S.useCallback(()=>{e(null)},[]),r=S.useMemo(()=>{if(n===null)return null;const{title:s,content:i,closeOnClickOutside:a}=n;return x.jsx(Yx,{onClose:t,title:s,closeOnClickOutside:a,children:i})},[n,t]),o=S.useCallback((s,i,a=!1)=>{e({closeOnClickOutside:a,content:i(t),title:s})},[t]);return[r,o]},Pm=he();function bN(n){if(!n.hasNodes([qo]))throw new Error("YouTubePlugin: YouTubeNode not registered on editor");return n.registerCommand(Pm,e=>{const t=K_(e);return sr(t),!0},V)}const jm=pe({name:"@datalayer/jupyter-lexical/YouTube",nodes:()=>[qo],register:bN}),ka=he("INSERT_LOOM_COMMAND");function yN(n){if(!n.hasNodes([Vo]))throw new Error("LoomExtension: LoomNode not registered on editor");return n.registerCommand(ka,e=>(sr($u(e)),!0),V)}const Fm=pe({name:Q_,config:tr({publicAppId:void 0}),nodes:()=>[Vo],register:yN}),wN={contentName:"Youtube Video",exampleUrl:"https://www.youtube.com/watch?v=jNQXAC9IVRw",icon:x.jsx(Ws,{size:16}),insertNode:(n,e)=>{n.dispatchCommand(Pm,e.id)},keywords:["youtube","video"],parseUrl:async n=>{const e=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(n),t=e&&e?.[2].length===11?e[2]:null;return t!=null?{id:t,url:n}:null},type:"youtube-video"},xN={contentName:"Loom Video",exampleUrl:"https://www.loom.com/share/c2b5b05f548d4f1492d5c107f0c48dbc",icon:x.jsx(Ws,{size:16}),insertNode:(n,e)=>{tm(e.url).then(t=>n.dispatchCommand(ka,t))},keywords:["loom","video","recording","screen"],parseUrl:async n=>{const e=kn(n);return e?{id:e,url:Mu(e)}:null},type:"loom-video"},qu=[wN,xN];function CN({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(i=>o.setRefElement(i),[o]);return x.jsx(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,sx:{p:2,cursor:"pointer",bg:e?"actionListItem.default.selectedBg":"transparent","&:hover":{bg:"actionListItem.default.hoverBg"},borderRadius:1},children:x.jsx(Le,{sx:{fontSize:1},children:o.title})},o.key)}function SN({options:n,selectedItemIndex:e,onOptionClick:t,onOptionMouseEnter:r}){return x.jsx(Y,{sx:{bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1},children:x.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:n.map((o,s)=>x.jsx(CN,{index:s,isSelected:e===s,onClick:()=>t(o,s),onMouseEnter:()=>r(s),option:o},o.key))})})}const vN=(n,e)=>{let t;return r=>{window.clearTimeout(t),t=window.setTimeout(()=>{n(r)},e)}};function kN({embedConfig:n,onClose:e}){const[t,r]=S.useState(""),[o]=fe(),[s,i]=S.useState(null),a=S.useMemo(()=>vN(u=>{const f=_N.exec(u);n!=null&&u!=null&&f!=null?Promise.resolve(n.parseUrl(u)).then(d=>{i(d)}):s!=null&&i(null)},200),[n,s]),l=()=>{s!=null&&(n.insertNode(o,s),e())},c=S.useRef(null);return S.useEffect(()=>{c.current?.focus()},[]),x.jsxs("div",{children:[x.jsx(vn,{ref:c,type:"text",placeholder:n.exampleUrl,value:t,"data-test-id":`${n.type}-embed-modal-url`,onChange:u=>{const{value:f}=u.target;r(f),a(f)},block:!0}),x.jsx(xu,{children:x.jsx(xr,{disabled:!s,onClick:l,"data-test-id":`${n.type}-embed-modal-submit-btn`,children:"Embed"})})]})}const TN=()=>{const[n,e]=Go(),t=o=>{e(`Embed ${o.contentName}`,s=>x.jsx(kN,{embedConfig:o,onClose:s}))},r=(o,s,i)=>[new Lg("Dismiss",{onSelect:i}),new Lg(`Embed ${o.contentName}`,{onSelect:s})];return x.jsxs(x.Fragment,{children:[n,x.jsx(mN,{embedConfigs:qu,onOpenEmbedModalForConfig:t,getMenuOptions:r,menuRenderFn:(o,{selectedIndex:s,options:i,selectOptionAndCleanUp:a,setHighlightedIndex:l})=>o.current?St.createPortal(x.jsx(Y,{sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",marginLeft:o.current.style.width,width:200},children:x.jsx(SN,{options:i,selectedItemIndex:s,onOptionClick:(c,u)=>{l(u),a(c)},onOptionMouseEnter:c=>{l(c)}})}),o.current):null})]})};class Gs extends Bt{__completionText;static getType(){return"inline-completion"}static clone(e){return new Gs(e.__completionText,e.__key)}constructor(e,t){super(t),this.__completionText=e}createDOM(e){const t=document.createElement("span");return t.className="inline-completion-ghost",t.style.cssText=`
206
+ `,document.body.appendChild(a)},cleanupEphemeralStore:e=>{if(!e){console.log(" No provider passed. Usage: window.debugLoro.cleanupEphemeralStore(provider)"),console.log("You can get the provider from your useCollaboration hook");return}if(typeof e.cleanupStaleStates!="function"){console.log(" Provider does not have cleanupStaleStates method");return}console.log(" Cleaning up stale ephemeral states..."),e.cleanupStaleStates()},resetGlobalEphemeralStore:()=>{try{console.log(" Attempting to reset global EphemeralStore..."),console.log(" You can also refresh the browser to clear the global store"),alert("To reset the global ephemeral store and clear all collaborators, please refresh the browser page.")}catch(e){console.warn(" Reset failed:",e.message)}}},window.debugLoro.binding=n,setTimeout(()=>{window.debugLoro.addDebugToPage()},2e3)}class sk{lexicalToLoro=new Map;loroToLexical=new Map;tree;constructor(e){this.tree=e.tree}createMapping(e,t){this.lexicalToLoro.set(e,t),this.loroToLexical.set(t,e)}removeMapping(e,t){this.lexicalToLoro.delete(e),this.loroToLexical.delete(t)}getLoroNodeByLexicalKey(e,t,r,o){const s=this.lexicalToLoro.get(e);if(s&&qt(this.tree,s))return this.tree.getNodeByID(s);if(e==="root"){const a=this.tree.roots()[0];if(a)return this.createMapping(e,a.id),a;const l=this.createLoroNode(e,t,void 0,0),c=this.tree.getNodeByID(l);return Se(c,"elementType","root"),c}if(!r&&t){const a=t.getParent();if(a){const l=a.getKey();r=this.lexicalToLoro.get(l),r||(r=this.getLoroNodeByLexicalKey(l,a,void 0,void 0).id)}}o===void 0&&t&&(o=t.getIndexWithinParent());const i=this.createLoroNode(e,t,r,o);return this.tree.getNodeByID(i)}getLexicalKeyByLoroId(e){const t=this.loroToLexical.get(e);return t||null}getLexicalNodeByLoroId(e,t){const r=this.getLexicalKeyByLoroId(e);return r&&t._nodeMap.get(r)||null}getLexicalParentByLoroId(e,t){return null}setMapping(e,t){this.lexicalToLoro.set(e,t),this.loroToLexical.set(t,e)}aliasLoroId(e,t){this.loroToLexical.set(e,t)}createLoroNode(e,t,r,o){const s=o;if(s!==void 0){const l=r!==void 0?this.tree.getNodeByID(r):null,c=l?l.children()?.length??0:this.tree.roots().length;dt(s>=0&&s<=c,"createLoroNode: insertion index out of range",{nodeKey:e,parentTreeID:r,insertionIndex:s,childrenLength:c})}const i=this.tree.createNode(r,s),a=i.id;if(r){const l=i.parent();dt(l!=null&&l.id===r,"createLoroNode: parent relationship not established",{nodeKey:e,expected:r,actual:l?.id??null})}if(Se(i,"createdAt",Date.now()),t)try{const l=t.exportJSON();if("key"in l||"__key"in l||"lexicalKey"in l){const{key:c,__key:u,lexicalKey:f,children:d,...g}=l;Se(i,"lexical",g)}else{const{children:c,...u}=l;Se(i,"lexical",u)}}catch(l){console.warn("Failed to export lexical node JSON in NodesMapper:",l)}return this.createMapping(e,a),a}updateMapping(e,t){const r=this.lexicalToLoro.get(e);r&&(this.removeMapping(e,r),this.createMapping(t,r),this.tree.getNodeByID(r))}deleteMapping(e){const t=this.lexicalToLoro.get(e);t&&(this.removeMapping(e,t),qt(this.tree,t)&&this.tree.delete(t))}removeMappingForKey(e){const t=this.lexicalToLoro.get(e);t&&this.removeMapping(e,t)}getTreeIDByLexicalKey(e){return this.lexicalToLoro.get(e)}hasLexicalMapping(e){return this.lexicalToLoro.has(e)}hasLoroMapping(e){return this.loroToLexical.has(e)}getAllMappings(){return{lexicalToLoro:new Map(this.lexicalToLoro),loroToLexical:new Map(this.loroToLexical)}}clearMappings(){this.lexicalToLoro.clear(),this.loroToLexical.clear()}syncExistingNodes(e){ye(" syncExistingNodes: Skipping sync - mappings established through TreeIntegrator")}}let vr=null;function ik(n){return vr=new sk(n),vr}function ak(n,e){const t=vr;vr=n;try{return e()}finally{vr=t}}function Ue(){if(!vr)throw new Error("NodeMapper not initialized. Call initializeNodeMapper() first.");return vr}function lk({binding:n,currentUserName:e="Me",currentUserColor:t}){const[r,o]=S.useState(0);S.useEffect(()=>{const g=setInterval(()=>{o(h=>h+1)},1e3);return()=>clearInterval(g)},[]);const s=n.clientID;Array.from(n.cursors.entries()).map(([g,h])=>({clientId:g,name:h.name,color:h.color,isCurrentUser:g===s}));const i=Array.from(n.cursors.entries()).map(([g,h])=>({clientId:g,cursor:h,isCurrentUser:g===s})),a=n.cursors.get(s),l=a?.name||e,c=Hw(l),u=a?.color||t||c,f=i.find(({isCurrentUser:g})=>g),d=i.filter(({isCurrentUser:g})=>!g);return x.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"8px 12px",backgroundColor:"var(--bgColor-muted, #f8f9fa)",borderBottom:"1px solid var(--borderColor-default, #e1e5e9)",fontSize:"14px",fontFamily:"system-ui, -apple-system, sans-serif",gap:"8px",flexWrap:"wrap",color:"var(--fgColor-default, inherit)"},children:[f&&x.jsx(rl,{name:`${f.cursor.name} (me)`,color:u,isCurrentUser:!0,clientId:s}),!f&&x.jsx(rl,{name:`${l} (me)`,color:u,isCurrentUser:!0,clientId:s}),d.length>0&&x.jsx("div",{style:{width:"1px",height:"20px",backgroundColor:"var(--borderColor-muted, #d1d5db)",margin:"0 4px"}}),d.map(({clientId:g,cursor:h})=>x.jsx(rl,{name:h.name,color:h.color,isCurrentUser:!1,clientId:g},g)),d.length===0&&x.jsx("span",{style:{color:"var(--fgColor-muted, #6b7280)",fontStyle:"italic",marginLeft:"8px"},children:"No other collaborators"})]})}function rl({name:n,color:e,isCurrentUser:t,clientId:r}){const o=e,s=e,i=String(r).slice(0,4);return x.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},title:`${n} (Client ID: ${r})`,children:[x.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",backgroundColor:o,border:t?"2px solid var(--bgColor-default, #ffffff)":"none",boxShadow:t?"0 0 0 1px var(--borderColor-default, #d1d5db)":"none",flexShrink:0}}),x.jsx("span",{style:{backgroundColor:s,color:"var(--fgColor-onEmphasis, #ffffff)",padding:"3px 8px",borderRadius:"12px",fontSize:"12px",fontWeight:"500",lineHeight:"1.2",whiteSpace:"nowrap",textShadow:"0 1px 2px rgba(0,0,0,0.1)",boxShadow:t?"0 1px 3px rgba(0,0,0,0.2), inset 0 1px 0 rgba(255,255,255,0.2)":"0 1px 2px rgba(0,0,0,0.1)",opacity:1},children:`${n} ${i}`})]})}function ck({binding:n,cursorsContainer:e,currentUserName:t="You",currentUserColor:r,showCollaborators:o=!0}){return x.jsxs(x.Fragment,{children:[o&&x.jsx(lk,{binding:n,currentUserName:t,currentUserColor:r}),e]})}function uk(n,e,t,r,o,s){G1(r!=null,"createBinding: doc is null or undefined");const i=tk(r);ye(" Loro tree initialized, content will be populated via server sync");const a=Wt(r);ye("- Creating binding:",{bindingId:t,localPeerId:r.peerId,generatedClientID:a,docPeerIdType:typeof r.peerId,awarenessKey:a.toString()});const l={clientID:a,cursors:new Map,cursorsContainer:null,doc:r,docMap:o,editor:n,tree:i,excludedProperties:s||new Map,id:t,nodeProperties:new Map,nodeMapper:null,commitTimeout:null,pendingCommit:!1};return l.nodeMapper=ik(l),Sm()&&(ok(l),ye(" Loro debugging enabled via ?debug=true URL parameter")),l}function vm(n){const e=n.awarenessData;if(!e||typeof e!="object")return n.name;const t=e,r=t.user,o=r&&typeof r=="object"?r:void 0,s=[o?.display_name,o?.displayName,o?.name,o?.username,o?.handle,t.display_name,t.displayName,t.name,t.username,t.handle,n.name];for(const i of s)if(typeof i=="string"&&i.trim().length>0)return i;return n.name}function rg(n,e){try{const t=Q(n.key);if(!t)return null;const r=e.nodeMapper;if(oe(t)){const s=r.getTreeIDByLexicalKey(n.key);if(!s)return null;const i=t.getTextContent(),a=Math.min(n.offset,i.length);return{treeId:s,offset:a,pointType:"text"}}if(q(t)){const s=t.getChildren();if(s.length===0){const a=r.getTreeIDByLexicalKey(n.key);return a?{treeId:a,offset:n.offset,pointType:"element"}:null}if(n.offset<s.length){const a=s[n.offset];if(a){const l=r.getTreeIDByLexicalKey(a.getKey());if(l)return{treeId:l,offset:0,pointType:oe(a)?"text":"element"}}}const i=r.getTreeIDByLexicalKey(n.key);return i?{treeId:i,offset:n.offset,pointType:"element"}:null}const o=r.getTreeIDByLexicalKey(n.key);return o?{treeId:o,offset:n.offset,pointType:"element"}:null}catch(t){return console.warn("Failed to convert Lexical point to Loro cursor:",t),null}}function km(n,e,t){try{if(!n||!e)return null;const r=n,o=e,s=t.nodeMapper;let i=null,a=null;return r.treeId&&(i=s.getLexicalKeyByLoroId(r.treeId)),o.treeId&&(a=s.getLexicalKeyByLoroId(o.treeId)),!i||!a?null:{anchorKey:i,anchorOffset:r.offset||0,focusKey:a,focusOffset:o.offset||0}}catch(r){return console.warn("Failed to convert Loro cursors to Lexical selection:",r),null}}function og(n,e,t){if(n.key!==e||n.offset!==t){let r=Q(e);if(r!==null&&!q(r)&&!oe(r)){const o=r.getParentOrThrow();e=o.getKey(),t=r.getIndexWithinParent(),r=o}n.set(e,t,q(r)?"element":"text")}}function dk(n,e){return{color:e,name:n,selection:null}}function fk(n,e,t,r,o,s=!1){const i=n.color,a=i,l=i,c=document.createElement("span");c.style.cssText=`position:absolute;top:0;bottom:0;right:-1px;width:2px;background-color:${a};z-index:10;${s?"opacity:0.8;":""}`;const u=document.createElement("span");return u.textContent=n.name,u.style.cssText=`position:absolute;left:-2px;top:-16px;background-color:${l};color:var(--fgColor-onEmphasis,#fff);line-height:12px;font-size:12px;padding:2px;font-family:Arial;font-weight:bold;white-space:nowrap;${s?"opacity:0.9;":""}`,c.appendChild(u),{anchor:{key:e,offset:t},focus:{key:r,offset:o},caret:c,color:n.color,name:u,selections:[]}}function gk(n,e){const t=e.selection;t!==null&&(Tm(n,t),e.selection=null)}function Tm(n,e){const t=n.cursorsContainer;if(t!==null){const r=e.selections,o=r.length;for(let s=0;s<o;s++)t.removeChild(r[s])}}function Im(n,e,t){const{getAwarenessStates:r=pk}=t??{},o=Array.from(r(n,e)),s=n.clientID,i=n.cursors,l=n.editor._editorState._nodeMap,c=new Set;for(let f=0;f<o.length;f++){const d=o[f],[g,h]=d;c.add(g);const{color:_}=h,m=vm(h),b=g===s;let w=null,C=i.get(g);if(C===void 0){const I=b?`${m} (Me)`:m;C=dk(I,_),i.set(g,C)}else C.name!==m&&(C.name=m,C.selection&&(C.selection.name.textContent=b?`${m} (Me)`:m));const{anchorPos:v,focusPos:k}=h;if(v!==null&&k!==null){const I=km(v,k,n);if(I){const{anchorKey:E,anchorOffset:N,focusKey:O,focusOffset:M}=I;if(w=C.selection,w===null)w=fk(C,E,N,O,M,b);else{const R=w.anchor,$=w.focus;R.key=E,R.offset=N,$.key=O,$.offset=M}}}hk(n,C,w,l,b)}const u=Array.from(i.keys());for(let f=0;f<u.length;f++){const d=u[f];if(!c.has(d)){const g=i.get(d);g!==void 0&&(gk(n,g),i.delete(d))}}}function pk(n,e){return e.awareness.getStates()}function hk(n,e,t,r,o=!1){const s=n.editor,i=s.getRootElement(),a=n.cursorsContainer;if(a===null||i===null)return;const l=a.getBoundingClientRect(),c=e.selection;if(t===null){if(c===null)return;e.selection=null,Tm(n,c);return}else e.selection=t;const u=t.caret,f=t.color,d=t.selections,g=t.anchor,h=t.focus,_=g.key,m=h.key,b=r.get(_),w=r.get(m);if(b==null||w==null)return;const C=_===m&&g.offset===h.offset;let v;if(b===w&&ue(b)){const E=s.getElementByKey(_);E?v=[E.getBoundingClientRect()]:v=[]}else{const E=fh(s,b,g.offset,w,h.offset);if(E===null)return;if(C){if(v=Ml(s,E),v.length===0){const N=E.getBoundingClientRect();N.height>0&&(v=[N])}}else v=Ml(s,E)}const k=d.length,I=v.length;for(let E=0;E<I;E++){const N=v[E];let O=d[E];if(O===void 0){O=document.createElement("span"),d[E]=O;const A=document.createElement("span");O.appendChild(A),a.appendChild(O)}const M=N.top-l.top,R=N.left-l.left,$=C?Math.max(N.width,4):N.width,L=`position:absolute;top:${M}px;left:${R}px;height:${N.height}px;width:${$}px;pointer-events:none;z-index:10;overflow:visible;`;O.style.cssText=L,C?(O.firstChild.style.cssText="position:absolute;left:0;top:0;width:0;height:0;",u.style.cssText=`position:absolute;top:0;left:0;width:2px;height:${N.height}px;background-color:${f};z-index:10;`):o?O.firstChild.style.cssText=`position:absolute;left:0;top:0;width:${N.width}px;height:${N.height}px;background-color:${f};opacity:0.08;border-radius:2px;pointer-events:none;`:O.firstChild.style.cssText=`position:absolute;left:0;top:0;width:${N.width}px;height:${N.height}px;background-color:${f};opacity:0.25;border-radius:2px;pointer-events:none;`,E===I-1&&u.parentNode!==O&&O.appendChild(u)}for(let E=k-1;E>=I;E--){const N=d[E];a.removeChild(N),d.pop()}}function Em(n,e,t,r){const o=e.awareness,s=o.getLocalState();if(s===null)return;const{anchorPos:i,focusPos:a,name:l,color:c,focusing:u,awarenessData:f}=s;let d=null,g=null;if(F(r))d=rg(r.anchor,n),g=rg(r.focus,n);else if(r!==null)return;if(!(sg(i,d)||sg(a,g)))return;const _=d!==null&&g!==null?!0:u;o.setLocalState({...s,anchorPos:d,awarenessData:f,color:c,focusPos:g,focusing:_,name:l})}function sg(n,e){if(n==null)return e!=null;if(e==null)return!0;{const t=n,r=e;return t.treeId!==r.treeId||t.offset!==r.offset||t.pointType!==r.pointType}}function ig(n,e){const r=e.awareness.getLocalState();if(r===null)return;const{anchorPos:o,focusPos:s}=r;if(o!==null&&s!==null){const i=km(o,s,n);if(i){const{anchorKey:a,anchorOffset:l,focusKey:c,focusOffset:u}=i,f=D();if(!F(f))return;og(f.anchor,a,l),og(f.focus,c,u)}}}const _k=(n,e)=>{const t=n.encode(),r=e.encode();return t.length===r.length&&t.every((o,s)=>o===r[s])},mk=n=>{const e=n.awarenessData,t=e&&e.user&&typeof e.user=="object"?e.user:void 0,r=t?.id??t?.uid;return typeof r=="string"&&r.length>0?r:void 0};function bk(n,e){const t=[];for(const[r,o]of n){const s=o.anchorPos,i=o.focusPos;t.push({clientId:r,uid:mk(o),name:vm(o),color:o.color,isCurrentUser:r===e,focusing:!!o.focusing,selecting:s!==null&&i!==null&&!_k(s,i)})}return t.sort((r,o)=>Number(o.isCurrentUser)-Number(r.isCurrentUser)||r.clientId-o.clientId)}const ag=["Cat","Dog","Rabbit","Frog","Fox","Hedgehog","Pigeon","Squirrel","Bear","Tiger","Leopard","Zebra","Wolf","Owl","Gull","Squid","Panda","Lion","Eagle","Shark","Dolphin","Penguin","Koala","Kangaroo"];function Nm(n){const e=Math.abs(n)%ag.length,t=Math.abs(n).toString().slice(-4),r=`${ag[e]}-${t}`,o=Jw(r);return{name:r,color:o}}const lg=Nm(Math.floor(Math.random()*1e5)),yk=S.createContext({clientID:0,color:lg.color,isCollabActive:!1,name:lg.name,docMap:new Map});function Lm(n,e){const t=S.useContext(yk);return n!=null&&(t.name=n),e!=null&&(t.color=e),t}const zu=["Map","List","MovableList","Text","Tree","Counter"];function wk(n,e){if(typeof n!="object"||n===null||Array.isArray(n))throw new Error("Invalid toContainerTree options");for(const t of Object.keys(n))if(t!=="text"&&!(e&&t==="roots"))throw new Error("Unknown toContainerTree option: "+t);if(e&&n.roots!==void 0&&!Array.isArray(n.roots))throw new Error("roots must be an array");return n}function xk(n,e,t){return{cid:n.cid,start:e,totalLength:t,items:n.value}}function Ck(n,e,t){return{type:zu[n],cid:e,value:t}}function Sk(n,e,t){return"cid:"+e+"@"+n+":"+zu[t]}function vk(n,e){return"cid:root-"+n+":"+zu[e]}function kk(n){return{type:"Value",value:n}}function Tk(n){return n.slice()}function Ik(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}function Ek(n,e,t){Object.defineProperty(n,e,{value:t,enumerable:!0,writable:!0,configurable:!0})}let p;function Nk(n){p=n}const Be=new Array(128).fill(void 0);Be.push(void 0,null,!0,!1);function W(n){return Be[n]}let G=0,hi=null;function ko(){return(hi===null||hi.byteLength===0)&&(hi=new Uint8Array(p.memory.buffer)),hi}const Lk=typeof TextEncoder>"u"?(0,module.require)("util").TextEncoder:TextEncoder;let Ti=new Lk("utf-8");const Ok=typeof Ti.encodeInto=="function"?function(n,e){return Ti.encodeInto(n,e)}:function(n,e){const t=Ti.encode(n);return e.set(t),{read:n.length,written:t.length}};function _e(n,e,t){if(t===void 0){const a=Ti.encode(n),l=e(a.length,1)>>>0;return ko().subarray(l,l+a.length).set(a),G=a.length,l}let r=n.length,o=e(r,1)>>>0;const s=ko();let i=0;for(;i<r;i++){const a=n.charCodeAt(i);if(a>127)break;s[o+i]=a}if(i!==r){i!==0&&(n=n.slice(i)),o=t(o,r,r=i+n.length*3,1)>>>0;const a=ko().subarray(o+i,o+r),l=Ok(n,a);i+=l.written,o=t(o,r,i,1)>>>0}return G=i,o}let io=null;function y(){return(io===null||io.buffer.detached===!0||io.buffer.detached===void 0&&io.buffer!==p.memory.buffer)&&(io=new DataView(p.memory.buffer)),io}let bs=Be.length;function P(n){bs===Be.length&&Be.push(Be.length+1);const e=bs;return bs=Be[e],Be[e]=n,e}function nt(n,e){try{return n.apply(this,e)}catch(t){p.__wbindgen_exn_store(P(t))}}const Rk=typeof TextDecoder>"u"?(0,module.require)("util").TextDecoder:TextDecoder;let Om=new Rk("utf-8",{ignoreBOM:!0,fatal:!0});Om.decode();function He(n,e){return n=n>>>0,Om.decode(ko().subarray(n,n+e))}function Ak(n){n<132||(Be[n]=bs,bs=n)}function T(n){const e=W(n);return Ak(n),e}function Tn(n,e){return n=n>>>0,ko().subarray(n/1,n/1+e)}function De(n){return n==null}const cg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>{p.__wbindgen_export_4.get(n.dtor)(n.a,n.b)});function Rm(n,e,t,r){const o={a:n,b:e,cnt:1,dtor:t},s=(...i)=>{o.cnt++;const a=o.a;o.a=0;try{return r(a,o.b,...i)}finally{--o.cnt===0?(p.__wbindgen_export_4.get(o.dtor)(a,o.b),cg.unregister(o)):o.a=a}};return s.original=o,cg.register(s,o,o),s}function dc(n){const e=typeof n;if(e=="number"||e=="boolean"||n==null)return`${n}`;if(e=="string")return`"${n}"`;if(e=="symbol"){const o=n.description;return o==null?"Symbol":`Symbol(${o})`}if(e=="function"){const o=n.name;return typeof o=="string"&&o.length>0?`Function(${o})`:"Function"}if(Array.isArray(n)){const o=n.length;let s="[";o>0&&(s+=dc(n[0]));for(let i=1;i<o;i++)s+=", "+dc(n[i]);return s+="]",s}const t=/\[object ([^\]]+)\]/.exec(toString.call(n));let r;if(t&&t.length>1)r=t[1];else return toString.call(n);if(r=="Object")try{return"Object("+JSON.stringify(n)+")"}catch{return"Object"}return n instanceof Error?`${n.name}: ${n.message}
207
+ ${n.stack}`:r}function Mk(){let n,e;try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.LORO_VERSION(o);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);return n=t,e=r,He(t,r)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(n,e,1)}}function Xn(n,e){const t=e(n.length*1,1)>>>0;return ko().set(n,t/1),G=n.length,t}function fc(n,e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(n,p.__wbindgen_malloc),a=G;p.decodeImportBlobMeta(s,i,a,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function gc(){p.callPendingEvents()}function $k(n,e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.redactJsonUpdates(s,P(n),P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function Am(n){const e=_e(n,p.__wbindgen_malloc,p.__wbindgen_realloc),t=G;return p.isValidContainerId(e,t)!==0}function Dk(){p.run()}function Tt(n,e){const t=e(n.length*4,4)>>>0,r=y();for(let o=0;o<n.length;o++)r.setUint32(t+4*o,P(n[o]),!0);return G=n.length,t}function Pk(n){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(n,p.__wbindgen_malloc),l=G;p.encodeFrontiers(i,a,l);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}function jk(n){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Xn(n,p.__wbindgen_malloc),i=G;p.decodeFrontiers(o,s,i);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}function Fk(){p.setDebug()}let et=128;function mt(n){if(et==1)throw new Error("out of js stack");return Be[--et]=n,et}function jo(n,e){if(!(n instanceof e))throw new Error(`expected instance of ${e.name}`)}function jt(n,e){n=n>>>0;const t=y(),r=[];for(let o=n;o<n+4*e;o+=4)r.push(T(t.getUint32(o,!0)));return r}function Bk(n,e,t){p._dyn_core_ed718c3d60ebd546___ops__function__FnMut_______Output______as_wasm_bindgen_cfd5deec16e3bd1c___closure__WasmClosure___describe__invoke___wasm_bindgen_cfd5deec16e3bd1c___JsValue_____(n,e,P(t))}function Uk(n,e){p._dyn_core_ed718c3d60ebd546___ops__function__FnMut_____Output______as_wasm_bindgen_cfd5deec16e3bd1c___closure__WasmClosure___describe__invoke______(n,e)}const ug=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_awarenesswasm_free(n>>>0,1));class zk{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ug.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_awarenesswasm_free(e,0)}getAllStates(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_getAllStates(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getTimestamp(e){try{const i=p.__wbindgen_add_to_stack_pointer(-32);p.awarenesswasm_getTimestamp(i,this.__wbg_ptr,P(e));var t=y().getInt32(i+0,!0),r=y().getFloat64(i+8,!0),o=y().getInt32(i+16,!0),s=y().getInt32(i+20,!0);if(s)throw T(o);return t===0?void 0:r}finally{p.__wbindgen_add_to_stack_pointer(32)}}setLocalState(e){p.awarenesswasm_setLocalState(this.__wbg_ptr,P(e))}removeOutdated(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_removeOutdated(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_new(i,P(e),t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return this.__wbg_ptr=r>>>0,ug.register(this,this.__wbg_ptr,this),this}finally{p.__wbindgen_add_to_stack_pointer(16)}}peer(){const e=p.awarenesswasm_peer(this.__wbg_ptr);return T(e)}apply(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(e,p.__wbindgen_malloc),a=G;p.awarenesswasm_apply(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}peers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_peers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_encode(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}length(){return p.awarenesswasm_length(this.__wbg_ptr)}isEmpty(){return p.awarenesswasm_isEmpty(this.__wbg_ptr)!==0}getState(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_getState(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encodeAll(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.awarenesswasm_encodeAll(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const dg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_changemodifier_free(n>>>0,1));class To{static __wrap(e){e=e>>>0;const t=Object.create(To.prototype);return t.__wbg_ptr=e,dg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,dg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_changemodifier_free(e,0)}setMessage(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G,o=p.changemodifier_setMessage(this.__wbg_ptr,t,r);return To.__wrap(o)}setTimestamp(e){const t=p.changemodifier_setTimestamp(this.__wbg_ptr,e);return To.__wrap(t)}}const fg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_cursor_free(n>>>0,1));class In{static __wrap(e){e=e>>>0;const t=Object.create(In.prototype);return t.__wbg_ptr=e,fg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,fg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_cursor_free(e,0)}containerId(){const e=p.cursor_containerId(this.__wbg_ptr);return T(e)}pos(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.cursor_pos(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.cursor_kind(this.__wbg_ptr);return T(e)}side(){const e=p.cursor_side(this.__wbg_ptr);return T(e)}static decode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(e,p.__wbindgen_malloc),a=G;p.cursor_decode(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return In.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.cursor_encode(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const gg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_ephemeralstorewasm_free(n>>>0,1));class Ku{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,gg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_ephemeralstorewasm_free(e,0)}getAllStates(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_getAllStates(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}removeOutdated(){p.ephemeralstorewasm_removeOutdated(this.__wbg_ptr)}subscribeLocalUpdates(e){const t=p.ephemeralstorewasm_subscribeLocalUpdates(this.__wbg_ptr,P(e));return T(t)}get(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G,o=p.ephemeralstorewasm_get(this.__wbg_ptr,t,r);return T(o)}constructor(e){const t=p.ephemeralstorewasm_new(e);return this.__wbg_ptr=t>>>0,gg.register(this,this.__wbg_ptr,this),this}set(e,t){const r=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),o=G;p.ephemeralstorewasm_set(this.__wbg_ptr,r,o,P(t))}keys(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_keys(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}apply(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Xn(e,p.__wbindgen_malloc),i=G;p.ephemeralstorewasm_apply(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G;p.ephemeralstorewasm_delete(this.__wbg_ptr,t,r)}encode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.ephemeralstorewasm_encode(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),o}finally{p.__wbindgen_add_to_stack_pointer(16)}}isEmpty(){return p.ephemeralstorewasm_isEmpty(this.__wbg_ptr)!==0}encodeAll(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.ephemeralstorewasm_encodeAll(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){const t=p.ephemeralstorewasm_subscribe(this.__wbg_ptr,P(e));return T(t)}}const ol=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorocounter_free(n>>>0,1));class Vr{static __wrap(e){e=e>>>0;const t=Object.create(Vr.prototype);return t.__wbg_ptr=e,ol.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ol.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorocounter_free(e,0)}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isAttached(){return p.lorocounter_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorocounter_id(this.__wbg_ptr);return T(e)}constructor(){const e=p.lorocounter_new();return this.__wbg_ptr=e>>>0,ol.register(this,this.__wbg_ptr,this),this}kind(){const e=p.lorocounter_kind(this.__wbg_ptr);return T(e)}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}decrement(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_decrement(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get value(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_getShallowValue(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e}finally{p.__wbindgen_add_to_stack_pointer(16)}}increment(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_increment(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorocounter_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const sl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorodoc_free(n>>>0,1));class sn{static __wrap(e){e=e>>>0;const t=Object.create(sn.prototype);return t.__wbg_ptr=e,sl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,sl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorodoc_free(e,0)}applyDiff(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_applyDiff(s,this.__wbg_ptr,P(e),De(t)?0:P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isShallow(){return p.lorodoc_isShallow(this.__wbg_ptr)!==0}changeCount(){return p.lorodoc_changeCount(this.__wbg_ptr)>>>0}getByPath(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorodoc_getByPath(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCounter(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getCounter(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Vr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}isDetached(){return p.lorodoc_isDetached(this.__wbg_ptr)!==0}get peerIdStr(){const e=p.lorodoc_peerIdStr(this.__wbg_ptr);return T(e)}setPeerId(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setPeerId(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursorPos(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);jo(e,In),p.lorodoc_getCursorPos(s,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}hasContainer(e){return p.lorodoc_hasContainer(this.__wbg_ptr,P(e))!==0}importBatch(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importBatch(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}cmpFrontiers(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(e,p.__wbindgen_malloc),l=G,c=Tt(t,p.__wbindgen_malloc),u=G;p.lorodoc_cmpFrontiers(i,this.__wbg_ptr,a,l,c,u);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}debugHistory(){p.lorodoc_debugHistory(this.__wbg_ptr)}static fromSnapshot(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(e,p.__wbindgen_malloc),a=G;p.lorodoc_fromSnapshot(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return sn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangeAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getChangeAt(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}oplogVersion(){const e=p.lorodoc_oplogVersion(this.__wbg_ptr);return At.__wrap(e)}getMovableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getMovableList(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}frontiersToVV(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=G;p.lorodoc_frontiersToVV(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getAllChanges(){const e=p.lorodoc_getAllChanges(this.__wbg_ptr);return T(e)}oplogFrontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_oplogFrontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}vvToFrontiers(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);jo(e,At),p.lorodoc_vvToFrontiers(s,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}shallowSinceVV(){const e=p.lorodoc_shallowSinceVV(this.__wbg_ptr);return At.__wrap(e)}configTextStyle(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_configTextStyle(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getOpsInChange(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getOpsInChange(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=jt(t,r).slice();return p.__wbindgen_free(t,r*4,4),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getShallowValue(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}checkoutToLatest(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_checkoutToLatest(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}cmpWithFrontiers(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=G;p.lorodoc_cmpWithFrontiers(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return t}finally{p.__wbindgen_add_to_stack_pointer(16)}}exportJsonInIdSpan(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_exportJsonInIdSpan(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribeJsonpath(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=G;p.lorodoc_subscribeJsonpath(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}deleteRootContainer(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_deleteRootContainer(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}exportJsonUpdates(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_exportJsonUpdates(a,this.__wbg_ptr,P(e),P(t),De(r)?16777215:r?1:0);var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getContainerById(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getContainerById(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getPendingTxnLength(){return p.lorodoc_getPendingTxnLength(this.__wbg_ptr)>>>0}importJsonUpdates(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importJsonUpdates(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}importUpdateBatch(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_importBatch(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setDetachedEditing(e){p.lorodoc_setDetachedEditing(this.__wbg_ptr,e)}setRecordTimestamp(e){p.lorodoc_setRecordTimestamp(this.__wbg_ptr,e)}subscribePreCommit(e){const t=p.lorodoc_subscribePreCommit(this.__wbg_ptr,P(e));return T(t)}findIdSpansBetween(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=Tt(e,p.__wbindgen_malloc),l=G,c=Tt(t,p.__wbindgen_malloc),u=G;p.lorodoc_findIdSpansBetween(i,this.__wbg_ptr,a,l,c,u);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangeAtLamport(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=G;p.lorodoc_getChangeAtLamport(i,this.__wbg_ptr,a,l,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getPathToContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getPathToContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getChangedContainersIn(e,t){try{const l=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getChangedContainersIn(l,this.__wbg_ptr,P(e),t);var r=y().getInt32(l+0,!0),o=y().getInt32(l+4,!0),s=y().getInt32(l+8,!0),i=y().getInt32(l+12,!0);if(i)throw T(s);var a=jt(r,o).slice();return p.__wbindgen_free(r,o*4,4),a}finally{p.__wbindgen_add_to_stack_pointer(16)}}getDeepValueWithID(){const e=p.lorodoc_getDeepValueWithID(this.__wbg_ptr);return T(e)}setNextCommitOrigin(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G;p.lorodoc_setNextCommitOrigin(this.__wbg_ptr,t,r)}getUncommittedOpsAsJson(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getUncommittedOpsAsJson(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setNextCommitMessage(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G;p.lorodoc_setNextCommitMessage(this.__wbg_ptr,t,r)}setNextCommitOptions(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setNextCommitOptions(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}shallowSinceFrontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_shallowSinceFrontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribeLocalUpdates(e){const t=p.lorodoc_subscribeLocalUpdates(this.__wbg_ptr,P(e));return T(t)}travelChangeAncestors(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=G;p.lorodoc_travelChangeAncestors(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clearNextCommitOptions(){p.lorodoc_clearNextCommitOptions(this.__wbg_ptr)}configDefaultTextStyle(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_configDefaultTextStyle(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setChangeMergeInterval(e){p.lorodoc_setChangeMergeInterval(this.__wbg_ptr,e)}setNextCommitTimestamp(e){p.lorodoc_setNextCommitTimestamp(this.__wbg_ptr,e)}setHideEmptyRootContainers(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_setHideEmptyRootContainers(o,this.__wbg_ptr,e);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDetachedEditingEnabled(){return p.lorodoc_isDetachedEditingEnabled(this.__wbg_ptr)!==0}subscribeFirstCommitFromPeer(e){const t=p.lorodoc_subscribeFirstCommitFromPeer(this.__wbg_ptr,P(e));return T(t)}constructor(){const e=p.lorodoc_new();return this.__wbg_ptr=e>>>0,sl.register(this,this.__wbg_ptr,this),this}diff(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16),l=Tt(e,p.__wbindgen_malloc),c=G,u=Tt(t,p.__wbindgen_malloc),f=G;p.lorodoc_diff(a,this.__wbg_ptr,l,c,u,f,De(r)?16777215:r?1:0);var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}fork(){const e=p.lorodoc_fork(this.__wbg_ptr);return sn.__wrap(e)}attach(){p.lorodoc_attach(this.__wbg_ptr)}commit(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_commit(o,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}detach(){p.lorodoc_detach(this.__wbg_ptr)}export(e){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_export(a,this.__wbg_ptr,P(e));var t=y().getInt32(a+0,!0),r=y().getInt32(a+4,!0),o=y().getInt32(a+8,!0),s=y().getInt32(a+12,!0);if(s)throw T(o);var i=Tn(t,r).slice();return p.__wbindgen_free(t,r*1,1),i}finally{p.__wbindgen_add_to_stack_pointer(16)}}import(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(e,p.__wbindgen_malloc),a=G;p.lorodoc_import(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}forkAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Tt(e,p.__wbindgen_malloc),a=G;p.lorodoc_forkAt(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return sn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getMap(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getMap(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}opCount(){return p.lorodoc_opCount(this.__wbg_ptr)>>>0}get peerId(){const e=p.lorodoc_peerId(this.__wbg_ptr);return BigInt.asUintN(64,e)}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_toJSON(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}version(){const e=p.lorodoc_version(this.__wbg_ptr);return At.__wrap(e)}checkout(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Tt(e,p.__wbindgen_malloc),i=G;p.lorodoc_checkout(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getList(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Yr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getText(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getText(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_getTree(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Zr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}frontiers(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_frontiers(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}JSONPath(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorodoc_JSONPath(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}revertTo(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=Tt(e,p.__wbindgen_malloc),i=G;p.lorodoc_revertTo(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}subscribe(e){const t=p.lorodoc_subscribe(this.__wbg_ptr,P(e));return T(t)}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorodoc_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const il=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorolist_free(n>>>0,1));class Yr{static __wrap(e){e=e>>>0;const t=Object.create(Yr.prototype);return t.__wbg_ptr=e,il.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,il.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorolist_free(e,0)}isAttached(){return p.lorolist_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}pushContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_pushContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeValue(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getRangeValue(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insertContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_insertContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.lorolist_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeDeepValueWithID(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getRangeDeepValueWithID(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorolist_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_get(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.lorolist_new();return this.__wbg_ptr=e>>>0,il.register(this,this.__wbg_ptr,this),this}pop(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_pop(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.lorolist_kind(this.__wbg_ptr);return T(e)}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_push(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_insert(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.lorolist_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getIdAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getIdAt(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorolist_toJSON(this.__wbg_ptr);return T(e)}toArray(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toArray(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorolist_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTreeSlice(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.lorolist_toContainerTreeSlice(a,this.__wbg_ptr,e,t,De(r)?0:P(r));var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const al=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_loromap_free(n>>>0,1));class Gn{static __wrap(e){e=e>>>0;const t=Object.create(Gn.prototype);return t.__wbg_ptr=e,al.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,al.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_loromap_free(e,0)}isAttached(){return p.loromap_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastEditor(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G,o=p.loromap_getLastEditor(this.__wbg_ptr,t,r);return T(o)}setContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=G;p.loromap_setContainer(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.loromap_getShallowValue(this.__wbg_ptr);return T(e)}ensureMergeableMap(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableMap(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gn.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableList(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Yr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableText(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableText(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Gr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableTree(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Zr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getOrCreateContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),l=G;p.loromap_getOrCreateContainer(i,this.__wbg_ptr,a,l,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableCounter(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableCounter(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Vr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}ensureMergeableMovableList(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_ensureMergeableMovableList(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return Xr.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.loromap_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_get(s,this.__wbg_ptr,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.loromap_new();return this.__wbg_ptr=e>>>0,al.register(this,this.__wbg_ptr,this),this}keys(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_keys(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.loromap_kind(this.__wbg_ptr);return T(e)}get size(){return p.loromap_size(this.__wbg_ptr)>>>0}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),i=G;p.loromap_delete(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}set(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.loromap_set(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}values(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_values(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}entries(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_entries(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.loromap_toJSON(this.__wbg_ptr);return T(e)}isDeleted(){return p.loromap_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromap_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const ll=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_loromovablelist_free(n>>>0,1));class Xr{static __wrap(e){e=e>>>0;const t=Object.create(Xr.prototype);return t.__wbg_ptr=e,ll.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ll.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_loromovablelist_free(e,0)}isAttached(){return p.loromovablelist_isAttached(this.__wbg_ptr)!==0}getCreatorAt(e){const t=p.loromovablelist_getCreatorAt(this.__wbg_ptr,e);return T(t)}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_setContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastMoverAt(e){const t=p.loromovablelist_getLastMoverAt(this.__wbg_ptr,e);return T(t)}pushContainer(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_pushContainer(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastEditorAt(e){const t=p.loromovablelist_getLastEditorAt(this.__wbg_ptr,e);return T(t)}getRangeValue(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getRangeValue(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insertContainer(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_insertContainer(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){const e=p.loromovablelist_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getRangeDeepValueWithID(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getRangeDeepValueWithID(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.loromovablelist_id(this.__wbg_ptr);return T(e)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_get(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}move(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_move(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(){const e=p.loromovablelist_new();return this.__wbg_ptr=e>>>0,ll.register(this,this.__wbg_ptr,this),this}pop(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_pop(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}set(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_set(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.loromovablelist_kind(this.__wbg_ptr);return T(e)}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_push(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_clear(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_insert(s,this.__wbg_ptr,e,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.loromovablelist_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.loromovablelist_toJSON(this.__wbg_ptr);return T(e)}toArray(){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toArray(i,this.__wbg_ptr);var e=y().getInt32(i+0,!0),t=y().getInt32(i+4,!0),r=y().getInt32(i+8,!0),o=y().getInt32(i+12,!0);if(o)throw T(r);var s=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),s}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.loromovablelist_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTreeSlice(e,t,r){try{const a=p.__wbindgen_add_to_stack_pointer(-16);p.loromovablelist_toContainerTreeSlice(a,this.__wbg_ptr,e,t,De(r)?0:P(r));var o=y().getInt32(a+0,!0),s=y().getInt32(a+4,!0),i=y().getInt32(a+8,!0);if(i)throw T(s);return T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const cl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotext_free(n>>>0,1));class Gr{static __wrap(e){e=e>>>0;const t=Object.create(Gr.prototype);return t.__wbg_ptr=e,cl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,cl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotext_free(e,0)}applyDelta(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_applyDelta(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}convertPos(e,t,r){const o=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),s=G,i=_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G,l=p.lorotext_convertPos(this.__wbg_ptr,e,o,s,i,a);return T(l)}deleteUtf8(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_deleteUtf8(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getEditorOf(e){const t=p.lorotext_getEditorOf(this.__wbg_ptr,e);return T(t)}insertUtf8(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorotext_insertUtf8(s,this.__wbg_ptr,e,i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isAttached(){return p.lorotext_isAttached(this.__wbg_ptr)!==0}sliceDelta(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_sliceDelta(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}updateByLine(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorotext_updateByLine(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}sliceDeltaUtf8(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_sliceDeltaUtf8(i,this.__wbg_ptr,e,t);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getShallowValue(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getShallowValue(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorotext_id(this.__wbg_ptr);return T(e)}constructor(){const e=p.lorotext_new();return this.__wbg_ptr=e>>>0,cl.register(this,this.__wbg_ptr,this),this}iter(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_iter(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}kind(){const e=p.lorotext_kind(this.__wbg_ptr);return T(e)}mark(e,t,r){try{const i=p.__wbindgen_add_to_stack_pointer(-16),a=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),l=G;p.lorotext_mark(i,this.__wbg_ptr,P(e),a,l,P(r));var o=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0);if(s)throw T(o)}finally{p.__wbindgen_add_to_stack_pointer(16)}}push(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16),s=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),i=G;p.lorotext_push(o,this.__wbg_ptr,s,i);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}slice(e,t){let r,o;try{const f=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_slice(f,this.__wbg_ptr,e,t);var s=y().getInt32(f+0,!0),i=y().getInt32(f+4,!0),a=y().getInt32(f+8,!0),l=y().getInt32(f+12,!0),c=s,u=i;if(l)throw c=0,u=0,T(a);return r=c,o=u,He(c,u)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(r,o,1)}}delete(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_delete(s,this.__wbg_ptr,e,t);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}insert(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorotext_insert(s,this.__wbg_ptr,e,i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get length(){return p.lorotext_length(this.__wbg_ptr)>>>0}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}splice(e,t,r){let o,s;try{const d=p.__wbindgen_add_to_stack_pointer(-16),g=_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),h=G;p.lorotext_splice(d,this.__wbg_ptr,e,t,g,h);var i=y().getInt32(d+0,!0),a=y().getInt32(d+4,!0),l=y().getInt32(d+8,!0),c=y().getInt32(d+12,!0),u=i,f=a;if(c)throw u=0,f=0,T(l);return o=u,s=f,He(u,f)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(o,s,1)}}unmark(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorotext_unmark(s,this.__wbg_ptr,P(e),i,a);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}update(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),a=G;p.lorotext_update(s,this.__wbg_ptr,i,a,P(t));var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}charAt(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_charAt(s,this.__wbg_ptr,e);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return String.fromCodePoint(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorotext_toJSON(this.__wbg_ptr);return T(e)}toDelta(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toDelta(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getCursor(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_getCursor(i,this.__wbg_ptr,e,P(t));var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return r===0?void 0:In.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorotext_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toString(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toString(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotext_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const ul=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotree_free(n>>>0,1));class Zr{static __wrap(e){e=e>>>0;const t=Object.create(Zr.prototype);return t.__wbg_ptr=e,ul.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,ul.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotree_free(e,0)}createNode(e,t){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_createNode(i,this.__wbg_ptr,mt(e),De(t)?4294967297:t>>>0);var r=y().getInt32(i+0,!0),o=y().getInt32(i+4,!0),s=y().getInt32(i+8,!0);if(s)throw T(o);return on.__wrap(r)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}isAttached(){return p.lorotree_isAttached(this.__wbg_ptr)!==0}getAttached(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getAttached(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getNodeByID(e){try{const t=p.lorotree_getNodeByID(this.__wbg_ptr,mt(e));return t===0?void 0:on.__wrap(t)}finally{Be[et++]=void 0}}isNodeDeleted(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_isNodeDeleted(s,this.__wbg_ptr,mt(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return t!==0}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}getShallowValue(){const e=p.lorotree_getShallowValue(this.__wbg_ptr);return T(e)}getDeepValueWithID(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getDeepValueWithID(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}enableFractionalIndex(e){p.lorotree_enableFractionalIndex(this.__wbg_ptr,e)}disableFractionalIndex(){p.lorotree_disableFractionalIndex(this.__wbg_ptr)}isFractionalIndexEnabled(){return p.lorotree_isFractionalIndexEnabled(this.__wbg_ptr)!==0}get id(){const e=p.lorotree_id(this.__wbg_ptr);return T(e)}move(e,t,r){try{const i=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_move(i,this.__wbg_ptr,mt(e),mt(t),De(r)?4294967297:r>>>0);var o=y().getInt32(i+0,!0),s=y().getInt32(i+4,!0);if(s)throw T(o)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0,Be[et++]=void 0}}constructor(){const e=p.lorotree_new();return this.__wbg_ptr=e>>>0,ul.register(this,this.__wbg_ptr,this),this}kind(){const e=p.lorotree_kind(this.__wbg_ptr);return T(e)}nodes(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_nodes(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}roots(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_roots(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=jt(e,t).slice();return p.__wbindgen_free(e,t*4,4),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}delete(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_delete(o,this.__wbg_ptr,mt(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.lorotree_toJSON(this.__wbg_ptr);return T(e)}has(e){try{return p.lorotree_has(this.__wbg_ptr,mt(e))!==0}finally{Be[et++]=void 0}}toArray(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_toArray(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getNodes(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_getNodes(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){return p.lorotree_isDeleted(this.__wbg_ptr)!==0}subscribe(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_subscribe(s,this.__wbg_ptr,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toContainerTree(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotree_toContainerTree(s,this.__wbg_ptr,De(e)?0:P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const pg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_lorotreenode_free(n>>>0,1));class on{static __wrap(e){e=e>>>0;const t=Object.create(on.prototype);return t.__wbg_ptr=e,pg.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,pg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_lorotreenode_free(e,0)}__getClassname(){let e,t;try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode___getClassname(s,this.__wbg_ptr);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);return e=r,t=o,He(r,o)}finally{p.__wbindgen_add_to_stack_pointer(16),p.__wbindgen_free(e,t,1)}}creationId(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_creationId(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}isDeleted(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_isDeleted(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}moveBefore(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);jo(e,on),p.lorotreenode_moveBefore(o,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}createNode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_createNode(s,this.__wbg_ptr,De(e)?4294967297:e>>>0);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return on.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}getLastMoveId(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_getLastMoveId(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_toJSON(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}fractionalIndex(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_fractionalIndex(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}get id(){const e=p.lorotreenode_id(this.__wbg_ptr);return T(e)}move(e,t){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_move(s,this.__wbg_ptr,mt(e),De(t)?4294967297:t>>>0);var r=y().getInt32(s+0,!0),o=y().getInt32(s+4,!0);if(o)throw T(r)}finally{p.__wbindgen_add_to_stack_pointer(16),Be[et++]=void 0}}get data(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_data(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return Gn.__wrap(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}index(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_index(o,this.__wbg_ptr);var e=y().getFloat64(o+0,!0),t=y().getInt32(o+8,!0),r=y().getInt32(o+12,!0);if(r)throw T(t);return e===4294967297?void 0:e}finally{p.__wbindgen_add_to_stack_pointer(16)}}parent(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.lorotreenode_parent(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e===0?void 0:on.__wrap(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}creator(){const e=p.lorotreenode_creator(this.__wbg_ptr);return T(e)}children(){const e=p.lorotreenode_children(this.__wbg_ptr);return T(e)}moveAfter(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);jo(e,on),p.lorotreenode_moveAfter(o,this.__wbg_ptr,e.__wbg_ptr);var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}const hg=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_undomanager_free(n>>>0,1));class Wu{__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,hg.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_undomanager_free(e,0)}groupStart(){try{const r=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_groupStart(r,this.__wbg_ptr);var e=y().getInt32(r+0,!0),t=y().getInt32(r+4,!0);if(t)throw T(e)}finally{p.__wbindgen_add_to_stack_pointer(16)}}topRedoValue(){const e=p.undomanager_topRedoValue(this.__wbg_ptr);return T(e)}topUndoValue(){const e=p.undomanager_topUndoValue(this.__wbg_ptr);return T(e)}setMaxUndoSteps(e){p.undomanager_setMaxUndoSteps(this.__wbg_ptr,e)}setMergeInterval(e){p.undomanager_setMergeInterval(this.__wbg_ptr,e)}addExcludeOriginPrefix(e){const t=_e(e,p.__wbindgen_malloc,p.__wbindgen_realloc),r=G;p.undomanager_addExcludeOriginPrefix(this.__wbg_ptr,t,r)}constructor(e,t){jo(e,sn);const r=p.undomanager_new(e.__wbg_ptr,P(t));return this.__wbg_ptr=r>>>0,hg.register(this,this.__wbg_ptr,this),this}peer(){const e=p.undomanager_peer(this.__wbg_ptr);return T(e)}redo(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_redo(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}undo(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.undomanager_undo(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=y().getInt32(o+8,!0);if(r)throw T(t);return e!==0}finally{p.__wbindgen_add_to_stack_pointer(16)}}clear(){p.undomanager_clear(this.__wbg_ptr)}pause(){p.undomanager_pause(this.__wbg_ptr)}resume(){p.undomanager_resume(this.__wbg_ptr)}canRedo(){return p.undomanager_canRedo(this.__wbg_ptr)!==0}canUndo(){return p.undomanager_canUndo(this.__wbg_ptr)!==0}groupEnd(){p.undomanager_groupEnd(this.__wbg_ptr)}isPaused(){return p.undomanager_isPaused(this.__wbg_ptr)!==0}setOnPop(e){p.undomanager_setOnPop(this.__wbg_ptr,P(e))}clearRedo(){p.undomanager_clearRedo(this.__wbg_ptr)}clearUndo(){p.undomanager_clearUndo(this.__wbg_ptr)}setOnPush(e){p.undomanager_setOnPush(this.__wbg_ptr,P(e))}}const dl=typeof FinalizationRegistry>"u"?{register:()=>{},unregister:()=>{}}:new FinalizationRegistry(n=>p.__wbg_versionvector_free(n>>>0,1));class At{static __wrap(e){e=e>>>0;const t=Object.create(At.prototype);return t.__wbg_ptr=e,dl.register(t,t.__wbg_ptr,t),t}__destroy_into_raw(){const e=this.__wbg_ptr;return this.__wbg_ptr=0,dl.unregister(this),e}free(){const e=this.__destroy_into_raw();p.__wbg_versionvector_free(e,0)}get(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_get(s,this.__wbg_ptr,P(e));var t=y().getFloat64(s+0,!0),r=y().getInt32(s+8,!0),o=y().getInt32(s+12,!0);if(o)throw T(r);return t===4294967297?void 0:t}finally{p.__wbindgen_add_to_stack_pointer(16)}}constructor(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_new(s,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return this.__wbg_ptr=t>>>0,dl.register(this,this.__wbg_ptr,this),this}finally{p.__wbindgen_add_to_stack_pointer(16)}}static decode(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16),i=Xn(e,p.__wbindgen_malloc),a=G;p.versionvector_decode(s,i,a);var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}encode(){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_encode(o,this.__wbg_ptr);var e=y().getInt32(o+0,!0),t=y().getInt32(o+4,!0),r=Tn(e,t).slice();return p.__wbindgen_free(e,t*1,1),r}finally{p.__wbindgen_add_to_stack_pointer(16)}}length(){return p.versionvector_length(this.__wbg_ptr)>>>0}remove(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_remove(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}setEnd(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_setEnd(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}compare(e){jo(e,At);const t=p.versionvector_compare(this.__wbg_ptr,e.__wbg_ptr);return t===4294967297?void 0:t}setLast(e){try{const o=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_setLast(o,this.__wbg_ptr,P(e));var t=y().getInt32(o+0,!0),r=y().getInt32(o+4,!0);if(r)throw T(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}toJSON(){const e=p.versionvector_toJSON(this.__wbg_ptr);return T(e)}static parseJSON(e){try{const s=p.__wbindgen_add_to_stack_pointer(-16);p.versionvector_parseJSON(s,P(e));var t=y().getInt32(s+0,!0),r=y().getInt32(s+4,!0),o=y().getInt32(s+8,!0);if(o)throw T(r);return At.__wrap(t)}finally{p.__wbindgen_add_to_stack_pointer(16)}}}function Kk(n,e){const t=String(W(e)),r=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=G;y().setInt32(n+4,o,!0),y().setInt32(n+0,r,!0)}function Wk(){return nt(function(n,e,t){const r=W(n).apply(W(e),W(t));return P(r)},arguments)}function Hk(){return nt(function(n,e,t){const r=Reflect.apply(W(n),W(e),W(t));return P(r)},arguments)}function Jk(n){const e=W(n).buffer;return P(e)}function qk(){return nt(function(n,e){const t=W(n).call(W(e));return P(t)},arguments)}function Vk(){return nt(function(n,e,t){const r=W(n).call(W(e),W(t));return P(r)},arguments)}function Yk(){return nt(function(n,e,t,r){const o=W(n).call(W(e),W(t),W(r));return P(o)},arguments)}function Xk(){return nt(function(n,e,t,r,o){const s=W(n).call(W(e),W(t),W(r),W(o));return P(s)},arguments)}function Gk(n){const e=To.__wrap(n);return P(e)}function Zk(n){const e=W(n).crypto;return P(e)}function Qk(n){const e=In.__wrap(n);return P(e)}function eT(n){return W(n).done}function tT(n){const e=Object.entries(W(n));return P(e)}function nT(n){const e=W(n).entries();return P(e)}function rT(n,e){console.error(He(n,e))}function oT(n){const e=Array.from(W(n));return P(e)}function sT(n){const e=Object.getOwnPropertySymbols(W(n));return P(e)}function iT(){return nt(function(n,e){W(n).getRandomValues(W(e))},arguments)}function aT(){return nt(function(n,e){const t=Reflect.get(W(n),W(e));return P(t)},arguments)}function lT(n,e){const t=W(n)[e>>>0];return P(t)}function cT(n,e){return W(n)[e>>>0]}function uT(n,e){const t=W(n)[W(e)];return P(t)}function dT(n){let e;try{e=W(n)instanceof ArrayBuffer}catch{e=!1}return e}function fT(n){let e;try{e=W(n)instanceof Map}catch{e=!1}return e}function gT(n){let e;try{e=W(n)instanceof Object}catch{e=!1}return e}function pT(n){let e;try{e=W(n)instanceof Uint8Array}catch{e=!1}return e}function hT(n){return Array.isArray(W(n))}function _T(n){return Number.isSafeInteger(W(n))}function mT(){return P(Symbol.iterator)}function bT(n){return W(n).length}function yT(n){return W(n).length}function wT(n,e,t,r,o,s,i,a){let l,c;try{l=n,c=e,console.log(He(n,e),He(t,r),He(o,s),He(i,a))}finally{p.__wbindgen_free(l,c,1)}}function xT(n,e){let t,r;try{t=n,r=e,console.log(He(n,e))}finally{p.__wbindgen_free(t,r,1)}}function CT(n,e){console.log(He(n,e))}function ST(n){const e=Vr.__wrap(n);return P(e)}function vT(n){const e=Yr.__wrap(n);return P(e)}function kT(n){const e=Gn.__wrap(n);return P(e)}function TT(n){const e=Xr.__wrap(n);return P(e)}function IT(n){const e=Gr.__wrap(n);return P(e)}function ET(n){const e=Zr.__wrap(n);return P(e)}function NT(n){const e=on.__wrap(n);return P(e)}function LT(n,e){performance.mark(He(n,e))}function OT(){return nt(function(n,e,t,r){let o,s,i,a;try{o=n,s=e,i=t,a=r,performance.measure(He(n,e),He(t,r))}finally{p.__wbindgen_free(o,s,1),p.__wbindgen_free(i,a,1)}},arguments)}function RT(n){const e=W(n).msCrypto;return P(e)}function AT(){const n=new Object;return P(n)}function MT(){return P(new Map)}function $T(){const n=new Array;return P(n)}function DT(n){const e=new Uint8Array(W(n));return P(e)}function PT(n,e){const t=new Error(He(n,e));return P(t)}function jT(n,e){const t=new Function(He(n,e));return P(t)}function FT(n,e,t){const r=new Uint8Array(W(n),e>>>0,t>>>0);return P(r)}function BT(n){const e=new Uint8Array(n>>>0);return P(e)}function UT(n){const e=new Array(n>>>0);return P(e)}function zT(n){const e=W(n).next;return P(e)}function KT(){return nt(function(n){const e=W(n).next();return P(e)},arguments)}function WT(n){const e=W(n).node;return P(e)}function HT(){return Date.now()}function JT(){return nt(function(n){const e=Reflect.ownKeys(W(n));return P(e)},arguments)}function qT(n){const e=W(n).process;return P(e)}function VT(n,e){return W(n).push(W(e))}function YT(){return nt(function(n,e){W(n).randomFillSync(T(e))},arguments)}function XT(){return nt(function(){const n=module.require;return P(n)},arguments)}function GT(n){const e=Promise.resolve(W(n));return P(e)}function ZT(n,e,t){W(n)[e>>>0]=T(t)}function QT(n,e,t){W(n)[T(e)]=T(t)}function eI(n,e,t){W(n).set(W(e),t>>>0)}function tI(n,e,t){const r=W(n).set(W(e),W(t));return P(r)}function nI(){return nt(function(n,e,t){return Reflect.set(W(n),W(e),W(t))},arguments)}function rI(n,e,t){W(n)[e>>>0]=t}function oI(n,e){const t=Tk(Tn(n,e));return P(t)}function sI(n,e,t){const r=Sk(W(n),e,t);return P(r)}function iI(n,e,t){const r=Ck(n,W(e),T(t));return P(r)}function aI(){return nt(function(n,e,t){Ik(W(n),e>>>0,W(t))},arguments)}function lI(){return nt(function(n,e){const t=wk(T(n),e!==0);return P(t)},arguments)}function cI(n,e,t){const r=vk(He(n,e),t);return P(r)}function uI(){return nt(function(n,e,t){Ek(W(n),W(e),W(t))},arguments)}function dI(n,e,t){const r=xk(T(n),e>>>0,t>>>0);return P(r)}function fI(n){const e=kk(T(n));return P(e)}function gI(){const n=typeof globalThis>"u"?null:globalThis;return De(n)?0:P(n)}function pI(){const n=typeof globalThis>"u"?null:globalThis;return De(n)?0:P(n)}function hI(){const n=typeof self>"u"?null:self;return De(n)?0:P(n)}function _I(){const n=typeof window>"u"?null:window;return De(n)?0:P(n)}function mI(n,e,t){const r=W(n).subarray(e>>>0,t>>>0);return P(r)}function bI(n,e){const t=W(n).then(W(e));return P(t)}function yI(n){const e=W(n).value;return P(e)}function wI(n){const e=W(n).versions;return P(e)}function xI(n){const e=At.__wrap(n);return P(e)}function CI(n,e){console.warn(He(n,e))}function SI(n){return+W(n)}function vI(n){return P(n)}function kI(n){const e=BigInt.asUintN(64,n);return P(e)}function TI(n,e){const t=W(e),r=typeof t=="bigint"?t:void 0;y().setBigInt64(n+8,De(r)?BigInt(0):r,!0),y().setInt32(n+0,!De(r),!0)}function II(n){const e=W(n);return typeof e=="boolean"?e?1:0:2}function EI(n){const e=T(n).original;return e.cnt--==1?(e.a=0,!0):!1}function NI(n,e,t){const r=Rm(n,e,15,Bk);return P(r)}function LI(n,e,t){const r=Rm(n,e,15,Uk);return P(r)}function OI(n,e){const t=dc(W(e)),r=_e(t,p.__wbindgen_malloc,p.__wbindgen_realloc),o=G;y().setInt32(n+4,o,!0),y().setInt32(n+0,r,!0)}function RI(n,e){const t=new Error(He(n,e));return P(t)}function AI(n,e){return W(n)in W(e)}function MI(n){return Array.isArray(W(n))}function $I(n){return typeof W(n)=="bigint"}function DI(n){return typeof W(n)=="function"}function PI(n){return W(n)===null}function jI(n){const e=W(n);return typeof e=="object"&&e!==null}function FI(n){return typeof W(n)=="string"}function BI(n){return W(n)===void 0}function UI(n,e){return W(n)===W(e)}function zI(n,e){return W(n)==W(e)}function KI(){const n=p.memory;return P(n)}function WI(n,e){const t=W(e),r=typeof t=="number"?t:void 0;y().setFloat64(n+8,De(r)?0:r,!0),y().setInt32(n+0,!De(r),!0)}function HI(n){return P(n)}function JI(n){const e=W(n);return P(e)}function qI(n){T(n)}function VI(n){throw T(n)}function YI(n,e){const t=W(e),r=typeof t=="string"?t:void 0;var o=De(r)?0:_e(r,p.__wbindgen_malloc,p.__wbindgen_realloc),s=G;y().setInt32(n+4,s,!0),y().setInt32(n+0,o,!0)}function XI(n,e){const t=He(n,e);return P(t)}function GI(n,e){throw new Error(He(n,e))}function ZI(n){const e=typeof W(n);return P(e)}const fl=Symbol("loroContainerId");function QI(n){const e=n.prototype,t=Object.getOwnPropertyDescriptor(e,"id"),r=t&&t.get,o=Object.getOwnPropertyDescriptor(e,"__destroy_into_raw"),s=o&&o.value;if(!r||!o||!s)throw new Error("Unexpected wasm-bindgen container wrapper shape");Object.defineProperty(e,"id",{...t,get(){if(this.__wbg_ptr===0)return r.call(this);const i=this[fl];if(i!==void 0)return i;const a=r.call(this);try{Object.defineProperty(this,fl,{configurable:!0,value:a})}catch{}return a}}),Object.defineProperty(e,"__destroy_into_raw",{...o,value(){try{delete this[fl]}catch{}return s.call(this)}})}function eE(n){const e=n.prototype,t=Object.getOwnPropertyDescriptor(e,"kind"),r=t&&t.value;if(typeof r!="function")throw new Error("Unexpected wasm-bindgen container wrapper shape");let o;Object.defineProperty(e,"kind",{...t,value(){return this.__wbg_ptr===0?r.call(this):(o===void 0&&(o=r.call(this)),o)}})}for(const n of[Gn,Gr,Yr,Zr,Xr,Vr])QI(n),eE(n);const Mm={AwarenessWasm:zk,ChangeModifier:To,Cursor:In,EphemeralStoreWasm:Ku,LORO_VERSION:Mk,LoroCounter:Vr,LoroDoc:sn,LoroList:Yr,LoroMap:Gn,LoroMovableList:Xr,LoroText:Gr,LoroTree:Zr,LoroTreeNode:on,UndoManager:Wu,VersionVector:At,__wbg_String_8f0eb39a4a4c2f66:Kk,__wbg_apply_36be6a55257c99bf:Wk,__wbg_apply_eb9e9b97497f91e4:Hk,__wbg_buffer_609cc3eee51ed158:Jk,__wbg_call_672a4d21634d4a24:qk,__wbg_call_7cccdd69e0791ae2:Vk,__wbg_call_833bed5770ea2041:Yk,__wbg_call_b8adc8b1d0a0d8eb:Xk,__wbg_changemodifier_new:Gk,__wbg_crypto_574e78ad8b13b65f:Zk,__wbg_cursor_new:Qk,__wbg_done_769e5ede4b31c67b:eT,__wbg_entries_3265d4158b33e5dc:tT,__wbg_entries_c8a90a7ed73e84ce:nT,__wbg_error_1d6f2b3f2c5a33ec:rT,__wbg_from_2a5d3e218e67aa85:oT,__wbg_getOwnPropertySymbols_97eebed6fe6e08be:sT,__wbg_getRandomValues_b8f5dbd5f3995a9e:iT,__wbg_get_67b2ba62fc30de12:aT,__wbg_get_b9b93047fe3cf45b:lT,__wbg_getindex_5b00c274b05714aa:cT,__wbg_getwithrefkey_1dc361bd10053bfe:uT,__wbg_instanceof_ArrayBuffer_e14585432e3737fc:dT,__wbg_instanceof_Map_f3469ce2244d2430:fT,__wbg_instanceof_Object_7f2dcef8f78644a4:gT,__wbg_instanceof_Uint8Array_17156bcf118086a9:pT,__wbg_isArray_a1eab7e0d067391b:hT,__wbg_isSafeInteger_343e2beeeece1bb0:_T,__wbg_iterator_9a24c88df860dc65:mT,__wbg_length_a446193dc22c12f8:bT,__wbg_length_e2d2a49132c1b256:yT,__wbg_log_0cc1b7768397bcfe:wT,__wbg_log_cb9e190acc5753fb:xT,__wbg_log_f665cabe523a97df:CT,__wbg_lorocounter_new:ST,__wbg_lorolist_new:vT,__wbg_loromap_new:kT,__wbg_loromovablelist_new:TT,__wbg_lorotext_new:IT,__wbg_lorotree_new:ET,__wbg_lorotreenode_new:NT,__wbg_mark_7438147ce31e9d4b:LT,__wbg_measure_fb7825c11612c823:OT,__wbg_msCrypto_a61aeb35a24c1329:RT,__wbg_new_405e22f390576ce2:AT,__wbg_new_5e0be73521bc8c17:MT,__wbg_new_78feb108b6472713:$T,__wbg_new_a12002a7f91c75be:DT,__wbg_new_c68d7209be747379:PT,__wbg_newnoargs_105ed471475aaf50:jT,__wbg_newwithbyteoffsetandlength_d97e637ebe145a9a:FT,__wbg_newwithlength_a381634e90c276d4:BT,__wbg_newwithlength_c4c419ef0bc8a1f8:UT,__wbg_next_25feadfc0913fea9:zT,__wbg_next_6574e1a8a62d1055:KT,__wbg_node_905d3e251edff8a2:WT,__wbg_now_454cbad00d40f177:HT,__wbg_ownKeys_3930041068756f1f:JT,__wbg_process_dc0fbacc7c1c06f7:qT,__wbg_push_737cfc8c1432c2c6:VT,__wbg_randomFillSync_ac0988aba3254290:YT,__wbg_require_60cc747a6bc5215a:XT,__wbg_resolve_4851785c9c5f573d:GT,__wbg_set_37837023f3d740e8:ZT,__wbg_set_3f1d0b984ed272ed:QT,__wbg_set_65595bdd868b3009:eI,__wbg_set_8fc6bf8a5b1071d1:tI,__wbg_set_bb8cecf6a62b9f46:nI,__wbg_set_wasm:Nk,__wbg_setindex_dcd71eabf405bde1:rI,__wbg_stateBinary_9e1da8a4daa74bc6:oI,__wbg_stateCid_c43ea762fb462319:sI,__wbg_stateContainer_cd983f42c6fe987d:iI,__wbg_stateIndex_1fbac6394e58cff9:aI,__wbg_stateOptions_dcb483514d1b925d:lI,__wbg_stateRootCid_9198769cdd9f37d5:cI,__wbg_stateSet_a3e74b27d3d26f9d:uI,__wbg_stateSlice_aafffe8ecba122b8:dI,__wbg_stateValue_8ed644fcdb61558c:fI,__wbg_static_accessor_GLOBAL_88a902d13a557d07:gI,__wbg_static_accessor_GLOBAL_THIS_56578be7e9f832b0:pI,__wbg_static_accessor_SELF_37c5d418e4bf5819:hI,__wbg_static_accessor_WINDOW_5de37043a91a9c40:_I,__wbg_subarray_aa9065fa9dc5df96:mI,__wbg_then_44b73946d2fb3e7d:bI,__wbg_value_cd1ffa7b1ab794f1:yI,__wbg_versions_c01dfd4722a88165:wI,__wbg_versionvector_new:xI,__wbg_warn_52b319b1b6be3d2f:CI,__wbindgen_as_number:SI,__wbindgen_bigint_from_i64:vI,__wbindgen_bigint_from_u64:kI,__wbindgen_bigint_get_as_i64:TI,__wbindgen_boolean_get:II,__wbindgen_cb_drop:EI,__wbindgen_closure_wrapper285:NI,__wbindgen_closure_wrapper544:LI,__wbindgen_debug_string:OI,__wbindgen_error_new:RI,__wbindgen_in:AI,__wbindgen_is_array:MI,__wbindgen_is_bigint:$I,__wbindgen_is_function:DI,__wbindgen_is_null:PI,__wbindgen_is_object:jI,__wbindgen_is_string:FI,__wbindgen_is_undefined:BI,__wbindgen_jsval_eq:UI,__wbindgen_jsval_loose_eq:zI,__wbindgen_memory:KI,__wbindgen_number_get:WI,__wbindgen_number_new:HI,__wbindgen_object_clone_ref:JI,__wbindgen_object_drop_ref:qI,__wbindgen_rethrow:VI,__wbindgen_string_get:YI,__wbindgen_string_new:XI,__wbindgen_throw:GI,__wbindgen_typeof:ZI,callPendingEvents:gc,decodeFrontiers:jk,decodeImportBlobMeta:fc,encodeFrontiers:Pk,isValidContainerId:Am,redactJsonUpdates:$k,run:Dk,setDebug:Fk},tE={"./loro_wasm_bg.js":Mm},nE=n=>{Mm.__wbg_set_wasm(n),rE(n)};function rE(n){typeof n.__wbindgen_start=="function"&&n.__wbindgen_start()}function oE(n){if(typeof XMLHttpRequest!="function")throw new Error("loro-crdt browser build requires XMLHttpRequest for synchronous WASM loading. Use the nodejs, web, base64, or bundler entry for this runtime.");const e=new XMLHttpRequest;if(e.open("GET",n,!1),e.overrideMimeType("text/plain; charset=x-user-defined"),e.send(null),e.status!==0&&(e.status<200||e.status>=300))throw new Error(`Failed to load loro-crdt WASM from ${n}: ${e.status} ${e.statusText}`);const t=e.responseText,r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t.charCodeAt(o)&255;return r}function sE(n,e){const t=new WebAssembly.Module(n);return new WebAssembly.Instance(t,e)}const iE=new URL(""+new URL("../assets/loro_wasm_bg-BjoaHtGs.wasm",import.meta.url).href,import.meta.url),aE=sE(oE(iE.href),tE);nE(aE.exports);const lE=["Map","Text","List","Tree","MovableList","Counter"];function cE(n){return Am(n)}function _g(n){if(typeof n!="object"||n==null)return!1;const e=Object.getPrototypeOf(n);return e==null||typeof e!="object"||typeof e.kind!="function"?!1:lE.includes(n.kind())}class uE{constructor(e=3e4){this.inner=new Ku(e),this.timeout=e}apply(e){this.inner.apply(e),this.startTimerIfNotEmpty()}set(e,t){this.inner.set(e,t),this.startTimerIfNotEmpty()}delete(e){this.inner.delete(e)}get(e){return this.inner.get(e)}getAllStates(){return this.inner.getAllStates()}encode(e){return this.inner.encode(e)}encodeAll(){return this.inner.encodeAll()}keys(){return this.inner.keys()}destroy(){clearInterval(this.timer)}subscribe(e){return this.inner.subscribe(e)}subscribeLocalUpdates(e){return this.inner.subscribeLocalUpdates(e)}startTimerIfNotEmpty(){this.inner.isEmpty()||this.timer!=null||(this.timer=setInterval(()=>{this.inner.removeOutdated(),this.inner.isEmpty()&&(clearInterval(this.timer),this.timer=void 0)},this.timeout/2))}}sn.prototype.toJsonWithReplacer=function(n){const e=new Set,t=this,r=(i,a)=>{if(typeof a=="string"&&cE(a)&&!e.has(a)){e.add(a);const c=t.getContainerById(a);if(c==null)throw new Error(`ContainerID not found: ${a}`);const u=n(i,c);if(u===c){const f=c.getShallowValue();return typeof f=="object"?o(f):f}if(_g(u))throw new Error("Using new container is not allowed in toJsonWithReplacer");return typeof u=="object"&&u!=null?o(u):u}if(typeof a=="object"&&a!=null)return o(a);const l=n(i,a);if(_g(l))throw new Error("Using new container is not allowed in toJsonWithReplacer");return l},o=i=>{if(Array.isArray(i))return i.map((l,c)=>r(c,l)).filter(l=>l!==void 0);const a={};for(const[l,c]of Object.entries(i)){const u=r(l,c);u!==void 0&&(a[l]=u)}return a},s=t.getShallowValue();return o(s)};const mg=Symbol("loro.callPendingEventsWrapped");function dE(n,e){const t=Object.getOwnPropertyDescriptor(n,e);if(!t||typeof t.value!="function")return;const r=t.value;if(r[mg])return;const o=function(...s){let i;try{return i=r.apply(this,s),i}finally{i&&typeof i.then=="function"?i.finally(()=>{gc()}):gc()}};o[mg]=!0,Object.defineProperty(n,e,{...t,value:o})}function Hu(n,e){for(const t of e)dE(n,t)}Hu(sn.prototype,["setDetachedEditing","attach","detach","fork","forkAt","checkoutToLatest","checkout","commit","getCursorPos","revertTo","export","exportJsonUpdates","exportJsonInIdSpan","importJsonUpdates","import","importUpdateBatch","importBatch","travelChangeAncestors","getChangedContainersIn","diff","applyDiff","setPeerId"]);Hu(Ku.prototype,["set","delete","apply","removeOutdated"]);Hu(Wu.prototype,["undo","redo"]);const fE=he("CONNECTED_COMMAND"),gE=he("TOGGLE_CONNECT_COMMAND");function pE(n){return new Wu(n.doc,{mergeInterval:1e3,maxUndoSteps:100,excludeOriginPrefixes:["collab-","sync-"]})}function hE(n,e,t,r,o){n.awareness.setLocalState({anchorPos:null,awarenessData:o,color:t,focusPos:null,focusing:r,name:e})}function bg(n,e,t,r,o){const{awareness:s}=n;let i=s.getLocalState();i===null&&(i={anchorPos:null,awarenessData:o,color:t,focusPos:null,focusing:r,name:e}),i.name=e,i.color=t,i.focusing=r,s.setLocalState(i)}function _E(n,e,t){const{awareness:r}=n;let o=r.getLocalState();o===null?o={anchorPos:null,awarenessData:{},color:t,focusPos:null,focusing:!1,name:e}:(o.name=e,o.color=t),r.setLocalState(o)}function mE(n,e,t){const o=Ue().getLoroNodeByLexicalKey(n,void 0,void 0,0);if(e)try{if("key"in e||"__key"in e||"lexicalKey"in e){const{key:s,__key:i,lexicalKey:a,children:l,...c}=e;Se(o,"lexical",c)}else{const{children:s,...i}=e;Se(o,"lexical",i)}}catch(s){console.warn("Failed to store lexical node JSON for RootNode:",s)}return Se(o,"elementType","root"),Se(o,"createdAt",Date.now()),o.id}function bE(n,e,t){const o=Ue().getLoroNodeByLexicalKey(n,void 0);if(e)try{if("key"in e||"__key"in e||"lexicalKey"in e){const{key:s,__key:i,lexicalKey:a,children:l,...c}=e;Se(o,"lexical",c)}else{const{children:s,...i}=e;Se(o,"lexical",i)}}catch(s){console.warn("Failed to store lexical node JSON for RootNode update:",s)}Se(o,"elementType","root")}function yE(n,e){Ue().deleteMapping(n)}function wE(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o){let s;n.editorState.read(()=>{if(o.getType()==="root")try{s=o.exportJSON()}catch(i){console.warn("Failed to export root node JSON:",i)}}),s&&mE(t,s)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o){let s;n.editorState.read(()=>{if(o.getType()==="root")try{s=o.exportJSON()}catch(i){console.warn("Failed to export root node JSON for update:",i)}}),s&&bE(t,s)}break}case"destroyed":{yE(t);break}}}function xE(n,e,t,r,o){const i=Ue().getLoroNodeByLexicalKey(n,void 0,e,t);if(r){const{key:a,__key:l,lexicalKey:c,children:u,...f}=r;Se(i,"lexical",f)}return Se(i,"elementType","linebreak"),Se(i,"createdAt",Date.now()),i.id}function CE(n,e,t,r,o){const s=Ue(),{tree:i}=o,a=s.getLoroNodeByLexicalKey(n,void 0);if(!a)return;const l=a.id;if(r){const{key:c,__key:u,lexicalKey:f,children:d,...g}=r;Se(a,"lexical",g)}(e!==void 0||t!==void 0)&&Xi(i,l,e,t),Se(a,"elementType","linebreak")}function SE(n,e){Ue().deleteMapping(n)}function vE(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o&&ue(o)){const{parentId:s,index:i,lexicalNodeJSON:a}=n.editorState.read(()=>{const l=o.getParent(),c=Ue(),u=l?c.getTreeIDByLexicalKey(l.getKey()):void 0,f=o.getIndexWithinParent();let d;try{d=o.exportJSON()}catch(g){console.warn("Failed to export node JSON in propagateLineBreakNode created:",g)}return{parentId:u,index:f,lexicalNodeJSON:d}});xE(t,s,i,a)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o&&ue(o)){const{parentId:s,index:i,lexicalNodeJSON:a}=n.editorState.read(()=>{const l=o.getParent(),c=Ue(),u=l?c.getTreeIDByLexicalKey(l.getKey()):void 0,f=o.getIndexWithinParent();let d;try{d=o.exportJSON()}catch(g){console.warn("Failed to export node data in propagateLineBreakNode updated:",g)}return{parentId:u,index:f,lexicalNodeJSON:d}});CE(t,s,i,a,r)}break}case"destroyed":{SE(t);break}}}function kE(n,e,t,r,o,s,i){const l=Ue().getLoroNodeByLexicalKey(n,void 0,t,r);if(s){const{key:c,__key:u,lexicalKey:f,children:d,...g}=s;Se(l,"lexical",g)}return Se(l,"elementType",e),Se(l,"createdAt",Date.now()),l.id}function TE(n,e,t,r,o,s,i,a,l){const u=Ue().getLoroNodeByLexicalKey(n,void 0);if(a){const{key:f,__key:d,lexicalKey:g,children:h,..._}=a;Se(u,"lexical",_)}if(e!==void 0&&Se(u,"elementType",e),t!==void 0||r!==void 0){const{tree:f}=l;dt(!(t&&u.id===t),"updateElementNodeInLoro: cycle move (node is its own parent)",{nodeKey:n,treeId:u.id});const d=u.parent(),g=d?d.id:void 0,_=(d?d.children()??[]:f.roots()).findIndex(w=>w.id===u.id),m=g===t;if(!m||r!==void 0&&r!==_){const w=t?f.getNodeByID(t):null,C=w?w.children()?.length??0:f.roots().length;if(r!==void 0){let v=r;const k=m?Math.max(C-1,0):C;if(v<0||v>k){const I=w?w.children()??[]:f.roots();if(o){const E=I.findIndex(N=>N.id===o);E>=0&&(v=E+1)}if((v<0||v>k)&&s){const E=I.findIndex(N=>N.id===s);E>=0&&(v=E)}if(v<0||v>k){const E=Math.min(Math.max(v,0),k);console.warn("[loro-collab] updateElementNodeInLoro: clamping out-of-range move index",{nodeKey:n,treeId:u.id,index:r,targetIndex:v,clamped:E,maxIndex:k,sameParent:m,previousSiblingId:o,nextSiblingId:s}),v=E}}Xi(f,u.id,t,v)}else Xi(f,u.id,t,C)}}}function IE(n,e){Ue().deleteMapping(n)}function EE(n,e,t,r){const{tree:o}=r;switch(e){case"created":{const s=n.editorState._nodeMap.get(t);if(s&&q(s)){let i,a,l,c;const u={};let f;n.editorState.read(()=>{i=s.getParent();const d=Ue();a=i?d.getTreeIDByLexicalKey(i.getKey()):void 0,l=s.getIndexWithinParent(),a&&d.getTreeIDByLexicalKey(t)===a&&(a=void 0),c=s.getType(),i&&!a&&console.warn(` ElementNodePropagator: parent mapping missing for ${c} nodeKey=${t}, parentKey=${i.getKey()}`),typeof s.getFormat=="function"&&(u.format=s.getFormat()),typeof s.getStyle=="function"&&(u.style=s.getStyle()),typeof s.getDirection=="function"&&(u.direction=s.getDirection()),f=s.exportJSON()}),kE(t,c,a,l,u,f)}break}case"updated":{const s=n.editorState._nodeMap.get(t);if(s&&q(s)){let i,a,l,c,u,f;const d={};let g;n.editorState.read(()=>{i=s.getParent();const h=Ue();if(a=i?h.getTreeIDByLexicalKey(i.getKey()):void 0,l=s.getIndexWithinParent(),i){const _=i.getChildren();for(let m=l-1;m>=0;m--){const b=_[m],w=h.getTreeIDByLexicalKey(b.getKey());if(w&&qt(o,w)){c=w;break}}for(let m=l+1;m<_.length;m++){const b=_[m],w=h.getTreeIDByLexicalKey(b.getKey());if(w&&qt(o,w)){u=w;break}}}f=s.getType(),typeof s.getFormat=="function"&&(d.format=s.getFormat()),typeof s.getStyle=="function"&&(d.style=s.getStyle()),typeof s.getDirection=="function"&&(d.direction=s.getDirection()),g=s.exportJSON()}),TE(t,f,a,l,c,u,d,g,r)}break}case"destroyed":{IE(t);break}}}function gl(n,e,t,r,o,s,i,a){const l=Ue();dt(o!==void 0,"createTextNodeInLoro: text node has no parent in Loro tree",{nodeKey:n});const c=l.getLoroNodeByLexicalKey(n,void 0,o,s);if(i)try{if("key"in i||"__key"in i||"lexicalKey"in i){const{key:u,__key:f,lexicalKey:d,children:g,...h}=i;Se(c,"lexical",h)}else{const{children:u,...f}=i;Se(c,"lexical",f)}}catch(u){console.warn("Failed to store lexical node JSON for TextNode:",u)}return Se(c,"elementType","text"),Se(c,"createdAt",Date.now()),c.id}function NE(n,e,t,r,o,s){const a=Ue().getTreeIDByLexicalKey(n);if(!a||!qt(s?.tree,a))return;const l=s.tree.getNodeByID(a);if(l){if(o)if("key"in o||"__key"in o||"lexicalKey"in o){const{key:c,__key:u,lexicalKey:f,children:d,...g}=o;Se(l,"lexical",g)}else{const{children:c,...u}=o;Se(l,"lexical",u)}Se(l,"elementType","text")}}function LE(n,e){Ue().deleteMapping(n)}function OE(n,e,t,r){const{tree:o}=r;switch(e){case"created":{const s=n.editorState._nodeMap.get(t),i=Ue(),a=i.getTreeIDByLexicalKey(t);if(a&&s&&oe(s)){const{currentParentId:l,expectedParentId:c}=n.editorState.read(()=>{const u=s.getParent(),f=u?i.getTreeIDByLexicalKey(u.getKey()):void 0;let d;try{const g=o.getNodeByID(a);if(g){const h=g.parent();d=h?h.id.toString():void 0}}catch(g){console.warn(` Failed to get parent for existing TreeID ${a}:`,g)}return{currentParentId:d,expectedParentId:f}});if(l===c)return;{let u=a;try{const f=o.getNodeByID(a);f&&(u=f.id)}catch(f){console.warn(` Could not get TreeNode for ${a} during creation:`,f)}i.deleteMapping(t);try{qt(o,u)&&o.delete(u)}catch(f){console.warn(` Failed to delete TreeNode ${u} during creation:`,f)}}}if(s&&oe(s)){const{parent:l,parentId:c,index:u,textContent:f,format:d,mode:g,lexicalNodeJSON:h}=n.editorState.read(()=>{const _=s.getParent(),m=Ue(),b=_?m.getTreeIDByLexicalKey(_.getKey()):void 0,w=s.getIndexWithinParent(),C=s.getTextContent(),v=s.getFormat(),k=s.getMode();let I;try{I=s.exportJSON()}catch(E){console.warn("Failed to export node JSON in propagateTextNode created:",E)}return{parent:_,parentId:b,index:w,textContent:C,format:v,mode:k,lexicalNodeJSON:I}});gl(t,f,d,g,c,u,h)}break}case"updated":{const s=n.editorState._nodeMap.get(t);if(s&&oe(s)){const i=Ue(),a=i.getTreeIDByLexicalKey(t);if(a){const{currentParentId:d,expectedParentId:g,parent:h}=n.editorState.read(()=>{const _=s.getParent(),m=_?i.getTreeIDByLexicalKey(_.getKey()):void 0;let b;try{const w=o.getNodeByID(a);if(w){const C=w.parent();b=C?C.id.toString():void 0}}catch(w){console.warn(` Failed to get parent for existing TreeID ${a} during update:`,w)}return{currentParentId:b,expectedParentId:m,parent:_}});if(d!==g){let _=a;try{const I=o.getNodeByID(a);I&&(_=I.id)}catch(I){console.warn(` Could not get TreeNode for ${a}:`,I)}i.deleteMapping(t);try{qt(o,_)&&o.delete(_)}catch(I){console.warn(` Failed to delete TreeNode ${_} during update:`,I)}const{parentId:m,index:b,textContent:w,format:C,mode:v,lexicalNodeJSON:k}=n.editorState.read(()=>{const I=h?i.getTreeIDByLexicalKey(h.getKey()):void 0,E=s.getIndexWithinParent(),N=s.getTextContent(),O=s.getFormat(),M=s.getMode();let R;try{R=s.exportJSON()}catch($){console.warn("Failed to export node JSON during TextNode recreation:",$)}return{parentId:I,index:E,textContent:N,format:O,mode:M,lexicalNodeJSON:R}});gl(t,w,C,v,m,b,k);return}}if(!a){const{parent:d,parentId:g,index:h,textContent:_,format:m,mode:b,lexicalNodeJSON:w}=n.editorState.read(()=>{const C=s.getParent(),v=C?i.getTreeIDByLexicalKey(C.getKey()):void 0,k=s.getIndexWithinParent(),I=s.getTextContent(),E=s.getFormat(),N=s.getMode();let O;try{O=s.exportJSON()}catch(M){console.warn("Failed to export node JSON in propagateTextNode updated(create fallback):",M)}return{parent:C,parentId:v,index:k,textContent:I,format:E,mode:N,lexicalNodeJSON:O}});g!==void 0&&gl(t,_,m,b,g,h,w);return}const{textContent:l,format:c,mode:u,lexicalNodeJSON:f}=n.editorState.read(()=>{const d=s.getTextContent(),g=s.getFormat(),h=s.getMode();let _;try{_=s.exportJSON()}catch(m){console.warn("Failed to export node JSON in propagateTextNode updated:",m)}return{textContent:d,format:g,mode:h,lexicalNodeJSON:_}});NE(t,l,c,u,f,r)}break}case"destroyed":{LE(t);break}}}function RE(n,e,t,r,o,s,i,a){const c=Ue().getLoroNodeByLexicalKey(n,void 0,r,o);if(i){const{key:u,__key:f,lexicalKey:d,children:g,...h}=i;Se(c,"lexical",h)}return Se(c,"elementType","decorator"),Se(c,"createdAt",Date.now()),c.id}function AE(n,e,t,r,o,s,i,a){const c=Ue().getLoroNodeByLexicalKey(n,void 0);if(!c)return;const{tree:u}=a,f=c.id;if(i){const{key:d,__key:g,lexicalKey:h,children:_,...m}=i;Se(c,"lexical",m)}(r!==void 0||o!==void 0)&&Xi(u,f,r,o),Se(c,"elementType","decorator")}function ME(n,e){Ue().deleteMapping(n)}function $E(n,e,t,r){switch(e){case"created":{const o=n.editorState._nodeMap.get(t);if(o&&It(o)){const{parentId:s,index:i,decoratorType:a,decoratorData:l,metadata:c,lexicalNodeJSON:u}=n.editorState.read(()=>{const f=o.getParent(),d=Ue(),g=f?d.getTreeIDByLexicalKey(f.getKey()):void 0,h=o.getIndexWithinParent(),_=o.getType(),m=o.__decoratorData||{},b={};typeof o.isInline=="function"&&(b.isInline=o.isInline());let w;try{w=o.exportJSON()}catch(C){console.warn("Failed to export node data in propagateDecoratorNode created:",C)}return{parentId:g,index:h,decoratorType:_,decoratorData:m,metadata:b,lexicalNodeJSON:w}});RE(t,a,l,s,i,c,u)}break}case"updated":{const o=n.editorState._nodeMap.get(t);if(o&&It(o)){const{parentId:s,index:i,decoratorType:a,decoratorData:l,metadata:c,lexicalNodeJSON:u}=n.editorState.read(()=>{const f=o.getParent(),d=Ue(),g=f?d.getTreeIDByLexicalKey(f.getKey()):void 0,h=o.getIndexWithinParent(),_=o.getType(),m=o.__decoratorData||{},b={};typeof o.isInline=="function"&&(b.isInline=o.isInline());let w;try{w=o.exportJSON()}catch(C){console.warn("Failed to export node data in propagateDecoratorNode updated:",C)}return{parentId:g,index:h,decoratorType:_,decoratorData:m,metadata:b,lexicalNodeJSON:w}});AE(t,a,l,s,i,c,u,r)}break}case"destroyed":{ME(t);break}}}function DE(n,e,t){ak(n.nodeMapper,()=>PE(n,e,t))}function PE(n,e,t){const{prevEditorState:r,editorState:o}=t,{dirtyElements:s,dirtyLeaves:i}=t,a=s.size===0&&i.size===0?null:t.mutatedNodes??jE(t);let l=0;if(a&&a.forEach(c=>{l+=c.size}),ye("[SEED-DEBUG] syncLexicalToLoro: mutatedNodes=",a?"map":"null","totalMutations=",l,"tags=",Array.from(t.tags)),a){const c=n.tree;Wt(n.doc);const u={tree:c};let f=!1;if(a.forEach(d=>{d.size>0&&(f=!0)}),f){a.forEach((h,_)=>{so(_,Dd)&&h.forEach((m,b)=>{wE(t,m,b)})});const d=[];a.forEach((h,_)=>{let m=null;if(so(_,Dd)||(so(_,Oe)?m="element":so(_,cn)?m="text":so(_,lw)?m="linebreak":so(_,Bt)&&(m="decorator"),m===null))return;const b=m;h.forEach((w,C)=>{let v=0,k=0;o.read(()=>{const I=Q(C);if(I){k=I.getIndexWithinParent();let E=I.getParent();for(;E;)v++,E=E.getParent()}}),d.push({mutation:w,nodeKey:C,depth:v,index:k,category:b})})});const g=h=>{switch(h.category){case"element":EE(t,h.mutation,h.nodeKey,u);break;case"text":OE(t,h.mutation,h.nodeKey,u);break;case"linebreak":vE(t,h.mutation,h.nodeKey,u);break;case"decorator":$E(t,h.mutation,h.nodeKey,u);break}};d.filter(h=>h.mutation==="destroyed").sort((h,_)=>_.depth-h.depth).forEach(g),d.filter(h=>h.mutation==="created").sort((h,_)=>h.depth-_.depth||h.index-_.index).forEach(g),d.filter(h=>h.mutation==="updated").sort((h,_)=>h.depth-_.depth||h.index-_.index).forEach(g),n.doc.commit({origin:n.doc.peerIdStr})}}o.read(()=>{const c=D(),u=r._selection;Em(n,e,u,c)})}function jE(n){const{dirtyElements:e,dirtyLeaves:t,prevEditorState:r,editorState:o}=n;if(e.size===0&&t.size===0)return null;const s=r._nodeMap,i=o._nodeMap,a=new Map,l=(c,u)=>{const f=c.constructor;let d=a.get(f);d||(d=new Map,a.set(f,d)),d.set(c.getKey(),u)};return i.forEach((c,u)=>{s.has(u)?(e.has(u)||t.has(u))&&l(c,"updated"):l(c,"created")}),s.forEach((c,u)=>{i.has(u)||l(c,"destroyed")}),a}function yg(n){return n&&typeof n=="object"&&typeof n.toJSON=="function"?n.toJSON():n}function FE(n,e,t,r,o){dt(qt(e,n),"NodeFactory: TreeID not live in Loro tree",{treeId:n});const s=e.getNodeByID(n);let i=yg(o?.lexical);if(i||(i=yg(s?.data.get("lexical"))),!i||typeof i!="object"){const f=s?.data.get("elementType")||s?.data.get("nodeType");dt(typeof f=="string"&&f.length>0,"NodeFactory: no lexical data or elementType for TreeID",{treeId:n}),i={type:f,version:1}}const a=i.type||i.__type;dt(!!a,"NodeFactory: no type field in lexical data for TreeID",{treeId:n});const c=t.editor._nodes.get(a);dt(c!=null,"NodeFactory: node type is not registered in the editor",{treeId:n,nodeType:a});const u={...i};return u.type||(u.type=a),u.version===void 0&&(u.version=1),"children"in u||(u.children=[]),c.klass.importJSON(u)}class BE{integrate(e,t,r){t.editor.update(()=>{this.integrateInternal(e,t,r)})}integrateInternal(e,t,r){const o=[],s=[],i=[];for(const _ of e.diff)switch(_.action){case"delete":o.push(_);break;case"create":s.push(_);break;case"move":i.push(_);break}const a=new Map;for(const _ of i)a.set(String(_.target),_);const l=new Set;for(const _ of s)if(_.parent===void 0){const m=a.get(String(_.target));m&&m.parent!==void 0&&(_.parent=m.parent,_.index=m.index,l.add(String(_.target)))}let c=i.filter(_=>!l.has(String(_.target)));const u=new Set;for(const _ of s)qt(t.tree,_.target)||u.add(String(_.target));for(let _=!0;_;){_=!1;for(const m of s){const b=String(m.target);!u.has(b)&&m.parent!==void 0&&u.has(String(m.parent))&&(u.add(b),_=!0)}}const f=u.size===0?s:s.filter(_=>!u.has(String(_.target)));u.size>0&&(c=c.filter(_=>!u.has(String(_.target))));const d=this.topologicalSortCreates(f,t);o.forEach(_=>this.integrateDelete(_,t,r));const g=new Map;let h=d;for(;h.length>0;){const _=[];for(const m of h)this.integrateCreate(m,t,r,g)==="deferred"&&_.push(m);_.length===h.length&&dt(!1,"TreeIntegrator: create operations reference parents missing from the batch",{pending:_.map(m=>({target:String(m.target),parent:m.parent?String(m.parent):null,parentInTree:m.parent?qt(t.tree,m.parent):null,parentMapped:m.parent?t.nodeMapper.getLexicalKeyByLoroId(m.parent)??null:null})),roots:t.tree.roots().map(m=>String(m.id))}),h=_}c.forEach(_=>this.integrateMove(_,t,r))}integrateCreate(e,t,r,o){if(e.parent==null){const l=t.tree.getNodeByID(e.target),c=l?.data.get("elementType"),u=l?.data.get("lexical")?.type;if(c==="root"||u==="root"||!c){const f=se(),d=t.nodeMapper.getTreeIDByLexicalKey(f.getKey());if(d===void 0||!qt(t.tree,d)){t.nodeMapper.setMapping(f.getKey(),e.target);for(const g of f.getChildren())t.nodeMapper.hasLexicalMapping(g.getKey())||g.remove()}else d!==e.target&&t.nodeMapper.aliasLoroId(e.target,f.getKey());return"created"}}const s=t.nodeMapper.getLexicalKeyByLoroId(e.target);if(s!==null&&Q(s)!==null)return"created";const i=String(e.target);let a=o.get(i);if(a===void 0&&(a=FE(e.target,t.tree,t),o.set(i,a)),dt(a!=null,"integrateCreate: failed to materialise Lexical node from Loro data",{target:i}),e.parent){const l=t.nodeMapper.getLexicalKeyByLoroId(e.parent),c=l?Q(l):null;if(!(c&&q(c)))return"deferred";this.insertChild(c,a,e.index)}else dt(this.canBeRootChild(a),"integrateCreate: inline node has no parent (cannot live at root)",{target:i,nodeType:a.getType()}),this.insertChild(se(),a,e.index);return t.nodeMapper.setMapping(a.getKey(),e.target),"created"}canBeRootChild(e){return q(e)||It(e)}insertChild(e,t,r){r!==void 0?e.splice(r,0,[t]):e.append(t)}integrateMove(e,t,r){const o=t.nodeMapper.getLexicalKeyByLoroId(e.target);dt(o!=null,"integrateMove: no Lexical key for move target",{target:String(e.target)});const s=Q(o);dt(s!=null,"integrateMove: node to move not found",{lexicalKey:o});let i;if(e.parent){const a=t.nodeMapper.getLexicalKeyByLoroId(e.parent),l=a?Q(a):null;dt(l!=null&&q(l),"integrateMove: move target parent is not a mapped element",{target:String(e.target),parent:String(e.parent)}),i=l}else dt(this.canBeRootChild(s),"integrateMove: inline node cannot be moved to the root",{lexicalKey:o,nodeType:s.getType()}),i=se();s.remove(),s.isAttached()&&wg(s),e.index!==void 0?i.splice(e.index,0,[s]):i.append(s)}integrateDelete(e,t,r){const o=t.nodeMapper.getLexicalKeyByLoroId(e.target);if(!o)return;const s=Q(o);if(!s){t.nodeMapper.removeMappingForKey(o);return}if(s===se())return;const i=this.collectDescendantKeys(s);for(const a of i)t.nodeMapper.removeMappingForKey(a);s.remove(),s.isAttached()&&wg(s),t.nodeMapper.removeMappingForKey(o)}collectDescendantKeys(e){if(!q(e))return[];const t=[],r=[...e.getChildren()];for(;r.length>0;){const o=r.pop();t.push(o.getKey()),q(o)&&r.push(...o.getChildren())}return t}topologicalSortCreates(e,t){if(e.length<=1)return e;const r=new Set(e.map(l=>String(l.target))),o=new Map;for(const l of e)l.parent&&o.set(String(l.target),String(l.parent));const s=new Map,i=l=>{if(s.has(l))return s.get(l);let c=0,u=l;const f=new Set;for(;o.has(u);){const d=o.get(u);if(f.has(d))break;if(f.add(d),r.has(d))c++,u=d;else break}return s.set(l,c),c},a=e.map((l,c)=>({op:l,depth:i(String(l.target)),idx:c}));return a.sort((l,c)=>l.depth-c.depth||l.idx-c.idx),a.map(l=>l.op)}}function wg(n){Bt.prototype.remove.call(n,!1)}class UE{integrate(e,t,r){e.updated&&Object.entries(e.updated).forEach(([o,s])=>{this.integratePropertyUpdate(o,s,t,r)}),e.deleted&&e.deleted.forEach(o=>{this.integratePropertyDelete(o,t,r)})}integrateWithContext(e,t,r,o){this.integrateWithContextInternal(e,t,r,o)}integrateInternal(e,t,r){e.updated&&Object.entries(e.updated).forEach(([o,s])=>{this.integratePropertyUpdate(o,s,t,r)}),e.deleted&&e.deleted.forEach(o=>{this.integratePropertyDelete(o,t,r)})}integrateWithContextInternal(e,t,r,o){e.updated&&Object.entries(e.updated).forEach(([s,i])=>{this.integratePropertyUpdateWithContextInternal(s,i,t,r,o)}),e.deleted&&e.deleted.forEach(s=>{this.integratePropertyDelete(s,r,o)})}integratePropertyUpdateWithContext(e,t,r,o,s){e==="lexical"&&this.integrateLexicalDataUpdateWithContext(t,r,o)}integratePropertyUpdateWithContextInternal(e,t,r,o,s){switch(e){case"lexical":let i=r;if(typeof r=="string"&&r.startsWith("cid:")){const l=r.split(":");l.length>=3&&(i=l[1])}const a=o.nodeMapper.getLexicalKeyByLoroId(i);a&&this.integrateLexicalDataUpdateInternal(t,a,i,o);break}}integratePropertyUpdate(e,t,r,o){}integratePropertyDelete(e,t,r){}integrateLexicalDataUpdateWithContext(e,t,r){let o=t;if(typeof t=="string"&&t.startsWith("cid:")){const i=t.split(":");i.length>=3&&(o=i[1])}const s=r.nodeMapper.getLexicalKeyByLoroId(o);s&&e&&typeof e=="object"&&r.editor.update(()=>{this.integrateLexicalDataUpdateInternal(e,s,o,r)})}integrateLexicalDataUpdateInternal(e,t,r,o){let s=e;s&&typeof s=="object"&&typeof s.toJSON=="function"&&(s=s.toJSON());const i=Q(t);if(!i)return;const a=i.getType();if(zE(i,s,a))return;const l=s.__text||s.text||s.textContent;if(a==="text"&&l!==void 0){const c=i,u=c.getTextContent();u!==l&&nk(c,t,u,l),s.format!==void 0&&c.setFormat(s.format),s.style!==void 0&&c.setStyle(s.style)}else if(It(i))try{const u=o.editor._nodes.get(a);if(!u){console.warn(` MapIntegrator: Node type '${a}' not registered`);return}const f={...s};if(f.type||(f.type=a),f.version===void 0&&(f.version=1),"children"in f||(f.children=[]),u.klass.prototype.updateFromJSON!==Bt.prototype.updateFromJSON){i.getWritable().updateFromJSON(f);return}const d=u.klass.importJSON(f);i.replace(d),o.nodeMapper.removeMappingForKey(t),o.nodeMapper.setMapping(d.getKey(),r)}catch(c){console.warn(` MapIntegrator: importJSON+replace failed for decorator ${a} node ${t}:`,c)}else try{const c={...s};c.type||(c.type=a),c.version===void 0&&(c.version=1),"children"in c||(c.children=[]),i.getWritable().updateFromJSON(c)}catch(c){console.warn(` MapIntegrator: updateFromJSON failed for ${a} node ${t}:`,c)}}}function zE(n,e,t){try{const r=n.exportJSON(),o=s=>{const{key:i,__key:a,lexicalKey:l,children:c,...u}=s;return{...u,type:u.type??t,version:u.version??1}};return JSON.stringify(o(r))===JSON.stringify(o(e))}catch{return!1}}class KE{integrate(e,t,r){ye(" Handling ListDiff:",e),this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.diff&&e.diff.forEach(o=>{switch(o.type){case"insert":this.integrateInsert(o,t,r);break;case"delete":this.integrateDelete(o,t,r);break;case"retain":this.integrateRetain(o,t,r);break;default:console.warn(` Unknown list change type: ${o.type}`)}})}integrateInsert(e,t,r){}integrateDelete(e,t,r){}integrateRetain(e,t,r){e.attributes&&ye(` List retain with attributes at ${e.index}, length: ${e.length}`,e.attributes)}}class WE{integrate(e,t,r){this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.diff&&e.diff.forEach(o=>{switch(o.type){case"insert":this.integrateTextInsert(o,t,r);break;case"delete":this.integrateTextDelete(o,t,r);break;case"retain":this.integrateTextRetain(o,t,r);break;default:console.warn(` Unknown text change type: ${o.type}`)}})}integrateTextInsert(e,t,r){}integrateTextDelete(e,t,r){}integrateTextRetain(e,t,r){e.attributes&&this.applyTextFormatting({...e,attributes:e.attributes},t,r)}applyTextFormatting(e,t,r){}}class HE{integrate(e,t,r){this.integrateInternal(e,t,r)}integrateInternal(e,t,r){e.increment!==void 0&&this.integrateIncrement(e.increment,t,r),e.value!==void 0&&this.integrateSetValue(e.value,t,r)}integrateIncrement(e,t,r){}integrateSetValue(e,t,r){}updateNodeCounter(e,t,r,o,s){}}const JE=new BE,xg=new UE,qE=new KE,VE=new WE,YE=new HE;function XE(n,e,t,r,o=Im){const s=n.editor,i=s._editorState;n.editor.update(()=>{D()&&Ee(null),t.events.forEach((c,u)=>{try{switch(c.diff.type){case"tree":JE.integrateInternal(c.diff,n,e);break;case"map":c.target?xg.integrateWithContextInternal(c.diff,c.target,n,e):xg.integrateInternal(c.diff,n,e);break;case"list":qE.integrateInternal(c.diff,n,e);break;case"text":VE.integrateInternal(c.diff,n,e);break;case"counter":YE.integrateInternal(c.diff,n,e);break;default:throw new Error(`Unsupported event diff type: ${c.diff.type}. Supported types are: 'tree', 'map', 'list', 'text', 'counter'.`)}}catch(f){console.error("[loro-collab] syncLoroToLexical: integrator threw for event",u,"diffType=",c.diff?.type,"target=",String(c?.target),"diff=",JSON.stringify(c.diff),f)}});const l=D();if(F(l))if(ng(l)){const c=i._selection;if(F(c)&&(ig(n,e),ng(l))){const u=l.anchor.key;Cm(u,i)}Em(n,e,c,D())}else ig(n,e);Ai($l)},{onUpdate:()=>{o(n,e),queueMicrotask(()=>{s.update(()=>{se().getChildrenSize()===0&&se().append(ne())})})},skipTransforms:!0,tag:ca})}function GE(n,e,t,r,o,s,i,a,l,c,u,f,d=Im,g){const h=S.useRef(!1),_=S.useCallback(()=>t.connect(),[t]),m=S.useCallback(()=>{try{t.disconnect()}catch{}},[t]);S.useEffect(()=>{const{awareness:w}=t,C=({status:A})=>{n.dispatchCommand(fE,A==="connected")};let v=!1;const k=A=>{A&&!v&&(v=!0,eN(n,a,u)),ye("[SEED-DEBUG] onSync: isSynced=",A,"shouldBootstrap=",i,"isReloadingDoc=",h.current),i&&A&&h.current===!1&&(tN(n,u),g&&g(!0)),h.current=!1},I=()=>{d(a,t)};hE(t,o,s,document.activeElement===n.getRootElement(),f||{});const E=A=>{nN(n,a),l(A),r.set(e,A),h.current=!0};t.on("reload",E),t.on("status",C),t.on("sync",k),w.on("update",I);const N=A=>{A.origin!==a.doc.peerIdStr&&XE(a,t,A,!1,d)},O=a.doc.subscribe(N),M=[],R=n._nodes;ye("[SEED-DEBUG] registering mutation listeners; registeredNodes=",R?R.size:"undefined"),R&&R.forEach(A=>{A&&A.klass&&M.push(n.registerMutationListener(A.klass,()=>{},{skipInitialization:!0}))}),ye("[SEED-DEBUG] mutation listeners registered=",M.length,"editor._listeners.mutation.size=",n._listeners?.mutation?.size);const $=n.registerUpdateListener(A=>{let B=0;A.mutatedNodes&&A.mutatedNodes.forEach(j=>{B+=j.size}),ye("[SEED-DEBUG] updateListener fired; tags=",Array.from(A.tags),"mutatedNodes=",A.mutatedNodes?"map":"null","count=",B,"dirtyElements=",A.dirtyElements?.size,"dirtyLeaves=",A.dirtyLeaves?.size),v&&A.tags.has(ca)===!1&&DE(a,t,A)}),L=_();return()=>{h.current===!1&&(L?L.then(m):m()),t.off("sync",k),t.off("status",C),t.off("reload",E),w.off("update",I),O?.(),r.delete(e),$(),M.forEach(A=>A())}},[a,s,_,m,r,n,e,u,o,t,i,f,l,d,g]);const b=S.useMemo(()=>{const w=C=>{a.cursorsContainer=C};return St.createPortal(x.jsx("div",{ref:w,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",pointerEvents:"none",zIndex:1e3,overflow:"visible"}}),c&&c.current||document.body)},[a,c]);return S.useEffect(()=>n.registerCommand(gE,w=>(w?_():m(),!0),V),[_,m,n]),b}function ZE(n,e,t,r,o){S.useEffect(()=>de(n.registerCommand(oh,()=>(bg(e,t,r,!0,o||{}),!1),V),n.registerCommand(cw,()=>(bg(e,t,r,!1,o||{}),!1),V)),[r,n,t,e,o])}function QE(n,e){const t=S.useMemo(()=>pE(e),[e]);S.useEffect(()=>{const o=()=>{t.undo()},s=()=>{t.redo()};return de(n.registerCommand(ph,()=>(o(),!0),V),n.registerCommand(gh,()=>(s(),!0),V))});const r=S.useCallback(()=>{t.clear()},[t]);return S.useEffect(()=>(n.dispatchCommand(hh,t.canUndo()),n.dispatchCommand(_h,t.canRedo()),()=>{}),[n,t]),r}function eN(n,e,t){n.update(()=>{const r=se();for(const o of r.getChildren())e.nodeMapper.hasLexicalMapping(o.getKey())||o.remove();r.isEmpty()&&!t&&r.append(ne())},{discrete:!0,tag:ca})}function tN(n,e){const t=new Set(["Lexical with Loro","Welcome to Lexical with Loro","Type something..."]),r=()=>{const i=se().getChildren();if(i.length===0)return!1;for(const a of i){const l=a.getType(),c=a.getTextContent().trim();if(c.length>0){if(!t.has(c))return!0;continue}if(l!=="paragraph"&&l!=="jupyter-output")return!0}return!1};let o=!1;if(n.getEditorState().read(()=>{o=!r()}),ye("[SEED-DEBUG] initializeEditor: shouldSeed=",o,"hasInitialState=",!!e,"type=",typeof e),!(!o||!e)){if(typeof e=="string"){let s=[];try{s=JSON.parse(e)?.root?.children??[]}catch{n.update(()=>{n.setEditorState(n.parseEditorState(e),{tag:$n})},{tag:$n});return}n.update(()=>{},{tag:$n,discrete:!0}),n.update(()=>{Ee(null)},{tag:$n,discrete:!0});let i=[];n.getEditorState().read(()=>{i=se().getChildren().map(l=>l.getKey())}),ye("[SEED-DEBUG] initializeEditor: seeding",s.length,"blocks, removing",i.length,"scaffold blocks first");for(const l of i)n.update(()=>{const c=Q(l);c&&c.remove()},{tag:$n,discrete:!0});let a=0;for(const l of s){const c=a++,u=l?.type,f=Array.isArray(l?.children)?l.children.map(d=>d?.type):[];n.update(()=>{se().append(uw(l))},{tag:$n,discrete:!0}),ye("[SEED-DEBUG] appended block",c,"type=",u,"children=",f)}return}n.update(()=>{r()||(typeof e=="object"?n.setEditorState(e,{tag:$n}):typeof e=="function"&&e(n))},{tag:$n})}}function nN(n,e){if(n.update(()=>{const s=se();s.clear(),s.select()},{tag:ca}),e.cursors==null)return;const t=e.cursors;if(t==null)return;const r=e.cursorsContainer;if(r==null)return;const o=Array.from(t.values());for(let s=0;s<o.length;s++){const a=o[s].selection;if(a&&a.selections!=null){const l=a.selections;for(let c=0;c<l.length;c++)r.removeChild(l[s])}}}function Cg(n,e){if(!n||typeof n!="object")return;const t=n,r=t.user,o=r&&typeof r=="object"?r:void 0;for(const s of e){const i=t[s];if(typeof i=="string"&&i.trim().length>0)return i;if(o){const a=o[s];if(typeof a=="string"&&a.trim().length>0)return a}}}function WM({id:n,providerFactory:e,shouldBootstrap:t,username:r,cursorColor:o,cursorsContainerRef:s,initialEditorState:i,excludedProperties:a,awarenessData:l,syncCursorPositionsFn:c,showCollaborators:u=!0,websocketUrl:f="ws://localhost:3002",onInitialization:d,onIdentityResolved:g,onCollaboratorsChange:h}){const _=S.useRef(!1),m=S.useRef(!1),b=Lm(r,o),w=qw(),C=S.useRef(w);C.current=w;const{docMap:v,name:k,color:I}=b,[E]=fe();S.useEffect(()=>(b.isCollabActive=!0,()=>{E._parentEditor==null&&(b.isCollabActive=!1)}),[b,E]);const[N,O]=S.useState(),[M,R]=S.useState();S.useEffect(()=>{if(m.current)return;m.current=!0;const A=e(n,v,f);return O(A),R(v.get(n)),()=>{A.disconnect()}},[n,e,v,f]);const[$,L]=S.useState();return S.useEffect(()=>{if(!N||_.current)return;_.current=!0;const A=uk(E,N,n,M||v.get(n),v,a),B=Nm(A.clientID),j=Cg(l,["display_name","displayName","name","username","handle"]),U=Cg(l,["color"]),z=r||j||B.name,K=C.current[Vw(z)%C.current.length],H=o||U||K;return b.name=z,b.color=H,b.clientID=A.clientID,g?.({name:z,color:H,clientID:A.clientID}),_E(N,z,H),L(A),()=>{}},[E,N,n,v,M,a,b,r,o,l]),!N||!$?x.jsx(x.Fragment,{}):x.jsx(rN,{awarenessData:l,binding:$,collabContext:b,color:I,cursorsContainerRef:s,editor:E,id:n,initialEditorState:i,name:k,provider:N,setDoc:R,shouldBootstrap:t,docMap:v,syncCursorPositionsFn:c,showCollaborators:u,onInitialization:d,onCollaboratorsChange:h})}function rN({editor:n,id:e,provider:t,docMap:r,name:o,color:s,shouldBootstrap:i,cursorsContainerRef:a,initialEditorState:l,awarenessData:c,collabContext:u,binding:f,setDoc:d,syncCursorPositionsFn:g,showCollaborators:h=!1,onInitialization:_,onCollaboratorsChange:m}){const b=GE(n,e,t,r,o,s,i,f,d,a,l,c,g,_);return u.clientID=f.clientID,QE(n,f),ZE(n,t,o,s,c),S.useEffect(()=>{if(!m)return;const{awareness:w}=t,C=()=>m(bk(w.getStates(),f.clientID));return C(),w.on("update",C),()=>{w.off("update",C)}},[f,m,t]),h?x.jsx(ck,{binding:f,cursorsContainer:b,currentUserName:o,currentUserColor:s,showCollaborators:!0}):b}const Sg=30*1e3,oN="update",sN="ephemeral",iN="query-ephemeral";class aN{ephemeralStore;localClientId;eventHandlers=new Map;constructor(e,t){this.ephemeralStore=e,this.localClientId=t?Wt(t):ek(),ye(" AwarenessAdapter created:",{localClientId:this.localClientId,docPeerId:t?t.peerId:"no-doc",existingStatesCount:Object.keys(e.getAllStates()).length}),this.ephemeralStore.subscribe(r=>{(this.eventHandlers.get("update")||[]).forEach(s=>s())})}getLocalState(){const e=this.localClientId.toString();try{const t=this.ephemeralStore.get(e);return t||null}catch(t){throw console.warn("[Client] AwarenessAdapter.getLocalState() - ephemeralStore.get() FAILED:",{error:t.message,stack:t.stack,localKey:e,peerId:this.localClientId,storeExists:!!this.ephemeralStore}),t}}getStates(){const e=new Map;try{const t=this.ephemeralStore.getAllStates();Math.random()<.001&&this.cleanupStaleStates(t);for(const[r,o]of Object.entries(t)){const s=parseInt(r,10);!isNaN(s)&&o&&e.set(s,o)}}catch(t){console.warn("[Client] AwarenessAdapter.getStates() - ERROR:",t.message);const r=this.getLocalState();r&&e.set(this.localClientId,r)}return e}cleanupStaleStates(e){const t=Date.now(),r=300*1e3;try{for(const[o,s]of Object.entries(e)){const i=parseInt(o,10);if(!isNaN(i)&&s&&typeof s=="object"){const a=s,l=typeof a.lastActivity=="number"?a.lastActivity:0;typeof l=="number"&&t-l>r&&(ye("Cleaning up stale user state:",o,"last activity:",new Date(l).toISOString()),this.ephemeralStore.delete(o))}}}catch(o){console.warn("Error during stale state cleanup:",o.message)}}setLocalState(e){const t=this.localClientId.toString(),r={...e,lastActivity:Date.now()};try{this.ephemeralStore.set(t,r)}catch(o){throw console.warn("[Client] AwarenessAdapter.setLocalState() - ephemeralStore.set() FAILED:",{error:o.message,stack:o.stack,localKey:t,peerId:this.localClientId,stateKeys:Object.keys(e||{}),storeExists:!!this.ephemeralStore}),o}}setLocalStateField(e,t){const r=this.getLocalState()||{anchorPos:null,awarenessData:{},color:"#000000",focusPos:null,focusing:!1,name:"Anonymous"};r[e]=t,this.setLocalState(r)}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,[]),this.eventHandlers.get(e).push(t)}off(e,t){const r=this.eventHandlers.get(e);if(r){const o=r.indexOf(t);o!==-1&&r.splice(o,1)}}forceCleanupStaleStates(){try{const e=this.ephemeralStore.getAllStates();ye("Force cleanup - total keys before:",Object.keys(e).length),this.cleanupStaleStates(e);const t=this.ephemeralStore.getAllStates();ye("Force cleanup - total keys after:",Object.keys(t).length)}catch(e){console.warn("Force cleanup failed:",e.message)}}}const Ms={};Ms[iN]=(n,e,t)=>{try{const r=n.ephemeralStore.encodeAll(),o={type:"ephemeral",ephemeral:Array.from(r),docId:e.docId};return JSON.stringify(o)}catch(r){return console.warn("Error in messageQueryEphemeral integrater:",r.message),null}};Ms[sN]=(n,e,t)=>{try{if(!e.ephemeral||e.ephemeral.length===0)return console.warn("[Client] messageHandlers[messageEphemeral] - Skipping empty ephemeral data"),null;if(e.ephemeral.length<8)return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting suspiciously small ephemeral data:",e.ephemeral.length),null;if(e.ephemeral.length===1)return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting single-byte ephemeral data (likely corrupted):",e.ephemeral),null;const r=e.ephemeral.slice(0,4);if(r.every(s=>s===0)||r.every(s=>s===255))return console.warn("[Client] messageHandlers[messageEphemeral] - Rejecting ephemeral data with suspicious pattern:",r),null;const o=new Uint8Array(e.ephemeral);try{n.ephemeralStore.apply(o)}catch(s){if(console.warn("[Client] messageHandlers[messageEphemeral] - WASM apply() failed:",{error:s.message,ephemeralLength:o.length,ephemeralSample:Array.from(o.slice(0,20))}),s.message&&s.message.includes("memory access out of bounds"))return console.warn("[Client] messageHandlers[messageEphemeral] - CRITICAL: WASM memory corruption in apply(). Stopping ephemeral processing."),null;throw s}return null}catch(r){return console.warn("[Client] messageHandlers[messageEphemeral] - ERROR in ephemeral message integrater:",{error:r.message,stack:r.stack,messageLength:e.ephemeral?.length,ephemeralSample:e.ephemeral?.slice(0,10)}),null}};Ms[oN]=(n,e,t)=>{try{const r=new Uint8Array(e.update),o=n.doc.import(r),s=n.doc.version();return ye("[SEED-DEBUG] messageUpdate: imported",r.length,"bytes; importStatus=",JSON.stringify(o)),n._lastExportedVersion=s,t&&n.snapshotLoaded&&!n._synced&&(n.synced=!0),null}catch(r){return console.warn(" [LORO-UPDATE-ERROR] Failed to apply Loro update:",r),null}};const $m=(n,e,t)=>{if(e instanceof ArrayBuffer)try{const r=new Uint8Array(e),o=fc(r,!1).partialEndVersionVector;n.doc.import(r),n.snapshotLoaded=!0;const s=n.doc.export({mode:"update",from:o});if(fc(s,!1).changeNum>0&&n.ws){const i={type:"update",update:Array.from(s),docId:n.docId};zn(n.ws,i)}return t&&!n._synced&&(n.synced=!0),null}catch(r){return console.warn("Failed to process binary Loro update:",r),null}else if(typeof e=="string")try{const r=JSON.parse(e),o=Ms[r.type];return o?o(n,r,t):(console.warn("Unknown message type:",r.type),null)}catch(r){return console.warn("Failed to process JSON message:",r),null}else if(typeof e=="object"&&e!==null)try{const r=e,o=Ms[r.type];return o?o(n,r,t):(console.warn("Unknown message type:",r.type),null)}catch(r){return console.warn("Failed to process object message:",r),null}return console.warn("Unknown message format:",typeof e),null},pc=(n,e,t)=>{if(e===n.ws){if(n.emit("connection-close",[t,n]),n.ws=null,e.close(),n.wsconnecting=!1,n.wsconnected){n.wsconnected=!1,n.synced=!1,n.ephemeralStore.delete("presence"),n.ephemeralStore.delete("cursor");try{const o=Wt(n.doc).toString();n.ephemeralStore.delete(o),ye("Disconnect cleanup: removed user key:",o)}catch(r){console.warn("Disconnect cleanup failed:",r.message)}n.emit("status",[{status:"disconnected"}])}else n.wsUnsuccessfulReconnects++;setTimeout(Dm,fw(gw(2,n.wsUnsuccessfulReconnects)*100,n.maxBackoffTime),n)}},zn=(n,e)=>{if(n&&n.readyState===n.OPEN)try{const t=JSON.stringify(e);n.send(t)}catch(t){console.warn("Failed to send message over WebSocket:",t)}else console.warn("WebSocket not open, cannot send message")},Dm=n=>{if(n.shouldConnect&&n.ws===null){const e=new n._WS(n.url,n.protocols);e.binaryType="arraybuffer",n.ws=e,n.wsconnecting=!0,n.wsconnected=!1,n.synced=!1,e.onmessage=t=>{n.wsLastMessageReceived=Dl(),$m(n,t.data,!0)},e.onerror=t=>{n.emit("connection-error",[t,n])},e.onclose=t=>{n.snapshotLoaded=!1,pc(n,e,t)},e.onopen=()=>{if(n.wsLastMessageReceived=Dl(),n.wsconnecting=!1,n.wsconnected=!0,n.wsUnsuccessfulReconnects=0,n.emit("status",[{status:"connected"}]),ye(" WebSocket connection established, requesting initial data"),n.snapshotLoaded)ye(" Snapshot already loaded, skipping request");else{const s=Math.random().toString(36).substr(2,9),i=Wt(n.doc).toString(),a={type:"query-snapshot",docId:n.docId,clientId:i};ye(` Requesting initial snapshot from server (ID: ${s}, clientId: ${i}):`,a),ye(` Provider instance ID: ${n.wsServerUrl}/${n.docId}, snapshotLoaded: ${n.snapshotLoaded}`),zn(e,a)}const t=Wt(n.doc).toString(),r={type:"query-ephemeral",docId:n.docId,clientId:t};zn(e,r);const o=n.ephemeralStore.getAllStates();if(Object.keys(o).length>0)try{const s=n.ephemeralStore.encodeAll(),i={type:"ephemeral",ephemeral:Array.from(s),docId:n.docId};zn(e,i)}catch(s){console.warn("[Client] setupWS - MAJOR ERROR in ephemeral process:",{error:s.message,stack:s.stack,localStateKeys:Object.keys(o),storeExists:!!n.ephemeralStore})}if(n._pendingUpdates.length>0){const s=n._pendingUpdates;n._pendingUpdates=[],ye("[SEED-DEBUG] ws.onopen: flushing",s.length,"buffered local updates");for(const i of s)zn(e,{type:"update",update:Array.from(i),docId:n.docId})}},n.emit("status",[{status:"connecting"}])}},vg=(n,e)=>{const t=n.ws;n.wsconnected&&t&&t.readyState===t.OPEN?zn(t,e):ye(" [BROADCAST] WebSocket not ready for sending"),n.bcconnected?is(n.bcChannel,JSON.stringify(e),n):ye(" [BROADCAST] BroadcastChannel not connected")};class gr extends dw{static globalEphemeralStore=null;wsServerUrl="";docId="";doc=null;_WS=null;protocols=[];params={};ephemeralStore=null;awareness=null;ws=null;wsconnected=!1;wsconnecting=!1;bcconnected=!1;disableBc=!1;bcChannel="";maxBackoffTime=2500;wsUnsuccessfulReconnects=0;messageHandlers=[];_synced=!1;wsLastMessageReceived=0;shouldConnect=!1;snapshotLoaded=!1;_checkInterval=null;_resyncInterval=null;_updateHandler=null;_ephemeralUpdateIntegrator=null;_exitIntegrator=null;_bcSubscriber=null;_lastExportedVersion=null;_pendingUpdates=[];constructor(e,t,r,{connect:o=!0,ephemeralStore:s=void 0,params:i={},protocols:a=[],WebSocketPolyfill:l=WebSocket,resyncInterval:c=-1,maxBackoffTime:u=2500,disableBc:f=!1}={}){for(super();e[e.length-1]==="/";)e=e.slice(0,e.length-1);this.wsServerUrl=e,this.bcChannel=e+"/"+t,this.maxBackoffTime=u,this.params=i,this.protocols=a,this.docId=t,this.doc=r,this._WS=l;try{if(s)this.ephemeralStore=s;else{if(!gr.globalEphemeralStore)gr.globalEphemeralStore=new uE(3e5),ye("🆕 Created new global EphemeralStore");else{ye(" Reusing existing global EphemeralStore - cleaning up stale user states");const d=gr.globalEphemeralStore.getAllStates();Object.keys(d).forEach(g=>{const h=parseInt(g,10);isNaN(h)||(gr.globalEphemeralStore.delete(g),ye(" Cleaned up stale user state:",g))})}this.ephemeralStore=gr.globalEphemeralStore}}catch(d){throw console.warn("[Client] WebsocketProvider constructor - ERROR setting up EphemeralStore:",{error:d.message,stack:d.stack,docId:t}),d}this.awareness=new aN(this.ephemeralStore,this.doc),this.wsconnected=!1,this.wsconnecting=!1,this.bcconnected=!1,this.disableBc=f,this.wsUnsuccessfulReconnects=0,this._synced=!1,this.ws=null,this.wsLastMessageReceived=0,this.shouldConnect=o,this._resyncInterval=0,c>0&&(this._resyncInterval=setInterval(()=>{if(this.ws&&this.ws.readyState===WebSocket.OPEN){const d=Wt(this.doc).toString(),g={type:"query-ephemeral",docId:this.docId,clientId:d};zn(this.ws,g)}},c)),this._bcSubscriber=(d,g)=>{if(g!==this){const h=$m(this,d,!1);h&&is(this.bcChannel,h,this)}},this._updateHandler=d=>{const g={type:"update",update:Array.from(d),docId:this.docId},h=this.ws;this.wsconnected&&h&&h.readyState===h.OPEN?(ye("[SEED-DEBUG] _updateHandler: sending local update over WS",d.length,"bytes"),zn(h,g)):(ye("[SEED-DEBUG] _updateHandler: WS not ready, buffering local update",d.length,"bytes (pending now",this._pendingUpdates.length+1,")"),this._pendingUpdates.push(d)),this.bcconnected&&is(this.bcChannel,JSON.stringify(g),this)},this._ephemeralUpdateIntegrator=d=>{if(d.added.length>0||d.updated.length>0||d.removed.length>0)try{const g=this.ephemeralStore.encodeAll(),h={type:"ephemeral",ephemeral:Array.from(g),docId:this.docId};vg(this,h)}catch(g){console.warn("[Client] _ephemeralUpdateIntegrator - ERROR:",g.message)}},this._exitIntegrator=()=>{if(this.ephemeralStore&&this.awareness)try{const g=Wt(this.doc).toString();this.ephemeralStore.delete(g)}catch(d){console.warn("[Client] Process exit - Could not clear user state:",d.message)}},Pd&&typeof process<"u"&&process.on("exit",this._exitIntegrator),this.ephemeralStore.subscribe(this._ephemeralUpdateIntegrator),this._lastExportedVersion=this.doc.version();try{this.doc.subscribeLocalUpdates(d=>{try{this._updateHandler(d)}catch(g){console.warn("[WEBSOCKET-PROVIDER] Error exporting incremental update:",g)}})}catch(d){console.warn("[Client] ERROR setting up Loro document subscription:",d)}this._checkInterval=setInterval(()=>{this.wsconnected&&Sg<Dl()-this.wsLastMessageReceived&&pc(this,this.ws,null)},Sg/10),o&&this.connect()}get url(){const e=Yw(this.params);return this.wsServerUrl+"/"+this.docId+(e.length===0?"":"?"+e)}get synced(){return this._synced}set synced(e){this._synced!==e&&(this._synced=e,super.emit("synced",[e]),super.emit("sync",[e]))}destroy(){if(this._resyncInterval!==0&&clearInterval(this._resyncInterval),clearInterval(this._checkInterval),this.disconnect(),Pd&&typeof process<"u"&&process.off("exit",this._exitIntegrator),this.ephemeralStore&&this.awareness)try{const t=Wt(this.doc).toString();this.ephemeralStore.delete(t)}catch(e){console.warn("[Client] WebsocketProvider.destroy - Could not clear user state:",e.message)}super.destroy()}connectBc(){if(this.disableBc)return;this.bcconnected||(Xw(this.bcChannel,this._bcSubscriber),this.bcconnected=!0);const e=Wt(this.doc).toString(),t={type:"query-ephemeral",docId:this.docId,clientId:e};is(this.bcChannel,JSON.stringify(t),this);const r=this.ephemeralStore.getAllStates();if(Object.keys(r).length>0)try{const o=this.ephemeralStore.encodeAll(),s={type:"ephemeral",ephemeral:Array.from(o),docId:this.docId};is(this.bcChannel,JSON.stringify(s),this)}catch(o){console.warn("Error broadcasting ephemeral state in connectBc:",o.message)}}disconnectBc(){this.ephemeralStore.delete("presence"),this.ephemeralStore.delete("cursor");try{const t=Wt(this.doc).toString();this.ephemeralStore.delete(t),ye("Broadcast disconnect cleanup: removed user key:",t)}catch(e){console.warn("Broadcast disconnect cleanup failed:",e.message)}try{const e=this.ephemeralStore.encodeAll(),t={type:"ephemeral",ephemeral:Array.from(e),docId:this.docId};vg(this,t)}catch(e){console.warn("Error broadcasting disconnect in disconnectBc:",e.message)}this.bcconnected&&(Gw(this.bcChannel,this._bcSubscriber),this.bcconnected=!1)}disconnect(){this.shouldConnect=!1,this.disconnectBc(),this.ws!==null&&pc(this,this.ws,null)}connect(){this.shouldConnect=!0,!this.wsconnected&&this.ws===null&&(Dm(this),this.connectBc())}sendUpdate(e){this._updateHandler(e,null)}cleanupStaleStates(){this.awareness&&typeof this.awareness.forceCleanupStaleStates=="function"?this.awareness.forceCleanupStaleStates():console.warn("Cleanup method not available on awareness provider")}}const lN=new URL(window.location.href),cN=new URLSearchParams(lN.search),kg=parseInt(cN.get("resyncInterval")||"30000",10);function HM(n,e,t){let r=e.get(n);r===void 0&&(r=new sn,e.set(n,r));const o=Math.random().toString(36).substr(2,9);ye(` Creating WebsocketProvider instance (ID: ${o}) for docId: ${n}`);let i=t||(()=>{const u=new URL(window.location.href);return new URLSearchParams(u.search).get("collabEndpoint")||"ws://localhost:3002"})();const a={},l=i.indexOf("?");if(l!==-1){const u=i.slice(l+1);i=i.slice(0,l),new URLSearchParams(u).forEach((f,d)=>{a[d]=f})}const c=new gr(i,n,r,{connect:!1,params:a,resyncInterval:kg});return ye(` WebsocketProvider created for: ${i}/${n} with resyncInterval: ${kg}ms`),c}const uN=qn?S.useLayoutEffect:S.useEffect;class dN{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Tg=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function Ig(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}const Eg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function fN({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,x.jsx("span",{className:"text",children:o.title})]},o.key)}function gN({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(fN,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),uN(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Eg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Tg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Eg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Tg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Ng(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function pN(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Ng(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return(function(f,d,g,h){const[_]=fe();S.useEffect(()=>{if(d!=null&&f!=null){const m=_.getRootElement(),b=m!=null?bh(m,!1):document.body;let w=!1,C=Ig(d,b);const v=function(){w||(window.requestAnimationFrame(function(){g(),w=!1}),w=!0);const E=Ig(d,b);E!==C&&(C=E,h?.(E))},k=new ResizeObserver(g),I=yh(m??d);return k.observe(d),de(Jt(window,"resize",g),Jt(document,"scroll",v,{capture:!0,passive:!0}),...I.map(E=>Jt(E,"scroll",v,{capture:!0,passive:!0})),()=>k.unobserve(d))}},[d,_,h,g,f])})(n,l.current,c,u),a!=null&&a===l.current&&(Ng(a,t),i?.append(a)),l}function hN({options:n,nodeKey:e,onClose:t,onOpen:r,onSelectOption:o,menuRenderFn:s,anchorClassName:i,commandPriority:a=ee,parent:l}){const[c]=fe(),[u,f]=S.useState(null),d=pN(u,f,i,l),g=S.useCallback(()=>{f(null),t!=null&&u!==null&&t()},[t,u]),h=S.useCallback(m=>{f(m),r!=null&&u===null&&r(m)},[r,u]),_=S.useCallback(()=>{e?c.update(()=>{const m=Q(e),b=c.getElementByKey(e);m!=null&&b!=null&&u==null&&S.startTransition(()=>h({getRect:()=>b.getBoundingClientRect()}))}):e==null&&u!=null&&g()},[g,c,e,h,u]);return S.useEffect(()=>{_()},[_,e]),S.useEffect(()=>{if(e!=null)return c.registerUpdateListener(({dirtyElements:m})=>{m.get(e)&&_()})},[c,_,e]),d.current===null||u===null||c===null?null:x.jsx(gN,{close:g,resolution:u,editor:c,anchorElementRef:d,options:n,menuRenderFn:s,onSelectOption:o,commandPriority:a})}const _N=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,Ju=he("INSERT_EMBED_COMMAND");let Lg=class extends dN{title;onSelect;constructor(e,t){super(e),this.title=e,this.onSelect=t.onSelect.bind(this)}};function mN({embedConfigs:n,onOpenEmbedModalForConfig:e,getMenuOptions:t,menuRenderFn:r,menuCommandPriority:o=ee}){const[s]=fe(),[i,a]=S.useState(null),[l,c]=S.useState(null),u=S.useCallback(()=>{a(null),c(null)},[]),f=S.useCallback(async _=>{const m=s.read("latest",function(){const b=Q(_);if(Pe(b))return b.getURL()});if(m!==void 0)for(const b of n)await Promise.resolve(b.parseUrl(m))!=null&&(c(b),a(_))},[s,n]);S.useEffect(()=>de(...[gn,fa].map(_=>s.registerMutationListener(_,(...m)=>((b,{updateTags:w,dirtyLeaves:C})=>{for(const[v,k]of b)k==="created"&&w.has(Up)&&C.size<=3?f(v):v===i&&u()})(...m),{skipInitialization:!0}))),[f,s,i,u]),S.useEffect(()=>{if(e)return s.registerCommand(Ju,_=>{const m=n.find(({type:b})=>b===_);return!!m&&(e(m),!0)},V)},[s,n,e]);const d=S.useCallback(async function(){if(l!=null&&i!=null){const _=s.read("latest",()=>{const m=Q(i);return Pe(m)?m:null});if(Pe(_)){const m=await Promise.resolve(l.parseUrl(_.__url));m!=null&&s.update(()=>{D()||_.selectEnd(),l.insertNode(s,m),_.isAttached()&&_.remove()})}}},[l,s,i]),g=S.useMemo(()=>l!=null&&i!=null?t(l,d,u):[],[l,d,t,i,u]),h=S.useCallback((_,m,b)=>{s.update(()=>{_.onSelect(m),b()})},[s]);return i!=null?x.jsx(hN,{nodeKey:i,onClose:u,onSelectOption:h,options:g,menuRenderFn:r,commandPriority:o}):null}const Xo=()=>{const[n,e]=S.useState(null),t=S.useCallback(()=>{e(null)},[]),r=S.useMemo(()=>{if(n===null)return null;const{title:s,content:i,closeOnClickOutside:a}=n;return x.jsx(Yx,{onClose:t,title:s,closeOnClickOutside:a,children:i})},[n,t]),o=S.useCallback((s,i,a=!1)=>{e({closeOnClickOutside:a,content:i(t),title:s})},[t]);return[r,o]},Pm=he();function bN(n){if(!n.hasNodes([qo]))throw new Error("YouTubePlugin: YouTubeNode not registered on editor");return n.registerCommand(Pm,e=>{const t=K_(e);return sr(t),!0},V)}const jm=pe({name:"@datalayer/jupyter-lexical/YouTube",nodes:()=>[qo],register:bN}),ka=he("INSERT_LOOM_COMMAND");function yN(n){if(!n.hasNodes([Vo]))throw new Error("LoomExtension: LoomNode not registered on editor");return n.registerCommand(ka,e=>(sr($u(e)),!0),V)}const Fm=pe({name:Q_,config:tr({publicAppId:void 0}),nodes:()=>[Vo],register:yN}),wN={contentName:"Youtube Video",exampleUrl:"https://www.youtube.com/watch?v=jNQXAC9IVRw",icon:x.jsx(Ws,{size:16}),insertNode:(n,e)=>{n.dispatchCommand(Pm,e.id)},keywords:["youtube","video"],parseUrl:async n=>{const e=/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|&v=)([^#&?]*).*/.exec(n),t=e&&e?.[2].length===11?e[2]:null;return t!=null?{id:t,url:n}:null},type:"youtube-video"},xN={contentName:"Loom Video",exampleUrl:"https://www.loom.com/share/c2b5b05f548d4f1492d5c107f0c48dbc",icon:x.jsx(Ws,{size:16}),insertNode:(n,e)=>{tm(e.url).then(t=>n.dispatchCommand(ka,t))},keywords:["loom","video","recording","screen"],parseUrl:async n=>{const e=kn(n);return e?{id:e,url:Mu(e)}:null},type:"loom-video"},qu=[wN,xN];function CN({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(i=>o.setRefElement(i),[o]);return x.jsx(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,sx:{p:2,cursor:"pointer",bg:e?"actionListItem.default.selectedBg":"transparent","&:hover":{bg:"actionListItem.default.hoverBg"},borderRadius:1},children:x.jsx(Le,{sx:{fontSize:1},children:o.title})},o.key)}function SN({options:n,selectedItemIndex:e,onOptionClick:t,onOptionMouseEnter:r}){return x.jsx(Y,{sx:{bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1},children:x.jsx("ul",{style:{listStyle:"none",margin:0,padding:0},children:n.map((o,s)=>x.jsx(CN,{index:s,isSelected:e===s,onClick:()=>t(o,s),onMouseEnter:()=>r(s),option:o},o.key))})})}const vN=(n,e)=>{let t;return r=>{window.clearTimeout(t),t=window.setTimeout(()=>{n(r)},e)}};function kN({embedConfig:n,onClose:e}){const[t,r]=S.useState(""),[o]=fe(),[s,i]=S.useState(null),a=S.useMemo(()=>vN(u=>{const f=_N.exec(u);n!=null&&u!=null&&f!=null?Promise.resolve(n.parseUrl(u)).then(d=>{i(d)}):s!=null&&i(null)},200),[n,s]),l=()=>{s!=null&&(n.insertNode(o,s),e())},c=S.useRef(null);return S.useEffect(()=>{c.current?.focus()},[]),x.jsxs("div",{children:[x.jsx(vn,{ref:c,type:"text",placeholder:n.exampleUrl,value:t,"data-test-id":`${n.type}-embed-modal-url`,onChange:u=>{const{value:f}=u.target;r(f),a(f)},block:!0}),x.jsx(xu,{children:x.jsx(xr,{disabled:!s,onClick:l,"data-test-id":`${n.type}-embed-modal-submit-btn`,children:"Embed"})})]})}const TN=()=>{const[n,e]=Xo(),t=o=>{e(`Embed ${o.contentName}`,s=>x.jsx(kN,{embedConfig:o,onClose:s}))},r=(o,s,i)=>[new Lg("Dismiss",{onSelect:i}),new Lg(`Embed ${o.contentName}`,{onSelect:s})];return x.jsxs(x.Fragment,{children:[n,x.jsx(mN,{embedConfigs:qu,onOpenEmbedModalForConfig:t,getMenuOptions:r,menuRenderFn:(o,{selectedIndex:s,options:i,selectOptionAndCleanUp:a,setHighlightedIndex:l})=>o.current?St.createPortal(x.jsx(Y,{sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",marginLeft:o.current.style.width,width:200},children:x.jsx(SN,{options:i,selectedItemIndex:s,onOptionClick:(c,u)=>{l(u),a(c)},onOptionMouseEnter:c=>{l(c)}})}),o.current):null})]})};class Xs extends Bt{__completionText;static getType(){return"inline-completion"}static clone(e){return new Xs(e.__completionText,e.__key)}constructor(e,t){super(t),this.__completionText=e}createDOM(e){const t=document.createElement("span");return t.className="inline-completion-ghost",t.style.cssText=`
208
208
  opacity: 0.5;
209
209
  color: var(--vscode-editorSuggestWidget-foreground, #999);
210
210
  pointer-events: none;
211
211
  user-select: none;
212
212
  white-space: pre;
213
- `,t}updateDOM(){return!1}static importJSON(e){return hc(e.completionText)}exportJSON(){return{completionText:"",type:"inline-completion",version:1}}static importDOM(){return null}exportDOM(){return{element:null}}getCompletionText(){return this.__completionText}setCompletionText(e){const t=this.getWritable();t.__completionText=e}decorate(){return x.jsx(IN,{completionText:this.__completionText})}isInline(){return!0}isKeyboardSelectable(){return!1}}function hc(n){return new Gs(n)}function ds(n){return n instanceof Gs}function IN({completionText:n}){return x.jsx("span",{className:"inline-completion-text",style:{opacity:.5,color:"var(--vscode-editorSuggestWidget-foreground, #999)",pointerEvents:"none",userSelect:"none",whiteSpace:"pre"},children:n})}const EN=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,NN=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,LN=[n=>{const e=EN.exec(n);if(e){const t=e[0].startsWith("http")?e[0]:`https://${e[0]}`;return{index:e.index,length:e[0].length,text:e[0],url:t,attributes:{rel:"noopener noreferrer",target:"_blank"}}}return null},n=>{const e=NN.exec(n);return e?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null}],ON=pe({name:"@datalayer/jupyter-lexical/AutoLink",dependencies:[ln(mC,{matchers:LN})]});function Bm(n){const e=n.anchor,t=n.focus,r=n.anchor.getNode(),o=n.focus.getNode();return r===o?r:n.isBackward()?jd(t)?r:o:jd(e)?o:r}const RN=new Set(["http:","https:","mailto:","sms:","tel:"]);function AN(n){try{const e=new URL(n);if(!RN.has(e.protocol))return"about:blank"}catch{return n}return n}const MN=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function qM(n){return n==="https://"||MN.test(n)}function Um(n,e,t){const r=S.useRef(null);return r.current=n,S.useMemo(()=>Lx((...o)=>{r.current&&r.current(...o)},e,{maxWait:t}),[e,t])}function pl(n){return n instanceof HTMLElement}class zm{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}equals({x:e,y:t}){return this.x===e&&this.y===t}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}}function $N(n){return n instanceof zm}class pr{_left;_top;_right;_bottom;constructor(e,t,r,o){const[s,i]=t<=o?[t,o]:[o,t],[a,l]=e<=r?[e,r]:[r,e];this._top=s,this._right=l,this._left=a,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:e,left:t,bottom:r,right:o}){return e===this._top&&r===this._bottom&&t===this._left&&o===this._right}contains(e){if($N(e)){const{x:t,y:r}=e,o=r<this._top,s=r>this._bottom,i=t<this._left,a=t>this._right;return{reason:{isOnBottomSide:s,isOnLeftSide:i,isOnRightSide:a,isOnTopSide:o},result:!o&&!s&&!i&&!a}}else{const{top:t,left:r,bottom:o,right:s}=e;return t>=this._top&&t<=this._bottom&&o>=this._top&&o<=this._bottom&&r>=this._left&&r<=this._right&&s>=this._left&&s<=this._right}}intersectsWith(e){const{left:t,top:r,width:o,height:s}=e,{left:i,top:a,width:l,height:c}=this,u=t+o>=i+l?t+o:i+l,f=r+s>=a+c?r+s:a+c,d=t<=i?t:i,g=r<=a?r:a;return u-d<=o+l&&f-g<=s+c}generateNewRect({left:e=this.left,top:t=this.top,right:r=this.right,bottom:o=this.bottom}){return new pr(e,t,r,o)}static fromLTRB(e,t,r,o){return new pr(e,t,r,o)}static fromLWTH(e,t,r,o){return new pr(e,r,e+t,r+o)}static fromPoints(e,t){const{y:r,x:o}=e,{y:s,x:i}=t;return pr.fromLTRB(o,r,i,s)}static fromDOM(e){const{top:t,width:r,left:o,height:s}=e.getBoundingClientRect();return pr.fromLWTH(o,r,t,s)}}const Xi=new Map,$s=new Map,_c=new Set;function Ii(n,e){e?Xi.set(n,e):Xi.delete(n),_c.forEach(t=>t())}function DN(n){return _c.add(n),()=>_c.delete(n)}function PN(n){return Xi.get(n)}function jN(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`video-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function FN(){return typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices}function BN(){if(!(typeof MediaRecorder>"u"))return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>MediaRecorder.isTypeSupported(n))}function UN(n){const e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),t=n.mimeType.startsWith("video/mp4")?"mp4":"webm";return`recording-${e}.${t}`}function zN(n){const e=n instanceof DOMException?n.name:"";return e==="NotAllowedError"?"Recording did not start: the browser was not allowed to capture.":e==="NotFoundError"?"Recording did not start: there is no camera or microphone to record.":`Recording did not start: ${n instanceof Error?n.message:String(n)}`}function KN(n){if(n.length<=1)return{track:n[0],close:()=>{}};const e=new AudioContext,t=e.createMediaStreamDestination();for(const r of n)e.createMediaStreamSource(new MediaStream([r])).connect(t);return{track:t.stream.getAudioTracks()[0],close:()=>{e.close()}}}async function WN(n,{source:e,microphone:t},r){const o=[],s=()=>o.forEach(i=>i.getTracks().forEach(a=>a.stop()));try{const i=navigator.mediaDevices;let a;const l=[];if(e==="screen"){const m=await i.getDisplayMedia({video:!0,audio:!0});if(o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks()),t){const b=await i.getUserMedia({audio:!0}).catch(()=>{});b&&(o.push(b),l.push(...b.getAudioTracks()))}}else{const m=await i.getUserMedia({video:!0,audio:t});o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks())}if(!a)throw new Error("there was no picture to record");const c=KN(l),u=new MediaStream(c.track?[a,c.track]:[a]),f=BN(),d=new MediaRecorder(u,f?{mimeType:f}:void 0),g=[],h=Date.now();d.ondataavailable=m=>{m.data.size>0&&g.push(m.data)};const _=()=>{s(),c.close()};d.onstop=()=>{_(),$s.delete(n);const m=d.mimeType||f||"video/webm",b=new Blob(g,{type:m}),w={status:"recorded",url:URL.createObjectURL(b),blob:b,mimeType:m,durationMs:Date.now()-h};Ii(n,w),r?.(w)},a.addEventListener("ended",()=>Vu(n)),$s.set(n,{recorder:d,release:_}),d.start(1e3),Ii(n,{status:"recording",startedAt:h,preview:new MediaStream([a])})}catch(i){s(),Ii(n,{status:"failed",message:zN(i)})}}function Vu(n){const e=$s.get(n);e&&e.recorder.state!=="inactive"&&e.recorder.stop()}function HN(n){const e=$s.get(n);e&&(e.recorder.onstop=null,e.recorder.state!=="inactive"&&e.recorder.stop(),e.release(),$s.delete(n));const t=Xi.get(n);t?.status==="recorded"&&URL.revokeObjectURL(t.url),Ii(n,void 0)}function JN(n,e){return e?e.status:n?"lost":"idle"}const Yu=j_?S.useLayoutEffect:S.useEffect;function qN({editor:n,getCodeDOMNode:e}){const[t,r]=S.useState(!1),o=Um(()=>{r(!1)},1e3);async function s(){const i=e();if(!i)return;let a="";n.update(()=>{const l=Ae(i);je(l)&&(a=l.getTextContent());const c=D();Ee(c)});try{await navigator.clipboard.writeText(a),r(!0),o()}catch(l){console.error("Failed to copy: ",l)}}return x.jsx(Ft,{icon:t?xh:pw,size:"small",variant:"invisible",onClick:s,"aria-label":"copy",sx:t?{color:"var(--fgColor-success)"}:void 0})}const VN=8;function YN({anchorElem:n}){const[e]=fe(),[t,r]=S.useState(""),[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState({right:"0",top:"0"}),u=S.useRef(new Set),f=S.useRef(null);function d(){return f.current}const g=Um(m=>{const{codeDOMNode:b,isOutside:w}=GN(m);if(w){s(!1);return}if(!b)return;f.current=b;let C=null,v="";if(e.update(()=>{const k=Ae(b);je(k)&&(C=k,v=C.getLanguage()||"")}),C){const{y:k,right:I}=n.getBoundingClientRect(),{y:E,right:N}=b.getBoundingClientRect();r(v),s(!0),c({right:`${I-N+VN}px`,top:`${E-k}px`})}},50,1e3);S.useEffect(()=>{if(i)return document.addEventListener("mousemove",g),()=>{s(!1),g.cancel(),document.removeEventListener("mousemove",g)}},[i,g]),S.useEffect(()=>e.registerMutationListener(dn,m=>{e.getEditorState().read(()=>{for(const[b,w]of m)switch(w){case"created":u.current.add(b);break;case"destroyed":u.current.delete(b);break}}),a(u.current.size>0)},{skipInitialization:!1}),[e]);const h=C0(t),_=x0(t);return x.jsx(x.Fragment,{children:o?x.jsxs("div",{className:"code-action-menu-container",style:{...l},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)",alignSelf:"center",px:1},children:_}),x.jsx(qN,{editor:e,getCodeDOMNode:d}),E0(h)?x.jsx(L0,{editor:e,getCodeDOMNode:d,lang:h}):null]}):null})}function GN(n){const e=n.target;if(ke(e)){const t=e.closest("code.JupyterLexicalTheme__code"),r=!(t||e.closest("div.code-action-menu-container"));return{codeDOMNode:t,isOutside:r}}else return{codeDOMNode:null,isOutside:!0}}function VM({anchorElem:n=document.body}){return St.createPortal(x.jsx(YN,{anchorElem:n}),n)}function Og(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
214
- `+ ++i);t.setAttribute("data-gutter",s)}function Km(n){const e=[];if(n instanceof dn&&e.push(n),q(n))for(const t of n.getChildren())q(t)&&e.push(...Km(t));return e}function XN(n){const e=de(S0(n),n.registerNodeTransform(dn,t=>{Og(t,n)}));return n.getEditorState().read(()=>{for(const t of Km(se()))Og(t,n)}),e}const ZN=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Vh],register:XN}),Gu=he("INSERT_COLLAPSIBLE_COMMAND"),Rg=()=>{const n=D();if(F(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Ag=()=>{const n=D();if(F(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();if(t!==null&&t.getLastChild()===e){const r=e.getFirstDescendant(),o=e.getLastDescendant();(o!==null&&n.anchor.key===o.getKey()&&n.anchor.offset===o.getTextContentSize()||r!==null&&n.anchor.key===r.getKey()&&n.anchor.offset===r.getTextContentSize())&&e.insertAfter(ne())}}}return!1};function QN(n){if(!n.hasNodes([Mr,Os,$r]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform($r,e=>{const t=e.getParent();if(!Pt(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(Os,e=>{const t=e.getParent();if(!Pt(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Mr,e=>{const t=e.getChildren();if(t.length!==2||!xi(t[0])||!Lu(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Vt,Ag,ee),n.registerCommand(ia,Ag,ee),n.registerCommand(pt,Rg,ee),n.registerCommand(zs,Rg,ee),n.registerCommand(Lo,()=>{const e=D();if(F(e)){const t=re(e.anchor.getNode(),r=>xi(r));if(xi(t)){const r=t.getParent();if(r&&Pt(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(Gu,()=>(n.update(()=>{const e=Z_(),t=ne();sr(Eu(!0).append(e.append(t),Nu().append(ne()))),t.select()}),!0),ee))}const e2=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Mr,Os,$r],register:QN}),t2=qn?S.useLayoutEffect:S.useEffect;class Wm{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Mg=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function $g(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function n2(n,e,t,r){const[o]=fe();S.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?bh(s,!1):document.body;let a=!1,l=$g(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=$g(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=yh(s??e);return u.observe(e),de(Jt(window,"resize",t),Jt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Jt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Dg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function r2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,x.jsx("span",{className:"text",children:o.title})]},o.key)}function o2({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(r2,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),t2(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Dg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Mg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Dg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Mg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Pg(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function s2(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Pg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return n2(n,l.current,c,u),a!=null&&a===l.current&&(Pg(a,t),i?.append(a)),l}const i2=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Hm(n,{minLength:e=1,maxLength:t=75,punctuation:r=i2,allowWhitespace:o=!1}){return S.useCallback(s=>{const i=new RegExp("(^|\\s|\\()(["+n+"]((?:"+("[^"+n+r+(o?"":"\\s")+"]")+"){0,"+t+"}))$").exec(s);if(i!==null){const a=i[1],l=i[3];if(l.length>=e)return{leadOffset:i.index+a.length,matchingString:l,replaceableString:i[2]}}return null},[o,n,r,t,e])}function Jm({options:n,onQueryChange:e,onSelectOption:t,onOpen:r,onClose:o,menuRenderFn:s,triggerFn:i,anchorClassName:a,commandPriority:l=ee,parent:c,preselectFirstItem:u=!0,ignoreEntityBoundary:f=!1}){const[d]=fe(),[g,h]=S.useState(null),_=s2(g,h,a,c),m=S.useCallback(()=>{if(g===null)return;const w=()=>{h(null)};let C;try{C=o&&o()}finally{C?C.then(w,w):w()}},[o,g]),b=S.useCallback(w=>{h(w),r!=null&&g===null&&r(w)},[r,g]);return S.useEffect(()=>{const w=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const C=d._window||window,v=C.document.createRange(),k=D(),I=(function(N){let O=null;return N.read("latest",()=>{const M=D();F(M)&&(O=(function(R){const $=R.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const A=$.offset;return L.getTextContent().slice(0,A)})(M))}),O})(d);if(!F(k)||!k.isCollapsed()||I===null||v===null)return void m();const E=i(I,d);if(e(E?E.matchingString:null),E!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=D();if(F(M)){const R=M.anchor.getNode().getPreviousSibling();return oe(R)&&R.isTextEntity()}return!1})})(d,E.leadOffset))&&(function(O,M,R,$){const L=or(R);if(L===null||!L.isCollapsed)return!1;const A=Pc(L,$),B=A.anchorNode,j=O,U=A.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,j),M.setEnd(B,U)}catch{return!1}return!0})(E.leadOffset,v,C,d.getRootElement())!==null)return void S.startTransition(()=>b({getRect:()=>v.getBoundingClientRect(),match:E}));m()})});return()=>{w()}},[d,i,e,g,m,b,f]),S.useEffect(()=>d.registerEditableListener(w=>{w||m()}),[d,m]),g===null||d===null||_.current===null?null:x.jsx(o2,{close:m,resolution:g,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const a2=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function l2({author:n,size:e}){const t=Jc(n);return n.avatarUrl?x.jsx(ax,{src:n.avatarUrl,size:e,alt:t}):x.jsx(Y,{as:"span","aria-hidden":!0,title:t,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:e,height:e,borderRadius:"50%",bg:"neutral.muted",color:"fg.muted",fontSize:`${Math.round(e*.45)}px`,fontWeight:"bold"},children:n.kind==="anonymous"?x.jsx(hw,{size:Math.round(e*.65)}):a2(t)})}const jr=S.createContext({}),c2=[],u2=250;function qm(n){const{searchPeople:e}=S.useContext(jr),[t,r]=S.useState(null);return S.useEffect(()=>{if(!e||!n)return;let o=!0;const s=setTimeout(()=>{e(n).then(i=>{o&&r({query:n,people:i})},()=>{o&&r({query:n,people:[]})})},u2);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:c2}class d2 extends Wm{person;constructor(e){super(e.uid),this.person=e}}function f2({onMention:n}){const[e]=fe(),{searchPeople:t}=S.useContext(jr),[r,o]=S.useState(null),s=qm(r),i=S.useMemo(()=>s.map(c=>new d2(c)),[s]),a=Hm("@",{minLength:1}),l=S.useCallback((c,u,f)=>{e.update(()=>{const d=$e(`@${wo(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?x.jsx(Jm,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?St.createPortal(x.jsx(Y,{as:"ul",role:"listbox","aria-label":"People to mention",sx:{position:"relative",zIndex:1e3,listStyle:"none",m:0,p:1,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",minWidth:200},children:i.map((g,h)=>x.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>g.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(g)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[x.jsx(Le,{children:wo(g.person)}),g.person.handle?x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",g.person.handle]}):null]},g.key))}),c.current):null}):null}function g2({thread:n}){const{searchPeople:e,assignThread:t}=S.useContext(jr),[r,o]=S.useState(!1),[s,i]=S.useState(""),a=qm(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?x.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",wo(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return x.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${wo(l)}`:"Not assigned"}),x.jsx(Ft,{icon:ex,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?x.jsxs(Y,{sx:{mt:1},children:[x.jsx(vn,{"aria-label":"Find a person to assign",placeholder:"Name or handle",size:"small",block:!0,autoFocus:!0,value:s,onChange:u=>i(u.target.value)}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>x.jsx(Y,{as:"li",children:x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:wo(u)})},u.uid))})]}):null]})}const p2={characterLimit:"JupyterLexicalTheme__characterLimit",code:"JupyterLexicalTheme__code",codeHighlight:{atrule:"JupyterLexicalTheme__tokenAttr",attr:"JupyterLexicalTheme__tokenAttr",boolean:"JupyterLexicalTheme__tokenProperty",builtin:"JupyterLexicalTheme__tokenSelector",cdata:"JupyterLexicalTheme__tokenComment",char:"JupyterLexicalTheme__tokenSelector",class:"JupyterLexicalTheme__tokenFunction","class-name":"JupyterLexicalTheme__tokenFunction",comment:"JupyterLexicalTheme__tokenComment",constant:"JupyterLexicalTheme__tokenProperty",deleted:"JupyterLexicalTheme__tokenProperty",doctype:"JupyterLexicalTheme__tokenComment",entity:"JupyterLexicalTheme__tokenOperator",function:"JupyterLexicalTheme__tokenFunction",important:"JupyterLexicalTheme__tokenVariable",inserted:"JupyterLexicalTheme__tokenSelector",keyword:"JupyterLexicalTheme__tokenAttr",namespace:"JupyterLexicalTheme__tokenVariable",number:"JupyterLexicalTheme__tokenProperty",operator:"JupyterLexicalTheme__tokenOperator",prolog:"JupyterLexicalTheme__tokenComment",property:"JupyterLexicalTheme__tokenProperty",punctuation:"JupyterLexicalTheme__tokenPunctuation",regex:"JupyterLexicalTheme__tokenVariable",selector:"JupyterLexicalTheme__tokenSelector",string:"JupyterLexicalTheme__tokenSelector",symbol:"JupyterLexicalTheme__tokenProperty",tag:"JupyterLexicalTheme__tokenProperty",url:"JupyterLexicalTheme__tokenOperator",variable:"JupyterLexicalTheme__tokenVariable"},embedBlock:{base:"JupyterLexicalTheme__embedBlock",focus:"JupyterLexicalTheme__embedBlockFocus"},hashtag:"JupyterLexicalTheme__hashtag",heading:{h1:"JupyterLexicalTheme__h1",h2:"JupyterLexicalTheme__h2",h3:"JupyterLexicalTheme__h3",h4:"JupyterLexicalTheme__h4",h5:"JupyterLexicalTheme__h5",h6:"JupyterLexicalTheme__h6"},image:"editor-image",link:"JupyterLexicalTheme__link",list:{listitem:"JupyterLexicalTheme__listItem",listitemChecked:"JupyterLexicalTheme__listItemChecked",listitemUnchecked:"JupyterLexicalTheme__listItemUnchecked",nested:{listitem:"JupyterLexicalTheme__nestedListItem"},olDepth:["JupyterLexicalTheme__ol1","JupyterLexicalTheme__ol2","JupyterLexicalTheme__ol3","JupyterLexicalTheme__ol4","JupyterLexicalTheme__ol5"],ul:"JupyterLexicalTheme__ul"},ltr:"JupyterLexicalTheme__ltr",mark:"JupyterLexicalTheme__mark",markOverlap:"JupyterLexicalTheme__markOverlap",layoutContainer:"JupyterLexicalTheme__layoutContainer",layoutItem:"JupyterLexicalTheme__layoutItem",paragraph:"JupyterLexicalTheme__paragraph",quote:"JupyterLexicalTheme__quote",rtl:"JupyterLexicalTheme__rtl",table:"JupyterLexicalTheme__table",tableCell:"JupyterLexicalTheme__tableCell",tableCellHeader:"JupyterLexicalTheme__tableCellHeader",text:{bold:"JupyterLexicalTheme__textBold",code:"JupyterLexicalTheme__textCode",italic:"JupyterLexicalTheme__textItalic",strikethrough:"JupyterLexicalTheme__textStrikethrough",subscript:"JupyterLexicalTheme__textSubscript",superscript:"JupyterLexicalTheme__textSuperscript",underline:"JupyterLexicalTheme__textUnderline",underlineStrikethrough:"JupyterLexicalTheme__textUnderlineStrikethrough"}},h2={...p2,paragraph:"CommentEditorTheme__paragraph"},ys=he();function _2({anchorKey:n,editor:e,onAddComment:t}){const r=S.useRef(null),o=S.useCallback(()=>{const s=r.current,i=e.getRootElement(),a=e.getElementByKey(n);if(s!==null&&i!==null&&a!==null){const{right:l}=i.getBoundingClientRect(),{top:c}=a.getBoundingClientRect();s.style.left=`${l-20}px`,s.style.top=`${c-30}px`}},[n,e]);return S.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),Yu(()=>{o()},[n,e,o]),x.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:x.jsx(Ft,{icon:Pi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Vm=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:h2,dependencies:[Cw,Sh,Sw]}),m2=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Vm,vw]});function b2({editorRef:n}){const[e]=fe();return Yu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function y2({onEscape:n}){const[e]=fe();return S.useEffect(()=>e.registerCommand(Nn,t=>n(t),2),[e,n]),null}function Ym({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Vm:m2;return x.jsx(ww,{extension:a,contentEditable:null,children:x.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[x.jsx(Ap,{className:"ContentEditable__root",style:n,placeholder:x.jsx(Bh,{children:i}),"aria-placeholder":i}),x.jsx(xw,{onChange:r}),x.jsx(y2,{onEscape:t}),o!==void 0&&x.jsx(f2,{onMention:o}),s!==void 0&&x.jsx(b2,{editorRef:s})]})})}function Gm(n,e){return S.useCallback((t,r)=>{t.read(()=>{n(bw()),e(!yw(r.isComposing(),!0))})},[e,n])}const jg=256;function w2({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),[a,l]=S.useState(null),c=S.useRef(null),u=S.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=Zm(),d=S.useCallback(()=>{n.getEditorState().read(()=>{const C=D();if(F(C)){const v=C.anchor,k=C.focus,I=fh(n,v.getNode(),v.offset,k.getNode(),k.offset);if(I!==null){const{left:E,bottom:N,width:O}=I.getBoundingClientRect(),M=Ml(n,I);let R=M.length===1?E+O/2-jg/2:E-jg/2;R<10&&(R=10),l({left:R,top:N+20});const $=M.length,{container:L}=u,A=u.elements,B=A.length;for(let j=0;j<$;j++){const U=M[j];let z=A[j];z===void 0&&(z=document.createElement("span"),A[j]=z,L.appendChild(z));const H=`position:absolute;top:${U.top}px;left:${U.left}px;height:${U.height}px;width:${U.width}px;background-color:var(--bgColor-attention-muted, rgba(255, 212, 0, 0.3));pointer-events:none;z-index:5;`;z.style.cssText=H}for(let j=B-1;j>=$;j--){const U=A[j];L.removeChild(U),A.pop()}}}})},[n,u]);Yu(()=>{c.current=n.getRootElement(),d();const C=u.container,v=document.body;if(v!==null)return v.appendChild(C),()=>{v.removeChild(C)}},[n,u.container,d]),S.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const g=C=>(C.preventDefault(),e(),!0),h=S.useRef(new Map),_=S.useCallback(C=>{h.current.set(C.uid,C)},[]),m=()=>{if(s){let C=n.getEditorState().read(()=>{const v=D();return v!==null?v.getTextContent():""});C.length>100&&(C=C.slice(0,99)+"…"),t(Px(C,[Ph(r,f,void 0,void 0,void 0,$h(r,h.current.values()))]),!0)}},b=Gm(o,i),w=C=>{const v=C.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:x.jsxs(kl,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:w,returnFocusRef:c,preventFocusOnOpen:!0,children:[x.jsx(Ym,{style:{position:"relative",border:"1px solid var(--borderColor-default)",backgroundColor:"var(--bgColor-default)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"80px"},onEscape:g,onChange:b,onMention:_}),x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[x.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),x.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function x2({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),a=S.useRef(null),l=Zm(),c=S.useRef(new Map),u=S.useCallback(g=>{c.current.set(g.uid,g)},[]),f=Gm(o,i),d=()=>{if(s){n(Ph(r,l,void 0,void 0,void 0,$h(r,c.current.values())),!1,e),c.current.clear();const g=a.current;g!==null&&g.dispatchCommand(Tw,void 0)}};return x.jsxs(x.Fragment,{children:[x.jsx(Ym,{style:{position:"relative",border:"1px solid",borderColor:"var(--borderColor-default, #ccc)",backgroundColor:"var(--bgColor-default, #fff)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"20px"},autoFocus:!1,onEscape:()=>!0,onChange:f,onMention:u,editorRef:a,placeholder:t}),x.jsx(Ft,{icon:kw,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function Xm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return x.jsxs(x.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[x.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),x.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function C2(n,e){const t=Math.round((e-Date.now())/1e3);if(t>-10)return"Just now";const r=Math.round(t/60);if(r>-60)return n.format(r,"minute");const o=Math.round(r/60);return o>-24?n.format(o,"hour"):n.format(Math.round(o/24),"day")}function Fg({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=Go(),{Avatar:i=l2}=S.useContext(jr),a=Dx(n);return x.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[x.jsx(i,{author:a,size:20}),x.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:Jc(a)}),a.agentUid&&x.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",C2(r,n.timeStamp)]})]}),x.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&x.jsxs(x.Fragment,{children:[x.jsx(Ft,{icon:Ch,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>x.jsx(Xm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function S2({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=S.useState(0),[u,f]=Go(),d=S.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return S.useEffect(()=>{const g=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(g)}},[l]),x.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(g=>{const h=g.id;if(g.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const b=document.activeElement;a.update(()=>{const w=Array.from(m)[0],C=Q(w);Ro(C)&&C.selectStart()},{onUpdate(){b!==null&&b.focus()}})}};return x.jsxs(Y,{as:"li",onClick:_,sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",cursor:s.has(h)?"pointer":"default",bg:n.indexOf(h)===-1?"var(--bgColor-default)":"var(--bgColor-accent-muted)","&:hover":s.has(h)?{bg:"var(--bgColor-muted)"}:{}},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[x.jsxs(Y,{as:"blockquote",sx:{flex:1,m:0,pl:2,borderLeft:"3px solid",borderColor:"var(--bgColor-accent-muted)",color:"var(--fgColor-muted)",fontSize:1},children:["> ",x.jsx("span",{children:g.quote})]}),i&&x.jsx(Ft,{icon:xh,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(g)}}),x.jsx(Ft,{icon:Ch,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>x.jsx(Xm,{commentOrThread:g,deleteCommentOrThread:t,onClose:m}))}}),u]}),x.jsx(g2,{thread:g}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:g.comments.map(m=>x.jsx(Fg,{comment:m,deleteComment:t,thread:g,rtf:d},m.id))}),x.jsx(Y,{sx:{mt:2},children:x.jsx(x2,{submitAddComment:o,thread:g,placeholder:"Reply to comment..."})})]},h)}return x.jsx(Fg,{comment:g,deleteComment:t,rtf:d},h)})})}function v2({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=S.useRef(null),a=t.length===0;return x.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[x.jsx(mw,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?x.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):x.jsx(S2,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function Zm(){const{author:n}=S.useContext(jr),{name:e}=Lm();return n??qc(e)}function YM({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=e_(),l=S.useRef(null),c=S.useRef(null),u=S.useMemo(()=>t??new Bx(s),[s,t]),f=Ux(u),d=S.useMemo(()=>new Map,[]),[g,h]=S.useState(),[_,m]=S.useState([]),[b,w]=S.useState(!1),C=S.useCallback(R=>{a(typeof R=="function"?R(i):R)},[a,i]),v=S.useCallback(()=>{s.update(()=>{const R=D();R!==null&&(R.dirty=!0)}),w(!1)},[s]),k=S.useCallback(R=>{const $=d.get(R);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const A=Q(L);Ro(A)&&(A.deleteID(R),A.getIDs().length===0&&Ox(A))}})})},[s,d]),I=S.useCallback((R,$)=>{R.type==="comment"?u.deleteComment(R,$):(u.deleteThread(R),k($!==void 0?$.id:R.id))},[u,k]),E=S.useMemo(()=>{if(u.resolveThread)return R=>{u.resolveThread?.(R),k(R.id)}},[u,k]),N=S.useCallback((R,$,L)=>{u.addComment(R,L),$&&(s.update(()=>{const A=D();if(F(A)){const B=A.focus,j=A.anchor,U=A.isBackward(),z=R.id;Rx(A,U,z),U?B.set(j.key,j.offset,j.type):j.set(B.key,B.offset,B.type)}}),w(!1))},[u,s]);S.useEffect(()=>{const R=[];for(let $=0;$<_.length;$++){const L=_[$],A=d.get(L);if(A!==void 0)for(const B of A){const j=s.getElementByKey(B);j!==null&&(j.classList.add("selected"),R.push(j),a(!0))}}return()=>{for(let $=0;$<R.length;$++)R[$].classList.remove("selected")}},[_,s,d]),S.useEffect(()=>{const R=new Map;return de(_w(s,Ts,$=>Hc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(Ts,$=>{s.getEditorState().read(()=>{for(const[L,A]of $){const B=Q(L);let j=[];A==="destroyed"?j=R.get(L)||[]:Ro(B)&&(j=B.getIDs());for(let U=0;U<j.length;U++){const z=j[U];let K=d.get(z);R.set(L,j),A==="destroyed"?K!==void 0&&(K.delete(L),K.size===0&&d.delete(z)):(K===void 0&&(K=new Set,d.set(z,K)),K.has(L)||K.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const A=D();let B=!1,j=!1;if(F(A)){const U=A.anchor.getNode();if(oe(U)){const z=Ax(U,A.anchor.offset);z!==null&&(m(z),B=!0),A.isCollapsed()||(h(U.getKey()),j=!0)}}B||m(U=>U.length===0?U:[]),j||h(null)}),L.has("collaboration")||w(!1)}),s.registerCommand(ys,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),w(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ys,void 0)},M=S.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return x.jsxs(jr.Provider,{value:M,children:[b&&x.jsx(jr.Provider,{value:M,children:x.jsx(w2,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&g!==null&&g!==void 0&&!b&&St.createPortal(x.jsx(_2,{anchorKey:g,editor:s,onAddComment:O}),document.body),x.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),x.jsx(vx,{isOpen:i,setIsOpen:C,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:x.jsx(v2,{comments:f,submitAddComment:N,deleteCommentOrThread:I,activeIDs:_,markNodeMap:d,resolveThread:E})})]})}const Fo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),Qm=Lt({type:wr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:Ke().describe("Left edge, in scene coordinates"),y:Ke().describe("Top edge, in scene coordinates"),width:Ke().optional().describe("Width in pixels (shapes only)"),height:Ke().optional().describe("Height in pixels (shapes only)"),id:Qe().optional().describe("Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it."),text:Qe().optional().describe("The text itself, for type 'text'"),label:Qe().optional().describe("Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label."),fontSize:Ke().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:Fo.optional().describe("Outline colour"),backgroundColor:Fo.optional().describe("Fill colour"),fillStyle:wr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:Ke().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:wr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:Ke().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians"),startId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),endId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow points at."),points:yr(yr(Ke())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:yr(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),eb=Qe().describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after"),On=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),tb=Lt({afterId:eb,elements:yr(Qm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:Ke().optional().describe("Rendered width in pixels. Omit to size to the content."),height:Ke().optional().describe("Rendered height in pixels. Omit to size to the content.")}),nb=Lt({}),rb=Lt({blockId:On,detail:wr(["summary","full"]).optional().describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits.")}),ob=Lt({blockId:On,elements:yr(Qm).describe("The elements to add. Existing elements are left alone.")}),sb=Lt({blockId:On,updates:yr(Lt({id:Qe().describe("The element id, from excalidrawReadScene"),x:Ke().optional(),y:Ke().optional(),width:Ke().optional(),height:Ke().optional(),text:Qe().optional().describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),strokeColor:Fo.optional(),backgroundColor:Fo.optional(),fillStyle:wr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:Ke().optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional(),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),ib=Lt({blockId:On,elementIds:yr(Qe()).describe("The ids to remove, from excalidrawReadScene")}),ab=Lt({blockId:On,fromId:Qe().describe("The element the arrow starts at"),toId:Qe().describe("The element the arrow points at"),label:Qe().optional().describe('Text to sit on the arrow, e.g. "yes", "then"'),strokeColor:Fo.optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional()}),lb=Lt({blockId:On,viewBackgroundColor:Fo.optional().describe("The canvas colour behind the drawing"),gridSize:Ke().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),cb=Lt({blockId:On,width:Ke().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:Ke().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),ub=Lt({blockId:On}),db=Lt({blockId:On.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:eb.optional().describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),mermaid:Qe().describe("Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image."),fontSize:Ke().optional().describe("Font size for the generated text, in pixels")}),Qt=n=>`datalayer_${n}`,Qr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},en=["lexical","excalidraw","drawing","diagram"],k2={name:Qt("excalidrawInsertNode"),displayName:"Insert Drawing",toolReferenceName:"excalidrawInsertNode",description:"Insert an Excalidraw drawing into the Lexical document, optionally with its contents. This is how you draw a diagram: give the elements you want and they are laid out as you place them, in scene coordinates where x grows right and y grows down. Give a shape an `id` and a later arrow can bind to it with `startId`/`endId`, so the arrow follows the shape when it moves. Put text on a shape with `label` rather than positioning a separate text element on top of it. Returns the new block_id — keep it, every other excalidraw tool needs it. Omit `elements` to insert an empty canvas for a person to draw on themselves.",parameters:Zt(tb),operation:"excalidrawInsertNode",config:{confirmationMessage:n=>`Insert a drawing of ${n.elements?.length??0} element(s)?`,invocationMessage:()=>"Drawing in the lexical document",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...en,"insert"]},T2={name:Qt("excalidrawListDrawings"),displayName:"List Drawings",toolReferenceName:"excalidrawListDrawings",description:'List the Excalidraw drawings in the open Lexical document, with the block_id of each and a one-line description of what it holds. Call this first when asked to change "the diagram" and you do not already know its block_id.',parameters:Zt(nb),operation:"excalidrawListDrawings",config:{...Qr,invocationMessage:()=>"Looking for drawings"},tags:[...en,"read"]},I2={name:Qt("excalidrawReadScene"),displayName:"Read Drawing",toolReferenceName:"excalidrawReadScene",description:"Read what is inside one drawing: every element with its id, type, position, size and text. The element ids are the only way to address a shape, so read the scene before updating, deleting or connecting anything. The default 'summary' detail is what you want; 'full' returns the raw Excalidraw elements and is large.",parameters:Zt(rb),operation:"excalidrawReadScene",config:{...Qr,invocationMessage:()=>"Reading the drawing"},tags:[...en,"read"]},E2={name:Qt("excalidrawAddElements"),displayName:"Add to Drawing",toolReferenceName:"excalidrawAddElements",description:"Add elements to a drawing that already exists, leaving what is there alone. Same element format as excalidrawInsertNode. To attach a new arrow to a shape already in the drawing, pass that shape's existing element id as `startId` or `endId`. Read the scene first if you need to know where there is room.",parameters:Zt(ob),operation:"excalidrawAddElements",config:{...Qr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...en,"edit"]},N2={name:Qt("excalidrawUpdateElements"),displayName:"Update Drawing Elements",toolReferenceName:"excalidrawUpdateElements",description:"Change elements already in a drawing — move them, resize them, recolour them, or rewrite their text. Address each one by the element id from excalidrawReadScene. Fields you leave out are kept as they are. Setting `text` on a shape rewrites the label bound inside it rather than replacing the shape.",parameters:Zt(sb),operation:"excalidrawUpdateElements",config:{...Qr,invocationMessage:()=>"Changing the drawing"},tags:[...en,"edit"]},L2={name:Qt("excalidrawDeleteElements"),displayName:"Delete Drawing Elements",toolReferenceName:"excalidrawDeleteElements",description:"Remove elements from a drawing by their element ids. Deleting a shape also removes the text bound inside it and detaches any arrows that pointed at it, so the drawing stays consistent.",parameters:Zt(ib),operation:"excalidrawDeleteElements",config:{confirmationMessage:n=>`Delete ${n.elementIds?.length??0} element(s) from the drawing?`,invocationMessage:()=>"Removing from the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"medium"},tags:[...en,"edit","delete"]},O2={name:Qt("excalidrawConnectElements"),displayName:"Connect Drawing Elements",toolReferenceName:"excalidrawConnectElements",description:"Draw an arrow from one element to another and bind it to both, so it follows them when either moves. Excalidraw works out where the arrow should meet each shape. Use this rather than adding an arrow with hand-computed points whenever both ends are existing shapes.",parameters:Zt(ab),operation:"excalidrawConnectElements",config:{...Qr,invocationMessage:()=>"Connecting two shapes"},tags:[...en,"edit"]},R2={name:Qt("excalidrawSetAppState"),displayName:"Set Drawing Canvas",toolReferenceName:"excalidrawSetAppState",description:"Set the canvas behind a drawing: its background colour and its grid. This is about the canvas, not the shapes on it — use excalidrawUpdateElements to recolour a shape.",parameters:Zt(lb),operation:"excalidrawSetAppState",config:{...Qr,invocationMessage:()=>"Setting up the canvas"},tags:[...en,"edit"]},A2={name:Qt("excalidrawResize"),displayName:"Resize Drawing",toolReferenceName:"excalidrawResize",description:"Set how large the drawing is rendered in the document. This scales the picture on the page; it does not move or resize anything inside it. Omit width and height to go back to sizing by content.",parameters:Zt(cb),operation:"excalidrawResize",config:{...Qr,invocationMessage:()=>"Resizing the drawing"},tags:[...en,"edit"]},M2={name:Qt("excalidrawClearScene"),displayName:"Clear Drawing",toolReferenceName:"excalidrawClearScene",description:"Empty a drawing, keeping the block so it can be drawn into again. To remove the drawing from the document altogether, use deleteBlocks with its block_id.",parameters:Zt(ub),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...en,"edit","delete"]},$2={name:Qt("excalidrawFromMermaid"),displayName:"Draw from Mermaid",toolReferenceName:"excalidrawFromMermaid",description:"Turn Mermaid source into a real Excalidraw drawing — shapes and arrows that can then be moved, recoloured and edited like anything else you drew. This is the fastest way to produce a flowchart, sequence diagram or class diagram: write the Mermaid and let the layout be worked out for you, rather than placing boxes by hand. Give blockId to replace an existing drawing, or afterId to insert a new one.",parameters:Zt(db),operation:"excalidrawFromMermaid",config:{confirmationMessage:n=>n.blockId?"Replace this drawing with the Mermaid diagram?":"Insert the Mermaid diagram as a drawing?",invocationMessage:()=>"Drawing the Mermaid diagram",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...en,"insert","mermaid"]},fb=[k2,$2,T2,I2,E2,N2,O2,L2,R2,A2,M2],hl=()=>({elements:[],appState:{},files:{}});function Xu(n){if(!n)return hl();let e;try{e=JSON.parse(n)}catch{return hl()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return hl();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function Zu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const Xs=n=>n.elements.filter(e=>!e?.isDeleted);function D2(n){const e={id:String(n?.id??""),type:String(n?.type??"unknown"),x:Number(n?.x??0),y:Number(n?.y??0),width:Number(n?.width??0),height:Number(n?.height??0)};return typeof n?.text=="string"&&n.text.length>0&&(e.text=n.text),n?.strokeColor&&(e.strokeColor=String(n.strokeColor)),n?.backgroundColor&&(e.backgroundColor=String(n.backgroundColor)),n?.containerId&&(e.containerId=String(n.containerId)),n?.startBinding?.elementId&&(e.startBoundElementId=String(n.startBinding.elementId)),n?.endBinding?.elementId&&(e.endBoundElementId=String(n.endBinding.elementId)),Array.isArray(n?.groupIds)&&n.groupIds.length>0&&(e.groupIds=n.groupIds.map(String)),e}function P2(n){const e=new Map;for(const t of n)t?.type==="text"&&t?.containerId&&t?.text&&e.set(String(t.containerId),String(t.text));return n.map(t=>{const r=D2(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function Qu(n){const e=Xs(n);if(e.length===0)return"empty drawing";const t=new Map,r=[];for(const i of e){const a=String(i?.type??"unknown");if(a==="text"){const l=String(i?.text??"").trim();if(l&&r.push(l),i?.containerId)continue}t.set(a,(t.get(a)??0)+1)}const o=[...t.entries()].sort((i,a)=>a[1]-i[1]||i[0].localeCompare(a[0])).map(([i,a])=>`${a} ${i}${a>1?"s":""}`).join(", "),s=r.slice(0,3).join(", ");return s?`${o}: ${s}`:o}function ed(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Zi=4;function gb(n,e){let t=null,r;if(n.getEditorState().read(()=>{const o=Q(e);o&&(r=o.getType?.(),r==="excalidraw"&&(t=o))}),!t)throw new Error(r?`Block '${e}' is a '${r}', not a drawing. Call excalidrawListDrawings to find the drawings in this document.`:`No block '${e}' in this document. Call excalidrawListDrawings to find the drawings in this document.`);return t}function Rn(n,e){const t=gb(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),Xu(r)}function eo(n,e,t){const r=Zu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const hn=(n,e,t)=>({success:!0,blockId:n,elementCount:Xs(e).length,...t});let j2=0;const F2=()=>`dla-${Date.now().toString(36)}-${(j2+=1).toString(36)}`;function B2(n,e){const{label:t,startId:r,endId:o,fontSize:s,text:i,children:a,name:l,...c}=n,u={...c,id:e};return n.type==="text"?(u.text=i??t??"",s&&(u.fontSize=s)):t&&(u.label=s?{text:t,fontSize:s}:{text:t}),(n.type==="arrow"||n.type==="line")&&(r&&(u.start={id:r}),o&&(u.end={id:o})),(n.type==="frame"||n.type==="magicframe")&&(u.children=a??[],l&&(u.name=l)),u}async function td(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-fzYCDL7m.js").then(a=>a.i);return{convertToExcalidrawElements:i}},[],import.meta.url),r=[],o=n.map(i=>{let a=String(i.id??"").trim();return(!a||e.has(a))&&(a=F2()),e.add(a),r.push(a),B2(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const mc=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function Bg(n,e){const t=mc(n),r=e.x-t.x,o=e.y-t.y;if(r===0&&o===0)return t;const s=Number(n.width??0)/2+Zi,i=Number(n.height??0)/2+Zi,a=Math.min(r===0?1/0:Math.abs(s/r),o===0?1/0:Math.abs(i/o));return{x:t.x+r*a,y:t.y+o*a}}function U2(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),ed({...n,boundElements:t})}function pb(n,e,t,r){const o=n.elements.find(c=>c.id===t),s=n.elements.find(c=>c.id===r);if(!o||!s){const c=o?r:t;throw new Error(`No element '${c}' in this drawing. Call excalidrawReadScene to see the element ids it holds.`)}const i=Bg(o,mc(s)),a=Bg(s,mc(o)),l={...e,x:i.x,y:i.y,width:Math.abs(a.x-i.x),height:Math.abs(a.y-i.y),points:[[0,0],[a.x-i.x,a.y-i.y]],startBinding:{elementId:t,focus:0,gap:Zi},endBinding:{elementId:r,focus:0,gap:Zi}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?U2(c,String(e.id)):c),l}const z2=async(n,e)=>{const t=e.elements??[],r=t.length>0?await td(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(o),width:e.width,height:e.height}},String(e.afterId??"BOTTOM"));if(!s.success||!s.blockId)throw new Error(s.error||"Failed to insert the drawing");return hn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},K2=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=Xu(r.metadata?.data);return{blockId:r.block_id,elementCount:Xs(o).length,description:Qu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},W2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Xs(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:P2(o),appState:r.appState,description:Qu(r)}},H2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=new Set(r.elements.map(u=>String(u.id))),s=e.elements??[],i=new Set(s.map(u=>String(u.id??"")).filter(Boolean)),a=new Map,l=s.map((u,f)=>{const{startId:d,endId:g}=u;if((u.type==="arrow"||u.type==="line")&&d&&g&&(!i.has(String(d))||!i.has(String(g)))){a.set(f,{fromId:String(d),toId:String(g)});const{startId:_,endId:m,...b}=u;return b}return u}),c=await td(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],g=r.elements.find(h=>h.id===d);if(g){const h=pb(r,g,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await eo(n.editor,t,r),hn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},J2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=e.updates??[],s=new Map;for(const l of r.elements)l?.type==="text"&&l?.containerId&&s.set(String(l.containerId),String(l.id));const i=new Map,a=[];for(const l of o){const c=String(l.id),u=r.elements.find(_=>_.id===c);if(!u){a.push(c);continue}const{id:f,text:d,...g}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(g.text=d,g.originalText=d)),Object.keys(g).length>0&&i.set(c,{...i.get(c)??{},...g})}if(a.length>0)throw new Error(`No element(s) ${a.map(l=>`'${l}'`).join(", ")} in this drawing. Call excalidrawReadScene to see the element ids it holds.`);return r.elements=r.elements.map(l=>{const c=i.get(String(l.id));return c?ed({...l,...c}):l}),await eo(n.editor,t,r),hn(t,r,{message:`Updated ${o.length} element(s)`})},q2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=new Set(e.elementIds.map(String)),s=new Set(o);for(const a of r.elements)a?.containerId&&o.has(String(a.containerId))&&s.add(String(a.id));const i=r.elements.length;return r.elements=r.elements.filter(a=>!s.has(String(a.id))).map(a=>{const l={};if(s.has(String(a.startBinding?.elementId))&&(l.startBinding=null),s.has(String(a.endBinding?.elementId))&&(l.endBinding=null),Array.isArray(a.boundElements)){const c=a.boundElements.filter(u=>!s.has(String(u?.id)));c.length!==a.boundElements.length&&(l.boundElements=c)}return Object.keys(l).length>0?ed({...a,...l}):a}),await eo(n.editor,t,r),hn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},V2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=String(e.fromId),s=String(e.toId),i=new Set(r.elements.map(d=>String(d.id))),{elements:a,ids:l}=await td([{type:"arrow",x:0,y:0,...e.label?{label:e.label}:{},...e.strokeColor?{strokeColor:e.strokeColor}:{},...e.strokeStyle?{strokeStyle:e.strokeStyle}:{}}],i),c=l[0];r.elements=[...r.elements,...a];const u=r.elements.find(d=>d.id===c),f=pb(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await eo(n.editor,t,r),hn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},Y2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t);return e.viewBackgroundColor!==void 0&&(r.appState.viewBackgroundColor=e.viewBackgroundColor),e.gridSize!==void 0&&(r.appState.gridSize=Number(e.gridSize)||null),await eo(n.editor,t,r),hn(t,r,{message:"Canvas updated"})},G2=async(n,e)=>{const t=String(e.blockId),r=gb(n.editor,t),o=e.width===void 0?"inherit":Number(e.width),s=e.height===void 0?"inherit":Number(e.height);await new Promise(a=>{n.editor.update(()=>{r.setWidth(o),r.setHeight(s)},{onUpdate:()=>a()})});const i=Rn(n.editor,t);return hn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},X2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Xs(r).length;return r.elements=[],r.files={},await eo(n.editor,t,r),hn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},Z2=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-TDpnbl90.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-fzYCDL7m.js").then(u=>u.i);return{convertToExcalidrawElements:c}},[],import.meta.url);let o;try{o=await t(String(e.mermaid),{fontSize:e.fontSize?Number(e.fontSize):void 0})}catch(c){const u=c instanceof Error?c.message:String(c);throw new Error(`That Mermaid source did not parse: ${u}. Flowcharts, sequence diagrams and class diagrams are the ones that convert to shapes.`,{cause:c})}const s=[...r(o.elements)],i=o.files??{};if(e.blockId){const c=String(e.blockId),u=Rn(n.editor,c);return u.elements=s,u.files=i,await eo(n.editor,c,u),hn(c,u,{createdIds:s.map(f=>String(f.id)),message:`Drawing replaced with ${s.length} element(s) from Mermaid`})}const a={elements:s,appState:{},files:i},l=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return hn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},bc={excalidrawInsertNode:z2,excalidrawListDrawings:K2,excalidrawReadScene:W2,excalidrawAddElements:H2,excalidrawUpdateElements:J2,excalidrawDeleteElements:q2,excalidrawConnectElements:V2,excalidrawSetAppState:Y2,excalidrawResize:G2,excalidrawClearScene:X2,excalidrawFromMermaid:Z2};function tn(n,e){return{name:n,async execute(t,r){const o=Iw(e,t??{},n);if(!r.documentId)throw new Error(`Document ID is required for ${n}. Ensure the tool execution context includes a valid documentId.`);if(!r.executor)throw new Error(`Executor is required for ${n}. This should be provided by the platform (DefaultExecutor, BridgeExecutor, etc.)`);try{return await r.executor.execute(n,o)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`Failed to run ${n}: ${i}`,{cause:s})}}}}const Q2=tn("excalidrawInsertNode",tb),eL=tn("excalidrawListDrawings",nb),tL=tn("excalidrawReadScene",rb),nL=tn("excalidrawAddElements",ob),rL=tn("excalidrawUpdateElements",sb),oL=tn("excalidrawDeleteElements",ib),sL=tn("excalidrawConnectElements",ab),iL=tn("excalidrawSetAppState",lb),aL=tn("excalidrawResize",cb),lL=tn("excalidrawClearScene",ub),cL=tn("excalidrawFromMermaid",db),Ei={excalidrawInsertNode:Q2,excalidrawListDrawings:eL,excalidrawReadScene:tL,excalidrawAddElements:nL,excalidrawUpdateElements:rL,excalidrawDeleteElements:oL,excalidrawConnectElements:sL,excalidrawSetAppState:iL,excalidrawResize:aL,excalidrawClearScene:lL,excalidrawFromMermaid:cL},Ug={name:"excalidraw",definitions:fb,operations:Ei,handlers:bc};function GM(){const n=[];for(const e of fb)Ei[e.operation]||n.push(`${e.name} points at operation '${e.operation}', which does not exist`),e.toolReferenceName.startsWith("excalidraw")||n.push(`${e.name} is not named for the plugin it belongs to`);for(const e of Object.keys(Ei))bc[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(bc))Ei[e]||n.push(`handler '${e}' has no operation`);return n}const uL=S.lazy(()=>me(()=>import("./ExcalidrawModal-BOVvWzYQ.js"),[],import.meta.url)),nd=he();function dL(){const[n]=fe(),[e,t]=S.useState(!1),o=M0()?.lexicalId;S.useEffect(()=>{if(!n.hasNodes([Yn]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(nd,()=>(t(!0),!0),V)},[n]),S.useEffect(()=>{if(o)return go.getState().registerPluginTools(o,Ug),()=>{go.getState().unregisterPluginTools(o,Ug.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ju();f.setData(JSON.stringify({elements:l,appState:c,files:u})),Tr([f]),wt(f.getParentOrThrow())&&Fc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?x.jsx(S.Suspense,{fallback:null,children:x.jsx(uL,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const fL=S.lazy(()=>me(()=>import("./DeckComponent-4gxuEH4A.js"),[],import.meta.url));function gL(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function pL(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:rd(JSON.parse(e))}}catch{return null}}class Xo extends Jo{__spec;static getType(){return"deck"}static clone(e){return new Xo(e.__spec,e.__format,e.__key)}static importJSON(e){const t=rd(e.spec);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"deck",version:1,spec:this.__spec}}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-deck")?{conversion:pL,priority:2}:null}}exportDOM(){const e=document.createElement("div");e.setAttribute("data-lexical-deck",JSON.stringify(this.__spec));const t=document.createElement("p");return t.textContent=this.__spec.deck?.title||"Deck",e.appendChild(t),{element:e}}constructor(e,t,r){super(t,r),this.__spec=e??gL()}getSpec(){return this.getLatest().__spec}setSpec(e){this.getWritable().__spec=e}getTextContent(){return this.__spec.deck?.title||""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(S.Suspense,{fallback:null,children:x.jsx(fL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function rd(n){return new Xo(n)}function XM(n){return n instanceof Xo}const od=he("INSERT_DECK_COMMAND");function hL(n){if(!n.hasNodes([Xo]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(od,e=>(sr(rd(e)),!0),V)}const _L=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Xo],register:hL}),zg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",hb={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function mL(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function bL(n){const e=n.currentTarget;if(Number.isFinite(e.duration))return;const t=()=>{e.removeEventListener("timeupdate",t),e.currentTime=0};e.addEventListener("timeupdate",t),e.currentTime=Number.MAX_SAFE_INTEGER}function yL({recordingId:n,recording:e}){const t=S.useRef(null),[r,o]=S.useState(()=>Date.now());return S.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),S.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),x.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:mL(r-e.startedAt)}),x.jsx(ft,{variant:"danger",leadingVisual:Nw,onClick:()=>Vu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function wL({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Hr(),a=S.useSyncExternalStore(DN,()=>PN(r)),l=JN(o,a),[c,u]=S.useState("screen"),[f,d]=S.useState(!0),g=S.useCallback(w=>{s.update(()=>{const C=Q(t);_b(C)&&C.setRecorded(w)})},[s,t]),h=()=>{WN(r,{source:c,microphone:f},()=>g(!0))},_=()=>{HN(r),g(!1)},m=w=>{const C=document.createElement("a");C.href=w.url,C.download=UN(w),C.click()};let b;return a?.status==="recording"?b=x.jsx(yL,{recordingId:r,recording:a}):a?.status==="recorded"?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:bL,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:zg}),x.jsx(ft,{leadingVisual:Ew,onClick:()=>m(a),children:"Download"}),i&&x.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?b=x.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"The video recorded here is gone: it was kept in the memory of the page that recorded it, and that page has been reloaded or closed."}),i&&x.jsx(ft,{onClick:()=>g(!1),children:"Record a new one"})]}):i?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Wc,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),x.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",zg]}),FN()?x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[x.jsxs(Aa,{"aria-label":"What to record",size:"small",children:[x.jsx(Aa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),x.jsx(Aa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),x.jsxs(Mt,{children:[x.jsx(Mp,{checked:f,onChange:w=>d(w.target.checked)}),x.jsx(Mt.Label,{children:"Microphone"})]}),x.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):x.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):b=x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx(Y,{"data-lexical-video":l,onFocusCapture:()=>s.update(()=>Ee(null)),sx:{p:l==="recorded"||l==="recording"?0:3,border:"1px dashed",borderColor:l==="recorded"||l==="recording"?"transparent":"border.default",borderRadius:2,bg:l==="recorded"||l==="recording"?"transparent":"canvas.subtle"},children:b})})}class Zn extends Jo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Zn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Zn(e.recordingId,e.recorded);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"video",version:1,recordingId:this.__recordingId,recorded:this.__recorded}}exportDOM(){return{element:null}}constructor(e,t=!1,r,o){super(r,o),this.__recordingId=e||jN(),this.__recorded=t}getRecordingId(){return this.getLatest().__recordingId}isRecorded(){return this.getLatest().__recorded}setRecorded(e){this.getWritable().__recorded=e}getTextContent(){return""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(wL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function xL(){return new Zn}function _b(n){return n instanceof Zn}const sd=he("INSERT_VIDEO_COMMAND");function CL(n){if(!n.hasNodes([Zn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(sd,()=>(sr(xL()),!0),V),n.registerMutationListener(Zn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return _b(i)?i.__recordingId:void 0});s&&Vu(s)}},{skipInitialization:!0}))}const SL=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Zn],register:CL});function vL({onConfirm:n,onClose:e}){const[t,r]=S.useState("5"),[o,s]=S.useState("5"),i=S.useRef(null),a=()=>{const c=parseInt(t,10),u=parseInt(o,10);c>0&&c<=500&&u>0&&u<=50&&n(c,u)},l=c=>{c.key==="Enter"&&a()};return x.jsx($p,{title:"Insert Table",onClose:()=>e(),width:"small",height:"auto",initialFocusRef:i,footerButtons:[{buttonType:"default",content:"Cancel",onClick:e},{buttonType:"primary",content:"Confirm",onClick:a}],children:x.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Rows"}),x.jsx(vn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Columns"}),x.jsx(vn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const ws=he();function mb(){const[n]=fe(),[e,t]=S.useState(!1);S.useEffect(()=>n.registerCommand(ws,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(nu,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?x.jsx(vL,{onConfirm:r,onClose:o}):null}function ZM(){return x.jsxs(x.Fragment,{children:[x.jsx(P_,{}),x.jsx(mb,{})]})}const id=he("INSERT_EQUATION_COMMAND");function bb(n){if(!n.hasNodes([ir]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(id,e=>{const{equation:t,inline:r}=e,o=ya(t,r);return Tr([o]),wt(o.getParentOrThrow())&&Fc(o,ne).selectEnd(),!0},V)}const yb=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[ir],register:bb});function ad({activeEditor:n,onClose:e}){const t=S.useCallback((r,o)=>{n.dispatchCommand(id,{equation:r,inline:o}),e()},[n,e]);return x.jsx(Vx,{onConfirm:t})}const Kg=()=>{const[n]=fe();return S.useEffect(()=>bb(n),[n]),null},kL=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:Kg,INSERT_EQUATION_COMMAND:id,InsertEquationDialog:ad,default:Kg},Symbol.toStringTag,{value:"Module"}));class ze extends Wm{title;icon;keywords;keyboardShortcut;onSelect;disabled;constructor(e,t){super(e),this.title=e,this.keywords=t.keywords||[],this.icon=t.icon,this.keyboardShortcut=t.keyboardShortcut,this.onSelect=t.onSelect.bind(this),this.disabled=t.disabled||!1}}function TL({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return x.jsxs(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e&&!o.disabled,"aria-disabled":o.disabled,id:"typeahead-item-"+n,onMouseEnter:a,onClick:i,sx:{display:"flex",alignItems:"center",gap:2,px:2,py:"6px",borderRadius:2,cursor:o.disabled?"not-allowed":"pointer",opacity:o.disabled?.5:1,bg:e&&!o.disabled?"actionListItem.default.selectedBg":"transparent",color:"var(--fgColor-default)","&:hover":o.disabled?{}:{bg:"actionListItem.default.hoverBg"},listStyle:"none"},children:[x.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),x.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const IL=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=Go(),[s,i]=S.useState(null),a=Hm("/",{minLength:0}),l=S.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),g=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=g.exec(s);if(h){const[m,b]=h[0].split("x").map(w=>parseInt(w,10));f.push(new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(b,w)=>w+1).map(b=>new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)})))}return f},[t,s]),c=S.useMemo(()=>{const f=[new ze("Jupyter Cell",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading..."})}}),new ze("Marimo Cell",{icon:x.jsx(br,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading...",variant:"marimo"})}}),new ze("Paragraph",{icon:x.jsx(Ih,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>ne())})}),...Array.from({length:3},(g,h)=>h+1).map(g=>new ze(`Heading ${g}`,{icon:x.jsx(tx,{size:16}),keywords:["heading","header",`h${g}`],onSelect:()=>t.update(()=>{const h=D();F(h)&&Un(h,()=>fn(`h${g}`))})})),new ze("Numbered List",{icon:x.jsx(Eh,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(eu,void 0)}),new ze("Bulleted List",{icon:x.jsx(vh,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(Qc,void 0)}),new ze("Check List",{icon:x.jsx(Lw,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(Zc,void 0)}),new ze("Table",{icon:x.jsx(yi,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(ws,void 0)}}),new ze("Collapsible Container",{icon:x.jsx(zc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(Gu,void 0)}),new ze("Excalidraw",{icon:x.jsx(Ow,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(nd,void 0)}),new ze("Video",{icon:x.jsx(Wc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(sd,void 0)}),new ze("Loom Video",{icon:x.jsx(Ws,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ka,void 0)}),new ze("Deck Slide",{icon:x.jsx(hs,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(od,void 0)}),new ze("Quote",{icon:x.jsx(Nh,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>Ln())})}),new ze("Code",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const g=D();if(F(g))if(g.isCollapsed())Un(g,()=>Ze());else{const h=g.getTextContent(),_=Ze();g.insertNodes([_]),g.insertRawText(h)}})}),new ze("Divider",{icon:x.jsx(ji,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(Kc,void 0)}),...qu.map(g=>new ze(`Embed ${g.contentName}`,{icon:g.icon,keywords:[...g.keywords,"embed"],onSelect:()=>t.dispatchCommand(Ju,g.type)})),new ze("Equation",{icon:x.jsx(Rw,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",g=>x.jsx(ad,{activeEditor:t,onClose:g}))}),new ze("GIF",{icon:x.jsx(hs,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{yu().then(g=>{g&&t.dispatchCommand(Ys,g)})}}),new ze("Image",{icon:x.jsx(hs,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",g=>x.jsx(z_,{activeEditor:t,onClose:g}))}),...["left","center","right","justify"].map(g=>new ze(`Align ${g}`,{icon:g==="left"?x.jsx(nx,{size:16}):g==="right"?x.jsx(rx,{size:16}):x.jsx(ji,{size:16}),keywords:["align","justify",g],onSelect:()=>t.dispatchCommand(Bn,g)}))],d=l();return s?[...d,...f.filter(g=>new RegExp(s,"gi").exec(g.title)||g.keywords!=null?g.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=S.useCallback((f,d,g,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),g()})},[t]);return x.jsxs(x.Fragment,{children:[r,x.jsx(Jm,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:g,setHighlightedIndex:h})=>f.current&&c.length?St.createPortal(x.jsx(Y,{onMouseDown:_=>{_.preventDefault()},sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1,maxHeight:300,overflow:"auto",minWidth:200},children:x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>x.jsx(TL,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),g(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},yc=4,EL=2,NL="draggable-block-menu",Wg="application/x-lexical-drag-block",Hg=28,LL=1,OL=-1,Jg=0;let Ni=1/0;function RL(n){return n===0?1/0:Ni>=0&&Ni<n?Ni:Math.floor(n/2)}function AL(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function wb(n){const e=(l,c)=>l?parseFloat(window.getComputedStyle(l)[c]):0,{marginTop:t,marginBottom:r}=window.getComputedStyle(n),o=e(n.previousElementSibling,"marginBottom"),s=e(n.nextElementSibling,"marginTop"),i=Math.max(parseFloat(t),o);return{marginBottom:Math.max(parseFloat(r),s),marginTop:i}}function _l(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=AL(e);let i=null;return e.getEditorState().read(()=>{if(r){const[c,u]=[e.getElementByKey(s[0]),e.getElementByKey(s[s.length-1])],[f,d]=[c?.getBoundingClientRect(),u?.getBoundingClientRect()];if(f&&d){const g=Wn(c),h=Wn(u);if(t.y/g<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=RL(s.length),l=Jg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Wn(u),d=new zm(t.x/f,t.y/f),g=pr.fromDOM(u),{marginTop:h,marginBottom:_}=wb(u),m=g.generateNewRect({bottom:g.bottom+_,left:o.left,right:o.right,top:g.top-h}),{result:b,reason:{isOnTopSide:w,isOnBottomSide:C}}=m.contains(d);if(b){i=u,Ni=a;break}l===Jg&&(w?l=OL:C?l=LL:l=1/0),a+=l}}),i}function ML(n){return!!n.closest(`.${NL}`)}function xb(n){const e=window.getComputedStyle(n),t=e.overflowY==="auto"||e.overflowY==="scroll",r=e.overflowX==="auto"||e.overflowX==="scroll";if(t||r)return{element:n,scrollTop:n.scrollTop||0,scrollLeft:n.scrollLeft||0};const o=n.parentElement;if(o){const s=window.getComputedStyle(o),i=s.overflowY==="auto"||s.overflowY==="scroll",a=s.overflowX==="auto"||s.overflowX==="scroll";if(i||a)return{element:o,scrollTop:o.scrollTop||0,scrollLeft:o.scrollLeft||0}}return{element:n,scrollTop:0,scrollLeft:0}}function $L(n,e,t){if(!n){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const r=n.getBoundingClientRect(),o=window.getComputedStyle(n),s=e.getBoundingClientRect(),i=t.getBoundingClientRect(),{scrollTop:a}=xb(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=yc;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function DL(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function PL(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=wb(e),{scrollTop:u}=xb(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-EL+u,g=Hg-yc;n.style.transform=`translate(${g}px, ${d}px)`,n.style.width=`${a-(Hg-yc)*2}px`,n.style.opacity=".4"}function jL(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function FL(n,e,t){const r=S.useRef(null),o=S.useRef(null),s=S.useRef(!1),[i,a]=S.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";S.useEffect(()=>{function g(_){const m=_.target;if(!pl(m)){a(null);return}if(!e.contains(m)||ML(m))return;const b=_l(e,n,_);a(b)}function h(){a(null)}return document.addEventListener("mousemove",g),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseleave",h)}},[e,n]),S.useEffect(()=>{r.current&&$L(i,r.current,e)},[e,i]),S.useEffect(()=>{function g(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{pageY:b,target:w}=_;if(!pl(w))return!1;const C=_l(e,n,_,!0),v=o.current;return C===null||v===null?!1:(PL(v,C,b/Wn(w),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{target:b,dataTransfer:w,pageY:C}=_,v=w?.getData(Wg)||"",k=Q(v);if(!k||!pl(b))return!1;const I=_l(e,n,_,!0);if(!I)return!1;const E=Ae(I);if(!E)return!1;if(E===k)return!0;const N=I.getBoundingClientRect().top;return C/Wn(b)>=N?E.insertAfter(k):E.insertBefore(k),a(null),!0}return de(n.registerCommand(Nc,_=>g(_),ee),n.registerCommand(Lc,_=>h(_),qe))},[e,n]);function f(g){const h=g.dataTransfer;if(!h||!i)return;DL(h,i);let _="";n.update(()=>{const m=Ae(i);m&&(_=m.getKey())}),s.current=!0,h.setData(Wg,_)}function d(){s.current=!1,jL(o.current)}return St.createPortal(x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?x.jsx(Aw,{size:16}):null}),x.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function QM({anchorElem:n=document.body}){const[e]=fe();return FL(e,n,e._editable)}const BL=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function UL(n,e,t,r){const[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState(!1),[u,f]=S.useState(!1),[d,g]=S.useState(!1),[h,_]=S.useState(!1),[m,b]=S.useState(!1),[w,C]=S.useState(!1),[v,k]=S.useState(!1),I=S.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=D(),R=window.getSelection(),$=n.getRootElement();if(R!==null&&(!F(M)||$===null||!$.contains(R.anchorNode))){s(!1);return}if(!F(M))return;const L=Bm(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),g(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),b(M.hasFormat("subscript")),C(M.hasFormat("superscript")),k(M.hasFormat("code"));const A=L.getParent();Pe(A)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);S.useEffect(()=>(document.addEventListener("selectionchange",I),()=>{document.removeEventListener("selectionchange",I)}),[I]),S.useEffect(()=>de(n.registerUpdateListener(()=>{I()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ys,()=>(s(!1),!1),ee)),[n,I]);const E=S.useCallback(()=>{i?(t(!1),n.dispatchCommand(Lr,null)):(t(!0),n.dispatchCommand(Lr,"https://example.com"))},[n,i,t]),N=S.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Lh,isActive:l,onClick:()=>n.dispatchCommand(Xe,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Oh,isActive:u,onClick:()=>n.dispatchCommand(Xe,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:BL,isActive:d,onClick:()=>n.dispatchCommand(Xe,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Rh,isActive:h,onClick:()=>n.dispatchCommand(Xe,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Xe,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:w,onClick:()=>n.dispatchCommand(Xe,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:br,isActive:v,onClick:()=>n.dispatchCommand(Xe,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Ah,isActive:i,onClick:E},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}],[n,l,u,d,h,m,w,v,i,E]),O=o&&!i;return x.jsx(Tx,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function e$({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return UL(r,n,e,t)}function zL(n){return n.registerCommand(Kc,()=>{const e=D();if(!F(e))return!1;if(e.focus.getNode()!==null){const r=ba();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Cb=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[mu],register:zL}),ss={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function KL(n){return n?{code:{...ss.code,...n.code},prose:{...ss.prose,...n.prose},debounceMs:n.debounceMs??ss.debounceMs,manualTriggerKey:n.manualTriggerKey??ss.manualTriggerKey}:{...ss}}function t$(n){return n===-1||n>=0}function n$(n){return n.triggerMode==="auto"}function r$(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function o$(n){return n.triggerMode==="disabled"}const qg="jupyter-cell";class Fr extends Bt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return qg}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Fr(e.__code,e.__outputs,e.__loading,e.__autoStart,e.__data,e.__key,e.__variant)}constructor(e,t,r,o,s="[]",i,a){super(i),this.__code=e,this.__outputs=t,this.__loading=r,this.__autoStart=o,this.__data=s,this.__variant=a}createDOM(e){const t=document.createElement("div"),o=e.theme.image;return o!==void 0&&(t.className=o),ge("createDOM",t),t}updateDOM(){return!1}decorate(e){return ge(`decorate -> key: ${this.getKey()} outputs: ${this.__outputs} data: ${this.__data}`),x.jsx(_x,{source:this.__code,outputs:this.__outputs,autoStart:this.__autoStart,variant:this.__variant})}setCode(e){const t=this.getWritable();t.__code=e}get code(){return this.__code}setOutputs(e){const t=this.getWritable();t.__outputs=e}get outputs(){return this.__outputs}setLoading(e){const t=this.getWritable();t.__loading=e}get loading(){return this.__loading}setAutostart(e){const t=this.getWritable();t.__autoStart=e}get autoStart(){return this.__autoStart}get variant(){return this.__variant}setData(e){const t=this.getWritable();t.__data=e}get data(){return this.__data}static importJSON(e){const t=e;return new Fr(t.code,t.outputs,t.loading,t.autoStart,t.data,void 0,t.variant)}exportJSON(){return{code:this.__code,outputs:this.__outputs,loading:this.__loading,autoStart:this.__autoStart,data:this.__data,variant:this.__variant,type:qg,version:1}}}function Vg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Fr(e,t,r,o)}function s$(n){return n instanceof Fr}const WL=he(),HL=he();function JL(n){if(!n.hasNodes([Fr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(WL,e=>{const t=Vg(e);return Tr([t]),!0},V),n.registerCommand(HL,e=>{const t=Vg({...e});return Tr([t]),!0},V))}const qL=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Fr],register:JL}),VL=he("INSERT_LAYOUT_COMMAND");function YL(n){return n.trim().split(/\s+/).length}function i$(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function GL(n){if(!n.hasNodes([Dr,Pr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=D();if(F(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),Ci);if(Ci(o)){const s=o.getParent(),i=s&&(t?s.getFirstChild():s.getLastChild()),a=t?o.getFirstDescendant()?.getKey():o.getLastDescendant()?.getKey();s!==null&&i===o&&r.anchor.key===a&&(t?o.insertBefore(ne()):o.insertAfter(ne()))}}return!1};return de(n.registerCommand(Vt,()=>e(!1),ee),n.registerCommand(ia,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(zs,()=>e(!0),ee),n.registerCommand(VL,t=>(n.update(()=>{const r=Ou(t);for(let o=0;o<YL(t);o++)r.append(Ru().append(ne()));sr(r),r.selectStart()}),!0),V),n.registerNodeTransform(Pr,t=>{const r=t.getParent();if(!Ci(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(Dr,t=>{const r=t.getChildren();if(!r.every(Au)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const XL=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[Dr,Pr],register:GL});function Yg(n,e,t,r,o){return n==="code"?ZL(e,t):QL(e,t,r,o)}function ZL(n,e){const t=n.getTextContent(),r=nO(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function QL(n,e,t,r){const s=se().getChildren(),i=eO(n);if(!i)return{before:"",after:"",fullText:""};const a=s.indexOf(i);if(a===-1)return{before:"",after:"",fullText:""};const l=t===-1?0:Math.max(0,a-t),c=r===-1?s.length-1:Math.min(s.length-1,a+r);let u="";for(let _=l;_<a;_++)u+=s[_].getTextContent()+`
213
+ `,t}updateDOM(){return!1}static importJSON(e){return hc(e.completionText)}exportJSON(){return{completionText:"",type:"inline-completion",version:1}}static importDOM(){return null}exportDOM(){return{element:null}}getCompletionText(){return this.__completionText}setCompletionText(e){const t=this.getWritable();t.__completionText=e}decorate(){return x.jsx(IN,{completionText:this.__completionText})}isInline(){return!0}isKeyboardSelectable(){return!1}}function hc(n){return new Xs(n)}function ds(n){return n instanceof Xs}function IN({completionText:n}){return x.jsx("span",{className:"inline-completion-text",style:{opacity:.5,color:"var(--vscode-editorSuggestWidget-foreground, #999)",pointerEvents:"none",userSelect:"none",whiteSpace:"pre"},children:n})}const EN=/((https?:\/\/(www\.)?)|(www\.))[-a-zA-Z0-9@:%._+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_+.~#?&//=]*)/,NN=/(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))/,LN=[n=>{const e=EN.exec(n);if(e){const t=e[0].startsWith("http")?e[0]:`https://${e[0]}`;return{index:e.index,length:e[0].length,text:e[0],url:t,attributes:{rel:"noopener noreferrer",target:"_blank"}}}return null},n=>{const e=NN.exec(n);return e?{index:e.index,length:e[0].length,text:e[0],url:`mailto:${e[0]}`}:null}],ON=pe({name:"@datalayer/jupyter-lexical/AutoLink",dependencies:[ln(mC,{matchers:LN})]});function Bm(n){const e=n.anchor,t=n.focus,r=n.anchor.getNode(),o=n.focus.getNode();return r===o?r:n.isBackward()?jd(t)?r:o:jd(e)?o:r}const RN=new Set(["http:","https:","mailto:","sms:","tel:"]);function AN(n){try{const e=new URL(n);if(!RN.has(e.protocol))return"about:blank"}catch{return n}return n}const MN=new RegExp(/((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[\w]*))?)/);function qM(n){return n==="https://"||MN.test(n)}function Um(n,e,t){const r=S.useRef(null);return r.current=n,S.useMemo(()=>Lx((...o)=>{r.current&&r.current(...o)},e,{maxWait:t}),[e,t])}function pl(n){return n instanceof HTMLElement}class zm{_x;_y;constructor(e,t){this._x=e,this._y=t}get x(){return this._x}get y(){return this._y}equals({x:e,y:t}){return this.x===e&&this.y===t}calcDeltaXTo({x:e}){return this.x-e}calcDeltaYTo({y:e}){return this.y-e}calcHorizontalDistanceTo(e){return Math.abs(this.calcDeltaXTo(e))}calcVerticalDistance(e){return Math.abs(this.calcDeltaYTo(e))}calcDistanceTo(e){return Math.sqrt(Math.pow(this.calcDeltaXTo(e),2)+Math.pow(this.calcDeltaYTo(e),2))}}function $N(n){return n instanceof zm}class pr{_left;_top;_right;_bottom;constructor(e,t,r,o){const[s,i]=t<=o?[t,o]:[o,t],[a,l]=e<=r?[e,r]:[r,e];this._top=s,this._right=l,this._left=a,this._bottom=i}get top(){return this._top}get right(){return this._right}get bottom(){return this._bottom}get left(){return this._left}get width(){return Math.abs(this._left-this._right)}get height(){return Math.abs(this._bottom-this._top)}equals({top:e,left:t,bottom:r,right:o}){return e===this._top&&r===this._bottom&&t===this._left&&o===this._right}contains(e){if($N(e)){const{x:t,y:r}=e,o=r<this._top,s=r>this._bottom,i=t<this._left,a=t>this._right;return{reason:{isOnBottomSide:s,isOnLeftSide:i,isOnRightSide:a,isOnTopSide:o},result:!o&&!s&&!i&&!a}}else{const{top:t,left:r,bottom:o,right:s}=e;return t>=this._top&&t<=this._bottom&&o>=this._top&&o<=this._bottom&&r>=this._left&&r<=this._right&&s>=this._left&&s<=this._right}}intersectsWith(e){const{left:t,top:r,width:o,height:s}=e,{left:i,top:a,width:l,height:c}=this,u=t+o>=i+l?t+o:i+l,f=r+s>=a+c?r+s:a+c,d=t<=i?t:i,g=r<=a?r:a;return u-d<=o+l&&f-g<=s+c}generateNewRect({left:e=this.left,top:t=this.top,right:r=this.right,bottom:o=this.bottom}){return new pr(e,t,r,o)}static fromLTRB(e,t,r,o){return new pr(e,t,r,o)}static fromLWTH(e,t,r,o){return new pr(e,r,e+t,r+o)}static fromPoints(e,t){const{y:r,x:o}=e,{y:s,x:i}=t;return pr.fromLTRB(o,r,i,s)}static fromDOM(e){const{top:t,width:r,left:o,height:s}=e.getBoundingClientRect();return pr.fromLWTH(o,r,t,s)}}const Gi=new Map,$s=new Map,_c=new Set;function Ii(n,e){e?Gi.set(n,e):Gi.delete(n),_c.forEach(t=>t())}function DN(n){return _c.add(n),()=>_c.delete(n)}function PN(n){return Gi.get(n)}function jN(){return typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID():`video-${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function FN(){return typeof MediaRecorder<"u"&&typeof navigator<"u"&&!!navigator.mediaDevices}function BN(){if(!(typeof MediaRecorder>"u"))return["video/webm;codecs=vp9,opus","video/webm;codecs=vp8,opus","video/webm","video/mp4"].find(n=>MediaRecorder.isTypeSupported(n))}function UN(n){const e=new Date().toISOString().slice(0,19).replace(/[:T]/g,"-"),t=n.mimeType.startsWith("video/mp4")?"mp4":"webm";return`recording-${e}.${t}`}function zN(n){const e=n instanceof DOMException?n.name:"";return e==="NotAllowedError"?"Recording did not start: the browser was not allowed to capture.":e==="NotFoundError"?"Recording did not start: there is no camera or microphone to record.":`Recording did not start: ${n instanceof Error?n.message:String(n)}`}function KN(n){if(n.length<=1)return{track:n[0],close:()=>{}};const e=new AudioContext,t=e.createMediaStreamDestination();for(const r of n)e.createMediaStreamSource(new MediaStream([r])).connect(t);return{track:t.stream.getAudioTracks()[0],close:()=>{e.close()}}}async function WN(n,{source:e,microphone:t},r){const o=[],s=()=>o.forEach(i=>i.getTracks().forEach(a=>a.stop()));try{const i=navigator.mediaDevices;let a;const l=[];if(e==="screen"){const m=await i.getDisplayMedia({video:!0,audio:!0});if(o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks()),t){const b=await i.getUserMedia({audio:!0}).catch(()=>{});b&&(o.push(b),l.push(...b.getAudioTracks()))}}else{const m=await i.getUserMedia({video:!0,audio:t});o.push(m),a=m.getVideoTracks()[0],l.push(...m.getAudioTracks())}if(!a)throw new Error("there was no picture to record");const c=KN(l),u=new MediaStream(c.track?[a,c.track]:[a]),f=BN(),d=new MediaRecorder(u,f?{mimeType:f}:void 0),g=[],h=Date.now();d.ondataavailable=m=>{m.data.size>0&&g.push(m.data)};const _=()=>{s(),c.close()};d.onstop=()=>{_(),$s.delete(n);const m=d.mimeType||f||"video/webm",b=new Blob(g,{type:m}),w={status:"recorded",url:URL.createObjectURL(b),blob:b,mimeType:m,durationMs:Date.now()-h};Ii(n,w),r?.(w)},a.addEventListener("ended",()=>Vu(n)),$s.set(n,{recorder:d,release:_}),d.start(1e3),Ii(n,{status:"recording",startedAt:h,preview:new MediaStream([a])})}catch(i){s(),Ii(n,{status:"failed",message:zN(i)})}}function Vu(n){const e=$s.get(n);e&&e.recorder.state!=="inactive"&&e.recorder.stop()}function HN(n){const e=$s.get(n);e&&(e.recorder.onstop=null,e.recorder.state!=="inactive"&&e.recorder.stop(),e.release(),$s.delete(n));const t=Gi.get(n);t?.status==="recorded"&&URL.revokeObjectURL(t.url),Ii(n,void 0)}function JN(n,e){return e?e.status:n?"lost":"idle"}const Yu=j_?S.useLayoutEffect:S.useEffect;function qN({editor:n,getCodeDOMNode:e}){const[t,r]=S.useState(!1),o=Um(()=>{r(!1)},1e3);async function s(){const i=e();if(!i)return;let a="";n.update(()=>{const l=Ae(i);je(l)&&(a=l.getTextContent());const c=D();Ee(c)});try{await navigator.clipboard.writeText(a),r(!0),o()}catch(l){console.error("Failed to copy: ",l)}}return x.jsx(Ft,{icon:t?xh:pw,size:"small",variant:"invisible",onClick:s,"aria-label":"copy",sx:t?{color:"var(--fgColor-success)"}:void 0})}const VN=8;function YN({anchorElem:n}){const[e]=fe(),[t,r]=S.useState(""),[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState({right:"0",top:"0"}),u=S.useRef(new Set),f=S.useRef(null);function d(){return f.current}const g=Um(m=>{const{codeDOMNode:b,isOutside:w}=XN(m);if(w){s(!1);return}if(!b)return;f.current=b;let C=null,v="";if(e.update(()=>{const k=Ae(b);je(k)&&(C=k,v=C.getLanguage()||"")}),C){const{y:k,right:I}=n.getBoundingClientRect(),{y:E,right:N}=b.getBoundingClientRect();r(v),s(!0),c({right:`${I-N+VN}px`,top:`${E-k}px`})}},50,1e3);S.useEffect(()=>{if(i)return document.addEventListener("mousemove",g),()=>{s(!1),g.cancel(),document.removeEventListener("mousemove",g)}},[i,g]),S.useEffect(()=>e.registerMutationListener(dn,m=>{e.getEditorState().read(()=>{for(const[b,w]of m)switch(w){case"created":u.current.add(b);break;case"destroyed":u.current.delete(b);break}}),a(u.current.size>0)},{skipInitialization:!1}),[e]);const h=C0(t),_=x0(t);return x.jsx(x.Fragment,{children:o?x.jsxs("div",{className:"code-action-menu-container",style:{...l},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)",alignSelf:"center",px:1},children:_}),x.jsx(qN,{editor:e,getCodeDOMNode:d}),E0(h)?x.jsx(L0,{editor:e,getCodeDOMNode:d,lang:h}):null]}):null})}function XN(n){const e=n.target;if(ke(e)){const t=e.closest("code.JupyterLexicalTheme__code"),r=!(t||e.closest("div.code-action-menu-container"));return{codeDOMNode:t,isOutside:r}}else return{codeDOMNode:null,isOutside:!0}}function VM({anchorElem:n=document.body}){return St.createPortal(x.jsx(YN,{anchorElem:n}),n)}function Og(n,e){const t=e.getElementByKey(n.getKey());if(t===null)return;const r=n.getChildren(),o=r.length;if(o===t.__cachedChildrenLength)return;t.__cachedChildrenLength=o;let s="1",i=1;for(let a=0;a<o;a++)ue(r[a])&&(s+=`
214
+ `+ ++i);t.setAttribute("data-gutter",s)}function Km(n){const e=[];if(n instanceof dn&&e.push(n),q(n))for(const t of n.getChildren())q(t)&&e.push(...Km(t));return e}function GN(n){const e=de(S0(n),n.registerNodeTransform(dn,t=>{Og(t,n)}));return n.getEditorState().read(()=>{for(const t of Km(se()))Og(t,n)}),e}const ZN=pe({name:"@datalayer/jupyter-lexical/CodeBlockHighlight",dependencies:[Vh],register:GN}),Xu=he("INSERT_COLLAPSIBLE_COMMAND"),Rg=()=>{const n=D();if(F(n)&&n.isCollapsed()&&n.anchor.offset===0){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();t!==null&&t.getFirstChild()===e&&n.anchor.key===e.getFirstDescendant()?.getKey()&&e.insertBefore(ne())}}return!1},Ag=()=>{const n=D();if(F(n)&&n.isCollapsed()){const e=re(n.anchor.getNode(),Pt);if(Pt(e)){const t=e.getParent();if(t!==null&&t.getLastChild()===e){const r=e.getFirstDescendant(),o=e.getLastDescendant();(o!==null&&n.anchor.key===o.getKey()&&n.anchor.offset===o.getTextContentSize()||r!==null&&n.anchor.key===r.getKey()&&n.anchor.offset===r.getTextContentSize())&&e.insertAfter(ne())}}}return!1};function QN(n){if(!n.hasNodes([Mr,Os,$r]))throw new Error("CollapsiblePlugin: CollapsibleContainerNode, CollapsibleTitleNode, or CollapsibleContentNode not registered on editor");return de(n.registerNodeTransform($r,e=>{const t=e.getParent();if(!Pt(t)){const r=e.getChildren();for(const o of r)e.insertBefore(o);e.remove()}}),n.registerNodeTransform(Os,e=>{const t=e.getParent();if(!Pt(t)){e.replace(ne().append(...e.getChildren()));return}}),n.registerNodeTransform(Mr,e=>{const t=e.getChildren();if(t.length!==2||!xi(t[0])||!Lu(t[1])){for(const r of t)e.insertBefore(r);e.remove()}}),n.registerCommand(Vt,Ag,ee),n.registerCommand(ia,Ag,ee),n.registerCommand(pt,Rg,ee),n.registerCommand(zs,Rg,ee),n.registerCommand(Lo,()=>{const e=D();if(F(e)){const t=re(e.anchor.getNode(),r=>xi(r));if(xi(t)){const r=t.getParent();if(r&&Pt(r))return r.getOpen()||r.toggleOpen(),t.getNextSibling()?.selectEnd(),!0}}return!1},ee),n.registerCommand(Xu,()=>(n.update(()=>{const e=Z_(),t=ne();sr(Eu(!0).append(e.append(t),Nu().append(ne()))),t.select()}),!0),ee))}const e2=pe({name:"@datalayer/jupyter-lexical/Collapsible",nodes:()=>[Mr,Os,$r],register:QN}),t2=qn?S.useLayoutEffect:S.useEffect;class Wm{key;ref;icon;title;constructor(e){this.key=e,this.ref={current:null},this.setRefElement=this.setRefElement.bind(this)}setRefElement(e){this.ref={current:e}}}const Mg=n=>{const e=n.closest("#typeahead-menu");if(!e)return;const t=e.getBoundingClientRect();t.top+t.height>window.innerHeight&&e.scrollIntoView({block:"center"}),t.top<0&&e.scrollIntoView({block:"center"}),n.scrollIntoView({block:"nearest"})};function $g(n,e){const t=n.getBoundingClientRect(),r=e.getBoundingClientRect();return t.top>=r.top-6&&t.top<=r.bottom+6}function n2(n,e,t,r){const[o]=fe();S.useEffect(()=>{if(e!=null&&n!=null){const s=o.getRootElement(),i=s!=null?bh(s,!1):document.body;let a=!1,l=$g(e,i);const c=function(){a||(window.requestAnimationFrame(function(){t(),a=!1}),a=!0);const d=$g(e,i);d!==l&&(l=d,r?.(d))},u=new ResizeObserver(t),f=yh(s??e);return u.observe(e),de(Jt(window,"resize",t),Jt(document,"scroll",c,{capture:!0,passive:!0}),...f.map(d=>Jt(d,"scroll",c,{capture:!0,passive:!0})),()=>u.unobserve(e))}},[e,o,r,t,n])}const Dg=he("SCROLL_TYPEAHEAD_OPTION_INTO_VIEW_COMMAND");function r2({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){let s="item";return e&&(s+=" selected"),x.jsxs("li",{tabIndex:-1,className:s,ref:o.setRefElement,role:"option","aria-selected":e,id:"typeahead-item-"+n,onMouseEnter:r,onClick:t,children:[o.icon,x.jsx("span",{className:"text",children:o.title})]},o.key)}function o2({close:n,editor:e,anchorElementRef:t,resolution:r,options:o,menuRenderFn:s,onSelectOption:i,shouldSplitNodeWithQuery:a=!1,commandPriority:l=ee,preselectFirstItem:c=!0}){const[u,f]=S.useState(null),d=u!==null?Math.min(o.length-1,u):null,g=r.match&&r.match.matchingString;S.useEffect(()=>{c&&f(0)},[g,c]);const h=S.useCallback(w=>{e.update(()=>{const C=r.match!=null&&a?(function(v){const k=D();if(!F(k)||!k.isCollapsed())return null;const I=k.anchor;if(I.type!=="text")return null;const E=I.getNode();if(!E.isSimpleText())return null;const N=I.offset,O=E.getTextContent().slice(0,N),M=v.replaceableString.length,R=N-(function(L,A,B){let j=B;for(let U=j;U<=A.length;U++)L.slice(-U)===A.substring(0,U)&&(j=U);return j})(O,v.matchingString,M);if(R<0)return null;let $;return R===0?[$]=E.splitText(N):[,$]=E.splitText(R,N),$})(r.match):null;i(w,C,n,r.match?r.match.matchingString:"")})},[e,a,r.match,i,n]),_=S.useCallback(w=>{const C=e.getRootElement();C!==null&&(C.setAttribute("aria-activedescendant","typeahead-item-"+w),f(w))},[e]),m=S.useCallback(()=>t.current&&o.length?wh.createPortal(x.jsx("div",{className:"typeahead-popover mentions-menu",children:x.jsx("ul",{children:o.map((w,C)=>x.jsx(r2,{index:C,isSelected:d===C,onClick:()=>{f(C),h(w)},onMouseEnter:()=>{f(C)},option:w},w.key))})}),t.current):null,[t,o,d,h,f]);S.useEffect(()=>()=>{const w=e.getRootElement();w!==null&&w.removeAttribute("aria-activedescendant")},[e]),t2(()=>{o===null?f(null):d===null&&c&&_(0)},[o,d,_,c]),S.useEffect(()=>de(e.registerCommand(Dg,({option:w})=>!(!w.ref||w.ref.current==null)&&(Mg(w.ref.current),!0),l)),[e,_,l]),S.useEffect(()=>de(e.registerCommand(Vt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?0:d!==o.length-1?d+1:0;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&e.dispatchCommand(Dg,{index:v,option:k}),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(pt,w=>{const C=w;if(o!==null&&o.length){const v=d===null?o.length-1:d!==0?d-1:o.length-1;_(v);const k=o[v];if(!k)return _(-1),C.preventDefault(),C.stopImmediatePropagation(),!0;k.ref&&k.ref.current&&Mg(k.ref.current),C.preventDefault(),C.stopImmediatePropagation()}return!0},l),e.registerCommand(Nn,w=>{const C=w;return C.preventDefault(),C.stopImmediatePropagation(),n(),!0},l),e.registerCommand(Kr,w=>{const C=w;return o!==null&&d!==null&&o[d]!=null&&(C.preventDefault(),C.stopImmediatePropagation(),h(o[d]),!0)},l),e.registerCommand(zr,w=>!(o===null||d===null||o[d]==null||w&&w.shiftKey)&&(w!==null&&(w.preventDefault(),w.stopImmediatePropagation()),h(o[d]),!0),l)),[h,n,e,o,d,_,l]);const b=S.useMemo(()=>({options:o,selectOptionAndCleanUp:h,selectedIndex:d,setHighlightedIndex:f}),[h,d,o]);return s!=null?s(t,b,r.match?r.match.matchingString:""):m()}function Pg(n,e){e!=null&&(n.className=e),n.setAttribute("aria-label","Typeahead menu"),n.setAttribute("role","listbox"),n.style.display="block",n.style.position="absolute"}function s2(n,e,t,r,o=!0){const[s]=fe(),i=r??(function(f){if(!qn)return;const d=f.getRootElement();if(d!==null){const g=d.getRootNode();return jc(g)?g:d.ownerDocument.body}return document.body})(s),a=qn?mh(s.getRootElement()).createElement("div"):null,l=S.useRef(a),c=S.useCallback(()=>{if(l.current===null||i===void 0)return;l.current.style.top=l.current.style.bottom;const f=s.getRootElement(),d=l.current,g=d.firstChild;if(f!==null&&n!==null){const{left:h,top:_,width:m,height:b}=n.getRect(),w=l.current.offsetHeight;if(d.style.top=`${_+w+3+(o?window.pageYOffset:0)}px`,d.style.left=`${h+window.pageXOffset}px`,d.style.height=`${b}px`,d.style.width=`${m}px`,g!==null){g.style.top=`${_}`;const C=g.getBoundingClientRect(),v=C.height,k=C.width,I=f.getBoundingClientRect();h+k>I.right&&(d.style.left=`${I.right-k+window.pageXOffset}px`),(_+v>window.innerHeight||_+v>I.bottom)&&_-I.top>v+b&&(d.style.top=`${_-v-b+(o?window.pageYOffset:0)}px`)}d.isConnected||(Pg(d,t),i.append(d)),d.setAttribute("id","typeahead-menu"),f.setAttribute("aria-controls","typeahead-menu")}},[s,n,o,t,i]);S.useEffect(()=>{const f=s.getRootElement();return n!==null&&c(),()=>{f!==null&&f.removeAttribute("aria-controls");const d=l.current;d!==null&&d.isConnected&&(d.remove(),d.removeAttribute("id"))}},[s,c,n]);const u=S.useCallback(f=>{n!==null&&(f||e(null))},[n,e]);return n2(n,l.current,c,u),a!=null&&a===l.current&&(Pg(a,t),i?.append(a)),l}const i2=`\\.,\\+\\*\\?\\$\\@\\|#{}\\(\\)\\^\\-\\[\\]\\\\/!%'"~=<>_:;`;function Hm(n,{minLength:e=1,maxLength:t=75,punctuation:r=i2,allowWhitespace:o=!1}){return S.useCallback(s=>{const i=new RegExp("(^|\\s|\\()(["+n+"]((?:"+("[^"+n+r+(o?"":"\\s")+"]")+"){0,"+t+"}))$").exec(s);if(i!==null){const a=i[1],l=i[3];if(l.length>=e)return{leadOffset:i.index+a.length,matchingString:l,replaceableString:i[2]}}return null},[o,n,r,t,e])}function Jm({options:n,onQueryChange:e,onSelectOption:t,onOpen:r,onClose:o,menuRenderFn:s,triggerFn:i,anchorClassName:a,commandPriority:l=ee,parent:c,preselectFirstItem:u=!0,ignoreEntityBoundary:f=!1}){const[d]=fe(),[g,h]=S.useState(null),_=s2(g,h,a,c),m=S.useCallback(()=>{if(g===null)return;const w=()=>{h(null)};let C;try{C=o&&o()}finally{C?C.then(w,w):w()}},[o,g]),b=S.useCallback(w=>{h(w),r!=null&&g===null&&r(w)},[r,g]);return S.useEffect(()=>{const w=d.registerUpdateListener(()=>{d.read("latest",()=>{if(!d.isEditable())return void m();if(d.isComposing())return;const C=d._window||window,v=C.document.createRange(),k=D(),I=(function(N){let O=null;return N.read("latest",()=>{const M=D();F(M)&&(O=(function(R){const $=R.anchor;if($.type!=="text")return null;const L=$.getNode();if(!L.isSimpleText())return null;const A=$.offset;return L.getTextContent().slice(0,A)})(M))}),O})(d);if(!F(k)||!k.isCollapsed()||I===null||v===null)return void m();const E=i(I,d);if(e(E?E.matchingString:null),E!==null&&(f||!(function(N,O){return O===0&&N.read("latest",()=>{const M=D();if(F(M)){const R=M.anchor.getNode().getPreviousSibling();return oe(R)&&R.isTextEntity()}return!1})})(d,E.leadOffset))&&(function(O,M,R,$){const L=or(R);if(L===null||!L.isCollapsed)return!1;const A=Pc(L,$),B=A.anchorNode,j=O,U=A.anchorOffset;if(B==null||U==null)return!1;try{M.setStart(B,j),M.setEnd(B,U)}catch{return!1}return!0})(E.leadOffset,v,C,d.getRootElement())!==null)return void S.startTransition(()=>b({getRect:()=>v.getBoundingClientRect(),match:E}));m()})});return()=>{w()}},[d,i,e,g,m,b,f]),S.useEffect(()=>d.registerEditableListener(w=>{w||m()}),[d,m]),g===null||d===null||_.current===null?null:x.jsx(o2,{close:m,resolution:g,editor:d,anchorElementRef:_,options:n,menuRenderFn:s,shouldSplitNodeWithQuery:!0,onSelectOption:t,commandPriority:l,preselectFirstItem:u})}const a2=n=>n.split(/[\s._-]+/).filter(Boolean).slice(0,2).map(e=>e[0].toUpperCase()).join("")||"?";function l2({author:n,size:e}){const t=Jc(n);return n.avatarUrl?x.jsx(ax,{src:n.avatarUrl,size:e,alt:t}):x.jsx(Y,{as:"span","aria-hidden":!0,title:t,sx:{display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:e,height:e,borderRadius:"50%",bg:"neutral.muted",color:"fg.muted",fontSize:`${Math.round(e*.45)}px`,fontWeight:"bold"},children:n.kind==="anonymous"?x.jsx(hw,{size:Math.round(e*.65)}):a2(t)})}const jr=S.createContext({}),c2=[],u2=250;function qm(n){const{searchPeople:e}=S.useContext(jr),[t,r]=S.useState(null);return S.useEffect(()=>{if(!e||!n)return;let o=!0;const s=setTimeout(()=>{e(n).then(i=>{o&&r({query:n,people:i})},()=>{o&&r({query:n,people:[]})})},u2);return()=>{o=!1,clearTimeout(s)}},[n,e]),t&&t.query===n?t.people:c2}class d2 extends Wm{person;constructor(e){super(e.uid),this.person=e}}function f2({onMention:n}){const[e]=fe(),{searchPeople:t}=S.useContext(jr),[r,o]=S.useState(null),s=qm(r),i=S.useMemo(()=>s.map(c=>new d2(c)),[s]),a=Hm("@",{minLength:1}),l=S.useCallback((c,u,f)=>{e.update(()=>{const d=$e(`@${wo(c.person)} `);u&&u.replace(d),d.select(),f()}),n(c.person)},[e,n]);return t?x.jsx(Jm,{onQueryChange:o,onSelectOption:l,triggerFn:a,options:i,menuRenderFn:(c,{selectedIndex:u,selectOptionAndCleanUp:f,setHighlightedIndex:d})=>c.current&&i.length>0?St.createPortal(x.jsx(Y,{as:"ul",role:"listbox","aria-label":"People to mention",sx:{position:"relative",zIndex:1e3,listStyle:"none",m:0,p:1,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",minWidth:200},children:i.map((g,h)=>x.jsxs(Y,{as:"li",role:"option","aria-selected":u===h,ref:_=>g.setRefElement(_),onMouseEnter:()=>d(h),onClick:()=>{d(h),f(g)},sx:{px:2,py:1,borderRadius:1,cursor:"pointer",bg:u===h?"actionListItem.default.hoverBg":"transparent"},children:[x.jsx(Le,{children:wo(g.person)}),g.person.handle?x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",ml:1},children:["@",g.person.handle]}):null]},g.key))}),c.current):null}):null}function g2({thread:n}){const{searchPeople:e,assignThread:t}=S.useContext(jr),[r,o]=S.useState(!1),[s,i]=S.useState(""),a=qm(r&&s.trim()?s.trim():null),l=n.assignee??null;if(!t||!e)return l?x.jsxs(Le,{as:"p",sx:{fontSize:0,color:"var(--fgColor-muted)",m:0,mt:1},children:["Assigned to ",wo(l)]}):null;const c=u=>{t(n,u),o(!1),i("")};return x.jsxs(Y,{sx:{mt:1},onClick:u=>u.stopPropagation(),children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1},children:[x.jsx(Le,{sx:{fontSize:0,color:"var(--fgColor-muted)"},children:l?`Assigned to ${wo(l)}`:"Not assigned"}),x.jsx(Ft,{icon:ex,"aria-label":"Assign thread",variant:"invisible",size:"small",onClick:()=>o(!r)}),l?x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(null),children:"Unassign"}):null]}),r?x.jsxs(Y,{sx:{mt:1},children:[x.jsx(vn,{"aria-label":"Find a person to assign",placeholder:"Name or handle",size:"small",block:!0,autoFocus:!0,value:s,onChange:u=>i(u.target.value)}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:1},children:a.map(u=>x.jsx(Y,{as:"li",children:x.jsx(ft,{variant:"invisible",size:"small",onClick:()=>c(u),children:wo(u)})},u.uid))})]}):null]})}const p2={characterLimit:"JupyterLexicalTheme__characterLimit",code:"JupyterLexicalTheme__code",codeHighlight:{atrule:"JupyterLexicalTheme__tokenAttr",attr:"JupyterLexicalTheme__tokenAttr",boolean:"JupyterLexicalTheme__tokenProperty",builtin:"JupyterLexicalTheme__tokenSelector",cdata:"JupyterLexicalTheme__tokenComment",char:"JupyterLexicalTheme__tokenSelector",class:"JupyterLexicalTheme__tokenFunction","class-name":"JupyterLexicalTheme__tokenFunction",comment:"JupyterLexicalTheme__tokenComment",constant:"JupyterLexicalTheme__tokenProperty",deleted:"JupyterLexicalTheme__tokenProperty",doctype:"JupyterLexicalTheme__tokenComment",entity:"JupyterLexicalTheme__tokenOperator",function:"JupyterLexicalTheme__tokenFunction",important:"JupyterLexicalTheme__tokenVariable",inserted:"JupyterLexicalTheme__tokenSelector",keyword:"JupyterLexicalTheme__tokenAttr",namespace:"JupyterLexicalTheme__tokenVariable",number:"JupyterLexicalTheme__tokenProperty",operator:"JupyterLexicalTheme__tokenOperator",prolog:"JupyterLexicalTheme__tokenComment",property:"JupyterLexicalTheme__tokenProperty",punctuation:"JupyterLexicalTheme__tokenPunctuation",regex:"JupyterLexicalTheme__tokenVariable",selector:"JupyterLexicalTheme__tokenSelector",string:"JupyterLexicalTheme__tokenSelector",symbol:"JupyterLexicalTheme__tokenProperty",tag:"JupyterLexicalTheme__tokenProperty",url:"JupyterLexicalTheme__tokenOperator",variable:"JupyterLexicalTheme__tokenVariable"},embedBlock:{base:"JupyterLexicalTheme__embedBlock",focus:"JupyterLexicalTheme__embedBlockFocus"},hashtag:"JupyterLexicalTheme__hashtag",heading:{h1:"JupyterLexicalTheme__h1",h2:"JupyterLexicalTheme__h2",h3:"JupyterLexicalTheme__h3",h4:"JupyterLexicalTheme__h4",h5:"JupyterLexicalTheme__h5",h6:"JupyterLexicalTheme__h6"},image:"editor-image",link:"JupyterLexicalTheme__link",list:{listitem:"JupyterLexicalTheme__listItem",listitemChecked:"JupyterLexicalTheme__listItemChecked",listitemUnchecked:"JupyterLexicalTheme__listItemUnchecked",nested:{listitem:"JupyterLexicalTheme__nestedListItem"},olDepth:["JupyterLexicalTheme__ol1","JupyterLexicalTheme__ol2","JupyterLexicalTheme__ol3","JupyterLexicalTheme__ol4","JupyterLexicalTheme__ol5"],ul:"JupyterLexicalTheme__ul"},ltr:"JupyterLexicalTheme__ltr",mark:"JupyterLexicalTheme__mark",markOverlap:"JupyterLexicalTheme__markOverlap",layoutContainer:"JupyterLexicalTheme__layoutContainer",layoutItem:"JupyterLexicalTheme__layoutItem",paragraph:"JupyterLexicalTheme__paragraph",quote:"JupyterLexicalTheme__quote",rtl:"JupyterLexicalTheme__rtl",table:"JupyterLexicalTheme__table",tableCell:"JupyterLexicalTheme__tableCell",tableCellHeader:"JupyterLexicalTheme__tableCellHeader",text:{bold:"JupyterLexicalTheme__textBold",code:"JupyterLexicalTheme__textCode",italic:"JupyterLexicalTheme__textItalic",strikethrough:"JupyterLexicalTheme__textStrikethrough",subscript:"JupyterLexicalTheme__textSubscript",superscript:"JupyterLexicalTheme__textSuperscript",underline:"JupyterLexicalTheme__textUnderline",underlineStrikethrough:"JupyterLexicalTheme__textUnderlineStrikethrough"}},h2={...p2,paragraph:"CommentEditorTheme__paragraph"},ys=he();function _2({anchorKey:n,editor:e,onAddComment:t}){const r=S.useRef(null),o=S.useCallback(()=>{const s=r.current,i=e.getRootElement(),a=e.getElementByKey(n);if(s!==null&&i!==null&&a!==null){const{right:l}=i.getBoundingClientRect(),{top:c}=a.getBoundingClientRect();s.style.left=`${l-20}px`,s.style.top=`${c-30}px`}},[n,e]);return S.useEffect(()=>(window.addEventListener("resize",o),()=>{window.removeEventListener("resize",o)}),[e,o]),Yu(()=>{o()},[n,e,o]),x.jsx(Y,{ref:r,sx:{position:"absolute",zIndex:10},children:x.jsx(Ft,{icon:Pi,"aria-label":"Add comment",variant:"invisible",size:"small",onClick:t})})}const Vm=pe({name:"@datalayer/jupyter-lexical/CommentComposer",namespace:"Commenting",theme:h2,dependencies:[Cw,Sh,Sw]}),m2=pe({name:"@datalayer/jupyter-lexical/CommentComposer/Focused",dependencies:[Vm,vw]});function b2({editorRef:n}){const[e]=fe();return Yu(()=>(n.current=e,()=>{n.current=null}),[e,n]),null}function y2({onEscape:n}){const[e]=fe();return S.useEffect(()=>e.registerCommand(Nn,t=>n(t),2),[e,n]),null}function Ym({style:n,autoFocus:e,onEscape:t,onChange:r,onMention:o,editorRef:s,placeholder:i="Type a comment..."}){const a=e===!1?Vm:m2;return x.jsx(ww,{extension:a,contentEditable:null,children:x.jsxs(Y,{sx:{position:"relative",m:"10px",borderRadius:2},children:[x.jsx(Ap,{className:"ContentEditable__root",style:n,placeholder:x.jsx(Bh,{children:i}),"aria-placeholder":i}),x.jsx(xw,{onChange:r}),x.jsx(y2,{onEscape:t}),o!==void 0&&x.jsx(f2,{onMention:o}),s!==void 0&&x.jsx(b2,{editorRef:s})]})})}function Xm(n,e){return S.useCallback((t,r)=>{t.read(()=>{n(bw()),e(!yw(r.isComposing(),!0))})},[e,n])}const jg=256;function w2({editor:n,cancelAddComment:e,submitAddComment:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),[a,l]=S.useState(null),c=S.useRef(null),u=S.useMemo(()=>({container:document.createElement("div"),elements:[]}),[]),f=Zm(),d=S.useCallback(()=>{n.getEditorState().read(()=>{const C=D();if(F(C)){const v=C.anchor,k=C.focus,I=fh(n,v.getNode(),v.offset,k.getNode(),k.offset);if(I!==null){const{left:E,bottom:N,width:O}=I.getBoundingClientRect(),M=Ml(n,I);let R=M.length===1?E+O/2-jg/2:E-jg/2;R<10&&(R=10),l({left:R,top:N+20});const $=M.length,{container:L}=u,A=u.elements,B=A.length;for(let j=0;j<$;j++){const U=M[j];let z=A[j];z===void 0&&(z=document.createElement("span"),A[j]=z,L.appendChild(z));const H=`position:absolute;top:${U.top}px;left:${U.left}px;height:${U.height}px;width:${U.width}px;background-color:var(--bgColor-attention-muted, rgba(255, 212, 0, 0.3));pointer-events:none;z-index:5;`;z.style.cssText=H}for(let j=B-1;j>=$;j--){const U=A[j];L.removeChild(U),A.pop()}}}})},[n,u]);Yu(()=>{c.current=n.getRootElement(),d();const C=u.container,v=document.body;if(v!==null)return v.appendChild(C),()=>{v.removeChild(C)}},[n,u.container,d]),S.useEffect(()=>(window.addEventListener("resize",d),()=>{window.removeEventListener("resize",d)}),[d]);const g=C=>(C.preventDefault(),e(),!0),h=S.useRef(new Map),_=S.useCallback(C=>{h.current.set(C.uid,C)},[]),m=()=>{if(s){let C=n.getEditorState().read(()=>{const v=D();return v!==null?v.getTextContent():""});C.length>100&&(C=C.slice(0,99)+"…"),t(Px(C,[Ph(r,f,void 0,void 0,void 0,$h(r,h.current.values()))]),!0)}},b=Xm(o,i),w=C=>{const v=C.target;v instanceof HTMLElement&&v.closest('[role="listbox"]')||e()};return a===null?null:x.jsxs(kl,{role:"dialog","aria-label":"Add a comment",width:"small",position:"fixed",left:a.left,top:a.top,onEscape:e,onClickOutside:w,returnFocusRef:c,preventFocusOnOpen:!0,children:[x.jsx(Ym,{style:{position:"relative",border:"1px solid var(--borderColor-default)",backgroundColor:"var(--bgColor-default)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"80px"},onEscape:g,onChange:b,onMention:_}),x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:2,px:2,pb:2},children:[x.jsx(ft,{onClick:e,variant:"invisible",size:"small",children:"Cancel"}),x.jsx(ft,{onClick:m,disabled:!s,variant:"primary",size:"small",children:"Comment"})]})]})}function x2({submitAddComment:n,thread:e,placeholder:t}){const[r,o]=S.useState(""),[s,i]=S.useState(!1),a=S.useRef(null),l=Zm(),c=S.useRef(new Map),u=S.useCallback(g=>{c.current.set(g.uid,g)},[]),f=Xm(o,i),d=()=>{if(s){n(Ph(r,l,void 0,void 0,void 0,$h(r,c.current.values())),!1,e),c.current.clear();const g=a.current;g!==null&&g.dispatchCommand(Tw,void 0)}};return x.jsxs(x.Fragment,{children:[x.jsx(Ym,{style:{position:"relative",border:"1px solid",borderColor:"var(--borderColor-default, #ccc)",backgroundColor:"var(--bgColor-default, #fff)",borderRadius:"6px",fontSize:"15px",caretColor:"var(--fgColor-default)",display:"block",padding:"9px 10px 10px 9px",minHeight:"20px"},autoFocus:!1,onEscape:()=>!0,onChange:f,onMention:u,editorRef:a,placeholder:t}),x.jsx(Ft,{icon:kw,"aria-label":"Send comment",variant:"invisible",size:"small",onClick:d,disabled:!s})]})}function Gm({commentOrThread:n,deleteCommentOrThread:e,onClose:t,thread:r=void 0}){return x.jsxs(x.Fragment,{children:["Are you sure you want to delete this ",n.type,"?",x.jsxs(Y,{sx:{display:"flex",gap:2,justifyContent:"flex-end",mt:3},children:[x.jsx(ft,{variant:"invisible",onClick:()=>{t()},children:"Cancel"}),x.jsx(ft,{variant:"danger",onClick:()=>{e(n,r),t()},children:"Delete"})]})]})}function C2(n,e){const t=Math.round((e-Date.now())/1e3);if(t>-10)return"Just now";const r=Math.round(t/60);if(r>-60)return n.format(r,"minute");const o=Math.round(r/60);return o>-24?n.format(o,"hour"):n.format(Math.round(o/24),"day")}function Fg({comment:n,deleteComment:e,thread:t,rtf:r}){const[o,s]=Xo(),{Avatar:i=l2}=S.useContext(jr),a=Dx(n);return x.jsxs(Y,{as:"li",sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)"},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:1,mb:1},children:[x.jsx(i,{author:a,size:20}),x.jsx(Le,{sx:{fontWeight:"bold",fontSize:1},children:Jc(a)}),a.agentUid&&x.jsx(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:"· with an agent"}),x.jsxs(Le,{sx:{color:"var(--fgColor-muted)",fontSize:0},children:["· ",C2(r,n.timeStamp)]})]}),x.jsx(Le,{as:"p",sx:{fontSize:1,m:0,...n.deleted?{color:"var(--fgColor-muted)",fontStyle:"italic"}:{}},children:n.content}),!n.deleted&&x.jsxs(x.Fragment,{children:[x.jsx(Ft,{icon:Ch,"aria-label":"Delete comment",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)",mt:1},onClick:()=>{s("Delete Comment",l=>x.jsx(Gm,{commentOrThread:n,deleteCommentOrThread:e,thread:t,onClose:l}))}}),o]})]})}function S2({activeIDs:n,comments:e,deleteCommentOrThread:t,listRef:r,submitAddComment:o,markNodeMap:s,resolveThread:i}){const[a]=fe(),[l,c]=S.useState(0),[u,f]=Xo(),d=S.useMemo(()=>new Intl.RelativeTimeFormat("en",{localeMatcher:"best fit",numeric:"auto",style:"short"}),[]);return S.useEffect(()=>{const g=setTimeout(()=>{c(l+1)},1e4);return()=>{clearTimeout(g)}},[l]),x.jsx(Y,{as:"ul",ref:r,sx:{listStyle:"none",m:0,p:0},children:e.map(g=>{const h=g.id;if(g.type==="thread"){const _=()=>{const m=s.get(h);if(m!==void 0&&(n===null||n.indexOf(h)===-1)){const b=document.activeElement;a.update(()=>{const w=Array.from(m)[0],C=Q(w);Ro(C)&&C.selectStart()},{onUpdate(){b!==null&&b.focus()}})}};return x.jsxs(Y,{as:"li",onClick:_,sx:{p:2,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",cursor:s.has(h)?"pointer":"default",bg:n.indexOf(h)===-1?"var(--bgColor-default)":"var(--bgColor-accent-muted)","&:hover":s.has(h)?{bg:"var(--bgColor-muted)"}:{}},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"flex-start",gap:2},children:[x.jsxs(Y,{as:"blockquote",sx:{flex:1,m:0,pl:2,borderLeft:"3px solid",borderColor:"var(--bgColor-accent-muted)",color:"var(--fgColor-muted)",fontSize:1},children:["> ",x.jsx("span",{children:g.quote})]}),i&&x.jsx(Ft,{icon:xh,"aria-label":"Resolve thread",variant:"invisible",size:"small",onClick:m=>{m.stopPropagation(),i(g)}}),x.jsx(Ft,{icon:Ch,"aria-label":"Delete thread",variant:"invisible",size:"small",sx:{color:"var(--fgColor-danger)"},onClick:()=>{f("Delete Thread",m=>x.jsx(Gm,{commentOrThread:g,deleteCommentOrThread:t,onClose:m}))}}),u]}),x.jsx(g2,{thread:g}),x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0,mt:2},children:g.comments.map(m=>x.jsx(Fg,{comment:m,deleteComment:t,thread:g,rtf:d},m.id))}),x.jsx(Y,{sx:{mt:2},children:x.jsx(x2,{submitAddComment:o,thread:g,placeholder:"Reply to comment..."})})]},h)}return x.jsx(Fg,{comment:g,deleteComment:t,rtf:d},h)})})}function v2({activeIDs:n,deleteCommentOrThread:e,comments:t,submitAddComment:r,markNodeMap:o,resolveThread:s}){const i=S.useRef(null),a=t.length===0;return x.jsxs(Y,{sx:{bg:"var(--bgColor-default)",borderRadius:2,overflow:"hidden",width:"100%",flex:1,display:"flex",flexDirection:"column"},children:[x.jsx(mw,{as:"h2",sx:{fontSize:2,p:3,borderBottom:"1px solid",borderColor:"var(--borderColor-muted)",m:0},children:"Comments"}),a?x.jsx(Y,{sx:{p:3,color:"var(--fgColor-muted)",textAlign:"center"},children:"No Comments"}):x.jsx(S2,{activeIDs:n,comments:t,deleteCommentOrThread:e,listRef:i,submitAddComment:r,markNodeMap:o,resolveThread:s})]})}function Zm(){const{author:n}=S.useContext(jr),{name:e}=Lm();return n??qc(e)}function YM({providerFactory:n,showFloatingAddButton:e=!0,commentStore:t,author:r,Avatar:o}){const[s]=fe(),{showComments:i,setShowComments:a}=e_(),l=S.useRef(null),c=S.useRef(null),u=S.useMemo(()=>t??new Bx(s),[s,t]),f=Ux(u),d=S.useMemo(()=>new Map,[]),[g,h]=S.useState(),[_,m]=S.useState([]),[b,w]=S.useState(!1),C=S.useCallback(R=>{a(typeof R=="function"?R(i):R)},[a,i]),v=S.useCallback(()=>{s.update(()=>{const R=D();R!==null&&(R.dirty=!0)}),w(!1)},[s]),k=S.useCallback(R=>{const $=d.get(R);$!==void 0&&setTimeout(()=>{s.update(()=>{for(const L of $){const A=Q(L);Ro(A)&&(A.deleteID(R),A.getIDs().length===0&&Ox(A))}})})},[s,d]),I=S.useCallback((R,$)=>{R.type==="comment"?u.deleteComment(R,$):(u.deleteThread(R),k($!==void 0?$.id:R.id))},[u,k]),E=S.useMemo(()=>{if(u.resolveThread)return R=>{u.resolveThread?.(R),k(R.id)}},[u,k]),N=S.useCallback((R,$,L)=>{u.addComment(R,L),$&&(s.update(()=>{const A=D();if(F(A)){const B=A.focus,j=A.anchor,U=A.isBackward(),z=R.id;Rx(A,U,z),U?B.set(j.key,j.offset,j.type):j.set(B.key,B.offset,B.type)}}),w(!1))},[u,s]);S.useEffect(()=>{const R=[];for(let $=0;$<_.length;$++){const L=_[$],A=d.get(L);if(A!==void 0)for(const B of A){const j=s.getElementByKey(B);j!==null&&(j.classList.add("selected"),R.push(j),a(!0))}}return()=>{for(let $=0;$<R.length;$++)R[$].classList.remove("selected")}},[_,s,d]),S.useEffect(()=>{const R=new Map;return de(_w(s,Ts,$=>Hc($.getIDs()),($,L)=>{$.getIDs().forEach(B=>{L.addID(B)})}),s.registerMutationListener(Ts,$=>{s.getEditorState().read(()=>{for(const[L,A]of $){const B=Q(L);let j=[];A==="destroyed"?j=R.get(L)||[]:Ro(B)&&(j=B.getIDs());for(let U=0;U<j.length;U++){const z=j[U];let K=d.get(z);R.set(L,j),A==="destroyed"?K!==void 0&&(K.delete(L),K.size===0&&d.delete(z)):(K===void 0&&(K=new Set,d.set(z,K)),K.has(L)||K.add(L))}}})}),s.registerUpdateListener(({editorState:$,tags:L})=>{$.read(()=>{const A=D();let B=!1,j=!1;if(F(A)){const U=A.anchor.getNode();if(oe(U)){const z=Ax(U,A.anchor.offset);z!==null&&(m(z),B=!0),A.isCollapsed()||(h(U.getKey()),j=!0)}}B||m(U=>U.length===0?U:[]),j||h(null)}),L.has("collaboration")||w(!1)}),s.registerCommand(ys,()=>{const $=window.getSelection();return $!==null&&$.removeAllRanges(),w(!0),!0},V))},[s,d]);const O=()=>{s.dispatchCommand(ys,void 0)},M=S.useMemo(()=>({searchPeople:u.searchPeople?.bind(u),assignThread:u.assignThread?.bind(u),author:r,Avatar:o}),[u,r,o]);return x.jsxs(jr.Provider,{value:M,children:[b&&x.jsx(jr.Provider,{value:M,children:x.jsx(w2,{editor:s,cancelAddComment:v,submitAddComment:N})}),e&&g!==null&&g!==void 0&&!b&&St.createPortal(x.jsx(_2,{anchorKey:g,editor:s,onAddComment:O}),document.body),x.jsx("button",{ref:l,style:{display:"none"},"aria-hidden":"true"}),x.jsx(vx,{isOpen:i,setIsOpen:C,openButtonRef:l,closeButtonRef:c,direction:"right",width:"350px",content:x.jsx(v2,{comments:f,submitAddComment:N,deleteCommentOrThread:I,activeIDs:_,markNodeMap:d,resolveThread:E})})]})}const Fo=Qe().describe("CSS colour, e.g. '#1e1e1e', '#e03131', 'transparent'"),Qm=Lt({type:wr(["rectangle","ellipse","diamond","text","arrow","line","frame"]).describe("What to draw"),x:Ke().describe("Left edge, in scene coordinates"),y:Ke().describe("Top edge, in scene coordinates"),width:Ke().optional().describe("Width in pixels (shapes only)"),height:Ke().optional().describe("Height in pixels (shapes only)"),id:Qe().optional().describe("Your own id for this element, so a later arrow can point at it by name. Any string; Excalidraw keeps it."),text:Qe().optional().describe("The text itself, for type 'text'"),label:Qe().optional().describe("Text to put inside the shape. Excalidraw binds it to the shape, so moving the shape moves the label."),fontSize:Ke().optional().describe("Font size in pixels, e.g. 16, 20, 28"),strokeColor:Fo.optional().describe("Outline colour"),backgroundColor:Fo.optional().describe("Fill colour"),fillStyle:wr(["hachure","cross-hatch","solid"]).optional().describe("How the fill is drawn"),strokeWidth:Ke().optional().describe("Outline thickness, 1 | 2 | 4"),strokeStyle:wr(["solid","dashed","dotted"]).optional().describe("Outline style"),roughness:Ke().optional().describe("0 for architect (clean), 1 for artist, 2 for cartoonist"),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians"),startId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow starts at. The arrow stays attached when either element moves."),endId:Qe().optional().describe("For 'arrow' and 'line': the id of the element the arrow points at."),points:yr(yr(Ke())).optional().describe("For 'arrow' and 'line' without bindings: points relative to x,y, e.g. [[0,0],[120,0]]"),children:yr(Qe()).optional().describe("For 'frame': the ids of the elements it contains"),name:Qe().optional().describe("For 'frame': its name")}),eb=Qe().describe("Where to put the drawing: 'TOP' for the beginning of the document, 'BOTTOM' for the end, or the block_id to insert after"),On=Qe().describe("The block_id of the drawing, from excalidrawListDrawings or readAllBlocks"),tb=Lt({afterId:eb,elements:yr(Qm).optional().describe("The drawing itself. Omit to insert an empty canvas for a person to draw on."),width:Ke().optional().describe("Rendered width in pixels. Omit to size to the content."),height:Ke().optional().describe("Rendered height in pixels. Omit to size to the content.")}),nb=Lt({}),rb=Lt({blockId:On,detail:wr(["summary","full"]).optional().describe("'summary' (default) gives each element's id, type, position, size and text — enough to change it. 'full' gives the raw Excalidraw elements, which is large; ask for it only when you need a field the summary omits.")}),ob=Lt({blockId:On,elements:yr(Qm).describe("The elements to add. Existing elements are left alone.")}),sb=Lt({blockId:On,updates:yr(Lt({id:Qe().describe("The element id, from excalidrawReadScene"),x:Ke().optional(),y:Ke().optional(),width:Ke().optional(),height:Ke().optional(),text:Qe().optional().describe("New text. On a shape this rewrites the label bound inside it; on a 'text' element it rewrites the element."),strokeColor:Fo.optional(),backgroundColor:Fo.optional(),fillStyle:wr(["hachure","cross-hatch","solid"]).optional(),strokeWidth:Ke().optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional(),opacity:Ke().optional().describe("0-100"),angle:Ke().optional().describe("Rotation in radians")})).describe("One entry per element to change. Fields left out are kept.")}),ib=Lt({blockId:On,elementIds:yr(Qe()).describe("The ids to remove, from excalidrawReadScene")}),ab=Lt({blockId:On,fromId:Qe().describe("The element the arrow starts at"),toId:Qe().describe("The element the arrow points at"),label:Qe().optional().describe('Text to sit on the arrow, e.g. "yes", "then"'),strokeColor:Fo.optional(),strokeStyle:wr(["solid","dashed","dotted"]).optional()}),lb=Lt({blockId:On,viewBackgroundColor:Fo.optional().describe("The canvas colour behind the drawing"),gridSize:Ke().optional().describe("Grid spacing in pixels. 0 turns the grid off.")}),cb=Lt({blockId:On,width:Ke().optional().describe("Rendered width in pixels. Omit to go back to sizing by content."),height:Ke().optional().describe("Rendered height in pixels. Omit to go back to sizing by content.")}),ub=Lt({blockId:On}),db=Lt({blockId:On.optional().describe("The drawing to replace. Omit to insert a new drawing instead, positioned by afterId."),afterId:eb.optional().describe("Where a new drawing goes: 'TOP', 'BOTTOM', or a block_id. Ignored when blockId is given."),mermaid:Qe().describe("Mermaid source. Flowcharts, sequence diagrams and class diagrams convert to real shapes; anything else comes across as an image."),fontSize:Ke().optional().describe("Font size for the generated text, in pixels")}),Qt=n=>`datalayer_${n}`,Qr={requiresConfirmation:!1,canBeReferencedInPrompt:!0,priority:"medium"},en=["lexical","excalidraw","drawing","diagram"],k2={name:Qt("excalidrawInsertNode"),displayName:"Insert Drawing",toolReferenceName:"excalidrawInsertNode",description:"Insert an Excalidraw drawing into the Lexical document, optionally with its contents. This is how you draw a diagram: give the elements you want and they are laid out as you place them, in scene coordinates where x grows right and y grows down. Give a shape an `id` and a later arrow can bind to it with `startId`/`endId`, so the arrow follows the shape when it moves. Put text on a shape with `label` rather than positioning a separate text element on top of it. Returns the new block_id — keep it, every other excalidraw tool needs it. Omit `elements` to insert an empty canvas for a person to draw on themselves.",parameters:Zt(tb),operation:"excalidrawInsertNode",config:{confirmationMessage:n=>`Insert a drawing of ${n.elements?.length??0} element(s)?`,invocationMessage:()=>"Drawing in the lexical document",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...en,"insert"]},T2={name:Qt("excalidrawListDrawings"),displayName:"List Drawings",toolReferenceName:"excalidrawListDrawings",description:'List the Excalidraw drawings in the open Lexical document, with the block_id of each and a one-line description of what it holds. Call this first when asked to change "the diagram" and you do not already know its block_id.',parameters:Zt(nb),operation:"excalidrawListDrawings",config:{...Qr,invocationMessage:()=>"Looking for drawings"},tags:[...en,"read"]},I2={name:Qt("excalidrawReadScene"),displayName:"Read Drawing",toolReferenceName:"excalidrawReadScene",description:"Read what is inside one drawing: every element with its id, type, position, size and text. The element ids are the only way to address a shape, so read the scene before updating, deleting or connecting anything. The default 'summary' detail is what you want; 'full' returns the raw Excalidraw elements and is large.",parameters:Zt(rb),operation:"excalidrawReadScene",config:{...Qr,invocationMessage:()=>"Reading the drawing"},tags:[...en,"read"]},E2={name:Qt("excalidrawAddElements"),displayName:"Add to Drawing",toolReferenceName:"excalidrawAddElements",description:"Add elements to a drawing that already exists, leaving what is there alone. Same element format as excalidrawInsertNode. To attach a new arrow to a shape already in the drawing, pass that shape's existing element id as `startId` or `endId`. Read the scene first if you need to know where there is room.",parameters:Zt(ob),operation:"excalidrawAddElements",config:{...Qr,invocationMessage:()=>"Adding to the drawing",priority:"high"},tags:[...en,"edit"]},N2={name:Qt("excalidrawUpdateElements"),displayName:"Update Drawing Elements",toolReferenceName:"excalidrawUpdateElements",description:"Change elements already in a drawing — move them, resize them, recolour them, or rewrite their text. Address each one by the element id from excalidrawReadScene. Fields you leave out are kept as they are. Setting `text` on a shape rewrites the label bound inside it rather than replacing the shape.",parameters:Zt(sb),operation:"excalidrawUpdateElements",config:{...Qr,invocationMessage:()=>"Changing the drawing"},tags:[...en,"edit"]},L2={name:Qt("excalidrawDeleteElements"),displayName:"Delete Drawing Elements",toolReferenceName:"excalidrawDeleteElements",description:"Remove elements from a drawing by their element ids. Deleting a shape also removes the text bound inside it and detaches any arrows that pointed at it, so the drawing stays consistent.",parameters:Zt(ib),operation:"excalidrawDeleteElements",config:{confirmationMessage:n=>`Delete ${n.elementIds?.length??0} element(s) from the drawing?`,invocationMessage:()=>"Removing from the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"medium"},tags:[...en,"edit","delete"]},O2={name:Qt("excalidrawConnectElements"),displayName:"Connect Drawing Elements",toolReferenceName:"excalidrawConnectElements",description:"Draw an arrow from one element to another and bind it to both, so it follows them when either moves. Excalidraw works out where the arrow should meet each shape. Use this rather than adding an arrow with hand-computed points whenever both ends are existing shapes.",parameters:Zt(ab),operation:"excalidrawConnectElements",config:{...Qr,invocationMessage:()=>"Connecting two shapes"},tags:[...en,"edit"]},R2={name:Qt("excalidrawSetAppState"),displayName:"Set Drawing Canvas",toolReferenceName:"excalidrawSetAppState",description:"Set the canvas behind a drawing: its background colour and its grid. This is about the canvas, not the shapes on it — use excalidrawUpdateElements to recolour a shape.",parameters:Zt(lb),operation:"excalidrawSetAppState",config:{...Qr,invocationMessage:()=>"Setting up the canvas"},tags:[...en,"edit"]},A2={name:Qt("excalidrawResize"),displayName:"Resize Drawing",toolReferenceName:"excalidrawResize",description:"Set how large the drawing is rendered in the document. This scales the picture on the page; it does not move or resize anything inside it. Omit width and height to go back to sizing by content.",parameters:Zt(cb),operation:"excalidrawResize",config:{...Qr,invocationMessage:()=>"Resizing the drawing"},tags:[...en,"edit"]},M2={name:Qt("excalidrawClearScene"),displayName:"Clear Drawing",toolReferenceName:"excalidrawClearScene",description:"Empty a drawing, keeping the block so it can be drawn into again. To remove the drawing from the document altogether, use deleteBlocks with its block_id.",parameters:Zt(ub),operation:"excalidrawClearScene",config:{confirmationMessage:()=>"Empty this drawing?",invocationMessage:()=>"Emptying the drawing",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"low"},tags:[...en,"edit","delete"]},$2={name:Qt("excalidrawFromMermaid"),displayName:"Draw from Mermaid",toolReferenceName:"excalidrawFromMermaid",description:"Turn Mermaid source into a real Excalidraw drawing — shapes and arrows that can then be moved, recoloured and edited like anything else you drew. This is the fastest way to produce a flowchart, sequence diagram or class diagram: write the Mermaid and let the layout be worked out for you, rather than placing boxes by hand. Give blockId to replace an existing drawing, or afterId to insert a new one.",parameters:Zt(db),operation:"excalidrawFromMermaid",config:{confirmationMessage:n=>n.blockId?"Replace this drawing with the Mermaid diagram?":"Insert the Mermaid diagram as a drawing?",invocationMessage:()=>"Drawing the Mermaid diagram",requiresConfirmation:!0,canBeReferencedInPrompt:!0,priority:"high"},tags:[...en,"insert","mermaid"]},fb=[k2,$2,T2,I2,E2,N2,O2,L2,R2,A2,M2],hl=()=>({elements:[],appState:{},files:{}});function Gu(n){if(!n)return hl();let e;try{e=JSON.parse(n)}catch{return hl()}if(Array.isArray(e))return{elements:e,appState:{},files:{}};if(!e||typeof e!="object")return hl();const t=e;return{elements:Array.isArray(t.elements)?t.elements:[],appState:t.appState??{},files:t.files??{}}}function Zu(n){return JSON.stringify({elements:n.elements,appState:n.appState,files:n.files})}const Gs=n=>n.elements.filter(e=>!e?.isDeleted);function D2(n){const e={id:String(n?.id??""),type:String(n?.type??"unknown"),x:Number(n?.x??0),y:Number(n?.y??0),width:Number(n?.width??0),height:Number(n?.height??0)};return typeof n?.text=="string"&&n.text.length>0&&(e.text=n.text),n?.strokeColor&&(e.strokeColor=String(n.strokeColor)),n?.backgroundColor&&(e.backgroundColor=String(n.backgroundColor)),n?.containerId&&(e.containerId=String(n.containerId)),n?.startBinding?.elementId&&(e.startBoundElementId=String(n.startBinding.elementId)),n?.endBinding?.elementId&&(e.endBoundElementId=String(n.endBinding.elementId)),Array.isArray(n?.groupIds)&&n.groupIds.length>0&&(e.groupIds=n.groupIds.map(String)),e}function P2(n){const e=new Map;for(const t of n)t?.type==="text"&&t?.containerId&&t?.text&&e.set(String(t.containerId),String(t.text));return n.map(t=>{const r=D2(t);if(r.text===void 0){const o=e.get(r.id);o&&(r.text=o)}return r})}function Qu(n){const e=Gs(n);if(e.length===0)return"empty drawing";const t=new Map,r=[];for(const i of e){const a=String(i?.type??"unknown");if(a==="text"){const l=String(i?.text??"").trim();if(l&&r.push(l),i?.containerId)continue}t.set(a,(t.get(a)??0)+1)}const o=[...t.entries()].sort((i,a)=>a[1]-i[1]||i[0].localeCompare(a[0])).map(([i,a])=>`${a} ${i}${a>1?"s":""}`).join(", "),s=r.slice(0,3).join(", ");return s?`${o}: ${s}`:o}function ed(n){return{...n,version:Number(n?.version??1)+1,versionNonce:Math.floor(Math.random()*2**31),updated:Date.now()}}const Zi=4;function gb(n,e){let t=null,r;if(n.getEditorState().read(()=>{const o=Q(e);o&&(r=o.getType?.(),r==="excalidraw"&&(t=o))}),!t)throw new Error(r?`Block '${e}' is a '${r}', not a drawing. Call excalidrawListDrawings to find the drawings in this document.`:`No block '${e}' in this document. Call excalidrawListDrawings to find the drawings in this document.`);return t}function Rn(n,e){const t=gb(n,e);let r="";return n.getEditorState().read(()=>{r=t.__data??""}),Gu(r)}function eo(n,e,t){const r=Zu(t);return new Promise(o=>{n.update(()=>{const s=Q(e);s?.setData&&s.setData(r)},{onUpdate:()=>o()})})}const hn=(n,e,t)=>({success:!0,blockId:n,elementCount:Gs(e).length,...t});let j2=0;const F2=()=>`dla-${Date.now().toString(36)}-${(j2+=1).toString(36)}`;function B2(n,e){const{label:t,startId:r,endId:o,fontSize:s,text:i,children:a,name:l,...c}=n,u={...c,id:e};return n.type==="text"?(u.text=i??t??"",s&&(u.fontSize=s)):t&&(u.label=s?{text:t,fontSize:s}:{text:t}),(n.type==="arrow"||n.type==="line")&&(r&&(u.start={id:r}),o&&(u.end={id:o})),(n.type==="frame"||n.type==="magicframe")&&(u.children=a??[],l&&(u.name=l)),u}async function td(n,e){const{convertToExcalidrawElements:t}=await me(async()=>{const{convertToExcalidrawElements:i}=await import("./percentages-BXMCSKIN-Bk5xifLL.js").then(a=>a.i);return{convertToExcalidrawElements:i}},[],import.meta.url),r=[],o=n.map(i=>{let a=String(i.id??"").trim();return(!a||e.has(a))&&(a=F2()),e.add(a),r.push(a),B2(i,a)});return{elements:[...t(o,{regenerateIds:!1})],ids:r}}const mc=n=>({x:Number(n.x??0)+Number(n.width??0)/2,y:Number(n.y??0)+Number(n.height??0)/2});function Bg(n,e){const t=mc(n),r=e.x-t.x,o=e.y-t.y;if(r===0&&o===0)return t;const s=Number(n.width??0)/2+Zi,i=Number(n.height??0)/2+Zi,a=Math.min(r===0?1/0:Math.abs(s/r),o===0?1/0:Math.abs(i/o));return{x:t.x+r*a,y:t.y+o*a}}function U2(n,e){const t=Array.isArray(n.boundElements)?[...n.boundElements]:[];return t.some(r=>r?.id===e)||t.push({id:e,type:"arrow"}),ed({...n,boundElements:t})}function pb(n,e,t,r){const o=n.elements.find(c=>c.id===t),s=n.elements.find(c=>c.id===r);if(!o||!s){const c=o?r:t;throw new Error(`No element '${c}' in this drawing. Call excalidrawReadScene to see the element ids it holds.`)}const i=Bg(o,mc(s)),a=Bg(s,mc(o)),l={...e,x:i.x,y:i.y,width:Math.abs(a.x-i.x),height:Math.abs(a.y-i.y),points:[[0,0],[a.x-i.x,a.y-i.y]],startBinding:{elementId:t,focus:0,gap:Zi},endBinding:{elementId:r,focus:0,gap:Zi}};return n.elements=n.elements.map(c=>c.id===t||c.id===r?U2(c,String(e.id)):c),l}const z2=async(n,e)=>{const t=e.elements??[],r=t.length>0?await td(t,new Set):{elements:[],ids:[]},o={elements:r.elements,appState:{},files:{}},s=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(o),width:e.width,height:e.height}},String(e.afterId??"BOTTOM"));if(!s.success||!s.blockId)throw new Error(s.error||"Failed to insert the drawing");return hn(s.blockId,o,{createdIds:r.ids,message:`Drawing inserted with ${r.elements.length} element(s)`})},K2=async n=>{const t=(await n.getBlocks("detailed")).filter(r=>r.block_type==="excalidraw").map(r=>{const o=Gu(r.metadata?.data);return{blockId:r.block_id,elementCount:Gs(o).length,description:Qu(o),width:r.metadata?.width,height:r.metadata?.height}});return{drawings:t,count:t.length}},W2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r);return{blockId:t,elementCount:o.length,elements:e.detail==="full"?o:P2(o),appState:r.appState,description:Qu(r)}},H2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=new Set(r.elements.map(u=>String(u.id))),s=e.elements??[],i=new Set(s.map(u=>String(u.id??"")).filter(Boolean)),a=new Map,l=s.map((u,f)=>{const{startId:d,endId:g}=u;if((u.type==="arrow"||u.type==="line")&&d&&g&&(!i.has(String(d))||!i.has(String(g)))){a.set(f,{fromId:String(d),toId:String(g)});const{startId:_,endId:m,...b}=u;return b}return u}),c=await td(l,o);r.elements=[...r.elements,...c.elements];for(const[u,f]of a){const d=c.ids[u],g=r.elements.find(h=>h.id===d);if(g){const h=pb(r,g,f.fromId,f.toId);r.elements=r.elements.map(_=>_.id===d?h:_)}}return await eo(n.editor,t,r),hn(t,r,{createdIds:c.ids,message:`Added ${c.elements.length} element(s)`})},J2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=e.updates??[],s=new Map;for(const l of r.elements)l?.type==="text"&&l?.containerId&&s.set(String(l.containerId),String(l.id));const i=new Map,a=[];for(const l of o){const c=String(l.id),u=r.elements.find(_=>_.id===c);if(!u){a.push(c);continue}const{id:f,text:d,...g}=l,h=u.type!=="text"&&s.get(c);d!==void 0&&(h?i.set(h,{...i.get(h)??{},text:d,originalText:d}):(g.text=d,g.originalText=d)),Object.keys(g).length>0&&i.set(c,{...i.get(c)??{},...g})}if(a.length>0)throw new Error(`No element(s) ${a.map(l=>`'${l}'`).join(", ")} in this drawing. Call excalidrawReadScene to see the element ids it holds.`);return r.elements=r.elements.map(l=>{const c=i.get(String(l.id));return c?ed({...l,...c}):l}),await eo(n.editor,t,r),hn(t,r,{message:`Updated ${o.length} element(s)`})},q2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=new Set(e.elementIds.map(String)),s=new Set(o);for(const a of r.elements)a?.containerId&&o.has(String(a.containerId))&&s.add(String(a.id));const i=r.elements.length;return r.elements=r.elements.filter(a=>!s.has(String(a.id))).map(a=>{const l={};if(s.has(String(a.startBinding?.elementId))&&(l.startBinding=null),s.has(String(a.endBinding?.elementId))&&(l.endBinding=null),Array.isArray(a.boundElements)){const c=a.boundElements.filter(u=>!s.has(String(u?.id)));c.length!==a.boundElements.length&&(l.boundElements=c)}return Object.keys(l).length>0?ed({...a,...l}):a}),await eo(n.editor,t,r),hn(t,r,{message:`Removed ${i-r.elements.length} element(s)`})},V2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=String(e.fromId),s=String(e.toId),i=new Set(r.elements.map(d=>String(d.id))),{elements:a,ids:l}=await td([{type:"arrow",x:0,y:0,...e.label?{label:e.label}:{},...e.strokeColor?{strokeColor:e.strokeColor}:{},...e.strokeStyle?{strokeStyle:e.strokeStyle}:{}}],i),c=l[0];r.elements=[...r.elements,...a];const u=r.elements.find(d=>d.id===c),f=pb(r,u,o,s);return r.elements=r.elements.map(d=>d.id===c?f:d),await eo(n.editor,t,r),hn(t,r,{createdIds:[c],message:`Connected '${o}' to '${s}'`})},Y2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t);return e.viewBackgroundColor!==void 0&&(r.appState.viewBackgroundColor=e.viewBackgroundColor),e.gridSize!==void 0&&(r.appState.gridSize=Number(e.gridSize)||null),await eo(n.editor,t,r),hn(t,r,{message:"Canvas updated"})},X2=async(n,e)=>{const t=String(e.blockId),r=gb(n.editor,t),o=e.width===void 0?"inherit":Number(e.width),s=e.height===void 0?"inherit":Number(e.height);await new Promise(a=>{n.editor.update(()=>{r.setWidth(o),r.setHeight(s)},{onUpdate:()=>a()})});const i=Rn(n.editor,t);return hn(t,i,{message:o==="inherit"&&s==="inherit"?"Drawing sized to its content":`Drawing sized to ${o} x ${s}`})},G2=async(n,e)=>{const t=String(e.blockId),r=Rn(n.editor,t),o=Gs(r).length;return r.elements=[],r.files={},await eo(n.editor,t,r),hn(t,r,{message:`Emptied the drawing (${o} element(s) removed)`})},Z2=async(n,e)=>{const{parseMermaidToExcalidraw:t}=await me(async()=>{const{parseMermaidToExcalidraw:c}=await import("./index-TDpnbl90.js").then(u=>u.an);return{parseMermaidToExcalidraw:c}},[],import.meta.url),{convertToExcalidrawElements:r}=await me(async()=>{const{convertToExcalidrawElements:c}=await import("./percentages-BXMCSKIN-Bk5xifLL.js").then(u=>u.i);return{convertToExcalidrawElements:c}},[],import.meta.url);let o;try{o=await t(String(e.mermaid),{fontSize:e.fontSize?Number(e.fontSize):void 0})}catch(c){const u=c instanceof Error?c.message:String(c);throw new Error(`That Mermaid source did not parse: ${u}. Flowcharts, sequence diagrams and class diagrams are the ones that convert to shapes.`,{cause:c})}const s=[...r(o.elements)],i=o.files??{};if(e.blockId){const c=String(e.blockId),u=Rn(n.editor,c);return u.elements=s,u.files=i,await eo(n.editor,c,u),hn(c,u,{createdIds:s.map(f=>String(f.id)),message:`Drawing replaced with ${s.length} element(s) from Mermaid`})}const a={elements:s,appState:{},files:i},l=await n.insertBlock({block_id:"",block_type:"excalidraw",source:"",metadata:{data:Zu(a)}},String(e.afterId??"BOTTOM"));if(!l.success||!l.blockId)throw new Error(l.error||"Failed to insert the drawing");return hn(l.blockId,a,{createdIds:s.map(c=>String(c.id)),message:`Drawing inserted with ${s.length} element(s) from Mermaid`})},bc={excalidrawInsertNode:z2,excalidrawListDrawings:K2,excalidrawReadScene:W2,excalidrawAddElements:H2,excalidrawUpdateElements:J2,excalidrawDeleteElements:q2,excalidrawConnectElements:V2,excalidrawSetAppState:Y2,excalidrawResize:X2,excalidrawClearScene:G2,excalidrawFromMermaid:Z2};function tn(n,e){return{name:n,async execute(t,r){const o=Iw(e,t??{},n);if(!r.documentId)throw new Error(`Document ID is required for ${n}. Ensure the tool execution context includes a valid documentId.`);if(!r.executor)throw new Error(`Executor is required for ${n}. This should be provided by the platform (DefaultExecutor, BridgeExecutor, etc.)`);try{return await r.executor.execute(n,o)}catch(s){const i=s instanceof Error?s.message:String(s);throw new Error(`Failed to run ${n}: ${i}`,{cause:s})}}}}const Q2=tn("excalidrawInsertNode",tb),eL=tn("excalidrawListDrawings",nb),tL=tn("excalidrawReadScene",rb),nL=tn("excalidrawAddElements",ob),rL=tn("excalidrawUpdateElements",sb),oL=tn("excalidrawDeleteElements",ib),sL=tn("excalidrawConnectElements",ab),iL=tn("excalidrawSetAppState",lb),aL=tn("excalidrawResize",cb),lL=tn("excalidrawClearScene",ub),cL=tn("excalidrawFromMermaid",db),Ei={excalidrawInsertNode:Q2,excalidrawListDrawings:eL,excalidrawReadScene:tL,excalidrawAddElements:nL,excalidrawUpdateElements:rL,excalidrawDeleteElements:oL,excalidrawConnectElements:sL,excalidrawSetAppState:iL,excalidrawResize:aL,excalidrawClearScene:lL,excalidrawFromMermaid:cL},Ug={name:"excalidraw",definitions:fb,operations:Ei,handlers:bc};function XM(){const n=[];for(const e of fb)Ei[e.operation]||n.push(`${e.name} points at operation '${e.operation}', which does not exist`),e.toolReferenceName.startsWith("excalidraw")||n.push(`${e.name} is not named for the plugin it belongs to`);for(const e of Object.keys(Ei))bc[e]||n.push(`operation '${e}' has no handler`);for(const e of Object.keys(bc))Ei[e]||n.push(`handler '${e}' has no operation`);return n}const uL=S.lazy(()=>me(()=>import("./ExcalidrawModal-BDgjdSz2.js"),[],import.meta.url)),nd=he();function dL(){const[n]=fe(),[e,t]=S.useState(!1),o=M0()?.lexicalId;S.useEffect(()=>{if(!n.hasNodes([Yn]))throw new Error("ExcalidrawPlugin: ExcalidrawNode not registered");return n.registerCommand(nd,()=>(t(!0),!0),V)},[n]),S.useEffect(()=>{if(o)return go.getState().registerPluginTools(o,Ug),()=>{go.getState().unregisterPluginTools(o,Ug.name)}},[o]);const s=(l,c,u)=>{n.update(()=>{const f=ju();f.setData(JSON.stringify({elements:l,appState:c,files:u})),Tr([f]),wt(f.getParentOrThrow())&&Fc(f,ne).selectEnd()}),t(!1)},i=()=>{t(!1)},a=()=>{t(!1)};return e?x.jsx(S.Suspense,{fallback:null,children:x.jsx(uL,{initialElements:[],initialAppState:{},initialFiles:{},isShown:e,onSave:s,onDelete:i,onClose:a,closeOnClickOutside:!1})}):null}const fL=S.lazy(()=>me(()=>import("./DeckComponent-Cb4_dZpN.js"),[],import.meta.url));function gL(){return{deck:{title:"Untitled deck",template:"datalayer"},slides:[{type:"title",title:"A new slide",meta:"Double-click to edit its specification"}]}}function pL(n){const e=n.getAttribute("data-lexical-deck");if(!e)return null;try{return{node:rd(JSON.parse(e))}}catch{return null}}class Go extends Jo{__spec;static getType(){return"deck"}static clone(e){return new Go(e.__spec,e.__format,e.__key)}static importJSON(e){const t=rd(e.spec);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"deck",version:1,spec:this.__spec}}static importDOM(){return{div:e=>e.hasAttribute("data-lexical-deck")?{conversion:pL,priority:2}:null}}exportDOM(){const e=document.createElement("div");e.setAttribute("data-lexical-deck",JSON.stringify(this.__spec));const t=document.createElement("p");return t.textContent=this.__spec.deck?.title||"Deck",e.appendChild(t),{element:e}}constructor(e,t,r){super(t,r),this.__spec=e??gL()}getSpec(){return this.getLatest().__spec}setSpec(e){this.getWritable().__spec=e}getTextContent(){return this.__spec.deck?.title||""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(S.Suspense,{fallback:null,children:x.jsx(fL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),spec:this.__spec})})}isTopLevel(){return!0}}function rd(n){return new Go(n)}function GM(n){return n instanceof Go}const od=he("INSERT_DECK_COMMAND");function hL(n){if(!n.hasNodes([Go]))throw new Error("DeckExtension: DeckNode not registered on editor");return n.registerCommand(od,e=>(sr(rd(e)),!0),V)}const _L=pe({name:"@datalayer/jupyter-lexical/Deck",nodes:()=>[Go],register:hL}),zg="Kept in this page’s memory only: it is lost when the page reloads, and nobody else sees it. Download it to keep it.",hb={position:"relative",width:"100%",aspectRatio:"16 / 9",borderRadius:2,overflow:"hidden",bg:"black"};function mL(n){const e=Math.max(0,Math.floor(n/1e3));return`${Math.floor(e/60)}:${String(e%60).padStart(2,"0")}`}function bL(n){const e=n.currentTarget;if(Number.isFinite(e.duration))return;const t=()=>{e.removeEventListener("timeupdate",t),e.currentTime=0};e.addEventListener("timeupdate",t),e.currentTime=Number.MAX_SAFE_INTEGER}function yL({recordingId:n,recording:e}){const t=S.useRef(null),[r,o]=S.useState(()=>Date.now());return S.useEffect(()=>{t.current&&(t.current.srcObject=e.preview)},[e.preview]),S.useEffect(()=>{const s=window.setInterval(()=>o(Date.now()),500);return()=>window.clearInterval(s)},[]),x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{ref:t,autoPlay:!0,muted:!0,playsInline:!0,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Y,{"aria-hidden":!0,sx:{width:10,height:10,borderRadius:"50%",bg:"danger.fg"}}),x.jsx(Le,{sx:{fontFamily:"mono"},"aria-live":"off",children:mL(r-e.startedAt)}),x.jsx(ft,{variant:"danger",leadingVisual:Nw,onClick:()=>Vu(n),sx:{ml:"auto"},children:"Stop"})]})]})}function wL({className:n,format:e,nodeKey:t,recordingId:r,recorded:o}){const[s]=fe(),i=Hr(),a=S.useSyncExternalStore(DN,()=>PN(r)),l=JN(o,a),[c,u]=S.useState("screen"),[f,d]=S.useState(!0),g=S.useCallback(w=>{s.update(()=>{const C=Q(t);_b(C)&&C.setRecorded(w)})},[s,t]),h=()=>{WN(r,{source:c,microphone:f},()=>g(!0))},_=()=>{HN(r),g(!1)},m=w=>{const C=document.createElement("a");C.href=w.url,C.download=UN(w),C.click()};let b;return a?.status==="recording"?b=x.jsx(yL,{recordingId:r,recording:a}):a?.status==="recorded"?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsx(Y,{sx:hb,children:x.jsx("video",{src:a.url,controls:!0,playsInline:!0,onLoadedMetadata:bL,style:{width:"100%",height:"100%",objectFit:"contain"}})}),x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:2},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:0,flex:"1 1 240px"},children:zg}),x.jsx(ft,{leadingVisual:Ew,onClick:()=>m(a),children:"Download"}),i&&x.jsx(ft,{onClick:_,children:"Record again"})]})]}):l==="lost"?b=x.jsxs(Y,{sx:{display:"grid",gap:2,justifyItems:"start"},children:[x.jsx(Le,{sx:{color:"fg.muted",fontSize:1},children:"The video recorded here is gone: it was kept in the memory of the page that recorded it, and that page has been reloaded or closed."}),i&&x.jsx(ft,{onClick:()=>g(!1),children:"Record a new one"})]}):i?b=x.jsxs(Y,{sx:{display:"grid",gap:2},children:[x.jsxs(Y,{sx:{display:"flex",alignItems:"center",gap:2},children:[x.jsx(Wc,{size:16}),x.jsx(Le,{sx:{fontWeight:"bold"},children:"Video"})]}),x.jsxs(Le,{sx:{color:"fg.muted",fontSize:0},children:["Recorded by this browser, with no account. ",zg]}),FN()?x.jsxs(Y,{sx:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:3},children:[x.jsxs(Aa,{"aria-label":"What to record",size:"small",children:[x.jsx(Aa.Button,{selected:c==="screen",onClick:()=>u("screen"),children:"Screen"}),x.jsx(Aa.Button,{selected:c==="camera",onClick:()=>u("camera"),children:"Camera"})]}),x.jsxs(Mt,{children:[x.jsx(Mp,{checked:f,onChange:w=>d(w.target.checked)}),x.jsx(Mt.Label,{children:"Microphone"})]}),x.jsx(ft,{variant:"primary",onClick:h,children:"Record"})]}):x.jsx(Le,{sx:{color:"danger.fg",fontSize:1},children:"This browser cannot record video."}),a?.status==="failed"&&x.jsx(Le,{role:"alert",sx:{color:"danger.fg",fontSize:1},children:a.message})]}):b=x.jsx(Le,{as:"p",sx:{color:"fg.muted",fontSize:1,m:0},children:"A video goes here."}),x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx(Y,{"data-lexical-video":l,onFocusCapture:()=>s.update(()=>Ee(null)),sx:{p:l==="recorded"||l==="recording"?0:3,border:"1px dashed",borderColor:l==="recorded"||l==="recording"?"transparent":"border.default",borderRadius:2,bg:l==="recorded"||l==="recording"?"transparent":"canvas.subtle"},children:b})})}class Zn extends Jo{__recordingId;__recorded;static getType(){return"video"}static clone(e){return new Zn(e.__recordingId,e.__recorded,e.__format,e.__key)}static importJSON(e){const t=new Zn(e.recordingId,e.recorded);return t.setFormat(e.format),t}exportJSON(){return{...super.exportJSON(),type:"video",version:1,recordingId:this.__recordingId,recorded:this.__recorded}}exportDOM(){return{element:null}}constructor(e,t=!1,r,o){super(r,o),this.__recordingId=e||jN(),this.__recorded=t}getRecordingId(){return this.getLatest().__recordingId}isRecorded(){return this.getLatest().__recorded}setRecorded(e){this.getWritable().__recorded=e}getTextContent(){return""}updateDOM(){return!1}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(wL,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),recordingId:this.__recordingId,recorded:this.__recorded})}isTopLevel(){return!0}}function xL(){return new Zn}function _b(n){return n instanceof Zn}const sd=he("INSERT_VIDEO_COMMAND");function CL(n){if(!n.hasNodes([Zn]))throw new Error("VideoExtension: VideoNode not registered on editor");return de(n.registerCommand(sd,()=>(sr(xL()),!0),V),n.registerMutationListener(Zn,(e,{prevEditorState:t})=>{for(const[r,o]of e){if(o!=="destroyed")continue;const s=t.read(()=>{const i=Q(r);return _b(i)?i.__recordingId:void 0});s&&Vu(s)}},{skipInitialization:!0}))}const SL=pe({name:"@datalayer/jupyter-lexical/Video",nodes:()=>[Zn],register:CL});function vL({onConfirm:n,onClose:e}){const[t,r]=S.useState("5"),[o,s]=S.useState("5"),i=S.useRef(null),a=()=>{const c=parseInt(t,10),u=parseInt(o,10);c>0&&c<=500&&u>0&&u<=50&&n(c,u)},l=c=>{c.key==="Enter"&&a()};return x.jsx($p,{title:"Insert Table",onClose:()=>e(),width:"small",height:"auto",initialFocusRef:i,footerButtons:[{buttonType:"default",content:"Cancel",onClick:e},{buttonType:"primary",content:"Confirm",onClick:a}],children:x.jsxs(Y,{sx:{display:"flex",flexDirection:"column",gap:3},onKeyDown:l,children:[x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Rows"}),x.jsx(vn,{ref:i,type:"number",min:1,max:500,value:t,onChange:c=>r(c.target.value),block:!0})]}),x.jsxs(Mt,{children:[x.jsx(Mt.Label,{children:"Columns"}),x.jsx(vn,{type:"number",min:1,max:50,value:o,onChange:c=>s(c.target.value),block:!0})]})]})})}const ws=he();function mb(){const[n]=fe(),[e,t]=S.useState(!1);S.useEffect(()=>n.registerCommand(ws,()=>(t(!0),!0),V),[n]);const r=(s,i)=>{n.dispatchCommand(nu,{rows:s.toString(),columns:i.toString()}),t(!1)},o=()=>{t(!1)};return e?x.jsx(vL,{onConfirm:r,onClose:o}):null}function ZM(){return x.jsxs(x.Fragment,{children:[x.jsx(P_,{}),x.jsx(mb,{})]})}const id=he("INSERT_EQUATION_COMMAND");function bb(n){if(!n.hasNodes([ir]))throw new Error("EquationsPlugins: EquationsNode not registered on editor");return n.registerCommand(id,e=>{const{equation:t,inline:r}=e,o=ya(t,r);return Tr([o]),wt(o.getParentOrThrow())&&Fc(o,ne).selectEnd(),!0},V)}const yb=pe({name:"@datalayer/jupyter-lexical/Equations",nodes:()=>[ir],register:bb});function ad({activeEditor:n,onClose:e}){const t=S.useCallback((r,o)=>{n.dispatchCommand(id,{equation:r,inline:o}),e()},[n,e]);return x.jsx(Vx,{onConfirm:t})}const Kg=()=>{const[n]=fe();return S.useEffect(()=>bb(n),[n]),null},kL=Object.freeze(Object.defineProperty({__proto__:null,EquationsPlugin:Kg,INSERT_EQUATION_COMMAND:id,InsertEquationDialog:ad,default:Kg},Symbol.toStringTag,{value:"Module"}));class ze extends Wm{title;icon;keywords;keyboardShortcut;onSelect;disabled;constructor(e,t){super(e),this.title=e,this.keywords=t.keywords||[],this.icon=t.icon,this.keyboardShortcut=t.keyboardShortcut,this.onSelect=t.onSelect.bind(this),this.disabled=t.disabled||!1}}function TL({index:n,isSelected:e,onClick:t,onMouseEnter:r,option:o}){const s=S.useCallback(l=>o.setRefElement(l),[o]),i=o.disabled?void 0:t,a=o.disabled?void 0:r;return x.jsxs(Y,{as:"li",tabIndex:-1,ref:s,role:"option","aria-selected":e&&!o.disabled,"aria-disabled":o.disabled,id:"typeahead-item-"+n,onMouseEnter:a,onClick:i,sx:{display:"flex",alignItems:"center",gap:2,px:2,py:"6px",borderRadius:2,cursor:o.disabled?"not-allowed":"pointer",opacity:o.disabled?.5:1,bg:e&&!o.disabled?"actionListItem.default.selectedBg":"transparent",color:"var(--fgColor-default)","&:hover":o.disabled?{}:{bg:"actionListItem.default.hoverBg"},listStyle:"none"},children:[x.jsx(Y,{sx:{display:"flex",alignItems:"center",color:"var(--fgColor-muted)",flexShrink:0},children:o.icon}),x.jsx(Le,{sx:{fontSize:1},children:o.title})]},o.key)}const IL=({kernel:n,initCode:e=""}={})=>{const[t]=fe(),[r,o]=Xo(),[s,i]=S.useState(null),a=Hm("/",{minLength:0}),l=S.useCallback(()=>{const f=[];if(s==null)return f;const d=new RegExp(/^([1-9]|10)x([1-9]|10)$/),g=new RegExp(/^([1-9]|10)x?$/),h=d.exec(s),_=g.exec(s);if(h){const[m,b]=h[0].split("x").map(w=>parseInt(w,10));f.push(new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)}))}else if(_){const m=parseInt(_[0],10);f.push(...Array.from({length:5},(b,w)=>w+1).map(b=>new ze(`${m}x${b} Table`,{icon:x.jsx(yi,{size:16}),keywords:["table"],onSelect:()=>t.dispatchCommand(ws,void 0)})))}return f},[t,s]),c=S.useMemo(()=>{const f=[new ze("Jupyter Cell",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock","jupyter"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading..."})}}),new ze("Marimo Cell",{icon:x.jsx(br,{size:16}),keywords:["marimo","reactive","python","cell"],onSelect:()=>{t.dispatchCommand(Vi,{code:e,outputs:ac,loading:"Loading...",variant:"marimo"})}}),new ze("Paragraph",{icon:x.jsx(Ih,{size:16}),keywords:["normal","paragraph","p","text"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>ne())})}),...Array.from({length:3},(g,h)=>h+1).map(g=>new ze(`Heading ${g}`,{icon:x.jsx(tx,{size:16}),keywords:["heading","header",`h${g}`],onSelect:()=>t.update(()=>{const h=D();F(h)&&Un(h,()=>fn(`h${g}`))})})),new ze("Numbered List",{icon:x.jsx(Eh,{size:16}),keywords:["numbered list","ordered list","ol"],onSelect:()=>t.dispatchCommand(eu,void 0)}),new ze("Bulleted List",{icon:x.jsx(vh,{size:16}),keywords:["bulleted list","unordered list","ul"],onSelect:()=>t.dispatchCommand(Qc,void 0)}),new ze("Check List",{icon:x.jsx(Lw,{size:16}),keywords:["check list","todo list"],onSelect:()=>t.dispatchCommand(Zc,void 0)}),new ze("Table",{icon:x.jsx(yi,{size:16}),keywords:["table","grid","spreadsheet"],onSelect:()=>{ge("[ComponentPicker] Table selected, dispatching INSERT_TABLE_WITH_DIALOG_COMMAND"),t.dispatchCommand(ws,void 0)}}),new ze("Collapsible Container",{icon:x.jsx(zc,{size:16}),keywords:["collapsible","collapse","expand","toggle","accordion","container"],onSelect:()=>t.dispatchCommand(Xu,void 0)}),new ze("Excalidraw",{icon:x.jsx(Ow,{size:16}),keywords:["excalidraw","drawing","diagram","sketch","whiteboard","draw"],onSelect:()=>t.dispatchCommand(nd,void 0)}),new ze("Video",{icon:x.jsx(Wc,{size:16}),keywords:["video","record","recording","screen","camera","webcam"],onSelect:()=>t.dispatchCommand(sd,void 0)}),new ze("Loom Video",{icon:x.jsx(Ws,{size:16}),keywords:["loom","video","record","recording","screen"],onSelect:()=>t.dispatchCommand(ka,void 0)}),new ze("Deck Slide",{icon:x.jsx(hs,{size:16}),keywords:["deck","slide","slides","presentation","pitch"],onSelect:()=>t.dispatchCommand(od,void 0)}),new ze("Quote",{icon:x.jsx(Nh,{size:16}),keywords:["block quote"],onSelect:()=>t.update(()=>{const g=D();F(g)&&Un(g,()=>Ln())})}),new ze("Code",{icon:x.jsx(br,{size:16}),keywords:["javascript","python","js","codeblock"],onSelect:()=>t.update(()=>{const g=D();if(F(g))if(g.isCollapsed())Un(g,()=>Ze());else{const h=g.getTextContent(),_=Ze();g.insertNodes([_]),g.insertRawText(h)}})}),new ze("Divider",{icon:x.jsx(ji,{size:16}),keywords:["horizontal rule","divider","hr"],onSelect:()=>t.dispatchCommand(Kc,void 0)}),...qu.map(g=>new ze(`Embed ${g.contentName}`,{icon:g.icon,keywords:[...g.keywords,"embed"],onSelect:()=>t.dispatchCommand(Ju,g.type)})),new ze("Equation",{icon:x.jsx(Rw,{size:16}),keywords:["equation","latex","math"],onSelect:()=>o("Insert Equation",g=>x.jsx(ad,{activeEditor:t,onClose:g}))}),new ze("GIF",{icon:x.jsx(hs,{size:16}),keywords:["gif","animate","image","file"],onSelect:()=>{yu().then(g=>{g&&t.dispatchCommand(Ys,g)})}}),new ze("Image",{icon:x.jsx(hs,{size:16}),keywords:["image","photo","picture","file"],onSelect:()=>o("Insert Image",g=>x.jsx(z_,{activeEditor:t,onClose:g}))}),...["left","center","right","justify"].map(g=>new ze(`Align ${g}`,{icon:g==="left"?x.jsx(nx,{size:16}):g==="right"?x.jsx(rx,{size:16}):x.jsx(ji,{size:16}),keywords:["align","justify",g],onSelect:()=>t.dispatchCommand(Bn,g)}))],d=l();return s?[...d,...f.filter(g=>new RegExp(s,"gi").exec(g.title)||g.keywords!=null?g.keywords.some(h=>new RegExp(s,"gi").exec(h)):!1)]:f},[t,l,s,o,n,e]),u=S.useCallback((f,d,g,h)=>{f.disabled||t.update(()=>{d&&d.remove(),f.onSelect(h),g()})},[t]);return x.jsxs(x.Fragment,{children:[r,x.jsx(Jm,{onQueryChange:i,onSelectOption:u,triggerFn:a,options:c,menuRenderFn:(f,{selectedIndex:d,selectOptionAndCleanUp:g,setHighlightedIndex:h})=>f.current&&c.length?St.createPortal(x.jsx(Y,{onMouseDown:_=>{_.preventDefault()},sx:{position:"relative",zIndex:1e3,bg:"var(--overlay-bgColor)",border:"1px solid",borderColor:"var(--borderColor-default)",borderRadius:2,boxShadow:"var(--shadow-floating-large, 0 0 0 1px #d1d9e0, 0 40px 80px 0 #25292e3d)",p:1,maxHeight:300,overflow:"auto",minWidth:200},children:x.jsx(Y,{as:"ul",sx:{listStyle:"none",m:0,p:0},children:c.map((_,m)=>x.jsx(TL,{index:m,isSelected:d===m,onClick:()=>{_.disabled||(h(m),g(_))},onMouseEnter:()=>{_.disabled||h(m)},option:_},_.key))})}),f.current):null})]})},yc=4,EL=2,NL="draggable-block-menu",Wg="application/x-lexical-drag-block",Hg=28,LL=1,OL=-1,Jg=0;let Ni=1/0;function RL(n){return n===0?1/0:Ni>=0&&Ni<n?Ni:Math.floor(n/2)}function AL(n){return n.getEditorState().read(()=>se().getChildrenKeys())}function wb(n){const e=(l,c)=>l?parseFloat(window.getComputedStyle(l)[c]):0,{marginTop:t,marginBottom:r}=window.getComputedStyle(n),o=e(n.previousElementSibling,"marginBottom"),s=e(n.nextElementSibling,"marginTop"),i=Math.max(parseFloat(t),o);return{marginBottom:Math.max(parseFloat(r),s),marginTop:i}}function _l(n,e,t,r=!1){const o=n.getBoundingClientRect(),s=AL(e);let i=null;return e.getEditorState().read(()=>{if(r){const[c,u]=[e.getElementByKey(s[0]),e.getElementByKey(s[s.length-1])],[f,d]=[c?.getBoundingClientRect(),u?.getBoundingClientRect()];if(f&&d){const g=Wn(c),h=Wn(u);if(t.y/g<f.top?i=c:t.y/h>d.bottom&&(i=u),i)return}}let a=RL(s.length),l=Jg;for(;a>=0&&a<s.length;){const c=s[a],u=e.getElementByKey(c);if(u===null)break;const f=Wn(u),d=new zm(t.x/f,t.y/f),g=pr.fromDOM(u),{marginTop:h,marginBottom:_}=wb(u),m=g.generateNewRect({bottom:g.bottom+_,left:o.left,right:o.right,top:g.top-h}),{result:b,reason:{isOnTopSide:w,isOnBottomSide:C}}=m.contains(d);if(b){i=u,Ni=a;break}l===Jg&&(w?l=OL:C?l=LL:l=1/0),a+=l}}),i}function ML(n){return!!n.closest(`.${NL}`)}function xb(n){const e=window.getComputedStyle(n),t=e.overflowY==="auto"||e.overflowY==="scroll",r=e.overflowX==="auto"||e.overflowX==="scroll";if(t||r)return{element:n,scrollTop:n.scrollTop||0,scrollLeft:n.scrollLeft||0};const o=n.parentElement;if(o){const s=window.getComputedStyle(o),i=s.overflowY==="auto"||s.overflowY==="scroll",a=s.overflowX==="auto"||s.overflowX==="scroll";if(i||a)return{element:o,scrollTop:o.scrollTop||0,scrollLeft:o.scrollLeft||0}}return{element:n,scrollTop:0,scrollLeft:0}}function $L(n,e,t){if(!n){e.style.opacity="0",e.style.transform="translate(-10000px, -10000px)";return}const r=n.getBoundingClientRect(),o=window.getComputedStyle(n),s=e.getBoundingClientRect(),i=t.getBoundingClientRect(),{scrollTop:a}=xb(t),c=(parseInt(o.lineHeight,10)-s.height)/2,u=r.top+c-i.top+a,f=yc;e.style.opacity="1",e.style.transform=`translate(${f}px, ${u}px)`}function DL(n,e){const{transform:t}=e.style;e.style.transform="translateZ(0)",n.setDragImage(e,0,0),setTimeout(()=>{e.style.transform=t})}function PL(n,e,t,r){const{top:o,height:s}=e.getBoundingClientRect(),{top:i,width:a}=r.getBoundingClientRect(),{marginTop:l,marginBottom:c}=wb(e),{scrollTop:u}=xb(r);let f=o;t>=o?f+=s+c/2:f-=l/2;const d=f-i-EL+u,g=Hg-yc;n.style.transform=`translate(${g}px, ${d}px)`,n.style.width=`${a-(Hg-yc)*2}px`,n.style.opacity=".4"}function jL(n){n&&(n.style.opacity="0",n.style.transform="translate(-10000px, -10000px)")}function FL(n,e,t){const r=S.useRef(null),o=S.useRef(null),s=S.useRef(!1),[i,a]=S.useState(null),l=n._config.theme,c=l.draggableBlockMenu||"",u=l.draggableBlockTargetLine||"";S.useEffect(()=>{function g(_){const m=_.target;if(!pl(m)){a(null);return}if(!e.contains(m)||ML(m))return;const b=_l(e,n,_);a(b)}function h(){a(null)}return document.addEventListener("mousemove",g),document.addEventListener("mouseleave",h),()=>{document.removeEventListener("mousemove",g),document.removeEventListener("mouseleave",h)}},[e,n]),S.useEffect(()=>{r.current&&$L(i,r.current,e)},[e,i]),S.useEffect(()=>{function g(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{pageY:b,target:w}=_;if(!pl(w))return!1;const C=_l(e,n,_,!0),v=o.current;return C===null||v===null?!1:(PL(v,C,b/Wn(w),e),_.preventDefault(),!0)}function h(_){if(!s.current)return!1;const[m]=uo(_);if(m)return!1;const{target:b,dataTransfer:w,pageY:C}=_,v=w?.getData(Wg)||"",k=Q(v);if(!k||!pl(b))return!1;const I=_l(e,n,_,!0);if(!I)return!1;const E=Ae(I);if(!E)return!1;if(E===k)return!0;const N=I.getBoundingClientRect().top;return C/Wn(b)>=N?E.insertAfter(k):E.insertBefore(k),a(null),!0}return de(n.registerCommand(Nc,_=>g(_),ee),n.registerCommand(Lc,_=>h(_),qe))},[e,n]);function f(g){const h=g.dataTransfer;if(!h||!i)return;DL(h,i);let _="";n.update(()=>{const m=Ae(i);m&&(_=m.getKey())}),s.current=!0,h.setData(Wg,_)}function d(){s.current=!1,jL(o.current)}return St.createPortal(x.jsxs(x.Fragment,{children:[x.jsx("div",{className:`draggable-block-menu ${c}`,ref:r,draggable:!0,onDragStart:f,onDragEnd:d,children:t?x.jsx(Aw,{size:16}):null}),x.jsx("div",{className:`draggable-block-target-line ${u}`,ref:o})]}),e)}function QM({anchorElem:n=document.body}){const[e]=fe();return FL(e,n,e._editable)}const BL=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]});function UL(n,e,t,r){const[o,s]=S.useState(!1),[i,a]=S.useState(!1),[l,c]=S.useState(!1),[u,f]=S.useState(!1),[d,g]=S.useState(!1),[h,_]=S.useState(!1),[m,b]=S.useState(!1),[w,C]=S.useState(!1),[v,k]=S.useState(!1),I=S.useCallback(()=>{n.getEditorState().read(()=>{if(n.isComposing())return;const M=D(),R=window.getSelection(),$=n.getRootElement();if(R!==null&&(!F(M)||$===null||!$.contains(R.anchorNode))){s(!1);return}if(!F(M))return;const L=Bm(M);c(M.hasFormat("bold")),f(M.hasFormat("italic")),g(M.hasFormat("underline")),_(M.hasFormat("strikethrough")),b(M.hasFormat("subscript")),C(M.hasFormat("superscript")),k(M.hasFormat("code"));const A=L.getParent();Pe(A)||Pe(L)?a(!0):a(!1),!Ve(M.anchor.getNode())&&M.getTextContent()!==""?s(oe(L)):s(!1)})},[n]);S.useEffect(()=>(document.addEventListener("selectionchange",I),()=>{document.removeEventListener("selectionchange",I)}),[I]),S.useEffect(()=>de(n.registerUpdateListener(()=>{I()}),n.registerRootListener(()=>{n.getRootElement()===null&&s(!1)}),n.registerCommand(ys,()=>(s(!1),!1),ee)),[n,I]);const E=S.useCallback(()=>{i?(t(!1),n.dispatchCommand(Lr,null)):(t(!0),n.dispatchCommand(Lr,"https://example.com"))},[n,i,t]),N=S.useMemo(()=>n.isEditable()?[{key:"bold",type:"button",order:0,ariaLabel:"Format text as bold",title:"Bold",icon:Lh,isActive:l,onClick:()=>n.dispatchCommand(Ge,"bold")},{key:"italic",type:"button",order:1,ariaLabel:"Format text as italics",title:"Italic",icon:Oh,isActive:u,onClick:()=>n.dispatchCommand(Ge,"italic")},{key:"underline",type:"button",order:2,ariaLabel:"Format text to underlined",title:"Underline",icon:BL,isActive:d,onClick:()=>n.dispatchCommand(Ge,"underline")},{key:"strikethrough",type:"button",order:3,ariaLabel:"Format text with a strikethrough",title:"Strikethrough",icon:Rh,isActive:h,onClick:()=>n.dispatchCommand(Ge,"strikethrough")},{key:"subscript",type:"button",order:4,ariaLabel:"Format Subscript",title:"Subscript",icon:void 0,label:"x₂",isActive:m,onClick:()=>n.dispatchCommand(Ge,"subscript")},{key:"superscript",type:"button",order:5,ariaLabel:"Format Superscript",title:"Superscript",icon:void 0,label:"x²",isActive:w,onClick:()=>n.dispatchCommand(Ge,"superscript")},{key:"code",type:"button",order:6,ariaLabel:"Insert code block",title:"Code",icon:br,isActive:v,onClick:()=>n.dispatchCommand(Ge,"code")},{key:"link",type:"button",order:7,ariaLabel:"Insert link",title:"Link",icon:Ah,isActive:i,onClick:E},{key:"comment",type:"button",order:8,ariaLabel:"Insert comment",title:"Comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}]:[{key:"comment",type:"button",order:100,ariaLabel:"Insert comment",icon:Pi,onClick:()=>n.dispatchCommand(ys,void 0)}],[n,l,u,d,h,m,w,v,i,E]),O=o&&!i;return x.jsx(Tx,{items:N,extraItems:r,anchorElement:e,isVisible:O,ariaLabel:"Floating text format toolbar"})}function e$({anchorElem:n=document.body,setIsLinkEditMode:e,extraItems:t}){const[r]=fe();return UL(r,n,e,t)}function zL(n){return n.registerCommand(Kc,()=>{const e=D();if(!F(e))return!1;if(e.focus.getNode()!==null){const r=ba();e.insertParagraph(),e.focus.getNode().getTopLevelElementOrThrow().insertBefore(r)}return!0},V)}const Cb=pe({name:"@datalayer/jupyter-lexical/HorizontalRule",nodes:()=>[mu],register:zL}),ss={code:{triggerMode:"auto",contextBefore:-1,contextAfter:-1,language:"python"},prose:{triggerMode:"manual",contextBefore:-1,contextAfter:-1},debounceMs:200,manualTriggerKey:"Cmd+Shift+,"};function KL(n){return n?{code:{...ss.code,...n.code},prose:{...ss.prose,...n.prose},debounceMs:n.debounceMs??ss.debounceMs,manualTriggerKey:n.manualTriggerKey??ss.manualTriggerKey}:{...ss}}function t$(n){return n===-1||n>=0}function n$(n){return n.triggerMode==="auto"}function r$(n){return n.triggerMode==="manual"||n.triggerMode==="auto"}function o$(n){return n.triggerMode==="disabled"}const qg="jupyter-cell";class Fr extends Bt{__code;__outputs;__loading;__autoStart;__data;__variant;static getType(){return qg}static clone(e){return console.debug(`clone: node: ${JSON.stringify(e,null,2)}`),new Fr(e.__code,e.__outputs,e.__loading,e.__autoStart,e.__data,e.__key,e.__variant)}constructor(e,t,r,o,s="[]",i,a){super(i),this.__code=e,this.__outputs=t,this.__loading=r,this.__autoStart=o,this.__data=s,this.__variant=a}createDOM(e){const t=document.createElement("div"),o=e.theme.image;return o!==void 0&&(t.className=o),ge("createDOM",t),t}updateDOM(){return!1}decorate(e){return ge(`decorate -> key: ${this.getKey()} outputs: ${this.__outputs} data: ${this.__data}`),x.jsx(_x,{source:this.__code,outputs:this.__outputs,autoStart:this.__autoStart,variant:this.__variant})}setCode(e){const t=this.getWritable();t.__code=e}get code(){return this.__code}setOutputs(e){const t=this.getWritable();t.__outputs=e}get outputs(){return this.__outputs}setLoading(e){const t=this.getWritable();t.__loading=e}get loading(){return this.__loading}setAutostart(e){const t=this.getWritable();t.__autoStart=e}get autoStart(){return this.__autoStart}get variant(){return this.__variant}setData(e){const t=this.getWritable();t.__data=e}get data(){return this.__data}static importJSON(e){const t=e;return new Fr(t.code,t.outputs,t.loading,t.autoStart,t.data,void 0,t.variant)}exportJSON(){return{code:this.__code,outputs:this.__outputs,loading:this.__loading,autoStart:this.__autoStart,data:this.__data,variant:this.__variant,type:qg,version:1}}}function Vg(n){const{code:e,outputs:t,loading:r,autoStart:o}=n;return new Fr(e,t,r,o)}function s$(n){return n instanceof Fr}const WL=he(),HL=he();function JL(n){if(!n.hasNodes([Fr]))throw new Error("JupyterCellNode is not registered.");return de(n.registerCommand(WL,e=>{const t=Vg(e);return Tr([t]),!0},V),n.registerCommand(HL,e=>{const t=Vg({...e});return Tr([t]),!0},V))}const qL=pe({name:"@datalayer/jupyter-lexical/JupyterCell",nodes:()=>[Fr],register:JL}),VL=he("INSERT_LAYOUT_COMMAND");function YL(n){return n.trim().split(/\s+/).length}function i$(n){return Array.from({length:Math.max(1,n)},()=>"1fr").join(" ")}function XL(n){if(!n.hasNodes([Dr,Pr]))throw new Error("LayoutPlugin: LayoutContainerNode, or LayoutItemNode not registered on editor");const e=t=>{const r=D();if(F(r)&&r.isCollapsed()&&r.anchor.offset===0){const o=re(r.anchor.getNode(),Ci);if(Ci(o)){const s=o.getParent(),i=s&&(t?s.getFirstChild():s.getLastChild()),a=t?o.getFirstDescendant()?.getKey():o.getLastDescendant()?.getKey();s!==null&&i===o&&r.anchor.key===a&&(t?o.insertBefore(ne()):o.insertAfter(ne()))}}return!1};return de(n.registerCommand(Vt,()=>e(!1),ee),n.registerCommand(ia,()=>e(!1),ee),n.registerCommand(pt,()=>e(!0),ee),n.registerCommand(zs,()=>e(!0),ee),n.registerCommand(VL,t=>(n.update(()=>{const r=Ou(t);for(let o=0;o<YL(t);o++)r.append(Ru().append(ne()));sr(r),r.selectStart()}),!0),V),n.registerNodeTransform(Pr,t=>{const r=t.getParent();if(!Ci(r)){for(const o of t.getChildren())t.insertBefore(o);t.remove();return}t.isEmpty()&&t.append(ne())}),n.registerNodeTransform(Dr,t=>{const r=t.getChildren();if(!r.every(Au)){for(const o of r)t.insertBefore(o);t.remove();return}r.length===0&&t.remove()}))}const GL=pe({name:"@datalayer/jupyter-lexical/Layout",nodes:()=>[Dr,Pr],register:XL});function Yg(n,e,t,r,o){return n==="code"?ZL(e,t):QL(e,t,r,o)}function ZL(n,e){const t=n.getTextContent(),r=nO(n,e),o=t.substring(0,r),s=t.substring(r);return{before:o,after:s,fullText:t}}function QL(n,e,t,r){const s=se().getChildren(),i=eO(n);if(!i)return{before:"",after:"",fullText:""};const a=s.indexOf(i);if(a===-1)return{before:"",after:"",fullText:""};const l=t===-1?0:Math.max(0,a-t),c=r===-1?s.length-1:Math.min(s.length-1,a+r);let u="";for(let _=l;_<a;_++)u+=s[_].getTextContent()+`
215
215
  `;const f=i.getTextContent(),d=tO(i,e);u+=f.substring(0,d);let g=f.substring(d);for(let _=a+1;_<=c;_++)g+=`
216
- `+s[_].getTextContent();const h=u+g;return{before:u,after:g,fullText:h}}function eO(n){let e=n;for(;e;){if(ht(e)||e.getType()==="heading"||e.getType()==="listitem")return e;e=e.getParent()}return se()}function tO(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function nO(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function rO(n){switch(n){case 1:case 2:return"𝑓";case 5:return"𝑥";case 6:return"C";case 8:return"M";case 9:return"∙";case 13:return"🔑";default:return"•"}}function oO(n,e){if(!e||e.length===0)return x.jsx(x.Fragment,{children:n});const t=n.toLowerCase(),r=e.toLowerCase(),o=t.indexOf(r);if(o===-1)return x.jsx(x.Fragment,{children:n});const s=n.substring(0,o),i=n.substring(o,o+e.length),a=n.substring(o+e.length);return x.jsxs(x.Fragment,{children:[s,x.jsx("strong",{style:{color:"var(--vscode-editorSuggestWidget-highlightForeground)",fontWeight:"bold"},children:i}),a]})}function sO({items:n,onSelect:e,onClose:t,position:r,filterText:o}){const[s,i]=S.useState(0),[a,l]=S.useState(r),c=S.useRef(null),u=S.useRef([]),f=S.useRef(null);return S.useEffect(()=>{const d=window.getSelection();if(d&&d.rangeCount>0){const g=d.getRangeAt(0);f.current=g.startContainer.parentElement}},[]),S.useEffect(()=>{const d=()=>{const g=window.getSelection();if(!g||g.rangeCount===0)return;const _=g.getRangeAt(0).getBoundingClientRect();l({top:_.bottom+window.scrollY,left:_.left+window.scrollX})};return window.addEventListener("scroll",d,!0),()=>window.removeEventListener("scroll",d,!0)},[]),S.useEffect(()=>{const d=u.current[s];d&&d.scrollIntoView({block:"nearest"})},[s]),S.useEffect(()=>{const d=g=>{switch(g.key){case"ArrowDown":g.preventDefault(),i(h=>Math.min(h+1,n.length-1));break;case"ArrowUp":g.preventDefault(),i(h=>Math.max(h-1,0));break;case"Enter":g.preventDefault(),n[s]&&e(n[s]);break;case"Escape":g.preventDefault(),t();break;case"Tab":g.preventDefault(),n[s]&&e(n[s]);break}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,n,e,t]),S.useEffect(()=>{const d=g=>{c.current&&!c.current.contains(g.target)&&t()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[t]),n.length===0?x.jsx(x.Fragment,{}):x.jsx("div",{ref:c,style:{position:"fixed",top:`${a.top}px`,left:`${a.left}px`,zIndex:1e4,background:"var(--vscode-editorSuggestWidget-background)",border:"1px solid var(--vscode-editorSuggestWidget-border)",borderRadius:"4px",boxShadow:"var(--shadow-resting-medium, 0 1px 1px 0 #25292e1a, 0 3px 6px 0 #25292e1f)",maxHeight:"300px",overflowY:"auto",minWidth:"300px"},children:x.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0"},children:n.map((d,g)=>{const h=g===s;return x.jsxs("li",{ref:_=>{u.current[g]=_},onClick:()=>e(d),onMouseEnter:()=>i(g),style:{padding:"4px 8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",backgroundColor:h?"var(--vscode-editorSuggestWidget-selectedBackground)":"transparent",color:h?"var(--vscode-editorSuggestWidget-selectedForeground)":"var(--vscode-editorSuggestWidget-foreground)"},children:[x.jsx("span",{style:{opacity:.7,fontSize:"12px",minWidth:"16px",textAlign:"center"},children:rO(d.kind)}),x.jsx("span",{style:{flex:1},children:oO(d.label,o)}),d.detail&&x.jsx("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"auto"},children:d.detail})]},`${d.label}-${g}`)})})})}const wc=he("LSP_MENU_STATE_COMMAND"),xc=he("LSP_COMPLETION_INSERTED_COMMAND");function ml(n,e,t){let r=0;function o(i){if(i===e)return r+=t,!0;if(q(i)){const a=i.getChildren();for(const l of a)if(o(l))return!0}else r+=i.getTextContent().length;return!1}const s=n.getChildren();for(const i of s)if(o(i))break;return r}function iO(n){const e=n.getChildren();for(const t of e)if(ds(t))return!0;return!1}function Gg(n){let e=n;for(;e;){if(st(e))return e;e=e.getParent()}return null}function aO(n,e){let t=0,r=0;for(let o=0;o<e&&o<n.length;o++)n[o]===`
217
- `?(t++,r=0):r++;return{line:t,character:r}}function lO(n){const e=n.getLanguage();return!e||e==="python"||e==="py"?"python":e==="markdown"||e==="md"||e==="text"?"markdown":"unknown"}function cO(n,e){if(!e)return n;const t=e.toLowerCase(),r=[],o=[];for(const s of n){const i=(s.filterText||s.label).toLowerCase();i.startsWith(t)?r.push(s):i.includes(t)&&o.push(s)}return[...r,...o]}function a$({providers:n,disabled:e=!1}){const[t]=fe(),[r,o]=S.useState([]),[s,i]=S.useState([]),[a,l]=S.useState(!1),[c,u]=S.useState({top:0,left:0}),[f,d]=S.useState(""),g=S.useRef(0),h=S.useRef(null),_=S.useCallback(()=>{const C=window.getSelection();if(!C||C.rangeCount===0)return{top:0,left:0};const k=C.getRangeAt(0).getBoundingClientRect();return{top:k.bottom+window.scrollY,left:k.left+window.scrollX}},[]),m=S.useCallback(()=>{l(!1),o([]),i([]),d(""),g.current=0,h.current=null,t.dispatchCommand(wc,!1)},[t]),b=S.useCallback(C=>{t.update(()=>{const v=D();if(!F(v))return;const k=v.anchor.getNode(),I=v.anchor.offset,E=h.current;if(E){const O=ml(E,k,I)-g.current;if(O>0){const M=I-O;if(M>=0){const R=k.getKey();v.anchor.set(R,M,"text"),v.focus.set(R,I,"text")}}}v.insertText(C.insertText)}),t.dispatchCommand(xc,void 0),m()},[t,m]);S.useEffect(()=>{if(!(!a||r.length===0))return t.registerUpdateListener(({editorState:C})=>{C.read(()=>{const v=D();if(!F(v)||!v.isCollapsed()){m();return}const k=v.anchor.getNode(),I=h.current;if(!I)return;const E=Gg(k);if(!E){m();return}const N=E.getJupyterInputNodeUuid(),O=I.getJupyterInputNodeUuid();if(N!==O){m();return}h.current=E;const M=v.anchor.offset,R=ml(E,k,M);if(R<g.current){m();return}const L=E.getTextContent().substring(g.current,R),A=cO(r,L);i(A),d(L),A.length===0&&m()})})},[t,a,r,m]);const w=S.useCallback(async(C,v)=>{if(n.length===0||e)return;const k=C.getJupyterInputNodeUuid(),I=C.getTextContent(),E=lO(C);if(E==="unknown")return;const N=aO(I,v),M=(await Promise.all(n.map(R=>R.fetchCompletions(k,I,N,E)))).flat();if(M.length===1){const R=M[0];t.update(()=>{const $=D();if(F($)){const L=$.anchor.getNode(),A=$.anchor.offset,B=L.getTextContent();let j=A;for(;j>0&&/[a-zA-Z0-9_]/.test(B[j-1]);)j--;if(A-j>0){const z=L.getKey();$.anchor.set(z,j,"text"),$.focus.set(z,A,"text")}$.insertText(R.insertText)}}),t.dispatchCommand(xc,void 0)}else if(M.length>1){const R=_();u(R),o(M),i(M),d(""),g.current=v,h.current=C,l(!0),t.dispatchCommand(wc,!0)}},[n,e,_,t]);return S.useEffect(()=>{if(!e)return t.registerCommand(Kr,C=>{const v=D();if(!F(v)||!v.isCollapsed())return!1;const k=v.anchor.getNode(),I=Gg(k);if(!I||iO(I))return!1;if(a)return C?.preventDefault(),!0;C?.preventDefault();const E=v.anchor.getNode(),N=v.anchor.offset,O=ml(I,E,N);return w(I,O),!0},bo)},[t,e,a,w]),e||n.length===0?null:a&&s.length>0?x.jsx(sO,{items:s,onSelect:b,onClose:m,position:c,filterText:f}):null}const Xg=he("TRIGGER_INLINE_COMPLETION_COMMAND");function uO({providers:n,debounceMs:e,enabled:t=!0,config:r}){const[o]=fe(),[s,i]=S.useState(null),[a,l]=S.useState(!1),c=S.useMemo(()=>KL(r),[r]),u=r?.debounceMs??e??Math.max(c.debounceMs,500),f=S.useRef(null),d=S.useRef(""),g=S.useRef(""),h=S.useRef(null),_=S.useRef(null),m=S.useRef(0);S.useEffect(()=>()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),S.useEffect(()=>{if(t)return o.registerCommand(wc,w=>(l(w),w&&(f.current&&(clearTimeout(f.current),f.current=null),i(null)),!1),ee)},[o,t]),S.useEffect(()=>{if(t)return o.registerCommand(xc,()=>(m.current=Date.now(),i(null),!1),ee)},[o,t]);const b=S.useCallback(async(w,C,v,k="code",I="auto")=>{if(!n||n.length===0)return;const E=n[0];try{const N=w.substring(0,C),O=w.substring(C),M=await E.fetch({text:w,offset:C,language:v,contentType:k},{before:N,after:O,inCodeCell:k==="code",triggerKind:I});if(M&&M.items&&M.items.length>0){const R=M.items[0].insertText;i(R)}else i(null)}catch(N){console.error("[InlineCompletionPlugin] Error requesting completion:",N),i(null)}},[n]);return S.useEffect(()=>{_.current=b},[b]),S.useEffect(()=>{if(t)return o.registerUpdateListener(({editorState:w})=>{w.read(()=>{if(!c){ge("[InlineCompletionPlugin] Config not ready, skipping auto-trigger"),i(null);return}if(a){i(null);return}if(Date.now()-m.current<300){i(null);return}const k=D();if(!F(k)||!k.isCollapsed()){i(null);return}const I=k.anchor.getNode(),E=Zg(I),N=E==="code"?c.code:c.prose;if(ge("[InlineCompletionPlugin] Auto-trigger check:",{contentType:E,triggerMode:N.triggerMode,willTrigger:N.triggerMode==="auto"}),N.triggerMode==="auto")if(E==="code"){const O=bl(I);if(!O){i(null);return}const M=O.getTextContent(),R=Qg(O,k);if(M===g.current)return;g.current=M;const $=M.substring(0,R);if($.trim().length===0){i(null);return}const L=$.lastIndexOf(`
216
+ `+s[_].getTextContent();const h=u+g;return{before:u,after:g,fullText:h}}function eO(n){let e=n;for(;e;){if(ht(e)||e.getType()==="heading"||e.getType()==="listitem")return e;e=e.getParent()}return se()}function tO(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function nO(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[ContextExtractor] Error getting cursor offset:",t),0}}function rO(n){switch(n){case 1:case 2:return"𝑓";case 5:return"𝑥";case 6:return"C";case 8:return"M";case 9:return"∙";case 13:return"🔑";default:return"•"}}function oO(n,e){if(!e||e.length===0)return x.jsx(x.Fragment,{children:n});const t=n.toLowerCase(),r=e.toLowerCase(),o=t.indexOf(r);if(o===-1)return x.jsx(x.Fragment,{children:n});const s=n.substring(0,o),i=n.substring(o,o+e.length),a=n.substring(o+e.length);return x.jsxs(x.Fragment,{children:[s,x.jsx("strong",{style:{color:"var(--vscode-editorSuggestWidget-highlightForeground)",fontWeight:"bold"},children:i}),a]})}function sO({items:n,onSelect:e,onClose:t,position:r,filterText:o}){const[s,i]=S.useState(0),[a,l]=S.useState(r),c=S.useRef(null),u=S.useRef([]),f=S.useRef(null);return S.useEffect(()=>{const d=window.getSelection();if(d&&d.rangeCount>0){const g=d.getRangeAt(0);f.current=g.startContainer.parentElement}},[]),S.useEffect(()=>{const d=()=>{const g=window.getSelection();if(!g||g.rangeCount===0)return;const _=g.getRangeAt(0).getBoundingClientRect();l({top:_.bottom+window.scrollY,left:_.left+window.scrollX})};return window.addEventListener("scroll",d,!0),()=>window.removeEventListener("scroll",d,!0)},[]),S.useEffect(()=>{const d=u.current[s];d&&d.scrollIntoView({block:"nearest"})},[s]),S.useEffect(()=>{const d=g=>{switch(g.key){case"ArrowDown":g.preventDefault(),i(h=>Math.min(h+1,n.length-1));break;case"ArrowUp":g.preventDefault(),i(h=>Math.max(h-1,0));break;case"Enter":g.preventDefault(),n[s]&&e(n[s]);break;case"Escape":g.preventDefault(),t();break;case"Tab":g.preventDefault(),n[s]&&e(n[s]);break}};return window.addEventListener("keydown",d),()=>window.removeEventListener("keydown",d)},[s,n,e,t]),S.useEffect(()=>{const d=g=>{c.current&&!c.current.contains(g.target)&&t()};return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[t]),n.length===0?x.jsx(x.Fragment,{}):x.jsx("div",{ref:c,style:{position:"fixed",top:`${a.top}px`,left:`${a.left}px`,zIndex:1e4,background:"var(--vscode-editorSuggestWidget-background)",border:"1px solid var(--vscode-editorSuggestWidget-border)",borderRadius:"4px",boxShadow:"var(--shadow-resting-medium, 0 1px 1px 0 #25292e1a, 0 3px 6px 0 #25292e1f)",maxHeight:"300px",overflowY:"auto",minWidth:"300px"},children:x.jsx("ul",{style:{listStyle:"none",margin:0,padding:"4px 0"},children:n.map((d,g)=>{const h=g===s;return x.jsxs("li",{ref:_=>{u.current[g]=_},onClick:()=>e(d),onMouseEnter:()=>i(g),style:{padding:"4px 8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",backgroundColor:h?"var(--vscode-editorSuggestWidget-selectedBackground)":"transparent",color:h?"var(--vscode-editorSuggestWidget-selectedForeground)":"var(--vscode-editorSuggestWidget-foreground)"},children:[x.jsx("span",{style:{opacity:.7,fontSize:"12px",minWidth:"16px",textAlign:"center"},children:rO(d.kind)}),x.jsx("span",{style:{flex:1},children:oO(d.label,o)}),d.detail&&x.jsx("span",{style:{fontSize:"11px",opacity:.6,marginLeft:"auto"},children:d.detail})]},`${d.label}-${g}`)})})})}const wc=he("LSP_MENU_STATE_COMMAND"),xc=he("LSP_COMPLETION_INSERTED_COMMAND");function ml(n,e,t){let r=0;function o(i){if(i===e)return r+=t,!0;if(q(i)){const a=i.getChildren();for(const l of a)if(o(l))return!0}else r+=i.getTextContent().length;return!1}const s=n.getChildren();for(const i of s)if(o(i))break;return r}function iO(n){const e=n.getChildren();for(const t of e)if(ds(t))return!0;return!1}function Xg(n){let e=n;for(;e;){if(st(e))return e;e=e.getParent()}return null}function aO(n,e){let t=0,r=0;for(let o=0;o<e&&o<n.length;o++)n[o]===`
217
+ `?(t++,r=0):r++;return{line:t,character:r}}function lO(n){const e=n.getLanguage();return!e||e==="python"||e==="py"?"python":e==="markdown"||e==="md"||e==="text"?"markdown":"unknown"}function cO(n,e){if(!e)return n;const t=e.toLowerCase(),r=[],o=[];for(const s of n){const i=(s.filterText||s.label).toLowerCase();i.startsWith(t)?r.push(s):i.includes(t)&&o.push(s)}return[...r,...o]}function a$({providers:n,disabled:e=!1}){const[t]=fe(),[r,o]=S.useState([]),[s,i]=S.useState([]),[a,l]=S.useState(!1),[c,u]=S.useState({top:0,left:0}),[f,d]=S.useState(""),g=S.useRef(0),h=S.useRef(null),_=S.useCallback(()=>{const C=window.getSelection();if(!C||C.rangeCount===0)return{top:0,left:0};const k=C.getRangeAt(0).getBoundingClientRect();return{top:k.bottom+window.scrollY,left:k.left+window.scrollX}},[]),m=S.useCallback(()=>{l(!1),o([]),i([]),d(""),g.current=0,h.current=null,t.dispatchCommand(wc,!1)},[t]),b=S.useCallback(C=>{t.update(()=>{const v=D();if(!F(v))return;const k=v.anchor.getNode(),I=v.anchor.offset,E=h.current;if(E){const O=ml(E,k,I)-g.current;if(O>0){const M=I-O;if(M>=0){const R=k.getKey();v.anchor.set(R,M,"text"),v.focus.set(R,I,"text")}}}v.insertText(C.insertText)}),t.dispatchCommand(xc,void 0),m()},[t,m]);S.useEffect(()=>{if(!(!a||r.length===0))return t.registerUpdateListener(({editorState:C})=>{C.read(()=>{const v=D();if(!F(v)||!v.isCollapsed()){m();return}const k=v.anchor.getNode(),I=h.current;if(!I)return;const E=Xg(k);if(!E){m();return}const N=E.getJupyterInputNodeUuid(),O=I.getJupyterInputNodeUuid();if(N!==O){m();return}h.current=E;const M=v.anchor.offset,R=ml(E,k,M);if(R<g.current){m();return}const L=E.getTextContent().substring(g.current,R),A=cO(r,L);i(A),d(L),A.length===0&&m()})})},[t,a,r,m]);const w=S.useCallback(async(C,v)=>{if(n.length===0||e)return;const k=C.getJupyterInputNodeUuid(),I=C.getTextContent(),E=lO(C);if(E==="unknown")return;const N=aO(I,v),M=(await Promise.all(n.map(R=>R.fetchCompletions(k,I,N,E)))).flat();if(M.length===1){const R=M[0];t.update(()=>{const $=D();if(F($)){const L=$.anchor.getNode(),A=$.anchor.offset,B=L.getTextContent();let j=A;for(;j>0&&/[a-zA-Z0-9_]/.test(B[j-1]);)j--;if(A-j>0){const z=L.getKey();$.anchor.set(z,j,"text"),$.focus.set(z,A,"text")}$.insertText(R.insertText)}}),t.dispatchCommand(xc,void 0)}else if(M.length>1){const R=_();u(R),o(M),i(M),d(""),g.current=v,h.current=C,l(!0),t.dispatchCommand(wc,!0)}},[n,e,_,t]);return S.useEffect(()=>{if(!e)return t.registerCommand(Kr,C=>{const v=D();if(!F(v)||!v.isCollapsed())return!1;const k=v.anchor.getNode(),I=Xg(k);if(!I||iO(I))return!1;if(a)return C?.preventDefault(),!0;C?.preventDefault();const E=v.anchor.getNode(),N=v.anchor.offset,O=ml(I,E,N);return w(I,O),!0},bo)},[t,e,a,w]),e||n.length===0?null:a&&s.length>0?x.jsx(sO,{items:s,onSelect:b,onClose:m,position:c,filterText:f}):null}const Gg=he("TRIGGER_INLINE_COMPLETION_COMMAND");function uO({providers:n,debounceMs:e,enabled:t=!0,config:r}){const[o]=fe(),[s,i]=S.useState(null),[a,l]=S.useState(!1),c=S.useMemo(()=>KL(r),[r]),u=r?.debounceMs??e??Math.max(c.debounceMs,500),f=S.useRef(null),d=S.useRef(""),g=S.useRef(""),h=S.useRef(null),_=S.useRef(null),m=S.useRef(0);S.useEffect(()=>()=>{f.current&&(clearTimeout(f.current),f.current=null)},[]),S.useEffect(()=>{if(t)return o.registerCommand(wc,w=>(l(w),w&&(f.current&&(clearTimeout(f.current),f.current=null),i(null)),!1),ee)},[o,t]),S.useEffect(()=>{if(t)return o.registerCommand(xc,()=>(m.current=Date.now(),i(null),!1),ee)},[o,t]);const b=S.useCallback(async(w,C,v,k="code",I="auto")=>{if(!n||n.length===0)return;const E=n[0];try{const N=w.substring(0,C),O=w.substring(C),M=await E.fetch({text:w,offset:C,language:v,contentType:k},{before:N,after:O,inCodeCell:k==="code",triggerKind:I});if(M&&M.items&&M.items.length>0){const R=M.items[0].insertText;i(R)}else i(null)}catch(N){console.error("[InlineCompletionPlugin] Error requesting completion:",N),i(null)}},[n]);return S.useEffect(()=>{_.current=b},[b]),S.useEffect(()=>{if(t)return o.registerUpdateListener(({editorState:w})=>{w.read(()=>{if(!c){ge("[InlineCompletionPlugin] Config not ready, skipping auto-trigger"),i(null);return}if(a){i(null);return}if(Date.now()-m.current<300){i(null);return}const k=D();if(!F(k)||!k.isCollapsed()){i(null);return}const I=k.anchor.getNode(),E=Zg(I),N=E==="code"?c.code:c.prose;if(ge("[InlineCompletionPlugin] Auto-trigger check:",{contentType:E,triggerMode:N.triggerMode,willTrigger:N.triggerMode==="auto"}),N.triggerMode==="auto")if(E==="code"){const O=bl(I);if(!O){i(null);return}const M=O.getTextContent(),R=Qg(O,k);if(M===g.current)return;g.current=M;const $=M.substring(0,R);if($.trim().length===0){i(null);return}const L=$.lastIndexOf(`
218
218
  `)+1;if($.substring(L).trim().length===0){i(null);return}const B=M.substring(R),j=B.indexOf(`
219
- `);if((j===-1?B:B.substring(0,j)).trim().length>0){let K=!1;const H=O.getChildren();for(const ie of H)if(ds(ie)){K=!0;break}if(!K){i(null);return}}f.current&&clearTimeout(f.current);const z=`${M}:${R}`;if(M.trim().length<2){i(null),d.current="";return}f.current=setTimeout(()=>{z!==d.current&&(d.current=z,_.current?.(M,R,N.language||"python","code","auto"))},u)}else{const O=Yg(E,I,k,N.contextBefore,N.contextAfter);if(O.fullText===g.current)return;if(g.current=O.fullText,O.before.trim().length<10){i(null);return}f.current&&clearTimeout(f.current);const M=`prose:${O.fullText.length}`;f.current=setTimeout(()=>{M!==d.current&&(d.current=M,_.current?.(O.fullText,O.before.length,N.language||"markdown","prose","auto"))},u)}})})},[o,t,u,c.code,c.prose,a]),S.useEffect(()=>{t&&o.update(()=>{const w=D();if(F(w)){if(h.current){const C=Q(h.current);C&&ds(C)&&C.remove(),h.current=null}if(s&&s.trim().length>0){const C=hc(s),v=w.anchor.getNode(),k=w.anchor.offset;v.getType()==="text"?v.splitText(k)[0].insertAfter(C):(v.getType(),v.insertAfter(C)),h.current=C.getKey()}}})},[o,s,t]),S.useEffect(()=>{if(!(!t||!s))return o.registerNodeTransform(Nt,w=>{const C=D();if(!F(C))return;const v=C.anchor.getNode();if(bl(v)!==w)return;if(!w.getChildren().some(N=>ds(N))&&s.trim()){const N=hc(s),O=C.anchor.getNode(),M=C.anchor.offset;O.getType()==="text"?O.splitText(M)[0].insertAfter(N):(O.getType(),O.insertAfter(N)),h.current=N.getKey()}})},[o,s,t]),S.useEffect(()=>{if(t)return o.registerCommand(Kr,w=>s?(w?.preventDefault(),o.update(()=>{const C=D();if(F(C)){if(h.current){const v=Q(h.current);if(v&&ds(v)){const k=$e(s);v.replace(k),h.current=null,k.select();const I=D();F(I)&&(I.anchor.set(k.getKey(),s.length,"text"),I.focus.set(k.getKey(),s.length,"text"))}}i(null)}}),!0):!1,qe)},[o,t,s]),S.useEffect(()=>{if(t)return o.registerCommand(Nn,()=>s?(i(null),!0):!1,ee)},[o,t,s]),S.useEffect(()=>{if(!t)return;const w=v=>{["Alt","AltGraph","Control","Meta","Shift","Dead","CapsLock","NumLock","ScrollLock","Fn"].includes(v.key)||fO(v,c.manualTriggerKey)&&(v.preventDefault(),o.dispatchCommand(Xg,void 0))},C=o.getRootElement();if(C)return C.addEventListener("keydown",w),()=>{C.removeEventListener("keydown",w)}},[o,t,c.manualTriggerKey]),S.useEffect(()=>{if(t)return o.registerCommand(Xg,()=>(o.getEditorState().read(()=>{const w=D();if(!F(w)||!w.isCollapsed())return;const C=w.anchor.getNode(),v=Zg(C),k=v==="code"?c.code:c.prose;if(k.triggerMode!=="disabled")if(f.current&&(clearTimeout(f.current),f.current=null),v==="code"){const I=bl(C);if(!I)return;const E=I.getTextContent(),N=Qg(I,w),O=`${E}:${N}`;d.current=O,_.current?.(E,N,k.language||"python","code","manual")}else{const I=Yg(v,C,w,k.contextBefore,k.contextAfter);if(I.before.trim().length<10)return;const E=`prose:manual:${I.fullText.length}`;d.current=E,_.current?.(I.fullText,I.before.length,k.language||"markdown","prose","manual")}}),!0),qe)},[o,t,c]),null}const dO={space:"Space",enter:"Enter",tab:"Tab",escape:"Escape",backspace:"Backspace",delete:"Delete",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",a:"KeyA",b:"KeyB",c:"KeyC",d:"KeyD",e:"KeyE",f:"KeyF",g:"KeyG",h:"KeyH",i:"KeyI",j:"KeyJ",k:"KeyK",l:"KeyL",m:"KeyM",n:"KeyN",o:"KeyO",p:"KeyP",q:"KeyQ",r:"KeyR",s:"KeyS",t:"KeyT",u:"KeyU",v:"KeyV",w:"KeyW",x:"KeyX",y:"KeyY",z:"KeyZ"};function fO(n,e){const t=e.split("+").map(u=>u.trim().toLowerCase()),r=t[t.length-1],o=t.slice(0,-1),s=dO[r];if(s){if(n.code!==s)return!1}else if(n.key.toLowerCase()!==r)return!1;const i=o.includes("ctrl"),a=o.includes("cmd")||o.includes("meta"),l=o.includes("shift"),c=o.includes("alt");return!(i&&!n.ctrlKey||a&&!n.metaKey||l&&!n.shiftKey||c&&!n.altKey)}function Zg(n){let e=n;for(;e;){if(st(e))return"code";e=e.getParent()}return"prose"}function bl(n){let e=n;for(;e;){if(st(e))return e;if(tt(e)){const t=e.getParent();if(t&&st(t))return t}e=e.getParent()}}function Qg(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[InlineCompletionPlugin] Error getting cursor offset:",t),0}}function gO(n){if(n.block_type==="horizontalrule")return"";if(n.block_type==="youtube"){const r=n.metadata?.videoID;return r?`youtu.be/${r}`:"(no ID)"}if(n.block_type==="excalidraw"){const r=Xu(n.metadata?.data);return r.elements.length>0?Qu(r):"(empty diagram)"}if(n.block_type==="table"){const r=n.metadata?.rows||0,o=n.metadata?.columns||0;return`${r}×${o} table`}if(n.block_type==="equation"){const r=n.metadata?.equation||"",o=n.metadata?.inline,s=r.length>20?r.slice(0,20)+"...":r;return o?`$${s}$`:`$$${s}$$`}if(n.block_type==="image"){const r=n.metadata?.altText||"",o=n.metadata?.src;if(r)return r.length>40?r.slice(0,37)+"...":r;if(o){const s=o.split("/").pop()||o;return s.length>40?s.slice(0,37)+"...":s}return"(image)"}if(n.block_type==="collapsible"){const r=n.metadata?.title,o=Array.isArray(n.source)?n.source.join(" "):n.source,s=r||o||"";return s.length>40?s.slice(0,37)+"...":s||"(untitled)"}const t=Array.isArray(n.source)?n.source.join(`
219
+ `);if((j===-1?B:B.substring(0,j)).trim().length>0){let K=!1;const H=O.getChildren();for(const ie of H)if(ds(ie)){K=!0;break}if(!K){i(null);return}}f.current&&clearTimeout(f.current);const z=`${M}:${R}`;if(M.trim().length<2){i(null),d.current="";return}f.current=setTimeout(()=>{z!==d.current&&(d.current=z,_.current?.(M,R,N.language||"python","code","auto"))},u)}else{const O=Yg(E,I,k,N.contextBefore,N.contextAfter);if(O.fullText===g.current)return;if(g.current=O.fullText,O.before.trim().length<10){i(null);return}f.current&&clearTimeout(f.current);const M=`prose:${O.fullText.length}`;f.current=setTimeout(()=>{M!==d.current&&(d.current=M,_.current?.(O.fullText,O.before.length,N.language||"markdown","prose","auto"))},u)}})})},[o,t,u,c.code,c.prose,a]),S.useEffect(()=>{t&&o.update(()=>{const w=D();if(F(w)){if(h.current){const C=Q(h.current);C&&ds(C)&&C.remove(),h.current=null}if(s&&s.trim().length>0){const C=hc(s),v=w.anchor.getNode(),k=w.anchor.offset;v.getType()==="text"?v.splitText(k)[0].insertAfter(C):(v.getType(),v.insertAfter(C)),h.current=C.getKey()}}})},[o,s,t]),S.useEffect(()=>{if(!(!t||!s))return o.registerNodeTransform(Nt,w=>{const C=D();if(!F(C))return;const v=C.anchor.getNode();if(bl(v)!==w)return;if(!w.getChildren().some(N=>ds(N))&&s.trim()){const N=hc(s),O=C.anchor.getNode(),M=C.anchor.offset;O.getType()==="text"?O.splitText(M)[0].insertAfter(N):(O.getType(),O.insertAfter(N)),h.current=N.getKey()}})},[o,s,t]),S.useEffect(()=>{if(t)return o.registerCommand(Kr,w=>s?(w?.preventDefault(),o.update(()=>{const C=D();if(F(C)){if(h.current){const v=Q(h.current);if(v&&ds(v)){const k=$e(s);v.replace(k),h.current=null,k.select();const I=D();F(I)&&(I.anchor.set(k.getKey(),s.length,"text"),I.focus.set(k.getKey(),s.length,"text"))}}i(null)}}),!0):!1,qe)},[o,t,s]),S.useEffect(()=>{if(t)return o.registerCommand(Nn,()=>s?(i(null),!0):!1,ee)},[o,t,s]),S.useEffect(()=>{if(!t)return;const w=v=>{["Alt","AltGraph","Control","Meta","Shift","Dead","CapsLock","NumLock","ScrollLock","Fn"].includes(v.key)||fO(v,c.manualTriggerKey)&&(v.preventDefault(),o.dispatchCommand(Gg,void 0))},C=o.getRootElement();if(C)return C.addEventListener("keydown",w),()=>{C.removeEventListener("keydown",w)}},[o,t,c.manualTriggerKey]),S.useEffect(()=>{if(t)return o.registerCommand(Gg,()=>(o.getEditorState().read(()=>{const w=D();if(!F(w)||!w.isCollapsed())return;const C=w.anchor.getNode(),v=Zg(C),k=v==="code"?c.code:c.prose;if(k.triggerMode!=="disabled")if(f.current&&(clearTimeout(f.current),f.current=null),v==="code"){const I=bl(C);if(!I)return;const E=I.getTextContent(),N=Qg(I,w),O=`${E}:${N}`;d.current=O,_.current?.(E,N,k.language||"python","code","manual")}else{const I=Yg(v,C,w,k.contextBefore,k.contextAfter);if(I.before.trim().length<10)return;const E=`prose:manual:${I.fullText.length}`;d.current=E,_.current?.(I.fullText,I.before.length,k.language||"markdown","prose","manual")}}),!0),qe)},[o,t,c]),null}const dO={space:"Space",enter:"Enter",tab:"Tab",escape:"Escape",backspace:"Backspace",delete:"Delete",arrowup:"ArrowUp",arrowdown:"ArrowDown",arrowleft:"ArrowLeft",arrowright:"ArrowRight",a:"KeyA",b:"KeyB",c:"KeyC",d:"KeyD",e:"KeyE",f:"KeyF",g:"KeyG",h:"KeyH",i:"KeyI",j:"KeyJ",k:"KeyK",l:"KeyL",m:"KeyM",n:"KeyN",o:"KeyO",p:"KeyP",q:"KeyQ",r:"KeyR",s:"KeyS",t:"KeyT",u:"KeyU",v:"KeyV",w:"KeyW",x:"KeyX",y:"KeyY",z:"KeyZ"};function fO(n,e){const t=e.split("+").map(u=>u.trim().toLowerCase()),r=t[t.length-1],o=t.slice(0,-1),s=dO[r];if(s){if(n.code!==s)return!1}else if(n.key.toLowerCase()!==r)return!1;const i=o.includes("ctrl"),a=o.includes("cmd")||o.includes("meta"),l=o.includes("shift"),c=o.includes("alt");return!(i&&!n.ctrlKey||a&&!n.metaKey||l&&!n.shiftKey||c&&!n.altKey)}function Zg(n){let e=n;for(;e;){if(st(e))return"code";e=e.getParent()}return"prose"}function bl(n){let e=n;for(;e;){if(st(e))return e;if(tt(e)){const t=e.getParent();if(t&&st(t))return t}e=e.getParent()}}function Qg(n,e){try{const t=n.getFirstDescendant(),r=t?t.getKey():n.getKey(),o=0,s=t?"text":"element",i=e.clone();return i.anchor.set(r,o,s),i.focus.set(e.anchor.key,e.anchor.offset,e.anchor.type),i.getTextContent().length}catch(t){return console.error("[InlineCompletionPlugin] Error getting cursor offset:",t),0}}function gO(n){if(n.block_type==="horizontalrule")return"";if(n.block_type==="youtube"){const r=n.metadata?.videoID;return r?`youtu.be/${r}`:"(no ID)"}if(n.block_type==="excalidraw"){const r=Gu(n.metadata?.data);return r.elements.length>0?Qu(r):"(empty diagram)"}if(n.block_type==="table"){const r=n.metadata?.rows||0,o=n.metadata?.columns||0;return`${r}×${o} table`}if(n.block_type==="equation"){const r=n.metadata?.equation||"",o=n.metadata?.inline,s=r.length>20?r.slice(0,20)+"...":r;return o?`$${s}$`:`$$${s}$$`}if(n.block_type==="image"){const r=n.metadata?.altText||"",o=n.metadata?.src;if(r)return r.length>40?r.slice(0,37)+"...":r;if(o){const s=o.split("/").pop()||o;return s.length>40?s.slice(0,37)+"...":s}return"(image)"}if(n.block_type==="collapsible"){const r=n.metadata?.title,o=Array.isArray(n.source)?n.source.join(" "):n.source,s=r||o||"";return s.length>40?s.slice(0,37)+"...":s||"(untitled)"}const t=Array.isArray(n.source)?n.source.join(`
220
220
  `):n.source;if(n.block_type==="list"){const o=t.split(`
221
221
  `).map(s=>s.trim()).filter(s=>s.length>0).join(", ");return o.length>40?o.slice(0,37)+"...":o}if(n.block_type==="code"||n.block_type==="jupyter-cell"){const r=t.split(`
222
222
  `)[0]||"";return r.length>40?r.slice(0,37)+"...":r}return t.length>40?t.slice(0,37)+"...":t}function yl(n,e="brief"){const t=[];return n.getEditorState().read(()=>{const o=se().getChildren(),s=new Set;for(let i=0;i<o.length;i++){const a=o[i],l=a.getType();if(l==="jupyter-output"){s.add(a.getKey());continue}if(l==="collapsible-title")continue;if(l==="collapsible-container"){const u=wl(a);u&&t.push(u);const d=(a.getChildren?.()||[]).find(g=>g.getType()==="collapsible-content");if(d){const g=a.getKey(),h=d.getChildren?.()||[];for(const _ of h){const m=_.getType();if(m==="jupyter-input"){let b=null;const w=h.indexOf(_);for(let v=w+1;v<h.length;v++)if(h[v].getType()==="jupyter-output"){b=h[v],s.add(b.getKey());break}const C=ep(_,b);C&&(C.metadata={...C.metadata,collapsible:g},t.push(C))}else if(m==="jupyter-output")s.has(_.getKey())||s.add(_.getKey());else{const b=wl(_);b&&(b.metadata={...b.metadata,collapsible:g},t.push(b))}}}continue}if(l==="jupyter-input"){const u=a;let f=null;for(let g=i+1;g<o.length;g++)if(o[g].getType()==="jupyter-output"){f=o[g],s.add(f.getKey());break}const d=ep(u,f);d&&t.push(d);continue}const c=wl(a);c&&t.push(c)}}),e==="brief"?t.map(r=>({block_id:r.block_id,block_type:r.block_type,preview:gO(r),collapsible:r.metadata?.collapsible||""})):t}function ep(n,e){const t=n.getKey(),r=n.getTextContent(),s=n.getLanguage?.()||"python";let i;if(e){const a=e,l=a.getLatest?.()||a,c=l.getOutputs?.()||l.__outputs||a.getOutputs?.()||a.__outputs;c&&Array.isArray(c)&&c.length>0&&(i=c)}return{block_id:t,block_type:"jupyter-cell",source:r,metadata:{language:s,outputs:i}}}function wl(n){const e=n.getType(),t=n.getKey();if(Wr(n)){const o=n.getTag(),s=parseInt(o.substring(1)),{text:i,formatting:a}=lo(n);return{block_id:t,block_type:"heading",source:i,metadata:{level:s},formatting:a}}if(Vn(n)){const{text:o,formatting:s}=lo(n);return{block_id:t,block_type:"quote",source:o,formatting:s}}if(je(n)){const o=n.getLanguage()||"plaintext",s=n.getTextContent();return{block_id:t,block_type:"code",source:s,metadata:{language:o}}}if(Z(n)){const s={bullet:"bullet",number:"number",check:"check"}[n.getListType()]||"bullet",{text:i,formatting:a}=lo(n);return{block_id:t,block_type:"list",source:i,metadata:{list_type:s},formatting:a}}if(e==="listitem"){const{text:o,formatting:s}=lo(n),i=n.getChecked?.()??void 0;return{block_id:t,block_type:"listitem",source:o,metadata:i!==void 0?{checked:i}:void 0,formatting:s}}if(e==="paragraph"){const o="getChildren"in n?n.getChildren():[];if(o.length===1){const a=o[0].getType();if(a==="equation"){const l=o[0],c=l,u=c.getEquation?.()||c.__equation||"",f=c.getInline?.()??c.__inline??!1;return{block_id:l.getKey(),block_type:"equation",source:u,metadata:{equation:u,inline:f}}}if(a==="excalidraw"){const l=o[0],c=l,u=c.__data||"[]",f=c.getWidth?.()||c.__width||"inherit",d=c.getHeight?.()||c.__height||"inherit";return{block_id:l.getKey(),block_type:"excalidraw",source:"",metadata:{data:u,width:f==="inherit"?void 0:f,height:d==="inherit"?void 0:d}}}}const{text:s,formatting:i}=lo(n);return{block_id:t,block_type:"paragraph",source:s,formatting:i}}if(e==="jupyter-cell"){const o=n.getTextContent(),s=n,i=s.getLanguage?.()||"python",a=s.getOutputs?.()||[];return{block_id:t,block_type:"jupyter-cell",source:o,metadata:{language:i,outputs:a.length>0?a:void 0}}}if(e==="jupyter-input"){const o=n.getTextContent(),i=n.getLanguage?.()||"python";return{block_id:t,block_type:"jupyter-cell",source:o,metadata:{language:i,outputs:void 0}}}if(e==="jupyter-output")return null;if(e==="image"){const o=n,s=o.getSrc?.()||o.__src||"",i=o.getAltText?.()||o.__altText||"";return{block_id:t,block_type:"image",source:"",metadata:{src:s,alt_text:i}}}if(e==="equation"){const o=n,s=o.getEquation?.()||o.__equation||"",i=o.getInline?.()??o.__inline??!1;return{block_id:t,block_type:"equation",source:s,metadata:{equation:s,inline:i}}}if(e==="youtube"){const o=n,s=o.getId?.()||o.__id||"";return{block_id:t,block_type:"youtube",source:"",metadata:{videoID:s}}}if(e==="excalidraw"){const o=n,s=o.__data||"[]",i=o.getWidth?.()||o.__width||"inherit",a=o.getHeight?.()||o.__height||"inherit";return{block_id:t,block_type:"excalidraw",source:"",metadata:{data:s,width:i==="inherit"?void 0:i,height:a==="inherit"?void 0:a}}}if(e==="table"){const s=n.getChildren?.()||[],i=s.length,a=i>0&&s[0].getChildren?.()?.length||0,l=[];for(const u of s){const f=u.getChildren?.()||[],d=[];for(const g of f)d.push(g.getTextContent().trim());l.push(d)}const c=l.map((u,f)=>{const d=u.join(" | ");if(f===0){const g=u.map(()=>"---").join(" | ");return`| ${d} |
@@ -224,19 +224,19 @@ ${n.stack}`:r}function Mk(){let n,e;try{const o=p.__wbindgen_add_to_stack_pointe
224
224
  `);return{block_id:t,block_type:"table",source:c,metadata:{rows:i,columns:a,data:l}}}if(e==="collapsible-container"){const o=n,s=o.getOpen?.()||o.__open||!1,i=o.getChildren?.()||[];let a="";return i[0]?.getType()==="collapsible-title"&&(a=i[0].getTextContent()),{block_id:t,block_type:"collapsible",source:a,metadata:{open:s,title:a}}}if(e==="collapsible-title")return null;const r=n.getTextContent();return{block_id:t,block_type:e,source:r}}function lo(n){const e=[];let t=!1;const r=n.getTextContent(),o="getChildren"in n?n.getChildren():[];if(o.length>0)for(const s of o)if(s.getType()==="text"){const i=s.getTextContent(),a=s.getFormat?.()||0;e.push({text:i,format:a}),a!==0&&(t=!0)}else{const i=lo(s);i.formatting?(e.push(...i.formatting),t=!0):e.push({text:i.text,format:0})}else{const s="getFormat"in n&&n.getFormat?.()||0;e.push({text:r,format:s}),s!==0&&(t=!0)}return{text:r,formatting:t&&e.length>0?e:void 0}}function tp(n){const s=[];let i=0;const a=[{regex:/\*\*\*(.*?)\*\*\*/g,format:3},{regex:/\*\*(.*?)\*\*/g,format:1},{regex:/\*(.*?)\*/g,format:2},{regex:/~~(.*?)~~/g,format:4},{regex:/`(.*?)`/g,format:16}],l=[];for(const c of a){c.regex.lastIndex=0;let u;for(;(u=c.regex.exec(n))!==null;)l.some(d=>u.index>=d.start&&u.index<d.end||u.index+u[0].length>d.start&&u.index+u[0].length<=d.end)||l.push({start:u.index,end:u.index+u[0].length,text:u[1],format:c.format})}l.sort((c,u)=>c.start-u.start);for(const c of l){if(c.start>i){const u=n.substring(i,c.start);u&&s.push({text:u,format:0})}s.push({text:c.text,format:c.format}),i=c.end}if(i<n.length){const c=n.substring(i);c&&s.push({text:c,format:0})}return s.length===0&&s.push({text:n,format:0}),s}class pO{_editor;_defaultBlockType="paragraph";_serviceManager;_runAllAbortController=null;constructor(e,t){this._editor=e,this._serviceManager=t}get editor(){return this._editor}get serviceManager(){return this._serviceManager}setDefaultBlockType(e){this._defaultBlockType=e}get defaultBlockType(){return this._defaultBlockType}async getBlocks(e="brief"){return new Promise(t=>{const r=yl(this._editor,e);t(r)})}async getBlock(e){return new Promise(t=>{const r=yl(this._editor,"detailed");e>=0&&e<r.length?t(r[e]):t(null)})}async getBlockById(e){return new Promise(t=>{const o=yl(this._editor,"detailed").find(s=>s.block_id===e);t(o||null)})}async getBlockCount(){return(await this.getBlocks()).length}async insertBlock(e,t){const r=Array.isArray(e.source)?e.source.join(`
225
225
  `):e.source;if((e.block_type==="paragraph"||e.block_type==="text")&&this.containsBlockLevelMarkdown(r)){const s=this.parseMarkdownToBlocks(r);if(s.length>1){let i=t,a;for(const l of s){l.metadata={...l.metadata,...e.metadata};const c=await this.insertBlock(l,i);if(!c.success)return c;c.blockId&&(a=c.blockId,i=c.blockId)}return{success:!0,blockId:a,message:`Inserted ${s.length} blocks from markdown`}}}if(e.metadata?.collapsible){const s=e.metadata.collapsible;return s==="TOP"||s==="BOTTOM"?Promise.resolve({success:!1,error:`Invalid collapsible ID: "${s}". To insert blocks inside a collapsible: 1) First insert the collapsible container (returns blockId), 2) Then insert nested blocks with properties.collapsible set to that blockId. Use afterId for positioning (TOP/BOTTOM/blockId), not properties.collapsible.`}):new Promise(i=>{this._editor.update(()=>{const c=se().getChildren().find(g=>g.getKey()===s);if(!c||c.getType()!=="collapsible-container"){i({success:!1,error:`Collapsible container ${s} not found`});return}const f=(c.getChildren?.()||[]).find(g=>g.getType()==="collapsible-content");if(!f){i({success:!1,error:`Collapsible content node not found in ${s}`});return}const d={...e,metadata:{...e.metadata,collapsible:void 0}};this.insertBlock(d,"BOTTOM").then(g=>{if(!g.success||!g.blockId){i({success:!1,error:`Failed to insert ${e.block_type}: ${g.error||"Unknown error"}`});return}setTimeout(()=>{this._editor.update(()=>{const m=se().getChildren().find(b=>b.getKey()===g.blockId);if(!m){i({success:!1,error:`Could not find inserted node ${g.blockId}`});return}m.remove(),f.append(m),i({success:!0,blockId:g.blockId,message:`Block of type '${e.block_type}' inserted inside collapsible ${s}`})})},50)}).catch(g=>{i({success:!1,error:`Failed to insert block: ${g.message||String(g)}`})})})})}return this.requiresCommand(e.block_type)?this.insertViaCommand(e,t):this.insertViaNode(e,t)}async deleteBlock(e){try{const t=await this.getBlocks("detailed"),r=new Set(t.map(a=>a.block_id)),o=[];for(const a of e)r.has(a)||o.push(a);if(o.length>0)return{success:!1,error:`Block ID(s) not found: ${o.join(", ")}. Document has ${t.length} blocks.`};const s=[...e].sort((a,l)=>{const c=t.findIndex(f=>f.block_id===a);return t.findIndex(f=>f.block_id===l)-c}),i=[];for(const a of s){const l=await this._deleteSingleBlock(a);if(l.success)i.push({id:a});else{if(l.error?.includes("not found"))continue;return l}}return{success:!0,deletedBlocks:i}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async _deleteSingleBlock(e){return new Promise(t=>{this._editor.update(()=>{try{const r=se(),o=(l,c)=>{if(l.getKey()===c)return l;if("getChildren"in l){const u=l.getChildren();for(const f of u){const d=o(f,c);if(d)return d}}return null},s=o(r,e);if(!s){t({success:!1,error:`Block with ID ${e} not found`});return}const i=s.getType(),a=s.getParent();(i==="equation"||i==="excalidraw")&&a&&a.getType()==="paragraph"?a.remove():s.remove(),t({success:!0})}catch(r){t({success:!1,error:r instanceof Error?r.message:String(r)})}})})}async updateBlock(e,t){const r=await this.deleteBlock([e]);if(!r.success)return r;const o=await this.getBlocks(),s=o.findIndex(a=>a.block_id===e),i=s>0?o[s-1].block_id:"TOP";return this.insertBlock(t,i)}async runBlock(e){if(!e){let o=null;if(this._editor.getEditorState().read(()=>{const s=D();if(!s)return;const i=s.getNodes();if(i.length===0)return;let l=i[0];for(;l;){const c=l.getType();if(c==="jupyter-cell"||c==="jupyter-input"){o=l.getKey();break}const u=l.getParent();if(!u)break;l=u}}),!o)return{success:!1,error:"No jupyter cell is currently focused"};e=o}const t=await this.getBlockById(e);if(!t)return{success:!1,error:`Block with ID ${e} not found`};if(!["jupyter-cell","jupyter-input"].includes(t.block_type))return{success:!1,error:`Block type ${t.block_type} is not executable`};try{const o=Date.now(),s=await new Promise((c,u)=>{this._editor.update(()=>{try{const f=se();let d=null,g="";const h=m=>{if(m.getType()==="jupyter-cell"&&m.getKey()===e)return m.getChildren().forEach(C=>{C.getType()==="jupyter-input"?g=C.getTextContent():C.getType()==="jupyter-output"&&(d=C)}),!0;if(m.getType()==="jupyter-input"&&m.getKey()===e){g=m.getTextContent();const w=m.getJupyterInputNodeUuid();return d=dr(w),!0}const b=m.getChildren?.()||[];for(const w of b)if(h(w))return!0;return!1};for(const m of f.getChildren())if(h(m))break;if(!d){u(new Error("Could not find jupyter-output node for execution"));return}if(!g||g.trim()===""){u(new Error("No code to execute"));return}d.executeCode(g);const _=d.__outputAdapter;if(!_){u(new Error("No outputAdapter available"));return}c({outputAdapter:_,code:g})}catch(f){u(f)}})});await new Promise(c=>setTimeout(c,500));const i=s.outputAdapter.outputArea.model.toJSON(),a=(Date.now()-o)/1e3;return{success:!0,execution_count:i.length>0?1:null,outputs:i,elapsed_time:a,message:`Block executed in ${a.toFixed(2)}s`}}catch(o){return{success:!1,error:`Failed to execute block: ${o instanceof Error?o.message:String(o)}`}}}async runAllBlocks(){this._runAllAbortController&&this._runAllAbortController.abort(),this._runAllAbortController=new AbortController;const e=this._runAllAbortController.signal;try{const r=(await this.getBlocks()).filter(o=>o.block_type==="jupyter-cell");for(const o of r){if(e.aborted)return{success:!1,error:"Run all blocks was cancelled (new run all started)"};const s=await this.runBlock(o.block_id);if(!s.success)return console.error(`[LexicalAdapter] Block ${o.block_id} failed:`,s.error),{success:!1,error:`Failed to run block ${o.block_id}: ${s.error}`}}return{success:!0,blockId:r.length>0?r[r.length-1].block_id:void 0}}finally{this._runAllAbortController?.signal===e&&(this._runAllAbortController=null)}}async clearAllOutputs(){return new Promise(e=>{this._editor.update(()=>{let t=0;function r(s){if(s.getType&&s.getType()==="jupyter-output"&&s.__outputAdapter&&(s.__outputAdapter.clear(),t++),s.getChildren){const i=s.getChildren();for(const a of i)r(a)}}const o=se();r(o),e({success:!0,message:t>0?`Cleared outputs from ${t} jupyter cells`:"No jupyter cells found to clear"})})})}async restartKernel(){return new Promise(e=>{me(()=>Promise.resolve().then(()=>Uf),void 0,import.meta.url).then(t=>{const{RESTART_JUPYTER_KERNEL_COMMAND:r}=t,o=this._editor.dispatchCommand(r,void 0);e(o?{success:!0,message:"Kernel restart initiated"}:{success:!1,error:"RESTART_JUPYTER_KERNEL_COMMAND was not handled"})}).catch(t=>{e({success:!1,error:`Failed to load restart command: ${t.message}`})})})}requiresCommand(e){return["jupyter-cell","image","equation","youtube","excalidraw","table","collapsible"].includes(e)}async insertViaCommand(e,t){return new Promise(async r=>{try{if(e.block_type==="equation"){const{INSERT_EQUATION_COMMAND:o}=await me(async()=>{const{INSERT_EQUATION_COMMAND:l}=await Promise.resolve().then(()=>kL);return{INSERT_EQUATION_COMMAND:l}},void 0,import.meta.url),s=Array.isArray(e.source)?e.source.join(`
226
226
  `):e.source,i=e.metadata?.equation||e.metadata?.latex||s,a=!1;this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(u.append($e("__EQUATION_MARKER__")),t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const f=se().getChildren().find(d=>d.getType()==="paragraph"&&d.getTextContent()==="__EQUATION_MARKER__");f&&(f.selectEnd(),f.remove())}),this._editor.dispatchCommand(o,{equation:i,inline:a});let l;setTimeout(()=>{this._editor.getEditorState().read(()=>{const u=se().getChildren();for(let f=u.length-1;f>=0;f--)if(u[f].getType()==="equation"){l=u[f].getKey();break}}),r({success:!0,blockId:l})},20)},10)}else if(e.block_type==="jupyter-cell"){const{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:o}=await me(async()=>{const{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:l}=await Promise.resolve().then(()=>Uf);return{INSERT_JUPYTER_INPUT_OUTPUT_COMMAND:l}},void 0,import.meta.url),i={code:Array.isArray(e.source)?e.source.join(`
227
- `):e.source,outputs:e.metadata?.outputs||[],loading:""};this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}u.selectStart(),this._editor.dispatchCommand(o,i)});let a;setTimeout(()=>{this._editor.getEditorState().read(()=>{const l=se(),c=(f,d)=>{let g=null;if(f.getType()===d&&(g=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(g=_)}return g},u=c(l,"jupyter-input");u&&(a=u.getKey())}),r({success:!0,blockId:a})},20)}else if(e.block_type==="youtube"){const{INSERT_YOUTUBE_COMMAND:o}=await me(async()=>{const{INSERT_YOUTUBE_COMMAND:c}=await import("./YouTubePlugin-CjgOnMCz.js");return{INSERT_YOUTUBE_COMMAND:c}},[],import.meta.url),s=Array.isArray(e.source)?e.source.join(`
227
+ `):e.source,outputs:e.metadata?.outputs||[],loading:""};this._editor.update(()=>{const l=se(),c=l.getChildren(),u=ne();if(t==="TOP")c.length>0?c[0].insertBefore(u):l.append(u);else if(t==="BOTTOM"||!t)l.append(u);else{const f=c.find(d=>d.getKey()===t);if(f)f.insertAfter(u);else throw new Error(`Block ID ${t} not found`)}u.selectStart(),this._editor.dispatchCommand(o,i)});let a;setTimeout(()=>{this._editor.getEditorState().read(()=>{const l=se(),c=(f,d)=>{let g=null;if(f.getType()===d&&(g=f),"getChildren"in f&&typeof f.getChildren=="function")for(const h of f.getChildren()){const _=c(h,d);_&&(g=_)}return g},u=c(l,"jupyter-input");u&&(a=u.getKey())}),r({success:!0,blockId:a})},20)}else if(e.block_type==="youtube"){const{INSERT_YOUTUBE_COMMAND:o}=await me(async()=>{const{INSERT_YOUTUBE_COMMAND:c}=await import("./YouTubePlugin-BB7Z7INn.js");return{INSERT_YOUTUBE_COMMAND:c}},[],import.meta.url),s=Array.isArray(e.source)?e.source.join(`
228
228
  `):e.source,a=(c=>{const u=c.trim();if(/^[a-zA-Z0-9_-]{11}$/.test(u))return u;const f=u.match(/youtu\.be\/([a-zA-Z0-9_-]{11})/);if(f)return f[1];const d=u.match(/[?&]v=([a-zA-Z0-9_-]{11})/);return d?d[1]:"lO2p9LQB7ds"})(s||"");await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,a)});let l;setTimeout(()=>{this._editor.getEditorState().read(()=>{const u=se().getChildren();for(let f=u.length-1;f>=0;f--)if(u[f].getType()==="youtube"){l=u[f].getKey();break}}),r({success:!0,blockId:l})},20)}else if(e.block_type==="excalidraw"){const{$createExcalidrawNode:o}=await me(async()=>{const{$createExcalidrawNode:f}=await Promise.resolve().then(()=>n1);return{$createExcalidrawNode:f}},void 0,import.meta.url),{$wrapNodeInElement:s}=await me(async()=>{const{$wrapNodeInElement:f}=await import("../datalayer-app-main.js").then(d=>d.tC);return{$wrapNodeInElement:f}},[],import.meta.url),{$isRootOrShadowRoot:i}=await me(async()=>{const{$isRootOrShadowRoot:f}=await import("../datalayer-app-main.js").then(d=>d.tB);return{$isRootOrShadowRoot:f}},[],import.meta.url),a=e.metadata?.data||"[]",l=e.metadata?.width,c=e.metadata?.height;let u;this._editor.update(()=>{const f=o(a,l||"inherit",c||"inherit");this.insertNodeAtPosition(f,t),u=f.getKey(),i(f.getParentOrThrow())&&s(f,ne).selectEnd()}),r({success:!0,blockId:u})}else if(e.block_type==="table"){const{INSERT_TABLE_COMMAND:o}=await me(async()=>{const{INSERT_TABLE_COMMAND:g}=await Promise.resolve().then(()=>Tf);return{INSERT_TABLE_COMMAND:g}},void 0,import.meta.url),{$getTableCellNodeFromLexicalNode:s,$getTableNodeFromLexicalNodeOrThrow:i}=await me(async()=>{const{$getTableCellNodeFromLexicalNode:g,$getTableNodeFromLexicalNodeOrThrow:h}=await Promise.resolve().then(()=>Tf);return{$getTableCellNodeFromLexicalNode:g,$getTableNodeFromLexicalNodeOrThrow:h}},void 0,import.meta.url);let a=e.metadata?.rows||2,l=e.metadata?.columns||2,c=e.metadata?.data;const u=e.metadata?.includeHeaders!==!1;c&&Array.isArray(c)&&c.length>0&&(a=c.length,l=c[0].length);const f=Array.isArray(e.source)?e.source.join(`
229
229
  `):e.source;if(f&&typeof f=="string"&&f.includes("|"))try{const g=f.split(`
230
- `).filter(_=>_.trim()),h=[];for(const _ of g){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(b=>b.trim());m.length>0&&h.push(m)}h.length>0&&(c=h,a=h.length,l=h[0].length)}catch{}await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,{rows:a.toString(),columns:l.toString(),includeHeaders:u})});let d;setTimeout(()=>{this._editor.update(()=>{const h=se().getChildren();for(let _=h.length-1;_>=0;_--)if(h[_].getType()==="table"){if(d=h[_].getKey(),c&&c.length>0)try{const b=i(h[_]).getChildren();for(let w=0;w<Math.min(c.length,b.length);w++){const v=b[w].getChildren();for(let k=0;k<Math.min(c[w].length,v.length);k++){const I=s(v[k]);I&&(I.clear(),I.append($e(c[w][k])))}}}catch{}break}}),r({success:!0,blockId:d})},20)}else if(e.block_type==="collapsible"){const{INSERT_COLLAPSIBLE_COMMAND:o}=await me(async()=>{const{INSERT_COLLAPSIBLE_COMMAND:l}=await import("./index-CxIZHPCc.js");return{INSERT_COLLAPSIBLE_COMMAND:l}},[],import.meta.url),s=e.metadata?.open??!0,i=Array.isArray(e.source)?e.source.join(`
230
+ `).filter(_=>_.trim()),h=[];for(const _ of g){if(_.match(/^\|?[\s-|]+\|?$/))continue;const m=_.split("|").slice(1,-1).map(b=>b.trim());m.length>0&&h.push(m)}h.length>0&&(c=h,a=h.length,l=h[0].length)}catch{}await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,{rows:a.toString(),columns:l.toString(),includeHeaders:u})});let d;setTimeout(()=>{this._editor.update(()=>{const h=se().getChildren();for(let _=h.length-1;_>=0;_--)if(h[_].getType()==="table"){if(d=h[_].getKey(),c&&c.length>0)try{const b=i(h[_]).getChildren();for(let w=0;w<Math.min(c.length,b.length);w++){const v=b[w].getChildren();for(let k=0;k<Math.min(c[w].length,v.length);k++){const I=s(v[k]);I&&(I.clear(),I.append($e(c[w][k])))}}}catch{}break}}),r({success:!0,blockId:d})},20)}else if(e.block_type==="collapsible"){const{INSERT_COLLAPSIBLE_COMMAND:o}=await me(async()=>{const{INSERT_COLLAPSIBLE_COMMAND:l}=await import("./index-DY8mjz1l.js");return{INSERT_COLLAPSIBLE_COMMAND:l}},[],import.meta.url),s=e.metadata?.open??!0,i=Array.isArray(e.source)?e.source.join(`
231
231
  `):e.source||"";await this.insertWithMarker(t,()=>{this._editor.dispatchCommand(o,void 0)});let a;setTimeout(()=>{this._editor.update(()=>{const c=se().getChildren();for(let u=c.length-1;u>=0;u--)if(c[u].getType()==="collapsible-container"){const f=c[u];a=f.getKey(),f.setOpen?.(s);const d=f.getChildren();d[0]&&i&&(d[0].clear(),d[0].append($e(i)));break}}),r({success:!0,blockId:a})},20)}else r({success:!1,error:`Unsupported command-based block type: ${e.block_type}`})}catch(o){r({success:!1,error:o instanceof Error?o.message:String(o)})}})}async insertViaNode(e,t){return new Promise(r=>{this._editor.update(()=>{try{const o=se(),s=this.createSimpleNode(e);if(!s){r({success:!1,error:`Failed to create node for type: ${e.block_type}`});return}const i=o.getChildren();if(t==="TOP")i.length>0?i[0].insertBefore(s):o.append(s);else if(t==="BOTTOM"||!t)o.append(s);else{const a=i.find(l=>l.getKey()===t);if(a)a.insertAfter(s);else{r({success:!1,error:`Block ID ${t} not found`});return}}r({success:!0,blockId:s.getKey()})}catch(o){r({success:!1,error:o instanceof Error?o.message:String(o)})}})})}createSimpleNode(e){const t=Array.isArray(e.source)?e.source.join(`
232
232
  `):e.source,r=()=>e.formatting&&e.formatting.length>0?e.formatting.map(o=>{const s=$e(o.text);return o.format&&s.setFormat(o.format),s}):tp(t||"").map(s=>{const i=$e(s.text);return s.format&&i.setFormat(s.format),i});switch(e.block_type){case"paragraph":{const o=ne();return r().forEach(s=>o.append(s)),o}case"heading":{const s=`h${e.metadata?.level||1}`,i=fn(s);return r().forEach(a=>i.append(a)),i}case"code":{const o=e.metadata?.language||"plaintext",s=Ze(o);return s.append($e(t)),s}case"quote":{const o=Ln();return r().forEach(s=>o.append(s)),o}case"list":{const o=e.metadata?.listType||"bullet",s=Et(o),i=t.split(`
233
233
  `).map(a=>a.trim()).filter(a=>a.length>0);if(i.length===0){const a=xt();s.append(a)}else i.forEach(a=>{const l=xt();tp(a).forEach(u=>{const f=$e(u.text);u.format&&f.setFormat(u.format),l.append(f)}),s.append(l)});return s}case"horizontalrule":return ba();case"listitem":{const o=xt();return e.metadata?.checked!==void 0&&o.setChecked(e.metadata.checked),r().forEach(s=>o.append(s)),o}default:return null}}containsBlockLevelMarkdown(e){return!e||typeof e!="string"?!1:!!(/^#{1,6}[ \t]+\S/m.test(e)||/^[ \t]*[-*+][ \t]+\S/m.test(e)||/^[ \t]*\d+\.[ \t]+\S/m.test(e)||/\n\s*\n/.test(e))}parseMarkdownToBlocks(e){const t=[],r=e.split(`
234
234
  `);let o=null;for(let s=0;s<r.length;s++){const i=r[s],a=i.trim();if(a===""){o&&o.lines.length>0&&(t.push(this.createBlockFromParsed(o)),o=null);continue}const l=a.match(/^(#{1,6})\s+(\S.*)$/);if(l){o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o));const f=l[1].length;t.push({block_id:"",block_type:"heading",source:l[2],metadata:{tag:`h${f}`}}),o=null;continue}const c=a.match(/^[-*+]\s+(\S.*)$/);if(c){!o||o.type!=="list-bullet"?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"list-bullet",lines:[c[1]],metadata:{listType:"bullet"}}):o.lines.push(c[1]);continue}const u=a.match(/^\d+\.\s+(\S.*)$/);if(u){!o||o.type!=="list-number"?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"list-number",lines:[u[1]],metadata:{listType:"number"}}):o.lines.push(u[1]);continue}!o||o.type.startsWith("list-")?(o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),o={type:"paragraph",lines:[i]}):o.lines.push(i)}return o&&o.lines.length>0&&t.push(this.createBlockFromParsed(o)),t}createBlockFromParsed(e){return e.type==="list-bullet"||e.type==="list-number"?{block_id:"",block_type:"list",source:e.lines.join(`
235
235
  `),metadata:e.metadata||{}}:{block_id:"",block_type:e.type,source:e.lines.join(`
236
- `),metadata:e.metadata||{}}}async executeCode(e,t,r,o){const s=e||"";if(!s.trim())return{success:!1,error:"Code parameter is required and cannot be empty"};if(!this._serviceManager)return{success:!1,error:"No ServiceManager available. LexicalAdapter requires a ServiceManager to execute code."};let i;try{await this._serviceManager.kernels.refreshRunning();const a=Array.from(this._serviceManager.kernels.running());if(a.length===0)return{success:!1,error:"No active kernel found. Please start a kernel first."};const l=a[0];i=await this._serviceManager.kernels.connectTo({model:l})}catch(a){return{success:!1,error:`Failed to connect to kernel: ${a instanceof Error?a.message:String(a)}`}}if(!i||typeof i.requestExecute!="function")return{success:!1,error:"Kernel connection does not have requestExecute method."};try{const a=i.requestExecute({code:s,stop_on_error:o??!0,store_history:t??!0,silent:r??!1,allow_stdin:!1}),l=[];let c;return a.onIOPub=u=>{const f=u.header.msg_type;f==="stream"?l.push({type:"stream",content:u.content}):f==="execute_result"?(l.push({type:"execute_result",content:u.content}),c=u.content.execution_count):f==="display_data"?l.push({type:"display_data",content:u.content}):f==="error"&&l.push({type:"error",content:u.content})},await a.done,{success:!0,outputs:l,executionCount:c}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async insertWithMarker(e,t){return new Promise(r=>{this._editor.update(()=>{const o=se(),s=o.getChildren(),i=ne();if(i.append($e("__MARKER__")),e==="TOP")s.length>0?s[0].insertBefore(i):o.append(i);else if(e==="BOTTOM"||!e)o.append(i);else{const a=s.find(l=>l.getKey()===e);if(a)a.insertAfter(i);else throw new Error(`Block ${e} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const s=se().getChildren().find(i=>i.getType()==="paragraph"&&i.getTextContent()==="__MARKER__");s&&(s.selectEnd(),s.remove())}),t(),r()},10)})}insertNodeAtPosition(e,t){const r=se(),o=r.getChildren();if(t==="TOP")o.length>0?o[0].insertBefore(e):r.append(e);else if(t==="BOTTOM"||!t)r.append(e);else{const s=o.find(i=>i.getKey()===t);if(s)s.insertAfter(e);else throw new Error(`Block ${t} not found`)}}async listAvailableBlocks(){try{const{listAvailableBlocksOperation:e}=await me(async()=>{const{listAvailableBlocksOperation:r}=await import("./LexicalToolRegistry-BlBEZPP4.js").then(o=>o.A);return{listAvailableBlocksOperation:r}},[],import.meta.url);return await e.execute({type:"all"},{documentId:"static-operation",executor:null})}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function Sb(n,e,t){const r=new pO(n,t),o=new Map(go.getState().lexicals);return o.set(e,{adapter:r}),go.getState().setLexicals(o),()=>{const s=new Map(go.getState().lexicals);s.delete(e),go.getState().setLexicals(s)}}const hO=pe({name:"@datalayer/jupyter-lexical/LexicalState",config:tr({lexicalId:null,serviceManager:void 0}),build:(n,e)=>nr(e),register:(n,e,t)=>{const{lexicalId:r,serviceManager:o}=t.getOutput();return zt(()=>{const s=r.value;if(s)return Sb(n,s,o.value)})}});function l$(){const[n]=fe(),{lexicalId:e,serviceManager:t}=A0();return S.useEffect(()=>Sb(n,e,t),[n,e,t]),null}const vb=7;function _O(n){const e=n.getNodes();return e.length===0?new Set([n.anchor.getNode().getParentOrThrow(),n.focus.getNode().getParentOrThrow()]):new Set(e.map(t=>q(t)?t:t.getParentOrThrow()))}function mO(n){const e=D();if(!F(e))return!1;const t=_O(e);let r=0;for(const o of t)if(Z(o))r=Math.max(Is(o)+1,r);else if(le(o)){const s=o.getParent();if(!Z(s))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(Is(s)+1,r)}return r<=n}function bO(n,e=vb){return n.registerCommand(Dt,()=>!mO(e),qe)}const yO=pe({name:"@datalayer/jupyter-lexical/ListMaxIndentLevel",config:tr({maxDepth:vb}),dependencies:[da],build:(n,e)=>nr(e),register:(n,e,t)=>{const{maxDepth:r}=t.getOutput();return zt(()=>bO(n,r.value))}});function Cc(n,e){const t={};for(const r of n){const o=e(r);o&&(t[o]?t[o].push(r):t[o]=[r])}return t}function wO(n){const e=Cc(n,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const np=/[!-/:-@[-`{-~\s]/;function rp(n){return n.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const xO=/^(\s*)(\d{1,})\.\s/,CO=/^(\s*)[-*+]\s/,SO=/^(#{1,6})\s/,vO=/^>\s/,kO=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,TO=/^[ \t]*`{3,}$/,fs=Us("mdListMarker",{parse:n=>typeof n=="string"&&/^[-*+]$/.test(n)?n:"-",resetOnCopyNode:!0}),op=Us("mdCodeFence",{parse:n=>typeof n=="string"&&/^`{3,}$/.test(n)?n:"```",resetOnCopyNode:!0}),IO=Us("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:"",resetOnCopyNode:!0});function EO(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];const e=n.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function NO(n){const e=n.getChildren(),t=e.length-1,r=e[t];if(!oe(r))return null;const o=r.getTextContent(),s=EO(o);if(s!==null){const[i,a]=s;return r.setTextContent(i),a}return/^ {2,}$/.test(o)&&(function(i,a){for(let l=a-1;l>=0;l--){if(ue(i[l]))return!1;if(/\S/.test(i[l].getTextContent()))return!0}return!1})(e,t)?(r.setTextContent(""),o):null}function LO(n){const e=vt(),t=NO(n);return t!==null&&xn(e,IO,t),e}const kb=n=>(e,t,r,o)=>{const s=n(r);s.append(...t),e.replace(s),o||s.select(0,0)},Tb=n=>(e,t,r,o)=>{if(Wr(e))return!1;const s=e.getPreviousSibling(),i=e.getNextSibling(),a=xt(n==="check"?r[3]==="x":void 0),l=r[0].trim()[0],c=n!=="bullet"&&n!=="check"||l!==fs.parse(l)?void 0:l;if(Z(i)&&i.getListType()===n){c&&xn(i,fs,c);const f=i.getFirstChild();f!==null?f.insertBefore(a):i.append(a),n==="number"&&i.setStart(Number(r[2])),e.remove()}else if(Z(s)&&s.getListType()===n)c&&xn(s,fs,c),s.append(a),e.remove();else{const f=Et(n,n==="number"?Number(r[2]):void 0);c&&xn(f,fs,c),f.append(a),e.replace(f)}a.append(...t),o||a.select(0,0);const u=(function(f){const d=f.match(/\t/g),g=f.match(/ /g);let h=0;return d&&(h+=d.length),g&&(h+=Math.floor(g.length/4)),h})(r[1]);u&&a.setIndent(u)},ld=(n,e,t,r)=>{const o=[],s=n.getChildren();let i=0;for(const a of s)if(le(a)){if(a.getChildrenSize()===1){const g=a.getFirstChild();if(Z(g)){const h=ld(g,e,t+1,r);h&&o.push(h);continue}}if(r&&!a.getChildren().some(g=>g.isSelected(r)))continue;const l=" ".repeat(4*t),c=n.getListType(),u=Cs(n,fs),f=c==="number"?`${n.getStart()+i}. `:c==="check"?`${u} [${a.getChecked()?"x":" "}] `:u+" ";let d=e(a);c!=="number"&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),o.push(l+f+d),i++}return o.join(`
236
+ `),metadata:e.metadata||{}}}async executeCode(e,t,r,o){const s=e||"";if(!s.trim())return{success:!1,error:"Code parameter is required and cannot be empty"};if(!this._serviceManager)return{success:!1,error:"No ServiceManager available. LexicalAdapter requires a ServiceManager to execute code."};let i;try{await this._serviceManager.kernels.refreshRunning();const a=Array.from(this._serviceManager.kernels.running());if(a.length===0)return{success:!1,error:"No active kernel found. Please start a kernel first."};const l=a[0];i=await this._serviceManager.kernels.connectTo({model:l})}catch(a){return{success:!1,error:`Failed to connect to kernel: ${a instanceof Error?a.message:String(a)}`}}if(!i||typeof i.requestExecute!="function")return{success:!1,error:"Kernel connection does not have requestExecute method."};try{const a=i.requestExecute({code:s,stop_on_error:o??!0,store_history:t??!0,silent:r??!1,allow_stdin:!1}),l=[];let c;return a.onIOPub=u=>{const f=u.header.msg_type;f==="stream"?l.push({type:"stream",content:u.content}):f==="execute_result"?(l.push({type:"execute_result",content:u.content}),c=u.content.execution_count):f==="display_data"?l.push({type:"display_data",content:u.content}):f==="error"&&l.push({type:"error",content:u.content})},await a.done,{success:!0,outputs:l,executionCount:c}}catch(a){return{success:!1,error:a instanceof Error?a.message:String(a)}}}async insertWithMarker(e,t){return new Promise(r=>{this._editor.update(()=>{const o=se(),s=o.getChildren(),i=ne();if(i.append($e("__MARKER__")),e==="TOP")s.length>0?s[0].insertBefore(i):o.append(i);else if(e==="BOTTOM"||!e)o.append(i);else{const a=s.find(l=>l.getKey()===e);if(a)a.insertAfter(i);else throw new Error(`Block ${e} not found`)}}),setTimeout(()=>{this._editor.update(()=>{const s=se().getChildren().find(i=>i.getType()==="paragraph"&&i.getTextContent()==="__MARKER__");s&&(s.selectEnd(),s.remove())}),t(),r()},10)})}insertNodeAtPosition(e,t){const r=se(),o=r.getChildren();if(t==="TOP")o.length>0?o[0].insertBefore(e):r.append(e);else if(t==="BOTTOM"||!t)r.append(e);else{const s=o.find(i=>i.getKey()===t);if(s)s.insertAfter(e);else throw new Error(`Block ${t} not found`)}}async listAvailableBlocks(){try{const{listAvailableBlocksOperation:e}=await me(async()=>{const{listAvailableBlocksOperation:r}=await import("./LexicalToolRegistry-8wJyLumb.js").then(o=>o.A);return{listAvailableBlocksOperation:r}},[],import.meta.url);return await e.execute({type:"all"},{documentId:"static-operation",executor:null})}catch(e){return{success:!1,error:e instanceof Error?e.message:String(e)}}}}function Sb(n,e,t){const r=new pO(n,t),o=new Map(go.getState().lexicals);return o.set(e,{adapter:r}),go.getState().setLexicals(o),()=>{const s=new Map(go.getState().lexicals);s.delete(e),go.getState().setLexicals(s)}}const hO=pe({name:"@datalayer/jupyter-lexical/LexicalState",config:tr({lexicalId:null,serviceManager:void 0}),build:(n,e)=>nr(e),register:(n,e,t)=>{const{lexicalId:r,serviceManager:o}=t.getOutput();return zt(()=>{const s=r.value;if(s)return Sb(n,s,o.value)})}});function l$(){const[n]=fe(),{lexicalId:e,serviceManager:t}=A0();return S.useEffect(()=>Sb(n,e,t),[n,e,t]),null}const vb=7;function _O(n){const e=n.getNodes();return e.length===0?new Set([n.anchor.getNode().getParentOrThrow(),n.focus.getNode().getParentOrThrow()]):new Set(e.map(t=>q(t)?t:t.getParentOrThrow()))}function mO(n){const e=D();if(!F(e))return!1;const t=_O(e);let r=0;for(const o of t)if(Z(o))r=Math.max(Is(o)+1,r);else if(le(o)){const s=o.getParent();if(!Z(s))throw new Error("ListMaxIndentLevelPlugin: A ListItemNode must have a ListNode for a parent.");r=Math.max(Is(s)+1,r)}return r<=n}function bO(n,e=vb){return n.registerCommand(Dt,()=>!mO(e),qe)}const yO=pe({name:"@datalayer/jupyter-lexical/ListMaxIndentLevel",config:tr({maxDepth:vb}),dependencies:[da],build:(n,e)=>nr(e),register:(n,e,t)=>{const{maxDepth:r}=t.getOutput();return zt(()=>bO(n,r.value))}});function Cc(n,e){const t={};for(const r of n){const o=e(r);o&&(t[o]?t[o].push(r):t[o]=[r])}return t}function wO(n){const e=Cc(n,t=>t.type);return{element:e.element||[],multilineElement:e["multiline-element"]||[],textFormat:e["text-format"]||[],textMatch:e["text-match"]||[]}}const np=/[!-/:-@[-`{-~\s]/;function rp(n){return n.replace(/\\([!-/:-@[-`{-~])/g,"$1").replace(/&#(\d+);/g,(e,t)=>String.fromCodePoint(Number(t)))}const xO=/^(\s*)(\d{1,})\.\s/,CO=/^(\s*)[-*+]\s/,SO=/^(#{1,6})\s/,vO=/^>\s/,kO=/^([ \t]*`{3,})([\w-]+)?[ \t]?/,TO=/^[ \t]*`{3,}$/,fs=Us("mdListMarker",{parse:n=>typeof n=="string"&&/^[-*+]$/.test(n)?n:"-",resetOnCopyNode:!0}),op=Us("mdCodeFence",{parse:n=>typeof n=="string"&&/^`{3,}$/.test(n)?n:"```",resetOnCopyNode:!0}),IO=Us("mdHardLineBreak",{parse:n=>typeof n=="string"&&/^(\\| {2,})$/.test(n)?n:"",resetOnCopyNode:!0});function EO(n){if(n.endsWith("\\"))return[n.slice(0,-1),"\\"];const e=n.match(/^(.*?\S)( {2,})$/);return e?[e[1],e[2]]:null}function NO(n){const e=n.getChildren(),t=e.length-1,r=e[t];if(!oe(r))return null;const o=r.getTextContent(),s=EO(o);if(s!==null){const[i,a]=s;return r.setTextContent(i),a}return/^ {2,}$/.test(o)&&(function(i,a){for(let l=a-1;l>=0;l--){if(ue(i[l]))return!1;if(/\S/.test(i[l].getTextContent()))return!0}return!1})(e,t)?(r.setTextContent(""),o):null}function LO(n){const e=vt(),t=NO(n);return t!==null&&xn(e,IO,t),e}const kb=n=>(e,t,r,o)=>{const s=n(r);s.append(...t),e.replace(s),o||s.select(0,0)},Tb=n=>(e,t,r,o)=>{if(Wr(e))return!1;const s=e.getPreviousSibling(),i=e.getNextSibling(),a=xt(n==="check"?r[3]==="x":void 0),l=r[0].trim()[0],c=n!=="bullet"&&n!=="check"||l!==fs.parse(l)?void 0:l;if(Z(i)&&i.getListType()===n){c&&xn(i,fs,c);const f=i.getFirstChild();f!==null?f.insertBefore(a):i.append(a),n==="number"&&i.setStart(Number(r[2])),e.remove()}else if(Z(s)&&s.getListType()===n)c&&xn(s,fs,c),s.append(a),e.remove();else{const f=Et(n,n==="number"?Number(r[2]):void 0);c&&xn(f,fs,c),f.append(a),e.replace(f)}a.append(...t),o||a.select(0,0);const u=(function(f){const d=f.match(/\t/g),g=f.match(/ /g);let h=0;return d&&(h+=d.length),g&&(h+=Math.floor(g.length/4)),h})(r[1]);u&&a.setIndent(u)},ld=(n,e,t,r)=>{const o=[],s=n.getChildren();let i=0;for(const a of s)if(le(a)){if(a.getChildrenSize()===1){const g=a.getFirstChild();if(Z(g)){const h=ld(g,e,t+1,r);h&&o.push(h);continue}}if(r&&!a.getChildren().some(g=>g.isSelected(r)))continue;const l=" ".repeat(4*t),c=n.getListType(),u=Cs(n,fs),f=c==="number"?`${n.getStart()+i}. `:c==="check"?`${u} [${a.getChecked()?"x":" "}] `:u+" ";let d=e(a);c!=="number"&&(d=d.replace(/^(\s{0,3}\d+)(\.\s)/,"$1\\$2")),o.push(l+f+d),i++}return o.join(`
237
237
  `)},OO={dependencies:[qs],export:(n,e)=>{if(!Wr(n))return null;const t=Number(n.getTag().slice(1));return"#".repeat(t)+" "+e(n)},regExp:SO,replace:kb(n=>{const e="h"+n[1].length;return fn(e)}),triggerOnEnter:!0,type:"element"},RO={dependencies:[Js],export:(n,e)=>{if(!Vn(n))return null;const t=e(n).split(`
238
238
  `),r=[];for(const o of t)r.push("> "+o);return r.join(`
239
239
  `)},regExp:vO,replace:(n,e,t,r)=>{if(r){const s=n.getPreviousSibling();if(Vn(s))return s.splice(s.getChildrenSize(),0,[LO(s),...e]),void n.remove()}const o=Ln();o.append(...e),n.replace(o),r||o.select(0,0)},triggerOnEnter:!0,type:"element"},Li={dependencies:[dn],export:n=>{if(!je(n))return null;const e=n.getTextContent();let t=Cs(n,op);if(e.indexOf(t)>-1){const r=e.match(/`{3,}/g);if(r){const o=Math.max(...r.map(s=>s.length));t="`".repeat(o+1)}}return t+(n.getLanguage()||"")+(e?`
240
240
  `+e:"")+`
241
241
  `+t},handleImportAfterStartMatch:({lines:n,rootNode:e,startLineIndex:t,startMatch:r})=>{const o=r[1],s=o.trim().length,i=n[t],a=r.index+o.length,l=i.slice(a),c=new RegExp(`\`{${s},}$`);if(c.test(l)){const g=l.match(c),h=l.slice(0,l.lastIndexOf(g[0])),_=[...r];return _[2]="",Li.replace(e,null,_,g,[h],!0),[!0,t]}const u=new RegExp(`^[ \\t]*\`{${s},}$`);for(let g=t+1;g<n.length;g++){const h=n[g];if(u.test(h)){const _=h.match(u),m=n.slice(t+1,g),b=i.slice(r[0].length);return b.length>0&&m.unshift(b),Li.replace(e,null,r,_,m,!0),[!0,g]}}const f=n.slice(t+1),d=i.slice(r[0].length);return d.length>0&&f.unshift(d),Li.replace(e,null,r,null,f,!0),[!0,n.length-1]},regExpEnd:{optional:!0,regExp:TO},regExpStart:kO,replace:(n,e,t,r,o,s)=>{let i,a;const l=t[1]?t[1].trim():"```",c=t[2]||void 0;if(!e&&o){if(o.length===1)r?(i=Ze(c),a=o[0]):(i=Ze(c),a=o[0].startsWith(" ")?o[0].slice(1):o[0]);else{for(i=Ze(c),o.length>0&&(o[0].trim().length===0?o.shift():o[0].startsWith(" ")&&(o[0]=o[0].slice(1)));o.length>0&&!o[o.length-1].length;)o.pop();a=o.join(`
242
- `)}xn(i,op,l);const u=$e(a);i.append(u),n.append(i)}else e&&kb(u=>Ze(u?u[2]:void 0))(n,e,t,s)},type:"multiline-element"},AO={dependencies:[Yt,bn],export:(n,e,t)=>Z(n)?ld(n,e,0,t):null,regExp:CO,replace:Tb("bullet"),triggerOnEnter:!0,type:"element"},MO={dependencies:[Yt,bn],export:(n,e,t)=>Z(n)?ld(n,e,0,t):null,regExp:xO,replace:Tb("number"),triggerOnEnter:!0,type:"element"},$O={format:["code"],tag:"`",type:"text-format"},DO={format:["highlight"],tag:"==",type:"text-format"},PO={format:["bold","italic"],tag:"***",type:"text-format"},jO={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},FO={format:["bold"],tag:"**",type:"text-format"},BO={format:["bold"],intraword:!1,tag:"__",type:"text-format"},UO={format:["strikethrough"],tag:"~~",type:"text-format"},zO={format:["italic"],tag:"*",type:"text-format"},KO={format:["italic"],intraword:!1,tag:"_",type:"text-format"},WO={dependencies:[gn],export:(n,e,t)=>{if(!Pe(n)||_t(n))return null;const r=e(n);let o=n.getTitle();return o!=null&&(o=o.replace(/([\\"])/g,"\\$1")),o?`[${r}](${n.getURL()} "${o}")`:`[${r}](${n.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(n,e)=>{if(re(n,Pe))return;const[,t,r,o]=e,s=r!=null?rp(r):void 0,i=o!=null?rp(o):void 0,a=Mo(s,{title:i}),l=t.split("[").length-1,c=t.split("]").length-1;let u=t,f="";if(l<c)return;if(l>c){const g=t.split("[");f="["+g[0],u=g.slice(1).join("[")}const d=$e(u);return d.setFormat(n.getFormat()),a.append(d),n.replace(a),f&&a.insertBefore($e(f)),d},trigger:")",type:"text-match"},HO=[OO,RO,AO,MO],JO=[Li],qO=[$O,PO,jO,FO,BO,DO,zO,KO,UO],VO=[WO],YO=[...HO,...JO,...qO,...VO];function sp(n){return oe(n)&&!n.hasFormat("code")}function GO(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ip(n,e,t,r,o){const s=n.getParent();if(!wt(s)||n.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!o&&i[t-1]!==" ")return!1;for(const{regExp:a,replace:l}of r){const c=i.match(a),u=o||c&&c[0].endsWith(" ")?t:t-1;if(c&&c[0].length===u){const f=e.getNextSiblings(),[d,g]=e.splitText(t);if(l(n,g?[g,...f]:f,c,!1)!==!1)return d.remove(),!0}}return!1}function ap(n,e,t,r,o){const s=n.getParent();if(!wt(s)||n.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!o&&i[t-1]!==" ")return!1;for(const{regExpStart:a,replace:l,regExpEnd:c}of r){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const u=i.match(a);if(u){const f=o||u[0].endsWith(" ")?t:t-1;if(u[0].length!==f)continue;const d=e.getNextSiblings(),[g,h]=e.splitText(t);if(l(n,h?[h,...d]:d,u,null,null,!1)!==!1)return g.remove(),!0}}return!1}function XO(n,e){let t=0;const r=n.getTextContent();for(let o=0;o<e;o++)r[o]==="`"&&t++;return t%2!=0}function lp(n,e,t){const r=t.length;for(let o=e;o>=r;o--){const s=o-r;if(Ib(n,s,t,0,r)&&n[s+r]!==" ")return s}return-1}function Ib(n,e,t,r,o){for(let s=0;s<o;s++)if(n[e+s]!==t[r+s])return!1;return!0}function ZO(n,e=YO){const t=wO(e),r=t.element.filter(l=>l.triggerOnEnter),o=Cc(t.textFormat,({tag:l})=>l[l.length-1]),s=Cc(t.textMatch,({trigger:l})=>l),i=new Set([" "]);for(const l of t.textFormat)i.add(l.tag.slice(-1));for(const l of t.textMatch)l.trigger!==void 0&&i.add(l.trigger);for(const l of e){const c=l.type;if(c==="element"||c==="text-match"||c==="multiline-element"){const u=l.dependencies;for(const f of u)n.hasNode(f)||GO(173,f.getType())}}const a=(l,c,u)=>!!ip(l,c,u,t.element)||!!ap(l,c,u,t.multilineElement)||!!(function(f,d,g){let h=f.getTextContent();const _=g[h[d-1]];if(_==null)return!1;d<h.length&&(h=h.slice(0,d));for(const m of _){if(!m.replace||!m.regExp)continue;const b=h.match(m.regExp);if(b===null)continue;const w=b.index||0,C=w+b[0].length;let v;return w===0?[v]=f.splitText(C):[,v]=f.splitText(w,C),v.selectNext(0,0),m.replace(v,b),!0}return!1})(c,u,s)||!!(function(f,d,g){const h=f.getTextContent(),_=d-1,m=h[_],b=g[m];if(!b)return!1;for(const w of b){const{tag:C}=w,v=C.length,k=_-v+1;if(v>1&&!Ib(h,k,C,0,v)||h[k-1]===" ")continue;const I=h[_+1];if(w.intraword===!1&&I&&!np.test(I))continue;const E=f;let N=E,O=lp(h,k,C),M=N;for(;O<0&&(M=M.getPreviousSibling())&&!ue(M);)if(oe(M)){if(M.hasFormat("code"))continue;const K=M.getTextContent();N=M,O=lp(K,K.length,C)}if(O<0||N===E&&O+v===k)continue;const R=N.getTextContent();if(O>0&&R[O-1]===m)continue;const $=R[O-1];if(w.intraword===!1&&$&&!np.test($)||!w.format.includes("code")&&XO(N,O))continue;const L=E.getTextContent(),A=L.slice(0,k)+L.slice(_+1);E.setTextContent(A);const B=N===E?A:R;N.setTextContent(B.slice(0,O)+B.slice(O+v));const j=D(),U=kr();Ee(U);const z=_-v*(N===E?2:1)+1;U.anchor.set(N.__key,O,"text"),U.focus.set(E.__key,z,"text");for(const K of w.format)U.formatText(K,rh[K]);U.anchor.set(U.focus.key,U.focus.offset,U.focus.type);for(const K of w.format)U.hasFormat(K)&&U.toggleFormat(K);return F(j)&&(U.format=j.format),!0}return!1})(c,u,o);return de(n.registerUpdateListener(({tags:l,dirtyLeaves:c,editorState:u,prevEditorState:f})=>{if(l.has(Mw)||l.has($w)||n.isComposing())return;const d=l.has(Dw),g=u.read(D),h=f.read(D);if(!F(h)||!F(g)||!g.isCollapsed()||g.is(h)&&!d)return;const _=g.anchor.key,m=g.anchor.offset,b=u._nodeMap.get(_);if(oe(b)&&c.has(_)&&(d||m===1||!(m>h.anchor.offset+1))){if(d){const w=u.read(()=>b.getTextContent())[m-1];if(!i.has(w))return}n.update(()=>{if(!sp(b))return;const w=b.getParent();w===null||je(w)||a(w,b,g.anchor.offset)&&Ai(Pw)})}}),n.registerCommand(zr,l=>{if(l!==null&&l.shiftKey)return!1;const c=D();if(!F(c)||!c.isCollapsed())return!1;const u=c.anchor.offset,f=c.anchor.getNode();if(!oe(f)||!sp(f))return!1;const d=f.getParent();return d===null||je(d)?!1:u===f.getTextContent().length&&!(!ap(d,f,u,t.multilineElement,!0)&&!ip(d,f,u,r,!0))&&(l!==null&&l.preventDefault(),!0)},ee))}var Bo;(function(n){n[n.increment=1]="increment",n[n.decrement=2]="decrement"})(Bo||(Bo={}));const Eb=(n,e)=>{if(!e)return n;let t=n;switch(e){case Bo.decrement:switch(!0){case n>Ba:t=Ba;break;case n>=48:t-=12;break;case n>=24:t-=4;break;case n>=14:t-=2;break;case n>=9:t-=1;break;default:t=Fa;break}break;case Bo.increment:switch(!0){case n<Fa:t=Fa;break;case n<12:t+=1;break;case n<20:t+=2;break;case n<36:t+=4;break;case n<=60:t+=12;break;default:t=Ba;break}break}return t},Qi=(n,e,t)=>{const r=o=>(o||(o=`${Wl}px`),o=o.slice(0,-2),`${Eb(Number(o),t)}px`);n.update(()=>{if(n.isEditable()){const o=D();o!==null&&kh(o,{"font-size":e||r})}})},cp=(n,e,t)=>{if(t!==""){const r=Eb(Number(t),e);Qi(n,String(r)+"px",null)}else Qi(n,null,e)},Ta=n=>{n.update(()=>{const e=D();Un(e,()=>ne())})},xl=(n,e,t)=>{e!==t&&n.update(()=>{const r=D();Un(r,()=>fn(t))})},QO=(n,e)=>{e!=="bullet"?n.dispatchCommand(Qc,void 0):Ta(n)},eR=(n,e)=>{e!=="check"?n.dispatchCommand(Zc,void 0):Ta(n)},tR=(n,e)=>{e!=="number"?n.dispatchCommand(eu,void 0):Ta(n)},nR=(n,e)=>{e!=="quote"&&n.update(()=>{const t=D();Un(t,()=>Ln())})},rR=(n,e)=>{e!=="code"&&n.update(()=>{let t=D();if(t)if(!F(t)||t.isCollapsed())Un(t,()=>Ze());else{const r=t.getTextContent(),o=Ze();t.insertNodes([o]),t=D(),F(t)&&t.insertRawText(r)}})},oR=n=>{n.update(()=>{const e=D();if(F(e)||ae(e)){const t=e.anchor,r=e.focus,o=e.getNodes(),s=e.extract();if(t.key===r.key&&t.offset===r.offset)return;o.forEach((i,a)=>{if(oe(i)){let l=i;a===0&&t.offset!==0&&(l=l.splitText(t.offset)[1]||l),a===o.length-1&&(l=l.splitText(r.offset)[0]||l);const c=s[0];o.length===1&&oe(c)&&(l=c),l.__style!==""&&l.setStyle(""),l.__format!==0&&l.setFormat(0);const u=Rc(l);u.__format!==0&&u.setFormat(""),u.__indent!==0&&u.setIndent(0)}else Wr(i)||Vn(i)?i.replace(ne(),!0):sc(i)&&i.setFormat("")})}})},xe=Object.freeze({NORMAL:we?"⌘+Opt+0":"Ctrl+Alt+0",HEADING1:we?"⌘+Opt+1":"Ctrl+Alt+1",HEADING2:we?"⌘+Opt+2":"Ctrl+Alt+2",HEADING3:we?"⌘+Opt+3":"Ctrl+Alt+3",NUMBERED_LIST:we?"⌘+Shift+7":"Ctrl+Shift+7",BULLET_LIST:we?"⌘+Shift+8":"Ctrl+Shift+8",CHECK_LIST:we?"⌘+Shift+9":"Ctrl+Shift+9",CODE_BLOCK:we?"⌘+Opt+C":"Ctrl+Alt+C",QUOTE:we?"⌃+Shift+Q":"Ctrl+Shift+Q",ADD_COMMENT:we?"⌘+Opt+M":"Ctrl+Alt+M",INCREASE_FONT_SIZE:we?"⌘+Shift+.":"Ctrl+Shift+.",DECREASE_FONT_SIZE:we?"⌘+Shift+,":"Ctrl+Shift+,",INSERT_CODE_BLOCK:we?"⌘+Shift+C":"Ctrl+Shift+C",STRIKETHROUGH:we?"⌘+Shift+X":"Ctrl+Shift+X",LOWERCASE:we?"⌃+Shift+1":"Ctrl+Shift+1",UPPERCASE:we?"⌃+Shift+2":"Ctrl+Shift+2",CAPITALIZE:we?"⌃+Shift+3":"Ctrl+Shift+3",CENTER_ALIGN:we?"⌘+Shift+E":"Ctrl+Shift+E",JUSTIFY_ALIGN:we?"⌘+Shift+J":"Ctrl+Shift+J",LEFT_ALIGN:we?"⌘+Shift+L":"Ctrl+Shift+L",RIGHT_ALIGN:we?"⌘+Shift+R":"Ctrl+Shift+R",SUBSCRIPT:we?"⌘+,":"Ctrl+,",SUPERSCRIPT:we?"⌘+.":"Ctrl+.",INDENT:we?"⌘+]":"Ctrl+]",OUTDENT:we?"⌘+[":"Ctrl+[",CLEAR_FORMATTING:we?"⌘+\\":"Ctrl+\\",REDO:we?"⌘+Shift+Z":"Ctrl+Y",UNDO:we?"⌘+Z":"Ctrl+Z",BOLD:we?"⌘+B":"Ctrl+B",ITALIC:we?"⌘+I":"Ctrl+I",UNDERLINE:we?"⌘+U":"Ctrl+U",INSERT_LINK:we?"⌘+K":"Ctrl+K"});function up(n){const e=n.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function sR(){const n=D();if(F(n)&&!n.isCollapsed()||ae(n)&&!n.anchor.is(n.focus)||!F(n)&&!ae(n))return!1;const[e]=We(n.anchor);return e.__colSpan>1||e.__rowSpan>1}function iR(n){const e=n.getLastDescendant();oe(e)?e.select():q(e)?e.selectEnd():e!==null&&e.selectNext()}function dp(n){return n.getEditorState().read(()=>{const e=D();if(F(e)||ae(e)){const[t]=We(e.anchor);if(J(t))return t.getBackgroundColor()}return null})}function aR({onClose:n,tableCellNode:e,cellMerge:t,showColorPickerModal:r}){const[o]=fe(),[s,i]=S.useState(e),[a,l]=S.useState({columns:1,rows:1}),[c,u]=S.useState(!1),[f,d]=S.useState(!1),[g,h]=S.useState(()=>dp(o)||"");S.useEffect(()=>o.registerMutationListener(Gt,B=>{B.get(s.getKey())==="updated"&&(o.getEditorState().read(()=>{i(s.getLatest())}),h(dp(o)||""))},{skipInitialization:!0}),[o,s]),S.useEffect(()=>{o.getEditorState().read(()=>{const B=D();if(ae(B)){const j=up(B);l(up(B)),u(j.columns>1||j.rows>1)}d(sR())})},[o]);const _=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s),j=kt(B,o.getElementByKey(B.getKey()));if(j===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const U=$o(j);U!==null&&U.$clearHighlight(),B.markDirty(),i(s.getLatest())}Ee(null)})},[o,s]),m=()=>{o.update(()=>{const B=D();if(!ae(B))return;const U=B.getNodes().filter(J),z=lu(U);z&&(iR(z),n())})},b=()=>{o.update(()=>{v_()})},w=S.useCallback(B=>{o.update(()=>{for(let j=0;j<a.rows;j++)ga(B);n()})},[o,n,a.rows]),C=S.useCallback(B=>{o.update(()=>{for(let j=0;j<a.columns;j++)pa(B);n()})},[o,n,a.columns]),v=S.useCallback(()=>{o.update(()=>{su(),n()})},[o,n]),k=S.useCallback(()=>{o.update(()=>{ot(s).remove(),_(),n()})},[o,s,_,n]),I=S.useCallback(()=>{o.update(()=>{iu(),n()})},[o,n]),E=S.useCallback(()=>{o.update(()=>{const B=ot(s),j=ou(s),[U]=at(B,null,null),z=new Set,K=s.getHeaderStyles()^te.ROW;for(let H=0;H<U[j].length;H++){const ie=U[j][H];ie?.cell&&(z.has(ie.cell)||(z.add(ie.cell),ie.cell.setHeaderStyles(K,te.ROW)))}_(),n()})},[o,s,_,n]),N=S.useCallback(()=>{o.update(()=>{const B=ot(s),j=C_(s),[U]=at(B,null,null),z=new Set,K=s.getHeaderStyles()^te.COLUMN;for(let H=0;H<U.length;H++){const ie=U[H][j];ie?.cell&&(z.has(ie.cell)||(z.add(ie.cell),ie.cell.setHeaderStyles(K,te.COLUMN)))}_(),n()})},[o,s,_,n]),O=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setRowStriping(!B.getRowStriping())}_(),n()})},[o,s,_,n]),M=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setFrozenRows(B.getFrozenRows()===0?1:0)}_(),n()})},[o,s,_,n]),R=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setFrozenColumns(B.getFrozenColumns()===0?1:0)}_(),n()})},[o,s,_,n]),$=S.useCallback(B=>{o.update(()=>{const j=D();if(F(j)||ae(j)){const[U]=We(j.anchor);if(J(U)&&U.setBackgroundColor(B),ae(j)){const z=j.getNodes();for(let K=0;K<z.length;K++){const H=z[K];J(H)&&H.setBackgroundColor(B)}}}})},[o]),L=B=>{o.update(()=>{const j=D();if(F(j)||ae(j)){const[U]=We(j.anchor);if(J(U)&&U.setVerticalAlign(B),ae(j)){const z=j.getNodes();for(let K=0;K<z.length;K++){const H=z[K];J(H)&&H.setVerticalAlign(B)}}}})};let A=null;return t&&(c?A=x.jsx(Te.Item,{onSelect:()=>m(),"data-test-id":"table-merge-cells",children:"Merge cells"}):f&&(A=x.jsx(Te.Item,{onSelect:()=>b(),"data-test-id":"table-unmerge-cells",children:"Unmerge cells"}))),x.jsxs(Te,{children:[A,x.jsx(Te.Item,{onSelect:()=>r("Cell background color",()=>x.jsx(Cx,{color:g,onChange:$})),"data-test-id":"table-background-color",children:"Background color"}),x.jsx(Te.Item,{onSelect:()=>O(),"data-test-id":"table-row-striping",children:"Toggle Row Striping"}),x.jsxs(Te.Group,{title:"Vertical Align",children:[x.jsxs(Te.Item,{onSelect:()=>L("top"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(ux,{})}),"Top Align"]}),x.jsxs(Te.Item,{onSelect:()=>L("middle"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(ji,{})}),"Middle Align"]}),x.jsxs(Te.Item,{onSelect:()=>L("bottom"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(dx,{})}),"Bottom Align"]})]}),x.jsx(Te.Item,{onSelect:()=>M(),"data-test-id":"table-freeze-first-row",children:"Toggle First Row Freeze"}),x.jsx(Te.Item,{onSelect:()=>R(),"data-test-id":"table-freeze-first-column",children:"Toggle First Column Freeze"}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>w(!1),"data-test-id":"table-insert-row-above",children:["Insert"," ",a.rows===1?"row":`${a.rows} rows`," ","above"]}),x.jsxs(Te.Item,{onSelect:()=>w(!0),"data-test-id":"table-insert-row-below",children:["Insert"," ",a.rows===1?"row":`${a.rows} rows`," ","below"]}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>C(!1),"data-test-id":"table-insert-column-before",children:["Insert"," ",a.columns===1?"column":`${a.columns} columns`," ","left"]}),x.jsxs(Te.Item,{onSelect:()=>C(!0),"data-test-id":"table-insert-column-after",children:["Insert"," ",a.columns===1?"column":`${a.columns} columns`," ","right"]}),x.jsx(Te.Divider,{}),x.jsx(Te.Item,{onSelect:()=>I(),"data-test-id":"table-delete-columns",variant:"danger",children:"Delete column"}),x.jsx(Te.Item,{onSelect:()=>v(),"data-test-id":"table-delete-rows",variant:"danger",children:"Delete row"}),x.jsx(Te.Item,{onSelect:()=>k(),"data-test-id":"table-delete",variant:"danger",children:"Delete table"}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>E(),"data-test-id":"table-row-header",children:[(s.__headerState&te.ROW)===te.ROW?"Remove":"Add"," ","row header"]}),x.jsxs(Te.Item,{onSelect:()=>N(),"data-test-id":"table-column-header",children:[(s.__headerState&te.COLUMN)===te.COLUMN?"Remove":"Add"," ","column header"]})]})}function lR({anchorElem:n,cellMerge:e}){const[t]=fe(),r=S.useRef(null),o=S.useRef(null),[s,i]=S.useState(!1),[a,l]=S.useState(null),[c,u]=Go(),f=S.useCallback(h=>{const _=h.closest(".JupyterLexicalTheme__tableScrollableWrapper");if(_){const m=_.getBoundingClientRect(),w=h.getBoundingClientRect().right-5,C=w-28;if(w>m.right||C<m.left)return!0}return!1},[]),d=S.useCallback(()=>{const h=r.current,_=D(),m=or(t._window),b=document.activeElement;function w(){h&&(h.classList.remove("JupyterLexicalTheme__tableCellActionButtonContainer--active"),h.classList.add("JupyterLexicalTheme__tableCellActionButtonContainer--inactive")),l(null)}if(_==null||h==null)return w();const C=t.getRootElement();let v=null,k=null;if(F(_)&&C!==null&&m!==null&&C.contains(m.anchorNode)){const E=Xl(_.anchor.getNode());if(E==null||(k=t.getElementByKey(E.getKey()),k==null||!E.isAttached())||f(k))return w();const N=ot(E),O=kt(N,t.getElementByKey(N.getKey()));if(O===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");v=$o(O),l(E)}else if(ae(_)){const E=Xl(_.anchor.getNode());if(!J(E))throw new Error("TableSelection anchorNode must be a TableCellNode");const N=ot(E),O=kt(N,t.getElementByKey(N.getKey()));if(O===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");if(v=$o(O),k=t.getElementByKey(E.getKey()),k===null||f(k))return w()}else if(!b)return w();if(v===null||k===null)return w();const I=!v||!v.isSelecting;if(h.classList.toggle("JupyterLexicalTheme__tableCellActionButtonContainer--active",I),h.classList.toggle("JupyterLexicalTheme__tableCellActionButtonContainer--inactive",!I),I){const E=k.getBoundingClientRect(),N=n.getBoundingClientRect(),O=E.top-N.top+6,M=E.right-N.left-29;h.style.transform=`translate(${M}px, ${O}px)`}},[t,n,f]);S.useEffect(()=>{let h;const _=()=>{h=void 0,t.getEditorState().read(d)},m=()=>(h===void 0&&(h=setTimeout(_,0)),!1),b=()=>{m()};return document.addEventListener("scroll",b,!0),window.addEventListener("scroll",b,!0),de(t.registerUpdateListener(m),t.registerCommand(Ht,m,bo),t.registerRootListener((C,v)=>{v&&v.removeEventListener("pointerup",m),C&&(C.addEventListener("pointerup",m),m())}),()=>{clearTimeout(h),document.removeEventListener("scroll",b,!0),window.removeEventListener("scroll",b,!0)})});const g=S.useRef(a);return S.useEffect(()=>{g.current!==a&&i(!1),g.current=a},[g,a]),x.jsx("div",{className:"JupyterLexicalTheme__tableCellActionButtonContainer",ref:r,children:a!=null&&x.jsxs(x.Fragment,{children:[c,x.jsxs(yo,{open:s,onOpenChange:i,children:[x.jsx(yo.Anchor,{children:x.jsx(Ft,{icon:zc,"aria-label":"Table cell menu",variant:"invisible",size:"small",ref:o,sx:{p:0,width:20,height:20}})}),x.jsx(yo.Overlay,{align:"end",side:"outside-bottom",children:x.jsx(aR,{onClose:()=>i(!1),tableCellNode:a,cellMerge:e,showColorPickerModal:u})})]})]})})}function c$({anchorElem:n=document.body,cellMerge:e=!1}){const t=Hr();return St.createPortal(t?x.jsx(lR,{anchorElem:n,cellMerge:e}):null,n)}function ea(n,e){const t=n()?.[e];if(typeof t!="string")throw new Error(`getThemeClass: required theme property ${e} not defined`);return t.split(/\s+/g).map(r=>`.${r}`).join()}function Ia(){return typeof window<"u"}function Zo(n){return Nb(n)?(n.nodeName||"").toLowerCase():"#document"}function Ct(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function An(n){var e;return(e=(Nb(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Nb(n){return Ia()?n instanceof Node||n instanceof Ct(n).Node:!1}function yt(n){return Ia()?n instanceof Element||n instanceof Ct(n).Element:!1}function ar(n){return Ia()?n instanceof HTMLElement||n instanceof Ct(n).HTMLElement:!1}function fp(n){return!Ia()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ct(n).ShadowRoot}function Ea(n){const{overflow:e,overflowX:t,overflowY:r,display:o}=_n(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&o!=="inline"&&o!=="contents"}function cR(n){return/^(table|td|th)$/.test(Zo(n))}function Na(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const uR=/transform|translate|scale|rotate|perspective|filter/,dR=/paint|layout|strict|content/,ur=n=>!!n&&n!=="none";let Cl;function cd(n){const e=yt(n)?_n(n):n;return ur(e.transform)||ur(e.translate)||ur(e.scale)||ur(e.rotate)||ur(e.perspective)||!ud()&&(ur(e.backdropFilter)||ur(e.filter))||uR.test(e.willChange||"")||dR.test(e.contain||"")}function fR(n){let e=Br(n);for(;ar(e)&&!Ds(e);){if(cd(e))return e;if(Na(e))return null;e=Br(e)}return null}function ud(){return Cl==null&&(Cl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cl}function Ds(n){return/^(html|body|#document)$/.test(Zo(n))}function _n(n){return Ct(n).getComputedStyle(n)}function La(n){return yt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Br(n){if(Zo(n)==="html")return n;const e=n.assignedSlot||n.parentNode||fp(n)&&n.host||An(n);return fp(e)?e.host:e}function Lb(n){const e=Br(n);return Ds(e)?(n.ownerDocument||n).body:ar(e)&&Ea(e)?e:Lb(e)}function Ps(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const o=Lb(n),s=o===((r=n.ownerDocument)==null?void 0:r.body),i=Ct(o);if(s){const a=Sc(i);return e.concat(i,i.visualViewport||[],Ea(o)?o:[],a&&t?Ps(a):[])}else return e.concat(o,Ps(o,[],t))}function Sc(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const gR=["top","right","bottom","left"],Qn=Math.min,Cn=Math.max,ta=Math.round,_i=Math.floor,Sn=n=>({x:n,y:n}),pR={left:"right",right:"left",bottom:"top",top:"bottom"};function Ob(n,e,t){return Cn(n,Qn(e,t))}function En(n,e){return typeof n=="function"?n(e):n}function er(n){return n.split("-")[0]}function Qo(n){return n.split("-")[1]}function dd(n){return n==="x"?"y":"x"}function fd(n){return n==="y"?"height":"width"}function an(n){const e=n[0];return e==="t"||e==="b"?"y":"x"}function gd(n){return dd(an(n))}function hR(n,e,t){t===void 0&&(t=!1);const r=Qo(n),o=gd(n),s=fd(o);let i=o==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=na(i)),[i,na(i)]}function _R(n){const e=na(n);return[vc(n),e,vc(e)]}function vc(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const gp=["left","right"],pp=["right","left"],mR=["top","bottom"],bR=["bottom","top"];function yR(n,e,t){switch(n){case"top":case"bottom":return t?e?pp:gp:e?gp:pp;case"left":case"right":return e?mR:bR;default:return[]}}function wR(n,e,t,r){const o=Qo(n);let s=yR(er(n),t==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(vc)))),s}function na(n){const e=er(n);return pR[e]+n.slice(e.length)}function xR(n){var e,t,r,o;return{top:(e=n.top)!=null?e:0,right:(t=n.right)!=null?t:0,bottom:(r=n.bottom)!=null?r:0,left:(o=n.left)!=null?o:0}}function Rb(n){return typeof n!="number"?xR(n):{top:n,right:n,bottom:n,left:n}}function ra(n){const{x:e,y:t,width:r,height:o}=n;return{width:r,height:o,top:t,left:e,right:e+r,bottom:t+o,x:e,y:t}}var CR=typeof document<"u",SR=function(){},kc=CR?S.useLayoutEffect:SR;const vR={...Th},kR=vR.useInsertionEffect,TR=kR||(n=>n());function IR(n){const e=S.useRef(()=>{});return TR(()=>{e.current=n}),S.useCallback(function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function hp(n,e,t){let{reference:r,floating:o}=n;const s=an(e),i=gd(e),a=fd(i),l=er(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-o.width,y:f};break;default:g={x:r.x,y:r.y}}const h=Qo(e);return h&&(g[i]+=d*(h==="end"?1:-1)*(t&&c?-1:1)),g}async function ER(n,e){var t;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=En(e,n),h=Rb(g),m=a[d?f==="floating"?"reference":"floating":f],b=ra(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(m)))==null||t?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),v=await(s.isElement==null?void 0:s.isElement(C))&&await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1},k=ra(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(b.top-k.top+h.top)/v.y,bottom:(k.bottom-b.bottom+h.bottom)/v.y,left:(b.left-k.left+h.left)/v.x,right:(k.right-b.right+h.right)/v.x}}const NR=50,LR=async(n,e,t)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=t,a=i.detectOverflow?i:{...i,detectOverflow:ER},l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:n,floating:e,strategy:o}),{x:u,y:f}=hp(c,r,l),d=r,g=0;const h={};for(let _=0;_<s.length;_++){const m=s[_];if(!m)continue;const{name:b,fn:w}=m,{x:C,y:v,data:k,reset:I}=await w({x:u,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:h,rects:c,platform:a,elements:{reference:n,floating:e}});u=C??u,f=v??f,h[b]={...h[b],...k},I&&g<NR&&(g++,typeof I=="object"&&(I.placement&&(d=I.placement),I.rects&&(c=I.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:o}):I.rects),{x:u,y:f}=hp(c,d,l)),_=-1)}return{x:u,y:f,placement:d,strategy:o,middlewareData:h}},OR=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=En(n,e)||{};if(c==null)return{};const f=Rb(u),d={x:t,y:r},g=gd(o),h=fd(g),_=await i.getDimensions(c),m=g==="y",b=m?"top":"left",w=m?"bottom":"right",C=m?"clientHeight":"clientWidth",v=s.reference[h]+s.reference[g]-d[g]-s.floating[h],k=d[g]-s.reference[g],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=I?I[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(I)))&&(E=a.floating[C]||s.floating[h]);const N=v/2-k/2,O=E/2-_[h]/2-1,M=Qn(f[b],O),R=Qn(f[w],O),$=E-_[h]-R,L=E/2-_[h]/2+N,A=Ob(M,L,$),B=!l.arrow&&Qo(o)!=null&&L!==A&&s.reference[h]/2-(L<M?M:R)-_[h]/2<0,j=B?L<M?L-M:L-$:0;return{[g]:d[g]+j,data:{[g]:A,centerOffset:L-A-j,...B&&{alignmentOffset:j}},reset:B}}}),RR=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:_=!0,...m}=En(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const b=er(o),w=an(a),C=er(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=d||(C||!_?[na(a)]:_R(a)),I=h!=="none";!d&&I&&k.push(...wR(a,_,h,v));const E=[a,...k],N=await l.detectOverflow(e,m),O=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&O.push(N[b]),f){const A=hR(o,i,v);O.push(N[A[0]],N[A[1]])}if(M=[...M,{placement:o,overflows:O}],!O.every(A=>A<=0)){var R,$;const A=(((R=s.flip)==null?void 0:R.index)||0)+1,B=E[A];if(B&&(!(f==="alignment"?w!==an(B):!1)||M.every(z=>an(z.placement)===w?z.overflows[0]>0:!0)))return{data:{index:A,overflows:M},reset:{placement:B}};let j=($=M.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!j)switch(g){case"bestFit":{var L;const U=(L=M.filter(z=>{if(I){const K=an(z.placement);return K===w||K==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(K=>K>0).reduce((K,H)=>K+H,0)]).sort((z,K)=>z[1]-K[1])[0])==null?void 0:L[0];U&&(j=U);break}case"initialPlacement":j=a;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function _p(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function mp(n){return gR.some(e=>n[e]>=0)}const AR=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t,platform:r}=e,{strategy:o="referenceHidden",...s}=En(n,e);switch(o){case"referenceHidden":{const i=await r.detectOverflow(e,{...s,elementContext:"reference"}),a=_p(i,t.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:mp(a)}}}case"escaped":{const i=await r.detectOverflow(e,{...s,altBoundary:!0}),a=_p(i,t.floating);return{data:{escapedOffsets:a,escaped:mp(a)}}}default:return{}}}}},Ab=new Set(["left","top"]);async function MR(n,e){const{placement:t,platform:r,elements:o}=n,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=er(t),a=Qo(t),l=an(t)==="y",c=Ab.has(i)?-1:1,u=s&&l?-1:1,f=En(e,n);let{mainAxis:d,crossAxis:g,alignmentAxis:h}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof h=="number"&&(g=a==="end"?h*-1:h),l?{x:g*u,y:d*c}:{x:d*c,y:g*u}}const $R=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await MR(e,n);return i===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},DR=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:C,y:v}=w;return{x:C,y:v}}},...c}=En(n,e),u={x:t,y:r},f=await s.detectOverflow(e,c),d=an(o),g=dd(d);let h=u[g],_=u[d];const m=(w,C)=>Ob(C+f[w==="y"?"top":"left"],C,C-f[w==="y"?"bottom":"right"]);i&&(h=m(g,h)),a&&(_=m(d,_));const b=l.fn({...e,[g]:h,[d]:_});return{...b,data:{x:b.x-t,y:b.y-r,enabled:{[g]:i,[d]:a}}}}}},PR=function(n){return n===void 0&&(n={}),{options:n,fn(e){var t,r;const{x:o,y:s,placement:i,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:u=!0,crossAxis:f=!0}=En(n,e),d={x:o,y:s},g=an(i),h=dd(g);let _=d[h],m=d[g];const b=En(c,e),w=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(r=b.crossAxis)!=null?r:0};if(u){const k=h==="y"?"height":"width",I=a.reference[h]-a.floating[k]+w.mainAxis,E=a.reference[h]+a.reference[k]-w.mainAxis;_<I?_=I:_>E&&(_=E)}if(f){var C,v;const k=h==="y"?"width":"height",I=Ab.has(er(i)),E=a.reference[g]-a.floating[k]+(I&&((C=l.offset)==null?void 0:C[g])||0)+(I?0:w.crossAxis),N=a.reference[g]+a.reference[k]+(I?0:((v=l.offset)==null?void 0:v[g])||0)-(I?w.crossAxis:0);m<E?m=E:m>N&&(m=N)}return{[h]:_,[g]:m}}}},jR=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:o,elements:s}=e,{apply:i=()=>{},...a}=En(n,e),l=await o.detectOverflow(e,a),c=er(t),u=Qo(t),f=an(t)==="y",{width:d,height:g}=r.floating;let h,_;c==="top"||c==="bottom"?(h=c,_=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(_=c,h=u==="end"?"top":"bottom");const m=g-l.top-l.bottom,b=d-l.left-l.right,w=Qn(g-l[h],m),C=Qn(d-l[_],b),v=e.middlewareData.shift,k=!v;let I=w,E=C;v!=null&&v.enabled.x&&(E=b),v!=null&&v.enabled.y&&(I=m),k&&!u&&(f?E=d-2*Cn(l.left,l.right):I=g-2*Cn(l.top,l.bottom)),await i({...e,availableWidth:E,availableHeight:I});const N=await o.getDimensions(s.floating);return d!==N.width||g!==N.height?{reset:{rects:!0}}:{}}}};function Mb(n){const e=_n(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=ar(n),s=o?n.offsetWidth:t,i=o?n.offsetHeight:r,a=ta(t)!==s||ta(r)!==i;return a&&(t=s,r=i),{width:t,height:r,$:a}}function pd(n){return yt(n)?n:n.contextElement}function Io(n){const e=pd(n);if(!ar(e))return Sn(1);const t=e.getBoundingClientRect(),{width:r,height:o,$:s}=Mb(e);let i=(s?ta(t.width):t.width)/r,a=(s?ta(t.height):t.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const FR=Sn(0);function $b(n){const e=Ct(n);return!ud()||!e.visualViewport?FR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function BR(n,e,t){return e===void 0&&(e=!1),!!t&&e&&t===Ct(n)}function Ur(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const o=n.getBoundingClientRect(),s=pd(n);let i=Sn(1);e&&(r?yt(r)&&(i=Io(r)):i=Io(n));const a=BR(s,t,r)?$b(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s&&r){const d=Ct(s),g=yt(r)?Ct(r):r;let h=d,_=Sc(h);for(;_&&g!==h;){const m=Io(_),b=_.getBoundingClientRect(),w=_n(_),C=b.left+(_.clientLeft+parseFloat(w.paddingLeft))*m.x,v=b.top+(_.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,f*=m.y,l+=C,c+=v,h=Ct(_),_=Sc(h)}}return ra({width:u,height:f,x:l,y:c})}function Oa(n,e){const t=La(n).scrollLeft;return e?e.left+t:Ur(An(n)).left+t}function Db(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Oa(n,t),o=t.top+e.scrollTop;return{x:r,y:o}}function UR(n){let{elements:e,rect:t,offsetParent:r,strategy:o}=n;const s=o==="fixed",i=An(r),a=e?Na(e.floating):!1;if(r===i||a&&s)return t;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const u=Sn(0),f=ar(r);if((f||!s)&&((Zo(r)!=="body"||Ea(i))&&(l=La(r)),f)){const g=Ur(r);c=Io(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const d=i&&!f&&!s?Db(i,l):Sn(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:t.y*c.y-l.scrollTop*c.y+u.y+d.y}}function zR(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function KR(n){const e=La(n),t=n.ownerDocument.body,r=Cn(n.scrollWidth,n.clientWidth,t.scrollWidth,t.clientWidth),o=Cn(n.scrollHeight,n.clientHeight,t.scrollHeight,t.clientHeight);let s=-e.scrollLeft+Oa(n);const i=-e.scrollTop;return _n(t).direction==="rtl"&&(s+=Cn(n.clientWidth,t.clientWidth)-r),{width:r,height:o,x:s,y:i}}const WR=25;function HR(n,e,t){t===void 0&&(t="viewport");const r=t==="layoutViewport",o=Ct(n),s=An(n),i=o.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(i){const d=!ud()||e==="fixed";r?d||(c=-i.offsetLeft,u=-i.offsetTop):(a=i.width,l=i.height,d&&(c=i.offsetLeft,u=i.offsetTop))}if(Oa(s)<=0){const d=s.ownerDocument,g=d.body,h=getComputedStyle(g),_=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(s.clientWidth-g.clientWidth-_),b=getComputedStyle(s).scrollbarGutter==="stable both-edges"?m/2:m;b<=WR&&(a-=b)}return{width:a,height:l,x:c,y:u}}function JR(n,e){const t=Ur(n,!0,e==="fixed"),r=t.top+n.clientTop,o=t.left+n.clientLeft,s=Io(n),i=n.clientWidth*s.x,a=n.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function bp(n,e,t){let r;if(e==="viewport"||e==="layoutViewport")r=HR(n,t,e);else if(e==="document")r=KR(An(n));else if(yt(e))r=JR(e,t);else{const o=$b(n);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ra(r)}function qR(n,e){const t=e.get(n);if(t)return t;let r=Ps(n,[],!1).filter(a=>yt(a)&&Zo(a)!=="body"),o=null;const s=_n(n).position==="fixed";let i=s?Br(n):n;for(;yt(i)&&!Ds(i);){const a=_n(i),l=cd(i),c=o?o.position:s?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(f=>f!==i):o=a,i=Br(i)}return e.set(n,r),r}function VR(n){let{element:e,boundary:t,rootBoundary:r,strategy:o}=n;const i=[...t==="clippingAncestors"?Na(e)?[]:qR(e,this._c):[].concat(t),r],a=bp(e,i[0],o);let l=a.top,c=a.right,u=a.bottom,f=a.left;for(let d=1;d<i.length;d++){const g=bp(e,i[d],o);l=Cn(g.top,l),c=Qn(g.right,c),u=Qn(g.bottom,u),f=Cn(g.left,f)}return{width:c-f,height:u-l,x:f,y:l}}function YR(n){const{width:e,height:t}=Mb(n);return{width:e,height:t}}function GR(n,e,t){const r=ar(e),o=An(e),s=t==="fixed",i=Ur(n,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);if((r||!s)&&((Zo(e)!=="body"||Ea(o))&&(a=La(e)),r)){const d=Ur(e,!0,s,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}!r&&o&&(l.x=Oa(o));const c=o&&!r&&!s?Db(o,a):Sn(0),u=i.left+a.scrollLeft-l.x-c.x,f=i.top+a.scrollTop-l.y-c.y;return{x:u,y:f,width:i.width,height:i.height}}function Sl(n){return _n(n).position==="static"}function yp(n,e){if(!ar(n)||_n(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return An(n)===t&&(t=t.ownerDocument.body),t}function Pb(n,e){const t=Ct(n);if(Na(n))return t;if(!ar(n)){let o=Br(n);for(;o&&!Ds(o);){if(yt(o)&&!Sl(o))return o;o=Br(o)}return t}let r=yp(n,e);for(;r&&cR(r)&&Sl(r);)r=yp(r,e);return r&&Ds(r)&&Sl(r)&&!cd(r)?t:r||fR(n)||t}const XR=async function(n){const e=this.getOffsetParent||Pb,t=this.getDimensions,r=await t(n.floating);return{reference:GR(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ZR(n){return _n(n).direction==="rtl"}const QR={convertOffsetParentRelativeRectToViewportRelativeRect:UR,getDocumentElement:An,getClippingRect:VR,getOffsetParent:Pb,getElementRects:XR,getClientRects:zR,getDimensions:YR,getScale:Io,isElement:yt,isRTL:ZR};function jb(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function eA(n,e,t){let r=null,o;const s=An(n);function i(){var u;clearTimeout(o),(u=r)==null||u.disconnect(),r=null}function a(u,f){u===void 0&&(u=!1),f===void 0&&(f=1),i();const d=n.getBoundingClientRect(),{left:g,top:h,width:_,height:m}=d;if(u||e(),!_||!m)return;const b=_i(h),w=_i(s.clientWidth-(g+_)),C=_i(s.clientHeight-(h+m)),v=_i(g),I={rootMargin:-b+"px "+-w+"px "+-C+"px "+-v+"px",threshold:Cn(0,Qn(1,f))||1};let E=!0;function N(O){const M=O[0].intersectionRatio;if(!jb(d,n.getBoundingClientRect()))return a();if(M!==f){if(!E)return a();M?a(!1,M):o=setTimeout(()=>{a(!1,1e-7)},1e3)}E=!1}try{r=new IntersectionObserver(N,{...I,root:s.ownerDocument})}catch{r=new IntersectionObserver(N,I)}r.observe(n)}const l=Ct(n),c=()=>a(t);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),i()}}function wp(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=pd(n),u=o||s?[...c?Ps(c):[],...e?Ps(e):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",t),s&&b.addEventListener("resize",t)});const f=c&&a?eA(c,t,s):null;let d=-1,g=null;i&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===c&&g&&e&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var C;(C=g)==null||C.observe(e)})),t()}),c&&!l&&g.observe(c),e&&g.observe(e));let h,_=l?Ur(n):null;l&&m();function m(){const b=Ur(n);_&&!jb(_,b)&&t(),_=b,h=requestAnimationFrame(m)}return t(),()=>{var b;u.forEach(w=>{o&&w.removeEventListener("scroll",t),s&&w.removeEventListener("resize",t)}),f?.(),(b=g)==null||b.disconnect(),g=null,l&&cancelAnimationFrame(h)}}const tA=$R,nA=DR,rA=RR,oA=jR,sA=AR,xp=OR,iA=PR,aA=(n,e,t)=>{const r=new Map,o=t??{},s={...QR,...o.platform,_c:r};return LR(n,e,{...o,platform:s})};var lA=typeof document<"u",cA=function(){},Oi=lA?S.useLayoutEffect:cA;function oa(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,o;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!oa(n[r],e[r]))return!1;return!0}if(o=Object.keys(n),t=o.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=t;r--!==0;){const s=o[r];if(!(s==="_owner"&&n.$$typeof)&&!oa(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function Fb(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Cp(n,e){const t=Fb(n);return Math.round(e*t)/t}function vl(n){const e=S.useRef(n);return Oi(()=>{e.current=n}),e}function uA(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=S.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,g]=S.useState(r);oa(d,r)||g(r);const[h,_]=S.useState(null),[m,b]=S.useState(null),w=S.useCallback(z=>{z!==I.current&&(I.current=z,_(z))},[]),C=S.useCallback(z=>{z!==E.current&&(E.current=z,b(z))},[]),v=s||h,k=i||m,I=S.useRef(null),E=S.useRef(null),N=S.useRef(u),O=l!=null,M=vl(l),R=vl(o),$=vl(c),L=S.useCallback(()=>{if(!I.current||!E.current)return;const z={placement:e,strategy:t,middleware:d};R.current&&(z.platform=R.current),aA(I.current,E.current,z).then(K=>{const H={...K,isPositioned:$.current!==!1};A.current&&!oa(N.current,H)&&(N.current=H,St.flushSync(()=>{f(H)}))})},[d,e,t,R,$]);Oi(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[c]);const A=S.useRef(!1);Oi(()=>(A.current=!0,()=>{A.current=!1}),[]),Oi(()=>{if(v&&(I.current=v),k&&(E.current=k),v&&k){if(M.current)return M.current(v,k,L);L()}},[v,k,L,M,O]);const B=S.useMemo(()=>({reference:I,floating:E,setReference:w,setFloating:C}),[w,C]),j=S.useMemo(()=>({reference:v,floating:k}),[v,k]),U=S.useMemo(()=>{const z={position:t,left:0,top:0};if(!j.floating)return z;const K=Cp(j.floating,u.x),H=Cp(j.floating,u.y);return a?{...z,transform:"translate("+K+"px, "+H+"px)",...Fb(j.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:K,top:H}},[t,a,j.floating,u.x,u.y]);return S.useMemo(()=>({...u,update:L,refs:B,elements:j,floatingStyles:U}),[u,L,B,j,U])}const dA=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:o}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?xp({element:r.current,padding:o}).fn(t):{}:r?xp({element:r,padding:o}).fn(t):{}}}},Sp=(n,e)=>{const t=tA(n);return{name:t.name,fn:t.fn,options:[n,e]}},vp=(n,e)=>{const t=nA(n);return{name:t.name,fn:t.fn,options:[n,e]}},u$=(n,e)=>({fn:iA(n).fn,options:[n,e]}),d$=(n,e)=>{const t=rA(n);return{name:t.name,fn:t.fn,options:[n,e]}},f$=(n,e)=>{const t=oA(n);return{name:t.name,fn:t.fn,options:[n,e]}},g$=(n,e)=>{const t=sA(n);return{name:t.name,fn:t.fn,options:[n,e]}},p$=(n,e)=>{const t=dA(n);return{name:t.name,fn:t.fn,options:[n,e]}},fA={...Th};let kp=!1,gA=0;const Tp=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+gA++;function pA(){const[n,e]=S.useState(()=>kp?Tp():void 0);return kc(()=>{n==null&&e(Tp())},[]),S.useEffect(()=>{kp=!0},[]),n}const hA=fA.useId,_A=hA||pA;function mA(){const n=new Map;return{emit(e,t){var r;(r=n.get(e))==null||r.forEach(o=>o(t))},on(e,t){n.has(e)||n.set(e,new Set),n.get(e).add(t)},off(e,t){var r;(r=n.get(e))==null||r.delete(t)}}}const bA=S.createContext(null),yA=S.createContext(null),wA=()=>{var n;return((n=S.useContext(bA))==null?void 0:n.id)||null},xA=()=>S.useContext(yA);function CA(n){const{open:e=!1,onOpenChange:t,elements:r}=n,o=_A(),s=S.useRef({}),[i]=S.useState(()=>mA()),a=wA()!=null,[l,c]=S.useState(r.reference),u=IR((g,h,_)=>{s.current.openEvent=g?h:void 0,i.emit("openchange",{open:g,event:h,reason:_,nested:a}),t?.(g,h,_)}),f=S.useMemo(()=>({setPositionReference:c}),[]),d=S.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return S.useMemo(()=>({dataRef:s,open:e,onOpenChange:u,elements:d,events:i,floatingId:o,refs:f}),[e,u,d,i,o,f])}function Ip(n){var e,t;let{elements:r,...o}=n===void 0?{}:n;const{nodeId:s}=o,i=CA({...o,elements:{reference:(e=r?.reference)!=null?e:null,floating:(t=r?.floating)!=null?t:null}}),a=o.rootContext||i,l=a.elements,[c,u]=S.useState(null),[f,d]=S.useState(null),h=l?.domReference||c,_=S.useRef(null),m=xA();kc(()=>{h&&(_.current=h)},[h]);const b=uA({...o,elements:{...l,...f&&{reference:f}}}),w=S.useCallback(E=>{const N=yt(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),getClientRects:()=>E.getClientRects(),contextElement:E}:E;d(N),b.refs.setReference(N)},[b.refs]),C=S.useCallback(E=>{(yt(E)||E===null)&&(_.current=E,u(E)),(yt(b.refs.reference.current)||b.refs.reference.current===null||E!==null&&!yt(E))&&b.refs.setReference(E)},[b.refs]),v=S.useMemo(()=>({...b.refs,setReference:C,setPositionReference:w,domReference:_}),[b.refs,C,w]),k=S.useMemo(()=>({...b.elements,domReference:h}),[b.elements,h]),I=S.useMemo(()=>({...b,...a,refs:v,elements:k,nodeId:s}),[b,v,k,s,a]);return kc(()=>{a.dataRef.current.floatingContext=I;const E=m?.nodesRef.current.find(N=>N.id===s);E&&(E.context=I)}),S.useMemo(()=>({...b,context:I,refs:v,elements:k}),[b,v,k,I])}function SA(n){const e=n.getChildren();let t=null;for(const r of e){if(!ce(r)||(t===null&&(t=r.getChildrenSize()),r.getChildrenSize()!==t))return!1;const o=r.getChildren();for(const s of o)if(!J(s)||s.getRowSpan()!==1||s.getColSpan()!==1)return!1}return(t||0)>0}function vA(n,e){if(!ke(n.target))return{isOutside:!0,tableElement:null};const t=`td${ea(e,"tableCell")}, th${ea(e,"tableCell")}`,o=n.target.closest(t)?.closest("table")??null;return{isOutside:o==null,tableElement:o}}function kA(n,e){const t=n.rows[0];if(!t)return null;let r=null,o=Number.POSITIVE_INFINITY;for(const s of Array.from(t.cells)){const i=s.getBoundingClientRect(),a=i.left+i.width/2,l=Math.abs(a-e);l<o&&(o=l,r={cell:s,centerX:a,top:i.top})}return r}function TA({anchorElem:n}){const[e,{getTheme:t}]=fe(),r=Hr(),[o,s]=S.useState(!1),[i,a]=S.useState(!1),l=S.useRef({getBoundingClientRect:()=>new DOMRect}),c=S.useRef({getBoundingClientRect:()=>new DOMRect}),u=S.useRef(null),f=S.useRef(null),d=S.useRef(null),g=S.useRef(null),h=S.useRef(null),{refs:_,floatingStyles:m,update:b}=Ip({middleware:[Sp({mainAxis:-9}),vp({padding:8})],placement:"top",strategy:"fixed",whileElementsMounted:wp}),{refs:w,floatingStyles:C,update:v}=Ip({middleware:[Sp({mainAxis:-9}),vp({padding:8})],placement:"left",strategy:"fixed",whileElementsMounted:wp});if(S.useEffect(()=>{if(!r)return;const N=O=>{if(u.current&&O.target instanceof Node&&u.current.contains(O.target)||f.current&&O.target instanceof Node&&f.current.contains(O.target))return;const{tableElement:M,isOutside:R}=vA(O,t);if(R||M==null||n&&!n.contains(M)){s(!1),a(!1);return}const $=`td${ea(t,"tableCell")}, th${ea(t,"tableCell")}`,L=ke(O.target)?O.target.closest($):null;if(!L){s(!1),a(!1),g.current=null,d.current=null;return}const A=L.parentElement instanceof HTMLTableRowElement?L.parentElement.rowIndex:-1,B=L.cellIndex??-1,j=kA(M,O.clientX);!j||A!==0?(s(!1),g.current=null):(g.current=j.cell,l.current.getBoundingClientRect=()=>new DOMRect(j.centerX,j.top,0,0),_.setReference(l.current),s(!0),b?.());const U=M.getBoundingClientRect();if(B!==0)a(!1),d.current=null;else{const{top:z,height:K}=L.getBoundingClientRect(),H=z+K/2;d.current=L,c.current.getBoundingClientRect=()=>new DOMRect(U.left,H,0,0),w.setReference(c.current),a(!0),v?.()}};return document.addEventListener("mousemove",N),()=>{document.removeEventListener("mousemove",N),s(!1),a(!1)}},[n,t,r,w,_,b,v]),S.useEffect(()=>{const N=O=>{const M=O.relatedTarget;M&&u.current&&u.current.contains(M)||M&&f.current&&f.current.contains(M)||(s(!1),a(!1))};return h.current=N,e.registerRootListener((O,M)=>{M&&h.current&&M.removeEventListener("mouseleave",h.current),O&&h.current&&O.addEventListener("mouseleave",h.current)})},[e]),!r)return null;const k=()=>{const N=g.current;N&&e.update(()=>{const O=Ae(N);J(O)&&(O.selectEnd(),pa())})},I=()=>{const N=d.current;N&&e.update(()=>{const O=Ae(N);J(O)&&(O.selectEnd(),ga())})},E=N=>{const O=g.current;O&&e.update(()=>{const M=Ae(O);if(!J(M))return;const R=M.getParent();if(!R||!ce(R))return;const $=R.getParent();if(!be($)||!SA($))return;const L=M.getIndexWithinParent(),A=$.getChildren().filter(ce),[B]=at($,M,M),U=B[0]?.[L]?.cell?.hasHeader()??!1,z=U?A.slice(1):A;if(z.length<=1)return;z.sort((H,ie)=>{const Ne=A.indexOf(H),Ce=A.indexOf(ie),ut=B[Ne]??[],Mn=B[Ce]??[],nn=ut[L],qb=Mn[L],Vb=nn?.cell.getTextContent()??"",Yb=qb?.cell.getTextContent()??"",md=Vb.localeCompare(Yb,void 0,{numeric:!0});return N==="asc"?-md:md}),(U?gt(A[0],"next"):Er($,"next"))?.splice(0,z)})};return x.jsxs(x.Fragment,{children:[x.jsxs(Y,{ref:N=>{u.current=N,_.setFloating(N)},style:{...m,opacity:o?1:0,display:o?"flex":"none"},sx:{alignItems:"center",gap:1,zIndex:10},children:[x.jsxs(yo,{children:[x.jsx(yo.Button,{"aria-label":"Sort column",variant:"invisible",size:"small",children:x.jsx(fx,{size:16})}),x.jsx(yo.Overlay,{children:x.jsxs(Te,{children:[x.jsx(Te.Item,{onSelect:()=>E("desc"),children:"Sort Ascending"}),x.jsx(Te.Item,{onSelect:()=>E("asc"),children:"Sort Descending"})]})})]}),x.jsx(Ft,{icon:Di,"aria-label":"Add column",variant:"invisible",size:"small",onClick:k})]}),x.jsx(Ft,{ref:N=>{f.current=N,w.setFloating(N)},style:{...C,opacity:i?1:0,display:i?"inline-flex":"none"},icon:Di,"aria-label":"Add row",variant:"invisible",size:"small",onClick:I})]})}function h$({anchorElem:n=document.body}){return Hr()?St.createPortal(x.jsx(TA,{anchorElem:n}),n):null}const IA=33,Ep=92;function EA({editor:n}){const e=S.useRef(null),t=S.useRef(null),[r,o]=S.useState(null),[s,i]=S.useState(!1),a=S.useRef(null),[l,c]=S.useState(null),[u,f]=S.useState(null),[d,g]=S.useState(null),h=(N,O)=>O.getElementByKey(N.getKey())?.clientHeight,_=S.useCallback(()=>{f(null),e.current=null,g(null),a.current=null,o(null)},[]);S.useEffect(()=>{const N=new Set;return de(n.registerMutationListener(Xt,O=>{for(const[R,$]of O)$==="destroyed"?N.delete(R):N.add(R);const M=N.size>0;i(M)}),n.registerNodeTransform(Xt,O=>{if(O.getColWidths())return O;const M=O.getColumnCount(),R=Ep;return O.setColWidths(Array(M).fill(R)),O}))},[n]),S.useEffect(()=>{if(!s)return;const N=$=>{const L=$.target;if(ke(L)){if(d){$.preventDefault(),$.stopPropagation(),c({x:$.clientX,y:$.clientY});return}if(!(t.current&&t.current.contains(L))&&e.current!==L){e.current=L;const A=Do(L);A&&u!==A?n.getEditorState().read(()=>{const B=Ae(A.elem);if(!B)throw new Error("TableCellResizer: Table cell node not found.");const j=ot(B),U=kt(j,n.getElementByKey(j.getKey()));if(!U)throw new Error("TableCellResizer: Table element not found.");e.current=L,o(U.getBoundingClientRect()),f(A)},{editor:n}):A==null&&_()}}},O=$=>{$.pointerType==="touch"&&N($)},M=t.current;M?.addEventListener("pointermove",N,{capture:!0});const R=n.registerRootListener(($,L)=>{L?.removeEventListener("pointermove",N),L?.removeEventListener("pointerdown",O),$?.addEventListener("pointermove",N),$?.addEventListener("pointerdown",O)});return()=>{R(),M?.removeEventListener("pointermove",N)}},[u,d,n,_,s]);const m=N=>N==="bottom",b=S.useCallback(N=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");n.update(()=>{const O=Ae(u.elem);if(!J(O))throw new Error("TableCellResizer: Table cell node not found.");const M=ot(O),R=ou(O),$=M.getChildren(),A=O.getColSpan()===M.getColumnCount()?R:R+O.getRowSpan()-1;if(A>=$.length||A<0)throw new Error("Expected table cell to be inside of table row.");const B=$[A];if(!ce(B))throw new Error("Expected table row");let j=B.getHeight();if(j===void 0){const z=B.getChildren();j=Math.min(...z.map(K=>h(K,n)??1/0))}const U=Math.max(j+N,IA);B.setHeight(U)},{tag:$l})},[u,n]),w=(N,O)=>{for(let M=0;M<O.length;M++)for(let R=0;R<O[M].length;R++)if(O[M][R].cell===N)return R},C=S.useCallback(N=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");n.update(()=>{const O=Ae(u.elem);if(!J(O))throw new Error("TableCellResizer: Table cell node not found.");const M=ot(O),[R]=at(M,null,null),$=w(O,R);if($===void 0)throw new Error("TableCellResizer: Table column not found.");const L=M.getColWidths();if(!L)return;const A=L[$];if(A===void 0)return;const B=[...L],j=Math.max(A+N,Ep);B[$]=j,M.setColWidths(B)},{tag:$l})},[u,n]),v=S.useCallback(N=>{const O=M=>{if(M.preventDefault(),M.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(a.current){const{x:R,y:$}=a.current;if(u===null)return;const L=Wn(M.target);if(m(N)){const A=(M.clientY-$)/L;b(A)}else{const A=(M.clientX-R)/L;C(A)}_(),document.removeEventListener("pointerup",O)}};return O},[u,_,C,b]),k=S.useCallback(N=>O=>{if(O.preventDefault(),O.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");a.current={x:O.clientX,y:O.clientY},c(a.current),g(N),document.addEventListener("pointerup",v(N))},[u,v]),E=S.useCallback(()=>{if(u){const{height:N,width:O,top:M,left:R}=u.elem.getBoundingClientRect(),$=Wn(u.elem),L=4,A={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+R}px`,top:`${window.scrollY+M+N-L/2}px`,width:`${O}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${N}px`,left:`${window.scrollX+R+O-L/2}px`,top:`${window.scrollY+M}px`,width:`${L}px`}};return d&&l&&r&&(m(d)?(A[d].left=`${window.scrollX+r.left}px`,A[d].top=`${window.scrollY+l.y/$}px`,A[d].height="3px",A[d].width=`${r.width}px`):(A[d].top=`${window.scrollY+r.top}px`,A[d].left=`${window.scrollX+l.x/$}px`,A[d].width="3px",A[d].height=`${r.height}px`),A[d].backgroundColor="var(--bgColor-accent-emphasis)",A[d].mixBlendMode="unset"),A}return{bottom:null,left:null,right:null,top:null}},[u,d,l,r])();return x.jsx("div",{ref:t,children:u!=null&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"TableCellResizer__resizer TableCellResizer__ui",style:E.right||void 0,onPointerDown:k("right")}),x.jsx("div",{className:"TableCellResizer__resizer TableCellResizer__ui",style:E.bottom||void 0,onPointerDown:k("bottom")})]})})}function _$(){const[n]=fe(),e=Hr();return S.useMemo(()=>e?St.createPortal(x.jsx(EA,{editor:n}),document.body):null,[n,e])}function NA(n){const e=n.match(/^(\d+(?:\.\d+)?)(px|pt)$/);return e?[Number(e[1]),e[2]]:null}function LA(n,e){return e==="pt"?Math.round(n*4/3):n}function OA(n){const e=NA(n);if(!e)return"";const[t,r]=e;return`${LA(t,r)}px`}const RA=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]}),Bb=w0().filter(n=>["c","clike","cpp","css","html","java","js","javascript","markdown","objc","objective-c","plain","powershell","py","python","rust","sql","swift","typescript","xml"].includes(n[0])),AA=Bb,Np=zl,Lp=[["prism","Prism (Default)"]],MA=[["Arial","Arial"],["Courier New","Courier New"],["Georgia","Georgia"],["Times New Roman","Times New Roman"],["Trebuchet MS","Trebuchet MS"],["Verdana","Verdana"]],$A={center:{name:"Center Align"},end:{name:"End Align"},justify:{name:"Justify Align"},left:{name:"Left Align"},right:{name:"Right Align"},start:{name:"Start Align"}};function Op(n){let e=n.getKey()==="root"?n:re(n,t=>{const r=t.getParent();return r!==null&&wt(r)});return e===null&&(e=n.getTopLevelElementOrThrow()),e}function DA({editor:n,fontSize:e,disabled:t}){const r=OA(e).slice(0,-2),[o,s]=S.useState(r);S.useEffect(()=>{s(r)},[r]);const i=a=>{const l=Number(o);if(a.key!=="Tab"){if(["e","E","+","-"].includes(a.key)||isNaN(l)){a.preventDefault(),s("");return}if(a.key==="Enter"||a.key==="Escape"){a.preventDefault();const c=Math.max(8,Math.min(72,l));s(String(c)),Qi(n,String(c)+"px",null)}}};return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[x.jsx("button",{type:"button",disabled:t||Number(o)<=8,onClick:()=>cp(n,Bo.decrement,o),"aria-label":"Decrease font size",title:`Decrease font size (${xe.DECREASE_FONT_SIZE})`,style:{border:"none",background:"none",cursor:t?"not-allowed":"pointer",padding:"4px",borderRadius:"6px",display:"flex",alignItems:"center"},children:x.jsx(ji,{size:14})}),x.jsx("input",{type:"number",title:"Font size",value:o,disabled:t,min:8,max:72,onChange:a=>s(a.target.value),onKeyDown:i,onBlur:()=>{if(o!==""){const a=Math.max(8,Math.min(72,Number(o)));s(String(a)),Qi(n,String(a)+"px",null)}},style:{width:32,textAlign:"center",border:"1px solid var(--borderColor-default, #d0d7de)",borderRadius:6,padding:"2px 4px",fontSize:12,background:"transparent",color:"inherit"}}),x.jsx("button",{type:"button",disabled:t||Number(o)>=72,onClick:()=>cp(n,Bo.increment,o),"aria-label":"Increase font size",title:`Increase font size (${xe.INCREASE_FONT_SIZE})`,style:{border:"none",background:"none",cursor:t?"not-allowed":"pointer",padding:"4px",borderRadius:"6px",display:"flex",alignItems:"center"},children:x.jsx(Di,{size:14})})]})}function m$({editor:n,activeEditor:e,setActiveEditor:t,setIsLinkEditMode:r,extraItems:o,hiddenItems:s}){const[i,a]=S.useState(null),[l,c]=Go(),[u,f]=S.useState(()=>n.isEditable()),{toolbarState:d,updateToolbarState:g}=U0(),{settings:{isCodeHighlighted:h,isCodeShiki:_}}=j0(),m=S.useCallback(L=>{const A=Wr(L)?L.getTag():L.getType();A in Ua&&g("blockType",A)},[g]),b=S.useCallback(L=>{if(je(L)){const A=L.getLanguage();g("codeLanguage",A?h&&(_?Np(A):zl(A))||A:"");const B=L.getTheme();g("codeTheme",B||"")}},[g,h,_]),w=S.useCallback(()=>{const L=D();if(F(L)){if(Q(L.anchor.key)==null||Q(L.focus.key)==null)return;if(e!==n&&jw(e)){const Ce=e.getRootElement();g("isImageCaption",!!Ce?.parentElement?.classList.contains("image-caption-container"))}else g("isImageCaption",!1);const A=L.anchor.getNode(),B=Op(A),j=B.getKey(),U=e.getElementByKey(j);g("isRTL",Fw(L));const z=Bm(L),K=z.getParent(),H=Pe(K)||Pe(z);g("isLink",H);const ie=re(z,be);if(be(ie)?g("rootType","table"):g("rootType","root"),U!==null)if(a(j),Z(B)){const Ce=Ol(A,Yt),ut=Ce?Ce.getListType():B.getListType();g("blockType",ut)}else m(B),b(B);g("fontColor",ei(L,"color","#000")),g("bgColor",ei(L,"background-color","#fff")),g("fontFamily",ei(L,"font-family","Arial"));let Ne;Pe(K)&&(Ne=re(z,Ce=>q(Ce)&&!Ce.isInline())),g("elementFormat",q(Ne)?Ne.getFormatType():q(z)?z.getFormatType():K?.getFormatType()||"left")}if((F(L)||ae(L))&&(g("isBold",L.hasFormat("bold")),g("isItalic",L.hasFormat("italic")),g("isUnderline",L.hasFormat("underline")),g("isStrikethrough",L.hasFormat("strikethrough")),g("isSubscript",L.hasFormat("subscript")),g("isSuperscript",L.hasFormat("superscript")),g("isHighlight",L.hasFormat("highlight")),g("isCode",L.hasFormat("code")),g("fontSize",ei(L,"font-size","15px")),g("isLowercase",L.hasFormat("lowercase")),g("isUppercase",L.hasFormat("uppercase")),g("isCapitalize",L.hasFormat("capitalize"))),ve(L)){const A=L.getNodes();for(const B of A){const j=Ol(B,Yt);if(j)g("blockType",j.getListType());else{const U=Op(B);m(U),b(U),q(U)&&g("elementFormat",U.getFormatType())}}}},[e,n,g,m,b]);S.useEffect(()=>n.registerCommand(Ht,(L,A)=>(t(A),w(),!1),bo),[n,w,t]),S.useEffect(()=>{e.getEditorState().read(()=>{w()},{editor:e})},[e,w]),S.useEffect(()=>de(n.registerEditableListener(L=>f(L)),e.registerUpdateListener(({editorState:L})=>{L.read(()=>{w()},{editor:e})}),e.registerCommand(hh,L=>(g("canUndo",L),!1),bo),e.registerCommand(_h,L=>(g("canRedo",L),!1),bo)),[w,e,n,g]);const C=S.useCallback(()=>{d.isLink?(r(!1),e.dispatchCommand(Lr,null)):(r(!0),e.dispatchCommand(Lr,AN("https://")))},[e,r,d.isLink]),v=S.useCallback(L=>{e.update(()=>{if(i!==null){const A=Q(i);je(A)&&A.setLanguage(L)}})},[e,i]),k=S.useCallback(L=>{e.update(()=>{if(i!==null){const A=Q(i);je(A)&&A.setTheme(L)}})},[e,i]),I=L=>{e.dispatchCommand(Ys,L)},{showComments:E,toggleComments:N}=e_(),O=!d.isImageCaption,M=!d.isImageCaption,R=S.useMemo(()=>{const L=[];let A=0;if(L.push({key:"undo",type:"button",order:A++,group:"history",ariaLabel:"Undo",title:we?"Undo (⌘Z)":"Undo (Ctrl+Z)",icon:ox,disabled:!d.canUndo||!u,onClick:()=>e.dispatchCommand(ph,void 0)}),L.push({key:"redo",type:"button",order:A++,group:"history",ariaLabel:"Redo",title:we?"Redo (⇧⌘Z)":"Redo (Ctrl+Y)",icon:sx,disabled:!d.canRedo||!u,onClick:()=>e.dispatchCommand(gh,void 0)}),L.push({key:"divider-history",type:"divider",order:A++}),d.blockType in Ua&&e===n){const j=[{key:"paragraph",label:"Normal",shortcut:xe.NORMAL,isActive:d.blockType==="paragraph",onClick:()=>Ta(e)},{key:"h1",label:"Heading 1",shortcut:xe.HEADING1,isActive:d.blockType==="h1",onClick:()=>xl(e,d.blockType,"h1")},{key:"h2",label:"Heading 2",shortcut:xe.HEADING2,isActive:d.blockType==="h2",onClick:()=>xl(e,d.blockType,"h2")},{key:"h3",label:"Heading 3",shortcut:xe.HEADING3,isActive:d.blockType==="h3",onClick:()=>xl(e,d.blockType,"h3")},{key:"number",label:"Numbered List",shortcut:xe.NUMBERED_LIST,isActive:d.blockType==="number",onClick:()=>tR(e,d.blockType),icon:Eh},{key:"bullet",label:"Bullet List",shortcut:xe.BULLET_LIST,isActive:d.blockType==="bullet",onClick:()=>QO(e,d.blockType),icon:vh},{key:"check",label:"Check List",shortcut:xe.CHECK_LIST,isActive:d.blockType==="check",onClick:()=>eR(e,d.blockType)},{key:"quote",label:"Quote",shortcut:xe.QUOTE,isActive:d.blockType==="quote",onClick:()=>nR(e,d.blockType),icon:Nh},{key:"code",label:"Code Block",shortcut:xe.CODE_BLOCK,isActive:d.blockType==="code",onClick:()=>rR(e,d.blockType),icon:br}];L.push({key:"block-format",type:"dropdown",order:A++,group:"block",ariaLabel:"Formatting options for text style",label:Ua[d.blockType],minWidth:110,options:j,disabled:!u}),L.push({key:"divider-block",type:"divider",order:A++})}if(d.blockType==="code"&&h){const j=_?AA:Bb;L.push({key:"code-language",type:"dropdown",order:A++,group:"code",ariaLabel:"Select language",label:(j.find(U=>U[0]===(_?Np(d.codeLanguage):zl(d.codeLanguage)))||["",""])[1],minWidth:90,disabled:!u,options:j.map(([U,z])=>({key:U,label:z,isActive:U===d.codeLanguage,onClick:()=>v(U)}))}),_&&L.push({key:"code-theme",type:"dropdown",order:A++,group:"code",ariaLabel:"Select theme",label:(Lp.find(U=>U[0]===d.codeTheme)||["",""])[1],minWidth:90,disabled:!u,options:Lp.map(([U,z])=>({key:U,label:z,isActive:U===d.codeTheme,onClick:()=>k(U)}))})}else{L.push({key:"font-family",type:"dropdown",order:A++,group:"font",ariaLabel:"Font family",icon:Ih,label:d.fontFamily,minWidth:90,disabled:!u,options:MA.map(([U,z])=>({key:U,label:z,isActive:d.fontFamily===U,onClick:()=>{e.update(()=>{const K=D();K!==null&&kh(K,{"font-family":U})})}}))}),L.push({key:"divider-font",type:"divider",order:A++}),L.push({key:"font-size",type:"custom",order:A++,group:"font",render:()=>x.jsx(DA,{editor:e,fontSize:d.fontSize,disabled:!u})}),L.push({key:"divider-fontsize",type:"divider",order:A++}),L.push({key:"bold",type:"button",order:A++,group:"format",ariaLabel:`Bold (${xe.BOLD})`,title:`Bold (${xe.BOLD})`,icon:Lh,isActive:d.isBold,disabled:!u,onClick:()=>e.dispatchCommand(Xe,"bold")}),L.push({key:"italic",type:"button",order:A++,group:"format",ariaLabel:`Italic (${xe.ITALIC})`,title:`Italic (${xe.ITALIC})`,icon:Oh,isActive:d.isItalic,disabled:!u,onClick:()=>e.dispatchCommand(Xe,"italic")}),L.push({key:"underline",type:"button",order:A++,group:"format",ariaLabel:`Underline (${xe.UNDERLINE})`,title:`Underline (${xe.UNDERLINE})`,icon:RA,isActive:d.isUnderline,disabled:!u,onClick:()=>e.dispatchCommand(Xe,"underline")}),M&&L.push({key:"code-inline",type:"button",order:A++,group:"format",ariaLabel:`Code (${xe.INSERT_CODE_BLOCK})`,title:`Code (${xe.INSERT_CODE_BLOCK})`,icon:br,isActive:d.isCode,disabled:!u,onClick:()=>e.dispatchCommand(Xe,"code")}),L.push({key:"link",type:"button",order:A++,group:"format",ariaLabel:`Link (${xe.INSERT_LINK})`,title:`Link (${xe.INSERT_LINK})`,icon:Ah,isActive:d.isLink,disabled:!u,onClick:C});const j=d.isLowercase?"Lowercase":d.isUppercase?"Uppercase":d.isCapitalize?"Capitalize":d.isStrikethrough?"Strikethrough":d.isSubscript?"Subscript":d.isSuperscript?"Superscript":d.isHighlight?"Highlight":"More";if(L.push({key:"more-formatting",type:"dropdown",order:A++,group:"format",ariaLabel:"More formatting options",icon:Bw,label:j,minWidth:95,disabled:!u,options:[{key:"lowercase",label:"Lowercase",shortcut:xe.LOWERCASE,isActive:d.isLowercase,onClick:()=>e.dispatchCommand(Xe,"lowercase")},{key:"uppercase",label:"Uppercase",shortcut:xe.UPPERCASE,isActive:d.isUppercase,onClick:()=>e.dispatchCommand(Xe,"uppercase")},{key:"capitalize",label:"Capitalize",shortcut:xe.CAPITALIZE,isActive:d.isCapitalize,onClick:()=>e.dispatchCommand(Xe,"capitalize")},{key:"strikethrough",label:"Strikethrough",shortcut:xe.STRIKETHROUGH,isActive:d.isStrikethrough,icon:Rh,onClick:()=>e.dispatchCommand(Xe,"strikethrough")},{key:"subscript",label:"Subscript",shortcut:xe.SUBSCRIPT,isActive:d.isSubscript,onClick:()=>e.dispatchCommand(Xe,"subscript")},{key:"superscript",label:"Superscript",shortcut:xe.SUPERSCRIPT,isActive:d.isSuperscript,onClick:()=>e.dispatchCommand(Xe,"superscript")},{key:"highlight",label:"Highlight",isActive:d.isHighlight,icon:gx,onClick:()=>e.dispatchCommand(Xe,"highlight")},{key:"clear",label:"Clear Formatting",shortcut:xe.CLEAR_FORMATTING,icon:Rp,onClick:()=>oR(e)}]}),O){L.push({key:"divider-insert",type:"divider",order:A++});const U=[{key:"hr",label:"Horizontal Rule",icon:ix,onClick:()=>e.dispatchCommand(Kc,void 0)},{key:"table",label:"Table",icon:yi,onClick:()=>e.dispatchCommand(ws,void 0)},{key:"collapsible",label:"Collapsible",icon:zc,onClick:()=>e.dispatchCommand(Gu,void 0)},{key:"excalidraw",label:"Excalidraw",onClick:()=>e.dispatchCommand(nd,void 0)},{key:"video",label:"Video",icon:Wc,onClick:()=>e.dispatchCommand(sd,void 0)},{key:"loom",label:"Loom Video",icon:Ws,onClick:()=>e.dispatchCommand(ka,void 0)},{key:"deck",label:"Deck Slide",icon:hs,onClick:()=>e.dispatchCommand(od,void 0)},{key:"image",label:"Image",icon:hs,onClick:()=>c("Insert Image",z=>x.jsx(z_,{activeEditor:e,onClose:z}))},{key:"gif",label:"GIF",onClick:()=>{yu().then(z=>{z&&I(z)})}},{key:"equation",label:"Equation",onClick:()=>c("Insert Equation",z=>x.jsx(ad,{activeEditor:e,onClose:z}))},...qu.map(z=>({key:`embed-${z.type}`,label:`Embed ${z.contentName}`,onClick:()=>e.dispatchCommand(Ju,z.type)}))];L.push({key:"insert",type:"dropdown",order:A++,group:"insert",ariaLabel:"Insert",icon:Di,label:"Insert",disabled:!u,options:U})}}L.push({key:"divider-align",type:"divider",order:A++});const B=$A[d.elementFormat||"left"];return L.push({key:"alignment",type:"dropdown",order:A++,group:"align",ariaLabel:"Text alignment",label:B.name,minWidth:95,icon:Uw,disabled:!u,options:[{key:"left",label:"Left Align",shortcut:xe.LEFT_ALIGN,isActive:d.elementFormat==="left",onClick:()=>e.dispatchCommand(Bn,"left")},{key:"center",label:"Center Align",shortcut:xe.CENTER_ALIGN,isActive:d.elementFormat==="center",onClick:()=>e.dispatchCommand(Bn,"center")},{key:"right",label:"Right Align",shortcut:xe.RIGHT_ALIGN,isActive:d.elementFormat==="right",onClick:()=>e.dispatchCommand(Bn,"right")},{key:"justify",label:"Justify Align",shortcut:xe.JUSTIFY_ALIGN,isActive:d.elementFormat==="justify",onClick:()=>e.dispatchCommand(Bn,"justify")},{key:"outdent",label:"Outdent",shortcut:xe.OUTDENT,onClick:()=>e.dispatchCommand(wn,void 0)},{key:"indent",label:"Indent",shortcut:xe.INDENT,onClick:()=>e.dispatchCommand(Dt,void 0)}]}),L.push({key:"divider-comments",type:"divider",order:A++}),L.push({key:"comments",type:"button",order:A,group:"comments",ariaLabel:E?"Hide Comments":"Show Comments",title:E?"Hide Comments":"Show Comments",icon:Pi,isActive:E,onClick:N}),L},[d,u,h,_,e,n,M,O,E,N,C,v,k,c,i]),$=S.useMemo(()=>{if(!s?.length)return R;const L=new Set(s);return R.filter(A=>!L.has(A.key))},[R,s]);return x.jsxs(x.Fragment,{children:[x.jsx(cx,{items:$,extraItems:o,ariaLabel:"Editor toolbar"}),l]})}const PA=he("PRINT_PDF_COMMAND"),jA=he("EXPORT_PDF_DOCUMENT_COMMAND"),FA=he("EXPORT_PDF_SNAPSHOT_COMMAND"),BA=he("EXPORT_PDF_TYPESET_COMMAND");function hd(n){return Uu(n).title??void 0}function _d(n,e,t,r){return e.then(o=>(t.download!==!1&&x1(t.filename??S1(hd(n),r),o),t.onDone?.(o),o),o=>{throw t.onError?.(o),o})}function Ub(n,e={}){const{onDone:t,onError:r,...o}=e;return U1(n,{title:hd(n),...o}).then(()=>t?.(),s=>{throw r?.(s),s})}function UA(n,e={}){return n.registerCommand(PA,t=>(Ub(n,{...e,...t}).catch(()=>{}),!0),V)}const zA=pe({name:"@datalayer/jupyter-lexical/PdfPrint",config:{},register:(n,e)=>UA(n,e),build:(n,e)=>({print:(t={})=>Ub(n,{...e,...t})})});function zb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,M1(n,i),{filename:t,download:r,onDone:o,onError:s},"document")}function KA(n,e={}){return n.registerCommand(jA,t=>(zb(n,{...e,...t}).catch(()=>{}),!0),V)}const WA=pe({name:"@datalayer/jupyter-lexical/PdfDocument",config:{},register:(n,e)=>KA(n,e),build:(n,e)=>({export:(t={})=>zb(n,{...e,...t})})});function Kb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,T1(n,{title:hd(n),...i}),{filename:t,download:r,onDone:o,onError:s},"snapshot")}function HA(n,e={}){return n.registerCommand(FA,t=>(Kb(n,{...e,...t}).catch(()=>{}),!0),V)}const JA=pe({name:"@datalayer/jupyter-lexical/PdfSnapshot",config:{},register:(n,e)=>HA(n,e),build:(n,e)=>({export:(t={})=>Kb(n,{...e,...t})})});function qA(n){return G1(n.engine)?Promise.resolve(n.engine):Y1(n.engine)}async function Wb(n,e={}){const{engine:t,...r}=e,[o,s]=await Promise.all([qA(e),wm(n,r)]);return{pdf:await o.compile(s.main,s.files),typst:s.main}}function Hb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,Wb(n,i).then(a=>a.pdf),{filename:t,download:r,onDone:o,onError:s},"typeset")}function VA(n,e={}){return n.registerCommand(BA,t=>(Hb(n,{...e,...t}).catch(()=>{}),!0),V)}const YA=pe({name:"@datalayer/jupyter-lexical/PdfTypeset",config:{},register:(n,e)=>VA(n,e),build:(n,e)=>({export:(t={})=>Hb(n,{...e,...t}),typeset:(t={})=>Wb(n,{...e,...t}),markup:(t={})=>wm(n,{...e,...t})})}),GA=pe({name:"@datalayer/jupyter-lexical/PdfExport",dependencies:[zA,WA,JA,YA]}),XA=pe({name:"@datalayer/jupyter-lexical/AutoEmbed",dependencies:[jm,Fm,ln(Ko,{decorators:[x.jsx(TN,{},"auto-embed")]})]}),ZA=pe({name:"@datalayer/jupyter-lexical/Comment",dependencies:[Mx],nodes:()=>[Ao]}),QA=pe({name:"@datalayer/jupyter-lexical/ComponentPickerMenu",dependencies:[Ko],build:()=>({Component:IL})}),eM=pe({name:"@datalayer/jupyter-lexical/Excalidraw",nodes:()=>[Yn],dependencies:[ln(Ko,{decorators:[x.jsx(dL,{},"excalidraw")]})]});function tM({className:n,format:e,nodeKey:t,executionId:r}){const{renderExecutionTree:o}=D0();return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx("div",{className:"execution-tree","data-execution-tree":r,children:o?o({executionId:r}):x.jsxs("span",{children:["Execution ",r]})})})}class es extends Jo{__executionId;static getType(){return"execution-tree"}static clone(e){return new es(e.__executionId,e.__format,e.__key)}static importJSON(e){return Jb(e.executionId).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:"execution-tree",version:1,executionId:this.__executionId}}constructor(e,t,r){super(t,r),this.__executionId=e}updateDOM(){return!1}getExecutionId(){return this.getLatest().__executionId}isTopLevel(){return!0}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(tM,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),executionId:this.__executionId})}}function Jb(n){return new es(n)}function b$(n){return n instanceof es}const nM=he("INSERT_EXECUTION_TREE_COMMAND");function rM(n){if(!n.hasNodes([es]))throw new Error("ExecutionTreeExtension: ExecutionTreeNode not registered on editor");return n.registerCommand(nM,e=>(sr(Jb(e)),!0),V)}const oM=pe({name:"@datalayer/jupyter-lexical/ExecutionTree",nodes:()=>[es],register:rM}),sM=pe({name:"@datalayer/jupyter-lexical/InlineCompletion",nodes:()=>[Gs],dependencies:[Ko],build:()=>({Component:uO})}),iM=pe({name:"@datalayer/jupyter-lexical/JupyterInputOutput",nodes:()=>[Nt,Ar,Kt],dependencies:[Ko],build:()=>({Component:lc})}),gs=Us("counter-value",{parse:n=>typeof n=="number"?n:void 0});function aM({editor:n,nodeKey:e}){const[t,r]=S.useState(0);S.useEffect(()=>{n.getEditorState().read(()=>{const a=Q(e);if(!a)return;const l=Cs(a,gs),c=typeof l=="number"?l:a.getCount();r(c)})},[n,e]);const o=S.useCallback(a=>{n.update(()=>{const l=Q(e);if(!l)return;const c=Cs(l,gs),f=(typeof c=="number"?c:l.getCount())+a;l.setCount(f),xn(l,gs,f),r(f)})},[n,e]),s=S.useCallback(()=>{n.update(()=>{const a=Q(e);a&&(a.setCount(0),xn(a,gs,0),r(0))})},[n,e]),i=S.useMemo(()=>({wrapper:{display:"flex",alignItems:"center",gap:"8px"},label:{fontFamily:"monospace",fontWeight:700,padding:"2px 6px",background:"var(--bgColor-default)",border:"1px solid var(--borderColor-default)",borderRadius:"4px"},minus:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-danger-emphasis)",background:"var(--bgColor-danger-muted)",color:"var(--fgColor-danger)",fontWeight:"bold",cursor:"pointer"},plus:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-success-emphasis)",background:"var(--bgColor-success-muted)",color:"var(--fgColor-success)",fontWeight:"bold",cursor:"pointer"},reset:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-default)",background:"var(--bgColor-muted)",color:"var(--fgColor-default)",cursor:"pointer"}}),[]);return x.jsxs("div",{style:i.wrapper,children:[x.jsx("button",{type:"button",style:i.minus,onClick:()=>o(-1),children:"-"}),x.jsxs("span",{style:i.label,children:["Counter: ",t]}),x.jsx("button",{type:"button",style:i.plus,onClick:()=>o(1),children:"+"}),x.jsx("button",{type:"button",style:i.reset,onClick:s,children:"R"})]})}class Uo extends Bt{__count;static getType(){return"counter"}static clone(e){return new Uo(e.__count,e.__key)}static importJSON(e){const t=new Uo(e.count);try{xn(t,gs,e.count)}catch{}return t}exportJSON(){return{type:"counter",version:1,count:this.__count}}constructor(e=0,t){super(t),this.__count=e}isInline(){return!1}createDOM(e,t){const r=document.createElement("div");return r.className="counter-node",r.style.display="block",r.style.padding="8px",r.style.margin="8px 0",r.style.border="1px solid var(--borderColor-default)",r.style.borderRadius="6px",r.style.background="var(--bgColor-muted)",r}updateDOM(){return!1}getCount(){return this.__count}setCount(e){const t=this.getWritable();t.__count=e}decorate(e){return x.jsx(aM,{editor:e,nodeKey:this.getKey()})}}function y$(n=0){return new Uo(n)}function w$(n){return n instanceof Uo}function lM(n,e){return e.filter(t=>{const r="dependencies"in t?t.dependencies:[];return n.hasNodes(r)})}const cM=pe({name:"@datalayer/jupyter-lexical/MarkdownShortcuts",config:tr({transformers:Qv}),dependencies:[s_,da,tu,Vh,ma,Cb,B_,yb],register:(n,{transformers:e})=>ZO(n,lM(n,e))}),uM=pe({name:"@datalayer/jupyter-lexical/Table",dependencies:[ln(ma,{hasHorizontalScroll:!1}),ln(Ko,{decorators:[x.jsx(mb,{},"table-insert-dialog")]})]}),x$=pe({name:"@datalayer/jupyter-lexical",nodes:()=>[Uo],dependencies:[s_,Sh,da,lC,tu,ON,aS,uM,Cb,ZN,yO,cM,B_,yb,jm,Fm,SL,e2,eM,_L,oM,XA,ZA,qL,iM,XL,GA,QA,sM,hO]});export{Eu as $,Fu as A,XM as B,Mr as C,IM as D,Ox as E,e$ as F,Jc as G,qc as H,Gu as I,lc as J,qs as K,NM as L,Js as M,Ls as N,Yt as O,bn as P,Nt as Q,Kt as R,dn as S,OM as T,Hs as U,Xt as V,Wo as W,Gt as X,Jr as Y,ir as Z,Ro as _,Nu as a,du as a$,mu as a0,qo as a1,Dr as a2,Pr as a3,gn as a4,fa as a5,Ru as a6,Ou as a7,fn as a8,Wr as a9,le as aA,ce as aB,J as aC,Du as aD,kn as aE,em as aF,Cv as aG,Qv as aH,zM as aI,Vi as aJ,Sr as aK,ds as aL,_C as aM,LN as aN,Bm as aO,_t as aP,AN as aQ,Lr as aR,XN as aS,zL as aT,JL as aU,GL as aV,bO as aW,vb as aX,ZO as aY,YO as aZ,Lx as a_,Ln as aa,Vn as ab,Z as ac,Et as ad,xt as ae,qr as af,st as ag,Cu as ah,Ze as ai,je as aj,be as ak,Ho as al,pn as am,lt as an,te as ao,xa as ap,Hn as aq,ya as ar,Rr as as,ba as at,K_ as au,W_ as av,Ci as aw,Au as ax,Mo as ay,Pe as az,Z_ as b,J1 as b$,kt as b0,ou as b1,C_ as b2,ga as b3,pa as b4,ea as b5,ae as b6,yN as b7,UM as b8,CL as b9,s$ as bA,tt as bB,_b as bC,ku as bD,dr as bE,i1 as bF,kN as bG,XA as bH,TN as bI,ON as bJ,xr as bK,j_ as bL,G_ as bM,US as bN,zS as bO,ZN as bP,e2 as bQ,l2 as bR,ZA as bS,jr as bT,Bx as bU,Ao as bV,Uo as bW,wi as bX,ss as bY,Wl as bZ,ac as b_,hL as ba,KA as bb,UA as bc,HA as bd,VA as be,YM as bf,iM as bg,QA as bh,Yi as bi,cs as bj,$x as bk,y$ as bl,rd as bm,ju as bn,Jb as bo,hc as bp,Vg as bq,ic as br,$u as bs,xL as bt,fr as bu,Bu as bv,ni as bw,w$ as bx,fv as by,b$ as bz,Pt as c,vu as c$,q1 as c0,_L as c1,Xo as c2,jA as c3,FA as c4,BA as c5,qu as c6,O0 as c7,yb as c8,Kg as c9,ad as cA,z_ as cB,AS as cC,RS as cD,qL as cE,Fr as cF,Ar as cG,Vx as cH,Q_ as cI,a$ as cJ,xc as cK,wc as cL,XL as cM,pO as cN,zx as cO,uO as cP,hO as cQ,yO as cR,xN as cS,Fm as cT,Vo as cU,Ba as cV,Fa as cW,cM as cX,f2 as cY,Yx as cZ,Su as c_,eM as ca,Yn as cb,dL as cc,oM as cd,es as ce,Jx as cf,Cb as cg,Sa as ch,Ca as ci,qi as cj,od as ck,id as cl,nd as cm,nM as cn,Ys as co,ys as cp,WL as cq,VL as cr,ka as cs,HL as ct,ws as cu,sd as cv,B_ as cw,MS as cx,sM as cy,Gs as cz,Lu as d,ob as d$,$0 as d0,Rs as d1,fi as d2,u2 as d3,$1 as d4,PA as d5,WA as d6,GA as d7,g1 as d8,zA as d9,C1 as dA,E0 as dB,Yo as dC,FN as dD,_m as dE,hm as dF,Qf as dG,d1 as dH,j1 as dI,L1 as dJ,r1 as dK,KM as dL,Ph as dM,Px as dN,ki as dO,tm as dP,Qu as dQ,HN as dR,A1 as dS,x1 as dT,Qm as dU,As as dV,hl as dW,c1 as dX,i$ as dY,el as dZ,Dn as d_,JA as da,YA as db,gm as dc,Bh as dd,zm as de,L0 as df,Y_ as dg,V_ as dh,q_ as di,pr as dj,LM as dk,Xg as dl,xm as dm,uM as dn,mb as dp,ZM as dq,Kl as dr,g2 as ds,SL as dt,Zn as du,jm as dv,wN as dw,Dx as dx,Ua as dy,F1 as dz,xi as e,Sb as e$,ub as e0,ab as e1,ib as e2,db as e3,tb as e4,nb as e5,Ug as e6,rb as e7,cb as e8,lb as e9,$N as eA,G1 as eB,t$ as eC,wm as eD,Xs as eE,_1 as eF,Y1 as eG,gv as eH,_v as eI,Mu as eJ,w1 as eK,$h as eL,KL as eM,gL as eN,jN as eO,KS as eP,Xu as eQ,S1 as eR,wo as eS,BN as eT,U1 as eU,Ub as eV,Uu as eW,GS as eX,bb as eY,rM as eZ,F_ as e_,fb as ea,bc as eb,GM as ec,Ei as ed,sb as ee,hv as ef,zN as eg,M1 as eh,zb as ei,Kb as ej,Hb as ek,vi as el,Zf as em,BM as en,FM as eo,JS as ep,Hi as eq,YL as er,jM as es,Rf as et,HS as eu,ms as ev,mm as ew,dm as ex,o$ as ey,pl as ez,$r as f,h1 as f0,Zu as f1,n$ as f2,r$ as f3,T1 as f4,WN as f5,Vu as f6,DN as f7,D2 as f8,lM as f9,d$ as fA,f$ as fB,p$ as fC,g$ as fD,wp as fE,K1 as fa,uc as fb,cr as fc,ed as fd,Wb as fe,Ux as ff,e_ as fg,Um as fh,R0 as fi,Yu as fj,A0 as fk,Go as fl,M0 as fm,D0 as fn,qm as fo,j0 as fp,U0 as fq,qM as fr,JN as fs,UN as ft,PN as fu,P2 as fv,uA as fw,Sp as fx,vp as fy,u$ as fz,Os as g,Pm as h,bN as i,EM as j,WM as k,HM as l,l$ as m,_$ as n,c$ as o,h$ as p,IL as q,QN as r,QM as s,VM as t,x$ as u,h2 as v,m$ as w,Hr as x,_u as y,qx as z};
242
+ `)}xn(i,op,l);const u=$e(a);i.append(u),n.append(i)}else e&&kb(u=>Ze(u?u[2]:void 0))(n,e,t,s)},type:"multiline-element"},AO={dependencies:[Yt,bn],export:(n,e,t)=>Z(n)?ld(n,e,0,t):null,regExp:CO,replace:Tb("bullet"),triggerOnEnter:!0,type:"element"},MO={dependencies:[Yt,bn],export:(n,e,t)=>Z(n)?ld(n,e,0,t):null,regExp:xO,replace:Tb("number"),triggerOnEnter:!0,type:"element"},$O={format:["code"],tag:"`",type:"text-format"},DO={format:["highlight"],tag:"==",type:"text-format"},PO={format:["bold","italic"],tag:"***",type:"text-format"},jO={format:["bold","italic"],intraword:!1,tag:"___",type:"text-format"},FO={format:["bold"],tag:"**",type:"text-format"},BO={format:["bold"],intraword:!1,tag:"__",type:"text-format"},UO={format:["strikethrough"],tag:"~~",type:"text-format"},zO={format:["italic"],tag:"*",type:"text-format"},KO={format:["italic"],intraword:!1,tag:"_",type:"text-format"},WO={dependencies:[gn],export:(n,e,t)=>{if(!Pe(n)||_t(n))return null;const r=e(n);let o=n.getTitle();return o!=null&&(o=o.replace(/([\\"])/g,"\\$1")),o?`[${r}](${n.getURL()} "${o}")`:`[${r}](${n.getURL()})`},importRegExp:/(?:\[(.+?)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))/,regExp:/(?:\[([^[\]]*(?:\[[^[\]]*\][^[\]]*)*)\])(?:\((?:([^()\s]+)(?:\s"((?:[^"]*\\")*[^"]*)"\s*)?)\))$/,replace:(n,e)=>{if(re(n,Pe))return;const[,t,r,o]=e,s=r!=null?rp(r):void 0,i=o!=null?rp(o):void 0,a=Mo(s,{title:i}),l=t.split("[").length-1,c=t.split("]").length-1;let u=t,f="";if(l<c)return;if(l>c){const g=t.split("[");f="["+g[0],u=g.slice(1).join("[")}const d=$e(u);return d.setFormat(n.getFormat()),a.append(d),n.replace(a),f&&a.insertBefore($e(f)),d},trigger:")",type:"text-match"},HO=[OO,RO,AO,MO],JO=[Li],qO=[$O,PO,jO,FO,BO,DO,zO,KO,UO],VO=[WO],YO=[...HO,...JO,...qO,...VO];function sp(n){return oe(n)&&!n.hasFormat("code")}function XO(n,...e){const t=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const o of e)r.append("v",o);throw t.search=r.toString(),Error(`Minified Lexical error #${n}; visit ${t.toString()} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)}function ip(n,e,t,r,o){const s=n.getParent();if(!wt(s)||n.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!o&&i[t-1]!==" ")return!1;for(const{regExp:a,replace:l}of r){const c=i.match(a),u=o||c&&c[0].endsWith(" ")?t:t-1;if(c&&c[0].length===u){const f=e.getNextSiblings(),[d,g]=e.splitText(t);if(l(n,g?[g,...f]:f,c,!1)!==!1)return d.remove(),!0}}return!1}function ap(n,e,t,r,o){const s=n.getParent();if(!wt(s)||n.getFirstChild()!==e)return!1;const i=e.getTextContent();if(!o&&i[t-1]!==" ")return!1;for(const{regExpStart:a,replace:l,regExpEnd:c}of r){if(c&&!("optional"in c)||c&&"optional"in c&&!c.optional)continue;const u=i.match(a);if(u){const f=o||u[0].endsWith(" ")?t:t-1;if(u[0].length!==f)continue;const d=e.getNextSiblings(),[g,h]=e.splitText(t);if(l(n,h?[h,...d]:d,u,null,null,!1)!==!1)return g.remove(),!0}}return!1}function GO(n,e){let t=0;const r=n.getTextContent();for(let o=0;o<e;o++)r[o]==="`"&&t++;return t%2!=0}function lp(n,e,t){const r=t.length;for(let o=e;o>=r;o--){const s=o-r;if(Ib(n,s,t,0,r)&&n[s+r]!==" ")return s}return-1}function Ib(n,e,t,r,o){for(let s=0;s<o;s++)if(n[e+s]!==t[r+s])return!1;return!0}function ZO(n,e=YO){const t=wO(e),r=t.element.filter(l=>l.triggerOnEnter),o=Cc(t.textFormat,({tag:l})=>l[l.length-1]),s=Cc(t.textMatch,({trigger:l})=>l),i=new Set([" "]);for(const l of t.textFormat)i.add(l.tag.slice(-1));for(const l of t.textMatch)l.trigger!==void 0&&i.add(l.trigger);for(const l of e){const c=l.type;if(c==="element"||c==="text-match"||c==="multiline-element"){const u=l.dependencies;for(const f of u)n.hasNode(f)||XO(173,f.getType())}}const a=(l,c,u)=>!!ip(l,c,u,t.element)||!!ap(l,c,u,t.multilineElement)||!!(function(f,d,g){let h=f.getTextContent();const _=g[h[d-1]];if(_==null)return!1;d<h.length&&(h=h.slice(0,d));for(const m of _){if(!m.replace||!m.regExp)continue;const b=h.match(m.regExp);if(b===null)continue;const w=b.index||0,C=w+b[0].length;let v;return w===0?[v]=f.splitText(C):[,v]=f.splitText(w,C),v.selectNext(0,0),m.replace(v,b),!0}return!1})(c,u,s)||!!(function(f,d,g){const h=f.getTextContent(),_=d-1,m=h[_],b=g[m];if(!b)return!1;for(const w of b){const{tag:C}=w,v=C.length,k=_-v+1;if(v>1&&!Ib(h,k,C,0,v)||h[k-1]===" ")continue;const I=h[_+1];if(w.intraword===!1&&I&&!np.test(I))continue;const E=f;let N=E,O=lp(h,k,C),M=N;for(;O<0&&(M=M.getPreviousSibling())&&!ue(M);)if(oe(M)){if(M.hasFormat("code"))continue;const K=M.getTextContent();N=M,O=lp(K,K.length,C)}if(O<0||N===E&&O+v===k)continue;const R=N.getTextContent();if(O>0&&R[O-1]===m)continue;const $=R[O-1];if(w.intraword===!1&&$&&!np.test($)||!w.format.includes("code")&&GO(N,O))continue;const L=E.getTextContent(),A=L.slice(0,k)+L.slice(_+1);E.setTextContent(A);const B=N===E?A:R;N.setTextContent(B.slice(0,O)+B.slice(O+v));const j=D(),U=kr();Ee(U);const z=_-v*(N===E?2:1)+1;U.anchor.set(N.__key,O,"text"),U.focus.set(E.__key,z,"text");for(const K of w.format)U.formatText(K,rh[K]);U.anchor.set(U.focus.key,U.focus.offset,U.focus.type);for(const K of w.format)U.hasFormat(K)&&U.toggleFormat(K);return F(j)&&(U.format=j.format),!0}return!1})(c,u,o);return de(n.registerUpdateListener(({tags:l,dirtyLeaves:c,editorState:u,prevEditorState:f})=>{if(l.has(Mw)||l.has($w)||n.isComposing())return;const d=l.has(Dw),g=u.read(D),h=f.read(D);if(!F(h)||!F(g)||!g.isCollapsed()||g.is(h)&&!d)return;const _=g.anchor.key,m=g.anchor.offset,b=u._nodeMap.get(_);if(oe(b)&&c.has(_)&&(d||m===1||!(m>h.anchor.offset+1))){if(d){const w=u.read(()=>b.getTextContent())[m-1];if(!i.has(w))return}n.update(()=>{if(!sp(b))return;const w=b.getParent();w===null||je(w)||a(w,b,g.anchor.offset)&&Ai(Pw)})}}),n.registerCommand(zr,l=>{if(l!==null&&l.shiftKey)return!1;const c=D();if(!F(c)||!c.isCollapsed())return!1;const u=c.anchor.offset,f=c.anchor.getNode();if(!oe(f)||!sp(f))return!1;const d=f.getParent();return d===null||je(d)?!1:u===f.getTextContent().length&&!(!ap(d,f,u,t.multilineElement,!0)&&!ip(d,f,u,r,!0))&&(l!==null&&l.preventDefault(),!0)},ee))}var Bo;(function(n){n[n.increment=1]="increment",n[n.decrement=2]="decrement"})(Bo||(Bo={}));const Eb=(n,e)=>{if(!e)return n;let t=n;switch(e){case Bo.decrement:switch(!0){case n>Ba:t=Ba;break;case n>=48:t-=12;break;case n>=24:t-=4;break;case n>=14:t-=2;break;case n>=9:t-=1;break;default:t=Fa;break}break;case Bo.increment:switch(!0){case n<Fa:t=Fa;break;case n<12:t+=1;break;case n<20:t+=2;break;case n<36:t+=4;break;case n<=60:t+=12;break;default:t=Ba;break}break}return t},Qi=(n,e,t)=>{const r=o=>(o||(o=`${Wl}px`),o=o.slice(0,-2),`${Eb(Number(o),t)}px`);n.update(()=>{if(n.isEditable()){const o=D();o!==null&&kh(o,{"font-size":e||r})}})},cp=(n,e,t)=>{if(t!==""){const r=Eb(Number(t),e);Qi(n,String(r)+"px",null)}else Qi(n,null,e)},Ta=n=>{n.update(()=>{const e=D();Un(e,()=>ne())})},xl=(n,e,t)=>{e!==t&&n.update(()=>{const r=D();Un(r,()=>fn(t))})},QO=(n,e)=>{e!=="bullet"?n.dispatchCommand(Qc,void 0):Ta(n)},eR=(n,e)=>{e!=="check"?n.dispatchCommand(Zc,void 0):Ta(n)},tR=(n,e)=>{e!=="number"?n.dispatchCommand(eu,void 0):Ta(n)},nR=(n,e)=>{e!=="quote"&&n.update(()=>{const t=D();Un(t,()=>Ln())})},rR=(n,e)=>{e!=="code"&&n.update(()=>{let t=D();if(t)if(!F(t)||t.isCollapsed())Un(t,()=>Ze());else{const r=t.getTextContent(),o=Ze();t.insertNodes([o]),t=D(),F(t)&&t.insertRawText(r)}})},oR=n=>{n.update(()=>{const e=D();if(F(e)||ae(e)){const t=e.anchor,r=e.focus,o=e.getNodes(),s=e.extract();if(t.key===r.key&&t.offset===r.offset)return;o.forEach((i,a)=>{if(oe(i)){let l=i;a===0&&t.offset!==0&&(l=l.splitText(t.offset)[1]||l),a===o.length-1&&(l=l.splitText(r.offset)[0]||l);const c=s[0];o.length===1&&oe(c)&&(l=c),l.__style!==""&&l.setStyle(""),l.__format!==0&&l.setFormat(0);const u=Rc(l);u.__format!==0&&u.setFormat(""),u.__indent!==0&&u.setIndent(0)}else Wr(i)||Vn(i)?i.replace(ne(),!0):sc(i)&&i.setFormat("")})}})},xe=Object.freeze({NORMAL:we?"⌘+Opt+0":"Ctrl+Alt+0",HEADING1:we?"⌘+Opt+1":"Ctrl+Alt+1",HEADING2:we?"⌘+Opt+2":"Ctrl+Alt+2",HEADING3:we?"⌘+Opt+3":"Ctrl+Alt+3",NUMBERED_LIST:we?"⌘+Shift+7":"Ctrl+Shift+7",BULLET_LIST:we?"⌘+Shift+8":"Ctrl+Shift+8",CHECK_LIST:we?"⌘+Shift+9":"Ctrl+Shift+9",CODE_BLOCK:we?"⌘+Opt+C":"Ctrl+Alt+C",QUOTE:we?"⌃+Shift+Q":"Ctrl+Shift+Q",ADD_COMMENT:we?"⌘+Opt+M":"Ctrl+Alt+M",INCREASE_FONT_SIZE:we?"⌘+Shift+.":"Ctrl+Shift+.",DECREASE_FONT_SIZE:we?"⌘+Shift+,":"Ctrl+Shift+,",INSERT_CODE_BLOCK:we?"⌘+Shift+C":"Ctrl+Shift+C",STRIKETHROUGH:we?"⌘+Shift+X":"Ctrl+Shift+X",LOWERCASE:we?"⌃+Shift+1":"Ctrl+Shift+1",UPPERCASE:we?"⌃+Shift+2":"Ctrl+Shift+2",CAPITALIZE:we?"⌃+Shift+3":"Ctrl+Shift+3",CENTER_ALIGN:we?"⌘+Shift+E":"Ctrl+Shift+E",JUSTIFY_ALIGN:we?"⌘+Shift+J":"Ctrl+Shift+J",LEFT_ALIGN:we?"⌘+Shift+L":"Ctrl+Shift+L",RIGHT_ALIGN:we?"⌘+Shift+R":"Ctrl+Shift+R",SUBSCRIPT:we?"⌘+,":"Ctrl+,",SUPERSCRIPT:we?"⌘+.":"Ctrl+.",INDENT:we?"⌘+]":"Ctrl+]",OUTDENT:we?"⌘+[":"Ctrl+[",CLEAR_FORMATTING:we?"⌘+\\":"Ctrl+\\",REDO:we?"⌘+Shift+Z":"Ctrl+Y",UNDO:we?"⌘+Z":"Ctrl+Z",BOLD:we?"⌘+B":"Ctrl+B",ITALIC:we?"⌘+I":"Ctrl+I",UNDERLINE:we?"⌘+U":"Ctrl+U",INSERT_LINK:we?"⌘+K":"Ctrl+K"});function up(n){const e=n.getShape();return{columns:e.toX-e.fromX+1,rows:e.toY-e.fromY+1}}function sR(){const n=D();if(F(n)&&!n.isCollapsed()||ae(n)&&!n.anchor.is(n.focus)||!F(n)&&!ae(n))return!1;const[e]=We(n.anchor);return e.__colSpan>1||e.__rowSpan>1}function iR(n){const e=n.getLastDescendant();oe(e)?e.select():q(e)?e.selectEnd():e!==null&&e.selectNext()}function dp(n){return n.getEditorState().read(()=>{const e=D();if(F(e)||ae(e)){const[t]=We(e.anchor);if(J(t))return t.getBackgroundColor()}return null})}function aR({onClose:n,tableCellNode:e,cellMerge:t,showColorPickerModal:r}){const[o]=fe(),[s,i]=S.useState(e),[a,l]=S.useState({columns:1,rows:1}),[c,u]=S.useState(!1),[f,d]=S.useState(!1),[g,h]=S.useState(()=>dp(o)||"");S.useEffect(()=>o.registerMutationListener(Xt,B=>{B.get(s.getKey())==="updated"&&(o.getEditorState().read(()=>{i(s.getLatest())}),h(dp(o)||""))},{skipInitialization:!0}),[o,s]),S.useEffect(()=>{o.getEditorState().read(()=>{const B=D();if(ae(B)){const j=up(B);l(up(B)),u(j.columns>1||j.rows>1)}d(sR())})},[o]);const _=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s),j=kt(B,o.getElementByKey(B.getKey()));if(j===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");const U=$o(j);U!==null&&U.$clearHighlight(),B.markDirty(),i(s.getLatest())}Ee(null)})},[o,s]),m=()=>{o.update(()=>{const B=D();if(!ae(B))return;const U=B.getNodes().filter(J),z=lu(U);z&&(iR(z),n())})},b=()=>{o.update(()=>{v_()})},w=S.useCallback(B=>{o.update(()=>{for(let j=0;j<a.rows;j++)ga(B);n()})},[o,n,a.rows]),C=S.useCallback(B=>{o.update(()=>{for(let j=0;j<a.columns;j++)pa(B);n()})},[o,n,a.columns]),v=S.useCallback(()=>{o.update(()=>{su(),n()})},[o,n]),k=S.useCallback(()=>{o.update(()=>{ot(s).remove(),_(),n()})},[o,s,_,n]),I=S.useCallback(()=>{o.update(()=>{iu(),n()})},[o,n]),E=S.useCallback(()=>{o.update(()=>{const B=ot(s),j=ou(s),[U]=at(B,null,null),z=new Set,K=s.getHeaderStyles()^te.ROW;for(let H=0;H<U[j].length;H++){const ie=U[j][H];ie?.cell&&(z.has(ie.cell)||(z.add(ie.cell),ie.cell.setHeaderStyles(K,te.ROW)))}_(),n()})},[o,s,_,n]),N=S.useCallback(()=>{o.update(()=>{const B=ot(s),j=C_(s),[U]=at(B,null,null),z=new Set,K=s.getHeaderStyles()^te.COLUMN;for(let H=0;H<U.length;H++){const ie=U[H][j];ie?.cell&&(z.has(ie.cell)||(z.add(ie.cell),ie.cell.setHeaderStyles(K,te.COLUMN)))}_(),n()})},[o,s,_,n]),O=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setRowStriping(!B.getRowStriping())}_(),n()})},[o,s,_,n]),M=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setFrozenRows(B.getFrozenRows()===0?1:0)}_(),n()})},[o,s,_,n]),R=S.useCallback(()=>{o.update(()=>{if(s.isAttached()){const B=ot(s);B&&B.setFrozenColumns(B.getFrozenColumns()===0?1:0)}_(),n()})},[o,s,_,n]),$=S.useCallback(B=>{o.update(()=>{const j=D();if(F(j)||ae(j)){const[U]=We(j.anchor);if(J(U)&&U.setBackgroundColor(B),ae(j)){const z=j.getNodes();for(let K=0;K<z.length;K++){const H=z[K];J(H)&&H.setBackgroundColor(B)}}}})},[o]),L=B=>{o.update(()=>{const j=D();if(F(j)||ae(j)){const[U]=We(j.anchor);if(J(U)&&U.setVerticalAlign(B),ae(j)){const z=j.getNodes();for(let K=0;K<z.length;K++){const H=z[K];J(H)&&H.setVerticalAlign(B)}}}})};let A=null;return t&&(c?A=x.jsx(Te.Item,{onSelect:()=>m(),"data-test-id":"table-merge-cells",children:"Merge cells"}):f&&(A=x.jsx(Te.Item,{onSelect:()=>b(),"data-test-id":"table-unmerge-cells",children:"Unmerge cells"}))),x.jsxs(Te,{children:[A,x.jsx(Te.Item,{onSelect:()=>r("Cell background color",()=>x.jsx(Cx,{color:g,onChange:$})),"data-test-id":"table-background-color",children:"Background color"}),x.jsx(Te.Item,{onSelect:()=>O(),"data-test-id":"table-row-striping",children:"Toggle Row Striping"}),x.jsxs(Te.Group,{title:"Vertical Align",children:[x.jsxs(Te.Item,{onSelect:()=>L("top"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(ux,{})}),"Top Align"]}),x.jsxs(Te.Item,{onSelect:()=>L("middle"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(ji,{})}),"Middle Align"]}),x.jsxs(Te.Item,{onSelect:()=>L("bottom"),children:[x.jsx(Te.LeadingVisual,{children:x.jsx(dx,{})}),"Bottom Align"]})]}),x.jsx(Te.Item,{onSelect:()=>M(),"data-test-id":"table-freeze-first-row",children:"Toggle First Row Freeze"}),x.jsx(Te.Item,{onSelect:()=>R(),"data-test-id":"table-freeze-first-column",children:"Toggle First Column Freeze"}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>w(!1),"data-test-id":"table-insert-row-above",children:["Insert"," ",a.rows===1?"row":`${a.rows} rows`," ","above"]}),x.jsxs(Te.Item,{onSelect:()=>w(!0),"data-test-id":"table-insert-row-below",children:["Insert"," ",a.rows===1?"row":`${a.rows} rows`," ","below"]}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>C(!1),"data-test-id":"table-insert-column-before",children:["Insert"," ",a.columns===1?"column":`${a.columns} columns`," ","left"]}),x.jsxs(Te.Item,{onSelect:()=>C(!0),"data-test-id":"table-insert-column-after",children:["Insert"," ",a.columns===1?"column":`${a.columns} columns`," ","right"]}),x.jsx(Te.Divider,{}),x.jsx(Te.Item,{onSelect:()=>I(),"data-test-id":"table-delete-columns",variant:"danger",children:"Delete column"}),x.jsx(Te.Item,{onSelect:()=>v(),"data-test-id":"table-delete-rows",variant:"danger",children:"Delete row"}),x.jsx(Te.Item,{onSelect:()=>k(),"data-test-id":"table-delete",variant:"danger",children:"Delete table"}),x.jsx(Te.Divider,{}),x.jsxs(Te.Item,{onSelect:()=>E(),"data-test-id":"table-row-header",children:[(s.__headerState&te.ROW)===te.ROW?"Remove":"Add"," ","row header"]}),x.jsxs(Te.Item,{onSelect:()=>N(),"data-test-id":"table-column-header",children:[(s.__headerState&te.COLUMN)===te.COLUMN?"Remove":"Add"," ","column header"]})]})}function lR({anchorElem:n,cellMerge:e}){const[t]=fe(),r=S.useRef(null),o=S.useRef(null),[s,i]=S.useState(!1),[a,l]=S.useState(null),[c,u]=Xo(),f=S.useCallback(h=>{const _=h.closest(".JupyterLexicalTheme__tableScrollableWrapper");if(_){const m=_.getBoundingClientRect(),w=h.getBoundingClientRect().right-5,C=w-28;if(w>m.right||C<m.left)return!0}return!1},[]),d=S.useCallback(()=>{const h=r.current,_=D(),m=or(t._window),b=document.activeElement;function w(){h&&(h.classList.remove("JupyterLexicalTheme__tableCellActionButtonContainer--active"),h.classList.add("JupyterLexicalTheme__tableCellActionButtonContainer--inactive")),l(null)}if(_==null||h==null)return w();const C=t.getRootElement();let v=null,k=null;if(F(_)&&C!==null&&m!==null&&C.contains(m.anchorNode)){const E=Gl(_.anchor.getNode());if(E==null||(k=t.getElementByKey(E.getKey()),k==null||!E.isAttached())||f(k))return w();const N=ot(E),O=kt(N,t.getElementByKey(N.getKey()));if(O===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");v=$o(O),l(E)}else if(ae(_)){const E=Gl(_.anchor.getNode());if(!J(E))throw new Error("TableSelection anchorNode must be a TableCellNode");const N=ot(E),O=kt(N,t.getElementByKey(N.getKey()));if(O===null)throw new Error("TableActionMenu: Expected to find tableElement in DOM");if(v=$o(O),k=t.getElementByKey(E.getKey()),k===null||f(k))return w()}else if(!b)return w();if(v===null||k===null)return w();const I=!v||!v.isSelecting;if(h.classList.toggle("JupyterLexicalTheme__tableCellActionButtonContainer--active",I),h.classList.toggle("JupyterLexicalTheme__tableCellActionButtonContainer--inactive",!I),I){const E=k.getBoundingClientRect(),N=n.getBoundingClientRect(),O=E.top-N.top+6,M=E.right-N.left-29;h.style.transform=`translate(${M}px, ${O}px)`}},[t,n,f]);S.useEffect(()=>{let h;const _=()=>{h=void 0,t.getEditorState().read(d)},m=()=>(h===void 0&&(h=setTimeout(_,0)),!1),b=()=>{m()};return document.addEventListener("scroll",b,!0),window.addEventListener("scroll",b,!0),de(t.registerUpdateListener(m),t.registerCommand(Ht,m,bo),t.registerRootListener((C,v)=>{v&&v.removeEventListener("pointerup",m),C&&(C.addEventListener("pointerup",m),m())}),()=>{clearTimeout(h),document.removeEventListener("scroll",b,!0),window.removeEventListener("scroll",b,!0)})});const g=S.useRef(a);return S.useEffect(()=>{g.current!==a&&i(!1),g.current=a},[g,a]),x.jsx("div",{className:"JupyterLexicalTheme__tableCellActionButtonContainer",ref:r,children:a!=null&&x.jsxs(x.Fragment,{children:[c,x.jsxs(yo,{open:s,onOpenChange:i,children:[x.jsx(yo.Anchor,{children:x.jsx(Ft,{icon:zc,"aria-label":"Table cell menu",variant:"invisible",size:"small",ref:o,sx:{p:0,width:20,height:20}})}),x.jsx(yo.Overlay,{align:"end",side:"outside-bottom",children:x.jsx(aR,{onClose:()=>i(!1),tableCellNode:a,cellMerge:e,showColorPickerModal:u})})]})]})})}function c$({anchorElem:n=document.body,cellMerge:e=!1}){const t=Hr();return St.createPortal(t?x.jsx(lR,{anchorElem:n,cellMerge:e}):null,n)}function ea(n,e){const t=n()?.[e];if(typeof t!="string")throw new Error(`getThemeClass: required theme property ${e} not defined`);return t.split(/\s+/g).map(r=>`.${r}`).join()}function Ia(){return typeof window<"u"}function Zo(n){return Nb(n)?(n.nodeName||"").toLowerCase():"#document"}function Ct(n){var e;return(n==null||(e=n.ownerDocument)==null?void 0:e.defaultView)||window}function An(n){var e;return(e=(Nb(n)?n.ownerDocument:n.document)||window.document)==null?void 0:e.documentElement}function Nb(n){return Ia()?n instanceof Node||n instanceof Ct(n).Node:!1}function yt(n){return Ia()?n instanceof Element||n instanceof Ct(n).Element:!1}function ar(n){return Ia()?n instanceof HTMLElement||n instanceof Ct(n).HTMLElement:!1}function fp(n){return!Ia()||typeof ShadowRoot>"u"?!1:n instanceof ShadowRoot||n instanceof Ct(n).ShadowRoot}function Ea(n){const{overflow:e,overflowX:t,overflowY:r,display:o}=_n(n);return/auto|scroll|overlay|hidden|clip/.test(e+r+t)&&o!=="inline"&&o!=="contents"}function cR(n){return/^(table|td|th)$/.test(Zo(n))}function Na(n){try{if(n.matches(":popover-open"))return!0}catch{}try{return n.matches(":modal")}catch{return!1}}const uR=/transform|translate|scale|rotate|perspective|filter/,dR=/paint|layout|strict|content/,ur=n=>!!n&&n!=="none";let Cl;function cd(n){const e=yt(n)?_n(n):n;return ur(e.transform)||ur(e.translate)||ur(e.scale)||ur(e.rotate)||ur(e.perspective)||!ud()&&(ur(e.backdropFilter)||ur(e.filter))||uR.test(e.willChange||"")||dR.test(e.contain||"")}function fR(n){let e=Br(n);for(;ar(e)&&!Ds(e);){if(cd(e))return e;if(Na(e))return null;e=Br(e)}return null}function ud(){return Cl==null&&(Cl=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Cl}function Ds(n){return/^(html|body|#document)$/.test(Zo(n))}function _n(n){return Ct(n).getComputedStyle(n)}function La(n){return yt(n)?{scrollLeft:n.scrollLeft,scrollTop:n.scrollTop}:{scrollLeft:n.scrollX,scrollTop:n.scrollY}}function Br(n){if(Zo(n)==="html")return n;const e=n.assignedSlot||n.parentNode||fp(n)&&n.host||An(n);return fp(e)?e.host:e}function Lb(n){const e=Br(n);return Ds(e)?(n.ownerDocument||n).body:ar(e)&&Ea(e)?e:Lb(e)}function Ps(n,e,t){var r;e===void 0&&(e=[]),t===void 0&&(t=!0);const o=Lb(n),s=o===((r=n.ownerDocument)==null?void 0:r.body),i=Ct(o);if(s){const a=Sc(i);return e.concat(i,i.visualViewport||[],Ea(o)?o:[],a&&t?Ps(a):[])}else return e.concat(o,Ps(o,[],t))}function Sc(n){return n.parent&&Object.getPrototypeOf(n.parent)?n.frameElement:null}const gR=["top","right","bottom","left"],Qn=Math.min,Cn=Math.max,ta=Math.round,_i=Math.floor,Sn=n=>({x:n,y:n}),pR={left:"right",right:"left",bottom:"top",top:"bottom"};function Ob(n,e,t){return Cn(n,Qn(e,t))}function En(n,e){return typeof n=="function"?n(e):n}function er(n){return n.split("-")[0]}function Qo(n){return n.split("-")[1]}function dd(n){return n==="x"?"y":"x"}function fd(n){return n==="y"?"height":"width"}function an(n){const e=n[0];return e==="t"||e==="b"?"y":"x"}function gd(n){return dd(an(n))}function hR(n,e,t){t===void 0&&(t=!1);const r=Qo(n),o=gd(n),s=fd(o);let i=o==="x"?r===(t?"end":"start")?"right":"left":r==="start"?"bottom":"top";return e.reference[s]>e.floating[s]&&(i=na(i)),[i,na(i)]}function _R(n){const e=na(n);return[vc(n),e,vc(e)]}function vc(n){return n.includes("start")?n.replace("start","end"):n.replace("end","start")}const gp=["left","right"],pp=["right","left"],mR=["top","bottom"],bR=["bottom","top"];function yR(n,e,t){switch(n){case"top":case"bottom":return t?e?pp:gp:e?gp:pp;case"left":case"right":return e?mR:bR;default:return[]}}function wR(n,e,t,r){const o=Qo(n);let s=yR(er(n),t==="start",r);return o&&(s=s.map(i=>i+"-"+o),e&&(s=s.concat(s.map(vc)))),s}function na(n){const e=er(n);return pR[e]+n.slice(e.length)}function xR(n){var e,t,r,o;return{top:(e=n.top)!=null?e:0,right:(t=n.right)!=null?t:0,bottom:(r=n.bottom)!=null?r:0,left:(o=n.left)!=null?o:0}}function Rb(n){return typeof n!="number"?xR(n):{top:n,right:n,bottom:n,left:n}}function ra(n){const{x:e,y:t,width:r,height:o}=n;return{width:r,height:o,top:t,left:e,right:e+r,bottom:t+o,x:e,y:t}}var CR=typeof document<"u",SR=function(){},kc=CR?S.useLayoutEffect:SR;const vR={...Th},kR=vR.useInsertionEffect,TR=kR||(n=>n());function IR(n){const e=S.useRef(()=>{});return TR(()=>{e.current=n}),S.useCallback(function(){for(var t=arguments.length,r=new Array(t),o=0;o<t;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function hp(n,e,t){let{reference:r,floating:o}=n;const s=an(e),i=gd(e),a=fd(i),l=er(e),c=s==="y",u=r.x+r.width/2-o.width/2,f=r.y+r.height/2-o.height/2,d=r[a]/2-o[a]/2;let g;switch(l){case"top":g={x:u,y:r.y-o.height};break;case"bottom":g={x:u,y:r.y+r.height};break;case"right":g={x:r.x+r.width,y:f};break;case"left":g={x:r.x-o.width,y:f};break;default:g={x:r.x,y:r.y}}const h=Qo(e);return h&&(g[i]+=d*(h==="end"?1:-1)*(t&&c?-1:1)),g}async function ER(n,e){var t;e===void 0&&(e={});const{x:r,y:o,platform:s,rects:i,elements:a,strategy:l}=n,{boundary:c="clippingAncestors",rootBoundary:u="viewport",elementContext:f="floating",altBoundary:d=!1,padding:g=0}=En(e,n),h=Rb(g),m=a[d?f==="floating"?"reference":"floating":f],b=ra(await s.getClippingRect({element:(t=await(s.isElement==null?void 0:s.isElement(m)))==null||t?m:m.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(a.floating)),boundary:c,rootBoundary:u,strategy:l})),w=f==="floating"?{x:r,y:o,width:i.floating.width,height:i.floating.height}:i.reference,C=await(s.getOffsetParent==null?void 0:s.getOffsetParent(a.floating)),v=await(s.isElement==null?void 0:s.isElement(C))&&await(s.getScale==null?void 0:s.getScale(C))||{x:1,y:1},k=ra(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:a,rect:w,offsetParent:C,strategy:l}):w);return{top:(b.top-k.top+h.top)/v.y,bottom:(k.bottom-b.bottom+h.bottom)/v.y,left:(b.left-k.left+h.left)/v.x,right:(k.right-b.right+h.right)/v.x}}const NR=50,LR=async(n,e,t)=>{const{placement:r="bottom",strategy:o="absolute",middleware:s=[],platform:i}=t,a=i.detectOverflow?i:{...i,detectOverflow:ER},l=await(i.isRTL==null?void 0:i.isRTL(e));let c=await i.getElementRects({reference:n,floating:e,strategy:o}),{x:u,y:f}=hp(c,r,l),d=r,g=0;const h={};for(let _=0;_<s.length;_++){const m=s[_];if(!m)continue;const{name:b,fn:w}=m,{x:C,y:v,data:k,reset:I}=await w({x:u,y:f,initialPlacement:r,placement:d,strategy:o,middlewareData:h,rects:c,platform:a,elements:{reference:n,floating:e}});u=C??u,f=v??f,h[b]={...h[b],...k},I&&g<NR&&(g++,typeof I=="object"&&(I.placement&&(d=I.placement),I.rects&&(c=I.rects===!0?await i.getElementRects({reference:n,floating:e,strategy:o}):I.rects),{x:u,y:f}=hp(c,d,l)),_=-1)}return{x:u,y:f,placement:d,strategy:o,middlewareData:h}},OR=n=>({name:"arrow",options:n,async fn(e){const{x:t,y:r,placement:o,rects:s,platform:i,elements:a,middlewareData:l}=e,{element:c,padding:u=0}=En(n,e)||{};if(c==null)return{};const f=Rb(u),d={x:t,y:r},g=gd(o),h=fd(g),_=await i.getDimensions(c),m=g==="y",b=m?"top":"left",w=m?"bottom":"right",C=m?"clientHeight":"clientWidth",v=s.reference[h]+s.reference[g]-d[g]-s.floating[h],k=d[g]-s.reference[g],I=await(i.getOffsetParent==null?void 0:i.getOffsetParent(c));let E=I?I[C]:0;(!E||!await(i.isElement==null?void 0:i.isElement(I)))&&(E=a.floating[C]||s.floating[h]);const N=v/2-k/2,O=E/2-_[h]/2-1,M=Qn(f[b],O),R=Qn(f[w],O),$=E-_[h]-R,L=E/2-_[h]/2+N,A=Ob(M,L,$),B=!l.arrow&&Qo(o)!=null&&L!==A&&s.reference[h]/2-(L<M?M:R)-_[h]/2<0,j=B?L<M?L-M:L-$:0;return{[g]:d[g]+j,data:{[g]:A,centerOffset:L-A-j,...B&&{alignmentOffset:j}},reset:B}}}),RR=function(n){return n===void 0&&(n={}),{name:"flip",options:n,async fn(e){var t,r;const{placement:o,middlewareData:s,rects:i,initialPlacement:a,platform:l,elements:c}=e,{mainAxis:u=!0,crossAxis:f=!0,fallbackPlacements:d,fallbackStrategy:g="bestFit",fallbackAxisSideDirection:h="none",flipAlignment:_=!0,...m}=En(n,e);if((t=s.arrow)!=null&&t.alignmentOffset)return{};const b=er(o),w=an(a),C=er(a)===a,v=await(l.isRTL==null?void 0:l.isRTL(c.floating)),k=d||(C||!_?[na(a)]:_R(a)),I=h!=="none";!d&&I&&k.push(...wR(a,_,h,v));const E=[a,...k],N=await l.detectOverflow(e,m),O=[];let M=((r=s.flip)==null?void 0:r.overflows)||[];if(u&&O.push(N[b]),f){const A=hR(o,i,v);O.push(N[A[0]],N[A[1]])}if(M=[...M,{placement:o,overflows:O}],!O.every(A=>A<=0)){var R,$;const A=(((R=s.flip)==null?void 0:R.index)||0)+1,B=E[A];if(B&&(!(f==="alignment"?w!==an(B):!1)||M.every(z=>an(z.placement)===w?z.overflows[0]>0:!0)))return{data:{index:A,overflows:M},reset:{placement:B}};let j=($=M.filter(U=>U.overflows[0]<=0).sort((U,z)=>U.overflows[1]-z.overflows[1])[0])==null?void 0:$.placement;if(!j)switch(g){case"bestFit":{var L;const U=(L=M.filter(z=>{if(I){const K=an(z.placement);return K===w||K==="y"}return!0}).map(z=>[z.placement,z.overflows.filter(K=>K>0).reduce((K,H)=>K+H,0)]).sort((z,K)=>z[1]-K[1])[0])==null?void 0:L[0];U&&(j=U);break}case"initialPlacement":j=a;break}if(o!==j)return{reset:{placement:j}}}return{}}}};function _p(n,e){return{top:n.top-e.height,right:n.right-e.width,bottom:n.bottom-e.height,left:n.left-e.width}}function mp(n){return gR.some(e=>n[e]>=0)}const AR=function(n){return n===void 0&&(n={}),{name:"hide",options:n,async fn(e){const{rects:t,platform:r}=e,{strategy:o="referenceHidden",...s}=En(n,e);switch(o){case"referenceHidden":{const i=await r.detectOverflow(e,{...s,elementContext:"reference"}),a=_p(i,t.reference);return{data:{referenceHiddenOffsets:a,referenceHidden:mp(a)}}}case"escaped":{const i=await r.detectOverflow(e,{...s,altBoundary:!0}),a=_p(i,t.floating);return{data:{escapedOffsets:a,escaped:mp(a)}}}default:return{}}}}},Ab=new Set(["left","top"]);async function MR(n,e){const{placement:t,platform:r,elements:o}=n,s=await(r.isRTL==null?void 0:r.isRTL(o.floating)),i=er(t),a=Qo(t),l=an(t)==="y",c=Ab.has(i)?-1:1,u=s&&l?-1:1,f=En(e,n);let{mainAxis:d,crossAxis:g,alignmentAxis:h}=typeof f=="number"?{mainAxis:f,crossAxis:0,alignmentAxis:null}:{mainAxis:f.mainAxis||0,crossAxis:f.crossAxis||0,alignmentAxis:f.alignmentAxis};return a&&typeof h=="number"&&(g=a==="end"?h*-1:h),l?{x:g*u,y:d*c}:{x:d*c,y:g*u}}const $R=function(n){return n===void 0&&(n=0),{name:"offset",options:n,async fn(e){var t,r;const{x:o,y:s,placement:i,middlewareData:a}=e,l=await MR(e,n);return i===((t=a.offset)==null?void 0:t.placement)&&(r=a.arrow)!=null&&r.alignmentOffset?{}:{x:o+l.x,y:s+l.y,data:{...l,placement:i}}}}},DR=function(n){return n===void 0&&(n={}),{name:"shift",options:n,async fn(e){const{x:t,y:r,placement:o,platform:s}=e,{mainAxis:i=!0,crossAxis:a=!1,limiter:l={fn:w=>{let{x:C,y:v}=w;return{x:C,y:v}}},...c}=En(n,e),u={x:t,y:r},f=await s.detectOverflow(e,c),d=an(o),g=dd(d);let h=u[g],_=u[d];const m=(w,C)=>Ob(C+f[w==="y"?"top":"left"],C,C-f[w==="y"?"bottom":"right"]);i&&(h=m(g,h)),a&&(_=m(d,_));const b=l.fn({...e,[g]:h,[d]:_});return{...b,data:{x:b.x-t,y:b.y-r,enabled:{[g]:i,[d]:a}}}}}},PR=function(n){return n===void 0&&(n={}),{options:n,fn(e){var t,r;const{x:o,y:s,placement:i,rects:a,middlewareData:l}=e,{offset:c=0,mainAxis:u=!0,crossAxis:f=!0}=En(n,e),d={x:o,y:s},g=an(i),h=dd(g);let _=d[h],m=d[g];const b=En(c,e),w=typeof b=="number"?{mainAxis:b,crossAxis:0}:{mainAxis:(t=b.mainAxis)!=null?t:0,crossAxis:(r=b.crossAxis)!=null?r:0};if(u){const k=h==="y"?"height":"width",I=a.reference[h]-a.floating[k]+w.mainAxis,E=a.reference[h]+a.reference[k]-w.mainAxis;_<I?_=I:_>E&&(_=E)}if(f){var C,v;const k=h==="y"?"width":"height",I=Ab.has(er(i)),E=a.reference[g]-a.floating[k]+(I&&((C=l.offset)==null?void 0:C[g])||0)+(I?0:w.crossAxis),N=a.reference[g]+a.reference[k]+(I?0:((v=l.offset)==null?void 0:v[g])||0)-(I?w.crossAxis:0);m<E?m=E:m>N&&(m=N)}return{[h]:_,[g]:m}}}},jR=function(n){return n===void 0&&(n={}),{name:"size",options:n,async fn(e){const{placement:t,rects:r,platform:o,elements:s}=e,{apply:i=()=>{},...a}=En(n,e),l=await o.detectOverflow(e,a),c=er(t),u=Qo(t),f=an(t)==="y",{width:d,height:g}=r.floating;let h,_;c==="top"||c==="bottom"?(h=c,_=u===(await(o.isRTL==null?void 0:o.isRTL(s.floating))?"start":"end")?"left":"right"):(_=c,h=u==="end"?"top":"bottom");const m=g-l.top-l.bottom,b=d-l.left-l.right,w=Qn(g-l[h],m),C=Qn(d-l[_],b),v=e.middlewareData.shift,k=!v;let I=w,E=C;v!=null&&v.enabled.x&&(E=b),v!=null&&v.enabled.y&&(I=m),k&&!u&&(f?E=d-2*Cn(l.left,l.right):I=g-2*Cn(l.top,l.bottom)),await i({...e,availableWidth:E,availableHeight:I});const N=await o.getDimensions(s.floating);return d!==N.width||g!==N.height?{reset:{rects:!0}}:{}}}};function Mb(n){const e=_n(n);let t=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const o=ar(n),s=o?n.offsetWidth:t,i=o?n.offsetHeight:r,a=ta(t)!==s||ta(r)!==i;return a&&(t=s,r=i),{width:t,height:r,$:a}}function pd(n){return yt(n)?n:n.contextElement}function Io(n){const e=pd(n);if(!ar(e))return Sn(1);const t=e.getBoundingClientRect(),{width:r,height:o,$:s}=Mb(e);let i=(s?ta(t.width):t.width)/r,a=(s?ta(t.height):t.height)/o;return(!i||!Number.isFinite(i))&&(i=1),(!a||!Number.isFinite(a))&&(a=1),{x:i,y:a}}const FR=Sn(0);function $b(n){const e=Ct(n);return!ud()||!e.visualViewport?FR:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function BR(n,e,t){return e===void 0&&(e=!1),!!t&&e&&t===Ct(n)}function Ur(n,e,t,r){e===void 0&&(e=!1),t===void 0&&(t=!1);const o=n.getBoundingClientRect(),s=pd(n);let i=Sn(1);e&&(r?yt(r)&&(i=Io(r)):i=Io(n));const a=BR(s,t,r)?$b(s):Sn(0);let l=(o.left+a.x)/i.x,c=(o.top+a.y)/i.y,u=o.width/i.x,f=o.height/i.y;if(s&&r){const d=Ct(s),g=yt(r)?Ct(r):r;let h=d,_=Sc(h);for(;_&&g!==h;){const m=Io(_),b=_.getBoundingClientRect(),w=_n(_),C=b.left+(_.clientLeft+parseFloat(w.paddingLeft))*m.x,v=b.top+(_.clientTop+parseFloat(w.paddingTop))*m.y;l*=m.x,c*=m.y,u*=m.x,f*=m.y,l+=C,c+=v,h=Ct(_),_=Sc(h)}}return ra({width:u,height:f,x:l,y:c})}function Oa(n,e){const t=La(n).scrollLeft;return e?e.left+t:Ur(An(n)).left+t}function Db(n,e){const t=n.getBoundingClientRect(),r=t.left+e.scrollLeft-Oa(n,t),o=t.top+e.scrollTop;return{x:r,y:o}}function UR(n){let{elements:e,rect:t,offsetParent:r,strategy:o}=n;const s=o==="fixed",i=An(r),a=e?Na(e.floating):!1;if(r===i||a&&s)return t;let l={scrollLeft:0,scrollTop:0},c=Sn(1);const u=Sn(0),f=ar(r);if((f||!s)&&((Zo(r)!=="body"||Ea(i))&&(l=La(r)),f)){const g=Ur(r);c=Io(r),u.x=g.x+r.clientLeft,u.y=g.y+r.clientTop}const d=i&&!f&&!s?Db(i,l):Sn(0);return{width:t.width*c.x,height:t.height*c.y,x:t.x*c.x-l.scrollLeft*c.x+u.x+d.x,y:t.y*c.y-l.scrollTop*c.y+u.y+d.y}}function zR(n){return n.getClientRects?Array.from(n.getClientRects()):[]}function KR(n){const e=La(n),t=n.ownerDocument.body,r=Cn(n.scrollWidth,n.clientWidth,t.scrollWidth,t.clientWidth),o=Cn(n.scrollHeight,n.clientHeight,t.scrollHeight,t.clientHeight);let s=-e.scrollLeft+Oa(n);const i=-e.scrollTop;return _n(t).direction==="rtl"&&(s+=Cn(n.clientWidth,t.clientWidth)-r),{width:r,height:o,x:s,y:i}}const WR=25;function HR(n,e,t){t===void 0&&(t="viewport");const r=t==="layoutViewport",o=Ct(n),s=An(n),i=o.visualViewport;let a=s.clientWidth,l=s.clientHeight,c=0,u=0;if(i){const d=!ud()||e==="fixed";r?d||(c=-i.offsetLeft,u=-i.offsetTop):(a=i.width,l=i.height,d&&(c=i.offsetLeft,u=i.offsetTop))}if(Oa(s)<=0){const d=s.ownerDocument,g=d.body,h=getComputedStyle(g),_=d.compatMode==="CSS1Compat"&&parseFloat(h.marginLeft)+parseFloat(h.marginRight)||0,m=Math.abs(s.clientWidth-g.clientWidth-_),b=getComputedStyle(s).scrollbarGutter==="stable both-edges"?m/2:m;b<=WR&&(a-=b)}return{width:a,height:l,x:c,y:u}}function JR(n,e){const t=Ur(n,!0,e==="fixed"),r=t.top+n.clientTop,o=t.left+n.clientLeft,s=Io(n),i=n.clientWidth*s.x,a=n.clientHeight*s.y,l=o*s.x,c=r*s.y;return{width:i,height:a,x:l,y:c}}function bp(n,e,t){let r;if(e==="viewport"||e==="layoutViewport")r=HR(n,t,e);else if(e==="document")r=KR(An(n));else if(yt(e))r=JR(e,t);else{const o=$b(n);r={x:e.x-o.x,y:e.y-o.y,width:e.width,height:e.height}}return ra(r)}function qR(n,e){const t=e.get(n);if(t)return t;let r=Ps(n,[],!1).filter(a=>yt(a)&&Zo(a)!=="body"),o=null;const s=_n(n).position==="fixed";let i=s?Br(n):n;for(;yt(i)&&!Ds(i);){const a=_n(i),l=cd(i),c=o?o.position:s?"fixed":"";!l&&(c==="fixed"||c==="absolute"&&a.position==="static")?r=r.filter(f=>f!==i):o=a,i=Br(i)}return e.set(n,r),r}function VR(n){let{element:e,boundary:t,rootBoundary:r,strategy:o}=n;const i=[...t==="clippingAncestors"?Na(e)?[]:qR(e,this._c):[].concat(t),r],a=bp(e,i[0],o);let l=a.top,c=a.right,u=a.bottom,f=a.left;for(let d=1;d<i.length;d++){const g=bp(e,i[d],o);l=Cn(g.top,l),c=Qn(g.right,c),u=Qn(g.bottom,u),f=Cn(g.left,f)}return{width:c-f,height:u-l,x:f,y:l}}function YR(n){const{width:e,height:t}=Mb(n);return{width:e,height:t}}function XR(n,e,t){const r=ar(e),o=An(e),s=t==="fixed",i=Ur(n,!0,s,e);let a={scrollLeft:0,scrollTop:0};const l=Sn(0);if((r||!s)&&((Zo(e)!=="body"||Ea(o))&&(a=La(e)),r)){const d=Ur(e,!0,s,e);l.x=d.x+e.clientLeft,l.y=d.y+e.clientTop}!r&&o&&(l.x=Oa(o));const c=o&&!r&&!s?Db(o,a):Sn(0),u=i.left+a.scrollLeft-l.x-c.x,f=i.top+a.scrollTop-l.y-c.y;return{x:u,y:f,width:i.width,height:i.height}}function Sl(n){return _n(n).position==="static"}function yp(n,e){if(!ar(n)||_n(n).position==="fixed")return null;if(e)return e(n);let t=n.offsetParent;return An(n)===t&&(t=t.ownerDocument.body),t}function Pb(n,e){const t=Ct(n);if(Na(n))return t;if(!ar(n)){let o=Br(n);for(;o&&!Ds(o);){if(yt(o)&&!Sl(o))return o;o=Br(o)}return t}let r=yp(n,e);for(;r&&cR(r)&&Sl(r);)r=yp(r,e);return r&&Ds(r)&&Sl(r)&&!cd(r)?t:r||fR(n)||t}const GR=async function(n){const e=this.getOffsetParent||Pb,t=this.getDimensions,r=await t(n.floating);return{reference:XR(n.reference,await e(n.floating),n.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function ZR(n){return _n(n).direction==="rtl"}const QR={convertOffsetParentRelativeRectToViewportRelativeRect:UR,getDocumentElement:An,getClippingRect:VR,getOffsetParent:Pb,getElementRects:GR,getClientRects:zR,getDimensions:YR,getScale:Io,isElement:yt,isRTL:ZR};function jb(n,e){return n.x===e.x&&n.y===e.y&&n.width===e.width&&n.height===e.height}function eA(n,e,t){let r=null,o;const s=An(n);function i(){var u;clearTimeout(o),(u=r)==null||u.disconnect(),r=null}function a(u,f){u===void 0&&(u=!1),f===void 0&&(f=1),i();const d=n.getBoundingClientRect(),{left:g,top:h,width:_,height:m}=d;if(u||e(),!_||!m)return;const b=_i(h),w=_i(s.clientWidth-(g+_)),C=_i(s.clientHeight-(h+m)),v=_i(g),I={rootMargin:-b+"px "+-w+"px "+-C+"px "+-v+"px",threshold:Cn(0,Qn(1,f))||1};let E=!0;function N(O){const M=O[0].intersectionRatio;if(!jb(d,n.getBoundingClientRect()))return a();if(M!==f){if(!E)return a();M?a(!1,M):o=setTimeout(()=>{a(!1,1e-7)},1e3)}E=!1}try{r=new IntersectionObserver(N,{...I,root:s.ownerDocument})}catch{r=new IntersectionObserver(N,I)}r.observe(n)}const l=Ct(n),c=()=>a(t);return l.addEventListener("resize",c),a(!0),()=>{l.removeEventListener("resize",c),i()}}function wp(n,e,t,r){r===void 0&&(r={});const{ancestorScroll:o=!0,ancestorResize:s=!0,elementResize:i=typeof ResizeObserver=="function",layoutShift:a=typeof IntersectionObserver=="function",animationFrame:l=!1}=r,c=pd(n),u=o||s?[...c?Ps(c):[],...e?Ps(e):[]]:[];u.forEach(b=>{o&&b.addEventListener("scroll",t),s&&b.addEventListener("resize",t)});const f=c&&a?eA(c,t,s):null;let d=-1,g=null;i&&(g=new ResizeObserver(b=>{let[w]=b;w&&w.target===c&&g&&e&&(g.unobserve(e),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var C;(C=g)==null||C.observe(e)})),t()}),c&&!l&&g.observe(c),e&&g.observe(e));let h,_=l?Ur(n):null;l&&m();function m(){const b=Ur(n);_&&!jb(_,b)&&t(),_=b,h=requestAnimationFrame(m)}return t(),()=>{var b;u.forEach(w=>{o&&w.removeEventListener("scroll",t),s&&w.removeEventListener("resize",t)}),f?.(),(b=g)==null||b.disconnect(),g=null,l&&cancelAnimationFrame(h)}}const tA=$R,nA=DR,rA=RR,oA=jR,sA=AR,xp=OR,iA=PR,aA=(n,e,t)=>{const r=new Map,o=t??{},s={...QR,...o.platform,_c:r};return LR(n,e,{...o,platform:s})};var lA=typeof document<"u",cA=function(){},Oi=lA?S.useLayoutEffect:cA;function oa(n,e){if(n===e)return!0;if(typeof n!=typeof e)return!1;if(typeof n=="function"&&n.toString()===e.toString())return!0;let t,r,o;if(n&&e&&typeof n=="object"){if(Array.isArray(n)){if(t=n.length,t!==e.length)return!1;for(r=t;r--!==0;)if(!oa(n[r],e[r]))return!1;return!0}if(o=Object.keys(n),t=o.length,t!==Object.keys(e).length)return!1;for(r=t;r--!==0;)if(!{}.hasOwnProperty.call(e,o[r]))return!1;for(r=t;r--!==0;){const s=o[r];if(!(s==="_owner"&&n.$$typeof)&&!oa(n[s],e[s]))return!1}return!0}return n!==n&&e!==e}function Fb(n){return typeof window>"u"?1:(n.ownerDocument.defaultView||window).devicePixelRatio||1}function Cp(n,e){const t=Fb(n);return Math.round(e*t)/t}function vl(n){const e=S.useRef(n);return Oi(()=>{e.current=n}),e}function uA(n){n===void 0&&(n={});const{placement:e="bottom",strategy:t="absolute",middleware:r=[],platform:o,elements:{reference:s,floating:i}={},transform:a=!0,whileElementsMounted:l,open:c}=n,[u,f]=S.useState({x:0,y:0,strategy:t,placement:e,middlewareData:{},isPositioned:!1}),[d,g]=S.useState(r);oa(d,r)||g(r);const[h,_]=S.useState(null),[m,b]=S.useState(null),w=S.useCallback(z=>{z!==I.current&&(I.current=z,_(z))},[]),C=S.useCallback(z=>{z!==E.current&&(E.current=z,b(z))},[]),v=s||h,k=i||m,I=S.useRef(null),E=S.useRef(null),N=S.useRef(u),O=l!=null,M=vl(l),R=vl(o),$=vl(c),L=S.useCallback(()=>{if(!I.current||!E.current)return;const z={placement:e,strategy:t,middleware:d};R.current&&(z.platform=R.current),aA(I.current,E.current,z).then(K=>{const H={...K,isPositioned:$.current!==!1};A.current&&!oa(N.current,H)&&(N.current=H,St.flushSync(()=>{f(H)}))})},[d,e,t,R,$]);Oi(()=>{c===!1&&N.current.isPositioned&&(N.current.isPositioned=!1,f(z=>({...z,isPositioned:!1})))},[c]);const A=S.useRef(!1);Oi(()=>(A.current=!0,()=>{A.current=!1}),[]),Oi(()=>{if(v&&(I.current=v),k&&(E.current=k),v&&k){if(M.current)return M.current(v,k,L);L()}},[v,k,L,M,O]);const B=S.useMemo(()=>({reference:I,floating:E,setReference:w,setFloating:C}),[w,C]),j=S.useMemo(()=>({reference:v,floating:k}),[v,k]),U=S.useMemo(()=>{const z={position:t,left:0,top:0};if(!j.floating)return z;const K=Cp(j.floating,u.x),H=Cp(j.floating,u.y);return a?{...z,transform:"translate("+K+"px, "+H+"px)",...Fb(j.floating)>=1.5&&{willChange:"transform"}}:{position:t,left:K,top:H}},[t,a,j.floating,u.x,u.y]);return S.useMemo(()=>({...u,update:L,refs:B,elements:j,floatingStyles:U}),[u,L,B,j,U])}const dA=n=>{function e(t){return{}.hasOwnProperty.call(t,"current")}return{name:"arrow",options:n,fn(t){const{element:r,padding:o}=typeof n=="function"?n(t):n;return r&&e(r)?r.current!=null?xp({element:r.current,padding:o}).fn(t):{}:r?xp({element:r,padding:o}).fn(t):{}}}},Sp=(n,e)=>{const t=tA(n);return{name:t.name,fn:t.fn,options:[n,e]}},vp=(n,e)=>{const t=nA(n);return{name:t.name,fn:t.fn,options:[n,e]}},u$=(n,e)=>({fn:iA(n).fn,options:[n,e]}),d$=(n,e)=>{const t=rA(n);return{name:t.name,fn:t.fn,options:[n,e]}},f$=(n,e)=>{const t=oA(n);return{name:t.name,fn:t.fn,options:[n,e]}},g$=(n,e)=>{const t=sA(n);return{name:t.name,fn:t.fn,options:[n,e]}},p$=(n,e)=>{const t=dA(n);return{name:t.name,fn:t.fn,options:[n,e]}},fA={...Th};let kp=!1,gA=0;const Tp=()=>"floating-ui-"+Math.random().toString(36).slice(2,6)+gA++;function pA(){const[n,e]=S.useState(()=>kp?Tp():void 0);return kc(()=>{n==null&&e(Tp())},[]),S.useEffect(()=>{kp=!0},[]),n}const hA=fA.useId,_A=hA||pA;function mA(){const n=new Map;return{emit(e,t){var r;(r=n.get(e))==null||r.forEach(o=>o(t))},on(e,t){n.has(e)||n.set(e,new Set),n.get(e).add(t)},off(e,t){var r;(r=n.get(e))==null||r.delete(t)}}}const bA=S.createContext(null),yA=S.createContext(null),wA=()=>{var n;return((n=S.useContext(bA))==null?void 0:n.id)||null},xA=()=>S.useContext(yA);function CA(n){const{open:e=!1,onOpenChange:t,elements:r}=n,o=_A(),s=S.useRef({}),[i]=S.useState(()=>mA()),a=wA()!=null,[l,c]=S.useState(r.reference),u=IR((g,h,_)=>{s.current.openEvent=g?h:void 0,i.emit("openchange",{open:g,event:h,reason:_,nested:a}),t?.(g,h,_)}),f=S.useMemo(()=>({setPositionReference:c}),[]),d=S.useMemo(()=>({reference:l||r.reference||null,floating:r.floating||null,domReference:r.reference}),[l,r.reference,r.floating]);return S.useMemo(()=>({dataRef:s,open:e,onOpenChange:u,elements:d,events:i,floatingId:o,refs:f}),[e,u,d,i,o,f])}function Ip(n){var e,t;let{elements:r,...o}=n===void 0?{}:n;const{nodeId:s}=o,i=CA({...o,elements:{reference:(e=r?.reference)!=null?e:null,floating:(t=r?.floating)!=null?t:null}}),a=o.rootContext||i,l=a.elements,[c,u]=S.useState(null),[f,d]=S.useState(null),h=l?.domReference||c,_=S.useRef(null),m=xA();kc(()=>{h&&(_.current=h)},[h]);const b=uA({...o,elements:{...l,...f&&{reference:f}}}),w=S.useCallback(E=>{const N=yt(E)?{getBoundingClientRect:()=>E.getBoundingClientRect(),getClientRects:()=>E.getClientRects(),contextElement:E}:E;d(N),b.refs.setReference(N)},[b.refs]),C=S.useCallback(E=>{(yt(E)||E===null)&&(_.current=E,u(E)),(yt(b.refs.reference.current)||b.refs.reference.current===null||E!==null&&!yt(E))&&b.refs.setReference(E)},[b.refs]),v=S.useMemo(()=>({...b.refs,setReference:C,setPositionReference:w,domReference:_}),[b.refs,C,w]),k=S.useMemo(()=>({...b.elements,domReference:h}),[b.elements,h]),I=S.useMemo(()=>({...b,...a,refs:v,elements:k,nodeId:s}),[b,v,k,s,a]);return kc(()=>{a.dataRef.current.floatingContext=I;const E=m?.nodesRef.current.find(N=>N.id===s);E&&(E.context=I)}),S.useMemo(()=>({...b,context:I,refs:v,elements:k}),[b,v,k,I])}function SA(n){const e=n.getChildren();let t=null;for(const r of e){if(!ce(r)||(t===null&&(t=r.getChildrenSize()),r.getChildrenSize()!==t))return!1;const o=r.getChildren();for(const s of o)if(!J(s)||s.getRowSpan()!==1||s.getColSpan()!==1)return!1}return(t||0)>0}function vA(n,e){if(!ke(n.target))return{isOutside:!0,tableElement:null};const t=`td${ea(e,"tableCell")}, th${ea(e,"tableCell")}`,o=n.target.closest(t)?.closest("table")??null;return{isOutside:o==null,tableElement:o}}function kA(n,e){const t=n.rows[0];if(!t)return null;let r=null,o=Number.POSITIVE_INFINITY;for(const s of Array.from(t.cells)){const i=s.getBoundingClientRect(),a=i.left+i.width/2,l=Math.abs(a-e);l<o&&(o=l,r={cell:s,centerX:a,top:i.top})}return r}function TA({anchorElem:n}){const[e,{getTheme:t}]=fe(),r=Hr(),[o,s]=S.useState(!1),[i,a]=S.useState(!1),l=S.useRef({getBoundingClientRect:()=>new DOMRect}),c=S.useRef({getBoundingClientRect:()=>new DOMRect}),u=S.useRef(null),f=S.useRef(null),d=S.useRef(null),g=S.useRef(null),h=S.useRef(null),{refs:_,floatingStyles:m,update:b}=Ip({middleware:[Sp({mainAxis:-9}),vp({padding:8})],placement:"top",strategy:"fixed",whileElementsMounted:wp}),{refs:w,floatingStyles:C,update:v}=Ip({middleware:[Sp({mainAxis:-9}),vp({padding:8})],placement:"left",strategy:"fixed",whileElementsMounted:wp});if(S.useEffect(()=>{if(!r)return;const N=O=>{if(u.current&&O.target instanceof Node&&u.current.contains(O.target)||f.current&&O.target instanceof Node&&f.current.contains(O.target))return;const{tableElement:M,isOutside:R}=vA(O,t);if(R||M==null||n&&!n.contains(M)){s(!1),a(!1);return}const $=`td${ea(t,"tableCell")}, th${ea(t,"tableCell")}`,L=ke(O.target)?O.target.closest($):null;if(!L){s(!1),a(!1),g.current=null,d.current=null;return}const A=L.parentElement instanceof HTMLTableRowElement?L.parentElement.rowIndex:-1,B=L.cellIndex??-1,j=kA(M,O.clientX);!j||A!==0?(s(!1),g.current=null):(g.current=j.cell,l.current.getBoundingClientRect=()=>new DOMRect(j.centerX,j.top,0,0),_.setReference(l.current),s(!0),b?.());const U=M.getBoundingClientRect();if(B!==0)a(!1),d.current=null;else{const{top:z,height:K}=L.getBoundingClientRect(),H=z+K/2;d.current=L,c.current.getBoundingClientRect=()=>new DOMRect(U.left,H,0,0),w.setReference(c.current),a(!0),v?.()}};return document.addEventListener("mousemove",N),()=>{document.removeEventListener("mousemove",N),s(!1),a(!1)}},[n,t,r,w,_,b,v]),S.useEffect(()=>{const N=O=>{const M=O.relatedTarget;M&&u.current&&u.current.contains(M)||M&&f.current&&f.current.contains(M)||(s(!1),a(!1))};return h.current=N,e.registerRootListener((O,M)=>{M&&h.current&&M.removeEventListener("mouseleave",h.current),O&&h.current&&O.addEventListener("mouseleave",h.current)})},[e]),!r)return null;const k=()=>{const N=g.current;N&&e.update(()=>{const O=Ae(N);J(O)&&(O.selectEnd(),pa())})},I=()=>{const N=d.current;N&&e.update(()=>{const O=Ae(N);J(O)&&(O.selectEnd(),ga())})},E=N=>{const O=g.current;O&&e.update(()=>{const M=Ae(O);if(!J(M))return;const R=M.getParent();if(!R||!ce(R))return;const $=R.getParent();if(!be($)||!SA($))return;const L=M.getIndexWithinParent(),A=$.getChildren().filter(ce),[B]=at($,M,M),U=B[0]?.[L]?.cell?.hasHeader()??!1,z=U?A.slice(1):A;if(z.length<=1)return;z.sort((H,ie)=>{const Ne=A.indexOf(H),Ce=A.indexOf(ie),ut=B[Ne]??[],Mn=B[Ce]??[],nn=ut[L],qb=Mn[L],Vb=nn?.cell.getTextContent()??"",Yb=qb?.cell.getTextContent()??"",md=Vb.localeCompare(Yb,void 0,{numeric:!0});return N==="asc"?-md:md}),(U?gt(A[0],"next"):Er($,"next"))?.splice(0,z)})};return x.jsxs(x.Fragment,{children:[x.jsxs(Y,{ref:N=>{u.current=N,_.setFloating(N)},style:{...m,opacity:o?1:0,display:o?"flex":"none"},sx:{alignItems:"center",gap:1,zIndex:10},children:[x.jsxs(yo,{children:[x.jsx(yo.Button,{"aria-label":"Sort column",variant:"invisible",size:"small",children:x.jsx(fx,{size:16})}),x.jsx(yo.Overlay,{children:x.jsxs(Te,{children:[x.jsx(Te.Item,{onSelect:()=>E("desc"),children:"Sort Ascending"}),x.jsx(Te.Item,{onSelect:()=>E("asc"),children:"Sort Descending"})]})})]}),x.jsx(Ft,{icon:Di,"aria-label":"Add column",variant:"invisible",size:"small",onClick:k})]}),x.jsx(Ft,{ref:N=>{f.current=N,w.setFloating(N)},style:{...C,opacity:i?1:0,display:i?"inline-flex":"none"},icon:Di,"aria-label":"Add row",variant:"invisible",size:"small",onClick:I})]})}function h$({anchorElem:n=document.body}){return Hr()?St.createPortal(x.jsx(TA,{anchorElem:n}),n):null}const IA=33,Ep=92;function EA({editor:n}){const e=S.useRef(null),t=S.useRef(null),[r,o]=S.useState(null),[s,i]=S.useState(!1),a=S.useRef(null),[l,c]=S.useState(null),[u,f]=S.useState(null),[d,g]=S.useState(null),h=(N,O)=>O.getElementByKey(N.getKey())?.clientHeight,_=S.useCallback(()=>{f(null),e.current=null,g(null),a.current=null,o(null)},[]);S.useEffect(()=>{const N=new Set;return de(n.registerMutationListener(Gt,O=>{for(const[R,$]of O)$==="destroyed"?N.delete(R):N.add(R);const M=N.size>0;i(M)}),n.registerNodeTransform(Gt,O=>{if(O.getColWidths())return O;const M=O.getColumnCount(),R=Ep;return O.setColWidths(Array(M).fill(R)),O}))},[n]),S.useEffect(()=>{if(!s)return;const N=$=>{const L=$.target;if(ke(L)){if(d){$.preventDefault(),$.stopPropagation(),c({x:$.clientX,y:$.clientY});return}if(!(t.current&&t.current.contains(L))&&e.current!==L){e.current=L;const A=Do(L);A&&u!==A?n.getEditorState().read(()=>{const B=Ae(A.elem);if(!B)throw new Error("TableCellResizer: Table cell node not found.");const j=ot(B),U=kt(j,n.getElementByKey(j.getKey()));if(!U)throw new Error("TableCellResizer: Table element not found.");e.current=L,o(U.getBoundingClientRect()),f(A)},{editor:n}):A==null&&_()}}},O=$=>{$.pointerType==="touch"&&N($)},M=t.current;M?.addEventListener("pointermove",N,{capture:!0});const R=n.registerRootListener(($,L)=>{L?.removeEventListener("pointermove",N),L?.removeEventListener("pointerdown",O),$?.addEventListener("pointermove",N),$?.addEventListener("pointerdown",O)});return()=>{R(),M?.removeEventListener("pointermove",N)}},[u,d,n,_,s]);const m=N=>N==="bottom",b=S.useCallback(N=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");n.update(()=>{const O=Ae(u.elem);if(!J(O))throw new Error("TableCellResizer: Table cell node not found.");const M=ot(O),R=ou(O),$=M.getChildren(),A=O.getColSpan()===M.getColumnCount()?R:R+O.getRowSpan()-1;if(A>=$.length||A<0)throw new Error("Expected table cell to be inside of table row.");const B=$[A];if(!ce(B))throw new Error("Expected table row");let j=B.getHeight();if(j===void 0){const z=B.getChildren();j=Math.min(...z.map(K=>h(K,n)??1/0))}const U=Math.max(j+N,IA);B.setHeight(U)},{tag:$l})},[u,n]),w=(N,O)=>{for(let M=0;M<O.length;M++)for(let R=0;R<O[M].length;R++)if(O[M][R].cell===N)return R},C=S.useCallback(N=>{if(!u)throw new Error("TableCellResizer: Expected active cell.");n.update(()=>{const O=Ae(u.elem);if(!J(O))throw new Error("TableCellResizer: Table cell node not found.");const M=ot(O),[R]=at(M,null,null),$=w(O,R);if($===void 0)throw new Error("TableCellResizer: Table column not found.");const L=M.getColWidths();if(!L)return;const A=L[$];if(A===void 0)return;const B=[...L],j=Math.max(A+N,Ep);B[$]=j,M.setColWidths(B)},{tag:$l})},[u,n]),v=S.useCallback(N=>{const O=M=>{if(M.preventDefault(),M.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");if(a.current){const{x:R,y:$}=a.current;if(u===null)return;const L=Wn(M.target);if(m(N)){const A=(M.clientY-$)/L;b(A)}else{const A=(M.clientX-R)/L;C(A)}_(),document.removeEventListener("pointerup",O)}};return O},[u,_,C,b]),k=S.useCallback(N=>O=>{if(O.preventDefault(),O.stopPropagation(),!u)throw new Error("TableCellResizer: Expected active cell.");a.current={x:O.clientX,y:O.clientY},c(a.current),g(N),document.addEventListener("pointerup",v(N))},[u,v]),E=S.useCallback(()=>{if(u){const{height:N,width:O,top:M,left:R}=u.elem.getBoundingClientRect(),$=Wn(u.elem),L=4,A={bottom:{backgroundColor:"none",cursor:"row-resize",height:`${L}px`,left:`${window.scrollX+R}px`,top:`${window.scrollY+M+N-L/2}px`,width:`${O}px`},right:{backgroundColor:"none",cursor:"col-resize",height:`${N}px`,left:`${window.scrollX+R+O-L/2}px`,top:`${window.scrollY+M}px`,width:`${L}px`}};return d&&l&&r&&(m(d)?(A[d].left=`${window.scrollX+r.left}px`,A[d].top=`${window.scrollY+l.y/$}px`,A[d].height="3px",A[d].width=`${r.width}px`):(A[d].top=`${window.scrollY+r.top}px`,A[d].left=`${window.scrollX+l.x/$}px`,A[d].width="3px",A[d].height=`${r.height}px`),A[d].backgroundColor="var(--bgColor-accent-emphasis)",A[d].mixBlendMode="unset"),A}return{bottom:null,left:null,right:null,top:null}},[u,d,l,r])();return x.jsx("div",{ref:t,children:u!=null&&x.jsxs(x.Fragment,{children:[x.jsx("div",{className:"TableCellResizer__resizer TableCellResizer__ui",style:E.right||void 0,onPointerDown:k("right")}),x.jsx("div",{className:"TableCellResizer__resizer TableCellResizer__ui",style:E.bottom||void 0,onPointerDown:k("bottom")})]})})}function _$(){const[n]=fe(),e=Hr();return S.useMemo(()=>e?St.createPortal(x.jsx(EA,{editor:n}),document.body):null,[n,e])}function NA(n){const e=n.match(/^(\d+(?:\.\d+)?)(px|pt)$/);return e?[Number(e[1]),e[2]]:null}function LA(n,e){return e==="pt"?Math.round(n*4/3):n}function OA(n){const e=NA(n);if(!e)return"";const[t,r]=e;return`${LA(t,r)}px`}const RA=()=>x.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",children:[x.jsx("path",{d:"M4.5 2v5.5a3.5 3.5 0 1 0 7 0V2H13v5.5a5 5 0 0 1-10 0V2h1.5Z"}),x.jsx("rect",{x:"2",y:"14",width:"12",height:"1.5",rx:".75"})]}),Bb=w0().filter(n=>["c","clike","cpp","css","html","java","js","javascript","markdown","objc","objective-c","plain","powershell","py","python","rust","sql","swift","typescript","xml"].includes(n[0])),AA=Bb,Np=zl,Lp=[["prism","Prism (Default)"]],MA=[["Arial","Arial"],["Courier New","Courier New"],["Georgia","Georgia"],["Times New Roman","Times New Roman"],["Trebuchet MS","Trebuchet MS"],["Verdana","Verdana"]],$A={center:{name:"Center Align"},end:{name:"End Align"},justify:{name:"Justify Align"},left:{name:"Left Align"},right:{name:"Right Align"},start:{name:"Start Align"}};function Op(n){let e=n.getKey()==="root"?n:re(n,t=>{const r=t.getParent();return r!==null&&wt(r)});return e===null&&(e=n.getTopLevelElementOrThrow()),e}function DA({editor:n,fontSize:e,disabled:t}){const r=OA(e).slice(0,-2),[o,s]=S.useState(r);S.useEffect(()=>{s(r)},[r]);const i=a=>{const l=Number(o);if(a.key!=="Tab"){if(["e","E","+","-"].includes(a.key)||isNaN(l)){a.preventDefault(),s("");return}if(a.key==="Enter"||a.key==="Escape"){a.preventDefault();const c=Math.max(8,Math.min(72,l));s(String(c)),Qi(n,String(c)+"px",null)}}};return x.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2},children:[x.jsx("button",{type:"button",disabled:t||Number(o)<=8,onClick:()=>cp(n,Bo.decrement,o),"aria-label":"Decrease font size",title:`Decrease font size (${xe.DECREASE_FONT_SIZE})`,style:{border:"none",background:"none",cursor:t?"not-allowed":"pointer",padding:"4px",borderRadius:"6px",display:"flex",alignItems:"center"},children:x.jsx(ji,{size:14})}),x.jsx("input",{type:"number",title:"Font size",value:o,disabled:t,min:8,max:72,onChange:a=>s(a.target.value),onKeyDown:i,onBlur:()=>{if(o!==""){const a=Math.max(8,Math.min(72,Number(o)));s(String(a)),Qi(n,String(a)+"px",null)}},style:{width:32,textAlign:"center",border:"1px solid var(--borderColor-default, #d0d7de)",borderRadius:6,padding:"2px 4px",fontSize:12,background:"transparent",color:"inherit"}}),x.jsx("button",{type:"button",disabled:t||Number(o)>=72,onClick:()=>cp(n,Bo.increment,o),"aria-label":"Increase font size",title:`Increase font size (${xe.INCREASE_FONT_SIZE})`,style:{border:"none",background:"none",cursor:t?"not-allowed":"pointer",padding:"4px",borderRadius:"6px",display:"flex",alignItems:"center"},children:x.jsx(Di,{size:14})})]})}function m$({editor:n,activeEditor:e,setActiveEditor:t,setIsLinkEditMode:r,extraItems:o,hiddenItems:s}){const[i,a]=S.useState(null),[l,c]=Xo(),[u,f]=S.useState(()=>n.isEditable()),{toolbarState:d,updateToolbarState:g}=U0(),{settings:{isCodeHighlighted:h,isCodeShiki:_}}=j0(),m=S.useCallback(L=>{const A=Wr(L)?L.getTag():L.getType();A in Ua&&g("blockType",A)},[g]),b=S.useCallback(L=>{if(je(L)){const A=L.getLanguage();g("codeLanguage",A?h&&(_?Np(A):zl(A))||A:"");const B=L.getTheme();g("codeTheme",B||"")}},[g,h,_]),w=S.useCallback(()=>{const L=D();if(F(L)){if(Q(L.anchor.key)==null||Q(L.focus.key)==null)return;if(e!==n&&jw(e)){const Ce=e.getRootElement();g("isImageCaption",!!Ce?.parentElement?.classList.contains("image-caption-container"))}else g("isImageCaption",!1);const A=L.anchor.getNode(),B=Op(A),j=B.getKey(),U=e.getElementByKey(j);g("isRTL",Fw(L));const z=Bm(L),K=z.getParent(),H=Pe(K)||Pe(z);g("isLink",H);const ie=re(z,be);if(be(ie)?g("rootType","table"):g("rootType","root"),U!==null)if(a(j),Z(B)){const Ce=Ol(A,Yt),ut=Ce?Ce.getListType():B.getListType();g("blockType",ut)}else m(B),b(B);g("fontColor",ei(L,"color","#000")),g("bgColor",ei(L,"background-color","#fff")),g("fontFamily",ei(L,"font-family","Arial"));let Ne;Pe(K)&&(Ne=re(z,Ce=>q(Ce)&&!Ce.isInline())),g("elementFormat",q(Ne)?Ne.getFormatType():q(z)?z.getFormatType():K?.getFormatType()||"left")}if((F(L)||ae(L))&&(g("isBold",L.hasFormat("bold")),g("isItalic",L.hasFormat("italic")),g("isUnderline",L.hasFormat("underline")),g("isStrikethrough",L.hasFormat("strikethrough")),g("isSubscript",L.hasFormat("subscript")),g("isSuperscript",L.hasFormat("superscript")),g("isHighlight",L.hasFormat("highlight")),g("isCode",L.hasFormat("code")),g("fontSize",ei(L,"font-size","15px")),g("isLowercase",L.hasFormat("lowercase")),g("isUppercase",L.hasFormat("uppercase")),g("isCapitalize",L.hasFormat("capitalize"))),ve(L)){const A=L.getNodes();for(const B of A){const j=Ol(B,Yt);if(j)g("blockType",j.getListType());else{const U=Op(B);m(U),b(U),q(U)&&g("elementFormat",U.getFormatType())}}}},[e,n,g,m,b]);S.useEffect(()=>n.registerCommand(Ht,(L,A)=>(t(A),w(),!1),bo),[n,w,t]),S.useEffect(()=>{e.getEditorState().read(()=>{w()},{editor:e})},[e,w]),S.useEffect(()=>de(n.registerEditableListener(L=>f(L)),e.registerUpdateListener(({editorState:L})=>{L.read(()=>{w()},{editor:e})}),e.registerCommand(hh,L=>(g("canUndo",L),!1),bo),e.registerCommand(_h,L=>(g("canRedo",L),!1),bo)),[w,e,n,g]);const C=S.useCallback(()=>{d.isLink?(r(!1),e.dispatchCommand(Lr,null)):(r(!0),e.dispatchCommand(Lr,AN("https://")))},[e,r,d.isLink]),v=S.useCallback(L=>{e.update(()=>{if(i!==null){const A=Q(i);je(A)&&A.setLanguage(L)}})},[e,i]),k=S.useCallback(L=>{e.update(()=>{if(i!==null){const A=Q(i);je(A)&&A.setTheme(L)}})},[e,i]),I=L=>{e.dispatchCommand(Ys,L)},{showComments:E,toggleComments:N}=e_(),O=!d.isImageCaption,M=!d.isImageCaption,R=S.useMemo(()=>{const L=[];let A=0;if(L.push({key:"undo",type:"button",order:A++,group:"history",ariaLabel:"Undo",title:we?"Undo (⌘Z)":"Undo (Ctrl+Z)",icon:ox,disabled:!d.canUndo||!u,onClick:()=>e.dispatchCommand(ph,void 0)}),L.push({key:"redo",type:"button",order:A++,group:"history",ariaLabel:"Redo",title:we?"Redo (⇧⌘Z)":"Redo (Ctrl+Y)",icon:sx,disabled:!d.canRedo||!u,onClick:()=>e.dispatchCommand(gh,void 0)}),L.push({key:"divider-history",type:"divider",order:A++}),d.blockType in Ua&&e===n){const j=[{key:"paragraph",label:"Normal",shortcut:xe.NORMAL,isActive:d.blockType==="paragraph",onClick:()=>Ta(e)},{key:"h1",label:"Heading 1",shortcut:xe.HEADING1,isActive:d.blockType==="h1",onClick:()=>xl(e,d.blockType,"h1")},{key:"h2",label:"Heading 2",shortcut:xe.HEADING2,isActive:d.blockType==="h2",onClick:()=>xl(e,d.blockType,"h2")},{key:"h3",label:"Heading 3",shortcut:xe.HEADING3,isActive:d.blockType==="h3",onClick:()=>xl(e,d.blockType,"h3")},{key:"number",label:"Numbered List",shortcut:xe.NUMBERED_LIST,isActive:d.blockType==="number",onClick:()=>tR(e,d.blockType),icon:Eh},{key:"bullet",label:"Bullet List",shortcut:xe.BULLET_LIST,isActive:d.blockType==="bullet",onClick:()=>QO(e,d.blockType),icon:vh},{key:"check",label:"Check List",shortcut:xe.CHECK_LIST,isActive:d.blockType==="check",onClick:()=>eR(e,d.blockType)},{key:"quote",label:"Quote",shortcut:xe.QUOTE,isActive:d.blockType==="quote",onClick:()=>nR(e,d.blockType),icon:Nh},{key:"code",label:"Code Block",shortcut:xe.CODE_BLOCK,isActive:d.blockType==="code",onClick:()=>rR(e,d.blockType),icon:br}];L.push({key:"block-format",type:"dropdown",order:A++,group:"block",ariaLabel:"Formatting options for text style",label:Ua[d.blockType],minWidth:110,options:j,disabled:!u}),L.push({key:"divider-block",type:"divider",order:A++})}if(d.blockType==="code"&&h){const j=_?AA:Bb;L.push({key:"code-language",type:"dropdown",order:A++,group:"code",ariaLabel:"Select language",label:(j.find(U=>U[0]===(_?Np(d.codeLanguage):zl(d.codeLanguage)))||["",""])[1],minWidth:90,disabled:!u,options:j.map(([U,z])=>({key:U,label:z,isActive:U===d.codeLanguage,onClick:()=>v(U)}))}),_&&L.push({key:"code-theme",type:"dropdown",order:A++,group:"code",ariaLabel:"Select theme",label:(Lp.find(U=>U[0]===d.codeTheme)||["",""])[1],minWidth:90,disabled:!u,options:Lp.map(([U,z])=>({key:U,label:z,isActive:U===d.codeTheme,onClick:()=>k(U)}))})}else{L.push({key:"font-family",type:"dropdown",order:A++,group:"font",ariaLabel:"Font family",icon:Ih,label:d.fontFamily,minWidth:90,disabled:!u,options:MA.map(([U,z])=>({key:U,label:z,isActive:d.fontFamily===U,onClick:()=>{e.update(()=>{const K=D();K!==null&&kh(K,{"font-family":U})})}}))}),L.push({key:"divider-font",type:"divider",order:A++}),L.push({key:"font-size",type:"custom",order:A++,group:"font",render:()=>x.jsx(DA,{editor:e,fontSize:d.fontSize,disabled:!u})}),L.push({key:"divider-fontsize",type:"divider",order:A++}),L.push({key:"bold",type:"button",order:A++,group:"format",ariaLabel:`Bold (${xe.BOLD})`,title:`Bold (${xe.BOLD})`,icon:Lh,isActive:d.isBold,disabled:!u,onClick:()=>e.dispatchCommand(Ge,"bold")}),L.push({key:"italic",type:"button",order:A++,group:"format",ariaLabel:`Italic (${xe.ITALIC})`,title:`Italic (${xe.ITALIC})`,icon:Oh,isActive:d.isItalic,disabled:!u,onClick:()=>e.dispatchCommand(Ge,"italic")}),L.push({key:"underline",type:"button",order:A++,group:"format",ariaLabel:`Underline (${xe.UNDERLINE})`,title:`Underline (${xe.UNDERLINE})`,icon:RA,isActive:d.isUnderline,disabled:!u,onClick:()=>e.dispatchCommand(Ge,"underline")}),M&&L.push({key:"code-inline",type:"button",order:A++,group:"format",ariaLabel:`Code (${xe.INSERT_CODE_BLOCK})`,title:`Code (${xe.INSERT_CODE_BLOCK})`,icon:br,isActive:d.isCode,disabled:!u,onClick:()=>e.dispatchCommand(Ge,"code")}),L.push({key:"link",type:"button",order:A++,group:"format",ariaLabel:`Link (${xe.INSERT_LINK})`,title:`Link (${xe.INSERT_LINK})`,icon:Ah,isActive:d.isLink,disabled:!u,onClick:C});const j=d.isLowercase?"Lowercase":d.isUppercase?"Uppercase":d.isCapitalize?"Capitalize":d.isStrikethrough?"Strikethrough":d.isSubscript?"Subscript":d.isSuperscript?"Superscript":d.isHighlight?"Highlight":"More";if(L.push({key:"more-formatting",type:"dropdown",order:A++,group:"format",ariaLabel:"More formatting options",icon:Bw,label:j,minWidth:95,disabled:!u,options:[{key:"lowercase",label:"Lowercase",shortcut:xe.LOWERCASE,isActive:d.isLowercase,onClick:()=>e.dispatchCommand(Ge,"lowercase")},{key:"uppercase",label:"Uppercase",shortcut:xe.UPPERCASE,isActive:d.isUppercase,onClick:()=>e.dispatchCommand(Ge,"uppercase")},{key:"capitalize",label:"Capitalize",shortcut:xe.CAPITALIZE,isActive:d.isCapitalize,onClick:()=>e.dispatchCommand(Ge,"capitalize")},{key:"strikethrough",label:"Strikethrough",shortcut:xe.STRIKETHROUGH,isActive:d.isStrikethrough,icon:Rh,onClick:()=>e.dispatchCommand(Ge,"strikethrough")},{key:"subscript",label:"Subscript",shortcut:xe.SUBSCRIPT,isActive:d.isSubscript,onClick:()=>e.dispatchCommand(Ge,"subscript")},{key:"superscript",label:"Superscript",shortcut:xe.SUPERSCRIPT,isActive:d.isSuperscript,onClick:()=>e.dispatchCommand(Ge,"superscript")},{key:"highlight",label:"Highlight",isActive:d.isHighlight,icon:gx,onClick:()=>e.dispatchCommand(Ge,"highlight")},{key:"clear",label:"Clear Formatting",shortcut:xe.CLEAR_FORMATTING,icon:Rp,onClick:()=>oR(e)}]}),O){L.push({key:"divider-insert",type:"divider",order:A++});const U=[{key:"hr",label:"Horizontal Rule",icon:ix,onClick:()=>e.dispatchCommand(Kc,void 0)},{key:"table",label:"Table",icon:yi,onClick:()=>e.dispatchCommand(ws,void 0)},{key:"collapsible",label:"Collapsible",icon:zc,onClick:()=>e.dispatchCommand(Xu,void 0)},{key:"excalidraw",label:"Excalidraw",onClick:()=>e.dispatchCommand(nd,void 0)},{key:"video",label:"Video",icon:Wc,onClick:()=>e.dispatchCommand(sd,void 0)},{key:"loom",label:"Loom Video",icon:Ws,onClick:()=>e.dispatchCommand(ka,void 0)},{key:"deck",label:"Deck Slide",icon:hs,onClick:()=>e.dispatchCommand(od,void 0)},{key:"image",label:"Image",icon:hs,onClick:()=>c("Insert Image",z=>x.jsx(z_,{activeEditor:e,onClose:z}))},{key:"gif",label:"GIF",onClick:()=>{yu().then(z=>{z&&I(z)})}},{key:"equation",label:"Equation",onClick:()=>c("Insert Equation",z=>x.jsx(ad,{activeEditor:e,onClose:z}))},...qu.map(z=>({key:`embed-${z.type}`,label:`Embed ${z.contentName}`,onClick:()=>e.dispatchCommand(Ju,z.type)}))];L.push({key:"insert",type:"dropdown",order:A++,group:"insert",ariaLabel:"Insert",icon:Di,label:"Insert",disabled:!u,options:U})}}L.push({key:"divider-align",type:"divider",order:A++});const B=$A[d.elementFormat||"left"];return L.push({key:"alignment",type:"dropdown",order:A++,group:"align",ariaLabel:"Text alignment",label:B.name,minWidth:95,icon:Uw,disabled:!u,options:[{key:"left",label:"Left Align",shortcut:xe.LEFT_ALIGN,isActive:d.elementFormat==="left",onClick:()=>e.dispatchCommand(Bn,"left")},{key:"center",label:"Center Align",shortcut:xe.CENTER_ALIGN,isActive:d.elementFormat==="center",onClick:()=>e.dispatchCommand(Bn,"center")},{key:"right",label:"Right Align",shortcut:xe.RIGHT_ALIGN,isActive:d.elementFormat==="right",onClick:()=>e.dispatchCommand(Bn,"right")},{key:"justify",label:"Justify Align",shortcut:xe.JUSTIFY_ALIGN,isActive:d.elementFormat==="justify",onClick:()=>e.dispatchCommand(Bn,"justify")},{key:"outdent",label:"Outdent",shortcut:xe.OUTDENT,onClick:()=>e.dispatchCommand(wn,void 0)},{key:"indent",label:"Indent",shortcut:xe.INDENT,onClick:()=>e.dispatchCommand(Dt,void 0)}]}),L.push({key:"divider-comments",type:"divider",order:A++}),L.push({key:"comments",type:"button",order:A,group:"comments",ariaLabel:E?"Hide Comments":"Show Comments",title:E?"Hide Comments":"Show Comments",icon:Pi,isActive:E,onClick:N}),L},[d,u,h,_,e,n,M,O,E,N,C,v,k,c,i]),$=S.useMemo(()=>{if(!s?.length)return R;const L=new Set(s);return R.filter(A=>!L.has(A.key))},[R,s]);return x.jsxs(x.Fragment,{children:[x.jsx(cx,{items:$,extraItems:o,ariaLabel:"Editor toolbar"}),l]})}const PA=he("PRINT_PDF_COMMAND"),jA=he("EXPORT_PDF_DOCUMENT_COMMAND"),FA=he("EXPORT_PDF_SNAPSHOT_COMMAND"),BA=he("EXPORT_PDF_TYPESET_COMMAND");function hd(n){return Uu(n).title??void 0}function _d(n,e,t,r){return e.then(o=>(t.download!==!1&&x1(t.filename??S1(hd(n),r),o),t.onDone?.(o),o),o=>{throw t.onError?.(o),o})}function Ub(n,e={}){const{onDone:t,onError:r,...o}=e;return U1(n,{title:hd(n),...o}).then(()=>t?.(),s=>{throw r?.(s),s})}function UA(n,e={}){return n.registerCommand(PA,t=>(Ub(n,{...e,...t}).catch(()=>{}),!0),V)}const zA=pe({name:"@datalayer/jupyter-lexical/PdfPrint",config:{},register:(n,e)=>UA(n,e),build:(n,e)=>({print:(t={})=>Ub(n,{...e,...t})})});function zb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,M1(n,i),{filename:t,download:r,onDone:o,onError:s},"document")}function KA(n,e={}){return n.registerCommand(jA,t=>(zb(n,{...e,...t}).catch(()=>{}),!0),V)}const WA=pe({name:"@datalayer/jupyter-lexical/PdfDocument",config:{},register:(n,e)=>KA(n,e),build:(n,e)=>({export:(t={})=>zb(n,{...e,...t})})});function Kb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,T1(n,{title:hd(n),...i}),{filename:t,download:r,onDone:o,onError:s},"snapshot")}function HA(n,e={}){return n.registerCommand(FA,t=>(Kb(n,{...e,...t}).catch(()=>{}),!0),V)}const JA=pe({name:"@datalayer/jupyter-lexical/PdfSnapshot",config:{},register:(n,e)=>HA(n,e),build:(n,e)=>({export:(t={})=>Kb(n,{...e,...t})})});function qA(n){return X1(n.engine)?Promise.resolve(n.engine):Y1(n.engine)}async function Wb(n,e={}){const{engine:t,...r}=e,[o,s]=await Promise.all([qA(e),wm(n,r)]);return{pdf:await o.compile(s.main,s.files),typst:s.main}}function Hb(n,e={}){const{filename:t,download:r,onDone:o,onError:s,...i}=e;return _d(n,Wb(n,i).then(a=>a.pdf),{filename:t,download:r,onDone:o,onError:s},"typeset")}function VA(n,e={}){return n.registerCommand(BA,t=>(Hb(n,{...e,...t}).catch(()=>{}),!0),V)}const YA=pe({name:"@datalayer/jupyter-lexical/PdfTypeset",config:{},register:(n,e)=>VA(n,e),build:(n,e)=>({export:(t={})=>Hb(n,{...e,...t}),typeset:(t={})=>Wb(n,{...e,...t}),markup:(t={})=>wm(n,{...e,...t})})}),XA=pe({name:"@datalayer/jupyter-lexical/PdfExport",dependencies:[zA,WA,JA,YA]}),GA=pe({name:"@datalayer/jupyter-lexical/AutoEmbed",dependencies:[jm,Fm,ln(Ko,{decorators:[x.jsx(TN,{},"auto-embed")]})]}),ZA=pe({name:"@datalayer/jupyter-lexical/Comment",dependencies:[Mx],nodes:()=>[Ao]}),QA=pe({name:"@datalayer/jupyter-lexical/ComponentPickerMenu",dependencies:[Ko],build:()=>({Component:IL})}),eM=pe({name:"@datalayer/jupyter-lexical/Excalidraw",nodes:()=>[Yn],dependencies:[ln(Ko,{decorators:[x.jsx(dL,{},"excalidraw")]})]});function tM({className:n,format:e,nodeKey:t,executionId:r}){const{renderExecutionTree:o}=D0();return x.jsx(Ls,{className:n,format:e,nodeKey:t,children:x.jsx("div",{className:"execution-tree","data-execution-tree":r,children:o?o({executionId:r}):x.jsxs("span",{children:["Execution ",r]})})})}class es extends Jo{__executionId;static getType(){return"execution-tree"}static clone(e){return new es(e.__executionId,e.__format,e.__key)}static importJSON(e){return Jb(e.executionId).updateFromJSON(e)}exportJSON(){return{...super.exportJSON(),type:"execution-tree",version:1,executionId:this.__executionId}}constructor(e,t,r){super(t,r),this.__executionId=e}updateDOM(){return!1}getExecutionId(){return this.getLatest().__executionId}isTopLevel(){return!0}decorate(e,t){const r=t.theme.embedBlock||{};return x.jsx(tM,{className:{base:r.base||"",focus:r.focus||""},format:this.__format,nodeKey:this.getKey(),executionId:this.__executionId})}}function Jb(n){return new es(n)}function b$(n){return n instanceof es}const nM=he("INSERT_EXECUTION_TREE_COMMAND");function rM(n){if(!n.hasNodes([es]))throw new Error("ExecutionTreeExtension: ExecutionTreeNode not registered on editor");return n.registerCommand(nM,e=>(sr(Jb(e)),!0),V)}const oM=pe({name:"@datalayer/jupyter-lexical/ExecutionTree",nodes:()=>[es],register:rM}),sM=pe({name:"@datalayer/jupyter-lexical/InlineCompletion",nodes:()=>[Xs],dependencies:[Ko],build:()=>({Component:uO})}),iM=pe({name:"@datalayer/jupyter-lexical/JupyterInputOutput",nodes:()=>[Nt,Ar,Kt],dependencies:[Ko],build:()=>({Component:lc})}),gs=Us("counter-value",{parse:n=>typeof n=="number"?n:void 0});function aM({editor:n,nodeKey:e}){const[t,r]=S.useState(0);S.useEffect(()=>{n.getEditorState().read(()=>{const a=Q(e);if(!a)return;const l=Cs(a,gs),c=typeof l=="number"?l:a.getCount();r(c)})},[n,e]);const o=S.useCallback(a=>{n.update(()=>{const l=Q(e);if(!l)return;const c=Cs(l,gs),f=(typeof c=="number"?c:l.getCount())+a;l.setCount(f),xn(l,gs,f),r(f)})},[n,e]),s=S.useCallback(()=>{n.update(()=>{const a=Q(e);a&&(a.setCount(0),xn(a,gs,0),r(0))})},[n,e]),i=S.useMemo(()=>({wrapper:{display:"flex",alignItems:"center",gap:"8px"},label:{fontFamily:"monospace",fontWeight:700,padding:"2px 6px",background:"var(--bgColor-default)",border:"1px solid var(--borderColor-default)",borderRadius:"4px"},minus:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-danger-emphasis)",background:"var(--bgColor-danger-muted)",color:"var(--fgColor-danger)",fontWeight:"bold",cursor:"pointer"},plus:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-success-emphasis)",background:"var(--bgColor-success-muted)",color:"var(--fgColor-success)",fontWeight:"bold",cursor:"pointer"},reset:{padding:"2px 8px",borderRadius:"4px",border:"1px solid var(--borderColor-default)",background:"var(--bgColor-muted)",color:"var(--fgColor-default)",cursor:"pointer"}}),[]);return x.jsxs("div",{style:i.wrapper,children:[x.jsx("button",{type:"button",style:i.minus,onClick:()=>o(-1),children:"-"}),x.jsxs("span",{style:i.label,children:["Counter: ",t]}),x.jsx("button",{type:"button",style:i.plus,onClick:()=>o(1),children:"+"}),x.jsx("button",{type:"button",style:i.reset,onClick:s,children:"R"})]})}class Uo extends Bt{__count;static getType(){return"counter"}static clone(e){return new Uo(e.__count,e.__key)}static importJSON(e){const t=new Uo(e.count);try{xn(t,gs,e.count)}catch{}return t}exportJSON(){return{type:"counter",version:1,count:this.__count}}constructor(e=0,t){super(t),this.__count=e}isInline(){return!1}createDOM(e,t){const r=document.createElement("div");return r.className="counter-node",r.style.display="block",r.style.padding="8px",r.style.margin="8px 0",r.style.border="1px solid var(--borderColor-default)",r.style.borderRadius="6px",r.style.background="var(--bgColor-muted)",r}updateDOM(){return!1}getCount(){return this.__count}setCount(e){const t=this.getWritable();t.__count=e}decorate(e){return x.jsx(aM,{editor:e,nodeKey:this.getKey()})}}function y$(n=0){return new Uo(n)}function w$(n){return n instanceof Uo}function lM(n,e){return e.filter(t=>{const r="dependencies"in t?t.dependencies:[];return n.hasNodes(r)})}const cM=pe({name:"@datalayer/jupyter-lexical/MarkdownShortcuts",config:tr({transformers:Qv}),dependencies:[s_,da,tu,Vh,ma,Cb,B_,yb],register:(n,{transformers:e})=>ZO(n,lM(n,e))}),uM=pe({name:"@datalayer/jupyter-lexical/Table",dependencies:[ln(ma,{hasHorizontalScroll:!1}),ln(Ko,{decorators:[x.jsx(mb,{},"table-insert-dialog")]})]}),x$=pe({name:"@datalayer/jupyter-lexical",nodes:()=>[Uo],dependencies:[s_,Sh,da,lC,tu,ON,aS,uM,Cb,ZN,yO,cM,B_,yb,jm,Fm,SL,e2,eM,_L,oM,GA,ZA,qL,iM,GL,XA,QA,sM,hO]});export{Eu as $,Fu as A,GM as B,Mr as C,IM as D,Ox as E,e$ as F,Jc as G,qc as H,Xu as I,lc as J,qs as K,NM as L,Js as M,Ls as N,Yt as O,bn as P,Nt as Q,Kt as R,dn as S,OM as T,Hs as U,Gt as V,Wo as W,Xt as X,Jr as Y,ir as Z,Ro as _,Nu as a,du as a$,mu as a0,qo as a1,Dr as a2,Pr as a3,gn as a4,fa as a5,Ru as a6,Ou as a7,fn as a8,Wr as a9,le as aA,ce as aB,J as aC,Du as aD,kn as aE,em as aF,Cv as aG,Qv as aH,zM as aI,Vi as aJ,Sr as aK,ds as aL,_C as aM,LN as aN,Bm as aO,_t as aP,AN as aQ,Lr as aR,GN as aS,zL as aT,JL as aU,XL as aV,bO as aW,vb as aX,ZO as aY,YO as aZ,Lx as a_,Ln as aa,Vn as ab,Z as ac,Et as ad,xt as ae,qr as af,st as ag,Cu as ah,Ze as ai,je as aj,be as ak,Ho as al,pn as am,lt as an,te as ao,xa as ap,Hn as aq,ya as ar,Rr as as,ba as at,K_ as au,W_ as av,Ci as aw,Au as ax,Mo as ay,Pe as az,Z_ as b,J1 as b$,kt as b0,ou as b1,C_ as b2,ga as b3,pa as b4,ea as b5,ae as b6,yN as b7,UM as b8,CL as b9,s$ as bA,tt as bB,_b as bC,ku as bD,dr as bE,i1 as bF,kN as bG,GA as bH,TN as bI,ON as bJ,xr as bK,j_ as bL,X_ as bM,US as bN,zS as bO,ZN as bP,e2 as bQ,l2 as bR,ZA as bS,jr as bT,Bx as bU,Ao as bV,Uo as bW,wi as bX,ss as bY,Wl as bZ,ac as b_,hL as ba,KA as bb,UA as bc,HA as bd,VA as be,YM as bf,iM as bg,QA as bh,Yi as bi,cs as bj,$x as bk,y$ as bl,rd as bm,ju as bn,Jb as bo,hc as bp,Vg as bq,ic as br,$u as bs,xL as bt,fr as bu,Bu as bv,ni as bw,w$ as bx,fv as by,b$ as bz,Pt as c,vu as c$,q1 as c0,_L as c1,Go as c2,jA as c3,FA as c4,BA as c5,qu as c6,O0 as c7,yb as c8,Kg as c9,ad as cA,z_ as cB,AS as cC,RS as cD,qL as cE,Fr as cF,Ar as cG,Vx as cH,Q_ as cI,a$ as cJ,xc as cK,wc as cL,GL as cM,pO as cN,zx as cO,uO as cP,hO as cQ,yO as cR,xN as cS,Fm as cT,Vo as cU,Ba as cV,Fa as cW,cM as cX,f2 as cY,Yx as cZ,Su as c_,eM as ca,Yn as cb,dL as cc,oM as cd,es as ce,Jx as cf,Cb as cg,Sa as ch,Ca as ci,qi as cj,od as ck,id as cl,nd as cm,nM as cn,Ys as co,ys as cp,WL as cq,VL as cr,ka as cs,HL as ct,ws as cu,sd as cv,B_ as cw,MS as cx,sM as cy,Xs as cz,Lu as d,ob as d$,$0 as d0,Rs as d1,fi as d2,u2 as d3,$1 as d4,PA as d5,WA as d6,XA as d7,g1 as d8,zA as d9,C1 as dA,E0 as dB,Yo as dC,FN as dD,_m as dE,hm as dF,Qf as dG,d1 as dH,j1 as dI,L1 as dJ,r1 as dK,KM as dL,Ph as dM,Px as dN,ki as dO,tm as dP,Qu as dQ,HN as dR,A1 as dS,x1 as dT,Qm as dU,As as dV,hl as dW,c1 as dX,i$ as dY,el as dZ,Dn as d_,JA as da,YA as db,gm as dc,Bh as dd,zm as de,L0 as df,Y_ as dg,V_ as dh,q_ as di,pr as dj,LM as dk,Gg as dl,xm as dm,uM as dn,mb as dp,ZM as dq,Kl as dr,g2 as ds,SL as dt,Zn as du,jm as dv,wN as dw,Dx as dx,Ua as dy,F1 as dz,xi as e,Sb as e$,ub as e0,ab as e1,ib as e2,db as e3,tb as e4,nb as e5,Ug as e6,rb as e7,cb as e8,lb as e9,$N as eA,X1 as eB,t$ as eC,wm as eD,Gs as eE,_1 as eF,Y1 as eG,gv as eH,_v as eI,Mu as eJ,w1 as eK,$h as eL,KL as eM,gL as eN,jN as eO,KS as eP,Gu as eQ,S1 as eR,wo as eS,BN as eT,U1 as eU,Ub as eV,Uu as eW,XS as eX,bb as eY,rM as eZ,F_ as e_,fb as ea,bc as eb,XM as ec,Ei as ed,sb as ee,hv as ef,zN as eg,M1 as eh,zb as ei,Kb as ej,Hb as ek,vi as el,Zf as em,BM as en,FM as eo,JS as ep,Hi as eq,YL as er,jM as es,Rf as et,HS as eu,ms as ev,mm as ew,dm as ex,o$ as ey,pl as ez,$r as f,h1 as f0,Zu as f1,n$ as f2,r$ as f3,T1 as f4,WN as f5,Vu as f6,DN as f7,D2 as f8,lM as f9,d$ as fA,f$ as fB,p$ as fC,g$ as fD,wp as fE,K1 as fa,uc as fb,cr as fc,ed as fd,Wb as fe,Ux as ff,e_ as fg,Um as fh,R0 as fi,Yu as fj,A0 as fk,Xo as fl,M0 as fm,D0 as fn,qm as fo,j0 as fp,U0 as fq,qM as fr,JN as fs,UN as ft,PN as fu,P2 as fv,uA as fw,Sp as fx,vp as fy,u$ as fz,Os as g,Pm as h,bN as i,EM as j,WM as k,HM as l,l$ as m,_$ as n,c$ as o,h$ as p,IL as q,QN as r,QM as s,VM as t,x$ as u,h2 as v,m$ as w,Hr as x,_u as y,qx as z};