@vonage/vivid 5.15.1 → 5.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (732) hide show
  1. package/accordion/definition.cjs +7 -207
  2. package/accordion/definition.js +2 -199
  3. package/accordion/index.cjs +4 -4
  4. package/accordion/index.js +93 -127
  5. package/accordion-item/definition.cjs +6 -146
  6. package/accordion-item/definition.js +2 -139
  7. package/accordion-item/index.cjs +1 -1
  8. package/accordion-item/index.js +6 -2
  9. package/action-group/definition.cjs +5 -69
  10. package/action-group/definition.js +1 -62
  11. package/action-group/index.cjs +4 -4
  12. package/action-group/index.js +16 -46
  13. package/alert/definition.cjs +6 -201
  14. package/alert/definition.js +2 -194
  15. package/alert/index.cjs +15 -15
  16. package/alert/index.js +90 -136
  17. package/audio-player/definition.cjs +6 -459
  18. package/audio-player/definition.js +2 -452
  19. package/audio-player/index.cjs +49 -49
  20. package/audio-player/index.js +234 -302
  21. package/avatar/definition.cjs +6 -117
  22. package/avatar/definition.js +2 -110
  23. package/avatar/index.cjs +14 -14
  24. package/avatar/index.js +44 -84
  25. package/badge/definition.cjs +6 -85
  26. package/badge/definition.js +2 -78
  27. package/badge/index.cjs +4 -4
  28. package/badge/index.js +21 -65
  29. package/banner/definition.cjs +6 -160
  30. package/banner/definition.js +2 -153
  31. package/banner/index.cjs +13 -13
  32. package/banner/index.js +76 -109
  33. package/breadcrumb/definition.cjs +5 -97
  34. package/breadcrumb/definition.js +1 -90
  35. package/breadcrumb/index.cjs +4 -4
  36. package/breadcrumb/index.js +33 -59
  37. package/breadcrumb-item/definition.cjs +7 -47
  38. package/breadcrumb-item/definition.js +3 -40
  39. package/breadcrumb-item/index.cjs +5 -5
  40. package/breadcrumb-item/index.js +20 -32
  41. package/bundled/affix.cjs +10 -10
  42. package/bundled/affix.js +44 -57
  43. package/bundled/anchored.cjs +3 -3
  44. package/bundled/anchored.js +47 -65
  45. package/bundled/aria.cjs +1 -1
  46. package/bundled/aria.js +6 -6
  47. package/bundled/attribute-binding-behaviour.cjs +1 -1
  48. package/bundled/attribute-binding-behaviour.js +17 -28
  49. package/bundled/base-color-picker.cjs +10 -10
  50. package/bundled/base-color-picker.js +115 -197
  51. package/bundled/base-progress.cjs +1 -1
  52. package/bundled/base-progress.js +29 -56
  53. package/bundled/breadcrumb-item.cjs +1 -1
  54. package/bundled/breadcrumb-item.js +11 -20
  55. package/bundled/button.cjs +1 -1
  56. package/bundled/button.js +65 -100
  57. package/bundled/calendar-event.cjs +1 -1
  58. package/bundled/calendar-event.js +11 -34
  59. package/bundled/calendar-picker.template.cjs +77 -77
  60. package/bundled/calendar-picker.template.js +2883 -3347
  61. package/bundled/char-count.cjs +7 -7
  62. package/bundled/char-count.js +31 -46
  63. package/bundled/children.cjs +1 -1
  64. package/bundled/children.js +27 -45
  65. package/bundled/class-names.cjs +1 -1
  66. package/bundled/class-names.js +8 -8
  67. package/bundled/data-grid.options.cjs +1 -1
  68. package/bundled/data-grid.options.js +22 -26
  69. package/bundled/decorate.cjs +1 -0
  70. package/bundled/decorate.js +9 -0
  71. package/bundled/definition.cjs +1 -39
  72. package/bundled/definition.js +5 -122
  73. package/bundled/definition10.cjs +18 -72
  74. package/bundled/definition10.js +74 -355
  75. package/bundled/definition11.cjs +10 -12
  76. package/bundled/definition11.js +28 -92
  77. package/bundled/definition12.cjs +72 -18
  78. package/bundled/definition12.js +192 -222
  79. package/bundled/definition13.cjs +20 -10
  80. package/bundled/definition13.js +55 -41
  81. package/bundled/definition14.cjs +5 -1
  82. package/bundled/definition14.js +11 -20
  83. package/bundled/definition15.cjs +19 -5
  84. package/bundled/definition15.js +77 -28
  85. package/bundled/definition16.cjs +12 -29
  86. package/bundled/definition16.js +80 -78
  87. package/bundled/definition17.cjs +17 -17
  88. package/bundled/definition17.js +126 -98
  89. package/bundled/definition18.cjs +87 -13
  90. package/bundled/definition18.js +423 -134
  91. package/bundled/definition19.cjs +5 -87
  92. package/bundled/definition19.js +16 -742
  93. package/bundled/definition2.cjs +8 -8
  94. package/bundled/definition2.js +79 -122
  95. package/bundled/definition20.cjs +26 -16
  96. package/bundled/definition20.js +153 -98
  97. package/bundled/definition21.cjs +29 -5
  98. package/bundled/definition21.js +174 -18
  99. package/bundled/definition22.cjs +38 -23
  100. package/bundled/definition22.js +70 -149
  101. package/bundled/definition3.cjs +1 -29
  102. package/bundled/definition3.js +183 -194
  103. package/bundled/definition4.cjs +24 -6
  104. package/bundled/definition4.js +88 -40
  105. package/bundled/definition5.cjs +30 -1
  106. package/bundled/definition5.js +48 -346
  107. package/bundled/definition6.cjs +28 -30
  108. package/bundled/definition6.js +110 -264
  109. package/bundled/definition7.cjs +6 -30
  110. package/bundled/definition7.js +22 -288
  111. package/bundled/definition8.cjs +13 -18
  112. package/bundled/definition8.js +150 -132
  113. package/bundled/definition9.cjs +12 -14
  114. package/bundled/definition9.js +67 -235
  115. package/bundled/delegates-aria.cjs +1 -1
  116. package/bundled/delegates-aria.js +56 -88
  117. package/bundled/dialog.cjs +1 -0
  118. package/bundled/dialog.js +6 -0
  119. package/bundled/divider.cjs +1 -1
  120. package/bundled/divider.js +16 -33
  121. package/bundled/dom.cjs +1 -1
  122. package/bundled/dom.js +5 -5
  123. package/bundled/enums.cjs +1 -1
  124. package/bundled/enums.js +16 -9
  125. package/bundled/floating-ui.dom.cjs +1 -1
  126. package/bundled/floating-ui.dom.js +953 -1238
  127. package/bundled/form-associated.cjs +1 -1
  128. package/bundled/form-associated.js +165 -318
  129. package/bundled/form-element.cjs +1 -1
  130. package/bundled/form-element.js +33 -55
  131. package/bundled/host-semantics.cjs +1 -1
  132. package/bundled/host-semantics.js +46 -69
  133. package/bundled/key-codes.cjs +1 -1
  134. package/bundled/key-codes.js +4 -16
  135. package/bundled/linkable.cjs +6 -6
  136. package/bundled/linkable.js +25 -45
  137. package/bundled/listbox.cjs +1 -1
  138. package/bundled/listbox.js +176 -351
  139. package/bundled/localized.cjs +1 -1
  140. package/bundled/localized.js +451 -564
  141. package/bundled/mixins.cjs +20 -20
  142. package/bundled/mixins.js +162 -210
  143. package/bundled/normalize.cjs +1 -1
  144. package/bundled/normalize.js +6 -6
  145. package/bundled/numbers.cjs +1 -1
  146. package/bundled/numbers.js +9 -11
  147. package/bundled/picker-field.template.cjs +23 -23
  148. package/bundled/picker-field.template.js +108 -171
  149. package/bundled/playbackRates.cjs +1 -1
  150. package/bundled/playbackRates.js +10 -10
  151. package/bundled/ref.cjs +1 -1
  152. package/bundled/ref.js +10 -14
  153. package/bundled/repeat.cjs +1 -1
  154. package/bundled/repeat.js +421 -552
  155. package/bundled/scrollIntoView.cjs +1 -1
  156. package/bundled/scrollIntoView.js +26 -29
  157. package/bundled/single-date-picker.cjs +1 -1
  158. package/bundled/single-date-picker.js +23 -38
  159. package/bundled/single-value-picker.cjs +1 -1
  160. package/bundled/single-value-picker.js +58 -86
  161. package/bundled/slider.template.cjs +14 -14
  162. package/bundled/slider.template.js +67 -78
  163. package/bundled/slottable-request.cjs +4 -4
  164. package/bundled/slottable-request.js +1907 -2904
  165. package/bundled/slotted.cjs +1 -1
  166. package/bundled/slotted.js +47 -97
  167. package/bundled/strings.cjs +1 -1
  168. package/bundled/strings.js +6 -6
  169. package/bundled/text-field.cjs +1 -1
  170. package/bundled/text-field.js +4 -4
  171. package/bundled/time-selection-picker.template.cjs +26 -26
  172. package/bundled/time-selection-picker.template.js +355 -552
  173. package/bundled/trapped-focus.cjs +1 -1
  174. package/bundled/trapped-focus.js +18 -25
  175. package/bundled/vivid-element.cjs +4 -5
  176. package/bundled/vivid-element.js +1781 -2806
  177. package/bundled/when.cjs +1 -1
  178. package/bundled/when.js +10 -10
  179. package/bundled/with-contextual-help.cjs +1 -1
  180. package/bundled/with-contextual-help.js +15 -31
  181. package/bundled/with-error-text.cjs +1 -1
  182. package/bundled/with-error-text.js +25 -38
  183. package/bundled/with-success-text.cjs +1 -1
  184. package/bundled/with-success-text.js +8 -15
  185. package/button/definition.cjs +6 -14
  186. package/button/definition.js +3 -4
  187. package/button/index.cjs +1 -1
  188. package/button/index.js +6 -2
  189. package/calendar/definition.cjs +5 -358
  190. package/calendar/definition.js +1 -351
  191. package/calendar/index.cjs +20 -20
  192. package/calendar/index.js +165 -427
  193. package/calendar-event/definition.cjs +6 -58
  194. package/calendar-event/definition.js +2 -51
  195. package/calendar-event/index.cjs +7 -7
  196. package/calendar-event/index.js +25 -41
  197. package/card/definition.cjs +6 -194
  198. package/card/definition.js +2 -187
  199. package/card/index.cjs +37 -34
  200. package/card/index.js +83 -133
  201. package/checkbox/definition.cjs +6 -209
  202. package/checkbox/definition.js +2 -202
  203. package/checkbox/index.cjs +1 -1
  204. package/checkbox/index.js +6 -2
  205. package/color-picker/definition.cjs +6 -1175
  206. package/color-picker/definition.js +2 -1168
  207. package/color-picker/index.cjs +94 -94
  208. package/color-picker/index.js +605 -737
  209. package/combobox/definition.cjs +6 -647
  210. package/combobox/definition.js +2 -640
  211. package/combobox/index.cjs +38 -37
  212. package/combobox/index.js +258 -458
  213. package/contextual-help/definition.cjs +6 -63
  214. package/contextual-help/definition.js +2 -56
  215. package/contextual-help/index.cjs +1 -1
  216. package/contextual-help/index.js +6 -2
  217. package/country/definition.cjs +6 -340
  218. package/country/definition.js +2 -333
  219. package/country/index.cjs +6 -6
  220. package/country/index.js +1209 -308
  221. package/custom-elements.json +1247 -1173
  222. package/data-grid/definition.cjs +10 -2350
  223. package/data-grid/definition.js +2 -2339
  224. package/data-grid/index.cjs +65 -65
  225. package/data-grid/index.js +644 -997
  226. package/date-picker/definition.cjs +6 -152
  227. package/date-picker/definition.js +2 -145
  228. package/date-picker/index.cjs +1 -1
  229. package/date-picker/index.js +66 -114
  230. package/date-range-picker/definition.cjs +6 -467
  231. package/date-range-picker/definition.js +2 -460
  232. package/date-range-picker/index.cjs +1 -1
  233. package/date-range-picker/index.js +218 -334
  234. package/date-time-picker/definition.cjs +6 -285
  235. package/date-time-picker/definition.js +2 -278
  236. package/date-time-picker/index.cjs +4 -4
  237. package/date-time-picker/index.js +116 -211
  238. package/dial-pad/definition.cjs +6 -460
  239. package/dial-pad/definition.js +2 -453
  240. package/dial-pad/index.cjs +44 -43
  241. package/dial-pad/index.js +197 -288
  242. package/dialog/definition.cjs +6 -349
  243. package/dialog/definition.js +2 -342
  244. package/dialog/index.cjs +28 -28
  245. package/dialog/index.js +148 -229
  246. package/divider/definition.cjs +6 -42
  247. package/divider/definition.js +2 -35
  248. package/divider/index.cjs +1 -1
  249. package/divider/index.js +5 -2
  250. package/elevation/definition.cjs +4 -11
  251. package/elevation/definition.js +2 -2
  252. package/elevation/index.cjs +1 -1
  253. package/elevation/index.js +5 -2
  254. package/empty-state/definition.cjs +6 -86
  255. package/empty-state/definition.js +2 -79
  256. package/empty-state/index.cjs +9 -9
  257. package/empty-state/index.js +28 -60
  258. package/fab/definition.cjs +6 -105
  259. package/fab/definition.js +2 -98
  260. package/fab/index.cjs +17 -17
  261. package/fab/index.js +46 -81
  262. package/file-picker/definition.cjs +6 -523
  263. package/file-picker/definition.js +2 -516
  264. package/file-picker/index.cjs +32 -29
  265. package/file-picker/index.js +254 -356
  266. package/header/definition.cjs +5 -78
  267. package/header/definition.js +1 -71
  268. package/header/index.cjs +6 -6
  269. package/header/index.js +28 -42
  270. package/icon/definition.cjs +5 -202
  271. package/icon/definition.js +1 -195
  272. package/icon/index.cjs +1 -1
  273. package/icon/index.js +5 -2
  274. package/index.cjs +353 -356
  275. package/index.js +79 -78
  276. package/layout/definition.cjs +5 -72
  277. package/layout/definition.js +1 -65
  278. package/layout/index.cjs +2 -2
  279. package/layout/index.js +10 -51
  280. package/lib/alert/alert.d.ts +0 -1
  281. package/lib/audio-player/audio-player.d.ts +0 -1
  282. package/lib/banner/banner.d.ts +0 -2
  283. package/lib/button/button.d.ts +0 -1
  284. package/lib/calendar/calendar.d.ts +0 -1
  285. package/lib/combobox/combobox.d.ts +0 -3
  286. package/lib/data-grid/data-grid-cell.d.ts +0 -3
  287. package/lib/data-grid/data-grid-row.d.ts +0 -3
  288. package/lib/data-grid/data-grid.d.ts +0 -1
  289. package/lib/date-time-picker/date-time-picker.d.ts +0 -4
  290. package/lib/dial-pad/dial-pad.d.ts +6 -2
  291. package/lib/dialog/dialog.d.ts +0 -1
  292. package/lib/fab/fab.d.ts +0 -1
  293. package/lib/file-picker/file-picker.d.ts +1 -1
  294. package/lib/icon/icon.d.ts +0 -1
  295. package/lib/menu/menu.d.ts +0 -1
  296. package/lib/option/option.d.ts +4 -1
  297. package/lib/pagination/pagination.d.ts +0 -4
  298. package/lib/popover/popover.d.ts +0 -5
  299. package/lib/rich-text-editor/rte/exports.d.ts +1 -0
  300. package/lib/rich-text-editor/rte/features/alignment.d.ts +1 -1
  301. package/lib/rich-text-editor/rte/features/character-count.d.ts +21 -0
  302. package/lib/rich-text-editor/rte/features/font-size-picker.d.ts +1 -1
  303. package/lib/rich-text-editor/rte/features/internal/basic-text-blocks.d.ts +1 -1
  304. package/lib/rich-text-editor/rte/features/keyboard-shortcuts.d.ts +1 -1
  305. package/lib/rich-text-editor/rte/features/text-color-picker.d.ts +1 -1
  306. package/lib/rich-text-editor/rte/public-interface.d.ts +6 -0
  307. package/lib/searchable-select/option-tag.d.ts +0 -1
  308. package/lib/split-button/split-button.d.ts +0 -2
  309. package/lib/tab/tab.d.ts +0 -2
  310. package/lib/table/definition.d.ts +2 -1
  311. package/lib/table/table-header-cell.d.ts +3 -0
  312. package/lib/table/table-sorting-button.d.ts +415 -0
  313. package/lib/table/table-sorting-button.template.d.ts +3 -0
  314. package/lib/tag/tag.d.ts +0 -2
  315. package/lib/toggletip/toggletip.d.ts +0 -1
  316. package/lib/tree-item/tree-item.d.ts +0 -2
  317. package/lib/tree-view/tree-view.d.ts +0 -1
  318. package/locales/de-DE.cjs +266 -550
  319. package/locales/de-DE.js +264 -548
  320. package/locales/en-GB.cjs +266 -382
  321. package/locales/en-GB.js +264 -380
  322. package/locales/en-US.cjs +266 -550
  323. package/locales/en-US.js +264 -548
  324. package/locales/ja-JP.cjs +266 -549
  325. package/locales/ja-JP.js +264 -547
  326. package/locales/zh-CN.cjs +266 -551
  327. package/locales/zh-CN.js +264 -549
  328. package/menu/definition.cjs +6 -393
  329. package/menu/definition.js +2 -386
  330. package/menu/index.cjs +1 -1
  331. package/menu/index.js +6 -2
  332. package/menu-item/definition.cjs +7 -14
  333. package/menu-item/definition.js +3 -3
  334. package/menu-item/index.cjs +1 -1
  335. package/menu-item/index.js +6 -2
  336. package/nav/definition.cjs +5 -27
  337. package/nav/definition.js +1 -20
  338. package/nav/index.cjs +3 -3
  339. package/nav/index.js +7 -10
  340. package/nav-disclosure/definition.cjs +6 -122
  341. package/nav-disclosure/definition.js +2 -115
  342. package/nav-disclosure/index.cjs +8 -8
  343. package/nav-disclosure/index.js +49 -86
  344. package/nav-item/definition.cjs +6 -79
  345. package/nav-item/definition.js +2 -72
  346. package/nav-item/index.cjs +2 -2
  347. package/nav-item/index.js +33 -58
  348. package/note/definition.cjs +6 -61
  349. package/note/definition.js +2 -54
  350. package/note/index.cjs +5 -5
  351. package/note/index.js +24 -38
  352. package/number-field/definition.cjs +6 -440
  353. package/number-field/definition.js +2 -433
  354. package/number-field/index.cjs +31 -31
  355. package/number-field/index.js +160 -328
  356. package/option/definition.cjs +6 -13
  357. package/option/definition.js +3 -3
  358. package/option/index.cjs +1 -1
  359. package/option/index.js +6 -2
  360. package/package.json +15 -17
  361. package/pagination/definition.cjs +6 -254
  362. package/pagination/definition.js +2 -247
  363. package/pagination/index.cjs +37 -37
  364. package/pagination/index.js +148 -186
  365. package/popover/definition.cjs +6 -356
  366. package/popover/definition.js +2 -349
  367. package/popover/index.cjs +16 -16
  368. package/popover/index.js +161 -239
  369. package/popup/definition.cjs +5 -13
  370. package/popup/definition.js +3 -4
  371. package/popup/index.cjs +1 -1
  372. package/popup/index.js +6 -2
  373. package/progress/definition.cjs +5 -87
  374. package/progress/definition.js +1 -80
  375. package/progress/index.cjs +9 -9
  376. package/progress/index.js +33 -55
  377. package/progress-ring/definition.cjs +5 -95
  378. package/progress-ring/definition.js +1 -88
  379. package/progress-ring/index.cjs +1 -1
  380. package/progress-ring/index.js +5 -2
  381. package/radio/definition.cjs +5 -227
  382. package/radio/definition.js +1 -220
  383. package/radio/index.cjs +1 -1
  384. package/radio/index.js +5 -2
  385. package/radio-group/definition.cjs +6 -361
  386. package/radio-group/definition.js +2 -354
  387. package/radio-group/index.cjs +10 -10
  388. package/radio-group/index.js +160 -242
  389. package/range-slider/definition.cjs +6 -632
  390. package/range-slider/definition.js +2 -625
  391. package/range-slider/index.cjs +41 -41
  392. package/range-slider/index.js +259 -429
  393. package/rich-text-editor/definition.cjs +33 -15694
  394. package/rich-text-editor/definition.js +3 -15662
  395. package/rich-text-editor/index.cjs +18 -18
  396. package/rich-text-editor/index.js +9129 -11475
  397. package/rich-text-view/definition.cjs +5 -171
  398. package/rich-text-view/definition.js +1 -164
  399. package/rich-text-view/index.cjs +1 -1
  400. package/rich-text-view/index.js +68 -102
  401. package/searchable-select/definition.cjs +5 -1401
  402. package/searchable-select/definition.js +2 -1395
  403. package/searchable-select/index.cjs +94 -94
  404. package/searchable-select/index.js +600 -1015
  405. package/select/definition.cjs +6 -1002
  406. package/select/definition.js +2 -995
  407. package/select/index.cjs +1 -1
  408. package/select/index.js +6 -2
  409. package/selectable-box/definition.cjs +6 -174
  410. package/selectable-box/definition.js +2 -167
  411. package/selectable-box/index.cjs +18 -18
  412. package/selectable-box/index.js +66 -127
  413. package/shared/foundation/test-utilities/fixture.d.ts +1 -1
  414. package/shared/patterns/linkable.d.ts +1 -1
  415. package/side-drawer/definition.cjs +5 -130
  416. package/side-drawer/definition.js +1 -123
  417. package/side-drawer/index.cjs +7 -7
  418. package/side-drawer/index.js +47 -89
  419. package/simple-color-picker/definition.cjs +6 -225
  420. package/simple-color-picker/definition.js +2 -218
  421. package/simple-color-picker/index.cjs +15 -15
  422. package/simple-color-picker/index.js +98 -135
  423. package/slider/definition.cjs +6 -499
  424. package/slider/definition.js +2 -492
  425. package/slider/index.cjs +1 -1
  426. package/slider/index.js +6 -2
  427. package/split-button/definition.cjs +6 -176
  428. package/split-button/definition.js +2 -169
  429. package/split-button/index.cjs +15 -15
  430. package/split-button/index.js +74 -135
  431. package/status/definition.cjs +6 -82
  432. package/status/definition.js +2 -75
  433. package/status/index.cjs +7 -7
  434. package/status/index.js +35 -52
  435. package/switch/definition.cjs +6 -148
  436. package/switch/definition.js +2 -141
  437. package/switch/index.cjs +8 -8
  438. package/switch/index.js +48 -92
  439. package/tab/definition.cjs +6 -127
  440. package/tab/definition.js +2 -120
  441. package/tab/index.cjs +1 -1
  442. package/tab/index.js +6 -2
  443. package/tab-panel/definition.cjs +5 -29
  444. package/tab-panel/definition.js +1 -22
  445. package/tab-panel/index.cjs +1 -1
  446. package/tab-panel/index.js +5 -2
  447. package/table/definition.cjs +18 -174
  448. package/table/definition.js +3 -158
  449. package/table/index.cjs +19 -10
  450. package/table/index.js +74 -82
  451. package/tabs/definition.cjs +7 -467
  452. package/tabs/definition.js +2 -459
  453. package/tabs/index.cjs +11 -11
  454. package/tabs/index.js +169 -296
  455. package/tag/definition.cjs +6 -176
  456. package/tag/definition.js +2 -169
  457. package/tag/index.cjs +26 -26
  458. package/tag/index.js +64 -125
  459. package/tag-group/definition.cjs +5 -40
  460. package/tag-group/definition.js +1 -33
  461. package/tag-group/index.cjs +4 -4
  462. package/tag-group/index.js +10 -21
  463. package/text-area/definition.cjs +6 -355
  464. package/text-area/definition.js +2 -348
  465. package/text-area/index.cjs +11 -11
  466. package/text-area/index.js +153 -260
  467. package/text-field/definition.cjs +6 -423
  468. package/text-field/definition.js +2 -416
  469. package/text-field/index.cjs +1 -1
  470. package/text-field/index.js +6 -2
  471. package/time-picker/definition.cjs +7 -43
  472. package/time-picker/definition.js +3 -36
  473. package/time-picker/index.cjs +1 -1
  474. package/time-picker/index.js +24 -29
  475. package/toggletip/definition.cjs +6 -159
  476. package/toggletip/definition.js +2 -152
  477. package/toggletip/index.cjs +1 -1
  478. package/toggletip/index.js +6 -2
  479. package/tooltip/definition.cjs +6 -139
  480. package/tooltip/definition.js +2 -132
  481. package/tooltip/index.cjs +1 -1
  482. package/tooltip/index.js +6 -2
  483. package/tree-item/definition.cjs +6 -13
  484. package/tree-item/definition.js +3 -3
  485. package/tree-item/index.cjs +1 -1
  486. package/tree-item/index.js +6 -2
  487. package/tree-view/definition.cjs +6 -302
  488. package/tree-view/definition.js +2 -295
  489. package/tree-view/index.cjs +11 -11
  490. package/tree-view/index.js +145 -174
  491. package/unbundled/affix.cjs +89 -62
  492. package/unbundled/affix.js +58 -55
  493. package/unbundled/anchored.cjs +87 -94
  494. package/unbundled/anchored.js +74 -90
  495. package/unbundled/attribute-binding-behaviour.cjs +37 -42
  496. package/unbundled/attribute-binding-behaviour.js +31 -40
  497. package/unbundled/base-color-picker.cjs +226 -275
  498. package/unbundled/base-color-picker.js +214 -272
  499. package/unbundled/base-progress.cjs +63 -78
  500. package/unbundled/base-progress.js +57 -76
  501. package/unbundled/breadcrumb-item.cjs +24 -28
  502. package/unbundled/breadcrumb-item.js +18 -26
  503. package/unbundled/button.cjs +115 -166
  504. package/unbundled/button.js +109 -164
  505. package/unbundled/calendar-event.cjs +28 -41
  506. package/unbundled/calendar-event.js +22 -39
  507. package/unbundled/calendar-picker.template.cjs +4967 -792
  508. package/unbundled/calendar-picker.template.js +4907 -781
  509. package/unbundled/char-count.cjs +50 -80
  510. package/unbundled/char-count.js +44 -78
  511. package/unbundled/chunk.cjs +28 -0
  512. package/unbundled/data-grid.options.cjs +80 -29
  513. package/unbundled/data-grid.options.js +51 -23
  514. package/unbundled/decorate.cjs +14 -0
  515. package/unbundled/decorate.js +9 -0
  516. package/unbundled/definition.cjs +42 -405
  517. package/unbundled/definition.js +24 -399
  518. package/unbundled/definition10.cjs +253 -0
  519. package/unbundled/definition10.js +229 -0
  520. package/unbundled/definition11.cjs +397 -0
  521. package/unbundled/definition11.js +379 -0
  522. package/unbundled/definition12.cjs +317 -0
  523. package/unbundled/definition12.js +287 -0
  524. package/unbundled/definition13.cjs +321 -0
  525. package/unbundled/definition13.js +303 -0
  526. package/unbundled/definition14.cjs +406 -0
  527. package/unbundled/definition14.js +388 -0
  528. package/unbundled/definition15.cjs +107 -0
  529. package/unbundled/definition15.js +89 -0
  530. package/unbundled/definition16.cjs +63 -0
  531. package/unbundled/definition16.js +45 -0
  532. package/unbundled/definition17.cjs +151 -0
  533. package/unbundled/definition17.js +133 -0
  534. package/unbundled/definition18.cjs +47 -0
  535. package/unbundled/definition18.js +35 -0
  536. package/unbundled/definition19.cjs +98 -0
  537. package/unbundled/definition19.js +80 -0
  538. package/unbundled/definition2.cjs +180 -220
  539. package/unbundled/definition2.js +162 -215
  540. package/unbundled/definition20.cjs +56 -0
  541. package/unbundled/definition20.js +43 -0
  542. package/unbundled/definition21.cjs +304 -0
  543. package/unbundled/definition21.js +285 -0
  544. package/unbundled/definition22.cjs +179 -0
  545. package/unbundled/definition22.js +161 -0
  546. package/unbundled/definition23.cjs +161 -0
  547. package/unbundled/definition23.js +143 -0
  548. package/unbundled/definition24.cjs +157 -0
  549. package/unbundled/definition24.js +139 -0
  550. package/unbundled/definition25.cjs +75 -0
  551. package/unbundled/definition25.js +57 -0
  552. package/unbundled/definition26.cjs +363 -0
  553. package/unbundled/definition26.js +345 -0
  554. package/unbundled/definition27.cjs +137 -0
  555. package/unbundled/definition27.js +119 -0
  556. package/unbundled/definition28.cjs +538 -0
  557. package/unbundled/definition28.js +520 -0
  558. package/unbundled/definition29.cjs +236 -0
  559. package/unbundled/definition29.js +212 -0
  560. package/unbundled/definition3.cjs +131 -284
  561. package/unbundled/definition3.js +113 -279
  562. package/unbundled/definition30.cjs +559 -0
  563. package/unbundled/definition30.js +541 -0
  564. package/unbundled/definition31.cjs +1265 -0
  565. package/unbundled/definition31.js +1247 -0
  566. package/unbundled/definition32.cjs +1908 -0
  567. package/unbundled/definition32.js +1866 -0
  568. package/unbundled/definition33.cjs +346 -0
  569. package/unbundled/definition33.js +256 -0
  570. package/unbundled/definition34.cjs +46 -0
  571. package/unbundled/definition34.js +33 -0
  572. package/unbundled/definition35.cjs +152 -0
  573. package/unbundled/definition35.js +134 -0
  574. package/unbundled/definition36.cjs +426 -0
  575. package/unbundled/definition36.js +408 -0
  576. package/unbundled/definition37.cjs +247 -0
  577. package/unbundled/definition37.js +229 -0
  578. package/unbundled/definition38.cjs +411 -0
  579. package/unbundled/definition38.js +393 -0
  580. package/unbundled/definition39.cjs +299 -0
  581. package/unbundled/definition39.js +281 -0
  582. package/unbundled/definition4.cjs +186 -205
  583. package/unbundled/definition4.js +162 -200
  584. package/unbundled/definition40.cjs +81 -0
  585. package/unbundled/definition40.js +63 -0
  586. package/unbundled/definition41.cjs +100 -0
  587. package/unbundled/definition41.js +82 -0
  588. package/unbundled/definition42.cjs +468 -0
  589. package/unbundled/definition42.js +450 -0
  590. package/unbundled/definition43.cjs +86 -0
  591. package/unbundled/definition43.js +68 -0
  592. package/unbundled/definition44.cjs +60 -0
  593. package/unbundled/definition44.js +41 -0
  594. package/unbundled/definition45.cjs +124 -0
  595. package/unbundled/definition45.js +106 -0
  596. package/unbundled/definition46.cjs +85 -0
  597. package/unbundled/definition46.js +67 -0
  598. package/unbundled/definition47.cjs +52 -0
  599. package/unbundled/definition47.js +31 -0
  600. package/unbundled/definition48.cjs +69 -0
  601. package/unbundled/definition48.js +51 -0
  602. package/unbundled/definition49.cjs +377 -0
  603. package/unbundled/definition49.js +359 -0
  604. package/unbundled/definition5.cjs +69 -298
  605. package/unbundled/definition5.js +44 -293
  606. package/unbundled/definition50.cjs +246 -0
  607. package/unbundled/definition50.js +228 -0
  608. package/unbundled/definition51.cjs +337 -0
  609. package/unbundled/definition51.js +319 -0
  610. package/unbundled/definition52.cjs +86 -0
  611. package/unbundled/definition52.js +67 -0
  612. package/unbundled/definition53.cjs +193 -0
  613. package/unbundled/definition53.js +174 -0
  614. package/unbundled/definition54.cjs +297 -0
  615. package/unbundled/definition54.js +279 -0
  616. package/unbundled/definition55.cjs +510 -0
  617. package/unbundled/definition55.js +492 -0
  618. package/unbundled/definition56.cjs +3659 -0
  619. package/unbundled/definition56.js +3478 -0
  620. package/unbundled/definition57.cjs +837 -0
  621. package/unbundled/definition57.js +819 -0
  622. package/unbundled/definition58.cjs +147 -0
  623. package/unbundled/definition58.js +129 -0
  624. package/unbundled/definition59.cjs +1081 -0
  625. package/unbundled/definition59.js +1063 -0
  626. package/unbundled/definition6.cjs +88 -56
  627. package/unbundled/definition6.js +69 -52
  628. package/unbundled/definition60.cjs +149 -0
  629. package/unbundled/definition60.js +131 -0
  630. package/unbundled/definition61.cjs +116 -0
  631. package/unbundled/definition61.js +97 -0
  632. package/unbundled/definition62.cjs +213 -0
  633. package/unbundled/definition62.js +195 -0
  634. package/unbundled/definition63.cjs +159 -0
  635. package/unbundled/definition63.js +141 -0
  636. package/unbundled/definition64.cjs +86 -0
  637. package/unbundled/definition64.js +68 -0
  638. package/unbundled/definition65.cjs +126 -0
  639. package/unbundled/definition65.js +107 -0
  640. package/unbundled/definition66.cjs +49 -0
  641. package/unbundled/definition66.js +28 -0
  642. package/unbundled/definition67.cjs +119 -0
  643. package/unbundled/definition67.js +101 -0
  644. package/unbundled/definition68.cjs +374 -0
  645. package/unbundled/definition68.js +349 -0
  646. package/unbundled/definition69.cjs +57 -0
  647. package/unbundled/definition69.js +38 -0
  648. package/unbundled/definition7.cjs +190 -0
  649. package/unbundled/definition7.js +166 -0
  650. package/unbundled/definition70.cjs +155 -0
  651. package/unbundled/definition70.js +137 -0
  652. package/unbundled/definition71.cjs +302 -0
  653. package/unbundled/definition71.js +284 -0
  654. package/unbundled/definition72.cjs +48 -0
  655. package/unbundled/definition72.js +37 -0
  656. package/unbundled/definition73.cjs +171 -0
  657. package/unbundled/definition73.js +147 -0
  658. package/unbundled/definition74.cjs +232 -0
  659. package/unbundled/definition74.js +213 -0
  660. package/unbundled/definition75.cjs +533 -0
  661. package/unbundled/definition75.js +513 -0
  662. package/unbundled/definition8.cjs +63 -0
  663. package/unbundled/definition8.js +44 -0
  664. package/unbundled/definition9.cjs +183 -0
  665. package/unbundled/definition9.js +165 -0
  666. package/unbundled/delegates-aria.cjs +90 -131
  667. package/unbundled/delegates-aria.js +77 -127
  668. package/unbundled/dialog.cjs +15 -0
  669. package/unbundled/dialog.js +10 -0
  670. package/unbundled/divider.cjs +42 -50
  671. package/unbundled/divider.js +30 -47
  672. package/unbundled/enums.cjs +166 -107
  673. package/unbundled/enums.js +95 -94
  674. package/unbundled/form-associated.cjs +408 -463
  675. package/unbundled/form-associated.js +396 -460
  676. package/unbundled/form-element.cjs +74 -83
  677. package/unbundled/form-element.js +68 -81
  678. package/unbundled/host-semantics.cjs +70 -89
  679. package/unbundled/host-semantics.js +57 -85
  680. package/unbundled/key-codes.cjs +16 -10
  681. package/unbundled/key-codes.js +5 -7
  682. package/unbundled/linkable.cjs +35 -56
  683. package/unbundled/linkable.js +27 -52
  684. package/unbundled/listbox.cjs +363 -465
  685. package/unbundled/listbox.js +357 -463
  686. package/unbundled/localized.cjs +79 -74
  687. package/unbundled/localized.js +61 -70
  688. package/unbundled/mixins.cjs +222 -223
  689. package/unbundled/mixins.js +186 -211
  690. package/unbundled/picker-field.template.cjs +188 -217
  691. package/unbundled/picker-field.template.js +165 -208
  692. package/unbundled/playbackRates.cjs +18 -11
  693. package/unbundled/playbackRates.js +13 -9
  694. package/unbundled/scrollIntoView.cjs +38 -43
  695. package/unbundled/scrollIntoView.js +33 -41
  696. package/unbundled/single-date-picker.cjs +48 -45
  697. package/unbundled/single-date-picker.js +43 -43
  698. package/unbundled/single-value-picker.cjs +106 -114
  699. package/unbundled/single-value-picker.js +101 -112
  700. package/unbundled/slider.template.cjs +107 -73
  701. package/unbundled/slider.template.js +67 -62
  702. package/unbundled/slottable-request.cjs +145 -3700
  703. package/unbundled/slottable-request.js +98 -3681
  704. package/unbundled/text-field.cjs +9 -5
  705. package/unbundled/text-field.js +4 -3
  706. package/unbundled/time-selection-picker.template.cjs +611 -755
  707. package/unbundled/time-selection-picker.template.js +554 -742
  708. package/unbundled/trapped-focus.cjs +45 -35
  709. package/unbundled/trapped-focus.js +34 -32
  710. package/unbundled/vivid-element.cjs +281 -274
  711. package/unbundled/vivid-element.js +239 -266
  712. package/unbundled/with-contextual-help.cjs +35 -39
  713. package/unbundled/with-contextual-help.js +29 -37
  714. package/unbundled/with-error-text.cjs +45 -55
  715. package/unbundled/with-error-text.js +39 -53
  716. package/unbundled/with-success-text.cjs +18 -22
  717. package/unbundled/with-success-text.js +12 -20
  718. package/video-player/definition.cjs +5 -69835
  719. package/video-player/definition.js +1 -69828
  720. package/video-player/index.cjs +44 -39
  721. package/video-player/index.js +23517 -35507
  722. package/visually-hidden/definition.cjs +5 -30
  723. package/visually-hidden/definition.js +1 -23
  724. package/visually-hidden/index.cjs +1 -1
  725. package/visually-hidden/index.js +5 -2
  726. package/vivid.api.json +331 -1874
  727. package/bundled/index.cjs +0 -1
  728. package/bundled/index.js +0 -6
  729. package/unbundled/_commonjsHelpers.cjs +0 -40
  730. package/unbundled/_commonjsHelpers.js +0 -36
  731. package/unbundled/index.cjs +0 -11
  732. package/unbundled/index.js +0 -9
@@ -1,16 +1,9 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const re=require("../bundled/vivid-element.cjs"),m=require("../bundled/slottable-request.cjs"),Jl=require("../bundled/localized.cjs"),Ui=require("../bundled/ref.cjs"),Tn=require("../bundled/definition9.cjs"),jl=require("../bundled/definition15.cjs"),Qo=require("../bundled/definition19.cjs"),Jr=require("../bundled/definition12.cjs"),es=require("../bundled/definition11.cjs"),ts=require("../bundled/definition6.cjs"),ns=require("../bundled/definition7.cjs"),rs=require("../bundled/definition10.cjs"),is=require("../bundled/definition16.cjs"),ss=require("../bundled/definition3.cjs"),Yl=require("../bundled/divider.cjs"),Xl=require("../bundled/mixins.cjs"),Zl=":host{display:flex;flex-direction:column}.rte{display:flex;flex-direction:column;block-size:100%;min-block-size:0}.editor{display:contents}.editor-viewport{position:relative;display:flex;overflow:hidden;flex:1;flex-direction:column;contain:layout;min-block-size:0}.editor-scroll-area{--editor-padding-inline: var( --rich-text-editor-padding-inline, 16px );--editor-padding-block: var( --rich-text-editor-padding-block, 8px );display:flex;flex:1;flex-direction:column;background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);min-block-size:0;overflow-y:auto;--scrollbar-track-color: transparent;--scrollbar-thumb-color: color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%)}.editor-scroll-area{scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{border:0;border-radius:4px;background-color:var(--scrollbar-fallback-track-color, var(--scrollbar-thumb-color))}.popovers--disabled>*{display:none!important}",ls=65535,as=Math.pow(2,16);function Ql(r,e){return r+e*as}function $i(r){return r&ls}function ea(r){return(r-(r&ls))/as}const cs=1,us=2,gn=4,ds=8;class Nr{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&ds)>0}get deletedBefore(){return(this.delInfo&(cs|gn))>0}get deletedAfter(){return(this.delInfo&(us|gn))>0}get deletedAcross(){return(this.delInfo&gn)>0}}class pe{constructor(e,t=!1){if(this.ranges=e,this.inverted=t,!e.length&&pe.empty)return pe.empty}recover(e){let t=0,n=$i(e);if(!this.inverted)for(let i=0;i<n;i++)t+=this.ranges[i*3+2]-this.ranges[i*3+1];return this.ranges[n*3]+t+ea(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let i=0,o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?i:0);if(a>e)break;let c=this.ranges[l+o],u=this.ranges[l+s],d=a+c;if(e<=d){let f=c?e==a?-1:e==d?1:t:t,h=a+i+(f<0?0:u);if(n)return h;let p=e==(t<0?a:d)?null:Ql(l/3,e-a),b=e==a?us:e==d?cs:gn;return(t<0?e!=a:e!=d)&&(b|=ds),new Nr(h,b,p)}i+=u-c}return n?e+i:new Nr(e+i,0,null)}touches(e,t){let n=0,i=$i(t),o=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;l<this.ranges.length;l+=3){let a=this.ranges[l]-(this.inverted?n:0);if(a>e)break;let c=this.ranges[l+o],u=a+c;if(e<=u&&l==i*3)return!0;n+=this.ranges[l+s]-c}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let i=0,o=0;i<this.ranges.length;i+=3){let s=this.ranges[i],l=s-(this.inverted?o:0),a=s+(this.inverted?0:o),c=this.ranges[i+t],u=this.ranges[i+n];e(l,l+c,a,a+u),o+=u-c}}invert(){return new pe(this.ranges,!this.inverted)}toString(){return(this.inverted?"-":"")+JSON.stringify(this.ranges)}static offset(e){return e==0?pe.empty:new pe(e<0?[0,-e,0]:[0,0,e])}}pe.empty=new pe([]);class Gt{constructor(e,t,n=0,i=e?e.length:0){this.mirror=t,this.from=n,this.to=i,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(e=0,t=this.maps.length){return new Gt(this._maps,this.mirror,e,t)}appendMap(e,t){this.ownData||(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),this.ownData=!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let i=e.getMirror(t);this.appendMap(e._maps[t],i!=null&&i<t?n+i:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||(this.mirror=[]),this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let i=e.getMirror(t);this.appendMap(e._maps[t].invert(),i!=null&&i>t?n-i-1:void 0)}}invert(){let e=new Gt;return e.appendMappingInverted(this),e}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let i=0;for(let o=this.from;o<this.to;o++){let s=this._maps[o],l=s.mapResult(e,t);if(l.recover!=null){let a=this.getMirror(o);if(a!=null&&a>o&&a<this.to){o=a,e=this._maps[a].recover(l.recover);continue}}i|=l.delInfo,e=l.pos}return n?e:new Nr(e,i,null)}}const er=Object.create(null);class ie{getMap(){return pe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw new RangeError("Invalid input for Step.fromJSON");let n=er[t.stepType];if(!n)throw new RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in er)throw new RangeError("Duplicate use of step JSON ID "+e);return er[e]=t,t.prototype.jsonID=e,t}}class z{constructor(e,t){this.doc=e,this.failed=t}static ok(e){return new z(e,null)}static fail(e){return new z(null,e)}static fromReplace(e,t,n,i){try{return z.ok(e.replace(t,n,i))}catch(o){if(o instanceof m.ReplaceError)return z.fail(o.message);throw o}}}function jr(r,e,t){let n=[];for(let i=0;i<r.childCount;i++){let o=r.child(i);o.content.size&&(o=o.copy(jr(o.content,e,o))),o.isInline&&(o=e(o,t,i)),n.push(o)}return m.Fragment.fromArray(n)}class qe extends ie{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),i=n.node(n.sharedDepth(this.to)),o=new m.Slice(jr(t.content,(s,l)=>!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),i),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,o)}invert(){return new be(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new qe(t.pos,n.pos,this.mark)}merge(e){return e instanceof qe&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new qe(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new qe(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("addMark",qe);class be extends ie{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new m.Slice(jr(t.content,i=>i.mark(this.mark.removeFromSet(i.marks)),e),t.openStart,t.openEnd);return z.fromReplace(e,this.from,this.to,n)}invert(){return new qe(this.from,this.to,this.mark)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deleted&&n.deleted||t.pos>=n.pos?null:new be(t.pos,n.pos,this.mark)}merge(e){return e instanceof be&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new be(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new be(t.from,t.to,e.markFromJSON(t.mark))}}ie.jsonID("removeMark",be);class Ke extends ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);if(t){let n=this.mark.addToSet(t.marks);if(n.length==t.marks.length){for(let i=0;i<t.marks.length;i++)if(!t.marks[i].isInSet(n))return new Ke(this.pos,t.marks[i]);return new Ke(this.pos,this.mark)}}return new at(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new Ke(t.pos,this.mark)}toJSON(){return{stepType:"addNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");return new Ke(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("addNodeMark",Ke);class at extends ie{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at mark step's position");let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new Ke(this.pos,this.mark)}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new at(t.pos,this.mark)}toJSON(){return{stepType:"removeNodeMark",pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");return new at(t.pos,e.markFromJSON(t.mark))}}ie.jsonID("removeNodeMark",at);class ee extends ie{constructor(e,t,n,i=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=i}apply(e){return this.structure&&wr(e,this.from,this.to)?z.fail("Structure replace would overwrite content"):z.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pe([this.from,this.to-this.from,this.slice.size])}invert(e){return new ee(this.from,this.from+this.slice.size,e.slice(this.from,this.to))}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1);return t.deletedAcross&&n.deletedAcross?null:new ee(t.pos,Math.max(t.pos,n.pos),this.slice,this.structure)}merge(e){if(!(e instanceof ee)||e.structure||this.structure)return null;if(this.from+this.slice.size==e.from&&!this.slice.openEnd&&!e.slice.openStart){let t=this.slice.size+e.slice.size==0?m.Slice.empty:new m.Slice(this.slice.content.append(e.slice.content),this.slice.openStart,e.slice.openEnd);return new ee(this.from,this.to+(e.to-e.from),t,this.structure)}else if(e.to==this.from&&!this.slice.openStart&&!e.slice.openEnd){let t=this.slice.size+e.slice.size==0?m.Slice.empty:new m.Slice(e.slice.content.append(this.slice.content),e.slice.openStart,this.slice.openEnd);return new ee(e.from,this.to,t,this.structure)}else return null}toJSON(){let e={stepType:"replace",from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number")throw new RangeError("Invalid input for ReplaceStep.fromJSON");return new ee(t.from,t.to,m.Slice.fromJSON(e,t.slice),!!t.structure)}}ie.jsonID("replace",ee);class te extends ie{constructor(e,t,n,i,o,s,l=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=i,this.slice=o,this.insert=s,this.structure=l}apply(e){if(this.structure&&(wr(e,this.from,this.gapFrom)||wr(e,this.gapTo,this.to)))return z.fail("Structure gap-replace would overwrite content");let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return z.fail("Gap is not a flat range");let n=this.slice.insertAt(this.insert,t.content);return n?z.fromReplace(e,this.from,this.to,n):z.fail("Content does not fit in gap")}getMap(){return new pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(e){let t=this.gapTo-this.gapFrom;return new te(this.from,this.from+this.slice.size+t,this.from+this.insert,this.from+this.insert+t,e.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(e){let t=e.mapResult(this.from,1),n=e.mapResult(this.to,-1),i=this.from==this.gapFrom?t.pos:e.map(this.gapFrom,-1),o=this.to==this.gapTo?n.pos:e.map(this.gapTo,1);return t.deletedAcross&&n.deletedAcross||i<t.pos||o>n.pos?null:new te(t.pos,n.pos,i,o,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,t){if(typeof t.from!="number"||typeof t.to!="number"||typeof t.gapFrom!="number"||typeof t.gapTo!="number"||typeof t.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new te(t.from,t.to,t.gapFrom,t.gapTo,m.Slice.fromJSON(e,t.slice),t.insert,!!t.structure)}}ie.jsonID("replaceAround",te);function wr(r,e,t){let n=r.resolve(e),i=t-e,o=n.depth;for(;i>0&&o>0&&n.indexAfter(o)==n.node(o).childCount;)o--,i--;if(i>0){let s=n.node(o).maybeChild(n.indexAfter(o));for(;i>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,i--}}return!1}function ta(r,e,t,n){let i=[],o=[],s,l;r.doc.nodesBetween(e,t,(a,c,u)=>{if(!a.isInline)return;let d=a.marks;if(!n.isInSet(d)&&u.type.allowsMarkType(n.type)){let f=Math.max(c,e),h=Math.min(c+a.nodeSize,t),p=n.addToSet(d);for(let b=0;b<d.length;b++)d[b].isInSet(p)||(s&&s.to==f&&s.mark.eq(d[b])?s.to=h:i.push(s=new be(f,h,d[b])));l&&l.to==f?l.to=h:o.push(l=new qe(f,h,n))}}),i.forEach(a=>r.step(a)),o.forEach(a=>r.step(a))}function na(r,e,t,n){let i=[],o=0;r.doc.nodesBetween(e,t,(s,l)=>{if(!s.isInline)return;o++;let a=null;if(n instanceof m.MarkType){let c=s.marks,u;for(;u=n.isInSet(c);)(a||(a=[])).push(u),c=u.removeFromSet(c)}else n?n.isInSet(s.marks)&&(a=[n]):a=s.marks;if(a&&a.length){let c=Math.min(l+s.nodeSize,t);for(let u=0;u<a.length;u++){let d=a[u],f;for(let h=0;h<i.length;h++){let p=i[h];p.step==o-1&&d.eq(i[h].style)&&(f=p)}f?(f.to=c,f.step=o):i.push({style:d,from:Math.max(l,e),to:c,step:o})}}}),i.forEach(s=>r.step(new be(s.from,s.to,s.style)))}function Yr(r,e,t,n=t.contentMatch,i=!0){let o=r.doc.nodeAt(e),s=[],l=e+1;for(let a=0;a<o.childCount;a++){let c=o.child(a),u=l+c.nodeSize,d=n.matchType(c.type);if(!d)s.push(new ee(l,u,m.Slice.empty));else{n=d;for(let f=0;f<c.marks.length;f++)t.allowsMarkType(c.marks[f].type)||r.step(new be(l,u,c.marks[f]));if(i&&c.isText&&t.whitespace!="pre"){let f,h=/\r?\n|\r/g,p;for(;f=h.exec(c.text);)p||(p=new m.Slice(m.Fragment.from(t.schema.text(" ",t.allowedMarks(c.marks))),0,0)),s.push(new ee(l+f.index,l+f.index+f[0].length,p))}}l=u}if(!n.validEnd){let a=n.fillBefore(m.Fragment.empty,!0);r.replace(l,l,new m.Slice(a,0,0))}for(let a=s.length-1;a>=0;a--)r.step(s[a])}function ra(r,e,t){return(e==0||r.canReplace(e,r.childCount))&&(t==r.childCount||r.canReplace(0,t))}function Xr(r){let t=r.parent.content.cutByIndex(r.startIndex,r.endIndex);for(let n=r.depth,i=0,o=0;;--n){let s=r.$from.node(n),l=r.$from.index(n)+i,a=r.$to.indexAfter(n)-o;if(n<r.depth&&s.canReplace(l,a,t))return n;if(n==0||s.type.spec.isolating||!ra(s,l,a))break;l&&(i=1),a<s.childCount&&(o=1)}return null}function ia(r,e,t){let{$from:n,$to:i,depth:o}=e,s=n.before(o+1),l=i.after(o+1),a=s,c=l,u=m.Fragment.empty,d=0;for(let p=o,b=!1;p>t;p--)b||n.index(p)>0?(b=!0,u=m.Fragment.from(n.node(p).copy(u)),d++):a--;let f=m.Fragment.empty,h=0;for(let p=o,b=!1;p>t;p--)b||i.after(p+1)<i.end(p)?(b=!0,f=m.Fragment.from(i.node(p).copy(f)),h++):c++;r.step(new te(a,c,s,l,new m.Slice(u.append(f),d,h),u.size-d,!0))}function oa(r,e,t){let n=m.Fragment.empty;for(let s=t.length-1;s>=0;s--){if(n.size){let l=t[s].type.contentMatch.matchFragment(n);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}n=m.Fragment.from(t[s].type.create(t[s].attrs,n))}let i=e.start,o=e.end;r.step(new te(i,o,i,o,new m.Slice(n,0,0),t.length,!0))}function sa(r,e,t,n,i){if(!n.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let o=r.steps.length;r.doc.nodesBetween(e,t,(s,l)=>{let a=typeof i=="function"?i(s):i;if(s.isTextblock&&!s.hasMarkup(n,a)&&la(r.doc,r.mapping.slice(o).map(l),n)){let c=null;if(n.schema.linebreakReplacement){let h=n.whitespace=="pre",p=!!n.contentMatch.matchType(n.schema.linebreakReplacement);h&&!p?c=!1:!h&&p&&(c=!0)}c===!1&&hs(r,s,l,o),Yr(r,r.mapping.slice(o).map(l,1),n,void 0,c===null);let u=r.mapping.slice(o),d=u.map(l,1),f=u.map(l+s.nodeSize,1);return r.step(new te(d,f,d+1,f-1,new m.Slice(m.Fragment.from(n.create(a,null,s.marks)),0,0),1,!0)),c===!0&&fs(r,s,l,o),!1}})}function fs(r,e,t,n){e.forEach((i,o)=>{if(i.isText){let s,l=/\r?\n|\r/g;for(;s=l.exec(i.text);){let a=r.mapping.slice(n).map(t+1+o+s.index);r.replaceWith(a,a+1,e.type.schema.linebreakReplacement.create())}}})}function hs(r,e,t,n){e.forEach((i,o)=>{if(i.type==i.type.schema.linebreakReplacement){let s=r.mapping.slice(n).map(t+1+o);r.replaceWith(s,s+1,e.type.schema.text(`
2
- `))}})}function la(r,e,t){let n=r.resolve(e),i=n.index();return n.parent.canReplaceWith(i,i+1,t)}function aa(r,e,t,n,i){let o=r.doc.nodeAt(e);if(!o)throw new RangeError("No node at given position");t||(t=o.type);let s=t.create(n,null,i||o.marks);if(o.isLeaf)return r.replaceWith(e,e+o.nodeSize,s);if(!t.validContent(o.content))throw new RangeError("Invalid content for node type "+t.name);r.step(new te(e,e+o.nodeSize,e+1,e+o.nodeSize-1,new m.Slice(m.Fragment.from(s),0,0),1,!0))}function bn(r,e,t=1,n){let i=r.resolve(e),o=i.depth-t,s=n&&n[n.length-1]||i.parent;if(o<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!s.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let c=i.depth-1,u=t-2;c>o;c--,u--){let d=i.node(c),f=i.index(c);if(d.type.spec.isolating)return!1;let h=d.content.cutByIndex(f,d.childCount),p=n&&n[u+1];p&&(h=h.replaceChild(0,p.type.create(p.attrs)));let b=n&&n[u]||d;if(!d.canReplace(f+1,d.childCount)||!b.type.validContent(h))return!1}let l=i.indexAfter(o),a=n&&n[0];return i.node(o).canReplaceWith(l,l,a?a.type:i.node(o+1).type)}function ca(r,e,t=1,n){let i=r.doc.resolve(e),o=m.Fragment.empty,s=m.Fragment.empty;for(let l=i.depth,a=i.depth-t,c=t-1;l>a;l--,c--){o=m.Fragment.from(i.node(l).copy(o));let u=n&&n[c];s=m.Fragment.from(u?u.type.create(u.attrs,s):i.node(l).copy(s))}r.step(new ee(e,e,new m.Slice(o.append(s),t,t),!0))}function Zr(r,e){let t=r.resolve(e),n=t.index();return da(t.nodeBefore,t.nodeAfter)&&t.parent.canReplace(n,n+1)}function ua(r,e){e.content.size||r.type.compatibleContent(e.type);let t=r.contentMatchAt(r.childCount),{linebreakReplacement:n}=r.type.schema;for(let i=0;i<e.childCount;i++){let o=e.child(i),s=o.type==n?r.type.schema.nodes.text:o.type;if(t=t.matchType(s),!t||!r.type.allowsMarks(o.marks))return!1}return t.validEnd}function da(r,e){return!!(r&&e&&!r.isLeaf&&ua(r,e))}function fa(r,e,t){let n=null,{linebreakReplacement:i}=r.doc.type.schema,o=r.doc.resolve(e-t),s=o.node().type;if(i&&s.inlineContent){let u=s.whitespace=="pre",d=!!s.contentMatch.matchType(i);u&&!d?n=!1:!u&&d&&(n=!0)}let l=r.steps.length;if(n===!1){let u=r.doc.resolve(e+t);hs(r,u.node(),u.before(),l)}s.inlineContent&&Yr(r,e+t-1,s,o.node().contentMatchAt(o.index()),n==null);let a=r.mapping.slice(l),c=a.map(e-t);if(r.step(new ee(c,a.map(e+t,-1),m.Slice.empty,!0)),n===!0){let u=r.doc.resolve(c);fs(r,u.node(),u.before(),r.steps.length)}return r}function ha(r,e,t){let n=r.resolve(e);if(n.parent.canReplaceWith(n.index(),n.index(),t))return e;if(n.parentOffset==0)for(let i=n.depth-1;i>=0;i--){let o=n.index(i);if(n.node(i).canReplaceWith(o,o,t))return n.before(i+1);if(o>0)return null}if(n.parentOffset==n.parent.content.size)for(let i=n.depth-1;i>=0;i--){let o=n.indexAfter(i);if(n.node(i).canReplaceWith(o,o,t))return n.after(i+1);if(o<n.node(i).childCount)return null}return null}function Qr(r,e,t){let n=r.resolve(e);if(!t.content.size)return e;let i=t.content;for(let o=0;o<t.openStart;o++)i=i.firstChild.content;for(let o=1;o<=(t.openStart==0&&t.size?2:1);o++)for(let s=n.depth;s>=0;s--){let l=s==n.depth?0:n.pos<=(n.start(s+1)+n.end(s+1))/2?-1:1,a=n.index(s)+(l>0?1:0),c=n.node(s),u=!1;if(o==1)u=c.canReplace(a,a,i);else{let d=c.contentMatchAt(a).findWrapping(i.firstChild.type);u=d&&c.canReplaceWith(a,a,d[0])}if(u)return l==0?n.pos:l<0?n.before(s+1):n.after(s+1)}return null}function ei(r,e,t=e,n=m.Slice.empty){if(e==t&&!n.size)return null;let i=r.resolve(e),o=r.resolve(t);return ps(i,o,n)?new ee(e,t,n):new pa(i,o,n).fit()}function ps(r,e,t){return!t.openStart&&!t.openEnd&&r.start()==e.start()&&r.parent.canReplace(r.index(),e.index(),t.content)}class pa{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=m.Fragment.empty;for(let i=0;i<=e.depth;i++){let o=e.node(i);this.frontier.push({type:o.type,match:o.contentMatchAt(e.indexAfter(i))})}for(let i=e.depth;i>0;i--)this.placed=m.Fragment.from(e.node(i).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let c=this.findFittable();c?this.placeNodes(c):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,i=this.close(e<0?this.$to:n.doc.resolve(e));if(!i)return null;let o=this.placed,s=n.depth,l=i.depth;for(;s&&l&&o.childCount==1;)o=o.firstChild.content,s--,l--;let a=new m.Slice(o,s,l);return e>-1?new te(n.pos,e,this.$to.pos,this.$to.end(),a,t):a.size||n.pos!=this.$to.pos?new ee(n.pos,i.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,i=this.unplaced.openEnd;n<e;n++){let o=t.firstChild;if(t.childCount>1&&(i=0),o.type.spec.isolating&&i<=n){e=n;break}t=o.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let i,o=null;n?(o=tr(this.unplaced.content,n-1).firstChild,i=o.content):i=this.unplaced.content;let s=i.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:c}=this.frontier[l],u,d=null;if(t==1&&(s?c.matchType(s.type)||(d=c.fillBefore(m.Fragment.from(s),!1)):o&&a.compatibleContent(o.type)))return{sliceDepth:n,frontierDepth:l,parent:o,inject:d};if(t==2&&s&&(u=c.findWrapping(s.type)))return{sliceDepth:n,frontierDepth:l,parent:o,wrap:u};if(o&&c.matchType(o.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=tr(e,t);return!i.childCount||i.firstChild.isLeaf?!1:(this.unplaced=new m.Slice(e,t+1,Math.max(n,i.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,i=tr(e,t);if(i.childCount<=1&&t>0){let o=e.size-t<=t+i.size;this.unplaced=new m.Slice(Vt(e,t-1,1),t-1,o?t-1:n)}else this.unplaced=new m.Slice(Vt(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:i,wrap:o}){for(;this.depth>t;)this.closeFrontierNode();if(o)for(let b=0;b<o.length;b++)this.openFrontierNode(o[b]);let s=this.unplaced,l=n?n.content:s.content,a=s.openStart-e,c=0,u=[],{match:d,type:f}=this.frontier[t];if(i){for(let b=0;b<i.childCount;b++)u.push(i.child(b));d=d.matchFragment(i)}let h=l.size+e-(s.content.size-s.openEnd);for(;c<l.childCount;){let b=l.child(c),y=d.matchType(b.type);if(!y)break;c++,(c>1||a==0||b.content.size)&&(d=y,u.push(ms(b.mark(f.allowedMarks(b.marks)),c==1?a:0,c==l.childCount?h:-1)))}let p=c==l.childCount;p||(h=-1),this.placed=Ht(this.placed,t,m.Fragment.from(u)),this.frontier[t].match=d,p&&h<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let b=0,y=l;b<h;b++){let k=y.lastChild;this.frontier.push({type:k.type,match:k.contentMatchAt(k.childCount)}),y=k.content}this.unplaced=p?e==0?m.Slice.empty:new m.Slice(Vt(s.content,e-1,1),e-1,h<0?s.openEnd:e-1):new m.Slice(Vt(s.content,e,c),s.openStart,s.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!nr(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,i=this.$to.after(n);for(;n>1&&i==this.$to.end(--n);)++i;return i}findCloseLevel(e){e:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:i}=this.frontier[t],o=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),s=nr(e,t,i,n,o);if(s){for(let l=t-1;l>=0;l--){let{match:a,type:c}=this.frontier[l],u=nr(e,l,c,a,!0);if(!u||u.childCount)continue e}return{depth:t,fit:s,move:o?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ht(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let i=e.node(n),o=i.type.contentMatch.fillBefore(i.content,!0,e.index(n));this.openFrontierNode(i.type,i.attrs,o)}return e}openFrontierNode(e,t=null,n){let i=this.frontier[this.depth];i.match=i.match.matchType(e),this.placed=Ht(this.placed,this.depth,m.Fragment.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let t=this.frontier.pop().match.fillBefore(m.Fragment.empty,!0);t.childCount&&(this.placed=Ht(this.placed,this.frontier.length,t))}}function Vt(r,e,t){return e==0?r.cutByIndex(t,r.childCount):r.replaceChild(0,r.firstChild.copy(Vt(r.firstChild.content,e-1,t)))}function Ht(r,e,t){return e==0?r.append(t):r.replaceChild(r.childCount-1,r.lastChild.copy(Ht(r.lastChild.content,e-1,t)))}function tr(r,e){for(let t=0;t<e;t++)r=r.firstChild.content;return r}function ms(r,e,t){if(e<=0)return r;let n=r.content;return e>1&&(n=n.replaceChild(0,ms(n.firstChild,e-1,n.childCount==1?t-1:0))),e>0&&(n=r.type.contentMatch.fillBefore(n).append(n),t<=0&&(n=n.append(r.type.contentMatch.matchFragment(n).fillBefore(m.Fragment.empty,!0)))),r.copy(n)}function nr(r,e,t,n,i){let o=r.node(e),s=i?r.indexAfter(e):r.index(e);if(s==o.childCount&&!t.compatibleContent(o.type))return null;let l=n.fillBefore(o.content,!0,s);return l&&!ma(t,o.content,s)?l:null}function ma(r,e,t){for(let n=t;n<e.childCount;n++)if(!r.allowsMarks(e.child(n).marks))return!0;return!1}function ga(r){return r.spec.defining||r.spec.definingForContent}function ba(r,e,t,n){if(!n.size)return r.deleteRange(e,t);let i=r.doc.resolve(e),o=r.doc.resolve(t);if(ps(i,o,n))return r.step(new ee(e,t,n));let s=bs(i,o);s[s.length-1]==0&&s.pop();let l=-(i.depth+1);s.unshift(l);for(let f=i.depth,h=i.pos-1;f>0;f--,h--){let p=i.node(f).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(f)>-1?l=f:i.before(f)==h&&s.splice(1,0,-f)}let a=s.indexOf(l),c=[],u=n.openStart;for(let f=n.content,h=0;;h++){let p=f.firstChild;if(c.push(p),h==n.openStart)break;f=p.content}for(let f=u-1;f>=0;f--){let h=c[f],p=ga(h.type);if(p&&!h.sameMarkup(i.node(Math.abs(l)-1)))u=f;else if(p||!h.type.isTextblock)break}for(let f=n.openStart;f>=0;f--){let h=(f+u+1)%(n.openStart+1),p=c[h];if(p)for(let b=0;b<s.length;b++){let y=s[(b+a)%s.length],k=!0;y<0&&(k=!1,y=-y);let R=i.node(y-1),N=i.index(y-1);if(R.canReplaceWith(N,N,p.type,p.marks))return r.replace(i.before(y),k?o.after(y):t,new m.Slice(gs(n.content,0,n.openStart,h),h,n.openEnd))}}let d=r.steps.length;for(let f=s.length-1;f>=0&&(r.replace(e,t,n),!(r.steps.length>d));f--){let h=s[f];h<0||(e=i.before(h),t=o.after(h))}}function gs(r,e,t,n,i){if(e<t){let o=r.firstChild;r=r.replaceChild(0,o.copy(gs(o.content,e+1,t,n,o)))}if(e>n){let o=i.contentMatchAt(0),s=o.fillBefore(r).append(r);r=s.append(o.matchFragment(s).fillBefore(m.Fragment.empty,!0))}return r}function ya(r,e,t,n){if(!n.isInline&&e==t&&r.doc.resolve(e).parent.content.size){let i=ha(r.doc,e,n.type);i!=null&&(e=t=i)}r.replaceRange(e,t,new m.Slice(m.Fragment.from(n),0,0))}function Sa(r,e,t){let n=r.doc.resolve(e),i=r.doc.resolve(t),o=bs(n,i);for(let s=0;s<o.length;s++){let l=o[s],a=s==o.length-1;if(a&&l==0||n.node(l).type.contentMatch.validEnd)return r.delete(n.start(l),i.end(l));if(l>0&&(a||n.node(l-1).canReplace(n.index(l-1),i.indexAfter(l-1))))return r.delete(n.before(l),i.after(l))}for(let s=1;s<=n.depth&&s<=i.depth;s++)if(e-n.start(s)==n.depth-s&&t>n.end(s)&&i.end(s)-t!=i.depth-s&&n.start(s-1)==i.start(s-1)&&n.node(s-1).canReplace(n.index(s-1),i.index(s-1)))return r.delete(n.before(s),t);r.delete(e,t)}function bs(r,e){let t=[],n=Math.min(r.depth,e.depth);for(let i=n;i>=0;i--){let o=r.start(i);if(o<r.pos-(r.depth-i)||e.end(i)>e.pos+(e.depth-i)||r.node(i).type.spec.isolating||e.node(i).type.spec.isolating)break;(o==e.start(i)||i==r.depth&&i==e.depth&&r.parent.inlineContent&&e.parent.inlineContent&&i&&e.start(i-1)==o-1)&&t.push(i)}return t}class xt extends ie{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return z.fail("No node at attribute step's position");let n=Object.create(null);for(let o in t.attrs)n[o]=t.attrs[o];n[this.attr]=this.value;let i=t.type.create(n,null,t.marks);return z.fromReplace(e,this.pos,this.pos+1,new m.Slice(m.Fragment.from(i),0,t.isLeaf?0:1))}getMap(){return pe.empty}invert(e){return new xt(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let t=e.mapResult(this.pos,1);return t.deletedAfter?null:new xt(t.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.pos!="number"||typeof t.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new xt(t.pos,t.attr,t.value)}}ie.jsonID("attr",xt);class Jt extends ie{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let i in e.attrs)t[i]=e.attrs[i];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return z.ok(n)}getMap(){return pe.empty}invert(e){return new Jt(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,t){if(typeof t.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Jt(t.attr,t.value)}}ie.jsonID("docAttr",Jt);let Et=class extends Error{};Et=function r(e){let t=Error.call(this,e);return t.__proto__=r.prototype,t};Et.prototype=Object.create(Error.prototype);Et.prototype.constructor=Et;Et.prototype.name="TransformError";class ka{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new Gt}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new Et(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let i=this.mapping.maps[n];n&&(e=i.map(e,1),t=i.map(t,-1)),i.forEach((o,s,l,a)=>{e=Math.min(e,l),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=m.Slice.empty){let i=ei(this.doc,e,t,n);return i&&this.step(i),this}replaceWith(e,t,n){return this.replace(e,t,new m.Slice(m.Fragment.from(n),0,0))}delete(e,t){return this.replace(e,t,m.Slice.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return ba(this,e,t,n),this}replaceRangeWith(e,t,n){return ya(this,e,t,n),this}deleteRange(e,t){return Sa(this,e,t),this}lift(e,t){return ia(this,e,t),this}join(e,t=1){return fa(this,e,t),this}wrap(e,t){return oa(this,e,t),this}setBlockType(e,t=e,n,i=null){return sa(this,e,t,n,i),this}setNodeMarkup(e,t,n=null,i){return aa(this,e,t,n,i),this}setNodeAttribute(e,t,n){return this.step(new xt(e,t,n)),this}setDocAttribute(e,t){return this.step(new Jt(e,t)),this}addNodeMark(e,t){return this.step(new Ke(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw new RangeError("No node at position "+e);if(t instanceof m.Mark)t.isInSet(n.marks)&&this.step(new at(e,t));else{let i=n.marks,o,s=[];for(;o=t.isInSet(i);)s.push(new at(e,o)),i=o.removeFromSet(i);for(let l=s.length-1;l>=0;l--)this.step(s[l])}return this}split(e,t=1,n){return ca(this,e,t,n),this}addMark(e,t,n){return ta(this,e,t,n),this}removeMark(e,t,n){return na(this,e,t,n),this}clearIncompatible(e,t,n){return Yr(this,e,t,n),this}}const rr=Object.create(null);class D{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new Ta(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=m.Slice.empty){let n=t.content.lastChild,i=null;for(let l=0;l<t.openEnd;l++)i=n,n=n.lastChild;let o=e.steps.length,s=this.ranges;for(let l=0;l<s.length;l++){let{$from:a,$to:c}=s[l],u=e.mapping.slice(o);e.replaceRange(u.map(a.pos),u.map(c.pos),l?m.Slice.empty:t),l==0&&Gi(e,o,(n?n.isInline:i&&i.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,i=this.ranges;for(let o=0;o<i.length;o++){let{$from:s,$to:l}=i[o],a=e.mapping.slice(n),c=a.map(s.pos),u=a.map(l.pos);o?e.deleteRange(c,u):(e.replaceRangeWith(c,u,t),Gi(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let i=e.parent.inlineContent?new O(e):Tt(e.node(0),e.parent,e.pos,e.index(),t,n);if(i)return i;for(let o=e.depth-1;o>=0;o--){let s=t<0?Tt(e.node(0),e.node(o),e.before(o+1),e.index(o),t,n):Tt(e.node(0),e.node(o),e.after(o+1),e.index(o)+1,t,n);if(s)return s}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new j(e.node(0))}static atStart(e){return Tt(e,e,0,0,1)||new j(e)}static atEnd(e){return Tt(e,e,e.content.size,e.childCount,-1)||new j(e)}static fromJSON(e,t){if(!t||!t.type)throw new RangeError("Invalid input for Selection.fromJSON");let n=rr[t.type];if(!n)throw new RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rr)throw new RangeError("Duplicate use of selection JSON ID "+e);return rr[e]=t,t.prototype.jsonID=e,t}getBookmark(){return O.between(this.$anchor,this.$head).getBookmark()}}D.prototype.visible=!0;class Ta{constructor(e,t){this.$from=e,this.$to=t}}let qi=!1;function Ki(r){!qi&&!r.parent.inlineContent&&(qi=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+r.parent.type.name+")"))}class O extends D{constructor(e,t=e){Ki(e),Ki(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,t){let n=e.resolve(t.map(this.head));if(!n.parent.inlineContent)return D.near(n);let i=e.resolve(t.map(this.anchor));return new O(i.parent.inlineContent?i:n,n)}replace(e,t=m.Slice.empty){if(super.replace(e,t),t==m.Slice.empty){let n=this.$from.marksAcross(this.$to);n&&e.ensureMarks(n)}}eq(e){return e instanceof O&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new An(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,t){if(typeof t.anchor!="number"||typeof t.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new O(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,n=t){let i=e.resolve(t);return new this(i,n==t?i:e.resolve(n))}static between(e,t,n){let i=e.pos-t.pos;if((!n||i)&&(n=i>=0?1:-1),!t.parent.inlineContent){let o=D.findFrom(t,n,!0)||D.findFrom(t,-n,!0);if(o)t=o.$head;else return D.near(t,n)}return e.parent.inlineContent||(i==0?e=t:(e=(D.findFrom(e,-n,!0)||D.findFrom(e,n,!0)).$anchor,e.pos<t.pos!=i<0&&(e=t))),new O(e,t)}}D.jsonID("text",O);class An{constructor(e,t){this.anchor=e,this.head=t}map(e){return new An(e.map(this.anchor),e.map(this.head))}resolve(e){return O.between(e.resolve(this.anchor),e.resolve(this.head))}}class M extends D{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(e,t){let{deleted:n,pos:i}=t.mapResult(this.anchor),o=e.resolve(i);return n?D.near(o):new M(o)}content(){return new m.Slice(m.Fragment.from(this.node),0,0)}eq(e){return e instanceof M&&e.anchor==this.anchor}toJSON(){return{type:"node",anchor:this.anchor}}getBookmark(){return new ti(this.anchor)}static fromJSON(e,t){if(typeof t.anchor!="number")throw new RangeError("Invalid input for NodeSelection.fromJSON");return new M(e.resolve(t.anchor))}static create(e,t){return new M(e.resolve(t))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}}M.prototype.visible=!1;D.jsonID("node",M);class ti{constructor(e){this.anchor=e}map(e){let{deleted:t,pos:n}=e.mapResult(this.anchor);return t?new An(n,n):new ti(n)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&M.isSelectable(n)?new M(t):D.near(t)}}class j extends D{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=m.Slice.empty){if(t==m.Slice.empty){e.delete(0,e.doc.content.size);let n=D.atStart(e.doc);n.eq(e.selection)||e.setSelection(n)}else super.replace(e,t)}toJSON(){return{type:"all"}}static fromJSON(e){return new j(e)}map(e){return new j(e)}eq(e){return e instanceof j}getBookmark(){return Ca}}D.jsonID("all",j);const Ca={map(){return this},resolve(r){return new j(r)}};function Tt(r,e,t,n,i,o=!1){if(e.inlineContent)return O.create(r,t);for(let s=n-(i>0?0:1);i>0?s<e.childCount:s>=0;s+=i){let l=e.child(s);if(l.isAtom){if(!o&&M.isSelectable(l))return M.create(r,t-(i<0?l.nodeSize:0))}else{let a=Tt(r,l,t+i,i<0?l.childCount:0,i,o);if(a)return a}t+=l.nodeSize*i}return null}function Gi(r,e,t){let n=r.steps.length-1;if(n<e)return;let i=r.steps[n];if(!(i instanceof ee||i instanceof te))return;let o=r.mapping.maps[n],s;o.forEach((l,a,c,u)=>{s==null&&(s=u)}),r.setSelection(D.near(r.doc.resolve(s),t))}const Ji=1,dn=2,ji=4;class Ma extends ka{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw new RangeError("Selection passed to setSelection must point at the current document");return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|Ji)&~dn,this.storedMarks=null,this}get selectionSet(){return(this.updated&Ji)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=dn,this}ensureMarks(e){return m.Mark.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&dn)>0}addStep(e,t){super.addStep(e,t),this.updated=this.updated&~dn,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||m.Mark.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let i=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(i.text(e),!0):this.deleteSelection();{if(n==null&&(n=t),!e)return this.deleteRange(t,n);let o=this.storedMarks;if(!o){let s=this.doc.resolve(t);o=n==t?s.marks():s.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,i.text(e,o)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(D.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e=="string"?e:e.key]=t,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=ji,this}get scrolledIntoView(){return(this.updated&ji)>0}}function Yi(r,e){return!e||!r?r:r.bind(e)}class Wt{constructor(e,t,n){this.name=e,this.init=Yi(t.init,n),this.apply=Yi(t.apply,n)}}const xa=[new Wt("doc",{init(r){return r.doc||r.schema.topNodeType.createAndFill()},apply(r){return r.doc}}),new Wt("selection",{init(r,e){return r.selection||D.atStart(e.doc)},apply(r){return r.selection}}),new Wt("storedMarks",{init(r){return r.storedMarks||null},apply(r,e,t,n){return n.selection.$cursor?r.storedMarks:null}}),new Wt("scrollToSelection",{init(){return 0},apply(r,e){return r.scrolledIntoView?e+1:e}})];class ir{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=xa.slice(),t&&t.forEach(n=>{if(this.pluginsByKey[n.key])throw new RangeError("Adding different instances of a keyed plugin ("+n.key+")");this.plugins.push(n),this.pluginsByKey[n.key]=n,n.spec.state&&this.fields.push(new Wt(n.key,n.spec.state,n))})}}class Mt{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let i=this.config.plugins[n];if(i.spec.filterTransaction&&!i.spec.filterTransaction.call(i,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),i=null;for(;;){let o=!1;for(let s=0;s<this.config.plugins.length;s++){let l=this.config.plugins[s];if(l.spec.appendTransaction){let a=i?i[s].n:0,c=i?i[s].state:this,u=a<t.length&&l.spec.appendTransaction.call(l,a?t.slice(a):t,c,n);if(u&&n.filterTransaction(u,s)){if(u.setMeta("appendedTransaction",e),!i){i=[];for(let d=0;d<this.config.plugins.length;d++)i.push(d<s?{state:n,n:t.length}:{state:this,n:0})}t.push(u),n=n.applyInner(u),o=!0}i&&(i[s]={state:n,n:t.length})}}if(!o)return{state:n,transactions:t}}}applyInner(e){if(!e.before.eq(this.doc))throw new RangeError("Applying a mismatched transaction");let t=new Mt(this.config),n=this.config.fields;for(let i=0;i<n.length;i++){let o=n[i];t[o.name]=o.apply(e,this[o.name],this,t)}return t}get tr(){return new Ma(this)}static create(e){let t=new ir(e.doc?e.doc.type.schema:e.schema,e.plugins),n=new Mt(t);for(let i=0;i<t.fields.length;i++)n[t.fields[i].name]=t.fields[i].init(e,n);return n}reconfigure(e){let t=new ir(this.schema,e.plugins),n=t.fields,i=new Mt(t);for(let o=0;o<n.length;o++){let s=n[o].name;i[s]=this.hasOwnProperty(s)?this[s]:n[o].init(e,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(n=>n.toJSON())),e&&typeof e=="object")for(let n in e){if(n=="doc"||n=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let i=e[n],o=i.spec.state;o&&o.toJSON&&(t[n]=o.toJSON.call(i,this[i.key]))}return t}static fromJSON(e,t,n){if(!t)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let i=new ir(e.schema,e.plugins),o=new Mt(i);return i.fields.forEach(s=>{if(s.name=="doc")o.doc=m.Node.fromJSON(e.schema,t.doc);else if(s.name=="selection")o.selection=D.fromJSON(o.doc,t.selection);else if(s.name=="storedMarks")t.storedMarks&&(o.storedMarks=t.storedMarks.map(e.schema.markFromJSON));else{if(n)for(let l in n){let a=n[l],c=a.spec.state;if(a.key==s.name&&c&&c.fromJSON&&Object.prototype.hasOwnProperty.call(t,l)){o[s.name]=c.fromJSON.call(a,e,t[l],o);return}}o[s.name]=s.init(e,o)}}),o}}function ys(r,e,t){for(let n in r){let i=r[n];i instanceof Function?i=i.bind(e):n=="handleDOMEvents"&&(i=ys(i,e,{})),t[n]=i}return t}class B{constructor(e){this.spec=e,this.props={},e.props&&ys(e.props,this,this.props),this.key=e.key?e.key.key:Ss("plugin")}getState(e){return e[this.key]}}const or=Object.create(null);function Ss(r){return r in or?r+"$"+ ++or[r]:(or[r]=0,r+"$")}class ni{constructor(e="key"){this.key=Ss(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}const K=function(r){for(var e=0;;e++)if(r=r.previousSibling,!r)return e},Dt=function(r){let e=r.assignedSlot||r.parentNode;return e&&e.nodeType==11?e.host:e};let Ar=null;const Pe=function(r,e,t){let n=Ar||(Ar=document.createRange());return n.setEnd(r,t??r.nodeValue.length),n.setStart(r,e||0),n},Oa=function(){Ar=null},ct=function(r,e,t,n){return t&&(Xi(r,e,t,n,-1)||Xi(r,e,t,n,1))},Ea=/^(img|br|input|textarea|hr)$/i;function Xi(r,e,t,n,i){for(var o;;){if(r==t&&e==n)return!0;if(e==(i<0?0:ge(r))){let s=r.parentNode;if(!s||s.nodeType!=1||Zt(r)||Ea.test(r.nodeName)||r.contentEditable=="false")return!1;e=K(r)+(i<0?0:1),r=s}else if(r.nodeType==1){let s=r.childNodes[e+(i<0?-1:0)];if(s.nodeType==1&&s.contentEditable=="false")if(!((o=s.pmViewDesc)===null||o===void 0)&&o.ignoreForSelection)e+=i;else return!1;else r=s,e=i<0?ge(r):0}else return!1}}function ge(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function Da(r,e){for(;;){if(r.nodeType==3&&e)return r;if(r.nodeType==1&&e>0){if(r.contentEditable=="false")return null;r=r.childNodes[e-1],e=ge(r)}else if(r.parentNode&&!Zt(r))e=K(r),r=r.parentNode;else return null}}function Na(r,e){for(;;){if(r.nodeType==3&&e<r.nodeValue.length)return r;if(r.nodeType==1&&e<r.childNodes.length){if(r.contentEditable=="false")return null;r=r.childNodes[e],e=0}else if(r.parentNode&&!Zt(r))e=K(r)+1,r=r.parentNode;else return null}}function wa(r,e,t){for(let n=e==0,i=e==ge(r);n||i;){if(r==t)return!0;let o=K(r);if(r=r.parentNode,!r)return!1;n=n&&o==0,i=i&&o==ge(r)}}function Zt(r){let e;for(let t=r;t&&!(e=t.pmViewDesc);t=t.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==r||e.contentDOM==r)}const vn=function(r){return r.focusNode&&ct(r.focusNode,r.focusOffset,r.anchorNode,r.anchorOffset)};function nt(r,e){let t=document.createEvent("Event");return t.initEvent("keydown",!0,!0),t.keyCode=r,t.key=t.code=e,t}function Aa(r){let e=r.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function va(r,e,t){if(r.caretPositionFromPoint)try{let n=r.caretPositionFromPoint(e,t);if(n)return{node:n.offsetNode,offset:Math.min(ge(n.offsetNode),n.offset)}}catch{}if(r.caretRangeFromPoint){let n=r.caretRangeFromPoint(e,t);if(n)return{node:n.startContainer,offset:Math.min(ge(n.startContainer),n.startOffset)}}}const we=typeof navigator<"u"?navigator:null,Zi=typeof document<"u"?document:null,Ze=we&&we.userAgent||"",vr=/Edge\/(\d+)/.exec(Ze),ks=/MSIE \d/.exec(Ze),Rr=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ze),fe=!!(ks||Rr||vr),Je=ks?document.documentMode:Rr?+Rr[1]:vr?+vr[1]:0,ye=!fe&&/gecko\/(\d+)/i.test(Ze);ye&&+(/Firefox\/(\d+)/.exec(Ze)||[0,0])[1];const Ir=!fe&&/Chrome\/(\d+)/.exec(Ze),J=!!Ir,Ts=Ir?+Ir[1]:0,ne=!fe&&!!we&&/Apple Computer/.test(we.vendor),Nt=ne&&(/Mobile\/\w+/.test(Ze)||!!we&&we.maxTouchPoints>2),me=Nt||(we?/Mac/.test(we.platform):!1),Cs=we?/Win/.test(we.platform):!1,ze=/Android \d/.test(Ze),Qt=!!Zi&&"webkitFontSmoothing"in Zi.documentElement.style,Ra=Qt?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function Ia(r){let e=r.defaultView&&r.defaultView.visualViewport;return e?{left:0,right:e.width,top:0,bottom:e.height}:{left:0,right:r.documentElement.clientWidth,top:0,bottom:r.documentElement.clientHeight}}function Fe(r,e){return typeof r=="number"?r:r[e]}function Fa(r){let e=r.getBoundingClientRect(),t=e.width/r.offsetWidth||1,n=e.height/r.offsetHeight||1;return{left:e.left,right:e.left+r.clientWidth*t,top:e.top,bottom:e.top+r.clientHeight*n}}function Qi(r,e,t){let n=r.someProp("scrollThreshold")||0,i=r.someProp("scrollMargin")||5,o=r.dom.ownerDocument;for(let s=t||r.dom;s;){if(s.nodeType!=1){s=Dt(s);continue}let l=s,a=l==o.body,c=a?Ia(o):Fa(l),u=0,d=0;if(e.top<c.top+Fe(n,"top")?d=-(c.top-e.top+Fe(i,"top")):e.bottom>c.bottom-Fe(n,"bottom")&&(d=e.bottom-e.top>c.bottom-c.top?e.top+Fe(i,"top")-c.top:e.bottom-c.bottom+Fe(i,"bottom")),e.left<c.left+Fe(n,"left")?u=-(c.left-e.left+Fe(i,"left")):e.right>c.right-Fe(n,"right")&&(u=e.right-c.right+Fe(i,"right")),u||d)if(a)o.defaultView.scrollBy(u,d);else{let h=l.scrollLeft,p=l.scrollTop;d&&(l.scrollTop+=d),u&&(l.scrollLeft+=u);let b=l.scrollLeft-h,y=l.scrollTop-p;e={left:e.left-b,top:e.top-y,right:e.right-b,bottom:e.bottom-y}}let f=a?"fixed":getComputedStyle(s).position;if(/^(fixed|sticky)$/.test(f))break;s=f=="absolute"?s.offsetParent:Dt(s)}}function Pa(r){let e=r.dom.getBoundingClientRect(),t=Math.max(0,e.top),n,i;for(let o=(e.left+e.right)/2,s=t+1;s<Math.min(innerHeight,e.bottom);s+=5){let l=r.root.elementFromPoint(o,s);if(!l||l==r.dom||!r.dom.contains(l))continue;let a=l.getBoundingClientRect();if(a.top>=t-20){n=l,i=a.top;break}}return{refDOM:n,refTop:i,stack:Ms(r.dom)}}function Ms(r){let e=[],t=r.ownerDocument;for(let n=r;n&&(e.push({dom:n,top:n.scrollTop,left:n.scrollLeft}),r!=t);n=Dt(n));return e}function La({refDOM:r,refTop:e,stack:t}){let n=r?r.getBoundingClientRect().top:0;xs(t,n==0?0:n-e)}function xs(r,e){for(let t=0;t<r.length;t++){let{dom:n,top:i,left:o}=r[t];n.scrollTop!=i+e&&(n.scrollTop=i+e),n.scrollLeft!=o&&(n.scrollLeft=o)}}let St=null;function za(r){if(r.setActive)return r.setActive();if(St)return r.focus(St);let e=Ms(r);r.focus(St==null?{get preventScroll(){return St={preventScroll:!0},!0}}:void 0),St||(St=!1,xs(e,0))}function Os(r,e){let t,n=2e8,i,o=0,s=e.top,l=e.top,a,c;for(let u=r.firstChild,d=0;u;u=u.nextSibling,d++){let f;if(u.nodeType==1)f=u.getClientRects();else if(u.nodeType==3)f=Pe(u).getClientRects();else continue;for(let h=0;h<f.length;h++){let p=f[h];if(p.top<=s&&p.bottom>=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let b=p.left>e.left?p.left-e.left:p.right<e.left?e.left-p.right:0;if(b<n){t=u,n=b,i=b&&t.nodeType==3?{left:p.right<e.left?p.right:p.left,top:e.top}:e,u.nodeType==1&&b&&(o=d+(e.left>=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=u,c={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!t&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(o=d+1)}}return!t&&a&&(t=a,i=c,n=0),t&&t.nodeType==3?Ba(t,i):!t||n&&t.nodeType==1?{node:r,offset:o}:Os(t,i)}function Ba(r,e){let t=r.nodeValue.length,n=document.createRange(),i;for(let o=0;o<t;o++){n.setEnd(r,o+1),n.setStart(r,o);let s=He(n,1);if(s.top!=s.bottom&&ri(e,s)){i={node:r,offset:o+(e.left>=(s.left+s.right)/2?1:0)};break}}return n.detach(),i||{node:r,offset:0}}function ri(r,e){return r.left>=e.left-1&&r.left<=e.right+1&&r.top>=e.top-1&&r.top<=e.bottom+1}function _a(r,e){let t=r.parentNode;return t&&/^li$/i.test(t.nodeName)&&e.left<r.getBoundingClientRect().left?t:r}function Va(r,e,t){let{node:n,offset:i}=Os(e,t),o=-1;if(n.nodeType==1&&!n.firstChild){let s=n.getBoundingClientRect();o=s.left!=s.right&&t.left>(s.left+s.right)/2?1:-1}return r.docView.posFromDOM(n,i,o)}function Ha(r,e,t,n){let i=-1;for(let o=e,s=!1;o!=r.dom;){let l=r.docView.nearestDesc(o,!0),a;if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent||!l.contentDOM)&&((a=l.dom.getBoundingClientRect()).width||a.height)&&(l.node.isBlock&&l.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(l.dom.nodeName)&&(!s&&a.left>n.left||a.top>n.top?i=l.posBefore:(!s&&a.right<n.left||a.bottom<n.top)&&(i=l.posAfter),s=!0),!l.contentDOM&&i<0&&!l.node.isText))return(l.node.isBlock?n.top<(a.top+a.bottom)/2:n.left<(a.left+a.right)/2)?l.posBefore:l.posAfter;o=l.dom.parentNode}return i>-1?i:r.docView.posFromDOM(e,t,-1)}function Es(r,e,t){let n=r.childNodes.length;if(n&&t.top<t.bottom)for(let i=Math.max(0,Math.min(n-1,Math.floor(n*(e.top-t.top)/(t.bottom-t.top))-2)),o=i;;){let s=r.childNodes[o];if(s.nodeType==1){let l=s.getClientRects();for(let a=0;a<l.length;a++){let c=l[a];if(ri(e,c))return Es(s,e,c)}}if((o=(o+1)%n)==i)break}return r}function Wa(r,e){let t=r.dom.ownerDocument,n,i=0,o=va(t,e.left,e.top);o&&({node:n,offset:i}=o);let s=(r.root.elementFromPoint?r.root:t).elementFromPoint(e.left,e.top),l;if(!s||!r.dom.contains(s.nodeType!=1?s.parentNode:s)){let c=r.dom.getBoundingClientRect();if(!ri(e,c)||(s=Es(r.dom,e,c),!s))return null}if(ne)for(let c=s;n&&c;c=Dt(c))c.draggable&&(n=void 0);if(s=_a(s,e),n){if(ye&&n.nodeType==1&&(i=Math.min(i,n.childNodes.length),i<n.childNodes.length)){let u=n.childNodes[i],d;u.nodeName=="IMG"&&(d=u.getBoundingClientRect()).right<=e.left&&d.bottom>e.top&&i++}let c;Qt&&i&&n.nodeType==1&&(c=n.childNodes[i-1]).nodeType==1&&c.contentEditable=="false"&&c.getBoundingClientRect().top>=e.top&&i--,n==r.dom&&i==n.childNodes.length-1&&n.lastChild.nodeType==1&&e.top>n.lastChild.getBoundingClientRect().bottom?l=r.state.doc.content.size:(i==0||n.nodeType!=1||n.childNodes[i-1].nodeName!="BR")&&(l=Ha(r,n,i,e))}l==null&&(l=Va(r,s,e));let a=r.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function eo(r){return r.top<r.bottom||r.left<r.right}function He(r,e){let t=r.getClientRects();if(t.length){let n=t[e<0?0:t.length-1];if(eo(n))return n}return Array.prototype.find.call(t,eo)||r.getBoundingClientRect()}const Ua=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function Ds(r,e,t){let{node:n,offset:i,atom:o}=r.docView.domFromPos(e,t<0?-1:1),s=Qt||ye;if(n.nodeType==3)if(s&&(Ua.test(n.nodeValue)||(t<0?!i:i==n.nodeValue.length))){let a=He(Pe(n,i,i),t);if(ye&&i&&/\s/.test(n.nodeValue[i-1])&&i<n.nodeValue.length){let c=He(Pe(n,i-1,i-1),-1);if(c.top==a.top){let u=He(Pe(n,i,i+1),-1);if(u.top!=a.top)return Ft(u,u.left<c.left)}}return a}else{let a=i,c=i,u=t<0?1:-1;return t<0&&!i?(c++,u=-1):t>=0&&i==n.nodeValue.length?(a--,u=1):t<0?a--:c++,Ft(He(Pe(n,a,c),u),u<0)}if(!r.state.doc.resolve(e-(o||0)).parent.inlineContent){if(o==null&&i&&(t<0||i==ge(n))){let a=n.childNodes[i-1];if(a.nodeType==1)return sr(a.getBoundingClientRect(),!1)}if(o==null&&i<ge(n)){let a=n.childNodes[i];if(a.nodeType==1)return sr(a.getBoundingClientRect(),!0)}return sr(n.getBoundingClientRect(),t>=0)}if(o==null&&i&&(t<0||i==ge(n))){let a=n.childNodes[i-1],c=a.nodeType==3?Pe(a,ge(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(c)return Ft(He(c,1),!1)}if(o==null&&i<ge(n)){let a=n.childNodes[i];for(;a.pmViewDesc&&a.pmViewDesc.ignoreForCoords;)a=a.nextSibling;let c=a?a.nodeType==3?Pe(a,0,s?0:1):a.nodeType==1?a:null:null;if(c)return Ft(He(c,-1),!0)}return Ft(He(n.nodeType==3?Pe(n):n,-t),t>=0)}function Ft(r,e){if(r.width==0)return r;let t=e?r.left:r.right;return{top:r.top,bottom:r.bottom,left:t,right:t}}function sr(r,e){if(r.height==0)return r;let t=e?r.top:r.bottom;return{top:t,bottom:t,left:r.left,right:r.right}}function Ns(r,e,t){let n=r.state,i=r.root.activeElement;n!=e&&r.updateState(e),i!=r.dom&&r.focus();try{return t()}finally{n!=e&&r.updateState(n),i!=r.dom&&i&&i.focus()}}function $a(r,e,t){let n=e.selection,i=t=="up"?n.$from:n.$to;return Ns(r,e,()=>{let{node:o}=r.docView.domFromPos(i.pos,t=="up"?-1:1);for(;;){let l=r.docView.nearestDesc(o,!0);if(!l)break;if(l.node.isBlock){o=l.contentDOM||l.dom;break}o=l.dom.parentNode}let s=Ds(r,i.pos,1);for(let l=o.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Pe(l,0,l.nodeValue.length).getClientRects();else continue;for(let c=0;c<a.length;c++){let u=a[c];if(u.bottom>u.top+1&&(t=="up"?s.top-u.top>(u.bottom-s.top)*2:u.bottom-s.bottom>(s.bottom-u.top)*2))return!1}}return!0})}const qa=/[\u0590-\u08ac]/;function Ka(r,e,t){let{$head:n}=e.selection;if(!n.parent.isTextblock)return!1;let i=n.parentOffset,o=!i,s=i==n.parent.content.size,l=r.domSelection();return l?!qa.test(n.parent.textContent)||!l.modify?t=="left"||t=="backward"?o:s:Ns(r,e,()=>{let{focusNode:a,focusOffset:c,anchorNode:u,anchorOffset:d}=r.domSelectionRange(),f=l.caretBidiLevel;l.modify("move",t,"character");let h=n.depth?r.docView.domAfterPos(n.before()):r.dom,{focusNode:p,focusOffset:b}=r.domSelectionRange(),y=p&&!h.contains(p.nodeType==1?p:p.parentNode)||a==p&&c==b;try{l.collapse(u,d),a&&(a!=u||c!=d)&&l.extend&&l.extend(a,c)}catch{}return f!=null&&(l.caretBidiLevel=f),y}):n.pos==n.start()||n.pos==n.end()}let to=null,no=null,ro=!1;function Ga(r,e,t){return to==e&&no==t?ro:(to=e,no=t,ro=t=="up"||t=="down"?$a(r,e,t):Ka(r,e,t))}const Se=0,io=1,rt=2,Ae=3;class en{constructor(e,t,n,i){this.parent=e,this.children=t,this.dom=n,this.contentDOM=i,this.dirty=Se,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let i=this.children[t];if(i==e)return n;n+=i.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let o,s;if(e==this.contentDOM)o=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.previousSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.previousSibling;return o?this.posBeforeChild(s)+s.size:this.posAtStart}else{let o,s;if(e==this.contentDOM)o=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;o=e.nextSibling}for(;o&&!((s=o.pmViewDesc)&&s.parent==this);)o=o.nextSibling;return o?this.posBeforeChild(s):this.posAtEnd}let i;if(e==this.dom&&this.contentDOM)i=t>K(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))i=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!1;break}if(o.previousSibling)break}if(i==null&&t==e.childNodes.length)for(let o=e;;o=o.parentNode){if(o==this.dom){i=!0;break}if(o.nextSibling)break}}return i??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,i=e;i;i=i.parentNode){let o=this.getDesc(i),s;if(o&&(!t||o.node))if(n&&(s=o.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))n=!1;else return o}}getDesc(e){let t=e.pmViewDesc;for(let n=t;n;n=n.parent)if(n==this)return t}posFromDOM(e,t,n){for(let i=e;i;i=i.parentNode){let o=this.getDesc(i);if(o)return o.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let i=this.children[t],o=n+i.size;if(n==e&&o!=n){for(;!i.border&&i.children.length;)for(let s=0;s<i.children.length;s++){let l=i.children[s];if(l.size){i=l;break}}return i}if(e<o)return i.descAt(e-n-i.border);n=o}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,i=0;for(let o=0;n<this.children.length;n++){let s=this.children[n],l=o+s.size;if(l>e||s instanceof As){i=e-o;break}o=l}if(i)return this.children[n].domFromPos(i-this.children[n].border,t);for(let o;n&&!(o=this.children[n-1]).size&&o instanceof ws&&o.side>=0;n--);if(t<=0){let o,s=!0;for(;o=n?this.children[n-1]:null,!(!o||o.dom.parentNode==this.contentDOM);n--,s=!1);return o&&t&&s&&!o.border&&!o.domAtom?o.domFromPos(o.size,t):{node:this.contentDOM,offset:o?K(o.dom)+1:0}}else{let o,s=!0;for(;o=n<this.children.length?this.children[n]:null,!(!o||o.dom.parentNode==this.contentDOM);n++,s=!1);return o&&s&&!o.border&&!o.domAtom?o.domFromPos(0,t):{node:this.contentDOM,offset:o?K(o.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let i=-1,o=-1;for(let s=n,l=0;;l++){let a=this.children[l],c=s+a.size;if(i==-1&&e<=c){let u=s+a.border;if(e>=u&&t<=c-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,t,u);e=s;for(let d=l;d>0;d--){let f=this.children[d-1];if(f.size&&f.dom.parentNode==this.contentDOM&&!f.emptyChildAt(1)){i=K(f.dom)+1;break}e-=f.size}i==-1&&(i=0)}if(i>-1&&(c>t||l==this.children.length-1)){t=c;for(let u=l+1;u<this.children.length;u++){let d=this.children[u];if(d.size&&d.dom.parentNode==this.contentDOM&&!d.emptyChildAt(-1)){o=K(d.dom);break}t+=d.size}o==-1&&(o=this.contentDOM.childNodes.length);break}s=c}return{node:this.contentDOM,from:e,to:t,fromOffset:i,toOffset:o}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw new RangeError("No node after pos "+e);return t.childNodes[n]}setSelection(e,t,n,i=!1){let o=Math.min(e,t),s=Math.max(e,t);for(let h=0,p=0;h<this.children.length;h++){let b=this.children[h],y=p+b.size;if(o>p&&s<y)return b.setSelection(e-p-b.border,t-p-b.border,n,i);p=y}let l=this.domFromPos(e,e?-1:1),a=t==e?l:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),u=n.domSelectionRange(),d=!1;if((ye||ne)&&e==t){let{node:h,offset:p}=l;if(h.nodeType==3){if(d=!!(p&&h.nodeValue[p-1]==`
3
- `),d&&p==h.nodeValue.length)for(let b=h,y;b;b=b.parentNode){if(y=b.nextSibling){y.nodeName=="BR"&&(l=a={node:y.parentNode,offset:K(y)+1});break}let k=b.pmViewDesc;if(k&&k.node&&k.node.isBlock)break}}else{let b=h.childNodes[p-1];d=b&&(b.nodeName=="BR"||b.contentEditable=="false")}}if(ye&&u.focusNode&&u.focusNode!=a.node&&u.focusNode.nodeType==1){let h=u.focusNode.childNodes[u.focusOffset];h&&h.contentEditable=="false"&&(i=!0)}if(!(i||d&&ne)&&ct(l.node,l.offset,u.anchorNode,u.anchorOffset)&&ct(a.node,a.offset,u.focusNode,u.focusOffset))return;let f=!1;if((c.extend||e==t)&&!(d&&ye)){c.collapse(l.node,l.offset);try{e!=t&&c.extend(a.node,a.offset),f=!0}catch{}}if(!f){if(e>t){let p=l;l=a,a=p}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),c.removeAllRanges(),c.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,i=0;i<this.children.length;i++){let o=this.children[i],s=n+o.size;if(n==s?e<=s&&t>=n:e<s&&t>n){let l=n+o.border,a=s-o.border;if(e>=l&&t<=a){this.dirty=e==n||t==s?rt:io,e==l&&t==a&&(o.contentLost||o.dom.parentNode!=this.contentDOM)?o.dirty=Ae:o.markDirty(e-l,t-l);return}else o.dirty=o.dom==o.contentDOM&&o.dom.parentNode==this.contentDOM&&!o.children.length?rt:Ae}n=s}this.dirty=rt}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?rt:io;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}}class ws extends en{constructor(e,t,n,i){let o,s=t.type.toDOM;if(typeof s=="function"&&(s=s(n,()=>{if(!o)return i;if(o.parent)return o.parent.posBeforeChild(o)})),!t.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=t,this.widget=t,o=this}matchesWidget(e){return this.dirty==Se&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}}class Ja extends en{constructor(e,t,n,i){super(e,[],t,null),this.textDOM=n,this.text=i}get size(){return this.text.length}localPosFromDOM(e,t){return e!=this.textDOM?this.posAtStart+(t?this.size:0):this.posAtStart+t}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class ut extends en{constructor(e,t,n,i,o){super(e,[],n,i),this.mark=t,this.spec=o}static create(e,t,n,i){let o=i.nodeViews[t.type.name],s=o&&o(t,i,n);return(!s||!s.dom)&&(s=m.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t,n),null,t.attrs)),new ut(e,t,s.dom,s.contentDOM||s.dom,s)}parseRule(){return this.dirty&Ae||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Ae&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Se){let n=this.parent;for(;!n.node;)n=n.parent;n.dirty<this.dirty&&(n.dirty=this.dirty),this.dirty=Se}}slice(e,t,n){let i=ut.create(this.parent,this.mark,!0,n),o=this.children,s=this.size;t<s&&(o=Pr(o,t,s,n)),e>0&&(o=Pr(o,0,e,n));for(let l=0;l<o.length;l++)o[l].parent=i;return i.children=o,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}}class je extends en{constructor(e,t,n,i,o,s,l,a,c){super(e,[],o,s),this.node=t,this.outerDeco=n,this.innerDeco=i,this.nodeDOM=l}static create(e,t,n,i,o,s){let l=o.nodeViews[t.type.name],a,c=l&&l(t,o,()=>{if(!a)return s;if(a.parent)return a.parent.posBeforeChild(a)},n,i),u=c&&c.dom,d=c&&c.contentDOM;if(t.isText){if(!u)u=document.createTextNode(t.text);else if(u.nodeType!=3)throw new RangeError("Text must be rendered as a DOM text node")}else u||({dom:u,contentDOM:d}=m.DOMSerializer.renderSpec(document,t.type.spec.toDOM(t),null,t.attrs));!d&&!t.isText&&u.nodeName!="BR"&&(u.hasAttribute("contenteditable")||(u.contentEditable="false"),t.type.spec.draggable&&(u.draggable=!0));let f=u;return u=Is(u,n,t),c?a=new ja(e,t,n,i,u,d||null,f,c,o,s+1):t.isText?new Rn(e,t,n,i,u,f,o):new je(e,t,n,i,u,d||null,f,o,s+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace=="pre"&&(e.preserveWhitespace="full"),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>m.Fragment.empty)}return e}matchesNode(e,t,n){return this.dirty==Se&&e.eq(this.node)&&Cn(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,i=t,o=e.composing?this.localCompositionInfo(e,t):null,s=o&&o.pos>-1?o:null,l=o&&o.pos<0,a=new Xa(this,s&&s.node,e);ec(this.node,this.innerDeco,(c,u,d)=>{c.spec.marks?a.syncToMarks(c.spec.marks,n,e,u):c.type.side>=0&&!d&&a.syncToMarks(u==this.node.childCount?m.Mark.none:this.node.child(u).marks,n,e,u),a.placeWidget(c,e,i)},(c,u,d,f)=>{a.syncToMarks(c.marks,n,e,f);let h;a.findNodeMatch(c,u,d,f)||l&&e.state.selection.from>i&&e.state.selection.to<i+c.nodeSize&&(h=a.findIndexWithChild(o.node))>-1&&a.updateNodeAt(c,u,d,h,e)||a.updateNextNode(c,u,d,e,f,i)||a.addNode(c,u,d,e,i),i+=c.nodeSize}),a.syncToMarks([],n,e,0),this.node.isTextblock&&a.addTextblockHacks(),a.destroyRest(),(a.changed||this.dirty==rt)&&(s&&this.protectLocalComposition(e,s),vs(this.contentDOM,this.children,e),Nt&&tc(this.dom))}localCompositionInfo(e,t){let{from:n,to:i}=e.state.selection;if(!(e.state.selection instanceof O)||n<t||i>t+this.node.content.size)return null;let o=e.input.compositionNode;if(!o||!this.dom.contains(o.parentNode))return null;if(this.node.inlineContent){let s=o.nodeValue,l=nc(this.node.content,s,n-t,i-t);return l<0?null:{node:o,pos:l,text:s}}else return{node:o,pos:-1,text:""}}protectLocalComposition(e,{node:t,pos:n,text:i}){if(this.getDesc(t))return;let o=t;for(;o.parentNode!=this.contentDOM;o=o.parentNode){for(;o.previousSibling;)o.parentNode.removeChild(o.previousSibling);for(;o.nextSibling;)o.parentNode.removeChild(o.nextSibling);o.pmViewDesc&&(o.pmViewDesc=void 0)}let s=new Ja(this,o,t,i);e.input.compositionNodes.push(s),this.children=Pr(this.children,n,n+i.length,e,s)}update(e,t,n,i){return this.dirty==Ae||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,i),!0)}updateInner(e,t,n,i){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(i,this.posAtStart),this.dirty=Se}updateOuterDeco(e){if(Cn(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Rs(this.dom,this.nodeDOM,Fr(this.outerDeco,this.node,t),Fr(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove("ProseMirror-selectednode"),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute("draggable"))}get domAtom(){return this.node.isAtom}}function oo(r,e,t,n,i){Is(n,e,r);let o=new je(void 0,r,e,t,n,n,n,i,0);return o.contentDOM&&o.updateChildren(i,0),o}class Rn extends je{constructor(e,t,n,i,o,s,l){super(e,t,n,i,o,null,s,l,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,i){return this.dirty==Ae||this.dirty!=Se&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Se||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,i.trackWrites==this.nodeDOM&&(i.trackWrites=null)),this.node=e,this.dirty=Se,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!="characterData"&&e.type!="selection"}slice(e,t,n){let i=this.node.cut(e,t),o=document.createTextNode(i.text);return new Rn(this.parent,i,this.outerDeco,this.innerDeco,o,o,n)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Ae)}get domAtom(){return!1}isText(e){return this.node.text==e}}class As extends en{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Se&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName=="IMG"}}class ja extends je{constructor(e,t,n,i,o,s,l,a,c,u){super(e,t,n,i,o,s,l,c,u),this.spec=a}update(e,t,n,i){if(this.dirty==Ae)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let o=this.spec.update(e,t,n);return o&&this.updateInner(e,t,n,i),o}else return!this.contentDOM&&!e.isLeaf?!1:super.update(e,t,n,i)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,i){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,i)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}}function vs(r,e,t){let n=r.firstChild,i=!1;for(let o=0;o<e.length;o++){let s=e[o],l=s.dom;if(l.parentNode==r){for(;l!=n;)n=so(n),i=!0;n=n.nextSibling}else i=!0,r.insertBefore(l,n);if(s instanceof ut){let a=n?n.previousSibling:r.lastChild;vs(s.contentDOM,s.children,t),n=a?a.nextSibling:r.firstChild}}for(;n;)n=so(n),i=!0;i&&t.trackWrites==r&&(t.trackWrites=null)}const $t=function(r){r&&(this.nodeName=r)};$t.prototype=Object.create(null);const it=[new $t];function Fr(r,e,t){if(r.length==0)return it;let n=t?it[0]:new $t,i=[n];for(let o=0;o<r.length;o++){let s=r[o].type.attrs;if(s){s.nodeName&&i.push(n=new $t(s.nodeName));for(let l in s){let a=s[l];a!=null&&(t&&i.length==1&&i.push(n=new $t(e.isInline?"span":"div")),l=="class"?n.class=(n.class?n.class+" ":"")+a:l=="style"?n.style=(n.style?n.style+";":"")+a:l!="nodeName"&&(n[l]=a))}}}return i}function Rs(r,e,t,n){if(t==it&&n==it)return e;let i=e;for(let o=0;o<n.length;o++){let s=n[o],l=t[o];if(o){let a;l&&l.nodeName==s.nodeName&&i!=r&&(a=i.parentNode)&&a.nodeName.toLowerCase()==s.nodeName||(a=document.createElement(s.nodeName),a.pmIsDeco=!0,a.appendChild(i),l=it[0]),i=a}Ya(i,l||it[0],s)}return i}function Ya(r,e,t){for(let n in e)n!="class"&&n!="style"&&n!="nodeName"&&!(n in t)&&r.removeAttribute(n);for(let n in t)n!="class"&&n!="style"&&n!="nodeName"&&t[n]!=e[n]&&r.setAttribute(n,t[n]);if(e.class!=t.class){let n=e.class?e.class.split(" ").filter(Boolean):[],i=t.class?t.class.split(" ").filter(Boolean):[];for(let o=0;o<n.length;o++)i.indexOf(n[o])==-1&&r.classList.remove(n[o]);for(let o=0;o<i.length;o++)n.indexOf(i[o])==-1&&r.classList.add(i[o]);r.classList.length==0&&r.removeAttribute("class")}if(e.style!=t.style){if(e.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,i;for(;i=n.exec(e.style);)r.style.removeProperty(i[1])}t.style&&(r.style.cssText+=t.style)}}function Is(r,e,t){return Rs(r,r,it,Fr(e,t,r.nodeType!=1))}function Cn(r,e){if(r.length!=e.length)return!1;for(let t=0;t<r.length;t++)if(!r[t].type.eq(e[t].type))return!1;return!0}function so(r){let e=r.nextSibling;return r.parentNode.removeChild(r),e}class Xa{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=Za(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,i){let o=0,s=this.stack.length>>1,l=Math.min(s,e.length);for(;o<l&&(o==s-1?this.top:this.stack[o+1<<1]).matchesMark(e[o])&&e[o].type.spec.spanning!==!1;)o++;for(;o<s;)this.destroyRest(),this.top.dirty=Se,this.index=this.stack.pop(),this.top=this.stack.pop(),s--;for(;s<e.length;){this.stack.push(this.top,this.index+1);let a=-1,c=this.top.children.length;i<this.preMatch.index&&(c=Math.min(this.index+3,c));for(let u=this.index;u<c;u++){let d=this.top.children[u];if(d.matchesMark(e[s])&&!this.isLocked(d.dom)){a=u;break}}if(a>-1)a>this.index&&(this.changed=!0,this.destroyBetween(this.index,a)),this.top=this.top.children[this.index];else{let u=ut.create(this.top,e[s],t,n);this.top.children.splice(this.index,0,u),this.top=u,this.changed=!0}this.index=0,s++}}findNodeMatch(e,t,n,i){let o=-1,s;if(i>=this.preMatch.index&&(s=this.preMatch.matches[i-this.preMatch.index]).parent==this.top&&s.matchesNode(e,t,n))o=this.top.children.indexOf(s,this.index);else for(let l=this.index,a=Math.min(this.top.children.length,l+5);l<a;l++){let c=this.top.children[l];if(c.matchesNode(e,t,n)&&!this.preMatch.matched.has(c)){o=l;break}}return o<0?!1:(this.destroyBetween(this.index,o),this.index++,!0)}updateNodeAt(e,t,n,i,o){let s=this.top.children[i];return s.dirty==Ae&&s.dom==s.contentDOM&&(s.dirty=rt),s.update(e,t,n,o)?(this.destroyBetween(this.index,i),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let n=e.pmViewDesc;if(n){for(let i=this.index;i<this.top.children.length;i++)if(this.top.children[i]==n)return i}return-1}e=t}}updateNextNode(e,t,n,i,o,s){for(let l=this.index;l<this.top.children.length;l++){let a=this.top.children[l];if(a instanceof je){let c=this.preMatch.matched.get(a);if(c!=null&&c!=o)return!1;let u=a.dom,d,f=this.isLocked(u)&&!(e.isText&&a.node&&a.node.isText&&a.nodeDOM.nodeValue==e.text&&a.dirty!=Ae&&Cn(t,a.outerDeco));if(!f&&a.update(e,t,n,i))return this.destroyBetween(this.index,l),a.dom!=u&&(this.changed=!0),this.index++,!0;if(!f&&(d=this.recreateWrapper(a,e,t,n,i,s)))return this.destroyBetween(this.index,l),this.top.children[this.index]=d,d.contentDOM&&(d.dirty=rt,d.updateChildren(i,s+1),d.dirty=Se),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,i,o,s){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!Cn(n,e.outerDeco)||!i.eq(e.innerDeco))return null;let l=je.create(this.top,t,n,i,o,s);if(l.contentDOM){l.children=e.children,e.children=[];for(let a of l.children)a.parent=l}return e.destroy(),l}addNode(e,t,n,i,o){let s=je.create(this.top,e,t,n,i,o);s.contentDOM&&s.updateChildren(i,o+1),this.top.children.splice(this.index++,0,s),this.changed=!0}placeWidget(e,t,n){let i=this.index<this.top.children.length?this.top.children[this.index]:null;if(i&&i.matchesWidget(e)&&(e==i.widget||!i.widget.type.toDOM.parentNode))this.index++;else{let o=new ws(this.top,e,t,n);this.top.children.splice(this.index++,0,o),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof ut;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Rn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((ne||J)&&e&&e.dom.contentEditable=="false"&&this.addHackNode("IMG",t),this.addHackNode("BR",this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e=="IMG"&&(n.className="ProseMirror-separator",n.alt=""),e=="BR"&&(n.className="ProseMirror-trailingBreak");let i=new As(this.top,[],n,null);t!=this.top?t.children.push(i):t.children.splice(this.index++,0,i),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}}function Za(r,e){let t=e,n=t.children.length,i=r.childCount,o=new Map,s=[];e:for(;i>0;){let l;for(;;)if(n){let c=t.children[n-1];if(c instanceof ut)t=c,n=c.children.length;else{l=c,n--;break}}else{if(t==e)break e;n=t.parent.children.indexOf(t),t=t.parent}let a=l.node;if(a){if(a!=r.child(i-1))break;--i,o.set(l,i),s.push(l)}}return{index:i,matched:o,matches:s.reverse()}}function Qa(r,e){return r.type.side-e.type.side}function ec(r,e,t,n){let i=e.locals(r),o=0;if(i.length==0){for(let c=0;c<r.childCount;c++){let u=r.child(c);n(u,i,e.forChild(o,u),c),o+=u.nodeSize}return}let s=0,l=[],a=null;for(let c=0;;){let u,d;for(;s<i.length&&i[s].to==o;){let y=i[s++];y.widget&&(u?(d||(d=[u])).push(y):u=y)}if(u)if(d){d.sort(Qa);for(let y=0;y<d.length;y++)t(d[y],c,!!a)}else t(u,c,!!a);let f,h;if(a)h=-1,f=a,a=null;else if(c<r.childCount)h=c,f=r.child(c++);else break;for(let y=0;y<l.length;y++)l[y].to<=o&&l.splice(y--,1);for(;s<i.length&&i[s].from<=o&&i[s].to>o;)l.push(i[s++]);let p=o+f.nodeSize;if(f.isText){let y=p;s<i.length&&i[s].from<y&&(y=i[s].from);for(let k=0;k<l.length;k++)l[k].to<y&&(y=l[k].to);y<p&&(a=f.cut(y-o),f=f.cut(0,y-o),p=y,h=-1)}else for(;s<i.length&&i[s].to<p;)s++;let b=f.isInline&&!f.isLeaf?l.filter(y=>!y.inline):l.slice();n(f,b,e.forChild(o,f),h),o=p}}function tc(r){if(r.nodeName=="UL"||r.nodeName=="OL"){let e=r.style.cssText;r.style.cssText=e+"; list-style: square !important",window.getComputedStyle(r).listStyle,r.style.cssText=e}}function nc(r,e,t,n){for(let i=0,o=0;i<r.childCount&&o<=n;){let s=r.child(i++),l=o;if(o+=s.nodeSize,!s.isText)continue;let a=s.text;for(;i<r.childCount;){let c=r.child(i++);if(o+=c.nodeSize,!c.isText)break;a+=c.text}if(o>=t){if(o>=n&&a.slice(n-e.length-l,n-l)==e)return n-e.length;let c=l<n?a.lastIndexOf(e,n-l-1):-1;if(c>=0&&c+e.length+l>=t)return l+c;if(t==n&&a.length>=n+e.length-l&&a.slice(n-l,n-l+e.length)==e)return n}}return-1}function Pr(r,e,t,n,i){let o=[];for(let s=0,l=0;s<r.length;s++){let a=r[s],c=l,u=l+=a.size;c>=t||u<=e?o.push(a):(c<e&&o.push(a.slice(0,e-c,n)),i&&(o.push(i),i=void 0),u>t&&o.push(a.slice(t-c,a.size,n)))}return o}function ii(r,e=null){let t=r.domSelectionRange(),n=r.state.doc;if(!t.focusNode)return null;let i=r.docView.nearestDesc(t.focusNode),o=i&&i.size==0,s=r.docView.posFromDOM(t.focusNode,t.focusOffset,1);if(s<0)return null;let l=n.resolve(s),a,c;if(vn(t)){for(a=s;i&&!i.node;)i=i.parent;let d=i.node;if(i&&d.isAtom&&M.isSelectable(d)&&i.parent&&!(d.isInline&&wa(t.focusNode,t.focusOffset,i.dom))){let f=i.posBefore;c=new M(s==f?l:n.resolve(f))}}else{if(t instanceof r.dom.ownerDocument.defaultView.Selection&&t.rangeCount>1){let d=s,f=s;for(let h=0;h<t.rangeCount;h++){let p=t.getRangeAt(h);d=Math.min(d,r.docView.posFromDOM(p.startContainer,p.startOffset,1)),f=Math.max(f,r.docView.posFromDOM(p.endContainer,p.endOffset,-1))}if(d<0)return null;[a,s]=f==r.state.selection.anchor?[f,d]:[d,f],l=n.resolve(s)}else a=r.docView.posFromDOM(t.anchorNode,t.anchorOffset,1);if(a<0)return null}let u=n.resolve(a);if(!c){let d=e=="pointer"||r.state.selection.head<l.pos&&!o?1:-1;c=oi(r,u,l,d)}return c}function Fs(r){return r.editable?r.hasFocus():Ls(r)&&document.activeElement&&document.activeElement.contains(r.dom)}function Be(r,e=!1){let t=r.state.selection;if(Ps(r,t),!!Fs(r)){if(!e&&r.input.mouseDown&&r.input.mouseDown.allowDefault&&J){let n=r.domSelectionRange(),i=r.domObserver.currentSelection;if(n.anchorNode&&i.anchorNode&&ct(n.anchorNode,n.anchorOffset,i.anchorNode,i.anchorOffset)){r.input.mouseDown.delayedSelectionSync=!0,r.domObserver.setCurSelection();return}}if(r.domObserver.disconnectSelection(),r.cursorWrapper)ic(r);else{let{anchor:n,head:i}=t,o,s;lo&&!(t instanceof O)&&(t.$from.parent.inlineContent||(o=ao(r,t.from)),!t.empty&&!t.$from.parent.inlineContent&&(s=ao(r,t.to))),r.docView.setSelection(n,i,r,e),lo&&(o&&co(o),s&&co(s)),t.visible?r.dom.classList.remove("ProseMirror-hideselection"):(r.dom.classList.add("ProseMirror-hideselection"),"onselectionchange"in document&&rc(r))}r.domObserver.setCurSelection(),r.domObserver.connectSelection()}}const lo=ne||J&&Ts<63;function ao(r,e){let{node:t,offset:n}=r.docView.domFromPos(e,0),i=n<t.childNodes.length?t.childNodes[n]:null,o=n?t.childNodes[n-1]:null;if(ne&&i&&i.contentEditable=="false")return lr(i);if((!i||i.contentEditable=="false")&&(!o||o.contentEditable=="false")){if(i)return lr(i);if(o)return lr(o)}}function lr(r){return r.contentEditable="true",ne&&r.draggable&&(r.draggable=!1,r.wasDraggable=!0),r}function co(r){r.contentEditable="false",r.wasDraggable&&(r.draggable=!0,r.wasDraggable=null)}function rc(r){let e=r.dom.ownerDocument;e.removeEventListener("selectionchange",r.input.hideSelectionGuard);let t=r.domSelectionRange(),n=t.anchorNode,i=t.anchorOffset;e.addEventListener("selectionchange",r.input.hideSelectionGuard=()=>{(t.anchorNode!=n||t.anchorOffset!=i)&&(e.removeEventListener("selectionchange",r.input.hideSelectionGuard),setTimeout(()=>{(!Fs(r)||r.state.selection.visible)&&r.dom.classList.remove("ProseMirror-hideselection")},20))})}function ic(r){let e=r.domSelection();if(!e)return;let t=r.cursorWrapper.dom,n=t.nodeName=="IMG";n?e.collapse(t.parentNode,K(t)+1):e.collapse(t,0),!n&&!r.state.selection.visible&&fe&&Je<=11&&(t.disabled=!0,t.disabled=!1)}function Ps(r,e){if(e instanceof M){let t=r.docView.descAt(e.from);t!=r.lastSelectedViewDesc&&(uo(r),t&&t.selectNode(),r.lastSelectedViewDesc=t)}else uo(r)}function uo(r){r.lastSelectedViewDesc&&(r.lastSelectedViewDesc.parent&&r.lastSelectedViewDesc.deselectNode(),r.lastSelectedViewDesc=void 0)}function oi(r,e,t,n){return r.someProp("createSelectionBetween",i=>i(r,e,t))||O.between(e,t,n)}function fo(r){return r.editable&&!r.hasFocus()?!1:Ls(r)}function Ls(r){let e=r.domSelectionRange();if(!e.anchorNode)return!1;try{return r.dom.contains(e.anchorNode.nodeType==3?e.anchorNode.parentNode:e.anchorNode)&&(r.editable||r.dom.contains(e.focusNode.nodeType==3?e.focusNode.parentNode:e.focusNode))}catch{return!1}}function oc(r){let e=r.docView.domFromPos(r.state.selection.anchor,0),t=r.domSelectionRange();return ct(e.node,e.offset,t.anchorNode,t.anchorOffset)}function Lr(r,e){let{$anchor:t,$head:n}=r.selection,i=e>0?t.max(n):t.min(n),o=i.parent.inlineContent?i.depth?r.doc.resolve(e>0?i.after():i.before()):null:i;return o&&D.findFrom(o,e)}function We(r,e){return r.dispatch(r.state.tr.setSelection(e).scrollIntoView()),!0}function ho(r,e,t){let n=r.state.selection;if(n instanceof O)if(t.indexOf("s")>-1){let{$head:i}=n,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter;if(!o||o.isText||!o.isLeaf)return!1;let s=r.state.doc.resolve(i.pos+o.nodeSize*(e<0?-1:1));return We(r,new O(n.$anchor,s))}else if(n.empty){if(r.endOfTextblock(e>0?"forward":"backward")){let i=Lr(r.state,e);return i&&i instanceof M?We(r,i):!1}else if(!(me&&t.indexOf("m")>-1)){let i=n.$head,o=i.textOffset?null:e<0?i.nodeBefore:i.nodeAfter,s;if(!o||o.isText)return!1;let l=e<0?i.pos-o.nodeSize:i.pos;return o.isAtom||(s=r.docView.descAt(l))&&!s.contentDOM?M.isSelectable(o)?We(r,new M(e<0?r.state.doc.resolve(i.pos-o.nodeSize):i)):Qt?We(r,new O(r.state.doc.resolve(e<0?l:l+o.nodeSize))):!1:!1}}else return!1;else{if(n instanceof M&&n.node.isInline)return We(r,new O(e>0?n.$to:n.$from));{let i=Lr(r.state,e);return i?We(r,i):!1}}}function Mn(r){return r.nodeType==3?r.nodeValue.length:r.childNodes.length}function qt(r,e){let t=r.pmViewDesc;return t&&t.size==0&&(e<0||r.nextSibling||r.nodeName!="BR")}function kt(r,e){return e<0?sc(r):lc(r)}function sc(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i,o,s=!1;for(ye&&t.nodeType==1&&n<Mn(t)&&qt(t.childNodes[n],-1)&&(s=!0);;)if(n>0){if(t.nodeType!=1)break;{let l=t.childNodes[n-1];if(qt(l,-1))i=t,o=--n;else if(l.nodeType==3)t=l,n=t.nodeValue.length;else break}}else{if(zs(t))break;{let l=t.previousSibling;for(;l&&qt(l,-1);)i=t.parentNode,o=K(l),l=l.previousSibling;if(l)t=l,n=Mn(t);else{if(t=t.parentNode,t==r.dom)break;n=0}}}s?zr(r,t,n):i&&zr(r,i,o)}function lc(r){let e=r.domSelectionRange(),t=e.focusNode,n=e.focusOffset;if(!t)return;let i=Mn(t),o,s;for(;;)if(n<i){if(t.nodeType!=1)break;let l=t.childNodes[n];if(qt(l,1))o=t,s=++n;else break}else{if(zs(t))break;{let l=t.nextSibling;for(;l&&qt(l,1);)o=l.parentNode,s=K(l)+1,l=l.nextSibling;if(l)t=l,n=0,i=Mn(t);else{if(t=t.parentNode,t==r.dom)break;n=i=0}}}o&&zr(r,o,s)}function zs(r){let e=r.pmViewDesc;return e&&e.node&&e.node.isBlock}function ac(r,e){for(;r&&e==r.childNodes.length&&!Zt(r);)e=K(r)+1,r=r.parentNode;for(;r&&e<r.childNodes.length;){let t=r.childNodes[e];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=0}}function cc(r,e){for(;r&&!e&&!Zt(r);)e=K(r),r=r.parentNode;for(;r&&e;){let t=r.childNodes[e-1];if(t.nodeType==3)return t;if(t.nodeType==1&&t.contentEditable=="false")break;r=t,e=r.childNodes.length}}function zr(r,e,t){if(e.nodeType!=3){let o,s;(s=ac(e,t))?(e=s,t=0):(o=cc(e,t))&&(e=o,t=o.nodeValue.length)}let n=r.domSelection();if(!n)return;if(vn(n)){let o=document.createRange();o.setEnd(e,t),o.setStart(e,t),n.removeAllRanges(),n.addRange(o)}else n.extend&&n.extend(e,t);r.domObserver.setCurSelection();let{state:i}=r;setTimeout(()=>{r.state==i&&Be(r)},50)}function po(r,e){let t=r.state.doc.resolve(e);if(!(J||Cs)&&t.parent.inlineContent){let i=r.coordsAtPos(e);if(e>t.start()){let o=r.coordsAtPos(e-1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left<i.left?"ltr":"rtl"}if(e<t.end()){let o=r.coordsAtPos(e+1),s=(o.top+o.bottom)/2;if(s>i.top&&s<i.bottom&&Math.abs(o.left-i.left)>1)return o.left>i.left?"ltr":"rtl"}}return getComputedStyle(r.dom).direction=="rtl"?"rtl":"ltr"}function mo(r,e,t){let n=r.state.selection;if(n instanceof O&&!n.empty||t.indexOf("s")>-1||me&&t.indexOf("m")>-1)return!1;let{$from:i,$to:o}=n;if(!i.parent.inlineContent||r.endOfTextblock(e<0?"up":"down")){let s=Lr(r.state,e);if(s&&s instanceof M)return We(r,s)}if(!i.parent.inlineContent){let s=e<0?i:o,l=n instanceof j?D.near(s,e):D.findFrom(s,e);return l?We(r,l):!1}return!1}function go(r,e){if(!(r.state.selection instanceof O))return!0;let{$head:t,$anchor:n,empty:i}=r.state.selection;if(!t.sameParent(n))return!0;if(!i)return!1;if(r.endOfTextblock(e>0?"forward":"backward"))return!0;let o=!t.textOffset&&(e<0?t.nodeBefore:t.nodeAfter);if(o&&!o.isText){let s=r.state.tr;return e<0?s.delete(t.pos-o.nodeSize,t.pos):s.delete(t.pos,t.pos+o.nodeSize),r.dispatch(s),!0}return!1}function bo(r,e,t){r.domObserver.stop(),e.contentEditable=t,r.domObserver.start()}function uc(r){if(!ne||r.state.selection.$head.parentOffset>0)return!1;let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(e&&e.nodeType==1&&t==0&&e.firstChild&&e.firstChild.contentEditable=="false"){let n=e.firstChild;bo(r,n,"true"),setTimeout(()=>bo(r,n,"false"),20)}return!1}function dc(r){let e="";return r.ctrlKey&&(e+="c"),r.metaKey&&(e+="m"),r.altKey&&(e+="a"),r.shiftKey&&(e+="s"),e}function fc(r,e){let t=e.keyCode,n=dc(e);if(t==8||me&&t==72&&n=="c")return go(r,-1)||kt(r,-1);if(t==46&&!e.shiftKey||me&&t==68&&n=="c")return go(r,1)||kt(r,1);if(t==13||t==27)return!0;if(t==37||me&&t==66&&n=="c"){let i=t==37?po(r,r.state.selection.from)=="ltr"?-1:1:-1;return ho(r,i,n)||kt(r,i)}else if(t==39||me&&t==70&&n=="c"){let i=t==39?po(r,r.state.selection.from)=="ltr"?1:-1:1;return ho(r,i,n)||kt(r,i)}else{if(t==38||me&&t==80&&n=="c")return mo(r,-1,n)||kt(r,-1);if(t==40||me&&t==78&&n=="c")return uc(r)||mo(r,1,n)||kt(r,1);if(n==(me?"m":"c")&&(t==66||t==73||t==89||t==90))return!0}return!1}function si(r,e){r.someProp("transformCopied",h=>{e=h(e,r)});let t=[],{content:n,openStart:i,openEnd:o}=e;for(;i>1&&o>1&&n.childCount==1&&n.firstChild.childCount==1;){i--,o--;let h=n.firstChild;t.push(h.type.name,h.attrs!=h.type.defaultAttrs?h.attrs:null),n=h.content}let s=r.someProp("clipboardSerializer")||m.DOMSerializer.fromSchema(r.state.schema),l=Us(),a=l.createElement("div");a.appendChild(s.serializeFragment(n,{document:l}));let c=a.firstChild,u,d=0;for(;c&&c.nodeType==1&&(u=Ws[c.nodeName.toLowerCase()]);){for(let h=u.length-1;h>=0;h--){let p=l.createElement(u[h]);for(;a.firstChild;)p.appendChild(a.firstChild);a.appendChild(p),d++}c=a.firstChild}c&&c.nodeType==1&&c.setAttribute("data-pm-slice",`${i} ${o}${d?` -${d}`:""} ${JSON.stringify(t)}`);let f=r.someProp("clipboardTextSerializer",h=>h(e,r))||e.content.textBetween(0,e.content.size,`
4
-
5
- `);return{dom:a,text:f,slice:e}}function Bs(r,e,t,n,i){let o=i.parent.type.spec.code,s,l;if(!t&&!e)return null;let a=!!e&&(n||o||!t);if(a){if(r.someProp("transformPastedText",f=>{e=f(e,o||n,r)}),o)return l=new m.Slice(m.Fragment.from(r.state.schema.text(e.replace(/\r\n?/g,`
6
- `))),0,0),r.someProp("transformPasted",f=>{l=f(l,r,!0)}),l;let d=r.someProp("clipboardTextParser",f=>f(e,i,n,r));if(d)l=d;else{let f=i.marks(),{schema:h}=r.state,p=m.DOMSerializer.fromSchema(h);s=document.createElement("div"),e.split(/(?:\r\n?|\n)+/).forEach(b=>{let y=s.appendChild(document.createElement("p"));b&&y.appendChild(p.serializeNode(h.text(b,f)))})}}else r.someProp("transformPastedHTML",d=>{t=d(t,r)}),s=gc(t),Qt&&bc(s);let c=s&&s.querySelector("[data-pm-slice]"),u=c&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(c.getAttribute("data-pm-slice")||"");if(u&&u[3])for(let d=+u[3];d>0;d--){let f=s.firstChild;for(;f&&f.nodeType!=1;)f=f.nextSibling;if(!f)break;s=f}if(l||(l=(r.someProp("clipboardParser")||r.someProp("domParser")||m.DOMParser.fromSchema(r.state.schema)).parseSlice(s,{preserveWhitespace:!!(a||u),context:i,ruleFromNode(f){return f.nodeName=="BR"&&!f.nextSibling&&f.parentNode&&!hc.test(f.parentNode.nodeName)?{ignore:!0}:null}})),u)l=yc(yo(l,+u[1],+u[2]),u[4]);else if(l=m.Slice.maxOpen(pc(l.content,i),!0),l.openStart||l.openEnd){let d=0,f=0;for(let h=l.content.firstChild;d<l.openStart&&!h.type.spec.isolating;d++,h=h.firstChild);for(let h=l.content.lastChild;f<l.openEnd&&!h.type.spec.isolating;f++,h=h.lastChild);l=yo(l,d,f)}return r.someProp("transformPasted",d=>{l=d(l,r,a)}),l}const hc=/^(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;function pc(r,e){if(r.childCount<2)return r;for(let t=e.depth;t>=0;t--){let i=e.node(t).contentMatchAt(e.index(t)),o,s=[];if(r.forEach(l=>{if(!s)return;let a=i.findWrapping(l.type),c;if(!a)return s=null;if(c=s.length&&o.length&&Vs(a,o,l,s[s.length-1],0))s[s.length-1]=c;else{s.length&&(s[s.length-1]=Hs(s[s.length-1],o.length));let u=_s(l,a);s.push(u),i=i.matchType(u.type),o=a}}),s)return m.Fragment.from(s)}return r}function _s(r,e,t=0){for(let n=e.length-1;n>=t;n--)r=e[n].create(null,m.Fragment.from(r));return r}function Vs(r,e,t,n,i){if(i<r.length&&i<e.length&&r[i]==e[i]){let o=Vs(r,e,t,n.lastChild,i+1);if(o)return n.copy(n.content.replaceChild(n.childCount-1,o));if(n.contentMatchAt(n.childCount).matchType(i==r.length-1?t.type:r[i+1]))return n.copy(n.content.append(m.Fragment.from(_s(t,r,i+1))))}}function Hs(r,e){if(e==0)return r;let t=r.content.replaceChild(r.childCount-1,Hs(r.lastChild,e-1)),n=r.contentMatchAt(r.childCount).fillBefore(m.Fragment.empty,!0);return r.copy(t.append(n))}function Br(r,e,t,n,i,o){let s=e<0?r.firstChild:r.lastChild,l=s.content;return r.childCount>1&&(o=0),i<n-1&&(l=Br(l,e,t,n,i+1,o)),i>=t&&(l=e<0?s.contentMatchAt(0).fillBefore(l,o<=i).append(l):l.append(s.contentMatchAt(s.childCount).fillBefore(m.Fragment.empty,!0))),r.replaceChild(e<0?0:r.childCount-1,s.copy(l))}function yo(r,e,t){return e<r.openStart&&(r=new m.Slice(Br(r.content,-1,e,r.openStart,0,r.openEnd),e,r.openEnd)),t<r.openEnd&&(r=new m.Slice(Br(r.content,1,t,r.openEnd,0,0),r.openStart,t)),r}const Ws={thead:["table"],tbody:["table"],tfoot:["table"],caption:["table"],colgroup:["table"],col:["table","colgroup"],tr:["table","tbody"],td:["table","tbody","tr"],th:["table","tbody","tr"]};let So=null;function Us(){return So||(So=document.implementation.createHTMLDocument("title"))}let ar=null;function mc(r){let e=window.trustedTypes;return e?(ar||(ar=e.defaultPolicy||e.createPolicy("ProseMirrorClipboard",{createHTML:t=>t})),ar.createHTML(r)):r}function gc(r){let e=/^(\s*<meta [^>]*>)*/.exec(r);e&&(r=r.slice(e[0].length));let t=Us().createElement("div"),n=/<([a-z][^>\s]+)/i.exec(r),i;if((i=n&&Ws[n[1].toLowerCase()])&&(r=i.map(o=>"<"+o+">").join("")+r+i.map(o=>"</"+o+">").reverse().join("")),t.innerHTML=mc(r),i)for(let o=0;o<i.length;o++)t=t.querySelector(i[o])||t;return t}function bc(r){let e=r.querySelectorAll(J?"span:not([class]):not([style])":"span.Apple-converted-space");for(let t=0;t<e.length;t++){let n=e[t];n.childNodes.length==1&&n.textContent==" "&&n.parentNode&&n.parentNode.replaceChild(r.ownerDocument.createTextNode(" "),n)}}function yc(r,e){if(!r.size)return r;let t=r.content.firstChild.type.schema,n;try{n=JSON.parse(e)}catch{return r}let{content:i,openStart:o,openEnd:s}=r;for(let l=n.length-2;l>=0;l-=2){let a=t.nodes[n[l]];if(!a||a.hasRequiredAttrs())break;i=m.Fragment.from(a.create(n[l+1],i)),o++,s++}return new m.Slice(i,o,s)}const le={},ae={},Sc={touchstart:!0,touchmove:!0};class kc{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:"",button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}}function Tc(r){for(let e in le){let t=le[e];r.dom.addEventListener(e,r.input.eventHandlers[e]=n=>{Mc(r,n)&&!li(r,n)&&(r.editable||!(n.type in ae))&&t(r,n)},Sc[e]?{passive:!0}:void 0)}ne&&r.dom.addEventListener("input",()=>null),_r(r)}function Ge(r,e){r.input.lastSelectionOrigin=e,r.input.lastSelectionTime=Date.now()}function Cc(r){r.domObserver.stop();for(let e in r.input.eventHandlers)r.dom.removeEventListener(e,r.input.eventHandlers[e]);clearTimeout(r.input.composingTimeout),clearTimeout(r.input.lastIOSEnterFallbackTimeout)}function _r(r){r.someProp("handleDOMEvents",e=>{for(let t in e)r.input.eventHandlers[t]||r.dom.addEventListener(t,r.input.eventHandlers[t]=n=>li(r,n))})}function li(r,e){return r.someProp("handleDOMEvents",t=>{let n=t[e.type];return n?n(r,e)||e.defaultPrevented:!1})}function Mc(r,e){if(!e.bubbles)return!0;if(e.defaultPrevented)return!1;for(let t=e.target;t!=r.dom;t=t.parentNode)if(!t||t.nodeType==11||t.pmViewDesc&&t.pmViewDesc.stopEvent(e))return!1;return!0}function xc(r,e){!li(r,e)&&le[e.type]&&(r.editable||!(e.type in ae))&&le[e.type](r,e)}ae.keydown=(r,e)=>{let t=e;if(r.input.shiftKey=t.keyCode==16||t.shiftKey,!qs(r,t)&&(r.input.lastKeyCode=t.keyCode,r.input.lastKeyCodeTime=Date.now(),!(ze&&J&&t.keyCode==13)))if(t.keyCode!=229&&r.domObserver.forceFlush(),Nt&&t.keyCode==13&&!t.ctrlKey&&!t.altKey&&!t.metaKey){let n=Date.now();r.input.lastIOSEnter=n,r.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{r.input.lastIOSEnter==n&&(r.someProp("handleKeyDown",i=>i(r,nt(13,"Enter"))),r.input.lastIOSEnter=0)},200)}else r.someProp("handleKeyDown",n=>n(r,t))||fc(r,t)?t.preventDefault():Ge(r,"key")};ae.keyup=(r,e)=>{e.keyCode==16&&(r.input.shiftKey=!1)};ae.keypress=(r,e)=>{let t=e;if(qs(r,t)||!t.charCode||t.ctrlKey&&!t.altKey||me&&t.metaKey)return;if(r.someProp("handleKeyPress",i=>i(r,t))){t.preventDefault();return}let n=r.state.selection;if(!(n instanceof O)||!n.$from.sameParent(n.$to)){let i=String.fromCharCode(t.charCode),o=()=>r.state.tr.insertText(i).scrollIntoView();!/[\r\n]/.test(i)&&!r.someProp("handleTextInput",s=>s(r,n.$from.pos,n.$to.pos,i,o))&&r.dispatch(o()),t.preventDefault()}};function In(r){return{left:r.clientX,top:r.clientY}}function Oc(r,e){let t=e.x-r.clientX,n=e.y-r.clientY;return t*t+n*n<100}function ai(r,e,t,n,i){if(n==-1)return!1;let o=r.state.doc.resolve(n);for(let s=o.depth+1;s>0;s--)if(r.someProp(e,l=>s>o.depth?l(r,t,o.nodeAfter,o.before(s),i,!0):l(r,t,o.node(s),o.before(s),i,!1)))return!0;return!1}function Ot(r,e,t){if(r.focused||r.focus(),r.state.selection.eq(e))return;let n=r.state.tr.setSelection(e);n.setMeta("pointer",!0),r.dispatch(n)}function Ec(r,e){if(e==-1)return!1;let t=r.state.doc.resolve(e),n=t.nodeAfter;return n&&n.isAtom&&M.isSelectable(n)?(Ot(r,new M(t)),!0):!1}function Dc(r,e){if(e==-1)return!1;let t=r.state.selection,n,i;t instanceof M&&(n=t.node);let o=r.state.doc.resolve(e);for(let s=o.depth+1;s>0;s--){let l=s>o.depth?o.nodeAfter:o.node(s);if(M.isSelectable(l)){n&&t.$from.depth>0&&s>=t.$from.depth&&o.before(t.$from.depth+1)==t.$from.pos?i=o.before(t.$from.depth):i=o.before(s);break}}return i!=null?(Ot(r,M.create(r.state.doc,i)),!0):!1}function Nc(r,e,t,n,i){return ai(r,"handleClickOn",e,t,n)||r.someProp("handleClick",o=>o(r,e,n))||(i?Dc(r,t):Ec(r,t))}function wc(r,e,t,n){return ai(r,"handleDoubleClickOn",e,t,n)||r.someProp("handleDoubleClick",i=>i(r,e,n))}function Ac(r,e,t,n){return ai(r,"handleTripleClickOn",e,t,n)||r.someProp("handleTripleClick",i=>i(r,e,n))||vc(r,t,n)}function vc(r,e,t){if(t.button!=0)return!1;let n=r.state.doc;if(e==-1)return n.inlineContent?(Ot(r,O.create(n,0,n.content.size)),!0):!1;let i=n.resolve(e);for(let o=i.depth+1;o>0;o--){let s=o>i.depth?i.nodeAfter:i.node(o),l=i.before(o);if(s.inlineContent)Ot(r,O.create(n,l+1,l+1+s.content.size));else if(M.isSelectable(s))Ot(r,M.create(n,l));else continue;return!0}}function ci(r){return xn(r)}const $s=me?"metaKey":"ctrlKey";le.mousedown=(r,e)=>{let t=e;r.input.shiftKey=t.shiftKey;let n=ci(r),i=Date.now(),o="singleClick";i-r.input.lastClick.time<500&&Oc(t,r.input.lastClick)&&!t[$s]&&r.input.lastClick.button==t.button&&(r.input.lastClick.type=="singleClick"?o="doubleClick":r.input.lastClick.type=="doubleClick"&&(o="tripleClick")),r.input.lastClick={time:i,x:t.clientX,y:t.clientY,type:o,button:t.button};let s=r.posAtCoords(In(t));s&&(o=="singleClick"?(r.input.mouseDown&&r.input.mouseDown.done(),r.input.mouseDown=new Rc(r,s,t,!!n)):(o=="doubleClick"?wc:Ac)(r,s.pos,s.inside,t)?t.preventDefault():Ge(r,"pointer"))};class Rc{constructor(e,t,n,i){this.view=e,this.pos=t,this.event=n,this.flushed=i,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[$s],this.allowDefault=n.shiftKey;let o,s;if(t.inside>-1)o=e.state.doc.nodeAt(t.inside),s=t.inside;else{let u=e.state.doc.resolve(t.pos);o=u.parent,s=u.depth?u.before():0}const l=i?null:n.target,a=l?e.docView.nearestDesc(l,!0):null;this.target=a&&a.nodeDOM.nodeType==1?a.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&o.type.spec.draggable&&o.type.spec.selectable!==!1||c instanceof M&&c.from<=s&&c.to>s)&&(this.mightDrag={node:o,pos:s,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&ye&&!this.target.hasAttribute("contentEditable"))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute("contentEditable","false")},20),this.view.domObserver.start()),e.root.addEventListener("mouseup",this.up=this.up.bind(this)),e.root.addEventListener("mousemove",this.move=this.move.bind(this)),Ge(e,"pointer")}done(){this.view.root.removeEventListener("mouseup",this.up),this.view.root.removeEventListener("mousemove",this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute("draggable"),this.mightDrag.setUneditable&&this.target.removeAttribute("contentEditable"),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>Be(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(In(e))),this.updateAllowDefault(e),this.allowDefault||!t?Ge(this.view,"pointer"):Nc(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||ne&&this.mightDrag&&!this.mightDrag.node.isAtom||J&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(Ot(this.view,D.near(this.view.state.doc.resolve(t.pos))),e.preventDefault()):Ge(this.view,"pointer")}move(e){this.updateAllowDefault(e),Ge(this.view,"pointer"),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}}le.touchstart=r=>{r.input.lastTouch=Date.now(),ci(r),Ge(r,"pointer")};le.touchmove=r=>{r.input.lastTouch=Date.now(),Ge(r,"pointer")};le.contextmenu=r=>ci(r);function qs(r,e){return r.composing?!0:ne&&Math.abs(e.timeStamp-r.input.compositionEndedAt)<500?(r.input.compositionEndedAt=-2e8,!0):!1}const Ic=ze?5e3:-1;ae.compositionstart=ae.compositionupdate=r=>{if(!r.composing){r.domObserver.flush();let{state:e}=r,t=e.selection.$to;if(e.selection instanceof O&&(e.storedMarks||!t.textOffset&&t.parentOffset&&t.nodeBefore.marks.some(n=>n.type.spec.inclusive===!1)||J&&Cs&&Fc(r)))r.markCursor=r.state.storedMarks||t.marks(),xn(r,!0),r.markCursor=null;else if(xn(r,!e.selection.empty),ye&&e.selection.empty&&t.parentOffset&&!t.textOffset&&t.nodeBefore.marks.length){let n=r.domSelectionRange();for(let i=n.focusNode,o=n.focusOffset;i&&i.nodeType==1&&o!=0;){let s=o<0?i.lastChild:i.childNodes[o-1];if(!s)break;if(s.nodeType==3){let l=r.domSelection();l&&l.collapse(s,s.nodeValue.length);break}else i=s,o=-1}}r.input.composing=!0}Ks(r,Ic)};function Fc(r){let{focusNode:e,focusOffset:t}=r.domSelectionRange();if(!e||e.nodeType!=1||t>=e.childNodes.length)return!1;let n=e.childNodes[t];return n.nodeType==1&&n.contentEditable=="false"}ae.compositionend=(r,e)=>{r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=e.timeStamp,r.input.compositionPendingChanges=r.domObserver.pendingRecords().length?r.input.compositionID:0,r.input.compositionNode=null,r.input.badSafariComposition?r.domObserver.forceFlush():r.input.compositionPendingChanges&&Promise.resolve().then(()=>r.domObserver.flush()),r.input.compositionID++,Ks(r,20))};function Ks(r,e){clearTimeout(r.input.composingTimeout),e>-1&&(r.input.composingTimeout=setTimeout(()=>xn(r),e))}function Gs(r){for(r.composing&&(r.input.composing=!1,r.input.compositionEndedAt=Lc());r.input.compositionNodes.length>0;)r.input.compositionNodes.pop().markParentsDirty()}function Pc(r){let e=r.domSelectionRange();if(!e.focusNode)return null;let t=Da(e.focusNode,e.focusOffset),n=Na(e.focusNode,e.focusOffset);if(t&&n&&t!=n){let i=n.pmViewDesc,o=r.domObserver.lastChangedTextNode;if(t==o||n==o)return o;if(!i||!i.isText(n.nodeValue))return n;if(r.input.compositionNode==n){let s=t.pmViewDesc;if(!(!s||!s.isText(t.nodeValue)))return n}}return t||n}function Lc(){let r=document.createEvent("Event");return r.initEvent("event",!0,!0),r.timeStamp}function xn(r,e=!1){if(!(ze&&r.domObserver.flushingSoon>=0)){if(r.domObserver.forceFlush(),Gs(r),e||r.docView&&r.docView.dirty){let t=ii(r),n=r.state.selection;return t&&!t.eq(n)?r.dispatch(r.state.tr.setSelection(t)):(r.markCursor||e)&&!n.$from.node(n.$from.sharedDepth(n.to)).inlineContent?r.dispatch(r.state.tr.deleteSelection()):r.updateState(r.state),!0}return!1}}function zc(r,e){if(!r.dom.parentNode)return;let t=r.dom.parentNode.appendChild(document.createElement("div"));t.appendChild(e),t.style.cssText="position: fixed; left: -10000px; top: 10px";let n=getSelection(),i=document.createRange();i.selectNodeContents(e),r.dom.blur(),n.removeAllRanges(),n.addRange(i),setTimeout(()=>{t.parentNode&&t.parentNode.removeChild(t),r.focus()},50)}const jt=fe&&Je<15||Nt&&Ra<604;le.copy=ae.cut=(r,e)=>{let t=e,n=r.state.selection,i=t.type=="cut";if(n.empty)return;let o=jt?null:t.clipboardData,s=n.content(),{dom:l,text:a}=si(r,s);o?(t.preventDefault(),o.clearData(),o.setData("text/html",l.innerHTML),o.setData("text/plain",a)):zc(r,l),i&&r.dispatch(r.state.tr.deleteSelection().scrollIntoView().setMeta("uiEvent","cut"))};function Bc(r){return r.openStart==0&&r.openEnd==0&&r.content.childCount==1?r.content.firstChild:null}function _c(r,e){if(!r.dom.parentNode)return;let t=r.input.shiftKey||r.state.selection.$from.parent.type.spec.code,n=r.dom.parentNode.appendChild(document.createElement(t?"textarea":"div"));t||(n.contentEditable="true"),n.style.cssText="position: fixed; left: -10000px; top: 10px",n.focus();let i=r.input.shiftKey&&r.input.lastKeyCode!=45;setTimeout(()=>{r.focus(),n.parentNode&&n.parentNode.removeChild(n),t?Yt(r,n.value,null,i,e):Yt(r,n.textContent,n.innerHTML,i,e)},50)}function Yt(r,e,t,n,i){let o=Bs(r,e,t,n,r.state.selection.$from);if(r.someProp("handlePaste",a=>a(r,i,o||m.Slice.empty)))return!0;if(!o)return!1;let s=Bc(o),l=s?r.state.tr.replaceSelectionWith(s,n):r.state.tr.replaceSelection(o);return r.dispatch(l.scrollIntoView().setMeta("paste",!0).setMeta("uiEvent","paste")),!0}function Js(r){let e=r.getData("text/plain")||r.getData("Text");if(e)return e;let t=r.getData("text/uri-list");return t?t.replace(/\r?\n/g," "):""}ae.paste=(r,e)=>{let t=e;if(r.composing&&!ze)return;let n=jt?null:t.clipboardData,i=r.input.shiftKey&&r.input.lastKeyCode!=45;n&&Yt(r,Js(n),n.getData("text/html"),i,t)?t.preventDefault():_c(r,t)};class js{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}}const Vc=me?"altKey":"ctrlKey";function Ys(r,e){let t=r.someProp("dragCopies",n=>!n(e));return t??!e[Vc]}le.dragstart=(r,e)=>{let t=e,n=r.input.mouseDown;if(n&&n.done(),!t.dataTransfer)return;let i=r.state.selection,o=i.empty?null:r.posAtCoords(In(t)),s;if(!(o&&o.pos>=i.from&&o.pos<=(i instanceof M?i.to-1:i.to))){if(n&&n.mightDrag)s=M.create(r.state.doc,n.mightDrag.pos);else if(t.target&&t.target.nodeType==1){let d=r.docView.nearestDesc(t.target,!0);d&&d.node.type.spec.draggable&&d!=r.docView&&(s=M.create(r.state.doc,d.posBefore))}}let l=(s||r.state.selection).content(),{dom:a,text:c,slice:u}=si(r,l);(!t.dataTransfer.files.length||!J||Ts>120)&&t.dataTransfer.clearData(),t.dataTransfer.setData(jt?"Text":"text/html",a.innerHTML),t.dataTransfer.effectAllowed="copyMove",jt||t.dataTransfer.setData("text/plain",c),r.dragging=new js(u,Ys(r,t),s)};le.dragend=r=>{let e=r.dragging;window.setTimeout(()=>{r.dragging==e&&(r.dragging=null)},50)};ae.dragover=ae.dragenter=(r,e)=>e.preventDefault();ae.drop=(r,e)=>{try{Hc(r,e,r.dragging)}finally{r.dragging=null}};function Hc(r,e,t){if(!e.dataTransfer)return;let n=r.posAtCoords(In(e));if(!n)return;let i=r.state.doc.resolve(n.pos),o=t&&t.slice;o?r.someProp("transformPasted",h=>{o=h(o,r,!1)}):o=Bs(r,Js(e.dataTransfer),jt?null:e.dataTransfer.getData("text/html"),!1,i);let s=!!(t&&Ys(r,e));if(r.someProp("handleDrop",h=>h(r,e,o||m.Slice.empty,s))){e.preventDefault();return}if(!o)return;e.preventDefault();let l=o?Qr(r.state.doc,i.pos,o):i.pos;l==null&&(l=i.pos);let a=r.state.tr;if(s){let{node:h}=t;h?h.replace(a):a.deleteSelection()}let c=a.mapping.map(l),u=o.openStart==0&&o.openEnd==0&&o.content.childCount==1,d=a.doc;if(u?a.replaceRangeWith(c,c,o.content.firstChild):a.replaceRange(c,c,o),a.doc.eq(d))return;let f=a.doc.resolve(c);if(u&&M.isSelectable(o.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(o.content.firstChild))a.setSelection(new M(f));else{let h=a.mapping.map(l);a.mapping.maps[a.mapping.maps.length-1].forEach((p,b,y,k)=>h=k),a.setSelection(oi(r,f,a.doc.resolve(h)))}r.focus(),r.dispatch(a.setMeta("uiEvent","drop"))}le.focus=r=>{r.input.lastFocus=Date.now(),r.focused||(r.domObserver.stop(),r.dom.classList.add("ProseMirror-focused"),r.domObserver.start(),r.focused=!0,setTimeout(()=>{r.docView&&r.hasFocus()&&!r.domObserver.currentSelection.eq(r.domSelectionRange())&&Be(r)},20))};le.blur=(r,e)=>{let t=e;r.focused&&(r.domObserver.stop(),r.dom.classList.remove("ProseMirror-focused"),r.domObserver.start(),t.relatedTarget&&r.dom.contains(t.relatedTarget)&&r.domObserver.currentSelection.clear(),r.focused=!1)};le.beforeinput=(r,e)=>{if(J&&ze&&e.inputType=="deleteContentBackward"){r.domObserver.flushSoon();let{domChangeCount:n}=r.input;setTimeout(()=>{if(r.input.domChangeCount!=n||(r.dom.blur(),r.focus(),r.someProp("handleKeyDown",o=>o(r,nt(8,"Backspace")))))return;let{$cursor:i}=r.state.selection;i&&i.pos>0&&r.dispatch(r.state.tr.delete(i.pos-1,i.pos).scrollIntoView())},50)}};for(let r in ae)le[r]=ae[r];function Xt(r,e){if(r==e)return!0;for(let t in r)if(r[t]!==e[t])return!1;for(let t in e)if(!(t in r))return!1;return!0}class On{constructor(e,t){this.toDOM=e,this.spec=t||ot,this.side=this.spec.side||0}map(e,t,n,i){let{pos:o,deleted:s}=e.mapResult(t.from+i,this.side<0?-1:1);return s?null:new W(o-n,o-n,this)}valid(){return!0}eq(e){return this==e||e instanceof On&&(this.spec.key&&this.spec.key==e.spec.key||this.toDOM==e.toDOM&&Xt(this.spec,e.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}}class Ye{constructor(e,t){this.attrs=e,this.spec=t||ot}map(e,t,n,i){let o=e.map(t.from+i,this.spec.inclusiveStart?-1:1)-n,s=e.map(t.to+i,this.spec.inclusiveEnd?1:-1)-n;return o>=s?null:new W(o,s,this)}valid(e,t){return t.from<t.to}eq(e){return this==e||e instanceof Ye&&Xt(this.attrs,e.attrs)&&Xt(this.spec,e.spec)}static is(e){return e.type instanceof Ye}destroy(){}}class ui{constructor(e,t){this.attrs=e,this.spec=t||ot}map(e,t,n,i){let o=e.mapResult(t.from+i,1);if(o.deleted)return null;let s=e.mapResult(t.to+i,-1);return s.deleted||s.pos<=o.pos?null:new W(o.pos-n,s.pos-n,this)}valid(e,t){let{index:n,offset:i}=e.content.findIndex(t.from),o;return i==t.from&&!(o=e.child(n)).isText&&i+o.nodeSize==t.to}eq(e){return this==e||e instanceof ui&&Xt(this.attrs,e.attrs)&&Xt(this.spec,e.spec)}destroy(){}}class W{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(e,t){return new W(e,t,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(e,t,n){return new W(e,e,new On(t,n))}static inline(e,t,n,i){return new W(e,t,new Ye(n,i))}static node(e,t,n,i){return new W(e,t,new ui(n,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Ye}get widget(){return this.type instanceof On}}const Ct=[],ot={};class A{constructor(e,t){this.local=e.length?e:Ct,this.children=t.length?t:Ct}static create(e,t){return t.length?En(t,e,0,ot):Q}find(e,t,n){let i=[];return this.findInner(e??0,t??1e9,i,0,n),i}findInner(e,t,n,i,o){for(let s=0;s<this.local.length;s++){let l=this.local[s];l.from<=t&&l.to>=e&&(!o||o(l.spec))&&n.push(l.copy(l.from+i,l.to+i))}for(let s=0;s<this.children.length;s+=3)if(this.children[s]<t&&this.children[s+1]>e){let l=this.children[s]+1;this.children[s+2].findInner(e-l,t-l,n,i+l,o)}}map(e,t,n){return this==Q||e.maps.length==0?this:this.mapInner(e,t,0,0,n||ot)}mapInner(e,t,n,i,o){let s;for(let l=0;l<this.local.length;l++){let a=this.local[l].map(e,n,i);a&&a.type.valid(t,a)?(s||(s=[])).push(a):o.onRemove&&o.onRemove(this.local[l].spec)}return this.children.length?Wc(this.children,s||[],e,t,n,i,o):s?new A(s.sort(st),Ct):Q}add(e,t){return t.length?this==Q?A.create(e,t):this.addInner(e,t,0):this}addInner(e,t,n){let i,o=0;e.forEach((l,a)=>{let c=a+n,u;if(u=Zs(t,l,c)){for(i||(i=this.children.slice());o<i.length&&i[o]<a;)o+=3;i[o]==a?i[o+2]=i[o+2].addInner(l,u,c+1):i.splice(o,0,a,a+l.nodeSize,En(u,l,c+1,ot)),o+=3}});let s=Xs(o?Qs(t):t,-n);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||s.splice(l--,1);return new A(s.length?this.local.concat(s).sort(st):this.local,i||this.children)}remove(e){return e.length==0||this==Q?this:this.removeInner(e,0)}removeInner(e,t){let n=this.children,i=this.local;for(let o=0;o<n.length;o+=3){let s,l=n[o]+t,a=n[o+1]+t;for(let u=0,d;u<e.length;u++)(d=e[u])&&d.from>l&&d.to<a&&(e[u]=null,(s||(s=[])).push(d));if(!s)continue;n==this.children&&(n=this.children.slice());let c=n[o+2].removeInner(s,l+1);c!=Q?n[o+2]=c:(n.splice(o,3),o-=3)}if(i.length){for(let o=0,s;o<e.length;o++)if(s=e[o])for(let l=0;l<i.length;l++)i[l].eq(s,t)&&(i==this.local&&(i=this.local.slice()),i.splice(l--,1))}return n==this.children&&i==this.local?this:i.length||n.length?new A(i,n):Q}forChild(e,t){if(this==Q)return this;if(t.isLeaf)return A.empty;let n,i;for(let l=0;l<this.children.length;l+=3)if(this.children[l]>=e){this.children[l]==e&&(n=this.children[l+2]);break}let o=e+1,s=o+t.content.size;for(let l=0;l<this.local.length;l++){let a=this.local[l];if(a.from<s&&a.to>o&&a.type instanceof Ye){let c=Math.max(o,a.from)-o,u=Math.min(s,a.to)-o;c<u&&(i||(i=[])).push(a.copy(c,u))}}if(i){let l=new A(i.sort(st),Ct);return n?new $e([l,n]):l}return n||Q}eq(e){if(this==e)return!0;if(!(e instanceof A)||this.local.length!=e.local.length||this.children.length!=e.children.length)return!1;for(let t=0;t<this.local.length;t++)if(!this.local[t].eq(e.local[t]))return!1;for(let t=0;t<this.children.length;t+=3)if(this.children[t]!=e.children[t]||this.children[t+1]!=e.children[t+1]||!this.children[t+2].eq(e.children[t+2]))return!1;return!0}locals(e){return di(this.localsInner(e))}localsInner(e){if(this==Q)return Ct;if(e.inlineContent||!this.local.some(Ye.is))return this.local;let t=[];for(let n=0;n<this.local.length;n++)this.local[n].type instanceof Ye||t.push(this.local[n]);return t}forEachSet(e){e(this)}}A.empty=new A([],[]);A.removeOverlap=di;const Q=A.empty;class $e{constructor(e){this.members=e}map(e,t){const n=this.members.map(i=>i.map(e,t,ot));return $e.from(n)}forChild(e,t){if(t.isLeaf)return A.empty;let n=[];for(let i=0;i<this.members.length;i++){let o=this.members[i].forChild(e,t);o!=Q&&(o instanceof $e?n=n.concat(o.members):n.push(o))}return $e.from(n)}eq(e){if(!(e instanceof $e)||e.members.length!=this.members.length)return!1;for(let t=0;t<this.members.length;t++)if(!this.members[t].eq(e.members[t]))return!1;return!0}locals(e){let t,n=!0;for(let i=0;i<this.members.length;i++){let o=this.members[i].localsInner(e);if(o.length)if(!t)t=o;else{n&&(t=t.slice(),n=!1);for(let s=0;s<o.length;s++)t.push(o[s])}}return t?di(n?t:t.sort(st)):Ct}static from(e){switch(e.length){case 0:return Q;case 1:return e[0];default:return new $e(e.every(t=>t instanceof A)?e:e.reduce((t,n)=>t.concat(n instanceof A?n:n.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}}function Wc(r,e,t,n,i,o,s){let l=r.slice();for(let c=0,u=o;c<t.maps.length;c++){let d=0;t.maps[c].forEach((f,h,p,b)=>{let y=b-p-(h-f);for(let k=0;k<l.length;k+=3){let R=l[k+1];if(R<0||f>R+u-d)continue;let N=l[k]+u-d;h>=N?l[k+1]=f<=N?-2:-1:f>=u&&y&&(l[k]+=y,l[k+1]+=y)}d+=y}),u=t.maps[c].map(u,-1)}let a=!1;for(let c=0;c<l.length;c+=3)if(l[c+1]<0){if(l[c+1]==-2){a=!0,l[c+1]=-1;continue}let u=t.map(r[c]+o),d=u-i;if(d<0||d>=n.content.size){a=!0;continue}let f=t.map(r[c+1]+o,-1),h=f-i,{index:p,offset:b}=n.content.findIndex(d),y=n.maybeChild(p);if(y&&b==d&&b+y.nodeSize==h){let k=l[c+2].mapInner(t,y,u+1,r[c]+o+1,s);k!=Q?(l[c]=d,l[c+1]=h,l[c+2]=k):(l[c+1]=-2,a=!0)}else a=!0}if(a){let c=Uc(l,r,e,t,i,o,s),u=En(c,n,0,s);e=u.local;for(let d=0;d<l.length;d+=3)l[d+1]<0&&(l.splice(d,3),d-=3);for(let d=0,f=0;d<u.children.length;d+=3){let h=u.children[d];for(;f<l.length&&l[f]<h;)f+=3;l.splice(f,0,u.children[d],u.children[d+1],u.children[d+2])}}return new A(e.sort(st),l)}function Xs(r,e){if(!e||!r.length)return r;let t=[];for(let n=0;n<r.length;n++){let i=r[n];t.push(new W(i.from+e,i.to+e,i.type))}return t}function Uc(r,e,t,n,i,o,s){function l(a,c){for(let u=0;u<a.local.length;u++){let d=a.local[u].map(n,i,c);d?t.push(d):s.onRemove&&s.onRemove(a.local[u].spec)}for(let u=0;u<a.children.length;u+=3)l(a.children[u+2],a.children[u]+c+1)}for(let a=0;a<r.length;a+=3)r[a+1]==-1&&l(r[a+2],e[a]+o+1);return t}function Zs(r,e,t){if(e.isLeaf)return null;let n=t+e.nodeSize,i=null;for(let o=0,s;o<r.length;o++)(s=r[o])&&s.from>t&&s.to<n&&((i||(i=[])).push(s),r[o]=null);return i}function Qs(r){let e=[];for(let t=0;t<r.length;t++)r[t]!=null&&e.push(r[t]);return e}function En(r,e,t,n){let i=[],o=!1;e.forEach((l,a)=>{let c=Zs(r,l,a+t);if(c){o=!0;let u=En(c,l,t+a+1,n);u!=Q&&i.push(a,a+l.nodeSize,u)}});let s=Xs(o?Qs(r):r,-t).sort(st);for(let l=0;l<s.length;l++)s[l].type.valid(e,s[l])||(n.onRemove&&n.onRemove(s[l].spec),s.splice(l--,1));return s.length||i.length?new A(s,i):Q}function st(r,e){return r.from-e.from||r.to-e.to}function di(r){let e=r;for(let t=0;t<e.length-1;t++){let n=e[t];if(n.from!=n.to)for(let i=t+1;i<e.length;i++){let o=e[i];if(o.from==n.from){o.to!=n.to&&(e==r&&(e=r.slice()),e[i]=o.copy(o.from,n.to),ko(e,i+1,o.copy(n.to,o.to)));continue}else{o.from<n.to&&(e==r&&(e=r.slice()),e[t]=n.copy(n.from,o.from),ko(e,i,n.copy(o.from,n.to)));break}}}return e}function ko(r,e,t){for(;e<r.length&&st(t,r[e])>0;)e++;r.splice(e,0,t)}function cr(r){let e=[];return r.someProp("decorations",t=>{let n=t(r.state);n&&n!=Q&&e.push(n)}),r.cursorWrapper&&e.push(A.create(r.state.doc,[r.cursorWrapper.deco])),$e.from(e)}const $c={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},qc=fe&&Je<=11;class Kc{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}}class Gc{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new Kc,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(n=>{for(let i=0;i<n.length;i++)this.queue.push(n[i]);fe&&Je<=11&&n.some(i=>i.type=="childList"&&i.removedNodes.length||i.type=="characterData"&&i.oldValue.length>i.target.nodeValue.length)?this.flushSoon():ne&&e.composing&&n.some(i=>i.type=="childList"&&i.target.nodeName=="TR")?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),qc&&(this.onCharData=n=>{this.queue.push({target:n.target,type:"characterData",oldValue:n.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,$c)),this.onCharData&&this.view.dom.addEventListener("DOMCharacterDataModified",this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener("DOMCharacterDataModified",this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener("selectionchange",this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener("selectionchange",this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(fo(this.view)){if(this.suppressingSelectionUpdates)return Be(this.view);if(fe&&Je<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&ct(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let o=e.focusNode;o;o=Dt(o))t.add(o);for(let o=e.anchorNode;o;o=Dt(o))if(t.has(o)){n=o;break}let i=n&&this.view.docView.nearestDesc(n);if(i&&i.ignoreMutation({type:"selection",target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),i=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&fo(e)&&!this.ignoreSelectionChange(n),o=-1,s=-1,l=!1,a=[];if(e.editable)for(let u=0;u<t.length;u++){let d=this.registerMutation(t[u],a);d&&(o=o<0?d.from:Math.min(d.from,o),s=s<0?d.to:Math.max(d.to,s),d.typeOver&&(l=!0))}if(a.some(u=>u.nodeName=="BR")&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let u of a)if(u.nodeName=="BR"&&u.parentNode){let d=u.nextSibling;d&&d.nodeType==1&&d.contentEditable=="false"&&u.parentNode.removeChild(u)}}else if(ye&&a.length){let u=a.filter(d=>d.nodeName=="BR");if(u.length==2){let[d,f]=u;d.parentNode&&d.parentNode.parentNode==f.parentNode?f.remove():d.remove()}else{let{focusNode:d}=this.currentSelection;for(let f of u){let h=f.parentNode;h&&h.nodeName=="LI"&&(!d||Yc(e,d)!=h)&&f.remove()}}}let c=null;o<0&&i&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&vn(n)&&(c=ii(e))&&c.eq(D.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,Be(e),this.currentSelection.set(n),e.scrollToSelection()):(o>-1||i)&&(o>-1&&(e.docView.markDirty(o,s),Jc(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,Xc(e,a)),this.handleDOMChange(o,s,l,a),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||Be(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type=="attributes"&&(n==this.view.docView||e.attributeName=="contenteditable"||e.attributeName=="style"&&!e.oldValue&&!e.target.getAttribute("style"))||!n||n.ignoreMutation(e))return null;if(e.type=="childList"){for(let u=0;u<e.addedNodes.length;u++){let d=e.addedNodes[u];t.push(d),d.nodeType==3&&(this.lastChangedTextNode=d)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let i=e.previousSibling,o=e.nextSibling;if(fe&&Je<=11&&e.addedNodes.length)for(let u=0;u<e.addedNodes.length;u++){let{previousSibling:d,nextSibling:f}=e.addedNodes[u];(!d||Array.prototype.indexOf.call(e.addedNodes,d)<0)&&(i=d),(!f||Array.prototype.indexOf.call(e.addedNodes,f)<0)&&(o=f)}let s=i&&i.parentNode==e.target?K(i)+1:0,l=n.localPosFromDOM(e.target,s,-1),a=o&&o.parentNode==e.target?K(o):e.target.childNodes.length,c=n.localPosFromDOM(e.target,a,1);return{from:l,to:c}}else return e.type=="attributes"?{from:n.posAtStart-n.border,to:n.posAtEnd+n.border}:(this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue})}}let To=new WeakMap,Co=!1;function Jc(r){if(!To.has(r)&&(To.set(r,null),["normal","nowrap","pre-line"].indexOf(getComputedStyle(r.dom).whiteSpace)!==-1)){if(r.requiresGeckoHackNode=ye,Co)return;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."),Co=!0}}function Mo(r,e){let t=e.startContainer,n=e.startOffset,i=e.endContainer,o=e.endOffset,s=r.domAtPos(r.state.selection.anchor);return ct(s.node,s.offset,i,o)&&([t,n,i,o]=[i,o,t,n]),{anchorNode:t,anchorOffset:n,focusNode:i,focusOffset:o}}function jc(r,e){if(e.getComposedRanges){let i=e.getComposedRanges(r.root)[0];if(i)return Mo(r,i)}let t;function n(i){i.preventDefault(),i.stopImmediatePropagation(),t=i.getTargetRanges()[0]}return r.dom.addEventListener("beforeinput",n,!0),document.execCommand("indent"),r.dom.removeEventListener("beforeinput",n,!0),t?Mo(r,t):null}function Yc(r,e){for(let t=e.parentNode;t&&t!=r.dom;t=t.parentNode){let n=r.docView.nearestDesc(t,!0);if(n&&n.node.isBlock)return t}return null}function Xc(r,e){var t;let{focusNode:n,focusOffset:i}=r.domSelectionRange();for(let o of e)if(((t=o.parentNode)===null||t===void 0?void 0:t.nodeName)=="TR"){let s=o.nextSibling;for(;s&&s.nodeName!="TD"&&s.nodeName!="TH";)s=s.nextSibling;if(s){let l=s;for(;;){let a=l.firstChild;if(!a||a.nodeType!=1||a.contentEditable=="false"||/^(BR|IMG)$/.test(a.nodeName))break;l=a}l.insertBefore(o,l.firstChild),n==o&&r.domSelection().collapse(o,i)}else o.parentNode.removeChild(o)}}function Zc(r,e,t){let{node:n,fromOffset:i,toOffset:o,from:s,to:l}=r.docView.parseRange(e,t),a=r.domSelectionRange(),c,u=a.anchorNode;if(u&&r.dom.contains(u.nodeType==1?u:u.parentNode)&&(c=[{node:u,offset:a.anchorOffset}],vn(a)||c.push({node:a.focusNode,offset:a.focusOffset})),J&&r.input.lastKeyCode===8)for(let y=o;y>i;y--){let k=n.childNodes[y-1],R=k.pmViewDesc;if(k.nodeName=="BR"&&!R){o=y;break}if(!R||R.size)break}let d=r.state.doc,f=r.someProp("domParser")||m.DOMParser.fromSchema(r.state.schema),h=d.resolve(s),p=null,b=f.parse(n,{topNode:h.parent,topMatch:h.parent.contentMatchAt(h.index()),topOpen:!0,from:i,to:o,preserveWhitespace:h.parent.type.whitespace=="pre"?"full":!0,findPositions:c,ruleFromNode:Qc,context:h});if(c&&c[0].pos!=null){let y=c[0].pos,k=c[1]&&c[1].pos;k==null&&(k=y),p={anchor:y+s,head:k+s}}return{doc:b,sel:p,from:s,to:l}}function Qc(r){let e=r.pmViewDesc;if(e)return e.parseRule();if(r.nodeName=="BR"&&r.parentNode){if(ne&&/^(ul|ol)$/i.test(r.parentNode.nodeName)){let t=document.createElement("div");return t.appendChild(document.createElement("li")),{skip:t}}else if(r.parentNode.lastChild==r||ne&&/^(tr|table)$/i.test(r.parentNode.nodeName))return{ignore:!0}}else if(r.nodeName=="IMG"&&r.getAttribute("mark-placeholder"))return{ignore:!0};return null}const eu=/^(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;function tu(r,e,t,n,i){let o=r.input.compositionPendingChanges||(r.composing?r.input.compositionID:0);if(r.input.compositionPendingChanges=0,e<0){let E=r.input.lastSelectionTime>Date.now()-50?r.input.lastSelectionOrigin:null,P=ii(r,E);if(P&&!r.state.selection.eq(P)){if(J&&ze&&r.input.lastKeyCode===13&&Date.now()-100<r.input.lastKeyCodeTime&&r.someProp("handleKeyDown",Bn=>Bn(r,nt(13,"Enter"))))return;let X=r.state.tr.setSelection(P);E=="pointer"?X.setMeta("pointer",!0):E=="key"&&X.scrollIntoView(),o&&X.setMeta("composition",o),r.dispatch(X)}return}let s=r.state.doc.resolve(e),l=s.sharedDepth(t);e=s.before(l+1),t=r.state.doc.resolve(t).after(l+1);let a=r.state.selection,c=Zc(r,e,t),u=r.state.doc,d=u.slice(c.from,c.to),f,h;r.input.lastKeyCode===8&&Date.now()-100<r.input.lastKeyCodeTime?(f=r.state.selection.to,h="end"):(f=r.state.selection.from,h="start"),r.input.lastKeyCode=null;let p=iu(d.content,c.doc.content,c.from,f,h);if(p&&r.input.domChangeCount++,(Nt&&r.input.lastIOSEnter>Date.now()-225||ze)&&i.some(E=>E.nodeType==1&&!eu.test(E.nodeName))&&(!p||p.endA>=p.endB)&&r.someProp("handleKeyDown",E=>E(r,nt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(!p)if(n&&a instanceof O&&!a.empty&&a.$head.sameParent(a.$anchor)&&!r.composing&&!(c.sel&&c.sel.anchor!=c.sel.head))p={start:a.from,endA:a.to,endB:a.to};else{if(c.sel){let E=xo(r,r.state.doc,c.sel);if(E&&!E.eq(r.state.selection)){let P=r.state.tr.setSelection(E);o&&P.setMeta("composition",o),r.dispatch(P)}}return}r.state.selection.from<r.state.selection.to&&p.start==p.endB&&r.state.selection instanceof O&&(p.start>r.state.selection.from&&p.start<=r.state.selection.from+2&&r.state.selection.from>=c.from?p.start=r.state.selection.from:p.endA<r.state.selection.to&&p.endA>=r.state.selection.to-2&&r.state.selection.to<=c.to&&(p.endB+=r.state.selection.to-p.endA,p.endA=r.state.selection.to)),fe&&Je<=11&&p.endB==p.start+1&&p.endA==p.start&&p.start>c.from&&c.doc.textBetween(p.start-c.from-1,p.start-c.from+1)=="  "&&(p.start--,p.endA--,p.endB--);let b=c.doc.resolveNoCache(p.start-c.from),y=c.doc.resolveNoCache(p.endB-c.from),k=u.resolve(p.start),R=b.sameParent(y)&&b.parent.inlineContent&&k.end()>=p.endA;if((Nt&&r.input.lastIOSEnter>Date.now()-225&&(!R||i.some(E=>E.nodeName=="DIV"||E.nodeName=="P"))||!R&&b.pos<c.doc.content.size&&(!b.sameParent(y)||!b.parent.inlineContent)&&b.pos<y.pos&&!/\S/.test(c.doc.textBetween(b.pos,y.pos,"","")))&&r.someProp("handleKeyDown",E=>E(r,nt(13,"Enter")))){r.input.lastIOSEnter=0;return}if(r.state.selection.anchor>p.start&&ru(u,p.start,p.endA,b,y)&&r.someProp("handleKeyDown",E=>E(r,nt(8,"Backspace")))){ze&&J&&r.domObserver.suppressSelectionUpdates();return}J&&p.endB==p.start&&(r.input.lastChromeDelete=Date.now()),ze&&!R&&b.start()!=y.start()&&y.parentOffset==0&&b.depth==y.depth&&c.sel&&c.sel.anchor==c.sel.head&&c.sel.head==p.endA&&(p.endB-=2,y=c.doc.resolveNoCache(p.endB-c.from),setTimeout(()=>{r.someProp("handleKeyDown",function(E){return E(r,nt(13,"Enter"))})},20));let N=p.start,w=p.endA,Ce=E=>{let P=E||r.state.tr.replace(N,w,c.doc.slice(p.start-c.from,p.endB-c.from));if(c.sel){let X=xo(r,P.doc,c.sel);X&&!(J&&r.composing&&X.empty&&(p.start!=p.endB||r.input.lastChromeDelete<Date.now()-100)&&(X.head==N||X.head==P.mapping.map(w)-1)||fe&&X.empty&&X.head==N)&&P.setSelection(X)}return o&&P.setMeta("composition",o),P.scrollIntoView()},Ve;if(R)if(b.pos==y.pos){fe&&Je<=11&&b.parentOffset==0&&(r.domObserver.suppressSelectionUpdates(),setTimeout(()=>Be(r),20));let E=Ce(r.state.tr.delete(N,w)),P=u.resolve(p.start).marksAcross(u.resolve(p.endA));P&&E.ensureMarks(P),r.dispatch(E)}else if(p.endA==p.endB&&(Ve=nu(b.parent.content.cut(b.parentOffset,y.parentOffset),k.parent.content.cut(k.parentOffset,p.endA-k.start())))){let E=Ce(r.state.tr);Ve.type=="add"?E.addMark(N,w,Ve.mark):E.removeMark(N,w,Ve.mark),r.dispatch(E)}else if(b.parent.child(b.index()).isText&&b.index()==y.index()-(y.textOffset?0:1)){let E=b.parent.textBetween(b.parentOffset,y.parentOffset),P=()=>Ce(r.state.tr.insertText(E,N,w));r.someProp("handleTextInput",X=>X(r,N,w,E,P))||r.dispatch(P())}else r.dispatch(Ce());else r.dispatch(Ce())}function xo(r,e,t){return Math.max(t.anchor,t.head)>e.content.size?null:oi(r,e.resolve(t.anchor),e.resolve(t.head))}function nu(r,e){let t=r.firstChild.marks,n=e.firstChild.marks,i=t,o=n,s,l,a;for(let u=0;u<n.length;u++)i=n[u].removeFromSet(i);for(let u=0;u<t.length;u++)o=t[u].removeFromSet(o);if(i.length==1&&o.length==0)l=i[0],s="add",a=u=>u.mark(l.addToSet(u.marks));else if(i.length==0&&o.length==1)l=o[0],s="remove",a=u=>u.mark(l.removeFromSet(u.marks));else return null;let c=[];for(let u=0;u<e.childCount;u++)c.push(a(e.child(u)));if(m.Fragment.from(c).eq(r))return{mark:l,type:s}}function ru(r,e,t,n,i){if(t-e<=i.pos-n.pos||ur(n,!0,!1)<i.pos)return!1;let o=r.resolve(e);if(!n.parent.isTextblock){let l=o.nodeAfter;return l!=null&&t==e+l.nodeSize}if(o.parentOffset<o.parent.content.size||!o.parent.isTextblock)return!1;let s=r.resolve(ur(o,!0,!0));return!s.parent.isTextblock||s.pos>t||ur(s,!0,!1)<t?!1:n.parent.content.cut(n.parentOffset).eq(s.parent.content)}function ur(r,e,t){let n=r.depth,i=e?r.end():r.pos;for(;n>0&&(e||r.indexAfter(n)==r.node(n).childCount);)n--,i++,e=!1;if(t){let o=r.node(n).maybeChild(r.indexAfter(n));for(;o&&!o.isLeaf;)o=o.firstChild,i++}return i}function iu(r,e,t,n,i){let o=r.findDiffStart(e,t);if(o==null)return null;let{a:s,b:l}=r.findDiffEnd(e,t+r.size,t+e.size);if(i=="end"){let a=Math.max(0,o-Math.min(s,l));n-=s+a-o}if(s<o&&r.size<e.size){let a=n<=o&&n>=s?o-n:0;o-=a,o&&o<e.size&&Oo(e.textBetween(o-1,o+1))&&(o+=a?1:-1),l=o+(l-s),s=o}else if(l<o){let a=n<=o&&n>=l?o-n:0;o-=a,o&&o<r.size&&Oo(r.textBetween(o-1,o+1))&&(o+=a?1:-1),s=o+(s-l),l=o}return{start:o,endA:s,endB:l}}function Oo(r){if(r.length!=2)return!1;let e=r.charCodeAt(0),t=r.charCodeAt(1);return e>=56320&&e<=57343&&t>=55296&&t<=56319}class el{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new kc,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ao),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement("div"),e&&(e.appendChild?e.appendChild(this.dom):typeof e=="function"?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=No(this),Do(this),this.nodeViews=wo(this),this.docView=oo(this.state.doc,Eo(this),cr(this),this.dom,this),this.domObserver=new Gc(this,(n,i,o,s)=>tu(this,n,i,o,s)),this.domObserver.start(),Tc(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&_r(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ao),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let n in this._props)t[n]=this._props[n];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){var n;let i=this.state,o=!1,s=!1;e.storedMarks&&this.composing&&(Gs(this),s=!0),this.state=e;let l=i.plugins!=e.plugins||this._props.plugins!=t.plugins;if(l||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let h=wo(this);su(h,this.nodeViews)&&(this.nodeViews=h,o=!0)}(l||t.handleDOMEvents!=this._props.handleDOMEvents)&&_r(this),this.editable=No(this),Do(this);let a=cr(this),c=Eo(this),u=i.plugins!=e.plugins&&!i.doc.eq(e.doc)?"reset":e.scrollToSelection>i.scrollToSelection?"to selection":"preserve",d=o||!this.docView.matchesNode(e.doc,c,a);(d||!e.selection.eq(i.selection))&&(s=!0);let f=u=="preserve"&&s&&this.dom.style.overflowAnchor==null&&Pa(this);if(s){this.domObserver.stop();let h=d&&(fe||J)&&!this.composing&&!i.selection.empty&&!e.selection.empty&&ou(i.selection,e.selection);if(d){let p=J?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pc(this)),(o||!this.docView.update(e.doc,c,a,this))&&(this.docView.updateOuterDeco(c),this.docView.destroy(),this.docView=oo(e.doc,c,a,this.dom,this)),p&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(h=!0)}h||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&oc(this))?Be(this,h):(Ps(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(i),!((n=this.dragging)===null||n===void 0)&&n.node&&!i.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,i),u=="reset"?this.dom.scrollTop=0:u=="to selection"?this.scrollToSelection():f&&La(f)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))){if(!this.someProp("handleScrollToSelection",t=>t(this)))if(this.state.selection instanceof M){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&Qi(this,t.getBoundingClientRect(),e)}else Qi(this,this.coordsAtPos(this.state.selection.head,1),e)}}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let t=0;t<this.directPlugins.length;t++){let n=this.directPlugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}for(let t=0;t<this.state.plugins.length;t++){let n=this.state.plugins[t];n.spec.view&&this.pluginViews.push(n.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,i=-1;if(this.state.doc.nodeAt(n.from)==n.node)i=n.from;else{let o=n.from+(this.state.doc.content.size-t.doc.content.size);(o>0&&this.state.doc.nodeAt(o))==n.node&&(i=o)}this.dragging=new js(e.slice,e.move,i<0?void 0:M.create(this.state.doc,i))}someProp(e,t){let n=this._props&&this._props[e],i;if(n!=null&&(i=t?t(n):n))return i;for(let s=0;s<this.directPlugins.length;s++){let l=this.directPlugins[s].props[e];if(l!=null&&(i=t?t(l):l))return i}let o=this.state.plugins;if(o)for(let s=0;s<o.length;s++){let l=o[s].props[e];if(l!=null&&(i=t?t(l):l))return i}}hasFocus(){if(fe){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable=="false")return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&za(this.dom),Be(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let t=this.dom.parentNode;t;t=t.parentNode)if(t.nodeType==9||t.nodeType==11&&t.host)return t.getSelection||(Object.getPrototypeOf(t).getSelection=()=>t.ownerDocument.getSelection()),this._root=t}return e||document}updateRoot(){this._root=null}posAtCoords(e){return Wa(this,e)}coordsAtPos(e,t=1){return Ds(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let i=this.docView.posFromDOM(e,t,n);if(i==null)throw new RangeError("DOM position not inside the editor");return i}endOfTextblock(e,t){return Ga(this,t||this.state,e)}pasteHTML(e,t){return Yt(this,"",e,!1,t||new ClipboardEvent("paste"))}pasteText(e,t){return Yt(this,e,null,!0,t||new ClipboardEvent("paste"))}serializeForClipboard(e){return si(this,e)}destroy(){this.docView&&(Cc(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],cr(this),this),this.dom.textContent=""):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Oa())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return xc(this,e)}domSelectionRange(){let e=this.domSelection();return e?ne&&this.root.nodeType===11&&Aa(this.dom.ownerDocument)==this.dom&&jc(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}}el.prototype.dispatch=function(r){let e=this._props.dispatchTransaction;e?e.call(this,r):this.updateState(this.state.apply(r))};function Eo(r){let e=Object.create(null);return e.class="ProseMirror",e.contenteditable=String(r.editable),r.someProp("attributes",t=>{if(typeof t=="function"&&(t=t(r.state)),t)for(let n in t)n=="class"?e.class+=" "+t[n]:n=="style"?e.style=(e.style?e.style+";":"")+t[n]:!e[n]&&n!="contenteditable"&&n!="nodeName"&&(e[n]=String(t[n]))}),e.translate||(e.translate="no"),[W.node(0,r.state.doc.content.size,e)]}function Do(r){if(r.markCursor){let e=document.createElement("img");e.className="ProseMirror-separator",e.setAttribute("mark-placeholder","true"),e.setAttribute("alt",""),r.cursorWrapper={dom:e,deco:W.widget(r.state.selection.from,e,{raw:!0,marks:r.markCursor})}}else r.cursorWrapper=null}function No(r){return!r.someProp("editable",e=>e(r.state)===!1)}function ou(r,e){let t=Math.min(r.$anchor.sharedDepth(r.head),e.$anchor.sharedDepth(e.head));return r.$anchor.start(t)!=e.$anchor.start(t)}function wo(r){let e=Object.create(null);function t(n){for(let i in n)Object.prototype.hasOwnProperty.call(e,i)||(e[i]=n[i])}return r.someProp("nodeViews",t),r.someProp("markViews",t),e}function su(r,e){let t=0,n=0;for(let i in r){if(r[i]!=e[i])return!0;t++}for(let i in e)n++;return t!=n}function Ao(r){if(r.spec.state||r.spec.filterTransaction||r.spec.appendTransaction)throw new RangeError("Plugins passed directly to the view must not have a state component")}class lu{constructor(e){this.specs=e,this.attrs={};for(const t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join("; ")}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}}class au{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(t=>t.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}}const cu=(r,e)=>{const t=e.config[m.impl].schema,n=s=>t.marks[s.type].rank,i=(s,l)=>{if(s.type!==l.type)return!1;const a=s.attrs,c=l.attrs;if(a===c)return!0;if(!a||!c)return!1;const u=Object.keys(a),d=Object.keys(c);if(u.length!==d.length)return!1;for(const f of u)if(a[f]!==c[f])return!1;return!0},o=s=>{const l=[],a=[],c=[l];for(const u of s){const d=[...u.marks??[]].sort((p,b)=>n(p)-n(b));let f=0,h=0;for(;f<a.length&&h<d.length&&i(a[f],d[h]);)f++,h++;for(;a.length>f;)a.pop(),c.pop();for(;h<d.length;){const p=d[h],b=[];c[c.length-1].push({type:"mark",mark:p,children:{type:"fragment",content:b,[m.impl]:e},[m.impl]:e}),a.push(p),c.push(b),h++}c[c.length-1].push({type:"node",node:u,children:o(u.content??[]),[m.impl]:e})}return{type:"fragment",content:l,[m.impl]:e}};return{type:"node",node:r,children:o(r.content),[m.impl]:e}};class uu{constructor(e){this[m.impl]=new du(e)}instantiateEditor(e){return new Ud(this,e)}instantiateView(e,t){return cu(e,{config:this,options:{...t}})}}class du{constructor(e){const t=o=>o.flatMap(s=>s.getFeatures().flatMap(l=>l===s?s:t([l])));this.features=t(e.map(m.getFeatureImpl)),this.featureMap=new Map;for(const o of this.features){if(this.featureMap.has(o.name))throw new Error(`Duplicate feature: ${o.name}`);this.featureMap.set(o.name,o)}this.featureFacadesMap=new Map;for(const o of e){const s=o.constructor,l=m.getFeatureImpl(o),a=this.featureFacadesMap.get(s);a?a.push(l):this.featureFacadesMap.set(s,[l])}if(!this.featureMap.has("RteBase"))throw new Error("RteBase feature is required");if(this.featureMap.has("RteLinkFeature")&&!this.featureMap.has("RteToolbarFeature"))throw new Error("RteToolbarFeature is required for RteLinkFeature");this.textblockAttrs=new lu(m.sortedContributions(this.features.flatMap(o=>o.getTextblockAttrs()))),this.textblockMarks=new au(m.sortedContributions(this.features.flatMap(o=>o.getTextblockMarks())));const n=m.sortedContributions(this.features.flatMap(o=>o.getSchema(this.textblockAttrs,this.textblockMarks))),i={nodes:{},marks:{}};for(const o of n)Object.assign(i.nodes,o.nodes??{}),Object.assign(i.marks,o.marks??{});for(const o of this.textblockMarks.getReferencedNodeNames())if(!(o in i.nodes))throw new Error(`Unknown node "${o}"`);this.schema=new m.Schema(i)}}var Xe={8:"Backspace",9:"Tab",10:"Enter",12:"NumLock",13:"Enter",16:"Shift",17:"Control",18:"Alt",20:"CapsLock",27:"Escape",32:" ",33:"PageUp",34:"PageDown",35:"End",36:"Home",37:"ArrowLeft",38:"ArrowUp",39:"ArrowRight",40:"ArrowDown",44:"PrintScreen",45:"Insert",46:"Delete",59:";",61:"=",91:"Meta",92:"Meta",106:"*",107:"+",108:",",109:"-",110:".",111:"/",144:"NumLock",145:"ScrollLock",160:"Shift",161:"Shift",162:"Control",163:"Control",164:"Alt",165:"Alt",173:"-",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},Dn={48:")",49:"!",50:"@",51:"#",52:"$",53:"%",54:"^",55:"&",56:"*",57:"(",59:":",61:"+",173:"_",186:":",187:"+",188:"<",189:"_",190:">",191:"?",192:"~",219:"{",220:"|",221:"}",222:'"'},fu=typeof navigator<"u"&&/Mac/.test(navigator.platform),hu=typeof navigator<"u"&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent);for(var G=0;G<10;G++)Xe[48+G]=Xe[96+G]=String(G);for(var G=1;G<=24;G++)Xe[G+111]="F"+G;for(var G=65;G<=90;G++)Xe[G]=String.fromCharCode(G+32),Dn[G]=String.fromCharCode(G);for(var dr in Xe)Dn.hasOwnProperty(dr)||(Dn[dr]=Xe[dr]);function pu(r){var e=fu&&r.metaKey&&r.shiftKey&&!r.ctrlKey&&!r.altKey||hu&&r.shiftKey&&r.key&&r.key.length==1||r.key=="Unidentified",t=!e&&r.key||(r.shiftKey?Dn:Xe)[r.keyCode]||r.key||"Unidentified";return t=="Esc"&&(t="Escape"),t=="Del"&&(t="Delete"),t=="Left"&&(t="ArrowLeft"),t=="Up"&&(t="ArrowUp"),t=="Right"&&(t="ArrowRight"),t=="Down"&&(t="ArrowDown"),t}const mu=typeof navigator<"u"&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),gu=typeof navigator<"u"&&/Win/.test(navigator.platform);function bu(r){let e=r.split(/-(?!$)/),t=e[e.length-1];t=="Space"&&(t=" ");let n,i,o,s;for(let l=0;l<e.length-1;l++){let a=e[l];if(/^(cmd|meta|m)$/i.test(a))s=!0;else if(/^a(lt)?$/i.test(a))n=!0;else if(/^(c|ctrl|control)$/i.test(a))i=!0;else if(/^s(hift)?$/i.test(a))o=!0;else if(/^mod$/i.test(a))mu?s=!0:i=!0;else throw new Error("Unrecognized modifier name: "+a)}return n&&(t="Alt-"+t),i&&(t="Ctrl-"+t),s&&(t="Meta-"+t),o&&(t="Shift-"+t),t}function yu(r){let e=Object.create(null);for(let t in r)e[bu(t)]=r[t];return e}function fr(r,e,t=!0){return e.altKey&&(r="Alt-"+r),e.ctrlKey&&(r="Ctrl-"+r),e.metaKey&&(r="Meta-"+r),t&&e.shiftKey&&(r="Shift-"+r),r}function Y(r){return new B({props:{handleKeyDown:tl(r)}})}function tl(r){let e=yu(r);return function(t,n){let i=pu(n),o,s=e[fr(i,n)];if(s&&s(t.state,t.dispatch,t))return!0;if(i.length==1&&i!=" "){if(n.shiftKey){let l=e[fr(i,n,!1)];if(l&&l(t.state,t.dispatch,t))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(gu&&n.ctrlKey&&n.altKey)&&(o=Xe[n.keyCode])&&o!=i){let l=e[fr(o,n)];if(l&&l(t.state,t.dispatch,t))return!0}}return!1}}const nl=(r,e)=>r.selection.empty?!1:(e&&e(r.tr.deleteSelection().scrollIntoView()),!0);function Su(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("backward",r):t.parentOffset>0)?null:t}const ku=(r,e,t)=>{let n=Su(r,t);if(!n)return!1;let i=rl(n);if(!i){let s=n.blockRange(),l=s&&Xr(s);return l==null?!1:(e&&e(r.tr.lift(s,l).scrollIntoView()),!0)}let o=i.nodeBefore;if(cl(r,i,e,-1))return!0;if(n.parent.content.size==0&&(wt(o,"end")||M.isSelectable(o)))for(let s=n.depth;;s--){let l=ei(r.doc,n.before(s),n.after(s),m.Slice.empty);if(l&&l.slice.size<l.to-l.from){if(e){let a=r.tr.step(l);a.setSelection(wt(o,"end")?D.findFrom(a.doc.resolve(a.mapping.map(i.pos,-1)),-1):M.create(a.doc,i.pos-o.nodeSize)),e(a.scrollIntoView())}return!0}if(s==1||n.node(s-1).childCount>1)break}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos-o.nodeSize,i.pos).scrollIntoView()),!0):!1};function wt(r,e,t=!1){for(let n=r;n;n=e=="start"?n.firstChild:n.lastChild){if(n.isTextblock)return!0;if(t&&n.childCount!=1)return!1}return!1}const Tu=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("backward",r):n.parentOffset>0)return!1;o=rl(n)}let s=o&&o.nodeBefore;return!s||!M.isSelectable(s)?!1:(e&&e(r.tr.setSelection(M.create(r.doc,o.pos-s.nodeSize)).scrollIntoView()),!0)};function rl(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){if(r.index(e)>0)return r.doc.resolve(r.before(e+1));if(r.node(e).type.spec.isolating)break}return null}function Cu(r,e){let{$cursor:t}=r.selection;return!t||(e?!e.endOfTextblock("forward",r):t.parentOffset<t.parent.content.size)?null:t}const Mu=(r,e,t)=>{let n=Cu(r,t);if(!n)return!1;let i=il(n);if(!i)return!1;let o=i.nodeAfter;if(cl(r,i,e,1))return!0;if(n.parent.content.size==0&&(wt(o,"start")||M.isSelectable(o))){let s=ei(r.doc,n.before(),n.after(),m.Slice.empty);if(s&&s.slice.size<s.to-s.from){if(e){let l=r.tr.step(s);l.setSelection(wt(o,"start")?D.findFrom(l.doc.resolve(l.mapping.map(i.pos)),1):M.create(l.doc,l.mapping.map(i.pos))),e(l.scrollIntoView())}return!0}}return o.isAtom&&i.depth==n.depth-1?(e&&e(r.tr.delete(i.pos,i.pos+o.nodeSize).scrollIntoView()),!0):!1},xu=(r,e,t)=>{let{$head:n,empty:i}=r.selection,o=n;if(!i)return!1;if(n.parent.isTextblock){if(t?!t.endOfTextblock("forward",r):n.parentOffset<n.parent.content.size)return!1;o=il(n)}let s=o&&o.nodeAfter;return!s||!M.isSelectable(s)?!1:(e&&e(r.tr.setSelection(M.create(r.doc,o.pos)).scrollIntoView()),!0)};function il(r){if(!r.parent.type.spec.isolating)for(let e=r.depth-1;e>=0;e--){let t=r.node(e);if(r.index(e)+1<t.childCount)return r.doc.resolve(r.after(e+1));if(t.type.spec.isolating)break}return null}const ol=(r,e)=>{let{$head:t,$anchor:n}=r.selection;return!t.parent.type.spec.code||!t.sameParent(n)?!1:(e&&e(r.tr.insertText(`
7
- `).scrollIntoView()),!0)};function fi(r){for(let e=0;e<r.edgeCount;e++){let{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}return null}const Ou=(r,e)=>{let{$head:t,$anchor:n}=r.selection;if(!t.parent.type.spec.code||!t.sameParent(n))return!1;let i=t.node(-1),o=t.indexAfter(-1),s=fi(i.contentMatchAt(o));if(!s||!i.canReplaceWith(o,o,s))return!1;if(e){let l=t.after(),a=r.tr.replaceWith(l,l,s.createAndFill());a.setSelection(D.near(a.doc.resolve(l),1)),e(a.scrollIntoView())}return!0},sl=(r,e)=>{let t=r.selection,{$from:n,$to:i}=t;if(t instanceof j||n.parent.inlineContent||i.parent.inlineContent)return!1;let o=fi(i.parent.contentMatchAt(i.indexAfter()));if(!o||!o.isTextblock)return!1;if(e){let s=(!n.parentOffset&&i.index()<i.parent.childCount?n:i).pos,l=r.tr.insert(s,o.createAndFill());l.setSelection(O.create(l.doc,s+1)),e(l.scrollIntoView())}return!0},ll=(r,e)=>{let{$cursor:t}=r.selection;if(!t||t.parent.content.size)return!1;if(t.depth>1&&t.after()!=t.end(-1)){let o=t.before();if(bn(r.doc,o))return e&&e(r.tr.split(o).scrollIntoView()),!0}let n=t.blockRange(),i=n&&Xr(n);return i==null?!1:(e&&e(r.tr.lift(n,i).scrollIntoView()),!0)};function al(r){return(e,t)=>{let{$from:n,$to:i}=e.selection;if(e.selection instanceof M&&e.selection.node.isBlock)return!n.parentOffset||!bn(e.doc,n.pos)?!1:(t&&t(e.tr.split(n.pos).scrollIntoView()),!0);if(!n.depth)return!1;let o=[],s,l,a=!1,c=!1;for(let h=n.depth;;h--)if(n.node(h).isBlock){a=n.end(h)==n.pos+(n.depth-h),c=n.start(h)==n.pos-(n.depth-h),l=fi(n.node(h-1).contentMatchAt(n.indexAfter(h-1)));let b=r&&r(i.parent,a,n);o.unshift(b||(a&&l?{type:l}:null)),s=h;break}else{if(h==1)return!1;o.unshift(null)}let u=e.tr;(e.selection instanceof O||e.selection instanceof j)&&u.deleteSelection();let d=u.mapping.map(n.pos),f=bn(u.doc,d,o.length,o);if(f||(o[0]=l?{type:l}:null,f=bn(u.doc,d,o.length,o)),!f)return!1;if(u.split(d,o.length,o),!a&&c&&n.node(s).type!=l){let h=u.mapping.map(n.before(s)),p=u.doc.resolve(h);l&&n.node(s-1).canReplaceWith(p.index(),p.index()+1,l)&&u.setNodeMarkup(u.mapping.map(n.before(s)),l)}return t&&t(u.scrollIntoView()),!0}}const Eu=al(),Du=(r,e)=>(e&&e(r.tr.setSelection(new j(r.doc))),!0);function Nu(r,e,t){let n=e.nodeBefore,i=e.nodeAfter,o=e.index();return!n||!i||!n.type.compatibleContent(i.type)?!1:!n.content.size&&e.parent.canReplace(o-1,o)?(t&&t(r.tr.delete(e.pos-n.nodeSize,e.pos).scrollIntoView()),!0):!e.parent.canReplace(o,o+1)||!(i.isTextblock||Zr(r.doc,e.pos))?!1:(t&&t(r.tr.join(e.pos).scrollIntoView()),!0)}function cl(r,e,t,n){let i=e.nodeBefore,o=e.nodeAfter,s,l,a=i.type.spec.isolating||o.type.spec.isolating;if(!a&&Nu(r,e,t))return!0;let c=!a&&e.parent.canReplace(e.index(),e.index()+1);if(c&&(s=(l=i.contentMatchAt(i.childCount)).findWrapping(o.type))&&l.matchType(s[0]||o.type).validEnd){if(t){let h=e.pos+o.nodeSize,p=m.Fragment.empty;for(let k=s.length-1;k>=0;k--)p=m.Fragment.from(s[k].create(null,p));p=m.Fragment.from(i.copy(p));let b=r.tr.step(new te(e.pos-1,h,e.pos,h,new m.Slice(p,1,0),s.length,!0)),y=b.doc.resolve(h+2*s.length);y.nodeAfter&&y.nodeAfter.type==i.type&&Zr(b.doc,y.pos)&&b.join(y.pos),t(b.scrollIntoView())}return!0}let u=o.type.spec.isolating||n>0&&a?null:D.findFrom(e,1),d=u&&u.$from.blockRange(u.$to),f=d&&Xr(d);if(f!=null&&f>=e.depth)return t&&t(r.tr.lift(d,f).scrollIntoView()),!0;if(c&&wt(o,"start",!0)&&wt(i,"end")){let h=i,p=[];for(;p.push(h),!h.isTextblock;)h=h.lastChild;let b=o,y=1;for(;!b.isTextblock;b=b.firstChild)y++;if(h.canReplace(h.childCount,h.childCount,b.content)){if(t){let k=m.Fragment.empty;for(let N=p.length-1;N>=0;N--)k=m.Fragment.from(p[N].copy(k));let R=r.tr.step(new te(e.pos-p.length,e.pos+o.nodeSize,e.pos+y,e.pos+o.nodeSize-y,new m.Slice(k,p.length,0),0,!0));t(R.scrollIntoView())}return!0}}return!1}function ul(r){return function(e,t){let n=e.selection,i=r<0?n.$from:n.$to,o=i.depth;for(;i.node(o).isInline;){if(!o)return!1;o--}return i.node(o).isTextblock?(t&&t(e.tr.setSelection(O.create(e.doc,r<0?i.start(o):i.end(o)))),!0):!1}}const wu=ul(-1),Au=ul(1);function vu(r,e,t,n){for(let i=0;i<e.length;i++){let{$from:o,$to:s}=e[i],l=o.depth==0?r.inlineContent&&r.type.allowsMarkType(t):!1;if(r.nodesBetween(o.pos,s.pos,(a,c)=>{if(l)return!1;l=a.inlineContent&&a.type.allowsMarkType(t)}),l)return!0}return!1}function _e(r,e=null,t){return function(n,i){let{empty:o,$cursor:s,ranges:l}=n.selection;if(o&&!s||!vu(n.doc,l,r))return!1;if(i)if(s)r.isInSet(n.storedMarks||s.marks())?i(n.tr.removeStoredMark(r)):i(n.tr.addStoredMark(r.create(e)));else{let a,c=n.tr;a=!l.some(u=>n.doc.rangeHasMark(u.$from.pos,u.$to.pos,r));for(let u=0;u<l.length;u++){let{$from:d,$to:f}=l[u];if(!a)c.removeMark(d.pos,f.pos,r);else{let h=d.pos,p=f.pos,b=d.nodeAfter,y=f.nodeBefore,k=b&&b.isText?/^\s*/.exec(b.text)[0].length:0,R=y&&y.isText?/\s*$/.exec(y.text)[0].length:0;h+k<p&&(h+=k,p-=R),c.addMark(h,p,r.create(e))}}i(c.scrollIntoView())}return!0}}function Ru(r,e){return t=>{if(!t.isGeneric)return r(t);let n=[];for(let o=0;o<t.mapping.maps.length;o++){let s=t.mapping.maps[o];for(let l=0;l<n.length;l++)n[l]=s.map(n[l]);s.forEach((l,a,c,u)=>n.push(c,u))}let i=[];for(let o=0;o<n.length;o+=2){let s=n[o],l=n[o+1],a=t.doc.resolve(s),c=a.sharedDepth(l),u=a.node(c);for(let d=a.indexAfter(c),f=a.after(c+1);f<=l;++d){let h=u.maybeChild(d);if(!h)break;if(d&&i.indexOf(f)==-1){let p=u.child(d-1);p.type==h.type&&e(p,h)&&i.push(f)}f+=h.nodeSize}}i.sort((o,s)=>o-s);for(let o=i.length-1;o>=0;o--)Zr(t.doc,i[o])&&t.join(i[o]);r(t)}}function Iu(r,e){let t=Array.isArray(e)?n=>e.indexOf(n.type.name)>-1:e;return(n,i,o)=>r(n,i&&Ru(i,t),o)}function Fn(...r){return function(e,t,n){for(let i=0;i<r.length;i++)if(r[i](e,t,n))return!0;return!1}}let hr=Fn(nl,ku,Tu),vo=Fn(nl,Mu,xu);const Le={Enter:Fn(ol,sl,ll,Eu),"Mod-Enter":Ou,Backspace:hr,"Mod-Backspace":hr,"Shift-Backspace":hr,Delete:vo,"Mod-Delete":vo,"Mod-a":Du},dl={"Ctrl-h":Le.Backspace,"Alt-Backspace":Le["Mod-Backspace"],"Ctrl-d":Le.Delete,"Ctrl-Alt-Backspace":Le["Mod-Delete"],"Alt-Delete":Le["Mod-Delete"],"Alt-d":Le["Mod-Delete"],"Ctrl-a":wu,"Ctrl-e":Au};for(let r in Le)dl[r]=Le[r];const Fu=typeof navigator<"u"?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<"u"&&os.platform?os.platform()=="darwin":!1,Pu=Fu?dl:Le,Lu='.ProseMirror{position:relative}.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection *::selection{background:transparent}.ProseMirror-hideselection *::-moz-selection{background:transparent}.ProseMirror-hideselection{caret-color:transparent}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";position:absolute;inset:-2px -2px -2px -32px;border:2px solid #8cf;pointer-events:none}img.ProseMirror-separator{display:inline!important;border:none!important;margin:0!important}';function zu(r={}){return new B({view(e){return new Bu(e,r)}})}class Bu{constructor(e,t){var n;this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=(n=t.width)!==null&&n!==void 0?n:1,this.color=t.color===!1?void 0:t.color||"black",this.class=t.class,this.handlers=["dragover","dragend","drop","dragleave"].map(i=>{let o=s=>{this[i](s)};return e.dom.addEventListener(i,o),{name:i,handler:o}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,i=this.editorView.dom,o=i.getBoundingClientRect(),s=o.width/i.offsetWidth,l=o.height/i.offsetHeight;if(t){let d=e.nodeBefore,f=e.nodeAfter;if(d||f){let h=this.editorView.nodeDOM(this.cursorPos-(d?d.nodeSize:0));if(h){let p=h.getBoundingClientRect(),b=d?p.bottom:p.top;d&&f&&(b=(b+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let y=this.width/2*l;n={left:p.left,right:p.right,top:b-y,bottom:b+y}}}}if(!n){let d=this.editorView.coordsAtPos(this.cursorPos),f=this.width/2*s;n={left:d.left-f,right:d.left+f,top:d.top,bottom:d.bottom}}let a=this.editorView.dom.offsetParent;this.element||(this.element=a.appendChild(document.createElement("div")),this.class&&(this.element.className=this.class),this.element.style.cssText="position: absolute; z-index: 50; pointer-events: none;",this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle("prosemirror-dropcursor-block",t),this.element.classList.toggle("prosemirror-dropcursor-inline",!t);let c,u;if(!a||a==document.body&&getComputedStyle(a).position=="static")c=-pageXOffset,u=-pageYOffset;else{let d=a.getBoundingClientRect(),f=d.width/a.offsetWidth,h=d.height/a.offsetHeight;c=d.left-a.scrollLeft*f,u=d.top-a.scrollTop*h}this.element.style.left=(n.left-c)/s+"px",this.element.style.top=(n.top-u)/l+"px",this.element.style.width=(n.right-n.left)/s+"px",this.element.style.height=(n.bottom-n.top)/l+"px"}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),i=n&&n.type.spec.disableDropCursor,o=typeof i=="function"?i(this.editorView,t,e):i;if(t&&!o){let s=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let l=Qr(this.editorView.state.doc,s,this.editorView.dragging.slice);l!=null&&(s=l)}this.setCursor(s),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}}class I extends D{constructor(e){super(e,e)}map(e,t){let n=e.resolve(t.map(this.head));return I.valid(n)?new I(n):D.near(n)}content(){return m.Slice.empty}eq(e){return e instanceof I&&e.head==this.head}toJSON(){return{type:"gapcursor",pos:this.head}}static fromJSON(e,t){if(typeof t.pos!="number")throw new RangeError("Invalid input for GapCursor.fromJSON");return new I(e.resolve(t.pos))}getBookmark(){return new hi(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!_u(e)||!Vu(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let i=t.contentMatchAt(e.index()).defaultType;return i&&i.isTextblock}static findGapCursorFrom(e,t,n=!1){e:for(;;){if(!n&&I.valid(e))return e;let i=e.pos,o=null;for(let s=e.depth;;s--){let l=e.node(s);if(t>0?e.indexAfter(s)<l.childCount:e.index(s)>0){o=l.child(t>0?e.indexAfter(s):e.index(s)-1);break}else if(s==0)return null;i+=t;let a=e.doc.resolve(i);if(I.valid(a))return a}for(;;){let s=t>0?o.firstChild:o.lastChild;if(!s){if(o.isAtom&&!o.isText&&!M.isSelectable(o)){e=e.doc.resolve(i+o.nodeSize*t),n=!1;continue e}break}o=s,i+=t;let l=e.doc.resolve(i);if(I.valid(l))return l}return null}}}I.prototype.visible=!1;I.findFrom=I.findGapCursorFrom;D.jsonID("gapcursor",I);class hi{constructor(e){this.pos=e}map(e){return new hi(e.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return I.valid(t)?new I(t):D.near(t)}}function fl(r){return r.isAtom||r.spec.isolating||r.spec.createGapCursor}function _u(r){for(let e=r.depth;e>=0;e--){let t=r.index(e),n=r.node(e);if(t==0){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t-1);;i=i.lastChild){if(i.childCount==0&&!i.inlineContent||fl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Vu(r){for(let e=r.depth;e>=0;e--){let t=r.indexAfter(e),n=r.node(e);if(t==n.childCount){if(n.type.spec.isolating)return!0;continue}for(let i=n.child(t);;i=i.firstChild){if(i.childCount==0&&!i.inlineContent||fl(i.type))return!0;if(i.inlineContent)return!1}}return!0}function Hu(){return new B({props:{decorations:qu,createSelectionBetween(r,e,t){return e.pos==t.pos&&I.valid(t)?new I(t):null},handleClick:Uu,handleKeyDown:Wu,handleDOMEvents:{beforeinput:$u}}})}const Wu=tl({ArrowLeft:fn("horiz",-1),ArrowRight:fn("horiz",1),ArrowUp:fn("vert",-1),ArrowDown:fn("vert",1)});function fn(r,e){const t=r=="vert"?e>0?"down":"up":e>0?"right":"left";return function(n,i,o){let s=n.selection,l=e>0?s.$to:s.$from,a=s.empty;if(s instanceof O){if(!o.endOfTextblock(t)||l.depth==0)return!1;a=!1,l=n.doc.resolve(e>0?l.after():l.before())}let c=I.findGapCursorFrom(l,e,a);return c?(i&&i(n.tr.setSelection(new I(c))),!0):!1}}function Uu(r,e,t){if(!r||!r.editable)return!1;let n=r.state.doc.resolve(e);if(!I.valid(n))return!1;let i=r.posAtCoords({left:t.clientX,top:t.clientY});return i&&i.inside>-1&&M.isSelectable(r.state.doc.nodeAt(i.inside))?!1:(r.dispatch(r.state.tr.setSelection(new I(n))),!0)}function $u(r,e){if(e.inputType!="insertCompositionText"||!(r.state.selection instanceof I))return!1;let{$from:t}=r.state.selection,n=t.parent.contentMatchAt(t.index()).findWrapping(r.state.schema.nodes.text);if(!n)return!1;let i=m.Fragment.empty;for(let s=n.length-1;s>=0;s--)i=m.Fragment.from(n[s].createAndFill(null,i));let o=r.state.tr.replace(t.pos,t.pos,new m.Slice(i,0,0));return o.setSelection(O.near(o.doc.resolve(t.pos+1))),r.dispatch(o),!1}function qu(r){if(!(r.selection instanceof I))return null;let e=document.createElement("div");return e.className="ProseMirror-gapcursor",A.create(r.doc,[W.widget(r.selection.head,e,{key:"gapcursor"})])}function hl(r){for(let e=0;e<r.edgeCount;e++){const{type:t}=r.edge(e);if(t.isTextblock&&!t.hasRequiredAttrs())return t}throw new Error("No default textblock found.")}const Ku="[data-class=ui-select]{margin-block:-4px;min-inline-size:120px}.ui-divider{block-size:20px}.ui-button-group{display:flex;gap:4px}.ui-tooltip,.ui-menu{display:contents;--_popup-display: contents}.ui-tooltip-wrapper{display:contents}";class pl{constructor(e){this.plugin=new B({state:{init:()=>e,apply:(t,n)=>{const i=t.getMeta(this.plugin);return i!==void 0?i:n}}})}getValue(e){return this.plugin.getState(e.state)}setValue(e,t){e.dispatchTransaction(e.tr.setMeta(this.plugin,t))}}const Gu='.ProseMirror{flex:1;padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none}.ProseMirror-selectednode{--focus-stroke-gap-color: transparent;--focus-border-radius: 2px;position:relative;outline:none}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in srgb,var(--focus-stroke-color, var(--vvd-color-cta-500)),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));position:absolute;display:block;border-radius:var(--focus-border-radius, inherit);block-size:calc(100% + var(--focus-block-size-addition, 4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition, 4px));inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}';var Nn=200,U=function(){};U.prototype.append=function(e){return e.length?(e=U.from(e),!this.length&&e||e.length<Nn&&this.leafAppend(e)||this.length<Nn&&e.leafPrepend(this)||this.appendInner(e)):this};U.prototype.prepend=function(e){return e.length?U.from(e).append(this):this};U.prototype.appendInner=function(e){return new Ju(this,e)};U.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?U.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))};U.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)};U.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)};U.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var i=[];return this.forEach(function(o,s){return i.push(e(o,s))},t,n),i};U.from=function(e){return e instanceof U?e:e&&e.length?new ml(e):U.empty};var ml=(function(r){function e(n){r.call(this),this.values=n}r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e;var t={length:{configurable:!0},depth:{configurable:!0}};return e.prototype.flatten=function(){return this.values},e.prototype.sliceInner=function(i,o){return i==0&&o==this.length?this:new e(this.values.slice(i,o))},e.prototype.getInner=function(i){return this.values[i]},e.prototype.forEachInner=function(i,o,s,l){for(var a=o;a<s;a++)if(i(this.values[a],l+a)===!1)return!1},e.prototype.forEachInvertedInner=function(i,o,s,l){for(var a=o-1;a>=s;a--)if(i(this.values[a],l+a)===!1)return!1},e.prototype.leafAppend=function(i){if(this.length+i.length<=Nn)return new e(this.values.concat(i.flatten()))},e.prototype.leafPrepend=function(i){if(this.length+i.length<=Nn)return new e(i.flatten().concat(this.values))},t.length.get=function(){return this.values.length},t.depth.get=function(){return 0},Object.defineProperties(e.prototype,t),e})(U);U.empty=new ml([]);var Ju=(function(r){function e(t,n){r.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return r&&(e.__proto__=r),e.prototype=Object.create(r&&r.prototype),e.prototype.constructor=e,e.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},e.prototype.getInner=function(n){return n<this.left.length?this.left.get(n):this.right.get(n-this.left.length)},e.prototype.forEachInner=function(n,i,o,s){var l=this.left.length;if(i<l&&this.left.forEachInner(n,i,Math.min(o,l),s)===!1||o>l&&this.right.forEachInner(n,Math.max(i-l,0),Math.min(this.length,o)-l,s+l)===!1)return!1},e.prototype.forEachInvertedInner=function(n,i,o,s){var l=this.left.length;if(i>l&&this.right.forEachInvertedInner(n,i-l,Math.max(o,l)-l,s+l)===!1||o<l&&this.left.forEachInvertedInner(n,Math.min(i,l),o,s)===!1)return!1},e.prototype.sliceInner=function(n,i){if(n==0&&i==this.length)return this;var o=this.left.length;return i<=o?this.left.slice(n,i):n>=o?this.right.slice(n-o,i-o):this.left.slice(n,o).append(this.right.slice(0,i-o))},e.prototype.leafAppend=function(n){var i=this.right.leafAppend(n);if(i)return new e(this.left,i)},e.prototype.leafPrepend=function(n){var i=this.left.leafPrepend(n);if(i)return new e(i,this.right)},e.prototype.appendInner=function(n){return this.left.depth>=Math.max(this.right.depth,n.depth)+1?new e(this.left,new e(this.right,n)):new e(this,n)},e})(U);const ju=500;class xe{constructor(e,t){this.items=e,this.eventCount=t}popEvent(e,t){if(this.eventCount==0)return null;let n=this.items.length;for(;;n--)if(this.items.get(n-1).selection){--n;break}let i,o;t&&(i=this.remapping(n,this.items.length),o=i.maps.length);let s=e.tr,l,a,c=[],u=[];return this.items.forEach((d,f)=>{if(!d.step){i||(i=this.remapping(n,f+1),o=i.maps.length),o--,u.push(d);return}if(i){u.push(new Ne(d.map));let h=d.step.map(i.slice(o)),p;h&&s.maybeStep(h).doc&&(p=s.mapping.maps[s.mapping.maps.length-1],c.push(new Ne(p,void 0,void 0,c.length+u.length))),o--,p&&i.appendMap(p,o)}else s.maybeStep(d.step);if(d.selection)return l=i?d.selection.map(i.slice(o)):d.selection,a=new xe(this.items.slice(0,n).append(u.reverse().concat(c)),this.eventCount-1),!1},this.items.length,0),{remaining:a,transform:s,selection:l}}addTransform(e,t,n,i){let o=[],s=this.eventCount,l=this.items,a=!i&&l.length?l.get(l.length-1):null;for(let u=0;u<e.steps.length;u++){let d=e.steps[u].invert(e.docs[u]),f=new Ne(e.mapping.maps[u],d,t),h;(h=a&&a.merge(f))&&(f=h,u?o.pop():l=l.slice(0,l.length-1)),o.push(f),t&&(s++,t=void 0),i||(a=f)}let c=s-n.depth;return c>Xu&&(l=Yu(l,c),s-=c),new xe(l.append(o),s)}remapping(e,t){let n=new Gt;return this.items.forEach((i,o)=>{let s=i.mirrorOffset!=null&&o-i.mirrorOffset>=e?n.maps.length-i.mirrorOffset:void 0;n.appendMap(i.map,s)},e,t),n}addMaps(e){return this.eventCount==0?this:new xe(this.items.append(e.map(t=>new Ne(t))),this.eventCount)}rebased(e,t){if(!this.eventCount)return this;let n=[],i=Math.max(0,this.items.length-t),o=e.mapping,s=e.steps.length,l=this.eventCount;this.items.forEach(f=>{f.selection&&l--},i);let a=t;this.items.forEach(f=>{let h=o.getMirror(--a);if(h==null)return;s=Math.min(s,h);let p=o.maps[h];if(f.step){let b=e.steps[h].invert(e.docs[h]),y=f.selection&&f.selection.map(o.slice(a+1,h));y&&l++,n.push(new Ne(p,b,y))}else n.push(new Ne(p))},i);let c=[];for(let f=t;f<s;f++)c.push(new Ne(o.maps[f]));let u=this.items.slice(0,i).append(c).append(n),d=new xe(u,l);return d.emptyItemCount()>ju&&(d=d.compress(this.items.length-n.length)),d}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(e=this.items.length){let t=this.remapping(0,e),n=t.maps.length,i=[],o=0;return this.items.forEach((s,l)=>{if(l>=e)i.push(s),s.selection&&o++;else if(s.step){let a=s.step.map(t.slice(n)),c=a&&a.getMap();if(n--,c&&t.appendMap(c,n),a){let u=s.selection&&s.selection.map(t.slice(n));u&&o++;let d=new Ne(c.invert(),a,u),f,h=i.length-1;(f=i.length&&i[h].merge(d))?i[h]=f:i.push(d)}}else s.map&&n--},this.items.length,0),new xe(U.from(i.reverse()),o)}}xe.empty=new xe(U.empty,0);function Yu(r,e){let t;return r.forEach((n,i)=>{if(n.selection&&e--==0)return t=i,!1}),r.slice(t)}class Ne{constructor(e,t,n,i){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=i}merge(e){if(this.step&&e.step&&!e.selection){let t=e.step.merge(this.step);if(t)return new Ne(t.getMap().invert(),t,this.selection)}}}class Ue{constructor(e,t,n,i,o){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=i,this.prevComposition=o}}const Xu=20;function Zu(r,e,t,n){let i=t.getMeta(lt),o;if(i)return i.historyState;t.getMeta(gl)&&(r=new Ue(r.done,r.undone,null,0,-1));let s=t.getMeta("appendedTransaction");if(t.steps.length==0)return r;if(s&&s.getMeta(lt))return s.getMeta(lt).redo?new Ue(r.done.addTransform(t,void 0,n,yn(e)),r.undone,Ro(t.mapping.maps),r.prevTime,r.prevComposition):new Ue(r.done,r.undone.addTransform(t,void 0,n,yn(e)),null,r.prevTime,r.prevComposition);if(t.getMeta("addToHistory")!==!1&&!(s&&s.getMeta("addToHistory")===!1)){let l=t.getMeta("composition"),a=r.prevTime==0||!s&&r.prevComposition!=l&&(r.prevTime<(t.time||0)-n.newGroupDelay||!Qu(t,r.prevRanges)),c=s?pr(r.prevRanges,t.mapping):Ro(t.mapping.maps);return new Ue(r.done.addTransform(t,a?e.selection.getBookmark():void 0,n,yn(e)),xe.empty,c,t.time,l??r.prevComposition)}else return(o=t.getMeta("rebased"))?new Ue(r.done.rebased(t,o),r.undone.rebased(t,o),pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition):new Ue(r.done.addMaps(t.mapping.maps),r.undone.addMaps(t.mapping.maps),pr(r.prevRanges,t.mapping),r.prevTime,r.prevComposition)}function Qu(r,e){if(!e)return!1;if(!r.docChanged)return!0;let t=!1;return r.mapping.maps[0].forEach((n,i)=>{for(let o=0;o<e.length;o+=2)n<=e[o+1]&&i>=e[o]&&(t=!0)}),t}function Ro(r){let e=[];for(let t=r.length-1;t>=0&&e.length==0;t--)r[t].forEach((n,i,o,s)=>e.push(o,s));return e}function pr(r,e){if(!r)return null;let t=[];for(let n=0;n<r.length;n+=2){let i=e.map(r[n],1),o=e.map(r[n+1],-1);i<=o&&t.push(i,o)}return t}function ed(r,e,t){let n=yn(e),i=lt.get(e).spec.config,o=(t?r.undone:r.done).popEvent(e,n);if(!o)return null;let s=o.selection.resolve(o.transform.doc),l=(t?r.done:r.undone).addTransform(o.transform,e.selection.getBookmark(),i,n),a=new Ue(t?l:o.remaining,t?o.remaining:l,null,0,-1);return o.transform.setSelection(s).setMeta(lt,{redo:t,historyState:a})}let mr=!1,Io=null;function yn(r){let e=r.plugins;if(Io!=e){mr=!1,Io=e;for(let t=0;t<e.length;t++)if(e[t].spec.historyPreserveItems){mr=!0;break}}return mr}function td(r){return r.setMeta(gl,!0)}const lt=new ni("history"),gl=new ni("closeHistory");function nd(r={}){return r={depth:r.depth||100,newGroupDelay:r.newGroupDelay||500},new B({key:lt,state:{init(){return new Ue(xe.empty,xe.empty,null,0,-1)},apply(e,t,n){return Zu(t,n,e,r)}},config:r,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,i=n=="historyUndo"?Sn:n=="historyRedo"?Ut:null;return!i||!e.editable?!1:(t.preventDefault(),i(e.state,e.dispatch))}}}})}function bl(r,e){return(t,n)=>{let i=lt.getState(t);if(!i||(r?i.undone:i.done).eventCount==0)return!1;if(n){let o=ed(i,t,r);o&&n(e?o.scrollIntoView():o)}return!0}}const Sn=bl(!1,!0),Ut=bl(!0,!0),Fo=r=>typeof r=="function",Pn=(r,e,t)=>[r,e,t];class Ln{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return Fo(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(Fo(e)){const n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(const e of this.bindings)e()}bindToEl(e,t={},n=[],i=[]){for(const o in t)this.bindProp(t[o],s=>{e[o]=s});for(const[o,s,l]of n)s&&e.addEventListener(o,l(s));for(const o of i)e.appendChild(o)}}const he=(r,e)=>{const t=document.createElement("div");return r.bindToEl(t,{className:e.className,slot:e.slot},[],e.children),t},rd=(r,e)=>{const t=document.createElement("a");return r.bindToEl(t,{href:e.href,target:e.target,rel:e.rel,className:e.className},[],e.children),t},yl=new WeakMap,Sl=(r,e)=>{const t=r.rte.createComponent(es.Tooltip);t.setAttribute("exportparts","vvd-theme-alternate"),r.bindToEl(t,{className:"ui-tooltip",text:e.label,placement:r.props.popupPlacement}),r.bindProp(e.enabled,i=>{i||(t.open=!1),t.anchor=i?e.anchor:void 0});const n=he(r,{className:"ui-tooltip-wrapper",slot:e.slot,children:[e.anchor,t]});return yl.set(n,e.anchor),n},V=(r,e)=>{const t=()=>r.evalProp(e.variant)??"toolbar",n=()=>t()==="toolbar"?"super-condensed":"condensed",i=()=>t()==="popover-primary"?"outlined":"ghost-light",o=()=>r.evalProp(e.active)?"filled":i(),s=()=>!!(r.evalProp(r.props.disabled)||r.evalProp(e.disabled)),l=r.rte.createComponent(ss.Button);return r.bindToEl(l,{size:n,appearance:o,disabled:s,icon:e.icon,autofocus:e.autofocus,connotation:e.connotation,[e.icon?"ariaLabel":"label"]:e.label},[Pn("click",e.onClick,a=>()=>{a()||r.view.focus()})]),Sl(r,{enabled:()=>!!(r.evalProp(e.icon)&&!r.evalProp(e.noTooltip)&&!s()),label:e.label,anchor:l,slot:e.slot})},pi=(r,e)=>{const t=r.rte.createComponent(ts.Menu);r.bindToEl(t,{className:"ui-menu",autoDismiss:!0,ariaLabel:e.label,anchor:yl.get(e.trigger)??e.trigger,placement:r.props.popupPlacement,offset:()=>r.evalProp(r.props.menuOffset)??null},[],e.children);const n=document.createDocumentFragment();return n.appendChild(e.trigger),n.appendChild(t),n},id=(r,e)=>{const t=()=>!!(r.evalProp(r.props.disabled)||r.evalProp(e.disabled)),n=r.rte.createComponent(ns.MenuItem);return r.bindToEl(n,{text:e.text,checked:e.checked,disabled:t,controlType:"radio",checkedAppearance:"tick-only"},[Pn("change",e.onSelect,i=>()=>{n.checked&&!n.disabled&&r.evalProp(e.checked)!==n.checked&&(i(),r.view.focus())})]),n},od=(r,e)=>he(r,{className:"ui-button-group",children:e.children});function sd(r,e){const{from:t,$from:n,to:i,empty:o}=r.selection;return o?!!e.isInSet(r.storedMarks||n.marks()):r.doc.rangeHasMark(t,i,e)}const tn=(r,e)=>V(r,{label:e.label,icon:e.icon,active:()=>sd(r.view.state,e.markType),disabled:()=>!_e(e.markType)(r.view.state),onClick:()=>{_e(e.markType)(r.view.state,r.view.dispatch)}}),ld=(r,e)=>{const t=()=>!!(r.evalProp(r.props.disabled)||r.evalProp(e.disabled)),n=r.rte.createComponent(Jr.ListboxOption);return r.bindToEl(n,{value:e.value,text:e.text,disabled:t}),n},ad=(r,e)=>{const t=()=>!!r.evalProp(r.props.disabled),n=r.rte.createComponent(Qo.Select);n.setAttribute("data-class","ui-select"),r.bindToEl(n,{placeholder:" ",ariaLabel:e.label,appearance:"ghost",disabled:t},[Pn("change",e.onSelect,o=>()=>{const s=n.value;s&&(o(s),r.view.focus())})],e.children),queueMicrotask(()=>{r.bindProp(e.value,o=>n.value=o)});let i=!1;return n.addEventListener("vwc-popup:open",()=>{i=!0,r.updateBindings()}),n.addEventListener("vwc-popup:close",()=>{i=!1,r.updateBindings()}),Sl(r,{enabled:()=>!i&&!t(),label:e.label,anchor:n})},Vr=r=>{const e=r.rte.createComponent(Yl.Divider);return r.bindToEl(e,{className:"ui-divider",orientation:"vertical"}),e},Po=(r,e)=>{const t=r.rte.createComponent(rs.TextField);return r.bindToEl(t,{label:e.label,value:e.value,placeholder:e.placeholder,slot:e.slot,autofocus:e.autofocus,type:e.type},[Pn("input",e.onInput,n=>()=>{n(t.value)})]),t},Lo=(r,e)=>{const t=document.createTextNode("");return r.bindToEl(t,{textContent:e.text}),t},cd=(r,e)=>{const t=document.createElement("slot");t.name=e.name;let n=null;const i=[];function o(){for(const{el:a,type:c,handler:u}of i)a.removeEventListener(c,u);i.length=0,n=null}for(const[a,c]of Object.entries(e.assignedProps))r.bindProp(c,u=>{n&&(n[a]=u)});function s(a){for(const[c,u]of Object.entries(e.assignedProps))a[c]=r.evalProp(u);for(const[c,u]of Object.entries(e.assignedEvents)){const d=f=>{u(f),r.view.focus()};a.addEventListener(c,d),i.push({el:a,type:c,handler:d})}}const l=()=>{const c=t.assignedElements({flatten:!0})[0];c!==n&&(o(),c&&(n=c,s(c)))};return t.addEventListener("slotchange",l),queueMicrotask(l),t};class ud extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteHistoryFeature"}getPlugins(){return[this.contribution(nd()),this.contribution(Y({"Mod-z":Sn,"Ctrl-y":Ut,"Cmd-Z":Ut}))]}getToolbarItems(){return[this.contribution({section:"history",render:e=>V(e,{label:t=>t.rte.getLocale().richTextEditor.undo,icon:"undo-line",disabled:t=>!Sn(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;Sn(t,n)}})},1),this.contribution({section:"history",render:e=>V(e,{label:t=>t.rte.getLocale().richTextEditor.redo,icon:"redo-line",disabled:t=>!Ut(t.view.state),onClick:()=>{const{state:t,dispatch:n}=e.view;Ut(t,n)}})},2)]}}class dd extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteForeignHtmlFeature"}getPlugins(e){return[this.contribution(new B({props:{transformPastedHTML:t=>e.foreignHtmlParser[m.impl].transform(t),clipboardParser:e.foreignHtmlParser[m.impl].parser,clipboardSerializer:e.foreignHtmlSerializer[m.impl].serializer}}))]}}const fd=r=>{if(!(r.parentOffset===r.parent.content.size))return null;const t=r.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null};class hd extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteCursorFix"}getPlugins(e){const t=[fd];for(const n of Object.values(e.schema.marks)){const i=n.spec;i.cursorFix&&t.push(i.cursorFix)}return[this.contribution(new B({props:{decorations:n=>{const{$cursor:i}=n.selection;if(!i)return null;let o=null;for(const s of t){const l=s(i,n);l&&Object.assign(o??={},l)}return o?A.create(n.doc,[W.widget(i.pos,()=>{const s=document.createElement("span");s.textContent="​";for(const[l,a]of Object.entries(o))s.style.setProperty(l,a);return s},{side:-1})]):null}}}))]}}const Kt=new B({state:{init(){return null},apply(r,e){const t=r.getMeta(Kt);return t||e}}});class pd extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteCore",this.disabled=new pl(!1)}getStyles(){return[this.contribution(Lu),this.contribution(Gu),this.contribution(Ku)]}getPlugins(e){const t=Fn(ol,sl,ll,al((n,i,o)=>i?{type:hl(o.node(o.depth-1).contentMatchAt(o.indexAfter(o.depth-1))),attrs:e.textblockAttrs.extractFromNode(n)}:{type:n.type,attrs:n.attrs}));return[this.contribution(this.disabled.plugin),this.contribution(new B({props:{editable:()=>!this.disabled.getValue(e),handleDOMEvents:{click:(n,i)=>this.disabled.getValue(e)?(i.preventDefault(),!0):!1}},view:n=>{const i=n.dom.getRootNode().querySelector(".popovers"),o=()=>{i.classList.toggle("popovers--disabled",this.disabled.getValue(e))};return o(),{update:()=>{o()}}}})),this.contribution(Y({...Pu,Enter:t,"Shift-Enter":t})),this.contribution(zu()),this.contribution(Hu()),this.contribution(Kt)]}getFeatures(){return[this,new ud,new dd,new hd]}}const{entries:kl,setPrototypeOf:zo,isFrozen:md,getPrototypeOf:gd,getOwnPropertyDescriptor:bd}=Object;let{freeze:ce,seal:ke,create:Hr}=Object,{apply:Wr,construct:Ur}=typeof Reflect<"u"&&Reflect;ce||(ce=function(e){return e});ke||(ke=function(e){return e});Wr||(Wr=function(e,t){for(var n=arguments.length,i=new Array(n>2?n-2:0),o=2;o<n;o++)i[o-2]=arguments[o];return e.apply(t,i)});Ur||(Ur=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return new e(...n)});const hn=ue(Array.prototype.forEach),yd=ue(Array.prototype.lastIndexOf),Bo=ue(Array.prototype.pop),Pt=ue(Array.prototype.push),Sd=ue(Array.prototype.splice),kn=ue(String.prototype.toLowerCase),gr=ue(String.prototype.toString),br=ue(String.prototype.match),Lt=ue(String.prototype.replace),kd=ue(String.prototype.indexOf),Td=ue(String.prototype.trim),Me=ue(Object.prototype.hasOwnProperty),se=ue(RegExp.prototype.test),zt=Cd(TypeError);function ue(r){return function(e){e instanceof RegExp&&(e.lastIndex=0);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return Wr(r,e,n)}}function Cd(r){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return Ur(r,t)}}function x(r,e){let t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:kn;zo&&zo(r,null);let n=e.length;for(;n--;){let i=e[n];if(typeof i=="string"){const o=t(i);o!==i&&(md(e)||(e[n]=o),i=o)}r[i]=!0}return r}function Md(r){for(let e=0;e<r.length;e++)Me(r,e)||(r[e]=null);return r}function De(r){const e=Hr(null);for(const[t,n]of kl(r))Me(r,t)&&(Array.isArray(n)?e[t]=Md(n):n&&typeof n=="object"&&n.constructor===Object?e[t]=De(n):e[t]=n);return e}function Bt(r,e){for(;r!==null;){const n=bd(r,e);if(n){if(n.get)return ue(n.get);if(typeof n.value=="function")return ue(n.value)}r=gd(r)}function t(){return null}return t}const _o=ce(["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"]),yr=ce(["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"]),Sr=ce(["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"]),xd=ce(["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"]),kr=ce(["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"]),Od=ce(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),Vo=ce(["#text"]),Ho=ce(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","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","slot"]),Tr=ce(["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","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","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-rendering","textlength","type","u1","u2","unicode","values","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"]),Wo=ce(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","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"]),pn=ce(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),Ed=ke(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Dd=ke(/<%[\w\W]*|[\w\W]*%>/gm),Nd=ke(/\$\{[\w\W]*/gm),wd=ke(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ad=ke(/^aria-[\-\w]+$/),Tl=ke(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),vd=ke(/^(?:\w+script|data):/i),Rd=ke(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Cl=ke(/^html$/i),Id=ke(/^[a-z][.\w]*(-[.\w]+)+$/i);var Uo=Object.freeze({__proto__:null,ARIA_ATTR:Ad,ATTR_WHITESPACE:Rd,CUSTOM_ELEMENT:Id,DATA_ATTR:wd,DOCTYPE_NAME:Cl,ERB_EXPR:Dd,IS_ALLOWED_URI:Tl,IS_SCRIPT_OR_DATA:vd,MUSTACHE_EXPR:Ed,TMPLIT_EXPR:Nd});const _t={element:1,text:3,progressingInstruction:7,comment:8,document:9},Fd=function(){return typeof window>"u"?null:window},Pd=function(e,t){if(typeof e!="object"||typeof e.createPolicy!="function")return null;let n=null;const i="data-tt-policy-suffix";t&&t.hasAttribute(i)&&(n=t.getAttribute(i));const o="dompurify"+(n?"#"+n:"");try{return e.createPolicy(o,{createHTML(s){return s},createScriptURL(s){return s}})}catch{return console.warn("TrustedTypes policy "+o+" could not be created."),null}},$o=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Ml(){let r=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Fd();const e=C=>Ml(C);if(e.version="3.3.1",e.removed=[],!r||!r.document||r.document.nodeType!==_t.document||!r.Element)return e.isSupported=!1,e;let{document:t}=r;const n=t,i=n.currentScript,{DocumentFragment:o,HTMLTemplateElement:s,Node:l,Element:a,NodeFilter:c,NamedNodeMap:u=r.NamedNodeMap||r.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:h}=r,p=a.prototype,b=Bt(p,"cloneNode"),y=Bt(p,"remove"),k=Bt(p,"nextSibling"),R=Bt(p,"childNodes"),N=Bt(p,"parentNode");if(typeof s=="function"){const C=t.createElement("template");C.content&&C.content.ownerDocument&&(t=C.content.ownerDocument)}let w,Ce="";const{implementation:Ve,createNodeIterator:E,createDocumentFragment:P,getElementsByTagName:X}=t,{importNode:Bn}=n;let oe=$o();e.isSupported=typeof kl=="function"&&typeof N=="function"&&Ve&&Ve.createHTMLDocument!==void 0;const{MUSTACHE_EXPR:_n,ERB_EXPR:Vn,TMPLIT_EXPR:Hn,DATA_ATTR:Ll,ARIA_ATTR:zl,IS_SCRIPT_OR_DATA:Bl,ATTR_WHITESPACE:Si,CUSTOM_ELEMENT:_l}=Uo;let{IS_ALLOWED_URI:ki}=Uo,H=null;const Ti=x({},[..._o,...yr,...Sr,...kr,...Vo]);let $=null;const Ci=x({},[...Ho,...Tr,...Wo,...pn]);let F=Object.seal(Hr(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),vt=null,Wn=null;const ft=Object.seal(Hr(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}}));let Mi=!0,Un=!0,xi=!1,Oi=!0,ht=!1,rn=!0,et=!1,$n=!1,qn=!1,pt=!1,on=!1,sn=!1,Ei=!0,Di=!1;const Vl="user-content-";let Kn=!0,Rt=!1,mt={},Oe=null;const Gn=x({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Ni=null;const wi=x({},["audio","video","img","source","image","track"]);let Jn=null;const Ai=x({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),ln="http://www.w3.org/1998/Math/MathML",an="http://www.w3.org/2000/svg",ve="http://www.w3.org/1999/xhtml";let gt=ve,jn=!1,Yn=null;const Hl=x({},[ln,an,ve],gr);let cn=x({},["mi","mo","mn","ms","mtext"]),un=x({},["annotation-xml"]);const Wl=x({},["title","style","font","a","script"]);let It=null;const Ul=["application/xhtml+xml","text/html"],$l="text/html";let _=null,bt=null;const ql=t.createElement("form"),vi=function(g){return g instanceof RegExp||g instanceof Function},Xn=function(){let g=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(bt&&bt===g)){if((!g||typeof g!="object")&&(g={}),g=De(g),It=Ul.indexOf(g.PARSER_MEDIA_TYPE)===-1?$l:g.PARSER_MEDIA_TYPE,_=It==="application/xhtml+xml"?gr:kn,H=Me(g,"ALLOWED_TAGS")?x({},g.ALLOWED_TAGS,_):Ti,$=Me(g,"ALLOWED_ATTR")?x({},g.ALLOWED_ATTR,_):Ci,Yn=Me(g,"ALLOWED_NAMESPACES")?x({},g.ALLOWED_NAMESPACES,gr):Hl,Jn=Me(g,"ADD_URI_SAFE_ATTR")?x(De(Ai),g.ADD_URI_SAFE_ATTR,_):Ai,Ni=Me(g,"ADD_DATA_URI_TAGS")?x(De(wi),g.ADD_DATA_URI_TAGS,_):wi,Oe=Me(g,"FORBID_CONTENTS")?x({},g.FORBID_CONTENTS,_):Gn,vt=Me(g,"FORBID_TAGS")?x({},g.FORBID_TAGS,_):De({}),Wn=Me(g,"FORBID_ATTR")?x({},g.FORBID_ATTR,_):De({}),mt=Me(g,"USE_PROFILES")?g.USE_PROFILES:!1,Mi=g.ALLOW_ARIA_ATTR!==!1,Un=g.ALLOW_DATA_ATTR!==!1,xi=g.ALLOW_UNKNOWN_PROTOCOLS||!1,Oi=g.ALLOW_SELF_CLOSE_IN_ATTR!==!1,ht=g.SAFE_FOR_TEMPLATES||!1,rn=g.SAFE_FOR_XML!==!1,et=g.WHOLE_DOCUMENT||!1,pt=g.RETURN_DOM||!1,on=g.RETURN_DOM_FRAGMENT||!1,sn=g.RETURN_TRUSTED_TYPE||!1,qn=g.FORCE_BODY||!1,Ei=g.SANITIZE_DOM!==!1,Di=g.SANITIZE_NAMED_PROPS||!1,Kn=g.KEEP_CONTENT!==!1,Rt=g.IN_PLACE||!1,ki=g.ALLOWED_URI_REGEXP||Tl,gt=g.NAMESPACE||ve,cn=g.MATHML_TEXT_INTEGRATION_POINTS||cn,un=g.HTML_INTEGRATION_POINTS||un,F=g.CUSTOM_ELEMENT_HANDLING||{},g.CUSTOM_ELEMENT_HANDLING&&vi(g.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(F.tagNameCheck=g.CUSTOM_ELEMENT_HANDLING.tagNameCheck),g.CUSTOM_ELEMENT_HANDLING&&vi(g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(F.attributeNameCheck=g.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),g.CUSTOM_ELEMENT_HANDLING&&typeof g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements=="boolean"&&(F.allowCustomizedBuiltInElements=g.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),ht&&(Un=!1),on&&(pt=!0),mt&&(H=x({},Vo),$=[],mt.html===!0&&(x(H,_o),x($,Ho)),mt.svg===!0&&(x(H,yr),x($,Tr),x($,pn)),mt.svgFilters===!0&&(x(H,Sr),x($,Tr),x($,pn)),mt.mathMl===!0&&(x(H,kr),x($,Wo),x($,pn))),g.ADD_TAGS&&(typeof g.ADD_TAGS=="function"?ft.tagCheck=g.ADD_TAGS:(H===Ti&&(H=De(H)),x(H,g.ADD_TAGS,_))),g.ADD_ATTR&&(typeof g.ADD_ATTR=="function"?ft.attributeCheck=g.ADD_ATTR:($===Ci&&($=De($)),x($,g.ADD_ATTR,_))),g.ADD_URI_SAFE_ATTR&&x(Jn,g.ADD_URI_SAFE_ATTR,_),g.FORBID_CONTENTS&&(Oe===Gn&&(Oe=De(Oe)),x(Oe,g.FORBID_CONTENTS,_)),g.ADD_FORBID_CONTENTS&&(Oe===Gn&&(Oe=De(Oe)),x(Oe,g.ADD_FORBID_CONTENTS,_)),Kn&&(H["#text"]=!0),et&&x(H,["html","head","body"]),H.table&&(x(H,["tbody"]),delete vt.tbody),g.TRUSTED_TYPES_POLICY){if(typeof g.TRUSTED_TYPES_POLICY.createHTML!="function")throw zt('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if(typeof g.TRUSTED_TYPES_POLICY.createScriptURL!="function")throw zt('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');w=g.TRUSTED_TYPES_POLICY,Ce=w.createHTML("")}else w===void 0&&(w=Pd(h,i)),w!==null&&typeof Ce=="string"&&(Ce=w.createHTML(""));ce&&ce(g),bt=g}},Ri=x({},[...yr,...Sr,...xd]),Ii=x({},[...kr,...Od]),Kl=function(g){let S=N(g);(!S||!S.tagName)&&(S={namespaceURI:gt,tagName:"template"});const T=kn(g.tagName),v=kn(S.tagName);return Yn[g.namespaceURI]?g.namespaceURI===an?S.namespaceURI===ve?T==="svg":S.namespaceURI===ln?T==="svg"&&(v==="annotation-xml"||cn[v]):!!Ri[T]:g.namespaceURI===ln?S.namespaceURI===ve?T==="math":S.namespaceURI===an?T==="math"&&un[v]:!!Ii[T]:g.namespaceURI===ve?S.namespaceURI===an&&!un[v]||S.namespaceURI===ln&&!cn[v]?!1:!Ii[T]&&(Wl[T]||!Ri[T]):!!(It==="application/xhtml+xml"&&Yn[g.namespaceURI]):!1},Ee=function(g){Pt(e.removed,{element:g});try{N(g).removeChild(g)}catch{y(g)}},tt=function(g,S){try{Pt(e.removed,{attribute:S.getAttributeNode(g),from:S})}catch{Pt(e.removed,{attribute:null,from:S})}if(S.removeAttribute(g),g==="is")if(pt||on)try{Ee(S)}catch{}else try{S.setAttribute(g,"")}catch{}},Fi=function(g){let S=null,T=null;if(qn)g="<remove></remove>"+g;else{const L=br(g,/^[\r\n\t ]+/);T=L&&L[0]}It==="application/xhtml+xml"&&gt===ve&&(g='<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>'+g+"</body></html>");const v=w?w.createHTML(g):g;if(gt===ve)try{S=new f().parseFromString(v,It)}catch{}if(!S||!S.documentElement){S=Ve.createDocument(gt,"template",null);try{S.documentElement.innerHTML=jn?Ce:v}catch{}}const Z=S.body||S.documentElement;return g&&T&&Z.insertBefore(t.createTextNode(T),Z.childNodes[0]||null),gt===ve?X.call(S,et?"html":"body")[0]:et?S.documentElement:Z},Pi=function(g){return E.call(g.ownerDocument||g,g,c.SHOW_ELEMENT|c.SHOW_COMMENT|c.SHOW_TEXT|c.SHOW_PROCESSING_INSTRUCTION|c.SHOW_CDATA_SECTION,null)},Zn=function(g){return g instanceof d&&(typeof g.nodeName!="string"||typeof g.textContent!="string"||typeof g.removeChild!="function"||!(g.attributes instanceof u)||typeof g.removeAttribute!="function"||typeof g.setAttribute!="function"||typeof g.namespaceURI!="string"||typeof g.insertBefore!="function"||typeof g.hasChildNodes!="function")},Li=function(g){return typeof l=="function"&&g instanceof l};function Re(C,g,S){hn(C,T=>{T.call(e,g,S,bt)})}const zi=function(g){let S=null;if(Re(oe.beforeSanitizeElements,g,null),Zn(g))return Ee(g),!0;const T=_(g.nodeName);if(Re(oe.uponSanitizeElement,g,{tagName:T,allowedTags:H}),rn&&g.hasChildNodes()&&!Li(g.firstElementChild)&&se(/<[/\w!]/g,g.innerHTML)&&se(/<[/\w!]/g,g.textContent)||g.nodeType===_t.progressingInstruction||rn&&g.nodeType===_t.comment&&se(/<[/\w]/g,g.data))return Ee(g),!0;if(!(ft.tagCheck instanceof Function&&ft.tagCheck(T))&&(!H[T]||vt[T])){if(!vt[T]&&_i(T)&&(F.tagNameCheck instanceof RegExp&&se(F.tagNameCheck,T)||F.tagNameCheck instanceof Function&&F.tagNameCheck(T)))return!1;if(Kn&&!Oe[T]){const v=N(g)||g.parentNode,Z=R(g)||g.childNodes;if(Z&&v){const L=Z.length;for(let de=L-1;de>=0;--de){const Ie=b(Z[de],!0);Ie.__removalCount=(g.__removalCount||0)+1,v.insertBefore(Ie,k(g))}}}return Ee(g),!0}return g instanceof a&&!Kl(g)||(T==="noscript"||T==="noembed"||T==="noframes")&&se(/<\/no(script|embed|frames)/i,g.innerHTML)?(Ee(g),!0):(ht&&g.nodeType===_t.text&&(S=g.textContent,hn([_n,Vn,Hn],v=>{S=Lt(S,v," ")}),g.textContent!==S&&(Pt(e.removed,{element:g.cloneNode()}),g.textContent=S)),Re(oe.afterSanitizeElements,g,null),!1)},Bi=function(g,S,T){if(Ei&&(S==="id"||S==="name")&&(T in t||T in ql))return!1;if(!(Un&&!Wn[S]&&se(Ll,S))){if(!(Mi&&se(zl,S))){if(!(ft.attributeCheck instanceof Function&&ft.attributeCheck(S,g))){if(!$[S]||Wn[S]){if(!(_i(g)&&(F.tagNameCheck instanceof RegExp&&se(F.tagNameCheck,g)||F.tagNameCheck instanceof Function&&F.tagNameCheck(g))&&(F.attributeNameCheck instanceof RegExp&&se(F.attributeNameCheck,S)||F.attributeNameCheck instanceof Function&&F.attributeNameCheck(S,g))||S==="is"&&F.allowCustomizedBuiltInElements&&(F.tagNameCheck instanceof RegExp&&se(F.tagNameCheck,T)||F.tagNameCheck instanceof Function&&F.tagNameCheck(T))))return!1}else if(!Jn[S]){if(!se(ki,Lt(T,Si,""))){if(!((S==="src"||S==="xlink:href"||S==="href")&&g!=="script"&&kd(T,"data:")===0&&Ni[g])){if(!(xi&&!se(Bl,Lt(T,Si,"")))){if(T)return!1}}}}}}}return!0},_i=function(g){return g!=="annotation-xml"&&br(g,_l)},Vi=function(g){Re(oe.beforeSanitizeAttributes,g,null);const{attributes:S}=g;if(!S||Zn(g))return;const T={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:$,forceKeepAttr:void 0};let v=S.length;for(;v--;){const Z=S[v],{name:L,namespaceURI:de,value:Ie}=Z,yt=_(L),Qn=Ie;let q=L==="value"?Qn:Td(Qn);if(T.attrName=yt,T.attrValue=q,T.keepAttr=!0,T.forceKeepAttr=void 0,Re(oe.uponSanitizeAttribute,g,T),q=T.attrValue,Di&&(yt==="id"||yt==="name")&&(tt(L,g),q=Vl+q),rn&&se(/((--!?|])>)|<\/(style|title|textarea)/i,q)){tt(L,g);continue}if(yt==="attributename"&&br(q,"href")){tt(L,g);continue}if(T.forceKeepAttr)continue;if(!T.keepAttr){tt(L,g);continue}if(!Oi&&se(/\/>/i,q)){tt(L,g);continue}ht&&hn([_n,Vn,Hn],Wi=>{q=Lt(q,Wi," ")});const Hi=_(g.nodeName);if(!Bi(Hi,yt,q)){tt(L,g);continue}if(w&&typeof h=="object"&&typeof h.getAttributeType=="function"&&!de)switch(h.getAttributeType(Hi,yt)){case"TrustedHTML":{q=w.createHTML(q);break}case"TrustedScriptURL":{q=w.createScriptURL(q);break}}if(q!==Qn)try{de?g.setAttributeNS(de,L,q):g.setAttribute(L,q),Zn(g)?Ee(g):Bo(e.removed)}catch{tt(L,g)}}Re(oe.afterSanitizeAttributes,g,null)},Gl=function C(g){let S=null;const T=Pi(g);for(Re(oe.beforeSanitizeShadowDOM,g,null);S=T.nextNode();)Re(oe.uponSanitizeShadowNode,S,null),zi(S),Vi(S),S.content instanceof o&&C(S.content);Re(oe.afterSanitizeShadowDOM,g,null)};return e.sanitize=function(C){let g=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},S=null,T=null,v=null,Z=null;if(jn=!C,jn&&(C="<!-->"),typeof C!="string"&&!Li(C))if(typeof C.toString=="function"){if(C=C.toString(),typeof C!="string")throw zt("dirty is not a string, aborting")}else throw zt("toString is not a function");if(!e.isSupported)return C;if($n||Xn(g),e.removed=[],typeof C=="string"&&(Rt=!1),Rt){if(C.nodeName){const Ie=_(C.nodeName);if(!H[Ie]||vt[Ie])throw zt("root node is forbidden and cannot be sanitized in-place")}}else if(C instanceof l)S=Fi("<!---->"),T=S.ownerDocument.importNode(C,!0),T.nodeType===_t.element&&T.nodeName==="BODY"||T.nodeName==="HTML"?S=T:S.appendChild(T);else{if(!pt&&!ht&&!et&&C.indexOf("<")===-1)return w&&sn?w.createHTML(C):C;if(S=Fi(C),!S)return pt?null:sn?Ce:""}S&&qn&&Ee(S.firstChild);const L=Pi(Rt?C:S);for(;v=L.nextNode();)zi(v),Vi(v),v.content instanceof o&&Gl(v.content);if(Rt)return C;if(pt){if(on)for(Z=P.call(S.ownerDocument);S.firstChild;)Z.appendChild(S.firstChild);else Z=S;return($.shadowroot||$.shadowrootmode)&&(Z=Bn.call(n,Z,!0)),Z}let de=et?S.outerHTML:S.innerHTML;return et&&H["!doctype"]&&S.ownerDocument&&S.ownerDocument.doctype&&S.ownerDocument.doctype.name&&se(Cl,S.ownerDocument.doctype.name)&&(de="<!DOCTYPE "+S.ownerDocument.doctype.name+`>
8
- `+de),ht&&hn([_n,Vn,Hn],Ie=>{de=Lt(de,Ie," ")}),w&&sn?w.createHTML(de):de},e.setConfig=function(){let C=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Xn(C),$n=!0},e.clearConfig=function(){bt=null,$n=!1},e.isValidAttribute=function(C,g,S){bt||Xn({});const T=_(C),v=_(g);return Bi(T,v,S)},e.addHook=function(C,g){typeof g=="function"&&Pt(oe[C],g)},e.removeHook=function(C,g){if(g!==void 0){const S=yd(oe[C],g);return S===-1?void 0:Sd(oe[C],S,1)[0]}return Bo(oe[C])},e.removeHooks=function(C){oe[C]=[]},e.removeAllHooks=function(){oe=$o()},e}var zn=Ml();const Ld=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,zd=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Bd=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,mi={ALLOWED_URI_REGEXP:zd},_d=r=>{if(!Ld.test(r.replace(Bd,"")))return"";const e=document.createElement("a");return e.setAttribute("href",r),zn.sanitize(e,{RETURN_DOM:!0,...mi}).querySelector("a").getAttribute("href")??""},xl=r=>{const e=document.createElement("img");return e.setAttribute("src",r),zn.sanitize(e,{RETURN_DOM:!0,...mi}).querySelector("img").getAttribute("src")??""},gi=r=>r.replace(/[;!].*/,""),wn=r=>({...r}),Vd=r=>({nodes:Object.fromEntries(Object.keys(r.nodes).map(e=>[e,(r.nodes[e].spec.parseDOM??[]).map(wn)])),marks:Object.fromEntries(Object.keys(r.marks).map(e=>[e,(r.marks[e].spec.parseDOM??[]).map(wn)]))});class Ol{constructor(e,t){this[m.impl]=new Hd(e[m.impl],t)}parseDocument(e,t){return this[m.impl].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[m.impl].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){const n=zn.sanitize(e,{RETURN_DOM:!0,...mi}),i=document.createDocumentFragment();return i.appendChild(n),t?.modifyDom?.(i),i}}class Hd{constructor(e,t){const n=Vd(e.schema);t?.modifyParseRules?.(n),this.parser=Wd(e.schema,n)}transform(e){return zn.sanitize(e)}}const Wd=(r,{marks:e,nodes:t})=>{const n=[],i=s=>s.priority??50;function o(s){let l=0;for(;l<n.length;l++){const a=n[l];if(i(a)<i(s))break}n.splice(l,0,s)}for(const s in e)e[s]?.forEach(l=>{o(l=wn(l)),l.mark||l.ignore||l.clearMark||(l.mark=s)});for(const s in t)t[s]?.forEach(l=>{o(l=wn(l)),l.node||l.ignore||l.mark||(l.node=s)});return new m.DOMParser(r,n)};class El{constructor(e,t){this[m.impl]=new bi(e[m.impl],t)}serializeDocument(e,t){return this[m.impl].serializeFragment(e.content,t)}serializeFragment(e,t){return this[m.impl].serializeFragment(e,t)}}class bi{constructor(e,t){this.config=e;const n=bi.domSerializersFromSchema(e.schema);Object.assign(n.nodes,t?.serializers?.nodes??{}),Object.assign(n.marks,t?.serializers?.marks??{}),this.serializer=new m.DOMSerializer(n.nodes,n.marks)}static domSerializersFromSchema(e){const t={nodes:{},marks:{}};for(const n in e.marks){const i=e.marks[n].spec.toDOM;i&&(t.marks[n]=i)}for(const n in e.nodes){const i=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;i&&(t.nodes[n]=i)}return t.nodes.text=n=>document.createTextNode(n.text),t}serializeFragment(e,t){const n=m.Fragment.fromJSON(this.config.schema,e),i=this.serializer.serializeFragment(n),o=document.createDocumentFragment();o.appendChild(i),t?.modifyDom?.(o);const s=document.createElement("div");return s.appendChild(o),s.innerHTML}}const Dl=(r,e)=>{const t=r.topNodeType.createAndFill(null,e?m.Fragment.fromJSON(r,e.content):null);if(!t)throw new Error("Document could not be parsed");return t.check(),t};class Ud{constructor(e,t){this.options=t,this.feature=(n,i)=>this[m.impl].getPublicInterface(n,i),this[m.impl]=new $d(this,e,t)}getDocument(){return this[m.impl].state.doc.toJSON()}reset(e){this[m.impl].reset(e)}replaceSelection(e,t){const{state:n,tr:i,schema:o,dispatchTransaction:s}=this[m.impl];i.replaceSelection(new m.Slice(m.Fragment.fromJSON(o,e),0,0)),i.doc.check();const l=i.doc.resolve(i.mapping.map(n.selection.from)),a=i.doc.resolve(i.selection.to),[c,u]=t?.cursorPlacement==="start"?[l,a]:[a,l];t?.selectContent?i.setSelection(n.selection instanceof j?new j(i.doc):O.between(u,c)):i.setSelection(O.between(c,c)),s(i)}replaceDocument(e,t){const{state:n,tr:i,schema:o,dispatchTransaction:s}=this[m.impl];i.replaceWith(0,n.doc.content.size,Dl(o,e)),t?.selectContent?i.setSelection(new j(i.doc)):t?.cursorPlacement==="end"?i.setSelection(O.atEnd(i.doc)):i.setSelection(O.atStart(i.doc)),s(i)}}class $d{constructor(e,t,n){this.options=n,this.view=null,this.dispatchTransaction=o=>{const s=this.state;return this.state=this.state.apply(o),this.view?.updateState(this.state),s.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;const i=t[m.impl];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=n?.foreignHtmlParser??new Ol(t),this.foreignHtmlSerializer=n?.foreignHtmlSerializer??new El(t),this.styles=new re.ElementStyles(m.sortedContributions(i.features.flatMap(o=>o.getStyles()))),this.initState(n?.initialDocument)}getFeature(e){const t=this.config.featureMap.get(e);if(!t)throw new Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){const n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw new Error("Feature not found");if(n[0].featureId!==void 0){if(t===void 0)throw new Error("No featureId provided for multi-instance feature.");const o=n.find(s=>s.featureId===t);if(!o)throw new Error(`Feature with id "${t}" not found`);return o.getPublicInterface(this)}if(t!==void 0)throw new Error("Feature does not support featureId");return n[0].getPublicInterface(this)}initState(e){this.state=Mt.create({doc:Dl(this.schema,e),schema:this.config.schema,plugins:m.sortedContributions(this.config.features.flatMap(t=>t.getPlugins(this)))})}reset(e){const t=Kt.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){this.view=new el(e,{state:this.state,dispatchTransaction:this.dispatchTransaction})}destroyViewIfNeeded(){this.view&&(this.view.destroy(),this.view=null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){const e=Kt.getState(this.state);if(!e)throw new Error("No host state available");return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(Kt,e))}}var qd=Object.defineProperty,Kd=(r,e,t,n)=>{for(var i=void 0,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=s(e,t,i)||i);return i&&qd(e,t,i),i};class Nl extends Jl.WithObservableLocale(re.VividElement){instanceChanged(e){e?.[m.impl].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[m.impl].styles.removeStylesFrom(this.shadowRoot),this.instance?.[m.impl].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){const e=this.instance?.[m.impl];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[m.impl].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[m.impl].updateHostState({locale:this.locale,ctx:this._ctx})}}Kd([re.observable],Nl.prototype,"instance");const Gd=r=>re.html`<template :_ctx="${()=>r}">
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`../bundled/localized.cjs`),t=require(`../bundled/vivid-element.cjs`),n=require(`../bundled/ref.cjs`);require(`../bundled/definition2.cjs`);const r=require(`../bundled/decorate.cjs`),i=require(`../bundled/definition5.cjs`),a=require(`../bundled/definition6.cjs`),o=require(`../bundled/definition8.cjs`),s=require(`../bundled/definition9.cjs`),c=require(`../bundled/mixins.cjs`),l=require(`../bundled/definition12.cjs`),u=require(`../bundled/definition17.cjs`),d=require(`../bundled/definition18.cjs`),f=require(`../bundled/definition19.cjs`),p=require(`../bundled/divider.cjs`),m=require(`../bundled/slottable-request.cjs`),h=require(`../bundled/definition20.cjs`),g=require(`../bundled/definition21.cjs`);var ee=`:host{flex-direction:column;display:flex}.rte{flex-direction:column;block-size:100%;min-block-size:0;display:flex}.editor{display:contents}.editor-viewport{contain:layout;flex-direction:column;flex:1;min-block-size:0;display:flex;position:relative;overflow:hidden}.editor-scroll-area{--editor-padding-inline:var(--rich-text-editor-padding-inline,16px);--editor-padding-block:var(--rich-text-editor-padding-block,8px);background-color:var(--vvd-color-canvas);color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);--scrollbar-track-color:transparent;--scrollbar-thumb-color:color-mix(in srgb, var(--vvd-color-neutral-950), transparent 70%);scrollbar-color:var(--scrollbar-thumb-color) var(--scrollbar-track-color);scrollbar-width:thin;flex-direction:column;flex:1;min-block-size:0;display:flex;overflow-y:auto}.editor-scroll-area ::-webkit-scrollbar{width:4px}.editor-scroll-area ::-webkit-scrollbar-track{background:var(--scrollbar-track-color)}.editor-scroll-area ::-webkit-scrollbar-thumb{background-color:var(--scrollbar-fallback-track-color,var(--scrollbar-thumb-color));border:0;border-radius:4px}.popovers--disabled>*{display:none!important}`,te=class extends e.n(t.t){instanceChanged(e){e?.[m.c].destroyViewIfNeeded(),this._initViewIfNeeded(),e?.[m.c].styles.removeStylesFrom(this.shadowRoot),this.instance?.[m.c].styles.addStylesTo(this.shadowRoot)}_initViewIfNeeded(){let e=this.instance?.[m.c];e&&this.$fastController.isConnected&&!e.view&&(this._syncStateIfNeeded(),e.createView(this._editorEl))}_destroyViewIfNeeded(){this.instance?.[m.c].destroyViewIfNeeded()}connectedCallback(){super.connectedCallback(),this._initViewIfNeeded()}disconnectedCallback(){super.disconnectedCallback(),this._destroyViewIfNeeded()}localeChanged(){this._syncStateIfNeeded()}_syncStateIfNeeded(){this.instance?.[m.c].updateHostState({locale:this.locale,ctx:this._ctx})}};r.t([t.T],te.prototype,`instance`,void 0);var _=e=>t.d`<template :_ctx="${()=>e}">
9
2
  <div class="rte">
10
- <div class="editor-viewport" ${Ui.ref("editorViewportElement")}>
3
+ <div class="editor-viewport" ${n.t(`editorViewportElement`)}>
11
4
  <div class="editor-scroll-area">
12
5
  <slot name="editor-start"></slot>
13
- <div class="editor rich-text" ${Ui.ref("_editorEl")}></div>
6
+ <div class="editor rich-text" ${n.t(`_editorEl`)}></div>
14
7
  <div class="popovers"></div>
15
8
  <slot name="editor-end"></slot>
16
9
  </div>
@@ -18,14 +11,21 @@
18
11
  <slot name="status"></slot>
19
12
  <div class="toolbar"></div>
20
13
  </div>
21
- </template>`;var Jd=Object.defineProperty,jd=Object.getOwnPropertyDescriptor,dt=(r,e,t,n)=>{for(var i=n>1?void 0:n?jd(e,t):e,o=r.length-1,s;o>=0;o--)(s=r[o])&&(i=(n?s(e,t,i):s(i))||i);return n&&i&&Jd(e,t,i),i};const Cr={default:{placement:void 0,placementStrategy:Tn.PlacementStrategy.AutoPlacementHorizontal,strategy:"absolute"},autocomplete:{placement:"bottom-start",placementStrategy:Tn.PlacementStrategy.Flip,strategy:"fixed"}},Yd=r=>{const e=r.tagFor(Tn.Popup);return re.html`<${e}
22
- :anchor="${t=>t.anchorEl}"
23
- :placement="${t=>Cr[t.kind].placement}"
24
- :placementStrategy="${t=>Cr[t.kind].placementStrategy}"
25
- :open="${t=>t.open}"
26
- :offset="${t=>t.offset}"
27
- :strategy="${t=>Cr[t.kind].strategy}"
14
+ </template>`,v={default:{placement:void 0,placementStrategy:o.r.AutoPlacementHorizontal,strategy:`absolute`},autocomplete:{placement:`bottom-start`,placementStrategy:o.r.Flip,strategy:`fixed`}},ne=e=>{let n=e.tagFor(o.i);return t.d`<${n}
15
+ :anchor="${e=>e.anchorEl}"
16
+ :placement="${e=>v[e.kind].placement}"
17
+ :placementStrategy="${e=>v[e.kind].placementStrategy}"
18
+ :open="${e=>e.open}"
19
+ :offset="${e=>e.offset}"
20
+ :strategy="${e=>v[e.kind].strategy}"
28
21
  exportparts="vvd-theme-alternate"
29
22
  >
30
23
  <slot></slot>
31
- </${e}>`};class Te extends re.VividElement{constructor(){super(...arguments),this.kind="default",this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover==="true"||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?"true":"false";const n=new CustomEvent("block-popover-changed",{bubbles:!1,composed:!1});e.dispatchEvent(n)}anchorElChanged(e,t){e?.removeEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),t?.addEventListener("block-popover-changed",this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorId&&this.isConnected?this.anchorEl=this.getRootNode().getElementById(this.anchorId)||void 0:this.anchorEl=void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(t=>Array.from(t.addedNodes).some(n=>n instanceof HTMLElement&&n.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}}dt([re.observable],Te.prototype,"kind",2);dt([re.observable],Te.prototype,"offset",2);dt([re.observable],Te.prototype,"anchorBlocksPopover",2);dt([re.observable],Te.prototype,"anchorEl",2);dt([re.observable],Te.prototype,"anchorId",2);dt([re.observable],Te.prototype,"requestedOpenState",2);dt([re.volatile],Te.prototype,"open",1);const Xd=re.defineVividComponent("rich-text-editor-popover",Te,Yd,[Tn.popupDefinition],{}),Zd="h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;line-height:20px;margin-block:16px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;line-height:28px;margin-block:24px 12px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;line-height:36px;margin-block:24px 12px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;line-height:42px;margin-block:32px 16px}";class Qd extends m.RteFeatureImpl{constructor(e){super(),this.enabledBlocks=e,this.name="RteBasicTextBlocks"}getStyles(){return[this.contribution(Zd)]}getSchema(e,t){const n={};this.enabledBlocks.paragraph&&(n.paragraph={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:"p",getAttrs:o=>e.fromDOM(o)}],marks:t.getAllowedMarksForNode("paragraph").join(" "),toDOM(o){return["p",{part:"node--paragraph",...e.getDOMAttrsProperties(o)},0]},serializeToDOM(o){return["p",...e.getDOMAttrs(o),0]}});let i=0;for(const o of[3,2,1]){const s=`heading${o}`,l=`h${o}`;if(!this.enabledBlocks[s])continue;i++;const a=i;n[s]={group:"block",content:"inline*",attrs:{...e.attrs},parseDOM:[{tag:l,getAttrs:c=>e.fromDOM(c)}],marks:t.getAllowedMarksForNode(s).join(" "),defining:!0,toDOM(c){return[l,{class:`heading-step-${a}`,part:`node--${s}`,...e.getDOMAttrsProperties(c)},0]},serializeToDOM(c){return[l,...e.getDOMAttrs(c),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){const t={};this.enabledBlocks.paragraph&&(t["Mod-Alt-0"]=this.setBlockType(e,"paragraph"));for(const n of[1,2,3]){const i=`heading${n}`;this.enabledBlocks[i]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,i))}return[this.contribution(Y(t))]}getCurrentBlockType(e){const{$from:t,$to:n}=e.selection,i=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1),o=n.depth===0?e.doc.childBefore(n.pos).node:n.node(1);return i!==o||!(i.type.name in this.enabledBlocks)?null:i.type.name}setBlockType(e,t){return(n,i)=>{const{from:o,to:s}=n.selection,l=n.tr;let a=!1;return n.doc.nodesBetween(o,s,(c,u)=>(c.type.name in this.enabledBlocks&&(a=!0,l.setBlockType(u,u+c.nodeSize,n.schema.nodes[t],d=>e.textblockAttrs.extractFromNode(d))),!1)),a?(i?.(l),!0):!1}}}class Qe{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t=="string"?ef(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}}function ef(r){return function(e,t,n,i){let o=r;if(t[1]){let s=t[0].lastIndexOf(t[1]);o+=t[0].slice(s+t[1].length),n+=s;let l=n-i;l>0&&(o=t[0].slice(s-l,s)+o,n=i)}return e.tr.insertText(o,n,i)}}const tf=500;function nf({rules:r}){let e=new B({state:{init(){return null},apply(t,n){let i=t.getMeta(this);return i||(t.selectionSet||t.docChanged?null:n)}},props:{handleTextInput(t,n,i,o){return qo(t,n,i,o,r,e)},handleDOMEvents:{compositionend:t=>{setTimeout(()=>{let{$cursor:n}=t.state.selection;n&&qo(t,n.pos,n.pos,"",r,e)})}}},isInputRules:!0});return e}function qo(r,e,t,n,i,o){if(r.composing)return!1;let s=r.state,l=s.doc.resolve(e),a=l.parent.textBetween(Math.max(0,l.parentOffset-tf),l.parentOffset,null,"")+n;for(let c=0;c<i.length;c++){let u=i[c];if(!u.inCodeMark&&l.marks().some(p=>p.type.spec.code))continue;if(l.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode==="only")continue;let d=u.match.exec(a);if(!d||d[0].length<n.length)continue;let f=e-(d[0].length-n.length);if(!u.inCodeMark){let p=!1;if(s.doc.nodesBetween(f,l.pos,b=>{b.isInline&&b.marks.some(y=>y.type.spec.code)&&(p=!0)}),p)continue}let h=u.handler(s,d,f,t);if(h)return u.undoable&&h.setMeta(o,{transform:h,from:e,to:t,text:n}),r.dispatch(h),!0}return!1}const rf=(r,e)=>{let t=r.plugins;for(let n=0;n<t.length;n++){let i=t[n],o;if(i.spec.isInputRules&&(o=i.getState(r))){if(e){let s=r.tr,l=o.transform;for(let a=l.steps.length-1;a>=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(o.text){let a=s.doc.resolve(o.from).marks();s.replaceWith(o.from,o.to,r.schema.text(o.text,a))}else s.delete(o.from,o.to);e(s)}return!0}}return!1};new Qe(/--$/,"—",{inCodeMark:!1});new Qe(/\.\.\.$/,"…",{inCodeMark:!1});new Qe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,"“",{inCodeMark:!1});new Qe(/"$/,"”",{inCodeMark:!1});new Qe(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,"‘",{inCodeMark:!1});new Qe(/'$/,"’",{inCodeMark:!1});const wl=r=>r.parent.textBetween(0,r.parentOffset,void 0,"");class of extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteInputRulesFeature"}getPlugins(e){const t=m.sortedContributions(e.config.features.flatMap(s=>s.getInputRules(e)));if(t.length===0)return[];const n=[],i=t.map(s=>s.rule);n.push(this.contribution(nf({rules:i}))),n.push(this.contribution(Y({Backspace:rf}),m.contributionPriority.high));const o=t.filter(s=>s.enterHandler).map(s=>s.enterHandler);return o.length>0&&n.push(this.contribution(Y({Enter:(s,l)=>{const{$cursor:a}=s.selection;if(!a)return!1;const c=wl(a);for(const{regex:u,handler:d}of o){const f=u.exec(c);if(!f)continue;const h=a.pos-a.parentOffset+f.index,p=h+f[0].length,b=d(s,f,h,p);b&&l?.(b);break}return!1}}),m.contributionPriority.highest)),n}}class sf extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteBase"}getSchema(){return[this.contribution({nodes:{doc:{content:"block+"},text:{group:"inline"}}})]}getFeatures(){return[this,new pd,new Qd({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new of]}getPublicInterface(e){const t=e.getFeature("RteCore");return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)}}}}const lf=m.featureFacade(sf);class af extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteTextBlockPickerFeature"}getToolbarItems(e){const t=e.getFeature("RteBasicTextBlocks");return[this.contribution({section:"font",render:n=>ad(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:i=>t.getCurrentBlockType(i.view.state)??"",onSelect:i=>{const{state:o,dispatch:s}=n.view;t.setBlockType(e,i)(o,s)},children:this.config.options.map(i=>ld(n,{text:i.label,value:i.node,disabled:()=>!t.setBlockType(e,i.node)(n.view.state)}))})},1)]}}const cf=m.featureFacade(af),uf=".toolbar{display:flex;flex-wrap:wrap;align-items:center;padding:4px;background-color:var(--vvd-color-neutral-50);gap:8px}.toolbar--hidden{display:none}";class df extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteToolbarFeature",this.hidden=new pl(!1)}getStyles(){return[this.contribution(uf)]}getPlugins(e){const t=["history","font","text-style","textblock","insert"],n=new Map(t.map(o=>[o,[]]));for(const o of m.sortedContributions(e.features.flatMap(s=>s.getToolbarItems(e))))n.get(o.section).push(o);const i=e.getFeature("RteCore");return[this.contribution(this.hidden.plugin),this.contribution(new B({view:o=>{const s=new Ln(o,e,{popupPlacement:this.config?.popupDirection==="outward"?"bottom":"top",menuOffset:8,disabled:()=>i.disabled.getValue(e)}),l=o.dom.getRootNode().querySelector(".toolbar");s.bindProp(()=>this.hidden.getValue(e),c=>{l.classList.toggle("toolbar--hidden",c)});let a=!1;for(const c of t){const u=n.get(c);u.length&&a&&(l.appendChild(Vr(s)),a=!1);for(const d of u)l.appendChild(d.render(s)),a=!0}return{update(){s.updateBindings()},destroy(){l.innerHTML=""}}}}))]}getPublicInterface(e){const t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}}const ff=m.featureFacade(df),hf=".placeholder{display:contents}.placeholder:before{position:absolute;color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size, inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none}";class pf extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RtePlaceholderFeature"}getStyles(){return[this.contribution(hf)]}getPlugins(){const e=new B({props:{decorations:t=>{if(t.doc.nodeSize===4){const i=t.schema.marks.fontSize?.isInSet(t.storedMarks??[])?.attrs.size;return A.create(t.doc,[W.widget(1,()=>{const o=document.createElement("span");return o.className="placeholder",o.dataset.placeholder=this.config.text,i&&o.style.setProperty("--placeholder-font-size",i),o})])}return null}}});return[this.contribution(e)]}}const mf=m.featureFacade(pf);class gf extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteHardBreakFeature"}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return["br"]}}}})]}getPlugins(e){const n={"Shift-Enter":(i,o)=>(o?.(i.tr.replaceSelectionWith(i.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0)};return[this.contribution(Y(n),m.contributionPriority.high)]}}const bf=m.featureFacade(gf),Mr=Symbol("mixedFontSize");class yf extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteFontSizePickerFeature",this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(const t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"fontSize",onNodeName:e.node})):[this.contribution({markName:"fontSize"})]}getSchema(){const e={attrs:{size:{validate:"string"}},parseDOM:[{tag:"span[style*='font-size']",getAttrs:t=>{const i=t.getAttribute("style").match(/font-size:\s*([^;]+)/)?.[1]?.trim();return i?{size:i}:!1}}],toDOM:t=>["span",{style:`font-size: ${gi(t.attrs.size)};`},0],cursorFix:(t,n)=>{const i=n.storedMarks;if(!i)return null;const o=i.find(s=>s.type.name==="fontSize");if(o)return{"font-size":o.attrs.size};if(i.length===0){const s=this.defaultFontSizeForNode?.[t.parent.type.name];if(s)return{"font-size":s}}return null}};return[this.contribution({marks:{fontSize:e}})]}getPlugins(){return[this.contribution(Y({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:"font",render:t=>pi(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:V(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:"text-size-line"}),children:this.fontSizes.map(n=>id(t,{text:n.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===n.size,disabled:()=>!this.setFontSize(n.size)(t.view.state),onSelect:()=>{const{state:i,dispatch:o}=t.view;this.setFontSize(n.size)(i,o)}}))})},2)]}getFontSizeFromSelection(e){const{from:t,to:n,$from:i,empty:o}=e.selection,{fontSize:s}=e.schema.marks;if(o){const c=this.defaultFontSizeForNode?.[i.parent.type.name]??null;return s.isInSet(e.storedMarks||i.marks())?.attrs.size??c}let l=null;const a=c=>{l===null?l=c??null:c!==l&&(l=Mr)};return e.doc.nodesBetween(t,n,(c,u,d)=>l===Mr?!1:c.isLeaf?(a(s.isInSet(c.marks)?.attrs.size??(d&&this.defaultFontSizeForNode?.[d.type.name])),!0):(c.type.allowsMarkType(s)&&c.childCount===0&&a(this.defaultFontSizeForNode?.[c.type.name]),!0)),l}setFontSize(e){return(t,n)=>{const{from:i,to:o,empty:s,$from:l}=t.selection,{fontSize:a}=t.schema.marks;if(!_e(a,{size:e})(t))return!1;const c=t.tr;if(s){const d=(t.storedMarks||[]).filter(h=>h.type!==a),f=this.defaultFontSizeForNode?.[l.parent.type.name];e!==f&&d.push(a.create({size:e})),c.setStoredMarks(d)}else c.addMark(i,o,a.create({size:e})),c.doc.nodesBetween(i,o,(u,d,f)=>{if(!u.isInline)return;const h=a.isInSet(u.marks),p=this.defaultFontSizeForNode?.[f.type.name];h&&h.attrs.size===p&&c.step(new be(d,d+u.nodeSize,h))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{const i=this.getFontSizeFromSelection(t);if(i===null||i===Mr)return!1;const s=this.fontSizes.findIndex(l=>l.size===i)+e;return s<0||s>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[s].size)(t,n)}}}const Sf=m.featureFacade(yf),kf=["p",0],Tf=["blockquote",0],Cf=["hr"],Mf=["pre",["code",0]],xf=["br"],Of={doc:{content:"block+"},paragraph:{content:"inline*",group:"block",parseDOM:[{tag:"p"}],toDOM(){return kf}},blockquote:{content:"block+",group:"block",defining:!0,parseDOM:[{tag:"blockquote"}],toDOM(){return Tf}},horizontal_rule:{group:"block",parseDOM:[{tag:"hr"}],toDOM(){return Cf}},heading:{attrs:{level:{default:1,validate:"number"}},content:"inline*",group:"block",defining:!0,parseDOM:[{tag:"h1",attrs:{level:1}},{tag:"h2",attrs:{level:2}},{tag:"h3",attrs:{level:3}},{tag:"h4",attrs:{level:4}},{tag:"h5",attrs:{level:5}},{tag:"h6",attrs:{level:6}}],toDOM(r){return["h"+r.attrs.level,0]}},code_block:{content:"text*",marks:"",group:"block",code:!0,defining:!0,parseDOM:[{tag:"pre",preserveWhitespace:"full"}],toDOM(){return Mf}},text:{group:"inline"},image:{inline:!0,attrs:{src:{validate:"string"},alt:{default:null,validate:"string|null"},title:{default:null,validate:"string|null"}},group:"inline",draggable:!0,parseDOM:[{tag:"img[src]",getAttrs(r){return{src:r.getAttribute("src"),title:r.getAttribute("title"),alt:r.getAttribute("alt")}}}],toDOM(r){let{src:e,alt:t,title:n}=r.attrs;return["img",{src:e,alt:t,title:n}]}},hard_break:{inline:!0,group:"inline",selectable:!1,parseDOM:[{tag:"br"}],toDOM(){return xf}}},Ef=["em",0],Df=["strong",0],Nf=["code",0],yi={link:{attrs:{href:{validate:"string"},title:{default:null,validate:"string|null"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(r){return{href:r.getAttribute("href"),title:r.getAttribute("title")}}}],toDOM(r){let{href:e,title:t}=r.attrs;return["a",{href:e,title:t},0]}},em:{parseDOM:[{tag:"i"},{tag:"em"},{style:"font-style=italic"},{style:"font-style=normal",clearMark:r=>r.type.name=="em"}],toDOM(){return Ef}},strong:{parseDOM:[{tag:"strong"},{tag:"b",getAttrs:r=>r.style.fontWeight!="normal"&&null},{style:"font-weight=400",clearMark:r=>r.type.name=="strong"},{style:"font-weight",getAttrs:r=>/^(bold(er)?|[5-9]\d{2,})$/.test(r)&&null}],toDOM(){return Df}},code:{code:!0,parseDOM:[{tag:"code"}],toDOM(){return Nf}}};new m.Schema({nodes:Of,marks:yi});class nn extends m.RteFeatureImpl{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}}class wf extends nn{constructor(){super(...arguments),this.name="RteBoldFeature",this.markName="bold"}getSchema(){return[this.contribution({marks:{bold:yi.strong}})]}getPlugins(e){return[this.contribution(Y({"Mod-b":_e(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>tn(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:"bold-line",markType:e.schema.marks.bold})},1)]}}const Af=m.featureFacade(wf);class vf extends nn{constructor(){super(...arguments),this.name="RteItalicFeature",this.markName="italic"}getSchema(){return[this.contribution({marks:{italic:yi.em}})]}getPlugins(e){return[this.contribution(Y({"Mod-i":_e(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>tn(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:"italic-line",markType:e.schema.marks.italic})},2)]}}const Rf=m.featureFacade(vf);class If extends nn{constructor(){super(...arguments),this.name="RteUnderlineFeature",this.markName="underline"}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:"u"}],toDOM(){return["u",0]}}}})]}getPlugins(e){return[this.contribution(Y({"Mod-u":_e(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>tn(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:"underline-line",markType:e.schema.marks.underline})},3)]}}const Ff=m.featureFacade(If);class Pf extends nn{constructor(){super(...arguments),this.name="RteStrikethroughFeature",this.markName="strikethrough"}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:"s"},{tag:"del"}],toDOM(){return["s",0]}}}})]}getPlugins(e){return[this.contribution(Y({"Alt-Shift-5":_e(e.schema.marks.strikethrough),"Cmd-Shift-X":_e(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>tn(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:"strikethrough-line",markType:e.schema.marks.strikethrough})},4)]}}const Lf=m.featureFacade(Pf),zf="tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}";class Bf extends nn{constructor(){super(...arguments),this.name="RteMonospaceFeature",this.markName="monospace"}getStyles(){return[this.contribution(zf)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:"tt"},{tag:"code"}],toDOM(){return["tt",0]}}}})]}getPlugins(e){return[this.contribution(Y({"Mod-M":_e(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:"text-style",render:t=>tn(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:"monospace-line",markType:e.schema.marks.monospace})},5)]}}const _f=m.featureFacade(Bf);function Vf(r,e,t){for(let n=0;n<e.length;n++){const{$from:i,$to:o}=e[n];let s=i.depth==0?r.type.allowsMarkType(t):!1;if(r.nodesBetween(i.pos,o.pos,l=>s?!1:(s=l.inlineContent&&l.type.allowsMarkType(t),!0)),s)return!0}return!1}const xr=Symbol("mixedColor");class Hf extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteTextColorPicker",e?.onBlocks){this.defaultColorForNode={};for(const t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:"textColor",onNodeName:e.node})):[this.contribution({markName:"textColor"})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:"string"}},parseDOM:[{tag:"span[data-text-color]",getAttrs:e=>({color:e.getAttribute("data-text-color")})},{style:"color",getAttrs:e=>({color:e})}],toDOM(e){const{color:t}=e.attrs;return["span",{style:`color: ${gi(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:"text-style",render:e=>{const t=V(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor("any")(e.view.state),icon:"textcolor-line"}),n=t.firstElementChild;return he(e,{children:[t,cd(e,{name:"text-color-picker",assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||""},assignedEvents:{change:i=>{const o=i.currentTarget.value;this.setColor(o)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){const{selection:t}=e,{textColor:n}=e.schema.marks,{from:i,to:o,$from:s,empty:l}=t;if(l){const u=this.defaultColorForNode?.[s.parent.type.name]??null;return n.isInSet(e.storedMarks||s.marks())?.attrs.color??u}let a=null;const c=u=>{a===null?a=u??null:u!==a&&(a=xr)};return e.doc.nodesBetween(i,o,(u,d,f)=>a===xr?!1:u.isLeaf?(c(n.isInSet(u.marks)?.attrs.color??(f&&this.defaultColorForNode?.[f.type.name])),!0):(u.type.allowsMarkType(n)&&u.childCount===0&&c(this.defaultColorForNode?.[u.type.name]),!0)),a===xr?null:a}setColor(e){return(t,n)=>{const{textColor:i}=t.schema.marks,{from:o,to:s,empty:l,$from:a}=t.selection;if(!Vf(t.doc,t.selection.ranges,i))return!1;const c=t.tr;if(l){const d=(t.storedMarks||[]).filter(h=>h.type!==i),f=this.defaultColorForNode?.[a.parent.type.name];e!==f&&d.push(i.create({color:e})),c.setStoredMarks(d)}else c.addMark(o,s,i.create({color:e})),c.doc.nodesBetween(o,s,(u,d,f)=>{if(!u.isInline)return;const h=i.isInSet(u.marks),p=this.defaultColorForNode?.[f.type.name];h&&h.attrs.color===p&&c.step(new be(d,d+u.nodeSize,h))});return n?.(c.scrollIntoView()),!0}}}const Wf=m.featureFacade(Hf),Uf=".rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}",Or=r=>r.parentOffset===0,$f=r=>r.nodeSize===2,At=r=>r.depth-1,$r=r=>r.depth-2,Al=r=>r.parent,qr=r=>r.node(At(r)),vl=r=>r.depth>2,Rl=(r,e)=>r.index(e)===0,qf=(r,e)=>r.index(e)===r.node(e).childCount-1,Il=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n-1)},Kf=(r,e)=>{const t=r.node(e),n=r.index(e);return t.maybeChild(n+1)},Ko=r=>{let{$from:e,$to:t}=r;if(r instanceof j){const n=O.between(r.$from,r.$to);e=n.$from,t=n.$to}return{$from:e,$to:t}},Go=(r,e)=>r.sameParent(e)?r.node(-1):r.node(r.sharedDepth(e.pos)),mn=r=>{const{$cursor:e}=r.selection;return e?.parent.type===r.schema.nodes.listItem?e:null},Jo=(r,e,t,n)=>{let i,o=!0;return r.doc.nodesBetween(e.pos,t.pos,s=>{s.type.isInGroup("list")&&(i=s.type),s.type===r.schema.nodes.listItem&&i!==n&&(o=!1)}),o},Er=(r,e,t)=>{vl(e)?Fl(e,t):Gf(r,e,t)},Fl=(r,e)=>{const t=new m.NodeRange(r.doc.resolve(r.before()),r.doc.resolve(r.after()),r.depth-1);e.lift(t,r.depth-2)},Gf=(r,e,t)=>{const n=qr(e),i=e.index($r(e)),o=hl(e.node($r(e)).contentMatchAt(i+1)),s=Rl(e,At(e)),l=qf(e,At(e));t.step(new te(e.before()-(s?1:0),e.after()+(l?1:0),e.start(),e.end(),new m.Slice((s?m.Fragment.empty:m.Fragment.from(n.copy(m.Fragment.empty))).append(m.Fragment.from(o.create(r.textblockAttrs.extractFromNode(Al(e))))).append(l?m.Fragment.empty:m.Fragment.from(n.copy(m.Fragment.empty))),s?0:1,l?0:1),(s?0:1)+1))},Jf=(r,e,t,n)=>{t.parent.type===r.schema.nodes.listItem?Pl(e,t,n):jf(r,e,t,n)},Pl=(r,e,t)=>{const n=Il(e,At(e))?.type===r,i=Kf(e,At(e))?.type===r,o=n?1:0,s=i?1:0;t.step(new te(e.before()-(n?1:0),e.after()+(i?1:0),e.before(),e.after(),new m.Slice(m.Fragment.from(r.create(null,[])),o,s),1-o))},jf=(r,e,t,n)=>{n.step(new te(t.before(),t.after(),t.start(),t.end(),new m.Slice(m.Fragment.from(e.create(null,[r.schema.nodes.listItem.create(r.textblockAttrs.extractFromNode(t.parent))])),0,0),2))};class Yf extends m.RteFeatureImpl{constructor(e){if(super(),this.config=e,this.name="RteListFeature",!e.bulletList&&!e.numberedList)throw new Error("RteListFeature requires at least one of bulletList or numberedList to be enabled")}getStyles(){return[this.contribution(Uf)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:"inline*",attrs:e.attrs,defining:!0,parseDOM:[{tag:"li",getAttrs:t=>e.fromDOM(t)}],toDOM(t){return["li",...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ul"}],toDOM(){return["ul",0]}}}:{},...this.config.numberedList?{numberedList:{group:"block list",content:"(listItem | list)+",parseDOM:[{tag:"ol"}],toDOM(){return["ol",0]}}}:{}}})]}getPlugins(e){this.rte=e;const t=(s,l)=>{const a=mn(s);if(a&&Or(a)){const c=s.tr;return Pl(qr(a).type,a,c),l?.(c.scrollIntoView()),!0}return!1},n=(s,l)=>{const a=mn(s);if(a&&Or(a)&&vl(a)){const c=s.tr;return Fl(a,c),l?.(c.scrollIntoView()),!0}return!1},i=(s,l)=>{const a=mn(s);if(a&&$f(Al(a))){const c=s.tr;return Er(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1},o=(s,l)=>{const a=mn(s);if(a&&Or(a)){if(Rl(a,At(a))&&Il(a,$r(a))?.type===qr(a).type)return!1;const c=s.tr;return Er(this.rte,a,c),l?.(c.scrollIntoView()),!0}return!1};return[this.contribution(Y({Enter:i,Backspace:o,Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),m.contributionPriority.high)]}getToolbarItems(e){const t=[];return this.config.bulletList&&t.push(this.contribution({section:"textblock",render:n=>V(n,{label:()=>n.rte.getLocale().richTextEditor.bulletList,icon:"bullet-list-2-line",active:()=>this.isSelectionInList(e.schema.nodes.bulletList,n.rte.state),onClick:()=>{const{state:i,dispatch:o}=n.view;this.toggleList(e.schema.nodes.bulletList)(i,o)}})},1)),this.config.numberedList&&t.push(this.contribution({section:"textblock",render:n=>V(n,{label:()=>n.rte.getLocale().richTextEditor.numberedList,icon:"list-numbered-line",active:()=>this.isSelectionInList(e.schema.nodes.numberedList,n.rte.state),onClick:()=>{const{state:i,dispatch:o}=n.view;this.toggleList(e.schema.nodes.numberedList)(i,o)}})},2)),t}toggleList(e){return Iu((t,n)=>{const{$from:i,$to:o}=Ko(t.selection);if(Go(i,o).type.isInGroup("list"))if(Jo(t,i,o,e)){const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{if(a.type===t.schema.nodes.listItem){const u=l.doc.resolve(l.mapping.map(c+1));Er(this.rte,u,l)}}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{a.type.isInGroup("list")&&a.type!==e&&l.setNodeMarkup(c,e,a.attrs)}),n?.(l.scrollIntoView()),!0}else{const l=t.tr;return t.doc.nodesBetween(i.pos,o.pos,(a,c)=>{if(!a.isTextblock)return;const u=l.doc.resolve(l.mapping.map(c+1));Jf(this.rte,e,u,l)}),n?.(l.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){const{$from:n,$to:i}=Ko(t.selection);return Go(n,i).type.isInGroup("list")?Jo(t,n,i,e):!1}}const Xf=m.featureFacade(Yf),Kr=[{value:"left",icon:"align-left-line",label:"left"},{value:"center",icon:"align-center-line",label:"center"},{value:"right",icon:"align-right-line",label:"right"}],jo=r=>Kr.find(e=>e.value===r)?.value??"left";class Zf extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteAlignmentFeature"}getTextblockAttrs(){return[this.contribution({name:"textAlign",default:"left",fromDOM(e){return jo(e.style.textAlign)},toStyles(e){return[`text-align: ${jo(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(Y({"Mod-L":this.setAlignment("left"),"Mod-E":this.setAlignment("center"),"Mod-R":this.setAlignment("right")}))]}getToolbarItems(){return[this.contribution({section:"textblock",render:e=>pi(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:V(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{const t=this.getAlignmentFromSelection(e.view.state);return Kr.find(n=>n.value===t)?.icon??"align-left-line"}}),children:[od(e,{children:Kr.map((t,n)=>V(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:"header",noTooltip:!0,autofocus:()=>{const i=this.getAlignmentFromSelection(e.view.state);return(i==="mixed"||i===null)&&n===0?!0:t.value===i},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{const{state:i,dispatch:o}=e.view;this.setAlignment(t.value)(i,o)}}))})]})},3)]}getAlignmentFromSelection(e){const{selection:t}=e,{from:n,to:i}=t;let o=null;return e.doc.nodesBetween(n,i,s=>{o!=="mixed"&&s.type.isTextblock&&(o?o!==s.attrs.textAlign&&(o="mixed"):o=s.attrs.textAlign)}),o}setAlignment(e){return(t,n)=>{const{tr:i,selection:o}=t,{from:s,to:l}=o;return t.doc.nodesBetween(s,l,(a,c)=>{a.type.isTextblock&&i.setNodeMarkup(c,a.type,{...a.attrs,textAlign:e})}),n?.(i.scrollIntoView()),!0}}}const Qf=m.featureFacade(Zf),eh=".link-popover{display:flex;flex-direction:column;padding:16px;gap:8px;inline-size:450px}.link-popover-header{display:flex;align-items:center;justify-content:space-between}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{display:flex;flex-direction:column;gap:16px}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{display:flex;justify-content:end;gap:8px}.link-toolbar-menu{display:flex;flex-direction:column;padding:8px;gap:16px;inline-size:368px}",Yo="(?:https?://|www\\.)[^\\s<]+";function Xo(r,e,t,n){if(r.doc.rangeHasMark(t,t+1,r.schema.marks.link))return null;const i=e.replace(/[.,;:!?) ]+$/,""),o=i.startsWith("www.")?`https://${i}`:i,s=r.schema.marks.link.create({href:o}),l=t+i.length,a=e.slice(i.length),c=r.tr.addMark(t,l,s);return a&&c.replaceWith(l,n,r.schema.text(a)),c}class th extends m.RteFeatureImpl{constructor(){super(...arguments),this.name="RteLinkFeature",this.removeLink=(e,t)=>{const n=e.tr,i=this.getCurrentLink(e);return n.removeMark(i.start,i.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(eh)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:"string"}},inclusive:!1,parseDOM:[{tag:"a[href]",getAttrs(e){return{href:e.getAttribute("href")}}}],toDOM(e){const{href:t}=e.attrs;return["a",{href:_d(t)},0]}}}},m.contributionPriority.high)]}getTextblockMarks(){return[this.contribution({markName:"link"})]}getInputRules(){const e=new RegExp(`${Yo}$`);return[this.contribution({rule:new Qe(new RegExp(`${Yo} $`),(t,n,i,o)=>Xo(t,n[0],i,o)),enterHandler:{regex:e,handler:(t,n,i,o)=>Xo(t,n[0],i,o)}})]}getPlugins(e){const t=()=>(this.toolbarMenu.open=!0,!0);return[this.contribution(new B({props:{decorations:n=>{const i=this.getCurrentLink(n);if(i){const o=W.inline(i.start,i.end,{id:"current-link"});return A.create(n.doc,[o])}return null}},view:n=>{const i=new Ln(n,e,{popupPlacement:"bottom"}),o=e.createComponent(Te);o.anchorId="current-link";const s=he(i,{className:"link-popover",children:[he(i,{className:"link-popover-header",children:[he(i,{className:"link-popover-label",children:[Lo(i,{text:()=>this.getCurrentLink(i.view.state)?.text||""})]}),V(i,{icon:"close-line",label:()=>i.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{o.requestOpenState(!1)}})]}),he(i,{className:"link-popover-content",children:[rd(i,{className:"link",href:()=>this.getCurrentLink(i.view.state)?.href||"",target:"_blank",rel:"noopener",children:[Lo(i,{text:()=>this.getCurrentLink(i.view.state)?.href||""})]}),he(i,{className:"link-action-bar",children:[V(i,{icon:"delete-line",label:()=>i.rte.getLocale().richTextEditor.delete,connotation:"alert",variant:"popover",noTooltip:!0,onClick:()=>{const{state:l,dispatch:a}=i.view;this.removeLink(l,a)}}),V(i,{icon:"edit-line",label:()=>i.rte.getLocale().richTextEditor.edit,variant:"popover",noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,o.requestOpenState(!1),!0)})]})]})]});return o.appendChild(s),n.dom.getRootNode().querySelector(".popovers").appendChild(o),{update:l=>{const a=l.state;i.updateBindings();const c=this.getCurrentLink(a);o.requestOpenState(!!c)},destroy:()=>{o.remove()}}}})),this.contribution(Y({"Mod-k":t}))]}getToolbarItems(e){const t=i=>{const{from:o,to:s}=i.selection;return o===s?"":i.doc.textBetween(o,s," ")},n=i=>{try{return new URL(i),!0}catch{return!1}};return[this.contribution({section:"insert",render:i=>{const o=Po(i,{label:()=>i.rte.getLocale().richTextEditor.linkText,placeholder:()=>i.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:"header",autofocus:!0,value:()=>this.getCurrentLink(i.view.state)?.text||t(i.view.state)||"",onInput:()=>{a()}}),s=Po(i,{label:()=>i.rte.getLocale().richTextEditor.linkUrl,type:"url",placeholder:()=>i.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:"header",value:()=>this.getCurrentLink(i.view.state)?.href||"",onInput:()=>{a()}}),l=V(i,{label:()=>i.rte.getLocale().richTextEditor.apply,variant:"popover-primary",disabled:()=>{const u=this.getCurrentLink(i.view.state);return!(u&&u.text.length&&n(u.href))},onClick:()=>{const{state:u,dispatch:d}=i.view;this.insertLink(e,s.value,o.value)(u,d)}}),a=()=>{l.querySelector('[data-vvd-component="button"]').disabled=!(o.value.length&&n(s.value))},c=pi(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,trigger:V(i,{label:()=>i.rte.getLocale().richTextEditor.hyperlink,icon:"link-line"}),children:[he(i,{className:"link-toolbar-menu",slot:"header",children:[o,s,he(i,{className:"link-action-bar",slot:"header",children:[V(i,{label:()=>i.rte.getLocale().richTextEditor.cancel,variant:"popover",onClick:()=>{this.toolbarMenu.open=!1}}),l]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){const t=e.selection;if(!(t instanceof O))return null;const n=e.schema.marks.link,{$from:i,$to:o}=t,s=e.selection.empty?i.marks():i.nodeAfter?.marks??[],l=n.isInSet(s)?.attrs.href;if(!l)return null;const a=h=>n.isInSet(h.marks)?.attrs.href===l;let c=-1,u=-1,d=!0;return e.doc.nodesBetween(i.start(),o.end(),(h,p)=>{if(!h.isText)return!0;const b=p+h.nodeSize;return a(h)?(c===-1&&(c=p),u=b):b>t.from&&p<t.to&&(d=!1),!1}),!d||c===-1?null:{text:e.doc.textBetween(c,u," "),href:l,start:c,end:u}}insertLink(e,t,n){return(i,o)=>{let{from:s,to:l}=i.selection;const a=i.tr,c=this.getCurrentLink(i);return c&&(s=c.start,l=c.end),a.insertText(n,s,l),a.addMark(s,s+n.length,e.schema.marks.link.create({href:t})),o?.(a.scrollIntoView()),!0}}}const nh=m.featureFacade(th),rh=".inline-image-wrapper{display:inline-block;vertical-align:text-bottom}.inline-image{display:block;block-size:auto}.inline-image-popover{display:flex;align-items:center;padding:8px;gap:4px}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}",Zo=r=>r!==null&&!!r.next;let ih=1;const oh=()=>ih++;class sh{constructor(e,t,n,i){this.view=t,this.getPos=n,this.config=i,this.content=null,this.dom=document.createElement("div"),this.dom.className="inline-image-wrapper",this.imageUrl=e.attrs.imageUrl,this.img=document.createElement("img"),this.initializeImg(e);const o=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,s=Zo(o)?null:o;this.handleResolvedUrl(s),Zo(o)&&this.handleResolvedUrlGenerator(o)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),Te.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){const t=e[Symbol.asyncIterator]();let n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e=="string")this.renderImg(e);else if(e?.type==="placeholder"){const t=`inline-image-placeholder-${oh()}`,n=document.createElement("slot");n.className="inline-image-placeholder",n.name=t;const i=e.create?.(t),o=this.view.dom.getRootNode().host;m.dispatchSlottableRequest(o,"inline-image-placeholder",t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{m.dispatchSlottableRequest(o,"inline-image-placeholder",t,m.removeSymbol),i?.()}})}else this.setContent(null)}initializeImg(e){this.img.className="inline-image",this.update(e),this.img.addEventListener("load",()=>{const t=this.getPos?.();if(t){const{state:n,dispatch:i}=this.view,o=n.doc.nodeAt(t);if(!o||o.attrs.naturalWidth===this.img.naturalWidth&&o.attrs.naturalHeight===this.img.naturalHeight)return;const s=n.tr;s.setNodeAttribute(t,"naturalWidth",this.img.naturalWidth),s.setNodeAttribute(t,"naturalHeight",this.img.naturalHeight),s.setMeta("addToHistory",!1),i(s)}})}renderImg(e){this.img.src=xl(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}}class lh extends m.RteFeatureImpl{constructor(e={}){super(),this.config=e,this.name="RteInlineImageFeature"}getStyles(){return[this.contribution(rh)]}getSchema(){const e={inline:!0,group:"inline",selectable:!0,atom:!0,attrs:{imageUrl:{validate:"string"},alt:{validate:"string",default:""},size:{validate:"string|null",default:null},naturalWidth:{validate:"number|null",default:null},naturalHeight:{validate:"number|null",default:null}},parseDOM:[{tag:"img[src],img[data-src]",getAttrs:t=>{const n=s=>{const l=parseInt(s??"",10);return isNaN(l)?null:l},i=t.getAttribute("data-src")??t.getAttribute("src"),o=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(i):i;return o===null?!1:{imageUrl:o,alt:t.getAttribute("alt")||"",size:t.style.maxWidth||null,naturalWidth:n(t.getAttribute("width")),naturalHeight:n(t.getAttribute("height"))}}}],toDOM:t=>{const{imageUrl:n,alt:i,size:o,naturalWidth:s,naturalHeight:l}=t.attrs,a=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(n):n;if(a===null)return document.createTextNode("");const c={src:xl(a),"data-src":a,alt:i};return o&&(c.style=`max-width: ${gi(o)}; height: auto;`),s&&(c.width=s),l&&(c.height=l),["img",c]}};return[this.contribution({nodes:{inlineImage:e}})]}getPlugins(e){return[this.contribution(new B({props:{nodeViews:{inlineImage:(t,n,i)=>new sh(t,n,i,this.config)}},view:t=>{const n=new Ln(t,e,{popupPlacement:"bottom"}),i=e.createComponent(Te);i.offset=4;const o=he(n,{className:"inline-image-popover",children:[V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="small",onClick:()=>{this.setSelectedImageSize("small")(n.view.state,n.view.dispatch)}}),Vr(n),V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="fit",onClick:()=>{this.setSelectedImageSize("fit")(n.view.state,n.view.dispatch)}}),Vr(n),V(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:"popover",active:()=>this.getSelectedImageSize(n.view.state)==="original",onClick:()=>{this.setSelectedImageSize("original")(n.view.state,n.view.dispatch)}})]});return i.appendChild(o),t.dom.getRootNode().querySelector(".popovers").appendChild(i),{update:s=>{n.updateBindings();const l=this.getSelectedInlineImage(s.state);l?(i.anchorEl=s.nodeDOM(l.pos),i.requestOpenState(!0)):(i.anchorEl=void 0,i.requestOpenState(!1))},destroy:()=>{i.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+"px"}getSelectedInlineImage(e){const t=e.selection;return t instanceof M&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{const i=this.getSelectedInlineImage(t);if(!i)return!1;const{naturalWidth:o}=i.node.attrs;if(e==="small"&&o===null)return!1;const s=t.tr;return s.setNodeAttribute(i.pos,"size",e==="small"?this.calculateSmallWidth(o):e==="fit"?"100%":null),n?.(s.scrollIntoView()),!0}}getSelectedImageSize(e){const t=this.getSelectedInlineImage(e);if(!t)return null;const{size:n,naturalWidth:i}=t.node.attrs;return i!==null&&n===this.calculateSmallWidth(i)?"small":n==="100%"?"fit":n===null?"original":null}}const ah=m.featureFacade(lh),ch=async r=>{try{return{type:"ok",result:await r}}catch(e){return{type:"error",error:e}}};class uh extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteFileHandlerFeature"}getPlugins(e){const t=new B({state:{init(){return A.empty},apply(a,c){c=c.map(a.mapping,a.doc);const u=a.getMeta(t);if(u&&u.add){const d=document.createElement("placeholder"),f=W.widget(u.add.pos,d,{id:u.add.id,relaxedSide:!0});c=c.add(a.doc,[f])}else u&&u.remove&&(c=c.remove(c.find(void 0,void 0,d=>d.id==u.remove.id)));return c}},props:{decorations(a){return this.getState(a)}}}),n=(a,c)=>{const u=Xl.generateRandomId();return a.setMeta(t,{add:{id:u,pos:c}}),{getPos:d=>{const h=t.getState(d).find(void 0,void 0,p=>p.id==u);return h.length?h[0].from:null},remove:d=>{d.setMeta(t,{remove:{id:u}})}}},i=(a,c,u)=>{if(u.type==="selection"){const d=m.Slice.fromJSON(e.schema,{content:c});a.replaceSelection(d)}else{const d=m.Fragment.fromJSON(e.schema,c);a.insert(u.pos,d)}},o=(a,c)=>{const u=this.config.handleFiles(a);u!==null&&(u instanceof Promise?l(u,c):s(u,c))},s=(a,c)=>{const u=e.state.tr;i(u,a,c),e.dispatchTransaction(u)},l=async(a,c)=>{const u=e.state.tr;c.type==="selection"&&!u.selection.empty&&u.deleteSelection();const d=c.type==="selection"?u.selection.from:c.pos,f=n(u,d);e.dispatchTransaction(u);const h=await ch(a),p=f.getPos(e.state),b=e.state.tr;f.remove(b),p!==null&&h.type==="ok"&&i(b,h.result,{type:"pos",pos:p}),e.dispatchTransaction(b),h.type==="error"&&console.error("Error in handleFiles handler:",h.error)};return[this.contribution(t),this.contribution(new B({props:{handlePaste:(a,c)=>{const u=Array.from(c.clipboardData.files);return u.length?(o(u,{type:"selection"}),!0):!1},handleDrop:(a,c,u,d)=>{const f=Array.from(c.dataTransfer.files);if(!f.length)return!1;let h=a.posAtCoords({left:c.clientX,top:c.clientY}).pos;if(a.dragging&&a.dragging.slice){const p=Qr(a.state.doc,h,a.dragging.slice);p!=null&&(h=p)}return o(f,{type:"pos",pos:h}),!0}}}))]}}const dh=m.featureFacade(uh);class fh extends m.RteFeatureImpl{constructor(e){super(),this.config=e,this.name="RteDebugFeature"}getPlugins(e){const t=new WeakMap;let n=!1;const i=u=>{t.get(u)===void 0&&(n=this.config.onViewportDragOver?.(u)??!1)},o=u=>{this.config.onViewportDrop?.(u),this.config.onViewportDragFinish?.()},s=()=>{this.config.onViewportDragFinish?.()};let l=!1;const a=()=>{l=!0,window.setTimeout(()=>l=!1,0)},c=()=>{l||this.config.onViewportDragFinish?.()};return[this.contribution(new B({view:u=>{const d=u.root.host.editorViewportElement;return d.addEventListener("dragover",i),d.addEventListener("drop",o),d.addEventListener("dragend",s),d.addEventListener("dragenter",a),d.addEventListener("dragleave",c),{destroy(){d.removeEventListener("dragover",i),d.removeEventListener("drop",o),d.removeEventListener("dragend",s),d.removeEventListener("dragenter",a),d.removeEventListener("dragleave",c)}}}})),this.contribution(new B({props:{handleDOMEvents:{dragover:(u,d)=>{const f=this.config.onViewportDragOver?.(d)??!1;return t.set(d,f),n=f,f?(d.stopImmediatePropagation(),d.preventDefault(),!0):!1},drop:(u,d)=>n}}}),m.contributionPriority.high)]}}const hh=m.featureFacade(fh);class ph extends m.RteFeatureImpl{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:"insert",render:e=>V(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/Number.MAX_SAFE_INTEGER)]}executeAction(e){const{action:t}=this.options;if(t.type==="insert-text"){const{state:n,dispatch:i}=e.view,{from:o,to:s}=n.selection,l=n.tr.insertText(t.text,o,s);i(l)}}}const mh=m.featureFacade(ph),gh=r=>r!==null&&typeof r=="object"&&"next"in r;class bh{constructor(e,t,n){this.dom=document.createElement("span"),this.dom.className="atom-wrapper",this.dom.setAttribute("part",`node--${n}`);const i=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;gh(i)?(this.dom.textContent="",this.handleResolvedGenerator(i)):this.dom.textContent=i??""}async handleResolvedGenerator(e){const t=e[Symbol.asyncIterator]();let n;do n=await t.next(),this.dom.textContent=n.value??"";while(!n.done)}}class yh extends m.RteFeatureImpl{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){const e={inline:!0,group:"inline",selectable:!0,atom:!0,attrs:{value:{validate:"string"}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:t=>({value:t.getAttribute("data-value")})}],toDOM:t=>{const n=this.config.serializeValueToHtml?this.config.serializeValueToHtml(t.attrs.value):t.attrs.value;return n===null?document.createDocumentFragment():["span",{part:`node--${this.atomName}`},n]},serializeToDOM:t=>{const n=this.config.serializeValueToHtml?this.config.serializeValueToHtml(t.attrs.value):t.attrs.value;return n===null?document.createTextNode(""):["span",{"data-atom-type":this.atomName,"data-value":t.attrs.value},n]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new B({props:{nodeViews:{[this.atomName]:t=>new bh(t,this.config,this.atomName)}}}))]}}const Sh=m.featureFacade(yh);class kh extends m.RteFeatureImpl{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){const t=`(?:${this.options.pattern.source})`,n=(l,a,c,u)=>{const d=this.options.handler(a);return d?l.tr.replaceWith(c,u,m.Fragment.fromJSON(e.schema,d)):null},i=this.options.matchAfterWhitespace?new RegExp(`${t} $`):new RegExp(`${t}$`),s={rule:new Qe(i,n)};return this.options.matchAfterWhitespace&&(s.enterHandler={regex:new RegExp(`${t}$`),handler:n}),[this.contribution(s)]}}const Th=m.featureFacade(kh);function Ch(r,e){return r.length===0?(t,n)=>r():(t,n)=>r(e)}class Mh extends m.RteFeatureImpl{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){const t={};for(const[n,i]of Object.entries(this.options.shortcuts))t[n]=Ch(i,e.facade);return[this.contribution(Y(t),m.contributionPriority.high)]}}const xh=m.featureFacade(Mh),Oh=".suggest-popover{display:flex;flex-direction:column;padding:4px;gap:2px;max-block-size:408px;max-inline-size:248px;min-inline-size:128px}.suggest-loading-widget{display:inline-flex;align-items:center;margin-inline-start:2px;vertical-align:middle;white-space:normal}.suggest-empty-message{display:flex;align-items:center;justify-content:center;color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);min-block-size:40px;text-align:center}.suggest-item--visible-focus{box-shadow:0 0 0 4px color-mix(in srgb,var(--focus-stroke-color, var(--vvd-color-cta-500)),transparent 85%),inset 0 0 0 3px var(--focus-stroke-gap-color, currentColor);outline:1px solid var(--focus-stroke-color, var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset, 0px));--focus-stroke-gap-color: transparent}",Gr=r=>!!(r?.suggestions&&!r.dismissed),Dr=r=>Gr(r)&&r.suggestions.items.length>0;function Eh(r,e){const{$cursor:t}=r.selection;if(!t)return null;const n=wl(t),i=e.exec(n);if(!i)return null;const o=t.pos-t.parentOffset;return{text:i[0],groups:[...i],start:o+i.index,end:o+i.index+i[0].length}}const Dh=(r,e,t)=>{const{state:n}=r;r.dispatch(td(n.tr));const i=r.state.tr;i.replaceWith(e.start,e.end,m.Fragment.fromJSON(r.state.schema,t));const o=i.mapping.map(e.end);i.setSelection(O.create(i.doc,o)),r.dispatch(i.scrollIntoView())};class Nh extends m.RteFeatureImpl{constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new ni("suggest"),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}selectSuggestion(e,t,n){const i=this.options.select(n);Dh(e,t.match,i),e.focus()}async startLoadingSuggestions(e,t){const n=++this.loadGeneration,i=await this.options.load(e);n===this.loadGeneration&&t({type:"load",generation:n,suggestions:i})}getStyles(){return[this.contribution(Oh)]}getPlugins(e){const t=o=>e.state.tr.setMeta(this.pluginKey,o),n=o=>e.dispatchTransaction(t(o)),i=new B({key:this.pluginKey,state:{init:()=>null,apply:(o,s,l,a)=>{const c=Eh(a,this.options.pattern);if(!c||!s&&!o.docChanged)return null;if(s?.dismissed)return s;const u=h=>h?!!(s?.loadingDecoration.find().length??0)?s.loadingDecoration.map(o.mapping,o.doc):A.create(o.doc,[W.widget(c.end,()=>{const b=document.createElement("span");b.className="suggest-loading-widget";const y=e.createComponent(is.ProgressRing);return y.size=-6,b.appendChild(y),b},{ignoreSelection:!0,side:1})]):A.empty,d=o.getMeta(this.pluginKey);if(s&&d)switch(d.type){case"load":return{...s,suggestions:{generation:d.generation,items:d.suggestions,selectedIndex:0,visibleFocus:!1},loadingDecoration:u(!1)};case"navigate":{if(!s.suggestions?.items.length)return s;if(!s.suggestions.visibleFocus)return{...s,suggestions:{...s.suggestions,visibleFocus:!0}};const h=Math.max(0,Math.min(s.suggestions.items.length-1,s.suggestions.selectedIndex+(d.action==="up"?-1:1)));return{...s,suggestions:{...s.suggestions,selectedIndex:h}}}case"dismiss":return{...s,dismissed:!0,loadingDecoration:A.empty}}if(!s)return this.startLoadingSuggestions(c.groups,n),{match:c,loadingDecoration:u(!0)};const f=c.groups[0]!==s.match.groups[0];return f&&this.startLoadingSuggestions(c.groups,n),{...s,match:c,suggestions:s.suggestions?{...s.suggestions,visibleFocus:!1}:void 0,loadingDecoration:u(f)}}},props:{decorations:o=>{const s=this.pluginKey.getState(o);return s?s.loadingDecoration.add(o.doc,[W.inline(s.match.start,s.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:o=>{const s=new Ln(o,e,{popupPlacement:"bottom"}),l=e.createComponent(Te);l.anchorId=`suggest-anchor-${this.featureId}`,l.kind="autocomplete",l.offset=4;const a=he(s,{className:"suggest-popover",children:[]});l.appendChild(a),o.dom.getRootNode().querySelector(".popovers").appendChild(l);const c=`${this.featureId}-suggestions-empty`,u=o.dom.getRootNode().host;let d=!1;const f=p=>{!d&&p&&m.dispatchSlottableRequest(u,"suggestions-empty-state",c,{id:this.featureId}),d&&!p&&m.dispatchSlottableRequest(u,"suggestions-empty-state",c,m.removeSymbol),d=p},h=p=>{a.innerHTML="";const b=p.suggestions,y=b.items.length===0;if(f(y),y){const k=document.createElement("slot");k.name=c,k.textContent=e.getLocale().richTextEditor.suggestNoResults,a.appendChild(he(s,{className:"suggest-empty-message",children:[k]}));return}for(const[k,R]of b.items.entries()){const N=e.createComponent(Jr.ListboxOption);N.text=R.text,N.textSecondary=R.textSecondary,k===b.selectedIndex&&(N._highlighted=!0,N.dataset.highlighted="true",b.visibleFocus&&N.classList.add("suggest-item--visible-focus"),queueMicrotask(()=>{N.scrollIntoView({block:"nearest"})})),N.addEventListener("click",w=>{w.preventDefault(),w.stopPropagation(),this.selectSuggestion(o,p,R)}),a.appendChild(N)}};return{update:p=>{s.updateBindings();const b=this.pluginKey.getState(p.state),y=Gr(b);l.requestOpenState(y),y?h(b):f(!1)},destroy:()=>{f(!1),l.remove()}}}});return[this.contribution(i),this.contribution(Y({ArrowUp:(o,s)=>{const l=this.pluginKey.getState(o);return Dr(l)?(s?.(t({type:"navigate",action:"up"})),!0):!1},ArrowDown:(o,s)=>{const l=this.pluginKey.getState(o);return Dr(l)?(s?.(t({type:"navigate",action:"down"})),!0):!1},Enter:(o,s,l)=>{const a=this.pluginKey.getState(o);if(!Dr(a))return!1;const c=a.suggestions.items[a.suggestions.selectedIndex];return l&&this.selectSuggestion(l,a,c),!0},Escape:(o,s)=>{const l=this.pluginKey.getState(o);return Gr(l)?(s?.(t({type:"dismiss"})),!0):!1}}),m.contributionPriority.high)]}}const wh=m.featureFacade(Nh),Ah=re.defineVividComponent("rich-text-editor",Nl,Gd,[jl.dividerDefinition,Qo.selectDefinition,Jr.listboxOptionDefinition,ss.buttonDefinition,es.tooltipDefinition,ts.menuDefinition,ns.menuItemDefinition,rs.textFieldDefinition,Xd,is.progressRingDefinition],{styles:Zl,shadowOptions:{delegatesFocus:!0}}),vh=re.createRegisterFunction(Ah);vh();exports.RteAlignmentFeature=Qf;exports.RteAtomFeature=Sh;exports.RteBase=lf;exports.RteBoldFeature=Af;exports.RteConfig=uu;exports.RteDropHandlerFeature=hh;exports.RteFileHandlerFeature=dh;exports.RteFontSizePickerFeature=Sf;exports.RteHardBreakFeature=bf;exports.RteHtmlParser=Ol;exports.RteHtmlSerializer=El;exports.RteInlineImageFeature=ah;exports.RteInputRuleFeature=Th;exports.RteItalicFeature=Rf;exports.RteKeyboardShortcutsFeature=xh;exports.RteLinkFeature=nh;exports.RteListFeature=Xf;exports.RteMonospaceFeature=_f;exports.RtePlaceholderFeature=mf;exports.RteStrikethroughFeature=Lf;exports.RteSuggestFeature=wh;exports.RteTextBlockPickerFeature=cf;exports.RteTextColorPickerFeature=Wf;exports.RteToolbarButtonFeature=mh;exports.RteToolbarFeature=ff;exports.RteUnderlineFeature=Ff;
24
+ </${n}>`},y=class extends t.t{constructor(...e){super(...e),this.kind=`default`,this.anchorBlocksPopover=!1,this.onAnchorBlockPopoverChanged=()=>{this.anchorBlocksPopover=this.anchorEl?.dataset.blockPopover===`true`||!1},this.requestedOpenState=!1}static setBlockPopover(e,t){e.dataset.blockPopover=t?`true`:`false`;let n=new CustomEvent(`block-popover-changed`,{bubbles:!1,composed:!1});e.dispatchEvent(n)}anchorElChanged(e,t){e?.removeEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),t?.addEventListener(`block-popover-changed`,this.onAnchorBlockPopoverChanged),this.onAnchorBlockPopoverChanged()}anchorIdChanged(){this.updateAnchor()}updateAnchor(){this.anchorId&&this.isConnected?this.anchorEl=this.getRootNode().getElementById(this.anchorId)||void 0:this.anchorEl=void 0}requestOpenState(e){this.requestedOpenState=e}get open(){return this.requestedOpenState&&!!this.anchorEl&&!this.anchorBlocksPopover}#e;connectedCallback(){super.connectedCallback(),this.updateAnchor(),this.#e=new MutationObserver(e=>{e.some(e=>Array.from(e.addedNodes).some(e=>e instanceof HTMLElement&&e.id===this.anchorId))&&this.updateAnchor()}),this.#e.observe(this.getRootNode(),{childList:!0,subtree:!0})}disconnectedCallback(){super.disconnectedCallback(),this.#e.disconnect()}};r.t([t.T],y.prototype,`kind`,void 0),r.t([t.T],y.prototype,`offset`,void 0),r.t([t.T],y.prototype,`anchorBlocksPopover`,void 0),r.t([t.T],y.prototype,`anchorEl`,void 0),r.t([t.T],y.prototype,`anchorId`,void 0),r.t([t.T],y.prototype,`requestedOpenState`,void 0),r.t([t.E],y.prototype,`open`,null);var re=t.o(`rich-text-editor-popover`,y,ne,[o.t],{}),ie=65535,ae=2**16;function oe(e,t){return e+t*ae}function b(e){return e&ie}function se(e){return(e-(e&ie))/ae}var ce=1,le=2,ue=4,de=8,fe=class{constructor(e,t,n){this.pos=e,this.delInfo=t,this.recover=n}get deleted(){return(this.delInfo&de)>0}get deletedBefore(){return(this.delInfo&(ce|ue))>0}get deletedAfter(){return(this.delInfo&(le|ue))>0}get deletedAcross(){return(this.delInfo&ue)>0}},pe=class e{constructor(t,n=!1){if(this.ranges=t,this.inverted=n,!t.length&&e.empty)return e.empty}recover(e){let t=0,n=b(e);if(!this.inverted)for(let e=0;e<n;e++)t+=this.ranges[e*3+2]-this.ranges[e*3+1];return this.ranges[n*3]+t+se(e)}mapResult(e,t=1){return this._map(e,t,!1)}map(e,t=1){return this._map(e,t,!0)}_map(e,t,n){let r=0,i=this.inverted?2:1,a=this.inverted?1:2;for(let o=0;o<this.ranges.length;o+=3){let s=this.ranges[o]-(this.inverted?r:0);if(s>e)break;let c=this.ranges[o+i],l=this.ranges[o+a],u=s+c;if(e<=u){let i=c?e==s?-1:e==u?1:t:t,a=s+r+(i<0?0:l);if(n)return a;let d=e==(t<0?s:u)?null:oe(o/3,e-s),f=e==s?le:e==u?ce:ue;return(t<0?e!=s:e!=u)&&(f|=de),new fe(a,f,d)}r+=l-c}return n?e+r:new fe(e+r,0,null)}touches(e,t){let n=0,r=b(t),i=this.inverted?2:1,a=this.inverted?1:2;for(let t=0;t<this.ranges.length;t+=3){let o=this.ranges[t]-(this.inverted?n:0);if(o>e)break;let s=this.ranges[t+i];if(e<=o+s&&t==r*3)return!0;n+=this.ranges[t+a]-s}return!1}forEach(e){let t=this.inverted?2:1,n=this.inverted?1:2;for(let r=0,i=0;r<this.ranges.length;r+=3){let a=this.ranges[r],o=a-(this.inverted?i:0),s=a+(this.inverted?0:i),c=this.ranges[r+t],l=this.ranges[r+n];e(o,o+c,s,s+l),i+=l-c}}invert(){return new e(this.ranges,!this.inverted)}toString(){return(this.inverted?`-`:``)+JSON.stringify(this.ranges)}static offset(t){return t==0?e.empty:new e(t<0?[0,-t,0]:[0,0,t])}};pe.empty=new pe([]);var me=class e{constructor(e,t,n=0,r=e?e.length:0){this.mirror=t,this.from=n,this.to=r,this._maps=e||[],this.ownData=!(e||t)}get maps(){return this._maps}slice(t=0,n=this.maps.length){return new e(this._maps,this.mirror,t,n)}appendMap(e,t){this.ownData||=(this._maps=this._maps.slice(),this.mirror=this.mirror&&this.mirror.slice(),!0),this.to=this._maps.push(e),t!=null&&this.setMirror(this._maps.length-1,t)}appendMapping(e){for(let t=0,n=this._maps.length;t<e._maps.length;t++){let r=e.getMirror(t);this.appendMap(e._maps[t],r!=null&&r<t?n+r:void 0)}}getMirror(e){if(this.mirror){for(let t=0;t<this.mirror.length;t++)if(this.mirror[t]==e)return this.mirror[t+(t%2?-1:1)]}}setMirror(e,t){this.mirror||=[],this.mirror.push(e,t)}appendMappingInverted(e){for(let t=e.maps.length-1,n=this._maps.length+e._maps.length;t>=0;t--){let r=e.getMirror(t);this.appendMap(e._maps[t].invert(),r!=null&&r>t?n-r-1:void 0)}}invert(){let t=new e;return t.appendMappingInverted(this),t}map(e,t=1){if(this.mirror)return this._map(e,t,!0);for(let n=this.from;n<this.to;n++)e=this._maps[n].map(e,t);return e}mapResult(e,t=1){return this._map(e,t,!1)}_map(e,t,n){let r=0;for(let n=this.from;n<this.to;n++){let i=this._maps[n].mapResult(e,t);if(i.recover!=null){let t=this.getMirror(n);if(t!=null&&t>n&&t<this.to){n=t,e=this._maps[t].recover(i.recover);continue}}r|=i.delInfo,e=i.pos}return n?e:new fe(e,r,null)}},he=Object.create(null),x=class{getMap(){return pe.empty}merge(e){return null}static fromJSON(e,t){if(!t||!t.stepType)throw RangeError(`Invalid input for Step.fromJSON`);let n=he[t.stepType];if(!n)throw RangeError(`No step type ${t.stepType} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in he)throw RangeError(`Duplicate use of step JSON ID `+e);return he[e]=t,t.prototype.jsonID=e,t}},S=class e{constructor(e,t){this.doc=e,this.failed=t}static ok(t){return new e(t,null)}static fail(t){return new e(null,t)}static fromReplace(t,n,r,i){try{return e.ok(t.replace(n,r,i))}catch(t){if(t instanceof m.g)return e.fail(t.message);throw t}}};function C(e,t,n){let r=[];for(let i=0;i<e.childCount;i++){let a=e.child(i);a.content.size&&(a=a.copy(C(a.content,t,a))),a.isInline&&(a=t(a,n,i)),r.push(a)}return m.d.fromArray(r)}var ge=class e extends x{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=e.resolve(this.from),r=n.node(n.sharedDepth(this.to)),i=new m.v(C(t.content,(e,t)=>!e.isAtom||!t.type.allowsMarkType(this.mark.type)?e:e.mark(this.mark.addToSet(e.marks)),r),t.openStart,t.openEnd);return S.fromReplace(e,this.from,this.to,i)}invert(){return new w(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`addMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for AddMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};x.jsonID(`addMark`,ge);var w=class e extends x{constructor(e,t,n){super(),this.from=e,this.to=t,this.mark=n}apply(e){let t=e.slice(this.from,this.to),n=new m.v(C(t.content,e=>e.mark(this.mark.removeFromSet(e.marks)),e),t.openStart,t.openEnd);return S.fromReplace(e,this.from,this.to,n)}invert(){return new ge(this.from,this.to,this.mark)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new e(n.pos,r.pos,this.mark)}merge(t){return t instanceof e&&t.mark.eq(this.mark)&&this.from<=t.to&&this.to>=t.from?new e(Math.min(this.from,t.from),Math.max(this.to,t.to),this.mark):null}toJSON(){return{stepType:`removeMark`,mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for RemoveMarkStep.fromJSON`);return new e(n.from,n.to,t.markFromJSON(n.mark))}};x.jsonID(`removeMark`,w);var _e=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.addToSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(n),0,t.isLeaf?0:1))}invert(t){let n=t.nodeAt(this.pos);if(n){let t=this.mark.addToSet(n.marks);if(t.length==n.marks.length){for(let r=0;r<n.marks.length;r++)if(!n.marks[r].isInSet(t))return new e(this.pos,n.marks[r]);return new e(this.pos,this.mark)}}return new ve(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`addNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for AddNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};x.jsonID(`addNodeMark`,_e);var ve=class e extends x{constructor(e,t){super(),this.pos=e,this.mark=t}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at mark step's position`);let n=t.type.create(t.attrs,null,this.mark.removeFromSet(t.marks));return S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(n),0,t.isLeaf?0:1))}invert(e){let t=e.nodeAt(this.pos);return!t||!this.mark.isInSet(t.marks)?this:new _e(this.pos,this.mark)}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.mark)}toJSON(){return{stepType:`removeNodeMark`,pos:this.pos,mark:this.mark.toJSON()}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for RemoveNodeMarkStep.fromJSON`);return new e(n.pos,t.markFromJSON(n.mark))}};x.jsonID(`removeNodeMark`,ve);var T=class e extends x{constructor(e,t,n,r=!1){super(),this.from=e,this.to=t,this.slice=n,this.structure=r}apply(e){return this.structure&&ye(e,this.from,this.to)?S.fail(`Structure replace would overwrite content`):S.fromReplace(e,this.from,this.to,this.slice)}getMap(){return new pe([this.from,this.to-this.from,this.slice.size])}invert(t){return new e(this.from,this.from+this.slice.size,t.slice(this.from,this.to))}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1);return n.deletedAcross&&r.deletedAcross?null:new e(n.pos,Math.max(n.pos,r.pos),this.slice,this.structure)}merge(t){if(!(t instanceof e)||t.structure||this.structure)return null;if(this.from+this.slice.size==t.from&&!this.slice.openEnd&&!t.slice.openStart){let n=this.slice.size+t.slice.size==0?m.v.empty:new m.v(this.slice.content.append(t.slice.content),this.slice.openStart,t.slice.openEnd);return new e(this.from,this.to+(t.to-t.from),n,this.structure)}else if(t.to==this.from&&!this.slice.openStart&&!t.slice.openEnd){let n=this.slice.size+t.slice.size==0?m.v.empty:new m.v(t.slice.content.append(this.slice.content),t.slice.openStart,this.slice.openEnd);return new e(t.from,this.to,n,this.structure)}else return null}toJSON(){let e={stepType:`replace`,from:this.from,to:this.to};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`)throw RangeError(`Invalid input for ReplaceStep.fromJSON`);return new e(n.from,n.to,m.v.fromJSON(t,n.slice),!!n.structure)}};x.jsonID(`replace`,T);var E=class e extends x{constructor(e,t,n,r,i,a,o=!1){super(),this.from=e,this.to=t,this.gapFrom=n,this.gapTo=r,this.slice=i,this.insert=a,this.structure=o}apply(e){if(this.structure&&(ye(e,this.from,this.gapFrom)||ye(e,this.gapTo,this.to)))return S.fail(`Structure gap-replace would overwrite content`);let t=e.slice(this.gapFrom,this.gapTo);if(t.openStart||t.openEnd)return S.fail(`Gap is not a flat range`);let n=this.slice.insertAt(this.insert,t.content);return n?S.fromReplace(e,this.from,this.to,n):S.fail(`Content does not fit in gap`)}getMap(){return new pe([this.from,this.gapFrom-this.from,this.insert,this.gapTo,this.to-this.gapTo,this.slice.size-this.insert])}invert(t){let n=this.gapTo-this.gapFrom;return new e(this.from,this.from+this.slice.size+n,this.from+this.insert,this.from+this.insert+n,t.slice(this.from,this.to).removeBetween(this.gapFrom-this.from,this.gapTo-this.from),this.gapFrom-this.from,this.structure)}map(t){let n=t.mapResult(this.from,1),r=t.mapResult(this.to,-1),i=this.from==this.gapFrom?n.pos:t.map(this.gapFrom,-1),a=this.to==this.gapTo?r.pos:t.map(this.gapTo,1);return n.deletedAcross&&r.deletedAcross||i<n.pos||a>r.pos?null:new e(n.pos,r.pos,i,a,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:`replaceAround`,from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(t,n){if(typeof n.from!=`number`||typeof n.to!=`number`||typeof n.gapFrom!=`number`||typeof n.gapTo!=`number`||typeof n.insert!=`number`)throw RangeError(`Invalid input for ReplaceAroundStep.fromJSON`);return new e(n.from,n.to,n.gapFrom,n.gapTo,m.v.fromJSON(t,n.slice),n.insert,!!n.structure)}};x.jsonID(`replaceAround`,E);function ye(e,t,n){let r=e.resolve(t),i=n-t,a=r.depth;for(;i>0&&a>0&&r.indexAfter(a)==r.node(a).childCount;)a--,i--;if(i>0){let e=r.node(a).maybeChild(r.indexAfter(a));for(;i>0;){if(!e||e.isLeaf)return!0;e=e.firstChild,i--}}return!1}function be(e,t,n,r){let i=[],a=[],o,s;e.doc.nodesBetween(t,n,(e,c,l)=>{if(!e.isInline)return;let u=e.marks;if(!r.isInSet(u)&&l.type.allowsMarkType(r.type)){let l=Math.max(c,t),d=Math.min(c+e.nodeSize,n),f=r.addToSet(u);for(let e=0;e<u.length;e++)u[e].isInSet(f)||(o&&o.to==l&&o.mark.eq(u[e])?o.to=d:i.push(o=new w(l,d,u[e])));s&&s.to==l?s.to=d:a.push(s=new ge(l,d,r))}}),i.forEach(t=>e.step(t)),a.forEach(t=>e.step(t))}function xe(e,t,n,r){let i=[],a=0;e.doc.nodesBetween(t,n,(e,o)=>{if(!e.isInline)return;a++;let s=null;if(r instanceof m.p){let t=e.marks,n;for(;n=r.isInSet(t);)(s||=[]).push(n),t=n.removeFromSet(t)}else r?r.isInSet(e.marks)&&(s=[r]):s=e.marks;if(s&&s.length){let r=Math.min(o+e.nodeSize,n);for(let e=0;e<s.length;e++){let n=s[e],c;for(let e=0;e<i.length;e++){let t=i[e];t.step==a-1&&n.eq(i[e].style)&&(c=t)}c?(c.to=r,c.step=a):i.push({style:n,from:Math.max(o,t),to:r,step:a})}}}),i.forEach(t=>e.step(new w(t.from,t.to,t.style)))}function Se(e,t,n,r=n.contentMatch,i=!0){let a=e.doc.nodeAt(t),o=[],s=t+1;for(let t=0;t<a.childCount;t++){let c=a.child(t),l=s+c.nodeSize,u=r.matchType(c.type);if(!u)o.push(new T(s,l,m.v.empty));else{r=u;for(let t=0;t<c.marks.length;t++)n.allowsMarkType(c.marks[t].type)||e.step(new w(s,l,c.marks[t]));if(i&&c.isText&&n.whitespace!=`pre`){let e,t=/\r?\n|\r/g,r;for(;e=t.exec(c.text);)r||=new m.v(m.d.from(n.schema.text(` `,n.allowedMarks(c.marks))),0,0),o.push(new T(s+e.index,s+e.index+e[0].length,r))}}s=l}if(!r.validEnd){let t=r.fillBefore(m.d.empty,!0);e.replace(s,s,new m.v(t,0,0))}for(let t=o.length-1;t>=0;t--)e.step(o[t])}function Ce(e,t,n){return(t==0||e.canReplace(t,e.childCount))&&(n==e.childCount||e.canReplace(0,n))}function we(e){let t=e.parent.content.cutByIndex(e.startIndex,e.endIndex);for(let n=e.depth,r=0,i=0;;--n){let a=e.$from.node(n),o=e.$from.index(n)+r,s=e.$to.indexAfter(n)-i;if(n<e.depth&&a.canReplace(o,s,t))return n;if(n==0||a.type.spec.isolating||!Ce(a,o,s))break;o&&(r=1),s<a.childCount&&(i=1)}return null}function Te(e,t,n){let{$from:r,$to:i,depth:a}=t,o=r.before(a+1),s=i.after(a+1),c=o,l=s,u=m.d.empty,d=0;for(let e=a,t=!1;e>n;e--)t||r.index(e)>0?(t=!0,u=m.d.from(r.node(e).copy(u)),d++):c--;let f=m.d.empty,p=0;for(let e=a,t=!1;e>n;e--)t||i.after(e+1)<i.end(e)?(t=!0,f=m.d.from(i.node(e).copy(f)),p++):l++;e.step(new E(c,l,o,s,new m.v(u.append(f),d,p),u.size-d,!0))}function Ee(e,t,n){let r=m.d.empty;for(let e=n.length-1;e>=0;e--){if(r.size){let t=n[e].type.contentMatch.matchFragment(r);if(!t||!t.validEnd)throw RangeError(`Wrapper type given to Transform.wrap does not form valid content of its parent wrapper`)}r=m.d.from(n[e].type.create(n[e].attrs,r))}let i=t.start,a=t.end;e.step(new E(i,a,i,a,new m.v(r,0,0),n.length,!0))}function De(e,t,n,r,i){if(!r.isTextblock)throw RangeError(`Type given to setBlockType should be a textblock`);let a=e.steps.length;e.doc.nodesBetween(t,n,(t,n)=>{let o=typeof i==`function`?i(t):i;if(t.isTextblock&&!t.hasMarkup(r,o)&&Ae(e.doc,e.mapping.slice(a).map(n),r)){let i=null;if(r.schema.linebreakReplacement){let e=r.whitespace==`pre`,t=!!r.contentMatch.matchType(r.schema.linebreakReplacement);e&&!t?i=!1:!e&&t&&(i=!0)}i===!1&&ke(e,t,n,a),Se(e,e.mapping.slice(a).map(n,1),r,void 0,i===null);let s=e.mapping.slice(a),c=s.map(n,1),l=s.map(n+t.nodeSize,1);return e.step(new E(c,l,c+1,l-1,new m.v(m.d.from(r.create(o,null,t.marks)),0,0),1,!0)),i===!0&&Oe(e,t,n,a),!1}})}function Oe(e,t,n,r){t.forEach((i,a)=>{if(i.isText){let o,s=/\r?\n|\r/g;for(;o=s.exec(i.text);){let i=e.mapping.slice(r).map(n+1+a+o.index);e.replaceWith(i,i+1,t.type.schema.linebreakReplacement.create())}}})}function ke(e,t,n,r){t.forEach((i,a)=>{if(i.type==i.type.schema.linebreakReplacement){let i=e.mapping.slice(r).map(n+1+a);e.replaceWith(i,i+1,t.type.schema.text(`
25
+ `))}})}function Ae(e,t,n){let r=e.resolve(t),i=r.index();return r.parent.canReplaceWith(i,i+1,n)}function je(e,t,n,r,i){let a=e.doc.nodeAt(t);if(!a)throw RangeError(`No node at given position`);n||=a.type;let o=n.create(r,null,i||a.marks);if(a.isLeaf)return e.replaceWith(t,t+a.nodeSize,o);if(!n.validContent(a.content))throw RangeError(`Invalid content for node type `+n.name);e.step(new E(t,t+a.nodeSize,t+1,t+a.nodeSize-1,new m.v(m.d.from(o),0,0),1,!0))}function Me(e,t,n=1,r){let i=e.resolve(t),a=i.depth-n,o=r&&r[r.length-1]||i.parent;if(a<0||i.parent.type.spec.isolating||!i.parent.canReplace(i.index(),i.parent.childCount)||!o.type.validContent(i.parent.content.cutByIndex(i.index(),i.parent.childCount)))return!1;for(let e=i.depth-1,t=n-2;e>a;e--,t--){let n=i.node(e),a=i.index(e);if(n.type.spec.isolating)return!1;let o=n.content.cutByIndex(a,n.childCount),s=r&&r[t+1];s&&(o=o.replaceChild(0,s.type.create(s.attrs)));let c=r&&r[t]||n;if(!n.canReplace(a+1,n.childCount)||!c.type.validContent(o))return!1}let s=i.indexAfter(a),c=r&&r[0];return i.node(a).canReplaceWith(s,s,c?c.type:i.node(a+1).type)}function Ne(e,t,n=1,r){let i=e.doc.resolve(t),a=m.d.empty,o=m.d.empty;for(let e=i.depth,t=i.depth-n,s=n-1;e>t;e--,s--){a=m.d.from(i.node(e).copy(a));let t=r&&r[s];o=m.d.from(t?t.type.create(t.attrs,o):i.node(e).copy(o))}e.step(new T(t,t,new m.v(a.append(o),n,n),!0))}function Pe(e,t){let n=e.resolve(t),r=n.index();return Ie(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function Fe(e,t){t.content.size||e.type.compatibleContent(t.type);let n=e.contentMatchAt(e.childCount),{linebreakReplacement:r}=e.type.schema;for(let i=0;i<t.childCount;i++){let a=t.child(i),o=a.type==r?e.type.schema.nodes.text:a.type;if(n=n.matchType(o),!n||!e.type.allowsMarks(a.marks))return!1}return n.validEnd}function Ie(e,t){return!!(e&&t&&!e.isLeaf&&Fe(e,t))}function Le(e,t,n){let r=null,{linebreakReplacement:i}=e.doc.type.schema,a=e.doc.resolve(t-n),o=a.node().type;if(i&&o.inlineContent){let e=o.whitespace==`pre`,t=!!o.contentMatch.matchType(i);e&&!t?r=!1:!e&&t&&(r=!0)}let s=e.steps.length;if(r===!1){let r=e.doc.resolve(t+n);ke(e,r.node(),r.before(),s)}o.inlineContent&&Se(e,t+n-1,o,a.node().contentMatchAt(a.index()),r==null);let c=e.mapping.slice(s),l=c.map(t-n);if(e.step(new T(l,c.map(t+n,-1),m.v.empty,!0)),r===!0){let t=e.doc.resolve(l);Oe(e,t.node(),t.before(),e.steps.length)}return e}function Re(e,t,n){let r=e.resolve(t);if(r.parent.canReplaceWith(r.index(),r.index(),n))return t;if(r.parentOffset==0)for(let e=r.depth-1;e>=0;e--){let t=r.index(e);if(r.node(e).canReplaceWith(t,t,n))return r.before(e+1);if(t>0)return null}if(r.parentOffset==r.parent.content.size)for(let e=r.depth-1;e>=0;e--){let t=r.indexAfter(e);if(r.node(e).canReplaceWith(t,t,n))return r.after(e+1);if(t<r.node(e).childCount)return null}return null}function ze(e,t,n){let r=e.resolve(t);if(!n.content.size)return t;let i=n.content;for(let e=0;e<n.openStart;e++)i=i.firstChild.content;for(let e=1;e<=(n.openStart==0&&n.size?2:1);e++)for(let t=r.depth;t>=0;t--){let n=t==r.depth?0:r.pos<=(r.start(t+1)+r.end(t+1))/2?-1:1,a=r.index(t)+(n>0?1:0),o=r.node(t),s=!1;if(e==1)s=o.canReplace(a,a,i);else{let e=o.contentMatchAt(a).findWrapping(i.firstChild.type);s=e&&o.canReplaceWith(a,a,e[0])}if(s)return n==0?r.pos:n<0?r.before(t+1):r.after(t+1)}return null}function Be(e,t,n=t,r=m.v.empty){if(t==n&&!r.size)return null;let i=e.resolve(t),a=e.resolve(n);return Ve(i,a,r)?new T(t,n,r):new He(i,a,r).fit()}function Ve(e,t,n){return!n.openStart&&!n.openEnd&&e.start()==t.start()&&e.parent.canReplace(e.index(),t.index(),n.content)}var He=class{constructor(e,t,n){this.$from=e,this.$to=t,this.unplaced=n,this.frontier=[],this.placed=m.d.empty;for(let t=0;t<=e.depth;t++){let n=e.node(t);this.frontier.push({type:n.type,match:n.contentMatchAt(e.indexAfter(t))})}for(let t=e.depth;t>0;t--)this.placed=m.d.from(e.node(t).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let e=this.findFittable();e?this.placeNodes(e):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),t=this.placed.size-this.depth-this.$from.depth,n=this.$from,r=this.close(e<0?this.$to:n.doc.resolve(e));if(!r)return null;let i=this.placed,a=n.depth,o=r.depth;for(;a&&o&&i.childCount==1;)i=i.firstChild.content,a--,o--;let s=new m.v(i,a,o);return e>-1?new E(n.pos,e,this.$to.pos,this.$to.end(),s,t):s.size||n.pos!=this.$to.pos?new T(n.pos,r.pos,s):null}findFittable(){let e=this.unplaced.openStart;for(let t=this.unplaced.content,n=0,r=this.unplaced.openEnd;n<e;n++){let i=t.firstChild;if(t.childCount>1&&(r=0),i.type.spec.isolating&&r<=n){e=n;break}t=i.content}for(let t=1;t<=2;t++)for(let n=t==1?e:this.unplaced.openStart;n>=0;n--){let e,r=null;n?(r=We(this.unplaced.content,n-1).firstChild,e=r.content):e=this.unplaced.content;let i=e.firstChild;for(let e=this.depth;e>=0;e--){let{type:a,match:o}=this.frontier[e],s,c=null;if(t==1&&(i?o.matchType(i.type)||(c=o.fillBefore(m.d.from(i),!1)):r&&a.compatibleContent(r.type)))return{sliceDepth:n,frontierDepth:e,parent:r,inject:c};if(t==2&&i&&(s=o.findWrapping(i.type)))return{sliceDepth:n,frontierDepth:e,parent:r,wrap:s};if(r&&o.matchType(r.type))break}}}openMore(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=We(e,t);return!r.childCount||r.firstChild.isLeaf?!1:(this.unplaced=new m.v(e,t+1,Math.max(n,r.size+t>=e.size-n?t+1:0)),!0)}dropNode(){let{content:e,openStart:t,openEnd:n}=this.unplaced,r=We(e,t);if(r.childCount<=1&&t>0){let i=e.size-t<=t+r.size;this.unplaced=new m.v(D(e,t-1,1),t-1,i?t-1:n)}else this.unplaced=new m.v(D(e,t,1),t,n)}placeNodes({sliceDepth:e,frontierDepth:t,parent:n,inject:r,wrap:i}){for(;this.depth>t;)this.closeFrontierNode();if(i)for(let e=0;e<i.length;e++)this.openFrontierNode(i[e]);let a=this.unplaced,o=n?n.content:a.content,s=a.openStart-e,c=0,l=[],{match:u,type:d}=this.frontier[t];if(r){for(let e=0;e<r.childCount;e++)l.push(r.child(e));u=u.matchFragment(r)}let f=o.size+e-(a.content.size-a.openEnd);for(;c<o.childCount;){let e=o.child(c),t=u.matchType(e.type);if(!t)break;c++,(c>1||s==0||e.content.size)&&(u=t,l.push(Ge(e.mark(d.allowedMarks(e.marks)),c==1?s:0,c==o.childCount?f:-1)))}let p=c==o.childCount;p||(f=-1),this.placed=Ue(this.placed,t,m.d.from(l)),this.frontier[t].match=u,p&&f<0&&n&&n.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let e=0,t=o;e<f;e++){let e=t.lastChild;this.frontier.push({type:e.type,match:e.contentMatchAt(e.childCount)}),t=e.content}this.unplaced=p?e==0?m.v.empty:new m.v(D(a.content,e-1,1),e-1,f<0?a.openEnd:e-1):new m.v(D(a.content,e,c),a.openStart,a.openEnd)}mustMoveInline(){if(!this.$to.parent.isTextblock)return-1;let e=this.frontier[this.depth],t;if(!e.type.isTextblock||!Ke(this.$to,this.$to.depth,e.type,e.match,!1)||this.$to.depth==this.depth&&(t=this.findCloseLevel(this.$to))&&t.depth==this.depth)return-1;let{depth:n}=this.$to,r=this.$to.after(n);for(;n>1&&r==this.$to.end(--n);)++r;return r}findCloseLevel(e){scan:for(let t=Math.min(this.depth,e.depth);t>=0;t--){let{match:n,type:r}=this.frontier[t],i=t<e.depth&&e.end(t+1)==e.pos+(e.depth-(t+1)),a=Ke(e,t,r,n,i);if(a){for(let n=t-1;n>=0;n--){let{match:t,type:r}=this.frontier[n],i=Ke(e,n,r,t,!0);if(!i||i.childCount)continue scan}return{depth:t,fit:a,move:i?e.doc.resolve(e.after(t+1)):e}}}}close(e){let t=this.findCloseLevel(e);if(!t)return null;for(;this.depth>t.depth;)this.closeFrontierNode();t.fit.childCount&&(this.placed=Ue(this.placed,t.depth,t.fit)),e=t.move;for(let n=t.depth+1;n<=e.depth;n++){let t=e.node(n),r=t.type.contentMatch.fillBefore(t.content,!0,e.index(n));this.openFrontierNode(t.type,t.attrs,r)}return e}openFrontierNode(e,t=null,n){let r=this.frontier[this.depth];r.match=r.match.matchType(e),this.placed=Ue(this.placed,this.depth,m.d.from(e.create(t,n))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let e=this.frontier.pop().match.fillBefore(m.d.empty,!0);e.childCount&&(this.placed=Ue(this.placed,this.frontier.length,e))}};function D(e,t,n){return t==0?e.cutByIndex(n,e.childCount):e.replaceChild(0,e.firstChild.copy(D(e.firstChild.content,t-1,n)))}function Ue(e,t,n){return t==0?e.append(n):e.replaceChild(e.childCount-1,e.lastChild.copy(Ue(e.lastChild.content,t-1,n)))}function We(e,t){for(let n=0;n<t;n++)e=e.firstChild.content;return e}function Ge(e,t,n){if(t<=0)return e;let r=e.content;return t>1&&(r=r.replaceChild(0,Ge(r.firstChild,t-1,r.childCount==1?n-1:0))),t>0&&(r=e.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(e.type.contentMatch.matchFragment(r).fillBefore(m.d.empty,!0)))),e.copy(r)}function Ke(e,t,n,r,i){let a=e.node(t),o=i?e.indexAfter(t):e.index(t);if(o==a.childCount&&!n.compatibleContent(a.type))return null;let s=r.fillBefore(a.content,!0,o);return s&&!qe(n,a.content,o)?s:null}function qe(e,t,n){for(let r=n;r<t.childCount;r++)if(!e.allowsMarks(t.child(r).marks))return!0;return!1}function Je(e){return e.spec.defining||e.spec.definingForContent}function Ye(e,t,n,r){if(!r.size)return e.deleteRange(t,n);let i=e.doc.resolve(t),a=e.doc.resolve(n);if(Ve(i,a,r))return e.step(new T(t,n,r));let o=Qe(i,a);o[o.length-1]==0&&o.pop();let s=-(i.depth+1);o.unshift(s);for(let e=i.depth,t=i.pos-1;e>0;e--,t--){let n=i.node(e).type.spec;if(n.defining||n.definingAsContext||n.isolating)break;o.indexOf(e)>-1?s=e:i.before(e)==t&&o.splice(1,0,-e)}let c=o.indexOf(s),l=[],u=r.openStart;for(let e=r.content,t=0;;t++){let n=e.firstChild;if(l.push(n),t==r.openStart)break;e=n.content}for(let e=u-1;e>=0;e--){let t=l[e],n=Je(t.type);if(n&&!t.sameMarkup(i.node(Math.abs(s)-1)))u=e;else if(n||!t.type.isTextblock)break}for(let t=r.openStart;t>=0;t--){let s=(t+u+1)%(r.openStart+1),d=l[s];if(d)for(let t=0;t<o.length;t++){let l=o[(t+c)%o.length],u=!0;l<0&&(u=!1,l=-l);let f=i.node(l-1),p=i.index(l-1);if(f.canReplaceWith(p,p,d.type,d.marks))return e.replace(i.before(l),u?a.after(l):n,new m.v(Xe(r.content,0,r.openStart,s),s,r.openEnd))}}let d=e.steps.length;for(let s=o.length-1;s>=0&&(e.replace(t,n,r),!(e.steps.length>d));s--){let e=o[s];e<0||(t=i.before(e),n=a.after(e))}}function Xe(e,t,n,r,i){if(t<n){let i=e.firstChild;e=e.replaceChild(0,i.copy(Xe(i.content,t+1,n,r,i)))}if(t>r){let t=i.contentMatchAt(0),n=t.fillBefore(e).append(e);e=n.append(t.matchFragment(n).fillBefore(m.d.empty,!0))}return e}function Ze(e,t,n,r){if(!r.isInline&&t==n&&e.doc.resolve(t).parent.content.size){let i=Re(e.doc,t,r.type);i!=null&&(t=n=i)}e.replaceRange(t,n,new m.v(m.d.from(r),0,0))}function O(e,t,n){let r=e.doc.resolve(t),i=e.doc.resolve(n),a=Qe(r,i);for(let t=0;t<a.length;t++){let n=a[t],o=t==a.length-1;if(o&&n==0||r.node(n).type.contentMatch.validEnd)return e.delete(r.start(n),i.end(n));if(n>0&&(o||r.node(n-1).canReplace(r.index(n-1),i.indexAfter(n-1))))return e.delete(r.before(n),i.after(n))}for(let a=1;a<=r.depth&&a<=i.depth;a++)if(t-r.start(a)==r.depth-a&&n>r.end(a)&&i.end(a)-n!=i.depth-a&&r.start(a-1)==i.start(a-1)&&r.node(a-1).canReplace(r.index(a-1),i.index(a-1)))return e.delete(r.before(a),n);e.delete(t,n)}function Qe(e,t){let n=[],r=Math.min(e.depth,t.depth);for(let i=r;i>=0;i--){let r=e.start(i);if(r<e.pos-(e.depth-i)||t.end(i)>t.pos+(t.depth-i)||e.node(i).type.spec.isolating||t.node(i).type.spec.isolating)break;(r==t.start(i)||i==e.depth&&i==t.depth&&e.parent.inlineContent&&t.parent.inlineContent&&i&&t.start(i-1)==r-1)&&n.push(i)}return n}var $e=class e extends x{constructor(e,t,n){super(),this.pos=e,this.attr=t,this.value=n}apply(e){let t=e.nodeAt(this.pos);if(!t)return S.fail(`No node at attribute step's position`);let n=Object.create(null);for(let e in t.attrs)n[e]=t.attrs[e];n[this.attr]=this.value;let r=t.type.create(n,null,t.marks);return S.fromReplace(e,this.pos,this.pos+1,new m.v(m.d.from(r),0,t.isLeaf?0:1))}getMap(){return pe.empty}invert(t){return new e(this.pos,this.attr,t.nodeAt(this.pos).attrs[this.attr])}map(t){let n=t.mapResult(this.pos,1);return n.deletedAfter?null:new e(n.pos,this.attr,this.value)}toJSON(){return{stepType:`attr`,pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.pos!=`number`||typeof n.attr!=`string`)throw RangeError(`Invalid input for AttrStep.fromJSON`);return new e(n.pos,n.attr,n.value)}};x.jsonID(`attr`,$e);var et=class e extends x{constructor(e,t){super(),this.attr=e,this.value=t}apply(e){let t=Object.create(null);for(let n in e.attrs)t[n]=e.attrs[n];t[this.attr]=this.value;let n=e.type.create(t,e.content,e.marks);return S.ok(n)}getMap(){return pe.empty}invert(t){return new e(this.attr,t.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:`docAttr`,attr:this.attr,value:this.value}}static fromJSON(t,n){if(typeof n.attr!=`string`)throw RangeError(`Invalid input for DocAttrStep.fromJSON`);return new e(n.attr,n.value)}};x.jsonID(`docAttr`,et);var tt=class extends Error{};tt=function e(t){let n=Error.call(this,t);return n.__proto__=e.prototype,n},tt.prototype=Object.create(Error.prototype),tt.prototype.constructor=tt,tt.prototype.name=`TransformError`;var nt=class{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new me}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let t=this.maybeStep(e);if(t.failed)throw new tt(t.failed);return this}maybeStep(e){let t=e.apply(this.doc);return t.failed||this.addStep(e,t.doc),t}get docChanged(){return this.steps.length>0}changedRange(){let e=1e9,t=-1e9;for(let n=0;n<this.mapping.maps.length;n++){let r=this.mapping.maps[n];n&&(e=r.map(e,1),t=r.map(t,-1)),r.forEach((n,r,i,a)=>{e=Math.min(e,i),t=Math.max(t,a)})}return e==1e9?null:{from:e,to:t}}addStep(e,t){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=t}replace(e,t=e,n=m.v.empty){let r=Be(this.doc,e,t,n);return r&&this.step(r),this}replaceWith(e,t,n){return this.replace(e,t,new m.v(m.d.from(n),0,0))}delete(e,t){return this.replace(e,t,m.v.empty)}insert(e,t){return this.replaceWith(e,e,t)}replaceRange(e,t,n){return Ye(this,e,t,n),this}replaceRangeWith(e,t,n){return Ze(this,e,t,n),this}deleteRange(e,t){return O(this,e,t),this}lift(e,t){return Te(this,e,t),this}join(e,t=1){return Le(this,e,t),this}wrap(e,t){return Ee(this,e,t),this}setBlockType(e,t=e,n,r=null){return De(this,e,t,n,r),this}setNodeMarkup(e,t,n=null,r){return je(this,e,t,n,r),this}setNodeAttribute(e,t,n){return this.step(new $e(e,t,n)),this}setDocAttribute(e,t){return this.step(new et(e,t)),this}addNodeMark(e,t){return this.step(new _e(e,t)),this}removeNodeMark(e,t){let n=this.doc.nodeAt(e);if(!n)throw RangeError(`No node at position `+e);if(t instanceof m.f)t.isInSet(n.marks)&&this.step(new ve(e,t));else{let r=n.marks,i,a=[];for(;i=t.isInSet(r);)a.push(new ve(e,i)),r=i.removeFromSet(r);for(let e=a.length-1;e>=0;e--)this.step(a[e])}return this}split(e,t=1,n){return Ne(this,e,t,n),this}addMark(e,t,n){return be(this,e,t,n),this}removeMark(e,t,n){return xe(this,e,t,n),this}clearIncompatible(e,t,n){return Se(this,e,t,n),this}},rt=Object.create(null),k=class{constructor(e,t,n){this.$anchor=e,this.$head=t,this.ranges=n||[new it(e.min(t),e.max(t))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let t=0;t<e.length;t++)if(e[t].$from.pos!=e[t].$to.pos)return!1;return!0}content(){return this.$from.doc.slice(this.from,this.to,!0)}replace(e,t=m.v.empty){let n=t.content.lastChild,r=null;for(let e=0;e<t.openEnd;e++)r=n,n=n.lastChild;let i=e.steps.length,a=this.ranges;for(let o=0;o<a.length;o++){let{$from:s,$to:c}=a[o],l=e.mapping.slice(i);e.replaceRange(l.map(s.pos),l.map(c.pos),o?m.v.empty:t),o==0&&dt(e,i,(n?n.isInline:r&&r.isTextblock)?-1:1)}}replaceWith(e,t){let n=e.steps.length,r=this.ranges;for(let i=0;i<r.length;i++){let{$from:a,$to:o}=r[i],s=e.mapping.slice(n),c=s.map(a.pos),l=s.map(o.pos);i?e.deleteRange(c,l):(e.replaceRangeWith(c,l,t),dt(e,n,t.isInline?-1:1))}}static findFrom(e,t,n=!1){let r=e.parent.inlineContent?new A(e):ut(e.node(0),e.parent,e.pos,e.index(),t,n);if(r)return r;for(let r=e.depth-1;r>=0;r--){let i=t<0?ut(e.node(0),e.node(r),e.before(r+1),e.index(r),t,n):ut(e.node(0),e.node(r),e.after(r+1),e.index(r)+1,t,n);if(i)return i}return null}static near(e,t=1){return this.findFrom(e,t)||this.findFrom(e,-t)||new M(e.node(0))}static atStart(e){return ut(e,e,0,0,1)||new M(e)}static atEnd(e){return ut(e,e,e.content.size,e.childCount,-1)||new M(e)}static fromJSON(e,t){if(!t||!t.type)throw RangeError(`Invalid input for Selection.fromJSON`);let n=rt[t.type];if(!n)throw RangeError(`No selection type ${t.type} defined`);return n.fromJSON(e,t)}static jsonID(e,t){if(e in rt)throw RangeError(`Duplicate use of selection JSON ID `+e);return rt[e]=t,t.prototype.jsonID=e,t}getBookmark(){return A.between(this.$anchor,this.$head).getBookmark()}};k.prototype.visible=!0;var it=class{constructor(e,t){this.$from=e,this.$to=t}},at=!1;function ot(e){!at&&!e.parent.inlineContent&&(at=!0,console.warn(`TextSelection endpoint not pointing into a node with inline content (`+e.parent.type.name+`)`))}var A=class e extends k{constructor(e,t=e){ot(e),ot(t),super(e,t)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(t,n){let r=t.resolve(n.map(this.head));if(!r.parent.inlineContent)return k.near(r);let i=t.resolve(n.map(this.anchor));return new e(i.parent.inlineContent?i:r,r)}replace(e,t=m.v.empty){if(super.replace(e,t),t==m.v.empty){let t=this.$from.marksAcross(this.$to);t&&e.ensureMarks(t)}}eq(t){return t instanceof e&&t.anchor==this.anchor&&t.head==this.head}getBookmark(){return new st(this.anchor,this.head)}toJSON(){return{type:`text`,anchor:this.anchor,head:this.head}}static fromJSON(t,n){if(typeof n.anchor!=`number`||typeof n.head!=`number`)throw RangeError(`Invalid input for TextSelection.fromJSON`);return new e(t.resolve(n.anchor),t.resolve(n.head))}static create(e,t,n=t){let r=e.resolve(t);return new this(r,n==t?r:e.resolve(n))}static between(t,n,r){let i=t.pos-n.pos;if((!r||i)&&(r=i>=0?1:-1),!n.parent.inlineContent){let e=k.findFrom(n,r,!0)||k.findFrom(n,-r,!0);if(e)n=e.$head;else return k.near(n,r)}return t.parent.inlineContent||(i==0?t=n:(t=(k.findFrom(t,-r,!0)||k.findFrom(t,r,!0)).$anchor,t.pos<n.pos!=i<0&&(t=n))),new e(t,n)}};k.jsonID(`text`,A);var st=class e{constructor(e,t){this.anchor=e,this.head=t}map(t){return new e(t.map(this.anchor),t.map(this.head))}resolve(e){return A.between(e.resolve(this.anchor),e.resolve(this.head))}},j=class e extends k{constructor(e){let t=e.nodeAfter,n=e.node(0).resolve(e.pos+t.nodeSize);super(e,n),this.node=t}map(t,n){let{deleted:r,pos:i}=n.mapResult(this.anchor),a=t.resolve(i);return r?k.near(a):new e(a)}content(){return new m.v(m.d.from(this.node),0,0)}eq(t){return t instanceof e&&t.anchor==this.anchor}toJSON(){return{type:`node`,anchor:this.anchor}}getBookmark(){return new ct(this.anchor)}static fromJSON(t,n){if(typeof n.anchor!=`number`)throw RangeError(`Invalid input for NodeSelection.fromJSON`);return new e(t.resolve(n.anchor))}static create(t,n){return new e(t.resolve(n))}static isSelectable(e){return!e.isText&&e.type.spec.selectable!==!1}};j.prototype.visible=!1,k.jsonID(`node`,j);var ct=class e{constructor(e){this.anchor=e}map(t){let{deleted:n,pos:r}=t.mapResult(this.anchor);return n?new st(r,r):new e(r)}resolve(e){let t=e.resolve(this.anchor),n=t.nodeAfter;return n&&j.isSelectable(n)?new j(t):k.near(t)}},M=class e extends k{constructor(e){super(e.resolve(0),e.resolve(e.content.size))}replace(e,t=m.v.empty){if(t==m.v.empty){e.delete(0,e.doc.content.size);let t=k.atStart(e.doc);t.eq(e.selection)||e.setSelection(t)}else super.replace(e,t)}toJSON(){return{type:`all`}}static fromJSON(t){return new e(t)}map(t){return new e(t)}eq(t){return t instanceof e}getBookmark(){return lt}};k.jsonID(`all`,M);var lt={map(){return this},resolve(e){return new M(e)}};function ut(e,t,n,r,i,a=!1){if(t.inlineContent)return A.create(e,n);for(let o=r-(i>0?0:1);i>0?o<t.childCount:o>=0;o+=i){let r=t.child(o);if(!r.isAtom){let t=ut(e,r,n+i,i<0?r.childCount:0,i,a);if(t)return t}else if(!a&&j.isSelectable(r))return j.create(e,n-(i<0?r.nodeSize:0));n+=r.nodeSize*i}return null}function dt(e,t,n){let r=e.steps.length-1;if(r<t)return;let i=e.steps[r];if(!(i instanceof T||i instanceof E))return;let a=e.mapping.maps[r],o;a.forEach((e,t,n,r)=>{o??=r}),e.setSelection(k.near(e.doc.resolve(o),n))}var ft=1,pt=2,mt=4,ht=class extends nt{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor<this.steps.length&&(this.curSelection=this.curSelection.map(this.doc,this.mapping.slice(this.curSelectionFor)),this.curSelectionFor=this.steps.length),this.curSelection}setSelection(e){if(e.$from.doc!=this.doc)throw RangeError(`Selection passed to setSelection must point at the current document`);return this.curSelection=e,this.curSelectionFor=this.steps.length,this.updated=(this.updated|ft)&~pt,this.storedMarks=null,this}get selectionSet(){return(this.updated&ft)>0}setStoredMarks(e){return this.storedMarks=e,this.updated|=pt,this}ensureMarks(e){return m.f.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&pt)>0}addStep(e,t){super.addStep(e,t),this.updated&=~pt,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,t=!0){let n=this.selection;return t&&(e=e.mark(this.storedMarks||(n.empty?n.$from.marks():n.$from.marksAcross(n.$to)||m.f.none))),n.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,t,n){let r=this.doc.type.schema;if(t==null)return e?this.replaceSelectionWith(r.text(e),!0):this.deleteSelection();{if(n??=t,!e)return this.deleteRange(t,n);let i=this.storedMarks;if(!i){let e=this.doc.resolve(t);i=n==t?e.marks():e.marksAcross(this.doc.resolve(n))}return this.replaceRangeWith(t,n,r.text(e,i)),!this.selection.empty&&this.selection.to==t+e.length&&this.setSelection(k.near(this.selection.$to)),this}}setMeta(e,t){return this.meta[typeof e==`string`?e:e.key]=t,this}getMeta(e){return this.meta[typeof e==`string`?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=mt,this}get scrolledIntoView(){return(this.updated&mt)>0}};function gt(e,t){return!t||!e?e:e.bind(t)}var _t=class{constructor(e,t,n){this.name=e,this.init=gt(t.init,n),this.apply=gt(t.apply,n)}},vt=[new _t(`doc`,{init(e){return e.doc||e.schema.topNodeType.createAndFill()},apply(e){return e.doc}}),new _t(`selection`,{init(e,t){return e.selection||k.atStart(t.doc)},apply(e){return e.selection}}),new _t(`storedMarks`,{init(e){return e.storedMarks||null},apply(e,t,n,r){return r.selection.$cursor?e.storedMarks:null}}),new _t(`scrollToSelection`,{init(){return 0},apply(e,t){return e.scrolledIntoView?t+1:t}})],yt=class{constructor(e,t){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=vt.slice(),t&&t.forEach(e=>{if(this.pluginsByKey[e.key])throw RangeError(`Adding different instances of a keyed plugin (`+e.key+`)`);this.plugins.push(e),this.pluginsByKey[e.key]=e,e.spec.state&&this.fields.push(new _t(e.key,e.spec.state,e))})}},bt=class e{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,t=-1){for(let n=0;n<this.config.plugins.length;n++)if(n!=t){let t=this.config.plugins[n];if(t.spec.filterTransaction&&!t.spec.filterTransaction.call(t,e,this))return!1}return!0}applyTransaction(e){if(!this.filterTransaction(e))return{state:this,transactions:[]};let t=[e],n=this.applyInner(e),r=null;for(;;){let i=!1;for(let a=0;a<this.config.plugins.length;a++){let o=this.config.plugins[a];if(o.spec.appendTransaction){let s=r?r[a].n:0,c=r?r[a].state:this,l=s<t.length&&o.spec.appendTransaction.call(o,s?t.slice(s):t,c,n);if(l&&n.filterTransaction(l,a)){if(l.setMeta(`appendedTransaction`,e),!r){r=[];for(let e=0;e<this.config.plugins.length;e++)r.push(e<a?{state:n,n:t.length}:{state:this,n:0})}t.push(l),n=n.applyInner(l),i=!0}r&&(r[a]={state:n,n:t.length})}}if(!i)return{state:n,transactions:t}}}applyInner(t){if(!t.before.eq(this.doc))throw RangeError(`Applying a mismatched transaction`);let n=new e(this.config),r=this.config.fields;for(let e=0;e<r.length;e++){let i=r[e];n[i.name]=i.apply(t,this[i.name],this,n)}return n}get tr(){return new ht(this)}static create(t){let n=new yt(t.doc?t.doc.type.schema:t.schema,t.plugins),r=new e(n);for(let e=0;e<n.fields.length;e++)r[n.fields[e].name]=n.fields[e].init(t,r);return r}reconfigure(t){let n=new yt(this.schema,t.plugins),r=n.fields,i=new e(n);for(let e=0;e<r.length;e++){let n=r[e].name;i[n]=this.hasOwnProperty(n)?this[n]:r[e].init(t,i)}return i}toJSON(e){let t={doc:this.doc.toJSON(),selection:this.selection.toJSON()};if(this.storedMarks&&(t.storedMarks=this.storedMarks.map(e=>e.toJSON())),e&&typeof e==`object`)for(let n in e){if(n==`doc`||n==`selection`)throw RangeError("The JSON fields `doc` and `selection` are reserved");let r=e[n],i=r.spec.state;i&&i.toJSON&&(t[n]=i.toJSON.call(r,this[r.key]))}return t}static fromJSON(t,n,r){if(!n)throw RangeError(`Invalid input for EditorState.fromJSON`);if(!t.schema)throw RangeError(`Required config field 'schema' missing`);let i=new yt(t.schema,t.plugins),a=new e(i);return i.fields.forEach(e=>{if(e.name==`doc`)a.doc=m.m.fromJSON(t.schema,n.doc);else if(e.name==`selection`)a.selection=k.fromJSON(a.doc,n.selection);else if(e.name==`storedMarks`)n.storedMarks&&(a.storedMarks=n.storedMarks.map(t.schema.markFromJSON));else{if(r)for(let i in r){let o=r[i],s=o.spec.state;if(o.key==e.name&&s&&s.fromJSON&&Object.prototype.hasOwnProperty.call(n,i)){a[e.name]=s.fromJSON.call(o,t,n[i],a);return}}a[e.name]=e.init(t,a)}}),a}};function xt(e,t,n){for(let r in e){let i=e[r];i instanceof Function?i=i.bind(t):r==`handleDOMEvents`&&(i=xt(i,t,{})),n[r]=i}return n}var N=class{constructor(e){this.spec=e,this.props={},e.props&&xt(e.props,this,this.props),this.key=e.key?e.key.key:Ct(`plugin`)}getState(e){return e[this.key]}},St=Object.create(null);function Ct(e){return e in St?e+`$`+ ++St[e]:(St[e]=0,e+`$`)}var wt=class{constructor(e=`key`){this.key=Ct(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}},P=function(e){for(var t=0;;t++)if(e=e.previousSibling,!e)return t},Tt=function(e){let t=e.assignedSlot||e.parentNode;return t&&t.nodeType==11?t.host:t},Et=null,Dt=function(e,t,n){let r=Et||=document.createRange();return r.setEnd(e,n??e.nodeValue.length),r.setStart(e,t||0),r},Ot=function(){Et=null},kt=function(e,t,n,r){return n&&(jt(e,t,n,r,-1)||jt(e,t,n,r,1))},At=/^(img|br|input|textarea|hr)$/i;function jt(e,t,n,r,i){for(;;){if(e==n&&t==r)return!0;if(t==(i<0?0:F(e))){let n=e.parentNode;if(!n||n.nodeType!=1||Ft(e)||At.test(e.nodeName)||e.contentEditable==`false`)return!1;t=P(e)+(i<0?0:1),e=n}else if(e.nodeType==1){let n=e.childNodes[t+(i<0?-1:0)];if(n.nodeType==1&&n.contentEditable==`false`)if(n.pmViewDesc?.ignoreForSelection)t+=i;else return!1;else e=n,t=i<0?F(e):0}else return!1}}function F(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function Mt(e,t){for(;;){if(e.nodeType==3&&t)return e;if(e.nodeType==1&&t>0){if(e.contentEditable==`false`)return null;e=e.childNodes[t-1],t=F(e)}else if(e.parentNode&&!Ft(e))t=P(e),e=e.parentNode;else return null}}function Nt(e,t){for(;;){if(e.nodeType==3&&t<e.nodeValue.length)return e;if(e.nodeType==1&&t<e.childNodes.length){if(e.contentEditable==`false`)return null;e=e.childNodes[t],t=0}else if(e.parentNode&&!Ft(e))t=P(e)+1,e=e.parentNode;else return null}}function Pt(e,t,n){for(let r=t==0,i=t==F(e);r||i;){if(e==n)return!0;let t=P(e);if(e=e.parentNode,!e)return!1;r&&=t==0,i&&=t==F(e)}}function Ft(e){let t;for(let n=e;n&&!(t=n.pmViewDesc);n=n.parentNode);return t&&t.node&&t.node.isBlock&&(t.dom==e||t.contentDOM==e)}var It=function(e){return e.focusNode&&kt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset)};function Lt(e,t){let n=document.createEvent(`Event`);return n.initEvent(`keydown`,!0,!0),n.keyCode=e,n.key=n.code=t,n}function Rt(e){let t=e.activeElement;for(;t&&t.shadowRoot;)t=t.shadowRoot.activeElement;return t}function zt(e,t,n){if(e.caretPositionFromPoint)try{let r=e.caretPositionFromPoint(t,n);if(r)return{node:r.offsetNode,offset:Math.min(F(r.offsetNode),r.offset)}}catch{}if(e.caretRangeFromPoint){let r=e.caretRangeFromPoint(t,n);if(r)return{node:r.startContainer,offset:Math.min(F(r.startContainer),r.startOffset)}}}var Bt=typeof navigator<`u`?navigator:null,Vt=typeof document<`u`?document:null,Ht=Bt&&Bt.userAgent||``,Ut=/Edge\/(\d+)/.exec(Ht),Wt=/MSIE \d/.exec(Ht),Gt=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(Ht),I=!!(Wt||Gt||Ut),Kt=Wt?document.documentMode:Gt?+Gt[1]:Ut?+Ut[1]:0,qt=!I&&/gecko\/(\d+)/i.test(Ht);qt&&+(/Firefox\/(\d+)/.exec(Ht)||[0,0])[1];var Jt=!I&&/Chrome\/(\d+)/.exec(Ht),L=!!Jt,Yt=Jt?+Jt[1]:0,R=!I&&!!Bt&&/Apple Computer/.test(Bt.vendor),Xt=R&&(/Mobile\/\w+/.test(Ht)||!!Bt&&Bt.maxTouchPoints>2),Zt=Xt||(Bt?/Mac/.test(Bt.platform):!1),Qt=Bt?/Win/.test(Bt.platform):!1,$t=/Android \d/.test(Ht),en=!!Vt&&`webkitFontSmoothing`in Vt.documentElement.style,tn=en?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function nn(e){let t=e.defaultView&&e.defaultView.visualViewport;return t?{left:0,right:t.width,top:0,bottom:t.height}:{left:0,right:e.documentElement.clientWidth,top:0,bottom:e.documentElement.clientHeight}}function rn(e,t){return typeof e==`number`?e:e[t]}function an(e){let t=e.getBoundingClientRect(),n=t.width/e.offsetWidth||1,r=t.height/e.offsetHeight||1;return{left:t.left,right:t.left+e.clientWidth*n,top:t.top,bottom:t.top+e.clientHeight*r}}function on(e,t,n){let r=e.someProp(`scrollThreshold`)||0,i=e.someProp(`scrollMargin`)||5,a=e.dom.ownerDocument;for(let o=n||e.dom;o;){if(o.nodeType!=1){o=Tt(o);continue}let e=o,n=e==a.body,s=n?nn(a):an(e),c=0,l=0;if(t.top<s.top+rn(r,`top`)?l=-(s.top-t.top+rn(i,`top`)):t.bottom>s.bottom-rn(r,`bottom`)&&(l=t.bottom-t.top>s.bottom-s.top?t.top+rn(i,`top`)-s.top:t.bottom-s.bottom+rn(i,`bottom`)),t.left<s.left+rn(r,`left`)?c=-(s.left-t.left+rn(i,`left`)):t.right>s.right-rn(r,`right`)&&(c=t.right-s.right+rn(i,`right`)),c||l)if(n)a.defaultView.scrollBy(c,l);else{let n=e.scrollLeft,r=e.scrollTop;l&&(e.scrollTop+=l),c&&(e.scrollLeft+=c);let i=e.scrollLeft-n,a=e.scrollTop-r;t={left:t.left-i,top:t.top-a,right:t.right-i,bottom:t.bottom-a}}let u=n?`fixed`:getComputedStyle(o).position;if(/^(fixed|sticky)$/.test(u))break;o=u==`absolute`?o.offsetParent:Tt(o)}}function sn(e){let t=e.dom.getBoundingClientRect(),n=Math.max(0,t.top),r,i;for(let a=(t.left+t.right)/2,o=n+1;o<Math.min(innerHeight,t.bottom);o+=5){let t=e.root.elementFromPoint(a,o);if(!t||t==e.dom||!e.dom.contains(t))continue;let s=t.getBoundingClientRect();if(s.top>=n-20){r=t,i=s.top;break}}return{refDOM:r,refTop:i,stack:cn(e.dom)}}function cn(e){let t=[],n=e.ownerDocument;for(let r=e;r&&(t.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),e!=n);r=Tt(r));return t}function ln({refDOM:e,refTop:t,stack:n}){let r=e?e.getBoundingClientRect().top:0;un(n,r==0?0:r-t)}function un(e,t){for(let n=0;n<e.length;n++){let{dom:r,top:i,left:a}=e[n];r.scrollTop!=i+t&&(r.scrollTop=i+t),r.scrollLeft!=a&&(r.scrollLeft=a)}}var dn=null;function fn(e){if(e.setActive)return e.setActive();if(dn)return e.focus(dn);let t=cn(e);e.focus(dn==null?{get preventScroll(){return dn={preventScroll:!0},!0}}:void 0),dn||(dn=!1,un(t,0))}function pn(e,t){let n,r=2e8,i,a=0,o=t.top,s=t.top,c,l;for(let u=e.firstChild,d=0;u;u=u.nextSibling,d++){let e;if(u.nodeType==1)e=u.getClientRects();else if(u.nodeType==3)e=Dt(u).getClientRects();else continue;for(let f=0;f<e.length;f++){let p=e[f];if(p.top<=o&&p.bottom>=s){o=Math.max(p.bottom,o),s=Math.min(p.top,s);let e=p.left>t.left?p.left-t.left:p.right<t.left?t.left-p.right:0;if(e<r){n=u,r=e,i=e&&n.nodeType==3?{left:p.right<t.left?p.right:p.left,top:t.top}:t,u.nodeType==1&&e&&(a=d+(t.left>=(p.left+p.right)/2?1:0));continue}}else p.top>t.top&&!c&&p.left<=t.left&&p.right>=t.left&&(c=u,l={left:Math.max(p.left,Math.min(p.right,t.left)),top:p.top});!n&&(t.left>=p.right&&t.top>=p.top||t.left>=p.left&&t.top>=p.bottom)&&(a=d+1)}}return!n&&c&&(n=c,i=l,r=0),n&&n.nodeType==3?mn(n,i):!n||r&&n.nodeType==1?{node:e,offset:a}:pn(n,i)}function mn(e,t){let n=e.nodeValue.length,r=document.createRange(),i;for(let a=0;a<n;a++){r.setEnd(e,a+1),r.setStart(e,a);let n=Sn(r,1);if(n.top!=n.bottom&&hn(t,n)){i={node:e,offset:a+(t.left>=(n.left+n.right)/2?1:0)};break}}return r.detach(),i||{node:e,offset:0}}function hn(e,t){return e.left>=t.left-1&&e.left<=t.right+1&&e.top>=t.top-1&&e.top<=t.bottom+1}function gn(e,t){let n=e.parentNode;return n&&/^li$/i.test(n.nodeName)&&t.left<e.getBoundingClientRect().left?n:e}function _n(e,t,n){let{node:r,offset:i}=pn(t,n),a=-1;if(r.nodeType==1&&!r.firstChild){let e=r.getBoundingClientRect();a=e.left!=e.right&&n.left>(e.left+e.right)/2?1:-1}return e.docView.posFromDOM(r,i,a)}function vn(e,t,n,r){let i=-1;for(let n=t,a=!1;n!=e.dom;){let t=e.docView.nearestDesc(n,!0),o;if(!t)return null;if(t.dom.nodeType==1&&(t.node.isBlock&&t.parent||!t.contentDOM)&&((o=t.dom.getBoundingClientRect()).width||o.height)&&(t.node.isBlock&&t.parent&&!/^T(R|BODY|HEAD|FOOT)$/.test(t.dom.nodeName)&&(!a&&o.left>r.left||o.top>r.top?i=t.posBefore:(!a&&o.right<r.left||o.bottom<r.top)&&(i=t.posAfter),a=!0),!t.contentDOM&&i<0&&!t.node.isText))return(t.node.isBlock?r.top<(o.top+o.bottom)/2:r.left<(o.left+o.right)/2)?t.posBefore:t.posAfter;n=t.dom.parentNode}return i>-1?i:e.docView.posFromDOM(t,n,-1)}function yn(e,t,n){let r=e.childNodes.length;if(r&&n.top<n.bottom)for(let i=Math.max(0,Math.min(r-1,Math.floor(r*(t.top-n.top)/(n.bottom-n.top))-2)),a=i;;){let n=e.childNodes[a];if(n.nodeType==1){let e=n.getClientRects();for(let r=0;r<e.length;r++){let i=e[r];if(hn(t,i))return yn(n,t,i)}}if((a=(a+1)%r)==i)break}return e}function bn(e,t){let n=e.dom.ownerDocument,r,i=0,a=zt(n,t.left,t.top);a&&({node:r,offset:i}=a);let o=(e.root.elementFromPoint?e.root:n).elementFromPoint(t.left,t.top),s;if(!o||!e.dom.contains(o.nodeType==1?o:o.parentNode)){let n=e.dom.getBoundingClientRect();if(!hn(t,n)||(o=yn(e.dom,t,n),!o))return null}if(R)for(let e=o;r&&e;e=Tt(e))e.draggable&&(r=void 0);if(o=gn(o,t),r){if(qt&&r.nodeType==1&&(i=Math.min(i,r.childNodes.length),i<r.childNodes.length)){let e=r.childNodes[i],n;e.nodeName==`IMG`&&(n=e.getBoundingClientRect()).right<=t.left&&n.bottom>t.top&&i++}let n;en&&i&&r.nodeType==1&&(n=r.childNodes[i-1]).nodeType==1&&n.contentEditable==`false`&&n.getBoundingClientRect().top>=t.top&&i--,r==e.dom&&i==r.childNodes.length-1&&r.lastChild.nodeType==1&&t.top>r.lastChild.getBoundingClientRect().bottom?s=e.state.doc.content.size:(i==0||r.nodeType!=1||r.childNodes[i-1].nodeName!=`BR`)&&(s=vn(e,r,i,t))}s??=_n(e,o,t);let c=e.docView.nearestDesc(o,!0);return{pos:s,inside:c?c.posAtStart-c.border:-1}}function xn(e){return e.top<e.bottom||e.left<e.right}function Sn(e,t){let n=e.getClientRects();if(n.length){let e=n[t<0?0:n.length-1];if(xn(e))return e}return Array.prototype.find.call(n,xn)||e.getBoundingClientRect()}var Cn=/[\u0590-\u05f4\u0600-\u06ff\u0700-\u08ac]/;function wn(e,t,n){let{node:r,offset:i,atom:a}=e.docView.domFromPos(t,n<0?-1:1),o=en||qt;if(r.nodeType==3)if(o&&(Cn.test(r.nodeValue)||(n<0?!i:i==r.nodeValue.length))){let e=Sn(Dt(r,i,i),n);if(qt&&i&&/\s/.test(r.nodeValue[i-1])&&i<r.nodeValue.length){let t=Sn(Dt(r,i-1,i-1),-1);if(t.top==e.top){let n=Sn(Dt(r,i,i+1),-1);if(n.top!=e.top)return Tn(n,n.left<t.left)}}return e}else{let e=i,t=i,a=n<0?1:-1;return n<0&&!i?(t++,a=-1):n>=0&&i==r.nodeValue.length?(e--,a=1):n<0?e--:t++,Tn(Sn(Dt(r,e,t),a),a<0)}if(!e.state.doc.resolve(t-(a||0)).parent.inlineContent){if(a==null&&i&&(n<0||i==F(r))){let e=r.childNodes[i-1];if(e.nodeType==1)return En(e.getBoundingClientRect(),!1)}if(a==null&&i<F(r)){let e=r.childNodes[i];if(e.nodeType==1)return En(e.getBoundingClientRect(),!0)}return En(r.getBoundingClientRect(),n>=0)}if(a==null&&i&&(n<0||i==F(r))){let e=r.childNodes[i-1],t=e.nodeType==3?Dt(e,F(e)-(o?0:1)):e.nodeType==1&&(e.nodeName!=`BR`||!e.nextSibling)?e:null;if(t)return Tn(Sn(t,1),!1)}if(a==null&&i<F(r)){let e=r.childNodes[i];for(;e.pmViewDesc&&e.pmViewDesc.ignoreForCoords;)e=e.nextSibling;let t=e?e.nodeType==3?Dt(e,0,o?0:1):e.nodeType==1?e:null:null;if(t)return Tn(Sn(t,-1),!0)}return Tn(Sn(r.nodeType==3?Dt(r):r,-n),n>=0)}function Tn(e,t){if(e.width==0)return e;let n=t?e.left:e.right;return{top:e.top,bottom:e.bottom,left:n,right:n}}function En(e,t){if(e.height==0)return e;let n=t?e.top:e.bottom;return{top:n,bottom:n,left:e.left,right:e.right}}function Dn(e,t,n){let r=e.state,i=e.root.activeElement;r!=t&&e.updateState(t),i!=e.dom&&e.focus();try{return n()}finally{r!=t&&e.updateState(r),i!=e.dom&&i&&i.focus()}}function On(e,t,n){let r=t.selection,i=n==`up`?r.$from:r.$to;return Dn(e,t,()=>{let{node:t}=e.docView.domFromPos(i.pos,n==`up`?-1:1);for(;;){let n=e.docView.nearestDesc(t,!0);if(!n)break;if(n.node.isBlock){t=n.contentDOM||n.dom;break}t=n.dom.parentNode}let r=wn(e,i.pos,1);for(let e=t.firstChild;e;e=e.nextSibling){let t;if(e.nodeType==1)t=e.getClientRects();else if(e.nodeType==3)t=Dt(e,0,e.nodeValue.length).getClientRects();else continue;for(let e=0;e<t.length;e++){let i=t[e];if(i.bottom>i.top+1&&(n==`up`?r.top-i.top>(i.bottom-r.top)*2:i.bottom-r.bottom>(r.bottom-i.top)*2))return!1}}return!0})}var kn=/[\u0590-\u08ac]/;function An(e,t,n){let{$head:r}=t.selection;if(!r.parent.isTextblock)return!1;let i=r.parentOffset,a=!i,o=i==r.parent.content.size,s=e.domSelection();return s?!kn.test(r.parent.textContent)||!s.modify?n==`left`||n==`backward`?a:o:Dn(e,t,()=>{let{focusNode:t,focusOffset:i,anchorNode:a,anchorOffset:o}=e.domSelectionRange(),c=s.caretBidiLevel;s.modify(`move`,n,`character`);let l=r.depth?e.docView.domAfterPos(r.before()):e.dom,{focusNode:u,focusOffset:d}=e.domSelectionRange(),f=u&&!l.contains(u.nodeType==1?u:u.parentNode)||t==u&&i==d;try{s.collapse(a,o),t&&(t!=a||i!=o)&&s.extend&&s.extend(t,i)}catch{}return c!=null&&(s.caretBidiLevel=c),f}):r.pos==r.start()||r.pos==r.end()}var jn=null,Mn=null,Nn=!1;function Pn(e,t,n){return jn==t&&Mn==n?Nn:(jn=t,Mn=n,Nn=n==`up`||n==`down`?On(e,t,n):An(e,t,n))}var Fn=0,In=1,Ln=2,Rn=3,zn=class{constructor(e,t,n,r){this.parent=e,this.children=t,this.dom=n,this.contentDOM=r,this.dirty=Fn,n.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,t,n){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let t=0;t<this.children.length;t++)e+=this.children[t].size;return e}get border(){return 0}destroy(){this.parent=void 0,this.dom.pmViewDesc==this&&(this.dom.pmViewDesc=void 0);for(let e=0;e<this.children.length;e++)this.children[e].destroy()}posBeforeChild(e){for(let t=0,n=this.posAtStart;;t++){let r=this.children[t];if(r==e)return n;n+=r.size}}get posBefore(){return this.parent.posBeforeChild(this)}get posAtStart(){return this.parent?this.parent.posBeforeChild(this)+this.border:0}get posAfter(){return this.posBefore+this.size}get posAtEnd(){return this.posAtStart+this.size-2*this.border}localPosFromDOM(e,t,n){if(this.contentDOM&&this.contentDOM.contains(e.nodeType==1?e:e.parentNode))if(n<0){let n,r;if(e==this.contentDOM)n=e.childNodes[t-1];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.previousSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.previousSibling;return n?this.posBeforeChild(r)+r.size:this.posAtStart}else{let n,r;if(e==this.contentDOM)n=e.childNodes[t];else{for(;e.parentNode!=this.contentDOM;)e=e.parentNode;n=e.nextSibling}for(;n&&!((r=n.pmViewDesc)&&r.parent==this);)n=n.nextSibling;return n?this.posBeforeChild(r):this.posAtEnd}let r;if(e==this.dom&&this.contentDOM)r=t>P(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))r=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(t==0)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!1;break}if(t.previousSibling)break}if(r==null&&t==e.childNodes.length)for(let t=e;;t=t.parentNode){if(t==this.dom){r=!0;break}if(t.nextSibling)break}}return r??n>0?this.posAtEnd:this.posAtStart}nearestDesc(e,t=!1){for(let n=!0,r=e;r;r=r.parentNode){let i=this.getDesc(r),a;if(i&&(!t||i.node))if(n&&(a=i.nodeDOM)&&!(a.nodeType==1?a.contains(e.nodeType==1?e:e.parentNode):a==e))n=!1;else return i}}getDesc(e){let t=e.pmViewDesc;for(let e=t;e;e=e.parent)if(e==this)return t}posFromDOM(e,t,n){for(let r=e;r;r=r.parentNode){let i=this.getDesc(r);if(i)return i.localPosFromDOM(e,t,n)}return-1}descAt(e){for(let t=0,n=0;t<this.children.length;t++){let r=this.children[t],i=n+r.size;if(n==e&&i!=n){for(;!r.border&&r.children.length;)for(let e=0;e<r.children.length;e++){let t=r.children[e];if(t.size){r=t;break}}return r}if(e<i)return r.descAt(e-n-r.border);n=i}}domFromPos(e,t){if(!this.contentDOM)return{node:this.dom,offset:0,atom:e+1};let n=0,r=0;for(let t=0;n<this.children.length;n++){let i=this.children[n],a=t+i.size;if(a>e||i instanceof Kn){r=e-t;break}t=a}if(r)return this.children[n].domFromPos(r-this.children[n].border,t);for(let e;n&&!(e=this.children[n-1]).size&&e instanceof Bn&&e.side>=0;n--);if(t<=0){let e,r=!0;for(;e=n?this.children[n-1]:null,!(!e||e.dom.parentNode==this.contentDOM);n--,r=!1);return e&&t&&r&&!e.border&&!e.domAtom?e.domFromPos(e.size,t):{node:this.contentDOM,offset:e?P(e.dom)+1:0}}else{let e,r=!0;for(;e=n<this.children.length?this.children[n]:null,!(!e||e.dom.parentNode==this.contentDOM);n++,r=!1);return e&&r&&!e.border&&!e.domAtom?e.domFromPos(0,t):{node:this.contentDOM,offset:e?P(e.dom):this.contentDOM.childNodes.length}}}parseRange(e,t,n=0){if(this.children.length==0)return{node:this.contentDOM,from:e,to:t,fromOffset:0,toOffset:this.contentDOM.childNodes.length};let r=-1,i=-1;for(let a=n,o=0;;o++){let n=this.children[o],s=a+n.size;if(r==-1&&e<=s){let i=a+n.border;if(e>=i&&t<=s-n.border&&n.node&&n.contentDOM&&this.contentDOM.contains(n.contentDOM))return n.parseRange(e,t,i);e=a;for(let t=o;t>0;t--){let n=this.children[t-1];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(1)){r=P(n.dom)+1;break}e-=n.size}r==-1&&(r=0)}if(r>-1&&(s>t||o==this.children.length-1)){t=s;for(let e=o+1;e<this.children.length;e++){let n=this.children[e];if(n.size&&n.dom.parentNode==this.contentDOM&&!n.emptyChildAt(-1)){i=P(n.dom);break}t+=n.size}i==-1&&(i=this.contentDOM.childNodes.length);break}a=s}return{node:this.contentDOM,from:e,to:t,fromOffset:r,toOffset:i}}emptyChildAt(e){if(this.border||!this.contentDOM||!this.children.length)return!1;let t=this.children[e<0?0:this.children.length-1];return t.size==0||t.emptyChildAt(e)}domAfterPos(e){let{node:t,offset:n}=this.domFromPos(e,0);if(t.nodeType!=1||n==t.childNodes.length)throw RangeError(`No node after pos `+e);return t.childNodes[n]}setSelection(e,t,n,r=!1){let i=Math.min(e,t),a=Math.max(e,t);for(let o=0,s=0;o<this.children.length;o++){let c=this.children[o],l=s+c.size;if(i>s&&a<l)return c.setSelection(e-s-c.border,t-s-c.border,n,r);s=l}let o=this.domFromPos(e,e?-1:1),s=t==e?o:this.domFromPos(t,t?-1:1),c=n.root.getSelection(),l=n.domSelectionRange(),u=!1;if((qt||R)&&e==t){let{node:e,offset:t}=o;if(e.nodeType==3){if(u=!!(t&&e.nodeValue[t-1]==`
26
+ `),u&&t==e.nodeValue.length)for(let t=e,n;t;t=t.parentNode){if(n=t.nextSibling){n.nodeName==`BR`&&(o=s={node:n.parentNode,offset:P(n)+1});break}let e=t.pmViewDesc;if(e&&e.node&&e.node.isBlock)break}}else{let n=e.childNodes[t-1];u=n&&(n.nodeName==`BR`||n.contentEditable==`false`)}}if(qt&&l.focusNode&&l.focusNode!=s.node&&l.focusNode.nodeType==1){let e=l.focusNode.childNodes[l.focusOffset];e&&e.contentEditable==`false`&&(r=!0)}if(!(r||u&&R)&&kt(o.node,o.offset,l.anchorNode,l.anchorOffset)&&kt(s.node,s.offset,l.focusNode,l.focusOffset))return;let d=!1;if((c.extend||e==t)&&!(u&&qt)){c.collapse(o.node,o.offset);try{e!=t&&c.extend(s.node,s.offset),d=!0}catch{}}if(!d){if(e>t){let e=o;o=s,s=e}let n=document.createRange();n.setEnd(s.node,s.offset),n.setStart(o.node,o.offset),c.removeAllRanges(),c.addRange(n)}}ignoreMutation(e){return!this.contentDOM&&e.type!=`selection`}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,t){for(let n=0,r=0;r<this.children.length;r++){let i=this.children[r],a=n+i.size;if(n==a?e<=a&&t>=n:e<a&&t>n){let r=n+i.border,o=a-i.border;if(e>=r&&t<=o){this.dirty=e==n||t==a?Ln:In,e==r&&t==o&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=Rn:i.markDirty(e-r,t-r);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Ln:Rn}n=a}this.dirty=Ln}markParentsDirty(){let e=1;for(let t=this.parent;t;t=t.parent,e++){let n=e==1?Ln:In;t.dirty<n&&(t.dirty=n)}}get domAtom(){return!1}get ignoreForCoords(){return!1}get ignoreForSelection(){return!1}isText(e){return!1}},Bn=class extends zn{constructor(e,t,n,r){let i,a=t.type.toDOM;if(typeof a==`function`&&(a=a(n,()=>{if(!i)return r;if(i.parent)return i.parent.posBeforeChild(i)})),!t.type.spec.raw){if(a.nodeType!=1){let e=document.createElement(`span`);e.appendChild(a),a=e}a.contentEditable=`false`,a.classList.add(`ProseMirror-widget`)}super(e,[],a,null),this.widget=t,this.widget=t,i=this}matchesWidget(e){return this.dirty==Fn&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let t=this.widget.spec.stopEvent;return t?t(e):!1}ignoreMutation(e){return e.type!=`selection`||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get ignoreForSelection(){return!!this.widget.type.spec.relaxedSide}get side(){return this.widget.type.side}},Vn=class extends zn{constructor(e,t,n,r){super(e,[],t,null),this.textDOM=n,this.text=r}get size(){return this.text.length}localPosFromDOM(e,t){return e==this.textDOM?this.posAtStart+t:this.posAtStart+(t?this.size:0)}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type===`characterData`&&e.target.nodeValue==e.oldValue}},Hn=class e extends zn{constructor(e,t,n,r,i){super(e,[],n,r),this.mark=t,this.spec=i}static create(t,n,r,i){let a=i.nodeViews[n.type.name],o=a&&a(n,i,r);return(!o||!o.dom)&&(o=m.u.renderSpec(document,n.type.spec.toDOM(n,r),null,n.attrs)),new e(t,n,o.dom,o.contentDOM||o.dom,o)}parseRule(){return this.dirty&Rn||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=Rn&&this.mark.eq(e)}markDirty(e,t){if(super.markDirty(e,t),this.dirty!=Fn){let e=this.parent;for(;!e.node;)e=e.parent;e.dirty<this.dirty&&(e.dirty=this.dirty),this.dirty=Fn}}slice(t,n,r){let i=e.create(this.parent,this.mark,!0,r),a=this.children,o=this.size;n<o&&(a=lr(a,n,o,r)),t>0&&(a=lr(a,0,t,r));for(let e=0;e<a.length;e++)a[e].parent=i;return i.children=a,i}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}},Un=class e extends zn{constructor(e,t,n,r,i,a,o,s,c){super(e,[],i,a),this.node=t,this.outerDeco=n,this.innerDeco=r,this.nodeDOM=o}static create(t,n,r,i,a,o){let s=a.nodeViews[n.type.name],c,l=s&&s(n,a,()=>{if(!c)return o;if(c.parent)return c.parent.posBeforeChild(c)},r,i),u=l&&l.dom,d=l&&l.contentDOM;if(n.isText){if(!u)u=document.createTextNode(n.text);else if(u.nodeType!=3)throw RangeError(`Text must be rendered as a DOM text node`)}else if(!u){let e=m.u.renderSpec(document,n.type.spec.toDOM(n),null,n.attrs);({dom:u,contentDOM:d}=e)}!d&&!n.isText&&u.nodeName!=`BR`&&(u.hasAttribute(`contenteditable`)||(u.contentEditable=`false`),n.type.spec.draggable&&(u.draggable=!0));let f=u;return u=er(u,r,n),l?c=new qn(t,n,r,i,u,d||null,f,l,a,o+1):n.isText?new Gn(t,n,r,i,u,f,a):new e(t,n,r,i,u,d||null,f,a,o+1)}parseRule(){if(this.node.type.spec.reparseInView)return null;let e={node:this.node.type.name,attrs:this.node.attrs};if(this.node.type.whitespace==`pre`&&(e.preserveWhitespace=`full`),!this.contentDOM)e.getContent=()=>this.node.content;else if(!this.contentLost)e.contentElement=this.contentDOM;else{for(let t=this.children.length-1;t>=0;t--){let n=this.children[t];if(this.dom.contains(n.dom.parentNode)){e.contentElement=n.dom.parentNode;break}}e.contentElement||(e.getContent=()=>m.d.empty)}return e}matchesNode(e,t,n){return this.dirty==Fn&&e.eq(this.node)&&tr(t,this.outerDeco)&&n.eq(this.innerDeco)}get size(){return this.node.nodeSize}get border(){return this.node.isLeaf?0:1}updateChildren(e,t){let n=this.node.inlineContent,r=t,i=e.composing?this.localCompositionInfo(e,t):null,a=i&&i.pos>-1?i:null,o=i&&i.pos<0,s=new rr(this,a&&a.node,e);or(this.node,this.innerDeco,(t,i,a)=>{t.spec.marks?s.syncToMarks(t.spec.marks,n,e,i):t.type.side>=0&&!a&&s.syncToMarks(i==this.node.childCount?m.f.none:this.node.child(i).marks,n,e,i),s.placeWidget(t,e,r)},(t,a,c,l)=>{s.syncToMarks(t.marks,n,e,l);let u;s.findNodeMatch(t,a,c,l)||o&&e.state.selection.from>r&&e.state.selection.to<r+t.nodeSize&&(u=s.findIndexWithChild(i.node))>-1&&s.updateNodeAt(t,a,c,u,e)||s.updateNextNode(t,a,c,e,l,r)||s.addNode(t,a,c,e,r),r+=t.nodeSize}),s.syncToMarks([],n,e,0),this.node.isTextblock&&s.addTextblockHacks(),s.destroyRest(),(s.changed||this.dirty==Ln)&&(a&&this.protectLocalComposition(e,a),Jn(this.contentDOM,this.children,e),Xt&&sr(this.dom))}localCompositionInfo(e,t){let{from:n,to:r}=e.state.selection;if(!(e.state.selection instanceof A)||n<t||r>t+this.node.content.size)return null;let i=e.input.compositionNode;if(!i||!this.dom.contains(i.parentNode))return null;if(this.node.inlineContent){let e=i.nodeValue,a=cr(this.node.content,e,n-t,r-t);return a<0?null:{node:i,pos:a,text:e}}else return{node:i,pos:-1,text:``}}protectLocalComposition(e,{node:t,pos:n,text:r}){if(this.getDesc(t))return;let i=t;for(;i.parentNode!=this.contentDOM;i=i.parentNode){for(;i.previousSibling;)i.parentNode.removeChild(i.previousSibling);for(;i.nextSibling;)i.parentNode.removeChild(i.nextSibling);i.pmViewDesc&&=void 0}let a=new Vn(this,i,t,r);e.input.compositionNodes.push(a),this.children=lr(this.children,n,n+r.length,e,a)}update(e,t,n,r){return this.dirty==Rn||!e.sameMarkup(this.node)?!1:(this.updateInner(e,t,n,r),!0)}updateInner(e,t,n,r){this.updateOuterDeco(t),this.node=e,this.innerDeco=n,this.contentDOM&&this.updateChildren(r,this.posAtStart),this.dirty=Fn}updateOuterDeco(e){if(tr(e,this.outerDeco))return;let t=this.nodeDOM.nodeType!=1,n=this.dom;this.dom=Qn(this.dom,this.nodeDOM,Zn(this.outerDeco,this.node,t),Zn(e,this.node,t)),this.dom!=n&&(n.pmViewDesc=void 0,this.dom.pmViewDesc=this),this.outerDeco=e}selectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.add(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&(this.nodeDOM.draggable=!0))}deselectNode(){this.nodeDOM.nodeType==1&&(this.nodeDOM.classList.remove(`ProseMirror-selectednode`),(this.contentDOM||!this.node.type.spec.draggable)&&this.nodeDOM.removeAttribute(`draggable`))}get domAtom(){return this.node.isAtom}};function Wn(e,t,n,r,i){er(r,t,e);let a=new Un(void 0,e,t,n,r,r,r,i,0);return a.contentDOM&&a.updateChildren(i,0),a}var Gn=class e extends Un{constructor(e,t,n,r,i,a,o){super(e,t,n,r,i,null,a,o,0)}parseRule(){let e=this.nodeDOM.parentNode;for(;e&&e!=this.dom&&!e.pmIsDeco;)e=e.parentNode;return{skip:e||!0}}update(e,t,n,r){return this.dirty==Rn||this.dirty!=Fn&&!this.inParent()||!e.sameMarkup(this.node)?!1:(this.updateOuterDeco(t),(this.dirty!=Fn||e.text!=this.node.text)&&e.text!=this.nodeDOM.nodeValue&&(this.nodeDOM.nodeValue=e.text,r.trackWrites==this.nodeDOM&&(r.trackWrites=null)),this.node=e,this.dirty=Fn,!0)}inParent(){let e=this.parent.contentDOM;for(let t=this.nodeDOM;t;t=t.parentNode)if(t==e)return!0;return!1}domFromPos(e){return{node:this.nodeDOM,offset:e}}localPosFromDOM(e,t,n){return e==this.nodeDOM?this.posAtStart+Math.min(t,this.node.text.length):super.localPosFromDOM(e,t,n)}ignoreMutation(e){return e.type!=`characterData`&&e.type!=`selection`}slice(t,n,r){let i=this.node.cut(t,n),a=document.createTextNode(i.text);return new e(this.parent,i,this.outerDeco,this.innerDeco,a,a,r)}markDirty(e,t){super.markDirty(e,t),this.dom!=this.nodeDOM&&(e==0||t==this.nodeDOM.nodeValue.length)&&(this.dirty=Rn)}get domAtom(){return!1}isText(e){return this.node.text==e}},Kn=class extends zn{parseRule(){return{ignore:!0}}matchesHack(e){return this.dirty==Fn&&this.dom.nodeName==e}get domAtom(){return!0}get ignoreForCoords(){return this.dom.nodeName==`IMG`}},qn=class extends Un{constructor(e,t,n,r,i,a,o,s,c,l){super(e,t,n,r,i,a,o,c,l),this.spec=s}update(e,t,n,r){if(this.dirty==Rn)return!1;if(this.spec.update&&(this.node.type==e.type||this.spec.multiType)){let i=this.spec.update(e,t,n);return i&&this.updateInner(e,t,n,r),i}else if(!this.contentDOM&&!e.isLeaf)return!1;else return super.update(e,t,n,r)}selectNode(){this.spec.selectNode?this.spec.selectNode():super.selectNode()}deselectNode(){this.spec.deselectNode?this.spec.deselectNode():super.deselectNode()}setSelection(e,t,n,r){this.spec.setSelection?this.spec.setSelection(e,t,n.root):super.setSelection(e,t,n,r)}destroy(){this.spec.destroy&&this.spec.destroy(),super.destroy()}stopEvent(e){return this.spec.stopEvent?this.spec.stopEvent(e):!1}ignoreMutation(e){return this.spec.ignoreMutation?this.spec.ignoreMutation(e):super.ignoreMutation(e)}};function Jn(e,t,n){let r=e.firstChild,i=!1;for(let a=0;a<t.length;a++){let o=t[a],s=o.dom;if(s.parentNode==e){for(;s!=r;)r=nr(r),i=!0;r=r.nextSibling}else i=!0,e.insertBefore(s,r);if(o instanceof Hn){let t=r?r.previousSibling:e.lastChild;Jn(o.contentDOM,o.children,n),r=t?t.nextSibling:e.firstChild}}for(;r;)r=nr(r),i=!0;i&&n.trackWrites==e&&(n.trackWrites=null)}var Yn=function(e){e&&(this.nodeName=e)};Yn.prototype=Object.create(null);var Xn=[new Yn];function Zn(e,t,n){if(e.length==0)return Xn;let r=n?Xn[0]:new Yn,i=[r];for(let a=0;a<e.length;a++){let o=e[a].type.attrs;if(o){o.nodeName&&i.push(r=new Yn(o.nodeName));for(let e in o){let a=o[e];a!=null&&(n&&i.length==1&&i.push(r=new Yn(t.isInline?`span`:`div`)),e==`class`?r.class=(r.class?r.class+` `:``)+a:e==`style`?r.style=(r.style?r.style+`;`:``)+a:e!=`nodeName`&&(r[e]=a))}}}return i}function Qn(e,t,n,r){if(n==Xn&&r==Xn)return t;let i=t;for(let t=0;t<r.length;t++){let a=r[t],o=n[t];if(t){let t;o&&o.nodeName==a.nodeName&&i!=e&&(t=i.parentNode)&&t.nodeName.toLowerCase()==a.nodeName?i=t:(t=document.createElement(a.nodeName),t.pmIsDeco=!0,t.appendChild(i),o=Xn[0],i=t)}$n(i,o||Xn[0],a)}return i}function $n(e,t,n){for(let r in t)r!=`class`&&r!=`style`&&r!=`nodeName`&&!(r in n)&&e.removeAttribute(r);for(let r in n)r!=`class`&&r!=`style`&&r!=`nodeName`&&n[r]!=t[r]&&e.setAttribute(r,n[r]);if(t.class!=n.class){let r=t.class?t.class.split(` `).filter(Boolean):[],i=n.class?n.class.split(` `).filter(Boolean):[];for(let t=0;t<r.length;t++)i.indexOf(r[t])==-1&&e.classList.remove(r[t]);for(let t=0;t<i.length;t++)r.indexOf(i[t])==-1&&e.classList.add(i[t]);e.classList.length==0&&e.removeAttribute(`class`)}if(t.style!=n.style){if(t.style){let n=/\s*([\w\-\xa1-\uffff]+)\s*:(?:"(?:\\.|[^"])*"|'(?:\\.|[^'])*'|\(.*?\)|[^;])*/g,r;for(;r=n.exec(t.style);)e.style.removeProperty(r[1])}n.style&&(e.style.cssText+=n.style)}}function er(e,t,n){return Qn(e,e,Xn,Zn(t,n,e.nodeType!=1))}function tr(e,t){if(e.length!=t.length)return!1;for(let n=0;n<e.length;n++)if(!e[n].type.eq(t[n].type))return!1;return!0}function nr(e){let t=e.nextSibling;return e.parentNode.removeChild(e),t}var rr=class{constructor(e,t,n){this.lock=t,this.view=n,this.index=0,this.stack=[],this.changed=!1,this.top=e,this.preMatch=ir(e.node.content,e)}destroyBetween(e,t){if(e!=t){for(let n=e;n<t;n++)this.top.children[n].destroy();this.top.children.splice(e,t-e),this.changed=!0}}destroyRest(){this.destroyBetween(this.index,this.top.children.length)}syncToMarks(e,t,n,r){let i=0,a=this.stack.length>>1,o=Math.min(a,e.length);for(;i<o&&(i==a-1?this.top:this.stack[i+1<<1]).matchesMark(e[i])&&e[i].type.spec.spanning!==!1;)i++;for(;i<a;)this.destroyRest(),this.top.dirty=Fn,this.index=this.stack.pop(),this.top=this.stack.pop(),a--;for(;a<e.length;){this.stack.push(this.top,this.index+1);let i=-1,o=this.top.children.length;r<this.preMatch.index&&(o=Math.min(this.index+3,o));for(let t=this.index;t<o;t++){let n=this.top.children[t];if(n.matchesMark(e[a])&&!this.isLocked(n.dom)){i=t;break}}if(i>-1)i>this.index&&(this.changed=!0,this.destroyBetween(this.index,i)),this.top=this.top.children[this.index];else{let r=Hn.create(this.top,e[a],t,n);this.top.children.splice(this.index,0,r),this.top=r,this.changed=!0}this.index=0,a++}}findNodeMatch(e,t,n,r){let i=-1,a;if(r>=this.preMatch.index&&(a=this.preMatch.matches[r-this.preMatch.index]).parent==this.top&&a.matchesNode(e,t,n))i=this.top.children.indexOf(a,this.index);else for(let r=this.index,a=Math.min(this.top.children.length,r+5);r<a;r++){let a=this.top.children[r];if(a.matchesNode(e,t,n)&&!this.preMatch.matched.has(a)){i=r;break}}return i<0?!1:(this.destroyBetween(this.index,i),this.index++,!0)}updateNodeAt(e,t,n,r,i){let a=this.top.children[r];return a.dirty==Rn&&a.dom==a.contentDOM&&(a.dirty=Ln),a.update(e,t,n,i)?(this.destroyBetween(this.index,r),this.index++,!0):!1}findIndexWithChild(e){for(;;){let t=e.parentNode;if(!t)return-1;if(t==this.top.contentDOM){let t=e.pmViewDesc;if(t){for(let e=this.index;e<this.top.children.length;e++)if(this.top.children[e]==t)return e}return-1}e=t}}updateNextNode(e,t,n,r,i,a){for(let o=this.index;o<this.top.children.length;o++){let s=this.top.children[o];if(s instanceof Un){let c=this.preMatch.matched.get(s);if(c!=null&&c!=i)return!1;let l=s.dom,u,d=this.isLocked(l)&&!(e.isText&&s.node&&s.node.isText&&s.nodeDOM.nodeValue==e.text&&s.dirty!=Rn&&tr(t,s.outerDeco));if(!d&&s.update(e,t,n,r))return this.destroyBetween(this.index,o),s.dom!=l&&(this.changed=!0),this.index++,!0;if(!d&&(u=this.recreateWrapper(s,e,t,n,r,a)))return this.destroyBetween(this.index,o),this.top.children[this.index]=u,u.contentDOM&&(u.dirty=Ln,u.updateChildren(r,a+1),u.dirty=Fn),this.changed=!0,this.index++,!0;break}}return!1}recreateWrapper(e,t,n,r,i,a){if(e.dirty||t.isAtom||!e.children.length||!e.node.content.eq(t.content)||!tr(n,e.outerDeco)||!r.eq(e.innerDeco))return null;let o=Un.create(this.top,t,n,r,i,a);if(o.contentDOM){o.children=e.children,e.children=[];for(let e of o.children)e.parent=o}return e.destroy(),o}addNode(e,t,n,r,i){let a=Un.create(this.top,e,t,n,r,i);a.contentDOM&&a.updateChildren(r,i+1),this.top.children.splice(this.index++,0,a),this.changed=!0}placeWidget(e,t,n){let r=this.index<this.top.children.length?this.top.children[this.index]:null;if(r&&r.matchesWidget(e)&&(e==r.widget||!r.widget.type.toDOM.parentNode))this.index++;else{let r=new Bn(this.top,e,t,n);this.top.children.splice(this.index++,0,r),this.changed=!0}}addTextblockHacks(){let e=this.top.children[this.index-1],t=this.top;for(;e instanceof Hn;)t=e,e=t.children[t.children.length-1];(!e||!(e instanceof Gn)||/\n$/.test(e.node.text)||this.view.requiresGeckoHackNode&&/\s$/.test(e.node.text))&&((R||L)&&e&&e.dom.contentEditable==`false`&&this.addHackNode(`IMG`,t),this.addHackNode(`BR`,this.top))}addHackNode(e,t){if(t==this.top&&this.index<t.children.length&&t.children[this.index].matchesHack(e))this.index++;else{let n=document.createElement(e);e==`IMG`&&(n.className=`ProseMirror-separator`,n.alt=``),e==`BR`&&(n.className=`ProseMirror-trailingBreak`);let r=new Kn(this.top,[],n,null);t==this.top?t.children.splice(this.index++,0,r):t.children.push(r),this.changed=!0}}isLocked(e){return this.lock&&(e==this.lock||e.nodeType==1&&e.contains(this.lock.parentNode))}};function ir(e,t){let n=t,r=n.children.length,i=e.childCount,a=new Map,o=[];outer:for(;i>0;){let s;for(;;)if(r){let e=n.children[r-1];if(e instanceof Hn)n=e,r=e.children.length;else{s=e,r--;break}}else if(n==t)break outer;else r=n.parent.children.indexOf(n),n=n.parent;let c=s.node;if(c){if(c!=e.child(i-1))break;--i,a.set(s,i),o.push(s)}}return{index:i,matched:a,matches:o.reverse()}}function ar(e,t){return e.type.side-t.type.side}function or(e,t,n,r){let i=t.locals(e),a=0;if(i.length==0){for(let n=0;n<e.childCount;n++){let o=e.child(n);r(o,i,t.forChild(a,o),n),a+=o.nodeSize}return}let o=0,s=[],c=null;for(let l=0;;){let u,d;for(;o<i.length&&i[o].to==a;){let e=i[o++];e.widget&&(u?(d||=[u]).push(e):u=e)}if(u)if(d){d.sort(ar);for(let e=0;e<d.length;e++)n(d[e],l,!!c)}else n(u,l,!!c);let f,p;if(c)p=-1,f=c,c=null;else if(l<e.childCount)p=l,f=e.child(l++);else break;for(let e=0;e<s.length;e++)s[e].to<=a&&s.splice(e--,1);for(;o<i.length&&i[o].from<=a&&i[o].to>a;)s.push(i[o++]);let m=a+f.nodeSize;if(f.isText){let e=m;o<i.length&&i[o].from<e&&(e=i[o].from);for(let t=0;t<s.length;t++)s[t].to<e&&(e=s[t].to);e<m&&(c=f.cut(e-a),f=f.cut(0,e-a),m=e,p=-1)}else for(;o<i.length&&i[o].to<m;)o++;let h=f.isInline&&!f.isLeaf?s.filter(e=>!e.inline):s.slice();r(f,h,t.forChild(a,f),p),a=m}}function sr(e){if(e.nodeName==`UL`||e.nodeName==`OL`){let t=e.style.cssText;e.style.cssText=t+`; list-style: square !important`,window.getComputedStyle(e).listStyle,e.style.cssText=t}}function cr(e,t,n,r){for(let i=0,a=0;i<e.childCount&&a<=r;){let o=e.child(i++),s=a;if(a+=o.nodeSize,!o.isText)continue;let c=o.text;for(;i<e.childCount;){let t=e.child(i++);if(a+=t.nodeSize,!t.isText)break;c+=t.text}if(a>=n){if(a>=r&&c.slice(r-t.length-s,r-s)==t)return r-t.length;let e=s<r?c.lastIndexOf(t,r-s-1):-1;if(e>=0&&e+t.length+s>=n)return s+e;if(n==r&&c.length>=r+t.length-s&&c.slice(r-s,r-s+t.length)==t)return r}}return-1}function lr(e,t,n,r,i){let a=[];for(let o=0,s=0;o<e.length;o++){let c=e[o],l=s,u=s+=c.size;l>=n||u<=t?a.push(c):(l<t&&a.push(c.slice(0,t-l,r)),i&&=(a.push(i),void 0),u>n&&a.push(c.slice(n-l,c.size,r)))}return a}function ur(e,t=null){let n=e.domSelectionRange(),r=e.state.doc;if(!n.focusNode)return null;let i=e.docView.nearestDesc(n.focusNode),a=i&&i.size==0,o=e.docView.posFromDOM(n.focusNode,n.focusOffset,1);if(o<0)return null;let s=r.resolve(o),c,l;if(It(n)){for(c=o;i&&!i.node;)i=i.parent;let e=i.node;if(i&&e.isAtom&&j.isSelectable(e)&&i.parent&&!(e.isInline&&Pt(n.focusNode,n.focusOffset,i.dom))){let e=i.posBefore;l=new j(o==e?s:r.resolve(e))}}else{if(n instanceof e.dom.ownerDocument.defaultView.Selection&&n.rangeCount>1){let t=o,i=o;for(let r=0;r<n.rangeCount;r++){let a=n.getRangeAt(r);t=Math.min(t,e.docView.posFromDOM(a.startContainer,a.startOffset,1)),i=Math.max(i,e.docView.posFromDOM(a.endContainer,a.endOffset,-1))}if(t<0)return null;[c,o]=i==e.state.selection.anchor?[i,t]:[t,i],s=r.resolve(o)}else c=e.docView.posFromDOM(n.anchorNode,n.anchorOffset,1);if(c<0)return null}let u=r.resolve(c);if(!l){let n=t==`pointer`||e.state.selection.head<s.pos&&!a?1:-1;l=xr(e,u,s,n)}return l}function dr(e){return e.editable?e.hasFocus():Cr(e)&&document.activeElement&&document.activeElement.contains(e.dom)}function fr(e,t=!1){let n=e.state.selection;if(yr(e,n),dr(e)){if(!t&&e.input.mouseDown&&e.input.mouseDown.allowDefault&&L){let t=e.domSelectionRange(),n=e.domObserver.currentSelection;if(t.anchorNode&&n.anchorNode&&kt(t.anchorNode,t.anchorOffset,n.anchorNode,n.anchorOffset)){e.input.mouseDown.delayedSelectionSync=!0,e.domObserver.setCurSelection();return}}if(e.domObserver.disconnectSelection(),e.cursorWrapper)vr(e);else{let{anchor:r,head:i}=n,a,o;pr&&!(n instanceof A)&&(n.$from.parent.inlineContent||(a=mr(e,n.from)),!n.empty&&!n.$from.parent.inlineContent&&(o=mr(e,n.to))),e.docView.setSelection(r,i,e,t),pr&&(a&&gr(a),o&&gr(o)),n.visible?e.dom.classList.remove(`ProseMirror-hideselection`):(e.dom.classList.add(`ProseMirror-hideselection`),`onselectionchange`in document&&_r(e))}e.domObserver.setCurSelection(),e.domObserver.connectSelection()}}var pr=R||L&&Yt<63;function mr(e,t){let{node:n,offset:r}=e.docView.domFromPos(t,0),i=r<n.childNodes.length?n.childNodes[r]:null,a=r?n.childNodes[r-1]:null;if(R&&i&&i.contentEditable==`false`)return hr(i);if((!i||i.contentEditable==`false`)&&(!a||a.contentEditable==`false`)){if(i)return hr(i);if(a)return hr(a)}}function hr(e){return e.contentEditable=`true`,R&&e.draggable&&(e.draggable=!1,e.wasDraggable=!0),e}function gr(e){e.contentEditable=`false`,e.wasDraggable&&=(e.draggable=!0,null)}function _r(e){let t=e.dom.ownerDocument;t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard);let n=e.domSelectionRange(),r=n.anchorNode,i=n.anchorOffset;t.addEventListener(`selectionchange`,e.input.hideSelectionGuard=()=>{(n.anchorNode!=r||n.anchorOffset!=i)&&(t.removeEventListener(`selectionchange`,e.input.hideSelectionGuard),setTimeout(()=>{(!dr(e)||e.state.selection.visible)&&e.dom.classList.remove(`ProseMirror-hideselection`)},20))})}function vr(e){let t=e.domSelection();if(!t)return;let n=e.cursorWrapper.dom,r=n.nodeName==`IMG`;r?t.collapse(n.parentNode,P(n)+1):t.collapse(n,0),!r&&!e.state.selection.visible&&I&&Kt<=11&&(n.disabled=!0,n.disabled=!1)}function yr(e,t){if(t instanceof j){let n=e.docView.descAt(t.from);n!=e.lastSelectedViewDesc&&(br(e),n&&n.selectNode(),e.lastSelectedViewDesc=n)}else br(e)}function br(e){e.lastSelectedViewDesc&&=(e.lastSelectedViewDesc.parent&&e.lastSelectedViewDesc.deselectNode(),void 0)}function xr(e,t,n,r){return e.someProp(`createSelectionBetween`,r=>r(e,t,n))||A.between(t,n,r)}function Sr(e){return e.editable&&!e.hasFocus()?!1:Cr(e)}function Cr(e){let t=e.domSelectionRange();if(!t.anchorNode)return!1;try{return e.dom.contains(t.anchorNode.nodeType==3?t.anchorNode.parentNode:t.anchorNode)&&(e.editable||e.dom.contains(t.focusNode.nodeType==3?t.focusNode.parentNode:t.focusNode))}catch{return!1}}function wr(e){let t=e.docView.domFromPos(e.state.selection.anchor,0),n=e.domSelectionRange();return kt(t.node,t.offset,n.anchorNode,n.anchorOffset)}function Tr(e,t){let{$anchor:n,$head:r}=e.selection,i=t>0?n.max(r):n.min(r),a=i.parent.inlineContent?i.depth?e.doc.resolve(t>0?i.after():i.before()):null:i;return a&&k.findFrom(a,t)}function Er(e,t){return e.dispatch(e.state.tr.setSelection(t).scrollIntoView()),!0}function Dr(e,t,n){let r=e.state.selection;if(r instanceof A){if(n.indexOf(`s`)>-1){let{$head:n}=r,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter;if(!i||i.isText||!i.isLeaf)return!1;let a=e.state.doc.resolve(n.pos+i.nodeSize*(t<0?-1:1));return Er(e,new A(r.$anchor,a))}else if(!r.empty)return!1;else if(e.endOfTextblock(t>0?`forward`:`backward`)){let n=Tr(e.state,t);return n&&n instanceof j?Er(e,n):!1}else if(!(Zt&&n.indexOf(`m`)>-1)){let n=r.$head,i=n.textOffset?null:t<0?n.nodeBefore:n.nodeAfter,a;if(!i||i.isText)return!1;let o=t<0?n.pos-i.nodeSize:n.pos;return i.isAtom||(a=e.docView.descAt(o))&&!a.contentDOM?j.isSelectable(i)?Er(e,new j(t<0?e.state.doc.resolve(n.pos-i.nodeSize):n)):en?Er(e,new A(e.state.doc.resolve(t<0?o:o+i.nodeSize))):!1:!1}}else if(r instanceof j&&r.node.isInline)return Er(e,new A(t>0?r.$to:r.$from));else{let n=Tr(e.state,t);return n?Er(e,n):!1}}function Or(e){return e.nodeType==3?e.nodeValue.length:e.childNodes.length}function kr(e,t){let n=e.pmViewDesc;return n&&n.size==0&&(t<0||e.nextSibling||e.nodeName!=`BR`)}function Ar(e,t){return t<0?jr(e):Mr(e)}function jr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i,a,o=!1;for(qt&&n.nodeType==1&&r<Or(n)&&kr(n.childNodes[r],-1)&&(o=!0);;)if(r>0){if(n.nodeType!=1)break;{let e=n.childNodes[r-1];if(kr(e,-1))i=n,a=--r;else if(e.nodeType==3)n=e,r=n.nodeValue.length;else break}}else if(Nr(n))break;else{let t=n.previousSibling;for(;t&&kr(t,-1);)i=n.parentNode,a=P(t),t=t.previousSibling;if(t)n=t,r=Or(n);else{if(n=n.parentNode,n==e.dom)break;r=0}}o?Ir(e,n,r):i&&Ir(e,i,a)}function Mr(e){let t=e.domSelectionRange(),n=t.focusNode,r=t.focusOffset;if(!n)return;let i=Or(n),a,o;for(;;)if(r<i){if(n.nodeType!=1)break;let e=n.childNodes[r];if(kr(e,1))a=n,o=++r;else break}else if(Nr(n))break;else{let t=n.nextSibling;for(;t&&kr(t,1);)a=t.parentNode,o=P(t)+1,t=t.nextSibling;if(t)n=t,r=0,i=Or(n);else{if(n=n.parentNode,n==e.dom)break;r=i=0}}a&&Ir(e,a,o)}function Nr(e){let t=e.pmViewDesc;return t&&t.node&&t.node.isBlock}function Pr(e,t){for(;e&&t==e.childNodes.length&&!Ft(e);)t=P(e)+1,e=e.parentNode;for(;e&&t<e.childNodes.length;){let n=e.childNodes[t];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=0}}function Fr(e,t){for(;e&&!t&&!Ft(e);)t=P(e),e=e.parentNode;for(;e&&t;){let n=e.childNodes[t-1];if(n.nodeType==3)return n;if(n.nodeType==1&&n.contentEditable==`false`)break;e=n,t=e.childNodes.length}}function Ir(e,t,n){if(t.nodeType!=3){let e,r;(r=Pr(t,n))?(t=r,n=0):(e=Fr(t,n))&&(t=e,n=e.nodeValue.length)}let r=e.domSelection();if(!r)return;if(It(r)){let e=document.createRange();e.setEnd(t,n),e.setStart(t,n),r.removeAllRanges(),r.addRange(e)}else r.extend&&r.extend(t,n);e.domObserver.setCurSelection();let{state:i}=e;setTimeout(()=>{e.state==i&&fr(e)},50)}function Lr(e,t){let n=e.state.doc.resolve(t);if(!(L||Qt)&&n.parent.inlineContent){let r=e.coordsAtPos(t);if(t>n.start()){let n=e.coordsAtPos(t-1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left<r.left?`ltr`:`rtl`}if(t<n.end()){let n=e.coordsAtPos(t+1),i=(n.top+n.bottom)/2;if(i>r.top&&i<r.bottom&&Math.abs(n.left-r.left)>1)return n.left>r.left?`ltr`:`rtl`}}return getComputedStyle(e.dom).direction==`rtl`?`rtl`:`ltr`}function Rr(e,t,n){let r=e.state.selection;if(r instanceof A&&!r.empty||n.indexOf(`s`)>-1||Zt&&n.indexOf(`m`)>-1)return!1;let{$from:i,$to:a}=r;if(!i.parent.inlineContent||e.endOfTextblock(t<0?`up`:`down`)){let n=Tr(e.state,t);if(n&&n instanceof j)return Er(e,n)}if(!i.parent.inlineContent){let n=t<0?i:a,o=r instanceof M?k.near(n,t):k.findFrom(n,t);return o?Er(e,o):!1}return!1}function zr(e,t){if(!(e.state.selection instanceof A))return!0;let{$head:n,$anchor:r,empty:i}=e.state.selection;if(!n.sameParent(r))return!0;if(!i)return!1;if(e.endOfTextblock(t>0?`forward`:`backward`))return!0;let a=!n.textOffset&&(t<0?n.nodeBefore:n.nodeAfter);if(a&&!a.isText){let r=e.state.tr;return t<0?r.delete(n.pos-a.nodeSize,n.pos):r.delete(n.pos,n.pos+a.nodeSize),e.dispatch(r),!0}return!1}function Br(e,t,n){e.domObserver.stop(),t.contentEditable=n,e.domObserver.start()}function Vr(e){if(!R||e.state.selection.$head.parentOffset>0)return!1;let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(t&&t.nodeType==1&&n==0&&t.firstChild&&t.firstChild.contentEditable==`false`){let n=t.firstChild;Br(e,n,`true`),setTimeout(()=>Br(e,n,`false`),20)}return!1}function Hr(e){let t=``;return e.ctrlKey&&(t+=`c`),e.metaKey&&(t+=`m`),e.altKey&&(t+=`a`),e.shiftKey&&(t+=`s`),t}function Ur(e,t){let n=t.keyCode,r=Hr(t);if(n==8||Zt&&n==72&&r==`c`)return zr(e,-1)||Ar(e,-1);if(n==46&&!t.shiftKey||Zt&&n==68&&r==`c`)return zr(e,1)||Ar(e,1);if(n==13||n==27)return!0;if(n==37||Zt&&n==66&&r==`c`){let t=n==37?Lr(e,e.state.selection.from)==`ltr`?-1:1:-1;return Dr(e,t,r)||Ar(e,t)}else if(n==39||Zt&&n==70&&r==`c`){let t=n==39?Lr(e,e.state.selection.from)==`ltr`?1:-1:1;return Dr(e,t,r)||Ar(e,t)}else if(n==38||Zt&&n==80&&r==`c`)return Rr(e,-1,r)||Ar(e,-1);else if(n==40||Zt&&n==78&&r==`c`)return Vr(e)||Rr(e,1,r)||Ar(e,1);else if(r==(Zt?`m`:`c`)&&(n==66||n==73||n==89||n==90))return!0;return!1}function Wr(e,t){e.someProp(`transformCopied`,n=>{t=n(t,e)});let n=[],{content:r,openStart:i,openEnd:a}=t;for(;i>1&&a>1&&r.childCount==1&&r.firstChild.childCount==1;){i--,a--;let e=r.firstChild;n.push(e.type.name,e.attrs==e.type.defaultAttrs?null:e.attrs),r=e.content}let o=e.someProp(`clipboardSerializer`)||m.u.fromSchema(e.state.schema),s=ti(),c=s.createElement(`div`);c.appendChild(o.serializeFragment(r,{document:s}));let l=c.firstChild,u,d=0;for(;l&&l.nodeType==1&&(u=$r[l.nodeName.toLowerCase()]);){for(let e=u.length-1;e>=0;e--){let t=s.createElement(u[e]);for(;c.firstChild;)t.appendChild(c.firstChild);c.appendChild(t),d++}l=c.firstChild}return l&&l.nodeType==1&&l.setAttribute(`data-pm-slice`,`${i} ${a}${d?` -${d}`:``} ${JSON.stringify(n)}`),{dom:c,text:e.someProp(`clipboardTextSerializer`,n=>n(t,e))||t.content.textBetween(0,t.content.size,`
27
+
28
+ `),slice:t}}function Gr(e,t,n,r,i){let a=i.parent.type.spec.code,o,s;if(!n&&!t)return null;let c=!!t&&(r||a||!n);if(c){if(e.someProp(`transformPastedText`,n=>{t=n(t,a||r,e)}),a)return s=new m.v(m.d.from(e.state.schema.text(t.replace(/\r\n?/g,`
29
+ `))),0,0),e.someProp(`transformPasted`,t=>{s=t(s,e,!0)}),s;let n=e.someProp(`clipboardTextParser`,n=>n(t,i,r,e));if(n)s=n;else{let n=i.marks(),{schema:r}=e.state,a=m.u.fromSchema(r);o=document.createElement(`div`),t.split(/(?:\r\n?|\n)+/).forEach(e=>{let t=o.appendChild(document.createElement(`p`));e&&t.appendChild(a.serializeNode(r.text(e,n)))})}}else e.someProp(`transformPastedHTML`,t=>{n=t(n,e)}),o=ii(n),en&&ai(o);let l=o&&o.querySelector(`[data-pm-slice]`),u=l&&/^(\d+) (\d+)(?: -(\d+))? (.*)/.exec(l.getAttribute(`data-pm-slice`)||``);if(u&&u[3])for(let e=+u[3];e>0;e--){let e=o.firstChild;for(;e&&e.nodeType!=1;)e=e.nextSibling;if(!e)break;o=e}if(s||=(e.someProp(`clipboardParser`)||e.someProp(`domParser`)||m.l.fromSchema(e.state.schema)).parseSlice(o,{preserveWhitespace:!!(c||u),context:i,ruleFromNode(e){return e.nodeName==`BR`&&!e.nextSibling&&e.parentNode&&!Kr.test(e.parentNode.nodeName)?{ignore:!0}:null}}),u)s=oi(Qr(s,+u[1],+u[2]),u[4]);else if(s=m.v.maxOpen(qr(s.content,i),!0),s.openStart||s.openEnd){let e=0,t=0;for(let t=s.content.firstChild;e<s.openStart&&!t.type.spec.isolating;e++,t=t.firstChild);for(let e=s.content.lastChild;t<s.openEnd&&!e.type.spec.isolating;t++,e=e.lastChild);s=Qr(s,e,t)}return e.someProp(`transformPasted`,t=>{s=t(s,e,c)}),s}var Kr=/^(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;function qr(e,t){if(e.childCount<2)return e;for(let n=t.depth;n>=0;n--){let r=t.node(n).contentMatchAt(t.index(n)),i,a=[];if(e.forEach(e=>{if(!a)return;let t=r.findWrapping(e.type),n;if(!t)return a=null;if(n=a.length&&i.length&&Yr(t,i,e,a[a.length-1],0))a[a.length-1]=n;else{a.length&&(a[a.length-1]=Xr(a[a.length-1],i.length));let n=Jr(e,t);a.push(n),r=r.matchType(n.type),i=t}}),a)return m.d.from(a)}return e}function Jr(e,t,n=0){for(let r=t.length-1;r>=n;r--)e=t[r].create(null,m.d.from(e));return e}function Yr(e,t,n,r,i){if(i<e.length&&i<t.length&&e[i]==t[i]){let a=Yr(e,t,n,r.lastChild,i+1);if(a)return r.copy(r.content.replaceChild(r.childCount-1,a));if(r.contentMatchAt(r.childCount).matchType(i==e.length-1?n.type:e[i+1]))return r.copy(r.content.append(m.d.from(Jr(n,e,i+1))))}}function Xr(e,t){if(t==0)return e;let n=e.content.replaceChild(e.childCount-1,Xr(e.lastChild,t-1)),r=e.contentMatchAt(e.childCount).fillBefore(m.d.empty,!0);return e.copy(n.append(r))}function Zr(e,t,n,r,i,a){let o=t<0?e.firstChild:e.lastChild,s=o.content;return e.childCount>1&&(a=0),i<r-1&&(s=Zr(s,t,n,r,i+1,a)),i>=n&&(s=t<0?o.contentMatchAt(0).fillBefore(s,a<=i).append(s):s.append(o.contentMatchAt(o.childCount).fillBefore(m.d.empty,!0))),e.replaceChild(t<0?0:e.childCount-1,o.copy(s))}function Qr(e,t,n){return t<e.openStart&&(e=new m.v(Zr(e.content,-1,t,e.openStart,0,e.openEnd),t,e.openEnd)),n<e.openEnd&&(e=new m.v(Zr(e.content,1,n,e.openEnd,0,0),e.openStart,n)),e}var $r={thead:[`table`],tbody:[`table`],tfoot:[`table`],caption:[`table`],colgroup:[`table`],col:[`table`,`colgroup`],tr:[`table`,`tbody`],td:[`table`,`tbody`,`tr`],th:[`table`,`tbody`,`tr`]},ei=null;function ti(){return ei||=document.implementation.createHTMLDocument(`title`)}var ni=null;function ri(e){let t=window.trustedTypes;return t?(ni||=t.defaultPolicy||t.createPolicy(`ProseMirrorClipboard`,{createHTML:e=>e}),ni.createHTML(e)):e}function ii(e){let t=/^(\s*<meta [^>]*>)*/.exec(e);t&&(e=e.slice(t[0].length));let n=ti().createElement(`div`),r=/<([a-z][^>\s]+)/i.exec(e),i;if((i=r&&$r[r[1].toLowerCase()])&&(e=i.map(e=>`<`+e+`>`).join(``)+e+i.map(e=>`</`+e+`>`).reverse().join(``)),n.innerHTML=ri(e),i)for(let e=0;e<i.length;e++)n=n.querySelector(i[e])||n;return n}function ai(e){let t=e.querySelectorAll(L?`span:not([class]):not([style])`:`span.Apple-converted-space`);for(let n=0;n<t.length;n++){let r=t[n];r.childNodes.length==1&&r.textContent==`\xA0`&&r.parentNode&&r.parentNode.replaceChild(e.ownerDocument.createTextNode(` `),r)}}function oi(e,t){if(!e.size)return e;let n=e.content.firstChild.type.schema,r;try{r=JSON.parse(t)}catch{return e}let{content:i,openStart:a,openEnd:o}=e;for(let e=r.length-2;e>=0;e-=2){let t=n.nodes[r[e]];if(!t||t.hasRequiredAttrs())break;i=m.d.from(t.create(r[e+1],i)),a++,o++}return new m.v(i,a,o)}var z={},B={},si={touchstart:!0,touchmove:!0},ci=class{constructor(){this.shiftKey=!1,this.mouseDown=null,this.lastKeyCode=null,this.lastKeyCodeTime=0,this.lastClick={time:0,x:0,y:0,type:``,button:0},this.lastSelectionOrigin=null,this.lastSelectionTime=0,this.lastIOSEnter=0,this.lastIOSEnterFallbackTimeout=-1,this.lastFocus=0,this.lastTouch=0,this.lastChromeDelete=0,this.composing=!1,this.compositionNode=null,this.composingTimeout=-1,this.compositionNodes=[],this.compositionEndedAt=-2e8,this.compositionID=1,this.badSafariComposition=!1,this.compositionPendingChanges=0,this.domChangeCount=0,this.eventHandlers=Object.create(null),this.hideSelectionGuard=null}};function li(e){for(let t in z){let n=z[t];e.dom.addEventListener(t,e.input.eventHandlers[t]=t=>{mi(e,t)&&!pi(e,t)&&(e.editable||!(t.type in B))&&n(e,t)},si[t]?{passive:!0}:void 0)}R&&e.dom.addEventListener(`input`,()=>null),fi(e)}function ui(e,t){e.input.lastSelectionOrigin=t,e.input.lastSelectionTime=Date.now()}function di(e){e.domObserver.stop();for(let t in e.input.eventHandlers)e.dom.removeEventListener(t,e.input.eventHandlers[t]);clearTimeout(e.input.composingTimeout),clearTimeout(e.input.lastIOSEnterFallbackTimeout)}function fi(e){e.someProp(`handleDOMEvents`,t=>{for(let n in t)e.input.eventHandlers[n]||e.dom.addEventListener(n,e.input.eventHandlers[n]=t=>pi(e,t))})}function pi(e,t){return e.someProp(`handleDOMEvents`,n=>{let r=n[t.type];return r?r(e,t)||t.defaultPrevented:!1})}function mi(e,t){if(!t.bubbles)return!0;if(t.defaultPrevented)return!1;for(let n=t.target;n!=e.dom;n=n.parentNode)if(!n||n.nodeType==11||n.pmViewDesc&&n.pmViewDesc.stopEvent(t))return!1;return!0}function hi(e,t){!pi(e,t)&&z[t.type]&&(e.editable||!(t.type in B))&&z[t.type](e,t)}B.keydown=(e,t)=>{let n=t;if(e.input.shiftKey=n.keyCode==16||n.shiftKey,!ki(e,n)&&(e.input.lastKeyCode=n.keyCode,e.input.lastKeyCodeTime=Date.now(),!($t&&L&&n.keyCode==13)))if(n.keyCode!=229&&e.domObserver.forceFlush(),Xt&&n.keyCode==13&&!n.ctrlKey&&!n.altKey&&!n.metaKey){let t=Date.now();e.input.lastIOSEnter=t,e.input.lastIOSEnterFallbackTimeout=setTimeout(()=>{e.input.lastIOSEnter==t&&(e.someProp(`handleKeyDown`,t=>t(e,Lt(13,`Enter`))),e.input.lastIOSEnter=0)},200)}else e.someProp(`handleKeyDown`,t=>t(e,n))||Ur(e,n)?n.preventDefault():ui(e,`key`)},B.keyup=(e,t)=>{t.keyCode==16&&(e.input.shiftKey=!1)},B.keypress=(e,t)=>{let n=t;if(ki(e,n)||!n.charCode||n.ctrlKey&&!n.altKey||Zt&&n.metaKey)return;if(e.someProp(`handleKeyPress`,t=>t(e,n))){n.preventDefault();return}let r=e.state.selection;if(!(r instanceof A)||!r.$from.sameParent(r.$to)){let t=String.fromCharCode(n.charCode),i=()=>e.state.tr.insertText(t).scrollIntoView();!/[\r\n]/.test(t)&&!e.someProp(`handleTextInput`,n=>n(e,r.$from.pos,r.$to.pos,t,i))&&e.dispatch(i()),n.preventDefault()}};function gi(e){return{left:e.clientX,top:e.clientY}}function _i(e,t){let n=t.x-e.clientX,r=t.y-e.clientY;return n*n+r*r<100}function vi(e,t,n,r,i){if(r==-1)return!1;let a=e.state.doc.resolve(r);for(let r=a.depth+1;r>0;r--)if(e.someProp(t,t=>r>a.depth?t(e,n,a.nodeAfter,a.before(r),i,!0):t(e,n,a.node(r),a.before(r),i,!1)))return!0;return!1}function yi(e,t,n){if(e.focused||e.focus(),e.state.selection.eq(t))return;let r=e.state.tr.setSelection(t);n==`pointer`&&r.setMeta(`pointer`,!0),e.dispatch(r)}function bi(e,t){if(t==-1)return!1;let n=e.state.doc.resolve(t),r=n.nodeAfter;return r&&r.isAtom&&j.isSelectable(r)?(yi(e,new j(n),`pointer`),!0):!1}function xi(e,t){if(t==-1)return!1;let n=e.state.selection,r,i;n instanceof j&&(r=n.node);let a=e.state.doc.resolve(t);for(let e=a.depth+1;e>0;e--){let t=e>a.depth?a.nodeAfter:a.node(e);if(j.isSelectable(t)){i=r&&n.$from.depth>0&&e>=n.$from.depth&&a.before(n.$from.depth+1)==n.$from.pos?a.before(n.$from.depth):a.before(e);break}}return i==null?!1:(yi(e,j.create(e.state.doc,i),`pointer`),!0)}function Si(e,t,n,r,i){return vi(e,`handleClickOn`,t,n,r)||e.someProp(`handleClick`,n=>n(e,t,r))||(i?xi(e,n):bi(e,n))}function Ci(e,t,n,r){return vi(e,`handleDoubleClickOn`,t,n,r)||e.someProp(`handleDoubleClick`,n=>n(e,t,r))}function wi(e,t,n,r){return vi(e,`handleTripleClickOn`,t,n,r)||e.someProp(`handleTripleClick`,n=>n(e,t,r))||Ti(e,n,r)}function Ti(e,t,n){if(n.button!=0)return!1;let r=e.state.doc;if(t==-1)return r.inlineContent?(yi(e,A.create(r,0,r.content.size),`pointer`),!0):!1;let i=r.resolve(t);for(let t=i.depth+1;t>0;t--){let n=t>i.depth?i.nodeAfter:i.node(t),a=i.before(t);if(n.inlineContent)yi(e,A.create(r,a+1,a+1+n.content.size),`pointer`);else if(j.isSelectable(n))yi(e,j.create(r,a),`pointer`);else continue;return!0}}function Ei(e){return Ii(e)}var Di=Zt?`metaKey`:`ctrlKey`;z.mousedown=(e,t)=>{let n=t;e.input.shiftKey=n.shiftKey;let r=Ei(e),i=Date.now(),a=`singleClick`;i-e.input.lastClick.time<500&&_i(n,e.input.lastClick)&&!n[Di]&&e.input.lastClick.button==n.button&&(e.input.lastClick.type==`singleClick`?a=`doubleClick`:e.input.lastClick.type==`doubleClick`&&(a=`tripleClick`)),e.input.lastClick={time:i,x:n.clientX,y:n.clientY,type:a,button:n.button};let o=e.posAtCoords(gi(n));o&&(a==`singleClick`?(e.input.mouseDown&&e.input.mouseDown.done(),e.input.mouseDown=new Oi(e,o,n,!!r)):(a==`doubleClick`?Ci:wi)(e,o.pos,o.inside,n)?n.preventDefault():ui(e,`pointer`))};var Oi=class{constructor(e,t,n,r){this.view=e,this.pos=t,this.event=n,this.flushed=r,this.delayedSelectionSync=!1,this.mightDrag=null,this.startDoc=e.state.doc,this.selectNode=!!n[Di],this.allowDefault=n.shiftKey;let i,a;if(t.inside>-1)i=e.state.doc.nodeAt(t.inside),a=t.inside;else{let n=e.state.doc.resolve(t.pos);i=n.parent,a=n.depth?n.before():0}let o=r?null:n.target,s=o?e.docView.nearestDesc(o,!0):null;this.target=s&&s.nodeDOM.nodeType==1?s.nodeDOM:null;let{selection:c}=e.state;(n.button==0&&i.type.spec.draggable&&i.type.spec.selectable!==!1||c instanceof j&&c.from<=a&&c.to>a)&&(this.mightDrag={node:i,pos:a,addAttr:!!(this.target&&!this.target.draggable),setUneditable:!!(this.target&&qt&&!this.target.hasAttribute(`contentEditable`))}),this.target&&this.mightDrag&&(this.mightDrag.addAttr||this.mightDrag.setUneditable)&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&(this.target.draggable=!0),this.mightDrag.setUneditable&&setTimeout(()=>{this.view.input.mouseDown==this&&this.target.setAttribute(`contentEditable`,`false`)},20),this.view.domObserver.start()),e.root.addEventListener(`mouseup`,this.up=this.up.bind(this)),e.root.addEventListener(`mousemove`,this.move=this.move.bind(this)),ui(e,`pointer`)}done(){this.view.root.removeEventListener(`mouseup`,this.up),this.view.root.removeEventListener(`mousemove`,this.move),this.mightDrag&&this.target&&(this.view.domObserver.stop(),this.mightDrag.addAttr&&this.target.removeAttribute(`draggable`),this.mightDrag.setUneditable&&this.target.removeAttribute(`contentEditable`),this.view.domObserver.start()),this.delayedSelectionSync&&setTimeout(()=>fr(this.view)),this.view.input.mouseDown=null}up(e){if(this.done(),!this.view.dom.contains(e.target))return;let t=this.pos;this.view.state.doc!=this.startDoc&&(t=this.view.posAtCoords(gi(e))),this.updateAllowDefault(e),this.allowDefault||!t?ui(this.view,`pointer`):Si(this.view,t.pos,t.inside,e,this.selectNode)?e.preventDefault():e.button==0&&(this.flushed||R&&this.mightDrag&&!this.mightDrag.node.isAtom||L&&!this.view.state.selection.visible&&Math.min(Math.abs(t.pos-this.view.state.selection.from),Math.abs(t.pos-this.view.state.selection.to))<=2)?(yi(this.view,k.near(this.view.state.doc.resolve(t.pos)),`pointer`),e.preventDefault()):ui(this.view,`pointer`)}move(e){this.updateAllowDefault(e),ui(this.view,`pointer`),e.buttons==0&&this.done()}updateAllowDefault(e){!this.allowDefault&&(Math.abs(this.event.x-e.clientX)>4||Math.abs(this.event.y-e.clientY)>4)&&(this.allowDefault=!0)}};z.touchstart=e=>{e.input.lastTouch=Date.now(),Ei(e),ui(e,`pointer`)},z.touchmove=e=>{e.input.lastTouch=Date.now(),ui(e,`pointer`)},z.contextmenu=e=>Ei(e);function ki(e,t){return e.composing?!0:R&&Math.abs(t.timeStamp-e.input.compositionEndedAt)<500?(e.input.compositionEndedAt=-2e8,!0):!1}var Ai=$t?5e3:-1;B.compositionstart=B.compositionupdate=e=>{if(!e.composing){e.domObserver.flush();let{state:t}=e,n=t.selection.$to;if(t.selection instanceof A&&(t.storedMarks||!n.textOffset&&n.parentOffset&&n.nodeBefore.marks.some(e=>e.type.spec.inclusive===!1)||L&&Qt&&ji(e)))e.markCursor=e.state.storedMarks||n.marks(),Ii(e,!0),e.markCursor=null;else if(Ii(e,!t.selection.empty),qt&&t.selection.empty&&n.parentOffset&&!n.textOffset&&n.nodeBefore.marks.length){let t=e.domSelectionRange();for(let n=t.focusNode,r=t.focusOffset;n&&n.nodeType==1&&r!=0;){let t=r<0?n.lastChild:n.childNodes[r-1];if(!t)break;if(t.nodeType==3){let n=e.domSelection();n&&n.collapse(t,t.nodeValue.length);break}else n=t,r=-1}}e.input.composing=!0}Mi(e,Ai)};function ji(e){let{focusNode:t,focusOffset:n}=e.domSelectionRange();if(!t||t.nodeType!=1||n>=t.childNodes.length)return!1;let r=t.childNodes[n];return r.nodeType==1&&r.contentEditable==`false`}B.compositionend=(e,t)=>{e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=t.timeStamp,e.input.compositionPendingChanges=e.domObserver.pendingRecords().length?e.input.compositionID:0,e.input.compositionNode=null,e.input.badSafariComposition?e.domObserver.forceFlush():e.input.compositionPendingChanges&&Promise.resolve().then(()=>e.domObserver.flush()),e.input.compositionID++,Mi(e,20))};function Mi(e,t){clearTimeout(e.input.composingTimeout),t>-1&&(e.input.composingTimeout=setTimeout(()=>Ii(e),t))}function Ni(e){for(e.composing&&(e.input.composing=!1,e.input.compositionEndedAt=Fi());e.input.compositionNodes.length>0;)e.input.compositionNodes.pop().markParentsDirty()}function Pi(e){let t=e.domSelectionRange();if(!t.focusNode)return null;let n=Mt(t.focusNode,t.focusOffset),r=Nt(t.focusNode,t.focusOffset);if(n&&r&&n!=r){let t=r.pmViewDesc,i=e.domObserver.lastChangedTextNode;if(n==i||r==i)return i;if(!t||!t.isText(r.nodeValue))return r;if(e.input.compositionNode==r){let e=n.pmViewDesc;if(!(!e||!e.isText(n.nodeValue)))return r}}return n||r}function Fi(){let e=document.createEvent(`Event`);return e.initEvent(`event`,!0,!0),e.timeStamp}function Ii(e,t=!1){if(!($t&&e.domObserver.flushingSoon>=0)){if(e.domObserver.forceFlush(),Ni(e),t||e.docView&&e.docView.dirty){let n=ur(e),r=e.state.selection;return n&&!n.eq(r)?e.dispatch(e.state.tr.setSelection(n)):(e.markCursor||t)&&!r.$from.node(r.$from.sharedDepth(r.to)).inlineContent?e.dispatch(e.state.tr.deleteSelection()):e.updateState(e.state),!0}return!1}}function Li(e,t){if(!e.dom.parentNode)return;let n=e.dom.parentNode.appendChild(document.createElement(`div`));n.appendChild(t),n.style.cssText=`position: fixed; left: -10000px; top: 10px`;let r=getSelection(),i=document.createRange();i.selectNodeContents(t),e.dom.blur(),r.removeAllRanges(),r.addRange(i),setTimeout(()=>{n.parentNode&&n.parentNode.removeChild(n),e.focus()},50)}var Ri=I&&Kt<15||Xt&&tn<604;z.copy=B.cut=(e,t)=>{let n=t,r=e.state.selection,i=n.type==`cut`;if(r.empty)return;let a=Ri?null:n.clipboardData,{dom:o,text:s}=Wr(e,r.content());a?(n.preventDefault(),a.clearData(),a.setData(`text/html`,o.innerHTML),a.setData(`text/plain`,s)):Li(e,o),i&&e.dispatch(e.state.tr.deleteSelection().scrollIntoView().setMeta(`uiEvent`,`cut`))};function zi(e){return e.openStart==0&&e.openEnd==0&&e.content.childCount==1?e.content.firstChild:null}function Bi(e,t){if(!e.dom.parentNode)return;let n=e.input.shiftKey||e.state.selection.$from.parent.type.spec.code,r=e.dom.parentNode.appendChild(document.createElement(n?`textarea`:`div`));n||(r.contentEditable=`true`),r.style.cssText=`position: fixed; left: -10000px; top: 10px`,r.focus();let i=e.input.shiftKey&&e.input.lastKeyCode!=45;setTimeout(()=>{e.focus(),r.parentNode&&r.parentNode.removeChild(r),n?Vi(e,r.value,null,i,t):Vi(e,r.textContent,r.innerHTML,i,t)},50)}function Vi(e,t,n,r,i){let a=Gr(e,t,n,r,e.state.selection.$from);if(e.someProp(`handlePaste`,t=>t(e,i,a||m.v.empty)))return!0;if(!a)return!1;let o=zi(a),s=o?e.state.tr.replaceSelectionWith(o,r):e.state.tr.replaceSelection(a);return e.dispatch(s.scrollIntoView().setMeta(`paste`,!0).setMeta(`uiEvent`,`paste`)),!0}function Hi(e){let t=e.getData(`text/plain`)||e.getData(`Text`);if(t)return t;let n=e.getData(`text/uri-list`);return n?n.replace(/\r?\n/g,` `):``}B.paste=(e,t)=>{let n=t;if(e.composing&&!$t)return;let r=Ri?null:n.clipboardData,i=e.input.shiftKey&&e.input.lastKeyCode!=45;r&&Vi(e,Hi(r),r.getData(`text/html`),i,n)?n.preventDefault():Bi(e,n)};var Ui=class{constructor(e,t,n){this.slice=e,this.move=t,this.node=n}},Wi=Zt?`altKey`:`ctrlKey`;function Gi(e,t){return e.someProp(`dragCopies`,e=>!e(t))??!t[Wi]}z.dragstart=(e,t)=>{let n=t,r=e.input.mouseDown;if(r&&r.done(),!n.dataTransfer)return;let i=e.state.selection,a=i.empty?null:e.posAtCoords(gi(n)),o;if(!(a&&a.pos>=i.from&&a.pos<=(i instanceof j?i.to-1:i.to))){if(r&&r.mightDrag)o=j.create(e.state.doc,r.mightDrag.pos);else if(n.target&&n.target.nodeType==1){let t=e.docView.nearestDesc(n.target,!0);t&&t.node.type.spec.draggable&&t!=e.docView&&(o=j.create(e.state.doc,t.posBefore))}}let{dom:s,text:c,slice:l}=Wr(e,(o||e.state.selection).content());(!n.dataTransfer.files.length||!L||Yt>120)&&n.dataTransfer.clearData(),n.dataTransfer.setData(Ri?`Text`:`text/html`,s.innerHTML),n.dataTransfer.effectAllowed=`copyMove`,Ri||n.dataTransfer.setData(`text/plain`,c),e.dragging=new Ui(l,Gi(e,n),o)},z.dragend=e=>{let t=e.dragging;window.setTimeout(()=>{e.dragging==t&&(e.dragging=null)},50)},B.dragover=B.dragenter=(e,t)=>t.preventDefault(),B.drop=(e,t)=>{try{Ki(e,t,e.dragging)}finally{e.dragging=null}};function Ki(e,t,n){if(!t.dataTransfer)return;let r=e.posAtCoords(gi(t));if(!r)return;let i=e.state.doc.resolve(r.pos),a=n&&n.slice;a?e.someProp(`transformPasted`,t=>{a=t(a,e,!1)}):a=Gr(e,Hi(t.dataTransfer),Ri?null:t.dataTransfer.getData(`text/html`),!1,i);let o=!!(n&&Gi(e,t));if(e.someProp(`handleDrop`,n=>n(e,t,a||m.v.empty,o))){t.preventDefault();return}if(!a)return;t.preventDefault();let s=a?ze(e.state.doc,i.pos,a):i.pos;s??=i.pos;let c=e.state.tr;if(o){let{node:e}=n;e?e.replace(c):c.deleteSelection()}let l=c.mapping.map(s),u=a.openStart==0&&a.openEnd==0&&a.content.childCount==1,d=c.doc;if(u?c.replaceRangeWith(l,l,a.content.firstChild):c.replaceRange(l,l,a),c.doc.eq(d))return;let f=c.doc.resolve(l);if(u&&j.isSelectable(a.content.firstChild)&&f.nodeAfter&&f.nodeAfter.sameMarkup(a.content.firstChild))c.setSelection(new j(f));else{let t=c.mapping.map(s);c.mapping.maps[c.mapping.maps.length-1].forEach((e,n,r,i)=>t=i),c.setSelection(xr(e,f,c.doc.resolve(t)))}e.focus(),e.dispatch(c.setMeta(`uiEvent`,`drop`))}z.focus=e=>{e.input.lastFocus=Date.now(),e.focused||(e.domObserver.stop(),e.dom.classList.add(`ProseMirror-focused`),e.domObserver.start(),e.focused=!0,setTimeout(()=>{e.docView&&e.hasFocus()&&!e.domObserver.currentSelection.eq(e.domSelectionRange())&&fr(e)},20))},z.blur=(e,t)=>{let n=t;e.focused&&=(e.domObserver.stop(),e.dom.classList.remove(`ProseMirror-focused`),e.domObserver.start(),n.relatedTarget&&e.dom.contains(n.relatedTarget)&&e.domObserver.currentSelection.clear(),!1)},z.beforeinput=(e,t)=>{if(L&&$t&&t.inputType==`deleteContentBackward`){e.domObserver.flushSoon();let{domChangeCount:t}=e.input;setTimeout(()=>{if(e.input.domChangeCount!=t||(e.dom.blur(),e.focus(),e.someProp(`handleKeyDown`,t=>t(e,Lt(8,`Backspace`)))))return;let{$cursor:n}=e.state.selection;n&&n.pos>0&&e.dispatch(e.state.tr.delete(n.pos-1,n.pos).scrollIntoView())},50)}};for(let e in B)z[e]=B[e];function qi(e,t){if(e==t)return!0;for(let n in e)if(e[n]!==t[n])return!1;for(let n in t)if(!(n in e))return!1;return!0}var Ji=class e{constructor(e,t){this.toDOM=e,this.spec=t||Qi,this.side=this.spec.side||0}map(e,t,n,r){let{pos:i,deleted:a}=e.mapResult(t.from+r,this.side<0?-1:1);return a?null:new V(i-n,i-n,this)}valid(){return!0}eq(t){return this==t||t instanceof e&&(this.spec.key&&this.spec.key==t.spec.key||this.toDOM==t.toDOM&&qi(this.spec,t.spec))}destroy(e){this.spec.destroy&&this.spec.destroy(e)}},Yi=class e{constructor(e,t){this.attrs=e,this.spec=t||Qi}map(e,t,n,r){let i=e.map(t.from+r,this.spec.inclusiveStart?-1:1)-n,a=e.map(t.to+r,this.spec.inclusiveEnd?1:-1)-n;return i>=a?null:new V(i,a,this)}valid(e,t){return t.from<t.to}eq(t){return this==t||t instanceof e&&qi(this.attrs,t.attrs)&&qi(this.spec,t.spec)}static is(t){return t.type instanceof e}destroy(){}},Xi=class e{constructor(e,t){this.attrs=e,this.spec=t||Qi}map(e,t,n,r){let i=e.mapResult(t.from+r,1);if(i.deleted)return null;let a=e.mapResult(t.to+r,-1);return a.deleted||a.pos<=i.pos?null:new V(i.pos-n,a.pos-n,this)}valid(e,t){let{index:n,offset:r}=e.content.findIndex(t.from),i;return r==t.from&&!(i=e.child(n)).isText&&r+i.nodeSize==t.to}eq(t){return this==t||t instanceof e&&qi(this.attrs,t.attrs)&&qi(this.spec,t.spec)}destroy(){}},V=class e{constructor(e,t,n){this.from=e,this.to=t,this.type=n}copy(t,n){return new e(t,n,this.type)}eq(e,t=0){return this.type.eq(e.type)&&this.from+t==e.from&&this.to+t==e.to}map(e,t,n){return this.type.map(e,this,t,n)}static widget(t,n,r){return new e(t,t,new Ji(n,r))}static inline(t,n,r,i){return new e(t,n,new Yi(r,i))}static node(t,n,r,i){return new e(t,n,new Xi(r,i))}get spec(){return this.type.spec}get inline(){return this.type instanceof Yi}get widget(){return this.type instanceof Ji}},Zi=[],Qi={},H=class e{constructor(e,t){this.local=e.length?e:Zi,this.children=t.length?t:Zi}static create(e,t){return t.length?aa(t,e,0,Qi):U}find(e,t,n){let r=[];return this.findInner(e??0,t??1e9,r,0,n),r}findInner(e,t,n,r,i){for(let a=0;a<this.local.length;a++){let o=this.local[a];o.from<=t&&o.to>=e&&(!i||i(o.spec))&&n.push(o.copy(o.from+r,o.to+r))}for(let a=0;a<this.children.length;a+=3)if(this.children[a]<t&&this.children[a+1]>e){let o=this.children[a]+1;this.children[a+2].findInner(e-o,t-o,n,r+o,i)}}map(e,t,n){return this==U||e.maps.length==0?this:this.mapInner(e,t,0,0,n||Qi)}mapInner(t,n,r,i,a){let o;for(let e=0;e<this.local.length;e++){let s=this.local[e].map(t,r,i);s&&s.type.valid(n,s)?(o||=[]).push(s):a.onRemove&&a.onRemove(this.local[e].spec)}return this.children.length?ea(this.children,o||[],t,n,r,i,a):o?new e(o.sort(oa),Zi):U}add(t,n){return n.length?this==U?e.create(t,n):this.addInner(t,n,0):this}addInner(t,n,r){let i,a=0;t.forEach((e,t)=>{let o=t+r,s;if(s=ra(n,e,o)){for(i||=this.children.slice();a<i.length&&i[a]<t;)a+=3;i[a]==t?i[a+2]=i[a+2].addInner(e,s,o+1):i.splice(a,0,t,t+e.nodeSize,aa(s,e,o+1,Qi)),a+=3}});let o=ta(a?ia(n):n,-r);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||o.splice(e--,1);return new e(o.length?this.local.concat(o).sort(oa):this.local,i||this.children)}remove(e){return e.length==0||this==U?this:this.removeInner(e,0)}removeInner(t,n){let r=this.children,i=this.local;for(let e=0;e<r.length;e+=3){let i,a=r[e]+n,o=r[e+1]+n;for(let e=0,n;e<t.length;e++)(n=t[e])&&n.from>a&&n.to<o&&(t[e]=null,(i||=[]).push(n));if(!i)continue;r==this.children&&(r=this.children.slice());let s=r[e+2].removeInner(i,a+1);s==U?(r.splice(e,3),e-=3):r[e+2]=s}if(i.length){for(let e=0,r;e<t.length;e++)if(r=t[e])for(let e=0;e<i.length;e++)i[e].eq(r,n)&&(i==this.local&&(i=this.local.slice()),i.splice(e--,1))}return r==this.children&&i==this.local?this:i.length||r.length?new e(i,r):U}forChild(t,n){if(this==U)return this;if(n.isLeaf)return e.empty;let r,i;for(let e=0;e<this.children.length;e+=3)if(this.children[e]>=t){this.children[e]==t&&(r=this.children[e+2]);break}let a=t+1,o=a+n.content.size;for(let e=0;e<this.local.length;e++){let t=this.local[e];if(t.from<o&&t.to>a&&t.type instanceof Yi){let e=Math.max(a,t.from)-a,n=Math.min(o,t.to)-a;e<n&&(i||=[]).push(t.copy(e,n))}}if(i){let t=new e(i.sort(oa),Zi);return r?new $i([t,r]):t}return r||U}eq(t){if(this==t)return!0;if(!(t instanceof e)||this.local.length!=t.local.length||this.children.length!=t.children.length)return!1;for(let e=0;e<this.local.length;e++)if(!this.local[e].eq(t.local[e]))return!1;for(let e=0;e<this.children.length;e+=3)if(this.children[e]!=t.children[e]||this.children[e+1]!=t.children[e+1]||!this.children[e+2].eq(t.children[e+2]))return!1;return!0}locals(e){return sa(this.localsInner(e))}localsInner(e){if(this==U)return Zi;if(e.inlineContent||!this.local.some(Yi.is))return this.local;let t=[];for(let e=0;e<this.local.length;e++)this.local[e].type instanceof Yi||t.push(this.local[e]);return t}forEachSet(e){e(this)}};H.empty=new H([],[]),H.removeOverlap=sa;var U=H.empty,$i=class e{constructor(e){this.members=e}map(t,n){let r=this.members.map(e=>e.map(t,n,Qi));return e.from(r)}forChild(t,n){if(n.isLeaf)return H.empty;let r=[];for(let i=0;i<this.members.length;i++){let a=this.members[i].forChild(t,n);a!=U&&(a instanceof e?r=r.concat(a.members):r.push(a))}return e.from(r)}eq(t){if(!(t instanceof e)||t.members.length!=this.members.length)return!1;for(let e=0;e<this.members.length;e++)if(!this.members[e].eq(t.members[e]))return!1;return!0}locals(e){let t,n=!0;for(let r=0;r<this.members.length;r++){let i=this.members[r].localsInner(e);if(i.length)if(!t)t=i;else{n&&=(t=t.slice(),!1);for(let e=0;e<i.length;e++)t.push(i[e])}}return t?sa(n?t:t.sort(oa)):Zi}static from(t){switch(t.length){case 0:return U;case 1:return t[0];default:return new e(t.every(e=>e instanceof H)?t:t.reduce((e,t)=>e.concat(t instanceof H?t:t.members),[]))}}forEachSet(e){for(let t=0;t<this.members.length;t++)this.members[t].forEachSet(e)}};function ea(e,t,n,r,i,a,o){let s=e.slice();for(let e=0,t=a;e<n.maps.length;e++){let r=0;n.maps[e].forEach((e,n,i,a)=>{let o=a-i-(n-e);for(let i=0;i<s.length;i+=3){let a=s[i+1];if(a<0||e>a+t-r)continue;let c=s[i]+t-r;n>=c?s[i+1]=e<=c?-2:-1:e>=t&&o&&(s[i]+=o,s[i+1]+=o)}r+=o}),t=n.maps[e].map(t,-1)}let c=!1;for(let t=0;t<s.length;t+=3)if(s[t+1]<0){if(s[t+1]==-2){c=!0,s[t+1]=-1;continue}let l=n.map(e[t]+a),u=l-i;if(u<0||u>=r.content.size){c=!0;continue}let d=n.map(e[t+1]+a,-1)-i,{index:f,offset:p}=r.content.findIndex(u),m=r.maybeChild(f);if(m&&p==u&&p+m.nodeSize==d){let r=s[t+2].mapInner(n,m,l+1,e[t]+a+1,o);r==U?(s[t+1]=-2,c=!0):(s[t]=u,s[t+1]=d,s[t+2]=r)}else c=!0}if(c){let c=aa(na(s,e,t,n,i,a,o),r,0,o);t=c.local;for(let e=0;e<s.length;e+=3)s[e+1]<0&&(s.splice(e,3),e-=3);for(let e=0,t=0;e<c.children.length;e+=3){let n=c.children[e];for(;t<s.length&&s[t]<n;)t+=3;s.splice(t,0,c.children[e],c.children[e+1],c.children[e+2])}}return new H(t.sort(oa),s)}function ta(e,t){if(!t||!e.length)return e;let n=[];for(let r=0;r<e.length;r++){let i=e[r];n.push(new V(i.from+t,i.to+t,i.type))}return n}function na(e,t,n,r,i,a,o){function s(e,t){for(let a=0;a<e.local.length;a++){let s=e.local[a].map(r,i,t);s?n.push(s):o.onRemove&&o.onRemove(e.local[a].spec)}for(let n=0;n<e.children.length;n+=3)s(e.children[n+2],e.children[n]+t+1)}for(let n=0;n<e.length;n+=3)e[n+1]==-1&&s(e[n+2],t[n]+a+1);return n}function ra(e,t,n){if(t.isLeaf)return null;let r=n+t.nodeSize,i=null;for(let t=0,a;t<e.length;t++)(a=e[t])&&a.from>n&&a.to<r&&((i||=[]).push(a),e[t]=null);return i}function ia(e){let t=[];for(let n=0;n<e.length;n++)e[n]!=null&&t.push(e[n]);return t}function aa(e,t,n,r){let i=[],a=!1;t.forEach((t,o)=>{let s=ra(e,t,o+n);if(s){a=!0;let e=aa(s,t,n+o+1,r);e!=U&&i.push(o,o+t.nodeSize,e)}});let o=ta(a?ia(e):e,-n).sort(oa);for(let e=0;e<o.length;e++)o[e].type.valid(t,o[e])||(r.onRemove&&r.onRemove(o[e].spec),o.splice(e--,1));return o.length||i.length?new H(o,i):U}function oa(e,t){return e.from-t.from||e.to-t.to}function sa(e){let t=e;for(let n=0;n<t.length-1;n++){let r=t[n];if(r.from!=r.to)for(let i=n+1;i<t.length;i++){let a=t[i];if(a.from==r.from){a.to!=r.to&&(t==e&&(t=e.slice()),t[i]=a.copy(a.from,r.to),ca(t,i+1,a.copy(r.to,a.to)));continue}else{a.from<r.to&&(t==e&&(t=e.slice()),t[n]=r.copy(r.from,a.from),ca(t,i,r.copy(a.from,r.to)));break}}}return t}function ca(e,t,n){for(;t<e.length&&oa(n,e[t])>0;)t++;e.splice(t,0,n)}function la(e){let t=[];return e.someProp(`decorations`,n=>{let r=n(e.state);r&&r!=U&&t.push(r)}),e.cursorWrapper&&t.push(H.create(e.state.doc,[e.cursorWrapper.deco])),$i.from(t)}var ua={childList:!0,characterData:!0,characterDataOldValue:!0,attributes:!0,attributeOldValue:!0,subtree:!0},da=I&&Kt<=11,fa=class{constructor(){this.anchorNode=null,this.anchorOffset=0,this.focusNode=null,this.focusOffset=0}set(e){this.anchorNode=e.anchorNode,this.anchorOffset=e.anchorOffset,this.focusNode=e.focusNode,this.focusOffset=e.focusOffset}clear(){this.anchorNode=this.focusNode=null}eq(e){return e.anchorNode==this.anchorNode&&e.anchorOffset==this.anchorOffset&&e.focusNode==this.focusNode&&e.focusOffset==this.focusOffset}},pa=class{constructor(e,t){this.view=e,this.handleDOMChange=t,this.queue=[],this.flushingSoon=-1,this.observer=null,this.currentSelection=new fa,this.onCharData=null,this.suppressingSelectionUpdates=!1,this.lastChangedTextNode=null,this.observer=window.MutationObserver&&new window.MutationObserver(t=>{for(let e=0;e<t.length;e++)this.queue.push(t[e]);I&&Kt<=11&&t.some(e=>e.type==`childList`&&e.removedNodes.length||e.type==`characterData`&&e.oldValue.length>e.target.nodeValue.length)?this.flushSoon():R&&e.composing&&t.some(e=>e.type==`childList`&&e.target.nodeName==`TR`)?(e.input.badSafariComposition=!0,this.flushSoon()):this.flush()}),da&&(this.onCharData=e=>{this.queue.push({target:e.target,type:`characterData`,oldValue:e.prevValue}),this.flushSoon()}),this.onSelectionChange=this.onSelectionChange.bind(this)}flushSoon(){this.flushingSoon<0&&(this.flushingSoon=window.setTimeout(()=>{this.flushingSoon=-1,this.flush()},20))}forceFlush(){this.flushingSoon>-1&&(window.clearTimeout(this.flushingSoon),this.flushingSoon=-1,this.flush())}start(){this.observer&&(this.observer.takeRecords(),this.observer.observe(this.view.dom,ua)),this.onCharData&&this.view.dom.addEventListener(`DOMCharacterDataModified`,this.onCharData),this.connectSelection()}stop(){if(this.observer){let e=this.observer.takeRecords();if(e.length){for(let t=0;t<e.length;t++)this.queue.push(e[t]);window.setTimeout(()=>this.flush(),20)}this.observer.disconnect()}this.onCharData&&this.view.dom.removeEventListener(`DOMCharacterDataModified`,this.onCharData),this.disconnectSelection()}connectSelection(){this.view.dom.ownerDocument.addEventListener(`selectionchange`,this.onSelectionChange)}disconnectSelection(){this.view.dom.ownerDocument.removeEventListener(`selectionchange`,this.onSelectionChange)}suppressSelectionUpdates(){this.suppressingSelectionUpdates=!0,setTimeout(()=>this.suppressingSelectionUpdates=!1,50)}onSelectionChange(){if(Sr(this.view)){if(this.suppressingSelectionUpdates)return fr(this.view);if(I&&Kt<=11&&!this.view.state.selection.empty){let e=this.view.domSelectionRange();if(e.focusNode&&kt(e.focusNode,e.focusOffset,e.anchorNode,e.anchorOffset))return this.flushSoon()}this.flush()}}setCurSelection(){this.currentSelection.set(this.view.domSelectionRange())}ignoreSelectionChange(e){if(!e.focusNode)return!0;let t=new Set,n;for(let n=e.focusNode;n;n=Tt(n))t.add(n);for(let r=e.anchorNode;r;r=Tt(r))if(t.has(r)){n=r;break}let r=n&&this.view.docView.nearestDesc(n);if(r&&r.ignoreMutation({type:`selection`,target:n.nodeType==3?n.parentNode:n}))return this.setCurSelection(),!0}pendingRecords(){if(this.observer)for(let e of this.observer.takeRecords())this.queue.push(e);return this.queue}flush(){let{view:e}=this;if(!e.docView||this.flushingSoon>-1)return;let t=this.pendingRecords();t.length&&(this.queue=[]);let n=e.domSelectionRange(),r=!this.suppressingSelectionUpdates&&!this.currentSelection.eq(n)&&Sr(e)&&!this.ignoreSelectionChange(n),i=-1,a=-1,o=!1,s=[];if(e.editable)for(let e=0;e<t.length;e++){let n=this.registerMutation(t[e],s);n&&(i=i<0?n.from:Math.min(n.from,i),a=a<0?n.to:Math.max(n.to,a),n.typeOver&&(o=!0))}if(s.some(e=>e.nodeName==`BR`)&&(e.input.lastKeyCode==8||e.input.lastKeyCode==46)){for(let e of s)if(e.nodeName==`BR`&&e.parentNode){let t=e.nextSibling;t&&t.nodeType==1&&t.contentEditable==`false`&&e.parentNode.removeChild(e)}}else if(qt&&s.length){let t=s.filter(e=>e.nodeName==`BR`);if(t.length==2){let[e,n]=t;e.parentNode&&e.parentNode.parentNode==n.parentNode?n.remove():e.remove()}else{let{focusNode:n}=this.currentSelection;for(let r of t){let t=r.parentNode;t&&t.nodeName==`LI`&&(!n||ya(e,n)!=t)&&r.remove()}}}let c=null;i<0&&r&&e.input.lastFocus>Date.now()-200&&Math.max(e.input.lastTouch,e.input.lastClick.time)<Date.now()-300&&It(n)&&(c=ur(e))&&c.eq(k.near(e.state.doc.resolve(0),1))?(e.input.lastFocus=0,fr(e),this.currentSelection.set(n),e.scrollToSelection()):(i>-1||r)&&(i>-1&&(e.docView.markDirty(i,a),ga(e)),e.input.badSafariComposition&&(e.input.badSafariComposition=!1,ba(e,s)),this.handleDOMChange(i,a,o,s),e.docView&&e.docView.dirty?e.updateState(e.state):this.currentSelection.eq(n)||fr(e),this.currentSelection.set(n))}registerMutation(e,t){if(t.indexOf(e.target)>-1)return null;let n=this.view.docView.nearestDesc(e.target);if(e.type==`attributes`&&(n==this.view.docView||e.attributeName==`contenteditable`||e.attributeName==`style`&&!e.oldValue&&!e.target.getAttribute(`style`))||!n||n.ignoreMutation(e))return null;if(e.type==`childList`){for(let n=0;n<e.addedNodes.length;n++){let r=e.addedNodes[n];t.push(r),r.nodeType==3&&(this.lastChangedTextNode=r)}if(n.contentDOM&&n.contentDOM!=n.dom&&!n.contentDOM.contains(e.target))return{from:n.posBefore,to:n.posAfter};let r=e.previousSibling,i=e.nextSibling;if(I&&Kt<=11&&e.addedNodes.length)for(let t=0;t<e.addedNodes.length;t++){let{previousSibling:n,nextSibling:a}=e.addedNodes[t];(!n||Array.prototype.indexOf.call(e.addedNodes,n)<0)&&(r=n),(!a||Array.prototype.indexOf.call(e.addedNodes,a)<0)&&(i=a)}let a=r&&r.parentNode==e.target?P(r)+1:0,o=n.localPosFromDOM(e.target,a,-1),s=i&&i.parentNode==e.target?P(i):e.target.childNodes.length;return{from:o,to:n.localPosFromDOM(e.target,s,1)}}else if(e.type==`attributes`)return{from:n.posAtStart-n.border,to:n.posAtEnd+n.border};else return this.lastChangedTextNode=e.target,{from:n.posAtStart,to:n.posAtEnd,typeOver:e.target.nodeValue==e.oldValue}}},ma=new WeakMap,ha=!1;function ga(e){if(!ma.has(e)&&(ma.set(e,null),[`normal`,`nowrap`,`pre-line`].indexOf(getComputedStyle(e.dom).whiteSpace)!==-1)){if(e.requiresGeckoHackNode=qt,ha)return;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.`),ha=!0}}function _a(e,t){let n=t.startContainer,r=t.startOffset,i=t.endContainer,a=t.endOffset,o=e.domAtPos(e.state.selection.anchor);return kt(o.node,o.offset,i,a)&&([n,r,i,a]=[i,a,n,r]),{anchorNode:n,anchorOffset:r,focusNode:i,focusOffset:a}}function va(e,t){if(t.getComposedRanges){let n=t.getComposedRanges(e.root)[0];if(n)return _a(e,n)}let n;function r(e){e.preventDefault(),e.stopImmediatePropagation(),n=e.getTargetRanges()[0]}return e.dom.addEventListener(`beforeinput`,r,!0),document.execCommand(`indent`),e.dom.removeEventListener(`beforeinput`,r,!0),n?_a(e,n):null}function ya(e,t){for(let n=t.parentNode;n&&n!=e.dom;n=n.parentNode){let t=e.docView.nearestDesc(n,!0);if(t&&t.node.isBlock)return n}return null}function ba(e,t){let{focusNode:n,focusOffset:r}=e.domSelectionRange();for(let i of t)if(i.parentNode?.nodeName==`TR`){let t=i.nextSibling;for(;t&&t.nodeName!=`TD`&&t.nodeName!=`TH`;)t=t.nextSibling;if(t){let a=t;for(;;){let e=a.firstChild;if(!e||e.nodeType!=1||e.contentEditable==`false`||/^(BR|IMG)$/.test(e.nodeName))break;a=e}a.insertBefore(i,a.firstChild),n==i&&e.domSelection().collapse(i,r)}else i.parentNode.removeChild(i)}}function xa(e,t,n){let{node:r,fromOffset:i,toOffset:a,from:o,to:s}=e.docView.parseRange(t,n),c=e.domSelectionRange(),l,u=c.anchorNode;if(u&&e.dom.contains(u.nodeType==1?u:u.parentNode)&&(l=[{node:u,offset:c.anchorOffset}],It(c)||l.push({node:c.focusNode,offset:c.focusOffset})),L&&e.input.lastKeyCode===8)for(let e=a;e>i;e--){let t=r.childNodes[e-1],n=t.pmViewDesc;if(t.nodeName==`BR`&&!n){a=e;break}if(!n||n.size)break}let d=e.state.doc,f=e.someProp(`domParser`)||m.l.fromSchema(e.state.schema),p=d.resolve(o),h=null,g=f.parse(r,{topNode:p.parent,topMatch:p.parent.contentMatchAt(p.index()),topOpen:!0,from:i,to:a,preserveWhitespace:p.parent.type.whitespace==`pre`?`full`:!0,findPositions:l,ruleFromNode:Sa,context:p});if(l&&l[0].pos!=null){let e=l[0].pos,t=l[1]&&l[1].pos;t??=e,h={anchor:e+o,head:t+o}}return{doc:g,sel:h,from:o,to:s}}function Sa(e){let t=e.pmViewDesc;if(t)return t.parseRule();if(e.nodeName==`BR`&&e.parentNode){if(R&&/^(ul|ol)$/i.test(e.parentNode.nodeName)){let e=document.createElement(`div`);return e.appendChild(document.createElement(`li`)),{skip:e}}else if(e.parentNode.lastChild==e||R&&/^(tr|table)$/i.test(e.parentNode.nodeName))return{ignore:!0}}else if(e.nodeName==`IMG`&&e.getAttribute(`mark-placeholder`))return{ignore:!0};return null}var Ca=/^(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;function wa(e,t,n,r,i){let a=e.input.compositionPendingChanges||(e.composing?e.input.compositionID:0);if(e.input.compositionPendingChanges=0,t<0){let t=e.input.lastSelectionTime>Date.now()-50?e.input.lastSelectionOrigin:null,n=ur(e,t);if(n&&!e.state.selection.eq(n)){if(L&&$t&&e.input.lastKeyCode===13&&Date.now()-100<e.input.lastKeyCodeTime&&e.someProp(`handleKeyDown`,t=>t(e,Lt(13,`Enter`))))return;let r=e.state.tr.setSelection(n);t==`pointer`?r.setMeta(`pointer`,!0):t==`key`&&r.scrollIntoView(),a&&r.setMeta(`composition`,a),e.dispatch(r)}return}let o=e.state.doc.resolve(t),s=o.sharedDepth(n);t=o.before(s+1),n=e.state.doc.resolve(n).after(s+1);let c=e.state.selection,l=xa(e,t,n),u=e.state.doc,d=u.slice(l.from,l.to),f,p;e.input.lastKeyCode===8&&Date.now()-100<e.input.lastKeyCodeTime?(f=e.state.selection.to,p=`end`):(f=e.state.selection.from,p=`start`),e.input.lastKeyCode=null;let m=ka(d.content,l.doc.content,l.from,f,p);if(m&&e.input.domChangeCount++,(Xt&&e.input.lastIOSEnter>Date.now()-225||$t)&&i.some(e=>e.nodeType==1&&!Ca.test(e.nodeName))&&(!m||m.endA>=m.endB)&&e.someProp(`handleKeyDown`,t=>t(e,Lt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(!m)if(r&&c instanceof A&&!c.empty&&c.$head.sameParent(c.$anchor)&&!e.composing&&!(l.sel&&l.sel.anchor!=l.sel.head))m={start:c.from,endA:c.to,endB:c.to};else{if(l.sel){let t=Ta(e,e.state.doc,l.sel);if(t&&!t.eq(e.state.selection)){let n=e.state.tr.setSelection(t);a&&n.setMeta(`composition`,a),e.dispatch(n)}}return}e.state.selection.from<e.state.selection.to&&m.start==m.endB&&e.state.selection instanceof A&&(m.start>e.state.selection.from&&m.start<=e.state.selection.from+2&&e.state.selection.from>=l.from?m.start=e.state.selection.from:m.endA<e.state.selection.to&&m.endA>=e.state.selection.to-2&&e.state.selection.to<=l.to&&(m.endB+=e.state.selection.to-m.endA,m.endA=e.state.selection.to)),I&&Kt<=11&&m.endB==m.start+1&&m.endA==m.start&&m.start>l.from&&l.doc.textBetween(m.start-l.from-1,m.start-l.from+1)==` \xA0`&&(m.start--,m.endA--,m.endB--);let h=l.doc.resolveNoCache(m.start-l.from),g=l.doc.resolveNoCache(m.endB-l.from),ee=u.resolve(m.start),te=h.sameParent(g)&&h.parent.inlineContent&&ee.end()>=m.endA;if((Xt&&e.input.lastIOSEnter>Date.now()-225&&(!te||i.some(e=>e.nodeName==`DIV`||e.nodeName==`P`))||!te&&h.pos<l.doc.content.size&&(!h.sameParent(g)||!h.parent.inlineContent)&&h.pos<g.pos&&!/\S/.test(l.doc.textBetween(h.pos,g.pos,``,``)))&&e.someProp(`handleKeyDown`,t=>t(e,Lt(13,`Enter`)))){e.input.lastIOSEnter=0;return}if(e.state.selection.anchor>m.start&&Da(u,m.start,m.endA,h,g)&&e.someProp(`handleKeyDown`,t=>t(e,Lt(8,`Backspace`)))){$t&&L&&e.domObserver.suppressSelectionUpdates();return}L&&m.endB==m.start&&(e.input.lastChromeDelete=Date.now()),$t&&!te&&h.start()!=g.start()&&g.parentOffset==0&&h.depth==g.depth&&l.sel&&l.sel.anchor==l.sel.head&&l.sel.head==m.endA&&(m.endB-=2,g=l.doc.resolveNoCache(m.endB-l.from),setTimeout(()=>{e.someProp(`handleKeyDown`,function(t){return t(e,Lt(13,`Enter`))})},20));let _=m.start,v=m.endA,ne=t=>{let n=t||e.state.tr.replace(_,v,l.doc.slice(m.start-l.from,m.endB-l.from));if(l.sel){let t=Ta(e,n.doc,l.sel);t&&!(L&&e.composing&&t.empty&&(m.start!=m.endB||e.input.lastChromeDelete<Date.now()-100)&&(t.head==_||t.head==n.mapping.map(v)-1)||I&&t.empty&&t.head==_)&&n.setSelection(t)}return a&&n.setMeta(`composition`,a),n.scrollIntoView()},y;if(te)if(h.pos==g.pos){I&&Kt<=11&&h.parentOffset==0&&(e.domObserver.suppressSelectionUpdates(),setTimeout(()=>fr(e),20));let t=ne(e.state.tr.delete(_,v)),n=u.resolve(m.start).marksAcross(u.resolve(m.endA));n&&t.ensureMarks(n),e.dispatch(t)}else if(m.endA==m.endB&&(y=Ea(h.parent.content.cut(h.parentOffset,g.parentOffset),ee.parent.content.cut(ee.parentOffset,m.endA-ee.start())))){let t=ne(e.state.tr);y.type==`add`?t.addMark(_,v,y.mark):t.removeMark(_,v,y.mark),e.dispatch(t)}else if(h.parent.child(h.index()).isText&&h.index()==g.index()-(g.textOffset?0:1)){let t=h.parent.textBetween(h.parentOffset,g.parentOffset),n=()=>ne(e.state.tr.insertText(t,_,v));e.someProp(`handleTextInput`,r=>r(e,_,v,t,n))||e.dispatch(n())}else e.dispatch(ne());else e.dispatch(ne())}function Ta(e,t,n){return Math.max(n.anchor,n.head)>t.content.size?null:xr(e,t.resolve(n.anchor),t.resolve(n.head))}function Ea(e,t){let n=e.firstChild.marks,r=t.firstChild.marks,i=n,a=r,o,s,c;for(let e=0;e<r.length;e++)i=r[e].removeFromSet(i);for(let e=0;e<n.length;e++)a=n[e].removeFromSet(a);if(i.length==1&&a.length==0)s=i[0],o=`add`,c=e=>e.mark(s.addToSet(e.marks));else if(i.length==0&&a.length==1)s=a[0],o=`remove`,c=e=>e.mark(s.removeFromSet(e.marks));else return null;let l=[];for(let e=0;e<t.childCount;e++)l.push(c(t.child(e)));if(m.d.from(l).eq(e))return{mark:s,type:o}}function Da(e,t,n,r,i){if(n-t<=i.pos-r.pos||Oa(r,!0,!1)<i.pos)return!1;let a=e.resolve(t);if(!r.parent.isTextblock){let e=a.nodeAfter;return e!=null&&n==t+e.nodeSize}if(a.parentOffset<a.parent.content.size||!a.parent.isTextblock)return!1;let o=e.resolve(Oa(a,!0,!0));return!o.parent.isTextblock||o.pos>n||Oa(o,!0,!1)<n?!1:r.parent.content.cut(r.parentOffset).eq(o.parent.content)}function Oa(e,t,n){let r=e.depth,i=t?e.end():e.pos;for(;r>0&&(t||e.indexAfter(r)==e.node(r).childCount);)r--,i++,t=!1;if(n){let t=e.node(r).maybeChild(e.indexAfter(r));for(;t&&!t.isLeaf;)t=t.firstChild,i++}return i}function ka(e,t,n,r,i){let a=e.findDiffStart(t,n);if(a==null)return null;let{a:o,b:s}=e.findDiffEnd(t,n+e.size,n+t.size);if(i==`end`){let e=Math.max(0,a-Math.min(o,s));r-=o+e-a}if(o<a&&e.size<t.size){let e=r<=a&&r>=o?a-r:0;a-=e,a&&a<t.size&&Aa(t.textBetween(a-1,a+1))&&(a+=e?1:-1),s=a+(s-o),o=a}else if(s<a){let t=r<=a&&r>=s?a-r:0;a-=t,a&&a<e.size&&Aa(e.textBetween(a-1,a+1))&&(a+=t?1:-1),o=a+(o-s),s=a}return{start:a,endA:o,endB:s}}function Aa(e){if(e.length!=2)return!1;let t=e.charCodeAt(0),n=e.charCodeAt(1);return t>=56320&&t<=57343&&n>=55296&&n<=56319}var ja=class{constructor(e,t){this._root=null,this.focused=!1,this.trackWrites=null,this.mounted=!1,this.markCursor=null,this.cursorWrapper=null,this.lastSelectedViewDesc=void 0,this.input=new ci,this.prevDirectPlugins=[],this.pluginViews=[],this.requiresGeckoHackNode=!1,this.dragging=null,this._props=t,this.state=t.state,this.directPlugins=t.plugins||[],this.directPlugins.forEach(Ra),this.dispatch=this.dispatch.bind(this),this.dom=e&&e.mount||document.createElement(`div`),e&&(e.appendChild?e.appendChild(this.dom):typeof e==`function`?e(this.dom):e.mount&&(this.mounted=!0)),this.editable=Pa(this),Na(this),this.nodeViews=Ia(this),this.docView=Wn(this.state.doc,Ma(this),la(this),this.dom,this),this.domObserver=new pa(this,(e,t,n,r)=>wa(this,e,t,n,r)),this.domObserver.start(),li(this),this.updatePluginViews()}get composing(){return this.input.composing}get props(){if(this._props.state!=this.state){let e=this._props;this._props={};for(let t in e)this._props[t]=e[t];this._props.state=this.state}return this._props}update(e){e.handleDOMEvents!=this._props.handleDOMEvents&&fi(this);let t=this._props;this._props=e,e.plugins&&(e.plugins.forEach(Ra),this.directPlugins=e.plugins),this.updateStateInner(e.state,t)}setProps(e){let t={};for(let e in this._props)t[e]=this._props[e];t.state=this.state;for(let n in e)t[n]=e[n];this.update(t)}updateState(e){this.updateStateInner(e,this._props)}updateStateInner(e,t){let n=this.state,r=!1,i=!1;e.storedMarks&&this.composing&&(Ni(this),i=!0),this.state=e;let a=n.plugins!=e.plugins||this._props.plugins!=t.plugins;if(a||this._props.plugins!=t.plugins||this._props.nodeViews!=t.nodeViews){let e=Ia(this);La(e,this.nodeViews)&&(this.nodeViews=e,r=!0)}(a||t.handleDOMEvents!=this._props.handleDOMEvents)&&fi(this),this.editable=Pa(this),Na(this);let o=la(this),s=Ma(this),c=n.plugins!=e.plugins&&!n.doc.eq(e.doc)?`reset`:e.scrollToSelection>n.scrollToSelection?`to selection`:`preserve`,l=r||!this.docView.matchesNode(e.doc,s,o);(l||!e.selection.eq(n.selection))&&(i=!0);let u=c==`preserve`&&i&&this.dom.style.overflowAnchor==null&&sn(this);if(i){this.domObserver.stop();let t=l&&(I||L)&&!this.composing&&!n.selection.empty&&!e.selection.empty&&Fa(n.selection,e.selection);if(l){let n=L?this.trackWrites=this.domSelectionRange().focusNode:null;this.composing&&(this.input.compositionNode=Pi(this)),(r||!this.docView.update(e.doc,s,o,this))&&(this.docView.updateOuterDeco(s),this.docView.destroy(),this.docView=Wn(e.doc,s,o,this.dom,this)),n&&(!this.trackWrites||!this.dom.contains(this.trackWrites))&&(t=!0)}t||!(this.input.mouseDown&&this.domObserver.currentSelection.eq(this.domSelectionRange())&&wr(this))?fr(this,t):(yr(this,e.selection),this.domObserver.setCurSelection()),this.domObserver.start()}this.updatePluginViews(n),this.dragging?.node&&!n.doc.eq(e.doc)&&this.updateDraggedNode(this.dragging,n),c==`reset`?this.dom.scrollTop=0:c==`to selection`?this.scrollToSelection():u&&ln(u)}scrollToSelection(){let e=this.domSelectionRange().focusNode;if(!(!e||!this.dom.contains(e.nodeType==1?e:e.parentNode))&&!this.someProp(`handleScrollToSelection`,e=>e(this)))if(this.state.selection instanceof j){let t=this.docView.domAfterPos(this.state.selection.from);t.nodeType==1&&on(this,t.getBoundingClientRect(),e)}else on(this,this.coordsAtPos(this.state.selection.head,1),e)}destroyPluginViews(){let e;for(;e=this.pluginViews.pop();)e.destroy&&e.destroy()}updatePluginViews(e){if(!e||e.plugins!=this.state.plugins||this.directPlugins!=this.prevDirectPlugins){this.prevDirectPlugins=this.directPlugins,this.destroyPluginViews();for(let e=0;e<this.directPlugins.length;e++){let t=this.directPlugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}for(let e=0;e<this.state.plugins.length;e++){let t=this.state.plugins[e];t.spec.view&&this.pluginViews.push(t.spec.view(this))}}else for(let t=0;t<this.pluginViews.length;t++){let n=this.pluginViews[t];n.update&&n.update(this,e)}}updateDraggedNode(e,t){let n=e.node,r=-1;if(this.state.doc.nodeAt(n.from)==n.node)r=n.from;else{let e=n.from+(this.state.doc.content.size-t.doc.content.size);(e>0&&this.state.doc.nodeAt(e))==n.node&&(r=e)}this.dragging=new Ui(e.slice,e.move,r<0?void 0:j.create(this.state.doc,r))}someProp(e,t){let n=this._props&&this._props[e],r;if(n!=null&&(r=t?t(n):n))return r;for(let n=0;n<this.directPlugins.length;n++){let i=this.directPlugins[n].props[e];if(i!=null&&(r=t?t(i):i))return r}let i=this.state.plugins;if(i)for(let n=0;n<i.length;n++){let a=i[n].props[e];if(a!=null&&(r=t?t(a):a))return r}}hasFocus(){if(I){let e=this.root.activeElement;if(e==this.dom)return!0;if(!e||!this.dom.contains(e))return!1;for(;e&&this.dom!=e&&this.dom.contains(e);){if(e.contentEditable==`false`)return!1;e=e.parentElement}return!0}return this.root.activeElement==this.dom}focus(){this.domObserver.stop(),this.editable&&fn(this.dom),fr(this),this.domObserver.start()}get root(){let e=this._root;if(e==null){for(let e=this.dom.parentNode;e;e=e.parentNode)if(e.nodeType==9||e.nodeType==11&&e.host)return e.getSelection||(Object.getPrototypeOf(e).getSelection=()=>e.ownerDocument.getSelection()),this._root=e}return e||document}updateRoot(){this._root=null}posAtCoords(e){return bn(this,e)}coordsAtPos(e,t=1){return wn(this,e,t)}domAtPos(e,t=0){return this.docView.domFromPos(e,t)}nodeDOM(e){let t=this.docView.descAt(e);return t?t.nodeDOM:null}posAtDOM(e,t,n=-1){let r=this.docView.posFromDOM(e,t,n);if(r==null)throw RangeError(`DOM position not inside the editor`);return r}endOfTextblock(e,t){return Pn(this,t||this.state,e)}pasteHTML(e,t){return Vi(this,``,e,!1,t||new ClipboardEvent(`paste`))}pasteText(e,t){return Vi(this,e,null,!0,t||new ClipboardEvent(`paste`))}serializeForClipboard(e){return Wr(this,e)}destroy(){this.docView&&(di(this),this.destroyPluginViews(),this.mounted?(this.docView.update(this.state.doc,[],la(this),this),this.dom.textContent=``):this.dom.parentNode&&this.dom.parentNode.removeChild(this.dom),this.docView.destroy(),this.docView=null,Ot())}get isDestroyed(){return this.docView==null}dispatchEvent(e){return hi(this,e)}domSelectionRange(){let e=this.domSelection();return e?R&&this.root.nodeType===11&&Rt(this.dom.ownerDocument)==this.dom&&va(this,e)||e:{focusNode:null,focusOffset:0,anchorNode:null,anchorOffset:0}}domSelection(){return this.root.getSelection()}};ja.prototype.dispatch=function(e){let t=this._props.dispatchTransaction;t?t.call(this,e):this.updateState(this.state.apply(e))};function Ma(e){let t=Object.create(null);return t.class=`ProseMirror`,t.contenteditable=String(e.editable),e.someProp(`attributes`,n=>{if(typeof n==`function`&&(n=n(e.state)),n)for(let e in n)e==`class`?t.class+=` `+n[e]:e==`style`?t.style=(t.style?t.style+`;`:``)+n[e]:!t[e]&&e!=`contenteditable`&&e!=`nodeName`&&(t[e]=String(n[e]))}),t.translate||=`no`,[V.node(0,e.state.doc.content.size,t)]}function Na(e){if(e.markCursor){let t=document.createElement(`img`);t.className=`ProseMirror-separator`,t.setAttribute(`mark-placeholder`,`true`),t.setAttribute(`alt`,``),e.cursorWrapper={dom:t,deco:V.widget(e.state.selection.from,t,{raw:!0,marks:e.markCursor})}}else e.cursorWrapper=null}function Pa(e){return!e.someProp(`editable`,t=>t(e.state)===!1)}function Fa(e,t){let n=Math.min(e.$anchor.sharedDepth(e.head),t.$anchor.sharedDepth(t.head));return e.$anchor.start(n)!=t.$anchor.start(n)}function Ia(e){let t=Object.create(null);function n(e){for(let n in e)Object.prototype.hasOwnProperty.call(t,n)||(t[n]=e[n])}return e.someProp(`nodeViews`,n),e.someProp(`markViews`,n),t}function La(e,t){let n=0,r=0;for(let r in e){if(e[r]!=t[r])return!0;n++}for(let e in t)r++;return n!=r}function Ra(e){if(e.spec.state||e.spec.filterTransaction||e.spec.appendTransaction)throw RangeError(`Plugins passed directly to the view must not have a state component`)}for(var za={8:`Backspace`,9:`Tab`,10:`Enter`,12:`NumLock`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,44:`PrintScreen`,45:`Insert`,46:`Delete`,59:`;`,61:`=`,91:`Meta`,92:`Meta`,106:`*`,107:`+`,108:`,`,109:`-`,110:`.`,111:`/`,144:`NumLock`,145:`ScrollLock`,160:`Shift`,161:`Shift`,162:`Control`,163:`Control`,164:`Alt`,165:`Alt`,173:`-`,186:`;`,187:`=`,188:`,`,189:`-`,190:`.`,191:`/`,192:"`",219:`[`,220:`\\`,221:`]`,222:`'`},Ba={48:`)`,49:`!`,50:`@`,51:`#`,52:`$`,53:`%`,54:`^`,55:`&`,56:`*`,57:`(`,59:`:`,61:`+`,173:`_`,186:`:`,187:`+`,188:`<`,189:`_`,190:`>`,191:`?`,192:`~`,219:`{`,220:`|`,221:`}`,222:`"`},Va=typeof navigator<`u`&&/Mac/.test(navigator.platform),Ha=typeof navigator<`u`&&/MSIE \d|Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(navigator.userAgent),W=0;W<10;W++)za[48+W]=za[96+W]=String(W);for(var W=1;W<=24;W++)za[W+111]=`F`+W;for(var W=65;W<=90;W++)za[W]=String.fromCharCode(W+32),Ba[W]=String.fromCharCode(W);for(var Ua in za)Ba.hasOwnProperty(Ua)||(Ba[Ua]=za[Ua]);function Wa(e){var t=!(Va&&e.metaKey&&e.shiftKey&&!e.ctrlKey&&!e.altKey||Ha&&e.shiftKey&&e.key&&e.key.length==1||e.key==`Unidentified`)&&e.key||(e.shiftKey?Ba:za)[e.keyCode]||e.key||`Unidentified`;return t==`Esc`&&(t=`Escape`),t==`Del`&&(t=`Delete`),t==`Left`&&(t=`ArrowLeft`),t==`Up`&&(t=`ArrowUp`),t==`Right`&&(t=`ArrowRight`),t==`Down`&&(t=`ArrowDown`),t}var Ga=typeof navigator<`u`&&/Mac|iP(hone|[oa]d)/.test(navigator.platform),Ka=typeof navigator<`u`&&/Win/.test(navigator.platform);function qa(e){let t=e.split(/-(?!$)/),n=t[t.length-1];n==`Space`&&(n=` `);let r,i,a,o;for(let e=0;e<t.length-1;e++){let n=t[e];if(/^(cmd|meta|m)$/i.test(n))o=!0;else if(/^a(lt)?$/i.test(n))r=!0;else if(/^(c|ctrl|control)$/i.test(n))i=!0;else if(/^s(hift)?$/i.test(n))a=!0;else if(/^mod$/i.test(n))Ga?o=!0:i=!0;else throw Error(`Unrecognized modifier name: `+n)}return r&&(n=`Alt-`+n),i&&(n=`Ctrl-`+n),o&&(n=`Meta-`+n),a&&(n=`Shift-`+n),n}function Ja(e){let t=Object.create(null);for(let n in e)t[qa(n)]=e[n];return t}function Ya(e,t,n=!0){return t.altKey&&(e=`Alt-`+e),t.ctrlKey&&(e=`Ctrl-`+e),t.metaKey&&(e=`Meta-`+e),n&&t.shiftKey&&(e=`Shift-`+e),e}function G(e){return new N({props:{handleKeyDown:Xa(e)}})}function Xa(e){let t=Ja(e);return function(e,n){let r=Wa(n),i,a=t[Ya(r,n)];if(a&&a(e.state,e.dispatch,e))return!0;if(r.length==1&&r!=` `){if(n.shiftKey){let i=t[Ya(r,n,!1)];if(i&&i(e.state,e.dispatch,e))return!0}if((n.altKey||n.metaKey||n.ctrlKey)&&!(Ka&&n.ctrlKey&&n.altKey)&&(i=za[n.keyCode])&&i!=r){let r=t[Ya(i,n)];if(r&&r(e.state,e.dispatch,e))return!0}}return!1}}var Za=(e,t)=>e.selection.empty?!1:(t&&t(e.tr.deleteSelection().scrollIntoView()),!0);function Qa(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`backward`,e):n.parentOffset>0)?null:n}var $a=(e,t,n)=>{let r=Qa(e,n);if(!r)return!1;let i=no(r);if(!i){let n=r.blockRange(),i=n&&we(n);return i==null?!1:(t&&t(e.tr.lift(n,i).scrollIntoView()),!0)}let a=i.nodeBefore;if(_o(e,i,t,-1))return!0;if(r.parent.content.size==0&&(eo(a,`end`)||j.isSelectable(a)))for(let n=r.depth;;n--){let o=Be(e.doc,r.before(n),r.after(n),m.v.empty);if(o&&o.slice.size<o.to-o.from){if(t){let n=e.tr.step(o);n.setSelection(eo(a,`end`)?k.findFrom(n.doc.resolve(n.mapping.map(i.pos,-1)),-1):j.create(n.doc,i.pos-a.nodeSize)),t(n.scrollIntoView())}return!0}if(n==1||r.node(n-1).childCount>1)break}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos-a.nodeSize,i.pos).scrollIntoView()),!0):!1};function eo(e,t,n=!1){for(let r=e;r;r=t==`start`?r.firstChild:r.lastChild){if(r.isTextblock)return!0;if(n&&r.childCount!=1)return!1}return!1}var to=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`backward`,e):r.parentOffset>0)return!1;a=no(r)}let o=a&&a.nodeBefore;return!o||!j.isSelectable(o)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,a.pos-o.nodeSize)).scrollIntoView()),!0)};function no(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){if(e.index(t)>0)return e.doc.resolve(e.before(t+1));if(e.node(t).type.spec.isolating)break}return null}function ro(e,t){let{$cursor:n}=e.selection;return!n||(t?!t.endOfTextblock(`forward`,e):n.parentOffset<n.parent.content.size)?null:n}var io=(e,t,n)=>{let r=ro(e,n);if(!r)return!1;let i=oo(r);if(!i)return!1;let a=i.nodeAfter;if(_o(e,i,t,1))return!0;if(r.parent.content.size==0&&(eo(a,`start`)||j.isSelectable(a))){let n=Be(e.doc,r.before(),r.after(),m.v.empty);if(n&&n.slice.size<n.to-n.from){if(t){let r=e.tr.step(n);r.setSelection(eo(a,`start`)?k.findFrom(r.doc.resolve(r.mapping.map(i.pos)),1):j.create(r.doc,r.mapping.map(i.pos))),t(r.scrollIntoView())}return!0}}return a.isAtom&&i.depth==r.depth-1?(t&&t(e.tr.delete(i.pos,i.pos+a.nodeSize).scrollIntoView()),!0):!1},ao=(e,t,n)=>{let{$head:r,empty:i}=e.selection,a=r;if(!i)return!1;if(r.parent.isTextblock){if(n?!n.endOfTextblock(`forward`,e):r.parentOffset<r.parent.content.size)return!1;a=oo(r)}let o=a&&a.nodeAfter;return!o||!j.isSelectable(o)?!1:(t&&t(e.tr.setSelection(j.create(e.doc,a.pos)).scrollIntoView()),!0)};function oo(e){if(!e.parent.type.spec.isolating)for(let t=e.depth-1;t>=0;t--){let n=e.node(t);if(e.index(t)+1<n.childCount)return e.doc.resolve(e.after(t+1));if(n.type.spec.isolating)break}return null}var so=(e,t)=>{let{$head:n,$anchor:r}=e.selection;return!n.parent.type.spec.code||!n.sameParent(r)?!1:(t&&t(e.tr.insertText(`
30
+ `).scrollIntoView()),!0)};function co(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}return null}var lo=(e,t)=>{let{$head:n,$anchor:r}=e.selection;if(!n.parent.type.spec.code||!n.sameParent(r))return!1;let i=n.node(-1),a=n.indexAfter(-1),o=co(i.contentMatchAt(a));if(!o||!i.canReplaceWith(a,a,o))return!1;if(t){let r=n.after(),i=e.tr.replaceWith(r,r,o.createAndFill());i.setSelection(k.near(i.doc.resolve(r),1)),t(i.scrollIntoView())}return!0},uo=(e,t)=>{let n=e.selection,{$from:r,$to:i}=n;if(n instanceof M||r.parent.inlineContent||i.parent.inlineContent)return!1;let a=co(i.parent.contentMatchAt(i.indexAfter()));if(!a||!a.isTextblock)return!1;if(t){let n=(!r.parentOffset&&i.index()<i.parent.childCount?r:i).pos,o=e.tr.insert(n,a.createAndFill());o.setSelection(A.create(o.doc,n+1)),t(o.scrollIntoView())}return!0},fo=(e,t)=>{let{$cursor:n}=e.selection;if(!n||n.parent.content.size)return!1;if(n.depth>1&&n.after()!=n.end(-1)){let r=n.before();if(Me(e.doc,r))return t&&t(e.tr.split(r).scrollIntoView()),!0}let r=n.blockRange(),i=r&&we(r);return i==null?!1:(t&&t(e.tr.lift(r,i).scrollIntoView()),!0)};function po(e){return(t,n)=>{let{$from:r,$to:i}=t.selection;if(t.selection instanceof j&&t.selection.node.isBlock)return!r.parentOffset||!Me(t.doc,r.pos)?!1:(n&&n(t.tr.split(r.pos).scrollIntoView()),!0);if(!r.depth)return!1;let a=[],o,s,c=!1,l=!1;for(let t=r.depth;;t--)if(r.node(t).isBlock){c=r.end(t)==r.pos+(r.depth-t),l=r.start(t)==r.pos-(r.depth-t),s=co(r.node(t-1).contentMatchAt(r.indexAfter(t-1)));let n=e&&e(i.parent,c,r);a.unshift(n||(c&&s?{type:s}:null)),o=t;break}else{if(t==1)return!1;a.unshift(null)}let u=t.tr;(t.selection instanceof A||t.selection instanceof M)&&u.deleteSelection();let d=u.mapping.map(r.pos),f=Me(u.doc,d,a.length,a);if(f||=(a[0]=s?{type:s}:null,Me(u.doc,d,a.length,a)),!f)return!1;if(u.split(d,a.length,a),!c&&l&&r.node(o).type!=s){let e=u.mapping.map(r.before(o)),t=u.doc.resolve(e);s&&r.node(o-1).canReplaceWith(t.index(),t.index()+1,s)&&u.setNodeMarkup(u.mapping.map(r.before(o)),s)}return n&&n(u.scrollIntoView()),!0}}var mo=po(),ho=(e,t)=>(t&&t(e.tr.setSelection(new M(e.doc))),!0);function go(e,t,n){let r=t.nodeBefore,i=t.nodeAfter,a=t.index();return!r||!i||!r.type.compatibleContent(i.type)?!1:!r.content.size&&t.parent.canReplace(a-1,a)?(n&&n(e.tr.delete(t.pos-r.nodeSize,t.pos).scrollIntoView()),!0):!t.parent.canReplace(a,a+1)||!(i.isTextblock||Pe(e.doc,t.pos))?!1:(n&&n(e.tr.join(t.pos).scrollIntoView()),!0)}function _o(e,t,n,r){let i=t.nodeBefore,a=t.nodeAfter,o,s,c=i.type.spec.isolating||a.type.spec.isolating;if(!c&&go(e,t,n))return!0;let l=!c&&t.parent.canReplace(t.index(),t.index()+1);if(l&&(o=(s=i.contentMatchAt(i.childCount)).findWrapping(a.type))&&s.matchType(o[0]||a.type).validEnd){if(n){let r=t.pos+a.nodeSize,s=m.d.empty;for(let e=o.length-1;e>=0;e--)s=m.d.from(o[e].create(null,s));s=m.d.from(i.copy(s));let c=e.tr.step(new E(t.pos-1,r,t.pos,r,new m.v(s,1,0),o.length,!0)),l=c.doc.resolve(r+2*o.length);l.nodeAfter&&l.nodeAfter.type==i.type&&Pe(c.doc,l.pos)&&c.join(l.pos),n(c.scrollIntoView())}return!0}let u=a.type.spec.isolating||r>0&&c?null:k.findFrom(t,1),d=u&&u.$from.blockRange(u.$to),f=d&&we(d);if(f!=null&&f>=t.depth)return n&&n(e.tr.lift(d,f).scrollIntoView()),!0;if(l&&eo(a,`start`,!0)&&eo(i,`end`)){let r=i,o=[];for(;o.push(r),!r.isTextblock;)r=r.lastChild;let s=a,c=1;for(;!s.isTextblock;s=s.firstChild)c++;if(r.canReplace(r.childCount,r.childCount,s.content)){if(n){let r=m.d.empty;for(let e=o.length-1;e>=0;e--)r=m.d.from(o[e].copy(r));n(e.tr.step(new E(t.pos-o.length,t.pos+a.nodeSize,t.pos+c,t.pos+a.nodeSize-c,new m.v(r,o.length,0),0,!0)).scrollIntoView())}return!0}}return!1}function vo(e){return function(t,n){let r=t.selection,i=e<0?r.$from:r.$to,a=i.depth;for(;i.node(a).isInline;){if(!a)return!1;a--}return i.node(a).isTextblock?(n&&n(t.tr.setSelection(A.create(t.doc,e<0?i.start(a):i.end(a)))),!0):!1}}var yo=vo(-1),bo=vo(1);function xo(e,t,n,r){for(let i=0;i<t.length;i++){let{$from:a,$to:o}=t[i],s=a.depth==0?e.inlineContent&&e.type.allowsMarkType(n):!1;if(e.nodesBetween(a.pos,o.pos,(e,t)=>{if(s||!r&&e.isAtom&&e.isInline&&t>=a.pos&&t+e.nodeSize<=o.pos)return!1;s=e.inlineContent&&e.type.allowsMarkType(n)}),s)return!0}return!1}function So(e){let t=[];for(let n=0;n<e.length;n++){let{$from:r,$to:i}=e[n];r.doc.nodesBetween(r.pos,i.pos,(e,n)=>{if(e.isAtom&&e.content.size&&e.isInline&&n>=r.pos&&n+e.nodeSize<=i.pos)return n+1>r.pos&&t.push(new it(r,r.doc.resolve(n+1))),r=r.doc.resolve(n+1+e.content.size),!1}),r.pos<i.pos&&t.push(new it(r,i))}return t}function Co(e,t=null,n){let r=(n&&n.removeWhenPresent)!==!1,i=(n&&n.enterInlineAtoms)!==!1,a=!(n&&n.includeWhitespace);return function(n,o){let{empty:s,$cursor:c,ranges:l}=n.selection;if(s&&!c||!xo(n.doc,l,e,i))return!1;if(o)if(c)e.isInSet(n.storedMarks||c.marks())?o(n.tr.removeStoredMark(e)):o(n.tr.addStoredMark(e.create(t)));else{let s,c=n.tr;i||(l=So(l)),s=r?!l.some(t=>n.doc.rangeHasMark(t.$from.pos,t.$to.pos,e)):!l.every(t=>{let n=!1;return c.doc.nodesBetween(t.$from.pos,t.$to.pos,(r,i,a)=>{if(n)return!1;n=!e.isInSet(r.marks)&&!!a&&a.type.allowsMarkType(e)&&!(r.isText&&/^\s*$/.test(r.textBetween(Math.max(0,t.$from.pos-i),Math.min(r.nodeSize,t.$to.pos-i))))}),!n});for(let n=0;n<l.length;n++){let{$from:r,$to:i}=l[n];if(!s)c.removeMark(r.pos,i.pos,e);else{let n=r.pos,o=i.pos,s=r.nodeAfter,l=i.nodeBefore,u=a&&s&&s.isText?/^\s*/.exec(s.text)[0].length:0,d=a&&l&&l.isText?/\s*$/.exec(l.text)[0].length:0;n+u<o&&(n+=u,o-=d),c.addMark(n,o,e.create(t))}}o(c.scrollIntoView())}return!0}}function wo(e,t){return n=>{if(!n.isGeneric)return e(n);let r=[];for(let e=0;e<n.mapping.maps.length;e++){let t=n.mapping.maps[e];for(let e=0;e<r.length;e++)r[e]=t.map(r[e]);t.forEach((e,t,n,i)=>r.push(n,i))}let i=[];for(let e=0;e<r.length;e+=2){let a=r[e],o=r[e+1],s=n.doc.resolve(a),c=s.sharedDepth(o),l=s.node(c);for(let e=s.indexAfter(c),n=s.after(c+1);n<=o;++e){let r=l.maybeChild(e);if(!r)break;if(e&&i.indexOf(n)==-1){let a=l.child(e-1);a.type==r.type&&t(a,r)&&i.push(n)}n+=r.nodeSize}}i.sort((e,t)=>e-t);for(let e=i.length-1;e>=0;e--)Pe(n.doc,i[e])&&n.join(i[e]);e(n)}}function To(e,t){let n=Array.isArray(t)?e=>t.indexOf(e.type.name)>-1:t;return(t,r,i)=>e(t,r&&wo(r,n),i)}function Eo(...e){return function(t,n,r){for(let i=0;i<e.length;i++)if(e[i](t,n,r))return!0;return!1}}var Do=Eo(Za,$a,to),Oo=Eo(Za,io,ao),ko={Enter:Eo(so,uo,fo,mo),"Mod-Enter":lo,Backspace:Do,"Mod-Backspace":Do,"Shift-Backspace":Do,Delete:Oo,"Mod-Delete":Oo,"Mod-a":ho},Ao={"Ctrl-h":ko.Backspace,"Alt-Backspace":ko[`Mod-Backspace`],"Ctrl-d":ko.Delete,"Ctrl-Alt-Backspace":ko[`Mod-Delete`],"Alt-Delete":ko[`Mod-Delete`],"Alt-d":ko[`Mod-Delete`],"Ctrl-a":yo,"Ctrl-e":bo};for(let e in ko)Ao[e]=ko[e];var jo=(typeof navigator<`u`?/Mac|iP(hone|[oa]d)/.test(navigator.platform):typeof os<`u`&&os.platform&&os.platform()==`darwin`)?Ao:ko,Mo=`.ProseMirror{word-wrap:break-word;white-space:pre-wrap;white-space:break-spaces;-webkit-font-variant-ligatures:none;font-variant-ligatures:none;font-feature-settings:"liga" 0;position:relative}.ProseMirror pre{white-space:pre-wrap}.ProseMirror li{position:relative}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection ::selection{background:0 0}.ProseMirror-hideselection{caret-color:#0000}.ProseMirror [draggable][contenteditable=false]{user-select:text}.ProseMirror-selectednode{outline:2px solid #8cf}li.ProseMirror-selectednode{outline:none}li.ProseMirror-selectednode:after{content:"";pointer-events:none;border:2px solid #8cf;position:absolute;inset:-2px -2px -2px -32px}img.ProseMirror-separator{border:none!important;margin:0!important;display:inline!important}`;function No(e={}){return new N({view(t){return new Po(t,e)}})}var Po=class{constructor(e,t){this.editorView=e,this.cursorPos=null,this.element=null,this.timeout=-1,this.width=t.width??1,this.color=t.color===!1?void 0:t.color||`black`,this.class=t.class,this.handlers=[`dragover`,`dragend`,`drop`,`dragleave`].map(t=>{let n=e=>{this[t](e)};return e.dom.addEventListener(t,n),{name:t,handler:n}})}destroy(){this.handlers.forEach(({name:e,handler:t})=>this.editorView.dom.removeEventListener(e,t))}update(e,t){this.cursorPos!=null&&t.doc!=e.state.doc&&(this.cursorPos>e.state.doc.content.size?this.setCursor(null):this.updateOverlay())}setCursor(e){e!=this.cursorPos&&(this.cursorPos=e,e==null?(this.element.parentNode.removeChild(this.element),this.element=null):this.updateOverlay())}updateOverlay(){let e=this.editorView.state.doc.resolve(this.cursorPos),t=!e.parent.inlineContent,n,r=this.editorView.dom,i=r.getBoundingClientRect(),a=i.width/r.offsetWidth,o=i.height/r.offsetHeight;if(t){let t=e.nodeBefore,r=e.nodeAfter;if(t||r){let e=this.editorView.nodeDOM(this.cursorPos-(t?t.nodeSize:0));if(e){let i=e.getBoundingClientRect(),a=t?i.bottom:i.top;t&&r&&(a=(a+this.editorView.nodeDOM(this.cursorPos).getBoundingClientRect().top)/2);let s=this.width/2*o;n={left:i.left,right:i.right,top:a-s,bottom:a+s}}}}if(!n){let e=this.editorView.coordsAtPos(this.cursorPos),t=this.width/2*a;n={left:e.left-t,right:e.left+t,top:e.top,bottom:e.bottom}}let s=this.editorView.dom.offsetParent;this.element||(this.element=s.appendChild(document.createElement(`div`)),this.class&&(this.element.className=this.class),this.element.style.cssText=`position: absolute; z-index: 50; pointer-events: none;`,this.color&&(this.element.style.backgroundColor=this.color)),this.element.classList.toggle(`prosemirror-dropcursor-block`,t),this.element.classList.toggle(`prosemirror-dropcursor-inline`,!t);let c,l;if(!s||s==document.body&&getComputedStyle(s).position==`static`)c=-pageXOffset,l=-pageYOffset;else{let e=s.getBoundingClientRect(),t=e.width/s.offsetWidth,n=e.height/s.offsetHeight;c=e.left-s.scrollLeft*t,l=e.top-s.scrollTop*n}this.element.style.left=(n.left-c)/a+`px`,this.element.style.top=(n.top-l)/o+`px`,this.element.style.width=(n.right-n.left)/a+`px`,this.element.style.height=(n.bottom-n.top)/o+`px`}scheduleRemoval(e){clearTimeout(this.timeout),this.timeout=setTimeout(()=>this.setCursor(null),e)}dragover(e){if(!this.editorView.editable)return;let t=this.editorView.posAtCoords({left:e.clientX,top:e.clientY}),n=t&&t.inside>=0&&this.editorView.state.doc.nodeAt(t.inside),r=n&&n.type.spec.disableDropCursor,i=typeof r==`function`?r(this.editorView,t,e):r;if(t&&!i){let e=t.pos;if(this.editorView.dragging&&this.editorView.dragging.slice){let t=ze(this.editorView.state.doc,e,this.editorView.dragging.slice);t!=null&&(e=t)}this.setCursor(e),this.scheduleRemoval(5e3)}}dragend(){this.scheduleRemoval(20)}drop(){this.scheduleRemoval(20)}dragleave(e){this.editorView.dom.contains(e.relatedTarget)||this.setCursor(null)}},K=class e extends k{constructor(e){super(e,e)}map(t,n){let r=t.resolve(n.map(this.head));return e.valid(r)?new e(r):k.near(r)}content(){return m.v.empty}eq(t){return t instanceof e&&t.head==this.head}toJSON(){return{type:`gapcursor`,pos:this.head}}static fromJSON(t,n){if(typeof n.pos!=`number`)throw RangeError(`Invalid input for GapCursor.fromJSON`);return new e(t.resolve(n.pos))}getBookmark(){return new Fo(this.anchor)}static valid(e){let t=e.parent;if(t.isTextblock||!Lo(e)||!Ro(e))return!1;let n=t.type.spec.allowGapCursor;if(n!=null)return n;let r=t.contentMatchAt(e.index()).defaultType;return r&&r.isTextblock}static findGapCursorFrom(t,n,r=!1){search:for(;;){if(!r&&e.valid(t))return t;let i=t.pos,a=null;for(let r=t.depth;;r--){let o=t.node(r);if(n>0?t.indexAfter(r)<o.childCount:t.index(r)>0){a=o.child(n>0?t.indexAfter(r):t.index(r)-1);break}else if(r==0)return null;i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}for(;;){let o=n>0?a.firstChild:a.lastChild;if(!o){if(a.isAtom&&!a.isText&&!j.isSelectable(a)){t=t.doc.resolve(i+a.nodeSize*n),r=!1;continue search}break}a=o,i+=n;let s=t.doc.resolve(i);if(e.valid(s))return s}return null}}};K.prototype.visible=!1,K.findFrom=K.findGapCursorFrom,k.jsonID(`gapcursor`,K);var Fo=class e{constructor(e){this.pos=e}map(t){return new e(t.map(this.pos))}resolve(e){let t=e.resolve(this.pos);return K.valid(t)?new K(t):k.near(t)}};function Io(e){return e.isAtom||e.spec.isolating||e.spec.createGapCursor}function Lo(e){for(let t=e.depth;t>=0;t--){let n=e.index(t),r=e.node(t);if(n==0){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n-1);;e=e.lastChild){if(e.childCount==0&&!e.inlineContent||Io(e.type))return!0;if(e.inlineContent)return!1}}return!0}function Ro(e){for(let t=e.depth;t>=0;t--){let n=e.indexAfter(t),r=e.node(t);if(n==r.childCount){if(r.type.spec.isolating)return!0;continue}for(let e=r.child(n);;e=e.firstChild){if(e.childCount==0&&!e.inlineContent||Io(e.type))return!0;if(e.inlineContent)return!1}}return!0}function zo(){return new N({props:{decorations:Wo,createSelectionBetween(e,t,n){return t.pos==n.pos&&K.valid(n)?new K(n):null},handleClick:Ho,handleKeyDown:Bo,handleDOMEvents:{beforeinput:Uo}}})}var Bo=Xa({ArrowLeft:Vo(`horiz`,-1),ArrowRight:Vo(`horiz`,1),ArrowUp:Vo(`vert`,-1),ArrowDown:Vo(`vert`,1)});function Vo(e,t){let n=e==`vert`?t>0?`down`:`up`:t>0?`right`:`left`;return function(e,r,i){let a=e.selection,o=t>0?a.$to:a.$from,s=a.empty;if(a instanceof A){if(!i.endOfTextblock(n)||o.depth==0)return!1;s=!1,o=e.doc.resolve(t>0?o.after():o.before())}let c=K.findGapCursorFrom(o,t,s);return c?(r&&r(e.tr.setSelection(new K(c))),!0):!1}}function Ho(e,t,n){if(!e||!e.editable)return!1;let r=e.state.doc.resolve(t);if(!K.valid(r))return!1;let i=e.posAtCoords({left:n.clientX,top:n.clientY});return i&&i.inside>-1&&j.isSelectable(e.state.doc.nodeAt(i.inside))?!1:(e.dispatch(e.state.tr.setSelection(new K(r))),!0)}function Uo(e,t){if(t.inputType!=`insertCompositionText`||!(e.state.selection instanceof K))return!1;let{$from:n}=e.state.selection,r=n.parent.contentMatchAt(n.index()).findWrapping(e.state.schema.nodes.text);if(!r)return!1;let i=m.d.empty;for(let e=r.length-1;e>=0;e--)i=m.d.from(r[e].createAndFill(null,i));let a=e.state.tr.replace(n.pos,n.pos,new m.v(i,0,0));return a.setSelection(A.near(a.doc.resolve(n.pos+1))),e.dispatch(a),!1}function Wo(e){if(!(e.selection instanceof K))return null;let t=document.createElement(`div`);return t.className=`ProseMirror-gapcursor`,H.create(e.doc,[V.widget(e.selection.head,t,{key:`gapcursor`})])}function Go(e){for(let t=0;t<e.edgeCount;t++){let{type:n}=e.edge(t);if(n.isTextblock&&!n.hasRequiredAttrs())return n}throw Error(`No default textblock found.`)}var Ko=`[data-class=ui-select]{min-inline-size:120px;margin-block:-4px}.ui-divider{block-size:20px}.ui-button-group{gap:4px;display:flex}.ui-tooltip,.ui-menu{--_popup-display:contents;display:contents}.ui-tooltip-wrapper{display:contents}`,qo=class{constructor(e){this.plugin=new N({state:{init:()=>e,apply:(e,t)=>{let n=e.getMeta(this.plugin);return n===void 0?t:n}}})}getValue(e){return this.plugin.getState(e.state)}setValue(e,t){e.dispatchTransaction(e.tr.setMeta(this.plugin,t))}},Jo=`.ProseMirror{padding:var(--editor-padding-block) var(--editor-padding-inline);outline:none;flex:1}.ProseMirror-selectednode{--focus-stroke-gap-color:transparent;--focus-border-radius:2px;outline:none;position:relative}.ProseMirror-selectednode:after{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));border-radius:var(--focus-border-radius,inherit);block-size:calc(100% + var(--focus-block-size-addition,4px));content:"";inline-size:calc(100% + var(--focus-block-size-addition,4px));display:block;position:absolute;inset-block-start:50%;inset-inline-start:50%;transform:translate(-50%,-50%)}`,Yo=200,q=function(){};q.prototype.append=function(e){return e.length?(e=q.from(e),!this.length&&e||e.length<Yo&&this.leafAppend(e)||this.length<Yo&&e.leafPrepend(this)||this.appendInner(e)):this},q.prototype.prepend=function(e){return e.length?q.from(e).append(this):this},q.prototype.appendInner=function(e){return new Zo(this,e)},q.prototype.slice=function(e,t){return e===void 0&&(e=0),t===void 0&&(t=this.length),e>=t?q.empty:this.sliceInner(Math.max(0,e),Math.min(this.length,t))},q.prototype.get=function(e){if(!(e<0||e>=this.length))return this.getInner(e)},q.prototype.forEach=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length),t<=n?this.forEachInner(e,t,n,0):this.forEachInvertedInner(e,t,n,0)},q.prototype.map=function(e,t,n){t===void 0&&(t=0),n===void 0&&(n=this.length);var r=[];return this.forEach(function(t,n){return r.push(e(t,n))},t,n),r},q.from=function(e){return e instanceof q?e:e&&e.length?new Xo(e):q.empty};var Xo=function(e){function t(t){e.call(this),this.values=t}e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t;var n={length:{configurable:!0},depth:{configurable:!0}};return t.prototype.flatten=function(){return this.values},t.prototype.sliceInner=function(e,n){return e==0&&n==this.length?this:new t(this.values.slice(e,n))},t.prototype.getInner=function(e){return this.values[e]},t.prototype.forEachInner=function(e,t,n,r){for(var i=t;i<n;i++)if(e(this.values[i],r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){for(var i=t-1;i>=n;i--)if(e(this.values[i],r+i)===!1)return!1},t.prototype.leafAppend=function(e){if(this.length+e.length<=Yo)return new t(this.values.concat(e.flatten()))},t.prototype.leafPrepend=function(e){if(this.length+e.length<=Yo)return new t(e.flatten().concat(this.values))},n.length.get=function(){return this.values.length},n.depth.get=function(){return 0},Object.defineProperties(t.prototype,n),t}(q);q.empty=new Xo([]);var Zo=function(e){function t(t,n){e.call(this),this.left=t,this.right=n,this.length=t.length+n.length,this.depth=Math.max(t.depth,n.depth)+1}return e&&(t.__proto__=e),t.prototype=Object.create(e&&e.prototype),t.prototype.constructor=t,t.prototype.flatten=function(){return this.left.flatten().concat(this.right.flatten())},t.prototype.getInner=function(e){return e<this.left.length?this.left.get(e):this.right.get(e-this.left.length)},t.prototype.forEachInner=function(e,t,n,r){var i=this.left.length;if(t<i&&this.left.forEachInner(e,t,Math.min(n,i),r)===!1||n>i&&this.right.forEachInner(e,Math.max(t-i,0),Math.min(this.length,n)-i,r+i)===!1)return!1},t.prototype.forEachInvertedInner=function(e,t,n,r){var i=this.left.length;if(t>i&&this.right.forEachInvertedInner(e,t-i,Math.max(n,i)-i,r+i)===!1||n<i&&this.left.forEachInvertedInner(e,Math.min(t,i),n,r)===!1)return!1},t.prototype.sliceInner=function(e,t){if(e==0&&t==this.length)return this;var n=this.left.length;return t<=n?this.left.slice(e,t):e>=n?this.right.slice(e-n,t-n):this.left.slice(e,n).append(this.right.slice(0,t-n))},t.prototype.leafAppend=function(e){var n=this.right.leafAppend(e);if(n)return new t(this.left,n)},t.prototype.leafPrepend=function(e){var n=this.left.leafPrepend(e);if(n)return new t(n,this.right)},t.prototype.appendInner=function(e){return this.left.depth>=Math.max(this.right.depth,e.depth)+1?new t(this.left,new t(this.right,e)):new t(this,e)},t}(q),Qo=500,$o=class e{constructor(e,t){this.items=e,this.eventCount=t}popEvent(t,n){if(this.eventCount==0)return null;let r=this.items.length;for(;;r--)if(this.items.get(r-1).selection){--r;break}let i,a;n&&(i=this.remapping(r,this.items.length),a=i.maps.length);let o=t.tr,s,c,l=[],u=[];return this.items.forEach((t,n)=>{if(!t.step){i||(i=this.remapping(r,n+1),a=i.maps.length),a--,u.push(t);return}if(i){u.push(new ts(t.map));let e=t.step.map(i.slice(a)),n;e&&o.maybeStep(e).doc&&(n=o.mapping.maps[o.mapping.maps.length-1],l.push(new ts(n,void 0,void 0,l.length+u.length))),a--,n&&i.appendMap(n,a)}else o.maybeStep(t.step);if(t.selection)return s=i?t.selection.map(i.slice(a)):t.selection,c=new e(this.items.slice(0,r).append(u.reverse().concat(l)),this.eventCount-1),!1},this.items.length,0),{remaining:c,transform:o,selection:s}}addTransform(t,n,r,i){let a=[],o=this.eventCount,s=this.items,c=!i&&s.length?s.get(s.length-1):null;for(let e=0;e<t.steps.length;e++){let r=t.steps[e].invert(t.docs[e]),l=new ts(t.mapping.maps[e],r,n),u;(u=c&&c.merge(l))&&(l=u,e?a.pop():s=s.slice(0,s.length-1)),a.push(l),n&&=(o++,void 0),i||(c=l)}let l=o-r.depth;return l>rs&&(s=es(s,l),o-=l),new e(s.append(a),o)}remapping(e,t){let n=new me;return this.items.forEach((t,r)=>{let i=t.mirrorOffset!=null&&r-t.mirrorOffset>=e?n.maps.length-t.mirrorOffset:void 0;n.appendMap(t.map,i)},e,t),n}addMaps(t){return this.eventCount==0?this:new e(this.items.append(t.map(e=>new ts(e))),this.eventCount)}rebased(t,n){if(!this.eventCount)return this;let r=[],i=Math.max(0,this.items.length-n),a=t.mapping,o=t.steps.length,s=this.eventCount;this.items.forEach(e=>{e.selection&&s--},i);let c=n;this.items.forEach(e=>{let n=a.getMirror(--c);if(n==null)return;o=Math.min(o,n);let i=a.maps[n];if(e.step){let o=t.steps[n].invert(t.docs[n]),l=e.selection&&e.selection.map(a.slice(c+1,n));l&&s++,r.push(new ts(i,o,l))}else r.push(new ts(i))},i);let l=[];for(let e=n;e<o;e++)l.push(new ts(a.maps[e]));let u=new e(this.items.slice(0,i).append(l).append(r),s);return u.emptyItemCount()>Qo&&(u=u.compress(this.items.length-r.length)),u}emptyItemCount(){let e=0;return this.items.forEach(t=>{t.step||e++}),e}compress(t=this.items.length){let n=this.remapping(0,t),r=n.maps.length,i=[],a=0;return this.items.forEach((e,o)=>{if(o>=t)i.push(e),e.selection&&a++;else if(e.step){let t=e.step.map(n.slice(r)),o=t&&t.getMap();if(r--,o&&n.appendMap(o,r),t){let s=e.selection&&e.selection.map(n.slice(r));s&&a++;let c=new ts(o.invert(),t,s),l,u=i.length-1;(l=i.length&&i[u].merge(c))?i[u]=l:i.push(c)}}else e.map&&r--},this.items.length,0),new e(q.from(i.reverse()),a)}};$o.empty=new $o(q.empty,0);function es(e,t){let n;return e.forEach((e,r)=>{if(e.selection&&t--==0)return n=r,!1}),e.slice(n)}var ts=class e{constructor(e,t,n,r){this.map=e,this.step=t,this.selection=n,this.mirrorOffset=r}merge(t){if(this.step&&t.step&&!t.selection){let n=t.step.merge(this.step);if(n)return new e(n.getMap().invert(),n,this.selection)}}},ns=class{constructor(e,t,n,r,i){this.done=e,this.undone=t,this.prevRanges=n,this.prevTime=r,this.prevComposition=i}},rs=20;function is(e,t,n,r){let i=n.getMeta(ms),a;if(i)return i.historyState;n.getMeta(hs)&&(e=new ns(e.done,e.undone,null,0,-1));let o=n.getMeta(`appendedTransaction`);if(n.steps.length==0)return e;if(o&&o.getMeta(ms))return o.getMeta(ms).redo?new ns(e.done.addTransform(n,void 0,r,fs(t)),e.undone,ss(n.mapping.maps),e.prevTime,e.prevComposition):new ns(e.done,e.undone.addTransform(n,void 0,r,fs(t)),null,e.prevTime,e.prevComposition);if(n.getMeta(`addToHistory`)!==!1&&!(o&&o.getMeta(`addToHistory`)===!1)){let i=n.getMeta(`composition`),a=e.prevTime==0||!o&&e.prevComposition!=i&&(e.prevTime<(n.time||0)-r.newGroupDelay||!as(n,e.prevRanges)),s=o?cs(e.prevRanges,n.mapping):ss(n.mapping.maps);return new ns(e.done.addTransform(n,a?t.selection.getBookmark():void 0,r,fs(t)),$o.empty,s,n.time,i??e.prevComposition)}else if(a=n.getMeta(`rebased`))return new ns(e.done.rebased(n,a),e.undone.rebased(n,a),cs(e.prevRanges,n.mapping),e.prevTime,e.prevComposition);else return new ns(e.done.addMaps(n.mapping.maps),e.undone.addMaps(n.mapping.maps),cs(e.prevRanges,n.mapping),e.prevTime,e.prevComposition)}function as(e,t){if(!t)return!1;if(!e.docChanged)return!0;let n=!1;return e.mapping.maps[0].forEach((e,r)=>{for(let i=0;i<t.length;i+=2)e<=t[i+1]&&r>=t[i]&&(n=!0)}),n}function ss(e){let t=[];for(let n=e.length-1;n>=0&&t.length==0;n--)e[n].forEach((e,n,r,i)=>t.push(r,i));return t}function cs(e,t){if(!e)return null;let n=[];for(let r=0;r<e.length;r+=2){let i=t.map(e[r],1),a=t.map(e[r+1],-1);i<=a&&n.push(i,a)}return n}function ls(e,t,n){let r=fs(t),i=ms.get(t).spec.config,a=(n?e.undone:e.done).popEvent(t,r);if(!a)return null;let o=a.selection.resolve(a.transform.doc),s=(n?e.done:e.undone).addTransform(a.transform,t.selection.getBookmark(),i,r),c=new ns(n?s:a.remaining,n?a.remaining:s,null,0,-1);return a.transform.setSelection(o).setMeta(ms,{redo:n,historyState:c})}var us=!1,ds=null;function fs(e){let t=e.plugins;if(ds!=t){us=!1,ds=t;for(let e=0;e<t.length;e++)if(t[e].spec.historyPreserveItems){us=!0;break}}return us}function ps(e){return e.setMeta(hs,!0)}var ms=new wt(`history`),hs=new wt(`closeHistory`);function gs(e={}){return e={depth:e.depth||100,newGroupDelay:e.newGroupDelay||500},new N({key:ms,state:{init(){return new ns($o.empty,$o.empty,null,0,-1)},apply(t,n,r){return is(n,r,t,e)}},config:e,props:{handleDOMEvents:{beforeinput(e,t){let n=t.inputType,r=n==`historyUndo`?vs:n==`historyRedo`?ys:null;return!r||!e.editable?!1:(t.preventDefault(),r(e.state,e.dispatch))}}}})}function _s(e,t){return(n,r)=>{let i=ms.getState(n);if(!i||(e?i.undone:i.done).eventCount==0)return!1;if(r){let a=ls(i,n,e);a&&r(t?a.scrollIntoView():a)}return!0}}var vs=_s(!1,!0),ys=_s(!0,!0),bs=e=>typeof e==`function`,xs=(e,t,n)=>[e,t,n],Ss=class{constructor(e,t,n){this.view=e,this.rte=t,this.props=n,this.bindings=[]}evalProp(e){return bs(e)?e(this):e}bindProp(e,t){if(e!==void 0)if(bs(e)){let n=()=>t(e(this));this.bindings.push(n),n()}else t(e)}updateBindings(){for(let e of this.bindings)e()}bindToEl(e,t={},n=[],r=[]){for(let n in t)this.bindProp(t[n],t=>{e[n]=t});for(let[t,r,i]of n)r&&e.addEventListener(t,i(r));for(let t of r)e.appendChild(t)}},J=(e,t)=>{let n=document.createElement(`div`);return e.bindToEl(n,{className:t.className,slot:t.slot},[],t.children),n},Cs=(e,t)=>{let n=document.createElement(`a`);return e.bindToEl(n,{href:t.href,target:t.target,rel:t.rel,className:t.className},[],t.children),n},ws=new WeakMap,Ts=(e,t)=>{let n=e.rte.createComponent(s.r);n.setAttribute(`exportparts`,`vvd-theme-alternate`),e.bindToEl(n,{className:`ui-tooltip`,text:t.label,placement:e.props.popupPlacement}),e.bindProp(t.enabled,e=>{e||(n.open=!1),n.anchor=e?t.anchor:void 0});let r=J(e,{className:`ui-tooltip-wrapper`,slot:t.slot,children:[t.anchor,n]});return ws.set(r,t.anchor),r},Y=(e,t)=>{let n=()=>e.evalProp(t.variant)??`toolbar`,r=()=>n()===`toolbar`?`super-condensed`:`condensed`,i=()=>n()===`popover-primary`?`outlined`:`ghost-light`,o=()=>e.evalProp(t.active)?`filled`:i(),s=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),c=e.rte.createComponent(a.i);return e.bindToEl(c,{size:r,appearance:o,disabled:s,icon:t.icon,autofocus:t.autofocus,connotation:t.connotation,[t.icon?`ariaLabel`:`label`]:t.label},[xs(`click`,t.onClick,t=>()=>{t()||e.view.focus()})]),Ts(e,{enabled:()=>!!(e.evalProp(t.icon)&&!e.evalProp(t.noTooltip)&&!s()),label:t.label,anchor:c,slot:t.slot})},Es=(e,t)=>{let n=e.rte.createComponent(g.r);e.bindToEl(n,{className:`ui-menu`,autoDismiss:!0,ariaLabel:t.label,anchor:ws.get(t.trigger)??t.trigger,placement:e.props.popupPlacement,offset:()=>e.evalProp(e.props.menuOffset)??null},[],t.children);let r=document.createDocumentFragment();return r.appendChild(t.trigger),r.appendChild(n),r},Ds=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(h.i);return e.bindToEl(r,{text:t.text,checked:t.checked,disabled:n,controlType:`radio`,checkedAppearance:`tick-only`},[xs(`change`,t.onSelect,n=>()=>{r.checked&&!r.disabled&&e.evalProp(t.checked)!==r.checked&&(n(),e.view.focus())})]),r},Os=(e,t)=>J(e,{className:`ui-button-group`,children:t.children});function ks(e,t){let{from:n,$from:r,to:i,empty:a}=e.selection;return a?!!t.isInSet(e.storedMarks||r.marks()):e.doc.rangeHasMark(n,i,t)}var As=(e,t)=>Y(e,{label:t.label,icon:t.icon,active:()=>ks(e.view.state,t.markType),disabled:()=>!Co(t.markType)(e.view.state),onClick:()=>{Co(t.markType)(e.view.state,e.view.dispatch)}}),js=(e,t)=>{let n=()=>!!(e.evalProp(e.props.disabled)||e.evalProp(t.disabled)),r=e.rte.createComponent(u.r);return e.bindToEl(r,{value:t.value,text:t.text,disabled:n}),r},Ms=(e,t)=>{let n=()=>!!e.evalProp(e.props.disabled),r=e.rte.createComponent(d.r);r.setAttribute(`data-class`,`ui-select`),e.bindToEl(r,{placeholder:` `,ariaLabel:t.label,appearance:`ghost`,disabled:n},[xs(`change`,t.onSelect,t=>()=>{let n=r.value;n&&(t(n),e.view.focus())})],t.children),queueMicrotask(()=>{e.bindProp(t.value,e=>r.value=e)});let i=!1;return r.addEventListener(`vwc-popup:open`,()=>{i=!0,e.updateBindings()}),r.addEventListener(`vwc-popup:close`,()=>{i=!1,e.updateBindings()}),Ts(e,{enabled:()=>!i&&!n(),label:t.label,anchor:r})},Ns=e=>{let t=e.rte.createComponent(p.t);return e.bindToEl(t,{className:`ui-divider`,orientation:`vertical`}),t},Ps=(e,t)=>{let n=e.rte.createComponent(l.r);return e.bindToEl(n,{label:t.label,value:t.value,placeholder:t.placeholder,slot:t.slot,autofocus:t.autofocus,type:t.type},[xs(`input`,t.onInput,e=>()=>{e(n.value)})]),n},Fs=(e,t)=>{let n=document.createTextNode(``);return e.bindToEl(n,{textContent:t.text}),n},Is=(e,t)=>{let n=document.createElement(`slot`);n.name=t.name;let r=null,i=[];function a(){for(let{el:e,type:t,handler:n}of i)e.removeEventListener(t,n);i.length=0,r=null}for(let[n,i]of Object.entries(t.assignedProps))e.bindProp(i,e=>{r&&(r[n]=e)});function o(n){for(let[r,i]of Object.entries(t.assignedProps))n[r]=e.evalProp(i);for(let[r,a]of Object.entries(t.assignedEvents)){let t=t=>{a(t),e.view.focus()};n.addEventListener(r,t),i.push({el:n,type:r,handler:t})}}let s=()=>{let e=n.assignedElements({flatten:!0})[0];e!==r&&(a(),e&&(r=e,o(e)))};return n.addEventListener(`slotchange`,s),queueMicrotask(s),n},Ls=class extends m.r{constructor(...e){super(...e),this.name=`RteHistoryFeature`}getPlugins(){return[this.contribution(gs()),this.contribution(G({"Mod-z":vs,"Ctrl-y":ys,"Cmd-Z":ys}))]}getToolbarItems(){return[this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.undo,icon:`undo-line`,disabled:e=>!vs(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;vs(t,n)}})},1),this.contribution({section:`history`,render:e=>Y(e,{label:e=>e.rte.getLocale().richTextEditor.redo,icon:`redo-line`,disabled:e=>!ys(e.view.state),onClick:()=>{let{state:t,dispatch:n}=e.view;ys(t,n)}})},2)]}},Rs=class extends m.r{constructor(...e){super(...e),this.name=`RteForeignHtmlFeature`}getPlugins(e){return[this.contribution(new N({props:{transformPastedHTML:t=>e.foreignHtmlParser[m.c].transform(t),clipboardParser:e.foreignHtmlParser[m.c].parser,clipboardSerializer:e.foreignHtmlSerializer[m.c].serializer}}))]}},zs=e=>{if(e.parentOffset!==e.parent.content.size)return null;let t=e.nodeBefore;return t&&t.isInline&&t.isAtom&&!t.isText?{}:null},Bs=class extends m.r{constructor(...e){super(...e),this.name=`RteCursorFix`}getPlugins(e){let t=[zs];for(let n of Object.values(e.schema.marks)){let e=n.spec;e.cursorFix&&t.push(e.cursorFix)}return[this.contribution(new N({props:{decorations:e=>{let{$cursor:n}=e.selection;if(!n)return null;let r=null;for(let i of t){let t=i(n,e);t&&Object.assign(r??={},t)}return r?H.create(e.doc,[V.widget(n.pos,()=>{let e=document.createElement(`span`);e.textContent=`​`;for(let[t,n]of Object.entries(r))e.style.setProperty(t,n);return e},{side:-1})]):null}}}))]}};m.a(Bs);var Vs=new N({state:{init(){return null},apply(e,t){return e.getMeta(Vs)||t}}}),Hs=class extends m.r{constructor(...e){super(...e),this.name=`RteCore`,this.disabled=new qo(!1)}getStyles(){return[this.contribution(Mo),this.contribution(Jo),this.contribution(Ko)]}getPlugins(e){let t=Eo(so,uo,fo,po((t,n,r)=>n?{type:Go(r.node(r.depth-1).contentMatchAt(r.indexAfter(r.depth-1))),attrs:e.textblockAttrs.extractFromNode(t)}:{type:t.type,attrs:t.attrs}));return[this.contribution(this.disabled.plugin),this.contribution(new N({props:{editable:()=>!this.disabled.getValue(e),handleDOMEvents:{click:(t,n)=>this.disabled.getValue(e)?(n.preventDefault(),!0):!1}},view:t=>{let n=t.dom.getRootNode().querySelector(`.popovers`),r=()=>{n.classList.toggle(`popovers--disabled`,this.disabled.getValue(e))};return r(),{update:()=>{r()}}}})),this.contribution(G({...jo,Enter:t,"Shift-Enter":t})),this.contribution(No()),this.contribution(zo()),this.contribution(Vs)]}getFeatures(){return[this,new Ls,new Rs,new Bs]}};m.a(Hs);var{entries:Us,setPrototypeOf:Ws,isFrozen:Gs,getPrototypeOf:Ks,getOwnPropertyDescriptor:qs}=Object,{freeze:X,seal:Js,create:Ys}=Object,{apply:Xs,construct:Zs}=typeof Reflect<`u`&&Reflect;X||=function(e){return e},Js||=function(e){return e},Xs||=function(e,t){for(var n=arguments.length,r=Array(n>2?n-2:0),i=2;i<n;i++)r[i-2]=arguments[i];return e.apply(t,r)},Zs||=function(e){for(var t=arguments.length,n=Array(t>1?t-1:0),r=1;r<t;r++)n[r-1]=arguments[r];return new e(...n)};var Qs=Q(Array.prototype.forEach),$s=Q(Array.prototype.lastIndexOf),ec=Q(Array.prototype.pop),tc=Q(Array.prototype.push),nc=Q(Array.prototype.splice),rc=Q(String.prototype.toLowerCase),ic=Q(String.prototype.toString),ac=Q(String.prototype.match),oc=Q(String.prototype.replace),sc=Q(String.prototype.indexOf),cc=Q(String.prototype.trim),lc=Q(Object.prototype.hasOwnProperty),Z=Q(RegExp.prototype.test),uc=dc(TypeError);function Q(e){return function(t){t instanceof RegExp&&(t.lastIndex=0);for(var n=arguments.length,r=Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];return Xs(e,t,r)}}function dc(e){return function(){for(var t=arguments.length,n=Array(t),r=0;r<t;r++)n[r]=arguments[r];return Zs(e,n)}}function $(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:rc;Ws&&Ws(e,null);let r=t.length;for(;r--;){let i=t[r];if(typeof i==`string`){let e=n(i);e!==i&&(Gs(t)||(t[r]=e),i=e)}e[i]=!0}return e}function fc(e){for(let t=0;t<e.length;t++)lc(e,t)||(e[t]=null);return e}function pc(e){let t=Ys(null);for(let[n,r]of Us(e))lc(e,n)&&(Array.isArray(r)?t[n]=fc(r):r&&typeof r==`object`&&r.constructor===Object?t[n]=pc(r):t[n]=r);return t}function mc(e,t){for(;e!==null;){let n=qs(e,t);if(n){if(n.get)return Q(n.get);if(typeof n.value==`function`)return Q(n.value)}e=Ks(e)}function n(){return null}return n}var hc=X(`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`.split(`.`)),gc=X(`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`.split(`.`)),_c=X([`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`]),vc=X([`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`]),yc=X(`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`.split(`.`)),bc=X([`maction`,`maligngroup`,`malignmark`,`mlongdiv`,`mscarries`,`mscarry`,`msgroup`,`mstack`,`msline`,`msrow`,`semantics`,`annotation`,`annotation-xml`,`mprescripts`,`none`]),xc=X([`#text`]),Sc=X(`accept.action.align.alt.autocapitalize.autocomplete.autopictureinpicture.autoplay.background.bgcolor.border.capture.cellpadding.cellspacing.checked.cite.class.clear.color.cols.colspan.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.slot`.split(`.`)),Cc=X(`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.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.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-rendering.textlength.type.u1.u2.unicode.values.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`.split(`.`)),wc=X(`accent.accentunder.align.bevelled.close.columnsalign.columnlines.columnspan.denomalign.depth.dir.display.displaystyle.encoding.fence.frame.height.href.id.largeop.length.linethickness.lspace.lquote.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`.split(`.`)),Tc=X([`xlink:href`,`xml:id`,`xlink:title`,`xml:space`,`xmlns:xlink`]),Ec=Js(/\{\{[\w\W]*|[\w\W]*\}\}/gm),Dc=Js(/<%[\w\W]*|[\w\W]*%>/gm),Oc=Js(/\$\{[\w\W]*/gm),kc=Js(/^data-[\-\w.\u00B7-\uFFFF]+$/),Ac=Js(/^aria-[\-\w]+$/),jc=Js(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|matrix):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),Mc=Js(/^(?:\w+script|data):/i),Nc=Js(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),Pc=Js(/^html$/i),Fc=Js(/^[a-z][.\w]*(-[.\w]+)+$/i),Ic=Object.freeze({__proto__:null,ARIA_ATTR:Ac,ATTR_WHITESPACE:Nc,CUSTOM_ELEMENT:Fc,DATA_ATTR:kc,DOCTYPE_NAME:Pc,ERB_EXPR:Dc,IS_ALLOWED_URI:jc,IS_SCRIPT_OR_DATA:Mc,MUSTACHE_EXPR:Ec,TMPLIT_EXPR:Oc}),Lc={element:1,attribute:2,text:3,cdataSection:4,entityReference:5,entityNode:6,progressingInstruction:7,comment:8,document:9,documentType:10,documentFragment:11,notation:12},Rc=function(){return typeof window>`u`?null:window},zc=function(e,t){if(typeof e!=`object`||typeof e.createPolicy!=`function`)return null;let n=null,r=`data-tt-policy-suffix`;t&&t.hasAttribute(r)&&(n=t.getAttribute(r));let i=`dompurify`+(n?`#`+n:``);try{return e.createPolicy(i,{createHTML(e){return e},createScriptURL(e){return e}})}catch{return console.warn(`TrustedTypes policy `+i+` could not be created.`),null}},Bc=function(){return{afterSanitizeAttributes:[],afterSanitizeElements:[],afterSanitizeShadowDOM:[],beforeSanitizeAttributes:[],beforeSanitizeElements:[],beforeSanitizeShadowDOM:[],uponSanitizeAttribute:[],uponSanitizeElement:[],uponSanitizeShadowNode:[]}};function Vc(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:Rc(),t=e=>Vc(e);if(t.version=`3.3.1`,t.removed=[],!e||!e.document||e.document.nodeType!==Lc.document||!e.Element)return t.isSupported=!1,t;let{document:n}=e,r=n,i=r.currentScript,{DocumentFragment:a,HTMLTemplateElement:o,Node:s,Element:c,NodeFilter:l,NamedNodeMap:u=e.NamedNodeMap||e.MozNamedAttrMap,HTMLFormElement:d,DOMParser:f,trustedTypes:p}=e,m=c.prototype,h=mc(m,`cloneNode`),g=mc(m,`remove`),ee=mc(m,`nextSibling`),te=mc(m,`childNodes`),_=mc(m,`parentNode`);if(typeof o==`function`){let e=n.createElement(`template`);e.content&&e.content.ownerDocument&&(n=e.content.ownerDocument)}let v,ne=``,{implementation:y,createNodeIterator:re,createDocumentFragment:ie,getElementsByTagName:ae}=n,{importNode:oe}=r,b=Bc();t.isSupported=typeof Us==`function`&&typeof _==`function`&&y&&y.createHTMLDocument!==void 0;let{MUSTACHE_EXPR:se,ERB_EXPR:ce,TMPLIT_EXPR:le,DATA_ATTR:ue,ARIA_ATTR:de,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:pe,CUSTOM_ELEMENT:me}=Ic,{IS_ALLOWED_URI:he}=Ic,x=null,S=$({},[...hc,...gc,..._c,...yc,...xc]),C=null,ge=$({},[...Sc,...Cc,...wc,...Tc]),w=Object.seal(Ys(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),_e=null,ve=null,T=Object.seal(Ys(null,{tagCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeCheck:{writable:!0,configurable:!1,enumerable:!0,value:null}})),E=!0,ye=!0,be=!1,xe=!0,Se=!1,Ce=!0,we=!1,Te=!1,Ee=!1,De=!1,Oe=!1,ke=!1,Ae=!0,je=!1,Me=!0,Ne=!1,Pe={},Fe=null,Ie=$({},[`annotation-xml`,`audio`,`colgroup`,`desc`,`foreignobject`,`head`,`iframe`,`math`,`mi`,`mn`,`mo`,`ms`,`mtext`,`noembed`,`noframes`,`noscript`,`plaintext`,`script`,`style`,`svg`,`template`,`thead`,`title`,`video`,`xmp`]),Le=null,Re=$({},[`audio`,`video`,`img`,`source`,`image`,`track`]),ze=null,Be=$({},[`alt`,`class`,`for`,`id`,`label`,`name`,`pattern`,`placeholder`,`role`,`summary`,`title`,`value`,`style`,`xmlns`]),Ve=`http://www.w3.org/1998/Math/MathML`,He=`http://www.w3.org/2000/svg`,D=`http://www.w3.org/1999/xhtml`,Ue=D,We=!1,Ge=null,Ke=$({},[Ve,He,D],ic),qe=$({},[`mi`,`mo`,`mn`,`ms`,`mtext`]),Je=$({},[`annotation-xml`]),Ye=$({},[`title`,`style`,`font`,`a`,`script`]),Xe=null,Ze=[`application/xhtml+xml`,`text/html`],O=null,Qe=null,$e=n.createElement(`form`),et=function(e){return e instanceof RegExp||e instanceof Function},tt=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};if(!(Qe&&Qe===e)){if((!e||typeof e!=`object`)&&(e={}),e=pc(e),Xe=Ze.indexOf(e.PARSER_MEDIA_TYPE)===-1?`text/html`:e.PARSER_MEDIA_TYPE,O=Xe===`application/xhtml+xml`?ic:rc,x=lc(e,`ALLOWED_TAGS`)?$({},e.ALLOWED_TAGS,O):S,C=lc(e,`ALLOWED_ATTR`)?$({},e.ALLOWED_ATTR,O):ge,Ge=lc(e,`ALLOWED_NAMESPACES`)?$({},e.ALLOWED_NAMESPACES,ic):Ke,ze=lc(e,`ADD_URI_SAFE_ATTR`)?$(pc(Be),e.ADD_URI_SAFE_ATTR,O):Be,Le=lc(e,`ADD_DATA_URI_TAGS`)?$(pc(Re),e.ADD_DATA_URI_TAGS,O):Re,Fe=lc(e,`FORBID_CONTENTS`)?$({},e.FORBID_CONTENTS,O):Ie,_e=lc(e,`FORBID_TAGS`)?$({},e.FORBID_TAGS,O):pc({}),ve=lc(e,`FORBID_ATTR`)?$({},e.FORBID_ATTR,O):pc({}),Pe=lc(e,`USE_PROFILES`)?e.USE_PROFILES:!1,E=e.ALLOW_ARIA_ATTR!==!1,ye=e.ALLOW_DATA_ATTR!==!1,be=e.ALLOW_UNKNOWN_PROTOCOLS||!1,xe=e.ALLOW_SELF_CLOSE_IN_ATTR!==!1,Se=e.SAFE_FOR_TEMPLATES||!1,Ce=e.SAFE_FOR_XML!==!1,we=e.WHOLE_DOCUMENT||!1,De=e.RETURN_DOM||!1,Oe=e.RETURN_DOM_FRAGMENT||!1,ke=e.RETURN_TRUSTED_TYPE||!1,Ee=e.FORCE_BODY||!1,Ae=e.SANITIZE_DOM!==!1,je=e.SANITIZE_NAMED_PROPS||!1,Me=e.KEEP_CONTENT!==!1,Ne=e.IN_PLACE||!1,he=e.ALLOWED_URI_REGEXP||jc,Ue=e.NAMESPACE||D,qe=e.MATHML_TEXT_INTEGRATION_POINTS||qe,Je=e.HTML_INTEGRATION_POINTS||Je,w=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&et(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(w.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&et(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(w.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements==`boolean`&&(w.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),Se&&(ye=!1),Oe&&(De=!0),Pe&&(x=$({},xc),C=[],Pe.html===!0&&($(x,hc),$(C,Sc)),Pe.svg===!0&&($(x,gc),$(C,Cc),$(C,Tc)),Pe.svgFilters===!0&&($(x,_c),$(C,Cc),$(C,Tc)),Pe.mathMl===!0&&($(x,yc),$(C,wc),$(C,Tc))),e.ADD_TAGS&&(typeof e.ADD_TAGS==`function`?T.tagCheck=e.ADD_TAGS:(x===S&&(x=pc(x)),$(x,e.ADD_TAGS,O))),e.ADD_ATTR&&(typeof e.ADD_ATTR==`function`?T.attributeCheck=e.ADD_ATTR:(C===ge&&(C=pc(C)),$(C,e.ADD_ATTR,O))),e.ADD_URI_SAFE_ATTR&&$(ze,e.ADD_URI_SAFE_ATTR,O),e.FORBID_CONTENTS&&(Fe===Ie&&(Fe=pc(Fe)),$(Fe,e.FORBID_CONTENTS,O)),e.ADD_FORBID_CONTENTS&&(Fe===Ie&&(Fe=pc(Fe)),$(Fe,e.ADD_FORBID_CONTENTS,O)),Me&&(x[`#text`]=!0),we&&$(x,[`html`,`head`,`body`]),x.table&&($(x,[`tbody`]),delete _e.tbody),e.TRUSTED_TYPES_POLICY){if(typeof e.TRUSTED_TYPES_POLICY.createHTML!=`function`)throw uc(`TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.`);if(typeof e.TRUSTED_TYPES_POLICY.createScriptURL!=`function`)throw uc(`TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.`);v=e.TRUSTED_TYPES_POLICY,ne=v.createHTML(``)}else v===void 0&&(v=zc(p,i)),v!==null&&typeof ne==`string`&&(ne=v.createHTML(``));X&&X(e),Qe=e}},nt=$({},[...gc,..._c,...vc]),rt=$({},[...yc,...bc]),k=function(e){let t=_(e);(!t||!t.tagName)&&(t={namespaceURI:Ue,tagName:`template`});let n=rc(e.tagName),r=rc(t.tagName);return Ge[e.namespaceURI]?e.namespaceURI===He?t.namespaceURI===D?n===`svg`:t.namespaceURI===Ve?n===`svg`&&(r===`annotation-xml`||qe[r]):!!nt[n]:e.namespaceURI===Ve?t.namespaceURI===D?n===`math`:t.namespaceURI===He?n===`math`&&Je[r]:!!rt[n]:e.namespaceURI===D?t.namespaceURI===He&&!Je[r]||t.namespaceURI===Ve&&!qe[r]?!1:!rt[n]&&(Ye[n]||!nt[n]):!!(Xe===`application/xhtml+xml`&&Ge[e.namespaceURI]):!1},it=function(e){tc(t.removed,{element:e});try{_(e).removeChild(e)}catch{g(e)}},at=function(e,n){try{tc(t.removed,{attribute:n.getAttributeNode(e),from:n})}catch{tc(t.removed,{attribute:null,from:n})}if(n.removeAttribute(e),e===`is`)if(De||Oe)try{it(n)}catch{}else try{n.setAttribute(e,``)}catch{}},ot=function(e){let t=null,r=null;if(Ee)e=`<remove></remove>`+e;else{let t=ac(e,/^[\r\n\t ]+/);r=t&&t[0]}Xe===`application/xhtml+xml`&&Ue===D&&(e=`<html xmlns="http://www.w3.org/1999/xhtml"><head></head><body>`+e+`</body></html>`);let i=v?v.createHTML(e):e;if(Ue===D)try{t=new f().parseFromString(i,Xe)}catch{}if(!t||!t.documentElement){t=y.createDocument(Ue,`template`,null);try{t.documentElement.innerHTML=We?ne:i}catch{}}let a=t.body||t.documentElement;return e&&r&&a.insertBefore(n.createTextNode(r),a.childNodes[0]||null),Ue===D?ae.call(t,we?`html`:`body`)[0]:we?t.documentElement:a},A=function(e){return re.call(e.ownerDocument||e,e,l.SHOW_ELEMENT|l.SHOW_COMMENT|l.SHOW_TEXT|l.SHOW_PROCESSING_INSTRUCTION|l.SHOW_CDATA_SECTION,null)},st=function(e){return e instanceof d&&(typeof e.nodeName!=`string`||typeof e.textContent!=`string`||typeof e.removeChild!=`function`||!(e.attributes instanceof u)||typeof e.removeAttribute!=`function`||typeof e.setAttribute!=`function`||typeof e.namespaceURI!=`string`||typeof e.insertBefore!=`function`||typeof e.hasChildNodes!=`function`)},j=function(e){return typeof s==`function`&&e instanceof s};function ct(e,n,r){Qs(e,e=>{e.call(t,n,r,Qe)})}let M=function(e){let n=null;if(ct(b.beforeSanitizeElements,e,null),st(e))return it(e),!0;let r=O(e.nodeName);if(ct(b.uponSanitizeElement,e,{tagName:r,allowedTags:x}),Ce&&e.hasChildNodes()&&!j(e.firstElementChild)&&Z(/<[/\w!]/g,e.innerHTML)&&Z(/<[/\w!]/g,e.textContent)||e.nodeType===Lc.progressingInstruction||Ce&&e.nodeType===Lc.comment&&Z(/<[/\w]/g,e.data))return it(e),!0;if(!(T.tagCheck instanceof Function&&T.tagCheck(r))&&(!x[r]||_e[r])){if(!_e[r]&&ut(r)&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r)))return!1;if(Me&&!Fe[r]){let t=_(e)||e.parentNode,n=te(e)||e.childNodes;if(n&&t){let r=n.length;for(let i=r-1;i>=0;--i){let r=h(n[i],!0);r.__removalCount=(e.__removalCount||0)+1,t.insertBefore(r,ee(e))}}}return it(e),!0}return e instanceof c&&!k(e)||(r===`noscript`||r===`noembed`||r===`noframes`)&&Z(/<\/no(script|embed|frames)/i,e.innerHTML)?(it(e),!0):(Se&&e.nodeType===Lc.text&&(n=e.textContent,Qs([se,ce,le],e=>{n=oc(n,e,` `)}),e.textContent!==n&&(tc(t.removed,{element:e.cloneNode()}),e.textContent=n)),ct(b.afterSanitizeElements,e,null),!1)},lt=function(e,t,r){if(Ae&&(t===`id`||t===`name`)&&(r in n||r in $e))return!1;if(!(ye&&!ve[t]&&Z(ue,t))&&!(E&&Z(de,t))&&!(T.attributeCheck instanceof Function&&T.attributeCheck(t,e))){if(!C[t]||ve[t]){if(!(ut(e)&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,e)||w.tagNameCheck instanceof Function&&w.tagNameCheck(e))&&(w.attributeNameCheck instanceof RegExp&&Z(w.attributeNameCheck,t)||w.attributeNameCheck instanceof Function&&w.attributeNameCheck(t,e))||t===`is`&&w.allowCustomizedBuiltInElements&&(w.tagNameCheck instanceof RegExp&&Z(w.tagNameCheck,r)||w.tagNameCheck instanceof Function&&w.tagNameCheck(r))))return!1}else if(!ze[t]&&!Z(he,oc(r,pe,``))&&!((t===`src`||t===`xlink:href`||t===`href`)&&e!==`script`&&sc(r,`data:`)===0&&Le[e])&&!(be&&!Z(fe,oc(r,pe,``)))&&r)return!1}return!0},ut=function(e){return e!==`annotation-xml`&&ac(e,me)},dt=function(e){ct(b.beforeSanitizeAttributes,e,null);let{attributes:n}=e;if(!n||st(e))return;let r={attrName:``,attrValue:``,keepAttr:!0,allowedAttributes:C,forceKeepAttr:void 0},i=n.length;for(;i--;){let{name:a,namespaceURI:o,value:s}=n[i],c=O(a),l=s,u=a===`value`?l:cc(l);if(r.attrName=c,r.attrValue=u,r.keepAttr=!0,r.forceKeepAttr=void 0,ct(b.uponSanitizeAttribute,e,r),u=r.attrValue,je&&(c===`id`||c===`name`)&&(at(a,e),u=`user-content-`+u),Ce&&Z(/((--!?|])>)|<\/(style|title|textarea)/i,u)){at(a,e);continue}if(c===`attributename`&&ac(u,`href`)){at(a,e);continue}if(r.forceKeepAttr)continue;if(!r.keepAttr){at(a,e);continue}if(!xe&&Z(/\/>/i,u)){at(a,e);continue}Se&&Qs([se,ce,le],e=>{u=oc(u,e,` `)});let d=O(e.nodeName);if(!lt(d,c,u)){at(a,e);continue}if(v&&typeof p==`object`&&typeof p.getAttributeType==`function`&&!o)switch(p.getAttributeType(d,c)){case`TrustedHTML`:u=v.createHTML(u);break;case`TrustedScriptURL`:u=v.createScriptURL(u);break}if(u!==l)try{o?e.setAttributeNS(o,a,u):e.setAttribute(a,u),st(e)?it(e):ec(t.removed)}catch{at(a,e)}}ct(b.afterSanitizeAttributes,e,null)},ft=function e(t){let n=null,r=A(t);for(ct(b.beforeSanitizeShadowDOM,t,null);n=r.nextNode();)ct(b.uponSanitizeShadowNode,n,null),M(n),dt(n),n.content instanceof a&&e(n.content);ct(b.afterSanitizeShadowDOM,t,null)};return t.sanitize=function(e){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=null,o=null,c=null,l=null;if(We=!e,We&&(e=`<!-->`),typeof e!=`string`&&!j(e))if(typeof e.toString==`function`){if(e=e.toString(),typeof e!=`string`)throw uc(`dirty is not a string, aborting`)}else throw uc(`toString is not a function`);if(!t.isSupported)return e;if(Te||tt(n),t.removed=[],typeof e==`string`&&(Ne=!1),Ne){if(e.nodeName){let t=O(e.nodeName);if(!x[t]||_e[t])throw uc(`root node is forbidden and cannot be sanitized in-place`)}}else if(e instanceof s)i=ot(`<!---->`),o=i.ownerDocument.importNode(e,!0),o.nodeType===Lc.element&&o.nodeName===`BODY`||o.nodeName===`HTML`?i=o:i.appendChild(o);else{if(!De&&!Se&&!we&&e.indexOf(`<`)===-1)return v&&ke?v.createHTML(e):e;if(i=ot(e),!i)return De?null:ke?ne:``}i&&Ee&&it(i.firstChild);let u=A(Ne?e:i);for(;c=u.nextNode();)M(c),dt(c),c.content instanceof a&&ft(c.content);if(Ne)return e;if(De){if(Oe)for(l=ie.call(i.ownerDocument);i.firstChild;)l.appendChild(i.firstChild);else l=i;return(C.shadowroot||C.shadowrootmode)&&(l=oe.call(r,l,!0)),l}let d=we?i.outerHTML:i.innerHTML;return we&&x[`!doctype`]&&i.ownerDocument&&i.ownerDocument.doctype&&i.ownerDocument.doctype.name&&Z(Pc,i.ownerDocument.doctype.name)&&(d=`<!DOCTYPE `+i.ownerDocument.doctype.name+`>
31
+ `+d),Se&&Qs([se,ce,le],e=>{d=oc(d,e,` `)}),v&&ke?v.createHTML(d):d},t.setConfig=function(){tt(arguments.length>0&&arguments[0]!==void 0?arguments[0]:{}),Te=!0},t.clearConfig=function(){Qe=null,Te=!1},t.isValidAttribute=function(e,t,n){return Qe||tt({}),lt(O(e),O(t),n)},t.addHook=function(e,t){typeof t==`function`&&tc(b[e],t)},t.removeHook=function(e,t){if(t!==void 0){let n=$s(b[e],t);return n===-1?void 0:nc(b[e],n,1)[0]}return ec(b[e])},t.removeHooks=function(e){b[e]=[]},t.removeAllHooks=function(){b=Bc()},t}var Hc=Vc(),Uc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Wc=/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp|blob):|[^a-z]|[a-z+.-]+(?:[^a-z+.\-:]|$))/i,Gc=/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g,Kc={ALLOWED_URI_REGEXP:Wc},qc=e=>{if(!Uc.test(e.replace(Gc,``)))return``;let t=document.createElement(`a`);return t.setAttribute(`href`,e),Hc.sanitize(t,{RETURN_DOM:!0,...Kc}).querySelector(`a`).getAttribute(`href`)??``},Jc=e=>{let t=document.createElement(`img`);return t.setAttribute(`src`,e),Hc.sanitize(t,{RETURN_DOM:!0,...Kc}).querySelector(`img`).getAttribute(`src`)??``},Yc=e=>e.replace(/[;!].*/,``),Xc=e=>({...e}),Zc=e=>({nodes:Object.fromEntries(Object.keys(e.nodes).map(t=>[t,(e.nodes[t].spec.parseDOM??[]).map(Xc)])),marks:Object.fromEntries(Object.keys(e.marks).map(t=>[t,(e.marks[t].spec.parseDOM??[]).map(Xc)]))}),Qc=class{constructor(e,t){this[m.c]=new $c(e[m.c],t)}parseDocument(e,t){return this[m.c].parser.parse(this.parseHtml(e,t),{preserveWhitespace:!0}).toJSON()}parseFragment(e,t){return this[m.c].parser.parseSlice(this.parseHtml(e,t),{preserveWhitespace:!0}).content.toJSON()??[]}parseHtml(e,t){let n=Hc.sanitize(e,{RETURN_DOM:!0,...Kc}),r=document.createDocumentFragment();return r.appendChild(n),t?.modifyDom?.(r),r}},$c=class{constructor(e,t){let n=Zc(e.schema);t?.modifyParseRules?.(n),this.parser=el(e.schema,n)}transform(e){return Hc.sanitize(e)}},el=(e,{marks:t,nodes:n})=>{let r=[],i=e=>e.priority??50;function a(e){let t=0;for(;t<r.length;t++){let n=r[t];if(i(n)<i(e))break}r.splice(t,0,e)}for(let e in t)t[e]?.forEach(t=>{a(t=Xc(t)),t.mark||t.ignore||t.clearMark||(t.mark=e)});for(let e in n)n[e]?.forEach(t=>{a(t=Xc(t)),t.node||t.ignore||t.mark||(t.node=e)});return new m.l(e,r)},tl=class{constructor(e,t){this[m.c]=new nl(e[m.c],t)}serializeDocument(e,t){return this[m.c].serializeFragment(e.content,t)}serializeFragment(e,t){return this[m.c].serializeFragment(e,t)}},nl=class e{constructor(t,n){this.config=t;let r=e.domSerializersFromSchema(t.schema);Object.assign(r.nodes,n?.serializers?.nodes??{}),Object.assign(r.marks,n?.serializers?.marks??{}),this.serializer=new m.u(r.nodes,r.marks)}static domSerializersFromSchema(e){let t={nodes:{},marks:{}};for(let n in e.marks){let r=e.marks[n].spec.toDOM;r&&(t.marks[n]=r)}for(let n in e.nodes){let r=e.nodes[n].spec.serializeToDOM??e.nodes[n].spec.toDOM;r&&(t.nodes[n]=r)}return t.nodes.text=e=>document.createTextNode(e.text),t}serializeFragment(e,t){let n=m.d.fromJSON(this.config.schema,e),r=this.serializer.serializeFragment(n),i=document.createDocumentFragment();i.appendChild(r),t?.modifyDom?.(i);let a=document.createElement(`div`);return a.appendChild(i),a.innerHTML}},rl=(e,t)=>{let n=e.topNodeType.createAndFill(null,t?m.d.fromJSON(e,t.content):null);if(!n)throw Error(`Document could not be parsed`);return n.check(),n},il=class{constructor(e,t){this.options=t,this.feature=(e,t)=>this[m.c].getPublicInterface(e,t),this[m.c]=new al(this,e,t)}getDocument(){return this[m.c].state.doc.toJSON()}reset(e){this[m.c].reset(e)}replaceSelection(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.c];r.replaceSelection(new m.v(m.d.fromJSON(i,e),0,0)),r.doc.check();let o=r.doc.resolve(r.mapping.map(n.selection.from)),s=r.doc.resolve(r.selection.to),[c,l]=t?.cursorPlacement===`start`?[o,s]:[s,o];t?.selectContent?r.setSelection(n.selection instanceof M?new M(r.doc):A.between(l,c)):r.setSelection(A.between(c,c)),a(r)}replaceDocument(e,t){let{state:n,tr:r,schema:i,dispatchTransaction:a}=this[m.c];r.replaceWith(0,n.doc.content.size,rl(i,e)),t?.selectContent?r.setSelection(new M(r.doc)):t?.cursorPlacement===`end`?r.setSelection(A.atEnd(r.doc)):r.setSelection(A.atStart(r.doc)),a(r)}},al=class{getFeature(e){let t=this.config.featureMap.get(e);if(!t)throw Error(`Feature not found: ${e}`);return t}getPublicInterface(e,t){let n=this.config.featureFacadesMap.get(e);if(!n||n.length===0)throw Error(`Feature not found`);if(n[0].featureId!==void 0){if(t===void 0)throw Error(`No featureId provided for multi-instance feature.`);let e=n.find(e=>e.featureId===t);if(!e)throw Error(`Feature with id "${t}" not found`);return e.getPublicInterface(this)}if(t!==void 0)throw Error(`Feature does not support featureId`);return n[0].getPublicInterface(this)}constructor(e,n,r){this.options=r,this.view=null,this.dispatchTransaction=e=>{let t=this.state;return this.state=this.state.apply(e),this.view?.updateState(this.state),t.doc!==this.state.doc&&this.options?.onChange?.(),this.state},this.facade=e;let i=n[m.c];this.config=i,this.schema=i.schema,this.textblockAttrs=i.textblockAttrs,this.features=i.features,this.foreignHtmlParser=r?.foreignHtmlParser??new Qc(n),this.foreignHtmlSerializer=r?.foreignHtmlSerializer??new tl(n),this.styles=new t.y(m.s(i.features.flatMap(e=>e.getStyles()))),this.initState(r?.initialDocument)}initState(e){this.state=bt.create({doc:rl(this.schema,e),schema:this.config.schema,plugins:m.s(this.config.features.flatMap(e=>e.getPlugins(this)))})}reset(e){let t=Vs.getState(this.state);this.initState(e),this.updateHostState(t),this.view?.updateState(this.state)}createView(e){this.view=new ja(e,{state:this.state,dispatchTransaction:this.dispatchTransaction})}destroyViewIfNeeded(){this.view&&=(this.view.destroy(),null)}createComponent(e){return document.createElement(this.hostState().ctx.tagFor(e,!0))}getLocale(){return this.hostState().locale}get tr(){return this.state.tr}hostState(){let e=Vs.getState(this.state);if(!e)throw Error(`No host state available`);return e}updateHostState(e){this.dispatchTransaction(this.tr.setMeta(Vs,e))}},ol=class{constructor(e){this.specs=e,this.attrs={};for(let t of e)this.attrs[t.name]={default:t.default}}fromDOM(e){return Object.assign({},...this.specs.map(t=>({[t.name]:t.fromDOM(e)})))}getStyle(e){return this.specs.flatMap(t=>t.toStyles(e)).join(`; `)}getDOMAttrsProperties(e){return this.specs.length?{style:this.getStyle(e)}:{}}getDOMAttrs(e){return this.specs.length?[this.getDOMAttrsProperties(e)]:[]}extractFromNode(e){return Object.assign({},...Object.keys(this.attrs).map(t=>({[t]:e.attrs[t]})))}},sl=class{constructor(e){this.specs=e}getAllowedMarksForNode(e){return this.specs.filter(t=>!t.onNodeName||t.onNodeName===e).map(e=>e.markName)}getReferencedNodeNames(){return new Set(this.specs.map(e=>e.onNodeName).filter(Boolean))}},cl=(e,t)=>{let n=t.config[m.c].schema,r=e=>n.marks[e.type].rank,i=(e,t)=>{if(e.type!==t.type)return!1;let n=e.attrs,r=t.attrs;if(n===r)return!0;if(!n||!r)return!1;let i=Object.keys(n),a=Object.keys(r);if(i.length!==a.length)return!1;for(let e of i)if(n[e]!==r[e])return!1;return!0},a=e=>{let n=[],o=[],s=[n];for(let n of e){let e=[...n.marks??[]].sort((e,t)=>r(e)-r(t)),c=0,l=0;for(;c<o.length&&l<e.length&&i(o[c],e[l]);)c++,l++;for(;o.length>c;)o.pop(),s.pop();for(;l<e.length;){let n=e[l],r=[];s[s.length-1].push({type:`mark`,mark:n,children:{type:`fragment`,content:r,[m.c]:t},[m.c]:t}),o.push(n),s.push(r),l++}s[s.length-1].push({type:`node`,node:n,children:a(n.content??[]),[m.c]:t})}return{type:`fragment`,content:n,[m.c]:t}};return{type:`node`,node:e,children:a(e.content),[m.c]:t}},ll=class{constructor(e){this[m.c]=new ul(e)}instantiateEditor(e){return new il(this,e)}instantiateView(e,t){return cl(e,{config:this,options:{...t}})}},ul=class{constructor(e){let t=e=>e.flatMap(e=>e.getFeatures().flatMap(n=>n===e?e:t([n])));this.features=t(e.map(m.o)),this.featureMap=new Map;for(let e of this.features){if(this.featureMap.has(e.name))throw Error(`Duplicate feature: ${e.name}`);this.featureMap.set(e.name,e)}this.featureFacadesMap=new Map;for(let t of e){let e=t.constructor,n=m.o(t),r=this.featureFacadesMap.get(e);r?r.push(n):this.featureFacadesMap.set(e,[n])}if(!this.featureMap.has(`RteBase`))throw Error(`RteBase feature is required`);if(this.featureMap.has(`RteLinkFeature`)&&!this.featureMap.has(`RteToolbarFeature`))throw Error(`RteToolbarFeature is required for RteLinkFeature`);this.textblockAttrs=new ol(m.s(this.features.flatMap(e=>e.getTextblockAttrs()))),this.textblockMarks=new sl(m.s(this.features.flatMap(e=>e.getTextblockMarks())));let n=m.s(this.features.flatMap(e=>e.getSchema(this.textblockAttrs,this.textblockMarks))),r={nodes:{},marks:{}};for(let e of n)Object.assign(r.nodes,e.nodes??{}),Object.assign(r.marks,e.marks??{});for(let e of this.textblockMarks.getReferencedNodeNames())if(!(e in r.nodes))throw Error(`Unknown node "${e}"`);this.schema=new m._(r)}},dl=`h1,h2,h3,p{all:unset;display:block}h1:first-child,h2:first-child,h3:first-child,p:first-child{margin-block-start:0}h1:last-child,h2:last-child,h3:last-child,p:last-child{margin-block-end:0}p{font:var(--vvd-typography-base);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:16px;line-height:20px}.heading-step-1{font:var(--vvd-typography-heading-4);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:28px}.heading-step-2{font:var(--vvd-typography-heading-3);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:24px 12px;line-height:36px}.heading-step-3{font:var(--vvd-typography-heading-2);font-variant-ligatures:unset;font-feature-settings:unset;margin-block:32px 16px;line-height:42px}`,fl=class extends m.r{constructor(e){super(),this.enabledBlocks=e,this.name=`RteBasicTextBlocks`}getStyles(){return[this.contribution(dl)]}getSchema(e,t){let n={};this.enabledBlocks.paragraph&&(n.paragraph={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:`p`,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(`paragraph`).join(` `),toDOM(t){return[`p`,{part:`node--paragraph`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[`p`,...e.getDOMAttrs(t),0]}});let r=0;for(let i of[3,2,1]){let a=`heading${i}`,o=`h${i}`;if(!this.enabledBlocks[a])continue;r++;let s=r;n[a]={group:`block`,content:`inline*`,attrs:{...e.attrs},parseDOM:[{tag:o,getAttrs:t=>e.fromDOM(t)}],marks:t.getAllowedMarksForNode(a).join(` `),defining:!0,toDOM(t){return[o,{class:`heading-step-${s}`,part:`node--${a}`,...e.getDOMAttrsProperties(t)},0]},serializeToDOM(t){return[o,...e.getDOMAttrs(t),0]}}}return[this.contribution({nodes:n})]}getPlugins(e){let t={};this.enabledBlocks.paragraph&&(t[`Mod-Alt-0`]=this.setBlockType(e,`paragraph`));for(let n of[1,2,3]){let r=`heading${n}`;this.enabledBlocks[r]&&(t[`Mod-Alt-${n}`]=this.setBlockType(e,r))}return[this.contribution(G(t))]}getCurrentBlockType(e){let{$from:t,$to:n}=e.selection,r=t.depth===0?e.doc.childAfter(t.pos).node:t.node(1);return r!==(n.depth===0?e.doc.childBefore(n.pos).node:n.node(1))||!(r.type.name in this.enabledBlocks)?null:r.type.name}setBlockType(e,t){return(n,r)=>{let{from:i,to:a}=n.selection,o=n.tr,s=!1;return n.doc.nodesBetween(i,a,(r,i)=>(r.type.name in this.enabledBlocks&&(s=!0,o.setBlockType(i,i+r.nodeSize,n.schema.nodes[t],t=>e.textblockAttrs.extractFromNode(t))),!1)),s?(r?.(o),!0):!1}}},pl=class{constructor(e,t,n={}){this.match=e,this.match=e,this.handler=typeof t==`string`?ml(t):t,this.undoable=n.undoable!==!1,this.inCode=n.inCode||!1,this.inCodeMark=n.inCodeMark!==!1}};function ml(e){return function(t,n,r,i){let a=e;if(n[1]){let e=n[0].lastIndexOf(n[1]);a+=n[0].slice(e+n[1].length),r+=e;let t=r-i;t>0&&(a=n[0].slice(e-t,e)+a,r=i)}return t.tr.insertText(a,r,i)}}var hl=500;function gl({rules:e}){let t=new N({state:{init(){return null},apply(e,t){return e.getMeta(this)||(e.selectionSet||e.docChanged?null:t)}},props:{handleTextInput(n,r,i,a){return _l(n,r,i,a,e,t)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&_l(n,r.pos,r.pos,``,e,t)})}}},isInputRules:!0});return t}function _l(e,t,n,r,i,a){if(e.composing)return!1;let o=e.state,s=o.doc.resolve(t),c=s.parent.textBetween(Math.max(0,s.parentOffset-hl),s.parentOffset,null,``)+r;for(let l=0;l<i.length;l++){let u=i[l];if(!u.inCodeMark&&s.marks().some(e=>e.type.spec.code))continue;if(s.parent.type.spec.code){if(!u.inCode)continue}else if(u.inCode===`only`)continue;let d=u.match.exec(c);if(!d||d[0].length<r.length)continue;let f=t-(d[0].length-r.length);if(!u.inCodeMark){let e=!1;if(o.doc.nodesBetween(f,s.pos,t=>{t.isInline&&t.marks.some(e=>e.type.spec.code)&&(e=!0)}),e)continue}let p=u.handler(o,d,f,n);if(p)return u.undoable&&p.setMeta(a,{transform:p,from:t,to:n,text:r}),e.dispatch(p),!0}return!1}var vl=(e,t)=>{let n=e.plugins;for(let r=0;r<n.length;r++){let i=n[r],a;if(i.spec.isInputRules&&(a=i.getState(e))){if(t){let n=e.tr,r=a.transform;for(let e=r.steps.length-1;e>=0;e--)n.step(r.steps[e].invert(r.docs[e]));if(a.text){let t=n.doc.resolve(a.from).marks();n.replaceWith(a.from,a.to,e.schema.text(a.text,t))}else n.delete(a.from,a.to);t(n)}return!0}}return!1};new pl(/--$/,`—`,{inCodeMark:!1}),new pl(/\.\.\.$/,`…`,{inCodeMark:!1}),new pl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(")$/,`“`,{inCodeMark:!1}),new pl(/"$/,`”`,{inCodeMark:!1}),new pl(/(?:^|[\s\{\[\(\<'"\u2018\u201C])(')$/,`‘`,{inCodeMark:!1}),new pl(/'$/,`’`,{inCodeMark:!1});var yl=e=>e.parent.textBetween(0,e.parentOffset,void 0,``),bl=class extends m.r{constructor(...e){super(...e),this.name=`RteInputRulesFeature`}getPlugins(e){let t=m.s(e.config.features.flatMap(t=>t.getInputRules(e)));if(t.length===0)return[];let n=[],r=t.map(e=>e.rule);n.push(this.contribution(gl({rules:r}))),n.push(this.contribution(G({Backspace:vl}),m.i.high));let i=t.filter(e=>e.enterHandler).map(e=>e.enterHandler);return i.length>0&&n.push(this.contribution(G({Enter:(e,t)=>{let{$cursor:n}=e.selection;if(!n)return!1;let r=yl(n);for(let{regex:a,handler:o}of i){let i=a.exec(r);if(!i)continue;let s=n.pos-n.parentOffset+i.index,c=o(e,i,s,s+i[0].length);c&&t?.(c);break}return!1}}),m.i.highest)),n}},xl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteBase`}getSchema(){return[this.contribution({nodes:{doc:{content:`block+`},text:{group:`inline`}}})]}getFeatures(){return[this,new Hs,new fl({heading1:this.config?.heading1??!1,heading2:this.config?.heading2??!1,heading3:this.config?.heading3??!1,paragraph:this.config?.paragraph??!0}),new bl]}getPublicInterface(e){let t=e.getFeature(`RteCore`);return{get disabled(){return t.disabled.getValue(e)},set disabled(n){t.disabled.setValue(e,n)}}}},Sl=m.a(xl),Cl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteTextBlockPickerFeature`}getToolbarItems(e){let t=e.getFeature(`RteBasicTextBlocks`);return[this.contribution({section:`font`,render:n=>Ms(n,{label:()=>n.rte.getLocale().richTextEditor.paragraphStyles,value:e=>t.getCurrentBlockType(e.view.state)??``,onSelect:r=>{let{state:i,dispatch:a}=n.view;t.setBlockType(e,r)(i,a)},children:this.config.options.map(r=>js(n,{text:r.label,value:r.node,disabled:()=>!t.setBlockType(e,r.node)(n.view.state)}))})},1)]}},wl=m.a(Cl),Tl=`.toolbar{background-color:var(--vvd-color-neutral-50);flex-wrap:wrap;align-items:center;gap:8px;padding:4px;display:flex}.toolbar--hidden{display:none}`,El=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteToolbarFeature`,this.hidden=new qo(!1)}getStyles(){return[this.contribution(Tl)]}getPlugins(e){let t=[`history`,`font`,`text-style`,`textblock`,`insert`],n=new Map(t.map(e=>[e,[]]));for(let t of m.s(e.features.flatMap(t=>t.getToolbarItems(e))))n.get(t.section).push(t);let r=e.getFeature(`RteCore`);return[this.contribution(this.hidden.plugin),this.contribution(new N({view:i=>{let a=new Ss(i,e,{popupPlacement:this.config?.popupDirection===`outward`?`bottom`:`top`,menuOffset:8,disabled:()=>r.disabled.getValue(e)}),o=i.dom.getRootNode().querySelector(`.toolbar`);a.bindProp(()=>this.hidden.getValue(e),e=>{o.classList.toggle(`toolbar--hidden`,e)});let s=!1;for(let e of t){let t=n.get(e);t.length&&s&&(o.appendChild(Ns(a)),s=!1);for(let e of t)o.appendChild(e.render(a)),s=!0}return{update(){a.updateBindings()},destroy(){o.innerHTML=``}}}}))]}getPublicInterface(e){let t=this.hidden;return{get hidden(){return t.getValue(e)},set hidden(n){t.setValue(e,n)}}}},Dl=m.a(El),Ol=`.placeholder{display:contents}.placeholder:before{color:var(--vvd-color-neutral-600);content:attr(data-placeholder);font-size:var(--placeholder-font-size,inherit);inset-inline:var(--editor-padding-inline);line-height:inherit;pointer-events:none;position:absolute}`,kl=class extends m.r{constructor(e){super(),this.config=e,this.name=`RtePlaceholderFeature`}getStyles(){return[this.contribution(Ol)]}getPlugins(){let e=new N({props:{decorations:e=>{if(e.doc.nodeSize===4){let t=e.schema.marks.fontSize?.isInSet(e.storedMarks??[])?.attrs.size;return H.create(e.doc,[V.widget(1,()=>{let e=document.createElement(`span`);return e.className=`placeholder`,e.dataset.placeholder=this.config.text,t&&e.style.setProperty(`--placeholder-font-size`,t),e})])}return null}}});return[this.contribution(e)]}},Al=m.a(kl),jl=class extends m.r{constructor(...e){super(...e),this.name=`RteHardBreakFeature`}getSchema(){return[this.contribution({nodes:{hardBreak:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return[`br`]}}}})]}getPlugins(e){let t=(e,t)=>(t?.(e.tr.replaceSelectionWith(e.schema.nodes.hardBreak.create(),!0).scrollIntoView()),!0),n={"Shift-Enter":t};return[this.contribution(G(n),m.i.high)]}},Ml=m.a(jl),Nl=Symbol(`mixedFontSize`),Pl=class extends m.r{constructor(e){if(super(),this.config=e,this.name=`RteFontSizePickerFeature`,this.fontSizes=e.options,e.onBlocks){this.defaultFontSizeForNode={};for(let t of e.onBlocks)this.defaultFontSizeForNode[t.node]=t.defaultSize??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`fontSize`,onNodeName:e.node})):[this.contribution({markName:`fontSize`})]}getSchema(){return[this.contribution({marks:{fontSize:{attrs:{size:{validate:`string`}},parseDOM:[{tag:`span[style*='font-size']`,getAttrs:e=>{let t=e.getAttribute(`style`).match(/font-size:\s*([^;]+)/)?.[1]?.trim();return t?{size:t}:!1}}],toDOM:e=>[`span`,{style:`font-size: ${Yc(e.attrs.size)};`},0],cursorFix:(e,t)=>{let n=t.storedMarks;if(!n)return null;let r=n.find(e=>e.type.name===`fontSize`);if(r)return{"font-size":r.attrs.size};if(n.length===0){let t=this.defaultFontSizeForNode?.[e.parent.type.name];if(t)return{"font-size":t}}return null}}}})]}getPlugins(){return[this.contribution(G({"Mod-Shift-.":this.adjustFontSize(-1),"Mod-Shift-,":this.adjustFontSize(1)}))]}getToolbarItems(e){return[this.contribution({section:`font`,render:t=>Es(t,{label:()=>e.getLocale().richTextEditor.textSize,trigger:Y(t,{label:()=>e.getLocale().richTextEditor.textSize,icon:`text-size-line`}),children:this.fontSizes.map(e=>Ds(t,{text:e.label,checked:()=>this.getFontSizeFromSelection(t.view.state)===e.size,disabled:()=>!this.setFontSize(e.size)(t.view.state),onSelect:()=>{let{state:n,dispatch:r}=t.view;this.setFontSize(e.size)(n,r)}}))})},2)]}getFontSizeFromSelection(e){let{from:t,to:n,$from:r,empty:i}=e.selection,{fontSize:a}=e.schema.marks;if(i){let t=this.defaultFontSizeForNode?.[r.parent.type.name]??null;return a.isInSet(e.storedMarks||r.marks())?.attrs.size??t}let o=null,s=e=>{o===null?o=e??null:e!==o&&(o=Nl)};return e.doc.nodesBetween(t,n,(e,t,n)=>o===Nl?!1:e.isLeaf?(s(a.isInSet(e.marks)?.attrs.size??(n&&this.defaultFontSizeForNode?.[n.type.name])),!0):(e.type.allowsMarkType(a)&&e.childCount===0&&s(this.defaultFontSizeForNode?.[e.type.name]),!0)),o}setFontSize(e){return(t,n)=>{let{from:r,to:i,empty:a,$from:o}=t.selection,{fontSize:s}=t.schema.marks;if(!Co(s,{size:e})(t))return!1;let c=t.tr;if(a){let n=(t.storedMarks||[]).filter(e=>e.type!==s);e!==this.defaultFontSizeForNode?.[o.parent.type.name]&&n.push(s.create({size:e})),c.setStoredMarks(n)}else c.addMark(r,i,s.create({size:e})),c.doc.nodesBetween(r,i,(e,t,n)=>{if(!e.isInline)return;let r=s.isInSet(e.marks),i=this.defaultFontSizeForNode?.[n.type.name];r&&r.attrs.size===i&&c.step(new w(t,t+e.nodeSize,r))});return n?.(c.scrollIntoView()),!0}}adjustFontSize(e){return(t,n)=>{let r=this.getFontSizeFromSelection(t);if(r===null||r===Nl)return!1;let i=this.fontSizes.findIndex(e=>e.size===r)+e;return i<0||i>=this.fontSizes.length?!1:this.setFontSize(this.fontSizes[i].size)(t,n)}}},Fl=m.a(Pl),Il=[`p`,0],Ll=[`blockquote`,0],Rl=[`hr`],zl=[`pre`,[`code`,0]],Bl=[`br`],Vl={doc:{content:`block+`},paragraph:{content:`inline*`,group:`block`,parseDOM:[{tag:`p`}],toDOM(){return Il}},blockquote:{content:`block+`,group:`block`,defining:!0,parseDOM:[{tag:`blockquote`}],toDOM(){return Ll}},horizontal_rule:{group:`block`,parseDOM:[{tag:`hr`}],toDOM(){return Rl}},heading:{attrs:{level:{default:1,validate:`number`}},content:`inline*`,group:`block`,defining:!0,parseDOM:[{tag:`h1`,attrs:{level:1}},{tag:`h2`,attrs:{level:2}},{tag:`h3`,attrs:{level:3}},{tag:`h4`,attrs:{level:4}},{tag:`h5`,attrs:{level:5}},{tag:`h6`,attrs:{level:6}}],toDOM(e){return[`h`+e.attrs.level,0]}},code_block:{content:`text*`,marks:``,group:`block`,code:!0,defining:!0,parseDOM:[{tag:`pre`,preserveWhitespace:`full`}],toDOM(){return zl}},text:{group:`inline`},image:{inline:!0,attrs:{src:{validate:`string`},alt:{default:null,validate:`string|null`},title:{default:null,validate:`string|null`}},group:`inline`,draggable:!0,parseDOM:[{tag:`img[src]`,getAttrs(e){return{src:e.getAttribute(`src`),title:e.getAttribute(`title`),alt:e.getAttribute(`alt`)}}}],toDOM(e){let{src:t,alt:n,title:r}=e.attrs;return[`img`,{src:t,alt:n,title:r}]}},hard_break:{inline:!0,group:`inline`,selectable:!1,parseDOM:[{tag:`br`}],toDOM(){return Bl}}},Hl=[`em`,0],Ul=[`strong`,0],Wl=[`code`,0],Gl={link:{attrs:{href:{validate:`string`},title:{default:null,validate:`string|null`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`),title:e.getAttribute(`title`)}}}],toDOM(e){let{href:t,title:n}=e.attrs;return[`a`,{href:t,title:n},0]}},em:{parseDOM:[{tag:`i`},{tag:`em`},{style:`font-style=italic`},{style:`font-style=normal`,clearMark:e=>e.type.name==`em`}],toDOM(){return Hl}},strong:{parseDOM:[{tag:`strong`},{tag:`b`,getAttrs:e=>e.style.fontWeight!=`normal`&&null},{style:`font-weight=400`,clearMark:e=>e.type.name==`strong`},{style:`font-weight`,getAttrs:e=>/^(bold(er)?|[5-9]\d{2,})$/.test(e)&&null}],toDOM(){return Ul}},code:{code:!0,parseDOM:[{tag:`code`}],toDOM(){return Wl}}};new m._({nodes:Vl,marks:Gl});var Kl=class extends m.r{constructor(e){super(),this.config=e}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:this.markName,onNodeName:e.node})):[this.contribution({markName:this.markName})]}},ql=class extends Kl{constructor(...e){super(...e),this.name=`RteBoldFeature`,this.markName=`bold`}getSchema(){return[this.contribution({marks:{bold:Gl.strong}})]}getPlugins(e){return[this.contribution(G({"Mod-b":Co(e.schema.marks.bold)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.bold,icon:`bold-line`,markType:e.schema.marks.bold})},1)]}},Jl=m.a(ql),Yl=class extends Kl{constructor(...e){super(...e),this.name=`RteItalicFeature`,this.markName=`italic`}getSchema(){return[this.contribution({marks:{italic:Gl.em}})]}getPlugins(e){return[this.contribution(G({"Mod-i":Co(e.schema.marks.italic)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.italic,icon:`italic-line`,markType:e.schema.marks.italic})},2)]}},Xl=m.a(Yl),Zl=class extends Kl{constructor(...e){super(...e),this.name=`RteUnderlineFeature`,this.markName=`underline`}getSchema(){return[this.contribution({marks:{underline:{parseDOM:[{tag:`u`}],toDOM(){return[`u`,0]}}}})]}getPlugins(e){return[this.contribution(G({"Mod-u":Co(e.schema.marks.underline)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.underline,icon:`underline-line`,markType:e.schema.marks.underline})},3)]}},Ql=m.a(Zl),$l=class extends Kl{constructor(...e){super(...e),this.name=`RteStrikethroughFeature`,this.markName=`strikethrough`}getSchema(){return[this.contribution({marks:{strikethrough:{parseDOM:[{tag:`s`},{tag:`del`}],toDOM(){return[`s`,0]}}}})]}getPlugins(e){return[this.contribution(G({"Alt-Shift-5":Co(e.schema.marks.strikethrough),"Cmd-Shift-X":Co(e.schema.marks.strikethrough)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.strikethrough,icon:`strikethrough-line`,markType:e.schema.marks.strikethrough})},4)]}},eu=m.a($l),tu=`tt{font:var(--vvd-typography-base-code);font-variant-ligatures:unset;font-feature-settings:unset;font-size:unset;font-weight:unset;line-height:unset}`,nu=class extends Kl{constructor(...e){super(...e),this.name=`RteMonospaceFeature`,this.markName=`monospace`}getStyles(){return[this.contribution(tu)]}getSchema(){return[this.contribution({marks:{monospace:{parseDOM:[{tag:`tt`},{tag:`code`}],toDOM(){return[`tt`,0]}}}})]}getPlugins(e){return[this.contribution(G({"Mod-M":Co(e.schema.marks.monospace)}))]}getToolbarItems(e){return[this.contribution({section:`text-style`,render:t=>As(t,{label:()=>t.rte.getLocale().richTextEditor.monospace,icon:`monospace-line`,markType:e.schema.marks.monospace})},5)]}},ru=m.a(nu);function iu(e,t,n){for(let r=0;r<t.length;r++){let{$from:i,$to:a}=t[r],o=i.depth==0?e.type.allowsMarkType(n):!1;if(e.nodesBetween(i.pos,a.pos,e=>o?!1:(o=e.inlineContent&&e.type.allowsMarkType(n),!0)),o)return!0}return!1}var au=Symbol(`mixedColor`),ou=class extends m.r{constructor(e){if(super(),this.config=e,this.name=`RteTextColorPicker`,e?.onBlocks){this.defaultColorForNode={};for(let t of e.onBlocks)this.defaultColorForNode[t.node]=t.defaultColor??null}}getTextblockMarks(){return this.config?.onBlocks?this.config.onBlocks.map(e=>this.contribution({markName:`textColor`,onNodeName:e.node})):[this.contribution({markName:`textColor`})]}getSchema(){return[this.contribution({marks:{textColor:{attrs:{color:{validate:`string`}},parseDOM:[{tag:`span[data-text-color]`,getAttrs:e=>({color:e.getAttribute(`data-text-color`)})},{style:`color`,getAttrs:e=>({color:e})}],toDOM(e){let{color:t}=e.attrs;return[`span`,{style:`color: ${Yc(t)};`,"data-text-color":t},0]},inclusive:!0}}})]}getToolbarItems(){return[this.contribution({section:`text-style`,render:e=>{let t=Y(e,{label:()=>e.rte.getLocale().richTextEditor.textColor,disabled:()=>!this.setColor(`any`)(e.view.state),icon:`textcolor-line`}),n=t.firstElementChild;return J(e,{children:[t,Is(e,{name:`text-color-picker`,assignedProps:{anchor:n,value:()=>this.getSelectionColor(e.view.state)||``},assignedEvents:{change:t=>{let n=t.currentTarget.value;this.setColor(n)(e.view.state,e.view.dispatch)}}})]})}},6)]}getSelectionColor(e){let{selection:t}=e,{textColor:n}=e.schema.marks,{from:r,to:i,$from:a,empty:o}=t;if(o){let t=this.defaultColorForNode?.[a.parent.type.name]??null;return n.isInSet(e.storedMarks||a.marks())?.attrs.color??t}let s=null,c=e=>{s===null?s=e??null:e!==s&&(s=au)};return e.doc.nodesBetween(r,i,(e,t,r)=>s===au?!1:e.isLeaf?(c(n.isInSet(e.marks)?.attrs.color??(r&&this.defaultColorForNode?.[r.type.name])),!0):(e.type.allowsMarkType(n)&&e.childCount===0&&c(this.defaultColorForNode?.[e.type.name]),!0)),s===au?null:s}setColor(e){return(t,n)=>{let{textColor:r}=t.schema.marks,{from:i,to:a,empty:o,$from:s}=t.selection;if(!iu(t.doc,t.selection.ranges,r))return!1;let c=t.tr;if(o){let n=(t.storedMarks||[]).filter(e=>e.type!==r);e!==this.defaultColorForNode?.[s.parent.type.name]&&n.push(r.create({color:e})),c.setStoredMarks(n)}else c.addMark(i,a,r.create({color:e})),c.doc.nodesBetween(i,a,(e,t,n)=>{if(!e.isInline)return;let i=r.isInSet(e.marks),a=this.defaultColorForNode?.[n.type.name];i&&i.attrs.color===a&&c.step(new w(t,t+e.nodeSize,i))});return n?.(c.scrollIntoView()),!0}}},su=m.a(ou),cu=`.rich-text ul,.rich-text ol{padding-inline-start:1.5em}.rich-text li{list-style-position:inside}`,lu=e=>e.parentOffset===0,uu=e=>e.nodeSize===2,du=e=>e.depth-1,fu=e=>e.depth-2,pu=e=>e.parent,mu=e=>e.node(du(e)),hu=e=>e.depth>2,gu=(e,t)=>e.index(t)===0,_u=(e,t)=>e.index(t)===e.node(t).childCount-1,vu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r-1)},yu=(e,t)=>{let n=e.node(t),r=e.index(t);return n.maybeChild(r+1)},bu=e=>{let{$from:t,$to:n}=e;if(e instanceof M){let r=A.between(e.$from,e.$to);t=r.$from,n=r.$to}return{$from:t,$to:n}},xu=(e,t)=>e.sameParent(t)?e.node(-1):e.node(e.sharedDepth(t.pos)),Su=e=>{let{$cursor:t}=e.selection;return t?.parent.type===e.schema.nodes.listItem?t:null},Cu=(e,t,n,r)=>{let i,a=!0;return e.doc.nodesBetween(t.pos,n.pos,t=>{t.type.isInGroup(`list`)&&(i=t.type),t.type===e.schema.nodes.listItem&&i!==r&&(a=!1)}),a},wu=(e,t,n)=>{hu(t)?Tu(t,n):Eu(e,t,n)},Tu=(e,t)=>{let n=new m.h(e.doc.resolve(e.before()),e.doc.resolve(e.after()),e.depth-1);t.lift(n,e.depth-2)},Eu=(e,t,n)=>{let r=mu(t),i=t.index(fu(t)),a=Go(t.node(fu(t)).contentMatchAt(i+1)),o=gu(t,du(t)),s=_u(t,du(t));n.step(new E(t.before()-(o?1:0),t.after()+(s?1:0),t.start(),t.end(),new m.v((o?m.d.empty:m.d.from(r.copy(m.d.empty))).append(m.d.from(a.create(e.textblockAttrs.extractFromNode(pu(t))))).append(s?m.d.empty:m.d.from(r.copy(m.d.empty))),o?0:1,s?0:1),(o?0:1)+1))},Du=(e,t,n,r)=>{n.parent.type===e.schema.nodes.listItem?Ou(t,n,r):ku(e,t,n,r)},Ou=(e,t,n)=>{let r=vu(t,du(t))?.type===e,i=yu(t,du(t))?.type===e,a=r?1:0,o=i?1:0;n.step(new E(t.before()-(r?1:0),t.after()+(i?1:0),t.before(),t.after(),new m.v(m.d.from(e.create(null,[])),a,o),1-a))},ku=(e,t,n,r)=>{r.step(new E(n.before(),n.after(),n.start(),n.end(),new m.v(m.d.from(t.create(null,[e.schema.nodes.listItem.create(e.textblockAttrs.extractFromNode(n.parent))])),0,0),2))},Au=class extends m.r{constructor(e){if(super(),this.config=e,this.name=`RteListFeature`,!e.bulletList&&!e.numberedList)throw Error(`RteListFeature requires at least one of bulletList or numberedList to be enabled`)}getStyles(){return[this.contribution(cu)]}getSchema(e){return[this.contribution({nodes:{listItem:{content:`inline*`,attrs:e.attrs,defining:!0,parseDOM:[{tag:`li`,getAttrs:t=>e.fromDOM(t)}],toDOM(t){return[`li`,...e.getDOMAttrs(t),0]}},...this.config.bulletList?{bulletList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ul`}],toDOM(){return[`ul`,0]}}}:{},...this.config.numberedList?{numberedList:{group:`block list`,content:`(listItem | list)+`,parseDOM:[{tag:`ol`}],toDOM(){return[`ol`,0]}}}:{}}})]}getPlugins(e){this.rte=e;let t=(e,t)=>{let n=Su(e);if(n&&lu(n)){let r=e.tr;return Ou(mu(n).type,n,r),t?.(r.scrollIntoView()),!0}return!1},n=(e,t)=>{let n=Su(e);if(n&&lu(n)&&hu(n)){let r=e.tr;return Tu(n,r),t?.(r.scrollIntoView()),!0}return!1};return[this.contribution(G({Enter:(e,t)=>{let n=Su(e);if(n&&uu(pu(n))){let r=e.tr;return wu(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Backspace:(e,t)=>{let n=Su(e);if(n&&lu(n)){if(gu(n,du(n))&&vu(n,fu(n))?.type===mu(n).type)return!1;let r=e.tr;return wu(this.rte,n,r),t?.(r.scrollIntoView()),!0}return!1},Tab:t,"Shift-Tab":n,...this.config.bulletList?{"Mod-Shift-8":this.toggleList(e.schema.nodes.bulletList)}:{},...this.config.numberedList?{"Mod-Shift-7":this.toggleList(e.schema.nodes.numberedList)}:{}}),m.i.high)]}getToolbarItems(e){let t=[];return this.config.bulletList&&t.push(this.contribution({section:`textblock`,render:t=>Y(t,{label:()=>t.rte.getLocale().richTextEditor.bulletList,icon:`bullet-list-2-line`,active:()=>this.isSelectionInList(e.schema.nodes.bulletList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.bulletList)(n,r)}})},1)),this.config.numberedList&&t.push(this.contribution({section:`textblock`,render:t=>Y(t,{label:()=>t.rte.getLocale().richTextEditor.numberedList,icon:`list-numbered-line`,active:()=>this.isSelectionInList(e.schema.nodes.numberedList,t.rte.state),onClick:()=>{let{state:n,dispatch:r}=t.view;this.toggleList(e.schema.nodes.numberedList)(n,r)}})},2)),t}toggleList(e){return To((t,n)=>{let{$from:r,$to:i}=bu(t.selection);if(xu(r,i).type.isInGroup(`list`))if(Cu(t,r,i,e)){let e=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(n,r)=>{if(n.type===t.schema.nodes.listItem){let t=e.doc.resolve(e.mapping.map(r+1));wu(this.rte,t,e)}}),n?.(e.scrollIntoView()),!0}else{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{t.type.isInGroup(`list`)&&t.type!==e&&a.setNodeMarkup(n,e,t.attrs)}),n?.(a.scrollIntoView()),!0}else{let a=t.tr;return t.doc.nodesBetween(r.pos,i.pos,(t,n)=>{if(!t.isTextblock)return;let r=a.doc.resolve(a.mapping.map(n+1));Du(this.rte,e,r,a)}),n?.(a.scrollIntoView()),!0}},(t,n)=>t.type===e&&n.type===e)}isSelectionInList(e,t){let{$from:n,$to:r}=bu(t.selection);return xu(n,r).type.isInGroup(`list`)?Cu(t,n,r,e):!1}},ju=m.a(Au),Mu=[{value:`left`,icon:`align-left-line`,label:`left`},{value:`center`,icon:`align-center-line`,label:`center`},{value:`right`,icon:`align-right-line`,label:`right`}],Nu=e=>Mu.find(t=>t.value===e)?.value??`left`,Pu=class extends m.r{constructor(...e){super(...e),this.name=`RteAlignmentFeature`}getTextblockAttrs(){return[this.contribution({name:`textAlign`,default:`left`,fromDOM(e){return Nu(e.style.textAlign)},toStyles(e){return[`text-align: ${Nu(e.attrs.textAlign)}`]}})]}getPlugins(){return[this.contribution(G({"Mod-L":this.setAlignment(`left`),"Mod-E":this.setAlignment(`center`),"Mod-R":this.setAlignment(`right`)}))]}getToolbarItems(){return[this.contribution({section:`textblock`,render:e=>Es(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,trigger:Y(e,{label:()=>e.rte.getLocale().richTextEditor.alignment,icon:()=>{let t=this.getAlignmentFromSelection(e.view.state);return Mu.find(e=>e.value===t)?.icon??`align-left-line`}}),children:[Os(e,{children:Mu.map((t,n)=>Y(e,{icon:t.icon,label:()=>e.rte.getLocale().richTextEditor.alignments[t.label],slot:`header`,noTooltip:!0,autofocus:()=>{let r=this.getAlignmentFromSelection(e.view.state);return(r===`mixed`||r===null)&&n===0?!0:t.value===r},active:()=>this.getAlignmentFromSelection(e.view.state)===t.value,disabled:()=>this.getAlignmentFromSelection(e.view.state)===null,onClick:()=>{let{state:n,dispatch:r}=e.view;this.setAlignment(t.value)(n,r)}}))})]})},3)]}getAlignmentFromSelection(e){let{selection:t}=e,{from:n,to:r}=t,i=null;return e.doc.nodesBetween(n,r,e=>{i!==`mixed`&&e.type.isTextblock&&(i?i!==e.attrs.textAlign&&(i=`mixed`):i=e.attrs.textAlign)}),i}setAlignment(e){return(t,n)=>{let{tr:r,selection:i}=t,{from:a,to:o}=i;return t.doc.nodesBetween(a,o,(t,n)=>{t.type.isTextblock&&r.setNodeMarkup(n,t.type,{...t.attrs,textAlign:e})}),n?.(r.scrollIntoView()),!0}}},Fu=m.a(Pu),Iu=`.link-popover{flex-direction:column;gap:8px;inline-size:450px;padding:16px;display:flex}.link-popover-header{justify-content:space-between;align-items:center;display:flex}.link-popover-label{color:var(--vvd-color-neutral-600);font:var(--vvd-typography-base-condensed)}.link-popover-content{flex-direction:column;gap:16px;display:flex}.link,.rich-text a[href],.link:visited,.rich-text a[href]:visited{color:var(--vvd-color-cta-600)}.link:hover,.rich-text a[href]:hover{color:var(--vvd-color-cta-500)}.link:active,.rich-text a[href]:active{color:var(--vvd-color-cta-400)}.link-action-bar{justify-content:end;gap:8px;display:flex}.link-toolbar-menu{flex-direction:column;gap:16px;inline-size:368px;padding:8px;display:flex}`,Lu=`(?:https?://|www\\.)[^\\s<]+`;function Ru(e,t,n,r){if(e.doc.rangeHasMark(n,n+1,e.schema.marks.link))return null;let i=t.replace(/[.,;:!?) ]+$/,``),a=i.startsWith(`www.`)?`https://${i}`:i,o=e.schema.marks.link.create({href:a}),s=n+i.length,c=t.slice(i.length),l=e.tr.addMark(n,s,o);return c&&l.replaceWith(s,r,e.schema.text(c)),l}var zu=class extends m.r{constructor(...e){super(...e),this.name=`RteLinkFeature`,this.removeLink=(e,t)=>{let n=e.tr,r=this.getCurrentLink(e);return n.removeMark(r.start,r.end,e.schema.marks.link),t?.(n.scrollIntoView()),!0}}getStyles(){return[this.contribution(Iu)]}getSchema(){return[this.contribution({marks:{link:{attrs:{href:{validate:`string`}},inclusive:!1,parseDOM:[{tag:`a[href]`,getAttrs(e){return{href:e.getAttribute(`href`)}}}],toDOM(e){let{href:t}=e.attrs;return[`a`,{href:qc(t)},0]}}}},m.i.high)]}getTextblockMarks(){return[this.contribution({markName:`link`})]}getInputRules(){let e=RegExp(`${Lu}$`);return[this.contribution({rule:new pl(RegExp(`${Lu} $`),(e,t,n,r)=>Ru(e,t[0],n,r)),enterHandler:{regex:e,handler:(e,t,n,r)=>Ru(e,t[0],n,r)}})]}getPlugins(e){let t=()=>(this.toolbarMenu.open=!0,!0);return[this.contribution(new N({props:{decorations:e=>{let t=this.getCurrentLink(e);if(t){let n=V.inline(t.start,t.end,{id:`current-link`});return H.create(e.doc,[n])}return null}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.anchorId=`current-link`;let i=J(n,{className:`link-popover`,children:[J(n,{className:`link-popover-header`,children:[J(n,{className:`link-popover-label`,children:[Fs(n,{text:()=>this.getCurrentLink(n.view.state)?.text||``})]}),Y(n,{icon:`close-line`,label:()=>n.rte.getLocale().richTextEditor.close,noTooltip:!0,onClick:()=>{r.requestOpenState(!1)}})]}),J(n,{className:`link-popover-content`,children:[Cs(n,{className:`link`,href:()=>this.getCurrentLink(n.view.state)?.href||``,target:`_blank`,rel:`noopener`,children:[Fs(n,{text:()=>this.getCurrentLink(n.view.state)?.href||``})]}),J(n,{className:`link-action-bar`,children:[Y(n,{icon:`delete-line`,label:()=>n.rte.getLocale().richTextEditor.delete,connotation:`alert`,variant:`popover`,noTooltip:!0,onClick:()=>{let{state:e,dispatch:t}=n.view;this.removeLink(e,t)}}),Y(n,{icon:`edit-line`,label:()=>n.rte.getLocale().richTextEditor.edit,variant:`popover`,noTooltip:!0,onClick:()=>(this.toolbarMenu.open=!0,r.requestOpenState(!1),!0)})]})]})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{let t=e.state;n.updateBindings();let i=this.getCurrentLink(t);r.requestOpenState(!!i)},destroy:()=>{r.remove()}}}})),this.contribution(G({"Mod-k":t}))]}getToolbarItems(e){let t=e=>{let{from:t,to:n}=e.selection;return t===n?``:e.doc.textBetween(t,n,` `)},n=e=>{try{return new URL(e),!0}catch{return!1}};return[this.contribution({section:`insert`,render:r=>{let i=Ps(r,{label:()=>r.rte.getLocale().richTextEditor.linkText,placeholder:()=>r.rte.getLocale().richTextEditor.linkTextPlaceholder,slot:`header`,autofocus:!0,value:()=>this.getCurrentLink(r.view.state)?.text||t(r.view.state)||``,onInput:()=>{s()}}),a=Ps(r,{label:()=>r.rte.getLocale().richTextEditor.linkUrl,type:`url`,placeholder:()=>r.rte.getLocale().richTextEditor.linkUrlPlaceholder,slot:`header`,value:()=>this.getCurrentLink(r.view.state)?.href||``,onInput:()=>{s()}}),o=Y(r,{label:()=>r.rte.getLocale().richTextEditor.apply,variant:`popover-primary`,disabled:()=>{let e=this.getCurrentLink(r.view.state);return!(e&&e.text.length&&n(e.href))},onClick:()=>{let{state:t,dispatch:n}=r.view;this.insertLink(e,a.value,i.value)(t,n)}}),s=()=>{o.querySelector(`[data-vvd-component="button"]`).disabled=!(i.value.length&&n(a.value))},c=Es(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,trigger:Y(r,{label:()=>r.rte.getLocale().richTextEditor.hyperlink,icon:`link-line`}),children:[J(r,{className:`link-toolbar-menu`,slot:`header`,children:[i,a,J(r,{className:`link-action-bar`,slot:`header`,children:[Y(r,{label:()=>r.rte.getLocale().richTextEditor.cancel,variant:`popover`,onClick:()=>{this.toolbarMenu.open=!1}}),o]})]})]});return this.toolbarMenu=c.lastElementChild,c}},1)]}getCurrentLink(e){let t=e.selection;if(!(t instanceof A))return null;let n=e.schema.marks.link,{$from:r,$to:i}=t,a=e.selection.empty?r.marks():r.nodeAfter?.marks??[],o=n.isInSet(a)?.attrs.href;if(!o)return null;let s=e=>n.isInSet(e.marks)?.attrs.href===o,c=-1,l=-1,u=!0;return e.doc.nodesBetween(r.start(),i.end(),(e,n)=>{if(!e.isText)return!0;let r=n+e.nodeSize;return s(e)?(c===-1&&(c=n),l=r):r>t.from&&n<t.to&&(u=!1),!1}),!u||c===-1?null:{text:e.doc.textBetween(c,l,` `),href:o,start:c,end:l}}insertLink(e,t,n){return(r,i)=>{let{from:a,to:o}=r.selection,s=r.tr,c=this.getCurrentLink(r);return c&&(a=c.start,o=c.end),s.insertText(n,a,o),s.addMark(a,a+n.length,e.schema.marks.link.create({href:t})),i?.(s.scrollIntoView()),!0}}},Bu=m.a(zu),Vu=`.inline-image-wrapper{vertical-align:text-bottom;display:inline-block}.inline-image{block-size:auto;display:block}.inline-image-popover{align-items:center;gap:4px;padding:8px;display:flex}.inline-image-placeholder{color:var(--vvd-color-canvas-text);font:var(--vvd-typography-base);font-feature-settings:normal;font-variant-ligatures:normal;overflow-wrap:normal;pointer-events:none;white-space:normal}`,Hu=e=>e!==null&&!!e.next,Uu=1,Wu=()=>Uu++,Gu=class{constructor(e,t,n,r){this.view=t,this.getPos=n,this.config=r,this.content=null,this.dom=document.createElement(`div`),this.dom.className=`inline-image-wrapper`,this.imageUrl=e.attrs.imageUrl,this.img=document.createElement(`img`),this.initializeImg(e);let i=this.config.resolveUrl?this.config.resolveUrl(this.imageUrl):this.imageUrl,a=Hu(i)?null:i;this.handleResolvedUrl(a),Hu(i)&&this.handleResolvedUrlGenerator(i)}setContent(e,{onDestroy:t,allowPopover:n}={}){this.content?.remove(),this.onContentDestroy?.(),this.content=e,e&&(this.onContentDestroy=t,this.dom.appendChild(e)),y.setBlockPopover(this.dom,!n)}async handleResolvedUrlGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.handleResolvedUrl(n.value);while(!n.done)}handleResolvedUrl(e){if(typeof e==`string`)this.renderImg(e);else if(e?.type===`placeholder`){let t=`inline-image-placeholder-${Wu()}`,n=document.createElement(`slot`);n.className=`inline-image-placeholder`,n.name=t;let r=e.create?.(t),i=this.view.dom.getRootNode().host;m.t(i,`inline-image-placeholder`,t,{url:this.imageUrl}),this.setContent(n,{onDestroy:()=>{m.t(i,`inline-image-placeholder`,t,m.n),r?.()}})}else this.setContent(null)}initializeImg(e){this.img.className=`inline-image`,this.update(e),this.img.addEventListener(`load`,()=>{let e=this.getPos?.();if(e){let{state:t,dispatch:n}=this.view,r=t.doc.nodeAt(e);if(!r||r.attrs.naturalWidth===this.img.naturalWidth&&r.attrs.naturalHeight===this.img.naturalHeight)return;let i=t.tr;i.setNodeAttribute(e,`naturalWidth`,this.img.naturalWidth),i.setNodeAttribute(e,`naturalHeight`,this.img.naturalHeight),i.setMeta(`addToHistory`,!1),n(i)}})}renderImg(e){this.img.src=Jc(e),this.setContent(this.img,{allowPopover:!0})}update(e){return this.img.alt=e.attrs.alt,this.img.width=e.attrs.naturalWidth,this.img.height=e.attrs.naturalHeight,this.img.style.maxWidth=e.attrs.size,!0}destroy(){this.setContent(null)}},Ku=class extends m.r{constructor(e={}){super(),this.config=e,this.name=`RteInlineImageFeature`}getStyles(){return[this.contribution(Vu)]}getSchema(){return[this.contribution({nodes:{inlineImage:{inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{imageUrl:{validate:`string`},alt:{validate:`string`,default:``},size:{validate:`string|null`,default:null},naturalWidth:{validate:`number|null`,default:null},naturalHeight:{validate:`number|null`,default:null}},parseDOM:[{tag:`img[src],img[data-src]`,getAttrs:e=>{let t=e=>{let t=parseInt(e??``,10);return isNaN(t)?null:t},n=e.getAttribute(`data-src`)??e.getAttribute(`src`),r=this.config.parseUrlFromHtml?this.config.parseUrlFromHtml(n):n;return r===null?!1:{imageUrl:r,alt:e.getAttribute(`alt`)||``,size:e.style.maxWidth||null,naturalWidth:t(e.getAttribute(`width`)),naturalHeight:t(e.getAttribute(`height`))}}}],toDOM:e=>{let{imageUrl:t,alt:n,size:r,naturalWidth:i,naturalHeight:a}=e.attrs,o=this.config.serializeUrlToHtml?this.config.serializeUrlToHtml(t):t;if(o===null)return document.createTextNode(``);let s={src:Jc(o),"data-src":o,alt:n};return r&&(s.style=`max-width: ${Yc(r)}; height: auto;`),i&&(s.width=i),a&&(s.height=a),[`img`,s]}}}})]}getPlugins(e){return[this.contribution(new N({props:{nodeViews:{inlineImage:(e,t,n)=>new Gu(e,t,n,this.config)}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.offset=4;let i=J(n,{className:`inline-image-popover`,children:[Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.small,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`small`,onClick:()=>{this.setSelectedImageSize(`small`)(n.view.state,n.view.dispatch)}}),Ns(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.fit,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`fit`,onClick:()=>{this.setSelectedImageSize(`fit`)(n.view.state,n.view.dispatch)}}),Ns(n),Y(n,{label:()=>n.rte.getLocale().richTextEditor.imageSizes.original,variant:`popover`,active:()=>this.getSelectedImageSize(n.view.state)===`original`,onClick:()=>{this.setSelectedImageSize(`original`)(n.view.state,n.view.dispatch)}})]});return r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r),{update:e=>{n.updateBindings();let t=this.getSelectedInlineImage(e.state);t?(r.anchorEl=e.nodeDOM(t.pos),r.requestOpenState(!0)):(r.anchorEl=void 0,r.requestOpenState(!1))},destroy:()=>{r.remove()}}}}))]}calculateSmallWidth(e){return Math.min(300,e/2)+`px`}getSelectedInlineImage(e){let t=e.selection;return t instanceof j&&t.node.type===e.schema.nodes.inlineImage?{pos:t.from,node:t.node}:null}setSelectedImageSize(e){return(t,n)=>{let r=this.getSelectedInlineImage(t);if(!r)return!1;let{naturalWidth:i}=r.node.attrs;if(e===`small`&&i===null)return!1;let a=t.tr;return a.setNodeAttribute(r.pos,`size`,e===`small`?this.calculateSmallWidth(i):e===`fit`?`100%`:null),n?.(a.scrollIntoView()),!0}}getSelectedImageSize(e){let t=this.getSelectedInlineImage(e);if(!t)return null;let{size:n,naturalWidth:r}=t.node.attrs;return r!==null&&n===this.calculateSmallWidth(r)?`small`:n===`100%`?`fit`:n===null?`original`:null}},qu=m.a(Ku),Ju=async e=>{try{return{type:`ok`,result:await e}}catch(e){return{type:`error`,error:e}}},Yu=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteFileHandlerFeature`}getPlugins(e){let t=new N({state:{init(){return H.empty},apply(e,n){n=n.map(e.mapping,e.doc);let r=e.getMeta(t);if(r&&r.add){let t=document.createElement(`placeholder`),i=V.widget(r.add.pos,t,{id:r.add.id,relaxedSide:!0});n=n.add(e.doc,[i])}else r&&r.remove&&(n=n.remove(n.find(void 0,void 0,e=>e.id==r.remove.id)));return n}},props:{decorations(e){return this.getState(e)}}}),n=(e,n)=>{let r=c.i();return e.setMeta(t,{add:{id:r,pos:n}}),{getPos:e=>{let n=t.getState(e).find(void 0,void 0,e=>e.id==r);return n.length?n[0].from:null},remove:e=>{e.setMeta(t,{remove:{id:r}})}}},r=(t,n,r)=>{if(r.type===`selection`){let r=m.v.fromJSON(e.schema,{content:n});t.replaceSelection(r)}else{let i=m.d.fromJSON(e.schema,n);t.insert(r.pos,i)}},i=(e,t)=>{let n=this.config.handleFiles(e);n!==null&&(n instanceof Promise?o(n,t):a(n,t))},a=(t,n)=>{let i=e.state.tr;r(i,t,n),e.dispatchTransaction(i)},o=async(t,i)=>{let a=e.state.tr;i.type===`selection`&&!a.selection.empty&&a.deleteSelection();let o=n(a,i.type===`selection`?a.selection.from:i.pos);e.dispatchTransaction(a);let s=await Ju(t),c=o.getPos(e.state),l=e.state.tr;o.remove(l),c!==null&&s.type===`ok`&&r(l,s.result,{type:`pos`,pos:c}),e.dispatchTransaction(l),s.type===`error`&&console.error(`Error in handleFiles handler:`,s.error)};return[this.contribution(t),this.contribution(new N({props:{handlePaste:(e,t)=>{let n=Array.from(t.clipboardData.files);return n.length?(i(n,{type:`selection`}),!0):!1},handleDrop:(e,t,n,r)=>{let a=Array.from(t.dataTransfer.files);if(!a.length)return!1;let o=e.posAtCoords({left:t.clientX,top:t.clientY}).pos;if(e.dragging&&e.dragging.slice){let t=ze(e.state.doc,o,e.dragging.slice);t!=null&&(o=t)}return i(a,{type:`pos`,pos:o}),!0}}}))]}},Xu=m.a(Yu),Zu=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteDebugFeature`}getPlugins(e){let t=new WeakMap,n=!1,r=e=>{t.get(e)===void 0&&(n=this.config.onViewportDragOver?.(e)??!1)},i=e=>{this.config.onViewportDrop?.(e),this.config.onViewportDragFinish?.()},a=()=>{this.config.onViewportDragFinish?.()},o=!1,s=()=>{o=!0,window.setTimeout(()=>o=!1,0)},c=()=>{o||this.config.onViewportDragFinish?.()};return[this.contribution(new N({view:e=>{let t=e.root.host.editorViewportElement;return t.addEventListener(`dragover`,r),t.addEventListener(`drop`,i),t.addEventListener(`dragend`,a),t.addEventListener(`dragenter`,s),t.addEventListener(`dragleave`,c),{destroy(){t.removeEventListener(`dragover`,r),t.removeEventListener(`drop`,i),t.removeEventListener(`dragend`,a),t.removeEventListener(`dragenter`,s),t.removeEventListener(`dragleave`,c)}}}})),this.contribution(new N({props:{handleDOMEvents:{dragover:(e,r)=>{let i=this.config.onViewportDragOver?.(r)??!1;return t.set(r,i),n=i,i?(r.stopImmediatePropagation(),r.preventDefault(),!0):!1},drop:(e,t)=>n}}}),m.i.high)]}},Qu=m.a(Zu),$u=class extends m.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteToolbarButtonFeature[${e}]`}getToolbarItems(){return[this.contribution({section:`insert`,render:e=>Y(e,{label:this.options.label,icon:this.options.icon,onClick:()=>{this.executeAction(e)}})},2+(this.options.order??0)/(2**53-1))]}executeAction(e){let{action:t}=this.options;switch(t.type){case`insert-text`:{let{state:n,dispatch:r}=e.view,{from:i,to:a}=n.selection;r(n.tr.insertText(t.text,i,a));break}}}},ed=m.a($u),td=e=>typeof e==`object`&&!!e&&`next`in e,nd=class{constructor(e,t,n){this.dom=document.createElement(`span`),this.dom.className=`atom-wrapper`,this.dom.setAttribute(`part`,`node--${n}`);let r=t.resolveValue?t.resolveValue(e.attrs.value):e.attrs.value;td(r)?(this.dom.textContent=``,this.handleResolvedGenerator(r)):this.dom.textContent=r??``}async handleResolvedGenerator(e){let t=e[Symbol.asyncIterator](),n;do n=await t.next(),this.dom.textContent=n.value??``;while(!n.done)}},rd=class extends m.r{constructor(e,t={}){super(),this.atomName=e,this.config=t,this.name=`RteAtomFeature[${e}]`}getSchema(){let e={inline:!0,group:`inline`,selectable:!0,atom:!0,attrs:{value:{validate:`string`}},parseDOM:[{tag:`span[data-atom-type="${this.atomName}"][data-value]`,getAttrs:e=>({value:e.getAttribute(`data-value`)})}],toDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createDocumentFragment():[`span`,{part:`node--${this.atomName}`},t]},serializeToDOM:e=>{let t=this.config.serializeValueToHtml?this.config.serializeValueToHtml(e.attrs.value):e.attrs.value;return t===null?document.createTextNode(``):[`span`,{"data-atom-type":this.atomName,"data-value":e.attrs.value},t]}};return[this.contribution({nodes:{[this.atomName]:e}})]}getPlugins(e){return[this.contribution(new N({props:{nodeViews:{[this.atomName]:e=>new nd(e,this.config,this.atomName)}}}))]}},id=m.a(rd),ad=class extends m.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteInputRuleFeature[${e}]`}getInputRules(e){let t=`(?:${this.options.pattern.source})`,n=(t,n,r,i)=>{let a=this.options.handler(n);return a?t.tr.replaceWith(r,i,m.d.fromJSON(e.schema,a)):null},r={rule:new pl(this.options.matchAfterWhitespace?RegExp(`${t} $`):RegExp(`${t}$`),n)};return this.options.matchAfterWhitespace&&(r.enterHandler={regex:RegExp(`${t}$`),handler:n}),[this.contribution(r)]}},od=m.a(ad);function sd(e,t){return e.length===0?(t,n)=>e():(n,r)=>e(t)}var cd=class extends m.r{constructor(e,t){super(),this.featureId=e,this.options=t,this.name=`RteKeyboardShortcutsFeature[${e}]`}getPlugins(e){let t={};for(let[n,r]of Object.entries(this.options.shortcuts))t[n]=sd(r,e.facade);return[this.contribution(G(t),m.i.high)]}},ld=m.a(cd),ud=`.suggest-popover{flex-direction:column;gap:2px;max-block-size:408px;min-inline-size:128px;max-inline-size:248px;padding:4px;display:flex}.suggest-loading-widget{vertical-align:middle;white-space:normal;align-items:center;margin-inline-start:2px;display:inline-flex}.suggest-empty-message{color:var(--vvd-color-neutral-300);font:var(--vvd-typography-base);text-align:center;justify-content:center;align-items:center;min-block-size:40px;display:flex}.suggest-item--visible-focus{box-shadow:0 0 0 4px color-mix(in srgb, var(--focus-stroke-color,var(--vvd-color-cta-500)), transparent 85%), inset 0 0 0 3px var(--focus-stroke-gap-color,currentColor);outline:1px solid var(--focus-stroke-color,var(--vvd-color-cta-500));outline-offset:calc(-1px - var(--focus-inset,0px));--focus-stroke-gap-color:transparent}`,dd=e=>!!(e?.suggestions&&!e.dismissed),fd=e=>dd(e)&&e.suggestions.items.length>0;function pd(e,t){let{$cursor:n}=e.selection;if(!n)return null;let r=yl(n),i=t.exec(r);if(!i)return null;let a=n.pos-n.parentOffset;return{text:i[0],groups:[...i],start:a+i.index,end:a+i.index+i[0].length}}var md=(e,t,n)=>{let{state:r}=e;e.dispatch(ps(r.tr));let i=e.state.tr;i.replaceWith(t.start,t.end,m.d.fromJSON(e.state.schema,n));let a=i.mapping.map(t.end);i.setSelection(A.create(i.doc,a)),e.dispatch(i.scrollIntoView())},hd=class extends m.r{selectSuggestion(e,t,n){let r=this.options.select(n);md(e,t.match,r),e.focus()}async startLoadingSuggestions(e,t){let n=++this.loadGeneration,r=await this.options.load(e);n===this.loadGeneration&&t({type:`load`,generation:n,suggestions:r})}constructor(e,t){super(),this.featureId=e,this.options=t,this.pluginKey=new wt(`suggest`),this.loadGeneration=0,this.name=`RteSuggestFeature[${e}]`}getStyles(){return[this.contribution(ud)]}getPlugins(e){let t=t=>e.state.tr.setMeta(this.pluginKey,t),n=n=>e.dispatchTransaction(t(n)),r=new N({key:this.pluginKey,state:{init:()=>null,apply:(t,r,a,o)=>{let s=pd(o,this.options.pattern);if(!s||!r&&!t.docChanged)return null;if(r?.dismissed)return r;let c=n=>n?r?.loadingDecoration.find().length??0?r.loadingDecoration.map(t.mapping,t.doc):H.create(t.doc,[V.widget(s.end,()=>{let t=document.createElement(`span`);t.className=`suggest-loading-widget`;let n=e.createComponent(i.r);return n.size=-6,t.appendChild(n),t},{ignoreSelection:!0,side:1})]):H.empty,l=t.getMeta(this.pluginKey);if(r&&l)switch(l.type){case`load`:return{...r,suggestions:{generation:l.generation,items:l.suggestions,selectedIndex:0,visibleFocus:!1},loadingDecoration:c(!1)};case`navigate`:{if(!r.suggestions?.items.length)return r;if(!r.suggestions.visibleFocus)return{...r,suggestions:{...r.suggestions,visibleFocus:!0}};let e=Math.max(0,Math.min(r.suggestions.items.length-1,r.suggestions.selectedIndex+(l.action===`up`?-1:1)));return{...r,suggestions:{...r.suggestions,selectedIndex:e}}}case`dismiss`:return{...r,dismissed:!0,loadingDecoration:H.empty}}if(!r)return this.startLoadingSuggestions(s.groups,n),{match:s,loadingDecoration:c(!0)};let u=s.groups[0]!==r.match.groups[0];return u&&this.startLoadingSuggestions(s.groups,n),{...r,match:s,suggestions:r.suggestions?{...r.suggestions,visibleFocus:!1}:void 0,loadingDecoration:c(u)}}},props:{decorations:e=>{let t=this.pluginKey.getState(e);return t?t.loadingDecoration.add(e.doc,[V.inline(t.match.start,t.match.end,{id:`suggest-anchor-${this.featureId}`})]):null}},view:t=>{let n=new Ss(t,e,{popupPlacement:`bottom`}),r=e.createComponent(y);r.anchorId=`suggest-anchor-${this.featureId}`,r.kind=`autocomplete`,r.offset=4;let i=J(n,{className:`suggest-popover`,children:[]});r.appendChild(i),t.dom.getRootNode().querySelector(`.popovers`).appendChild(r);let a=`${this.featureId}-suggestions-empty`,o=t.dom.getRootNode().host,s=!1,c=e=>{!s&&e&&m.t(o,`suggestions-empty-state`,a,{id:this.featureId}),s&&!e&&m.t(o,`suggestions-empty-state`,a,m.n),s=e},l=r=>{i.innerHTML=``;let o=r.suggestions,s=o.items.length===0;if(c(s),s){let t=document.createElement(`slot`);t.name=a,t.textContent=e.getLocale().richTextEditor.suggestNoResults,i.appendChild(J(n,{className:`suggest-empty-message`,children:[t]}));return}for(let[n,a]of o.items.entries()){let s=e.createComponent(u.r);s.text=a.text,s.textSecondary=a.textSecondary,n===o.selectedIndex&&(s._highlighted=!0,s.dataset.highlighted=`true`,o.visibleFocus&&s.classList.add(`suggest-item--visible-focus`),queueMicrotask(()=>{s.scrollIntoView({block:`nearest`})})),s.addEventListener(`click`,e=>{e.preventDefault(),e.stopPropagation(),this.selectSuggestion(t,r,a)}),i.appendChild(s)}};return{update:e=>{n.updateBindings();let t=this.pluginKey.getState(e.state),i=dd(t);r.requestOpenState(i),i?l(t):c(!1)},destroy:()=>{c(!1),r.remove()}}}});return[this.contribution(r),this.contribution(G({ArrowUp:(e,n)=>fd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`up`})),!0):!1,ArrowDown:(e,n)=>fd(this.pluginKey.getState(e))?(n?.(t({type:`navigate`,action:`down`})),!0):!1,Enter:(e,t,n)=>{let r=this.pluginKey.getState(e);if(!fd(r))return!1;let i=r.suggestions.items[r.suggestions.selectedIndex];return n&&this.selectSuggestion(n,r,i),!0},Escape:(e,n)=>dd(this.pluginKey.getState(e))?(n?.(t({type:`dismiss`})),!0):!1}),m.i.high)]}},gd=m.a(hd),_d=e=>e.textBetween(0,e.content.size,void 0,` `).length,vd=class extends m.r{constructor(e){super(),this.config=e,this.name=`RteCharacterCountFeature`}getPlugins(){let e=this.config?.limit;return e===void 0?[]:[this.contribution(new N({filterTransaction:(t,n)=>{if(!t.docChanged)return!0;let r=_d(n.doc),i=_d(t.doc);if(i<=e)return!0;if(r>e)return i<=r;if(!t.getMeta(`paste`))return!1;let a=t.selection.$head.pos,o=a-(i-e),s=a;return t.deleteRange(o,s),_d(t.doc)<=e}}))]}getPublicInterface(e){let t=this.config?.limit;return{get characters(){return _d(e.state.doc)},get limit(){return t}}}},yd=m.a(vd),bd=t.o(`rich-text-editor`,te,_,[f.t,d.n,u.t,a.t,s.n,g.t,h.t,l.n,re,i.t],{styles:ee,shadowOptions:{delegatesFocus:!0}});t.s(bd)(),exports.RteAlignmentFeature=Fu,exports.RteAtomFeature=id,exports.RteBase=Sl,exports.RteBoldFeature=Jl,exports.RteCharacterCountFeature=yd,exports.RteConfig=ll,exports.RteDropHandlerFeature=Qu,exports.RteFileHandlerFeature=Xu,exports.RteFontSizePickerFeature=Fl,exports.RteHardBreakFeature=Ml,exports.RteHtmlParser=Qc,exports.RteHtmlSerializer=tl,exports.RteInlineImageFeature=qu,exports.RteInputRuleFeature=od,exports.RteItalicFeature=Xl,exports.RteKeyboardShortcutsFeature=ld,exports.RteLinkFeature=Bu,exports.RteListFeature=ju,exports.RteMonospaceFeature=ru,exports.RtePlaceholderFeature=Al,exports.RteStrikethroughFeature=eu,exports.RteSuggestFeature=gd,exports.RteTextBlockPickerFeature=wl,exports.RteTextColorPickerFeature=su,exports.RteToolbarButtonFeature=ed,exports.RteToolbarFeature=Dl,exports.RteUnderlineFeature=Ql;