ocean-brain 0.8.2 → 0.11.0

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 (244) hide show
  1. package/README.md +2 -0
  2. package/dist/mcp.js +103 -105
  3. package/package.json +3 -2
  4. package/server/client/dist/assets/{ArrowRight.es-g2YZTklZ.js → ArrowRight.es-BEhnlwfe.js} +1 -1
  5. package/server/client/dist/assets/AuxiliaryPanelHeader-B1k7pZpn.js +1 -0
  6. package/server/client/dist/assets/Calendar-D7QJsAlg.js +25 -0
  7. package/server/client/dist/assets/{Callout-B_IPSF_5.js → Callout-BTd1BYtV.js} +1 -1
  8. package/server/client/dist/assets/{Copy.es-CNxe4ujr.js → Copy.es-BoLjilxv.js} +1 -1
  9. package/server/client/dist/assets/File.es-Ct7fscBg.js +1 -0
  10. package/server/client/dist/assets/Graph-DYUb7gQb.js +46 -0
  11. package/server/client/dist/assets/{Graph-D9GeO71k.js → Graph-LY_IgMYy.js} +1 -1
  12. package/server/client/dist/assets/{Image.es-DnON8cv2.js → Image.es-OYyN3BYt.js} +1 -1
  13. package/server/client/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  14. package/server/client/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  15. package/server/client/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  16. package/server/client/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  17. package/server/client/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  18. package/server/client/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  19. package/server/client/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  20. package/server/client/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  21. package/server/client/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  22. package/server/client/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  23. package/server/client/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  24. package/server/client/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  25. package/server/client/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  26. package/server/client/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  27. package/server/client/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  28. package/server/client/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  29. package/server/client/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  30. package/server/client/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  31. package/server/client/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  32. package/server/client/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  33. package/server/client/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  34. package/server/client/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  35. package/server/client/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  36. package/server/client/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  37. package/server/client/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  38. package/server/client/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  39. package/server/client/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  40. package/server/client/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  41. package/server/client/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  42. package/server/client/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  43. package/server/client/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  44. package/server/client/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  45. package/server/client/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  46. package/server/client/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  47. package/server/client/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  48. package/server/client/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  49. package/server/client/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  50. package/server/client/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  51. package/server/client/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  52. package/server/client/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  53. package/server/client/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  54. package/server/client/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  55. package/server/client/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  56. package/server/client/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  57. package/server/client/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  58. package/server/client/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  59. package/server/client/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  60. package/server/client/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  61. package/server/client/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  62. package/server/client/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  63. package/server/client/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  64. package/server/client/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  65. package/server/client/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  66. package/server/client/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  67. package/server/client/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  68. package/server/client/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  69. package/server/client/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  70. package/server/client/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  71. package/server/client/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  72. package/server/client/dist/assets/Note-DsMhwrHw.js +25 -0
  73. package/server/client/dist/assets/NotePropertiesPanel-aCKXAe5F.js +2 -0
  74. package/server/client/dist/assets/PencilLine.es-0JpEgxFY.js +1 -0
  75. package/server/client/dist/assets/{Plus.es-CQ8wn2is.js → Plus.es-DRfLW_bI.js} +1 -1
  76. package/server/client/dist/assets/Reminders-COr1OHvF.js +1 -0
  77. package/server/client/dist/assets/Search-Ctkx0BQk.js +31 -0
  78. package/server/client/dist/assets/SurfaceCard-t7pdfhEe.js +1 -0
  79. package/server/client/dist/assets/Tag-BjxtrIQW.js +1 -0
  80. package/server/client/dist/assets/TagNotes-DV_fdRbg.js +1 -0
  81. package/server/client/dist/assets/{Trash.es-0aPpA-3S.js → Trash.es-Bo1VyK9Q.js} +1 -1
  82. package/server/client/dist/assets/ViewChip-DlCkL4z4.js +1 -0
  83. package/server/client/dist/assets/ViewNotes-wWWeFJyU.js +1 -0
  84. package/server/client/dist/assets/ViewSectionDialog-DhH8harC.js +102 -0
  85. package/server/client/dist/assets/Views-CWE99SnI.js +1 -0
  86. package/server/client/dist/assets/abnfDiagram-VRR7QNED-CWlV5dXw.js +1 -0
  87. package/server/client/dist/assets/app-B9WZRrAH.css +1 -0
  88. package/server/client/dist/assets/app-BpSMjzET.js +26 -0
  89. package/server/client/dist/assets/arc-BV-n6RUX.js +1 -0
  90. package/server/client/dist/assets/architectureDiagram-ZJ3FMSHR-CekzMXdu.js +36 -0
  91. package/server/client/dist/assets/blockDiagram-677ZJIJ3-B49yHoxq.js +132 -0
  92. package/server/client/dist/assets/c4Diagram-LMCZKHZV-0AfB9NBC.js +10 -0
  93. package/server/client/dist/assets/channel-CigOulR-.js +1 -0
  94. package/server/client/dist/assets/chunk-2Q5K7J3B-DaPQAU1q.js +1 -0
  95. package/server/client/dist/assets/chunk-32BRIVSS-CfL3kZAg.js +1 -0
  96. package/server/client/dist/assets/chunk-5VM5RSS4-DeOwWPE_.js +15 -0
  97. package/server/client/dist/assets/chunk-EX3LRPZG-C3W1oc9y.js +231 -0
  98. package/server/client/dist/assets/chunk-JWPE2WC7-_Oqh79OY.js +1 -0
  99. package/server/client/dist/assets/chunk-MOJQB5TN-DDKNNzI6.js +88 -0
  100. package/server/client/dist/assets/chunk-RYQCIY6F-DCHah7CC.js +1 -0
  101. package/server/client/dist/assets/chunk-V7JOEXUC-uUOIzgxj.js +206 -0
  102. package/server/client/dist/assets/chunk-VR4S4FIN-DDVw2WPs.js +1 -0
  103. package/server/client/dist/assets/chunk-XXDRQBXY-Coo4UFm2.js +1 -0
  104. package/server/client/dist/assets/classDiagram-OUVF2IWQ-D13ISIOW.js +1 -0
  105. package/server/client/dist/assets/classDiagram-v2-EOCWNBFH-D13ISIOW.js +1 -0
  106. package/server/client/dist/assets/colors-Cc3OSVma.js +1 -0
  107. package/server/client/dist/assets/cose-bilkent-JH36ORCC-C3pHmHpD.js +1 -0
  108. package/server/client/dist/assets/cynefin-VYW2F7L2-DU_G4Atc.js +166 -0
  109. package/server/client/dist/assets/cynefinDiagram-TSTJHNR4-DZ6iiJFo.js +62 -0
  110. package/server/client/dist/assets/cytoscape.esm-D3_iZ_3b.js +321 -0
  111. package/server/client/dist/assets/dagre-VKFMJZFB-DNELbhwC.js +4 -0
  112. package/server/client/dist/assets/defaultLocale-DX6XiGOO.js +1 -0
  113. package/server/client/dist/assets/diagram-FQU43EPY-CMEvZJ61.js +3 -0
  114. package/server/client/dist/assets/diagram-G47NLZAW-BYDtf6j9.js +24 -0
  115. package/server/client/dist/assets/diagram-NH7WQ7WH-CmXfcCQA.js +24 -0
  116. package/server/client/dist/assets/diagram-OA4YK3LP-BflTKJxU.js +30 -0
  117. package/server/client/dist/assets/diagram-WEI45ONY-KW3fKqna.js +41 -0
  118. package/server/client/dist/assets/ebnfDiagram-CCIWWBDH-CbyhY5Nj.js +1 -0
  119. package/server/client/dist/assets/erDiagram-Q63AITRT-CC2eZV8g.js +85 -0
  120. package/server/client/dist/assets/{floating-ui.react-dom-wWLZ1CdM.js → floating-ui.react-dom-BWTnA00G.js} +1 -1
  121. package/server/client/dist/assets/flowDiagram-23GEKE2U-unplo7Qm.js +156 -0
  122. package/server/client/dist/assets/ganttDiagram-NO4QXBWP-BcBK5HcZ.js +292 -0
  123. package/server/client/dist/assets/gitGraphDiagram-IHSO6WYX-DgVbbb5k.js +106 -0
  124. package/server/client/dist/assets/graph-C5DFNLrC.js +1 -0
  125. package/server/client/dist/assets/image-delete-confirmation-D7xrODQV.js +1 -0
  126. package/server/client/dist/assets/image.api-CyQisInP.js +17 -0
  127. package/server/client/dist/assets/index-B-E1Ilh9.js +1 -0
  128. package/server/client/dist/assets/infoDiagram-FWYZ7A6U-N_D9RdfG.js +2 -0
  129. package/server/client/dist/assets/init-Gi6I4Gst.js +1 -0
  130. package/server/client/dist/assets/isObject-U9U2HXiq.js +1 -0
  131. package/server/client/dist/assets/ishikawaDiagram-FXEZZL3T-BBKrzmB2.js +70 -0
  132. package/server/client/dist/assets/journeyDiagram-5HDEW3XC-NdCxLmQB.js +139 -0
  133. package/server/client/dist/assets/kanban-definition-HUTT4EX6-Ck7t4-tt.js +89 -0
  134. package/server/client/dist/assets/katex-DywYRkvg.css +1 -0
  135. package/server/client/dist/assets/katex-HP8lGamR.js +257 -0
  136. package/server/client/dist/assets/katex-x288kqHd.js +257 -0
  137. package/server/client/dist/assets/layout-Cz0MDlGi.js +1 -0
  138. package/server/client/dist/assets/linear-D6yRgDLq.js +1 -0
  139. package/server/client/dist/assets/manage-image-azmo5iVw.js +1 -0
  140. package/server/client/dist/assets/manage-image-detail-BF-uSqb_.js +1 -0
  141. package/server/client/dist/assets/map-Mm1V-_Na.js +1 -0
  142. package/server/client/dist/assets/{mcp-CT_9IV2c.js → mcp-CCaFd0zm.js} +4 -4
  143. package/server/client/dist/assets/{mcp-admin-adapter-xAuyZc_M.js → mcp-admin-adapter-PMmgPupc.js} +1 -1
  144. package/server/client/dist/assets/mermaid.core-B14ZAmWA.js +308 -0
  145. package/server/client/dist/assets/min-tv6RD-6E.js +1 -0
  146. package/server/client/dist/assets/mindmap-definition-LN4V7U3C-BTUqSdcP.js +96 -0
  147. package/server/client/dist/assets/{note-core-Buwzyxi7.js → note-core-DUTqUh5N.js} +2 -2
  148. package/server/client/dist/assets/{note-runtime-CPDVOFEo.js → note-runtime-zN5ddTba.js} +1 -1
  149. package/server/client/dist/assets/{note-ui-CHI-tzj-.js → note-ui-CtijppHK.js} +1 -1
  150. package/server/client/dist/assets/{note.api-D_00ZzJC.js → note.api-D3oJmG3q.js} +6 -6
  151. package/server/client/dist/assets/ordinal-Cboi1Yqb.js +1 -0
  152. package/server/client/dist/assets/pegDiagram-2B236MQR-Cjcu3mVz.js +1 -0
  153. package/server/client/dist/assets/pieDiagram-ENE6RG2P-BxI_c22Z.js +39 -0
  154. package/server/client/dist/assets/{placeholder-DbdGiYGL.js → placeholder-AusSo8p9.js} +4 -4
  155. package/server/client/dist/assets/properties-BrNJLkxR.js +1 -0
  156. package/server/client/dist/assets/quadrantDiagram-ABIIQ3AL-DGm0a-yR.js +7 -0
  157. package/server/client/dist/assets/railroadDiagram-RFXS5EU6-DmCDu89O.js +1 -0
  158. package/server/client/dist/assets/requirementDiagram-TGXJPOKE-CBpUt7Ig.js +84 -0
  159. package/server/client/dist/assets/route-preload.js +2 -2
  160. package/server/client/dist/assets/sankeyDiagram-HTMAVEWB-BjGnDZlp.js +40 -0
  161. package/server/client/dist/assets/search-D-xKTPdO.js +1 -0
  162. package/server/client/dist/assets/search-admin-adapter-CJnJmL6w.js +1 -0
  163. package/server/client/dist/assets/sequenceDiagram-DBY2YBRQ-B7rpCfS6.js +162 -0
  164. package/server/client/dist/assets/sizeCapture-X5ZJPWSS-CUJhD0uW.js +1 -0
  165. package/server/client/dist/assets/stateDiagram-2N3HPSRC-Y9-3XqRX.js +1 -0
  166. package/server/client/dist/assets/stateDiagram-v2-6OUMAXLB-DbHXhT02.js +1 -0
  167. package/server/client/dist/assets/swimlanes-5IMT3BWC-Cs1NO9ng.js +2 -0
  168. package/server/client/dist/assets/swimlanesDiagram-G3AALYLV-DQnrq2ZC.js +8 -0
  169. package/server/client/dist/assets/{tag.api-CX0SE06J.js → tag.api-DNSQpqwk.js} +3 -3
  170. package/server/client/dist/assets/time-D5LRMumI.js +9 -0
  171. package/server/client/dist/assets/timeline-definition-FHXFAJF6-8fqD4WNL.js +120 -0
  172. package/server/client/dist/assets/toNumber-DE3J3kMD.js +1 -0
  173. package/server/client/dist/assets/transform-BUB79_za.js +1 -0
  174. package/server/client/dist/assets/trash-D4-9sv8q.js +1 -0
  175. package/server/client/dist/assets/url-9nrbQs7Z.js +1 -0
  176. package/server/client/dist/assets/{useReminderMutate-CLK1tHvT.js → useReminderMutate-BrGO9M0o.js} +4 -4
  177. package/server/client/dist/assets/vennDiagram-L72KCM5P-BPqKkd5a.js +34 -0
  178. package/server/client/dist/assets/wardleyDiagram-EHGQE667-Cq11kU2M.js +78 -0
  179. package/server/client/dist/assets/xychartDiagram-FW5EYKEG-DJ6UzFj-.js +7 -0
  180. package/server/client/dist/index.html +7 -7
  181. package/server/dist/features/image/services/delete.js +25 -1
  182. package/server/dist/features/note/graphql/note.field.resolver.js +2 -0
  183. package/server/dist/features/note/graphql/note.mutation.resolver.js +54 -23
  184. package/server/dist/features/note/graphql/note.query.resolver.js +15 -5
  185. package/server/dist/features/note/graphql/note.type-defs.js +2 -1
  186. package/server/dist/features/note/http/mcp.js +1 -60
  187. package/server/dist/features/note/services/authoring.js +17 -80
  188. package/server/dist/features/note/services/markdown-patch.js +80 -8
  189. package/server/dist/features/note/services/note-reference-index.js +98 -0
  190. package/server/dist/features/note/services/properties.js +21 -1
  191. package/server/dist/features/note/services/property-restore.js +26 -0
  192. package/server/dist/features/note/services/search.js +5 -0
  193. package/server/dist/features/note/services/snapshot.js +82 -58
  194. package/server/dist/features/note/services/trash.js +18 -31
  195. package/server/dist/features/note/services/write.js +10 -3
  196. package/server/dist/features/search/embedding-api-key-store.js +57 -0
  197. package/server/dist/features/search/embedding-client.js +179 -0
  198. package/server/dist/features/search/graphql/index.js +6 -0
  199. package/server/dist/features/search/graphql/resolver.js +32 -0
  200. package/server/dist/features/search/graphql/type-defs.js +37 -0
  201. package/server/dist/features/search/http/handlers.js +108 -0
  202. package/server/dist/features/search/hybrid-ranking.js +57 -0
  203. package/server/dist/features/search/hybrid-search.js +176 -0
  204. package/server/dist/features/search/note-change.js +16 -0
  205. package/server/dist/features/search/note-chunking.js +75 -0
  206. package/server/dist/features/search/related-notes.js +186 -0
  207. package/server/dist/features/search/search-config.js +150 -0
  208. package/server/dist/features/search/search-manager.js +431 -0
  209. package/server/dist/features/search/semantic-indexer.js +138 -0
  210. package/server/dist/features/search/sqlite-vector-index.js +636 -0
  211. package/server/dist/features/search/url-normalization.js +10 -0
  212. package/server/dist/features/tag/services/organization.js +3 -0
  213. package/server/dist/features/view/services/workspace.js +1 -1
  214. package/server/dist/main.js +12 -3
  215. package/server/dist/modules/blocknote.js +4 -5
  216. package/server/dist/paths.js +7 -2
  217. package/server/dist/routes/api.js +37 -0
  218. package/server/dist/routes/mcp.js +0 -5
  219. package/server/dist/schema/index.js +3 -0
  220. package/server/prisma/migrations/20260728090000_0019_note_reference_index/migration.sql +15 -0
  221. package/server/prisma/schema.prisma +16 -0
  222. package/server/client/dist/assets/Calendar-BP6HTuSn.js +0 -25
  223. package/server/client/dist/assets/Graph-Xha3fwhp.js +0 -46
  224. package/server/client/dist/assets/Image-BLEjLUqd.js +0 -1
  225. package/server/client/dist/assets/Note-DjrCYtat.js +0 -24
  226. package/server/client/dist/assets/NotePropertiesPanel-2DgXEM4B.js +0 -2
  227. package/server/client/dist/assets/Reminders-B4l3KdlK.js +0 -1
  228. package/server/client/dist/assets/Search-BN5sf7bE.js +0 -1
  229. package/server/client/dist/assets/SurfaceCard-BZm73nyS.js +0 -1
  230. package/server/client/dist/assets/Tag-oSnmViVp.js +0 -1
  231. package/server/client/dist/assets/TagNotes-BDTCcJcL.js +0 -1
  232. package/server/client/dist/assets/ViewNotes-CiZtGJNE.js +0 -1
  233. package/server/client/dist/assets/ViewSectionDialog-Ctl_694Y.js +0 -102
  234. package/server/client/dist/assets/Views-D-zlatYD.js +0 -1
  235. package/server/client/dist/assets/app-DmqIOMWF.css +0 -1
  236. package/server/client/dist/assets/app-cTRcKMGc.js +0 -26
  237. package/server/client/dist/assets/image.api-CVuuvTBk.js +0 -17
  238. package/server/client/dist/assets/index-DKJChPr4.js +0 -1
  239. package/server/client/dist/assets/manage-image-BZjaxp-f.js +0 -1
  240. package/server/client/dist/assets/manage-image-detail-DPv0FQ2m.js +0 -1
  241. package/server/client/dist/assets/properties-D447wsWk.js +0 -1
  242. package/server/client/dist/assets/time-B3pt8vt4.js +0 -9
  243. package/server/client/dist/assets/trash-8sH7EZgc.js +0 -1
  244. package/server/client/dist/assets/url-BSnWpmJx.js +0 -1
@@ -1,4 +1,4 @@
1
- import{g as yp,r as C,R as mc,a as za,j as O,w as wA,b as St,c as kA,d as NE,e as Pr,u as AA,f as Kl,h as eh,o as IE,i as vA,k as mu,s as Ep,l as q0,m as Yo,n as RE,p as _A}from"./floating-ui.react-dom-wWLZ1CdM.js";const xs=new WeakMap,Gl=new WeakMap,gu={current:[]};let Af=!1;const ml=new Set,Y0=new Map;function ME(t){const e=Array.from(t).sort((n,r)=>n instanceof Ss&&n.options.deps.includes(r)?1:r instanceof Ss&&r.options.deps.includes(n)?-1:0);for(const n of e){if(gu.current.includes(n))continue;gu.current.push(n),n.recompute();const r=Gl.get(n);if(r)for(const i of r){const s=xs.get(i);s&&ME(s)}}}function NA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function IA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function RA(t){if(ml.add(t),!Af)try{for(Af=!0;ml.size>0;){const e=Array.from(ml);ml.clear();for(const n of e){const r=Y0.get(n)??n.prevState;n.prevState=r,NA(n)}for(const n of e){const r=xs.get(n);r&&(gu.current.push(n),ME(r))}for(const n of e){const r=xs.get(n);if(r)for(const i of r)IA(i)}}}finally{Af=!1,gu.current=[],Y0.clear()}}function MA(t){return typeof t=="function"}class K0{constructor(e,n){this.listeners=new Set,this.subscribe=r=>{var i,s;this.listeners.add(r);const o=(s=(i=this.options)==null?void 0:i.onSubscribe)==null?void 0:s.call(i,r,this);return()=>{this.listeners.delete(r),o?.()}},this.prevState=e,this.state=e,this.options=n}setState(e){var n,r,i;this.prevState=this.state,(n=this.options)!=null&&n.updateFn?this.state=this.options.updateFn(this.prevState)(e):MA(e)?this.state=e(this.prevState):this.state=e,(i=(r=this.options)==null?void 0:r.onUpdate)==null||i.call(r),RA(this)}}class Ss{constructor(e){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const n=this.options.deps.length,r=new Array(n),i=new Array(n);for(let s=0;s<n;s++){const o=this.options.deps[s];r[s]=o.prevState,i[s]=o.state}return this.lastSeenDepValues=i,{prevDepVals:r,currDepVals:i,prevVal:this.prevState??void 0}},this.recompute=()=>{var n,r;this.prevState=this.state;const i=this.getDepVals();this.state=this.options.fn(i),(r=(n=this.options).onUpdate)==null||r.call(n)},this.checkIfRecalculationNeededDeeply=()=>{for(const s of this.options.deps)s instanceof Ss&&s.checkIfRecalculationNeededDeeply();let n=!1;const r=this.lastSeenDepValues,{currDepVals:i}=this.getDepVals();for(let s=0;s<i.length;s++)if(i[s]!==r[s]){n=!0;break}n&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const n of this._subscriptions)n()}),this.subscribe=n=>{var r,i;this.listeners.add(n);const s=(i=(r=this.options).onSubscribe)==null?void 0:i.call(r,n,this);return()=>{this.listeners.delete(n),s?.()}},this.options=e,this.state=e.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(e=this.options.deps){for(const n of e)if(n instanceof Ss)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof K0){let r=xs.get(n);r||(r=new Set,xs.set(n,r)),r.add(this);let i=Gl.get(this);i||(i=new Set,Gl.set(this,i)),i.add(n)}}unregisterFromGraph(e=this.options.deps){for(const n of e)if(n instanceof Ss)this.unregisterFromGraph(n.options.deps);else if(n instanceof K0){const r=xs.get(n);r&&r.delete(this);const i=Gl.get(this);i&&i.delete(n)}}}function Et(t){this.content=t}Et.prototype={constructor:Et,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Et(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Et(n)},addToStart:function(t,e){return new Et([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Et(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Et(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Et.from(t),t.size?new Et(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Et.from(t),t.size?new Et(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Et.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Et.from=function(t){if(t instanceof Et)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Et(e)};function OE(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=OE(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function DE(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let u=0,c=Math.min(o.text.length,a.text.length);for(;u<c&&o.text[o.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let u=DE(o.content,a.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class q{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,a=0;a<n;o++){let l=this.content[o],u=a+l.nodeSize;if(u>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new q(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new q(r,i)}cutByIndex(e,n){return e==n?q.empty:e==0&&n==this.content.length?this:new q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new q(i,s)}addToStart(e){return new q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return OE(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return DE(this,e,n,r)}findIndex(e){if(e==0)return gl(0,e);if(e==this.size)return gl(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?gl(n+1,s):gl(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return q.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return q.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new q(n||e,r)}static from(e){if(!e)return q.empty;if(e instanceof q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new q([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}q.empty=new q([],0);const vf={index:0,offset:0};function gl(t,e){return vf.index=t,vf.offset=e,vf}function bu(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!bu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!bu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let He=class th{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&bu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return th.none;if(e instanceof th)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};He.none=[];class yu extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=PE(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(LE(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(q.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(q.empty,0,0);function LE(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(LE(s.content,e-i-1,n-i-1)))}function PE(t,e,n,r,i,s){let{index:o,offset:a}=t.findIndex(e),l=t.maybeChild(o);if(a==e||l.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let u=PE(l.content,e-a-1,n,o==0?r-1:0,o==t.childCount-1?i-1:0,l);return u&&t.replaceChild(o,l.copy(u))}function OA(t,e,n){if(n.openStart>t.depth)throw new yu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new yu("Inconsistent open depths");return BE(t,e,n,0)}function BE(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=BE(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return Ii(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=DA(n,t);return Ii(s,HE(t,o,a,e,r))}else return Ii(s,Eu(t,e,r))}function FE(t,e){if(!e.type.compatibleContent(t.type))throw new yu("Cannot join "+e.type.name+" onto "+t.type.name)}function nh(t,e,n){let r=t.node(n);return FE(r,e.node(n)),r}function Ni(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ko(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Ni(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Ni(i.child(a),r);e&&e.depth==n&&e.textOffset&&Ni(e.nodeBefore,r)}function Ii(t,e){return t.type.checkContent(e),t.copy(e)}function HE(t,e,n,r,i){let s=t.depth>i&&nh(t,e,i+1),o=r.depth>i&&nh(n,r,i+1),a=[];return Ko(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(FE(s,o),Ni(Ii(s,HE(t,e,n,r,i+1)),a)):(s&&Ni(Ii(s,Eu(t,e,i+1)),a),Ko(e,n,i,a),o&&Ni(Ii(o,Eu(n,r,i+1)),a)),Ko(r,null,i,a),new q(a)}function Eu(t,e,n){let r=[];if(Ko(null,t,n,r),t.depth>n){let i=nh(t,e,n+1);Ni(Ii(i,Eu(t,e,n+1)),r)}return Ko(e,null,n,r),new q(r)}function DA(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(q.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class da{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return He.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Tu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),u=s-l;if(r.push(o,a,i+l),!u||(o=o.child(a),o.isText))break;s=u-1,i+=l+1}return new da(n,r,s)}static resolveCached(e,n){let r=G0.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else G0.set(e,r=new LA);let i=r.elts[r.i]=da.resolve(e,n);return r.i=(r.i+1)%PA,i}}class LA{constructor(){this.elts=[],this.i=0}}const PA=12,G0=new WeakMap;class Tu{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const BA=Object.create(null);let ni=class rh{constructor(e,n,r,i=He.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||q.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&bu(this.attrs,n||e.defaultAttrs||BA)&&He.sameSet(this.marks,r||He.none)}copy(e=null){return e==this.content?this:new rh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new rh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),a=i.start(o),u=i.node(o).content.cut(i.pos-a,s.pos-a);return new ee(u,i.depth-o,s.depth-o)}replace(e,n,r){return OA(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return da.resolveCached(this,e)}resolveNoCache(e){return da.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),UE(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=q.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=He.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!He.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=q.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};ni.prototype.text=void 0;class Cu extends ni{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):UE(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Cu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Cu(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function UE(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new FA(e,n);if(r.next==null)return Pi.empty;let i=$E(r);r.next&&r.err("Unexpected trailing text");let s=WA(jA(i));return qA(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return q.from(a.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:c,next:f}=o.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=s(f,a.concat(c));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
1
+ import{g as yp,r as C,R as mc,a as za,j as O,w as wA,b as St,c as kA,d as NE,e as Pr,u as AA,f as Kl,h as eh,o as IE,i as vA,k as mu,s as Ep,l as q0,m as Yo,n as RE,p as _A}from"./floating-ui.react-dom-BWTnA00G.js";const xs=new WeakMap,Gl=new WeakMap,gu={current:[]};let Af=!1;const ml=new Set,Y0=new Map;function ME(t){const e=Array.from(t).sort((n,r)=>n instanceof Ss&&n.options.deps.includes(r)?1:r instanceof Ss&&r.options.deps.includes(n)?-1:0);for(const n of e){if(gu.current.includes(n))continue;gu.current.push(n),n.recompute();const r=Gl.get(n);if(r)for(const i of r){const s=xs.get(i);s&&ME(s)}}}function NA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function IA(t){const e={prevVal:t.prevState,currentVal:t.state};for(const n of t.listeners)n(e)}function RA(t){if(ml.add(t),!Af)try{for(Af=!0;ml.size>0;){const e=Array.from(ml);ml.clear();for(const n of e){const r=Y0.get(n)??n.prevState;n.prevState=r,NA(n)}for(const n of e){const r=xs.get(n);r&&(gu.current.push(n),ME(r))}for(const n of e){const r=xs.get(n);if(r)for(const i of r)IA(i)}}}finally{Af=!1,gu.current=[],Y0.clear()}}function MA(t){return typeof t=="function"}class K0{constructor(e,n){this.listeners=new Set,this.subscribe=r=>{var i,s;this.listeners.add(r);const o=(s=(i=this.options)==null?void 0:i.onSubscribe)==null?void 0:s.call(i,r,this);return()=>{this.listeners.delete(r),o?.()}},this.prevState=e,this.state=e,this.options=n}setState(e){var n,r,i;this.prevState=this.state,(n=this.options)!=null&&n.updateFn?this.state=this.options.updateFn(this.prevState)(e):MA(e)?this.state=e(this.prevState):this.state=e,(i=(r=this.options)==null?void 0:r.onUpdate)==null||i.call(r),RA(this)}}class Ss{constructor(e){this.listeners=new Set,this._subscriptions=[],this.lastSeenDepValues=[],this.getDepVals=()=>{const n=this.options.deps.length,r=new Array(n),i=new Array(n);for(let s=0;s<n;s++){const o=this.options.deps[s];r[s]=o.prevState,i[s]=o.state}return this.lastSeenDepValues=i,{prevDepVals:r,currDepVals:i,prevVal:this.prevState??void 0}},this.recompute=()=>{var n,r;this.prevState=this.state;const i=this.getDepVals();this.state=this.options.fn(i),(r=(n=this.options).onUpdate)==null||r.call(n)},this.checkIfRecalculationNeededDeeply=()=>{for(const s of this.options.deps)s instanceof Ss&&s.checkIfRecalculationNeededDeeply();let n=!1;const r=this.lastSeenDepValues,{currDepVals:i}=this.getDepVals();for(let s=0;s<i.length;s++)if(i[s]!==r[s]){n=!0;break}n&&this.recompute()},this.mount=()=>(this.registerOnGraph(),this.checkIfRecalculationNeededDeeply(),()=>{this.unregisterFromGraph();for(const n of this._subscriptions)n()}),this.subscribe=n=>{var r,i;this.listeners.add(n);const s=(i=(r=this.options).onSubscribe)==null?void 0:i.call(r,n,this);return()=>{this.listeners.delete(n),s?.()}},this.options=e,this.state=e.fn({prevDepVals:void 0,prevVal:void 0,currDepVals:this.getDepVals().currDepVals})}registerOnGraph(e=this.options.deps){for(const n of e)if(n instanceof Ss)n.registerOnGraph(),this.registerOnGraph(n.options.deps);else if(n instanceof K0){let r=xs.get(n);r||(r=new Set,xs.set(n,r)),r.add(this);let i=Gl.get(this);i||(i=new Set,Gl.set(this,i)),i.add(n)}}unregisterFromGraph(e=this.options.deps){for(const n of e)if(n instanceof Ss)this.unregisterFromGraph(n.options.deps);else if(n instanceof K0){const r=xs.get(n);r&&r.delete(this);const i=Gl.get(this);i&&i.delete(n)}}}function Et(t){this.content=t}Et.prototype={constructor:Et,find:function(t){for(var e=0;e<this.content.length;e+=2)if(this.content[e]===t)return e;return-1},get:function(t){var e=this.find(t);return e==-1?void 0:this.content[e+1]},update:function(t,e,n){var r=n&&n!=t?this.remove(n):this,i=r.find(t),s=r.content.slice();return i==-1?s.push(n||t,e):(s[i+1]=e,n&&(s[i]=n)),new Et(s)},remove:function(t){var e=this.find(t);if(e==-1)return this;var n=this.content.slice();return n.splice(e,2),new Et(n)},addToStart:function(t,e){return new Et([t,e].concat(this.remove(t).content))},addToEnd:function(t,e){var n=this.remove(t).content.slice();return n.push(t,e),new Et(n)},addBefore:function(t,e,n){var r=this.remove(e),i=r.content.slice(),s=r.find(t);return i.splice(s==-1?i.length:s,0,e,n),new Et(i)},forEach:function(t){for(var e=0;e<this.content.length;e+=2)t(this.content[e],this.content[e+1])},prepend:function(t){return t=Et.from(t),t.size?new Et(t.content.concat(this.subtract(t).content)):this},append:function(t){return t=Et.from(t),t.size?new Et(this.subtract(t).content.concat(t.content)):this},subtract:function(t){var e=this;t=Et.from(t);for(var n=0;n<t.content.length;n+=2)e=e.remove(t.content[n]);return e},toObject:function(){var t={};return this.forEach(function(e,n){t[e]=n}),t},get size(){return this.content.length>>1}};Et.from=function(t){if(t instanceof Et)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Et(e)};function OE(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let i=t.child(r),s=e.child(r);if(i==s){n+=i.nodeSize;continue}if(!i.sameMarkup(s))return n;if(i.isText&&i.text!=s.text){for(let o=0;i.text[o]==s.text[o];o++)n++;return n}if(i.content.size||s.content.size){let o=OE(i.content,s.content,n+1);if(o!=null)return o}n+=i.nodeSize}}function DE(t,e,n,r){for(let i=t.childCount,s=e.childCount;;){if(i==0||s==0)return i==s?null:{a:n,b:r};let o=t.child(--i),a=e.child(--s),l=o.nodeSize;if(o==a){n-=l,r-=l;continue}if(!o.sameMarkup(a))return{a:n,b:r};if(o.isText&&o.text!=a.text){let u=0,c=Math.min(o.text.length,a.text.length);for(;u<c&&o.text[o.text.length-u-1]==a.text[a.text.length-u-1];)u++,n--,r--;return{a:n,b:r}}if(o.content.size||a.content.size){let u=DE(o.content,a.content,n-1,r-1);if(u)return u}n-=l,r-=l}}class q{constructor(e,n){if(this.content=e,this.size=n||0,n==null)for(let r=0;r<e.length;r++)this.size+=e[r].nodeSize}nodesBetween(e,n,r,i=0,s){for(let o=0,a=0;a<n;o++){let l=this.content[o],u=a+l.nodeSize;if(u>e&&r(l,i+a,s||null,o)!==!1&&l.content.size){let c=a+1;l.nodesBetween(Math.max(0,e-c),Math.min(l.content.size,n-c),r,i+c)}a=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,i){let s="",o=!0;return this.nodesBetween(e,n,(a,l)=>{let u=a.isText?a.text.slice(Math.max(e,l)-l,n-l):a.isLeaf?i?typeof i=="function"?i(a):i:a.type.spec.leafText?a.type.spec.leafText(a):"":"";a.isBlock&&(a.isLeaf&&u||a.isTextblock)&&r&&(o?o=!1:s+=r),s+=u},0),s}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,i=this.content.slice(),s=0;for(n.isText&&n.sameMarkup(r)&&(i[i.length-1]=n.withText(n.text+r.text),s=1);s<e.content.length;s++)i.push(e.content[s]);return new q(i,this.size+e.size)}cut(e,n=this.size){if(e==0&&n==this.size)return this;let r=[],i=0;if(n>e)for(let s=0,o=0;o<n;s++){let a=this.content[s],l=o+a.nodeSize;l>e&&((o<e||l>n)&&(a.isText?a=a.cut(Math.max(0,e-o),Math.min(a.text.length,n-o)):a=a.cut(Math.max(0,e-o-1),Math.min(a.content.size,n-o-1))),r.push(a),i+=a.nodeSize),o=l}return new q(r,i)}cutByIndex(e,n){return e==n?q.empty:e==0&&n==this.content.length?this:new q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let i=this.content.slice(),s=this.size+n.nodeSize-r.nodeSize;return i[e]=n,new q(i,s)}addToStart(e){return new q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;n<this.content.length;n++)if(!this.content[n].eq(e.content[n]))return!1;return!0}get firstChild(){return this.content.length?this.content[0]:null}get lastChild(){return this.content.length?this.content[this.content.length-1]:null}get childCount(){return this.content.length}child(e){let n=this.content[e];if(!n)throw new RangeError("Index "+e+" out of range for "+this);return n}maybeChild(e){return this.content[e]||null}forEach(e){for(let n=0,r=0;n<this.content.length;n++){let i=this.content[n];e(i,r,n),r+=i.nodeSize}}findDiffStart(e,n=0){return OE(this,e,n)}findDiffEnd(e,n=this.size,r=e.size){return DE(this,e,n,r)}findIndex(e){if(e==0)return gl(0,e);if(e==this.size)return gl(this.content.length,e);if(e>this.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let n=0,r=0;;n++){let i=this.child(n),s=r+i.nodeSize;if(s>=e)return s==e?gl(n+1,s):gl(n,r);r=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return q.fromArray(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return q.empty;let n,r=0;for(let i=0;i<e.length;i++){let s=e[i];r+=s.nodeSize,i&&s.isText&&e[i-1].sameMarkup(s)?(n||(n=e.slice(0,i)),n[n.length-1]=s.withText(n[n.length-1].text+s.text)):n&&n.push(s)}return new q(n||e,r)}static from(e){if(!e)return q.empty;if(e instanceof q)return e;if(Array.isArray(e))return this.fromArray(e);if(e.attrs)return new q([e],e.nodeSize);throw new RangeError("Can not convert "+e+" to a Fragment"+(e.nodesBetween?" (looks like multiple versions of prosemirror-model were loaded)":""))}}q.empty=new q([],0);const vf={index:0,offset:0};function gl(t,e){return vf.index=t,vf.offset=e,vf}function bu(t,e){if(t===e)return!0;if(!(t&&typeof t=="object")||!(e&&typeof e=="object"))return!1;let n=Array.isArray(t);if(Array.isArray(e)!=n)return!1;if(n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!bu(t[r],e[r]))return!1}else{for(let r in t)if(!(r in e)||!bu(t[r],e[r]))return!1;for(let r in e)if(!(r in t))return!1}return!0}let He=class th{constructor(e,n){this.type=e,this.attrs=n}addToSet(e){let n,r=!1;for(let i=0;i<e.length;i++){let s=e[i];if(this.eq(s))return e;if(this.type.excludes(s.type))n||(n=e.slice(0,i));else{if(s.type.excludes(this.type))return e;!r&&s.type.rank>this.type.rank&&(n||(n=e.slice(0,i)),n.push(this),r=!0),n&&n.push(s)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return e.slice(0,n).concat(e.slice(n+1));return e}isInSet(e){for(let n=0;n<e.length;n++)if(this.eq(e[n]))return!0;return!1}eq(e){return this==e||this.type==e.type&&bu(this.attrs,e.attrs)}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Mark.fromJSON");let r=e.marks[n.type];if(!r)throw new RangeError(`There is no mark type ${n.type} in this schema`);let i=r.create(n.attrs);return r.checkAttrs(i.attrs),i}static sameSet(e,n){if(e==n)return!0;if(e.length!=n.length)return!1;for(let r=0;r<e.length;r++)if(!e[r].eq(n[r]))return!1;return!0}static setFrom(e){if(!e||Array.isArray(e)&&e.length==0)return th.none;if(e instanceof th)return[e];let n=e.slice();return n.sort((r,i)=>r.type.rank-i.type.rank),n}};He.none=[];class yu extends Error{}class ee{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=PE(this.content,e+this.openStart,n,this.openStart+1,this.openEnd+1);return r&&new ee(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ee(LE(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ee.empty;let r=n.openStart||0,i=n.openEnd||0;if(typeof r!="number"||typeof i!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ee(q.fromJSON(e,n.content),r,i)}static maxOpen(e,n=!0){let r=0,i=0;for(let s=e.firstChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.firstChild)r++;for(let s=e.lastChild;s&&!s.isLeaf&&(n||!s.type.spec.isolating);s=s.lastChild)i++;return new ee(e,r,i)}}ee.empty=new ee(q.empty,0,0);function LE(t,e,n){let{index:r,offset:i}=t.findIndex(e),s=t.maybeChild(r),{index:o,offset:a}=t.findIndex(n);if(i==e||s.isText){if(a!=n&&!t.child(o).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=o)throw new RangeError("Removing non-flat range");return t.replaceChild(r,s.copy(LE(s.content,e-i-1,n-i-1)))}function PE(t,e,n,r,i,s){let{index:o,offset:a}=t.findIndex(e),l=t.maybeChild(o);if(a==e||l.isText)return s&&r<=0&&i<=0&&!s.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let u=PE(l.content,e-a-1,n,o==0?r-1:0,o==t.childCount-1?i-1:0,l);return u&&t.replaceChild(o,l.copy(u))}function OA(t,e,n){if(n.openStart>t.depth)throw new yu("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new yu("Inconsistent open depths");return BE(t,e,n,0)}function BE(t,e,n,r){let i=t.index(r),s=t.node(r);if(i==e.index(r)&&r<t.depth-n.openStart){let o=BE(t,e,n,r+1);return s.copy(s.content.replaceChild(i,o))}else if(n.content.size)if(!n.openStart&&!n.openEnd&&t.depth==r&&e.depth==r){let o=t.parent,a=o.content;return Ii(o,a.cut(0,t.parentOffset).append(n.content).append(a.cut(e.parentOffset)))}else{let{start:o,end:a}=DA(n,t);return Ii(s,HE(t,o,a,e,r))}else return Ii(s,Eu(t,e,r))}function FE(t,e){if(!e.type.compatibleContent(t.type))throw new yu("Cannot join "+e.type.name+" onto "+t.type.name)}function nh(t,e,n){let r=t.node(n);return FE(r,e.node(n)),r}function Ni(t,e){let n=e.length-1;n>=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ko(t,e,n,r){let i=(e||t).node(n),s=0,o=e?e.index(n):i.childCount;t&&(s=t.index(n),t.depth>n?s++:t.textOffset&&(Ni(t.nodeAfter,r),s++));for(let a=s;a<o;a++)Ni(i.child(a),r);e&&e.depth==n&&e.textOffset&&Ni(e.nodeBefore,r)}function Ii(t,e){return t.type.checkContent(e),t.copy(e)}function HE(t,e,n,r,i){let s=t.depth>i&&nh(t,e,i+1),o=r.depth>i&&nh(n,r,i+1),a=[];return Ko(null,t,i,a),s&&o&&e.index(i)==n.index(i)?(FE(s,o),Ni(Ii(s,HE(t,e,n,r,i+1)),a)):(s&&Ni(Ii(s,Eu(t,e,i+1)),a),Ko(e,n,i,a),o&&Ni(Ii(o,Eu(n,r,i+1)),a)),Ko(r,null,i,a),new q(a)}function Eu(t,e,n){let r=[];if(Ko(null,t,n,r),t.depth>n){let i=nh(t,e,n+1);Ni(Ii(i,Eu(t,e,n+1)),r)}return Ko(e,null,n,r),new q(r)}function DA(t,e){let n=e.depth-t.openStart,i=e.node(n).copy(t.content);for(let s=n-1;s>=0;s--)i=e.node(s).copy(q.from(i));return{start:i.resolveNoCache(t.openStart+n),end:i.resolveNoCache(i.content.size-t.openEnd-n)}}class da{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],i=e.child(n);return r?e.child(n).cut(r):i}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],i=n==0?0:this.path[n*3-1]+1;for(let s=0;s<e;s++)i+=r.child(s).nodeSize;return i}marks(){let e=this.parent,n=this.index();if(e.content.size==0)return He.none;if(this.textOffset)return e.child(n).marks;let r=e.maybeChild(n-1),i=e.maybeChild(n);if(!r){let a=r;r=i,i=a}let s=r.marks;for(var o=0;o<s.length;o++)s[o].type.spec.inclusive===!1&&(!i||!s[o].isInSet(i.marks))&&(s=s[o--].removeFromSet(s));return s}marksAcross(e){let n=this.parent.maybeChild(this.index());if(!n||!n.isInline)return null;let r=n.marks,i=e.parent.maybeChild(e.index());for(var s=0;s<r.length;s++)r[s].type.spec.inclusive===!1&&(!i||!r[s].isInSet(i.marks))&&(r=r[s--].removeFromSet(r));return r}sharedDepth(e){for(let n=this.depth;n>0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos<this.pos)return e.blockRange(this);for(let r=this.depth-(this.parent.inlineContent||this.pos==e.pos?1:0);r>=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Tu(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos<this.pos?e:this}toString(){let e="";for(let n=1;n<=this.depth;n++)e+=(e?"/":"")+this.node(n).type.name+"_"+this.index(n-1);return e+":"+this.parentOffset}static resolve(e,n){if(!(n>=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],i=0,s=n;for(let o=e;;){let{index:a,offset:l}=o.content.findIndex(s),u=s-l;if(r.push(o,a,i+l),!u||(o=o.child(a),o.isText))break;s=u-1,i+=l+1}return new da(n,r,s)}static resolveCached(e,n){let r=G0.get(e);if(r)for(let s=0;s<r.elts.length;s++){let o=r.elts[s];if(o.pos==n)return o}else G0.set(e,r=new LA);let i=r.elts[r.i]=da.resolve(e,n);return r.i=(r.i+1)%PA,i}}class LA{constructor(){this.elts=[],this.i=0}}const PA=12,G0=new WeakMap;class Tu{constructor(e,n,r){this.$from=e,this.$to=n,this.depth=r}get start(){return this.$from.before(this.depth+1)}get end(){return this.$to.after(this.depth+1)}get parent(){return this.$from.node(this.depth)}get startIndex(){return this.$from.index(this.depth)}get endIndex(){return this.$to.indexAfter(this.depth)}}const BA=Object.create(null);let ni=class rh{constructor(e,n,r,i=He.none){this.type=e,this.attrs=n,this.marks=i,this.content=r||q.empty}get children(){return this.content.content}get nodeSize(){return this.isLeaf?1:2+this.content.size}get childCount(){return this.content.childCount}child(e){return this.content.child(e)}maybeChild(e){return this.content.maybeChild(e)}forEach(e){this.content.forEach(e)}nodesBetween(e,n,r,i=0){this.content.nodesBetween(e,n,r,i,this)}descendants(e){this.nodesBetween(0,this.content.size,e)}get textContent(){return this.isLeaf&&this.type.spec.leafText?this.type.spec.leafText(this):this.textBetween(0,this.content.size,"")}textBetween(e,n,r,i){return this.content.textBetween(e,n,r,i)}get firstChild(){return this.content.firstChild}get lastChild(){return this.content.lastChild}eq(e){return this==e||this.sameMarkup(e)&&this.content.eq(e.content)}sameMarkup(e){return this.hasMarkup(e.type,e.attrs,e.marks)}hasMarkup(e,n,r){return this.type==e&&bu(this.attrs,n||e.defaultAttrs||BA)&&He.sameSet(this.marks,r||He.none)}copy(e=null){return e==this.content?this:new rh(this.type,this.attrs,e,this.marks)}mark(e){return e==this.marks?this:new rh(this.type,this.attrs,this.content,e)}cut(e,n=this.content.size){return e==0&&n==this.content.size?this:this.copy(this.content.cut(e,n))}slice(e,n=this.content.size,r=!1){if(e==n)return ee.empty;let i=this.resolve(e),s=this.resolve(n),o=r?0:i.sharedDepth(n),a=i.start(o),u=i.node(o).content.cut(i.pos-a,s.pos-a);return new ee(u,i.depth-o,s.depth-o)}replace(e,n,r){return OA(this.resolve(e),this.resolve(n),r)}nodeAt(e){for(let n=this;;){let{index:r,offset:i}=n.content.findIndex(e);if(n=n.maybeChild(r),!n)return null;if(i==e||n.isText)return n;e-=i+1}}childAfter(e){let{index:n,offset:r}=this.content.findIndex(e);return{node:this.content.maybeChild(n),index:n,offset:r}}childBefore(e){if(e==0)return{node:null,index:0,offset:0};let{index:n,offset:r}=this.content.findIndex(e);if(r<e)return{node:this.content.child(n),index:n,offset:r};let i=this.content.child(n-1);return{node:i,index:n-1,offset:r-i.nodeSize}}resolve(e){return da.resolveCached(this,e)}resolveNoCache(e){return da.resolve(this,e)}rangeHasMark(e,n,r){let i=!1;return n>e&&this.nodesBetween(e,n,s=>(r.isInSet(s.marks)&&(i=!0),!i)),i}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),UE(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=q.empty,i=0,s=r.childCount){let o=this.contentMatchAt(e).matchFragment(r,i,s),a=o&&o.matchFragment(this.content,n);if(!a||!a.validEnd)return!1;for(let l=i;l<s;l++)if(!this.type.allowsMarks(r.child(l).marks))return!1;return!0}canReplaceWith(e,n,r,i){if(i&&!this.type.allowsMarks(i))return!1;let s=this.contentMatchAt(e).matchType(r),o=s&&s.matchFragment(this.content,n);return o?o.validEnd:!1}canAppend(e){return e.content.size?this.canReplace(this.childCount,this.childCount,e.content):this.type.compatibleContent(e.type)}check(){this.type.checkContent(this.content),this.type.checkAttrs(this.attrs);let e=He.none;for(let n=0;n<this.marks.length;n++){let r=this.marks[n];r.type.checkAttrs(r.attrs),e=r.addToSet(e)}if(!He.sameSet(e,this.marks))throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map(n=>n.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let i=q.fromJSON(e,n.content),s=e.nodeType(n.type).create(n.attrs,i,r);return s.type.checkAttrs(s.attrs),s}};ni.prototype.text=void 0;class Cu extends ni{constructor(e,n,r,i){if(super(e,n,null,i),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):UE(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Cu(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Cu(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function UE(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Pi{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new FA(e,n);if(r.next==null)return Pi.empty;let i=$E(r);r.next&&r.err("Unexpected trailing text");let s=WA(jA(i));return qA(s,r),s}matchType(e){for(let n=0;n<this.next.length;n++)if(this.next[n].type==e)return this.next[n].next;return null}matchFragment(e,n=0,r=e.childCount){let i=this;for(let s=n;i&&s<r;s++)i=i.matchType(e.child(s).type);return i}get inlineContent(){return this.next.length!=0&&this.next[0].type.isInline}get defaultType(){for(let e=0;e<this.next.length;e++){let{type:n}=this.next[e];if(!(n.isText||n.hasRequiredAttrs()))return n}return null}compatible(e){for(let n=0;n<this.next.length;n++)for(let r=0;r<e.next.length;r++)if(this.next[n].type==e.next[r].type)return!0;return!1}fillBefore(e,n=!1,r=0){let i=[this];function s(o,a){let l=o.matchFragment(e,r);if(l&&(!n||l.validEnd))return q.from(a.map(u=>u.createAndFill()));for(let u=0;u<o.next.length;u++){let{type:c,next:f}=o.next[u];if(!(c.isText||c.hasRequiredAttrs())&&i.indexOf(f)==-1){i.push(f);let d=s(f,a.concat(c));if(d)return d}}return null}return s(this,[])}findWrapping(e){for(let r=0;r<this.wrapCache.length;r+=2)if(this.wrapCache[r]==e)return this.wrapCache[r+1];let n=this.computeWrapping(e);return this.wrapCache.push(e,n),n}computeWrapping(e){let n=Object.create(null),r=[{match:this,type:null,via:null}];for(;r.length;){let i=r.shift(),s=i.match;if(s.matchType(e)){let o=[];for(let a=i;a.type;a=a.via)o.push(a.type);return o.reverse()}for(let o=0;o<s.next.length;o++){let{type:a,next:l}=s.next[o];!a.isLeaf&&!a.hasRequiredAttrs()&&!(a.name in n)&&(!i.type||l.validEnd)&&(r.push({match:a.contentMatch,type:a,via:i}),n[a.name]=!0)}}return null}get edgeCount(){return this.next.length}edge(e){if(e>=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let i=0;i<r.next.length;i++)e.indexOf(r.next[i].next)==-1&&n(r.next[i].next)}return n(this),e.map((r,i)=>{let s=i+(r.validEnd?"*":" ")+" ";for(let o=0;o<r.next.length;o++)s+=(o?", ":"")+r.next[o].type.name+"->"+e.indexOf(r.next[o].next);return s}).join(`
2
2
  `)}}Pi.empty=new Pi(!0);class FA{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function $E(t){let e=[];do e.push(HA(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function HA(t){let e=[];do e.push(UA(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function UA(t){let e=zA(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=$A(t,e);else break;return e}function X0(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function $A(t,e){let n=X0(t),r=n;return t.eat(",")&&(t.next!="}"?r=X0(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function VA(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let i=[];for(let s in n){let o=n[s];o.isInGroup(e)&&i.push(o)}return i.length==0&&t.err("No node type or group '"+e+"' found"),i}function zA(t){if(t.eat("(")){let e=$E(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=VA(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function jA(t){let e=[[]];return i(s(t,0),n()),e;function n(){return e.push([])-1}function r(o,a,l){let u={term:l,to:a};return e[o].push(u),u}function i(o,a){o.forEach(l=>l.to=a)}function s(o,a){if(o.type=="choice")return o.exprs.reduce((l,u)=>l.concat(s(u,a)),[]);if(o.type=="seq")for(let l=0;;l++){let u=s(o.exprs[l],a);if(l==o.exprs.length-1)return u;i(u,a=n())}else if(o.type=="star"){let l=n();return r(a,l),i(s(o.expr,l),l),[r(l)]}else if(o.type=="plus"){let l=n();return i(s(o.expr,a),l),i(s(o.expr,l),l),[r(l)]}else{if(o.type=="opt")return[r(a)].concat(s(o.expr,a));if(o.type=="range"){let l=a;for(let u=0;u<o.min;u++){let c=n();i(s(o.expr,l),c),l=c}if(o.max==-1)i(s(o.expr,l),l);else for(let u=o.min;u<o.max;u++){let c=n();r(l,c),i(s(o.expr,l),c),l=c}return[r(l)]}else{if(o.type=="name")return[r(a,void 0,o.value)];throw new Error("Unknown expr type")}}}}function VE(t,e){return e-t}function Q0(t,e){let n=[];return r(e),n.sort(VE);function r(i){let s=t[i];if(s.length==1&&!s[0].term)return r(s[0].to);n.push(i);for(let o=0;o<s.length;o++){let{term:a,to:l}=s[o];!a&&n.indexOf(l)==-1&&r(l)}}}function WA(t){let e=Object.create(null);return n(Q0(t,0));function n(r){let i=[];r.forEach(o=>{t[o].forEach(({term:a,to:l})=>{if(!a)return;let u;for(let c=0;c<i.length;c++)i[c][0]==a&&(u=i[c][1]);Q0(t,l).forEach(c=>{u||i.push([a,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let s=e[r.join(",")]=new Pi(r.indexOf(t.length-1)>-1);for(let o=0;o<i.length;o++){let a=i[o][1].sort(VE);s.next.push({type:i[o][0],next:e[a.join(",")]||n(a)})}return s}}function qA(t,e){for(let n=0,r=[t];n<r.length;n++){let i=r[n],s=!i.validEnd,o=[];for(let a=0;a<i.next.length;a++){let{type:l,next:u}=i.next[a];o.push(l.name),s&&!(l.isText||l.hasRequiredAttrs())&&(s=!1),r.indexOf(u)==-1&&r.push(u)}s&&e.err("Only non-generatable nodes ("+o.join(", ")+") in a required position (see https://prosemirror.net/docs/guide/#generatable)")}}function zE(t){let e=Object.create(null);for(let n in t){let r=t[n];if(!r.hasDefault)return null;e[n]=r.default}return e}function jE(t,e){let n=Object.create(null);for(let r in t){let i=e&&e[r];if(i===void 0){let s=t[r];if(s.hasDefault)i=s.default;else throw new RangeError("No value supplied for attribute "+r)}n[r]=i}return n}function WE(t,e,n,r){for(let i in e)if(!(i in t))throw new RangeError(`Unsupported attribute ${i} for ${n} of type ${i}`);for(let i in t){let s=t[i];s.validate&&s.validate(e[i])}}function qE(t,e){let n=Object.create(null);if(e)for(let r in e)n[r]=new KA(t,r,e[r]);return n}let Z0=class YE{constructor(e,n,r){this.name=e,this.schema=n,this.spec=r,this.markSet=null,this.groups=r.group?r.group.split(" "):[],this.attrs=qE(e,r.attrs),this.defaultAttrs=zE(this.attrs),this.contentMatch=null,this.inlineContent=null,this.isBlock=!(r.inline||e=="text"),this.isText=e=="text"}get isInline(){return!this.isBlock}get isTextblock(){return this.isBlock&&this.inlineContent}get isLeaf(){return this.contentMatch==Pi.empty}get isAtom(){return this.isLeaf||!!this.spec.atom}isInGroup(e){return this.groups.indexOf(e)>-1}get whitespace(){return this.spec.whitespace||(this.spec.code?"pre":"normal")}hasRequiredAttrs(){for(let e in this.attrs)if(this.attrs[e].isRequired)return!0;return!1}compatibleContent(e){return this==e||this.contentMatch.compatible(e.contentMatch)}computeAttrs(e){return!e&&this.defaultAttrs?this.defaultAttrs:jE(this.attrs,e)}create(e=null,n,r){if(this.isText)throw new Error("NodeType.create can't construct text nodes");return new ni(this,this.computeAttrs(e),q.from(n),He.setFrom(r))}createChecked(e=null,n,r){return n=q.from(n),this.checkContent(n),new ni(this,this.computeAttrs(e),n,He.setFrom(r))}createAndFill(e=null,n,r){if(e=this.computeAttrs(e),n=q.from(n),n.size){let o=this.contentMatch.fillBefore(n);if(!o)return null;n=o.append(n)}let i=this.contentMatch.matchFragment(n),s=i&&i.fillBefore(q.empty,!0);return s?new ni(this,e,n.append(s),He.setFrom(r)):null}validContent(e){let n=this.contentMatch.matchFragment(e);if(!n||!n.validEnd)return!1;for(let r=0;r<e.childCount;r++)if(!this.allowsMarks(e.child(r).marks))return!1;return!0}checkContent(e){if(!this.validContent(e))throw new RangeError(`Invalid content for node ${this.name}: ${e.toString().slice(0,50)}`)}checkAttrs(e){WE(this.attrs,e,"node",this.name)}allowsMarkType(e){return this.markSet==null||this.markSet.indexOf(e)>-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;n<e.length;n++)if(!this.allowsMarkType(e[n].type))return!1;return!0}allowedMarks(e){if(this.markSet==null)return e;let n;for(let r=0;r<e.length;r++)this.allowsMarkType(e[r].type)?n&&n.push(e[r]):n||(n=e.slice(0,r));return n?n.length?n:He.none:e}static compile(e,n){let r=Object.create(null);e.forEach((s,o)=>r[s]=new YE(s,n,o));let i=n.spec.topNode||"doc";if(!r[i])throw new RangeError("Schema is missing its top node type ('"+i+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let s in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};function YA(t,e,n){let r=n.split("|");return i=>{let s=i===null?"null":typeof i;if(r.indexOf(s)<0)throw new RangeError(`Expected value of type ${r} for attribute ${e} on type ${t}, got ${s}`)}}class KA{constructor(e,n,r){this.hasDefault=Object.prototype.hasOwnProperty.call(r,"default"),this.default=r.default,this.validate=typeof r.validate=="string"?YA(e,n,r.validate):r.validate}get isRequired(){return!this.hasDefault}}class gc{constructor(e,n,r,i){this.name=e,this.rank=n,this.schema=r,this.spec=i,this.attrs=qE(e,i.attrs),this.excluded=null;let s=zE(this.attrs);this.instance=s?new He(this,s):null}create(e=null){return!e&&this.instance?this.instance:new He(this,jE(this.attrs,e))}static compile(e,n){let r=Object.create(null),i=0;return e.forEach((s,o)=>r[s]=new gc(s,i++,n,o)),r}removeFromSet(e){for(var n=0;n<e.length;n++)e[n].type==this&&(e=e.slice(0,n).concat(e.slice(n+1)),n--);return e}isInSet(e){for(let n=0;n<e.length;n++)if(e[n].type==this)return e[n]}checkAttrs(e){WE(this.attrs,e,"mark",this.name)}excludes(e){return this.excluded.indexOf(e)>-1}}let KE=class{constructor(e){this.linebreakReplacement=null,this.cached=Object.create(null);let n=this.spec={};for(let i in e)n[i]=e[i];n.nodes=Et.from(e.nodes),n.marks=Et.from(e.marks||{}),this.nodes=Z0.compile(this.spec.nodes,this),this.marks=gc.compile(this.spec.marks,this);let r=Object.create(null);for(let i in this.nodes){if(i in this.marks)throw new RangeError(i+" can not be both a node and a mark");let s=this.nodes[i],o=s.spec.content||"",a=s.spec.marks;if(s.contentMatch=r[o]||(r[o]=Pi.parse(o,this.nodes)),s.inlineContent=s.contentMatch.inlineContent,s.spec.linebreakReplacement){if(this.linebreakReplacement)throw new RangeError("Multiple linebreak nodes defined");if(!s.isInline||!s.isLeaf)throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");this.linebreakReplacement=s}s.markSet=a=="_"?null:a?J0(this,a.split(" ")):a==""||!s.inlineContent?[]:null}for(let i in this.marks){let s=this.marks[i],o=s.spec.excludes;s.excluded=o==null?[s]:o==""?[]:J0(this,o.split(" "))}this.nodeFromJSON=i=>ni.fromJSON(this,i),this.markFromJSON=i=>He.fromJSON(this,i),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,i){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof Z0){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,i)}text(e,n){let r=this.nodes.text;return new Cu(r,r.defaultAttrs,e,He.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function J0(t,e){let n=[];for(let r=0;r<e.length;r++){let i=e[r],s=t.marks[i],o=s;if(s)n.push(s);else for(let a in t.marks){let l=t.marks[a];(i=="_"||l.spec.group&&l.spec.group.split(" ").indexOf(i)>-1)&&n.push(o=l)}if(!o)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}function GA(t){return t.tag!=null}function XA(t){return t.style!=null}let Go=class ih{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[];let r=this.matchedStyles=[];n.forEach(i=>{if(GA(i))this.tags.push(i);else if(XA(i)){let s=/[^=]*/.exec(i.style)[0];r.indexOf(s)<0&&r.push(s),this.styles.push(i)}}),this.normalizeLists=!this.tags.some(i=>{if(!/^(ul|ol)\b/.test(i.tag)||!i.node)return!1;let s=e.nodes[i.node];return s.contentMatch.matchType(s)})}parse(e,n={}){let r=new tg(this,n,!1);return r.addAll(e,He.none,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new tg(this,n,!0);return r.addAll(e,He.none,n.from,n.to),ee.maxOpen(r.finish())}matchTag(e,n,r){for(let i=r?this.tags.indexOf(r)+1:0;i<this.tags.length;i++){let s=this.tags[i];if(JA(e,s.tag)&&(s.namespace===void 0||e.namespaceURI==s.namespace)&&(!s.context||n.matchesContext(s.context))){if(s.getAttrs){let o=s.getAttrs(e);if(o===!1)continue;s.attrs=o||void 0}return s}}}matchStyle(e,n,r,i){for(let s=i?this.styles.indexOf(i)+1:0;s<this.styles.length;s++){let o=this.styles[s],a=o.style;if(!(a.indexOf(e)!=0||o.context&&!r.matchesContext(o.context)||a.length>e.length&&(a.charCodeAt(e.length)!=61||a.slice(e.length+1)!=n))){if(o.getAttrs){let l=o.getAttrs(n);if(l===!1)continue;o.attrs=l||void 0}return o}}}static schemaRules(e){let n=[];function r(i){let s=i.priority==null?50:i.priority,o=0;for(;o<n.length;o++){let a=n[o];if((a.priority==null?50:a.priority)<s)break}n.splice(o,0,i)}for(let i in e.marks){let s=e.marks[i].spec.parseDOM;s&&s.forEach(o=>{r(o=ng(o)),o.mark||o.ignore||o.clearMark||(o.mark=i)})}for(let i in e.nodes){let s=e.nodes[i].spec.parseDOM;s&&s.forEach(o=>{r(o=ng(o)),o.node||o.ignore||o.mark||(o.node=i)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new ih(e,ih.schemaRules(e)))}};const GE={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},QA={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},XE={ol:!0,ul:!0},ha=1,sh=2,Xo=4;function eg(t,e,n){return e!=null?(e?ha:0)|(e==="full"?sh:0):t&&t.whitespace=="pre"?ha|sh:n&~Xo}class bl{constructor(e,n,r,i,s,o){this.type=e,this.attrs=n,this.marks=r,this.solid=i,this.options=o,this.content=[],this.activeMarks=He.none,this.match=s||(o&Xo?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,i;return(i=r.findWrapping(e.type))?(this.match=r,i):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&ha)){let r=this.content[this.content.length-1],i;if(r&&r.isText&&(i=/[ \t\r\n\u000c]+$/.exec(r.text))){let s=r;r.text.length==i[0].length?this.content.pop():this.content[this.content.length-1]=s.withText(s.text.slice(0,s.text.length-i[0].length))}}let n=q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}inlineContext(e){return this.type?this.type.inlineContent:this.content.length?this.content[0].isInline:e.parentNode&&!GE.hasOwnProperty(e.parentNode.nodeName.toLowerCase())}}class tg{constructor(e,n,r){this.parser=e,this.options=n,this.isOpen=r,this.open=0,this.localPreserveWS=!1;let i=n.topNode,s,o=eg(null,n.preserveWhitespace,0)|(r?Xo:0);i?s=new bl(i.type,i.attrs,He.none,!0,n.topMatch||i.type.contentMatch,o):r?s=new bl(null,null,He.none,!0,null,o):s=new bl(e.schema.topNodeType,null,He.none,!0,null,o),this.nodes=[s],this.find=n.findPositions,this.needsBlock=!1}get top(){return this.nodes[this.open]}addDOM(e,n){e.nodeType==3?this.addTextNode(e,n):e.nodeType==1&&this.addElement(e,n)}addTextNode(e,n){let r=e.nodeValue,i=this.top,s=i.options&sh?"full":this.localPreserveWS||(i.options&ha)>0,{schema:o}=this.parser;if(s==="full"||i.inlineContext(e)||/[^ \t\r\n\u000c]/.test(r)){if(s)if(s==="full")r=r.replace(/\r\n?/g,`
3
3
  `);else if(o.linebreakReplacement&&/[\r\n]/.test(r)&&this.top.findWrapping(o.linebreakReplacement.create())){let a=r.split(/\r?\n|\r/);for(let l=0;l<a.length;l++)l&&this.insertNode(o.linebreakReplacement.create(),n,!0),a[l]&&this.insertNode(o.text(a[l]),n,!/\S/.test(a[l]));r=""}else r=r.replace(/\r?\n|\r/g," ");else if(r=r.replace(/[ \t\r\n\u000c]+/g," "),/^[ \t\r\n\u000c]/.test(r)&&this.open==this.nodes.length-1){let a=i.content[i.content.length-1],l=e.previousSibling;(!a||l&&l.nodeName=="BR"||a.isText&&/[ \t\r\n\u000c]$/.test(a.text))&&(r=r.slice(1))}r&&this.insertNode(o.text(r),n,!/\S/.test(r)),this.findInText(e)}else this.findInside(e)}addElement(e,n,r){let i=this.localPreserveWS,s=this.top;(e.tagName=="PRE"||/pre/.test(e.style&&e.style.whiteSpace))&&(this.localPreserveWS=!0);let o=e.nodeName.toLowerCase(),a;XE.hasOwnProperty(o)&&this.parser.normalizeLists&&ZA(e);let l=this.options.ruleFromNode&&this.options.ruleFromNode(e)||(a=this.parser.matchTag(e,this,r));e:if(l?l.ignore:QA.hasOwnProperty(o))this.findInside(e),this.ignoreFallback(e,n);else if(!l||l.skip||l.closeParent){l&&l.closeParent?this.open=Math.max(0,this.open-1):l&&l.skip.nodeType&&(e=l.skip);let u,c=this.needsBlock;if(GE.hasOwnProperty(o))s.content.length&&s.content[0].isInline&&this.open&&(this.open--,s=this.top),u=!0,s.type||(this.needsBlock=!0);else if(!e.firstChild){this.leafFallback(e,n);break e}let f=l&&l.skip?n:this.readStyles(e,n);f&&this.addAll(e,f),u&&this.sync(s),this.needsBlock=c}else{let u=this.readStyles(e,n);u&&this.addElementByRule(e,l,u,l.consuming===!1?a:void 0)}this.localPreserveWS=i}leafFallback(e,n){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
4
4
  `),n)}ignoreFallback(e,n){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"),n,!0)}readStyles(e,n){let r=e.style;if(r&&r.length)for(let i=0;i<this.parser.matchedStyles.length;i++){let s=this.parser.matchedStyles[i],o=r.getPropertyValue(s);if(o)for(let a=void 0;;){let l=this.parser.matchStyle(s,o,this,a);if(!l)break;if(l.ignore)return null;if(l.clearMark?n=n.filter(u=>!l.clearMark(u)):n=n.concat(this.parser.schema.marks[l.mark].create(l.attrs)),l.consuming===!1)a=l;else break}}return n}addElementByRule(e,n,r,i){let s,o;if(n.node)if(o=this.parser.schema.nodes[n.node],o.isLeaf)this.insertNode(o.create(n.attrs),r,e.nodeName=="BR")||this.leafFallback(e,r);else{let l=this.enter(o,n.attrs||null,r,n.preserveWhitespace);l&&(s=!0,r=l)}else{let l=this.parser.schema.marks[n.mark];r=r.concat(l.create(n.attrs))}let a=this.top;if(o&&o.isLeaf)this.findInside(e);else if(i)this.addElement(e,r,i);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(l=>this.insertNode(l,r,!1));else{let l=e;typeof n.contentElement=="string"?l=e.querySelector(n.contentElement):typeof n.contentElement=="function"?l=n.contentElement(e):n.contentElement&&(l=n.contentElement),this.findAround(e,l,!0),this.addAll(l,r),this.findAround(e,l,!1)}s&&this.sync(a)&&this.open--}addAll(e,n,r,i){let s=r||0;for(let o=r?e.childNodes[r]:e.firstChild,a=i==null?null:e.childNodes[i];o!=a;o=o.nextSibling,++s)this.findAtPoint(e,s),this.addDOM(o,n);this.findAtPoint(e,s)}findPlace(e,n,r){let i,s;for(let o=this.open,a=0;o>=0;o--){let l=this.nodes[o],u=l.findWrapping(e);if(u&&(!i||i.length>u.length+a)&&(i=u,s=l,!u.length))break;if(l.solid){if(r)break;a+=2}}if(!i)return null;this.sync(s);for(let o=0;o<i.length;o++)n=this.enterInner(i[o],null,n,!1);return n}insertNode(e,n,r){if(e.isInline&&this.needsBlock&&!this.top.type){let s=this.textblockFromContext();s&&(n=this.enterInner(s,null,n))}let i=this.findPlace(e,n,r);if(i){this.closeExtra();let s=this.top;s.match&&(s.match=s.match.matchType(e.type));let o=He.none;for(let a of i.concat(e.marks))(s.type?s.type.allowsMarkType(a.type):rg(a.type,e.type))&&(o=a.addToSet(o));return s.content.push(e.mark(o)),!0}return!1}enter(e,n,r,i){let s=this.findPlace(e.create(n),r,!1);return s&&(s=this.enterInner(e,n,r,!0,i)),s}enterInner(e,n,r,i=!1,s){this.closeExtra();let o=this.top;o.match=o.match&&o.match.matchType(e);let a=eg(e,s,o.options);o.options&Xo&&o.content.length==0&&(a|=Xo);let l=He.none;return r=r.filter(u=>(o.type?o.type.allowsMarkType(u.type):rg(u.type,e))?(l=u.addToSet(l),!1):!0),this.nodes.push(new bl(e,n,l,i,null,a)),this.open++,r}closeExtra(e=!1){let n=this.nodes.length-1;if(n>this.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(!!(this.isOpen||this.options.topOpen))}sync(e){for(let n=this.open;n>=0;n--){if(this.nodes[n]==e)return this.open=n,!0;this.localPreserveWS&&(this.nodes[n].options|=ha)}return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let i=r.length-1;i>=0;i--)e+=r[i].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r<this.find.length;r++)this.find[r].node==e&&this.find[r].offset==n&&(this.find[r].pos=this.currentPos)}findInside(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].pos==null&&e.nodeType==1&&e.contains(this.find[n].node)&&(this.find[n].pos=this.currentPos)}findAround(e,n,r){if(e!=n&&this.find)for(let i=0;i<this.find.length;i++)this.find[i].pos==null&&e.nodeType==1&&e.contains(this.find[i].node)&&n.compareDocumentPosition(this.find[i].node)&(r?2:4)&&(this.find[i].pos=this.currentPos)}findInText(e){if(this.find)for(let n=0;n<this.find.length;n++)this.find[n].node==e&&(this.find[n].pos=this.currentPos-(e.nodeValue.length-this.find[n].offset))}matchesContext(e){if(e.indexOf("|")>-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,i=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),s=-(r?r.depth+1:0)+(i?0:1),o=(a,l)=>{for(;a>=0;a--){let u=n[a];if(u==""){if(a==n.length-1||a==0)continue;for(;l>=s;l--)if(o(a-1,l))return!0;return!1}else{let c=l>0||l==0&&i?this.nodes[l].type:r&&l>=s?r.node(l-s).type:null;if(!c||c.name!=u&&!c.isInGroup(u))return!1;l--}}return!0};return o(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}}function ZA(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&XE.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function JA(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function ng(t){let e={};for(let n in t)e[n]=t[n];return e}function rg(t,e){let n=e.schema.nodes;for(let r in n){let i=n[r];if(!i.allowsMarkType(t))continue;let s=[],o=a=>{s.push(a);for(let l=0;l<a.edgeCount;l++){let{type:u,next:c}=a.edge(l);if(u==e||s.indexOf(c)<0&&o(c))return!0}};if(o(i.contentMatch))return!0}}class Ki{constructor(e,n){this.nodes=e,this.marks=n}serializeFragment(e,n={},r){r||(r=yl(n).createDocumentFragment());let i=r,s=[];return e.forEach(o=>{if(s.length||o.marks.length){let a=0,l=0;for(;a<s.length&&l<o.marks.length;){let u=o.marks[l];if(!this.marks[u.type.name]){l++;continue}if(!u.eq(s[a][0])||u.type.spec.spanning===!1)break;a++,l++}for(;a<s.length;)i=s.pop()[1];for(;l<o.marks.length;){let u=o.marks[l++],c=this.serializeMark(u,o.isInline,n);c&&(s.push([u,i]),i.appendChild(c.dom),i=c.contentDOM||c.dom)}}i.appendChild(this.serializeNodeInner(o,n))}),r}serializeNodeInner(e,n){if(e.isText)return yl(n).createTextNode(e.text);let{dom:r,contentDOM:i}=Xl(yl(n),this.nodes[e.type.name](e),null,e.attrs);if(i){if(e.isLeaf)throw new RangeError("Content hole not allowed in a leaf node spec");this.serializeFragment(e.content,n,i)}return r}serializeNode(e,n={}){let r=this.serializeNodeInner(e,n);for(let i=e.marks.length-1;i>=0;i--){let s=this.serializeMark(e.marks[i],e.isInline,n);s&&((s.contentDOM||s.dom).appendChild(r),r=s.dom)}return r}serializeMark(e,n,r={}){let i=this.marks[e.type.name];return i&&Xl(yl(r),i(e,n),null,e.attrs)}static renderSpec(e,n,r=null,i){return typeof n=="string"?{dom:e.createTextNode(n)}:Xl(e,n,r,i)}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Ki(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=ig(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return ig(e.marks)}}function ig(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function yl(t){return t.document||window.document}const sg=new WeakMap;function e3(t){let e=sg.get(t);return e===void 0&&sg.set(t,e=t3(t)),e}function t3(t){let e=null;function n(r){if(r&&typeof r=="object")if(Array.isArray(r))if(typeof r[0]=="string")e||(e=[]),e.push(r);else for(let i=0;i<r.length;i++)n(r[i]);else for(let i in r)n(r[i])}return n(t),e}function Xl(t,e,n,r){if(e.nodeType==1)return{dom:e};if(e.dom&&e.dom.nodeType==1)return e;let i=e[0],s;if(typeof i!="string")throw new RangeError("Invalid array passed to renderSpec");if(r&&(s=e3(r))&&s.indexOf(e)>-1)throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");let o=i.indexOf(" ");o>0&&(n=i.slice(0,o),i=i.slice(o+1));let a,l=n?t.createElementNS(n,i):t.createElement(i),u=e[1],c=1;if(u&&typeof u=="object"&&u.nodeType==null&&!Array.isArray(u)){c=2;for(let f in u)if(u[f]!=null){let d=f.indexOf(" ");d>0?l.setAttributeNS(f.slice(0,d),f.slice(d+1),u[f]):f=="style"&&l.style?l.style.cssText=u[f]:l.setAttribute(f,u[f])}}for(let f=c;f<e.length;f++){let d=e[f];if(d===0){if(f<e.length-1||f>c)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else if(typeof d=="string")l.appendChild(t.createTextNode(d));else{let{dom:h,contentDOM:p}=Xl(t,d,n,r);if(l.appendChild(h),p){if(a)throw new RangeError("Multiple content holes");a=p}}}return{dom:l,contentDOM:a}}const QE=65535,ZE=Math.pow(2,16);function n3(t,e){return t+e*ZE}function og(t){return t&QE}function r3(t){return(t-(t&QE))/ZE}const JE=1,e2=2,Ql=4,t2=8;class oh{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&t2)>0}get deletedBefore(){return(this.delInfo&(JE|Ql))>0}get deletedAfter(){return(this.delInfo&(e2|Ql))>0}get deletedAcross(){return(this.delInfo&Ql)>0}}class pn{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&pn.empty)return pn.empty}recover(e){let n=0,r=og(e);if(!this.inverted)for(let i=0;i<r;i++)n+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[r*3]+n+r3(e)}mapResult(e,n=1){return this._map(e,n,!1)}map(e,n=1){return this._map(e,n,!0)}_map(e,n,r){let i=0,s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?i:0);if(l>e)break;let u=this.ranges[a+s],c=this.ranges[a+o],f=l+u;if(e<=f){let d=u?e==l?-1:e==f?1:n:n,h=l+i+(d<0?0:c);if(r)return h;let p=e==(n<0?l:f)?null:n3(a/3,e-l),g=e==l?e2:e==f?JE:Ql;return(n<0?e!=l:e!=f)&&(g|=t2),new oh(h,g,p)}i+=c-u}return r?e+i:new oh(e+i,0,null)}touches(e,n){let r=0,i=og(n),s=this.inverted?2:1,o=this.inverted?1:2;for(let a=0;a<this.ranges.length;a+=3){let l=this.ranges[a]-(this.inverted?r:0);if(l>e)break;let u=this.ranges[a+s],c=l+u;if(e<=c&&a==i*3)return!0;r+=this.ranges[a+o]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let i=0,s=0;i<this.ranges.length;i+=3){let o=this.ranges[i],a=o-(this.inverted?s:0),l=o+(this.inverted?0:s),u=this.ranges[i+n],c=this.ranges[i+r];e(a,a+u,l,l+c),s+=c-u}}invert(){return new pn(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?pn.empty:new pn(e<0?[0,-e,0]:[0,0,e])}}pn.empty=new pn([]);class pa{constructor(e,n,r=0,i=e?e.length:0){this.mirror=n,this.from=r,this.to=i,this._maps=e||[],this.ownData=!(e||n)}get maps(){return this._maps}slice(e=0,n=this.maps.length){return new pa(this._maps,this.mirror,e,n)}appendMap(e,n){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),n!=null&&this.setMirror(this._maps.length-1,n)}appendMapping(e){for(let n=0,r=this._maps.length;n<e._maps.length;n++){let i=e.getMirror(n);this.appendMap(e._maps[n],i!=null&&i<n?r+i:void 0)}}getMirror(e){if(this.mirror){for(let n=0;n<this.mirror.length;n++)if(this.mirror[n]==e)return this.mirror[n+(n%2?-1:1)]}}setMirror(e,n){this.mirror||(this.mirror=[]),this.mirror.push(e,n)}appendMappingInverted(e){for(let n=e.maps.length-1,r=this._maps.length+e._maps.length;n>=0;n--){let i=e.getMirror(n);this.appendMap(e._maps[n].invert(),i!=null&&i>n?r-i-1:void 0)}}invert(){let e=new pa;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;r<this.to;r++)e=this._maps[r].map(e,n);return e}mapResult(e,n=1){return this._map(e,n,!1)}_map(e,n,r){let i=0;for(let s=this.from;s<this.to;s++){let o=this._maps[s],a=o.mapResult(e,n);if(a.recover!=null){let l=this.getMirror(s);if(l!=null&&l>s&&l<this.to){s=l,e=this._maps[l].recover(a.recover);continue}}i|=a.delInfo,e=a.pos}return r?e:new oh(e,i,null)}}const _f=Object.create(null);class Mt{getMap(){return pn.empty}merge(e){return null}static fromJSON(e,n){if(!n||!n.stepType)throw new RangeError("Invalid input for Step.fromJSON");let r=_f[n.stepType];if(!r)throw new RangeError(`No step type ${n.stepType} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in _f)throw new RangeError("Duplicate use of step JSON ID "+e);return _f[e]=n,n.prototype.jsonID=e,n}}class it{constructor(e,n){this.doc=e,this.failed=n}static ok(e){return new it(e,null)}static fail(e){return new it(null,e)}static fromReplace(e,n,r,i){try{return it.ok(e.replace(n,r,i))}catch(s){if(s instanceof yu)return it.fail(s.message);throw s}}}function Tp(t,e,n){let r=[];for(let i=0;i<t.childCount;i++){let s=t.child(i);s.content.size&&(s=s.copy(Tp(s.content,e,s))),s.isInline&&(s=e(s,n,i)),r.push(s)}return q.fromArray(r)}class Xr extends Mt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=e.resolve(this.from),i=r.node(r.sharedDepth(this.to)),s=new ee(Tp(n.content,(o,a)=>!o.isAtom||!a.type.allowsMarkType(this.mark.type)?o:o.mark(this.mark.addToSet(o.marks)),i),n.openStart,n.openEnd);return it.fromReplace(e,this.from,this.to,s)}invert(){return new Bn(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Xr(n.pos,r.pos,this.mark)}merge(e){return e instanceof Xr&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Xr(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Xr(n.from,n.to,e.markFromJSON(n.mark))}}Mt.jsonID("addMark",Xr);class Bn extends Mt{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ee(Tp(n.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),n.openStart,n.openEnd);return it.fromReplace(e,this.from,this.to,r)}invert(){return new Xr(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Bn(n.pos,r.pos,this.mark)}merge(e){return e instanceof Bn&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Bn(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Bn(n.from,n.to,e.markFromJSON(n.mark))}}Mt.jsonID("removeMark",Bn);class Qr extends Mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return it.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return it.fromReplace(e,this.pos,this.pos+1,new ee(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let i=0;i<n.marks.length;i++)if(!n.marks[i].isInSet(r))return new Qr(this.pos,n.marks[i]);return new Qr(this.pos,this.mark)}}return new Bi(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Qr(n.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Qr(n.pos,e.markFromJSON(n.mark))}}Mt.jsonID("addNodeMark",Qr);class Bi extends Mt{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return it.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.removeFromSet(n.marks));return it.fromReplace(e,this.pos,this.pos+1,new ee(q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);return!n||!this.mark.isInSet(n.marks)?this:new Qr(this.pos,this.mark)}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new Bi(n.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,n){if(typeof n.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new Bi(n.pos,e.markFromJSON(n.mark))}}Mt.jsonID("removeNodeMark",Bi);class rt extends Mt{constructor(e,n,r,i=!1){super(),this.from=e,this.to=n,this.slice=r,this.structure=i}apply(e){return this.structure&&ah(e,this.from,this.to)?it.fail("Structure replace would overwrite content"):it.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pn([this.from,this.to-this.from,this.slice.size])}invert(e){return new rt(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let n=e.mapResult(this.to,-1),r=this.from==this.to&&rt.MAP_BIAS<0?n:e.mapResult(this.from,1);return r.deletedAcross&&n.deletedAcross?null:new rt(r.pos,Math.max(r.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof rt)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new rt(this.from,this.to+(e.to-e.from),n,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let n=this.slice.size+e.slice.size==0?ee.empty:new ee(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new rt(e.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new rt(n.from,n.to,ee.fromJSON(e,n.slice),!!n.structure)}}rt.MAP_BIAS=1;Mt.jsonID("replace",rt);class pt extends Mt{constructor(e,n,r,i,s,o,a=!1){super(),this.from=e,this.to=n,this.gapFrom=r,this.gapTo=i,this.slice=s,this.insert=o,this.structure=a}apply(e){if(this.structure&&(ah(e,this.from,this.gapFrom)||ah(e,this.gapTo,this.to)))return it.fail("Structure gap-replace would overwrite content");let n=e.slice(this.gapFrom,this.gapTo);if(n.openStart||n.openEnd)return it.fail("Gap is not a flat range");let r=this.slice.insertAt(this.insert,n.content);return r?it.fromReplace(e,this.from,this.to,r):it.fail("Content does not fit in gap")}getMap(){return new pn([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let n=this.gapTo-this.gapFrom;return new pt(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:e.map(this.gapFrom,-1),s=this.to==this.gapTo?r.pos:e.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||s>r.pos?null:new pt(n.pos,r.pos,i,s,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new pt(n.from,n.to,n.gapFrom,n.gapTo,ee.fromJSON(e,n.slice),n.insert,!!n.structure)}}Mt.jsonID("replaceAround",pt);function ah(t,e,n){let r=t.resolve(e),i=n-e,s=r.depth;for(;i>0&&s>0&&r.indexAfter(s)==r.node(s).childCount;)s--,i--;if(i>0){let o=r.node(s).maybeChild(r.indexAfter(s));for(;i>0;){if(!o||o.isLeaf)return!0;o=o.firstChild,i--}}return!1}function i3(t,e,n,r){let i=[],s=[],o,a;t.doc.nodesBetween(e,n,(l,u,c)=>{if(!l.isInline)return;let f=l.marks;if(!r.isInSet(f)&&c.type.allowsMarkType(r.type)){let d=Math.max(u,e),h=Math.min(u+l.nodeSize,n),p=r.addToSet(f);for(let g=0;g<f.length;g++)f[g].isInSet(p)||(o&&o.to==d&&o.mark.eq(f[g])?o.to=h:i.push(o=new Bn(d,h,f[g])));a&&a.to==d?a.to=h:s.push(a=new Xr(d,h,r))}}),i.forEach(l=>t.step(l)),s.forEach(l=>t.step(l))}function s3(t,e,n,r){let i=[],s=0;t.doc.nodesBetween(e,n,(o,a)=>{if(!o.isInline)return;s++;let l=null;if(r instanceof gc){let u=o.marks,c;for(;c=r.isInSet(u);)(l||(l=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(o.marks)&&(l=[r]):l=o.marks;if(l&&l.length){let u=Math.min(a+o.nodeSize,n);for(let c=0;c<l.length;c++){let f=l[c],d;for(let h=0;h<i.length;h++){let p=i[h];p.step==s-1&&f.eq(i[h].style)&&(d=p)}d?(d.to=u,d.step=s):i.push({style:f,from:Math.max(a,e),to:u,step:s})}}}),i.forEach(o=>t.step(new Bn(o.from,o.to,o.style)))}function Cp(t,e,n,r=n.contentMatch,i=!0){let s=t.doc.nodeAt(e),o=[],a=e+1;for(let l=0;l<s.childCount;l++){let u=s.child(l),c=a+u.nodeSize,f=r.matchType(u.type);if(!f)o.push(new rt(a,c,ee.empty));else{r=f;for(let d=0;d<u.marks.length;d++)n.allowsMarkType(u.marks[d].type)||t.step(new Bn(a,c,u.marks[d]));if(i&&u.isText&&n.whitespace!="pre"){let d,h=/\r?\n|\r/g,p;for(;d=h.exec(u.text);)p||(p=new ee(q.from(n.schema.text(" ",n.allowedMarks(u.marks))),0,0)),o.push(new rt(a+d.index,a+d.index+d[0].length,p))}}a=c}if(!r.validEnd){let l=r.fillBefore(q.empty,!0);t.replace(a,a,new ee(l,0,0))}for(let l=o.length-1;l>=0;l--)t.step(o[l])}function o3(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function oo(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth,i=0,s=0;;--r){let o=t.$from.node(r),a=t.$from.index(r)+i,l=t.$to.indexAfter(r)-s;if(r<t.depth&&o.canReplace(a,l,n))return r;if(r==0||o.type.spec.isolating||!o3(o,a,l))break;a&&(i=1),l<o.childCount&&(s=1)}return null}function a3(t,e,n){let{$from:r,$to:i,depth:s}=e,o=r.before(s+1),a=i.after(s+1),l=o,u=a,c=q.empty,f=0;for(let p=s,g=!1;p>n;p--)g||r.index(p)>0?(g=!0,c=q.from(r.node(p).copy(c)),f++):l--;let d=q.empty,h=0;for(let p=s,g=!1;p>n;p--)g||i.after(p+1)<i.end(p)?(g=!0,d=q.from(i.node(p).copy(d)),h++):u++;t.step(new pt(l,u,o,a,new ee(c.append(d),f,h),c.size-f,!0))}function n2(t,e,n=null,r=t){let i=l3(t,e),s=i&&u3(r,e);return s?i.map(ag).concat({type:e,attrs:n}).concat(s.map(ag)):null}function ag(t){return{type:t,attrs:null}}function l3(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.contentMatchAt(r).findWrapping(e);if(!s)return null;let o=s.length?s[0]:e;return n.canReplaceWith(r,i,o)?s:null}function u3(t,e){let{parent:n,startIndex:r,endIndex:i}=t,s=n.child(r),o=e.contentMatch.findWrapping(s.type);if(!o)return null;let l=(o.length?o[o.length-1]:e).contentMatch;for(let u=r;l&&u<i;u++)l=l.matchType(n.child(u).type);return!l||!l.validEnd?null:o}function c3(t,e,n){let r=q.empty;for(let o=n.length-1;o>=0;o--){if(r.size){let a=n[o].type.contentMatch.matchFragment(r);if(!a||!a.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=q.from(n[o].type.create(n[o].attrs,r))}let i=e.start,s=e.end;t.step(new pt(i,s,i,s,new ee(r,0,0),n.length,!0))}function f3(t,e,n,r,i){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let s=t.steps.length;t.doc.nodesBetween(e,n,(o,a)=>{let l=typeof i=="function"?i(o):i;if(o.isTextblock&&!o.hasMarkup(r,l)&&d3(t.doc,t.mapping.slice(s).map(a),r)){let u=null;if(r.schema.linebreakReplacement){let h=r.whitespace=="pre",p=!!r.contentMatch.matchType(r.schema.linebreakReplacement);h&&!p?u=!1:!h&&p&&(u=!0)}u===!1&&i2(t,o,a,s),Cp(t,t.mapping.slice(s).map(a,1),r,void 0,u===null);let c=t.mapping.slice(s),f=c.map(a,1),d=c.map(a+o.nodeSize,1);return t.step(new pt(f,d,f+1,d-1,new ee(q.from(r.create(l,null,o.marks)),0,0),1,!0)),u===!0&&r2(t,o,a,s),!1}})}function r2(t,e,n,r){e.forEach((i,s)=>{if(i.isText){let o,a=/\r?\n|\r/g;for(;o=a.exec(i.text);){let l=t.mapping.slice(r).map(n+1+s+o.index);t.replaceWith(l,l+1,e.type.schema.linebreakReplacement.create())}}})}function i2(t,e,n,r){e.forEach((i,s)=>{if(i.type==i.type.schema.linebreakReplacement){let o=t.mapping.slice(r).map(n+1+s);t.replaceWith(o,o+1,e.type.schema.text(`
@@ -1,2 +1,2 @@
1
- import{r as d,j as r,w as Zt,b as pe,a as ae}from"./floating-ui.react-dom-wWLZ1CdM.js";import{$ as Xt,q as Jt,U as en,s as tn,v as B,w as R,L as nn,I as on,P as z,D as P,n as Y,Z as U,a as S,C as ge,K as ie,M as Z,b as rn,O as ln,i as be,c as D,Y as _e,V as Ge,d as an,o as sn,e as et,A as cn,x as tt,f as nt,u as dn,g as un,N as X,W as mn,T as ot,H as pn,r as $e,h as gn,j as bn,k as fn,l as hn,m as xn,F as j,p as Re}from"./note-core-Buwzyxi7.js";import{aL as vn,aM as Cn,aN as Me,aO as kn,aP as jn,aQ as wn,aR as yn,aS as Sn,aT as Tn,aU as ve,aV as _n,aW as Rn,I as En,aX as He,aY as In,aZ as Mn,a_ as Pn,a$ as Nn,b0 as Bn,b1 as A,b2 as J,b3 as ee,T as On,b4 as rt,b5 as se,b6 as Fn,b7 as Dn,b8 as Ln,b9 as An,ba as zn,bb as Gn,bc as $n,bd as Hn,be as Pe,bf as lt,bg as it,bh as at,bi as st,bj as ct,bk as ce,bl as de,bm as ue,bn as dt,bo as ut,bp as mt,bq as pt,br as Ue,bs as Un,bt as Ve,bu as Vn,bv as qn,bw as Kn,bx as Qn,by as Wn,bz as Yn,bA as Zn,bB as Xn,bC as Jn,bD as eo,bE as to,bF as no,bG as oo,bH as ro,bI as gt,bJ as bt,bK as lo,bL as io,bM as ao,bN as ft,bO as so,bP as co,bQ as uo,bR as mo,bS as po,bT as ht,bU as xt,N as go,bV as bo,bW as fo,bX as ho,bY as $,bZ as vt,b_ as xo,b$ as M,c0 as N,c1 as V,c2 as vo,c3 as Ct,c4 as Ne,c5 as kt,c6 as Co,c7 as ko,c8 as Be,c9 as jo,ca as wo,cb as yo,cc as So,cd as jt,ce as wt,cf as Oe,cg as To,ch as _o,ci as oe,cj as Ro,ck as qe,cl as Eo,cm as Io}from"./note-runtime-CPDVOFEo.js";import{_ as me}from"./preload-helper-BXl3LOEh.js";import{c as Mo}from"./time-B3pt8vt4.js";var yt=d.createContext(void 0);function O(e){return d.useContext(yt)}function v(e){let o=O();if(!o?.editor)throw Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return o.editor}function w(e,o){let t=(o?.editor??v()).getExtension(e);if(!t)throw Error("Extension not found",{cause:{plugin:e}});return t}function y(e,o){let{store:t}=w(e,o);if(!t)throw Error("Store not found on plugin",{cause:{plugin:e}});return vn(t,o?.selector)}function Po(e){let o=new DOMRect,t="getBoundingClientRect"in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(o=t()),o):t()}function No(e,o){return e?o?(t,n,l)=>{let i=e(t,n,l),s=o(t,n,l);return()=>{i?.(),s?.()}}:e:o}var L=e=>{let o=v(),t=o?.portalElement;if(!t)throw Error("Portal element not found");let{whileElementsMounted:n,...l}=e.useFloatingOptions??{},{refs:i,floatingStyles:s,context:a}=Cn({whileElementsMounted:No(Me,e.useFloatingOptions?.whileElementsMounted),...l}),{isMounted:c,styles:u}=kn(a,e.useTransitionStylesProps),{status:m}=jn(a,e.useTransitionStatusProps),{getFloatingProps:p}=wn([yn(a,e.useDismissProps),Sn(a,{enabled:!1,...e.useHoverProps})]),g=d.useRef(""),b=d.useRef(null),f=Tn([b,i.setFloating]);if(d.useEffect(()=>{if(e.reference){let C="element"in e.reference?e.reference.element:void 0;C!==void 0&&(e.focusManagerProps?.disabled||!o.isWithinEditor(C))&&i.setReference(C),i.setPositionReference({getBoundingClientRect:Po(e.reference),contextElement:C})}},[e.reference,i,e.focusManagerProps?.disabled,o]),d.useEffect(()=>{(m==="initial"||m==="open")&&b.current?.innerHTML&&(g.current=b.current.innerHTML)},[m,e.reference,e.children]),!c)return!1;let x={...e.elementProps,style:{display:"flex",...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...u},...p()};return m==="close"?r.jsx(ve,{root:t,children:r.jsx("div",{ref:f,...x,dangerouslySetInnerHTML:{__html:g.current}})}):e.focusManagerProps?.disabled?r.jsx(ve,{root:t,children:r.jsx("div",{ref:f,...x,children:e.children})}):r.jsx(ve,{root:t,children:r.jsx(_n,{...e.focusManagerProps,context:a,children:r.jsx("div",{ref:f,...x,children:e.children})})})},St=d.createContext(void 0);function h(){return d.useContext(St)}function k(){return O().editor.dictionary}var Bo=typeof window<"u"?d.useLayoutEffect:d.useEffect,Oo=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(o){this.editor=o,this.lastSnapshot={editor:o,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(o){return this.subscribers.add(o),()=>{this.subscribers.delete(o)}}watch(o,t){if(this.editor=o,this.editor){let n=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},l=this.editor._tiptapEditor,i={all:["transaction","create","mount","unmount"],mount:["create","mount","unmount"],selection:["selectionUpdate"],change:["update"]};for(let s of i[t])l.on(s,n);return()=>{for(let s of i[t])l.off(s,n)}}}};function E(e){let o=O(),t=e.editor||o?.editor||null,n=e.on||"all",[l]=d.useState(()=>new Oo(t)),i=Zt.useSyncExternalStoreWithSelector(l.subscribe,l.getSnapshot,l.getServerSnapshot,e.selector,e.equalityFn??Rn);return Bo(()=>l.watch(t,n),[t,l,n]),d.useDebugValue(i),i}function q(e){let o=O();return e||=o?.editor,E({editor:e,selector:t=>t.editor?.domElement,equalityFn:(t,n)=>t===n,on:"mount"})}var Fe=e=>{let{position:o,children:t,...n}=e,{from:l,to:i}=o||{},s=v(),a=q();return r.jsx(L,{reference:d.useMemo(()=>{if(!(l===void 0||i===void 0))return{element:a?.firstElementChild||void 0,getBoundingClientRect:()=>En(s.prosemirrorView,l,i??l)}},[s,a,l,i]),...n,children:o!==void 0&&t})},De=(e={},o=[])=>d.useMemo(()=>{let t=Xt.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},o),Le=e=>{let[o,t]=d.useState(!1),n=E({editor:e.editor,selector:({editor:a})=>a.isEmpty}),l=h(),i=d.useCallback(()=>{t(!0)},[]),s=d.useCallback(()=>{t(!1)},[]);return d.useEffect(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),r.jsxs(r.Fragment,{children:[r.jsx(l.Comments.Editor,{autoFocus:e.autoFocus,className:"bn-comment-editor",editor:e.editor,onFocus:i,onBlur:s,editable:e.editable}),e.actions&&r.jsx("div",{className:"bn-comment-actions-wrapper",children:r.jsx(e.actions,{isFocused:o,isEmpty:n})})]})},{textColor:ui,backgroundColor:mi,...Fo}=en,Ae=Jt.create({blockSpecs:{paragraph:tn()},styleSpecs:Fo}),Ke=Object.defineProperty,Tt=(e,o)=>{let t={};for(var n in e)Ke(t,n,{get:e[n],enumerable:!0});return Ke(t,Symbol.toStringTag,{value:"Module"}),t},Ce;async function Do(){return Ce||(Ce=(async()=>{let[e,o]=await Promise.all([me(()=>import("./module-RjUF93sV.js"),[]),me(()=>import("./native-48B9X9Wg.js"),[])]),t="default"in e?e.default:e,n="default"in o?o.default:o;return await t.init({data:n}),{emojiMart:t,emojiData:n}})(),Ce)}function Lo(e){let o=d.useRef(null),t=d.useRef(null);return t.current&&t.current.update(e),d.useEffect(()=>((async()=>{let{emojiMart:n}=await Do();t.current=new n.Picker({...e,ref:o})})(),()=>{t.current=null}),[]),pe.createElement("div",{ref:o})}var Qe=e=>{let[o,t]=d.useState(!1),n=h(),l=O(),i=l.editor?.portalElement;if(!i)throw Error("Portal root not found");return r.jsxs(n.Generic.Popover.Root,{open:o,portalRoot:i,children:[r.jsx(n.Generic.Popover.Trigger,{children:r.jsx("div",{onClick:s=>{s.preventDefault(),s.stopPropagation(),t(!o),e.onOpenChange?.(!o)},style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.children})}),r.jsx(n.Generic.Popover.Content,{className:"bn-emoji-picker-popover",variant:"panel-popover",children:r.jsx(Lo,{perLine:7,onClickOutside:()=>{t(!1),e.onOpenChange?.(!1)},onEmojiSelect:s=>{e.onEmojiSelect(s),t(!1),e.onOpenChange?.(!1)},theme:l?.colorSchemePreference})})]})};function _t(e){return fe([e]).get(e)}function fe(e){let o=w(B).userStore,t=d.useCallback(()=>{let l=new Map;for(let i of e){let s=o.getUser(i);s&&l.set(i,s)}return l},[o,e]),n=d.useMemo(()=>({current:t()}),[t]);return d.useSyncExternalStore(d.useCallback(l=>{let i=o.subscribe(s=>{n.current=t(),l()});return o.loadUsers(e),i},[o,t,e,n]),()=>n.current)}var Ao=e=>{let o=h(),t=k(),n=w(B),l=e.comment.reactions.find(c=>c.emoji===e.emoji);if(!l)throw Error("Trying to render reaction badge for non-existing reaction");let[i,s]=d.useState([]),a=fe(i);return r.jsx(o.Generic.Badge.Root,{className:R("bn-badge","bn-comment-reaction"),text:l.userIds.length.toString(),icon:l.emoji,isSelected:n.threadStore.auth.canDeleteReaction(e.comment,l.emoji),onClick:()=>e.onReactionSelect(l.emoji),onMouseEnter:()=>s(l.userIds),mainTooltip:t.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(a.values()).map(c=>c.username).join(`
1
+ import{r as d,j as r,w as Zt,b as pe,a as ae}from"./floating-ui.react-dom-BWTnA00G.js";import{$ as Xt,q as Jt,U as en,s as tn,v as B,w as R,L as nn,I as on,P as z,D as P,n as Y,Z as U,a as S,C as ge,K as ie,M as Z,b as rn,O as ln,i as be,c as D,Y as _e,V as Ge,d as an,o as sn,e as et,A as cn,x as tt,f as nt,u as dn,g as un,N as X,W as mn,T as ot,H as pn,r as $e,h as gn,j as bn,k as fn,l as hn,m as xn,F as j,p as Re}from"./note-core-DUTqUh5N.js";import{aL as vn,aM as Cn,aN as Me,aO as kn,aP as jn,aQ as wn,aR as yn,aS as Sn,aT as Tn,aU as ve,aV as _n,aW as Rn,I as En,aX as He,aY as In,aZ as Mn,a_ as Pn,a$ as Nn,b0 as Bn,b1 as A,b2 as J,b3 as ee,T as On,b4 as rt,b5 as se,b6 as Fn,b7 as Dn,b8 as Ln,b9 as An,ba as zn,bb as Gn,bc as $n,bd as Hn,be as Pe,bf as lt,bg as it,bh as at,bi as st,bj as ct,bk as ce,bl as de,bm as ue,bn as dt,bo as ut,bp as mt,bq as pt,br as Ue,bs as Un,bt as Ve,bu as Vn,bv as qn,bw as Kn,bx as Qn,by as Wn,bz as Yn,bA as Zn,bB as Xn,bC as Jn,bD as eo,bE as to,bF as no,bG as oo,bH as ro,bI as gt,bJ as bt,bK as lo,bL as io,bM as ao,bN as ft,bO as so,bP as co,bQ as uo,bR as mo,bS as po,bT as ht,bU as xt,N as go,bV as bo,bW as fo,bX as ho,bY as $,bZ as vt,b_ as xo,b$ as M,c0 as N,c1 as V,c2 as vo,c3 as Ct,c4 as Ne,c5 as kt,c6 as Co,c7 as ko,c8 as Be,c9 as jo,ca as wo,cb as yo,cc as So,cd as jt,ce as wt,cf as Oe,cg as To,ch as _o,ci as oe,cj as Ro,ck as qe,cl as Eo,cm as Io}from"./note-runtime-zN5ddTba.js";import{_ as me}from"./preload-helper-BXl3LOEh.js";import{c as Mo}from"./time-D5LRMumI.js";var yt=d.createContext(void 0);function O(e){return d.useContext(yt)}function v(e){let o=O();if(!o?.editor)throw Error("useBlockNoteEditor was called outside of a BlockNoteContext provider or BlockNoteView component");return o.editor}function w(e,o){let t=(o?.editor??v()).getExtension(e);if(!t)throw Error("Extension not found",{cause:{plugin:e}});return t}function y(e,o){let{store:t}=w(e,o);if(!t)throw Error("Store not found on plugin",{cause:{plugin:e}});return vn(t,o?.selector)}function Po(e){let o=new DOMRect,t="getBoundingClientRect"in e?()=>e.getBoundingClientRect():()=>e.element.getBoundingClientRect();return()=>e.element&&(e.cacheMountedBoundingClientRect??!0)?(e.element.isConnected&&(o=t()),o):t()}function No(e,o){return e?o?(t,n,l)=>{let i=e(t,n,l),s=o(t,n,l);return()=>{i?.(),s?.()}}:e:o}var L=e=>{let o=v(),t=o?.portalElement;if(!t)throw Error("Portal element not found");let{whileElementsMounted:n,...l}=e.useFloatingOptions??{},{refs:i,floatingStyles:s,context:a}=Cn({whileElementsMounted:No(Me,e.useFloatingOptions?.whileElementsMounted),...l}),{isMounted:c,styles:u}=kn(a,e.useTransitionStylesProps),{status:m}=jn(a,e.useTransitionStatusProps),{getFloatingProps:p}=wn([yn(a,e.useDismissProps),Sn(a,{enabled:!1,...e.useHoverProps})]),g=d.useRef(""),b=d.useRef(null),f=Tn([b,i.setFloating]);if(d.useEffect(()=>{if(e.reference){let C="element"in e.reference?e.reference.element:void 0;C!==void 0&&(e.focusManagerProps?.disabled||!o.isWithinEditor(C))&&i.setReference(C),i.setPositionReference({getBoundingClientRect:Po(e.reference),contextElement:C})}},[e.reference,i,e.focusManagerProps?.disabled,o]),d.useEffect(()=>{(m==="initial"||m==="open")&&b.current?.innerHTML&&(g.current=b.current.innerHTML)},[m,e.reference,e.children]),!c)return!1;let x={...e.elementProps,style:{display:"flex",...e.elementProps?.style,zIndex:`calc(var(--bn-ui-base-z-index, 0) + ${e.elementProps?.style?.zIndex||0})`,...s,...u},...p()};return m==="close"?r.jsx(ve,{root:t,children:r.jsx("div",{ref:f,...x,dangerouslySetInnerHTML:{__html:g.current}})}):e.focusManagerProps?.disabled?r.jsx(ve,{root:t,children:r.jsx("div",{ref:f,...x,children:e.children})}):r.jsx(ve,{root:t,children:r.jsx(_n,{...e.focusManagerProps,context:a,children:r.jsx("div",{ref:f,...x,children:e.children})})})},St=d.createContext(void 0);function h(){return d.useContext(St)}function k(){return O().editor.dictionary}var Bo=typeof window<"u"?d.useLayoutEffect:d.useEffect,Oo=class{transactionNumber=0;lastTransactionNumber=0;lastSnapshot;editor;subscribers=new Set;constructor(o){this.editor=o,this.lastSnapshot={editor:o,transactionNumber:0},this.getSnapshot=this.getSnapshot.bind(this),this.getServerSnapshot=this.getServerSnapshot.bind(this),this.watch=this.watch.bind(this),this.subscribe=this.subscribe.bind(this)}getSnapshot(){return this.transactionNumber===this.lastTransactionNumber?this.lastSnapshot:(this.lastTransactionNumber=this.transactionNumber,this.lastSnapshot={editor:this.editor,transactionNumber:this.transactionNumber},this.lastSnapshot)}getServerSnapshot(){return{editor:null,transactionNumber:0}}subscribe(o){return this.subscribers.add(o),()=>{this.subscribers.delete(o)}}watch(o,t){if(this.editor=o,this.editor){let n=()=>{this.transactionNumber+=1,this.subscribers.forEach(s=>s())},l=this.editor._tiptapEditor,i={all:["transaction","create","mount","unmount"],mount:["create","mount","unmount"],selection:["selectionUpdate"],change:["update"]};for(let s of i[t])l.on(s,n);return()=>{for(let s of i[t])l.off(s,n)}}}};function E(e){let o=O(),t=e.editor||o?.editor||null,n=e.on||"all",[l]=d.useState(()=>new Oo(t)),i=Zt.useSyncExternalStoreWithSelector(l.subscribe,l.getSnapshot,l.getServerSnapshot,e.selector,e.equalityFn??Rn);return Bo(()=>l.watch(t,n),[t,l,n]),d.useDebugValue(i),i}function q(e){let o=O();return e||=o?.editor,E({editor:e,selector:t=>t.editor?.domElement,equalityFn:(t,n)=>t===n,on:"mount"})}var Fe=e=>{let{position:o,children:t,...n}=e,{from:l,to:i}=o||{},s=v(),a=q();return r.jsx(L,{reference:d.useMemo(()=>{if(!(l===void 0||i===void 0))return{element:a?.firstElementChild||void 0,getBoundingClientRect:()=>En(s.prosemirrorView,l,i??l)}},[s,a,l,i]),...n,children:o!==void 0&&t})},De=(e={},o=[])=>d.useMemo(()=>{let t=Xt.create(e);return window&&(window.ProseMirror=t._tiptapEditor),t},o),Le=e=>{let[o,t]=d.useState(!1),n=E({editor:e.editor,selector:({editor:a})=>a.isEmpty}),l=h(),i=d.useCallback(()=>{t(!0)},[]),s=d.useCallback(()=>{t(!1)},[]);return d.useEffect(()=>{e.editable&&e.autoFocus&&e.editor.focus()},[e.autoFocus,e.editable,e.editor]),r.jsxs(r.Fragment,{children:[r.jsx(l.Comments.Editor,{autoFocus:e.autoFocus,className:"bn-comment-editor",editor:e.editor,onFocus:i,onBlur:s,editable:e.editable}),e.actions&&r.jsx("div",{className:"bn-comment-actions-wrapper",children:r.jsx(e.actions,{isFocused:o,isEmpty:n})})]})},{textColor:ui,backgroundColor:mi,...Fo}=en,Ae=Jt.create({blockSpecs:{paragraph:tn()},styleSpecs:Fo}),Ke=Object.defineProperty,Tt=(e,o)=>{let t={};for(var n in e)Ke(t,n,{get:e[n],enumerable:!0});return Ke(t,Symbol.toStringTag,{value:"Module"}),t},Ce;async function Do(){return Ce||(Ce=(async()=>{let[e,o]=await Promise.all([me(()=>import("./module-RjUF93sV.js"),[]),me(()=>import("./native-48B9X9Wg.js"),[])]),t="default"in e?e.default:e,n="default"in o?o.default:o;return await t.init({data:n}),{emojiMart:t,emojiData:n}})(),Ce)}function Lo(e){let o=d.useRef(null),t=d.useRef(null);return t.current&&t.current.update(e),d.useEffect(()=>((async()=>{let{emojiMart:n}=await Do();t.current=new n.Picker({...e,ref:o})})(),()=>{t.current=null}),[]),pe.createElement("div",{ref:o})}var Qe=e=>{let[o,t]=d.useState(!1),n=h(),l=O(),i=l.editor?.portalElement;if(!i)throw Error("Portal root not found");return r.jsxs(n.Generic.Popover.Root,{open:o,portalRoot:i,children:[r.jsx(n.Generic.Popover.Trigger,{children:r.jsx("div",{onClick:s=>{s.preventDefault(),s.stopPropagation(),t(!o),e.onOpenChange?.(!o)},style:{display:"flex",justifyContent:"center",alignItems:"center"},children:e.children})}),r.jsx(n.Generic.Popover.Content,{className:"bn-emoji-picker-popover",variant:"panel-popover",children:r.jsx(Lo,{perLine:7,onClickOutside:()=>{t(!1),e.onOpenChange?.(!1)},onEmojiSelect:s=>{e.onEmojiSelect(s),t(!1),e.onOpenChange?.(!1)},theme:l?.colorSchemePreference})})]})};function _t(e){return fe([e]).get(e)}function fe(e){let o=w(B).userStore,t=d.useCallback(()=>{let l=new Map;for(let i of e){let s=o.getUser(i);s&&l.set(i,s)}return l},[o,e]),n=d.useMemo(()=>({current:t()}),[t]);return d.useSyncExternalStore(d.useCallback(l=>{let i=o.subscribe(s=>{n.current=t(),l()});return o.loadUsers(e),i},[o,t,e,n]),()=>n.current)}var Ao=e=>{let o=h(),t=k(),n=w(B),l=e.comment.reactions.find(c=>c.emoji===e.emoji);if(!l)throw Error("Trying to render reaction badge for non-existing reaction");let[i,s]=d.useState([]),a=fe(i);return r.jsx(o.Generic.Badge.Root,{className:R("bn-badge","bn-comment-reaction"),text:l.userIds.length.toString(),icon:l.emoji,isSelected:n.threadStore.auth.canDeleteReaction(e.comment,l.emoji),onClick:()=>e.onReactionSelect(l.emoji),onMouseEnter:()=>s(l.userIds),mainTooltip:t.comments.reactions.reacted_by,secondaryTooltip:`${Array.from(a.values()).map(c=>c.username).join(`
2
2
  `)}`},l.emoji)},Rt=({comment:e,thread:o,showResolveButton:t})=>{let n=w(B),l=k(),i=De({initialContent:e.body,trailingBlock:!1,dictionary:{...l,placeholders:{emptyDocument:l.placeholders.edit_comment}},schema:n.commentEditorSchema||Ae}),s=h(),[a,c]=d.useState(!1),[u,m]=d.useState(!1),p=n.threadStore,g=d.useCallback(()=>{c(!0)},[]),b=d.useCallback(()=>{i.replaceBlocks(i.document,e.body),c(!1)},[i,e.body]),f=d.useCallback(async _=>{await p.updateComment({commentId:e.id,comment:{body:i.document},threadId:o.id}),c(!1)},[e,o.id,i,p]),x=d.useCallback(async()=>{await p.deleteComment({commentId:e.id,threadId:o.id})},[e,o.id,p]),C=d.useCallback(async _=>{p.auth.canAddReaction(e,_)?await p.addReaction({threadId:o.id,commentId:e.id,emoji:_}):p.auth.canDeleteReaction(e,_)&&await p.deleteReaction({threadId:o.id,commentId:e.id,emoji:_})},[p,e,o.id]),T=d.useCallback(async()=>{await p.resolveThread({threadId:o.id})},[o.id,p]),I=d.useCallback(async()=>{await p.unresolveThread({threadId:o.id})},[o.id,p]),F=_t(e.userId);if(!e.body)return null;let Q,te=p.auth.canAddReaction(e),K=p.auth.canDeleteComment(e),ne=p.auth.canUpdateComment(e),xe=t&&(o.resolved?p.auth.canUnresolveThread(o):p.auth.canResolveThread(o));a||(Q=r.jsxs(s.Generic.Toolbar.Root,{className:R("bn-action-toolbar","bn-comment-actions"),variant:"action-toolbar",children:[te&&r.jsx(Qe,{onEmojiSelect:_=>C(_.native),onOpenChange:m,children:r.jsx(s.Generic.Toolbar.Button,{mainTooltip:l.comments.actions.add_reaction,variant:"compact",children:r.jsx(He,{size:16})},"add-reaction")}),xe&&(o.resolved?r.jsx(s.Generic.Toolbar.Button,{mainTooltip:"Re-open",variant:"compact",onClick:I,children:r.jsx(In,{size:16})},"reopen"):r.jsx(s.Generic.Toolbar.Button,{mainTooltip:l.comments.actions.resolve,variant:"compact",onClick:T,children:r.jsx(Mn,{size:16})},"resolve")),(K||ne)&&r.jsxs(s.Generic.Menu.Root,{position:"bottom-start",children:[r.jsx(s.Generic.Menu.Trigger,{children:r.jsx(s.Generic.Toolbar.Button,{mainTooltip:l.comments.actions.more_actions,variant:"compact",children:r.jsx(Pn,{size:16})},"more-actions")}),r.jsxs(s.Generic.Menu.Dropdown,{className:"bn-menu-dropdown",children:[ne&&r.jsx(s.Generic.Menu.Item,{icon:r.jsx(Nn,{}),onClick:g,children:l.comments.actions.edit_comment},"edit-comment"),K&&r.jsx(s.Generic.Menu.Item,{icon:r.jsx(Bn,{}),onClick:x,children:l.comments.actions.delete_comment},"delete-comment")]})]})]}));let G=e.createdAt.toLocaleDateString(void 0,{month:"short",day:"numeric"});if(!e.body)throw Error("soft deletes are not yet supported");return r.jsx(s.Comments.Comment,{authorInfo:F??"loading",timeString:G,edited:e.updatedAt.getTime()!==e.createdAt.getTime(),showActions:"hover",actions:Q,className:"bn-thread-comment",emojiPickerOpen:u,children:r.jsx(Le,{autoFocus:a,editor:i,editable:a,actions:e.reactions.length>0||a?({isEmpty:_})=>r.jsxs(r.Fragment,{children:[e.reactions.length>0&&!a&&r.jsxs(s.Generic.Badge.Group,{className:R("bn-badge-group","bn-comment-reactions"),children:[e.reactions.map(H=>r.jsx(Ao,{comment:e,emoji:H.emoji,onReactionSelect:C},H.emoji)),te&&r.jsx(Qe,{onEmojiSelect:H=>C(H.native),onOpenChange:m,children:r.jsx(s.Generic.Badge.Root,{className:R("bn-badge","bn-comment-add-reaction"),text:"+",icon:r.jsx(He,{size:16}),mainTooltip:l.comments.actions.add_reaction})})]}),a&&r.jsxs(s.Generic.Toolbar.Root,{variant:"action-toolbar",className:R("bn-action-toolbar","bn-comment-actions"),children:[r.jsx(s.Generic.Toolbar.Button,{mainTooltip:l.comments.save_button_text,variant:"compact",onClick:f,isDisabled:_,children:l.comments.save_button_text}),r.jsx(s.Generic.Toolbar.Button,{className:"bn-button",mainTooltip:l.comments.cancel_button_text,variant:"compact",onClick:b,children:l.comments.cancel_button_text})]})]}):void 0})})},Et=({thread:e,maxCommentsBeforeCollapse:o})=>{let t=h(),n=k(),l=fe(e.resolvedBy?[e.resolvedBy]:[]),i=e.comments.map((s,a)=>r.jsx(Rt,{thread:e,comment:s,showResolveButton:a===0},s.id+JSON.stringify(s.body||"{}")));if(e.resolved&&e.resolvedUpdatedAt&&e.resolvedBy){if(!l.get(e.resolvedBy))throw Error(`User ${e.resolvedBy} resolved thread ${e.id}, but their data could not be found.`);let s=e.comments.findLastIndex(a=>e.resolvedUpdatedAt.getTime()>a.createdAt.getTime())+1;i.splice(s,0,r.jsx(t.Comments.Comment,{className:"bn-thread-comment",authorInfo:e.resolvedBy&&l.get(e.resolvedBy)||"loading",timeString:e.resolvedUpdatedAt.toLocaleDateString(void 0,{month:"short",day:"numeric"}),edited:!1,showActions:!1,children:r.jsx("div",{className:"bn-resolved-text",children:n.comments.sidebar.marked_as_resolved})},"resolved-comment"))}return o&&i.length>o&&i.splice(1,i.length-2,r.jsx(t.Comments.ExpandSectionsPrompt,{className:"bn-thread-expand-prompt",children:n.comments.sidebar.more_replies(e.comments.length-2)},"expand-prompt")),i},ze=({thread:e,selected:o,referenceText:t,maxCommentsBeforeCollapse:n,onFocus:l,onBlur:i,tabIndex:s})=>{let a=h(),c=k(),u=w(B),m=De({trailingBlock:!1,dictionary:{...c,placeholders:{emptyDocument:c.placeholders.comment_reply}},schema:u.commentEditorSchema||Ae}),p=d.useCallback(async()=>{await u.threadStore.addComment({comment:{body:m.document},threadId:e.id}),m.removeBlocks(m.document)},[u,m,e.id]);return r.jsxs(a.Comments.Card,{className:"bn-thread",headerText:t,onFocus:l,onBlur:i,selected:o,tabIndex:s,children:[r.jsx(a.Comments.CardSection,{className:"bn-thread-comments",children:r.jsx(Et,{thread:e,maxCommentsBeforeCollapse:o?void 0:n||5})}),o&&r.jsx(a.Comments.CardSection,{className:"bn-thread-composer",children:r.jsx(Le,{autoFocus:!1,editable:!0,editor:m,actions:({isEmpty:g})=>g?null:r.jsx(a.Generic.Toolbar.Root,{variant:"action-toolbar",className:R("bn-action-toolbar","bn-comment-actions"),children:r.jsx(a.Generic.Toolbar.Button,{mainTooltip:c.comments.save_button_text,variant:"compact",isDisabled:g,onClick:p,children:c.comments.save_button_text})})})})]})};function It(){let e=w(B).threadStore,o=d.useRef(void 0);return o.current||=e.getThreads(),d.useSyncExternalStore(d.useCallback(t=>e.subscribe(n=>{o.current=n,t()}),[e]),()=>o.current)}var zo=Tt({default:()=>Mt});function Mt(e){let o=v(),t=w(B),n=y(B,{editor:o,selector:c=>c.selectedThreadId?{id:c.selectedThreadId,position:c.threadPositions.get(c.selectedThreadId)}:void 0}),l=It(),i=d.useMemo(()=>n?l.get(n.id):void 0,[n,l]),s=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!n,onOpenChange:(c,u,m)=>{m==="escape-key"&&o.focus(),c||t.selectThread(void 0)},placement:"bottom",middleware:[A(10),J(),ee()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:30},...e.floatingUIOptions?.elementProps}}),[t,o,e.floatingUIOptions,n]),a=e.floatingThread||ze;return r.jsx(Fe,{position:n?.position,...s,children:i&&r.jsx(a,{thread:i,selected:!0})})}const Go=Object.freeze(Object.defineProperty({__proto__:null,a:Et,c:fe,i:ze,n:zo,o:Rt,r:It,s:_t,t:Mt},Symbol.toStringTag,{value:"Module"}));function Pt(){let e=v(),o=w(B),t=h(),n=k(),l=De({trailingBlock:!1,dictionary:{...n,placeholders:{emptyDocument:n.placeholders.new_comment}},schema:o.commentEditorSchema||Ae});return r.jsx(t.Comments.Card,{className:"bn-thread",children:r.jsx(Le,{autoFocus:!0,editable:!0,editor:l,actions:({isEmpty:i})=>r.jsx(t.Generic.Toolbar.Root,{className:R("bn-action-toolbar","bn-comment-actions"),variant:"action-toolbar",children:r.jsx(t.Generic.Toolbar.Button,{className:"bn-button",mainTooltip:"Save",variant:"compact",isDisabled:i,onClick:async()=>{await o.createThread({initialComment:{body:l.document}}),o.stopPendingComment(),e.transact(s=>{s.setSelection(On.create(s.doc,s.selection.to))}),e.focus()},children:"Save"})})})})}var $o=Tt({default:()=>Nt});function Nt(e){let o=v(),t=w(B),n=y(B,{editor:o,selector:a=>a.pendingComment}),l=E({editor:o,selector:({editor:a})=>n?{from:a.prosemirrorState.selection.from,to:a.prosemirrorState.selection.to}:void 0}),i=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!n,onOpenChange:a=>{a||(t.stopPendingComment(),o.focus())},placement:"bottom",middleware:[A(10),J(),ee()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!1},elementProps:{style:{zIndex:60},...e.floatingUIOptions?.elementProps}}),[t,o,n,e.floatingUIOptions]),s=e.floatingComposer||Pt;return r.jsx(Fe,{position:l,...i,children:r.jsx(s,{})})}const Ho=Object.freeze(Object.defineProperty({__proto__:null,n:$o,r:Pt,t:Nt},Symbol.toStringTag,{value:"Module"}));var Bt=e=>{let{blockId:o,children:t,...n}=e,l=v();return r.jsx(L,{reference:d.useMemo(()=>l.transact(i=>{if(!o)return;let s=et(o,i.doc);if(!s)return;let{node:a}=l.prosemirrorView.domAtPos(s.posBeforeNode+1);if(a instanceof Element)return{element:a}}),[l,o]),...n,children:o!==void 0&&t})},Uo=e=>{let o=h(),t=k(),n=v(),l=n.getBlock(e.blockId),[i,s]=d.useState(""),a=d.useCallback(m=>{s(m.currentTarget.value)},[]),c=d.useCallback(m=>{m.key==="Enter"&&!m.nativeEvent.isComposing&&(m.preventDefault(),n.updateBlock(l.id,{props:{name:Ge(i),url:i}}))},[n,l.id,i]),u=d.useCallback(()=>{n.updateBlock(l.id,{props:{name:Ge(i),url:i}})},[n,l.id,i]);return r.jsxs(o.FilePanel.TabPanel,{className:"bn-tab-panel",children:[r.jsx(o.FilePanel.TextInput,{className:"bn-text-input",placeholder:t.file_panel.embed.url_placeholder,value:i,onChange:a,onKeyDown:c,"data-test":"embed-input"}),r.jsx(o.FilePanel.Button,{className:"bn-button",onClick:u,"data-test":"embed-input-button",children:t.file_panel.embed.embed_button[l.type]||t.file_panel.embed.embed_button.file})]})},Vo=e=>{let o=h(),t=k(),{setLoading:n}=e,l=v(),i=l.getBlock(e.blockId),[s,a]=d.useState(!1);d.useEffect(()=>{s&&setTimeout(()=>{a(!1)},3e3)},[s]);let c=d.useCallback(p=>{if(p===null)return;async function g(b){if(n(!0),l.uploadFile!==void 0)try{let f=await l.uploadFile(b,e.blockId);typeof f=="string"&&(f={props:{name:b.name,url:f}}),l.updateBlock(e.blockId,f)}catch{a(!0)}finally{n(!1)}}g(p)},[e.blockId,l,n]),u=l.schema.blockSpecs[i.type],m=u.implementation.meta?.fileBlockAccept?.length?u.implementation.meta.fileBlockAccept.join(","):"*/*";return r.jsxs(o.FilePanel.TabPanel,{className:"bn-tab-panel",children:[r.jsx(o.FilePanel.FileInput,{className:"bn-file-input","data-test":"upload-input",accept:m,placeholder:t.file_panel.upload.file_placeholder[i.type]||t.file_panel.upload.file_placeholder.file,value:null,onChange:c}),s&&r.jsx("div",{className:"bn-error-text",children:t.file_panel.upload.upload_error})]})},Ot=e=>{let o=h(),t=k(),n=v(),[l,i]=d.useState(!1),s=e.tabs??[...n.uploadFile===void 0?[]:[{name:t.file_panel.upload.title,tabPanel:r.jsx(Vo,{blockId:e.blockId,setLoading:i})}],{name:t.file_panel.embed.title,tabPanel:r.jsx(Uo,{blockId:e.blockId})}],[a,c]=d.useState(e.defaultOpenTab||s[0].name);return r.jsx(o.FilePanel.Root,{className:"bn-panel",defaultOpenTab:a,openTab:a,setOpenTab:c,tabs:s,loading:l})},qo=e=>{let o=v(),t=w(_e),n=y(_e),l=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:!!n,onOpenChange:(s,a,c)=>{s||t.closeMenu(),c==="escape-key"&&o.focus()},middleware:[A(10),ee()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:90},...e.floatingUIOptions?.elementProps}}),[n,o,t,e.floatingUIOptions]),i=e.filePanel||Ot;return r.jsx(Bt,{blockId:n,...l,children:n&&r.jsx(i,{blockId:n})})},Ko={bold:Xn,italic:Zn,underline:Yn,strike:Wn,code:Qn};function Qo(e,o){return e in o.schema.styleSchema&&o.schema.styleSchema[e].type===e&&o.schema.styleSchema[e].propSchema==="boolean"}var re=e=>{let o=k(),t=h(),n=v(),l=E({editor:n,selector:({editor:a})=>{if(!(!a.isEditable||!Qo(e.basicTextStyle,a)||!(a.getSelection()?.blocks||[a.getTextCursorPosition().block]).find(c=>c.content!==void 0)))return e.basicTextStyle in a.getActiveStyles()?{active:!0}:{active:!1}}}),i=d.useCallback(a=>{n.focus(),n.toggleStyles({[a]:!0})},[n,e]);if(l===void 0)return null;let s=Ko[e.basicTextStyle];return r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":e.basicTextStyle,onClick:()=>i(e.basicTextStyle),isSelected:l.active,label:o.formatting_toolbar[e.basicTextStyle].tooltip,mainTooltip:o.formatting_toolbar[e.basicTextStyle].tooltip,secondaryTooltip:ge(o.formatting_toolbar[e.basicTextStyle].secondary_tooltip,o.generic.ctrl_shortcut),icon:r.jsx(s,{})})},Ee=e=>{let o=e.textColor||"default",t=e.backgroundColor||"default",n=e.size||16;return r.jsx("div",{className:"bn-color-icon","data-background-color":t,"data-text-color":o,style:d.useMemo(()=>({pointerEvents:"none",fontSize:(n*.75).toString()+"px",height:n.toString()+"px",lineHeight:n.toString()+"px",textAlign:"center",width:n.toString()+"px"}),[n]),children:"A"})},We=["default","gray","brown","red","orange","yellow","green","blue","purple","pink"],he=e=>{let o=h(),t=k();return r.jsxs(r.Fragment,{children:[r.jsx(()=>e.text?r.jsxs(r.Fragment,{children:[r.jsx(o.Generic.Menu.Label,{children:t.color_picker.text_title}),We.map(n=>r.jsx(o.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.text.setColor(n)},"data-test":"text-color-"+n,icon:r.jsx(Ee,{textColor:n,size:e.iconSize}),checked:e.text.color===n,children:t.color_picker.colors[n]},"text-color-"+n))]}):null,{}),r.jsx(()=>e.background?r.jsxs(r.Fragment,{children:[r.jsx(o.Generic.Menu.Label,{children:t.color_picker.background_title}),We.map(n=>r.jsx(o.Generic.Menu.Item,{onClick:()=>{e.onClick&&e.onClick(),e.background.setColor(n)},"data-test":"background-color-"+n,icon:r.jsx(Ee,{backgroundColor:n,size:e.iconSize}),checked:e.background.color===n,children:t.color_picker.colors[n]},"background-color-"+n))]}):null,{})]})};function le(e,o){return`${e}Color`in o.schema.styleSchema&&o.schema.styleSchema[`${e}Color`].type===`${e}Color`&&o.schema.styleSchema[`${e}Color`].propSchema==="string"}var Wo=()=>{let e=h(),o=k(),t=v(),n=le("text",t),l=le("background",t),i=E({editor:t,selector:({editor:c})=>{if(!c.isEditable||!(c.getSelection()?.blocks||[c.getTextCursorPosition().block]).find(p=>p.content!==void 0))return;let u=le("text",c),m=le("background",c);if(!(!u&&!m))return{textColor:u?c.getActiveStyles().textColor||"default":void 0,backgroundColor:m?c.getActiveStyles().backgroundColor||"default":void 0}}}),s=d.useCallback(c=>{if(!n)throw Error("Tried to set text color, but style does not exist in editor schema.");c==="default"?t.removeStyles({textColor:c}):t.addStyles({textColor:c}),setTimeout(()=>{t.focus()})},[t,n]),a=d.useCallback(c=>{if(!l)throw Error("Tried to set background color, but style does not exist in editor schema.");c==="default"?t.removeStyles({backgroundColor:c}):t.addStyles({backgroundColor:c}),setTimeout(()=>{t.focus()})},[l,t]);return i===void 0?null:r.jsxs(e.Generic.Menu.Root,{children:[r.jsx(e.Generic.Menu.Trigger,{children:r.jsx(e.FormattingToolbar.Button,{className:"bn-button","data-test":"colors",label:o.formatting_toolbar.colors.tooltip,mainTooltip:o.formatting_toolbar.colors.tooltip,icon:r.jsx(Ee,{textColor:i.textColor,backgroundColor:i.backgroundColor,size:20})})}),r.jsx(e.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(he,{text:i.textColor?{color:i.textColor,setColor:s}:void 0,background:i.backgroundColor?{color:i.backgroundColor,setColor:a}:void 0})})]})},Ye=e=>{for(let o of an)if(e.startsWith(o))return e;return`${sn}://${e}`},Ft=e=>{let o=h(),t=k(),{editLink:n}=w(be),{url:l,text:i,showTextField:s}=e,[a,c]=d.useState(l),[u,m]=d.useState(i);d.useEffect(()=>{c(l),m(i)},[i,l]);let p=d.useCallback(x=>{x.key==="Enter"&&!x.nativeEvent.isComposing&&(x.preventDefault(),n(Ye(a),u,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1))},[n,a,u,e]),g=d.useCallback(x=>c(x.currentTarget.value),[]),b=d.useCallback(x=>m(x.currentTarget.value),[]),f=d.useCallback(()=>{n(Ye(a),u,e.range.from),e.setToolbarOpen?.(!1),e.setToolbarPositionFrozen?.(!1)},[n,a,u,e]);return r.jsxs(o.Generic.Form.Root,{children:[r.jsx(o.Generic.Form.TextInput,{className:"bn-text-input",name:"url",icon:r.jsx(gt,{}),autoFocus:!0,placeholder:t.link_toolbar.form.url_placeholder,value:a,onKeyDown:p,onChange:g,onSubmit:f}),s!==!1&&r.jsx(o.Generic.Form.TextInput,{className:"bn-text-input",name:"title",icon:r.jsx(Pe,{}),placeholder:t.link_toolbar.form.title_placeholder,value:u,onKeyDown:p,onChange:b,onSubmit:f})]})};function Yo(e){return"link"in e.schema.inlineContentSchema&&e.schema.inlineContentSchema.link==="link"}var Zo=()=>{let e=v(),o=q(),t=h(),n=k(),l=w(Y),{showSelection:i}=w(rn),[s,a]=d.useState(!1);d.useEffect(()=>(i(s,"createLinkButton"),()=>i(!1,"createLinkButton")),[s,i]);let c=E({editor:e,selector:({editor:u})=>{if(!(!u.isEditable||!Yo(u)||ln(u.prosemirrorState.selection)||!(u.getSelection()?.blocks||[u.getTextCursorPosition().block]).find(m=>m.content!==void 0)))return{url:u.getSelectedLinkUrl(),text:u.getSelectedText(),range:{from:u.prosemirrorState.selection.from,to:u.prosemirrorState.selection.to}}}});return d.useEffect(()=>{a(!1)},[c]),d.useEffect(()=>{let u=m=>{(m.ctrlKey||m.metaKey)&&m.key==="k"&&(a(!0),m.preventDefault())};return o?.addEventListener("keydown",u),()=>{o?.removeEventListener("keydown",u)}},[o]),c===void 0?null:r.jsxs(t.Generic.Popover.Root,{open:s,onOpenChange:a,children:[r.jsx(t.Generic.Popover.Trigger,{children:r.jsx(t.FormattingToolbar.Button,{className:"bn-button","data-test":"createLink",label:n.formatting_toolbar.link.tooltip,mainTooltip:n.formatting_toolbar.link.tooltip,secondaryTooltip:ge(n.formatting_toolbar.link.secondary_tooltip,n.generic.ctrl_shortcut),icon:r.jsx(gt,{}),onClick:()=>a(u=>!u)})}),r.jsx(t.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(Ft,{url:c.url||"",text:c.text,range:c.range,showTextField:!1,setToolbarOpen:u=>l.store.setState(u)})})]})},Xo=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:c})=>{if(!c.isEditable)return;let u=c.getSelection()?.blocks||[c.getTextCursorPosition().block];if(u.length!==1)return;let m=u[0];if(P(m,c,m.type,{url:"string",caption:"string"}))return m}}),[l,i]=d.useState(!1),s=d.useCallback(c=>{n!==void 0&&U(t,n.type,{caption:"string"})&&t.updateBlock(n.id,{props:{caption:c.currentTarget.value}})},[n,t]),a=d.useCallback(c=>{c.key==="Enter"&&!c.nativeEvent.isComposing&&(c.preventDefault(),i(!1))},[]);return n===void 0?null:r.jsxs(o.Generic.Popover.Root,{open:l,onOpenChange:i,children:[r.jsx(o.Generic.Popover.Trigger,{children:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_caption.tooltip,mainTooltip:e.formatting_toolbar.file_caption.tooltip,icon:r.jsx(Ue,{}),onClick:()=>i(c=>!c)})}),r.jsx(o.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(o.Generic.Form.Root,{children:r.jsx(o.Generic.Form.TextInput,{name:"file-caption",icon:r.jsx(Ue,{}),value:n.props.caption,autoFocus:!0,placeholder:e.formatting_toolbar.file_caption.input_placeholder,onKeyDown:a,onChange:s})})})]})},Jo=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:i})=>{if(!i.isEditable)return;let s=i.getSelection()?.blocks||[i.getTextCursorPosition().block];if(s.length!==1)return;let a=s[0];if(P(a,i,a.type,{url:"string"}))return a}}),l=d.useCallback(()=>{n!==void 0&&(t.focus(),t.removeBlocks([n.id]))},[n,t]);return n===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_delete.tooltip[n.type]||e.formatting_toolbar.file_delete.tooltip.file,mainTooltip:e.formatting_toolbar.file_delete.tooltip[n.type]||e.formatting_toolbar.file_delete.tooltip.file,icon:r.jsx(Vn,{}),onClick:l})},er=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:c})=>{if(!c.isEditable)return;let u=c.getSelection()?.blocks||[c.getTextCursorPosition().block];if(u.length!==1)return;let m=u[0];if(P(m,c,m.type,{url:"string",name:"string"}))return m}}),[l,i]=d.useState(!1),s=d.useCallback(c=>{n!==void 0&&U(t,n.type,{name:"string"})&&t.updateBlock(n.id,{props:{name:c.currentTarget.value}})},[n,t]),a=d.useCallback(c=>{c.key==="Enter"&&!c.nativeEvent.isComposing&&(c.preventDefault(),i(!1))},[]);return n===void 0?null:r.jsxs(o.Generic.Popover.Root,{open:l,onOpenChange:i,children:[r.jsx(o.Generic.Popover.Trigger,{children:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_rename.tooltip[n.type]||e.formatting_toolbar.file_rename.tooltip.file,mainTooltip:e.formatting_toolbar.file_rename.tooltip[n.type]||e.formatting_toolbar.file_rename.tooltip.file,icon:r.jsx(Ve,{}),onClick:()=>i(c=>!c)})}),r.jsx(o.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(o.Generic.Form.Root,{children:r.jsx(o.Generic.Form.TextInput,{name:"file-name",icon:r.jsx(Ve,{}),value:n.props.name,autoFocus:!0,placeholder:e.formatting_toolbar.file_rename.input_placeholder[n.type]||e.formatting_toolbar.file_rename.input_placeholder.file,onKeyDown:a,onChange:s})})})]})},tr=()=>{let e=k(),o=h(),t=E({editor:v(),selector:({editor:n})=>{if(!n.isEditable)return;let l=n.getSelection()?.blocks||[n.getTextCursorPosition().block];if(l.length!==1)return;let i=l[0];if(P(i,n,i.type,{url:"string"}))return i}});return t===void 0?null:r.jsxs(o.Generic.Popover.Root,{position:"bottom",children:[r.jsx(o.Generic.Popover.Trigger,{children:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",mainTooltip:e.formatting_toolbar.file_replace.tooltip[t.type]||e.formatting_toolbar.file_replace.tooltip.file,label:e.formatting_toolbar.file_replace.tooltip[t.type]||e.formatting_toolbar.file_replace.tooltip.file,icon:r.jsx(Un,{})})}),r.jsx(o.Generic.Popover.Content,{className:"bn-popover-content bn-panel-popover",variant:"panel-popover",children:r.jsx(Ot,{blockId:t.id})})]})},nr=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:i})=>{if(!(!i.isEditable||!(i.getSelection()?.blocks||[i.getTextCursorPosition().block]).find(s=>s.content!==void 0)))return{canNestBlock:i.canNestBlock()}}}),l=d.useCallback(()=>{n!==void 0&&n.canNestBlock&&(t.focus(),t.nestBlock())},[t,n]);return n===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button","data-test":"nestBlock",onClick:l,isDisabled:!n.canNestBlock,label:e.formatting_toolbar.nest.tooltip,mainTooltip:e.formatting_toolbar.nest.tooltip,secondaryTooltip:ge(e.formatting_toolbar.nest.secondary_tooltip,e.generic.ctrl_shortcut),icon:r.jsx(oo,{})})},or=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:i})=>{if(!(!i.isEditable||!(i.getSelection()?.blocks||[i.getTextCursorPosition().block]).find(s=>s.content!==void 0)))return{canUnnestBlock:i.canUnnestBlock()}}}),l=d.useCallback(()=>{n!==void 0&&n.canUnnestBlock&&(t.focus(),t.unnestBlock())},[t,n]);return n===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button","data-test":"unnestBlock",onClick:l,isDisabled:!n.canUnnestBlock,label:e.formatting_toolbar.unnest.tooltip,mainTooltip:e.formatting_toolbar.unnest.tooltip,secondaryTooltip:ge(e.formatting_toolbar.unnest.secondary_tooltip,e.generic.ctrl_shortcut),icon:r.jsx(ro,{})})},rr=e=>[{name:e.slash_menu.paragraph.title,type:"paragraph",icon:Pe},{name:e.slash_menu.heading.title,type:"heading",props:{level:1,isToggleable:!1},icon:ue},{name:e.slash_menu.heading_2.title,type:"heading",props:{level:2,isToggleable:!1},icon:de},{name:e.slash_menu.heading_3.title,type:"heading",props:{level:3,isToggleable:!1},icon:ce},{name:e.slash_menu.heading_4.title,type:"heading",props:{level:4,isToggleable:!1},icon:mt},{name:e.slash_menu.heading_5.title,type:"heading",props:{level:5,isToggleable:!1},icon:ut},{name:e.slash_menu.heading_6.title,type:"heading",props:{level:6,isToggleable:!1},icon:dt},{name:e.slash_menu.toggle_heading.title,type:"heading",props:{level:1,isToggleable:!0},icon:ue},{name:e.slash_menu.toggle_heading_2.title,type:"heading",props:{level:2,isToggleable:!0},icon:de},{name:e.slash_menu.toggle_heading_3.title,type:"heading",props:{level:3,isToggleable:!0},icon:ce},{name:e.slash_menu.quote.title,type:"quote",icon:ct},{name:e.slash_menu.toggle_list.title,type:"toggleListItem",icon:st},{name:e.slash_menu.bullet_list.title,type:"bulletListItem",icon:it},{name:e.slash_menu.numbered_list.title,type:"numberedListItem",icon:at},{name:e.slash_menu.check_list.title,type:"checkListItem",icon:lt}],lr=e=>{let o=h(),t=v(),n=E({editor:t,selector:({editor:a})=>a.getSelection()?.blocks||[a.getTextCursorPosition().block]}),l=n[0],i=d.useMemo(()=>(e.items||rr(t.dictionary)).filter(a=>U(t,a.type,Object.fromEntries(Object.entries(a.props||{}).map(([c,u])=>[c,typeof u])))),[t,e.items]),s=d.useMemo(()=>i.map(a=>{let c=a.icon,u=a.type===l.type,m=Object.entries(a.props||{}).filter(([p,g])=>g!==l.props[p]).length===0;return{text:a.name,icon:r.jsx(c,{size:16}),onClick:()=>{t.focus(),t.transact(()=>{for(let p of n)t.updateBlock(p,{type:a.type,props:a.props})})},isSelected:u&&m}}),[t,i,l.props,l.type,n]);return!d.useMemo(()=>s.find(a=>a.isSelected)!==void 0,[s])||!t.isEditable?null:r.jsx(o.FormattingToolbar.Select,{className:"bn-select",items:s})},ir=()=>{let e=k(),o=h(),t=w("comments"),{store:n}=w(Y),l=d.useCallback(()=>{t.startPendingComment(),n.setState(!1)},[t,n]);return r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:r.jsx(bt,{}),onClick:l})},ar=()=>v().getExtension("comments")?r.jsx(ir,{}):null,sr=()=>{let e=k(),o=h(),t=v(),n=d.useCallback(()=>{t._tiptapEditor.chain().focus().addPendingComment().run()},[t]);return!t._tiptapEditor.commands.addPendingComment||!t.isEditable?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.comment.tooltip,mainTooltip:e.formatting_toolbar.comment.tooltip,icon:r.jsx(bt,{}),onClick:n})};function Ie(e,o){try{let t=new URL(e,o);if(t.protocol!=="javascript:")return t.href}catch{}return"#"}var cr=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:i})=>{let s=i.getSelection()?.blocks||[i.getTextCursorPosition().block];if(s.length!==1)return;let a=s[0];if(P(a,i,a.type,{url:"string"}))return a}}),l=d.useCallback(()=>{n!==void 0&&(t.focus(),t.resolveFileUrl?t.resolveFileUrl(n.props.url).then(i=>window.open(Ie(i,window.location.href))):window.open(Ie(n.props.url,window.location.href)))},[n,t]);return n===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.file_download.tooltip[n.type]||e.formatting_toolbar.file_download.tooltip.file,mainTooltip:e.formatting_toolbar.file_download.tooltip[n.type]||e.formatting_toolbar.file_download.tooltip.file,icon:r.jsx(qn,{}),onClick:l})},dr=()=>{let e=k(),o=h(),t=v(),n=E({editor:t,selector:({editor:i})=>{if(!i.isEditable)return;let s=i.getSelection()?.blocks||[i.getTextCursorPosition().block];if(s.length!==1)return;let a=s[0];if(P(a,i,a.type,{url:"string",showPreview:"boolean"}))return a}}),l=d.useCallback(()=>{n!==void 0&&U(t,n.type,{showPreview:"boolean"})&&t.updateBlock(n.id,{props:{showPreview:!n.props.showPreview}})},[n,t]);return n===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:"Toggle preview",mainTooltip:e.formatting_toolbar.file_preview_toggle.tooltip,icon:r.jsx(Kn,{}),isSelected:n.props.showPreview,onClick:l})},ur=()=>{let e=k(),o=h(),t=v(),n=w(S),l=E({editor:t,selector:({editor:s})=>{if(!s.isEditable||!s.settings.tables.splitCells)return;let a=s.getSelection()?.blocks||[s.getTextCursorPosition().block];if(a.length!==1)return;let c=a[0];if(c.type==="table")return{mergeDirection:n.getMergeDirection(c)}}}),i=d.useCallback(()=>{n?.mergeCells()},[n]);return l===void 0?null:r.jsx(o.FormattingToolbar.Button,{className:"bn-button",label:e.formatting_toolbar.table_cell_merge.tooltip,mainTooltip:e.formatting_toolbar.table_cell_merge.tooltip,icon:l.mergeDirection==="horizontal"?r.jsx(lo,{}):r.jsx(io,{}),onClick:i})},mr=()=>v().getExtension(S)?r.jsx(ur,{}):null,pr={left:no,center:to,right:eo,justify:Jn},ke=e=>{let o=h(),t=k(),n=v(),l=E({editor:n,selector:({editor:a})=>{if(!a.isEditable)return;let c=a.getSelection()?.blocks||[a.getTextCursorPosition().block],u=c[0];if(P(u,a,u.type,{textAlignment:ie.textAlignment}))return{textAlignment:u.props.textAlignment,blocks:c};if(c.length===1&&P(u,a,"table"))return a.getExtension(S)?.getCellSelection()?{textAlignment:Z(u.content.rows[0].cells[0]).props.textAlignment,blocks:[u]}:void 0}}),i=d.useCallback(a=>{if(l!==void 0){n.focus();for(let c of l.blocks)if(P(c,n,c.type,{textAlignment:ie.textAlignment})&&U(n,c.type,{textAlignment:ie.textAlignment}))n.updateBlock(c,{props:{textAlignment:a}});else if(c.type==="table"){let u=n.getExtension(S)?.getCellSelection();if(!u)continue;let m=c.content.rows.map(p=>({...p,cells:p.cells.map(g=>Z(g))}));u.cells.forEach(({row:p,col:g})=>{m[p].cells[g].props.textAlignment=a}),n.updateBlock(c,{type:"table",content:{...c.content,type:"tableContent",rows:m}}),n.setTextCursorPosition(c)}}},[n,l]);if(l===void 0)return null;let s=pr[e.textAlignment];return r.jsx(o.FormattingToolbar.Button,{className:"bn-button","data-test":`alignText${e.textAlignment.slice(0,1).toUpperCase()+e.textAlignment.slice(1)}`,onClick:()=>i(e.textAlignment),isSelected:l.textAlignment===e.textAlignment,label:t.formatting_toolbar[`align_${e.textAlignment}`].tooltip,mainTooltip:t.formatting_toolbar[`align_${e.textAlignment}`].tooltip,icon:r.jsx(s,{})})},Dt=e=>[r.jsx(lr,{items:e},"blockTypeSelect"),r.jsx(mr,{},"tableCellMergeButton"),r.jsx(Xo,{},"fileCaptionButton"),r.jsx(tr,{},"replaceFileButton"),r.jsx(er,{},"fileRenameButton"),r.jsx(Jo,{},"fileDeleteButton"),r.jsx(cr,{},"fileDownloadButton"),r.jsx(dr,{},"filePreviewButton"),r.jsx(re,{basicTextStyle:"bold"},"boldStyleButton"),r.jsx(re,{basicTextStyle:"italic"},"italicStyleButton"),r.jsx(re,{basicTextStyle:"underline"},"underlineStyleButton"),r.jsx(re,{basicTextStyle:"strike"},"strikeStyleButton"),r.jsx(ke,{textAlignment:"left"},"textAlignLeftButton"),r.jsx(ke,{textAlignment:"center"},"textAlignCenterButton"),r.jsx(ke,{textAlignment:"right"},"textAlignRightButton"),r.jsx(Wo,{},"colorStyleButton"),r.jsx(nr,{},"nestBlockButton"),r.jsx(or,{},"unnestBlockButton"),r.jsx(Zo,{},"createLinkButton"),r.jsx(ar,{},"addCommentButton"),r.jsx(sr,{},"addTiptapCommentButton")],Lt=e=>r.jsx(h().FormattingToolbar.Root,{className:"bn-toolbar bn-formatting-toolbar",children:e.children||Dt(e.blockTypeSelectItems)}),gr=e=>{switch(e){case"left":return"top-start";case"center":return"top";case"right":return"top-end";default:return"top-start"}},At=e=>{let o=v(),t=w(Y,{editor:o}),n=y(Y,{editor:o}),l=E({editor:o,selector:({editor:c})=>t.store.state?{from:c.prosemirrorState.selection.from,to:c.prosemirrorState.selection.to}:void 0}),i=E({editor:o,selector:({editor:c})=>{let u=c.getTextCursorPosition().block;return P(u,c,u.type,{textAlignment:ie.textAlignment})?gr(u.props.textAlignment):"top-start"}}),s=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:n,onOpenChange:(c,u,m)=>{t.store.setState(c),m==="escape-key"&&o.focus()},placement:i,middleware:[A(10),J(),ee()],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:40},...e.floatingUIOptions?.elementProps}}),[n,i,e.floatingUIOptions,t.store,o]),a=e.formattingToolbar||Lt;return r.jsx(Fe,{position:l,...s,children:n&&r.jsx(a,{})})},br=e=>{let o=h(),t=k(),{deleteLink:n}=w(be);return r.jsx(o.LinkToolbar.Button,{className:"bn-button",label:t.link_toolbar.delete.tooltip,mainTooltip:t.link_toolbar.delete.tooltip,isSelected:!1,onClick:()=>{n(e.range.from),e.setToolbarOpen?.(!1)},icon:r.jsx(mo,{})})},fr=e=>{let o=h(),t=k();return r.jsxs(o.Generic.Popover.Root,{onOpenChange:e.setToolbarPositionFrozen,children:[r.jsx(o.Generic.Popover.Trigger,{children:r.jsx(o.LinkToolbar.Button,{className:"bn-button",mainTooltip:t.link_toolbar.edit.tooltip,isSelected:!1,children:t.link_toolbar.edit.text})}),r.jsx(o.Generic.Popover.Content,{className:"bn-popover-content bn-form-popover",variant:"form-popover",children:r.jsx(Ft,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen})})]})},hr=e=>{let o=h(),t=k();return r.jsx(o.LinkToolbar.Button,{className:"bn-button",mainTooltip:t.link_toolbar.open.tooltip,label:t.link_toolbar.open.tooltip,isSelected:!1,onClick:()=>{window.open(Ie(e.url,window.location.href),"_blank")},icon:r.jsx(uo,{})})},xr=e=>r.jsx(h().LinkToolbar.Root,{className:"bn-toolbar bn-link-toolbar",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(fr,{url:e.url,text:e.text,range:e.range,setToolbarOpen:e.setToolbarOpen,setToolbarPositionFrozen:e.setToolbarPositionFrozen}),r.jsx(hr,{url:e.url}),r.jsx(br,{range:e.range,setToolbarOpen:e.setToolbarOpen})]})}),vr=e=>{let o=v(),[t,n]=d.useState(!1),[l,i]=d.useState(!1),s=q(),a=w(be),[c,u]=d.useState(void 0);d.useEffect(()=>{let b=()=>{let T=a.getLinkAtSelection();if(!T){u(void 0),l||n(!1);return}u({cursorType:"text",url:T.mark.attrs.href,text:T.text,range:T.range,element:a.getLinkElementAtPos(T.range.from)}),l||n(!0)},f=T=>{if(c!==void 0&&c.cursorType==="text"||!(T.target instanceof HTMLElement))return;let I=a.getLinkAtElement(T.target);I&&u({cursorType:"mouse",url:I.mark.attrs.href,text:I.text,range:I.range,element:a.getLinkElementAtPos(I.range.from)})},x=o.onChange(b),C=o.onSelectionChange(b);return s?.addEventListener("mouseover",f),()=>{x(),C(),s?.removeEventListener("mouseover",f)}},[o,s,a,c,l]);let m=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:t,onOpenChange:(b,f,x)=>{l||c!==void 0&&c.cursorType==="text"&&x==="hover"||(x==="escape-key"&&o.focus(),n(b))},placement:"top-start",middleware:[A(10),ee()],...e.floatingUIOptions?.useFloatingOptions},useHoverProps:{enabled:c!==void 0&&c.cursorType==="mouse",delay:{open:250,close:250},handleClose:ao(),...e.floatingUIOptions?.useHoverProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:50},...e.floatingUIOptions?.elementProps}}),[o,c,e.floatingUIOptions,t,l]),p=d.useMemo(()=>c?.element?{element:c.element}:void 0,[c?.element]);if(!o.isEditable)return null;let g=e.linkToolbar||xr;return r.jsx(L,{reference:p,...m,children:c&&r.jsx(g,{url:c.url,text:c.text,range:c.range,setToolbarOpen:n,setToolbarPositionFrozen:i})})},Cr=()=>{let e=h(),o=k(),t=v(),n=w(z),l=y(D,{editor:t,selector:s=>s?.block}),i=d.useCallback(()=>{if(l===void 0)return;let s=l.content;if(s!==void 0&&Array.isArray(s)&&s.length===0)t.setTextCursorPosition(l),n.openSuggestionMenu("/");else{let a=t.insertBlocks([{type:"paragraph"}],l,"after")[0];t.setTextCursorPosition(a),n.openSuggestionMenu("/")}},[l,t,n]);return l===void 0?null:r.jsx(e.SideMenu.Button,{className:"bn-button",label:o.side_menu.add_block_label,icon:r.jsx(po,{size:24,onClick:i,"data-test":"dragHandleAdd"})})},kr=e=>{let o=h(),t=v(),n=y(D,{editor:t,selector:l=>l?.block});return n===void 0||!P(n,t,n.type,{textColor:"string"})&&!P(n,t,n.type,{backgroundColor:"string"})?null:r.jsxs(o.Generic.Menu.Root,{position:"right",sub:!0,children:[r.jsx(o.Generic.Menu.Trigger,{sub:!0,children:r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children})}),r.jsx(o.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(he,{iconSize:18,text:P(n,t,n.type,{textColor:"string"})&&U(t,n.type,{textColor:"string"})?{color:n.props.textColor,setColor:l=>t.updateBlock(n,{type:n.type,props:{textColor:l}})}:void 0,background:P(n,t,n.type,{backgroundColor:"string"})&&U(t,n.type,{backgroundColor:"string"})?{color:n.props.backgroundColor,setColor:l=>t.updateBlock(n,{props:{backgroundColor:l}})}:void 0})})]})},jr=e=>{let o=h(),t=v(),n=y(D,{editor:t,selector:l=>l?.block});return n===void 0?null:r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",onClick:()=>t.removeBlocks([n]),children:e.children})},wr=e=>{let o=h(),t=v(),n=y(D,{editor:t,selector:i=>i?.block});if(n===void 0||n.type!=="table"||!t.settings.tables.headers)return null;let l=!!n.content.headerRows;return r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",checked:l,onClick:()=>{t.updateBlock(n,{content:{...n.content,headerRows:l?void 0:1}})},children:e.children})},yr=e=>{let o=h(),t=v(),n=y(D,{editor:t,selector:i=>i?.block});if(n===void 0||n.type!=="table"||!t.settings.tables.headers)return null;let l=!!n.content.headerCols;return r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",checked:l,onClick:()=>{t.updateBlock(n,{content:{...n.content,headerCols:l?void 0:1}})},children:e.children})},Sr=e=>{let o=h(),t=k();return r.jsx(o.Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-drag-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(jr,{children:t.drag_handle.delete_menuitem}),r.jsx(kr,{children:t.drag_handle.colors_menuitem}),r.jsx(wr,{children:t.drag_handle.header_row_menuitem}),r.jsx(yr,{children:t.drag_handle.header_column_menuitem})]})})},Tr=e=>{let o=h(),t=k(),n=w(D),l=y(D,{selector:s=>s?.block});if(l===void 0)return null;let i=e.dragHandleMenu||Sr;return r.jsxs(o.Generic.Menu.Root,{onOpenChange:s=>{s?n.freezeMenu():n.unfreezeMenu()},position:"left",children:[r.jsx(o.Generic.Menu.Trigger,{children:r.jsx(o.SideMenu.Button,{label:t.side_menu.drag_handle_label,draggable:!0,onDragStart:s=>n.blockDragStart(s,l),onDragEnd:n.blockDragEnd,className:"bn-button",icon:r.jsx(ft,{size:24,"data-test":"dragHandle"})})}),r.jsx(i,{children:e.children})]})},_r=e=>{let o=h(),t=v(),n=y(D,{editor:t,selector:i=>i?.block}),l=d.useMemo(()=>{if(n===void 0)return{};let i={"data-block-type":n.type};return n.type==="heading"&&(i["data-level"]=n.props.level.toString()),t.schema.blockSpecs[n.type].implementation.meta?.fileBlockAccept&&(n.props.url?i["data-url"]="true":i["data-url"]="false"),i},[n,t.schema.blockSpecs]);return r.jsx(o.SideMenu.Root,{className:"bn-side-menu",...l,children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Cr,{}),r.jsx(Tr,{dragHandleMenu:e.dragHandleMenu})]})})},Rr=e=>{let o=v(),{show:t,block:n}=y(D,{selector:a=>a===void 0?void 0:{show:a.show,block:a.block}})||{},l=d.useCallback((a,c,u)=>{let m=!1;return Me(a,c,()=>{if(!m){m=!0;return}o.getExtension(D)?.hideMenuIfNotFrozen()},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[o]),i=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:t,placement:"left-start",whileElementsMounted:l,...e.floatingUIOptions?.useFloatingOptions},useDismissProps:{enabled:!1,...e.floatingUIOptions?.useDismissProps},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{style:{zIndex:20},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,t,l]),s=e.sideMenu||_r;return r.jsx(Bt,{blockId:t?n?.id:void 0,...i,children:n?.id&&r.jsx(s,{})})};async function Er(e,o){return(await cn(e,o)).map(({id:t,onItemClick:n})=>({id:t,onItemClick:n,icon:t}))}function Ir(e){let o=h(),t=k(),{items:n,loadingState:l,selectedIndex:i,onItemClick:s,columns:a}=e,c=l==="loading-initial"||l==="loading"?r.jsx(o.GridSuggestionMenu.Loader,{className:"bn-grid-suggestion-menu-loader",columns:a}):null,u=d.useMemo(()=>{let m=[];for(let p=0;p<n.length;p++){let g=n[p];m.push(r.jsx(o.GridSuggestionMenu.Item,{className:"bn-grid-suggestion-menu-item",item:g,id:`bn-grid-suggestion-menu-item-${p}`,isSelected:p===i,onClick:()=>s?.(g)},g.id))}return m},[o,n,s,i]);return r.jsxs(o.GridSuggestionMenu.Root,{id:"bn-grid-suggestion-menu",columns:a,className:"bn-grid-suggestion-menu",children:[c,u,u.length===0&&e.loadingState==="loaded"&&r.jsx(o.GridSuggestionMenu.EmptyItem,{className:"bn-grid-suggestion-menu-empty-item",columns:a,children:t.suggestion_menu.no_items_title})]})}function zt(e,o,t,n=3){let l=d.useRef(0);d.useEffect(()=>{o!==void 0&&(e.length>0?l.current=o.length:o.length-l.current>n&&t())},[t,n,e.length,o])}function Gt(e,o){let[t,n]=d.useState([]),[l,i]=d.useState(!1),s=d.useRef(void 0),a=d.useRef(void 0);return d.useEffect(()=>{let c=e;s.current=e,i(!0),o(e).then(u=>{s.current===c&&(n(u),i(!1),a.current=c)})},[e,o]),{items:t||[],usedQuery:a.current,loadingState:a.current===void 0?"loading-initial":l?"loading":"loaded"}}function Mr(e,o,t,n,l){let i=q(e),[s,a]=d.useState(0);return d.useEffect(()=>{let c=u=>(u.key==="ArrowLeft"&&(u.preventDefault(),t.length&&a((s-1+t.length)%t.length)),u.key==="ArrowRight"&&(u.preventDefault(),t.length&&a((s+1+t.length)%t.length)),u.key==="ArrowUp"?(u.preventDefault(),t.length&&a((s-n+t.length)%t.length),!0):u.key==="ArrowDown"?(u.preventDefault(),t.length&&a((s+n)%t.length),!0):u.key==="Enter"&&!u.isComposing?(u.stopPropagation(),u.preventDefault(),t.length&&l?.(t[s]),!0):!1);return i?.addEventListener("keydown",c,!0),()=>{i?.removeEventListener("keydown",c,!0)}},[i,t,s,l,n,n!==void 0&&n>1]),d.useEffect(()=>{a(0)},[o]),{selectedIndex:t.length===0?void 0:s}}function Pr(e){let o=O().setContentEditableProps,t=v(),{getItems:n,gridSuggestionMenuComponent:l,query:i,clearQuery:s,closeMenu:a,onItemClick:c,columns:u}=e,m=d.useCallback(x=>{a(),s(),c?.(x)},[c,a,s]),{items:p,usedQuery:g,loadingState:b}=Gt(i,n);zt(p,g,a);let{selectedIndex:f}=Mr(t,i,p,u,m);return d.useEffect(()=>(o(x=>({...x,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{o(x=>({...x,"aria-expanded":!1,"aria-controls":void 0}))}),[o]),d.useEffect(()=>(o(x=>({...x,"aria-activedescendant":f?"bn-suggestion-menu-item-"+f:void 0})),()=>{o(x=>({...x,"aria-activedescendant":void 0}))}),[o,f]),r.jsx(l,{items:p,onItemClick:m,loadingState:b,selectedIndex:f,columns:u})}function Nr(e){let o=v(),t=q(),{triggerCharacter:n,gridSuggestionMenuComponent:l,columns:i,shouldOpen:s,minQueryLength:a,onItemClick:c,getItems:u}=e,m=d.useMemo(()=>c||(C=>{C.onItemClick(o)}),[o,c]),p=d.useMemo(()=>u||(async C=>await Er(o,C)),[o,u]),g=w(z);d.useEffect(()=>{g.addSuggestionMenu({triggerCharacter:n,shouldOpen:s})},[g,n,s]);let b=y(z),f=y(z,{selector:C=>({element:t?.firstChild||void 0,getBoundingClientRect:()=>C?.referencePos||new DOMRect})}),x=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:b?.show&&b?.triggerCharacter===n,onOpenChange:C=>{C||g.closeMenu()},placement:"bottom-start",middleware:[A(10),rt({allowedPlacements:["bottom-start","top-start"],padding:10}),J(),se({apply({elements:C,availableHeight:T}){C.floating.style.maxHeight=`${Math.max(0,T)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:C=>C.preventDefault(),style:{zIndex:70},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,b?.show,b?.triggerCharacter,g,n]);return!b||!b.ignoreQueryLength&&a&&(b.query.startsWith(" ")||b.query.length<a)?null:r.jsx(L,{reference:f,...x,children:n&&r.jsx(Pr,{query:b.query,closeMenu:g.closeMenu,clearQuery:g.clearQuery,getItems:p,columns:i,gridSuggestionMenuComponent:l||Ir,onItemClick:m})})}function Br(e){let o=h(),t=k(),{items:n,loadingState:l,selectedIndex:i,onItemClick:s}=e,a=l==="loading-initial"||l==="loading"?r.jsx(o.SuggestionMenu.Loader,{className:"bn-suggestion-menu-loader"}):null,c=d.useMemo(()=>{let u,m=[];for(let p=0;p<n.length;p++){let g=n[p];g.group!==u&&(u=g.group,m.push(r.jsx(o.SuggestionMenu.Label,{className:"bn-suggestion-menu-label",children:u},u))),m.push(r.jsx(o.SuggestionMenu.Item,{className:R("bn-suggestion-menu-item",g.size==="small"?"bn-suggestion-menu-item-small":""),item:g,id:`bn-suggestion-menu-item-${p}`,isSelected:p===i,onClick:()=>s?.(g)},g.title))}return m},[o,n,s,i]);return r.jsxs(o.SuggestionMenu.Root,{id:"bn-suggestion-menu",className:"bn-suggestion-menu",children:[c,c.length===0&&(e.loadingState==="loading"||e.loadingState==="loaded")&&r.jsx(o.SuggestionMenu.EmptyItem,{className:"bn-suggestion-menu-item",children:t.suggestion_menu.no_items_title}),a]})}function Or(e,o){let[t,n]=d.useState(0);return{selectedIndex:t,setSelectedIndex:n,handler:l=>{if(l.key==="ArrowUp")return l.preventDefault(),e.length&&n((t-1+e.length)%e.length),!0;if(l.key==="ArrowDown")return l.preventDefault(),e.length&&n((t+1)%e.length),!0;if(l.key==="PageUp")return l.preventDefault(),e.length&&n(0),!0;if(l.key==="PageDown")return l.preventDefault(),e.length&&n(e.length-1),!0;let i=Fr(l)?l.nativeEvent.isComposing:l.isComposing;return l.key==="Enter"&&!i?(l.preventDefault(),l.stopPropagation(),e.length&&o?.(e[t]),!0):!1}}}function Fr(e){return e.nativeEvent!==void 0}function Dr(e,o,t,n,l){let i=q(),{selectedIndex:s,setSelectedIndex:a,handler:c}=Or(t,n);return d.useEffect(()=>{let u=i;return u?.addEventListener("keydown",c,!0),()=>{u?.removeEventListener("keydown",c,!0)}},[i,t,s,n,l,c]),d.useEffect(()=>{a(0)},[o,a]),{selectedIndex:t.length===0?void 0:s}}function Lr(e){let o=O().setContentEditableProps,t=v(),{getItems:n,suggestionMenuComponent:l,query:i,clearQuery:s,closeMenu:a,onItemClick:c}=e,u=d.useCallback(f=>{a(),s(),c?.(f)},[c,a,s]),{items:m,usedQuery:p,loadingState:g}=Gt(i,n);zt(m,p,a);let{selectedIndex:b}=Dr(t,i,m,u);return d.useEffect(()=>(o(f=>({...f,"aria-expanded":!0,"aria-controls":"bn-suggestion-menu"})),()=>{o(f=>({...f,"aria-expanded":!1,"aria-controls":void 0}))}),[o]),d.useEffect(()=>(o(f=>({...f,"aria-activedescendant":b?"bn-suggestion-menu-item-"+b:void 0})),()=>{o(f=>({...f,"aria-activedescendant":void 0}))}),[o,b]),r.jsx(l,{items:m,onItemClick:u,loadingState:g,selectedIndex:b})}var Ar={heading:ue,heading_2:de,heading_3:ce,heading_4:mt,heading_5:ut,heading_6:dt,toggle_heading:ue,toggle_heading_2:de,toggle_heading_3:ce,quote:ct,toggle_list:st,numbered_list:at,bullet_list:it,check_list:lt,paragraph:Pe,table:Hn,image:$n,video:Gn,audio:zn,file:An,emoji:Ln,code_block:Dn,divider:Fn};function zr(e){return on(e).map(o=>{let t=Ar[o.key];return{...o,icon:r.jsx(t,{size:18})}})}function Gr(e){let o=v(),t=q(),{triggerCharacter:n,suggestionMenuComponent:l,shouldOpen:i,minQueryLength:s,onItemClick:a,getItems:c}=e,u=d.useMemo(()=>a||(x=>{x.onItemClick(o)}),[o,a]),m=d.useMemo(()=>c||(async x=>nn(zr(o),x)),[o,c]),p=w(z);d.useEffect(()=>{p.addSuggestionMenu({triggerCharacter:n,shouldOpen:i})},[p,n,i]);let g=y(z),b=y(z,{selector:x=>({element:t?.firstChild||void 0,getBoundingClientRect:()=>x?.referencePos||new DOMRect})}),f=d.useMemo(()=>({...e.floatingUIOptions,useFloatingOptions:{open:g?.show&&g?.triggerCharacter===n,onOpenChange:x=>{x||p.closeMenu()},placement:"bottom-start",middleware:[A(10),rt({allowedPlacements:["bottom-start","top-start"],padding:10}),J(),se({apply({elements:x,availableHeight:C}){x.floating.style.maxHeight=`${Math.max(0,C)}px`},padding:10})],...e.floatingUIOptions?.useFloatingOptions},focusManagerProps:{disabled:!0,...e.floatingUIOptions?.focusManagerProps},elementProps:{onMouseDownCapture:x=>x.preventDefault(),style:{zIndex:80},...e.floatingUIOptions?.elementProps}}),[e.floatingUIOptions,g?.show,g?.triggerCharacter,p,n]);return!g||!g.ignoreQueryLength&&s&&(g.query.startsWith(" ")||g.query.length<s)?null:r.jsx(L,{reference:b,...f,children:n&&r.jsx(Lr,{query:g.query,closeMenu:p.closeMenu,clearQuery:p.clearQuery,getItems:m,suggestionMenuComponent:l||Br,onItemClick:u})})}var $r=(e,o=.3)=>{let t=Math.floor(e)+o,n=Math.ceil(e)-o;return e>=t&&e<=n?Math.round(e):e<t?Math.floor(e):Math.ceil(e)},Hr=e=>{let o=h(),t=v(),n=w(S),l=y(S,{selector:m=>m?.block}),i=d.useRef(!1),[s,a]=d.useState(),c=d.useCallback(m=>{n.freezeHandles(),e.hideOtherElements(!0),l&&(a({originalContent:l.content,originalCroppedContent:{rows:n.cropEmptyRowsOrColumns(l,e.orientation==="addOrRemoveColumns"?"columns":"rows")},startPos:e.orientation==="addOrRemoveColumns"?m.clientX:m.clientY}),i.current=!1,m.preventDefault())},[l,e,n]),u=d.useCallback(()=>{!l||i.current||t.updateBlock(l,{type:"table",content:{...l.content,rows:e.orientation==="addOrRemoveColumns"?n.addRowsOrColumns(l,"columns",1):n.addRowsOrColumns(l,"rows",1)}})},[l,t,e.orientation,n]);return d.useEffect(()=>{let m=p=>{if(!l)return;if(!s)throw Error("editingState is undefined");i.current=!0;let g=(e.orientation==="addOrRemoveColumns"?p.clientX:p.clientY)-s.startPos,b=e.orientation==="addOrRemoveColumns"?s.originalCroppedContent.rows[0]?.cells.length??0:s.originalCroppedContent.rows.length,f=e.orientation==="addOrRemoveColumns"?s.originalContent.rows[0]?.cells.length??0:s.originalContent.rows.length,x=e.orientation==="addOrRemoveColumns"?l.content.rows[0].cells.length:l.content.rows.length,C=f+$r(g/(e.orientation==="addOrRemoveColumns"?dn:un),.3);C>=b&&C>0&&C!==x&&(t.updateBlock(l,{type:"table",content:{...l.content,rows:e.orientation==="addOrRemoveColumns"?n.addRowsOrColumns({type:"table",content:s.originalCroppedContent},"columns",C-b):n.addRowsOrColumns({type:"table",content:s.originalCroppedContent},"rows",C-b)}}),l.content&&t.setTextCursorPosition(l))};return s&&window.addEventListener("mousemove",m),()=>{window.removeEventListener("mousemove",m)}},[l,s,t,e.orientation,n]),d.useEffect(()=>{let m=()=>{e.hideOtherElements(!1),n.unfreezeHandles(),a(void 0)};return s&&window.addEventListener("mouseup",m),()=>{window.removeEventListener("mouseup",m)}},[s,e,n]),t.isEditable?r.jsx(o.TableHandle.ExtendButton,{className:R("bn-extend-button",e.orientation==="addOrRemoveColumns"?"bn-extend-button-add-remove-columns":"bn-extend-button-add-remove-rows",s===null?"":"bn-extend-button-editing"),onClick:u,onMouseDown:c,children:e.children||r.jsx(so,{size:18,"data-test":"extendButton"})}):null},Ur=e=>{let o=h(),t=k(),n=v(),{block:l,colIndex:i,rowIndex:s}=y(S,{selector:u=>({block:u?.block,colIndex:u?.colIndex,rowIndex:u?.rowIndex})}),a=(u,m)=>{if(l===void 0||i===void 0||s===void 0)return;let p=l.content.rows.map(g=>({...g,cells:g.cells.map(b=>Z(b))}));m==="text"?p[s].cells[i].props.textColor=u:p[s].cells[i].props.backgroundColor=u,n.updateBlock(l,{type:"table",content:{...l.content,rows:p}}),n.setTextCursorPosition(l)};if(l===void 0||i===void 0||s===void 0)return null;let c=l.content.rows[s]?.cells?.[i];return!c||n.settings.tables.cellTextColor===!1&&n.settings.tables.cellBackgroundColor===!1?null:r.jsxs(o.Generic.Menu.Root,{position:"right",sub:!0,children:[r.jsx(o.Generic.Menu.Trigger,{sub:!0,children:r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children||t.drag_handle.colors_menuitem})}),r.jsx(o.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(he,{iconSize:18,text:n.settings.tables.cellTextColor?{color:X(c)?c.props.textColor:"default",setColor:u=>a(u,"text")}:void 0,background:n.settings.tables.cellBackgroundColor?{color:X(c)?c.props.backgroundColor:"default",setColor:u=>a(u,"background")}:void 0})})]})},Vr=()=>{let e=h(),o=k(),t=v(),n=w(S),{block:l,colIndex:i,rowIndex:s}=y(S,{selector:c=>({block:c?.block,colIndex:c?.colIndex,rowIndex:c?.rowIndex})});if(l===void 0||i===void 0||s===void 0)return null;let a=l.content.rows[s]?.cells?.[i];return!a||!X(a)||nt(a)===1&&tt(a)===1||!t.settings.tables.splitCells?null:r.jsx(e.Generic.Menu.Item,{onClick:()=>{n.splitCell({row:s,col:i})},children:o.table_handle.split_cell_menuitem})},qr=e=>r.jsx(h().Generic.Menu.Dropdown,{className:"bn-menu-dropdown bn-table-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Vr,{}),r.jsx(Ur,{})]})}),Kr=e=>{let o=h(),t=v(),n=w(S),l=e.tableCellMenu||qr;return!t.settings.tables.splitCells&&!t.settings.tables.cellBackgroundColor&&!t.settings.tables.cellTextColor?null:r.jsxs(o.Generic.Menu.Root,{onOpenChange:i=>{i?(n.freezeHandles(),e.hideOtherElements(!0)):(n.unfreezeHandles(),e.hideOtherElements(!1),t.focus())},position:"right",children:[r.jsx(o.Generic.Menu.Trigger,{children:r.jsx(o.Generic.Menu.Button,{className:"bn-table-cell-handle",children:e.children||r.jsx(co,{size:12,"data-test":"tableCellHandle"})})}),r.jsx(l,{})]})},Ze=e=>{let o=h(),t=k(),n=w(S),l=y(S,{selector:i=>e.orientation==="column"?i?.colIndex:i?.rowIndex});return n===void 0||l===void 0?null:r.jsx(o.Generic.Menu.Item,{onClick:()=>{n.addRowOrColumn(l,e.orientation==="row"?{orientation:"row",side:e.side}:{orientation:"column",side:e.side})},children:t.table_handle[`add_${e.side}_menuitem`]})},Qr=e=>{let o=h(),t=k(),n=w(S),l=y(S,{selector:i=>e.orientation==="column"?i?.colIndex:i?.rowIndex});return n===void 0||l===void 0?null:r.jsx(o.Generic.Menu.Item,{onClick:()=>n.removeRowOrColumn(l,e.orientation),children:e.orientation==="row"?t.table_handle.delete_row_menuitem:t.table_handle.delete_column_menuitem})},Wr=e=>{let o=h(),t=k(),n=v(),l=w(S),{block:i,index:s}=y(S,{selector:m=>({block:m?.block,index:e.orientation==="column"?m?.colIndex:m?.rowIndex})}),a=d.useMemo(()=>l===void 0||i===void 0||s===void 0?[]:e.orientation==="row"?l.getCellsAtRowHandle(i,s):l.getCellsAtColumnHandle(i,s),[i,s,e.orientation,l]),c=(m,p)=>{if(i===void 0)return;let g=i.content.rows.map(b=>({...b,cells:b.cells.map(f=>Z(f))}));a.forEach(({row:b,col:f})=>{p==="text"?g[b].cells[f].props.textColor=m:g[b].cells[f].props.backgroundColor=m}),n.updateBlock(i,{type:"table",content:{...i.content,rows:g}}),n.setTextCursorPosition(i)};if(!a||!a[0]||!l||n.settings.tables.cellTextColor===!1&&n.settings.tables.cellBackgroundColor===!1)return null;let u=Z(a[0].cell);return r.jsxs(o.Generic.Menu.Root,{position:"right",sub:!0,children:[r.jsx(o.Generic.Menu.Trigger,{sub:!0,children:r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",subTrigger:!0,children:e.children||t.drag_handle.colors_menuitem})}),r.jsx(o.Generic.Menu.Dropdown,{sub:!0,className:"bn-menu-dropdown bn-color-picker-dropdown",children:r.jsx(he,{iconSize:18,text:n.settings.tables.cellTextColor?{color:a.every(({cell:m})=>X(m)&&m.props.textColor===u.props.textColor)?u.props.textColor:"default",setColor:m=>{c(m,"text")}}:void 0,background:n.settings.tables.cellBackgroundColor?{color:a.every(({cell:m})=>X(m)&&m.props.backgroundColor===u.props.backgroundColor)?u.props.backgroundColor:"default",setColor:m=>c(m,"background")}:void 0})})]})},Yr=e=>{let o=h(),t=k(),n=v(),l=w(S),{block:i,index:s}=y(S,{selector:c=>({block:c?.block,index:e.orientation==="column"?c?.colIndex:c?.rowIndex})});if(l===void 0||i===void 0||s!==0||e.orientation!=="row"||!n.settings.tables.headers)return null;let a=!!i.content.headerRows;return r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",checked:a,onClick:()=>{n.updateBlock(i,{...i,content:{...i.content,headerRows:a?void 0:1}})},children:t.drag_handle.header_row_menuitem})},Zr=e=>{let o=h(),t=k(),n=v(),l=w(S),i=y(S,{selector:c=>c?.block}),s=y(S,{selector:c=>e.orientation==="column"?c?.colIndex:c?.rowIndex});if(!l||s!==0||!i||e.orientation!=="column"||!n.settings.tables.headers)return null;let a=!!i.content.headerCols;return r.jsx(o.Generic.Menu.Item,{className:"bn-menu-item",checked:a,onClick:()=>{n.updateBlock(i,{...i,content:{...i.content,headerCols:a?void 0:1}})},children:t.drag_handle.header_column_menuitem})},Xr=e=>r.jsx(h().Generic.Menu.Dropdown,{className:"bn-table-handle-menu",children:e.children||r.jsxs(r.Fragment,{children:[r.jsx(Qr,{orientation:e.orientation}),r.jsx(Ze,{orientation:e.orientation,side:e.orientation==="row"?"above":"left"}),r.jsx(Ze,{orientation:e.orientation,side:e.orientation==="row"?"below":"right"}),r.jsx(Yr,{orientation:e.orientation}),r.jsx(Zr,{orientation:e.orientation}),r.jsx(Wr,{orientation:e.orientation})]})}),Jr=e=>{let o=v(),t=h(),[n,l]=d.useState(!1),i=e.tableHandleMenu||Xr,s=w(S),a=y(S),c=d.useMemo(()=>!s||!a||!a.block||a.block.type!=="table"?!1:e.orientation==="column"?s.getCellsAtColumnHandle(a.block,a.colIndex).every(({cell:u})=>tt(u)===1):s.getCellsAtRowHandle(a.block,a.rowIndex).every(({cell:u})=>nt(u)===1),[e.orientation,a,s]);return a?r.jsxs(t.Generic.Menu.Root,{onOpenChange:u=>{u?(s.freezeHandles(),e.hideOtherElements(!0)):(s.unfreezeHandles(),e.hideOtherElements(!1),o.focus())},position:"right",children:[r.jsx(t.Generic.Menu.Trigger,{children:r.jsx(t.TableHandle.Root,{className:R("bn-table-handle",n?"bn-table-handle-dragging":"",c?"":"bn-table-handle-not-draggable"),draggable:c,onDragStart:u=>{l(!0),e.hideOtherElements(!0),e.orientation==="column"?s.colDragStart(u):s.rowDragStart(u)},onDragEnd:()=>{s.dragEnd(),e.hideOtherElements(!1),l(!1)},style:e.orientation==="column"?{transform:"rotate(0.25turn)"}:void 0,children:e.children||r.jsx(ft,{size:24,"data-test":"tableHandle"})})}),r.jsx(i,{orientation:e.orientation})]}):null},el=e=>{let o=v(),[t,n]=d.useState(),l=y(S),i=d.useMemo(()=>{let p={};if(l===void 0)return{};let g=et(l.block.id,o.prosemirrorState.doc);if(!g)return{};let b=g.posBeforeNode+1,f=o.prosemirrorView.domAtPos(b+1).node;if(!(f instanceof Element))return{};if(p.tableReference={element:f},l.rowIndex===void 0||l.colIndex===void 0)return p;let x=o.prosemirrorState.doc.resolve(b+1).posAtIndex(l.rowIndex),C=o.prosemirrorState.doc.resolve(x+1).posAtIndex(l.colIndex),T=o.prosemirrorView.domAtPos(C+1).node;return T instanceof Element?(p.cellReference={element:T},p.rowReference={element:f,getBoundingClientRect:()=>{let I=f.getBoundingClientRect(),F=T.getBoundingClientRect();return new DOMRect(I.x,l.draggingState&&l.draggingState.draggedCellOrientation==="row"?l.draggingState.mousePos-F.height/2:F.y,I.width,F.height)}},p.columnReference={element:f,getBoundingClientRect:()=>{let I=f.getBoundingClientRect(),F=T.getBoundingClientRect();return new DOMRect(l.draggingState&&l.draggingState.draggedCellOrientation==="col"?l.draggingState.mousePos-F.width/2:F.x,I.y,F.width,I.height)}},p):{}},[o,l]),s=d.useCallback((p,g,b)=>{let f=!1;return Me(p,g,()=>{if(!f){f=!0;return}o.getExtension(S)?.hideHandlesIfNotFrozen()},{ancestorScroll:!0,ancestorResize:!1,elementResize:!1,layoutShift:!1})},[o]),a=d.useMemo(()=>l===void 0?void 0:{rowTableHandle:{useFloatingOptions:{open:l.show&&l.rowIndex!==void 0&&(!t||t==="rowTableHandle"),placement:"left",middleware:[A(-10)],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},columnTableHandle:{useFloatingOptions:{open:l.show&&l.colIndex!==void 0&&(!t||t==="columnTableHandle"),placement:"top",middleware:[A(-12)],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},tableCellHandle:{useFloatingOptions:{open:l.show&&l.rowIndex!==void 0&&l.colIndex!==void 0&&(!t||t==="tableCellHandle"),placement:"top-end",middleware:[A({mainAxis:-15,crossAxis:-1})],whileElementsMounted:s},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendRowsButton:{useFloatingOptions:{open:l.show&&l.showAddOrRemoveRowsButton&&(!t||t==="extendRowsButton"),placement:"bottom",whileElementsMounted:s,middleware:[se({apply({rects:p,elements:g}){Object.assign(g.floating.style,{width:`${p.reference.width}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}},extendColumnsButton:{useFloatingOptions:{open:l.show&&l.showAddOrRemoveColumnsButton&&(!t||t==="extendColumnsButton"),placement:"right",whileElementsMounted:s,middleware:[se({apply({rects:p,elements:g}){Object.assign(g.floating.style,{height:`${p.reference.height}px`})}})]},focusManagerProps:{disabled:!0},elementProps:{style:{zIndex:10}}}},[t,l,s]);if(!l)return null;let c=e.tableHandle||Jr,u=e.extendButton||Hr,m=e.tableCellHandle||Kr;return r.jsxs(r.Fragment,{children:[r.jsx(L,{reference:i?.rowReference,...a?.rowTableHandle,children:l.show&&l.rowIndex!==void 0&&(!t||t==="rowTableHandle")&&r.jsx(c,{orientation:"row",hideOtherElements:p=>n(p?"rowTableHandle":void 0)})}),r.jsx(L,{reference:i?.columnReference,...a?.columnTableHandle,children:l.show&&l.colIndex!==void 0&&(!t||t==="columnTableHandle")&&r.jsx(c,{orientation:"column",hideOtherElements:p=>n(p?"columnTableHandle":void 0)})}),r.jsx(L,{reference:i?.cellReference,...a?.tableCellHandle,children:l.show&&l.rowIndex!==void 0&&l.colIndex!==void 0&&(!t||t==="tableCellHandle")&&r.jsx(m,{hideOtherElements:p=>n(p?"tableCellHandle":void 0)})}),r.jsx(L,{reference:i?.tableReference,...a?.extendRowsButton,children:l.show&&l.showAddOrRemoveRowsButton&&(!t||t==="extendRowsButton")&&r.jsx(u,{orientation:"addOrRemoveRows",hideOtherElements:p=>n(p?"extendRowsButton":void 0)})}),r.jsx(L,{reference:i?.tableReference,...a?.extendColumnsButton,children:l.show&&l.showAddOrRemoveColumnsButton&&(!t||t==="extendColumnsButton")&&r.jsx(u,{orientation:"addOrRemoveColumns",hideOtherElements:p=>n(p?"extendColumnsButton":void 0)})})]})},tl=d.lazy(()=>me(()=>Promise.resolve().then(()=>Ho),void 0).then(e=>e.n)),nl=d.lazy(()=>me(()=>Promise.resolve().then(()=>Go),void 0).then(e=>e.n));function ol(e){let o=v();if(!o)throw Error("BlockNoteDefaultUI must be used within a BlockNoteContext.Provider");return r.jsxs(r.Fragment,{children:[o.getExtension(Y)&&e.formattingToolbar!==!1&&r.jsx(At,{}),o.getExtension(be)&&e.linkToolbar!==!1&&r.jsx(vr,{}),o.getExtension(z)&&e.slashMenu!==!1&&r.jsx(Gr,{triggerCharacter:"/",shouldOpen:t=>!t.selection.$from.parent.type.isInGroup("tableContent")}),o.getExtension(z)&&e.emojiPicker!==!1&&r.jsx(Nr,{triggerCharacter:":",columns:10,minQueryLength:2}),o.getExtension(D)&&e.sideMenu!==!1&&r.jsx(Rr,{}),o.getExtension(_e)&&e.filePanel!==!1&&r.jsx(qo,{}),o.getExtension(S)&&e.tableHandles!==!1&&r.jsx(el,{}),o.getExtension(B)&&e.comments!==!1&&r.jsxs(d.Suspense,{children:[r.jsx(tl,{}),r.jsx(nl,{})]})]})}function rl(e,o){let t=O();o||=t?.editor,d.useEffect(()=>{if(!o)throw Error("'editor' is required, either from BlockNoteContext or as a function argument");return o.onChange(e)},[e,o])}function ll(e,o,t){let n=O();o||=n?.editor,d.useEffect(()=>{if(!o)throw Error("'editor' is required, either from BlockNoteContext or as a function argument");return o.onSelectionChange(e,t)},[e,o,t])}var $t=()=>{let e=d.useMemo(()=>window.matchMedia?.("(prefers-color-scheme: dark)"),[]),o=d.useMemo(()=>window.matchMedia?.("(prefers-color-scheme: light)"),[]),t=e?.matches,n=o?.matches,[l,i]=d.useState(t?"dark":n?"light":"no-preference");return d.useEffect(()=>{i(t?"dark":n?"light":"no-preference")},[t,n]),d.useEffect(()=>{if(typeof e?.addEventListener=="function"){let s=({matches:c})=>c&&i("dark"),a=({matches:c})=>c&&i("light");return e?.addEventListener("change",s),o?.addEventListener("change",a),()=>{e?.removeEventListener("change",s),o?.removeEventListener("change",a)}}else{let s=()=>i(e.matches?"dark":o.matches?"light":"no-preference");return e?.addEventListener("change",s),o?.addEventListener("change",s),()=>{e?.removeEventListener("change",s),o?.removeEventListener("change",s)}}},[e,o]),l},Ht=d.createContext(void 0);function il(){return d.useContext(Ht)}function al(){let e=new Set,o={};return{subscribe(t){return e.add(t),()=>{e.delete(t)}},getSnapshot(){return o},getServerSnapshot(){return o},setRenderer(t,n){o={...o,[t]:ae.createPortal(n.reactElement,n.element,t)},e.forEach(l=>l())},removeRenderer(t){let n={...o};delete n[t],o=n,e.forEach(l=>l())}}}var sl=({contentComponent:e})=>{let o=d.useSyncExternalStore(e.subscribe,e.getSnapshot,e.getServerSnapshot);return r.jsx(r.Fragment,{children:Object.values(o)})},cl=d.forwardRef((e,o)=>{let[t,n]=d.useState();return d.useImperativeHandle(o,()=>(l,i)=>{ae.flushSync(()=>{n({node:l,container:i})}),n(void 0)},[]),r.jsx(r.Fragment,{children:t&&ae.createPortal(t.node,t.container)})}),Xe=()=>{};function dl(e,o){let{editor:t,className:n,theme:l,children:i,editable:s,onSelectionChange:a,onChange:c,formattingToolbar:u,linkToolbar:m,slashMenu:p,emojiPicker:g,sideMenu:b,filePanel:f,tableHandles:x,comments:C,autoFocus:T,renderEditor:I=!0,...F}=e,[Q,te]=d.useState(),K=O(),ne=$t(),xe=K?.colorSchemePreference||ne,G=l||(xe==="dark"?"dark":"light"),_=h(),H=d.useMemo(()=>({formattingToolbar:_?u:!1,linkToolbar:_?m:!1,sideMenu:_?b:!1,slashMenu:_?p:!1,filePanel:_?f:!1,tableHandles:_?x:!1,emojiPicker:_?g:!1,comments:_?C:!1}),[C,_,g,f,u,m,b,p,x]);rl(c||Xe,t),ll(a||Xe,t);let Kt=d.useCallback(Yt=>{t.elementRenderer=Yt},[t]);d.useEffect(()=>{if(!t.portalElement)throw Error("Portal element not found");t.portalElement.className=R("bn-root",G,n||""),t.portalElement.setAttribute("data-color-scheme",G)},[t,G,n]);let Qt=d.useMemo(()=>({...K,editor:t,setContentEditableProps:te,colorSchemePreference:G}),[K,t,G]),Wt=d.useMemo(()=>({editorProps:{autoFocus:T,contentEditableProps:Q,editable:s},defaultUIProps:H}),[T,Q,s,H]);return r.jsx(yt.Provider,{value:Qt,children:r.jsxs(Ht.Provider,{value:Wt,children:[r.jsx(cl,{ref:Kt}),r.jsx(ul,{className:n,renderEditor:I,editorColorScheme:G,ref:o,...F,children:i})]})})}var ul=pe.forwardRef(({className:e,renderEditor:o,editorColorScheme:t,children:n,...l},i)=>r.jsx("div",{className:R("bn-root","bn-container",t,e),"data-color-scheme":t,...l,ref:i,children:o?r.jsx(pl,{children:n}):n})),ml=pe.forwardRef(dl),pl=e=>{let o=il(),t=v(),n=d.useMemo(()=>al(),[]),l=d.useCallback(i=>{t.isEditable=o.editorProps.editable!==!1,t._tiptapEditor.contentComponent=n,i?t.mount(i):t.unmount()},[o.editorProps.editable,t,n]);return r.jsxs(r.Fragment,{children:[r.jsx(sl,{contentComponent:n}),r.jsx(gl,{...o.editorProps,...e,mount:l}),r.jsx(ol,{...o.defaultUIProps}),e.children]})},gl=e=>{let{autoFocus:o,mount:t,contentEditableProps:n}=e;return r.jsx("div",{"aria-autocomplete":"list","aria-haspopup":"listbox","data-bn-autofocus":o,ref:t,...n})};function W(e,o){let t,n=document.createElement("div"),l;if(o?.elementRenderer)o.elementRenderer(e(c=>t=c||void 0),n);else{if(!o?.headless)throw Error("elementRenderer not available, expected headless editor");l=Mo.createRoot(n),ae.flushSync(()=>{l.render(e(c=>t=c||void 0))})}if(!n.childElementCount)return console.warn("ReactInlineContentSpec: renderHTML() failed"),{dom:document.createElement("span")};t?.setAttribute("data-tmp-find","true");let i=n.cloneNode(!0),s=i.firstElementChild,a=i.querySelector("[data-tmp-find]");return a?.removeAttribute("data-tmp-find"),l?.unmount(),{dom:s,contentDOM:a||void 0}}function je(e){return r.jsx(xt,{onDragOver:o=>o.preventDefault(),...Object.fromEntries(Object.entries(e.domAttributes||{}).filter(([o])=>o!=="class")),className:R("bn-block-content",e.domAttributes?.class||""),"data-content-type":e.blockType,...Object.fromEntries(Object.entries(e.blockProps).filter(([o,t])=>t!==e.propSchema[o].default).map(([o,t])=>[ot(o),t])),"data-file-block":e.isFileBlock===!0||void 0,children:e.children})}function pi(e,o,t){return(n={})=>{let l=typeof e=="function"?e(n):e,i=typeof o=="function"?o(n):o,s=t?typeof t=="function"?t(n):t:void 0;return{config:l,implementation:{...i,toExternalHTML(a,c,u){let m=i.toExternalHTML||i.render;return W(p=>r.jsx(je,{blockType:a.type,blockProps:a.props,propSchema:l.propSchema,domAttributes:this.blockContentDOMAttributes,isFileBlock:i.meta?.fileBlockAccept!==void 0,children:r.jsx(m,{block:a,editor:c,contentRef:g=>{p(g),g&&(g.className=R("bn-inline-content",g.className))},context:u})}),c)},render(a,c){if(this.renderType==="nodeView")return pt(u=>{let m=mn(u.getPos,c,u.editor,l.type),p=ht().nodeViewContentRef;if(!p)throw Error("nodeViewContentRef is not set");let g=i.render;return r.jsx(je,{blockType:m.type,blockProps:m.props,propSchema:l.propSchema,isFileBlock:!!i.meta?.fileBlockAccept,domAttributes:this.blockContentDOMAttributes,children:r.jsx(g,{block:m,editor:c,contentRef:b=>{p(b),b&&(b.className=R("bn-inline-content",b.className),b.dataset.nodeViewContent="")}})})},{className:"bn-react-node-view-renderer"})(this.props);{let u=i.render;return W(m=>r.jsx(je,{blockType:a.type,blockProps:a.props,propSchema:l.propSchema,domAttributes:this.blockContentDOMAttributes,children:r.jsx(u,{block:a,editor:c,contentRef:p=>{m(p),p&&(p.className=R("bn-inline-content",p.className))}})}),c)}}},extensions:s}}}pe.memo(({thread:e,selectedThreadId:o,maxCommentsBeforeCollapse:t,referenceText:n})=>{let l=w(B),i=d.useCallback(a=>{a.target.closest(".bn-action-toolbar")||l.selectThread(e.id)},[l,e.id]),s=d.useCallback(a=>{if(!a.relatedTarget||a.relatedTarget.closest(".bn-action-toolbar"))return;let c=a.target instanceof Node?a.target:null,u=a.relatedTarget instanceof Node?a.relatedTarget.closest(".bn-thread"):null;(!c||!u||!u.contains(c))&&l.selectThread(void 0)},[l]);return r.jsx(ze,{thread:e,selected:e.id===o,referenceText:n,maxCommentsBeforeCollapse:t,onFocus:i,onBlur:s,tabIndex:0})});function we(e){return r.jsx(xt,{as:"span",className:"bn-inline-content-section","data-inline-content-type":e.inlineContentType,...Object.fromEntries(Object.entries(e.inlineContentProps).filter(([o,t])=>t!==e.propSchema[o].default).map(([o,t])=>[ot(o),t])),children:e.children})}function gi(e,o){let t=go.create({name:e.type,inline:!0,group:"inline",selectable:e.content==="styled",atom:e.content==="none",draggable:o.meta?.draggable,content:e.content==="styled"?"inline*":"",addAttributes(){return hn(e.propSchema)},addKeyboardShortcuts(){return fn(e)},parseHTML(){return bn(e,o.parse)},renderHTML({node:n}){let l=this.options.editor,i=$e(n,l.schema.inlineContentSchema,l.schema.styleSchema),s=o.toExternalHTML||o.render;return gn(W(a=>r.jsx(s,{contentRef:c=>{a(c),c&&(c.dataset.editable="")},inlineContent:i,updateInlineContent:()=>{},editor:l}),l),e.type,n.attrs,e.propSchema)},addNodeView(){let n=this.options.editor;return l=>pt(i=>{let s=ht().nodeViewContentRef;if(!s)throw Error("nodeViewContentRef is not set");let a=o.render;return r.jsx(we,{inlineContentProps:i.node.attrs,inlineContentType:e.type,propSchema:e.propSchema,children:r.jsx(a,{contentRef:c=>{s(c),c&&(c.dataset.editable="")},editor:n,inlineContent:$e(i.node,n.schema.inlineContentSchema,n.schema.styleSchema),updateInlineContent:c=>{let u=pn([c],n.pmSchema),m=i.getPos();m!==void 0&&n.transact(p=>p.replaceWith(m,m+i.node.nodeSize,u))}})})},{className:"bn-ic-react-node-view-renderer",as:"span"})(l)}});return xn(e,{...o,node:t,render(n,l,i){let s=o.render;return W(a=>r.jsx(we,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:r.jsx(s,{contentRef:c=>{a(c),c&&(c.dataset.editable="")},editor:i,inlineContent:n,updateInlineContent:l})}),i)},toExternalHTML(n,l){let i=o.toExternalHTML||o.render;return W(s=>r.jsx(we,{inlineContentProps:n.props,inlineContentType:e.type,propSchema:e.propSchema,children:r.jsx(i,{contentRef:a=>{s(a),a&&(a.dataset.editable="")},editor:l,inlineContent:n,updateInlineContent:()=>{}})}),l)}})}function Ut(e,o){let t=e.getBoundingClientRect(),n=o.getBoundingClientRect(),l=t.top<n.top,i=t.bottom>n.bottom;return l&&i?"both":l?"top":i?"bottom":"none"}function bl(e){return o=>{e.forEach(t=>{typeof t=="function"?t(o):t!=null&&(t.current=o)})}}var Vt=(e,o,t=!1)=>{let n=[];function l(i,s="--bn"){for(let a in i){let c=`${s}-${a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase()}`;typeof i[a]=="object"?l(i[a],c):(typeof i[a]=="number"&&(i[a]=`${i[a]}px`),t?o.style.removeProperty(c):o.style.setProperty(c,i[a].toString()))}}return l(e),n},Je=(e,o)=>Vt(e,o),fl={colors:{editor:{text:void 0,background:void 0},menu:{text:void 0,background:void 0},tooltip:{text:void 0,background:void 0},hovered:{text:void 0,background:void 0},selected:{text:void 0,background:void 0},disabled:{text:void 0,background:void 0},shadow:void 0,border:void 0,sideMenu:void 0,highlights:{gray:{text:void 0,background:void 0},brown:{text:void 0,background:void 0},red:{text:void 0,background:void 0},orange:{text:void 0,background:void 0},yellow:{text:void 0,background:void 0},green:{text:void 0,background:void 0},blue:{text:void 0,background:void 0},purple:{text:void 0,background:void 0},pink:{text:void 0,background:void 0}}},borderRadius:void 0,fontFamily:void 0},hl=e=>Vt(fl,e,!0),qt=e=>r.jsxs(Oe,{gap:0,className:"bn-tooltip",children:[r.jsx($,{size:"sm",lineClamp:5,children:e.mainTooltip}),e.secondaryTooltip&&r.jsx($,{size:"xs",lineClamp:5,children:e.secondaryTooltip})]}),ye=d.forwardRef((e,o)=>{let{className:t,children:n,mainTooltip:l,secondaryTooltip:i,icon:s,isSelected:a,isDisabled:c,onClick:u,label:m,variant:p,...g}=e;j(g,!1);let[b,f]=d.useState(!1),x=n?r.jsx(V,{"aria-label":m,className:t,onMouseDown:C=>{Re()&&C.currentTarget.focus()},onClick:C=>{f(!0),u?.(C)},onPointerLeave:()=>f(!1),"aria-pressed":a,"data-selected":a||void 0,"data-test":l?l.slice(0,1).toLowerCase()+l.replace(/\s+/g,"").slice(1):void 0,size:p==="compact"?"compact-xs":"xs",disabled:c||!1,ref:o,...g,children:n}):r.jsx(Ne,{className:t,"aria-label":m,onMouseDown:C=>{Re()&&C.currentTarget.focus()},onClick:C=>{f(!0),u?.(C)},onPointerLeave:()=>f(!1),"aria-pressed":a,"data-selected":a||void 0,"data-test":l?l.slice(0,1).toLowerCase()+l.replace(/\s+/g,"").slice(1):void 0,size:p==="compact"?20:30,disabled:c||!1,ref:o,...g,children:s});return l?r.jsx(kt,{disabled:b,withinPortal:!1,label:r.jsx(qt,{mainTooltip:l,secondaryTooltip:i}),children:x}):x}),xl=d.forwardRef((e,o)=>{let{className:t,text:n,icon:l,isSelected:i,mainTooltip:s,secondaryTooltip:a,onClick:c,onMouseEnter:u,...m}=e;j(m,!1);let[p,g]=d.useState(!1),b=r.jsxs(Io,{className:t,checked:i===!0,wrapperProps:{onMouseEnter:u,onMouseLeave:()=>g(!1),onClick:f=>{g(!0),c?.(f)}},variant:"light",icon:null,ref:o,children:[r.jsx("span",{children:l}),r.jsx("span",{children:n})]});return!s||p?b:r.jsx(kt,{refProp:"rootRef",withinPortal:!1,label:r.jsx(qt,{mainTooltip:s,secondaryTooltip:a}),children:b})}),vl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l),r.jsx(M,{className:t,ref:o,children:n})}),Cl=d.forwardRef((e,o)=>{let{className:t,children:n,headerText:l,selected:i,onFocus:s,onBlur:a,tabIndex:c,...u}=e;return j(u,!1),r.jsxs(vt,{className:R(t,i?"selected":""),onFocus:s,onBlur:a,tabIndex:c,ref:o,children:[l&&r.jsx($,{className:"bn-header-text",children:l}),n]})}),kl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l,!1),r.jsx(vt.Section,{className:t,ref:o,children:n})}),jl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l,!1),r.jsx(ho,{className:t,label:r.jsx($,{children:n}),ref:o})}),wl=d.forwardRef((e,o)=>{let{authorInfo:t,timeString:n,edited:l,...i}=e,s=k();return j(i,!1),t==="loading"?r.jsxs(M,{children:[r.jsx(qe,{height:24,width:24}),r.jsx("div",{children:r.jsx(qe,{height:12,width:100})})]}):r.jsxs(M,{children:[r.jsx(Eo,{src:t.avatarUrl,alt:t.username,radius:"xl",size:"sm",color:"initials"}),r.jsxs($,{fz:"sm",fw:"bold",children:[t.username,r.jsxs($,{fz:"xs",c:"dimmed",span:!0,ml:"xs",children:[n," ",l&&`(${s.comments.edited})`]})]})]})}),yl=d.forwardRef((e,o)=>{let{className:t,showActions:n,authorInfo:l,timeString:i,edited:s,actions:a,emojiPickerOpen:c,children:u,...m}=e,{hovered:p,ref:g}=xo(),b=bl([o,g]);return j(m,!1),r.jsxs(M,{pos:"relative",ref:b,className:t,children:[a&&(n===!0||n===void 0||n==="hover"&&p||c)?r.jsx(M,{style:{position:"absolute",right:0,top:0,zIndex:10},children:a}):null,r.jsx(wl,{...e}),u]})}),Sl=d.forwardRef((e,o)=>{let{className:t,autoFocus:n,onFocus:l,onBlur:i,editor:s,editable:a,...c}=e;j(c,!1);let u=O();return r.jsx(ri,{autoFocus:n,className:t,editor:e.editor,sideMenu:!1,slashMenu:!1,tableHandles:!1,filePanel:!1,formattingToolbar:!1,editable:a,theme:u?.colorSchemePreference,ref:o,onFocus:l,onBlur:i,children:r.jsx(At,{formattingToolbar:Tl})})}),Tl=()=>r.jsx(Lt,{blockTypeSelectItems:[],children:Dt([]).filter(e=>e.key!=="nestBlockButton"&&e.key!=="unnestBlockButton")}),_l=d.forwardRef((e,o)=>{let{className:t,name:n,label:l,variant:i,icon:s,value:a,autoFocus:c,placeholder:u,disabled:m,onKeyDown:p,onChange:g,onSubmit:b,autoComplete:f,"aria-activedescendant":x,rightSection:C,...T}=e;return j(T),r.jsx(jt,{size:"xs",className:R(t||"",i==="large"?"bn-mt-input-large":""),ref:o,name:n,label:l,leftSection:s,value:a,autoFocus:c,"data-autofocus":c?"true":void 0,rightSection:C,placeholder:u,disabled:m,onKeyDown:p,onChange:g,onSubmit:b,autoComplete:f,"aria-activedescendant":x})}),Rl=d.createContext(void 0),El=e=>{let{children:o,onOpenChange:t,position:n,sub:l,...i}=e;return j(i),l?r.jsx(N.Sub,{transitionProps:{duration:250,exitDelay:250},withinPortal:!1,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:t,position:n,children:o}):r.jsx(N,{withinPortal:!1,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},onChange:t,position:n,returnFocus:!1,children:o})},Il=d.forwardRef((e,o)=>{let{className:t,children:n,icon:l,checked:i,subTrigger:s,onClick:a,...c}=e;return j(c,!1),r.jsx(s?N.Sub.Item:N.Item,{className:t,ref:o,leftSection:l,rightSection:i?r.jsx(Ct,{size:10}):i===!1?r.jsx("div",{className:"bn-tick-space"}):null,onClick:a,...c,children:n})}),Ml=e=>{let{children:o,sub:t,...n}=e;return j(n),r.jsx(t?N.Sub.Target:N.Target,{children:o})},Pl=d.forwardRef((e,o)=>{let{className:t,children:n,sub:l,...i}=e;j(i);let s=d.useContext(Rl);return r.jsx(l?N.Sub.Dropdown:N.Dropdown,{className:t,ref:o,onMouseOver:s?.onMenuMouseOver,onMouseLeave:s?.onMenuMouseLeave,children:n})}),Nl=d.forwardRef((e,o)=>{let{className:t,...n}=e;return j(n),r.jsx(N.Divider,{className:t,ref:o})}),Bl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l),r.jsx(N.Label,{className:t,ref:o,children:n})}),Ol=d.forwardRef((e,o)=>{let{className:t,children:n,icon:l,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,label:u,...m}=e;return j(m,!1),l?r.jsx(Ne,{size:24,className:t,ref:o,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,"aria-label":u,...m,children:l}):r.jsx(V,{className:t,ref:o,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,"aria-label":u,...m,children:n})}),Fl=d.forwardRef((e,o)=>{let{className:t,tabs:n,defaultOpenTab:l,openTab:i,setOpenTab:s,loading:a,...c}=e;return j(c),r.jsx(M,{className:t,ref:o,children:r.jsxs(oe,{value:i,defaultValue:l,onChange:s,children:[a&&r.jsx(Ro,{visible:a}),r.jsx(oe.List,{children:n.map(u=>r.jsx(oe.Tab,{"data-test":`${u.name.toLowerCase()}-tab`,value:u.name,children:u.name},u.name))}),n.map(u=>r.jsx(oe.Panel,{value:u.name,children:u.tabPanel},u.name))]})})}),Dl=d.forwardRef((e,o)=>{let{className:t,children:n,onClick:l,label:i,...s}=e;return j(s),r.jsx(V,{size:"xs","aria-label":i,className:t,ref:o,onClick:l,...s,children:n})}),Ll=d.forwardRef((e,o)=>{let{className:t,accept:n,value:l,placeholder:i,onChange:s,...a}=e;return j(a),r.jsx(_o,{size:"xs",className:t,ref:o,accept:n,value:l,placeholder:i,onChange:s,...a})}),Al=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l),r.jsx("div",{className:t,ref:o,children:n})}),zl=d.forwardRef((e,o)=>{let{className:t,value:n,placeholder:l,onKeyDown:i,onChange:s,...a}=e;return j(a),r.jsx(jt,{size:"xs","data-test":"embed-input",className:t,ref:o,value:n,placeholder:l,onKeyDown:i,onChange:s})}),Gl=e=>{let{open:o,onOpenChange:t,position:n,portalRoot:l,children:i,...s}=e;return j(s),r.jsx(So,{middlewares:{size:{padding:20}},withinPortal:!!l,portalProps:l?{target:l}:void 0,opened:o,onChange:t,position:n,children:i})},$l=e=>{let{children:o,...t}=e;return j(t),r.jsx(yo,{children:o})},Hl=d.forwardRef((e,o)=>{let{className:t,children:n,variant:l,...i}=e;return j(i),r.jsx(wo,{className:t,ref:o,children:n})}),Ul=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l,!1),r.jsx(M,{align:"center",gap:0,className:t,ref:o,...l,children:n})}),Vl=d.forwardRef((e,o)=>{let{className:t,children:n,icon:l,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,label:u,...m}=e;return j(m,!1),l?r.jsx(Ne,{size:24,className:t,ref:o,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,"aria-label":u,...m,children:l}):r.jsx(V,{className:t,ref:o,onClick:i,onDragEnd:s,onDragStart:a,draggable:c,"aria-label":u,...m,children:n})}),ql=d.forwardRef((e,o)=>{let{className:t,children:n,id:l,...i}=e;return j(i),r.jsx(Oe,{gap:0,className:t,ref:o,id:l,role:"listbox",children:n})}),Kl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l),r.jsx(M,{className:t,ref:o,children:r.jsx(M,{className:"bn-mt-suggestion-menu-item-title",children:n})})}),Ql=d.forwardRef((e,o)=>{let{className:t,isSelected:n,onClick:l,item:i,id:s,...a}=e;j(a);let c=d.useRef(null);return d.useEffect(()=>{!c.current||!n||Ut(c.current,c.current.closest(".bn-suggestion-menu, #ai-suggestion-menu"))!=="none"&&c.current.scrollIntoView({block:"nearest"})},[n]),r.jsxs(M,{gap:0,className:t,ref:Be(o,c),id:s,role:"option",onMouseDown:u=>u.preventDefault(),onClick:l,"aria-selected":n||void 0,children:[i.icon&&r.jsx(M,{className:"bn-mt-suggestion-menu-item-section","data-position":"left",children:i.icon}),r.jsxs(Oe,{gap:0,className:"bn-mt-suggestion-menu-item-body",children:[r.jsx($,{className:"bn-mt-suggestion-menu-item-title",children:i.title}),r.jsx($,{className:"bn-mt-suggestion-menu-item-subtitle",children:i.subtext})]}),i.badge&&r.jsx(M,{"data-position":"right",className:"bn-mt-suggestion-menu-item-section",children:r.jsx(To,{size:"xs",children:i.badge})})]})}),Wl=d.forwardRef((e,o)=>{let{className:t,children:n,...l}=e;return j(l),r.jsx(M,{className:t,ref:o,children:n})}),Yl=d.forwardRef((e,o)=>{let{className:t,...n}=e;return j(n),r.jsx(wt,{className:t,type:"dots",size:16,ref:o})}),Zl=d.forwardRef((e,o)=>{let{className:t,children:n,id:l,columns:i,...s}=e;return j(s),r.jsx("div",{className:t,style:{gridTemplateColumns:`repeat(${i}, 1fr)`},ref:o,id:l,role:"grid",children:n})}),Xl=d.forwardRef((e,o)=>{let{className:t,children:n,columns:l,...i}=e;return j(i),r.jsx(M,{className:t,style:{gridColumn:`1 / ${l+1}`},ref:o,children:r.jsx(M,{className:"bn-mt-suggestion-menu-item-title",children:n})})}),Jl=d.forwardRef((e,o)=>{let{className:t,isSelected:n,onClick:l,item:i,id:s,...a}=e;j(a);let c=d.useRef(null);return d.useEffect(()=>{!c.current||!n||Ut(c.current,c.current.closest(".bn-grid-suggestion-menu"))!=="none"&&c.current.scrollIntoView({block:"nearest"})},[n]),r.jsx("div",{className:t,ref:Be(o,c),id:s,role:"option",onClick:l,"aria-selected":n||void 0,children:i.icon})}),ei=d.forwardRef((e,o)=>{let{className:t,children:n,columns:l,...i}=e;return j(i),r.jsx(wt,{className:t,style:{gridColumn:`1 / ${l+1}`},type:"dots",ref:o})}),ti=d.forwardRef((e,o)=>{let{children:t,className:n,onMouseDown:l,onClick:i,...s}=e;return j(s,!1),r.jsx(V,{className:n,ref:o,onMouseDown:l,onClick:i,...s,children:t})}),ni=d.forwardRef((e,o)=>{let{className:t,children:n,draggable:l,onDragStart:i,onDragEnd:s,style:a,label:c,...u}=e;return j(u,!1),r.jsx(V,{className:t,ref:o,"aria-label":c,draggable:l,onDragStart:i,onDragEnd:s,style:a,...u,children:n})}),Se=d.forwardRef((e,o)=>{let{className:t,children:n,onMouseEnter:l,onMouseLeave:i,variant:s,...a}=e;j(a);let{ref:c,focused:u}=Co();return r.jsx(ko,{className:t,ref:Be(o,c,jo(u)),role:"toolbar",onMouseEnter:l,onMouseLeave:i,gap:s==="action-toolbar"?2:void 0,children:n})}),Te=d.forwardRef((e,o)=>{let{className:t,items:n,isDisabled:l,...i}=e;j(i);let s=n.filter(a=>a.isSelected)[0];return s?r.jsxs(N,{withinPortal:!1,transitionProps:{exitDuration:0},disabled:l,middlewares:{flip:!0,shift:!0,inline:!1,size:!0},children:[r.jsx(N.Target,{children:r.jsx(V,{onMouseDown:a=>{Re()&&a.currentTarget.focus()},leftSection:s.icon,rightSection:r.jsx(vo,{}),size:"xs",variant:"subtle",disabled:l,children:s.text})}),r.jsx(N.Dropdown,{className:t,ref:o,children:n.map(a=>r.jsx(N.Item,{onClick:a.onClick,leftSection:a.icon,rightSection:a.isSelected?r.jsx(Ct,{size:10,className:"bn-tick-icon"}):r.jsx("div",{className:"bn-tick-space"}),disabled:a.isDisabled,children:a.text},a.text))})]}):null}),oi={FormattingToolbar:{Root:Se,Button:ye,Select:Te},FilePanel:{Root:Fl,Button:Dl,FileInput:Ll,TabPanel:Al,TextInput:zl},GridSuggestionMenu:{Root:Zl,Item:Jl,EmptyItem:Xl,Loader:ei},LinkToolbar:{Root:Se,Button:ye,Select:Te},SideMenu:{Root:Ul,Button:Vl},SuggestionMenu:{Root:ql,Item:Ql,EmptyItem:Kl,Label:Wl,Loader:Yl},TableHandle:{Root:ni,ExtendButton:ti},Generic:{Badge:{Root:xl,Group:vl},Form:{Root:e=>r.jsx("div",{children:e.children}),TextInput:_l},Menu:{Root:El,Trigger:Ml,Dropdown:Pl,Divider:Nl,Label:Bl,Item:Il,Button:Ol},Popover:{Root:Gl,Trigger:$l,Content:Hl},Toolbar:{Root:Se,Button:ye,Select:Te}},Comments:{Comment:yl,Editor:Sl,Card:Cl,CardSection:kl,ExpandSectionsPrompt:jl}},ri=e=>{let{className:o,theme:t,editor:n,...l}=e,i=O(),s=$t(),a=i?.colorSchemePreference||s,c=typeof t=="string"?t:a==="no-preference"?"light":a,u=d.useCallback(g=>{if(g&&(hl(g),typeof t=="object")){if("light"in t&&"dark"in t){Je(t[a==="dark"?"dark":"light"],g);return}Je(t,g);return}},[a,t]);d.useEffect(()=>{if(!n.portalElement)throw Error("Portal element not found");n.portalElement.setAttribute("data-mantine-color-scheme",c),u(n.portalElement)},[n,u,c]);let m=d.useContext(bo),p=r.jsx(St.Provider,{value:oi,children:r.jsx(ml,{"data-mantine-color-scheme":c,className:R("bn-mantine",o||""),theme:typeof t=="object"?void 0:t,editor:n,...l,ref:u})});return m?p:r.jsx(fo,{withCssVariables:!1,getRootElement:()=>{},children:p})};export{De as K,gi as L,v as M,pi as Z,ri as a,Gr as h,zr as m};