@madie/madie-design-system 1.2.97 → 1.2.98

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 (213) hide show
  1. package/components/RichTextEditor/test.html +1 -0
  2. package/dist/browser.js +1 -1
  3. package/dist/index.js +1 -1
  4. package/madie-madie-design-system-1.2.96.tgz +0 -0
  5. package/madie-madie-design-system-1.2.98.tgz +0 -0
  6. package/package.json +1 -1
  7. package/storybook-static/1005.b918c97b.iframe.bundle.js +3 -0
  8. package/storybook-static/1005.b918c97b.iframe.bundle.js.LICENSE.txt +1 -0
  9. package/storybook-static/1005.b918c97b.iframe.bundle.js.map +1 -0
  10. package/storybook-static/1236.098e1cb2.iframe.bundle.js +2 -0
  11. package/storybook-static/1236.098e1cb2.iframe.bundle.js.map +1 -0
  12. package/storybook-static/139.ac2799e4.iframe.bundle.js +3 -0
  13. package/storybook-static/139.ac2799e4.iframe.bundle.js.LICENSE.txt +26 -0
  14. package/storybook-static/139.ac2799e4.iframe.bundle.js.map +1 -0
  15. package/storybook-static/1984.6b4e50ae.iframe.bundle.js +2 -0
  16. package/storybook-static/1984.6b4e50ae.iframe.bundle.js.map +1 -0
  17. package/storybook-static/2543.31cbf114.iframe.bundle.js +3 -0
  18. package/storybook-static/2543.31cbf114.iframe.bundle.js.LICENSE.txt +8 -0
  19. package/storybook-static/2543.31cbf114.iframe.bundle.js.map +1 -0
  20. package/storybook-static/2862.571661b6.iframe.bundle.js +2 -0
  21. package/storybook-static/2862.571661b6.iframe.bundle.js.map +1 -0
  22. package/storybook-static/2902.1a427f9a.iframe.bundle.js +2 -0
  23. package/storybook-static/2902.1a427f9a.iframe.bundle.js.map +1 -0
  24. package/storybook-static/2984.7fe13753.iframe.bundle.js +2 -0
  25. package/storybook-static/2984.7fe13753.iframe.bundle.js.map +1 -0
  26. package/storybook-static/312.c4693e73.iframe.bundle.js +3 -0
  27. package/storybook-static/312.c4693e73.iframe.bundle.js.LICENSE.txt +17 -0
  28. package/storybook-static/312.c4693e73.iframe.bundle.js.map +1 -0
  29. package/storybook-static/3666.a04121c4.iframe.bundle.js +2 -0
  30. package/storybook-static/3666.a04121c4.iframe.bundle.js.map +1 -0
  31. package/storybook-static/4197.408fcd63.iframe.bundle.js +2 -0
  32. package/storybook-static/4197.408fcd63.iframe.bundle.js.map +1 -0
  33. package/storybook-static/442.81ce93b1.iframe.bundle.js +2 -0
  34. package/storybook-static/442.81ce93b1.iframe.bundle.js.map +1 -0
  35. package/storybook-static/5161.8a31ff0b.iframe.bundle.js +3 -0
  36. package/storybook-static/5161.8a31ff0b.iframe.bundle.js.LICENSE.txt +8 -0
  37. package/storybook-static/5161.8a31ff0b.iframe.bundle.js.map +1 -0
  38. package/storybook-static/5238.c4a8e283.iframe.bundle.js +2 -0
  39. package/storybook-static/5238.c4a8e283.iframe.bundle.js.map +1 -0
  40. package/storybook-static/6294.8381ed88.iframe.bundle.js +2 -0
  41. package/storybook-static/6294.8381ed88.iframe.bundle.js.map +1 -0
  42. package/storybook-static/6728.48097498.iframe.bundle.js +185 -0
  43. package/storybook-static/6728.48097498.iframe.bundle.js.LICENSE.txt +8 -0
  44. package/storybook-static/6728.48097498.iframe.bundle.js.map +1 -0
  45. package/storybook-static/7148.1912a15a.iframe.bundle.js +3 -0
  46. package/storybook-static/7148.1912a15a.iframe.bundle.js.LICENSE.txt +27 -0
  47. package/storybook-static/7148.1912a15a.iframe.bundle.js.map +1 -0
  48. package/storybook-static/7364.0bbb17e6.iframe.bundle.js +1 -0
  49. package/storybook-static/7368.edc8102e.iframe.bundle.js +3 -0
  50. package/storybook-static/7368.edc8102e.iframe.bundle.js.LICENSE.txt +7 -0
  51. package/storybook-static/7368.edc8102e.iframe.bundle.js.map +1 -0
  52. package/storybook-static/7608.5925882a.iframe.bundle.js +2 -0
  53. package/storybook-static/7608.5925882a.iframe.bundle.js.map +1 -0
  54. package/storybook-static/7648.5ac43950.iframe.bundle.js +2 -0
  55. package/storybook-static/7648.5ac43950.iframe.bundle.js.map +1 -0
  56. package/storybook-static/7674.58735d56.iframe.bundle.js +3 -0
  57. package/storybook-static/7674.58735d56.iframe.bundle.js.LICENSE.txt +21 -0
  58. package/storybook-static/7674.58735d56.iframe.bundle.js.map +1 -0
  59. package/storybook-static/8552.33b568fb.iframe.bundle.js +10 -0
  60. package/storybook-static/8552.33b568fb.iframe.bundle.js.LICENSE.txt +14 -0
  61. package/storybook-static/8552.33b568fb.iframe.bundle.js.map +1 -0
  62. package/storybook-static/8609.28d04d51.iframe.bundle.js +3 -0
  63. package/storybook-static/8609.28d04d51.iframe.bundle.js.LICENSE.txt +11 -0
  64. package/storybook-static/8609.28d04d51.iframe.bundle.js.map +1 -0
  65. package/storybook-static/8936.ecc13c90.iframe.bundle.js +2 -0
  66. package/storybook-static/8936.ecc13c90.iframe.bundle.js.map +1 -0
  67. package/storybook-static/8980.64c0d3f1.iframe.bundle.js +2 -0
  68. package/storybook-static/8980.64c0d3f1.iframe.bundle.js.map +1 -0
  69. package/storybook-static/9269.8bb04a59.iframe.bundle.js +2 -0
  70. package/storybook-static/9269.8bb04a59.iframe.bundle.js.map +1 -0
  71. package/storybook-static/9425.89de0c76.iframe.bundle.js +2 -0
  72. package/storybook-static/9425.89de0c76.iframe.bundle.js.map +1 -0
  73. package/storybook-static/961.3d25a584.iframe.bundle.js +3 -0
  74. package/storybook-static/961.3d25a584.iframe.bundle.js.LICENSE.txt +17 -0
  75. package/storybook-static/961.3d25a584.iframe.bundle.js.map +1 -0
  76. package/storybook-static/9646.75583d09.iframe.bundle.js +2 -0
  77. package/storybook-static/9646.75583d09.iframe.bundle.js.map +1 -0
  78. package/storybook-static/9822.ff44564b.iframe.bundle.js +2 -0
  79. package/storybook-static/9822.ff44564b.iframe.bundle.js.map +1 -0
  80. package/storybook-static/9878.85fd7dab.iframe.bundle.js +95 -0
  81. package/storybook-static/9878.85fd7dab.iframe.bundle.js.LICENSE.txt +8 -0
  82. package/storybook-static/9878.85fd7dab.iframe.bundle.js.map +1 -0
  83. package/storybook-static/Accordion-Accordion-stories.0c0bc5e9.iframe.bundle.js +2 -0
  84. package/storybook-static/Accordion-Accordion-stories.0c0bc5e9.iframe.bundle.js.map +1 -0
  85. package/storybook-static/Alert-Alert-stories.b50ecf37.iframe.bundle.js +2 -0
  86. package/storybook-static/Alert-Alert-stories.b50ecf37.iframe.bundle.js.map +1 -0
  87. package/storybook-static/AutoComplete-AutoComplete-stories.c19f10c7.iframe.bundle.js +2 -0
  88. package/storybook-static/AutoComplete-AutoComplete-stories.c19f10c7.iframe.bundle.js.map +1 -0
  89. package/storybook-static/Breadcrumb-Breadcrumb-stories.dc6d7542.iframe.bundle.js +2 -0
  90. package/storybook-static/Breadcrumb-Breadcrumb-stories.dc6d7542.iframe.bundle.js.map +1 -0
  91. package/storybook-static/Button-Button-stories.d72e6d80.iframe.bundle.js +2 -0
  92. package/storybook-static/Button-Button-stories.d72e6d80.iframe.bundle.js.map +1 -0
  93. package/storybook-static/CalloutBox-CalloutBox-stories.ba542174.iframe.bundle.js +2 -0
  94. package/storybook-static/CalloutBox-CalloutBox-stories.ba542174.iframe.bundle.js.map +1 -0
  95. package/storybook-static/Card-Card-stories.91f76acb.iframe.bundle.js +2 -0
  96. package/storybook-static/Card-Card-stories.91f76acb.iframe.bundle.js.map +1 -0
  97. package/storybook-static/DateField-DateField-stories.bbe464e1.iframe.bundle.js +2 -0
  98. package/storybook-static/DateField-DateField-stories.bbe464e1.iframe.bundle.js.map +1 -0
  99. package/storybook-static/DateTimeField-DateTimeField-stories.d00a350a.iframe.bundle.js +2 -0
  100. package/storybook-static/DateTimeField-DateTimeField-stories.d00a350a.iframe.bundle.js.map +1 -0
  101. package/storybook-static/Dropdown-Dropdown-stories.2c72dbc5.iframe.bundle.js +2 -0
  102. package/storybook-static/Dropdown-Dropdown-stories.2c72dbc5.iframe.bundle.js.map +1 -0
  103. package/storybook-static/Footer-Footer-stories.ec274928.iframe.bundle.js +2 -0
  104. package/storybook-static/Footer-Footer-stories.ec274928.iframe.bundle.js.map +1 -0
  105. package/storybook-static/Infotip-Infotip-stories.3a2e9151.iframe.bundle.js +2 -0
  106. package/storybook-static/Infotip-Infotip-stories.3a2e9151.iframe.bundle.js.map +1 -0
  107. package/storybook-static/Instant-Instant-stories.d4d3b917.iframe.bundle.js +2 -0
  108. package/storybook-static/Instant-Instant-stories.d4d3b917.iframe.bundle.js.map +1 -0
  109. package/storybook-static/Link-Link-stories.e4a40f96.iframe.bundle.js +2 -0
  110. package/storybook-static/Link-Link-stories.e4a40f96.iframe.bundle.js.map +1 -0
  111. package/storybook-static/MadieAlert-MadieAlert-stories.ff732f0b.iframe.bundle.js +3 -0
  112. package/storybook-static/MadieAlert-MadieAlert-stories.ff732f0b.iframe.bundle.js.LICENSE.txt +5 -0
  113. package/storybook-static/MadieAlert-MadieAlert-stories.ff732f0b.iframe.bundle.js.map +1 -0
  114. package/storybook-static/MadieConfirmDialog-MadieConfirmDialog-stories.1bec5e61.iframe.bundle.js +2 -0
  115. package/storybook-static/MadieConfirmDialog-MadieConfirmDialog-stories.1bec5e61.iframe.bundle.js.map +1 -0
  116. package/storybook-static/MadieDeleteDialog-MadieDeleteDialog-stories.c55f9367.iframe.bundle.js +2 -0
  117. package/storybook-static/MadieDeleteDialog-MadieDeleteDialog-stories.c55f9367.iframe.bundle.js.map +1 -0
  118. package/storybook-static/MadieDialog-MadieDialog-stories.d2bdc88c.iframe.bundle.js +2 -0
  119. package/storybook-static/MadieDialog-MadieDialog-stories.d2bdc88c.iframe.bundle.js.map +1 -0
  120. package/storybook-static/MadieDiscardDialog-MadieDiscardDialog-stories.050cc027.iframe.bundle.js +2 -0
  121. package/storybook-static/MadieDiscardDialog-MadieDiscardDialog-stories.050cc027.iframe.bundle.js.map +1 -0
  122. package/storybook-static/MadieSpinner-MadieSpinner-stories.82085813.iframe.bundle.js +2 -0
  123. package/storybook-static/MadieSpinner-MadieSpinner-stories.82085813.iframe.bundle.js.map +1 -0
  124. package/storybook-static/MadieTooltip-MadieTooltip-stories.c7413617.iframe.bundle.js +2 -0
  125. package/storybook-static/MadieTooltip-MadieTooltip-stories.c7413617.iframe.bundle.js.map +1 -0
  126. package/storybook-static/MadieTooltipIcon-MadieTooltipIcon-stories.b42bb7f1.iframe.bundle.js +2 -0
  127. package/storybook-static/MadieTooltipIcon-MadieTooltipIcon-stories.b42bb7f1.iframe.bundle.js.map +1 -0
  128. package/storybook-static/Modal-Modal-stories.d5279c12.iframe.bundle.js +2 -0
  129. package/storybook-static/Modal-Modal-stories.d5279c12.iframe.bundle.js.map +1 -0
  130. package/storybook-static/NotificationBanner-NotificationBanner-stories.c9cd7214.iframe.bundle.js +2 -0
  131. package/storybook-static/NotificationBanner-NotificationBanner-stories.c9cd7214.iframe.bundle.js.map +1 -0
  132. package/storybook-static/NumberInput-NumberInput-stories.ed54df5a.iframe.bundle.js +2 -0
  133. package/storybook-static/NumberInput-NumberInput-stories.ed54df5a.iframe.bundle.js.map +1 -0
  134. package/storybook-static/Pagination-Pagination-stories.c699faa0.iframe.bundle.js +2 -0
  135. package/storybook-static/Pagination-Pagination-stories.c699faa0.iframe.bundle.js.map +1 -0
  136. package/storybook-static/Popover-Popover-stories.61ae1fb7.iframe.bundle.js +2 -0
  137. package/storybook-static/Popover-Popover-stories.61ae1fb7.iframe.bundle.js.map +1 -0
  138. package/storybook-static/RadioButton-RadioButton-stories.86bf3fd2.iframe.bundle.js +2 -0
  139. package/storybook-static/RadioButton-RadioButton-stories.86bf3fd2.iframe.bundle.js.map +1 -0
  140. package/storybook-static/ReadOnlyTextField-ReadOnlyTextField-stories.a599e67a.iframe.bundle.js +2 -0
  141. package/storybook-static/ReadOnlyTextField-ReadOnlyTextField-stories.a599e67a.iframe.bundle.js.map +1 -0
  142. package/storybook-static/RichTextEditor-RichTextEditor-stories.81d66b4b.iframe.bundle.js +2 -0
  143. package/storybook-static/RichTextEditor-RichTextEditor-stories.81d66b4b.iframe.bundle.js.map +1 -0
  144. package/storybook-static/Select-Select-stories.a3b5faa6.iframe.bundle.js +2 -0
  145. package/storybook-static/Select-Select-stories.a3b5faa6.iframe.bundle.js.map +1 -0
  146. package/storybook-static/Tabs-Tabs-stories.0689a934.iframe.bundle.js +2 -0
  147. package/storybook-static/Tabs-Tabs-stories.0689a934.iframe.bundle.js.map +1 -0
  148. package/storybook-static/TextArea-TextArea-stories.f862921e.iframe.bundle.js +2 -0
  149. package/storybook-static/TextArea-TextArea-stories.f862921e.iframe.bundle.js.map +1 -0
  150. package/storybook-static/TextField-TextField-stories.ed07af6e.iframe.bundle.js +2 -0
  151. package/storybook-static/TextField-TextField-stories.ed07af6e.iframe.bundle.js.map +1 -0
  152. package/storybook-static/TextInput-TextInput-stories.7043f852.iframe.bundle.js +2 -0
  153. package/storybook-static/TextInput-TextInput-stories.7043f852.iframe.bundle.js.map +1 -0
  154. package/storybook-static/TimeField-TimeField-stories.e69c0bc6.iframe.bundle.js +2 -0
  155. package/storybook-static/TimeField-TimeField-stories.e69c0bc6.iframe.bundle.js.map +1 -0
  156. package/storybook-static/Toast-Toast-stories.9226d3b7.iframe.bundle.js +3 -0
  157. package/storybook-static/Toast-Toast-stories.9226d3b7.iframe.bundle.js.LICENSE.txt +5 -0
  158. package/storybook-static/Toast-Toast-stories.9226d3b7.iframe.bundle.js.map +1 -0
  159. package/storybook-static/Toggle-Toggle-stories.dabdd09d.iframe.bundle.js +2 -0
  160. package/storybook-static/Toggle-Toggle-stories.dabdd09d.iframe.bundle.js.map +1 -0
  161. package/storybook-static/Tooltip-Tooltip-stories.78bdceea.iframe.bundle.js +2 -0
  162. package/storybook-static/Tooltip-Tooltip-stories.78bdceea.iframe.bundle.js.map +1 -0
  163. package/storybook-static/TruncateText-TruncateText-stories.a5188e85.iframe.bundle.js +2 -0
  164. package/storybook-static/TruncateText-TruncateText-stories.a5188e85.iframe.bundle.js.map +1 -0
  165. package/storybook-static/iframe.html +513 -0
  166. package/storybook-static/index.json +1 -1
  167. package/storybook-static/main.f46f596f.iframe.bundle.js +2 -0
  168. package/storybook-static/main.f46f596f.iframe.bundle.js.map +1 -0
  169. package/storybook-static/project.json +1 -1
  170. package/storybook-static/runtime~main.acd6c2b7.iframe.bundle.js +2 -0
  171. package/storybook-static/runtime~main.acd6c2b7.iframe.bundle.js.map +1 -0
  172. package/storybook-static/sb-addons/backgrounds-7/manager-bundle.js +7 -7
  173. package/storybook-static/sb-addons/docs-6/manager-bundle.js +1 -1
  174. package/storybook-static/sb-addons/knobs-4/register-bundle.js +11 -11
  175. package/storybook-static/static/media/Bitter-Bold.091bd4b7.woff +0 -0
  176. package/storybook-static/static/media/Bitter-Bold.24bf01e4.woff2 +0 -0
  177. package/storybook-static/static/media/Bitter-Bold.46bc29e4.ttf +0 -0
  178. package/storybook-static/static/media/Bitter-Bold.790f4f2f.eot +0 -0
  179. package/storybook-static/static/media/Bitter-Italic.1fa5390c.eot +0 -0
  180. package/storybook-static/static/media/Bitter-Italic.25e5675f.woff +0 -0
  181. package/storybook-static/static/media/Bitter-Italic.2eb18f5a.ttf +0 -0
  182. package/storybook-static/static/media/Bitter-Italic.34644574.woff2 +0 -0
  183. package/storybook-static/static/media/Bitter-Regular.4b22b6e8.woff +0 -0
  184. package/storybook-static/static/media/Bitter-Regular.559e7075.eot +0 -0
  185. package/storybook-static/static/media/Bitter-Regular.8db0301b.ttf +0 -0
  186. package/storybook-static/static/media/Bitter-Regular.f4e2f1f1.woff2 +0 -0
  187. package/storybook-static/static/media/FontAwesome.91f80bba.otf +0 -0
  188. package/storybook-static/static/media/OpenSans-Bold-webfont.202d819d.eot +0 -0
  189. package/storybook-static/static/media/OpenSans-Bold-webfont.92e570c6.woff2 +0 -0
  190. package/storybook-static/static/media/OpenSans-Bold-webfont.da71e99a.ttf +0 -0
  191. package/storybook-static/static/media/OpenSans-Bold-webfont.e75949bb.woff +0 -0
  192. package/storybook-static/static/media/OpenSans-Italic-webfont.72daa33a.woff2 +0 -0
  193. package/storybook-static/static/media/OpenSans-Italic-webfont.74ead3a8.woff +0 -0
  194. package/storybook-static/static/media/OpenSans-Italic-webfont.ae19388f.eot +0 -0
  195. package/storybook-static/static/media/OpenSans-Italic-webfont.ec7a2746.ttf +0 -0
  196. package/storybook-static/static/media/OpenSans-Regular-webfont.63a5fa7d.woff +0 -0
  197. package/storybook-static/static/media/OpenSans-Regular-webfont.66451be4.ttf +0 -0
  198. package/storybook-static/static/media/OpenSans-Regular-webfont.7882d20f.eot +0 -0
  199. package/storybook-static/static/media/OpenSans-Regular-webfont.ca4dd835.woff2 +0 -0
  200. package/storybook-static/static/media/OpenSans-Semibold-webfont.17ded75f.woff2 +0 -0
  201. package/storybook-static/static/media/OpenSans-Semibold-webfont.2a5adf6c.woff +0 -0
  202. package/storybook-static/static/media/OpenSans-Semibold-webfont.6059fecb.ttf +0 -0
  203. package/storybook-static/static/media/OpenSans-Semibold-webfont.c9808185.eot +0 -0
  204. package/storybook-static/static/media/Rubik-Bold.31bbd4d2.ttf +0 -0
  205. package/storybook-static/static/media/Rubik-Light.c90e2014.ttf +0 -0
  206. package/storybook-static/static/media/Rubik-Medium.5daa89aa.ttf +0 -0
  207. package/storybook-static/static/media/Rubik-Regular.cdf97d58.ttf +0 -0
  208. package/storybook-static/static/media/arrow-both.a0959e13.svg +3 -0
  209. package/storybook-static/static/media/fontawesome-webfont.1e59d233.ttf +0 -0
  210. package/storybook-static/static/media/fontawesome-webfont.20fd1704.woff2 +0 -0
  211. package/storybook-static/static/media/fontawesome-webfont.8b43027f.eot +0 -0
  212. package/storybook-static/static/media/fontawesome-webfont.c1e38fd9.svg +2671 -0
  213. package/storybook-static/static/media/fontawesome-webfont.f691f37e.woff +0 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"7674.88d82ff0.iframe.bundle.js","mappings":";AAGA","sources":["webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/FormatBold.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/FormatItalic.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/FormatListBulleted.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/FormatListNumbered.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/FormatUnderlined.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/Redo.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/StrikethroughS.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/TableChart.js","webpack://@madie/madie-design-system/./node_modules/@mui/icons-material/Undo.js","webpack://@madie/madie-design-system/./node_modules/dompurify/dist/purify.cjs.js","webpack://@madie/madie-design-system/./node_modules/linkifyjs/dist/linkify.mjs","webpack://@madie/madie-design-system/./node_modules/use-sync-external-store/cjs/use-sync-external-store-shim.production.js","webpack://@madie/madie-design-system/./node_modules/use-sync-external-store/cjs/use-sync-external-store-shim/with-selector.production.js","webpack://@madie/madie-design-system/./node_modules/use-sync-external-store/shim/index.js","webpack://@madie/madie-design-system/./node_modules/use-sync-external-store/shim/with-selector.js","webpack://@madie/madie-design-system/./node_modules/@tiptap/core/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/core/dist/jsx-runtime/jsx-runtime.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/core/jsx-runtime/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-blockquote/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-bold/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-code-block/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-code/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-document/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-gapcursor/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-hard-break/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-heading/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-horizontal-rule/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-italic/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-link/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-list/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-paragraph/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-strike/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-table-cell/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-table-header/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-table-row/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-table/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-text/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extension-underline/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/extensions/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/commands/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/dropcursor/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/gapcursor/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/history/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/keymap/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/model/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/schema-list/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/state/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/tables/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/transform/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/pm/dist/view/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/react/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/@tiptap/starter-kit/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/fast-equals/dist/cjs/index.cjs","webpack://@madie/madie-design-system/./node_modules/orderedmap/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-commands/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-dropcursor/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-gapcursor/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-history/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-keymap/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-model/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-schema-list/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-state/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-tables/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-transform/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/prosemirror-view/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/rope-sequence/dist/index.cjs","webpack://@madie/madie-design-system/./node_modules/w3c-keyname/index.cjs"],"sourcesContent":["\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M15.6 10.79c.97-.67 1.65-1.77 1.65-2.79 0-2.26-1.75-4-4-4H7v14h7.04c2.09 0 3.71-1.7 3.71-3.79 0-1.52-.86-2.82-2.15-3.42M10 6.5h3c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5h-3zm3.5 9H10v-3h3.5c.83 0 1.5.67 1.5 1.5s-.67 1.5-1.5 1.5\"\n}), 'FormatBold');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M10 4v3h2.21l-3.42 8H6v3h8v-3h-2.21l3.42-8H18V4z\"\n}), 'FormatItalic');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M4 10.5c-.83 0-1.5.67-1.5 1.5s.67 1.5 1.5 1.5 1.5-.67 1.5-1.5-.67-1.5-1.5-1.5m0-6c-.83 0-1.5.67-1.5 1.5S3.17 7.5 4 7.5 5.5 6.83 5.5 6 4.83 4.5 4 4.5m0 12c-.83 0-1.5.68-1.5 1.5s.68 1.5 1.5 1.5 1.5-.68 1.5-1.5-.67-1.5-1.5-1.5M7 19h14v-2H7zm0-6h14v-2H7zm0-8v2h14V5z\"\n}), 'FormatListBulleted');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M2 17h2v.5H3v1h1v.5H2v1h3v-4H2zm1-9h1V4H2v1h1zm-1 3h1.8L2 13.1v.9h3v-1H3.2L5 10.9V10H2zm5-6v2h14V5zm0 14h14v-2H7zm0-6h14v-2H7z\"\n}), 'FormatListNumbered');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M12 17c3.31 0 6-2.69 6-6V3h-2.5v8c0 1.93-1.57 3.5-3.5 3.5S8.5 12.93 8.5 11V3H6v8c0 3.31 2.69 6 6 6m-7 2v2h14v-2z\"\n}), 'FormatUnderlined');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M18.4 10.6C16.55 8.99 14.15 8 11.5 8c-4.65 0-8.58 3.03-9.96 7.22L3.9 16c1.05-3.19 4.05-5.5 7.6-5.5 1.95 0 3.73.72 5.12 1.88L13 16h9V7z\"\n}), 'Redo');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M6.85 7.08C6.85 4.37 9.45 3 12.24 3c1.64 0 3 .49 3.9 1.28.77.65 1.46 1.73 1.46 3.24h-3.01c0-.31-.05-.59-.15-.85-.29-.86-1.2-1.28-2.25-1.28-1.86 0-2.34 1.02-2.34 1.7 0 .48.25.88.74 1.21.38.25.77.48 1.41.7H7.39c-.21-.34-.54-.89-.54-1.92M21 12v-2H3v2h9.62c1.15.45 1.96.75 1.96 1.97 0 1-.81 1.67-2.28 1.67-1.54 0-2.93-.54-2.93-2.51H6.4c0 .55.08 1.13.24 1.58.81 2.29 3.29 3.3 5.67 3.3 2.27 0 5.3-.89 5.3-4.05 0-.3-.01-1.16-.48-1.94H21z\"\n}), 'StrikethroughS');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M10 10.02h5V21h-5zM17 21h3c1.1 0 2-.9 2-2v-9h-5zm3-18H5c-1.1 0-2 .9-2 2v3h19V5c0-1.1-.9-2-2-2M3 19c0 1.1.9 2 2 2h3V10H3z\"\n}), 'TableChart');","\"use strict\";\n\"use client\";\n\nvar _interopRequireDefault = require(\"@babel/runtime/helpers/interopRequireDefault\").default;\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = void 0;\nvar _createSvgIcon = _interopRequireDefault(require(\"./utils/createSvgIcon\"));\nvar _jsxRuntime = require(\"react/jsx-runtime\");\nvar _default = exports.default = (0, _createSvgIcon.default)(/*#__PURE__*/(0, _jsxRuntime.jsx)(\"path\", {\n d: \"M12.5 8c-2.65 0-5.05.99-6.9 2.6L2 7v9h9l-3.62-3.62c1.39-1.16 3.16-1.88 5.12-1.88 3.54 0 6.55 2.31 7.6 5.5l2.37-.78C21.08 11.03 17.15 8 12.5 8\"\n}), 'Undo');","/*! @license DOMPurify 3.4.15 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.4.15/LICENSE */\n\n'use strict';\n\nfunction _arrayLikeToArray(r, a) {\n (null == a || a > r.length) && (a = r.length);\n for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];\n return n;\n}\nfunction _arrayWithHoles(r) {\n if (Array.isArray(r)) return r;\n}\nfunction _iterableToArrayLimit(r, l) {\n var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"];\n if (null != t) {\n var e,\n n,\n i,\n u,\n a = [],\n f = true,\n o = false;\n try {\n if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);\n } catch (r) {\n o = true, n = r;\n } finally {\n try {\n if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;\n } finally {\n if (o) throw n;\n }\n }\n return a;\n }\n}\nfunction _nonIterableRest() {\n throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\");\n}\nfunction _slicedToArray(r, e) {\n return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();\n}\nfunction _unsupportedIterableToArray(r, a) {\n if (r) {\n if (\"string\" == typeof r) return _arrayLikeToArray(r, a);\n var t = {}.toString.call(r).slice(8, -1);\n return \"Object\" === t && r.constructor && (t = r.constructor.name), \"Map\" === t || \"Set\" === t ? Array.from(r) : \"Arguments\" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;\n }\n}\n\nconst entries = Object.entries,\n setPrototypeOf = Object.setPrototypeOf,\n isFrozen = Object.isFrozen,\n getPrototypeOf = Object.getPrototypeOf,\n getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;\nlet freeze = Object.freeze,\n seal = Object.seal,\n create = Object.create; // eslint-disable-line import/no-mutable-exports\nlet _ref = typeof Reflect !== 'undefined' && Reflect,\n apply = _ref.apply,\n construct = _ref.construct;\nif (!freeze) {\n freeze = function freeze(x) {\n return x;\n };\n}\nif (!seal) {\n seal = function seal(x) {\n return x;\n };\n}\nif (!apply) {\n apply = function apply(func, thisArg) {\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n return func.apply(thisArg, args);\n };\n}\nif (!construct) {\n construct = function construct(Func) {\n for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {\n args[_key2 - 1] = arguments[_key2];\n }\n return new Func(...args);\n };\n}\nconst arrayForEach = unapply(Array.prototype.forEach);\nconst arrayLastIndexOf = unapply(Array.prototype.lastIndexOf);\nconst arrayPop = unapply(Array.prototype.pop);\nconst arrayPush = unapply(Array.prototype.push);\nconst arraySplice = unapply(Array.prototype.splice);\nconst arrayIsArray = Array.isArray;\nconst stringToLowerCase = unapply(String.prototype.toLowerCase);\nconst stringToString = unapply(String.prototype.toString);\nconst stringMatch = unapply(String.prototype.match);\nconst stringReplace = unapply(String.prototype.replace);\nconst stringIndexOf = unapply(String.prototype.indexOf);\nconst stringTrim = unapply(String.prototype.trim);\nconst numberToString = unapply(Number.prototype.toString);\nconst booleanToString = unapply(Boolean.prototype.toString);\nconst bigintToString = typeof BigInt === 'undefined' ? null : unapply(BigInt.prototype.toString);\nconst symbolToString = typeof Symbol === 'undefined' ? null : unapply(Symbol.prototype.toString);\nconst objectHasOwnProperty = unapply(Object.prototype.hasOwnProperty);\nconst objectToString = unapply(Object.prototype.toString);\nconst regExpTest = unapply(RegExp.prototype.test);\nconst typeErrorCreate = unconstruct(TypeError);\n/**\n * Creates a new function that calls the given function with a specified thisArg and arguments.\n *\n * @param func - The function to be wrapped and called.\n * @returns A new function that calls the given function with a specified thisArg and arguments.\n */\nfunction unapply(func) {\n return function (thisArg) {\n if (thisArg instanceof RegExp) {\n thisArg.lastIndex = 0;\n }\n for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {\n args[_key3 - 1] = arguments[_key3];\n }\n return apply(func, thisArg, args);\n };\n}\n/**\n * Creates a new function that constructs an instance of the given constructor function with the provided arguments.\n *\n * @param func - The constructor function to be wrapped and called.\n * @returns A new function that constructs an instance of the given constructor function with the provided arguments.\n */\nfunction unconstruct(Func) {\n return function () {\n for (var _len4 = arguments.length, args = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {\n args[_key4] = arguments[_key4];\n }\n return construct(Func, args);\n };\n}\n/**\n * Add properties to a lookup table\n *\n * @param set - The set to which elements will be added.\n * @param array - The array containing elements to be added to the set.\n * @param transformCaseFunc - An optional function to transform the case of each element before adding to the set.\n * @returns The modified set with added elements.\n */\nfunction addToSet(set, array) {\n let transformCaseFunc = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : stringToLowerCase;\n if (setPrototypeOf) {\n // Make 'in' and truthy checks like Boolean(set.constructor)\n // independent of any properties defined on Object.prototype.\n // Prevent prototype setters from intercepting set as a this value.\n setPrototypeOf(set, null);\n }\n if (!arrayIsArray(array)) {\n return set;\n }\n let l = array.length;\n while (l--) {\n let element = array[l];\n if (typeof element === 'string') {\n const lcElement = transformCaseFunc(element);\n if (lcElement !== element) {\n // Config presets (e.g. tags.js, attrs.js) are immutable.\n if (!isFrozen(array)) {\n array[l] = lcElement;\n }\n element = lcElement;\n }\n }\n set[element] = true;\n }\n return set;\n}\n/**\n * Clean up an array to harden against CSPP\n *\n * @param array - The array to be cleaned.\n * @returns The cleaned version of the array\n */\nfunction cleanArray(array) {\n for (let index = 0; index < array.length; index++) {\n const isPropertyExist = objectHasOwnProperty(array, index);\n if (!isPropertyExist) {\n array[index] = null;\n }\n }\n return array;\n}\n/**\n * Shallow clone an object\n *\n * @param object - The object to be cloned.\n * @returns A new object that copies the original.\n */\nfunction clone(object) {\n const newObject = create(null);\n for (const _ref2 of entries(object)) {\n var _ref3 = _slicedToArray(_ref2, 2);\n const property = _ref3[0];\n const value = _ref3[1];\n const isPropertyExist = objectHasOwnProperty(object, property);\n if (isPropertyExist) {\n if (arrayIsArray(value)) {\n newObject[property] = cleanArray(value);\n } else if (value && typeof value === 'object' && value.constructor === Object) {\n newObject[property] = clone(value);\n } else {\n newObject[property] = value;\n }\n }\n }\n return newObject;\n}\n/**\n * Convert non-node values into strings without depending on direct property access.\n *\n * @param value - The value to stringify.\n * @returns A string representation of the provided value.\n */\nfunction stringifyValue(value) {\n switch (typeof value) {\n case 'string':\n {\n return value;\n }\n case 'number':\n {\n return numberToString(value);\n }\n case 'boolean':\n {\n return booleanToString(value);\n }\n case 'bigint':\n {\n return bigintToString ? bigintToString(value) : '0';\n }\n case 'symbol':\n {\n return symbolToString ? symbolToString(value) : 'Symbol()';\n }\n case 'undefined':\n {\n return objectToString(value);\n }\n case 'function':\n case 'object':\n {\n if (value === null) {\n return objectToString(value);\n }\n const valueAsRecord = value;\n const valueToString = lookupGetter(valueAsRecord, 'toString');\n if (typeof valueToString === 'function') {\n const stringified = valueToString(valueAsRecord);\n return typeof stringified === 'string' ? stringified : objectToString(stringified);\n }\n return objectToString(value);\n }\n default:\n {\n return objectToString(value);\n }\n }\n}\n/**\n * This method automatically checks if the prop is function or getter and behaves accordingly.\n *\n * @param object - The object to look up the getter function in its prototype chain.\n * @param prop - The property name for which to find the getter function.\n * @returns The getter function found in the prototype chain or a fallback function.\n */\nfunction lookupGetter(object, prop) {\n while (object !== null) {\n const desc = getOwnPropertyDescriptor(object, prop);\n if (desc) {\n if (desc.get) {\n return unapply(desc.get);\n }\n if (typeof desc.value === 'function') {\n return unapply(desc.value);\n }\n }\n object = getPrototypeOf(object);\n }\n function fallbackValue() {\n return null;\n }\n return fallbackValue;\n}\nfunction isRegex(value) {\n try {\n regExpTest(value, '');\n return true;\n } catch (_unused) {\n return false;\n }\n}\n\nconst html$1 = freeze(['a', 'abbr', 'acronym', 'address', 'area', 'article', 'aside', 'audio', 'b', 'bdi', 'bdo', 'big', 'blink', 'blockquote', 'body', 'br', 'button', 'canvas', 'caption', 'center', 'cite', 'code', 'col', 'colgroup', 'content', 'data', 'datalist', 'dd', 'decorator', 'del', 'details', 'dfn', 'dialog', 'dir', 'div', 'dl', 'dt', 'element', 'em', 'fieldset', 'figcaption', 'figure', 'font', 'footer', 'form', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'head', 'header', 'hgroup', 'hr', 'html', 'i', 'img', 'input', 'ins', 'kbd', 'label', 'legend', 'li', 'main', 'map', 'mark', 'marquee', 'menu', 'menuitem', 'meter', 'nav', 'nobr', 'ol', 'optgroup', 'option', 'output', 'p', 'picture', 'pre', 'progress', 'q', 'rp', 'rt', 'ruby', 's', 'samp', 'search', 'section', 'select', 'shadow', 'slot', 'small', 'source', 'spacer', 'span', 'strike', 'strong', 'style', 'sub', 'summary', 'sup', 'table', 'tbody', 'td', 'template', 'textarea', 'tfoot', 'th', 'thead', 'time', 'tr', 'track', 'tt', 'u', 'ul', 'var', 'video', 'wbr']);\nconst svg$1 = freeze(['svg', 'a', 'altglyph', 'altglyphdef', 'altglyphitem', 'animatecolor', 'animatemotion', 'animatetransform', 'circle', 'clippath', 'defs', 'desc', 'ellipse', 'enterkeyhint', 'exportparts', 'filter', 'font', 'g', 'glyph', 'glyphref', 'hkern', 'image', 'inputmode', 'line', 'lineargradient', 'marker', 'mask', 'metadata', 'mpath', 'part', 'path', 'pattern', 'polygon', 'polyline', 'radialgradient', 'rect', 'stop', 'style', 'switch', 'symbol', 'text', 'textpath', 'title', 'tref', 'tspan', 'view', 'vkern']);\nconst svgFilters = freeze(['feBlend', 'feColorMatrix', 'feComponentTransfer', 'feComposite', 'feConvolveMatrix', 'feDiffuseLighting', 'feDisplacementMap', 'feDistantLight', 'feDropShadow', 'feFlood', 'feFuncA', 'feFuncB', 'feFuncG', 'feFuncR', 'feGaussianBlur', 'feImage', 'feMerge', 'feMergeNode', 'feMorphology', 'feOffset', 'fePointLight', 'feSpecularLighting', 'feSpotLight', 'feTile', 'feTurbulence']);\n// List of SVG elements that are disallowed by default.\n// We still need to know them so that we can do namespace\n// checks properly in case one wants to add them to\n// allow-list.\nconst svgDisallowed = freeze(['animate', 'color-profile', 'cursor', 'discard', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'foreignobject', 'hatch', 'hatchpath', 'mesh', 'meshgradient', 'meshpatch', 'meshrow', 'missing-glyph', 'script', 'set', 'solidcolor', 'unknown', 'use']);\nconst mathMl$1 = freeze(['math', 'menclose', 'merror', 'mfenced', 'mfrac', 'mglyph', 'mi', 'mlabeledtr', 'mmultiscripts', 'mn', 'mo', 'mover', 'mpadded', 'mphantom', 'mroot', 'mrow', 'ms', 'mspace', 'msqrt', 'mstyle', 'msub', 'msup', 'msubsup', 'mtable', 'mtd', 'mtext', 'mtr', 'munder', 'munderover', 'mprescripts']);\n// Similarly to SVG, we want to know all MathML elements,\n// even those that we disallow by default.\nconst mathMlDisallowed = freeze(['maction', 'maligngroup', 'malignmark', 'mlongdiv', 'mscarries', 'mscarry', 'msgroup', 'mstack', 'msline', 'msrow', 'semantics', 'annotation', 'annotation-xml', 'mprescripts', 'none']);\nconst text = freeze(['#text']);\n\nconst html = freeze(['accept', 'action', 'align', 'alt', 'autocapitalize', 'autocomplete', 'autopictureinpicture', 'autoplay', 'background', 'bgcolor', 'border', 'capture', 'cellpadding', 'cellspacing', 'checked', 'cite', 'class', 'clear', 'color', 'cols', 'colspan', 'command', 'commandfor', 'controls', 'controlslist', 'coords', 'crossorigin', 'datetime', 'decoding', 'default', 'dir', 'disabled', 'disablepictureinpicture', 'disableremoteplayback', 'download', 'draggable', 'enctype', 'enterkeyhint', 'exportparts', 'face', 'for', 'headers', 'height', 'hidden', 'high', 'href', 'hreflang', 'id', 'inert', 'inputmode', 'integrity', 'ismap', 'kind', 'label', 'lang', 'list', 'loading', 'loop', 'low', 'max', 'maxlength', 'media', 'method', 'min', 'minlength', 'multiple', 'muted', 'name', 'nonce', 'noshade', 'novalidate', 'nowrap', 'open', 'optimum', 'part', 'pattern', 'placeholder', 'playsinline', 'popover', 'popovertarget', 'popovertargetaction', 'poster', 'preload', 'pubdate', 'radiogroup', 'readonly', 'rel', 'required', 'rev', 'reversed', 'role', 'rows', 'rowspan', 'spellcheck', 'scope', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'srclang', 'start', 'src', 'srcset', 'step', 'style', 'summary', 'tabindex', 'title', 'translate', 'type', 'usemap', 'valign', 'value', 'width', 'wrap', 'xmlns']);\nconst svg = freeze(['accent-height', 'accumulate', 'additive', 'alignment-baseline', 'amplitude', 'ascent', 'attributename', 'attributetype', 'azimuth', 'basefrequency', 'baseline-shift', 'begin', 'bias', 'by', 'class', 'clip', 'clippathunits', 'clip-path', 'clip-rule', 'color', 'color-interpolation', 'color-interpolation-filters', 'color-profile', 'color-rendering', 'cx', 'cy', 'd', 'dx', 'dy', 'diffuseconstant', 'direction', 'display', 'divisor', 'dominant-baseline', 'dur', 'edgemode', 'elevation', 'end', 'exponent', 'fill', 'fill-opacity', 'fill-rule', 'filter', 'filterunits', 'flood-color', 'flood-opacity', 'font-family', 'font-size', 'font-size-adjust', 'font-stretch', 'font-style', 'font-variant', 'font-weight', 'fx', 'fy', 'g1', 'g2', 'glyph-name', 'glyphref', 'gradientunits', 'gradienttransform', 'height', 'href', 'id', 'image-rendering', 'in', 'in2', 'intercept', 'k', 'k1', 'k2', 'k3', 'k4', 'kerning', 'keypoints', 'keysplines', 'keytimes', 'lang', 'lengthadjust', 'letter-spacing', 'kernelmatrix', 'kernelunitlength', 'lighting-color', 'local', 'marker-end', 'marker-mid', 'marker-start', 'markerheight', 'markerunits', 'markerwidth', 'maskcontentunits', 'maskunits', 'max', 'mask', 'mask-type', 'media', 'method', 'mode', 'min', 'name', 'numoctaves', 'offset', 'operator', 'opacity', 'order', 'orient', 'orientation', 'origin', 'overflow', 'paint-order', 'path', 'pathlength', 'patterncontentunits', 'patterntransform', 'patternunits', 'pointer-events', 'points', 'preservealpha', 'preserveaspectratio', 'primitiveunits', 'r', 'rx', 'ry', 'radius', 'refx', 'refy', 'repeatcount', 'repeatdur', 'restart', 'result', 'rotate', 'scale', 'seed', 'shape-rendering', 'slope', 'specularconstant', 'specularexponent', 'spreadmethod', 'startoffset', 'stddeviation', 'stitchtiles', 'stop-color', 'stop-opacity', 'stroke-dasharray', 'stroke-dashoffset', 'stroke-linecap', 'stroke-linejoin', 'stroke-miterlimit', 'stroke-opacity', 'stroke', 'stroke-width', 'style', 'surfacescale', 'systemlanguage', 'tabindex', 'tablevalues', 'targetx', 'targety', 'transform', 'transform-origin', 'text-anchor', 'text-decoration', 'text-orientation', 'text-rendering', 'textlength', 'type', 'u1', 'u2', 'unicode', 'values', 'vector-effect', 'viewbox', 'visibility', 'version', 'vert-adv-y', 'vert-origin-x', 'vert-origin-y', 'width', 'word-spacing', 'wrap', 'writing-mode', 'xchannelselector', 'ychannelselector', 'x', 'x1', 'x2', 'xmlns', 'y', 'y1', 'y2', 'z', 'zoomandpan']);\nconst mathMl = freeze(['accent', 'accentunder', 'align', 'bevelled', 'close', 'columnalign', 'columnlines', 'columnspacing', 'columnspan', 'denomalign', 'depth', 'dir', 'display', 'displaystyle', 'encoding', 'fence', 'frame', 'height', 'href', 'id', 'largeop', 'length', 'linethickness', 'lquote', 'lspace', 'mathbackground', 'mathcolor', 'mathsize', 'mathvariant', 'maxsize', 'minsize', 'movablelimits', 'notation', 'numalign', 'open', 'rowalign', 'rowlines', 'rowspacing', 'rowspan', 'rspace', 'rquote', 'scriptlevel', 'scriptminsize', 'scriptsizemultiplier', 'selection', 'separator', 'separators', 'stretchy', 'subscriptshift', 'supscriptshift', 'symmetric', 'voffset', 'width', 'xmlns']);\nconst xml = freeze(['xlink:href', 'xml:id', 'xlink:title', 'xml:space', 'xmlns:xlink']);\n\nconst MUSTACHE_EXPR = seal(/{{[\\w\\W]*|^[\\w\\W]*}}/g);\nconst ERB_EXPR = seal(/<%[\\w\\W]*|^[\\w\\W]*%>/g);\nconst TMPLIT_EXPR = seal(/\\${[\\w\\W]*/g);\nconst DATA_ATTR = seal(/^data-[\\-\\w.\\u00B7-\\uFFFF]+$/); // eslint-disable-line no-useless-escape\nconst ARIA_ATTR = seal(/^aria-[\\-\\w]+$/); // eslint-disable-line no-useless-escape\nconst IS_ALLOWED_URI = seal(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\\-]+(?:[^a-z+.\\-:]|$))/i // eslint-disable-line no-useless-escape\n);\nconst IS_SCRIPT_OR_DATA = seal(/^(?:\\w+script|data):/i);\nconst ATTR_WHITESPACE = seal(/[\\u0000-\\u0020\\u00A0\\u1680\\u180E\\u2000-\\u2029\\u205F\\u3000]/g // eslint-disable-line no-control-regex\n);\nconst DOCTYPE_NAME = seal(/^html$/i);\nconst CUSTOM_ELEMENT = seal(/^[a-z][.\\w]*(-[.\\w]+)+$/i);\n// Markup-significant character probes used by _sanitizeElements.\n// Shared module-level instances are safe despite the sticky /g flags:\n// unapply() resets lastIndex for RegExp receivers before every call.\nconst ELEMENT_MARKUP_PROBE = seal(/<[/\\w!]/g);\nconst COMMENT_MARKUP_PROBE = seal(/<[/\\w]/g);\nconst FALLBACK_TAG_CLOSE = seal(/<\\/no(script|embed|frames)/i);\nconst SELF_CLOSING_TAG = seal(/\\/>/i);\n\n// https://developer.mozilla.org/en-US/docs/Web/API/Node/nodeType\nconst NODE_TYPE = {\n element: 1,\n attribute: 2,\n text: 3,\n cdataSection: 4,\n entityReference: 5,\n // Deprecated\n entityNode: 6,\n // Deprecated\n processingInstruction: 7,\n comment: 8,\n document: 9,\n documentType: 10,\n documentFragment: 11,\n notation: 12 // Deprecated\n};\n/* HTML-namespace elements whose child text nodes are serialized *literally*\n (unescaped) by the HTML fragment-serialization algorithm. Two reparse-mXSS\n shapes ride on that literal serialization:\n (a) an element child - a tree the HTML parser can never build, but the DOM\n API and an XML/XHTML parse can - after which a `</tag>`-bearing text\n sibling breaks the element open on reparse; and\n (b) text-only content that already carries the element's OWN end tag, e.g.\n `<style>...</style><img onerror=x>` built as a node, which the literal\n serializer emits verbatim for the HTML parser to re-open.\n Shape (a) is handled by the firstElementChild branch in _isUnsafeNode; shape\n (b) by the LITERAL_TEXT_CLOSE probe. Both read textContent (the raw-serialized\n form for these elements) rather than innerHTML, because an XML/XHTML working\n document serializes innerHTML with `<` escaped, which silently blinds the\n innerHTML-based probes (rule 1's second probe and FALLBACK_TAG_CLOSE) there.\n `script` is never allow-listed, but is kept here so the guard matches the\n serializer's own literal-text list exactly. */\nconst LITERAL_TEXT_ELEMENT_NAMES = ['style', 'script', 'xmp', 'iframe', 'noembed', 'noframes', 'plaintext', 'noscript'];\nconst LITERAL_TEXT_ELEMENTS = freeze(addToSet({}, LITERAL_TEXT_ELEMENT_NAMES));\n/* Per-element end-tag matcher. On an HTML reparse the ONLY token that\n terminates a literal-text element's raw content is its own end tag; a foreign\n literal-text close (e.g. `</xmp>` sitting inside `<style>`) does not break\n out, so matching is per-element, not a shared alternation. The lookahead\n requires an HTML tag-name terminator (whitespace, `/` or `>`) so a longer\n name such as `</styles` is not mistaken for `</style`. */\nconst LITERAL_TEXT_CLOSE = function () {\n const map = {};\n arrayForEach(LITERAL_TEXT_ELEMENT_NAMES, name => {\n map[name] = seal(new RegExp('</' + name + '(?=[\\\\t\\\\n\\\\f\\\\r />])', 'i'));\n });\n return freeze(map);\n}();\nconst getGlobal = function getGlobal() {\n return typeof window === 'undefined' ? null : window;\n};\n/**\n * Creates a no-op policy for internal use only.\n * Don't export this function outside this module!\n * @param trustedTypes The policy factory.\n * @param purifyHostElement The Script element used to load DOMPurify (to determine policy name suffix).\n * @return The policy created (or null, if Trusted Types\n * are not supported or creating the policy failed).\n */\nconst _createTrustedTypesPolicy = function _createTrustedTypesPolicy(trustedTypes, purifyHostElement) {\n if (typeof trustedTypes !== 'object' || typeof trustedTypes.createPolicy !== 'function') {\n return null;\n }\n // Allow the callers to control the unique policy name\n // by adding a data-tt-policy-suffix to the script element with the DOMPurify.\n // Policy creation with duplicate names throws in Trusted Types.\n let suffix = null;\n const ATTR_NAME = 'data-tt-policy-suffix';\n if (purifyHostElement && purifyHostElement.hasAttribute(ATTR_NAME)) {\n suffix = purifyHostElement.getAttribute(ATTR_NAME);\n }\n const policyName = 'dompurify' + (suffix ? '#' + suffix : '');\n try {\n return trustedTypes.createPolicy(policyName, {\n createHTML(html) {\n return html;\n },\n createScriptURL(scriptUrl) {\n return scriptUrl;\n }\n });\n } catch (_) {\n // Policy creation failed (most likely another DOMPurify script has\n // already run). Skip creating the policy, as this will only cause errors\n // if TT are enforced.\n console.warn('TrustedTypes policy ' + policyName + ' could not be created.');\n return null;\n }\n};\nconst _createHooksMap = function _createHooksMap() {\n return {\n afterSanitizeAttributes: [],\n afterSanitizeElements: [],\n afterSanitizeShadowDOM: [],\n beforeSanitizeAttributes: [],\n beforeSanitizeElements: [],\n beforeSanitizeShadowDOM: [],\n uponSanitizeAttribute: [],\n uponSanitizeElement: [],\n uponSanitizeShadowNode: []\n };\n};\n/**\n * Resolve a set-valued configuration option: a fresh set built from\n * cfg[key] when it is an own array property (seeded with a clone of\n * options.base when given, case-normalized via options.transform),\n * the fallback set otherwise.\n *\n * @param cfg the cloned, prototype-free configuration object\n * @param key the configuration property to read\n * @param fallback the set to use when the option is absent or not an array\n * @param options transform and optional base set to merge into\n * @returns the resolved set\n */\nconst _resolveSetOption = function _resolveSetOption(cfg, key, fallback, options) {\n return objectHasOwnProperty(cfg, key) && arrayIsArray(cfg[key]) ? addToSet(options.base ? clone(options.base) : {}, cfg[key], options.transform) : fallback;\n};\n/**\n * Resolve an object-valued configuration option: a prototype-free clone\n * of cfg[key] when it is an own, truthy object property, else a fresh\n * fallback built by makeFallback (fresh on every parse, so a previous\n * parse can never leak state into the next one).\n *\n * @param cfg the cloned, prototype-free configuration object\n * @param key the configuration property to read\n * @param makeFallback builds the fallback value when the option is absent\n * @returns the resolved object\n */\nconst _resolveObjectOption = function _resolveObjectOption(cfg, key, makeFallback) {\n const value = objectHasOwnProperty(cfg, key) ? cfg[key] : undefined;\n return value && typeof value === 'object' ? clone(value) : makeFallback();\n};\nfunction createDOMPurify() {\n let window = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getGlobal();\n const DOMPurify = root => createDOMPurify(root);\n DOMPurify.version = '3.4.15';\n DOMPurify.removed = [];\n if (!window || !window.document || window.document.nodeType !== NODE_TYPE.document || !window.Element) {\n // Not running in a browser, provide a factory function\n // so that you can pass your own Window\n DOMPurify.isSupported = false;\n return DOMPurify;\n }\n let document = window.document;\n const originalDocument = document;\n const currentScript = originalDocument.currentScript;\n window.DocumentFragment;\n const HTMLTemplateElement = window.HTMLTemplateElement,\n Node = window.Node,\n Element = window.Element,\n NodeFilter = window.NodeFilter,\n _window$NamedNodeMap = window.NamedNodeMap;\n _window$NamedNodeMap === void 0 ? window.NamedNodeMap || window.MozNamedAttrMap : _window$NamedNodeMap;\n window.HTMLFormElement;\n const DOMParser = window.DOMParser,\n trustedTypes = window.trustedTypes;\n const ElementPrototype = Element.prototype;\n const cloneNode = lookupGetter(ElementPrototype, 'cloneNode');\n const remove = lookupGetter(ElementPrototype, 'remove');\n // Clobber-safe Attr-node removal. On an HTMLFormElement a descendant named\n // \"removeAttributeNode\" shadows the prototype method via\n // [LegacyOverrideBuiltIns], so element.removeAttributeNode(attr) throws.\n // Calling the cached Element.prototype method with the element as the\n // receiver removes the exact live Attr node regardless of the shadowing.\n const removeAttributeNode = lookupGetter(ElementPrototype, 'removeAttributeNode');\n const getNextSibling = lookupGetter(ElementPrototype, 'nextSibling');\n const getChildNodes = lookupGetter(ElementPrototype, 'childNodes');\n const getParentNode = lookupGetter(ElementPrototype, 'parentNode');\n const getShadowRoot = lookupGetter(ElementPrototype, 'shadowRoot');\n const getAttributes = lookupGetter(ElementPrototype, 'attributes');\n const getNodeType = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeType') : null;\n const getNodeName = Node && Node.prototype ? lookupGetter(Node.prototype, 'nodeName') : null;\n const getOwnerDocument = Node && Node.prototype ? lookupGetter(Node.prototype, 'ownerDocument') : null;\n /* Clobber-safe nodeType / nodeName reads through the cached Node.prototype\n getters, with a direct-property fallback for environments that lack\n Node.prototype. Sites that need a different fallback (e.g. _isClobbered\n returns early on a null name) intentionally keep their own reads. */\n const _readNodeType = function _readNodeType(node) {\n return getNodeType ? getNodeType(node) : node.nodeType;\n };\n const _readNodeName = function _readNodeName(node) {\n return getNodeName ? getNodeName(node) : node.nodeName;\n };\n // As per issue #47, the web-components registry is inherited by a\n // new document created via createHTMLDocument. As per the spec\n // (http://w3c.github.io/webcomponents/spec/custom/#creating-and-passing-registries)\n // a new empty registry is used when creating a template contents owner\n // document, so we use that as our parent document to ensure nothing\n // is inherited.\n if (typeof HTMLTemplateElement === 'function') {\n const template = document.createElement('template');\n if (template.content && template.content.ownerDocument) {\n document = template.content.ownerDocument;\n }\n }\n let trustedTypesPolicy;\n let emptyHTML = '';\n // The instance's own internal Trusted Types policy. Unlike a caller-supplied\n // `TRUSTED_TYPES_POLICY`, this is created at most once — Trusted Types throws\n // on duplicate policy names — and is the only policy allowed to persist\n // across configurations and survive `clearConfig()`.\n let defaultTrustedTypesPolicy;\n let defaultTrustedTypesPolicyResolved = false;\n // Tracks whether we are already inside a call to the configured Trusted Types\n // policy (`createHTML` or `createScriptURL`). If a supplied policy callback\n // itself calls `DOMPurify.sanitize` (the cause of #1422), `sanitize` would\n // re-enter the policy and recurse until the stack overflows. We detect that\n // re-entry and throw a clear, actionable error instead. The guard is shared\n // across both callbacks, because either one re-entering `sanitize` triggers\n // the same unbounded recursion.\n let IN_TRUSTED_TYPES_POLICY = 0;\n const _assertNotInTrustedTypesPolicy = function _assertNotInTrustedTypesPolicy() {\n if (IN_TRUSTED_TYPES_POLICY > 0) {\n throw typeErrorCreate('A configured TRUSTED_TYPES_POLICY callback (createHTML or ' + 'createScriptURL) must not call DOMPurify.sanitize, as that causes ' + 'infinite recursion. Do not pass a policy whose callbacks wrap ' + 'DOMPurify as TRUSTED_TYPES_POLICY; see the \"DOMPurify and Trusted ' + 'Types\" section of the README.');\n }\n };\n const _createTrustedHTML = function _createTrustedHTML(html) {\n _assertNotInTrustedTypesPolicy();\n IN_TRUSTED_TYPES_POLICY++;\n try {\n return trustedTypesPolicy.createHTML(html);\n } finally {\n IN_TRUSTED_TYPES_POLICY--;\n }\n };\n const _createTrustedScriptURL = function _createTrustedScriptURL(scriptUrl) {\n _assertNotInTrustedTypesPolicy();\n IN_TRUSTED_TYPES_POLICY++;\n try {\n return trustedTypesPolicy.createScriptURL(scriptUrl);\n } finally {\n IN_TRUSTED_TYPES_POLICY--;\n }\n };\n // Lazily resolve (and cache) the instance's internal default policy.\n // Resolution is attempted at most once: a successful `createPolicy` cannot be\n // repeated (Trusted Types throws on duplicate names), and a failed or\n // unsupported attempt must not be retried on every parse.\n const _getDefaultTrustedTypesPolicy = function _getDefaultTrustedTypesPolicy() {\n if (!defaultTrustedTypesPolicyResolved) {\n defaultTrustedTypesPolicy = _createTrustedTypesPolicy(trustedTypes, currentScript);\n defaultTrustedTypesPolicyResolved = true;\n }\n return defaultTrustedTypesPolicy;\n };\n const _document = document,\n implementation = _document.implementation,\n createNodeIterator = _document.createNodeIterator,\n createDocumentFragment = _document.createDocumentFragment,\n getElementsByTagName = _document.getElementsByTagName;\n const importNode = originalDocument.importNode;\n let hooks = _createHooksMap();\n /**\n * Expose whether this browser supports running the full DOMPurify.\n */\n DOMPurify.isSupported = typeof entries === 'function' && typeof getParentNode === 'function' && implementation && implementation.createHTMLDocument !== undefined;\n const MUSTACHE_EXPR$1 = MUSTACHE_EXPR,\n ERB_EXPR$1 = ERB_EXPR,\n TMPLIT_EXPR$1 = TMPLIT_EXPR,\n DATA_ATTR$1 = DATA_ATTR,\n ARIA_ATTR$1 = ARIA_ATTR,\n IS_SCRIPT_OR_DATA$1 = IS_SCRIPT_OR_DATA,\n ATTR_WHITESPACE$1 = ATTR_WHITESPACE,\n CUSTOM_ELEMENT$1 = CUSTOM_ELEMENT;\n let IS_ALLOWED_URI$1 = IS_ALLOWED_URI;\n /**\n * We consider the elements and attributes below to be safe. Ideally\n * don't add any new ones but feel free to remove unwanted ones.\n */\n /* allowed element names */\n let ALLOWED_TAGS = null;\n const DEFAULT_ALLOWED_TAGS = addToSet({}, [...html$1, ...svg$1, ...svgFilters, ...mathMl$1, ...text]);\n /* Allowed attribute names */\n let ALLOWED_ATTR = null;\n const DEFAULT_ALLOWED_ATTR = addToSet({}, [...html, ...svg, ...mathMl, ...xml]);\n /*\n * Configure how DOMPurify should handle custom elements and their attributes as well as customized built-in elements.\n * @property {RegExp|Function|null} tagNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any custom elements)\n * @property {RegExp|Function|null} attributeNameCheck one of [null, regexPattern, predicate]. Default: `null` (disallow any attributes not on the allow list)\n * @property {boolean} allowCustomizedBuiltInElements allow custom elements derived from built-ins if they pass CUSTOM_ELEMENT_HANDLING.tagNameCheck. Default: `false`.\n */\n let CUSTOM_ELEMENT_HANDLING = Object.seal(create(null, {\n tagNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeNameCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n allowCustomizedBuiltInElements: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: false\n }\n }));\n /* Explicitly forbidden tags (overrides ALLOWED_TAGS/ADD_TAGS) */\n let FORBID_TAGS = null;\n /* Explicitly forbidden attributes (overrides ALLOWED_ATTR/ADD_ATTR) */\n let FORBID_ATTR = null;\n /* Config object to store ADD_TAGS/ADD_ATTR functions (when used as functions) */\n const EXTRA_ELEMENT_HANDLING = Object.seal(create(null, {\n tagCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n },\n attributeCheck: {\n writable: true,\n configurable: false,\n enumerable: true,\n value: null\n }\n }));\n /* Decide if ARIA attributes are okay */\n let ALLOW_ARIA_ATTR = true;\n /* Decide if custom data attributes are okay */\n let ALLOW_DATA_ATTR = true;\n /* Decide if unknown protocols are okay */\n let ALLOW_UNKNOWN_PROTOCOLS = false;\n /* Decide if self-closing tags in attributes are allowed.\n * Usually removed due to a mXSS issue in jQuery 3.0 */\n let ALLOW_SELF_CLOSE_IN_ATTR = true;\n /* Output should be safe for common template engines.\n * This means, DOMPurify removes data attributes, mustaches and ERB\n */\n let SAFE_FOR_TEMPLATES = false;\n /* Output should be safe even for XML used within HTML and alike.\n * This means, DOMPurify removes comments when containing risky content.\n */\n let SAFE_FOR_XML = true;\n /* Decide if document with <html>... should be returned */\n let WHOLE_DOCUMENT = false;\n /* Track whether config is already set on this instance of DOMPurify. */\n let SET_CONFIG = false;\n /* Pristine allowlist bindings captured at setConfig() time. On the\n * persistent-config path sanitize() restores the sets from these before\n * the per-walk hook clone-guard, so a hook's in-call widening cannot\n * carry across calls. Null until setConfig() is called; reset by\n * clearConfig(). */\n let SET_CONFIG_ALLOWED_TAGS = null;\n let SET_CONFIG_ALLOWED_ATTR = null;\n /* Decide if all elements (e.g. style, script) must be children of\n * document.body. By default, browsers might move them to document.head */\n let FORCE_BODY = false;\n /* Decide if a DOM `HTMLBodyElement` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported).\n * If `WHOLE_DOCUMENT` is enabled a `HTMLHtmlElement` will be returned instead\n */\n let RETURN_DOM = false;\n /* Decide if a DOM `DocumentFragment` should be returned, instead of a html\n * string (or a TrustedHTML object if Trusted Types are supported) */\n let RETURN_DOM_FRAGMENT = false;\n /* Try to return a Trusted Type object instead of a string, return a string in\n * case Trusted Types are not supported */\n let RETURN_TRUSTED_TYPE = false;\n /* Output should be free from DOM clobbering attacks?\n * This sanitizes markups named with colliding, clobberable built-in DOM APIs.\n */\n let SANITIZE_DOM = true;\n /* Achieve full DOM Clobbering protection by isolating the namespace of named\n * properties and JS variables, mitigating attacks that abuse the HTML/DOM spec rules.\n *\n * HTML/DOM spec rules that enable DOM Clobbering:\n * - Named Access on Window (§7.3.3)\n * - DOM Tree Accessors (§3.1.5)\n * - Form Element Parent-Child Relations (§4.10.3)\n * - Iframe srcdoc / Nested WindowProxies (§4.8.5)\n * - HTMLCollection (§4.2.10.2)\n *\n * Namespace isolation is implemented by prefixing `id` and `name` attributes\n * with a constant string, i.e., `user-content-`\n */\n let SANITIZE_NAMED_PROPS = false;\n const SANITIZE_NAMED_PROPS_PREFIX = 'user-content-';\n /* Keep element content when removing element? */\n let KEEP_CONTENT = true;\n /* If a `Node` is passed to sanitize(), then performs sanitization in-place instead\n * of importing it into a new Document and returning a sanitized copy */\n let IN_PLACE = false;\n /* Allow usage of profiles like html, svg and mathMl */\n let USE_PROFILES = {};\n /* Tags to ignore content of when KEEP_CONTENT is true */\n let FORBID_CONTENTS = null;\n const DEFAULT_FORBID_CONTENTS = addToSet({}, ['annotation-xml', 'audio', 'colgroup', 'desc', 'foreignobject', 'head', 'iframe', 'math', 'mi', 'mn', 'mo', 'ms', 'mtext', 'noembed', 'noframes', 'noscript', 'plaintext', 'script',\n // <selectedcontent> mirrors the selected <option>'s subtree, cloned by\n // the UA (customizable <select>) — including any on* handlers — and the\n // engine re-mirrors synchronously whenever a removal changes which\n // option/selectedcontent is current, even inside DOMPurify's inert\n // DOMParser document. Hoisting its children on removal re-inserts a fresh\n // mirror target ahead of the walk, which the engine refills, looping\n // forever (DoS) and amplifying output. Dropping its content on removal\n // (rather than hoisting) breaks that cascade; the content is a duplicate\n // of the option, which is sanitized on its own. See campaign-3 F1/F6.\n 'selectedcontent', 'style', 'svg', 'template', 'thead', 'title', 'video', 'xmp']);\n /* Tags that are safe for data: URIs */\n let DATA_URI_TAGS = null;\n const DEFAULT_DATA_URI_TAGS = addToSet({}, ['audio', 'video', 'img', 'source', 'image', 'track']);\n /* Attributes safe for values like \"javascript:\" */\n let URI_SAFE_ATTRIBUTES = null;\n const DEFAULT_URI_SAFE_ATTRIBUTES = addToSet({}, ['alt', 'class', 'for', 'id', 'label', 'name', 'pattern', 'placeholder', 'role', 'summary', 'title', 'value', 'style', 'xmlns']);\n const MATHML_NAMESPACE = 'http://www.w3.org/1998/Math/MathML';\n const SVG_NAMESPACE = 'http://www.w3.org/2000/svg';\n const HTML_NAMESPACE = 'http://www.w3.org/1999/xhtml';\n /* Document namespace */\n let NAMESPACE = HTML_NAMESPACE;\n let IS_EMPTY_INPUT = false;\n /* Allowed XHTML+XML namespaces */\n let ALLOWED_NAMESPACES = null;\n const DEFAULT_ALLOWED_NAMESPACES = addToSet({}, [MATHML_NAMESPACE, SVG_NAMESPACE, HTML_NAMESPACE], stringToString);\n const DEFAULT_MATHML_TEXT_INTEGRATION_POINTS = freeze(['mi', 'mo', 'mn', 'ms', 'mtext']);\n let MATHML_TEXT_INTEGRATION_POINTS = addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS);\n const DEFAULT_HTML_INTEGRATION_POINTS = freeze(['annotation-xml']);\n let HTML_INTEGRATION_POINTS = addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS);\n // Certain elements are allowed in both SVG and HTML\n // namespace. We need to specify them explicitly\n // so that they don't get erroneously deleted from\n // HTML namespace.\n const COMMON_SVG_AND_HTML_ELEMENTS = addToSet({}, ['title', 'style', 'font', 'a', 'script']);\n /* Parsing of strict XHTML documents */\n let PARSER_MEDIA_TYPE = null;\n const SUPPORTED_PARSER_MEDIA_TYPES = ['application/xhtml+xml', 'text/html'];\n const DEFAULT_PARSER_MEDIA_TYPE = 'text/html';\n let transformCaseFunc = null;\n /* Keep a reference to config to pass to hooks */\n let CONFIG = null;\n /* Ideally, do not touch anything below this line */\n /* ______________________________________________ */\n const formElement = document.createElement('form');\n const isRegexOrFunction = function isRegexOrFunction(testValue) {\n return testValue instanceof RegExp || testValue instanceof Function;\n };\n /**\n * _parseConfig\n *\n * @param cfg optional config literal\n */\n // eslint-disable-next-line complexity\n const _parseConfig = function _parseConfig() {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n if (CONFIG && CONFIG === cfg) {\n return;\n }\n /* Shield configuration object from tampering */\n if (!cfg || typeof cfg !== 'object') {\n cfg = {};\n }\n /* Shield configuration object from prototype pollution */\n cfg = clone(cfg);\n PARSER_MEDIA_TYPE =\n // eslint-disable-next-line unicorn/prefer-includes\n SUPPORTED_PARSER_MEDIA_TYPES.indexOf(cfg.PARSER_MEDIA_TYPE) === -1 ? DEFAULT_PARSER_MEDIA_TYPE : cfg.PARSER_MEDIA_TYPE;\n // HTML tags and attributes are not case-sensitive, converting to lowercase. Keeping XHTML as is.\n transformCaseFunc = PARSER_MEDIA_TYPE === 'application/xhtml+xml' ? stringToString : stringToLowerCase;\n /* Set configuration parameters */\n ALLOWED_TAGS = _resolveSetOption(cfg, 'ALLOWED_TAGS', DEFAULT_ALLOWED_TAGS, {\n transform: transformCaseFunc\n });\n ALLOWED_ATTR = _resolveSetOption(cfg, 'ALLOWED_ATTR', DEFAULT_ALLOWED_ATTR, {\n transform: transformCaseFunc\n });\n ALLOWED_NAMESPACES = _resolveSetOption(cfg, 'ALLOWED_NAMESPACES', DEFAULT_ALLOWED_NAMESPACES, {\n transform: stringToString\n });\n URI_SAFE_ATTRIBUTES = _resolveSetOption(cfg, 'ADD_URI_SAFE_ATTR', DEFAULT_URI_SAFE_ATTRIBUTES, {\n transform: transformCaseFunc,\n base: DEFAULT_URI_SAFE_ATTRIBUTES\n });\n DATA_URI_TAGS = _resolveSetOption(cfg, 'ADD_DATA_URI_TAGS', DEFAULT_DATA_URI_TAGS, {\n transform: transformCaseFunc,\n base: DEFAULT_DATA_URI_TAGS\n });\n FORBID_CONTENTS = _resolveSetOption(cfg, 'FORBID_CONTENTS', DEFAULT_FORBID_CONTENTS, {\n transform: transformCaseFunc\n });\n FORBID_TAGS = _resolveSetOption(cfg, 'FORBID_TAGS', clone({}), {\n transform: transformCaseFunc\n });\n FORBID_ATTR = _resolveSetOption(cfg, 'FORBID_ATTR', clone({}), {\n transform: transformCaseFunc\n });\n USE_PROFILES = objectHasOwnProperty(cfg, 'USE_PROFILES') ? cfg.USE_PROFILES && typeof cfg.USE_PROFILES === 'object' ? clone(cfg.USE_PROFILES) : cfg.USE_PROFILES : false;\n ALLOW_ARIA_ATTR = cfg.ALLOW_ARIA_ATTR !== false; // Default true\n ALLOW_DATA_ATTR = cfg.ALLOW_DATA_ATTR !== false; // Default true\n ALLOW_UNKNOWN_PROTOCOLS = cfg.ALLOW_UNKNOWN_PROTOCOLS || false; // Default false\n ALLOW_SELF_CLOSE_IN_ATTR = cfg.ALLOW_SELF_CLOSE_IN_ATTR !== false; // Default true\n SAFE_FOR_TEMPLATES = cfg.SAFE_FOR_TEMPLATES || false; // Default false\n SAFE_FOR_XML = cfg.SAFE_FOR_XML !== false; // Default true\n WHOLE_DOCUMENT = cfg.WHOLE_DOCUMENT || false; // Default false\n RETURN_DOM = cfg.RETURN_DOM || false; // Default false\n RETURN_DOM_FRAGMENT = cfg.RETURN_DOM_FRAGMENT || false; // Default false\n RETURN_TRUSTED_TYPE = cfg.RETURN_TRUSTED_TYPE || false; // Default false\n FORCE_BODY = cfg.FORCE_BODY || false; // Default false\n SANITIZE_DOM = cfg.SANITIZE_DOM !== false; // Default true\n SANITIZE_NAMED_PROPS = cfg.SANITIZE_NAMED_PROPS || false; // Default false\n KEEP_CONTENT = cfg.KEEP_CONTENT !== false; // Default true\n IN_PLACE = cfg.IN_PLACE || false; // Default false\n IS_ALLOWED_URI$1 = isRegex(cfg.ALLOWED_URI_REGEXP) ? cfg.ALLOWED_URI_REGEXP : IS_ALLOWED_URI; // Default regexp\n NAMESPACE = typeof cfg.NAMESPACE === 'string' ? cfg.NAMESPACE : HTML_NAMESPACE; // Default HTML namespace\n MATHML_TEXT_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'MATHML_TEXT_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_MATHML_TEXT_INTEGRATION_POINTS) // Default built-in map\n );\n HTML_INTEGRATION_POINTS = _resolveObjectOption(cfg, 'HTML_INTEGRATION_POINTS', () => addToSet({}, DEFAULT_HTML_INTEGRATION_POINTS) // Default built-in map\n );\n const customElementHandling = _resolveObjectOption(cfg, 'CUSTOM_ELEMENT_HANDLING', () => create(null));\n CUSTOM_ELEMENT_HANDLING = create(null);\n if (objectHasOwnProperty(customElementHandling, 'tagNameCheck') && isRegexOrFunction(customElementHandling.tagNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.tagNameCheck = customElementHandling.tagNameCheck; // Default undefined\n }\n if (objectHasOwnProperty(customElementHandling, 'attributeNameCheck') && isRegexOrFunction(customElementHandling.attributeNameCheck)) {\n CUSTOM_ELEMENT_HANDLING.attributeNameCheck = customElementHandling.attributeNameCheck; // Default undefined\n }\n if (objectHasOwnProperty(customElementHandling, 'allowCustomizedBuiltInElements') && typeof customElementHandling.allowCustomizedBuiltInElements === 'boolean') {\n CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements = customElementHandling.allowCustomizedBuiltInElements; // Default undefined\n }\n seal(CUSTOM_ELEMENT_HANDLING);\n if (SAFE_FOR_TEMPLATES) {\n ALLOW_DATA_ATTR = false;\n }\n if (RETURN_DOM_FRAGMENT) {\n RETURN_DOM = true;\n }\n /* Parse profile info */\n if (USE_PROFILES) {\n ALLOWED_TAGS = addToSet({}, text);\n ALLOWED_ATTR = create(null);\n if (USE_PROFILES.html === true) {\n addToSet(ALLOWED_TAGS, html$1);\n addToSet(ALLOWED_ATTR, html);\n }\n if (USE_PROFILES.svg === true) {\n addToSet(ALLOWED_TAGS, svg$1);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.svgFilters === true) {\n addToSet(ALLOWED_TAGS, svgFilters);\n addToSet(ALLOWED_ATTR, svg);\n addToSet(ALLOWED_ATTR, xml);\n }\n if (USE_PROFILES.mathMl === true) {\n addToSet(ALLOWED_TAGS, mathMl$1);\n addToSet(ALLOWED_ATTR, mathMl);\n addToSet(ALLOWED_ATTR, xml);\n }\n }\n /* Always reset function-based ADD_TAGS / ADD_ATTR checks to prevent\n * leaking across calls when switching from function to array config */\n EXTRA_ELEMENT_HANDLING.tagCheck = null;\n EXTRA_ELEMENT_HANDLING.attributeCheck = null;\n /* Merge configuration parameters */\n if (objectHasOwnProperty(cfg, 'ADD_TAGS')) {\n if (typeof cfg.ADD_TAGS === 'function') {\n EXTRA_ELEMENT_HANDLING.tagCheck = cfg.ADD_TAGS;\n } else if (arrayIsArray(cfg.ADD_TAGS)) {\n if (ALLOWED_TAGS === DEFAULT_ALLOWED_TAGS) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n addToSet(ALLOWED_TAGS, cfg.ADD_TAGS, transformCaseFunc);\n }\n }\n if (objectHasOwnProperty(cfg, 'ADD_ATTR')) {\n if (typeof cfg.ADD_ATTR === 'function') {\n EXTRA_ELEMENT_HANDLING.attributeCheck = cfg.ADD_ATTR;\n } else if (arrayIsArray(cfg.ADD_ATTR)) {\n if (ALLOWED_ATTR === DEFAULT_ALLOWED_ATTR) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n addToSet(ALLOWED_ATTR, cfg.ADD_ATTR, transformCaseFunc);\n }\n }\n if (objectHasOwnProperty(cfg, 'ADD_FORBID_CONTENTS') && arrayIsArray(cfg.ADD_FORBID_CONTENTS)) {\n if (FORBID_CONTENTS === DEFAULT_FORBID_CONTENTS) {\n FORBID_CONTENTS = clone(FORBID_CONTENTS);\n }\n addToSet(FORBID_CONTENTS, cfg.ADD_FORBID_CONTENTS, transformCaseFunc);\n }\n /* Add #text in case KEEP_CONTENT is set to true */\n if (KEEP_CONTENT) {\n ALLOWED_TAGS['#text'] = true;\n }\n /* Add html, head and body to ALLOWED_TAGS in case WHOLE_DOCUMENT is true */\n if (WHOLE_DOCUMENT) {\n addToSet(ALLOWED_TAGS, ['html', 'head', 'body']);\n }\n /* Add tbody to ALLOWED_TAGS in case tables are permitted, see #286, #365 */\n if (ALLOWED_TAGS.table) {\n addToSet(ALLOWED_TAGS, ['tbody']);\n delete FORBID_TAGS.tbody;\n }\n // Re-derive the active Trusted Types policy from this configuration on\n // every parse. The active policy must never be sticky closure state that\n // outlives the config that set it: a caller-supplied policy left in place\n // after `clearConfig()` — or after a later call that supplied none, or\n // `TRUSTED_TYPES_POLICY: null` — could sign a subsequent \"default\"\n // `RETURN_TRUSTED_TYPE` result with a foreign, possibly unsafe policy.\n // See GHSA-vxr8-fq34-vvx9.\n if (cfg.TRUSTED_TYPES_POLICY) {\n if (typeof cfg.TRUSTED_TYPES_POLICY.createHTML !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createHTML\" hook.');\n }\n if (typeof cfg.TRUSTED_TYPES_POLICY.createScriptURL !== 'function') {\n throw typeErrorCreate('TRUSTED_TYPES_POLICY configuration option must provide a \"createScriptURL\" hook.');\n }\n // A caller-supplied policy applies to this configuration only.\n const previousTrustedTypesPolicy = trustedTypesPolicy;\n trustedTypesPolicy = cfg.TRUSTED_TYPES_POLICY;\n // Sign local variables required by `sanitize`. If the supplied policy's\n // `createHTML` is circular (i.e. it calls `DOMPurify.sanitize`), this\n // throws via the re-entrancy guard. Restore the previous policy first so\n // the instance is not left in a poisoned state. See #1422.\n try {\n emptyHTML = _createTrustedHTML('');\n } catch (error) {\n trustedTypesPolicy = previousTrustedTypesPolicy;\n throw error;\n }\n } else if (cfg.TRUSTED_TYPES_POLICY === null) {\n // Explicit opt-out for this call: perform no Trusted Types signing and\n // create nothing (so a strict `trusted-types` CSP that disallows a\n // `dompurify` policy can still call `sanitize` from inside its own\n // policy — see #1422). Resetting to `undefined` rather than a sticky\n // `null` also drops any previously retained caller policy, so it cannot\n // resurface on a later call, while still allowing the next config-less\n // call to restore the internal default policy. See GHSA-vxr8-fq34-vvx9.\n trustedTypesPolicy = undefined;\n emptyHTML = '';\n } else {\n // No policy supplied: keep the currently active policy if one is set — a\n // previously supplied policy is intentionally sticky across config-less\n // calls — otherwise fall back to the instance's own internal policy,\n // created at most once. (A policy supplied for a *single* call still\n // lingers by design; what must not linger is a policy whose configuration\n // has been torn down via `clearConfig()`, which restores the default.)\n if (trustedTypesPolicy === undefined) {\n trustedTypesPolicy = _getDefaultTrustedTypesPolicy();\n }\n // Sign internal variables only when a policy is active. A falsy policy\n // (Trusted Types unsupported, creation failed, or an explicit opt-out)\n // leaves `emptyHTML` as a plain string, so we never call `.createHTML` on\n // a non-policy and throw. See #1422.\n if (trustedTypesPolicy && typeof emptyHTML === 'string') {\n emptyHTML = _createTrustedHTML('');\n }\n }\n // Prevent further manipulation of configuration.\n // Not available in IE8, Safari 5, etc.\n if (freeze) {\n freeze(cfg);\n }\n CONFIG = cfg;\n };\n /* Keep track of all possible SVG and MathML tags\n * so that we can perform the namespace checks\n * correctly. */\n const ALL_SVG_TAGS = addToSet({}, [...svg$1, ...svgFilters, ...svgDisallowed]);\n const ALL_MATHML_TAGS = addToSet({}, [...mathMl$1, ...mathMlDisallowed]);\n /**\n * Namespace rules for an element in the SVG namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkSvgNamespace = function _checkSvgNamespace(tagName, parent, parentTagName) {\n // The only way to switch from HTML namespace to SVG\n // is via <svg>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'svg';\n }\n // The only way to switch from MathML to SVG is via <svg>\n // if the parent is either <annotation-xml> or a MathML\n // text integration point.\n if (parent.namespaceURI === MATHML_NAMESPACE) {\n return tagName === 'svg' && (parentTagName === 'annotation-xml' || MATHML_TEXT_INTEGRATION_POINTS[parentTagName]);\n }\n // We only allow elements that are defined in SVG\n // spec. All others are disallowed in SVG namespace.\n return Boolean(ALL_SVG_TAGS[tagName]);\n };\n /**\n * Namespace rules for an element in the MathML namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkMathMlNamespace = function _checkMathMlNamespace(tagName, parent, parentTagName) {\n // The only way to switch from HTML namespace to MathML\n // is via <math>. If it happens via any other tag, then\n // it should be killed.\n if (parent.namespaceURI === HTML_NAMESPACE) {\n return tagName === 'math';\n }\n // The only way to switch from SVG to MathML is via\n // <math> and HTML integration points\n if (parent.namespaceURI === SVG_NAMESPACE) {\n return tagName === 'math' && HTML_INTEGRATION_POINTS[parentTagName];\n }\n // We only allow elements that are defined in MathML\n // spec. All others are disallowed in MathML namespace.\n return Boolean(ALL_MATHML_TAGS[tagName]);\n };\n /**\n * Namespace rules for an element in the HTML namespace.\n *\n * @param tagName the element's lowercase tag name\n * @param parent the (possibly simulated) parent node\n * @param parentTagName the parent's lowercase tag name\n * @returns true if a spec-compliant parser could produce this element\n */\n const _checkHtmlNamespace = function _checkHtmlNamespace(tagName, parent, parentTagName) {\n // The only way to switch from SVG to HTML is via\n // HTML integration points, and from MathML to HTML\n // is via MathML text integration points\n if (parent.namespaceURI === SVG_NAMESPACE && !HTML_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n if (parent.namespaceURI === MATHML_NAMESPACE && !MATHML_TEXT_INTEGRATION_POINTS[parentTagName]) {\n return false;\n }\n // We disallow tags that are specific for MathML\n // or SVG and should never appear in HTML namespace\n return !ALL_MATHML_TAGS[tagName] && (COMMON_SVG_AND_HTML_ELEMENTS[tagName] || !ALL_SVG_TAGS[tagName]);\n };\n /**\n * @param element a DOM element whose namespace is being checked\n * @returns Return false if the element has a\n * namespace that a spec-compliant parser would never\n * return. Return true otherwise.\n */\n const _checkValidNamespace = function _checkValidNamespace(element) {\n let parent = getParentNode(element);\n // In JSDOM, if we're inside shadow DOM, then parentNode\n // can be null. We just simulate parent in this case.\n if (!parent || !parent.tagName) {\n parent = {\n namespaceURI: NAMESPACE,\n tagName: 'template'\n };\n }\n const tagName = stringToLowerCase(element.tagName);\n const parentTagName = stringToLowerCase(parent.tagName);\n if (!ALLOWED_NAMESPACES[element.namespaceURI]) {\n return false;\n }\n if (element.namespaceURI === SVG_NAMESPACE) {\n return _checkSvgNamespace(tagName, parent, parentTagName);\n }\n if (element.namespaceURI === MATHML_NAMESPACE) {\n return _checkMathMlNamespace(tagName, parent, parentTagName);\n }\n if (element.namespaceURI === HTML_NAMESPACE) {\n return _checkHtmlNamespace(tagName, parent, parentTagName);\n }\n // For XHTML and XML documents that support custom namespaces\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && ALLOWED_NAMESPACES[element.namespaceURI]) {\n return true;\n }\n // The code should never reach this place (this means\n // that the element somehow got namespace that is not\n // HTML, SVG, MathML or allowed via ALLOWED_NAMESPACES).\n // Return false just in case.\n return false;\n };\n /**\n * _forceRemove\n *\n * @param node a DOM node\n */\n const _forceRemove = function _forceRemove(node) {\n arrayPush(DOMPurify.removed, {\n element: node\n });\n try {\n // eslint-disable-next-line unicorn/prefer-dom-node-remove\n getParentNode(node).removeChild(node);\n } catch (_) {\n /* The normal detach failed — this is reached for a parentless node\n (getParentNode() is null, so .removeChild throws). Element.prototype\n .remove() is itself a spec no-op on a parentless node, so a recorded\n \"removal\" would otherwise hand the caller back an intact,\n payload-bearing node (e.g. a detached IN_PLACE root the mXSS canary or\n the style-with-element-child rule decided to kill). Fail closed by\n throwing — exactly as a clobbered root does at the IN_PLACE entry —\n rather than trying to \"neutralize\" the node via its own methods.\n Neutralizing would mean calling getAttributeNames()/removeAttribute()\n on the node, both of which a <form> root can clobber via a named child\n (and _isClobbered does not even probe getAttributeNames), so the\n neutralize step could itself be silently defeated, leaving the payload\n intact. A throw touches only the cached, clobber-safe remove() and\n getParentNode(). Generalizes GHSA-r47g-fvhr-h676 (clobbered-form root)\n to every root-kill reason. REPORT-3.\n This lives inside the catch, so it never fires for a normally-removed\n in-tree node: those have a parent, removeChild() succeeds, and the\n catch is not entered. Only a kept (parentless) root reaches here. */\n remove(node);\n if (!getParentNode(node)) {\n throw typeErrorCreate('a node selected for removal could not be detached from its tree ' + 'and cannot be safely returned; refusing to sanitize in place');\n }\n }\n };\n /**\n * _stripAttributeNode\n *\n * Remove a single Attr node case/namespace-exactly on an attribute-teardown\n * path. Name-based removeAttribute() ASCII-lowercases its lookup key for an\n * HTML element in an HTML document and so silently misses a case-preserved\n * handler (e.g. `ONERROR` off an XML/XHTML import) - the same defect\n * _removeAttribute() was fixed for, which a name-based call would reintroduce\n * on these IN_PLACE teardown paths. Unlike _removeAttribute this does not\n * record into DOMPurify.removed: the neutralize passes intentionally do not\n * book-keep. A clobbered/detached node falls back to best-effort name-based\n * removal.\n *\n * @param element the element to strip the attribute from\n * @param attribute the Attr node to remove\n * @param name the attribute's name, for the fallback path\n */\n const _stripAttributeNode = function _stripAttributeNode(element, attribute, name) {\n try {\n removeAttributeNode(element, attribute);\n } catch (_) {\n try {\n element.removeAttribute(name);\n } catch (_) {}\n }\n };\n /**\n * _neutralizeRoot\n *\n * Fail-closed teardown of an in-place root after the sanitize walk aborts\n * (campaign-3 F2). An internal throw mid-walk — e.g. a page-registered\n * custom element's reaction detaches a node so `_forceRemove`'s deliberate\n * parentless guard throws, or any other re-entrant engine mutation — would\n * otherwise leave the caller's *live* tree half-sanitized, with everything\n * after the abort point still carrying its handlers. There is no safe way\n * to resume the walk (the tree mutated under us), so we strip the root bare:\n * remove every child and every attribute, then let the caller's catch see\n * the original error. Clobber-safe (cached `remove`/`childNodes`/`attributes`\n * getters; the root was already clobber-pre-flighted at the IN_PLACE entry).\n *\n * @param root the in-place root to empty\n */\n const _neutralizeRoot = function _neutralizeRoot(root) {\n /* Strip every disallowed attribute (on* handlers included) off the whole\n subtree BEFORE detaching anything. Detaching first would hand back\n handler-bearing originals (e.g. an already-loading `<img onerror>`)\n whose queued resource event still fires in page scope after we throw.\n Clobber-safe reads; a doomed clobbered node's own attributes are\n irrelevant while its non-clobbered descendants are reached and scrubbed. */\n _neutralizeSubtree(root);\n const childNodes = getChildNodes(root);\n if (childNodes) {\n const snapshot = [];\n arrayForEach(childNodes, child => {\n arrayPush(snapshot, child);\n });\n arrayForEach(snapshot, child => {\n try {\n remove(child);\n } catch (_) {\n /* Best-effort teardown; a still-attached child is handled below */\n }\n });\n }\n const attributes = getAttributes(root);\n if (attributes) {\n for (let i = attributes.length - 1; i >= 0; --i) {\n const attribute = attributes[i];\n const name = attribute && attribute.name;\n if (typeof name === 'string') {\n _stripAttributeNode(root, attribute, name);\n }\n }\n }\n };\n /**\n * _removeAttribute\n *\n * Name-based getAttributeNode()/removeAttribute() ASCII-lowercase their\n * lookup key for HTML elements in an HTML document, so they silently miss an\n * attribute whose stored qualified name still contains uppercase ASCII\n * letters. That happens when the node came from a case-preserving source\n * (an XML/XHTML document imported via importNode(), or createAttributeNS()),\n * where e.g. `ONERROR` survives the walk: the policy check lowercases to\n * `onerror` and rejects it, but `removeAttribute('ONERROR')` looks up\n * `onerror` and finds nothing. Remove the exact Attr node instead, which is\n * case- and namespace-exact, and fall back to name-based removal only when\n * the caller could not supply the node.\n *\n * @param name an Attribute name\n * @param element a DOM node\n * @param attr the exact Attr node to remove, when the caller has it\n */\n const _removeAttribute = function _removeAttribute(name, element, attr) {\n if (!attr) {\n try {\n attr = element.getAttributeNode(name);\n } catch (_) {\n attr = null;\n }\n }\n arrayPush(DOMPurify.removed, {\n attribute: attr || null,\n from: element\n });\n try {\n if (attr) {\n removeAttributeNode(element, attr);\n } else {\n element.removeAttribute(name);\n }\n } catch (_) {\n /* Clobbered or already-detached node - best-effort fall back to a\n name-based removal so the \"is\" handling below still runs. Note this\n fallback ASCII-lowercases its lookup key in an HTML document and so\n cannot reach a case-preserved attribute name; the cached\n removeAttributeNode() above is what removes those, and a clobbered\n form is already removed wholesale by _isClobbered() before reaching\n here. */\n try {\n element.removeAttribute(name);\n } catch (_) {}\n }\n // We void attribute values for unremovable \"is\" attributes\n if (name === 'is') {\n if (RETURN_DOM || RETURN_DOM_FRAGMENT) {\n try {\n _forceRemove(element);\n } catch (_) {}\n } else {\n try {\n element.setAttribute(name, '');\n } catch (_) {}\n }\n }\n };\n /**\n * _stripDisallowedAttributes\n *\n * Removes every attribute the active configuration does not allow from a\n * single element, using the same allowlist as the main attribute pass (so\n * `on*` handlers go, but no `/^on/` blocklist is introduced). Used only to\n * neutralise nodes that are being discarded from an in-place tree.\n *\n * @param element the element to strip\n */\n const _stripDisallowedAttributes = function _stripDisallowedAttributes(element) {\n const attributes = getAttributes(element);\n if (!attributes) {\n return;\n }\n for (let i = attributes.length - 1; i >= 0; --i) {\n const attribute = attributes[i];\n const name = attribute && attribute.name;\n if (typeof name !== 'string' || ALLOWED_ATTR[transformCaseFunc(name)]) {\n continue;\n }\n _stripAttributeNode(element, attribute, name);\n }\n };\n /**\n * _neutralizeSubtree\n *\n * Completes the audit-5 F1 fix across every removal path. The KEEP_CONTENT\n * move-hoist neutralises only disallowed-tag removals; clobber, mXSS-canary,\n * namespace, comment, processing-instruction and KEEP_CONTENT:false removals\n * all drop their subtree wholesale via `_forceRemove`. On the IN_PLACE path\n * those dropped nodes are detached from the caller's LIVE tree but a\n * handler-bearing original among them (an `<img onerror>`/`<video>` that was\n * loading) keeps its queued resource event, which fires in page scope after\n * sanitize returns. This walks a removed subtree and strips every attribute\n * the active configuration does not allow — so `on*` handlers are cancelled\n * through the SAME allowlist that governs kept nodes, not a separate `/^on/`\n * blocklist. Run synchronously before sanitize returns, i.e. before any\n * queued event can fire. Hook-free by design: these nodes leave the output,\n * so firing attribute hooks for them would be surprising. Clobber-safe reads;\n * a doomed clobbered node may shadow `removeAttribute` (its own attributes are\n * irrelevant — it is discarded — while its non-clobbered descendants, e.g.\n * the `<img>`, are reached and scrubbed).\n *\n * @param root the root of a removed subtree to neutralise\n */\n const _neutralizeSubtree = function _neutralizeSubtree(root) {\n const stack = [root];\n while (stack.length > 0) {\n const node = stack.pop();\n const nodeType = _readNodeType(node);\n if (nodeType === NODE_TYPE.element) {\n _stripDisallowedAttributes(node);\n }\n const childNodes = getChildNodes(node);\n if (childNodes) {\n for (let i = childNodes.length - 1; i >= 0; --i) {\n stack.push(childNodes[i]);\n }\n }\n }\n };\n /**\n * _neutralizePatchLinkage\n *\n * IN_PLACE entry pre-pass (declarative-partial-updates / streaming\n * hardening, https://github.com/WICG/declarative-partial-updates).\n *\n * The main walk strips patch linkage (`for`/`patchsrc`) and removes range\n * markers (PIs / markup comments) node-by-node, in document order, AS it\n * reaches each node. On a live in-place root that leaves a window: from the\n * moment the root is connected until the walk arrives at a given node, that\n * node's linkage is live. A patch applied on connection/stream can fire as\n * a microtask during the walk and inject or teleport an unsanitized DOM\n * range into a region the iterator has already passed and will not revisit,\n * so the post-return \"tree is sanitized\" contract is violated. Sweep the\n * whole tree once up front and sever every linkage before the walk begins,\n * closing that window.\n *\n * This CANNOT undo a patch that already fired before sanitize ran — that is\n * the irreducible \"do not IN_PLACE a live-connected attacker tree\" caveat —\n * but it closes everything from sanitize-start onward. Gated on SAFE_FOR_XML\n * to group with the rest of the declarative-partial-updates handling and\n * stay overridable, consistent with the codebase.\n *\n * Clobber-safe traversal (cached childNodes getter); per-node try/catch so a\n * clobbered root cannot defeat the sweep of its non-clobbered descendants.\n *\n * NOTE (pending real-Chrome confirmation, see test/declarative-patch-probe\n * .html Q1): this mirrors the existing policy of keeping `for` on\n * <label>/<output>. If the shipping feature can drive a patch through a\n * surviving `for`-on-label/output + `id` pair, this pre-pass and the\n * attribute check at _isBasicCustomElement's caller must additionally drop\n * that pair on the IN_PLACE path. Left as-is until the taxonomy is verified.\n *\n * @param root the in-place root to sweep\n */\n /**\n * Central policy for declarative-partial-updates patch-linkage attributes,\n * shared by the _neutralizePatchLinkage pre-pass and _isValidAttribute so\n * the two sites cannot drift: `patchsrc` always links, `for` links\n * everywhere except on <label>/<output>, and the whole policy is gated on\n * SAFE_FOR_XML (see the rationale block in _isValidAttribute).\n *\n * @param lcName the transformCaseFunc'd attribute name\n * @param lcTag the transformCaseFunc'd tag name of the carrying element\n * @return true if the attribute is patch linkage and must be dropped\n */\n const _isPatchLinkageAttribute = function _isPatchLinkageAttribute(lcName, lcTag) {\n if (!SAFE_FOR_XML) {\n return false;\n }\n if (lcName === 'patchsrc') {\n return true;\n }\n return lcName === 'for' && lcTag !== 'label' && lcTag !== 'output';\n };\n const _neutralizePatchLinkage = function _neutralizePatchLinkage(root) {\n if (!SAFE_FOR_XML) {\n return;\n }\n const stack = [root];\n while (stack.length > 0) {\n const node = stack.pop();\n const nodeType = _readNodeType(node);\n /* Remove range markers (the target side of a patch linkage): every\n processing instruction, and any markup-bearing comment. */\n if (nodeType === NODE_TYPE.processingInstruction || nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, node.data)) {\n try {\n remove(node);\n } catch (_) {\n /* Best-effort */\n }\n continue;\n }\n /* Strip patch-source attributes (the source side) off elements. */\n if (nodeType === NODE_TYPE.element) {\n const element = node;\n const lcTag = transformCaseFunc(_readNodeName(node));\n try {\n if (element.hasAttribute && element.hasAttribute('patchsrc')) {\n element.removeAttribute('patchsrc');\n }\n if (element.hasAttribute && element.hasAttribute('for') && _isPatchLinkageAttribute('for', lcTag)) {\n element.removeAttribute('for');\n }\n } catch (_) {\n /* Clobbered removeAttribute/hasAttribute on a doomed node — ignore */\n }\n }\n const childNodes = getChildNodes(node);\n if (childNodes) {\n for (let i = childNodes.length - 1; i >= 0; --i) {\n stack.push(childNodes[i]);\n }\n }\n }\n };\n /**\n * _initDocument\n *\n * @param dirty - a string of dirty markup\n * @return a DOM, filled with the dirty markup\n */\n const _initDocument = function _initDocument(dirty) {\n /* Create a HTML document */\n let doc = null;\n let leadingWhitespace = null;\n if (FORCE_BODY) {\n dirty = '<remove></remove>' + dirty;\n } else {\n /* If FORCE_BODY isn't used, leading whitespace needs to be preserved manually */\n const matches = stringMatch(dirty, /^[\\r\\n\\t ]+/);\n leadingWhitespace = matches && matches[0];\n }\n if (PARSER_MEDIA_TYPE === 'application/xhtml+xml' && NAMESPACE === HTML_NAMESPACE) {\n // Root of XHTML doc must contain xmlns declaration (see https://www.w3.org/TR/xhtml1/normative.html#strict)\n dirty = '<html xmlns=\"http://www.w3.org/1999/xhtml\"><head></head><body>' + dirty + '</body></html>';\n }\n const dirtyPayload = trustedTypesPolicy ? _createTrustedHTML(dirty) : dirty;\n /*\n * Use the DOMParser API by default, fallback later if needs be\n * DOMParser not work for svg when has multiple root element.\n */\n if (NAMESPACE === HTML_NAMESPACE) {\n try {\n doc = new DOMParser().parseFromString(dirtyPayload, PARSER_MEDIA_TYPE);\n } catch (_) {}\n }\n /* Use createHTMLDocument in case DOMParser is not available */\n if (!doc || !doc.documentElement) {\n doc = implementation.createDocument(NAMESPACE, 'template', null);\n try {\n doc.documentElement.innerHTML = IS_EMPTY_INPUT ? emptyHTML : dirtyPayload;\n } catch (_) {\n // Syntax error if dirtyPayload is invalid xml\n }\n }\n const body = doc.body || doc.documentElement;\n if (dirty && leadingWhitespace) {\n body.insertBefore(document.createTextNode(leadingWhitespace), body.childNodes[0] || null);\n }\n /* Work on whole document or just its body */\n if (NAMESPACE === HTML_NAMESPACE) {\n return getElementsByTagName.call(doc, WHOLE_DOCUMENT ? 'html' : 'body')[0];\n }\n return WHOLE_DOCUMENT ? doc.documentElement : body;\n };\n /**\n * Creates a NodeIterator object that you can use to traverse filtered lists of nodes or elements in a document.\n *\n * @param root The root element or node to start traversing on.\n * @return The created NodeIterator\n */\n const _createNodeIterator = function _createNodeIterator(root) {\n /* Read ownerDocument through the cached Node.prototype getter, never the\n direct property. HTMLFormElement has [LegacyOverrideBuiltIns], so a\n clobbering child (<input name=\"ownerDocument\"> or a form-associated\n external input) shadows the prototype getter and makes a direct read\n return that <input>. createNodeIterator.call(<input>, ...) then throws\n \"Illegal invocation\", and on the IN_PLACE path that throw lands before\n the walk's fail-closed barrier - leaving the caller's live tree, with\n any already-armed handler in it, un-neutralized. The cached getter\n returns the real Document regardless of the clobber. */\n const doc = getOwnerDocument ? getOwnerDocument(root) : root.ownerDocument;\n return createNodeIterator.call(doc || root, root,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_ELEMENT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_TEXT | NodeFilter.SHOW_PROCESSING_INSTRUCTION | NodeFilter.SHOW_CDATA_SECTION, null);\n };\n /**\n * Replace template expression syntax (mustache, ERB, template\n * literal) with a space; shared by all SAFE_FOR_TEMPLATES scrub\n * sites. Order matters: mustache, then ERB, then template literal.\n *\n * @param value the string to scrub\n * @returns the scrubbed string\n */\n const _stripTemplateExpressions = function _stripTemplateExpressions(value) {\n value = stringReplace(value, MUSTACHE_EXPR$1, ' ');\n value = stringReplace(value, ERB_EXPR$1, ' ');\n value = stringReplace(value, TMPLIT_EXPR$1, ' ');\n return value;\n };\n /**\n * Strip template-engine expressions ({{...}}, ${...}, <%...%>) from the\n * character data of an element subtree. Used as the final safety net for\n * SAFE_FOR_TEMPLATES on every DOM-returning code path so that expressions\n * which only form after text-node normalization (e.g. fragments split across\n * stripped elements) cannot survive into a template-evaluating framework.\n *\n * Walks text/comment/CDATA/processing-instruction nodes and mutates `.data`\n * in place rather than round-tripping through innerHTML. This preserves\n * descendant node references (important for IN_PLACE callers), avoids a\n * serialize/reparse cycle, and reads literal character data — which means\n * `<%...%>` in text content matches the ERB regex against its real bytes\n * instead of the HTML-entity-escaped form innerHTML would produce.\n *\n * Attribute values are not visited here; SAFE_FOR_TEMPLATES handling for\n * attributes is performed during the per-node `_sanitizeAttributes` pass.\n *\n * @param node The root element whose character data should be scrubbed.\n */\n const _scrubTemplateExpressions2 = function _scrubTemplateExpressions(node) {\n var _node$querySelectorAl;\n node.normalize();\n /* Clobber-safe ownerDocument read, same reasoning as _createNodeIterator:\n under SAFE_FOR_TEMPLATES this runs on the live IN_PLACE root, which may\n carry a form-named-getter override of ownerDocument. */\n const doc = getOwnerDocument ? getOwnerDocument(node) : node.ownerDocument;\n const walker = createNodeIterator.call(doc || node, node,\n // eslint-disable-next-line no-bitwise\n NodeFilter.SHOW_TEXT | NodeFilter.SHOW_COMMENT | NodeFilter.SHOW_CDATA_SECTION | NodeFilter.SHOW_PROCESSING_INSTRUCTION, null);\n let currentNode = walker.nextNode();\n while (currentNode) {\n currentNode.data = _stripTemplateExpressions(currentNode.data);\n currentNode = walker.nextNode();\n }\n // NodeIterator does not descend into <template>.content per the DOM spec,\n // so we must explicitly recurse into each template's content fragment,\n // mirroring the approach used by _sanitizeShadowDOM.\n const templates = (_node$querySelectorAl = node.querySelectorAll) === null || _node$querySelectorAl === void 0 ? void 0 : _node$querySelectorAl.call(node, 'template');\n if (templates) {\n arrayForEach(templates, tmpl => {\n if (_isDocumentFragment(tmpl.content)) {\n _scrubTemplateExpressions2(tmpl.content);\n }\n });\n }\n };\n /**\n * _isClobbered\n *\n * Detect DOM-clobbering on HTMLFormElement nodes. Form is the only HTML\n * interface with [LegacyOverrideBuiltIns]; a descendant element with a\n * `name` attribute matching a prototype property shadows that property\n * on direct reads. We use this check at the IN_PLACE entry-point and\n * during attribute sanitization to refuse clobbered forms.\n *\n * @param element element to check for clobbering attacks\n * @return true if clobbered, false if safe\n */\n const _isClobbered = function _isClobbered(element) {\n // Realm-independent tag-name probe. If we can't determine the tag\n // name at all, we can't reason about clobbering — return false\n // (the caller's other defences still apply).\n const realTagName = getNodeName ? getNodeName(element) : null;\n if (typeof realTagName !== 'string') {\n return false;\n }\n if (transformCaseFunc(realTagName) !== 'form') {\n return false;\n }\n return typeof element.nodeName !== 'string' || typeof element.textContent !== 'string' || typeof element.removeChild !== 'function' ||\n // Realm-safe NamedNodeMap detection: equality against the cached\n // prototype getter. Clobbered .attributes (e.g. <input name=\"attributes\">)\n // makes the direct read diverge from the cached read; a clean form\n // (same-realm OR foreign-realm) has both reads pointing at the same\n // canonical NamedNodeMap.\n element.attributes !== getAttributes(element) || typeof element.removeAttribute !== 'function' ||\n // A form descendant named \"removeAttributeNode\" or \"getAttributeNode\"\n // shadows these Attr-node methods via [LegacyOverrideBuiltIns].\n // _removeAttribute() / _stripAttributeNode() reach for\n // element.removeAttributeNode(attr) first; when it is shadowed the call\n // throws and the name-based fallback element.removeAttribute(name)\n // ASCII-lowercases its lookup key in an HTML document, silently missing\n // a case-preserved event-handler attribute (e.g. an ONANIMATIONSTART\n // that reached the sanitizer through an XML/XHTML parse). Flag the form\n // so it is removed wholesale, exactly as for the other shadowed methods.\n typeof element.removeAttributeNode !== 'function' || typeof element.getAttributeNode !== 'function' || typeof element.setAttribute !== 'function' || typeof element.namespaceURI !== 'string' || typeof element.insertBefore !== 'function' || typeof element.hasChildNodes !== 'function' ||\n // NodeType clobbering probe. Cached Node.prototype.nodeType getter\n // returns the integer 1 for any Element regardless of realm; direct\n // read on a clobbered form (e.g. <input name=\"nodeType\">) returns\n // the named child element. Cheap addition — nodeType is read from\n // an internal slot, no serialization cost — and removes a residual\n // clobbering surface used by several mXSS / PI / comment branches\n // in _sanitizeElements that compare currentNode.nodeType directly.\n element.nodeType !== getNodeType(element) ||\n // HTMLFormElement has [LegacyOverrideBuiltIns]: a descendant named\n // \"childNodes\" shadows the prototype getter. Direct reads of\n // form.childNodes from a clobbered form return the named child\n // instead of the real NodeList, so any walk that reads it directly\n // skips the form's real children. Compare the direct read to the\n // cached Node.prototype getter — when the form's named-property\n // getter intercepts the read, the two values differ and we flag\n // the form. This catches every clobbering child type (input,\n // select, etc.) regardless of whether the named child happens to\n // carry a numeric .length, which a typeof-based probe would miss\n // (e.g. HTMLSelectElement.length is a defined unsigned-long).\n element.childNodes !== getChildNodes(element);\n };\n /**\n * Checks whether the given value is a DocumentFragment from any realm.\n *\n * The realm-independent replacement reads `nodeType` through the cached\n * Node.prototype getter and compares to the DOCUMENT_FRAGMENT_NODE\n * constant (11). nodeType is a numeric value resolved from the node's\n * internal slot, identical across realms for the same kind of node.\n *\n * @param value object to check\n * @return true if value is a DocumentFragment-shaped node from any realm\n */\n const _isDocumentFragment = function _isDocumentFragment(value) {\n if (!getNodeType || typeof value !== 'object' || value === null) {\n return false;\n }\n try {\n return getNodeType(value) === NODE_TYPE.documentFragment;\n } catch (_) {\n return false;\n }\n };\n /**\n * Checks whether the given object is a DOM node, including nodes that\n * originate from a different window/realm (e.g. an iframe's\n * contentDocument). The previous `value instanceof Node` check was\n * realm-bound: nodes from a different window failed it, causing\n * sanitize() to silently stringify them and reset IN_PLACE to false,\n * returning the original node unsanitized. See GHSA-4w3q-35jp-p934.\n *\n * @param value object to check whether it's a DOM node\n * @return true if value is a DOM node from any realm\n */\n const _isNode = function _isNode(value) {\n if (!getNodeType || typeof value !== 'object' || value === null) {\n return false;\n }\n try {\n return typeof getNodeType(value) === 'number';\n } catch (_) {\n return false;\n }\n };\n function _executeHooks(hooks, currentNode, data) {\n if (hooks.length === 0) {\n return;\n }\n arrayForEach(hooks, hook => {\n hook.call(DOMPurify, currentNode, data, CONFIG);\n });\n }\n /**\n * Structural-threat checks that condemn a node regardless of the\n * allowlists: mXSS via namespace confusion, risky CSS construction,\n * processing instructions, markup-bearing comments. Pure predicate;\n * the caller removes. Check order is load-bearing.\n *\n * @param currentNode the node to inspect\n * @param tagName the node's transformCaseFunc'd tag name\n * @return true if the node must be removed\n */\n const _isUnsafeNode = function _isUnsafeNode(currentNode, tagName) {\n /* Detect mXSS attempts abusing namespace confusion */\n if (SAFE_FOR_XML && currentNode.hasChildNodes() && !_isNode(currentNode.firstElementChild) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.textContent) && regExpTest(ELEMENT_MARKUP_PROBE, currentNode.innerHTML)) {\n return true;\n }\n /* Remove rawtext/literal-text elements whose literal serialization\n re-opens markup on an HTML reparse - shapes (a) and (b) documented at\n LITERAL_TEXT_ELEMENTS. Both are invisible to rule 1 above (which\n self-disables once there is an element child, and whose second probe\n reads the innerHTML an XML/XHTML document serializes escaped), which\n is why both probes here read textContent instead. Previously only\n `style`-with-element-child was covered; every element in\n LITERAL_TEXT_ELEMENTS shares this literal serialization and is\n equally affected. */\n if (SAFE_FOR_XML && currentNode.namespaceURI === HTML_NAMESPACE && LITERAL_TEXT_ELEMENTS[tagName] && (_isNode(currentNode.firstElementChild) || typeof currentNode.textContent === 'string' && regExpTest(LITERAL_TEXT_CLOSE[tagName], currentNode.textContent))) {\n return true;\n }\n /* Remove any occurrence of processing instructions */\n if (currentNode.nodeType === NODE_TYPE.processingInstruction) {\n return true;\n }\n /* Remove any kind of possibly harmful comments */\n if (SAFE_FOR_XML && currentNode.nodeType === NODE_TYPE.comment && regExpTest(COMMENT_MARKUP_PROBE, currentNode.data)) {\n return true;\n }\n return false;\n };\n /**\n * Evaluate a CUSTOM_ELEMENT_HANDLING check (a RegExp or a predicate\n * function, per the validation in _parseConfig) against a name.\n * Additional arguments are forwarded to predicate functions - the\n * attributeNameCheck predicate receives the tag name as its second\n * argument. A null/absent check never matches.\n *\n * @param check the configured tagNameCheck / attributeNameCheck value\n * @param name the name to test\n * @param args extra arguments forwarded to a predicate function\n * @return true if the check matches the name\n */\n const _matchesNameCheck = function _matchesNameCheck(check, name) {\n if (check instanceof RegExp) {\n return regExpTest(check, name);\n }\n if (check instanceof Function) {\n for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {\n args[_key - 2] = arguments[_key];\n }\n return Boolean(check(name, ...args));\n }\n return false;\n };\n /**\n * Handle a node whose tag is forbidden or not allowlisted: keep\n * allowed custom elements (false return exits _sanitizeElements\n * early - the namespace and fallback-tag removal checks are\n * intentionally skipped for kept custom elements), else hoist\n * content per KEEP_CONTENT and remove.\n *\n * A kept custom element is the ONLY case in which this function\n * returns false, so the caller uses that return value to run the\n * afterSanitizeElements hook on the kept element and keep the\n * element-hook lifecycle consistent with normal allowlisted\n * elements (GHSA-c2j3-45gr-mqc4).\n *\n * @param currentNode the disallowed node\n * @param tagName the node's transformCaseFunc'd tag name\n * @return true if the node was removed, false if kept\n */\n const _sanitizeDisallowedNode = function _sanitizeDisallowedNode(currentNode, tagName, root) {\n /* Check if we have a custom element to handle */\n if (!FORBID_TAGS[tagName] && _isBasicCustomElement(tagName) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, tagName)) {\n return false;\n }\n /* Keep content except for bad-listed elements.\n Use the cached prototype getters exclusively — the previous code\n had `|| currentNode.parentNode` / `|| currentNode.childNodes`\n fallbacks, but the cached getters always return the canonical\n value (or null for a real parent-less node), so the fallback\n path was dead in safe cases and a clobbering surface in unsafe\n ones. Falsy cached results stay falsy; the `if (childNodes &&\n parentNode)` check already gates correctly. */\n if (KEEP_CONTENT && !FORBID_CONTENTS[tagName]) {\n const parentNode = getParentNode(currentNode);\n const childNodes = getChildNodes(currentNode);\n if (childNodes && parentNode) {\n const childCount = childNodes.length;\n /* Hoist by moving each child up one level rather than deep-cloning\n it. Moving transfers every descendant exactly once, so a chain of\n nested disallowed elements costs O(n) instead of the O(n^2) that\n re-cloning the shrinking subtree at each level produced; it also\n empties the removed original, so `DOMPurify.removed` no longer\n pins whole subtrees. Moving preserves the in-place guarantee too:\n an original carrying already-queued resource events (`<img\n onerror>`, `<video>`/`<audio>` error, lazy/`onload`, …) is\n relocated and sanitised rather than left detached but still armed.\n The sole case that must clone is removing the walk root itself.\n The result is serialised from the root's subtree, so a restrictive\n ALLOWED_TAGS that strips the root (`body` on the string path) must\n leave the content inside it, which only cloning does. In IN_PLACE\n the root is pre-validated as an allowed tag and so is never removed\n here, so that path always takes the move branch.\n `childNodes` is live; a tail-to-head walk keeps `childNodes[i]`\n valid whether we move (drops the trailing entry) or clone (leaves\n the list intact). */\n for (let i = childCount - 1; i >= 0; --i) {\n const hoisted = currentNode === root ? cloneNode(childNodes[i], true) : childNodes[i];\n parentNode.insertBefore(hoisted, getNextSibling(currentNode));\n }\n }\n }\n _forceRemove(currentNode);\n return true;\n };\n /**\n * Fork a hook-mutable allowlist off its shared binding the first time a\n * (possibly lazily-installed) uponSanitize* hook is about to see it, so the\n * hook cannot widen the per-instance default or the setConfig binding by\n * reference and leak past the call. Returns the set unchanged once it is\n * already call-local, so repeated calls across elements are idempotent.\n *\n * @param hookList the uponSanitize* hook array for this event\n * @param set the current ALLOWED_TAGS / ALLOWED_ATTR binding\n * @param defaultSet the per-instance DEFAULT_ALLOWED_* constant\n * @param setConfigSet the captured setConfig() binding, or null\n * @return a call-local clone if a hook is present and set is still shared,\n * else set unchanged\n */\n const _forkSharedAllowlist = function _forkSharedAllowlist(hookList, set, defaultSet, setConfigSet) {\n if (hookList.length === 0) {\n return set;\n }\n return set === defaultSet || set === setConfigSet ? clone(set) : set;\n };\n /**\n * Shared guard for a node that a hook has detached from the walk tree,\n * used after each element-hook site in _sanitizeElements. Detaching is a\n * long-standing user pattern (issue #469; draw.io-style foreignObject\n * filtering). Per the cached, unclobberable parentNode getter the node is\n * genuinely out of the tree, so it can reach neither the serialized\n * output nor an IN_PLACE live tree; treat it as removed and stop\n * processing it. Without this guard, the unsafe-node / namespace checks\n * would call _forceRemove on a parentless node and hit the REPORT-3\n * fail-closed throw — which exists for nodes DOMPurify wants gone but\n * *cannot* detach (clobbered / parentless roots), the opposite of a node\n * that is already safely gone. The walk root is exempt: a detached\n * IN_PLACE root is legitimate input and must still be fully sanitized,\n * and a kill-decision on it must keep hitting the REPORT-3 throw.\n *\n * Nodes detached by hooks stay the hook's responsibility for placement:\n * they are not recorded in DOMPurify.removed, so the post-walk IN_PLACE\n * pass (which iterates DOMPurify.removed) does not reach them. But a\n * hook-detached subtree can still hold a queued resource-event handler -\n * e.g. an <img onload> that began loading when the caller built the live\n * tree - which fires in page scope after sanitize returns even though the\n * handler never reached the returned tree. That is the audit-5 F1 hazard,\n * and the documented node.remove() hook pattern walks straight into it.\n * So on the IN_PLACE path we neutralize the detached subtree inline,\n * stripping its non-allow-listed attributes before returning, exactly as\n * the post-walk pass does for _forceRemove'd subtrees.\n *\n * @param currentNode the node a hook may have detached\n * @param root the current walk root\n * @return true if the node is detached and now handled, false otherwise\n */\n const _handleHookDetachedNode = function _handleHookDetachedNode(currentNode, root) {\n if (currentNode === root || getParentNode(currentNode) !== null) {\n return false;\n }\n if (IN_PLACE) {\n _neutralizeSubtree(currentNode);\n }\n return true;\n };\n /**\n * _sanitizeElements\n *\n * @protect nodeName\n * @protect textContent\n * @protect removeChild\n * @param currentNode to check for permission to exist\n * @return true if node was killed, false if left alive\n */\n const _sanitizeElements = function _sanitizeElements(currentNode, root) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeElements, currentNode, null);\n /* A hook may have detached the node - treat it as removed (see\n _handleHookDetachedNode for the full rationale). */\n if (_handleHookDetachedNode(currentNode, root)) {\n return true;\n }\n /* Check if element is clobbered or can clobber */\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Now let's check the element's type and name */\n const tagName = transformCaseFunc(_readNodeName(currentNode));\n /* Close the pre-walk clone-guard's timing gap: an uponSanitizeElement\n hook may have been installed after that guard sampled the hook arrays\n (e.g. lazily from beforeSanitizeElements), leaving ALLOWED_TAGS still\n aliasing a shared binding that a widening hook would mutate by\n reference. Fork it before exposing it to the hook. */\n ALLOWED_TAGS = _forkSharedAllowlist(hooks.uponSanitizeElement, ALLOWED_TAGS, DEFAULT_ALLOWED_TAGS, SET_CONFIG_ALLOWED_TAGS);\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeElement, currentNode, {\n tagName,\n allowedTags: ALLOWED_TAGS\n });\n /* The uponSanitizeElement hook may have detached the node, exactly as\n above (see _handleHookDetachedNode for the full rationale). */\n if (_handleHookDetachedNode(currentNode, root)) {\n return true;\n }\n /* Remove mXSS vectors, processing instructions and risky comments */\n if (_isUnsafeNode(currentNode, tagName)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Remove element if anything forbids its presence */\n if (FORBID_TAGS[tagName] || !(EXTRA_ELEMENT_HANDLING.tagCheck instanceof Function && EXTRA_ELEMENT_HANDLING.tagCheck(tagName)) && !ALLOWED_TAGS[tagName]) {\n const removed = _sanitizeDisallowedNode(currentNode, tagName, root);\n /* A false return means the node is a custom element kept via\n CUSTOM_ELEMENT_HANDLING - the only keep path through\n _sanitizeDisallowedNode. Run afterSanitizeElements on it so the\n element-hook lifecycle matches normal allowlisted elements: a\n security policy applied in this hook (e.g. stripping an attribute\n from every surviving element) must not silently skip kept custom\n elements (GHSA-c2j3-45gr-mqc4). This mirrors the normal-element\n tail below - the hook runs, then the walker's subsequent\n _sanitizeAttributes pass sanitizes the element's attributes. The\n deliberately skipped namespace and fallback-tag removal checks stay\n skipped; they are removal decisions, not the hook contract. */\n if (removed === false) {\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n }\n return removed;\n }\n /* Check whether element has a valid namespace.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): use the cached Node.prototype\n nodeType getter rather than `instanceof Element`, which is realm-\n bound and short-circuits to false for any node minted in a different\n realm — letting a foreign-realm element with a forbidden namespace\n slip past the namespace check entirely. */\n const nt = _readNodeType(currentNode);\n if (nt === NODE_TYPE.element && !_checkValidNamespace(currentNode)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Make sure that older browsers don't get fallback-tag mXSS */\n if ((tagName === 'noscript' || tagName === 'noembed' || tagName === 'noframes') && regExpTest(FALLBACK_TAG_CLOSE, currentNode.innerHTML)) {\n _forceRemove(currentNode);\n return true;\n }\n /* Sanitize element content to be template-safe */\n if (SAFE_FOR_TEMPLATES && currentNode.nodeType === NODE_TYPE.text) {\n /* Get the element's text content */\n const content = _stripTemplateExpressions(currentNode.textContent);\n if (currentNode.textContent !== content) {\n arrayPush(DOMPurify.removed, {\n element: currentNode.cloneNode()\n });\n currentNode.textContent = content;\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeElements, currentNode, null);\n return false;\n };\n /**\n * _isValidAttribute\n *\n * @param lcTag Lowercase tag name of containing element.\n * @param lcName Lowercase attribute name.\n * @param value Attribute value.\n * @return Returns true if `value` is valid, otherwise false.\n */\n // eslint-disable-next-line complexity\n const _isValidAttribute = function _isValidAttribute(lcTag, lcName, value) {\n /* FORBID_ATTR must always win, even if ADD_ATTR predicate would allow it */\n if (FORBID_ATTR[lcName]) {\n return false;\n }\n /* Reject declarative-partial-updates patch-linkage attributes\n (https://github.com/WICG/declarative-partial-updates).\n Empirical note (Chrome 150, verified — see\n test/declarative-patch-probe-v3.html): expansion is NOT applied after\n sanitization. For the string path it fires during sanitize()'s own\n parse, so the walk sees and sanitizes the fully materialized expanded\n tree — teleports into MathML/SVG integration points included; a\n weaponized `<template for>`->`<img onerror>` comes back with the handler\n stripped. For the IN_PLACE path it fires on connection, before the walk.\n Either way DOMPurify is NOT blind to the patch.\n This removal is therefore defense-in-depth rather than the sole barrier:\n it prevents live linkage from surviving into the OUTPUT and re-expanding\n in the caller's context, and keeps behaviour deterministic if a future\n engine defers expansion. `for` is legitimate only on <label>/<output>;\n anywhere else (notably <template for>) it links the element to a patch\n target and teleports or removes an arbitrary DOM range by id/marker name.\n `patchsrc` fetches remote markup and is treated as a script-loading\n mechanism (CSP). Gated on SAFE_FOR_XML so the removal groups with the\n other structural-threat checks and stays overridable, consistent with\n the rest of the codebase. PI range markers are already removed by\n _isUnsafeNode. */\n if (_isPatchLinkageAttribute(lcName, lcTag)) {\n return false;\n }\n /* Make sure attribute cannot clobber */\n if (SANITIZE_DOM && (lcName === 'id' || lcName === 'name') && (value in document || value in formElement)) {\n return false;\n }\n const nameIsPermitted = ALLOWED_ATTR[lcName] || EXTRA_ELEMENT_HANDLING.attributeCheck instanceof Function && EXTRA_ELEMENT_HANDLING.attributeCheck(lcName, lcTag);\n /* Allow valid data-* attributes: At least one character after \"-\"\n (https://html.spec.whatwg.org/multipage/dom.html#embedding-custom-non-visible-data-with-the-data-*-attributes)\n XML-compatible (https://html.spec.whatwg.org/multipage/infrastructure.html#xml-compatible and http://www.w3.org/TR/xml/#d0e804)\n We don't need to check the value; it's always URI safe. */\n if (ALLOW_DATA_ATTR && regExpTest(DATA_ATTR$1, lcName)) {\n return true;\n }\n /* Allow valid aria-* attributes, the value is always URI safe */\n if (ALLOW_ARIA_ATTR && regExpTest(ARIA_ATTR$1, lcName)) {\n return true;\n }\n /* A name outside the allowlist is acceptable on custom-element terms\n only. The value checks below are intentionally skipped in that case:\n if the user supplied a tagNameCheck we also allow derived custom\n elements using the same test, and attributes passing the configured\n attributeNameCheck are allowed as custom elements define these at\n their own discretion. */\n if (!nameIsPermitted) {\n return (\n // Condition a) covers a basically valid custom element tag name whose\n // tag passes the configured tagNameCheck and whose attribute name\n // passes the configured attributeNameCheck ...\n _isBasicCustomElement(lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, lcTag) && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.attributeNameCheck, lcName, lcTag) ||\n // Condition b) covers an `is` attribute whose value passes the\n // configured tagNameCheck while customized built-in elements are\n // allowed.\n lcName === 'is' && CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements && _matchesNameCheck(CUSTOM_ELEMENT_HANDLING.tagNameCheck, value)\n );\n }\n /* Check value is safe. First, is attr inert? If so, is safe */\n if (URI_SAFE_ATTRIBUTES[lcName]) {\n return true;\n }\n /* Check no script, data or unknown possibly unsafe URI\n unless we know URI values are safe for that attribute */\n if (regExpTest(IS_ALLOWED_URI$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {\n return true;\n }\n /* Keep image data URIs alive if src/xlink:href is allowed */\n /* Further prevent gadget XSS for dynamically built script tags */\n if ((lcName === 'src' || lcName === 'xlink:href' || lcName === 'href') && lcTag !== 'script' && stringIndexOf(value, 'data:') === 0 && DATA_URI_TAGS[lcTag]) {\n return true;\n }\n /* Allow unknown protocols: This provides support for links that\n are handled by protocol handlers which may be unknown ahead of\n time, e.g. fb:, spotify: */\n if (ALLOW_UNKNOWN_PROTOCOLS && !regExpTest(IS_SCRIPT_OR_DATA$1, stringReplace(value, ATTR_WHITESPACE$1, ''))) {\n return true;\n }\n /* Only an empty (binary) value remains safe at this point;\n anything else is presumed unsafe, do not add it back */\n return !value;\n };\n /* Names the HTML spec reserves from valid-custom-element-name; these must\n * never be treated as basic custom elements even when a permissive\n * CUSTOM_ELEMENT_HANDLING.tagNameCheck is configured. */\n const RESERVED_CUSTOM_ELEMENT_NAMES = addToSet({}, ['annotation-xml', 'color-profile', 'font-face', 'font-face-format', 'font-face-name', 'font-face-src', 'font-face-uri', 'missing-glyph']);\n /**\n * _isBasicCustomElement\n * checks if at least one dash is included in tagName, and it's not the first char\n * for more sophisticated checking see https://github.com/sindresorhus/validate-element-name\n *\n * @param tagName name of the tag of the node to sanitize\n * @returns Returns true if the tag name meets the basic criteria for a custom element, otherwise false.\n */\n const _isBasicCustomElement = function _isBasicCustomElement(tagName) {\n return !RESERVED_CUSTOM_ELEMENT_NAMES[stringToLowerCase(tagName)] && regExpTest(CUSTOM_ELEMENT$1, tagName);\n };\n /**\n * Wrap an attribute value in the matching Trusted Types object when\n * the active policy requires it. Namespaced attributes pass through\n * unchanged (no TT support yet, see\n * https://bugs.chromium.org/p/chromium/issues/detail?id=1305293).\n *\n * @param lcTag lowercase tag name of the containing element\n * @param lcName lowercase attribute name\n * @param namespaceURI the attribute's namespace, if any\n * @param value the attribute value to wrap\n * @return the value, wrapped when Trusted Types demand it\n */\n const _applyTrustedTypesToAttribute = function _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value) {\n if (trustedTypesPolicy && typeof trustedTypes === 'object' && typeof trustedTypes.getAttributeType === 'function' && !namespaceURI) {\n switch (trustedTypes.getAttributeType(lcTag, lcName)) {\n case 'TrustedHTML':\n {\n return _createTrustedHTML(value);\n }\n case 'TrustedScriptURL':\n {\n return _createTrustedScriptURL(value);\n }\n }\n }\n return value;\n };\n /**\n * Write a modified attribute value back onto the element. On\n * success, re-probe for clobbering introduced by the new value and\n * remove the element when found; otherwise, when this writeback is the\n * recreate half of the SANITIZE_NAMED_PROPS remove-and-recreate, pop the\n * removal entry that path recorded so it does not show as removed. On\n * failure, remove the attribute instead.\n *\n * Returns true only on a clean write (the value was set and the new value\n * introduced no clobbering). The caller uses that, together with its own\n * knowledge of whether this attribute pushed a DOMPurify.removed record, to\n * decide whether to pop that record. The pop must happen ONLY for the\n * named-prop remove-and-recreate; popping on any other value change (trim,\n * template scrubbing, Trusted Types) would consume an unrelated _forceRemove\n * subtree-cleanup record and let that detached subtree keep a live event\n * handler through the IN_PLACE neutralization pass (SO-001).\n *\n * @param currentNode the element carrying the attribute\n * @param name the attribute name as present on the element\n * @param namespaceURI the attribute's namespace, if any\n * @param value the new attribute value\n * @return true if the value was written without introducing clobbering\n */\n const _setAttributeValue = function _setAttributeValue(currentNode, name, namespaceURI, value) {\n try {\n if (namespaceURI) {\n currentNode.setAttributeNS(namespaceURI, name, value);\n } else {\n /* Fallback to setAttribute() for browser-unrecognized namespaces e.g. \"x-schema\". */\n currentNode.setAttribute(name, value);\n }\n if (_isClobbered(currentNode)) {\n _forceRemove(currentNode);\n return false;\n }\n return true;\n } catch (_) {\n _removeAttribute(name, currentNode);\n return false;\n }\n };\n /**\n * _sanitizeAttributes\n *\n * @protect attributes\n * @protect nodeName\n * @protect removeAttribute\n * @protect setAttribute\n *\n * @param currentNode to sanitize\n */\n // eslint-disable-next-line complexity\n const _sanitizeAttributes = function _sanitizeAttributes(currentNode) {\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeAttributes, currentNode, null);\n const attributes = currentNode.attributes;\n /* Check if we have attributes; if not we might have a text node */\n if (!attributes || _isClobbered(currentNode)) {\n return;\n }\n /* Same lazy-install guard as uponSanitizeElement (see there): fork the\n attribute allowlist off its shared binding before a hook can see it. */\n ALLOWED_ATTR = _forkSharedAllowlist(hooks.uponSanitizeAttribute, ALLOWED_ATTR, DEFAULT_ALLOWED_ATTR, SET_CONFIG_ALLOWED_ATTR);\n const hookEvent = {\n attrName: '',\n attrValue: '',\n keepAttr: true,\n allowedAttributes: ALLOWED_ATTR,\n forceKeepAttr: undefined\n };\n let l = attributes.length;\n const lcTag = transformCaseFunc(currentNode.nodeName);\n /* Go backwards over all attributes; safely remove bad ones */\n while (l--) {\n const attr = attributes[l];\n const name = attr.name,\n namespaceURI = attr.namespaceURI,\n attrValue = attr.value;\n const lcName = transformCaseFunc(name);\n const initValue = attrValue;\n let value = name === 'value' ? initValue : stringTrim(initValue);\n /* Tracks whether this specific attribute pushed a DOMPurify.removed\n record that a later _setAttributeValue() writeback is expected to pop\n back off (the SANITIZE_NAMED_PROPS remove-and-recreate below is the\n only path that does). A value that merely changed via trim, template\n scrubbing, or Trusted Types pushes no such record, so its writeback\n must NOT pop — otherwise it consumes an unrelated _forceRemove subtree\n record and that detached subtree escapes the IN_PLACE handler-\n neutralization pass (SO-001). */\n let recreatedNamedProp = false;\n /* Execute a hook if present */\n hookEvent.attrName = lcName;\n hookEvent.attrValue = value;\n hookEvent.keepAttr = true;\n hookEvent.forceKeepAttr = undefined; // Allows developers to see this is a property they can set\n _executeHooks(hooks.uponSanitizeAttribute, currentNode, hookEvent);\n value = hookEvent.attrValue;\n /* Full DOM Clobbering protection via namespace isolation,\n * Prefix id and name attributes with `user-content-`\n */\n if (SANITIZE_NAMED_PROPS && (lcName === 'id' || lcName === 'name') && stringIndexOf(value, SANITIZE_NAMED_PROPS_PREFIX) !== 0) {\n // Remove the attribute with this value\n _removeAttribute(name, currentNode, attr);\n // Prefix the value and later re-create the attribute with the sanitized value\n value = SANITIZE_NAMED_PROPS_PREFIX + value;\n // This attribute owns the record just pushed; its recreate writeback\n // is the one allowed to pop it back off.\n recreatedNamedProp = true;\n }\n // Else: already prefixed, leave the attribute alone — the prefix is\n // itself the clobbering protection, and re-applying it is incorrect.\n /* Work around a security issue with comments inside attributes */\n if (SAFE_FOR_XML && regExpTest(/((--!?|])>)|<\\/(style|script|title|xmp|textarea|noscript|iframe|noembed|noframes)/i, value)) {\n _removeAttribute(name, currentNode, attr);\n continue;\n }\n /* Make sure we cannot easily use animated hrefs, even if animations are allowed */\n if (lcName === 'attributename' && stringMatch(value, 'href')) {\n _removeAttribute(name, currentNode, attr);\n continue;\n }\n /* Did the hooks force-keep the attribute? */\n if (hookEvent.forceKeepAttr) {\n continue;\n }\n /* Did the hooks approve of the attribute? */\n if (!hookEvent.keepAttr) {\n _removeAttribute(name, currentNode, attr);\n continue;\n }\n /* Work around a security issue in jQuery 3.0 */\n if (!ALLOW_SELF_CLOSE_IN_ATTR && regExpTest(SELF_CLOSING_TAG, value)) {\n _removeAttribute(name, currentNode, attr);\n continue;\n }\n /* Sanitize attribute content to be template-safe */\n if (SAFE_FOR_TEMPLATES) {\n value = _stripTemplateExpressions(value);\n }\n /* Is `value` valid for this attribute? */\n if (!_isValidAttribute(lcTag, lcName, value)) {\n _removeAttribute(name, currentNode, attr);\n continue;\n }\n /* Handle attributes that require Trusted Types */\n value = _applyTrustedTypesToAttribute(lcTag, lcName, namespaceURI, value);\n /* Handle invalid data-* attribute set by try-catching it */\n if (value !== initValue) {\n const cleanWrite = _setAttributeValue(currentNode, name, namespaceURI, value);\n /* Only the named-prop remove-and-recreate owns a DOMPurify.removed\n record to pop; a plain trim/template/Trusted-Types writeback owns\n none, so popping here would drop an unrelated subtree's cleanup\n record (SO-001). */\n if (cleanWrite && recreatedNamedProp) {\n arrayPop(DOMPurify.removed);\n }\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeAttributes, currentNode, null);\n };\n /**\n * _sanitizeShadowDOM\n *\n * @param fragment to iterate over recursively\n */\n const _sanitizeShadowDOM2 = function _sanitizeShadowDOM(fragment) {\n let shadowNode = null;\n const shadowIterator = _createNodeIterator(fragment);\n /* Execute a hook if present */\n _executeHooks(hooks.beforeSanitizeShadowDOM, fragment, null);\n while (shadowNode = shadowIterator.nextNode()) {\n /* Execute a hook if present */\n _executeHooks(hooks.uponSanitizeShadowNode, shadowNode, null);\n /* Sanitize tags and elements */\n _sanitizeElements(shadowNode, fragment);\n /* Check attributes next */\n _sanitizeAttributes(shadowNode);\n /* Deep shadow DOM detected.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): use nodeType against the\n DOCUMENT_FRAGMENT_NODE constant rather than instanceof, so we\n recurse into <template>.content from foreign realms too. */\n if (_isDocumentFragment(shadowNode.content)) {\n _sanitizeShadowDOM2(shadowNode.content);\n }\n /* An element iterated here may itself host an attached\n shadow root. The default NodeIterator does not enter shadow\n trees, so a shadow root nested inside template.content was\n previously reached by no walk at all (the pre-pass at\n _sanitizeAttachedShadowRoots descends via childNodes, which\n doesn't enter template.content; the template-content recursion\n above iterates the content but never inspected shadowRoot).\n Walk it explicitly. The nodeType guard avoids reading\n shadowRoot off text / comment / CDATA / PI nodes that the\n iterator also surfaces. */\n if (_readNodeType(shadowNode) === NODE_TYPE.element) {\n const innerSr = getShadowRoot(shadowNode);\n if (_isDocumentFragment(innerSr)) {\n _sanitizeAttachedShadowRoots(innerSr);\n _sanitizeShadowDOM2(innerSr);\n }\n }\n }\n /* Execute a hook if present */\n _executeHooks(hooks.afterSanitizeShadowDOM, fragment, null);\n };\n /**\n * _sanitizeAttachedShadowRoots\n *\n * Walks `root` and feeds every attached shadow root we encounter into\n * the existing _sanitizeShadowDOM pipeline. The default node iterator\n * does not descend into shadow trees, so nodes inside an attached\n * shadow root would otherwise be skipped entirely.\n *\n * Two real input paths put attached shadow roots in front of us:\n * 1. IN_PLACE on a DOM node that already has shadow roots attached.\n * 2. DOM-node input where importNode(dirty, true) deep-clones the\n * shadow root because it was created with `clonable: true`.\n *\n * This pass runs once, up front, so the main iteration loop (and the\n * existing _sanitizeShadowDOM template-content recursion) stay\n * untouched — string-input paths are not affected.\n *\n * @param root the subtree root to walk for attached shadow roots\n */\n const _sanitizeAttachedShadowRoots = function _sanitizeAttachedShadowRoots(root) {\n /* Iterative (explicit stack) rather than per-child recursion. DOM APIs\n impose no depth cap, so an attacker-shaped tree (JSON/CRDT/editor data\n built straight into the DOM — the IN_PLACE surface) deeper than the JS\n call-stack budget would otherwise overflow native recursion here and\n throw at the IN_PLACE entry pre-pass, before a single node is\n sanitized, leaving the caller's live tree untouched (fail-open). See\n campaign-3 F4. A heap stack keeps depth off the call stack.\n Each work item is either a node to descend into, or a deferred\n `_sanitizeShadowDOM` for an already-walked shadow root. The deferred\n form preserves the original post-order discipline: a shadow root's\n nested shadow roots are discovered before the outer shadow is\n sanitized (which may remove hosts). Pushes are in reverse of the\n desired processing order (LIFO): template content, then children, then\n the shadow-sanitize, then the shadow walk — so the order matches the\n previous recursion exactly. */\n const stack = [{\n node: root,\n shadow: null\n }];\n while (stack.length > 0) {\n const item = stack.pop();\n /* Deferred shadow-DOM sanitisation: runs after its subtree was walked. */\n if (item.shadow) {\n _sanitizeShadowDOM2(item.shadow);\n continue;\n }\n const node = item.node;\n const nodeType = _readNodeType(node);\n const isElement = nodeType === NODE_TYPE.element;\n /* (pushed last → processed first) Children, snapshotted in reverse so\n the first child is processed first. Snapshotting matters because a\n hook may detach siblings mid-walk. */\n const childNodes = getChildNodes(node);\n if (childNodes) {\n for (let i = childNodes.length - 1; i >= 0; --i) {\n stack.push({\n node: childNodes[i],\n shadow: null\n });\n }\n }\n /* (pushed before children → processed after them, matching the old\n \"template content last\" order) When the node is a <template>,\n descend into its content. */\n if (isElement) {\n const rootName = getNodeName ? getNodeName(node) : null;\n if (typeof rootName === 'string' && transformCaseFunc(rootName) === 'template') {\n const content = node.content;\n if (_isDocumentFragment(content)) {\n stack.push({\n node: content,\n shadow: null\n });\n }\n }\n }\n /* Shadow root (processed first): walk its subtree, then sanitise it.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection\n rather than `instanceof DocumentFragment`, which is realm-bound and\n silently skipped foreign-realm shadow roots (e.g.\n iframe.contentDocument attachShadow). */\n if (isElement) {\n const sr = getShadowRoot(node);\n if (_isDocumentFragment(sr)) {\n /* Push the deferred sanitise first so it pops after the shadow\n walk we push next, i.e. nested shadow roots are discovered\n before this one is sanitised. */\n stack.push({\n node: null,\n shadow: sr\n }, {\n node: sr,\n shadow: null\n });\n }\n }\n }\n };\n // eslint-disable-next-line complexity\n DOMPurify.sanitize = function (dirty) {\n let cfg = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n let body = null;\n let importedNode = null;\n let currentNode = null;\n let returnNode = null;\n /* Make sure we have a string to sanitize.\n DO NOT return early, as this will return the wrong type if\n the user has requested a DOM object rather than a string */\n IS_EMPTY_INPUT = !dirty;\n if (IS_EMPTY_INPUT) {\n dirty = '<!-->';\n }\n /* Stringify, in case dirty is an object */\n if (typeof dirty !== 'string' && !_isNode(dirty)) {\n dirty = stringifyValue(dirty);\n if (typeof dirty !== 'string') {\n throw typeErrorCreate('dirty is not a string, aborting');\n }\n }\n /* Return dirty HTML if DOMPurify cannot run */\n if (!DOMPurify.isSupported) {\n return dirty;\n }\n /* Assign config vars */\n if (SET_CONFIG) {\n /* Persistent setConfig() path: _parseConfig is skipped, so the sets are\n * not re-derived per call. Restore them from the pristine bindings\n * captured at setConfig() time so a previous call's hook clone (mutated\n * below) does not carry over. */\n ALLOWED_TAGS = SET_CONFIG_ALLOWED_TAGS;\n ALLOWED_ATTR = SET_CONFIG_ALLOWED_ATTR;\n } else {\n _parseConfig(cfg);\n }\n /* Clone the hook-mutable allowlists before the walk whenever an\n * uponSanitize* hook is registered. The hook event exposes ALLOWED_TAGS\n * and ALLOWED_ATTR by reference (as allowedTags / allowedAttributes), so\n * a hook that widens them would otherwise mutate the shared set\n * permanently: across later calls and across every element. Cloning per\n * walk keeps documented in-call widening working while scoping it to the\n * call. A single guard for both config paths - the per-call path rebinds\n * the sets in _parseConfig each call, the persistent path restores them\n * from the captured bindings just above - so the two cannot diverge. */\n if (hooks.uponSanitizeElement.length > 0 || hooks.uponSanitizeAttribute.length > 0) {\n ALLOWED_TAGS = clone(ALLOWED_TAGS);\n }\n if (hooks.uponSanitizeAttribute.length > 0) {\n ALLOWED_ATTR = clone(ALLOWED_ATTR);\n }\n /* Clean up removed elements */\n DOMPurify.removed = [];\n /* Resolve IN_PLACE for this call without mutating persistent config.\n Writing the IN_PLACE closure variable here leaks under setConfig(),\n where _parseConfig is skipped on later calls: a single string call would\n disable in-place mode for every subsequent node call, returning a\n sanitized copy while leaving the caller's node — which in-place callers\n keep using and whose return value they ignore — unsanitized. REPORT-2. */\n const inPlace = IN_PLACE && typeof dirty !== 'string' && _isNode(dirty);\n if (inPlace) {\n /* Declarative-partial-updates / streaming pre-pass: sever every patch\n linkage across the live tree BEFORE the walk, so no patch can fire\n mid-walk and inject into an already-processed region. Runs first, so\n it also covers the forbidden/clobbered roots that throw below. */\n _neutralizePatchLinkage(dirty);\n /* Do some early pre-sanitization to avoid unsafe root nodes.\n Read nodeName through the cached prototype getter — a clobbering\n child named \"nodeName\" on the form root would otherwise shadow\n the property and let this check skip the root-allowlist\n validation entirely. */\n const nn = _readNodeName(dirty);\n if (typeof nn === 'string') {\n const tagName = transformCaseFunc(nn);\n if (!ALLOWED_TAGS[tagName] || FORBID_TAGS[tagName]) {\n /* Fail closed on a live root: neutralize handlers/children before\n throwing, exactly as the mid-walk abort path does. */\n _neutralizeRoot(dirty);\n throw typeErrorCreate('root node is forbidden and cannot be sanitized in-place');\n }\n }\n /* Pre-flight the root through _isClobbered. The iterator-driven\n removal path can not detach a parent-less root: _forceRemove\n falls through to Element.prototype.remove(), which per spec\n is a no-op on a node with no parent. A clobbered root would\n then survive the main loop with its attributes uninspected,\n because _sanitizeAttributes early-returns on _isClobbered. The\n result would be an attacker-controlled form, complete with any\n event-handler attributes the caller passed in, handed back to\n the application unsanitized. Refuse to sanitize such a root\n the same way we refuse a forbidden tag. GHSA-r47g-fvhr-h676. */\n if (_isClobbered(dirty)) {\n /* Fail closed on a live clobbered root before throwing.\n _neutralizeRoot's reads are clobber-safe (cached getters); the\n form's non-clobbered descendants, e.g. an armed <img>, are scrubbed. */\n _neutralizeRoot(dirty);\n throw typeErrorCreate('root node is clobbered and cannot be sanitized in-place');\n }\n /* Sanitize attached shadow roots before the main iterator runs.\n The iterator does not descend into shadow trees. Same fail-closed\n barrier as the main walk (campaign-3 F2): a custom-element reaction\n inside a shadow root could abort this pre-pass before the walk runs,\n which would otherwise leave the entire live tree unsanitized. */\n try {\n _sanitizeAttachedShadowRoots(dirty);\n } catch (error) {\n _neutralizeRoot(dirty);\n throw error;\n }\n } else if (_isNode(dirty)) {\n /* If dirty is a DOM element, append to an empty document to avoid\n elements being stripped by the parser */\n body = _initDocument('<!---->');\n importedNode = body.ownerDocument.importNode(dirty, true);\n if (importedNode.nodeType === NODE_TYPE.element && importedNode.nodeName === 'BODY') {\n /* Node is already a body, use as is */\n body = importedNode;\n } else if (importedNode.nodeName === 'HTML') {\n body = importedNode;\n } else {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n body.appendChild(importedNode);\n }\n /* Clonable shadow roots are deep-cloned by importNode(); sanitize\n them before the main iterator runs, since the iterator does not\n descend into shadow trees. The walk routes every read through a\n cached prototype getter so clobbering descendants on a form root\n cannot hide a shadow host from this pass.\n Traverse from `body`, not `importedNode`: when importedNode is a\n DocumentFragment, the appendChild() above moves its children into\n `body` and leaves the fragment empty, so walking importedNode would\n scan nothing and miss every attached shadow host now under `body`\n (SO-003). In the BODY/HTML branches `body === importedNode`, so this\n is equivalent there; in the element branch `body` contains the\n appended element and its descendants. `body` covers all three. */\n _sanitizeAttachedShadowRoots(body);\n } else {\n /* Exit directly if we have nothing to do */\n if (!RETURN_DOM && !SAFE_FOR_TEMPLATES && !WHOLE_DOCUMENT &&\n // eslint-disable-next-line unicorn/prefer-includes\n dirty.indexOf('<') === -1) {\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(dirty) : dirty;\n }\n /* Initialize the document to work on */\n body = _initDocument(dirty);\n /* Check we have a DOM node from the data */\n if (!body) {\n return RETURN_DOM ? null : RETURN_TRUSTED_TYPE ? emptyHTML : '';\n }\n }\n /* Remove first element node (ours) if FORCE_BODY is set */\n if (body && FORCE_BODY) {\n _forceRemove(body.firstChild);\n }\n /* Get node iterator */\n const walkRoot = inPlace ? dirty : body;\n /* Now start iterating over the created document.\n The walk runs inside an exception barrier (campaign-3 F2): a re-entrant\n engine/custom-element mutation can detach a node mid-walk so\n `_forceRemove`'s parentless guard throws, aborting the loop. Without the\n barrier the caller's in-place tree would be left half-sanitized with the\n unvisited tail still armed. _createNodeIterator itself is inside the\n barrier too: constructing the iterator dereferences the root's document,\n and any failure there (e.g. an exotic/clobbered root) must still fail\n closed rather than skip the neutralize. On any throw we fail closed -\n strip the in-place root bare - then rethrow so the existing throw\n contract is preserved. (String/DOM-copy paths never return the partial\n body, so the propagating throw is already fail-closed there.) */\n try {\n const nodeIterator = _createNodeIterator(walkRoot);\n while (currentNode = nodeIterator.nextNode()) {\n /* Sanitize tags and elements */\n _sanitizeElements(currentNode, walkRoot);\n /* Check attributes next */\n _sanitizeAttributes(currentNode);\n /* Shadow DOM detected, sanitize it.\n Realm-safe check (GHSA-hpcv-96wg-7vj8): nodeType-based detection\n instead of instanceof, so foreign-realm <template>.content is\n walked correctly. */\n if (_isDocumentFragment(currentNode.content)) {\n _sanitizeShadowDOM2(currentNode.content);\n }\n }\n } catch (error) {\n if (inPlace) {\n _neutralizeRoot(dirty);\n /* Nodes _forceRemove'd earlier in the aborted walk are already\n detached from the root, so _neutralizeRoot's subtree pass does not\n reach them. Defuse them too, mirroring the success-path loop below. */\n arrayForEach(DOMPurify.removed, entry => {\n if (entry.element) {\n _neutralizeSubtree(entry.element);\n }\n });\n }\n throw error;\n }\n /* If we sanitized `dirty` in-place, return it. */\n if (inPlace) {\n /* Fail-closed completion of the audit-5 F1 fix: every node removed from\n the caller's live tree is detached but may still hold a queued\n resource-event handler that fires in page scope after we return. The\n move-hoist covers only disallowed-tag KEEP_CONTENT removals; strip the\n non-allow-listed attributes off every other removed subtree (clobber,\n mXSS, namespace, comments, KEEP_CONTENT:false, …) so those handlers are\n cancelled before any event can fire. Runs synchronously, pre-return. */\n arrayForEach(DOMPurify.removed, entry => {\n if (entry.element) {\n _neutralizeSubtree(entry.element);\n }\n });\n if (SAFE_FOR_TEMPLATES) {\n _scrubTemplateExpressions2(dirty);\n }\n return dirty;\n }\n /* Return sanitized string or DOM */\n if (RETURN_DOM) {\n if (SAFE_FOR_TEMPLATES) {\n _scrubTemplateExpressions2(body);\n }\n if (RETURN_DOM_FRAGMENT) {\n returnNode = createDocumentFragment.call(body.ownerDocument);\n while (body.firstChild) {\n // eslint-disable-next-line unicorn/prefer-dom-node-append\n returnNode.appendChild(body.firstChild);\n }\n } else {\n returnNode = body;\n }\n if (ALLOWED_ATTR.shadowroot || ALLOWED_ATTR.shadowrootmode) {\n /*\n AdoptNode() is not used because internal state is not reset\n (e.g. the past names map of a HTMLFormElement), this is safe\n in theory but we would rather not risk another attack vector.\n The state that is cloned by importNode() is explicitly defined\n by the specs.\n */\n returnNode = importNode.call(originalDocument, returnNode, true);\n }\n return returnNode;\n }\n let serializedHTML = WHOLE_DOCUMENT ? body.outerHTML : body.innerHTML;\n /* Serialize doctype if allowed */\n if (WHOLE_DOCUMENT && ALLOWED_TAGS['!doctype'] && body.ownerDocument && body.ownerDocument.doctype && body.ownerDocument.doctype.name && regExpTest(DOCTYPE_NAME, body.ownerDocument.doctype.name)) {\n serializedHTML = '<!DOCTYPE ' + body.ownerDocument.doctype.name + '>\\n' + serializedHTML;\n }\n /* Sanitize final string template-safe */\n if (SAFE_FOR_TEMPLATES) {\n serializedHTML = _stripTemplateExpressions(serializedHTML);\n }\n return trustedTypesPolicy && RETURN_TRUSTED_TYPE ? _createTrustedHTML(serializedHTML) : serializedHTML;\n };\n DOMPurify.setConfig = function () {\n let cfg = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n _parseConfig(cfg);\n SET_CONFIG = true;\n SET_CONFIG_ALLOWED_TAGS = ALLOWED_TAGS;\n SET_CONFIG_ALLOWED_ATTR = ALLOWED_ATTR;\n };\n DOMPurify.clearConfig = function () {\n CONFIG = null;\n SET_CONFIG = false;\n SET_CONFIG_ALLOWED_TAGS = null;\n SET_CONFIG_ALLOWED_ATTR = null;\n // Drop any caller-supplied Trusted Types policy so it cannot poison later\n // `RETURN_TRUSTED_TYPE` output. The internal default policy (cached, and\n // never recreated — Trusted Types throws on duplicate names) is restored by\n // the next `_parseConfig`. See GHSA-vxr8-fq34-vvx9.\n trustedTypesPolicy = defaultTrustedTypesPolicy;\n emptyHTML = '';\n };\n DOMPurify.isValidAttribute = function (tag, attr, value) {\n /* Initialize shared config vars if necessary. */\n if (!CONFIG) {\n _parseConfig({});\n }\n const lcTag = transformCaseFunc(tag);\n const lcName = transformCaseFunc(attr);\n return _isValidAttribute(lcTag, lcName, value);\n };\n DOMPurify.addHook = function (entryPoint, hookFunction) {\n if (typeof hookFunction !== 'function') {\n return;\n }\n /* Reject unknown entry points. Without this, a non-hook key (e.g.\n * '__proto__') indexes off the prototype chain rather than a real\n * hook array, and arrayPush then writes to Object.prototype. Guard\n * with an own-property check against the known hook names. */\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return;\n }\n arrayPush(hooks[entryPoint], hookFunction);\n };\n DOMPurify.removeHook = function (entryPoint, hookFunction) {\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return undefined;\n }\n if (hookFunction !== undefined) {\n const index = arrayLastIndexOf(hooks[entryPoint], hookFunction);\n return index === -1 ? undefined : arraySplice(hooks[entryPoint], index, 1)[0];\n }\n return arrayPop(hooks[entryPoint]);\n };\n DOMPurify.removeHooks = function (entryPoint) {\n if (!objectHasOwnProperty(hooks, entryPoint)) {\n return;\n }\n hooks[entryPoint] = [];\n };\n DOMPurify.removeAllHooks = function () {\n hooks = _createHooksMap();\n };\n return DOMPurify;\n}\nvar purify = createDOMPurify();\n\nmodule.exports = purify;\n//# sourceMappingURL=purify.cjs.js.map\n","// THIS FILE IS AUTOMATICALLY GENERATED DO NOT EDIT DIRECTLY\n// See update-tlds.js for encoding/decoding format\n// https://data.iana.org/TLD/tlds-alpha-by-domain.txt\nconst encodedTlds = 'aaa1rp3bb0ott3vie4c1le2ogado5udhabi7c0ademy5centure6ountant0s9o1tor4d0s1ult4e0g1ro2tna4f0l1rica5g0akhan5ency5i0g1rbus3force5tel5kdn3l0ibaba4pay4lfinanz6state5y2sace3tom5m0azon4ericanexpress7family11x2fam3ica3sterdam8nalytics7droid5quan4z2o0l2partments8p0le4q0uarelle8r0ab1mco4chi3my2pa2t0e3s0da2ia2sociates9t0hleta5torney7u0ction5di0ble3o3spost5thor3o0s4w0s2x0a2z0ure5ba0by2idu3namex4d1k2r0celona5laycard4s5efoot5gains6seball5ketball8uhaus5yern5b0c1t1va3cg1n2d1e0ats2uty4er2rlin4st0buy5t2f1g1h0arti5i0ble3d1ke2ng0o3o1z2j1lack0friday9ockbuster8g1omberg7ue3m0s1w2n0pparibas9o0ats3ehringer8fa2m1nd2o0k0ing5sch2tik2on4t1utique6x2r0adesco6idgestone9oadway5ker3ther5ussels7s1t1uild0ers6siness6y1zz3v1w1y1z0h3ca0b1fe2l0l1vinklein9m0era3p2non3petown5ital0one8r0avan4ds2e0er0s4s2sa1e1h1ino4t0ering5holic7ba1n1re3c1d1enter4o1rn3f0a1d2g1h0anel2nel4rity4se2t2eap3intai5ristmas6ome4urch5i0priani6rcle4sco3tadel4i0c2y3k1l0aims4eaning6ick2nic1que6othing5ud3ub0med6m1n1o0ach3des3ffee4llege4ogne5m0mbank4unity6pany2re3uter5sec4ndos3struction8ulting7tact3ractors9oking4l1p2rsica5untry4pon0s4rses6pa2r0edit0card4union9icket5own3s1uise0s6u0isinella9v1w1x1y0mru3ou3z2dad1nce3ta1e1ing3sun4y2clk3ds2e0al0er2s3gree4livery5l1oitte5ta3mocrat6ntal2ist5si0gn4v2hl2iamonds6et2gital5rect0ory7scount3ver5h2y2j1k1m1np2o0cs1tor4g1mains5t1wnload7rive4tv2ubai3pont4rban5vag2r2z2earth3t2c0o2deka3u0cation8e1g1mail3erck5nergy4gineer0ing9terprises10pson4quipment8r0icsson6ni3s0q1tate5t1u0rovision8s2vents5xchange6pert3osed4ress5traspace10fage2il1rwinds6th3mily4n0s2rm0ers5shion4t3edex3edback6rrari3ero6i0delity5o2lm2nal1nce1ial7re0stone6mdale6sh0ing5t0ness6j1k1lickr3ghts4r2orist4wers5y2m1o0o0d1tball6rd1ex2sale4um3undation8x2r0ee1senius7l1ogans4ntier7tr2ujitsu5n0d2rniture7tbol5yi3ga0l0lery3o1up4me0s3p1rden4y2b0iz3d0n2e0a1nt0ing5orge5f1g0ee3h1i0ft0s3ves2ing5l0ass3e1obal2o4m0ail3bh2o1x2n1odaddy5ld0point6f2odyear5g0le4p1t1v2p1q1r0ainger5phics5tis4een3ipe3ocery4up4s1t1u0cci3ge2ide2tars5ru3w1y2hair2mburg5ngout5us3bo2dfc0bank7ealth0care8lp1sinki6re1mes5iphop4samitsu7tachi5v2k0t2m1n1ockey4ldings5iday5medepot5goods5s0ense7nda3rse3spital5t0ing5t0els3mail5use3w2r1sbc3t1u0ghes5yatt3undai7ibm2cbc2e1u2d1e0ee3fm2kano4l1m0amat4db2mo0bilien9n0c1dustries8finiti5o2g1k1stitute6urance4e4t0ernational10uit4vestments10o1piranga7q1r0ish4s0maili5t0anbul7t0au2v3jaguar4va3cb2e0ep2tzt3welry6io2ll2m0p2nj2o0bs1urg4t1y2p0morgan6rs3uegos4niper7kaufen5ddi3e0rryhotels6properties14fh2g1h1i0a1ds2m1ndle4tchen5wi3m1n1oeln3matsu5sher5p0mg2n2r0d1ed3uokgroup8w1y0oto4z2la0caixa5mborghini8er3nd0rover6xess5salle5t0ino3robe5w0yer5b1c1ds2ease3clerc5frak4gal2o2xus4gbt3i0dl2fe0insurance9style7ghting6ke2lly3mited4o2ncoln4k2ve1ing5k1lc1p2oan0s3cker3us3l1ndon4tte1o3ve3pl0financial11r1s1t0d0a3u0ndbeck6xe1ury5v1y2ma0drid4if1son4keup4n0agement7go3p1rket0ing3s4riott5shalls7ttel5ba2c0kinsey7d1e0d0ia3et2lbourne7me1orial6n0u2rck0msd7g1h1iami3crosoft7l1ni1t2t0subishi9k1l0b1s2m0a2n1o0bi0le4da2e1i1m1nash3ey2ster5rmon3tgage6scow4to0rcycles9v0ie4p1q1r1s0d2t0n1r2u0seum3ic4v1w1x1y1z2na0b1goya4me2vy3ba2c1e0c1t0bank4flix4work5ustar5w0s2xt0direct7us4f0l2g0o2hk2i0co2ke1on3nja3ssan1y5l1o0kia3rton4w0ruz3tv4p1r0a1w2tt2u1yc2z2obi1server7ffice5kinawa6layan0group9lo3m0ega4ne1g1l0ine5oo2pen3racle3nge4g0anic5igins6saka4tsuka4t2vh3pa0ge2nasonic7ris2s1tners4s1y3y2ccw3e0t2f0izer5g1h0armacy6d1ilips5one2to0graphy6s4ysio5ics1tet2ures6d1n0g1k2oneer5zza4k1l0ace2y0station9umbing5s3m1n0c2ohl2ker3litie5rn2st3r0axi3ess3ime3o0d0uctions8f1gressive8mo2perties3y5tection8u0dential9s1t1ub2w0c2y2qa1pon3uebec3st5racing4dio4e0ad1lestate6tor2y4cipes5d0umbrella9hab3ise0n3t2liance6n0t0als5pair3ort3ublican8st0aurant8view0s5xroth6ich0ardli6oh3l1o1p2o0cks3deo3gers4om3s0vp3u0gby3hr2n2w0e2yukyu6sa0arland6fe0ty4kura4le1on3msclub4ung5ndvik0coromant12ofi4p1rl2s1ve2xo3b0i1s2c0b1haeffler7midt4olarships8ol3ule3warz5ience5ot3d1e0arch3t2cure1ity6ek2lect4ner3rvices6ven3w1x0y3fr2g1h0angrila6rp3ell3ia1ksha5oes2p0ping5uji3w3i0lk2na1gles5te3j1k0i0n2y0pe4l0ing4m0art3ile4n0cf3o0ccer3ial4ftbank4ware6hu2lar2utions7ng1y2y2pa0ce3ort2t3r0l2s1t0ada2ples4r1tebank4farm7c0group6ockholm6rage3e3ream4udio2y3yle4u0cks3pplies3y2ort5rf1gery5zuki5v1watch4iss4x1y0dney4stems6z2tab1ipei4lk2obao4rget4tamotors6r2too4x0i3c0i2d0k2eam2ch0nology8l1masek5nnis4va3f1g1h0d1eater2re6iaa2ckets5enda4ps2res2ol4j0maxx4x2k0maxx5l1m0all4n1o0day3kyo3ols3p1ray3shiba5tal3urs3wn2yota3s3r0ade1ing4ining5vel0ers0insurance16ust3v2t1ube2i1nes3shu4v0s2w1z2ua1bank3s2g1k1nicom3versity8o2ol2ps2s1y1z2va0cations7na1guard7c1e0gas3ntures6risign5mögensberater2ung14sicherung10t2g1i0ajes4deo3g1king4llas4n1p1rgin4sa1ion4va1o3laanderen9n1odka3lvo3te1ing3o2yage5u2wales2mart4ter4ng0gou5tch0es6eather0channel12bcam3er2site5d0ding5ibo2r3f1hoswho6ien2ki2lliamhill9n0dows4e1ners6me2oodside6rk0s2ld3w2s1tc1f3xbox3erox4ihuan4n2xx2yz3yachts4hoo3maxun5ndex5e1odobashi7ga2kohama6u0tube6t1un3za0ppos4ra3ero3ip2m1one3uerich6w2';\n// Internationalized domain names containing non-ASCII\nconst encodedUtlds = 'ελ1υ2бг1ел3дети4ею2католик6ом3мкд2он1сква6онлайн5рг3рус2ф2сайт3рб3укр3қаз3հայ3ישראל5קום3ابوظبي5رامكو5لاردن4بحرين5جزائر5سعودية6عليان5مغرب5مارات5یران5بارت2زار4يتك3ھارت5تونس4سودان3رية5شبكة4عراق2ب2مان4فلسطين6قطر3كاثوليك6وم3مصر2ليسيا5وريتانيا7قع4همراه5پاکستان7ڀارت4कॉम3नेट3भारत0म्3ोत5संगठन5বাংলা5ভারত2ৰত4ਭਾਰਤ4ભારત4ଭାରତ4இந்தியா6லங்கை6சிங்கப்பூர்11భారత్5ಭಾರತ4ഭാരതം5ලංකා4คอม3ไทย3ລາວ3გე2みんな3アマゾン4クラウド4グーグル4コム2ストア3セール3ファッション6ポイント4世界2中信1国1國1文网3亚马逊3企业2佛山2信息2健康2八卦2公司1益2台湾1灣2商城1店1标2嘉里0大酒店5在线2大拿2天主教3娱乐2家電2广东2微博2慈善2我爱你3手机2招聘2政务1府2新加坡2闻2时尚2書籍2机构2淡马锡3游戏2澳門2点看2移动2组织机构4网址1店1站1络2联通2谷歌2购物2通販2集团2電訊盈科4飞利浦3食品2餐厅2香格里拉3港2닷넷1컴2삼성2한국2';\n\n/**\n * Finite State Machine generation utilities\n */\n\n/**\n * @template T\n * @typedef {{ [group: string]: T[] }} Collections\n */\n\n/**\n * @typedef {{ [group: string]: true }} Flags\n */\n\n// Keys in scanner Collections instances\nconst numeric = 'numeric';\nconst ascii = 'ascii';\nconst alpha = 'alpha';\nconst asciinumeric = 'asciinumeric';\nconst alphanumeric = 'alphanumeric';\nconst domain = 'domain';\nconst emoji = 'emoji';\nconst scheme = 'scheme';\nconst slashscheme = 'slashscheme';\nconst whitespace = 'whitespace';\n\n/**\n * @template T\n * @param {string} name\n * @param {Collections<T>} groups to register in\n * @returns {T[]} Current list of tokens in the given collection\n */\nfunction registerGroup(name, groups) {\n if (!(name in groups)) {\n groups[name] = [];\n }\n return groups[name];\n}\n\n/**\n * @template T\n * @param {T} t token to add\n * @param {Collections<T>} groups\n * @param {Flags} flags\n */\nfunction addToGroups(t, flags, groups) {\n if (flags[numeric]) {\n flags[asciinumeric] = true;\n flags[alphanumeric] = true;\n }\n if (flags[ascii]) {\n flags[asciinumeric] = true;\n flags[alpha] = true;\n }\n if (flags[asciinumeric]) {\n flags[alphanumeric] = true;\n }\n if (flags[alpha]) {\n flags[alphanumeric] = true;\n }\n if (flags[alphanumeric]) {\n flags[domain] = true;\n }\n if (flags[emoji]) {\n flags[domain] = true;\n }\n for (const k in flags) {\n const group = registerGroup(k, groups);\n if (group.indexOf(t) < 0) {\n group.push(t);\n }\n }\n}\n\n/**\n * @template T\n * @param {T} t token to check\n * @param {Collections<T>} groups\n * @returns {Flags} group flags that contain this token\n */\nfunction flagsForToken(t, groups) {\n const result = {};\n for (const c in groups) {\n if (groups[c].indexOf(t) >= 0) {\n result[c] = true;\n }\n }\n return result;\n}\n\n/**\n * @template T\n * @typedef {null | T } Transition\n */\n\n/**\n * Define a basic state machine state. j is the list of character transitions,\n * jr is the list of regex-match transitions, jd is the default state to\n * transition to t is the accepting token type, if any. If this is the terminal\n * state, then it does not emit a token.\n *\n * The template type T represents the type of the token this state accepts. This\n * should be a string (such as of the token exports in `text.js`) or a\n * MultiToken subclass (from `multi.js`)\n *\n * @template T\n * @param {T} [token] Token that this state emits\n */\nfunction State(token = null) {\n // this.n = null; // DEBUG: State name\n /** @type {{ [input: string]: State<T> }} j */\n this.j = {}; // IMPLEMENTATION 1\n // this.j = []; // IMPLEMENTATION 2\n /** @type {[RegExp, State<T>][]} jr */\n this.jr = [];\n /** @type {?State<T>} jd */\n this.jd = null;\n /** @type {?T} t */\n this.t = token;\n}\n\n/**\n * Scanner token groups\n * @type Collections<string>\n */\nState.groups = {};\nState.prototype = {\n accepts() {\n return !!this.t;\n },\n /**\n * Follow an existing transition from the given input to the next state.\n * Does not mutate.\n * @param {string} input character or token type to transition on\n * @returns {?State<T>} the next state, if any\n */\n go(input) {\n const state = this;\n const nextState = state.j[input];\n if (nextState) {\n return nextState;\n }\n for (let i = 0; i < state.jr.length; i++) {\n const regex = state.jr[i][0];\n const nextState = state.jr[i][1]; // note: might be empty to prevent default jump\n if (nextState && regex.test(input)) {\n return nextState;\n }\n }\n // Nowhere left to jump! Return default, if any\n return state.jd;\n },\n /**\n * Whether the state has a transition for the given input. Set the second\n * argument to true to only look for an exact match (and not a default or\n * regular-expression-based transition)\n * @param {string} input\n * @param {boolean} exactOnly\n */\n has(input, exactOnly = false) {\n return exactOnly ? input in this.j : !!this.go(input);\n },\n /**\n * Short for \"transition all\"; create a transition from the array of items\n * in the given list to the same final resulting state.\n * @param {string | string[]} inputs Group of inputs to transition on\n * @param {Transition<T> | State<T>} [next] Transition options\n * @param {Flags} [flags] Collections flags to add token to\n * @param {Collections<T>} [groups] Master list of token groups\n */\n ta(inputs, next, flags, groups) {\n for (let i = 0; i < inputs.length; i++) {\n this.tt(inputs[i], next, flags, groups);\n }\n },\n /**\n * Short for \"take regexp transition\"; defines a transition for this state\n * when it encounters a token which matches the given regular expression\n * @param {RegExp} regexp Regular expression transition (populate first)\n * @param {T | State<T>} [next] Transition options\n * @param {Flags} [flags] Collections flags to add token to\n * @param {Collections<T>} [groups] Master list of token groups\n * @returns {State<T>} taken after the given input\n */\n tr(regexp, next, flags, groups) {\n groups = groups || State.groups;\n let nextState;\n if (next && next.j) {\n nextState = next;\n } else {\n // Token with maybe token groups\n nextState = new State(next);\n if (flags && groups) {\n addToGroups(next, flags, groups);\n }\n }\n this.jr.push([regexp, nextState]);\n return nextState;\n },\n /**\n * Short for \"take transitions\", will take as many sequential transitions as\n * the length of the given input and returns the\n * resulting final state.\n * @param {string | string[]} input\n * @param {T | State<T>} [next] Transition options\n * @param {Flags} [flags] Collections flags to add token to\n * @param {Collections<T>} [groups] Master list of token groups\n * @returns {State<T>} taken after the given input\n */\n ts(input, next, flags, groups) {\n let state = this;\n const len = input.length;\n if (!len) {\n return state;\n }\n for (let i = 0; i < len - 1; i++) {\n state = state.tt(input[i]);\n }\n return state.tt(input[len - 1], next, flags, groups);\n },\n /**\n * Short for \"take transition\", this is a method for building/working with\n * state machines.\n *\n * If a state already exists for the given input, returns it.\n *\n * If a token is specified, that state will emit that token when reached by\n * the linkify engine.\n *\n * If no state exists, it will be initialized with some default transitions\n * that resemble existing default transitions.\n *\n * If a state is given for the second argument, that state will be\n * transitioned to on the given input regardless of what that input\n * previously did.\n *\n * Specify a token group flags to define groups that this token belongs to.\n * The token will be added to corresponding entires in the given groups\n * object.\n *\n * @param {string} input character, token type to transition on\n * @param {T | State<T>} [next] Transition options\n * @param {Flags} [flags] Collections flags to add token to\n * @param {Collections<T>} [groups] Master list of groups\n * @returns {State<T>} taken after the given input\n */\n tt(input, next, flags, groups) {\n groups = groups || State.groups;\n const state = this;\n\n // Check if existing state given, just a basic transition\n if (next && next.j) {\n state.j[input] = next;\n return next;\n }\n const t = next;\n\n // Take the transition with the usual default mechanisms and use that as\n // a template for creating the next state\n let nextState,\n templateState = state.go(input);\n if (templateState) {\n nextState = new State();\n Object.assign(nextState.j, templateState.j);\n nextState.jr.push.apply(nextState.jr, templateState.jr);\n nextState.jd = templateState.jd;\n nextState.t = templateState.t;\n } else {\n nextState = new State();\n }\n if (t) {\n // Ensure newly token is in the same groups as the old token\n if (groups) {\n if (nextState.t && typeof nextState.t === 'string') {\n const allFlags = Object.assign(flagsForToken(nextState.t, groups), flags);\n addToGroups(t, allFlags, groups);\n } else if (flags) {\n addToGroups(t, flags, groups);\n }\n }\n nextState.t = t; // overwrite anything that was previously there\n }\n state.j[input] = nextState;\n return nextState;\n }\n};\n\n// Helper functions to improve minification (not exported outside linkifyjs module)\n\n/**\n * @template T\n * @param {State<T>} state\n * @param {string | string[]} input\n * @param {Flags} [flags]\n * @param {Collections<T>} [groups]\n */\nconst ta = (state, input, next, flags, groups) => state.ta(input, next, flags, groups);\n\n/**\n * @template T\n * @param {State<T>} state\n * @param {RegExp} regexp\n * @param {T | State<T>} [next]\n * @param {Flags} [flags]\n * @param {Collections<T>} [groups]\n */\nconst tr = (state, regexp, next, flags, groups) => state.tr(regexp, next, flags, groups);\n\n/**\n * @template T\n * @param {State<T>} state\n * @param {string | string[]} input\n * @param {T | State<T>} [next]\n * @param {Flags} [flags]\n * @param {Collections<T>} [groups]\n */\nconst ts = (state, input, next, flags, groups) => state.ts(input, next, flags, groups);\n\n/**\n * @template T\n * @param {State<T>} state\n * @param {string} input\n * @param {T | State<T>} [next]\n * @param {Collections<T>} [groups]\n * @param {Flags} [flags]\n */\nconst tt = (state, input, next, flags, groups) => state.tt(input, next, flags, groups);\n\n/******************************************************************************\nText Tokens\nIdentifiers for token outputs from the regexp scanner\n******************************************************************************/\n\n// A valid web domain token\nconst WORD = 'WORD'; // only contains a-z\nconst UWORD = 'UWORD'; // contains letters other than a-z, used for IDN\nconst ASCIINUMERICAL = 'ASCIINUMERICAL'; // contains a-z, 0-9\nconst ALPHANUMERICAL = 'ALPHANUMERICAL'; // contains numbers and letters other than a-z, used for IDN\n\n// Special case of word\nconst LOCALHOST = 'LOCALHOST';\n\n// Valid top-level domain, special case of WORD (see tlds.js)\nconst TLD = 'TLD';\n\n// Valid IDN TLD, special case of UWORD (see tlds.js)\nconst UTLD = 'UTLD';\n\n// The scheme portion of a web URI protocol. Supported types include: `mailto`,\n// `file`, and user-defined custom protocols. Limited to schemes that contain\n// only letters\nconst SCHEME = 'SCHEME';\n\n// Similar to SCHEME, except makes distinction for schemes that must always be\n// followed by `://`, not just `:`. Supported types include `http`, `https`,\n// `ftp`, `ftps`\nconst SLASH_SCHEME = 'SLASH_SCHEME';\n\n// Any sequence of digits 0-9\nconst NUM = 'NUM';\n\n// Any number of consecutive whitespace characters that are not newline\nconst WS = 'WS';\n\n// New line (unix style)\nconst NL = 'NL'; // \\n\n\n// Opening/closing bracket classes\n// TODO: Rename OPEN -> LEFT and CLOSE -> RIGHT in v5 to fit with Unicode names\n// Also rename angle brackes to LESSTHAN and GREATER THAN\nconst OPENBRACE = 'OPENBRACE'; // {\nconst CLOSEBRACE = 'CLOSEBRACE'; // }\nconst OPENBRACKET = 'OPENBRACKET'; // [\nconst CLOSEBRACKET = 'CLOSEBRACKET'; // ]\nconst OPENPAREN = 'OPENPAREN'; // (\nconst CLOSEPAREN = 'CLOSEPAREN'; // )\nconst OPENANGLEBRACKET = 'OPENANGLEBRACKET'; // <\nconst CLOSEANGLEBRACKET = 'CLOSEANGLEBRACKET'; // >\nconst FULLWIDTHLEFTPAREN = 'FULLWIDTHLEFTPAREN'; // (\nconst FULLWIDTHRIGHTPAREN = 'FULLWIDTHRIGHTPAREN'; // )\nconst LEFTCORNERBRACKET = 'LEFTCORNERBRACKET'; // 「\nconst RIGHTCORNERBRACKET = 'RIGHTCORNERBRACKET'; // 」\nconst LEFTWHITECORNERBRACKET = 'LEFTWHITECORNERBRACKET'; // 『\nconst RIGHTWHITECORNERBRACKET = 'RIGHTWHITECORNERBRACKET'; // 』\nconst FULLWIDTHLESSTHAN = 'FULLWIDTHLESSTHAN'; // <\nconst FULLWIDTHGREATERTHAN = 'FULLWIDTHGREATERTHAN'; // >\n\n// Various symbols\nconst AMPERSAND = 'AMPERSAND'; // &\nconst APOSTROPHE = 'APOSTROPHE'; // '\nconst ASTERISK = 'ASTERISK'; // *\nconst AT = 'AT'; // @\nconst BACKSLASH = 'BACKSLASH'; // \\\nconst BACKTICK = 'BACKTICK'; // `\nconst CARET = 'CARET'; // ^\nconst COLON = 'COLON'; // :\nconst COMMA = 'COMMA'; // ,\nconst DOLLAR = 'DOLLAR'; // $\nconst DOT = 'DOT'; // .\nconst EQUALS = 'EQUALS'; // =\nconst EXCLAMATION = 'EXCLAMATION'; // !\nconst HYPHEN = 'HYPHEN'; // -\nconst PERCENT = 'PERCENT'; // %\nconst PIPE = 'PIPE'; // |\nconst PLUS = 'PLUS'; // +\nconst POUND = 'POUND'; // #\nconst QUERY = 'QUERY'; // ?\nconst QUOTE = 'QUOTE'; // \"\nconst FULLWIDTHMIDDLEDOT = 'FULLWIDTHMIDDLEDOT'; // ・\n\nconst SEMI = 'SEMI'; // ;\nconst SLASH = 'SLASH'; // /\nconst TILDE = 'TILDE'; // ~\nconst UNDERSCORE = 'UNDERSCORE'; // _\n\n// Emoji symbol\nconst EMOJI$1 = 'EMOJI';\n\n// Default token - anything that is not one of the above\nconst SYM = 'SYM';\n\nvar tk = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tALPHANUMERICAL: ALPHANUMERICAL,\n\tAMPERSAND: AMPERSAND,\n\tAPOSTROPHE: APOSTROPHE,\n\tASCIINUMERICAL: ASCIINUMERICAL,\n\tASTERISK: ASTERISK,\n\tAT: AT,\n\tBACKSLASH: BACKSLASH,\n\tBACKTICK: BACKTICK,\n\tCARET: CARET,\n\tCLOSEANGLEBRACKET: CLOSEANGLEBRACKET,\n\tCLOSEBRACE: CLOSEBRACE,\n\tCLOSEBRACKET: CLOSEBRACKET,\n\tCLOSEPAREN: CLOSEPAREN,\n\tCOLON: COLON,\n\tCOMMA: COMMA,\n\tDOLLAR: DOLLAR,\n\tDOT: DOT,\n\tEMOJI: EMOJI$1,\n\tEQUALS: EQUALS,\n\tEXCLAMATION: EXCLAMATION,\n\tFULLWIDTHGREATERTHAN: FULLWIDTHGREATERTHAN,\n\tFULLWIDTHLEFTPAREN: FULLWIDTHLEFTPAREN,\n\tFULLWIDTHLESSTHAN: FULLWIDTHLESSTHAN,\n\tFULLWIDTHMIDDLEDOT: FULLWIDTHMIDDLEDOT,\n\tFULLWIDTHRIGHTPAREN: FULLWIDTHRIGHTPAREN,\n\tHYPHEN: HYPHEN,\n\tLEFTCORNERBRACKET: LEFTCORNERBRACKET,\n\tLEFTWHITECORNERBRACKET: LEFTWHITECORNERBRACKET,\n\tLOCALHOST: LOCALHOST,\n\tNL: NL,\n\tNUM: NUM,\n\tOPENANGLEBRACKET: OPENANGLEBRACKET,\n\tOPENBRACE: OPENBRACE,\n\tOPENBRACKET: OPENBRACKET,\n\tOPENPAREN: OPENPAREN,\n\tPERCENT: PERCENT,\n\tPIPE: PIPE,\n\tPLUS: PLUS,\n\tPOUND: POUND,\n\tQUERY: QUERY,\n\tQUOTE: QUOTE,\n\tRIGHTCORNERBRACKET: RIGHTCORNERBRACKET,\n\tRIGHTWHITECORNERBRACKET: RIGHTWHITECORNERBRACKET,\n\tSCHEME: SCHEME,\n\tSEMI: SEMI,\n\tSLASH: SLASH,\n\tSLASH_SCHEME: SLASH_SCHEME,\n\tSYM: SYM,\n\tTILDE: TILDE,\n\tTLD: TLD,\n\tUNDERSCORE: UNDERSCORE,\n\tUTLD: UTLD,\n\tUWORD: UWORD,\n\tWORD: WORD,\n\tWS: WS\n});\n\n// Note that these two Unicode ones expand into a really big one with Babel\nconst ASCII_LETTER = /[a-z]/;\nconst LETTER = /\\p{L}/u; // Any Unicode character with letter data type\nconst EMOJI = /\\p{Emoji}/u; // Any Unicode emoji character\nconst EMOJI_VARIATION$1 = /\\ufe0f/;\nconst DIGIT = /\\d/;\nconst SPACE = /\\s/;\n\nvar regexp = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tASCII_LETTER: ASCII_LETTER,\n\tDIGIT: DIGIT,\n\tEMOJI: EMOJI,\n\tEMOJI_VARIATION: EMOJI_VARIATION$1,\n\tLETTER: LETTER,\n\tSPACE: SPACE\n});\n\n/**\n\tThe scanner provides an interface that takes a string of text as input, and\n\toutputs an array of tokens instances that can be used for easy URL parsing.\n*/\n\nconst CR = '\\r'; // carriage-return character\nconst LF = '\\n'; // line-feed character\nconst EMOJI_VARIATION = '\\ufe0f'; // Variation selector, follows heart and others\nconst EMOJI_JOINER = '\\u200d'; // zero-width joiner\nconst OBJECT_REPLACEMENT = '\\ufffc'; // whitespace placeholder that sometimes appears in rich text editors\n\nlet tlds = null,\n utlds = null; // don't change so only have to be computed once\n\n/**\n * Scanner output token:\n * - `t` is the token name (e.g., 'NUM', 'EMOJI', 'TLD')\n * - `v` is the value of the token (e.g., '123', '❤️', 'com')\n * - `s` is the start index of the token in the original string\n * - `e` is the end index of the token in the original string\n * @typedef {{t: string, v: string, s: number, e: number}} Token\n */\n\n/**\n * @template T\n * @typedef {{ [collection: string]: T[] }} Collections\n */\n\n/**\n * Initialize the scanner character-based state machine for the given start\n * state\n * @param {[string, boolean][]} customSchemes List of custom schemes, where each\n * item is a length-2 tuple with the first element set to the string scheme, and\n * the second element set to `true` if the `://` after the scheme is optional\n */\nfunction init$2(customSchemes = []) {\n // Frequently used states (name argument removed during minification)\n /** @type Collections<string> */\n const groups = {}; // of tokens\n State.groups = groups;\n /** @type State<string> */\n const Start = new State();\n if (tlds == null) {\n tlds = decodeTlds(encodedTlds);\n }\n if (utlds == null) {\n utlds = decodeTlds(encodedUtlds);\n }\n\n // States for special URL symbols that accept immediately after start\n tt(Start, \"'\", APOSTROPHE);\n tt(Start, '{', OPENBRACE);\n tt(Start, '}', CLOSEBRACE);\n tt(Start, '[', OPENBRACKET);\n tt(Start, ']', CLOSEBRACKET);\n tt(Start, '(', OPENPAREN);\n tt(Start, ')', CLOSEPAREN);\n tt(Start, '<', OPENANGLEBRACKET);\n tt(Start, '>', CLOSEANGLEBRACKET);\n tt(Start, '(', FULLWIDTHLEFTPAREN);\n tt(Start, ')', FULLWIDTHRIGHTPAREN);\n tt(Start, '「', LEFTCORNERBRACKET);\n tt(Start, '」', RIGHTCORNERBRACKET);\n tt(Start, '『', LEFTWHITECORNERBRACKET);\n tt(Start, '』', RIGHTWHITECORNERBRACKET);\n tt(Start, '<', FULLWIDTHLESSTHAN);\n tt(Start, '>', FULLWIDTHGREATERTHAN);\n tt(Start, '&', AMPERSAND);\n tt(Start, '*', ASTERISK);\n tt(Start, '@', AT);\n tt(Start, '`', BACKTICK);\n tt(Start, '^', CARET);\n tt(Start, ':', COLON);\n tt(Start, ',', COMMA);\n tt(Start, '$', DOLLAR);\n tt(Start, '.', DOT);\n tt(Start, '=', EQUALS);\n tt(Start, '!', EXCLAMATION);\n tt(Start, '-', HYPHEN);\n tt(Start, '%', PERCENT);\n tt(Start, '|', PIPE);\n tt(Start, '+', PLUS);\n tt(Start, '#', POUND);\n tt(Start, '?', QUERY);\n tt(Start, '\"', QUOTE);\n tt(Start, '/', SLASH);\n tt(Start, ';', SEMI);\n tt(Start, '~', TILDE);\n tt(Start, '_', UNDERSCORE);\n tt(Start, '\\\\', BACKSLASH);\n tt(Start, '・', FULLWIDTHMIDDLEDOT);\n const Num = tr(Start, DIGIT, NUM, {\n [numeric]: true\n });\n tr(Num, DIGIT, Num);\n const Asciinumeric = tr(Num, ASCII_LETTER, ASCIINUMERICAL, {\n [asciinumeric]: true\n });\n const Alphanumeric = tr(Num, LETTER, ALPHANUMERICAL, {\n [alphanumeric]: true\n });\n\n // State which emits a word token\n const Word = tr(Start, ASCII_LETTER, WORD, {\n [ascii]: true\n });\n tr(Word, DIGIT, Asciinumeric);\n tr(Word, ASCII_LETTER, Word);\n tr(Asciinumeric, DIGIT, Asciinumeric);\n tr(Asciinumeric, ASCII_LETTER, Asciinumeric);\n\n // Same as previous, but specific to non-fsm.ascii alphabet words\n const UWord = tr(Start, LETTER, UWORD, {\n [alpha]: true\n });\n tr(UWord, ASCII_LETTER); // Non-accepting\n tr(UWord, DIGIT, Alphanumeric);\n tr(UWord, LETTER, UWord);\n tr(Alphanumeric, DIGIT, Alphanumeric);\n tr(Alphanumeric, ASCII_LETTER); // Non-accepting\n tr(Alphanumeric, LETTER, Alphanumeric); // Non-accepting\n\n // Whitespace jumps\n // Tokens of only non-newline whitespace are arbitrarily long\n // If any whitespace except newline, more whitespace!\n const Nl = tt(Start, LF, NL, {\n [whitespace]: true\n });\n const Cr = tt(Start, CR, WS, {\n [whitespace]: true\n });\n const Ws = tr(Start, SPACE, WS, {\n [whitespace]: true\n });\n tt(Start, OBJECT_REPLACEMENT, Ws);\n tt(Cr, LF, Nl); // \\r\\n\n tt(Cr, OBJECT_REPLACEMENT, Ws);\n tr(Cr, SPACE, Ws);\n tt(Ws, CR); // non-accepting state to avoid mixing whitespaces\n tt(Ws, LF); // non-accepting state to avoid mixing whitespaces\n tr(Ws, SPACE, Ws);\n tt(Ws, OBJECT_REPLACEMENT, Ws);\n\n // Emoji tokens. They are not grouped by the scanner except in cases where a\n // zero-width joiner is present\n const Emoji = tr(Start, EMOJI, EMOJI$1, {\n [emoji]: true\n });\n tt(Emoji, '#'); // no transition, emoji regex seems to match #\n tr(Emoji, EMOJI, Emoji);\n tt(Emoji, EMOJI_VARIATION, Emoji);\n // tt(Start, EMOJI_VARIATION, Emoji); // This one is sketchy\n\n const EmojiJoiner = tt(Emoji, EMOJI_JOINER);\n tt(EmojiJoiner, '#');\n tr(EmojiJoiner, EMOJI, Emoji);\n // tt(EmojiJoiner, EMOJI_VARIATION, Emoji); // also sketchy\n\n // Generates states for top-level domains\n // Note that this is most accurate when tlds are in alphabetical order\n const wordjr = [[ASCII_LETTER, Word], [DIGIT, Asciinumeric]];\n const uwordjr = [[ASCII_LETTER, null], [LETTER, UWord], [DIGIT, Alphanumeric]];\n for (let i = 0; i < tlds.length; i++) {\n fastts(Start, tlds[i], TLD, WORD, wordjr);\n }\n for (let i = 0; i < utlds.length; i++) {\n fastts(Start, utlds[i], UTLD, UWORD, uwordjr);\n }\n addToGroups(TLD, {\n tld: true,\n ascii: true\n }, groups);\n addToGroups(UTLD, {\n utld: true,\n alpha: true\n }, groups);\n\n // Collect the states generated by different protocols. NOTE: If any new TLDs\n // get added that are also protocols, set the token to be the same as the\n // protocol to ensure parsing works as expected.\n fastts(Start, 'file', SCHEME, WORD, wordjr);\n fastts(Start, 'mailto', SCHEME, WORD, wordjr);\n fastts(Start, 'http', SLASH_SCHEME, WORD, wordjr);\n fastts(Start, 'https', SLASH_SCHEME, WORD, wordjr);\n fastts(Start, 'ftp', SLASH_SCHEME, WORD, wordjr);\n fastts(Start, 'ftps', SLASH_SCHEME, WORD, wordjr);\n addToGroups(SCHEME, {\n scheme: true,\n ascii: true\n }, groups);\n addToGroups(SLASH_SCHEME, {\n slashscheme: true,\n ascii: true\n }, groups);\n\n // Register custom schemes. Assumes each scheme is asciinumeric with hyphens\n customSchemes = customSchemes.sort((a, b) => a[0] > b[0] ? 1 : -1);\n for (let i = 0; i < customSchemes.length; i++) {\n const sch = customSchemes[i][0];\n const optionalSlashSlash = customSchemes[i][1];\n const flags = optionalSlashSlash ? {\n [scheme]: true\n } : {\n [slashscheme]: true\n };\n if (sch.indexOf('-') >= 0) {\n flags[domain] = true;\n } else if (!ASCII_LETTER.test(sch)) {\n flags[numeric] = true; // numbers only\n } else if (DIGIT.test(sch)) {\n flags[asciinumeric] = true;\n } else {\n flags[ascii] = true;\n }\n ts(Start, sch, sch, flags);\n }\n\n // Localhost token\n ts(Start, 'localhost', LOCALHOST, {\n ascii: true\n });\n\n // Set default transition for start state (some symbol)\n Start.jd = new State(SYM);\n return {\n start: Start,\n tokens: Object.assign({\n groups\n }, tk)\n };\n}\n\n/**\n\tGiven a string, returns an array of TOKEN instances representing the\n\tcomposition of that string.\n\n\t@method run\n\t@param {State<string>} start scanner starting state\n\t@param {string} str input string to scan\n\t@return {Token[]} list of tokens, each with a type and value\n*/\nfunction run$1(start, str) {\n // State machine is not case sensitive, so input is tokenized in lowercased\n // form (still returns regular case). Uses selective `toLowerCase` because\n // lowercasing the entire string causes the length and character position to\n // vary in some non-English strings with V8-based runtimes.\n const iterable = stringToArray(str.replace(/[A-Z]/g, c => c.toLowerCase()));\n const charCount = iterable.length; // <= len if there are emojis, etc\n const tokens = []; // return value\n\n // cursor through the string itself, accounting for characters that have\n // width with length 2 such as emojis\n let cursor = 0;\n\n // Cursor through the array-representation of the string\n let charCursor = 0;\n\n // Tokenize the string\n while (charCursor < charCount) {\n let state = start;\n let nextState = null;\n let tokenLength = 0;\n let latestAccepting = null;\n let sinceAccepts = -1;\n let charsSinceAccepts = -1;\n while (charCursor < charCount && (nextState = state.go(iterable[charCursor]))) {\n state = nextState;\n\n // Keep track of the latest accepting state\n if (state.accepts()) {\n sinceAccepts = 0;\n charsSinceAccepts = 0;\n latestAccepting = state;\n } else if (sinceAccepts >= 0) {\n sinceAccepts += iterable[charCursor].length;\n charsSinceAccepts++;\n }\n tokenLength += iterable[charCursor].length;\n cursor += iterable[charCursor].length;\n charCursor++;\n }\n\n // Roll back to the latest accepting state\n cursor -= sinceAccepts;\n charCursor -= charsSinceAccepts;\n tokenLength -= sinceAccepts;\n\n // No more jumps, just make a new token from the last accepting one\n tokens.push({\n t: latestAccepting.t,\n // token type/name\n v: str.slice(cursor - tokenLength, cursor),\n // string value\n s: cursor - tokenLength,\n // start index\n e: cursor // end index (excluding)\n });\n }\n return tokens;\n}\n\n/**\n * Convert a String to an Array of characters, taking into account that some\n * characters like emojis take up two string indexes.\n *\n * Adapted from core-js (MIT license)\n * https://github.com/zloirock/core-js/blob/2d69cf5f99ab3ea3463c395df81e5a15b68f49d9/packages/core-js/internals/string-multibyte.js\n *\n * @function stringToArray\n * @param {string} str\n * @returns {string[]}\n */\nfunction stringToArray(str) {\n const result = [];\n const len = str.length;\n let index = 0;\n while (index < len) {\n let first = str.charCodeAt(index);\n let second;\n let char = first < 0xd800 || first > 0xdbff || index + 1 === len || (second = str.charCodeAt(index + 1)) < 0xdc00 || second > 0xdfff ? str[index] // single character\n : str.slice(index, index + 2); // two-index characters\n result.push(char);\n index += char.length;\n }\n return result;\n}\n\n/**\n * Fast version of ts function for when transition defaults are well known\n * @param {State<string>} state\n * @param {string} input\n * @param {string} t\n * @param {string} defaultt\n * @param {[RegExp, State<string>][]} jr\n * @returns {State<string>}\n */\nfunction fastts(state, input, t, defaultt, jr) {\n let next;\n const len = input.length;\n for (let i = 0; i < len - 1; i++) {\n const char = input[i];\n if (state.j[char]) {\n next = state.j[char];\n } else {\n next = new State(defaultt);\n next.jr = jr.slice();\n state.j[char] = next;\n }\n state = next;\n }\n next = new State(t);\n next.jr = jr.slice();\n state.j[input[len - 1]] = next;\n return next;\n}\n\n/**\n * Converts a string of Top-Level Domain names encoded in update-tlds.js back\n * into a list of strings.\n * @param {str} encoded encoded TLDs string\n * @returns {str[]} original TLDs list\n */\nfunction decodeTlds(encoded) {\n const words = [];\n const stack = [];\n let i = 0;\n let digits = '0123456789';\n while (i < encoded.length) {\n let popDigitCount = 0;\n while (digits.indexOf(encoded[i + popDigitCount]) >= 0) {\n popDigitCount++; // encountered some digits, have to pop to go one level up trie\n }\n if (popDigitCount > 0) {\n words.push(stack.join('')); // whatever preceded the pop digits must be a word\n for (let popCount = parseInt(encoded.substring(i, i + popDigitCount), 10); popCount > 0; popCount--) {\n stack.pop();\n }\n i += popDigitCount;\n } else {\n stack.push(encoded[i]); // drop down a level into the trie\n i++;\n }\n }\n return words;\n}\n\n/**\n * An object where each key is a valid DOM Event Name such as `click` or `focus`\n * and each value is an event handler function.\n *\n * https://developer.mozilla.org/en-US/docs/Web/API/Element#events\n * @typedef {?{ [event: string]: Function }} EventListeners\n */\n\n/**\n * All formatted properties required to render a link, including `tagName`,\n * `attributes`, `content` and `eventListeners`.\n * @typedef {{ tagName: any, attributes: {[attr: string]: any}, content: string,\n * eventListeners: EventListeners }} IntermediateRepresentation\n */\n\n/**\n * Specify either an object described by the template type `O` or a function.\n *\n * The function takes a string value (usually the link's href attribute), the\n * link type (`'url'`, `'hashtag`', etc.) and an internal token representation\n * of the link. It should return an object of the template type `O`\n * @template O\n * @typedef {O | ((value: string, type: string, token: MultiToken) => O)} OptObj\n */\n\n/**\n * Specify either a function described by template type `F` or an object.\n *\n * Each key in the object should be a link type (`'url'`, `'hashtag`', etc.). Each\n * value should be a function with template type `F` that is called when the\n * corresponding link type is encountered.\n * @template F\n * @typedef {F | { [type: string]: F}} OptFn\n */\n\n/**\n * Specify either a value with template type `V`, a function that returns `V` or\n * an object where each value resolves to `V`.\n *\n * The function takes a string value (usually the link's href attribute), the\n * link type (`'url'`, `'hashtag`', etc.) and an internal token representation\n * of the link. It should return an object of the template type `V`\n *\n * For the object, each key should be a link type (`'url'`, `'hashtag`', etc.).\n * Each value should either have type `V` or a function that returns V. This\n * function similarly takes a string value and a token.\n *\n * Example valid types for `Opt<string>`:\n *\n * ```js\n * 'hello'\n * (value, type, token) => 'world'\n * { url: 'hello', email: (value, token) => 'world'}\n * ```\n * @template V\n * @typedef {V | ((value: string, type: string, token: MultiToken) => V) | { [type: string]: V | ((value: string, token: MultiToken) => V) }} Opt\n */\n\n/**\n * See available options: https://linkify.js.org/docs/options.html\n * @typedef {{\n * \tdefaultProtocol?: string,\n * events?: OptObj<EventListeners>,\n * \tformat?: Opt<string>,\n * \tformatHref?: Opt<string>,\n * \tnl2br?: boolean,\n * \ttagName?: Opt<any>,\n * \ttarget?: Opt<string>,\n * \trel?: Opt<string>,\n * \tvalidate?: Opt<boolean>,\n * \ttruncate?: Opt<number>,\n * \tclassName?: Opt<string>,\n * \tattributes?: OptObj<({ [attr: string]: any })>,\n * ignoreTags?: string[],\n * \trender?: OptFn<((ir: IntermediateRepresentation) => any)>\n * }} Opts\n */\n\n/**\n * @type Required<Opts>\n */\nconst defaults = {\n defaultProtocol: 'http',\n events: null,\n format: noop,\n formatHref: noop,\n nl2br: false,\n tagName: 'a',\n target: null,\n rel: null,\n validate: true,\n truncate: Infinity,\n className: null,\n attributes: null,\n ignoreTags: [],\n render: null\n};\n\n/**\n * Utility class for linkify interfaces to apply specified\n * {@link Opts formatting and rendering options}.\n *\n * @param {Opts | Options} [opts] Option value overrides.\n * @param {(ir: IntermediateRepresentation) => any} [defaultRender] (For\n * internal use) default render function that determines how to generate an\n * HTML element based on a link token's derived tagName, attributes and HTML.\n * Similar to render option\n */\nfunction Options(opts, defaultRender = null) {\n let o = Object.assign({}, defaults);\n if (opts) {\n o = Object.assign(o, opts instanceof Options ? opts.o : opts);\n }\n\n // Ensure all ignored tags are uppercase\n const ignoredTags = o.ignoreTags;\n const uppercaseIgnoredTags = [];\n for (let i = 0; i < ignoredTags.length; i++) {\n uppercaseIgnoredTags.push(ignoredTags[i].toUpperCase());\n }\n /** @protected */\n this.o = o;\n if (defaultRender) {\n this.defaultRender = defaultRender;\n }\n this.ignoreTags = uppercaseIgnoredTags;\n}\nOptions.prototype = {\n o: defaults,\n /**\n * @type string[]\n */\n ignoreTags: [],\n /**\n * @param {IntermediateRepresentation} ir\n * @returns {any}\n */\n defaultRender(ir) {\n return ir;\n },\n /**\n * Returns true or false based on whether a token should be displayed as a\n * link based on the user options.\n * @param {MultiToken} token\n * @returns {boolean}\n */\n check(token) {\n return this.get('validate', token.toString(), token);\n },\n // Private methods\n\n /**\n * Resolve an option's value based on the value of the option and the given\n * params. If operator and token are specified and the target option is\n * callable, automatically calls the function with the given argument.\n * @template {keyof Opts} K\n * @param {K} key Name of option to use\n * @param {string} [operator] will be passed to the target option if it's a\n * function. If not specified, RAW function value gets returned\n * @param {MultiToken} [token] The token from linkify.tokenize\n * @returns {Opts[K] | any}\n */\n get(key, operator, token) {\n const isCallable = operator != null;\n let option = this.o[key];\n if (!option) {\n return option;\n }\n if (typeof option === 'object') {\n option = token.t in option ? option[token.t] : defaults[key];\n if (typeof option === 'function' && isCallable) {\n option = option(operator, token);\n }\n } else if (typeof option === 'function' && isCallable) {\n option = option(operator, token.t, token);\n }\n return option;\n },\n /**\n * @template {keyof Opts} L\n * @param {L} key Name of options object to use\n * @param {string} [operator]\n * @param {MultiToken} [token]\n * @returns {Opts[L] | any}\n */\n getObj(key, operator, token) {\n let obj = this.o[key];\n if (typeof obj === 'function' && operator != null) {\n obj = obj(operator, token.t, token);\n }\n return obj;\n },\n /**\n * Convert the given token to a rendered element that may be added to the\n * calling-interface's DOM\n * @param {MultiToken} token Token to render to an HTML element\n * @returns {any} Render result; e.g., HTML string, DOM element, React\n * Component, etc.\n */\n render(token) {\n const ir = token.render(this); // intermediate representation\n const renderFn = this.get('render', null, token) || this.defaultRender;\n return renderFn(ir, token.t, token);\n }\n};\nfunction noop(val) {\n return val;\n}\n\nvar options = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tOptions: Options,\n\tdefaults: defaults\n});\n\n/******************************************************************************\n\tMulti-Tokens\n\tTokens composed of arrays of TextTokens\n******************************************************************************/\n\n/**\n * @param {string} value\n * @param {Token[]} tokens\n */\nfunction MultiToken(value, tokens) {\n this.t = 'token';\n this.v = value;\n this.tk = tokens;\n}\n\n/**\n * Abstract class used for manufacturing tokens of text tokens. That is rather\n * than the value for a token being a small string of text, it's value an array\n * of text tokens.\n *\n * Used for grouping together URLs, emails, hashtags, and other potential\n * creations.\n * @class MultiToken\n * @property {string} t\n * @property {string} v\n * @property {Token[]} tk\n * @abstract\n */\nMultiToken.prototype = {\n isLink: false,\n /**\n * Return the string this token represents.\n * @return {string}\n */\n toString() {\n return this.v;\n },\n /**\n * What should the value for this token be in the `href` HTML attribute?\n * Returns the `.toString` value by default.\n * @param {string} [scheme]\n * @return {string}\n */\n toHref(scheme) {\n return this.toString();\n },\n /**\n * @param {Options} options Formatting options\n * @returns {string}\n */\n toFormattedString(options) {\n const val = this.toString();\n const truncate = options.get('truncate', val, this);\n const formatted = options.get('format', val, this);\n return truncate && formatted.length > truncate ? formatted.substring(0, truncate) + '…' : formatted;\n },\n /**\n *\n * @param {Options} options\n * @returns {string}\n */\n toFormattedHref(options) {\n return options.get('formatHref', this.toHref(options.get('defaultProtocol')), this);\n },\n /**\n * The start index of this token in the original input string\n * @returns {number}\n */\n startIndex() {\n return this.tk[0].s;\n },\n /**\n * The end index of this token in the original input string (up to this\n * index but not including it)\n * @returns {number}\n */\n endIndex() {\n return this.tk[this.tk.length - 1].e;\n },\n /**\n \tReturns an object of relevant values for this token, which includes keys\n \t* type - Kind of token ('url', 'email', etc.)\n \t* value - Original text\n \t* href - The value that should be added to the anchor tag's href\n \t\tattribute\n \t\t@method toObject\n \t@param {string} [protocol] `'http'` by default\n */\n toObject(protocol = defaults.defaultProtocol) {\n return {\n type: this.t,\n value: this.toString(),\n isLink: this.isLink,\n href: this.toHref(protocol),\n start: this.startIndex(),\n end: this.endIndex()\n };\n },\n /**\n *\n * @param {Options} options Formatting option\n */\n toFormattedObject(options) {\n return {\n type: this.t,\n value: this.toFormattedString(options),\n isLink: this.isLink,\n href: this.toFormattedHref(options),\n start: this.startIndex(),\n end: this.endIndex()\n };\n },\n /**\n * Whether this token should be rendered as a link according to the given options\n * @param {Options} options\n * @returns {boolean}\n */\n validate(options) {\n return options.get('validate', this.toString(), this);\n },\n /**\n * Return an object that represents how this link should be rendered.\n * @param {Options} options Formattinng options\n */\n render(options) {\n const token = this;\n const href = this.toHref(options.get('defaultProtocol'));\n const formattedHref = options.get('formatHref', href, this);\n const tagName = options.get('tagName', href, token);\n const content = this.toFormattedString(options);\n const attributes = {};\n const className = options.get('className', href, token);\n const target = options.get('target', href, token);\n const rel = options.get('rel', href, token);\n const attrs = options.getObj('attributes', href, token);\n const eventListeners = options.getObj('events', href, token);\n attributes.href = formattedHref;\n if (className) {\n attributes.class = className;\n }\n if (target) {\n attributes.target = target;\n }\n if (rel) {\n attributes.rel = rel;\n }\n if (attrs) {\n Object.assign(attributes, attrs);\n }\n return {\n tagName,\n attributes,\n content,\n eventListeners\n };\n }\n};\n\n/**\n * Create a new token that can be emitted by the parser state machine\n * @param {string} type readable type of the token\n * @param {object} props properties to assign or override, including isLink = true or false\n * @returns {new (value: string, tokens: Token[]) => MultiToken} new token class\n */\nfunction createTokenClass(type, props) {\n class Token extends MultiToken {\n constructor(value, tokens) {\n super(value, tokens);\n this.t = type;\n }\n }\n for (const p in props) {\n Token.prototype[p] = props[p];\n }\n Token.t = type;\n return Token;\n}\n\n/**\n\tRepresents a list of tokens making up a valid email address\n*/\nconst Email = createTokenClass('email', {\n isLink: true,\n toHref() {\n return 'mailto:' + this.toString();\n }\n});\n\n/**\n\tRepresents some plain text\n*/\nconst Text = createTokenClass('text');\n\n/**\n\tMulti-linebreak token - represents a line break\n\t@class Nl\n*/\nconst Nl = createTokenClass('nl');\n\n/**\n\tRepresents a list of text tokens making up a valid URL\n\t@class Url\n*/\nconst Url = createTokenClass('url', {\n isLink: true,\n /**\n \tLowercases relevant parts of the domain and adds the protocol if\n \trequired. Note that this will not escape unsafe HTML characters in the\n \tURL.\n \t\t@param {string} [scheme] default scheme (e.g., 'https')\n \t@return {string} the full href\n */\n toHref(scheme = defaults.defaultProtocol) {\n // Check if already has a prefix scheme\n return this.hasProtocol() ? this.v : `${scheme}://${this.v}`;\n },\n /**\n * Check whether this URL token has a protocol\n * @return {boolean}\n */\n hasProtocol() {\n const tokens = this.tk;\n return tokens.length >= 2 && tokens[0].t !== LOCALHOST && tokens[1].t === COLON;\n }\n});\n\nvar multi = /*#__PURE__*/Object.freeze({\n\t__proto__: null,\n\tBase: MultiToken,\n\tEmail: Email,\n\tMultiToken: MultiToken,\n\tNl: Nl,\n\tText: Text,\n\tUrl: Url,\n\tcreateTokenClass: createTokenClass\n});\n\n/**\n\tNot exactly parser, more like the second-stage scanner (although we can\n\ttheoretically hotswap the code here with a real parser in the future... but\n\tfor a little URL-finding utility abstract syntax trees may be a little\n\toverkill).\n\n\tURL format: http://en.wikipedia.org/wiki/URI_scheme\n\tEmail format: http://en.wikipedia.org/wiki/EmailAddress (links to RFC in\n\treference)\n\n\t@module linkify\n\t@submodule parser\n\t@main run\n*/\n\nconst makeState = arg => new State(arg);\n\n/**\n * Generate the parser multi token-based state machine\n * @param {{ groups: Collections<string> }} tokens\n */\nfunction init$1({\n groups\n}) {\n // Types of characters the URL can definitely end in\n const qsAccepting = groups.domain.concat([AMPERSAND, ASTERISK, AT, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, NUM, PERCENT, PIPE, PLUS, POUND, SLASH, SYM, TILDE, UNDERSCORE]);\n\n // Types of tokens that can follow a URL and be part of the query string\n // but cannot be the very last characters\n // Characters that cannot appear in the URL at all should be excluded\n const qsNonAccepting = [APOSTROPHE, COLON, COMMA, DOT, EXCLAMATION, PERCENT, QUERY, QUOTE, SEMI, OPENANGLEBRACKET, CLOSEANGLEBRACKET, OPENBRACE, CLOSEBRACE, CLOSEBRACKET, OPENBRACKET, OPENPAREN, CLOSEPAREN, FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN, LEFTCORNERBRACKET, RIGHTCORNERBRACKET, LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET, FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN];\n\n // For addresses without the mailto prefix\n // Tokens allowed in the localpart of the email\n const localpartAccepting = [AMPERSAND, APOSTROPHE, ASTERISK, BACKSLASH, BACKTICK, CARET, DOLLAR, EQUALS, HYPHEN, OPENBRACE, CLOSEBRACE, PERCENT, PIPE, PLUS, POUND, QUERY, SLASH, SYM, TILDE, UNDERSCORE];\n\n // The universal starting state.\n /**\n * @type State<Token>\n */\n const Start = makeState();\n const Localpart = tt(Start, TILDE); // Local part of the email address\n ta(Localpart, localpartAccepting, Localpart);\n ta(Localpart, groups.domain, Localpart);\n const Domain = makeState(),\n Scheme = makeState(),\n SlashScheme = makeState();\n ta(Start, groups.domain, Domain); // parsed string ends with a potential domain name (A)\n ta(Start, groups.scheme, Scheme); // e.g., 'mailto'\n ta(Start, groups.slashscheme, SlashScheme); // e.g., 'http'\n\n ta(Domain, localpartAccepting, Localpart);\n ta(Domain, groups.domain, Domain);\n const LocalpartAt = tt(Domain, AT); // Local part of the email address plus @\n\n tt(Localpart, AT, LocalpartAt); // close to an email address now\n\n // Local part of an email address can be e.g. 'http' or 'mailto'\n tt(Scheme, AT, LocalpartAt);\n tt(SlashScheme, AT, LocalpartAt);\n const LocalpartDot = tt(Localpart, DOT); // Local part of the email address plus '.' (localpart cannot end in .)\n ta(LocalpartDot, localpartAccepting, Localpart);\n ta(LocalpartDot, groups.domain, Localpart);\n const EmailDomain = makeState();\n ta(LocalpartAt, groups.domain, EmailDomain); // parsed string starts with local email info + @ with a potential domain name\n ta(EmailDomain, groups.domain, EmailDomain);\n const EmailDomainDot = tt(EmailDomain, DOT); // domain followed by DOT\n ta(EmailDomainDot, groups.domain, EmailDomain);\n const Email$1 = makeState(Email); // Possible email address (could have more tlds)\n ta(EmailDomainDot, groups.tld, Email$1);\n ta(EmailDomainDot, groups.utld, Email$1);\n tt(LocalpartAt, LOCALHOST, Email$1);\n\n // Hyphen can jump back to a domain name\n const EmailDomainHyphen = tt(EmailDomain, HYPHEN); // parsed string starts with local email info + @ with a potential domain name\n tt(EmailDomainHyphen, HYPHEN, EmailDomainHyphen);\n ta(EmailDomainHyphen, groups.domain, EmailDomain);\n ta(Email$1, groups.domain, EmailDomain);\n tt(Email$1, DOT, EmailDomainDot);\n tt(Email$1, HYPHEN, EmailDomainHyphen);\n\n // Account for dots and hyphens. Hyphens are usually parts of domain names\n // (but not TLDs)\n const DomainHyphen = tt(Domain, HYPHEN); // domain followed by hyphen\n const DomainDot = tt(Domain, DOT); // domain followed by DOT\n tt(DomainHyphen, HYPHEN, DomainHyphen);\n ta(DomainHyphen, groups.domain, Domain);\n ta(DomainDot, localpartAccepting, Localpart);\n ta(DomainDot, groups.domain, Domain);\n const DomainDotTld = makeState(Url); // Simplest possible URL with no query string\n ta(DomainDot, groups.tld, DomainDotTld);\n ta(DomainDot, groups.utld, DomainDotTld);\n ta(DomainDotTld, groups.domain, Domain);\n ta(DomainDotTld, localpartAccepting, Localpart);\n tt(DomainDotTld, DOT, DomainDot);\n tt(DomainDotTld, HYPHEN, DomainHyphen);\n tt(DomainDotTld, AT, LocalpartAt);\n const DomainDotTldColon = tt(DomainDotTld, COLON); // URL followed by colon (potential port number here)\n const DomainDotTldColonPort = makeState(Url); // TLD followed by a port number\n ta(DomainDotTldColon, groups.numeric, DomainDotTldColonPort);\n\n // Long URL with optional port and maybe query string\n const Url$1 = makeState(Url);\n\n // URL with extra symbols at the end, followed by an opening bracket\n const UrlNonaccept = makeState(); // URL followed by some symbols (will not be part of the final URL)\n\n // Query strings\n ta(Url$1, qsAccepting, Url$1);\n ta(Url$1, qsNonAccepting, UrlNonaccept);\n ta(UrlNonaccept, qsAccepting, Url$1);\n ta(UrlNonaccept, qsNonAccepting, UrlNonaccept);\n\n // Become real URLs after `SLASH` or `COLON NUM SLASH`\n // Here works with or without scheme:// prefix\n tt(DomainDotTld, SLASH, Url$1);\n tt(DomainDotTldColonPort, SLASH, Url$1);\n\n // Note that domains that begin with schemes are treated slighly differently\n const SchemeColon = tt(Scheme, COLON); // e.g., 'mailto:'\n const SlashSchemeColon = tt(SlashScheme, COLON); // e.g., 'http:'\n const SlashSchemeColonSlash = tt(SlashSchemeColon, SLASH); // e.g., 'http:/'\n\n const UriPrefix = tt(SlashSchemeColonSlash, SLASH); // e.g., 'http://'\n\n // Scheme states can transition to domain states\n ta(Scheme, groups.domain, Domain);\n tt(Scheme, DOT, DomainDot);\n tt(Scheme, HYPHEN, DomainHyphen);\n ta(SlashScheme, groups.domain, Domain);\n tt(SlashScheme, DOT, DomainDot);\n tt(SlashScheme, HYPHEN, DomainHyphen);\n\n // Force URL with scheme prefix followed by anything sane\n ta(SchemeColon, groups.domain, Url$1);\n tt(SchemeColon, SLASH, Url$1);\n tt(SchemeColon, QUERY, Url$1);\n ta(UriPrefix, groups.domain, Url$1);\n ta(UriPrefix, qsAccepting, Url$1);\n tt(UriPrefix, SLASH, Url$1);\n const bracketPairs = [[OPENBRACE, CLOSEBRACE],\n // {}\n [OPENBRACKET, CLOSEBRACKET],\n // []\n [OPENPAREN, CLOSEPAREN],\n // ()\n [OPENANGLEBRACKET, CLOSEANGLEBRACKET],\n // <>\n [FULLWIDTHLEFTPAREN, FULLWIDTHRIGHTPAREN],\n // ()\n [LEFTCORNERBRACKET, RIGHTCORNERBRACKET],\n // 「」\n [LEFTWHITECORNERBRACKET, RIGHTWHITECORNERBRACKET],\n // 『』\n [FULLWIDTHLESSTHAN, FULLWIDTHGREATERTHAN] // <>\n ];\n for (let i = 0; i < bracketPairs.length; i++) {\n const [OPEN, CLOSE] = bracketPairs[i];\n const UrlOpen = tt(Url$1, OPEN); // URL followed by open bracket\n\n // Continue not accepting for open brackets\n tt(UrlNonaccept, OPEN, UrlOpen);\n\n // URL that begins with an opening bracket, followed by a symbols.\n // Note that the final state can still be `UrlOpen` (if the URL has a\n // single opening bracket for some reason).\n const UrlOpenQ = makeState(Url);\n ta(UrlOpen, qsAccepting, UrlOpenQ);\n const UrlOpenSyms = makeState(); // UrlOpen followed by some symbols it cannot end it\n ta(UrlOpen, qsNonAccepting, UrlOpenSyms);\n\n // Closing bracket component. This character WILL be included in the URL.\n // Must come after qsNonAccepting (which includes all close-bracket tokens)\n // so that CLOSE -> Url wins over CLOSE -> UrlOpenSyms.\n tt(UrlOpen, CLOSE, Url$1);\n\n // URL that begins with an opening bracket, followed by some symbols\n ta(UrlOpenQ, qsAccepting, UrlOpenQ);\n ta(UrlOpenQ, qsNonAccepting, UrlOpenSyms);\n ta(UrlOpenSyms, qsAccepting, UrlOpenQ);\n ta(UrlOpenSyms, qsNonAccepting, UrlOpenSyms);\n\n // Close brace/bracket to become regular URL\n tt(UrlOpenQ, CLOSE, Url$1);\n tt(UrlOpenSyms, CLOSE, Url$1);\n }\n tt(Start, LOCALHOST, DomainDotTld); // localhost is a valid URL state\n tt(Start, NL, Nl); // single new line\n\n return {\n start: Start,\n tokens: tk\n };\n}\n\n/**\n * Run the parser state machine on a list of scanned string-based tokens to\n * create a list of multi tokens, each of which represents a URL, email address,\n * plain text, etc.\n *\n * @param {State<MultiToken>} start parser start state\n * @param {string} input the original input used to generate the given tokens\n * @param {Token[]} tokens list of scanned tokens\n * @returns {MultiToken[]}\n */\nfunction run(start, input, tokens) {\n let len = tokens.length;\n let cursor = 0;\n let multis = [];\n let textTokens = [];\n while (cursor < len) {\n let state = start;\n let secondState = null;\n let nextState = null;\n let multiLength = 0;\n let latestAccepting = null;\n let sinceAccepts = -1;\n while (cursor < len && !(secondState = state.go(tokens[cursor].t))) {\n // Starting tokens with nowhere to jump to.\n // Consider these to be just plain text\n textTokens.push(tokens[cursor++]);\n }\n while (cursor < len && (nextState = secondState || state.go(tokens[cursor].t))) {\n // Get the next state\n secondState = null;\n state = nextState;\n\n // Keep track of the latest accepting state\n if (state.accepts()) {\n sinceAccepts = 0;\n latestAccepting = state;\n } else if (sinceAccepts >= 0) {\n sinceAccepts++;\n }\n cursor++;\n multiLength++;\n }\n if (sinceAccepts < 0) {\n // No accepting state was found, part of a regular text token add\n // the first text token to the text tokens array and try again from\n // the next\n cursor -= multiLength;\n if (cursor < len) {\n textTokens.push(tokens[cursor]);\n cursor++;\n }\n } else {\n // Accepting state!\n // First close off the textTokens (if available)\n if (textTokens.length > 0) {\n multis.push(initMultiToken(Text, input, textTokens));\n textTokens = [];\n }\n\n // Roll back to the latest accepting state\n cursor -= sinceAccepts;\n multiLength -= sinceAccepts;\n\n // Create a new multitoken\n const Multi = latestAccepting.t;\n const subtokens = tokens.slice(cursor - multiLength, cursor);\n multis.push(initMultiToken(Multi, input, subtokens));\n }\n }\n\n // Finally close off the textTokens (if available)\n if (textTokens.length > 0) {\n multis.push(initMultiToken(Text, input, textTokens));\n }\n return multis;\n}\n\n/**\n * Utility function for instantiating a new multitoken with all the relevant\n * fields during parsing.\n * @param {new (value: string, tokens: Token[]) => MultiToken} Multi class to instantiate\n * @param {string} input original input string\n * @param {Token[]} tokens consecutive tokens scanned from input string\n * @returns {MultiToken}\n */\nfunction initMultiToken(Multi, input, tokens) {\n const startIdx = tokens[0].s;\n const endIdx = tokens[tokens.length - 1].e;\n const value = input.slice(startIdx, endIdx);\n return new Multi(value, tokens);\n}\n\nconst warn = typeof console !== 'undefined' && console && console.warn || (() => {});\nconst warnAdvice = 'until manual call of linkify.init(). Register all schemes and plugins before invoking linkify the first time.';\n\n// Side-effect initialization state\nconst INIT = {\n scanner: null,\n parser: null,\n tokenQueue: [],\n pluginQueue: [],\n customSchemes: [],\n initialized: false\n};\n\n/**\n * @typedef {{\n * \tstart: State<string>,\n * \ttokens: { groups: Collections<string> } & typeof tk\n * }} ScannerInit\n */\n\n/**\n * @typedef {{\n * \tstart: State<MultiToken>,\n * \ttokens: typeof multi\n * }} ParserInit\n */\n\n/**\n * @typedef {(arg: { scanner: ScannerInit }) => void} TokenPlugin\n */\n\n/**\n * @typedef {(arg: { scanner: ScannerInit, parser: ParserInit }) => void} Plugin\n */\n\n/**\n * De-register all plugins and reset the internal state-machine. Used for\n * testing; not required in practice.\n * @private\n */\nfunction reset() {\n State.groups = {};\n INIT.scanner = null;\n INIT.parser = null;\n INIT.tokenQueue = [];\n INIT.pluginQueue = [];\n INIT.customSchemes = [];\n INIT.initialized = false;\n return INIT;\n}\n\n/**\n * Register a token plugin to allow the scanner to recognize additional token\n * types before the parser state machine is constructed from the results.\n * @param {string} name of plugin to register\n * @param {TokenPlugin} plugin function that accepts the scanner state machine\n * and available scanner tokens and collections and extends the state machine to\n * recognize additional tokens or groups.\n */\nfunction registerTokenPlugin(name, plugin) {\n if (typeof plugin !== 'function') {\n throw new Error(`linkifyjs: Invalid token plugin ${plugin} (expects function)`);\n }\n for (let i = 0; i < INIT.tokenQueue.length; i++) {\n if (name === INIT.tokenQueue[i][0]) {\n warn(`linkifyjs: token plugin \"${name}\" already registered - will be overwritten`);\n INIT.tokenQueue[i] = [name, plugin];\n return;\n }\n }\n INIT.tokenQueue.push([name, plugin]);\n if (INIT.initialized) {\n warn(`linkifyjs: already initialized - will not register token plugin \"${name}\" ${warnAdvice}`);\n }\n}\n\n/**\n * Register a linkify plugin\n * @param {string} name of plugin to register\n * @param {Plugin} plugin function that accepts the parser state machine and\n * extends the parser to recognize additional link types\n */\nfunction registerPlugin(name, plugin) {\n if (typeof plugin !== 'function') {\n throw new Error(`linkifyjs: Invalid plugin ${plugin} (expects function)`);\n }\n for (let i = 0; i < INIT.pluginQueue.length; i++) {\n if (name === INIT.pluginQueue[i][0]) {\n warn(`linkifyjs: plugin \"${name}\" already registered - will be overwritten`);\n INIT.pluginQueue[i] = [name, plugin];\n return;\n }\n }\n INIT.pluginQueue.push([name, plugin]);\n if (INIT.initialized) {\n warn(`linkifyjs: already initialized - will not register plugin \"${name}\" ${warnAdvice}`);\n }\n}\n\n/**\n * Detect URLs with the following additional protocol. Anything with format\n * \"protocol://...\" will be considered a link. If `optionalSlashSlash` is set to\n * `true`, anything with format \"protocol:...\" will be considered a link.\n * @param {string} scheme\n * @param {boolean} [optionalSlashSlash]\n */\nfunction registerCustomProtocol(scheme, optionalSlashSlash = false) {\n if (INIT.initialized) {\n warn(`linkifyjs: already initialized - will not register custom scheme \"${scheme}\" ${warnAdvice}`);\n }\n if (!/^[0-9a-z]+(-[0-9a-z]+)*$/.test(scheme)) {\n throw new Error(`linkifyjs: incorrect scheme format.\n1. Must only contain digits, lowercase ASCII letters or \"-\"\n2. Cannot start or end with \"-\"\n3. \"-\" cannot repeat`);\n }\n INIT.customSchemes.push([scheme, optionalSlashSlash]);\n}\n\n/**\n * Initialize the linkify state machine. Called automatically the first time\n * linkify is called on a string, but may be called manually as well.\n */\nfunction init() {\n // Initialize scanner state machine and plugins\n INIT.scanner = init$2(INIT.customSchemes);\n for (let i = 0; i < INIT.tokenQueue.length; i++) {\n INIT.tokenQueue[i][1]({\n scanner: INIT.scanner\n });\n }\n\n // Initialize parser state machine and plugins\n INIT.parser = init$1(INIT.scanner.tokens);\n for (let i = 0; i < INIT.pluginQueue.length; i++) {\n INIT.pluginQueue[i][1]({\n scanner: INIT.scanner,\n parser: INIT.parser\n });\n }\n INIT.initialized = true;\n return INIT;\n}\n\n/**\n * Parse a string into tokens that represent linkable and non-linkable sub-components\n * @param {string} str\n * @return {MultiToken[]} tokens\n */\nfunction tokenize(str) {\n if (!INIT.initialized) {\n init();\n }\n return run(INIT.parser.start, str, run$1(INIT.scanner.start, str));\n}\ntokenize.scan = run$1; // for testing\n\n/**\n * Find a list of linkable items in the given string.\n * @param {string} str string to find links in\n * @param {string | Opts} [type] either formatting options or specific type of\n * links to find, e.g., 'url' or 'email'\n * @param {Opts} [opts] formatting options for final output. Cannot be specified\n * if opts already provided in `type` argument\n */\nfunction find(str, type = null, opts = null) {\n if (type && typeof type === 'object') {\n if (opts) {\n throw Error(`linkifyjs: Invalid link type ${type}; must be a string`);\n }\n opts = type;\n type = null;\n }\n const options = new Options(opts);\n const tokens = tokenize(str);\n const filtered = [];\n for (let i = 0; i < tokens.length; i++) {\n const token = tokens[i];\n if (token.isLink && (!type || token.t === type) && options.check(token)) {\n filtered.push(token.toFormattedObject(options));\n }\n }\n return filtered;\n}\n\n/**\n * Is the given string valid linkable text of some sort. Note that this does not\n * trim the text for you.\n *\n * Optionally pass in a second `type` param, which is the type of link to test\n * for.\n *\n * For example,\n *\n * linkify.test(str, 'email');\n *\n * Returns `true` if str is a valid email.\n * @param {string} str string to test for links\n * @param {string} [type] optional specific link type to look for\n * @returns boolean true/false\n */\nfunction test(str, type = null) {\n const tokens = tokenize(str);\n return tokens.length === 1 && tokens[0].isLink && (!type || tokens[0].t === type);\n}\n\nexport { MultiToken, Options, State, createTokenClass, find, init, multi, options, regexp, registerCustomProtocol, registerPlugin, registerTokenPlugin, reset, stringToArray, test, multi as text, tokenize };\n","/**\n * @license React\n * use-sync-external-store-shim.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar React = require(\"react\");\nfunction is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n}\nvar objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useState = React.useState,\n useEffect = React.useEffect,\n useLayoutEffect = React.useLayoutEffect,\n useDebugValue = React.useDebugValue;\nfunction useSyncExternalStore$2(subscribe, getSnapshot) {\n var value = getSnapshot(),\n _useState = useState({ inst: { value: value, getSnapshot: getSnapshot } }),\n inst = _useState[0].inst,\n forceUpdate = _useState[1];\n useLayoutEffect(\n function () {\n inst.value = value;\n inst.getSnapshot = getSnapshot;\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n },\n [subscribe, value, getSnapshot]\n );\n useEffect(\n function () {\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n return subscribe(function () {\n checkIfSnapshotChanged(inst) && forceUpdate({ inst: inst });\n });\n },\n [subscribe]\n );\n useDebugValue(value);\n return value;\n}\nfunction checkIfSnapshotChanged(inst) {\n var latestGetSnapshot = inst.getSnapshot;\n inst = inst.value;\n try {\n var nextValue = latestGetSnapshot();\n return !objectIs(inst, nextValue);\n } catch (error) {\n return !0;\n }\n}\nfunction useSyncExternalStore$1(subscribe, getSnapshot) {\n return getSnapshot();\n}\nvar shim =\n \"undefined\" === typeof window ||\n \"undefined\" === typeof window.document ||\n \"undefined\" === typeof window.document.createElement\n ? useSyncExternalStore$1\n : useSyncExternalStore$2;\nexports.useSyncExternalStore =\n void 0 !== React.useSyncExternalStore ? React.useSyncExternalStore : shim;\n","/**\n * @license React\n * use-sync-external-store-shim/with-selector.production.js\n *\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\n\n\"use strict\";\nvar React = require(\"react\"),\n shim = require(\"use-sync-external-store/shim\");\nfunction is(x, y) {\n return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y);\n}\nvar objectIs = \"function\" === typeof Object.is ? Object.is : is,\n useSyncExternalStore = shim.useSyncExternalStore,\n useRef = React.useRef,\n useEffect = React.useEffect,\n useMemo = React.useMemo,\n useDebugValue = React.useDebugValue;\nexports.useSyncExternalStoreWithSelector = function (\n subscribe,\n getSnapshot,\n getServerSnapshot,\n selector,\n isEqual\n) {\n var instRef = useRef(null);\n if (null === instRef.current) {\n var inst = { hasValue: !1, value: null };\n instRef.current = inst;\n } else inst = instRef.current;\n instRef = useMemo(\n function () {\n function memoizedSelector(nextSnapshot) {\n if (!hasMemo) {\n hasMemo = !0;\n memoizedSnapshot = nextSnapshot;\n nextSnapshot = selector(nextSnapshot);\n if (void 0 !== isEqual && inst.hasValue) {\n var currentSelection = inst.value;\n if (isEqual(currentSelection, nextSnapshot))\n return (memoizedSelection = currentSelection);\n }\n return (memoizedSelection = nextSnapshot);\n }\n currentSelection = memoizedSelection;\n if (objectIs(memoizedSnapshot, nextSnapshot)) return currentSelection;\n var nextSelection = selector(nextSnapshot);\n if (void 0 !== isEqual && isEqual(currentSelection, nextSelection))\n return (memoizedSnapshot = nextSnapshot), currentSelection;\n memoizedSnapshot = nextSnapshot;\n return (memoizedSelection = nextSelection);\n }\n var hasMemo = !1,\n memoizedSnapshot,\n memoizedSelection,\n maybeGetServerSnapshot =\n void 0 === getServerSnapshot ? null : getServerSnapshot;\n return [\n function () {\n return memoizedSelector(getSnapshot());\n },\n null === maybeGetServerSnapshot\n ? void 0\n : function () {\n return memoizedSelector(maybeGetServerSnapshot());\n }\n ];\n },\n [getSnapshot, getServerSnapshot, selector, isEqual]\n );\n var value = useSyncExternalStore(subscribe, instRef[0], instRef[1]);\n useEffect(\n function () {\n inst.hasValue = !0;\n inst.value = value;\n },\n [value]\n );\n useDebugValue(value);\n return value;\n};\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim.production.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim.development.js');\n}\n","'use strict';\n\nif (process.env.NODE_ENV === 'production') {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.production.js');\n} else {\n module.exports = require('../cjs/use-sync-external-store-shim/with-selector.development.js');\n}\n","Object.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\n//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\nlet _tiptap_pm_transform = require(\"@tiptap/pm/transform\");\nlet _tiptap_pm_commands = require(\"@tiptap/pm/commands\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\nlet _tiptap_pm_model = require(\"@tiptap/pm/model\");\nlet _tiptap_pm_schema_list = require(\"@tiptap/pm/schema-list\");\nlet _tiptap_pm_view = require(\"@tiptap/pm/view\");\nlet _tiptap_pm_keymap = require(\"@tiptap/pm/keymap\");\n//#region src/helpers/createChainableState.ts\n/**\n* Takes a Transaction & Editor State and turns it into a chainable state object\n* @param config The transaction and state to create the chainable state from\n* @returns A chainable Editor state object\n*/\nfunction createChainableState(config) {\n\tconst { state, transaction } = config;\n\tlet { selection } = transaction;\n\tlet { doc } = transaction;\n\tlet { storedMarks } = transaction;\n\treturn {\n\t\t...state,\n\t\tapply: state.apply.bind(state),\n\t\tapplyTransaction: state.applyTransaction.bind(state),\n\t\tplugins: state.plugins,\n\t\tschema: state.schema,\n\t\treconfigure: state.reconfigure.bind(state),\n\t\ttoJSON: state.toJSON.bind(state),\n\t\tget storedMarks() {\n\t\t\treturn storedMarks;\n\t\t},\n\t\tget selection() {\n\t\t\treturn selection;\n\t\t},\n\t\tget doc() {\n\t\t\treturn doc;\n\t\t},\n\t\tget tr() {\n\t\t\tselection = transaction.selection;\n\t\t\tdoc = transaction.doc;\n\t\t\tstoredMarks = transaction.storedMarks;\n\t\t\treturn transaction;\n\t\t}\n\t};\n}\n//#endregion\n//#region src/CommandManager.ts\nvar CommandManager = class CommandManager {\n\tconstructor(props) {\n\t\tthis.editor = props.editor;\n\t\tthis.rawCommands = this.editor.extensionManager.commands;\n\t\tthis.customState = props.state;\n\t}\n\tget hasCustomState() {\n\t\treturn !!this.customState;\n\t}\n\tget state() {\n\t\treturn this.customState || this.editor.state;\n\t}\n\tget commands() {\n\t\tconst { rawCommands, editor, state } = this;\n\t\tconst { view } = editor;\n\t\tconst { tr } = state;\n\t\tconst props = this.buildProps(tr);\n\t\treturn Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {\n\t\t\tconst method = (...args) => {\n\t\t\t\tconst callback = command(...args)(props);\n\t\t\t\tif (!tr.getMeta(\"preventDispatch\") && !this.hasCustomState) view.dispatch(tr);\n\t\t\t\treturn callback;\n\t\t\t};\n\t\t\treturn [name, method];\n\t\t}));\n\t}\n\tget chain() {\n\t\treturn () => this.createChain();\n\t}\n\tget can() {\n\t\treturn () => this.createCan();\n\t}\n\tcreateChain(startTr, shouldDispatch = true) {\n\t\tconst { rawCommands, editor, state } = this;\n\t\tconst { view } = editor;\n\t\tconst callbacks = [];\n\t\tconst hasStartTransaction = !!startTr;\n\t\tconst tr = startTr || state.tr;\n\t\tconst run = () => {\n\t\t\tif (!hasStartTransaction && shouldDispatch && !tr.getMeta(\"preventDispatch\") && !this.hasCustomState) view.dispatch(tr);\n\t\t\treturn callbacks.every((callback) => callback === true);\n\t\t};\n\t\tconst chain = {\n\t\t\t...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {\n\t\t\t\tconst chainedCommand = (...args) => {\n\t\t\t\t\tconst props = this.buildProps(tr, shouldDispatch);\n\t\t\t\t\tconst callback = command(...args)(props);\n\t\t\t\t\tcallbacks.push(callback);\n\t\t\t\t\treturn chain;\n\t\t\t\t};\n\t\t\t\treturn [name, chainedCommand];\n\t\t\t})),\n\t\t\trun\n\t\t};\n\t\treturn chain;\n\t}\n\t/**\n\t* Creates a chain that safely returns `false` when run.\n\t* @returns A non-dispatching command chain.\n\t* @example\n\t* const chain = CommandManager.createFakeChain()\n\t* chain.focus().run() // false\n\t*/\n\tstatic createFakeChain() {\n\t\tconst chain = new Proxy({}, { get: (_target, property) => {\n\t\t\tif (property === \"then\") return;\n\t\t\tif (property === \"run\") return () => false;\n\t\t\treturn () => chain;\n\t\t} });\n\t\treturn chain;\n\t}\n\tcreateCan(startTr) {\n\t\tconst { rawCommands, state } = this;\n\t\tconst dispatch = false;\n\t\tconst tr = startTr || state.tr;\n\t\tconst props = this.buildProps(tr, dispatch);\n\t\treturn {\n\t\t\t...Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {\n\t\t\t\treturn [name, (...args) => command(...args)({\n\t\t\t\t\t...props,\n\t\t\t\t\tdispatch: void 0\n\t\t\t\t})];\n\t\t\t})),\n\t\t\tchain: () => this.createChain(tr, dispatch)\n\t\t};\n\t}\n\t/**\n\t* Creates capability checks that safely return `false`.\n\t* @returns A non-dispatching capability checker.\n\t* @example\n\t* const can = CommandManager.createFallbackCan()\n\t* can.focus() // false\n\t*/\n\tstatic createFallbackCan() {\n\t\tconst chain = CommandManager.createFakeChain();\n\t\treturn new Proxy({ chain: () => chain }, { get: (target, property) => {\n\t\t\tif (property === \"then\") return;\n\t\t\tif (property === \"chain\") return target.chain;\n\t\t\treturn () => false;\n\t\t} });\n\t}\n\tbuildProps(tr, shouldDispatch = true) {\n\t\tconst { rawCommands, editor, state } = this;\n\t\tconst { view } = editor;\n\t\tconst props = {\n\t\t\ttr,\n\t\t\teditor,\n\t\t\tview,\n\t\t\tstate: createChainableState({\n\t\t\t\tstate,\n\t\t\t\ttransaction: tr\n\t\t\t}),\n\t\t\tdispatch: shouldDispatch ? () => void 0 : void 0,\n\t\t\tchain: () => this.createChain(tr, shouldDispatch),\n\t\t\tcan: () => this.createCan(tr),\n\t\t\tget commands() {\n\t\t\t\treturn Object.fromEntries(Object.entries(rawCommands).map(([name, command]) => {\n\t\t\t\t\treturn [name, (...args) => command(...args)(props)];\n\t\t\t\t}));\n\t\t\t}\n\t\t};\n\t\treturn props;\n\t}\n};\n//#endregion\n//#region src/commands/blur.ts\nconst blur = () => ({ editor, view }) => {\n\trequestAnimationFrame(() => {\n\t\tif (!editor.isDestroyed) {\n\t\t\tvar _window;\n\t\t\tview.dom.blur();\n\t\t\t(_window = window) === null || _window === void 0 || (_window = _window.getSelection()) === null || _window === void 0 || _window.removeAllRanges();\n\t\t}\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/commands/clearContent.ts\nconst clearContent = (emitUpdate = true) => ({ commands }) => {\n\treturn commands.setContent(\"\", { emitUpdate });\n};\n//#endregion\n//#region src/commands/clearNodes.ts\nconst clearNodes = () => ({ state, tr, dispatch }) => {\n\tconst { selection } = tr;\n\tconst { ranges } = selection;\n\tif (!dispatch) return true;\n\tranges.forEach(({ $from, $to }) => {\n\t\tstate.doc.nodesBetween($from.pos, $to.pos, (node, pos) => {\n\t\t\tif (node.type.isText) return;\n\t\t\tconst { doc, mapping } = tr;\n\t\t\tconst $mappedFrom = doc.resolve(mapping.map(pos));\n\t\t\tconst $mappedTo = doc.resolve(mapping.map(pos + node.nodeSize));\n\t\t\tconst nodeRange = $mappedFrom.blockRange($mappedTo);\n\t\t\tif (!nodeRange) return;\n\t\t\tconst targetLiftDepth = (0, _tiptap_pm_transform.liftTarget)(nodeRange);\n\t\t\tif (node.type.isTextblock) {\n\t\t\t\tconst { defaultType } = $mappedFrom.parent.contentMatchAt($mappedFrom.index());\n\t\t\t\ttr.setNodeMarkup(nodeRange.start, defaultType);\n\t\t\t}\n\t\t\tif (targetLiftDepth || targetLiftDepth === 0) tr.lift(nodeRange, targetLiftDepth);\n\t\t});\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/commands/command.ts\nconst command = (fn) => (props) => {\n\treturn fn(props);\n};\n//#endregion\n//#region src/commands/createParagraphNear.ts\nconst createParagraphNear = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.createParagraphNear)(state, dispatch);\n};\n//#endregion\n//#region src/commands/cut.ts\nconst cut = (originRange, targetPos) => ({ editor, tr }) => {\n\tconst { state } = editor;\n\tconst contentSlice = state.doc.slice(originRange.from, originRange.to);\n\ttr.deleteRange(originRange.from, originRange.to);\n\tconst newPos = tr.mapping.map(targetPos);\n\ttr.insert(newPos, contentSlice.content);\n\ttr.setSelection(new _tiptap_pm_state.TextSelection(tr.doc.resolve(Math.max(newPos - 1, 0))));\n\treturn true;\n};\n//#endregion\n//#region src/commands/deleteCurrentNode.ts\nconst deleteCurrentNode = () => ({ tr, dispatch }) => {\n\tconst { selection } = tr;\n\tconst currentNode = selection.$anchor.node();\n\tif (currentNode.content.size > 0) return false;\n\tconst $pos = tr.selection.$anchor;\n\tfor (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === currentNode.type) {\n\t\tif (dispatch) {\n\t\t\tconst from = $pos.before(depth);\n\t\t\tconst to = $pos.after(depth);\n\t\t\ttr.delete(from, to).scrollIntoView();\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n};\n//#endregion\n//#region src/helpers/getNodeType.ts\nfunction getNodeType(nameOrType, schema) {\n\tif (typeof nameOrType === \"string\") {\n\t\tif (!schema.nodes[nameOrType]) throw Error(`There is no node type named '${nameOrType}'. Maybe you forgot to add the extension?`);\n\t\treturn schema.nodes[nameOrType];\n\t}\n\treturn nameOrType;\n}\n//#endregion\n//#region src/commands/deleteNode.ts\nconst deleteNode = (typeOrName) => ({ tr, state, dispatch }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tconst $pos = tr.selection.$anchor;\n\tfor (let depth = $pos.depth; depth > 0; depth -= 1) if ($pos.node(depth).type === type) {\n\t\tif (dispatch) {\n\t\t\tconst from = $pos.before(depth);\n\t\t\tconst to = $pos.after(depth);\n\t\t\ttr.delete(from, to).scrollIntoView();\n\t\t}\n\t\treturn true;\n\t}\n\treturn false;\n};\n//#endregion\n//#region src/commands/deleteRange.ts\nconst deleteRange = (range) => ({ tr, dispatch }) => {\n\tconst { from, to } = range;\n\tif (dispatch) tr.delete(from, to);\n\treturn true;\n};\n//#endregion\n//#region src/commands/deleteSelection.ts\n/**\n* Check if a node has text content based on its content specification.\n* Returns true if the node's content spec matches text* or text+ patterns.\n*/\nconst hasTextContent = (nodeSpec) => {\n\tif (!nodeSpec.content) return false;\n\treturn /^text(\\*|\\+)/.test(nodeSpec.content);\n};\n/**\n* Expand selection position for a specific side (left or right) to handle inline text nodes.\n* This function checks if the position is within an inline node with text content and\n* expands it to include the entire node boundaries for proper deletion.\n* @param $pos - The resolved position to expand\n* @param schema - The ProseMirror schema\n* @param side - Which side to expand ('left' or 'right')\n* @returns The expanded position for deletion\n*/\nconst expandSelectionForSide = ($pos, schema, side) => {\n\tif (!$pos.parent.isInline) return $pos.pos;\n\tif (side === \"left\" && $pos.pos > $pos.start() || side === \"right\" && $pos.pos < $pos.end()) return $pos.pos;\n\tconst parentContent = schema.nodes[$pos.parent.type.name].spec;\n\tif (!hasTextContent(parentContent)) return $pos.pos;\n\treturn side === \"left\" ? $pos.start() - 1 : $pos.end() + 1;\n};\n/**\n* Expand selection range to properly handle deletion of inline text nodes.\n* Inline text nodes don't collapse correctly when text inside is deleted,\n* so we need to expand the selection to include the entire node.\n* See: https://code.haverbeke.berlin/prosemirror/prosemirror/issues/1365\n*/\nconst expandSelectionForInlineText = ($from, $to, schema) => {\n\treturn {\n\t\tfrom: expandSelectionForSide($from, schema, \"left\"),\n\t\tto: expandSelectionForSide($to, schema, \"right\")\n\t};\n};\nconst deleteSelection = () => ({ state, dispatch }) => {\n\tif (state.selection.empty) return false;\n\tif (dispatch) {\n\t\tconst tr = state.tr;\n\t\tconst { ranges } = state.selection;\n\t\tconst mapFrom = tr.steps.length;\n\t\tranges.forEach((range) => {\n\t\t\tconst mapping = tr.mapping.slice(mapFrom);\n\t\t\tconst $from = tr.doc.resolve(mapping.map(range.$from.pos));\n\t\t\tconst $to = tr.doc.resolve(mapping.map(range.$to.pos));\n\t\t\tconst { from, to } = expandSelectionForInlineText($from, $to, state.schema);\n\t\t\ttr.deleteRange(from, to);\n\t\t});\n\t\tif (!tr.selection.empty) tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(tr.selection.from)));\n\t\ttr.scrollIntoView();\n\t\tdispatch(tr);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/enter.ts\nconst enter = () => ({ commands }) => {\n\treturn commands.keyboardShortcut(\"Enter\");\n};\n//#endregion\n//#region src/commands/exitCode.ts\nconst exitCode = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.exitCode)(state, dispatch);\n};\n//#endregion\n//#region src/utilities/isRegExp.ts\nfunction isRegExp(value) {\n\treturn Object.prototype.toString.call(value) === \"[object RegExp]\";\n}\n//#endregion\n//#region src/utilities/objectIncludes.ts\n/**\n* Check if object1 includes object2\n* @param object1 Object\n* @param object2 Object\n*/\nfunction objectIncludes(object1, object2, options = { strict: true }) {\n\tconst keys = Object.keys(object2);\n\tif (!keys.length) return true;\n\treturn keys.every((key) => {\n\t\tif (options.strict) return object2[key] === object1[key];\n\t\tif (isRegExp(object2[key])) return object2[key].test(object1[key]);\n\t\treturn object2[key] === object1[key];\n\t});\n}\n//#endregion\n//#region src/helpers/getMarkRange.ts\nfunction findMarkInSet(marks, type, attributes = {}) {\n\treturn marks.find((item) => {\n\t\treturn item.type === type && objectIncludes(Object.fromEntries(Object.keys(attributes).map((k) => [k, item.attrs[k]])), attributes);\n\t});\n}\nfunction isMarkInSet(marks, type, attributes = {}) {\n\treturn !!findMarkInSet(marks, type, attributes);\n}\n/**\n* Get the range of a mark at a resolved position.\n*/\nfunction getMarkRange($pos, type, attributes) {\n\tif (!$pos || !type) return;\n\tlet start = $pos.parent.childAfter($pos.parentOffset);\n\tif (!start.node || !start.node.marks.some((mark) => mark.type === type)) start = $pos.parent.childBefore($pos.parentOffset);\n\tif (!start.node || !start.node.marks.some((mark) => mark.type === type)) return;\n\tif (!attributes) {\n\t\tconst firstMark = start.node.marks.find((mark) => mark.type === type);\n\t\tif (firstMark) attributes = firstMark.attrs;\n\t}\n\tif (!findMarkInSet([...start.node.marks], type, attributes)) return;\n\tlet startIndex = start.index;\n\tlet startPos = $pos.start() + start.offset;\n\tlet endIndex = startIndex + 1;\n\tlet endPos = startPos + start.node.nodeSize;\n\twhile (startIndex > 0 && isMarkInSet([...$pos.parent.child(startIndex - 1).marks], type, attributes)) {\n\t\tstartIndex -= 1;\n\t\tstartPos -= $pos.parent.child(startIndex).nodeSize;\n\t}\n\twhile (endIndex < $pos.parent.childCount && isMarkInSet([...$pos.parent.child(endIndex).marks], type, attributes)) {\n\t\tendPos += $pos.parent.child(endIndex).nodeSize;\n\t\tendIndex += 1;\n\t}\n\treturn {\n\t\tfrom: startPos,\n\t\tto: endPos\n\t};\n}\n//#endregion\n//#region src/helpers/getMarkType.ts\nfunction getMarkType(nameOrType, schema) {\n\tif (typeof nameOrType === \"string\") {\n\t\tif (!schema.marks[nameOrType]) throw Error(`There is no mark type named '${nameOrType}'. Maybe you forgot to add the extension?`);\n\t\treturn schema.marks[nameOrType];\n\t}\n\treturn nameOrType;\n}\n//#endregion\n//#region src/commands/extendMarkRange.ts\nconst extendMarkRange = (typeOrName, attributes) => ({ tr, state, dispatch }) => {\n\tconst type = getMarkType(typeOrName, state.schema);\n\tconst { doc, selection } = tr;\n\tconst { $from, from, to } = selection;\n\tif (dispatch) {\n\t\tconst range = getMarkRange($from, type, attributes);\n\t\tif (range && range.from <= from && range.to >= to) {\n\t\t\tconst newSelection = _tiptap_pm_state.TextSelection.create(doc, range.from, range.to);\n\t\t\ttr.setSelection(newSelection);\n\t\t}\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/first.ts\nconst first = (commands) => (props) => {\n\tconst items = typeof commands === \"function\" ? commands(props) : commands;\n\tfor (let i = 0; i < items.length; i += 1) if (items[i](props)) return true;\n\treturn false;\n};\n//#endregion\n//#region src/helpers/isTextSelection.ts\nfunction isTextSelection(value) {\n\treturn value instanceof _tiptap_pm_state.TextSelection;\n}\n//#endregion\n//#region src/utilities/minMax.ts\nfunction minMax(value = 0, min = 0, max = 0) {\n\treturn Math.min(Math.max(value, min), max);\n}\n//#endregion\n//#region src/helpers/resolveFocusPosition.ts\nfunction resolveFocusPosition(doc, position = null) {\n\tif (!position) return null;\n\tconst selectionAtStart = _tiptap_pm_state.Selection.atStart(doc);\n\tconst selectionAtEnd = _tiptap_pm_state.Selection.atEnd(doc);\n\tif (position === \"start\" || position === true) return selectionAtStart;\n\tif (position === \"end\") return selectionAtEnd;\n\tconst minPos = selectionAtStart.from;\n\tconst maxPos = selectionAtEnd.to;\n\tif (position === \"all\") return _tiptap_pm_state.TextSelection.create(doc, minMax(0, minPos, maxPos), minMax(doc.content.size, minPos, maxPos));\n\treturn _tiptap_pm_state.TextSelection.create(doc, minMax(position, minPos, maxPos), minMax(position, minPos, maxPos));\n}\n//#endregion\n//#region src/utilities/isAndroid.ts\nfunction isAndroid() {\n\treturn [\"Android\"].includes(navigator.platform) || /android/i.test(navigator.userAgent);\n}\n//#endregion\n//#region src/utilities/isiOS.ts\nfunction isiOS() {\n\treturn [\n\t\t\"iPad Simulator\",\n\t\t\"iPhone Simulator\",\n\t\t\"iPod Simulator\",\n\t\t\"iPad\",\n\t\t\"iPhone\",\n\t\t\"iPod\"\n\t].includes(navigator.platform) || navigator.userAgent.includes(\"Mac\") && \"ontouchend\" in document;\n}\n//#endregion\n//#region src/utilities/isSafari.ts\n/**\n* Detects if the current browser is Safari (but not iOS Safari or Chrome).\n* @returns `true` if the browser is Safari, `false` otherwise.\n* @example\n* if (isSafari()) {\n* // Safari-specific handling\n* }\n*/\nfunction isSafari() {\n\treturn typeof navigator !== \"undefined\" ? /^((?!chrome|android).)*safari/i.test(navigator.userAgent) : false;\n}\n//#endregion\n//#region src/commands/focus.ts\nconst focus = (position = null, options = {}) => ({ editor, view, tr, dispatch }) => {\n\toptions = {\n\t\tscrollIntoView: true,\n\t\t...options\n\t};\n\tconst delayedFocus = () => {\n\t\tif (isiOS() || isAndroid()) view.dom.focus();\n\t\tif (isSafari() && !isiOS() && !isAndroid()) view.dom.focus({ preventScroll: true });\n\t\trequestAnimationFrame(() => {\n\t\t\tif (!editor.isDestroyed) {\n\t\t\t\tview.focus();\n\t\t\t\tif (options === null || options === void 0 ? void 0 : options.scrollIntoView) editor.commands.scrollIntoView();\n\t\t\t}\n\t\t});\n\t};\n\ttry {\n\t\tif (view.hasFocus() && position === null || position === false) return true;\n\t} catch {\n\t\treturn false;\n\t}\n\tif (dispatch && position === null && !isTextSelection(editor.state.selection)) {\n\t\tdelayedFocus();\n\t\treturn true;\n\t}\n\tconst selection = resolveFocusPosition(tr.doc, position) || editor.state.selection;\n\tconst isSameSelection = editor.state.selection.eq(selection);\n\tif (dispatch) {\n\t\tif (!isSameSelection) tr.setSelection(selection);\n\t\tif (isSameSelection && tr.storedMarks) tr.setStoredMarks(tr.storedMarks);\n\t\tdelayedFocus();\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/forEach.ts\nconst forEach = (items, fn) => (props) => {\n\treturn items.every((item, index) => fn(item, {\n\t\t...props,\n\t\tindex\n\t}));\n};\n//#endregion\n//#region src/commands/insertContent.ts\nconst insertContent = (value, options) => ({ tr, commands }) => {\n\treturn commands.insertContentAt({\n\t\tfrom: tr.selection.from,\n\t\tto: tr.selection.to\n\t}, value, options);\n};\n//#endregion\n//#region src/utilities/elementFromString.ts\nconst removeWhitespaces = (node) => {\n\tconst children = node.childNodes;\n\tfor (let i = children.length - 1; i >= 0; i -= 1) {\n\t\tconst child = children[i];\n\t\tif (child.nodeType === 3 && child.nodeValue && /^(\\n\\s\\s|\\n)$/.test(child.nodeValue)) node.removeChild(child);\n\t\telse if (child.nodeType === 1) removeWhitespaces(child);\n\t}\n\treturn node;\n};\nfunction elementFromString(value) {\n\tif (typeof window === \"undefined\") throw new Error(\"[tiptap error]: there is no window object available, so this function cannot be used\");\n\tconst wrappedValue = `<body>${value}</body>`;\n\tconst html = new window.DOMParser().parseFromString(wrappedValue, \"text/html\").body;\n\treturn removeWhitespaces(html);\n}\n//#endregion\n//#region src/helpers/isProseMirrorContent.ts\n/**\n* Checks whether a value is already a ProseMirror node or fragment. Looks for the\n* `nodesBetween` method, because `instanceof` fails when prosemirror-model is loaded twice.\n* @param value Any value that could be passed as content\n* @returns True for a node or a fragment, false for JSON, HTML and everything else\n* @example ```js\n* isProseMirrorContent(editor.state.doc)\n* ```\n*/\nfunction isProseMirrorContent(value) {\n\treturn typeof (value === null || value === void 0 ? void 0 : value.nodesBetween) === \"function\";\n}\n//#endregion\n//#region src/helpers/createNodeFromContent.ts\n/**\n* Takes a JSON or HTML content and creates a Prosemirror node or fragment from it.\n* @param content The JSON or HTML content to create the node from\n* @param schema The Prosemirror schema to use for the node\n* @param options Options for the parser\n* @returns The created Prosemirror node or fragment\n*/\nfunction createNodeFromContent(content, schema, options) {\n\tif (isProseMirrorContent(content)) return content;\n\tconst isJSONContent = typeof content === \"object\" && content !== null;\n\toptions = {\n\t\tslice: true,\n\t\tparseOptions: {},\n\t\t...options\n\t};\n\tconst isTextContent = typeof content === \"string\";\n\tif (isJSONContent) try {\n\t\tif (Array.isArray(content) && content.length > 0) return _tiptap_pm_model.Fragment.fromArray(content.map((item) => schema.nodeFromJSON(item)));\n\t\tconst node = schema.nodeFromJSON(content);\n\t\tif (options.errorOnInvalidContent) node.check();\n\t\treturn node;\n\t} catch (error) {\n\t\tif (options.errorOnInvalidContent) throw new Error(\"[tiptap error]: Invalid JSON content\", { cause: error });\n\t\tconsole.warn(\"[tiptap warn]: Invalid content.\", \"Passed value:\", content, \"Error:\", error);\n\t\treturn createNodeFromContent(\"\", schema, options);\n\t}\n\tif (isTextContent) {\n\t\tif (options.errorOnInvalidContent) {\n\t\t\tlet hasInvalidContent = false;\n\t\t\tlet invalidContent = \"\";\n\t\t\tconst contentCheckSchema = new _tiptap_pm_model.Schema({\n\t\t\t\ttopNode: schema.spec.topNode,\n\t\t\t\tmarks: schema.spec.marks,\n\t\t\t\tnodes: schema.spec.nodes.append({ __tiptap__private__unknown__catch__all__node: {\n\t\t\t\t\tcontent: \"inline*\",\n\t\t\t\t\tgroup: \"block\",\n\t\t\t\t\tparseDOM: [{\n\t\t\t\t\t\ttag: \"*\",\n\t\t\t\t\t\tgetAttrs: (e) => {\n\t\t\t\t\t\t\thasInvalidContent = true;\n\t\t\t\t\t\t\tinvalidContent = typeof e === \"string\" ? e : e.outerHTML;\n\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t}\n\t\t\t\t\t}]\n\t\t\t\t} })\n\t\t\t});\n\t\t\tif (options.slice) _tiptap_pm_model.DOMParser.fromSchema(contentCheckSchema).parseSlice(elementFromString(content), options.parseOptions);\n\t\t\telse _tiptap_pm_model.DOMParser.fromSchema(contentCheckSchema).parse(elementFromString(content), options.parseOptions);\n\t\t\tif (options.errorOnInvalidContent && hasInvalidContent) throw new Error(\"[tiptap error]: Invalid HTML content\", { cause: /* @__PURE__ */ new Error(`Invalid element found: ${invalidContent}`) });\n\t\t}\n\t\tconst parser = _tiptap_pm_model.DOMParser.fromSchema(schema);\n\t\tif (options.slice) return parser.parseSlice(elementFromString(content), options.parseOptions).content;\n\t\treturn parser.parse(elementFromString(content), options.parseOptions);\n\t}\n\treturn createNodeFromContent(\"\", schema, options);\n}\n//#endregion\n//#region src/helpers/isFragment.ts\n/**\n* Checks whether a node or fragment is a fragment. Looks for a missing `type` field,\n* because `instanceof` fails when prosemirror-model is loaded twice.\n* @param nodeOrFragment A ProseMirror node or fragment\n* @returns True for a fragment, false for a node\n* @example ```js\n* isFragment(editor.state.doc.content)\n* ```\n*/\nfunction isFragment(nodeOrFragment) {\n\treturn !(\"type\" in nodeOrFragment);\n}\n//#endregion\n//#region src/helpers/selectionToInsertionEnd.ts\nfunction selectionToInsertionEnd(tr, startLen, bias) {\n\tconst last = tr.steps.length - 1;\n\tif (last < startLen) return;\n\tconst step = tr.steps[last];\n\tif (!(step instanceof _tiptap_pm_transform.ReplaceStep || step instanceof _tiptap_pm_transform.ReplaceAroundStep)) return;\n\tconst map = tr.mapping.maps[last];\n\tlet end = 0;\n\tmap.forEach((_from, _to, _newFrom, newTo) => {\n\t\tif (end === 0) end = newTo;\n\t});\n\ttr.setSelection(_tiptap_pm_state.Selection.near(tr.doc.resolve(end), bias));\n}\n//#endregion\n//#region src/commands/insertContentAt.ts\nconst insertContentAt = (position, value, options) => ({ tr, dispatch, editor }) => {\n\tif (dispatch) {\n\t\toptions = {\n\t\t\tparseOptions: editor.options.parseOptions,\n\t\t\tupdateSelection: true,\n\t\t\tapplyInputRules: false,\n\t\t\tapplyPasteRules: false,\n\t\t\t...options\n\t\t};\n\t\tlet content;\n\t\tconst emitContentError = (error) => {\n\t\t\teditor.emit(\"contentError\", {\n\t\t\t\teditor,\n\t\t\t\terror,\n\t\t\t\tdisableCollaboration: () => {\n\t\t\t\t\tif (\"collaboration\" in editor.storage && typeof editor.storage.collaboration === \"object\" && editor.storage.collaboration) editor.storage.collaboration.isDisabled = true;\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\tconst parseOptions = {\n\t\t\tpreserveWhitespace: \"full\",\n\t\t\t...options.parseOptions\n\t\t};\n\t\tif (!options.errorOnInvalidContent && !editor.options.enableContentCheck && editor.options.emitContentError) try {\n\t\t\tcreateNodeFromContent(value, editor.schema, {\n\t\t\t\tparseOptions,\n\t\t\t\terrorOnInvalidContent: true\n\t\t\t});\n\t\t} catch (e) {\n\t\t\temitContentError(e);\n\t\t}\n\t\ttry {\n\t\t\tvar _options$errorOnInval;\n\t\t\tcontent = createNodeFromContent(value, editor.schema, {\n\t\t\t\tparseOptions,\n\t\t\t\terrorOnInvalidContent: (_options$errorOnInval = options.errorOnInvalidContent) !== null && _options$errorOnInval !== void 0 ? _options$errorOnInval : editor.options.enableContentCheck\n\t\t\t});\n\t\t} catch (e) {\n\t\t\temitContentError(e);\n\t\t\treturn false;\n\t\t}\n\t\tlet { from, to } = typeof position === \"number\" ? {\n\t\t\tfrom: position,\n\t\t\tto: position\n\t\t} : {\n\t\t\tfrom: position.from,\n\t\t\tto: position.to\n\t\t};\n\t\tlet isOnlyTextContent = true;\n\t\tlet isOnlyBlockContent = true;\n\t\tconst nodes = isFragment(content) ? content.content : [content];\n\t\tnodes.forEach((node) => {\n\t\t\tnode.check();\n\t\t\tisOnlyTextContent = isOnlyTextContent ? node.isText && node.marks.length === 0 : false;\n\t\t\tisOnlyBlockContent = isOnlyBlockContent ? node.isBlock : false;\n\t\t});\n\t\tif (from === to && isOnlyBlockContent) {\n\t\t\tconst { parent } = tr.doc.resolve(from);\n\t\t\tif (parent.isTextblock && !parent.type.spec.code && !parent.childCount) {\n\t\t\t\tfrom -= 1;\n\t\t\t\tto += 1;\n\t\t\t}\n\t\t}\n\t\tlet newContent;\n\t\tif (isOnlyTextContent) {\n\t\t\tif (Array.isArray(value)) newContent = value.map((item) => item.text || \"\").join(\"\");\n\t\t\telse if (isProseMirrorContent(value)) newContent = nodes.map((node) => {\n\t\t\t\tvar _node$text;\n\t\t\t\treturn (_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : \"\";\n\t\t\t}).join(\"\");\n\t\t\telse if (typeof value === \"object\" && !!value && !!value.text) newContent = value.text;\n\t\t\telse newContent = value;\n\t\t\ttr.insertText(newContent, from, to);\n\t\t} else {\n\t\t\tnewContent = _tiptap_pm_model.Fragment.from(nodes);\n\t\t\tconst $from = tr.doc.resolve(from);\n\t\t\tconst $fromNode = $from.node();\n\t\t\tconst fromSelectionAtStart = $from.parentOffset === 0;\n\t\t\tconst isTextSelection = $fromNode.isText || $fromNode.isTextblock;\n\t\t\tconst hasContent = $fromNode.content.size > 0;\n\t\t\tif (fromSelectionAtStart && isTextSelection && hasContent && isOnlyBlockContent) from = Math.max(0, from - 1);\n\t\t\ttr.replaceWith(from, to, nodes);\n\t\t}\n\t\tif (options.updateSelection) selectionToInsertionEnd(tr, tr.steps.length - 1, -1);\n\t\tif (options.applyInputRules) tr.setMeta(\"applyInputRules\", {\n\t\t\tfrom,\n\t\t\ttext: newContent\n\t\t});\n\t\tif (options.applyPasteRules) tr.setMeta(\"applyPasteRules\", {\n\t\t\tfrom,\n\t\t\ttext: newContent\n\t\t});\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/helpers/defaultBlockAt.ts\n/**\n* Gets the default block type at a given match\n* @param match The content match to get the default block type from\n* @returns The default block type or null\n*/\nfunction defaultBlockAt(match) {\n\tfor (let i = 0; i < match.edgeCount; i += 1) {\n\t\tconst { type } = match.edge(i);\n\t\tif (type.isTextblock && !type.hasRequiredAttrs()) return type;\n\t}\n\treturn null;\n}\n//#endregion\n//#region src/commands/insertDefaultBlock.ts\nconst insertDefaultBlock = (options = {}) => ({ tr, dispatch, editor }) => {\n\tconst { pos, attrs, content, updateSelection = true } = options;\n\tlet $pos;\n\tif (typeof pos === \"number\") $pos = tr.doc.resolve(pos);\n\telse if (pos) $pos = pos;\n\telse $pos = tr.selection.$from;\n\tconst defaultType = defaultBlockAt($pos.parent.contentMatchAt($pos.index()));\n\tif (!defaultType) return false;\n\tconst validAttrKeys = Object.keys(defaultType.spec.attrs || {});\n\tconst filteredAttrs = attrs ? Object.fromEntries(Object.entries(attrs).filter(([key]) => validAttrKeys.includes(key))) : {};\n\tlet node;\n\tif (content) {\n\t\tconst parsed = createNodeFromContent(content, editor.schema);\n\t\tnode = defaultType.createAndFill(filteredAttrs, parsed);\n\t} else node = defaultType.createAndFill(filteredAttrs);\n\tif (!node) return false;\n\tif (dispatch) {\n\t\ttr.insert($pos.pos, node);\n\t\tif (updateSelection) selectionToInsertionEnd(tr, tr.steps.length - 1, -1);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/join.ts\nconst joinUp = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinUp)(state, dispatch);\n};\nconst joinDown = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinDown)(state, dispatch);\n};\nconst joinBackward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinBackward)(state, dispatch);\n};\nconst joinForward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinForward)(state, dispatch);\n};\n//#endregion\n//#region src/commands/joinItemBackward.ts\nconst joinItemBackward = () => ({ state, dispatch, tr }) => {\n\ttry {\n\t\tconst point = (0, _tiptap_pm_transform.joinPoint)(state.doc, state.selection.$from.pos, -1);\n\t\tif (point === null || point === void 0) return false;\n\t\ttr.join(point, 2);\n\t\tif (dispatch) dispatch(tr);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n//#endregion\n//#region src/commands/joinItemForward.ts\nconst joinItemForward = () => ({ state, dispatch, tr }) => {\n\ttry {\n\t\tconst point = (0, _tiptap_pm_transform.joinPoint)(state.doc, state.selection.$from.pos, 1);\n\t\tif (point === null || point === void 0) return false;\n\t\ttr.join(point, 2);\n\t\tif (dispatch) dispatch(tr);\n\t\treturn true;\n\t} catch {\n\t\treturn false;\n\t}\n};\n//#endregion\n//#region src/commands/joinTextblockBackward.ts\nconst joinTextblockBackward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinTextblockBackward)(state, dispatch);\n};\n//#endregion\n//#region src/commands/joinTextblockForward.ts\nconst joinTextblockForward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.joinTextblockForward)(state, dispatch);\n};\n//#endregion\n//#region src/utilities/isMacOS.ts\nfunction isMacOS() {\n\treturn typeof navigator !== \"undefined\" ? /Mac/.test(navigator.platform) : false;\n}\n//#endregion\n//#region src/commands/keyboardShortcut.ts\nfunction normalizeKeyName(name) {\n\tconst parts = name.split(/-(?!$)/);\n\tlet result = parts[parts.length - 1];\n\tif (result === \"Space\") result = \" \";\n\tlet alt;\n\tlet ctrl;\n\tlet shift;\n\tlet meta;\n\tfor (let i = 0; i < parts.length - 1; i += 1) {\n\t\tconst mod = parts[i];\n\t\tif (/^(cmd|meta|m)$/i.test(mod)) meta = true;\n\t\telse if (/^a(lt)?$/i.test(mod)) alt = true;\n\t\telse if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;\n\t\telse if (/^s(hift)?$/i.test(mod)) shift = true;\n\t\telse if (/^mod$/i.test(mod)) {\n\t\t\tif (isiOS() || isMacOS()) meta = true;\n\t\t\telse ctrl = true;\n\t\t} else throw new Error(`Unrecognized modifier name: ${mod}`);\n\t}\n\tif (alt) result = `Alt-${result}`;\n\tif (ctrl) result = `Ctrl-${result}`;\n\tif (meta) result = `Meta-${result}`;\n\tif (shift) result = `Shift-${result}`;\n\treturn result;\n}\nconst keyboardShortcut = (name) => ({ editor, view, tr, dispatch }) => {\n\tconst keys = normalizeKeyName(name).split(/-(?!$)/);\n\tconst key = keys.find((item) => ![\n\t\t\"Alt\",\n\t\t\"Ctrl\",\n\t\t\"Meta\",\n\t\t\"Shift\"\n\t].includes(item));\n\tconst event = new KeyboardEvent(\"keydown\", {\n\t\tkey: key === \"Space\" ? \" \" : key,\n\t\taltKey: keys.includes(\"Alt\"),\n\t\tctrlKey: keys.includes(\"Ctrl\"),\n\t\tmetaKey: keys.includes(\"Meta\"),\n\t\tshiftKey: keys.includes(\"Shift\"),\n\t\tbubbles: true,\n\t\tcancelable: true\n\t});\n\tconst capturedTransaction = editor.captureTransaction(() => {\n\t\tview.someProp(\"handleKeyDown\", (f) => f(view, event));\n\t});\n\tcapturedTransaction === null || capturedTransaction === void 0 || capturedTransaction.steps.forEach((step) => {\n\t\tconst newStep = step.map(tr.mapping);\n\t\tif (newStep && dispatch) tr.maybeStep(newStep);\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/helpers/isNodeActive.ts\nfunction isNodeActive(state, typeOrName, attributes = {}) {\n\tconst { from, to, empty } = state.selection;\n\tconst type = typeOrName ? getNodeType(typeOrName, state.schema) : null;\n\tconst nodeRanges = [];\n\tstate.doc.nodesBetween(from, to, (node, pos) => {\n\t\tif (node.isText) return;\n\t\tconst relativeFrom = Math.max(from, pos);\n\t\tconst relativeTo = Math.min(to, pos + node.nodeSize);\n\t\tnodeRanges.push({\n\t\t\tnode,\n\t\t\tfrom: relativeFrom,\n\t\t\tto: relativeTo\n\t\t});\n\t});\n\tconst selectionRange = to - from;\n\tconst matchedNodeRanges = nodeRanges.filter((nodeRange) => {\n\t\tif (!type) return true;\n\t\treturn type.name === nodeRange.node.type.name;\n\t}).filter((nodeRange) => objectIncludes(nodeRange.node.attrs, attributes, { strict: false }));\n\tif (empty) return !!matchedNodeRanges.length;\n\treturn matchedNodeRanges.reduce((sum, nodeRange) => sum + nodeRange.to - nodeRange.from, 0) >= selectionRange;\n}\n//#endregion\n//#region src/commands/lift.ts\nconst lift = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\n\tif (!isNodeActive(state, getNodeType(typeOrName, state.schema), attributes)) return false;\n\treturn (0, _tiptap_pm_commands.lift)(state, dispatch);\n};\n//#endregion\n//#region src/commands/liftEmptyBlock.ts\nconst liftEmptyBlock = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.liftEmptyBlock)(state, dispatch);\n};\n//#endregion\n//#region src/commands/liftListItem.ts\nconst liftListItem = (typeOrName) => ({ state, dispatch }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\treturn (0, _tiptap_pm_schema_list.liftListItem)(type)(state, dispatch);\n};\n//#endregion\n//#region src/commands/newlineInCode.ts\nconst newlineInCode = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.newlineInCode)(state, dispatch);\n};\n//#endregion\n//#region src/helpers/getSchemaTypeNameByName.ts\n/**\n* Get the type of a schema item by its name.\n* @param name The name of the schema item\n* @param schema The Prosemiror schema to search in\n* @returns The type of the schema item (`node` or `mark`), or null if it doesn't exist\n*/\nfunction getSchemaTypeNameByName(name, schema) {\n\tif (schema.nodes[name]) return \"node\";\n\tif (schema.marks[name]) return \"mark\";\n\treturn null;\n}\n//#endregion\n//#region src/utilities/deleteProps.ts\n/**\n* Remove a property or an array of properties from an object\n* @param obj Object\n* @param key Key to remove\n*/\nfunction deleteProps(obj, propOrProps) {\n\tconst props = typeof propOrProps === \"string\" ? [propOrProps] : propOrProps;\n\treturn Object.keys(obj).reduce((newObj, prop) => {\n\t\tif (!props.includes(prop)) newObj[prop] = obj[prop];\n\t\treturn newObj;\n\t}, {});\n}\n//#endregion\n//#region src/commands/resetAttributes.ts\nconst resetAttributes = (typeOrName, attributes) => ({ tr, state, dispatch }) => {\n\tlet nodeType = null;\n\tlet markType = null;\n\tconst schemaType = getSchemaTypeNameByName(typeof typeOrName === \"string\" ? typeOrName : typeOrName.name, state.schema);\n\tif (!schemaType) return false;\n\tif (schemaType === \"node\") nodeType = getNodeType(typeOrName, state.schema);\n\tif (schemaType === \"mark\") markType = getMarkType(typeOrName, state.schema);\n\tlet canReset = false;\n\ttr.selection.ranges.forEach((range) => {\n\t\tstate.doc.nodesBetween(range.$from.pos, range.$to.pos, (node, pos) => {\n\t\t\tif (nodeType && nodeType === node.type) {\n\t\t\t\tcanReset = true;\n\t\t\t\tif (dispatch) tr.setNodeMarkup(pos, void 0, deleteProps(node.attrs, attributes));\n\t\t\t}\n\t\t\tif (markType && node.marks.length) node.marks.forEach((mark) => {\n\t\t\t\tif (markType === mark.type) {\n\t\t\t\t\tcanReset = true;\n\t\t\t\t\tif (dispatch) tr.addMark(pos, pos + node.nodeSize, markType.create(deleteProps(mark.attrs, attributes)));\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n\treturn canReset;\n};\n//#endregion\n//#region src/commands/scrollIntoView.ts\nconst scrollIntoView = () => ({ tr, dispatch }) => {\n\tif (dispatch) tr.scrollIntoView();\n\treturn true;\n};\n//#endregion\n//#region src/commands/selectAll.ts\nconst selectAll = () => ({ tr, dispatch }) => {\n\tif (dispatch) {\n\t\tconst selection = new _tiptap_pm_state.AllSelection(tr.doc);\n\t\ttr.setSelection(selection);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/selectNodeBackward.ts\nconst selectNodeBackward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.selectNodeBackward)(state, dispatch);\n};\n//#endregion\n//#region src/commands/selectNodeForward.ts\nconst selectNodeForward = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.selectNodeForward)(state, dispatch);\n};\n//#endregion\n//#region src/commands/selectParentNode.ts\nconst selectParentNode = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.selectParentNode)(state, dispatch);\n};\n//#endregion\n//#region src/commands/selectTextblockEnd.ts\nconst selectTextblockEnd = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.selectTextblockEnd)(state, dispatch);\n};\n//#endregion\n//#region src/commands/selectTextblockStart.ts\nconst selectTextblockStart = () => ({ state, dispatch }) => {\n\treturn (0, _tiptap_pm_commands.selectTextblockStart)(state, dispatch);\n};\n//#endregion\n//#region src/helpers/createDocument.ts\n/**\n* Create a new Prosemirror document node from content.\n* @param content The JSON or HTML content to create the document from\n* @param schema The Prosemirror schema to use for the document\n* @param parseOptions Options for the parser\n* @returns The created Prosemirror document node\n*/\nfunction createDocument(content, schema, parseOptions = {}, options = {}) {\n\treturn createNodeFromContent(content, schema, {\n\t\tslice: false,\n\t\tparseOptions,\n\t\terrorOnInvalidContent: options.errorOnInvalidContent\n\t});\n}\n//#endregion\n//#region src/commands/setContent.ts\nconst setContent = (content, { errorOnInvalidContent, emitUpdate = true, parseOptions = {} } = {}) => ({ editor, tr, dispatch, commands }) => {\n\tconst { doc } = tr;\n\tif (parseOptions.preserveWhitespace !== \"full\") {\n\t\tconst document = createDocument(content, editor.schema, parseOptions, { errorOnInvalidContent: errorOnInvalidContent !== null && errorOnInvalidContent !== void 0 ? errorOnInvalidContent : editor.options.enableContentCheck });\n\t\tif (dispatch) {\n\t\t\tconst nodes = isFragment(document) ? document.content : [document];\n\t\t\ttr.replaceWith(0, doc.content.size, nodes).setMeta(\"preventUpdate\", !emitUpdate);\n\t\t}\n\t\treturn true;\n\t}\n\tif (dispatch) tr.setMeta(\"preventUpdate\", !emitUpdate);\n\treturn commands.insertContentAt({\n\t\tfrom: 0,\n\t\tto: doc.content.size\n\t}, content, {\n\t\tparseOptions,\n\t\terrorOnInvalidContent: errorOnInvalidContent !== null && errorOnInvalidContent !== void 0 ? errorOnInvalidContent : editor.options.enableContentCheck\n\t});\n};\n//#endregion\n//#region src/helpers/getMarkAttributes.ts\nfunction getMarkAttributes(state, typeOrName) {\n\tconst type = getMarkType(typeOrName, state.schema);\n\tconst { from, to, empty } = state.selection;\n\tconst marks = [];\n\tif (empty) {\n\t\tif (state.storedMarks) marks.push(...state.storedMarks);\n\t\tmarks.push(...state.selection.$head.marks());\n\t} else state.doc.nodesBetween(from, to, (node) => {\n\t\tmarks.push(...node.marks);\n\t});\n\tconst mark = marks.find((markItem) => markItem.type.name === type.name);\n\tif (!mark) return {};\n\treturn { ...mark.attrs };\n}\n//#endregion\n//#region src/helpers/combineTransactionSteps.ts\n/**\n* Returns a new `Transform` based on all steps of the passed transactions.\n* @param oldDoc The Prosemirror node to start from\n* @param transactions The transactions to combine\n* @returns A new `Transform` with all steps of the passed transactions\n*/\nfunction combineTransactionSteps(oldDoc, transactions) {\n\tconst transform = new _tiptap_pm_transform.Transform(oldDoc);\n\ttransactions.forEach((transaction) => {\n\t\ttransaction.steps.forEach((step) => {\n\t\t\ttransform.step(step);\n\t\t});\n\t});\n\treturn transform;\n}\n//#endregion\n//#region src/helpers/findChildren.ts\n/**\n* Find children inside a Prosemirror node that match a predicate.\n* @param node The Prosemirror node to search in\n* @param predicate The predicate to match\n* @returns An array of nodes with their positions\n*/\nfunction findChildren(node, predicate) {\n\tconst nodesWithPos = [];\n\tnode.descendants((child, pos) => {\n\t\tif (predicate(child)) nodesWithPos.push({\n\t\t\tnode: child,\n\t\t\tpos\n\t\t});\n\t});\n\treturn nodesWithPos;\n}\n//#endregion\n//#region src/helpers/findChildrenInRange.ts\n/**\n* Same as `findChildren` but searches only within a `range`.\n* @param node The Prosemirror node to search in\n* @param range The range to search in\n* @param predicate The predicate to match\n* @returns An array of nodes with their positions\n*/\nfunction findChildrenInRange(node, range, predicate) {\n\tconst nodesWithPos = [];\n\tnode.nodesBetween(range.from, range.to, (child, pos) => {\n\t\tif (predicate(child)) nodesWithPos.push({\n\t\t\tnode: child,\n\t\t\tpos\n\t\t});\n\t});\n\treturn nodesWithPos;\n}\n//#endregion\n//#region src/helpers/findParentNodeClosestToPos.ts\n/**\n* Finds the closest parent node to a resolved position that matches a predicate.\n* @param $pos The resolved position to search from\n* @param predicate The predicate to match\n* @returns The closest parent node to the resolved position that matches the predicate\n* @example ```js\n* findParentNodeClosestToPos($from, node => node.type.name === 'paragraph')\n* ```\n*/\nfunction findParentNodeClosestToPos($pos, predicate) {\n\tfor (let i = $pos.depth; i > 0; i -= 1) {\n\t\tconst node = $pos.node(i);\n\t\tif (predicate(node)) return {\n\t\t\tpos: i > 0 ? $pos.before(i) : 0,\n\t\t\tstart: $pos.start(i),\n\t\t\tdepth: i,\n\t\t\tnode\n\t\t};\n\t}\n}\n//#endregion\n//#region src/helpers/findParentNode.ts\n/**\n* Finds the closest parent node to the current selection that matches a predicate.\n* @param predicate The predicate to match\n* @returns A command that finds the closest parent node to the current selection that matches the predicate\n* @example ```js\n* findParentNode(node => node.type.name === 'paragraph')\n* ```\n*/\nfunction findParentNode(predicate) {\n\treturn (selection) => findParentNodeClosestToPos(selection.$from, predicate);\n}\n//#endregion\n//#region src/helpers/getExtensionField.ts\n/**\n* Returns a field from an extension\n* @param extension The Tiptap extension\n* @param field The field, for example `renderHTML` or `priority`\n* @param context The context object that should be passed as `this` into the function\n* @returns The field value\n*/\nfunction getExtensionField(extension, field, context) {\n\tif (extension.config[field] === void 0 && extension.parent) return getExtensionField(extension.parent, field, context);\n\tif (typeof extension.config[field] === \"function\") return extension.config[field].bind({\n\t\t...context,\n\t\tparent: extension.parent ? getExtensionField(extension.parent, field, context) : null\n\t});\n\treturn extension.config[field];\n}\n//#endregion\n//#region src/helpers/flattenExtensions.ts\n/**\n* Create a flattened array of extensions by traversing the `addExtensions` field.\n* @param extensions An array of Tiptap extensions\n* @returns A flattened array of Tiptap extensions\n*/\nfunction flattenExtensions(extensions) {\n\treturn extensions.map((extension) => {\n\t\tconst addExtensions = getExtensionField(extension, \"addExtensions\", {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage\n\t\t});\n\t\tif (addExtensions) return [extension, ...flattenExtensions(addExtensions())];\n\t\treturn extension;\n\t}).flat(10);\n}\n//#endregion\n//#region src/helpers/getHTMLFromFragment.ts\nfunction getHTMLFromFragment(fragment, schema) {\n\tconst documentFragment = _tiptap_pm_model.DOMSerializer.fromSchema(schema).serializeFragment(fragment);\n\tconst container = document.implementation.createHTMLDocument().createElement(\"div\");\n\tcontainer.appendChild(documentFragment);\n\treturn container.innerHTML;\n}\n//#endregion\n//#region src/utilities/isFunction.ts\nfunction isFunction(value) {\n\treturn typeof value === \"function\";\n}\n//#endregion\n//#region src/utilities/callOrReturn.ts\n/**\n* Optionally calls `value` as a function.\n* Otherwise it is returned directly.\n* @param value Function or any value.\n* @param context Optional context to bind to function.\n* @param props Optional props to pass to function.\n*/\nfunction callOrReturn(value, context = void 0, ...props) {\n\tif (isFunction(value)) {\n\t\tif (context) return value.bind(context)(...props);\n\t\treturn value(...props);\n\t}\n\treturn value;\n}\n//#endregion\n//#region src/utilities/isEmptyObject.ts\nfunction isEmptyObject(value = {}) {\n\treturn Object.keys(value).length === 0 && value.constructor === Object;\n}\n//#endregion\n//#region src/helpers/splitExtensions.ts\nfunction splitExtensions(extensions) {\n\treturn {\n\t\tbaseExtensions: extensions.filter((extension) => extension.type === \"extension\"),\n\t\tnodeExtensions: extensions.filter((extension) => extension.type === \"node\"),\n\t\tmarkExtensions: extensions.filter((extension) => extension.type === \"mark\")\n\t};\n}\n//#endregion\n//#region src/helpers/getAttributesFromExtensions.ts\n/**\n* Get a list of all extension attributes defined in `addAttribute` and `addGlobalAttribute`.\n* @param extensions List of extensions\n*/\nfunction getAttributesFromExtensions(extensions) {\n\tconst extensionAttributes = [];\n\tconst { nodeExtensions, markExtensions } = splitExtensions(extensions);\n\tconst nodeAndMarkExtensions = [...nodeExtensions, ...markExtensions];\n\tconst defaultAttribute = {\n\t\tdefault: null,\n\t\tvalidate: void 0,\n\t\trendered: true,\n\t\trenderHTML: null,\n\t\tparseHTML: null,\n\t\tkeepOnSplit: true,\n\t\tisRequired: false\n\t};\n\tconst nodeExtensionTypes = nodeExtensions.filter((ext) => ext.name !== \"text\").map((ext) => ext.name);\n\tconst markExtensionTypes = markExtensions.map((ext) => ext.name);\n\tconst allExtensionTypes = [...nodeExtensionTypes, ...markExtensionTypes];\n\textensions.forEach((extension) => {\n\t\tconst addGlobalAttributes = getExtensionField(extension, \"addGlobalAttributes\", {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage,\n\t\t\textensions: nodeAndMarkExtensions\n\t\t});\n\t\tif (!addGlobalAttributes) return;\n\t\taddGlobalAttributes().forEach((globalAttribute) => {\n\t\t\tlet resolvedTypes;\n\t\t\tif (Array.isArray(globalAttribute.types)) resolvedTypes = globalAttribute.types;\n\t\t\telse if (globalAttribute.types === \"*\") resolvedTypes = allExtensionTypes;\n\t\t\telse if (globalAttribute.types === \"nodes\") resolvedTypes = nodeExtensionTypes;\n\t\t\telse if (globalAttribute.types === \"marks\") resolvedTypes = markExtensionTypes;\n\t\t\telse resolvedTypes = [];\n\t\t\tresolvedTypes.forEach((type) => {\n\t\t\t\tObject.entries(globalAttribute.attributes).forEach(([name, attribute]) => {\n\t\t\t\t\textensionAttributes.push({\n\t\t\t\t\t\ttype,\n\t\t\t\t\t\tname,\n\t\t\t\t\t\tattribute: {\n\t\t\t\t\t\t\t...defaultAttribute,\n\t\t\t\t\t\t\t...attribute\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t});\n\t});\n\tnodeAndMarkExtensions.forEach((extension) => {\n\t\tconst addAttributes = getExtensionField(extension, \"addAttributes\", {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage\n\t\t});\n\t\tif (!addAttributes) return;\n\t\tconst attributes = addAttributes();\n\t\tObject.entries(attributes).forEach(([name, attribute]) => {\n\t\t\tconst mergedAttr = {\n\t\t\t\t...defaultAttribute,\n\t\t\t\t...attribute\n\t\t\t};\n\t\t\tif (typeof (mergedAttr === null || mergedAttr === void 0 ? void 0 : mergedAttr.default) === \"function\") mergedAttr.default = mergedAttr.default();\n\t\t\tif ((mergedAttr === null || mergedAttr === void 0 ? void 0 : mergedAttr.isRequired) && (mergedAttr === null || mergedAttr === void 0 ? void 0 : mergedAttr.default) === void 0) delete mergedAttr.default;\n\t\t\textensionAttributes.push({\n\t\t\t\ttype: extension.name,\n\t\t\t\tname,\n\t\t\t\tattribute: mergedAttr\n\t\t\t});\n\t\t});\n\t});\n\treturn extensionAttributes;\n}\n//#endregion\n//#region src/utilities/mergeAttributes.ts\n/** Splits a CSS style string into declarations, ignoring semicolons inside quotes/parentheses. */\nfunction splitStyleDeclarations(styles) {\n\tconst result = [];\n\tlet current = \"\";\n\tlet inSingleQuote = false;\n\tlet inDoubleQuote = false;\n\tlet parenDepth = 0;\n\tconst length = styles.length;\n\tfor (let i = 0; i < length; i += 1) {\n\t\tconst char = styles[i];\n\t\tif (char === \"'\" && !inDoubleQuote) {\n\t\t\tinSingleQuote = !inSingleQuote;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === \"\\\"\" && !inSingleQuote) {\n\t\t\tinDoubleQuote = !inDoubleQuote;\n\t\t\tcurrent += char;\n\t\t\tcontinue;\n\t\t}\n\t\tif (!inSingleQuote && !inDoubleQuote) {\n\t\t\tif (char === \"(\") {\n\t\t\t\tparenDepth += 1;\n\t\t\t\tcurrent += char;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \")\" && parenDepth > 0) {\n\t\t\t\tparenDepth -= 1;\n\t\t\t\tcurrent += char;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (char === \";\" && parenDepth === 0) {\n\t\t\t\tresult.push(current);\n\t\t\t\tcurrent = \"\";\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t}\n\t\tcurrent += char;\n\t}\n\tif (current) result.push(current);\n\treturn result;\n}\n/** Yields property/value pairs from a style string. */\nfunction parseStyleEntries(styles) {\n\tconst pairs = [];\n\tconst declarations = splitStyleDeclarations(styles || \"\");\n\tconst numDeclarations = declarations.length;\n\tfor (let i = 0; i < numDeclarations; i += 1) {\n\t\tconst declaration = declarations[i];\n\t\tconst firstColonIndex = declaration.indexOf(\":\");\n\t\tif (firstColonIndex === -1) continue;\n\t\tconst property = declaration.slice(0, firstColonIndex).trim();\n\t\tconst value = declaration.slice(firstColonIndex + 1).trim();\n\t\tif (property && value) pairs.push([property, value]);\n\t}\n\treturn pairs;\n}\nfunction mergeAttributes(...objects) {\n\treturn objects.filter((item) => !!item).reduce((items, item) => {\n\t\tconst mergedAttributes = { ...items };\n\t\tObject.entries(item).forEach(([key, value]) => {\n\t\t\tif (key === \"__proto__\") {\n\t\t\t\tObject.defineProperty(mergedAttributes, key, {\n\t\t\t\t\tconfigurable: true,\n\t\t\t\t\tenumerable: true,\n\t\t\t\t\tvalue,\n\t\t\t\t\twritable: true\n\t\t\t\t});\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!mergedAttributes[key]) {\n\t\t\t\tmergedAttributes[key] = value;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (key === \"class\") {\n\t\t\t\tconst valueClasses = value ? String(value).split(\" \") : [];\n\t\t\t\tconst existingClasses = mergedAttributes[key] ? mergedAttributes[key].split(\" \") : [];\n\t\t\t\tconst insertClasses = valueClasses.filter((valueClass) => !existingClasses.includes(valueClass));\n\t\t\t\tmergedAttributes[key] = [...existingClasses, ...insertClasses].join(\" \");\n\t\t\t} else if (key === \"style\") {\n\t\t\t\tconst styleMap = new Map([...parseStyleEntries(mergedAttributes[key]), ...parseStyleEntries(value)]);\n\t\t\t\tmergedAttributes[key] = Array.from(styleMap.entries()).map(([property, val]) => `${property}: ${val}`).join(\"; \");\n\t\t\t} else mergedAttributes[key] = value;\n\t\t});\n\t\treturn mergedAttributes;\n\t}, {});\n}\n//#endregion\n//#region src/helpers/getRenderedAttributes.ts\nfunction getRenderedAttributes(nodeOrMark, extensionAttributes) {\n\treturn extensionAttributes.filter((attribute) => attribute.type === nodeOrMark.type.name).filter((item) => item.attribute.rendered).map((item) => {\n\t\tif (!item.attribute.renderHTML) return { [item.name]: nodeOrMark.attrs[item.name] };\n\t\treturn item.attribute.renderHTML(nodeOrMark.attrs) || {};\n\t}).reduce((attributes, attribute) => mergeAttributes(attributes, attribute), {});\n}\n//#endregion\n//#region src/utilities/fromString.ts\nfunction fromString(value) {\n\tif (typeof value !== \"string\") return value;\n\tif (value.match(/^[+-]?(?:\\d*\\.)?\\d+$/)) return Number(value);\n\tif (value === \"true\") return true;\n\tif (value === \"false\") return false;\n\treturn value;\n}\n//#endregion\n//#region src/helpers/injectExtensionAttributesToParseRule.ts\n/**\n* This function merges extension attributes into parserule attributes (`attrs` or `getAttrs`).\n* Cancels when `getAttrs` returned `false`.\n* @param parseRule ProseMirror ParseRule\n* @param extensionAttributes List of attributes to inject\n*/\nfunction injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {\n\tif (\"style\" in parseRule) return parseRule;\n\treturn {\n\t\t...parseRule,\n\t\tgetAttrs: (node) => {\n\t\t\tconst oldAttributes = parseRule.getAttrs ? parseRule.getAttrs(node) : parseRule.attrs;\n\t\t\tif (oldAttributes === false) return false;\n\t\t\tconst newAttributes = extensionAttributes.reduce((items, item) => {\n\t\t\t\tconst value = item.attribute.parseHTML ? item.attribute.parseHTML(node) : fromString(node.getAttribute(item.name));\n\t\t\t\tif (value === null || value === void 0) return items;\n\t\t\t\treturn {\n\t\t\t\t\t...items,\n\t\t\t\t\t[item.name]: value\n\t\t\t\t};\n\t\t\t}, {});\n\t\t\treturn {\n\t\t\t\t...oldAttributes,\n\t\t\t\t...newAttributes\n\t\t\t};\n\t\t}\n\t};\n}\n//#endregion\n//#region src/helpers/getSchemaByResolvedExtensions.ts\nfunction cleanUpSchemaItem(data) {\n\treturn Object.fromEntries(Object.entries(data).filter(([key, value]) => {\n\t\tif (key === \"attrs\" && isEmptyObject(value)) return false;\n\t\treturn value !== null && value !== void 0;\n\t}));\n}\n/**\n* Builds an attribute spec tuple for ProseMirror schema from an extension attribute.\n* @param extensionAttribute The extension attribute to build the spec for\n* @returns A tuple of [attributeName, spec]\n*/\nfunction buildAttributeSpec(extensionAttribute) {\n\tvar _extensionAttribute$a, _extensionAttribute$a2;\n\tconst spec = {};\n\tif (!(extensionAttribute === null || extensionAttribute === void 0 || (_extensionAttribute$a = extensionAttribute.attribute) === null || _extensionAttribute$a === void 0 ? void 0 : _extensionAttribute$a.isRequired) && \"default\" in ((extensionAttribute === null || extensionAttribute === void 0 ? void 0 : extensionAttribute.attribute) || {})) spec.default = extensionAttribute.attribute.default;\n\tif ((extensionAttribute === null || extensionAttribute === void 0 || (_extensionAttribute$a2 = extensionAttribute.attribute) === null || _extensionAttribute$a2 === void 0 ? void 0 : _extensionAttribute$a2.validate) !== void 0) spec.validate = extensionAttribute.attribute.validate;\n\treturn [extensionAttribute.name, spec];\n}\n/**\n* Creates a new Prosemirror schema based on the given extensions.\n* @param extensions An array of Tiptap extensions\n* @param editor The editor instance\n* @returns A Prosemirror schema\n*/\nfunction getSchemaByResolvedExtensions(extensions, editor) {\n\tvar _nodeExtensions$find;\n\tconst allAttributes = getAttributesFromExtensions(extensions);\n\tconst { nodeExtensions, markExtensions } = splitExtensions(extensions);\n\tconst topNode = (_nodeExtensions$find = nodeExtensions.find((extension) => getExtensionField(extension, \"topNode\"))) === null || _nodeExtensions$find === void 0 ? void 0 : _nodeExtensions$find.name;\n\tconst nodes = Object.fromEntries(nodeExtensions.map((extension) => {\n\t\tconst extensionAttributes = allAttributes.filter((attribute) => attribute.type === extension.name);\n\t\tconst context = {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage,\n\t\t\teditor\n\t\t};\n\t\tconst schema = cleanUpSchemaItem({\n\t\t\t...extensions.reduce((fields, e) => {\n\t\t\t\tconst extendNodeSchema = getExtensionField(e, \"extendNodeSchema\", context);\n\t\t\t\treturn {\n\t\t\t\t\t...fields,\n\t\t\t\t\t...extendNodeSchema ? extendNodeSchema(extension) : {}\n\t\t\t\t};\n\t\t\t}, {}),\n\t\t\tcontent: callOrReturn(getExtensionField(extension, \"content\", context)),\n\t\t\tmarks: callOrReturn(getExtensionField(extension, \"marks\", context)),\n\t\t\tgroup: callOrReturn(getExtensionField(extension, \"group\", context)),\n\t\t\tinline: callOrReturn(getExtensionField(extension, \"inline\", context)),\n\t\t\tatom: callOrReturn(getExtensionField(extension, \"atom\", context)),\n\t\t\tselectable: callOrReturn(getExtensionField(extension, \"selectable\", context)),\n\t\t\tdraggable: callOrReturn(getExtensionField(extension, \"draggable\", context)),\n\t\t\tcode: callOrReturn(getExtensionField(extension, \"code\", context)),\n\t\t\twhitespace: callOrReturn(getExtensionField(extension, \"whitespace\", context)),\n\t\t\tlinebreakReplacement: callOrReturn(getExtensionField(extension, \"linebreakReplacement\", context)),\n\t\t\tdefining: callOrReturn(getExtensionField(extension, \"defining\", context)),\n\t\t\tisolating: callOrReturn(getExtensionField(extension, \"isolating\", context)),\n\t\t\tattrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec))\n\t\t});\n\t\tconst parseHTML = callOrReturn(getExtensionField(extension, \"parseHTML\", context));\n\t\tif (parseHTML) schema.parseDOM = parseHTML.map((parseRule) => injectExtensionAttributesToParseRule(parseRule, extensionAttributes));\n\t\tconst renderHTML = getExtensionField(extension, \"renderHTML\", context);\n\t\tif (renderHTML) schema.toDOM = (node) => renderHTML({\n\t\t\tnode,\n\t\t\tHTMLAttributes: getRenderedAttributes(node, extensionAttributes)\n\t\t});\n\t\tconst renderText = getExtensionField(extension, \"renderText\", context);\n\t\tif (renderText) schema.toText = renderText;\n\t\treturn [extension.name, schema];\n\t}));\n\tconst marks = Object.fromEntries(markExtensions.map((extension) => {\n\t\tconst extensionAttributes = allAttributes.filter((attribute) => attribute.type === extension.name);\n\t\tconst context = {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage,\n\t\t\teditor\n\t\t};\n\t\tconst schema = cleanUpSchemaItem({\n\t\t\t...extensions.reduce((fields, e) => {\n\t\t\t\tconst extendMarkSchema = getExtensionField(e, \"extendMarkSchema\", context);\n\t\t\t\treturn {\n\t\t\t\t\t...fields,\n\t\t\t\t\t...extendMarkSchema ? extendMarkSchema(extension) : {}\n\t\t\t\t};\n\t\t\t}, {}),\n\t\t\tinclusive: callOrReturn(getExtensionField(extension, \"inclusive\", context)),\n\t\t\texcludes: callOrReturn(getExtensionField(extension, \"excludes\", context)),\n\t\t\tgroup: callOrReturn(getExtensionField(extension, \"group\", context)),\n\t\t\tspanning: callOrReturn(getExtensionField(extension, \"spanning\", context)),\n\t\t\tcode: callOrReturn(getExtensionField(extension, \"code\", context)),\n\t\t\tattrs: Object.fromEntries(extensionAttributes.map(buildAttributeSpec))\n\t\t});\n\t\tconst parseHTML = callOrReturn(getExtensionField(extension, \"parseHTML\", context));\n\t\tif (parseHTML) schema.parseDOM = parseHTML.map((parseRule) => injectExtensionAttributesToParseRule(parseRule, extensionAttributes));\n\t\tconst renderHTML = getExtensionField(extension, \"renderHTML\", context);\n\t\tif (renderHTML) schema.toDOM = (mark) => renderHTML({\n\t\t\tmark,\n\t\t\tHTMLAttributes: getRenderedAttributes(mark, extensionAttributes)\n\t\t});\n\t\treturn [extension.name, schema];\n\t}));\n\treturn new _tiptap_pm_model.Schema({\n\t\ttopNode,\n\t\tnodes,\n\t\tmarks\n\t});\n}\n//#endregion\n//#region src/utilities/findDuplicates.ts\n/**\n* Find duplicates in an array.\n*/\nfunction findDuplicates(items) {\n\tconst filtered = items.filter((el, index) => items.indexOf(el) !== index);\n\treturn Array.from(new Set(filtered));\n}\n//#endregion\n//#region src/helpers/sortExtensions.ts\n/**\n* Sort extensions by priority.\n* @param extensions An array of Tiptap extensions\n* @returns A sorted array of Tiptap extensions by priority\n*/\nfunction sortExtensions(extensions) {\n\tconst defaultPriority = 100;\n\treturn extensions.sort((a, b) => {\n\t\tconst priorityA = getExtensionField(a, \"priority\") || defaultPriority;\n\t\tconst priorityB = getExtensionField(b, \"priority\") || defaultPriority;\n\t\tif (priorityA > priorityB) return -1;\n\t\tif (priorityA < priorityB) return 1;\n\t\treturn 0;\n\t});\n}\n//#endregion\n//#region src/helpers/resolveExtensions.ts\n/**\n* Returns a flattened and sorted extension list while\n* also checking for duplicated extensions and warns the user.\n* @param extensions An array of Tiptap extensions\n* @returns An flattened and sorted array of Tiptap extensions\n*/\nfunction resolveExtensions(extensions) {\n\tconst resolvedExtensions = sortExtensions(flattenExtensions(extensions));\n\tconst duplicatedNames = findDuplicates(resolvedExtensions.map((extension) => extension.name));\n\tif (duplicatedNames.length) console.warn(`[tiptap warn]: Duplicate extension names found: [${duplicatedNames.map((item) => `'${item}'`).join(\", \")}]. This can lead to issues.`);\n\treturn resolvedExtensions;\n}\n//#endregion\n//#region src/helpers/getSchema.ts\nfunction getSchema(extensions, editor) {\n\treturn getSchemaByResolvedExtensions(resolveExtensions(extensions), editor);\n}\n//#endregion\n//#region src/helpers/generateHTML.ts\n/**\n* Generate HTML from a JSONContent\n* @param doc The JSONContent to generate HTML from\n* @param extensions The extensions to use for the schema\n* @returns The generated HTML\n*/\nfunction generateHTML(doc, extensions) {\n\tconst schema = getSchema(extensions);\n\treturn getHTMLFromFragment(_tiptap_pm_model.Node.fromJSON(schema, doc).content, schema);\n}\n//#endregion\n//#region src/helpers/generateJSON.ts\n/**\n* Generate JSONContent from HTML\n* @param html The HTML to generate JSONContent from\n* @param extensions The extensions to use for the schema\n* @returns The generated JSONContent\n*/\nfunction generateJSON(html, extensions) {\n\tconst schema = getSchema(extensions);\n\tconst dom = elementFromString(html);\n\treturn _tiptap_pm_model.DOMParser.fromSchema(schema).parse(dom).toJSON();\n}\n//#endregion\n//#region src/helpers/getTextBetween.ts\n/**\n* Gets the text between two positions in a Prosemirror node\n* and serializes it using the given text serializers and block separator (see getText)\n* @param startNode The Prosemirror node to start from\n* @param range The range of the text to get\n* @param options Options for the text serializer & block separator\n* @returns The text between the two positions\n*/\nfunction getTextBetween(startNode, range, options) {\n\tconst { from, to } = range;\n\tconst { blockSeparator = \"\\n\\n\", textSerializers = {} } = options || {};\n\tlet text = \"\";\n\tstartNode.nodesBetween(from, to, (node, pos, parent, index) => {\n\t\tif (node.isBlock && pos > from) text += blockSeparator;\n\t\tconst textSerializer = textSerializers === null || textSerializers === void 0 ? void 0 : textSerializers[node.type.name];\n\t\tif (textSerializer) {\n\t\t\tif (parent) text += textSerializer({\n\t\t\t\tnode,\n\t\t\t\tpos,\n\t\t\t\tparent,\n\t\t\t\tindex,\n\t\t\t\trange\n\t\t\t});\n\t\t\treturn false;\n\t\t}\n\t\tif (node.isText) {\n\t\t\tvar _node$text;\n\t\t\ttext += node === null || node === void 0 || (_node$text = node.text) === null || _node$text === void 0 ? void 0 : _node$text.slice(Math.max(from, pos) - pos, to - pos);\n\t\t}\n\t});\n\treturn text;\n}\n//#endregion\n//#region src/helpers/getText.ts\n/**\n* Gets the text of a Prosemirror node\n* @param node The Prosemirror node\n* @param options Options for the text serializer & block separator\n* @returns The text of the node\n* @example ```js\n* const text = getText(node, { blockSeparator: '\\n' })\n* ```\n*/\nfunction getText(node, options) {\n\treturn getTextBetween(node, {\n\t\tfrom: 0,\n\t\tto: node.content.size\n\t}, options);\n}\n//#endregion\n//#region src/helpers/getTextSerializersFromSchema.ts\n/**\n* Find text serializers `toText` in a Prosemirror schema\n* @param schema The Prosemirror schema to search in\n* @returns A record of text serializers by node name\n*/\nfunction getTextSerializersFromSchema(schema) {\n\treturn Object.fromEntries(Object.entries(schema.nodes).filter(([, node]) => node.spec.toText).map(([name, node]) => [name, node.spec.toText]));\n}\n//#endregion\n//#region src/helpers/generateText.ts\n/**\n* Generate raw text from a JSONContent\n* @param doc The JSONContent to generate text from\n* @param extensions The extensions to use for the schema\n* @param options Options for the text generation f.e. blockSeparator or textSerializers\n* @returns The generated text\n*/\nfunction generateText(doc, extensions, options) {\n\tconst { blockSeparator = \"\\n\\n\", textSerializers = {} } = options || {};\n\tconst schema = getSchema(extensions);\n\treturn getText(_tiptap_pm_model.Node.fromJSON(schema, doc), {\n\t\tblockSeparator,\n\t\ttextSerializers: {\n\t\t\t...getTextSerializersFromSchema(schema),\n\t\t\t...textSerializers\n\t\t}\n\t});\n}\n//#endregion\n//#region src/helpers/getNodeAttributes.ts\nfunction getNodeAttributes(state, typeOrName) {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tconst { from, to } = state.selection;\n\tconst nodes = [];\n\tstate.doc.nodesBetween(from, to, (node) => {\n\t\tnodes.push(node);\n\t});\n\tconst node = nodes.reverse().find((nodeItem) => nodeItem.type.name === type.name);\n\tif (!node) return {};\n\treturn { ...node.attrs };\n}\n//#endregion\n//#region src/helpers/getAttributes.ts\n/**\n* Get node or mark attributes by type or name on the current editor state\n* @param state The current editor state\n* @param typeOrName The node or mark type or name\n* @returns The attributes of the node or mark or an empty object\n*/\nfunction getAttributes(state, typeOrName) {\n\tconst schemaType = getSchemaTypeNameByName(typeof typeOrName === \"string\" ? typeOrName : typeOrName.name, state.schema);\n\tif (schemaType === \"node\") return getNodeAttributes(state, typeOrName);\n\tif (schemaType === \"mark\") return getMarkAttributes(state, typeOrName);\n\treturn {};\n}\n//#endregion\n//#region src/utilities/removeDuplicates.ts\n/**\n* Removes duplicated values within an array.\n* Supports numbers, strings and objects.\n*/\nfunction removeDuplicates(array, by = JSON.stringify) {\n\tconst seen = {};\n\treturn array.filter((item) => {\n\t\tconst key = by(item);\n\t\treturn Object.prototype.hasOwnProperty.call(seen, key) ? false : seen[key] = true;\n\t});\n}\n//#endregion\n//#region src/helpers/getChangedRanges.ts\n/**\n* Removes duplicated ranges and ranges that are\n* fully captured by other ranges.\n*/\nfunction simplifyChangedRanges(changes) {\n\tconst uniqueChanges = removeDuplicates(changes);\n\treturn uniqueChanges.length === 1 ? uniqueChanges : uniqueChanges.filter((change, index) => {\n\t\treturn !uniqueChanges.filter((_, i) => i !== index).some((otherChange) => {\n\t\t\treturn change.oldRange.from >= otherChange.oldRange.from && change.oldRange.to <= otherChange.oldRange.to && change.newRange.from >= otherChange.newRange.from && change.newRange.to <= otherChange.newRange.to;\n\t\t});\n\t});\n}\n/**\n* Returns a list of changed ranges\n* based on the first and last state of all steps.\n*/\nfunction getChangedRanges(transform) {\n\tconst { mapping, steps } = transform;\n\tconst changes = [];\n\tmapping.maps.forEach((stepMap, index) => {\n\t\tconst ranges = [];\n\t\tif (!stepMap.ranges.length) {\n\t\t\tconst { from, to } = steps[index];\n\t\t\tif (from === void 0 || to === void 0) return;\n\t\t\tranges.push({\n\t\t\t\tfrom,\n\t\t\t\tto\n\t\t\t});\n\t\t} else stepMap.forEach((from, to) => {\n\t\t\tranges.push({\n\t\t\t\tfrom,\n\t\t\t\tto\n\t\t\t});\n\t\t});\n\t\tranges.forEach(({ from, to }) => {\n\t\t\tconst newStart = mapping.slice(index).map(from, -1);\n\t\t\tconst newEnd = mapping.slice(index).map(to);\n\t\t\tconst oldStart = mapping.invert().map(newStart, -1);\n\t\t\tconst oldEnd = mapping.invert().map(newEnd);\n\t\t\tchanges.push({\n\t\t\t\toldRange: {\n\t\t\t\t\tfrom: oldStart,\n\t\t\t\t\tto: oldEnd\n\t\t\t\t},\n\t\t\t\tnewRange: {\n\t\t\t\t\tfrom: newStart,\n\t\t\t\t\tto: newEnd\n\t\t\t\t}\n\t\t\t});\n\t\t});\n\t});\n\treturn simplifyChangedRanges(changes);\n}\n//#endregion\n//#region src/helpers/getDebugJSON.ts\nfunction getDebugJSON(node, startOffset = 0) {\n\tconst increment = node.type === node.type.schema.topNodeType ? 0 : 1;\n\tconst from = startOffset;\n\tconst to = from + node.nodeSize;\n\tconst marks = node.marks.map((mark) => {\n\t\tconst output = { type: mark.type.name };\n\t\tif (Object.keys(mark.attrs).length) output.attrs = { ...mark.attrs };\n\t\treturn output;\n\t});\n\tconst attrs = { ...node.attrs };\n\tconst output = {\n\t\ttype: node.type.name,\n\t\tfrom,\n\t\tto\n\t};\n\tif (Object.keys(attrs).length) output.attrs = attrs;\n\tif (marks.length) output.marks = marks;\n\tif (node.content.childCount) {\n\t\toutput.content = [];\n\t\tnode.forEach((child, offset) => {\n\t\t\tvar _output$content;\n\t\t\t(_output$content = output.content) === null || _output$content === void 0 || _output$content.push(getDebugJSON(child, startOffset + offset + increment));\n\t\t});\n\t}\n\tif (node.text) output.text = node.text;\n\treturn output;\n}\n//#endregion\n//#region src/helpers/getMarksBetween.ts\nfunction getMarksBetween(from, to, doc) {\n\tconst marks = [];\n\tif (from === to) doc.resolve(from).marks().forEach((mark) => {\n\t\tconst range = getMarkRange(doc.resolve(from), mark.type);\n\t\tif (!range) return;\n\t\tmarks.push({\n\t\t\tmark,\n\t\t\t...range\n\t\t});\n\t});\n\telse doc.nodesBetween(from, to, (node, pos) => {\n\t\tif (!node || (node === null || node === void 0 ? void 0 : node.nodeSize) === void 0) return;\n\t\tmarks.push(...node.marks.map((mark) => ({\n\t\t\tfrom: pos,\n\t\t\tto: pos + node.nodeSize,\n\t\t\tmark\n\t\t})));\n\t});\n\treturn marks;\n}\n//#endregion\n//#region src/helpers/getNodeAtPosition.ts\n/**\n* Finds the first node of a given type or name in the current selection.\n* @param state The editor state.\n* @param typeOrName The node type or name.\n* @param pos The position to start searching from.\n* @param maxDepth The maximum depth to search.\n* @returns The node and the depth as an array.\n*/\nconst getNodeAtPosition = (state, typeOrName, pos, maxDepth = 20) => {\n\tconst $pos = state.doc.resolve(pos);\n\tlet currentDepth = maxDepth;\n\tlet node = null;\n\twhile (currentDepth > 0 && node === null) {\n\t\tconst currentNode = $pos.node(currentDepth);\n\t\tif ((currentNode === null || currentNode === void 0 ? void 0 : currentNode.type.name) === typeOrName) node = currentNode;\n\t\telse currentDepth -= 1;\n\t}\n\treturn [node, currentDepth];\n};\n//#endregion\n//#region src/helpers/getPreviousBlockSibling.ts\n/**\n* Returns the block-level sibling immediately before the cursor's textblock\n* (or null when the cursor is at the first child of its block parent).\n*\n* The position does not have to sit inside a textblock: for any resolved\n* position, the result is the sibling immediately before `$pos.parent`. At a\n* GapCursor position this is the sibling before the whole container, not the\n* node before the gap.\n*\n* @param $pos The resolved position to look around\n* @returns The previous block-level sibling, or null\n* @example ```js\n* // Cursor in a top-level paragraph after a list:\n* // <ul><li>A</li></ul><p>|B</p>\n* getPreviousBlockSibling($from) // <ul>\n*\n* // Cursor in the second paragraph of a list item:\n* // <ul><li><p>A</p><p>|B</p></li></ul>\n* getPreviousBlockSibling($from) // <p>A</p>\n*\n* // Cursor in the first child of its block parent:\n* // <doc><p>|A</p></doc>\n* getPreviousBlockSibling($from) // null\n* ```\n*/\nconst getPreviousBlockSibling = ($pos) => {\n\tconst parentDepth = $pos.depth - 1;\n\tif (parentDepth < 0) return null;\n\tconst index = $pos.index(parentDepth);\n\tif (index === 0) return null;\n\treturn $pos.node(parentDepth).child(index - 1);\n};\n//#endregion\n//#region src/helpers/getSchemaTypeByName.ts\n/**\n* Tries to get a node or mark type by its name.\n* @param name The name of the node or mark type\n* @param schema The Prosemiror schema to search in\n* @returns The node or mark type, or null if it doesn't exist\n*/\nfunction getSchemaTypeByName(name, schema) {\n\treturn schema.nodes[name] || schema.marks[name] || null;\n}\n//#endregion\n//#region src/helpers/getSplittedAttributes.ts\n/**\n* Return attributes of an extension that should be splitted by keepOnSplit flag\n* @param extensionAttributes Array of extension attributes\n* @param typeName The type of the extension\n* @param attributes The attributes of the extension\n* @returns The splitted attributes\n*/\nfunction getSplittedAttributes(extensionAttributes, typeName, attributes) {\n\treturn Object.fromEntries(Object.entries(attributes).filter(([name]) => {\n\t\tconst extensionAttribute = extensionAttributes.find((item) => {\n\t\t\treturn item.type === typeName && item.name === name;\n\t\t});\n\t\tif (!extensionAttribute) return false;\n\t\treturn extensionAttribute.attribute.keepOnSplit;\n\t}));\n}\n//#endregion\n//#region src/helpers/getTextContentFromNodes.ts\n/**\n* Returns the text content of a resolved prosemirror position\n* @param $from The resolved position to get the text content from\n* @param maxMatch The maximum number of characters to match\n* @returns The text content\n*/\nconst getTextContentFromNodes = ($from, maxMatch = 500) => {\n\tlet textBefore = \"\";\n\tconst sliceEndPos = $from.parentOffset;\n\t$from.parent.nodesBetween(Math.max(0, sliceEndPos - maxMatch), sliceEndPos, (node, pos, parent, index) => {\n\t\tvar _node$type$spec$toTex, _node$type$spec;\n\t\tconst chunk = ((_node$type$spec$toTex = (_node$type$spec = node.type.spec).toText) === null || _node$type$spec$toTex === void 0 ? void 0 : _node$type$spec$toTex.call(_node$type$spec, {\n\t\t\tnode,\n\t\t\tpos,\n\t\t\tparent,\n\t\t\tindex\n\t\t})) || node.textContent || \"%leaf%\";\n\t\ttextBefore += node.isAtom && !node.isText ? chunk : chunk.slice(0, Math.max(0, sliceEndPos - pos));\n\t});\n\treturn textBefore;\n};\n//#endregion\n//#region src/helpers/isMarkActive.ts\nfunction isMarkActive(state, typeOrName, attributes = {}) {\n\tconst { empty, ranges } = state.selection;\n\tconst type = typeOrName ? getMarkType(typeOrName, state.schema) : null;\n\tif (empty) return !!(state.storedMarks || state.selection.$from.marks()).filter((mark) => {\n\t\tif (!type) return true;\n\t\treturn type.name === mark.type.name;\n\t}).find((mark) => objectIncludes(mark.attrs, attributes, { strict: false }));\n\tlet selectionRange = 0;\n\tconst markRanges = [];\n\tranges.forEach(({ $from, $to }) => {\n\t\tconst from = $from.pos;\n\t\tconst to = $to.pos;\n\t\tstate.doc.nodesBetween(from, to, (node, pos) => {\n\t\t\tif (type && node.inlineContent && !node.type.allowsMarkType(type)) return false;\n\t\t\tif (!node.isText && !node.marks.length) return;\n\t\t\tconst relativeFrom = Math.max(from, pos);\n\t\t\tconst relativeTo = Math.min(to, pos + node.nodeSize);\n\t\t\tconst range = relativeTo - relativeFrom;\n\t\t\tselectionRange += range;\n\t\t\tmarkRanges.push(...node.marks.map((mark) => ({\n\t\t\t\tmark,\n\t\t\t\tfrom: relativeFrom,\n\t\t\t\tto: relativeTo\n\t\t\t})));\n\t\t});\n\t});\n\tif (selectionRange === 0) return false;\n\tconst matchedRange = markRanges.filter((markRange) => {\n\t\tif (!type) return true;\n\t\treturn type.name === markRange.mark.type.name;\n\t}).filter((markRange) => objectIncludes(markRange.mark.attrs, attributes, { strict: false })).reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);\n\tconst excludedRange = markRanges.filter((markRange) => {\n\t\tif (!type) return true;\n\t\treturn markRange.mark.type !== type && markRange.mark.type.excludes(type);\n\t}).reduce((sum, markRange) => sum + markRange.to - markRange.from, 0);\n\treturn (matchedRange > 0 ? matchedRange + excludedRange : matchedRange) >= selectionRange;\n}\n//#endregion\n//#region src/helpers/isActive.ts\nfunction isActive(state, name, attributes = {}) {\n\tif (!name) return isNodeActive(state, null, attributes) || isMarkActive(state, null, attributes);\n\tconst schemaType = getSchemaTypeNameByName(name, state.schema);\n\tif (schemaType === \"node\") return isNodeActive(state, name, attributes);\n\tif (schemaType === \"mark\") return isMarkActive(state, name, attributes);\n\treturn false;\n}\n//#endregion\n//#region src/helpers/isAtEndOfNode.ts\nconst isAtEndOfNode = (state, nodeType) => {\n\tconst { $from, $to, $anchor } = state.selection;\n\tif (nodeType) {\n\t\tconst parentNode = findParentNode((node) => node.type.name === nodeType)(state.selection);\n\t\tif (!parentNode) return false;\n\t\tconst $parentPos = state.doc.resolve(parentNode.pos + 1);\n\t\tif ($anchor.pos + 1 === $parentPos.end()) return true;\n\t\treturn false;\n\t}\n\tif ($to.parentOffset < $to.parent.nodeSize - 2 || $from.pos !== $to.pos) return false;\n\treturn true;\n};\n//#endregion\n//#region src/helpers/isAtStartOfNode.ts\nconst isAtStartOfNode = (state) => {\n\tconst { $from, $to } = state.selection;\n\tif ($from.parentOffset > 0 || $from.pos !== $to.pos) return false;\n\treturn true;\n};\n//#endregion\n//#region src/helpers/isExtensionRulesEnabled.ts\nfunction isExtensionRulesEnabled(extension, enabled) {\n\tif (Array.isArray(enabled)) return enabled.some((enabledExtension) => {\n\t\treturn (typeof enabledExtension === \"string\" ? enabledExtension : enabledExtension.name) === extension.name;\n\t});\n\treturn enabled;\n}\n//#endregion\n//#region src/helpers/isList.ts\nfunction isList(name, extensions) {\n\tconst { nodeExtensions } = splitExtensions(extensions);\n\tconst extension = nodeExtensions.find((item) => item.name === name);\n\tif (!extension) return false;\n\tconst group = callOrReturn(getExtensionField(extension, \"group\", {\n\t\tname: extension.name,\n\t\toptions: extension.options,\n\t\tstorage: extension.storage\n\t}));\n\tif (typeof group !== \"string\") return false;\n\treturn group.split(\" \").includes(\"list\");\n}\n//#endregion\n//#region src/helpers/isNodeEmpty.ts\n/**\n* Returns true if the given prosemirror node is empty.\n*/\nfunction isNodeEmpty(node, { checkChildren = true, ignoreWhitespace = false } = {}) {\n\tif (ignoreWhitespace) {\n\t\tif (node.type.name === \"hardBreak\") return true;\n\t\tif (node.isText) {\n\t\t\tvar _node$text;\n\t\t\treturn !/\\S/.test((_node$text = node.text) !== null && _node$text !== void 0 ? _node$text : \"\");\n\t\t}\n\t}\n\tif (node.isText) return !node.text;\n\tif (node.isAtom || node.isLeaf) return false;\n\tif (node.content.childCount === 0) return true;\n\tif (checkChildren) {\n\t\tlet isContentEmpty = true;\n\t\tnode.content.forEach((childNode) => {\n\t\t\tif (isContentEmpty === false) return;\n\t\t\tif (!isNodeEmpty(childNode, {\n\t\t\t\tignoreWhitespace,\n\t\t\t\tcheckChildren\n\t\t\t})) isContentEmpty = false;\n\t\t});\n\t\treturn isContentEmpty;\n\t}\n\treturn false;\n}\n//#endregion\n//#region src/helpers/isNodeSelection.ts\nfunction isNodeSelection(value) {\n\treturn value instanceof _tiptap_pm_state.NodeSelection;\n}\n//#endregion\n//#region src/helpers/isNodeViewSelected.ts\n/**\n* Determines whether a node view should be considered selected for the given\n* editor selection.\n*\n* A node is considered selected when the current selection fully covers it\n* (e.g. a `NodeSelection`). When `selectedOnTextSelection` is enabled, the\n* node is additionally considered selected if a `TextSelection` is fully\n* contained within the node's range.\n*\n* @param selection The current editor selection.\n* @param pos The start position of the node in the document.\n* @param nodeSize The size of the node.\n* @param selectedOnTextSelection When `true`, also treat selections inside the node as selected.\n* @returns `true` if the node view should render as selected.\n*/\nfunction isNodeViewSelected({ selection, pos, nodeSize, selectedOnTextSelection = false }) {\n\tconst { from, to } = selection;\n\tif (from <= pos && to >= pos + nodeSize) return true;\n\tif (selectedOnTextSelection && isTextSelection(selection) && from > pos && to < pos + nodeSize) return true;\n\treturn false;\n}\n//#endregion\n//#region src/helpers/isProseMirrorStep.ts\n/**\n* Checks if a value is a ProseMirror step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror Step\n* @example ```js\n* isProseMirrorStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (typeof step.apply !== \"function\" || typeof step.getMap !== \"function\" || typeof step.invert !== \"function\" || typeof step.map !== \"function\" || typeof step.merge !== \"function\" || typeof step.toJSON !== \"function\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorAddMarkStep.ts\n/**\n* Checks if a value is a ProseMirror add mark step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror AddMarkStep\n* @example ```js\n* isProseMirrorAddMarkStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorAddMarkStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"addMark\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorAddNodeMarkStep.ts\n/**\n* Checks if a value is a ProseMirror add node mark step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror AddNodeMarkStep\n* @example ```js\n* isProseMirrorAddNodeMarkStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorAddNodeMarkStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"addNodeMark\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorAttrStep.ts\n/**\n* Checks if a value is a ProseMirror attribute step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror AttrStep\n* @example ```js\n* isProseMirrorAttrStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorAttrStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"attr\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorCellSelection.ts\n/**\n* Check whether a selection provides the cell-iteration API.\n*\n* @param selection - Selection to inspect.\n* @returns Whether the selection is a table cell selection.\n* @example ```js\n* isProseMirrorCellSelection(editor.state.selection)\n* ```\n*/\nfunction isProseMirrorCellSelection(selection) {\n\tif (selection === null || typeof selection !== \"object\") return false;\n\treturn \"forEachCell\" in selection && typeof selection.forEachCell === \"function\";\n}\n//#endregion\n//#region src/helpers/isProseMirrorDocAttrStep.ts\n/**\n* Checks if a value is a ProseMirror document attribute step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror DocAttrStep\n* @example ```js\n* isProseMirrorDocAttrStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorDocAttrStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"docAttr\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorFragment.ts\n/**\n* Checks if a value is a ProseMirror fragment by inspecting it\n* @param value The value to check\n* @returns - A boolean, if true the value is a ProseMirror fragment\n* @example ```js\n* isProseMirrorFragment(editor.state.doc.content)\n* ```\n*/\nfunction isProseMirrorFragment(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst fragment = value;\n\tif (!Array.isArray(fragment.content) || typeof fragment.size !== \"number\" || typeof fragment.nodesBetween !== \"function\" || typeof fragment.descendants !== \"function\" || typeof fragment.textBetween !== \"function\" || typeof fragment.append !== \"function\" || typeof fragment.cut !== \"function\" || typeof fragment.eq !== \"function\" || typeof fragment.child !== \"function\" || typeof fragment.forEach !== \"function\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorNodeSelection.ts\n/**\n* Check whether a selection exposes a selected node.\n*\n* @param selection - Selection to inspect.\n* @returns Whether the selection is a node selection.\n* @example ```js\n* isProseMirrorNodeSelection(editor.state.selection)\n* ```\n*/\nfunction isProseMirrorNodeSelection(selection) {\n\tif (selection === null || typeof selection !== \"object\") return false;\n\treturn \"node\" in selection && selection.node != null;\n}\n//#endregion\n//#region src/helpers/isProseMirrorRemoveMarkStep.ts\n/**\n* Checks if a value is a ProseMirror remove mark step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror RemoveMarkStep\n* @example ```js\n* isProseMirrorRemoveMarkStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorRemoveMarkStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"removeMark\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorRemoveNodeMarkStep.ts\n/**\n* Checks if a value is a ProseMirror remove node mark step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror RemoveNodeMarkStep\n* @example ```js\n* isProseMirrorRemoveNodeMarkStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorRemoveNodeMarkStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"removeNodeMark\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorReplaceAroundStep.ts\n/**\n* Checks if a value is a ProseMirror replace around step\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror ReplaceAroundStep\n* @example ```js\n* isProseMirrorReplaceAroundStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorReplaceAroundStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"replaceAround\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorReplaceStep.ts\n/**\n* Checks if a value is a ProseMirror replace step result\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror ReplaceStep\n* @example ```js\n* isProseMirrorReplaceStep(transaction.steps[0])\n* ```\n*/\nfunction isProseMirrorReplaceStep(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst step = value;\n\tif (!isProseMirrorStep(step)) return false;\n\tconst json = step.toJSON();\n\tif (json === null || typeof json !== \"object\" || json.stepType !== \"replace\") return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorSlice.ts\n/**\n* Checks if a value is a ProseMirror slice by inspecting it\n* @param value The value to check\n* @returns - A boolean, if true the value is a ProseMirror slice\n* @example ```js\n* isProseMirrorSlice(editor.state.doc.content.slice(0, 10))\n* ```\n*/\nfunction isProseMirrorSlice(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst slice = value;\n\tconst openStartIsNumber = Number.isInteger(slice.openStart) && slice.openStart >= 0;\n\tconst openEndIsNumber = Number.isInteger(slice.openEnd) && slice.openEnd >= 0;\n\tconst sliceHasRequiredProperties = typeof slice.size === \"number\" && typeof slice.eq === \"function\" && typeof slice.toJSON === \"function\";\n\tif (!openStartIsNumber || !openEndIsNumber || !sliceHasRequiredProperties) return false;\n\tconst content = slice.content;\n\tif (content === null || typeof content !== \"object\") return false;\n\tif (!isProseMirrorFragment(content)) return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/isProseMirrorStepResult.ts\n/**\n* Checks if a value is a ProseMirror step result\n* @param value The value to check\n* @returns - A boolean, if the boolean is true the value is a ProseMirror StepResult\n* @example ```js\n* isProseMirrorStepResult(step.apply(editor.state.doc))\n* ```\n*/\nfunction isProseMirrorStepResult(value) {\n\tif (value === null || typeof value !== \"object\") return false;\n\tconst result = value;\n\tconst isValidDoc = result.doc !== null && typeof result.doc === \"object\" && result.failed === null;\n\tconst isValidFailed = typeof result.failed === \"string\" && result.doc === null;\n\tif (!isValidDoc && !isValidFailed) return false;\n\treturn true;\n}\n//#endregion\n//#region src/helpers/MappablePosition.ts\n/**\n* A class that represents a mappable position in the editor. It can be extended\n* by other extensions to add additional position mapping capabilities.\n*/\nvar MappablePosition = class MappablePosition {\n\tconstructor(position) {\n\t\tthis.position = position;\n\t}\n\t/**\n\t* Creates a MappablePosition from a JSON object.\n\t*/\n\tstatic fromJSON(json) {\n\t\treturn new MappablePosition(json.position);\n\t}\n\t/**\n\t* Converts the MappablePosition to a JSON object.\n\t*/\n\ttoJSON() {\n\t\treturn { position: this.position };\n\t}\n};\n/**\n* Calculates the new position after applying a transaction.\n*\n* @returns The new mappable position and the map result.\n*/\nfunction getUpdatedPosition(position, transaction) {\n\tconst mapResult = transaction.mapping.mapResult(position.position);\n\treturn {\n\t\tposition: new MappablePosition(mapResult.pos),\n\t\tmapResult\n\t};\n}\n/**\n* Creates a MappablePosition from a position number. This is the default\n* implementation for Tiptap core. It can be overridden by other Tiptap\n* extensions.\n*\n* @param position The position (as a number) where the MappablePosition will be created.\n* @returns A new MappablePosition instance at the given position.\n*/\nfunction createMappablePosition(position) {\n\treturn new MappablePosition(position);\n}\n//#endregion\n//#region src/helpers/posToDOMRect.ts\nfunction posToDOMRect(view, from, to) {\n\tconst minPos = 0;\n\tconst maxPos = view.state.doc.content.size;\n\tconst resolvedFrom = minMax(from, minPos, maxPos);\n\tconst resolvedEnd = minMax(to, minPos, maxPos);\n\tconst start = view.coordsAtPos(resolvedFrom);\n\tconst end = view.coordsAtPos(resolvedEnd, -1);\n\tconst top = Math.min(start.top, end.top);\n\tconst bottom = Math.max(start.bottom, end.bottom);\n\tconst left = Math.min(start.left, end.left);\n\tconst right = Math.max(start.right, end.right);\n\tconst data = {\n\t\ttop,\n\t\tbottom,\n\t\tleft,\n\t\tright,\n\t\twidth: right - left,\n\t\theight: bottom - top,\n\t\tx: left,\n\t\ty: top\n\t};\n\treturn {\n\t\t...data,\n\t\ttoJSON: () => data\n\t};\n}\n//#endregion\n//#region src/helpers/rewriteUnknownContent.ts\n/**\n* The actual implementation of the rewriteUnknownContent function\n*/\nfunction rewriteUnknownContentInner({ json, validMarks, validNodes, options, rewrittenContent = [] }) {\n\tif (json.marks && Array.isArray(json.marks)) json.marks = json.marks.filter((mark) => {\n\t\tif (mark === null || mark === void 0) return false;\n\t\tconst name = typeof mark === \"string\" ? mark : mark.type;\n\t\tif (validMarks.has(name)) return true;\n\t\trewrittenContent.push({\n\t\t\toriginal: JSON.parse(JSON.stringify(mark)),\n\t\t\tunsupported: name\n\t\t});\n\t\treturn false;\n\t});\n\tif (json.content && Array.isArray(json.content)) json.content = json.content.map((value) => {\n\t\tif (value === null || value === void 0) return null;\n\t\treturn rewriteUnknownContentInner({\n\t\t\tjson: value,\n\t\t\tvalidMarks,\n\t\t\tvalidNodes,\n\t\t\toptions,\n\t\t\trewrittenContent\n\t\t}).json;\n\t}).filter((a) => a !== null && a !== void 0);\n\tif (json.type && !validNodes.has(json.type)) {\n\t\trewrittenContent.push({\n\t\t\toriginal: JSON.parse(JSON.stringify(json)),\n\t\t\tunsupported: json.type\n\t\t});\n\t\tif (json.content && Array.isArray(json.content) && (options === null || options === void 0 ? void 0 : options.fallbackToParagraph) !== false) {\n\t\t\tjson.type = \"paragraph\";\n\t\t\treturn {\n\t\t\t\tjson,\n\t\t\t\trewrittenContent\n\t\t\t};\n\t\t}\n\t\treturn {\n\t\t\tjson: null,\n\t\t\trewrittenContent\n\t\t};\n\t}\n\treturn {\n\t\tjson,\n\t\trewrittenContent\n\t};\n}\n/**\n* Rewrite unknown nodes and marks within JSON content\n* Allowing for user within the editor\n*/\nfunction rewriteUnknownContent(json, schema, options) {\n\treturn rewriteUnknownContentInner({\n\t\tjson,\n\t\tvalidNodes: new Set(Object.keys(schema.nodes)),\n\t\tvalidMarks: new Set(Object.keys(schema.marks)),\n\t\toptions\n\t});\n}\n//#endregion\n//#region src/commands/setMark.ts\nfunction canSetMark(state, tr, newMarkType) {\n\tconst { selection } = tr;\n\tlet cursor = null;\n\tif (isTextSelection(selection)) cursor = selection.$cursor;\n\tif (cursor) {\n\t\tvar _state$storedMarks;\n\t\tconst currentMarks = (_state$storedMarks = state.storedMarks) !== null && _state$storedMarks !== void 0 ? _state$storedMarks : cursor.marks();\n\t\treturn cursor.parent.type.allowsMarkType(newMarkType) && (!!newMarkType.isInSet(currentMarks) || !currentMarks.some((mark) => mark.type.excludes(newMarkType)));\n\t}\n\tconst { ranges } = selection;\n\treturn ranges.some(({ $from, $to }) => {\n\t\tlet someNodeSupportsMark = $from.depth === 0 ? state.doc.inlineContent && state.doc.type.allowsMarkType(newMarkType) : false;\n\t\tstate.doc.nodesBetween($from.pos, $to.pos, (node, _pos, parent) => {\n\t\t\tif (someNodeSupportsMark) return false;\n\t\t\tif (node.isInline) {\n\t\t\t\tconst parentAllowsMarkType = !parent || parent.type.allowsMarkType(newMarkType);\n\t\t\t\tconst currentMarksAllowMarkType = !!newMarkType.isInSet(node.marks) || !node.marks.some((otherMark) => otherMark.type.excludes(newMarkType));\n\t\t\t\tsomeNodeSupportsMark = parentAllowsMarkType && currentMarksAllowMarkType;\n\t\t\t}\n\t\t\treturn !someNodeSupportsMark;\n\t\t});\n\t\treturn someNodeSupportsMark;\n\t});\n}\nconst setMark = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\n\tconst { selection } = tr;\n\tconst { empty, ranges } = selection;\n\tconst type = getMarkType(typeOrName, state.schema);\n\tif (dispatch) {\n\t\tif (empty) {\n\t\t\tconst oldAttributes = getMarkAttributes(state, type);\n\t\t\ttr.addStoredMark(type.create({\n\t\t\t\t...oldAttributes,\n\t\t\t\t...attributes\n\t\t\t}));\n\t\t} else ranges.forEach((range) => {\n\t\t\tconst from = range.$from.pos;\n\t\t\tconst to = range.$to.pos;\n\t\t\tstate.doc.nodesBetween(from, to, (node, pos) => {\n\t\t\t\tconst trimmedFrom = Math.max(pos, from);\n\t\t\t\tconst trimmedTo = Math.min(pos + node.nodeSize, to);\n\t\t\t\tif (node.marks.find((mark) => mark.type === type)) node.marks.forEach((mark) => {\n\t\t\t\t\tif (type === mark.type) tr.addMark(trimmedFrom, trimmedTo, type.create({\n\t\t\t\t\t\t...mark.attrs,\n\t\t\t\t\t\t...attributes\n\t\t\t\t\t}));\n\t\t\t\t});\n\t\t\t\telse tr.addMark(trimmedFrom, trimmedTo, type.create(attributes));\n\t\t\t});\n\t\t});\n\t}\n\treturn canSetMark(state, tr, type);\n};\n//#endregion\n//#region src/commands/setMeta.ts\nconst setMeta = (key, value) => ({ tr }) => {\n\ttr.setMeta(key, value);\n\treturn true;\n};\n//#endregion\n//#region src/commands/setNode.ts\nconst setNode = (typeOrName, attributes = {}) => ({ state, dispatch, chain }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tlet attributesToCopy;\n\tif (state.selection.$anchor.sameParent(state.selection.$head)) attributesToCopy = state.selection.$anchor.parent.attrs;\n\tif (!type.isTextblock) {\n\t\tconsole.warn(\"[tiptap warn]: Currently \\\"setNode()\\\" only supports text block nodes.\");\n\t\treturn false;\n\t}\n\treturn chain().command(({ commands }) => {\n\t\tif ((0, _tiptap_pm_commands.setBlockType)(type, {\n\t\t\t...attributesToCopy,\n\t\t\t...attributes\n\t\t})(state)) return true;\n\t\treturn commands.clearNodes();\n\t}).command(({ state: updatedState }) => {\n\t\treturn (0, _tiptap_pm_commands.setBlockType)(type, {\n\t\t\t...attributesToCopy,\n\t\t\t...attributes\n\t\t})(updatedState, dispatch);\n\t}).run();\n};\n//#endregion\n//#region src/commands/setNodeSelection.ts\nconst setNodeSelection = (position) => ({ tr, dispatch }) => {\n\tif (dispatch) {\n\t\tconst { doc } = tr;\n\t\tconst from = minMax(position, 0, doc.content.size);\n\t\tconst selection = _tiptap_pm_state.NodeSelection.create(doc, from);\n\t\ttr.setSelection(selection);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/setTextDirection.ts\nconst setTextDirection = (direction, position) => ({ tr, state, dispatch }) => {\n\tconst { selection } = state;\n\tlet from;\n\tlet to;\n\tif (typeof position === \"number\") {\n\t\tfrom = position;\n\t\tto = position;\n\t} else if (position && \"from\" in position && \"to\" in position) {\n\t\tfrom = position.from;\n\t\tto = position.to;\n\t} else {\n\t\tfrom = selection.from;\n\t\tto = selection.to;\n\t}\n\tif (dispatch) tr.doc.nodesBetween(from, to, (node, pos) => {\n\t\tif (node.isText) return;\n\t\ttr.setNodeMarkup(pos, void 0, {\n\t\t\t...node.attrs,\n\t\t\tdir: direction\n\t\t});\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/commands/setTextSelection.ts\nconst setTextSelection = (position) => ({ tr, dispatch }) => {\n\tif (dispatch) {\n\t\tconst { doc } = tr;\n\t\tconst { from, to } = typeof position === \"number\" ? {\n\t\t\tfrom: position,\n\t\t\tto: position\n\t\t} : position;\n\t\tconst minPos = _tiptap_pm_state.TextSelection.atStart(doc).from;\n\t\tconst maxPos = _tiptap_pm_state.TextSelection.atEnd(doc).to;\n\t\tconst resolvedFrom = minMax(from, minPos, maxPos);\n\t\tconst resolvedEnd = minMax(to, minPos, maxPos);\n\t\tconst selection = _tiptap_pm_state.TextSelection.create(doc, resolvedFrom, resolvedEnd);\n\t\ttr.setSelection(selection);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/sinkListItem.ts\nconst sinkListItem = (typeOrName) => ({ state, dispatch }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\treturn (0, _tiptap_pm_schema_list.sinkListItem)(type)(state, dispatch);\n};\n//#endregion\n//#region src/commands/splitBlock.ts\nfunction ensureMarks(state, splittableMarks) {\n\tconst marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();\n\tif (marks) {\n\t\tconst filteredMarks = marks.filter((mark) => splittableMarks === null || splittableMarks === void 0 ? void 0 : splittableMarks.includes(mark.type.name));\n\t\tstate.tr.ensureMarks(filteredMarks);\n\t}\n}\nconst splitBlock = ({ keepMarks = true } = {}) => ({ tr, state, dispatch, editor }) => {\n\tconst { selection, doc } = tr;\n\tconst { $from, $to } = selection;\n\tconst extensionAttributes = editor.extensionManager.attributes;\n\tconst newAttributes = getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs);\n\tif (selection instanceof _tiptap_pm_state.NodeSelection && selection.node.isBlock) {\n\t\tif (!$from.parentOffset || !(0, _tiptap_pm_transform.canSplit)(doc, $from.pos)) return false;\n\t\tif (dispatch) {\n\t\t\tif (keepMarks) ensureMarks(state, editor.extensionManager.splittableMarks);\n\t\t\ttr.split($from.pos).scrollIntoView();\n\t\t}\n\t\treturn true;\n\t}\n\tif (!$from.parent.isBlock) return false;\n\tconst atEnd = $to.parentOffset === $to.parent.content.size;\n\tconst deflt = $from.depth === 0 ? void 0 : defaultBlockAt($from.node(-1).contentMatchAt($from.indexAfter(-1)));\n\tlet types = atEnd && deflt ? [{\n\t\ttype: deflt,\n\t\tattrs: newAttributes\n\t}] : void 0;\n\tlet can = (0, _tiptap_pm_transform.canSplit)(tr.doc, tr.mapping.map($from.pos), 1, types);\n\tif (!types && !can && (0, _tiptap_pm_transform.canSplit)(tr.doc, tr.mapping.map($from.pos), 1, deflt ? [{ type: deflt }] : void 0)) {\n\t\tcan = true;\n\t\ttypes = deflt ? [{\n\t\t\ttype: deflt,\n\t\t\tattrs: newAttributes\n\t\t}] : void 0;\n\t}\n\tif (dispatch) {\n\t\tif (can) {\n\t\t\tif (selection instanceof _tiptap_pm_state.TextSelection) tr.deleteSelection();\n\t\t\ttr.split(tr.mapping.map($from.pos), 1, types);\n\t\t\tif (deflt && !atEnd && !$from.parentOffset && $from.parent.type !== deflt) {\n\t\t\t\tconst first = tr.mapping.map($from.before());\n\t\t\t\tconst $first = tr.doc.resolve(first);\n\t\t\t\tif ($from.node(-1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(tr.mapping.map($from.before()), deflt);\n\t\t\t}\n\t\t}\n\t\tif (keepMarks) ensureMarks(state, editor.extensionManager.splittableMarks);\n\t\ttr.scrollIntoView();\n\t}\n\treturn can;\n};\n//#endregion\n//#region src/commands/splitListItem.ts\nconst splitListItem = (typeOrName, overrideAttrs = {}) => ({ tr, state, dispatch, editor }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tconst { $from, $to } = state.selection;\n\tconst node = state.selection.node;\n\tif (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) return false;\n\tconst grandParent = $from.node(-1);\n\tif (grandParent.type !== type) return false;\n\tconst extensionAttributes = editor.extensionManager.attributes;\n\tif ($from.parent.content.size === 0 && $from.node(-1).childCount === $from.indexAfter(-1)) {\n\t\tif ($from.depth === 2 || $from.node(-3).type !== type || $from.index(-2) !== $from.node(-2).childCount - 1) return false;\n\t\tif (dispatch) {\n\t\t\tvar _type$contentMatch$de;\n\t\t\tlet wrap = _tiptap_pm_model.Fragment.empty;\n\t\t\tconst depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;\n\t\t\tfor (let d = $from.depth - depthBefore; d >= $from.depth - 3; d -= 1) wrap = _tiptap_pm_model.Fragment.from($from.node(d).copy(wrap));\n\t\t\tconst depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;\n\t\t\tconst newNextTypeAttributes = {\n\t\t\t\t...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),\n\t\t\t\t...overrideAttrs\n\t\t\t};\n\t\t\tconst nextType = ((_type$contentMatch$de = type.contentMatch.defaultType) === null || _type$contentMatch$de === void 0 ? void 0 : _type$contentMatch$de.createAndFill(newNextTypeAttributes)) || void 0;\n\t\t\twrap = wrap.append(_tiptap_pm_model.Fragment.from(type.createAndFill(null, nextType) || void 0));\n\t\t\tconst start = $from.before($from.depth - (depthBefore - 1));\n\t\t\ttr.replace(start, $from.after(-depthAfter), new _tiptap_pm_model.Slice(wrap, 4 - depthBefore, 0));\n\t\t\tlet sel = -1;\n\t\t\ttr.doc.nodesBetween(start, tr.doc.content.size, (n, pos) => {\n\t\t\t\tif (sel > -1) return false;\n\t\t\t\tif (n.isTextblock && n.content.size === 0) sel = pos + 1;\n\t\t\t});\n\t\t\tif (sel > -1) tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(sel)));\n\t\t\ttr.scrollIntoView();\n\t\t}\n\t\treturn true;\n\t}\n\tconst nextType = $to.pos === $from.end() ? grandParent.contentMatchAt(0).defaultType : null;\n\tconst newTypeAttributes = {\n\t\t...getSplittedAttributes(extensionAttributes, grandParent.type.name, grandParent.attrs),\n\t\t...overrideAttrs\n\t};\n\tconst newNextTypeAttributes = {\n\t\t...getSplittedAttributes(extensionAttributes, $from.node().type.name, $from.node().attrs),\n\t\t...overrideAttrs\n\t};\n\ttr.delete($from.pos, $to.pos);\n\tconst types = nextType ? [{\n\t\ttype,\n\t\tattrs: newTypeAttributes\n\t}, {\n\t\ttype: nextType,\n\t\tattrs: newNextTypeAttributes\n\t}] : [{\n\t\ttype,\n\t\tattrs: newTypeAttributes\n\t}];\n\tif (!(0, _tiptap_pm_transform.canSplit)(tr.doc, $from.pos, 2)) return false;\n\tif (dispatch) {\n\t\tconst { selection, storedMarks } = state;\n\t\tconst { splittableMarks } = editor.extensionManager;\n\t\tconst marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();\n\t\ttr.split($from.pos, 2, types).scrollIntoView();\n\t\tif (!marks || !dispatch) return true;\n\t\tconst filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));\n\t\ttr.ensureMarks(filteredMarks);\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/toggleList.ts\n/**\n* Normalise a list type attribute for comparison.\n* Treats null, undefined, and \"1\" as equivalent (the default numeric type).\n*/\nfunction normalizeListType(type) {\n\treturn !type || type === \"1\" ? null : type;\n}\n/**\n* Check if two list type attributes are compatible for joining.\n* Lists can only join when they have the same type (both default, or both the same non-default type).\n*/\nfunction areListTypesCompatible(typeA, typeB) {\n\treturn normalizeListType(typeA) === normalizeListType(typeB);\n}\nconst joinListBackwards = (tr, listType) => {\n\tconst list = findParentNode((node) => node.type === listType)(tr.selection);\n\tif (!list) return true;\n\tconst before = tr.doc.resolve(Math.max(0, list.pos - 1)).before(list.depth);\n\tif (before === void 0) return true;\n\tconst nodeBefore = tr.doc.nodeAt(before);\n\tif (!(list.node.type === (nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.type) && (0, _tiptap_pm_transform.canJoin)(tr.doc, list.pos))) return true;\n\tif (!areListTypesCompatible(list.node.attrs.type, nodeBefore === null || nodeBefore === void 0 ? void 0 : nodeBefore.attrs.type)) return true;\n\ttr.join(list.pos);\n\treturn true;\n};\nconst joinListForwards = (tr, listType) => {\n\tconst list = findParentNode((node) => node.type === listType)(tr.selection);\n\tif (!list) return true;\n\tconst after = tr.doc.resolve(list.start).after(list.depth);\n\tif (after === void 0) return true;\n\tconst nodeAfter = tr.doc.nodeAt(after);\n\tif (!(list.node.type === (nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.type) && (0, _tiptap_pm_transform.canJoin)(tr.doc, after))) return true;\n\tif (!areListTypesCompatible(list.node.attrs.type, nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.attrs.type)) return true;\n\ttr.join(after);\n\treturn true;\n};\nfunction createInnerSelectionForWholeDocList(tr) {\n\tconst doc = tr.doc;\n\tconst list = doc.firstChild;\n\tif (!list) return null;\n\tconst $start = doc.resolve(1);\n\tconst $end = doc.resolve(list.nodeSize - 1);\n\treturn _tiptap_pm_state.TextSelection.between($start, $end);\n}\nconst toggleList = (listTypeOrName, itemTypeOrName, keepMarks, attributes = {}) => ({ editor, tr, state, dispatch, chain, commands, can }) => {\n\tconst { extensions, splittableMarks } = editor.extensionManager;\n\tconst listType = getNodeType(listTypeOrName, state.schema);\n\tconst itemType = getNodeType(itemTypeOrName, state.schema);\n\tconst { selection, storedMarks } = state;\n\tconst { $from, $to } = selection;\n\tconst range = $from.blockRange($to);\n\tconst marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();\n\tif (!range) return false;\n\tconst parentList = findParentNode((node) => isList(node.type.name, extensions))(selection);\n\tconst isAllSelection = selection.from === 0 && selection.to === state.doc.content.size;\n\tconst topLevelNodes = state.doc.content.content;\n\tconst soleTopLevelNode = topLevelNodes.length === 1 ? topLevelNodes[0] : null;\n\tconst allSelectionList = isAllSelection && soleTopLevelNode && isList(soleTopLevelNode.type.name, extensions) ? {\n\t\tnode: soleTopLevelNode,\n\t\tpos: 0,\n\t\tdepth: 0\n\t} : null;\n\tconst currentList = parentList !== null && parentList !== void 0 ? parentList : allSelectionList;\n\tconst isInsideExistingList = !!parentList && range.depth >= 1 && range.depth - parentList.depth <= 1;\n\tconst hasWholeDocSelectedList = !!allSelectionList;\n\tif ((isInsideExistingList || hasWholeDocSelectedList) && currentList) {\n\t\tif (currentList.node.type === listType) {\n\t\t\tif (isAllSelection && hasWholeDocSelectedList) return chain().command(({ tr: trx, dispatch: disp }) => {\n\t\t\t\tconst nextSelection = createInnerSelectionForWholeDocList(trx);\n\t\t\t\tif (!nextSelection) return false;\n\t\t\t\ttrx.setSelection(nextSelection);\n\t\t\t\tif (disp) disp(trx);\n\t\t\t\treturn true;\n\t\t\t}).liftListItem(itemType).run();\n\t\t\treturn commands.liftListItem(itemType);\n\t\t}\n\t\tif (isList(currentList.node.type.name, extensions) && listType.validContent(currentList.node.content)) return chain().command(() => {\n\t\t\ttr.setNodeMarkup(currentList.pos, listType);\n\t\t\treturn true;\n\t\t}).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();\n\t}\n\tif (!keepMarks || !marks || !dispatch) return chain().command(() => {\n\t\tif (can().wrapInList(listType, attributes)) return true;\n\t\treturn commands.clearNodes();\n\t}).wrapInList(listType, attributes).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();\n\treturn chain().command(() => {\n\t\tconst canWrapInList = can().wrapInList(listType, attributes);\n\t\tconst filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));\n\t\ttr.ensureMarks(filteredMarks);\n\t\tif (canWrapInList) return true;\n\t\treturn commands.clearNodes();\n\t}).wrapInList(listType, attributes).command(() => joinListBackwards(tr, listType)).command(() => joinListForwards(tr, listType)).run();\n};\n//#endregion\n//#region src/commands/toggleMark.ts\nconst toggleMark = (typeOrName, attributes = {}, options = {}) => ({ state, commands }) => {\n\tconst { extendEmptyMarkRange = false } = options;\n\tconst type = getMarkType(typeOrName, state.schema);\n\tif (isMarkActive(state, type, attributes)) return commands.unsetMark(type, { extendEmptyMarkRange });\n\treturn commands.setMark(type, attributes);\n};\n//#endregion\n//#region src/commands/toggleNode.ts\nconst toggleNode = (typeOrName, toggleTypeOrName, attributes = {}) => ({ state, commands }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tconst toggleType = getNodeType(toggleTypeOrName, state.schema);\n\tconst isActive = isNodeActive(state, type, attributes);\n\tlet attributesToCopy;\n\tif (state.selection.$anchor.sameParent(state.selection.$head)) attributesToCopy = state.selection.$anchor.parent.attrs;\n\tif (isActive) return commands.setNode(toggleType, attributesToCopy);\n\treturn commands.setNode(type, {\n\t\t...attributesToCopy,\n\t\t...attributes\n\t});\n};\n//#endregion\n//#region src/commands/toggleWrap.ts\nconst toggleWrap = (typeOrName, attributes = {}) => ({ state, commands }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\tif (isNodeActive(state, type, attributes)) return commands.lift(type);\n\treturn commands.wrapIn(type, attributes);\n};\n//#endregion\n//#region src/commands/undoInputRule.ts\nconst undoInputRule = () => ({ state, dispatch }) => {\n\tconst plugins = state.plugins;\n\tfor (let i = 0; i < plugins.length; i += 1) {\n\t\tconst plugin = plugins[i];\n\t\tlet undoable;\n\t\tif (plugin.spec.isInputRules && (undoable = plugin.getState(state))) {\n\t\t\tif (dispatch) {\n\t\t\t\tconst tr = state.tr;\n\t\t\t\tconst toUndo = undoable.transform;\n\t\t\t\tfor (let j = toUndo.steps.length - 1; j >= 0; j -= 1) tr.step(toUndo.steps[j].invert(toUndo.docs[j]));\n\t\t\t\tif (undoable.text) {\n\t\t\t\t\tconst marks = tr.doc.resolve(undoable.from).marks();\n\t\t\t\t\ttr.replaceWith(undoable.from, undoable.to, state.schema.text(undoable.text, marks));\n\t\t\t\t} else tr.delete(undoable.from, undoable.to);\n\t\t\t}\n\t\t\treturn true;\n\t\t}\n\t}\n\treturn false;\n};\n//#endregion\n//#region src/commands/unsetAllMarks.ts\nconst unsetAllMarks = (options = {}) => ({ tr, dispatch, editor }) => {\n\tconst { ignoreClearable = false } = options;\n\tconst { selection } = tr;\n\tconst { empty, ranges } = selection;\n\tif (empty) return true;\n\tconst { nonClearableMarks } = editor.extensionManager;\n\tif (dispatch) {\n\t\tconst clearableMarkTypes = Object.values(editor.schema.marks).filter((markType) => ignoreClearable || !nonClearableMarks.includes(markType.name));\n\t\tranges.forEach((range) => {\n\t\t\tfor (const markType of clearableMarkTypes) tr.removeMark(range.$from.pos, range.$to.pos, markType);\n\t\t});\n\t}\n\treturn true;\n};\n//#endregion\n//#region src/commands/unsetMark.ts\nconst unsetMark = (typeOrName, options = {}) => ({ tr, state, dispatch }) => {\n\tconst { extendEmptyMarkRange = false } = options;\n\tconst { selection } = tr;\n\tconst type = getMarkType(typeOrName, state.schema);\n\tconst { $from, empty, ranges } = selection;\n\tif (!dispatch) return true;\n\tif (empty && extendEmptyMarkRange) {\n\t\tvar _$from$marks$find;\n\t\tlet { from, to } = selection;\n\t\tconst range = getMarkRange($from, type, (_$from$marks$find = $from.marks().find((mark) => mark.type === type)) === null || _$from$marks$find === void 0 ? void 0 : _$from$marks$find.attrs);\n\t\tif (range) {\n\t\t\tfrom = range.from;\n\t\t\tto = range.to;\n\t\t}\n\t\ttr.removeMark(from, to, type);\n\t} else ranges.forEach((range) => {\n\t\ttr.removeMark(range.$from.pos, range.$to.pos, type);\n\t});\n\ttr.removeStoredMark(type);\n\treturn true;\n};\n//#endregion\n//#region src/commands/unsetTextDirection.ts\nconst unsetTextDirection = (position) => ({ tr, state, dispatch }) => {\n\tconst { selection } = state;\n\tlet from;\n\tlet to;\n\tif (typeof position === \"number\") {\n\t\tfrom = position;\n\t\tto = position;\n\t} else if (position && \"from\" in position && \"to\" in position) {\n\t\tfrom = position.from;\n\t\tto = position.to;\n\t} else {\n\t\tfrom = selection.from;\n\t\tto = selection.to;\n\t}\n\tif (dispatch) tr.doc.nodesBetween(from, to, (node, pos) => {\n\t\tif (node.isText) return;\n\t\tconst newAttrs = { ...node.attrs };\n\t\tdelete newAttrs.dir;\n\t\ttr.setNodeMarkup(pos, void 0, newAttrs);\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/commands/updateAttributes.ts\nconst updateAttributes = (typeOrName, attributes = {}) => ({ tr, state, dispatch }) => {\n\tlet nodeType = null;\n\tlet markType = null;\n\tconst schemaType = getSchemaTypeNameByName(typeof typeOrName === \"string\" ? typeOrName : typeOrName.name, state.schema);\n\tif (!schemaType) return false;\n\tif (schemaType === \"node\") nodeType = getNodeType(typeOrName, state.schema);\n\tif (schemaType === \"mark\") markType = getMarkType(typeOrName, state.schema);\n\tlet canUpdate = false;\n\ttr.selection.ranges.forEach((range) => {\n\t\tconst from = range.$from.pos;\n\t\tconst to = range.$to.pos;\n\t\tlet lastPos;\n\t\tlet lastNode;\n\t\tlet trimmedFrom;\n\t\tlet trimmedTo;\n\t\tif (tr.selection.empty) state.doc.nodesBetween(from, to, (node, pos) => {\n\t\t\tif (nodeType && nodeType === node.type) {\n\t\t\t\tcanUpdate = true;\n\t\t\t\ttrimmedFrom = Math.max(pos, from);\n\t\t\t\ttrimmedTo = Math.min(pos + node.nodeSize, to);\n\t\t\t\tlastPos = pos;\n\t\t\t\tlastNode = node;\n\t\t\t}\n\t\t});\n\t\telse state.doc.nodesBetween(from, to, (node, pos) => {\n\t\t\tif (pos < from && nodeType && nodeType === node.type) {\n\t\t\t\tcanUpdate = true;\n\t\t\t\ttrimmedFrom = Math.max(pos, from);\n\t\t\t\ttrimmedTo = Math.min(pos + node.nodeSize, to);\n\t\t\t\tlastPos = pos;\n\t\t\t\tlastNode = node;\n\t\t\t}\n\t\t\tif (pos >= from && pos <= to) {\n\t\t\t\tif (nodeType && nodeType === node.type) {\n\t\t\t\t\tcanUpdate = true;\n\t\t\t\t\tif (dispatch) tr.setNodeMarkup(pos, void 0, {\n\t\t\t\t\t\t...node.attrs,\n\t\t\t\t\t\t...attributes\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tif (markType && node.marks.length) node.marks.forEach((mark) => {\n\t\t\t\t\tif (markType === mark.type) {\n\t\t\t\t\t\tcanUpdate = true;\n\t\t\t\t\t\tif (dispatch) {\n\t\t\t\t\t\t\tconst trimmedFrom2 = Math.max(pos, from);\n\t\t\t\t\t\t\tconst trimmedTo2 = Math.min(pos + node.nodeSize, to);\n\t\t\t\t\t\t\ttr.addMark(trimmedFrom2, trimmedTo2, markType.create({\n\t\t\t\t\t\t\t\t...mark.attrs,\n\t\t\t\t\t\t\t\t...attributes\n\t\t\t\t\t\t\t}));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t\tif (lastNode) {\n\t\t\tif (lastPos !== void 0 && dispatch) tr.setNodeMarkup(lastPos, void 0, {\n\t\t\t\t...lastNode.attrs,\n\t\t\t\t...attributes\n\t\t\t});\n\t\t\tif (markType && lastNode.marks.length) lastNode.marks.forEach((mark) => {\n\t\t\t\tif (markType === mark.type && dispatch) tr.addMark(trimmedFrom, trimmedTo, markType.create({\n\t\t\t\t\t...mark.attrs,\n\t\t\t\t\t...attributes\n\t\t\t\t}));\n\t\t\t});\n\t\t}\n\t});\n\treturn canUpdate;\n};\nconst DECORATION_MANAGER_PLUGIN_KEY = new _tiptap_pm_state.PluginKey(\"__tiptap_decorations__\");\n//#endregion\n//#region src/commands/updateDecorations.ts\nconst updateDecorations = (extensionName) => ({ tr, dispatch }) => {\n\tif (dispatch) tr.setMeta(DECORATION_MANAGER_PLUGIN_KEY, {\n\t\ttype: \"force\",\n\t\tname: extensionName\n\t});\n\treturn true;\n};\n//#endregion\n//#region src/commands/wrapIn.ts\nconst wrapIn = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\treturn (0, _tiptap_pm_commands.wrapIn)(type, attributes)(state, dispatch);\n};\n//#endregion\n//#region src/commands/wrapInList.ts\nconst wrapInList = (typeOrName, attributes = {}) => ({ state, dispatch }) => {\n\tconst type = getNodeType(typeOrName, state.schema);\n\treturn (0, _tiptap_pm_schema_list.wrapInList)(type, attributes)(state, dispatch);\n};\n//#endregion\n//#region src/commands/index.ts\nvar commands_exports = /* @__PURE__ */ __exportAll({\n\tblur: () => blur,\n\tclearContent: () => clearContent,\n\tclearNodes: () => clearNodes,\n\tcommand: () => command,\n\tcreateParagraphNear: () => createParagraphNear,\n\tcut: () => cut,\n\tdeleteCurrentNode: () => deleteCurrentNode,\n\tdeleteNode: () => deleteNode,\n\tdeleteRange: () => deleteRange,\n\tdeleteSelection: () => deleteSelection,\n\tenter: () => enter,\n\texitCode: () => exitCode,\n\textendMarkRange: () => extendMarkRange,\n\tfirst: () => first,\n\tfocus: () => focus,\n\tforEach: () => forEach,\n\tinsertContent: () => insertContent,\n\tinsertContentAt: () => insertContentAt,\n\tinsertDefaultBlock: () => insertDefaultBlock,\n\tjoinBackward: () => joinBackward,\n\tjoinDown: () => joinDown,\n\tjoinForward: () => joinForward,\n\tjoinItemBackward: () => joinItemBackward,\n\tjoinItemForward: () => joinItemForward,\n\tjoinTextblockBackward: () => joinTextblockBackward,\n\tjoinTextblockForward: () => joinTextblockForward,\n\tjoinUp: () => joinUp,\n\tkeyboardShortcut: () => keyboardShortcut,\n\tlift: () => lift,\n\tliftEmptyBlock: () => liftEmptyBlock,\n\tliftListItem: () => liftListItem,\n\tnewlineInCode: () => newlineInCode,\n\tresetAttributes: () => resetAttributes,\n\tscrollIntoView: () => scrollIntoView,\n\tselectAll: () => selectAll,\n\tselectNodeBackward: () => selectNodeBackward,\n\tselectNodeForward: () => selectNodeForward,\n\tselectParentNode: () => selectParentNode,\n\tselectTextblockEnd: () => selectTextblockEnd,\n\tselectTextblockStart: () => selectTextblockStart,\n\tsetContent: () => setContent,\n\tsetMark: () => setMark,\n\tsetMeta: () => setMeta,\n\tsetNode: () => setNode,\n\tsetNodeSelection: () => setNodeSelection,\n\tsetTextDirection: () => setTextDirection,\n\tsetTextSelection: () => setTextSelection,\n\tsinkListItem: () => sinkListItem,\n\tsplitBlock: () => splitBlock,\n\tsplitListItem: () => splitListItem,\n\ttoggleList: () => toggleList,\n\ttoggleMark: () => toggleMark,\n\ttoggleNode: () => toggleNode,\n\ttoggleWrap: () => toggleWrap,\n\tundoInputRule: () => undoInputRule,\n\tunsetAllMarks: () => unsetAllMarks,\n\tunsetMark: () => unsetMark,\n\tunsetTextDirection: () => unsetTextDirection,\n\tupdateAttributes: () => updateAttributes,\n\tupdateDecorations: () => updateDecorations,\n\twrapIn: () => wrapIn,\n\twrapInList: () => wrapInList\n});\n//#endregion\n//#region src/decorations/decorationApplyScope.ts\n/**\n* Tracks which editors are running decoration create() callbacks inside state.apply,\n* using a private WeakMap to keep this off the public Editor surface.\n*/\nconst depthByEditor = /* @__PURE__ */ new WeakMap();\n/**\n* Marks callback as decoration-apply work for editor, so editor.state can warn\n* about stale reads. Counts depth to handle nested applies.\n*\n* @param editor The editor the decorations belong to\n* @param callback The work to run inside the scope\n* @returns Whatever `callback` returns\n* @example\n* runInDecorationApplyScope(editor, () => spec.create({ editor, state, view }))\n*/\nfunction runInDecorationApplyScope(editor, callback) {\n\tvar _depthByEditor$get;\n\tdepthByEditor.set(editor, ((_depthByEditor$get = depthByEditor.get(editor)) !== null && _depthByEditor$get !== void 0 ? _depthByEditor$get : 0) + 1);\n\ttry {\n\t\treturn callback();\n\t} finally {\n\t\tvar _depthByEditor$get2;\n\t\tconst remaining = ((_depthByEditor$get2 = depthByEditor.get(editor)) !== null && _depthByEditor$get2 !== void 0 ? _depthByEditor$get2 : 1) - 1;\n\t\tif (remaining > 0) depthByEditor.set(editor, remaining);\n\t\telse depthByEditor.delete(editor);\n\t}\n}\n/**\n* Whether the editor is currently inside a decoration apply scope.\n*\n* @param editor The editor to check\n* @returns `true` while decoration create() callbacks run\n* @example\n* if (isInDecorationApplyScope(editor)) {\n* // reads of editor.state are stale here\n* }\n*/\nfunction isInDecorationApplyScope(editor) {\n\treturn depthByEditor.has(editor);\n}\n//#endregion\n//#region src/EventEmitter.ts\nvar EventEmitter = class {\n\tconstructor() {\n\t\tthis.callbacks = {};\n\t}\n\ton(event, fn) {\n\t\tif (!this.callbacks[event]) this.callbacks[event] = [];\n\t\tthis.callbacks[event].push(fn);\n\t\treturn this;\n\t}\n\temit(event, ...args) {\n\t\tconst callbacks = this.callbacks[event];\n\t\tif (callbacks) callbacks.forEach((callback) => callback.apply(this, args));\n\t\treturn this;\n\t}\n\toff(event, fn) {\n\t\tconst callbacks = this.callbacks[event];\n\t\tif (callbacks) {\n\t\t\tif (fn) this.callbacks[event] = callbacks.filter((callback) => callback !== fn);\n\t\t\telse delete this.callbacks[event];\n\t\t}\n\t\treturn this;\n\t}\n\tonce(event, fn) {\n\t\tconst onceFn = (...args) => {\n\t\t\tthis.off(event, onceFn);\n\t\t\tfn.apply(this, args);\n\t\t};\n\t\treturn this.on(event, onceFn);\n\t}\n\tremoveAllListeners() {\n\t\tthis.callbacks = {};\n\t}\n};\n//#endregion\n//#region src/utilities/isDev.ts\n/**\n* Whether the editor runs in a development build. Use it to guard warnings so\n* bundlers can drop them from production output.\n*/\nconst isDev = typeof process !== \"undefined\" && process.env.NODE_ENV !== \"production\";\n//#endregion\n//#region src/decorations/helpers/decorationsToPMDecorations.ts\nfunction isWidgetDecoration(decoration) {\n\treturn decoration.kind === \"widget\";\n}\n/**\n* Converts a list of decorations to ProseMirror decorations.\n* @param decorations The decorations to convert.\n* @param extensionName The name of the extension that created the decorations.\n* @returns The converted decorations and the widget keys.\n*/\nfunction decorationsToPMDecorations(decorations, extensionName) {\n\tconst pmDecorations = [];\n\tconst widgetKeys = /* @__PURE__ */ new Set();\n\tfor (const decoration of decorations) {\n\t\tif (decoration.kind === \"widget\") {\n\t\t\tif (isWidgetDecoration(decoration)) widgetKeys.add(decoration.key);\n\t\t}\n\t\tpmDecorations.push(decoration.toPMDecoration(extensionName));\n\t}\n\treturn {\n\t\tdecorations: pmDecorations,\n\t\twidgetKeys\n\t};\n}\n//#endregion\n//#region src/decorations/helpers/buildDecorationSet.ts\n/**\n* Builds a DecorationSet from a list of decorations.\n* @param doc The document to build the decoration set for.\n* @param decorations The decorations to build the set from.\n* @param extensionName The name of the extension that created the decorations.\n* @returns The built decoration set and the widget keys.\n*/\nfunction buildDecorationSet(doc, decorations, extensionName) {\n\tconst { decorations: pmDecorations, widgetKeys } = decorationsToPMDecorations(decorations, extensionName);\n\treturn {\n\t\tset: _tiptap_pm_view.DecorationSet.create(doc, pmDecorations),\n\t\twidgetKeys\n\t};\n}\n//#endregion\n//#region src/decorations/helpers/rangeOwnsPosition.ts\n/**\n* Whether the block range `[from, to)` owns a decoration at `position`.\n*\n* `to` is the next block's start, so that block owns it. The last block is the\n* exception: nothing follows it, so it owns the end of the document.\n*\n* @param options The position, the range, and the document size.\n* @returns True when the range owns the position.\n* @example\n* // <p>foo</p><p>bar</p>, blocks [0, 5] and [5, 10]\n* rangeOwnsPosition({ position: 5, from: 0, to: 5, docSize: 10 }) // false, block 2 owns it\n* rangeOwnsPosition({ position: 5, from: 5, to: 10, docSize: 10 }) // true\n* rangeOwnsPosition({ position: 10, from: 5, to: 10, docSize: 10 }) // true, end of document\n*/\nfunction rangeOwnsPosition({ position, from, to, docSize }) {\n\tif (position < from) return false;\n\tif (position < to) return true;\n\treturn position === to && to === docSize;\n}\n//#endregion\n//#region src/decorations/helpers/filterOutOfRangeDecorations.ts\n/**\n* Filter decorations the block range `[from, to)` does not own.\n* Must match the stale sweep in `DecorationManager.rebuildRanges`.\n*\n* @param options The decorations, the range, and the warning bookkeeping.\n* @returns The filtered decorations.\n*/\nfunction filterOutOfRangeDecorations({ decorations, from, to, docSize, extensionName, warnedExtensions }) {\n\treturn decorations.filter((decoration) => {\n\t\tif (rangeOwnsPosition({\n\t\t\tposition: decoration.anchor,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\tdocSize\n\t\t})) return true;\n\t\tif (decoration.anchor === to) return false;\n\t\tif (!warnedExtensions.has(extensionName)) {\n\t\t\twarnedExtensions.add(extensionName);\n\t\t\tconsole.warn(`[tiptap warn]: Extension \"${extensionName}\" returned a decoration outside the requested range [${from}, ${to}). It was ignored.`);\n\t\t}\n\t\treturn false;\n\t});\n}\n//#endregion\n//#region src/decorations/helpers/widgetKeyOf.ts\n/**\n* Extracts the widget key from a decoration spec.\n* @param decoration The decoration to extract the key from.\n* @returns The widget key, or undefined if the decoration has no key.\n*/\nfunction widgetKeyOf(decoration) {\n\tvar _decoration$spec;\n\tconst key = (_decoration$spec = decoration.spec) === null || _decoration$spec === void 0 ? void 0 : _decoration$spec.key;\n\treturn typeof key === \"string\" ? key : void 0;\n}\n//#endregion\n//#region src/decorations/helpers/findDuplicateWidgetKeys.ts\n/**\n* Finds widget keys which are still duplicated in the final decoration set.\n* @param decorationSet The merged decoration set to inspect.\n* @returns The duplicate keys and their producing extensions.\n*/\nfunction findDuplicateWidgetKeys(decorationSet) {\n\tconst extensionsByKey = /* @__PURE__ */ new Map();\n\tconst counts = /* @__PURE__ */ new Map();\n\tfor (const decoration of decorationSet.find()) {\n\t\tvar _extensionName, _extensionsByKey$get, _counts$get;\n\t\tconst key = widgetKeyOf(decoration);\n\t\tif (!key) continue;\n\t\tconst extension = (_extensionName = decoration.spec.extensionName) !== null && _extensionName !== void 0 ? _extensionName : \"unknown\";\n\t\tconst extensions = (_extensionsByKey$get = extensionsByKey.get(key)) !== null && _extensionsByKey$get !== void 0 ? _extensionsByKey$get : /* @__PURE__ */ new Set();\n\t\textensions.add(extension);\n\t\textensionsByKey.set(key, extensions);\n\t\tcounts.set(key, ((_counts$get = counts.get(key)) !== null && _counts$get !== void 0 ? _counts$get : 0) + 1);\n\t}\n\treturn Array.from(extensionsByKey, ([key, extensions]) => ({\n\t\tkey,\n\t\textensions\n\t})).filter(({ key }) => {\n\t\tvar _counts$get2;\n\t\treturn ((_counts$get2 = counts.get(key)) !== null && _counts$get2 !== void 0 ? _counts$get2 : 0) > 1;\n\t});\n}\n//#endregion\n//#region src/decorations/helpers/isAttrStep.ts\n/**\n* Whether a step only sets a node attribute.\n*\n* Matched by `jsonID` rather than `instanceof`, which fails when two copies of\n* prosemirror-transform are loaded.\n*\n* @param step The step to check.\n* @returns `true` for an `AttrStep`, which carries the target node's position.\n* @example\n* if (isAttrStep(step)) {\n* rebuildBlockAt(step.pos)\n* }\n*/\nfunction isAttrStep(step) {\n\treturn step.jsonID === \"attr\";\n}\n//#endregion\n//#region src/decorations/helpers/hasResolvableChangedRange.ts\n/**\n* Check if a step has a resolvable changed range.\n* @param step The step to check.\n* @returns True if the step has a resolvable changed range, false otherwise.\n*/\nfunction hasResolvableChangedRange(step) {\n\tlet hasMappedRange = false;\n\tstep.getMap().forEach(() => {\n\t\thasMappedRange = true;\n\t});\n\tif (hasMappedRange || isAttrStep(step)) return true;\n\tconst positionalStep = step;\n\treturn typeof positionalStep.from === \"number\" && typeof positionalStep.to === \"number\";\n}\n//#endregion\n//#region src/decorations/helpers/getRebuildRanges.ts\n/**\n* Expands a changed range to the top-level blocks it touches. Blocks are\n* ordered, so the walk stops as soon as it passes the range.\n*/\nfunction blockRangeFor(doc, changed) {\n\tlet from = null;\n\tlet to = 0;\n\tlet nodeStart = 0;\n\tfor (let index = 0; index < doc.childCount; index += 1) {\n\t\tif (nodeStart > changed.to) break;\n\t\tconst nodeEnd = nodeStart + doc.child(index).nodeSize;\n\t\tif (nodeEnd >= changed.from) {\n\t\t\tif (from === null) from = nodeStart;\n\t\t\tto = nodeEnd;\n\t\t}\n\t\tnodeStart = nodeEnd;\n\t}\n\treturn from === null ? null : {\n\t\tfrom,\n\t\tto\n\t};\n}\n/**\n* Returns the top-level block ranges to recompute after a transaction,\n* or `{ type: 'full' }` when the whole document must be rebuilt.\n* @param tr The transaction to inspect.\n* @param doc The new document after the transaction.\n* @returns The block ranges to recompute, or a full-recompute signal.\n*/\nfunction getRebuildRanges(tr, doc) {\n\tif (tr.steps.some((step) => !hasResolvableChangedRange(step))) return { type: \"full\" };\n\tconst newRanges = getChangedRanges(tr).map(({ newRange }) => newRange);\n\ttr.steps.forEach((step, index) => {\n\t\tif (!isAttrStep(step)) return;\n\t\tconst mapping = tr.mapping.slice(index);\n\t\tnewRanges.push({\n\t\t\tfrom: mapping.map(step.pos, -1),\n\t\t\tto: mapping.map(step.pos + 1)\n\t\t});\n\t});\n\tconst ranges = [];\n\tfor (const newRange of newRanges) {\n\t\tconst blockRange = blockRangeFor(doc, newRange);\n\t\tif (blockRange) ranges.push(blockRange);\n\t}\n\tranges.sort((a, b) => a.from - b.from);\n\tconst merged = [];\n\tfor (const range of ranges) {\n\t\tconst last = merged[merged.length - 1];\n\t\tif (last && range.from <= last.to) last.to = Math.max(last.to, range.to);\n\t\telse merged.push({ ...range });\n\t}\n\treturn {\n\t\ttype: \"ranges\",\n\t\tranges: merged\n\t};\n}\n//#endregion\n//#region src/decorations/helpers/mapDecorationSet.ts\n/**\n* Maps a decoration set through a mapping and prunes the keys of any widget\n* dropped because its position was deleted.\n* @param set The decoration set to map.\n* @param mapping The mapping to use.\n* @param doc The document to map the set through.\n* @param widgetKeys The set of widget keys to prune.\n* @returns The mapped decoration set.\n*/\nfunction mapDecorationSet(set, mapping, doc, widgetKeys) {\n\treturn set.map(mapping, doc, { onRemove: (removedSpec) => {\n\t\tconst key = removedSpec === null || removedSpec === void 0 ? void 0 : removedSpec.key;\n\t\tif (typeof key === \"string\") widgetKeys.delete(key);\n\t} });\n}\n//#endregion\n//#region src/decorations/helpers/mapDecorations.ts\n/**\n* Moves an extension's existing decorations to their new positions after a\n* transaction, and prunes widget keys for any widget whose position was deleted.\n* @param name The name of the decoration extension.\n* @param previous The previous decoration manager state.\n* @param tr The transaction to map through.\n* @returns The updated decoration set and widget keys.\n*/\nfunction mapDecorations(name, previous, tr) {\n\tvar _previous$decorationS, _previous$widgetKeysB;\n\tconst previousSet = (_previous$decorationS = previous.decorationSetsByExtension[name]) !== null && _previous$decorationS !== void 0 ? _previous$decorationS : _tiptap_pm_view.DecorationSet.empty;\n\tconst widgetKeys = new Set((_previous$widgetKeysB = previous.widgetKeysByExtension[name]) !== null && _previous$widgetKeysB !== void 0 ? _previous$widgetKeysB : []);\n\treturn {\n\t\tset: mapDecorationSet(previousSet, tr.mapping, tr.doc, widgetKeys),\n\t\twidgetKeys\n\t};\n}\n//#endregion\n//#region src/decorations/helpers/mergeDecorationSets.ts\n/**\n* Merges multiple decoration sets into a single decoration set.\n* @param doc The document to merge the decoration sets for.\n* @param decorationSetsByExtension The decoration sets to merge.\n* @returns The merged decoration set.\n*/\nfunction mergeDecorationSets(doc, decorationSetsByExtension) {\n\tconst allDecorations = Object.values(decorationSetsByExtension).flatMap((set) => set.find());\n\treturn _tiptap_pm_view.DecorationSet.create(doc, allDecorations);\n}\n//#endregion\n//#region src/decorations/helpers/unionWidgetKeys.ts\n/**\n* Unions all widget keys from multiple extensions into a single set.\n* @param widgetKeysByExtension The widget keys to union.\n* @returns The unioned widget keys.\n*/\nfunction unionWidgetKeys(widgetKeysByExtension) {\n\tconst merged = /* @__PURE__ */ new Set();\n\tfor (const keys of Object.values(widgetKeysByExtension)) for (const key of keys) merged.add(key);\n\treturn merged;\n}\n//#endregion\n//#region src/decorations/helpers/validateDecorationSpec.ts\n/**\n* Validates a decoration spec to ensure it follows the correct pattern for its update strategy.\n* @param name The name of the extension.\n* @param spec The decoration spec to validate\n*/\nfunction validateDecorationSpec(name, spec) {\n\tvar _update;\n\tswitch ((_update = spec.update) !== null && _update !== void 0 ? _update : \"document\") {\n\t\tcase \"document\":\n\t\t\tif (spec.createInRange) throw new Error(`[tiptap error]: Extension \"${name}\" provides createInRange() but does not use the \"changedRanges\" decoration update strategy.`);\n\t\t\treturn;\n\t\tcase \"changedRanges\":\n\t\t\tif (!spec.createInRange) throw new Error(`[tiptap error]: Extension \"${name}\" uses the \"changedRanges\" decoration update strategy but does not provide createInRange().`);\n\t\t\treturn;\n\t\tcase \"manual\":\n\t\t\tif (spec.createInRange) throw new Error(`[tiptap error]: Extension \"${name}\" uses the \"manual\" decoration update strategy, which is not compatible with createInRange(). createInRange() requires the \"changedRanges\" strategy.`);\n\t\t\tif (spec.shouldUpdate) throw new Error(`[tiptap error]: Extension \"${name}\" cannot combine the \"manual\" decoration update strategy with shouldUpdate().`);\n\t\t\treturn;\n\t\tdefault: throw new Error(`[tiptap error]: Extension \"${name}\" uses an unknown decoration update strategy. Expected \"document\", \"changedRanges\", or \"manual\".`);\n\t}\n}\n//#endregion\n//#region src/decorations/helpers/shouldRecomputeDecoration.ts\n/**\n* Decides whether a decoration spec should be recomputed for a transaction.\n* @param spec The decoration spec to check.\n* @param props Properties containing editor, transaction, and state.\n* @param forced Whether recomputation was forced.\n* @returns `true` if the decoration should be recomputed.\n*/\nfunction shouldRecomputeDecoration(spec, props, forced) {\n\tif (forced) return true;\n\tif (spec.update === \"manual\") return false;\n\treturn spec.shouldUpdate ? spec.shouldUpdate(props) : props.tr.docChanged;\n}\n//#endregion\n//#region src/decorations/DecorationManager.ts\nconst EMPTY_KEYS = /* @__PURE__ */ new Set();\nfunction liveWidgetKeys(editor) {\n\tvar _editor$extensionMana, _editor$extensionMana2;\n\treturn (_editor$extensionMana = (_editor$extensionMana2 = editor.extensionManager) === null || _editor$extensionMana2 === void 0 || (_editor$extensionMana2 = _editor$extensionMana2.decorationManager) === null || _editor$extensionMana2 === void 0 ? void 0 : _editor$extensionMana2.liveWidgetKeys()) !== null && _editor$extensionMana !== void 0 ? _editor$extensionMana : EMPTY_KEYS;\n}\nvar DecorationManager = class {\n\tconstructor(options) {\n\t\tthis.warnedWidgetKeys = /* @__PURE__ */ new Set();\n\t\tthis.warnedOutOfRangeExtensions = /* @__PURE__ */ new Set();\n\t\tthis.handleBeforeTransaction = ({ nextState }) => {\n\t\t\tconst state = DECORATION_MANAGER_PLUGIN_KEY.getState(nextState);\n\t\t\tif (state) this.warnDuplicateWidgetKeys(state);\n\t\t};\n\t\tthis.editor = options.editor;\n\t\tthis.entries = this.resolveEntries(options.entries);\n\t\tthis.entries.forEach(({ name, spec }) => validateDecorationSpec(name, spec));\n\t\tthis.plugin = this.entries.length > 0 ? this.createPlugin() : null;\n\t\tthis.editor.on(\"beforeTransaction\", this.handleBeforeTransaction);\n\t}\n\tdestroy() {\n\t\tthis.editor.off(\"beforeTransaction\", this.handleBeforeTransaction);\n\t}\n\t/**\n\t* Returns the set of live widget keys from all decoration extensions.\n\t* @returns A readonly set of widget keys\n\t*/\n\tliveWidgetKeys() {\n\t\tvar _DECORATION_MANAGER_P, _DECORATION_MANAGER_P2;\n\t\treturn (_DECORATION_MANAGER_P = (_DECORATION_MANAGER_P2 = DECORATION_MANAGER_PLUGIN_KEY.getState(this.editor.state)) === null || _DECORATION_MANAGER_P2 === void 0 ? void 0 : _DECORATION_MANAGER_P2.widgetKeys) !== null && _DECORATION_MANAGER_P !== void 0 ? _DECORATION_MANAGER_P : EMPTY_KEYS;\n\t}\n\t/**\n\t* The mounted editor view, or `null` when destroyed. Decoration callbacks\n\t* must never receive the placeholder view `editor.view` falls back to.\n\t* @returns The mounted editor view, or `null`\n\t*/\n\tget mountedView() {\n\t\treturn this.editor.isDestroyed ? null : this.editor.view;\n\t}\n\t/**\n\t* Resolves decoration entries by calling the addDecorations function for each extension entry.\n\t* @param entries The decoration manager entries to resolve\n\t* @returns An array of resolved decoration entries\n\t*/\n\tresolveEntries(entries) {\n\t\tconst resolved = [];\n\t\tfor (const { name, addDecorations } of entries) {\n\t\t\tconst spec = addDecorations();\n\t\t\tif (spec) resolved.push({\n\t\t\t\tname,\n\t\t\t\tspec\n\t\t\t});\n\t\t}\n\t\treturn resolved;\n\t}\n\t/**\n\t* Creates the ProseMirror plugin for managing decorations.\n\t* @returns A ProseMirror plugin with state management\n\t*/\n\tcreatePlugin() {\n\t\tconst { editor, entries } = this;\n\t\treturn new _tiptap_pm_state.Plugin({\n\t\t\tkey: DECORATION_MANAGER_PLUGIN_KEY,\n\t\t\tstate: {\n\t\t\t\tinit: (_config, state) => {\n\t\t\t\t\tconst decorationSetsByExtension = {};\n\t\t\t\t\tconst widgetKeysByExtension = {};\n\t\t\t\t\tfor (const { name, spec } of entries) {\n\t\t\t\t\t\tconst { set, widgetKeys } = this.buildFullSet(name, spec, state);\n\t\t\t\t\t\tdecorationSetsByExtension[name] = set;\n\t\t\t\t\t\twidgetKeysByExtension[name] = widgetKeys;\n\t\t\t\t\t}\n\t\t\t\t\tconst managerState = {\n\t\t\t\t\t\tdecorationSetsByExtension,\n\t\t\t\t\t\twidgetKeysByExtension,\n\t\t\t\t\t\tmergedDecorationSet: this.buildMergedSet(state.doc, decorationSetsByExtension),\n\t\t\t\t\t\twidgetKeys: unionWidgetKeys(widgetKeysByExtension)\n\t\t\t\t\t};\n\t\t\t\t\tthis.warnDuplicateWidgetKeys(managerState);\n\t\t\t\t\treturn managerState;\n\t\t\t\t},\n\t\t\t\tapply: (tr, previous, oldState, newState) => {\n\t\t\t\t\tconst meta = tr.getMeta(DECORATION_MANAGER_PLUGIN_KEY);\n\t\t\t\t\tconst forceAll = (meta === null || meta === void 0 ? void 0 : meta.type) === \"force\" && !meta.name;\n\t\t\t\t\tconst forceName = (meta === null || meta === void 0 ? void 0 : meta.type) === \"force\" ? meta.name : void 0;\n\t\t\t\t\tconst decorationSetsByExtension = {};\n\t\t\t\t\tconst widgetKeysByExtension = {};\n\t\t\t\t\tconst recomputedNames = /* @__PURE__ */ new Set();\n\t\t\t\t\trunInDecorationApplyScope(editor, () => {\n\t\t\t\t\t\tfor (const { name, spec } of entries) {\n\t\t\t\t\t\t\tconst forced = forceAll || forceName === name;\n\t\t\t\t\t\t\tif (!shouldRecomputeDecoration(spec, {\n\t\t\t\t\t\t\t\teditor,\n\t\t\t\t\t\t\t\ttr,\n\t\t\t\t\t\t\t\toldState,\n\t\t\t\t\t\t\t\tnewState\n\t\t\t\t\t\t\t}, forced)) {\n\t\t\t\t\t\t\t\tconst result = mapDecorations(name, previous, tr);\n\t\t\t\t\t\t\t\tdecorationSetsByExtension[name] = result.set;\n\t\t\t\t\t\t\t\twidgetKeysByExtension[name] = result.widgetKeys;\n\t\t\t\t\t\t\t} else if (spec.update === \"changedRanges\" && tr.docChanged && !forced) {\n\t\t\t\t\t\t\t\tconst result = this.applyChangedRangesRecompute(name, spec, previous, tr, newState);\n\t\t\t\t\t\t\t\tdecorationSetsByExtension[name] = result.set;\n\t\t\t\t\t\t\t\twidgetKeysByExtension[name] = result.widgetKeys;\n\t\t\t\t\t\t\t\trecomputedNames.add(name);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tconst { set, widgetKeys } = this.buildFullSet(name, spec, newState);\n\t\t\t\t\t\t\t\tdecorationSetsByExtension[name] = set;\n\t\t\t\t\t\t\t\twidgetKeysByExtension[name] = widgetKeys;\n\t\t\t\t\t\t\t\trecomputedNames.add(name);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tif (recomputedNames.size === 0 && !tr.docChanged) return previous;\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdecorationSetsByExtension,\n\t\t\t\t\t\twidgetKeysByExtension,\n\t\t\t\t\t\tmergedDecorationSet: this.mergeAfterApply({\n\t\t\t\t\t\t\tentries,\n\t\t\t\t\t\t\tprevious,\n\t\t\t\t\t\t\ttr,\n\t\t\t\t\t\t\tdecorationSetsByExtension,\n\t\t\t\t\t\t\trecomputedNames\n\t\t\t\t\t\t}),\n\t\t\t\t\t\twidgetKeys: unionWidgetKeys(widgetKeysByExtension)\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t},\n\t\t\tprops: { decorations(state) {\n\t\t\t\tvar _DECORATION_MANAGER_P3, _DECORATION_MANAGER_P4;\n\t\t\t\treturn (_DECORATION_MANAGER_P3 = (_DECORATION_MANAGER_P4 = DECORATION_MANAGER_PLUGIN_KEY.getState(state)) === null || _DECORATION_MANAGER_P4 === void 0 ? void 0 : _DECORATION_MANAGER_P4.mergedDecorationSet) !== null && _DECORATION_MANAGER_P3 !== void 0 ? _DECORATION_MANAGER_P3 : _tiptap_pm_view.DecorationSet.empty;\n\t\t\t} }\n\t\t});\n\t}\n\t/**\n\t* Applies changed ranges recomputation to a decoration set, dropping stale decorations and rebuilding only the touched blocks.\n\t* @param name The name of the decoration extension\n\t* @param spec The decoration spec\n\t* @param previous The previous decoration manager state\n\t* @param tr The transaction to apply\n\t* @param newState The new editor state\n\t* @returns The updated decoration set and widget keys\n\t*/\n\tapplyChangedRangesRecompute(name, spec, previous, tr, newState) {\n\t\tconst resolution = getRebuildRanges(tr, newState.doc);\n\t\tif (resolution.type === \"full\") return this.buildFullSet(name, spec, newState);\n\t\treturn this.rebuildRanges(name, spec, previous, tr, newState, resolution.ranges);\n\t}\n\t/**\n\t* Rebuilds decorations for the changed block ranges: maps the previous set\n\t* forward, then for each range removes stale decorations, calls\n\t* `createInRange`, and adds the new ones while syncing widget keys.\n\t* @param name The extension name.\n\t* @param spec The decoration spec.\n\t* @param previous The previous decoration manager state.\n\t* @param tr The transaction to apply.\n\t* @param newState The new editor state.\n\t* @param ranges The block ranges to rebuild.\n\t* @returns The updated decoration set and widget keys.\n\t*/\n\trebuildRanges(name, spec, previous, tr, newState, ranges) {\n\t\tvar _previous$decorationS, _previous$widgetKeysB;\n\t\tconst previousSet = (_previous$decorationS = previous.decorationSetsByExtension[name]) !== null && _previous$decorationS !== void 0 ? _previous$decorationS : _tiptap_pm_view.DecorationSet.empty;\n\t\tconst widgetKeys = new Set((_previous$widgetKeysB = previous.widgetKeysByExtension[name]) !== null && _previous$widgetKeysB !== void 0 ? _previous$widgetKeysB : []);\n\t\tlet set = mapDecorationSet(previousSet, tr.mapping, tr.doc, widgetKeys);\n\t\tconst docSize = newState.doc.content.size;\n\t\tfor (const { from, to } of ranges) {\n\t\t\tconst stale = set.find(from, to).filter((decoration) => rangeOwnsPosition({\n\t\t\t\tposition: decoration.from,\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t\tdocSize\n\t\t\t}));\n\t\t\tfor (const decoration of stale) {\n\t\t\t\tconst key = widgetKeyOf(decoration);\n\t\t\t\tif (key) widgetKeys.delete(key);\n\t\t\t}\n\t\t\tset = set.remove(stale);\n\t\t\tconst { decorations: pmDecorations, widgetKeys: addedKeys } = decorationsToPMDecorations(filterOutOfRangeDecorations({\n\t\t\t\tdecorations: this.runCreate(name, \"createInRange\", () => spec.createInRange({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tstate: newState,\n\t\t\t\t\tview: this.mountedView,\n\t\t\t\t\tfrom,\n\t\t\t\t\tto\n\t\t\t\t})),\n\t\t\t\tfrom,\n\t\t\t\tto,\n\t\t\t\tdocSize,\n\t\t\t\textensionName: name,\n\t\t\t\twarnedExtensions: this.warnedOutOfRangeExtensions\n\t\t\t}), name);\n\t\t\tset = set.add(newState.doc, pmDecorations);\n\t\t\tfor (const key of addedKeys) widgetKeys.add(key);\n\t\t}\n\t\treturn {\n\t\t\tset,\n\t\t\twidgetKeys\n\t\t};\n\t}\n\t/**\n\t* Builds a full decoration set for the entire document.\n\t* @param name The name of the decoration extension\n\t* @param spec The decoration spec\n\t* @param state The editor state\n\t* @returns The decoration set and widget keys\n\t*/\n\tbuildFullSet(name, spec, state) {\n\t\tconst decorations = this.runCreate(name, \"create\", () => spec.create({\n\t\t\teditor: this.editor,\n\t\t\tstate,\n\t\t\tview: this.mountedView\n\t\t}));\n\t\treturn buildDecorationSet(state.doc, decorations, name);\n\t}\n\t/**\n\t* Runs a decoration callback and swallows anything it throws. These run inside\n\t* `state.apply`, where an uncaught error would abort the whole transaction.\n\t* @param name The extension name.\n\t* @param method The callback name, used in the error message.\n\t* @param create The callback to run.\n\t* @returns The decorations, or an empty array if the callback threw.\n\t*/\n\trunCreate(name, method, create) {\n\t\ttry {\n\t\t\treturn create();\n\t\t} catch (error) {\n\t\t\tconsole.error(`[tiptap error]: Extension \"${name}\" threw in \\`addDecorations().${method}()\\`. Its decorations were dropped for this update.`, error);\n\t\t\treturn [];\n\t\t}\n\t}\n\twarnDuplicateWidgetKeys(state) {\n\t\tif (!isDev) return;\n\t\tif (state.widgetKeys.size === 0) {\n\t\t\tthis.warnedWidgetKeys.clear();\n\t\t\treturn;\n\t\t}\n\t\tconst duplicateKeys = findDuplicateWidgetKeys(state.mergedDecorationSet);\n\t\tconst nextWarningKeys = new Set(duplicateKeys.map(({ key }) => key));\n\t\tfor (const { key, extensions } of duplicateKeys) {\n\t\t\tif (this.warnedWidgetKeys.has(key)) continue;\n\t\t\tconst names = Array.from(extensions).map((name) => `\"${name}\"`).join(\", \");\n\t\t\tconsole.warn(`[tiptap warn]: Duplicate widget decoration key \"${key}\" in extension${extensions.size === 1 ? \"\" : \"s\"} ${names}. Widget decoration keys must be globally unique, otherwise ProseMirror misplaces the widget DOM. Use a stable, unique key (e.g. \\`comment-\\${id}\\`).`);\n\t\t}\n\t\tthis.warnedWidgetKeys = nextWarningKeys;\n\t}\n\t/**\n\t* Builds the merged DecorationSet during init. Skips the merge for a\n\t* single extension since its per-extension set is already correct.\n\t* @param doc The document to build the merged set for.\n\t* @param decorationSetsByExtension The per-extension decoration sets.\n\t* @returns The merged decoration set.\n\t*/\n\tbuildMergedSet(doc, decorationSetsByExtension) {\n\t\tconst names = Object.keys(decorationSetsByExtension);\n\t\tif (names.length === 1) return decorationSetsByExtension[names[0]];\n\t\treturn mergeDecorationSets(doc, decorationSetsByExtension);\n\t}\n\t/**\n\t* Computes the merged DecorationSet after apply. Single extension skips the\n\t* merge; nothing recomputed maps the previous merged set forward; otherwise\n\t* the merge is rebuilt from the per-extension sets.\n\t*/\n\tmergeAfterApply({ entries, previous, tr, decorationSetsByExtension, recomputedNames }) {\n\t\tif (entries.length === 1) return decorationSetsByExtension[entries[0].name];\n\t\tif (recomputedNames.size === 0) return previous.mergedDecorationSet.map(tr.mapping, tr.doc);\n\t\treturn mergeDecorationSets(tr.doc, decorationSetsByExtension);\n\t}\n};\n//#endregion\n//#region src/utilities/attrsEqual.ts\n/**\n* Compare two attribute objects for equality.\n* Handles null/undefined and asserts key presence in both objects so that\n* `{ foo: undefined }` and `{ bar: undefined }` are not treated as equal.\n*/\nfunction attrsEqual(a, b) {\n\tif (a === b) return true;\n\tif (!a || !b) return false;\n\tconst keysA = Object.keys(a);\n\tconst keysB = Object.keys(b);\n\tif (keysA.length !== keysB.length) return false;\n\treturn keysA.every((key) => Object.prototype.hasOwnProperty.call(b, key) && Object.is(a[key], b[key]));\n}\n//#endregion\n//#region src/utilities/canInsertNode.ts\nfunction canInsertNode(state, nodeType) {\n\tconst { selection } = state;\n\tconst { $from } = selection;\n\tif (selection instanceof _tiptap_pm_state.NodeSelection) {\n\t\tconst index = $from.index();\n\t\treturn $from.parent.canReplaceWith(index, index + 1, nodeType);\n\t}\n\tlet depth = $from.depth;\n\twhile (depth >= 0) {\n\t\tconst index = $from.index(depth);\n\t\tif ($from.node(depth).contentMatchAt(index).matchType(nodeType)) return true;\n\t\tdepth -= 1;\n\t}\n\treturn false;\n}\n//#endregion\n//#region src/utilities/createStyleTag.ts\nfunction createStyleTag(style, nonce, suffix) {\n\tconst tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : \"\"}]`);\n\tif (tiptapStyleTag !== null) return tiptapStyleTag;\n\tconst styleNode = document.createElement(\"style\");\n\tif (nonce) styleNode.setAttribute(\"nonce\", nonce);\n\tstyleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : \"\"}`, \"\");\n\tstyleNode.innerHTML = style;\n\tdocument.getElementsByTagName(\"head\")[0].appendChild(styleNode);\n\treturn styleNode;\n}\n//#endregion\n//#region src/utilities/escapeForRegEx.ts\nfunction escapeForRegEx(string) {\n\treturn string.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\");\n}\n//#endregion\n//#region src/utilities/getStyleProperty.ts\n/**\n* Read a CSS property value directly from an element's raw inline `style`\n* attribute, bypassing the CSSOM (e.g. `element.style.fontFamily`) which\n* canonicalizes values and can change formatting. The original format is\n* preserved (quotes, hex vs rgb, etc.).\n*\n* When a property is declared more than once, the last declaration wins —\n* this matches CSS cascade order and is useful when nested spans are merged\n* and the child's value should take priority.\n*\n* Property name comparison is case-insensitive.\n*\n* @param element - The element whose `style` attribute should be read.\n* @param propertyName - The CSS property name (e.g. `font-family`).\n* @returns The raw value string, or `null` if the property is not present.\n*\n* @example\n* ```ts\n* parseHTML: element => getStyleProperty(element, 'font-family')\n* ```\n*/\nfunction getStyleProperty(element, propertyName) {\n\tconst styleAttr = element.getAttribute(\"style\");\n\tif (!styleAttr) return null;\n\tconst decls = styleAttr.split(\";\").map((decl) => decl.trim()).filter(Boolean);\n\tconst target = propertyName.toLowerCase();\n\tfor (let i = decls.length - 1; i >= 0; i -= 1) {\n\t\tconst decl = decls[i];\n\t\tconst colonIndex = decl.indexOf(\":\");\n\t\tif (colonIndex === -1) continue;\n\t\tif (decl.slice(0, colonIndex).trim().toLowerCase() === target) return decl.slice(colonIndex + 1).trim();\n\t}\n\treturn null;\n}\n//#endregion\n//#region src/utilities/htmlEntities.ts\n/**\n* Decode common HTML entities in text content so they display as literal\n* characters inside the editor. The decode order matters: `&amp;` must be\n* decoded **last** so that doubly-encoded sequences like `&amp;lt;` first\n* survive the `&lt;` pass and then correctly become `&lt;` (not `<`).\n*/\nfunction decodeHtmlEntities(text) {\n\treturn text.replace(/&lt;/g, \"<\").replace(/&gt;/g, \">\").replace(/&quot;/g, \"\\\"\").replace(/&amp;/g, \"&\");\n}\n/**\n* Encode HTML special characters so they roundtrip safely through markdown.\n* `&` is encoded **first** to avoid double-encoding the ampersand in other\n* entities (e.g. `<` → `&lt;`, not `&amp;lt;`).\n*\n* Note: `\"` is intentionally NOT encoded here because double quotes are\n* ordinary characters in markdown and do not need escaping. The decode\n* function still handles `&quot;` because the markdown tokenizer may emit it.\n*/\nfunction encodeHtmlEntities(text) {\n\treturn text.replace(/&/g, \"&amp;\").replace(/</g, \"&lt;\").replace(/>/g, \"&gt;\");\n}\n//#endregion\n//#region src/utilities/isFirefox.ts\n/**\n* Detects if the current browser is Firefox.\n* @returns `true` if the browser is Firefox, `false` otherwise.\n* @example\n* if (isFirefox()) {\n* // Firefox-specific handling\n* }\n*/\nfunction isFirefox() {\n\treturn typeof navigator !== \"undefined\" ? /Firefox/.test(navigator.userAgent) : false;\n}\n//#endregion\n//#region src/utilities/isNumber.ts\nfunction isNumber(value) {\n\treturn typeof value === \"number\";\n}\n//#endregion\n//#region src/utilities/isPlainObject.ts\nfunction getType(value) {\n\treturn Object.prototype.toString.call(value).slice(8, -1);\n}\nfunction isPlainObject(value) {\n\tif (getType(value) !== \"Object\") return false;\n\treturn value.constructor === Object && Object.getPrototypeOf(value) === Object.prototype;\n}\n//#endregion\n//#region src/utilities/isString.ts\nfunction isString(value) {\n\treturn typeof value === \"string\";\n}\n//#endregion\n//#region src/utilities/markdown/tokenizeAttributes.ts\nfunction isWhitespace(character) {\n\treturn /\\s/.test(character);\n}\nfunction isAsciiLetter(character) {\n\treturn /^[a-zA-Z]$/.test(character);\n}\nfunction isWordCharacter(character) {\n\treturn /^\\w$/.test(character);\n}\nfunction skipWhitespace(input, index) {\n\twhile (index < input.length && isWhitespace(input[index])) index += 1;\n\treturn index;\n}\nfunction skipToWhitespace(input, index) {\n\twhile (index < input.length && !isWhitespace(input[index])) index += 1;\n\treturn index;\n}\nfunction readName(input, index, allowHyphen) {\n\twhile (index < input.length && (isWordCharacter(input[index]) || allowHyphen && input[index] === \"-\")) index += 1;\n\treturn index;\n}\nfunction readShorthand(input, index) {\n\tconst prefix = input[index];\n\tconst nameStart = index + 1;\n\tconst nameEnd = readName(input, nameStart, true);\n\tif (nameEnd === nameStart) return { nextIndex: skipToWhitespace(input, nameEnd) };\n\treturn {\n\t\ttoken: {\n\t\t\ttype: prefix === \".\" ? \"class\" : \"id\",\n\t\t\tname: input.slice(nameStart, nameEnd)\n\t\t},\n\t\tnextIndex: skipToWhitespace(input, nameEnd)\n\t};\n}\nfunction readQuotedSegment(input, index) {\n\tconst closingQuote = input.indexOf(input[index], index + 1);\n\treturn { nextIndex: skipToWhitespace(input, closingQuote === -1 ? index : closingQuote + 1) };\n}\nfunction readKeyValue(input, name, index, allowWhitespace) {\n\tlet valueStart = allowWhitespace ? skipWhitespace(input, index) : index;\n\tif (input[valueStart] !== \"=\") return;\n\tvalueStart = allowWhitespace ? skipWhitespace(input, valueStart + 1) : valueStart + 1;\n\tconst quote = input[valueStart];\n\tif (quote !== \"\\\"\" && quote !== \"'\") return;\n\tconst valueEnd = input.indexOf(quote, valueStart + 1);\n\tif (valueEnd === -1) return;\n\treturn {\n\t\ttoken: {\n\t\t\ttype: \"keyValue\",\n\t\t\tname,\n\t\t\tvalue: input.slice(valueStart + 1, valueEnd)\n\t\t},\n\t\tnextIndex: skipToWhitespace(input, valueEnd + 1)\n\t};\n}\nfunction readNamedAttribute(input, index, syntax) {\n\tconst isPandoc = syntax === \"pandoc\";\n\tconst nameEnd = readName(input, index + 1, isPandoc);\n\tconst name = input.slice(index, nameEnd);\n\tconst keyValue = readKeyValue(input, name, nameEnd, isPandoc);\n\tif (keyValue) return keyValue;\n\tconst isStandalone = nameEnd === input.length || isWhitespace(input[nameEnd]);\n\treturn {\n\t\ttoken: isPandoc && isStandalone ? {\n\t\t\ttype: \"boolean\",\n\t\t\tname\n\t\t} : void 0,\n\t\tnextIndex: syntax === \"shortcode\" ? skipToWhitespace(input, nameEnd) : nameEnd\n\t};\n}\nfunction readAttribute(input, index, syntax) {\n\tconst prefix = input[index];\n\tif (syntax === \"pandoc\" && (prefix === \".\" || prefix === \"#\")) return readShorthand(input, index);\n\tif (prefix === \"\\\"\" || prefix === \"'\") return readQuotedSegment(input, index);\n\tif (syntax === \"pandoc\" ? isAsciiLetter(prefix) : isWordCharacter(prefix)) return readNamedAttribute(input, index, syntax);\n\treturn { nextIndex: skipToWhitespace(input, index) };\n}\nfunction tokenizeAttributes(input, syntax) {\n\tconst tokens = [];\n\tlet index = 0;\n\twhile (index < input.length) {\n\t\tindex = skipWhitespace(input, index);\n\t\tif (index >= input.length) break;\n\t\tconst result = readAttribute(input, index, syntax);\n\t\tif (result.token) tokens.push(result.token);\n\t\tindex = result.nextIndex;\n\t}\n\treturn tokens;\n}\n//#endregion\n//#region src/utilities/markdown/parseAttributes.ts\nfunction applyTokens(tokens) {\n\tconst attributes = {};\n\tconst classes = tokens.filter((token) => token.type === \"class\").map((token) => token.name);\n\tconst id = tokens.find((token) => token.type === \"id\");\n\tif (classes.length > 0) attributes.class = classes.join(\" \");\n\tif (id) attributes.id = id.name;\n\ttokens.forEach((token) => {\n\t\tif (token.type === \"keyValue\") attributes[token.name] = token.value;\n\t});\n\ttokens.forEach((token) => {\n\t\tif (token.type === \"boolean\") attributes[token.name] = true;\n\t});\n\treturn attributes;\n}\n/**\n* Parses a Pandoc-style attribute string into an object.\n*\n* @param attrString - The attribute string to parse\n* @returns Parsed attributes object\n*\n* @example\n* ```ts\n* parseAttributes('.btn #submit disabled type=\"button\"')\n* // { class: 'btn', id: 'submit', disabled: true, type: 'button' }\n* ```\n*/\nfunction parseAttributes(attrString) {\n\tif (!(attrString === null || attrString === void 0 ? void 0 : attrString.trim())) return {};\n\treturn applyTokens(tokenizeAttributes(attrString, \"pandoc\"));\n}\n//#endregion\n//#region src/utilities/markdown/serializeAttributes.ts\n/**\n* Serializes an attributes object to a Pandoc-style attribute string.\n*\n* @param attributes - The attributes object to serialize\n* @returns Serialized attribute string\n*\n* @example\n* ```ts\n* serializeAttributes({ class: 'btn primary', id: 'submit', disabled: true, type: 'button' })\n* // '.btn .primary #submit disabled type=\"button\"'\n* ```\n*/\nfunction serializeAttributes(attributes) {\n\tif (!attributes || Object.keys(attributes).length === 0) return \"\";\n\tconst parts = [];\n\tif (attributes.class) String(attributes.class).split(/\\s+/).filter(Boolean).forEach((className) => parts.push(`.${className}`));\n\tif (attributes.id) parts.push(`#${attributes.id}`);\n\tObject.entries(attributes).forEach(([key, value]) => {\n\t\tif (key === \"class\" || key === \"id\") return;\n\t\tif (value === true) parts.push(key);\n\t\telse if (value !== false && value != null) parts.push(`${key}=\"${String(value)}\"`);\n\t});\n\treturn parts.join(\" \");\n}\n//#endregion\n//#region src/utilities/markdown/createAtomBlockMarkdownSpec.ts\n/**\n* Creates a complete markdown spec for atomic block nodes using Pandoc syntax.\n*\n* The generated spec handles:\n* - Parsing self-closing blocks with `:::blockName {attributes}`\n* - Extracting and parsing attributes\n* - Validating required attributes\n* - Rendering blocks back to markdown\n*\n* @param options - Configuration for the atomic block markdown spec\n* @returns Complete markdown specification object\n*\n* @example\n* ```ts\n* const youtubeSpec = createAtomBlockMarkdownSpec({\n* nodeName: 'youtube',\n* requiredAttributes: ['src'],\n* defaultAttributes: { start: 0 },\n* allowedAttributes: ['src', 'start', 'width', 'height'] // Only these get rendered to markdown\n* })\n*\n* // Usage in extension:\n* export const Youtube = Node.create({\n* // ... other config\n* markdown: youtubeSpec\n* })\n* ```\n*/\nfunction createAtomBlockMarkdownSpec(options) {\n\tconst { nodeName, name: markdownName, parseAttributes: parseAttributes$2 = parseAttributes, serializeAttributes: serializeAttributes$2 = serializeAttributes, defaultAttributes = {}, requiredAttributes = [], allowedAttributes } = options;\n\tconst blockName = markdownName || nodeName;\n\tconst filterAttributes = (attrs) => {\n\t\tif (!allowedAttributes) return attrs;\n\t\tconst filtered = {};\n\t\tallowedAttributes.forEach((key) => {\n\t\t\tif (key in attrs) filtered[key] = attrs[key];\n\t\t});\n\t\treturn filtered;\n\t};\n\treturn {\n\t\tparseMarkdown: (token, h) => {\n\t\t\tconst attrs = {\n\t\t\t\t...defaultAttributes,\n\t\t\t\t...token.attributes\n\t\t\t};\n\t\t\treturn h.createNode(nodeName, attrs, []);\n\t\t},\n\t\tmarkdownTokenizer: {\n\t\t\tname: nodeName,\n\t\t\tlevel: \"block\",\n\t\t\tstart(src) {\n\t\t\t\tvar _src$match;\n\t\t\t\tconst regex = new RegExp(`^:::${blockName}(?:\\\\s|$)`, \"m\");\n\t\t\t\tconst index = (_src$match = src.match(regex)) === null || _src$match === void 0 ? void 0 : _src$match.index;\n\t\t\t\treturn index !== void 0 ? index : -1;\n\t\t\t},\n\t\t\ttokenize(src, _tokens, _lexer) {\n\t\t\t\tconst regex = new RegExp(`^:::${blockName}(?:\\\\s+\\\\{([^}]*)\\\\})?\\\\s*:::(?:\\\\n|$)`);\n\t\t\t\tconst match = src.match(regex);\n\t\t\t\tif (!match) return;\n\t\t\t\tconst attrString = match[1] || \"\";\n\t\t\t\tconst attributes = parseAttributes$2(attrString);\n\t\t\t\tif (requiredAttributes.find((required) => !(required in attributes))) return;\n\t\t\t\treturn {\n\t\t\t\t\ttype: nodeName,\n\t\t\t\t\traw: match[0],\n\t\t\t\t\tattributes\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\trenderMarkdown: (node) => {\n\t\t\tconst filteredAttrs = filterAttributes(node.attrs || {});\n\t\t\tconst attrs = serializeAttributes$2(filteredAttrs);\n\t\t\tconst attrString = attrs ? ` {${attrs}}` : \"\";\n\t\t\treturn `:::${blockName}${attrString} :::`;\n\t\t}\n\t};\n}\n//#endregion\n//#region src/utilities/markdown/createBlockMarkdownSpec.ts\n/**\n* Creates a complete markdown spec for block-level nodes using Pandoc syntax.\n*\n* The generated spec handles:\n* - Parsing blocks with `:::blockName {attributes}` syntax\n* - Extracting and parsing attributes\n* - Rendering blocks back to markdown with proper formatting\n* - Nested content support\n*\n* @param options - Configuration for the block markdown spec\n* @returns Complete markdown specification object\n*\n* @example\n* ```ts\n* const calloutSpec = createBlockMarkdownSpec({\n* nodeName: 'callout',\n* defaultAttributes: { type: 'info' },\n* allowedAttributes: ['type', 'title'] // Only these get rendered to markdown\n* })\n*\n* // Usage in extension:\n* export const Callout = Node.create({\n* // ... other config\n* markdown: calloutSpec\n* })\n* ```\n*/\nfunction createBlockMarkdownSpec(options) {\n\tconst { nodeName, name: markdownName, getContent, parseAttributes: parseAttributes$1 = parseAttributes, serializeAttributes: serializeAttributes$1 = serializeAttributes, defaultAttributes = {}, content = \"block\", allowedAttributes } = options;\n\tconst blockName = markdownName || nodeName;\n\tconst filterAttributes = (attrs) => {\n\t\tif (!allowedAttributes) return attrs;\n\t\tconst filtered = {};\n\t\tallowedAttributes.forEach((key) => {\n\t\t\tif (key in attrs) filtered[key] = attrs[key];\n\t\t});\n\t\treturn filtered;\n\t};\n\treturn {\n\t\tparseMarkdown: (token, h) => {\n\t\t\tlet nodeContent;\n\t\t\tif (getContent) {\n\t\t\t\tconst contentResult = getContent(token);\n\t\t\t\tnodeContent = typeof contentResult === \"string\" ? [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: contentResult\n\t\t\t\t}] : contentResult;\n\t\t\t} else if (content === \"block\") nodeContent = h.parseChildren(token.tokens || []);\n\t\t\telse nodeContent = h.parseInline(token.tokens || []);\n\t\t\tconst attrs = {\n\t\t\t\t...defaultAttributes,\n\t\t\t\t...token.attributes\n\t\t\t};\n\t\t\treturn h.createNode(nodeName, attrs, nodeContent);\n\t\t},\n\t\tmarkdownTokenizer: {\n\t\t\tname: nodeName,\n\t\t\tlevel: \"block\",\n\t\t\tstart(src) {\n\t\t\t\tvar _src$match;\n\t\t\t\tconst regex = new RegExp(`^:::${blockName}`, \"m\");\n\t\t\t\tconst index = (_src$match = src.match(regex)) === null || _src$match === void 0 ? void 0 : _src$match.index;\n\t\t\t\treturn index !== void 0 ? index : -1;\n\t\t\t},\n\t\t\ttokenize(src, _tokens, lexer) {\n\t\t\t\tconst openingRegex = new RegExp(`^:::${blockName}(?:\\\\s+\\\\{([^}]*)\\\\})?\\\\s*\\\\n`);\n\t\t\t\tconst openingMatch = src.match(openingRegex);\n\t\t\t\tif (!openingMatch) return;\n\t\t\t\tconst [openingTag, attrString = \"\"] = openingMatch;\n\t\t\t\tconst attributes = parseAttributes$1(attrString);\n\t\t\t\tlet level = 1;\n\t\t\t\tconst position = openingTag.length;\n\t\t\t\tlet matchedContent = \"\";\n\t\t\t\tconst blockPattern = /^:::([\\w-]*)(\\s.*)?/gm;\n\t\t\t\tconst remaining = src.slice(position);\n\t\t\t\tblockPattern.lastIndex = 0;\n\t\t\t\tfor (;;) {\n\t\t\t\t\tvar _match$;\n\t\t\t\t\tconst match = blockPattern.exec(remaining);\n\t\t\t\t\tif (match === null) break;\n\t\t\t\t\tconst matchPos = match.index;\n\t\t\t\t\tconst blockType = match[1];\n\t\t\t\t\tif ((_match$ = match[2]) === null || _match$ === void 0 ? void 0 : _match$.endsWith(\":::\")) continue;\n\t\t\t\t\tif (blockType) level += 1;\n\t\t\t\t\telse {\n\t\t\t\t\t\tlevel -= 1;\n\t\t\t\t\t\tif (level === 0) {\n\t\t\t\t\t\t\tconst rawContent = remaining.slice(0, matchPos);\n\t\t\t\t\t\t\tmatchedContent = rawContent.trim();\n\t\t\t\t\t\t\tconst fullMatch = src.slice(0, position + matchPos + match[0].length);\n\t\t\t\t\t\t\tlet contentTokens = [];\n\t\t\t\t\t\t\tif (matchedContent) {\n\t\t\t\t\t\t\t\tif (content === \"block\") {\n\t\t\t\t\t\t\t\t\tcontentTokens = lexer.blockTokens(rawContent);\n\t\t\t\t\t\t\t\t\tcontentTokens.forEach((token) => {\n\t\t\t\t\t\t\t\t\t\tif (token.text && (!token.tokens || token.tokens.length === 0)) token.tokens = lexer.inlineTokens(token.text);\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\twhile (contentTokens.length > 0) {\n\t\t\t\t\t\t\t\t\t\tconst lastToken = contentTokens[contentTokens.length - 1];\n\t\t\t\t\t\t\t\t\t\tif (lastToken.type === \"paragraph\" && (!lastToken.text || lastToken.text.trim() === \"\")) contentTokens.pop();\n\t\t\t\t\t\t\t\t\t\telse break;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} else contentTokens = lexer.inlineTokens(matchedContent);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\ttype: nodeName,\n\t\t\t\t\t\t\t\traw: fullMatch,\n\t\t\t\t\t\t\t\tattributes,\n\t\t\t\t\t\t\t\tcontent: matchedContent,\n\t\t\t\t\t\t\t\ttokens: contentTokens\n\t\t\t\t\t\t\t};\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t},\n\t\trenderMarkdown: (node, h) => {\n\t\t\tconst filteredAttrs = filterAttributes(node.attrs || {});\n\t\t\tconst attrs = serializeAttributes$1(filteredAttrs);\n\t\t\tconst attrString = attrs ? ` {${attrs}}` : \"\";\n\t\t\tconst renderedContent = h.renderChildren(node.content || [], \"\\n\\n\");\n\t\t\treturn `:::${blockName}${attrString}\\n\\n${renderedContent}\\n\\n:::`;\n\t\t}\n\t};\n}\n//#endregion\n//#region src/utilities/markdown/parseShortcodeAttributes.ts\nfunction parseShortcodeAttributes(attrString) {\n\tconst attributes = {};\n\ttokenizeAttributes(attrString, \"shortcode\").forEach((token) => {\n\t\tif (token.type === \"keyValue\") attributes[token.name] = token.value;\n\t});\n\treturn attributes;\n}\n//#endregion\n//#region src/utilities/markdown/createInlineMarkdownSpec.ts\n/**\n* Serialize attributes back to shortcode format\n* Always quotes all values with double quotes\n*/\nfunction serializeShortcodeAttributes(attrs) {\n\treturn Object.entries(attrs).filter(([, value]) => value !== void 0 && value !== null).map(([key, value]) => `${key}=\"${value}\"`).join(\" \");\n}\n/**\n* Creates a complete markdown spec for inline nodes using attribute syntax.\n*\n* The generated spec handles:\n* - Parsing shortcode syntax with `[nodeName attributes]content[/nodeName]` format\n* - Self-closing shortcodes like `[emoji name=party_popper]`\n* - Extracting and parsing attributes from the opening tag\n* - Rendering inline elements back to shortcode markdown\n* - Supporting both content-based and self-closing inline elements\n*\n* @param options - Configuration for the inline markdown spec\n* @returns Complete markdown specification object\n*\n* @example\n* ```ts\n* // Self-closing mention: [mention id=\"madonna\" label=\"Madonna\"]\n* const mentionSpec = createInlineMarkdownSpec({\n* nodeName: 'mention',\n* selfClosing: true,\n* defaultAttributes: { type: 'user' },\n* allowedAttributes: ['id', 'label'] // Only these get rendered to markdown\n* })\n*\n* // Self-closing emoji: [emoji name=\"party_popper\"]\n* const emojiSpec = createInlineMarkdownSpec({\n* nodeName: 'emoji',\n* selfClosing: true,\n* allowedAttributes: ['name']\n* })\n*\n* // With content: [highlight color=\"yellow\"]text[/highlight]\n* const highlightSpec = createInlineMarkdownSpec({\n* nodeName: 'highlight',\n* selfClosing: false,\n* allowedAttributes: ['color', 'style']\n* })\n*\n* // Usage in extension:\n* export const Mention = Node.create({\n* name: 'mention', // Must match nodeName\n* // ... other config\n* markdown: mentionSpec\n* })\n* ```\n*/\nfunction createInlineMarkdownSpec(options) {\n\tconst { nodeName, name: shortcodeName, getContent, parseAttributes = parseShortcodeAttributes, serializeAttributes = serializeShortcodeAttributes, defaultAttributes = {}, selfClosing = false, allowedAttributes } = options;\n\tconst shortcode = shortcodeName || nodeName;\n\tconst filterAttributes = (attrs) => {\n\t\tif (!allowedAttributes) return attrs;\n\t\tconst filtered = {};\n\t\tallowedAttributes.forEach((attr) => {\n\t\t\tconst attrName = typeof attr === \"string\" ? attr : attr.name;\n\t\t\tconst skipIfDefault = typeof attr === \"string\" ? void 0 : attr.skipIfDefault;\n\t\t\tif (attrName in attrs) {\n\t\t\t\tconst value = attrs[attrName];\n\t\t\t\tif (skipIfDefault !== void 0 && value === skipIfDefault) return;\n\t\t\t\tfiltered[attrName] = value;\n\t\t\t}\n\t\t});\n\t\treturn filtered;\n\t};\n\tconst escapedShortcode = shortcode.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\treturn {\n\t\tparseMarkdown: (token, h) => {\n\t\t\tconst attrs = {\n\t\t\t\t...defaultAttributes,\n\t\t\t\t...token.attributes\n\t\t\t};\n\t\t\tif (selfClosing) return h.createNode(nodeName, attrs);\n\t\t\tconst content = getContent ? getContent(token) : token.content || \"\";\n\t\t\tif (content) return h.createNode(nodeName, attrs, [h.createTextNode(content)]);\n\t\t\treturn h.createNode(nodeName, attrs, []);\n\t\t},\n\t\tmarkdownTokenizer: {\n\t\t\tname: nodeName,\n\t\t\tlevel: \"inline\",\n\t\t\tstart(src) {\n\t\t\t\tconst startPattern = selfClosing ? new RegExp(`\\\\[${escapedShortcode}\\\\s*[^\\\\]]*\\\\]`) : new RegExp(`\\\\[${escapedShortcode}\\\\s*[^\\\\]]*\\\\][\\\\s\\\\S]*?\\\\[\\\\/${escapedShortcode}\\\\]`);\n\t\t\t\tconst match = src.match(startPattern);\n\t\t\t\tconst index = match === null || match === void 0 ? void 0 : match.index;\n\t\t\t\treturn index !== void 0 ? index : -1;\n\t\t\t},\n\t\t\ttokenize(src, _tokens, _lexer) {\n\t\t\t\tconst tokenPattern = selfClosing ? new RegExp(`^\\\\[${escapedShortcode}\\\\s*([^\\\\]]*)\\\\]`) : new RegExp(`^\\\\[${escapedShortcode}\\\\s*([^\\\\]]*)\\\\]([\\\\s\\\\S]*?)\\\\[\\\\/${escapedShortcode}\\\\]`);\n\t\t\t\tconst match = src.match(tokenPattern);\n\t\t\t\tif (!match) return;\n\t\t\t\tlet content = \"\";\n\t\t\t\tlet attrString = \"\";\n\t\t\t\tif (selfClosing) {\n\t\t\t\t\tconst [, attrs] = match;\n\t\t\t\t\tattrString = attrs;\n\t\t\t\t} else {\n\t\t\t\t\tconst [, attrs, contentMatch] = match;\n\t\t\t\t\tattrString = attrs;\n\t\t\t\t\tcontent = contentMatch || \"\";\n\t\t\t\t}\n\t\t\t\tconst attributes = parseAttributes(attrString.trim());\n\t\t\t\treturn {\n\t\t\t\t\ttype: nodeName,\n\t\t\t\t\traw: match[0],\n\t\t\t\t\tcontent: content.trim(),\n\t\t\t\t\tattributes\n\t\t\t\t};\n\t\t\t}\n\t\t},\n\t\trenderMarkdown: (node) => {\n\t\t\tlet content = \"\";\n\t\t\tif (getContent) content = getContent(node);\n\t\t\telse if (node.content && node.content.length > 0) content = node.content.filter((child) => child.type === \"text\").map((child) => child.text).join(\"\");\n\t\t\tconst filteredAttrs = filterAttributes(node.attrs || {});\n\t\t\tconst attrs = serializeAttributes(filteredAttrs);\n\t\t\tconst attrString = attrs ? ` ${attrs}` : \"\";\n\t\t\tif (selfClosing) return `[${shortcode}${attrString}]`;\n\t\t\treturn `[${shortcode}${attrString}]${content}[/${shortcode}]`;\n\t\t}\n\t};\n}\n//#endregion\n//#region src/utilities/markdown/parseIndentedBlocks.ts\n/**\n* Parses markdown text into hierarchical indented blocks with proper nesting.\n*\n* This utility handles:\n* - Line-by-line parsing with pattern matching\n* - Hierarchical nesting based on indentation levels\n* - Nested content collection and parsing\n* - Empty line handling\n* - Content dedenting for nested blocks\n*\n* The key difference from flat parsing is that this maintains the hierarchical\n* structure where nested items become `nestedTokens` of their parent items,\n* rather than being flattened into a single array.\n*\n* @param src - The markdown source text to parse\n* @param config - Configuration object defining how to parse and create tokens\n* @param lexer - Markdown lexer for parsing nested content\n* @returns Parsed result with hierarchical items, or undefined if no matches\n*\n* @example\n* ```ts\n* const result = parseIndentedBlocks(src, {\n* itemPattern: /^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,\n* extractItemData: (match) => ({\n* indentLevel: match[1].length,\n* mainContent: match[4],\n* checked: match[3].toLowerCase() === 'x'\n* }),\n* createToken: (data, nestedTokens) => ({\n* type: 'taskItem',\n* checked: data.checked,\n* text: data.mainContent,\n* nestedTokens\n* })\n* }, lexer)\n* ```\n*/\nfunction parseIndentedBlocks(src, config, lexer) {\n\tconst lines = src.split(\"\\n\");\n\tconst items = [];\n\tlet totalRaw = \"\";\n\tlet i = 0;\n\tconst baseIndentSize = config.baseIndentSize || 2;\n\twhile (i < lines.length) {\n\t\tconst currentLine = lines[i];\n\t\tconst itemMatch = currentLine.match(config.itemPattern);\n\t\tif (!itemMatch) {\n\t\t\tif (items.length > 0) break;\n\t\t\telse if (currentLine.trim() === \"\") {\n\t\t\t\ti += 1;\n\t\t\t\ttotalRaw = `${totalRaw}${currentLine}\\n`;\n\t\t\t\tcontinue;\n\t\t\t} else return;\n\t\t}\n\t\tconst itemData = config.extractItemData(itemMatch);\n\t\tconst { indentLevel, mainContent } = itemData;\n\t\ttotalRaw = `${totalRaw}${currentLine}\\n`;\n\t\tconst itemContent = [mainContent];\n\t\ti += 1;\n\t\twhile (i < lines.length) {\n\t\t\tvar _nextLine$match;\n\t\t\tconst nextLine = lines[i];\n\t\t\tif (nextLine.trim() === \"\") {\n\t\t\t\tvar _nextNonEmpty$match;\n\t\t\t\tconst nextNonEmptyIndex = lines.slice(i + 1).findIndex((l) => l.trim() !== \"\");\n\t\t\t\tif (nextNonEmptyIndex === -1) break;\n\t\t\t\tif ((((_nextNonEmpty$match = lines[i + 1 + nextNonEmptyIndex].match(/^(\\s*)/)) === null || _nextNonEmpty$match === void 0 || (_nextNonEmpty$match = _nextNonEmpty$match[1]) === null || _nextNonEmpty$match === void 0 ? void 0 : _nextNonEmpty$match.length) || 0) > indentLevel) {\n\t\t\t\t\titemContent.push(nextLine);\n\t\t\t\t\ttotalRaw = `${totalRaw}${nextLine}\\n`;\n\t\t\t\t\ti += 1;\n\t\t\t\t\tcontinue;\n\t\t\t\t} else break;\n\t\t\t}\n\t\t\tif ((((_nextLine$match = nextLine.match(/^(\\s*)/)) === null || _nextLine$match === void 0 || (_nextLine$match = _nextLine$match[1]) === null || _nextLine$match === void 0 ? void 0 : _nextLine$match.length) || 0) > indentLevel) {\n\t\t\t\titemContent.push(nextLine);\n\t\t\t\ttotalRaw = `${totalRaw}${nextLine}\\n`;\n\t\t\t\ti += 1;\n\t\t\t} else break;\n\t\t}\n\t\tlet nestedTokens;\n\t\tconst nestedContent = itemContent.slice(1);\n\t\tif (nestedContent.length > 0) {\n\t\t\tconst dedentedNested = nestedContent.map((nestedLine) => nestedLine.slice(indentLevel + baseIndentSize)).join(\"\\n\");\n\t\t\tif (dedentedNested.trim()) {\n\t\t\t\tif (config.customNestedParser) nestedTokens = config.customNestedParser(dedentedNested);\n\t\t\t\telse nestedTokens = lexer.blockTokens(dedentedNested);\n\t\t\t}\n\t\t}\n\t\tconst token = config.createToken(itemData, nestedTokens);\n\t\titems.push(token);\n\t}\n\tif (items.length === 0) return;\n\treturn {\n\t\titems,\n\t\traw: totalRaw\n\t};\n}\n//#endregion\n//#region src/utilities/markdown/renderNestedMarkdownContent.ts\n/**\n* @fileoverview Utility functions for rendering nested content in markdown.\n*\n* This module provides reusable utilities for extensions that need to render\n* content with a prefix on the main line and properly indented nested content.\n*/\n/**\n* Utility function for rendering content with a main line prefix and nested indented content.\n*\n* This function handles the common pattern of rendering content with:\n* 1. A main line with a prefix (like \"- \" for lists, \"> \" for blockquotes, etc.)\n* 2. Nested content that gets indented properly\n*\n* @param node - The ProseMirror node representing the content\n* @param h - The markdown renderer helper\n* @param prefixOrGenerator - Either a string prefix or a function that generates the prefix from context\n* @param ctx - Optional context object (used when prefixOrGenerator is a function)\n* @param options - Optional rendering options\n* @param options.alignNestedToPrefix - Indent nested content to the width of the prefix\n* instead of the configured indent size, when the configured one is narrower\n* @returns The rendered markdown string\n*\n* @example\n* ```ts\n* // For a bullet list item with static prefix\n* return renderNestedMarkdownContent(node, h, '- ')\n*\n* // For a task item with static prefix\n* const prefix = `- [${node.attrs?.checked ? 'x' : ' '}] `\n* return renderNestedMarkdownContent(node, h, prefix)\n*\n* // For an ordered list item, where the nested block has to line up with the marker\n* return renderNestedMarkdownContent(node, h, '10. ', ctx, { alignNestedToPrefix: true })\n*\n* // For a blockquote with static prefix\n* return renderNestedMarkdownContent(node, h, '> ')\n*\n* // For content with dynamic prefix based on context\n* return renderNestedMarkdownContent(node, h, ctx => {\n* if (ctx.parentType === 'orderedList') {\n* return `${ctx.index + 1}. `\n* }\n* return '- '\n* }, ctx)\n*\n* // Custom extension example\n* const CustomContainer = Node.create({\n* name: 'customContainer',\n* // ... other config\n* markdown: {\n* render: (node, h) => {\n* const type = node.attrs?.type || 'info'\n* return renderNestedMarkdownContent(node, h, `[${type}] `)\n* }\n* }\n* })\n* ```\n*/\nconst TAB_STOP = 4;\n/** Width of indentation in Markdown columns, where a tab runs to the next tab stop. */\nfunction columnWidth(text) {\n\tlet width = 0;\n\tfor (const character of text) width = character === \"\t\" ? width + TAB_STOP - width % TAB_STOP : width + 1;\n\treturn width;\n}\nfunction renderNestedMarkdownContent(node, h, prefixOrGenerator, ctx, options) {\n\tif (!node || !Array.isArray(node.content)) return \"\";\n\tconst prefix = typeof prefixOrGenerator === \"function\" ? prefixOrGenerator(ctx) : prefixOrGenerator;\n\tconst [content, ...children] = node.content;\n\tlet output = `${prefix}${h.renderChildren([content])}`;\n\tif (children && children.length > 0) children.forEach((child, index) => {\n\t\tvar _h$renderChild, _h$renderChild2;\n\t\tconst childContent = (_h$renderChild = (_h$renderChild2 = h.renderChild) === null || _h$renderChild2 === void 0 ? void 0 : _h$renderChild2.call(h, child, index + 1)) !== null && _h$renderChild !== void 0 ? _h$renderChild : h.renderChildren([child]);\n\t\tif (childContent !== void 0 && childContent !== null) {\n\t\t\tconst indentLine = (line) => {\n\t\t\t\tif (!(options === null || options === void 0 ? void 0 : options.alignNestedToPrefix)) return h.indent(line);\n\t\t\t\tconst configured = h.indent(\"\");\n\t\t\t\tconst prefixWidth = columnWidth(prefix);\n\t\t\t\treturn (columnWidth(configured) >= prefixWidth ? configured : \" \".repeat(prefixWidth)) + line;\n\t\t\t};\n\t\t\tconst indentedChild = childContent.split(\"\\n\").map((line) => line ? indentLine(line) : indentLine(\"\")).join(\"\\n\");\n\t\t\toutput += child.type === \"paragraph\" ? `\\n\\n${indentedChild}` : `\\n${indentedChild}`;\n\t\t}\n\t});\n\treturn output;\n}\n//#endregion\n//#region src/utilities/markdown/index.ts\nvar markdown_exports = /* @__PURE__ */ __exportAll({\n\tcreateAtomBlockMarkdownSpec: () => createAtomBlockMarkdownSpec,\n\tcreateBlockMarkdownSpec: () => createBlockMarkdownSpec,\n\tcreateInlineMarkdownSpec: () => createInlineMarkdownSpec,\n\tparseAttributes: () => parseAttributes,\n\tparseIndentedBlocks: () => parseIndentedBlocks,\n\trenderNestedMarkdownContent: () => renderNestedMarkdownContent,\n\tserializeAttributes: () => serializeAttributes\n});\n//#endregion\n//#region src/utilities/marksEqual.ts\nfunction markTypeName(mark) {\n\treturn typeof mark.type === \"string\" ? mark.type : mark.type.name;\n}\n/**\n* Compare two arrays of mark objects for equality (order-insensitive).\n* Marks are matched by type name and attributes (via attrsEqual),\n* so key ordering in attrs does not matter, nor does mark array order.\n*/\nfunction marksEqual(a, b) {\n\tif (a.length !== b.length) return false;\n\tconst consumed = Array.from({ length: b.length }, () => false);\n\treturn a.every((markA) => {\n\t\tconst nameA = markTypeName(markA);\n\t\tconst idx = b.findIndex((markB, i) => !consumed[i] && nameA === markTypeName(markB) && attrsEqual(markA.attrs, markB.attrs));\n\t\tif (idx === -1) return false;\n\t\tconsumed[idx] = true;\n\t\treturn true;\n\t});\n}\n//#endregion\n//#region src/utilities/mergeDeep.ts\nfunction mergeDeep(target, source) {\n\tconst output = { ...target };\n\tif (isPlainObject(target) && isPlainObject(source)) Object.keys(source).forEach((key) => {\n\t\tif (isPlainObject(source[key]) && isPlainObject(target[key])) output[key] = mergeDeep(target[key], source[key]);\n\t\telse output[key] = source[key];\n\t});\n\treturn output;\n}\n//#endregion\n//#region src/MarkView.ts\nfunction updateMarkViewAttributes(checkMark, editor, attrs = {}) {\n\tconst { state } = editor;\n\tconst { doc, tr } = state;\n\tconst thisMark = checkMark;\n\tdoc.descendants((node, pos) => {\n\t\tconst from = tr.mapping.map(pos);\n\t\tconst to = tr.mapping.map(pos) + node.nodeSize;\n\t\tlet foundMark = null;\n\t\tnode.marks.forEach((mark) => {\n\t\t\tif (mark !== thisMark) return false;\n\t\t\tfoundMark = mark;\n\t\t});\n\t\tif (!foundMark) return;\n\t\tlet needsUpdate = false;\n\t\tObject.keys(attrs).forEach((k) => {\n\t\t\tif (attrs[k] !== foundMark.attrs[k]) needsUpdate = true;\n\t\t});\n\t\tif (needsUpdate) {\n\t\t\tconst updatedMark = checkMark.type.create({\n\t\t\t\t...checkMark.attrs,\n\t\t\t\t...attrs\n\t\t\t});\n\t\t\ttr.removeMark(from, to, checkMark.type);\n\t\t\ttr.addMark(from, to, updatedMark);\n\t\t}\n\t});\n\tif (tr.docChanged) editor.view.dispatch(tr);\n}\nvar MarkView = class {\n\tconstructor(component, props, options) {\n\t\tthis.component = component;\n\t\tthis.editor = props.editor;\n\t\tthis.options = { ...options };\n\t\tthis.mark = props.mark;\n\t\tthis.HTMLAttributes = props.HTMLAttributes;\n\t}\n\tget dom() {\n\t\treturn this.editor.view.dom;\n\t}\n\tget contentDOM() {\n\t\treturn null;\n\t}\n\t/**\n\t* Update the attributes of the mark in the document.\n\t* @param attrs The attributes to update.\n\t*/\n\tupdateAttributes(attrs, checkMark) {\n\t\tupdateMarkViewAttributes(checkMark || this.mark, this.editor, attrs);\n\t}\n\tignoreMutation(mutation) {\n\t\tif (!this.dom || !this.contentDOM) return true;\n\t\tif (typeof this.options.ignoreMutation === \"function\") return this.options.ignoreMutation({ mutation });\n\t\tif (mutation.type === \"selection\") return false;\n\t\tif (this.contentDOM.contains(mutation.target) && mutation.type === \"childList\" && (isiOS() || isAndroid()) && this.editor.isFocused) {\n\t\t\tif ([...Array.from(mutation.addedNodes), ...Array.from(mutation.removedNodes)].every((node) => node.isContentEditable)) return false;\n\t\t}\n\t\tif (this.contentDOM === mutation.target && mutation.type === \"attributes\") return true;\n\t\tif (this.contentDOM.contains(mutation.target)) return false;\n\t\treturn true;\n\t}\n};\n//#endregion\n//#region src/InputRule.ts\nvar InputRule = class {\n\tconstructor(config) {\n\t\tvar _config$undoable;\n\t\tthis.find = config.find;\n\t\tthis.handler = config.handler;\n\t\tthis.undoable = (_config$undoable = config.undoable) !== null && _config$undoable !== void 0 ? _config$undoable : true;\n\t}\n};\nconst inputRuleMatcherHandler = (text, find) => {\n\tif (isRegExp(find)) return find.exec(text);\n\tconst inputRuleMatch = find(text);\n\tif (!inputRuleMatch) return null;\n\tconst result = [inputRuleMatch.text];\n\tresult.index = inputRuleMatch.index;\n\tresult.input = text;\n\tresult.data = inputRuleMatch.data;\n\tif (inputRuleMatch.replaceWith) {\n\t\tif (!inputRuleMatch.text.includes(inputRuleMatch.replaceWith)) console.warn(\"[tiptap warn]: \\\"inputRuleMatch.replaceWith\\\" must be part of \\\"inputRuleMatch.text\\\".\");\n\t\tresult.push(inputRuleMatch.replaceWith);\n\t}\n\treturn result;\n};\nfunction run$1(config) {\n\tvar _ref;\n\tconst { editor, from, to, text, rules, plugin } = config;\n\tconst { view } = editor;\n\tif (view.composing) return false;\n\tconst $from = view.state.doc.resolve(from);\n\tif ($from.parent.type.spec.code || !!((_ref = $from.nodeBefore || $from.nodeAfter) === null || _ref === void 0 ? void 0 : _ref.marks.find((mark) => mark.type.spec.code))) return false;\n\tlet matched = false;\n\tconst textBefore = getTextContentFromNodes($from) + text;\n\trules.forEach((rule) => {\n\t\tif (matched) return;\n\t\tconst match = inputRuleMatcherHandler(textBefore, rule.find);\n\t\tif (!match) return;\n\t\tconst matchedDocLength = match[0].length - text.length;\n\t\tif (matchedDocLength > 0) {\n\t\t\tconst matchStartOffset = $from.parentOffset - matchedDocLength;\n\t\t\tif (matchStartOffset < 0 || $from.parent.textBetween(matchStartOffset, $from.parentOffset) !== match[0].slice(0, matchedDocLength)) return;\n\t\t}\n\t\tconst tr = view.state.tr;\n\t\tconst state = createChainableState({\n\t\t\tstate: view.state,\n\t\t\ttransaction: tr\n\t\t});\n\t\tconst range = {\n\t\t\tfrom: from - (match[0].length - text.length),\n\t\t\tto\n\t\t};\n\t\tconst { commands, chain, can } = new CommandManager({\n\t\t\teditor,\n\t\t\tstate\n\t\t});\n\t\tif (rule.handler({\n\t\t\tstate,\n\t\t\trange,\n\t\t\tmatch,\n\t\t\tcommands,\n\t\t\tchain,\n\t\t\tcan\n\t\t}) === null || !tr.steps.length) return;\n\t\tif (rule.undoable) tr.setMeta(plugin, {\n\t\t\ttransform: tr,\n\t\t\tfrom,\n\t\t\tto,\n\t\t\ttext\n\t\t});\n\t\tview.dispatch(tr);\n\t\tmatched = true;\n\t});\n\treturn matched;\n}\n/**\n* Create an input rules plugin. When enabled, it will cause text\n* input that matches any of the given rules to trigger the rule’s\n* action.\n*/\nfunction inputRulesPlugin(props) {\n\tconst { editor, rules } = props;\n\tconst plugin = new _tiptap_pm_state.Plugin({\n\t\tstate: {\n\t\t\tinit() {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tapply(tr, prev, state) {\n\t\t\t\tconst stored = tr.getMeta(plugin);\n\t\t\t\tif (stored) return stored;\n\t\t\t\tconst simulatedInputMeta = tr.getMeta(\"applyInputRules\");\n\t\t\t\tif (!!simulatedInputMeta) setTimeout(() => {\n\t\t\t\t\tlet { text } = simulatedInputMeta;\n\t\t\t\t\tif (typeof text === \"string\") text = text;\n\t\t\t\t\telse text = getHTMLFromFragment(_tiptap_pm_model.Fragment.from(text), state.schema);\n\t\t\t\t\tconst { from } = simulatedInputMeta;\n\t\t\t\t\tconst to = from + text.length;\n\t\t\t\t\trun$1({\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\ttext,\n\t\t\t\t\t\trules,\n\t\t\t\t\t\tplugin\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn tr.selectionSet || tr.docChanged ? null : prev;\n\t\t\t}\n\t\t},\n\t\tprops: {\n\t\t\thandleTextInput(view, from, to, text) {\n\t\t\t\treturn run$1({\n\t\t\t\t\teditor,\n\t\t\t\t\tfrom,\n\t\t\t\t\tto,\n\t\t\t\t\ttext,\n\t\t\t\t\trules,\n\t\t\t\t\tplugin\n\t\t\t\t});\n\t\t\t},\n\t\t\thandleDOMEvents: { compositionend: (view) => {\n\t\t\t\tsetTimeout(() => {\n\t\t\t\t\tconst { $cursor } = view.state.selection;\n\t\t\t\t\tif ($cursor) run$1({\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\tfrom: $cursor.pos,\n\t\t\t\t\t\tto: $cursor.pos,\n\t\t\t\t\t\ttext: \"\",\n\t\t\t\t\t\trules,\n\t\t\t\t\t\tplugin\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t} },\n\t\t\thandleKeyDown(view, event) {\n\t\t\t\tif (event.key !== \"Enter\") return false;\n\t\t\t\tconst { $cursor } = view.state.selection;\n\t\t\t\tif ($cursor) return run$1({\n\t\t\t\t\teditor,\n\t\t\t\t\tfrom: $cursor.pos,\n\t\t\t\t\tto: $cursor.pos,\n\t\t\t\t\ttext: \"\\n\",\n\t\t\t\t\trules,\n\t\t\t\t\tplugin\n\t\t\t\t});\n\t\t\t\treturn false;\n\t\t\t}\n\t\t},\n\t\tisInputRules: true\n\t});\n\treturn plugin;\n}\n//#endregion\n//#region src/Extendable.ts\nvar Extendable = class {\n\tconstructor(config = {}) {\n\t\tthis.type = \"extendable\";\n\t\tthis.parent = null;\n\t\tthis.child = null;\n\t\tthis.name = \"\";\n\t\tthis.config = { name: this.name };\n\t\tthis.config = {\n\t\t\t...this.config,\n\t\t\t...config\n\t\t};\n\t\tthis.name = this.config.name;\n\t}\n\tget options() {\n\t\treturn { ...callOrReturn(getExtensionField(this, \"addOptions\", { name: this.name })) };\n\t}\n\tget storage() {\n\t\treturn { ...callOrReturn(getExtensionField(this, \"addStorage\", {\n\t\t\tname: this.name,\n\t\t\toptions: this.options\n\t\t})) };\n\t}\n\tconfigure(options = {}) {\n\t\tconst extension = this.extend({\n\t\t\t...this.config,\n\t\t\taddOptions: () => {\n\t\t\t\treturn mergeDeep(this.options, options);\n\t\t\t}\n\t\t});\n\t\textension.name = this.name;\n\t\textension.parent = this.parent;\n\t\tthis.child = null;\n\t\treturn extension;\n\t}\n\textend(extendedConfig = {}) {\n\t\tconst extension = new this.constructor({\n\t\t\t...this.config,\n\t\t\t...extendedConfig\n\t\t});\n\t\textension.parent = this;\n\t\tthis.child = extension;\n\t\textension.name = \"name\" in extendedConfig ? extendedConfig.name : extension.parent.name;\n\t\treturn extension;\n\t}\n};\n//#endregion\n//#region src/Mark.ts\n/**\n* The Mark class is used to create custom mark extensions.\n* @see https://tiptap.dev/api/extensions#create-a-new-extension\n*/\nvar Mark = class Mark extends Extendable {\n\tconstructor(..._args) {\n\t\tsuper(..._args);\n\t\tthis.type = \"mark\";\n\t}\n\t/**\n\t* Create a new Mark instance\n\t* @param config - Mark configuration object or a function that returns a configuration object\n\t*/\n\tstatic create(config = {}) {\n\t\tconst resolvedConfig = typeof config === \"function\" ? config() : config;\n\t\treturn new Mark(resolvedConfig);\n\t}\n\tstatic handleExit({ editor, mark }) {\n\t\tconst { tr } = editor.state;\n\t\tconst currentPos = editor.state.selection.$from;\n\t\tif (currentPos.pos === currentPos.end()) {\n\t\t\tconst currentMarks = currentPos.marks();\n\t\t\tif (!!!currentMarks.find((m) => (m === null || m === void 0 ? void 0 : m.type.name) === mark.name)) return false;\n\t\t\tconst removeMark = currentMarks.find((m) => (m === null || m === void 0 ? void 0 : m.type.name) === mark.name);\n\t\t\tif (removeMark) tr.removeStoredMark(removeMark);\n\t\t\ttr.insertText(\" \", currentPos.pos);\n\t\t\teditor.view.dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n\tconfigure(options) {\n\t\treturn super.configure(options);\n\t}\n\textend(extendedConfig) {\n\t\tconst resolvedConfig = typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n\t\treturn super.extend(resolvedConfig);\n\t}\n};\n//#endregion\n//#region src/PasteRule.ts\n/**\n* Paste rules are used to react to pasted content.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\n*/\nvar PasteRule = class {\n\tconstructor(config) {\n\t\tthis.find = config.find;\n\t\tthis.handler = config.handler;\n\t}\n};\nconst pasteRuleMatcherHandler = (text, find, event) => {\n\tif (isRegExp(find)) return [...text.matchAll(find)];\n\tconst matches = find(text, event);\n\tif (!matches) return [];\n\treturn matches.map((pasteRuleMatch) => {\n\t\tconst result = [pasteRuleMatch.text];\n\t\tresult.index = pasteRuleMatch.index;\n\t\tresult.input = text;\n\t\tresult.data = pasteRuleMatch.data;\n\t\tif (pasteRuleMatch.replaceWith) {\n\t\t\tif (!pasteRuleMatch.text.includes(pasteRuleMatch.replaceWith)) console.warn(\"[tiptap warn]: \\\"pasteRuleMatch.replaceWith\\\" must be part of \\\"pasteRuleMatch.text\\\".\");\n\t\t\tresult.push(pasteRuleMatch.replaceWith);\n\t\t}\n\t\treturn result;\n\t});\n};\nfunction run(config) {\n\tconst { editor, state, from, to, rule, pasteEvent, dropEvent } = config;\n\tconst { commands, chain, can } = new CommandManager({\n\t\teditor,\n\t\tstate\n\t});\n\tconst handlers = [];\n\tstate.doc.nodesBetween(from, to, (node, pos) => {\n\t\tvar _node$type, _ref, _node$content$size, _node$content;\n\t\tif (((_node$type = node.type) === null || _node$type === void 0 || (_node$type = _node$type.spec) === null || _node$type === void 0 ? void 0 : _node$type.code) || !(node.isText || node.isTextblock || node.isInline)) return;\n\t\tconst contentSize = (_ref = (_node$content$size = (_node$content = node.content) === null || _node$content === void 0 ? void 0 : _node$content.size) !== null && _node$content$size !== void 0 ? _node$content$size : node.nodeSize) !== null && _ref !== void 0 ? _ref : 0;\n\t\tconst resolvedFrom = Math.max(from, pos);\n\t\tconst resolvedTo = Math.min(to, pos + contentSize);\n\t\tif (resolvedFrom >= resolvedTo) return;\n\t\tconst textToMatch = node.isText ? node.text || \"\" : node.textBetween(resolvedFrom - pos, resolvedTo - pos, void 0, \"\");\n\t\tpasteRuleMatcherHandler(textToMatch, rule.find, pasteEvent).forEach((match) => {\n\t\t\tif (match.index === void 0) return;\n\t\t\tconst start = resolvedFrom + match.index + 1;\n\t\t\tconst end = start + match[0].length;\n\t\t\tconst range = {\n\t\t\t\tfrom: state.tr.mapping.map(start),\n\t\t\t\tto: state.tr.mapping.map(end)\n\t\t\t};\n\t\t\tconst handler = rule.handler({\n\t\t\t\tstate,\n\t\t\t\trange,\n\t\t\t\tmatch,\n\t\t\t\tcommands,\n\t\t\t\tchain,\n\t\t\t\tcan,\n\t\t\t\tpasteEvent,\n\t\t\t\tdropEvent\n\t\t\t});\n\t\t\thandlers.push(handler);\n\t\t});\n\t});\n\treturn handlers.every((handler) => handler !== null);\n}\nlet tiptapDragFromOtherEditor = null;\nconst createClipboardPasteEvent = (text) => {\n\tvar _event$clipboardData;\n\tconst event = new ClipboardEvent(\"paste\", { clipboardData: new DataTransfer() });\n\t(_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 || _event$clipboardData.setData(\"text/html\", text);\n\treturn event;\n};\n/**\n* Create an paste rules plugin. When enabled, it will cause pasted\n* text that matches any of the given rules to trigger the rule’s\n* action.\n*/\nfunction pasteRulesPlugin(props) {\n\tconst { editor, rules } = props;\n\tlet dragSourceElement = null;\n\tlet isPastedFromProseMirror = false;\n\tlet isDroppedFromProseMirror = false;\n\tlet pasteEvent = typeof ClipboardEvent !== \"undefined\" ? new ClipboardEvent(\"paste\") : null;\n\tlet dropEvent;\n\ttry {\n\t\tdropEvent = typeof DragEvent !== \"undefined\" ? new DragEvent(\"drop\") : null;\n\t} catch {\n\t\tdropEvent = null;\n\t}\n\tconst processEvent = ({ state, from, to, rule, pasteEvt }) => {\n\t\tconst tr = state.tr;\n\t\tconst chainableState = createChainableState({\n\t\t\tstate,\n\t\t\ttransaction: tr\n\t\t});\n\t\tif (!run({\n\t\t\teditor,\n\t\t\tstate: chainableState,\n\t\t\tfrom: Math.max(from - 1, 0),\n\t\t\tto: to.b - 1,\n\t\t\trule,\n\t\t\tpasteEvent: pasteEvt,\n\t\t\tdropEvent\n\t\t}) || !tr.steps.length) return;\n\t\ttry {\n\t\t\tdropEvent = typeof DragEvent !== \"undefined\" ? new DragEvent(\"drop\") : null;\n\t\t} catch {\n\t\t\tdropEvent = null;\n\t\t}\n\t\tpasteEvent = typeof ClipboardEvent !== \"undefined\" ? new ClipboardEvent(\"paste\") : null;\n\t\treturn tr;\n\t};\n\treturn rules.map((rule) => {\n\t\treturn new _tiptap_pm_state.Plugin({\n\t\t\tview(view) {\n\t\t\t\tconst handleDragstart = (event) => {\n\t\t\t\t\tvar _view$dom$parentEleme;\n\t\t\t\t\tdragSourceElement = ((_view$dom$parentEleme = view.dom.parentElement) === null || _view$dom$parentEleme === void 0 ? void 0 : _view$dom$parentEleme.contains(event.target)) ? view.dom.parentElement : null;\n\t\t\t\t\tif (dragSourceElement) tiptapDragFromOtherEditor = editor;\n\t\t\t\t};\n\t\t\t\tconst handleDragend = () => {\n\t\t\t\t\tif (tiptapDragFromOtherEditor) tiptapDragFromOtherEditor = null;\n\t\t\t\t};\n\t\t\t\twindow.addEventListener(\"dragstart\", handleDragstart);\n\t\t\t\twindow.addEventListener(\"dragend\", handleDragend);\n\t\t\t\treturn { destroy() {\n\t\t\t\t\twindow.removeEventListener(\"dragstart\", handleDragstart);\n\t\t\t\t\twindow.removeEventListener(\"dragend\", handleDragend);\n\t\t\t\t} };\n\t\t\t},\n\t\t\tprops: { handleDOMEvents: {\n\t\t\t\tdrop: (view, event) => {\n\t\t\t\t\tisDroppedFromProseMirror = dragSourceElement === view.dom.parentElement;\n\t\t\t\t\tdropEvent = event;\n\t\t\t\t\tif (!isDroppedFromProseMirror) {\n\t\t\t\t\t\tconst dragFromOtherEditor = tiptapDragFromOtherEditor;\n\t\t\t\t\t\tif (dragFromOtherEditor === null || dragFromOtherEditor === void 0 ? void 0 : dragFromOtherEditor.isEditable) setTimeout(() => {\n\t\t\t\t\t\t\tconst selection = dragFromOtherEditor.state.selection;\n\t\t\t\t\t\t\tif (selection) dragFromOtherEditor.commands.deleteRange({\n\t\t\t\t\t\t\t\tfrom: selection.from,\n\t\t\t\t\t\t\t\tto: selection.to\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}, 10);\n\t\t\t\t\t}\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\tpaste: (_view, event) => {\n\t\t\t\t\tvar _clipboardData;\n\t\t\t\t\tconst html = (_clipboardData = event.clipboardData) === null || _clipboardData === void 0 ? void 0 : _clipboardData.getData(\"text/html\");\n\t\t\t\t\tpasteEvent = event;\n\t\t\t\t\tisPastedFromProseMirror = !!(html === null || html === void 0 ? void 0 : html.includes(\"data-pm-slice\"));\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} },\n\t\t\tappendTransaction: (transactions, oldState, state) => {\n\t\t\t\tconst transaction = transactions[0];\n\t\t\t\tconst isPaste = transaction.getMeta(\"uiEvent\") === \"paste\" && !isPastedFromProseMirror;\n\t\t\t\tconst isDrop = transaction.getMeta(\"uiEvent\") === \"drop\" && !isDroppedFromProseMirror;\n\t\t\t\tconst simulatedPasteMeta = transaction.getMeta(\"applyPasteRules\");\n\t\t\t\tconst isSimulatedPaste = !!simulatedPasteMeta;\n\t\t\t\tif (!isPaste && !isDrop && !isSimulatedPaste) return;\n\t\t\t\tif (isSimulatedPaste) {\n\t\t\t\t\tlet { text } = simulatedPasteMeta;\n\t\t\t\t\tif (typeof text === \"string\") text = text;\n\t\t\t\t\telse text = getHTMLFromFragment(_tiptap_pm_model.Fragment.from(text), state.schema);\n\t\t\t\t\tconst { from } = simulatedPasteMeta;\n\t\t\t\t\tconst to = from + text.length;\n\t\t\t\t\tconst pasteEvt = createClipboardPasteEvent(text);\n\t\t\t\t\treturn processEvent({\n\t\t\t\t\t\trule,\n\t\t\t\t\t\tstate,\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto: { b: to },\n\t\t\t\t\t\tpasteEvt\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tconst from = oldState.doc.content.findDiffStart(state.doc.content);\n\t\t\t\tconst to = oldState.doc.content.findDiffEnd(state.doc.content);\n\t\t\t\tif (!isNumber(from) || !to || from === to.b) return;\n\t\t\t\treturn processEvent({\n\t\t\t\t\trule,\n\t\t\t\t\tstate,\n\t\t\t\t\tfrom,\n\t\t\t\t\tto,\n\t\t\t\t\tpasteEvt: pasteEvent\n\t\t\t\t});\n\t\t\t}\n\t\t});\n\t});\n}\n//#endregion\n//#region src/ExtensionManager.ts\nvar ExtensionManager = class {\n\tconstructor(extensions, editor) {\n\t\tthis.splittableMarks = [];\n\t\tthis.nonClearableMarks = [];\n\t\tthis.decorationManager = null;\n\t\tthis.editor = editor;\n\t\tthis.baseExtensions = extensions;\n\t\tthis.extensions = resolveExtensions(extensions);\n\t\tthis.schema = getSchemaByResolvedExtensions(this.extensions, editor);\n\t\tthis.setupExtensions();\n\t}\n\t/**\n\t* Get all commands from the extensions.\n\t* @returns An object with all commands where the key is the command name and the value is the command function\n\t*/\n\tget commands() {\n\t\treturn this.extensions.reduce((commands, extension) => {\n\t\t\tconst addCommands = getExtensionField(extension, \"addCommands\", {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor: this.editor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t});\n\t\t\tif (!addCommands) return commands;\n\t\t\treturn {\n\t\t\t\t...commands,\n\t\t\t\t...addCommands()\n\t\t\t};\n\t\t}, {});\n\t}\n\t/**\n\t* Get all registered Prosemirror plugins from the extensions.\n\t* @returns An array of Prosemirror plugins\n\t*/\n\tget plugins() {\n\t\tconst { editor } = this;\n\t\tconst allPlugins = sortExtensions([...this.extensions].reverse()).flatMap((extension) => {\n\t\t\tconst context = {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t};\n\t\t\tconst plugins = [];\n\t\t\tconst addKeyboardShortcuts = getExtensionField(extension, \"addKeyboardShortcuts\", context);\n\t\t\tlet defaultBindings = {};\n\t\t\tif (extension.type === \"mark\" && getExtensionField(extension, \"exitable\", context)) defaultBindings.ArrowRight = () => Mark.handleExit({\n\t\t\t\teditor,\n\t\t\t\tmark: extension\n\t\t\t});\n\t\t\tif (addKeyboardShortcuts) {\n\t\t\t\tconst bindings = Object.fromEntries(Object.entries(addKeyboardShortcuts()).map(([shortcut, method]) => {\n\t\t\t\t\treturn [shortcut, () => method({ editor })];\n\t\t\t\t}));\n\t\t\t\tdefaultBindings = {\n\t\t\t\t\t...defaultBindings,\n\t\t\t\t\t...bindings\n\t\t\t\t};\n\t\t\t}\n\t\t\tconst keyMapPlugin = (0, _tiptap_pm_keymap.keymap)(defaultBindings);\n\t\t\tplugins.push(keyMapPlugin);\n\t\t\tconst addInputRules = getExtensionField(extension, \"addInputRules\", context);\n\t\t\tif (isExtensionRulesEnabled(extension, editor.options.enableInputRules) && addInputRules) {\n\t\t\t\tconst rules = addInputRules();\n\t\t\t\tif (rules && rules.length) {\n\t\t\t\t\tconst inputResult = inputRulesPlugin({\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\trules\n\t\t\t\t\t});\n\t\t\t\t\tconst inputPlugins = Array.isArray(inputResult) ? inputResult : [inputResult];\n\t\t\t\t\tplugins.push(...inputPlugins);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst addPasteRules = getExtensionField(extension, \"addPasteRules\", context);\n\t\t\tif (isExtensionRulesEnabled(extension, editor.options.enablePasteRules) && addPasteRules) {\n\t\t\t\tconst rules = addPasteRules();\n\t\t\t\tif (rules && rules.length) {\n\t\t\t\t\tconst pasteRules = pasteRulesPlugin({\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\trules\n\t\t\t\t\t});\n\t\t\t\t\tplugins.push(...pasteRules);\n\t\t\t\t}\n\t\t\t}\n\t\t\tconst addProseMirrorPlugins = getExtensionField(extension, \"addProseMirrorPlugins\", context);\n\t\t\tif (addProseMirrorPlugins) {\n\t\t\t\tconst proseMirrorPlugins = addProseMirrorPlugins();\n\t\t\t\tplugins.push(...proseMirrorPlugins);\n\t\t\t}\n\t\t\treturn plugins;\n\t\t});\n\t\tconst decorationPlugin = this.createDecorationPlugin();\n\t\tif (decorationPlugin) allPlugins.push(decorationPlugin);\n\t\treturn allPlugins;\n\t}\n\t/**\n\t* Aggregates decorations from extensions into a single plugin, or returns null\n\t* if none exist. Destroys the previous manager to avoid orphaned listeners.\n\t* @returns A ProseMirror plugin or `null`\n\t* @example\n\t* const plugin = editor.extensionManager.createDecorationPlugin()\n\t*/\n\tcreateDecorationPlugin() {\n\t\tvar _this$decorationManag;\n\t\tconst { editor } = this;\n\t\t(_this$decorationManag = this.decorationManager) === null || _this$decorationManag === void 0 || _this$decorationManag.destroy();\n\t\tconst entries = [];\n\t\tthis.extensions.forEach((extension) => {\n\t\t\tconst addDecorations = getExtensionField(extension, \"addDecorations\", {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t});\n\t\t\tif (!addDecorations) return;\n\t\t\tentries.push({\n\t\t\t\tname: extension.name,\n\t\t\t\taddDecorations\n\t\t\t});\n\t\t});\n\t\tthis.decorationManager = new DecorationManager({\n\t\t\teditor,\n\t\t\tentries\n\t\t});\n\t\treturn this.decorationManager.plugin;\n\t}\n\t/**\n\t* Get all attributes from the extensions.\n\t* @returns An array of attributes\n\t*/\n\tget attributes() {\n\t\treturn getAttributesFromExtensions(this.extensions);\n\t}\n\t/**\n\t* Get all node views from the extensions.\n\t* @returns An object with all node views where the key is the node name and the value is the node view function\n\t*/\n\tget nodeViews() {\n\t\tconst { editor } = this;\n\t\tconst { nodeExtensions } = splitExtensions(this.extensions);\n\t\treturn Object.fromEntries(nodeExtensions.filter((extension) => !!getExtensionField(extension, \"addNodeView\")).map((extension) => {\n\t\t\tconst extensionAttributes = this.attributes.filter((attribute) => attribute.type === extension.name);\n\t\t\tconst addNodeView = getExtensionField(extension, \"addNodeView\", {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getNodeType(extension.name, this.schema)\n\t\t\t});\n\t\t\tif (!addNodeView) return [];\n\t\t\tconst nodeViewResult = addNodeView();\n\t\t\tif (!nodeViewResult) return [];\n\t\t\tconst nodeview = (node, view, getPos, decorations, innerDecorations) => {\n\t\t\t\tconst HTMLAttributes = getRenderedAttributes(node, extensionAttributes);\n\t\t\t\treturn nodeViewResult({\n\t\t\t\t\tnode,\n\t\t\t\t\tview,\n\t\t\t\t\tgetPos,\n\t\t\t\t\tdecorations,\n\t\t\t\t\tinnerDecorations,\n\t\t\t\t\teditor,\n\t\t\t\t\textension,\n\t\t\t\t\tHTMLAttributes\n\t\t\t\t});\n\t\t\t};\n\t\t\treturn [extension.name, nodeview];\n\t\t}));\n\t}\n\t/**\n\t* Get the composed dispatchTransaction function from all extensions.\n\t* @param baseDispatch The base dispatch function (e.g. from the editor or user props)\n\t* @returns A composed dispatch function\n\t*/\n\tdispatchTransaction(baseDispatch) {\n\t\tconst { editor } = this;\n\t\treturn sortExtensions([...this.extensions].reverse()).reduceRight((next, extension) => {\n\t\t\tconst context = {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t};\n\t\t\tconst dispatchTransaction = getExtensionField(extension, \"dispatchTransaction\", context);\n\t\t\tif (!dispatchTransaction) return next;\n\t\t\treturn (transaction) => {\n\t\t\t\tdispatchTransaction.call(context, {\n\t\t\t\t\ttransaction,\n\t\t\t\t\tnext\n\t\t\t\t});\n\t\t\t};\n\t\t}, baseDispatch);\n\t}\n\t/**\n\t* Get the composed transformPastedHTML function from all extensions.\n\t* @param baseTransform The base transform function (e.g. from the editor props)\n\t* @returns A composed transform function that chains all extension transforms\n\t*/\n\ttransformPastedHTML(baseTransform) {\n\t\tconst { editor } = this;\n\t\treturn sortExtensions([...this.extensions]).reduce((transform, extension) => {\n\t\t\tconst context = {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t};\n\t\t\tconst extensionTransform = getExtensionField(extension, \"transformPastedHTML\", context);\n\t\t\tif (!extensionTransform) return transform;\n\t\t\treturn (html, view) => {\n\t\t\t\tconst transformedHtml = transform(html, view);\n\t\t\t\treturn extensionTransform.call(context, transformedHtml);\n\t\t\t};\n\t\t}, baseTransform || ((html) => html));\n\t}\n\tget markViews() {\n\t\tconst { editor } = this;\n\t\tconst { markExtensions } = splitExtensions(this.extensions);\n\t\treturn Object.fromEntries(markExtensions.filter((extension) => !!getExtensionField(extension, \"addMarkView\")).map((extension) => {\n\t\t\tconst extensionAttributes = this.attributes.filter((attribute) => attribute.type === extension.name);\n\t\t\tconst addMarkView = getExtensionField(extension, \"addMarkView\", {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor,\n\t\t\t\ttype: getMarkType(extension.name, this.schema)\n\t\t\t});\n\t\t\tif (!addMarkView) return [];\n\t\t\tconst markView = (mark, view, inline) => {\n\t\t\t\tconst HTMLAttributes = getRenderedAttributes(mark, extensionAttributes);\n\t\t\t\treturn addMarkView()({\n\t\t\t\t\tmark,\n\t\t\t\t\tview,\n\t\t\t\t\tinline,\n\t\t\t\t\teditor,\n\t\t\t\t\textension,\n\t\t\t\t\tHTMLAttributes,\n\t\t\t\t\tupdateAttributes: (attrs) => {\n\t\t\t\t\t\tupdateMarkViewAttributes(mark, editor, attrs);\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t};\n\t\t\treturn [extension.name, markView];\n\t\t}));\n\t}\n\t/**\n\t* Destroy the extension manager and clean up all extension references\n\t* to prevent memory leaks through parent/child extension chains.\n\t*\n\t* Walks each extension's full parent chain and nulls every forward\n\t* `parent.child → current` link where the parent still points to the\n\t* current node. This breaks the retention path from module-scope\n\t* singleton roots through deep extend() chains.\n\t*\n\t* Only ancestor `.child` links matching the current chain are cleared.\n\t* The `.parent` pointer on ancestors is never touched — extensions\n\t* may be shared across live editors, so their own backward references\n\t* and non-matching forward links must remain intact.\n\t*/\n\tdestroy() {\n\t\tvar _this$decorationManag2;\n\t\t(_this$decorationManag2 = this.decorationManager) === null || _this$decorationManag2 === void 0 || _this$decorationManag2.destroy();\n\t\tthis.extensions.forEach((extension) => {\n\t\t\tlet current = extension;\n\t\t\twhile (current.parent) {\n\t\t\t\tconst parent = current.parent;\n\t\t\t\tif (parent.child === current) parent.child = null;\n\t\t\t\tcurrent = parent;\n\t\t\t}\n\t\t});\n\t\tthis.extensions = [];\n\t\tthis.baseExtensions = [];\n\t\tthis.decorationManager = null;\n\t\tthis.schema = null;\n\t\tthis.editor = null;\n\t}\n\t/**\n\t* Go through all extensions, create extension storages & setup marks\n\t* & bind editor event listener.\n\t*/\n\tsetupExtensions() {\n\t\tconst extensions = this.extensions;\n\t\tthis.editor.extensionStorage = Object.fromEntries(extensions.map((extension) => [extension.name, extension.storage]));\n\t\textensions.forEach((extension) => {\n\t\t\tconst context = {\n\t\t\t\tname: extension.name,\n\t\t\t\toptions: extension.options,\n\t\t\t\tstorage: this.editor.extensionStorage[extension.name],\n\t\t\t\teditor: this.editor,\n\t\t\t\ttype: getSchemaTypeByName(extension.name, this.schema)\n\t\t\t};\n\t\t\tif (extension.type === \"mark\") {\n\t\t\t\tvar _callOrReturn, _callOrReturn2;\n\t\t\t\tif ((_callOrReturn = callOrReturn(getExtensionField(extension, \"keepOnSplit\", context))) !== null && _callOrReturn !== void 0 ? _callOrReturn : true) this.splittableMarks.push(extension.name);\n\t\t\t\tif (!((_callOrReturn2 = callOrReturn(getExtensionField(extension, \"clearable\", context))) !== null && _callOrReturn2 !== void 0 ? _callOrReturn2 : true)) this.nonClearableMarks.push(extension.name);\n\t\t\t}\n\t\t\tconst onBeforeCreate = getExtensionField(extension, \"onBeforeCreate\", context);\n\t\t\tconst onCreate = getExtensionField(extension, \"onCreate\", context);\n\t\t\tconst onUpdate = getExtensionField(extension, \"onUpdate\", context);\n\t\t\tconst onSelectionUpdate = getExtensionField(extension, \"onSelectionUpdate\", context);\n\t\t\tconst onTransaction = getExtensionField(extension, \"onTransaction\", context);\n\t\t\tconst onFocus = getExtensionField(extension, \"onFocus\", context);\n\t\t\tconst onBlur = getExtensionField(extension, \"onBlur\", context);\n\t\t\tconst onDestroy = getExtensionField(extension, \"onDestroy\", context);\n\t\t\tif (onBeforeCreate) this.editor.on(\"beforeCreate\", onBeforeCreate);\n\t\t\tif (onCreate) this.editor.on(\"create\", onCreate);\n\t\t\tif (onUpdate) this.editor.on(\"update\", onUpdate);\n\t\t\tif (onSelectionUpdate) this.editor.on(\"selectionUpdate\", onSelectionUpdate);\n\t\t\tif (onTransaction) this.editor.on(\"transaction\", onTransaction);\n\t\t\tif (onFocus) this.editor.on(\"focus\", onFocus);\n\t\t\tif (onBlur) this.editor.on(\"blur\", onBlur);\n\t\t\tif (onDestroy) this.editor.on(\"destroy\", onDestroy);\n\t\t});\n\t}\n};\nExtensionManager.resolve = resolveExtensions;\nExtensionManager.sort = sortExtensions;\nExtensionManager.flatten = flattenExtensions;\n//#endregion\n//#region src/Extension.ts\n/**\n* The Extension class is the base class for all extensions.\n* @see https://tiptap.dev/api/extensions#create-a-new-extension\n*/\nvar Extension = class Extension extends Extendable {\n\tconstructor(..._args) {\n\t\tsuper(..._args);\n\t\tthis.type = \"extension\";\n\t}\n\t/**\n\t* Create a new Extension instance\n\t* @param config - Extension configuration object or a function that returns a configuration object\n\t*/\n\tstatic create(config = {}) {\n\t\tconst resolvedConfig = typeof config === \"function\" ? config() : config;\n\t\treturn new Extension(resolvedConfig);\n\t}\n\tconfigure(options) {\n\t\treturn super.configure(options);\n\t}\n\textend(extendedConfig) {\n\t\tconst resolvedConfig = typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n\t\treturn super.extend(resolvedConfig);\n\t}\n};\n//#endregion\n//#region src/extensions/clipboardTextSerializer.ts\nconst ClipboardTextSerializer = Extension.create({\n\tname: \"clipboardTextSerializer\",\n\taddOptions() {\n\t\treturn { blockSeparator: void 0 };\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"clipboardTextSerializer\"),\n\t\t\tprops: { clipboardTextSerializer: () => {\n\t\t\t\tconst { editor } = this;\n\t\t\t\tconst { state, schema } = editor;\n\t\t\t\tconst { doc, selection } = state;\n\t\t\t\tconst textSerializers = getTextSerializersFromSchema(schema);\n\t\t\t\tconst { blockSeparator } = this.options;\n\t\t\t\tconst options = {\n\t\t\t\t\t...blockSeparator !== void 0 ? { blockSeparator } : {},\n\t\t\t\t\ttextSerializers\n\t\t\t\t};\n\t\t\t\treturn [...selection.ranges].sort((a, b) => a.$from.pos - b.$from.pos).map(({ $from, $to }) => getTextBetween(doc, {\n\t\t\t\t\tfrom: $from.pos,\n\t\t\t\t\tto: $to.pos\n\t\t\t\t}, options)).join(blockSeparator !== null && blockSeparator !== void 0 ? blockSeparator : \"\\n\\n\");\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/commands.ts\nconst Commands = Extension.create({\n\tname: \"commands\",\n\taddCommands() {\n\t\treturn { ...commands_exports };\n\t}\n});\n//#endregion\n//#region src/extensions/delete.ts\n/**\n* This extension allows you to be notified when the user deletes content you are interested in.\n*/\nconst Delete = Extension.create({\n\tname: \"delete\",\n\tonUpdate({ transaction, appendedTransactions }) {\n\t\tvar _this$editor$options$4, _this$editor$options$5;\n\t\tconst callback = () => {\n\t\t\tvar _this$editor$options$, _this$editor$options$2, _this$editor$options$3;\n\t\t\tif ((_this$editor$options$ = (_this$editor$options$2 = this.editor.options.coreExtensionOptions) === null || _this$editor$options$2 === void 0 || (_this$editor$options$2 = _this$editor$options$2.delete) === null || _this$editor$options$2 === void 0 || (_this$editor$options$3 = _this$editor$options$2.filterTransaction) === null || _this$editor$options$3 === void 0 ? void 0 : _this$editor$options$3.call(_this$editor$options$2, transaction)) !== null && _this$editor$options$ !== void 0 ? _this$editor$options$ : transaction.getMeta(\"y-sync$\")) return;\n\t\t\tconst nextTransaction = combineTransactionSteps(transaction.before, [transaction, ...appendedTransactions]);\n\t\t\tgetChangedRanges(nextTransaction).forEach((change) => {\n\t\t\t\tif (nextTransaction.mapping.mapResult(change.oldRange.from).deletedAfter && nextTransaction.mapping.mapResult(change.oldRange.to).deletedBefore) nextTransaction.before.nodesBetween(change.oldRange.from, change.oldRange.to, (node, from) => {\n\t\t\t\t\tconst to = from + node.nodeSize - 2;\n\t\t\t\t\tconst isFullyWithinRange = change.oldRange.from <= from && to <= change.oldRange.to;\n\t\t\t\t\tthis.editor.emit(\"delete\", {\n\t\t\t\t\t\ttype: \"node\",\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tfrom,\n\t\t\t\t\t\tto,\n\t\t\t\t\t\tnewFrom: nextTransaction.mapping.map(from),\n\t\t\t\t\t\tnewTo: nextTransaction.mapping.map(to),\n\t\t\t\t\t\tdeletedRange: change.oldRange,\n\t\t\t\t\t\tnewRange: change.newRange,\n\t\t\t\t\t\tpartial: !isFullyWithinRange,\n\t\t\t\t\t\teditor: this.editor,\n\t\t\t\t\t\ttransaction,\n\t\t\t\t\t\tcombinedTransform: nextTransaction\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst mapping = nextTransaction.mapping;\n\t\t\tnextTransaction.steps.forEach((step, index) => {\n\t\t\t\tif (step instanceof _tiptap_pm_transform.RemoveMarkStep) {\n\t\t\t\t\tvar _nextTransaction$doc$, _nextTransaction$doc$2;\n\t\t\t\t\tconst newStart = mapping.slice(index).map(step.from, -1);\n\t\t\t\t\tconst newEnd = mapping.slice(index).map(step.to);\n\t\t\t\t\tconst oldStart = mapping.invert().map(newStart, -1);\n\t\t\t\t\tconst oldEnd = mapping.invert().map(newEnd);\n\t\t\t\t\tconst foundBeforeMark = newStart > 0 ? (_nextTransaction$doc$ = nextTransaction.doc.nodeAt(newStart - 1)) === null || _nextTransaction$doc$ === void 0 ? void 0 : _nextTransaction$doc$.marks.some((mark) => mark.eq(step.mark)) : false;\n\t\t\t\t\tconst foundAfterMark = (_nextTransaction$doc$2 = nextTransaction.doc.nodeAt(newEnd)) === null || _nextTransaction$doc$2 === void 0 ? void 0 : _nextTransaction$doc$2.marks.some((mark) => mark.eq(step.mark));\n\t\t\t\t\tthis.editor.emit(\"delete\", {\n\t\t\t\t\t\ttype: \"mark\",\n\t\t\t\t\t\tmark: step.mark,\n\t\t\t\t\t\tfrom: step.from,\n\t\t\t\t\t\tto: step.to,\n\t\t\t\t\t\tdeletedRange: {\n\t\t\t\t\t\t\tfrom: oldStart,\n\t\t\t\t\t\t\tto: oldEnd\n\t\t\t\t\t\t},\n\t\t\t\t\t\tnewRange: {\n\t\t\t\t\t\t\tfrom: newStart,\n\t\t\t\t\t\t\tto: newEnd\n\t\t\t\t\t\t},\n\t\t\t\t\t\tpartial: Boolean(foundAfterMark || foundBeforeMark),\n\t\t\t\t\t\teditor: this.editor,\n\t\t\t\t\t\ttransaction,\n\t\t\t\t\t\tcombinedTransform: nextTransaction\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t};\n\t\tif ((_this$editor$options$4 = (_this$editor$options$5 = this.editor.options.coreExtensionOptions) === null || _this$editor$options$5 === void 0 || (_this$editor$options$5 = _this$editor$options$5.delete) === null || _this$editor$options$5 === void 0 ? void 0 : _this$editor$options$5.async) !== null && _this$editor$options$4 !== void 0 ? _this$editor$options$4 : true) setTimeout(callback, 0);\n\t\telse callback();\n\t}\n});\n//#endregion\n//#region src/extensions/drop.ts\nconst Drop = Extension.create({\n\tname: \"drop\",\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"tiptapDrop\"),\n\t\t\tprops: { handleDrop: (_, e, slice, moved) => {\n\t\t\t\tthis.editor.emit(\"drop\", {\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tevent: e,\n\t\t\t\t\tslice,\n\t\t\t\t\tmoved\n\t\t\t\t});\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/editable.ts\nconst Editable = Extension.create({\n\tname: \"editable\",\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"editable\"),\n\t\t\tprops: { editable: () => this.editor.options.editable }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/focusEvents.ts\nconst focusEventsPluginKey = new _tiptap_pm_state.PluginKey(\"focusEvents\");\nconst FocusEvents = Extension.create({\n\tname: \"focusEvents\",\n\taddProseMirrorPlugins() {\n\t\tconst { editor } = this;\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: focusEventsPluginKey,\n\t\t\tprops: { handleDOMEvents: {\n\t\t\t\tfocus: (view, event) => {\n\t\t\t\t\teditor.isFocused = true;\n\t\t\t\t\tconst transaction = editor.state.tr.setMeta(\"focus\", { event }).setMeta(\"addToHistory\", false);\n\t\t\t\t\tview.dispatch(transaction);\n\t\t\t\t\treturn false;\n\t\t\t\t},\n\t\t\t\tblur: (view, event) => {\n\t\t\t\t\teditor.isFocused = false;\n\t\t\t\t\tconst transaction = editor.state.tr.setMeta(\"blur\", { event }).setMeta(\"addToHistory\", false);\n\t\t\t\t\tview.dispatch(transaction);\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/keymap.ts\nconst Keymap = Extension.create({\n\tname: \"keymap\",\n\taddKeyboardShortcuts() {\n\t\tconst handleBackspace = () => this.editor.commands.first(({ commands }) => [\n\t\t\t() => commands.undoInputRule(),\n\t\t\t() => commands.command(({ tr }) => {\n\t\t\t\tconst { selection, doc } = tr;\n\t\t\t\tconst { empty, $anchor } = selection;\n\t\t\t\tconst { pos, parent } = $anchor;\n\t\t\t\tconst $parentPos = $anchor.parent.isTextblock && pos > 0 ? tr.doc.resolve(pos - 1) : $anchor;\n\t\t\t\tconst parentIsIsolating = $parentPos.parent.type.spec.isolating;\n\t\t\t\tconst parentPos = $anchor.pos - $anchor.parentOffset;\n\t\t\t\tconst isAtStart = parentIsIsolating && $parentPos.parent.childCount === 1 ? parentPos === $anchor.pos : _tiptap_pm_state.Selection.atStart(doc).from === pos;\n\t\t\t\tif (!empty || !parent.type.isTextblock || parent.textContent.length || !isAtStart || isAtStart && $anchor.parent.type.name === \"paragraph\") return false;\n\t\t\t\treturn commands.clearNodes();\n\t\t\t}),\n\t\t\t() => commands.deleteSelection(),\n\t\t\t() => commands.joinBackward(),\n\t\t\t() => commands.selectNodeBackward()\n\t\t]);\n\t\tconst handleDelete = () => this.editor.commands.first(({ commands }) => [\n\t\t\t() => commands.deleteSelection(),\n\t\t\t() => commands.deleteCurrentNode(),\n\t\t\t() => commands.joinForward(),\n\t\t\t() => commands.selectNodeForward()\n\t\t]);\n\t\tconst handleEnter = () => this.editor.commands.first(({ commands }) => [\n\t\t\t() => commands.newlineInCode(),\n\t\t\t() => commands.createParagraphNear(),\n\t\t\t() => commands.liftEmptyBlock(),\n\t\t\t() => commands.splitBlock()\n\t\t]);\n\t\tconst baseKeymap = {\n\t\t\tEnter: handleEnter,\n\t\t\t\"Mod-Enter\": () => this.editor.commands.exitCode(),\n\t\t\tBackspace: handleBackspace,\n\t\t\t\"Mod-Backspace\": handleBackspace,\n\t\t\t\"Shift-Backspace\": handleBackspace,\n\t\t\tDelete: handleDelete,\n\t\t\t\"Mod-Delete\": handleDelete,\n\t\t\t\"Mod-a\": () => this.editor.commands.selectAll()\n\t\t};\n\t\tconst pcKeymap = { ...baseKeymap };\n\t\tconst macKeymap = {\n\t\t\t...baseKeymap,\n\t\t\t\"Ctrl-h\": handleBackspace,\n\t\t\t\"Alt-Backspace\": handleBackspace,\n\t\t\t\"Ctrl-d\": handleDelete,\n\t\t\t\"Ctrl-Alt-Backspace\": handleDelete,\n\t\t\t\"Alt-Delete\": handleDelete,\n\t\t\t\"Alt-d\": handleDelete,\n\t\t\t\"Ctrl-a\": () => this.editor.commands.selectTextblockStart(),\n\t\t\t\"Ctrl-e\": () => this.editor.commands.selectTextblockEnd()\n\t\t};\n\t\tif (isiOS() || isMacOS()) return macKeymap;\n\t\treturn pcKeymap;\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"clearDocument\"),\n\t\t\tappendTransaction: (transactions, oldState, newState) => {\n\t\t\t\tif (transactions.some((tr) => tr.getMeta(\"composition\"))) return;\n\t\t\t\tconst docChanges = transactions.some((transaction) => transaction.docChanged) && !oldState.doc.eq(newState.doc);\n\t\t\t\tconst ignoreTr = transactions.some((transaction) => transaction.getMeta(\"preventClearDocument\"));\n\t\t\t\tif (!docChanges || ignoreTr) return;\n\t\t\t\tconst { empty, from, to } = oldState.selection;\n\t\t\t\tconst allFrom = _tiptap_pm_state.Selection.atStart(oldState.doc).from;\n\t\t\t\tconst allEnd = _tiptap_pm_state.Selection.atEnd(oldState.doc).to;\n\t\t\t\tif (empty || !(from === allFrom && to === allEnd)) return;\n\t\t\t\tif (!isNodeEmpty(newState.doc)) return;\n\t\t\t\tconst tr = newState.tr;\n\t\t\t\tconst state = createChainableState({\n\t\t\t\t\tstate: newState,\n\t\t\t\t\ttransaction: tr\n\t\t\t\t});\n\t\t\t\tconst { commands } = new CommandManager({\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tstate\n\t\t\t\t});\n\t\t\t\tcommands.clearNodes();\n\t\t\t\tif (!tr.steps.length) return;\n\t\t\t\treturn tr;\n\t\t\t}\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/paste.ts\nconst Paste = Extension.create({\n\tname: \"paste\",\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"tiptapPaste\"),\n\t\t\tprops: { handlePaste: (_view, e, slice) => {\n\t\t\t\tthis.editor.emit(\"paste\", {\n\t\t\t\t\teditor: this.editor,\n\t\t\t\t\tevent: e,\n\t\t\t\t\tslice\n\t\t\t\t});\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/tabindex.ts\n/**\n* The Tabindex extension adds a configurable tabindex attribute to the editor.\n*\n* By default, the editor gets tabindex=\"0\" when editable. This can be customized\n* via coreExtensionOptions to support specific focus ordering requirements in forms\n* or to enable focusing on non-editable editors.\n*\n* @example\n* ```ts\n* new Editor({\n* coreExtensionOptions: {\n* tabindex: {\n* value: '-1',\n* },\n* },\n* })\n* ```\n*/\nconst Tabindex = Extension.create({\n\tname: \"tabindex\",\n\taddOptions() {\n\t\treturn { value: void 0 };\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"tabindex\"),\n\t\t\tprops: { attributes: () => {\n\t\t\t\tvar _this$options$value;\n\t\t\t\tif (!this.editor.isEditable && this.options.value === void 0) return {};\n\t\t\t\treturn { tabindex: (_this$options$value = this.options.value) !== null && _this$options$value !== void 0 ? _this$options$value : \"0\" };\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/textDirection.ts\n/**\n* The TextDirection extension adds support for setting text direction (LTR/RTL/auto)\n* on all nodes in the editor.\n*\n* This extension adds a global `dir` attribute to all node types, which can be used\n* to control bidirectional text rendering. The direction can be set globally via\n* editor options or per-node using commands.\n*/\nconst TextDirection = Extension.create({\n\tname: \"textDirection\",\n\taddOptions() {\n\t\treturn { direction: void 0 };\n\t},\n\taddGlobalAttributes() {\n\t\tif (!this.options.direction) return [];\n\t\tconst { nodeExtensions } = splitExtensions(this.extensions);\n\t\treturn [{\n\t\t\ttypes: nodeExtensions.filter((extension) => extension.name !== \"text\").map((extension) => extension.name),\n\t\t\tattributes: { dir: {\n\t\t\t\tdefault: this.options.direction,\n\t\t\t\tparseHTML: (element) => {\n\t\t\t\t\tconst dir = element.getAttribute(\"dir\");\n\t\t\t\t\tif (dir && (dir === \"ltr\" || dir === \"rtl\" || dir === \"auto\")) return dir;\n\t\t\t\t\treturn this.options.direction;\n\t\t\t\t},\n\t\t\t\trenderHTML: (attributes) => {\n\t\t\t\t\tif (!attributes.dir) return {};\n\t\t\t\t\treturn { dir: attributes.dir };\n\t\t\t\t}\n\t\t\t} }\n\t\t}];\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"textDirection\"),\n\t\t\tprops: { attributes: () => {\n\t\t\t\tconst direction = this.options.direction;\n\t\t\t\tif (!direction) return {};\n\t\t\t\treturn { dir: direction };\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/extensions/index.ts\nvar extensions_exports = /* @__PURE__ */ __exportAll({\n\tClipboardTextSerializer: () => ClipboardTextSerializer,\n\tCommands: () => Commands,\n\tDelete: () => Delete,\n\tDrop: () => Drop,\n\tEditable: () => Editable,\n\tFocusEvents: () => FocusEvents,\n\tKeymap: () => Keymap,\n\tPaste: () => Paste,\n\tTabindex: () => Tabindex,\n\tTextDirection: () => TextDirection,\n\tfocusEventsPluginKey: () => focusEventsPluginKey\n});\n//#endregion\n//#region src/helpers/warnOnDuplicatedProseMirrorModel.ts\nlet hasChecked = false;\n/**\n* Warns once when prosemirror-model is loaded twice\n* @param schema The editor schema\n* @returns void\n* @example ```js\n* warnOnDuplicatedProseMirrorModel(editor.schema)\n* ```\n*/\nfunction warnOnDuplicatedProseMirrorModel(schema) {\n\tif (hasChecked) return;\n\thasChecked = true;\n\tlet content;\n\ttry {\n\t\tcontent = _tiptap_pm_transform.ReplaceStep.fromJSON(schema, {\n\t\t\tfrom: 0,\n\t\t\tto: 0\n\t\t}).slice.content;\n\t} catch {\n\t\treturn;\n\t}\n\tif (content instanceof _tiptap_pm_model.Fragment) return;\n\tconsole.warn(\"[tiptap warn]: prosemirror-model is loaded more than once. Wrapping and splitting nodes will fail. Deduplicate it in your lock file, or alias it to a single copy in your bundler.\");\n}\n//#endregion\n//#region src/NodePos.ts\nvar NodePos = class NodePos {\n\tget name() {\n\t\treturn this.node.type.name;\n\t}\n\tconstructor(pos, editor, isBlock = false, node = null) {\n\t\tthis.currentNode = null;\n\t\tthis.actualDepth = null;\n\t\tthis.isBlock = isBlock;\n\t\tthis.resolvedPos = pos;\n\t\tthis.editor = editor;\n\t\tthis.currentNode = node;\n\t}\n\tget node() {\n\t\treturn this.currentNode || this.resolvedPos.node();\n\t}\n\tget element() {\n\t\treturn this.editor.view.domAtPos(this.pos).node;\n\t}\n\tget depth() {\n\t\tvar _this$actualDepth;\n\t\treturn (_this$actualDepth = this.actualDepth) !== null && _this$actualDepth !== void 0 ? _this$actualDepth : this.resolvedPos.depth;\n\t}\n\tget pos() {\n\t\treturn this.resolvedPos.pos;\n\t}\n\tget content() {\n\t\treturn this.node.content;\n\t}\n\tset content(content) {\n\t\tlet from = this.from;\n\t\tlet to = this.to;\n\t\tif (this.isBlock) {\n\t\t\tif (this.content.size === 0) {\n\t\t\t\tconsole.error(`You can’t set content on a block node. Tried to set content on ${this.name} at ${this.pos}`);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tfrom = this.from + 1;\n\t\t\tto = this.to - 1;\n\t\t}\n\t\tthis.editor.commands.insertContentAt({\n\t\t\tfrom,\n\t\t\tto\n\t\t}, content);\n\t}\n\tget attributes() {\n\t\treturn this.node.attrs;\n\t}\n\tget textContent() {\n\t\treturn this.node.textContent;\n\t}\n\tget size() {\n\t\treturn this.node.nodeSize;\n\t}\n\tget from() {\n\t\tif (this.isBlock) return this.pos;\n\t\treturn this.resolvedPos.start(this.resolvedPos.depth);\n\t}\n\tget range() {\n\t\treturn {\n\t\t\tfrom: this.from,\n\t\t\tto: this.to\n\t\t};\n\t}\n\tget to() {\n\t\tif (this.isBlock) return this.pos + this.size;\n\t\treturn this.resolvedPos.end(this.resolvedPos.depth) + (this.node.isText ? 0 : 1);\n\t}\n\tget parent() {\n\t\tif (this.depth === 0) return null;\n\t\tconst parentPos = this.resolvedPos.start(this.resolvedPos.depth - 1);\n\t\tconst $pos = this.resolvedPos.doc.resolve(parentPos);\n\t\treturn new NodePos($pos, this.editor);\n\t}\n\tget before() {\n\t\tlet $pos = this.resolvedPos.doc.resolve(this.from - (this.isBlock ? 1 : 2));\n\t\tif ($pos.depth !== this.depth) $pos = this.resolvedPos.doc.resolve(this.from - 3);\n\t\treturn new NodePos($pos, this.editor);\n\t}\n\tget after() {\n\t\tlet $pos = this.resolvedPos.doc.resolve(this.to + (this.isBlock ? 2 : 1));\n\t\tif ($pos.depth !== this.depth) $pos = this.resolvedPos.doc.resolve(this.to + 3);\n\t\treturn new NodePos($pos, this.editor);\n\t}\n\tget children() {\n\t\tconst children = [];\n\t\tthis.node.content.forEach((node, offset) => {\n\t\t\tconst isBlock = node.isBlock && !node.isTextblock;\n\t\t\tconst isNonTextAtom = node.isAtom && !node.isText;\n\t\t\tconst isInline = node.isInline;\n\t\t\tconst targetPos = this.pos + offset + (isNonTextAtom ? 0 : 1);\n\t\t\tif (targetPos < 0 || targetPos > this.resolvedPos.doc.nodeSize - 2) return;\n\t\t\tconst $pos = this.resolvedPos.doc.resolve(targetPos);\n\t\t\tif (!isBlock && !isInline && $pos.depth <= this.depth) return;\n\t\t\tconst childNodePos = new NodePos($pos, this.editor, isBlock, isBlock || isInline ? node : null);\n\t\t\tif (isBlock) childNodePos.actualDepth = this.depth + 1;\n\t\t\tchildren.push(childNodePos);\n\t\t});\n\t\treturn children;\n\t}\n\tget firstChild() {\n\t\treturn this.children[0] || null;\n\t}\n\tget lastChild() {\n\t\tconst children = this.children;\n\t\treturn children[children.length - 1] || null;\n\t}\n\tclosest(selector, attributes = {}) {\n\t\tlet node = null;\n\t\tlet currentNode = this.parent;\n\t\twhile (currentNode && !node) {\n\t\t\tif (currentNode.node.type.name === selector) {\n\t\t\t\tif (Object.keys(attributes).length > 0) {\n\t\t\t\t\tconst nodeAttributes = currentNode.node.attrs;\n\t\t\t\t\tconst attrKeys = Object.keys(attributes);\n\t\t\t\t\tfor (let index = 0; index < attrKeys.length; index += 1) {\n\t\t\t\t\t\tconst key = attrKeys[index];\n\t\t\t\t\t\tif (nodeAttributes[key] !== attributes[key]) break;\n\t\t\t\t\t}\n\t\t\t\t} else node = currentNode;\n\t\t\t}\n\t\t\tcurrentNode = currentNode.parent;\n\t\t}\n\t\treturn node;\n\t}\n\tquerySelector(selector, attributes = {}) {\n\t\treturn this.querySelectorAll(selector, attributes, true)[0] || null;\n\t}\n\tquerySelectorAll(selector, attributes = {}, firstItemOnly = false) {\n\t\tlet nodes = [];\n\t\tif (!this.children || this.children.length === 0) return nodes;\n\t\tconst attrKeys = Object.keys(attributes);\n\t\t/**\n\t\t* Finds all children recursively that match the selector and attributes\n\t\t* If firstItemOnly is true, it will return the first item found\n\t\t*/\n\t\tthis.children.forEach((childPos) => {\n\t\t\tif (firstItemOnly && nodes.length > 0) return;\n\t\t\tif (childPos.node.type.name === selector) {\n\t\t\t\tif (attrKeys.every((key) => attributes[key] === childPos.node.attrs[key])) nodes.push(childPos);\n\t\t\t}\n\t\t\tif (firstItemOnly && nodes.length > 0) return;\n\t\t\tnodes = nodes.concat(childPos.querySelectorAll(selector, attributes, firstItemOnly));\n\t\t});\n\t\treturn nodes;\n\t}\n\tsetAttribute(attributes) {\n\t\tconst { tr } = this.editor.state;\n\t\ttr.setNodeMarkup(this.from, void 0, {\n\t\t\t...this.node.attrs,\n\t\t\t...attributes\n\t\t});\n\t\tthis.editor.view.dispatch(tr);\n\t}\n};\n//#endregion\n//#region src/style.ts\nconst style = `.ProseMirror {\n position: relative;\n}\n\n.ProseMirror {\n word-wrap: break-word;\n white-space: pre-wrap;\n white-space: break-spaces;\n -webkit-font-variant-ligatures: none;\n font-variant-ligatures: none;\n font-feature-settings: \"liga\" 0; /* the above doesn't seem to work in Edge */\n}\n\n.ProseMirror [contenteditable=\"false\"] {\n white-space: normal;\n}\n\n.ProseMirror [contenteditable=\"false\"] [contenteditable=\"true\"] {\n white-space: pre-wrap;\n}\n\n.ProseMirror pre {\n white-space: pre-wrap;\n}\n\nimg.ProseMirror-separator {\n display: inline !important;\n border: none !important;\n margin: 0 !important;\n width: 0 !important;\n height: 0 !important;\n}\n\n.ProseMirror-gapcursor {\n display: none;\n pointer-events: none;\n position: absolute;\n margin: 0;\n}\n\n.ProseMirror-gapcursor:after {\n content: \"\";\n display: block;\n position: absolute;\n top: -2px;\n width: 20px;\n border-top: 1px solid black;\n animation: ProseMirror-cursor-blink 1.1s steps(2, start) infinite;\n}\n\n@keyframes ProseMirror-cursor-blink {\n to {\n visibility: hidden;\n }\n}\n\n.ProseMirror-hideselection *::selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection *::-moz-selection {\n background: transparent;\n}\n\n.ProseMirror-hideselection * {\n caret-color: transparent;\n}\n\n.ProseMirror-focused .ProseMirror-gapcursor {\n display: block;\n}`;\n//#endregion\n//#region src/Editor.ts\nvar Editor = class extends EventEmitter {\n\tconstructor(options = {}) {\n\t\tsuper();\n\t\tthis.css = null;\n\t\tthis.className = \"tiptap\";\n\t\tthis.editorView = null;\n\t\tthis.isFocused = false;\n\t\tthis.destroyed = false;\n\t\tthis.isInitialized = false;\n\t\tthis.extensionStorage = {};\n\t\tthis.instanceId = Math.random().toString(36).slice(2, 9);\n\t\tthis.hasWarnedStaleDecorationRead = false;\n\t\tthis.options = {\n\t\t\telement: typeof document !== \"undefined\" ? document.createElement(\"div\") : null,\n\t\t\tcontent: \"\",\n\t\t\tinjectCSS: true,\n\t\t\tinjectNonce: void 0,\n\t\t\textensions: [],\n\t\t\tautofocus: false,\n\t\t\teditable: true,\n\t\t\ttextDirection: void 0,\n\t\t\teditorProps: {},\n\t\t\tparseOptions: {},\n\t\t\tcoreExtensionOptions: {},\n\t\t\tenableInputRules: true,\n\t\t\tenablePasteRules: true,\n\t\t\tenableCoreExtensions: true,\n\t\t\tenableContentCheck: false,\n\t\t\temitContentError: false,\n\t\t\tonBeforeCreate: () => null,\n\t\t\tonCreate: () => null,\n\t\t\tonMount: () => null,\n\t\t\tonUnmount: () => null,\n\t\t\tonUpdate: () => null,\n\t\t\tonSelectionUpdate: () => null,\n\t\t\tonTransaction: () => null,\n\t\t\tonFocus: () => null,\n\t\t\tonBlur: () => null,\n\t\t\tonDestroy: () => null,\n\t\t\tonContentError: ({ error }) => {\n\t\t\t\tthrow error;\n\t\t\t},\n\t\t\tonPaste: () => null,\n\t\t\tonDrop: () => null,\n\t\t\tonDelete: () => null,\n\t\t\tenableExtensionDispatchTransaction: true\n\t\t};\n\t\tthis.isCapturingTransaction = false;\n\t\tthis.capturedTransaction = null;\n\t\tthis.utils = {\n\t\t\tgetUpdatedPosition,\n\t\t\tcreateMappablePosition\n\t\t};\n\t\tthis.setOptions(options);\n\t\tthis.createExtensionManager();\n\t\tthis.createCommandManager();\n\t\tthis.createSchema();\n\t\tthis.on(\"beforeCreate\", this.options.onBeforeCreate);\n\t\tthis.emit(\"beforeCreate\", { editor: this });\n\t\tthis.on(\"mount\", this.options.onMount);\n\t\tthis.on(\"unmount\", this.options.onUnmount);\n\t\tthis.on(\"contentError\", this.options.onContentError);\n\t\tthis.on(\"create\", this.options.onCreate);\n\t\tthis.on(\"update\", this.options.onUpdate);\n\t\tthis.on(\"selectionUpdate\", this.options.onSelectionUpdate);\n\t\tthis.on(\"transaction\", this.options.onTransaction);\n\t\tthis.on(\"focus\", this.options.onFocus);\n\t\tthis.on(\"blur\", this.options.onBlur);\n\t\tthis.on(\"destroy\", this.options.onDestroy);\n\t\tthis.on(\"drop\", ({ event, slice, moved }) => this.options.onDrop(event, slice, moved));\n\t\tthis.on(\"paste\", ({ event, slice }) => this.options.onPaste(event, slice));\n\t\tthis.on(\"delete\", this.options.onDelete);\n\t\tconst initialDoc = this.createDoc();\n\t\tif (!this.editorState) {\n\t\t\tconst selection = resolveFocusPosition(initialDoc, this.options.autofocus);\n\t\t\tthis.editorState = _tiptap_pm_state.EditorState.create({\n\t\t\t\tdoc: initialDoc,\n\t\t\t\tschema: this.schema,\n\t\t\t\tselection: selection || void 0\n\t\t\t});\n\t\t}\n\t\twarnOnDuplicatedProseMirrorModel(this.schema);\n\t\tif (this.options.element) this.mount(this.options.element);\n\t}\n\t/**\n\t* Attach the editor to the DOM, creating a new editor view.\n\t*/\n\tmount(el) {\n\t\tif (typeof document === \"undefined\") throw new Error(`[tiptap error]: The editor cannot be mounted because there is no 'document' defined in this environment.`);\n\t\tthis.createView(el);\n\t\tthis.emit(\"mount\", { editor: this });\n\t\tif (this.css && !document.head.contains(this.css)) document.head.appendChild(this.css);\n\t\twindow.setTimeout(() => {\n\t\t\tif (this.isDestroyed) return;\n\t\t\tif (this.options.autofocus !== false && this.options.autofocus !== null) this.commands.focus(this.options.autofocus);\n\t\t\tthis.emit(\"create\", { editor: this });\n\t\t\tthis.isInitialized = true;\n\t\t}, 0);\n\t}\n\t/**\n\t* Remove the editor from the DOM, but still allow remounting at a different point in time\n\t*/\n\tunmount() {\n\t\tif (this.editorView) {\n\t\t\tthis.editorState = this.editorView.state;\n\t\t\tconst dom = this.editorView.dom;\n\t\t\tif (dom === null || dom === void 0 ? void 0 : dom.editor) delete dom.editor;\n\t\t\tthis.editorView.destroy();\n\t\t}\n\t\tthis.editorView = null;\n\t\tthis.isInitialized = false;\n\t\tif (this.css && !document.querySelectorAll(`.${this.className}`).length) try {\n\t\t\tif (typeof this.css.remove === \"function\") this.css.remove();\n\t\t\telse if (this.css.parentNode) this.css.parentNode.removeChild(this.css);\n\t\t} catch (error) {\n\t\t\tconsole.warn(\"Failed to remove CSS element:\", error);\n\t\t}\n\t\tthis.css = null;\n\t\tthis.emit(\"unmount\", { editor: this });\n\t}\n\t/**\n\t* Returns the editor storage.\n\t*/\n\tget storage() {\n\t\treturn this.extensionStorage;\n\t}\n\t/**\n\t* An object of all registered commands.\n\t*/\n\tget commands() {\n\t\treturn this.commandManager.commands;\n\t}\n\t/**\n\t* Create a command chain to call multiple commands at once.\n\t*/\n\tchain() {\n\t\tif (!this.commandManager) return CommandManager.createFakeChain();\n\t\treturn this.commandManager.chain();\n\t}\n\t/**\n\t* Check if a command or a command chain can be executed. Without executing it.\n\t*/\n\tcan() {\n\t\tif (!this.commandManager) return CommandManager.createFallbackCan();\n\t\treturn this.commandManager.can();\n\t}\n\t/**\n\t* Inject CSS styles.\n\t*/\n\tinjectCSS() {\n\t\tif (this.options.injectCSS && typeof document !== \"undefined\") this.css = createStyleTag(style, this.options.injectNonce);\n\t}\n\t/**\n\t* Update editor options.\n\t*\n\t* @param options A list of options\n\t*/\n\tsetOptions(options = {}) {\n\t\tthis.options = {\n\t\t\t...this.options,\n\t\t\t...options\n\t\t};\n\t\tif (!this.editorView || !this.state || this.isDestroyed) return;\n\t\tif (this.options.editorProps) this.view.setProps(this.options.editorProps);\n\t\tthis.view.updateState(this.state);\n\t}\n\t/**\n\t* Update editable state of the editor.\n\t*/\n\tsetEditable(editable, emitUpdate = true) {\n\t\tthis.setOptions({ editable });\n\t\tif (emitUpdate) this.emit(\"update\", {\n\t\t\teditor: this,\n\t\t\ttransaction: this.state.tr,\n\t\t\tappendedTransactions: []\n\t\t});\n\t}\n\t/**\n\t* Returns whether the editor is editable.\n\t*/\n\tget isEditable() {\n\t\treturn this.options.editable && this.view && this.view.editable;\n\t}\n\t/**\n\t* Returns the editor view.\n\t*/\n\tget view() {\n\t\tif (this.editorView) return this.editorView;\n\t\treturn new Proxy({\n\t\t\tstate: this.editorState,\n\t\t\tupdateState: (state) => {\n\t\t\t\tthis.editorState = state;\n\t\t\t},\n\t\t\tdispatch: (tr) => {\n\t\t\t\tthis.dispatchTransaction(tr);\n\t\t\t},\n\t\t\tcomposing: false,\n\t\t\tdragging: null,\n\t\t\teditable: true,\n\t\t\tisDestroyed: false\n\t\t}, { get: (obj, key) => {\n\t\t\tif (this.editorView) return this.editorView[key];\n\t\t\tif (key === \"state\") return this.editorState;\n\t\t\tif (key in obj) return Reflect.get(obj, key);\n\t\t\tthrow new Error(`[tiptap error]: The editor view is not available. Cannot access view['${key}']. The editor may not be mounted yet.`);\n\t\t} });\n\t}\n\t/**\n\t* Returns the editor state.\n\t*/\n\tget state() {\n\t\tif (isDev && !this.hasWarnedStaleDecorationRead && isInDecorationApplyScope(this)) {\n\t\t\tthis.hasWarnedStaleDecorationRead = true;\n\t\t\tconsole.warn(\"[tiptap warn]: `editor.state` was read while decoration `create()` was running. It returns the pre-transaction document. Use the `state` argument passed to `create()` instead. Helpers like `editor.isActive()` read `editor.state` too, so pass `state` to their standalone versions instead of calling them on the editor.\");\n\t\t}\n\t\tif (this.editorView) this.editorState = this.view.state;\n\t\treturn this.editorState;\n\t}\n\t/**\n\t* Register a ProseMirror plugin.\n\t*\n\t* @param plugin A ProseMirror plugin\n\t* @param handlePlugins Control how to merge the plugin into the existing plugins.\n\t* @returns The new editor state\n\t*/\n\tregisterPlugin(plugin, handlePlugins) {\n\t\tconst plugins = isFunction(handlePlugins) ? handlePlugins(plugin, [...this.state.plugins]) : [...this.state.plugins, plugin];\n\t\tconst state = this.state.reconfigure({ plugins });\n\t\tthis.view.updateState(state);\n\t\treturn state;\n\t}\n\t/**\n\t* Unregister a ProseMirror plugin.\n\t*\n\t* @param nameOrPluginKeyToRemove The plugins name\n\t* @returns The new editor state or undefined if the editor is destroyed\n\t*/\n\tunregisterPlugin(nameOrPluginKeyToRemove) {\n\t\tif (this.isDestroyed) return;\n\t\tconst prevPlugins = this.state.plugins;\n\t\tlet plugins = prevPlugins;\n\t\t[].concat(nameOrPluginKeyToRemove).forEach((nameOrPluginKey) => {\n\t\t\tconst name = typeof nameOrPluginKey === \"string\" ? `${nameOrPluginKey}$` : nameOrPluginKey.key;\n\t\t\tplugins = plugins.filter((plugin) => !plugin.key.startsWith(name));\n\t\t});\n\t\tif (prevPlugins.length === plugins.length) return;\n\t\tconst state = this.state.reconfigure({ plugins });\n\t\tthis.view.updateState(state);\n\t\treturn state;\n\t}\n\t/**\n\t* Creates an extension manager.\n\t*/\n\tcreateExtensionManager() {\n\t\tvar _this$options$coreExt, _this$options$coreExt2;\n\t\tconst allExtensions = [...this.options.enableCoreExtensions ? [\n\t\t\tEditable,\n\t\t\tClipboardTextSerializer.configure({ blockSeparator: (_this$options$coreExt = this.options.coreExtensionOptions) === null || _this$options$coreExt === void 0 || (_this$options$coreExt = _this$options$coreExt.clipboardTextSerializer) === null || _this$options$coreExt === void 0 ? void 0 : _this$options$coreExt.blockSeparator }),\n\t\t\tCommands,\n\t\t\tFocusEvents,\n\t\t\tKeymap,\n\t\t\tTabindex.configure({ value: (_this$options$coreExt2 = this.options.coreExtensionOptions) === null || _this$options$coreExt2 === void 0 || (_this$options$coreExt2 = _this$options$coreExt2.tabindex) === null || _this$options$coreExt2 === void 0 ? void 0 : _this$options$coreExt2.value }),\n\t\t\tDrop,\n\t\t\tPaste,\n\t\t\tDelete,\n\t\t\tTextDirection.configure({ direction: this.options.textDirection })\n\t\t].filter((ext) => {\n\t\t\tif (typeof this.options.enableCoreExtensions === \"object\") return this.options.enableCoreExtensions[ext.name] !== false;\n\t\t\treturn true;\n\t\t}) : [], ...this.options.extensions].filter((extension) => {\n\t\t\treturn [\n\t\t\t\t\"extension\",\n\t\t\t\t\"node\",\n\t\t\t\t\"mark\"\n\t\t\t].includes(extension === null || extension === void 0 ? void 0 : extension.type);\n\t\t});\n\t\tthis.extensionManager = new ExtensionManager(allExtensions, this);\n\t}\n\t/**\n\t* Creates an command manager.\n\t*/\n\tcreateCommandManager() {\n\t\tthis.commandManager = new CommandManager({ editor: this });\n\t}\n\t/**\n\t* Creates a ProseMirror schema.\n\t*/\n\tcreateSchema() {\n\t\tthis.schema = this.extensionManager.schema;\n\t}\n\t/**\n\t* Creates the initial document.\n\t*/\n\tcreateDoc() {\n\t\tlet doc;\n\t\ttry {\n\t\t\tdoc = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });\n\t\t} catch (e) {\n\t\t\tif (!(e instanceof Error) || ![\"[tiptap error]: Invalid JSON content\", \"[tiptap error]: Invalid HTML content\"].includes(e.message)) throw e;\n\t\t\tconst fallbackDoc = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });\n\t\t\tthis.editorState = _tiptap_pm_state.EditorState.create({\n\t\t\t\tdoc: fallbackDoc,\n\t\t\t\tschema: this.schema,\n\t\t\t\tselection: resolveFocusPosition(fallbackDoc, this.options.autofocus) || void 0\n\t\t\t});\n\t\t\tthis.emit(\"contentError\", {\n\t\t\t\teditor: this,\n\t\t\t\terror: e,\n\t\t\t\tdisableCollaboration: () => {\n\t\t\t\t\tif (\"collaboration\" in this.storage && typeof this.storage.collaboration === \"object\" && this.storage.collaboration) this.storage.collaboration.isDisabled = true;\n\t\t\t\t\tthis.options.extensions = this.options.extensions.filter((extension) => extension.name !== \"collaboration\");\n\t\t\t\t\tthis.createExtensionManager();\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn this.editorState.doc;\n\t\t}\n\t\treturn doc;\n\t}\n\t/**\n\t* Creates a ProseMirror view.\n\t*/\n\tcreateView(element) {\n\t\tconst { editorProps, enableExtensionDispatchTransaction } = this.options;\n\t\tconst baseDispatch = editorProps.dispatchTransaction || this.dispatchTransaction.bind(this);\n\t\tconst dispatch = enableExtensionDispatchTransaction ? this.extensionManager.dispatchTransaction(baseDispatch) : baseDispatch;\n\t\tconst baseTransformPastedHTML = editorProps.transformPastedHTML;\n\t\tconst transformPastedHTML = this.extensionManager.transformPastedHTML(baseTransformPastedHTML);\n\t\tthis.editorView = new _tiptap_pm_view.EditorView(element, {\n\t\t\t...editorProps,\n\t\t\tattributes: {\n\t\t\t\trole: \"textbox\",\n\t\t\t\t...editorProps === null || editorProps === void 0 ? void 0 : editorProps.attributes\n\t\t\t},\n\t\t\tdispatchTransaction: dispatch,\n\t\t\ttransformPastedHTML,\n\t\t\tstate: this.editorState,\n\t\t\tmarkViews: this.extensionManager.markViews,\n\t\t\tnodeViews: this.extensionManager.nodeViews\n\t\t});\n\t\tconst newState = this.state.reconfigure({ plugins: this.extensionManager.plugins });\n\t\tthis.view.updateState(newState);\n\t\tthis.prependClass();\n\t\tthis.injectCSS();\n\t\tconst dom = this.view.dom;\n\t\tdom.editor = this;\n\t}\n\t/**\n\t* Creates all node and mark views.\n\t*/\n\tcreateNodeViews() {\n\t\tif (this.view.isDestroyed) return;\n\t\tthis.view.setProps({\n\t\t\tmarkViews: this.extensionManager.markViews,\n\t\t\tnodeViews: this.extensionManager.nodeViews\n\t\t});\n\t}\n\t/**\n\t* Prepend class name to element.\n\t*/\n\tprependClass() {\n\t\tthis.view.dom.className = `${this.className} ${this.view.dom.className}`;\n\t}\n\tcaptureTransaction(fn) {\n\t\tthis.isCapturingTransaction = true;\n\t\tfn();\n\t\tthis.isCapturingTransaction = false;\n\t\tconst tr = this.capturedTransaction;\n\t\tthis.capturedTransaction = null;\n\t\treturn tr;\n\t}\n\t/**\n\t* The callback over which to send transactions (state updates) produced by the view.\n\t*\n\t* @param transaction An editor state transaction\n\t*/\n\tdispatchTransaction(transaction) {\n\t\tif (this.view.isDestroyed) return;\n\t\tif (this.isCapturingTransaction) {\n\t\t\tif (!this.capturedTransaction) {\n\t\t\t\tthis.capturedTransaction = transaction;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\ttransaction.steps.forEach((step) => {\n\t\t\t\tvar _this$capturedTransac;\n\t\t\t\treturn (_this$capturedTransac = this.capturedTransaction) === null || _this$capturedTransac === void 0 ? void 0 : _this$capturedTransac.step(step);\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tconst { state, transactions } = this.state.applyTransaction(transaction);\n\t\tconst selectionHasChanged = !this.state.selection.eq(state.selection);\n\t\tconst rootTrWasApplied = transactions.includes(transaction);\n\t\tconst prevState = this.state;\n\t\tthis.emit(\"beforeTransaction\", {\n\t\t\teditor: this,\n\t\t\ttransaction,\n\t\t\tnextState: state\n\t\t});\n\t\tif (!rootTrWasApplied) return;\n\t\tthis.view.updateState(state);\n\t\tthis.emit(\"transaction\", {\n\t\t\teditor: this,\n\t\t\ttransaction,\n\t\t\tappendedTransactions: transactions.slice(1)\n\t\t});\n\t\tif (selectionHasChanged) this.emit(\"selectionUpdate\", {\n\t\t\teditor: this,\n\t\t\ttransaction\n\t\t});\n\t\tconst mostRecentFocusTr = transactions.findLast((tr) => tr.getMeta(\"focus\") || tr.getMeta(\"blur\"));\n\t\tconst focus = mostRecentFocusTr === null || mostRecentFocusTr === void 0 ? void 0 : mostRecentFocusTr.getMeta(\"focus\");\n\t\tconst blur = mostRecentFocusTr === null || mostRecentFocusTr === void 0 ? void 0 : mostRecentFocusTr.getMeta(\"blur\");\n\t\tif (focus) this.emit(\"focus\", {\n\t\t\teditor: this,\n\t\t\tevent: focus.event,\n\t\t\ttransaction: mostRecentFocusTr\n\t\t});\n\t\tif (blur) this.emit(\"blur\", {\n\t\t\teditor: this,\n\t\t\tevent: blur.event,\n\t\t\ttransaction: mostRecentFocusTr\n\t\t});\n\t\tif (transaction.getMeta(\"preventUpdate\") || !transactions.some((tr) => tr.docChanged) || prevState.doc.eq(state.doc)) return;\n\t\tthis.emit(\"update\", {\n\t\t\teditor: this,\n\t\t\ttransaction,\n\t\t\tappendedTransactions: transactions.slice(1)\n\t\t});\n\t}\n\t/**\n\t* Get attributes of the currently selected node or mark.\n\t*/\n\tgetAttributes(nameOrType) {\n\t\treturn getAttributes(this.state, nameOrType);\n\t}\n\tisActive(nameOrAttributes, attributesOrUndefined) {\n\t\tconst name = typeof nameOrAttributes === \"string\" ? nameOrAttributes : null;\n\t\tconst attributes = typeof nameOrAttributes === \"string\" ? attributesOrUndefined : nameOrAttributes;\n\t\treturn isActive(this.state, name, attributes);\n\t}\n\t/**\n\t* Get the document as JSON.\n\t*/\n\tgetJSON() {\n\t\treturn this.state.doc.toJSON();\n\t}\n\t/**\n\t* Get the document as HTML.\n\t*/\n\tgetHTML() {\n\t\treturn getHTMLFromFragment(this.state.doc.content, this.schema);\n\t}\n\t/**\n\t* Get the document as text.\n\t*/\n\tgetText(options) {\n\t\tconst { blockSeparator = \"\\n\\n\", textSerializers = {} } = options || {};\n\t\treturn getText(this.state.doc, {\n\t\t\tblockSeparator,\n\t\t\ttextSerializers: {\n\t\t\t\t...getTextSerializersFromSchema(this.schema),\n\t\t\t\t...textSerializers\n\t\t\t}\n\t\t});\n\t}\n\t/**\n\t* Check if there is no content.\n\t*/\n\tget isEmpty() {\n\t\treturn isNodeEmpty(this.state.doc);\n\t}\n\t/**\n\t* Destroy the editor.\n\t*/\n\tdestroy() {\n\t\tif (this.destroyed) return;\n\t\tthis.destroyed = true;\n\t\tthis.emit(\"destroy\");\n\t\tthis.unmount();\n\t\tthis.removeAllListeners();\n\t\tthis.extensionManager.destroy();\n\t\tthis.extensionManager = null;\n\t\tthis.schema = null;\n\t\tthis.commandManager = null;\n\t\tthis.extensionStorage = {};\n\t}\n\t/**\n\t* Check if the editor is already destroyed.\n\t*/\n\tget isDestroyed() {\n\t\tvar _this$editorView$isDe, _this$editorView;\n\t\treturn (_this$editorView$isDe = (_this$editorView = this.editorView) === null || _this$editorView === void 0 ? void 0 : _this$editorView.isDestroyed) !== null && _this$editorView$isDe !== void 0 ? _this$editorView$isDe : true;\n\t}\n\t$node(selector, attributes) {\n\t\tvar _this$$doc;\n\t\treturn ((_this$$doc = this.$doc) === null || _this$$doc === void 0 ? void 0 : _this$$doc.querySelector(selector, attributes)) || null;\n\t}\n\t$nodes(selector, attributes) {\n\t\tvar _this$$doc2;\n\t\treturn ((_this$$doc2 = this.$doc) === null || _this$$doc2 === void 0 ? void 0 : _this$$doc2.querySelectorAll(selector, attributes)) || null;\n\t}\n\t$pos(pos) {\n\t\tconst $pos = this.state.doc.resolve(pos);\n\t\tconst node = pos > 0 && $pos.nodeAfter && !$pos.nodeAfter.isText && $pos.nodeAfter.isAtom ? $pos.nodeAfter : null;\n\t\treturn new NodePos($pos, this, false, node);\n\t}\n\tget $doc() {\n\t\treturn this.$pos(0);\n\t}\n};\n//#endregion\n//#region src/decorations/Decoration.ts\n/**\n* Base class for decorations built in `addDecorations()`. Shadows `Decoration`\n* from `@tiptap/pm/view`, like core's `Node` and `Mark` do, so alias one of them\n* in files that need both.\n*\n* @example\n* import { Decoration } from '@tiptap/core'\n* import { Decoration as PMDecoration } from '@tiptap/pm/view'\n*\n* const highlight = Decoration.Inline(1, 5, { class: 'highlight' })\n*/\nvar Decoration = class {\n\tstatic Inline(from, to, attrs = {}, spec) {\n\t\treturn new InlineDecoration(from, to, attrs, spec);\n\t}\n\tstatic Node(pos, to, attrs = {}, spec) {\n\t\treturn new NodeDecoration(pos, to, attrs, spec);\n\t}\n\t/**\n\t* Creates a widget decoration: a DOM node drawn at a document position.\n\t*\n\t* The `key` is the widget's identity. While it stays the same, ProseMirror\n\t* keeps the widget mounted and only its position tracks the document.\n\t* `render`, `side`, `destroy` and other options are fixed on first mount.\n\t* Change the key to remount with new options.\n\t*\n\t* @param pos The document position where the widget is drawn.\n\t* @param render Called once on first mount. Returns the DOM node.\n\t* @param options Must include a unique `key`. See `WidgetDecorationOptions`.\n\t* @returns The widget decoration.\n\t*/\n\tstatic Widget(pos, render, options) {\n\t\tconst { key, ...spec } = options;\n\t\treturn new WidgetDecoration(pos, render, key, spec);\n\t}\n};\n/**\n* Represents an inline decoration (text-level highlighting, etc.).\n*/\nvar InlineDecoration = class extends Decoration {\n\tconstructor(from, to, attrs = {}, spec) {\n\t\tsuper();\n\t\tthis.kind = \"inline\";\n\t\tthis.from = from;\n\t\tthis.to = to;\n\t\tthis.attrs = attrs;\n\t\tthis.spec = spec;\n\t}\n\tget anchor() {\n\t\treturn this.from;\n\t}\n\ttoPMDecoration(extensionName) {\n\t\tconst spec = extensionName ? {\n\t\t\t...this.spec,\n\t\t\textensionName\n\t\t} : this.spec;\n\t\treturn _tiptap_pm_view.Decoration.inline(this.from, this.to, this.attrs, spec);\n\t}\n};\n/**\n* Represents a node-level decoration (block-level highlights, etc.).\n*/\nvar NodeDecoration = class extends Decoration {\n\tconstructor(pos, to, attrs = {}, spec) {\n\t\tsuper();\n\t\tthis.kind = \"node\";\n\t\tthis.from = pos;\n\t\tthis.to = to;\n\t\tthis.attrs = attrs;\n\t\tthis.spec = spec;\n\t}\n\tget anchor() {\n\t\treturn this.from;\n\t}\n\ttoPMDecoration(extensionName) {\n\t\tconst spec = extensionName ? {\n\t\t\t...this.spec,\n\t\t\textensionName\n\t\t} : this.spec;\n\t\treturn _tiptap_pm_view.Decoration.node(this.from, this.to, this.attrs, spec);\n\t}\n};\n/**\n* Represents a widget decoration (inline widgets, etc.).\n*/\nvar WidgetDecoration = class extends Decoration {\n\tconstructor(pos, render, key, spec) {\n\t\tsuper();\n\t\tthis.kind = \"widget\";\n\t\tthis.pos = pos;\n\t\tthis.render = render;\n\t\tthis.key = key;\n\t\tthis.spec = spec;\n\t}\n\tget anchor() {\n\t\treturn this.pos;\n\t}\n\ttoPMDecoration(extensionName) {\n\t\tconst spec = extensionName ? {\n\t\t\t...this.spec,\n\t\t\tkey: this.key,\n\t\t\textensionName\n\t\t} : {\n\t\t\t...this.spec,\n\t\t\tkey: this.key\n\t\t};\n\t\treturn _tiptap_pm_view.Decoration.widget(this.pos, this.render, spec);\n\t}\n};\n//#endregion\n//#region src/decorations/createWidgetDecoration.ts\nfunction getCache(editor, cacheKey) {\n\tconst host = editor;\n\tlet cache = host[cacheKey];\n\tif (!cache) {\n\t\tcache = {\n\t\t\trenderers: /* @__PURE__ */ new Map(),\n\t\t\tprops: /* @__PURE__ */ new Map(),\n\t\t\tpendingProps: /* @__PURE__ */ new Map(),\n\t\t\tflushScheduled: false\n\t\t};\n\t\thost[cacheKey] = cache;\n\t\tconst sweep = cache;\n\t\teditor.on(\"destroy\", () => {\n\t\t\tsweep.pendingProps.clear();\n\t\t\tsweep.renderers.forEach((renderer) => renderer.destroy());\n\t\t\tsweep.renderers.clear();\n\t\t\tsweep.props.clear();\n\t\t});\n\t}\n\treturn cache;\n}\nfunction flushPendingProps(cache) {\n\tcache.flushScheduled = false;\n\tfor (const [key, props] of cache.pendingProps) {\n\t\tconst renderer = cache.renderers.get(key);\n\t\tif (renderer) {\n\t\t\trenderer.updateProps(props);\n\t\t\tcache.props.set(key, { ...props });\n\t\t}\n\t}\n\tcache.pendingProps.clear();\n}\n/**\n* Builds a widget decoration backed by a framework component renderer.\n*\n* Owns everything that is not framework specific: the per-editor renderer\n* cache, prop diffing, the deferred prop flush, the key reassignment guard and\n* the ProseMirror option pass-through. Framework packages supply only `create`,\n* `context` and `materialize`.\n*\n* @param options The widget options plus the three framework hooks.\n* @returns The widget decoration to return from `addDecorations`.\n* @example\n* createWidgetDecoration<ReactRenderer>({\n* editor, pos, key, props, cacheKey: WIDGET_CACHE,\n* context: getPos => ({ editor, getPos }),\n* create: renderProps => new ReactRenderer(component, { editor, props: renderProps }),\n* materialize: renderer => renderer.element,\n* })\n*/\nfunction createWidgetDecoration(options) {\n\tconst { editor, pos, key, props, cacheKey, context, create, materialize, side, relaxedSide, marks, stopEvent, ignoreSelection, destroy } = options;\n\tconst cache = getCache(editor, cacheKey);\n\tif (cache.renderers.has(key)) {\n\t\tvar _cache$pendingProps$g;\n\t\tconst previous = (_cache$pendingProps$g = cache.pendingProps.get(key)) !== null && _cache$pendingProps$g !== void 0 ? _cache$pendingProps$g : cache.props.get(key);\n\t\tif (!previous || !attrsEqual(previous, props)) {\n\t\t\tcache.pendingProps.set(key, props);\n\t\t\tif (!cache.flushScheduled) {\n\t\t\t\tcache.flushScheduled = true;\n\t\t\t\tqueueMicrotask(() => flushPendingProps(cache));\n\t\t\t}\n\t\t}\n\t}\n\tconst render = (_view, getPos) => {\n\t\tconst renderProps = {\n\t\t\t...props,\n\t\t\t...context(getPos)\n\t\t};\n\t\tlet renderer = cache.renderers.get(key);\n\t\tif (renderer) renderer.updateProps(renderProps);\n\t\telse {\n\t\t\trenderer = create(renderProps);\n\t\t\tcache.renderers.set(key, renderer);\n\t\t\tcache.props.set(key, { ...props });\n\t\t}\n\t\treturn materialize(renderer);\n\t};\n\treturn Decoration.Widget(pos, render, {\n\t\tkey,\n\t\tside,\n\t\trelaxedSide,\n\t\tmarks,\n\t\tstopEvent,\n\t\tignoreSelection,\n\t\tdestroy: (rendererElement) => {\n\t\t\tif (liveWidgetKeys(editor).has(key)) return;\n\t\t\ttry {\n\t\t\t\tvar _cache$renderers$get;\n\t\t\t\t(_cache$renderers$get = cache.renderers.get(key)) === null || _cache$renderers$get === void 0 || _cache$renderers$get.destroy();\n\t\t\t\tcache.renderers.delete(key);\n\t\t\t\tcache.props.delete(key);\n\t\t\t\tcache.pendingProps.delete(key);\n\t\t\t} finally {\n\t\t\t\tdestroy === null || destroy === void 0 || destroy(rendererElement);\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\n//#region src/inputRules/markInputRule.ts\n/**\n* Build an input rule that adds a mark when the\n* matched text is typed into it.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n*/\nfunction markInputRule(config) {\n\treturn new InputRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match }) => {\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match);\n\t\t\tif (attributes === false || attributes === null) return null;\n\t\t\tconst { tr } = state;\n\t\t\tconst captureGroup = match[match.length - 1];\n\t\t\tconst fullMatch = match[0];\n\t\t\tif (captureGroup) {\n\t\t\t\tconst startSpaces = fullMatch.search(/\\S/);\n\t\t\t\tconst textStart = range.from + fullMatch.indexOf(captureGroup);\n\t\t\t\tconst textEnd = textStart + captureGroup.length;\n\t\t\t\tif (getMarksBetween(range.from, range.to, state.doc).filter((item) => {\n\t\t\t\t\treturn item.mark.type.excluded.find((type) => type === config.type && type !== item.mark.type);\n\t\t\t\t}).filter((item) => item.to > textStart).length) return null;\n\t\t\t\tif (textEnd < range.to) tr.delete(textEnd, range.to);\n\t\t\t\tif (textStart > range.from) tr.delete(range.from + startSpaces, textStart);\n\t\t\t\tconst markEnd = range.from + startSpaces + captureGroup.length;\n\t\t\t\ttr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));\n\t\t\t\ttr.removeStoredMark(config.type);\n\t\t\t}\n\t\t},\n\t\tundoable: config.undoable\n\t});\n}\n//#endregion\n//#region src/inputRules/nodeInputRule.ts\n/**\n* Build an input rule that adds a node when the\n* matched text is typed into it.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n*/\nfunction nodeInputRule(config) {\n\treturn new InputRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match }) => {\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match) || {};\n\t\t\tconst { tr } = state;\n\t\t\tconst start = range.from;\n\t\t\tlet end = range.to;\n\t\t\tconst newNode = config.type.create(attributes);\n\t\t\tif (match[1]) {\n\t\t\t\tlet matchStart = start + match[0].lastIndexOf(match[1]);\n\t\t\t\tif (matchStart > end) matchStart = end;\n\t\t\t\telse end = matchStart + match[1].length;\n\t\t\t\tconst lastChar = match[0][match[0].length - 1];\n\t\t\t\ttr.insertText(lastChar, start + match[0].length - 1);\n\t\t\t\ttr.replaceWith(matchStart, end, newNode);\n\t\t\t} else if (match[0]) {\n\t\t\t\tconst insertionStart = config.type.isInline ? start : start - 1;\n\t\t\t\ttr.insert(insertionStart, config.type.create(attributes)).delete(tr.mapping.map(start), tr.mapping.map(end));\n\t\t\t}\n\t\t\ttr.scrollIntoView();\n\t\t},\n\t\tundoable: config.undoable\n\t});\n}\n//#endregion\n//#region src/inputRules/textblockTypeInputRule.ts\n/**\n* Build an input rule that changes the type of a textblock when the\n* matched text is typed into it. When using a regular expresion you’ll\n* probably want the regexp to start with `^`, so that the pattern can\n* only occur at the start of a textblock.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n*/\nfunction textblockTypeInputRule(config) {\n\treturn new InputRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match }) => {\n\t\t\tconst $start = state.doc.resolve(range.from);\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match) || {};\n\t\t\tif (!$start.node(-1).canReplaceWith($start.index(-1), $start.indexAfter(-1), config.type)) return null;\n\t\t\tstate.tr.delete(range.from, range.to).setBlockType(range.from, range.from, config.type, attributes);\n\t\t},\n\t\tundoable: config.undoable\n\t});\n}\n//#endregion\n//#region src/inputRules/textInputRule.ts\n/**\n* Build an input rule that replaces text when the\n* matched text is typed into it.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n*/\nfunction textInputRule(config) {\n\treturn new InputRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match }) => {\n\t\t\tlet insert = config.replace;\n\t\t\tlet start = range.from;\n\t\t\tconst end = range.to;\n\t\t\tif (match[1]) {\n\t\t\t\tconst offset = match[0].lastIndexOf(match[1]);\n\t\t\t\tinsert += match[0].slice(offset + match[1].length);\n\t\t\t\tstart += offset;\n\t\t\t\tconst cutOff = start - end;\n\t\t\t\tif (cutOff > 0) {\n\t\t\t\t\tinsert = match[0].slice(offset - cutOff, offset) + insert;\n\t\t\t\t\tstart = end;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.tr.insertText(insert, start, end);\n\t\t},\n\t\tundoable: config.undoable\n\t});\n}\n//#endregion\n//#region src/inputRules/wrappingInputRule.ts\n/**\n* Build an input rule for automatically wrapping a textblock when a\n* given string is typed. When using a regular expresion you’ll\n* probably want the regexp to start with `^`, so that the pattern can\n* only occur at the start of a textblock.\n*\n* `type` is the type of node to wrap in.\n*\n* By default, if there’s a node with the same type above the newly\n* wrapped node, the rule will try to join those\n* two nodes. You can pass a join predicate, which takes a regular\n* expression match and the node before the wrapped node, and can\n* return a boolean to indicate whether a join should happen.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#input-rules\n*/\nfunction wrappingInputRule(config) {\n\treturn new InputRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match, chain }) => {\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match) || {};\n\t\t\tconst tr = state.tr.delete(range.from, range.to);\n\t\t\tconst blockRange = tr.doc.resolve(range.from).blockRange();\n\t\t\tconst wrapping = blockRange && (0, _tiptap_pm_transform.findWrapping)(blockRange, config.type, attributes);\n\t\t\tif (!wrapping) return null;\n\t\t\ttr.wrap(blockRange, wrapping);\n\t\t\tif (config.keepMarks && config.editor) {\n\t\t\t\tconst { selection, storedMarks } = state;\n\t\t\t\tconst { splittableMarks } = config.editor.extensionManager;\n\t\t\t\tconst marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();\n\t\t\t\tif (marks) {\n\t\t\t\t\tconst filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));\n\t\t\t\t\ttr.ensureMarks(filteredMarks);\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (config.keepAttributes) {\n\t\t\t\t/** If the nodeType is `bulletList` or `orderedList` set the `nodeType` as `listItem` */\n\t\t\t\tconst nodeType = config.type.name === \"bulletList\" || config.type.name === \"orderedList\" ? \"listItem\" : \"taskList\";\n\t\t\t\tchain().updateAttributes(nodeType, attributes).run();\n\t\t\t}\n\t\t\tconst before = tr.doc.resolve(range.from - 1).nodeBefore;\n\t\t\tif (before && before.type === config.type && (0, _tiptap_pm_transform.canJoin)(tr.doc, range.from - 1) && (!config.joinPredicate || config.joinPredicate(match, before))) tr.join(range.from - 1);\n\t\t},\n\t\tundoable: config.undoable\n\t});\n}\n//#endregion\n//#region src/jsx-runtime.ts\nconst jsxElements = /* @__PURE__ */ new WeakSet();\nconst jsxFragments = /* @__PURE__ */ new WeakSet();\n/** Create a new JSX element from the given spec */\nfunction createJSXElement(spec) {\n\tconst element = spec;\n\tjsxElements.add(element);\n\treturn element;\n}\n/** Check if a spec is a JSX element */\nfunction isJSXElement(value) {\n\treturn Array.isArray(value) && jsxElements.has(value);\n}\nfunction flattenFragmentChildren(children) {\n\treturn children.flatMap((child) => {\n\t\tif (child == null) return [];\n\t\tif (Array.isArray(child) && jsxFragments.has(child) && !isJSXElement(child)) return flattenFragmentChildren(child);\n\t\treturn [child];\n\t});\n}\nfunction Fragment(props) {\n\tjsxFragments.add(props.children);\n\treturn props.children;\n}\nfunction render(tag, attributes) {\n\tif (tag === \"slot\") return 0;\n\tif (tag instanceof Function) {\n\t\tconst result = tag(attributes);\n\t\tif (Array.isArray(result) && !isJSXElement(result) && !jsxFragments.has(result)) return createJSXElement(result);\n\t\treturn result;\n\t}\n\tconst { children, ...rest } = attributes !== null && attributes !== void 0 ? attributes : {};\n\tif (tag === \"svg\") throw new Error(\"SVG elements are not supported in the JSX syntax, use the array syntax instead\");\n\tif (Array.isArray(children)) {\n\t\tif (isJSXElement(children)) return createJSXElement([\n\t\t\ttag,\n\t\t\trest,\n\t\t\tchildren\n\t\t]);\n\t\tif (children.length === 0) return createJSXElement([tag, rest]);\n\t\tconst flattenedChildren = flattenFragmentChildren(children);\n\t\tif (flattenedChildren.length === 0) return createJSXElement([tag, rest]);\n\t\treturn createJSXElement([\n\t\t\ttag,\n\t\t\trest,\n\t\t\t...flattenedChildren\n\t\t]);\n\t}\n\tif (children !== void 0 && children !== null) return createJSXElement([\n\t\ttag,\n\t\trest,\n\t\tchildren\n\t]);\n\treturn createJSXElement([tag, rest]);\n}\nconst h = (tag, attributes) => render(tag, attributes);\n//#endregion\n//#region src/lib/ResizableNodeView.ts\nconst isTouchEvent = (e) => {\n\treturn \"touches\" in e;\n};\n/**\n* A NodeView implementation that adds resize handles to any DOM element.\n*\n* This class creates a resizable node view for Tiptap/ProseMirror editors.\n* It wraps your element with resize handles and manages the resize interaction,\n* including aspect ratio preservation, min/max constraints, and keyboard modifiers.\n*\n* @example\n* ```ts\n* // Basic usage in a Tiptap extension\n* addNodeView() {\n* return ({ node, getPos }) => {\n* const img = document.createElement('img')\n* img.src = node.attrs.src\n*\n* return new ResizableNodeView({\n* element: img,\n* node,\n* getPos,\n* onResize: (width, height) => {\n* img.style.width = `${width}px`\n* img.style.height = `${height}px`\n* },\n* onCommit: (width, height) => {\n* this.editor.commands.updateAttributes('image', { width, height })\n* },\n* onUpdate: () => true,\n* options: {\n* min: { width: 100, height: 100 },\n* preserveAspectRatio: true\n* }\n* })\n* }\n* }\n* ```\n*/\nvar ResizableNodeView = class {\n\t/**\n\t* Creates a new ResizableNodeView instance.\n\t*\n\t* The constructor sets up the resize handles, applies initial sizing from\n\t* node attributes, and configures all resize behavior options.\n\t*\n\t* @param options - Configuration options for the resizable node view\n\t*/\n\tconstructor(options) {\n\t\tvar _options$options, _options$options2, _options$options3, _options$options4, _options$options5, _options$options6;\n\t\tthis.directions = [\n\t\t\t\"bottom-left\",\n\t\t\t\"bottom-right\",\n\t\t\t\"top-left\",\n\t\t\t\"top-right\"\n\t\t];\n\t\tthis.minSize = {\n\t\t\theight: 8,\n\t\t\twidth: 8\n\t\t};\n\t\tthis.preserveAspectRatio = false;\n\t\tthis.classNames = {\n\t\t\tcontainer: \"\",\n\t\t\twrapper: \"\",\n\t\t\thandle: \"\",\n\t\t\tresizing: \"\"\n\t\t};\n\t\tthis.initialWidth = 0;\n\t\tthis.initialHeight = 0;\n\t\tthis.aspectRatio = 1;\n\t\tthis.isResizing = false;\n\t\tthis.activeHandle = null;\n\t\tthis.startX = 0;\n\t\tthis.startY = 0;\n\t\tthis.startWidth = 0;\n\t\tthis.startHeight = 0;\n\t\tthis.isShiftKeyPressed = false;\n\t\tthis.lastEditableState = void 0;\n\t\tthis.handleMap = /* @__PURE__ */ new Map();\n\t\tthis.handleMouseMove = (event) => {\n\t\t\tif (!this.isResizing || !this.activeHandle) return;\n\t\t\tconst deltaX = event.clientX - this.startX;\n\t\t\tconst deltaY = event.clientY - this.startY;\n\t\t\tthis.handleResize(deltaX, deltaY);\n\t\t};\n\t\tthis.handleTouchMove = (event) => {\n\t\t\tif (!this.isResizing || !this.activeHandle) return;\n\t\t\tconst touch = event.touches[0];\n\t\t\tif (!touch) return;\n\t\t\tconst deltaX = touch.clientX - this.startX;\n\t\t\tconst deltaY = touch.clientY - this.startY;\n\t\t\tthis.handleResize(deltaX, deltaY);\n\t\t};\n\t\tthis.handleMouseUp = () => {\n\t\t\tif (!this.isResizing) return;\n\t\t\tconst finalWidth = this.element.offsetWidth;\n\t\t\tconst finalHeight = this.element.offsetHeight;\n\t\t\tthis.onCommit(finalWidth, finalHeight);\n\t\t\tthis.isResizing = false;\n\t\t\tthis.activeHandle = null;\n\t\t\tthis.container.dataset.resizeState = \"false\";\n\t\t\tif (this.classNames.resizing) this.container.classList.remove(this.classNames.resizing);\n\t\t\tdocument.removeEventListener(\"mousemove\", this.handleMouseMove);\n\t\t\tdocument.removeEventListener(\"mouseup\", this.handleMouseUp);\n\t\t\tdocument.removeEventListener(\"keydown\", this.handleKeyDown);\n\t\t\tdocument.removeEventListener(\"keyup\", this.handleKeyUp);\n\t\t};\n\t\tthis.handleKeyDown = (event) => {\n\t\t\tif (event.key === \"Shift\") this.isShiftKeyPressed = true;\n\t\t};\n\t\tthis.handleKeyUp = (event) => {\n\t\t\tif (event.key === \"Shift\") this.isShiftKeyPressed = false;\n\t\t};\n\t\tthis.node = options.node;\n\t\tthis.editor = options.editor;\n\t\tthis.element = options.element;\n\t\tthis.element.draggable = false;\n\t\tthis.contentElement = options.contentElement;\n\t\tthis.getPos = options.getPos;\n\t\tthis.onResize = options.onResize;\n\t\tthis.onCommit = options.onCommit;\n\t\tthis.onUpdate = options.onUpdate;\n\t\tif ((_options$options = options.options) === null || _options$options === void 0 ? void 0 : _options$options.min) this.minSize = {\n\t\t\t...this.minSize,\n\t\t\t...options.options.min\n\t\t};\n\t\tif ((_options$options2 = options.options) === null || _options$options2 === void 0 ? void 0 : _options$options2.max) this.maxSize = options.options.max;\n\t\tif (options === null || options === void 0 || (_options$options3 = options.options) === null || _options$options3 === void 0 ? void 0 : _options$options3.directions) this.directions = options.options.directions;\n\t\tif ((_options$options4 = options.options) === null || _options$options4 === void 0 ? void 0 : _options$options4.preserveAspectRatio) this.preserveAspectRatio = options.options.preserveAspectRatio;\n\t\tif ((_options$options5 = options.options) === null || _options$options5 === void 0 ? void 0 : _options$options5.className) this.classNames = {\n\t\t\tcontainer: options.options.className.container || \"\",\n\t\t\twrapper: options.options.className.wrapper || \"\",\n\t\t\thandle: options.options.className.handle || \"\",\n\t\t\tresizing: options.options.className.resizing || \"\"\n\t\t};\n\t\tif ((_options$options6 = options.options) === null || _options$options6 === void 0 ? void 0 : _options$options6.createCustomHandle) this.createCustomHandle = options.options.createCustomHandle;\n\t\tthis.wrapper = this.createWrapper();\n\t\tthis.container = this.createContainer();\n\t\tthis.applyInitialSize();\n\t\tthis.attachHandles();\n\t\tthis.editor.on(\"update\", this.handleEditorUpdate.bind(this));\n\t}\n\t/**\n\t* Returns the top-level DOM node that should be placed in the editor.\n\t*\n\t* This is required by the ProseMirror NodeView interface. The container\n\t* includes the wrapper, handles, and the actual content element.\n\t*\n\t* @returns The container element to be inserted into the editor\n\t*/\n\tget dom() {\n\t\treturn this.container;\n\t}\n\tget contentDOM() {\n\t\tvar _this$contentElement;\n\t\treturn (_this$contentElement = this.contentElement) !== null && _this$contentElement !== void 0 ? _this$contentElement : null;\n\t}\n\thandleEditorUpdate() {\n\t\tconst isEditable = this.editor.isEditable;\n\t\tif (isEditable === this.lastEditableState) return;\n\t\tthis.lastEditableState = isEditable;\n\t\tif (!isEditable) this.removeHandles();\n\t\telse if (isEditable && this.handleMap.size === 0) this.attachHandles();\n\t}\n\t/**\n\t* Called when the node's content or attributes change.\n\t*\n\t* Updates the internal node reference. If a custom `onUpdate` callback\n\t* was provided, it will be called to handle additional update logic.\n\t*\n\t* @param node - The new/updated node\n\t* @param decorations - Node decorations\n\t* @param innerDecorations - Inner decorations\n\t* @returns `false` if the node type has changed (requires full rebuild), otherwise the result of `onUpdate` or `true`\n\t*/\n\tupdate(node, decorations, innerDecorations) {\n\t\tif (node.type !== this.node.type) return false;\n\t\tthis.node = node;\n\t\tif (this.onUpdate) return this.onUpdate(node, decorations, innerDecorations);\n\t\treturn true;\n\t}\n\t/**\n\t* Cleanup method called when the node view is being removed.\n\t*\n\t* Removes all event listeners to prevent memory leaks. This is required\n\t* by the ProseMirror NodeView interface. If a resize is active when\n\t* destroy is called, it will be properly cancelled.\n\t*/\n\tdestroy() {\n\t\tif (this.isResizing) {\n\t\t\tthis.container.dataset.resizeState = \"false\";\n\t\t\tif (this.classNames.resizing) this.container.classList.remove(this.classNames.resizing);\n\t\t\tdocument.removeEventListener(\"mousemove\", this.handleMouseMove);\n\t\t\tdocument.removeEventListener(\"mouseup\", this.handleMouseUp);\n\t\t\tdocument.removeEventListener(\"keydown\", this.handleKeyDown);\n\t\t\tdocument.removeEventListener(\"keyup\", this.handleKeyUp);\n\t\t\tthis.isResizing = false;\n\t\t\tthis.activeHandle = null;\n\t\t}\n\t\tthis.editor.off(\"update\", this.handleEditorUpdate.bind(this));\n\t\tthis.container.remove();\n\t}\n\t/**\n\t* Creates the outer container element.\n\t*\n\t* The container is the top-level element returned by the NodeView and\n\t* wraps the entire resizable node. It's set up with flexbox to handle\n\t* alignment and includes data attributes for styling and identification.\n\t*\n\t* @returns The container element\n\t*/\n\tcreateContainer() {\n\t\tconst element = document.createElement(\"div\");\n\t\telement.dataset.resizeContainer = \"\";\n\t\telement.dataset.node = this.node.type.name;\n\t\telement.style.display = this.node.type.isInline ? \"inline-flex\" : \"flex\";\n\t\tif (this.classNames.container) element.className = this.classNames.container;\n\t\telement.appendChild(this.wrapper);\n\t\treturn element;\n\t}\n\t/**\n\t* Creates the wrapper element that contains the content and handles.\n\t*\n\t* The wrapper uses relative positioning so that resize handles can be\n\t* positioned absolutely within it. This is the direct parent of the\n\t* content element being made resizable.\n\t*\n\t* @returns The wrapper element\n\t*/\n\tcreateWrapper() {\n\t\tconst element = document.createElement(\"div\");\n\t\telement.style.position = \"relative\";\n\t\telement.style.display = \"block\";\n\t\telement.dataset.resizeWrapper = \"\";\n\t\tif (this.classNames.wrapper) element.className = this.classNames.wrapper;\n\t\telement.appendChild(this.element);\n\t\treturn element;\n\t}\n\t/**\n\t* Creates a resize handle element for a specific direction.\n\t*\n\t* Each handle is absolutely positioned and includes a data attribute\n\t* identifying its direction for styling purposes.\n\t*\n\t* @param direction - The resize direction for this handle\n\t* @returns The handle element\n\t*/\n\tcreateHandle(direction) {\n\t\tconst handle = document.createElement(\"div\");\n\t\thandle.dataset.resizeHandle = direction;\n\t\thandle.style.position = \"absolute\";\n\t\tif (this.classNames.handle) handle.className = this.classNames.handle;\n\t\treturn handle;\n\t}\n\t/**\n\t* Positions a handle element according to its direction.\n\t*\n\t* Corner handles (e.g., 'top-left') are positioned at the intersection\n\t* of two edges. Edge handles (e.g., 'top') span the full width or height.\n\t*\n\t* @param handle - The handle element to position\n\t* @param direction - The direction determining the position\n\t*/\n\tpositionHandle(handle, direction) {\n\t\tconst isTop = direction.includes(\"top\");\n\t\tconst isBottom = direction.includes(\"bottom\");\n\t\tconst isLeft = direction.includes(\"left\");\n\t\tconst isRight = direction.includes(\"right\");\n\t\tif (isTop) handle.style.top = \"0\";\n\t\tif (isBottom) handle.style.bottom = \"0\";\n\t\tif (isLeft) handle.style.left = \"0\";\n\t\tif (isRight) handle.style.right = \"0\";\n\t\tif (direction === \"top\" || direction === \"bottom\") {\n\t\t\thandle.style.left = \"0\";\n\t\t\thandle.style.right = \"0\";\n\t\t}\n\t\tif (direction === \"left\" || direction === \"right\") {\n\t\t\thandle.style.top = \"0\";\n\t\t\thandle.style.bottom = \"0\";\n\t\t}\n\t}\n\t/**\n\t* Creates and attaches all resize handles to the wrapper.\n\t*\n\t* Iterates through the configured directions, creates a handle for each,\n\t* positions it, attaches the mousedown listener, and appends it to the DOM.\n\t*/\n\tattachHandles() {\n\t\tthis.directions.forEach((direction) => {\n\t\t\tlet handle;\n\t\t\tif (this.createCustomHandle) handle = this.createCustomHandle(direction);\n\t\t\telse handle = this.createHandle(direction);\n\t\t\tif (!(handle instanceof HTMLElement)) {\n\t\t\t\tconsole.warn(`[ResizableNodeView] createCustomHandle(\"${direction}\") did not return an HTMLElement. Falling back to default handle.`);\n\t\t\t\thandle = this.createHandle(direction);\n\t\t\t}\n\t\t\tif (!this.createCustomHandle) this.positionHandle(handle, direction);\n\t\t\thandle.addEventListener(\"mousedown\", (event) => this.handleResizeStart(event, direction));\n\t\t\thandle.addEventListener(\"touchstart\", (event) => this.handleResizeStart(event, direction));\n\t\t\tthis.handleMap.set(direction, handle);\n\t\t\tthis.wrapper.appendChild(handle);\n\t\t});\n\t}\n\t/**\n\t* Removes all resize handles from the wrapper.\n\t*\n\t* Cleans up the handle map and removes each handle element from the DOM.\n\t*/\n\tremoveHandles() {\n\t\tthis.handleMap.forEach((el) => el.remove());\n\t\tthis.handleMap.clear();\n\t}\n\t/**\n\t* Applies initial sizing from node attributes to the element.\n\t*\n\t* If width/height attributes exist on the node, they're applied to the element.\n\t* Otherwise, the element's natural/current dimensions are measured. The aspect\n\t* ratio is calculated for later use in aspect-ratio-preserving resizes.\n\t*/\n\tapplyInitialSize() {\n\t\tconst width = this.node.attrs.width;\n\t\tconst height = this.node.attrs.height;\n\t\tif (width) {\n\t\t\tthis.element.style.width = `${width}px`;\n\t\t\tthis.initialWidth = width;\n\t\t} else this.initialWidth = this.element.offsetWidth;\n\t\tif (height) {\n\t\t\tthis.element.style.height = `${height}px`;\n\t\t\tthis.initialHeight = height;\n\t\t} else this.initialHeight = this.element.offsetHeight;\n\t\tif (this.initialWidth > 0 && this.initialHeight > 0) this.aspectRatio = this.initialWidth / this.initialHeight;\n\t}\n\t/**\n\t* Initiates a resize operation when a handle is clicked.\n\t*\n\t* Captures the starting mouse position and element dimensions, sets up\n\t* the resize state, adds the resizing class and state attribute, and\n\t* attaches document-level listeners for mouse movement and keyboard input.\n\t*\n\t* @param event - The mouse down event\n\t* @param direction - The direction of the handle being dragged\n\t*/\n\thandleResizeStart(event, direction) {\n\t\tevent.preventDefault();\n\t\tevent.stopPropagation();\n\t\tthis.isResizing = true;\n\t\tthis.activeHandle = direction;\n\t\tif (isTouchEvent(event)) {\n\t\t\tthis.startX = event.touches[0].clientX;\n\t\t\tthis.startY = event.touches[0].clientY;\n\t\t} else {\n\t\t\tthis.startX = event.clientX;\n\t\t\tthis.startY = event.clientY;\n\t\t}\n\t\tthis.startWidth = this.element.offsetWidth;\n\t\tthis.startHeight = this.element.offsetHeight;\n\t\tif (this.startWidth > 0 && this.startHeight > 0) this.aspectRatio = this.startWidth / this.startHeight;\n\t\tif (this.getPos() !== void 0) {}\n\t\tthis.container.dataset.resizeState = \"true\";\n\t\tif (this.classNames.resizing) this.container.classList.add(this.classNames.resizing);\n\t\tdocument.addEventListener(\"mousemove\", this.handleMouseMove);\n\t\tdocument.addEventListener(\"touchmove\", this.handleTouchMove);\n\t\tdocument.addEventListener(\"mouseup\", this.handleMouseUp);\n\t\tdocument.addEventListener(\"keydown\", this.handleKeyDown);\n\t\tdocument.addEventListener(\"keyup\", this.handleKeyUp);\n\t}\n\thandleResize(deltaX, deltaY) {\n\t\tif (!this.activeHandle) return;\n\t\tconst shouldPreserveAspectRatio = this.preserveAspectRatio || this.isShiftKeyPressed;\n\t\tconst { width, height } = this.calculateNewDimensions(this.activeHandle, deltaX, deltaY);\n\t\tconst constrained = this.applyConstraints(width, height, shouldPreserveAspectRatio);\n\t\tthis.element.style.width = `${constrained.width}px`;\n\t\tthis.element.style.height = `${constrained.height}px`;\n\t\tif (this.onResize) this.onResize(constrained.width, constrained.height);\n\t}\n\t/**\n\t* Calculates new dimensions based on mouse delta and resize direction.\n\t*\n\t* Takes the starting dimensions and applies the mouse movement delta\n\t* according to the handle direction. For corner handles, both dimensions\n\t* are affected. For edge handles, only one dimension changes. If aspect\n\t* ratio should be preserved, delegates to applyAspectRatio.\n\t*\n\t* @param direction - The active resize handle direction\n\t* @param deltaX - Horizontal mouse movement since resize start\n\t* @param deltaY - Vertical mouse movement since resize start\n\t* @returns The calculated width and height\n\t*/\n\tcalculateNewDimensions(direction, deltaX, deltaY) {\n\t\tlet newWidth = this.startWidth;\n\t\tlet newHeight = this.startHeight;\n\t\tconst isRight = direction.includes(\"right\");\n\t\tconst isLeft = direction.includes(\"left\");\n\t\tconst isBottom = direction.includes(\"bottom\");\n\t\tconst isTop = direction.includes(\"top\");\n\t\tif (isRight) newWidth = this.startWidth + deltaX;\n\t\telse if (isLeft) newWidth = this.startWidth - deltaX;\n\t\tif (isBottom) newHeight = this.startHeight + deltaY;\n\t\telse if (isTop) newHeight = this.startHeight - deltaY;\n\t\tif (direction === \"right\" || direction === \"left\") newWidth = this.startWidth + (isRight ? deltaX : -deltaX);\n\t\tif (direction === \"top\" || direction === \"bottom\") newHeight = this.startHeight + (isBottom ? deltaY : -deltaY);\n\t\tif (this.preserveAspectRatio || this.isShiftKeyPressed) return this.applyAspectRatio(newWidth, newHeight, direction);\n\t\treturn {\n\t\t\twidth: newWidth,\n\t\t\theight: newHeight\n\t\t};\n\t}\n\t/**\n\t* Applies min/max constraints to dimensions.\n\t*\n\t* When aspect ratio is NOT preserved, constraints are applied independently\n\t* to width and height. When aspect ratio IS preserved, constraints are\n\t* applied while maintaining the aspect ratio—if one dimension hits a limit,\n\t* the other is recalculated proportionally.\n\t*\n\t* This ensures that aspect ratio is never broken when constrained.\n\t*\n\t* @param width - The unconstrained width\n\t* @param height - The unconstrained height\n\t* @param preserveAspectRatio - Whether to maintain aspect ratio while constraining\n\t* @returns The constrained dimensions\n\t*/\n\tapplyConstraints(width, height, preserveAspectRatio) {\n\t\tvar _this$maxSize3, _this$maxSize4;\n\t\tif (!preserveAspectRatio) {\n\t\t\tvar _this$maxSize, _this$maxSize2;\n\t\t\tlet constrainedWidth = Math.max(this.minSize.width, width);\n\t\t\tlet constrainedHeight = Math.max(this.minSize.height, height);\n\t\t\tif ((_this$maxSize = this.maxSize) === null || _this$maxSize === void 0 ? void 0 : _this$maxSize.width) constrainedWidth = Math.min(this.maxSize.width, constrainedWidth);\n\t\t\tif ((_this$maxSize2 = this.maxSize) === null || _this$maxSize2 === void 0 ? void 0 : _this$maxSize2.height) constrainedHeight = Math.min(this.maxSize.height, constrainedHeight);\n\t\t\treturn {\n\t\t\t\twidth: constrainedWidth,\n\t\t\t\theight: constrainedHeight\n\t\t\t};\n\t\t}\n\t\tlet constrainedWidth = width;\n\t\tlet constrainedHeight = height;\n\t\tif (constrainedWidth < this.minSize.width) {\n\t\t\tconstrainedWidth = this.minSize.width;\n\t\t\tconstrainedHeight = constrainedWidth / this.aspectRatio;\n\t\t}\n\t\tif (constrainedHeight < this.minSize.height) {\n\t\t\tconstrainedHeight = this.minSize.height;\n\t\t\tconstrainedWidth = constrainedHeight * this.aspectRatio;\n\t\t}\n\t\tif (((_this$maxSize3 = this.maxSize) === null || _this$maxSize3 === void 0 ? void 0 : _this$maxSize3.width) && constrainedWidth > this.maxSize.width) {\n\t\t\tconstrainedWidth = this.maxSize.width;\n\t\t\tconstrainedHeight = constrainedWidth / this.aspectRatio;\n\t\t}\n\t\tif (((_this$maxSize4 = this.maxSize) === null || _this$maxSize4 === void 0 ? void 0 : _this$maxSize4.height) && constrainedHeight > this.maxSize.height) {\n\t\t\tconstrainedHeight = this.maxSize.height;\n\t\t\tconstrainedWidth = constrainedHeight * this.aspectRatio;\n\t\t}\n\t\treturn {\n\t\t\twidth: constrainedWidth,\n\t\t\theight: constrainedHeight\n\t\t};\n\t}\n\t/**\n\t* Adjusts dimensions to maintain the original aspect ratio.\n\t*\n\t* For horizontal handles (left/right), uses width as the primary dimension\n\t* and calculates height from it. For vertical handles (top/bottom), uses\n\t* height as primary and calculates width. For corner handles, uses width\n\t* as the primary dimension.\n\t*\n\t* @param width - The new width\n\t* @param height - The new height\n\t* @param direction - The active resize direction\n\t* @returns Dimensions adjusted to preserve aspect ratio\n\t*/\n\tapplyAspectRatio(width, height, direction) {\n\t\tconst isHorizontal = direction === \"left\" || direction === \"right\";\n\t\tconst isVertical = direction === \"top\" || direction === \"bottom\";\n\t\tif (isHorizontal) return {\n\t\t\twidth,\n\t\t\theight: width / this.aspectRatio\n\t\t};\n\t\tif (isVertical) return {\n\t\t\twidth: height * this.aspectRatio,\n\t\t\theight\n\t\t};\n\t\treturn {\n\t\t\twidth,\n\t\t\theight: width / this.aspectRatio\n\t\t};\n\t}\n};\n/**\n* Alias for ResizableNodeView to maintain consistent naming.\n* @deprecated Use ResizableNodeView instead - will be removed in future versions.\n*/\nconst ResizableNodeview = ResizableNodeView;\n//#endregion\n//#region src/Node.ts\n/**\n* The Node class is used to create custom node extensions.\n* @see https://tiptap.dev/api/extensions#create-a-new-extension\n*/\nvar Node = class Node extends Extendable {\n\tconstructor(..._args) {\n\t\tsuper(..._args);\n\t\tthis.type = \"node\";\n\t}\n\t/**\n\t* Create a new Node instance\n\t* @param config - Node configuration object or a function that returns a configuration object\n\t*/\n\tstatic create(config = {}) {\n\t\tconst resolvedConfig = typeof config === \"function\" ? config() : config;\n\t\treturn new Node(resolvedConfig);\n\t}\n\tconfigure(options) {\n\t\treturn super.configure(options);\n\t}\n\textend(extendedConfig) {\n\t\tconst resolvedConfig = typeof extendedConfig === \"function\" ? extendedConfig() : extendedConfig;\n\t\treturn super.extend(resolvedConfig);\n\t}\n};\n//#endregion\n//#region src/NodeView.ts\n/**\n* Node views are used to customize the rendered DOM structure of a node.\n* @see https://tiptap.dev/guide/node-views\n*/\nvar NodeView = class {\n\tconstructor(component, props, options) {\n\t\tthis.isDragging = false;\n\t\tthis.component = component;\n\t\tthis.editor = props.editor;\n\t\tthis.options = {\n\t\t\tstopEvent: null,\n\t\t\tignoreMutation: null,\n\t\t\t...options\n\t\t};\n\t\tthis.extension = props.extension;\n\t\tthis.node = props.node;\n\t\tthis.decorations = props.decorations;\n\t\tthis.innerDecorations = props.innerDecorations;\n\t\tthis.view = props.view;\n\t\tthis.HTMLAttributes = props.HTMLAttributes;\n\t\tthis.getPos = () => {\n\t\t\ttry {\n\t\t\t\treturn props.getPos();\n\t\t\t} catch {\n\t\t\t\treturn;\n\t\t\t}\n\t\t};\n\t\tthis.mount();\n\t}\n\tmount() {}\n\tget dom() {\n\t\treturn this.editor.view.dom;\n\t}\n\tget contentDOM() {\n\t\treturn null;\n\t}\n\tonDragStart(event) {\n\t\tvar _target$parentElement, _this$contentDOM;\n\t\tconst { view } = this.editor;\n\t\tconst target = event.target;\n\t\tconst dragHandle = target.nodeType === 3 ? (_target$parentElement = target.parentElement) === null || _target$parentElement === void 0 ? void 0 : _target$parentElement.closest(\"[data-drag-handle]\") : target.closest(\"[data-drag-handle]\");\n\t\tif (!this.dom || ((_this$contentDOM = this.contentDOM) === null || _this$contentDOM === void 0 ? void 0 : _this$contentDOM.contains(target)) || !dragHandle) return;\n\t\tlet x = 0;\n\t\tlet y = 0;\n\t\tif (this.dom !== dragHandle) {\n\t\t\tvar _event$offsetX, _nativeEvent, _event$offsetY, _nativeEvent2;\n\t\t\tconst domBox = this.dom.getBoundingClientRect();\n\t\t\tconst handleBox = dragHandle.getBoundingClientRect();\n\t\t\tconst offsetX = (_event$offsetX = event.offsetX) !== null && _event$offsetX !== void 0 ? _event$offsetX : (_nativeEvent = event.nativeEvent) === null || _nativeEvent === void 0 ? void 0 : _nativeEvent.offsetX;\n\t\t\tconst offsetY = (_event$offsetY = event.offsetY) !== null && _event$offsetY !== void 0 ? _event$offsetY : (_nativeEvent2 = event.nativeEvent) === null || _nativeEvent2 === void 0 ? void 0 : _nativeEvent2.offsetY;\n\t\t\tx = handleBox.x - domBox.x + offsetX;\n\t\t\ty = handleBox.y - domBox.y + offsetY;\n\t\t}\n\t\tconst clonedNode = this.dom.cloneNode(true);\n\t\ttry {\n\t\t\tconst domBox = this.dom.getBoundingClientRect();\n\t\t\tclonedNode.style.width = `${Math.round(domBox.width)}px`;\n\t\t\tclonedNode.style.height = `${Math.round(domBox.height)}px`;\n\t\t\tclonedNode.style.boxSizing = \"border-box\";\n\t\t\tclonedNode.style.pointerEvents = \"none\";\n\t\t} catch {}\n\t\tlet dragImageWrapper = null;\n\t\ttry {\n\t\t\tvar _event$dataTransfer;\n\t\t\tdragImageWrapper = document.createElement(\"div\");\n\t\t\tdragImageWrapper.style.position = \"absolute\";\n\t\t\tdragImageWrapper.style.top = \"-9999px\";\n\t\t\tdragImageWrapper.style.left = \"-9999px\";\n\t\t\tdragImageWrapper.style.pointerEvents = \"none\";\n\t\t\tdragImageWrapper.appendChild(clonedNode);\n\t\t\tdocument.body.appendChild(dragImageWrapper);\n\t\t\t(_event$dataTransfer = event.dataTransfer) === null || _event$dataTransfer === void 0 || _event$dataTransfer.setDragImage(clonedNode, x, y);\n\t\t} finally {\n\t\t\tif (dragImageWrapper) setTimeout(() => {\n\t\t\t\ttry {\n\t\t\t\t\tdragImageWrapper === null || dragImageWrapper === void 0 || dragImageWrapper.remove();\n\t\t\t\t} catch {}\n\t\t\t}, 0);\n\t\t}\n\t\tconst pos = this.getPos();\n\t\tif (typeof pos !== \"number\") return;\n\t\tconst selection = _tiptap_pm_state.NodeSelection.create(view.state.doc, pos);\n\t\tconst transaction = view.state.tr.setSelection(selection);\n\t\tview.dispatch(transaction);\n\t}\n\tstopEvent(event) {\n\t\tvar _this$contentDOM2;\n\t\tif (!this.dom) return false;\n\t\tif (typeof this.options.stopEvent === \"function\") return this.options.stopEvent({ event });\n\t\tconst target = event.target;\n\t\tif (!(this.dom.contains(target) && !((_this$contentDOM2 = this.contentDOM) === null || _this$contentDOM2 === void 0 ? void 0 : _this$contentDOM2.contains(target)))) return false;\n\t\tconst isDragEvent = event.type.startsWith(\"drag\");\n\t\tconst isDragOverEnterEvent = event.type === \"dragover\" || event.type === \"dragenter\";\n\t\tconst isDropEvent = event.type === \"drop\";\n\t\tif (([\n\t\t\t\"INPUT\",\n\t\t\t\"BUTTON\",\n\t\t\t\"SELECT\",\n\t\t\t\"TEXTAREA\"\n\t\t].includes(target.tagName) || target.isContentEditable) && !isDropEvent && !isDragEvent) return true;\n\t\tconst { isEditable } = this.editor;\n\t\tconst { isDragging } = this;\n\t\tconst isDraggable = !!this.node.type.spec.draggable;\n\t\tconst isSelectable = _tiptap_pm_state.NodeSelection.isSelectable(this.node);\n\t\tconst isCopyEvent = event.type === \"copy\";\n\t\tconst isPasteEvent = event.type === \"paste\";\n\t\tconst isCutEvent = event.type === \"cut\";\n\t\tconst isClickEvent = event.type === \"mousedown\";\n\t\tif (!isDraggable && isSelectable && isDragEvent && event.target === this.dom) event.preventDefault();\n\t\tif (isDraggable && isDragEvent && !isDragging && event.target === this.dom) {\n\t\t\tevent.preventDefault();\n\t\t\treturn false;\n\t\t}\n\t\tif (isDraggable && isEditable && !isDragging && isClickEvent) {\n\t\t\tconst dragHandle = target.closest(\"[data-drag-handle]\");\n\t\t\tif (dragHandle && (this.dom === dragHandle || this.dom.contains(dragHandle))) {\n\t\t\t\tthis.isDragging = true;\n\t\t\t\tdocument.addEventListener(\"dragend\", () => {\n\t\t\t\t\tthis.isDragging = false;\n\t\t\t\t}, { once: true });\n\t\t\t\tdocument.addEventListener(\"drop\", () => {\n\t\t\t\t\tthis.isDragging = false;\n\t\t\t\t}, { once: true });\n\t\t\t\tdocument.addEventListener(\"mouseup\", () => {\n\t\t\t\t\tthis.isDragging = false;\n\t\t\t\t}, { once: true });\n\t\t\t}\n\t\t}\n\t\tif (isDragging || isDragOverEnterEvent || isDropEvent || isCopyEvent || isPasteEvent || isCutEvent || isClickEvent && isSelectable) return false;\n\t\treturn true;\n\t}\n\t/**\n\t* Called when a DOM [mutation](https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver) or a selection change happens within the view.\n\t* @return `false` if the editor should re-read the selection or re-parse the range around the mutation\n\t* @return `true` if it can safely be ignored.\n\t*/\n\tignoreMutation(mutation) {\n\t\tif (!this.dom || !this.contentDOM) return true;\n\t\tif (typeof this.options.ignoreMutation === \"function\") return this.options.ignoreMutation({ mutation });\n\t\tif (this.node.isLeaf || this.node.isAtom) return true;\n\t\tif (mutation.type === \"selection\") return false;\n\t\tif (this.contentDOM.contains(mutation.target) && mutation.type === \"childList\" && (isiOS() || isAndroid()) && this.editor.isFocused) {\n\t\t\tif ([...Array.from(mutation.addedNodes), ...Array.from(mutation.removedNodes)].every((node) => node.isContentEditable)) return false;\n\t\t}\n\t\tif (this.contentDOM === mutation.target && mutation.type === \"attributes\") return true;\n\t\tif (this.contentDOM.contains(mutation.target)) return false;\n\t\treturn true;\n\t}\n\t/**\n\t* Update the attributes of the prosemirror node.\n\t*/\n\tupdateAttributes(attributes) {\n\t\tthis.editor.commands.command(({ tr }) => {\n\t\t\tconst pos = this.getPos();\n\t\t\tif (typeof pos !== \"number\") return false;\n\t\t\ttr.setNodeMarkup(pos, void 0, {\n\t\t\t\t...this.node.attrs,\n\t\t\t\t...attributes\n\t\t\t});\n\t\t\treturn true;\n\t\t});\n\t}\n\t/**\n\t* Delete the node.\n\t*/\n\tdeleteNode() {\n\t\tconst from = this.getPos();\n\t\tif (typeof from !== \"number\") return;\n\t\tconst to = from + this.node.nodeSize;\n\t\tthis.editor.commands.deleteRange({\n\t\t\tfrom,\n\t\t\tto\n\t\t});\n\t}\n};\n//#endregion\n//#region src/pasteRules/markPasteRule.ts\n/**\n* Build an paste rule that adds a mark when the\n* matched text is pasted into it.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\n*/\nfunction markPasteRule(config) {\n\treturn new PasteRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match, pasteEvent }) => {\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);\n\t\t\tif (attributes === false || attributes === null) return null;\n\t\t\tconst { tr } = state;\n\t\t\tconst captureGroup = match[match.length - 1];\n\t\t\tconst fullMatch = match[0];\n\t\t\tlet markEnd = range.to;\n\t\t\tif (captureGroup) {\n\t\t\t\tconst startSpaces = fullMatch.search(/\\S/);\n\t\t\t\tconst textStart = range.from + fullMatch.indexOf(captureGroup);\n\t\t\t\tconst textEnd = textStart + captureGroup.length;\n\t\t\t\tif (getMarksBetween(range.from, range.to, state.doc).filter((item) => {\n\t\t\t\t\treturn item.mark.type.excluded.find((type) => type === config.type && type !== item.mark.type);\n\t\t\t\t}).filter((item) => item.to > textStart).length) return null;\n\t\t\t\tif (textEnd < range.to) tr.delete(textEnd, range.to);\n\t\t\t\tif (textStart > range.from) tr.delete(range.from + startSpaces, textStart);\n\t\t\t\tmarkEnd = range.from + startSpaces + captureGroup.length;\n\t\t\t\ttr.addMark(range.from + startSpaces, markEnd, config.type.create(attributes || {}));\n\t\t\t\tif (!(match.index !== void 0 && match.input !== void 0 && match.index + match[0].length >= match.input.length)) tr.removeStoredMark(config.type);\n\t\t\t}\n\t\t}\n\t});\n}\n//#endregion\n//#region src/pasteRules/nodePasteRule.ts\n/**\n* Build an paste rule that adds a node when the\n* matched text is pasted into it.\n* @see https://tiptap.dev/docs/editor/api/paste-rules\n*/\nfunction nodePasteRule(config) {\n\treturn new PasteRule({\n\t\tfind: config.find,\n\t\thandler({ match, chain, range, pasteEvent }) {\n\t\t\tconst attributes = callOrReturn(config.getAttributes, void 0, match, pasteEvent);\n\t\t\tconst content = callOrReturn(config.getContent, void 0, attributes);\n\t\t\tif (attributes === false || attributes === null) return null;\n\t\t\tconst node = {\n\t\t\t\ttype: config.type.name,\n\t\t\t\tattrs: attributes\n\t\t\t};\n\t\t\tif (content) node.content = content;\n\t\t\tif (match.input) chain().deleteRange(range).insertContentAt(range.from, node);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/pasteRules/textPasteRule.ts\n/**\n* Build an paste rule that replaces text when the\n* matched text is pasted into it.\n* @see https://tiptap.dev/docs/editor/extensions/custom-extensions/extend-existing#paste-rules\n*/\nfunction textPasteRule(config) {\n\treturn new PasteRule({\n\t\tfind: config.find,\n\t\thandler: ({ state, range, match }) => {\n\t\t\tlet insert = config.replace;\n\t\t\tlet start = range.from;\n\t\t\tconst end = range.to;\n\t\t\tif (match[1]) {\n\t\t\t\tconst offset = match[0].lastIndexOf(match[1]);\n\t\t\t\tinsert += match[0].slice(offset + match[1].length);\n\t\t\t\tstart += offset;\n\t\t\t\tconst cutOff = start - end;\n\t\t\t\tif (cutOff > 0) {\n\t\t\t\t\tinsert = match[0].slice(offset - cutOff, offset) + insert;\n\t\t\t\t\tstart = end;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.tr.insertText(insert, start, end);\n\t\t}\n\t});\n}\n//#endregion\n//#region src/Tracker.ts\nvar Tracker = class {\n\tconstructor(transaction) {\n\t\tthis.transaction = transaction;\n\t\tthis.currentStep = this.transaction.steps.length;\n\t}\n\tmap(position) {\n\t\tlet deleted = false;\n\t\treturn {\n\t\t\tposition: this.transaction.steps.slice(this.currentStep).reduce((newPosition, step) => {\n\t\t\t\tconst mapResult = step.getMap().mapResult(newPosition);\n\t\t\t\tif (mapResult.deleted) deleted = true;\n\t\t\t\treturn mapResult.pos;\n\t\t\t}, position),\n\t\t\tdeleted\n\t\t};\n\t}\n};\n//#endregion\nexports.CommandManager = CommandManager;\nexports.DECORATION_MANAGER_PLUGIN_KEY = DECORATION_MANAGER_PLUGIN_KEY;\nexports.Decoration = Decoration;\nexports.DecorationManager = DecorationManager;\nexports.Editor = Editor;\nexports.Extendable = Extendable;\nexports.Extension = Extension;\nexports.Fragment = Fragment;\nexports.InlineDecoration = InlineDecoration;\nexports.InputRule = InputRule;\nexports.MappablePosition = MappablePosition;\nexports.Mark = Mark;\nexports.MarkView = MarkView;\nexports.Node = Node;\nexports.NodeDecoration = NodeDecoration;\nexports.NodePos = NodePos;\nexports.NodeView = NodeView;\nexports.PasteRule = PasteRule;\nexports.ResizableNodeView = ResizableNodeView;\nexports.ResizableNodeview = ResizableNodeview;\nexports.Tracker = Tracker;\nexports.WidgetDecoration = WidgetDecoration;\nexports.attrsEqual = attrsEqual;\nexports.callOrReturn = callOrReturn;\nexports.canInsertNode = canInsertNode;\nexports.combineTransactionSteps = combineTransactionSteps;\nObject.defineProperty(exports, \"commands\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn commands_exports;\n\t}\n});\nexports.createAtomBlockMarkdownSpec = createAtomBlockMarkdownSpec;\nexports.createBlockMarkdownSpec = createBlockMarkdownSpec;\nexports.createChainableState = createChainableState;\nexports.createDocument = createDocument;\nexports.createElement = h;\nexports.createInlineMarkdownSpec = createInlineMarkdownSpec;\nexports.createMappablePosition = createMappablePosition;\nexports.createNodeFromContent = createNodeFromContent;\nexports.createStyleTag = createStyleTag;\nexports.createWidgetDecoration = createWidgetDecoration;\nexports.decodeHtmlEntities = decodeHtmlEntities;\nexports.defaultBlockAt = defaultBlockAt;\nexports.deleteProps = deleteProps;\nexports.elementFromString = elementFromString;\nexports.encodeHtmlEntities = encodeHtmlEntities;\nexports.escapeForRegEx = escapeForRegEx;\nObject.defineProperty(exports, \"extensions\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn extensions_exports;\n\t}\n});\nexports.findChildren = findChildren;\nexports.findChildrenInRange = findChildrenInRange;\nexports.findDuplicates = findDuplicates;\nexports.findParentNode = findParentNode;\nexports.findParentNodeClosestToPos = findParentNodeClosestToPos;\nexports.flattenExtensions = flattenExtensions;\nexports.fromString = fromString;\nexports.generateHTML = generateHTML;\nexports.generateJSON = generateJSON;\nexports.generateText = generateText;\nexports.getAttributes = getAttributes;\nexports.getAttributesFromExtensions = getAttributesFromExtensions;\nexports.getChangedRanges = getChangedRanges;\nexports.getDebugJSON = getDebugJSON;\nexports.getExtensionField = getExtensionField;\nexports.getHTMLFromFragment = getHTMLFromFragment;\nexports.getMarkAttributes = getMarkAttributes;\nexports.getMarkRange = getMarkRange;\nexports.getMarkType = getMarkType;\nexports.getMarksBetween = getMarksBetween;\nexports.getNodeAtPosition = getNodeAtPosition;\nexports.getNodeAttributes = getNodeAttributes;\nexports.getNodeType = getNodeType;\nexports.getPreviousBlockSibling = getPreviousBlockSibling;\nexports.getRenderedAttributes = getRenderedAttributes;\nexports.getSchema = getSchema;\nexports.getSchemaByResolvedExtensions = getSchemaByResolvedExtensions;\nexports.getSchemaTypeByName = getSchemaTypeByName;\nexports.getSchemaTypeNameByName = getSchemaTypeNameByName;\nexports.getSplittedAttributes = getSplittedAttributes;\nexports.getStyleProperty = getStyleProperty;\nexports.getText = getText;\nexports.getTextBetween = getTextBetween;\nexports.getTextContentFromNodes = getTextContentFromNodes;\nexports.getTextSerializersFromSchema = getTextSerializersFromSchema;\nexports.getUpdatedPosition = getUpdatedPosition;\nexports.h = h;\nexports.injectExtensionAttributesToParseRule = injectExtensionAttributesToParseRule;\nexports.inputRulesPlugin = inputRulesPlugin;\nexports.isActive = isActive;\nexports.isAndroid = isAndroid;\nexports.isAtEndOfNode = isAtEndOfNode;\nexports.isAtStartOfNode = isAtStartOfNode;\nexports.isEmptyObject = isEmptyObject;\nexports.isExtensionRulesEnabled = isExtensionRulesEnabled;\nexports.isFirefox = isFirefox;\nexports.isFunction = isFunction;\nexports.isList = isList;\nexports.isMacOS = isMacOS;\nexports.isMarkActive = isMarkActive;\nexports.isNodeActive = isNodeActive;\nexports.isNodeEmpty = isNodeEmpty;\nexports.isNodeSelection = isNodeSelection;\nexports.isNodeViewSelected = isNodeViewSelected;\nexports.isNumber = isNumber;\nexports.isPlainObject = isPlainObject;\nexports.isProseMirrorAddMarkStep = isProseMirrorAddMarkStep;\nexports.isProseMirrorAddNodeMarkStep = isProseMirrorAddNodeMarkStep;\nexports.isProseMirrorAttrStep = isProseMirrorAttrStep;\nexports.isProseMirrorCellSelection = isProseMirrorCellSelection;\nexports.isProseMirrorDocAttrStep = isProseMirrorDocAttrStep;\nexports.isProseMirrorFragment = isProseMirrorFragment;\nexports.isProseMirrorNodeSelection = isProseMirrorNodeSelection;\nexports.isProseMirrorRemoveMarkStep = isProseMirrorRemoveMarkStep;\nexports.isProseMirrorRemoveNodeMarkStep = isProseMirrorRemoveNodeMarkStep;\nexports.isProseMirrorReplaceAroundStep = isProseMirrorReplaceAroundStep;\nexports.isProseMirrorReplaceStep = isProseMirrorReplaceStep;\nexports.isProseMirrorSlice = isProseMirrorSlice;\nexports.isProseMirrorStep = isProseMirrorStep;\nexports.isProseMirrorStepResult = isProseMirrorStepResult;\nexports.isRegExp = isRegExp;\nexports.isSafari = isSafari;\nexports.isString = isString;\nexports.isTextSelection = isTextSelection;\nexports.isiOS = isiOS;\nexports.liveWidgetKeys = liveWidgetKeys;\nexports.markInputRule = markInputRule;\nexports.markPasteRule = markPasteRule;\nObject.defineProperty(exports, \"markdown\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn markdown_exports;\n\t}\n});\nexports.marksEqual = marksEqual;\nexports.mergeAttributes = mergeAttributes;\nexports.mergeDeep = mergeDeep;\nexports.minMax = minMax;\nexports.nodeInputRule = nodeInputRule;\nexports.nodePasteRule = nodePasteRule;\nexports.objectIncludes = objectIncludes;\nexports.parseAttributes = parseAttributes;\nexports.parseIndentedBlocks = parseIndentedBlocks;\nexports.pasteRulesPlugin = pasteRulesPlugin;\nexports.posToDOMRect = posToDOMRect;\nexports.removeDuplicates = removeDuplicates;\nexports.renderNestedMarkdownContent = renderNestedMarkdownContent;\nexports.resolveExtensions = resolveExtensions;\nexports.resolveFocusPosition = resolveFocusPosition;\nexports.rewriteUnknownContent = rewriteUnknownContent;\nexports.selectionToInsertionEnd = selectionToInsertionEnd;\nexports.serializeAttributes = serializeAttributes;\nexports.sortExtensions = sortExtensions;\nexports.splitExtensions = splitExtensions;\nexports.textInputRule = textInputRule;\nexports.textPasteRule = textPasteRule;\nexports.textblockTypeInputRule = textblockTypeInputRule;\nexports.updateMarkViewAttributes = updateMarkViewAttributes;\nexports.wrappingInputRule = wrappingInputRule;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\n//#region src/jsx-runtime.ts\nconst jsxElements = /* @__PURE__ */ new WeakSet();\nconst jsxFragments = /* @__PURE__ */ new WeakSet();\n/** Create a new JSX element from the given spec */\nfunction createJSXElement(spec) {\n\tconst element = spec;\n\tjsxElements.add(element);\n\treturn element;\n}\n/** Check if a spec is a JSX element */\nfunction isJSXElement(value) {\n\treturn Array.isArray(value) && jsxElements.has(value);\n}\nfunction flattenFragmentChildren(children) {\n\treturn children.flatMap((child) => {\n\t\tif (child == null) return [];\n\t\tif (Array.isArray(child) && jsxFragments.has(child) && !isJSXElement(child)) return flattenFragmentChildren(child);\n\t\treturn [child];\n\t});\n}\nfunction Fragment(props) {\n\tjsxFragments.add(props.children);\n\treturn props.children;\n}\nfunction render(tag, attributes) {\n\tif (tag === \"slot\") return 0;\n\tif (tag instanceof Function) {\n\t\tconst result = tag(attributes);\n\t\tif (Array.isArray(result) && !isJSXElement(result) && !jsxFragments.has(result)) return createJSXElement(result);\n\t\treturn result;\n\t}\n\tconst { children, ...rest } = attributes !== null && attributes !== void 0 ? attributes : {};\n\tif (tag === \"svg\") throw new Error(\"SVG elements are not supported in the JSX syntax, use the array syntax instead\");\n\tif (Array.isArray(children)) {\n\t\tif (isJSXElement(children)) return createJSXElement([\n\t\t\ttag,\n\t\t\trest,\n\t\t\tchildren\n\t\t]);\n\t\tif (children.length === 0) return createJSXElement([tag, rest]);\n\t\tconst flattenedChildren = flattenFragmentChildren(children);\n\t\tif (flattenedChildren.length === 0) return createJSXElement([tag, rest]);\n\t\treturn createJSXElement([\n\t\t\ttag,\n\t\t\trest,\n\t\t\t...flattenedChildren\n\t\t]);\n\t}\n\tif (children !== void 0 && children !== null) return createJSXElement([\n\t\ttag,\n\t\trest,\n\t\tchildren\n\t]);\n\treturn createJSXElement([tag, rest]);\n}\nconst h = (tag, attributes) => render(tag, attributes);\nconst jsxs = (tag, attributes) => render(tag, attributes);\nconst jsxDEV = (tag, attributes, _key, _isStaticChildren) => {\n\treturn render(tag, attributes);\n};\n//#endregion\nexports.Fragment = Fragment;\nexports.createElement = h;\nexports.h = h;\nexports.jsx = h;\nexports.jsxDEV = jsxDEV;\nexports.jsxs = jsxs;\n\n//# sourceMappingURL=jsx-runtime.cjs.map","module.exports = require('../dist/jsx-runtime/jsx-runtime.cjs')\n","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_model = require(\"@tiptap/pm/model\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\nlet _tiptap_core_jsx_runtime = require(\"@tiptap/core/jsx-runtime\");\n//#region src/handleBackspace.ts\n/**\n* Restructure the blockquote boundary at the caret.\n*\n* Two cases are handled in a single backspace:\n*\n* 1. Caret at the start of a non-first child of a blockquote — lift the\n* current child out, splitting the blockquote around it.\n* 2. Caret at the start of a top-level textblock whose previous sibling is\n* a blockquote with a textblock last child — merge the current\n* textblock's inline content into the blockquote's last textblock\n* instead of letting joinBackward pull the paragraph back inside.\n*\n* Returns true when the backspace was consumed.\n*/\nconst handleBackspace = (editor, type) => {\n\tvar _previous$lastChild;\n\tconst { state } = editor;\n\tconst { selection } = state;\n\tif (!selection.empty) return false;\n\tconst { $from } = selection;\n\tif ($from.parentOffset !== 0) return false;\n\tconst parentDepth = $from.depth - 1;\n\tif (parentDepth < 0) return false;\n\tconst parent = $from.node(parentDepth);\n\tconst index = $from.index(parentDepth);\n\tif (index === 0) return false;\n\tif (parent.type === type) return editor.commands.lift(type.name);\n\tconst previous = parent.child(index - 1);\n\tif (previous.type !== type || !((_previous$lastChild = previous.lastChild) === null || _previous$lastChild === void 0 ? void 0 : _previous$lastChild.isTextblock)) return false;\n\tconst targetPos = $from.before() - 1 - 1;\n\treturn editor.commands.command(({ tr, dispatch }) => {\n\t\tif (!dispatch) return true;\n\t\tconst content = $from.parent.content;\n\t\tconst slice = new _tiptap_pm_model.Slice(content, 0, 0);\n\t\ttr.replace(targetPos, $from.after(), slice);\n\t\ttr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, targetPos + content.size));\n\t\ttr.scrollIntoView();\n\t\tdispatch(tr);\n\t\treturn true;\n\t});\n};\n//#endregion\n//#region src/blockquote.tsx\n/** @jsxImportSource @tiptap/core */\n/**\n* Matches a blockquote to a `>` as input.\n*/\nconst inputRegex = /^\\s*>\\s$/;\n/**\n* This extension allows you to create blockquotes.\n* @see https://tiptap.dev/api/nodes/blockquote\n*/\nconst Blockquote = _tiptap_core.Node.create({\n\tname: \"blockquote\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"block+\",\n\tgroup: \"block\",\n\tdefining: true,\n\tparseHTML() {\n\t\treturn [{ tag: \"blockquote\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn /* @__PURE__ */ (0, _tiptap_core_jsx_runtime.jsx)(\"blockquote\", {\n\t\t\t...(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\tchildren: /* @__PURE__ */ (0, _tiptap_core_jsx_runtime.jsx)(\"slot\", {})\n\t\t});\n\t},\n\tparseMarkdown: (token, helpers) => {\n\t\tvar _helpers$parseBlockCh;\n\t\tconst parseBlockChildren = (_helpers$parseBlockCh = helpers.parseBlockChildren) !== null && _helpers$parseBlockCh !== void 0 ? _helpers$parseBlockCh : helpers.parseChildren;\n\t\treturn helpers.createNode(\"blockquote\", void 0, parseBlockChildren(token.tokens || []));\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\tconst prefix = \">\";\n\t\tconst result = [];\n\t\tnode.content.forEach((child, index) => {\n\t\t\tvar _h$renderChild, _h$renderChild2;\n\t\t\tconst linesWithPrefix = ((_h$renderChild = (_h$renderChild2 = h.renderChild) === null || _h$renderChild2 === void 0 ? void 0 : _h$renderChild2.call(h, child, index)) !== null && _h$renderChild !== void 0 ? _h$renderChild : h.renderChildren([child])).split(\"\\n\").map((line) => {\n\t\t\t\tif (line.trim() === \"\") return prefix;\n\t\t\t\treturn `${prefix} ${line}`;\n\t\t\t});\n\t\t\tresult.push(linesWithPrefix.join(\"\\n\"));\n\t\t});\n\t\treturn result.join(`\\n${prefix}\\n`);\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetBlockquote: () => ({ commands }) => {\n\t\t\t\treturn commands.wrapIn(this.name);\n\t\t\t},\n\t\t\ttoggleBlockquote: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleWrap(this.name);\n\t\t\t},\n\t\t\tunsetBlockquote: () => ({ commands }) => {\n\t\t\t\treturn commands.lift(this.name);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-Shift-b\": () => this.editor.commands.toggleBlockquote(),\n\t\t\tBackspace: () => handleBackspace(this.editor, this.type)\n\t\t};\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: inputRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Blockquote;\n//#endregion\nexports.Blockquote = Blockquote;\nexports.default = src_default;\nexports.inputRegex = inputRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_core_jsx_runtime = require(\"@tiptap/core/jsx-runtime\");\n//#region src/bold.tsx\n/** @jsxImportSource @tiptap/core */\n/**\n* Matches bold text via `**` as input.\n*/\nconst starInputRegex = /(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))$/;\n/**\n* Matches bold text via `**` while pasting.\n*/\nconst starPasteRegex = /(?:^|\\s)(\\*\\*(?!\\s+\\*\\*)((?:[^*]+))\\*\\*(?!\\s+\\*\\*))/g;\n/**\n* Matches bold text via `__` as input.\n*/\nconst underscoreInputRegex = /(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))$/;\n/**\n* Matches bold text via `__` while pasting.\n*/\nconst underscorePasteRegex = /(?:^|\\s)(__(?!\\s+__)((?:[^_]+))__(?!\\s+__))/g;\n/**\n* This extension allows you to mark text as bold.\n* @see https://tiptap.dev/api/marks/bold\n*/\nconst Bold = _tiptap_core.Mark.create({\n\tname: \"bold\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tparseHTML() {\n\t\treturn [\n\t\t\t{ tag: \"strong\" },\n\t\t\t{\n\t\t\t\ttag: \"b\",\n\t\t\t\tgetAttrs: (node) => node.style.fontWeight !== \"normal\" && null\n\t\t\t},\n\t\t\t{\n\t\t\t\tstyle: \"font-weight=400\",\n\t\t\t\tclearMark: (mark) => mark.type.name === this.name\n\t\t\t},\n\t\t\t{\n\t\t\t\tstyle: \"font-weight\",\n\t\t\t\tgetAttrs: (value) => /^(bold(er)?|[5-9]\\d{2,})$/.test(value) && null\n\t\t\t}\n\t\t];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn /* @__PURE__ */ (0, _tiptap_core_jsx_runtime.jsx)(\"strong\", {\n\t\t\t...(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\tchildren: /* @__PURE__ */ (0, _tiptap_core_jsx_runtime.jsx)(\"slot\", {})\n\t\t});\n\t},\n\tmarkdownTokenName: \"strong\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.applyMark(\"bold\", helpers.parseInline(token.tokens || []));\n\t},\n\tmarkdownOptions: { htmlReopen: {\n\t\topen: \"<strong>\",\n\t\tclose: \"</strong>\"\n\t} },\n\trenderMarkdown: (node, h) => {\n\t\treturn `**${h.renderChildren(node)}**`;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetBold: () => ({ commands }) => {\n\t\t\t\treturn commands.setMark(this.name);\n\t\t\t},\n\t\t\ttoggleBold: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleMark(this.name);\n\t\t\t},\n\t\t\tunsetBold: () => ({ commands }) => {\n\t\t\t\treturn commands.unsetMark(this.name);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-b\": () => this.editor.commands.toggleBold(),\n\t\t\t\"Mod-B\": () => this.editor.commands.toggleBold()\n\t\t};\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.markInputRule)({\n\t\t\tfind: starInputRegex,\n\t\t\ttype: this.type\n\t\t}), (0, _tiptap_core.markInputRule)({\n\t\t\tfind: underscoreInputRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t},\n\taddPasteRules() {\n\t\treturn [(0, _tiptap_core.markPasteRule)({\n\t\t\tfind: starPasteRegex,\n\t\t\ttype: this.type\n\t\t}), (0, _tiptap_core.markPasteRule)({\n\t\t\tfind: underscorePasteRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Bold;\n//#endregion\nexports.Bold = Bold;\nexports.default = src_default;\nexports.starInputRegex = starInputRegex;\nexports.starPasteRegex = starPasteRegex;\nexports.underscoreInputRegex = underscoreInputRegex;\nexports.underscorePasteRegex = underscorePasteRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\n//#region src/code-block.ts\nconst DEFAULT_TAB_SIZE = 4;\n/**\n* Matches a code block with backticks.\n*/\nconst backtickInputRegex = /^```([a-z]+)?[\\s\\n]$/;\n/**\n* Matches a code block with tildes.\n*/\nconst tildeInputRegex = /^~~~([a-z]+)?[\\s\\n]$/;\n/**\n* This extension allows you to create code blocks.\n* @see https://tiptap.dev/api/nodes/code-block\n*/\nconst CodeBlock = _tiptap_core.Node.create({\n\tname: \"codeBlock\",\n\taddOptions() {\n\t\treturn {\n\t\t\tlanguageClassPrefix: \"language-\",\n\t\t\texitOnTripleEnter: true,\n\t\t\texitOnArrowDown: true,\n\t\t\texitOnArrowUp: true,\n\t\t\tdefaultLanguage: null,\n\t\t\tenableTabIndentation: false,\n\t\t\ttabSize: DEFAULT_TAB_SIZE,\n\t\t\tHTMLAttributes: {}\n\t\t};\n\t},\n\tcontent: \"text*\",\n\tmarks: \"\",\n\tgroup: \"block\",\n\tcode: true,\n\tdefining: true,\n\taddAttributes() {\n\t\treturn { language: {\n\t\t\tdefault: this.options.defaultLanguage,\n\t\t\tparseHTML: (element) => {\n\t\t\t\tvar _element$firstElement;\n\t\t\t\tconst { languageClassPrefix } = this.options;\n\t\t\t\tif (!languageClassPrefix) return null;\n\t\t\t\tconst language = [...((_element$firstElement = element.firstElementChild) === null || _element$firstElement === void 0 ? void 0 : _element$firstElement.classList) || []].filter((className) => className.startsWith(languageClassPrefix)).map((className) => className.replace(languageClassPrefix, \"\"))[0];\n\t\t\t\tif (!language) return null;\n\t\t\t\treturn language;\n\t\t\t},\n\t\t\trendered: false\n\t\t} };\n\t},\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"pre\",\n\t\t\tpreserveWhitespace: \"full\"\n\t\t}];\n\t},\n\trenderHTML({ node, HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"pre\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t[\n\t\t\t\t\"code\",\n\t\t\t\t{ class: node.attrs.language ? this.options.languageClassPrefix + node.attrs.language : null },\n\t\t\t\t0\n\t\t\t]\n\t\t];\n\t},\n\tmarkdownTokenName: \"code\",\n\tparseMarkdown: (token, helpers) => {\n\t\tvar _token$raw, _token$raw2;\n\t\tif (((_token$raw = token.raw) === null || _token$raw === void 0 ? void 0 : _token$raw.startsWith(\"```\")) === false && ((_token$raw2 = token.raw) === null || _token$raw2 === void 0 ? void 0 : _token$raw2.startsWith(\"~~~\")) === false && token.codeBlockStyle !== \"indented\") return [];\n\t\treturn helpers.createNode(\"codeBlock\", { language: token.lang || null }, token.text ? [helpers.createTextNode(token.text)] : []);\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tvar _node$attrs;\n\t\tlet output = \"\";\n\t\tconst language = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.language) || \"\";\n\t\tif (!node.content) output = `\\`\\`\\`${language}\\n\\n\\`\\`\\``;\n\t\telse output = [\n\t\t\t`\\`\\`\\`${language}`,\n\t\t\th.renderChildren(node.content),\n\t\t\t\"```\"\n\t\t].join(\"\\n\");\n\t\treturn output;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetCodeBlock: (attributes) => ({ commands }) => {\n\t\t\t\treturn commands.setNode(this.name, attributes);\n\t\t\t},\n\t\t\ttoggleCodeBlock: (attributes) => ({ commands }) => {\n\t\t\t\treturn commands.toggleNode(this.name, \"paragraph\", attributes);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-Alt-c\": () => this.editor.commands.toggleCodeBlock(),\n\t\t\tBackspace: () => {\n\t\t\t\tconst { empty, $anchor } = this.editor.state.selection;\n\t\t\t\tconst isAtStart = $anchor.pos === 1;\n\t\t\t\tif (!empty || $anchor.parent.type.name !== this.name) return false;\n\t\t\t\tif (isAtStart || !$anchor.parent.textContent.length) return this.editor.commands.clearNodes();\n\t\t\t\treturn false;\n\t\t\t},\n\t\t\tTab: ({ editor }) => {\n\t\t\t\tvar _this$options$tabSize;\n\t\t\t\tif (!this.options.enableTabIndentation) return false;\n\t\t\t\tconst tabSize = (_this$options$tabSize = this.options.tabSize) !== null && _this$options$tabSize !== void 0 ? _this$options$tabSize : DEFAULT_TAB_SIZE;\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { selection } = state;\n\t\t\t\tconst { $from, empty } = selection;\n\t\t\t\tif ($from.parent.type !== this.type) return false;\n\t\t\t\tconst indent = \" \".repeat(tabSize);\n\t\t\t\tif (empty) return editor.commands.insertContent(indent);\n\t\t\t\treturn editor.commands.command(({ tr }) => {\n\t\t\t\t\tconst { from, to } = selection;\n\t\t\t\t\tconst indentedText = state.doc.textBetween(from, to, \"\\n\", \"\\n\").split(\"\\n\").map((line) => indent + line).join(\"\\n\");\n\t\t\t\t\ttr.replaceWith(from, to, state.schema.text(indentedText));\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t},\n\t\t\t\"Shift-Tab\": ({ editor }) => {\n\t\t\t\tvar _this$options$tabSize2;\n\t\t\t\tif (!this.options.enableTabIndentation) return false;\n\t\t\t\tconst tabSize = (_this$options$tabSize2 = this.options.tabSize) !== null && _this$options$tabSize2 !== void 0 ? _this$options$tabSize2 : DEFAULT_TAB_SIZE;\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { selection } = state;\n\t\t\t\tconst { $from, empty } = selection;\n\t\t\t\tif ($from.parent.type !== this.type) return false;\n\t\t\t\tif (empty) return editor.commands.command(({ tr }) => {\n\t\t\t\t\tvar _currentLine$match;\n\t\t\t\t\tconst { pos } = $from;\n\t\t\t\t\tconst codeBlockStart = $from.start();\n\t\t\t\t\tconst codeBlockEnd = $from.end();\n\t\t\t\t\tconst lines = state.doc.textBetween(codeBlockStart, codeBlockEnd, \"\\n\", \"\\n\").split(\"\\n\");\n\t\t\t\t\tlet currentLineIndex = 0;\n\t\t\t\t\tlet charCount = 0;\n\t\t\t\t\tconst relativeCursorPos = pos - codeBlockStart;\n\t\t\t\t\tfor (let i = 0; i < lines.length; i += 1) {\n\t\t\t\t\t\tif (charCount + lines[i].length >= relativeCursorPos) {\n\t\t\t\t\t\t\tcurrentLineIndex = i;\n\t\t\t\t\t\t\tbreak;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcharCount += lines[i].length + 1;\n\t\t\t\t\t}\n\t\t\t\t\tconst leadingSpaces = ((_currentLine$match = lines[currentLineIndex].match(/^ */)) === null || _currentLine$match === void 0 ? void 0 : _currentLine$match[0]) || \"\";\n\t\t\t\t\tconst spacesToRemove = Math.min(leadingSpaces.length, tabSize);\n\t\t\t\t\tif (spacesToRemove === 0) return true;\n\t\t\t\t\tlet lineStartPos = codeBlockStart;\n\t\t\t\t\tfor (let i = 0; i < currentLineIndex; i += 1) lineStartPos += lines[i].length + 1;\n\t\t\t\t\ttr.delete(lineStartPos, lineStartPos + spacesToRemove);\n\t\t\t\t\tif (pos - lineStartPos <= spacesToRemove) tr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, lineStartPos));\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t\treturn editor.commands.command(({ tr }) => {\n\t\t\t\t\tconst { from, to } = selection;\n\t\t\t\t\tconst reverseIndentText = state.doc.textBetween(from, to, \"\\n\", \"\\n\").split(\"\\n\").map((line) => {\n\t\t\t\t\t\tvar _line$match;\n\t\t\t\t\t\tconst leadingSpaces = ((_line$match = line.match(/^ */)) === null || _line$match === void 0 ? void 0 : _line$match[0]) || \"\";\n\t\t\t\t\t\tconst spacesToRemove = Math.min(leadingSpaces.length, tabSize);\n\t\t\t\t\t\treturn line.slice(spacesToRemove);\n\t\t\t\t\t}).join(\"\\n\");\n\t\t\t\t\ttr.replaceWith(from, to, state.schema.text(reverseIndentText));\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t},\n\t\t\tEnter: ({ editor }) => {\n\t\t\t\tif (!this.options.exitOnTripleEnter) return false;\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { selection } = state;\n\t\t\t\tconst { $from, empty } = selection;\n\t\t\t\tif (!empty || $from.parent.type !== this.type) return false;\n\t\t\t\tconst isAtEnd = $from.parentOffset === $from.parent.nodeSize - 2;\n\t\t\t\tconst endsWithDoubleNewline = $from.parent.textContent.endsWith(\"\\n\\n\");\n\t\t\t\tif (!isAtEnd || !endsWithDoubleNewline) return false;\n\t\t\t\treturn editor.chain().command(({ tr }) => {\n\t\t\t\t\ttr.delete($from.pos - 2, $from.pos);\n\t\t\t\t\treturn true;\n\t\t\t\t}).exitCode().run();\n\t\t\t},\n\t\t\tArrowUp: ({ editor }) => {\n\t\t\t\tif (!this.options.exitOnArrowUp) return false;\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { selection } = state;\n\t\t\t\tconst { $from, empty } = selection;\n\t\t\t\tif (!empty || $from.parent.type !== this.type) return false;\n\t\t\t\tif ($from.parentOffset !== 0) return false;\n\t\t\t\tconst before = $from.before();\n\t\t\t\tif (before > 0) return false;\n\t\t\t\treturn editor.commands.insertDefaultBlock({ pos: before });\n\t\t\t},\n\t\t\tArrowDown: ({ editor }) => {\n\t\t\t\tif (!this.options.exitOnArrowDown) return false;\n\t\t\t\tconst { state } = editor;\n\t\t\t\tconst { selection, doc } = state;\n\t\t\t\tconst { $from, empty } = selection;\n\t\t\t\tif (!empty || $from.parent.type !== this.type) return false;\n\t\t\t\tif (!($from.parentOffset === $from.parent.nodeSize - 2)) return false;\n\t\t\t\tconst after = $from.after();\n\t\t\t\tif (after === void 0) return false;\n\t\t\t\tif (doc.nodeAt(after)) return editor.commands.command(({ tr }) => {\n\t\t\t\t\ttr.setSelection(_tiptap_pm_state.Selection.near(doc.resolve(after)));\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t\treturn editor.commands.exitCode();\n\t\t\t}\n\t\t};\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.textblockTypeInputRule)({\n\t\t\tfind: backtickInputRegex,\n\t\t\ttype: this.type,\n\t\t\tgetAttributes: (match) => ({ language: match[1] })\n\t\t}), (0, _tiptap_core.textblockTypeInputRule)({\n\t\t\tfind: tildeInputRegex,\n\t\t\ttype: this.type,\n\t\t\tgetAttributes: (match) => ({ language: match[1] })\n\t\t})];\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"codeBlockVSCodeHandler\"),\n\t\t\tprops: { handlePaste: (view, event) => {\n\t\t\t\tif (!event.clipboardData) return false;\n\t\t\t\tif (this.editor.isActive(this.type.name)) return false;\n\t\t\t\tconst text = event.clipboardData.getData(\"text/plain\");\n\t\t\t\tconst vscode = event.clipboardData.getData(\"vscode-editor-data\");\n\t\t\t\tconst vscodeData = vscode ? JSON.parse(vscode) : void 0;\n\t\t\t\tconst language = vscodeData === null || vscodeData === void 0 ? void 0 : vscodeData.mode;\n\t\t\t\tif (!text || !language) return false;\n\t\t\t\tconst { tr, schema } = view.state;\n\t\t\t\tconst textNode = schema.text(text.replace(/\\r\\n?/g, \"\\n\"));\n\t\t\t\ttr.replaceSelectionWith(this.type.create({ language }, textNode));\n\t\t\t\tif (tr.selection.$from.parent.type !== this.type) tr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(Math.max(0, tr.selection.from - 2))));\n\t\t\t\ttr.setMeta(\"paste\", true);\n\t\t\t\tview.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = CodeBlock;\n//#endregion\nexports.CodeBlock = CodeBlock;\nexports.backtickInputRegex = backtickInputRegex;\nexports.default = src_default;\nexports.tildeInputRegex = tildeInputRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/code.ts\n/**\n* The regular expression used for the inline code input rule.\n* @deprecated The extension now uses a function-based finder internally.\n* This regex is kept for backward compatibility.\n*/\nconst inputRegex = /(^|[^`])`([^`]+)`(?!`)$/;\n/**\n* The regular expression used for the inline code paste rule.\n* @deprecated The extension now uses a function-based finder internally.\n* This regex is kept for backward compatibility.\n*/\nconst pasteRegex = /(^|[^`])`([^`]+)`(?!`)/g;\n/**\n* A function-based finder for the inline code input rule.\n* Used internally by the extension to ensure the preceding character\n* is not consumed as part of the match, preventing it from being deleted.\n*/\nconst inputRegexMatch = (text) => {\n\tconst match = /`([^`]+)`(?!`)$/.exec(text);\n\tif (!match) return null;\n\tif (match.index > 0 && text[match.index - 1] === \"`\") return null;\n\treturn {\n\t\tindex: match.index,\n\t\ttext: match[0],\n\t\treplaceWith: match[1]\n\t};\n};\n/**\n* A function-based finder for the inline code paste rule.\n* Used internally by the extension to avoid consuming the preceding\n* character as part of the match.\n*/\nconst pasteRegexMatch = (text) => {\n\tconst regex = /`([^`]+)`(?!`)/g;\n\tconst matches = [];\n\tlet match;\n\twhile ((match = regex.exec(text)) !== null) {\n\t\tif (match.index > 0 && text[match.index - 1] === \"`\") continue;\n\t\tmatches.push({\n\t\t\tindex: match.index,\n\t\t\ttext: match[0],\n\t\t\treplaceWith: match[1]\n\t\t});\n\t}\n\treturn matches;\n};\n/**\n* This extension allows you to mark text as inline code.\n* @see https://tiptap.dev/api/marks/code\n*/\nconst Code = _tiptap_core.Mark.create({\n\tname: \"code\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\texcludes: \"_\",\n\tcode: true,\n\texitable: true,\n\tparseHTML() {\n\t\treturn [{ tag: \"code\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"code\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"codespan\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.applyMark(\"code\", [{\n\t\t\ttype: \"text\",\n\t\t\ttext: token.text || \"\"\n\t\t}]);\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\treturn `\\`${h.renderChildren(node.content)}\\``;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetCode: () => ({ commands }) => {\n\t\t\t\treturn commands.setMark(this.name);\n\t\t\t},\n\t\t\ttoggleCode: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleMark(this.name);\n\t\t\t},\n\t\t\tunsetCode: () => ({ commands }) => {\n\t\t\t\treturn commands.unsetMark(this.name);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-e\": () => this.editor.commands.toggleCode() };\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.markInputRule)({\n\t\t\tfind: inputRegexMatch,\n\t\t\ttype: this.type\n\t\t})];\n\t},\n\taddPasteRules() {\n\t\treturn [(0, _tiptap_core.markPasteRule)({\n\t\t\tfind: pasteRegexMatch,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Code;\n//#endregion\nexports.Code = Code;\nexports.default = src_default;\nexports.inputRegex = inputRegex;\nexports.inputRegexMatch = inputRegexMatch;\nexports.pasteRegex = pasteRegex;\nexports.pasteRegexMatch = pasteRegexMatch;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\n//#region src/document.ts\n/**\n* The default document node which represents the top level node of the editor.\n* @see https://tiptap.dev/api/nodes/document\n*/\nconst Document = require(\"@tiptap/core\").Node.create({\n\tname: \"doc\",\n\ttopNode: true,\n\tcontent: \"block+\",\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\treturn h.renderChildren(node.content, \"\\n\\n\");\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Document;\n//#endregion\nexports.Document = Document;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_extensions = require(\"@tiptap/extensions\");\n//#region src/index.ts\nvar src_default = _tiptap_extensions.Gapcursor;\n//#endregion\nObject.defineProperty(exports, \"Gapcursor\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn _tiptap_extensions.Gapcursor;\n\t}\n});\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/hard-break.ts\n/**\n* This extension allows you to insert hard breaks.\n* @see https://www.tiptap.dev/api/nodes/hard-break\n*/\nconst HardBreak = _tiptap_core.Node.create({\n\tname: \"hardBreak\",\n\tmarkdownTokenName: \"br\",\n\taddOptions() {\n\t\treturn {\n\t\t\tkeepMarks: true,\n\t\t\tHTMLAttributes: {}\n\t\t};\n\t},\n\tinline: true,\n\tgroup: \"inline\",\n\tselectable: false,\n\tlinebreakReplacement: true,\n\tparseHTML() {\n\t\treturn [{ tag: \"br\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\"br\", (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes)];\n\t},\n\trenderText() {\n\t\treturn \"\\n\";\n\t},\n\trenderMarkdown: () => ` \\n`,\n\tparseMarkdown: () => {\n\t\treturn { type: \"hardBreak\" };\n\t},\n\taddCommands() {\n\t\treturn { setHardBreak: () => ({ commands, chain, state, editor }) => {\n\t\t\treturn commands.first([() => commands.exitCode(), () => commands.command(() => {\n\t\t\t\tconst { selection, storedMarks } = state;\n\t\t\t\tif (selection.$from.parent.type.spec.isolating) return false;\n\t\t\t\tconst { keepMarks } = this.options;\n\t\t\t\tconst { splittableMarks } = editor.extensionManager;\n\t\t\t\tconst marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();\n\t\t\t\treturn chain().insertContent({ type: this.name }).command(({ tr, dispatch }) => {\n\t\t\t\t\tif (dispatch && marks && keepMarks) {\n\t\t\t\t\t\tconst filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));\n\t\t\t\t\t\ttr.ensureMarks(filteredMarks);\n\t\t\t\t\t}\n\t\t\t\t\treturn true;\n\t\t\t\t}).scrollIntoView().run();\n\t\t\t})]);\n\t\t} };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-Enter\": () => this.editor.commands.setHardBreak(),\n\t\t\t\"Shift-Enter\": () => this.editor.commands.setHardBreak()\n\t\t};\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = HardBreak;\n//#endregion\nexports.HardBreak = HardBreak;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/heading.ts\n/**\n* This extension allows you to create headings.\n* @see https://www.tiptap.dev/api/nodes/heading\n*/\nconst Heading = _tiptap_core.Node.create({\n\tname: \"heading\",\n\taddOptions() {\n\t\treturn {\n\t\t\tlevels: [\n\t\t\t\t1,\n\t\t\t\t2,\n\t\t\t\t3,\n\t\t\t\t4,\n\t\t\t\t5,\n\t\t\t\t6\n\t\t\t],\n\t\t\tHTMLAttributes: {}\n\t\t};\n\t},\n\tcontent: \"inline*\",\n\tgroup: \"block\",\n\tdefining: true,\n\taddAttributes() {\n\t\treturn { level: {\n\t\t\tdefault: 1,\n\t\t\trendered: false\n\t\t} };\n\t},\n\tparseHTML() {\n\t\treturn this.options.levels.map((level) => ({\n\t\t\ttag: `h${level}`,\n\t\t\tattrs: { level }\n\t\t}));\n\t},\n\trenderHTML({ node, HTMLAttributes }) {\n\t\treturn [\n\t\t\t`h${this.options.levels.includes(node.attrs.level) ? node.attrs.level : this.options.levels[0]}`,\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.createNode(\"heading\", { level: token.depth || 1 }, helpers.parseInline(token.tokens || []));\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tvar _node$attrs;\n\t\tconst level = ((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.level) ? parseInt(node.attrs.level, 10) : 1;\n\t\tconst headingChars = \"#\".repeat(level);\n\t\tif (!node.content) return \"\";\n\t\treturn `${headingChars} ${h.renderChildren(node.content)}`;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetHeading: (attributes) => ({ commands }) => {\n\t\t\t\tif (!this.options.levels.includes(attributes.level)) return false;\n\t\t\t\treturn commands.setNode(this.name, attributes);\n\t\t\t},\n\t\t\ttoggleHeading: (attributes) => ({ commands }) => {\n\t\t\t\tif (!this.options.levels.includes(attributes.level)) return false;\n\t\t\t\treturn commands.toggleNode(this.name, \"paragraph\", attributes);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn this.options.levels.reduce((items, level) => ({\n\t\t\t...items,\n\t\t\t[`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })\n\t\t}), {});\n\t},\n\taddInputRules() {\n\t\treturn this.options.levels.map((level) => {\n\t\t\treturn (0, _tiptap_core.textblockTypeInputRule)({\n\t\t\t\tfind: new RegExp(`^(#{${Math.min(...this.options.levels)},${level}})\\\\s$`),\n\t\t\t\ttype: this.type,\n\t\t\t\tgetAttributes: { level }\n\t\t\t});\n\t\t});\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Heading;\n//#endregion\nexports.Heading = Heading;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\n//#region src/horizontal-rule.ts\n/**\n* This extension allows you to insert horizontal rules.\n* @see https://www.tiptap.dev/api/nodes/horizontal-rule\n*/\nconst HorizontalRule = _tiptap_core.Node.create({\n\tname: \"horizontalRule\",\n\taddOptions() {\n\t\treturn {\n\t\t\tHTMLAttributes: {},\n\t\t\tnextNodeType: \"paragraph\"\n\t\t};\n\t},\n\tgroup: \"block\",\n\tparseHTML() {\n\t\treturn [{ tag: \"hr\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\"hr\", (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes)];\n\t},\n\tmarkdownTokenName: \"hr\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.createNode(\"horizontalRule\");\n\t},\n\trenderMarkdown: () => {\n\t\treturn \"---\";\n\t},\n\taddCommands() {\n\t\treturn { setHorizontalRule: () => ({ chain, state }) => {\n\t\t\tif (!(0, _tiptap_core.canInsertNode)(state, state.schema.nodes[this.name])) return false;\n\t\t\tconst { selection } = state;\n\t\t\tconst { $to: $originTo } = selection;\n\t\t\tconst currentChain = chain();\n\t\t\tif ((0, _tiptap_core.isNodeSelection)(selection)) currentChain.insertContentAt($originTo.pos, { type: this.name });\n\t\t\telse currentChain.insertContent({ type: this.name });\n\t\t\treturn currentChain.command(({ state: chainState, tr, dispatch }) => {\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tconst { $to } = tr.selection;\n\t\t\t\t\tconst posAfter = $to.end();\n\t\t\t\t\tif ($to.nodeAfter) {\n\t\t\t\t\t\tif ($to.nodeAfter.isTextblock) tr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, $to.pos + 1));\n\t\t\t\t\t\telse if ($to.nodeAfter.isBlock) tr.setSelection(_tiptap_pm_state.NodeSelection.create(tr.doc, $to.pos));\n\t\t\t\t\t\telse tr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, $to.pos));\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst nodeType = chainState.schema.nodes[this.options.nextNodeType] || $to.parent.type.contentMatch.defaultType;\n\t\t\t\t\t\tconst node = nodeType === null || nodeType === void 0 ? void 0 : nodeType.create();\n\t\t\t\t\t\tif (node) {\n\t\t\t\t\t\t\ttr.insert(posAfter, node);\n\t\t\t\t\t\t\ttr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, posAfter + 1));\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\ttr.scrollIntoView();\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}).run();\n\t\t} };\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.nodeInputRule)({\n\t\t\tfind: /^(?:---|—-|___\\s|\\*\\*\\*\\s)$/,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = HorizontalRule;\n//#endregion\nexports.HorizontalRule = HorizontalRule;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/italic.ts\n/**\n* Matches an italic to a *italic* on input.\n*/\nconst starInputRegex = /(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))$/;\n/**\n* Matches an italic to a *italic* on paste.\n*/\nconst starPasteRegex = /(?:^|\\s)(\\*(?!\\s+\\*)((?:[^*]+))\\*(?!\\s+\\*))/g;\n/**\n* Matches an italic to a _italic_ on input.\n*/\nconst underscoreInputRegex = /(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))$/;\n/**\n* Matches an italic to a _italic_ on paste.\n*/\nconst underscorePasteRegex = /(?:^|\\s)(_(?!\\s+_)((?:[^_]+))_(?!\\s+_))/g;\n/**\n* This extension allows you to create italic text.\n* @see https://www.tiptap.dev/api/marks/italic\n*/\nconst Italic = _tiptap_core.Mark.create({\n\tname: \"italic\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tparseHTML() {\n\t\treturn [\n\t\t\t{ tag: \"em\" },\n\t\t\t{\n\t\t\t\ttag: \"i\",\n\t\t\t\tgetAttrs: (node) => node.style.fontStyle !== \"normal\" && null\n\t\t\t},\n\t\t\t{\n\t\t\t\tstyle: \"font-style=normal\",\n\t\t\t\tclearMark: (mark) => mark.type.name === this.name\n\t\t\t},\n\t\t\t{ style: \"font-style=italic\" }\n\t\t];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"em\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetItalic: () => ({ commands }) => {\n\t\t\t\treturn commands.setMark(this.name);\n\t\t\t},\n\t\t\ttoggleItalic: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleMark(this.name);\n\t\t\t},\n\t\t\tunsetItalic: () => ({ commands }) => {\n\t\t\t\treturn commands.unsetMark(this.name);\n\t\t\t}\n\t\t};\n\t},\n\tmarkdownTokenName: \"em\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.applyMark(\"italic\", helpers.parseInline(token.tokens || []));\n\t},\n\tmarkdownOptions: { htmlReopen: {\n\t\topen: \"<em>\",\n\t\tclose: \"</em>\"\n\t} },\n\trenderMarkdown: (node, h) => {\n\t\treturn `*${h.renderChildren(node)}*`;\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-i\": () => this.editor.commands.toggleItalic(),\n\t\t\t\"Mod-I\": () => this.editor.commands.toggleItalic()\n\t\t};\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.markInputRule)({\n\t\t\tfind: starInputRegex,\n\t\t\ttype: this.type\n\t\t}), (0, _tiptap_core.markInputRule)({\n\t\t\tfind: underscoreInputRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t},\n\taddPasteRules() {\n\t\treturn [(0, _tiptap_core.markPasteRule)({\n\t\t\tfind: starPasteRegex,\n\t\t\ttype: this.type\n\t\t}), (0, _tiptap_core.markPasteRule)({\n\t\t\tfind: underscorePasteRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Italic;\n//#endregion\nexports.Italic = Italic;\nexports.default = src_default;\nexports.starInputRegex = starInputRegex;\nexports.starPasteRegex = starPasteRegex;\nexports.underscoreInputRegex = underscoreInputRegex;\nexports.underscorePasteRegex = underscorePasteRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet linkifyjs = require(\"linkifyjs\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\n//#region src/helpers/whitespace.ts\nconst UNICODE_WHITESPACE_PATTERN = \"[\\0- \\xA0 ᠎ -\\u2029  ]\";\nconst UNICODE_WHITESPACE_REGEX = new RegExp(UNICODE_WHITESPACE_PATTERN);\nconst UNICODE_WHITESPACE_REGEX_END = new RegExp(`${UNICODE_WHITESPACE_PATTERN}$`);\nconst UNICODE_WHITESPACE_REGEX_GLOBAL = new RegExp(UNICODE_WHITESPACE_PATTERN, \"g\");\n//#endregion\n//#region src/helpers/autolink.ts\n/**\n* Check if the provided tokens form a valid link structure, which can either be a single link token\n* or a link token surrounded by parentheses or square brackets.\n*\n* This ensures that only complete and valid text is hyperlinked, preventing cases where a valid\n* top-level domain (TLD) is immediately followed by an invalid character, like a number. For\n* example, with the `find` method from Linkify, entering `example.com1` would result in\n* `example.com` being linked and the trailing `1` left as plain text. By using the `tokenize`\n* method, we can perform more comprehensive validation on the input text.\n*/\nfunction isValidLinkStructure(tokens) {\n\tif (tokens.length === 1) return tokens[0].isLink;\n\tif (tokens.length === 3 && tokens[1].isLink) return [\"()\", \"[]\"].includes(tokens[0].value + tokens[2].value);\n\treturn false;\n}\n/**\n* This plugin allows you to automatically add links to your editor.\n* @param options The plugin options\n* @returns The plugin instance\n*/\nfunction autolink(options) {\n\treturn new _tiptap_pm_state.Plugin({\n\t\tkey: new _tiptap_pm_state.PluginKey(\"autolink\"),\n\t\tappendTransaction: (transactions, oldState, newState) => {\n\t\t\t/**\n\t\t\t* Does the transaction change the document?\n\t\t\t*/\n\t\t\tconst docChanges = transactions.some((transaction) => transaction.docChanged) && !oldState.doc.eq(newState.doc);\n\t\t\t/**\n\t\t\t* Prevent autolink if the transaction is not a document change or if the transaction has the meta `preventAutolink`.\n\t\t\t*/\n\t\t\tconst preventAutolink = transactions.some((transaction) => transaction.getMeta(\"preventAutolink\"));\n\t\t\t/**\n\t\t\t* Prevent autolink if the transaction is not a document change\n\t\t\t* or if the transaction has the meta `preventAutolink`.\n\t\t\t*/\n\t\t\tif (!docChanges || preventAutolink) return;\n\t\t\tconst { tr } = newState;\n\t\t\tconst transform = (0, _tiptap_core.combineTransactionSteps)(oldState.doc, [...transactions]);\n\t\t\t(0, _tiptap_core.getChangedRanges)(transform).forEach(({ newRange }) => {\n\t\t\t\tconst nodesInChangedRanges = (0, _tiptap_core.findChildrenInRange)(newState.doc, newRange, (node) => node.isTextblock);\n\t\t\t\tlet textBlock;\n\t\t\t\tlet textBeforeWhitespace;\n\t\t\t\tif (nodesInChangedRanges.length > 1) {\n\t\t\t\t\ttextBlock = nodesInChangedRanges[0];\n\t\t\t\t\ttextBeforeWhitespace = newState.doc.textBetween(textBlock.pos, textBlock.pos + textBlock.node.nodeSize, void 0, \" \");\n\t\t\t\t} else if (nodesInChangedRanges.length) {\n\t\t\t\t\tconst endText = newState.doc.textBetween(newRange.from, newRange.to, \" \", \" \");\n\t\t\t\t\tif (!UNICODE_WHITESPACE_REGEX_END.test(endText)) return;\n\t\t\t\t\ttextBlock = nodesInChangedRanges[0];\n\t\t\t\t\ttextBeforeWhitespace = newState.doc.textBetween(textBlock.pos, newRange.to, void 0, \" \");\n\t\t\t\t}\n\t\t\t\tif (textBlock && textBeforeWhitespace) {\n\t\t\t\t\tconst wordsBeforeWhitespace = textBeforeWhitespace.split(UNICODE_WHITESPACE_REGEX).filter(Boolean);\n\t\t\t\t\tif (wordsBeforeWhitespace.length <= 0) return false;\n\t\t\t\t\tconst lastWordBeforeSpace = wordsBeforeWhitespace[wordsBeforeWhitespace.length - 1];\n\t\t\t\t\tconst lastWordAndBlockOffset = textBlock.pos + textBeforeWhitespace.lastIndexOf(lastWordBeforeSpace);\n\t\t\t\t\tif (!lastWordBeforeSpace) return false;\n\t\t\t\t\tconst linksBeforeSpace = (0, linkifyjs.tokenize)(lastWordBeforeSpace).map((t) => t.toObject(options.defaultProtocol));\n\t\t\t\t\tif (!isValidLinkStructure(linksBeforeSpace)) return false;\n\t\t\t\t\tlinksBeforeSpace.filter((link) => link.isLink).map((link) => ({\n\t\t\t\t\t\t...link,\n\t\t\t\t\t\tfrom: lastWordAndBlockOffset + link.start + 1,\n\t\t\t\t\t\tto: lastWordAndBlockOffset + link.end + 1\n\t\t\t\t\t})).filter((link) => {\n\t\t\t\t\t\tif (!newState.schema.marks.code) return true;\n\t\t\t\t\t\treturn !newState.doc.rangeHasMark(link.from, link.to, newState.schema.marks.code);\n\t\t\t\t\t}).filter((link) => options.validate(link.value)).filter((link) => options.shouldAutoLink(link.value)).forEach((link) => {\n\t\t\t\t\t\tif ((0, _tiptap_core.getMarksBetween)(link.from, link.to, newState.doc).some((item) => item.mark.type === options.type)) return;\n\t\t\t\t\t\ttr.addMark(link.from, link.to, options.type.create({ href: link.href }));\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t\tif (!tr.steps.length) return;\n\t\t\treturn tr;\n\t\t}\n\t});\n}\n//#endregion\n//#region src/helpers/clickHandler.ts\nfunction clickHandler(options) {\n\treturn new _tiptap_pm_state.Plugin({\n\t\tkey: new _tiptap_pm_state.PluginKey(\"handleClickLink\"),\n\t\tprops: { handleClick: (view, pos, event) => {\n\t\t\tif (event.button !== 0) return false;\n\t\t\tif (!view.editable) return false;\n\t\t\tlet link = null;\n\t\t\tif (event.target instanceof HTMLAnchorElement) link = event.target;\n\t\t\telse {\n\t\t\t\tconst target = event.target;\n\t\t\t\tif (!target) return false;\n\t\t\t\tconst root = options.editor.view.dom;\n\t\t\t\tlink = target.closest(\"a\");\n\t\t\t\tif (link && !root.contains(link)) link = null;\n\t\t\t}\n\t\t\tif (!link) return false;\n\t\t\tlet handled = false;\n\t\t\tif (options.enableClickSelection) handled = options.editor.commands.extendMarkRange(options.type.name);\n\t\t\tif (options.openOnClick) {\n\t\t\t\tvar _link$href, _link$target;\n\t\t\t\tconst attrs = (0, _tiptap_core.getAttributes)(view.state, options.type.name);\n\t\t\t\tconst href = (_link$href = link.href) !== null && _link$href !== void 0 ? _link$href : attrs.href;\n\t\t\t\tconst target = (_link$target = link.target) !== null && _link$target !== void 0 ? _link$target : attrs.target;\n\t\t\t\tif (href) {\n\t\t\t\t\twindow.open(href, target);\n\t\t\t\t\thandled = true;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn handled;\n\t\t} }\n\t});\n}\n//#endregion\n//#region src/helpers/markdownLink.ts\n/**\n* Matches a Markdown link with an optional quoted title.\n* for ex: [Tiptap](https://tiptap.dev) or [Tiptap](https://tiptap.dev \"some title\")\n* the URL may also contain one level of balanced parentheses, as in CommonMark\n* (titles accept curly quotes too, the Typography extension swaps them in while typing)\n* the title delimiters must come in matching pairs\n*/\nconst MARKDOWN_LINK_INPUT_REGEX = /\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)$/;\n/**\n* Same as the input regex but global, to find every Markdown link in pasted text.\n*/\nconst MARKDOWN_LINK_PASTE_REGEX = /\\[([^[\\]]+)\\]\\(((?:[^\\s()]|\\([^\\s()]*\\))+)(?:\\s+(?:([\"'])(.*?)\\3|“(.*?)”|‘(.*?)’))?\\)/g;\nfunction isEscaped(text, index) {\n\tlet backslashes = 0;\n\tfor (let position = index - 1; position >= 0 && text[position] === \"\\\\\"; position -= 1) backslashes += 1;\n\treturn backslashes % 2 === 1;\n}\n/**\n* Pairs the backtick runs before the match by length, as CommonMark does.\n* A run left open means the match sits in an unfinished code span.\n*/\nfunction isInsideCodeSpan(text, matchIndex) {\n\tlet openRunLength = 0;\n\tlet index = 0;\n\twhile (index < matchIndex) {\n\t\tif (text[index] !== \"`\") {\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tif (openRunLength === 0 && isEscaped(text, index)) {\n\t\t\tindex += 1;\n\t\t\tcontinue;\n\t\t}\n\t\tlet runLength = 0;\n\t\twhile (index < matchIndex && text[index] === \"`\") {\n\t\t\trunLength += 1;\n\t\t\tindex += 1;\n\t\t}\n\t\tif (openRunLength === 0) openRunLength = runLength;\n\t\telse if (runLength === openRunLength) openRunLength = 0;\n\t}\n\treturn openRunLength > 0;\n}\nfunction isConvertibleLink(text, match, isAllowedHref) {\n\tvar _match$index, _match$index2;\n\tconst [, linkText, href] = match;\n\tif ((match.index ? text[match.index - 1] : void 0) === \"!\" || isEscaped(text, (_match$index = match.index) !== null && _match$index !== void 0 ? _match$index : 0)) return false;\n\tif (isInsideCodeSpan(text, (_match$index2 = match.index) !== null && _match$index2 !== void 0 ? _match$index2 : 0)) return false;\n\treturn !!linkText.trim() && isAllowedHref(href);\n}\nfunction toRuleMatch(match) {\n\tvar _ref, _match$index3;\n\tconst [linkSyntax, linkText, href, , straightQuotedTitle, curlyDoubleTitle, curlySingleTitle] = match;\n\tconst title = (_ref = straightQuotedTitle !== null && straightQuotedTitle !== void 0 ? straightQuotedTitle : curlyDoubleTitle) !== null && _ref !== void 0 ? _ref : curlySingleTitle;\n\treturn {\n\t\tindex: (_match$index3 = match.index) !== null && _match$index3 !== void 0 ? _match$index3 : 0,\n\t\ttext: linkSyntax,\n\t\treplaceWith: linkText,\n\t\tdata: {\n\t\t\thref,\n\t\t\ttitle: title || null,\n\t\t\tmarkdown: true\n\t\t}\n\t};\n}\nfunction matchesOverlap(a, b) {\n\treturn a.index < b.index + b.text.length && b.index < a.index + a.text.length;\n}\nfunction getMarkdownLinkAttributes(match) {\n\tvar _match$data, _match$data$title, _match$data2;\n\treturn {\n\t\thref: (_match$data = match.data) === null || _match$data === void 0 ? void 0 : _match$data.href,\n\t\ttitle: (_match$data$title = (_match$data2 = match.data) === null || _match$data2 === void 0 ? void 0 : _match$data2.title) !== null && _match$data$title !== void 0 ? _match$data$title : null\n\t};\n}\n/**\n* Turns typed Markdown link syntax into a link mark as soon as the closing `)` comes in.\n* The transaction gets flagged so autolink doesn't touch the converted text again.\n*/\nfunction markdownLinkInputRule(config) {\n\tconst rule = (0, _tiptap_core.markInputRule)({\n\t\tfind: (text) => {\n\t\t\tconst match = MARKDOWN_LINK_INPUT_REGEX.exec(text);\n\t\t\tif (!match || !isConvertibleLink(text, match, config.isAllowedHref)) return null;\n\t\t\treturn toRuleMatch(match);\n\t\t},\n\t\ttype: config.type,\n\t\tgetAttributes: getMarkdownLinkAttributes\n\t});\n\treturn new _tiptap_core.InputRule({\n\t\tfind: rule.find,\n\t\thandler: (props) => {\n\t\t\tconst result = rule.handler(props);\n\t\t\tif (result !== null && props.state.tr.steps.length) props.state.tr.setMeta(\"preventAutolink\", true);\n\t\t\treturn result;\n\t\t}\n\t});\n}\n/**\n* Same for pasting, converts every Markdown link found in the pasted text\n* and links the plain URLs from `findPlainUrls`.\n*/\nfunction markdownLinkPasteRule(config) {\n\tconst rule = (0, _tiptap_core.markPasteRule)({\n\t\tfind: (text) => {\n\t\t\tvar _config$findPlainUrls, _config$findPlainUrls2;\n\t\t\tconst markdownMatches = [];\n\t\t\tfor (const match of text.matchAll(MARKDOWN_LINK_PASTE_REGEX)) if (isConvertibleLink(text, match, config.isAllowedHref)) markdownMatches.push(toRuleMatch(match));\n\t\t\tconst plainUrlMatches = ((_config$findPlainUrls = (_config$findPlainUrls2 = config.findPlainUrls) === null || _config$findPlainUrls2 === void 0 ? void 0 : _config$findPlainUrls2.call(config, text)) !== null && _config$findPlainUrls !== void 0 ? _config$findPlainUrls : []).filter((urlMatch) => !markdownMatches.some((markdownMatch) => matchesOverlap(markdownMatch, urlMatch)));\n\t\t\treturn [...markdownMatches, ...plainUrlMatches];\n\t\t},\n\t\ttype: config.type,\n\t\tgetAttributes: getMarkdownLinkAttributes\n\t});\n\treturn new _tiptap_core.PasteRule({\n\t\tfind: rule.find,\n\t\thandler: (props) => {\n\t\t\tvar _props$match$data;\n\t\t\tconst result = rule.handler(props);\n\t\t\tif (result !== null && props.state.tr.steps.length && ((_props$match$data = props.match.data) === null || _props$match$data === void 0 ? void 0 : _props$match$data.markdown)) props.state.tr.setMeta(\"preventAutolink\", true);\n\t\t\treturn result;\n\t\t}\n\t});\n}\n//#endregion\n//#region src/helpers/pasteHandler.ts\nfunction pasteHandler(options) {\n\treturn new _tiptap_pm_state.Plugin({\n\t\tkey: new _tiptap_pm_state.PluginKey(\"handlePasteLink\"),\n\t\tprops: { handlePaste: (view, _event, slice) => {\n\t\t\tconst { shouldAutoLink } = options;\n\t\t\tconst { state } = view;\n\t\t\tconst { selection } = state;\n\t\t\tconst { empty } = selection;\n\t\t\tif (empty) return false;\n\t\t\tlet textContent = \"\";\n\t\t\tslice.content.forEach((node) => {\n\t\t\t\ttextContent += node.textContent;\n\t\t\t});\n\t\t\tconst link = (0, linkifyjs.find)(textContent, { defaultProtocol: options.defaultProtocol }).find((item) => item.isLink && item.value === textContent);\n\t\t\tif (!textContent || !link || shouldAutoLink !== void 0 && !shouldAutoLink(link.value)) return false;\n\t\t\treturn options.editor.commands.setMark(options.type, { href: link.href });\n\t\t} }\n\t});\n}\n//#endregion\n//#region src/link.ts\nconst pasteRegex = /https?:\\/\\/(?:www\\.)?[-a-zA-Z0-9@:%._+~#=]{1,256}\\.[a-zA-Z]{2,}\\b(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)(?:[-a-zA-Z0-9@:%._+~#=?!&/]*)/gi;\nfunction isAllowedUri(uri, protocols) {\n\tconst allowedProtocols = [\n\t\t\"http\",\n\t\t\"https\",\n\t\t\"ftp\",\n\t\t\"ftps\",\n\t\t\"mailto\",\n\t\t\"tel\",\n\t\t\"callto\",\n\t\t\"sms\",\n\t\t\"cid\",\n\t\t\"xmpp\"\n\t];\n\tif (protocols) protocols.forEach((protocol) => {\n\t\tconst nextProtocol = typeof protocol === \"string\" ? protocol : protocol.scheme;\n\t\tif (nextProtocol) allowedProtocols.push(nextProtocol);\n\t});\n\treturn !uri || uri.replace(UNICODE_WHITESPACE_REGEX_GLOBAL, \"\").match(new RegExp(`^(?:(?:${allowedProtocols.map((protocol) => protocol.replace(/[-/\\\\^$*+?.()|[\\]{}]/g, \"\\\\$&\")).join(\"|\")}):|[^a-z]|[a-z0-9+.\\\\-]+(?:[^a-z+.\\\\-:]|$))`, \"i\"));\n}\n/**\n* This extension allows you to create links.\n* @see https://www.tiptap.dev/api/marks/link\n*/\nconst Link = _tiptap_core.Mark.create({\n\tname: \"link\",\n\tpriority: 1e3,\n\tkeepOnSplit: false,\n\texitable: true,\n\tonCreate() {\n\t\tif (this.options.validate && !this.options.shouldAutoLink) {\n\t\t\tthis.options.shouldAutoLink = this.options.validate;\n\t\t\tconsole.warn(\"The `validate` option is deprecated. Rename to the `shouldAutoLink` option instead.\");\n\t\t}\n\t\tthis.options.protocols.forEach((protocol) => {\n\t\t\tif (typeof protocol === \"string\") {\n\t\t\t\t(0, linkifyjs.registerCustomProtocol)(protocol);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t(0, linkifyjs.registerCustomProtocol)(protocol.scheme, protocol.optionalSlashes);\n\t\t});\n\t},\n\tonDestroy() {\n\t\t(0, linkifyjs.reset)();\n\t},\n\tinclusive() {\n\t\treturn this.options.autolink;\n\t},\n\taddOptions() {\n\t\treturn {\n\t\t\topenOnClick: true,\n\t\t\tenableClickSelection: false,\n\t\t\tlinkOnPaste: true,\n\t\t\tmarkdownLinks: false,\n\t\t\tautolink: true,\n\t\t\tprotocols: [],\n\t\t\tdefaultProtocol: \"http\",\n\t\t\tHTMLAttributes: {\n\t\t\t\ttarget: \"_blank\",\n\t\t\t\trel: \"noopener noreferrer nofollow\",\n\t\t\t\tclass: null\n\t\t\t},\n\t\t\tisAllowedUri: (url, ctx) => !!isAllowedUri(url, ctx.protocols),\n\t\t\tvalidate: (url) => !!url,\n\t\t\tshouldAutoLink: (url) => {\n\t\t\t\tconst hasProtocol = /^[a-z][a-z0-9+.-]*:\\/\\//i.test(url);\n\t\t\t\tconst hasMaybeProtocol = /^[a-z][a-z0-9+.-]*:/i.test(url);\n\t\t\t\tif (hasProtocol || hasMaybeProtocol && !url.includes(\"@\")) return true;\n\t\t\t\tconst hostname = (url.includes(\"@\") ? url.split(\"@\").pop() : url).split(/[/?#:]/)[0];\n\t\t\t\tif (/^\\d{1,3}(\\.\\d{1,3}){3}$/.test(hostname)) return false;\n\t\t\t\tif (!/\\./.test(hostname)) return false;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\t},\n\taddAttributes() {\n\t\tvar _this$options$HTMLAtt, _this$options$HTMLAtt2, _this$options$HTMLAtt3;\n\t\treturn {\n\t\t\thref: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML(element) {\n\t\t\t\t\treturn element.getAttribute(\"href\");\n\t\t\t\t}\n\t\t\t},\n\t\t\ttarget: { default: (_this$options$HTMLAtt = this.options.HTMLAttributes.target) !== null && _this$options$HTMLAtt !== void 0 ? _this$options$HTMLAtt : null },\n\t\t\trel: { default: (_this$options$HTMLAtt2 = this.options.HTMLAttributes.rel) !== null && _this$options$HTMLAtt2 !== void 0 ? _this$options$HTMLAtt2 : null },\n\t\t\tclass: { default: (_this$options$HTMLAtt3 = this.options.HTMLAttributes.class) !== null && _this$options$HTMLAtt3 !== void 0 ? _this$options$HTMLAtt3 : null },\n\t\t\ttitle: { default: null }\n\t\t};\n\t},\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"a[href]\",\n\t\t\tgetAttrs: (dom) => {\n\t\t\t\tconst href = dom.getAttribute(\"href\");\n\t\t\t\tif (!href || !this.options.isAllowedUri(href, {\n\t\t\t\t\tdefaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),\n\t\t\t\t\tprotocols: this.options.protocols,\n\t\t\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t\t\t})) return false;\n\t\t\t\treturn null;\n\t\t\t}\n\t\t}];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\tif (!this.options.isAllowedUri(HTMLAttributes.href, {\n\t\t\tdefaultValidate: (href) => !!isAllowedUri(href, this.options.protocols),\n\t\t\tprotocols: this.options.protocols,\n\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t})) return [\n\t\t\t\"a\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, {\n\t\t\t\t...HTMLAttributes,\n\t\t\t\thref: \"\"\n\t\t\t}),\n\t\t\t0\n\t\t];\n\t\treturn [\n\t\t\t\"a\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"link\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.applyMark(\"link\", helpers.parseInline(token.tokens || []), {\n\t\t\thref: token.href,\n\t\t\ttitle: token.title || null\n\t\t});\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tvar _node$attrs$href, _node$attrs, _node$attrs$title, _node$attrs2;\n\t\tconst href = (_node$attrs$href = (_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.href) !== null && _node$attrs$href !== void 0 ? _node$attrs$href : \"\";\n\t\tconst title = (_node$attrs$title = (_node$attrs2 = node.attrs) === null || _node$attrs2 === void 0 ? void 0 : _node$attrs2.title) !== null && _node$attrs$title !== void 0 ? _node$attrs$title : \"\";\n\t\tconst text = h.renderChildren(node);\n\t\treturn title ? `[${text}](${href} \"${title}\")` : `[${text}](${href})`;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetLink: (attributes) => ({ chain }) => {\n\t\t\t\tconst { href } = attributes;\n\t\t\t\tif (!this.options.isAllowedUri(href, {\n\t\t\t\t\tdefaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),\n\t\t\t\t\tprotocols: this.options.protocols,\n\t\t\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t\t\t})) return false;\n\t\t\t\treturn chain().setMark(this.name, attributes).setMeta(\"preventAutolink\", true).run();\n\t\t\t},\n\t\t\ttoggleLink: (attributes) => ({ chain }) => {\n\t\t\t\tconst { href } = attributes || {};\n\t\t\t\tif (href && !this.options.isAllowedUri(href, {\n\t\t\t\t\tdefaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),\n\t\t\t\t\tprotocols: this.options.protocols,\n\t\t\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t\t\t})) return false;\n\t\t\t\treturn chain().toggleMark(this.name, attributes, { extendEmptyMarkRange: true }).setMeta(\"preventAutolink\", true).run();\n\t\t\t},\n\t\t\tunsetLink: () => ({ chain }) => {\n\t\t\t\treturn chain().unsetMark(this.name, { extendEmptyMarkRange: true }).setMeta(\"preventAutolink\", true).run();\n\t\t\t}\n\t\t};\n\t},\n\taddInputRules() {\n\t\tif (!this.options.markdownLinks) return [];\n\t\treturn [markdownLinkInputRule({\n\t\t\ttype: this.type,\n\t\t\tisAllowedHref: (href) => this.options.isAllowedUri(href, {\n\t\t\t\tdefaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),\n\t\t\t\tprotocols: this.options.protocols,\n\t\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t\t})\n\t\t})];\n\t},\n\taddPasteRules() {\n\t\tconst findPlainUrls = (text) => {\n\t\t\tconst foundLinks = [];\n\t\t\tif (text) {\n\t\t\t\tconst { protocols, defaultProtocol } = this.options;\n\t\t\t\t(0, linkifyjs.find)(text).filter((item) => item.isLink && this.options.isAllowedUri(item.value, {\n\t\t\t\t\tdefaultValidate: (href) => !!isAllowedUri(href, protocols),\n\t\t\t\t\tprotocols,\n\t\t\t\t\tdefaultProtocol\n\t\t\t\t})).forEach((link) => {\n\t\t\t\t\tif (!this.options.shouldAutoLink(link.value)) return;\n\t\t\t\t\tfoundLinks.push({\n\t\t\t\t\t\ttext: link.value,\n\t\t\t\t\t\tdata: { href: link.href },\n\t\t\t\t\t\tindex: link.start\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t}\n\t\t\treturn foundLinks;\n\t\t};\n\t\tif (this.options.markdownLinks) return [markdownLinkPasteRule({\n\t\t\ttype: this.type,\n\t\t\tisAllowedHref: (href) => this.options.isAllowedUri(href, {\n\t\t\t\tdefaultValidate: (url) => !!isAllowedUri(url, this.options.protocols),\n\t\t\t\tprotocols: this.options.protocols,\n\t\t\t\tdefaultProtocol: this.options.defaultProtocol\n\t\t\t}),\n\t\t\tfindPlainUrls\n\t\t})];\n\t\treturn [(0, _tiptap_core.markPasteRule)({\n\t\t\tfind: findPlainUrls,\n\t\t\ttype: this.type,\n\t\t\tgetAttributes: (match) => {\n\t\t\t\tvar _match$data;\n\t\t\t\treturn { href: (_match$data = match.data) === null || _match$data === void 0 ? void 0 : _match$data.href };\n\t\t\t}\n\t\t})];\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst plugins = [];\n\t\tconst { protocols, defaultProtocol } = this.options;\n\t\tif (this.options.autolink) plugins.push(autolink({\n\t\t\ttype: this.type,\n\t\t\tdefaultProtocol: this.options.defaultProtocol,\n\t\t\tvalidate: (url) => this.options.isAllowedUri(url, {\n\t\t\t\tdefaultValidate: (href) => !!isAllowedUri(href, protocols),\n\t\t\t\tprotocols,\n\t\t\t\tdefaultProtocol\n\t\t\t}),\n\t\t\tshouldAutoLink: this.options.shouldAutoLink\n\t\t}));\n\t\tplugins.push(clickHandler({\n\t\t\ttype: this.type,\n\t\t\teditor: this.editor,\n\t\t\topenOnClick: this.options.openOnClick === \"whenNotEditable\" ? true : this.options.openOnClick,\n\t\t\tenableClickSelection: this.options.enableClickSelection\n\t\t}));\n\t\tif (this.options.linkOnPaste) plugins.push(pasteHandler({\n\t\t\teditor: this.editor,\n\t\t\tdefaultProtocol: this.options.defaultProtocol,\n\t\t\ttype: this.type,\n\t\t\tshouldAutoLink: this.options.shouldAutoLink\n\t\t}));\n\t\treturn plugins;\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Link;\n//#endregion\nexports.Link = Link;\nexports.default = src_default;\nexports.isAllowedUri = isAllowedUri;\nexports.pasteRegex = pasteRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\n//#region \\0rolldown/runtime.js\nvar __defProp = Object.defineProperty;\nvar __exportAll = (all, no_symbols) => {\n\tlet target = {};\n\tfor (var name in all) __defProp(target, name, {\n\t\tget: all[name],\n\t\tenumerable: true\n\t});\n\tif (!no_symbols) __defProp(target, Symbol.toStringTag, { value: \"Module\" });\n\treturn target;\n};\n//#endregion\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_model = require(\"@tiptap/pm/model\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\n//#region src/bullet-list/bullet-list.ts\nconst ListItemName$1 = \"listItem\";\nconst TextStyleName$1 = \"textStyle\";\n/**\n* Matches a bullet list to a dash or asterisk.\n*/\nconst bulletListInputRegex = /^\\s*([-+*])\\s$/;\n/**\n* This extension allows you to create bullet lists.\n* This requires the ListItem extension\n* @see https://tiptap.dev/api/nodes/bullet-list\n* @see https://tiptap.dev/api/nodes/list-item.\n*/\nconst BulletList = _tiptap_core.Node.create({\n\tname: \"bulletList\",\n\taddOptions() {\n\t\treturn {\n\t\t\titemTypeName: \"listItem\",\n\t\t\tHTMLAttributes: {},\n\t\t\tkeepMarks: false,\n\t\t\tkeepAttributes: false\n\t\t};\n\t},\n\tgroup: \"block list\",\n\tcontent() {\n\t\treturn `${this.options.itemTypeName}+`;\n\t},\n\tparseHTML() {\n\t\treturn [{ tag: \"ul\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"ul\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"list\",\n\tparseMarkdown: (token, helpers) => {\n\t\tif (token.type !== \"list\" || token.ordered) return [];\n\t\treturn {\n\t\t\ttype: \"bulletList\",\n\t\t\tcontent: token.items ? helpers.parseChildren(token.items) : []\n\t\t};\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\treturn h.renderChildren(node.content, \"\\n\");\n\t},\n\tmarkdownOptions: { indentsContent: true },\n\taddCommands() {\n\t\treturn { toggleBulletList: () => ({ commands, chain }) => {\n\t\t\tif (this.options.keepAttributes) return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName$1, this.editor.getAttributes(TextStyleName$1)).run();\n\t\t\treturn commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);\n\t\t} };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-Shift-8\": () => this.editor.commands.toggleBulletList() };\n\t},\n\taddInputRules() {\n\t\tlet inputRule = (0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: bulletListInputRegex,\n\t\t\ttype: this.type\n\t\t});\n\t\tif (this.options.keepMarks || this.options.keepAttributes) inputRule = (0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: bulletListInputRegex,\n\t\t\ttype: this.type,\n\t\t\tkeepMarks: this.options.keepMarks,\n\t\t\tkeepAttributes: this.options.keepAttributes,\n\t\t\tgetAttributes: () => {\n\t\t\t\treturn this.editor.getAttributes(TextStyleName$1);\n\t\t\t},\n\t\t\teditor: this.editor\n\t\t});\n\t\treturn [inputRule];\n\t}\n});\n//#endregion\n//#region src/helpers/getBranchingNestedListAtCursor.ts\n/**\n* Resolves a branching nested list immediately after the cursor when the selection is\n* collapsed at the end of a textblock inside a list item.\n*\n* @param state - The editor state to inspect.\n* @param itemName - The list item node name (for example `listItem` or `taskItem`).\n* @param wrapperNames - List wrapper node names (for example `bulletList` and `orderedList`).\n* @returns Resolved positions and nodes for hoisting, or `null` when not applicable.\n*\n* @example\n* ```ts\n* const context = getBranchingNestedListAtCursor(editor.state, 'listItem', [\n* 'bulletList',\n* 'orderedList',\n* ])\n*\n* if (context) {\n* // cursor is at the end of Item 1 before a branching nested sublist\n* }\n* ```\n*/\nconst getBranchingNestedListAtCursor = (state, itemName, wrapperNames) => {\n\tconst { selection } = state;\n\tif (!selection.empty) return null;\n\tconst { $from } = selection;\n\tif (!$from.parent.isTextblock) return null;\n\tif ($from.parentOffset !== $from.parent.content.size) return null;\n\tlet listItemDepth = -1;\n\tfor (let depth = $from.depth; depth > 0; depth -= 1) if ($from.node(depth).type.name === itemName) {\n\t\tlistItemDepth = depth;\n\t\tbreak;\n\t}\n\tif (listItemDepth < 0) return null;\n\tconst listItem = $from.node(listItemDepth);\n\tconst indexInListItem = $from.index(listItemDepth);\n\tif (indexInListItem + 1 >= listItem.childCount) return null;\n\tconst nextChild = listItem.child(indexInListItem + 1);\n\tif (!wrapperNames.includes(nextChild.type.name)) return null;\n\tconst itemType = state.schema.nodes[itemName];\n\tlet hasBranching = false;\n\tnextChild.forEach((child) => {\n\t\tif (child.type === itemType && child.childCount > 1) hasBranching = true;\n\t});\n\tif (!hasBranching) return null;\n\tconst nodeAfter = state.doc.resolve($from.after()).nodeAfter;\n\tif (!nodeAfter || !wrapperNames.includes(nodeAfter.type.name)) return null;\n\tconst items = [];\n\tnodeAfter.forEach((child) => {\n\t\titems.push(child);\n\t});\n\tif (items.length === 0) return null;\n\treturn {\n\t\tlistItemDepth,\n\t\tnestedList: nodeAfter,\n\t\tnestedListPos: $from.after(),\n\t\tinsertPos: $from.after(listItemDepth),\n\t\titems\n\t};\n};\n//#endregion\n//#region src/helpers/hoistBranchingNestedList.ts\n/**\n* Hoists all list items from a branching nested list after the cursor into the parent list.\n*\n* Use this when `joinForward` cannot restructure a nested list that contains list items\n* with sublists (see issue #6906).\n*\n* @param state - The editor state to transform.\n* @param dispatch - Optional dispatch function for the transaction.\n* @param itemName - The list item node name (for example `listItem` or `taskItem`).\n* @param wrapperNames - List wrapper node names (for example `bulletList` and `orderedList`).\n* @returns `true` when the nested list was hoisted, otherwise `false`.\n*\n* @example\n* ```ts\n* // Cursor at the end of \"Item 1\" before a nested list with branching items.\n* hoistBranchingNestedList(editor.state, editor.view.dispatch, 'listItem', [\n* 'bulletList',\n* 'orderedList',\n* ])\n* ```\n*/\nconst hoistBranchingNestedList = (state, dispatch, itemName, wrapperNames) => {\n\tconst context = getBranchingNestedListAtCursor(state, itemName, wrapperNames);\n\tif (!context) return false;\n\tconst { selection } = state;\n\tconst { nestedList, nestedListPos, insertPos, items } = context;\n\tconst tr = state.tr;\n\ttr.delete(nestedListPos, nestedListPos + nestedList.nodeSize);\n\tconst mappedInsertPos = tr.mapping.map(insertPos);\n\ttr.insert(mappedInsertPos, _tiptap_pm_model.Fragment.from(items));\n\ttr.setSelection(selection.map(tr.doc, tr.mapping));\n\tif (dispatch) dispatch(tr);\n\treturn true;\n};\n//#endregion\n//#region src/helpers/handleDeleteBranchingNestedList.ts\n/**\n* Handles Delete for a list item when a branching nested sublist follows the cursor.\n*\n* @param editor - The editor instance whose state should be updated.\n* @param itemName - The list item node name (for example `listItem` or `taskItem`).\n* @param wrapperNames - List wrapper node names (for example `bulletList` and `orderedList`).\n* @returns `true` when the nested list was hoisted, otherwise `false`.\n*\n* @example\n* ```ts\n* Delete: () =>\n* handleDeleteBranchingNestedList(editor, 'listItem', ['bulletList', 'orderedList']),\n* ```\n*/\nconst handleDeleteBranchingNestedList = (editor, itemName, wrapperNames) => {\n\treturn hoistBranchingNestedList(editor.state, editor.view.dispatch, itemName, wrapperNames);\n};\n//#endregion\n//#region src/helpers/createBranchingListDeleteKeymap.ts\n/**\n* Creates a high-priority keymap extension that handles Delete for branching nested lists.\n* Kept separate from the list item node so Enter/Tab shortcuts keep their default priority.\n*/\nconst createBranchingListDeleteKeymap = (itemName, wrapperNames) => {\n\treturn _tiptap_core.Extension.create({\n\t\tname: `${itemName}BranchingDeleteKeymap`,\n\t\tpriority: 101,\n\t\taddKeyboardShortcuts() {\n\t\t\tconst handleDelete = () => handleDeleteBranchingNestedList(this.editor, itemName, wrapperNames);\n\t\t\treturn {\n\t\t\t\tDelete: handleDelete,\n\t\t\t\t\"Mod-Delete\": handleDelete\n\t\t\t};\n\t\t}\n\t});\n};\n//#endregion\n//#region src/ordered-list/roman.ts\nconst ROMAN_NUMERALS = [\n\t[1e3, \"m\"],\n\t[900, \"cm\"],\n\t[500, \"d\"],\n\t[400, \"cd\"],\n\t[100, \"c\"],\n\t[90, \"xc\"],\n\t[50, \"l\"],\n\t[40, \"xl\"],\n\t[10, \"x\"],\n\t[9, \"ix\"],\n\t[5, \"v\"],\n\t[4, \"iv\"],\n\t[1, \"i\"]\n];\nconst ALPHA_NUMERALS = \"abcdefghijklmnopqrstuvwxyz\";\n/**\n* Marker segment for ordered list lines: numeric, roman, or 1–2 letter alpha.\n* Roman is matched before alpha so \"iii\" is roman; invalid romans like \"aa\" fall through to alpha.\n*/\nconst ORDERED_LIST_MARKER_PATTERN = String.raw`\\d+|[ivxlcdmIVXLCDM]+|${\"[a-zA-Z]{1,2}\"}`;\n/**\n* Convert a number to lowercase roman numerals.\n* @example toRoman(1) // 'i'\n* @example toRoman(4) // 'iv'\n*/\nfunction toRoman(num) {\n\tlet remaining = num;\n\tlet result = \"\";\n\tfor (const [value, numeral] of ROMAN_NUMERALS) while (remaining >= value) {\n\t\tresult += numeral;\n\t\tremaining -= value;\n\t}\n\treturn result;\n}\n/**\n* Convert a number to uppercase roman numerals.\n* @example toRomanUpper(1) // 'I'\n* @example toRomanUpper(4) // 'IV'\n*/\nfunction toRomanUpper(num) {\n\treturn toRoman(num).toUpperCase();\n}\nfunction fromRoman(roman) {\n\tconst lower = roman.toLowerCase();\n\tlet index = 0;\n\tlet result = 0;\n\twhile (index < lower.length) {\n\t\tlet matched = false;\n\t\tfor (const [value, numeral] of ROMAN_NUMERALS) if (lower.startsWith(numeral, index)) {\n\t\t\tresult += value;\n\t\t\tindex += numeral.length;\n\t\t\tmatched = true;\n\t\t\tbreak;\n\t\t}\n\t\tif (!matched) return 0;\n\t}\n\treturn result;\n}\nfunction isValidRoman(marker) {\n\tif (!/^[ivxlcdmIVXLCDM]+$/.test(marker)) return false;\n\tconst value = fromRoman(marker);\n\tif (value <= 0) return false;\n\treturn (marker === marker.toLowerCase() ? toRoman(value) : toRomanUpper(value)) === marker;\n}\nfunction fromAlpha(marker) {\n\tconst lower = marker.toLowerCase();\n\tif (lower.length === 1) return lower.charCodeAt(0) - \"a\".charCodeAt(0) + 1;\n\tif (lower.length === 2) {\n\t\tconst first = lower.charCodeAt(0) - \"a\".charCodeAt(0);\n\t\tconst second = lower.charCodeAt(1) - \"a\".charCodeAt(0);\n\t\treturn (first + 1) * 26 + second + 1;\n\t}\n\treturn 0;\n}\nfunction toRomanAlpha(num) {\n\tif (num <= 26) return ALPHA_NUMERALS[num - 1];\n\tconst first = Math.floor((num - 1) / 26) - 1;\n\tconst second = (num - 1) % 26;\n\tif (first < 0) return ALPHA_NUMERALS[second];\n\treturn ALPHA_NUMERALS[first] + ALPHA_NUMERALS[second];\n}\n/**\n* Extract the list marker type from a marker string.\n* Supports \"1\", \"a\", \"A\", \"i\", \"I\" marker styles.\n*\n* @param marker The text content of the list marker (e.g. \"a\", \"1\", \"iii\", \"b\")\n* @returns The normalized type string, or undefined for default numeric type\n*/\nfunction detectMarkerType(marker) {\n\tif (!marker || /^\\d+$/.test(marker)) return;\n\tif (isValidRoman(marker)) return marker === marker.toLowerCase() ? \"i\" : \"I\";\n\tif (/^[a-z]{1,2}$/.test(marker)) return \"a\";\n\tif (/^[A-Z]{1,2}$/.test(marker)) return \"A\";\n}\n/**\n* Convert a list marker string to its numeric start position.\n*\n* @param marker The text content of the list marker (e.g. \"3\", \"b\", \"II\")\n* @returns The 1-based start value for the ordered list\n*/\nfunction markerToStart(marker) {\n\tif (/^\\d+$/.test(marker)) return parseInt(marker, 10);\n\tconst type = detectMarkerType(marker);\n\tif (type === \"i\" || type === \"I\") return fromRoman(marker);\n\tif (type === \"a\" || type === \"A\") {\n\t\tconst start = fromAlpha(marker);\n\t\treturn start > 0 ? start : 1;\n\t}\n\tconst parsed = parseInt(marker, 10);\n\treturn Number.isNaN(parsed) ? 1 : parsed;\n}\nfunction startToMarker(type, start) {\n\tif (type === \"numeric\") return String(start);\n\tswitch (type) {\n\t\tcase \"a\": return toRomanAlpha(start);\n\t\tcase \"A\": return toRomanAlpha(start).toUpperCase();\n\t\tcase \"i\": return toRoman(start);\n\t\tcase \"I\": return toRomanUpper(start);\n\t\tdefault: return String(start);\n\t}\n}\n/**\n* Returns true when all markers share the same style and increment by 1.\n* Style is inferred from the first marker so ambiguous letters (e.g. \"c\", \"i\")\n* are not re-classified differently on later lines.\n*/\nfunction areOrderedListMarkersSequential(markers) {\n\tvar _detectMarkerType;\n\tif (markers.length === 0) return false;\n\tconst firstType = (_detectMarkerType = detectMarkerType(markers[0])) !== null && _detectMarkerType !== void 0 ? _detectMarkerType : \"numeric\";\n\tconst firstStart = markerToStart(markers[0]);\n\tif (firstStart < 1) return false;\n\tfor (let i = 0; i < markers.length; i++) {\n\t\tconst expected = startToMarker(firstType, firstStart + i);\n\t\tif (markers[i] !== expected) return false;\n\t}\n\treturn true;\n}\n/**\n* Parse a list marker into HTML ordered-list attrs (type + start).\n*/\nfunction parseListMarker(marker) {\n\treturn {\n\t\ttype: detectMarkerType(marker),\n\t\tstart: markerToStart(marker)\n\t};\n}\n/**\n* Build orderedList node attrs from the first list item marker.\n*/\nfunction buildOrderedListAttrsFromMarker(marker) {\n\tconst { type, start } = parseListMarker(marker);\n\tconst attrs = {};\n\tif (type) attrs.type = type;\n\tif (start !== 1) attrs.start = start;\n\treturn attrs;\n}\n/**\n* Returns the list marker prefix for a given item at a given index.\n*\n* @param type The list type attribute (e.g. \"a\", \"A\", \"i\", \"I\", null/undefined for default)\n* @param index The zero-based index of the list item\n* @param separator The separator to use (default: \". \")\n* @returns The marker string (e.g. \"a. \", \"I. \", \"1. \")\n*/\nfunction getListMarker(type, index, separator = \". \") {\n\tconst position = index + 1;\n\tif (!type || type === \"1\") return `${position}${separator}`;\n\tswitch (type) {\n\t\tcase \"a\": return `${toRomanAlpha(position)}${separator}`;\n\t\tcase \"A\": return `${toRomanAlpha(position).toUpperCase()}${separator}`;\n\t\tcase \"i\": return `${toRoman(position)}${separator}`;\n\t\tcase \"I\": return `${toRomanUpper(position)}${separator}`;\n\t\tdefault: return `${position}${separator}`;\n\t}\n}\n//#endregion\n//#region src/item/list-item.ts\nfunction isSameLineOrderedListToken(token) {\n\tvar _token$tokens, _token$tokens2;\n\tconst nestedToken = (_token$tokens = token.tokens) === null || _token$tokens === void 0 ? void 0 : _token$tokens[0];\n\treturn Boolean(token.text && ((_token$tokens2 = token.tokens) === null || _token$tokens2 === void 0 ? void 0 : _token$tokens2.length) === 1 && (nestedToken === null || nestedToken === void 0 ? void 0 : nestedToken.type) === \"list\" && nestedToken.ordered && nestedToken.raw === token.text);\n}\nfunction parseSameLineOrderedListText(text, helpers) {\n\tif (helpers.tokenizeInline) return helpers.parseInline(helpers.tokenizeInline(text));\n\treturn helpers.parseInline([{\n\t\ttype: \"text\",\n\t\traw: text,\n\t\ttext\n\t}]);\n}\n/**\n* This extension allows you to create list items.\n* @see https://www.tiptap.dev/api/nodes/list-item\n*/\nconst ListItem = _tiptap_core.Node.create({\n\tname: \"listItem\",\n\taddOptions() {\n\t\treturn {\n\t\t\tHTMLAttributes: {},\n\t\t\tbulletListTypeName: \"bulletList\",\n\t\t\torderedListTypeName: \"orderedList\"\n\t\t};\n\t},\n\tcontent: \"paragraph block*\",\n\tdefining: true,\n\tparseHTML() {\n\t\treturn [{ tag: \"li\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"li\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"list_item\",\n\tparseMarkdown: (token, helpers) => {\n\t\tvar _helpers$parseBlockCh;\n\t\tif (token.type !== \"list_item\") return [];\n\t\tconst parseBlockChildren = (_helpers$parseBlockCh = helpers.parseBlockChildren) !== null && _helpers$parseBlockCh !== void 0 ? _helpers$parseBlockCh : helpers.parseChildren;\n\t\tlet content = [];\n\t\tif (token.tokens && token.tokens.length > 0) {\n\t\t\tif (isSameLineOrderedListToken(token)) return {\n\t\t\t\ttype: \"listItem\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: parseSameLineOrderedListText(token.text || \"\", helpers)\n\t\t\t\t}]\n\t\t\t};\n\t\t\tif (token.tokens.some((t) => t.type === \"paragraph\")) content = parseBlockChildren(token.tokens);\n\t\t\telse {\n\t\t\t\tconst firstToken = token.tokens[0];\n\t\t\t\tif (firstToken && firstToken.type === \"text\" && firstToken.tokens && firstToken.tokens.length > 0) {\n\t\t\t\t\tcontent = [{\n\t\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\t\tcontent: helpers.parseInline(firstToken.tokens)\n\t\t\t\t\t}];\n\t\t\t\t\tif (token.tokens.length > 1) {\n\t\t\t\t\t\tconst additionalContent = parseBlockChildren(token.tokens.slice(1));\n\t\t\t\t\t\tcontent.push(...additionalContent);\n\t\t\t\t\t}\n\t\t\t\t} else content = parseBlockChildren(token.tokens);\n\t\t\t}\n\t\t}\n\t\tif (content.length === 0) content = [{\n\t\t\ttype: \"paragraph\",\n\t\t\tcontent: []\n\t\t}];\n\t\treturn {\n\t\t\ttype: \"listItem\",\n\t\t\tcontent\n\t\t};\n\t},\n\trenderMarkdown: (node, h, ctx) => {\n\t\treturn (0, _tiptap_core.renderNestedMarkdownContent)(node, h, (context) => {\n\t\t\tif (context.parentType === \"bulletList\") return \"- \";\n\t\t\tif (context.parentType === \"orderedList\") {\n\t\t\t\tvar _context$meta, _context$meta2;\n\t\t\t\tconst start = ((_context$meta = context.meta) === null || _context$meta === void 0 || (_context$meta = _context$meta.parentAttrs) === null || _context$meta === void 0 ? void 0 : _context$meta.start) || 1;\n\t\t\t\treturn getListMarker((_context$meta2 = context.meta) === null || _context$meta2 === void 0 || (_context$meta2 = _context$meta2.parentAttrs) === null || _context$meta2 === void 0 ? void 0 : _context$meta2.type, start - 1 + (context.index || 0), \". \");\n\t\t\t}\n\t\t\treturn \"- \";\n\t\t}, ctx, { alignNestedToPrefix: (ctx === null || ctx === void 0 ? void 0 : ctx.parentType) === \"orderedList\" });\n\t},\n\taddExtensions() {\n\t\treturn [createBranchingListDeleteKeymap(this.name, [this.options.bulletListTypeName, this.options.orderedListTypeName])];\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\tEnter: () => this.editor.commands.splitListItem(this.name),\n\t\t\tTab: () => this.editor.commands.sinkListItem(this.name),\n\t\t\t\"Shift-Tab\": () => this.editor.commands.liftListItem(this.name)\n\t\t};\n\t}\n});\n//#endregion\n//#region src/keymap/listHelpers/findListItemPos.ts\nconst findListItemPos = (typeOrName, state) => {\n\tconst { $from } = state.selection;\n\tconst nodeType = (0, _tiptap_core.getNodeType)(typeOrName, state.schema);\n\tlet currentNode = null;\n\tlet currentDepth = $from.depth;\n\tlet currentPos = $from.pos;\n\tlet targetDepth = null;\n\twhile (currentDepth > 0 && targetDepth === null) {\n\t\tcurrentNode = $from.node(currentDepth);\n\t\tif (currentNode.type === nodeType) targetDepth = currentDepth;\n\t\telse {\n\t\t\tcurrentDepth -= 1;\n\t\t\tcurrentPos -= 1;\n\t\t}\n\t}\n\tif (targetDepth === null) return null;\n\treturn {\n\t\t$pos: state.doc.resolve(currentPos),\n\t\tdepth: targetDepth\n\t};\n};\n//#endregion\n//#region src/keymap/listHelpers/getNextListDepth.ts\nconst getNextListDepth = (typeOrName, state) => {\n\tconst listItemPos = findListItemPos(typeOrName, state);\n\tif (!listItemPos) return false;\n\tconst [, depth] = (0, _tiptap_core.getNodeAtPosition)(state, typeOrName, listItemPos.$pos.pos + 4);\n\treturn depth;\n};\n//#endregion\n//#region src/keymap/listHelpers/hasListBefore.ts\nconst hasListBefore = (editorState, name, parentListTypes) => {\n\tconst { $anchor } = editorState.selection;\n\tconst previousNodePos = Math.max(0, $anchor.pos - 2);\n\tconst previousNode = editorState.doc.resolve(previousNodePos).node();\n\tif (!previousNode || !parentListTypes.includes(previousNode.type.name)) return false;\n\treturn true;\n};\n//#endregion\n//#region src/keymap/listHelpers/handleBackspace.ts\nconst handleBackspace = (editor, name, parentListTypes) => {\n\tif (editor.commands.undoInputRule()) return true;\n\tif (editor.state.selection.from !== editor.state.selection.to) return false;\n\tif (!(0, _tiptap_core.isNodeActive)(editor.state, name) && hasListBefore(editor.state, name, parentListTypes)) {\n\t\tconst { $anchor } = editor.state.selection;\n\t\tconst $listPos = editor.state.doc.resolve($anchor.before() - 1);\n\t\tconst listDescendants = [];\n\t\t$listPos.node().descendants((node, pos) => {\n\t\t\tif (node.type.name === name) listDescendants.push({\n\t\t\t\tnode,\n\t\t\t\tpos\n\t\t\t});\n\t\t});\n\t\tconst lastItem = listDescendants.at(-1);\n\t\tif (!lastItem) return false;\n\t\tconst $lastItemPos = editor.state.doc.resolve($listPos.start() + lastItem.pos + 1);\n\t\treturn editor.chain().cut({\n\t\t\tfrom: $anchor.start() - 1,\n\t\t\tto: $anchor.end() + 1\n\t\t}, $lastItemPos.end()).joinForward().run();\n\t}\n\tif (!(0, _tiptap_core.isNodeActive)(editor.state, name)) return false;\n\tif (!(0, _tiptap_core.isAtStartOfNode)(editor.state)) return false;\n\tconst { $from } = editor.state.selection;\n\tconst itemDepth = $from.depth - 1;\n\tif ($from.node(itemDepth).type !== editor.schema.nodes[name] || $from.index(itemDepth) !== 0) return false;\n\treturn editor.chain().liftListItem(name).run();\n};\n//#endregion\n//#region src/keymap/listHelpers/nextListIsDeeper.ts\nconst nextListIsDeeper = (typeOrName, state) => {\n\tconst listDepth = getNextListDepth(typeOrName, state);\n\tconst listItemPos = findListItemPos(typeOrName, state);\n\tif (!listItemPos || !listDepth) return false;\n\tif (listDepth > listItemPos.depth) return true;\n\treturn false;\n};\n//#endregion\n//#region src/keymap/listHelpers/nextListIsHigher.ts\nconst nextListIsHigher = (typeOrName, state) => {\n\tconst listDepth = getNextListDepth(typeOrName, state);\n\tconst listItemPos = findListItemPos(typeOrName, state);\n\tif (!listItemPos || !listDepth) return false;\n\tif (listDepth < listItemPos.depth) return true;\n\treturn false;\n};\n//#endregion\n//#region src/keymap/listHelpers/handleDelete.ts\nconst handleDelete = (editor, name) => {\n\tif (!(0, _tiptap_core.isNodeActive)(editor.state, name)) return false;\n\tif (!(0, _tiptap_core.isAtEndOfNode)(editor.state, name)) return false;\n\tconst { selection } = editor.state;\n\tconst { $from, $to } = selection;\n\tif (!selection.empty && $from.sameParent($to)) return false;\n\tif (nextListIsDeeper(name, editor.state)) return editor.chain().focus(editor.state.selection.from + 4).lift(name).joinBackward().run();\n\tif (nextListIsHigher(name, editor.state)) return editor.chain().joinForward().joinBackward().run();\n\treturn editor.commands.joinItemForward();\n};\n//#endregion\n//#region src/keymap/listHelpers/handleTab.ts\nconst handleTab = (editor, name, parentListTypes) => {\n\tconst { state } = editor;\n\tconst { selection } = state;\n\tif (!selection.empty) return false;\n\tconst { $from } = selection;\n\tif ($from.parentOffset !== 0) return false;\n\tif (!$from.parent.isTextblock) return false;\n\tif ((0, _tiptap_core.isNodeActive)(state, name)) return false;\n\tconst previous = (0, _tiptap_core.getPreviousBlockSibling)($from);\n\tif (!previous || !parentListTypes.includes(previous.type.name)) return false;\n\tconst lastItem = previous.lastChild;\n\tif (!lastItem || lastItem.type.name !== name) return false;\n\tconst block = $from.parent;\n\tif (!lastItem.canReplace(lastItem.childCount, lastItem.childCount, _tiptap_pm_model.Fragment.from(block))) return false;\n\tconst blockStart = $from.before();\n\tconst blockEnd = $from.after();\n\tconst insideLastItemEnd = blockStart - 2;\n\treturn editor.commands.command(({ tr, dispatch }) => {\n\t\tif (dispatch) {\n\t\t\ttr.delete(blockStart, blockEnd).insert(insideLastItemEnd, _tiptap_pm_model.Fragment.from(block));\n\t\t\ttr.setSelection(_tiptap_pm_state.TextSelection.create(tr.doc, insideLastItemEnd + 1));\n\t\t\ttr.scrollIntoView();\n\t\t}\n\t\treturn true;\n\t});\n};\n//#endregion\n//#region src/keymap/listHelpers/hasListItemAfter.ts\nconst hasListItemAfter = (typeOrName, state) => {\n\tvar _$targetPos$nodeAfter;\n\tconst { $anchor } = state.selection;\n\tconst $targetPos = state.doc.resolve($anchor.pos - $anchor.parentOffset - 2);\n\tif ($targetPos.index() === $targetPos.parent.childCount - 1) return false;\n\tif (((_$targetPos$nodeAfter = $targetPos.nodeAfter) === null || _$targetPos$nodeAfter === void 0 ? void 0 : _$targetPos$nodeAfter.type.name) !== typeOrName) return false;\n\treturn true;\n};\n//#endregion\n//#region src/keymap/listHelpers/hasListItemBefore.ts\nconst hasListItemBefore = (typeOrName, state) => {\n\tvar _$targetPos$nodeBefor;\n\tconst { $anchor } = state.selection;\n\tconst $targetPos = state.doc.resolve($anchor.pos - 2);\n\tif ($targetPos.index() === 0) return false;\n\tif (((_$targetPos$nodeBefor = $targetPos.nodeBefore) === null || _$targetPos$nodeBefor === void 0 ? void 0 : _$targetPos$nodeBefor.type.name) !== typeOrName) return false;\n\treturn true;\n};\n//#endregion\n//#region src/keymap/listHelpers/listItemHasSubList.ts\nconst listItemHasSubList = (typeOrName, state, node) => {\n\tif (!node) return false;\n\tconst nodeType = (0, _tiptap_core.getNodeType)(typeOrName, state.schema);\n\tlet hasSubList = false;\n\tnode.descendants((child) => {\n\t\tif (child.type === nodeType) hasSubList = true;\n\t});\n\treturn hasSubList;\n};\n//#endregion\n//#region src/keymap/listHelpers/index.ts\nvar listHelpers_exports = /* @__PURE__ */ __exportAll({\n\tfindListItemPos: () => findListItemPos,\n\tgetNextListDepth: () => getNextListDepth,\n\thandleBackspace: () => handleBackspace,\n\thandleDelete: () => handleDelete,\n\thandleTab: () => handleTab,\n\thasListBefore: () => hasListBefore,\n\thasListItemAfter: () => hasListItemAfter,\n\thasListItemBefore: () => hasListItemBefore,\n\tlistItemHasSubList: () => listItemHasSubList,\n\tnextListIsDeeper: () => nextListIsDeeper,\n\tnextListIsHigher: () => nextListIsHigher\n});\n//#endregion\n//#region src/keymap/list-keymap.ts\n/**\n* This extension registers custom keymaps to change the behaviour of the backspace and delete keys.\n* By default Prosemirror keyhandling will always lift or sink items so paragraphs are joined into\n* the adjacent or previous list item. This extension will prevent this behaviour and instead will\n* try to join paragraphs from two list items into a single list item.\n* @see https://www.tiptap.dev/api/extensions/list-keymap\n*/\nconst ListKeymap = _tiptap_core.Extension.create({\n\tname: \"listKeymap\",\n\taddOptions() {\n\t\treturn { listTypes: [{\n\t\t\titemName: \"listItem\",\n\t\t\twrapperNames: [\"bulletList\", \"orderedList\"]\n\t\t}, {\n\t\t\titemName: \"taskItem\",\n\t\t\twrapperNames: [\"taskList\"]\n\t\t}] };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\tDelete: ({ editor }) => {\n\t\t\t\tlet handled = false;\n\t\t\t\tthis.options.listTypes.forEach(({ itemName }) => {\n\t\t\t\t\tif (editor.state.schema.nodes[itemName] === void 0) return;\n\t\t\t\t\tif (handleDelete(editor, itemName)) handled = true;\n\t\t\t\t});\n\t\t\t\treturn handled;\n\t\t\t},\n\t\t\t\"Mod-Delete\": ({ editor }) => {\n\t\t\t\tlet handled = false;\n\t\t\t\tthis.options.listTypes.forEach(({ itemName }) => {\n\t\t\t\t\tif (editor.state.schema.nodes[itemName] === void 0) return;\n\t\t\t\t\tif (handleDelete(editor, itemName)) handled = true;\n\t\t\t\t});\n\t\t\t\treturn handled;\n\t\t\t},\n\t\t\tBackspace: ({ editor }) => {\n\t\t\t\tlet handled = false;\n\t\t\t\tthis.options.listTypes.forEach(({ itemName, wrapperNames }) => {\n\t\t\t\t\tif (editor.state.schema.nodes[itemName] === void 0) return;\n\t\t\t\t\tif (handleBackspace(editor, itemName, wrapperNames)) handled = true;\n\t\t\t\t});\n\t\t\t\treturn handled;\n\t\t\t},\n\t\t\t\"Mod-Backspace\": ({ editor }) => {\n\t\t\t\tlet handled = false;\n\t\t\t\tthis.options.listTypes.forEach(({ itemName, wrapperNames }) => {\n\t\t\t\t\tif (editor.state.schema.nodes[itemName] === void 0) return;\n\t\t\t\t\tif (handleBackspace(editor, itemName, wrapperNames)) handled = true;\n\t\t\t\t});\n\t\t\t\treturn handled;\n\t\t\t},\n\t\t\tTab: ({ editor }) => {\n\t\t\t\tfor (const { itemName, wrapperNames } of this.options.listTypes) {\n\t\t\t\t\tif (editor.state.schema.nodes[itemName] === void 0) continue;\n\t\t\t\t\tif (handleTab(editor, itemName, wrapperNames)) return true;\n\t\t\t\t}\n\t\t\t\treturn false;\n\t\t\t}\n\t\t};\n\t}\n});\n//#endregion\n//#region src/ordered-list/utils.ts\n/**\n* Matches an ordered list item line with optional leading whitespace.\n* Captures: (1) indentation spaces, (2) item marker (number, letter, or roman numeral),\n* (3) separator (. or )), (4) content after marker\n*\n* Examples: \"1. Item\", \" a) Nested item\", \" I. Roman item\", \"iii. Another\", \"aa. Item 27\"\n*/\nconst ORDERED_LIST_ITEM_REGEX = new RegExp(`^(\\\\s*)(${ORDERED_LIST_MARKER_PATTERN})([.)])\\\\s+(.*)$`);\n/**\n* Matches any line that starts with whitespace (indented content).\n* Used to identify continuation content that belongs to a list item.\n*/\nconst INDENTED_LINE_REGEX = /^\\s/;\n/**\n* This are blocks that can interrupt a paragraph, so a line starting with one of\n* them can never be lazy continuation text of a list item\n*/\nconst PARAGRAPH_INTERRUPTERS = {\n\theading: /^#{1,6}(?:\\s|$)/,\n\tbulletItem: /^[-+*]\\s+/,\n\tcodeFence: /^(?:```|~~~)/,\n\tblockMath: /^\\$\\$/,\n\tthematicBreak: /^(?:(?:-[ \\t]*){3,}|(?:_[ \\t]*){3,}|(?:\\*[ \\t]*){3,})$/\n};\nfunction isOrderedListMarkerLine(line) {\n\treturn ORDERED_LIST_ITEM_REGEX.test(line.trimStart());\n}\nfunction isBlockContentLine(line) {\n\tconst trimmedLine = line.trimStart();\n\treturn PARAGRAPH_INTERRUPTERS.bulletItem.test(trimmedLine) || isOrderedListMarkerLine(trimmedLine) || PARAGRAPH_INTERRUPTERS.heading.test(trimmedLine) || PARAGRAPH_INTERRUPTERS.thematicBreak.test(trimmedLine) && !trimmedLine.startsWith(\"-\") || /^>\\s?/.test(trimmedLine) || PARAGRAPH_INTERRUPTERS.codeFence.test(trimmedLine) || PARAGRAPH_INTERRUPTERS.blockMath.test(trimmedLine);\n}\nfunction interruptsLazyContinuation(line) {\n\treturn Object.values(PARAGRAPH_INTERRUPTERS).some((pattern) => pattern.test(line));\n}\nfunction splitItemContent(contentLines) {\n\tconst paragraphLines = [];\n\tconst blockLines = [];\n\tlet reachedBlockBoundary = false;\n\tcontentLines.forEach((line) => {\n\t\tif (reachedBlockBoundary) {\n\t\t\tblockLines.push(line);\n\t\t\treturn;\n\t\t}\n\t\tif (line.trim() === \"\") {\n\t\t\treachedBlockBoundary = true;\n\t\t\tblockLines.push(line);\n\t\t\treturn;\n\t\t}\n\t\tif (paragraphLines.length > 0 && isBlockContentLine(line)) {\n\t\t\treachedBlockBoundary = true;\n\t\t\tblockLines.push(line);\n\t\t\treturn;\n\t\t}\n\t\tparagraphLines.push(line);\n\t});\n\treturn {\n\t\tparagraphLines,\n\t\tblockLines\n\t};\n}\n/**\n* Collects all ordered list items from lines, parsing them into a flat array\n* with indentation information. Stops collecting continuation content when\n* encountering nested list items, allowing them to be processed separately.\n*\n* @param lines - Array of source lines to parse\n* @returns Tuple of [listItems array, number of lines consumed]\n*/\nfunction collectOrderedListItems(lines) {\n\tconst listItems = [];\n\tlet currentLineIndex = 0;\n\tlet consumed = 0;\n\twhile (currentLineIndex < lines.length) {\n\t\tconst line = lines[currentLineIndex];\n\t\tconst match = line.match(ORDERED_LIST_ITEM_REGEX);\n\t\tif (!match) break;\n\t\tconst [, indent, marker, _separator, content] = match;\n\t\tconst indentLevel = indent.length;\n\t\tconst number = parseInt(marker, 10);\n\t\tconst markerType = isNaN(number) ? detectMarkerType(marker) : void 0;\n\t\tconst itemNumber = isNaN(number) ? markerToStart(marker) : number;\n\t\tconst itemContentLines = [content];\n\t\tlet nextLineIndex = currentLineIndex + 1;\n\t\tconst itemLines = [line];\n\t\tlet sawBlankLine = false;\n\t\twhile (nextLineIndex < lines.length) {\n\t\t\tconst nextLine = lines[nextLineIndex];\n\t\t\tif (nextLine.match(ORDERED_LIST_ITEM_REGEX)) break;\n\t\t\tif (nextLine.trim() === \"\") {\n\t\t\t\titemLines.push(nextLine);\n\t\t\t\titemContentLines.push(\"\");\n\t\t\t\tsawBlankLine = true;\n\t\t\t\tnextLineIndex += 1;\n\t\t\t} else if (nextLine.match(INDENTED_LINE_REGEX)) {\n\t\t\t\tconst leadingWhitespace = nextLine.length - nextLine.trimStart().length;\n\t\t\t\tconst contentIndent = indentLevel + marker.length + 1;\n\t\t\t\titemLines.push(nextLine);\n\t\t\t\titemContentLines.push(nextLine.slice(Math.min(leadingWhitespace, contentIndent)));\n\t\t\t\tnextLineIndex += 1;\n\t\t\t} else {\n\t\t\t\tif (sawBlankLine || interruptsLazyContinuation(nextLine)) break;\n\t\t\t\titemLines.push(nextLine);\n\t\t\t\titemContentLines.push(nextLine);\n\t\t\t\tnextLineIndex += 1;\n\t\t\t}\n\t\t}\n\t\tlistItems.push({\n\t\t\tindent: indentLevel,\n\t\t\tnumber: itemNumber,\n\t\t\ttype: markerType,\n\t\t\tcontent: itemContentLines.join(\"\\n\").trim(),\n\t\t\tcontentLines: itemContentLines,\n\t\t\traw: itemLines.join(\"\\n\")\n\t\t});\n\t\tconsumed = nextLineIndex;\n\t\tcurrentLineIndex = nextLineIndex;\n\t}\n\treturn [listItems, consumed];\n}\nconst PLAIN_TEXT_ORDERED_LIST_LINE_REGEX = new RegExp(`^(${ORDERED_LIST_MARKER_PATTERN})([.)])\\\\s+(.+)$`);\n/**\n* Parse plain-text pasted ordered list lines into JSONContent, or null if not a typed list.\n*/\nfunction parsePlainTextOrderedListPaste(text) {\n\tconst lines = text.split(\"\\n\").filter((l) => l.trim().length > 0);\n\tif (lines.length === 0) return null;\n\tconst parsedItems = [];\n\tfor (const line of lines) {\n\t\tconst match = line.trim().match(PLAIN_TEXT_ORDERED_LIST_LINE_REGEX);\n\t\tif (!match) return null;\n\t\tparsedItems.push({\n\t\t\tmarker: match[1],\n\t\t\tcontent: match[3]\n\t\t});\n\t}\n\tif (!areOrderedListMarkersSequential(parsedItems.map((item) => item.marker))) return null;\n\treturn {\n\t\ttype: \"orderedList\",\n\t\tattrs: buildOrderedListAttrsFromMarker(parsedItems[0].marker),\n\t\tcontent: parsedItems.map((item) => ({\n\t\t\ttype: \"listItem\",\n\t\t\tcontent: [{\n\t\t\t\ttype: \"paragraph\",\n\t\t\t\tcontent: [{\n\t\t\t\t\ttype: \"text\",\n\t\t\t\t\ttext: item.content\n\t\t\t\t}]\n\t\t\t}]\n\t\t}))\n\t};\n}\n/**\n* Recursively builds a nested structure from a flat array of list items\n* based on their indentation levels. Creates proper markdown tokens with\n* nested lists where appropriate.\n*\n* @param items - Flat array of list items with indentation info\n* @param baseIndent - The indentation level to process at this recursion level\n* @param lexer - Markdown lexer for parsing inline and block content\n* @returns Array of list_item tokens with proper nesting\n*/\nfunction buildNestedStructure(items, baseIndent, lexer) {\n\tconst result = [];\n\tlet currentIndex = 0;\n\twhile (currentIndex < items.length) {\n\t\tconst item = items[currentIndex];\n\t\tif (item.indent === baseIndent) {\n\t\t\tconst { paragraphLines, blockLines } = splitItemContent(item.contentLines);\n\t\t\tconst mainText = paragraphLines.join(\"\\n\").trim();\n\t\t\tconst tokens = [];\n\t\t\tif (mainText) tokens.push({\n\t\t\t\ttype: \"paragraph\",\n\t\t\t\traw: mainText,\n\t\t\t\ttokens: lexer.inlineTokens(mainText)\n\t\t\t});\n\t\t\tconst additionalContent = blockLines.join(\"\\n\").trim();\n\t\t\tif (additionalContent) {\n\t\t\t\tconst blockTokens = lexer.blockTokens(additionalContent);\n\t\t\t\ttokens.push(...blockTokens);\n\t\t\t}\n\t\t\tlet lookAheadIndex = currentIndex + 1;\n\t\t\tconst nestedItems = [];\n\t\t\twhile (lookAheadIndex < items.length && items[lookAheadIndex].indent > baseIndent) {\n\t\t\t\tnestedItems.push(items[lookAheadIndex]);\n\t\t\t\tlookAheadIndex += 1;\n\t\t\t}\n\t\t\tif (nestedItems.length > 0) {\n\t\t\t\tconst nestedListItems = buildNestedStructure(nestedItems, Math.min(...nestedItems.map((nestedItem) => nestedItem.indent)), lexer);\n\t\t\t\ttokens.push({\n\t\t\t\t\ttype: \"list\",\n\t\t\t\t\tordered: true,\n\t\t\t\t\tstart: nestedItems[0].number,\n\t\t\t\t\ttypeMarker: nestedItems[0].type,\n\t\t\t\t\titems: nestedListItems,\n\t\t\t\t\traw: nestedItems.map((nestedItem) => nestedItem.raw).join(\"\\n\")\n\t\t\t\t});\n\t\t\t}\n\t\t\tresult.push({\n\t\t\t\ttype: \"list_item\",\n\t\t\t\traw: item.raw,\n\t\t\t\ttokens\n\t\t\t});\n\t\t\tcurrentIndex = lookAheadIndex;\n\t\t} else currentIndex += 1;\n\t}\n\treturn result;\n}\n/**\n* Parses markdown list item tokens into Tiptap JSONContent structure,\n* ensuring text content is properly wrapped in paragraph nodes.\n*\n* @param items - Array of markdown tokens representing list items\n* @param helpers - Markdown parse helpers for recursive parsing\n* @returns Array of listItem JSONContent nodes\n*/\nfunction parseListItems(items, helpers) {\n\treturn items.map((item) => {\n\t\tif (item.type !== \"list_item\") return helpers.parseChildren([item])[0];\n\t\tconst content = [];\n\t\tif (item.tokens && item.tokens.length > 0) item.tokens.forEach((itemToken) => {\n\t\t\tif (itemToken.type === \"paragraph\" || itemToken.type === \"list\" || itemToken.type === \"blockquote\" || itemToken.type === \"code\") content.push(...helpers.parseChildren([itemToken]));\n\t\t\telse if (itemToken.type === \"text\" && itemToken.tokens) {\n\t\t\t\tconst inlineContent = helpers.parseChildren([itemToken]);\n\t\t\t\tcontent.push({\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: inlineContent\n\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tconst parsed = helpers.parseChildren([itemToken]);\n\t\t\t\tif (parsed.length > 0) content.push(...parsed);\n\t\t\t}\n\t\t});\n\t\treturn {\n\t\t\ttype: \"listItem\",\n\t\t\tcontent\n\t\t};\n\t});\n}\n//#endregion\n//#region src/ordered-list/ordered-list.ts\nconst ListItemName = \"listItem\";\nconst TextStyleName = \"textStyle\";\n/**\n* Matches an ordered list to a 1. on input (or any number followed by a dot).\n*/\nconst orderedListInputRegex = /^(\\d+)\\.\\s$/;\n/**\n* Maps CSS list-style-type values to HTML type attribute values.\n* Google Docs and Word often use CSS instead of the HTML type attribute.\n*/\nfunction cssListStyleTypeToHtmlType(style) {\n\tconst match = style.match(/list-style-type\\s*:\\s*([^;]+)/i);\n\tif (!match) return null;\n\tswitch (match[1].trim().toLowerCase()) {\n\t\tcase \"upper-roman\": return \"I\";\n\t\tcase \"lower-roman\": return \"i\";\n\t\tcase \"upper-alpha\":\n\t\tcase \"upper-latin\": return \"A\";\n\t\tcase \"lower-alpha\":\n\t\tcase \"lower-latin\": return \"a\";\n\t\tdefault: return null;\n\t}\n}\n/**\n* This extension allows you to create ordered lists.\n* This requires the ListItem extension\n* @see https://www.tiptap.dev/api/nodes/ordered-list\n* @see https://www.tiptap.dev/api/nodes/list-item\n*/\nconst OrderedList = _tiptap_core.Node.create({\n\tname: \"orderedList\",\n\taddOptions() {\n\t\treturn {\n\t\t\titemTypeName: \"listItem\",\n\t\t\tHTMLAttributes: {},\n\t\t\tkeepMarks: false,\n\t\t\tkeepAttributes: false\n\t\t};\n\t},\n\tgroup: \"block list\",\n\tcontent() {\n\t\treturn `${this.options.itemTypeName}+`;\n\t},\n\taddAttributes() {\n\t\treturn {\n\t\t\tstart: {\n\t\t\t\tdefault: 1,\n\t\t\t\tparseHTML: (element) => {\n\t\t\t\t\treturn element.hasAttribute(\"start\") ? parseInt(element.getAttribute(\"start\") || \"\", 10) : 1;\n\t\t\t\t}\n\t\t\t},\n\t\t\ttype: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML: (element) => {\n\t\t\t\t\tconst htmlType = element.getAttribute(\"type\");\n\t\t\t\t\tif (htmlType) return htmlType;\n\t\t\t\t\tconst style = element.getAttribute(\"style\");\n\t\t\t\t\tif (style) {\n\t\t\t\t\t\tconst mappedFromOl = cssListStyleTypeToHtmlType(style);\n\t\t\t\t\t\tif (mappedFromOl) return mappedFromOl;\n\t\t\t\t\t}\n\t\t\t\t\tconst firstLi = element.querySelector(\"li\");\n\t\t\t\t\tif (firstLi) {\n\t\t\t\t\t\tconst liStyle = firstLi.getAttribute(\"style\");\n\t\t\t\t\t\tif (liStyle) {\n\t\t\t\t\t\t\tconst mappedFromLi = cssListStyleTypeToHtmlType(liStyle);\n\t\t\t\t\t\t\tif (mappedFromLi) return mappedFromLi;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t},\n\tparseHTML() {\n\t\treturn [{ tag: \"ol\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\tconst { start, type, ...attributesWithoutType } = HTMLAttributes;\n\t\tconst attrs = (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, attributesWithoutType);\n\t\tif (start !== 1) attrs.start = start;\n\t\tif (type && type !== \"1\") attrs.type = type;\n\t\treturn [\n\t\t\t\"ol\",\n\t\t\tattrs,\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"list\",\n\tparseMarkdown: (token, helpers) => {\n\t\tif (token.type !== \"list\" || !token.ordered) return [];\n\t\tconst startValue = token.start || 1;\n\t\tconst typeValue = token.typeMarker;\n\t\tconst content = token.items ? parseListItems(token.items, helpers) : [];\n\t\tconst attrs = {};\n\t\tif (startValue !== 1) attrs.start = startValue;\n\t\tif (typeValue) attrs.type = typeValue;\n\t\tif (Object.keys(attrs).length > 0) return {\n\t\t\ttype: \"orderedList\",\n\t\t\tattrs,\n\t\t\tcontent\n\t\t};\n\t\treturn {\n\t\t\ttype: \"orderedList\",\n\t\t\tcontent\n\t\t};\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\treturn h.renderChildren(node.content, \"\\n\");\n\t},\n\tmarkdownTokenizer: {\n\t\tname: \"orderedList\",\n\t\tlevel: \"block\",\n\t\tstart: () => -1,\n\t\ttokenize: (src, _tokens, lexer) => {\n\t\t\tvar _listItems$, _listItems$2;\n\t\t\tconst lines = src.split(\"\\n\");\n\t\t\tconst [listItems, consumed] = collectOrderedListItems(lines);\n\t\t\tif (listItems.length === 0) return;\n\t\t\tconst items = buildNestedStructure(listItems, listItems[0].indent, lexer);\n\t\t\tif (items.length === 0) return;\n\t\t\treturn {\n\t\t\t\ttype: \"list\",\n\t\t\t\tordered: true,\n\t\t\t\tstart: ((_listItems$ = listItems[0]) === null || _listItems$ === void 0 ? void 0 : _listItems$.number) || 1,\n\t\t\t\ttypeMarker: (_listItems$2 = listItems[0]) === null || _listItems$2 === void 0 ? void 0 : _listItems$2.type,\n\t\t\t\titems,\n\t\t\t\traw: lines.slice(0, consumed).join(\"\\n\")\n\t\t\t};\n\t\t}\n\t},\n\tmarkdownOptions: { indentsContent: true },\n\taddCommands() {\n\t\treturn { toggleOrderedList: () => ({ commands, chain }) => {\n\t\t\tif (this.options.keepAttributes) return chain().toggleList(this.name, this.options.itemTypeName, this.options.keepMarks).updateAttributes(ListItemName, this.editor.getAttributes(TextStyleName)).run();\n\t\t\treturn commands.toggleList(this.name, this.options.itemTypeName, this.options.keepMarks);\n\t\t} };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-Shift-7\": () => this.editor.commands.toggleOrderedList() };\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({ props: { handlePaste: (view, event) => {\n\t\t\tvar _event$clipboardData, _event$clipboardData2;\n\t\t\tconst html = (_event$clipboardData = event.clipboardData) === null || _event$clipboardData === void 0 ? void 0 : _event$clipboardData.getData(\"text/html\");\n\t\t\tif (html === null || html === void 0 ? void 0 : html.trim()) return false;\n\t\t\tconst text = (_event$clipboardData2 = event.clipboardData) === null || _event$clipboardData2 === void 0 ? void 0 : _event$clipboardData2.getData(\"text/plain\");\n\t\t\tif (!text) return false;\n\t\t\tconst orderedListContent = parsePlainTextOrderedListPaste(text);\n\t\t\tif (!orderedListContent) return false;\n\t\t\ttry {\n\t\t\t\tconst orderedListNode = view.state.schema.nodeFromJSON(orderedListContent);\n\t\t\t\tconst tr = view.state.tr.replaceSelectionWith(orderedListNode);\n\t\t\t\tview.dispatch(tr);\n\t\t\t\treturn true;\n\t\t\t} catch {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t} } })];\n\t},\n\taddInputRules() {\n\t\tconst joinPredicate = (match, node) => {\n\t\t\treturn (!node.attrs.type || node.attrs.type === \"1\") && node.childCount + node.attrs.start === +match[1];\n\t\t};\n\t\tlet inputRule = (0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: orderedListInputRegex,\n\t\t\ttype: this.type,\n\t\t\tgetAttributes: (match) => ({ start: +match[1] }),\n\t\t\tjoinPredicate\n\t\t});\n\t\tif (this.options.keepMarks || this.options.keepAttributes) inputRule = (0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: orderedListInputRegex,\n\t\t\ttype: this.type,\n\t\t\tkeepMarks: this.options.keepMarks,\n\t\t\tkeepAttributes: this.options.keepAttributes,\n\t\t\tgetAttributes: (match) => ({\n\t\t\t\tstart: +match[1],\n\t\t\t\t...this.editor.getAttributes(TextStyleName)\n\t\t\t}),\n\t\t\tjoinPredicate,\n\t\t\teditor: this.editor\n\t\t});\n\t\treturn [inputRule];\n\t}\n});\n//#endregion\n//#region src/task-item/task-item.ts\n/**\n* Matches a task item to a - [ ] on input.\n*/\nconst inputRegex = /^\\s*(\\[([( |x])?\\])\\s$/;\n/**\n* Hides the checkbox label visually while keeping it in the accessibility tree.\n*/\nconst visuallyHiddenStyle = \"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0\";\nconst getCheckboxLabel = (node, checked, a11y) => {\n\tvar _a11y$checkboxLabel;\n\treturn (a11y === null || a11y === void 0 || (_a11y$checkboxLabel = a11y.checkboxLabel) === null || _a11y$checkboxLabel === void 0 ? void 0 : _a11y$checkboxLabel.call(a11y, node, checked)) || `Task item checkbox for ${node.textContent || \"empty task item\"}`;\n};\n/**\n* This extension allows you to create task items.\n* @see https://www.tiptap.dev/api/nodes/task-item\n*/\nconst TaskItem = _tiptap_core.Node.create({\n\tname: \"taskItem\",\n\taddOptions() {\n\t\treturn {\n\t\t\tnested: false,\n\t\t\tHTMLAttributes: {},\n\t\t\ttaskListTypeName: \"taskList\",\n\t\t\ta11y: void 0\n\t\t};\n\t},\n\tcontent() {\n\t\treturn this.options.nested ? \"paragraph block*\" : \"paragraph+\";\n\t},\n\tdefining: true,\n\taddAttributes() {\n\t\treturn { checked: {\n\t\t\tdefault: false,\n\t\t\tkeepOnSplit: false,\n\t\t\tparseHTML: (element) => {\n\t\t\t\tconst dataChecked = element.getAttribute(\"data-checked\");\n\t\t\t\treturn dataChecked === \"\" || dataChecked === \"true\";\n\t\t\t},\n\t\t\trenderHTML: (attributes) => ({ \"data-checked\": attributes.checked })\n\t\t} };\n\t},\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: `li[data-type=\"${this.name}\"]`,\n\t\t\tpriority: 51,\n\t\t\tcontentElement: (element) => {\n\t\t\t\tvar _element$querySelecto;\n\t\t\t\treturn (_element$querySelecto = element.querySelector(\"div\")) !== null && _element$querySelecto !== void 0 ? _element$querySelecto : element;\n\t\t\t}\n\t\t}];\n\t},\n\trenderHTML({ node, HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"li\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, { \"data-type\": this.name }),\n\t\t\t[\n\t\t\t\t\"label\",\n\t\t\t\t[\"input\", {\n\t\t\t\t\ttype: \"checkbox\",\n\t\t\t\t\tchecked: node.attrs.checked ? \"checked\" : null\n\t\t\t\t}],\n\t\t\t\t[\"span\"]\n\t\t\t],\n\t\t\t[\"div\", 0]\n\t\t];\n\t},\n\tparseMarkdown: (token, h) => {\n\t\tconst content = [];\n\t\tif (token.tokens && token.tokens.length > 0) content.push(h.createNode(\"paragraph\", {}, h.parseInline(token.tokens)));\n\t\telse if (token.text) content.push(h.createNode(\"paragraph\", {}, [h.createNode(\"text\", { text: token.text })]));\n\t\telse content.push(h.createNode(\"paragraph\", {}, []));\n\t\tif (token.nestedTokens && token.nestedTokens.length > 0) {\n\t\t\tconst nestedContent = h.parseChildren(token.nestedTokens);\n\t\t\tcontent.push(...nestedContent);\n\t\t}\n\t\treturn h.createNode(\"taskItem\", { checked: token.checked || false }, content);\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tvar _node$attrs;\n\t\tconst prefix = `- [${((_node$attrs = node.attrs) === null || _node$attrs === void 0 ? void 0 : _node$attrs.checked) ? \"x\" : \" \"}] `;\n\t\treturn (0, _tiptap_core.renderNestedMarkdownContent)(node, h, prefix);\n\t},\n\taddExtensions() {\n\t\tif (!this.options.nested) return [];\n\t\treturn [createBranchingListDeleteKeymap(this.name, [this.options.taskListTypeName])];\n\t},\n\taddKeyboardShortcuts() {\n\t\tconst shortcuts = {\n\t\t\tEnter: () => this.editor.commands.splitListItem(this.name),\n\t\t\t\"Shift-Tab\": () => this.editor.commands.liftListItem(this.name)\n\t\t};\n\t\tif (!this.options.nested) return shortcuts;\n\t\treturn {\n\t\t\t...shortcuts,\n\t\t\tTab: () => this.editor.commands.sinkListItem(this.name)\n\t\t};\n\t},\n\taddNodeView() {\n\t\treturn ({ node, HTMLAttributes, getPos, editor }) => {\n\t\t\tconst listItem = document.createElement(\"li\");\n\t\t\tconst checkboxWrapper = document.createElement(\"label\");\n\t\t\tconst checkboxStyler = document.createElement(\"span\");\n\t\t\tconst checkbox = document.createElement(\"input\");\n\t\t\tconst content = document.createElement(\"div\");\n\t\t\tcheckboxStyler.style.cssText = visuallyHiddenStyle;\n\t\t\tconst updateA11Y = (currentNode) => {\n\t\t\t\tconst label = getCheckboxLabel(currentNode, currentNode.attrs.checked, this.options.a11y);\n\t\t\t\tcheckbox.setAttribute(\"aria-label\", label);\n\t\t\t\tcheckboxStyler.textContent = label;\n\t\t\t};\n\t\t\tupdateA11Y(node);\n\t\t\tcheckboxWrapper.contentEditable = \"false\";\n\t\t\tcheckbox.type = \"checkbox\";\n\t\t\tcheckbox.addEventListener(\"mousedown\", (event) => event.preventDefault());\n\t\t\tcheckbox.addEventListener(\"change\", (event) => {\n\t\t\t\tif (!editor.isEditable && !this.options.onReadOnlyChecked) {\n\t\t\t\t\tcheckbox.checked = !checkbox.checked;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { checked } = event.target;\n\t\t\t\tif (editor.isEditable && typeof getPos === \"function\") editor.chain().focus(void 0, { scrollIntoView: false }).command(({ tr }) => {\n\t\t\t\t\tconst position = getPos();\n\t\t\t\t\tif (typeof position !== \"number\") return false;\n\t\t\t\t\tconst currentNode = tr.doc.nodeAt(position);\n\t\t\t\t\ttr.setNodeMarkup(position, void 0, {\n\t\t\t\t\t\t...currentNode === null || currentNode === void 0 ? void 0 : currentNode.attrs,\n\t\t\t\t\t\tchecked\n\t\t\t\t\t});\n\t\t\t\t\treturn true;\n\t\t\t\t}).run();\n\t\t\t\tif (!editor.isEditable && this.options.onReadOnlyChecked) {\n\t\t\t\t\tif (!this.options.onReadOnlyChecked(node, checked)) checkbox.checked = !checkbox.checked;\n\t\t\t\t}\n\t\t\t});\n\t\t\tObject.entries(this.options.HTMLAttributes).forEach(([key, value]) => {\n\t\t\t\tlistItem.setAttribute(key, value);\n\t\t\t});\n\t\t\tlistItem.dataset.checked = node.attrs.checked;\n\t\t\tcheckbox.checked = node.attrs.checked;\n\t\t\tcheckboxWrapper.append(checkbox, checkboxStyler);\n\t\t\tlistItem.append(checkboxWrapper, content);\n\t\t\tObject.entries(HTMLAttributes).forEach(([key, value]) => {\n\t\t\t\tlistItem.setAttribute(key, value);\n\t\t\t});\n\t\t\tlet prevRenderedAttributeKeys = new Set(Object.keys(HTMLAttributes));\n\t\t\treturn {\n\t\t\t\tdom: listItem,\n\t\t\t\tcontentDOM: content,\n\t\t\t\tupdate: (updatedNode) => {\n\t\t\t\t\tif (updatedNode.type !== this.type) return false;\n\t\t\t\t\tlistItem.dataset.checked = updatedNode.attrs.checked;\n\t\t\t\t\tcheckbox.checked = updatedNode.attrs.checked;\n\t\t\t\t\tupdateA11Y(updatedNode);\n\t\t\t\t\tconst extensionAttributes = editor.extensionManager.attributes;\n\t\t\t\t\tconst newHTMLAttributes = (0, _tiptap_core.getRenderedAttributes)(updatedNode, extensionAttributes);\n\t\t\t\t\tconst newKeys = new Set(Object.keys(newHTMLAttributes));\n\t\t\t\t\tconst staticAttrs = this.options.HTMLAttributes;\n\t\t\t\t\tprevRenderedAttributeKeys.forEach((key) => {\n\t\t\t\t\t\tif (!newKeys.has(key)) {\n\t\t\t\t\t\t\tif (key in staticAttrs) listItem.setAttribute(key, staticAttrs[key]);\n\t\t\t\t\t\t\telse listItem.removeAttribute(key);\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t\tObject.entries(newHTMLAttributes).forEach(([key, value]) => {\n\t\t\t\t\t\tif (value === null || value === void 0) {\n\t\t\t\t\t\t\tif (key in staticAttrs) listItem.setAttribute(key, staticAttrs[key]);\n\t\t\t\t\t\t\telse listItem.removeAttribute(key);\n\t\t\t\t\t\t} else listItem.setAttribute(key, value);\n\t\t\t\t\t});\n\t\t\t\t\tprevRenderedAttributeKeys = newKeys;\n\t\t\t\t\treturn true;\n\t\t\t\t}\n\t\t\t};\n\t\t};\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.wrappingInputRule)({\n\t\t\tfind: inputRegex,\n\t\t\ttype: this.type,\n\t\t\tgetAttributes: (match) => ({ checked: match[match.length - 1] === \"x\" })\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/task-list/task-list.ts\n/**\n* This extension allows you to create task lists.\n* @see https://www.tiptap.dev/api/nodes/task-list\n*/\nconst TaskList = _tiptap_core.Node.create({\n\tname: \"taskList\",\n\taddOptions() {\n\t\treturn {\n\t\t\titemTypeName: \"taskItem\",\n\t\t\tHTMLAttributes: {}\n\t\t};\n\t},\n\tgroup: \"block list\",\n\tcontent() {\n\t\treturn `${this.options.itemTypeName}+`;\n\t},\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: `ul[data-type=\"${this.name}\"]`,\n\t\t\tpriority: 51\n\t\t}];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"ul\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, { \"data-type\": this.name }),\n\t\t\t0\n\t\t];\n\t},\n\tparseMarkdown: (token, h) => {\n\t\treturn h.createNode(\"taskList\", {}, h.parseChildren(token.items || []));\n\t},\n\trenderMarkdown: (node, h) => {\n\t\tif (!node.content) return \"\";\n\t\treturn h.renderChildren(node.content, \"\\n\");\n\t},\n\tmarkdownTokenizer: {\n\t\tname: \"taskList\",\n\t\tlevel: \"block\",\n\t\tstart(src) {\n\t\t\tvar _src$match;\n\t\t\tconst index = (_src$match = src.match(/^\\s*[-+*]\\s+\\[([ xX])\\]\\s+/)) === null || _src$match === void 0 ? void 0 : _src$match.index;\n\t\t\treturn index !== void 0 ? index : -1;\n\t\t},\n\t\ttokenize(src, tokens, lexer) {\n\t\t\tconst parseTaskListContent = (content) => {\n\t\t\t\tconst nestedResult = (0, _tiptap_core.parseIndentedBlocks)(content, {\n\t\t\t\t\titemPattern: /^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,\n\t\t\t\t\textractItemData: (match) => ({\n\t\t\t\t\t\tindentLevel: match[1].length,\n\t\t\t\t\t\tmainContent: match[4],\n\t\t\t\t\t\tchecked: match[3].toLowerCase() === \"x\"\n\t\t\t\t\t}),\n\t\t\t\t\tcreateToken: (data, nestedTokens) => ({\n\t\t\t\t\t\ttype: \"taskItem\",\n\t\t\t\t\t\traw: \"\",\n\t\t\t\t\t\tmainContent: data.mainContent,\n\t\t\t\t\t\tindentLevel: data.indentLevel,\n\t\t\t\t\t\tchecked: data.checked,\n\t\t\t\t\t\ttext: data.mainContent,\n\t\t\t\t\t\ttokens: lexer.inlineTokens(data.mainContent),\n\t\t\t\t\t\tnestedTokens\n\t\t\t\t\t}),\n\t\t\t\t\tcustomNestedParser: parseTaskListContent\n\t\t\t\t}, lexer);\n\t\t\t\tif (nestedResult) {\n\t\t\t\t\tconst taskListToken = {\n\t\t\t\t\t\ttype: \"taskList\",\n\t\t\t\t\t\traw: nestedResult.raw,\n\t\t\t\t\t\titems: nestedResult.items\n\t\t\t\t\t};\n\t\t\t\t\tconst remainder = content.slice(nestedResult.raw.length);\n\t\t\t\t\tif (remainder.trim()) return [taskListToken, ...lexer.blockTokens(remainder)];\n\t\t\t\t\treturn [taskListToken];\n\t\t\t\t}\n\t\t\t\treturn lexer.blockTokens(content);\n\t\t\t};\n\t\t\tconst result = (0, _tiptap_core.parseIndentedBlocks)(src, {\n\t\t\t\titemPattern: /^(\\s*)([-+*])\\s+\\[([ xX])\\]\\s+(.*)$/,\n\t\t\t\textractItemData: (match) => ({\n\t\t\t\t\tindentLevel: match[1].length,\n\t\t\t\t\tmainContent: match[4],\n\t\t\t\t\tchecked: match[3].toLowerCase() === \"x\"\n\t\t\t\t}),\n\t\t\t\tcreateToken: (data, nestedTokens) => ({\n\t\t\t\t\ttype: \"taskItem\",\n\t\t\t\t\traw: \"\",\n\t\t\t\t\tmainContent: data.mainContent,\n\t\t\t\t\tindentLevel: data.indentLevel,\n\t\t\t\t\tchecked: data.checked,\n\t\t\t\t\ttext: data.mainContent,\n\t\t\t\t\ttokens: lexer.inlineTokens(data.mainContent),\n\t\t\t\t\tnestedTokens\n\t\t\t\t}),\n\t\t\t\tcustomNestedParser: parseTaskListContent\n\t\t\t}, lexer);\n\t\t\tif (!result) return;\n\t\t\treturn {\n\t\t\t\ttype: \"taskList\",\n\t\t\t\traw: result.raw,\n\t\t\t\titems: result.items\n\t\t\t};\n\t\t}\n\t},\n\tmarkdownOptions: { indentsContent: true },\n\taddCommands() {\n\t\treturn { toggleTaskList: () => ({ commands }) => {\n\t\t\treturn commands.toggleList(this.name, this.options.itemTypeName);\n\t\t} };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-Shift-9\": () => this.editor.commands.toggleTaskList() };\n\t}\n});\n//#endregion\n//#region src/kit/index.ts\n/**\n* The table kit is a collection of table editor extensions.\n*\n* It’s a good starting point for building your own table in Tiptap.\n*/\nconst ListKit = _tiptap_core.Extension.create({\n\tname: \"listKit\",\n\taddExtensions() {\n\t\tconst extensions = [];\n\t\tif (this.options.bulletList !== false) extensions.push(BulletList.configure(this.options.bulletList));\n\t\tif (this.options.listItem !== false) extensions.push(ListItem.configure(this.options.listItem));\n\t\tif (this.options.listKeymap !== false) extensions.push(ListKeymap.configure(this.options.listKeymap));\n\t\tif (this.options.orderedList !== false) extensions.push(OrderedList.configure(this.options.orderedList));\n\t\tif (this.options.taskItem !== false) extensions.push(TaskItem.configure(this.options.taskItem));\n\t\tif (this.options.taskList !== false) extensions.push(TaskList.configure(this.options.taskList));\n\t\treturn extensions;\n\t}\n});\n//#endregion\nexports.BulletList = BulletList;\nexports.ListItem = ListItem;\nexports.ListKeymap = ListKeymap;\nexports.ListKit = ListKit;\nexports.ORDERED_LIST_MARKER_PATTERN = ORDERED_LIST_MARKER_PATTERN;\nexports.OrderedList = OrderedList;\nexports.TaskItem = TaskItem;\nexports.TaskList = TaskList;\nexports.areOrderedListMarkersSequential = areOrderedListMarkersSequential;\nexports.buildOrderedListAttrsFromMarker = buildOrderedListAttrsFromMarker;\nexports.bulletListInputRegex = bulletListInputRegex;\nexports.detectMarkerType = detectMarkerType;\nexports.getListMarker = getListMarker;\nexports.inputRegex = inputRegex;\nObject.defineProperty(exports, \"listHelpers\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn listHelpers_exports;\n\t}\n});\nexports.markerToStart = markerToStart;\nexports.orderedListInputRegex = orderedListInputRegex;\nexports.parseListMarker = parseListMarker;\nexports.parsePlainTextOrderedListPaste = parsePlainTextOrderedListPaste;\nexports.toRoman = toRoman;\nexports.toRomanUpper = toRomanUpper;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/paragraph.ts\n/**\n* Markdown marker for empty paragraphs to preserve blank lines.\n* Using &nbsp; (non-breaking space HTML entity) ensures the paragraph\n* is not collapsed by markdown parsers while remaining human-readable.\n*/\nconst EMPTY_PARAGRAPH_MARKDOWN = \"&nbsp;\";\n/**\n* Unicode character for non-breaking space (U+00A0).\n* Some markdown parsers may convert &nbsp; entities to this literal character.\n*/\nconst NBSP_CHAR = \"\\xA0\";\n/**\n* This extension allows you to create paragraphs.\n* @see https://www.tiptap.dev/api/nodes/paragraph\n*/\nconst Paragraph = _tiptap_core.Node.create({\n\tname: \"paragraph\",\n\tpriority: 1e3,\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tgroup: \"block\",\n\tcontent: \"inline*\",\n\tparseHTML() {\n\t\treturn [{ tag: \"p\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"p\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tparseMarkdown: (token, helpers) => {\n\t\tconst tokens = token.tokens || [];\n\t\tif (tokens.length === 1 && tokens[0].type === \"image\") return helpers.parseChildren([tokens[0]]);\n\t\tconst content = helpers.parseInline(tokens);\n\t\tif (tokens.length === 1 && tokens[0].type === \"text\" && (tokens[0].raw === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].text === EMPTY_PARAGRAPH_MARKDOWN || tokens[0].raw === NBSP_CHAR || tokens[0].text === NBSP_CHAR) && content.length === 1 && content[0].type === \"text\" && (content[0].text === EMPTY_PARAGRAPH_MARKDOWN || content[0].text === NBSP_CHAR)) return helpers.createNode(\"paragraph\", void 0, []);\n\t\treturn helpers.createNode(\"paragraph\", void 0, content);\n\t},\n\trenderMarkdown: (node, h, ctx) => {\n\t\tif (!node) return \"\";\n\t\tconst content = Array.isArray(node.content) ? node.content : [];\n\t\tif (content.length === 0) {\n\t\t\tvar _ctx$previousNode, _ctx$previousNode2;\n\t\t\tconst previousContent = Array.isArray(ctx === null || ctx === void 0 || (_ctx$previousNode = ctx.previousNode) === null || _ctx$previousNode === void 0 ? void 0 : _ctx$previousNode.content) ? ctx.previousNode.content : [];\n\t\t\treturn (ctx === null || ctx === void 0 || (_ctx$previousNode2 = ctx.previousNode) === null || _ctx$previousNode2 === void 0 ? void 0 : _ctx$previousNode2.type) === \"paragraph\" && previousContent.length === 0 ? EMPTY_PARAGRAPH_MARKDOWN : \"\";\n\t\t}\n\t\treturn h.renderChildren(content);\n\t},\n\taddCommands() {\n\t\treturn { setParagraph: () => ({ commands }) => {\n\t\t\treturn commands.setNode(this.name);\n\t\t} };\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-Alt-0\": () => this.editor.commands.setParagraph() };\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Paragraph;\n//#endregion\nexports.Paragraph = Paragraph;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/strike.ts\n/**\n* Matches a strike to a ~~strike~~ on input.\n*/\nconst inputRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))$/;\n/**\n* Matches a strike to a ~~strike~~ on paste.\n*/\nconst pasteRegex = /(?:^|\\s)(~~(?!\\s+~~)((?:[^~]+))~~(?!\\s+~~))/g;\n/**\n* This extension allows you to create strike text.\n* @see https://www.tiptap.dev/api/marks/strike\n*/\nconst Strike = _tiptap_core.Mark.create({\n\tname: \"strike\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tparseHTML() {\n\t\treturn [\n\t\t\t{ tag: \"s\" },\n\t\t\t{ tag: \"del\" },\n\t\t\t{ tag: \"strike\" },\n\t\t\t{\n\t\t\t\tstyle: \"text-decoration\",\n\t\t\t\tconsuming: false,\n\t\t\t\tgetAttrs: (style) => style.includes(\"line-through\") ? {} : false\n\t\t\t}\n\t\t];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"s\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tmarkdownTokenName: \"del\",\n\tparseMarkdown: (token, helpers) => {\n\t\treturn helpers.applyMark(\"strike\", helpers.parseInline(token.tokens || []));\n\t},\n\trenderMarkdown: (node, h) => {\n\t\treturn `~~${h.renderChildren(node)}~~`;\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetStrike: () => ({ commands }) => {\n\t\t\t\treturn commands.setMark(this.name);\n\t\t\t},\n\t\t\ttoggleStrike: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleMark(this.name);\n\t\t\t},\n\t\t\tunsetStrike: () => ({ commands }) => {\n\t\t\t\treturn commands.unsetMark(this.name);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn { \"Mod-Shift-s\": () => this.editor.commands.toggleStrike() };\n\t},\n\taddInputRules() {\n\t\treturn [(0, _tiptap_core.markInputRule)({\n\t\t\tfind: inputRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t},\n\taddPasteRules() {\n\t\treturn [(0, _tiptap_core.markPasteRule)({\n\t\t\tfind: pasteRegex,\n\t\t\ttype: this.type\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Strike;\n//#endregion\nexports.Strike = Strike;\nexports.default = src_default;\nexports.inputRegex = inputRegex;\nexports.pasteRegex = pasteRegex;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_extension_table = require(\"@tiptap/extension-table\");\n//#region src/index.ts\nvar src_default = _tiptap_extension_table.TableCell;\n//#endregion\nObject.defineProperty(exports, \"TableCell\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn _tiptap_extension_table.TableCell;\n\t}\n});\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_extension_table = require(\"@tiptap/extension-table\");\n//#region src/index.ts\nvar src_default = _tiptap_extension_table.TableHeader;\n//#endregion\nObject.defineProperty(exports, \"TableHeader\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn _tiptap_extension_table.TableHeader;\n\t}\n});\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_extension_table = require(\"@tiptap/extension-table\");\n//#region src/index.ts\nvar src_default = _tiptap_extension_table.TableRow;\n//#endregion\nObject.defineProperty(exports, \"TableRow\", {\n\tenumerable: true,\n\tget: function() {\n\t\treturn _tiptap_extension_table.TableRow;\n\t}\n});\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\nlet _tiptap_pm_tables = require(\"@tiptap/pm/tables\");\n//#region src/utils/parseAlign.ts\n/**\n* Normalize unknown input into a supported table alignment\n*\n* @param value - A potential alignment value\n* @returns A valid TableCellAlign value or null\n*/\nfunction normalizeTableCellAlign(value) {\n\tif (value === \"left\" || value === \"right\" || value === \"center\") return value;\n\treturn null;\n}\n/**\n* Parse table cell alignment from an HTML element\n*\n* Prefers inline style (${\"`\"}text-align${\"`\"}) and falls back to the legacy\n* ${\"`\"}align${\"`\"} attribute.\n*\n* @param element - The table cell/header DOM element\n* @returns A valid TableCellAlign value or null\n*/\nfunction parseAlign(element) {\n\tconst styleAlign = (element.style.textAlign || \"\").trim().toLowerCase();\n\tconst attrAlign = (element.getAttribute(\"align\") || \"\").trim().toLowerCase();\n\treturn normalizeTableCellAlign(styleAlign || attrAlign);\n}\n/**\n* Normalize alignment from a generic attrs object that may include an align field\n*\n* @param attributes - A node attrs-like object with an optional align field\n* @returns A valid TableCellAlign value or null.\n*/\nfunction normalizeTableCellAlignFromAttributes(attributes) {\n\treturn normalizeTableCellAlign(attributes === null || attributes === void 0 ? void 0 : attributes.align);\n}\n/**\n* Create a reusable Tiptap attribute config for table alignment\n*\n* @returns A Tiptap Attribute definition that parses and renders table alignment\n*/\nfunction createAlignAttribute() {\n\treturn {\n\t\tdefault: null,\n\t\tparseHTML: (element) => parseAlign(element),\n\t\trenderHTML: (attributes) => {\n\t\t\tif (!attributes.align) return {};\n\t\t\treturn { style: `text-align: ${attributes.align}` };\n\t\t}\n\t};\n}\n//#endregion\n//#region src/utils/parseColwidth.ts\n/**\n* reads the width of the `<col>` element matching a cell's column from the table's `<colgroup>`\n*\n* @param element - The table cell/header DOM element\n* @returns - An array with the column width in pixels or null\n*/\nfunction parseColgroupWidth(element) {\n\tvar _table$querySelectorA;\n\tconst row = element.parentElement;\n\tconst table = element.closest(\"table\");\n\tif (!row || !table) return null;\n\tconst cellIndex = Array.from(row.children).indexOf(element);\n\tconst width = (_table$querySelectorA = table.querySelectorAll(\"colgroup > col\")[cellIndex]) === null || _table$querySelectorA === void 0 ? void 0 : _table$querySelectorA.getAttribute(\"width\");\n\treturn width ? [parseInt(width, 10)] : null;\n}\n/**\n* Parse the column width/s of a table cell/header from an HTML element.\n* it prefers the `colwidth` attribute and if not-provided falls back to the `width` attribute\n* of the matching `<col>` element in the table's `<colgroup>`.\n*\n* @param element - The table cell/header DOM element\n* @returns - An array of column widths in pixels or null\n*/\nfunction parseColwidth(element) {\n\tconst colwidth = element.getAttribute(\"colwidth\");\n\tif (colwidth) return colwidth.split(\",\").map((width) => parseInt(width, 10));\n\treturn parseColgroupWidth(element);\n}\n//#endregion\n//#region src/utils/fillEmptyCellContent.ts\nconst COLLAPSIBLE_WHITESPACE = /[ \\t\\r\\n\\f]+/g;\n/** Whether a cell/header element has no child elements and only collapsible whitespace. */\nfunction isEmptyCellElement(element) {\n\tvar _element$textContent;\n\tif (element.children.length > 0) return false;\n\treturn ((_element$textContent = element.textContent) !== null && _element$textContent !== void 0 ? _element$textContent : \"\").replace(COLLAPSIBLE_WHITESPACE, \"\") === \"\";\n}\n/** Builds a cell/header's minimal `block+` content, derived from the node type. */\nfunction fillEmptyCellContent(cellType) {\n\tconst filled = cellType.createAndFill();\n\tif (!filled) throw new Error(`[tiptap error]: \"${cellType.name}\" has no default content to backfill.`);\n\treturn filled.content;\n}\n//#endregion\n//#region src/cell/table-cell.ts\n/**\n* This extension allows you to create table cells.\n* @see https://www.tiptap.dev/api/nodes/table-cell\n*/\nconst TableCell = _tiptap_core.Node.create({\n\tname: \"tableCell\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"block+\",\n\taddAttributes() {\n\t\treturn {\n\t\t\tcolspan: { default: 1 },\n\t\t\trowspan: { default: 1 },\n\t\t\tcolwidth: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML: parseColwidth\n\t\t\t},\n\t\t\talign: createAlignAttribute()\n\t\t};\n\t},\n\ttableRole: \"cell\",\n\tisolating: true,\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"td\",\n\t\t\tgetAttrs: (node) => isEmptyCellElement(node) ? {} : false,\n\t\t\tgetContent: (_node, schema) => fillEmptyCellContent(schema.nodes[this.name])\n\t\t}, { tag: \"td\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"td\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/header/table-header.ts\n/**\n* This extension allows you to create table headers.\n* @see https://www.tiptap.dev/api/nodes/table-header\n*/\nconst TableHeader = _tiptap_core.Node.create({\n\tname: \"tableHeader\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"block+\",\n\taddAttributes() {\n\t\treturn {\n\t\t\tcolspan: { default: 1 },\n\t\t\trowspan: { default: 1 },\n\t\t\tcolwidth: {\n\t\t\t\tdefault: null,\n\t\t\t\tparseHTML: parseColwidth\n\t\t\t},\n\t\t\talign: createAlignAttribute()\n\t\t};\n\t},\n\ttableRole: \"header_cell\",\n\tisolating: true,\n\tparseHTML() {\n\t\treturn [{\n\t\t\ttag: \"th\",\n\t\t\tgetAttrs: (node) => isEmptyCellElement(node) ? {} : false,\n\t\t\tgetContent: (_node, schema) => fillEmptyCellContent(schema.nodes[this.name])\n\t\t}, { tag: \"th\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"th\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/row/table-row.ts\n/**\n* This extension allows you to create table rows.\n* @see https://www.tiptap.dev/api/nodes/table-row\n*/\nconst TableRow = _tiptap_core.Node.create({\n\tname: \"tableRow\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tcontent: \"(tableCell | tableHeader)*\",\n\ttableRole: \"row\",\n\tparseHTML() {\n\t\treturn [{ tag: \"tr\" }];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"tr\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t}\n});\n//#endregion\n//#region src/table/utilities/colStyle.ts\nfunction getColStyleDeclaration(minWidth, width) {\n\tif (width) return [\"width\", `${Math.max(width, minWidth)}px`];\n\treturn [\"min-width\", `${minWidth}px`];\n}\n//#endregion\n//#region src/table/TableView.ts\nfunction updateColumns(node, colgroup, table, cellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tlet nextDOM = colgroup.firstChild;\n\tconst row = node.firstChild;\n\tif (row !== null) for (let i = 0, col = 0; i < row.childCount; i += 1) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j += 1, col += 1) {\n\t\t\tconst hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];\n\t\t\tconst cssWidth = hasWidth ? `${hasWidth}px` : \"\";\n\t\t\ttotalWidth += hasWidth || cellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tif (!nextDOM) {\n\t\t\t\tconst colElement = document.createElement(\"col\");\n\t\t\t\tconst [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\t\tcolElement.style.setProperty(propertyKey, propertyValue);\n\t\t\t\tcolgroup.appendChild(colElement);\n\t\t\t} else {\n\t\t\t\tif (nextDOM.style.width !== cssWidth) {\n\t\t\t\t\tconst [propertyKey, propertyValue] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\t\t\tnextDOM.style.setProperty(propertyKey, propertyValue);\n\t\t\t\t}\n\t\t\t\tnextDOM = nextDOM.nextSibling;\n\t\t\t}\n\t\t}\n\t}\n\twhile (nextDOM) {\n\t\tvar _nextDOM$parentNode;\n\t\tconst after = nextDOM.nextSibling;\n\t\t(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);\n\t\tnextDOM = after;\n\t}\n\tconst hasUserWidth = node.attrs.style && typeof node.attrs.style === \"string\" && /\\bwidth\\s*:/i.test(node.attrs.style);\n\tif (fixedWidth && !hasUserWidth) {\n\t\ttable.style.width = `${totalWidth}px`;\n\t\ttable.style.minWidth = \"\";\n\t} else {\n\t\ttable.style.width = \"\";\n\t\ttable.style.minWidth = `${totalWidth}px`;\n\t}\n}\nvar TableView = class {\n\tconstructor(node, cellMinWidth, _view, HTMLAttributes = {}) {\n\t\tthis.node = node;\n\t\tthis.cellMinWidth = cellMinWidth;\n\t\tthis.dom = document.createElement(\"div\");\n\t\tthis.dom.className = \"tableWrapper\";\n\t\tthis.table = this.dom.appendChild(document.createElement(\"table\"));\n\t\tfor (const [key, value] of Object.entries(HTMLAttributes)) if (value !== void 0 && value !== null) {\n\t\t\tif (key === \"style\") this.table.style.cssText = String(value);\n\t\t\telse this.table.setAttribute(key, String(value));\n\t\t}\n\t\tif (node.attrs.style) this.table.style.cssText = node.attrs.style;\n\t\tthis.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n\t\tupdateColumns(node, this.colgroup, this.table, cellMinWidth);\n\t\tthis.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n\t}\n\tupdate(node) {\n\t\tif (node.type !== this.node.type) return false;\n\t\tthis.node = node;\n\t\tupdateColumns(node, this.colgroup, this.table, this.cellMinWidth);\n\t\treturn true;\n\t}\n\tignoreMutation(mutation) {\n\t\tconst target = mutation.target;\n\t\tconst isInsideWrapper = this.dom.contains(target);\n\t\tconst isInsideContent = this.contentDOM.contains(target);\n\t\tif (isInsideWrapper && !isInsideContent) {\n\t\t\tif (mutation.type === \"attributes\" || mutation.type === \"childList\" || mutation.type === \"characterData\") return true;\n\t\t}\n\t\treturn false;\n\t}\n};\n//#endregion\n//#region src/table/utilities/createColGroup.ts\nfunction createColGroup(node, cellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tconst cols = [];\n\tconst row = node.firstChild;\n\tif (!row) return {};\n\tfor (let i = 0, col = 0; i < row.childCount; i += 1) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j += 1, col += 1) {\n\t\t\tconst hasWidth = overrideCol === col ? overrideValue : colwidth && colwidth[j];\n\t\t\ttotalWidth += hasWidth || cellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tconst [property, value] = getColStyleDeclaration(cellMinWidth, hasWidth);\n\t\t\tcols.push([\"col\", { style: `${property}: ${value}` }]);\n\t\t}\n\t}\n\tconst tableWidth = fixedWidth ? `${totalWidth}px` : \"\";\n\tconst tableMinWidth = fixedWidth ? \"\" : `${totalWidth}px`;\n\treturn {\n\t\tcolgroup: [\n\t\t\t\"colgroup\",\n\t\t\t{},\n\t\t\t...cols\n\t\t],\n\t\ttableWidth,\n\t\ttableMinWidth\n\t};\n}\n//#endregion\n//#region src/table/utilities/createCell.ts\nfunction createCell(cellType, cellContent) {\n\tif (cellContent) return cellType.createChecked(null, cellContent);\n\treturn cellType.createAndFill();\n}\n//#endregion\n//#region src/table/utilities/getTableNodeTypes.ts\nfunction getTableNodeTypes(schema) {\n\tif (schema.cached.tableNodeTypes) return schema.cached.tableNodeTypes;\n\tconst roles = {};\n\tObject.keys(schema.nodes).forEach((type) => {\n\t\tconst nodeType = schema.nodes[type];\n\t\tif (nodeType.spec.tableRole) roles[nodeType.spec.tableRole] = nodeType;\n\t});\n\tschema.cached.tableNodeTypes = roles;\n\treturn roles;\n}\n//#endregion\n//#region src/table/utilities/createTable.ts\nfunction createTable(schema, rowsCount, colsCount, withHeaderRow, cellContent) {\n\tconst types = getTableNodeTypes(schema);\n\tconst headerCells = [];\n\tconst cells = [];\n\tfor (let index = 0; index < colsCount; index += 1) {\n\t\tconst cell = createCell(types.cell, cellContent);\n\t\tif (cell) cells.push(cell);\n\t\tif (withHeaderRow) {\n\t\t\tconst headerCell = createCell(types.header_cell, cellContent);\n\t\t\tif (headerCell) headerCells.push(headerCell);\n\t\t}\n\t}\n\tconst rows = [];\n\tfor (let index = 0; index < rowsCount; index += 1) rows.push(types.row.createChecked(null, withHeaderRow && index === 0 ? headerCells : cells));\n\treturn types.table.createChecked(null, rows);\n}\n//#endregion\n//#region src/table/utilities/isCellSelection.ts\nfunction isCellSelection(value) {\n\treturn value instanceof _tiptap_pm_tables.CellSelection;\n}\n//#endregion\n//#region src/table/utilities/deleteTableWhenAllCellsSelected.ts\nconst deleteTableWhenAllCellsSelected = ({ editor }) => {\n\tconst { selection } = editor.state;\n\tif (!isCellSelection(selection)) return false;\n\tlet cellCount = 0;\n\tconst table = (0, _tiptap_core.findParentNodeClosestToPos)(selection.ranges[0].$from, (node) => {\n\t\treturn node.type.name === \"table\";\n\t});\n\ttable === null || table === void 0 || table.node.descendants((node) => {\n\t\tif (node.type.name === \"table\") return false;\n\t\tif ([\"tableCell\", \"tableHeader\"].includes(node.type.name)) cellCount += 1;\n\t});\n\tif (!(cellCount === selection.ranges.length)) return false;\n\teditor.commands.deleteTable();\n\treturn true;\n};\n//#endregion\n//#region src/table/utilities/keepCursorInTable.ts\nfunction keepCursorInTable(tr, tablePos) {\n\tconst mappedTablePos = tr.mapping.map(tablePos);\n\tconst stillInTable = (0, _tiptap_core.findParentNodeClosestToPos)(tr.selection.$from, (node) => node.type.name === \"table\");\n\tif ((stillInTable === null || stillInTable === void 0 ? void 0 : stillInTable.pos) === mappedTablePos) return;\n\tconst tableNode = tr.doc.nodeAt(mappedTablePos);\n\tif (!tableNode) return;\n\tconst endOfTable = mappedTablePos + tableNode.nodeSize - 1;\n\ttr.setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(endOfTable), -1));\n}\n//#endregion\n//#region src/table/utilities/markdown.ts\nconst DEFAULT_CELL_LINE_SEPARATOR = \"\u001f\";\n/**\n* Walk a single table-row line and escape any `|` characters that appear\n* inside backtick code spans so marked's cell splitter ignores them.\n* Backslash escape sequences outside code spans are passed through untouched.\n* If a backtick run has no matching closer on the same line it is emitted\n* as-is — no over-escaping for malformed input.\n*/\nfunction escapeTableCellPipes(line) {\n\tlet result = \"\";\n\tlet i = 0;\n\twhile (i < line.length) {\n\t\tif (line[i] === \"\\\\\" && i + 1 < line.length) {\n\t\t\tresult += line[i] + line[i + 1];\n\t\t\ti += 2;\n\t\t\tcontinue;\n\t\t}\n\t\tif (line[i] !== \"`\") {\n\t\t\tresult += line[i++];\n\t\t\tcontinue;\n\t\t}\n\t\tlet runLen = 0;\n\t\twhile (i + runLen < line.length && line[i + runLen] === \"`\") runLen += 1;\n\t\tlet j = i + runLen;\n\t\tlet found = false;\n\t\twhile (j < line.length) {\n\t\t\tif (line[j] !== \"`\") {\n\t\t\t\tj += 1;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tlet closeLen = 0;\n\t\t\twhile (j + closeLen < line.length && line[j + closeLen] === \"`\") closeLen += 1;\n\t\t\tif (closeLen === runLen) {\n\t\t\t\tconst spanContent = line.slice(i + runLen, j);\n\t\t\t\tresult += line.slice(i, i + runLen) + spanContent.replace(/\\\\\\||\\|/g, (match) => match === \"|\" ? \"\\\\|\" : match) + line.slice(j, j + runLen);\n\t\t\t\ti = j + runLen;\n\t\t\t\tfound = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tj += closeLen;\n\t\t}\n\t\tif (!found) {\n\t\t\tresult += line.slice(i, i + runLen);\n\t\t\ti += runLen;\n\t\t}\n\t}\n\treturn result;\n}\n/**\n* Escape pipe characters inside backtick code spans on table-row lines.\n* marked's `splitCells` only recognises backslash-escaped pipes (`\\|`) and\n* splits on every other `|`, so \\`a || b\\` in a table cell would be treated\n* as multiple column delimiters. Escaping them here lets `splitCells` skip\n* them; it already converts `\\|` → `|` after splitting, so the cell content\n* is restored correctly.\n*/\nfunction preprocessTablePipes(src) {\n\treturn src.split(\"\\n\").map((line) => {\n\t\tif (!line.includes(\"|\") || !line.includes(\"`\")) return line;\n\t\treturn escapeTableCellPipes(line);\n\t}).join(\"\\n\");\n}\nfunction collapseWhitespace(s) {\n\treturn (s || \"\").replace(/\\s+/g, \" \").trim();\n}\nfunction renderTableToMarkdown(node, h, options = {}) {\n\tvar _options$cellLineSepa;\n\tconst cellSep = (_options$cellLineSepa = options.cellLineSeparator) !== null && _options$cellLineSepa !== void 0 ? _options$cellLineSepa : \"\u001f\";\n\tif (!node || !node.content || node.content.length === 0) return \"\";\n\tconst rows = [];\n\tnode.content.forEach((rowNode) => {\n\t\tconst cells = [];\n\t\tif (rowNode.content) rowNode.content.forEach((cellNode) => {\n\t\t\tlet raw = \"\";\n\t\t\tif (cellNode.content && Array.isArray(cellNode.content) && cellNode.content.length > 1) raw = cellNode.content.map((child) => h.renderChildren(child)).join(cellSep);\n\t\t\telse raw = cellNode.content ? h.renderChildren(cellNode.content) : \"\";\n\t\t\tconst text = collapseWhitespace(raw.split(cellSep).join(\"\\n\").replace(/[ \\t]*\\r?\\n[ \\t]*/g, \"<br>\"));\n\t\t\tconst isHeader = cellNode.type === \"tableHeader\";\n\t\t\tconst align = normalizeTableCellAlignFromAttributes(cellNode.attrs);\n\t\t\tcells.push({\n\t\t\t\ttext,\n\t\t\t\tisHeader,\n\t\t\t\talign\n\t\t\t});\n\t\t});\n\t\trows.push(cells);\n\t});\n\tconst columnCount = rows.reduce((max, r) => Math.max(max, r.length), 0);\n\tif (columnCount === 0) return \"\";\n\tconst colWidths = Array.from({ length: columnCount }).fill(0);\n\trows.forEach((r) => {\n\t\tfor (let i = 0; i < columnCount; i += 1) {\n\t\t\tvar _r$i;\n\t\t\tconst len = (((_r$i = r[i]) === null || _r$i === void 0 ? void 0 : _r$i.text) || \"\").length;\n\t\t\tif (len > colWidths[i]) colWidths[i] = len;\n\t\t\tif (colWidths[i] < 3) colWidths[i] = 3;\n\t\t}\n\t});\n\tconst pad = (s, width) => s + \" \".repeat(Math.max(0, width - s.length));\n\tconst headerRow = rows[0];\n\tconst hasHeader = headerRow.some((c) => c.isHeader);\n\tconst colAlignments = Array.from({ length: columnCount }).fill(null);\n\trows.forEach((r) => {\n\t\tfor (let i = 0; i < columnCount; i += 1) {\n\t\t\tvar _r$i2;\n\t\t\tif (!colAlignments[i] && ((_r$i2 = r[i]) === null || _r$i2 === void 0 ? void 0 : _r$i2.align)) colAlignments[i] = r[i].align;\n\t\t}\n\t});\n\tlet out = \"\\n\";\n\tconst headerTexts = Array.from({ length: columnCount }).map((_, i) => hasHeader ? headerRow[i] && headerRow[i].text || \"\" : \"\");\n\tout += `| ${headerTexts.map((t, i) => pad(t, colWidths[i])).join(\" | \")} |\\n`;\n\tout += `| ${colWidths.map((w, index) => {\n\t\tconst dashCount = Math.max(3, w);\n\t\tconst alignment = colAlignments[index];\n\t\tif (alignment === \"left\") return `:${\"-\".repeat(dashCount)}`;\n\t\tif (alignment === \"right\") return `${\"-\".repeat(dashCount)}:`;\n\t\tif (alignment === \"center\") return `:${\"-\".repeat(dashCount)}:`;\n\t\treturn \"-\".repeat(dashCount);\n\t}).join(\" | \")} |\\n`;\n\t(hasHeader ? rows.slice(1) : rows).forEach((r) => {\n\t\tout += `| ${Array.from({ length: columnCount }).fill(0).map((_, i) => pad(r[i] && r[i].text || \"\", colWidths[i])).join(\" | \")} |\\n`;\n\t});\n\treturn out;\n}\n//#endregion\n//#region src/table/table.ts\n/**\n* This extension allows you to create tables.\n* @see https://www.tiptap.dev/api/nodes/table\n*/\nconst Table = _tiptap_core.Node.create({\n\tname: \"table\",\n\taddOptions() {\n\t\treturn {\n\t\t\tHTMLAttributes: {},\n\t\t\tresizable: false,\n\t\t\trenderWrapper: false,\n\t\t\thandleWidth: 5,\n\t\t\tcellMinWidth: 25,\n\t\t\tView: TableView,\n\t\t\tlastColumnResizable: true,\n\t\t\tallowTableNodeSelection: false\n\t\t};\n\t},\n\tcontent: \"tableRow+\",\n\ttableRole: \"table\",\n\tisolating: true,\n\tgroup: \"block\",\n\tparseHTML() {\n\t\treturn [{ tag: \"table\" }];\n\t},\n\trenderHTML({ node, HTMLAttributes }) {\n\t\tconst { colgroup, tableWidth, tableMinWidth } = createColGroup(node, this.options.cellMinWidth);\n\t\tconst userStyles = HTMLAttributes.style;\n\t\tfunction getTableStyle() {\n\t\t\tif (userStyles) return userStyles;\n\t\t\treturn tableWidth ? `width: ${tableWidth}` : `min-width: ${tableMinWidth}`;\n\t\t}\n\t\tconst table = [\n\t\t\t\"table\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes, { style: getTableStyle() }),\n\t\t\tcolgroup,\n\t\t\t[\"tbody\", 0]\n\t\t];\n\t\treturn this.options.renderWrapper ? [\n\t\t\t\"div\",\n\t\t\t{ class: \"tableWrapper\" },\n\t\t\ttable\n\t\t] : table;\n\t},\n\tparseMarkdown: (token, h) => {\n\t\tconst rows = [];\n\t\tconst alignments = Array.isArray(token.align) ? token.align : [];\n\t\tif (token.header) {\n\t\t\tconst headerCells = [];\n\t\t\ttoken.header.forEach((cell, index) => {\n\t\t\t\tvar _alignments$index;\n\t\t\t\tconst align = normalizeTableCellAlign((_alignments$index = alignments[index]) !== null && _alignments$index !== void 0 ? _alignments$index : cell.align);\n\t\t\t\tconst attrs = align ? { align } : {};\n\t\t\t\theaderCells.push(h.createNode(\"tableHeader\", attrs, [{\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: h.parseInline(cell.tokens)\n\t\t\t\t}]));\n\t\t\t});\n\t\t\trows.push(h.createNode(\"tableRow\", {}, headerCells));\n\t\t}\n\t\tif (token.rows) token.rows.forEach((row) => {\n\t\t\tconst bodyCells = [];\n\t\t\trow.forEach((cell, index) => {\n\t\t\t\tvar _alignments$index2;\n\t\t\t\tconst align = normalizeTableCellAlign((_alignments$index2 = alignments[index]) !== null && _alignments$index2 !== void 0 ? _alignments$index2 : cell.align);\n\t\t\t\tconst attrs = align ? { align } : {};\n\t\t\t\tbodyCells.push(h.createNode(\"tableCell\", attrs, [{\n\t\t\t\t\ttype: \"paragraph\",\n\t\t\t\t\tcontent: h.parseInline(cell.tokens)\n\t\t\t\t}]));\n\t\t\t});\n\t\t\trows.push(h.createNode(\"tableRow\", {}, bodyCells));\n\t\t});\n\t\treturn h.createNode(\"table\", void 0, rows);\n\t},\n\trenderMarkdown: (node, h) => {\n\t\treturn renderTableToMarkdown(node, h);\n\t},\n\tmarkdownTokenizer: {\n\t\tname: \"table\",\n\t\tlevel: \"block\",\n\t\tstart: (src) => {\n\t\t\tconst lines = src.split(\"\\n\");\n\t\t\tif (lines.length < 2) return -1;\n\t\t\tconst sep = lines[1];\n\t\t\tif (!/^[ \\t|:]*-[ \\t|:-]*$/.test(sep) || !sep.includes(\"|\")) return -1;\n\t\t\treturn lines[0].includes(\"|\") ? 0 : -1;\n\t\t},\n\t\ttokenize(src, _tokens, helper) {\n\t\t\tconst blankLineIndex = src.indexOf(\"\\n\\n\");\n\t\t\tconst candidate = blankLineIndex >= 0 ? src.slice(0, blankLineIndex) : src;\n\t\t\tconst candidateLines = candidate.split(\"\\n\");\n\t\t\tif (candidateLines.length < 2) return void 0;\n\t\t\tconst sep = candidateLines[1];\n\t\t\tif (!/^[ \\t|:]*-[ \\t|:-]*$/.test(sep) || !sep.includes(\"|\")) return void 0;\n\t\t\tconst preprocessed = preprocessTablePipes(candidate);\n\t\t\tif (preprocessed === candidate) return void 0;\n\t\t\tconst tableToken = helper.blockTokens(preprocessed)[0];\n\t\t\tif ((tableToken === null || tableToken === void 0 ? void 0 : tableToken.type) !== \"table\" || !tableToken.raw) return void 0;\n\t\t\tconst lineCount = tableToken.raw.split(\"\\n\").length;\n\t\t\tconst raw = src.split(\"\\n\").slice(0, lineCount).join(\"\\n\");\n\t\t\treturn {\n\t\t\t\t...tableToken,\n\t\t\t\traw\n\t\t\t};\n\t\t}\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tinsertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr, dispatch, editor }) => {\n\t\t\t\tconst node = createTable(editor.schema, rows, cols, withHeaderRow);\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tconst offset = tr.selection.from + 1;\n\t\t\t\t\ttr.replaceSelectionWith(node).scrollIntoView().setSelection(_tiptap_pm_state.TextSelection.near(tr.doc.resolve(offset)));\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\taddColumnBefore: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.addColumnBefore)(state, dispatch);\n\t\t\t},\n\t\t\taddColumnAfter: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.addColumnAfter)(state, dispatch);\n\t\t\t},\n\t\t\tdeleteColumn: () => ({ state, dispatch }) => {\n\t\t\t\tconst table = (0, _tiptap_core.findParentNodeClosestToPos)(state.selection.$from, (node) => node.type.name === \"table\");\n\t\t\t\treturn (0, _tiptap_pm_tables.deleteColumn)(state, dispatch && ((tr) => {\n\t\t\t\t\tif (table) keepCursorInTable(tr, table.pos);\n\t\t\t\t\tdispatch(tr);\n\t\t\t\t}));\n\t\t\t},\n\t\t\taddRowBefore: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.addRowBefore)(state, dispatch);\n\t\t\t},\n\t\t\taddRowAfter: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.addRowAfter)(state, dispatch);\n\t\t\t},\n\t\t\tdeleteRow: () => ({ state, dispatch }) => {\n\t\t\t\tconst table = (0, _tiptap_core.findParentNodeClosestToPos)(state.selection.$from, (node) => node.type.name === \"table\");\n\t\t\t\treturn (0, _tiptap_pm_tables.deleteRow)(state, dispatch && ((tr) => {\n\t\t\t\t\tif (table) keepCursorInTable(tr, table.pos);\n\t\t\t\t\tdispatch(tr);\n\t\t\t\t}));\n\t\t\t},\n\t\t\tdeleteTable: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.deleteTable)(state, dispatch);\n\t\t\t},\n\t\t\tmergeCells: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.mergeCells)(state, dispatch);\n\t\t\t},\n\t\t\tsplitCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.splitCell)(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderColumn: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.toggleHeader)(\"column\")(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderRow: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.toggleHeader)(\"row\")(state, dispatch);\n\t\t\t},\n\t\t\ttoggleHeaderCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.toggleHeaderCell)(state, dispatch);\n\t\t\t},\n\t\t\tmergeOrSplit: () => ({ state, dispatch }) => {\n\t\t\t\tif ((0, _tiptap_pm_tables.mergeCells)(state, dispatch)) return true;\n\t\t\t\treturn (0, _tiptap_pm_tables.splitCell)(state, dispatch);\n\t\t\t},\n\t\t\tsetCellAttribute: (name, value) => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.setCellAttr)(name, value)(state, dispatch);\n\t\t\t},\n\t\t\tgoToNextCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.goToNextCell)(1)(state, dispatch);\n\t\t\t},\n\t\t\tgoToPreviousCell: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_tables.goToNextCell)(-1)(state, dispatch);\n\t\t\t},\n\t\t\tfixTables: () => ({ state, dispatch }) => {\n\t\t\t\tif (dispatch) (0, _tiptap_pm_tables.fixTables)(state);\n\t\t\t\treturn true;\n\t\t\t},\n\t\t\tsetCellSelection: (position) => ({ tr, dispatch }) => {\n\t\t\t\tif (dispatch) {\n\t\t\t\t\tconst selection = _tiptap_pm_tables.CellSelection.create(tr.doc, position.anchorCell, position.headCell);\n\t\t\t\t\ttr.setSelection(selection);\n\t\t\t\t}\n\t\t\t\treturn true;\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\tTab: () => {\n\t\t\t\tif (this.editor.commands.goToNextCell()) return true;\n\t\t\t\tif (!this.editor.can().addRowAfter()) return false;\n\t\t\t\treturn this.editor.chain().addRowAfter().goToNextCell().run();\n\t\t\t},\n\t\t\t\"Shift-Tab\": () => this.editor.commands.goToPreviousCell(),\n\t\t\tBackspace: deleteTableWhenAllCellsSelected,\n\t\t\t\"Mod-Backspace\": deleteTableWhenAllCellsSelected,\n\t\t\tDelete: deleteTableWhenAllCellsSelected,\n\t\t\t\"Mod-Delete\": deleteTableWhenAllCellsSelected\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [...this.options.resizable && this.editor.isEditable ? [(0, _tiptap_pm_tables.columnResizing)({\n\t\t\thandleWidth: this.options.handleWidth,\n\t\t\tcellMinWidth: this.options.cellMinWidth,\n\t\t\tdefaultCellMinWidth: this.options.cellMinWidth,\n\t\t\tView: this.options.View,\n\t\t\tlastColumnResizable: this.options.lastColumnResizable\n\t\t})] : [], (0, _tiptap_pm_tables.tableEditing)({ allowTableNodeSelection: this.options.allowTableNodeSelection })];\n\t},\n\taddNodeView() {\n\t\tconst isResizable = this.options.resizable && this.editor.isEditable;\n\t\tconst View = this.options.View;\n\t\tif (isResizable || !View) return null;\n\t\treturn ({ node, view, HTMLAttributes }) => {\n\t\t\tconst mergedAttributes = (0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes);\n\t\t\treturn new View(node, this.options.cellMinWidth, view, mergedAttributes);\n\t\t};\n\t},\n\textendNodeSchema(extension) {\n\t\tconst context = {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage\n\t\t};\n\t\treturn { tableRole: (0, _tiptap_core.callOrReturn)((0, _tiptap_core.getExtensionField)(extension, \"tableRole\", context)) };\n\t}\n});\n//#endregion\n//#region src/kit/index.ts\n/**\n* The table kit is a collection of table editor extensions.\n*\n* It’s a good starting point for building your own table in Tiptap.\n*/\nconst TableKit = _tiptap_core.Extension.create({\n\tname: \"tableKit\",\n\taddExtensions() {\n\t\tconst extensions = [];\n\t\tif (this.options.table !== false) extensions.push(Table.configure(this.options.table));\n\t\tif (this.options.tableCell !== false) extensions.push(TableCell.configure(this.options.tableCell));\n\t\tif (this.options.tableHeader !== false) extensions.push(TableHeader.configure(this.options.tableHeader));\n\t\tif (this.options.tableRow !== false) extensions.push(TableRow.configure(this.options.tableRow));\n\t\treturn extensions;\n\t}\n});\n//#endregion\nexports.DEFAULT_CELL_LINE_SEPARATOR = DEFAULT_CELL_LINE_SEPARATOR;\nexports.Table = Table;\nexports.TableCell = TableCell;\nexports.TableHeader = TableHeader;\nexports.TableKit = TableKit;\nexports.TableRow = TableRow;\nexports.TableView = TableView;\nexports.createColGroup = createColGroup;\nexports.createTable = createTable;\nexports.escapeTableCellPipes = escapeTableCellPipes;\nexports.preprocessTablePipes = preprocessTablePipes;\nexports.renderTableToMarkdown = renderTableToMarkdown;\nexports.updateColumns = updateColumns;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\n//#region src/text.ts\n/**\n* This extension allows you to create text nodes.\n* @see https://www.tiptap.dev/api/nodes/text\n*/\nconst Text = require(\"@tiptap/core\").Node.create({\n\tname: \"text\",\n\tgroup: \"inline\",\n\tparseMarkdown: (token) => {\n\t\treturn {\n\t\t\ttype: \"text\",\n\t\t\ttext: token.text || \"\"\n\t\t};\n\t},\n\trenderMarkdown: (node) => node.text || \"\"\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Text;\n//#endregion\nexports.Text = Text;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\n//#region src/underline.ts\n/**\n* This extension allows you to create underline text.\n* @see https://www.tiptap.dev/api/marks/underline\n*/\nconst Underline = _tiptap_core.Mark.create({\n\tname: \"underline\",\n\taddOptions() {\n\t\treturn { HTMLAttributes: {} };\n\t},\n\tparseHTML() {\n\t\treturn [{ tag: \"u\" }, {\n\t\t\tstyle: \"text-decoration\",\n\t\t\tconsuming: false,\n\t\t\tgetAttrs: (style) => style.includes(\"underline\") ? {} : false\n\t\t}];\n\t},\n\trenderHTML({ HTMLAttributes }) {\n\t\treturn [\n\t\t\t\"u\",\n\t\t\t(0, _tiptap_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes),\n\t\t\t0\n\t\t];\n\t},\n\tparseMarkdown(token, helpers) {\n\t\treturn helpers.applyMark(this.name || \"underline\", helpers.parseInline(token.tokens || []));\n\t},\n\trenderMarkdown(node, helpers) {\n\t\treturn `++${helpers.renderChildren(node)}++`;\n\t},\n\tmarkdownTokenizer: {\n\t\tname: \"underline\",\n\t\tlevel: \"inline\",\n\t\tstart(src) {\n\t\t\treturn src.indexOf(\"++\");\n\t\t},\n\t\ttokenize(src, _tokens, lexer) {\n\t\t\tconst match = /^(\\+\\+)([\\s\\S]+?)(\\+\\+)/.exec(src);\n\t\t\tif (!match) return;\n\t\t\tconst innerContent = match[2].trim();\n\t\t\treturn {\n\t\t\t\ttype: \"underline\",\n\t\t\t\traw: match[0],\n\t\t\t\ttext: innerContent,\n\t\t\t\ttokens: lexer.inlineTokens(innerContent)\n\t\t\t};\n\t\t}\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tsetUnderline: () => ({ commands }) => {\n\t\t\t\treturn commands.setMark(this.name);\n\t\t\t},\n\t\t\ttoggleUnderline: () => ({ commands }) => {\n\t\t\t\treturn commands.toggleMark(this.name);\n\t\t\t},\n\t\t\tunsetUnderline: () => ({ commands }) => {\n\t\t\t\treturn commands.unsetMark(this.name);\n\t\t\t}\n\t\t};\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-u\": () => this.editor.commands.toggleUnderline(),\n\t\t\t\"Mod-U\": () => this.editor.commands.toggleUnderline()\n\t\t};\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = Underline;\n//#endregion\nexports.Underline = Underline;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_pm_state = require(\"@tiptap/pm/state\");\nlet _tiptap_pm_dropcursor = require(\"@tiptap/pm/dropcursor\");\nlet _tiptap_pm_view = require(\"@tiptap/pm/view\");\nlet _tiptap_pm_gapcursor = require(\"@tiptap/pm/gapcursor\");\nlet _tiptap_pm_history = require(\"@tiptap/pm/history\");\n//#region src/character-count/character-count.ts\n/**\n* This extension allows you to count the characters and words of your document.\n* @see https://tiptap.dev/api/extensions/character-count\n*/\nconst CharacterCount = _tiptap_core.Extension.create({\n\tname: \"characterCount\",\n\taddOptions() {\n\t\treturn {\n\t\t\tlimit: null,\n\t\t\tautoTrim: true,\n\t\t\tmode: \"textSize\",\n\t\t\ttextCounter: (text) => text.length,\n\t\t\twordCounter: (text) => text.split(\" \").filter((word) => word !== \"\").length\n\t\t};\n\t},\n\taddStorage() {\n\t\treturn {\n\t\t\tcharacters: () => 0,\n\t\t\twords: () => 0\n\t\t};\n\t},\n\tonBeforeCreate() {\n\t\tthis.storage.characters = (options) => {\n\t\t\tconst node = (options === null || options === void 0 ? void 0 : options.node) || this.editor.state.doc;\n\t\t\tif (((options === null || options === void 0 ? void 0 : options.mode) || this.options.mode) === \"textSize\") {\n\t\t\t\tconst text = node.textBetween(0, node.content.size, void 0, \" \");\n\t\t\t\treturn this.options.textCounter(text);\n\t\t\t}\n\t\t\treturn node.nodeSize;\n\t\t};\n\t\tthis.storage.words = (options) => {\n\t\t\tconst node = (options === null || options === void 0 ? void 0 : options.node) || this.editor.state.doc;\n\t\t\tconst text = node.textBetween(0, node.content.size, \" \", \" \");\n\t\t\treturn this.options.wordCounter(text);\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\tlet initialEvaluationDone = false;\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"characterCount\"),\n\t\t\tappendTransaction: (transactions, oldState, newState) => {\n\t\t\t\tif (initialEvaluationDone) return;\n\t\t\t\tconst limit = this.options.limit;\n\t\t\t\tconst autoTrim = this.options.autoTrim;\n\t\t\t\tif (limit === null || limit === void 0 || limit === 0 || autoTrim === false) {\n\t\t\t\t\tinitialEvaluationDone = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst initialContentSize = this.storage.characters({ node: newState.doc });\n\t\t\t\tif (initialContentSize > limit) {\n\t\t\t\t\tconst over = initialContentSize - limit;\n\t\t\t\t\tconst from = 0;\n\t\t\t\t\tconst to = over;\n\t\t\t\t\tconsole.warn(`[CharacterCount] Initial content exceeded limit of ${limit} characters. Content was automatically trimmed.`);\n\t\t\t\t\tconst tr = newState.tr.deleteRange(from, to);\n\t\t\t\t\tinitialEvaluationDone = true;\n\t\t\t\t\treturn tr;\n\t\t\t\t}\n\t\t\t\tinitialEvaluationDone = true;\n\t\t\t},\n\t\t\tfilterTransaction: (transaction, state) => {\n\t\t\t\tconst limit = this.options.limit;\n\t\t\t\tif (!transaction.docChanged || limit === 0 || limit === null || limit === void 0) return true;\n\t\t\t\tconst oldSize = this.storage.characters({ node: state.doc });\n\t\t\t\tconst newSize = this.storage.characters({ node: transaction.doc });\n\t\t\t\tif (newSize <= limit) return true;\n\t\t\t\tif (oldSize > limit && newSize > limit && newSize <= oldSize) return true;\n\t\t\t\tif (oldSize > limit && newSize > limit && newSize > oldSize) return false;\n\t\t\t\tif (!transaction.getMeta(\"paste\")) return false;\n\t\t\t\tconst pos = transaction.selection.$head.pos;\n\t\t\t\tconst from = pos - (newSize - limit);\n\t\t\t\tconst to = pos;\n\t\t\t\ttransaction.deleteRange(from, to);\n\t\t\t\tif (this.storage.characters({ node: transaction.doc }) > limit) return false;\n\t\t\t\treturn true;\n\t\t\t}\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/drop-cursor/drop-cursor.ts\n/**\n* This extension allows you to add a drop cursor to your editor.\n* A drop cursor is a line that appears when you drag and drop content\n* in-between nodes.\n* @see https://tiptap.dev/api/extensions/dropcursor\n*/\nconst Dropcursor = _tiptap_core.Extension.create({\n\tname: \"dropCursor\",\n\taddOptions() {\n\t\treturn {\n\t\t\tcolor: \"currentColor\",\n\t\t\twidth: 1,\n\t\t\tclass: void 0\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [(0, _tiptap_pm_dropcursor.dropCursor)(this.options)];\n\t}\n});\n//#endregion\n//#region src/focus/focus.ts\n/**\n* This extension allows you to add a class to the focused node.\n* @see https://www.tiptap.dev/api/extensions/focus\n*/\nconst Focus = _tiptap_core.Extension.create({\n\tname: \"focus\",\n\taddOptions() {\n\t\treturn {\n\t\t\tclassName: \"has-focus\",\n\t\t\tmode: \"all\"\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"focus\"),\n\t\t\tprops: { decorations: ({ doc, selection }) => {\n\t\t\t\tconst { isEditable, isFocused } = this.editor;\n\t\t\t\tconst { anchor } = selection;\n\t\t\t\tconst decorations = [];\n\t\t\t\tif (!isEditable || !isFocused) return _tiptap_pm_view.DecorationSet.create(doc, []);\n\t\t\t\tlet maxLevels = 0;\n\t\t\t\tif (this.options.mode === \"deepest\") doc.descendants((node, pos) => {\n\t\t\t\t\tif (node.isText) return;\n\t\t\t\t\tif (!(anchor >= pos && anchor <= pos + node.nodeSize - 1)) return false;\n\t\t\t\t\tmaxLevels += 1;\n\t\t\t\t});\n\t\t\t\tlet currentLevel = 0;\n\t\t\t\tdoc.descendants((node, pos) => {\n\t\t\t\t\tif (node.isText) return false;\n\t\t\t\t\tif (!(anchor >= pos && anchor <= pos + node.nodeSize - 1)) return false;\n\t\t\t\t\tcurrentLevel += 1;\n\t\t\t\t\tif (this.options.mode === \"deepest\" && maxLevels - currentLevel > 0 || this.options.mode === \"shallowest\" && currentLevel > 1) return this.options.mode === \"deepest\";\n\t\t\t\t\tdecorations.push(_tiptap_pm_view.Decoration.node(pos, pos + node.nodeSize, { class: this.options.className }));\n\t\t\t\t});\n\t\t\t\treturn _tiptap_pm_view.DecorationSet.create(doc, decorations);\n\t\t\t} }\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/gap-cursor/gap-cursor.ts\n/**\n* This extension allows you to add a gap cursor to your editor.\n* A gap cursor is a cursor that appears when you click on a place\n* where no content is present, for example inbetween nodes.\n* @see https://tiptap.dev/api/extensions/gapcursor\n*/\nconst Gapcursor = _tiptap_core.Extension.create({\n\tname: \"gapCursor\",\n\taddProseMirrorPlugins() {\n\t\treturn [(0, _tiptap_pm_gapcursor.gapCursor)()];\n\t},\n\textendNodeSchema(extension) {\n\t\tvar _callOrReturn;\n\t\tconst context = {\n\t\t\tname: extension.name,\n\t\t\toptions: extension.options,\n\t\t\tstorage: extension.storage\n\t\t};\n\t\treturn { allowGapCursor: (_callOrReturn = (0, _tiptap_core.callOrReturn)((0, _tiptap_core.getExtensionField)(extension, \"allowGapCursor\", context))) !== null && _callOrReturn !== void 0 ? _callOrReturn : null };\n\t}\n});\n//#endregion\n//#region src/placeholder/constants.ts\n/** The default data attribute label */\nconst DEFAULT_DATA_ATTRIBUTE = \"placeholder\";\n/** The plugin key used to store and read the placeholder decoration set */\nconst PLUGIN_KEY = new _tiptap_pm_state.PluginKey(\"tiptap__placeholder\");\n//#endregion\n//#region src/placeholder/utils/createPlaceholderDecoration.ts\n/**\n* Creates a ProseMirror node decoration that applies a placeholder\n* CSS class and data attribute to an empty node.\n* @param options.editor - The editor instance\n* @param options.pos - The position of the node in the document\n* @param options.node - The ProseMirror node\n* @param options.isEmptyDoc - Whether the entire document is empty\n* @param options.hasAnchor - Whether the selection anchor is within the node\n* @param options.dataAttribute - The data attribute name (e.g. `data-placeholder`)\n* @param options.classes - CSS classes for empty nodes and the empty editor\n* @param options.placeholder - The placeholder text or a function that returns it\n* @returns A ProseMirror node decoration with placeholder classes and data attribute\n*/\nfunction createPlaceholderDecoration(options) {\n\tconst { editor, placeholder, dataAttribute, pos, node, isEmptyDoc, hasAnchor, classes: { emptyNode, emptyEditor } } = options;\n\tconst classes = [emptyNode];\n\tif (isEmptyDoc) classes.push(emptyEditor);\n\treturn _tiptap_pm_view.Decoration.node(pos, pos + node.nodeSize, {\n\t\tclass: classes.join(\" \"),\n\t\t[dataAttribute]: typeof placeholder === \"function\" ? placeholder({\n\t\t\teditor,\n\t\t\tnode,\n\t\t\tpos,\n\t\t\thasAnchor\n\t\t}) : placeholder\n\t});\n}\n//#endregion\n//#region src/placeholder/utils/buildPlaceholderDecorations.ts\nfunction resolveEmptyNodeClass(emptyNodeClass, props) {\n\treturn typeof emptyNodeClass === \"function\" ? emptyNodeClass(props) : emptyNodeClass;\n}\n/**\n* Scans a document range for empty textblocks that should receive placeholder\n* decorations. Used by the slow path and incremental state updates.\n*/\nfunction scanRangeForDecorations({ editor, options, dataAttribute, doc, selection, from, to }) {\n\tconst { anchor } = selection;\n\tconst decorations = [];\n\tconst isEmptyDoc = editor.isEmpty;\n\tdoc.nodesBetween(from, to, (node, pos) => {\n\t\tconst hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;\n\t\tconst isEmpty = !node.isLeaf && (0, _tiptap_core.isNodeEmpty)(node);\n\t\tif (!node.type.isTextblock) return options.includeChildren;\n\t\tif ((hasAnchor || !options.showOnlyCurrent) && isEmpty) decorations.push(createPlaceholderDecoration({\n\t\t\teditor,\n\t\t\tisEmptyDoc,\n\t\t\tdataAttribute,\n\t\t\thasAnchor,\n\t\t\tplaceholder: options.placeholder,\n\t\t\tclasses: {\n\t\t\t\temptyEditor: options.emptyEditorClass,\n\t\t\t\temptyNode: resolveEmptyNodeClass(options.emptyNodeClass, {\n\t\t\t\t\teditor,\n\t\t\t\t\tnode,\n\t\t\t\t\tpos,\n\t\t\t\t\thasAnchor\n\t\t\t\t})\n\t\t\t},\n\t\t\tnode,\n\t\t\tpos\n\t\t}));\n\t\treturn options.includeChildren;\n\t});\n\treturn decorations;\n}\n/**\n* Builds the placeholder decorations for the current document state.\n* @param options.editor - The editor instance.\n* @param options.options - The resolved placeholder options.\n* @param options.dataAttribute - The prepared `data-*` attribute name.\n* @param options.doc - The current document node.\n* @param options.selection - The current selection.\n* @returns A decoration set, or `null` when no placeholders should be shown.\n*/\nfunction buildPlaceholderDecorations({ editor, options, dataAttribute, doc, selection }) {\n\tif (!(editor.isEditable || !options.showOnlyWhenEditable)) return null;\n\tconst { anchor } = selection;\n\tconst decorations = [];\n\tconst isEmptyDoc = editor.isEmpty;\n\tif (options.showOnlyCurrent && !options.includeChildren) {\n\t\tconst resolved = doc.resolve(anchor);\n\t\tconst node = resolved.depth > 0 ? resolved.node(1) : resolved.nodeAfter;\n\t\tconst nodeStart = resolved.depth > 0 ? resolved.before(1) : anchor;\n\t\tif (node && node.type.isTextblock && (0, _tiptap_core.isNodeEmpty)(node)) {\n\t\t\tconst hasAnchor = anchor >= nodeStart && anchor <= nodeStart + node.nodeSize;\n\t\t\tdecorations.push(createPlaceholderDecoration({\n\t\t\t\teditor,\n\t\t\t\tisEmptyDoc,\n\t\t\t\tdataAttribute,\n\t\t\t\thasAnchor,\n\t\t\t\tplaceholder: options.placeholder,\n\t\t\t\tclasses: {\n\t\t\t\t\temptyEditor: options.emptyEditorClass,\n\t\t\t\t\temptyNode: resolveEmptyNodeClass(options.emptyNodeClass, {\n\t\t\t\t\t\teditor,\n\t\t\t\t\t\tnode,\n\t\t\t\t\t\tpos: nodeStart,\n\t\t\t\t\t\thasAnchor\n\t\t\t\t\t})\n\t\t\t\t},\n\t\t\t\tnode,\n\t\t\t\tpos: nodeStart\n\t\t\t}));\n\t\t}\n\t} else decorations.push(...scanRangeForDecorations({\n\t\teditor,\n\t\toptions,\n\t\tdataAttribute,\n\t\tdoc,\n\t\tselection,\n\t\tfrom: 0,\n\t\tto: doc.content.size\n\t}));\n\treturn _tiptap_pm_view.DecorationSet.create(doc, decorations);\n}\n//#endregion\n//#region src/placeholder/utils/resolveTopLevelRange.ts\n/**\n* Resolves a document position to the `[from, to)` range of its containing\n* top-level block node in absolute document positions.\n*/\nfunction resolveTopLevelRange(doc, pos) {\n\tconst resolved = doc.resolve(pos);\n\tif (resolved.depth === 0) {\n\t\tvar _resolved$nodeAfter;\n\t\tconst node = (_resolved$nodeAfter = resolved.nodeAfter) !== null && _resolved$nodeAfter !== void 0 ? _resolved$nodeAfter : resolved.nodeBefore;\n\t\tif (!node) return {\n\t\t\tfrom: pos,\n\t\t\tto: pos\n\t\t};\n\t\tconst nodePos = resolved.nodeAfter ? pos : pos - node.nodeSize;\n\t\treturn {\n\t\t\tfrom: nodePos,\n\t\t\tto: nodePos + node.nodeSize\n\t\t};\n\t}\n\tconst topLevelPos = resolved.before(1);\n\treturn {\n\t\tfrom: topLevelPos,\n\t\tto: topLevelPos + resolved.node(1).nodeSize\n\t};\n}\n/**\n* Converts an absolute document range to content-relative positions used by\n* `Node#nodesBetween` and `Node#forEach` offsets.\n*/\nfunction toContentRelativeRange(doc, range) {\n\treturn {\n\t\tfrom: Math.max(0, range.from - 1),\n\t\tto: Math.min(doc.content.size, range.to - 1)\n\t};\n}\n/**\n* Returns the top-level block ranges that intersect a document change range.\n* Input `from`/`to` are absolute positions (e.g. from `getChangedRanges`).\n* Returned ranges are content-relative, matching `Node#forEach` offsets.\n*/\nfunction getTopLevelBlocksInRange(doc, from, to) {\n\tconst ranges = [];\n\tdoc.forEach((node, offset) => {\n\t\tconst nodeStart = offset;\n\t\tconst nodeEnd = nodeStart + node.nodeSize;\n\t\tconst absNodeStart = nodeStart + 1;\n\t\tconst absNodeEnd = nodeEnd + 1;\n\t\tif (absNodeStart < to && absNodeEnd > from) ranges.push({\n\t\t\tfrom: nodeStart,\n\t\t\tto: nodeEnd\n\t\t});\n\t});\n\treturn ranges;\n}\n/**\n* Sorts ranges by start position and merges overlapping or adjacent ranges.\n*/\nfunction mergeRanges(ranges) {\n\tif (ranges.length === 0) return [];\n\tconst sorted = [...ranges].sort((a, b) => a.from - b.from);\n\tconst merged = [{ ...sorted[0] }];\n\tfor (let i = 1; i < sorted.length; i += 1) {\n\t\tconst last = merged[merged.length - 1];\n\t\tconst current = sorted[i];\n\t\tif (current.from <= last.to) last.to = Math.max(last.to, current.to);\n\t\telse merged.push({ ...current });\n\t}\n\treturn merged;\n}\n//#endregion\n//#region src/placeholder/utils/placeholderStateField.ts\n/**\n* Expands a single changed range to the top-level blocks it touches.\n* Also resolves blocks at range boundaries so split/merge edits update\n* adjacent empty nodes (e.g. a new paragraph after Enter).\n*/\nfunction collectBlocksForChange(doc, change) {\n\tconst ranges = getTopLevelBlocksInRange(doc, change.from, change.to);\n\tranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, change.from)));\n\tif (change.to > change.from) ranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, Math.min(change.to, doc.content.size + 1) - 1)));\n\telse if (change.from < doc.content.size + 1) ranges.push(toContentRelativeRange(doc, resolveTopLevelRange(doc, Math.min(change.from + 1, doc.content.size))));\n\treturn ranges;\n}\n/**\n* Collects content-relative top-level block ranges that need placeholder\n* decorations recomputed after a transaction.\n*/\nfunction collectRescanRanges(tr, oldState, newState) {\n\tconst ranges = [];\n\tif (tr.docChanged) {\n\t\tconst changes = (0, _tiptap_core.getChangedRanges)(tr);\n\t\tfor (const change of changes) ranges.push(...collectBlocksForChange(newState.doc, change.newRange));\n\t}\n\tif (tr.selectionSet) {\n\t\tranges.push(toContentRelativeRange(newState.doc, resolveTopLevelRange(newState.doc, tr.mapping.map(oldState.selection.anchor))));\n\t\tranges.push(toContentRelativeRange(newState.doc, resolveTopLevelRange(newState.doc, newState.selection.anchor)));\n\t}\n\treturn mergeRanges(ranges);\n}\n/** Clamps a content-relative range to `[0, doc.content.size]`. */\nfunction clampRange(from, to, doc) {\n\tconst clampedFrom = Math.max(0, Math.min(from, doc.content.size));\n\treturn {\n\t\tfrom: clampedFrom,\n\t\tto: Math.max(clampedFrom, Math.min(to, doc.content.size))\n\t};\n}\n/**\n* Removes and rebuilds placeholder decorations within the given ranges.\n* Only drops decorations fully contained in a range so mapped decorations\n* on neighbouring blocks (e.g. at a block boundary) are kept intact.\n*/\nfunction updateDecorationsInRanges({ decorations, ranges, editor, options, dataAttribute, doc, selection }) {\n\tlet next = decorations;\n\tfor (const range of ranges) {\n\t\tconst { from, to } = clampRange(range.from, range.to, doc);\n\t\tconst existing = next.find(from, to).filter((decoration) => decoration.from >= from && decoration.to <= to);\n\t\tif (existing.length) next = next.remove(existing);\n\t\tconst newDecos = scanRangeForDecorations({\n\t\t\teditor,\n\t\t\toptions,\n\t\t\tdataAttribute,\n\t\t\tdoc,\n\t\t\tselection,\n\t\t\tfrom,\n\t\t\tto\n\t\t});\n\t\tif (newDecos.length) next = next.add(doc, newDecos);\n\t}\n\treturn next;\n}\n/**\n* Creates the incremental `StateField<DecorationSet>` used by the slow path\n* (`showOnlyCurrent: false` or `includeChildren: true`).\n*\n* Decorations are mapped through each transaction and only recomputed for\n* top-level blocks touched by document or selection changes.\n* @param options.editor - The editor instance.\n* @param options.options - The resolved placeholder options.\n* @param options.dataAttribute - The prepared `data-*` attribute name.\n* @returns A ProseMirror state field storing the placeholder decoration set.\n*/\nfunction createPlaceholderStateField({ editor, options, dataAttribute }) {\n\treturn {\n\t\tinit(_config, state) {\n\t\t\tconst decorations = buildPlaceholderDecorations({\n\t\t\t\teditor,\n\t\t\t\toptions,\n\t\t\t\tdataAttribute,\n\t\t\t\tdoc: state.doc,\n\t\t\t\tselection: state.selection\n\t\t\t});\n\t\t\treturn decorations !== null && decorations !== void 0 ? decorations : _tiptap_pm_view.DecorationSet.empty;\n\t\t},\n\t\tapply(tr, prev, oldState, newState) {\n\t\t\tif (!tr.docChanged && !tr.selectionSet) return prev;\n\t\t\treturn updateDecorationsInRanges({\n\t\t\t\tdecorations: prev.map(tr.mapping, tr.doc),\n\t\t\t\tranges: collectRescanRanges(tr, oldState, newState),\n\t\t\t\teditor,\n\t\t\t\toptions,\n\t\t\t\tdataAttribute,\n\t\t\t\tdoc: newState.doc,\n\t\t\t\tselection: newState.selection\n\t\t\t});\n\t\t}\n\t};\n}\n//#endregion\n//#region src/placeholder/utils/preparePlaceholderAttribute.ts\n/**\n* Prepares the placeholder attribute by ensuring it is properly formatted.\n* @param attr - The placeholder attribute string.\n* @returns The prepared placeholder attribute string.\n*/\nfunction preparePlaceholderAttribute(attr) {\n\treturn attr.replace(/\\s+/g, \"-\").replace(/[^a-zA-Z0-9-]/g, \"\").replace(/^[0-9-]+/, \"\").replace(/^-+/, \"\").toLowerCase();\n}\n//#endregion\n//#region src/placeholder/plugins/PlaceholderPlugin.ts\n/**\n* Creates the ProseMirror plugin that renders placeholder decorations.\n* @param options.editor - The editor instance.\n* @param options.options - The resolved placeholder options.\n* @returns The configured placeholder plugin.\n*/\nfunction createPlaceholderPlugin({ editor, options }) {\n\tconst dataAttribute = options.dataAttribute ? `data-${preparePlaceholderAttribute(options.dataAttribute)}` : `data-${DEFAULT_DATA_ATTRIBUTE}`;\n\tconst useResolvedPath = options.showOnlyCurrent && !options.includeChildren;\n\treturn new _tiptap_pm_state.Plugin({\n\t\tkey: PLUGIN_KEY,\n\t\t...useResolvedPath ? {} : { state: createPlaceholderStateField({\n\t\t\teditor,\n\t\t\toptions,\n\t\t\tdataAttribute\n\t\t}) },\n\t\tprops: { decorations: useResolvedPath ? ({ doc, selection }) => buildPlaceholderDecorations({\n\t\t\teditor,\n\t\t\toptions,\n\t\t\tdataAttribute,\n\t\t\tdoc,\n\t\t\tselection\n\t\t}) : (state) => {\n\t\t\tvar _PLUGIN_KEY$getState;\n\t\t\tif (options.showOnlyWhenEditable && !editor.isEditable) return _tiptap_pm_view.DecorationSet.empty;\n\t\t\treturn (_PLUGIN_KEY$getState = PLUGIN_KEY.getState(state)) !== null && _PLUGIN_KEY$getState !== void 0 ? _PLUGIN_KEY$getState : _tiptap_pm_view.DecorationSet.empty;\n\t\t} }\n\t});\n}\n//#endregion\n//#region src/placeholder/placeholder.ts\n/**\n* This extension allows you to add a placeholder to your editor.\n* A placeholder is a text that appears when the editor or a node is empty.\n* @see https://www.tiptap.dev/api/extensions/placeholder\n*/\nconst Placeholder = _tiptap_core.Extension.create({\n\tname: \"placeholder\",\n\taddOptions() {\n\t\treturn {\n\t\t\temptyEditorClass: \"is-editor-empty\",\n\t\t\temptyNodeClass: \"is-empty\",\n\t\t\tdataAttribute: DEFAULT_DATA_ATTRIBUTE,\n\t\t\tplaceholder: \"Write something …\",\n\t\t\tshowOnlyWhenEditable: true,\n\t\t\tshowOnlyCurrent: true,\n\t\t\tincludeChildren: false\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [createPlaceholderPlugin({\n\t\t\teditor: this.editor,\n\t\t\toptions: this.options\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/selection/selection.ts\n/**\n* Whether the native browser selection should be cleared on blur and restored on focus.\n* Only applies to non-empty text selections in an editable editor.\n*/\nfunction shouldSyncDomSelection(state, editor) {\n\treturn !state.selection.empty && !(0, _tiptap_core.isNodeSelection)(state.selection) && editor.isEditable;\n}\n/**\n* Whether the selection decoration should be rendered to keep the selection\n* visible while the editor is blurred (and not dragging).\n*/\nfunction shouldPreserveSelection(state, editor) {\n\treturn shouldSyncDomSelection(state, editor) && !editor.isFocused && !editor.view.dragging;\n}\nfunction clearDomSelection() {\n\tvar _window$getSelection;\n\t(_window$getSelection = window.getSelection()) === null || _window$getSelection === void 0 || _window$getSelection.removeAllRanges();\n}\n/**\n* Sync the native selection from the editor state.\n* @see https://prosemirror.net/docs/ref/#view.EditorView.focus\n*/\nfunction restoreDomSelection(view) {\n\tview.focus();\n}\n/**\n* This extension allows you to add a class to the selected text when the editor is blurred.\n* It clears the native browser selection on blur (so `::selection` styles do not overlap the\n* decoration) and restores it when the editor is focused again.\n* @see https://www.tiptap.dev/api/extensions/selection\n*/\nconst Selection = _tiptap_core.Extension.create({\n\tname: \"selection\",\n\taddOptions() {\n\t\treturn { className: \"selection\" };\n\t},\n\taddProseMirrorPlugins() {\n\t\tconst { editor, options } = this;\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: new _tiptap_pm_state.PluginKey(\"selection\"),\n\t\t\tprops: {\n\t\t\t\tdecorations(state) {\n\t\t\t\t\tif (!shouldPreserveSelection(state, editor)) return null;\n\t\t\t\t\treturn _tiptap_pm_view.DecorationSet.create(state.doc, [_tiptap_pm_view.Decoration.inline(state.selection.from, state.selection.to, { class: options.className })]);\n\t\t\t\t},\n\t\t\t\thandleDOMEvents: {\n\t\t\t\t\tblur(view) {\n\t\t\t\t\t\tif (!shouldSyncDomSelection(view.state, editor)) return false;\n\t\t\t\t\t\tclearDomSelection();\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t},\n\t\t\t\t\tfocus(view) {\n\t\t\t\t\t\tif (!shouldSyncDomSelection(view.state, editor)) return false;\n\t\t\t\t\t\trequestAnimationFrame(() => {\n\t\t\t\t\t\t\tif (!editor.isDestroyed && view.hasFocus()) restoreDomSelection(view);\n\t\t\t\t\t\t});\n\t\t\t\t\t\treturn false;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/trailing-node/trailing-node.ts\nconst skipTrailingNodeMeta = \"skipTrailingNode\";\nfunction nodeEqualsType({ types, node }) {\n\treturn node && Array.isArray(types) && types.includes(node.type) || (node === null || node === void 0 ? void 0 : node.type) === types;\n}\n/**\n* This extension allows you to add an extra node at the end of the document.\n* @see https://www.tiptap.dev/api/extensions/trailing-node\n*/\nconst TrailingNode = _tiptap_core.Extension.create({\n\tname: \"trailingNode\",\n\taddOptions() {\n\t\treturn {\n\t\t\tnode: void 0,\n\t\t\tnotAfter: []\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\tvar _this$editor$schema$t;\n\t\tconst plugin = new _tiptap_pm_state.PluginKey(this.name);\n\t\tconst defaultNode = this.options.node || ((_this$editor$schema$t = this.editor.schema.topNodeType.contentMatch.defaultType) === null || _this$editor$schema$t === void 0 ? void 0 : _this$editor$schema$t.name) || \"paragraph\";\n\t\tconst disabledNodes = Object.entries(this.editor.schema.nodes).map(([, value]) => value).filter((node) => (this.options.notAfter || []).concat(defaultNode).includes(node.name));\n\t\treturn [new _tiptap_pm_state.Plugin({\n\t\t\tkey: plugin,\n\t\t\tappendTransaction: (transactions, __, state) => {\n\t\t\t\tconst { doc, tr, schema } = state;\n\t\t\t\tconst shouldInsertNodeAtEnd = plugin.getState(state);\n\t\t\t\tconst endPosition = doc.content.size;\n\t\t\t\tconst type = schema.nodes[defaultNode];\n\t\t\t\tif (transactions.some((transaction) => transaction.getMeta(\"skipTrailingNode\"))) return;\n\t\t\t\tif (!shouldInsertNodeAtEnd) return;\n\t\t\t\treturn tr.insert(endPosition, type.create());\n\t\t\t},\n\t\t\tstate: {\n\t\t\t\tinit: (_, state) => {\n\t\t\t\t\tconst lastNode = state.tr.doc.lastChild;\n\t\t\t\t\treturn !nodeEqualsType({\n\t\t\t\t\t\tnode: lastNode,\n\t\t\t\t\t\ttypes: disabledNodes\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\tapply: (tr, value) => {\n\t\t\t\t\tif (!tr.docChanged) return value;\n\t\t\t\t\tif (tr.getMeta(\"__uniqueIDTransaction\")) return value;\n\t\t\t\t\tconst lastNode = tr.doc.lastChild;\n\t\t\t\t\treturn !nodeEqualsType({\n\t\t\t\t\t\tnode: lastNode,\n\t\t\t\t\t\ttypes: disabledNodes\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}\n\t\t})];\n\t}\n});\n//#endregion\n//#region src/undo-redo/undo-redo.ts\n/**\n* This extension allows you to undo and redo recent changes.\n* @see https://www.tiptap.dev/api/extensions/undo-redo\n*\n* **Important**: If the `@tiptap/extension-collaboration` package is used, make sure to remove\n* the `undo-redo` extension, as it is not compatible with the `collaboration` extension.\n*\n* `@tiptap/extension-collaboration` uses its own history implementation.\n*/\nconst UndoRedo = _tiptap_core.Extension.create({\n\tname: \"undoRedo\",\n\taddOptions() {\n\t\treturn {\n\t\t\tdepth: 100,\n\t\t\tnewGroupDelay: 500\n\t\t};\n\t},\n\taddCommands() {\n\t\treturn {\n\t\t\tundo: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_history.undo)(state, dispatch);\n\t\t\t},\n\t\t\tredo: () => ({ state, dispatch }) => {\n\t\t\t\treturn (0, _tiptap_pm_history.redo)(state, dispatch);\n\t\t\t}\n\t\t};\n\t},\n\taddProseMirrorPlugins() {\n\t\treturn [(0, _tiptap_pm_history.history)(this.options)];\n\t},\n\taddKeyboardShortcuts() {\n\t\treturn {\n\t\t\t\"Mod-z\": () => this.editor.commands.undo(),\n\t\t\t\"Shift-Mod-z\": () => this.editor.commands.redo(),\n\t\t\t\"Mod-y\": () => this.editor.commands.redo(),\n\t\t\t\"Mod-я\": () => this.editor.commands.undo(),\n\t\t\t\"Shift-Mod-я\": () => this.editor.commands.redo()\n\t\t};\n\t}\n});\n//#endregion\nexports.CharacterCount = CharacterCount;\nexports.DEFAULT_DATA_ATTRIBUTE = DEFAULT_DATA_ATTRIBUTE;\nexports.Dropcursor = Dropcursor;\nexports.Focus = Focus;\nexports.Gapcursor = Gapcursor;\nexports.PLUGIN_KEY = PLUGIN_KEY;\nexports.Placeholder = Placeholder;\nexports.Selection = Selection;\nexports.TrailingNode = TrailingNode;\nexports.UndoRedo = UndoRedo;\nexports.preparePlaceholderAttribute = preparePlaceholderAttribute;\nexports.skipTrailingNodeMeta = skipTrailingNodeMeta;\n\n//# sourceMappingURL=index.cjs.map","var prosemirror_commands = require(\"prosemirror-commands\");\nObject.keys(prosemirror_commands).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_commands[k];\n\t\t}\n\t});\n});\n","var prosemirror_dropcursor = require(\"prosemirror-dropcursor\");\nObject.keys(prosemirror_dropcursor).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_dropcursor[k];\n\t\t}\n\t});\n});\n","var prosemirror_gapcursor = require(\"prosemirror-gapcursor\");\nObject.keys(prosemirror_gapcursor).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_gapcursor[k];\n\t\t}\n\t});\n});\n","var prosemirror_history = require(\"prosemirror-history\");\nObject.keys(prosemirror_history).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_history[k];\n\t\t}\n\t});\n});\n","var prosemirror_keymap = require(\"prosemirror-keymap\");\nObject.keys(prosemirror_keymap).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_keymap[k];\n\t\t}\n\t});\n});\n","var prosemirror_model = require(\"prosemirror-model\");\nObject.keys(prosemirror_model).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_model[k];\n\t\t}\n\t});\n});\n","var prosemirror_schema_list = require(\"prosemirror-schema-list\");\nObject.keys(prosemirror_schema_list).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_schema_list[k];\n\t\t}\n\t});\n});\n","var prosemirror_state = require(\"prosemirror-state\");\nObject.keys(prosemirror_state).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_state[k];\n\t\t}\n\t});\n});\n","var prosemirror_tables = require(\"prosemirror-tables\");\nObject.keys(prosemirror_tables).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_tables[k];\n\t\t}\n\t});\n});\n","var prosemirror_transform = require(\"prosemirror-transform\");\nObject.keys(prosemirror_transform).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_transform[k];\n\t\t}\n\t});\n});\n","var prosemirror_view = require(\"prosemirror-view\");\nObject.keys(prosemirror_view).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn prosemirror_view[k];\n\t\t}\n\t});\n});\n","\"use client\";\nObject.defineProperty(exports, Symbol.toStringTag, { value: \"Module\" });\n//#region \\0rolldown/runtime.js\nvar __create = Object.create;\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __getProtoOf = Object.getPrototypeOf;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __copyProps = (to, from, except, desc) => {\n\tif (from && typeof from === \"object\" || typeof from === \"function\") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {\n\t\tkey = keys[i];\n\t\tif (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {\n\t\t\tget: ((k) => from[k]).bind(null, key),\n\t\t\tenumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable\n\t\t});\n\t}\n\treturn to;\n};\nvar __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, \"default\") ? __defProp(target, \"default\", {\n\tvalue: mod,\n\tenumerable: true\n}) : target, mod));\n//#endregion\nlet react = require(\"react\");\nreact = __toESM(react, 1);\nlet react_dom = require(\"react-dom\");\nreact_dom = __toESM(react_dom, 1);\nlet use_sync_external_store_shim_index_js = require(\"use-sync-external-store/shim/index.js\");\nlet react_jsx_runtime = require(\"react/jsx-runtime\");\nlet _tiptap_core = require(\"@tiptap/core\");\nlet fast_equals = require(\"fast-equals\");\nlet use_sync_external_store_shim_with_selector_js = require(\"use-sync-external-store/shim/with-selector.js\");\n//#region src/EditorContent.tsx\nconst mergeRefs = (...refs) => {\n\treturn (node) => {\n\t\trefs.forEach((ref) => {\n\t\t\tif (typeof ref === \"function\") ref(node);\n\t\t\telse if (ref) ref.current = node;\n\t\t});\n\t};\n};\n/**\n* This component renders all of the editor's node views.\n*/\nconst Portals = ({ contentComponent }) => {\n\tconst renderers = (0, use_sync_external_store_shim_index_js.useSyncExternalStore)(contentComponent.subscribe, contentComponent.getSnapshot, contentComponent.getServerSnapshot);\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(react_jsx_runtime.Fragment, { children: Object.values(renderers) });\n};\nfunction createContentComponent() {\n\tconst subscribers = /* @__PURE__ */ new Set();\n\tlet renderers = {};\n\tlet isNotificationQueued = false;\n\tconst notifySubscribers = () => {\n\t\tif (isNotificationQueued || !subscribers.size) return;\n\t\tisNotificationQueued = true;\n\t\tqueueMicrotask(() => {\n\t\t\tisNotificationQueued = false;\n\t\t\tsubscribers.forEach((subscriber) => subscriber());\n\t\t});\n\t};\n\treturn {\n\t\t/**\n\t\t* Subscribe to the editor instance's changes.\n\t\t*/\n\t\tsubscribe(callback) {\n\t\t\tsubscribers.add(callback);\n\t\t\treturn () => {\n\t\t\t\tsubscribers.delete(callback);\n\t\t\t};\n\t\t},\n\t\tgetSnapshot() {\n\t\t\treturn renderers;\n\t\t},\n\t\tgetServerSnapshot() {\n\t\t\treturn renderers;\n\t\t},\n\t\t/**\n\t\t* Adds a new NodeView Renderer to the editor.\n\t\t*/\n\t\tsetRenderer(id, renderer) {\n\t\t\trenderers = {\n\t\t\t\t...renderers,\n\t\t\t\t[id]: react_dom.default.createPortal(renderer.reactElement, renderer.element, id)\n\t\t\t};\n\t\t\tnotifySubscribers();\n\t\t},\n\t\t/**\n\t\t* Removes a NodeView Renderer from the editor.\n\t\t*/\n\t\tremoveRenderer(id) {\n\t\t\tconst nextRenderers = { ...renderers };\n\t\t\tdelete nextRenderers[id];\n\t\t\trenderers = nextRenderers;\n\t\t\tnotifySubscribers();\n\t\t}\n\t};\n}\nvar PureEditorContent = class extends react.default.Component {\n\tconstructor(props) {\n\t\tsuper(props);\n\t\tthis.editorContentRef = react.default.createRef();\n\t}\n\tcomponentDidMount() {\n\t\tthis.init();\n\t}\n\tcomponentDidUpdate() {\n\t\tthis.init();\n\t}\n\tinit() {\n\t\tvar _editor$view$dom;\n\t\tconst editor = this.props.editor;\n\t\tif (editor && !editor.isDestroyed && ((_editor$view$dom = editor.view.dom) === null || _editor$view$dom === void 0 ? void 0 : _editor$view$dom.parentNode)) {\n\t\t\tif (editor.contentComponent) return;\n\t\t\tconst element = this.editorContentRef.current;\n\t\t\telement.append(...editor.view.dom.parentNode.childNodes);\n\t\t\teditor.setOptions({ element });\n\t\t\teditor.contentComponent = createContentComponent();\n\t\t\teditor.createNodeViews();\n\t\t\teditor.isEditorContentInitialized = true;\n\t\t\tthis.forceUpdate();\n\t\t}\n\t}\n\tcomponentWillUnmount() {\n\t\tconst editor = this.props.editor;\n\t\tif (!editor) return;\n\t\teditor.isEditorContentInitialized = false;\n\t\tif (!editor.isDestroyed) editor.view.setProps({ nodeViews: {} });\n\t\teditor.contentComponent = null;\n\t\ttry {\n\t\t\tvar _editor$view$dom2;\n\t\t\tif (!((_editor$view$dom2 = editor.view.dom) === null || _editor$view$dom2 === void 0 ? void 0 : _editor$view$dom2.parentNode)) return;\n\t\t\tconst newElement = document.createElement(\"div\");\n\t\t\tnewElement.append(...editor.view.dom.parentNode.childNodes);\n\t\t\teditor.setOptions({ element: newElement });\n\t\t} catch {}\n\t}\n\trender() {\n\t\tconst { editor, innerRef, ...rest } = this.props;\n\t\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(\"div\", {\n\t\t\tref: mergeRefs(innerRef, this.editorContentRef),\n\t\t\t...rest\n\t\t}), (editor === null || editor === void 0 ? void 0 : editor.contentComponent) && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Portals, { contentComponent: editor.contentComponent })] });\n\t}\n};\nconst EditorContentWithKey = (0, react.forwardRef)((props, ref) => {\n\tconst key = react.default.useMemo(() => {\n\t\treturn Math.floor(Math.random() * 4294967295).toString();\n\t}, [props.editor]);\n\treturn react.default.createElement(PureEditorContent, {\n\t\tkey,\n\t\tinnerRef: ref,\n\t\t...props\n\t});\n});\nconst EditorContent = react.default.memo(EditorContentWithKey);\n//#endregion\n//#region src/useEditorState.ts\nconst useIsomorphicLayoutEffect = typeof window !== \"undefined\" ? react.useLayoutEffect : react.useEffect;\n/**\n* To synchronize the editor instance with the component state,\n* we need to create a separate instance that is not affected by the component re-renders.\n*/\nvar EditorStateManager = class {\n\tconstructor(initialEditor) {\n\t\tthis.transactionNumber = 0;\n\t\tthis.lastTransactionNumber = 0;\n\t\tthis.subscribers = /* @__PURE__ */ new Set();\n\t\tthis.editor = initialEditor;\n\t\tthis.lastSnapshot = {\n\t\t\teditor: initialEditor,\n\t\t\ttransactionNumber: 0\n\t\t};\n\t\tthis.getSnapshot = this.getSnapshot.bind(this);\n\t\tthis.getServerSnapshot = this.getServerSnapshot.bind(this);\n\t\tthis.watch = this.watch.bind(this);\n\t\tthis.subscribe = this.subscribe.bind(this);\n\t}\n\t/**\n\t* Get the current editor instance.\n\t*/\n\tgetSnapshot() {\n\t\tif (this.transactionNumber === this.lastTransactionNumber) return this.lastSnapshot;\n\t\tthis.lastTransactionNumber = this.transactionNumber;\n\t\tthis.lastSnapshot = {\n\t\t\teditor: this.editor,\n\t\t\ttransactionNumber: this.transactionNumber\n\t\t};\n\t\treturn this.lastSnapshot;\n\t}\n\t/**\n\t* Always disable the editor on the server-side.\n\t*/\n\tgetServerSnapshot() {\n\t\treturn {\n\t\t\teditor: null,\n\t\t\ttransactionNumber: 0\n\t\t};\n\t}\n\t/**\n\t* Subscribe to the editor instance's changes.\n\t*/\n\tsubscribe(callback) {\n\t\tthis.subscribers.add(callback);\n\t\treturn () => {\n\t\t\tthis.subscribers.delete(callback);\n\t\t};\n\t}\n\t/**\n\t* Watch the editor instance for changes.\n\t*/\n\twatch(nextEditor) {\n\t\tthis.editor = nextEditor;\n\t\tif (this.editor) {\n\t\t\t/**\n\t\t\t* This will force a re-render when the editor state changes.\n\t\t\t* This is to support things like `editor.can().toggleBold()` in components that `useEditor`.\n\t\t\t* This could be more efficient, but it's a good trade-off for now.\n\t\t\t*/\n\t\t\tlet lastTransaction;\n\t\t\tconst fn = (props) => {\n\t\t\t\tif ((props === null || props === void 0 ? void 0 : props.transaction) !== void 0 && props.transaction === lastTransaction) return;\n\t\t\t\tlastTransaction = props === null || props === void 0 ? void 0 : props.transaction;\n\t\t\t\tthis.transactionNumber += 1;\n\t\t\t\tthis.subscribers.forEach((callback) => callback());\n\t\t\t};\n\t\t\tconst currentEditor = this.editor;\n\t\t\tcurrentEditor.on(\"transaction\", fn);\n\t\t\tcurrentEditor.on(\"update\", fn);\n\t\t\treturn () => {\n\t\t\t\tcurrentEditor.off(\"transaction\", fn);\n\t\t\t\tcurrentEditor.off(\"update\", fn);\n\t\t\t};\n\t\t}\n\t}\n};\n/**\n* This hook allows you to watch for changes on the editor instance.\n* It will allow you to select a part of the editor state and re-render the component when it changes.\n* @example\n* ```tsx\n* const editor = useEditor({...options})\n* const { currentSelection } = useEditorState({\n* editor,\n* selector: snapshot => ({ currentSelection: snapshot.editor.state.selection }),\n* })\n*/\nfunction useEditorState(options) {\n\tvar _options$equalityFn;\n\tconst [editorStateManager] = (0, react.useState)(() => new EditorStateManager(options.editor));\n\tconst selectedState = (0, use_sync_external_store_shim_with_selector_js.useSyncExternalStoreWithSelector)(editorStateManager.subscribe, editorStateManager.getSnapshot, editorStateManager.getServerSnapshot, options.selector, (_options$equalityFn = options.equalityFn) !== null && _options$equalityFn !== void 0 ? _options$equalityFn : fast_equals.deepEqual);\n\tuseIsomorphicLayoutEffect(() => {\n\t\treturn editorStateManager.watch(options.editor);\n\t}, [options.editor, editorStateManager]);\n\t(0, react.useDebugValue)(selectedState);\n\treturn selectedState;\n}\n//#endregion\n//#region src/useEditor.ts\nconst isDev = process.env.NODE_ENV !== \"production\";\nconst isSSR = typeof window === \"undefined\";\nconst isNext = isSSR || Boolean(typeof window !== \"undefined\" && window.next);\n/**\n* This class handles the creation, destruction, and re-creation of the editor instance.\n*/\nvar EditorInstanceManager = class EditorInstanceManager {\n\tconstructor(options) {\n\t\tthis.editor = null;\n\t\tthis.subscriptions = /* @__PURE__ */ new Set();\n\t\tthis.isComponentMounted = false;\n\t\tthis.previousDeps = null;\n\t\tthis.instanceId = \"\";\n\t\tthis.options = options;\n\t\tthis.subscriptions = /* @__PURE__ */ new Set();\n\t\tthis.setEditor(this.getInitialEditor());\n\t\tthis.scheduleDestroy();\n\t\tthis.getEditor = this.getEditor.bind(this);\n\t\tthis.getServerSnapshot = this.getServerSnapshot.bind(this);\n\t\tthis.subscribe = this.subscribe.bind(this);\n\t\tthis.refreshEditorInstance = this.refreshEditorInstance.bind(this);\n\t\tthis.scheduleDestroy = this.scheduleDestroy.bind(this);\n\t\tthis.onRender = this.onRender.bind(this);\n\t\tthis.createEditor = this.createEditor.bind(this);\n\t}\n\tsetEditor(editor) {\n\t\tthis.editor = editor;\n\t\tthis.instanceId = Math.random().toString(36).slice(2, 9);\n\t\tthis.subscriptions.forEach((cb) => cb());\n\t}\n\tgetInitialEditor() {\n\t\tconst explicit = this.options.current.immediatelyRender;\n\t\tlet immediatelyRender = explicit !== null && explicit !== void 0 ? explicit : true;\n\t\tif (isSSR) {\n\t\t\tif (immediatelyRender && isDev) console.warn(\"SSR detected. `immediatelyRender` has been set to false to avoid hydration mismatches\");\n\t\t\timmediatelyRender = false;\n\t\t} else if (isNext && explicit === void 0) {\n\t\t\timmediatelyRender = false;\n\t\t\tif (isDev) console.warn(\"Next.js detected. `immediatelyRender` defaults to false to avoid hydration mismatches. Pass `immediatelyRender: true` explicitly if you are rendering the editor only on the client.\");\n\t\t}\n\t\treturn immediatelyRender ? this.createEditor() : null;\n\t}\n\t/**\n\t* Create a new editor instance. And attach event listeners.\n\t*/\n\tcreateEditor() {\n\t\tconst optionsToApply = {\n\t\t\t...this.options.current,\n\t\t\tonBeforeCreate: (...args) => {\n\t\t\t\tvar _this$options$current, _this$options$current2;\n\t\t\t\treturn (_this$options$current = (_this$options$current2 = this.options.current).onBeforeCreate) === null || _this$options$current === void 0 ? void 0 : _this$options$current.call(_this$options$current2, ...args);\n\t\t\t},\n\t\t\tonBlur: (...args) => {\n\t\t\t\tvar _this$options$current3, _this$options$current4;\n\t\t\t\treturn (_this$options$current3 = (_this$options$current4 = this.options.current).onBlur) === null || _this$options$current3 === void 0 ? void 0 : _this$options$current3.call(_this$options$current4, ...args);\n\t\t\t},\n\t\t\tonCreate: (...args) => {\n\t\t\t\tvar _this$options$current5, _this$options$current6;\n\t\t\t\treturn (_this$options$current5 = (_this$options$current6 = this.options.current).onCreate) === null || _this$options$current5 === void 0 ? void 0 : _this$options$current5.call(_this$options$current6, ...args);\n\t\t\t},\n\t\t\tonDestroy: (...args) => {\n\t\t\t\tvar _this$options$current7, _this$options$current8;\n\t\t\t\treturn (_this$options$current7 = (_this$options$current8 = this.options.current).onDestroy) === null || _this$options$current7 === void 0 ? void 0 : _this$options$current7.call(_this$options$current8, ...args);\n\t\t\t},\n\t\t\tonFocus: (...args) => {\n\t\t\t\tvar _this$options$current9, _this$options$current10;\n\t\t\t\treturn (_this$options$current9 = (_this$options$current10 = this.options.current).onFocus) === null || _this$options$current9 === void 0 ? void 0 : _this$options$current9.call(_this$options$current10, ...args);\n\t\t\t},\n\t\t\tonSelectionUpdate: (...args) => {\n\t\t\t\tvar _this$options$current11, _this$options$current12;\n\t\t\t\treturn (_this$options$current11 = (_this$options$current12 = this.options.current).onSelectionUpdate) === null || _this$options$current11 === void 0 ? void 0 : _this$options$current11.call(_this$options$current12, ...args);\n\t\t\t},\n\t\t\tonTransaction: (...args) => {\n\t\t\t\tvar _this$options$current13, _this$options$current14;\n\t\t\t\treturn (_this$options$current13 = (_this$options$current14 = this.options.current).onTransaction) === null || _this$options$current13 === void 0 ? void 0 : _this$options$current13.call(_this$options$current14, ...args);\n\t\t\t},\n\t\t\tonUpdate: (...args) => {\n\t\t\t\tvar _this$options$current15, _this$options$current16;\n\t\t\t\treturn (_this$options$current15 = (_this$options$current16 = this.options.current).onUpdate) === null || _this$options$current15 === void 0 ? void 0 : _this$options$current15.call(_this$options$current16, ...args);\n\t\t\t},\n\t\t\tonContentError: (...args) => {\n\t\t\t\tvar _this$options$current17, _this$options$current18;\n\t\t\t\treturn (_this$options$current17 = (_this$options$current18 = this.options.current).onContentError) === null || _this$options$current17 === void 0 ? void 0 : _this$options$current17.call(_this$options$current18, ...args);\n\t\t\t},\n\t\t\tonDrop: (...args) => {\n\t\t\t\tvar _this$options$current19, _this$options$current20;\n\t\t\t\treturn (_this$options$current19 = (_this$options$current20 = this.options.current).onDrop) === null || _this$options$current19 === void 0 ? void 0 : _this$options$current19.call(_this$options$current20, ...args);\n\t\t\t},\n\t\t\tonPaste: (...args) => {\n\t\t\t\tvar _this$options$current21, _this$options$current22;\n\t\t\t\treturn (_this$options$current21 = (_this$options$current22 = this.options.current).onPaste) === null || _this$options$current21 === void 0 ? void 0 : _this$options$current21.call(_this$options$current22, ...args);\n\t\t\t},\n\t\t\tonDelete: (...args) => {\n\t\t\t\tvar _this$options$current23, _this$options$current24;\n\t\t\t\treturn (_this$options$current23 = (_this$options$current24 = this.options.current).onDelete) === null || _this$options$current23 === void 0 ? void 0 : _this$options$current23.call(_this$options$current24, ...args);\n\t\t\t},\n\t\t\tonMount: (...args) => {\n\t\t\t\tvar _this$options$current25, _this$options$current26;\n\t\t\t\treturn (_this$options$current25 = (_this$options$current26 = this.options.current).onMount) === null || _this$options$current25 === void 0 ? void 0 : _this$options$current25.call(_this$options$current26, ...args);\n\t\t\t},\n\t\t\tonUnmount: (...args) => {\n\t\t\t\tvar _this$options$current27, _this$options$current28;\n\t\t\t\treturn (_this$options$current27 = (_this$options$current28 = this.options.current).onUnmount) === null || _this$options$current27 === void 0 ? void 0 : _this$options$current27.call(_this$options$current28, ...args);\n\t\t\t}\n\t\t};\n\t\treturn new _tiptap_core.Editor(optionsToApply);\n\t}\n\t/**\n\t* Get the current editor instance.\n\t*/\n\tgetEditor() {\n\t\treturn this.editor;\n\t}\n\t/**\n\t* Always disable the editor on the server-side.\n\t*/\n\tgetServerSnapshot() {\n\t\treturn null;\n\t}\n\t/**\n\t* Subscribe to the editor instance's changes.\n\t*/\n\tsubscribe(onStoreChange) {\n\t\tthis.subscriptions.add(onStoreChange);\n\t\treturn () => {\n\t\t\tthis.subscriptions.delete(onStoreChange);\n\t\t};\n\t}\n\tstatic compareOptions(a, b) {\n\t\treturn Object.keys(a).every((key) => {\n\t\t\tif ([\n\t\t\t\t\"onCreate\",\n\t\t\t\t\"onBeforeCreate\",\n\t\t\t\t\"onDestroy\",\n\t\t\t\t\"onUpdate\",\n\t\t\t\t\"onTransaction\",\n\t\t\t\t\"onFocus\",\n\t\t\t\t\"onBlur\",\n\t\t\t\t\"onSelectionUpdate\",\n\t\t\t\t\"onContentError\",\n\t\t\t\t\"onDrop\",\n\t\t\t\t\"onPaste\"\n\t\t\t].includes(key)) return true;\n\t\t\tif (key === \"extensions\" && a.extensions && b.extensions) {\n\t\t\t\tif (a.extensions.length !== b.extensions.length) return false;\n\t\t\t\treturn a.extensions.every((extension, index) => {\n\t\t\t\t\tvar _b$extensions;\n\t\t\t\t\tif (extension !== ((_b$extensions = b.extensions) === null || _b$extensions === void 0 ? void 0 : _b$extensions[index])) return false;\n\t\t\t\t\treturn true;\n\t\t\t\t});\n\t\t\t}\n\t\t\tif (a[key] !== b[key]) return false;\n\t\t\treturn true;\n\t\t});\n\t}\n\t/**\n\t* On each render, we will create, update, or destroy the editor instance.\n\t* @param deps The dependencies to watch for changes\n\t* @returns A cleanup function\n\t*/\n\tonRender(deps) {\n\t\treturn () => {\n\t\t\tthis.isComponentMounted = true;\n\t\t\tclearTimeout(this.scheduledDestructionTimeout);\n\t\t\tif (this.editor && !this.editor.isDestroyed && deps.length === 0) {\n\t\t\t\tif (!EditorInstanceManager.compareOptions(this.options.current, this.editor.options)) this.editor.setOptions({\n\t\t\t\t\t...this.options.current,\n\t\t\t\t\teditable: this.editor.isEditable\n\t\t\t\t});\n\t\t\t} else this.refreshEditorInstance(deps);\n\t\t\treturn () => {\n\t\t\t\tthis.isComponentMounted = false;\n\t\t\t\tthis.scheduleDestroy();\n\t\t\t};\n\t\t};\n\t}\n\t/**\n\t* Recreate the editor instance if the dependencies have changed.\n\t*/\n\trefreshEditorInstance(deps) {\n\t\tif (this.editor && !this.editor.isDestroyed) {\n\t\t\tif (this.previousDeps === null) {\n\t\t\t\tthis.previousDeps = deps;\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (this.previousDeps.length === deps.length && this.previousDeps.every((dep, index) => dep === deps[index])) return;\n\t\t}\n\t\tif (this.editor && !this.editor.isDestroyed) this.editor.destroy();\n\t\tthis.setEditor(this.createEditor());\n\t\tthis.previousDeps = deps;\n\t}\n\t/**\n\t* Schedule the destruction of the editor instance.\n\t* This will only destroy the editor if it was not mounted on the next tick.\n\t* This is to avoid destroying the editor instance when it's actually still mounted.\n\t*/\n\tscheduleDestroy() {\n\t\tconst currentInstanceId = this.instanceId;\n\t\tconst currentEditor = this.editor;\n\t\tthis.scheduledDestructionTimeout = setTimeout(() => {\n\t\t\tif (this.isComponentMounted && this.instanceId === currentInstanceId) {\n\t\t\t\tif (currentEditor) currentEditor.setOptions(this.options.current);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (currentEditor && !currentEditor.isDestroyed) {\n\t\t\t\tcurrentEditor.destroy();\n\t\t\t\tif (this.instanceId === currentInstanceId) this.setEditor(null);\n\t\t\t}\n\t\t}, 1);\n\t}\n};\nfunction useEditor(options = {}, deps = []) {\n\tconst mostRecentOptions = (0, react.useRef)(options);\n\tmostRecentOptions.current = options;\n\tconst [instanceManager] = (0, react.useState)(() => new EditorInstanceManager(mostRecentOptions));\n\tconst editor = (0, use_sync_external_store_shim_index_js.useSyncExternalStore)(instanceManager.subscribe, instanceManager.getEditor, instanceManager.getServerSnapshot);\n\t(0, react.useDebugValue)(editor);\n\t(0, react.useEffect)(instanceManager.onRender(deps));\n\tuseEditorState({\n\t\teditor,\n\t\tselector: ({ transactionNumber }) => {\n\t\t\tif (options.shouldRerenderOnTransaction === false || options.shouldRerenderOnTransaction === void 0) return null;\n\t\t\tif (options.immediatelyRender && transactionNumber === 0) return 0;\n\t\t\treturn transactionNumber + 1;\n\t\t}\n\t});\n\treturn editor;\n}\n//#endregion\n//#region src/Context.tsx\nconst EditorContext = (0, react.createContext)({ editor: null });\nconst EditorConsumer = EditorContext.Consumer;\n/**\n* A hook to get the current editor instance.\n*/\nconst useCurrentEditor = () => (0, react.useContext)(EditorContext);\n/**\n* This is the provider component for the editor.\n* It allows the editor to be accessible across the entire component tree\n* with `useCurrentEditor`.\n*/\nfunction EditorProvider({ children, slotAfter, slotBefore, editorContainerProps = {}, ...editorOptions }) {\n\tconst editor = useEditor(editorOptions);\n\tconst contextValue = (0, react.useMemo)(() => ({ editor }), [editor]);\n\tif (!editor) return null;\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(EditorContext.Provider, {\n\t\tvalue: contextValue,\n\t\tchildren: [\n\t\t\tslotBefore,\n\t\t\t/* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorConsumer, { children: ({ editor: currentEditor }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorContent, {\n\t\t\t\teditor: currentEditor,\n\t\t\t\t...editorContainerProps\n\t\t\t}) }),\n\t\t\tchildren,\n\t\t\tslotAfter\n\t\t]\n\t});\n}\n//#endregion\n//#region src/useReactNodeView.ts\nconst ReactNodeViewContext = (0, react.createContext)({\n\tonDragStart: () => {},\n\tnodeViewContentChildren: void 0,\n\tnodeViewContentRef: () => {}\n});\nconst ReactNodeViewContentProvider = ({ children, content }) => {\n\treturn (0, react.createElement)(ReactNodeViewContext.Provider, { value: { nodeViewContentChildren: content } }, children);\n};\nconst useReactNodeView = () => (0, react.useContext)(ReactNodeViewContext);\n//#endregion\n//#region src/NodeViewContent.tsx\nfunction NodeViewContent({ as: Tag = \"div\", ...props }) {\n\tconst { nodeViewContentRef, nodeViewContentChildren } = useReactNodeView();\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {\n\t\t...props,\n\t\tref: nodeViewContentRef,\n\t\t\"data-node-view-content\": \"\",\n\t\tstyle: {\n\t\t\twhiteSpace: \"pre-wrap\",\n\t\t\t...props.style\n\t\t},\n\t\tchildren: nodeViewContentChildren\n\t});\n}\n//#endregion\n//#region src/NodeViewWrapper.tsx\nconst NodeViewWrapper = react.default.forwardRef((props, ref) => {\n\tconst { onDragStart } = useReactNodeView();\n\tconst Tag = props.as || \"div\";\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {\n\t\t...props,\n\t\tref,\n\t\t\"data-node-view-wrapper\": \"\",\n\t\tonDragStart,\n\t\tstyle: {\n\t\t\twhiteSpace: \"normal\",\n\t\t\t...props.style\n\t\t}\n\t});\n});\n//#endregion\n//#region src/ReactRenderer.tsx\n/**\n* Check if a component is a class component.\n* @param Component\n* @returns {boolean}\n*/\nfunction isClassComponent(Component) {\n\treturn !!(typeof Component === \"function\" && Component.prototype && Component.prototype.isReactComponent);\n}\n/**\n* Check if a component is a forward ref component.\n* @param Component\n* @returns {boolean}\n*/\nfunction isForwardRefComponent(Component) {\n\treturn !!(typeof Component === \"object\" && Component.$$typeof && (Component.$$typeof.toString() === \"Symbol(react.forward_ref)\" || Component.$$typeof.description === \"react.forward_ref\"));\n}\n/**\n* Check if a component is a memoized component.\n* @param Component\n* @returns {boolean}\n*/\nfunction isMemoComponent(Component) {\n\treturn !!(typeof Component === \"object\" && Component.$$typeof && (Component.$$typeof.toString() === \"Symbol(react.memo)\" || Component.$$typeof.description === \"react.memo\"));\n}\n/**\n* Check if a component can safely receive a ref prop.\n* This includes class components, forwardRef components, and memoized components\n* that wrap forwardRef or class components.\n* @param Component\n* @returns {boolean}\n*/\nfunction canReceiveRef(Component) {\n\tif (isClassComponent(Component)) return true;\n\tif (isForwardRefComponent(Component)) return true;\n\tif (isMemoComponent(Component)) {\n\t\tconst wrappedComponent = Component.type;\n\t\tif (wrappedComponent) return isClassComponent(wrappedComponent) || isForwardRefComponent(wrappedComponent);\n\t}\n\treturn false;\n}\n/**\n* Check if we're running React 19+ by detecting if function components support ref props\n* @returns {boolean}\n*/\nfunction isReact19Plus() {\n\ttry {\n\t\tif (react.version) return parseInt(react.version.split(\".\")[0], 10) >= 19;\n\t} catch {}\n\treturn false;\n}\n/**\n* The ReactRenderer class. It's responsible for rendering React components inside the editor.\n* @example\n* new ReactRenderer(MyComponent, {\n* editor,\n* props: {\n* foo: 'bar',\n* },\n* as: 'span',\n* })\n*/\nvar ReactRenderer = class {\n\t/**\n\t* Immediately creates element and renders the provided React component.\n\t*/\n\tconstructor(component, { editor, props = {}, as = \"div\", className = \"\" }) {\n\t\tthis.ref = null;\n\t\tthis.destroyed = false;\n\t\tthis.id = Math.floor(Math.random() * 4294967295).toString();\n\t\tthis.component = component;\n\t\tthis.editor = editor;\n\t\tthis.props = props;\n\t\tthis.element = document.createElement(as);\n\t\tthis.element.classList.add(\"react-renderer\");\n\t\tif (className) this.element.classList.add(...className.split(\" \"));\n\t\tif (this.editor.isEditorContentInitialized) (0, react_dom.flushSync)(() => {\n\t\t\tthis.render();\n\t\t});\n\t\telse queueMicrotask(() => {\n\t\t\tif (this.destroyed) return;\n\t\t\tthis.render();\n\t\t});\n\t}\n\t/**\n\t* Render the React component.\n\t*/\n\trender() {\n\t\tvar _editor$contentCompon;\n\t\tif (this.destroyed) return;\n\t\tconst Component = this.component;\n\t\tconst props = this.props;\n\t\tconst editor = this.editor;\n\t\tconst isReact19 = isReact19Plus();\n\t\tconst componentCanReceiveRef = canReceiveRef(Component);\n\t\tconst elementProps = { ...props };\n\t\tif (elementProps.ref && !(isReact19 || componentCanReceiveRef)) delete elementProps.ref;\n\t\tif (!elementProps.ref && (isReact19 || componentCanReceiveRef)) elementProps.ref = (ref) => {\n\t\t\tthis.ref = ref;\n\t\t};\n\t\tthis.reactElement = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Component, { ...elementProps });\n\t\teditor === null || editor === void 0 || (_editor$contentCompon = editor.contentComponent) === null || _editor$contentCompon === void 0 || _editor$contentCompon.setRenderer(this.id, this);\n\t}\n\t/**\n\t* Re-renders the React component with new props.\n\t* Skips the render if none of the supplied props actually changed,\n\t* to avoid unnecessary portal re-creation.\n\t*/\n\tupdateProps(props = {}) {\n\t\tif (this.destroyed) return;\n\t\tlet changed = false;\n\t\tconst keys = Object.keys(props);\n\t\tfor (let i = 0; i < keys.length; i += 1) {\n\t\t\tconst key = keys[i];\n\t\t\tif (props[key] !== this.props[key]) {\n\t\t\t\tchanged = true;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (!changed) return;\n\t\tthis.props = {\n\t\t\t...this.props,\n\t\t\t...props\n\t\t};\n\t\tthis.render();\n\t}\n\t/**\n\t* Destroy the React component.\n\t*/\n\tdestroy() {\n\t\tvar _editor$contentCompon2;\n\t\tthis.destroyed = true;\n\t\tconst editor = this.editor;\n\t\teditor === null || editor === void 0 || (_editor$contentCompon2 = editor.contentComponent) === null || _editor$contentCompon2 === void 0 || _editor$contentCompon2.removeRenderer(this.id);\n\t\ttry {\n\t\t\tif (this.element && this.element.parentNode) this.element.parentNode.removeChild(this.element);\n\t\t} catch {}\n\t}\n\t/**\n\t* Update the attributes of the element that holds the React component.\n\t*/\n\tupdateAttributes(attributes) {\n\t\tObject.keys(attributes).forEach((key) => {\n\t\t\tthis.element.setAttribute(key, attributes[key]);\n\t\t});\n\t}\n};\n//#endregion\n//#region src/ReactMarkViewRenderer.tsx\nconst ReactMarkViewContext = react.default.createContext({ markViewContentRef: () => {} });\nconst MarkViewContent = (props) => {\n\tconst { as: Tag = \"span\", ...rest } = props;\n\tconst { markViewContentRef } = react.default.useContext(ReactMarkViewContext);\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Tag, {\n\t\t...rest,\n\t\tref: markViewContentRef,\n\t\t\"data-mark-view-content\": \"\"\n\t});\n};\nvar ReactMarkView = class extends _tiptap_core.MarkView {\n\tconstructor(component, props, options) {\n\t\tsuper(component, props, options);\n\t\tconst { as = \"span\", attrs, className = \"\" } = options || {};\n\t\tconst componentProps = {\n\t\t\t...props,\n\t\t\tupdateAttributes: this.updateAttributes.bind(this)\n\t\t};\n\t\tthis.contentDOMElement = document.createElement(\"span\");\n\t\tconst markViewContentRef = (el) => {\n\t\t\tif (el && !el.contains(this.contentDOMElement)) el.appendChild(this.contentDOMElement);\n\t\t};\n\t\tconst context = { markViewContentRef };\n\t\tconst ReactMarkViewProvider = react.default.memo((componentProps) => {\n\t\t\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReactMarkViewContext.Provider, {\n\t\t\t\tvalue: context,\n\t\t\t\tchildren: react.default.createElement(component, componentProps)\n\t\t\t});\n\t\t});\n\t\tReactMarkViewProvider.displayName = \"ReactMarkView\";\n\t\tthis.renderer = new ReactRenderer(ReactMarkViewProvider, {\n\t\t\teditor: props.editor,\n\t\t\tprops: componentProps,\n\t\t\tas,\n\t\t\tclassName: `mark-${props.mark.type.name} ${className}`.trim()\n\t\t});\n\t\tif (attrs) this.renderer.updateAttributes(attrs);\n\t}\n\tget dom() {\n\t\treturn this.renderer.element;\n\t}\n\tget contentDOM() {\n\t\treturn this.contentDOMElement;\n\t}\n};\nfunction ReactMarkViewRenderer(component, options = {}) {\n\treturn (props) => new ReactMarkView(component, props, options);\n}\n//#endregion\n//#region src/captureDOMSelection.ts\n/**\n* Saves the DOM selection inside `element`, returns a function to put it back.\n* Browsers drop the selection when an element moves, so restore it after the move.\n*/\nfunction captureDOMSelection(element) {\n\tvar _element$ownerDocumen;\n\tconst root = element.getRootNode();\n\tconst selection = typeof root.getSelection === \"function\" ? root.getSelection() : (_element$ownerDocumen = element.ownerDocument) === null || _element$ownerDocumen === void 0 || (_element$ownerDocumen = _element$ownerDocumen.defaultView) === null || _element$ownerDocumen === void 0 ? void 0 : _element$ownerDocumen.getSelection();\n\tif (!selection || selection.rangeCount === 0) return null;\n\tconst { anchorNode, anchorOffset, focusNode, focusOffset } = selection;\n\tif (!anchorNode || !focusNode) return null;\n\tif (!element.contains(anchorNode) || !element.contains(focusNode)) return null;\n\treturn () => {\n\t\ttry {\n\t\t\tselection.setBaseAndExtent(anchorNode, anchorOffset, focusNode, focusOffset);\n\t\t} catch {}\n\t};\n}\n//#endregion\n//#region src/lib/utils/getTextSelectionAncestorPositions.ts\nfunction isSameAncestor($from, $to, depth) {\n\treturn $from.node(depth) === $to.node(depth) && $from.before(depth) === $to.before(depth);\n}\nfunction getTextSelectionAncestorPositions(selection) {\n\tif (!(0, _tiptap_core.isTextSelection)(selection)) return [];\n\tconst { $from, $to } = selection;\n\tconst positions = [];\n\tconst maxDepth = Math.min($from.depth, $to.depth);\n\tfor (let depth = 1; depth <= maxDepth; depth += 1) {\n\t\tif (!isSameAncestor($from, $to, depth)) break;\n\t\tpositions.push($from.before(depth));\n\t}\n\treturn positions;\n}\n//#endregion\n//#region src/ReactNodeViewSelectionTracker.ts\nvar ReactNodeViewSelectionTracker = class {\n\tconstructor(editor) {\n\t\tthis.views = /* @__PURE__ */ new WeakMap();\n\t\tthis.viewCount = 0;\n\t\tthis.insideViews = /* @__PURE__ */ new Set();\n\t\tthis.syncQueued = false;\n\t\tthis.scheduleSync = () => {\n\t\t\tif (this.syncQueued) return;\n\t\t\tthis.syncQueued = true;\n\t\t\tqueueMicrotask(() => {\n\t\t\t\tthis.syncQueued = false;\n\t\t\t\tthis.sync();\n\t\t\t});\n\t\t};\n\t\tthis.handleTransaction = () => this.scheduleSync();\n\t\tthis.editor = editor;\n\t}\n\tregister(view) {\n\t\tif (this.viewCount === 0) this.editor.on(\"transaction\", this.handleTransaction);\n\t\tthis.views.set(view.dom, view);\n\t\tthis.viewCount += 1;\n\t\tthis.scheduleSync();\n\t}\n\tunregister(view) {\n\t\tthis.views.delete(view.dom);\n\t\tthis.viewCount -= 1;\n\t\tthis.insideViews.delete(view);\n\t\tif (this.viewCount === 0) this.editor.off(\"transaction\", this.handleTransaction);\n\t}\n\tsync() {\n\t\tif (this.viewCount === 0 || this.editor.isDestroyed) return;\n\t\tconst nextInsideViews = this.findInsideViews();\n\t\tthis.updateViews(this.insideViews, nextInsideViews, false);\n\t\tthis.updateViews(nextInsideViews, this.insideViews, true);\n\t\tthis.insideViews = nextInsideViews;\n\t}\n\tupdateViews(views, unchangedViews, selectionInside) {\n\t\tfor (const view of views) if (!unchangedViews.has(view)) view.setSelectionInside(selectionInside);\n\t}\n\tfindInsideViews() {\n\t\tconst insideViews = /* @__PURE__ */ new Set();\n\t\tfor (const position of getTextSelectionAncestorPositions(this.editor.state.selection)) {\n\t\t\tconst dom = this.editor.view.nodeDOM(position);\n\t\t\tconst view = dom ? this.views.get(dom) : void 0;\n\t\t\tif (view) insideViews.add(view);\n\t\t}\n\t\treturn insideViews;\n\t}\n};\nconst trackers = /* @__PURE__ */ new WeakMap();\nfunction getReactNodeViewSelectionTracker(editor) {\n\tlet tracker = trackers.get(editor);\n\tif (!tracker) {\n\t\ttracker = new ReactNodeViewSelectionTracker(editor);\n\t\ttrackers.set(editor, tracker);\n\t}\n\treturn tracker;\n}\n//#endregion\n//#region src/ReactNodeViewRenderer.tsx\nvar ReactNodeView = class extends _tiptap_core.NodeView {\n\tconstructor(component, props, options) {\n\t\tsuper(component, props, options);\n\t\tthis.nodeSelected = false;\n\t\tthis.handlePositionUpdate = () => {\n\t\t\tconst newPos = this.getPos();\n\t\t\tif (typeof newPos !== \"number\" || newPos === this.currentPos) return;\n\t\t\tthis.currentPos = newPos;\n\t\t\tthis.renderer.updateProps({ getPos: () => this.getPos() });\n\t\t\tif (typeof this.options.attrs === \"function\") this.updateElementAttributes();\n\t\t};\n\t\tthis.cachedExtensionWithSyncedStorage = null;\n\t\tif (!this.node.isLeaf) {\n\t\t\tif (this.options.contentDOMElementTag) this.contentDOMElement = document.createElement(this.options.contentDOMElementTag);\n\t\t\telse this.contentDOMElement = document.createElement(this.node.isInline ? \"span\" : \"div\");\n\t\t\tthis.contentDOMElement.dataset.nodeViewContentReact = \"\";\n\t\t\tthis.contentDOMElement.dataset.nodeViewWrapper = \"\";\n\t\t\tthis.contentDOMElement.style.whiteSpace = \"inherit\";\n\t\t\tconst contentTarget = this.dom.querySelector(\"[data-node-view-content]\");\n\t\t\tif (contentTarget) contentTarget.appendChild(this.contentDOMElement);\n\t\t\telse this.dom.appendChild(this.contentDOMElement);\n\t\t}\n\t\tif (this.options.trackNodeViewPosition) this.editor.on(\"update\", this.handlePositionUpdate);\n\t}\n\t/**\n\t* Returns a proxy of the extension that redirects storage access to the editor's mutable storage.\n\t* This preserves the original prototype chain (instanceof checks, methods like configure/extend work).\n\t* Cached to avoid proxy creation on every update.\n\t*/\n\tget extensionWithSyncedStorage() {\n\t\tif (!this.cachedExtensionWithSyncedStorage) {\n\t\t\tconst editor = this.editor;\n\t\t\tconst extension = this.extension;\n\t\t\tthis.cachedExtensionWithSyncedStorage = new Proxy(extension, { get(target, prop, receiver) {\n\t\t\t\tif (prop === \"storage\") {\n\t\t\t\t\tvar _editor$storage;\n\t\t\t\t\treturn (_editor$storage = editor.storage[extension.name]) !== null && _editor$storage !== void 0 ? _editor$storage : {};\n\t\t\t\t}\n\t\t\t\treturn Reflect.get(target, prop, receiver);\n\t\t\t} });\n\t\t}\n\t\treturn this.cachedExtensionWithSyncedStorage;\n\t}\n\t/**\n\t* Setup the React component.\n\t* Called on initialization.\n\t*/\n\tmount() {\n\t\tconst mountProps = {\n\t\t\teditor: this.editor,\n\t\t\tnode: this.node,\n\t\t\tdecorations: this.decorations,\n\t\t\tinnerDecorations: this.innerDecorations,\n\t\t\tview: this.view,\n\t\t\tselected: false,\n\t\t\tselectionInside: false,\n\t\t\textension: this.extensionWithSyncedStorage,\n\t\t\tHTMLAttributes: this.HTMLAttributes,\n\t\t\tgetPos: () => this.getPos(),\n\t\t\tupdateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n\t\t\tdeleteNode: () => this.deleteNode(),\n\t\t\tref: (0, react.createRef)()\n\t\t};\n\t\tif (!this.component.displayName) {\n\t\t\tconst capitalizeFirstChar = (string) => {\n\t\t\t\treturn string.charAt(0).toUpperCase() + string.substring(1);\n\t\t\t};\n\t\t\tthis.component.displayName = capitalizeFirstChar(this.extension.name);\n\t\t}\n\t\tconst onDragStart = this.onDragStart.bind(this);\n\t\tconst nodeViewContentRef = (element) => {\n\t\t\tif (element && this.contentDOMElement && element.firstChild !== this.contentDOMElement) {\n\t\t\t\tif (element.hasAttribute(\"data-node-view-wrapper\")) element.removeAttribute(\"data-node-view-wrapper\");\n\t\t\t\tconst restoreSelection = captureDOMSelection(this.contentDOMElement);\n\t\t\t\telement.appendChild(this.contentDOMElement);\n\t\t\t\trestoreSelection === null || restoreSelection === void 0 || restoreSelection();\n\t\t\t}\n\t\t};\n\t\tconst context = {\n\t\t\tonDragStart,\n\t\t\tnodeViewContentRef\n\t\t};\n\t\tconst Component = this.component;\n\t\tconst ReactNodeViewProvider = (0, react.memo)((componentProps) => {\n\t\t\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ReactNodeViewContext.Provider, {\n\t\t\t\tvalue: context,\n\t\t\t\tchildren: (0, react.createElement)(Component, componentProps)\n\t\t\t});\n\t\t});\n\t\tReactNodeViewProvider.displayName = \"ReactNodeView\";\n\t\tlet as = this.node.isInline ? \"span\" : \"div\";\n\t\tif (this.options.as) as = this.options.as;\n\t\tconst { className = \"\" } = this.options;\n\t\tthis.renderer = new ReactRenderer(ReactNodeViewProvider, {\n\t\t\teditor: this.editor,\n\t\t\tprops: mountProps,\n\t\t\tas,\n\t\t\tclassName: `node-${this.node.type.name} ${className}`.trim()\n\t\t});\n\t\tgetReactNodeViewSelectionTracker(this.editor).register(this);\n\t\tthis.updateElementAttributes();\n\t\tthis.currentPos = this.getPos();\n\t}\n\t/**\n\t* Return the DOM element.\n\t* This is the element that will be used to display the node view.\n\t*/\n\tget dom() {\n\t\tvar _this$renderer$elemen;\n\t\tif (this.renderer.element.firstElementChild && !((_this$renderer$elemen = this.renderer.element.firstElementChild) === null || _this$renderer$elemen === void 0 ? void 0 : _this$renderer$elemen.hasAttribute(\"data-node-view-wrapper\"))) throw Error(\"Please use the NodeViewWrapper component for your node view.\");\n\t\treturn this.renderer.element;\n\t}\n\t/**\n\t* Return the content DOM element.\n\t* This is the element that will be used to display the rich-text content of the node.\n\t*/\n\tget contentDOM() {\n\t\tif (this.node.isLeaf) return null;\n\t\treturn this.contentDOMElement;\n\t}\n\t/**\n\t* On update, update the React component.\n\t* To prevent unnecessary updates, the `update` option can be used.\n\t*/\n\tupdate(node, decorations, innerDecorations) {\n\t\tconst rerenderComponent = (props) => {\n\t\t\tthis.renderer.updateProps(props);\n\t\t\tif (typeof this.options.attrs === \"function\") this.updateElementAttributes();\n\t\t};\n\t\tif (node.type !== this.node.type) return false;\n\t\tif (typeof this.options.update === \"function\") {\n\t\t\tconst oldNode = this.node;\n\t\t\tconst oldDecorations = this.decorations;\n\t\t\tconst oldInnerDecorations = this.innerDecorations;\n\t\t\tthis.node = node;\n\t\t\tthis.decorations = decorations;\n\t\t\tthis.innerDecorations = innerDecorations;\n\t\t\tthis.currentPos = this.getPos();\n\t\t\treturn this.options.update({\n\t\t\t\toldNode,\n\t\t\t\toldDecorations,\n\t\t\t\tnewNode: node,\n\t\t\t\tnewDecorations: decorations,\n\t\t\t\toldInnerDecorations,\n\t\t\t\tinnerDecorations,\n\t\t\t\tupdateProps: () => rerenderComponent({\n\t\t\t\t\tnode,\n\t\t\t\t\tdecorations,\n\t\t\t\t\tinnerDecorations,\n\t\t\t\t\textension: this.extensionWithSyncedStorage\n\t\t\t\t})\n\t\t\t});\n\t\t}\n\t\tif (!(node !== this.node)) {\n\t\t\tthis.node = node;\n\t\t\tthis.decorations = decorations;\n\t\t\tthis.innerDecorations = innerDecorations;\n\t\t\treturn true;\n\t\t}\n\t\tconst newPos = this.getPos();\n\t\tthis.node = node;\n\t\tthis.decorations = decorations;\n\t\tthis.innerDecorations = innerDecorations;\n\t\tthis.currentPos = newPos;\n\t\tconst extraProps = {\n\t\t\tnode,\n\t\t\tdecorations,\n\t\t\tinnerDecorations,\n\t\t\textension: this.extensionWithSyncedStorage\n\t\t};\n\t\tif (this.options.trackNodeViewPosition) extraProps.getPos = () => this.getPos();\n\t\trerenderComponent(extraProps);\n\t\treturn true;\n\t}\n\t/**\n\t* Select the node.\n\t* Add the `selected` prop and the `ProseMirror-selectednode` class.\n\t*/\n\tselectNode() {\n\t\tthis.nodeSelected = true;\n\t\tthis.updateSelectedState(true);\n\t}\n\t/**\n\t* Deselect the node.\n\t* Remove the `selected` prop and the `ProseMirror-selectednode` class.\n\t*/\n\tdeselectNode() {\n\t\tthis.nodeSelected = false;\n\t\tthis.updateSelectedState(this.options.selectedOnTextSelection === true && this.isTextSelectionInside());\n\t}\n\tsetSelectionInside(selectionInside) {\n\t\tconst selected = this.nodeSelected || this.options.selectedOnTextSelection === true && selectionInside;\n\t\tthis.renderer.updateProps({\n\t\t\tselectionInside,\n\t\t\tselected\n\t\t});\n\t\tthis.renderer.element.classList.toggle(\"ProseMirror-selectednode\", selected);\n\t}\n\tupdateSelectedState(selected) {\n\t\tthis.renderer.updateProps({ selected });\n\t\tthis.renderer.element.classList.toggle(\"ProseMirror-selectednode\", selected);\n\t}\n\tisTextSelectionInside() {\n\t\tconst pos = this.getPos();\n\t\treturn typeof pos === \"number\" && getTextSelectionAncestorPositions(this.editor.state.selection).includes(pos);\n\t}\n\t/**\n\t* Destroy the React component instance.\n\t*/\n\tdestroy() {\n\t\tthis.renderer.destroy();\n\t\tgetReactNodeViewSelectionTracker(this.editor).unregister(this);\n\t\tif (this.options.trackNodeViewPosition) this.editor.off(\"update\", this.handlePositionUpdate);\n\t\tthis.contentDOMElement = null;\n\t}\n\t/**\n\t* Update the attributes of the top-level element that holds the React component.\n\t* Applying the attributes defined in the `attrs` option.\n\t*/\n\tupdateElementAttributes() {\n\t\tif (this.options.attrs) {\n\t\t\tlet attrsObj = {};\n\t\t\tif (typeof this.options.attrs === \"function\") {\n\t\t\t\tconst extensionAttributes = this.editor.extensionManager.attributes;\n\t\t\t\tconst HTMLAttributes = (0, _tiptap_core.getRenderedAttributes)(this.node, extensionAttributes);\n\t\t\t\tattrsObj = this.options.attrs({\n\t\t\t\t\tnode: this.node,\n\t\t\t\t\tHTMLAttributes\n\t\t\t\t});\n\t\t\t} else attrsObj = this.options.attrs;\n\t\t\tthis.renderer.updateAttributes(attrsObj);\n\t\t}\n\t}\n};\n/**\n* Create a React node view renderer.\n*/\nfunction ReactNodeViewRenderer(component, options) {\n\treturn (props) => {\n\t\tif (!props.editor.contentComponent) return {\n\t\t\tdom: document.createElement(\"span\"),\n\t\t\tcontentDOM: null,\n\t\t\tupdate: () => false,\n\t\t\tdestroy: () => {},\n\t\t\tselectNode: () => {},\n\t\t\tdeselectNode: () => {},\n\t\t\tstopEvent: () => false,\n\t\t\tignoreMutation: () => true\n\t\t};\n\t\treturn new ReactNodeView(component, props, options);\n\t};\n}\n//#endregion\n//#region src/ReactWidgetRenderer.tsx\nconst WIDGET_CACHE = Symbol(\"tiptapReactWidgetCache\");\n/**\n* Renders a React component into a ProseMirror widget decoration.\n* Reuses Tiptap's `ReactRenderer` so the component lives in the editor's\n* React tree (context and hooks work as usual). Use a stable `key` for\n* stateful widgets.\n* @example\n* addDecorations() {\n* return {\n* create: ({ editor, state }) =>\n* findMatches(state.doc).map(match =>\n* ReactWidgetRenderer(MyWidget, {\n* editor, pos: match.pos, key: `match-${match.id}`,\n* props: { label: match.label },\n* }),\n* ),\n* }\n* }\n*/\nfunction ReactWidgetRenderer(component, options) {\n\tconst { editor, props = {}, as = \"span\", className } = options;\n\treturn (0, _tiptap_core.createWidgetDecoration)({\n\t\t...options,\n\t\tprops,\n\t\tcacheKey: WIDGET_CACHE,\n\t\tcontext: (getPos) => ({\n\t\t\teditor,\n\t\t\tgetPos\n\t\t}),\n\t\tcreate: (renderProps) => new ReactRenderer(component, {\n\t\t\teditor,\n\t\t\tas,\n\t\t\tclassName,\n\t\t\tprops: renderProps\n\t\t}),\n\t\tmaterialize: (renderer) => {\n\t\t\trenderer.render();\n\t\t\treturn renderer.element;\n\t\t}\n\t});\n}\n//#endregion\n//#region src/Tiptap.tsx\n/**\n* React context that stores the current editor instance.\n*\n* Use `useTiptap()` to read from this context in child components.\n*/\nconst TiptapContext = (0, react.createContext)({ get editor() {\n\tthrow new Error(\"useTiptap must be used within a <Tiptap> provider\");\n} });\nTiptapContext.displayName = \"TiptapContext\";\n/**\n* Hook to read the Tiptap context and access the editor instance.\n*\n* This is a small convenience wrapper around `useContext(TiptapContext)`.\n* The editor is always available when used within a `<Tiptap>` provider.\n*\n* @returns The current `TiptapContextType` value from the provider.\n*\n* @example\n* ```tsx\n* import { useTiptap } from '@tiptap/react'\n*\n* function Toolbar() {\n* const { editor } = useTiptap()\n*\n* return (\n* <button onClick={() => editor.chain().focus().toggleBold().run()}>\n* Bold\n* </button>\n* )\n* }\n* ```\n*/\nconst useTiptap = () => (0, react.useContext)(TiptapContext);\n/**\n* Select a slice of the editor state using the context-provided editor.\n*\n* This is a thin wrapper around `useEditorState` that reads the `editor`\n* instance from `useTiptap()` so callers don't have to pass it manually.\n*\n* @typeParam TSelectorResult - The type returned by the selector.\n* @param selector - Function that receives the editor state snapshot and\n* returns the piece of state you want to subscribe to.\n* @param equalityFn - Optional function to compare previous/next selected\n* values and avoid unnecessary updates.\n* @returns The selected slice of the editor state.\n*\n* @example\n* ```tsx\n* function WordCount() {\n* const wordCount = useTiptapState(state => {\n* const text = state.editor.state.doc.textContent\n* return text.split(/\\s+/).filter(Boolean).length\n* })\n*\n* return <span>{wordCount} words</span>\n* }\n* ```\n*/\nfunction useTiptapState(selector, equalityFn) {\n\tconst { editor } = useTiptap();\n\treturn useEditorState({\n\t\teditor,\n\t\tselector,\n\t\tequalityFn\n\t});\n}\n/**\n* Top-level provider component that makes the editor instance available via\n* React context to all child components.\n*\n* This component also provides backwards compatibility with the legacy\n* `EditorContext`, so components using `useCurrentEditor()` will work\n* inside a `<Tiptap>` provider.\n*\n* @param props - Component props.\n* @returns A context provider element wrapping `children`.\n*\n* @example\n* ```tsx\n* import { Tiptap, useEditor } from '@tiptap/react'\n*\n* function App() {\n* const editor = useEditor({ extensions: [...] })\n*\n* return (\n* <Tiptap editor={editor}>\n* <Toolbar />\n* <Tiptap.Content />\n* </Tiptap>\n* )\n* }\n* ```\n*/\nfunction TiptapWrapper({ children, ...props }) {\n\tconst resolvedEditor = \"editor\" in props ? props.editor : props.instance;\n\tif (!resolvedEditor) throw new Error(\"Tiptap: An editor instance is required. Pass a non-null `editor` prop.\");\n\tconst tiptapContextValue = (0, react.useMemo)(() => ({ editor: resolvedEditor }), [resolvedEditor]);\n\tconst legacyContextValue = (0, react.useMemo)(() => ({ editor: resolvedEditor }), [resolvedEditor]);\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorContext.Provider, {\n\t\tvalue: legacyContextValue,\n\t\tchildren: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(TiptapContext.Provider, {\n\t\t\tvalue: tiptapContextValue,\n\t\t\tchildren\n\t\t})\n\t});\n}\nTiptapWrapper.displayName = \"Tiptap\";\n/**\n* Convenience component that renders `EditorContent` using the context-provided\n* editor instance. Use this instead of manually passing the `editor` prop.\n*\n* @param props - All `EditorContent` props except `editor` and `ref`.\n* @returns An `EditorContent` element bound to the context editor.\n*\n* @example\n* ```tsx\n* // inside a Tiptap provider\n* <Tiptap.Content className=\"editor\" />\n* ```\n*/\nfunction TiptapContent({ ...rest }) {\n\tconst { editor } = useTiptap();\n\treturn /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EditorContent, {\n\t\teditor,\n\t\t...rest\n\t});\n}\nTiptapContent.displayName = \"Tiptap.Content\";\n/**\n* Root `Tiptap` component. Use it as the provider for all child components.\n*\n* The exported object includes the `Content` subcomponent for rendering the\n* editor content area.\n*\n* This component provides both the new `TiptapContext` (accessed via `useTiptap()`)\n* and the legacy `EditorContext` (accessed via `useCurrentEditor()`) for\n* backwards compatibility.\n*\n* For bubble menus and floating menus, import them separately from\n* `@tiptap/react/menus` to keep floating-ui as an optional dependency.\n*\n* @example\n* ```tsx\n* import { Tiptap, useEditor } from '@tiptap/react'\n* import { BubbleMenu } from '@tiptap/react/menus'\n*\n* function App() {\n* const editor = useEditor({ extensions: [...] })\n*\n* return (\n* <Tiptap editor={editor}>\n* <Tiptap.Content />\n* <BubbleMenu>\n* <button onClick={() => editor.chain().focus().toggleBold().run()}>Bold</button>\n* </BubbleMenu>\n* </Tiptap>\n* )\n* }\n* ```\n*/\nconst Tiptap = Object.assign(TiptapWrapper, { \n/**\n* The Tiptap Content component that renders the EditorContent with the editor instance from the context.\n* @see TiptapContent\n*/\nContent: TiptapContent });\n//#endregion\nexports.EditorConsumer = EditorConsumer;\nexports.EditorContent = EditorContent;\nexports.EditorContext = EditorContext;\nexports.EditorProvider = EditorProvider;\nexports.MarkViewContent = MarkViewContent;\nexports.NodeViewContent = NodeViewContent;\nexports.NodeViewWrapper = NodeViewWrapper;\nexports.PureEditorContent = PureEditorContent;\nexports.ReactMarkView = ReactMarkView;\nexports.ReactMarkViewContext = ReactMarkViewContext;\nexports.ReactMarkViewRenderer = ReactMarkViewRenderer;\nexports.ReactNodeView = ReactNodeView;\nexports.ReactNodeViewContentProvider = ReactNodeViewContentProvider;\nexports.ReactNodeViewContext = ReactNodeViewContext;\nexports.ReactNodeViewRenderer = ReactNodeViewRenderer;\nexports.ReactRenderer = ReactRenderer;\nexports.ReactWidgetRenderer = ReactWidgetRenderer;\nexports.Tiptap = Tiptap;\nexports.TiptapContent = TiptapContent;\nexports.TiptapContext = TiptapContext;\nexports.TiptapWrapper = TiptapWrapper;\nexports.createContentComponent = createContentComponent;\nexports.useCurrentEditor = useCurrentEditor;\nexports.useEditor = useEditor;\nexports.useEditorState = useEditorState;\nexports.useReactNodeView = useReactNodeView;\nexports.useTiptap = useTiptap;\nexports.useTiptapState = useTiptapState;\nObject.keys(_tiptap_core).forEach(function(k) {\n\tif (k !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {\n\t\tenumerable: true,\n\t\tget: function() {\n\t\t\treturn _tiptap_core[k];\n\t\t}\n\t});\n});\n\n//# sourceMappingURL=index.cjs.map","Object.defineProperties(exports, {\n\t__esModule: { value: true },\n\t[Symbol.toStringTag]: { value: \"Module\" }\n});\nlet _tiptap_core = require(\"@tiptap/core\");\nlet _tiptap_extension_blockquote = require(\"@tiptap/extension-blockquote\");\nlet _tiptap_extension_bold = require(\"@tiptap/extension-bold\");\nlet _tiptap_extension_code = require(\"@tiptap/extension-code\");\nlet _tiptap_extension_code_block = require(\"@tiptap/extension-code-block\");\nlet _tiptap_extension_document = require(\"@tiptap/extension-document\");\nlet _tiptap_extension_hard_break = require(\"@tiptap/extension-hard-break\");\nlet _tiptap_extension_heading = require(\"@tiptap/extension-heading\");\nlet _tiptap_extension_horizontal_rule = require(\"@tiptap/extension-horizontal-rule\");\nlet _tiptap_extension_italic = require(\"@tiptap/extension-italic\");\nlet _tiptap_extension_link = require(\"@tiptap/extension-link\");\nlet _tiptap_extension_list = require(\"@tiptap/extension-list\");\nlet _tiptap_extension_paragraph = require(\"@tiptap/extension-paragraph\");\nlet _tiptap_extension_strike = require(\"@tiptap/extension-strike\");\nlet _tiptap_extension_text = require(\"@tiptap/extension-text\");\nlet _tiptap_extension_underline = require(\"@tiptap/extension-underline\");\nlet _tiptap_extensions = require(\"@tiptap/extensions\");\n//#region src/starter-kit.ts\n/**\n* The starter kit is a collection of essential editor extensions.\n*\n* It’s a good starting point for building your own editor.\n*/\nconst StarterKit = _tiptap_core.Extension.create({\n\tname: \"starterKit\",\n\taddExtensions() {\n\t\tconst extensions = [];\n\t\tif (this.options.bold !== false) extensions.push(_tiptap_extension_bold.Bold.configure(this.options.bold));\n\t\tif (this.options.blockquote !== false) extensions.push(_tiptap_extension_blockquote.Blockquote.configure(this.options.blockquote));\n\t\tif (this.options.bulletList !== false) extensions.push(_tiptap_extension_list.BulletList.configure(this.options.bulletList));\n\t\tif (this.options.code !== false) extensions.push(_tiptap_extension_code.Code.configure(this.options.code));\n\t\tif (this.options.codeBlock !== false) extensions.push(_tiptap_extension_code_block.CodeBlock.configure(this.options.codeBlock));\n\t\tif (this.options.document !== false) extensions.push(_tiptap_extension_document.Document.configure(this.options.document));\n\t\tif (this.options.dropcursor !== false) extensions.push(_tiptap_extensions.Dropcursor.configure(this.options.dropcursor));\n\t\tif (this.options.gapcursor !== false) extensions.push(_tiptap_extensions.Gapcursor.configure(this.options.gapcursor));\n\t\tif (this.options.hardBreak !== false) extensions.push(_tiptap_extension_hard_break.HardBreak.configure(this.options.hardBreak));\n\t\tif (this.options.heading !== false) extensions.push(_tiptap_extension_heading.Heading.configure(this.options.heading));\n\t\tif (this.options.undoRedo !== false) extensions.push(_tiptap_extensions.UndoRedo.configure(this.options.undoRedo));\n\t\tif (this.options.horizontalRule !== false) extensions.push(_tiptap_extension_horizontal_rule.HorizontalRule.configure(this.options.horizontalRule));\n\t\tif (this.options.italic !== false) extensions.push(_tiptap_extension_italic.Italic.configure(this.options.italic));\n\t\tif (this.options.listItem !== false) extensions.push(_tiptap_extension_list.ListItem.configure(this.options.listItem));\n\t\tif (this.options.listKeymap !== false) {\n\t\t\tvar _this$options;\n\t\t\textensions.push(_tiptap_extension_list.ListKeymap.configure((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.listKeymap));\n\t\t}\n\t\tif (this.options.link !== false) {\n\t\t\tvar _this$options2;\n\t\t\textensions.push(_tiptap_extension_link.Link.configure((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.link));\n\t\t}\n\t\tif (this.options.orderedList !== false) extensions.push(_tiptap_extension_list.OrderedList.configure(this.options.orderedList));\n\t\tif (this.options.paragraph !== false) extensions.push(_tiptap_extension_paragraph.Paragraph.configure(this.options.paragraph));\n\t\tif (this.options.strike !== false) extensions.push(_tiptap_extension_strike.Strike.configure(this.options.strike));\n\t\tif (this.options.text !== false) extensions.push(_tiptap_extension_text.Text.configure(this.options.text));\n\t\tif (this.options.underline !== false) {\n\t\t\tvar _this$options3;\n\t\t\textensions.push(_tiptap_extension_underline.Underline.configure((_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.underline));\n\t\t}\n\t\tif (this.options.trailingNode !== false) {\n\t\t\tvar _this$options4;\n\t\t\textensions.push(_tiptap_extensions.TrailingNode.configure((_this$options4 = this.options) === null || _this$options4 === void 0 ? void 0 : _this$options4.trailingNode));\n\t\t}\n\t\treturn extensions;\n\t}\n});\n//#endregion\n//#region src/index.ts\nvar src_default = StarterKit;\n//#endregion\nexports.StarterKit = StarterKit;\nexports.default = src_default;\n\n//# sourceMappingURL=index.cjs.map","'use strict';\n\nconst { getOwnPropertyNames, getOwnPropertySymbols } = Object;\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst { hasOwnProperty } = Object.prototype;\n/**\n * Combine two comparators into a single comparators.\n */\nfunction combineComparators(comparatorA, comparatorB) {\n return function isEqual(a, b, state) {\n return comparatorA(a, b, state) && comparatorB(a, b, state);\n };\n}\n/**\n * Wrap the provided `areItemsEqual` method to manage the circular state, allowing\n * for circular references to be safely included in the comparison without creating\n * stack overflows.\n */\nfunction createIsCircular(areItemsEqual) {\n return function isCircular(a, b, state) {\n if (!a || !b || typeof a !== 'object' || typeof b !== 'object') {\n return areItemsEqual(a, b, state);\n }\n const { cache } = state;\n const cachedA = cache.get(a);\n const cachedB = cache.get(b);\n if (cachedA && cachedB) {\n return cachedA === b && cachedB === a;\n }\n cache.set(a, b);\n cache.set(b, a);\n const result = areItemsEqual(a, b, state);\n cache.delete(a);\n cache.delete(b);\n return result;\n };\n}\n/**\n * Get the `@@toStringTag` of the value, if it exists.\n */\nfunction getShortTag(value) {\n return value != null ? value[Symbol.toStringTag] : undefined;\n}\n/**\n * Get the properties to strictly examine, which include both own properties that are\n * not enumerable and symbol properties.\n */\nfunction getStrictProperties(object) {\n return getOwnPropertyNames(object).concat(getOwnPropertySymbols(object));\n}\n/**\n * Whether the object contains the property passed as an own property.\n */\nconst hasOwn = \n// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\nObject.hasOwn || ((object, property) => hasOwnProperty.call(object, property));\n/**\n * Whether the values passed are strictly equal or both NaN.\n */\nfunction sameValueZeroEqual(a, b) {\n return a === b || (!a && !b && a !== a && b !== b);\n}\n\nconst PREACT_VNODE = '__v';\nconst PREACT_OWNER = '__o';\nconst REACT_OWNER = '_owner';\n// `Float16Array` is recent enough that it cannot be referenced unguarded, and capturing its\n// availability once keeps that detail out of the comparison itself.\nconst HAS_FLOAT_16_ARRAY = typeof Float16Array !== 'undefined';\nconst { getOwnPropertyDescriptor, keys } = Object;\n/**\n * Whether the array buffers are equal in value.\n */\nfunction areArrayBuffersEqual(a, b) {\n return a.byteLength === b.byteLength && areTypedArraysEqual(new Uint8Array(a), new Uint8Array(b));\n}\n/**\n * Whether the arrays are equal in value.\n */\nfunction areArraysEqual(a, b, state) {\n let index = a.length;\n if (b.length !== index) {\n return false;\n }\n while (index-- > 0) {\n if (!state.equals(a[index], b[index], index, index, a, b, state)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the dataviews are equal in value.\n */\nfunction areDataViewsEqual(a, b) {\n return (a.byteLength === b.byteLength\n && areTypedArraysEqual(new Uint8Array(a.buffer, a.byteOffset, a.byteLength), new Uint8Array(b.buffer, b.byteOffset, b.byteLength)));\n}\n/**\n * Whether the dates passed are equal in value.\n */\nfunction areDatesEqual(a, b) {\n return sameValueZeroEqual(a.getTime(), b.getTime());\n}\n/**\n * Whether the errors passed are equal in value.\n */\nfunction areErrorsEqual(a, b, state) {\n return (a.name === b.name\n && a.message === b.message\n && a.stack === b.stack\n && state.equals(a.cause, b.cause, 'cause', 'cause', a, b, state));\n}\n/**\n * Whether the functions passed are equal in value.\n */\nfunction areFunctionsEqual(a, b) {\n return a === b;\n}\n/**\n * Whether the `Map`s are equal in value.\n */\nfunction areMapsEqual(a, b, state) {\n const size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n const matchedIndices = new Array(size);\n const aIterable = a.entries();\n let aResult;\n let bResult;\n let index = 0;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n const bIterable = b.entries();\n let hasMatch = false;\n let matchIndex = 0;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (matchedIndices[matchIndex]) {\n matchIndex++;\n continue;\n }\n const aEntry = aResult.value;\n const bEntry = bResult.value;\n if (state.equals(aEntry[0], bEntry[0], index, matchIndex, a, b, state)\n && state.equals(aEntry[1], bEntry[1], aEntry[0], bEntry[0], a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n index++;\n }\n return true;\n}\n/**\n * Whether the numbers are equal in value.\n */\nconst areNumbersEqual = sameValueZeroEqual;\n/**\n * Whether the objects are equal in value.\n */\nfunction areObjectsEqual(a, b, state) {\n const properties = keys(a);\n let index = properties.length;\n if (keys(b).length !== index) {\n return false;\n }\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n if (!isPropertyEqual(a, b, state, properties[index])) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the objects are equal in value with strict property checking.\n */\nfunction areObjectsEqualStrict(a, b, state) {\n const properties = getStrictProperties(a);\n let index = properties.length;\n if (getStrictProperties(b).length !== index) {\n return false;\n }\n let property;\n let descriptorA;\n let descriptorB;\n // Decrementing `while` showed faster results than either incrementing or\n // decrementing `for` loop and than an incrementing `while` loop. Declarative\n // methods like `some` / `every` were not used to avoid incurring the garbage\n // cost of anonymous callbacks.\n while (index-- > 0) {\n property = properties[index];\n if (!isPropertyEqual(a, b, state, property)) {\n return false;\n }\n descriptorA = getOwnPropertyDescriptor(a, property);\n descriptorB = getOwnPropertyDescriptor(b, property);\n if ((descriptorA || descriptorB)\n && (!descriptorA\n || !descriptorB\n || descriptorA.configurable !== descriptorB.configurable\n || descriptorA.enumerable !== descriptorB.enumerable\n || descriptorA.writable !== descriptorB.writable)) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the primitive wrappers passed are equal in value.\n */\nfunction arePrimitiveWrappersEqual(a, b) {\n return sameValueZeroEqual(a.valueOf(), b.valueOf());\n}\n/**\n * Whether the regexps passed are equal in value.\n */\nfunction areRegExpsEqual(a, b) {\n return a.source === b.source && a.flags === b.flags;\n}\n/**\n * Whether the `Set`s are equal in value.\n */\nfunction areSetsEqual(a, b, state) {\n const size = a.size;\n if (size !== b.size) {\n return false;\n }\n if (!size) {\n return true;\n }\n const matchedIndices = new Array(size);\n const aIterable = a.values();\n let aResult;\n let bResult;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while ((aResult = aIterable.next())) {\n if (aResult.done) {\n break;\n }\n const bIterable = b.values();\n let hasMatch = false;\n let matchIndex = 0;\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n while ((bResult = bIterable.next())) {\n if (bResult.done) {\n break;\n }\n if (!matchedIndices[matchIndex]\n && state.equals(aResult.value, bResult.value, aResult.value, bResult.value, a, b, state)) {\n hasMatch = matchedIndices[matchIndex] = true;\n break;\n }\n matchIndex++;\n }\n if (!hasMatch) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the TypedArray instances are equal in value.\n */\nfunction areTypedArraysEqual(a, b) {\n let index = a.length;\n if (b.length !== index || a.byteOffset !== b.byteOffset) {\n return false;\n }\n // Only float-backed views can hold `NaN`, and the additional check needed to treat it as equal\n // to itself measurably slows the loop, so integer views keep the plain comparison. This is\n // hoisted out of the loop so the cost is paid once per call rather than once per element.\n if (a instanceof Float64Array || a instanceof Float32Array || (HAS_FLOAT_16_ARRAY && a instanceof Float16Array)) {\n while (index-- > 0) {\n // `NaN` is the only value not equal to itself, and it is treated as equal here to match\n // the SameValueZero semantics used for every other numeric comparison in the library.\n if (a[index] !== b[index] && (a[index] === a[index] || b[index] === b[index])) {\n return false;\n }\n }\n return true;\n }\n while (index-- > 0) {\n if (a[index] !== b[index]) {\n return false;\n }\n }\n return true;\n}\n/**\n * Whether the URL instances are equal in value.\n */\nfunction areUrlsEqual(a, b) {\n // `href` is the normalized serialization of every component, so matching hrefs are equal without\n // any further work. Only a difference in query parameter ordering can survive a mismatch here.\n if (a.href === b.href) {\n return true;\n }\n return (a.protocol === b.protocol\n && a.username === b.username\n && a.password === b.password\n // `host` covers both the hostname and the port.\n && a.host === b.host\n && a.pathname === b.pathname\n && a.hash === b.hash\n && areSearchParamsEqual(a.searchParams, b.searchParams));\n}\n/**\n * Whether the search params passed are equal in value.\n *\n * @note\n * Order is not significant, matching how the other unordered collections in the library are\n * compared. Repeated keys are, so this is a comparison of multisets rather than of sets:\n * `a=1&a=2` is equal to `a=2&a=1`, but not to `a=1&a=1`.\n */\nfunction areSearchParamsEqual(a, b) {\n const serializedA = a.toString();\n const serializedB = b.toString();\n // Identical serializations are equal under any ordering, and this is by far the common case, so\n // it is worth checking before sorting anything.\n return serializedA === serializedB || sortSearchParams(serializedA) === sortSearchParams(serializedB);\n}\n/**\n * Reorder a serialized query string so that params holding the same pairs compare as equal\n * regardless of the order they appear in.\n *\n * @note\n * The serializer percent-encodes `&` and `=` wherever they appear inside a name or a value, so\n * splitting on `&` recovers exactly the pairs and nothing else.\n */\nfunction sortSearchParams(serialized) {\n return serialized.split('&').sort().join('&');\n}\nfunction isPropertyEqual(a, b, state, property) {\n if ((property === REACT_OWNER || property === PREACT_OWNER || property === PREACT_VNODE)\n && (a.$$typeof || b.$$typeof)) {\n return true;\n }\n return hasOwn(b, property) && state.equals(a[property], b[property], property, property, a, b, state);\n}\n\nconst ARRAY_BUFFER_TAG = '[object ArrayBuffer]';\nconst ARGUMENTS_TAG = '[object Arguments]';\nconst BOOLEAN_TAG = '[object Boolean]';\nconst DATA_VIEW_TAG = '[object DataView]';\nconst DATE_TAG = '[object Date]';\nconst ERROR_TAG = '[object Error]';\nconst MAP_TAG = '[object Map]';\nconst NUMBER_TAG = '[object Number]';\nconst OBJECT_TAG = '[object Object]';\nconst REG_EXP_TAG = '[object RegExp]';\nconst SET_TAG = '[object Set]';\nconst STRING_TAG = '[object String]';\nconst TYPED_ARRAY_TAGS = {\n '[object Int8Array]': true,\n '[object Uint8Array]': true,\n '[object Uint8ClampedArray]': true,\n '[object Int16Array]': true,\n '[object Uint16Array]': true,\n '[object Int32Array]': true,\n '[object Uint32Array]': true,\n '[object Float16Array]': true,\n '[object Float32Array]': true,\n '[object Float64Array]': true,\n '[object BigInt64Array]': true,\n '[object BigUint64Array]': true,\n};\nconst URL_TAG = '[object URL]';\n// eslint-disable-next-line @typescript-eslint/unbound-method\nconst toString = Object.prototype.toString;\n/**\n * Create a comparator method based on the type-specific equality comparators passed.\n */\nfunction createEqualityComparator({ areArrayBuffersEqual, areArraysEqual, areDataViewsEqual, areDatesEqual, areErrorsEqual, areFunctionsEqual, areMapsEqual, areNumbersEqual, areObjectsEqual, arePrimitiveWrappersEqual, areRegExpsEqual, areSetsEqual, areTypedArraysEqual, areUrlsEqual, unknownTagComparators, }) {\n /**\n * compare the value of the two objects and return true if they are equivalent in values\n */\n return function comparator(a, b, state) {\n // If the items are strictly equal, no need to do a value comparison.\n if (a === b) {\n return true;\n }\n // If either of the items are nullish and fail the strictly equal check\n // above, then they must be unequal.\n if (a == null || b == null) {\n return false;\n }\n const type = typeof a;\n if (type !== typeof b) {\n return false;\n }\n if (type !== 'object') {\n if (type === 'number') {\n return areNumbersEqual(a, b, state);\n }\n if (type === 'function') {\n return areFunctionsEqual(a, b, state);\n }\n // If a primitive value that is not strictly equal, it must be unequal.\n return false;\n }\n const constructor = a.constructor;\n // Checks are listed in order of commonality of use-case:\n // 1. Common complex object types (plain object, array)\n // 2. Common data values (date, regexp)\n // 3. Less-common complex object types (map, set)\n // 4. Less-common data values (promise, primitive wrappers)\n // Inherently this is both subjective and assumptive, however\n // when reviewing comparable libraries in the wild this order\n // appears to be generally consistent.\n // Constructors should match, otherwise there is potential for false positives\n // between class and subclass or custom object and POJO.\n if (constructor !== b.constructor) {\n return false;\n }\n // `isPlainObject` only checks against the object's own realm. Cross-realm\n // comparisons are rare, and will be handled in the ultimate fallback, so\n // we can avoid capturing the string tag.\n if (constructor === Object) {\n return areObjectsEqual(a, b, state);\n }\n // `isArray()` works on subclasses and is cross-realm, so we can avoid capturing\n // the string tag or doing an `instanceof` check.\n if (Array.isArray(a)) {\n return areArraysEqual(a, b, state);\n }\n // Try to fast-path equality checks for other complex object types in the\n // same realm to avoid capturing the string tag. Strict equality is used\n // instead of `instanceof` because it is more performant for the common\n // use-case. If someone is subclassing a native class, it will be handled\n // with the string tag comparison.\n if (constructor === Date) {\n return areDatesEqual(a, b, state);\n }\n if (constructor === RegExp) {\n return areRegExpsEqual(a, b, state);\n }\n if (constructor === Map) {\n return areMapsEqual(a, b, state);\n }\n if (constructor === Set) {\n return areSetsEqual(a, b, state);\n }\n // Since this is a custom object, capture the string tag to determing its type.\n // This is reasonably performant in modern environments like v8 and SpiderMonkey.\n const tag = toString.call(a);\n if (tag === DATE_TAG) {\n return areDatesEqual(a, b, state);\n }\n // For RegExp, the properties are not enumerable, and therefore will give false positives if\n // tested like a standard object.\n if (tag === REG_EXP_TAG) {\n return areRegExpsEqual(a, b, state);\n }\n if (tag === MAP_TAG) {\n return areMapsEqual(a, b, state);\n }\n if (tag === SET_TAG) {\n return areSetsEqual(a, b, state);\n }\n if (tag === OBJECT_TAG) {\n // The exception for value comparison is custom `Promise`-like class instances. These should\n // be treated the same as standard `Promise` objects, which means strict equality, and if\n // it reaches this point then that strict equality comparison has already failed.\n return typeof a.then !== 'function' && typeof b.then !== 'function' && areObjectsEqual(a, b, state);\n }\n // If a URL tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === URL_TAG) {\n return areUrlsEqual(a, b, state);\n }\n // If an error tag, it should be tested explicitly. Like RegExp, the properties are not\n // enumerable, and therefore will give false positives if tested like a standard object.\n if (tag === ERROR_TAG) {\n return areErrorsEqual(a, b, state);\n }\n // If an arguments tag, it should be treated as a standard object.\n if (tag === ARGUMENTS_TAG) {\n return areObjectsEqual(a, b, state);\n }\n if (TYPED_ARRAY_TAGS[tag]) {\n return areTypedArraysEqual(a, b, state);\n }\n if (tag === ARRAY_BUFFER_TAG) {\n return areArrayBuffersEqual(a, b, state);\n }\n if (tag === DATA_VIEW_TAG) {\n return areDataViewsEqual(a, b, state);\n }\n // As the penultimate fallback, check if the values passed are primitive wrappers. This\n // is very rare in modern JS, which is why it is deprioritized compared to all other object\n // types.\n if (tag === BOOLEAN_TAG || tag === NUMBER_TAG || tag === STRING_TAG) {\n return arePrimitiveWrappersEqual(a, b, state);\n }\n if (unknownTagComparators) {\n let unknownTagComparator = unknownTagComparators[tag];\n if (!unknownTagComparator) {\n const shortTag = getShortTag(a);\n if (shortTag) {\n unknownTagComparator = unknownTagComparators[shortTag];\n }\n }\n // If the custom config has an unknown tag comparator that matches the captured tag or the\n // @@toStringTag, it is the source of truth for whether the values are equal.\n if (unknownTagComparator) {\n return unknownTagComparator(a, b, state);\n }\n }\n // If not matching any tags that require a specific type of comparison, then we hard-code false because\n // the only thing remaining is strict equality, which has already been compared. This is for a few reasons:\n // - Certain types that cannot be introspected (e.g., `WeakMap`). For these types, this is the only\n // comparison that can be made.\n // - For types that can be introspected, but rarely have requirements to be compared\n // (`ArrayBuffer`, `DataView`, etc.), the cost is avoided to prioritize the common\n // use-cases (may be included in a future release, if requested enough).\n // - For types that can be introspected but do not have an objective definition of what\n // equality is (`Error`, etc.), the subjective decision is to be conservative and strictly compare.\n // In all cases, these decisions should be reevaluated based on changes to the language and\n // common development practices.\n return false;\n };\n}\n/**\n * Create the configuration object used for building comparators.\n */\nfunction createEqualityComparatorConfig({ circular, createCustomConfig, strict, }) {\n let config = {\n areArrayBuffersEqual,\n areArraysEqual: strict ? areObjectsEqualStrict : areArraysEqual,\n areDataViewsEqual,\n areDatesEqual: areDatesEqual,\n // `Error` subclasses routinely carry their own enumerable properties (`status`, `code`, ...),\n // which the error comparator alone does not see, so it is composed with the object comparator.\n // `name` / `message` / `stack` are own but not enumerable, which is why errors need a\n // comparator of their own rather than being treated as plain objects in the first place.\n areErrorsEqual: strict\n ? combineComparators(areErrorsEqual, areObjectsEqualStrict)\n : combineComparators(areErrorsEqual, areObjectsEqual),\n areFunctionsEqual: areFunctionsEqual,\n areMapsEqual: strict ? combineComparators(areMapsEqual, areObjectsEqualStrict) : areMapsEqual,\n areNumbersEqual: areNumbersEqual,\n areObjectsEqual: strict ? areObjectsEqualStrict : areObjectsEqual,\n arePrimitiveWrappersEqual: arePrimitiveWrappersEqual,\n areRegExpsEqual: areRegExpsEqual,\n areSetsEqual: strict ? combineComparators(areSetsEqual, areObjectsEqualStrict) : areSetsEqual,\n areTypedArraysEqual: strict\n ? combineComparators(areTypedArraysEqual, areObjectsEqualStrict)\n : areTypedArraysEqual,\n areUrlsEqual: areUrlsEqual,\n unknownTagComparators: undefined,\n };\n if (createCustomConfig) {\n config = Object.assign({}, config, createCustomConfig(config));\n }\n if (circular) {\n const areArraysEqual = createIsCircular(config.areArraysEqual);\n // Errors are included because comparing `cause` and own properties by value means an error\n // that references itself would otherwise recurse without bound.\n const areErrorsEqual = createIsCircular(config.areErrorsEqual);\n const areMapsEqual = createIsCircular(config.areMapsEqual);\n const areObjectsEqual = createIsCircular(config.areObjectsEqual);\n const areSetsEqual = createIsCircular(config.areSetsEqual);\n config = Object.assign({}, config, {\n areArraysEqual,\n areErrorsEqual,\n areMapsEqual,\n areObjectsEqual,\n areSetsEqual,\n });\n }\n return config;\n}\n/**\n * Default equality comparator pass-through, used as the standard `isEqual` creator for\n * use inside the built comparator.\n */\nfunction createInternalEqualityComparator(compare) {\n return function (a, b, _indexOrKeyA, _indexOrKeyB, _parentA, _parentB, state) {\n return compare(a, b, state);\n };\n}\n/**\n * Create the `isEqual` function used by the consuming application.\n */\nfunction createIsEqual({ circular, comparator, createState, equals, strict }) {\n if (createState) {\n return function isEqual(a, b) {\n const { cache = circular ? new WeakMap() : undefined, meta } = createState();\n return comparator(a, b, {\n cache,\n equals,\n meta,\n strict,\n });\n };\n }\n if (circular) {\n return function isEqual(a, b) {\n return comparator(a, b, {\n cache: new WeakMap(),\n equals,\n meta: undefined,\n strict,\n });\n };\n }\n const state = {\n cache: undefined,\n equals,\n meta: undefined,\n strict,\n };\n return function isEqual(a, b) {\n return comparator(a, b, state);\n };\n}\n\n/**\n * Whether the items passed are deeply-equal in value.\n */\nconst deepEqual = createCustomEqual();\n/**\n * Whether the items passed are deeply-equal in value based on strict comparison.\n */\nconst strictDeepEqual = createCustomEqual({ strict: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references.\n */\nconst circularDeepEqual = createCustomEqual({ circular: true });\n/**\n * Whether the items passed are deeply-equal in value, including circular references,\n * based on strict comparison.\n */\nconst strictCircularDeepEqual = createCustomEqual({\n circular: true,\n strict: true,\n});\n/**\n * Whether the items passed are shallowly-equal in value.\n */\nconst shallowEqual = createCustomEqual({\n createInternalComparator: () => sameValueZeroEqual,\n});\n/**\n * Whether the items passed are shallowly-equal in value based on strict comparison\n */\nconst strictShallowEqual = createCustomEqual({\n strict: true,\n createInternalComparator: () => sameValueZeroEqual,\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references.\n */\nconst circularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: () => sameValueZeroEqual,\n});\n/**\n * Whether the items passed are shallowly-equal in value, including circular references,\n * based on strict comparison.\n */\nconst strictCircularShallowEqual = createCustomEqual({\n circular: true,\n createInternalComparator: () => sameValueZeroEqual,\n strict: true,\n});\n/**\n * Create a custom equality comparison method.\n *\n * This can be done to create very targeted comparisons in extreme hot-path scenarios\n * where the standard methods are not performant enough, but can also be used to provide\n * support for legacy environments that do not support expected features like\n * `RegExp.prototype.flags` out of the box.\n */\nfunction createCustomEqual(options = {}) {\n const { circular = false, createInternalComparator: createCustomInternalComparator, createState, strict = false, } = options;\n const config = createEqualityComparatorConfig(options);\n const comparator = createEqualityComparator(config);\n const equals = createCustomInternalComparator\n ? createCustomInternalComparator(comparator)\n : createInternalEqualityComparator(comparator);\n return createIsEqual({ circular, comparator, createState, equals, strict });\n}\n\nexports.circularDeepEqual = circularDeepEqual;\nexports.circularShallowEqual = circularShallowEqual;\nexports.createCustomEqual = createCustomEqual;\nexports.deepEqual = deepEqual;\nexports.sameValueZeroEqual = sameValueZeroEqual;\nexports.shallowEqual = shallowEqual;\nexports.strictCircularDeepEqual = strictCircularDeepEqual;\nexports.strictCircularShallowEqual = strictCircularShallowEqual;\nexports.strictDeepEqual = strictDeepEqual;\nexports.strictShallowEqual = strictShallowEqual;\n//# sourceMappingURL=index.cjs.map\n","'use strict';\n\n// ::- Persistent data structure representing an ordered mapping from\n// strings to values, with some convenient update methods.\nfunction OrderedMap(content) {\n this.content = content;\n}\n\nOrderedMap.prototype = {\n constructor: OrderedMap,\n\n find: function(key) {\n for (var i = 0; i < this.content.length; i += 2)\n if (this.content[i] === key) return i\n return -1\n },\n\n // :: (string) → ?any\n // Retrieve the value stored under `key`, or return undefined when\n // no such key exists.\n get: function(key) {\n var found = this.find(key);\n return found == -1 ? undefined : this.content[found + 1]\n },\n\n // :: (string, any, ?string) → OrderedMap\n // Create a new map by replacing the value of `key` with a new\n // value, or adding a binding to the end of the map. If `newKey` is\n // given, the key of the binding will be replaced with that key.\n update: function(key, value, newKey) {\n var self = newKey && newKey != key ? this.remove(newKey) : this;\n var found = self.find(key), content = self.content.slice();\n if (found == -1) {\n content.push(newKey || key, value);\n } else {\n content[found + 1] = value;\n if (newKey) content[found] = newKey;\n }\n return new OrderedMap(content)\n },\n\n // :: (string) → OrderedMap\n // Return a map with the given key removed, if it existed.\n remove: function(key) {\n var found = this.find(key);\n if (found == -1) return this\n var content = this.content.slice();\n content.splice(found, 2);\n return new OrderedMap(content)\n },\n\n // :: (string, any) → OrderedMap\n // Add a new key to the start of the map.\n addToStart: function(key, value) {\n return new OrderedMap([key, value].concat(this.remove(key).content))\n },\n\n // :: (string, any) → OrderedMap\n // Add a new key to the end of the map.\n addToEnd: function(key, value) {\n var content = this.remove(key).content.slice();\n content.push(key, value);\n return new OrderedMap(content)\n },\n\n // :: (string, string, any) → OrderedMap\n // Add a key after the given key. If `place` is not found, the new\n // key is added to the end.\n addBefore: function(place, key, value) {\n var without = this.remove(key), content = without.content.slice();\n var found = without.find(place);\n content.splice(found == -1 ? content.length : found, 0, key, value);\n return new OrderedMap(content)\n },\n\n // :: ((key: string, value: any))\n // Call the given function for each key/value pair in the map, in\n // order.\n forEach: function(f) {\n for (var i = 0; i < this.content.length; i += 2)\n f(this.content[i], this.content[i + 1]);\n },\n\n // :: (union<Object, OrderedMap>) → OrderedMap\n // Create a new map by prepending the keys in this map that don't\n // appear in `map` before the keys in `map`.\n prepend: function(map) {\n map = OrderedMap.from(map);\n if (!map.size) return this\n return new OrderedMap(map.content.concat(this.subtract(map).content))\n },\n\n // :: (union<Object, OrderedMap>) → OrderedMap\n // Create a new map by appending the keys in this map that don't\n // appear in `map` after the keys in `map`.\n append: function(map) {\n map = OrderedMap.from(map);\n if (!map.size) return this\n return new OrderedMap(this.subtract(map).content.concat(map.content))\n },\n\n // :: (union<Object, OrderedMap>) → OrderedMap\n // Create a map containing all the keys in this map that don't\n // appear in `map`.\n subtract: function(map) {\n var result = this;\n map = OrderedMap.from(map);\n for (var i = 0; i < map.content.length; i += 2)\n result = result.remove(map.content[i]);\n return result\n },\n\n // :: () → Object\n // Turn ordered map into a plain object.\n toObject: function() {\n var result = {};\n this.forEach(function(key, value) { result[key] = value; });\n return result\n },\n\n // :: number\n // The amount of keys in this map.\n get size() {\n return this.content.length >> 1\n }\n};\n\n// :: (?union<Object, OrderedMap>) → OrderedMap\n// Return a map with the given content. If null, create an empty\n// map. If given an ordered map, return that map itself. If given an\n// object, create a map from the object's properties.\nOrderedMap.from = function(value) {\n if (value instanceof OrderedMap) return value\n var content = [];\n if (value) for (var prop in value) content.push(prop, value[prop]);\n return new OrderedMap(content)\n};\n\nmodule.exports = OrderedMap;\n","'use strict';\n\nvar prosemirrorTransform = require('prosemirror-transform');\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorState = require('prosemirror-state');\nvar deleteSelection = function deleteSelection(state, dispatch) {\n if (state.selection.empty) return false;\n if (dispatch) dispatch(state.tr.deleteSelection().scrollIntoView());\n return true;\n};\nfunction atBlockStart(state, view) {\n var $cursor = state.selection.$cursor;\n if (!$cursor || (view ? !view.endOfTextblock(\"backward\", state) : $cursor.parentOffset > 0)) return null;\n return $cursor;\n}\nvar joinBackward = function joinBackward(state, dispatch, view) {\n var $cursor = atBlockStart(state, view);\n if (!$cursor) return false;\n var $cut = findCutBefore($cursor);\n if (!$cut) {\n var range = $cursor.blockRange(),\n target = range && prosemirrorTransform.liftTarget(range);\n if (target == null) return false;\n if (dispatch) dispatch(state.tr.lift(range, target).scrollIntoView());\n return true;\n }\n var before = $cut.nodeBefore;\n if (deleteBarrier(state, $cut, dispatch, -1)) return true;\n if ($cursor.parent.content.size == 0 && (textblockAt(before, \"end\") || prosemirrorState.NodeSelection.isSelectable(before))) {\n for (var depth = $cursor.depth;; depth--) {\n var delStep = prosemirrorTransform.replaceStep(state.doc, $cursor.before(depth), $cursor.after(depth), prosemirrorModel.Slice.empty);\n if (delStep && delStep.slice.size < delStep.to - delStep.from) {\n if (dispatch) {\n var tr = state.tr.step(delStep);\n tr.setSelection(textblockAt(before, \"end\") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos, -1)), -1) : prosemirrorState.NodeSelection.create(tr.doc, $cut.pos - before.nodeSize));\n dispatch(tr.scrollIntoView());\n }\n return true;\n }\n if (depth == 1 || $cursor.node(depth - 1).childCount > 1) break;\n }\n }\n if (before.isAtom && $cut.depth == $cursor.depth - 1) {\n if (dispatch) dispatch(state.tr[\"delete\"]($cut.pos - before.nodeSize, $cut.pos).scrollIntoView());\n return true;\n }\n return false;\n};\nvar joinTextblockBackward = function joinTextblockBackward(state, dispatch, view) {\n var $cursor = atBlockStart(state, view);\n if (!$cursor) return false;\n var $cut = findCutBefore($cursor);\n return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;\n};\nvar joinTextblockForward = function joinTextblockForward(state, dispatch, view) {\n var $cursor = atBlockEnd(state, view);\n if (!$cursor) return false;\n var $cut = findCutAfter($cursor);\n return $cut ? joinTextblocksAround(state, $cut, dispatch) : false;\n};\nfunction joinTextblocksAround(state, $cut, dispatch) {\n var before = $cut.nodeBefore,\n beforeText = before,\n beforePos = $cut.pos - 1;\n for (; !beforeText.isTextblock; beforePos--) {\n if (beforeText.type.spec.isolating) return false;\n var child = beforeText.lastChild;\n if (!child) return false;\n beforeText = child;\n }\n var after = $cut.nodeAfter,\n afterText = after,\n afterPos = $cut.pos + 1;\n for (; !afterText.isTextblock; afterPos++) {\n if (afterText.type.spec.isolating) return false;\n var _child = afterText.firstChild;\n if (!_child) return false;\n afterText = _child;\n }\n var step = prosemirrorTransform.replaceStep(state.doc, beforePos, afterPos, prosemirrorModel.Slice.empty);\n if (!step || step.from != beforePos || step instanceof prosemirrorTransform.ReplaceStep && step.slice.size >= afterPos - beforePos) return false;\n if (dispatch) {\n var tr = state.tr.step(step);\n tr.setSelection(prosemirrorState.TextSelection.create(tr.doc, beforePos));\n dispatch(tr.scrollIntoView());\n }\n return true;\n}\nfunction textblockAt(node, side) {\n var only = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n for (var scan = node; scan; scan = side == \"start\" ? scan.firstChild : scan.lastChild) {\n if (scan.isTextblock) return true;\n if (only && scan.childCount != 1) return false;\n }\n return false;\n}\nvar selectNodeBackward = function selectNodeBackward(state, dispatch, view) {\n var _state$selection = state.selection,\n $head = _state$selection.$head,\n empty = _state$selection.empty,\n $cut = $head;\n if (!empty) return false;\n if ($head.parent.isTextblock) {\n if (view ? !view.endOfTextblock(\"backward\", state) : $head.parentOffset > 0) return false;\n $cut = findCutBefore($head);\n }\n var node = $cut && $cut.nodeBefore;\n if (!node || !prosemirrorState.NodeSelection.isSelectable(node)) return false;\n if (dispatch) dispatch(state.tr.setSelection(prosemirrorState.NodeSelection.create(state.doc, $cut.pos - node.nodeSize)).scrollIntoView());\n return true;\n};\nfunction findCutBefore($pos) {\n if (!$pos.parent.type.spec.isolating) for (var i = $pos.depth - 1; i >= 0; i--) {\n if ($pos.index(i) > 0) return $pos.doc.resolve($pos.before(i + 1));\n if ($pos.node(i).type.spec.isolating) break;\n }\n return null;\n}\nfunction atBlockEnd(state, view) {\n var $cursor = state.selection.$cursor;\n if (!$cursor || (view ? !view.endOfTextblock(\"forward\", state) : $cursor.parentOffset < $cursor.parent.content.size)) return null;\n return $cursor;\n}\nvar joinForward = function joinForward(state, dispatch, view) {\n var $cursor = atBlockEnd(state, view);\n if (!$cursor) return false;\n var $cut = findCutAfter($cursor);\n if (!$cut) return false;\n var after = $cut.nodeAfter;\n if (deleteBarrier(state, $cut, dispatch, 1)) return true;\n if ($cursor.parent.content.size == 0 && (textblockAt(after, \"start\") || prosemirrorState.NodeSelection.isSelectable(after))) {\n var delStep = prosemirrorTransform.replaceStep(state.doc, $cursor.before(), $cursor.after(), prosemirrorModel.Slice.empty);\n if (delStep && delStep.slice.size < delStep.to - delStep.from) {\n if (dispatch) {\n var tr = state.tr.step(delStep);\n tr.setSelection(textblockAt(after, \"start\") ? prosemirrorState.Selection.findFrom(tr.doc.resolve(tr.mapping.map($cut.pos)), 1) : prosemirrorState.NodeSelection.create(tr.doc, tr.mapping.map($cut.pos)));\n dispatch(tr.scrollIntoView());\n }\n return true;\n }\n }\n if (after.isAtom && $cut.depth == $cursor.depth - 1) {\n if (dispatch) dispatch(state.tr[\"delete\"]($cut.pos, $cut.pos + after.nodeSize).scrollIntoView());\n return true;\n }\n return false;\n};\nvar selectNodeForward = function selectNodeForward(state, dispatch, view) {\n var _state$selection2 = state.selection,\n $head = _state$selection2.$head,\n empty = _state$selection2.empty,\n $cut = $head;\n if (!empty) return false;\n if ($head.parent.isTextblock) {\n if (view ? !view.endOfTextblock(\"forward\", state) : $head.parentOffset < $head.parent.content.size) return false;\n $cut = findCutAfter($head);\n }\n var node = $cut && $cut.nodeAfter;\n if (!node || !prosemirrorState.NodeSelection.isSelectable(node)) return false;\n if (dispatch) dispatch(state.tr.setSelection(prosemirrorState.NodeSelection.create(state.doc, $cut.pos)).scrollIntoView());\n return true;\n};\nfunction findCutAfter($pos) {\n if (!$pos.parent.type.spec.isolating) for (var i = $pos.depth - 1; i >= 0; i--) {\n var parent = $pos.node(i);\n if ($pos.index(i) + 1 < parent.childCount) return $pos.doc.resolve($pos.after(i + 1));\n if (parent.type.spec.isolating) break;\n }\n return null;\n}\nvar joinUp = function joinUp(state, dispatch) {\n var sel = state.selection,\n nodeSel = sel instanceof prosemirrorState.NodeSelection,\n point;\n if (nodeSel) {\n if (sel.node.isTextblock || !prosemirrorTransform.canJoin(state.doc, sel.from)) return false;\n point = sel.from;\n } else {\n point = prosemirrorTransform.joinPoint(state.doc, sel.from, -1);\n if (point == null) return false;\n }\n if (dispatch) {\n var tr = state.tr.join(point);\n if (nodeSel) tr.setSelection(prosemirrorState.NodeSelection.create(tr.doc, point - state.doc.resolve(point).nodeBefore.nodeSize));\n dispatch(tr.scrollIntoView());\n }\n return true;\n};\nvar joinDown = function joinDown(state, dispatch) {\n var sel = state.selection,\n point;\n if (sel instanceof prosemirrorState.NodeSelection) {\n if (sel.node.isTextblock || !prosemirrorTransform.canJoin(state.doc, sel.to)) return false;\n point = sel.to;\n } else {\n point = prosemirrorTransform.joinPoint(state.doc, sel.to, 1);\n if (point == null) return false;\n }\n if (dispatch) dispatch(state.tr.join(point).scrollIntoView());\n return true;\n};\nvar lift = function lift(state, dispatch) {\n var _state$selection3 = state.selection,\n $from = _state$selection3.$from,\n $to = _state$selection3.$to;\n var range = $from.blockRange($to),\n target = range && prosemirrorTransform.liftTarget(range);\n if (target == null) return false;\n if (dispatch) dispatch(state.tr.lift(range, target).scrollIntoView());\n return true;\n};\nvar newlineInCode = function newlineInCode(state, dispatch) {\n var _state$selection4 = state.selection,\n $head = _state$selection4.$head,\n $anchor = _state$selection4.$anchor;\n if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) return false;\n if (dispatch) dispatch(state.tr.insertText(\"\\n\").scrollIntoView());\n return true;\n};\nfunction defaultBlockAt(match) {\n for (var i = 0; i < match.edgeCount; i++) {\n var _match$edge = match.edge(i),\n type = _match$edge.type;\n if (type.isTextblock && !type.hasRequiredAttrs()) return type;\n }\n return null;\n}\nvar exitCode = function exitCode(state, dispatch) {\n var _state$selection5 = state.selection,\n $head = _state$selection5.$head,\n $anchor = _state$selection5.$anchor;\n if (!$head.parent.type.spec.code || !$head.sameParent($anchor)) return false;\n var above = $head.node(-1),\n after = $head.indexAfter(-1),\n type = defaultBlockAt(above.contentMatchAt(after));\n if (!type || !above.canReplaceWith(after, after, type)) return false;\n if (dispatch) {\n var pos = $head.after(),\n tr = state.tr.replaceWith(pos, pos, type.createAndFill());\n tr.setSelection(prosemirrorState.Selection.near(tr.doc.resolve(pos), 1));\n dispatch(tr.scrollIntoView());\n }\n return true;\n};\nvar createParagraphNear = function createParagraphNear(state, dispatch) {\n var sel = state.selection,\n $from = sel.$from,\n $to = sel.$to;\n if (sel instanceof prosemirrorState.AllSelection || $from.parent.inlineContent || $to.parent.inlineContent) return false;\n var type = defaultBlockAt($to.parent.contentMatchAt($to.indexAfter()));\n if (!type || !type.isTextblock) return false;\n if (dispatch) {\n var side = (!$from.parentOffset && $to.index() < $to.parent.childCount ? $from : $to).pos;\n var tr = state.tr.insert(side, type.createAndFill());\n tr.setSelection(prosemirrorState.TextSelection.create(tr.doc, side + 1));\n dispatch(tr.scrollIntoView());\n }\n return true;\n};\nvar liftEmptyBlock = function liftEmptyBlock(state, dispatch) {\n var $cursor = state.selection.$cursor;\n if (!$cursor || $cursor.parent.content.size) return false;\n if ($cursor.depth > 1 && $cursor.after() != $cursor.end(-1)) {\n var before = $cursor.before();\n if (prosemirrorTransform.canSplit(state.doc, before)) {\n if (dispatch) dispatch(state.tr.split(before).scrollIntoView());\n return true;\n }\n }\n var range = $cursor.blockRange(),\n target = range && prosemirrorTransform.liftTarget(range);\n if (target == null) return false;\n if (dispatch) dispatch(state.tr.lift(range, target).scrollIntoView());\n return true;\n};\nfunction splitBlockAs(splitNode) {\n return function (state, dispatch) {\n if (state.selection instanceof prosemirrorState.NodeSelection && state.selection.node.isBlock) {\n var _$from = state.selection.$from;\n if (!_$from.parentOffset || !prosemirrorTransform.canSplit(state.doc, _$from.pos)) return false;\n if (dispatch) dispatch(state.tr.split(_$from.pos).scrollIntoView());\n return true;\n }\n if (!state.selection.$from.depth) return false;\n var tr = state.tr;\n if (!state.selection.empty && (state.selection instanceof prosemirrorState.TextSelection || state.selection instanceof prosemirrorState.AllSelection)) tr.deleteSelection();\n var $from = tr.selection.$from,\n mapFrom = tr.steps.length;\n var types = [];\n var splitDepth,\n deflt,\n atEnd = false,\n atStart = false;\n for (var d = $from.depth;; d--) {\n var node = $from.node(d);\n if (node.isBlock) {\n atEnd = $from.end(d) == $from.pos + ($from.depth - d);\n atStart = $from.start(d) == $from.pos - ($from.depth - d);\n deflt = defaultBlockAt($from.node(d - 1).contentMatchAt($from.indexAfter(d - 1)));\n var splitType = splitNode && splitNode($from.parent, atEnd, $from);\n types.unshift(splitType || (atEnd && deflt ? {\n type: deflt\n } : null));\n splitDepth = d;\n break;\n } else {\n if (d == 1) return false;\n types.unshift(null);\n }\n }\n var splitPos = $from.pos;\n var can = prosemirrorTransform.canSplit(tr.doc, splitPos, types.length, types);\n if (!can) {\n types[0] = deflt ? {\n type: deflt\n } : null;\n can = prosemirrorTransform.canSplit(tr.doc, splitPos, types.length, types);\n }\n if (!can) return false;\n tr.split(splitPos, types.length, types);\n if (!atEnd && atStart && $from.node(splitDepth).type != deflt) {\n var mapping = tr.mapping.slice(mapFrom);\n var first = mapping.map($from.before(splitDepth)),\n $first = tr.doc.resolve(first);\n if (deflt && $from.node(splitDepth - 1).canReplaceWith($first.index(), $first.index() + 1, deflt)) tr.setNodeMarkup(mapping.map($from.before(splitDepth)), deflt);\n }\n if (dispatch) dispatch(tr.scrollIntoView());\n return true;\n };\n}\nvar splitBlock = splitBlockAs();\nvar splitBlockKeepMarks = function splitBlockKeepMarks(state, dispatch) {\n return splitBlock(state, dispatch && function (tr) {\n var marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();\n if (marks) tr.ensureMarks(marks);\n dispatch(tr);\n });\n};\nvar selectParentNode = function selectParentNode(state, dispatch) {\n var _state$selection6 = state.selection,\n $from = _state$selection6.$from,\n to = _state$selection6.to,\n pos;\n var same = $from.sharedDepth(to);\n if (same == 0) return false;\n pos = $from.before(same);\n if (dispatch) dispatch(state.tr.setSelection(prosemirrorState.NodeSelection.create(state.doc, pos)));\n return true;\n};\nvar selectAll = function selectAll(state, dispatch) {\n if (dispatch) dispatch(state.tr.setSelection(new prosemirrorState.AllSelection(state.doc)));\n return true;\n};\nfunction joinMaybeClear(state, $pos, dispatch) {\n var before = $pos.nodeBefore,\n after = $pos.nodeAfter,\n index = $pos.index();\n if (!before || !after || !before.type.compatibleContent(after.type)) return false;\n if (!before.content.size && $pos.parent.canReplace(index - 1, index)) {\n if (dispatch) dispatch(state.tr[\"delete\"]($pos.pos - before.nodeSize, $pos.pos).scrollIntoView());\n return true;\n }\n if (!$pos.parent.canReplace(index, index + 1) || !(after.isTextblock || prosemirrorTransform.canJoin(state.doc, $pos.pos))) return false;\n if (dispatch) dispatch(state.tr.join($pos.pos).scrollIntoView());\n return true;\n}\nfunction deleteBarrier(state, $cut, dispatch, dir) {\n var before = $cut.nodeBefore,\n after = $cut.nodeAfter,\n conn,\n match;\n var isolated = before.type.spec.isolating || after.type.spec.isolating;\n if (!isolated && joinMaybeClear(state, $cut, dispatch)) return true;\n var canDelAfter = !isolated && $cut.parent.canReplace($cut.index(), $cut.index() + 1);\n if (canDelAfter && (conn = (match = before.contentMatchAt(before.childCount)).findWrapping(after.type)) && match.matchType(conn[0] || after.type).validEnd) {\n if (dispatch) {\n var end = $cut.pos + after.nodeSize,\n wrap = prosemirrorModel.Fragment.empty;\n for (var i = conn.length - 1; i >= 0; i--) wrap = prosemirrorModel.Fragment.from(conn[i].create(null, wrap));\n wrap = prosemirrorModel.Fragment.from(before.copy(wrap));\n var tr = state.tr.step(new prosemirrorTransform.ReplaceAroundStep($cut.pos - 1, end, $cut.pos, end, new prosemirrorModel.Slice(wrap, 1, 0), conn.length, true));\n var $joinAt = tr.doc.resolve(end + 2 * conn.length);\n if ($joinAt.nodeAfter && $joinAt.nodeAfter.type == before.type && prosemirrorTransform.canJoin(tr.doc, $joinAt.pos)) tr.join($joinAt.pos);\n dispatch(tr.scrollIntoView());\n }\n return true;\n }\n var selAfter = after.type.spec.isolating || dir > 0 && isolated ? null : prosemirrorState.Selection.findFrom($cut, 1);\n var range = selAfter && selAfter.$from.blockRange(selAfter.$to),\n target = range && prosemirrorTransform.liftTarget(range);\n if (target != null && target >= $cut.depth) {\n if (dispatch) dispatch(state.tr.lift(range, target).scrollIntoView());\n return true;\n }\n if (canDelAfter && textblockAt(after, \"start\", true) && textblockAt(before, \"end\")) {\n var at = before,\n _wrap = [];\n for (;;) {\n _wrap.push(at);\n if (at.isTextblock) break;\n at = at.lastChild;\n }\n var afterText = after,\n afterDepth = 1;\n for (; !afterText.isTextblock; afterText = afterText.firstChild) afterDepth++;\n if (at.canReplace(at.childCount, at.childCount, afterText.content)) {\n if (dispatch) {\n var _end = prosemirrorModel.Fragment.empty;\n for (var _i = _wrap.length - 1; _i >= 0; _i--) _end = prosemirrorModel.Fragment.from(_wrap[_i].copy(_end));\n var _tr = state.tr.step(new prosemirrorTransform.ReplaceAroundStep($cut.pos - _wrap.length, $cut.pos + after.nodeSize, $cut.pos + afterDepth, $cut.pos + after.nodeSize - afterDepth, new prosemirrorModel.Slice(_end, _wrap.length, 0), 0, true));\n dispatch(_tr.scrollIntoView());\n }\n return true;\n }\n }\n return false;\n}\nfunction selectTextblockSide(side) {\n return function (state, dispatch) {\n var sel = state.selection,\n $pos = side < 0 ? sel.$from : sel.$to;\n var depth = $pos.depth;\n while ($pos.node(depth).isInline) {\n if (!depth) return false;\n depth--;\n }\n if (!$pos.node(depth).isTextblock) return false;\n if (dispatch) dispatch(state.tr.setSelection(prosemirrorState.TextSelection.create(state.doc, side < 0 ? $pos.start(depth) : $pos.end(depth))));\n return true;\n };\n}\nvar selectTextblockStart = selectTextblockSide(-1);\nvar selectTextblockEnd = selectTextblockSide(1);\nfunction wrapIn(nodeType) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return function (state, dispatch) {\n var _state$selection7 = state.selection,\n $from = _state$selection7.$from,\n $to = _state$selection7.$to;\n var range = $from.blockRange($to),\n wrapping = range && prosemirrorTransform.findWrapping(range, nodeType, attrs);\n if (!wrapping) return false;\n if (dispatch) dispatch(state.tr.wrap(range, wrapping).scrollIntoView());\n return true;\n };\n}\nfunction setBlockType(nodeType) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return function (state, dispatch) {\n var applicable = false;\n for (var i = 0; i < state.selection.ranges.length && !applicable; i++) {\n var _state$selection$rang = state.selection.ranges[i],\n from = _state$selection$rang.$from.pos,\n to = _state$selection$rang.$to.pos;\n state.doc.nodesBetween(from, to, function (node, pos) {\n if (applicable) return false;\n if (!node.isTextblock || node.hasMarkup(nodeType, attrs)) return;\n if (node.type == nodeType) {\n applicable = true;\n } else {\n var $pos = state.doc.resolve(pos),\n index = $pos.index();\n applicable = $pos.parent.canReplaceWith(index, index + 1, nodeType);\n }\n });\n }\n if (!applicable) return false;\n if (dispatch) {\n var tr = state.tr;\n for (var _i2 = 0; _i2 < state.selection.ranges.length; _i2++) {\n var _state$selection$rang2 = state.selection.ranges[_i2],\n _from = _state$selection$rang2.$from.pos,\n _to = _state$selection$rang2.$to.pos;\n tr.setBlockType(_from, _to, nodeType, attrs);\n }\n dispatch(tr.scrollIntoView());\n }\n return true;\n };\n}\nfunction markApplies(doc, ranges, type, enterAtoms) {\n var _loop = function _loop() {\n var _ranges$i = ranges[i],\n $from = _ranges$i.$from,\n $to = _ranges$i.$to;\n var can = $from.depth == 0 ? doc.inlineContent && doc.type.allowsMarkType(type) : false;\n doc.nodesBetween($from.pos, $to.pos, function (node, pos) {\n if (can || !enterAtoms && node.isAtom && node.isInline && pos >= $from.pos && pos + node.nodeSize <= $to.pos) return false;\n can = node.inlineContent && node.type.allowsMarkType(type);\n });\n if (can) return {\n v: true\n };\n },\n _ret;\n for (var i = 0; i < ranges.length; i++) {\n _ret = _loop();\n if (_ret) return _ret.v;\n }\n return false;\n}\nfunction removeInlineAtoms(ranges) {\n var result = [];\n var _loop2 = function _loop2() {\n var _ranges$i2 = ranges[i],\n $from = _ranges$i2.$from,\n $to = _ranges$i2.$to;\n $from.doc.nodesBetween($from.pos, $to.pos, function (node, pos) {\n if (node.isAtom && node.content.size && node.isInline && pos >= $from.pos && pos + node.nodeSize <= $to.pos) {\n if (pos + 1 > $from.pos) result.push(new prosemirrorState.SelectionRange($from, $from.doc.resolve(pos + 1)));\n $from = $from.doc.resolve(pos + 1 + node.content.size);\n return false;\n }\n });\n if ($from.pos < $to.pos) result.push(new prosemirrorState.SelectionRange($from, $to));\n };\n for (var i = 0; i < ranges.length; i++) {\n _loop2();\n }\n return result;\n}\nfunction toggleMark(markType) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var options = arguments.length > 2 ? arguments[2] : undefined;\n var removeWhenPresent = (options && options.removeWhenPresent) !== false;\n var enterAtoms = (options && options.enterInlineAtoms) !== false;\n var dropSpace = !(options && options.includeWhitespace);\n return function (state, dispatch) {\n var _state$selection8 = state.selection,\n empty = _state$selection8.empty,\n $cursor = _state$selection8.$cursor,\n ranges = _state$selection8.ranges;\n if (empty && !$cursor || !markApplies(state.doc, ranges, markType, enterAtoms)) return false;\n if (dispatch) {\n if ($cursor) {\n if (markType.isInSet(state.storedMarks || $cursor.marks())) dispatch(state.tr.removeStoredMark(markType));else dispatch(state.tr.addStoredMark(markType.create(attrs)));\n } else {\n var add,\n tr = state.tr;\n if (!enterAtoms) ranges = removeInlineAtoms(ranges);\n if (removeWhenPresent) {\n add = !ranges.some(function (r) {\n return state.doc.rangeHasMark(r.$from.pos, r.$to.pos, markType);\n });\n } else {\n add = !ranges.every(function (r) {\n var missing = false;\n tr.doc.nodesBetween(r.$from.pos, r.$to.pos, function (node, pos, parent) {\n if (missing) return false;\n missing = !markType.isInSet(node.marks) && !!parent && parent.type.allowsMarkType(markType) && !(node.isText && /^\\s*$/.test(node.textBetween(Math.max(0, r.$from.pos - pos), Math.min(node.nodeSize, r.$to.pos - pos))));\n });\n return !missing;\n });\n }\n for (var i = 0; i < ranges.length; i++) {\n var _ranges$i3 = ranges[i],\n $from = _ranges$i3.$from,\n $to = _ranges$i3.$to;\n if (!add) {\n tr.removeMark($from.pos, $to.pos, markType);\n } else {\n var from = $from.pos,\n to = $to.pos,\n start = $from.nodeAfter,\n end = $to.nodeBefore;\n var spaceStart = dropSpace && start && start.isText ? /^\\s*/.exec(start.text)[0].length : 0;\n var spaceEnd = dropSpace && end && end.isText ? /\\s*$/.exec(end.text)[0].length : 0;\n if (from + spaceStart < to) {\n from += spaceStart;\n to -= spaceEnd;\n }\n tr.addMark(from, to, markType.create(attrs));\n }\n }\n dispatch(tr.scrollIntoView());\n }\n }\n return true;\n };\n}\nfunction wrapDispatchForJoin(dispatch, isJoinable) {\n return function (tr) {\n if (!tr.isGeneric) return dispatch(tr);\n var ranges = [];\n for (var i = 0; i < tr.mapping.maps.length; i++) {\n var map = tr.mapping.maps[i];\n for (var j = 0; j < ranges.length; j++) ranges[j] = map.map(ranges[j]);\n map.forEach(function (_s, _e, from, to) {\n return ranges.push(from, to);\n });\n }\n var joinable = [];\n for (var _i3 = 0; _i3 < ranges.length; _i3 += 2) {\n var from = ranges[_i3],\n to = ranges[_i3 + 1];\n var $from = tr.doc.resolve(from),\n depth = $from.sharedDepth(to),\n parent = $from.node(depth);\n for (var index = $from.indexAfter(depth), pos = $from.after(depth + 1); pos <= to; ++index) {\n var after = parent.maybeChild(index);\n if (!after) break;\n if (index && joinable.indexOf(pos) == -1) {\n var before = parent.child(index - 1);\n if (before.type == after.type && isJoinable(before, after)) joinable.push(pos);\n }\n pos += after.nodeSize;\n }\n }\n joinable.sort(function (a, b) {\n return a - b;\n });\n for (var _i4 = joinable.length - 1; _i4 >= 0; _i4--) {\n if (prosemirrorTransform.canJoin(tr.doc, joinable[_i4])) tr.join(joinable[_i4]);\n }\n dispatch(tr);\n };\n}\nfunction autoJoin(command, isJoinable) {\n var canJoin = Array.isArray(isJoinable) ? function (node) {\n return isJoinable.indexOf(node.type.name) > -1;\n } : isJoinable;\n return function (state, dispatch, view) {\n return command(state, dispatch && wrapDispatchForJoin(dispatch, canJoin), view);\n };\n}\nfunction chainCommands() {\n for (var _len = arguments.length, commands = new Array(_len), _key = 0; _key < _len; _key++) {\n commands[_key] = arguments[_key];\n }\n return function (state, dispatch, view) {\n for (var i = 0; i < commands.length; i++) if (commands[i](state, dispatch, view)) return true;\n return false;\n };\n}\nvar backspace = chainCommands(deleteSelection, joinBackward, selectNodeBackward);\nvar del = chainCommands(deleteSelection, joinForward, selectNodeForward);\nvar pcBaseKeymap = {\n \"Enter\": chainCommands(newlineInCode, createParagraphNear, liftEmptyBlock, splitBlock),\n \"Mod-Enter\": exitCode,\n \"Backspace\": backspace,\n \"Mod-Backspace\": backspace,\n \"Shift-Backspace\": backspace,\n \"Delete\": del,\n \"Mod-Delete\": del,\n \"Mod-a\": selectAll\n};\nvar macBaseKeymap = {\n \"Ctrl-h\": pcBaseKeymap[\"Backspace\"],\n \"Alt-Backspace\": pcBaseKeymap[\"Mod-Backspace\"],\n \"Ctrl-d\": pcBaseKeymap[\"Delete\"],\n \"Ctrl-Alt-Backspace\": pcBaseKeymap[\"Mod-Delete\"],\n \"Alt-Delete\": pcBaseKeymap[\"Mod-Delete\"],\n \"Alt-d\": pcBaseKeymap[\"Mod-Delete\"],\n \"Ctrl-a\": selectTextblockStart,\n \"Ctrl-e\": selectTextblockEnd\n};\nfor (var key in pcBaseKeymap) macBaseKeymap[key] = pcBaseKeymap[key];\nvar mac = typeof navigator != \"undefined\" ? /Mac|iP(hone|[oa]d)/.test(navigator.platform) : typeof os != \"undefined\" && os.platform ? os.platform() == \"darwin\" : false;\nvar baseKeymap = mac ? macBaseKeymap : pcBaseKeymap;\nexports.autoJoin = autoJoin;\nexports.baseKeymap = baseKeymap;\nexports.chainCommands = chainCommands;\nexports.createParagraphNear = createParagraphNear;\nexports.deleteSelection = deleteSelection;\nexports.exitCode = exitCode;\nexports.joinBackward = joinBackward;\nexports.joinDown = joinDown;\nexports.joinForward = joinForward;\nexports.joinTextblockBackward = joinTextblockBackward;\nexports.joinTextblockForward = joinTextblockForward;\nexports.joinUp = joinUp;\nexports.lift = lift;\nexports.liftEmptyBlock = liftEmptyBlock;\nexports.macBaseKeymap = macBaseKeymap;\nexports.newlineInCode = newlineInCode;\nexports.pcBaseKeymap = pcBaseKeymap;\nexports.selectAll = selectAll;\nexports.selectNodeBackward = selectNodeBackward;\nexports.selectNodeForward = selectNodeForward;\nexports.selectParentNode = selectParentNode;\nexports.selectTextblockEnd = selectTextblockEnd;\nexports.selectTextblockStart = selectTextblockStart;\nexports.setBlockType = setBlockType;\nexports.splitBlock = splitBlock;\nexports.splitBlockAs = splitBlockAs;\nexports.splitBlockKeepMarks = splitBlockKeepMarks;\nexports.toggleMark = toggleMark;\nexports.wrapIn = wrapIn;\n","'use strict';\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar prosemirrorState = require('prosemirror-state');\nvar prosemirrorTransform = require('prosemirror-transform');\nfunction dropCursor() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n return new prosemirrorState.Plugin({\n view: function view(editorView) {\n return new DropCursorView(editorView, options);\n }\n });\n}\nvar DropCursorView = function () {\n function DropCursorView(editorView, options) {\n var _this = this;\n _classCallCheck(this, DropCursorView);\n var _a;\n this.editorView = editorView;\n this.cursorPos = null;\n this.element = null;\n this.timeout = -1;\n this.lastDragEvent = null;\n this.width = (_a = options.width) !== null && _a !== void 0 ? _a : 1;\n this.color = options.color === false ? undefined : options.color || \"black\";\n this[\"class\"] = options[\"class\"];\n this.handlers = [\"dragover\", \"dragend\", \"drop\", \"dragleave\"].map(function (name) {\n var handler = function handler(e) {\n _this[name](e);\n };\n editorView.dom.addEventListener(name, handler);\n return {\n name: name,\n handler: handler\n };\n });\n }\n _createClass(DropCursorView, [{\n key: \"destroy\",\n value: function destroy() {\n var _this2 = this;\n this.handlers.forEach(function (_ref) {\n var name = _ref.name,\n handler = _ref.handler;\n return _this2.editorView.dom.removeEventListener(name, handler);\n });\n }\n }, {\n key: \"update\",\n value: function update(editorView, prevState) {\n if (this.cursorPos != null && prevState.doc != editorView.state.doc) {\n if (this.lastDragEvent) {\n var target = this.computeTarget(this.lastDragEvent);\n if (target == this.cursorPos) this.updateOverlay();else this.setCursor(target);\n } else {\n this.updateOverlay();\n }\n }\n }\n }, {\n key: \"setCursor\",\n value: function setCursor(pos) {\n if (pos == this.cursorPos) return;\n this.cursorPos = pos;\n if (pos == null) {\n this.element.parentNode.removeChild(this.element);\n this.element = null;\n } else {\n this.updateOverlay();\n }\n }\n }, {\n key: \"updateOverlay\",\n value: function updateOverlay() {\n var $pos = this.editorView.state.doc.resolve(this.cursorPos);\n var isBlock = !$pos.parent.inlineContent,\n rect;\n var editorDOM = this.editorView.dom,\n editorRect = editorDOM.getBoundingClientRect();\n var scaleX = editorRect.width / editorDOM.offsetWidth,\n scaleY = editorRect.height / editorDOM.offsetHeight;\n if (isBlock) {\n var before = $pos.nodeBefore,\n after = $pos.nodeAfter;\n if (before || after) {\n var node = this.editorView.nodeDOM(this.cursorPos - (before ? before.nodeSize : 0));\n if (node) {\n var nodeRect = node.getBoundingClientRect();\n var top = before ? nodeRect.bottom : nodeRect.top;\n if (before && after) top = (top + this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top) / 2;\n var halfWidth = this.width / 2 * scaleY;\n rect = {\n left: nodeRect.left,\n right: nodeRect.right,\n top: top - halfWidth,\n bottom: top + halfWidth\n };\n }\n }\n }\n if (!rect) {\n var coords = this.editorView.coordsAtPos(this.cursorPos);\n var _halfWidth = this.width / 2 * scaleX;\n rect = {\n left: coords.left - _halfWidth,\n right: coords.left + _halfWidth,\n top: coords.top,\n bottom: coords.bottom\n };\n }\n var parent = this.editorView.dom.offsetParent;\n if (!this.element) {\n this.element = parent.appendChild(document.createElement(\"div\"));\n if (this[\"class\"]) this.element.className = this[\"class\"];\n this.element.style.cssText = \"position: absolute; z-index: 50; pointer-events: none;\";\n if (this.color) {\n this.element.style.backgroundColor = this.color;\n }\n }\n this.element.classList.toggle(\"prosemirror-dropcursor-block\", isBlock);\n this.element.classList.toggle(\"prosemirror-dropcursor-inline\", !isBlock);\n var parentLeft, parentTop;\n if (!parent || parent == document.body && getComputedStyle(parent).position == \"static\") {\n parentLeft = -pageXOffset;\n parentTop = -pageYOffset;\n } else {\n var _rect = parent.getBoundingClientRect();\n var parentScaleX = _rect.width / parent.offsetWidth,\n parentScaleY = _rect.height / parent.offsetHeight;\n parentLeft = _rect.left - parent.scrollLeft * parentScaleX;\n parentTop = _rect.top - parent.scrollTop * parentScaleY;\n }\n this.element.style.left = (rect.left - parentLeft) / scaleX + \"px\";\n this.element.style.top = (rect.top - parentTop) / scaleY + \"px\";\n this.element.style.width = (rect.right - rect.left) / scaleX + \"px\";\n this.element.style.height = (rect.bottom - rect.top) / scaleY + \"px\";\n }\n }, {\n key: \"scheduleRemoval\",\n value: function scheduleRemoval(timeout) {\n var _this3 = this;\n clearTimeout(this.timeout);\n this.timeout = setTimeout(function () {\n return _this3.setCursor(null);\n }, timeout);\n }\n }, {\n key: \"computeTarget\",\n value: function computeTarget(event) {\n var pos = this.editorView.posAtCoords({\n left: event.clientX,\n top: event.clientY\n });\n var node = pos && pos.inside >= 0 && this.editorView.state.doc.nodeAt(pos.inside);\n var disableDropCursor = node && node.type.spec.disableDropCursor;\n var disabled = typeof disableDropCursor == \"function\" ? disableDropCursor(this.editorView, pos, event) : disableDropCursor;\n if (!pos || disabled) return null;\n var target = pos.pos;\n if (this.editorView.dragging && this.editorView.dragging.slice) {\n var point = prosemirrorTransform.dropPoint(this.editorView.state.doc, target, this.editorView.dragging.slice);\n if (point != null) target = point;\n }\n return target;\n }\n }, {\n key: \"dragover\",\n value: function dragover(event) {\n if (!this.editorView.editable) return;\n this.lastDragEvent = event;\n var target = this.computeTarget(event);\n if (target != null) {\n this.setCursor(target);\n this.scheduleRemoval(5000);\n }\n }\n }, {\n key: \"dragend\",\n value: function dragend() {\n this.scheduleRemoval(20);\n }\n }, {\n key: \"drop\",\n value: function drop() {\n this.scheduleRemoval(20);\n }\n }, {\n key: \"dragleave\",\n value: function dragleave(event) {\n if (!this.editorView.dom.contains(event.relatedTarget)) this.setCursor(null);\n }\n }]);\n return DropCursorView;\n}();\nexports.dropCursor = dropCursor;\n","'use strict';\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nvar prosemirrorKeymap = require('prosemirror-keymap');\nvar prosemirrorState = require('prosemirror-state');\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorView = require('prosemirror-view');\nvar GapCursor = function (_prosemirrorState$Sel) {\n _inherits(GapCursor, _prosemirrorState$Sel);\n var _super = _createSuper(GapCursor);\n function GapCursor($pos) {\n _classCallCheck(this, GapCursor);\n return _super.call(this, $pos, $pos);\n }\n _createClass(GapCursor, [{\n key: \"map\",\n value: function map(doc, mapping) {\n var $pos = doc.resolve(mapping.map(this.head));\n return GapCursor.valid($pos) ? new GapCursor($pos) : prosemirrorState.Selection.near($pos);\n }\n }, {\n key: \"content\",\n value: function content() {\n return prosemirrorModel.Slice.empty;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return other instanceof GapCursor && other.head == this.head;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n type: \"gapcursor\",\n pos: this.head\n };\n }\n }, {\n key: \"getBookmark\",\n value: function getBookmark() {\n return new GapBookmark(this.anchor);\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(doc, json) {\n if (typeof json.pos != \"number\") throw new RangeError(\"Invalid input for GapCursor.fromJSON\");\n return new GapCursor(doc.resolve(json.pos));\n }\n }, {\n key: \"valid\",\n value: function valid($pos) {\n var parent = $pos.parent;\n if (parent.inlineContent || !closedBefore($pos) || !closedAfter($pos)) return false;\n var override = parent.type.spec.allowGapCursor;\n if (override != null) return override;\n var deflt = parent.contentMatchAt($pos.index()).defaultType;\n return deflt && deflt.isTextblock;\n }\n }, {\n key: \"findGapCursorFrom\",\n value: function findGapCursorFrom($pos, dir) {\n var mustMove = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n search: for (;;) {\n if (!mustMove && GapCursor.valid($pos)) return $pos;\n var pos = $pos.pos,\n next = null;\n for (var d = $pos.depth;; d--) {\n var parent = $pos.node(d);\n if (dir > 0 ? $pos.indexAfter(d) < parent.childCount : $pos.index(d) > 0) {\n next = parent.child(dir > 0 ? $pos.indexAfter(d) : $pos.index(d) - 1);\n break;\n } else if (d == 0) {\n return null;\n }\n pos += dir;\n var $cur = $pos.doc.resolve(pos);\n if (GapCursor.valid($cur)) return $cur;\n }\n for (;;) {\n var inside = dir > 0 ? next.firstChild : next.lastChild;\n if (!inside) {\n if (next.isAtom && !next.isText && !prosemirrorState.NodeSelection.isSelectable(next)) {\n $pos = $pos.doc.resolve(pos + next.nodeSize * dir);\n mustMove = false;\n continue search;\n }\n break;\n }\n next = inside;\n pos += dir;\n var _$cur = $pos.doc.resolve(pos);\n if (GapCursor.valid(_$cur)) return _$cur;\n }\n return null;\n }\n }\n }]);\n return GapCursor;\n}(prosemirrorState.Selection);\nGapCursor.prototype.visible = false;\nGapCursor.findFrom = GapCursor.findGapCursorFrom;\nprosemirrorState.Selection.jsonID(\"gapcursor\", GapCursor);\nvar GapBookmark = function () {\n function GapBookmark(pos) {\n _classCallCheck(this, GapBookmark);\n this.pos = pos;\n }\n _createClass(GapBookmark, [{\n key: \"map\",\n value: function map(mapping) {\n return new GapBookmark(mapping.map(this.pos));\n }\n }, {\n key: \"resolve\",\n value: function resolve(doc) {\n var $pos = doc.resolve(this.pos);\n return GapCursor.valid($pos) ? new GapCursor($pos) : prosemirrorState.Selection.near($pos);\n }\n }]);\n return GapBookmark;\n}();\nfunction needsGap(type) {\n return type.isAtom || type.spec.isolating || type.spec.createGapCursor;\n}\nfunction closedBefore($pos) {\n for (var d = $pos.depth; d >= 0; d--) {\n var index = $pos.index(d),\n parent = $pos.node(d);\n if (index == 0) {\n if (parent.type.spec.isolating) return true;\n continue;\n }\n for (var before = parent.child(index - 1);; before = before.lastChild) {\n if (before.childCount == 0 && !before.inlineContent || needsGap(before.type)) return true;\n if (before.inlineContent) return false;\n }\n }\n return true;\n}\nfunction closedAfter($pos) {\n for (var d = $pos.depth; d >= 0; d--) {\n var index = $pos.indexAfter(d),\n parent = $pos.node(d);\n if (index == parent.childCount) {\n if (parent.type.spec.isolating) return true;\n continue;\n }\n for (var after = parent.child(index);; after = after.firstChild) {\n if (after.childCount == 0 && !after.inlineContent || needsGap(after.type)) return true;\n if (after.inlineContent) return false;\n }\n }\n return true;\n}\nfunction gapCursor() {\n return new prosemirrorState.Plugin({\n props: {\n decorations: drawGapCursor,\n createSelectionBetween: function createSelectionBetween(_view, $anchor, $head) {\n return $anchor.pos == $head.pos && GapCursor.valid($head) ? new GapCursor($head) : null;\n },\n handleClick: handleClick,\n handleKeyDown: handleKeyDown,\n handleDOMEvents: {\n beforeinput: beforeinput\n }\n }\n });\n}\nvar handleKeyDown = prosemirrorKeymap.keydownHandler({\n \"ArrowLeft\": arrow(\"horiz\", -1),\n \"ArrowRight\": arrow(\"horiz\", 1),\n \"ArrowUp\": arrow(\"vert\", -1),\n \"ArrowDown\": arrow(\"vert\", 1)\n});\nfunction arrow(axis, dir) {\n var dirStr = axis == \"vert\" ? dir > 0 ? \"down\" : \"up\" : dir > 0 ? \"right\" : \"left\";\n return function (state, dispatch, view) {\n var sel = state.selection;\n var $start = dir > 0 ? sel.$to : sel.$from,\n mustMove = sel.empty;\n if (sel instanceof prosemirrorState.TextSelection) {\n if (!view.endOfTextblock(dirStr) || $start.depth == 0) return false;\n mustMove = false;\n $start = state.doc.resolve(dir > 0 ? $start.after() : $start.before());\n }\n var $found = GapCursor.findGapCursorFrom($start, dir, mustMove);\n if (!$found) return false;\n if (dispatch) dispatch(state.tr.setSelection(new GapCursor($found)));\n return true;\n };\n}\nfunction handleClick(view, pos, event) {\n if (!view || !view.editable) return false;\n var $pos = view.state.doc.resolve(pos);\n if (!GapCursor.valid($pos)) return false;\n var clickPos = view.posAtCoords({\n left: event.clientX,\n top: event.clientY\n });\n if (clickPos && clickPos.inside > -1 && prosemirrorState.NodeSelection.isSelectable(view.state.doc.nodeAt(clickPos.inside))) return false;\n view.dispatch(view.state.tr.setSelection(new GapCursor($pos)));\n return true;\n}\nfunction beforeinput(view, event) {\n if (event.inputType != \"insertCompositionText\" || !(view.state.selection instanceof GapCursor)) return false;\n var $from = view.state.selection.$from;\n var insert = $from.parent.contentMatchAt($from.index()).findWrapping(view.state.schema.nodes.text);\n if (!insert) return false;\n var frag = prosemirrorModel.Fragment.empty;\n for (var i = insert.length - 1; i >= 0; i--) frag = prosemirrorModel.Fragment.from(insert[i].createAndFill(null, frag));\n var tr = view.state.tr.replace($from.pos, $from.pos, new prosemirrorModel.Slice(frag, 0, 0));\n tr.setSelection(prosemirrorState.TextSelection.near(tr.doc.resolve($from.pos + 1)));\n view.dispatch(tr);\n return false;\n}\nfunction drawGapCursor(state) {\n if (!(state.selection instanceof GapCursor)) return null;\n var node = document.createElement(\"div\");\n node.className = \"ProseMirror-gapcursor\";\n return prosemirrorView.DecorationSet.create(state.doc, [prosemirrorView.Decoration.widget(state.selection.head, node, {\n key: \"gapcursor\"\n })]);\n}\nexports.GapCursor = GapCursor;\nexports.gapCursor = gapCursor;\n","'use strict';\n\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar RopeSequence = require('rope-sequence');\nvar prosemirrorTransform = require('prosemirror-transform');\nvar prosemirrorState = require('prosemirror-state');\nvar max_empty_items = 500;\nvar Branch = function () {\n function Branch(items, eventCount) {\n _classCallCheck(this, Branch);\n this.items = items;\n this.eventCount = eventCount;\n }\n _createClass(Branch, [{\n key: \"popEvent\",\n value: function popEvent(state, preserveItems) {\n var _this = this;\n if (this.eventCount == 0) return null;\n var end = this.items.length;\n for (;; end--) {\n var next = this.items.get(end - 1);\n if (next.selection) {\n --end;\n break;\n }\n }\n var remap, mapFrom;\n if (preserveItems) {\n remap = this.remapping(end, this.items.length);\n mapFrom = remap.maps.length;\n }\n var transform = state.tr;\n var selection, remaining;\n var addAfter = [],\n addBefore = [];\n this.items.forEach(function (item, i) {\n if (!item.step) {\n if (!remap) {\n remap = _this.remapping(end, i + 1);\n mapFrom = remap.maps.length;\n }\n mapFrom--;\n addBefore.push(item);\n return;\n }\n if (remap) {\n addBefore.push(new Item(item.map));\n var step = item.step.map(remap.slice(mapFrom)),\n map;\n if (step && transform.maybeStep(step).doc) {\n map = transform.mapping.maps[transform.mapping.maps.length - 1];\n addAfter.push(new Item(map, undefined, undefined, addAfter.length + addBefore.length));\n }\n mapFrom--;\n if (map) remap.appendMap(map, mapFrom);\n } else {\n transform.maybeStep(item.step);\n }\n if (item.selection) {\n selection = remap ? item.selection.map(remap.slice(mapFrom)) : item.selection;\n remaining = new Branch(_this.items.slice(0, end).append(addBefore.reverse().concat(addAfter)), _this.eventCount - 1);\n return false;\n }\n }, this.items.length, 0);\n return {\n remaining: remaining,\n transform: transform,\n selection: selection\n };\n }\n }, {\n key: \"addTransform\",\n value: function addTransform(transform, selection, histOptions, preserveItems) {\n var newItems = [],\n eventCount = this.eventCount;\n var oldItems = this.items,\n lastItem = !preserveItems && oldItems.length ? oldItems.get(oldItems.length - 1) : null;\n for (var i = 0; i < transform.steps.length; i++) {\n var step = transform.steps[i].invert(transform.docs[i]);\n var item = new Item(transform.mapping.maps[i], step, selection),\n merged = void 0;\n if (merged = lastItem && lastItem.merge(item)) {\n item = merged;\n if (i) newItems.pop();else oldItems = oldItems.slice(0, oldItems.length - 1);\n }\n newItems.push(item);\n if (selection) {\n eventCount++;\n selection = undefined;\n }\n if (!preserveItems) lastItem = item;\n }\n var overflow = eventCount - histOptions.depth;\n if (overflow > DEPTH_OVERFLOW) {\n oldItems = cutOffEvents(oldItems, overflow);\n eventCount -= overflow;\n }\n return new Branch(oldItems.append(newItems), eventCount);\n }\n }, {\n key: \"remapping\",\n value: function remapping(from, to) {\n var maps = new prosemirrorTransform.Mapping();\n this.items.forEach(function (item, i) {\n var mirrorPos = item.mirrorOffset != null && i - item.mirrorOffset >= from ? maps.maps.length - item.mirrorOffset : undefined;\n maps.appendMap(item.map, mirrorPos);\n }, from, to);\n return maps;\n }\n }, {\n key: \"addMaps\",\n value: function addMaps(array) {\n if (this.eventCount == 0) return this;\n return new Branch(this.items.append(array.map(function (map) {\n return new Item(map);\n })), this.eventCount);\n }\n }, {\n key: \"rebased\",\n value: function rebased(rebasedTransform, rebasedCount) {\n if (!this.eventCount) return this;\n var rebasedItems = [],\n start = Math.max(0, this.items.length - rebasedCount);\n var mapping = rebasedTransform.mapping;\n var newUntil = rebasedTransform.steps.length;\n var eventCount = this.eventCount;\n this.items.forEach(function (item) {\n if (item.selection) eventCount--;\n }, start);\n var iRebased = rebasedCount;\n this.items.forEach(function (item) {\n var pos = mapping.getMirror(--iRebased);\n if (pos == null) return;\n newUntil = Math.min(newUntil, pos);\n var map = mapping.maps[pos];\n if (item.step) {\n var step = rebasedTransform.steps[pos].invert(rebasedTransform.docs[pos]);\n var selection = item.selection && item.selection.map(mapping.slice(iRebased + 1, pos));\n if (selection) eventCount++;\n rebasedItems.push(new Item(map, step, selection));\n } else {\n rebasedItems.push(new Item(map));\n }\n }, start);\n var newMaps = [];\n for (var i = rebasedCount; i < newUntil; i++) newMaps.push(new Item(mapping.maps[i]));\n var items = this.items.slice(0, start).append(newMaps).append(rebasedItems);\n var branch = new Branch(items, eventCount);\n if (branch.emptyItemCount() > max_empty_items) branch = branch.compress(this.items.length - rebasedItems.length);\n return branch;\n }\n }, {\n key: \"emptyItemCount\",\n value: function emptyItemCount() {\n var count = 0;\n this.items.forEach(function (item) {\n if (!item.step) count++;\n });\n return count;\n }\n }, {\n key: \"compress\",\n value: function compress() {\n var upto = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.items.length;\n var remap = this.remapping(0, upto),\n mapFrom = remap.maps.length;\n var items = [],\n events = 0;\n this.items.forEach(function (item, i) {\n if (i >= upto) {\n items.push(item);\n if (item.selection) events++;\n } else if (item.step) {\n var step = item.step.map(remap.slice(mapFrom)),\n map = step && step.getMap();\n mapFrom--;\n if (map) remap.appendMap(map, mapFrom);\n if (step) {\n var selection = item.selection && item.selection.map(remap.slice(mapFrom));\n if (selection) events++;\n var newItem = new Item(map.invert(), step, selection),\n merged,\n last = items.length - 1;\n if (merged = items.length && items[last].merge(newItem)) items[last] = merged;else items.push(newItem);\n }\n } else if (item.map) {\n mapFrom--;\n }\n }, this.items.length, 0);\n return new Branch(RopeSequence.from(items.reverse()), events);\n }\n }]);\n return Branch;\n}();\nBranch.empty = new Branch(RopeSequence.empty, 0);\nfunction cutOffEvents(items, n) {\n var cutPoint;\n items.forEach(function (item, i) {\n if (item.selection && n-- == 0) {\n cutPoint = i;\n return false;\n }\n });\n return items.slice(cutPoint);\n}\nvar Item = function () {\n function Item(map, step, selection, mirrorOffset) {\n _classCallCheck(this, Item);\n this.map = map;\n this.step = step;\n this.selection = selection;\n this.mirrorOffset = mirrorOffset;\n }\n _createClass(Item, [{\n key: \"merge\",\n value: function merge(other) {\n if (this.step && other.step && !other.selection) {\n var step = other.step.merge(this.step);\n if (step) return new Item(step.getMap().invert(), step, this.selection);\n }\n }\n }]);\n return Item;\n}();\nvar HistoryState = _createClass(function HistoryState(done, undone, prevRanges, prevTime, prevComposition) {\n _classCallCheck(this, HistoryState);\n this.done = done;\n this.undone = undone;\n this.prevRanges = prevRanges;\n this.prevTime = prevTime;\n this.prevComposition = prevComposition;\n});\nvar DEPTH_OVERFLOW = 20;\nfunction applyTransaction(history, state, tr, options) {\n var historyTr = tr.getMeta(historyKey),\n rebased;\n if (historyTr) return historyTr.historyState;\n if (tr.getMeta(closeHistoryKey)) history = new HistoryState(history.done, history.undone, null, 0, -1);\n var appended = tr.getMeta(\"appendedTransaction\");\n if (tr.steps.length == 0) {\n return history;\n } else if (appended && appended.getMeta(historyKey)) {\n if (appended.getMeta(historyKey).redo) return new HistoryState(history.done.addTransform(tr, undefined, options, mustPreserveItems(state)), history.undone, rangesFor(tr.mapping.maps), history.prevTime, history.prevComposition);else return new HistoryState(history.done, history.undone.addTransform(tr, undefined, options, mustPreserveItems(state)), null, history.prevTime, history.prevComposition);\n } else if (tr.getMeta(\"addToHistory\") !== false && !(appended && appended.getMeta(\"addToHistory\") === false)) {\n var composition = tr.getMeta(\"composition\");\n var newGroup = history.prevTime == 0 || !appended && history.prevComposition != composition && (history.prevTime < (tr.time || 0) - options.newGroupDelay || !isAdjacentTo(tr, history.prevRanges));\n var prevRanges = appended ? mapRanges(history.prevRanges, tr.mapping) : rangesFor(tr.mapping.maps);\n return new HistoryState(history.done.addTransform(tr, newGroup ? state.selection.getBookmark() : undefined, options, mustPreserveItems(state)), Branch.empty, prevRanges, tr.time, composition == null ? history.prevComposition : composition);\n } else if (rebased = tr.getMeta(\"rebased\")) {\n return new HistoryState(history.done.rebased(tr, rebased), history.undone.rebased(tr, rebased), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);\n } else {\n return new HistoryState(history.done.addMaps(tr.mapping.maps), history.undone.addMaps(tr.mapping.maps), mapRanges(history.prevRanges, tr.mapping), history.prevTime, history.prevComposition);\n }\n}\nfunction isAdjacentTo(transform, prevRanges) {\n if (!prevRanges) return false;\n if (!transform.docChanged) return true;\n var adjacent = false;\n transform.mapping.maps[0].forEach(function (start, end) {\n for (var i = 0; i < prevRanges.length; i += 2) if (start <= prevRanges[i + 1] && end >= prevRanges[i]) adjacent = true;\n });\n return adjacent;\n}\nfunction rangesFor(maps) {\n var result = [];\n for (var i = maps.length - 1; i >= 0 && result.length == 0; i--) maps[i].forEach(function (_from, _to, from, to) {\n return result.push(from, to);\n });\n return result;\n}\nfunction mapRanges(ranges, mapping) {\n if (!ranges) return null;\n var result = [];\n for (var i = 0; i < ranges.length; i += 2) {\n var from = mapping.map(ranges[i], 1),\n to = mapping.map(ranges[i + 1], -1);\n if (from <= to) result.push(from, to);\n }\n return result;\n}\nfunction histTransaction(history, state, redo) {\n var preserveItems = mustPreserveItems(state);\n var histOptions = historyKey.get(state).spec.config;\n var pop = (redo ? history.undone : history.done).popEvent(state, preserveItems);\n if (!pop) return null;\n var selection = pop.selection.resolve(pop.transform.doc);\n var added = (redo ? history.done : history.undone).addTransform(pop.transform, state.selection.getBookmark(), histOptions, preserveItems);\n var newHist = new HistoryState(redo ? added : pop.remaining, redo ? pop.remaining : added, null, 0, -1);\n return pop.transform.setSelection(selection).setMeta(historyKey, {\n redo: redo,\n historyState: newHist\n });\n}\nvar cachedPreserveItems = false,\n cachedPreserveItemsPlugins = null;\nfunction mustPreserveItems(state) {\n var plugins = state.plugins;\n if (cachedPreserveItemsPlugins != plugins) {\n cachedPreserveItems = false;\n cachedPreserveItemsPlugins = plugins;\n for (var i = 0; i < plugins.length; i++) if (plugins[i].spec.historyPreserveItems) {\n cachedPreserveItems = true;\n break;\n }\n }\n return cachedPreserveItems;\n}\nfunction closeHistory(tr) {\n return tr.setMeta(closeHistoryKey, true);\n}\nvar historyKey = new prosemirrorState.PluginKey(\"history\");\nvar closeHistoryKey = new prosemirrorState.PluginKey(\"closeHistory\");\nfunction history() {\n var config = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n config = {\n depth: config.depth || 100,\n newGroupDelay: config.newGroupDelay || 500\n };\n return new prosemirrorState.Plugin({\n key: historyKey,\n state: {\n init: function init() {\n return new HistoryState(Branch.empty, Branch.empty, null, 0, -1);\n },\n apply: function apply(tr, hist, state) {\n return applyTransaction(hist, state, tr, config);\n }\n },\n config: config,\n props: {\n handleDOMEvents: {\n beforeinput: function beforeinput(view, e) {\n var inputType = e.inputType;\n var command = inputType == \"historyUndo\" ? undo : inputType == \"historyRedo\" ? redo : null;\n if (!command || !view.editable) return false;\n e.preventDefault();\n return command(view.state, view.dispatch);\n }\n }\n }\n });\n}\nfunction buildCommand(redo, scroll) {\n return function (state, dispatch) {\n var hist = historyKey.getState(state);\n if (!hist || (redo ? hist.undone : hist.done).eventCount == 0) return false;\n if (dispatch) {\n var tr = histTransaction(hist, state, redo);\n if (tr) dispatch(scroll ? tr.scrollIntoView() : tr);\n }\n return true;\n };\n}\nvar undo = buildCommand(false, true);\nvar redo = buildCommand(true, true);\nvar undoNoScroll = buildCommand(false, false);\nvar redoNoScroll = buildCommand(true, false);\nfunction undoDepth(state) {\n var hist = historyKey.getState(state);\n return hist ? hist.done.eventCount : 0;\n}\nfunction redoDepth(state) {\n var hist = historyKey.getState(state);\n return hist ? hist.undone.eventCount : 0;\n}\nfunction isHistoryTransaction(tr) {\n return tr.getMeta(historyKey) != null;\n}\nexports.closeHistory = closeHistory;\nexports.history = history;\nexports.isHistoryTransaction = isHistoryTransaction;\nexports.redo = redo;\nexports.redoDepth = redoDepth;\nexports.redoNoScroll = redoNoScroll;\nexports.undo = undo;\nexports.undoDepth = undoDepth;\nexports.undoNoScroll = undoNoScroll;\n","'use strict';\n\nvar w3cKeyname = require('w3c-keyname');\nvar prosemirrorState = require('prosemirror-state');\nvar mac = typeof navigator != \"undefined\" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);\nvar windows = typeof navigator != \"undefined\" && /Win/.test(navigator.platform);\nfunction normalizeKeyName(name) {\n var parts = name.split(/-(?!$)/),\n result = parts[parts.length - 1];\n if (result == \"Space\") result = \" \";\n var alt, ctrl, shift, meta;\n for (var i = 0; i < parts.length - 1; i++) {\n var mod = parts[i];\n if (/^(cmd|meta|m)$/i.test(mod)) meta = true;else if (/^a(lt)?$/i.test(mod)) alt = true;else if (/^(c|ctrl|control)$/i.test(mod)) ctrl = true;else if (/^s(hift)?$/i.test(mod)) shift = true;else if (/^mod$/i.test(mod)) {\n if (mac) meta = true;else ctrl = true;\n } else throw new Error(\"Unrecognized modifier name: \" + mod);\n }\n if (alt) result = \"Alt-\" + result;\n if (ctrl) result = \"Ctrl-\" + result;\n if (meta) result = \"Meta-\" + result;\n if (shift) result = \"Shift-\" + result;\n return result;\n}\nfunction normalize(map) {\n var copy = Object.create(null);\n for (var prop in map) copy[normalizeKeyName(prop)] = map[prop];\n return copy;\n}\nfunction modifiers(name, event) {\n var shift = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;\n if (event.altKey) name = \"Alt-\" + name;\n if (event.ctrlKey) name = \"Ctrl-\" + name;\n if (event.metaKey) name = \"Meta-\" + name;\n if (shift && event.shiftKey) name = \"Shift-\" + name;\n return name;\n}\nfunction keymap(bindings) {\n return new prosemirrorState.Plugin({\n props: {\n handleKeyDown: keydownHandler(bindings)\n }\n });\n}\nfunction keydownHandler(bindings) {\n var map = normalize(bindings);\n return function (view, event) {\n var name = w3cKeyname.keyName(event),\n baseName,\n direct = map[modifiers(name, event)];\n if (direct && direct(view.state, view.dispatch, view)) return true;\n if (name.length == 1 && name != \" \") {\n if (event.shiftKey) {\n var noShift = map[modifiers(name, event, false)];\n if (noShift && noShift(view.state, view.dispatch, view)) return true;\n }\n if ((event.altKey || event.metaKey || event.ctrlKey) && !(windows && event.ctrlKey && event.altKey) && (baseName = w3cKeyname.base[event.keyCode]) && baseName != name) {\n var fromCode = map[modifiers(baseName, event)];\n if (fromCode && fromCode(view.state, view.dispatch, view)) return true;\n }\n }\n return false;\n };\n}\nexports.keydownHandler = keydownHandler;\nexports.keymap = keymap;\n","'use strict';\n\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; } catch (e) { return typeof fn === \"function\"; } }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar OrderedMap = require('orderedmap');\nfunction _findDiffStart(a, b, pos) {\n for (var i = 0;; i++) {\n if (i == a.childCount || i == b.childCount) return a.childCount == b.childCount ? null : pos;\n var childA = a.child(i),\n childB = b.child(i);\n if (childA == childB) {\n pos += childA.nodeSize;\n continue;\n }\n if (!childA.sameMarkup(childB)) return pos;\n if (childA.isText && childA.text != childB.text) {\n var tA = childA.text,\n tB = childB.text,\n j = 0;\n for (; tA[j] == tB[j]; j++) pos++;\n if (j && j < tA.length && j < tB.length && surrogateHigh(tA.charCodeAt(j - 1)) && surrogateLow(tA.charCodeAt(j))) pos--;\n return pos;\n }\n if (childA.content.size || childB.content.size) {\n var inner = _findDiffStart(childA.content, childB.content, pos + 1);\n if (inner != null) return inner;\n }\n pos += childA.nodeSize;\n }\n}\nfunction _findDiffEnd(a, b, posA, posB) {\n for (var iA = a.childCount, iB = b.childCount;;) {\n if (iA == 0 || iB == 0) return iA == iB ? null : {\n a: posA,\n b: posB\n };\n var childA = a.child(--iA),\n childB = b.child(--iB),\n size = childA.nodeSize;\n if (childA == childB) {\n posA -= size;\n posB -= size;\n continue;\n }\n if (!childA.sameMarkup(childB)) return {\n a: posA,\n b: posB\n };\n if (childA.isText && childA.text != childB.text) {\n var tA = childA.text,\n tB = childB.text,\n _iA = tA.length,\n _iB = tB.length;\n while (_iA > 0 && _iB > 0 && tA[_iA - 1] == tB[_iB - 1]) {\n _iA--;\n _iB--;\n posA--;\n posB--;\n }\n if (_iA && _iB && _iA < tA.length && surrogateHigh(tA.charCodeAt(_iA - 1)) && surrogateLow(tA.charCodeAt(_iA))) {\n posA++;\n posB++;\n }\n return {\n a: posA,\n b: posB\n };\n }\n if (childA.content.size || childB.content.size) {\n var inner = _findDiffEnd(childA.content, childB.content, posA - 1, posB - 1);\n if (inner) return inner;\n }\n posA -= size;\n posB -= size;\n }\n}\nfunction surrogateLow(ch) {\n return ch >= 0xDC00 && ch < 0xE000;\n}\nfunction surrogateHigh(ch) {\n return ch >= 0xD800 && ch < 0xDC00;\n}\nvar Fragment = function () {\n function Fragment(content, size) {\n _classCallCheck(this, Fragment);\n this.content = content;\n this.size = size || 0;\n if (size == null) for (var i = 0; i < content.length; i++) this.size += content[i].nodeSize;\n }\n _createClass(Fragment, [{\n key: \"nodesBetween\",\n value: function nodesBetween(from, to, f) {\n var nodeStart = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var parent = arguments.length > 4 ? arguments[4] : undefined;\n for (var i = 0, pos = 0; pos < to; i++) {\n var child = this.content[i],\n end = pos + child.nodeSize;\n if (end > from && f(child, nodeStart + pos, parent || null, i) !== false && child.content.size) {\n var start = pos + 1;\n child.nodesBetween(Math.max(0, from - start), Math.min(child.content.size, to - start), f, nodeStart + start);\n }\n pos = end;\n }\n }\n }, {\n key: \"descendants\",\n value: function descendants(f) {\n this.nodesBetween(0, this.size, f);\n }\n }, {\n key: \"textBetween\",\n value: function textBetween(from, to, blockSeparator, leafText) {\n var text = \"\",\n first = true;\n this.nodesBetween(from, to, function (node, pos) {\n var nodeText = node.isText ? node.text.slice(Math.max(from, pos) - pos, to - pos) : !node.isLeaf ? \"\" : leafText ? typeof leafText === \"function\" ? leafText(node) : leafText : node.type.spec.leafText ? node.type.spec.leafText(node) : \"\";\n if (node.isBlock && (node.isLeaf && nodeText || node.isTextblock) && blockSeparator) {\n if (first) first = false;else text += blockSeparator;\n }\n text += nodeText;\n }, 0);\n return text;\n }\n }, {\n key: \"append\",\n value: function append(other) {\n if (!other.size) return this;\n if (!this.size) return other;\n var last = this.lastChild,\n first = other.firstChild,\n content = this.content.slice(),\n i = 0;\n if (last.isText && last.sameMarkup(first)) {\n content[content.length - 1] = last.withText(last.text + first.text);\n i = 1;\n }\n for (; i < other.content.length; i++) content.push(other.content[i]);\n return new Fragment(content, this.size + other.size);\n }\n }, {\n key: \"cut\",\n value: function cut(from) {\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;\n if (from == 0 && to == this.size) return this;\n var result = [],\n size = 0;\n if (to > from) for (var i = 0, pos = 0; pos < to; i++) {\n var child = this.content[i],\n end = pos + child.nodeSize;\n if (end > from) {\n if (pos < from || end > to) {\n if (child.isText) child = child.cut(Math.max(0, from - pos), Math.min(child.text.length, to - pos));else child = child.cut(Math.max(0, from - pos - 1), Math.min(child.content.size, to - pos - 1));\n }\n result.push(child);\n size += child.nodeSize;\n }\n pos = end;\n }\n return new Fragment(result, size);\n }\n }, {\n key: \"cutByIndex\",\n value: function cutByIndex(from, to) {\n if (from == to) return Fragment.empty;\n if (from == 0 && to == this.content.length) return this;\n return new Fragment(this.content.slice(from, to));\n }\n }, {\n key: \"replaceChild\",\n value: function replaceChild(index, node) {\n var current = this.content[index];\n if (current == node) return this;\n var copy = this.content.slice();\n var size = this.size + node.nodeSize - current.nodeSize;\n copy[index] = node;\n return new Fragment(copy, size);\n }\n }, {\n key: \"addToStart\",\n value: function addToStart(node) {\n return new Fragment([node].concat(this.content), this.size + node.nodeSize);\n }\n }, {\n key: \"addToEnd\",\n value: function addToEnd(node) {\n return new Fragment(this.content.concat(node), this.size + node.nodeSize);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n if (this.content.length != other.content.length) return false;\n for (var i = 0; i < this.content.length; i++) if (!this.content[i].eq(other.content[i])) return false;\n return true;\n }\n }, {\n key: \"firstChild\",\n get: function get() {\n return this.content.length ? this.content[0] : null;\n }\n }, {\n key: \"lastChild\",\n get: function get() {\n return this.content.length ? this.content[this.content.length - 1] : null;\n }\n }, {\n key: \"childCount\",\n get: function get() {\n return this.content.length;\n }\n }, {\n key: \"child\",\n value: function child(index) {\n var found = this.content[index];\n if (!found) throw new RangeError(\"Index \" + index + \" out of range for \" + this);\n return found;\n }\n }, {\n key: \"maybeChild\",\n value: function maybeChild(index) {\n return this.content[index] || null;\n }\n }, {\n key: \"forEach\",\n value: function forEach(f) {\n for (var i = 0, p = 0; i < this.content.length; i++) {\n var child = this.content[i];\n f(child, p, i);\n p += child.nodeSize;\n }\n }\n }, {\n key: \"findDiffStart\",\n value: function findDiffStart(other) {\n var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n return _findDiffStart(this, other, pos);\n }\n }, {\n key: \"findDiffEnd\",\n value: function findDiffEnd(other) {\n var pos = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.size;\n var otherPos = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : other.size;\n return _findDiffEnd(this, other, pos, otherPos);\n }\n }, {\n key: \"findIndex\",\n value: function findIndex(pos) {\n if (pos == 0) return retIndex(0, pos);\n if (pos == this.size) return retIndex(this.content.length, pos);\n if (pos > this.size || pos < 0) throw new RangeError(\"Position \".concat(pos, \" outside of fragment (\").concat(this, \")\"));\n for (var i = 0, curPos = 0;; i++) {\n var cur = this.child(i),\n end = curPos + cur.nodeSize;\n if (end >= pos) {\n if (end == pos) return retIndex(i + 1, end);\n return retIndex(i, curPos);\n }\n curPos = end;\n }\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return \"<\" + this.toStringInner() + \">\";\n }\n }, {\n key: \"toStringInner\",\n value: function toStringInner() {\n return this.content.join(\", \");\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return this.content.length ? this.content.map(function (n) {\n return n.toJSON();\n }) : null;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, value) {\n if (!value) return Fragment.empty;\n if (!Array.isArray(value)) throw new RangeError(\"Invalid input for Fragment.fromJSON\");\n return Fragment.fromArray(value.map(schema.nodeFromJSON));\n }\n }, {\n key: \"fromArray\",\n value: function fromArray(array) {\n if (!array.length) return Fragment.empty;\n var joined,\n size = 0;\n for (var i = 0; i < array.length; i++) {\n var node = array[i];\n size += node.nodeSize;\n if (i && node.isText && array[i - 1].sameMarkup(node)) {\n if (!joined) joined = array.slice(0, i);\n joined[joined.length - 1] = node.withText(joined[joined.length - 1].text + node.text);\n } else if (joined) {\n joined.push(node);\n }\n }\n return new Fragment(joined || array, size);\n }\n }, {\n key: \"from\",\n value: function from(nodes) {\n if (!nodes) return Fragment.empty;\n if (nodes instanceof Fragment) return nodes;\n if (Array.isArray(nodes)) return this.fromArray(nodes);\n if (nodes.attrs) return new Fragment([nodes], nodes.nodeSize);\n throw new RangeError(\"Can not convert \" + nodes + \" to a Fragment\" + (nodes.nodesBetween ? \" (looks like multiple versions of prosemirror-model were loaded)\" : \"\"));\n }\n }]);\n return Fragment;\n}();\nFragment.empty = new Fragment([], 0);\nvar found = {\n index: 0,\n offset: 0\n};\nfunction retIndex(index, offset) {\n found.index = index;\n found.offset = offset;\n return found;\n}\nfunction compareDeep(a, b) {\n if (a === b) return true;\n if (!(a && _typeof(a) == \"object\") || !(b && _typeof(b) == \"object\")) return false;\n var array = Array.isArray(a);\n if (Array.isArray(b) != array) return false;\n if (array) {\n if (a.length != b.length) return false;\n for (var i = 0; i < a.length; i++) if (!compareDeep(a[i], b[i])) return false;\n } else {\n for (var p in a) if (!(p in b) || !compareDeep(a[p], b[p])) return false;\n for (var _p in b) if (!(_p in a)) return false;\n }\n return true;\n}\nvar Mark = function () {\n function Mark(type, attrs) {\n _classCallCheck(this, Mark);\n this.type = type;\n this.attrs = attrs;\n }\n _createClass(Mark, [{\n key: \"addToSet\",\n value: function addToSet(set) {\n var copy,\n placed = false;\n for (var i = 0; i < set.length; i++) {\n var other = set[i];\n if (this.eq(other)) return set;\n if (this.type.excludes(other.type)) {\n if (!copy) copy = set.slice(0, i);\n } else if (other.type.excludes(this.type)) {\n return set;\n } else {\n if (!placed && other.type.rank > this.type.rank) {\n if (!copy) copy = set.slice(0, i);\n copy.push(this);\n placed = true;\n }\n if (copy) copy.push(other);\n }\n }\n if (!copy) copy = set.slice();\n if (!placed) copy.push(this);\n return copy;\n }\n }, {\n key: \"removeFromSet\",\n value: function removeFromSet(set) {\n for (var i = 0; i < set.length; i++) if (this.eq(set[i])) return set.slice(0, i).concat(set.slice(i + 1));\n return set;\n }\n }, {\n key: \"isInSet\",\n value: function isInSet(set) {\n for (var i = 0; i < set.length; i++) if (this.eq(set[i])) return true;\n return false;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this == other || this.type == other.type && compareDeep(this.attrs, other.attrs);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var obj = {\n type: this.type.name\n };\n for (var _ in this.attrs) {\n obj.attrs = this.attrs;\n break;\n }\n return obj;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (!json) throw new RangeError(\"Invalid input for Mark.fromJSON\");\n var type = schema.marks[json.type];\n if (!type) throw new RangeError(\"There is no mark type \".concat(json.type, \" in this schema\"));\n var mark = type.create(json.attrs);\n type.checkAttrs(mark.attrs);\n return mark;\n }\n }, {\n key: \"sameSet\",\n value: function sameSet(a, b) {\n if (a == b) return true;\n if (a.length != b.length) return false;\n for (var i = 0; i < a.length; i++) if (!a[i].eq(b[i])) return false;\n return true;\n }\n }, {\n key: \"setFrom\",\n value: function setFrom(marks) {\n if (!marks || Array.isArray(marks) && marks.length == 0) return Mark.none;\n if (marks instanceof Mark) return [marks];\n var copy = marks.slice();\n copy.sort(function (a, b) {\n return a.type.rank - b.type.rank;\n });\n return copy;\n }\n }]);\n return Mark;\n}();\nMark.none = [];\nvar ReplaceError = function (_Error) {\n _inherits(ReplaceError, _Error);\n var _super = _createSuper(ReplaceError);\n function ReplaceError() {\n _classCallCheck(this, ReplaceError);\n return _super.apply(this, arguments);\n }\n return _createClass(ReplaceError);\n}(_wrapNativeSuper(Error));\nvar Slice = function () {\n function Slice(content, openStart, openEnd) {\n _classCallCheck(this, Slice);\n this.content = content;\n this.openStart = openStart;\n this.openEnd = openEnd;\n }\n _createClass(Slice, [{\n key: \"size\",\n get: function get() {\n return this.content.size - this.openStart - this.openEnd;\n }\n }, {\n key: \"insertAt\",\n value: function insertAt(pos, fragment) {\n var content = insertInto(this.content, pos + this.openStart, fragment, this.openStart + 1, this.openEnd + 1);\n return content && new Slice(content, this.openStart, this.openEnd);\n }\n }, {\n key: \"removeBetween\",\n value: function removeBetween(from, to) {\n return new Slice(removeRange(this.content, from + this.openStart, to + this.openStart), this.openStart, this.openEnd);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this.content.eq(other.content) && this.openStart == other.openStart && this.openEnd == other.openEnd;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return this.content + \"(\" + this.openStart + \",\" + this.openEnd + \")\";\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n if (!this.content.size) return null;\n var json = {\n content: this.content.toJSON()\n };\n if (this.openStart > 0) json.openStart = this.openStart;\n if (this.openEnd > 0) json.openEnd = this.openEnd;\n return json;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (!json) return Slice.empty;\n var openStart = json.openStart || 0,\n openEnd = json.openEnd || 0;\n if (typeof openStart != \"number\" || typeof openEnd != \"number\") throw new RangeError(\"Invalid input for Slice.fromJSON\");\n return new Slice(Fragment.fromJSON(schema, json.content), openStart, openEnd);\n }\n }, {\n key: \"maxOpen\",\n value: function maxOpen(fragment) {\n var openIsolating = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n var openStart = 0,\n openEnd = 0;\n for (var n = fragment.firstChild; n && !n.isLeaf && (openIsolating || !n.type.spec.isolating); n = n.firstChild) openStart++;\n for (var _n = fragment.lastChild; _n && !_n.isLeaf && (openIsolating || !_n.type.spec.isolating); _n = _n.lastChild) openEnd++;\n return new Slice(fragment, openStart, openEnd);\n }\n }]);\n return Slice;\n}();\nSlice.empty = new Slice(Fragment.empty, 0, 0);\nfunction removeRange(content, from, to) {\n var _content$findIndex = content.findIndex(from),\n index = _content$findIndex.index,\n offset = _content$findIndex.offset,\n child = content.maybeChild(index);\n var _content$findIndex2 = content.findIndex(to),\n indexTo = _content$findIndex2.index,\n offsetTo = _content$findIndex2.offset;\n if (offset == from || child.isText) {\n if (offsetTo != to && !content.child(indexTo).isText) throw new RangeError(\"Removing non-flat range\");\n return content.cut(0, from).append(content.cut(to));\n }\n if (index != indexTo) throw new RangeError(\"Removing non-flat range\");\n return content.replaceChild(index, child.copy(removeRange(child.content, from - offset - 1, to - offset - 1)));\n}\nfunction insertInto(content, dist, insert, openStart, openEnd, parent) {\n var _content$findIndex3 = content.findIndex(dist),\n index = _content$findIndex3.index,\n offset = _content$findIndex3.offset,\n child = content.maybeChild(index);\n if (offset == dist || child.isText) {\n if (parent && openStart <= 0 && openEnd <= 0 && !parent.canReplace(index, index, insert)) return null;\n return content.cut(0, dist).append(insert).append(content.cut(dist));\n }\n var inner = insertInto(child.content, dist - offset - 1, insert, index == 0 ? openStart - 1 : 0, index == content.childCount - 1 ? openEnd - 1 : 0, child);\n return inner && content.replaceChild(index, child.copy(inner));\n}\nfunction _replace($from, $to, slice) {\n if (slice.openStart > $from.depth) throw new ReplaceError(\"Inserted content deeper than insertion position\");\n if ($from.depth - slice.openStart != $to.depth - slice.openEnd) throw new ReplaceError(\"Inconsistent open depths\");\n return replaceOuter($from, $to, slice, 0);\n}\nfunction replaceOuter($from, $to, slice, depth) {\n var index = $from.index(depth),\n node = $from.node(depth);\n if (index == $to.index(depth) && depth < $from.depth - slice.openStart) {\n var inner = replaceOuter($from, $to, slice, depth + 1);\n return node.copy(node.content.replaceChild(index, inner));\n } else if (!slice.content.size) {\n return close(node, replaceTwoWay($from, $to, depth));\n } else if (!slice.openStart && !slice.openEnd && $from.depth == depth && $to.depth == depth) {\n var parent = $from.parent,\n content = parent.content;\n return close(parent, content.cut(0, $from.parentOffset).append(slice.content).append(content.cut($to.parentOffset)));\n } else {\n var _prepareSliceForRepla = prepareSliceForReplace(slice, $from),\n start = _prepareSliceForRepla.start,\n end = _prepareSliceForRepla.end;\n return close(node, replaceThreeWay($from, start, end, $to, depth));\n }\n}\nfunction checkJoin(main, sub) {\n if (!sub.type.compatibleContent(main.type)) throw new ReplaceError(\"Cannot join \" + sub.type.name + \" onto \" + main.type.name);\n}\nfunction joinable($before, $after, depth) {\n var node = $before.node(depth);\n checkJoin(node, $after.node(depth));\n return node;\n}\nfunction addNode(child, target) {\n var last = target.length - 1;\n if (last >= 0 && child.isText && child.sameMarkup(target[last])) target[last] = child.withText(target[last].text + child.text);else target.push(child);\n}\nfunction addRange($start, $end, depth, target) {\n var node = ($end || $start).node(depth);\n var startIndex = 0,\n endIndex = $end ? $end.index(depth) : node.childCount;\n if ($start) {\n startIndex = $start.index(depth);\n if ($start.depth > depth) {\n startIndex++;\n } else if ($start.textOffset) {\n addNode($start.nodeAfter, target);\n startIndex++;\n }\n }\n for (var i = startIndex; i < endIndex; i++) addNode(node.child(i), target);\n if ($end && $end.depth == depth && $end.textOffset) addNode($end.nodeBefore, target);\n}\nfunction close(node, content) {\n if (!node.type.validContent(content)) throw new ReplaceError(\"Invalid content for node \" + node.type.name);\n return node.copy(content);\n}\nfunction replaceThreeWay($from, $start, $end, $to, depth) {\n var openStart = $from.depth > depth && joinable($from, $start, depth + 1);\n var openEnd = $to.depth > depth && joinable($end, $to, depth + 1);\n var content = [];\n addRange(null, $from, depth, content);\n if (openStart && openEnd && $start.index(depth) == $end.index(depth)) {\n checkJoin(openStart, openEnd);\n addNode(close(openStart, replaceThreeWay($from, $start, $end, $to, depth + 1)), content);\n } else {\n if (openStart) addNode(close(openStart, replaceTwoWay($from, $start, depth + 1)), content);\n addRange($start, $end, depth, content);\n if (openEnd) addNode(close(openEnd, replaceTwoWay($end, $to, depth + 1)), content);\n }\n addRange($to, null, depth, content);\n return new Fragment(content);\n}\nfunction replaceTwoWay($from, $to, depth) {\n var content = [];\n addRange(null, $from, depth, content);\n if ($from.depth > depth) {\n var type = joinable($from, $to, depth + 1);\n addNode(close(type, replaceTwoWay($from, $to, depth + 1)), content);\n }\n addRange($to, null, depth, content);\n return new Fragment(content);\n}\nfunction prepareSliceForReplace(slice, $along) {\n var extra = $along.depth - slice.openStart,\n parent = $along.node(extra);\n var node = parent.copy(slice.content);\n for (var i = extra - 1; i >= 0; i--) node = $along.node(i).copy(Fragment.from(node));\n return {\n start: node.resolveNoCache(slice.openStart + extra),\n end: node.resolveNoCache(node.content.size - slice.openEnd - extra)\n };\n}\nvar ResolvedPos = function () {\n function ResolvedPos(pos, path, parentOffset) {\n _classCallCheck(this, ResolvedPos);\n this.pos = pos;\n this.path = path;\n this.parentOffset = parentOffset;\n this.depth = path.length / 3 - 1;\n }\n _createClass(ResolvedPos, [{\n key: \"resolveDepth\",\n value: function resolveDepth(val) {\n if (val == null) return this.depth;\n if (val < 0) return this.depth + val;\n return val;\n }\n }, {\n key: \"parent\",\n get: function get() {\n return this.node(this.depth);\n }\n }, {\n key: \"doc\",\n get: function get() {\n return this.node(0);\n }\n }, {\n key: \"node\",\n value: function node(depth) {\n return this.path[this.resolveDepth(depth) * 3];\n }\n }, {\n key: \"index\",\n value: function index(depth) {\n return this.path[this.resolveDepth(depth) * 3 + 1];\n }\n }, {\n key: \"indexAfter\",\n value: function indexAfter(depth) {\n depth = this.resolveDepth(depth);\n return this.index(depth) + (depth == this.depth && !this.textOffset ? 0 : 1);\n }\n }, {\n key: \"start\",\n value: function start(depth) {\n depth = this.resolveDepth(depth);\n return depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;\n }\n }, {\n key: \"end\",\n value: function end(depth) {\n depth = this.resolveDepth(depth);\n return this.start(depth) + this.node(depth).content.size;\n }\n }, {\n key: \"before\",\n value: function before(depth) {\n depth = this.resolveDepth(depth);\n if (!depth) throw new RangeError(\"There is no position before the top-level node\");\n return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1];\n }\n }, {\n key: \"after\",\n value: function after(depth) {\n depth = this.resolveDepth(depth);\n if (!depth) throw new RangeError(\"There is no position after the top-level node\");\n return depth == this.depth + 1 ? this.pos : this.path[depth * 3 - 1] + this.path[depth * 3].nodeSize;\n }\n }, {\n key: \"textOffset\",\n get: function get() {\n return this.pos - this.path[this.path.length - 1];\n }\n }, {\n key: \"nodeAfter\",\n get: function get() {\n var parent = this.parent,\n index = this.index(this.depth);\n if (index == parent.childCount) return null;\n var dOff = this.pos - this.path[this.path.length - 1],\n child = parent.child(index);\n return dOff ? parent.child(index).cut(dOff) : child;\n }\n }, {\n key: \"nodeBefore\",\n get: function get() {\n var index = this.index(this.depth);\n var dOff = this.pos - this.path[this.path.length - 1];\n if (dOff) return this.parent.child(index).cut(0, dOff);\n return index == 0 ? null : this.parent.child(index - 1);\n }\n }, {\n key: \"posAtIndex\",\n value: function posAtIndex(index, depth) {\n depth = this.resolveDepth(depth);\n var node = this.path[depth * 3],\n pos = depth == 0 ? 0 : this.path[depth * 3 - 1] + 1;\n for (var i = 0; i < index; i++) pos += node.child(i).nodeSize;\n return pos;\n }\n }, {\n key: \"marks\",\n value: function marks() {\n var parent = this.parent,\n index = this.index();\n if (parent.content.size == 0) return Mark.none;\n if (this.textOffset) return parent.child(index).marks;\n var main = parent.maybeChild(index - 1),\n other = parent.maybeChild(index);\n if (!main) {\n var tmp = main;\n main = other;\n other = tmp;\n }\n var marks = main.marks;\n for (var i = 0; i < marks.length; i++) if (marks[i].type.spec.inclusive === false && (!other || !marks[i].isInSet(other.marks))) marks = marks[i--].removeFromSet(marks);\n return marks;\n }\n }, {\n key: \"marksAcross\",\n value: function marksAcross($end) {\n var after = this.parent.maybeChild(this.index());\n if (!after || !after.isInline) return null;\n var marks = after.marks,\n next = $end.parent.maybeChild($end.index());\n for (var i = 0; i < marks.length; i++) if (marks[i].type.spec.inclusive === false && (!next || !marks[i].isInSet(next.marks))) marks = marks[i--].removeFromSet(marks);\n return marks;\n }\n }, {\n key: \"sharedDepth\",\n value: function sharedDepth(pos) {\n for (var depth = this.depth; depth > 0; depth--) if (this.start(depth) <= pos && this.end(depth) >= pos) return depth;\n return 0;\n }\n }, {\n key: \"blockRange\",\n value: function blockRange() {\n var other = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this;\n var pred = arguments.length > 1 ? arguments[1] : undefined;\n if (other.pos < this.pos) return other.blockRange(this);\n for (var d = this.depth - (this.parent.inlineContent || this.pos == other.pos ? 1 : 0); d >= 0; d--) if (other.pos <= this.end(d) && (!pred || pred(this.node(d)))) return new NodeRange(this, other, d);\n return null;\n }\n }, {\n key: \"sameParent\",\n value: function sameParent(other) {\n return this.pos - this.parentOffset == other.pos - other.parentOffset;\n }\n }, {\n key: \"max\",\n value: function max(other) {\n return other.pos > this.pos ? other : this;\n }\n }, {\n key: \"min\",\n value: function min(other) {\n return other.pos < this.pos ? other : this;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var str = \"\";\n for (var i = 1; i <= this.depth; i++) str += (str ? \"/\" : \"\") + this.node(i).type.name + \"_\" + this.index(i - 1);\n return str + \":\" + this.parentOffset;\n }\n }], [{\n key: \"resolve\",\n value: function resolve(doc, pos) {\n if (!(pos >= 0 && pos <= doc.content.size)) throw new RangeError(\"Position \" + pos + \" out of range\");\n var path = [];\n var start = 0,\n parentOffset = pos;\n for (var node = doc;;) {\n var _node$content$findInd = node.content.findIndex(parentOffset),\n index = _node$content$findInd.index,\n offset = _node$content$findInd.offset;\n var rem = parentOffset - offset;\n path.push(node, index, start + offset);\n if (!rem) break;\n node = node.child(index);\n if (node.isText) break;\n parentOffset = rem - 1;\n start += offset + 1;\n }\n return new ResolvedPos(pos, path, parentOffset);\n }\n }, {\n key: \"resolveCached\",\n value: function resolveCached(doc, pos) {\n var cache = resolveCache.get(doc);\n if (cache) {\n for (var i = 0; i < cache.elts.length; i++) {\n var elt = cache.elts[i];\n if (elt.pos == pos) return elt;\n }\n } else {\n resolveCache.set(doc, cache = new ResolveCache());\n }\n var result = cache.elts[cache.i] = ResolvedPos.resolve(doc, pos);\n cache.i = (cache.i + 1) % resolveCacheSize;\n return result;\n }\n }]);\n return ResolvedPos;\n}();\nvar ResolveCache = _createClass(function ResolveCache() {\n _classCallCheck(this, ResolveCache);\n this.elts = [];\n this.i = 0;\n});\nvar resolveCacheSize = 12,\n resolveCache = new WeakMap();\nvar NodeRange = function () {\n function NodeRange($from, $to, depth) {\n _classCallCheck(this, NodeRange);\n this.$from = $from;\n this.$to = $to;\n this.depth = depth;\n }\n _createClass(NodeRange, [{\n key: \"start\",\n get: function get() {\n return this.$from.before(this.depth + 1);\n }\n }, {\n key: \"end\",\n get: function get() {\n return this.$to.after(this.depth + 1);\n }\n }, {\n key: \"parent\",\n get: function get() {\n return this.$from.node(this.depth);\n }\n }, {\n key: \"startIndex\",\n get: function get() {\n return this.$from.index(this.depth);\n }\n }, {\n key: \"endIndex\",\n get: function get() {\n return this.$to.indexAfter(this.depth);\n }\n }]);\n return NodeRange;\n}();\nvar emptyAttrs = Object.create(null);\nvar Node = function () {\n function Node(type, attrs, content) {\n var marks = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : Mark.none;\n _classCallCheck(this, Node);\n this.type = type;\n this.attrs = attrs;\n this.marks = marks;\n this.content = content || Fragment.empty;\n }\n _createClass(Node, [{\n key: \"children\",\n get: function get() {\n return this.content.content;\n }\n }, {\n key: \"nodeSize\",\n get: function get() {\n return this.isLeaf ? 1 : 2 + this.content.size;\n }\n }, {\n key: \"childCount\",\n get: function get() {\n return this.content.childCount;\n }\n }, {\n key: \"child\",\n value: function child(index) {\n return this.content.child(index);\n }\n }, {\n key: \"maybeChild\",\n value: function maybeChild(index) {\n return this.content.maybeChild(index);\n }\n }, {\n key: \"forEach\",\n value: function forEach(f) {\n this.content.forEach(f);\n }\n }, {\n key: \"nodesBetween\",\n value: function nodesBetween(from, to, f) {\n var startPos = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n this.content.nodesBetween(from, to, f, startPos, this);\n }\n }, {\n key: \"descendants\",\n value: function descendants(f) {\n this.nodesBetween(0, this.content.size, f);\n }\n }, {\n key: \"textContent\",\n get: function get() {\n return this.isLeaf && this.type.spec.leafText ? this.type.spec.leafText(this) : this.textBetween(0, this.content.size, \"\");\n }\n }, {\n key: \"textBetween\",\n value: function textBetween(from, to, blockSeparator, leafText) {\n return this.content.textBetween(from, to, blockSeparator, leafText);\n }\n }, {\n key: \"firstChild\",\n get: function get() {\n return this.content.firstChild;\n }\n }, {\n key: \"lastChild\",\n get: function get() {\n return this.content.lastChild;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this == other || this.sameMarkup(other) && this.content.eq(other.content);\n }\n }, {\n key: \"sameMarkup\",\n value: function sameMarkup(other) {\n return this.hasMarkup(other.type, other.attrs, other.marks);\n }\n }, {\n key: \"hasMarkup\",\n value: function hasMarkup(type, attrs, marks) {\n return this.type == type && compareDeep(this.attrs, attrs || type.defaultAttrs || emptyAttrs) && Mark.sameSet(this.marks, marks || Mark.none);\n }\n }, {\n key: \"copy\",\n value: function copy() {\n var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n if (content == this.content) return this;\n return new Node(this.type, this.attrs, content, this.marks);\n }\n }, {\n key: \"mark\",\n value: function mark(marks) {\n return marks == this.marks ? this : new Node(this.type, this.attrs, this.content, marks);\n }\n }, {\n key: \"cut\",\n value: function cut(from) {\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.content.size;\n if (from == 0 && to == this.content.size) return this;\n return this.copy(this.content.cut(from, to));\n }\n }, {\n key: \"slice\",\n value: function slice(from) {\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.content.size;\n var includeParents = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n if (from == to) return Slice.empty;\n var $from = this.resolve(from),\n $to = this.resolve(to);\n var depth = includeParents ? 0 : $from.sharedDepth(to);\n var start = $from.start(depth),\n node = $from.node(depth);\n var content = node.content.cut($from.pos - start, $to.pos - start);\n return new Slice(content, $from.depth - depth, $to.depth - depth);\n }\n }, {\n key: \"replace\",\n value: function replace(from, to, slice) {\n return _replace(this.resolve(from), this.resolve(to), slice);\n }\n }, {\n key: \"nodeAt\",\n value: function nodeAt(pos) {\n for (var node = this;;) {\n var _node$content$findInd2 = node.content.findIndex(pos),\n index = _node$content$findInd2.index,\n offset = _node$content$findInd2.offset;\n node = node.maybeChild(index);\n if (!node) return null;\n if (offset == pos || node.isText) return node;\n pos -= offset + 1;\n }\n }\n }, {\n key: \"childAfter\",\n value: function childAfter(pos) {\n var _this$content$findInd = this.content.findIndex(pos),\n index = _this$content$findInd.index,\n offset = _this$content$findInd.offset;\n return {\n node: this.content.maybeChild(index),\n index: index,\n offset: offset\n };\n }\n }, {\n key: \"childBefore\",\n value: function childBefore(pos) {\n if (pos == 0) return {\n node: null,\n index: 0,\n offset: 0\n };\n var _this$content$findInd2 = this.content.findIndex(pos),\n index = _this$content$findInd2.index,\n offset = _this$content$findInd2.offset;\n if (offset < pos) return {\n node: this.content.child(index),\n index: index,\n offset: offset\n };\n var node = this.content.child(index - 1);\n return {\n node: node,\n index: index - 1,\n offset: offset - node.nodeSize\n };\n }\n }, {\n key: \"resolve\",\n value: function resolve(pos) {\n return ResolvedPos.resolveCached(this, pos);\n }\n }, {\n key: \"resolveNoCache\",\n value: function resolveNoCache(pos) {\n return ResolvedPos.resolve(this, pos);\n }\n }, {\n key: \"rangeHasMark\",\n value: function rangeHasMark(from, to, type) {\n var found = false;\n if (to > from) this.nodesBetween(from, to, function (node) {\n if (type.isInSet(node.marks)) found = true;\n return !found;\n });\n return found;\n }\n }, {\n key: \"isBlock\",\n get: function get() {\n return this.type.isBlock;\n }\n }, {\n key: \"isTextblock\",\n get: function get() {\n return this.type.isTextblock;\n }\n }, {\n key: \"inlineContent\",\n get: function get() {\n return this.type.inlineContent;\n }\n }, {\n key: \"isInline\",\n get: function get() {\n return this.type.isInline;\n }\n }, {\n key: \"isText\",\n get: function get() {\n return this.type.isText;\n }\n }, {\n key: \"isLeaf\",\n get: function get() {\n return this.type.isLeaf;\n }\n }, {\n key: \"isAtom\",\n get: function get() {\n return this.type.isAtom;\n }\n }, {\n key: \"toString\",\n value: function toString() {\n if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);\n var name = this.type.name;\n if (this.content.size) name += \"(\" + this.content.toStringInner() + \")\";\n return wrapMarks(this.marks, name);\n }\n }, {\n key: \"contentMatchAt\",\n value: function contentMatchAt(index) {\n var match = this.type.contentMatch.matchFragment(this.content, 0, index);\n if (!match) throw new Error(\"Called contentMatchAt on a node with invalid content\");\n return match;\n }\n }, {\n key: \"canReplace\",\n value: function canReplace(from, to) {\n var replacement = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Fragment.empty;\n var start = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;\n var end = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : replacement.childCount;\n var one = this.contentMatchAt(from).matchFragment(replacement, start, end);\n var two = one && one.matchFragment(this.content, to);\n if (!two || !two.validEnd) return false;\n for (var i = start; i < end; i++) if (!this.type.allowsMarks(replacement.child(i).marks)) return false;\n return true;\n }\n }, {\n key: \"canReplaceWith\",\n value: function canReplaceWith(from, to, type, marks) {\n if (marks && !this.type.allowsMarks(marks)) return false;\n var start = this.contentMatchAt(from).matchType(type);\n var end = start && start.matchFragment(this.content, to);\n return end ? end.validEnd : false;\n }\n }, {\n key: \"canAppend\",\n value: function canAppend(other) {\n if (other.content.size) return this.canReplace(this.childCount, this.childCount, other.content);else return this.type.compatibleContent(other.type);\n }\n }, {\n key: \"check\",\n value: function check() {\n this.type.checkContent(this.content);\n this.type.checkAttrs(this.attrs);\n var copy = Mark.none;\n for (var i = 0; i < this.marks.length; i++) {\n var mark = this.marks[i];\n mark.type.checkAttrs(mark.attrs);\n copy = mark.addToSet(copy);\n }\n if (!Mark.sameSet(copy, this.marks)) throw new RangeError(\"Invalid collection of marks for node \".concat(this.type.name, \": \").concat(this.marks.map(function (m) {\n return m.type.name;\n })));\n this.content.forEach(function (node) {\n return node.check();\n });\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var obj = {\n type: this.type.name\n };\n for (var _ in this.attrs) {\n obj.attrs = this.attrs;\n break;\n }\n if (this.content.size) obj.content = this.content.toJSON();\n if (this.marks.length) obj.marks = this.marks.map(function (n) {\n return n.toJSON();\n });\n return obj;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (!json) throw new RangeError(\"Invalid input for Node.fromJSON\");\n var marks = undefined;\n if (json.marks) {\n if (!Array.isArray(json.marks)) throw new RangeError(\"Invalid mark data for Node.fromJSON\");\n marks = json.marks.map(schema.markFromJSON);\n }\n if (json.type == \"text\") {\n if (typeof json.text != \"string\") throw new RangeError(\"Invalid text node in JSON\");\n return schema.text(json.text, marks);\n }\n var content = Fragment.fromJSON(schema, json.content);\n var node = schema.nodeType(json.type).create(json.attrs, content, marks);\n node.type.checkAttrs(node.attrs);\n return node;\n }\n }]);\n return Node;\n}();\nNode.prototype.text = undefined;\nvar TextNode = function (_Node) {\n _inherits(TextNode, _Node);\n var _super2 = _createSuper(TextNode);\n function TextNode(type, attrs, content, marks) {\n var _this;\n _classCallCheck(this, TextNode);\n _this = _super2.call(this, type, attrs, null, marks);\n if (!content) throw new RangeError(\"Empty text nodes are not allowed\");\n _this.text = content;\n return _this;\n }\n _createClass(TextNode, [{\n key: \"toString\",\n value: function toString() {\n if (this.type.spec.toDebugString) return this.type.spec.toDebugString(this);\n return wrapMarks(this.marks, JSON.stringify(this.text));\n }\n }, {\n key: \"textContent\",\n get: function get() {\n return this.text;\n }\n }, {\n key: \"textBetween\",\n value: function textBetween(from, to) {\n return this.text.slice(from, to);\n }\n }, {\n key: \"nodeSize\",\n get: function get() {\n return this.text.length;\n }\n }, {\n key: \"mark\",\n value: function mark(marks) {\n return marks == this.marks ? this : new TextNode(this.type, this.attrs, this.text, marks);\n }\n }, {\n key: \"withText\",\n value: function withText(text) {\n if (text == this.text) return this;\n return new TextNode(this.type, this.attrs, text, this.marks);\n }\n }, {\n key: \"cut\",\n value: function cut() {\n var from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.text.length;\n if (from == 0 && to == this.text.length) return this;\n return this.withText(this.text.slice(from, to));\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this.sameMarkup(other) && this.text == other.text;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var base = _get(_getPrototypeOf(TextNode.prototype), \"toJSON\", this).call(this);\n base.text = this.text;\n return base;\n }\n }]);\n return TextNode;\n}(Node);\nfunction wrapMarks(marks, str) {\n for (var i = marks.length - 1; i >= 0; i--) str = marks[i].type.name + \"(\" + str + \")\";\n return str;\n}\nvar ContentMatch = function () {\n function ContentMatch(validEnd) {\n _classCallCheck(this, ContentMatch);\n this.validEnd = validEnd;\n this.next = [];\n this.wrapCache = [];\n }\n _createClass(ContentMatch, [{\n key: \"matchType\",\n value: function matchType(type) {\n for (var i = 0; i < this.next.length; i++) if (this.next[i].type == type) return this.next[i].next;\n return null;\n }\n }, {\n key: \"matchFragment\",\n value: function matchFragment(frag) {\n var start = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n var end = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : frag.childCount;\n var cur = this;\n for (var i = start; cur && i < end; i++) cur = cur.matchType(frag.child(i).type);\n return cur;\n }\n }, {\n key: \"inlineContent\",\n get: function get() {\n return this.next.length != 0 && this.next[0].type.isInline;\n }\n }, {\n key: \"defaultType\",\n get: function get() {\n for (var i = 0; i < this.next.length; i++) {\n var type = this.next[i].type;\n if (!(type.isText || type.hasRequiredAttrs())) return type;\n }\n return null;\n }\n }, {\n key: \"compatible\",\n value: function compatible(other) {\n for (var i = 0; i < this.next.length; i++) for (var j = 0; j < other.next.length; j++) if (this.next[i].type == other.next[j].type) return true;\n return false;\n }\n }, {\n key: \"fillBefore\",\n value: function fillBefore(after) {\n var toEnd = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var startIndex = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n var seen = [this];\n function search(match, types) {\n var finished = match.matchFragment(after, startIndex);\n if (finished && (!toEnd || finished.validEnd)) return Fragment.from(types.map(function (tp) {\n return tp.createAndFill();\n }));\n for (var i = 0; i < match.next.length; i++) {\n var _match$next$i = match.next[i],\n type = _match$next$i.type,\n next = _match$next$i.next;\n if (!(type.isText || type.hasRequiredAttrs()) && seen.indexOf(next) == -1) {\n seen.push(next);\n var _found = search(next, types.concat(type));\n if (_found) return _found;\n }\n }\n return null;\n }\n return search(this, []);\n }\n }, {\n key: \"findWrapping\",\n value: function findWrapping(target) {\n for (var i = 0; i < this.wrapCache.length; i += 2) if (this.wrapCache[i] == target) return this.wrapCache[i + 1];\n var computed = this.computeWrapping(target);\n this.wrapCache.push(target, computed);\n return computed;\n }\n }, {\n key: \"computeWrapping\",\n value: function computeWrapping(target) {\n var seen = Object.create(null),\n active = [{\n match: this,\n type: null,\n via: null\n }];\n while (active.length) {\n var current = active.shift(),\n match = current.match;\n if (match.matchType(target)) {\n var result = [];\n for (var obj = current; obj.type; obj = obj.via) result.push(obj.type);\n return result.reverse();\n }\n for (var i = 0; i < match.next.length; i++) {\n var _match$next$i2 = match.next[i],\n type = _match$next$i2.type,\n next = _match$next$i2.next;\n if (!type.isLeaf && !type.hasRequiredAttrs() && !(type.name in seen) && (!current.type || next.validEnd)) {\n active.push({\n match: type.contentMatch,\n type: type,\n via: current\n });\n seen[type.name] = true;\n }\n }\n }\n return null;\n }\n }, {\n key: \"edgeCount\",\n get: function get() {\n return this.next.length;\n }\n }, {\n key: \"edge\",\n value: function edge(n) {\n if (n >= this.next.length) throw new RangeError(\"There's no \".concat(n, \"th edge in this content match\"));\n return this.next[n];\n }\n }, {\n key: \"toString\",\n value: function toString() {\n var seen = [];\n function scan(m) {\n seen.push(m);\n for (var i = 0; i < m.next.length; i++) if (seen.indexOf(m.next[i].next) == -1) scan(m.next[i].next);\n }\n scan(this);\n return seen.map(function (m, i) {\n var out = i + (m.validEnd ? \"*\" : \" \") + \" \";\n for (var _i = 0; _i < m.next.length; _i++) out += (_i ? \", \" : \"\") + m.next[_i].type.name + \"->\" + seen.indexOf(m.next[_i].next);\n return out;\n }).join(\"\\n\");\n }\n }], [{\n key: \"parse\",\n value: function parse(string, nodeTypes) {\n var stream = new TokenStream(string, nodeTypes);\n if (stream.next == null) return ContentMatch.empty;\n var expr = parseExpr(stream);\n if (stream.next) stream.err(\"Unexpected trailing text\");\n var match = dfa(nfa(expr));\n checkForDeadEnds(match, stream);\n return match;\n }\n }]);\n return ContentMatch;\n}();\nContentMatch.empty = new ContentMatch(true);\nvar TokenStream = function () {\n function TokenStream(string, nodeTypes) {\n _classCallCheck(this, TokenStream);\n this.string = string;\n this.nodeTypes = nodeTypes;\n this.inline = null;\n this.pos = 0;\n this.tokens = string.split(/\\s*(?=\\b|\\W|$)/);\n if (this.tokens[this.tokens.length - 1] == \"\") this.tokens.pop();\n if (this.tokens[0] == \"\") this.tokens.shift();\n }\n _createClass(TokenStream, [{\n key: \"next\",\n get: function get() {\n return this.tokens[this.pos];\n }\n }, {\n key: \"eat\",\n value: function eat(tok) {\n return this.next == tok && (this.pos++ || true);\n }\n }, {\n key: \"err\",\n value: function err(str) {\n throw new SyntaxError(str + \" (in content expression '\" + this.string + \"')\");\n }\n }]);\n return TokenStream;\n}();\nfunction parseExpr(stream) {\n var exprs = [];\n do {\n exprs.push(parseExprSeq(stream));\n } while (stream.eat(\"|\"));\n return exprs.length == 1 ? exprs[0] : {\n type: \"choice\",\n exprs: exprs\n };\n}\nfunction parseExprSeq(stream) {\n var exprs = [];\n do {\n exprs.push(parseExprSubscript(stream));\n } while (stream.next && stream.next != \")\" && stream.next != \"|\");\n return exprs.length == 1 ? exprs[0] : {\n type: \"seq\",\n exprs: exprs\n };\n}\nfunction parseExprSubscript(stream) {\n var expr = parseExprAtom(stream);\n for (;;) {\n if (stream.eat(\"+\")) expr = {\n type: \"plus\",\n expr: expr\n };else if (stream.eat(\"*\")) expr = {\n type: \"star\",\n expr: expr\n };else if (stream.eat(\"?\")) expr = {\n type: \"opt\",\n expr: expr\n };else if (stream.eat(\"{\")) expr = parseExprRange(stream, expr);else break;\n }\n return expr;\n}\nfunction parseNum(stream) {\n if (/\\D/.test(stream.next)) stream.err(\"Expected number, got '\" + stream.next + \"'\");\n var result = Number(stream.next);\n stream.pos++;\n return result;\n}\nfunction parseExprRange(stream, expr) {\n var min = parseNum(stream),\n max = min;\n if (stream.eat(\",\")) {\n if (stream.next != \"}\") max = parseNum(stream);else max = -1;\n }\n if (!stream.eat(\"}\")) stream.err(\"Unclosed braced range\");\n return {\n type: \"range\",\n min: min,\n max: max,\n expr: expr\n };\n}\nfunction resolveName(stream, name) {\n var types = stream.nodeTypes,\n type = types[name];\n if (type) return [type];\n var result = [];\n for (var typeName in types) {\n var _type = types[typeName];\n if (_type.isInGroup(name)) result.push(_type);\n }\n if (result.length == 0) stream.err(\"No node type or group '\" + name + \"' found\");\n return result;\n}\nfunction parseExprAtom(stream) {\n if (stream.eat(\"(\")) {\n var expr = parseExpr(stream);\n if (!stream.eat(\")\")) stream.err(\"Missing closing paren\");\n return expr;\n } else if (!/\\W/.test(stream.next)) {\n var exprs = resolveName(stream, stream.next).map(function (type) {\n if (stream.inline == null) stream.inline = type.isInline;else if (stream.inline != type.isInline) stream.err(\"Mixing inline and block content\");\n return {\n type: \"name\",\n value: type\n };\n });\n stream.pos++;\n return exprs.length == 1 ? exprs[0] : {\n type: \"choice\",\n exprs: exprs\n };\n } else {\n stream.err(\"Unexpected token '\" + stream.next + \"'\");\n }\n}\nfunction nfa(expr) {\n var nfa = [[]];\n connect(compile(expr, 0), node());\n return nfa;\n function node() {\n return nfa.push([]) - 1;\n }\n function edge(from, to, term) {\n var edge = {\n term: term,\n to: to\n };\n nfa[from].push(edge);\n return edge;\n }\n function connect(edges, to) {\n edges.forEach(function (edge) {\n return edge.to = to;\n });\n }\n function compile(expr, from) {\n if (expr.type == \"choice\") {\n return expr.exprs.reduce(function (out, expr) {\n return out.concat(compile(expr, from));\n }, []);\n } else if (expr.type == \"seq\") {\n for (var i = 0;; i++) {\n var next = compile(expr.exprs[i], from);\n if (i == expr.exprs.length - 1) return next;\n connect(next, from = node());\n }\n } else if (expr.type == \"star\") {\n var loop = node();\n edge(from, loop);\n connect(compile(expr.expr, loop), loop);\n return [edge(loop)];\n } else if (expr.type == \"plus\") {\n var _loop = node();\n connect(compile(expr.expr, from), _loop);\n connect(compile(expr.expr, _loop), _loop);\n return [edge(_loop)];\n } else if (expr.type == \"opt\") {\n return [edge(from)].concat(compile(expr.expr, from));\n } else if (expr.type == \"range\") {\n var cur = from;\n for (var _i2 = 0; _i2 < expr.min; _i2++) {\n var _next = node();\n connect(compile(expr.expr, cur), _next);\n cur = _next;\n }\n if (expr.max == -1) {\n connect(compile(expr.expr, cur), cur);\n } else {\n for (var _i3 = expr.min; _i3 < expr.max; _i3++) {\n var _next2 = node();\n edge(cur, _next2);\n connect(compile(expr.expr, cur), _next2);\n cur = _next2;\n }\n }\n return [edge(cur)];\n } else if (expr.type == \"name\") {\n return [edge(from, undefined, expr.value)];\n } else {\n throw new Error(\"Unknown expr type\");\n }\n }\n}\nfunction cmp(a, b) {\n return b - a;\n}\nfunction nullFrom(nfa, node) {\n var result = [];\n scan(node);\n return result.sort(cmp);\n function scan(node) {\n var edges = nfa[node];\n if (edges.length == 1 && !edges[0].term) return scan(edges[0].to);\n result.push(node);\n for (var i = 0; i < edges.length; i++) {\n var _edges$i = edges[i],\n term = _edges$i.term,\n to = _edges$i.to;\n if (!term && result.indexOf(to) == -1) scan(to);\n }\n }\n}\nfunction dfa(nfa) {\n var labeled = Object.create(null);\n return explore(nullFrom(nfa, 0));\n function explore(states) {\n var out = [];\n states.forEach(function (node) {\n nfa[node].forEach(function (_ref) {\n var term = _ref.term,\n to = _ref.to;\n if (!term) return;\n var set;\n for (var i = 0; i < out.length; i++) if (out[i][0] == term) set = out[i][1];\n nullFrom(nfa, to).forEach(function (node) {\n if (!set) out.push([term, set = []]);\n if (set.indexOf(node) == -1) set.push(node);\n });\n });\n });\n var state = labeled[states.join(\",\")] = new ContentMatch(states.indexOf(nfa.length - 1) > -1);\n for (var i = 0; i < out.length; i++) {\n var _states = out[i][1].sort(cmp);\n state.next.push({\n type: out[i][0],\n next: labeled[_states.join(\",\")] || explore(_states)\n });\n }\n return state;\n }\n}\nfunction checkForDeadEnds(match, stream) {\n for (var i = 0, work = [match]; i < work.length; i++) {\n var state = work[i],\n dead = !state.validEnd,\n nodes = [];\n for (var j = 0; j < state.next.length; j++) {\n var _state$next$j = state.next[j],\n type = _state$next$j.type,\n next = _state$next$j.next;\n nodes.push(type.name);\n if (dead && !(type.isText || type.hasRequiredAttrs())) dead = false;\n if (work.indexOf(next) == -1) work.push(next);\n }\n if (dead) stream.err(\"Only non-generatable nodes (\" + nodes.join(\", \") + \") in a required position (see https://prosemirror.net/docs/guide/#generatable)\");\n }\n}\nfunction defaultAttrs(attrs) {\n var defaults = Object.create(null);\n for (var attrName in attrs) {\n var attr = attrs[attrName];\n if (!attr.hasDefault) return null;\n defaults[attrName] = attr[\"default\"];\n }\n return defaults;\n}\nfunction _computeAttrs(attrs, value) {\n var built = Object.create(null);\n for (var name in attrs) {\n var given = value && value[name];\n if (given === undefined) {\n var attr = attrs[name];\n if (attr.hasDefault) given = attr[\"default\"];else throw new RangeError(\"No value supplied for attribute \" + name);\n }\n built[name] = given;\n }\n return built;\n}\nfunction _checkAttrs(attrs, values, type, name) {\n for (var attr in values) if (!(attr in attrs)) throw new RangeError(\"Unsupported attribute \".concat(attr, \" for \").concat(type, \" of type \").concat(name));\n for (var _attr in attrs) {\n if (attrs[_attr].validate) attrs[_attr].validate(values[_attr]);\n }\n}\nfunction initAttrs(typeName, attrs) {\n var result = Object.create(null);\n if (attrs) for (var name in attrs) result[name] = new Attribute(typeName, name, attrs[name]);\n return result;\n}\nvar NodeType = function () {\n function NodeType(name, schema, spec) {\n _classCallCheck(this, NodeType);\n this.name = name;\n this.schema = schema;\n this.spec = spec;\n this.markSet = null;\n this.groups = spec.group ? spec.group.split(\" \") : [];\n this.attrs = initAttrs(name, spec.attrs);\n this.defaultAttrs = defaultAttrs(this.attrs);\n this.contentMatch = null;\n this.inlineContent = null;\n this.isBlock = !(spec.inline || name == \"text\");\n this.isText = name == \"text\";\n }\n _createClass(NodeType, [{\n key: \"isInline\",\n get: function get() {\n return !this.isBlock;\n }\n }, {\n key: \"isTextblock\",\n get: function get() {\n return this.isBlock && this.inlineContent;\n }\n }, {\n key: \"isLeaf\",\n get: function get() {\n return this.contentMatch == ContentMatch.empty;\n }\n }, {\n key: \"isAtom\",\n get: function get() {\n return this.isLeaf || !!this.spec.atom;\n }\n }, {\n key: \"isInGroup\",\n value: function isInGroup(group) {\n return this.groups.indexOf(group) > -1;\n }\n }, {\n key: \"whitespace\",\n get: function get() {\n return this.spec.whitespace || (this.spec.code ? \"pre\" : \"normal\");\n }\n }, {\n key: \"hasRequiredAttrs\",\n value: function hasRequiredAttrs() {\n for (var n in this.attrs) if (this.attrs[n].isRequired) return true;\n return false;\n }\n }, {\n key: \"compatibleContent\",\n value: function compatibleContent(other) {\n return this == other || this.contentMatch.compatible(other.contentMatch);\n }\n }, {\n key: \"computeAttrs\",\n value: function computeAttrs(attrs) {\n if (!attrs && this.defaultAttrs) return this.defaultAttrs;else return _computeAttrs(this.attrs, attrs);\n }\n }, {\n key: \"create\",\n value: function create() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var content = arguments.length > 1 ? arguments[1] : undefined;\n var marks = arguments.length > 2 ? arguments[2] : undefined;\n if (this.isText) throw new Error(\"NodeType.create can't construct text nodes\");\n return new Node(this, this.computeAttrs(attrs), Fragment.from(content), Mark.setFrom(marks));\n }\n }, {\n key: \"createChecked\",\n value: function createChecked() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var content = arguments.length > 1 ? arguments[1] : undefined;\n var marks = arguments.length > 2 ? arguments[2] : undefined;\n content = Fragment.from(content);\n this.checkContent(content);\n return new Node(this, this.computeAttrs(attrs), content, Mark.setFrom(marks));\n }\n }, {\n key: \"createAndFill\",\n value: function createAndFill() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n var content = arguments.length > 1 ? arguments[1] : undefined;\n var marks = arguments.length > 2 ? arguments[2] : undefined;\n attrs = this.computeAttrs(attrs);\n content = Fragment.from(content);\n if (content.size) {\n var before = this.contentMatch.fillBefore(content);\n if (!before) return null;\n content = before.append(content);\n }\n var matched = this.contentMatch.matchFragment(content);\n var after = matched && matched.fillBefore(Fragment.empty, true);\n if (!after) return null;\n return new Node(this, attrs, content.append(after), Mark.setFrom(marks));\n }\n }, {\n key: \"validContent\",\n value: function validContent(content) {\n var result = this.contentMatch.matchFragment(content);\n if (!result || !result.validEnd) return false;\n for (var i = 0; i < content.childCount; i++) if (!this.allowsMarks(content.child(i).marks)) return false;\n return true;\n }\n }, {\n key: \"checkContent\",\n value: function checkContent(content) {\n if (!this.validContent(content)) throw new RangeError(\"Invalid content for node \".concat(this.name, \": \").concat(content.toString().slice(0, 50)));\n }\n }, {\n key: \"checkAttrs\",\n value: function checkAttrs(attrs) {\n _checkAttrs(this.attrs, attrs, \"node\", this.name);\n }\n }, {\n key: \"allowsMarkType\",\n value: function allowsMarkType(markType) {\n return this.markSet == null || this.markSet.indexOf(markType) > -1;\n }\n }, {\n key: \"allowsMarks\",\n value: function allowsMarks(marks) {\n if (this.markSet == null) return true;\n for (var i = 0; i < marks.length; i++) if (!this.allowsMarkType(marks[i].type)) return false;\n return true;\n }\n }, {\n key: \"allowedMarks\",\n value: function allowedMarks(marks) {\n if (this.markSet == null) return marks;\n var copy;\n for (var i = 0; i < marks.length; i++) {\n if (!this.allowsMarkType(marks[i].type)) {\n if (!copy) copy = marks.slice(0, i);\n } else if (copy) {\n copy.push(marks[i]);\n }\n }\n return !copy ? marks : copy.length ? copy : Mark.none;\n }\n }], [{\n key: \"compile\",\n value: function compile(nodes, schema) {\n var result = Object.create(null);\n nodes.forEach(function (name, spec) {\n return result[name] = new NodeType(name, schema, spec);\n });\n var topType = schema.spec.topNode || \"doc\";\n if (!result[topType]) throw new RangeError(\"Schema is missing its top node type ('\" + topType + \"')\");\n if (!result.text) throw new RangeError(\"Every schema needs a 'text' type\");\n for (var _ in result.text.attrs) throw new RangeError(\"The text node type should not have attributes\");\n return result;\n }\n }]);\n return NodeType;\n}();\nfunction validateType(typeName, attrName, type) {\n var types = type.split(\"|\");\n return function (value) {\n var name = value === null ? \"null\" : _typeof(value);\n if (types.indexOf(name) < 0) throw new RangeError(\"Expected value of type \".concat(types, \" for attribute \").concat(attrName, \" on type \").concat(typeName, \", got \").concat(name));\n };\n}\nvar Attribute = function () {\n function Attribute(typeName, attrName, options) {\n _classCallCheck(this, Attribute);\n this.hasDefault = Object.prototype.hasOwnProperty.call(options, \"default\");\n this[\"default\"] = options[\"default\"];\n this.validate = typeof options.validate == \"string\" ? validateType(typeName, attrName, options.validate) : options.validate;\n }\n _createClass(Attribute, [{\n key: \"isRequired\",\n get: function get() {\n return !this.hasDefault;\n }\n }]);\n return Attribute;\n}();\nvar MarkType = function () {\n function MarkType(name, rank, schema, spec) {\n _classCallCheck(this, MarkType);\n this.name = name;\n this.rank = rank;\n this.schema = schema;\n this.spec = spec;\n this.attrs = initAttrs(name, spec.attrs);\n this.excluded = null;\n var defaults = defaultAttrs(this.attrs);\n this.instance = defaults ? new Mark(this, defaults) : null;\n }\n _createClass(MarkType, [{\n key: \"create\",\n value: function create() {\n var attrs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;\n if (!attrs && this.instance) return this.instance;\n return new Mark(this, _computeAttrs(this.attrs, attrs));\n }\n }, {\n key: \"removeFromSet\",\n value: function removeFromSet(set) {\n for (var i = 0; i < set.length; i++) if (set[i].type == this) {\n set = set.slice(0, i).concat(set.slice(i + 1));\n i--;\n }\n return set;\n }\n }, {\n key: \"isInSet\",\n value: function isInSet(set) {\n for (var i = 0; i < set.length; i++) if (set[i].type == this) return set[i];\n }\n }, {\n key: \"checkAttrs\",\n value: function checkAttrs(attrs) {\n _checkAttrs(this.attrs, attrs, \"mark\", this.name);\n }\n }, {\n key: \"excludes\",\n value: function excludes(other) {\n return this.excluded.indexOf(other) > -1;\n }\n }], [{\n key: \"compile\",\n value: function compile(marks, schema) {\n var result = Object.create(null),\n rank = 0;\n marks.forEach(function (name, spec) {\n return result[name] = new MarkType(name, rank++, schema, spec);\n });\n return result;\n }\n }]);\n return MarkType;\n}();\nvar Schema = function () {\n function Schema(spec) {\n var _this2 = this;\n _classCallCheck(this, Schema);\n this.linebreakReplacement = null;\n this.cached = Object.create(null);\n var instanceSpec = this.spec = {};\n for (var prop in spec) instanceSpec[prop] = spec[prop];\n instanceSpec.nodes = OrderedMap.from(spec.nodes), instanceSpec.marks = OrderedMap.from(spec.marks || {}), this.nodes = NodeType.compile(this.spec.nodes, this);\n this.marks = MarkType.compile(this.spec.marks, this);\n var contentExprCache = Object.create(null);\n for (var _prop in this.nodes) {\n if (_prop in this.marks) throw new RangeError(_prop + \" can not be both a node and a mark\");\n var type = this.nodes[_prop],\n contentExpr = type.spec.content || \"\",\n markExpr = type.spec.marks;\n type.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));\n type.inlineContent = type.contentMatch.inlineContent;\n if (type.spec.linebreakReplacement) {\n if (this.linebreakReplacement) throw new RangeError(\"Multiple linebreak nodes defined\");\n if (!type.isInline || !type.isLeaf) throw new RangeError(\"Linebreak replacement nodes must be inline leaf nodes\");\n this.linebreakReplacement = type;\n }\n type.markSet = markExpr == \"_\" ? null : markExpr ? gatherMarks(this, markExpr.split(\" \")) : markExpr == \"\" || !type.inlineContent ? [] : null;\n }\n for (var _prop2 in this.marks) {\n var _type2 = this.marks[_prop2],\n excl = _type2.spec.excludes;\n _type2.excluded = excl == null ? [_type2] : excl == \"\" ? [] : gatherMarks(this, excl.split(\" \"));\n }\n this.nodeFromJSON = function (json) {\n return Node.fromJSON(_this2, json);\n };\n this.markFromJSON = function (json) {\n return Mark.fromJSON(_this2, json);\n };\n this.topNodeType = this.nodes[this.spec.topNode || \"doc\"];\n this.cached.wrappings = Object.create(null);\n }\n _createClass(Schema, [{\n key: \"node\",\n value: function node(type) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var content = arguments.length > 2 ? arguments[2] : undefined;\n var marks = arguments.length > 3 ? arguments[3] : undefined;\n if (typeof type == \"string\") type = this.nodeType(type);else if (!(type instanceof NodeType)) throw new RangeError(\"Invalid node type: \" + type);else if (type.schema != this) throw new RangeError(\"Node type from different schema used (\" + type.name + \")\");\n return type.createChecked(attrs, content, marks);\n }\n }, {\n key: \"text\",\n value: function text(_text, marks) {\n var type = this.nodes.text;\n return new TextNode(type, type.defaultAttrs, _text, Mark.setFrom(marks));\n }\n }, {\n key: \"mark\",\n value: function mark(type, attrs) {\n if (typeof type == \"string\") type = this.marks[type];\n return type.create(attrs);\n }\n }, {\n key: \"nodeType\",\n value: function nodeType(name) {\n var found = this.nodes[name];\n if (!found) throw new RangeError(\"Unknown node type: \" + name);\n return found;\n }\n }]);\n return Schema;\n}();\nfunction gatherMarks(schema, marks) {\n var found = [];\n for (var i = 0; i < marks.length; i++) {\n var name = marks[i],\n mark = schema.marks[name],\n ok = mark;\n if (mark) {\n found.push(mark);\n } else {\n for (var prop in schema.marks) {\n var _mark = schema.marks[prop];\n if (name == \"_\" || _mark.spec.group && _mark.spec.group.split(\" \").indexOf(name) > -1) found.push(ok = _mark);\n }\n }\n if (!ok) throw new SyntaxError(\"Unknown mark type: '\" + marks[i] + \"'\");\n }\n return found;\n}\nfunction isTagRule(rule) {\n return rule.tag != null;\n}\nfunction isStyleRule(rule) {\n return rule.style != null;\n}\nvar DOMParser = function () {\n function DOMParser(schema, rules) {\n var _this3 = this;\n _classCallCheck(this, DOMParser);\n this.schema = schema;\n this.rules = rules;\n this.tags = [];\n this.styles = [];\n var matchedStyles = this.matchedStyles = [];\n rules.forEach(function (rule) {\n if (isTagRule(rule)) {\n _this3.tags.push(rule);\n } else if (isStyleRule(rule)) {\n var prop = /[^=]*/.exec(rule.style)[0];\n if (matchedStyles.indexOf(prop) < 0) matchedStyles.push(prop);\n _this3.styles.push(rule);\n }\n });\n this.normalizeLists = !this.tags.some(function (r) {\n if (!/^(ul|ol)\\b/.test(r.tag) || !r.node) return false;\n var node = schema.nodes[r.node];\n return node.contentMatch.matchType(node);\n });\n }\n _createClass(DOMParser, [{\n key: \"parse\",\n value: function parse(dom) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var context = new ParseContext(this, options, false);\n context.addAll(dom, Mark.none, options.from, options.to);\n return context.finish();\n }\n }, {\n key: \"parseSlice\",\n value: function parseSlice(dom) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var context = new ParseContext(this, options, true);\n context.addAll(dom, Mark.none, options.from, options.to);\n return Slice.maxOpen(context.finish());\n }\n }, {\n key: \"matchTag\",\n value: function matchTag(dom, context, after) {\n for (var i = after ? this.tags.indexOf(after) + 1 : 0; i < this.tags.length; i++) {\n var rule = this.tags[i];\n if (matches(dom, rule.tag) && (rule.namespace === undefined || dom.namespaceURI == rule.namespace) && (!rule.context || context.matchesContext(rule.context))) {\n if (rule.getAttrs) {\n var result = rule.getAttrs(dom);\n if (result === false) continue;\n rule.attrs = result || undefined;\n }\n return rule;\n }\n }\n }\n }, {\n key: \"matchStyle\",\n value: function matchStyle(prop, value, context, after) {\n for (var i = after ? this.styles.indexOf(after) + 1 : 0; i < this.styles.length; i++) {\n var rule = this.styles[i],\n style = rule.style;\n if (style.indexOf(prop) != 0 || rule.context && !context.matchesContext(rule.context) || style.length > prop.length && (style.charCodeAt(prop.length) != 61 || style.slice(prop.length + 1) != value)) continue;\n if (rule.getAttrs) {\n var result = rule.getAttrs(value);\n if (result === false) continue;\n rule.attrs = result || undefined;\n }\n return rule;\n }\n }\n }], [{\n key: \"schemaRules\",\n value: function schemaRules(schema) {\n var result = [];\n function insert(rule) {\n var priority = rule.priority == null ? 50 : rule.priority,\n i = 0;\n for (; i < result.length; i++) {\n var next = result[i],\n nextPriority = next.priority == null ? 50 : next.priority;\n if (nextPriority < priority) break;\n }\n result.splice(i, 0, rule);\n }\n var _loop2 = function _loop2(name) {\n var rules = schema.marks[name].spec.parseDOM;\n if (rules) rules.forEach(function (rule) {\n insert(rule = copy(rule));\n if (!(rule.mark || rule.ignore || rule.clearMark)) rule.mark = name;\n });\n };\n for (var name in schema.marks) {\n _loop2(name);\n }\n var _loop3 = function _loop3(_name) {\n var rules = schema.nodes[_name].spec.parseDOM;\n if (rules) rules.forEach(function (rule) {\n insert(rule = copy(rule));\n if (!(rule.node || rule.ignore || rule.mark)) rule.node = _name;\n });\n };\n for (var _name in schema.nodes) {\n _loop3(_name);\n }\n return result;\n }\n }, {\n key: \"fromSchema\",\n value: function fromSchema(schema) {\n return schema.cached.domParser || (schema.cached.domParser = new DOMParser(schema, DOMParser.schemaRules(schema)));\n }\n }]);\n return DOMParser;\n}();\nvar blockTags = {\n address: true,\n article: true,\n aside: true,\n blockquote: true,\n body: true,\n canvas: true,\n dd: true,\n div: true,\n dl: true,\n fieldset: true,\n figcaption: true,\n figure: true,\n footer: true,\n form: true,\n h1: true,\n h2: true,\n h3: true,\n h4: true,\n h5: true,\n h6: true,\n header: true,\n hgroup: true,\n hr: true,\n li: true,\n noscript: true,\n ol: true,\n output: true,\n p: true,\n pre: true,\n section: true,\n table: true,\n tfoot: true,\n ul: true\n};\nvar ignoreTags = {\n head: true,\n noscript: true,\n object: true,\n script: true,\n style: true,\n title: true\n};\nvar listTags = {\n ol: true,\n ul: true\n};\nvar OPT_PRESERVE_WS = 1,\n OPT_PRESERVE_WS_FULL = 2,\n OPT_OPEN_LEFT = 4;\nfunction wsOptionsFor(type, preserveWhitespace, base) {\n if (preserveWhitespace != null) return (preserveWhitespace ? OPT_PRESERVE_WS : 0) | (preserveWhitespace === \"full\" ? OPT_PRESERVE_WS_FULL : 0);\n return type && type.whitespace == \"pre\" ? OPT_PRESERVE_WS | OPT_PRESERVE_WS_FULL : base & ~OPT_OPEN_LEFT;\n}\nvar NodeContext = function () {\n function NodeContext(type, attrs, marks, solid, match, options) {\n _classCallCheck(this, NodeContext);\n this.type = type;\n this.attrs = attrs;\n this.marks = marks;\n this.solid = solid;\n this.options = options;\n this.content = [];\n this.activeMarks = Mark.none;\n this.match = match || (options & OPT_OPEN_LEFT ? null : type.contentMatch);\n }\n _createClass(NodeContext, [{\n key: \"findWrapping\",\n value: function findWrapping(node) {\n if (!this.match) {\n if (!this.type) return [];\n var fill = this.type.contentMatch.fillBefore(Fragment.from(node));\n if (fill) {\n this.match = this.type.contentMatch.matchFragment(fill);\n } else {\n var start = this.type.contentMatch,\n wrap;\n if (wrap = start.findWrapping(node.type)) {\n this.match = start;\n return wrap;\n } else {\n return null;\n }\n }\n }\n return this.match.findWrapping(node.type);\n }\n }, {\n key: \"finish\",\n value: function finish(openEnd) {\n if (!(this.options & OPT_PRESERVE_WS)) {\n var last = this.content[this.content.length - 1],\n m;\n if (last && last.isText && (m = /[ \\t\\r\\n\\u000c]+$/.exec(last.text))) {\n var text = last;\n if (last.text.length == m[0].length) this.content.pop();else this.content[this.content.length - 1] = text.withText(text.text.slice(0, text.text.length - m[0].length));\n }\n }\n var content = Fragment.from(this.content);\n if (!openEnd && this.match) content = content.append(this.match.fillBefore(Fragment.empty, true));\n return this.type ? this.type.create(this.attrs, content, this.marks) : content;\n }\n }, {\n key: \"inlineContext\",\n value: function inlineContext(node) {\n if (this.type) return this.type.inlineContent;\n if (this.content.length) return this.content[0].isInline;\n return node.parentNode && !blockTags.hasOwnProperty(node.parentNode.nodeName.toLowerCase());\n }\n }]);\n return NodeContext;\n}();\nvar ParseContext = function () {\n function ParseContext(parser, options, isOpen) {\n _classCallCheck(this, ParseContext);\n this.parser = parser;\n this.options = options;\n this.isOpen = isOpen;\n this.open = 0;\n this.localPreserveWS = false;\n var topNode = options.topNode,\n topContext;\n var topOptions = wsOptionsFor(null, options.preserveWhitespace, 0) | (isOpen ? OPT_OPEN_LEFT : 0);\n if (topNode) topContext = new NodeContext(topNode.type, topNode.attrs, Mark.none, true, options.topMatch || topNode.type.contentMatch, topOptions);else if (isOpen) topContext = new NodeContext(null, null, Mark.none, true, null, topOptions);else topContext = new NodeContext(parser.schema.topNodeType, null, Mark.none, true, null, topOptions);\n this.nodes = [topContext];\n this.find = options.findPositions;\n this.needsBlock = false;\n }\n _createClass(ParseContext, [{\n key: \"top\",\n get: function get() {\n return this.nodes[this.open];\n }\n }, {\n key: \"addDOM\",\n value: function addDOM(dom, marks) {\n if (dom.nodeType == 3) this.addTextNode(dom, marks);else if (dom.nodeType == 1) this.addElement(dom, marks);\n }\n }, {\n key: \"addTextNode\",\n value: function addTextNode(dom, marks) {\n var value = dom.nodeValue;\n var top = this.top,\n preserveWS = top.options & OPT_PRESERVE_WS_FULL ? \"full\" : this.localPreserveWS || (top.options & OPT_PRESERVE_WS) > 0;\n var schema = this.parser.schema;\n if (preserveWS === \"full\" || top.inlineContext(dom) || /[^ \\t\\r\\n\\u000c]/.test(value)) {\n if (!preserveWS) {\n value = value.replace(/[ \\t\\r\\n\\u000c]+/g, \" \");\n if (/^[ \\t\\r\\n\\u000c]/.test(value) && this.open == this.nodes.length - 1) {\n var nodeBefore = top.content[top.content.length - 1];\n var domNodeBefore = dom.previousSibling;\n if (!nodeBefore || domNodeBefore && domNodeBefore.nodeName == 'BR' || nodeBefore.isText && /[ \\t\\r\\n\\u000c]$/.test(nodeBefore.text)) value = value.slice(1);\n }\n } else if (preserveWS === \"full\") {\n value = value.replace(/\\r\\n?/g, \"\\n\");\n } else if (schema.linebreakReplacement && /[\\r\\n]/.test(value) && this.top.findWrapping(schema.linebreakReplacement.create())) {\n var lines = value.split(/\\r?\\n|\\r/);\n for (var i = 0; i < lines.length; i++) {\n if (i) this.insertNode(schema.linebreakReplacement.create(), marks, true);\n if (lines[i]) this.insertNode(schema.text(lines[i]), marks, !/\\S/.test(lines[i]));\n }\n value = \"\";\n } else {\n value = value.replace(/\\r?\\n|\\r/g, \" \");\n }\n if (value) this.insertNode(schema.text(value), marks, !/\\S/.test(value));\n this.findInText(dom);\n } else {\n this.findInside(dom);\n }\n }\n }, {\n key: \"addElement\",\n value: function addElement(dom, marks, matchAfter) {\n var outerWS = this.localPreserveWS,\n top = this.top;\n if (dom.tagName == \"PRE\" || /pre/.test(dom.style && dom.style.whiteSpace)) this.localPreserveWS = true;\n var name = dom.nodeName.toLowerCase(),\n ruleID;\n if (listTags.hasOwnProperty(name) && this.parser.normalizeLists) normalizeList(dom);\n var rule = this.options.ruleFromNode && this.options.ruleFromNode(dom) || (ruleID = this.parser.matchTag(dom, this, matchAfter));\n out: if (rule ? rule.ignore : ignoreTags.hasOwnProperty(name)) {\n this.findInside(dom);\n this.ignoreFallback(dom, marks);\n } else if (!rule || rule.skip || rule.closeParent) {\n if (rule && rule.closeParent) this.open = Math.max(0, this.open - 1);else if (rule && rule.skip.nodeType) dom = rule.skip;\n var sync,\n oldNeedsBlock = this.needsBlock;\n if (blockTags.hasOwnProperty(name)) {\n if (top.content.length && top.content[0].isInline && this.open) {\n this.open--;\n top = this.top;\n }\n sync = true;\n if (!top.type) this.needsBlock = true;\n } else if (!dom.firstChild) {\n this.leafFallback(dom, marks);\n break out;\n }\n var innerMarks = rule && rule.skip ? marks : this.readStyles(dom, marks);\n if (innerMarks) this.addAll(dom, innerMarks);\n if (sync) this.sync(top);\n this.needsBlock = oldNeedsBlock;\n } else {\n var _innerMarks = this.readStyles(dom, marks);\n if (_innerMarks) this.addElementByRule(dom, rule, _innerMarks, rule.consuming === false ? ruleID : undefined);\n }\n this.localPreserveWS = outerWS;\n }\n }, {\n key: \"leafFallback\",\n value: function leafFallback(dom, marks) {\n if (dom.nodeName == \"BR\" && this.top.type && this.top.type.inlineContent) this.addTextNode(dom.ownerDocument.createTextNode(\"\\n\"), marks);\n }\n }, {\n key: \"ignoreFallback\",\n value: function ignoreFallback(dom, marks) {\n if (dom.nodeName == \"BR\" && (!this.top.type || !this.top.type.inlineContent)) this.findPlace(this.parser.schema.text(\"-\"), marks, true);\n }\n }, {\n key: \"readStyles\",\n value: function readStyles(dom, marks) {\n var _this4 = this;\n var styles = dom.style;\n if (styles && styles.length) for (var i = 0; i < this.parser.matchedStyles.length; i++) {\n var name = this.parser.matchedStyles[i],\n value = styles.getPropertyValue(name);\n if (value) {\n var _loop4 = function _loop4(_after) {\n var rule = _this4.parser.matchStyle(name, value, _this4, _after);\n if (!rule) {\n after = _after;\n return 0;\n }\n if (rule.ignore) return {\n v: null\n };\n if (rule.clearMark) marks = marks.filter(function (m) {\n return !rule.clearMark(m);\n });else marks = marks.concat(_this4.parser.schema.marks[rule.mark].create(rule.attrs));\n if (rule.consuming === false) _after = rule;else {\n after = _after;\n return 0;\n }\n after = _after;\n },\n _ret;\n for (var after = undefined;;) {\n _ret = _loop4(after);\n if (_ret === 0) break;\n if (_ret) return _ret.v;\n }\n }\n }\n return marks;\n }\n }, {\n key: \"addElementByRule\",\n value: function addElementByRule(dom, rule, marks, continueAfter) {\n var _this5 = this;\n var sync, nodeType;\n if (rule.node) {\n nodeType = this.parser.schema.nodes[rule.node];\n if (!nodeType.isLeaf) {\n var inner = this.enter(nodeType, rule.attrs || null, marks, rule.preserveWhitespace);\n if (inner) {\n sync = true;\n marks = inner;\n }\n } else if (!this.insertNode(nodeType.create(rule.attrs), marks, dom.nodeName == \"BR\")) {\n this.leafFallback(dom, marks);\n }\n } else {\n var markType = this.parser.schema.marks[rule.mark];\n marks = marks.concat(markType.create(rule.attrs));\n }\n var startIn = this.top;\n if (nodeType && nodeType.isLeaf) {\n this.findInside(dom);\n } else if (continueAfter) {\n this.addElement(dom, marks, continueAfter);\n } else if (rule.getContent) {\n this.findInside(dom);\n rule.getContent(dom, this.parser.schema).forEach(function (node) {\n return _this5.insertNode(node, marks, false);\n });\n } else {\n var contentDOM = dom;\n if (typeof rule.contentElement == \"string\") contentDOM = dom.querySelector(rule.contentElement);else if (typeof rule.contentElement == \"function\") contentDOM = rule.contentElement(dom);else if (rule.contentElement) contentDOM = rule.contentElement;\n this.findAround(dom, contentDOM, true);\n this.addAll(contentDOM, marks);\n this.findAround(dom, contentDOM, false);\n }\n if (sync && this.sync(startIn)) this.open--;\n }\n }, {\n key: \"addAll\",\n value: function addAll(parent, marks, startIndex, endIndex) {\n var index = startIndex || 0;\n for (var dom = startIndex ? parent.childNodes[startIndex] : parent.firstChild, end = endIndex == null ? null : parent.childNodes[endIndex]; dom != end; dom = dom.nextSibling, ++index) {\n this.findAtPoint(parent, index);\n this.addDOM(dom, marks);\n }\n this.findAtPoint(parent, index);\n }\n }, {\n key: \"findPlace\",\n value: function findPlace(node, marks, cautious) {\n var route, sync;\n for (var depth = this.open, penalty = 0; depth >= 0; depth--) {\n var cx = this.nodes[depth];\n var _found2 = cx.findWrapping(node);\n if (_found2 && (!route || route.length > _found2.length + penalty)) {\n route = _found2;\n sync = cx;\n if (!_found2.length) break;\n }\n if (cx.solid) {\n if (cautious) break;\n penalty += 2;\n }\n }\n if (!route) return null;\n this.sync(sync);\n for (var i = 0; i < route.length; i++) marks = this.enterInner(route[i], null, marks, false);\n return marks;\n }\n }, {\n key: \"insertNode\",\n value: function insertNode(node, marks, cautious) {\n if (node.isInline && this.needsBlock && !this.top.type) {\n var block = this.textblockFromContext();\n if (block) marks = this.enterInner(block, null, marks);\n }\n var innerMarks = this.findPlace(node, marks, cautious);\n if (innerMarks) {\n this.closeExtra();\n var top = this.top;\n if (top.match) top.match = top.match.matchType(node.type);\n var nodeMarks = Mark.none;\n var _iterator = _createForOfIteratorHelper(innerMarks.concat(node.marks)),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var m = _step.value;\n if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, node.type)) nodeMarks = m.addToSet(nodeMarks);\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n top.content.push(node.mark(nodeMarks));\n return true;\n }\n return false;\n }\n }, {\n key: \"enter\",\n value: function enter(type, attrs, marks, preserveWS) {\n var innerMarks = this.findPlace(type.create(attrs), marks, false);\n if (innerMarks) innerMarks = this.enterInner(type, attrs, marks, true, preserveWS);\n return innerMarks;\n }\n }, {\n key: \"enterInner\",\n value: function enterInner(type, attrs, marks) {\n var solid = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n var preserveWS = arguments.length > 4 ? arguments[4] : undefined;\n this.closeExtra();\n var top = this.top;\n top.match = top.match && top.match.matchType(type);\n var options = wsOptionsFor(type, preserveWS, top.options);\n if (top.options & OPT_OPEN_LEFT && top.content.length == 0) options |= OPT_OPEN_LEFT;\n var applyMarks = Mark.none;\n marks = marks.filter(function (m) {\n if (top.type ? top.type.allowsMarkType(m.type) : markMayApply(m.type, type)) {\n applyMarks = m.addToSet(applyMarks);\n return false;\n }\n return true;\n });\n this.nodes.push(new NodeContext(type, attrs, applyMarks, solid, null, options));\n this.open++;\n return marks;\n }\n }, {\n key: \"closeExtra\",\n value: function closeExtra() {\n var openEnd = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;\n var i = this.nodes.length - 1;\n if (i > this.open) {\n for (; i > this.open; i--) this.nodes[i - 1].content.push(this.nodes[i].finish(openEnd));\n this.nodes.length = this.open + 1;\n }\n }\n }, {\n key: \"finish\",\n value: function finish() {\n this.open = 0;\n this.closeExtra(this.isOpen);\n return this.nodes[0].finish(!!(this.isOpen || this.options.topOpen));\n }\n }, {\n key: \"sync\",\n value: function sync(to) {\n for (var i = this.open; i >= 0; i--) {\n if (this.nodes[i] == to) {\n this.open = i;\n return true;\n } else if (this.localPreserveWS) {\n this.nodes[i].options |= OPT_PRESERVE_WS;\n }\n }\n return false;\n }\n }, {\n key: \"currentPos\",\n get: function get() {\n this.closeExtra();\n var pos = 0;\n for (var i = this.open; i >= 0; i--) {\n var content = this.nodes[i].content;\n for (var j = content.length - 1; j >= 0; j--) pos += content[j].nodeSize;\n if (i) pos++;\n }\n return pos;\n }\n }, {\n key: \"findAtPoint\",\n value: function findAtPoint(parent, offset) {\n if (this.find) for (var i = 0; i < this.find.length; i++) {\n if (this.find[i].node == parent && this.find[i].offset == offset) this.find[i].pos = this.currentPos;\n }\n }\n }, {\n key: \"findInside\",\n value: function findInside(parent) {\n if (this.find) for (var i = 0; i < this.find.length; i++) {\n if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) this.find[i].pos = this.currentPos;\n }\n }\n }, {\n key: \"findAround\",\n value: function findAround(parent, content, before) {\n if (parent != content && this.find) for (var i = 0; i < this.find.length; i++) {\n if (this.find[i].pos == null && parent.nodeType == 1 && parent.contains(this.find[i].node)) {\n var pos = content.compareDocumentPosition(this.find[i].node);\n if (pos & (before ? 2 : 4)) this.find[i].pos = this.currentPos;\n }\n }\n }\n }, {\n key: \"findInText\",\n value: function findInText(textNode) {\n if (this.find) for (var i = 0; i < this.find.length; i++) {\n if (this.find[i].node == textNode) this.find[i].pos = this.currentPos - (textNode.nodeValue.length - this.find[i].offset);\n }\n }\n }, {\n key: \"matchesContext\",\n value: function matchesContext(context) {\n var _this6 = this;\n if (context.indexOf(\"|\") > -1) return context.split(/\\s*\\|\\s*/).some(this.matchesContext, this);\n var parts = context.split(\"/\");\n var option = this.options.context;\n var useRoot = !this.isOpen && (!option || option.parent.type == this.nodes[0].type);\n var minDepth = -(option ? option.depth + 1 : 0) + (useRoot ? 0 : 1);\n var match = function match(i, depth) {\n for (; i >= 0; i--) {\n var part = parts[i];\n if (part == \"\") {\n if (i == parts.length - 1 || i == 0) continue;\n for (; depth >= minDepth; depth--) if (match(i - 1, depth)) return true;\n return false;\n } else {\n var next = depth > 0 || depth == 0 && useRoot ? _this6.nodes[depth].type : option && depth >= minDepth ? option.node(depth - minDepth).type : null;\n if (!next || next.name != part && !next.isInGroup(part)) return false;\n depth--;\n }\n }\n return true;\n };\n return match(parts.length - 1, this.open);\n }\n }, {\n key: \"textblockFromContext\",\n value: function textblockFromContext() {\n var $context = this.options.context;\n if ($context) for (var d = $context.depth; d >= 0; d--) {\n var deflt = $context.node(d).contentMatchAt($context.indexAfter(d)).defaultType;\n if (deflt && deflt.isTextblock && deflt.defaultAttrs) return deflt;\n }\n for (var name in this.parser.schema.nodes) {\n var type = this.parser.schema.nodes[name];\n if (type.isTextblock && type.defaultAttrs) return type;\n }\n }\n }]);\n return ParseContext;\n}();\nfunction normalizeList(dom) {\n for (var child = dom.firstChild, prevItem = null; child; child = child.nextSibling) {\n var name = child.nodeType == 1 ? child.nodeName.toLowerCase() : null;\n if (name && listTags.hasOwnProperty(name) && prevItem) {\n prevItem.appendChild(child);\n child = prevItem;\n } else if (name == \"li\") {\n prevItem = child;\n } else if (name) {\n prevItem = null;\n }\n }\n}\nfunction matches(dom, selector) {\n return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector);\n}\nfunction copy(obj) {\n var copy = {};\n for (var prop in obj) copy[prop] = obj[prop];\n return copy;\n}\nfunction markMayApply(markType, nodeType) {\n var nodes = nodeType.schema.nodes;\n var _loop5 = function _loop5() {\n var parent = nodes[name];\n if (!parent.allowsMarkType(markType)) return 0;\n var seen = [],\n scan = function scan(match) {\n seen.push(match);\n for (var i = 0; i < match.edgeCount; i++) {\n var _match$edge = match.edge(i),\n type = _match$edge.type,\n next = _match$edge.next;\n if (type == nodeType) return true;\n if (seen.indexOf(next) < 0 && scan(next)) return true;\n }\n };\n if (scan(parent.contentMatch)) return {\n v: true\n };\n },\n _ret2;\n for (var name in nodes) {\n _ret2 = _loop5();\n if (_ret2 === 0) continue;\n if (_ret2) return _ret2.v;\n }\n}\nvar DOMSerializer = function () {\n function DOMSerializer(nodes, marks) {\n _classCallCheck(this, DOMSerializer);\n this.nodes = nodes;\n this.marks = marks;\n }\n _createClass(DOMSerializer, [{\n key: \"serializeFragment\",\n value: function serializeFragment(fragment) {\n var _this7 = this;\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var target = arguments.length > 2 ? arguments[2] : undefined;\n if (!target) target = doc(options).createDocumentFragment();\n var top = target,\n active = [];\n fragment.forEach(function (node) {\n if (active.length || node.marks.length) {\n var keep = 0,\n rendered = 0;\n while (keep < active.length && rendered < node.marks.length) {\n var next = node.marks[rendered];\n if (!_this7.marks[next.type.name]) {\n rendered++;\n continue;\n }\n if (!next.eq(active[keep][0]) || next.type.spec.spanning === false) break;\n keep++;\n rendered++;\n }\n while (keep < active.length) top = active.pop()[1];\n while (rendered < node.marks.length) {\n var add = node.marks[rendered++];\n var markDOM = _this7.serializeMark(add, node.isInline, options);\n if (markDOM) {\n active.push([add, top]);\n top.appendChild(markDOM.dom);\n top = markDOM.contentDOM || markDOM.dom;\n }\n }\n }\n top.appendChild(_this7.serializeNodeInner(node, options));\n });\n return target;\n }\n }, {\n key: \"serializeNodeInner\",\n value: function serializeNodeInner(node, options) {\n if (node.isText) return doc(options).createTextNode(node.text);\n var _renderSpec2 = _renderSpec(doc(options), this.nodes[node.type.name](node), null, node.attrs),\n dom = _renderSpec2.dom,\n contentDOM = _renderSpec2.contentDOM;\n if (contentDOM) {\n if (node.isLeaf) throw new RangeError(\"Content hole not allowed in a leaf node spec\");\n this.serializeFragment(node.content, options, contentDOM);\n }\n return dom;\n }\n }, {\n key: \"serializeNode\",\n value: function serializeNode(node) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var dom = this.serializeNodeInner(node, options);\n for (var i = node.marks.length - 1; i >= 0; i--) {\n var wrap = this.serializeMark(node.marks[i], node.isInline, options);\n if (wrap) {\n (wrap.contentDOM || wrap.dom).appendChild(dom);\n dom = wrap.dom;\n }\n }\n return dom;\n }\n }, {\n key: \"serializeMark\",\n value: function serializeMark(mark, inline) {\n var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};\n var toDOM = this.marks[mark.type.name];\n return toDOM && _renderSpec(doc(options), toDOM(mark, inline), null, mark.attrs);\n }\n }], [{\n key: \"renderSpec\",\n value: function renderSpec(doc, structure) {\n var xmlNS = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var blockArraysIn = arguments.length > 3 ? arguments[3] : undefined;\n if (typeof structure == \"string\") return {\n dom: doc.createTextNode(structure)\n };\n return _renderSpec(doc, structure, xmlNS, blockArraysIn);\n }\n }, {\n key: \"fromSchema\",\n value: function fromSchema(schema) {\n return schema.cached.domSerializer || (schema.cached.domSerializer = new DOMSerializer(this.nodesFromSchema(schema), this.marksFromSchema(schema)));\n }\n }, {\n key: \"nodesFromSchema\",\n value: function nodesFromSchema(schema) {\n var result = gatherToDOM(schema.nodes);\n if (!result.text) result.text = function (node) {\n return node.text;\n };\n return result;\n }\n }, {\n key: \"marksFromSchema\",\n value: function marksFromSchema(schema) {\n return gatherToDOM(schema.marks);\n }\n }]);\n return DOMSerializer;\n}();\nfunction gatherToDOM(obj) {\n var result = {};\n for (var name in obj) {\n var toDOM = obj[name].spec.toDOM;\n if (toDOM) result[name] = toDOM;\n }\n return result;\n}\nfunction doc(options) {\n return options.document || window.document;\n}\nvar suspiciousAttributeCache = new WeakMap();\nfunction suspiciousAttributes(attrs) {\n var value = suspiciousAttributeCache.get(attrs);\n if (value === undefined) suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));\n return value;\n}\nfunction suspiciousAttributesInner(attrs) {\n var result = null;\n function scan(value) {\n if (value && _typeof(value) == \"object\") {\n if (Array.isArray(value)) {\n if (typeof value[0] == \"string\") {\n if (!result) result = [];\n result.push(value);\n } else {\n for (var i = 0; i < value.length; i++) scan(value[i]);\n }\n } else {\n for (var prop in value) scan(value[prop]);\n }\n }\n }\n scan(attrs);\n return result;\n}\nfunction _renderSpec(doc, structure, xmlNS, blockArraysIn) {\n if (structure.nodeType == 1) return {\n dom: structure\n };\n if (structure.dom && structure.dom.nodeType == 1) return structure;\n var tagName = structure[0],\n suspicious;\n if (typeof tagName != \"string\") throw new RangeError(\"Invalid array passed to renderSpec\");\n if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1) throw new RangeError(\"Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.\");\n var space = tagName.indexOf(\" \");\n if (space > 0) {\n xmlNS = tagName.slice(0, space);\n tagName = tagName.slice(space + 1);\n }\n var contentDOM;\n var dom = xmlNS ? doc.createElementNS(xmlNS, tagName) : doc.createElement(tagName);\n var attrs = structure[1],\n start = 1;\n if (attrs && _typeof(attrs) == \"object\" && attrs.nodeType == null && !Array.isArray(attrs)) {\n start = 2;\n for (var name in attrs) if (attrs[name] != null) {\n var _space = name.indexOf(\" \");\n if (_space > 0) dom.setAttributeNS(name.slice(0, _space), name.slice(_space + 1), attrs[name]);else if (name == \"style\" && dom.style) dom.style.cssText = attrs[name];else dom.setAttribute(name, attrs[name]);\n }\n }\n for (var i = start; i < structure.length; i++) {\n var child = structure[i];\n if (child === 0) {\n if (i < structure.length - 1 || i > start) throw new RangeError(\"Content hole must be the only child of its parent node\");\n return {\n dom: dom,\n contentDOM: dom\n };\n } else if (typeof child == \"string\") {\n dom.appendChild(doc.createTextNode(child));\n } else {\n var _renderSpec3 = _renderSpec(doc, child, xmlNS, blockArraysIn),\n inner = _renderSpec3.dom,\n innerContent = _renderSpec3.contentDOM;\n dom.appendChild(inner);\n if (innerContent) {\n if (contentDOM) throw new RangeError(\"Multiple content holes\");\n contentDOM = innerContent;\n }\n }\n }\n return {\n dom: dom,\n contentDOM: contentDOM\n };\n}\nexports.ContentMatch = ContentMatch;\nexports.DOMParser = DOMParser;\nexports.DOMSerializer = DOMSerializer;\nexports.Fragment = Fragment;\nexports.Mark = Mark;\nexports.MarkType = MarkType;\nexports.Node = Node;\nexports.NodeRange = NodeRange;\nexports.NodeType = NodeType;\nexports.ReplaceError = ReplaceError;\nexports.ResolvedPos = ResolvedPos;\nexports.Schema = Schema;\nexports.Slice = Slice;\n","'use strict';\n\nvar prosemirrorTransform = require('prosemirror-transform');\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorState = require('prosemirror-state');\nvar olDOM = [\"ol\", 0],\n ulDOM = [\"ul\", 0],\n liDOM = [\"li\", 0];\nvar orderedList = {\n attrs: {\n order: {\n \"default\": 1,\n validate: \"number\"\n }\n },\n parseDOM: [{\n tag: \"ol\",\n getAttrs: function getAttrs(dom) {\n return {\n order: dom.hasAttribute(\"start\") ? +dom.getAttribute(\"start\") : 1\n };\n }\n }],\n toDOM: function toDOM(node) {\n return node.attrs.order == 1 ? olDOM : [\"ol\", {\n start: node.attrs.order\n }, 0];\n }\n};\nvar bulletList = {\n parseDOM: [{\n tag: \"ul\"\n }],\n toDOM: function toDOM() {\n return ulDOM;\n }\n};\nvar listItem = {\n parseDOM: [{\n tag: \"li\"\n }],\n toDOM: function toDOM() {\n return liDOM;\n },\n defining: true\n};\nfunction add(obj, props) {\n var copy = {};\n for (var prop in obj) copy[prop] = obj[prop];\n for (var _prop in props) copy[_prop] = props[_prop];\n return copy;\n}\nfunction addListNodes(nodes, itemContent, listGroup) {\n return nodes.append({\n ordered_list: add(orderedList, {\n content: \"list_item+\",\n group: listGroup\n }),\n bullet_list: add(bulletList, {\n content: \"list_item+\",\n group: listGroup\n }),\n list_item: add(listItem, {\n content: itemContent\n })\n });\n}\nfunction wrapInList(listType) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n return function (state, dispatch) {\n var _state$selection = state.selection,\n $from = _state$selection.$from,\n $to = _state$selection.$to;\n var range = $from.blockRange($to);\n if (!range) return false;\n var tr = dispatch ? state.tr : null;\n if (!wrapRangeInList(tr, range, listType, attrs)) return false;\n if (dispatch) dispatch(tr.scrollIntoView());\n return true;\n };\n}\nfunction wrapRangeInList(tr, range, listType) {\n var attrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n var doJoin = false,\n outerRange = range,\n doc = range.$from.doc;\n if (range.depth >= 2 && range.$from.node(range.depth - 1).type.compatibleContent(listType) && range.startIndex == 0) {\n if (range.$from.index(range.depth - 1) == 0) return false;\n var $insert = doc.resolve(range.start - 2);\n outerRange = new prosemirrorModel.NodeRange($insert, $insert, range.depth);\n if (range.endIndex < range.parent.childCount) range = new prosemirrorModel.NodeRange(range.$from, doc.resolve(range.$to.end(range.depth)), range.depth);\n doJoin = true;\n }\n var wrap = prosemirrorTransform.findWrapping(outerRange, listType, attrs, range);\n if (!wrap) return false;\n if (tr) doWrapInList(tr, range, wrap, doJoin, listType);\n return true;\n}\nfunction doWrapInList(tr, range, wrappers, joinBefore, listType) {\n var content = prosemirrorModel.Fragment.empty;\n for (var i = wrappers.length - 1; i >= 0; i--) content = prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));\n tr.step(new prosemirrorTransform.ReplaceAroundStep(range.start - (joinBefore ? 2 : 0), range.end, range.start, range.end, new prosemirrorModel.Slice(content, 0, 0), wrappers.length, true));\n var found = 0;\n for (var _i = 0; _i < wrappers.length; _i++) if (wrappers[_i].type == listType) found = _i + 1;\n var splitDepth = wrappers.length - found;\n var splitPos = range.start + wrappers.length - (joinBefore ? 2 : 0),\n parent = range.parent;\n for (var _i2 = range.startIndex, e = range.endIndex, first = true; _i2 < e; _i2++, first = false) {\n if (!first && prosemirrorTransform.canSplit(tr.doc, splitPos, splitDepth)) {\n tr.split(splitPos, splitDepth);\n splitPos += 2 * splitDepth;\n }\n splitPos += parent.child(_i2).nodeSize;\n }\n return tr;\n}\nfunction splitListItem(itemType, itemAttrs) {\n return function (state, dispatch) {\n var _state$selection2 = state.selection,\n $from = _state$selection2.$from,\n $to = _state$selection2.$to,\n node = _state$selection2.node;\n if (node && node.isBlock || $from.depth < 2 || !$from.sameParent($to)) return false;\n var grandParent = $from.node(-1);\n if (grandParent.type != itemType) return false;\n if ($from.parent.content.size == 0 && $from.node(-1).childCount == $from.indexAfter(-1)) {\n if ($from.depth == 3 || $from.node(-3).type != itemType || $from.index(-2) != $from.node(-2).childCount - 1) return false;\n if (dispatch) {\n var wrap = prosemirrorModel.Fragment.empty;\n var depthBefore = $from.index(-1) ? 1 : $from.index(-2) ? 2 : 3;\n for (var d = $from.depth - depthBefore; d >= $from.depth - 3; d--) wrap = prosemirrorModel.Fragment.from($from.node(d).copy(wrap));\n var depthAfter = $from.indexAfter(-1) < $from.node(-2).childCount ? 1 : $from.indexAfter(-2) < $from.node(-3).childCount ? 2 : 3;\n wrap = wrap.append(prosemirrorModel.Fragment.from(itemType.createAndFill()));\n var start = $from.before($from.depth - (depthBefore - 1));\n var _tr = state.tr.replace(start, $from.after(-depthAfter), new prosemirrorModel.Slice(wrap, 4 - depthBefore, 0));\n var sel = -1;\n _tr.doc.nodesBetween(start, _tr.doc.content.size, function (node, pos) {\n if (sel > -1) return false;\n if (node.isTextblock && node.content.size == 0) sel = pos + 1;\n });\n if (sel > -1) _tr.setSelection(prosemirrorState.Selection.near(_tr.doc.resolve(sel)));\n dispatch(_tr.scrollIntoView());\n }\n return true;\n }\n var nextType = $to.pos == $from.end() ? grandParent.contentMatchAt(0).defaultType : null;\n var tr = state.tr[\"delete\"]($from.pos, $to.pos);\n var types = nextType ? [itemAttrs ? {\n type: itemType,\n attrs: itemAttrs\n } : null, {\n type: nextType\n }] : undefined;\n if (!prosemirrorTransform.canSplit(tr.doc, $from.pos, 2, types)) return false;\n if (dispatch) dispatch(tr.split($from.pos, 2, types).scrollIntoView());\n return true;\n };\n}\nfunction splitListItemKeepMarks(itemType, itemAttrs) {\n var split = splitListItem(itemType, itemAttrs);\n return function (state, dispatch) {\n return split(state, dispatch && function (tr) {\n var marks = state.storedMarks || state.selection.$to.parentOffset && state.selection.$from.marks();\n if (marks) tr.ensureMarks(marks);\n dispatch(tr);\n });\n };\n}\nfunction liftListItem(itemType) {\n return function (state, dispatch) {\n var _state$selection3 = state.selection,\n $from = _state$selection3.$from,\n $to = _state$selection3.$to;\n var range = $from.blockRange($to, function (node) {\n return node.childCount > 0 && node.firstChild.type == itemType;\n });\n if (!range) return false;\n if (!dispatch) return true;\n if ($from.node(range.depth - 1).type == itemType) return liftToOuterList(state, dispatch, itemType, range);else return liftOutOfList(state, dispatch, range);\n };\n}\nfunction liftToOuterList(state, dispatch, itemType, range) {\n var tr = state.tr,\n end = range.end,\n endOfList = range.$to.end(range.depth);\n if (end < endOfList) {\n tr.step(new prosemirrorTransform.ReplaceAroundStep(end - 1, endOfList, end, endOfList, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(itemType.create(null, range.parent.copy())), 1, 0), 1, true));\n range = new prosemirrorModel.NodeRange(tr.doc.resolve(range.$from.pos), tr.doc.resolve(endOfList), range.depth);\n }\n var target = prosemirrorTransform.liftTarget(range);\n if (target == null) return false;\n tr.lift(range, target);\n var $after = tr.doc.resolve(tr.mapping.map(end, -1) - 1);\n if (prosemirrorTransform.canJoin(tr.doc, $after.pos) && $after.nodeBefore.type == $after.nodeAfter.type) tr.join($after.pos);\n dispatch(tr.scrollIntoView());\n return true;\n}\nfunction liftOutOfList(state, dispatch, range) {\n var tr = state.tr,\n list = range.parent;\n for (var pos = range.end, i = range.endIndex - 1, e = range.startIndex; i > e; i--) {\n pos -= list.child(i).nodeSize;\n tr[\"delete\"](pos - 1, pos + 1);\n }\n var $start = tr.doc.resolve(range.start),\n item = $start.nodeAfter;\n if (tr.mapping.map(range.end) != range.start + $start.nodeAfter.nodeSize) return false;\n var atStart = range.startIndex == 0,\n atEnd = range.endIndex == list.childCount;\n var parent = $start.node(-1),\n indexBefore = $start.index(-1);\n if (!parent.canReplace(indexBefore + (atStart ? 0 : 1), indexBefore + 1, item.content.append(atEnd ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list)))) return false;\n var start = $start.pos,\n end = start + item.nodeSize;\n tr.step(new prosemirrorTransform.ReplaceAroundStep(start - (atStart ? 1 : 0), end + (atEnd ? 1 : 0), start + 1, end - 1, new prosemirrorModel.Slice((atStart ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list.copy(prosemirrorModel.Fragment.empty))).append(atEnd ? prosemirrorModel.Fragment.empty : prosemirrorModel.Fragment.from(list.copy(prosemirrorModel.Fragment.empty))), atStart ? 0 : 1, atEnd ? 0 : 1), atStart ? 0 : 1));\n dispatch(tr.scrollIntoView());\n return true;\n}\nfunction sinkListItem(itemType) {\n return function (state, dispatch) {\n var _state$selection4 = state.selection,\n $from = _state$selection4.$from,\n $to = _state$selection4.$to;\n var range = $from.blockRange($to, function (node) {\n return node.childCount > 0 && node.firstChild.type == itemType;\n });\n if (!range) return false;\n var startIndex = range.startIndex;\n if (startIndex == 0) return false;\n var parent = range.parent,\n nodeBefore = parent.child(startIndex - 1);\n if (nodeBefore.type != itemType) return false;\n if (dispatch) {\n var nestedBefore = nodeBefore.lastChild && nodeBefore.lastChild.type == parent.type;\n var inner = prosemirrorModel.Fragment.from(nestedBefore ? itemType.create() : null);\n var slice = new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(itemType.create(null, prosemirrorModel.Fragment.from(parent.type.create(null, inner)))), nestedBefore ? 3 : 1, 0);\n var before = range.start,\n after = range.end;\n dispatch(state.tr.step(new prosemirrorTransform.ReplaceAroundStep(before - (nestedBefore ? 3 : 1), after, before, after, slice, 1, true)).scrollIntoView());\n }\n return true;\n };\n}\nexports.addListNodes = addListNodes;\nexports.bulletList = bulletList;\nexports.liftListItem = liftListItem;\nexports.listItem = listItem;\nexports.orderedList = orderedList;\nexports.sinkListItem = sinkListItem;\nexports.splitListItem = splitListItem;\nexports.splitListItemKeepMarks = splitListItemKeepMarks;\nexports.wrapInList = wrapInList;\nexports.wrapRangeInList = wrapRangeInList;\n","'use strict';\n\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorTransform = require('prosemirror-transform');\nvar classesById = Object.create(null);\nvar Selection = function () {\n function Selection($anchor, $head, ranges) {\n _classCallCheck(this, Selection);\n this.$anchor = $anchor;\n this.$head = $head;\n this.ranges = ranges || [new SelectionRange($anchor.min($head), $anchor.max($head))];\n }\n _createClass(Selection, [{\n key: \"anchor\",\n get: function get() {\n return this.$anchor.pos;\n }\n }, {\n key: \"head\",\n get: function get() {\n return this.$head.pos;\n }\n }, {\n key: \"from\",\n get: function get() {\n return this.$from.pos;\n }\n }, {\n key: \"to\",\n get: function get() {\n return this.$to.pos;\n }\n }, {\n key: \"$from\",\n get: function get() {\n return this.ranges[0].$from;\n }\n }, {\n key: \"$to\",\n get: function get() {\n return this.ranges[0].$to;\n }\n }, {\n key: \"empty\",\n get: function get() {\n var ranges = this.ranges;\n for (var i = 0; i < ranges.length; i++) if (ranges[i].$from.pos != ranges[i].$to.pos) return false;\n return true;\n }\n }, {\n key: \"content\",\n value: function content() {\n return this.$from.doc.slice(this.from, this.to, true);\n }\n }, {\n key: \"replace\",\n value: function replace(tr) {\n var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prosemirrorModel.Slice.empty;\n var lastNode = content.content.lastChild,\n lastParent = null;\n for (var i = 0; i < content.openEnd; i++) {\n lastParent = lastNode;\n lastNode = lastNode.lastChild;\n }\n var mapFrom = tr.steps.length,\n ranges = this.ranges;\n for (var _i = 0; _i < ranges.length; _i++) {\n var _ranges$_i = ranges[_i],\n $from = _ranges$_i.$from,\n $to = _ranges$_i.$to,\n mapping = tr.mapping.slice(mapFrom);\n tr.replaceRange(mapping.map($from.pos), mapping.map($to.pos), _i ? prosemirrorModel.Slice.empty : content);\n if (_i == 0) selectionToInsertionEnd(tr, mapFrom, (lastNode ? lastNode.isInline : lastParent && lastParent.isTextblock) ? -1 : 1);\n }\n }\n }, {\n key: \"replaceWith\",\n value: function replaceWith(tr, node) {\n var mapFrom = tr.steps.length,\n ranges = this.ranges;\n for (var i = 0; i < ranges.length; i++) {\n var _ranges$i = ranges[i],\n $from = _ranges$i.$from,\n $to = _ranges$i.$to,\n mapping = tr.mapping.slice(mapFrom);\n var from = mapping.map($from.pos),\n to = mapping.map($to.pos);\n if (i) {\n tr.deleteRange(from, to);\n } else {\n tr.replaceRangeWith(from, to, node);\n selectionToInsertionEnd(tr, mapFrom, node.isInline ? -1 : 1);\n }\n }\n }\n }, {\n key: \"getBookmark\",\n value: function getBookmark() {\n return TextSelection.between(this.$anchor, this.$head).getBookmark();\n }\n }], [{\n key: \"findFrom\",\n value: function findFrom($pos, dir) {\n var textOnly = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;\n var inner = $pos.parent.inlineContent ? new TextSelection($pos) : findSelectionIn($pos.node(0), $pos.parent, $pos.pos, $pos.index(), dir, textOnly);\n if (inner) return inner;\n for (var depth = $pos.depth - 1; depth >= 0; depth--) {\n var found = dir < 0 ? findSelectionIn($pos.node(0), $pos.node(depth), $pos.before(depth + 1), $pos.index(depth), dir, textOnly) : findSelectionIn($pos.node(0), $pos.node(depth), $pos.after(depth + 1), $pos.index(depth) + 1, dir, textOnly);\n if (found) return found;\n }\n return null;\n }\n }, {\n key: \"near\",\n value: function near($pos) {\n var bias = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return this.findFrom($pos, bias) || this.findFrom($pos, -bias) || new AllSelection($pos.node(0));\n }\n }, {\n key: \"atStart\",\n value: function atStart(doc) {\n return findSelectionIn(doc, doc, 0, 0, 1) || new AllSelection(doc);\n }\n }, {\n key: \"atEnd\",\n value: function atEnd(doc) {\n return findSelectionIn(doc, doc, doc.content.size, doc.childCount, -1) || new AllSelection(doc);\n }\n }, {\n key: \"fromJSON\",\n value: function fromJSON(doc, json) {\n if (!json || !json.type) throw new RangeError(\"Invalid input for Selection.fromJSON\");\n var cls = classesById[json.type];\n if (!cls) throw new RangeError(\"No selection type \".concat(json.type, \" defined\"));\n return cls.fromJSON(doc, json);\n }\n }, {\n key: \"jsonID\",\n value: function jsonID(id, selectionClass) {\n if (id in classesById) throw new RangeError(\"Duplicate use of selection JSON ID \" + id);\n classesById[id] = selectionClass;\n selectionClass.prototype.jsonID = id;\n return selectionClass;\n }\n }]);\n return Selection;\n}();\nSelection.prototype.visible = true;\nvar SelectionRange = _createClass(function SelectionRange($from, $to) {\n _classCallCheck(this, SelectionRange);\n this.$from = $from;\n this.$to = $to;\n});\nvar warnedAboutTextSelection = false;\nfunction checkTextSelection($pos) {\n if (!warnedAboutTextSelection && !$pos.parent.inlineContent) {\n warnedAboutTextSelection = true;\n console[\"warn\"](\"TextSelection endpoint not pointing into a node with inline content (\" + $pos.parent.type.name + \")\");\n }\n}\nvar TextSelection = function (_Selection) {\n _inherits(TextSelection, _Selection);\n var _super = _createSuper(TextSelection);\n function TextSelection($anchor) {\n var $head = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : $anchor;\n _classCallCheck(this, TextSelection);\n checkTextSelection($anchor);\n checkTextSelection($head);\n return _super.call(this, $anchor, $head);\n }\n _createClass(TextSelection, [{\n key: \"$cursor\",\n get: function get() {\n return this.$anchor.pos == this.$head.pos ? this.$head : null;\n }\n }, {\n key: \"map\",\n value: function map(doc, mapping) {\n var $head = doc.resolve(mapping.map(this.head));\n if (!$head.parent.inlineContent) return Selection.near($head);\n var $anchor = doc.resolve(mapping.map(this.anchor));\n return new TextSelection($anchor.parent.inlineContent ? $anchor : $head, $head);\n }\n }, {\n key: \"replace\",\n value: function replace(tr) {\n var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prosemirrorModel.Slice.empty;\n _get(_getPrototypeOf(TextSelection.prototype), \"replace\", this).call(this, tr, content);\n if (content == prosemirrorModel.Slice.empty) {\n var marks = this.$from.marksAcross(this.$to);\n if (marks) tr.ensureMarks(marks);\n }\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return other instanceof TextSelection && other.anchor == this.anchor && other.head == this.head;\n }\n }, {\n key: \"getBookmark\",\n value: function getBookmark() {\n return new TextBookmark(this.anchor, this.head);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n type: \"text\",\n anchor: this.anchor,\n head: this.head\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(doc, json) {\n if (typeof json.anchor != \"number\" || typeof json.head != \"number\") throw new RangeError(\"Invalid input for TextSelection.fromJSON\");\n return new TextSelection(doc.resolve(json.anchor), doc.resolve(json.head));\n }\n }, {\n key: \"create\",\n value: function create(doc, anchor) {\n var head = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : anchor;\n var $anchor = doc.resolve(anchor);\n return new this($anchor, head == anchor ? $anchor : doc.resolve(head));\n }\n }, {\n key: \"between\",\n value: function between($anchor, $head, bias) {\n var dPos = $anchor.pos - $head.pos;\n if (!bias || dPos) bias = dPos >= 0 ? 1 : -1;\n if (!$head.parent.inlineContent) {\n var found = Selection.findFrom($head, bias, true) || Selection.findFrom($head, -bias, true);\n if (found) $head = found.$head;else return Selection.near($head, bias);\n }\n if (!$anchor.parent.inlineContent) {\n if (dPos == 0) {\n $anchor = $head;\n } else {\n $anchor = (Selection.findFrom($anchor, -bias, true) || Selection.findFrom($anchor, bias, true)).$anchor;\n if ($anchor.pos < $head.pos != dPos < 0) $anchor = $head;\n }\n }\n return new TextSelection($anchor, $head);\n }\n }]);\n return TextSelection;\n}(Selection);\nSelection.jsonID(\"text\", TextSelection);\nvar TextBookmark = function () {\n function TextBookmark(anchor, head) {\n _classCallCheck(this, TextBookmark);\n this.anchor = anchor;\n this.head = head;\n }\n _createClass(TextBookmark, [{\n key: \"map\",\n value: function map(mapping) {\n return new TextBookmark(mapping.map(this.anchor), mapping.map(this.head));\n }\n }, {\n key: \"resolve\",\n value: function resolve(doc) {\n return TextSelection.between(doc.resolve(this.anchor), doc.resolve(this.head));\n }\n }]);\n return TextBookmark;\n}();\nvar NodeSelection = function (_Selection2) {\n _inherits(NodeSelection, _Selection2);\n var _super2 = _createSuper(NodeSelection);\n function NodeSelection($pos) {\n var _this;\n _classCallCheck(this, NodeSelection);\n var node = $pos.nodeAfter;\n var $end = $pos.node(0).resolve($pos.pos + node.nodeSize);\n _this = _super2.call(this, $pos, $end);\n _this.node = node;\n return _this;\n }\n _createClass(NodeSelection, [{\n key: \"map\",\n value: function map(doc, mapping) {\n var _mapping$mapResult = mapping.mapResult(this.anchor),\n deleted = _mapping$mapResult.deleted,\n pos = _mapping$mapResult.pos;\n var $pos = doc.resolve(pos);\n if (deleted) return Selection.near($pos);\n return new NodeSelection($pos);\n }\n }, {\n key: \"content\",\n value: function content() {\n return new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(this.node), 0, 0);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return other instanceof NodeSelection && other.anchor == this.anchor;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n type: \"node\",\n anchor: this.anchor\n };\n }\n }, {\n key: \"getBookmark\",\n value: function getBookmark() {\n return new NodeBookmark(this.anchor);\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(doc, json) {\n if (typeof json.anchor != \"number\") throw new RangeError(\"Invalid input for NodeSelection.fromJSON\");\n return new NodeSelection(doc.resolve(json.anchor));\n }\n }, {\n key: \"create\",\n value: function create(doc, from) {\n return new NodeSelection(doc.resolve(from));\n }\n }, {\n key: \"isSelectable\",\n value: function isSelectable(node) {\n return !node.isText && node.type.spec.selectable !== false;\n }\n }]);\n return NodeSelection;\n}(Selection);\nNodeSelection.prototype.visible = false;\nSelection.jsonID(\"node\", NodeSelection);\nvar NodeBookmark = function () {\n function NodeBookmark(anchor) {\n _classCallCheck(this, NodeBookmark);\n this.anchor = anchor;\n }\n _createClass(NodeBookmark, [{\n key: \"map\",\n value: function map(mapping) {\n var _mapping$mapResult2 = mapping.mapResult(this.anchor),\n deleted = _mapping$mapResult2.deleted,\n pos = _mapping$mapResult2.pos;\n return deleted ? new TextBookmark(pos, pos) : new NodeBookmark(pos);\n }\n }, {\n key: \"resolve\",\n value: function resolve(doc) {\n var $pos = doc.resolve(this.anchor),\n node = $pos.nodeAfter;\n if (node && NodeSelection.isSelectable(node)) return new NodeSelection($pos);\n return Selection.near($pos);\n }\n }]);\n return NodeBookmark;\n}();\nvar AllSelection = function (_Selection3) {\n _inherits(AllSelection, _Selection3);\n var _super3 = _createSuper(AllSelection);\n function AllSelection(doc) {\n _classCallCheck(this, AllSelection);\n return _super3.call(this, doc.resolve(0), doc.resolve(doc.content.size));\n }\n _createClass(AllSelection, [{\n key: \"replace\",\n value: function replace(tr) {\n var content = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : prosemirrorModel.Slice.empty;\n if (content == prosemirrorModel.Slice.empty) {\n tr[\"delete\"](0, tr.doc.content.size);\n var sel = Selection.atStart(tr.doc);\n if (!sel.eq(tr.selection)) tr.setSelection(sel);\n } else {\n _get(_getPrototypeOf(AllSelection.prototype), \"replace\", this).call(this, tr, content);\n }\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n type: \"all\"\n };\n }\n }, {\n key: \"map\",\n value: function map(doc) {\n return new AllSelection(doc);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return other instanceof AllSelection;\n }\n }, {\n key: \"getBookmark\",\n value: function getBookmark() {\n return AllBookmark;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(doc) {\n return new AllSelection(doc);\n }\n }]);\n return AllSelection;\n}(Selection);\nSelection.jsonID(\"all\", AllSelection);\nvar AllBookmark = {\n map: function map() {\n return this;\n },\n resolve: function resolve(doc) {\n return new AllSelection(doc);\n }\n};\nfunction findSelectionIn(doc, node, pos, index, dir) {\n var text = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : false;\n if (node.inlineContent) return TextSelection.create(doc, pos);\n for (var i = index - (dir > 0 ? 0 : 1); dir > 0 ? i < node.childCount : i >= 0; i += dir) {\n var child = node.child(i);\n if (!child.isAtom) {\n var inner = findSelectionIn(doc, child, pos + dir, dir < 0 ? child.childCount : 0, dir, text);\n if (inner) return inner;\n } else if (!text && NodeSelection.isSelectable(child)) {\n return NodeSelection.create(doc, pos - (dir < 0 ? child.nodeSize : 0));\n }\n pos += child.nodeSize * dir;\n }\n return null;\n}\nfunction selectionToInsertionEnd(tr, startLen, bias) {\n var last = tr.steps.length - 1;\n if (last < startLen) return;\n var step = tr.steps[last];\n if (!(step instanceof prosemirrorTransform.ReplaceStep || step instanceof prosemirrorTransform.ReplaceAroundStep)) return;\n var map = tr.mapping.maps[last],\n end;\n map.forEach(function (_from, _to, _newFrom, newTo) {\n if (end == null) end = newTo;\n });\n tr.setSelection(Selection.near(tr.doc.resolve(end), bias));\n}\nvar UPDATED_SEL = 1,\n UPDATED_MARKS = 2,\n UPDATED_SCROLL = 4;\nvar Transaction = function (_prosemirrorTransform) {\n _inherits(Transaction, _prosemirrorTransform);\n var _super4 = _createSuper(Transaction);\n function Transaction(state) {\n var _this2;\n _classCallCheck(this, Transaction);\n _this2 = _super4.call(this, state.doc);\n _this2.curSelectionFor = 0;\n _this2.updated = 0;\n _this2.meta = Object.create(null);\n _this2.time = Date.now();\n _this2.curSelection = state.selection;\n _this2.storedMarks = state.storedMarks;\n return _this2;\n }\n _createClass(Transaction, [{\n key: \"selection\",\n get: function get() {\n if (this.curSelectionFor < this.steps.length) {\n this.curSelection = this.curSelection.map(this.doc, this.mapping.slice(this.curSelectionFor));\n this.curSelectionFor = this.steps.length;\n }\n return this.curSelection;\n }\n }, {\n key: \"setSelection\",\n value: function setSelection(selection) {\n if (selection.$from.doc != this.doc) throw new RangeError(\"Selection passed to setSelection must point at the current document\");\n this.curSelection = selection;\n this.curSelectionFor = this.steps.length;\n this.updated = (this.updated | UPDATED_SEL) & ~UPDATED_MARKS;\n this.storedMarks = null;\n return this;\n }\n }, {\n key: \"selectionSet\",\n get: function get() {\n return (this.updated & UPDATED_SEL) > 0;\n }\n }, {\n key: \"setStoredMarks\",\n value: function setStoredMarks(marks) {\n this.storedMarks = marks;\n this.updated |= UPDATED_MARKS;\n return this;\n }\n }, {\n key: \"ensureMarks\",\n value: function ensureMarks(marks) {\n if (!prosemirrorModel.Mark.sameSet(this.storedMarks || this.selection.$from.marks(), marks)) this.setStoredMarks(marks);\n return this;\n }\n }, {\n key: \"addStoredMark\",\n value: function addStoredMark(mark) {\n return this.ensureMarks(mark.addToSet(this.storedMarks || this.selection.$head.marks()));\n }\n }, {\n key: \"removeStoredMark\",\n value: function removeStoredMark(mark) {\n return this.ensureMarks(mark.removeFromSet(this.storedMarks || this.selection.$head.marks()));\n }\n }, {\n key: \"storedMarksSet\",\n get: function get() {\n return (this.updated & UPDATED_MARKS) > 0;\n }\n }, {\n key: \"addStep\",\n value: function addStep(step, doc) {\n _get(_getPrototypeOf(Transaction.prototype), \"addStep\", this).call(this, step, doc);\n this.updated = this.updated & ~UPDATED_MARKS;\n this.storedMarks = null;\n }\n }, {\n key: \"setTime\",\n value: function setTime(time) {\n this.time = time;\n return this;\n }\n }, {\n key: \"replaceSelection\",\n value: function replaceSelection(slice) {\n this.selection.replace(this, slice);\n return this;\n }\n }, {\n key: \"replaceSelectionWith\",\n value: function replaceSelectionWith(node) {\n var inheritMarks = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n var selection = this.selection;\n if (inheritMarks) node = node.mark(this.storedMarks || (selection.empty ? selection.$from.marks() : selection.$from.marksAcross(selection.$to) || prosemirrorModel.Mark.none));\n selection.replaceWith(this, node);\n return this;\n }\n }, {\n key: \"deleteSelection\",\n value: function deleteSelection() {\n this.selection.replace(this);\n return this;\n }\n }, {\n key: \"insertText\",\n value: function insertText(text, from, to) {\n var schema = this.doc.type.schema;\n if (from == null) {\n if (!text) return this.deleteSelection();\n return this.replaceSelectionWith(schema.text(text), true);\n } else {\n if (to == null) to = from;\n if (!text) return this.deleteRange(from, to);\n var marks = this.storedMarks;\n if (!marks) {\n var $from = this.doc.resolve(from);\n marks = to == from ? $from.marks() : $from.marksAcross(this.doc.resolve(to));\n }\n this.replaceRangeWith(from, to, schema.text(text, marks));\n if (!this.selection.empty && this.selection.to == from + text.length) this.setSelection(Selection.near(this.selection.$to));\n return this;\n }\n }\n }, {\n key: \"setMeta\",\n value: function setMeta(key, value) {\n this.meta[typeof key == \"string\" ? key : key.key] = value;\n return this;\n }\n }, {\n key: \"getMeta\",\n value: function getMeta(key) {\n return this.meta[typeof key == \"string\" ? key : key.key];\n }\n }, {\n key: \"isGeneric\",\n get: function get() {\n for (var _ in this.meta) return false;\n return true;\n }\n }, {\n key: \"scrollIntoView\",\n value: function scrollIntoView() {\n this.updated |= UPDATED_SCROLL;\n return this;\n }\n }, {\n key: \"scrolledIntoView\",\n get: function get() {\n return (this.updated & UPDATED_SCROLL) > 0;\n }\n }]);\n return Transaction;\n}(prosemirrorTransform.Transform);\nfunction bind(f, self) {\n return !self || !f ? f : f.bind(self);\n}\nvar FieldDesc = _createClass(function FieldDesc(name, desc, self) {\n _classCallCheck(this, FieldDesc);\n this.name = name;\n this.init = bind(desc.init, self);\n this.apply = bind(desc.apply, self);\n});\nvar baseFields = [new FieldDesc(\"doc\", {\n init: function init(config) {\n return config.doc || config.schema.topNodeType.createAndFill();\n },\n apply: function apply(tr) {\n return tr.doc;\n }\n}), new FieldDesc(\"selection\", {\n init: function init(config, instance) {\n return config.selection || Selection.atStart(instance.doc);\n },\n apply: function apply(tr) {\n return tr.selection;\n }\n}), new FieldDesc(\"storedMarks\", {\n init: function init(config) {\n return config.storedMarks || null;\n },\n apply: function apply(tr, _marks, _old, state) {\n return state.selection.$cursor ? tr.storedMarks : null;\n }\n}), new FieldDesc(\"scrollToSelection\", {\n init: function init() {\n return 0;\n },\n apply: function apply(tr, prev) {\n return tr.scrolledIntoView ? prev + 1 : prev;\n }\n})];\nvar Configuration = _createClass(function Configuration(schema, plugins) {\n var _this3 = this;\n _classCallCheck(this, Configuration);\n this.schema = schema;\n this.plugins = [];\n this.pluginsByKey = Object.create(null);\n this.fields = baseFields.slice();\n if (plugins) plugins.forEach(function (plugin) {\n if (_this3.pluginsByKey[plugin.key]) throw new RangeError(\"Adding different instances of a keyed plugin (\" + plugin.key + \")\");\n _this3.plugins.push(plugin);\n _this3.pluginsByKey[plugin.key] = plugin;\n if (plugin.spec.state) _this3.fields.push(new FieldDesc(plugin.key, plugin.spec.state, plugin));\n });\n});\nvar EditorState = function () {\n function EditorState(config) {\n _classCallCheck(this, EditorState);\n this.config = config;\n }\n _createClass(EditorState, [{\n key: \"schema\",\n get: function get() {\n return this.config.schema;\n }\n }, {\n key: \"plugins\",\n get: function get() {\n return this.config.plugins;\n }\n }, {\n key: \"apply\",\n value: function apply(tr) {\n return this.applyTransaction(tr).state;\n }\n }, {\n key: \"filterTransaction\",\n value: function filterTransaction(tr) {\n var ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : -1;\n for (var i = 0; i < this.config.plugins.length; i++) if (i != ignore) {\n var plugin = this.config.plugins[i];\n if (plugin.spec.filterTransaction && !plugin.spec.filterTransaction.call(plugin, tr, this)) return false;\n }\n return true;\n }\n }, {\n key: \"applyTransaction\",\n value: function applyTransaction(rootTr) {\n if (!this.filterTransaction(rootTr)) return {\n state: this,\n transactions: []\n };\n var trs = [rootTr],\n newState = this.applyInner(rootTr),\n seen = null;\n for (;;) {\n var haveNew = false;\n for (var i = 0; i < this.config.plugins.length; i++) {\n var plugin = this.config.plugins[i];\n if (plugin.spec.appendTransaction) {\n var n = seen ? seen[i].n : 0,\n oldState = seen ? seen[i].state : this;\n var tr = n < trs.length && plugin.spec.appendTransaction.call(plugin, n ? trs.slice(n) : trs, oldState, newState);\n if (tr && newState.filterTransaction(tr, i)) {\n tr.setMeta(\"appendedTransaction\", rootTr);\n if (!seen) {\n seen = [];\n for (var j = 0; j < this.config.plugins.length; j++) seen.push(j < i ? {\n state: newState,\n n: trs.length\n } : {\n state: this,\n n: 0\n });\n }\n trs.push(tr);\n newState = newState.applyInner(tr);\n haveNew = true;\n }\n if (seen) seen[i] = {\n state: newState,\n n: trs.length\n };\n }\n }\n if (!haveNew) return {\n state: newState,\n transactions: trs\n };\n }\n }\n }, {\n key: \"applyInner\",\n value: function applyInner(tr) {\n if (!tr.before.eq(this.doc)) throw new RangeError(\"Applying a mismatched transaction\");\n var newInstance = new EditorState(this.config),\n fields = this.config.fields;\n for (var i = 0; i < fields.length; i++) {\n var field = fields[i];\n newInstance[field.name] = field.apply(tr, this[field.name], this, newInstance);\n }\n return newInstance;\n }\n }, {\n key: \"tr\",\n get: function get() {\n return new Transaction(this);\n }\n }, {\n key: \"reconfigure\",\n value: function reconfigure(config) {\n var $config = new Configuration(this.schema, config.plugins);\n var fields = $config.fields,\n instance = new EditorState($config);\n for (var i = 0; i < fields.length; i++) {\n var name = fields[i].name;\n instance[name] = this.hasOwnProperty(name) ? this[name] : fields[i].init(config, instance);\n }\n return instance;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON(pluginFields) {\n var result = {\n doc: this.doc.toJSON(),\n selection: this.selection.toJSON()\n };\n if (this.storedMarks) result.storedMarks = this.storedMarks.map(function (m) {\n return m.toJSON();\n });\n if (pluginFields && _typeof(pluginFields) == 'object') for (var prop in pluginFields) {\n if (prop == \"doc\" || prop == \"selection\") throw new RangeError(\"The JSON fields `doc` and `selection` are reserved\");\n var plugin = pluginFields[prop],\n state = plugin.spec.state;\n if (state && state.toJSON) result[prop] = state.toJSON.call(plugin, this[plugin.key]);\n }\n return result;\n }\n }], [{\n key: \"create\",\n value: function create(config) {\n var $config = new Configuration(config.doc ? config.doc.type.schema : config.schema, config.plugins);\n var instance = new EditorState($config);\n for (var i = 0; i < $config.fields.length; i++) instance[$config.fields[i].name] = $config.fields[i].init(config, instance);\n return instance;\n }\n }, {\n key: \"fromJSON\",\n value: function fromJSON(config, json, pluginFields) {\n if (!json) throw new RangeError(\"Invalid input for EditorState.fromJSON\");\n if (!config.schema) throw new RangeError(\"Required config field 'schema' missing\");\n var $config = new Configuration(config.schema, config.plugins);\n var instance = new EditorState($config);\n $config.fields.forEach(function (field) {\n if (field.name == \"doc\") {\n instance.doc = prosemirrorModel.Node.fromJSON(config.schema, json.doc);\n } else if (field.name == \"selection\") {\n instance.selection = Selection.fromJSON(instance.doc, json.selection);\n } else if (field.name == \"storedMarks\") {\n if (json.storedMarks) instance.storedMarks = json.storedMarks.map(config.schema.markFromJSON);\n } else {\n if (pluginFields) for (var prop in pluginFields) {\n var plugin = pluginFields[prop],\n state = plugin.spec.state;\n if (plugin.key == field.name && state && state.fromJSON && Object.prototype.hasOwnProperty.call(json, prop)) {\n instance[field.name] = state.fromJSON.call(plugin, config, json[prop], instance);\n return;\n }\n }\n instance[field.name] = field.init(config, instance);\n }\n });\n return instance;\n }\n }]);\n return EditorState;\n}();\nfunction bindProps(obj, self, target) {\n for (var prop in obj) {\n var val = obj[prop];\n if (val instanceof Function) val = val.bind(self);else if (prop == \"handleDOMEvents\") val = bindProps(val, self, {});\n target[prop] = val;\n }\n return target;\n}\nvar Plugin = function () {\n function Plugin(spec) {\n _classCallCheck(this, Plugin);\n this.spec = spec;\n this.props = {};\n if (spec.props) bindProps(spec.props, this, this.props);\n this.key = spec.key ? spec.key.key : createKey(\"plugin\");\n }\n _createClass(Plugin, [{\n key: \"getState\",\n value: function getState(state) {\n return state[this.key];\n }\n }]);\n return Plugin;\n}();\nvar keys = Object.create(null);\nfunction createKey(name) {\n if (name in keys) return name + \"$\" + ++keys[name];\n keys[name] = 0;\n return name + \"$\";\n}\nvar PluginKey = function () {\n function PluginKey() {\n var name = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : \"key\";\n _classCallCheck(this, PluginKey);\n this.key = createKey(name);\n }\n _createClass(PluginKey, [{\n key: \"get\",\n value: function get(state) {\n return state.config.pluginsByKey[this.key];\n }\n }, {\n key: \"getState\",\n value: function getState(state) {\n return state[this.key];\n }\n }]);\n return PluginKey;\n}();\nexports.AllSelection = AllSelection;\nexports.EditorState = EditorState;\nexports.NodeSelection = NodeSelection;\nexports.Plugin = Plugin;\nexports.PluginKey = PluginKey;\nexports.Selection = Selection;\nexports.SelectionRange = SelectionRange;\nexports.TextSelection = TextSelection;\nexports.Transaction = Transaction;\n","let prosemirror_state = require(\"prosemirror-state\");\nlet prosemirror_model = require(\"prosemirror-model\");\nlet prosemirror_view = require(\"prosemirror-view\");\nlet prosemirror_keymap = require(\"prosemirror-keymap\");\nlet prosemirror_transform = require(\"prosemirror-transform\");\n\n//#region src/tablemap.ts\nlet readFromCache;\nlet addToCache;\nif (typeof WeakMap != \"undefined\") {\n\tlet cache = /* @__PURE__ */ new WeakMap();\n\treadFromCache = (key) => cache.get(key);\n\taddToCache = (key, value) => {\n\t\tcache.set(key, value);\n\t\treturn value;\n\t};\n} else {\n\tconst cache = [];\n\tconst cacheSize = 10;\n\tlet cachePos = 0;\n\treadFromCache = (key) => {\n\t\tfor (let i = 0; i < cache.length; i += 2) if (cache[i] == key) return cache[i + 1];\n\t};\n\taddToCache = (key, value) => {\n\t\tif (cachePos == cacheSize) cachePos = 0;\n\t\tcache[cachePos++] = key;\n\t\treturn cache[cachePos++] = value;\n\t};\n}\n/**\n* A table map describes the structure of a given table. To avoid\n* recomputing them all the time, they are cached per table node. To\n* be able to do that, positions saved in the map are relative to the\n* start of the table, rather than the start of the document.\n*\n* @public\n*/\nvar TableMap = class {\n\tconstructor(width, height, map, problems) {\n\t\tthis.width = width;\n\t\tthis.height = height;\n\t\tthis.map = map;\n\t\tthis.problems = problems;\n\t}\n\tfindCell(pos) {\n\t\tfor (let i = 0; i < this.map.length; i++) {\n\t\t\tconst curPos = this.map[i];\n\t\t\tif (curPos != pos) continue;\n\t\t\tconst left = i % this.width;\n\t\t\tconst top = i / this.width | 0;\n\t\t\tlet right = left + 1;\n\t\t\tlet bottom = top + 1;\n\t\t\tfor (let j = 1; right < this.width && this.map[i + j] == curPos; j++) right++;\n\t\t\tfor (let j = 1; bottom < this.height && this.map[i + this.width * j] == curPos; j++) bottom++;\n\t\t\treturn {\n\t\t\t\tleft,\n\t\t\t\ttop,\n\t\t\t\tright,\n\t\t\t\tbottom\n\t\t\t};\n\t\t}\n\t\tthrow new RangeError(`No cell with offset ${pos} found`);\n\t}\n\tcolCount(pos) {\n\t\tfor (let i = 0; i < this.map.length; i++) if (this.map[i] == pos) return i % this.width;\n\t\tthrow new RangeError(`No cell with offset ${pos} found`);\n\t}\n\tnextCell(pos, axis, dir) {\n\t\tconst { left, right, top, bottom } = this.findCell(pos);\n\t\tif (axis == \"horiz\") {\n\t\t\tif (dir < 0 ? left == 0 : right == this.width) return null;\n\t\t\treturn this.map[top * this.width + (dir < 0 ? left - 1 : right)];\n\t\t} else {\n\t\t\tif (dir < 0 ? top == 0 : bottom == this.height) return null;\n\t\t\treturn this.map[left + this.width * (dir < 0 ? top - 1 : bottom)];\n\t\t}\n\t}\n\trectBetween(a, b) {\n\t\tconst { left: leftA, right: rightA, top: topA, bottom: bottomA } = this.findCell(a);\n\t\tconst { left: leftB, right: rightB, top: topB, bottom: bottomB } = this.findCell(b);\n\t\treturn {\n\t\t\tleft: Math.min(leftA, leftB),\n\t\t\ttop: Math.min(topA, topB),\n\t\t\tright: Math.max(rightA, rightB),\n\t\t\tbottom: Math.max(bottomA, bottomB)\n\t\t};\n\t}\n\tcellsInRect(rect) {\n\t\tconst result = [];\n\t\tconst seen = {};\n\t\tfor (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {\n\t\t\tconst index = row * this.width + col;\n\t\t\tconst pos = this.map[index];\n\t\t\tif (seen[pos]) continue;\n\t\t\tseen[pos] = true;\n\t\t\tif (col == rect.left && col && this.map[index - 1] == pos || row == rect.top && row && this.map[index - this.width] == pos) continue;\n\t\t\tresult.push(pos);\n\t\t}\n\t\treturn result;\n\t}\n\tpositionAt(row, col, table) {\n\t\tfor (let i = 0, rowStart = 0;; i++) {\n\t\t\tconst rowEnd = rowStart + table.child(i).nodeSize;\n\t\t\tif (i == row) {\n\t\t\t\tlet index = col + row * this.width;\n\t\t\t\tconst rowEndIndex = (row + 1) * this.width;\n\t\t\t\twhile (index < rowEndIndex && this.map[index] < rowStart) index++;\n\t\t\t\treturn index == rowEndIndex ? rowEnd - 1 : this.map[index];\n\t\t\t}\n\t\t\trowStart = rowEnd;\n\t\t}\n\t}\n\tstatic get(table) {\n\t\treturn readFromCache(table) || addToCache(table, computeMap(table));\n\t}\n};\nfunction computeMap(table) {\n\tif (table.type.spec.tableRole != \"table\") throw new RangeError(\"Not a table node: \" + table.type.name);\n\tconst width = findWidth(table), height = table.childCount;\n\tconst map = [];\n\tlet mapPos = 0;\n\tlet problems = null;\n\tconst colWidths = [];\n\tfor (let i = 0, e = width * height; i < e; i++) map[i] = 0;\n\tfor (let row = 0, pos = 0; row < height; row++) {\n\t\tconst rowNode = table.child(row);\n\t\tpos++;\n\t\tfor (let i = 0;; i++) {\n\t\t\twhile (mapPos < map.length && map[mapPos] != 0) mapPos++;\n\t\t\tif (i == rowNode.childCount) break;\n\t\t\tconst cellNode = rowNode.child(i);\n\t\t\tconst { colspan, rowspan, colwidth } = cellNode.attrs;\n\t\t\tfor (let h = 0; h < rowspan; h++) {\n\t\t\t\tif (h + row >= height) {\n\t\t\t\t\t(problems || (problems = [])).push({\n\t\t\t\t\t\ttype: \"overlong_rowspan\",\n\t\t\t\t\t\tpos,\n\t\t\t\t\t\tn: rowspan - h\n\t\t\t\t\t});\n\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t\tconst start = mapPos + h * width;\n\t\t\t\tfor (let w = 0; w < colspan; w++) {\n\t\t\t\t\tif (map[start + w] == 0) map[start + w] = pos;\n\t\t\t\t\telse (problems || (problems = [])).push({\n\t\t\t\t\t\ttype: \"collision\",\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tpos,\n\t\t\t\t\t\tn: colspan - w\n\t\t\t\t\t});\n\t\t\t\t\tconst colW = colwidth && colwidth[w];\n\t\t\t\t\tif (colW) {\n\t\t\t\t\t\tconst widthIndex = (start + w) % width * 2, prev = colWidths[widthIndex];\n\t\t\t\t\t\tif (prev == null || prev != colW && colWidths[widthIndex + 1] == 1) {\n\t\t\t\t\t\t\tcolWidths[widthIndex] = colW;\n\t\t\t\t\t\t\tcolWidths[widthIndex + 1] = 1;\n\t\t\t\t\t\t} else if (prev == colW) colWidths[widthIndex + 1]++;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tmapPos += colspan;\n\t\t\tpos += cellNode.nodeSize;\n\t\t}\n\t\tconst expectedPos = (row + 1) * width;\n\t\tlet missing = 0;\n\t\twhile (mapPos < expectedPos) if (map[mapPos++] == 0) missing++;\n\t\tif (missing) (problems || (problems = [])).push({\n\t\t\ttype: \"missing\",\n\t\t\trow,\n\t\t\tn: missing\n\t\t});\n\t\tpos++;\n\t}\n\tif (width === 0 || height === 0) (problems || (problems = [])).push({ type: \"zero_sized\" });\n\tconst tableMap = new TableMap(width, height, map, problems);\n\tlet badWidths = false;\n\tfor (let i = 0; !badWidths && i < colWidths.length; i += 2) if (colWidths[i] != null && colWidths[i + 1] < height) badWidths = true;\n\tif (badWidths) findBadColWidths(tableMap, colWidths, table);\n\treturn tableMap;\n}\nfunction findWidth(table) {\n\tlet width = -1;\n\tlet hasRowSpan = false;\n\tfor (let row = 0; row < table.childCount; row++) {\n\t\tconst rowNode = table.child(row);\n\t\tlet rowWidth = 0;\n\t\tif (hasRowSpan) for (let j = 0; j < row; j++) {\n\t\t\tconst prevRow = table.child(j);\n\t\t\tfor (let i = 0; i < prevRow.childCount; i++) {\n\t\t\t\tconst cell = prevRow.child(i);\n\t\t\t\tif (j + cell.attrs.rowspan > row) rowWidth += cell.attrs.colspan;\n\t\t\t}\n\t\t}\n\t\tfor (let i = 0; i < rowNode.childCount; i++) {\n\t\t\tconst cell = rowNode.child(i);\n\t\t\trowWidth += cell.attrs.colspan;\n\t\t\tif (cell.attrs.rowspan > 1) hasRowSpan = true;\n\t\t}\n\t\tif (width == -1) width = rowWidth;\n\t\telse if (width != rowWidth) width = Math.max(width, rowWidth);\n\t}\n\treturn width;\n}\nfunction findBadColWidths(map, colWidths, table) {\n\tif (!map.problems) map.problems = [];\n\tconst seen = {};\n\tfor (let i = 0; i < map.map.length; i++) {\n\t\tconst pos = map.map[i];\n\t\tif (seen[pos]) continue;\n\t\tseen[pos] = true;\n\t\tconst node = table.nodeAt(pos);\n\t\tif (!node) throw new RangeError(`No cell with offset ${pos} found`);\n\t\tlet updated = null;\n\t\tconst attrs = node.attrs;\n\t\tfor (let j = 0; j < attrs.colspan; j++) {\n\t\t\tconst colWidth = colWidths[(i + j) % map.width * 2];\n\t\t\tif (colWidth != null && (!attrs.colwidth || attrs.colwidth[j] != colWidth)) (updated || (updated = freshColWidth(attrs)))[j] = colWidth;\n\t\t}\n\t\tif (updated) map.problems.unshift({\n\t\t\ttype: \"colwidth mismatch\",\n\t\t\tpos,\n\t\t\tcolwidth: updated\n\t\t});\n\t}\n}\nfunction freshColWidth(attrs) {\n\tif (attrs.colwidth) return attrs.colwidth.slice();\n\tconst result = [];\n\tfor (let i = 0; i < attrs.colspan; i++) result.push(0);\n\treturn result;\n}\n\n//#endregion\n//#region src/schema.ts\nfunction getCellAttrs(dom, extraAttrs) {\n\tif (typeof dom === \"string\") return {};\n\tconst widthAttr = dom.getAttribute(\"data-colwidth\");\n\tconst widths = widthAttr && /^\\d+(,\\d+)*$/.test(widthAttr) ? widthAttr.split(\",\").map((s) => Number(s)) : null;\n\tconst colspan = Number(dom.getAttribute(\"colspan\") || 1);\n\tconst result = {\n\t\tcolspan,\n\t\trowspan: Number(dom.getAttribute(\"rowspan\") || 1),\n\t\tcolwidth: widths && widths.length == colspan ? widths : null\n\t};\n\tfor (const prop in extraAttrs) {\n\t\tconst getter = extraAttrs[prop].getFromDOM;\n\t\tconst value = getter && getter(dom);\n\t\tif (value != null) result[prop] = value;\n\t}\n\treturn result;\n}\nfunction setCellAttrs(node, extraAttrs) {\n\tconst attrs = {};\n\tif (node.attrs.colspan != 1) attrs.colspan = node.attrs.colspan;\n\tif (node.attrs.rowspan != 1) attrs.rowspan = node.attrs.rowspan;\n\tif (node.attrs.colwidth) attrs[\"data-colwidth\"] = node.attrs.colwidth.join(\",\");\n\tfor (const prop in extraAttrs) {\n\t\tconst setter = extraAttrs[prop].setDOMAttr;\n\t\tif (setter) setter(node.attrs[prop], attrs);\n\t}\n\treturn attrs;\n}\nfunction validateColwidth(value) {\n\tif (value === null) return;\n\tif (!Array.isArray(value)) throw new TypeError(\"colwidth must be null or an array\");\n\tfor (const item of value) if (typeof item !== \"number\") throw new TypeError(\"colwidth must be null or an array of numbers\");\n}\n/**\n* This function creates a set of [node\n* specs](http://prosemirror.net/docs/ref/#model.SchemaSpec.nodes) for\n* `table`, `table_row`, and `table_cell` nodes types as used by this\n* module. The result can then be added to the set of nodes when\n* creating a schema.\n*\n* @public\n*/\nfunction tableNodes(options) {\n\tconst extraAttrs = options.cellAttributes || {};\n\tconst cellAttrs = {\n\t\tcolspan: {\n\t\t\tdefault: 1,\n\t\t\tvalidate: \"number\"\n\t\t},\n\t\trowspan: {\n\t\t\tdefault: 1,\n\t\t\tvalidate: \"number\"\n\t\t},\n\t\tcolwidth: {\n\t\t\tdefault: null,\n\t\t\tvalidate: validateColwidth\n\t\t}\n\t};\n\tfor (const prop in extraAttrs) cellAttrs[prop] = {\n\t\tdefault: extraAttrs[prop].default,\n\t\tvalidate: extraAttrs[prop].validate\n\t};\n\treturn {\n\t\ttable: {\n\t\t\tcontent: \"table_row+\",\n\t\t\ttableRole: \"table\",\n\t\t\tisolating: true,\n\t\t\tgroup: options.tableGroup,\n\t\t\tparseDOM: [{ tag: \"table\" }],\n\t\t\ttoDOM() {\n\t\t\t\treturn [\"table\", [\"tbody\", 0]];\n\t\t\t}\n\t\t},\n\t\ttable_row: {\n\t\t\tcontent: \"(table_cell | table_header)*\",\n\t\t\ttableRole: \"row\",\n\t\t\tparseDOM: [{ tag: \"tr\" }],\n\t\t\ttoDOM() {\n\t\t\t\treturn [\"tr\", 0];\n\t\t\t}\n\t\t},\n\t\ttable_cell: {\n\t\t\tcontent: options.cellContent,\n\t\t\tattrs: cellAttrs,\n\t\t\ttableRole: \"cell\",\n\t\t\tisolating: true,\n\t\t\tparseDOM: [{\n\t\t\t\ttag: \"td\",\n\t\t\t\tgetAttrs: (dom) => getCellAttrs(dom, extraAttrs)\n\t\t\t}],\n\t\t\ttoDOM(node) {\n\t\t\t\treturn [\n\t\t\t\t\t\"td\",\n\t\t\t\t\tsetCellAttrs(node, extraAttrs),\n\t\t\t\t\t0\n\t\t\t\t];\n\t\t\t}\n\t\t},\n\t\ttable_header: {\n\t\t\tcontent: options.cellContent,\n\t\t\tattrs: cellAttrs,\n\t\t\ttableRole: \"header_cell\",\n\t\t\tisolating: true,\n\t\t\tparseDOM: [{\n\t\t\t\ttag: \"th\",\n\t\t\t\tgetAttrs: (dom) => getCellAttrs(dom, extraAttrs)\n\t\t\t}],\n\t\t\ttoDOM(node) {\n\t\t\t\treturn [\n\t\t\t\t\t\"th\",\n\t\t\t\t\tsetCellAttrs(node, extraAttrs),\n\t\t\t\t\t0\n\t\t\t\t];\n\t\t\t}\n\t\t}\n\t};\n}\n/**\n* @public\n*/\nfunction tableNodeTypes(schema) {\n\tlet result = schema.cached.tableNodeTypes;\n\tif (!result) {\n\t\tresult = schema.cached.tableNodeTypes = {};\n\t\tfor (const name in schema.nodes) {\n\t\t\tconst type = schema.nodes[name], role = type.spec.tableRole;\n\t\t\tif (role) result[role] = type;\n\t\t}\n\t}\n\treturn result;\n}\n\n//#endregion\n//#region src/util.ts\n/**\n* @public\n*/\nconst tableEditingKey = new prosemirror_state.PluginKey(\"selectingCells\");\n/**\n* @public\n*/\nfunction cellAround($pos) {\n\tfor (let d = $pos.depth - 1; d > 0; d--) if ($pos.node(d).type.spec.tableRole == \"row\") return $pos.node(0).resolve($pos.before(d + 1));\n\treturn null;\n}\nfunction cellWrapping($pos) {\n\tfor (let d = $pos.depth; d > 0; d--) {\n\t\tconst role = $pos.node(d).type.spec.tableRole;\n\t\tif (role === \"cell\" || role === \"header_cell\") return $pos.node(d);\n\t}\n\treturn null;\n}\n/**\n* @public\n*/\nfunction isInTable(state) {\n\tconst $head = state.selection.$head;\n\tfor (let d = $head.depth; d > 0; d--) if ($head.node(d).type.spec.tableRole == \"row\") return true;\n\treturn false;\n}\n/**\n* @internal\n*/\nfunction selectionCell(state) {\n\tconst sel = state.selection;\n\tif (\"$anchorCell\" in sel && sel.$anchorCell) return sel.$anchorCell.pos > sel.$headCell.pos ? sel.$anchorCell : sel.$headCell;\n\telse if (\"node\" in sel && sel.node && sel.node.type.spec.tableRole == \"cell\") return sel.$anchor;\n\tconst $cell = cellAround(sel.$head) || cellNear(sel.$head);\n\tif ($cell) return $cell;\n\tthrow new RangeError(`No cell found around position ${sel.head}`);\n}\n/**\n* @public\n*/\nfunction cellNear($pos) {\n\tfor (let after = $pos.nodeAfter, pos = $pos.pos; after; after = after.firstChild, pos++) {\n\t\tconst role = after.type.spec.tableRole;\n\t\tif (role == \"cell\" || role == \"header_cell\") return $pos.doc.resolve(pos);\n\t}\n\tfor (let before = $pos.nodeBefore, pos = $pos.pos; before; before = before.lastChild, pos--) {\n\t\tconst role = before.type.spec.tableRole;\n\t\tif (role == \"cell\" || role == \"header_cell\") return $pos.doc.resolve(pos - before.nodeSize);\n\t}\n}\n/**\n* @public\n*/\nfunction pointsAtCell($pos) {\n\treturn $pos.parent.type.spec.tableRole == \"row\" && !!$pos.nodeAfter;\n}\n/**\n* @public\n*/\nfunction moveCellForward($pos) {\n\treturn $pos.node(0).resolve($pos.pos + $pos.nodeAfter.nodeSize);\n}\n/**\n* @internal\n*/\nfunction inSameTable($cellA, $cellB) {\n\treturn $cellA.depth == $cellB.depth && $cellA.pos >= $cellB.start(-1) && $cellA.pos <= $cellB.end(-1);\n}\n/**\n* @public\n*/\nfunction findCell($pos) {\n\treturn TableMap.get($pos.node(-1)).findCell($pos.pos - $pos.start(-1));\n}\n/**\n* @public\n*/\nfunction colCount($pos) {\n\treturn TableMap.get($pos.node(-1)).colCount($pos.pos - $pos.start(-1));\n}\n/**\n* @public\n*/\nfunction nextCell($pos, axis, dir) {\n\tconst table = $pos.node(-1);\n\tconst map = TableMap.get(table);\n\tconst tableStart = $pos.start(-1);\n\tconst moved = map.nextCell($pos.pos - tableStart, axis, dir);\n\treturn moved == null ? null : $pos.node(0).resolve(tableStart + moved);\n}\n/**\n* @public\n*/\nfunction removeColSpan(attrs, pos, n = 1) {\n\tconst result = {\n\t\t...attrs,\n\t\tcolspan: attrs.colspan - n\n\t};\n\tif (result.colwidth) {\n\t\tresult.colwidth = result.colwidth.slice();\n\t\tresult.colwidth.splice(pos, n);\n\t\tif (!result.colwidth.some((w) => w > 0)) result.colwidth = null;\n\t}\n\treturn result;\n}\n/**\n* @public\n*/\nfunction addColSpan(attrs, pos, n = 1) {\n\tconst result = {\n\t\t...attrs,\n\t\tcolspan: attrs.colspan + n\n\t};\n\tif (result.colwidth) {\n\t\tresult.colwidth = result.colwidth.slice();\n\t\tfor (let i = 0; i < n; i++) result.colwidth.splice(pos, 0, 0);\n\t}\n\treturn result;\n}\n/**\n* @public\n*/\nfunction columnIsHeader(map, table, col) {\n\tconst headerCell = tableNodeTypes(table.type.schema).header_cell;\n\tfor (let row = 0; row < map.height; row++) if (table.nodeAt(map.map[col + row * map.width]).type != headerCell) return false;\n\treturn true;\n}\n\n//#endregion\n//#region src/cellselection.ts\n/**\n* A [`Selection`](http://prosemirror.net/docs/ref/#state.Selection)\n* subclass that represents a cell selection spanning part of a table.\n* With the plugin enabled, these will be created when the user\n* selects across cells, and will be drawn by giving selected cells a\n* `selectedCell` CSS class.\n*\n* @public\n*/\nvar CellSelection = class CellSelection extends prosemirror_state.Selection {\n\tconstructor($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst rect = map.rectBetween($anchorCell.pos - tableStart, $headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tconst cells = map.cellsInRect(rect).filter((p) => p != $headCell.pos - tableStart);\n\t\tcells.unshift($headCell.pos - tableStart);\n\t\tconst ranges = cells.map((pos) => {\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tif (!cell) throw new RangeError(`No cell with offset ${pos} found`);\n\t\t\tconst from = tableStart + pos + 1;\n\t\t\treturn new prosemirror_state.SelectionRange(doc.resolve(from), doc.resolve(from + cell.content.size));\n\t\t});\n\t\tsuper(ranges[0].$from, ranges[0].$to, ranges);\n\t\tthis.$anchorCell = $anchorCell;\n\t\tthis.$headCell = $headCell;\n\t}\n\tmap(doc, mapping) {\n\t\tconst $anchorCell = doc.resolve(mapping.map(this.$anchorCell.pos));\n\t\tconst $headCell = doc.resolve(mapping.map(this.$headCell.pos));\n\t\tif (pointsAtCell($anchorCell) && pointsAtCell($headCell) && inSameTable($anchorCell, $headCell)) {\n\t\t\tconst tableChanged = this.$anchorCell.node(-1) != $anchorCell.node(-1);\n\t\t\tif (tableChanged && this.isRowSelection()) return CellSelection.rowSelection($anchorCell, $headCell);\n\t\t\telse if (tableChanged && this.isColSelection()) return CellSelection.colSelection($anchorCell, $headCell);\n\t\t\telse return new CellSelection($anchorCell, $headCell);\n\t\t}\n\t\treturn prosemirror_state.TextSelection.between($anchorCell, $headCell);\n\t}\n\tcontent() {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst rect = map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart);\n\t\tconst seen = {};\n\t\tconst rows = [];\n\t\tfor (let row = rect.top; row < rect.bottom; row++) {\n\t\t\tconst rowContent = [];\n\t\t\tfor (let index = row * map.width + rect.left, col = rect.left; col < rect.right; col++, index++) {\n\t\t\t\tconst pos = map.map[index];\n\t\t\t\tif (seen[pos]) continue;\n\t\t\t\tseen[pos] = true;\n\t\t\t\tconst cellRect = map.findCell(pos);\n\t\t\t\tlet cell = table.nodeAt(pos);\n\t\t\t\tif (!cell) throw new RangeError(`No cell with offset ${pos} found`);\n\t\t\t\tconst extraLeft = rect.left - cellRect.left;\n\t\t\t\tconst extraRight = cellRect.right - rect.right;\n\t\t\t\tif (extraLeft > 0 || extraRight > 0) {\n\t\t\t\t\tlet attrs = cell.attrs;\n\t\t\t\t\tif (extraLeft > 0) attrs = removeColSpan(attrs, 0, extraLeft);\n\t\t\t\t\tif (extraRight > 0) attrs = removeColSpan(attrs, attrs.colspan - extraRight, extraRight);\n\t\t\t\t\tif (cellRect.left < rect.left) {\n\t\t\t\t\t\tcell = cell.type.createAndFill(attrs);\n\t\t\t\t\t\tif (!cell) throw new RangeError(`Could not create cell with attrs ${JSON.stringify(attrs)}`);\n\t\t\t\t\t} else cell = cell.type.create(attrs, cell.content);\n\t\t\t\t}\n\t\t\t\tif (cellRect.top < rect.top || cellRect.bottom > rect.bottom) {\n\t\t\t\t\tconst attrs = {\n\t\t\t\t\t\t...cell.attrs,\n\t\t\t\t\t\trowspan: Math.min(cellRect.bottom, rect.bottom) - Math.max(cellRect.top, rect.top)\n\t\t\t\t\t};\n\t\t\t\t\tif (cellRect.top < rect.top) cell = cell.type.createAndFill(attrs);\n\t\t\t\t\telse cell = cell.type.create(attrs, cell.content);\n\t\t\t\t}\n\t\t\t\trowContent.push(cell);\n\t\t\t}\n\t\t\trows.push(table.child(row).copy(prosemirror_model.Fragment.from(rowContent)));\n\t\t}\n\t\tconst fragment = this.isColSelection() && this.isRowSelection() ? table : rows;\n\t\treturn new prosemirror_model.Slice(prosemirror_model.Fragment.from(fragment), 1, 1);\n\t}\n\treplace(tr, content = prosemirror_model.Slice.empty) {\n\t\tconst mapFrom = tr.steps.length, ranges = this.ranges;\n\t\tfor (let i = 0; i < ranges.length; i++) {\n\t\t\tconst { $from, $to } = ranges[i], mapping = tr.mapping.slice(mapFrom);\n\t\t\ttr.replace(mapping.map($from.pos), mapping.map($to.pos), i ? prosemirror_model.Slice.empty : content);\n\t\t}\n\t\tconst sel = prosemirror_state.Selection.findFrom(tr.doc.resolve(tr.mapping.slice(mapFrom).map(this.to)), -1);\n\t\tif (sel) tr.setSelection(sel);\n\t}\n\treplaceWith(tr, node) {\n\t\tthis.replace(tr, new prosemirror_model.Slice(prosemirror_model.Fragment.from(node), 0, 0));\n\t}\n\tforEachCell(f) {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst cells = map.cellsInRect(map.rectBetween(this.$anchorCell.pos - tableStart, this.$headCell.pos - tableStart));\n\t\tfor (let i = 0; i < cells.length; i++) f(table.nodeAt(cells[i]), tableStart + cells[i]);\n\t}\n\tisColSelection() {\n\t\tconst anchorTop = this.$anchorCell.index(-1);\n\t\tconst headTop = this.$headCell.index(-1);\n\t\tif (Math.min(anchorTop, headTop) > 0) return false;\n\t\tconst anchorBottom = anchorTop + this.$anchorCell.nodeAfter.attrs.rowspan;\n\t\tconst headBottom = headTop + this.$headCell.nodeAfter.attrs.rowspan;\n\t\treturn Math.max(anchorBottom, headBottom) == this.$headCell.node(-1).childCount;\n\t}\n\tstatic colSelection($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst anchorRect = map.findCell($anchorCell.pos - tableStart);\n\t\tconst headRect = map.findCell($headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tif (anchorRect.top <= headRect.top) {\n\t\t\tif (anchorRect.top > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.left]);\n\t\t\tif (headRect.bottom < map.height) $headCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + headRect.right - 1]);\n\t\t} else {\n\t\t\tif (headRect.top > 0) $headCell = doc.resolve(tableStart + map.map[headRect.left]);\n\t\t\tif (anchorRect.bottom < map.height) $anchorCell = doc.resolve(tableStart + map.map[map.width * (map.height - 1) + anchorRect.right - 1]);\n\t\t}\n\t\treturn new CellSelection($anchorCell, $headCell);\n\t}\n\tisRowSelection() {\n\t\tconst table = this.$anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = this.$anchorCell.start(-1);\n\t\tconst anchorLeft = map.colCount(this.$anchorCell.pos - tableStart);\n\t\tconst headLeft = map.colCount(this.$headCell.pos - tableStart);\n\t\tif (Math.min(anchorLeft, headLeft) > 0) return false;\n\t\tconst anchorRight = anchorLeft + this.$anchorCell.nodeAfter.attrs.colspan;\n\t\tconst headRight = headLeft + this.$headCell.nodeAfter.attrs.colspan;\n\t\treturn Math.max(anchorRight, headRight) == map.width;\n\t}\n\teq(other) {\n\t\treturn other instanceof CellSelection && other.$anchorCell.pos == this.$anchorCell.pos && other.$headCell.pos == this.$headCell.pos;\n\t}\n\tstatic rowSelection($anchorCell, $headCell = $anchorCell) {\n\t\tconst table = $anchorCell.node(-1);\n\t\tconst map = TableMap.get(table);\n\t\tconst tableStart = $anchorCell.start(-1);\n\t\tconst anchorRect = map.findCell($anchorCell.pos - tableStart);\n\t\tconst headRect = map.findCell($headCell.pos - tableStart);\n\t\tconst doc = $anchorCell.node(0);\n\t\tif (anchorRect.left <= headRect.left) {\n\t\t\tif (anchorRect.left > 0) $anchorCell = doc.resolve(tableStart + map.map[anchorRect.top * map.width]);\n\t\t\tif (headRect.right < map.width) $headCell = doc.resolve(tableStart + map.map[map.width * (headRect.top + 1) - 1]);\n\t\t} else {\n\t\t\tif (headRect.left > 0) $headCell = doc.resolve(tableStart + map.map[headRect.top * map.width]);\n\t\t\tif (anchorRect.right < map.width) $anchorCell = doc.resolve(tableStart + map.map[map.width * (anchorRect.top + 1) - 1]);\n\t\t}\n\t\treturn new CellSelection($anchorCell, $headCell);\n\t}\n\ttoJSON() {\n\t\treturn {\n\t\t\ttype: \"cell\",\n\t\t\tanchor: this.$anchorCell.pos,\n\t\t\thead: this.$headCell.pos\n\t\t};\n\t}\n\tstatic fromJSON(doc, json) {\n\t\treturn new CellSelection(doc.resolve(json.anchor), doc.resolve(json.head));\n\t}\n\tstatic create(doc, anchorCell, headCell = anchorCell) {\n\t\treturn new CellSelection(doc.resolve(anchorCell), doc.resolve(headCell));\n\t}\n\tgetBookmark() {\n\t\treturn new CellBookmark(this.$anchorCell.pos, this.$headCell.pos);\n\t}\n};\nCellSelection.prototype.visible = false;\nprosemirror_state.Selection.jsonID(\"cell\", CellSelection);\n/**\n* @public\n*/\nvar CellBookmark = class CellBookmark {\n\tconstructor(anchor, head) {\n\t\tthis.anchor = anchor;\n\t\tthis.head = head;\n\t}\n\tmap(mapping) {\n\t\treturn new CellBookmark(mapping.map(this.anchor), mapping.map(this.head));\n\t}\n\tresolve(doc) {\n\t\tconst $anchorCell = doc.resolve(this.anchor), $headCell = doc.resolve(this.head);\n\t\tif ($anchorCell.parent.type.spec.tableRole == \"row\" && $headCell.parent.type.spec.tableRole == \"row\" && $anchorCell.index() < $anchorCell.parent.childCount && $headCell.index() < $headCell.parent.childCount && inSameTable($anchorCell, $headCell)) return new CellSelection($anchorCell, $headCell);\n\t\telse return prosemirror_state.Selection.near($headCell, 1);\n\t}\n};\nfunction drawCellSelection(state) {\n\tif (!(state.selection instanceof CellSelection)) return null;\n\tconst cells = [];\n\tstate.selection.forEachCell((node, pos) => {\n\t\tcells.push(prosemirror_view.Decoration.node(pos, pos + node.nodeSize, { class: \"selectedCell\" }));\n\t});\n\treturn prosemirror_view.DecorationSet.create(state.doc, cells);\n}\nfunction isCellBoundarySelection({ $from, $to }) {\n\tif ($from.pos == $to.pos || $from.pos < $to.pos - 6) return false;\n\tlet afterFrom = $from.pos;\n\tlet beforeTo = $to.pos;\n\tlet depth = $from.depth;\n\tfor (; depth >= 0; depth--, afterFrom++) if ($from.after(depth + 1) < $from.end(depth)) break;\n\tfor (let d = $to.depth; d >= 0; d--, beforeTo--) if ($to.before(d + 1) > $to.start(d)) break;\n\treturn afterFrom == beforeTo && /row|table/.test($from.node(depth).type.spec.tableRole);\n}\nfunction isTextSelectionAcrossCells({ $from, $to }) {\n\tlet fromCellBoundaryNode;\n\tlet toCellBoundaryNode;\n\tfor (let i = $from.depth; i > 0; i--) {\n\t\tconst node = $from.node(i);\n\t\tif (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n\t\t\tfromCellBoundaryNode = node;\n\t\t\tbreak;\n\t\t}\n\t}\n\tfor (let i = $to.depth; i > 0; i--) {\n\t\tconst node = $to.node(i);\n\t\tif (node.type.spec.tableRole === \"cell\" || node.type.spec.tableRole === \"header_cell\") {\n\t\t\ttoCellBoundaryNode = node;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn fromCellBoundaryNode !== toCellBoundaryNode && $to.parentOffset === 0;\n}\nfunction normalizeSelection(state, tr, allowTableNodeSelection) {\n\tconst sel = (tr || state).selection;\n\tconst doc = (tr || state).doc;\n\tlet normalize;\n\tlet role;\n\tif (sel instanceof prosemirror_state.NodeSelection && (role = sel.node.type.spec.tableRole)) {\n\t\tif (role == \"cell\" || role == \"header_cell\") normalize = CellSelection.create(doc, sel.from);\n\t\telse if (role == \"row\") {\n\t\t\tconst $cell = doc.resolve(sel.from + 1);\n\t\t\tnormalize = CellSelection.rowSelection($cell, $cell);\n\t\t} else if (!allowTableNodeSelection) {\n\t\t\tconst map = TableMap.get(sel.node);\n\t\t\tconst start = sel.from + 1;\n\t\t\tconst lastCell = start + map.map[map.width * map.height - 1];\n\t\t\tnormalize = CellSelection.create(doc, start + 1, lastCell);\n\t\t}\n\t} else if (sel instanceof prosemirror_state.TextSelection && isCellBoundarySelection(sel)) normalize = prosemirror_state.TextSelection.create(doc, sel.from);\n\telse if (sel instanceof prosemirror_state.TextSelection && isTextSelectionAcrossCells(sel)) normalize = prosemirror_state.TextSelection.create(doc, sel.$from.start(), sel.$from.end());\n\tif (normalize) (tr || (tr = state.tr)).setSelection(normalize);\n\treturn tr;\n}\n\n//#endregion\n//#region src/fixtables.ts\n/**\n* @public\n*/\nconst fixTablesKey = new prosemirror_state.PluginKey(\"fix-tables\");\n/**\n* Helper for iterating through the nodes in a document that changed\n* compared to the given previous document. Useful for avoiding\n* duplicate work on each transaction.\n*\n* @public\n*/\nfunction changedDescendants(old, cur, offset, f) {\n\tconst oldSize = old.childCount, curSize = cur.childCount;\n\touter: for (let i = 0, j = 0; i < curSize; i++) {\n\t\tconst child = cur.child(i);\n\t\tfor (let scan = j, e = Math.min(oldSize, i + 3); scan < e; scan++) if (old.child(scan) == child) {\n\t\t\tj = scan + 1;\n\t\t\toffset += child.nodeSize;\n\t\t\tcontinue outer;\n\t\t}\n\t\tf(child, offset);\n\t\tif (j < oldSize && old.child(j).sameMarkup(child)) changedDescendants(old.child(j), child, offset + 1, f);\n\t\telse child.nodesBetween(0, child.content.size, f, offset + 1);\n\t\toffset += child.nodeSize;\n\t}\n}\n/**\n* Inspect all tables in the given state's document and return a\n* transaction that fixes them, if necessary. If `oldState` was\n* provided, that is assumed to hold a previous, known-good state,\n* which will be used to avoid re-scanning unchanged parts of the\n* document.\n*\n* @public\n*/\nfunction fixTables(state, oldState) {\n\tlet tr;\n\tconst check = (node, pos) => {\n\t\tif (node.type.spec.tableRole == \"table\") tr = fixTable(state, node, pos, tr);\n\t};\n\tif (!oldState) state.doc.descendants(check);\n\telse if (oldState.doc != state.doc) changedDescendants(oldState.doc, state.doc, 0, check);\n\treturn tr;\n}\nfunction fixTable(state, table, tablePos, tr) {\n\tconst map = TableMap.get(table);\n\tif (!map.problems) return tr;\n\tif (!tr) tr = state.tr;\n\tconst mustAdd = [];\n\tfor (let i = 0; i < map.height; i++) mustAdd.push(0);\n\tfor (let i = 0; i < map.problems.length; i++) {\n\t\tconst prob = map.problems[i];\n\t\tif (prob.type == \"collision\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\tconst attrs = cell.attrs;\n\t\t\tfor (let j = 0; j < attrs.rowspan; j++) mustAdd[prob.row + j] += prob.n;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, removeColSpan(attrs, attrs.colspan - prob.n, prob.n));\n\t\t} else if (prob.type == \"missing\") mustAdd[prob.row] += prob.n;\n\t\telse if (prob.type == \"overlong_rowspan\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: cell.attrs.rowspan - prob.n\n\t\t\t});\n\t\t} else if (prob.type == \"colwidth mismatch\") {\n\t\t\tconst cell = table.nodeAt(prob.pos);\n\t\t\tif (!cell) continue;\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tablePos + 1 + prob.pos), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\tcolwidth: prob.colwidth\n\t\t\t});\n\t\t} else if (prob.type == \"zero_sized\") {\n\t\t\tconst pos = tr.mapping.map(tablePos);\n\t\t\ttr.delete(pos, pos + table.nodeSize);\n\t\t}\n\t}\n\tlet first, last;\n\tfor (let i = 0; i < mustAdd.length; i++) if (mustAdd[i]) {\n\t\tif (first == null) first = i;\n\t\tlast = i;\n\t}\n\tfor (let i = 0, pos = tablePos + 1; i < map.height; i++) {\n\t\tconst row = table.child(i);\n\t\tconst end = pos + row.nodeSize;\n\t\tconst add = mustAdd[i];\n\t\tif (add > 0) {\n\t\t\tlet role = \"cell\";\n\t\t\tif (row.firstChild) role = row.firstChild.type.spec.tableRole;\n\t\t\tconst nodes = [];\n\t\t\tfor (let j = 0; j < add; j++) {\n\t\t\t\tconst node = tableNodeTypes(state.schema)[role].createAndFill();\n\t\t\t\tif (node) nodes.push(node);\n\t\t\t}\n\t\t\tconst side = (i == 0 || first == i - 1) && last == i ? pos + 1 : end - 1;\n\t\t\ttr.insert(tr.mapping.map(side), nodes);\n\t\t}\n\t\tpos = end;\n\t}\n\treturn tr.setMeta(fixTablesKey, { fixTables: true });\n}\n\n//#endregion\n//#region src/utils/convert.ts\n/**\n* This function will transform the table node into a matrix of rows and columns\n* respecting merged cells, for example this table:\n*\n* ```\n* ┌──────┬──────┬─────────────┐\n* │ A1 │ B1 │ C1 │\n* ├──────┼──────┴──────┬──────┤\n* │ A2 │ B2 │ │\n* ├──────┼─────────────┤ D1 │\n* │ A3 │ B3 │ C3 │ │\n* └──────┴──────┴──────┴──────┘\n* ```\n*\n* will be converted to the below:\n*\n* ```javascript\n* [\n* [A1, B1, C1, null],\n* [A2, B2, null, D1],\n* [A3, B3, C3, null],\n* ]\n* ```\n* @internal\n*/\nfunction convertTableNodeToArrayOfRows(tableNode) {\n\tconst map = TableMap.get(tableNode);\n\tconst rows = [];\n\tconst rowCount = map.height;\n\tconst colCount$1 = map.width;\n\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\tconst row = [];\n\t\tfor (let colIndex = 0; colIndex < colCount$1; colIndex++) {\n\t\t\tconst cellIndex = rowIndex * colCount$1 + colIndex;\n\t\t\tconst cellPos = map.map[cellIndex];\n\t\t\tif (rowIndex > 0) {\n\t\t\t\tconst topCellIndex = cellIndex - colCount$1;\n\t\t\t\tif (cellPos === map.map[topCellIndex]) {\n\t\t\t\t\trow.push(null);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (colIndex > 0) {\n\t\t\t\tconst leftCellIndex = cellIndex - 1;\n\t\t\t\tif (cellPos === map.map[leftCellIndex]) {\n\t\t\t\t\trow.push(null);\n\t\t\t\t\tcontinue;\n\t\t\t\t}\n\t\t\t}\n\t\t\trow.push(tableNode.nodeAt(cellPos));\n\t\t}\n\t\trows.push(row);\n\t}\n\treturn rows;\n}\n/**\n* Convert an array of rows to a table node.\n*\n* @internal\n*/\nfunction convertArrayOfRowsToTableNode(tableNode, arrayOfNodes) {\n\tconst newRows = [];\n\tconst map = TableMap.get(tableNode);\n\tconst rowCount = map.height;\n\tconst colCount$1 = map.width;\n\tfor (let rowIndex = 0; rowIndex < rowCount; rowIndex++) {\n\t\tconst oldRow = tableNode.child(rowIndex);\n\t\tconst newCells = [];\n\t\tfor (let colIndex = 0; colIndex < colCount$1; colIndex++) {\n\t\t\tconst cell = arrayOfNodes[rowIndex][colIndex];\n\t\t\tif (!cell) continue;\n\t\t\tconst cellPos = map.map[rowIndex * map.width + colIndex];\n\t\t\tconst oldCell = tableNode.nodeAt(cellPos);\n\t\t\tif (!oldCell) continue;\n\t\t\tconst newCell = oldCell.type.createChecked(cell.attrs, cell.content, cell.marks);\n\t\t\tnewCells.push(newCell);\n\t\t}\n\t\tconst newRow = oldRow.type.createChecked(oldRow.attrs, newCells, oldRow.marks);\n\t\tnewRows.push(newRow);\n\t}\n\treturn tableNode.type.createChecked(tableNode.attrs, newRows, tableNode.marks);\n}\n\n//#endregion\n//#region src/utils/move-row-in-array-of-rows.ts\n/**\n* Move a row in an array of rows.\n*\n* @internal\n*/\nfunction moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, directionOverride) {\n\tconst direction = indexesOrigin[0] > indexesTarget[0] ? -1 : 1;\n\tconst rowsExtracted = rows.splice(indexesOrigin[0], indexesOrigin.length);\n\tconst positionOffset = rowsExtracted.length % 2 === 0 ? 1 : 0;\n\tlet target;\n\tif (directionOverride === -1 && direction === 1) target = indexesTarget[0] - 1;\n\telse if (directionOverride === 1 && direction === -1) target = indexesTarget[indexesTarget.length - 1] - positionOffset + 1;\n\telse target = direction === -1 ? indexesTarget[0] : indexesTarget[indexesTarget.length - 1] - positionOffset;\n\trows.splice(target, 0, ...rowsExtracted);\n\treturn rows;\n}\n\n//#endregion\n//#region src/utils/query.ts\n/**\n* Checks if the given object is a `CellSelection` instance.\n*\n* @internal\n*/\nfunction isCellSelection(value) {\n\treturn value instanceof CellSelection;\n}\n/**\n* Find the closest table node for a given position.\n*\n* @public\n*/\nfunction findTable($pos) {\n\treturn findParentNode((node) => node.type.spec.tableRole === \"table\", $pos);\n}\n/**\n* Try to find the anchor and head cell in the same table by using the given\n* anchor and head as hit points, or fallback to the selection's anchor and\n* head.\n*\n* @public\n*/\nfunction findCellRange(selection, anchorHit, headHit) {\n\tvar _ref, _ref2;\n\tif (anchorHit == null && headHit == null && isCellSelection(selection)) return [selection.$anchorCell, selection.$headCell];\n\tconst anchor = (_ref = anchorHit !== null && anchorHit !== void 0 ? anchorHit : headHit) !== null && _ref !== void 0 ? _ref : selection.anchor;\n\tconst head = (_ref2 = headHit !== null && headHit !== void 0 ? headHit : anchorHit) !== null && _ref2 !== void 0 ? _ref2 : selection.head;\n\tconst doc = selection.$head.doc;\n\tconst $anchorCell = findCellPos(doc, anchor);\n\tconst $headCell = findCellPos(doc, head);\n\tif ($anchorCell && $headCell && inSameTable($anchorCell, $headCell)) return [$anchorCell, $headCell];\n\treturn null;\n}\n/**\n* Try to find a resolved pos of a cell by using the given pos as a hit point.\n*\n* @public\n*/\nfunction findCellPos(doc, pos) {\n\tconst $pos = doc.resolve(pos);\n\treturn cellAround($pos) || cellNear($pos);\n}\n/**\n* Find the closest parent node that satisfies the predicate.\n*\n* @internal\n*/\nfunction findParentNode(predicate, $pos) {\n\tfor (let depth = $pos.depth; depth >= 0; depth -= 1) {\n\t\tconst node = $pos.node(depth);\n\t\tif (predicate(node)) return {\n\t\t\tnode,\n\t\t\tpos: depth === 0 ? 0 : $pos.before(depth),\n\t\t\tstart: $pos.start(depth),\n\t\t\tdepth\n\t\t};\n\t}\n\treturn null;\n}\n\n//#endregion\n//#region src/utils/get-cells.ts\n/**\n* Returns an array of cells in a column at the specified column index.\n*\n* @internal\n*/\nfunction getCellsInColumn(columnIndex, selection) {\n\tconst table = findTable(selection.$from);\n\tif (!table) return;\n\tconst map = TableMap.get(table.node);\n\tif (columnIndex < 0 || columnIndex > map.width - 1) return;\n\treturn map.cellsInRect({\n\t\tleft: columnIndex,\n\t\tright: columnIndex + 1,\n\t\ttop: 0,\n\t\tbottom: map.height\n\t}).map((nodePos) => {\n\t\tconst node = table.node.nodeAt(nodePos);\n\t\tconst pos = nodePos + table.start;\n\t\treturn {\n\t\t\tpos,\n\t\t\tstart: pos + 1,\n\t\t\tnode,\n\t\t\tdepth: table.depth + 2\n\t\t};\n\t});\n}\n/**\n* Returns an array of cells in a row at the specified row index.\n*\n* @internal\n*/\nfunction getCellsInRow(rowIndex, selection) {\n\tconst table = findTable(selection.$from);\n\tif (!table) return;\n\tconst map = TableMap.get(table.node);\n\tif (rowIndex < 0 || rowIndex > map.height - 1) return;\n\treturn map.cellsInRect({\n\t\tleft: 0,\n\t\tright: map.width,\n\t\ttop: rowIndex,\n\t\tbottom: rowIndex + 1\n\t}).map((nodePos) => {\n\t\tconst node = table.node.nodeAt(nodePos);\n\t\tconst pos = nodePos + table.start;\n\t\treturn {\n\t\t\tpos,\n\t\t\tstart: pos + 1,\n\t\t\tnode,\n\t\t\tdepth: table.depth + 2\n\t\t};\n\t});\n}\n\n//#endregion\n//#region src/utils/selection-range.ts\n/**\n* Returns a range of rectangular selection spanning all merged cells around a\n* column at index `columnIndex`.\n*\n* Original implementation from Atlassian (Apache License 2.0)\n*\n* https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-column.ts#editor/editor-tables/src/utils/get-selection-range-in-column.ts\n*\n* @internal\n*/\nfunction getSelectionRangeInColumn(tr, startColIndex, endColIndex = startColIndex) {\n\tlet startIndex = startColIndex;\n\tlet endIndex = endColIndex;\n\tfor (let i = startColIndex; i >= 0; i--) {\n\t\tconst cells = getCellsInColumn(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.colspan + i - 1;\n\t\t\tif (maybeEndIndex >= startIndex) startIndex = i;\n\t\t\tif (maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tfor (let i = startColIndex; i <= endIndex; i++) {\n\t\tconst cells = getCellsInColumn(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.colspan + i - 1;\n\t\t\tif (cell.node.attrs.colspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tconst indexes = [];\n\tfor (let i = startIndex; i <= endIndex; i++) {\n\t\tconst maybeCells = getCellsInColumn(i, tr.selection);\n\t\tif (maybeCells && maybeCells.length > 0) indexes.push(i);\n\t}\n\tstartIndex = indexes[0];\n\tendIndex = indexes[indexes.length - 1];\n\tconst firstSelectedColumnCells = getCellsInColumn(startIndex, tr.selection);\n\tconst firstRowCells = getCellsInRow(0, tr.selection);\n\tif (!firstSelectedColumnCells || !firstRowCells) return;\n\tconst $anchor = tr.doc.resolve(firstSelectedColumnCells[firstSelectedColumnCells.length - 1].pos);\n\tlet headCell;\n\tfor (let i = endIndex; i >= startIndex; i--) {\n\t\tconst columnCells = getCellsInColumn(i, tr.selection);\n\t\tif (columnCells && columnCells.length > 0) {\n\t\t\tfor (let j = firstRowCells.length - 1; j >= 0; j--) if (firstRowCells[j].pos === columnCells[0].pos) {\n\t\t\t\theadCell = columnCells[0];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (headCell) break;\n\t\t}\n\t}\n\tif (!headCell) return;\n\treturn {\n\t\t$anchor,\n\t\t$head: tr.doc.resolve(headCell.pos),\n\t\tindexes\n\t};\n}\n/**\n* Returns a range of rectangular selection spanning all merged cells around a\n* row at index `rowIndex`.\n*\n* Original implementation from Atlassian (Apache License 2.0)\n*\n* https://bitbucket.org/atlassian/atlassian-frontend-mirror/src/5f91cb871e8248bc3bae5ddc30bb9fd9200fadbb/editor/editor-tables/src/utils/get-selection-range-in-row.ts#editor/editor-tables/src/utils/get-selection-range-in-row.ts\n*\n* @internal\n*/\nfunction getSelectionRangeInRow(tr, startRowIndex, endRowIndex = startRowIndex) {\n\tlet startIndex = startRowIndex;\n\tlet endIndex = endRowIndex;\n\tfor (let i = startRowIndex; i >= 0; i--) {\n\t\tconst cells = getCellsInRow(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.rowspan + i - 1;\n\t\t\tif (maybeEndIndex >= startIndex) startIndex = i;\n\t\t\tif (maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tfor (let i = startRowIndex; i <= endIndex; i++) {\n\t\tconst cells = getCellsInRow(i, tr.selection);\n\t\tif (cells) cells.forEach((cell) => {\n\t\t\tconst maybeEndIndex = cell.node.attrs.rowspan + i - 1;\n\t\t\tif (cell.node.attrs.rowspan > 1 && maybeEndIndex > endIndex) endIndex = maybeEndIndex;\n\t\t});\n\t}\n\tconst indexes = [];\n\tfor (let i = startIndex; i <= endIndex; i++) {\n\t\tconst maybeCells = getCellsInRow(i, tr.selection);\n\t\tif (maybeCells && maybeCells.length > 0) indexes.push(i);\n\t}\n\tstartIndex = indexes[0];\n\tendIndex = indexes[indexes.length - 1];\n\tconst firstSelectedRowCells = getCellsInRow(startIndex, tr.selection);\n\tconst firstColumnCells = getCellsInColumn(0, tr.selection);\n\tif (!firstSelectedRowCells || !firstColumnCells) return;\n\tconst $anchor = tr.doc.resolve(firstSelectedRowCells[firstSelectedRowCells.length - 1].pos);\n\tlet headCell;\n\tfor (let i = endIndex; i >= startIndex; i--) {\n\t\tconst rowCells = getCellsInRow(i, tr.selection);\n\t\tif (rowCells && rowCells.length > 0) {\n\t\t\tfor (let j = firstColumnCells.length - 1; j >= 0; j--) if (firstColumnCells[j].pos === rowCells[0].pos) {\n\t\t\t\theadCell = rowCells[0];\n\t\t\t\tbreak;\n\t\t\t}\n\t\t\tif (headCell) break;\n\t\t}\n\t}\n\tif (!headCell) return;\n\treturn {\n\t\t$anchor,\n\t\t$head: tr.doc.resolve(headCell.pos),\n\t\tindexes\n\t};\n}\n\n//#endregion\n//#region src/utils/transpose.ts\n/**\n* Transposes a 2D array by flipping columns to rows.\n*\n* Transposition is a familiar algebra concept where the matrix is flipped\n* along its diagonal. For more details, see:\n* https://en.wikipedia.org/wiki/Transpose\n*\n* @example\n* ```javascript\n* const arr = [\n* ['a1', 'a2', 'a3'],\n* ['b1', 'b2', 'b3'],\n* ['c1', 'c2', 'c3'],\n* ['d1', 'd2', 'd3'],\n* ];\n*\n* const result = transpose(arr);\n* result === [\n* ['a1', 'b1', 'c1', 'd1'],\n* ['a2', 'b2', 'c2', 'd2'],\n* ['a3', 'b3', 'c3', 'd3'],\n* ]\n* ```\n*/\nfunction transpose(array) {\n\treturn array[0].map((_, i) => {\n\t\treturn array.map((column) => column[i]);\n\t});\n}\n\n//#endregion\n//#region src/utils/move-column.ts\n/**\n* Move a column from index `origin` to index `target`.\n*\n* @internal\n*/\nfunction moveColumn(moveColParams) {\n\tvar _getSelectionRangeInC, _getSelectionRangeInC2;\n\tconst { tr, originIndex, targetIndex, select, pos } = moveColParams;\n\tconst table = findTable(tr.doc.resolve(pos));\n\tif (!table) return false;\n\tconst indexesOriginColumn = (_getSelectionRangeInC = getSelectionRangeInColumn(tr, originIndex)) === null || _getSelectionRangeInC === void 0 ? void 0 : _getSelectionRangeInC.indexes;\n\tconst indexesTargetColumn = (_getSelectionRangeInC2 = getSelectionRangeInColumn(tr, targetIndex)) === null || _getSelectionRangeInC2 === void 0 ? void 0 : _getSelectionRangeInC2.indexes;\n\tif (!indexesOriginColumn || !indexesTargetColumn) return false;\n\tif (indexesOriginColumn.includes(targetIndex)) return false;\n\tconst newTable = moveTableColumn$1(table.node, indexesOriginColumn, indexesTargetColumn, 0);\n\ttr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);\n\tif (!select) return true;\n\tconst map = TableMap.get(newTable);\n\tconst start = table.start;\n\tconst index = targetIndex;\n\tconst lastCell = map.positionAt(map.height - 1, index, newTable);\n\tconst $lastCell = tr.doc.resolve(start + lastCell);\n\tconst firstCell = map.positionAt(0, index, newTable);\n\tconst $firstCell = tr.doc.resolve(start + firstCell);\n\ttr.setSelection(CellSelection.colSelection($lastCell, $firstCell));\n\treturn true;\n}\nfunction moveTableColumn$1(table, indexesOrigin, indexesTarget, direction) {\n\tlet rows = transpose(convertTableNodeToArrayOfRows(table));\n\trows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);\n\trows = transpose(rows);\n\treturn convertArrayOfRowsToTableNode(table, rows);\n}\n\n//#endregion\n//#region src/utils/move-row.ts\n/**\n* Move a row from index `origin` to index `target`.\n*\n* @internal\n*/\nfunction moveRow(moveRowParams) {\n\tvar _getSelectionRangeInR, _getSelectionRangeInR2;\n\tconst { tr, originIndex, targetIndex, select, pos } = moveRowParams;\n\tconst table = findTable(tr.doc.resolve(pos));\n\tif (!table) return false;\n\tconst indexesOriginRow = (_getSelectionRangeInR = getSelectionRangeInRow(tr, originIndex)) === null || _getSelectionRangeInR === void 0 ? void 0 : _getSelectionRangeInR.indexes;\n\tconst indexesTargetRow = (_getSelectionRangeInR2 = getSelectionRangeInRow(tr, targetIndex)) === null || _getSelectionRangeInR2 === void 0 ? void 0 : _getSelectionRangeInR2.indexes;\n\tif (!indexesOriginRow || !indexesTargetRow) return false;\n\tif (indexesOriginRow.includes(targetIndex)) return false;\n\tconst newTable = moveTableRow$1(table.node, indexesOriginRow, indexesTargetRow, 0);\n\ttr.replaceWith(table.pos, table.pos + table.node.nodeSize, newTable);\n\tif (!select) return true;\n\tconst map = TableMap.get(newTable);\n\tconst start = table.start;\n\tconst index = targetIndex;\n\tconst lastCell = map.positionAt(index, map.width - 1, newTable);\n\tconst $lastCell = tr.doc.resolve(start + lastCell);\n\tconst firstCell = map.positionAt(index, 0, newTable);\n\tconst $firstCell = tr.doc.resolve(start + firstCell);\n\ttr.setSelection(CellSelection.rowSelection($lastCell, $firstCell));\n\treturn true;\n}\nfunction moveTableRow$1(table, indexesOrigin, indexesTarget, direction) {\n\tlet rows = convertTableNodeToArrayOfRows(table);\n\trows = moveRowInArrayOfRows(rows, indexesOrigin, indexesTarget, direction);\n\treturn convertArrayOfRowsToTableNode(table, rows);\n}\n\n//#endregion\n//#region src/commands.ts\n/**\n* Helper to get the selected rectangle in a table, if any. Adds table\n* map, table node, and table start offset to the object for\n* convenience.\n*\n* @public\n*/\nfunction selectedRect(state) {\n\tconst sel = state.selection;\n\tconst $pos = selectionCell(state);\n\tconst table = $pos.node(-1);\n\tconst tableStart = $pos.start(-1);\n\tconst map = TableMap.get(table);\n\treturn {\n\t\t...sel instanceof CellSelection ? map.rectBetween(sel.$anchorCell.pos - tableStart, sel.$headCell.pos - tableStart) : map.findCell($pos.pos - tableStart),\n\t\ttableStart,\n\t\tmap,\n\t\ttable\n\t};\n}\n/**\n* Add a column at the given position in a table.\n*\n* @public\n*/\nfunction addColumn(tr, { map, tableStart, table }, col) {\n\tlet refColumn = col > 0 ? -1 : 0;\n\tif (columnIsHeader(map, table, col + refColumn)) refColumn = col == 0 || col == map.width ? null : 0;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst index = row * map.width + col;\n\t\tif (col > 0 && col < map.width && map.map[index - 1] == map.map[index]) {\n\t\t\tconst pos = map.map[index];\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\ttr.setNodeMarkup(tr.mapping.map(tableStart + pos), null, addColSpan(cell.attrs, col - map.colCount(pos)));\n\t\t\trow += cell.attrs.rowspan - 1;\n\t\t} else {\n\t\t\tconst type = refColumn == null ? tableNodeTypes(table.type.schema).cell : table.nodeAt(map.map[index + refColumn]).type;\n\t\t\tconst pos = map.positionAt(row, col, table);\n\t\t\ttr.insert(tr.mapping.map(tableStart + pos), type.createAndFill());\n\t\t}\n\t}\n\treturn tr;\n}\n/**\n* Command to add a column before the column with the selection.\n*\n* @public\n*/\nfunction addColumnBefore(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addColumn(state.tr, rect, rect.left));\n\t}\n\treturn true;\n}\n/**\n* Command to add a column after the column with the selection.\n*\n* @public\n*/\nfunction addColumnAfter(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addColumn(state.tr, rect, rect.right));\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction removeColumn(tr, { map, table, tableStart }, col) {\n\tconst mapStart = tr.mapping.maps.length;\n\tfor (let row = 0; row < map.height;) {\n\t\tconst index = row * map.width + col;\n\t\tconst pos = map.map[index];\n\t\tconst cell = table.nodeAt(pos);\n\t\tconst attrs = cell.attrs;\n\t\tif (col > 0 && map.map[index - 1] == pos || col < map.width - 1 && map.map[index + 1] == pos) tr.setNodeMarkup(tr.mapping.slice(mapStart).map(tableStart + pos), null, removeColSpan(attrs, col - map.colCount(pos)));\n\t\telse {\n\t\t\tconst start = tr.mapping.slice(mapStart).map(tableStart + pos);\n\t\t\ttr.delete(start, start + cell.nodeSize);\n\t\t}\n\t\trow += attrs.rowspan;\n\t}\n}\n/**\n* Command function that removes the selected columns from a table.\n*\n* @public\n*/\nfunction deleteColumn(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tconst tr = state.tr;\n\t\tif (rect.left == 0 && rect.right == rect.map.width) return false;\n\t\tfor (let i = rect.right - 1;; i--) {\n\t\t\tremoveColumn(tr, rect, i);\n\t\t\tif (i == rect.left) break;\n\t\t\tconst table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n\t\t\tif (!table) throw new RangeError(\"No table found\");\n\t\t\trect.table = table;\n\t\t\trect.map = TableMap.get(table);\n\t\t}\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction rowIsHeader(map, table, row) {\n\tvar _table$nodeAt;\n\tconst headerCell = tableNodeTypes(table.type.schema).header_cell;\n\tfor (let col = 0; col < map.width; col++) if (((_table$nodeAt = table.nodeAt(map.map[col + row * map.width])) === null || _table$nodeAt === void 0 ? void 0 : _table$nodeAt.type) != headerCell) return false;\n\treturn true;\n}\n/**\n* @public\n*/\nfunction addRow(tr, { map, tableStart, table }, row) {\n\tlet rowPos = tableStart;\n\tfor (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;\n\tconst cells = [];\n\tlet refRow = row > 0 ? -1 : 0;\n\tif (rowIsHeader(map, table, row + refRow)) refRow = row == 0 || row == map.height ? null : 0;\n\tfor (let col = 0, index = map.width * row; col < map.width; col++, index++) if (row > 0 && row < map.height && map.map[index] == map.map[index - map.width]) {\n\t\tconst pos = map.map[index];\n\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\ttr.setNodeMarkup(tableStart + pos, null, {\n\t\t\t...attrs,\n\t\t\trowspan: attrs.rowspan + 1\n\t\t});\n\t\tcol += attrs.colspan - 1;\n\t} else {\n\t\tvar _table$nodeAt2;\n\t\tconst type = refRow == null ? tableNodeTypes(table.type.schema).cell : (_table$nodeAt2 = table.nodeAt(map.map[index + refRow * map.width])) === null || _table$nodeAt2 === void 0 ? void 0 : _table$nodeAt2.type;\n\t\tconst node = type === null || type === void 0 ? void 0 : type.createAndFill();\n\t\tif (node) cells.push(node);\n\t}\n\ttr.insert(rowPos, tableNodeTypes(table.type.schema).row.create(null, cells));\n\treturn tr;\n}\n/**\n* Add a table row before the selection.\n*\n* @public\n*/\nfunction addRowBefore(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addRow(state.tr, rect, rect.top));\n\t}\n\treturn true;\n}\n/**\n* Add a table row after the selection.\n*\n* @public\n*/\nfunction addRowAfter(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state);\n\t\tdispatch(addRow(state.tr, rect, rect.bottom));\n\t}\n\treturn true;\n}\n/**\n* @public\n*/\nfunction removeRow(tr, { map, table, tableStart }, row) {\n\tlet rowPos = 0;\n\tfor (let i = 0; i < row; i++) rowPos += table.child(i).nodeSize;\n\tconst nextRow = rowPos + table.child(row).nodeSize;\n\tconst mapFrom = tr.mapping.maps.length;\n\ttr.delete(rowPos + tableStart, nextRow + tableStart);\n\tconst seen = /* @__PURE__ */ new Set();\n\tfor (let col = 0, index = row * map.width; col < map.width; col++, index++) {\n\t\tconst pos = map.map[index];\n\t\tif (seen.has(pos)) continue;\n\t\tseen.add(pos);\n\t\tif (row > 0 && pos == map.map[index - map.width]) {\n\t\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\t\ttr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + tableStart), null, {\n\t\t\t\t...attrs,\n\t\t\t\trowspan: attrs.rowspan - 1\n\t\t\t});\n\t\t\tcol += attrs.colspan - 1;\n\t\t} else if (row < map.height && pos == map.map[index + map.width]) {\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst attrs = cell.attrs;\n\t\t\tconst copy = cell.type.create({\n\t\t\t\t...attrs,\n\t\t\t\trowspan: cell.attrs.rowspan - 1\n\t\t\t}, cell.content);\n\t\t\tconst newPos = map.positionAt(row + 1, col, table);\n\t\t\ttr.insert(tr.mapping.slice(mapFrom).map(tableStart + newPos), copy);\n\t\t\tcol += attrs.colspan - 1;\n\t\t}\n\t}\n}\n/**\n* Remove the selected rows from a table.\n*\n* @public\n*/\nfunction deleteRow(state, dispatch) {\n\tif (!isInTable(state)) return false;\n\tif (dispatch) {\n\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\tif (rect.top == 0 && rect.bottom == rect.map.height) return false;\n\t\tfor (let i = rect.bottom - 1;; i--) {\n\t\t\tremoveRow(tr, rect, i);\n\t\t\tif (i == rect.top) break;\n\t\t\tconst table = rect.tableStart ? tr.doc.nodeAt(rect.tableStart - 1) : tr.doc;\n\t\t\tif (!table) throw new RangeError(\"No table found\");\n\t\t\trect.table = table;\n\t\t\trect.map = TableMap.get(rect.table);\n\t\t}\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\nfunction isEmpty(cell) {\n\tconst c = cell.content;\n\treturn c.childCount == 1 && c.child(0).isTextblock && c.child(0).childCount == 0;\n}\nfunction cellsOverlapRectangle({ width, height, map }, rect) {\n\tlet indexTop = rect.top * width + rect.left, indexLeft = indexTop;\n\tlet indexBottom = (rect.bottom - 1) * width + rect.left, indexRight = indexTop + (rect.right - rect.left - 1);\n\tfor (let i = rect.top; i < rect.bottom; i++) {\n\t\tif (rect.left > 0 && map[indexLeft] == map[indexLeft - 1] || rect.right < width && map[indexRight] == map[indexRight + 1]) return true;\n\t\tindexLeft += width;\n\t\tindexRight += width;\n\t}\n\tfor (let i = rect.left; i < rect.right; i++) {\n\t\tif (rect.top > 0 && map[indexTop] == map[indexTop - width] || rect.bottom < height && map[indexBottom] == map[indexBottom + width]) return true;\n\t\tindexTop++;\n\t\tindexBottom++;\n\t}\n\treturn false;\n}\n/**\n* Merge the selected cells into a single cell. Only available when\n* the selected cells' outline forms a rectangle.\n*\n* @public\n*/\nfunction mergeCells(state, dispatch) {\n\tconst sel = state.selection;\n\tif (!(sel instanceof CellSelection) || sel.$anchorCell.pos == sel.$headCell.pos) return false;\n\tconst rect = selectedRect(state), { map } = rect;\n\tif (cellsOverlapRectangle(map, rect)) return false;\n\tif (dispatch) {\n\t\tconst tr = state.tr;\n\t\tconst seen = {};\n\t\tlet content = prosemirror_model.Fragment.empty;\n\t\tlet mergedPos;\n\t\tlet mergedCell;\n\t\tfor (let row = rect.top; row < rect.bottom; row++) for (let col = rect.left; col < rect.right; col++) {\n\t\t\tconst cellPos = map.map[row * map.width + col];\n\t\t\tconst cell = rect.table.nodeAt(cellPos);\n\t\t\tif (seen[cellPos] || !cell) continue;\n\t\t\tseen[cellPos] = true;\n\t\t\tif (mergedPos == null) {\n\t\t\t\tmergedPos = cellPos;\n\t\t\t\tmergedCell = cell;\n\t\t\t} else {\n\t\t\t\tif (!isEmpty(cell)) content = content.append(cell.content);\n\t\t\t\tconst mapped = tr.mapping.map(cellPos + rect.tableStart);\n\t\t\t\ttr.delete(mapped, mapped + cell.nodeSize);\n\t\t\t}\n\t\t}\n\t\tif (mergedPos == null || mergedCell == null) return true;\n\t\ttr.setNodeMarkup(mergedPos + rect.tableStart, null, {\n\t\t\t...addColSpan(mergedCell.attrs, mergedCell.attrs.colspan, rect.right - rect.left - mergedCell.attrs.colspan),\n\t\t\trowspan: rect.bottom - rect.top\n\t\t});\n\t\tif (content.size > 0) {\n\t\t\tconst end = mergedPos + 1 + mergedCell.content.size;\n\t\t\tconst start = isEmpty(mergedCell) ? mergedPos + 1 : end;\n\t\t\ttr.replaceWith(start + rect.tableStart, end + rect.tableStart, content);\n\t\t}\n\t\ttr.setSelection(new CellSelection(tr.doc.resolve(mergedPos + rect.tableStart)));\n\t\tdispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* Split a selected cell, whose rowpan or colspan is greater than one,\n* into smaller cells. Use the first cell type for the new cells.\n*\n* @public\n*/\nfunction splitCell(state, dispatch) {\n\tconst nodeTypes = tableNodeTypes(state.schema);\n\treturn splitCellWithType(({ node }) => {\n\t\treturn nodeTypes[node.type.spec.tableRole];\n\t})(state, dispatch);\n}\n/**\n* Split a selected cell, whose rowpan or colspan is greater than one,\n* into smaller cells with the cell type (th, td) returned by getType function.\n*\n* @public\n*/\nfunction splitCellWithType(getCellType) {\n\treturn (state, dispatch) => {\n\t\tconst sel = state.selection;\n\t\tlet cellNode;\n\t\tlet cellPos;\n\t\tif (!(sel instanceof CellSelection)) {\n\t\t\tvar _cellAround;\n\t\t\tcellNode = cellWrapping(sel.$from);\n\t\t\tif (!cellNode) return false;\n\t\t\tcellPos = (_cellAround = cellAround(sel.$from)) === null || _cellAround === void 0 ? void 0 : _cellAround.pos;\n\t\t} else {\n\t\t\tif (sel.$anchorCell.pos != sel.$headCell.pos) return false;\n\t\t\tcellNode = sel.$anchorCell.nodeAfter;\n\t\t\tcellPos = sel.$anchorCell.pos;\n\t\t}\n\t\tif (cellNode == null || cellPos == null) return false;\n\t\tif (cellNode.attrs.colspan == 1 && cellNode.attrs.rowspan == 1) return false;\n\t\tif (dispatch) {\n\t\t\tlet baseAttrs = cellNode.attrs;\n\t\t\tconst attrs = [];\n\t\t\tconst colwidth = baseAttrs.colwidth;\n\t\t\tif (baseAttrs.rowspan > 1) baseAttrs = {\n\t\t\t\t...baseAttrs,\n\t\t\t\trowspan: 1\n\t\t\t};\n\t\t\tif (baseAttrs.colspan > 1) baseAttrs = {\n\t\t\t\t...baseAttrs,\n\t\t\t\tcolspan: 1\n\t\t\t};\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tfor (let i = 0; i < rect.right - rect.left; i++) attrs.push(colwidth ? {\n\t\t\t\t...baseAttrs,\n\t\t\t\tcolwidth: colwidth && colwidth[i] ? [colwidth[i]] : null\n\t\t\t} : baseAttrs);\n\t\t\tlet lastCell;\n\t\t\tfor (let row = rect.top; row < rect.bottom; row++) {\n\t\t\t\tlet pos = rect.map.positionAt(row, rect.left, rect.table);\n\t\t\t\tif (row == rect.top) pos += cellNode.nodeSize;\n\t\t\t\tfor (let col = rect.left, i = 0; col < rect.right; col++, i++) {\n\t\t\t\t\tif (col == rect.left && row == rect.top) continue;\n\t\t\t\t\ttr.insert(lastCell = tr.mapping.map(pos + rect.tableStart, 1), getCellType({\n\t\t\t\t\t\tnode: cellNode,\n\t\t\t\t\t\trow,\n\t\t\t\t\t\tcol\n\t\t\t\t\t}).createAndFill(attrs[i]));\n\t\t\t\t}\n\t\t\t}\n\t\t\ttr.setNodeMarkup(cellPos, getCellType({\n\t\t\t\tnode: cellNode,\n\t\t\t\trow: rect.top,\n\t\t\t\tcol: rect.left\n\t\t\t}), attrs[0]);\n\t\t\tif (sel instanceof CellSelection) tr.setSelection(new CellSelection(tr.doc.resolve(sel.$anchorCell.pos), lastCell ? tr.doc.resolve(lastCell) : void 0));\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Returns a command that sets the given attribute to the given value,\n* and is only available when the currently selected cell doesn't\n* already have that attribute set to that value.\n*\n* @public\n*/\nfunction setCellAttr(name, value) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tconst $cell = selectionCell(state);\n\t\tif ($cell.nodeAfter.attrs[name] === value) return false;\n\t\tif (dispatch) {\n\t\t\tconst tr = state.tr;\n\t\t\tif (state.selection instanceof CellSelection) state.selection.forEachCell((node, pos) => {\n\t\t\t\tif (node.attrs[name] !== value) tr.setNodeMarkup(pos, null, {\n\t\t\t\t\t...node.attrs,\n\t\t\t\t\t[name]: value\n\t\t\t\t});\n\t\t\t});\n\t\t\telse tr.setNodeMarkup($cell.pos, null, {\n\t\t\t\t...$cell.nodeAfter.attrs,\n\t\t\t\t[name]: value\n\t\t\t});\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\nfunction deprecated_toggleHeader(type) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tif (dispatch) {\n\t\t\tconst types = tableNodeTypes(state.schema);\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tconst cells = rect.map.cellsInRect(type == \"column\" ? {\n\t\t\t\tleft: rect.left,\n\t\t\t\ttop: 0,\n\t\t\t\tright: rect.right,\n\t\t\t\tbottom: rect.map.height\n\t\t\t} : type == \"row\" ? {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: rect.top,\n\t\t\t\tright: rect.map.width,\n\t\t\t\tbottom: rect.bottom\n\t\t\t} : rect);\n\t\t\tconst nodes = cells.map((pos) => rect.table.nodeAt(pos));\n\t\t\tfor (let i = 0; i < cells.length; i++) if (nodes[i].type == types.header_cell) tr.setNodeMarkup(rect.tableStart + cells[i], types.cell, nodes[i].attrs);\n\t\t\tif (tr.steps.length === 0) for (let i = 0; i < cells.length; i++) tr.setNodeMarkup(rect.tableStart + cells[i], types.header_cell, nodes[i].attrs);\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\nfunction isHeaderEnabledByType(type, rect, types) {\n\tconst cellPositions = rect.map.cellsInRect({\n\t\tleft: 0,\n\t\ttop: 0,\n\t\tright: type == \"row\" ? rect.map.width : 1,\n\t\tbottom: type == \"column\" ? rect.map.height : 1\n\t});\n\tfor (let i = 0; i < cellPositions.length; i++) {\n\t\tconst cell = rect.table.nodeAt(cellPositions[i]);\n\t\tif (cell && cell.type !== types.header_cell) return false;\n\t}\n\treturn true;\n}\n/**\n* Toggles between row/column header and normal cells (Only applies to first row/column).\n* For deprecated behavior pass `useDeprecatedLogic` in options with true.\n*\n* @public\n*/\nfunction toggleHeader(type, options) {\n\toptions = options || { useDeprecatedLogic: false };\n\tif (options.useDeprecatedLogic) return deprecated_toggleHeader(type);\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tif (dispatch) {\n\t\t\tconst types = tableNodeTypes(state.schema);\n\t\t\tconst rect = selectedRect(state), tr = state.tr;\n\t\t\tconst isHeaderRowEnabled = isHeaderEnabledByType(\"row\", rect, types);\n\t\t\tconst isHeaderColumnEnabled = isHeaderEnabledByType(\"column\", rect, types);\n\t\t\tconst selectionStartsAt = (type === \"column\" ? isHeaderRowEnabled : type === \"row\" ? isHeaderColumnEnabled : false) ? 1 : 0;\n\t\t\tconst cellsRect = type == \"column\" ? {\n\t\t\t\tleft: 0,\n\t\t\t\ttop: selectionStartsAt,\n\t\t\t\tright: 1,\n\t\t\t\tbottom: rect.map.height\n\t\t\t} : type == \"row\" ? {\n\t\t\t\tleft: selectionStartsAt,\n\t\t\t\ttop: 0,\n\t\t\t\tright: rect.map.width,\n\t\t\t\tbottom: 1\n\t\t\t} : rect;\n\t\t\tconst newType = type == \"column\" ? isHeaderColumnEnabled ? types.cell : types.header_cell : type == \"row\" ? isHeaderRowEnabled ? types.cell : types.header_cell : types.cell;\n\t\t\trect.map.cellsInRect(cellsRect).forEach((relativeCellPos) => {\n\t\t\t\tconst cellPos = relativeCellPos + rect.tableStart;\n\t\t\t\tconst cell = tr.doc.nodeAt(cellPos);\n\t\t\t\tif (cell) tr.setNodeMarkup(cellPos, newType, cell.attrs);\n\t\t\t});\n\t\t\tdispatch(tr);\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Toggles whether the selected row contains header cells.\n*\n* @public\n*/\nconst toggleHeaderRow = toggleHeader(\"row\", { useDeprecatedLogic: true });\n/**\n* Toggles whether the selected column contains header cells.\n*\n* @public\n*/\nconst toggleHeaderColumn = toggleHeader(\"column\", { useDeprecatedLogic: true });\n/**\n* Toggles whether the selected cells are header cells.\n*\n* @public\n*/\nconst toggleHeaderCell = toggleHeader(\"cell\", { useDeprecatedLogic: true });\nfunction findNextCell($cell, dir) {\n\tif (dir < 0) {\n\t\tconst before = $cell.nodeBefore;\n\t\tif (before) return $cell.pos - before.nodeSize;\n\t\tfor (let row = $cell.index(-1) - 1, rowEnd = $cell.before(); row >= 0; row--) {\n\t\t\tconst rowNode = $cell.node(-1).child(row);\n\t\t\tconst lastChild = rowNode.lastChild;\n\t\t\tif (lastChild) return rowEnd - 1 - lastChild.nodeSize;\n\t\t\trowEnd -= rowNode.nodeSize;\n\t\t}\n\t} else {\n\t\tif ($cell.index() < $cell.parent.childCount - 1) return $cell.pos + $cell.nodeAfter.nodeSize;\n\t\tconst table = $cell.node(-1);\n\t\tfor (let row = $cell.indexAfter(-1), rowStart = $cell.after(); row < table.childCount; row++) {\n\t\t\tconst rowNode = table.child(row);\n\t\t\tif (rowNode.childCount) return rowStart + 1;\n\t\t\trowStart += rowNode.nodeSize;\n\t\t}\n\t}\n\treturn null;\n}\n/**\n* Returns a command for selecting the next (direction=1) or previous\n* (direction=-1) cell in a table.\n*\n* @public\n*/\nfunction goToNextCell(direction) {\n\treturn function(state, dispatch) {\n\t\tif (!isInTable(state)) return false;\n\t\tconst cell = findNextCell(selectionCell(state), direction);\n\t\tif (cell == null) return false;\n\t\tif (dispatch) {\n\t\t\tconst $cell = state.doc.resolve(cell);\n\t\t\tdispatch(state.tr.setSelection(prosemirror_state.TextSelection.between($cell, moveCellForward($cell))).scrollIntoView());\n\t\t}\n\t\treturn true;\n\t};\n}\n/**\n* Deletes the table around the selection, if any.\n*\n* @public\n*/\nfunction deleteTable(state, dispatch) {\n\tconst $pos = state.selection.$anchor;\n\tfor (let d = $pos.depth; d > 0; d--) if ($pos.node(d).type.spec.tableRole == \"table\") {\n\t\tif (dispatch) dispatch(state.tr.delete($pos.before(d), $pos.after(d)).scrollIntoView());\n\t\treturn true;\n\t}\n\treturn false;\n}\n/**\n* Deletes the content of the selected cells, if they are not empty.\n*\n* @public\n*/\nfunction deleteCellSelection(state, dispatch) {\n\tconst sel = state.selection;\n\tif (!(sel instanceof CellSelection)) return false;\n\tif (dispatch) {\n\t\tconst tr = state.tr;\n\t\tconst baseContent = tableNodeTypes(state.schema).cell.createAndFill().content;\n\t\tsel.forEachCell((cell, pos) => {\n\t\t\tif (!cell.content.eq(baseContent)) tr.replace(tr.mapping.map(pos + 1), tr.mapping.map(pos + cell.nodeSize - 1), new prosemirror_model.Slice(baseContent, 0, 0));\n\t\t});\n\t\tif (tr.docChanged) dispatch(tr);\n\t}\n\treturn true;\n}\n/**\n* Move a table row from index `from` to index `to`.\n*\n* @public\n*/\nfunction moveTableRow(options) {\n\treturn (state, dispatch) => {\n\t\tconst { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;\n\t\tconst tr = state.tr;\n\t\tif (moveRow({\n\t\t\ttr,\n\t\t\toriginIndex,\n\t\t\ttargetIndex,\n\t\t\tselect,\n\t\t\tpos\n\t\t})) {\n\t\t\tdispatch === null || dispatch === void 0 || dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n}\n/**\n* Move a table column from index `from` to index `to`.\n*\n* @public\n*/\nfunction moveTableColumn(options) {\n\treturn (state, dispatch) => {\n\t\tconst { from: originIndex, to: targetIndex, select = true, pos = state.selection.from } = options;\n\t\tconst tr = state.tr;\n\t\tif (moveColumn({\n\t\t\ttr,\n\t\t\toriginIndex,\n\t\t\ttargetIndex,\n\t\t\tselect,\n\t\t\tpos\n\t\t})) {\n\t\t\tdispatch === null || dispatch === void 0 || dispatch(tr);\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t};\n}\n\n//#endregion\n//#region src/copypaste.ts\n/**\n* Get a rectangular area of cells from a slice, or null if the outer\n* nodes of the slice aren't table cells or rows.\n*\n* @internal\n*/\nfunction pastedCells(slice) {\n\tif (slice.size === 0) return null;\n\tlet { content, openStart, openEnd } = slice;\n\twhile (content.childCount == 1 && (openStart > 0 && openEnd > 0 || content.child(0).type.spec.tableRole == \"table\")) {\n\t\topenStart--;\n\t\topenEnd--;\n\t\tcontent = content.child(0).content;\n\t}\n\tconst first = content.child(0);\n\tconst role = first.type.spec.tableRole;\n\tconst schema = first.type.schema, rows = [];\n\tif (role == \"row\") for (let i = 0; i < content.childCount; i++) {\n\t\tlet cells = content.child(i).content;\n\t\tconst left = i ? 0 : Math.max(0, openStart - 1);\n\t\tconst right = i < content.childCount - 1 ? 0 : Math.max(0, openEnd - 1);\n\t\tif (left || right) cells = fitSlice(tableNodeTypes(schema).row, new prosemirror_model.Slice(cells, left, right)).content;\n\t\trows.push(cells);\n\t}\n\telse if (role == \"cell\" || role == \"header_cell\") rows.push(openStart || openEnd ? fitSlice(tableNodeTypes(schema).row, new prosemirror_model.Slice(content, openStart, openEnd)).content : content);\n\telse return null;\n\treturn ensureRectangular(schema, rows);\n}\nfunction ensureRectangular(schema, rows) {\n\tconst widths = [];\n\tfor (let i = 0; i < rows.length; i++) {\n\t\tconst row = rows[i];\n\t\tfor (let j = row.childCount - 1; j >= 0; j--) {\n\t\t\tconst { rowspan, colspan } = row.child(j).attrs;\n\t\t\tfor (let r = i; r < i + rowspan; r++) widths[r] = (widths[r] || 0) + colspan;\n\t\t}\n\t}\n\tlet width = 0;\n\tfor (let r = 0; r < widths.length; r++) width = Math.max(width, widths[r]);\n\tfor (let r = 0; r < widths.length; r++) {\n\t\tif (r >= rows.length) rows.push(prosemirror_model.Fragment.empty);\n\t\tif (widths[r] < width) {\n\t\t\tconst empty = tableNodeTypes(schema).cell.createAndFill();\n\t\t\tconst cells = [];\n\t\t\tfor (let i = widths[r]; i < width; i++) cells.push(empty);\n\t\t\trows[r] = rows[r].append(prosemirror_model.Fragment.from(cells));\n\t\t}\n\t}\n\treturn {\n\t\theight: rows.length,\n\t\twidth,\n\t\trows\n\t};\n}\nfunction fitSlice(nodeType, slice) {\n\tconst node = nodeType.createAndFill();\n\treturn new prosemirror_transform.Transform(node).replace(0, node.content.size, slice).doc;\n}\n/**\n* Clip or extend (repeat) the given set of cells to cover the given\n* width and height. Will clip rowspan/colspan cells at the edges when\n* they stick out.\n*\n* @internal\n*/\nfunction clipCells({ width, height, rows }, newWidth, newHeight) {\n\tif (width != newWidth) {\n\t\tconst added = [];\n\t\tconst newRows = [];\n\t\tfor (let row = 0; row < rows.length; row++) {\n\t\t\tconst frag = rows[row], cells = [];\n\t\t\tfor (let col = added[row] || 0, i = 0; col < newWidth; i++) {\n\t\t\t\tlet cell = frag.child(i % frag.childCount);\n\t\t\t\tif (col + cell.attrs.colspan > newWidth) cell = cell.type.createChecked(removeColSpan(cell.attrs, cell.attrs.colspan, col + cell.attrs.colspan - newWidth), cell.content);\n\t\t\t\tcells.push(cell);\n\t\t\t\tcol += cell.attrs.colspan;\n\t\t\t\tfor (let j = 1; j < cell.attrs.rowspan; j++) added[row + j] = (added[row + j] || 0) + cell.attrs.colspan;\n\t\t\t}\n\t\t\tnewRows.push(prosemirror_model.Fragment.from(cells));\n\t\t}\n\t\trows = newRows;\n\t\twidth = newWidth;\n\t}\n\tif (height != newHeight) {\n\t\tconst newRows = [];\n\t\tfor (let row = 0, i = 0; row < newHeight; row++, i++) {\n\t\t\tconst cells = [], source = rows[i % height];\n\t\t\tfor (let j = 0; j < source.childCount; j++) {\n\t\t\t\tlet cell = source.child(j);\n\t\t\t\tif (row + cell.attrs.rowspan > newHeight) cell = cell.type.create({\n\t\t\t\t\t...cell.attrs,\n\t\t\t\t\trowspan: Math.max(1, newHeight - cell.attrs.rowspan)\n\t\t\t\t}, cell.content);\n\t\t\t\tcells.push(cell);\n\t\t\t}\n\t\t\tnewRows.push(prosemirror_model.Fragment.from(cells));\n\t\t}\n\t\trows = newRows;\n\t\theight = newHeight;\n\t}\n\treturn {\n\t\twidth,\n\t\theight,\n\t\trows\n\t};\n}\nfunction growTable(tr, map, table, start, width, height, mapFrom) {\n\tconst schema = tr.doc.type.schema;\n\tconst types = tableNodeTypes(schema);\n\tlet empty;\n\tlet emptyHead;\n\tif (width > map.width) for (let row = 0, rowEnd = 0; row < map.height; row++) {\n\t\tconst rowNode = table.child(row);\n\t\trowEnd += rowNode.nodeSize;\n\t\tconst cells = [];\n\t\tlet add;\n\t\tif (rowNode.lastChild == null || rowNode.lastChild.type == types.cell) add = empty || (empty = types.cell.createAndFill());\n\t\telse add = emptyHead || (emptyHead = types.header_cell.createAndFill());\n\t\tfor (let i = map.width; i < width; i++) cells.push(add);\n\t\ttr.insert(tr.mapping.slice(mapFrom).map(rowEnd - 1 + start), cells);\n\t}\n\tif (height > map.height) {\n\t\tconst cells = [];\n\t\tfor (let i = 0, start$1 = (map.height - 1) * map.width; i < Math.max(map.width, width); i++) {\n\t\t\tconst header = i >= map.width ? false : table.nodeAt(map.map[start$1 + i]).type == types.header_cell;\n\t\t\tcells.push(header ? emptyHead || (emptyHead = types.header_cell.createAndFill()) : empty || (empty = types.cell.createAndFill()));\n\t\t}\n\t\tconst emptyRow = types.row.create(null, prosemirror_model.Fragment.from(cells)), rows = [];\n\t\tfor (let i = map.height; i < height; i++) rows.push(emptyRow);\n\t\ttr.insert(tr.mapping.slice(mapFrom).map(start + table.nodeSize - 2), rows);\n\t}\n\treturn !!(empty || emptyHead);\n}\nfunction isolateHorizontal(tr, map, table, start, left, right, top, mapFrom) {\n\tif (top == 0 || top == map.height) return false;\n\tlet found = false;\n\tfor (let col = left; col < right; col++) {\n\t\tconst index = top * map.width + col, pos = map.map[index];\n\t\tif (map.map[index - map.width] == pos) {\n\t\t\tfound = true;\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst { top: cellTop, left: cellLeft } = map.findCell(pos);\n\t\t\ttr.setNodeMarkup(tr.mapping.slice(mapFrom).map(pos + start), null, {\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: top - cellTop\n\t\t\t});\n\t\t\ttr.insert(tr.mapping.slice(mapFrom).map(map.positionAt(top, cellLeft, table)), cell.type.createAndFill({\n\t\t\t\t...cell.attrs,\n\t\t\t\trowspan: cellTop + cell.attrs.rowspan - top\n\t\t\t}));\n\t\t\tcol += cell.attrs.colspan - 1;\n\t\t}\n\t}\n\treturn found;\n}\nfunction isolateVertical(tr, map, table, start, top, bottom, left, mapFrom) {\n\tif (left == 0 || left == map.width) return false;\n\tlet found = false;\n\tfor (let row = top; row < bottom; row++) {\n\t\tconst index = row * map.width + left, pos = map.map[index];\n\t\tif (map.map[index - 1] == pos) {\n\t\t\tfound = true;\n\t\t\tconst cell = table.nodeAt(pos);\n\t\t\tconst cellLeft = map.colCount(pos);\n\t\t\tconst updatePos = tr.mapping.slice(mapFrom).map(pos + start);\n\t\t\ttr.setNodeMarkup(updatePos, null, removeColSpan(cell.attrs, left - cellLeft, cell.attrs.colspan - (left - cellLeft)));\n\t\t\ttr.insert(updatePos + cell.nodeSize, cell.type.createAndFill(removeColSpan(cell.attrs, 0, left - cellLeft)));\n\t\t\trow += cell.attrs.rowspan - 1;\n\t\t}\n\t}\n\treturn found;\n}\n/**\n* Insert the given set of cells (as returned by `pastedCells`) into a\n* table, at the position pointed at by rect.\n*\n* @internal\n*/\nfunction insertCells(state, dispatch, tableStart, rect, cells) {\n\tlet table = tableStart ? state.doc.nodeAt(tableStart - 1) : state.doc;\n\tif (!table) throw new Error(\"No table found\");\n\tlet map = TableMap.get(table);\n\tconst { top, left } = rect;\n\tconst right = left + cells.width, bottom = top + cells.height;\n\tconst tr = state.tr;\n\tlet mapFrom = 0;\n\tfunction recomp() {\n\t\ttable = tableStart ? tr.doc.nodeAt(tableStart - 1) : tr.doc;\n\t\tif (!table) throw new Error(\"No table found\");\n\t\tmap = TableMap.get(table);\n\t\tmapFrom = tr.mapping.maps.length;\n\t}\n\tif (growTable(tr, map, table, tableStart, right, bottom, mapFrom)) recomp();\n\tif (isolateHorizontal(tr, map, table, tableStart, left, right, top, mapFrom)) recomp();\n\tif (isolateHorizontal(tr, map, table, tableStart, left, right, bottom, mapFrom)) recomp();\n\tif (isolateVertical(tr, map, table, tableStart, top, bottom, left, mapFrom)) recomp();\n\tif (isolateVertical(tr, map, table, tableStart, top, bottom, right, mapFrom)) recomp();\n\tfor (let row = top; row < bottom; row++) {\n\t\tconst from = map.positionAt(row, left, table), to = map.positionAt(row, right, table);\n\t\ttr.replace(tr.mapping.slice(mapFrom).map(from + tableStart), tr.mapping.slice(mapFrom).map(to + tableStart), new prosemirror_model.Slice(cells.rows[row - top], 0, 0));\n\t}\n\trecomp();\n\ttr.setSelection(new CellSelection(tr.doc.resolve(tableStart + map.positionAt(top, left, table)), tr.doc.resolve(tableStart + map.positionAt(bottom - 1, right - 1, table))));\n\tdispatch(tr);\n}\n\n//#endregion\n//#region src/input.ts\nconst handleKeyDown = (0, prosemirror_keymap.keydownHandler)({\n\tArrowLeft: arrow(\"horiz\", -1),\n\tArrowRight: arrow(\"horiz\", 1),\n\tArrowUp: arrow(\"vert\", -1),\n\tArrowDown: arrow(\"vert\", 1),\n\t\"Shift-ArrowLeft\": shiftArrow(\"horiz\", -1),\n\t\"Shift-ArrowRight\": shiftArrow(\"horiz\", 1),\n\t\"Shift-ArrowUp\": shiftArrow(\"vert\", -1),\n\t\"Shift-ArrowDown\": shiftArrow(\"vert\", 1),\n\tBackspace: deleteCellSelection,\n\t\"Mod-Backspace\": deleteCellSelection,\n\tDelete: deleteCellSelection,\n\t\"Mod-Delete\": deleteCellSelection\n});\nfunction maybeSetSelection(state, dispatch, selection) {\n\tif (selection.eq(state.selection)) return false;\n\tif (dispatch) dispatch(state.tr.setSelection(selection).scrollIntoView());\n\treturn true;\n}\n/**\n* @internal\n*/\nfunction arrow(axis, dir) {\n\treturn (state, dispatch, view) => {\n\t\tif (!view) return false;\n\t\tconst sel = state.selection;\n\t\tif (sel instanceof CellSelection) return maybeSetSelection(state, dispatch, prosemirror_state.Selection.near(sel.$headCell, dir));\n\t\tif (axis != \"horiz\" && !sel.empty) return false;\n\t\tconst end = atEndOfCell(view, axis, dir);\n\t\tif (end == null) return false;\n\t\tif (axis == \"horiz\") return maybeSetSelection(state, dispatch, prosemirror_state.Selection.near(state.doc.resolve(sel.head + dir), dir));\n\t\telse {\n\t\t\tconst $cell = state.doc.resolve(end);\n\t\t\tconst $next = nextCell($cell, axis, dir);\n\t\t\tlet newSel;\n\t\t\tif ($next) newSel = prosemirror_state.Selection.near($next, 1);\n\t\t\telse if (dir < 0) newSel = prosemirror_state.Selection.near(state.doc.resolve($cell.before(-1)), -1);\n\t\t\telse newSel = prosemirror_state.Selection.near(state.doc.resolve($cell.after(-1)), 1);\n\t\t\treturn maybeSetSelection(state, dispatch, newSel);\n\t\t}\n\t};\n}\nfunction shiftArrow(axis, dir) {\n\treturn (state, dispatch, view) => {\n\t\tif (!view) return false;\n\t\tconst sel = state.selection;\n\t\tlet cellSel;\n\t\tif (sel instanceof CellSelection) cellSel = sel;\n\t\telse {\n\t\t\tconst end = atEndOfCell(view, axis, dir);\n\t\t\tif (end == null) return false;\n\t\t\tcellSel = new CellSelection(state.doc.resolve(end));\n\t\t}\n\t\tconst $head = nextCell(cellSel.$headCell, axis, dir);\n\t\tif (!$head) return false;\n\t\treturn maybeSetSelection(state, dispatch, new CellSelection(cellSel.$anchorCell, $head));\n\t};\n}\nfunction handleTripleClick(view, pos) {\n\tconst doc = view.state.doc, $cell = cellAround(doc.resolve(pos));\n\tif (!$cell) return false;\n\tview.dispatch(view.state.tr.setSelection(new CellSelection($cell)));\n\treturn true;\n}\n/**\n* @public\n*/\nfunction handlePaste(view, _, slice) {\n\tif (!isInTable(view.state)) return false;\n\tlet cells = pastedCells(slice);\n\tconst sel = view.state.selection;\n\tif (sel instanceof CellSelection) {\n\t\tif (!cells) cells = {\n\t\t\twidth: 1,\n\t\t\theight: 1,\n\t\t\trows: [prosemirror_model.Fragment.from(fitSlice(tableNodeTypes(view.state.schema).cell, slice))]\n\t\t};\n\t\tconst table = sel.$anchorCell.node(-1);\n\t\tconst start = sel.$anchorCell.start(-1);\n\t\tconst rect = TableMap.get(table).rectBetween(sel.$anchorCell.pos - start, sel.$headCell.pos - start);\n\t\tcells = clipCells(cells, rect.right - rect.left, rect.bottom - rect.top);\n\t\tinsertCells(view.state, view.dispatch, start, rect, cells);\n\t\treturn true;\n\t} else if (cells) {\n\t\tconst $cell = selectionCell(view.state);\n\t\tconst start = $cell.start(-1);\n\t\tinsertCells(view.state, view.dispatch, start, TableMap.get($cell.node(-1)).findCell($cell.pos - start), cells);\n\t\treturn true;\n\t} else return false;\n}\nfunction handleMouseDown$1(view, startEvent) {\n\tvar _cellUnderMouse;\n\tif (startEvent.button != 0) return;\n\tif (startEvent.ctrlKey || startEvent.metaKey) return;\n\tconst startDOMCell = domInCell(view, startEvent.target);\n\tlet $anchor;\n\tif (startEvent.shiftKey && view.state.selection instanceof CellSelection) {\n\t\tsetCellSelection(view.state.selection.$anchorCell, startEvent);\n\t\tstartEvent.preventDefault();\n\t} else if (startEvent.shiftKey && startDOMCell && ($anchor = cellAround(view.state.selection.$anchor)) != null && ((_cellUnderMouse = cellUnderMouse(view, startEvent)) === null || _cellUnderMouse === void 0 ? void 0 : _cellUnderMouse.pos) != $anchor.pos) {\n\t\tsetCellSelection($anchor, startEvent);\n\t\tstartEvent.preventDefault();\n\t} else if (!startDOMCell) return;\n\tfunction setCellSelection($anchor$1, event) {\n\t\tlet $head = cellUnderMouse(view, event);\n\t\tconst starting = tableEditingKey.getState(view.state) == null;\n\t\tif (!$head || !inSameTable($anchor$1, $head)) if (starting) $head = $anchor$1;\n\t\telse return;\n\t\tconst selection = new CellSelection($anchor$1, $head);\n\t\tif (starting || !view.state.selection.eq(selection)) {\n\t\t\tconst tr = view.state.tr.setSelection(selection);\n\t\t\tif (starting) tr.setMeta(tableEditingKey, $anchor$1.pos);\n\t\t\tview.dispatch(tr);\n\t\t}\n\t}\n\tfunction stop() {\n\t\tview.root.removeEventListener(\"mouseup\", stop);\n\t\tview.root.removeEventListener(\"dragstart\", stop);\n\t\tview.root.removeEventListener(\"mousemove\", move);\n\t\tif (tableEditingKey.getState(view.state) != null) view.dispatch(view.state.tr.setMeta(tableEditingKey, -1));\n\t}\n\tfunction move(_event) {\n\t\tconst event = _event;\n\t\tconst anchor = tableEditingKey.getState(view.state);\n\t\tlet $anchor$1;\n\t\tif (anchor != null) $anchor$1 = view.state.doc.resolve(anchor);\n\t\telse if (domInCell(view, event.target) != startDOMCell) {\n\t\t\t$anchor$1 = cellUnderMouse(view, startEvent);\n\t\t\tif (!$anchor$1) return stop();\n\t\t}\n\t\tif ($anchor$1) setCellSelection($anchor$1, event);\n\t}\n\tview.root.addEventListener(\"mouseup\", stop);\n\tview.root.addEventListener(\"dragstart\", stop);\n\tview.root.addEventListener(\"mousemove\", move);\n}\nfunction atEndOfCell(view, axis, dir) {\n\tif (!(view.state.selection instanceof prosemirror_state.TextSelection)) return null;\n\tconst { $head } = view.state.selection;\n\tfor (let d = $head.depth - 1; d >= 0; d--) {\n\t\tconst parent = $head.node(d);\n\t\tif ((dir < 0 ? $head.index(d) : $head.indexAfter(d)) != (dir < 0 ? 0 : parent.childCount)) return null;\n\t\tif (parent.type.spec.tableRole == \"cell\" || parent.type.spec.tableRole == \"header_cell\") {\n\t\t\tconst cellPos = $head.before(d);\n\t\t\tconst dirStr = axis == \"vert\" ? dir > 0 ? \"down\" : \"up\" : dir > 0 ? \"right\" : \"left\";\n\t\t\treturn view.endOfTextblock(dirStr) ? cellPos : null;\n\t\t}\n\t}\n\treturn null;\n}\nfunction domInCell(view, dom) {\n\tfor (; dom && dom != view.dom; dom = dom.parentNode) if (dom.nodeName == \"TD\" || dom.nodeName == \"TH\") return dom;\n\treturn null;\n}\nfunction cellUnderMouse(view, event) {\n\tconst mousePos = view.posAtCoords({\n\t\tleft: event.clientX,\n\t\ttop: event.clientY\n\t});\n\tif (!mousePos) return null;\n\tlet { inside, pos } = mousePos;\n\treturn inside >= 0 && cellAround(view.state.doc.resolve(inside)) || cellAround(view.state.doc.resolve(pos));\n}\n\n//#endregion\n//#region src/tableview.ts\n/**\n* @public\n*/\nvar TableView = class {\n\tconstructor(node, defaultCellMinWidth) {\n\t\tthis.node = node;\n\t\tthis.defaultCellMinWidth = defaultCellMinWidth;\n\t\tthis.dom = document.createElement(\"div\");\n\t\tthis.dom.className = \"tableWrapper\";\n\t\tthis.table = this.dom.appendChild(document.createElement(\"table\"));\n\t\tthis.table.style.setProperty(\"--default-cell-min-width\", `${defaultCellMinWidth}px`);\n\t\tthis.colgroup = this.table.appendChild(document.createElement(\"colgroup\"));\n\t\tupdateColumnsOnResize(node, this.colgroup, this.table, defaultCellMinWidth);\n\t\tthis.contentDOM = this.table.appendChild(document.createElement(\"tbody\"));\n\t}\n\tupdate(node) {\n\t\tif (node.type != this.node.type) return false;\n\t\tthis.node = node;\n\t\tupdateColumnsOnResize(node, this.colgroup, this.table, this.defaultCellMinWidth);\n\t\treturn true;\n\t}\n\tignoreMutation(record) {\n\t\treturn record.type == \"attributes\" && (record.target == this.table || this.colgroup.contains(record.target));\n\t}\n};\n/**\n* @public\n*/\nfunction updateColumnsOnResize(node, colgroup, table, defaultCellMinWidth, overrideCol, overrideValue) {\n\tlet totalWidth = 0;\n\tlet fixedWidth = true;\n\tlet nextDOM = colgroup.firstChild;\n\tconst row = node.firstChild;\n\tif (!row) return;\n\tfor (let i = 0, col = 0; i < row.childCount; i++) {\n\t\tconst { colspan, colwidth } = row.child(i).attrs;\n\t\tfor (let j = 0; j < colspan; j++, col++) {\n\t\t\tconst hasWidth = overrideCol == col ? overrideValue : colwidth && colwidth[j];\n\t\t\tconst cssWidth = hasWidth ? hasWidth + \"px\" : \"\";\n\t\t\ttotalWidth += hasWidth || defaultCellMinWidth;\n\t\t\tif (!hasWidth) fixedWidth = false;\n\t\t\tif (!nextDOM) {\n\t\t\t\tconst col$1 = document.createElement(\"col\");\n\t\t\t\tcol$1.style.width = cssWidth;\n\t\t\t\tcolgroup.appendChild(col$1);\n\t\t\t} else {\n\t\t\t\tif (nextDOM.style.width != cssWidth) nextDOM.style.width = cssWidth;\n\t\t\t\tnextDOM = nextDOM.nextSibling;\n\t\t\t}\n\t\t}\n\t}\n\twhile (nextDOM) {\n\t\tvar _nextDOM$parentNode;\n\t\tconst after = nextDOM.nextSibling;\n\t\t(_nextDOM$parentNode = nextDOM.parentNode) === null || _nextDOM$parentNode === void 0 || _nextDOM$parentNode.removeChild(nextDOM);\n\t\tnextDOM = after;\n\t}\n\tif (fixedWidth) {\n\t\ttable.style.width = totalWidth + \"px\";\n\t\ttable.style.minWidth = \"\";\n\t} else {\n\t\ttable.style.width = \"\";\n\t\ttable.style.minWidth = totalWidth + \"px\";\n\t}\n}\n\n//#endregion\n//#region src/columnresizing.ts\n/**\n* @public\n*/\nconst columnResizingPluginKey = new prosemirror_state.PluginKey(\"tableColumnResizing\");\n/**\n* @public\n*/\nfunction columnResizing({ handleWidth = 5, cellMinWidth = 25, defaultCellMinWidth = 100, View = TableView, lastColumnResizable = true } = {}) {\n\tconst plugin = new prosemirror_state.Plugin({\n\t\tkey: columnResizingPluginKey,\n\t\tstate: {\n\t\t\tinit(_, state) {\n\t\t\t\tvar _plugin$spec;\n\t\t\t\tconst nodeViews = (_plugin$spec = plugin.spec) === null || _plugin$spec === void 0 || (_plugin$spec = _plugin$spec.props) === null || _plugin$spec === void 0 ? void 0 : _plugin$spec.nodeViews;\n\t\t\t\tconst tableName = tableNodeTypes(state.schema).table.name;\n\t\t\t\tif (View && nodeViews) nodeViews[tableName] = (node, view) => {\n\t\t\t\t\treturn new View(node, defaultCellMinWidth, view);\n\t\t\t\t};\n\t\t\t\treturn new ResizeState(-1, false);\n\t\t\t},\n\t\t\tapply(tr, prev) {\n\t\t\t\treturn prev.apply(tr);\n\t\t\t}\n\t\t},\n\t\tprops: {\n\t\t\tattributes: (state) => {\n\t\t\t\tconst pluginState = columnResizingPluginKey.getState(state);\n\t\t\t\treturn pluginState && pluginState.activeHandle > -1 ? { class: \"resize-cursor\" } : {};\n\t\t\t},\n\t\t\thandleDOMEvents: {\n\t\t\t\tmousemove: (view, event) => {\n\t\t\t\t\thandleMouseMove(view, event, handleWidth, lastColumnResizable);\n\t\t\t\t},\n\t\t\t\tmouseleave: (view) => {\n\t\t\t\t\thandleMouseLeave(view);\n\t\t\t\t},\n\t\t\t\tmousedown: (view, event) => {\n\t\t\t\t\thandleMouseDown(view, event, cellMinWidth, defaultCellMinWidth);\n\t\t\t\t}\n\t\t\t},\n\t\t\tdecorations: (state) => {\n\t\t\t\tconst pluginState = columnResizingPluginKey.getState(state);\n\t\t\t\tif (pluginState && pluginState.activeHandle > -1) return handleDecorations(state, pluginState.activeHandle);\n\t\t\t},\n\t\t\tnodeViews: {}\n\t\t}\n\t});\n\treturn plugin;\n}\n/**\n* @public\n*/\nvar ResizeState = class ResizeState {\n\tconstructor(activeHandle, dragging) {\n\t\tthis.activeHandle = activeHandle;\n\t\tthis.dragging = dragging;\n\t}\n\tapply(tr) {\n\t\tconst state = this;\n\t\tconst action = tr.getMeta(columnResizingPluginKey);\n\t\tif (action && action.setHandle != null) return new ResizeState(action.setHandle, false);\n\t\tif (action && action.setDragging !== void 0) return new ResizeState(state.activeHandle, action.setDragging);\n\t\tif (state.activeHandle > -1 && tr.docChanged) {\n\t\t\tlet handle = tr.mapping.map(state.activeHandle, -1);\n\t\t\tif (!pointsAtCell(tr.doc.resolve(handle))) handle = -1;\n\t\t\treturn new ResizeState(handle, state.dragging);\n\t\t}\n\t\treturn state;\n\t}\n};\nfunction handleMouseMove(view, event, handleWidth, lastColumnResizable) {\n\tif (!view.editable) return;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (!pluginState) return;\n\tif (!pluginState.dragging) {\n\t\tconst target = domCellAround(event.target);\n\t\tlet cell = -1;\n\t\tif (target) {\n\t\t\tconst { left, right } = target.getBoundingClientRect();\n\t\t\tif (event.clientX - left <= handleWidth) cell = edgeCell(view, event, \"left\", handleWidth);\n\t\t\telse if (right - event.clientX <= handleWidth) cell = edgeCell(view, event, \"right\", handleWidth);\n\t\t}\n\t\tif (cell != pluginState.activeHandle) {\n\t\t\tif (!lastColumnResizable && cell !== -1) {\n\t\t\t\tconst $cell = view.state.doc.resolve(cell);\n\t\t\t\tconst table = $cell.node(-1);\n\t\t\t\tconst map = TableMap.get(table);\n\t\t\t\tconst tableStart = $cell.start(-1);\n\t\t\t\tif (map.colCount($cell.pos - tableStart) + $cell.nodeAfter.attrs.colspan - 1 == map.width - 1) return;\n\t\t\t}\n\t\t\tupdateHandle(view, cell);\n\t\t}\n\t}\n}\nfunction handleMouseLeave(view) {\n\tif (!view.editable) return;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (pluginState && pluginState.activeHandle > -1 && !pluginState.dragging) updateHandle(view, -1);\n}\nfunction handleMouseDown(view, event, cellMinWidth, defaultCellMinWidth) {\n\tvar _view$dom$ownerDocume;\n\tif (!view.editable) return false;\n\tconst win = (_view$dom$ownerDocume = view.dom.ownerDocument.defaultView) !== null && _view$dom$ownerDocume !== void 0 ? _view$dom$ownerDocume : window;\n\tconst pluginState = columnResizingPluginKey.getState(view.state);\n\tif (!pluginState || pluginState.activeHandle == -1 || pluginState.dragging) return false;\n\tconst cell = view.state.doc.nodeAt(pluginState.activeHandle);\n\tconst width = currentColWidth(view, pluginState.activeHandle, cell.attrs);\n\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: {\n\t\tstartX: event.clientX,\n\t\tstartWidth: width\n\t} }));\n\tfunction finish(event$1) {\n\t\twin.removeEventListener(\"mouseup\", finish);\n\t\twin.removeEventListener(\"mousemove\", move);\n\t\tconst pluginState$1 = columnResizingPluginKey.getState(view.state);\n\t\tif (pluginState$1 === null || pluginState$1 === void 0 ? void 0 : pluginState$1.dragging) {\n\t\t\tupdateColumnWidth(view, pluginState$1.activeHandle, draggedWidth(pluginState$1.dragging, event$1, cellMinWidth));\n\t\t\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setDragging: null }));\n\t\t}\n\t}\n\tfunction move(event$1) {\n\t\tif (!event$1.which) return finish(event$1);\n\t\tconst pluginState$1 = columnResizingPluginKey.getState(view.state);\n\t\tif (!pluginState$1) return;\n\t\tif (pluginState$1.dragging) {\n\t\t\tconst dragged = draggedWidth(pluginState$1.dragging, event$1, cellMinWidth);\n\t\t\tdisplayColumnWidth(view, pluginState$1.activeHandle, dragged, defaultCellMinWidth);\n\t\t}\n\t}\n\tdisplayColumnWidth(view, pluginState.activeHandle, width, defaultCellMinWidth);\n\twin.addEventListener(\"mouseup\", finish);\n\twin.addEventListener(\"mousemove\", move);\n\tevent.preventDefault();\n\treturn true;\n}\nfunction currentColWidth(view, cellPos, { colspan, colwidth }) {\n\tconst width = colwidth && colwidth[colwidth.length - 1];\n\tif (width) return width;\n\tconst dom = view.domAtPos(cellPos);\n\tlet domWidth = dom.node.childNodes[dom.offset].offsetWidth, parts = colspan;\n\tif (colwidth) {\n\t\tfor (let i = 0; i < colspan; i++) if (colwidth[i]) {\n\t\t\tdomWidth -= colwidth[i];\n\t\t\tparts--;\n\t\t}\n\t}\n\treturn domWidth / parts;\n}\nfunction domCellAround(target) {\n\twhile (target && target.nodeName != \"TD\" && target.nodeName != \"TH\") target = target.classList && target.classList.contains(\"ProseMirror\") ? null : target.parentNode;\n\treturn target;\n}\nfunction edgeCell(view, event, side, handleWidth) {\n\tconst offset = side == \"right\" ? -handleWidth : handleWidth;\n\tconst found = view.posAtCoords({\n\t\tleft: event.clientX + offset,\n\t\ttop: event.clientY\n\t});\n\tif (!found) return -1;\n\tconst { pos } = found;\n\tconst $cell = cellAround(view.state.doc.resolve(pos));\n\tif (!$cell) return -1;\n\tif (side == \"right\") return $cell.pos;\n\tconst map = TableMap.get($cell.node(-1)), start = $cell.start(-1);\n\tconst index = map.map.indexOf($cell.pos - start);\n\treturn index % map.width == 0 ? -1 : start + map.map[index - 1];\n}\nfunction draggedWidth(dragging, event, resizeMinWidth) {\n\tconst offset = event.clientX - dragging.startX;\n\treturn Math.max(resizeMinWidth, dragging.startWidth + offset);\n}\nfunction updateHandle(view, value) {\n\tview.dispatch(view.state.tr.setMeta(columnResizingPluginKey, { setHandle: value }));\n}\nfunction updateColumnWidth(view, cell, width) {\n\tconst $cell = view.state.doc.resolve(cell);\n\tconst table = $cell.node(-1), map = TableMap.get(table), start = $cell.start(-1);\n\tconst col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tconst tr = view.state.tr;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst mapIndex = row * map.width + col;\n\t\tif (row && map.map[mapIndex] == map.map[mapIndex - map.width]) continue;\n\t\tconst pos = map.map[mapIndex];\n\t\tconst attrs = table.nodeAt(pos).attrs;\n\t\tconst index = attrs.colspan == 1 ? 0 : col - map.colCount(pos);\n\t\tif (attrs.colwidth && attrs.colwidth[index] == width) continue;\n\t\tconst colwidth = attrs.colwidth ? attrs.colwidth.slice() : zeroes(attrs.colspan);\n\t\tcolwidth[index] = width;\n\t\ttr.setNodeMarkup(start + pos, null, {\n\t\t\t...attrs,\n\t\t\tcolwidth\n\t\t});\n\t}\n\tif (tr.docChanged) view.dispatch(tr);\n}\nfunction displayColumnWidth(view, cell, width, defaultCellMinWidth) {\n\tconst $cell = view.state.doc.resolve(cell);\n\tconst table = $cell.node(-1), start = $cell.start(-1);\n\tconst col = TableMap.get(table).colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tlet dom = view.domAtPos($cell.start(-1)).node;\n\twhile (dom && dom.nodeName != \"TABLE\") dom = dom.parentNode;\n\tif (!dom) return;\n\tupdateColumnsOnResize(table, dom.firstChild, dom, defaultCellMinWidth, col, width);\n}\nfunction zeroes(n) {\n\treturn Array(n).fill(0);\n}\nfunction handleDecorations(state, cell) {\n\tconst decorations = [];\n\tconst $cell = state.doc.resolve(cell);\n\tconst table = $cell.node(-1);\n\tif (!table) return prosemirror_view.DecorationSet.empty;\n\tconst map = TableMap.get(table);\n\tconst start = $cell.start(-1);\n\tconst col = map.colCount($cell.pos - start) + $cell.nodeAfter.attrs.colspan - 1;\n\tfor (let row = 0; row < map.height; row++) {\n\t\tconst index = col + row * map.width;\n\t\tif ((col == map.width - 1 || map.map[index] != map.map[index + 1]) && (row == 0 || map.map[index] != map.map[index - map.width])) {\n\t\t\tvar _columnResizingPlugin;\n\t\t\tconst cellPos = map.map[index];\n\t\t\tconst pos = start + cellPos + table.nodeAt(cellPos).nodeSize - 1;\n\t\t\tconst dom = document.createElement(\"div\");\n\t\t\tdom.className = \"column-resize-handle\";\n\t\t\tif ((_columnResizingPlugin = columnResizingPluginKey.getState(state)) === null || _columnResizingPlugin === void 0 ? void 0 : _columnResizingPlugin.dragging) decorations.push(prosemirror_view.Decoration.node(start + cellPos, start + cellPos + table.nodeAt(cellPos).nodeSize, { class: \"column-resize-dragging\" }));\n\t\t\tdecorations.push(prosemirror_view.Decoration.widget(pos, dom));\n\t\t}\n\t}\n\treturn prosemirror_view.DecorationSet.create(state.doc, decorations);\n}\n\n//#endregion\n//#region src/index.ts\n/**\n* Creates a [plugin](http://prosemirror.net/docs/ref/#state.Plugin)\n* that, when added to an editor, enables cell-selection, handles\n* cell-based copy/paste, and makes sure tables stay well-formed (each\n* row has the same width, and cells don't overlap).\n*\n* You should probably put this plugin near the end of your array of\n* plugins, since it handles mouse and arrow key events in tables\n* rather broadly, and other plugins, like the gap cursor or the\n* column-width dragging plugin, might want to get a turn first to\n* perform more specific behavior.\n*\n* @public\n*/\nfunction tableEditing({ allowTableNodeSelection = false } = {}) {\n\treturn new prosemirror_state.Plugin({\n\t\tkey: tableEditingKey,\n\t\tstate: {\n\t\t\tinit() {\n\t\t\t\treturn null;\n\t\t\t},\n\t\t\tapply(tr, cur) {\n\t\t\t\tconst set = tr.getMeta(tableEditingKey);\n\t\t\t\tif (set != null) return set == -1 ? null : set;\n\t\t\t\tif (cur == null || !tr.docChanged) return cur;\n\t\t\t\tconst { deleted, pos } = tr.mapping.mapResult(cur);\n\t\t\t\treturn deleted ? null : pos;\n\t\t\t}\n\t\t},\n\t\tprops: {\n\t\t\tdecorations: drawCellSelection,\n\t\t\thandleDOMEvents: { mousedown: handleMouseDown$1 },\n\t\t\tcreateSelectionBetween(view) {\n\t\t\t\treturn tableEditingKey.getState(view.state) != null ? view.state.selection : null;\n\t\t\t},\n\t\t\thandleTripleClick,\n\t\t\thandleKeyDown,\n\t\t\thandlePaste\n\t\t},\n\t\tappendTransaction(_, oldState, state) {\n\t\t\treturn normalizeSelection(state, fixTables(state, oldState), allowTableNodeSelection);\n\t\t}\n\t});\n}\n\n//#endregion\nexports.CellBookmark = CellBookmark;\nexports.CellSelection = CellSelection;\nexports.ResizeState = ResizeState;\nexports.TableMap = TableMap;\nexports.TableView = TableView;\nexports.__clipCells = clipCells;\nexports.__insertCells = insertCells;\nexports.__pastedCells = pastedCells;\nexports.addColSpan = addColSpan;\nexports.addColumn = addColumn;\nexports.addColumnAfter = addColumnAfter;\nexports.addColumnBefore = addColumnBefore;\nexports.addRow = addRow;\nexports.addRowAfter = addRowAfter;\nexports.addRowBefore = addRowBefore;\nexports.cellAround = cellAround;\nexports.cellNear = cellNear;\nexports.colCount = colCount;\nexports.columnIsHeader = columnIsHeader;\nexports.columnResizing = columnResizing;\nexports.columnResizingPluginKey = columnResizingPluginKey;\nexports.deleteCellSelection = deleteCellSelection;\nexports.deleteColumn = deleteColumn;\nexports.deleteRow = deleteRow;\nexports.deleteTable = deleteTable;\nexports.findCell = findCell;\nexports.findCellPos = findCellPos;\nexports.findCellRange = findCellRange;\nexports.findTable = findTable;\nexports.fixTables = fixTables;\nexports.fixTablesKey = fixTablesKey;\nexports.goToNextCell = goToNextCell;\nexports.handlePaste = handlePaste;\nexports.inSameTable = inSameTable;\nexports.isInTable = isInTable;\nexports.mergeCells = mergeCells;\nexports.moveCellForward = moveCellForward;\nexports.moveTableColumn = moveTableColumn;\nexports.moveTableRow = moveTableRow;\nexports.nextCell = nextCell;\nexports.pointsAtCell = pointsAtCell;\nexports.removeColSpan = removeColSpan;\nexports.removeColumn = removeColumn;\nexports.removeRow = removeRow;\nexports.rowIsHeader = rowIsHeader;\nexports.selectedRect = selectedRect;\nexports.selectionCell = selectionCell;\nexports.setCellAttr = setCellAttr;\nexports.splitCell = splitCell;\nexports.splitCellWithType = splitCellWithType;\nexports.tableEditing = tableEditing;\nexports.tableEditingKey = tableEditingKey;\nexports.tableNodeTypes = tableNodeTypes;\nexports.tableNodes = tableNodes;\nexports.toggleHeader = toggleHeader;\nexports.toggleHeaderCell = toggleHeaderCell;\nexports.toggleHeaderColumn = toggleHeaderColumn;\nexports.toggleHeaderRow = toggleHeaderRow;\nexports.updateColumnsOnResize = updateColumnsOnResize;","'use strict';\n\nfunction _wrapNativeSuper(Class) { var _cache = typeof Map === \"function\" ? new Map() : undefined; _wrapNativeSuper = function _wrapNativeSuper(Class) { if (Class === null || !_isNativeFunction(Class)) return Class; if (typeof Class !== \"function\") { throw new TypeError(\"Super expression must either be null or a function\"); } if (typeof _cache !== \"undefined\") { if (_cache.has(Class)) return _cache.get(Class); _cache.set(Class, Wrapper); } function Wrapper() { return _construct(Class, arguments, _getPrototypeOf(this).constructor); } Wrapper.prototype = Object.create(Class.prototype, { constructor: { value: Wrapper, enumerable: false, writable: true, configurable: true } }); return _setPrototypeOf(Wrapper, Class); }; return _wrapNativeSuper(Class); }\nfunction _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }\nfunction _isNativeFunction(fn) { try { return Function.toString.call(fn).indexOf(\"[native code]\") !== -1; } catch (e) { return typeof fn === \"function\"; } }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar prosemirrorModel = require('prosemirror-model');\nvar lower16 = 0xffff;\nvar factor16 = Math.pow(2, 16);\nfunction makeRecover(index, offset) {\n return index + offset * factor16;\n}\nfunction recoverIndex(value) {\n return value & lower16;\n}\nfunction recoverOffset(value) {\n return (value - (value & lower16)) / factor16;\n}\nvar DEL_BEFORE = 1,\n DEL_AFTER = 2,\n DEL_ACROSS = 4,\n DEL_SIDE = 8;\nvar MapResult = function () {\n function MapResult(pos, delInfo, recover) {\n _classCallCheck(this, MapResult);\n this.pos = pos;\n this.delInfo = delInfo;\n this.recover = recover;\n }\n _createClass(MapResult, [{\n key: \"deleted\",\n get: function get() {\n return (this.delInfo & DEL_SIDE) > 0;\n }\n }, {\n key: \"deletedBefore\",\n get: function get() {\n return (this.delInfo & (DEL_BEFORE | DEL_ACROSS)) > 0;\n }\n }, {\n key: \"deletedAfter\",\n get: function get() {\n return (this.delInfo & (DEL_AFTER | DEL_ACROSS)) > 0;\n }\n }, {\n key: \"deletedAcross\",\n get: function get() {\n return (this.delInfo & DEL_ACROSS) > 0;\n }\n }]);\n return MapResult;\n}();\nvar StepMap = function () {\n function StepMap(ranges) {\n var inverted = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n _classCallCheck(this, StepMap);\n this.ranges = ranges;\n this.inverted = inverted;\n if (!ranges.length && StepMap.empty) return StepMap.empty;\n }\n _createClass(StepMap, [{\n key: \"recover\",\n value: function recover(value) {\n var diff = 0,\n index = recoverIndex(value);\n if (!this.inverted) for (var i = 0; i < index; i++) diff += this.ranges[i * 3 + 2] - this.ranges[i * 3 + 1];\n return this.ranges[index * 3] + diff + recoverOffset(value);\n }\n }, {\n key: \"mapResult\",\n value: function mapResult(pos) {\n var assoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return this._map(pos, assoc, false);\n }\n }, {\n key: \"map\",\n value: function map(pos) {\n var assoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return this._map(pos, assoc, true);\n }\n }, {\n key: \"_map\",\n value: function _map(pos, assoc, simple) {\n var diff = 0,\n oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n for (var i = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i] - (this.inverted ? diff : 0);\n if (start > pos) break;\n var oldSize = this.ranges[i + oldIndex],\n newSize = this.ranges[i + newIndex],\n end = start + oldSize;\n if (pos <= end) {\n var side = !oldSize ? assoc : pos == start ? -1 : pos == end ? 1 : assoc;\n var result = start + diff + (side < 0 ? 0 : newSize);\n if (simple) return result;\n var recover = pos == (assoc < 0 ? start : end) ? null : makeRecover(i / 3, pos - start);\n var del = pos == start ? DEL_AFTER : pos == end ? DEL_BEFORE : DEL_ACROSS;\n if (assoc < 0 ? pos != start : pos != end) del |= DEL_SIDE;\n return new MapResult(result, del, recover);\n }\n diff += newSize - oldSize;\n }\n return simple ? pos + diff : new MapResult(pos + diff, 0, null);\n }\n }, {\n key: \"touches\",\n value: function touches(pos, recover) {\n var diff = 0,\n index = recoverIndex(recover);\n var oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n for (var i = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i] - (this.inverted ? diff : 0);\n if (start > pos) break;\n var oldSize = this.ranges[i + oldIndex],\n end = start + oldSize;\n if (pos <= end && i == index * 3) return true;\n diff += this.ranges[i + newIndex] - oldSize;\n }\n return false;\n }\n }, {\n key: \"forEach\",\n value: function forEach(f) {\n var oldIndex = this.inverted ? 2 : 1,\n newIndex = this.inverted ? 1 : 2;\n for (var i = 0, diff = 0; i < this.ranges.length; i += 3) {\n var start = this.ranges[i],\n oldStart = start - (this.inverted ? diff : 0),\n newStart = start + (this.inverted ? 0 : diff);\n var oldSize = this.ranges[i + oldIndex],\n newSize = this.ranges[i + newIndex];\n f(oldStart, oldStart + oldSize, newStart, newStart + newSize);\n diff += newSize - oldSize;\n }\n }\n }, {\n key: \"invert\",\n value: function invert() {\n return new StepMap(this.ranges, !this.inverted);\n }\n }, {\n key: \"toString\",\n value: function toString() {\n return (this.inverted ? \"-\" : \"\") + JSON.stringify(this.ranges);\n }\n }], [{\n key: \"offset\",\n value: function offset(n) {\n return n == 0 ? StepMap.empty : new StepMap(n < 0 ? [0, -n, 0] : [0, 0, n]);\n }\n }]);\n return StepMap;\n}();\nStepMap.empty = new StepMap([]);\nvar Mapping = function () {\n function Mapping(maps, mirror) {\n var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n var to = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : maps ? maps.length : 0;\n _classCallCheck(this, Mapping);\n this.mirror = mirror;\n this.from = from;\n this.to = to;\n this._maps = maps || [];\n this.ownData = !(maps || mirror);\n }\n _createClass(Mapping, [{\n key: \"maps\",\n get: function get() {\n return this._maps;\n }\n }, {\n key: \"slice\",\n value: function slice() {\n var from = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : this.maps.length;\n return new Mapping(this._maps, this.mirror, from, to);\n }\n }, {\n key: \"appendMap\",\n value: function appendMap(map, mirrors) {\n if (!this.ownData) {\n this._maps = this._maps.slice();\n this.mirror = this.mirror && this.mirror.slice();\n this.ownData = true;\n }\n this.to = this._maps.push(map);\n if (mirrors != null) this.setMirror(this._maps.length - 1, mirrors);\n }\n }, {\n key: \"appendMapping\",\n value: function appendMapping(mapping) {\n for (var i = 0, startSize = this._maps.length; i < mapping._maps.length; i++) {\n var mirr = mapping.getMirror(i);\n this.appendMap(mapping._maps[i], mirr != null && mirr < i ? startSize + mirr : undefined);\n }\n }\n }, {\n key: \"getMirror\",\n value: function getMirror(n) {\n if (this.mirror) for (var i = 0; i < this.mirror.length; i++) if (this.mirror[i] == n) return this.mirror[i + (i % 2 ? -1 : 1)];\n }\n }, {\n key: \"setMirror\",\n value: function setMirror(n, m) {\n if (!this.mirror) this.mirror = [];\n this.mirror.push(n, m);\n }\n }, {\n key: \"appendMappingInverted\",\n value: function appendMappingInverted(mapping) {\n for (var i = mapping.maps.length - 1, totalSize = this._maps.length + mapping._maps.length; i >= 0; i--) {\n var mirr = mapping.getMirror(i);\n this.appendMap(mapping._maps[i].invert(), mirr != null && mirr > i ? totalSize - mirr - 1 : undefined);\n }\n }\n }, {\n key: \"invert\",\n value: function invert() {\n var inverse = new Mapping();\n inverse.appendMappingInverted(this);\n return inverse;\n }\n }, {\n key: \"map\",\n value: function map(pos) {\n var assoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n if (this.mirror) return this._map(pos, assoc, true);\n for (var i = this.from; i < this.to; i++) pos = this._maps[i].map(pos, assoc);\n return pos;\n }\n }, {\n key: \"mapResult\",\n value: function mapResult(pos) {\n var assoc = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return this._map(pos, assoc, false);\n }\n }, {\n key: \"_map\",\n value: function _map(pos, assoc, simple) {\n var delInfo = 0;\n for (var i = this.from; i < this.to; i++) {\n var map = this._maps[i],\n result = map.mapResult(pos, assoc);\n if (result.recover != null) {\n var corr = this.getMirror(i);\n if (corr != null && corr > i && corr < this.to) {\n i = corr;\n pos = this._maps[corr].recover(result.recover);\n continue;\n }\n }\n delInfo |= result.delInfo;\n pos = result.pos;\n }\n return simple ? pos : new MapResult(pos, delInfo, null);\n }\n }]);\n return Mapping;\n}();\nvar stepsByID = Object.create(null);\nvar Step = function () {\n function Step() {\n _classCallCheck(this, Step);\n }\n _createClass(Step, [{\n key: \"getMap\",\n value: function getMap() {\n return StepMap.empty;\n }\n }, {\n key: \"merge\",\n value: function merge(other) {\n return null;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (!json || !json.stepType) throw new RangeError(\"Invalid input for Step.fromJSON\");\n var type = stepsByID[json.stepType];\n if (!type) throw new RangeError(\"No step type \".concat(json.stepType, \" defined\"));\n return type.fromJSON(schema, json);\n }\n }, {\n key: \"jsonID\",\n value: function jsonID(id, stepClass) {\n if (id in stepsByID) throw new RangeError(\"Duplicate use of step JSON ID \" + id);\n stepsByID[id] = stepClass;\n stepClass.prototype.jsonID = id;\n return stepClass;\n }\n }]);\n return Step;\n}();\nvar StepResult = function () {\n function StepResult(doc, failed) {\n _classCallCheck(this, StepResult);\n this.doc = doc;\n this.failed = failed;\n }\n _createClass(StepResult, null, [{\n key: \"ok\",\n value: function ok(doc) {\n return new StepResult(doc, null);\n }\n }, {\n key: \"fail\",\n value: function fail(message) {\n return new StepResult(null, message);\n }\n }, {\n key: \"fromReplace\",\n value: function fromReplace(doc, from, to, slice) {\n try {\n return StepResult.ok(doc.replace(from, to, slice));\n } catch (e) {\n if (e instanceof prosemirrorModel.ReplaceError) return StepResult.fail(e.message);\n throw e;\n }\n }\n }]);\n return StepResult;\n}();\nfunction mapFragment(fragment, f, parent) {\n var mapped = [];\n for (var i = 0; i < fragment.childCount; i++) {\n var child = fragment.child(i);\n if (child.content.size) child = child.copy(mapFragment(child.content, f, child));\n if (child.isInline) child = f(child, parent, i);\n mapped.push(child);\n }\n return prosemirrorModel.Fragment.fromArray(mapped);\n}\nvar AddMarkStep = function (_Step) {\n _inherits(AddMarkStep, _Step);\n var _super = _createSuper(AddMarkStep);\n function AddMarkStep(from, to, mark) {\n var _this;\n _classCallCheck(this, AddMarkStep);\n _this = _super.call(this);\n _this.from = from;\n _this.to = to;\n _this.mark = mark;\n return _this;\n }\n _createClass(AddMarkStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var _this2 = this;\n var oldSlice = doc.slice(this.from, this.to),\n $from = doc.resolve(this.from);\n var parent = $from.node($from.sharedDepth(this.to));\n var slice = new prosemirrorModel.Slice(mapFragment(oldSlice.content, function (node, parent) {\n if (!node.isAtom || !parent.type.allowsMarkType(_this2.mark.type)) return node;\n return node.mark(_this2.mark.addToSet(node.marks));\n }, parent), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n }\n }, {\n key: \"invert\",\n value: function invert() {\n return new RemoveMarkStep(this.from, this.to, this.mark);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n if (from.deleted && to.deleted || from.pos >= to.pos) return null;\n return new AddMarkStep(from.pos, to.pos, this.mark);\n }\n }, {\n key: \"merge\",\n value: function merge(other) {\n if (other instanceof AddMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) return new AddMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n return null;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"addMark\",\n mark: this.mark.toJSON(),\n from: this.from,\n to: this.to\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") throw new RangeError(\"Invalid input for AddMarkStep.fromJSON\");\n return new AddMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n }\n }]);\n return AddMarkStep;\n}(Step);\nStep.jsonID(\"addMark\", AddMarkStep);\nvar RemoveMarkStep = function (_Step2) {\n _inherits(RemoveMarkStep, _Step2);\n var _super2 = _createSuper(RemoveMarkStep);\n function RemoveMarkStep(from, to, mark) {\n var _this3;\n _classCallCheck(this, RemoveMarkStep);\n _this3 = _super2.call(this);\n _this3.from = from;\n _this3.to = to;\n _this3.mark = mark;\n return _this3;\n }\n _createClass(RemoveMarkStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var _this4 = this;\n var oldSlice = doc.slice(this.from, this.to);\n var slice = new prosemirrorModel.Slice(mapFragment(oldSlice.content, function (node) {\n return node.mark(_this4.mark.removeFromSet(node.marks));\n }, doc), oldSlice.openStart, oldSlice.openEnd);\n return StepResult.fromReplace(doc, this.from, this.to, slice);\n }\n }, {\n key: \"invert\",\n value: function invert() {\n return new AddMarkStep(this.from, this.to, this.mark);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n if (from.deleted && to.deleted || from.pos >= to.pos) return null;\n return new RemoveMarkStep(from.pos, to.pos, this.mark);\n }\n }, {\n key: \"merge\",\n value: function merge(other) {\n if (other instanceof RemoveMarkStep && other.mark.eq(this.mark) && this.from <= other.to && this.to >= other.from) return new RemoveMarkStep(Math.min(this.from, other.from), Math.max(this.to, other.to), this.mark);\n return null;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"removeMark\",\n mark: this.mark.toJSON(),\n from: this.from,\n to: this.to\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") throw new RangeError(\"Invalid input for RemoveMarkStep.fromJSON\");\n return new RemoveMarkStep(json.from, json.to, schema.markFromJSON(json.mark));\n }\n }]);\n return RemoveMarkStep;\n}(Step);\nStep.jsonID(\"removeMark\", RemoveMarkStep);\nvar AddNodeMarkStep = function (_Step3) {\n _inherits(AddNodeMarkStep, _Step3);\n var _super3 = _createSuper(AddNodeMarkStep);\n function AddNodeMarkStep(pos, mark) {\n var _this5;\n _classCallCheck(this, AddNodeMarkStep);\n _this5 = _super3.call(this);\n _this5.pos = pos;\n _this5.mark = mark;\n return _this5;\n }\n _createClass(AddNodeMarkStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var node = doc.nodeAt(this.pos);\n if (!node) return StepResult.fail(\"No node at mark step's position\");\n var updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n var node = doc.nodeAt(this.pos);\n if (node) {\n var newSet = this.mark.addToSet(node.marks);\n if (newSet.length == node.marks.length) {\n for (var i = 0; i < node.marks.length; i++) if (!node.marks[i].isInSet(newSet)) return new AddNodeMarkStep(this.pos, node.marks[i]);\n return new AddNodeMarkStep(this.pos, this.mark);\n }\n }\n return new RemoveNodeMarkStep(this.pos, this.mark);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"addNodeMark\",\n pos: this.pos,\n mark: this.mark.toJSON()\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.pos != \"number\") throw new RangeError(\"Invalid input for AddNodeMarkStep.fromJSON\");\n return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));\n }\n }]);\n return AddNodeMarkStep;\n}(Step);\nStep.jsonID(\"addNodeMark\", AddNodeMarkStep);\nvar RemoveNodeMarkStep = function (_Step4) {\n _inherits(RemoveNodeMarkStep, _Step4);\n var _super4 = _createSuper(RemoveNodeMarkStep);\n function RemoveNodeMarkStep(pos, mark) {\n var _this6;\n _classCallCheck(this, RemoveNodeMarkStep);\n _this6 = _super4.call(this);\n _this6.pos = pos;\n _this6.mark = mark;\n return _this6;\n }\n _createClass(RemoveNodeMarkStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var node = doc.nodeAt(this.pos);\n if (!node) return StepResult.fail(\"No node at mark step's position\");\n var updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n var node = doc.nodeAt(this.pos);\n if (!node || !this.mark.isInSet(node.marks)) return this;\n return new AddNodeMarkStep(this.pos, this.mark);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"removeNodeMark\",\n pos: this.pos,\n mark: this.mark.toJSON()\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.pos != \"number\") throw new RangeError(\"Invalid input for RemoveNodeMarkStep.fromJSON\");\n return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));\n }\n }]);\n return RemoveNodeMarkStep;\n}(Step);\nStep.jsonID(\"removeNodeMark\", RemoveNodeMarkStep);\nvar ReplaceStep = function (_Step5) {\n _inherits(ReplaceStep, _Step5);\n var _super5 = _createSuper(ReplaceStep);\n function ReplaceStep(from, to, slice) {\n var _this7;\n var structure = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n _classCallCheck(this, ReplaceStep);\n _this7 = _super5.call(this);\n _this7.from = from;\n _this7.to = to;\n _this7.slice = slice;\n _this7.structure = structure;\n return _this7;\n }\n _createClass(ReplaceStep, [{\n key: \"apply\",\n value: function apply(doc) {\n if (this.structure && contentBetween(doc, this.from, this.to)) return StepResult.fail(\"Structure replace would overwrite content\");\n return StepResult.fromReplace(doc, this.from, this.to, this.slice);\n }\n }, {\n key: \"getMap\",\n value: function getMap() {\n return new StepMap([this.from, this.to - this.from, this.slice.size]);\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n return new ReplaceStep(this.from, this.from + this.slice.size, doc.slice(this.from, this.to));\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var to = mapping.mapResult(this.to, -1);\n var from = this.from == this.to && ReplaceStep.MAP_BIAS < 0 ? to : mapping.mapResult(this.from, 1);\n if (from.deletedAcross && to.deletedAcross) return null;\n return new ReplaceStep(from.pos, Math.max(from.pos, to.pos), this.slice, this.structure);\n }\n }, {\n key: \"merge\",\n value: function merge(other) {\n if (!(other instanceof ReplaceStep) || other.structure || this.structure) return null;\n if (this.from + this.slice.size == other.from && !this.slice.openEnd && !other.slice.openStart) {\n var slice = this.slice.size + other.slice.size == 0 ? prosemirrorModel.Slice.empty : new prosemirrorModel.Slice(this.slice.content.append(other.slice.content), this.slice.openStart, other.slice.openEnd);\n return new ReplaceStep(this.from, this.to + (other.to - other.from), slice, this.structure);\n } else if (other.to == this.from && !this.slice.openStart && !other.slice.openEnd) {\n var _slice = this.slice.size + other.slice.size == 0 ? prosemirrorModel.Slice.empty : new prosemirrorModel.Slice(other.slice.content.append(this.slice.content), other.slice.openStart, this.slice.openEnd);\n return new ReplaceStep(other.from, this.to, _slice, this.structure);\n } else {\n return null;\n }\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var json = {\n stepType: \"replace\",\n from: this.from,\n to: this.to\n };\n if (this.slice.size) json.slice = this.slice.toJSON();\n if (this.structure) json.structure = true;\n return json;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\") throw new RangeError(\"Invalid input for ReplaceStep.fromJSON\");\n return new ReplaceStep(json.from, json.to, prosemirrorModel.Slice.fromJSON(schema, json.slice), !!json.structure);\n }\n }]);\n return ReplaceStep;\n}(Step);\nReplaceStep.MAP_BIAS = 1;\nStep.jsonID(\"replace\", ReplaceStep);\nvar ReplaceAroundStep = function (_Step6) {\n _inherits(ReplaceAroundStep, _Step6);\n var _super6 = _createSuper(ReplaceAroundStep);\n function ReplaceAroundStep(from, to, gapFrom, gapTo, slice, insert) {\n var _this8;\n var structure = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : false;\n _classCallCheck(this, ReplaceAroundStep);\n _this8 = _super6.call(this);\n _this8.from = from;\n _this8.to = to;\n _this8.gapFrom = gapFrom;\n _this8.gapTo = gapTo;\n _this8.slice = slice;\n _this8.insert = insert;\n _this8.structure = structure;\n return _this8;\n }\n _createClass(ReplaceAroundStep, [{\n key: \"apply\",\n value: function apply(doc) {\n if (this.structure && (contentBetween(doc, this.from, this.gapFrom) || contentBetween(doc, this.gapTo, this.to))) return StepResult.fail(\"Structure gap-replace would overwrite content\");\n var gap = doc.slice(this.gapFrom, this.gapTo);\n if (gap.openStart || gap.openEnd) return StepResult.fail(\"Gap is not a flat range\");\n var inserted = this.slice.insertAt(this.insert, gap.content);\n if (!inserted) return StepResult.fail(\"Content does not fit in gap\");\n return StepResult.fromReplace(doc, this.from, this.to, inserted);\n }\n }, {\n key: \"getMap\",\n value: function getMap() {\n return new StepMap([this.from, this.gapFrom - this.from, this.insert, this.gapTo, this.to - this.gapTo, this.slice.size - this.insert]);\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n var gap = this.gapTo - this.gapFrom;\n return new ReplaceAroundStep(this.from, this.from + this.slice.size + gap, this.from + this.insert, this.from + this.insert + gap, doc.slice(this.from, this.to).removeBetween(this.gapFrom - this.from, this.gapTo - this.from), this.gapFrom - this.from, this.structure);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var from = mapping.mapResult(this.from, 1),\n to = mapping.mapResult(this.to, -1);\n var gapFrom = this.from == this.gapFrom ? from.pos : mapping.map(this.gapFrom, -1);\n var gapTo = this.to == this.gapTo ? to.pos : mapping.map(this.gapTo, 1);\n if (from.deletedAcross && to.deletedAcross || gapFrom < from.pos || gapTo > to.pos) return null;\n return new ReplaceAroundStep(from.pos, to.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n var json = {\n stepType: \"replaceAround\",\n from: this.from,\n to: this.to,\n gapFrom: this.gapFrom,\n gapTo: this.gapTo,\n insert: this.insert\n };\n if (this.slice.size) json.slice = this.slice.toJSON();\n if (this.structure) json.structure = true;\n return json;\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.from != \"number\" || typeof json.to != \"number\" || typeof json.gapFrom != \"number\" || typeof json.gapTo != \"number\" || typeof json.insert != \"number\") throw new RangeError(\"Invalid input for ReplaceAroundStep.fromJSON\");\n return new ReplaceAroundStep(json.from, json.to, json.gapFrom, json.gapTo, prosemirrorModel.Slice.fromJSON(schema, json.slice), json.insert, !!json.structure);\n }\n }]);\n return ReplaceAroundStep;\n}(Step);\nStep.jsonID(\"replaceAround\", ReplaceAroundStep);\nfunction contentBetween(doc, from, to) {\n var $from = doc.resolve(from),\n dist = to - from,\n depth = $from.depth;\n while (dist > 0 && depth > 0 && $from.indexAfter(depth) == $from.node(depth).childCount) {\n depth--;\n dist--;\n }\n if (dist > 0) {\n var next = $from.node(depth).maybeChild($from.indexAfter(depth));\n while (dist > 0) {\n if (!next || next.isLeaf) return true;\n next = next.firstChild;\n dist--;\n }\n }\n return false;\n}\nfunction _addMark(tr, from, to, mark) {\n var removed = [],\n added = [];\n var removing, adding;\n tr.doc.nodesBetween(from, to, function (node, pos, parent) {\n if (!node.isInline) return;\n var marks = node.marks;\n if (!mark.isInSet(marks) && parent.type.allowsMarkType(mark.type)) {\n var start = Math.max(pos, from),\n end = Math.min(pos + node.nodeSize, to);\n var newSet = mark.addToSet(marks);\n for (var i = 0; i < marks.length; i++) {\n if (!marks[i].isInSet(newSet)) {\n if (removing && removing.to == start && removing.mark.eq(marks[i])) removing.to = end;else removed.push(removing = new RemoveMarkStep(start, end, marks[i]));\n }\n }\n if (adding && adding.to == start) adding.to = end;else added.push(adding = new AddMarkStep(start, end, mark));\n }\n });\n removed.forEach(function (s) {\n return tr.step(s);\n });\n added.forEach(function (s) {\n return tr.step(s);\n });\n}\nfunction _removeMark(tr, from, to, mark) {\n var matched = [],\n step = 0;\n tr.doc.nodesBetween(from, to, function (node, pos) {\n if (!node.isInline) return;\n step++;\n var toRemove = null;\n if (mark instanceof prosemirrorModel.MarkType) {\n var set = node.marks,\n found;\n while (found = mark.isInSet(set)) {\n (toRemove || (toRemove = [])).push(found);\n set = found.removeFromSet(set);\n }\n } else if (mark) {\n if (mark.isInSet(node.marks)) toRemove = [mark];\n } else {\n toRemove = node.marks;\n }\n if (toRemove && toRemove.length) {\n var end = Math.min(pos + node.nodeSize, to);\n for (var i = 0; i < toRemove.length; i++) {\n var style = toRemove[i],\n _found = void 0;\n for (var j = 0; j < matched.length; j++) {\n var m = matched[j];\n if (m.step == step - 1 && style.eq(matched[j].style)) _found = m;\n }\n if (_found) {\n _found.to = end;\n _found.step = step;\n } else {\n matched.push({\n style: style,\n from: Math.max(pos, from),\n to: end,\n step: step\n });\n }\n }\n }\n });\n matched.forEach(function (m) {\n return tr.step(new RemoveMarkStep(m.from, m.to, m.style));\n });\n}\nfunction _clearIncompatible(tr, pos, parentType) {\n var match = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : parentType.contentMatch;\n var clearNewlines = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : true;\n var node = tr.doc.nodeAt(pos);\n var replSteps = [],\n cur = pos + 1;\n for (var i = 0; i < node.childCount; i++) {\n var child = node.child(i),\n end = cur + child.nodeSize;\n var allowed = match.matchType(child.type);\n if (!allowed) {\n replSteps.push(new ReplaceStep(cur, end, prosemirrorModel.Slice.empty));\n } else {\n match = allowed;\n for (var j = 0; j < child.marks.length; j++) if (!parentType.allowsMarkType(child.marks[j].type)) tr.step(new RemoveMarkStep(cur, end, child.marks[j]));\n if (clearNewlines && child.isText && parentType.whitespace != \"pre\") {\n var m = void 0,\n newline = /\\r?\\n|\\r/g,\n slice = void 0;\n while (m = newline.exec(child.text)) {\n if (!slice) slice = new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(parentType.schema.text(\" \", parentType.allowedMarks(child.marks))), 0, 0);\n replSteps.push(new ReplaceStep(cur + m.index, cur + m.index + m[0].length, slice));\n }\n }\n }\n cur = end;\n }\n if (!match.validEnd) {\n var fill = match.fillBefore(prosemirrorModel.Fragment.empty, true);\n tr.replace(cur, cur, new prosemirrorModel.Slice(fill, 0, 0));\n }\n for (var _i = replSteps.length - 1; _i >= 0; _i--) tr.step(replSteps[_i]);\n}\nfunction canCut(node, start, end) {\n return (start == 0 || node.canReplace(start, node.childCount)) && (end == node.childCount || node.canReplace(0, end));\n}\nfunction liftTarget(range) {\n var parent = range.parent;\n var content = parent.content.cutByIndex(range.startIndex, range.endIndex);\n for (var depth = range.depth, contentBefore = 0, contentAfter = 0;; --depth) {\n var node = range.$from.node(depth);\n var index = range.$from.index(depth) + contentBefore,\n endIndex = range.$to.indexAfter(depth) - contentAfter;\n if (depth < range.depth && node.canReplace(index, endIndex, content)) return depth;\n if (depth == 0 || node.type.spec.isolating || !canCut(node, index, endIndex)) break;\n if (index) contentBefore = 1;\n if (endIndex < node.childCount) contentAfter = 1;\n }\n return null;\n}\nfunction _lift(tr, range, target) {\n var $from = range.$from,\n $to = range.$to,\n depth = range.depth;\n var gapStart = $from.before(depth + 1),\n gapEnd = $to.after(depth + 1);\n var start = gapStart,\n end = gapEnd;\n var before = prosemirrorModel.Fragment.empty,\n openStart = 0;\n for (var d = depth, splitting = false; d > target; d--) if (splitting || $from.index(d) > 0) {\n splitting = true;\n before = prosemirrorModel.Fragment.from($from.node(d).copy(before));\n openStart++;\n } else {\n start--;\n }\n var after = prosemirrorModel.Fragment.empty,\n openEnd = 0;\n for (var _d = depth, _splitting = false; _d > target; _d--) if (_splitting || $to.after(_d + 1) < $to.end(_d)) {\n _splitting = true;\n after = prosemirrorModel.Fragment.from($to.node(_d).copy(after));\n openEnd++;\n } else {\n end++;\n }\n tr.step(new ReplaceAroundStep(start, end, gapStart, gapEnd, new prosemirrorModel.Slice(before.append(after), openStart, openEnd), before.size - openStart, true));\n}\nfunction findWrapping(range, nodeType) {\n var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var innerRange = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : range;\n var around = findWrappingOutside(range, nodeType);\n var inner = around && findWrappingInside(innerRange, nodeType);\n if (!inner) return null;\n return around.map(withAttrs).concat({\n type: nodeType,\n attrs: attrs\n }).concat(inner.map(withAttrs));\n}\nfunction withAttrs(type) {\n return {\n type: type,\n attrs: null\n };\n}\nfunction findWrappingOutside(range, type) {\n var parent = range.parent,\n startIndex = range.startIndex,\n endIndex = range.endIndex;\n var around = parent.contentMatchAt(startIndex).findWrapping(type);\n if (!around) return null;\n var outer = around.length ? around[0] : type;\n return parent.canReplaceWith(startIndex, endIndex, outer) ? around : null;\n}\nfunction findWrappingInside(range, type) {\n var parent = range.parent,\n startIndex = range.startIndex,\n endIndex = range.endIndex;\n var inner = parent.child(startIndex);\n var inside = type.contentMatch.findWrapping(inner.type);\n if (!inside) return null;\n var lastType = inside.length ? inside[inside.length - 1] : type;\n var innerMatch = lastType.contentMatch;\n for (var i = startIndex; innerMatch && i < endIndex; i++) innerMatch = innerMatch.matchType(parent.child(i).type);\n if (!innerMatch || !innerMatch.validEnd) return null;\n return inside;\n}\nfunction _wrap2(tr, range, wrappers) {\n var content = prosemirrorModel.Fragment.empty;\n for (var i = wrappers.length - 1; i >= 0; i--) {\n if (content.size) {\n var match = wrappers[i].type.contentMatch.matchFragment(content);\n if (!match || !match.validEnd) throw new RangeError(\"Wrapper type given to Transform.wrap does not form valid content of its parent wrapper\");\n }\n content = prosemirrorModel.Fragment.from(wrappers[i].type.create(wrappers[i].attrs, content));\n }\n var start = range.start,\n end = range.end;\n tr.step(new ReplaceAroundStep(start, end, start, end, new prosemirrorModel.Slice(content, 0, 0), wrappers.length, true));\n}\nfunction _setBlockType(tr, from, to, type, attrs) {\n if (!type.isTextblock) throw new RangeError(\"Type given to setBlockType should be a textblock\");\n var mapFrom = tr.steps.length;\n tr.doc.nodesBetween(from, to, function (node, pos) {\n var attrsHere = typeof attrs == \"function\" ? attrs(node) : attrs;\n if (node.isTextblock && !node.hasMarkup(type, attrsHere) && canChangeType(tr.doc, tr.mapping.slice(mapFrom).map(pos), type)) {\n var convertNewlines = null;\n if (type.schema.linebreakReplacement) {\n var pre = type.whitespace == \"pre\",\n supportLinebreak = !!type.contentMatch.matchType(type.schema.linebreakReplacement);\n if (pre && !supportLinebreak) convertNewlines = false;else if (!pre && supportLinebreak) convertNewlines = true;\n }\n if (convertNewlines === false) replaceLinebreaks(tr, node, pos, mapFrom);\n _clearIncompatible(tr, tr.mapping.slice(mapFrom).map(pos, 1), type, undefined, convertNewlines === null);\n var mapping = tr.mapping.slice(mapFrom);\n var startM = mapping.map(pos, 1),\n endM = mapping.map(pos + node.nodeSize, 1);\n tr.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(type.create(attrsHere, null, node.marks)), 0, 0), 1, true));\n if (convertNewlines === true) replaceNewlines(tr, node, pos, mapFrom);\n return false;\n }\n });\n}\nfunction replaceNewlines(tr, node, pos, mapFrom) {\n node.forEach(function (child, offset) {\n if (child.isText) {\n var m,\n newline = /\\r?\\n|\\r/g;\n while (m = newline.exec(child.text)) {\n var start = tr.mapping.slice(mapFrom).map(pos + 1 + offset + m.index);\n tr.replaceWith(start, start + 1, node.type.schema.linebreakReplacement.create());\n }\n }\n });\n}\nfunction replaceLinebreaks(tr, node, pos, mapFrom) {\n node.forEach(function (child, offset) {\n if (child.type == child.type.schema.linebreakReplacement) {\n var start = tr.mapping.slice(mapFrom).map(pos + 1 + offset);\n tr.replaceWith(start, start + 1, node.type.schema.text(\"\\n\"));\n }\n });\n}\nfunction canChangeType(doc, pos, type) {\n var $pos = doc.resolve(pos),\n index = $pos.index();\n return $pos.parent.canReplaceWith(index, index + 1, type);\n}\nfunction _setNodeMarkup(tr, pos, type, attrs, marks) {\n var node = tr.doc.nodeAt(pos);\n if (!node) throw new RangeError(\"No node at given position\");\n if (!type) type = node.type;\n var newNode = type.create(attrs, null, marks || node.marks);\n if (node.isLeaf) return tr.replaceWith(pos, pos + node.nodeSize, newNode);\n if (!type.validContent(node.content)) throw new RangeError(\"Invalid content for node type \" + type.name);\n tr.step(new ReplaceAroundStep(pos, pos + node.nodeSize, pos + 1, pos + node.nodeSize - 1, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(newNode), 0, 0), 1, true));\n}\nfunction canSplit(doc, pos) {\n var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;\n var typesAfter = arguments.length > 3 ? arguments[3] : undefined;\n var $pos = doc.resolve(pos),\n base = $pos.depth - depth;\n var innerType = typesAfter && typesAfter[typesAfter.length - 1] || $pos.parent;\n if (base < 0 || $pos.parent.type.spec.isolating || !$pos.parent.canReplace($pos.index(), $pos.parent.childCount) || !innerType.type.validContent($pos.parent.content.cutByIndex($pos.index(), $pos.parent.childCount))) return false;\n for (var d = $pos.depth - 1, i = depth - 2; d > base; d--, i--) {\n var node = $pos.node(d),\n _index = $pos.index(d);\n if (node.type.spec.isolating) return false;\n var rest = node.content.cutByIndex(_index, node.childCount);\n var overrideChild = typesAfter && typesAfter[i + 1];\n if (overrideChild) rest = rest.replaceChild(0, overrideChild.type.create(overrideChild.attrs));\n var after = typesAfter && typesAfter[i] || node;\n if (!node.canReplace(_index + 1, node.childCount) || !after.type.validContent(rest)) return false;\n }\n var index = $pos.indexAfter(base);\n var baseType = typesAfter && typesAfter[0];\n return $pos.node(base).canReplaceWith(index, index, baseType ? baseType.type : $pos.node(base + 1).type);\n}\nfunction _split(tr, pos) {\n var depth = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;\n var typesAfter = arguments.length > 3 ? arguments[3] : undefined;\n var $pos = tr.doc.resolve(pos),\n before = prosemirrorModel.Fragment.empty,\n after = prosemirrorModel.Fragment.empty;\n for (var d = $pos.depth, e = $pos.depth - depth, i = depth - 1; d > e; d--, i--) {\n before = prosemirrorModel.Fragment.from($pos.node(d).copy(before));\n var typeAfter = typesAfter && typesAfter[i];\n after = prosemirrorModel.Fragment.from(typeAfter ? typeAfter.type.create(typeAfter.attrs, after) : $pos.node(d).copy(after));\n }\n tr.step(new ReplaceStep(pos, pos, new prosemirrorModel.Slice(before.append(after), depth, depth), true));\n}\nfunction canJoin(doc, pos) {\n var $pos = doc.resolve(pos),\n index = $pos.index();\n return joinable($pos.nodeBefore, $pos.nodeAfter) && $pos.parent.canReplace(index, index + 1);\n}\nfunction canAppendWithSubstitutedLinebreaks(a, b) {\n if (!b.content.size) a.type.compatibleContent(b.type);\n var match = a.contentMatchAt(a.childCount);\n var linebreakReplacement = a.type.schema.linebreakReplacement;\n for (var i = 0; i < b.childCount; i++) {\n var child = b.child(i);\n var type = child.type == linebreakReplacement ? a.type.schema.nodes.text : child.type;\n match = match.matchType(type);\n if (!match) return false;\n if (!a.type.allowsMarks(child.marks)) return false;\n }\n return match.validEnd;\n}\nfunction joinable(a, b) {\n return !!(a && b && !a.isLeaf && canAppendWithSubstitutedLinebreaks(a, b));\n}\nfunction joinPoint(doc, pos) {\n var dir = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;\n var $pos = doc.resolve(pos);\n for (var d = $pos.depth;; d--) {\n var before = void 0,\n after = void 0,\n index = $pos.index(d);\n if (d == $pos.depth) {\n before = $pos.nodeBefore;\n after = $pos.nodeAfter;\n } else if (dir > 0) {\n before = $pos.node(d + 1);\n index++;\n after = $pos.node(d).maybeChild(index);\n } else {\n before = $pos.node(d).maybeChild(index - 1);\n after = $pos.node(d + 1);\n }\n if (before && !before.isTextblock && joinable(before, after) && $pos.node(d).canReplace(index, index + 1)) return pos;\n if (d == 0) break;\n pos = dir < 0 ? $pos.before(d) : $pos.after(d);\n }\n}\nfunction _join(tr, pos, depth) {\n var convertNewlines = null;\n var linebreakReplacement = tr.doc.type.schema.linebreakReplacement;\n var $before = tr.doc.resolve(pos - depth),\n beforeType = $before.node().type;\n if (linebreakReplacement && beforeType.inlineContent) {\n var pre = beforeType.whitespace == \"pre\";\n var supportLinebreak = !!beforeType.contentMatch.matchType(linebreakReplacement);\n if (pre && !supportLinebreak) convertNewlines = false;else if (!pre && supportLinebreak) convertNewlines = true;\n }\n var mapFrom = tr.steps.length;\n if (convertNewlines === false) {\n var $after = tr.doc.resolve(pos + depth);\n replaceLinebreaks(tr, $after.node(), $after.before(), mapFrom);\n }\n if (beforeType.inlineContent) _clearIncompatible(tr, pos + depth - 1, beforeType, $before.node().contentMatchAt($before.index()), convertNewlines == null);\n var mapping = tr.mapping.slice(mapFrom),\n start = mapping.map(pos - depth);\n tr.step(new ReplaceStep(start, mapping.map(pos + depth, -1), prosemirrorModel.Slice.empty, true));\n if (convertNewlines === true) {\n var $full = tr.doc.resolve(start);\n replaceNewlines(tr, $full.node(), $full.before(), tr.steps.length);\n }\n return tr;\n}\nfunction insertPoint(doc, pos, nodeType) {\n var $pos = doc.resolve(pos);\n if ($pos.parent.canReplaceWith($pos.index(), $pos.index(), nodeType)) return pos;\n if ($pos.parentOffset == 0) for (var d = $pos.depth - 1; d >= 0; d--) {\n var index = $pos.index(d);\n if ($pos.node(d).canReplaceWith(index, index, nodeType)) return $pos.before(d + 1);\n if (index > 0) return null;\n }\n if ($pos.parentOffset == $pos.parent.content.size) for (var _d2 = $pos.depth - 1; _d2 >= 0; _d2--) {\n var _index2 = $pos.indexAfter(_d2);\n if ($pos.node(_d2).canReplaceWith(_index2, _index2, nodeType)) return $pos.after(_d2 + 1);\n if (_index2 < $pos.node(_d2).childCount) return null;\n }\n return null;\n}\nfunction dropPoint(doc, pos, slice) {\n var $pos = doc.resolve(pos);\n if (!slice.content.size) return pos;\n var content = slice.content;\n for (var i = 0; i < slice.openStart; i++) content = content.firstChild.content;\n for (var pass = 1; pass <= (slice.openStart == 0 && slice.size ? 2 : 1); pass++) {\n for (var d = $pos.depth; d >= 0; d--) {\n var bias = d == $pos.depth ? 0 : $pos.pos <= ($pos.start(d + 1) + $pos.end(d + 1)) / 2 ? -1 : 1;\n var insertPos = $pos.index(d) + (bias > 0 ? 1 : 0);\n var parent = $pos.node(d),\n fits = false;\n if (pass == 1) {\n fits = parent.canReplace(insertPos, insertPos, content);\n } else {\n var wrapping = parent.contentMatchAt(insertPos).findWrapping(content.firstChild.type);\n fits = wrapping && parent.canReplaceWith(insertPos, insertPos, wrapping[0]);\n }\n if (fits) return bias == 0 ? $pos.pos : bias < 0 ? $pos.before(d + 1) : $pos.after(d + 1);\n }\n }\n return null;\n}\nfunction replaceStep(doc, from) {\n var to = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : from;\n var slice = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : prosemirrorModel.Slice.empty;\n if (from == to && !slice.size) return null;\n var $from = doc.resolve(from),\n $to = doc.resolve(to);\n if (fitsTrivially($from, $to, slice)) return new ReplaceStep(from, to, slice);\n return new Fitter($from, $to, slice).fit();\n}\nfunction fitsTrivially($from, $to, slice) {\n return !slice.openStart && !slice.openEnd && $from.start() == $to.start() && $from.parent.canReplace($from.index(), $to.index(), slice.content);\n}\nvar Fitter = function () {\n function Fitter($from, $to, unplaced) {\n _classCallCheck(this, Fitter);\n this.$from = $from;\n this.$to = $to;\n this.unplaced = unplaced;\n this.frontier = [];\n this.placed = prosemirrorModel.Fragment.empty;\n for (var i = 0; i <= $from.depth; i++) {\n var node = $from.node(i);\n this.frontier.push({\n type: node.type,\n match: node.contentMatchAt($from.indexAfter(i))\n });\n }\n for (var _i2 = $from.depth; _i2 > 0; _i2--) this.placed = prosemirrorModel.Fragment.from($from.node(_i2).copy(this.placed));\n }\n _createClass(Fitter, [{\n key: \"depth\",\n get: function get() {\n return this.frontier.length - 1;\n }\n }, {\n key: \"fit\",\n value: function fit() {\n while (this.unplaced.size) {\n var fit = this.findFittable();\n if (fit) this.placeNodes(fit);else this.openMore() || this.dropNode();\n }\n var moveInline = this.mustMoveInline(),\n placedSize = this.placed.size - this.depth - this.$from.depth;\n var $from = this.$from,\n $to = this.close(moveInline < 0 ? this.$to : $from.doc.resolve(moveInline));\n if (!$to) return null;\n var content = this.placed,\n openStart = $from.depth,\n openEnd = $to.depth;\n while (openStart && openEnd && content.childCount == 1) {\n content = content.firstChild.content;\n openStart--;\n openEnd--;\n }\n var slice = new prosemirrorModel.Slice(content, openStart, openEnd);\n if (moveInline > -1) return new ReplaceAroundStep($from.pos, moveInline, this.$to.pos, this.$to.end(), slice, placedSize);\n if (slice.size || $from.pos != this.$to.pos) return new ReplaceStep($from.pos, $to.pos, slice);\n return null;\n }\n }, {\n key: \"findFittable\",\n value: function findFittable() {\n var startDepth = this.unplaced.openStart;\n for (var cur = this.unplaced.content, d = 0, openEnd = this.unplaced.openEnd; d < startDepth; d++) {\n var node = cur.firstChild;\n if (cur.childCount > 1) openEnd = 0;\n if (node.type.spec.isolating && openEnd <= d) {\n startDepth = d;\n break;\n }\n cur = node.content;\n }\n for (var pass = 1; pass <= 2; pass++) {\n for (var sliceDepth = pass == 1 ? startDepth : this.unplaced.openStart; sliceDepth >= 0; sliceDepth--) {\n var fragment = void 0,\n parent = null;\n if (sliceDepth) {\n parent = contentAt(this.unplaced.content, sliceDepth - 1).firstChild;\n fragment = parent.content;\n } else {\n fragment = this.unplaced.content;\n }\n var first = fragment.firstChild;\n for (var frontierDepth = this.depth; frontierDepth >= 0; frontierDepth--) {\n var _this$frontier$fronti = this.frontier[frontierDepth],\n type = _this$frontier$fronti.type,\n match = _this$frontier$fronti.match,\n _wrap = void 0,\n inject = null;\n if (pass == 1 && (first ? match.matchType(first.type) || (inject = match.fillBefore(prosemirrorModel.Fragment.from(first), false)) : parent && type.compatibleContent(parent.type))) return {\n sliceDepth: sliceDepth,\n frontierDepth: frontierDepth,\n parent: parent,\n inject: inject\n };else if (pass == 2 && first && (_wrap = match.findWrapping(first.type))) return {\n sliceDepth: sliceDepth,\n frontierDepth: frontierDepth,\n parent: parent,\n wrap: _wrap\n };\n if (parent && match.matchType(parent.type)) break;\n }\n }\n }\n }\n }, {\n key: \"openMore\",\n value: function openMore() {\n var _this$unplaced = this.unplaced,\n content = _this$unplaced.content,\n openStart = _this$unplaced.openStart,\n openEnd = _this$unplaced.openEnd;\n if (maxOpen(content, -1) <= openStart) return false;\n if (this.unplaced.size > 1 && maxOpen(content, 1) > openEnd) openEnd++;\n this.unplaced = new prosemirrorModel.Slice(content, openStart + 1, openEnd);\n return true;\n }\n }, {\n key: \"dropNode\",\n value: function dropNode() {\n var _this$unplaced2 = this.unplaced,\n content = _this$unplaced2.content,\n openStart = _this$unplaced2.openStart,\n openEnd = _this$unplaced2.openEnd;\n var inner = contentAt(content, openStart);\n if (inner.childCount <= 1 && openStart > 0) {\n var openAtEnd = content.size - openStart <= openStart + inner.size;\n this.unplaced = new prosemirrorModel.Slice(dropFromFragment(content, openStart - 1, 1), openStart - 1, openAtEnd ? openStart - 1 : openEnd);\n } else {\n this.unplaced = new prosemirrorModel.Slice(dropFromFragment(content, openStart, 1), openStart, openEnd);\n }\n }\n }, {\n key: \"placeNodes\",\n value: function placeNodes(_ref) {\n var sliceDepth = _ref.sliceDepth,\n frontierDepth = _ref.frontierDepth,\n parent = _ref.parent,\n inject = _ref.inject,\n wrap = _ref.wrap;\n while (this.depth > frontierDepth) this.closeFrontierNode();\n if (wrap) for (var i = 0; i < wrap.length; i++) this.openFrontierNode(wrap[i]);\n var slice = this.unplaced,\n fragment = parent ? parent.content : slice.content;\n var openStart = slice.openStart - sliceDepth;\n var taken = 0,\n add = [];\n var _this$frontier$fronti2 = this.frontier[frontierDepth],\n match = _this$frontier$fronti2.match,\n type = _this$frontier$fronti2.type;\n if (inject) {\n for (var _i3 = 0; _i3 < inject.childCount; _i3++) add.push(inject.child(_i3));\n match = match.matchFragment(inject);\n }\n var openEndCount = fragment.size + sliceDepth - (slice.content.size - slice.openEnd);\n while (taken < fragment.childCount) {\n var next = fragment.child(taken),\n matches = match.matchType(next.type);\n if (!matches) break;\n taken++;\n if (taken > 1 || openStart == 0 || next.content.size) {\n match = matches;\n add.push(closeNodeStart(next.mark(type.allowedMarks(next.marks)), taken == 1 ? openStart : 0, taken == fragment.childCount ? openEndCount : -1));\n }\n }\n var toEnd = taken == fragment.childCount;\n if (!toEnd) openEndCount = -1;\n this.placed = addToFragment(this.placed, frontierDepth, prosemirrorModel.Fragment.from(add));\n this.frontier[frontierDepth].match = match;\n if (toEnd && openEndCount < 0 && parent && parent.type == this.frontier[this.depth].type && this.frontier.length > 1) this.closeFrontierNode();\n for (var _i4 = 0, cur = fragment; _i4 < openEndCount; _i4++) {\n var node = cur.lastChild;\n this.frontier.push({\n type: node.type,\n match: node.contentMatchAt(node.childCount)\n });\n cur = node.content;\n }\n this.unplaced = !toEnd ? new prosemirrorModel.Slice(dropFromFragment(slice.content, sliceDepth, taken), slice.openStart, slice.openEnd) : sliceDepth == 0 ? prosemirrorModel.Slice.empty : new prosemirrorModel.Slice(dropFromFragment(slice.content, sliceDepth - 1, 1), sliceDepth - 1, openEndCount < 0 ? slice.openEnd : sliceDepth - 1);\n }\n }, {\n key: \"mustMoveInline\",\n value: function mustMoveInline() {\n if (!this.$to.parent.isTextblock) return -1;\n var top = this.frontier[this.depth],\n level;\n if (!top.type.isTextblock || !contentAfterFits(this.$to, this.$to.depth, top.type, top.match, false) || this.$to.depth == this.depth && (level = this.findCloseLevel(this.$to)) && level.depth == this.depth) return -1;\n var depth = this.$to.depth,\n after = this.$to.after(depth);\n while (depth > 1 && after == this.$to.end(--depth)) ++after;\n return after;\n }\n }, {\n key: \"findCloseLevel\",\n value: function findCloseLevel($to) {\n scan: for (var i = Math.min(this.depth, $to.depth); i >= 0; i--) {\n var _this$frontier$i = this.frontier[i],\n match = _this$frontier$i.match,\n type = _this$frontier$i.type;\n var dropInner = i < $to.depth && $to.end(i + 1) == $to.pos + ($to.depth - (i + 1));\n var fit = contentAfterFits($to, i, type, match, dropInner);\n if (!fit) continue;\n for (var d = i - 1; d >= 0; d--) {\n var _this$frontier$d = this.frontier[d],\n _match = _this$frontier$d.match,\n _type = _this$frontier$d.type;\n var matches = contentAfterFits($to, d, _type, _match, true);\n if (!matches || matches.childCount) continue scan;\n }\n return {\n depth: i,\n fit: fit,\n move: dropInner ? $to.doc.resolve($to.after(i + 1)) : $to\n };\n }\n }\n }, {\n key: \"close\",\n value: function close($to) {\n var close = this.findCloseLevel($to);\n if (!close) return null;\n while (this.depth > close.depth) this.closeFrontierNode();\n if (close.fit.childCount) this.placed = addToFragment(this.placed, close.depth, close.fit);\n $to = close.move;\n for (var d = close.depth + 1; d <= $to.depth; d++) {\n var node = $to.node(d),\n add = node.type.contentMatch.fillBefore(node.content, true, $to.index(d));\n this.openFrontierNode(node.type, node.attrs, add);\n }\n return $to;\n }\n }, {\n key: \"openFrontierNode\",\n value: function openFrontierNode(type) {\n var attrs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var content = arguments.length > 2 ? arguments[2] : undefined;\n var top = this.frontier[this.depth];\n top.match = top.match.matchType(type);\n this.placed = addToFragment(this.placed, this.depth, prosemirrorModel.Fragment.from(type.create(attrs, content)));\n this.frontier.push({\n type: type,\n match: type.contentMatch\n });\n }\n }, {\n key: \"closeFrontierNode\",\n value: function closeFrontierNode() {\n var open = this.frontier.pop();\n var add = open.match.fillBefore(prosemirrorModel.Fragment.empty, true);\n if (add.childCount) this.placed = addToFragment(this.placed, this.frontier.length, add);\n }\n }]);\n return Fitter;\n}();\nfunction dropFromFragment(fragment, depth, count) {\n if (depth == 0) return fragment.cutByIndex(count, fragment.childCount);\n return fragment.replaceChild(0, fragment.firstChild.copy(dropFromFragment(fragment.firstChild.content, depth - 1, count)));\n}\nfunction addToFragment(fragment, depth, content) {\n if (depth == 0) return fragment.append(content);\n return fragment.replaceChild(fragment.childCount - 1, fragment.lastChild.copy(addToFragment(fragment.lastChild.content, depth - 1, content)));\n}\nfunction contentAt(fragment, depth) {\n for (var i = 0; i < depth; i++) fragment = fragment.firstChild.content;\n return fragment;\n}\nfunction closeNodeStart(node, openStart, openEnd) {\n if (openStart <= 0) return node;\n var frag = node.content;\n if (openStart > 1) frag = frag.replaceChild(0, closeNodeStart(frag.firstChild, openStart - 1, frag.childCount == 1 ? openEnd - 1 : 0));\n if (openStart > 0) {\n frag = node.type.contentMatch.fillBefore(frag).append(frag);\n if (openEnd <= 0) frag = frag.append(node.type.contentMatch.matchFragment(frag).fillBefore(prosemirrorModel.Fragment.empty, true));\n }\n return node.copy(frag);\n}\nfunction contentAfterFits($to, depth, type, match, open) {\n var node = $to.node(depth),\n index = open ? $to.indexAfter(depth) : $to.index(depth);\n if (index == node.childCount && !type.compatibleContent(node.type)) return null;\n var fit = match.fillBefore(node.content, true, index);\n return fit && !invalidMarks(type, node.content, index) ? fit : null;\n}\nfunction invalidMarks(type, fragment, start) {\n for (var i = start; i < fragment.childCount; i++) if (!type.allowsMarks(fragment.child(i).marks)) return true;\n return false;\n}\nfunction definesContent(type) {\n return type.spec.defining || type.spec.definingForContent;\n}\nfunction maxOpen(frag, side) {\n for (var count = 0;; count++) {\n var ch = side < 0 ? frag.firstChild : frag.lastChild;\n if (!ch || ch.isAtom) return count;\n frag = ch.content;\n }\n}\nfunction _replaceRange(tr, from, to, slice) {\n if (!slice.size) return tr.deleteRange(from, to);\n var $from = tr.doc.resolve(from),\n $to = tr.doc.resolve(to);\n if (fitsTrivially($from, $to, slice)) return tr.step(new ReplaceStep(from, to, slice));\n var targetDepths = coveredDepths($from, $to);\n if (targetDepths[targetDepths.length - 1] == 0) targetDepths.pop();\n var preferredTarget = -($from.depth + 1);\n targetDepths.unshift(preferredTarget);\n for (var d = $from.depth, pos = $from.pos - 1; d > 0; d--, pos--) {\n var spec = $from.node(d).type.spec;\n if (spec.defining || spec.definingAsContext || spec.isolating) break;\n if (targetDepths.indexOf(d) > -1) preferredTarget = d;else if ($from.before(d) == pos) targetDepths.splice(1, 0, -d);\n }\n var preferredTargetIndex = targetDepths.indexOf(preferredTarget);\n var leftNodes = [],\n preferredDepth = slice.openStart;\n for (var content = slice.content, i = 0;; i++) {\n var node = content.firstChild;\n leftNodes.push(node);\n if (i == slice.openStart) break;\n content = node.content;\n }\n for (var _d3 = preferredDepth - 1; _d3 >= 0; _d3--) {\n var leftNode = leftNodes[_d3],\n def = definesContent(leftNode.type);\n if (def && !leftNode.sameMarkup($from.node(Math.abs(preferredTarget) - 1))) preferredDepth = _d3;else if (def || !leftNode.type.isTextblock) break;\n }\n for (var j = slice.openStart; j >= 0; j--) {\n var openDepth = (j + preferredDepth + 1) % (slice.openStart + 1);\n var insert = leftNodes[openDepth];\n if (!insert) continue;\n for (var _i5 = 0; _i5 < targetDepths.length; _i5++) {\n var targetDepth = targetDepths[(_i5 + preferredTargetIndex) % targetDepths.length],\n expand = true;\n if (targetDepth < 0) {\n expand = false;\n targetDepth = -targetDepth;\n }\n var parent = $from.node(targetDepth - 1),\n index = $from.index(targetDepth - 1);\n if (parent.canReplaceWith(index, index, insert.type, insert.marks)) return tr.replace($from.before(targetDepth), expand ? $to.after(targetDepth) : to, new prosemirrorModel.Slice(closeFragment(slice.content, 0, slice.openStart, openDepth), openDepth, slice.openEnd));\n }\n }\n var startSteps = tr.steps.length;\n for (var _i6 = targetDepths.length - 1; _i6 >= 0; _i6--) {\n tr.replace(from, to, slice);\n if (tr.steps.length > startSteps) break;\n var depth = targetDepths[_i6];\n if (depth < 0) continue;\n from = $from.before(depth);\n to = $to.after(depth);\n }\n}\nfunction closeFragment(fragment, depth, oldOpen, newOpen, parent) {\n if (depth < oldOpen) {\n var first = fragment.firstChild;\n fragment = fragment.replaceChild(0, first.copy(closeFragment(first.content, depth + 1, oldOpen, newOpen, first)));\n }\n if (depth > newOpen) {\n var match = parent.contentMatchAt(0);\n var start = match.fillBefore(fragment).append(fragment);\n fragment = start.append(match.matchFragment(start).fillBefore(prosemirrorModel.Fragment.empty, true));\n }\n return fragment;\n}\nfunction _replaceRangeWith(tr, from, to, node) {\n if (!node.isInline && from == to && tr.doc.resolve(from).parent.content.size) {\n var point = insertPoint(tr.doc, from, node.type);\n if (point != null) from = to = point;\n }\n tr.replaceRange(from, to, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(node), 0, 0));\n}\nfunction _deleteRange(tr, from, to) {\n var $from = tr.doc.resolve(from),\n $to = tr.doc.resolve(to);\n if ($from.parent.isTextblock && $to.parent.isTextblock && $from.start() != $to.start() && $from.parentOffset == 0 && $to.parentOffset == 0) {\n var shared = $from.sharedDepth(to),\n isolated = false;\n for (var d = $from.depth; d > shared; d--) if ($from.node(d).type.spec.isolating) isolated = true;\n for (var _d4 = $to.depth; _d4 > shared; _d4--) if ($to.node(_d4).type.spec.isolating) isolated = true;\n if (!isolated) {\n for (var _d5 = $from.depth; _d5 > 0 && from == $from.start(_d5); _d5--) from = $from.before(_d5);\n for (var _d6 = $to.depth; _d6 > 0 && to == $to.start(_d6); _d6--) to = $to.before(_d6);\n $from = tr.doc.resolve(from);\n $to = tr.doc.resolve(to);\n }\n }\n var covered = coveredDepths($from, $to);\n for (var i = 0; i < covered.length; i++) {\n var depth = covered[i],\n last = i == covered.length - 1;\n if (last && depth == 0 || $from.node(depth).type.contentMatch.validEnd) return tr[\"delete\"]($from.start(depth), $to.end(depth));\n if (depth > 0 && (last || $from.node(depth - 1).canReplace($from.index(depth - 1), $to.indexAfter(depth - 1)))) return tr[\"delete\"]($from.before(depth), $to.after(depth));\n }\n for (var _d7 = 1; _d7 <= $from.depth && _d7 <= $to.depth; _d7++) {\n if (from - $from.start(_d7) == $from.depth - _d7 && to > $from.end(_d7) && $to.end(_d7) - to != $to.depth - _d7 && $from.start(_d7 - 1) == $to.start(_d7 - 1) && $from.node(_d7 - 1).canReplace($from.index(_d7 - 1), $to.index(_d7 - 1))) return tr[\"delete\"]($from.before(_d7), to);\n }\n tr[\"delete\"](from, to);\n}\nfunction coveredDepths($from, $to) {\n var result = [],\n minDepth = Math.min($from.depth, $to.depth);\n for (var d = minDepth; d >= 0; d--) {\n var start = $from.start(d);\n if (start < $from.pos - ($from.depth - d) || $to.end(d) > $to.pos + ($to.depth - d) || $from.node(d).type.spec.isolating || $to.node(d).type.spec.isolating) break;\n if (start == $to.start(d) || d == $from.depth && d == $to.depth && $from.parent.inlineContent && $to.parent.inlineContent && d && $to.start(d - 1) == start - 1) result.push(d);\n }\n return result;\n}\nvar AttrStep = function (_Step7) {\n _inherits(AttrStep, _Step7);\n var _super7 = _createSuper(AttrStep);\n function AttrStep(pos, attr, value) {\n var _this9;\n _classCallCheck(this, AttrStep);\n _this9 = _super7.call(this);\n _this9.pos = pos;\n _this9.attr = attr;\n _this9.value = value;\n return _this9;\n }\n _createClass(AttrStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var node = doc.nodeAt(this.pos);\n if (!node) return StepResult.fail(\"No node at attribute step's position\");\n var attrs = Object.create(null);\n for (var name in node.attrs) attrs[name] = node.attrs[name];\n attrs[this.attr] = this.value;\n var updated = node.type.create(attrs, null, node.marks);\n return StepResult.fromReplace(doc, this.pos, this.pos + 1, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(updated), 0, node.isLeaf ? 0 : 1));\n }\n }, {\n key: \"getMap\",\n value: function getMap() {\n return StepMap.empty;\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n return new AttrStep(this.pos, this.attr, doc.nodeAt(this.pos).attrs[this.attr]);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n var pos = mapping.mapResult(this.pos, 1);\n return pos.deletedAfter ? null : new AttrStep(pos.pos, this.attr, this.value);\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"attr\",\n pos: this.pos,\n attr: this.attr,\n value: this.value\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.pos != \"number\" || typeof json.attr != \"string\") throw new RangeError(\"Invalid input for AttrStep.fromJSON\");\n return new AttrStep(json.pos, json.attr, json.value);\n }\n }]);\n return AttrStep;\n}(Step);\nStep.jsonID(\"attr\", AttrStep);\nvar DocAttrStep = function (_Step8) {\n _inherits(DocAttrStep, _Step8);\n var _super8 = _createSuper(DocAttrStep);\n function DocAttrStep(attr, value) {\n var _this10;\n _classCallCheck(this, DocAttrStep);\n _this10 = _super8.call(this);\n _this10.attr = attr;\n _this10.value = value;\n return _this10;\n }\n _createClass(DocAttrStep, [{\n key: \"apply\",\n value: function apply(doc) {\n var attrs = Object.create(null);\n for (var name in doc.attrs) attrs[name] = doc.attrs[name];\n attrs[this.attr] = this.value;\n var updated = doc.type.create(attrs, doc.content, doc.marks);\n return StepResult.ok(updated);\n }\n }, {\n key: \"getMap\",\n value: function getMap() {\n return StepMap.empty;\n }\n }, {\n key: \"invert\",\n value: function invert(doc) {\n return new DocAttrStep(this.attr, doc.attrs[this.attr]);\n }\n }, {\n key: \"map\",\n value: function map(mapping) {\n return this;\n }\n }, {\n key: \"toJSON\",\n value: function toJSON() {\n return {\n stepType: \"docAttr\",\n attr: this.attr,\n value: this.value\n };\n }\n }], [{\n key: \"fromJSON\",\n value: function fromJSON(schema, json) {\n if (typeof json.attr != \"string\") throw new RangeError(\"Invalid input for DocAttrStep.fromJSON\");\n return new DocAttrStep(json.attr, json.value);\n }\n }]);\n return DocAttrStep;\n}(Step);\nStep.jsonID(\"docAttr\", DocAttrStep);\nexports.TransformError = function (_Error) {\n _inherits(TransformError, _Error);\n var _super9 = _createSuper(TransformError);\n function TransformError() {\n _classCallCheck(this, TransformError);\n return _super9.apply(this, arguments);\n }\n return _createClass(TransformError);\n}(_wrapNativeSuper(Error));\nexports.TransformError = function TransformError(message) {\n var err = Error.call(this, message);\n err.__proto__ = TransformError.prototype;\n return err;\n};\nexports.TransformError.prototype = Object.create(Error.prototype);\nexports.TransformError.prototype.constructor = exports.TransformError;\nexports.TransformError.prototype.name = \"TransformError\";\nvar Transform = function () {\n function Transform(doc) {\n _classCallCheck(this, Transform);\n this.doc = doc;\n this.steps = [];\n this.docs = [];\n this.mapping = new Mapping();\n }\n _createClass(Transform, [{\n key: \"before\",\n get: function get() {\n return this.docs.length ? this.docs[0] : this.doc;\n }\n }, {\n key: \"step\",\n value: function step(_step) {\n var result = this.maybeStep(_step);\n if (result.failed) throw new exports.TransformError(result.failed);\n return this;\n }\n }, {\n key: \"maybeStep\",\n value: function maybeStep(step) {\n var result = step.apply(this.doc);\n if (!result.failed) this.addStep(step, result.doc);\n return result;\n }\n }, {\n key: \"docChanged\",\n get: function get() {\n return this.steps.length > 0;\n }\n }, {\n key: \"changedRange\",\n value: function changedRange() {\n var from = 1e9,\n to = -1e9;\n for (var i = 0; i < this.mapping.maps.length; i++) {\n var map = this.mapping.maps[i];\n if (i) {\n from = map.map(from, 1);\n to = map.map(to, -1);\n }\n map.forEach(function (_f, _t, fromB, toB) {\n from = Math.min(from, fromB);\n to = Math.max(to, toB);\n });\n }\n return from == 1e9 ? null : {\n from: from,\n to: to\n };\n }\n }, {\n key: \"addStep\",\n value: function addStep(step, doc) {\n this.docs.push(this.doc);\n this.steps.push(step);\n this.mapping.appendMap(step.getMap());\n this.doc = doc;\n }\n }, {\n key: \"replace\",\n value: function replace(from) {\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : from;\n var slice = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : prosemirrorModel.Slice.empty;\n var step = replaceStep(this.doc, from, to, slice);\n if (step) this.step(step);\n return this;\n }\n }, {\n key: \"replaceWith\",\n value: function replaceWith(from, to, content) {\n return this.replace(from, to, new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(content), 0, 0));\n }\n }, {\n key: \"delete\",\n value: function _delete(from, to) {\n return this.replace(from, to, prosemirrorModel.Slice.empty);\n }\n }, {\n key: \"insert\",\n value: function insert(pos, content) {\n return this.replaceWith(pos, pos, content);\n }\n }, {\n key: \"replaceRange\",\n value: function replaceRange(from, to, slice) {\n _replaceRange(this, from, to, slice);\n return this;\n }\n }, {\n key: \"replaceRangeWith\",\n value: function replaceRangeWith(from, to, node) {\n _replaceRangeWith(this, from, to, node);\n return this;\n }\n }, {\n key: \"deleteRange\",\n value: function deleteRange(from, to) {\n _deleteRange(this, from, to);\n return this;\n }\n }, {\n key: \"lift\",\n value: function lift(range, target) {\n _lift(this, range, target);\n return this;\n }\n }, {\n key: \"join\",\n value: function join(pos) {\n var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n _join(this, pos, depth);\n return this;\n }\n }, {\n key: \"wrap\",\n value: function wrap(range, wrappers) {\n _wrap2(this, range, wrappers);\n return this;\n }\n }, {\n key: \"setBlockType\",\n value: function setBlockType(from) {\n var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : from;\n var type = arguments.length > 2 ? arguments[2] : undefined;\n var attrs = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null;\n _setBlockType(this, from, to, type, attrs);\n return this;\n }\n }, {\n key: \"setNodeMarkup\",\n value: function setNodeMarkup(pos, type) {\n var attrs = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;\n var marks = arguments.length > 3 ? arguments[3] : undefined;\n _setNodeMarkup(this, pos, type, attrs, marks);\n return this;\n }\n }, {\n key: \"setNodeAttribute\",\n value: function setNodeAttribute(pos, attr, value) {\n this.step(new AttrStep(pos, attr, value));\n return this;\n }\n }, {\n key: \"setDocAttribute\",\n value: function setDocAttribute(attr, value) {\n this.step(new DocAttrStep(attr, value));\n return this;\n }\n }, {\n key: \"addNodeMark\",\n value: function addNodeMark(pos, mark) {\n this.step(new AddNodeMarkStep(pos, mark));\n return this;\n }\n }, {\n key: \"removeNodeMark\",\n value: function removeNodeMark(pos, mark) {\n var node = this.doc.nodeAt(pos);\n if (!node) throw new RangeError(\"No node at position \" + pos);\n if (mark instanceof prosemirrorModel.Mark) {\n if (mark.isInSet(node.marks)) this.step(new RemoveNodeMarkStep(pos, mark));\n } else {\n var set = node.marks,\n found,\n steps = [];\n while (found = mark.isInSet(set)) {\n steps.push(new RemoveNodeMarkStep(pos, found));\n set = found.removeFromSet(set);\n }\n for (var i = steps.length - 1; i >= 0; i--) this.step(steps[i]);\n }\n return this;\n }\n }, {\n key: \"split\",\n value: function split(pos) {\n var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n var typesAfter = arguments.length > 2 ? arguments[2] : undefined;\n _split(this, pos, depth, typesAfter);\n return this;\n }\n }, {\n key: \"addMark\",\n value: function addMark(from, to, mark) {\n _addMark(this, from, to, mark);\n return this;\n }\n }, {\n key: \"removeMark\",\n value: function removeMark(from, to, mark) {\n _removeMark(this, from, to, mark);\n return this;\n }\n }, {\n key: \"clearIncompatible\",\n value: function clearIncompatible(pos, parentType, match) {\n _clearIncompatible(this, pos, parentType, match);\n return this;\n }\n }]);\n return Transform;\n}();\nexports.AddMarkStep = AddMarkStep;\nexports.AddNodeMarkStep = AddNodeMarkStep;\nexports.AttrStep = AttrStep;\nexports.DocAttrStep = DocAttrStep;\nexports.MapResult = MapResult;\nexports.Mapping = Mapping;\nexports.RemoveMarkStep = RemoveMarkStep;\nexports.RemoveNodeMarkStep = RemoveNodeMarkStep;\nexports.ReplaceAroundStep = ReplaceAroundStep;\nexports.ReplaceStep = ReplaceStep;\nexports.Step = Step;\nexports.StepMap = StepMap;\nexports.StepResult = StepResult;\nexports.Transform = Transform;\nexports.canJoin = canJoin;\nexports.canSplit = canSplit;\nexports.dropPoint = dropPoint;\nexports.findWrapping = findWrapping;\nexports.insertPoint = insertPoint;\nexports.joinPoint = joinPoint;\nexports.liftTarget = liftTarget;\nexports.replaceStep = replaceStep;\n","'use strict';\n\nfunction _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }\nfunction _nonIterableRest() { throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); }\nfunction _iterableToArrayLimit(r, l) { var t = null == r ? null : \"undefined\" != typeof Symbol && r[Symbol.iterator] || r[\"@@iterator\"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t[\"return\"] && (u = t[\"return\"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }\nfunction _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }\nfunction _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== \"undefined\" && o[Symbol.iterator] || o[\"@@iterator\"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === \"number\") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\"); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it[\"return\"] != null) it[\"return\"](); } finally { if (didErr) throw err; } } }; }\nfunction _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === \"string\") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === \"Object\" && o.constructor) n = o.constructor.name; if (n === \"Map\" || n === \"Set\") return Array.from(o); if (n === \"Arguments\" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }\nfunction _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }\nfunction _get() { if (typeof Reflect !== \"undefined\" && Reflect.get) { _get = Reflect.get.bind(); } else { _get = function _get(target, property, receiver) { var base = _superPropBase(target, property); if (!base) return; var desc = Object.getOwnPropertyDescriptor(base, property); if (desc.get) { return desc.get.call(arguments.length < 3 ? target : receiver); } return desc.value; }; } return _get.apply(this, arguments); }\nfunction _superPropBase(object, property) { while (!Object.prototype.hasOwnProperty.call(object, property)) { object = _getPrototypeOf(object); if (object === null) break; } return object; }\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function\"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, \"prototype\", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }\nfunction _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }\nfunction _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }\nfunction _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === \"object\" || typeof call === \"function\")) { return call; } else if (call !== void 0) { throw new TypeError(\"Derived constructors may only return object or undefined\"); } return _assertThisInitialized(self); }\nfunction _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return self; }\nfunction _isNativeReflectConstruct() { if (typeof Reflect === \"undefined\" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === \"function\") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }\nfunction _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }\nfunction _typeof(o) { \"@babel/helpers - typeof\"; return _typeof = \"function\" == typeof Symbol && \"symbol\" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && \"function\" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? \"symbol\" : typeof o; }, _typeof(o); }\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, \"prototype\", { writable: false }); return Constructor; }\nfunction _toPropertyKey(arg) { var key = _toPrimitive(arg, \"string\"); return _typeof(key) === \"symbol\" ? key : String(key); }\nfunction _toPrimitive(input, hint) { if (_typeof(input) !== \"object\" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || \"default\"); if (_typeof(res) !== \"object\") return res; throw new TypeError(\"@@toPrimitive must return a primitive value.\"); } return (hint === \"string\" ? String : Number)(input); }\nvar prosemirrorState = require('prosemirror-state');\nvar prosemirrorModel = require('prosemirror-model');\nvar prosemirrorTransform = require('prosemirror-transform');\nvar domIndex = function domIndex(node) {\n for (var index = 0;; index++) {\n node = node.previousSibling;\n if (!node) return index;\n }\n};\nvar parentNode = function parentNode(node) {\n var parent = node.assignedSlot || node.parentNode;\n return parent && parent.nodeType == 11 ? parent.host : parent;\n};\nvar reusedRange = null;\nvar textRange = function textRange(node, from, to) {\n var range = reusedRange || (reusedRange = document.createRange());\n range.setEnd(node, to == null ? node.nodeValue.length : to);\n range.setStart(node, from || 0);\n return range;\n};\nvar clearReusedRange = function clearReusedRange() {\n reusedRange = null;\n};\nvar isEquivalentPosition = function isEquivalentPosition(node, off, targetNode, targetOff) {\n return targetNode && (scanFor(node, off, targetNode, targetOff, -1) || scanFor(node, off, targetNode, targetOff, 1));\n};\nvar atomElements = /^(img|br|input|textarea|hr)$/i;\nfunction scanFor(node, off, targetNode, targetOff, dir) {\n var _a;\n for (;;) {\n if (node == targetNode && off == targetOff) return true;\n if (off == (dir < 0 ? 0 : nodeSize(node))) {\n var parent = node.parentNode;\n if (!parent || parent.nodeType != 1 || hasBlockDesc(node) || atomElements.test(node.nodeName) || node.contentEditable == \"false\") return false;\n off = domIndex(node) + (dir < 0 ? 0 : 1);\n node = parent;\n } else if (node.nodeType == 1) {\n var child = node.childNodes[off + (dir < 0 ? -1 : 0)];\n if (child.nodeType == 1 && child.contentEditable == \"false\") {\n if ((_a = child.pmViewDesc) === null || _a === void 0 ? void 0 : _a.ignoreForSelection) off += dir;else return false;\n } else {\n node = child;\n off = dir < 0 ? nodeSize(node) : 0;\n }\n } else {\n return false;\n }\n }\n}\nfunction nodeSize(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\nfunction textNodeBefore$1(node, offset) {\n for (;;) {\n if (node.nodeType == 3 && offset) return node;\n if (node.nodeType == 1 && offset > 0) {\n if (node.contentEditable == \"false\") return null;\n node = node.childNodes[offset - 1];\n offset = nodeSize(node);\n } else if (node.parentNode && !hasBlockDesc(node)) {\n offset = domIndex(node);\n node = node.parentNode;\n } else {\n return null;\n }\n }\n}\nfunction textNodeAfter$1(node, offset) {\n for (;;) {\n if (node.nodeType == 3 && offset < node.nodeValue.length) return node;\n if (node.nodeType == 1 && offset < node.childNodes.length) {\n if (node.contentEditable == \"false\") return null;\n node = node.childNodes[offset];\n offset = 0;\n } else if (node.parentNode && !hasBlockDesc(node)) {\n offset = domIndex(node) + 1;\n node = node.parentNode;\n } else {\n return null;\n }\n }\n}\nfunction isOnEdge(node, offset, parent) {\n for (var atStart = offset == 0, atEnd = offset == nodeSize(node); atStart || atEnd;) {\n if (node == parent) return true;\n var index = domIndex(node);\n node = node.parentNode;\n if (!node) return false;\n atStart = atStart && index == 0;\n atEnd = atEnd && index == nodeSize(node);\n }\n}\nfunction hasBlockDesc(dom) {\n var desc;\n for (var cur = dom; cur; cur = cur.parentNode) if (desc = cur.pmViewDesc) break;\n return desc && desc.node && desc.node.isBlock && (desc.dom == dom || desc.contentDOM == dom);\n}\nvar selectionCollapsed = function selectionCollapsed(domSel) {\n return domSel.focusNode && isEquivalentPosition(domSel.focusNode, domSel.focusOffset, domSel.anchorNode, domSel.anchorOffset);\n};\nfunction keyEvent(keyCode, key) {\n var event = document.createEvent(\"Event\");\n event.initEvent(\"keydown\", true, true);\n event.keyCode = keyCode;\n event.key = event.code = key;\n return event;\n}\nfunction deepActiveElement(doc) {\n var elt = doc.activeElement;\n while (elt && elt.shadowRoot) elt = elt.shadowRoot.activeElement;\n return elt;\n}\nfunction caretFromPoint(doc, x, y) {\n if (doc.caretPositionFromPoint) {\n try {\n var pos = doc.caretPositionFromPoint(x, y);\n if (pos) return {\n node: pos.offsetNode,\n offset: Math.min(nodeSize(pos.offsetNode), pos.offset)\n };\n } catch (_) {}\n }\n if (doc.caretRangeFromPoint) {\n var range = doc.caretRangeFromPoint(x, y);\n if (range) return {\n node: range.startContainer,\n offset: Math.min(nodeSize(range.startContainer), range.startOffset)\n };\n }\n}\nvar nav = typeof navigator != \"undefined\" ? navigator : null;\nvar doc = typeof document != \"undefined\" ? document : null;\nvar agent = nav && nav.userAgent || \"\";\nvar ie_edge = /Edge\\/(\\d+)/.exec(agent);\nvar ie_upto10 = /MSIE \\d/.exec(agent);\nvar ie_11up = /Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(agent);\nvar ie = !!(ie_upto10 || ie_11up || ie_edge);\nvar ie_version = ie_upto10 ? document.documentMode : ie_11up ? +ie_11up[1] : ie_edge ? +ie_edge[1] : 0;\nvar gecko = !ie && /gecko\\/(\\d+)/i.test(agent);\ngecko && +(/Firefox\\/(\\d+)/.exec(agent) || [0, 0])[1];\nvar _chrome = !ie && /Chrome\\/(\\d+)/.exec(agent);\nvar chrome = !!_chrome;\nvar chrome_version = _chrome ? +_chrome[1] : 0;\nvar safari = !ie && !!nav && /Apple Computer/.test(nav.vendor);\nvar ios = safari && (/Mobile\\/\\w+/.test(agent) || !!nav && nav.maxTouchPoints > 2);\nvar mac = ios || (nav ? /Mac/.test(nav.platform) : false);\nvar windows = nav ? /Win/.test(nav.platform) : false;\nvar android = /Android \\d/.test(agent);\nvar webkit = !!doc && \"webkitFontSmoothing\" in doc.documentElement.style;\nvar webkit_version = webkit ? +(/\\bAppleWebKit\\/(\\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;\nfunction windowRect(doc) {\n var vp = doc.defaultView && doc.defaultView.visualViewport;\n if (vp) return {\n left: 0,\n right: vp.width,\n top: 0,\n bottom: vp.height\n };\n return {\n left: 0,\n right: doc.documentElement.clientWidth,\n top: 0,\n bottom: doc.documentElement.clientHeight\n };\n}\nfunction getSide(value, side) {\n return typeof value == \"number\" ? value : value[side];\n}\nfunction clientRect(node) {\n var rect = node.getBoundingClientRect();\n var scaleX = rect.width / node.offsetWidth || 1;\n var scaleY = rect.height / node.offsetHeight || 1;\n return {\n left: rect.left,\n right: rect.left + node.clientWidth * scaleX,\n top: rect.top,\n bottom: rect.top + node.clientHeight * scaleY\n };\n}\nfunction scrollRectIntoView(view, rect, startDOM) {\n if (!nonZero(rect) && rect.left == 0) return;\n var scrollThreshold = view.someProp(\"scrollThreshold\") || 0,\n scrollMargin = view.someProp(\"scrollMargin\") || 5;\n var doc = view.dom.ownerDocument;\n for (var parent = startDOM || view.dom;;) {\n if (!parent) break;\n if (parent.nodeType != 1) {\n parent = parentNode(parent);\n continue;\n }\n var elt = parent;\n var atTop = elt == doc.body;\n var bounding = atTop ? windowRect(doc) : clientRect(elt);\n var moveX = 0,\n moveY = 0;\n if (rect.top < bounding.top + getSide(scrollThreshold, \"top\")) moveY = -(bounding.top - rect.top + getSide(scrollMargin, \"top\"));else if (rect.bottom > bounding.bottom - getSide(scrollThreshold, \"bottom\")) moveY = rect.bottom - rect.top > bounding.bottom - bounding.top ? rect.top + getSide(scrollMargin, \"top\") - bounding.top : rect.bottom - bounding.bottom + getSide(scrollMargin, \"bottom\");\n if (rect.left < bounding.left + getSide(scrollThreshold, \"left\")) moveX = -(bounding.left - rect.left + getSide(scrollMargin, \"left\"));else if (rect.right > bounding.right - getSide(scrollThreshold, \"right\")) moveX = rect.right - bounding.right + getSide(scrollMargin, \"right\");\n if (moveX || moveY) {\n if (atTop) {\n doc.defaultView.scrollBy(moveX, moveY);\n } else {\n var startX = elt.scrollLeft,\n startY = elt.scrollTop;\n if (moveY) elt.scrollTop += moveY;\n if (moveX) elt.scrollLeft += moveX;\n var dX = elt.scrollLeft - startX,\n dY = elt.scrollTop - startY;\n rect = {\n left: rect.left - dX,\n top: rect.top - dY,\n right: rect.right - dX,\n bottom: rect.bottom - dY\n };\n }\n }\n var pos = atTop ? \"fixed\" : getComputedStyle(parent).position;\n if (/^(fixed|sticky)$/.test(pos)) break;\n parent = pos == \"absolute\" ? parent.offsetParent : parentNode(parent);\n }\n}\nfunction storeScrollPos(view) {\n var rect = view.dom.getBoundingClientRect(),\n startY = Math.max(0, rect.top);\n var refDOM, refTop;\n for (var x = (rect.left + rect.right) / 2, y = startY + 1; y < Math.min(innerHeight, rect.bottom); y += 5) {\n var dom = view.root.elementFromPoint(x, y);\n if (!dom || dom == view.dom || !view.dom.contains(dom)) continue;\n var localRect = dom.getBoundingClientRect();\n if (localRect.top >= startY - 20) {\n refDOM = dom;\n refTop = localRect.top;\n break;\n }\n }\n return {\n refDOM: refDOM,\n refTop: refTop,\n stack: scrollStack(view.dom)\n };\n}\nfunction scrollStack(dom) {\n var stack = [],\n doc = dom.ownerDocument;\n for (var cur = dom; cur; cur = parentNode(cur)) {\n stack.push({\n dom: cur,\n top: cur.scrollTop,\n left: cur.scrollLeft\n });\n if (dom == doc) break;\n }\n return stack;\n}\nfunction resetScrollPos(_ref) {\n var refDOM = _ref.refDOM,\n refTop = _ref.refTop,\n stack = _ref.stack;\n var newRefTop = refDOM ? refDOM.getBoundingClientRect().top : 0;\n restoreScrollStack(stack, newRefTop == 0 ? 0 : newRefTop - refTop);\n}\nfunction restoreScrollStack(stack, dTop) {\n for (var i = 0; i < stack.length; i++) {\n var _stack$i = stack[i],\n dom = _stack$i.dom,\n top = _stack$i.top,\n left = _stack$i.left;\n if (dom.scrollTop != top + dTop) dom.scrollTop = top + dTop;\n if (dom.scrollLeft != left) dom.scrollLeft = left;\n }\n}\nvar preventScrollSupported = null;\nfunction focusPreventScroll(dom) {\n if (dom.setActive) return dom.setActive();\n if (preventScrollSupported) return dom.focus(preventScrollSupported);\n var stored = scrollStack(dom);\n dom.focus(preventScrollSupported == null ? {\n get preventScroll() {\n preventScrollSupported = {\n preventScroll: true\n };\n return true;\n }\n } : undefined);\n if (!preventScrollSupported) {\n preventScrollSupported = false;\n restoreScrollStack(stored, 0);\n }\n}\nfunction findOffsetInNode(node, coords) {\n var closest,\n dxClosest = 2e8,\n coordsClosest,\n offset = 0;\n var rowBot = coords.top,\n rowTop = coords.top;\n var firstBelow, coordsBelow;\n for (var child = node.firstChild, childIndex = 0; child; child = child.nextSibling, childIndex++) {\n var rects = void 0;\n if (child.nodeType == 1) rects = child.getClientRects();else if (child.nodeType == 3) rects = textRange(child).getClientRects();else continue;\n for (var i = 0; i < rects.length; i++) {\n var rect = rects[i];\n if (rect.top <= rowBot && rect.bottom >= rowTop) {\n rowBot = Math.max(rect.bottom, rowBot);\n rowTop = Math.min(rect.top, rowTop);\n var dx = rect.left > coords.left ? rect.left - coords.left : rect.right < coords.left ? coords.left - rect.right : 0;\n if (dx < dxClosest) {\n closest = child;\n dxClosest = dx;\n coordsClosest = dx && closest.nodeType == 3 ? {\n left: rect.right < coords.left ? rect.right : rect.left,\n top: coords.top\n } : coords;\n if (child.nodeType == 1 && dx) offset = childIndex + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0);\n continue;\n }\n } else if (rect.top > coords.top && !firstBelow && rect.left <= coords.left && rect.right >= coords.left) {\n firstBelow = child;\n coordsBelow = {\n left: Math.max(rect.left, Math.min(rect.right, coords.left)),\n top: rect.top\n };\n }\n if (!closest && (coords.left >= rect.right && coords.top >= rect.top || coords.left >= rect.left && coords.top >= rect.bottom)) offset = childIndex + 1;\n }\n }\n if (!closest && firstBelow) {\n closest = firstBelow;\n coordsClosest = coordsBelow;\n dxClosest = 0;\n }\n if (closest && closest.nodeType == 3) return findOffsetInText(closest, coordsClosest);\n if (!closest || dxClosest && closest.nodeType == 1) return {\n node: node,\n offset: offset\n };\n return findOffsetInNode(closest, coordsClosest);\n}\nfunction findOffsetInText(node, coords) {\n var len = node.nodeValue.length;\n var range = document.createRange(),\n result;\n for (var i = 0; i < len; i++) {\n range.setEnd(node, i + 1);\n range.setStart(node, i);\n var rect = singleRect(range, 1);\n if (rect.top == rect.bottom) continue;\n if (inRect(coords, rect)) {\n result = {\n node: node,\n offset: i + (coords.left >= (rect.left + rect.right) / 2 ? 1 : 0)\n };\n break;\n }\n }\n range.detach();\n return result || {\n node: node,\n offset: 0\n };\n}\nfunction inRect(coords, rect) {\n return coords.left >= rect.left - 1 && coords.left <= rect.right + 1 && coords.top >= rect.top - 1 && coords.top <= rect.bottom + 1;\n}\nfunction targetKludge(dom, coords) {\n var parent = dom.parentNode;\n if (parent && /^li$/i.test(parent.nodeName) && coords.left < dom.getBoundingClientRect().left) return parent;\n return dom;\n}\nfunction posFromElement(view, elt, coords) {\n var _findOffsetInNode = findOffsetInNode(elt, coords),\n node = _findOffsetInNode.node,\n offset = _findOffsetInNode.offset,\n bias = -1;\n if (node.nodeType == 1 && !node.firstChild) {\n var rect = node.getBoundingClientRect();\n bias = rect.left != rect.right && coords.left > (rect.left + rect.right) / 2 ? 1 : -1;\n }\n return view.docView.posFromDOM(node, offset, bias);\n}\nfunction posFromCaret(view, node, offset, coords) {\n var outsideBlock = -1;\n for (var cur = node, sawBlock = false;;) {\n if (cur == view.dom) break;\n var desc = view.docView.nearestDesc(cur, true),\n rect = void 0;\n if (!desc) return null;\n if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM) && ((rect = desc.dom.getBoundingClientRect()).width || rect.height)) {\n if (desc.node.isBlock && desc.parent && !/^T(R|BODY|HEAD|FOOT)$/.test(desc.dom.nodeName)) {\n if (!sawBlock && rect.left > coords.left || rect.top > coords.top) outsideBlock = desc.posBefore;else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top) outsideBlock = desc.posAfter;\n sawBlock = true;\n }\n if (!desc.contentDOM && outsideBlock < 0 && !desc.node.isText) {\n var before = desc.node.isBlock ? coords.top < (rect.top + rect.bottom) / 2 : coords.left < (rect.left + rect.right) / 2;\n return before ? desc.posBefore : desc.posAfter;\n }\n }\n cur = desc.dom.parentNode;\n }\n return outsideBlock > -1 ? outsideBlock : view.docView.posFromDOM(node, offset, -1);\n}\nfunction elementFromPoint(element, coords, box) {\n var len = element.childNodes.length;\n if (len && box.top < box.bottom) {\n for (var startI = Math.max(0, Math.min(len - 1, Math.floor(len * (coords.top - box.top) / (box.bottom - box.top)) - 2)), i = startI;;) {\n var child = element.childNodes[i];\n if (child.nodeType == 1) {\n var rects = child.getClientRects();\n for (var j = 0; j < rects.length; j++) {\n var rect = rects[j];\n if (inRect(coords, rect)) return elementFromPoint(child, coords, rect);\n }\n }\n if ((i = (i + 1) % len) == startI) break;\n }\n }\n return element;\n}\nfunction _posAtCoords(view, coords) {\n var doc = view.dom.ownerDocument,\n node,\n offset = 0;\n var caret = caretFromPoint(doc, coords.left, coords.top);\n if (caret) {\n node = caret.node;\n offset = caret.offset;\n }\n var elt = (view.root.elementFromPoint ? view.root : doc).elementFromPoint(coords.left, coords.top);\n var pos;\n if (!elt || !view.dom.contains(elt.nodeType != 1 ? elt.parentNode : elt)) {\n var box = view.dom.getBoundingClientRect();\n if (!inRect(coords, box)) return null;\n elt = elementFromPoint(view.dom, coords, box);\n if (!elt) return null;\n }\n if (safari) {\n for (var p = elt; node && p; p = parentNode(p)) if (p.draggable) node = undefined;\n }\n elt = targetKludge(elt, coords);\n if (node) {\n if (gecko && node.nodeType == 1) {\n offset = Math.min(offset, node.childNodes.length);\n if (offset < node.childNodes.length) {\n var next = node.childNodes[offset],\n _box;\n if (next.nodeName == \"IMG\" && (_box = next.getBoundingClientRect()).right <= coords.left && _box.bottom > coords.top) offset++;\n }\n }\n var prev;\n if (webkit && offset && node.nodeType == 1 && (prev = node.childNodes[offset - 1]).nodeType == 1 && prev.contentEditable == \"false\" && prev.getBoundingClientRect().top >= coords.top) offset--;\n if (node == view.dom && offset == node.childNodes.length - 1 && node.lastChild.nodeType == 1 && coords.top > node.lastChild.getBoundingClientRect().bottom) pos = view.state.doc.content.size;else if (offset == 0 || node.nodeType != 1 || node.childNodes[offset - 1].nodeName != \"BR\") pos = posFromCaret(view, node, offset, coords);\n }\n if (pos == null) pos = posFromElement(view, elt, coords);\n var desc = view.docView.nearestDesc(elt, true);\n return {\n pos: pos,\n inside: desc ? desc.posAtStart - desc.border : -1\n };\n}\nfunction nonZero(rect) {\n return rect.top < rect.bottom || rect.left < rect.right;\n}\nfunction singleRect(target, bias) {\n var rects = target.getClientRects();\n if (rects.length) {\n var first = rects[bias < 0 ? 0 : rects.length - 1];\n if (nonZero(first)) return first;\n }\n return Array.prototype.find.call(rects, nonZero) || target.getBoundingClientRect();\n}\nvar BIDI = /[\\u0590-\\u05f4\\u0600-\\u06ff\\u0700-\\u08ac]/;\nfunction _coordsAtPos(view, pos, side) {\n var _view$docView$domFrom = view.docView.domFromPos(pos, side < 0 ? -1 : 1),\n node = _view$docView$domFrom.node,\n offset = _view$docView$domFrom.offset,\n atom = _view$docView$domFrom.atom;\n var supportEmptyRange = webkit || gecko;\n if (node.nodeType == 3) {\n if (supportEmptyRange && (BIDI.test(node.nodeValue) || (side < 0 ? !offset : offset == node.nodeValue.length))) {\n var rect = singleRect(textRange(node, offset, offset), side);\n if (gecko && offset && /\\s/.test(node.nodeValue[offset - 1]) && offset < node.nodeValue.length) {\n var rectBefore = singleRect(textRange(node, offset - 1, offset - 1), -1);\n if (rectBefore.top == rect.top) {\n var rectAfter = singleRect(textRange(node, offset, offset + 1), -1);\n if (rectAfter.top != rect.top) return flattenV(rectAfter, rectAfter.left < rectBefore.left);\n }\n }\n return rect;\n } else {\n var from = offset,\n to = offset,\n takeSide = side < 0 ? 1 : -1;\n if (side < 0 && !offset) {\n to++;\n takeSide = -1;\n } else if (side >= 0 && offset == node.nodeValue.length) {\n from--;\n takeSide = 1;\n } else if (side < 0) {\n from--;\n } else {\n to++;\n }\n return flattenV(singleRect(textRange(node, from, to), takeSide), takeSide < 0);\n }\n }\n var $dom = view.state.doc.resolve(pos - (atom || 0));\n if (!$dom.parent.inlineContent) {\n if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {\n var before = node.childNodes[offset - 1];\n if (before.nodeType == 1) return flattenH(before.getBoundingClientRect(), false);\n }\n if (atom == null && offset < nodeSize(node)) {\n var after = node.childNodes[offset];\n if (after.nodeType == 1) return flattenH(after.getBoundingClientRect(), true);\n }\n return flattenH(node.getBoundingClientRect(), side >= 0);\n }\n if (atom == null && offset && (side < 0 || offset == nodeSize(node))) {\n var _before = node.childNodes[offset - 1];\n var target = _before.nodeType == 3 ? textRange(_before, nodeSize(_before) - (supportEmptyRange ? 0 : 1)) : _before.nodeType == 1 && (_before.nodeName != \"BR\" || !_before.nextSibling) ? _before : null;\n if (target) return flattenV(singleRect(target, 1), false);\n }\n if (atom == null && offset < nodeSize(node)) {\n var _after = node.childNodes[offset];\n while (_after.pmViewDesc && _after.pmViewDesc.ignoreForCoords) _after = _after.nextSibling;\n var _target = !_after ? null : _after.nodeType == 3 ? textRange(_after, 0, supportEmptyRange ? 0 : 1) : _after.nodeType == 1 ? _after : null;\n if (_target) return flattenV(singleRect(_target, -1), true);\n }\n return flattenV(singleRect(node.nodeType == 3 ? textRange(node) : node, -side), side >= 0);\n}\nfunction flattenV(rect, left) {\n if (rect.width == 0) return rect;\n var x = left ? rect.left : rect.right;\n return {\n top: rect.top,\n bottom: rect.bottom,\n left: x,\n right: x\n };\n}\nfunction flattenH(rect, top) {\n if (rect.height == 0) return rect;\n var y = top ? rect.top : rect.bottom;\n return {\n top: y,\n bottom: y,\n left: rect.left,\n right: rect.right\n };\n}\nfunction withFlushedState(view, state, f) {\n var viewState = view.state,\n active = view.root.activeElement;\n if (viewState != state) view.updateState(state);\n if (active != view.dom) view.focus();\n try {\n return f();\n } finally {\n if (viewState != state) view.updateState(viewState);\n if (active != view.dom && active) active.focus();\n }\n}\nfunction endOfTextblockVertical(view, state, dir) {\n var sel = state.selection;\n var $pos = dir == \"up\" ? sel.$from : sel.$to;\n return withFlushedState(view, state, function () {\n var _view$docView$domFrom2 = view.docView.domFromPos($pos.pos, dir == \"up\" ? -1 : 1),\n dom = _view$docView$domFrom2.node;\n for (;;) {\n var nearest = view.docView.nearestDesc(dom, true);\n if (!nearest) break;\n if (nearest.node.isBlock) {\n dom = nearest.contentDOM || nearest.dom;\n break;\n }\n dom = nearest.dom.parentNode;\n }\n var coords = _coordsAtPos(view, $pos.pos, 1);\n for (var child = dom.firstChild; child; child = child.nextSibling) {\n var boxes = void 0;\n if (child.nodeType == 1) boxes = child.getClientRects();else if (child.nodeType == 3) boxes = textRange(child, 0, child.nodeValue.length).getClientRects();else continue;\n for (var i = 0; i < boxes.length; i++) {\n var box = boxes[i];\n if (box.bottom > box.top + 1 && (dir == \"up\" ? coords.top - box.top > (box.bottom - coords.top) * 2 : box.bottom - coords.bottom > (coords.bottom - box.top) * 2)) return false;\n }\n }\n return true;\n });\n}\nvar maybeRTL = /[\\u0590-\\u08ac]/;\nfunction endOfTextblockHorizontal(view, state, dir) {\n var $head = state.selection.$head;\n if (!$head.parent.isTextblock) return false;\n var offset = $head.parentOffset,\n atStart = !offset,\n atEnd = offset == $head.parent.content.size;\n var sel = view.domSelection();\n if (!sel) return $head.pos == $head.start() || $head.pos == $head.end();\n if (!maybeRTL.test($head.parent.textContent) || !sel.modify) return dir == \"left\" || dir == \"backward\" ? atStart : atEnd;\n return withFlushedState(view, state, function () {\n var _view$domSelectionRan = view.domSelectionRange(),\n oldNode = _view$domSelectionRan.focusNode,\n oldOff = _view$domSelectionRan.focusOffset,\n anchorNode = _view$domSelectionRan.anchorNode,\n anchorOffset = _view$domSelectionRan.anchorOffset;\n var oldBidiLevel = sel.caretBidiLevel;\n sel.modify(\"move\", dir, \"character\");\n var parentDOM = $head.depth ? view.docView.domAfterPos($head.before()) : view.dom;\n var _view$domSelectionRan2 = view.domSelectionRange(),\n newNode = _view$domSelectionRan2.focusNode,\n newOff = _view$domSelectionRan2.focusOffset;\n var result = newNode && !parentDOM.contains(newNode.nodeType == 1 ? newNode : newNode.parentNode) || oldNode == newNode && oldOff == newOff;\n try {\n sel.collapse(anchorNode, anchorOffset);\n if (oldNode && (oldNode != anchorNode || oldOff != anchorOffset) && sel.extend) sel.extend(oldNode, oldOff);\n } catch (_) {}\n if (oldBidiLevel != null) sel.caretBidiLevel = oldBidiLevel;\n return result;\n });\n}\nvar cachedState = null;\nvar cachedDir = null;\nvar cachedResult = false;\nfunction _endOfTextblock(view, state, dir) {\n if (cachedState == state && cachedDir == dir) return cachedResult;\n cachedState = state;\n cachedDir = dir;\n return cachedResult = dir == \"up\" || dir == \"down\" ? endOfTextblockVertical(view, state, dir) : endOfTextblockHorizontal(view, state, dir);\n}\nvar NOT_DIRTY = 0,\n CHILD_DIRTY = 1,\n CONTENT_DIRTY = 2,\n NODE_DIRTY = 3;\nvar ViewDesc = function () {\n function ViewDesc(parent, children, dom, contentDOM) {\n _classCallCheck(this, ViewDesc);\n this.parent = parent;\n this.children = children;\n this.dom = dom;\n this.contentDOM = contentDOM;\n this.dirty = NOT_DIRTY;\n dom.pmViewDesc = this;\n }\n _createClass(ViewDesc, [{\n key: \"matchesWidget\",\n value: function matchesWidget(widget) {\n return false;\n }\n }, {\n key: \"matchesMark\",\n value: function matchesMark(mark) {\n return false;\n }\n }, {\n key: \"matchesNode\",\n value: function matchesNode(node, outerDeco, innerDeco) {\n return false;\n }\n }, {\n key: \"matchesHack\",\n value: function matchesHack(nodeName) {\n return false;\n }\n }, {\n key: \"parseRule\",\n value: function parseRule(addedNodes) {\n return null;\n }\n }, {\n key: \"stopEvent\",\n value: function stopEvent(event) {\n return false;\n }\n }, {\n key: \"size\",\n get: function get() {\n var size = 0;\n for (var i = 0; i < this.children.length; i++) size += this.children[i].size;\n return size;\n }\n }, {\n key: \"border\",\n get: function get() {\n return 0;\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.parent = undefined;\n if (this.dom.pmViewDesc == this) this.dom.pmViewDesc = undefined;\n for (var i = 0; i < this.children.length; i++) this.children[i].destroy();\n }\n }, {\n key: \"posBeforeChild\",\n value: function posBeforeChild(child) {\n for (var i = 0, pos = this.posAtStart;; i++) {\n var cur = this.children[i];\n if (cur == child) return pos;\n pos += cur.size;\n }\n }\n }, {\n key: \"posBefore\",\n get: function get() {\n return this.parent.posBeforeChild(this);\n }\n }, {\n key: \"posAtStart\",\n get: function get() {\n return this.parent ? this.parent.posBeforeChild(this) + this.border : 0;\n }\n }, {\n key: \"posAfter\",\n get: function get() {\n return this.posBefore + this.size;\n }\n }, {\n key: \"posAtEnd\",\n get: function get() {\n return this.posAtStart + this.size - 2 * this.border;\n }\n }, {\n key: \"localPosFromDOM\",\n value: function localPosFromDOM(dom, offset, bias) {\n if (this.contentDOM && this.contentDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode)) {\n if (bias < 0) {\n var domBefore, desc;\n if (dom == this.contentDOM) {\n domBefore = dom.childNodes[offset - 1];\n } else {\n while (dom.parentNode != this.contentDOM) dom = dom.parentNode;\n domBefore = dom.previousSibling;\n }\n while (domBefore && !((desc = domBefore.pmViewDesc) && desc.parent == this)) domBefore = domBefore.previousSibling;\n return domBefore ? this.posBeforeChild(desc) + desc.size : this.posAtStart;\n } else {\n var domAfter, _desc;\n if (dom == this.contentDOM) {\n domAfter = dom.childNodes[offset];\n } else {\n while (dom.parentNode != this.contentDOM) dom = dom.parentNode;\n domAfter = dom.nextSibling;\n }\n while (domAfter && !((_desc = domAfter.pmViewDesc) && _desc.parent == this)) domAfter = domAfter.nextSibling;\n return domAfter ? this.posBeforeChild(_desc) : this.posAtEnd;\n }\n }\n var atEnd;\n if (dom == this.dom && this.contentDOM) {\n atEnd = offset > domIndex(this.contentDOM);\n } else if (this.contentDOM && this.contentDOM != this.dom && this.dom.contains(this.contentDOM)) {\n atEnd = dom.compareDocumentPosition(this.contentDOM) & 2;\n } else if (this.dom.firstChild) {\n if (offset == 0) for (var search = dom;; search = search.parentNode) {\n if (search == this.dom) {\n atEnd = false;\n break;\n }\n if (search.previousSibling) break;\n }\n if (atEnd == null && offset == dom.childNodes.length) for (var _search = dom;; _search = _search.parentNode) {\n if (_search == this.dom) {\n atEnd = true;\n break;\n }\n if (_search.nextSibling) break;\n }\n }\n return (atEnd == null ? bias > 0 : atEnd) ? this.posAtEnd : this.posAtStart;\n }\n }, {\n key: \"nearestDesc\",\n value: function nearestDesc(dom) {\n var onlyNodes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n for (var first = true, cur = dom; cur; cur = cur.parentNode) {\n var desc = this.getDesc(cur),\n nodeDOM = void 0;\n if (desc && (!onlyNodes || desc.node)) {\n if (first && (nodeDOM = desc.nodeDOM) && !(nodeDOM.nodeType == 1 ? nodeDOM.contains(dom.nodeType == 1 ? dom : dom.parentNode) : nodeDOM == dom)) first = false;else return desc;\n }\n }\n }\n }, {\n key: \"getDesc\",\n value: function getDesc(dom) {\n var desc = dom.pmViewDesc;\n for (var cur = desc; cur; cur = cur.parent) if (cur == this) return desc;\n }\n }, {\n key: \"posFromDOM\",\n value: function posFromDOM(dom, offset, bias) {\n for (var scan = dom; scan; scan = scan.parentNode) {\n var desc = this.getDesc(scan);\n if (desc) return desc.localPosFromDOM(dom, offset, bias);\n }\n return -1;\n }\n }, {\n key: \"descAt\",\n value: function descAt(pos) {\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n if (offset == pos && end != offset) {\n while (!child.border && child.children.length) {\n for (var _i = 0; _i < child.children.length; _i++) {\n var inner = child.children[_i];\n if (inner.size) {\n child = inner;\n break;\n }\n }\n }\n return child;\n }\n if (pos < end) return child.descAt(pos - offset - child.border);\n offset = end;\n }\n }\n }, {\n key: \"domFromPos\",\n value: function domFromPos(pos, side) {\n if (!this.contentDOM) return {\n node: this.dom,\n offset: 0,\n atom: pos + 1\n };\n var i = 0,\n offset = 0;\n for (var curPos = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = curPos + child.size;\n if (end > pos || child instanceof TrailingHackViewDesc) {\n offset = pos - curPos;\n break;\n }\n curPos = end;\n }\n if (offset) return this.children[i].domFromPos(offset - this.children[i].border, side);\n for (var prev; i && !(prev = this.children[i - 1]).size && prev instanceof WidgetViewDesc && prev.side >= 0; i--) {}\n if (side <= 0) {\n var _prev,\n enter = true;\n for (;; i--, enter = false) {\n _prev = i ? this.children[i - 1] : null;\n if (!_prev || _prev.dom.parentNode == this.contentDOM) break;\n }\n if (_prev && side && enter && !_prev.border && !_prev.domAtom) return _prev.domFromPos(_prev.size, side);\n return {\n node: this.contentDOM,\n offset: _prev ? domIndex(_prev.dom) + 1 : 0\n };\n } else {\n var next,\n _enter = true;\n for (;; i++, _enter = false) {\n next = i < this.children.length ? this.children[i] : null;\n if (!next || next.dom.parentNode == this.contentDOM) break;\n }\n if (next && _enter && !next.border && !next.domAtom) return next.domFromPos(0, side);\n return {\n node: this.contentDOM,\n offset: next ? domIndex(next.dom) : this.contentDOM.childNodes.length\n };\n }\n }\n }, {\n key: \"parseRange\",\n value: function parseRange(from, to) {\n var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n if (this.children.length == 0) return {\n node: this.contentDOM,\n from: from,\n to: to,\n fromOffset: 0,\n toOffset: this.contentDOM.childNodes.length\n };\n var fromOffset = -1,\n toOffset = -1;\n for (var offset = base, i = 0;; i++) {\n var child = this.children[i],\n end = offset + child.size;\n if (fromOffset == -1 && from <= end) {\n var childBase = offset + child.border;\n if (from >= childBase && to <= end - child.border && child.node && child.contentDOM && this.contentDOM.contains(child.contentDOM)) return child.parseRange(from, to, childBase);\n from = offset;\n for (var j = i; j > 0; j--) {\n var prev = this.children[j - 1];\n if (prev.size && prev.dom.parentNode == this.contentDOM && !prev.emptyChildAt(1)) {\n fromOffset = domIndex(prev.dom) + 1;\n break;\n }\n from -= prev.size;\n }\n if (fromOffset == -1) fromOffset = 0;\n }\n if (fromOffset > -1 && (end > to || i == this.children.length - 1)) {\n to = end;\n for (var _j = i + 1; _j < this.children.length; _j++) {\n var next = this.children[_j];\n if (next.size && next.dom.parentNode == this.contentDOM && !next.emptyChildAt(-1)) {\n toOffset = domIndex(next.dom);\n break;\n }\n to += next.size;\n }\n if (toOffset == -1) toOffset = this.contentDOM.childNodes.length;\n break;\n }\n offset = end;\n }\n return {\n node: this.contentDOM,\n from: from,\n to: to,\n fromOffset: fromOffset,\n toOffset: toOffset\n };\n }\n }, {\n key: \"emptyChildAt\",\n value: function emptyChildAt(side) {\n if (this.border || !this.contentDOM || !this.children.length) return false;\n var child = this.children[side < 0 ? 0 : this.children.length - 1];\n return child.size == 0 || child.emptyChildAt(side);\n }\n }, {\n key: \"domAfterPos\",\n value: function domAfterPos(pos) {\n var _this$domFromPos = this.domFromPos(pos, 0),\n node = _this$domFromPos.node,\n offset = _this$domFromPos.offset;\n if (node.nodeType != 1 || offset == node.childNodes.length) throw new RangeError(\"No node after pos \" + pos);\n return node.childNodes[offset];\n }\n }, {\n key: \"setSelection\",\n value: function setSelection(anchor, head, view) {\n var force = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;\n var from = Math.min(anchor, head),\n to = Math.max(anchor, head);\n for (var i = 0, offset = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n if (from > offset && to < end) return child.setSelection(anchor - offset - child.border, head - offset - child.border, view, force);\n offset = end;\n }\n var anchorDOM = this.domFromPos(anchor, anchor ? -1 : 1);\n var headDOM = head == anchor ? anchorDOM : this.domFromPos(head, head ? -1 : 1);\n var domSel = view.root.getSelection();\n var selRange = view.domSelectionRange();\n var brKludge = false;\n if ((gecko || safari) && anchor == head) {\n var _anchorDOM = anchorDOM,\n node = _anchorDOM.node,\n _offset = _anchorDOM.offset;\n if (node.nodeType == 3) {\n brKludge = !!(_offset && node.nodeValue[_offset - 1] == \"\\n\");\n if (brKludge && _offset == node.nodeValue.length) {\n for (var scan = node, after; scan; scan = scan.parentNode) {\n if (after = scan.nextSibling) {\n if (after.nodeName == \"BR\") anchorDOM = headDOM = {\n node: after.parentNode,\n offset: domIndex(after) + 1\n };\n break;\n }\n var desc = scan.pmViewDesc;\n if (desc && desc.node && desc.node.isBlock) break;\n }\n }\n } else {\n var prev = node.childNodes[_offset - 1];\n brKludge = prev && (prev.nodeName == \"BR\" || prev.contentEditable == \"false\");\n }\n }\n if (gecko && selRange.focusNode && selRange.focusNode != headDOM.node && selRange.focusNode.nodeType == 1) {\n var _after2 = selRange.focusNode.childNodes[selRange.focusOffset];\n if (_after2 && _after2.contentEditable == \"false\") force = true;\n }\n if (!(force || brKludge && safari) && isEquivalentPosition(anchorDOM.node, anchorDOM.offset, selRange.anchorNode, selRange.anchorOffset) && isEquivalentPosition(headDOM.node, headDOM.offset, selRange.focusNode, selRange.focusOffset)) return;\n var domSelExtended = false;\n if ((domSel.extend || anchor == head) && !(brKludge && gecko)) {\n domSel.collapse(anchorDOM.node, anchorDOM.offset);\n try {\n if (anchor != head) domSel.extend(headDOM.node, headDOM.offset);\n domSelExtended = true;\n } catch (_) {}\n }\n if (!domSelExtended) {\n if (anchor > head) {\n var tmp = anchorDOM;\n anchorDOM = headDOM;\n headDOM = tmp;\n }\n var range = document.createRange();\n range.setEnd(headDOM.node, headDOM.offset);\n range.setStart(anchorDOM.node, anchorDOM.offset);\n domSel.removeAllRanges();\n domSel.addRange(range);\n }\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mutation) {\n return !this.contentDOM && mutation.type != \"selection\";\n }\n }, {\n key: \"contentLost\",\n get: function get() {\n return this.contentDOM && this.contentDOM != this.dom && !this.dom.contains(this.contentDOM);\n }\n }, {\n key: \"markDirty\",\n value: function markDirty(from, to) {\n for (var offset = 0, i = 0; i < this.children.length; i++) {\n var child = this.children[i],\n end = offset + child.size;\n if (offset == end ? from <= end && to >= offset : from < end && to > offset) {\n var startInside = offset + child.border,\n endInside = end - child.border;\n if (from >= startInside && to <= endInside) {\n this.dirty = from == offset || to == end ? CONTENT_DIRTY : CHILD_DIRTY;\n if (from == startInside && to == endInside && (child.contentLost || child.dom.parentNode != this.contentDOM)) child.dirty = NODE_DIRTY;else child.markDirty(from - startInside, to - startInside);\n return;\n } else {\n child.dirty = child.dom == child.contentDOM && child.dom.parentNode == this.contentDOM && !child.children.length ? CONTENT_DIRTY : NODE_DIRTY;\n }\n }\n offset = end;\n }\n this.dirty = CONTENT_DIRTY;\n }\n }, {\n key: \"markParentsDirty\",\n value: function markParentsDirty() {\n var level = 1;\n for (var node = this.parent; node; node = node.parent, level++) {\n var dirty = level == 1 ? CONTENT_DIRTY : CHILD_DIRTY;\n if (node.dirty < dirty) node.dirty = dirty;\n }\n }\n }, {\n key: \"domAtom\",\n get: function get() {\n return false;\n }\n }, {\n key: \"ignoreForCoords\",\n get: function get() {\n return false;\n }\n }, {\n key: \"ignoreForSelection\",\n get: function get() {\n return false;\n }\n }, {\n key: \"isText\",\n value: function isText(text) {\n return false;\n }\n }]);\n return ViewDesc;\n}();\nvar WidgetViewDesc = function (_ViewDesc) {\n _inherits(WidgetViewDesc, _ViewDesc);\n var _super = _createSuper(WidgetViewDesc);\n function WidgetViewDesc(parent, widget, view, pos) {\n var _this;\n _classCallCheck(this, WidgetViewDesc);\n var self,\n dom = widget.type.toDOM;\n if (typeof dom == \"function\") dom = dom(view, function () {\n if (!self) return pos;\n if (self.parent) return self.parent.posBeforeChild(self);\n });\n if (!widget.type.spec.raw) {\n if (dom.nodeType != 1) {\n var wrap = document.createElement(\"span\");\n wrap.appendChild(dom);\n dom = wrap;\n }\n if (!dom.hasAttribute(\"contenteditable\")) dom.contentEditable = \"false\";\n dom.classList.add(\"ProseMirror-widget\");\n }\n _this = _super.call(this, parent, [], dom, null);\n _this.widget = widget;\n _this.widget = widget;\n self = _assertThisInitialized(_this);\n return _this;\n }\n _createClass(WidgetViewDesc, [{\n key: \"matchesWidget\",\n value: function matchesWidget(widget) {\n return this.dirty == NOT_DIRTY && widget.type.eq(this.widget.type);\n }\n }, {\n key: \"parseRule\",\n value: function parseRule() {\n return {\n ignore: true\n };\n }\n }, {\n key: \"stopEvent\",\n value: function stopEvent(event) {\n var stop = this.widget.spec.stopEvent;\n return stop ? stop(event) : false;\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mutation) {\n return mutation.type != \"selection\" || this.widget.spec.ignoreSelection;\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n this.widget.type.destroy(this.dom);\n _get(_getPrototypeOf(WidgetViewDesc.prototype), \"destroy\", this).call(this);\n }\n }, {\n key: \"domAtom\",\n get: function get() {\n return true;\n }\n }, {\n key: \"ignoreForSelection\",\n get: function get() {\n return !!this.widget.type.spec.relaxedSide;\n }\n }, {\n key: \"side\",\n get: function get() {\n return this.widget.type.side;\n }\n }]);\n return WidgetViewDesc;\n}(ViewDesc);\nvar CompositionViewDesc = function (_ViewDesc2) {\n _inherits(CompositionViewDesc, _ViewDesc2);\n var _super2 = _createSuper(CompositionViewDesc);\n function CompositionViewDesc(parent, dom, textDOM, text) {\n var _this2;\n _classCallCheck(this, CompositionViewDesc);\n _this2 = _super2.call(this, parent, [], dom, null);\n _this2.textDOM = textDOM;\n _this2.text = text;\n return _this2;\n }\n _createClass(CompositionViewDesc, [{\n key: \"size\",\n get: function get() {\n return this.text.length;\n }\n }, {\n key: \"localPosFromDOM\",\n value: function localPosFromDOM(dom, offset) {\n if (dom != this.textDOM) return this.posAtStart + (offset ? this.size : 0);\n return this.posAtStart + offset;\n }\n }, {\n key: \"domFromPos\",\n value: function domFromPos(pos) {\n return {\n node: this.textDOM,\n offset: pos\n };\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mut) {\n return mut.type === 'characterData' && mut.target.nodeValue == mut.oldValue;\n }\n }]);\n return CompositionViewDesc;\n}(ViewDesc);\nvar MarkViewDesc = function (_ViewDesc3) {\n _inherits(MarkViewDesc, _ViewDesc3);\n var _super3 = _createSuper(MarkViewDesc);\n function MarkViewDesc(parent, mark, dom, contentDOM, spec) {\n var _this3;\n _classCallCheck(this, MarkViewDesc);\n _this3 = _super3.call(this, parent, [], dom, contentDOM);\n _this3.mark = mark;\n _this3.spec = spec;\n return _this3;\n }\n _createClass(MarkViewDesc, [{\n key: \"parseRule\",\n value: function parseRule() {\n if (this.dirty & NODE_DIRTY || this.mark.type.spec.reparseInView) return null;\n return {\n mark: this.mark.type.name,\n attrs: this.mark.attrs,\n contentElement: this.contentDOM\n };\n }\n }, {\n key: \"matchesMark\",\n value: function matchesMark(mark) {\n return this.dirty != NODE_DIRTY && this.mark.eq(mark);\n }\n }, {\n key: \"markDirty\",\n value: function markDirty(from, to) {\n _get(_getPrototypeOf(MarkViewDesc.prototype), \"markDirty\", this).call(this, from, to);\n if (this.dirty != NOT_DIRTY) {\n var parent = this.parent;\n while (!parent.node) parent = parent.parent;\n if (parent.dirty < this.dirty) parent.dirty = this.dirty;\n this.dirty = NOT_DIRTY;\n }\n }\n }, {\n key: \"slice\",\n value: function slice(from, to, view) {\n var copy = MarkViewDesc.create(this.parent, this.mark, true, view);\n var nodes = this.children,\n size = this.size;\n if (to < size) nodes = replaceNodes(nodes, to, size, view);\n if (from > 0) nodes = replaceNodes(nodes, 0, from, view);\n for (var i = 0; i < nodes.length; i++) nodes[i].parent = copy;\n copy.children = nodes;\n return copy;\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mutation) {\n return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : _get(_getPrototypeOf(MarkViewDesc.prototype), \"ignoreMutation\", this).call(this, mutation);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n if (this.spec.destroy) this.spec.destroy();\n _get(_getPrototypeOf(MarkViewDesc.prototype), \"destroy\", this).call(this);\n }\n }], [{\n key: \"create\",\n value: function create(parent, mark, inline, view) {\n var custom = view.nodeViews[mark.type.name];\n var spec = custom && custom(mark, view, inline);\n if (!spec || !spec.dom) spec = prosemirrorModel.DOMSerializer.renderSpec(document, mark.type.spec.toDOM(mark, inline), null, mark.attrs);\n return new MarkViewDesc(parent, mark, spec.dom, spec.contentDOM || spec.dom, spec);\n }\n }]);\n return MarkViewDesc;\n}(ViewDesc);\nvar NodeViewDesc = function (_ViewDesc4) {\n _inherits(NodeViewDesc, _ViewDesc4);\n var _super4 = _createSuper(NodeViewDesc);\n function NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM) {\n var _this4;\n _classCallCheck(this, NodeViewDesc);\n _this4 = _super4.call(this, parent, [], dom, contentDOM);\n _this4.node = node;\n _this4.outerDeco = outerDeco;\n _this4.innerDeco = innerDeco;\n _this4.nodeDOM = nodeDOM;\n return _this4;\n }\n _createClass(NodeViewDesc, [{\n key: \"parseRule\",\n value: function parseRule(addedNodes) {\n var _this5 = this;\n if (this.node.type.spec.reparseInView) return null;\n var rule = {\n node: this.node.type.name,\n attrs: this.node.attrs\n };\n if (this.node.type.whitespace == \"pre\") rule.preserveWhitespace = \"full\";\n if (!this.contentDOM) {\n rule.getContent = function () {\n return _this5.node.content;\n };\n } else if (!this.contentLost) {\n rule.contentElement = this.contentDOM;\n } else {\n for (var i = this.children.length - 1; i >= 0; i--) {\n var child = this.children[i];\n if (this.dom.contains(child.dom.parentNode)) {\n rule.contentElement = child.dom.parentNode;\n break;\n }\n }\n if (!rule.contentElement) {\n var found = addedNodes && addedNodes.find(function (n) {\n return n.nodeType == 1 && addedNodes.indexOf(n.parentNode) < 0 && _this5.dom.contains(n);\n });\n if (found) rule.contentElement = found;else rule.getContent = function () {\n return prosemirrorModel.Fragment.empty;\n };\n }\n }\n return rule;\n }\n }, {\n key: \"matchesNode\",\n value: function matchesNode(node, outerDeco, innerDeco) {\n return this.dirty == NOT_DIRTY && node.eq(this.node) && sameOuterDeco(outerDeco, this.outerDeco) && innerDeco.eq(this.innerDeco);\n }\n }, {\n key: \"size\",\n get: function get() {\n return this.node.nodeSize;\n }\n }, {\n key: \"border\",\n get: function get() {\n return this.node.isLeaf ? 0 : 1;\n }\n }, {\n key: \"updateChildren\",\n value: function updateChildren(view, pos) {\n var _this6 = this;\n var inline = this.node.inlineContent,\n off = pos;\n var composition = view.composing ? this.localCompositionInfo(view, pos) : null;\n var localComposition = composition && composition.pos > -1 ? composition : null;\n var compositionInChild = composition && composition.pos < 0;\n var updater = new ViewTreeUpdater(this, localComposition && localComposition.node, view);\n iterDeco(this.node, this.innerDeco, function (widget, i, insideNode) {\n if (widget.spec.marks) updater.syncToMarks(widget.spec.marks, inline, view, i);else if (widget.type.side >= 0 && !insideNode) updater.syncToMarks(i == _this6.node.childCount ? prosemirrorModel.Mark.none : _this6.node.child(i).marks, inline, view, i);\n updater.placeWidget(widget, view, off);\n }, function (child, outerDeco, innerDeco, i) {\n updater.syncToMarks(child.marks, inline, view, i);\n var compIndex;\n if (updater.findNodeMatch(child, outerDeco, innerDeco, i)) ;else if (compositionInChild && view.state.selection.from > off && view.state.selection.to < off + child.nodeSize && (compIndex = updater.findIndexWithChild(composition.node)) > -1 && updater.updateNodeAt(child, outerDeco, innerDeco, compIndex, view)) ;else if (updater.updateNextNode(child, outerDeco, innerDeco, view, i, off)) ;else {\n updater.addNode(child, outerDeco, innerDeco, view, off);\n }\n off += child.nodeSize;\n });\n updater.syncToMarks([], inline, view, 0);\n if (this.node.isTextblock) updater.addTextblockHacks();\n updater.destroyRest();\n if (updater.changed || this.dirty == CONTENT_DIRTY) {\n if (localComposition) this.protectLocalComposition(view, localComposition);\n renderDescs(this.contentDOM, this.children, view);\n if (ios) iosHacks(this.dom);\n }\n }\n }, {\n key: \"localCompositionInfo\",\n value: function localCompositionInfo(view, pos) {\n var _view$state$selection = view.state.selection,\n from = _view$state$selection.from,\n to = _view$state$selection.to;\n if (!(view.state.selection instanceof prosemirrorState.TextSelection) || from < pos || to > pos + this.node.content.size) return null;\n var textNode = view.input.compositionNode;\n if (!textNode || !this.dom.contains(textNode.parentNode)) return null;\n if (this.node.inlineContent) {\n var text = textNode.nodeValue;\n var textPos = findTextInFragment(this.node.content, text, from - pos, to - pos);\n return textPos < 0 ? null : {\n node: textNode,\n pos: textPos,\n text: text\n };\n } else {\n return {\n node: textNode,\n pos: -1,\n text: \"\"\n };\n }\n }\n }, {\n key: \"protectLocalComposition\",\n value: function protectLocalComposition(view, _ref2) {\n var node = _ref2.node,\n pos = _ref2.pos,\n text = _ref2.text;\n if (this.getDesc(node)) return;\n var topNode = node;\n for (;; topNode = topNode.parentNode) {\n if (topNode.parentNode == this.contentDOM) break;\n while (topNode.previousSibling) topNode.parentNode.removeChild(topNode.previousSibling);\n while (topNode.nextSibling) topNode.parentNode.removeChild(topNode.nextSibling);\n if (topNode.pmViewDesc) topNode.pmViewDesc = undefined;\n }\n var desc = new CompositionViewDesc(this, topNode, node, text);\n view.input.compositionNodes.push(desc);\n this.children = replaceNodes(this.children, pos, pos + text.length, view, desc);\n }\n }, {\n key: \"update\",\n value: function update(node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY || !node.sameMarkup(this.node)) return false;\n this.updateInner(node, outerDeco, innerDeco, view);\n return true;\n }\n }, {\n key: \"updateInner\",\n value: function updateInner(node, outerDeco, innerDeco, view) {\n this.updateOuterDeco(outerDeco);\n this.node = node;\n this.innerDeco = innerDeco;\n if (this.contentDOM) this.updateChildren(view, this.posAtStart);\n this.dirty = NOT_DIRTY;\n }\n }, {\n key: \"updateOuterDeco\",\n value: function updateOuterDeco(outerDeco) {\n if (sameOuterDeco(outerDeco, this.outerDeco)) return;\n var needsWrap = this.nodeDOM.nodeType != 1;\n var oldDOM = this.dom;\n this.dom = patchOuterDeco(this.dom, this.nodeDOM, computeOuterDeco(this.outerDeco, this.node, needsWrap), computeOuterDeco(outerDeco, this.node, needsWrap));\n if (this.dom != oldDOM) {\n oldDOM.pmViewDesc = undefined;\n this.dom.pmViewDesc = this;\n }\n this.outerDeco = outerDeco;\n }\n }, {\n key: \"selectNode\",\n value: function selectNode() {\n if (this.nodeDOM.nodeType == 1) {\n this.nodeDOM.classList.add(\"ProseMirror-selectednode\");\n if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.draggable = true;\n }\n }\n }, {\n key: \"deselectNode\",\n value: function deselectNode() {\n if (this.nodeDOM.nodeType == 1) {\n this.nodeDOM.classList.remove(\"ProseMirror-selectednode\");\n if (this.contentDOM || !this.node.type.spec.draggable) this.nodeDOM.removeAttribute(\"draggable\");\n }\n }\n }, {\n key: \"domAtom\",\n get: function get() {\n return this.node.isAtom;\n }\n }], [{\n key: \"create\",\n value: function create(parent, node, outerDeco, innerDeco, view, pos) {\n var custom = view.nodeViews[node.type.name],\n descObj;\n var spec = custom && custom(node, view, function () {\n if (!descObj) return pos;\n if (descObj.parent) return descObj.parent.posBeforeChild(descObj);\n }, outerDeco, innerDeco);\n var dom = spec && spec.dom,\n contentDOM = spec && spec.contentDOM;\n if (node.isText) {\n if (!dom) dom = document.createTextNode(node.text);else if (dom.nodeType != 3) throw new RangeError(\"Text must be rendered as a DOM text node\");\n } else if (!dom) {\n var _spec = prosemirrorModel.DOMSerializer.renderSpec(document, node.type.spec.toDOM(node), null, node.attrs);\n dom = _spec.dom;\n contentDOM = _spec.contentDOM;\n }\n if (!contentDOM && !node.isText && dom.nodeName != \"BR\") {\n if (!dom.hasAttribute(\"contenteditable\")) dom.contentEditable = \"false\";\n if (node.type.spec.draggable) dom.draggable = true;\n }\n var nodeDOM = dom;\n dom = applyOuterDeco(dom, outerDeco, node);\n if (spec) return descObj = new CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null, nodeDOM, spec);else if (node.isText) return new TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM);else return new NodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM || null, nodeDOM);\n }\n }]);\n return NodeViewDesc;\n}(ViewDesc);\nfunction docViewDesc(doc, outerDeco, innerDeco, dom, view) {\n applyOuterDeco(dom, outerDeco, doc);\n var docView = new NodeViewDesc(undefined, doc, outerDeco, innerDeco, dom, dom, dom);\n if (docView.contentDOM) docView.updateChildren(view, 0);\n return docView;\n}\nvar TextViewDesc = function (_NodeViewDesc) {\n _inherits(TextViewDesc, _NodeViewDesc);\n var _super5 = _createSuper(TextViewDesc);\n function TextViewDesc(parent, node, outerDeco, innerDeco, dom, nodeDOM) {\n _classCallCheck(this, TextViewDesc);\n return _super5.call(this, parent, node, outerDeco, innerDeco, dom, null, nodeDOM);\n }\n _createClass(TextViewDesc, [{\n key: \"parseRule\",\n value: function parseRule() {\n var skip = this.nodeDOM.parentNode;\n while (skip && skip != this.dom && !skip.pmIsDeco) skip = skip.parentNode;\n return {\n skip: skip || true\n };\n }\n }, {\n key: \"update\",\n value: function update(node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY || this.dirty != NOT_DIRTY && !this.inParent() || !node.sameMarkup(this.node)) return false;\n this.updateOuterDeco(outerDeco);\n if ((this.dirty != NOT_DIRTY || node.text != this.node.text) && node.text != this.nodeDOM.nodeValue) {\n this.nodeDOM.nodeValue = node.text;\n if (view.trackWrites == this.nodeDOM) view.trackWrites = null;\n }\n this.node = node;\n this.dirty = NOT_DIRTY;\n return true;\n }\n }, {\n key: \"inParent\",\n value: function inParent() {\n var parentDOM = this.parent.contentDOM;\n for (var n = this.nodeDOM; n; n = n.parentNode) if (n == parentDOM) return true;\n return false;\n }\n }, {\n key: \"domFromPos\",\n value: function domFromPos(pos) {\n return {\n node: this.nodeDOM,\n offset: pos\n };\n }\n }, {\n key: \"localPosFromDOM\",\n value: function localPosFromDOM(dom, offset, bias) {\n if (dom == this.nodeDOM) return this.posAtStart + Math.min(offset, this.node.text.length);\n return _get(_getPrototypeOf(TextViewDesc.prototype), \"localPosFromDOM\", this).call(this, dom, offset, bias);\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mutation) {\n return mutation.type != \"characterData\" && mutation.type != \"selection\";\n }\n }, {\n key: \"slice\",\n value: function slice(from, to, _view) {\n var node = this.node.cut(from, to),\n dom = document.createTextNode(node.text);\n return new TextViewDesc(this.parent, node, this.outerDeco, this.innerDeco, dom, dom);\n }\n }, {\n key: \"markDirty\",\n value: function markDirty(from, to) {\n _get(_getPrototypeOf(TextViewDesc.prototype), \"markDirty\", this).call(this, from, to);\n if (this.dom != this.nodeDOM && (from == 0 || to == this.nodeDOM.nodeValue.length)) this.dirty = NODE_DIRTY;\n }\n }, {\n key: \"domAtom\",\n get: function get() {\n return false;\n }\n }, {\n key: \"isText\",\n value: function isText(text) {\n return this.node.text == text;\n }\n }]);\n return TextViewDesc;\n}(NodeViewDesc);\nvar TrailingHackViewDesc = function (_ViewDesc5) {\n _inherits(TrailingHackViewDesc, _ViewDesc5);\n var _super6 = _createSuper(TrailingHackViewDesc);\n function TrailingHackViewDesc() {\n _classCallCheck(this, TrailingHackViewDesc);\n return _super6.apply(this, arguments);\n }\n _createClass(TrailingHackViewDesc, [{\n key: \"parseRule\",\n value: function parseRule() {\n return {\n ignore: true\n };\n }\n }, {\n key: \"matchesHack\",\n value: function matchesHack(nodeName) {\n return this.dirty == NOT_DIRTY && this.dom.nodeName == nodeName;\n }\n }, {\n key: \"domAtom\",\n get: function get() {\n return true;\n }\n }, {\n key: \"ignoreForCoords\",\n get: function get() {\n return this.dom.nodeName == \"IMG\";\n }\n }]);\n return TrailingHackViewDesc;\n}(ViewDesc);\nvar CustomNodeViewDesc = function (_NodeViewDesc2) {\n _inherits(CustomNodeViewDesc, _NodeViewDesc2);\n var _super7 = _createSuper(CustomNodeViewDesc);\n function CustomNodeViewDesc(parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM, spec) {\n var _this7;\n _classCallCheck(this, CustomNodeViewDesc);\n _this7 = _super7.call(this, parent, node, outerDeco, innerDeco, dom, contentDOM, nodeDOM);\n _this7.spec = spec;\n return _this7;\n }\n _createClass(CustomNodeViewDesc, [{\n key: \"update\",\n value: function update(node, outerDeco, innerDeco, view) {\n if (this.dirty == NODE_DIRTY) return false;\n if (this.spec.update && (this.node.type == node.type || this.spec.multiType)) {\n var result = this.spec.update(node, outerDeco, innerDeco);\n if (result) this.updateInner(node, outerDeco, innerDeco, view);\n return result;\n } else if (!this.contentDOM && !node.isLeaf) {\n return false;\n } else {\n return _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"update\", this).call(this, node, outerDeco, innerDeco, view);\n }\n }\n }, {\n key: \"selectNode\",\n value: function selectNode() {\n this.spec.selectNode ? this.spec.selectNode() : _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"selectNode\", this).call(this);\n }\n }, {\n key: \"deselectNode\",\n value: function deselectNode() {\n this.spec.deselectNode ? this.spec.deselectNode() : _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"deselectNode\", this).call(this);\n }\n }, {\n key: \"setSelection\",\n value: function setSelection(anchor, head, view, force) {\n this.spec.setSelection ? this.spec.setSelection(anchor, head, view.root) : _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"setSelection\", this).call(this, anchor, head, view, force);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n if (this.spec.destroy) this.spec.destroy();\n _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"destroy\", this).call(this);\n }\n }, {\n key: \"stopEvent\",\n value: function stopEvent(event) {\n return this.spec.stopEvent ? this.spec.stopEvent(event) : false;\n }\n }, {\n key: \"ignoreMutation\",\n value: function ignoreMutation(mutation) {\n return this.spec.ignoreMutation ? this.spec.ignoreMutation(mutation) : _get(_getPrototypeOf(CustomNodeViewDesc.prototype), \"ignoreMutation\", this).call(this, mutation);\n }\n }]);\n return CustomNodeViewDesc;\n}(NodeViewDesc);\nfunction renderDescs(parentDOM, descs, view) {\n var dom = parentDOM.firstChild,\n written = false;\n for (var i = 0; i < descs.length; i++) {\n var desc = descs[i],\n childDOM = desc.dom;\n if (childDOM.parentNode == parentDOM) {\n while (childDOM != dom) {\n dom = rm(dom);\n written = true;\n }\n dom = dom.nextSibling;\n } else {\n written = true;\n parentDOM.insertBefore(childDOM, dom);\n }\n if (desc instanceof MarkViewDesc) {\n var pos = dom ? dom.previousSibling : parentDOM.lastChild;\n renderDescs(desc.contentDOM, desc.children, view);\n dom = pos ? pos.nextSibling : parentDOM.firstChild;\n }\n }\n while (dom) {\n dom = rm(dom);\n written = true;\n }\n if (written && view.trackWrites == parentDOM) view.trackWrites = null;\n}\nvar OuterDecoLevel = function OuterDecoLevel(nodeName) {\n if (nodeName) this.nodeName = nodeName;\n};\nOuterDecoLevel.prototype = Object.create(null);\nvar noDeco = [new OuterDecoLevel()];\nfunction computeOuterDeco(outerDeco, node, needsWrap) {\n if (outerDeco.length == 0) return noDeco;\n var top = needsWrap ? noDeco[0] : new OuterDecoLevel(),\n result = [top];\n for (var i = 0; i < outerDeco.length; i++) {\n var attrs = outerDeco[i].type.attrs;\n if (!attrs) continue;\n if (attrs.nodeName) result.push(top = new OuterDecoLevel(attrs.nodeName));\n for (var name in attrs) {\n var val = attrs[name];\n if (val == null) continue;\n if (needsWrap && result.length == 1) result.push(top = new OuterDecoLevel(node.isInline ? \"span\" : \"div\"));\n if (name == \"class\") top[\"class\"] = (top[\"class\"] ? top[\"class\"] + \" \" : \"\") + val;else if (name == \"style\") top.style = (top.style ? top.style + \";\" : \"\") + val;else if (name != \"nodeName\") top[name] = val;\n }\n }\n return result;\n}\nfunction patchOuterDeco(outerDOM, nodeDOM, prevComputed, curComputed) {\n if (prevComputed == noDeco && curComputed == noDeco) return nodeDOM;\n var curDOM = nodeDOM;\n for (var i = 0; i < curComputed.length; i++) {\n var deco = curComputed[i],\n prev = prevComputed[i];\n if (i) {\n var parent = void 0;\n if (prev && prev.nodeName == deco.nodeName && curDOM != outerDOM && (parent = curDOM.parentNode) && parent.nodeName.toLowerCase() == deco.nodeName) {\n curDOM = parent;\n } else {\n parent = document.createElement(deco.nodeName);\n parent.pmIsDeco = true;\n parent.appendChild(curDOM);\n prev = noDeco[0];\n curDOM = parent;\n }\n }\n patchAttributes(curDOM, prev || noDeco[0], deco);\n }\n return curDOM;\n}\nfunction patchAttributes(dom, prev, cur) {\n for (var name in prev) if (name != \"class\" && name != \"style\" && name != \"nodeName\" && !(name in cur)) dom.removeAttribute(name);\n for (var _name in cur) if (_name != \"class\" && _name != \"style\" && _name != \"nodeName\" && cur[_name] != prev[_name]) dom.setAttribute(_name, cur[_name]);\n if (prev[\"class\"] != cur[\"class\"]) {\n var prevList = prev[\"class\"] ? prev[\"class\"].split(\" \").filter(Boolean) : [];\n var curList = cur[\"class\"] ? cur[\"class\"].split(\" \").filter(Boolean) : [];\n for (var i = 0; i < prevList.length; i++) if (curList.indexOf(prevList[i]) == -1) dom.classList.remove(prevList[i]);\n for (var _i2 = 0; _i2 < curList.length; _i2++) if (prevList.indexOf(curList[_i2]) == -1) dom.classList.add(curList[_i2]);\n if (dom.classList.length == 0) dom.removeAttribute(\"class\");\n }\n if (prev.style != cur.style) {\n if (prev.style) {\n var prop = /\\s*([\\w\\-\\xa1-\\uffff]+)\\s*:(?:\"(?:\\\\.|[^\"])*\"|'(?:\\\\.|[^'])*'|\\(.*?\\)|[^;])*/g,\n m;\n while (m = prop.exec(prev.style)) dom.style.removeProperty(m[1]);\n }\n if (cur.style) dom.style.cssText += cur.style;\n }\n}\nfunction applyOuterDeco(dom, deco, node) {\n return patchOuterDeco(dom, dom, noDeco, computeOuterDeco(deco, node, dom.nodeType != 1));\n}\nfunction sameOuterDeco(a, b) {\n if (a.length != b.length) return false;\n for (var i = 0; i < a.length; i++) if (!a[i].type.eq(b[i].type)) return false;\n return true;\n}\nfunction rm(dom) {\n var next = dom.nextSibling;\n dom.parentNode.removeChild(dom);\n return next;\n}\nvar ViewTreeUpdater = function () {\n function ViewTreeUpdater(top, lock, view) {\n _classCallCheck(this, ViewTreeUpdater);\n this.lock = lock;\n this.view = view;\n this.index = 0;\n this.stack = [];\n this.changed = false;\n this.top = top;\n this.preMatch = preMatch(top.node.content, top);\n }\n _createClass(ViewTreeUpdater, [{\n key: \"destroyBetween\",\n value: function destroyBetween(start, end) {\n if (start == end) return;\n for (var i = start; i < end; i++) this.top.children[i].destroy();\n this.top.children.splice(start, end - start);\n this.changed = true;\n }\n }, {\n key: \"destroyRest\",\n value: function destroyRest() {\n this.destroyBetween(this.index, this.top.children.length);\n }\n }, {\n key: \"syncToMarks\",\n value: function syncToMarks(marks, inline, view, parentIndex) {\n var keep = 0,\n depth = this.stack.length >> 1;\n var maxKeep = Math.min(depth, marks.length);\n while (keep < maxKeep && (keep == depth - 1 ? this.top : this.stack[keep + 1 << 1]).matchesMark(marks[keep]) && marks[keep].type.spec.spanning !== false) keep++;\n while (keep < depth) {\n this.destroyRest();\n this.top.dirty = NOT_DIRTY;\n this.index = this.stack.pop();\n this.top = this.stack.pop();\n depth--;\n }\n while (depth < marks.length) {\n this.stack.push(this.top, this.index + 1);\n var found = -1,\n scanTo = this.top.children.length;\n if (parentIndex < this.preMatch.index) scanTo = Math.min(this.index + 3, scanTo);\n for (var i = this.index; i < scanTo; i++) {\n var next = this.top.children[i];\n if (next.matchesMark(marks[depth]) && !this.isLocked(next.dom)) {\n found = i;\n break;\n }\n }\n if (found < 0 && this.index < this.top.children.length) {\n var cur = this.top.children[this.index];\n if (cur instanceof MarkViewDesc && cur.dirty != NODE_DIRTY && cur.mark.type == marks[depth].type && cur.spec.update && !this.isLocked(cur.dom) && cur.spec.update(marks[depth])) {\n cur.mark = marks[depth];\n found = this.index;\n this.changed = true;\n }\n }\n if (found > -1) {\n if (found > this.index) {\n this.changed = true;\n this.destroyBetween(this.index, found);\n }\n this.top = this.top.children[this.index];\n } else {\n var markDesc = MarkViewDesc.create(this.top, marks[depth], inline, view);\n this.top.children.splice(this.index, 0, markDesc);\n this.top = markDesc;\n this.changed = true;\n }\n this.index = 0;\n depth++;\n }\n }\n }, {\n key: \"findNodeMatch\",\n value: function findNodeMatch(node, outerDeco, innerDeco, index) {\n var found = -1,\n targetDesc;\n if (index >= this.preMatch.index && (targetDesc = this.preMatch.matches[index - this.preMatch.index]).parent == this.top && targetDesc.matchesNode(node, outerDeco, innerDeco)) {\n found = this.top.children.indexOf(targetDesc, this.index);\n } else {\n for (var i = this.index, e = Math.min(this.top.children.length, i + 5); i < e; i++) {\n var child = this.top.children[i];\n if (child.matchesNode(node, outerDeco, innerDeco) && !this.preMatch.matched.has(child)) {\n found = i;\n break;\n }\n }\n }\n if (found < 0) return false;\n this.destroyBetween(this.index, found);\n this.index++;\n return true;\n }\n }, {\n key: \"updateNodeAt\",\n value: function updateNodeAt(node, outerDeco, innerDeco, index, view) {\n var child = this.top.children[index];\n if (child.dirty == NODE_DIRTY && child.dom == child.contentDOM) child.dirty = CONTENT_DIRTY;\n if (!child.update(node, outerDeco, innerDeco, view)) return false;\n this.destroyBetween(this.index, index);\n this.index++;\n return true;\n }\n }, {\n key: \"findIndexWithChild\",\n value: function findIndexWithChild(domNode) {\n for (;;) {\n var parent = domNode.parentNode;\n if (!parent) return -1;\n if (parent == this.top.contentDOM) {\n var desc = domNode.pmViewDesc;\n if (desc) for (var i = this.index; i < this.top.children.length; i++) {\n if (this.top.children[i] == desc) return i;\n }\n return -1;\n }\n domNode = parent;\n }\n }\n }, {\n key: \"updateNextNode\",\n value: function updateNextNode(node, outerDeco, innerDeco, view, index, pos) {\n for (var i = this.index; i < this.top.children.length; i++) {\n var next = this.top.children[i];\n if (next instanceof NodeViewDesc) {\n var _preMatch = this.preMatch.matched.get(next);\n if (_preMatch != null && _preMatch != index) return false;\n var nextDOM = next.dom,\n updated = void 0;\n var locked = this.isLocked(nextDOM) && !(node.isText && next.node && next.node.isText && next.nodeDOM.nodeValue == node.text && next.dirty != NODE_DIRTY && sameOuterDeco(outerDeco, next.outerDeco));\n if (!locked && next.update(node, outerDeco, innerDeco, view)) {\n this.destroyBetween(this.index, i);\n if (next.dom != nextDOM) this.changed = true;\n this.index++;\n return true;\n } else if (!locked && (updated = this.recreateWrapper(next, node, outerDeco, innerDeco, view, pos))) {\n this.destroyBetween(this.index, i);\n this.top.children[this.index] = updated;\n if (updated.contentDOM) {\n updated.dirty = CONTENT_DIRTY;\n updated.updateChildren(view, pos + 1);\n updated.dirty = NOT_DIRTY;\n }\n this.changed = true;\n this.index++;\n return true;\n }\n break;\n }\n }\n return false;\n }\n }, {\n key: \"recreateWrapper\",\n value: function recreateWrapper(next, node, outerDeco, innerDeco, view, pos) {\n if (next.dirty || node.isAtom || !next.children.length || !next.node.content.eq(node.content) || !sameOuterDeco(outerDeco, next.outerDeco) || !innerDeco.eq(next.innerDeco)) return null;\n var wrapper = NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos);\n if (wrapper.contentDOM) {\n wrapper.children = next.children;\n next.children = [];\n var _iterator = _createForOfIteratorHelper(wrapper.children),\n _step;\n try {\n for (_iterator.s(); !(_step = _iterator.n()).done;) {\n var ch = _step.value;\n ch.parent = wrapper;\n }\n } catch (err) {\n _iterator.e(err);\n } finally {\n _iterator.f();\n }\n }\n next.destroy();\n return wrapper;\n }\n }, {\n key: \"addNode\",\n value: function addNode(node, outerDeco, innerDeco, view, pos) {\n var desc = NodeViewDesc.create(this.top, node, outerDeco, innerDeco, view, pos);\n if (desc.contentDOM) desc.updateChildren(view, pos + 1);\n this.top.children.splice(this.index++, 0, desc);\n this.changed = true;\n }\n }, {\n key: \"placeWidget\",\n value: function placeWidget(widget, view, pos) {\n var next = this.index < this.top.children.length ? this.top.children[this.index] : null;\n if (next && next.matchesWidget(widget) && (widget == next.widget || !next.widget.type.toDOM.parentNode)) {\n this.index++;\n } else {\n var desc = new WidgetViewDesc(this.top, widget, view, pos);\n this.top.children.splice(this.index++, 0, desc);\n this.changed = true;\n }\n }\n }, {\n key: \"addTextblockHacks\",\n value: function addTextblockHacks() {\n var lastChild = this.top.children[this.index - 1],\n parent = this.top;\n while (lastChild instanceof MarkViewDesc) {\n parent = lastChild;\n lastChild = parent.children[parent.children.length - 1];\n }\n if (!lastChild || !(lastChild instanceof TextViewDesc) || /\\n$/.test(lastChild.node.text) || this.view.requiresGeckoHackNode && /\\s$/.test(lastChild.node.text)) {\n if ((safari || chrome) && lastChild && lastChild.dom.contentEditable == \"false\") this.addHackNode(\"IMG\", parent);\n this.addHackNode(\"BR\", this.top);\n }\n }\n }, {\n key: \"addHackNode\",\n value: function addHackNode(nodeName, parent) {\n if (parent == this.top && this.index < parent.children.length && parent.children[this.index].matchesHack(nodeName)) {\n this.index++;\n } else {\n var dom = document.createElement(nodeName);\n if (nodeName == \"IMG\") {\n dom.className = \"ProseMirror-separator\";\n dom.alt = \"\";\n }\n if (nodeName == \"BR\") dom.className = \"ProseMirror-trailingBreak\";\n var hack = new TrailingHackViewDesc(this.top, [], dom, null);\n if (parent != this.top) parent.children.push(hack);else parent.children.splice(this.index++, 0, hack);\n this.changed = true;\n }\n }\n }, {\n key: \"isLocked\",\n value: function isLocked(node) {\n return this.lock && (node == this.lock || node.nodeType == 1 && node.contains(this.lock.parentNode));\n }\n }]);\n return ViewTreeUpdater;\n}();\nfunction preMatch(frag, parentDesc) {\n var curDesc = parentDesc,\n descI = curDesc.children.length;\n var fI = frag.childCount,\n matched = new Map(),\n matches = [];\n outer: while (fI > 0) {\n var desc = void 0;\n for (;;) {\n if (descI) {\n var next = curDesc.children[descI - 1];\n if (next instanceof MarkViewDesc) {\n curDesc = next;\n descI = next.children.length;\n } else {\n desc = next;\n descI--;\n break;\n }\n } else if (curDesc == parentDesc) {\n break outer;\n } else {\n descI = curDesc.parent.children.indexOf(curDesc);\n curDesc = curDesc.parent;\n }\n }\n var node = desc.node;\n if (!node) continue;\n if (node != frag.child(fI - 1)) break;\n --fI;\n matched.set(desc, fI);\n matches.push(desc);\n }\n return {\n index: fI,\n matched: matched,\n matches: matches.reverse()\n };\n}\nfunction compareSide(a, b) {\n return a.type.side - b.type.side;\n}\nfunction iterDeco(parent, deco, onWidget, onNode) {\n var locals = deco.locals(parent),\n offset = 0;\n if (locals.length == 0) {\n for (var i = 0; i < parent.childCount; i++) {\n var child = parent.child(i);\n onNode(child, locals, deco.forChild(offset, child), i);\n offset += child.nodeSize;\n }\n return;\n }\n var decoIndex = 0,\n active = [],\n restNode = null;\n for (var parentIndex = 0;;) {\n var widget = void 0,\n widgets = void 0;\n while (decoIndex < locals.length && locals[decoIndex].to == offset) {\n var next = locals[decoIndex++];\n if (next.widget) {\n if (!widget) widget = next;else (widgets || (widgets = [widget])).push(next);\n }\n }\n if (widget) {\n if (widgets) {\n widgets.sort(compareSide);\n for (var _i3 = 0; _i3 < widgets.length; _i3++) onWidget(widgets[_i3], parentIndex, !!restNode);\n } else {\n onWidget(widget, parentIndex, !!restNode);\n }\n }\n var _child = void 0,\n index = void 0;\n if (restNode) {\n index = -1;\n _child = restNode;\n restNode = null;\n } else if (parentIndex < parent.childCount) {\n index = parentIndex;\n _child = parent.child(parentIndex++);\n } else {\n break;\n }\n for (var _i4 = 0; _i4 < active.length; _i4++) if (active[_i4].to <= offset) active.splice(_i4--, 1);\n while (decoIndex < locals.length && locals[decoIndex].from <= offset && locals[decoIndex].to > offset) active.push(locals[decoIndex++]);\n var end = offset + _child.nodeSize;\n if (_child.isText) {\n var cutAt = end;\n if (decoIndex < locals.length && locals[decoIndex].from < cutAt) cutAt = locals[decoIndex].from;\n for (var _i5 = 0; _i5 < active.length; _i5++) if (active[_i5].to < cutAt) cutAt = active[_i5].to;\n if (cutAt < end) {\n restNode = _child.cut(cutAt - offset);\n _child = _child.cut(0, cutAt - offset);\n end = cutAt;\n index = -1;\n }\n } else {\n while (decoIndex < locals.length && locals[decoIndex].to < end) decoIndex++;\n }\n var outerDeco = _child.isInline && !_child.isLeaf ? active.filter(function (d) {\n return !d.inline;\n }) : active.slice();\n onNode(_child, outerDeco, deco.forChild(offset, _child), index);\n offset = end;\n }\n}\nfunction iosHacks(dom) {\n if (dom.nodeName == \"UL\" || dom.nodeName == \"OL\") {\n var oldCSS = dom.style.cssText;\n dom.style.cssText = oldCSS + \"; list-style: square !important\";\n window.getComputedStyle(dom).listStyle;\n dom.style.cssText = oldCSS;\n }\n}\nfunction findTextInFragment(frag, text, from, to) {\n for (var i = 0, pos = 0; i < frag.childCount && pos <= to;) {\n var child = frag.child(i++),\n childStart = pos;\n pos += child.nodeSize;\n if (!child.isText) continue;\n var str = child.text;\n while (i < frag.childCount) {\n var next = frag.child(i++);\n pos += next.nodeSize;\n if (!next.isText) break;\n str += next.text;\n }\n if (pos >= from) {\n if (pos >= to && str.slice(to - text.length - childStart, to - childStart) == text) return to - text.length;\n var found = childStart < to ? str.lastIndexOf(text, to - childStart - 1) : -1;\n if (found >= 0 && found + text.length + childStart >= from) return childStart + found;\n if (from == to && str.length >= to + text.length - childStart && str.slice(to - childStart, to - childStart + text.length) == text) return to;\n }\n }\n return -1;\n}\nfunction replaceNodes(nodes, from, to, view, replacement) {\n var result = [];\n for (var i = 0, off = 0; i < nodes.length; i++) {\n var child = nodes[i],\n start = off,\n end = off += child.size;\n if (start >= to || end <= from) {\n result.push(child);\n } else {\n if (start < from) result.push(child.slice(0, from - start, view));\n if (replacement) {\n result.push(replacement);\n replacement = undefined;\n }\n if (end > to) result.push(child.slice(to - start, child.size, view));\n }\n }\n return result;\n}\nfunction selectionFromDOM(view) {\n var origin = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;\n var domSel = view.domSelectionRange(),\n doc = view.state.doc;\n if (!domSel.focusNode) return null;\n var nearestDesc = view.docView.nearestDesc(domSel.focusNode),\n inWidget = nearestDesc && nearestDesc.size == 0;\n var head = view.docView.posFromDOM(domSel.focusNode, domSel.focusOffset, 1);\n if (head < 0) return null;\n var $head = doc.resolve(head),\n anchor,\n selection;\n if (selectionCollapsed(domSel)) {\n anchor = head;\n while (nearestDesc && !nearestDesc.node) nearestDesc = nearestDesc.parent;\n var nearestDescNode = nearestDesc.node;\n if (nearestDesc && nearestDescNode.isAtom && prosemirrorState.NodeSelection.isSelectable(nearestDescNode) && nearestDesc.parent && !(nearestDescNode.isInline && isOnEdge(domSel.focusNode, domSel.focusOffset, nearestDesc.dom))) {\n var pos = nearestDesc.posBefore;\n selection = new prosemirrorState.NodeSelection(head == pos ? $head : doc.resolve(pos));\n }\n } else {\n if (domSel instanceof view.dom.ownerDocument.defaultView.Selection && domSel.rangeCount > 1) {\n var min = head,\n max = head;\n for (var i = 0; i < domSel.rangeCount; i++) {\n var range = domSel.getRangeAt(i);\n min = Math.min(min, view.docView.posFromDOM(range.startContainer, range.startOffset, 1));\n max = Math.max(max, view.docView.posFromDOM(range.endContainer, range.endOffset, -1));\n }\n if (min < 0) return null;\n var _ref3 = max == view.state.selection.anchor ? [max, min] : [min, max];\n var _ref4 = _slicedToArray(_ref3, 2);\n anchor = _ref4[0];\n head = _ref4[1];\n $head = doc.resolve(head);\n } else {\n anchor = view.docView.posFromDOM(domSel.anchorNode, domSel.anchorOffset, 1);\n }\n if (anchor < 0) return null;\n }\n var $anchor = doc.resolve(anchor);\n if (!selection) {\n var bias = origin == \"pointer\" || view.state.selection.head < $head.pos && !inWidget ? 1 : -1;\n selection = selectionBetween(view, $anchor, $head, bias);\n }\n return selection;\n}\nfunction editorOwnsSelection(view) {\n return view.editable ? view.hasFocus() : hasSelection(view) && document.activeElement && document.activeElement.contains(view.dom);\n}\nfunction selectionToDOM(view) {\n var force = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n var sel = view.state.selection;\n syncNodeSelection(view, sel);\n if (!editorOwnsSelection(view)) return;\n var mouseDown = view.input.mouseDown;\n if (!force && chrome && mouseDown) {\n var domSel = view.domSelectionRange(),\n curSel = view.domObserver.currentSelection;\n if (domSel.anchorNode && curSel.anchorNode && isEquivalentPosition(domSel.anchorNode, domSel.anchorOffset, curSel.anchorNode, curSel.anchorOffset) && mouseDown.delaySelUpdate()) {\n view.domObserver.setCurSelection();\n return;\n }\n }\n view.domObserver.disconnectSelection();\n if (view.cursorWrapper) {\n selectCursorWrapper(view);\n } else {\n var anchor = sel.anchor,\n head = sel.head,\n resetEditableFrom,\n resetEditableTo;\n if (brokenSelectBetweenUneditable && !(sel instanceof prosemirrorState.TextSelection)) {\n if (!sel.$from.parent.inlineContent) resetEditableFrom = temporarilyEditableNear(view, sel.from);\n if (!sel.empty && !sel.$from.parent.inlineContent) resetEditableTo = temporarilyEditableNear(view, sel.to);\n }\n view.docView.setSelection(anchor, head, view, force);\n if (brokenSelectBetweenUneditable) {\n if (resetEditableFrom) resetEditable(resetEditableFrom);\n if (resetEditableTo) resetEditable(resetEditableTo);\n }\n if (sel.visible) {\n view.dom.classList.remove(\"ProseMirror-hideselection\");\n } else {\n view.dom.classList.add(\"ProseMirror-hideselection\");\n if (\"onselectionchange\" in document) removeClassOnSelectionChange(view);\n }\n }\n view.domObserver.setCurSelection();\n view.domObserver.connectSelection();\n}\nvar brokenSelectBetweenUneditable = safari || chrome && chrome_version < 63;\nfunction temporarilyEditableNear(view, pos) {\n var _view$docView$domFrom3 = view.docView.domFromPos(pos, 0),\n node = _view$docView$domFrom3.node,\n offset = _view$docView$domFrom3.offset;\n var after = offset < node.childNodes.length ? node.childNodes[offset] : null;\n var before = offset ? node.childNodes[offset - 1] : null;\n if (safari && after && after.contentEditable == \"false\") return setEditable(after);\n if ((!after || after.contentEditable == \"false\") && (!before || before.contentEditable == \"false\")) {\n if (after) return setEditable(after);else if (before) return setEditable(before);\n }\n}\nfunction setEditable(element) {\n element.contentEditable = \"true\";\n if (safari && element.draggable) {\n element.draggable = false;\n element.wasDraggable = true;\n }\n return element;\n}\nfunction resetEditable(element) {\n element.contentEditable = \"false\";\n if (element.wasDraggable) {\n element.draggable = true;\n element.wasDraggable = null;\n }\n}\nfunction removeClassOnSelectionChange(view) {\n var doc = view.dom.ownerDocument;\n doc.removeEventListener(\"selectionchange\", view.input.hideSelectionGuard);\n var domSel = view.domSelectionRange();\n var node = domSel.anchorNode,\n offset = domSel.anchorOffset;\n doc.addEventListener(\"selectionchange\", view.input.hideSelectionGuard = function () {\n if (domSel.anchorNode != node || domSel.anchorOffset != offset) {\n doc.removeEventListener(\"selectionchange\", view.input.hideSelectionGuard);\n setTimeout(function () {\n if (!editorOwnsSelection(view) || view.state.selection.visible) view.dom.classList.remove(\"ProseMirror-hideselection\");\n }, 20);\n }\n });\n}\nfunction selectCursorWrapper(view) {\n var domSel = view.domSelection();\n if (!domSel) return;\n var node = view.cursorWrapper.dom,\n img = node.nodeName == \"IMG\";\n if (img) domSel.collapse(node.parentNode, domIndex(node) + 1);else domSel.collapse(node, 0);\n if (!img && !view.state.selection.visible && ie && ie_version <= 11) {\n node.disabled = true;\n node.disabled = false;\n }\n}\nfunction syncNodeSelection(view, sel) {\n if (sel instanceof prosemirrorState.NodeSelection) {\n var desc = view.docView.descAt(sel.from);\n if (desc != view.lastSelectedViewDesc) {\n clearNodeSelection(view);\n if (desc) desc.selectNode();\n view.lastSelectedViewDesc = desc;\n }\n } else {\n clearNodeSelection(view);\n }\n}\nfunction clearNodeSelection(view) {\n if (view.lastSelectedViewDesc) {\n if (view.lastSelectedViewDesc.parent) view.lastSelectedViewDesc.deselectNode();\n view.lastSelectedViewDesc = undefined;\n }\n}\nfunction selectionBetween(view, $anchor, $head, bias) {\n return view.someProp(\"createSelectionBetween\", function (f) {\n return f(view, $anchor, $head);\n }) || prosemirrorState.TextSelection.between($anchor, $head, bias);\n}\nfunction hasFocusAndSelection(view) {\n if (view.editable && !view.hasFocus()) return false;\n return hasSelection(view);\n}\nfunction hasSelection(view) {\n var sel = view.domSelectionRange();\n if (!sel.anchorNode) return false;\n try {\n return view.dom.contains(sel.anchorNode.nodeType == 3 ? sel.anchorNode.parentNode : sel.anchorNode) && (view.editable || view.dom.contains(sel.focusNode.nodeType == 3 ? sel.focusNode.parentNode : sel.focusNode));\n } catch (_) {\n return false;\n }\n}\nfunction anchorInRightPlace(view) {\n var anchorDOM = view.docView.domFromPos(view.state.selection.anchor, 0);\n var domSel = view.domSelectionRange();\n return isEquivalentPosition(anchorDOM.node, anchorDOM.offset, domSel.anchorNode, domSel.anchorOffset);\n}\nfunction moveSelectionBlock(state, dir) {\n var _state$selection = state.selection,\n $anchor = _state$selection.$anchor,\n $head = _state$selection.$head;\n var $side = dir > 0 ? $anchor.max($head) : $anchor.min($head);\n var $start = !$side.parent.inlineContent ? $side : $side.depth ? state.doc.resolve(dir > 0 ? $side.after() : $side.before()) : null;\n return $start && prosemirrorState.Selection.findFrom($start, dir);\n}\nfunction apply(view, sel) {\n view.dispatch(view.state.tr.setSelection(sel).scrollIntoView());\n return true;\n}\nfunction selectHorizontally(view, dir, mods) {\n var sel = view.state.selection;\n if (sel instanceof prosemirrorState.TextSelection) {\n if (mods.indexOf(\"s\") > -1) {\n var $head = sel.$head,\n node = $head.textOffset ? null : dir < 0 ? $head.nodeBefore : $head.nodeAfter;\n if (!node || node.isText || !node.isLeaf) return false;\n var $newHead = view.state.doc.resolve($head.pos + node.nodeSize * (dir < 0 ? -1 : 1));\n return apply(view, new prosemirrorState.TextSelection(sel.$anchor, $newHead));\n } else if (!sel.empty) {\n return false;\n } else if (view.endOfTextblock(dir > 0 ? \"forward\" : \"backward\")) {\n var next = moveSelectionBlock(view.state, dir);\n if (next && next instanceof prosemirrorState.NodeSelection) return apply(view, next);\n return false;\n } else if (!(mac && mods.indexOf(\"m\") > -1)) {\n var _$head = sel.$head,\n _node = _$head.textOffset ? null : dir < 0 ? _$head.nodeBefore : _$head.nodeAfter,\n desc;\n if (!_node || _node.isText) return false;\n var nodePos = dir < 0 ? _$head.pos - _node.nodeSize : _$head.pos;\n if (!(_node.isAtom || (desc = view.docView.descAt(nodePos)) && !desc.contentDOM)) return false;\n if (prosemirrorState.NodeSelection.isSelectable(_node)) {\n return apply(view, new prosemirrorState.NodeSelection(dir < 0 ? view.state.doc.resolve(_$head.pos - _node.nodeSize) : _$head));\n } else if (webkit) {\n return apply(view, new prosemirrorState.TextSelection(view.state.doc.resolve(dir < 0 ? nodePos : nodePos + _node.nodeSize)));\n } else {\n return false;\n }\n }\n } else if (sel instanceof prosemirrorState.NodeSelection && sel.node.isInline) {\n return apply(view, new prosemirrorState.TextSelection(dir > 0 ? sel.$to : sel.$from));\n } else {\n var _next = moveSelectionBlock(view.state, dir);\n if (_next) return apply(view, _next);\n return false;\n }\n}\nfunction nodeLen(node) {\n return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;\n}\nfunction isIgnorable(dom, dir) {\n var desc = dom.pmViewDesc;\n return desc && desc.size == 0 && (dir < 0 || dom.nextSibling || dom.nodeName != \"BR\");\n}\nfunction skipIgnoredNodes(view, dir) {\n return dir < 0 ? skipIgnoredNodesBefore(view) : skipIgnoredNodesAfter(view);\n}\nfunction skipIgnoredNodesBefore(view) {\n var sel = view.domSelectionRange();\n var node = sel.focusNode,\n offset = sel.focusOffset;\n if (!node) return;\n var moveNode,\n moveOffset,\n force = false;\n if (gecko && node.nodeType == 1 && offset < nodeLen(node) && isIgnorable(node.childNodes[offset], -1)) force = true;\n for (;;) {\n if (offset > 0) {\n if (node.nodeType != 1) {\n break;\n } else {\n var before = node.childNodes[offset - 1];\n if (isIgnorable(before, -1)) {\n moveNode = node;\n moveOffset = --offset;\n } else if (before.nodeType == 3) {\n node = before;\n offset = node.nodeValue.length;\n } else break;\n }\n } else if (isBlockNode(node)) {\n break;\n } else {\n var prev = node.previousSibling;\n while (prev && isIgnorable(prev, -1)) {\n moveNode = node.parentNode;\n moveOffset = domIndex(prev);\n prev = prev.previousSibling;\n }\n if (!prev) {\n node = node.parentNode;\n if (node == view.dom) break;\n offset = 0;\n } else {\n node = prev;\n offset = nodeLen(node);\n }\n }\n }\n if (force) setSelFocus(view, node, offset);else if (moveNode) setSelFocus(view, moveNode, moveOffset);\n}\nfunction skipIgnoredNodesAfter(view) {\n var sel = view.domSelectionRange();\n var node = sel.focusNode,\n offset = sel.focusOffset;\n if (!node) return;\n var len = nodeLen(node);\n var moveNode, moveOffset;\n for (;;) {\n if (offset < len) {\n if (node.nodeType != 1) break;\n var after = node.childNodes[offset];\n if (isIgnorable(after, 1)) {\n moveNode = node;\n moveOffset = ++offset;\n } else break;\n } else if (isBlockNode(node)) {\n break;\n } else {\n var next = node.nextSibling;\n while (next && isIgnorable(next, 1)) {\n moveNode = next.parentNode;\n moveOffset = domIndex(next) + 1;\n next = next.nextSibling;\n }\n if (!next) {\n node = node.parentNode;\n if (node == view.dom) break;\n offset = len = 0;\n } else {\n node = next;\n offset = 0;\n len = nodeLen(node);\n }\n }\n }\n if (moveNode) setSelFocus(view, moveNode, moveOffset);\n}\nfunction isBlockNode(dom) {\n var desc = dom.pmViewDesc;\n return desc && desc.node && desc.node.isBlock;\n}\nfunction textNodeAfter(node, offset) {\n while (node && offset == node.childNodes.length && !hasBlockDesc(node)) {\n offset = domIndex(node) + 1;\n node = node.parentNode;\n }\n while (node && offset < node.childNodes.length) {\n var next = node.childNodes[offset];\n if (next.nodeType == 3) return next;\n if (next.nodeType == 1 && next.contentEditable == \"false\") break;\n node = next;\n offset = 0;\n }\n}\nfunction textNodeBefore(node, offset) {\n while (node && !offset && !hasBlockDesc(node)) {\n offset = domIndex(node);\n node = node.parentNode;\n }\n while (node && offset) {\n var next = node.childNodes[offset - 1];\n if (next.nodeType == 3) return next;\n if (next.nodeType == 1 && next.contentEditable == \"false\") break;\n node = next;\n offset = node.childNodes.length;\n }\n}\nfunction setSelFocus(view, node, offset) {\n if (node.nodeType != 3) {\n var before, after;\n if (after = textNodeAfter(node, offset)) {\n node = after;\n offset = 0;\n } else if (before = textNodeBefore(node, offset)) {\n node = before;\n offset = before.nodeValue.length;\n }\n }\n var sel = view.domSelection();\n if (!sel) return;\n if (selectionCollapsed(sel)) {\n var range = document.createRange();\n range.setEnd(node, offset);\n range.setStart(node, offset);\n sel.removeAllRanges();\n sel.addRange(range);\n } else if (sel.extend) {\n sel.extend(node, offset);\n }\n view.domObserver.setCurSelection();\n var state = view.state;\n setTimeout(function () {\n if (view.state == state) selectionToDOM(view);\n }, 50);\n}\nfunction findDirection(view, pos) {\n var $pos = view.state.doc.resolve(pos);\n if (!(chrome || windows) && $pos.parent.inlineContent) {\n var coords = view.coordsAtPos(pos);\n if (pos > $pos.start()) {\n var before = view.coordsAtPos(pos - 1);\n var mid = (before.top + before.bottom) / 2;\n if (mid > coords.top && mid < coords.bottom && Math.abs(before.left - coords.left) > 1) return before.left < coords.left ? \"ltr\" : \"rtl\";\n }\n if (pos < $pos.end()) {\n var after = view.coordsAtPos(pos + 1);\n var _mid = (after.top + after.bottom) / 2;\n if (_mid > coords.top && _mid < coords.bottom && Math.abs(after.left - coords.left) > 1) return after.left > coords.left ? \"ltr\" : \"rtl\";\n }\n }\n var computed = getComputedStyle(view.dom).direction;\n return computed == \"rtl\" ? \"rtl\" : \"ltr\";\n}\nfunction selectVertically(view, dir, mods) {\n var sel = view.state.selection;\n if (sel instanceof prosemirrorState.TextSelection && !sel.empty || mods.indexOf(\"s\") > -1) return false;\n if (mac && mods.indexOf(\"m\") > -1) return false;\n var $from = sel.$from,\n $to = sel.$to;\n if (!$from.parent.inlineContent || view.endOfTextblock(dir < 0 ? \"up\" : \"down\")) {\n var next = moveSelectionBlock(view.state, dir);\n if (next && next instanceof prosemirrorState.NodeSelection) return apply(view, next);\n }\n if (!$from.parent.inlineContent) {\n var side = dir < 0 ? $from : $to;\n var beyond = sel instanceof prosemirrorState.AllSelection ? prosemirrorState.Selection.near(side, dir) : prosemirrorState.Selection.findFrom(side, dir);\n return beyond ? apply(view, beyond) : false;\n }\n return false;\n}\nfunction stopNativeHorizontalDelete(view, dir) {\n if (!(view.state.selection instanceof prosemirrorState.TextSelection)) return true;\n var _view$state$selection2 = view.state.selection,\n $head = _view$state$selection2.$head,\n $anchor = _view$state$selection2.$anchor,\n empty = _view$state$selection2.empty;\n if (!$head.sameParent($anchor)) return true;\n if (!empty) return false;\n if (view.endOfTextblock(dir > 0 ? \"forward\" : \"backward\")) return true;\n var nextNode = !$head.textOffset && (dir < 0 ? $head.nodeBefore : $head.nodeAfter);\n if (nextNode && !nextNode.isText) {\n var tr = view.state.tr;\n if (dir < 0) tr[\"delete\"]($head.pos - nextNode.nodeSize, $head.pos);else tr[\"delete\"]($head.pos, $head.pos + nextNode.nodeSize);\n view.dispatch(tr);\n return true;\n }\n return false;\n}\nfunction switchEditable(view, node, state) {\n view.domObserver.stop();\n node.contentEditable = state;\n view.domObserver.start();\n}\nfunction safariDownArrowBug(view) {\n if (!safari || view.state.selection.$head.parentOffset > 0) return false;\n var _view$domSelectionRan3 = view.domSelectionRange(),\n focusNode = _view$domSelectionRan3.focusNode,\n focusOffset = _view$domSelectionRan3.focusOffset;\n if (focusNode && focusNode.nodeType == 1 && focusOffset == 0 && focusNode.firstChild && focusNode.firstChild.contentEditable == \"false\") {\n var child = focusNode.firstChild;\n switchEditable(view, child, \"true\");\n setTimeout(function () {\n return switchEditable(view, child, \"false\");\n }, 20);\n }\n return false;\n}\nfunction getMods(event) {\n var result = \"\";\n if (event.ctrlKey) result += \"c\";\n if (event.metaKey) result += \"m\";\n if (event.altKey) result += \"a\";\n if (event.shiftKey) result += \"s\";\n return result;\n}\nfunction captureKeyDown(view, event) {\n var code = event.keyCode,\n mods = getMods(event);\n if (code == 8 || mac && code == 72 && mods == \"c\") {\n return stopNativeHorizontalDelete(view, -1) || skipIgnoredNodes(view, -1);\n } else if (code == 46 && !event.shiftKey || mac && code == 68 && mods == \"c\") {\n return stopNativeHorizontalDelete(view, 1) || skipIgnoredNodes(view, 1);\n } else if (code == 13 || code == 27) {\n return true;\n } else if (code == 37 || mac && code == 66 && mods == \"c\") {\n var dir = code == 37 ? findDirection(view, view.state.selection.from) == \"ltr\" ? -1 : 1 : -1;\n return selectHorizontally(view, dir, mods) || skipIgnoredNodes(view, dir);\n } else if (code == 39 || mac && code == 70 && mods == \"c\") {\n var _dir = code == 39 ? findDirection(view, view.state.selection.from) == \"ltr\" ? 1 : -1 : 1;\n return selectHorizontally(view, _dir, mods) || skipIgnoredNodes(view, _dir);\n } else if (code == 38 || mac && code == 80 && mods == \"c\") {\n return selectVertically(view, -1, mods) || skipIgnoredNodes(view, -1);\n } else if (code == 40 || mac && code == 78 && mods == \"c\") {\n return safariDownArrowBug(view) || selectVertically(view, 1, mods) || skipIgnoredNodes(view, 1);\n } else if (mods == (mac ? \"m\" : \"c\") && (code == 66 || code == 73 || code == 89 || code == 90)) {\n return true;\n }\n return false;\n}\nfunction _serializeForClipboard(view, slice) {\n view.someProp(\"transformCopied\", function (f) {\n slice = f(slice, view);\n });\n var context = [],\n _slice = slice,\n content = _slice.content,\n openStart = _slice.openStart,\n openEnd = _slice.openEnd;\n while (openStart > 1 && openEnd > 1 && content.childCount == 1 && content.firstChild.childCount == 1) {\n openStart--;\n openEnd--;\n var node = content.firstChild;\n context.push(node.type.name, node.attrs != node.type.defaultAttrs ? node.attrs : null);\n content = node.content;\n }\n var serializer = view.someProp(\"clipboardSerializer\") || prosemirrorModel.DOMSerializer.fromSchema(view.state.schema);\n var doc = detachedDoc(),\n wrap = doc.createElement(\"div\");\n wrap.appendChild(serializer.serializeFragment(content, {\n document: doc\n }));\n var firstChild = wrap.firstChild,\n needsWrap,\n wrappers = 0;\n while (firstChild && firstChild.nodeType == 1 && (needsWrap = wrapMap[firstChild.nodeName.toLowerCase()])) {\n for (var i = needsWrap.length - 1; i >= 0; i--) {\n var wrapper = doc.createElement(needsWrap[i]);\n while (wrap.firstChild) wrapper.appendChild(wrap.firstChild);\n wrap.appendChild(wrapper);\n wrappers++;\n }\n firstChild = wrap.firstChild;\n }\n if (firstChild && firstChild.nodeType == 1) firstChild.setAttribute(\"data-pm-slice\", \"\".concat(openStart, \" \").concat(openEnd).concat(wrappers ? \" -\".concat(wrappers) : \"\", \" \").concat(JSON.stringify(context)));\n var text = view.someProp(\"clipboardTextSerializer\", function (f) {\n return f(slice, view);\n }) || slice.content.textBetween(0, slice.content.size, \"\\n\\n\");\n return {\n dom: wrap,\n text: text,\n slice: slice\n };\n}\nfunction parseFromClipboard(view, text, html, plainText, $context) {\n var inCode = $context.parent.type.spec.code;\n var dom, slice;\n if (!html && !text) return null;\n var asText = !!text && (plainText || inCode || !html);\n if (asText) {\n view.someProp(\"transformPastedText\", function (f) {\n text = f(text, inCode || plainText, view);\n });\n if (inCode) {\n slice = new prosemirrorModel.Slice(prosemirrorModel.Fragment.from(view.state.schema.text(text.replace(/\\r\\n?/g, \"\\n\"))), 0, 0);\n view.someProp(\"transformPasted\", function (f) {\n slice = f(slice, view, true);\n });\n return slice;\n }\n var parsed = view.someProp(\"clipboardTextParser\", function (f) {\n return f(text, $context, plainText, view);\n });\n if (parsed) {\n slice = parsed;\n } else {\n var marks = $context.marks();\n var schema = view.state.schema,\n serializer = prosemirrorModel.DOMSerializer.fromSchema(schema);\n dom = document.createElement(\"div\");\n text.split(/(?:\\r\\n?|\\n)+/).forEach(function (block) {\n var p = dom.appendChild(document.createElement(\"p\"));\n if (block) p.appendChild(serializer.serializeNode(schema.text(block, marks)));\n });\n }\n } else {\n view.someProp(\"transformPastedHTML\", function (f) {\n html = f(html, view);\n });\n dom = readHTML(html);\n if (webkit) restoreReplacedSpaces(dom);\n }\n var contextNode = dom && dom.querySelector(\"[data-pm-slice]\");\n var sliceData = contextNode && /^(\\d+) (\\d+)(?: -(\\d+))? (.*)/.exec(contextNode.getAttribute(\"data-pm-slice\") || \"\");\n if (sliceData && sliceData[3]) for (var i = +sliceData[3]; i > 0; i--) {\n var child = dom.firstChild;\n while (child && child.nodeType != 1) child = child.nextSibling;\n if (!child) break;\n dom = child;\n }\n if (!slice) {\n var parser = view.someProp(\"clipboardParser\") || view.someProp(\"domParser\") || prosemirrorModel.DOMParser.fromSchema(view.state.schema);\n slice = parser.parseSlice(dom, {\n preserveWhitespace: !!(asText || sliceData),\n context: $context,\n ruleFromNode: function ruleFromNode(dom) {\n if (dom.nodeName == \"BR\" && !dom.nextSibling && dom.parentNode && !inlineParents.test(dom.parentNode.nodeName)) return {\n ignore: true\n };\n return null;\n }\n });\n }\n if (sliceData) {\n slice = addContext(closeSlice(slice, +sliceData[1], +sliceData[2]), sliceData[4]);\n } else {\n slice = prosemirrorModel.Slice.maxOpen(normalizeSiblings(slice.content, $context), true);\n if (slice.openStart || slice.openEnd) {\n var openStart = 0,\n openEnd = 0;\n for (var node = slice.content.firstChild; openStart < slice.openStart && !node.type.spec.isolating; openStart++, node = node.firstChild) {}\n for (var _node2 = slice.content.lastChild; openEnd < slice.openEnd && !_node2.type.spec.isolating; openEnd++, _node2 = _node2.lastChild) {}\n slice = closeSlice(slice, openStart, openEnd);\n }\n }\n view.someProp(\"transformPasted\", function (f) {\n slice = f(slice, view, asText);\n });\n return slice;\n}\nvar inlineParents = /^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var)$/i;\nfunction normalizeSiblings(fragment, $context) {\n if (fragment.childCount < 2) return fragment;\n var _loop = function _loop() {\n var parent = $context.node(d);\n var match = parent.contentMatchAt($context.index(d));\n var lastWrap,\n result = [];\n fragment.forEach(function (node) {\n if (!result) return;\n var wrap = match.findWrapping(node.type),\n inLast;\n if (!wrap) return result = null;\n if (inLast = result.length && lastWrap.length && addToSibling(wrap, lastWrap, node, result[result.length - 1], 0)) {\n result[result.length - 1] = inLast;\n } else {\n if (result.length) result[result.length - 1] = closeRight(result[result.length - 1], lastWrap.length);\n var wrapped = withWrappers(node, wrap);\n result.push(wrapped);\n match = match.matchType(wrapped.type);\n lastWrap = wrap;\n }\n });\n if (result) return {\n v: prosemirrorModel.Fragment.from(result)\n };\n },\n _ret;\n for (var d = $context.depth; d >= 0; d--) {\n _ret = _loop();\n if (_ret) return _ret.v;\n }\n return fragment;\n}\nfunction withWrappers(node, wrap) {\n var from = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;\n for (var i = wrap.length - 1; i >= from; i--) node = wrap[i].create(null, prosemirrorModel.Fragment.from(node));\n return node;\n}\nfunction addToSibling(wrap, lastWrap, node, sibling, depth) {\n if (depth < wrap.length && depth < lastWrap.length && wrap[depth] == lastWrap[depth]) {\n var inner = addToSibling(wrap, lastWrap, node, sibling.lastChild, depth + 1);\n if (inner) return sibling.copy(sibling.content.replaceChild(sibling.childCount - 1, inner));\n var match = sibling.contentMatchAt(sibling.childCount);\n if (match.matchType(depth == wrap.length - 1 ? node.type : wrap[depth + 1])) return sibling.copy(sibling.content.append(prosemirrorModel.Fragment.from(withWrappers(node, wrap, depth + 1))));\n }\n}\nfunction closeRight(node, depth) {\n if (depth == 0) return node;\n var fragment = node.content.replaceChild(node.childCount - 1, closeRight(node.lastChild, depth - 1));\n var fill = node.contentMatchAt(node.childCount).fillBefore(prosemirrorModel.Fragment.empty, true);\n return node.copy(fragment.append(fill));\n}\nfunction closeRange(fragment, side, from, to, depth, openEnd) {\n var node = side < 0 ? fragment.firstChild : fragment.lastChild,\n inner = node.content;\n if (fragment.childCount > 1) openEnd = 0;\n if (depth < to - 1) inner = closeRange(inner, side, from, to, depth + 1, openEnd);\n if (depth >= from) inner = side < 0 ? node.contentMatchAt(0).fillBefore(inner, openEnd <= depth).append(inner) : inner.append(node.contentMatchAt(node.childCount).fillBefore(prosemirrorModel.Fragment.empty, true));\n return fragment.replaceChild(side < 0 ? 0 : fragment.childCount - 1, node.copy(inner));\n}\nfunction closeSlice(slice, openStart, openEnd) {\n if (openStart < slice.openStart) slice = new prosemirrorModel.Slice(closeRange(slice.content, -1, openStart, slice.openStart, 0, slice.openEnd), openStart, slice.openEnd);\n if (openEnd < slice.openEnd) slice = new prosemirrorModel.Slice(closeRange(slice.content, 1, openEnd, slice.openEnd, 0, 0), slice.openStart, openEnd);\n return slice;\n}\nvar wrapMap = {\n thead: [\"table\"],\n tbody: [\"table\"],\n tfoot: [\"table\"],\n caption: [\"table\"],\n colgroup: [\"table\"],\n col: [\"table\", \"colgroup\"],\n tr: [\"table\", \"tbody\"],\n td: [\"table\", \"tbody\", \"tr\"],\n th: [\"table\", \"tbody\", \"tr\"]\n};\nfunction detachedDoc() {\n return document.implementation.createHTMLDocument(\"title\");\n}\nvar _policy = null;\nfunction maybeWrapTrusted(html) {\n var trustedTypes = window.trustedTypes;\n if (!trustedTypes) return html;\n if (!_policy) {\n if (_policy = trustedTypes.defaultPolicy) try {\n return _policy.createHTML(html);\n } catch (_a) {}\n _policy = trustedTypes.createPolicy(\"ProseMirrorClipboard\", {\n createHTML: function createHTML(s) {\n return s;\n }\n });\n }\n return _policy.createHTML(html);\n}\nfunction readHTML(html) {\n var metas = /^(\\s*<meta [^>]*>)*/.exec(html);\n if (metas) html = html.slice(metas[0].length);\n var doc = detachedDoc(),\n elt = doc.body;\n var firstTag = /<([a-z][^>\\s]+)/i.exec(html),\n wrap;\n if (wrap = firstTag && wrapMap[firstTag[1].toLowerCase()]) html = wrap.map(function (n) {\n return \"<\" + n + \">\";\n }).join(\"\") + html + wrap.map(function (n) {\n return \"</\" + n + \">\";\n }).reverse().join(\"\");\n elt.innerHTML = maybeWrapTrusted(html);\n if (wrap) for (var i = 0; i < wrap.length; i++) elt = elt.querySelector(wrap[i]) || elt;\n for (var _i6 = 0; _i6 < doc.styleSheets.length; _i6++) {\n var style = doc.styleSheets[_i6];\n for (var j = 0; j < style.rules.length; j++) {\n var rule = style.rules[j];\n if (rule instanceof CSSStyleRule) {\n var matches = elt.querySelectorAll(rule.selectorText);\n for (var k = 0; k < matches.length; k++) matches[k].style.cssText += rule.style.cssText;\n }\n }\n }\n return elt;\n}\nfunction restoreReplacedSpaces(dom) {\n var nodes = dom.querySelectorAll(chrome ? \"span:not([class]):not([style])\" : \"span.Apple-converted-space\");\n for (var i = 0; i < nodes.length; i++) {\n var node = nodes[i];\n if (node.childNodes.length == 1 && node.textContent == \"\\xA0\" && node.parentNode) node.parentNode.replaceChild(dom.ownerDocument.createTextNode(\" \"), node);\n }\n}\nfunction addContext(slice, context) {\n if (!slice.size) return slice;\n var schema = slice.content.firstChild.type.schema,\n array;\n try {\n array = JSON.parse(context);\n } catch (e) {\n return slice;\n }\n var content = slice.content,\n openStart = slice.openStart,\n openEnd = slice.openEnd;\n for (var i = array.length - 2; i >= 0; i -= 2) {\n var type = schema.nodes[array[i]];\n if (!type || type.hasRequiredAttrs()) break;\n try {\n type.checkAttrs(array[i + 1]);\n } catch (e) {\n break;\n }\n content = prosemirrorModel.Fragment.from(type.create(array[i + 1], content));\n openStart++;\n openEnd++;\n }\n return new prosemirrorModel.Slice(content, openStart, openEnd);\n}\nvar handlers = {};\nvar editHandlers = {};\nvar passiveHandlers = {\n touchstart: true,\n touchmove: true\n};\nvar InputState = _createClass(function InputState() {\n _classCallCheck(this, InputState);\n this.shiftKey = false;\n this.mouseDown = null;\n this.lastKeyCode = null;\n this.lastKeyCodeTime = 0;\n this.lastClick = {\n time: 0,\n x: 0,\n y: 0,\n type: \"\",\n button: 0\n };\n this.lastSelectionOrigin = null;\n this.lastSelectionTime = 0;\n this.lastIOSEnter = 0;\n this.lastIOSEnterFallbackTimeout = -1;\n this.lastFocus = 0;\n this.lastTouch = 0;\n this.lastChromeDelete = 0;\n this.composing = false;\n this.compositionNode = null;\n this.composingTimeout = -1;\n this.compositionNodes = [];\n this.compositionEndedAt = -2e8;\n this.compositionID = 1;\n this.badSafariComposition = false;\n this.compositionPendingChanges = 0;\n this.domChangeCount = 0;\n this.eventHandlers = Object.create(null);\n this.hideSelectionGuard = null;\n});\nfunction initInput(view) {\n var _loop2 = function _loop2() {\n var handler = handlers[event];\n view.dom.addEventListener(event, view.input.eventHandlers[event] = function (event) {\n if (eventBelongsToView(view, event) && !runCustomHandler(view, event) && (view.editable || !(event.type in editHandlers))) handler(view, event);\n }, passiveHandlers[event] ? {\n passive: true\n } : undefined);\n };\n for (var event in handlers) {\n _loop2();\n }\n if (safari) view.dom.addEventListener(\"input\", function () {\n return null;\n });\n ensureListeners(view);\n}\nfunction setSelectionOrigin(view, origin) {\n view.input.lastSelectionOrigin = origin;\n view.input.lastSelectionTime = Date.now();\n}\nfunction destroyInput(view) {\n if (view.input.mouseDown) view.input.mouseDown.done();\n view.domObserver.stop();\n for (var type in view.input.eventHandlers) view.dom.removeEventListener(type, view.input.eventHandlers[type]);\n clearTimeout(view.input.composingTimeout);\n clearTimeout(view.input.lastIOSEnterFallbackTimeout);\n}\nfunction ensureListeners(view) {\n view.someProp(\"handleDOMEvents\", function (currentHandlers) {\n for (var type in currentHandlers) if (!view.input.eventHandlers[type]) view.dom.addEventListener(type, view.input.eventHandlers[type] = function (event) {\n return runCustomHandler(view, event);\n });\n });\n}\nfunction runCustomHandler(view, event) {\n return view.someProp(\"handleDOMEvents\", function (handlers) {\n var handler = handlers[event.type];\n return handler ? handler(view, event) || event.defaultPrevented : false;\n });\n}\nfunction eventBelongsToView(view, event) {\n if (!event.bubbles) return true;\n if (event.defaultPrevented) return false;\n for (var node = event.target; node != view.dom; node = node.parentNode) if (!node || node.nodeType == 11 || node.pmViewDesc && node.pmViewDesc.stopEvent(event)) return false;\n return true;\n}\nfunction _dispatchEvent(view, event) {\n if (!runCustomHandler(view, event) && handlers[event.type] && (view.editable || !(event.type in editHandlers))) handlers[event.type](view, event);\n}\neditHandlers.keydown = function (view, _event) {\n var event = _event;\n view.input.shiftKey = event.keyCode == 16 || event.shiftKey;\n if (inOrNearComposition(view)) return;\n view.input.lastKeyCode = event.keyCode;\n view.input.lastKeyCodeTime = Date.now();\n if (android && chrome && event.keyCode == 13) return;\n if (event.keyCode != 229) view.domObserver.forceFlush();\n if (ios && event.keyCode == 13 && !event.ctrlKey && !event.altKey && !event.metaKey) {\n var now = Date.now();\n view.input.lastIOSEnter = now;\n view.input.lastIOSEnterFallbackTimeout = setTimeout(function () {\n if (view.input.lastIOSEnter == now) {\n view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n });\n view.input.lastIOSEnter = 0;\n }\n }, 200);\n } else if (view.someProp(\"handleKeyDown\", function (f) {\n return f(view, event);\n }) || captureKeyDown(view, event)) {\n event.preventDefault();\n } else {\n setSelectionOrigin(view, \"key\");\n }\n};\neditHandlers.keyup = function (view, event) {\n if (event.keyCode == 16) view.input.shiftKey = false;\n};\neditHandlers.keypress = function (view, _event) {\n var event = _event;\n if (inOrNearComposition(view) || !event.charCode || event.ctrlKey && !event.altKey || mac && event.metaKey) return;\n if (view.someProp(\"handleKeyPress\", function (f) {\n return f(view, event);\n })) {\n event.preventDefault();\n return;\n }\n var sel = view.state.selection;\n if (!(sel instanceof prosemirrorState.TextSelection) || !sel.$from.sameParent(sel.$to)) {\n var text = String.fromCharCode(event.charCode);\n var deflt = function deflt() {\n return view.state.tr.insertText(text).scrollIntoView();\n };\n if (!/[\\r\\n]/.test(text) && !view.someProp(\"handleTextInput\", function (f) {\n return f(view, sel.$from.pos, sel.$to.pos, text, deflt);\n })) view.dispatch(deflt());\n event.preventDefault();\n }\n};\nfunction eventCoords(event) {\n return {\n left: event.clientX,\n top: event.clientY\n };\n}\nfunction isNear(event, click) {\n var dx = click.x - event.clientX,\n dy = click.y - event.clientY;\n return dx * dx + dy * dy < 100;\n}\nfunction runHandlerOnContext(view, propName, pos, inside, event) {\n if (inside == -1) return false;\n var $pos = view.state.doc.resolve(inside);\n var _loop3 = function _loop3(i) {\n if (view.someProp(propName, function (f) {\n return i > $pos.depth ? f(view, pos, $pos.nodeAfter, $pos.before(i), event, true) : f(view, pos, $pos.node(i), $pos.before(i), event, false);\n })) return {\n v: true\n };\n },\n _ret2;\n for (var i = $pos.depth + 1; i > 0; i--) {\n _ret2 = _loop3(i);\n if (_ret2) return _ret2.v;\n }\n return false;\n}\nfunction updateSelection(view, selection, origin) {\n if (!view.focused) view.focus();\n if (view.state.selection.eq(selection)) return;\n var tr = view.state.tr.setSelection(selection);\n if (origin == \"pointer\") tr.setMeta(\"pointer\", true);\n view.dispatch(tr);\n}\nfunction selectClickedLeaf(view, inside) {\n if (inside == -1) return false;\n var $pos = view.state.doc.resolve(inside),\n node = $pos.nodeAfter;\n if (node && node.isAtom && prosemirrorState.NodeSelection.isSelectable(node)) {\n updateSelection(view, new prosemirrorState.NodeSelection($pos), \"pointer\");\n return true;\n }\n return false;\n}\nfunction selectClickedNode(view, inside) {\n if (inside == -1) return false;\n var sel = view.state.selection,\n selectedNode,\n selectAt;\n if (sel instanceof prosemirrorState.NodeSelection) selectedNode = sel.node;\n var $pos = view.state.doc.resolve(inside);\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n if (prosemirrorState.NodeSelection.isSelectable(node)) {\n if (selectedNode && sel.$from.depth > 0 && i >= sel.$from.depth && $pos.before(sel.$from.depth + 1) == sel.$from.pos) selectAt = $pos.before(sel.$from.depth);else selectAt = $pos.before(i);\n break;\n }\n }\n if (selectAt != null) {\n updateSelection(view, prosemirrorState.NodeSelection.create(view.state.doc, selectAt), \"pointer\");\n return true;\n } else {\n return false;\n }\n}\nfunction handleSingleClick(view, pos, inside, event, selectNode) {\n return runHandlerOnContext(view, \"handleClickOn\", pos, inside, event) || view.someProp(\"handleClick\", function (f) {\n return f(view, pos, event);\n }) || (selectNode ? selectClickedNode(view, inside) : selectClickedLeaf(view, inside));\n}\nfunction handleDoubleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleDoubleClickOn\", pos, inside, event) || view.someProp(\"handleDoubleClick\", function (f) {\n return f(view, pos, event);\n });\n}\nfunction handleTripleClick(view, pos, inside, event) {\n return runHandlerOnContext(view, \"handleTripleClickOn\", pos, inside, event) || view.someProp(\"handleTripleClick\", function (f) {\n return f(view, pos, event);\n }) || defaultTripleClick(view, inside, event);\n}\nfunction defaultTripleClick(view, inside, event) {\n if (event.button != 0) return false;\n var selection = selectionForTripleClick(view, inside, true),\n doc = view.state.doc;\n if (!selection) return false;\n updateSelection(view, selection, \"pointer\");\n if (selection instanceof prosemirrorState.TextSelection && doc.eq(view.state.doc)) view.input.mouseDown = new TripleClickDrag(view, selection);\n return true;\n}\nfunction selectionForTripleClick(view, inside, selectNodes) {\n var doc = view.state.doc;\n if (inside == -1) return doc.inlineContent ? prosemirrorState.TextSelection.create(doc, 0, doc.content.size) : null;\n var $pos = doc.resolve(inside);\n for (var i = $pos.depth + 1; i > 0; i--) {\n var node = i > $pos.depth ? $pos.nodeAfter : $pos.node(i);\n var nodePos = $pos.before(i);\n if (node.inlineContent) return prosemirrorState.TextSelection.create(doc, nodePos + 1, nodePos + 1 + node.content.size);else if (selectNodes && prosemirrorState.NodeSelection.isSelectable(node)) return prosemirrorState.NodeSelection.create(doc, nodePos);\n }\n return null;\n}\nfunction forceDOMFlush(view) {\n return endComposition(view);\n}\nvar selectNodeModifier = mac ? \"metaKey\" : \"ctrlKey\";\nhandlers.mousedown = function (view, _event) {\n var event = _event;\n view.input.shiftKey = event.shiftKey;\n var flushed = forceDOMFlush(view);\n var now = Date.now(),\n type = \"singleClick\";\n if (now - view.input.lastClick.time < 500 && isNear(event, view.input.lastClick) && !event[selectNodeModifier] && view.input.lastClick.button == event.button) {\n if (view.input.lastClick.type == \"singleClick\") type = \"doubleClick\";else if (view.input.lastClick.type == \"doubleClick\") type = \"tripleClick\";\n }\n view.input.lastClick = {\n time: now,\n x: event.clientX,\n y: event.clientY,\n type: type,\n button: event.button\n };\n if (view.input.mouseDown) view.input.mouseDown.done();\n var pos = view.posAtCoords(eventCoords(event));\n if (!pos) return;\n if (type == \"singleClick\") {\n view.input.mouseDown = new LeftMouseDown(view, pos, event, !!flushed);\n } else if ((type == \"doubleClick\" ? handleDoubleClick : handleTripleClick)(view, pos.pos, pos.inside, event)) {\n event.preventDefault();\n } else {\n setSelectionOrigin(view, \"pointer\");\n }\n};\nvar MouseDown = function () {\n function MouseDown(view) {\n _classCallCheck(this, MouseDown);\n this.view = view;\n this.mightDrag = null;\n view.root.addEventListener(\"mouseup\", this.up = this.up.bind(this));\n view.root.addEventListener(\"mousemove\", this.move = this.move.bind(this));\n }\n _createClass(MouseDown, [{\n key: \"up\",\n value: function up(event) {\n this.done();\n }\n }, {\n key: \"move\",\n value: function move(event) {\n if (event.buttons == 0) this.done();\n }\n }, {\n key: \"done\",\n value: function done() {\n this.view.root.removeEventListener(\"mouseup\", this.up);\n this.view.root.removeEventListener(\"mousemove\", this.move);\n if (this.view.input.mouseDown == this) this.view.input.mouseDown = null;\n }\n }, {\n key: \"delaySelUpdate\",\n value: function delaySelUpdate() {\n return false;\n }\n }]);\n return MouseDown;\n}();\nvar LeftMouseDown = function (_MouseDown) {\n _inherits(LeftMouseDown, _MouseDown);\n var _super8 = _createSuper(LeftMouseDown);\n function LeftMouseDown(view, pos, event, flushed) {\n var _this8;\n _classCallCheck(this, LeftMouseDown);\n _this8 = _super8.call(this, view);\n _this8.pos = pos;\n _this8.event = event;\n _this8.flushed = flushed;\n _this8.delayedSelectionSync = false;\n _this8.startDoc = view.state.doc;\n _this8.selectNode = !!event[selectNodeModifier];\n _this8.allowDefault = event.shiftKey;\n var targetNode, targetPos;\n if (pos.inside > -1) {\n targetNode = view.state.doc.nodeAt(pos.inside);\n targetPos = pos.inside;\n } else {\n var $pos = view.state.doc.resolve(pos.pos);\n targetNode = $pos.parent;\n targetPos = $pos.depth ? $pos.before() : 0;\n }\n var target = flushed ? null : event.target;\n var targetDesc = target ? view.docView.nearestDesc(target, true) : null;\n _this8.target = targetDesc && targetDesc.nodeDOM.nodeType == 1 ? targetDesc.nodeDOM : null;\n var selection = view.state.selection;\n if (event.button == 0 && (targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof prosemirrorState.NodeSelection && selection.from <= targetPos && selection.to > targetPos)) _this8.mightDrag = {\n node: targetNode,\n pos: targetPos,\n addAttr: !!(_this8.target && !_this8.target.draggable),\n setUneditable: !!(_this8.target && gecko && !_this8.target.hasAttribute(\"contentEditable\"))\n };\n if (_this8.target && _this8.mightDrag && (_this8.mightDrag.addAttr || _this8.mightDrag.setUneditable)) {\n _this8.view.domObserver.stop();\n if (_this8.mightDrag.addAttr) _this8.target.draggable = true;\n if (_this8.mightDrag.setUneditable) setTimeout(function () {\n if (_this8.view.input.mouseDown == _assertThisInitialized(_this8)) _this8.target.setAttribute(\"contentEditable\", \"false\");\n }, 20);\n _this8.view.domObserver.start();\n }\n setSelectionOrigin(view, \"pointer\");\n return _this8;\n }\n _createClass(LeftMouseDown, [{\n key: \"done\",\n value: function done() {\n var _this9 = this;\n _get(_getPrototypeOf(LeftMouseDown.prototype), \"done\", this).call(this);\n if (this.mightDrag && this.target) {\n this.view.domObserver.stop();\n if (this.mightDrag.addAttr) this.target.removeAttribute(\"draggable\");\n if (this.mightDrag.setUneditable) this.target.removeAttribute(\"contentEditable\");\n this.view.domObserver.start();\n }\n if (this.delayedSelectionSync) setTimeout(function () {\n if (!_this9.view.isDestroyed) selectionToDOM(_this9.view);\n });\n }\n }, {\n key: \"up\",\n value: function up(event) {\n this.done();\n if (!this.view.dom.contains(event.target)) return;\n var pos = this.pos;\n if (this.view.state.doc != this.startDoc) pos = this.view.posAtCoords(eventCoords(event));\n this.updateAllowDefault(event);\n if (this.allowDefault || !pos) {\n setSelectionOrigin(this.view, \"pointer\");\n } else if (handleSingleClick(this.view, pos.pos, pos.inside, event, this.selectNode)) {\n event.preventDefault();\n } else if (event.button == 0 && (this.flushed || safari && this.mightDrag && !this.mightDrag.node.isAtom || chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {\n updateSelection(this.view, prosemirrorState.Selection.near(this.view.state.doc.resolve(pos.pos)), \"pointer\");\n event.preventDefault();\n } else {\n setSelectionOrigin(this.view, \"pointer\");\n }\n }\n }, {\n key: \"move\",\n value: function move(event) {\n this.updateAllowDefault(event);\n setSelectionOrigin(this.view, \"pointer\");\n _get(_getPrototypeOf(LeftMouseDown.prototype), \"move\", this).call(this, event);\n }\n }, {\n key: \"updateAllowDefault\",\n value: function updateAllowDefault(event) {\n if (!this.allowDefault && (Math.abs(this.event.x - event.clientX) > 4 || Math.abs(this.event.y - event.clientY) > 4)) this.allowDefault = true;\n }\n }, {\n key: \"delaySelUpdate\",\n value: function delaySelUpdate() {\n if (!this.allowDefault) return false;\n this.delayedSelectionSync = true;\n return true;\n }\n }]);\n return LeftMouseDown;\n}(MouseDown);\nvar TripleClickDrag = function (_MouseDown2) {\n _inherits(TripleClickDrag, _MouseDown2);\n var _super9 = _createSuper(TripleClickDrag);\n function TripleClickDrag(view, startSelection) {\n var _this10;\n _classCallCheck(this, TripleClickDrag);\n _this10 = _super9.call(this, view);\n _this10.startSelection = startSelection;\n _this10.startDoc = view.state.doc;\n return _this10;\n }\n _createClass(TripleClickDrag, [{\n key: \"move\",\n value: function move(event) {\n if (event.buttons == 0 || this.view.isDestroyed || !this.view.state.doc.eq(this.startDoc)) {\n this.done();\n return;\n }\n event.preventDefault();\n setSelectionOrigin(this.view, \"pointer\");\n var pos = this.view.posAtCoords(eventCoords(event));\n var target = pos && selectionForTripleClick(this.view, pos.inside, false);\n if (!target) return;\n var doc = this.view.state.doc,\n start = this.startSelection;\n var _ref5 = target.from < start.from ? [start.to, target.from] : [start.from, target.to],\n _ref6 = _slicedToArray(_ref5, 2),\n anchor = _ref6[0],\n head = _ref6[1];\n updateSelection(this.view, prosemirrorState.TextSelection.create(doc, anchor, head), \"pointer\");\n }\n }]);\n return TripleClickDrag;\n}(MouseDown);\nhandlers.touchstart = function (view) {\n view.input.lastTouch = Date.now();\n forceDOMFlush(view);\n setSelectionOrigin(view, \"pointer\");\n};\nhandlers.touchmove = function (view) {\n view.input.lastTouch = Date.now();\n setSelectionOrigin(view, \"pointer\");\n};\nhandlers.contextmenu = function (view) {\n return forceDOMFlush(view);\n};\nfunction inOrNearComposition(view, event) {\n if (view.composing) return true;\n if (safari && Math.abs(Date.now() - view.input.compositionEndedAt) < 500) {\n view.input.compositionEndedAt = -2e8;\n return true;\n }\n return false;\n}\nvar timeoutComposition = android ? 5000 : -1;\neditHandlers.compositionstart = editHandlers.compositionupdate = function (view) {\n if (!view.composing) {\n view.domObserver.flush();\n var state = view.state,\n $pos = state.selection.$to;\n if (state.selection instanceof prosemirrorState.TextSelection && (state.storedMarks || !$pos.textOffset && $pos.parentOffset && $pos.nodeBefore.marks.some(function (m) {\n return m.type.spec.inclusive === false;\n }) || chrome && windows && selectionBeforeUneditable(view))) {\n view.markCursor = view.state.storedMarks || $pos.marks();\n endComposition(view, true);\n view.markCursor = null;\n } else {\n endComposition(view, !state.selection.empty);\n if (gecko && state.selection.empty && $pos.parentOffset && !$pos.textOffset && $pos.nodeBefore.marks.length) {\n var sel = view.domSelectionRange();\n for (var node = sel.focusNode, offset = sel.focusOffset; node && node.nodeType == 1 && offset != 0;) {\n var before = offset < 0 ? node.lastChild : node.childNodes[offset - 1];\n if (!before) break;\n if (before.nodeType == 3) {\n var _sel = view.domSelection();\n if (_sel) _sel.collapse(before, before.nodeValue.length);\n break;\n } else {\n node = before;\n offset = -1;\n }\n }\n }\n }\n view.input.composing = true;\n }\n scheduleComposeEnd(view, timeoutComposition);\n};\nfunction selectionBeforeUneditable(view) {\n var _view$domSelectionRan4 = view.domSelectionRange(),\n focusNode = _view$domSelectionRan4.focusNode,\n focusOffset = _view$domSelectionRan4.focusOffset;\n if (!focusNode || focusNode.nodeType != 1 || focusOffset >= focusNode.childNodes.length) return false;\n var next = focusNode.childNodes[focusOffset];\n return next.nodeType == 1 && next.contentEditable == \"false\";\n}\neditHandlers.compositionend = function (view, event) {\n if (view.composing) {\n view.input.composing = false;\n view.input.compositionEndedAt = Date.now();\n view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;\n view.input.compositionNode = null;\n if (view.input.badSafariComposition) view.domObserver.forceFlush();else if (view.input.compositionPendingChanges) Promise.resolve().then(function () {\n return view.domObserver.flush();\n });\n view.input.compositionID++;\n scheduleComposeEnd(view, 20);\n }\n};\nfunction scheduleComposeEnd(view, delay) {\n clearTimeout(view.input.composingTimeout);\n if (delay > -1) view.input.composingTimeout = setTimeout(function () {\n return endComposition(view);\n }, delay);\n}\nfunction clearComposition(view) {\n if (view.composing) {\n view.input.composing = false;\n view.input.compositionEndedAt = Date.now();\n }\n while (view.input.compositionNodes.length > 0) view.input.compositionNodes.pop().markParentsDirty();\n}\nfunction findCompositionNode(view) {\n var sel = view.domSelectionRange();\n if (!sel.focusNode) return null;\n var textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);\n var textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);\n if (textBefore && textAfter && textBefore != textAfter) {\n var descAfter = textAfter.pmViewDesc,\n lastChanged = view.domObserver.lastChangedTextNode;\n if (textBefore == lastChanged || textAfter == lastChanged) return lastChanged;\n if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {\n return textAfter;\n } else if (view.input.compositionNode == textAfter) {\n var descBefore = textBefore.pmViewDesc;\n if (!(!descBefore || !descBefore.isText(textBefore.nodeValue))) return textAfter;\n }\n }\n return textBefore || textAfter;\n}\nfunction endComposition(view) {\n var restarting = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;\n if (android && view.domObserver.flushingSoon >= 0) return;\n view.domObserver.forceFlush();\n clearComposition(view);\n if (restarting || view.docView && view.docView.dirty) {\n var sel = selectionFromDOM(view),\n cur = view.state.selection;\n if (sel && !sel.eq(cur)) view.dispatch(view.state.tr.setSelection(sel));else if ((view.markCursor || restarting) && !cur.$from.node(cur.$from.sharedDepth(cur.to)).inlineContent) view.dispatch(view.state.tr.deleteSelection());else view.updateState(view.state);\n return true;\n }\n return false;\n}\nfunction captureCopy(view, dom) {\n if (!view.dom.parentNode) return;\n var wrap = view.dom.parentNode.appendChild(document.createElement(\"div\"));\n wrap.appendChild(dom);\n wrap.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n var sel = getSelection(),\n range = document.createRange();\n range.selectNodeContents(dom);\n view.dom.blur();\n sel.removeAllRanges();\n sel.addRange(range);\n setTimeout(function () {\n if (wrap.parentNode) wrap.parentNode.removeChild(wrap);\n view.focus();\n }, 50);\n}\nvar brokenClipboardAPI = ie && ie_version < 15 || ios && webkit_version < 604;\nhandlers.copy = editHandlers.cut = function (view, _event) {\n var event = _event;\n var sel = view.state.selection,\n cut = event.type == \"cut\";\n if (sel.empty) return;\n var data = brokenClipboardAPI ? null : event.clipboardData;\n var slice = sel.content(),\n _serializeForClipboar = _serializeForClipboard(view, slice),\n dom = _serializeForClipboar.dom,\n text = _serializeForClipboar.text;\n if (data) {\n event.preventDefault();\n data.clearData();\n data.setData(\"text/html\", dom.innerHTML);\n data.setData(\"text/plain\", text);\n } else {\n captureCopy(view, dom);\n }\n if (cut) view.dispatch(view.state.tr.deleteSelection().scrollIntoView().setMeta(\"uiEvent\", \"cut\"));\n};\nfunction sliceSingleNode(slice) {\n return slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1 ? slice.content.firstChild : null;\n}\nfunction capturePaste(view, event) {\n if (!view.dom.parentNode) return;\n var plainText = view.input.shiftKey || view.state.selection.$from.parent.type.spec.code;\n var target = view.dom.parentNode.appendChild(document.createElement(plainText ? \"textarea\" : \"div\"));\n if (!plainText) target.contentEditable = \"true\";\n target.style.cssText = \"position: fixed; left: -10000px; top: 10px\";\n target.focus();\n var plain = view.input.shiftKey && view.input.lastKeyCode != 45;\n setTimeout(function () {\n view.focus();\n if (target.parentNode) target.parentNode.removeChild(target);\n if (plainText) doPaste(view, target.value, null, plain, event);else doPaste(view, target.textContent, target.innerHTML, plain, event);\n }, 50);\n}\nfunction doPaste(view, text, html, preferPlain, event) {\n var slice = parseFromClipboard(view, text, html, preferPlain, view.state.selection.$from);\n if (view.someProp(\"handlePaste\", function (f) {\n return f(view, event, slice || prosemirrorModel.Slice.empty);\n })) return true;\n if (!slice) return false;\n var singleNode = sliceSingleNode(slice);\n var tr = singleNode ? view.state.tr.replaceSelectionWith(singleNode, preferPlain) : view.state.tr.replaceSelection(slice);\n view.dispatch(tr.scrollIntoView().setMeta(\"paste\", true).setMeta(\"uiEvent\", \"paste\"));\n return true;\n}\nfunction getText(clipboardData) {\n var text = clipboardData.getData(\"text/plain\") || clipboardData.getData(\"Text\");\n if (text) return text;\n var uris = clipboardData.getData(\"text/uri-list\");\n return uris ? uris.replace(/\\r?\\n/g, \" \") : \"\";\n}\neditHandlers.paste = function (view, _event) {\n var event = _event;\n if (view.composing && !android) return;\n var data = brokenClipboardAPI ? null : event.clipboardData;\n var plain = view.input.shiftKey && view.input.lastKeyCode != 45;\n if (data && doPaste(view, getText(data), data.getData(\"text/html\"), plain, event)) event.preventDefault();else capturePaste(view, event);\n};\nvar Dragging = _createClass(function Dragging(slice, move, node) {\n _classCallCheck(this, Dragging);\n this.slice = slice;\n this.move = move;\n this.node = node;\n});\nvar dragCopyModifier = mac ? \"altKey\" : \"ctrlKey\";\nfunction dragMoves(view, event) {\n var copy;\n view.someProp(\"dragCopies\", function (test) {\n copy = copy || test(event);\n });\n return copy != null ? !copy : !event[dragCopyModifier];\n}\nhandlers.dragstart = function (view, _event) {\n var event = _event;\n var mouseDown = view.input.mouseDown;\n if (mouseDown) mouseDown.done();\n if (!event.dataTransfer) return;\n var sel = view.state.selection;\n var pos = sel.empty ? null : view.posAtCoords(eventCoords(event));\n var node;\n if (pos && pos.pos >= sel.from && pos.pos <= (sel instanceof prosemirrorState.NodeSelection ? sel.to - 1 : sel.to)) ;else if (mouseDown && mouseDown.mightDrag) {\n node = prosemirrorState.NodeSelection.create(view.state.doc, mouseDown.mightDrag.pos);\n } else if (event.target && event.target.nodeType == 1) {\n var desc = view.docView.nearestDesc(event.target, true);\n if (desc && desc.node.type.spec.draggable && desc != view.docView) node = prosemirrorState.NodeSelection.create(view.state.doc, desc.posBefore);\n }\n var draggedSlice = (node || view.state.selection).content();\n var _serializeForClipboar2 = _serializeForClipboard(view, draggedSlice),\n dom = _serializeForClipboar2.dom,\n text = _serializeForClipboar2.text,\n slice = _serializeForClipboar2.slice;\n if (!event.dataTransfer.files.length || !chrome || chrome_version > 120) event.dataTransfer.clearData();\n event.dataTransfer.setData(brokenClipboardAPI ? \"Text\" : \"text/html\", dom.innerHTML);\n event.dataTransfer.effectAllowed = \"copyMove\";\n if (!brokenClipboardAPI) event.dataTransfer.setData(\"text/plain\", text);\n view.dragging = new Dragging(slice, dragMoves(view, event), node);\n};\nhandlers.dragend = function (view) {\n var dragging = view.dragging;\n window.setTimeout(function () {\n if (view.dragging == dragging) view.dragging = null;\n }, 50);\n};\neditHandlers.dragover = editHandlers.dragenter = function (_, e) {\n return e.preventDefault();\n};\neditHandlers.drop = function (view, event) {\n try {\n handleDrop(view, event, view.dragging);\n } finally {\n view.dragging = null;\n }\n};\nfunction handleDrop(view, event, dragging) {\n if (!event.dataTransfer) return;\n var eventPos = view.posAtCoords(eventCoords(event));\n if (!eventPos) return;\n var $mouse = view.state.doc.resolve(eventPos.pos);\n var slice = dragging && dragging.slice;\n if (slice) {\n view.someProp(\"transformPasted\", function (f) {\n slice = f(slice, view, false);\n });\n } else {\n slice = parseFromClipboard(view, getText(event.dataTransfer), brokenClipboardAPI ? null : event.dataTransfer.getData(\"text/html\"), false, $mouse);\n }\n var move = !!(dragging && dragMoves(view, event));\n if (view.someProp(\"handleDrop\", function (f) {\n return f(view, event, slice || prosemirrorModel.Slice.empty, move);\n })) {\n event.preventDefault();\n return;\n }\n if (!slice) return;\n event.preventDefault();\n var insertPos = slice ? prosemirrorTransform.dropPoint(view.state.doc, $mouse.pos, slice) : $mouse.pos;\n if (insertPos == null) insertPos = $mouse.pos;\n var tr = view.state.tr;\n if (move) {\n var node = dragging.node;\n if (node) node.replace(tr);else tr.deleteSelection();\n }\n var pos = tr.mapping.map(insertPos);\n var isNode = slice.openStart == 0 && slice.openEnd == 0 && slice.content.childCount == 1;\n var beforeInsert = tr.doc;\n if (isNode) tr.replaceRangeWith(pos, pos, slice.content.firstChild);else tr.replaceRange(pos, pos, slice);\n if (tr.doc.eq(beforeInsert)) return;\n var $pos = tr.doc.resolve(pos);\n if (isNode && prosemirrorState.NodeSelection.isSelectable(slice.content.firstChild) && $pos.nodeAfter && $pos.nodeAfter.sameMarkup(slice.content.firstChild)) {\n tr.setSelection(new prosemirrorState.NodeSelection($pos));\n } else {\n var end = tr.mapping.map(insertPos);\n tr.mapping.maps[tr.mapping.maps.length - 1].forEach(function (_from, _to, _newFrom, newTo) {\n return end = newTo;\n });\n tr.setSelection(selectionBetween(view, $pos, tr.doc.resolve(end)));\n }\n view.focus();\n view.dispatch(tr.setMeta(\"uiEvent\", \"drop\"));\n}\nhandlers.focus = function (view) {\n view.input.lastFocus = Date.now();\n if (!view.focused) {\n view.domObserver.stop();\n view.dom.classList.add(\"ProseMirror-focused\");\n view.domObserver.start();\n view.focused = true;\n setTimeout(function () {\n if (view.docView && view.hasFocus() && !view.domObserver.currentSelection.eq(view.domSelectionRange())) selectionToDOM(view);\n }, 20);\n }\n};\nhandlers.blur = function (view, _event) {\n var event = _event;\n if (view.focused) {\n view.domObserver.stop();\n view.dom.classList.remove(\"ProseMirror-focused\");\n view.domObserver.start();\n if (event.relatedTarget && view.dom.contains(event.relatedTarget)) view.domObserver.currentSelection.clear();\n view.focused = false;\n }\n};\nhandlers.beforeinput = function (view, _event) {\n var event = _event;\n if (android && event.inputType == \"deleteContentBackward\") {\n view.domObserver.flushSoon();\n var domChangeCount = view.input.domChangeCount;\n setTimeout(function () {\n if (view.input.domChangeCount != domChangeCount) return;\n view.dom.blur();\n view.focus();\n if (view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(8, \"Backspace\"));\n })) return;\n var $cursor = view.state.selection.$cursor;\n if ($cursor && $cursor.pos > 0) view.dispatch(view.state.tr[\"delete\"]($cursor.pos - 1, $cursor.pos).scrollIntoView());\n }, 50);\n }\n};\nfor (var prop in editHandlers) handlers[prop] = editHandlers[prop];\nfunction compareObjs(a, b) {\n if (a == b) return true;\n for (var p in a) if (a[p] !== b[p]) return false;\n for (var _p in b) if (!(_p in a)) return false;\n return true;\n}\nvar WidgetType = function () {\n function WidgetType(toDOM, spec) {\n _classCallCheck(this, WidgetType);\n this.toDOM = toDOM;\n this.spec = spec || noSpec;\n this.side = this.spec.side || 0;\n }\n _createClass(WidgetType, [{\n key: \"map\",\n value: function map(mapping, span, offset, oldOffset) {\n var _mapping$mapResult = mapping.mapResult(span.from + oldOffset, this.side < 0 ? -1 : 1),\n pos = _mapping$mapResult.pos,\n deleted = _mapping$mapResult.deleted;\n return deleted ? null : new Decoration(pos - offset, pos - offset, this);\n }\n }, {\n key: \"valid\",\n value: function valid() {\n return true;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this == other || other instanceof WidgetType && (this.spec.key && this.spec.key == other.spec.key || this.toDOM == other.toDOM && compareObjs(this.spec, other.spec));\n }\n }, {\n key: \"destroy\",\n value: function destroy(node) {\n if (this.spec.destroy) this.spec.destroy(node);\n }\n }]);\n return WidgetType;\n}();\nvar InlineType = function () {\n function InlineType(attrs, spec) {\n _classCallCheck(this, InlineType);\n this.attrs = attrs;\n this.spec = spec || noSpec;\n }\n _createClass(InlineType, [{\n key: \"map\",\n value: function map(mapping, span, offset, oldOffset) {\n var from = mapping.map(span.from + oldOffset, this.spec.inclusiveStart ? -1 : 1) - offset;\n var to = mapping.map(span.to + oldOffset, this.spec.inclusiveEnd ? 1 : -1) - offset;\n return from >= to ? null : new Decoration(from, to, this);\n }\n }, {\n key: \"valid\",\n value: function valid(_, span) {\n return span.from < span.to;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this == other || other instanceof InlineType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {}\n }], [{\n key: \"is\",\n value: function is(span) {\n return span.type instanceof InlineType;\n }\n }]);\n return InlineType;\n}();\nvar NodeType = function () {\n function NodeType(attrs, spec) {\n _classCallCheck(this, NodeType);\n this.attrs = attrs;\n this.spec = spec || noSpec;\n }\n _createClass(NodeType, [{\n key: \"map\",\n value: function map(mapping, span, offset, oldOffset) {\n var from = mapping.mapResult(span.from + oldOffset, 1);\n if (from.deleted) return null;\n var to = mapping.mapResult(span.to + oldOffset, -1);\n if (to.deleted || to.pos <= from.pos) return null;\n return new Decoration(from.pos - offset, to.pos - offset, this);\n }\n }, {\n key: \"valid\",\n value: function valid(node, span) {\n var _node$content$findInd = node.content.findIndex(span.from),\n index = _node$content$findInd.index,\n offset = _node$content$findInd.offset,\n child;\n return offset == span.from && !(child = node.child(index)).isText && offset + child.nodeSize == span.to;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n return this == other || other instanceof NodeType && compareObjs(this.attrs, other.attrs) && compareObjs(this.spec, other.spec);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {}\n }]);\n return NodeType;\n}();\nvar Decoration = function () {\n function Decoration(from, to, type) {\n _classCallCheck(this, Decoration);\n this.from = from;\n this.to = to;\n this.type = type;\n }\n _createClass(Decoration, [{\n key: \"copy\",\n value: function copy(from, to) {\n return new Decoration(from, to, this.type);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n var offset = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n return this.type.eq(other.type) && this.from + offset == other.from && this.to + offset == other.to;\n }\n }, {\n key: \"map\",\n value: function map(mapping, offset, oldOffset) {\n return this.type.map(mapping, this, offset, oldOffset);\n }\n }, {\n key: \"spec\",\n get: function get() {\n return this.type.spec;\n }\n }, {\n key: \"inline\",\n get: function get() {\n return this.type instanceof InlineType;\n }\n }, {\n key: \"widget\",\n get: function get() {\n return this.type instanceof WidgetType;\n }\n }], [{\n key: \"widget\",\n value: function widget(pos, toDOM, spec) {\n return new Decoration(pos, pos, new WidgetType(toDOM, spec));\n }\n }, {\n key: \"inline\",\n value: function inline(from, to, attrs, spec) {\n return new Decoration(from, to, new InlineType(attrs, spec));\n }\n }, {\n key: \"node\",\n value: function node(from, to, attrs, spec) {\n return new Decoration(from, to, new NodeType(attrs, spec));\n }\n }]);\n return Decoration;\n}();\nvar none = [],\n noSpec = {};\nvar DecorationSet = function () {\n function DecorationSet(local, children) {\n _classCallCheck(this, DecorationSet);\n this.local = local.length ? local : none;\n this.children = children.length ? children : none;\n }\n _createClass(DecorationSet, [{\n key: \"find\",\n value: function find(start, end, predicate) {\n var result = [];\n this.findInner(start == null ? 0 : start, end == null ? 1e9 : end, result, 0, predicate);\n return result;\n }\n }, {\n key: \"findInner\",\n value: function findInner(start, end, result, offset, predicate) {\n for (var i = 0; i < this.local.length; i++) {\n var span = this.local[i];\n if (span.from <= end && span.to >= start && (!predicate || predicate(span.spec))) result.push(span.copy(span.from + offset, span.to + offset));\n }\n for (var _i7 = 0; _i7 < this.children.length; _i7 += 3) {\n if (this.children[_i7] < end && this.children[_i7 + 1] > start) {\n var childOff = this.children[_i7] + 1;\n this.children[_i7 + 2].findInner(start - childOff, end - childOff, result, offset + childOff, predicate);\n }\n }\n }\n }, {\n key: \"map\",\n value: function map(mapping, doc, options) {\n if (this == empty || mapping.maps.length == 0) return this;\n return this.mapInner(mapping, doc, 0, 0, options || noSpec);\n }\n }, {\n key: \"mapInner\",\n value: function mapInner(mapping, node, offset, oldOffset, options) {\n var newLocal;\n for (var i = 0; i < this.local.length; i++) {\n var mapped = this.local[i].map(mapping, offset, oldOffset);\n if (mapped && mapped.type.valid(node, mapped)) (newLocal || (newLocal = [])).push(mapped);else if (options.onRemove) options.onRemove(this.local[i].spec);\n }\n if (this.children.length) return mapChildren(this.children, newLocal || [], mapping, node, offset, oldOffset, options);else return newLocal ? new DecorationSet(newLocal.sort(byPos), none) : empty;\n }\n }, {\n key: \"add\",\n value: function add(doc, decorations) {\n if (!decorations.length) return this;\n if (this == empty) return DecorationSet.create(doc, decorations);\n return this.addInner(doc, decorations, 0);\n }\n }, {\n key: \"addInner\",\n value: function addInner(doc, decorations, offset) {\n var _this11 = this;\n var children,\n childIndex = 0;\n doc.forEach(function (childNode, childOffset) {\n var baseOffset = childOffset + offset,\n found;\n if (!(found = takeSpansForNode(decorations, childNode, baseOffset))) return;\n if (!children) children = _this11.children.slice();\n while (childIndex < children.length && children[childIndex] < childOffset) childIndex += 3;\n if (children[childIndex] == childOffset) children[childIndex + 2] = children[childIndex + 2].addInner(childNode, found, baseOffset + 1);else children.splice(childIndex, 0, childOffset, childOffset + childNode.nodeSize, buildTree(found, childNode, baseOffset + 1, noSpec));\n childIndex += 3;\n });\n var local = moveSpans(childIndex ? withoutNulls(decorations) : decorations, -offset);\n for (var i = 0; i < local.length; i++) if (!local[i].type.valid(doc, local[i])) local.splice(i--, 1);\n return new DecorationSet(local.length ? this.local.concat(local).sort(byPos) : this.local, children || this.children);\n }\n }, {\n key: \"remove\",\n value: function remove(decorations) {\n if (decorations.length == 0 || this == empty) return this;\n return this.removeInner(decorations, 0);\n }\n }, {\n key: \"removeInner\",\n value: function removeInner(decorations, offset) {\n var children = this.children,\n local = this.local;\n for (var i = 0; i < children.length; i += 3) {\n var found = void 0;\n var from = children[i] + offset,\n to = children[i + 1] + offset;\n for (var j = 0, span; j < decorations.length; j++) if (span = decorations[j]) {\n if (span.from > from && span.to < to) {\n decorations[j] = null;\n (found || (found = [])).push(span);\n }\n }\n if (!found) continue;\n if (children == this.children) children = this.children.slice();\n var removed = children[i + 2].removeInner(found, from + 1);\n if (removed != empty) {\n children[i + 2] = removed;\n } else {\n children.splice(i, 3);\n i -= 3;\n }\n }\n if (local.length) for (var _i8 = 0, _span; _i8 < decorations.length; _i8++) if (_span = decorations[_i8]) {\n for (var _j2 = 0; _j2 < local.length; _j2++) if (local[_j2].eq(_span, offset)) {\n if (local == this.local) local = this.local.slice();\n local.splice(_j2--, 1);\n }\n }\n if (children == this.children && local == this.local) return this;\n return local.length || children.length ? new DecorationSet(local, children) : empty;\n }\n }, {\n key: \"forChild\",\n value: function forChild(offset, node) {\n if (this == empty) return this;\n if (node.isLeaf) return DecorationSet.empty;\n var child, local;\n for (var i = 0; i < this.children.length; i += 3) if (this.children[i] >= offset) {\n if (this.children[i] == offset) child = this.children[i + 2];\n break;\n }\n var start = offset + 1,\n end = start + node.content.size;\n for (var _i9 = 0; _i9 < this.local.length; _i9++) {\n var dec = this.local[_i9];\n if (dec.from < end && dec.to > start && dec.type instanceof InlineType) {\n var from = Math.max(start, dec.from) - start,\n to = Math.min(end, dec.to) - start;\n if (from < to) (local || (local = [])).push(dec.copy(from, to));\n }\n }\n if (local) {\n var localSet = new DecorationSet(local.sort(byPos), none);\n return child ? new DecorationGroup([localSet, child]) : localSet;\n }\n return child || empty;\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n if (this == other) return true;\n if (!(other instanceof DecorationSet) || this.local.length != other.local.length || this.children.length != other.children.length) return false;\n for (var i = 0; i < this.local.length; i++) if (!this.local[i].eq(other.local[i])) return false;\n for (var _i10 = 0; _i10 < this.children.length; _i10 += 3) if (this.children[_i10] != other.children[_i10] || this.children[_i10 + 1] != other.children[_i10 + 1] || !this.children[_i10 + 2].eq(other.children[_i10 + 2])) return false;\n return true;\n }\n }, {\n key: \"locals\",\n value: function locals(node) {\n return removeOverlap(this.localsInner(node));\n }\n }, {\n key: \"localsInner\",\n value: function localsInner(node) {\n if (this == empty) return none;\n if (node.inlineContent || !this.local.some(InlineType.is)) return this.local;\n var result = [];\n for (var i = 0; i < this.local.length; i++) {\n if (!(this.local[i].type instanceof InlineType)) result.push(this.local[i]);\n }\n return result;\n }\n }, {\n key: \"forEachSet\",\n value: function forEachSet(f) {\n f(this);\n }\n }], [{\n key: \"create\",\n value: function create(doc, decorations) {\n return decorations.length ? buildTree(decorations, doc, 0, noSpec) : empty;\n }\n }]);\n return DecorationSet;\n}();\nDecorationSet.empty = new DecorationSet([], []);\nDecorationSet.removeOverlap = removeOverlap;\nvar empty = DecorationSet.empty;\nvar DecorationGroup = function () {\n function DecorationGroup(members) {\n _classCallCheck(this, DecorationGroup);\n this.members = members;\n }\n _createClass(DecorationGroup, [{\n key: \"map\",\n value: function map(mapping, doc) {\n var mappedDecos = this.members.map(function (member) {\n return member.map(mapping, doc, noSpec);\n });\n return DecorationGroup.from(mappedDecos);\n }\n }, {\n key: \"forChild\",\n value: function forChild(offset, child) {\n if (child.isLeaf) return DecorationSet.empty;\n var found = [];\n for (var i = 0; i < this.members.length; i++) {\n var result = this.members[i].forChild(offset, child);\n if (result == empty) continue;\n if (result instanceof DecorationGroup) found = found.concat(result.members);else found.push(result);\n }\n return DecorationGroup.from(found);\n }\n }, {\n key: \"eq\",\n value: function eq(other) {\n if (!(other instanceof DecorationGroup) || other.members.length != this.members.length) return false;\n for (var i = 0; i < this.members.length; i++) if (!this.members[i].eq(other.members[i])) return false;\n return true;\n }\n }, {\n key: \"locals\",\n value: function locals(node) {\n var result,\n sorted = true;\n for (var i = 0; i < this.members.length; i++) {\n var locals = this.members[i].localsInner(node);\n if (!locals.length) continue;\n if (!result) {\n result = locals;\n } else {\n if (sorted) {\n result = result.slice();\n sorted = false;\n }\n for (var j = 0; j < locals.length; j++) result.push(locals[j]);\n }\n }\n return result ? removeOverlap(sorted ? result : result.sort(byPos)) : none;\n }\n }, {\n key: \"forEachSet\",\n value: function forEachSet(f) {\n for (var i = 0; i < this.members.length; i++) this.members[i].forEachSet(f);\n }\n }], [{\n key: \"from\",\n value: function from(members) {\n switch (members.length) {\n case 0:\n return empty;\n case 1:\n return members[0];\n default:\n return new DecorationGroup(members.every(function (m) {\n return m instanceof DecorationSet;\n }) ? members : members.reduce(function (r, m) {\n return r.concat(m instanceof DecorationSet ? m : m.members);\n }, []));\n }\n }\n }]);\n return DecorationGroup;\n}();\nfunction mapChildren(oldChildren, newLocal, mapping, node, offset, oldOffset, options) {\n var children = oldChildren.slice();\n var _loop4 = function _loop4(_baseOffset) {\n var moved = 0;\n mapping.maps[i].forEach(function (oldStart, oldEnd, newStart, newEnd) {\n var dSize = newEnd - newStart - (oldEnd - oldStart);\n for (var _i14 = 0; _i14 < children.length; _i14 += 3) {\n var end = children[_i14 + 1];\n if (end < 0 || oldStart > end + _baseOffset - moved) continue;\n var start = children[_i14] + _baseOffset - moved;\n if (oldEnd >= start) {\n children[_i14 + 1] = oldStart <= start ? -2 : -1;\n } else if (oldStart >= _baseOffset && dSize) {\n children[_i14] += dSize;\n children[_i14 + 1] += dSize;\n }\n }\n moved += dSize;\n });\n _baseOffset = mapping.maps[i].map(_baseOffset, -1);\n baseOffset = _baseOffset;\n };\n for (var i = 0, baseOffset = oldOffset; i < mapping.maps.length; i++) {\n _loop4(baseOffset);\n }\n var mustRebuild = false;\n for (var _i11 = 0; _i11 < children.length; _i11 += 3) if (children[_i11 + 1] < 0) {\n if (children[_i11 + 1] == -2) {\n mustRebuild = true;\n children[_i11 + 1] = -1;\n continue;\n }\n var from = mapping.map(oldChildren[_i11] + oldOffset),\n fromLocal = from - offset;\n if (fromLocal < 0 || fromLocal >= node.content.size) {\n mustRebuild = true;\n continue;\n }\n var to = mapping.map(oldChildren[_i11 + 1] + oldOffset, -1),\n toLocal = to - offset;\n var _node$content$findInd2 = node.content.findIndex(fromLocal),\n index = _node$content$findInd2.index,\n childOffset = _node$content$findInd2.offset;\n var childNode = node.maybeChild(index);\n if (childNode && childOffset == fromLocal && childOffset + childNode.nodeSize == toLocal) {\n var mapped = children[_i11 + 2].mapInner(mapping, childNode, from + 1, oldChildren[_i11] + oldOffset + 1, options);\n if (mapped != empty) {\n children[_i11] = fromLocal;\n children[_i11 + 1] = toLocal;\n children[_i11 + 2] = mapped;\n } else {\n children[_i11 + 1] = -2;\n mustRebuild = true;\n }\n } else {\n mustRebuild = true;\n }\n }\n if (mustRebuild) {\n var decorations = mapAndGatherRemainingDecorations(children, oldChildren, newLocal, mapping, offset, oldOffset, options);\n var built = buildTree(decorations, node, 0, options);\n newLocal = built.local;\n for (var _i12 = 0; _i12 < children.length; _i12 += 3) if (children[_i12 + 1] < 0) {\n children.splice(_i12, 3);\n _i12 -= 3;\n }\n for (var _i13 = 0, j = 0; _i13 < built.children.length; _i13 += 3) {\n var _from2 = built.children[_i13];\n while (j < children.length && children[j] < _from2) j += 3;\n children.splice(j, 0, built.children[_i13], built.children[_i13 + 1], built.children[_i13 + 2]);\n }\n }\n return new DecorationSet(newLocal.sort(byPos), children);\n}\nfunction moveSpans(spans, offset) {\n if (!offset || !spans.length) return spans;\n var result = [];\n for (var i = 0; i < spans.length; i++) {\n var span = spans[i];\n result.push(new Decoration(span.from + offset, span.to + offset, span.type));\n }\n return result;\n}\nfunction mapAndGatherRemainingDecorations(children, oldChildren, decorations, mapping, offset, oldOffset, options) {\n function gather(set, oldOffset) {\n for (var i = 0; i < set.local.length; i++) {\n var mapped = set.local[i].map(mapping, offset, oldOffset);\n if (mapped) decorations.push(mapped);else if (options.onRemove) options.onRemove(set.local[i].spec);\n }\n for (var _i15 = 0; _i15 < set.children.length; _i15 += 3) gather(set.children[_i15 + 2], set.children[_i15] + oldOffset + 1);\n }\n for (var i = 0; i < children.length; i += 3) if (children[i + 1] == -1) gather(children[i + 2], oldChildren[i] + oldOffset + 1);\n return decorations;\n}\nfunction takeSpansForNode(spans, node, offset) {\n if (node.isLeaf) return null;\n var end = offset + node.nodeSize,\n found = null;\n for (var i = 0, span; i < spans.length; i++) {\n if ((span = spans[i]) && span.from > offset && span.to < end) {\n (found || (found = [])).push(span);\n spans[i] = null;\n }\n }\n return found;\n}\nfunction withoutNulls(array) {\n var result = [];\n for (var i = 0; i < array.length; i++) if (array[i] != null) result.push(array[i]);\n return result;\n}\nfunction buildTree(spans, node, offset, options) {\n var children = [],\n hasNulls = false;\n node.forEach(function (childNode, localStart) {\n var found = takeSpansForNode(spans, childNode, localStart + offset);\n if (found) {\n hasNulls = true;\n var subtree = buildTree(found, childNode, offset + localStart + 1, options);\n if (subtree != empty) children.push(localStart, localStart + childNode.nodeSize, subtree);\n }\n });\n var locals = moveSpans(hasNulls ? withoutNulls(spans) : spans, -offset).sort(byPos);\n for (var i = 0; i < locals.length; i++) if (!locals[i].type.valid(node, locals[i])) {\n if (options.onRemove) options.onRemove(locals[i].spec);\n locals.splice(i--, 1);\n }\n return locals.length || children.length ? new DecorationSet(locals, children) : empty;\n}\nfunction byPos(a, b) {\n return a.from - b.from || a.to - b.to;\n}\nfunction removeOverlap(spans) {\n var working = spans;\n for (var i = 0; i < working.length - 1; i++) {\n var span = working[i];\n if (span.from != span.to) for (var j = i + 1; j < working.length; j++) {\n var next = working[j];\n if (next.from == span.from) {\n if (next.to != span.to) {\n if (working == spans) working = spans.slice();\n working[j] = next.copy(next.from, span.to);\n insertAhead(working, j + 1, next.copy(span.to, next.to));\n }\n continue;\n } else {\n if (next.from < span.to) {\n if (working == spans) working = spans.slice();\n working[i] = span.copy(span.from, next.from);\n insertAhead(working, j, span.copy(next.from, span.to));\n }\n break;\n }\n }\n }\n return working;\n}\nfunction insertAhead(array, i, deco) {\n while (i < array.length && byPos(deco, array[i]) > 0) i++;\n array.splice(i, 0, deco);\n}\nfunction viewDecorations(view) {\n var found = [];\n view.someProp(\"decorations\", function (f) {\n var result = f(view.state);\n if (result && result != empty) found.push(result);\n });\n if (view.cursorWrapper) found.push(DecorationSet.create(view.state.doc, [view.cursorWrapper.deco]));\n return DecorationGroup.from(found);\n}\nvar observeOptions = {\n childList: true,\n characterData: true,\n characterDataOldValue: true,\n attributes: true,\n attributeOldValue: true,\n subtree: true\n};\nvar useCharData = ie && ie_version <= 11;\nvar SelectionState = function () {\n function SelectionState() {\n _classCallCheck(this, SelectionState);\n this.anchorNode = null;\n this.anchorOffset = 0;\n this.focusNode = null;\n this.focusOffset = 0;\n }\n _createClass(SelectionState, [{\n key: \"set\",\n value: function set(sel) {\n this.anchorNode = sel.anchorNode;\n this.anchorOffset = sel.anchorOffset;\n this.focusNode = sel.focusNode;\n this.focusOffset = sel.focusOffset;\n }\n }, {\n key: \"clear\",\n value: function clear() {\n this.anchorNode = this.focusNode = null;\n }\n }, {\n key: \"eq\",\n value: function eq(sel) {\n return sel.anchorNode == this.anchorNode && sel.anchorOffset == this.anchorOffset && sel.focusNode == this.focusNode && sel.focusOffset == this.focusOffset;\n }\n }]);\n return SelectionState;\n}();\nvar DOMObserver = function () {\n function DOMObserver(view, handleDOMChange) {\n var _this12 = this;\n _classCallCheck(this, DOMObserver);\n this.view = view;\n this.handleDOMChange = handleDOMChange;\n this.queue = [];\n this.flushingSoon = -1;\n this.observer = null;\n this.currentSelection = new SelectionState();\n this.onCharData = null;\n this.suppressingSelectionUpdates = false;\n this.lastChangedTextNode = null;\n this.observer = window.MutationObserver && new window.MutationObserver(function (mutations) {\n for (var i = 0; i < mutations.length; i++) _this12.queue.push(mutations[i]);\n if (ie && ie_version <= 11 && mutations.some(function (m) {\n return m.type == \"childList\" && m.removedNodes.length || m.type == \"characterData\" && m.oldValue.length > m.target.nodeValue.length;\n })) {\n _this12.flushSoon();\n } else if (safari && view.composing && mutations.some(function (m) {\n return m.type == \"childList\" && m.target.nodeName == \"TR\";\n })) {\n view.input.badSafariComposition = true;\n _this12.flushSoon();\n } else {\n _this12.flush();\n }\n });\n if (useCharData) {\n this.onCharData = function (e) {\n _this12.queue.push({\n target: e.target,\n type: \"characterData\",\n oldValue: e.prevValue\n });\n _this12.flushSoon();\n };\n }\n this.onSelectionChange = this.onSelectionChange.bind(this);\n }\n _createClass(DOMObserver, [{\n key: \"flushSoon\",\n value: function flushSoon() {\n var _this13 = this;\n if (this.flushingSoon < 0) this.flushingSoon = window.setTimeout(function () {\n _this13.flushingSoon = -1;\n _this13.flush();\n }, 20);\n }\n }, {\n key: \"forceFlush\",\n value: function forceFlush() {\n if (this.flushingSoon > -1) {\n window.clearTimeout(this.flushingSoon);\n this.flushingSoon = -1;\n this.flush();\n }\n }\n }, {\n key: \"start\",\n value: function start() {\n if (this.observer) {\n this.observer.takeRecords();\n this.observer.observe(this.view.dom, observeOptions);\n }\n if (this.onCharData) this.view.dom.addEventListener(\"DOMCharacterDataModified\", this.onCharData);\n this.connectSelection();\n }\n }, {\n key: \"stop\",\n value: function stop() {\n var _this14 = this;\n if (this.observer) {\n var take = this.observer.takeRecords();\n if (take.length) {\n for (var i = 0; i < take.length; i++) this.queue.push(take[i]);\n window.setTimeout(function () {\n return _this14.flush();\n }, 20);\n }\n this.observer.disconnect();\n }\n if (this.onCharData) this.view.dom.removeEventListener(\"DOMCharacterDataModified\", this.onCharData);\n this.disconnectSelection();\n }\n }, {\n key: \"connectSelection\",\n value: function connectSelection() {\n this.view.dom.ownerDocument.addEventListener(\"selectionchange\", this.onSelectionChange);\n }\n }, {\n key: \"disconnectSelection\",\n value: function disconnectSelection() {\n this.view.dom.ownerDocument.removeEventListener(\"selectionchange\", this.onSelectionChange);\n }\n }, {\n key: \"suppressSelectionUpdates\",\n value: function suppressSelectionUpdates() {\n var _this15 = this;\n this.suppressingSelectionUpdates = true;\n setTimeout(function () {\n return _this15.suppressingSelectionUpdates = false;\n }, 50);\n }\n }, {\n key: \"onSelectionChange\",\n value: function onSelectionChange() {\n if (!hasFocusAndSelection(this.view)) return;\n if (this.suppressingSelectionUpdates) return selectionToDOM(this.view);\n if (ie && ie_version <= 11 && !this.view.state.selection.empty) {\n var sel = this.view.domSelectionRange();\n if (sel.focusNode && isEquivalentPosition(sel.focusNode, sel.focusOffset, sel.anchorNode, sel.anchorOffset)) return this.flushSoon();\n }\n this.flush();\n }\n }, {\n key: \"setCurSelection\",\n value: function setCurSelection() {\n this.currentSelection.set(this.view.domSelectionRange());\n }\n }, {\n key: \"ignoreSelectionChange\",\n value: function ignoreSelectionChange(sel) {\n if (!sel.focusNode) return true;\n var ancestors = new Set(),\n container;\n for (var scan = sel.focusNode; scan; scan = parentNode(scan)) ancestors.add(scan);\n for (var _scan = sel.anchorNode; _scan; _scan = parentNode(_scan)) if (ancestors.has(_scan)) {\n container = _scan;\n break;\n }\n var desc = container && this.view.docView.nearestDesc(container);\n if (desc && desc.ignoreMutation({\n type: \"selection\",\n target: container.nodeType == 3 ? container.parentNode : container\n })) {\n this.setCurSelection();\n return true;\n }\n }\n }, {\n key: \"pendingRecords\",\n value: function pendingRecords() {\n if (this.observer) {\n var _iterator2 = _createForOfIteratorHelper(this.observer.takeRecords()),\n _step2;\n try {\n for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {\n var mut = _step2.value;\n this.queue.push(mut);\n }\n } catch (err) {\n _iterator2.e(err);\n } finally {\n _iterator2.f();\n }\n }\n return this.queue;\n }\n }, {\n key: \"flush\",\n value: function flush() {\n var view = this.view;\n if (!view.docView || this.flushingSoon > -1) return;\n var mutations = this.pendingRecords();\n if (mutations.length) this.queue = [];\n var sel = view.domSelectionRange();\n var newSel = !this.suppressingSelectionUpdates && !this.currentSelection.eq(sel) && hasFocusAndSelection(view) && !this.ignoreSelectionChange(sel);\n var from = -1,\n to = -1,\n typeOver = false,\n added = [];\n if (view.editable) {\n for (var i = 0; i < mutations.length; i++) {\n var result = this.registerMutation(mutations[i], added);\n if (result) {\n from = from < 0 ? result.from : Math.min(result.from, from);\n to = to < 0 ? result.to : Math.max(result.to, to);\n if (result.typeOver) typeOver = true;\n }\n }\n }\n if (added.some(function (n) {\n return n.nodeName == \"BR\";\n }) && (view.input.lastKeyCode == 8 || view.input.lastKeyCode == 46 || chrome && (view.composing || view.input.compositionEndedAt > Date.now() - 50) && mutations.some(function (m) {\n return m.type == \"childList\" && m.removedNodes.length;\n }))) {\n var _iterator3 = _createForOfIteratorHelper(added),\n _step3;\n try {\n for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {\n var node = _step3.value;\n if (node.nodeName == \"BR\" && node.parentNode) {\n var after = node.nextSibling;\n while (after && after.nodeType == 1) {\n if (after.contentEditable == \"false\") {\n node.parentNode.removeChild(node);\n break;\n }\n after = after.firstChild;\n }\n }\n }\n } catch (err) {\n _iterator3.e(err);\n } finally {\n _iterator3.f();\n }\n } else if (gecko && added.length) {\n var brs = added.filter(function (n) {\n return n.nodeName == \"BR\";\n });\n if (brs.length == 2) {\n var _brs = _slicedToArray(brs, 2),\n a = _brs[0],\n b = _brs[1];\n if (a.parentNode && a.parentNode.parentNode == b.parentNode) b.remove();else a.remove();\n } else {\n var focusNode = this.currentSelection.focusNode;\n var _iterator4 = _createForOfIteratorHelper(brs),\n _step4;\n try {\n for (_iterator4.s(); !(_step4 = _iterator4.n()).done;) {\n var br = _step4.value;\n var parent = br.parentNode;\n if (parent && parent.nodeName == \"LI\" && (!focusNode || blockParent(view, focusNode) != parent)) br.remove();\n }\n } catch (err) {\n _iterator4.e(err);\n } finally {\n _iterator4.f();\n }\n }\n }\n var readSel = null;\n if (from < 0 && newSel && view.input.lastFocus > Date.now() - 200 && Math.max(view.input.lastTouch, view.input.lastClick.time) < Date.now() - 300 && selectionCollapsed(sel) && (readSel = selectionFromDOM(view)) && readSel.eq(prosemirrorState.Selection.near(view.state.doc.resolve(0), 1))) {\n view.input.lastFocus = 0;\n selectionToDOM(view);\n this.currentSelection.set(sel);\n view.scrollToSelection();\n } else if (from > -1 || newSel) {\n if (from > -1) {\n view.docView.markDirty(from, to);\n checkCSS(view);\n }\n if (view.input.badSafariComposition) {\n view.input.badSafariComposition = false;\n fixUpBadSafariComposition(view, added);\n }\n this.handleDOMChange(from, to, typeOver, added);\n if (view.docView && view.docView.dirty) view.updateState(view.state);else if (!this.currentSelection.eq(sel)) selectionToDOM(view);\n this.currentSelection.set(sel);\n }\n }\n }, {\n key: \"registerMutation\",\n value: function registerMutation(mut, added) {\n if (added.indexOf(mut.target) > -1) return null;\n var desc = this.view.docView.nearestDesc(mut.target);\n if (mut.type == \"attributes\" && (desc == this.view.docView || mut.attributeName == \"contenteditable\" || mut.attributeName == \"style\" && !mut.oldValue && !mut.target.getAttribute(\"style\"))) return null;\n if (!desc || desc.ignoreMutation(mut)) return null;\n if (mut.type == \"childList\") {\n for (var i = 0; i < mut.addedNodes.length; i++) {\n var node = mut.addedNodes[i];\n added.push(node);\n if (node.nodeType == 3) this.lastChangedTextNode = node;\n }\n if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target)) return {\n from: desc.posBefore,\n to: desc.posAfter\n };\n var prev = mut.previousSibling,\n next = mut.nextSibling;\n if (ie && ie_version <= 11 && mut.addedNodes.length) {\n for (var _i16 = 0; _i16 < mut.addedNodes.length; _i16++) {\n var _mut$addedNodes$_i = mut.addedNodes[_i16],\n previousSibling = _mut$addedNodes$_i.previousSibling,\n nextSibling = _mut$addedNodes$_i.nextSibling;\n if (!previousSibling || Array.prototype.indexOf.call(mut.addedNodes, previousSibling) < 0) prev = previousSibling;\n if (!nextSibling || Array.prototype.indexOf.call(mut.addedNodes, nextSibling) < 0) next = nextSibling;\n }\n }\n var fromOffset = prev && prev.parentNode == mut.target ? domIndex(prev) + 1 : 0;\n var from = desc.localPosFromDOM(mut.target, fromOffset, -1);\n var toOffset = next && next.parentNode == mut.target ? domIndex(next) : mut.target.childNodes.length;\n var to = desc.localPosFromDOM(mut.target, toOffset, 1);\n return {\n from: from,\n to: to\n };\n } else if (mut.type == \"attributes\") {\n return {\n from: desc.posAtStart - desc.border,\n to: desc.posAtEnd + desc.border\n };\n } else {\n this.lastChangedTextNode = mut.target;\n return {\n from: desc.posAtStart,\n to: desc.posAtEnd,\n typeOver: mut.target.nodeValue == mut.oldValue\n };\n }\n }\n }]);\n return DOMObserver;\n}();\nvar cssChecked = new WeakMap();\nvar cssCheckWarned = false;\nfunction checkCSS(view) {\n if (cssChecked.has(view)) return;\n cssChecked.set(view, null);\n if (['normal', 'nowrap', 'pre-line'].indexOf(getComputedStyle(view.dom).whiteSpace) !== -1) {\n view.requiresGeckoHackNode = gecko;\n if (cssCheckWarned) return;\n console[\"warn\"](\"ProseMirror expects the CSS white-space property to be set, preferably to 'pre-wrap'. It is recommended to load style/prosemirror.css from the prosemirror-view package.\");\n cssCheckWarned = true;\n }\n}\nfunction rangeToSelectionRange(view, range) {\n var anchorNode = range.startContainer,\n anchorOffset = range.startOffset;\n var focusNode = range.endContainer,\n focusOffset = range.endOffset;\n var currentAnchor = view.domAtPos(view.state.selection.anchor);\n if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset)) {\n var _ref7 = [focusNode, focusOffset, anchorNode, anchorOffset];\n anchorNode = _ref7[0];\n anchorOffset = _ref7[1];\n focusNode = _ref7[2];\n focusOffset = _ref7[3];\n }\n return {\n anchorNode: anchorNode,\n anchorOffset: anchorOffset,\n focusNode: focusNode,\n focusOffset: focusOffset\n };\n}\nfunction safariShadowSelectionRange(view, selection) {\n if (selection.getComposedRanges) {\n var range = selection.getComposedRanges(view.root)[0];\n if (range) return rangeToSelectionRange(view, range);\n }\n var found;\n function read(event) {\n event.preventDefault();\n event.stopImmediatePropagation();\n found = event.getTargetRanges()[0];\n }\n view.dom.addEventListener(\"beforeinput\", read, true);\n document.execCommand(\"indent\");\n view.dom.removeEventListener(\"beforeinput\", read, true);\n return found ? rangeToSelectionRange(view, found) : null;\n}\nfunction blockParent(view, node) {\n for (var p = node.parentNode; p && p != view.dom; p = p.parentNode) {\n var desc = view.docView.nearestDesc(p, true);\n if (desc && desc.node.isBlock) return p;\n }\n return null;\n}\nfunction fixUpBadSafariComposition(view, addedNodes) {\n var _a;\n var _view$domSelectionRan5 = view.domSelectionRange(),\n focusNode = _view$domSelectionRan5.focusNode,\n focusOffset = _view$domSelectionRan5.focusOffset;\n var _iterator5 = _createForOfIteratorHelper(addedNodes),\n _step5;\n try {\n for (_iterator5.s(); !(_step5 = _iterator5.n()).done;) {\n var node = _step5.value;\n if (((_a = node.parentNode) === null || _a === void 0 ? void 0 : _a.nodeName) == \"TR\") {\n var nextCell = node.nextSibling;\n while (nextCell && nextCell.nodeName != \"TD\" && nextCell.nodeName != \"TH\") nextCell = nextCell.nextSibling;\n if (nextCell) {\n var parent = nextCell;\n for (;;) {\n var first = parent.firstChild;\n if (!first || first.nodeType != 1 || first.contentEditable == \"false\" || /^(BR|IMG)$/.test(first.nodeName)) break;\n parent = first;\n }\n parent.insertBefore(node, parent.firstChild);\n if (focusNode == node) view.domSelection().collapse(node, focusOffset);\n } else {\n node.parentNode.removeChild(node);\n }\n }\n }\n } catch (err) {\n _iterator5.e(err);\n } finally {\n _iterator5.f();\n }\n}\nfunction parseBetween(view, from_, to_, addedNodes) {\n var _view$docView$parseRa = view.docView.parseRange(from_, to_),\n parent = _view$docView$parseRa.node,\n fromOffset = _view$docView$parseRa.fromOffset,\n toOffset = _view$docView$parseRa.toOffset,\n from = _view$docView$parseRa.from,\n to = _view$docView$parseRa.to;\n var domSel = view.domSelectionRange();\n var find;\n var anchor = domSel.anchorNode;\n if (anchor && view.dom.contains(anchor.nodeType == 1 ? anchor : anchor.parentNode)) {\n find = [{\n node: anchor,\n offset: domSel.anchorOffset\n }];\n if (!selectionCollapsed(domSel)) find.push({\n node: domSel.focusNode,\n offset: domSel.focusOffset\n });\n }\n if (chrome && view.input.lastKeyCode === 8) {\n for (var off = toOffset; off > fromOffset; off--) {\n var node = parent.childNodes[off - 1],\n desc = node.pmViewDesc;\n if (node.nodeName == \"BR\" && !desc) {\n toOffset = off;\n break;\n }\n if (!desc || desc.size) break;\n }\n }\n var startDoc = view.state.doc;\n var parser = view.someProp(\"domParser\") || prosemirrorModel.DOMParser.fromSchema(view.state.schema);\n var $from = startDoc.resolve(from);\n var sel = null,\n doc = parser.parse(parent, {\n topNode: $from.parent,\n topMatch: $from.parent.contentMatchAt($from.index()),\n topOpen: true,\n from: fromOffset,\n to: toOffset,\n preserveWhitespace: $from.parent.type.whitespace == \"pre\" ? \"full\" : true,\n findPositions: find,\n ruleFromNode: ruleFromNode(addedNodes),\n context: $from\n });\n if (find && find[0].pos != null) {\n var _anchor = find[0].pos,\n head = find[1] && find[1].pos;\n if (head == null) head = _anchor;\n sel = {\n anchor: _anchor + from,\n head: head + from\n };\n }\n return {\n doc: doc,\n sel: sel,\n from: from,\n to: to\n };\n}\nvar ruleFromNode = function ruleFromNode(added) {\n return function (dom) {\n var desc = dom.pmViewDesc;\n if (desc) {\n return desc.parseRule(added);\n } else if (dom.nodeName == \"BR\" && dom.parentNode) {\n if (safari && /^(ul|ol)$/i.test(dom.parentNode.nodeName)) {\n var skip = document.createElement(\"div\");\n skip.appendChild(document.createElement(\"li\"));\n return {\n skip: skip\n };\n } else if (dom.parentNode.lastChild == dom || safari && /^(tr|table)$/i.test(dom.parentNode.nodeName)) {\n return {\n ignore: true\n };\n }\n } else if (dom.nodeName == \"IMG\" && dom.getAttribute(\"mark-placeholder\")) {\n return {\n ignore: true\n };\n }\n return null;\n };\n};\nvar isInline = /^(a|abbr|acronym|b|bd[io]|big|br|button|cite|code|data(list)?|del|dfn|em|i|img|ins|kbd|label|map|mark|meter|output|q|ruby|s|samp|small|span|strong|su[bp]|time|u|tt|var)$/i;\nfunction readDOMChange(view, from, to, typeOver, addedNodes) {\n var compositionID = view.input.compositionPendingChanges || (view.composing ? view.input.compositionID : 0);\n view.input.compositionPendingChanges = 0;\n if (from < 0) {\n var origin = view.input.lastSelectionTime > Date.now() - 50 ? view.input.lastSelectionOrigin : null;\n var newSel = selectionFromDOM(view, origin);\n if (newSel && !view.state.selection.eq(newSel)) {\n if (chrome && android && view.input.lastKeyCode === 13 && Date.now() - 100 < view.input.lastKeyCodeTime && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n })) return;\n var tr = view.state.tr.setSelection(newSel);\n if (origin == \"pointer\") tr.setMeta(\"pointer\", true);else if (origin == \"key\") tr.scrollIntoView();\n if (compositionID) tr.setMeta(\"composition\", compositionID);\n view.dispatch(tr);\n }\n return;\n }\n var $before = view.state.doc.resolve(from);\n var shared = $before.sharedDepth(to);\n from = $before.before(shared + 1);\n to = view.state.doc.resolve(to).after(shared + 1);\n var sel = view.state.selection;\n var parse = parseBetween(view, from, to, addedNodes);\n var doc = view.state.doc,\n compare = doc.slice(parse.from, parse.to);\n var preferredPos, preferredSide;\n if (view.input.lastKeyCode === 8 && Date.now() - 100 < view.input.lastKeyCodeTime) {\n preferredPos = view.state.selection.to;\n preferredSide = \"end\";\n } else {\n preferredPos = view.state.selection.from;\n preferredSide = \"start\";\n }\n view.input.lastKeyCode = null;\n var change = findDiff(compare.content, parse.doc.content, parse.from, preferredPos, preferredSide);\n if (change) view.input.domChangeCount++;\n if ((ios && view.input.lastIOSEnter > Date.now() - 225 || android) && addedNodes.some(function (n) {\n return n.nodeType == 1 && !isInline.test(n.nodeName);\n }) && (!change || change.endA >= change.endB) && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n })) {\n view.input.lastIOSEnter = 0;\n return;\n }\n if (!change) {\n if (typeOver && sel instanceof prosemirrorState.TextSelection && !sel.empty && sel.$head.sameParent(sel.$anchor) && !view.composing && !(parse.sel && parse.sel.anchor != parse.sel.head)) {\n change = {\n start: sel.from,\n endA: sel.to,\n endB: sel.to\n };\n } else {\n if (parse.sel) {\n var _sel2 = resolveSelection(view, view.state.doc, parse.sel);\n if (_sel2 && !_sel2.eq(view.state.selection)) {\n var _tr = view.state.tr.setSelection(_sel2);\n if (compositionID) _tr.setMeta(\"composition\", compositionID);\n view.dispatch(_tr);\n }\n }\n return;\n }\n }\n if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof prosemirrorState.TextSelection) {\n if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse.from) {\n change.start = view.state.selection.from;\n } else if (change.endA < view.state.selection.to && change.endA >= view.state.selection.to - 2 && view.state.selection.to <= parse.to) {\n change.endB += view.state.selection.to - change.endA;\n change.endA = view.state.selection.to;\n }\n }\n if (ie && ie_version <= 11 && change.endB == change.start + 1 && change.endA == change.start && change.start > parse.from && parse.doc.textBetween(change.start - parse.from - 1, change.start - parse.from + 1) == \" \\xA0\") {\n change.start--;\n change.endA--;\n change.endB--;\n }\n var $from = parse.doc.resolveNoCache(change.start - parse.from);\n var $to = parse.doc.resolveNoCache(change.endB - parse.from);\n var $fromA = doc.resolve(change.start);\n var inlineChange = $from.sameParent($to) && $from.parent.inlineContent && $fromA.end() >= change.endA;\n if ((ios && view.input.lastIOSEnter > Date.now() - 225 && (!inlineChange || addedNodes.some(function (n) {\n return n.nodeName == \"DIV\" || n.nodeName == \"P\";\n })) || !inlineChange && $from.pos < parse.doc.content.size && (!$from.sameParent($to) || !$from.parent.inlineContent) && $from.pos < $to.pos && !/\\S/.test(parse.doc.textBetween($from.pos, $to.pos, \"\", \"\"))) && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n })) {\n view.input.lastIOSEnter = 0;\n return;\n }\n if (view.state.selection.anchor > change.start && looksLikeBackspace(doc, change.start, change.endA, $from, $to) && view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(8, \"Backspace\"));\n })) {\n if (android && chrome) view.domObserver.suppressSelectionUpdates();\n return;\n }\n if (chrome && change.endB == change.start) view.input.lastChromeDelete = Date.now();\n if (android && !inlineChange && $from.start() != $to.start() && $to.parentOffset == 0 && $from.depth == $to.depth && parse.sel && parse.sel.anchor == parse.sel.head && parse.sel.head == change.endA) {\n change.endB -= 2;\n $to = parse.doc.resolveNoCache(change.endB - parse.from);\n setTimeout(function () {\n view.someProp(\"handleKeyDown\", function (f) {\n return f(view, keyEvent(13, \"Enter\"));\n });\n }, 20);\n }\n var chFrom = change.start,\n chTo = change.endA;\n var mkTr = function mkTr(base) {\n var tr = base || view.state.tr.replace(chFrom, chTo, parse.doc.slice(change.start - parse.from, change.endB - parse.from));\n if (parse.sel) {\n var _sel3 = resolveSelection(view, tr.doc, parse.sel);\n if (_sel3 && !(chrome && view.composing && _sel3.empty && (change.start != change.endB || view.input.lastChromeDelete < Date.now() - 100) && (_sel3.head == chFrom || _sel3.head == tr.mapping.map(chTo) - 1) || ie && _sel3.empty && _sel3.head == chFrom)) tr.setSelection(_sel3);\n }\n if (compositionID) tr.setMeta(\"composition\", compositionID);\n return tr.scrollIntoView();\n };\n var markChange;\n if (inlineChange) {\n if ($from.pos == $to.pos) {\n if (ie && ie_version <= 11 && $from.parentOffset == 0) {\n view.domObserver.suppressSelectionUpdates();\n setTimeout(function () {\n return selectionToDOM(view);\n }, 20);\n }\n var _tr2 = mkTr(view.state.tr[\"delete\"](chFrom, chTo));\n var marks = doc.resolve(change.start).marksAcross(doc.resolve(change.endA));\n if (marks) _tr2.ensureMarks(marks);\n view.dispatch(_tr2);\n } else if (change.endA == change.endB && (markChange = isMarkChange($from.parent.content.cut($from.parentOffset, $to.parentOffset), $fromA.parent.content.cut($fromA.parentOffset, change.endA - $fromA.start())))) {\n var _tr3 = mkTr(view.state.tr);\n if (markChange.type == \"add\") _tr3.addMark(chFrom, chTo, markChange.mark);else _tr3.removeMark(chFrom, chTo, markChange.mark);\n view.dispatch(_tr3);\n } else if ($from.parent.child($from.index()).isText && $from.index() == $to.index() - ($to.textOffset ? 0 : 1)) {\n var text = $from.parent.textBetween($from.parentOffset, $to.parentOffset);\n var deflt = function deflt() {\n return mkTr(view.state.tr.insertText(text, chFrom, chTo));\n };\n if (!view.someProp(\"handleTextInput\", function (f) {\n return f(view, chFrom, chTo, text, deflt);\n })) view.dispatch(deflt());\n } else {\n view.dispatch(mkTr());\n }\n } else {\n view.dispatch(mkTr());\n }\n}\nfunction resolveSelection(view, doc, parsedSel) {\n if (Math.max(parsedSel.anchor, parsedSel.head) > doc.content.size) return null;\n return selectionBetween(view, doc.resolve(parsedSel.anchor), doc.resolve(parsedSel.head));\n}\nfunction isMarkChange(cur, prev) {\n var curMarks = cur.firstChild.marks,\n prevMarks = prev.firstChild.marks;\n var added = curMarks,\n removed = prevMarks,\n type,\n mark,\n update;\n for (var i = 0; i < prevMarks.length; i++) added = prevMarks[i].removeFromSet(added);\n for (var _i17 = 0; _i17 < curMarks.length; _i17++) removed = curMarks[_i17].removeFromSet(removed);\n if (added.length == 1 && removed.length == 0) {\n mark = added[0];\n type = \"add\";\n update = function update(node) {\n return node.mark(mark.addToSet(node.marks));\n };\n } else if (added.length == 0 && removed.length == 1) {\n mark = removed[0];\n type = \"remove\";\n update = function update(node) {\n return node.mark(mark.removeFromSet(node.marks));\n };\n } else {\n return null;\n }\n var updated = [];\n for (var _i18 = 0; _i18 < prev.childCount; _i18++) updated.push(update(prev.child(_i18)));\n if (prosemirrorModel.Fragment.from(updated).eq(cur)) return {\n mark: mark,\n type: type\n };\n}\nfunction looksLikeBackspace(old, start, end, $newStart, $newEnd) {\n if (end - start <= $newEnd.pos - $newStart.pos || skipClosingAndOpening($newStart, true, false) < $newEnd.pos) return false;\n var $start = old.resolve(start);\n if (!$newStart.parent.isTextblock) {\n var after = $start.nodeAfter;\n return after != null && end == start + after.nodeSize;\n }\n if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock) return false;\n var $next = old.resolve(skipClosingAndOpening($start, true, true));\n if (!$next.parent.isTextblock || $next.pos > end || skipClosingAndOpening($next, true, false) < end) return false;\n return $newStart.parent.content.cut($newStart.parentOffset).eq($next.parent.content);\n}\nfunction skipClosingAndOpening($pos, fromEnd, mayOpen) {\n var depth = $pos.depth,\n end = fromEnd ? $pos.end() : $pos.pos;\n while (depth > 0 && (fromEnd || $pos.indexAfter(depth) == $pos.node(depth).childCount)) {\n depth--;\n end++;\n fromEnd = false;\n }\n if (mayOpen) {\n var next = $pos.node(depth).maybeChild($pos.indexAfter(depth));\n while (next && !next.isLeaf) {\n next = next.firstChild;\n end++;\n }\n }\n return end;\n}\nfunction findDiff(a, b, pos, preferredPos, preferredSide) {\n var start = a.findDiffStart(b, pos),\n lenA = pos + a.size,\n lenB = pos + b.size;\n if (start == null) return null;\n var _a$findDiffEnd = a.findDiffEnd(b, lenA, lenB),\n endA = _a$findDiffEnd.a,\n endB = _a$findDiffEnd.b;\n if (preferredSide == \"end\") {\n var adjust = Math.max(0, start - Math.min(endA, endB));\n preferredPos -= endA + adjust - start;\n }\n if (endA < start && lenA < lenB) {\n var move = preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0;\n start -= move;\n endB = start + (endB - endA);\n endA = start;\n } else if (endB < start) {\n var _move = preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0;\n start -= _move;\n endA = start + (endA - endB);\n endB = start;\n }\n return {\n start: start,\n endA: endA,\n endB: endB\n };\n}\nvar __parseFromClipboard = parseFromClipboard;\nvar __endComposition = endComposition;\nvar EditorView = function () {\n function EditorView(place, props) {\n var _this16 = this;\n _classCallCheck(this, EditorView);\n this._root = null;\n this.focused = false;\n this.trackWrites = null;\n this.mounted = false;\n this.markCursor = null;\n this.cursorWrapper = null;\n this.lastSelectedViewDesc = undefined;\n this.input = new InputState();\n this.prevDirectPlugins = [];\n this.pluginViews = [];\n this.requiresGeckoHackNode = false;\n this.dragging = null;\n this._props = props;\n this.state = props.state;\n this.directPlugins = props.plugins || [];\n this.directPlugins.forEach(checkStateComponent);\n this.dispatch = this.dispatch.bind(this);\n this.dom = place && place.mount || document.createElement(\"div\");\n if (place) {\n if (place.appendChild) place.appendChild(this.dom);else if (typeof place == \"function\") place(this.dom);else if (place.mount) this.mounted = true;\n }\n this.editable = getEditable(this);\n updateCursorWrapper(this);\n this.nodeViews = buildNodeViews(this);\n this.docView = docViewDesc(this.state.doc, computeDocDeco(this), viewDecorations(this), this.dom, this);\n this.domObserver = new DOMObserver(this, function (from, to, typeOver, added) {\n return readDOMChange(_this16, from, to, typeOver, added);\n });\n this.domObserver.start();\n initInput(this);\n this.updatePluginViews();\n }\n _createClass(EditorView, [{\n key: \"composing\",\n get: function get() {\n return this.input.composing;\n }\n }, {\n key: \"props\",\n get: function get() {\n if (this._props.state != this.state) {\n var prev = this._props;\n this._props = {};\n for (var name in prev) this._props[name] = prev[name];\n this._props.state = this.state;\n }\n return this._props;\n }\n }, {\n key: \"update\",\n value: function update(props) {\n if (props.handleDOMEvents != this._props.handleDOMEvents) ensureListeners(this);\n var prevProps = this._props;\n this._props = props;\n if (props.plugins) {\n props.plugins.forEach(checkStateComponent);\n this.directPlugins = props.plugins;\n }\n this.updateStateInner(props.state, prevProps);\n }\n }, {\n key: \"setProps\",\n value: function setProps(props) {\n var updated = {};\n for (var name in this._props) updated[name] = this._props[name];\n updated.state = this.state;\n for (var _name2 in props) updated[_name2] = props[_name2];\n this.update(updated);\n }\n }, {\n key: \"updateState\",\n value: function updateState(state) {\n this.updateStateInner(state, this._props);\n }\n }, {\n key: \"updateStateInner\",\n value: function updateStateInner(state, prevProps) {\n var _a;\n var prev = this.state,\n redraw = false,\n updateSel = false;\n if (state.storedMarks && this.composing) {\n clearComposition(this);\n updateSel = true;\n }\n this.state = state;\n var pluginsChanged = prev.plugins != state.plugins || this._props.plugins != prevProps.plugins;\n if (pluginsChanged || this._props.plugins != prevProps.plugins || this._props.nodeViews != prevProps.nodeViews) {\n var nodeViews = buildNodeViews(this);\n if (changedNodeViews(nodeViews, this.nodeViews)) {\n this.nodeViews = nodeViews;\n redraw = true;\n }\n }\n if (pluginsChanged || prevProps.handleDOMEvents != this._props.handleDOMEvents) {\n ensureListeners(this);\n }\n this.editable = getEditable(this);\n updateCursorWrapper(this);\n var innerDeco = viewDecorations(this),\n outerDeco = computeDocDeco(this);\n var scroll = prev.plugins != state.plugins && !prev.doc.eq(state.doc) ? \"reset\" : state.scrollToSelection > prev.scrollToSelection ? \"to selection\" : \"preserve\";\n var updateDoc = redraw || !this.docView.matchesNode(state.doc, outerDeco, innerDeco);\n if (updateDoc || !state.selection.eq(prev.selection)) updateSel = true;\n var oldScrollPos = scroll == \"preserve\" && updateSel && this.dom.style.overflowAnchor == null && storeScrollPos(this);\n if (updateSel) {\n this.domObserver.stop();\n var forceSelUpdate = updateDoc && (ie || chrome) && !this.composing && !prev.selection.empty && !state.selection.empty && selectionContextChanged(prev.selection, state.selection);\n if (updateDoc) {\n var chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;\n if (this.composing) this.input.compositionNode = findCompositionNode(this);\n if (redraw || !this.docView.update(state.doc, outerDeco, innerDeco, this)) {\n this.docView.updateOuterDeco(outerDeco);\n this.docView.destroy();\n this.docView = docViewDesc(state.doc, outerDeco, innerDeco, this.dom, this);\n }\n if (chromeKludge && (!this.trackWrites || !this.dom.contains(this.trackWrites))) forceSelUpdate = true;\n }\n var mouseDown = this.input.mouseDown;\n if (forceSelUpdate || !(mouseDown && this.domObserver.currentSelection.eq(this.domSelectionRange()) && anchorInRightPlace(this) && mouseDown.delaySelUpdate())) {\n selectionToDOM(this, forceSelUpdate);\n } else {\n syncNodeSelection(this, state.selection);\n this.domObserver.setCurSelection();\n }\n this.domObserver.start();\n }\n this.updatePluginViews(prev);\n if (((_a = this.dragging) === null || _a === void 0 ? void 0 : _a.node) && !prev.doc.eq(state.doc)) this.updateDraggedNode(this.dragging, prev);\n if (scroll == \"reset\") {\n this.dom.scrollTop = 0;\n } else if (scroll == \"to selection\") {\n this.scrollToSelection();\n } else if (oldScrollPos) {\n resetScrollPos(oldScrollPos);\n }\n }\n }, {\n key: \"scrollToSelection\",\n value: function scrollToSelection() {\n var _this17 = this;\n var startDOM = this.domSelectionRange().focusNode;\n if (!startDOM || !this.dom.contains(startDOM.nodeType == 1 ? startDOM : startDOM.parentNode)) ;else if (this.someProp(\"handleScrollToSelection\", function (f) {\n return f(_this17);\n })) ;else if (this.state.selection instanceof prosemirrorState.NodeSelection) {\n var target = this.docView.domAfterPos(this.state.selection.from);\n if (target.nodeType == 1) scrollRectIntoView(this, target.getBoundingClientRect(), startDOM);\n } else {\n scrollRectIntoView(this, this.coordsAtPos(this.state.selection.head, 1), startDOM);\n }\n }\n }, {\n key: \"destroyPluginViews\",\n value: function destroyPluginViews() {\n var view;\n while (view = this.pluginViews.pop()) if (view.destroy) view.destroy();\n }\n }, {\n key: \"updatePluginViews\",\n value: function updatePluginViews(prevState) {\n if (!prevState || prevState.plugins != this.state.plugins || this.directPlugins != this.prevDirectPlugins) {\n this.prevDirectPlugins = this.directPlugins;\n this.destroyPluginViews();\n for (var i = 0; i < this.directPlugins.length; i++) {\n var plugin = this.directPlugins[i];\n if (plugin.spec.view) this.pluginViews.push(plugin.spec.view(this));\n }\n for (var _i19 = 0; _i19 < this.state.plugins.length; _i19++) {\n var _plugin = this.state.plugins[_i19];\n if (_plugin.spec.view) this.pluginViews.push(_plugin.spec.view(this));\n }\n } else {\n for (var _i20 = 0; _i20 < this.pluginViews.length; _i20++) {\n var pluginView = this.pluginViews[_i20];\n if (pluginView.update) pluginView.update(this, prevState);\n }\n }\n }\n }, {\n key: \"updateDraggedNode\",\n value: function updateDraggedNode(dragging, prev) {\n var sel = dragging.node,\n found = -1;\n if (sel.from < this.state.doc.content.size && this.state.doc.nodeAt(sel.from) == sel.node) {\n found = sel.from;\n } else {\n var movedPos = sel.from + (this.state.doc.content.size - prev.doc.content.size);\n var moved = movedPos > 0 && movedPos < this.state.doc.content.size && this.state.doc.nodeAt(movedPos);\n if (moved == sel.node) found = movedPos;\n }\n this.dragging = new Dragging(dragging.slice, dragging.move, found < 0 ? undefined : prosemirrorState.NodeSelection.create(this.state.doc, found));\n }\n }, {\n key: \"someProp\",\n value: function someProp(propName, f) {\n var prop = this._props && this._props[propName],\n value;\n if (prop != null && (value = f ? f(prop) : prop)) return value;\n for (var i = 0; i < this.directPlugins.length; i++) {\n var _prop = this.directPlugins[i].props[propName];\n if (_prop != null && (value = f ? f(_prop) : _prop)) return value;\n }\n var plugins = this.state.plugins;\n if (plugins) for (var _i21 = 0; _i21 < plugins.length; _i21++) {\n var _prop2 = plugins[_i21].props[propName];\n if (_prop2 != null && (value = f ? f(_prop2) : _prop2)) return value;\n }\n }\n }, {\n key: \"hasFocus\",\n value: function hasFocus() {\n if (ie) {\n var node = this.root.activeElement;\n if (node == this.dom) return true;\n if (!node || !this.dom.contains(node)) return false;\n while (node && this.dom != node && this.dom.contains(node)) {\n if (node.contentEditable == 'false') return false;\n node = node.parentElement;\n }\n return true;\n }\n return this.root.activeElement == this.dom;\n }\n }, {\n key: \"focus\",\n value: function focus() {\n this.domObserver.stop();\n if (this.editable) focusPreventScroll(this.dom);\n selectionToDOM(this);\n this.domObserver.start();\n }\n }, {\n key: \"root\",\n get: function get() {\n var _this18 = this;\n var cached = this._root;\n if (cached == null) {\n var _loop5 = function _loop5(search) {\n if (search.nodeType == 9 || search.nodeType == 11 && search.host) {\n if (!search.getSelection) Object.getPrototypeOf(search).getSelection = function () {\n return search.ownerDocument.getSelection();\n };\n return {\n v: _this18._root = search\n };\n }\n },\n _ret3;\n for (var search = this.dom.parentNode; search; search = search.parentNode) {\n _ret3 = _loop5(search);\n if (_ret3) return _ret3.v;\n }\n }\n return cached || document;\n }\n }, {\n key: \"updateRoot\",\n value: function updateRoot() {\n this._root = null;\n }\n }, {\n key: \"posAtCoords\",\n value: function posAtCoords(coords) {\n return _posAtCoords(this, coords);\n }\n }, {\n key: \"coordsAtPos\",\n value: function coordsAtPos(pos) {\n var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;\n return _coordsAtPos(this, pos, side);\n }\n }, {\n key: \"domAtPos\",\n value: function domAtPos(pos) {\n var side = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;\n return this.docView.domFromPos(pos, side);\n }\n }, {\n key: \"nodeDOM\",\n value: function nodeDOM(pos) {\n var desc = this.docView.descAt(pos);\n return desc ? desc.nodeDOM : null;\n }\n }, {\n key: \"posAtDOM\",\n value: function posAtDOM(node, offset) {\n var bias = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : -1;\n var pos = this.docView.posFromDOM(node, offset, bias);\n if (pos == null) throw new RangeError(\"DOM position not inside the editor\");\n return pos;\n }\n }, {\n key: \"endOfTextblock\",\n value: function endOfTextblock(dir, state) {\n return _endOfTextblock(this, state || this.state, dir);\n }\n }, {\n key: \"pasteHTML\",\n value: function pasteHTML(html, event) {\n return doPaste(this, \"\", html, false, event || new ClipboardEvent(\"paste\"));\n }\n }, {\n key: \"pasteText\",\n value: function pasteText(text, event) {\n return doPaste(this, text, null, true, event || new ClipboardEvent(\"paste\"));\n }\n }, {\n key: \"serializeForClipboard\",\n value: function serializeForClipboard(slice) {\n return _serializeForClipboard(this, slice);\n }\n }, {\n key: \"destroy\",\n value: function destroy() {\n if (!this.docView) return;\n destroyInput(this);\n this.destroyPluginViews();\n if (this.mounted) {\n this.docView.update(this.state.doc, [], viewDecorations(this), this);\n this.dom.textContent = \"\";\n } else if (this.dom.parentNode) {\n this.dom.parentNode.removeChild(this.dom);\n }\n this.docView.destroy();\n this.docView = null;\n clearReusedRange();\n }\n }, {\n key: \"isDestroyed\",\n get: function get() {\n return this.docView == null;\n }\n }, {\n key: \"dispatchEvent\",\n value: function dispatchEvent(event) {\n return _dispatchEvent(this, event);\n }\n }, {\n key: \"domSelectionRange\",\n value: function domSelectionRange() {\n var sel = this.domSelection();\n if (!sel) return {\n focusNode: null,\n focusOffset: 0,\n anchorNode: null,\n anchorOffset: 0\n };\n return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;\n }\n }, {\n key: \"domSelection\",\n value: function domSelection() {\n return this.root.getSelection();\n }\n }]);\n return EditorView;\n}();\nEditorView.prototype.dispatch = function (tr) {\n var dispatchTransaction = this._props.dispatchTransaction;\n if (dispatchTransaction) dispatchTransaction.call(this, tr);else this.updateState(this.state.apply(tr));\n};\nfunction computeDocDeco(view) {\n var attrs = Object.create(null);\n attrs[\"class\"] = \"ProseMirror\";\n attrs.contenteditable = String(view.editable);\n view.someProp(\"attributes\", function (value) {\n if (typeof value == \"function\") value = value(view.state);\n if (value) for (var attr in value) {\n if (attr == \"class\") attrs[\"class\"] += \" \" + value[attr];else if (attr == \"style\") attrs.style = (attrs.style ? attrs.style + \";\" : \"\") + value[attr];else if (!attrs[attr] && attr != \"contenteditable\" && attr != \"nodeName\") attrs[attr] = String(value[attr]);\n }\n });\n if (!attrs.translate) attrs.translate = \"no\";\n return [Decoration.node(0, view.state.doc.content.size, attrs)];\n}\nfunction updateCursorWrapper(view) {\n if (view.markCursor) {\n var dom = document.createElement(\"img\");\n dom.className = \"ProseMirror-separator\";\n dom.setAttribute(\"mark-placeholder\", \"true\");\n dom.setAttribute(\"alt\", \"\");\n view.cursorWrapper = {\n dom: dom,\n deco: Decoration.widget(view.state.selection.from, dom, {\n raw: true,\n marks: view.markCursor\n })\n };\n } else {\n view.cursorWrapper = null;\n }\n}\nfunction getEditable(view) {\n return !view.someProp(\"editable\", function (value) {\n return value(view.state) === false;\n });\n}\nfunction selectionContextChanged(sel1, sel2) {\n var depth = Math.min(sel1.$anchor.sharedDepth(sel1.head), sel2.$anchor.sharedDepth(sel2.head));\n return sel1.$anchor.start(depth) != sel2.$anchor.start(depth);\n}\nfunction buildNodeViews(view) {\n var result = Object.create(null);\n function add(obj) {\n for (var _prop3 in obj) if (!Object.prototype.hasOwnProperty.call(result, _prop3)) result[_prop3] = obj[_prop3];\n }\n view.someProp(\"nodeViews\", add);\n view.someProp(\"markViews\", add);\n return result;\n}\nfunction changedNodeViews(a, b) {\n var nA = 0,\n nB = 0;\n for (var _prop4 in a) {\n if (a[_prop4] != b[_prop4]) return true;\n nA++;\n }\n for (var _ in b) nB++;\n return nA != nB;\n}\nfunction checkStateComponent(plugin) {\n if (plugin.spec.state || plugin.spec.filterTransaction || plugin.spec.appendTransaction) throw new RangeError(\"Plugins passed directly to the view must not have a state component\");\n}\nexports.Decoration = Decoration;\nexports.DecorationSet = DecorationSet;\nexports.EditorView = EditorView;\nexports.__endComposition = __endComposition;\nexports.__parseFromClipboard = __parseFromClipboard;\n","'use strict';\n\nvar GOOD_LEAF_SIZE = 200;\n\n// :: class<T> A rope sequence is a persistent sequence data structure\n// that supports appending, prepending, and slicing without doing a\n// full copy. It is represented as a mostly-balanced tree.\nvar RopeSequence = function RopeSequence () {};\n\nRopeSequence.prototype.append = function append (other) {\n if (!other.length) { return this }\n other = RopeSequence.from(other);\n\n return (!this.length && other) ||\n (other.length < GOOD_LEAF_SIZE && this.leafAppend(other)) ||\n (this.length < GOOD_LEAF_SIZE && other.leafPrepend(this)) ||\n this.appendInner(other)\n};\n\n// :: (union<[T], RopeSequence<T>>) → RopeSequence<T>\n// Prepend an array or other rope to this one, returning a new rope.\nRopeSequence.prototype.prepend = function prepend (other) {\n if (!other.length) { return this }\n return RopeSequence.from(other).append(this)\n};\n\nRopeSequence.prototype.appendInner = function appendInner (other) {\n return new Append(this, other)\n};\n\n// :: (?number, ?number) → RopeSequence<T>\n// Create a rope repesenting a sub-sequence of this rope.\nRopeSequence.prototype.slice = function slice (from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n if (from >= to) { return RopeSequence.empty }\n return this.sliceInner(Math.max(0, from), Math.min(this.length, to))\n};\n\n// :: (number) → T\n// Retrieve the element at the given position from this rope.\nRopeSequence.prototype.get = function get (i) {\n if (i < 0 || i >= this.length) { return undefined }\n return this.getInner(i)\n};\n\n// :: ((element: T, index: number) → ?bool, ?number, ?number)\n// Call the given function for each element between the given\n// indices. This tends to be more efficient than looping over the\n// indices and calling `get`, because it doesn't have to descend the\n// tree for every element.\nRopeSequence.prototype.forEach = function forEach (f, from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n if (from <= to)\n { this.forEachInner(f, from, to, 0); }\n else\n { this.forEachInvertedInner(f, from, to, 0); }\n};\n\n// :: ((element: T, index: number) → U, ?number, ?number) → [U]\n// Map the given functions over the elements of the rope, producing\n// a flat array.\nRopeSequence.prototype.map = function map (f, from, to) {\n if ( from === void 0 ) from = 0;\n if ( to === void 0 ) to = this.length;\n\n var result = [];\n this.forEach(function (elt, i) { return result.push(f(elt, i)); }, from, to);\n return result\n};\n\n// :: (?union<[T], RopeSequence<T>>) → RopeSequence<T>\n// Create a rope representing the given array, or return the rope\n// itself if a rope was given.\nRopeSequence.from = function from (values) {\n if (values instanceof RopeSequence) { return values }\n return values && values.length ? new Leaf(values) : RopeSequence.empty\n};\n\nvar Leaf = /*@__PURE__*/(function (RopeSequence) {\n function Leaf(values) {\n RopeSequence.call(this);\n this.values = values;\n }\n\n if ( RopeSequence ) Leaf.__proto__ = RopeSequence;\n Leaf.prototype = Object.create( RopeSequence && RopeSequence.prototype );\n Leaf.prototype.constructor = Leaf;\n\n var prototypeAccessors = { length: { configurable: true },depth: { configurable: true } };\n\n Leaf.prototype.flatten = function flatten () {\n return this.values\n };\n\n Leaf.prototype.sliceInner = function sliceInner (from, to) {\n if (from == 0 && to == this.length) { return this }\n return new Leaf(this.values.slice(from, to))\n };\n\n Leaf.prototype.getInner = function getInner (i) {\n return this.values[i]\n };\n\n Leaf.prototype.forEachInner = function forEachInner (f, from, to, start) {\n for (var i = from; i < to; i++)\n { if (f(this.values[i], start + i) === false) { return false } }\n };\n\n Leaf.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {\n for (var i = from - 1; i >= to; i--)\n { if (f(this.values[i], start + i) === false) { return false } }\n };\n\n Leaf.prototype.leafAppend = function leafAppend (other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE)\n { return new Leaf(this.values.concat(other.flatten())) }\n };\n\n Leaf.prototype.leafPrepend = function leafPrepend (other) {\n if (this.length + other.length <= GOOD_LEAF_SIZE)\n { return new Leaf(other.flatten().concat(this.values)) }\n };\n\n prototypeAccessors.length.get = function () { return this.values.length };\n\n prototypeAccessors.depth.get = function () { return 0 };\n\n Object.defineProperties( Leaf.prototype, prototypeAccessors );\n\n return Leaf;\n}(RopeSequence));\n\n// :: RopeSequence\n// The empty rope sequence.\nRopeSequence.empty = new Leaf([]);\n\nvar Append = /*@__PURE__*/(function (RopeSequence) {\n function Append(left, right) {\n RopeSequence.call(this);\n this.left = left;\n this.right = right;\n this.length = left.length + right.length;\n this.depth = Math.max(left.depth, right.depth) + 1;\n }\n\n if ( RopeSequence ) Append.__proto__ = RopeSequence;\n Append.prototype = Object.create( RopeSequence && RopeSequence.prototype );\n Append.prototype.constructor = Append;\n\n Append.prototype.flatten = function flatten () {\n return this.left.flatten().concat(this.right.flatten())\n };\n\n Append.prototype.getInner = function getInner (i) {\n return i < this.left.length ? this.left.get(i) : this.right.get(i - this.left.length)\n };\n\n Append.prototype.forEachInner = function forEachInner (f, from, to, start) {\n var leftLen = this.left.length;\n if (from < leftLen &&\n this.left.forEachInner(f, from, Math.min(to, leftLen), start) === false)\n { return false }\n if (to > leftLen &&\n this.right.forEachInner(f, Math.max(from - leftLen, 0), Math.min(this.length, to) - leftLen, start + leftLen) === false)\n { return false }\n };\n\n Append.prototype.forEachInvertedInner = function forEachInvertedInner (f, from, to, start) {\n var leftLen = this.left.length;\n if (from > leftLen &&\n this.right.forEachInvertedInner(f, from - leftLen, Math.max(to, leftLen) - leftLen, start + leftLen) === false)\n { return false }\n if (to < leftLen &&\n this.left.forEachInvertedInner(f, Math.min(from, leftLen), to, start) === false)\n { return false }\n };\n\n Append.prototype.sliceInner = function sliceInner (from, to) {\n if (from == 0 && to == this.length) { return this }\n var leftLen = this.left.length;\n if (to <= leftLen) { return this.left.slice(from, to) }\n if (from >= leftLen) { return this.right.slice(from - leftLen, to - leftLen) }\n return this.left.slice(from, leftLen).append(this.right.slice(0, to - leftLen))\n };\n\n Append.prototype.leafAppend = function leafAppend (other) {\n var inner = this.right.leafAppend(other);\n if (inner) { return new Append(this.left, inner) }\n };\n\n Append.prototype.leafPrepend = function leafPrepend (other) {\n var inner = this.left.leafPrepend(other);\n if (inner) { return new Append(inner, this.right) }\n };\n\n Append.prototype.appendInner = function appendInner (other) {\n if (this.left.depth >= Math.max(this.right.depth, other.depth) + 1)\n { return new Append(this.left, new Append(this.right, other)) }\n return new Append(this, other)\n };\n\n return Append;\n}(RopeSequence));\n\nmodule.exports = RopeSequence;\n","'use strict';\n\nObject.defineProperty(exports, '__esModule', { value: true });\n\nvar base = {\n 8: \"Backspace\",\n 9: \"Tab\",\n 10: \"Enter\",\n 12: \"NumLock\",\n 13: \"Enter\",\n 16: \"Shift\",\n 17: \"Control\",\n 18: \"Alt\",\n 20: \"CapsLock\",\n 27: \"Escape\",\n 32: \" \",\n 33: \"PageUp\",\n 34: \"PageDown\",\n 35: \"End\",\n 36: \"Home\",\n 37: \"ArrowLeft\",\n 38: \"ArrowUp\",\n 39: \"ArrowRight\",\n 40: \"ArrowDown\",\n 44: \"PrintScreen\",\n 45: \"Insert\",\n 46: \"Delete\",\n 59: \";\",\n 61: \"=\",\n 91: \"Meta\",\n 92: \"Meta\",\n 106: \"*\",\n 107: \"+\",\n 108: \",\",\n 109: \"-\",\n 110: \".\",\n 111: \"/\",\n 144: \"NumLock\",\n 145: \"ScrollLock\",\n 160: \"Shift\",\n 161: \"Shift\",\n 162: \"Control\",\n 163: \"Control\",\n 164: \"Alt\",\n 165: \"Alt\",\n 173: \"-\",\n 186: \";\",\n 187: \"=\",\n 188: \",\",\n 189: \"-\",\n 190: \".\",\n 191: \"/\",\n 192: \"`\",\n 219: \"[\",\n 220: \"\\\\\",\n 221: \"]\",\n 222: \"'\"\n};\n\nvar shift = {\n 48: \")\",\n 49: \"!\",\n 50: \"@\",\n 51: \"#\",\n 52: \"$\",\n 53: \"%\",\n 54: \"^\",\n 55: \"&\",\n 56: \"*\",\n 57: \"(\",\n 59: \":\",\n 61: \"+\",\n 173: \"_\",\n 186: \":\",\n 187: \"+\",\n 188: \"<\",\n 189: \"_\",\n 190: \">\",\n 191: \"?\",\n 192: \"~\",\n 219: \"{\",\n 220: \"|\",\n 221: \"}\",\n 222: \"\\\"\"\n};\n\nvar mac = typeof navigator != \"undefined\" && /Mac/.test(navigator.platform);\nvar ie = typeof navigator != \"undefined\" && /MSIE \\d|Trident\\/(?:[7-9]|\\d{2,})\\..*rv:(\\d+)/.exec(navigator.userAgent);\n\n// Fill in the digit keys\nfor (var i = 0; i < 10; i++) base[48 + i] = base[96 + i] = String(i);\n\n// The function keys\nfor (var i = 1; i <= 24; i++) base[i + 111] = \"F\" + i;\n\n// And the alphabetic keys\nfor (var i = 65; i <= 90; i++) {\n base[i] = String.fromCharCode(i + 32);\n shift[i] = String.fromCharCode(i);\n}\n\n// For each code that doesn't have a shift-equivalent, copy the base name\nfor (var code in base) if (!shift.hasOwnProperty(code)) shift[code] = base[code];\n\nfunction keyName(event) {\n // On macOS, keys held with Shift and Cmd don't reflect the effect of Shift in `.key`.\n // On IE, shift effect is never included in `.key`.\n var ignoreKey = mac && event.metaKey && event.shiftKey && !event.ctrlKey && !event.altKey ||\n ie && event.shiftKey && event.key && event.key.length == 1 ||\n event.key == \"Unidentified\";\n var name = (!ignoreKey && event.key) ||\n (event.shiftKey ? shift : base)[event.keyCode] ||\n event.key || \"Unidentified\";\n // Edge sometimes produces wrong names (Issue #3)\n if (name == \"Esc\") name = \"Escape\";\n if (name == \"Del\") name = \"Delete\";\n // https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/8860571/\n if (name == \"Left\") name = \"ArrowLeft\";\n if (name == \"Up\") name = \"ArrowUp\";\n if (name == \"Right\") name = \"ArrowRight\";\n if (name == \"Down\") name = \"ArrowDown\";\n return name\n}\n\nexports.base = base;\nexports.keyName = keyName;\nexports.shift = shift;\n"],"names":[],"sourceRoot":""}