@ncino/web-components 5.0.0-preview.1 → 5.0.0-preview.10

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 (223) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +1 -1
  2. package/dist/_virtual/index_html.js +1 -1
  3. package/dist/_virtual/index_react.js +1 -1
  4. package/dist/_virtual/preload-helper.js +1 -1
  5. package/dist/assets/node_modules/.pnpm/ckeditor5@45.2.1/node_modules/ckeditor5/dist/ckeditor5.css +1 -1
  6. package/dist/components/accordion/gator/base/accordion.gator.js +6 -6
  7. package/dist/components/accordion/gator/group/accordion-group.gator.js +2 -2
  8. package/dist/components/alert/gator/base/alert.gator.js +2 -2
  9. package/dist/components/alert/gator/subtitle/alert-subtitle.gator.js +2 -2
  10. package/dist/components/alert/gator/title/alert-title.gator.js +2 -2
  11. package/dist/components/avatar/gator/avatar.gator.js +2 -2
  12. package/dist/components/badge/gator/badge.gator.js +2 -2
  13. package/dist/components/banner/gator/banner.gator.js +2 -2
  14. package/dist/components/boolean/boolean.gator.js +6 -6
  15. package/dist/components/breadcrumbs/gator/breadcrumb/breadcrumb.gator.js +2 -2
  16. package/dist/components/button/gator/button.gator.js +4 -4
  17. package/dist/components/button-group/gator/button-group.gator.js +2 -2
  18. package/dist/components/card/gator/footer/card-footer.gator.js +2 -2
  19. package/dist/components/card/gator/header/card-header.gator.js +2 -2
  20. package/dist/components/checkbox/checkbox.gator.js +5 -5
  21. package/dist/components/checkbox-group/checkbox-group.gator.js +8 -8
  22. package/dist/components/chip/chip.js +1 -1
  23. package/dist/components/chip/gator/chip.gator.js +15 -5
  24. package/dist/components/combobox/base/combobox.js +1 -1
  25. package/dist/components/combobox/base/combobox.slds.js +13 -13
  26. package/dist/components/date-picker/base/gator/datepicker.gator.js +18 -18
  27. package/dist/components/date-picker/year-month-selector/year-month-selector.gator.js +2 -2
  28. package/dist/components/headline-card/gator/headline-card.gator.js +2 -2
  29. package/dist/components/icon/gator/icon.gator.js +2 -2
  30. package/dist/components/illustration/gator/illustration.gator.js +2 -2
  31. package/dist/components/input/base/input-base.gator.js +1 -1
  32. package/dist/components/input/gator/dropdown/input-dropdown.gator.js +11 -11
  33. package/dist/components/input/gator/input-currency/input-currency.gator.js +2 -2
  34. package/dist/components/input/gator/input-date/input-date.gator.js +15 -15
  35. package/dist/components/input/gator/input-file/input-file.gator.js +3 -3
  36. package/dist/components/input/gator/input-masked/input-masked.gator.js +1 -1
  37. package/dist/components/input/gator/input-phone/input-phone.gator.js +2 -2
  38. package/dist/components/input/gator/input-search/input-search.gator.js +2 -2
  39. package/dist/components/input/gator/input-text/input-text.gator.js +1 -1
  40. package/dist/components/input/gator/input-time/input-time.gator.js +2 -2
  41. package/dist/components/list/gator/list/list.gator.js +2 -2
  42. package/dist/components/list/gator/list-item/list-item.gator.js +6 -6
  43. package/dist/components/menu/base/gator/menu.gator.js +3 -3
  44. package/dist/components/menu/base/slds/menu.slds.js +2 -2
  45. package/dist/components/menu/menu-item/gator/menu-item.gator.js +2 -2
  46. package/dist/components/menu/menu-submenu/menu-submenu.js +1 -1
  47. package/dist/components/modal/gator/modal.gator.js +38 -39
  48. package/dist/components/page-header/gator/page-header.gator.js +2 -2
  49. package/dist/components/panel/gator/panel.gator.js +13 -13
  50. package/dist/components/panel/gator/panel.storybook-test.js +1 -1
  51. package/dist/components/pill/pill.slds.js +3 -3
  52. package/dist/components/popover/gator/popover.gator.js +10 -10
  53. package/dist/components/popover/popover.js +1 -1
  54. package/dist/components/radio/radio.gator.js +2 -2
  55. package/dist/components/radio-group/radio-group.gator.js +2 -2
  56. package/dist/components/selection-box-group/selection-box-group.gator.js +5 -5
  57. package/dist/components/selector/gator/selector.gator.js +2 -2
  58. package/dist/components/switch/gator/switch.gator.js +2 -2
  59. package/dist/components/table/gator/table-bulk-controls/table-bulk-controls.gator.js +16 -0
  60. package/dist/components/table/gator/table.gator.js +55 -36
  61. package/dist/components/tabs/gator/tabset/tabset.gator.js +3 -3
  62. package/dist/components/text-detail/gator/text-detail.gator.js +17 -18
  63. package/dist/components/time-picker/gator/time-picker.gator.js +19 -19
  64. package/dist/components/toast/gator/base/toast.gator.js +8 -9
  65. package/dist/components/toast/gator/subtitle/toast-subtitle.gator.js +2 -2
  66. package/dist/components/toast/gator/title/toast-title.gator.js +2 -2
  67. package/dist/components/toast/toast.js +1 -1
  68. package/dist/components/toast-container/gator/toast-container.gator.js +18 -0
  69. package/dist/components/toast-container/index.js +1 -0
  70. package/dist/components/toaster/gator/toaster.gator.js +5 -0
  71. package/dist/components/toaster/index.js +1 -0
  72. package/dist/components/tooltip/tooltip.js +1 -1
  73. package/dist/index.gator.js +1 -1
  74. package/dist/index.js +1 -1
  75. package/dist/index.services.js +1 -0
  76. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-autosave@45.2.1/node_modules/@ckeditor/ckeditor5-autosave/dist/index.js +2 -2
  77. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-basic-styles@45.2.1/node_modules/@ckeditor/ckeditor5-basic-styles/dist/index.js +2 -2
  78. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-clipboard@45.2.1/node_modules/@ckeditor/ckeditor5-clipboard/dist/index.js +10 -10
  79. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-cloud-services@45.2.1/node_modules/@ckeditor/ckeditor5-cloud-services/dist/index.js +2 -2
  80. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-code-block@45.2.1/node_modules/@ckeditor/ckeditor5-code-block/dist/index.js +5 -5
  81. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-core@45.2.1/node_modules/@ckeditor/ckeditor5-core/dist/index.js +2 -2
  82. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-editor-classic@45.2.1/node_modules/@ckeditor/ckeditor5-editor-classic/dist/index.js +2 -2
  83. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-engine@45.2.1/node_modules/@ckeditor/ckeditor5-engine/dist/index.js +12 -12
  84. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-find-and-replace@45.2.1/node_modules/@ckeditor/ckeditor5-find-and-replace/dist/index.js +3 -3
  85. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-font@45.2.1/node_modules/@ckeditor/ckeditor5-font/dist/index.js +3 -3
  86. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-heading@45.2.1/node_modules/@ckeditor/ckeditor5-heading/dist/index.js +3 -3
  87. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-embed@45.2.1/node_modules/@ckeditor/ckeditor5-html-embed/dist/index.js +2 -2
  88. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-html-support@45.2.1/node_modules/@ckeditor/ckeditor5-html-support/dist/index.js +6 -6
  89. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-image@45.2.1/node_modules/@ckeditor/ckeditor5-image/dist/index.js +4 -4
  90. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-indent@45.2.1/node_modules/@ckeditor/ckeditor5-indent/dist/index.js +4 -4
  91. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-link@45.2.1/node_modules/@ckeditor/ckeditor5-link/dist/index.js +2 -2
  92. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-list@45.2.1/node_modules/@ckeditor/ckeditor5-list/dist/index.js +5 -5
  93. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-markdown-gfm@45.2.1/node_modules/@ckeditor/ckeditor5-markdown-gfm/dist/index.js +4 -4
  94. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-media-embed@45.2.1/node_modules/@ckeditor/ckeditor5-media-embed/dist/index.js +2 -2
  95. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paragraph@45.2.1/node_modules/@ckeditor/ckeditor5-paragraph/dist/index.js +2 -2
  96. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-paste-from-office@45.2.1/node_modules/@ckeditor/ckeditor5-paste-from-office/dist/index.js +9 -9
  97. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-source-editing@45.2.1/node_modules/@ckeditor/ckeditor5-source-editing/dist/index.js +2 -2
  98. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-special-characters@45.2.1/node_modules/@ckeditor/ckeditor5-special-characters/dist/index.js +2 -2
  99. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-style@45.2.1/node_modules/@ckeditor/ckeditor5-style/dist/index.js +2 -2
  100. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-table@45.2.1/node_modules/@ckeditor/ckeditor5-table/dist/index.js +6 -6
  101. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-typing@45.2.1/node_modules/@ckeditor/ckeditor5-typing/dist/index.js +4 -4
  102. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-ui@45.2.1/node_modules/@ckeditor/ckeditor5-ui/dist/index.js +10 -10
  103. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-undo@45.2.1/node_modules/@ckeditor/ckeditor5-undo/dist/index.js +2 -2
  104. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-upload@45.2.1/node_modules/@ckeditor/ckeditor5-upload/dist/index.js +2 -2
  105. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js +38 -38
  106. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-watchdog@45.2.1/node_modules/@ckeditor/ckeditor5-watchdog/dist/index.js +3 -3
  107. package/dist/node_modules/.pnpm/@ckeditor_ckeditor5-widget@45.2.1/node_modules/@ckeditor/ckeditor5-widget/dist/index.js +2 -2
  108. package/dist/node_modules/.pnpm/@deltablot_dropzone@7.3.1/node_modules/@deltablot/dropzone/dist/dropzone.js +1 -1
  109. package/dist/node_modules/.pnpm/@fastify_busboy@2.1.1/node_modules/@fastify/busboy/lib/main.js +1 -1
  110. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/common/fetch.js +1 -0
  111. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +1 -0
  112. package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/helpers.js +1 -1
  113. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.4/node_modules/@figma/code-connect/package.json.js +1 -0
  114. package/dist/node_modules/.pnpm/@floating-ui_dom@1.7.2/node_modules/@floating-ui/dom/dist/floating-ui.dom.js +1 -1
  115. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.4/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.js +1 -0
  116. package/dist/node_modules/.pnpm/@lit_reactive-element@2.1.0/node_modules/@lit/reactive-element/reactive-element.js +2 -2
  117. package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/channels/index.js +9 -9
  118. package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/csf/index.js +1 -1
  119. package/dist/node_modules/.pnpm/@storybook_core@8.6.14_prettier@3.6.2_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/core/dist/preview-api/index.js +22 -22
  120. package/dist/node_modules/.pnpm/@storybook_instrumenter@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/instrumenter/dist/index.js +36 -36
  121. package/dist/node_modules/.pnpm/@storybook_test@8.6.14_storybook@8.6.14_prettier@3.6.2_/node_modules/@storybook/test/dist/index.js +111 -111
  122. package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.2_77c47ac19cbe97978028e1e5ac862536/node_modules/@vitest/browser/context.js +1 -0
  123. package/dist/node_modules/.pnpm/@vitest_expect@3.2.4/node_modules/@vitest/expect/dist/index.js +8 -8
  124. package/dist/node_modules/.pnpm/@vitest_pretty-format@3.2.4/node_modules/@vitest/pretty-format/dist/index.js +2 -2
  125. package/dist/node_modules/.pnpm/@vitest_runner@3.2.4/node_modules/@vitest/runner/dist/chunk-hooks.js +5 -5
  126. package/dist/node_modules/.pnpm/@vitest_snapshot@3.2.4/node_modules/@vitest/snapshot/dist/index.js +12 -12
  127. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/diff.js +21 -21
  128. package/dist/node_modules/.pnpm/@vitest_utils@3.2.4/node_modules/@vitest/utils/dist/error.js +2 -2
  129. package/dist/node_modules/.pnpm/axe-core@4.10.3/node_modules/axe-core/axe.js +4 -4
  130. package/dist/node_modules/.pnpm/chai@5.2.0/node_modules/chai/chai.js +3 -3
  131. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/_internal/isPrototype.js +1 -1
  132. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeepWith.js +1 -1
  133. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js +1 -1
  134. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/unset.js +1 -1
  135. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js +1 -1
  136. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/function/debounce.js +1 -1
  137. package/dist/node_modules/.pnpm/es-toolkit@1.32.0/node_modules/es-toolkit/dist/object/cloneDeepWith.js +1 -1
  138. package/dist/node_modules/.pnpm/lit-element@4.2.0/node_modules/lit-element/lit-element.js +2 -2
  139. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/async-directive.js +1 -1
  140. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directive-helpers.js +2 -2
  141. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/class-map.js +2 -2
  142. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/ref.js +2 -2
  143. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/directives/repeat.js +5 -0
  144. package/dist/node_modules/.pnpm/lit-html@3.3.0/node_modules/lit-html/lit-html.js +3 -3
  145. package/dist/node_modules/.pnpm/magic-string@0.30.17/node_modules/magic-string/dist/magic-string.es.js +1 -1
  146. package/dist/node_modules/.pnpm/tinyrainbow@2.0.0/node_modules/tinyrainbow/dist/chunk-BVHSVHOK.js +1 -1
  147. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cache.js +1 -1
  148. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cache/cachestorage.js +1 -1
  149. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/cookies/parse.js +1 -1
  150. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/constants.js +1 -1
  151. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/headers.js +1 -1
  152. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/index.js +1 -1
  153. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/request.js +1 -1
  154. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/response.js +1 -1
  155. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/util.js +2 -2
  156. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/fetch/webidl.js +1 -1
  157. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/connection.js +1 -1
  158. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/events.js +1 -1
  159. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/frame.js +1 -1
  160. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/receiver.js +1 -1
  161. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/util.js +1 -1
  162. package/dist/node_modules/.pnpm/undici@5.29.0/node_modules/undici/lib/websocket/websocket.js +1 -1
  163. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js +1 -1
  164. package/dist/node_modules/.pnpm/vitest@3.2.4_@types_debug@4.1.12_@types_node@24.0.10_@vitest_browser@3.2.4_@vitest_ui@3_8c34ee540b1f52c214debce201d1e515/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js +8 -8
  165. package/dist/packages/web-components/src/components/accordion/gator/base/accordion.gator.scss.js +1 -1
  166. package/dist/packages/web-components/src/components/accordion/gator/group/accordion-group.gator.scss.js +1 -1
  167. package/dist/packages/web-components/src/components/button/gator/button.gator.scss.js +1 -1
  168. package/dist/packages/web-components/src/components/button-card/gator/button-card.gator.scss.js +1 -1
  169. package/dist/packages/web-components/src/components/chip/gator/chip.gator.scss.js +1 -1
  170. package/dist/packages/web-components/src/components/modal/gator/modal.gator.scss.js +1 -1
  171. package/dist/packages/web-components/src/components/switch/gator/switch.gator.scss.js +1 -1
  172. package/dist/packages/web-components/src/components/table/gator/table-bulk-controls/table-bulk-controls.gator.scss.js +1 -0
  173. package/dist/packages/web-components/src/components/text-detail/gator/text-detail.gator.scss.js +1 -1
  174. package/dist/packages/web-components/src/components/toast/gator/base/toast.gator.scss.js +1 -1
  175. package/dist/packages/web-components/src/components/toast-container/gator/toast-container.gator.scss.js +1 -0
  176. package/dist/packages/web-components/src/components/toaster/gator/toaster.gator.scss.js +1 -0
  177. package/dist/packages/web-components/src/index.slds.scss.js +1 -1
  178. package/dist/services/toaster-service.js +1 -0
  179. package/dist/types/components/accordion/gator/group/accordion-group.gator.d.ts +5 -0
  180. package/dist/types/components/chip/chip.d.ts +10 -0
  181. package/dist/types/components/chip/gator/chip.gator.d.ts +1 -0
  182. package/dist/types/components/modal/gator/modal.gator.d.ts +1 -1
  183. package/dist/types/components/table/gator/table-bulk-controls/table-bulk-controls.gator.d.ts +29 -0
  184. package/dist/types/components/table/gator/table-bulk-controls/table-bulk-controls.gator.test.d.ts +0 -0
  185. package/dist/types/components/table/gator/table.gator.d.ts +9 -0
  186. package/dist/types/components/text-detail/gator/text-detail.gator.d.ts +4 -2
  187. package/dist/types/components/toast/toast.d.ts +14 -0
  188. package/dist/types/components/toast-container/gator/toast-container.gator.d.ts +15 -0
  189. package/dist/types/components/toast-container/gator/toast-container.gator.test.d.ts +0 -0
  190. package/dist/types/components/toast-container/index.d.ts +1 -0
  191. package/dist/types/components/toaster/gator/toaster.gator.d.ts +32 -0
  192. package/dist/types/components/toaster/gator/toaster.gator.test.d.ts +0 -0
  193. package/dist/types/components/toaster/index.d.ts +1 -0
  194. package/dist/types/index.d.ts +2 -0
  195. package/dist/types/index.gator.d.ts +2 -0
  196. package/dist/types/index.services.d.ts +1 -0
  197. package/dist/types/services/toaster-service.d.ts +117 -0
  198. package/dist/types/services/toaster-service.test.d.ts +1 -0
  199. package/dist/utils/accessibility-utils.js +1 -1
  200. package/dist/utils/datatestid-utils.js +1 -1
  201. package/dist/utils/lightdom-utils.js +1 -1
  202. package/dist/utils/vitest-a11y-utils.js +1 -1
  203. package/dist/utils/vitest-utils.js +1 -1
  204. package/package.json +15 -11
  205. package/web-types.json +286 -113
  206. package/dist/_virtual/sourcemap-codec.umd.js +0 -1
  207. package/dist/_virtual/sourcemap-codec.umd2.js +0 -1
  208. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/common/fetch.js +0 -1
  209. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/dist/connect/figma_rest_api.js +0 -1
  210. package/dist/node_modules/.pnpm/@figma_code-connect@1.3.3/node_modules/@figma/code-connect/package.json.js +0 -1
  211. package/dist/node_modules/.pnpm/@jridgewell_sourcemap-codec@1.5.0/node_modules/@jridgewell/sourcemap-codec/dist/sourcemap-codec.umd.js +0 -1
  212. package/dist/node_modules/.pnpm/@vitest_browser@3.2.4_msw@2.7.3_@types_node@24.0.10_typescript@5.8.3__playwright@1.53.1_5fd2997ee9a97429a51e07bc2023c338/node_modules/@vitest/browser/context.js +0 -1
  213. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/external.js +0 -0
  214. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/client/figma_client.js +0 -0
  215. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/logging.js +0 -0
  216. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/common/updates.js +0 -0
  217. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/external_types.js +0 -0
  218. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/connect/index_common.js +0 -0
  219. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/external.js +0 -0
  220. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/index_html.js +0 -0
  221. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/html/template_literal.js +0 -0
  222. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/external.js +0 -0
  223. /package/dist/node_modules/.pnpm/{@figma_code-connect@1.3.3 → @figma_code-connect@1.3.4}/node_modules/@figma/code-connect/dist/react/index_react.js +0 -0
@@ -1,30 +1,30 @@
1
- var Ds=Object.defineProperty;var Vs=(r,t,e)=>t in r?Ds(r,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):r[t]=e;var c=(r,t,e)=>Vs(r,typeof t!="symbol"?t+"":t,e);import{global as ie,EmitterMixin as O,CKEditorError as d,compareArrays as B,toMap as we,ObservableMixin as J,count as tn,isIterable as ce,toArray as le,EventInfo as Tt,Collection as qt,uid as $s,spliceArray as nn,logWarning as q,DomEmitterMixin as Ls,isValidAttributeName as Ws,first as zt,isText as R,indexOf as Te,getAncestors as qs,isComment as We,env as x,scrollViewportToShowTarget as zs,isInsideSurrogatePair as zn,isInsideCombinedSymbol as Un,remove as sn,insertAt as Jn,diff as pt,fastDiff as Us,keyCodes as me,isArrowKeyCode as Js,priorities as _t,isInsideEmojiSequence as js,isNode as lt,getCode as Gs}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{clone as jn}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/object/clone.js";import{isEqual as rn}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/predicate/isEqual.js";import{isObject as ct}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isObject.js";import{unset as Hs}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/unset.js";import{get as ht}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js";import{isPlainObject as Mt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js";import{assignIn as Ks}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/assignIn.js";import{merge as Gn}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/merge.js";import{set as Xs}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/set.js";import{cloneDeep as he}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeep.js";import{isEqualWith as Ys}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js";import{debounce as xt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/debounce.js";/**
1
+ import{global as re,EmitterMixin as N,CKEditorError as f,compareArrays as F,toMap as pe,ObservableMixin as U,count as Zt,isIterable as le,toArray as ae,EventInfo as Rt,Collection as Lt,uid as Fs,spliceArray as en,logWarning as W,DomEmitterMixin as Ds,isValidAttributeName as Bs,first as Wt,isText as E,indexOf as Ee,getAncestors as Vs,isComment as Le,env as M,scrollViewportToShowTarget as $s,isInsideSurrogatePair as Wn,isInsideCombinedSymbol as qn,remove as tn,insertAt as zn,diff as gt,fastDiff as Ls,keyCodes as de,isArrowKeyCode as Ws,priorities as pt,isInsideEmojiSequence as qs,isNode as ot,getCode as zs}from"../../../../../@ckeditor_ckeditor5-utils@45.2.1/node_modules/@ckeditor/ckeditor5-utils/dist/index.js";import{clone as Un}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/object/clone.js";import{isEqual as nn}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/predicate/isEqual.js";import{isObject as at}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isObject.js";import{unset as Us}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/unset.js";import{get as lt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/get.js";import{isPlainObject as Tt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isPlainObject.js";import{assignIn as Js}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/assignIn.js";import{merge as Jn}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/merge.js";import{set as js}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/set.js";import{cloneDeep as ce}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/object/cloneDeep.js";import{isEqualWith as Gs}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/predicate/isEqualWith.js";import{debounce as Mt}from"../../../../../es-toolkit@1.32.0/node_modules/es-toolkit/dist/compat/function/debounce.js";/**
2
2
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
3
3
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
4
- */const Oe=new WeakMap;let on=!1;function fl({view:r,element:t,text:e,isDirectHost:n=!0,keepOnFocus:s=!1}){const i=r.document;Oe.has(i)||(Oe.set(i,new Map),i.registerPostFixer(a=>wt(Oe.get(i),a)),i.on("change:isComposing",()=>{r.change(a=>wt(Oe.get(i),a))},{priority:"high"})),t.is("editableElement")&&t.on("change:placeholder",(a,l,h)=>o(h)),t.placeholder?o(t.placeholder):e&&o(e),e&&sr();function o(a){const l={text:a,isDirectHost:n,keepOnFocus:s,hostElement:n?t:null};Oe.get(i).set(t,l),r.change(h=>wt([[t,l]],h))}}function Qs(r,t){return t.hasClass("ck-placeholder")?!1:(r.addClass("ck-placeholder",t),!0)}function Zs(r,t){return t.hasClass("ck-placeholder")?(r.removeClass("ck-placeholder",t),!0):!1}function er(r,t){if(!r.isAttached()||tr(r))return!1;const e=r.document,s=e.selection.anchor;return e.isComposing&&s&&s.parent===r?!1:t||!e.isFocused?!0:!!s&&s.parent!==r}function tr(r){for(const t of r.getChildren())if(!t.is("uiElement"))return!0;return!1}function wt(r,t){const e=[];let n=!1;for(const[s,i]of r)i.isDirectHost&&(e.push(s),an(t,s,i)&&(n=!0));for(const[s,i]of r){if(i.isDirectHost)continue;const o=nr(s);o&&(e.includes(o)||(i.hostElement=o,an(t,s,i)&&(n=!0)))}return n}function an(r,t,e){const{text:n,isDirectHost:s,hostElement:i}=e;let o=!1;return i.getAttribute("data-placeholder")!==n&&(r.setAttribute("data-placeholder",n,i),o=!0),(s||t.childCount==1)&&er(i,e.keepOnFocus)?Qs(r,i)&&(o=!0):Zs(r,i)&&(o=!0),o}function nr(r){if(r.childCount){const t=r.getChild(0);if(t.is("element")&&!t.is("uiElement")&&!t.is("attributeElement"))return t}return null}function sr(){on||q("enableplaceholder-deprecated-text-option"),on=!0}/**
4
+ */const Ne=new WeakMap;let sn=!1;function al({view:s,element:e,text:t,isDirectHost:n=!0,keepOnFocus:r=!1}){const i=s.document;Ne.has(i)||(Ne.set(i,new Map),i.registerPostFixer(a=>_t(Ne.get(i),a)),i.on("change:isComposing",()=>{s.change(a=>_t(Ne.get(i),a))},{priority:"high"})),e.is("editableElement")&&e.on("change:placeholder",(a,l,c)=>o(c)),e.placeholder?o(e.placeholder):t&&o(t),t&&Zs();function o(a){const l={text:a,isDirectHost:n,keepOnFocus:r,hostElement:n?e:null};Ne.get(i).set(e,l),s.change(c=>_t([[e,l]],c))}}function Hs(s,e){return e.hasClass("ck-placeholder")?!1:(s.addClass("ck-placeholder",e),!0)}function Ks(s,e){return e.hasClass("ck-placeholder")?(s.removeClass("ck-placeholder",e),!0):!1}function Xs(s,e){if(!s.isAttached()||Ys(s))return!1;const t=s.document,r=t.selection.anchor;return t.isComposing&&r&&r.parent===s?!1:e||!t.isFocused?!0:!!r&&r.parent!==s}function Ys(s){for(const e of s.getChildren())if(!e.is("uiElement"))return!0;return!1}function _t(s,e){const t=[];let n=!1;for(const[r,i]of s)i.isDirectHost&&(t.push(r),rn(e,r,i)&&(n=!0));for(const[r,i]of s){if(i.isDirectHost)continue;const o=Qs(r);o&&(t.includes(o)||(i.hostElement=o,rn(e,r,i)&&(n=!0)))}return n}function rn(s,e,t){const{text:n,isDirectHost:r,hostElement:i}=t;let o=!1;return i.getAttribute("data-placeholder")!==n&&(s.setAttribute("data-placeholder",n,i),o=!0),(r||e.childCount==1)&&Xs(i,t.keepOnFocus)?Hs(s,i)&&(o=!0):Ks(s,i)&&(o=!0),o}function Qs(s){if(s.childCount){const e=s.getChild(0);if(e.is("element")&&!e.is("uiElement")&&!e.is("attributeElement"))return e}return null}function Zs(){sn||W("enableplaceholder-deprecated-text-option"),sn=!0}/**
5
5
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
6
6
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
7
- */let ye=class{is(){throw new Error("is() method is abstract")}},ve=class extends O(ye){constructor(e){super();c(this,"document");c(this,"parent");this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))==-1)throw new d("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let n=this;for(;n.parent;)e.unshift(n.index),n=n.parent;return e}getAncestors(e={}){const n=[];let s=e.includeSelf?this:this.parent;for(;s;)n[e.parentFirst?"push":"unshift"](s),s=s.parent;return n}getCommonAncestor(e,n={}){const s=this.getAncestors(n),i=e.getAncestors(n);let o=0;for(;s[o]==i[o]&&s[o];)o++;return o===0?null:s[o-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const n=this.getPath(),s=e.getPath(),i=B(n,s);switch(i){case"prefix":return!0;case"extension":return!1;default:return n[i]<s[i]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,n,s){this.fire(`change:${e}`,n,s),this.parent&&this.parent._fireChange(e,n,s)}toJSON(){const e=jn(this);return delete e.parent,e}};ve.prototype.is=function(r){return r==="node"||r==="view:node"};let N=class Nt extends ve{constructor(e,n){super(e);c(this,"_textData");this._textData=n}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof Nt?this===e||this.data===e.data:!1}_clone(){return new Nt(this.document,this.data)}};N.prototype.is=function(r){return r==="$text"||r==="view:$text"||r==="text"||r==="view:text"||r==="node"||r==="view:node"};let Z=class extends ye{constructor(e,n,s){super();c(this,"textNode");c(this,"data");c(this,"offsetInText");if(this.textNode=e,n<0||n>e.data.length)throw new d("view-textproxy-wrong-offsetintext",this);if(s<0||n+s>e.data.length)throw new d("view-textproxy-wrong-length",this);this.data=e.data.substring(n,n+s),this.offsetInText=n}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const n=[];let s=e.includeSelf?this.textNode:this.parent;for(;s!==null;)n[e.parentFirst?"push":"unshift"](s),s=s.parent;return n}};Z.prototype.is=function(r){return r==="$textProxy"||r==="view:$textProxy"||r==="textProxy"||r==="view:textProxy"};class ut{constructor(){c(this,"_consumables",new Map)}add(t,e){let n;if(t.is("$text")||t.is("documentFragment")){this._consumables.set(t,!0);return}this._consumables.has(t)?n=this._consumables.get(t):(n=new rr(t),this._consumables.set(t,n)),n.add(e?$e(e):t._getConsumables())}test(t,e){const n=this._consumables.get(t);return n===void 0?null:t.is("$text")||t.is("documentFragment")?n:n.test($e(e))}consume(t,e){if(t.is("$text")||t.is("documentFragment"))return this.test(t,e)?(this._consumables.set(t,!1),!0):!1;const n=this._consumables.get(t);return n===void 0?!1:n.consume($e(e))}revert(t,e){const n=this._consumables.get(t);n!==void 0&&(t.is("$text")||t.is("documentFragment")?this._consumables.set(t,!0):n.revert($e(e)))}static createFrom(t,e){if(e||(e=new ut),t.is("$text"))e.add(t);else if(t.is("element")||t.is("documentFragment")){e.add(t);for(const n of t.getChildren())ut.createFrom(n,e)}return e}}class rr{constructor(t){c(this,"element");c(this,"_canConsumeName",null);c(this,"_attributes",new Map);this.element=t}add(t){t.name&&(this._canConsumeName=!0);for(const[e,n]of t.attributes)if(n){let s=this._attributes.get(e);(!s||typeof s=="boolean")&&(s=new Map,this._attributes.set(e,s)),s.set(n,!0)}else{if(e=="style"||e=="class")throw new d("viewconsumable-invalid-attribute",this);this._attributes.set(e,!0)}}test(t){if(t.name&&!this._canConsumeName)return this._canConsumeName;for(const[e,n]of t.attributes){const s=this._attributes.get(e);if(s===void 0)return null;if(s===!1)return!1;if(s!==!0){if(n){const i=s.get(n);if(i===void 0)return null;if(!i)return!1}else for(const i of s.values())if(!i)return!1}}return!0}consume(t){if(!this.test(t))return!1;t.name&&(this._canConsumeName=!1);for(const[e,n]of t.attributes){const s=this._attributes.get(e);if(typeof s=="boolean")for(const[i]of this.element._getConsumables(e,n).attributes)this._attributes.set(i,!1);else if(n)for(const[,i]of this.element._getConsumables(e,n).attributes)s.set(i,!1);else for(const i of s.keys())s.set(i,!1)}return!0}revert(t){t.name&&(this._canConsumeName=!0);for(const[e,n]of t.attributes){const s=this._attributes.get(e);if(s===!1){this._attributes.set(e,!0);continue}if(!(s===void 0||s===!0))if(n)s.get(n)===!1&&s.set(n,!0);else for(const i of s.keys())s.set(i,!0)}}}function $e(r){const t=[];return"attributes"in r&&r.attributes&&bt(t,r.attributes),"classes"in r&&r.classes&&bt(t,r.classes,"class"),"styles"in r&&r.styles&&bt(t,r.styles,"style"),{name:r.name||!1,attributes:t}}function bt(r,t,e){if(typeof t=="string"){r.push(e?[e,t]:[t]);return}for(const n of t)Array.isArray(n)?r.push(n):r.push(e?[e,n]:[n])}class He{constructor(...t){c(this,"_patterns",[]);this.add(...t)}add(...t){for(let e of t)(typeof e=="string"||e instanceof RegExp)&&(e={name:e}),this._patterns.push(e)}match(...t){for(const e of t)for(const n of this._patterns){const s=this._isElementMatching(e,n);if(s)return{element:e,pattern:n,match:s}}return null}matchAll(...t){const e=[];for(const n of t)for(const s of this._patterns){const i=this._isElementMatching(n,s);i&&e.push({element:n,pattern:s,match:i})}return e.length>0?e:null}getElementName(){if(this._patterns.length!==1)return null;const t=this._patterns[0],e=t.name;return typeof t!="function"&&e&&!(e instanceof RegExp)?e:null}_isElementMatching(t,e){if(typeof e=="function"){const i=e(t);return!i||typeof i!="object"?i:$e(i)}const n={};if(e.name&&(n.name=ir(e.name,t.name),!n.name))return null;const s=[];return e.attributes&&!or(e.attributes,t,s)||e.classes&&!ar(e.classes,t,s)||e.styles&&!lr(e.styles,t,s)?null:(s.length&&(n.attributes=s),n)}}function ft(r,t){return r===!0||r===t||r instanceof RegExp&&!!String(t).match(r)}function ir(r,t){return r instanceof RegExp?!!t.match(r):r===t}function Ut(r,t){if(Array.isArray(r))return r.map(n=>typeof n!="object"||n instanceof RegExp?t?[t,n,!0]:[n,!0]:((n.key===void 0||n.value===void 0)&&q("matcher-pattern-missing-key-or-value",n),t?[t,n.key,n.value]:[n.key,n.value]));if(typeof r!="object"||r instanceof RegExp)return[t?[t,r,!0]:[r,!0]];const e=[];for(const n in r)Object.prototype.hasOwnProperty.call(r,n)&&e.push(t?[t,n,r[n]]:[n,r[n]]);return e}function or(r,t,e){let n;return typeof r=="object"&&!(r instanceof RegExp)&&!Array.isArray(r)?(r.style!==void 0&&q("matcher-pattern-deprecated-attributes-style-key",r),r.class!==void 0&&q("matcher-pattern-deprecated-attributes-class-key",r)):n=["class","style"],t._collectAttributesMatch(Ut(r),e,n)}function ar(r,t,e){return t._collectAttributesMatch(Ut(r,"class"),e)}function lr(r,t,e){return t._collectAttributesMatch(Ut(r,"style"),e)}class qe{constructor(t){c(this,"_styles");c(this,"_cachedStyleNames",null);c(this,"_cachedExpandedStyleNames",null);c(this,"_styleProcessor");this._styles={},this._styleProcessor=t}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(t){this.clear();const e=cr(t);for(const[n,s]of e)this._styleProcessor.toNormalizedForm(n,s,this._styles);return this}has(t){if(this.isEmpty)return!1;const n=this._styleProcessor.getReducedForm(t,this._styles).find(([s])=>s===t);return Array.isArray(n)}set(t,e){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,ct(t))for(const[n,s]of Object.entries(t))this._styleProcessor.toNormalizedForm(n,s,this._styles);else this._styleProcessor.toNormalizedForm(t,e,this._styles)}remove(t){for(const e of le(t)){this._cachedStyleNames=null,this._cachedExpandedStyleNames=null;const n=Ot(e);Hs(this._styles,n),delete this._styles[e],this._cleanEmptyObjectsOnPath(n)}}getNormalized(t){return this._styleProcessor.getNormalized(t,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(t=>t.join(":")).sort().join(";")+";"}getAsString(t){if(this.isEmpty)return;if(this._styles[t]&&!ct(this._styles[t]))return this._styles[t];const n=this._styleProcessor.getReducedForm(t,this._styles).find(([s])=>s===t);if(Array.isArray(n))return n[1]}getStyleNames(t=!1){return this.isEmpty?[]:t?(this._cachedExpandedStyleNames||(this._cachedExpandedStyleNames=this._styleProcessor.getStyleNames(this._styles)),this._cachedExpandedStyleNames):(this._cachedStyleNames||(this._cachedStyleNames=this.getStylesEntries().map(([e])=>e)),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(t){if(this.size!==t.size)return!1;for(const e of this.getStyleNames())if(!t.has(e)||t.getAsString(e)!==this.getAsString(e))return!1;return!0}getStylesEntries(){const t=[],e=Object.keys(this._styles);for(const n of e)t.push(...this._styleProcessor.getReducedForm(n,this._styles));return t}_clone(){const t=new this.constructor(this._styleProcessor);return t.set(this.getNormalized()),t}_getTokensMatch(t,e){const n=[];for(const s of this.getStyleNames(!0))if(ft(t,s)){if(e===!0){n.push(s);continue}const i=this.getAsString(s);ft(e,i)&&n.push(s)}return n.length?n:void 0}_getConsumables(t){const e=[];if(t){e.push(t);for(const n of this._styleProcessor.getRelatedStyles(t))e.push(n)}else for(const n of this.getStyleNames()){for(const s of this._styleProcessor.getRelatedStyles(n))e.push(s);e.push(n)}return e}_canMergeFrom(t){for(const e of t.getStyleNames())if(this.has(e)&&this.getAsString(e)!==t.getAsString(e))return!1;return!0}_mergeFrom(t){for(const e of t.getStyleNames())this.has(e)||this.set(e,t.getAsString(e))}_isMatching(t){for(const e of t.getStyleNames())if(!this.has(e)||this.getAsString(e)!==t.getAsString(e))return!1;return!0}_cleanEmptyObjectsOnPath(t){const e=t.split(".");if(!(e.length>1))return;const s=e.splice(0,e.length-1).join("."),i=ht(this._styles,s);if(!i)return;!Object.keys(i).length&&this.remove(s)}}class pl{constructor(){c(this,"_normalizers");c(this,"_extractors");c(this,"_reducers");c(this,"_consumables");this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(t,e,n){if(ct(e)){yt(n,Ot(t),e);return}if(this._normalizers.has(t)){const s=this._normalizers.get(t),{path:i,value:o}=s(e);yt(n,i,o)}else yt(n,t,e)}getNormalized(t,e){if(!t)return Gn({},e);if(e[t]!==void 0)return e[t];if(this._extractors.has(t)){const n=this._extractors.get(t);if(typeof n=="string")return ht(e,n);const s=n(t,e);if(s)return s}return ht(e,Ot(t))}getReducedForm(t,e){const n=this.getNormalized(t,e);return n===void 0?[]:this._reducers.has(t)?this._reducers.get(t)(n):[[t,n]]}getStyleNames(t){const e=new Set;for(const n of this._consumables.keys()){const s=this.getNormalized(n,t);s&&(typeof s!="object"||Object.keys(s).length)&&e.add(n)}for(const n of Object.keys(t))e.add(n);return Array.from(e)}getRelatedStyles(t){return this._consumables.get(t)||[]}setNormalizer(t,e){this._normalizers.set(t,e)}setExtractor(t,e){this._extractors.set(t,e)}setReducer(t,e){this._reducers.set(t,e)}setStyleRelation(t,e){this._mapStyleNames(t,e);for(const n of e)this._mapStyleNames(n,[t])}_mapStyleNames(t,e){this._consumables.has(t)||this._consumables.set(t,[]),this._consumables.get(t).push(...e)}}function cr(r){let t=null,e=0,n=0,s=null;const i=new Map;if(r==="")return i;r.charAt(r.length-1)!=";"&&(r=r+";");for(let o=0;o<r.length;o++){const a=r.charAt(o);if(t===null)switch(a){case":":s||(s=r.substr(e,o-e),n=o+1);break;case'"':case"'":t=a;break;case";":{const l=r.substr(n,o-n);s&&i.set(s.trim(),l.trim()),s=null,e=o+1;break}}else a===t&&(t=null)}return i}function Ot(r){return r.replace("-",".")}function yt(r,t,e){let n=e;ct(e)&&(n=Gn({},ht(r,t),e)),Xs(r,t,n)}class vt{constructor(){c(this,"_set",new Set)}get isEmpty(){return this._set.size==0}get size(){return this._set.size}has(t){return this._set.has(t)}keys(){return Array.from(this._set.keys())}setTo(t){this.clear();for(const e of t.split(/\s+/))e&&this._set.add(e);return this}set(t){for(const e of le(t))e&&this._set.add(e)}remove(t){for(const e of le(t))this._set.delete(e)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(t){if(this.size!==t.size)return!1;for(const e of this.keys())if(!t.has(e))return!1;return!0}_clone(){const t=new this.constructor;return t._set=new Set(this._set),t}_getTokensMatch(t){const e=[];if(t===!0){for(const n of this._set.keys())e.push(n);return e}if(typeof t=="string"){for(const n of t.split(/\s+/))if(this._set.has(n))e.push(n);else return;return e}for(const n of this._set.keys())n.match(t)&&e.push(n);return e.length?e:void 0}_getConsumables(t){return t?[t]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(t){for(const e of t._set.keys())this._set.has(e)||this._set.add(e)}_isMatching(t){for(const e of t._set.keys())if(!this._set.has(e))return!1;return!0}}let ne=class Hn extends ve{constructor(e,n,s,i){super(e);c(this,"name");c(this,"_unsafeAttributesToRender",[]);c(this,"_attrs");c(this,"_children");c(this,"_customProperties",new Map);this.name=n,this._attrs=this._parseAttributes(s),this._children=[],i&&this._insertChild(0,i)}get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}get childCount(){return this._children.length}get isEmpty(){return this._children.length===0}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())e!="class"&&e!="style"&&(yield e)}*getAttributes(){for(const[e,n]of this._attrs.entries())yield[e,String(n)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,n){return this._attrs.has(e)?n!==void 0?ke(this.name,e)||Ie(this.name,e)?this._attrs.get(e).has(n):this._attrs.get(e)===n:!0:!1}isSimilar(e){if(!(e instanceof Hn))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(const[n,s]of this._attrs){const i=e._attrs.get(n);if(i===void 0)return!1;if(typeof s=="string"||typeof i=="string"){if(i!==s)return!1}else if(!s.isSimilar(i))return!1}return!0}hasClass(...e){for(const n of e)if(!this._classes||!this._classes.has(n))return!1;return!0}getClassNames(){const e=this._classes?this._classes.keys():[],n=e[Symbol.iterator]();return Object.assign(e,{next:n.next.bind(n)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(...e){for(const n of e)if(!this._styles||!this._styles.has(n))return!1;return!0}findAncestor(...e){const n=new He(...e);let s=this.parent;for(;s&&!s.is("documentFragment");){if(n.match(s))return s;s=s.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",n=this._styles&&String(this._styles),s=Array.from(this._attrs).filter(([i])=>i!="style"&&i!="class").map(i=>`${i[0]}="${i[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(n?` style="${n}"`:"")+(s==""?"":` ${s}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const n=[];if(e)for(const i of this.getChildren())n.push(i._clone(e));const s=new this.constructor(this.document,this.name,this._attrs,n);return s._customProperties=new Map(this._customProperties),s.getFillerOffset=this.getFillerOffset,s._unsafeAttributesToRender=this._unsafeAttributesToRender,s}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,n){this._fireChange("children",this,{index:e});let s=0;const i=hr(this.document,n);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,o.document=this.document,this._children.splice(e,0,o),e++,s++;return s}_removeChildren(e,n=1){this._fireChange("children",this,{index:e});for(let s=e;s<e+n;s++)this._children[s].parent=null;return this._children.splice(e,n)}_setAttribute(e,n,s=!0){if(this._fireChange("attributes",this),ke(this.name,e)||Ie(this.name,e)){let i=this._attrs.get(e);i||(i=ke(this.name,e)?new qe(this.document.stylesProcessor):new vt,this._attrs.set(e,i)),s?i.setTo(String(n)):ke(this.name,e)?Array.isArray(n)?i.set(n[0],n[1]):i.set(n):i.set(typeof n=="string"?n.split(/\s+/):n)}else this._attrs.set(e,String(n))}_removeAttribute(e,n){if(this._fireChange("attributes",this),n!==void 0&&(ke(this.name,e)||Ie(this.name,e))){const s=this._attrs.get(e);return s?(Ie(this.name,e)&&typeof n=="string"&&(n=n.split(/\s+/)),s.remove(n),s.isEmpty?this._attrs.delete(e):!1):!1}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,n){typeof e!="string"?this._setAttribute("style",e,!1):this._setAttribute("style",[e,n],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,n,s){for(const[i,o,a]of e){let l=!1,h=!1;for(const[u,m]of this._attrs)if(!(s&&s.includes(u)||!ft(i,u)))if(l=!0,typeof m=="string"){if(ft(o,m))n.push([u]),h=!0;else if(!(i instanceof RegExp))return!1}else{const p=m._getTokensMatch(o,a||!0);if(p){h=!0;for(const w of p)n.push([u,w])}else if(!(i instanceof RegExp))return!1}if(!l||!h)return!1}return!0}_getConsumables(e,n){const s=[];if(e){const i=this._attrs.get(e);if(i!==void 0)if(typeof i=="string")s.push([e]);else for(const o of i._getConsumables(n))s.push([e,o])}else for(const[i,o]of this._attrs)if(typeof o=="string")s.push([i]);else for(const a of o._getConsumables())s.push([i,a]);return{name:!e,attributes:s}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[n,s]of e._attrs){const i=this._attrs.get(n);if(i!==void 0){if(typeof i=="string"||typeof s=="string"){if(i!==s)return!1}else if(!i._canMergeFrom(s))return!1}}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[n,s]of e._attrs){const i=this._attrs.get(n);i===void 0||typeof i=="string"||typeof s=="string"?this._setAttribute(n,s):i._mergeFrom(s)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[n,s]of e._attrs){const i=this._attrs.get(n);if(i===void 0)return!1;if(typeof i=="string"||typeof s=="string"){if(i!==s)return!1}else if(!i._isMatching(s))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[n,s]of e._attrs){const i=this._attrs.get(n);typeof i=="string"||typeof s=="string"?this._attrs.delete(n):(i.remove(s.keys()),i.isEmpty&&this._attrs.delete(n))}}_setCustomProperty(e,n){this._customProperties.set(e,n)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const n=we(e);for(const[s,i]of n)if(i===null)n.delete(s);else if(ke(this.name,s)){const o=i instanceof qe?i._clone():new qe(this.document.stylesProcessor).setTo(String(i));n.set(s,o)}else if(Ie(this.name,s)){const o=i instanceof vt?i._clone():new vt().setTo(String(i));n.set(s,o)}else typeof i!="string"&&n.set(s,String(i));return n}};ne.prototype.is=function(r,t){return t?t===this.name&&(r==="element"||r==="view:element"):r==="element"||r==="view:element"||r==="node"||r==="view:node"};function hr(r,t){if(typeof t=="string")return[new N(r,t)];ce(t)||(t=[t]);const e=[];for(const n of t)typeof n=="string"?e.push(new N(r,n)):n instanceof Z?e.push(new N(r,n.data)):e.push(n);return e}function Ie(r,t){return t=="class"||r=="a"&&t=="rel"}function ke(r,t){return t=="style"}class Ke extends ne{constructor(t,e,n,s){super(t,e,n,s),this.getFillerOffset=ur}}Ke.prototype.is=function(r,t){return t?t===this.name&&(r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function ur(){const r=[...this.getChildren()],t=r[this.childCount-1];if(t&&t.is("element","br"))return this.childCount;for(const e of r)if(!e.is("uiElement"))return null;return this.childCount}class mt extends J(Ke){constructor(t,e,n,s){super(t,e,n,s),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(t),this.bind("isFocused").to(t,"isFocused",i=>i&&t.selection.editableElement==this),this.listenTo(t.selection,"change",()=>{this.isFocused=t.isFocused&&t.selection.editableElement==this})}destroy(){this.stopListening()}}mt.prototype.is=function(r,t){return t?t===this.name&&(r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};const ln=Symbol("rootName");class Kn extends mt{constructor(t,e){super(t,e),this.rootName="main"}get rootName(){return this.getCustomProperty(ln)}set rootName(t){this._setCustomProperty(ln,t)}set _name(t){this.name=t}}Kn.prototype.is=function(r,t){return t?t===this.name&&(r==="rootElement"||r==="view:rootElement"||r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"):r==="rootElement"||r==="view:rootElement"||r==="editableElement"||r==="view:editableElement"||r==="containerElement"||r==="view:containerElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};let ge=class{constructor(t={}){c(this,"direction");c(this,"boundaries");c(this,"singleCharacters");c(this,"shallow");c(this,"ignoreElementEnd");c(this,"_position");c(this,"_boundaryStartParent");c(this,"_boundaryEndParent");if(!t.boundaries&&!t.startPosition)throw new d("view-tree-walker-no-start-position",null);if(t.direction&&t.direction!="forward"&&t.direction!="backward")throw new d("view-tree-walker-unknown-direction",t.startPosition,{direction:t.direction});this.boundaries=t.boundaries||null,t.startPosition?this._position=_._createAt(t.startPosition):this._position=_._createAt(t.boundaries[t.direction=="backward"?"end":"start"]),this.direction=t.direction||"forward",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(t){let e,n;do n=this.position,e=this.next();while(!e.done&&t(e.value));e.done||(this._position=n)}jumpTo(t){this._boundaryStartParent&&t.isBefore(this.boundaries.start)?t=this.boundaries.start:this._boundaryEndParent&&t.isAfter(this.boundaries.end)&&(t=this.boundaries.end),this._position=t.clone()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let t=this.position.clone();const e=this.position,n=t.parent;if(n.parent===null&&t.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let s;if(n&&n.is("view:$text")){if(t.isAtEnd)return this._position=_._createAfter(n),this._next();s=n.data[t.offset]}else s=n.getChild(t.offset);if(typeof s=="string"){let i;this.singleCharacters?i=1:i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-t.offset;const o=new Z(n,t.offset,i);return t.offset+=i,this._position=t,this._formatReturnValue("text",o,e,t,i)}if(s&&s.is("view:element")){if(!this.shallow)t=new _(s,0);else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,this._formatReturnValue("elementStart",s,e,t,1)}if(s&&s.is("view:$text")){if(this.singleCharacters)return t=new _(s,0),this._position=t,this._next();let i=s.data.length,o;return s==this._boundaryEndParent?(i=this.boundaries.end.offset,o=new Z(s,0,i),t=_._createAfter(o)):(o=new Z(s,0,s.data.length),t.offset++),this._position=t,this._formatReturnValue("text",o,e,t,i)}return t=_._createAfter(n),this._position=t,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,e,t)}_previous(){let t=this.position.clone();const e=this.position,n=t.parent;if(n.parent===null&&t.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let s;if(n.is("view:$text")){if(t.isAtStart)return this._position=_._createBefore(n),this._previous();s=n.data[t.offset-1]}else s=n.getChild(t.offset-1);if(typeof s=="string"){let i;if(this.singleCharacters)i=1;else{const a=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=t.offset-a}t.offset-=i;const o=new Z(n,t.offset,i);return this._position=t,this._formatReturnValue("text",o,e,t,i)}if(s&&s.is("view:element"))return this.shallow?(t.offset--,this._position=t,this._formatReturnValue("elementStart",s,e,t,1)):(t=new _(s,s.childCount),this._position=t,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",s,e,t));if(s&&s.is("view:$text")){if(this.singleCharacters)return t=new _(s,s.data.length),this._position=t,this._previous();let i=s.data.length,o;if(s==this._boundaryStartParent){const a=this.boundaries.start.offset;o=new Z(s,a,s.data.length-a),i=o.data.length,t=_._createBefore(o)}else o=new Z(s,0,s.data.length),t.offset--;return this._position=t,this._formatReturnValue("text",o,e,t,i)}return t=_._createBefore(n),this._position=t,this._formatReturnValue("elementStart",n,e,t,1)}_formatReturnValue(t,e,n,s,i){return e.is("view:$textProxy")&&(e.offsetInText+e.data.length==e.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(s=_._createAfter(e.textNode),this._position=s):n=_._createAfter(e.textNode)),e.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(s=_._createBefore(e.textNode),this._position=s):n=_._createBefore(e.textNode))),{done:!1,value:{type:t,item:e,previousPosition:n,nextPosition:s,length:i}}}},_=class Q extends ye{constructor(e,n){super();c(this,"parent");c(this,"offset");this.parent=e,this.offset=n}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return this.offset===0}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof mt);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const n=Q._createAt(this),s=n.offset+e;return n.offset=s<0?0:s,n}getLastMatchingPosition(e,n={}){n.startPosition=this;const s=new ge(n);return s.skip(e),s.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const n=this.getAncestors(),s=e.getAncestors();let i=0;for(;n[i]==s[i]&&n[i];)i++;return i===0?null:n[i-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)=="before"}isAfter(e){return this.compareWith(e)=="after"}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const n=this.parent.is("node")?this.parent.getPath():[],s=e.parent.is("node")?e.parent.getPath():[];n.push(this.offset),s.push(e.offset);const i=B(n,s);switch(i){case"prefix":return"before";case"extension":return"after";default:return n[i]<s[i]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new ge(e)}clone(){return new Q(this.parent,this.offset)}static _createAt(e,n){if(e instanceof Q)return new this(e.parent,e.offset);{const s=e;if(n=="end")n=s.is("$text")?s.data.length:s.childCount;else{if(n=="before")return this._createBefore(s);if(n=="after")return this._createAfter(s);if(n!==0&&!n)throw new d("view-createpositionat-offset-required",s)}return new Q(s,n)}}static _createAfter(e){if(e.is("$textProxy"))return new Q(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new d("view-position-after-root",e,{root:e});return new Q(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new Q(e.textNode,e.offsetInText);if(!e.parent)throw new d("view-position-before-root",e,{root:e});return new Q(e.parent,e.index)}};_.prototype.is=function(r){return r==="position"||r==="view:position"};let b=class re extends ye{constructor(e,n=null){super();c(this,"start");c(this,"end");this.start=e.clone(),this.end=n?n.clone():e.clone()}*[Symbol.iterator](){yield*new ge({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(nt,{direction:"backward"}),n=this.end.getLastMatchingPosition(nt);return e.parent.is("$text")&&e.isAtStart&&(e=_._createBefore(e.parent)),n.parent.is("$text")&&n.isAtEnd&&(n=_._createAfter(n.parent)),new re(e,n)}getTrimmed(){let e=this.start.getLastMatchingPosition(nt);if(e.isAfter(this.end)||e.isEqual(this.end))return new re(e,e);let n=this.end.getLastMatchingPosition(nt,{direction:"backward"});const s=e.nodeAfter,i=n.nodeBefore;return s&&s.is("$text")&&(e=new _(s,0)),i&&i.is("$text")&&(n=new _(i,i.data.length)),new re(e,n)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,n=!1){e.isCollapsed&&(n=!1);const s=this.containsPosition(e.start)||n&&this.start.isEqual(e.start),i=this.containsPosition(e.end)||n&&this.end.isEqual(e.end);return s&&i}getDifference(e){const n=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&n.push(new re(this.start,e.start)),this.containsPosition(e.end)&&n.push(new re(e.end,this.end))):n.push(this.clone()),n}getIntersection(e){if(this.isIntersecting(e)){let n=this.start,s=this.end;return this.containsPosition(e.start)&&(n=e.start),this.containsPosition(e.end)&&(s=e.end),new re(n,s)}return null}getWalker(e={}){return e.boundaries=this,new ge(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,n=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(n=this.end.parent.previousSibling),e&&e.is("element")&&e===n?e:null}clone(){return new re(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const n=new ge(e);for(const s of n)yield s.item}*getPositions(e={}){e.boundaries=this;const n=new ge(e);yield n.position;for(const s of n)yield s.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,n,s,i){return new this(new _(e,n),new _(s,i))}static _createFromPositionAndShift(e,n){const s=e,i=e.getShiftedBy(n);return n>0?new this(s,i):new this(i,s)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const n=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(_._createBefore(e),n)}};b.prototype.is=function(r){return r==="range"||r==="view:range"};function nt(r){return!!(r.item.is("attributeElement")||r.item.is("uiElement"))}let ee=class Xn extends O(ye){constructor(...e){super();c(this,"_ranges");c(this,"_lastRangeBackward");c(this,"_isFake");c(this,"_fakeSelectionLabel");this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const n of this._ranges)(!e||n.start.isBefore(e.start))&&(e=n);return e?e.clone():null}getLastRange(){let e=null;for(const n of this._ranges)(!e||n.end.isAfter(e.end))&&(e=n);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const n of this._ranges){let s=!1;for(const i of e._ranges)if(n.isEqual(i)){s=!0;break}if(!s)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const n=tn(this.getRanges()),s=tn(e.getRanges());if(n!=s)return!1;if(n==0)return!0;for(let i of this.getRanges()){i=i.getTrimmed();let o=!1;for(let a of e.getRanges())if(a=a.getTrimmed(),i.start.isEqual(a.start)&&i.end.isEqual(a.end)){o=!0;break}if(!o)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[n,s,i]=e;if(typeof s=="object"&&(i=s,s=void 0),n===null)this._setRanges([]),this._setFakeOptions(i);else if(n instanceof Xn||n instanceof Jt)this._setRanges(n.getRanges(),n.isBackward),this._setFakeOptions({fake:n.isFake,label:n.fakeSelectionLabel});else if(n instanceof b)this._setRanges([n],i&&i.backward),this._setFakeOptions(i);else if(n instanceof _)this._setRanges([new b(n)]),this._setFakeOptions(i);else if(n instanceof ve){const o=!!i&&!!i.backward;let a;if(s===void 0)throw new d("view-selection-setto-required-second-parameter",this);s=="in"?a=b._createIn(n):s=="on"?a=b._createOn(n):a=new b(_._createAt(n,s)),this._setRanges([a],o),this._setFakeOptions(i)}else if(ce(n))this._setRanges(n,i&&i.backward),this._setFakeOptions(i);else throw new d("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,n){if(this.anchor===null)throw new d("view-selection-setfocus-no-ranges",this);const s=_._createAt(e,n);if(s.compareWith(this.focus)=="same")return;const i=this.anchor;this._ranges.pop(),s.compareWith(i)=="before"?this._addRange(new b(s,i),!0):this._addRange(new b(i,s)),this.fire("change")}_setRanges(e,n=!1){e=Array.from(e),this._ranges=[];for(const s of e)this._addRange(s);this._lastRangeBackward=!!n}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,n=!1){if(!(e instanceof b))throw new d("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!n}_pushRange(e){for(const n of this._ranges)if(e.isIntersecting(n))throw new d("view-selection-range-intersects",this,{addedRange:e,intersectingRange:n});this._ranges.push(new b(e.start,e.end))}};ee.prototype.is=function(r){return r==="selection"||r==="view:selection"};let Jt=class extends O(ye){constructor(...e){super();c(this,"_selection");this._selection=new ee,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,n){this._selection.setFocus(e,n)}};Jt.prototype.is=function(r){return r==="selection"||r=="documentSelection"||r=="view:selection"||r=="view:documentSelection"};class jt extends Tt{constructor(e,n,s){super(e,n);c(this,"startRange");c(this,"_eventPhase");c(this,"_currentTarget");this.startRange=s,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const Pt=Symbol("bubbling contexts");function It(r){class t extends r{fire(n,...s){try{const i=n instanceof Tt?n:new Tt(this,n),o=Ct(this);if(!o.size)return;if(Fe(i,"capturing",this),Ae(o,"$capture",i,...s))return i.return;const a=i.startRange||this.selection.getFirstRange(),l=a?a.getContainedElement():null,h=l?!!Yn(o,l):!1;let u=l||fr(a);if(Fe(i,"atTarget",u),!h){if(Ae(o,"$text",i,...s))return i.return;Fe(i,"bubbling",u)}for(;u;){if(u.is("rootElement")){if(Ae(o,"$root",i,...s))return i.return}else if(u.is("element")&&Ae(o,u.name,i,...s))return i.return;if(Ae(o,u,i,...s))return i.return;u=u.parent,Fe(i,"bubbling",u)}return Fe(i,"bubbling",this),Ae(o,"$document",i,...s),i.return}catch(i){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(i,this)}}_addEventListener(n,s,i){const o=le(i.context||"$document"),a=Ct(this);for(const l of o){let h=a.get(l);h||(h=new(O()),a.set(l,h)),this.listenTo(h,n,s,i)}}_removeEventListener(n,s){const i=Ct(this);for(const o of i.values())this.stopListening(o,n,s)}}return t}{const r=It(Object);["fire","_addEventListener","_removeEventListener"].forEach(t=>{It[t]=r.prototype[t]})}function Fe(r,t,e){r instanceof jt&&(r._eventPhase=t,r._currentTarget=e)}function Ae(r,t,e,...n){const s=typeof t=="string"?r.get(t):Yn(r,t);return s?(s.fire(e,...n),e.stop.called):!1}function Yn(r,t){for(const[e,n]of r)if(typeof e=="function"&&e(t))return n;return null}function Ct(r){return r[Pt]||(r[Pt]=new Map),r[Pt]}function fr(r){if(!r)return null;const t=r.start.parent,e=r.end.parent,n=t.getPath(),s=e.getPath();return n.length>s.length?t:e}let Qn=class extends It(J()){constructor(e){super();c(this,"selection");c(this,"roots");c(this,"stylesProcessor");c(this,"_postFixers",new Set);this.selection=new Jt,this.roots=new qt({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let n=!1;do for(const s of this._postFixers)if(n=s(e),n)break;while(n)}};const cn=10;class pe extends ne{constructor(e,n,s,i){super(e,n,s,i);c(this,"_priority",cn);c(this,"_id",null);c(this,"_clonesGroup",null);this.getFillerOffset=dr}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new d("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e=!1){const n=super._clone(e);return n._priority=this._priority,n._id=this._id,n}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}c(pe,"DEFAULT_PRIORITY",cn);pe.prototype.is=function(r,t){return t?t===this.name&&(r==="attributeElement"||r==="view:attributeElement"||r==="element"||r==="view:element"):r==="attributeElement"||r==="view:attributeElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function dr(){if(kt(this))return null;let r=this.parent;for(;r&&r.is("attributeElement");){if(kt(r)>1)return null;r=r.parent}return!r||kt(r)>1?null:this.childCount}function kt(r){return Array.from(r.getChildren()).filter(t=>!t.is("uiElement")).length}class Gt extends ne{constructor(t,e,n,s){super(t,e,n,s),this.getFillerOffset=mr}_insertChild(t,e){if(e&&(e instanceof ve||Array.from(e).length>0))throw new d("view-emptyelement-cannot-add",[this,e]);return 0}}Gt.prototype.is=function(r,t){return t?t===this.name&&(r==="emptyElement"||r==="view:emptyElement"||r==="element"||r==="view:element"):r==="emptyElement"||r==="view:emptyElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function mr(){return null}class gt extends ne{constructor(t,e,n,s){super(t,e,n,s),this.getFillerOffset=pr}_insertChild(t,e){if(e&&(e instanceof ve||Array.from(e).length>0))throw new d("view-uielement-cannot-add",[this,e]);return 0}render(t,e){return this.toDomElement(t)}toDomElement(t){const e=t.createElement(this.name);for(const n of this.getAttributeKeys())e.setAttribute(n,this.getAttribute(n));return e}}gt.prototype.is=function(r,t){return t?t===this.name&&(r==="uiElement"||r==="view:uiElement"||r==="element"||r==="view:element"):r==="uiElement"||r==="view:uiElement"||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function gr(r){r.document.on("arrowKey",(t,e)=>_r(t,e,r.domConverter),{priority:"low"})}function pr(){return null}function _r(r,t,e){if(t.keyCode==me.arrowright){const n=t.domTarget.ownerDocument.defaultView.getSelection(),s=n.rangeCount==1&&n.getRangeAt(0).collapsed;if(s||t.shiftKey){const i=n.focusNode,o=n.focusOffset,a=e.domPositionToView(i,o);if(a===null)return;let l=!1;const h=a.getLastMatchingPosition(u=>(u.item.is("uiElement")&&(l=!0),!!(u.item.is("uiElement")||u.item.is("attributeElement"))));if(l){const u=e.viewPositionToDom(h);s?n.collapse(u.parent,u.offset):n.extend(u.parent,u.offset)}}}}class Ht extends ne{constructor(t,e,n,s){super(t,e,n,s),this.getFillerOffset=wr}_insertChild(t,e){if(e&&(e instanceof ve||Array.from(e).length>0))throw new d("view-rawelement-cannot-add",[this,e]);return 0}render(t,e){}}Ht.prototype.is=function(r,t){return t?t===this.name&&(r==="rawElement"||r==="view:rawElement"||r==="element"||r==="view:element"):r==="rawElement"||r==="view:rawElement"||r===this.name||r==="view:"+this.name||r==="element"||r==="view:element"||r==="node"||r==="view:node"};function wr(){return null}let _e=class extends O(ye){constructor(e,n){super();c(this,"document");c(this,"_children",[]);c(this,"_customProperties",new Map);this.document=e,n&&this._insertChild(0,n)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,n){this._fireChange("children",this,{index:e});let s=0;const i=br(this.document,n);for(const o of i)o.parent!==null&&o._remove(),o.parent=this,this._children.splice(e,0,o),e++,s++;return s}_removeChildren(e,n=1){this._fireChange("children",this,{index:e});for(let s=e;s<e+n;s++)this._children[s].parent=null;return this._children.splice(e,n)}_fireChange(e,n,s){this.fire(`change:${e}`,n,s)}_setCustomProperty(e,n){this._customProperties.set(e,n)}_removeCustomProperty(e){return this._customProperties.delete(e)}};_e.prototype.is=function(r){return r==="documentFragment"||r==="view:documentFragment"};function br(r,t){return typeof t=="string"?[new N(r,t)]:(ce(t)||(t=[t]),Array.from(t).map(e=>typeof e=="string"?new N(r,e):e instanceof Z?new N(r,e.data):e))}class Zn{constructor(t){c(this,"document");c(this,"_cloneGroups",new Map);c(this,"_slotFactory",null);this.document=t}setSelection(...t){this.document.selection._setTo(...t)}setSelectionFocus(t,e){this.document.selection._setFocus(t,e)}createDocumentFragment(t){return new _e(this.document,t)}createText(t){return new N(this.document,t)}createAttributeElement(t,e,n={}){const s=new pe(this.document,t,e);return typeof n.priority=="number"&&(s._priority=n.priority),n.id&&(s._id=n.id),n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createContainerElement(t,e,n={},s={}){let i=null;Mt(n)?s=n:i=n;const o=new Ke(this.document,t,e,i);return s.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...s.renderUnsafeAttributes),o}createEditableElement(t,e,n={}){const s=new mt(this.document,t,e);return n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createEmptyElement(t,e,n={}){const s=new Gt(this.document,t,e);return n.renderUnsafeAttributes&&s._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),s}createUIElement(t,e,n){const s=new gt(this.document,t,e);return n&&(s.render=n),s}createRawElement(t,e,n,s={}){const i=new Ht(this.document,t,e);return n&&(i.render=n),s.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...s.renderUnsafeAttributes),i}setAttribute(t,e,n,s){s!==void 0?s._setAttribute(t,e,n):n._setAttribute(t,e)}removeAttribute(t,e,n){n!==void 0?n._removeAttribute(t,e):e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,n){Mt(t)&&n===void 0?e._setStyle(t):n._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,n){n._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}breakAttributes(t){return t instanceof _?this._breakAttributes(t):this._breakAttributesRange(t)}breakContainer(t){const e=t.parent;if(!e.is("containerElement"))throw new d("view-writer-break-non-container-element",this.document);if(!e.parent)throw new d("view-writer-break-root",this.document);if(t.isAtStart)return _._createBefore(e);if(!t.isAtEnd){const n=e._clone(!1);this.insert(_._createAfter(e),n);const s=new b(t,_._createAt(e,"end")),i=new _(n,0);this.move(s,i)}return _._createAfter(e)}mergeAttributes(t){const e=t.offset,n=t.parent;if(n.is("$text"))return t;if(n.is("attributeElement")&&n.childCount===0){const o=n.parent,a=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new _(o,a))}const s=n.getChild(e-1),i=n.getChild(e);if(!s||!i)return t;if(s.is("$text")&&i.is("$text"))return un(s,i);if(s.is("attributeElement")&&i.is("attributeElement")&&s.isSimilar(i)){const o=s.childCount;return s._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new _(s,o))}return t}mergeContainers(t){const e=t.nodeBefore,n=t.nodeAfter;if(!e||!n||!e.is("containerElement")||!n.is("containerElement"))throw new d("view-writer-merge-containers-invalid-position",this.document);const s=e.getChild(e.childCount-1),i=s instanceof N?_._createAt(s,"end"):_._createAt(e,"end");return this.move(b._createIn(n),_._createAt(e,"end")),this.remove(b._createOn(n)),i}insert(t,e){e=ce(e)?[...e]:[e],es(e,this.document);const n=e.reduce((o,a)=>{const l=o[o.length-1],h=!a.is("uiElement");return!l||l.breakAttributes!=h?o.push({breakAttributes:h,nodes:[a]}):l.nodes.push(a),o},[]);let s=null,i=t;for(const{nodes:o,breakAttributes:a}of n){const l=this._insertNodes(i,o,a);s||(s=l.start),i=l.end}return s?new b(s,i):new b(t)}remove(t){const e=t instanceof b?t:b._createOn(t);if(Be(e,this.document),e.isCollapsed)return new _e(this.document);const{start:n,end:s}=this._breakAttributesRange(e,!0),i=n.parent,o=s.offset-n.offset,a=i._removeChildren(n.offset,o);for(const h of a)this._removeFromClonedElementsGroup(h);const l=this.mergeAttributes(n);return e.start=l,e.end=l.clone(),new _e(this.document,a)}clear(t,e){Be(t,this.document);const n=t.getWalker({direction:"backward",ignoreElementEnd:!0});for(const s of n){const i=s.item;let o;if(i.is("element")&&e.isSimilar(i))o=b._createOn(i);else if(!s.nextPosition.isAfter(t.start)&&i.is("$textProxy")){const a=i.getAncestors().find(l=>l.is("element")&&e.isSimilar(l));a&&(o=b._createIn(a))}o&&(o.end.isAfter(t.end)&&(o.end=t.end),o.start.isBefore(t.start)&&(o.start=t.start),this.remove(o))}}move(t,e){let n;if(e.isAfter(t.end)){e=this._breakAttributes(e,!0);const s=e.parent,i=s.childCount;t=this._breakAttributesRange(t,!0),n=this.remove(t),e.offset+=s.childCount-i}else n=this.remove(t);return this.insert(e,n)}wrap(t,e){if(!(e instanceof pe))throw new d("view-writer-wrap-invalid-attribute",this.document);if(Be(t,this.document),t.isCollapsed){let n=t.start;n.parent.is("element")&&!yr(n.parent)&&(n=n.getLastMatchingPosition(i=>i.item.is("uiElement"))),n=this._wrapPosition(n,e);const s=this.document.selection;return s.isCollapsed&&s.getFirstPosition().isEqual(t.start)&&this.setSelection(n),new b(n)}else return this._wrapRange(t,e)}unwrap(t,e){if(!(e instanceof pe))throw new d("view-writer-unwrap-invalid-attribute",this.document);if(Be(t,this.document),t.isCollapsed)return t;const{start:n,end:s}=this._breakAttributesRange(t,!0),i=n.parent,o=this._unwrapChildren(i,n.offset,s.offset,e),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new b(a,l)}rename(t,e){const n=new Ke(this.document,t,e.getAttributes());return this.insert(_._createAfter(e),n),this.move(b._createIn(e),_._createAt(n,0)),this.remove(b._createOn(e)),n}clearClonedElementsGroup(t){this._cloneGroups.delete(t)}createPositionAt(t,e){return _._createAt(t,e)}createPositionAfter(t){return _._createAfter(t)}createPositionBefore(t){return _._createBefore(t)}createRange(t,e){return new b(t,e)}createRangeOn(t){return b._createOn(t)}createRangeIn(t){return b._createIn(t)}createSelection(...t){return new ee(...t)}createSlot(t="children"){if(!this._slotFactory)throw new d("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,t)}_registerSlotFactory(t){this._slotFactory=t}_clearSlotFactory(){this._slotFactory=null}_insertNodes(t,e,n){let s;if(n?s=Ft(t):s=t.parent.is("$text")?t.parent.parent:t.parent,!s)throw new d("view-writer-invalid-position-container",this.document);let i;n?i=this._breakAttributes(t,!0):i=t.parent.is("$text")?At(t):t;const o=s._insertChild(i.offset,e);for(const u of e)this._addToClonedElementsGroup(u);const a=i.getShiftedBy(o),l=this.mergeAttributes(i);l.isEqual(i)||a.offset--;const h=this.mergeAttributes(a);return new b(l,h)}_wrapChildren(t,e,n,s){let i=e;const o=[];for(;i<n;){const l=t.getChild(i),h=l.is("$text"),u=l.is("attributeElement");if(u&&l._canMergeAttributesFrom(s))l._mergeAttributesFrom(s),o.push(new _(t,i));else if(h||!u||vr(s,l)){const m=s._clone();l._remove(),m._appendChild(l),t._insertChild(i,m),this._addToClonedElementsGroup(m),o.push(new _(t,i))}else this._wrapChildren(l,0,l.childCount,s);i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==e)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return b._createFromParentsAndOffsets(t,e,t,n)}_unwrapChildren(t,e,n,s){let i=e;const o=[];for(;i<n;){const l=t.getChild(i);if(!l.is("attributeElement")){i++;continue}if(l.isSimilar(s)){const h=l.getChildren(),u=l.childCount;l._remove(),t._insertChild(i,h),this._removeFromClonedElementsGroup(l),o.push(new _(t,i),new _(t,i+u)),i+=u,n+=u-1;continue}if(l._canSubtractAttributesOf(s)){l._subtractAttributesOf(s),o.push(new _(t,i),new _(t,i+1)),i++;continue}this._unwrapChildren(l,0,l.childCount,s),i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==e||l.offset==n)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return b._createFromParentsAndOffsets(t,e,t,n)}_wrapRange(t,e){const{start:n,end:s}=this._breakAttributesRange(t,!0),i=n.parent,o=this._wrapChildren(i,n.offset,s.offset,e),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new b(a,l)}_wrapPosition(t,e){if(e.isSimilar(t.parent))return hn(t.clone());t.parent.is("$text")&&(t=At(t));const n=this.createAttributeElement("_wrapPosition-fake-element");n._priority=Number.POSITIVE_INFINITY,n.isSimilar=()=>!1,t.parent._insertChild(t.offset,n);const s=new b(t,t.getShiftedBy(1));this.wrap(s,e);const i=new _(n.parent,n.index);n._remove();const o=i.nodeBefore,a=i.nodeAfter;return o&&o.is("view:$text")&&a&&a.is("view:$text")?un(o,a):hn(i)}_breakAttributesRange(t,e=!1){const n=t.start,s=t.end;if(Be(t,this.document),t.isCollapsed){const l=this._breakAttributes(t.start,e);return new b(l,l)}const i=this._breakAttributes(s,e),o=i.parent.childCount,a=this._breakAttributes(n,e);return i.offset+=i.parent.childCount-o,new b(a,i)}_breakAttributes(t,e=!1){const n=t.offset,s=t.parent;if(t.parent.is("emptyElement"))throw new d("view-writer-cannot-break-empty-element",this.document);if(t.parent.is("uiElement"))throw new d("view-writer-cannot-break-ui-element",this.document);if(t.parent.is("rawElement"))throw new d("view-writer-cannot-break-raw-element",this.document);if(!e&&s.is("$text")&&Bt(s.parent)||Bt(s))return t.clone();if(s.is("$text"))return this._breakAttributes(At(t),e);const i=s.childCount;if(n==i){const o=new _(s.parent,s.index+1);return this._breakAttributes(o,e)}else if(n===0){const o=new _(s.parent,s.index);return this._breakAttributes(o,e)}else{const o=s.index+1,a=s._clone();s.parent._insertChild(o,a),this._addToClonedElementsGroup(a);const l=s.childCount-n,h=s._removeChildren(n,l);a._appendChild(h);const u=new _(s.parent,o);return this._breakAttributes(u,e)}}_addToClonedElementsGroup(t){if(!t.root.is("rootElement"))return;if(t.is("element"))for(const s of t.getChildren())this._addToClonedElementsGroup(s);const e=t.id;if(!e)return;let n=this._cloneGroups.get(e);n||(n=new Set,this._cloneGroups.set(e,n)),n.add(t),t._clonesGroup=n}_removeFromClonedElementsGroup(t){if(t.is("element"))for(const s of t.getChildren())this._removeFromClonedElementsGroup(s);const e=t.id;if(!e)return;const n=this._cloneGroups.get(e);n&&n.delete(t)}}function yr(r){return Array.from(r.getChildren()).some(t=>!t.is("uiElement"))}function Ft(r){let t=r.parent;for(;!Bt(t);){if(!t)return;t=t.parent}return t}function vr(r,t){return r.priority<t.priority?!0:r.priority>t.priority?!1:r.getIdentity()<t.getIdentity()}function hn(r){const t=r.nodeBefore;if(t&&t.is("$text"))return new _(t,t.data.length);const e=r.nodeAfter;return e&&e.is("$text")?new _(e,0):r}function At(r){if(r.offset==r.parent.data.length)return new _(r.parent.parent,r.parent.index+1);if(r.offset===0)return new _(r.parent.parent,r.parent.index);const t=r.parent.data.slice(r.offset);return r.parent._data=r.parent.data.slice(0,r.offset),r.parent.parent._insertChild(r.parent.index+1,new N(r.root.document,t)),new _(r.parent.parent,r.parent.index+1)}function un(r,t){const e=r.data.length;return r._data+=t.data,t._remove(),new _(r,e)}const Pr=[N,pe,Ke,Gt,Ht,gt];function es(r,t){for(const e of r){if(!Pr.some(n=>e instanceof n))throw new d("view-writer-insert-invalid-node-type",t);e.is("$text")||es(e.getChildren(),t)}}function Bt(r){return r&&(r.is("containerElement")||r.is("documentFragment"))}function Be(r,t){const e=Ft(r.start),n=Ft(r.end);if(!e||!n||e!==n)throw new d("view-writer-invalid-range-container",t)}const ts=r=>r.createTextNode(" "),ns=r=>{const t=r.createElement("span");return t.dataset.ckeFiller="true",t.innerText=" ",t},ss=r=>{const t=r.createElement("br");return t.dataset.ckeFiller="true",t},W=7,Xe="⁠".repeat(W);function D(r){return typeof r=="string"?r.substr(0,W)===Xe:R(r)&&r.data.substr(0,W)===Xe}function Me(r){return r.data.length==W&&D(r)}function fn(r){const t=typeof r=="string"?r:r.data;return D(r)?t.slice(W):t}function Cr(r){r.document.on("arrowKey",kr,{priority:"low"})}function kr(r,t){if(t.keyCode==me.arrowleft){const e=t.domTarget.ownerDocument.defaultView.getSelection();if(e.rangeCount==1&&e.getRangeAt(0).collapsed){const n=e.getRangeAt(0).startContainer,s=e.getRangeAt(0).startOffset;D(n)&&s<=W&&e.collapse(n,0)}}}class Ar extends J(){constructor(e,n){super();c(this,"domDocuments",new Set);c(this,"domConverter");c(this,"markedAttributes",new Set);c(this,"markedChildren",new Set);c(this,"markedTexts",new Set);c(this,"selection");c(this,"_inlineFiller",null);c(this,"_fakeSelectionContainer",null);this.domConverter=e,this.selection=n,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),x.isBlink&&!x.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,n){if(e==="text")this.domConverter.mapViewToDom(n.parent)&&this.markedTexts.add(n);else{if(!this.domConverter.mapViewToDom(n))return;if(e==="attributes")this.markedAttributes.add(n);else if(e==="children")this.markedChildren.add(n);else throw new d("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!x.isAndroid)return;let e=null;const n=x.isBlink&&!x.isAndroid?!this.isSelecting:!0;for(const s of this.markedChildren)this._updateChildrenMappings(s);n?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=_._createBefore(e.parent)));for(const s of this.markedAttributes)this._updateAttrs(s);for(const s of this.markedChildren)this._updateChildren(s,{inlineFillerPosition:e});for(const s of this.markedTexts)!this.markedChildren.has(s.parent)&&this.domConverter.mapViewToDom(s.parent)&&this._updateText(s,{inlineFillerPosition:e});if(n)if(e){const s=this.domConverter.viewPositionToDom(e),i=s.parent.ownerDocument;D(s.parent)?this._inlineFiller=s.parent:this._inlineFiller=dn(i,s.parent,s.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const n=this.domConverter.mapViewToDom(e);if(!n)return;const s=Array.from(n.childNodes),i=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),o=this._diffNodeLists(s,i),a=this._findUpdateActions(o,s,i,Er);if(a.indexOf("update")!==-1){const l={equal:0,insert:0,delete:0};for(const h of a)if(h==="update"){const u=l.equal+l.insert,m=l.equal+l.delete,p=e.getChild(u);p&&!p.is("uiElement")&&!p.is("rawElement")&&this._updateElementMappings(p,s[m]),sn(i[u]),l.equal++}else l[h]++}}_updateElementMappings(e,n){this.domConverter.unbindDomElement(n),this.domConverter.bindElements(n,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?_._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),n=this.domConverter.viewPositionToDom(e);return!!(n&&R(n.parent)&&D(n.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!D(e))throw new d("view-renderer-filler-was-lost",this);Me(e)?e.remove():e.data=e.data.substr(W),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),n=e.parent,s=e.offset;if(!this.domConverter.mapViewToDom(n.root)||!n.is("element")||!Sr(n))return!1;const i=e.nodeBefore,o=e.nodeAfter;return!(i instanceof N||o instanceof N||s===n.getFillerOffset()&&(!i||!i.is("element","br"))||x.isAndroid&&(i||o))}_updateText(e,n){const s=this.domConverter.findCorrespondingDomText(e);let o=this.domConverter.viewToDom(e).data;const a=n.inlineFillerPosition;a&&a.parent==e.parent&&a.offset==e.index&&(o=Xe+o),this._updateTextNode(s,o)}_updateAttrs(e){const n=this.domConverter.mapViewToDom(e);if(n){for(const s of Array.from(n.attributes)){const i=s.name;e.hasAttribute(i)||this.domConverter.removeDomElementAttribute(n,i)}for(const s of e.getAttributeKeys())this.domConverter.setDomElementAttribute(n,s,e.getAttribute(s),e)}}_updateChildren(e,n){const s=this.domConverter.mapViewToDom(e);if(!s)return;if(x.isAndroid){let p=null;for(const w of Array.from(s.childNodes)){if(p&&R(p)&&R(w)){s.normalize();break}p=w}}const i=n.inlineFillerPosition,o=s.childNodes,a=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));i&&i.parent===e&&dn(s.ownerDocument,a,i.offset);const l=this._diffNodeLists(o,a),h=this._findUpdateActions(l,o,a,Rr);let u=0;const m=new Set;for(const p of h)p==="delete"?(m.add(o[u]),sn(o[u])):(p==="equal"||p==="update")&&u++;u=0;for(const p of h)p==="insert"?(Jn(s,u,a[u]),u++):p==="update"?(this._updateTextNode(o[u],a[u].data),u++):p==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(a[u])),u++);for(const p of m)p.parentNode||this.domConverter.unbindDomElement(p)}_diffNodeLists(e,n){return e=xr(e,this._fakeSelectionContainer),pt(e,n,Tr.bind(null,this.domConverter))}_findUpdateActions(e,n,s,i){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let o=[],a=[],l=[];const h={equal:0,insert:0,delete:0};for(const u of e)u==="insert"?l.push(s[h.equal+h.insert]):u==="delete"?a.push(n[h.equal+h.delete]):(o=o.concat(pt(a,l,i).map(m=>m==="equal"?"update":m)),o.push("equal"),a=[],l=[]),h[u]++;return o.concat(pt(a,l,i).map(u=>u==="equal"?"update":u))}_updateTextNode(e,n){const s=e.data;s!=n&&(x.isAndroid&&this.isComposing&&s.replace(/\u00A0/g," ")==n.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,n))}_updateTextNodeInternal(e,n){const s=Us(e.data,n);for(const i of s)i.type==="insert"?e.insertData(i.index,i.values.join("")):e.deleteData(i.index,i.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const n of e.getChildren())this._markDescendantTextToSync(n)}}_updateSelection(){if(x.isBlink&&!x.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&x.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const n=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=Nr(n));const s=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(s,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!s.parentElement||s.parentElement!=e)&&e.appendChild(s),s.textContent=this.selection.fakeSelectionLabel||" ";const i=n.getSelection(),o=n.createRange();i.removeAllRanges(),o.selectNodeContents(s),i.addRange(o)}_updateDomSelection(e){const n=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(n))return;const s=this.domConverter.viewPositionToDom(this.selection.anchor),i=this.domConverter.viewPositionToDom(this.selection.focus);n.setBaseAndExtent(s.parent,s.offset,i.parent,i.offset),x.isGecko&&Mr(i,n)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const n=e&&this.domConverter.domSelectionToView(e);return!(n&&this.selection.isEqual(n)||!this.selection.isCollapsed&&this.selection.isSimilar(n))}_fakeSelectionNeedsUpdate(e){const n=this._fakeSelectionContainer,s=e.ownerDocument.getSelection();return!n||n.parentElement!==e||s.anchorNode!==n&&!n.contains(s.anchorNode)?!0:n.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const n=e.getSelection();if(n.rangeCount){const s=e.activeElement,i=this.domConverter.mapDomToView(s);s&&i&&n.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Sr(r){if(r.getAttribute("contenteditable")=="false")return!1;const t=r.findAncestor(e=>e.hasAttribute("contenteditable"));return!t||t.getAttribute("contenteditable")=="true"}function dn(r,t,e){const n=t instanceof Array?t:t.childNodes,s=n[e];if(R(s))return s.data=Xe+s.data,s;{const i=r.createTextNode(Xe);return Array.isArray(t)?n.splice(e,0,i):Jn(t,e,i),i}}function Er(r,t){return lt(r)&&lt(t)&&!R(r)&&!R(t)&&!We(r)&&!We(t)&&r.tagName.toLowerCase()===t.tagName.toLowerCase()}function Rr(r,t){return lt(r)&&lt(t)&&R(r)&&R(t)}function Tr(r,t,e){return t===e?!0:R(t)&&R(e)?t.data===e.data:!!(r.isBlockFiller(t)&&r.isBlockFiller(e))}function Mr(r,t){let e=r.parent,n=r.offset;if(R(e)&&Me(e)&&(n=Te(e)+1,e=e.parentNode),e.nodeType!=Node.ELEMENT_NODE||n!=e.childNodes.length-1)return;const s=e.childNodes[n];s&&s.tagName=="BR"&&t.addRange(t.getRangeAt(0))}function xr(r,t){const e=Array.from(r);return e.length==0||!t||e[e.length-1]==t&&e.pop(),e}function Nr(r){const t=r.createElement("div");return t.className="ck-fake-selection-container",Object.assign(t.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),t.textContent=" ",t}const Or=ss(ie.document),Ir=ts(ie.document),Fr=ns(ie.document),st="data-ck-unsafe-attribute-",mn="data-ck-unsafe-element";class rs{constructor(t,{blockFillerMode:e,renderingMode:n="editing"}={}){c(this,"document");c(this,"renderingMode");c(this,"blockFillerMode");c(this,"preElements");c(this,"blockElements");c(this,"inlineObjectElements");c(this,"unsafeElements");c(this,"_domDocument");c(this,"_domToViewMapping",new WeakMap);c(this,"_viewToDomMapping",new WeakMap);c(this,"_fakeSelectionMapping",new WeakMap);c(this,"_rawContentElementMatcher",new He);c(this,"_inlineObjectElementMatcher",new He);c(this,"_elementsWithTemporaryCustomProperties",new Set);this.document=t,this.renderingMode=n,this.blockFillerMode=e||(n==="editing"?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?ie.document:ie.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(t,e){this._fakeSelectionMapping.set(t,new ee(e))}fakeSelectionToView(t){return this._fakeSelectionMapping.get(t)}bindElements(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}unbindDomElement(t){const e=this._domToViewMapping.get(t);if(e){this._domToViewMapping.delete(t),this._viewToDomMapping.delete(e);for(const n of t.children)this.unbindDomElement(n)}}bindDocumentFragments(t,e){this._domToViewMapping.set(t,e),this._viewToDomMapping.set(e,t)}shouldRenderAttribute(t,e,n){return this.renderingMode==="data"?!0:(t=t.toLowerCase(),t.startsWith("on")||t==="srcdoc"&&e.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:n==="img"&&(t==="src"||t==="srcset")||n==="source"&&t==="srcset"?!0:!e.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(t,e){if(this.renderingMode==="data"){t.innerHTML=e;return}const n=new DOMParser().parseFromString(e,"text/html"),s=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)s.appendChild(i[0]);const o=n.createTreeWalker(s,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=o.nextNode();)a.push(l);for(const h of a){for(const m of h.getAttributeNames())this.setDomElementAttribute(h,m,h.getAttribute(m));const u=h.tagName.toLowerCase();this._shouldRenameElement(u)&&(wn(u),h.replaceWith(this._createReplacementDomElement(u,h)))}for(;t.firstChild;)t.firstChild.remove();t.append(s)}viewToDom(t,e={}){if(t.is("$text")){const n=this._processDataFromViewText(t);return this._domDocument.createTextNode(n)}else{const n=t;if(this.mapViewToDom(n))if(n.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(n);else return this.mapViewToDom(n);let s;if(n.is("documentFragment"))s=this._domDocument.createDocumentFragment(),e.bind&&this.bindDocumentFragments(s,n);else{if(n.is("uiElement"))return n.name==="$comment"?s=this._domDocument.createComment(n.getCustomProperty("$rawContent")):s=n.render(this._domDocument,this),e.bind&&this.bindElements(s,n),s;this._shouldRenameElement(n.name)?(wn(n.name),s=this._createReplacementDomElement(n.name)):n.hasAttribute("xmlns")?s=this._domDocument.createElementNS(n.getAttribute("xmlns"),n.name):s=this._domDocument.createElement(n.name),n.is("rawElement")&&n.render(s,this),e.bind&&this.bindElements(s,n);for(const i of n.getAttributeKeys())this.setDomElementAttribute(s,i,n.getAttribute(i),n)}if(e.withChildren!==!1)for(const i of this.viewChildrenToDom(n,e))s instanceof HTMLTemplateElement?s.content.appendChild(i):s.appendChild(i);return s}}setDomElementAttribute(t,e,n,s){const i=this.shouldRenderAttribute(e,n,t.tagName.toLowerCase())||s&&s.shouldRenderUnsafeAttribute(e);if(i||q("domconverter-unsafe-attribute-detected",{domElement:t,key:e,value:n}),!Ws(e)){q("domconverter-invalid-attribute-detected",{domElement:t,key:e,value:n});return}t.hasAttribute(e)&&!i?t.removeAttribute(e):t.hasAttribute(st+e)&&i&&t.removeAttribute(st+e),t.setAttribute(i?e:st+e,n)}removeDomElementAttribute(t,e){e!=mn&&(t.removeAttribute(e),t.removeAttribute(st+e))}*viewChildrenToDom(t,e={}){const n=t.getFillerOffset&&t.getFillerOffset();let s=0;for(const i of t.getChildren()){n===s&&(yield this._getBlockFiller());const o=i.is("element")&&!!i.getCustomProperty("dataPipeline:transparentRendering")&&!zt(i.getAttributes());if(o&&this.renderingMode=="data")if(i.is("rawElement")){const a=this._domDocument.createElement(i.name);i.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(i,e);else o&&q("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:i}),yield this.viewToDom(i,e);s++}n===s&&(yield this._getBlockFiller())}viewRangeToDom(t){const e=this.viewPositionToDom(t.start),n=this.viewPositionToDom(t.end),s=this._domDocument.createRange();return s.setStart(e.parent,e.offset),s.setEnd(n.parent,n.offset),s}viewPositionToDom(t){const e=t.parent;if(e.is("$text")){const n=this.findCorrespondingDomText(e);if(!n)return null;let s=t.offset;return D(n)&&(s+=W),n.data&&s>n.data.length&&(s=n.data.length),{parent:n,offset:s}}else{let n,s,i;if(t.offset===0){if(n=this.mapViewToDom(e),!n)return null;i=n.childNodes[0]}else{const a=t.nodeBefore;if(s=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!s)return null;n=s.parentNode,i=s.nextSibling}if(R(i)&&D(i))return{parent:i,offset:W};const o=s?Te(s)+1:0;return{parent:n,offset:o}}}domToView(t,e={}){const n=[],s=this._domToView(t,e,n),i=s.next().value;return!i||(s.next(),this._processDomInlineNodes(null,n,e),this.blockFillerMode=="br"&&pn(i))||i.is("$text")&&i.data.length==0?null:i}*domChildrenToView(t,e={},n=[]){let s=[];t instanceof HTMLTemplateElement?s=[...t.content.childNodes]:s=[...t.childNodes];for(let i=0;i<s.length;i++){const o=s[i],a=this._domToView(o,e,n),l=a.next().value;l!==null&&(this._isBlockViewElement(l)&&this._processDomInlineNodes(t,n,e),this.blockFillerMode=="br"&&pn(l)||(yield l),a.next())}this._processDomInlineNodes(t,n,e)}domSelectionToView(t){if(Lr(t))return new ee([]);if(t.rangeCount===1){let s=t.getRangeAt(0).startContainer;R(s)&&(s=s.parentNode);const i=this.fakeSelectionToView(s);if(i)return i}const e=this.isDomSelectionBackward(t),n=[];for(let s=0;s<t.rangeCount;s++){const i=t.getRangeAt(s),o=this.domRangeToView(i);o&&n.push(o)}return new ee(n,{backward:e})}domRangeToView(t){const e=this.domPositionToView(t.startContainer,t.startOffset),n=this.domPositionToView(t.endContainer,t.endOffset);return e&&n?new b(e,n):null}domPositionToView(t,e=0){if(this.isBlockFiller(t))return this.domPositionToView(t.parentNode,Te(t));const n=this.mapDomToView(t);if(n&&(n.is("uiElement")||n.is("rawElement")))return _._createBefore(n);if(R(t)){if(Me(t))return this.domPositionToView(t.parentNode,Te(t));const s=this.findCorrespondingViewText(t);let i=e;return s?(D(t)&&(i-=W,i=i<0?0:i),new _(s,i)):null}else{if(e===0){const s=this.mapDomToView(t);if(s)return new _(s,0)}else{const s=t.childNodes[e-1];if(R(s)&&Me(s)||s&&this.isBlockFiller(s))return this.domPositionToView(s.parentNode,Te(s));const i=R(s)?this.findCorrespondingViewText(s):this.mapDomToView(s);if(i&&i.parent)return new _(i.parent,i.index+1)}return null}}mapDomToView(t){return this.getHostViewElement(t)||this._domToViewMapping.get(t)}findCorrespondingViewText(t){if(Me(t))return null;const e=this.getHostViewElement(t);if(e)return e;const n=t.previousSibling;if(n){if(!this.isElement(n))return null;const s=this.mapDomToView(n);if(s){const i=s.nextSibling;return i instanceof N?i:null}}else{const s=this.mapDomToView(t.parentNode);if(s){const i=s.getChild(0);return i instanceof N?i:null}}return null}mapViewToDom(t){return this._viewToDomMapping.get(t)}findCorrespondingDomText(t){const e=t.previousSibling;return e&&this.mapViewToDom(e)?this.mapViewToDom(e).nextSibling:!e&&t.parent&&this.mapViewToDom(t.parent)?this.mapViewToDom(t.parent).childNodes[0]:null}focus(t){const e=this.mapViewToDom(t);if(!e||e.ownerDocument.activeElement===e)return;const{scrollX:n,scrollY:s}=ie.window,i=[];gn(e,o=>{const{scrollLeft:a,scrollTop:l}=o;i.push([a,l])}),e.focus(),gn(e,o=>{const[a,l]=i.shift();o.scrollLeft=a,o.scrollTop=l}),ie.window.scrollTo(n,s)}_clearDomSelection(){const t=this.mapViewToDom(this.document.selection.editableElement);if(!t)return;const e=t.ownerDocument.defaultView.getSelection(),n=this.domSelectionToView(e);n&&n.rangeCount>0&&e.removeAllRanges()}isElement(t){return t&&t.nodeType==Node.ELEMENT_NODE}isDocumentFragment(t){return t&&t.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(t){return this.blockFillerMode=="br"?t.isEqualNode(Or):_n(t,this.blockElements)?!0:t.isEqualNode(Fr)||Dr(t,this.blockElements)}isDomSelectionBackward(t){if(t.isCollapsed)return!1;const e=this._domDocument.createRange();try{e.setStart(t.anchorNode,t.anchorOffset),e.setEnd(t.focusNode,t.focusOffset)}catch{return!1}const n=e.collapsed;return e.detach(),n}getHostViewElement(t){const e=qs(t);for(e.pop();e.length;){const n=e.pop(),s=this._domToViewMapping.get(n);if(s&&(s.is("uiElement")||s.is("rawElement")))return s}return null}isDomSelectionCorrect(t){return this._isDomSelectionPositionCorrect(t.anchorNode,t.anchorOffset)&&this._isDomSelectionPositionCorrect(t.focusNode,t.focusOffset)}registerRawContentMatcher(t){this._rawContentElementMatcher.add(t)}registerInlineObjectMatcher(t){this._inlineObjectElementMatcher.add(t)}_clearTemporaryCustomProperties(){for(const t of this._elementsWithTemporaryCustomProperties)t._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return ts(this._domDocument);case"markedNbsp":return ns(this._domDocument);case"br":return ss(this._domDocument)}}_isDomSelectionPositionCorrect(t,e){if(R(t)&&D(t)&&e<W||this.isElement(t)&&D(t.childNodes[e]))return!1;const n=this.mapDomToView(t);return!(n&&(n.is("uiElement")||n.is("rawElement")))}*_domToView(t,e,n){if(this.blockFillerMode!="br"&&_n(t,this.blockElements))return null;const s=this.getHostViewElement(t);if(s)return s;if(We(t)&&e.skipComments)return null;if(R(t)){if(Me(t))return null;{const i=t.data;if(i==="")return null;const o=new N(this.document,i);return n.push(o),o}}else{let i=this.mapDomToView(t);if(i)return this._isInlineObjectElement(i)&&n.push(i),i;if(this.isDocumentFragment(t))i=new _e(this.document),e.bind&&this.bindDocumentFragments(t,i);else{i=this._createViewElement(t,e),e.bind&&this.bindElements(t,i);const a=t.attributes;if(a)for(let l=a.length,h=0;h<l;h++)i._setAttribute(a[h].name,a[h].value);if(this._isViewElementWithRawContent(i,e))return i._setCustomProperty("$rawContent",t.innerHTML),this._isBlockViewElement(i)||n.push(i),i;if(We(t))return i._setCustomProperty("$rawContent",t.data),i}yield i;const o=[];if(e.withChildren!==!1)for(const a of this.domChildrenToView(t,e,o))i._appendChild(a);if(this._isInlineObjectElement(i))n.push(i),this._processDomInlineNodes(null,o,e);else for(const a of o)n.push(a)}}_processDomInlineNodes(t,e,n){if(!e.length||t&&!this.isDocumentFragment(t)&&!this._isBlockDomElement(t))return;let s=!1;for(let i=0;i<e.length;i++){const o=e[i];if(!o.is("$text")){s=!1;continue}let a,l=!1;if(this._isPreFormatted(o))a=fn(o.data);else{a=o.data.replace(/[ \n\t\r]{1,}/g," "),l=/[^\S\u00A0]/.test(a.charAt(a.length-1));const h=i>0?e[i-1]:null,u=i+1<e.length?e[i+1]:null,m=!h||h.is("element")&&h.name=="br"||s,p=u?!1:!D(o.data);n.withChildren!==!1&&(m&&(a=a.replace(/^ /,"")),p&&(a=a.replace(/ $/,""))),a=fn(a),this.blockFillerMode!="br"&&o.parent&&($r(o.parent,a)?(a="",o.parent.parent&&(o.parent.parent._setCustomProperty("$hasBlockFiller",!0),o.parent._remove())):Vr(o.parent,a,this.blockElements)&&(a="",o.parent._setCustomProperty("$hasBlockFiller",!0))),a=a.replace(/ \u00A0/g," ");const w=u&&u.is("element")&&u.name!="br",y=u&&u.is("$text")&&u.data.charAt(0)==" ";(/[ \u00A0]\u00A0$/.test(a)||!u||w||y)&&(a=a.replace(/\u00A0$/," ")),(m||h&&h.is("element")&&h.name!="br")&&(a=a.replace(/^\u00A0/," "))}a.length==0&&o.parent?(o._remove(),e.splice(i,1),i--):(o._data=a,s=l)}e.length=0}_processDataFromViewText(t){let e=t.data;if(this._isPreFormatted(t))return e;if(e.charAt(0)==" "){const n=this._getTouchingInlineViewNode(t,!1);(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n)||!n)&&(e=" "+e.substr(1))}if(e.charAt(e.length-1)==" "){const n=this._getTouchingInlineViewNode(t,!0),s=n&&n.is("$textProxy")&&n.data.charAt(0)==" ";(e.charAt(e.length-2)==" "||!n||s)&&(e=e.substr(0,e.length-1)+" ")}return e.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(t){if(this._isPreFormatted(t))return!1;const e=this._processDataFromViewText(t);return e.charAt(e.length-1)==" "}_isPreFormatted(t){if(Br(t,this.preElements))return!0;for(const e of t.getAncestors({parentFirst:!0}))if(!(!e.is("element")||!e.hasStyle("white-space")||e.getStyle("white-space")==="inherit"))return["pre","pre-wrap","break-spaces"].includes(e.getStyle("white-space"));return!1}_getTouchingInlineViewNode(t,e){const n=new ge({startPosition:e?_._createAfter(t):_._createBefore(t),direction:e?"forward":"backward"});for(const{item:s}of n){if(s.is("$textProxy"))return s;if(s.is("element")&&s.getCustomProperty("dataPipeline:transparentRendering"))continue;if(s.is("element","br"))return null;if(this._isInlineObjectElement(s))return s;if(s.is("containerElement"))return null}return null}_isBlockDomElement(t){return this.isElement(t)&&this.blockElements.includes(t.tagName.toLowerCase())}_isBlockViewElement(t){return t.is("element")&&this.blockElements.includes(t.name)}_isInlineObjectElement(t){return t.is("element")?t.name=="br"||this.inlineObjectElements.includes(t.name)||!!this._inlineObjectElementMatcher.match(t):!1}_createViewElement(t,e){if(We(t))return new gt(this.document,"$comment");const n=e.keepOriginalCase?t.tagName:t.tagName.toLowerCase();return new ne(this.document,n)}_isViewElementWithRawContent(t,e){return e.withChildren!==!1&&t.is("element")&&!!this._rawContentElementMatcher.match(t)}_shouldRenameElement(t){const e=t.toLowerCase();return this.renderingMode==="editing"&&this.unsafeElements.includes(e)}_createReplacementDomElement(t,e){const n=this._domDocument.createElement("span");if(n.setAttribute(mn,t),e){for(;e.firstChild;)n.appendChild(e.firstChild);for(const s of e.getAttributeNames())n.setAttribute(s,e.getAttribute(s))}return n}}function Br(r,t){return r.getAncestors().some(e=>e.is("element")&&t.includes(e.name))}function gn(r,t){let e=r;for(;e;)t(e),e=e.parentElement}function Dr(r,t){return r.isEqualNode(Ir)&&is(r,t)&&r.parentNode.childNodes.length===1}function is(r,t){const e=r.parentNode;return!!e&&!!e.tagName&&t.includes(e.tagName.toLowerCase())}function Vr(r,t,e){return t==" "&&r&&r.is("element")&&r.childCount==1&&e.includes(r.name)}function $r(r,t){return t==" "&&r&&r.is("element","span")&&r.childCount==1&&r.hasAttribute("data-cke-filler")}function pn(r){return r.is("element","br")&&r.hasAttribute("data-cke-filler")}function _n(r,t){return r.tagName==="BR"&&is(r,t)&&r.parentNode.childNodes.length===1}function wn(r){r==="script"&&q("domconverter-unsafe-script-element-detected"),r==="style"&&q("domconverter-unsafe-style-element-detected")}function Lr(r){if(!x.isGecko||!r.rangeCount)return!1;const t=r.getRangeAt(0).startContainer;try{Object.prototype.toString.call(t)}catch{return!0}return!1}class Ne extends Ls(){constructor(e){super();c(this,"view");c(this,"document");c(this,"_isEnabled",!1);this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class Wr{constructor(t,e,n){c(this,"view");c(this,"document");c(this,"domEvent");c(this,"domTarget");this.view=t,this.document=t.document,this.domEvent=e,this.domTarget=e.target,Ks(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class Pe extends Ne{constructor(){super(...arguments);c(this,"useCapture",!1);c(this,"usePassive",!1)}observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(s=>{this.listenTo(e,s,(i,o)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(o.target)&&this.onDomEvent(o)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,n,s){this.isEnabled&&this.document.fire(e,new Wr(this.view,n,s))}}class qr extends Pe{constructor(){super(...arguments);c(this,"domEventType",["keydown","keyup"])}onDomEvent(e){const n={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return Gs(this)}};this.fire(e.type,e,n)}}class zr extends Ne{constructor(e){super(e);c(this,"_fireSelectionChangeDoneDebounced");this._fireSelectionChangeDoneDebounced=xt(n=>{this.document.fire("selectionChangeDone",n)},200)}observe(){const e=this.document;e.on("arrowKey",(n,s)=>{e.selection.isFake&&this.isEnabled&&s.preventDefault()},{context:"$capture"}),e.on("arrowKey",(n,s)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(s.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const n=this.document.selection,s=new ee(n.getRanges(),{backward:n.isBackward,fake:!1});(e==me.arrowleft||e==me.arrowup)&&s.setTo(s.getFirstPosition()),(e==me.arrowright||e==me.arrowdown)&&s.setTo(s.getLastPosition());const i={oldSelection:n,newSelection:s,domSelection:null};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}class os extends Ne{constructor(e){super(e);c(this,"domConverter");c(this,"_config");c(this,"_domElements");c(this,"_mutationObserver");this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const n of this._domElements)this._mutationObserver.observe(n,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(e.length===0)return;const n=this.domConverter,s=new Set,i=new Set;for(const a of e){const l=n.mapDomToView(a.target);l&&(l.is("uiElement")||l.is("rawElement")||a.type==="childList"&&!this._isBogusBrMutation(a)&&i.add(l))}for(const a of e){const l=n.mapDomToView(a.target);if(!(l&&(l.is("uiElement")||l.is("rawElement")))&&a.type==="characterData"){const h=n.findCorrespondingViewText(a.target);h&&!i.has(h.parent)?s.add(h):!h&&D(a.target)&&i.add(n.mapDomToView(a.target.parentNode))}}const o=[];for(const a of s)o.push({type:"text",node:a});for(const a of i){const l=n.mapViewToDom(a),h=Array.from(a.getChildren()),u=Array.from(n.domChildrenToView(l,{withChildren:!1}));Ys(h,u,Ur)||o.push({type:"children",node:a})}o.length&&this.document.fire("mutations",{mutations:o})}_isBogusBrMutation(e){let n=null;return e.nextSibling===null&&e.removedNodes.length===0&&e.addedNodes.length==1&&(n=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),n&&n.is("element","br")}}function Ur(r,t){if(!Array.isArray(r))return r===t?!0:r.is("$text")&&t.is("$text")?r.data===t.data:!1}class Dt extends Pe{constructor(e){super(e);c(this,"_renderTimeoutId",null);c(this,"_isFocusChanging",!1);c(this,"domEventType",["focus","blur"]);this.useCapture=!0;const n=this.document;n.on("focus",()=>this._handleFocus()),n.on("blur",(s,i)=>this._handleBlur(i)),n.on("beforeinput",()=>{n.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const n=this.document.selection.editableElement;(n===null||n===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Jr extends Ne{constructor(e){super(e);c(this,"mutationObserver");c(this,"focusObserver");c(this,"selection");c(this,"domConverter");c(this,"_documents",new WeakSet);c(this,"_fireSelectionChangeDoneDebounced");c(this,"_clearInfiniteLoopInterval");c(this,"_documentIsSelectingInactivityTimeoutDebounced");c(this,"_loopbackCounter",0);c(this,"_pendingSelectionChange",new Set);this.mutationObserver=e.getObserver(os),this.focusObserver=e.getObserver(Dt),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=xt(n=>{this.document.fire("selectionChangeDone",n)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=xt(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(n,s,i)=>{if(i&&this._pendingSelectionChange.size){for(const o of Array.from(this._pendingSelectionChange))this._handleSelectionChange(o);this._pendingSelectionChange.clear()}})}observe(e){const n=e.ownerDocument,s=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},i=()=>{this.document.isSelecting&&(this._handleSelectionChange(n),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",s,{priority:"highest"}),this.listenTo(e,"keydown",i,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",i,{priority:"highest",useCapture:!0}),!this._documents.has(n)&&(this.listenTo(n,"mouseup",i,{priority:"highest",useCapture:!0}),this.listenTo(n,"selectionchange",()=>{this.document.isComposing&&!x.isAndroid||(this._handleSelectionChange(n),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(n)},{priority:"lowest"}),this._documents.add(n))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const n=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(n.anchorNode))return;this.mutationObserver.flush();const s=this.domConverter.domSelectionToView(n);if(s.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(s)&&this.domConverter.isDomSelectionCorrect(n))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(this.selection.isSimilar(s))this.view.forceRender();else{const i={oldSelection:this.selection,newSelection:s,domSelection:n};this.document.fire("selectionChange",i),this._fireSelectionChangeDoneDebounced(i)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}class jr extends Pe{constructor(e){super(e);c(this,"domEventType",["compositionstart","compositionupdate","compositionend"]);const n=this.document;n.on("compositionstart",()=>{n.isComposing=!0}),n.on("compositionend",()=>{n.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}/**
7
+ */let we=class{is(){throw new Error("is() method is abstract")}},be=class extends N(we){document;parent;constructor(e){super(),this.document=e,this.parent=null}get index(){let e;if(!this.parent)return null;if((e=this.parent.getChildIndex(this))==-1)throw new f("view-node-not-found-in-parent",this);return e}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.root.is("rootElement")}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.index),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),r=e.getAncestors(t);let i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),r=F(t,n);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r]<n[r]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}_remove(){this.parent._removeChildren(this.index)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n),this.parent&&this.parent._fireChange(e,t,n)}toJSON(){const e=Un(this);return delete e.parent,e}};be.prototype.is=function(s){return s==="node"||s==="view:node"};let x=class xt extends be{_textData;constructor(e,t){super(e),this._textData=t}get data(){return this._textData}get _data(){return this.data}set _data(e){this._fireChange("text",this),this._textData=e}isSimilar(e){return e instanceof xt?this===e||this.data===e.data:!1}_clone(){return new xt(this.document,this.data)}};x.prototype.is=function(s){return s==="$text"||s==="view:$text"||s==="text"||s==="view:text"||s==="node"||s==="view:node"};let Q=class extends we{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.data.length)throw new f("view-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.data.length)throw new f("view-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get offsetSize(){return this.data.length}get isPartial(){return this.data.length!==this.textNode.data.length}get parent(){return this.textNode.parent}get root(){return this.textNode.root}get document(){return this.textNode.document}getAncestors(e={}){const t=[];let n=e.includeSelf?this.textNode:this.parent;for(;n!==null;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}};Q.prototype.is=function(s){return s==="$textProxy"||s==="view:$textProxy"||s==="textProxy"||s==="view:textProxy"};class ct{_consumables=new Map;add(e,t){let n;if(e.is("$text")||e.is("documentFragment")){this._consumables.set(e,!0);return}this._consumables.has(e)?n=this._consumables.get(e):(n=new er(e),this._consumables.set(e,n)),n.add(t?Ve(t):e._getConsumables())}test(e,t){const n=this._consumables.get(e);return n===void 0?null:e.is("$text")||e.is("documentFragment")?n:n.test(Ve(t))}consume(e,t){if(e.is("$text")||e.is("documentFragment"))return this.test(e,t)?(this._consumables.set(e,!1),!0):!1;const n=this._consumables.get(e);return n===void 0?!1:n.consume(Ve(t))}revert(e,t){const n=this._consumables.get(e);n!==void 0&&(e.is("$text")||e.is("documentFragment")?this._consumables.set(e,!0):n.revert(Ve(t)))}static createFrom(e,t){if(t||(t=new ct),e.is("$text"))t.add(e);else if(e.is("element")||e.is("documentFragment")){t.add(e);for(const n of e.getChildren())ct.createFrom(n,t)}return t}}class er{element;_canConsumeName=null;_attributes=new Map;constructor(e){this.element=e}add(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes)if(n){let r=this._attributes.get(t);(!r||typeof r=="boolean")&&(r=new Map,this._attributes.set(t,r)),r.set(n,!0)}else{if(t=="style"||t=="class")throw new f("viewconsumable-invalid-attribute",this);this._attributes.set(t,!0)}}test(e){if(e.name&&!this._canConsumeName)return this._canConsumeName;for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(r===void 0)return null;if(r===!1)return!1;if(r!==!0){if(n){const i=r.get(n);if(i===void 0)return null;if(!i)return!1}else for(const i of r.values())if(!i)return!1}}return!0}consume(e){if(!this.test(e))return!1;e.name&&(this._canConsumeName=!1);for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(typeof r=="boolean")for(const[i]of this.element._getConsumables(t,n).attributes)this._attributes.set(i,!1);else if(n)for(const[,i]of this.element._getConsumables(t,n).attributes)r.set(i,!1);else for(const i of r.keys())r.set(i,!1)}return!0}revert(e){e.name&&(this._canConsumeName=!0);for(const[t,n]of e.attributes){const r=this._attributes.get(t);if(r===!1){this._attributes.set(t,!0);continue}if(!(r===void 0||r===!0))if(n)r.get(n)===!1&&r.set(n,!0);else for(const i of r.keys())r.set(i,!0)}}}function Ve(s){const e=[];return"attributes"in s&&s.attributes&&wt(e,s.attributes),"classes"in s&&s.classes&&wt(e,s.classes,"class"),"styles"in s&&s.styles&&wt(e,s.styles,"style"),{name:s.name||!1,attributes:e}}function wt(s,e,t){if(typeof e=="string"){s.push(t?[t,e]:[e]);return}for(const n of e)Array.isArray(n)?s.push(n):s.push(t?[t,n]:[n])}class je{_patterns=[];constructor(...e){this.add(...e)}add(...e){for(let t of e)(typeof t=="string"||t instanceof RegExp)&&(t={name:t}),this._patterns.push(t)}match(...e){for(const t of e)for(const n of this._patterns){const r=this._isElementMatching(t,n);if(r)return{element:t,pattern:n,match:r}}return null}matchAll(...e){const t=[];for(const n of e)for(const r of this._patterns){const i=this._isElementMatching(n,r);i&&t.push({element:n,pattern:r,match:i})}return t.length>0?t:null}getElementName(){if(this._patterns.length!==1)return null;const e=this._patterns[0],t=e.name;return typeof e!="function"&&t&&!(t instanceof RegExp)?t:null}_isElementMatching(e,t){if(typeof t=="function"){const i=t(e);return!i||typeof i!="object"?i:Ve(i)}const n={};if(t.name&&(n.name=tr(t.name,e.name),!n.name))return null;const r=[];return t.attributes&&!nr(t.attributes,e,r)||t.classes&&!sr(t.classes,e,r)||t.styles&&!rr(t.styles,e,r)?null:(r.length&&(n.attributes=r),n)}}function ht(s,e){return s===!0||s===e||s instanceof RegExp&&!!String(e).match(s)}function tr(s,e){return s instanceof RegExp?!!e.match(s):s===e}function qt(s,e){if(Array.isArray(s))return s.map(n=>typeof n!="object"||n instanceof RegExp?e?[e,n,!0]:[n,!0]:((n.key===void 0||n.value===void 0)&&W("matcher-pattern-missing-key-or-value",n),e?[e,n.key,n.value]:[n.key,n.value]));if(typeof s!="object"||s instanceof RegExp)return[e?[e,s,!0]:[s,!0]];const t=[];for(const n in s)Object.prototype.hasOwnProperty.call(s,n)&&t.push(e?[e,n,s[n]]:[n,s[n]]);return t}function nr(s,e,t){let n;return typeof s=="object"&&!(s instanceof RegExp)&&!Array.isArray(s)?(s.style!==void 0&&W("matcher-pattern-deprecated-attributes-style-key",s),s.class!==void 0&&W("matcher-pattern-deprecated-attributes-class-key",s)):n=["class","style"],e._collectAttributesMatch(qt(s),t,n)}function sr(s,e,t){return e._collectAttributesMatch(qt(s,"class"),t)}function rr(s,e,t){return e._collectAttributesMatch(qt(s,"style"),t)}class We{_styles;_cachedStyleNames=null;_cachedExpandedStyleNames=null;_styleProcessor;constructor(e){this._styles={},this._styleProcessor=e}get isEmpty(){return!Object.entries(this._styles).length}get size(){return this.isEmpty?0:this.getStyleNames().length}setTo(e){this.clear();const t=ir(e);for(const[n,r]of t)this._styleProcessor.toNormalizedForm(n,r,this._styles);return this}has(e){if(this.isEmpty)return!1;const n=this._styleProcessor.getReducedForm(e,this._styles).find(([r])=>r===e);return Array.isArray(n)}set(e,t){if(this._cachedStyleNames=null,this._cachedExpandedStyleNames=null,at(e))for(const[n,r]of Object.entries(e))this._styleProcessor.toNormalizedForm(n,r,this._styles);else this._styleProcessor.toNormalizedForm(e,t,this._styles)}remove(e){for(const t of ae(e)){this._cachedStyleNames=null,this._cachedExpandedStyleNames=null;const n=Nt(t);Us(this._styles,n),delete this._styles[t],this._cleanEmptyObjectsOnPath(n)}}getNormalized(e){return this._styleProcessor.getNormalized(e,this._styles)}toString(){return this.isEmpty?"":this.getStylesEntries().map(e=>e.join(":")).sort().join(";")+";"}getAsString(e){if(this.isEmpty)return;if(this._styles[e]&&!at(this._styles[e]))return this._styles[e];const n=this._styleProcessor.getReducedForm(e,this._styles).find(([r])=>r===e);if(Array.isArray(n))return n[1]}getStyleNames(e=!1){return this.isEmpty?[]:e?(this._cachedExpandedStyleNames||=this._styleProcessor.getStyleNames(this._styles),this._cachedExpandedStyleNames):(this._cachedStyleNames||=this.getStylesEntries().map(([t])=>t),this._cachedStyleNames)}keys(){return this.getStyleNames()}clear(){this._styles={},this._cachedStyleNames=null,this._cachedExpandedStyleNames=null}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.getStyleNames())if(!e.has(t)||e.getAsString(t)!==this.getAsString(t))return!1;return!0}getStylesEntries(){const e=[],t=Object.keys(this._styles);for(const n of t)e.push(...this._styleProcessor.getReducedForm(n,this._styles));return e}_clone(){const e=new this.constructor(this._styleProcessor);return e.set(this.getNormalized()),e}_getTokensMatch(e,t){const n=[];for(const r of this.getStyleNames(!0))if(ht(e,r)){if(t===!0){n.push(r);continue}const i=this.getAsString(r);ht(t,i)&&n.push(r)}return n.length?n:void 0}_getConsumables(e){const t=[];if(e){t.push(e);for(const n of this._styleProcessor.getRelatedStyles(e))t.push(n)}else for(const n of this.getStyleNames()){for(const r of this._styleProcessor.getRelatedStyles(n))t.push(r);t.push(n)}return t}_canMergeFrom(e){for(const t of e.getStyleNames())if(this.has(t)&&this.getAsString(t)!==e.getAsString(t))return!1;return!0}_mergeFrom(e){for(const t of e.getStyleNames())this.has(t)||this.set(t,e.getAsString(t))}_isMatching(e){for(const t of e.getStyleNames())if(!this.has(t)||this.getAsString(t)!==e.getAsString(t))return!1;return!0}_cleanEmptyObjectsOnPath(e){const t=e.split(".");if(!(t.length>1))return;const r=t.splice(0,t.length-1).join("."),i=lt(this._styles,r);if(!i)return;!Object.keys(i).length&&this.remove(r)}}class ul{_normalizers;_extractors;_reducers;_consumables;constructor(){this._normalizers=new Map,this._extractors=new Map,this._reducers=new Map,this._consumables=new Map}toNormalizedForm(e,t,n){if(at(t)){bt(n,Nt(e),t);return}if(this._normalizers.has(e)){const r=this._normalizers.get(e),{path:i,value:o}=r(t);bt(n,i,o)}else bt(n,e,t)}getNormalized(e,t){if(!e)return Jn({},t);if(t[e]!==void 0)return t[e];if(this._extractors.has(e)){const n=this._extractors.get(e);if(typeof n=="string")return lt(t,n);const r=n(e,t);if(r)return r}return lt(t,Nt(e))}getReducedForm(e,t){const n=this.getNormalized(e,t);return n===void 0?[]:this._reducers.has(e)?this._reducers.get(e)(n):[[e,n]]}getStyleNames(e){const t=new Set;for(const n of this._consumables.keys()){const r=this.getNormalized(n,e);r&&(typeof r!="object"||Object.keys(r).length)&&t.add(n)}for(const n of Object.keys(e))t.add(n);return Array.from(t)}getRelatedStyles(e){return this._consumables.get(e)||[]}setNormalizer(e,t){this._normalizers.set(e,t)}setExtractor(e,t){this._extractors.set(e,t)}setReducer(e,t){this._reducers.set(e,t)}setStyleRelation(e,t){this._mapStyleNames(e,t);for(const n of t)this._mapStyleNames(n,[e])}_mapStyleNames(e,t){this._consumables.has(e)||this._consumables.set(e,[]),this._consumables.get(e).push(...t)}}function ir(s){let e=null,t=0,n=0,r=null;const i=new Map;if(s==="")return i;s.charAt(s.length-1)!=";"&&(s=s+";");for(let o=0;o<s.length;o++){const a=s.charAt(o);if(e===null)switch(a){case":":r||(r=s.substr(t,o-t),n=o+1);break;case'"':case"'":e=a;break;case";":{const l=s.substr(n,o-n);r&&i.set(r.trim(),l.trim()),r=null,t=o+1;break}}else a===e&&(e=null)}return i}function Nt(s){return s.replace("-",".")}function bt(s,e,t){let n=t;at(t)&&(n=Jn({},lt(s,e),t)),js(s,e,n)}class yt{_set=new Set;get isEmpty(){return this._set.size==0}get size(){return this._set.size}has(e){return this._set.has(e)}keys(){return Array.from(this._set.keys())}setTo(e){this.clear();for(const t of e.split(/\s+/))t&&this._set.add(t);return this}set(e){for(const t of ae(e))t&&this._set.add(t)}remove(e){for(const t of ae(e))this._set.delete(t)}clear(){this._set.clear()}toString(){return Array.from(this._set).join(" ")}isSimilar(e){if(this.size!==e.size)return!1;for(const t of this.keys())if(!e.has(t))return!1;return!0}_clone(){const e=new this.constructor;return e._set=new Set(this._set),e}_getTokensMatch(e){const t=[];if(e===!0){for(const n of this._set.keys())t.push(n);return t}if(typeof e=="string"){for(const n of e.split(/\s+/))if(this._set.has(n))t.push(n);else return;return t}for(const n of this._set.keys())n.match(e)&&t.push(n);return t.length?t:void 0}_getConsumables(e){return e?[e]:this.keys()}_canMergeFrom(){return!0}_mergeFrom(e){for(const t of e._set.keys())this._set.has(t)||this._set.add(t)}_isMatching(e){for(const t of e._set.keys())if(!this._set.has(t))return!1;return!0}}let te=class jn extends be{name;_unsafeAttributesToRender=[];_attrs;_children;_customProperties=new Map;get _classes(){return this._attrs.get("class")}get _styles(){return this._attrs.get("style")}constructor(e,t,n,r){super(e),this.name=t,this._attrs=this._parseAttributes(n),this._children=[],r&&this._insertChild(0,r)}get childCount(){return this._children.length}get isEmpty(){return this._children.length===0}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}*getAttributeKeys(){this._classes&&(yield"class"),this._styles&&(yield"style");for(const e of this._attrs.keys())e!="class"&&e!="style"&&(yield e)}*getAttributes(){for(const[e,t]of this._attrs.entries())yield[e,String(t)]}getAttribute(e){return this._attrs.has(e)?String(this._attrs.get(e)):void 0}hasAttribute(e,t){return this._attrs.has(e)?t!==void 0?Pe(this.name,e)||Oe(this.name,e)?this._attrs.get(e).has(t):this._attrs.get(e)===t:!0:!1}isSimilar(e){if(!(e instanceof jn))return!1;if(this===e)return!0;if(this.name!=e.name||this._attrs.size!==e._attrs.size)return!1;for(const[t,n]of this._attrs){const r=e._attrs.get(t);if(r===void 0)return!1;if(typeof n=="string"||typeof r=="string"){if(r!==n)return!1}else if(!n.isSimilar(r))return!1}return!0}hasClass(...e){for(const t of e)if(!this._classes||!this._classes.has(t))return!1;return!0}getClassNames(){const e=this._classes?this._classes.keys():[],t=e[Symbol.iterator]();return Object.assign(e,{next:t.next.bind(t)})}getStyle(e){return this._styles&&this._styles.getAsString(e)}getNormalizedStyle(e){return this._styles&&this._styles.getNormalized(e)}getStyleNames(e){return this._styles?this._styles.getStyleNames(e):[]}hasStyle(...e){for(const t of e)if(!this._styles||!this._styles.has(t))return!1;return!0}findAncestor(...e){const t=new je(...e);let n=this.parent;for(;n&&!n.is("documentFragment");){if(t.match(n))return n;n=n.parent}return null}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}getIdentity(){const e=this._classes?this._classes.keys().sort().join(","):"",t=this._styles&&String(this._styles),n=Array.from(this._attrs).filter(([r])=>r!="style"&&r!="class").map(r=>`${r[0]}="${r[1]}"`).sort().join(" ");return this.name+(e==""?"":` class="${e}"`)+(t?` style="${t}"`:"")+(n==""?"":` ${n}`)}shouldRenderUnsafeAttribute(e){return this._unsafeAttributesToRender.includes(e)}_clone(e=!1){const t=[];if(e)for(const r of this.getChildren())t.push(r._clone(e));const n=new this.constructor(this.document,this.name,this._attrs,t);return n._customProperties=new Map(this._customProperties),n.getFillerOffset=this.getFillerOffset,n._unsafeAttributesToRender=this._unsafeAttributesToRender,n}_appendChild(e){return this._insertChild(this.childCount,e)}_insertChild(e,t){this._fireChange("children",this,{index:e});let n=0;const r=or(this.document,t);for(const i of r)i.parent!==null&&i._remove(),i.parent=this,i.document=this.document,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_setAttribute(e,t,n=!0){if(this._fireChange("attributes",this),Pe(this.name,e)||Oe(this.name,e)){let r=this._attrs.get(e);r||(r=Pe(this.name,e)?new We(this.document.stylesProcessor):new yt,this._attrs.set(e,r)),n?r.setTo(String(t)):Pe(this.name,e)?Array.isArray(t)?r.set(t[0],t[1]):r.set(t):r.set(typeof t=="string"?t.split(/\s+/):t)}else this._attrs.set(e,String(t))}_removeAttribute(e,t){if(this._fireChange("attributes",this),t!==void 0&&(Pe(this.name,e)||Oe(this.name,e))){const n=this._attrs.get(e);return n?(Oe(this.name,e)&&typeof t=="string"&&(t=t.split(/\s+/)),n.remove(t),n.isEmpty?this._attrs.delete(e):!1):!1}return this._attrs.delete(e)}_addClass(e){this._setAttribute("class",e,!1)}_removeClass(e){this._removeAttribute("class",e)}_setStyle(e,t){typeof e!="string"?this._setAttribute("style",e,!1):this._setAttribute("style",[e,t],!1)}_removeStyle(e){this._removeAttribute("style",e)}_collectAttributesMatch(e,t,n){for(const[r,i,o]of e){let a=!1,l=!1;for(const[c,h]of this._attrs)if(!(n&&n.includes(c)||!ht(r,c)))if(a=!0,typeof h=="string"){if(ht(i,h))t.push([c]),l=!0;else if(!(r instanceof RegExp))return!1}else{const d=h._getTokensMatch(i,o||!0);if(d){l=!0;for(const p of d)t.push([c,p])}else if(!(r instanceof RegExp))return!1}if(!a||!l)return!1}return!0}_getConsumables(e,t){const n=[];if(e){const r=this._attrs.get(e);if(r!==void 0)if(typeof r=="string")n.push([e]);else for(const i of r._getConsumables(t))n.push([e,i])}else for(const[r,i]of this._attrs)if(typeof i=="string")n.push([r]);else for(const o of i._getConsumables())n.push([r,o]);return{name:!e,attributes:n}}_canMergeAttributesFrom(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const r=this._attrs.get(t);if(r!==void 0){if(typeof r=="string"||typeof n=="string"){if(r!==n)return!1}else if(!r._canMergeFrom(n))return!1}}return!0}_mergeAttributesFrom(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const r=this._attrs.get(t);r===void 0||typeof r=="string"||typeof n=="string"?this._setAttribute(t,n):r._mergeFrom(n)}}_canSubtractAttributesOf(e){if(this.name!=e.name)return!1;for(const[t,n]of e._attrs){const r=this._attrs.get(t);if(r===void 0)return!1;if(typeof r=="string"||typeof n=="string"){if(r!==n)return!1}else if(!r._isMatching(n))return!1}return!0}_subtractAttributesOf(e){this._fireChange("attributes",this);for(const[t,n]of e._attrs){const r=this._attrs.get(t);typeof r=="string"||typeof n=="string"?this._attrs.delete(t):(r.remove(n.keys()),r.isEmpty&&this._attrs.delete(t))}}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}_parseAttributes(e){const t=pe(e);for(const[n,r]of t)if(r===null)t.delete(n);else if(Pe(this.name,n)){const i=r instanceof We?r._clone():new We(this.document.stylesProcessor).setTo(String(r));t.set(n,i)}else if(Oe(this.name,n)){const i=r instanceof yt?r._clone():new yt().setTo(String(r));t.set(n,i)}else typeof r!="string"&&t.set(n,String(r));return t}};te.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="view:element"):s==="element"||s==="view:element"||s==="node"||s==="view:node"};function or(s,e){if(typeof e=="string")return[new x(s,e)];le(e)||(e=[e]);const t=[];for(const n of e)typeof n=="string"?t.push(new x(s,n)):n instanceof Q?t.push(new x(s,n.data)):t.push(n);return t}function Oe(s,e){return e=="class"||s=="a"&&e=="rel"}function Pe(s,e){return e=="style"}class Ge extends te{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=ar}}Ge.prototype.is=function(s,e){return e?e===this.name&&(s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function ar(){const s=[...this.getChildren()],e=s[this.childCount-1];if(e&&e.is("element","br"))return this.childCount;for(const t of s)if(!t.is("uiElement"))return null;return this.childCount}class dt extends U(Ge){constructor(e,t,n,r){super(e,t,n,r),this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("placeholder",void 0),this.bind("isReadOnly").to(e),this.bind("isFocused").to(e,"isFocused",i=>i&&e.selection.editableElement==this),this.listenTo(e.selection,"change",()=>{this.isFocused=e.isFocused&&e.selection.editableElement==this})}destroy(){this.stopListening()}}dt.prototype.is=function(s,e){return e?e===this.name&&(s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};const on=Symbol("rootName");class Gn extends dt{constructor(e,t){super(e,t),this.rootName="main"}get rootName(){return this.getCustomProperty(on)}set rootName(e){this._setCustomProperty(on,e)}set _name(e){this.name=e}}Gn.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"):s==="rootElement"||s==="view:rootElement"||s==="editableElement"||s==="view:editableElement"||s==="containerElement"||s==="view:containerElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};let me=class{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;constructor(e={}){if(!e.boundaries&&!e.startPosition)throw new f("view-tree-walker-no-start-position",null);if(e.direction&&e.direction!="forward"&&e.direction!="backward")throw new f("view-tree-walker-unknown-direction",e.startPosition,{direction:e.direction});this.boundaries=e.boundaries||null,e.startPosition?this._position=g._createAt(e.startPosition):this._position=g._createAt(e.boundaries[e.direction=="backward"?"end":"start"]),this.direction=e.direction||"forward",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,n;do n=this.position,t=this.next();while(!t.done&&e(t.value));t.done||(this._position=n)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone()}next(){return this.direction=="forward"?this._next():this._previous()}_next(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===n.childCount)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};let r;if(n&&n.is("view:$text")){if(e.isAtEnd)return this._position=g._createAfter(n),this._next();r=n.data[e.offset]}else r=n.getChild(e.offset);if(typeof r=="string"){let i;this.singleCharacters?i=1:i=(n===this._boundaryEndParent?this.boundaries.end.offset:n.data.length)-e.offset;const o=new Q(n,e.offset,i);return e.offset+=i,this._position=e,this._formatReturnValue("text",o,t,e,i)}if(r&&r.is("view:element")){if(!this.shallow)e=new g(r,0);else{if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}return this._position=e,this._formatReturnValue("elementStart",r,t,e,1)}if(r&&r.is("view:$text")){if(this.singleCharacters)return e=new g(r,0),this._position=e,this._next();let i=r.data.length,o;return r==this._boundaryEndParent?(i=this.boundaries.end.offset,o=new Q(r,0,i),e=g._createAfter(o)):(o=new Q(r,0,r.data.length),e.offset++),this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=g._createAfter(n),this._position=e,this.ignoreElementEnd?this._next():this._formatReturnValue("elementEnd",n,t,e)}_previous(){let e=this.position.clone();const t=this.position,n=e.parent;if(n.parent===null&&e.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};let r;if(n.is("view:$text")){if(e.isAtStart)return this._position=g._createBefore(n),this._previous();r=n.data[e.offset-1]}else r=n.getChild(e.offset-1);if(typeof r=="string"){let i;if(this.singleCharacters)i=1;else{const a=n===this._boundaryStartParent?this.boundaries.start.offset:0;i=e.offset-a}e.offset-=i;const o=new Q(n,e.offset,i);return this._position=e,this._formatReturnValue("text",o,t,e,i)}if(r&&r.is("view:element"))return this.shallow?(e.offset--,this._position=e,this._formatReturnValue("elementStart",r,t,e,1)):(e=new g(r,r.childCount),this._position=e,this.ignoreElementEnd?this._previous():this._formatReturnValue("elementEnd",r,t,e));if(r&&r.is("view:$text")){if(this.singleCharacters)return e=new g(r,r.data.length),this._position=e,this._previous();let i=r.data.length,o;if(r==this._boundaryStartParent){const a=this.boundaries.start.offset;o=new Q(r,a,r.data.length-a),i=o.data.length,e=g._createBefore(o)}else o=new Q(r,0,r.data.length),e.offset--;return this._position=e,this._formatReturnValue("text",o,t,e,i)}return e=g._createBefore(n),this._position=e,this._formatReturnValue("elementStart",n,t,e,1)}_formatReturnValue(e,t,n,r,i){return t.is("view:$textProxy")&&(t.offsetInText+t.data.length==t.textNode.data.length&&(this.direction=="forward"&&!(this.boundaries&&this.boundaries.end.isEqual(this.position))?(r=g._createAfter(t.textNode),this._position=r):n=g._createAfter(t.textNode)),t.offsetInText===0&&(this.direction=="backward"&&!(this.boundaries&&this.boundaries.start.isEqual(this.position))?(r=g._createBefore(t.textNode),this._position=r):n=g._createBefore(t.textNode))),{done:!1,value:{type:e,item:t,previousPosition:n,nextPosition:r,length:i}}}},g=class Y extends we{parent;offset;constructor(e,t){super(),this.parent=e,this.offset=t}get nodeAfter(){return this.parent.is("$text")?null:this.parent.getChild(this.offset)||null}get nodeBefore(){return this.parent.is("$text")?null:this.parent.getChild(this.offset-1)||null}get isAtStart(){return this.offset===0}get isAtEnd(){const e=this.parent.is("$text")?this.parent.data.length:this.parent.childCount;return this.offset===e}get root(){return this.parent.root}get editableElement(){let e=this.parent;for(;!(e instanceof dt);)if(e.parent)e=e.parent;else return null;return e}getShiftedBy(e){const t=Y._createAt(this),n=t.offset+e;return t.offset=n<0?0:n,t}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new me(t);return n.skip(e),n.position}getAncestors(){return this.parent.is("documentFragment")?[this.parent]:this.parent.getAncestors({includeSelf:!0})}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]==n[r]&&t[r];)r++;return r===0?null:t[r-1]}isEqual(e){return this.parent==e.parent&&this.offset==e.offset}isBefore(e){return this.compareWith(e)=="before"}isAfter(e){return this.compareWith(e)=="after"}compareWith(e){if(this.root!==e.root)return"different";if(this.isEqual(e))return"same";const t=this.parent.is("node")?this.parent.getPath():[],n=e.parent.is("node")?e.parent.getPath():[];t.push(this.offset),n.push(e.offset);const r=F(t,n);switch(r){case"prefix":return"before";case"extension":return"after";default:return t[r]<n[r]?"before":"after"}}getWalker(e={}){return e.startPosition=this,new me(e)}clone(){return new Y(this.parent,this.offset)}static _createAt(e,t){if(e instanceof Y)return new this(e.parent,e.offset);{const n=e;if(t=="end")t=n.is("$text")?n.data.length:n.childCount;else{if(t=="before")return this._createBefore(n);if(t=="after")return this._createAfter(n);if(t!==0&&!t)throw new f("view-createpositionat-offset-required",n)}return new Y(n,t)}}static _createAfter(e){if(e.is("$textProxy"))return new Y(e.textNode,e.offsetInText+e.data.length);if(!e.parent)throw new f("view-position-after-root",e,{root:e});return new Y(e.parent,e.index+1)}static _createBefore(e){if(e.is("$textProxy"))return new Y(e.textNode,e.offsetInText);if(!e.parent)throw new f("view-position-before-root",e,{root:e});return new Y(e.parent,e.index)}};g.prototype.is=function(s){return s==="position"||s==="view:position"};let w=class se extends we{start;end;constructor(e,t=null){super(),this.start=e.clone(),this.end=t?t.clone():e.clone()}*[Symbol.iterator](){yield*new me({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){return this.start.parent===this.end.parent}get root(){return this.start.root}getEnlarged(){let e=this.start.getLastMatchingPosition(et,{direction:"backward"}),t=this.end.getLastMatchingPosition(et);return e.parent.is("$text")&&e.isAtStart&&(e=g._createBefore(e.parent)),t.parent.is("$text")&&t.isAtEnd&&(t=g._createAfter(t.parent)),new se(e,t)}getTrimmed(){let e=this.start.getLastMatchingPosition(et);if(e.isAfter(this.end)||e.isEqual(this.end))return new se(e,e);let t=this.end.getLastMatchingPosition(et,{direction:"backward"});const n=e.nodeAfter,r=t.nodeBefore;return n&&n.is("$text")&&(e=new g(n,0)),r&&r.is("$text")&&(t=new g(r,r.data.length)),new se(e,t)}isEqual(e){return this==e||this.start.isEqual(e.start)&&this.end.isEqual(e.end)}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&r}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new se(this.start,e.start)),this.containsPosition(e.end)&&t.push(new se(e.end,this.end))):t.push(this.clone()),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new se(t,n)}return null}getWalker(e={}){return e.boundaries=this,new me(e)}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;let e=this.start.nodeAfter,t=this.end.nodeBefore;return this.start.parent.is("$text")&&this.start.isAtEnd&&this.start.parent.nextSibling&&(e=this.start.parent.nextSibling),this.end.parent.is("$text")&&this.end.isAtStart&&this.end.parent.previousSibling&&(t=this.end.parent.previousSibling),e&&e.is("element")&&e===t?e:null}clone(){return new se(this.start,this.end)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new me(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new me(e);yield t.position;for(const n of t)yield n.nextPosition}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}static _createFromParentsAndOffsets(e,t,n,r){return new this(new g(e,t),new g(n,r))}static _createFromPositionAndShift(e,t){const n=e,r=e.getShiftedBy(t);return t>0?new this(n,r):new this(r,n)}static _createIn(e){return this._createFromParentsAndOffsets(e,0,e,e.childCount)}static _createOn(e){const t=e.is("$textProxy")?e.offsetSize:1;return this._createFromPositionAndShift(g._createBefore(e),t)}};w.prototype.is=function(s){return s==="range"||s==="view:range"};function et(s){return!!(s.item.is("attributeElement")||s.item.is("uiElement"))}let Z=class Hn extends N(we){_ranges;_lastRangeBackward;_isFake;_fakeSelectionLabel;constructor(...e){super(),this._ranges=[],this._lastRangeBackward=!1,this._isFake=!1,this._fakeSelectionLabel="",e.length&&this.setTo(...e)}get isFake(){return this._isFake}get fakeSelectionLabel(){return this._fakeSelectionLabel}get anchor(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.end:e.start).clone()}get focus(){if(!this._ranges.length)return null;const e=this._ranges[this._ranges.length-1];return(this._lastRangeBackward?e.start:e.end).clone()}get isCollapsed(){return this.rangeCount===1&&this._ranges[0].isCollapsed}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}get editableElement(){return this.anchor?this.anchor.editableElement:null}*getRanges(){for(const e of this._ranges)yield e.clone()}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?e.clone():null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?e.clone():null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}isEqual(e){if(this.isFake!=e.isFake||this.isFake&&this.fakeSelectionLabel!=e.fakeSelectionLabel||this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}isSimilar(e){if(this.isBackward!=e.isBackward)return!1;const t=Zt(this.getRanges()),n=Zt(e.getRanges());if(t!=n)return!1;if(t==0)return!0;for(let r of this.getRanges()){r=r.getTrimmed();let i=!1;for(let o of e.getRanges())if(o=o.getTrimmed(),r.start.isEqual(o.start)&&r.end.isEqual(o.end)){i=!0;break}if(!i)return!1}return!0}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}setTo(...e){let[t,n,r]=e;if(typeof n=="object"&&(r=n,n=void 0),t===null)this._setRanges([]),this._setFakeOptions(r);else if(t instanceof Hn||t instanceof zt)this._setRanges(t.getRanges(),t.isBackward),this._setFakeOptions({fake:t.isFake,label:t.fakeSelectionLabel});else if(t instanceof w)this._setRanges([t],r&&r.backward),this._setFakeOptions(r);else if(t instanceof g)this._setRanges([new w(t)]),this._setFakeOptions(r);else if(t instanceof be){const i=!!r&&!!r.backward;let o;if(n===void 0)throw new f("view-selection-setto-required-second-parameter",this);n=="in"?o=w._createIn(t):n=="on"?o=w._createOn(t):o=new w(g._createAt(t,n)),this._setRanges([o],i),this._setFakeOptions(r)}else if(le(t))this._setRanges(t,r&&r.backward),this._setFakeOptions(r);else throw new f("view-selection-setto-not-selectable",this);this.fire("change")}setFocus(e,t){if(this.anchor===null)throw new f("view-selection-setfocus-no-ranges",this);const n=g._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const r=this.anchor;this._ranges.pop(),n.compareWith(r)=="before"?this._addRange(new w(n,r),!0):this._addRange(new w(r,n)),this.fire("change")}_setRanges(e,t=!1){e=Array.from(e),this._ranges=[];for(const n of e)this._addRange(n);this._lastRangeBackward=!!t}_setFakeOptions(e={}){this._isFake=!!e.fake,this._fakeSelectionLabel=e.fake&&e.label||""}_addRange(e,t=!1){if(!(e instanceof w))throw new f("view-selection-add-range-not-range",this);this._pushRange(e),this._lastRangeBackward=!!t}_pushRange(e){for(const t of this._ranges)if(e.isIntersecting(t))throw new f("view-selection-range-intersects",this,{addedRange:e,intersectingRange:t});this._ranges.push(new w(e.start,e.end))}};Z.prototype.is=function(s){return s==="selection"||s==="view:selection"};let zt=class extends N(we){_selection;constructor(...e){super(),this._selection=new Z,this._selection.delegate("change").to(this),e.length&&this._selection.setTo(...e)}get isFake(){return this._selection.isFake}get fakeSelectionLabel(){return this._selection.fakeSelectionLabel}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get isCollapsed(){return this._selection.isCollapsed}get rangeCount(){return this._selection.rangeCount}get isBackward(){return this._selection.isBackward}get editableElement(){return this._selection.editableElement}get _ranges(){return this._selection._ranges}*getRanges(){yield*this._selection.getRanges()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getSelectedElement(){return this._selection.getSelectedElement()}isEqual(e){return this._selection.isEqual(e)}isSimilar(e){return this._selection.isSimilar(e)}_setTo(...e){this._selection.setTo(...e)}_setFocus(e,t){this._selection.setFocus(e,t)}};zt.prototype.is=function(s){return s==="selection"||s=="documentSelection"||s=="view:selection"||s=="view:documentSelection"};class Ut extends Rt{startRange;_eventPhase;_currentTarget;constructor(e,t,n){super(e,t),this.startRange=n,this._eventPhase="none",this._currentTarget=null}get eventPhase(){return this._eventPhase}get currentTarget(){return this._currentTarget}}const vt=Symbol("bubbling contexts");function Ot(s){class e extends s{fire(n,...r){try{const i=n instanceof Rt?n:new Rt(this,n),o=Pt(this);if(!o.size)return;if(Ie(i,"capturing",this),Ce(o,"$capture",i,...r))return i.return;const a=i.startRange||this.selection.getFirstRange(),l=a?a.getContainedElement():null,c=l?!!Kn(o,l):!1;let h=l||lr(a);if(Ie(i,"atTarget",h),!c){if(Ce(o,"$text",i,...r))return i.return;Ie(i,"bubbling",h)}for(;h;){if(h.is("rootElement")){if(Ce(o,"$root",i,...r))return i.return}else if(h.is("element")&&Ce(o,h.name,i,...r))return i.return;if(Ce(o,h,i,...r))return i.return;h=h.parent,Ie(i,"bubbling",h)}return Ie(i,"bubbling",this),Ce(o,"$document",i,...r),i.return}catch(i){/* istanbul ignore next -- @preserve */f.rethrowUnexpectedError(i,this)}}_addEventListener(n,r,i){const o=ae(i.context||"$document"),a=Pt(this);for(const l of o){let c=a.get(l);c||(c=new(N()),a.set(l,c)),this.listenTo(c,n,r,i)}}_removeEventListener(n,r){const i=Pt(this);for(const o of i.values())this.stopListening(o,n,r)}}return e}{const s=Ot(Object);["fire","_addEventListener","_removeEventListener"].forEach(e=>{Ot[e]=s.prototype[e]})}function Ie(s,e,t){s instanceof Ut&&(s._eventPhase=e,s._currentTarget=t)}function Ce(s,e,t,...n){const r=typeof e=="string"?s.get(e):Kn(s,e);return r?(r.fire(t,...n),t.stop.called):!1}function Kn(s,e){for(const[t,n]of s)if(typeof t=="function"&&t(e))return n;return null}function Pt(s){return s[vt]||(s[vt]=new Map),s[vt]}function lr(s){if(!s)return null;const e=s.start.parent,t=s.end.parent,n=e.getPath(),r=t.getPath();return n.length>r.length?e:t}let Xn=class extends Ot(U()){selection;roots;stylesProcessor;_postFixers=new Set;constructor(e){super(),this.selection=new zt,this.roots=new Lt({idProperty:"rootName"}),this.stylesProcessor=e,this.set("isReadOnly",!1),this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1)}getRoot(e="main"){return this.roots.get(e)}registerPostFixer(e){this._postFixers.add(e)}destroy(){this.roots.forEach(e=>e.destroy()),this.stopListening()}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(t=n(e),t)break;while(t)}};const an=10;class Me extends te{static DEFAULT_PRIORITY=an;_priority=an;_id=null;_clonesGroup=null;constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=cr}get priority(){return this._priority}get id(){return this._id}getElementsWithSameId(){if(this.id===null)throw new f("attribute-element-get-elements-with-same-id-no-id",this);return new Set(this._clonesGroup)}isSimilar(e){return this.id!==null||e.id!==null?this.id===e.id:super.isSimilar(e)&&this.priority==e.priority}_clone(e=!1){const t=super._clone(e);return t._priority=this._priority,t._id=this._id,t}_canMergeAttributesFrom(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canMergeAttributesFrom(e)}_canSubtractAttributesOf(e){return this.id!==null||e.id!==null||this.priority!==e.priority?!1:super._canSubtractAttributesOf(e)}}Me.prototype.is=function(s,e){return e?e===this.name&&(s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"):s==="attributeElement"||s==="view:attributeElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function cr(){if(Ct(this))return null;let s=this.parent;for(;s&&s.is("attributeElement");){if(Ct(s)>1)return null;s=s.parent}return!s||Ct(s)>1?null:this.childCount}function Ct(s){return Array.from(s.getChildren()).filter(e=>!e.is("uiElement")).length}class Jt extends te{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=hr}_insertChild(e,t){if(t&&(t instanceof be||Array.from(t).length>0))throw new f("view-emptyelement-cannot-add",[this,t]);return 0}}Jt.prototype.is=function(s,e){return e?e===this.name&&(s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"):s==="emptyElement"||s==="view:emptyElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function hr(){return null}class mt extends te{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=fr}_insertChild(e,t){if(t&&(t instanceof be||Array.from(t).length>0))throw new f("view-uielement-cannot-add",[this,t]);return 0}render(e,t){return this.toDomElement(e)}toDomElement(e){const t=e.createElement(this.name);for(const n of this.getAttributeKeys())t.setAttribute(n,this.getAttribute(n));return t}}mt.prototype.is=function(s,e){return e?e===this.name&&(s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"):s==="uiElement"||s==="view:uiElement"||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function ur(s){s.document.on("arrowKey",(e,t)=>dr(e,t,s.domConverter),{priority:"low"})}function fr(){return null}function dr(s,e,t){if(e.keyCode==de.arrowright){const n=e.domTarget.ownerDocument.defaultView.getSelection(),r=n.rangeCount==1&&n.getRangeAt(0).collapsed;if(r||e.shiftKey){const i=n.focusNode,o=n.focusOffset,a=t.domPositionToView(i,o);if(a===null)return;let l=!1;const c=a.getLastMatchingPosition(h=>(h.item.is("uiElement")&&(l=!0),!!(h.item.is("uiElement")||h.item.is("attributeElement"))));if(l){const h=t.viewPositionToDom(c);r?n.collapse(h.parent,h.offset):n.extend(h.parent,h.offset)}}}}class jt extends te{constructor(e,t,n,r){super(e,t,n,r),this.getFillerOffset=mr}_insertChild(e,t){if(t&&(t instanceof be||Array.from(t).length>0))throw new f("view-rawelement-cannot-add",[this,t]);return 0}render(e,t){}}jt.prototype.is=function(s,e){return e?e===this.name&&(s==="rawElement"||s==="view:rawElement"||s==="element"||s==="view:element"):s==="rawElement"||s==="view:rawElement"||s===this.name||s==="view:"+this.name||s==="element"||s==="view:element"||s==="node"||s==="view:node"};function mr(){return null}let ge=class extends N(we){document;_children=[];_customProperties=new Map;constructor(e,t){super(),this.document=e,t&&this._insertChild(0,t)}[Symbol.iterator](){return this._children[Symbol.iterator]()}get childCount(){return this._children.length}get isEmpty(){return this.childCount===0}get root(){return this}get parent(){return null}get name(){}get getFillerOffset(){}getCustomProperty(e){return this._customProperties.get(e)}*getCustomProperties(){yield*this._customProperties.entries()}_appendChild(e){return this._insertChild(this.childCount,e)}getChild(e){return this._children[e]}getChildIndex(e){return this._children.indexOf(e)}getChildren(){return this._children[Symbol.iterator]()}_insertChild(e,t){this._fireChange("children",this,{index:e});let n=0;const r=gr(this.document,t);for(const i of r)i.parent!==null&&i._remove(),i.parent=this,this._children.splice(e,0,i),e++,n++;return n}_removeChildren(e,t=1){this._fireChange("children",this,{index:e});for(let n=e;n<e+t;n++)this._children[n].parent=null;return this._children.splice(e,t)}_fireChange(e,t,n){this.fire(`change:${e}`,t,n)}_setCustomProperty(e,t){this._customProperties.set(e,t)}_removeCustomProperty(e){return this._customProperties.delete(e)}};ge.prototype.is=function(s){return s==="documentFragment"||s==="view:documentFragment"};function gr(s,e){return typeof e=="string"?[new x(s,e)]:(le(e)||(e=[e]),Array.from(e).map(t=>typeof t=="string"?new x(s,t):t instanceof Q?new x(s,t.data):t))}class Yn{document;_cloneGroups=new Map;_slotFactory=null;constructor(e){this.document=e}setSelection(...e){this.document.selection._setTo(...e)}setSelectionFocus(e,t){this.document.selection._setFocus(e,t)}createDocumentFragment(e){return new ge(this.document,e)}createText(e){return new x(this.document,e)}createAttributeElement(e,t,n={}){const r=new Me(this.document,e,t);return typeof n.priority=="number"&&(r._priority=n.priority),n.id&&(r._id=n.id),n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createContainerElement(e,t,n={},r={}){let i=null;Tt(n)?r=n:i=n;const o=new Ge(this.document,e,t,i);return r.renderUnsafeAttributes&&o._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),o}createEditableElement(e,t,n={}){const r=new dt(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createEmptyElement(e,t,n={}){const r=new Jt(this.document,e,t);return n.renderUnsafeAttributes&&r._unsafeAttributesToRender.push(...n.renderUnsafeAttributes),r}createUIElement(e,t,n){const r=new mt(this.document,e,t);return n&&(r.render=n),r}createRawElement(e,t,n,r={}){const i=new jt(this.document,e,t);return n&&(i.render=n),r.renderUnsafeAttributes&&i._unsafeAttributesToRender.push(...r.renderUnsafeAttributes),i}setAttribute(e,t,n,r){r!==void 0?r._setAttribute(e,t,n):n._setAttribute(e,t)}removeAttribute(e,t,n){n!==void 0?n._removeAttribute(e,t):t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Tt(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}breakAttributes(e){return e instanceof g?this._breakAttributes(e):this._breakAttributesRange(e)}breakContainer(e){const t=e.parent;if(!t.is("containerElement"))throw new f("view-writer-break-non-container-element",this.document);if(!t.parent)throw new f("view-writer-break-root",this.document);if(e.isAtStart)return g._createBefore(t);if(!e.isAtEnd){const n=t._clone(!1);this.insert(g._createAfter(t),n);const r=new w(e,g._createAt(t,"end")),i=new g(n,0);this.move(r,i)}return g._createAfter(t)}mergeAttributes(e){const t=e.offset,n=e.parent;if(n.is("$text"))return e;if(n.is("attributeElement")&&n.childCount===0){const o=n.parent,a=n.index;return n._remove(),this._removeFromClonedElementsGroup(n),this.mergeAttributes(new g(o,a))}const r=n.getChild(t-1),i=n.getChild(t);if(!r||!i)return e;if(r.is("$text")&&i.is("$text"))return cn(r,i);if(r.is("attributeElement")&&i.is("attributeElement")&&r.isSimilar(i)){const o=r.childCount;return r._appendChild(i.getChildren()),i._remove(),this._removeFromClonedElementsGroup(i),this.mergeAttributes(new g(r,o))}return e}mergeContainers(e){const t=e.nodeBefore,n=e.nodeAfter;if(!t||!n||!t.is("containerElement")||!n.is("containerElement"))throw new f("view-writer-merge-containers-invalid-position",this.document);const r=t.getChild(t.childCount-1),i=r instanceof x?g._createAt(r,"end"):g._createAt(t,"end");return this.move(w._createIn(n),g._createAt(t,"end")),this.remove(w._createOn(n)),i}insert(e,t){t=le(t)?[...t]:[t],Qn(t,this.document);const n=t.reduce((o,a)=>{const l=o[o.length-1],c=!a.is("uiElement");return!l||l.breakAttributes!=c?o.push({breakAttributes:c,nodes:[a]}):l.nodes.push(a),o},[]);let r=null,i=e;for(const{nodes:o,breakAttributes:a}of n){const l=this._insertNodes(i,o,a);r||(r=l.start),i=l.end}return r?new w(r,i):new w(e)}remove(e){const t=e instanceof w?e:w._createOn(e);if(Fe(t,this.document),t.isCollapsed)return new ge(this.document);const{start:n,end:r}=this._breakAttributesRange(t,!0),i=n.parent,o=r.offset-n.offset,a=i._removeChildren(n.offset,o);for(const c of a)this._removeFromClonedElementsGroup(c);const l=this.mergeAttributes(n);return t.start=l,t.end=l.clone(),new ge(this.document,a)}clear(e,t){Fe(e,this.document);const n=e.getWalker({direction:"backward",ignoreElementEnd:!0});for(const r of n){const i=r.item;let o;if(i.is("element")&&t.isSimilar(i))o=w._createOn(i);else if(!r.nextPosition.isAfter(e.start)&&i.is("$textProxy")){const a=i.getAncestors().find(l=>l.is("element")&&t.isSimilar(l));a&&(o=w._createIn(a))}o&&(o.end.isAfter(e.end)&&(o.end=e.end),o.start.isBefore(e.start)&&(o.start=e.start),this.remove(o))}}move(e,t){let n;if(t.isAfter(e.end)){t=this._breakAttributes(t,!0);const r=t.parent,i=r.childCount;e=this._breakAttributesRange(e,!0),n=this.remove(e),t.offset+=r.childCount-i}else n=this.remove(e);return this.insert(t,n)}wrap(e,t){if(!(t instanceof Me))throw new f("view-writer-wrap-invalid-attribute",this.document);if(Fe(e,this.document),e.isCollapsed){let n=e.start;n.parent.is("element")&&!pr(n.parent)&&(n=n.getLastMatchingPosition(i=>i.item.is("uiElement"))),n=this._wrapPosition(n,t);const r=this.document.selection;return r.isCollapsed&&r.getFirstPosition().isEqual(e.start)&&this.setSelection(n),new w(n)}else return this._wrapRange(e,t)}unwrap(e,t){if(!(t instanceof Me))throw new f("view-writer-unwrap-invalid-attribute",this.document);if(Fe(e,this.document),e.isCollapsed)return e;const{start:n,end:r}=this._breakAttributesRange(e,!0),i=n.parent,o=this._unwrapChildren(i,n.offset,r.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}rename(e,t){const n=new Ge(this.document,e,t.getAttributes());return this.insert(g._createAfter(t),n),this.move(w._createIn(t),g._createAt(n,0)),this.remove(w._createOn(t)),n}clearClonedElementsGroup(e){this._cloneGroups.delete(e)}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Z(...e)}createSlot(e="children"){if(!this._slotFactory)throw new f("view-writer-invalid-create-slot-context",this.document);return this._slotFactory(this,e)}_registerSlotFactory(e){this._slotFactory=e}_clearSlotFactory(){this._slotFactory=null}_insertNodes(e,t,n){let r;if(n?r=It(e):r=e.parent.is("$text")?e.parent.parent:e.parent,!r)throw new f("view-writer-invalid-position-container",this.document);let i;n?i=this._breakAttributes(e,!0):i=e.parent.is("$text")?kt(e):e;const o=r._insertChild(i.offset,t);for(const h of t)this._addToClonedElementsGroup(h);const a=i.getShiftedBy(o),l=this.mergeAttributes(i);l.isEqual(i)||a.offset--;const c=this.mergeAttributes(a);return new w(l,c)}_wrapChildren(e,t,n,r){let i=t;const o=[];for(;i<n;){const l=e.getChild(i),c=l.is("$text"),h=l.is("attributeElement");if(h&&l._canMergeAttributesFrom(r))l._mergeAttributesFrom(r),o.push(new g(e,i));else if(c||!h||_r(r,l)){const d=r._clone();l._remove(),d._appendChild(l),e._insertChild(i,d),this._addToClonedElementsGroup(d),o.push(new g(e,i))}else this._wrapChildren(l,0,l.childCount,r);i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_unwrapChildren(e,t,n,r){let i=t;const o=[];for(;i<n;){const l=e.getChild(i);if(!l.is("attributeElement")){i++;continue}if(l.isSimilar(r)){const c=l.getChildren(),h=l.childCount;l._remove(),e._insertChild(i,c),this._removeFromClonedElementsGroup(l),o.push(new g(e,i),new g(e,i+h)),i+=h,n+=h-1;continue}if(l._canSubtractAttributesOf(r)){l._subtractAttributesOf(r),o.push(new g(e,i),new g(e,i+1)),i++;continue}this._unwrapChildren(l,0,l.childCount,r),i++}let a=0;for(const l of o){if(l.offset-=a,l.offset==t||l.offset==n)continue;this.mergeAttributes(l).isEqual(l)||(a++,n--)}return w._createFromParentsAndOffsets(e,t,e,n)}_wrapRange(e,t){const{start:n,end:r}=this._breakAttributesRange(e,!0),i=n.parent,o=this._wrapChildren(i,n.offset,r.offset,t),a=this.mergeAttributes(o.start);a.isEqual(o.start)||o.end.offset--;const l=this.mergeAttributes(o.end);return new w(a,l)}_wrapPosition(e,t){if(t.isSimilar(e.parent))return ln(e.clone());e.parent.is("$text")&&(e=kt(e));const n=this.createAttributeElement("_wrapPosition-fake-element");n._priority=Number.POSITIVE_INFINITY,n.isSimilar=()=>!1,e.parent._insertChild(e.offset,n);const r=new w(e,e.getShiftedBy(1));this.wrap(r,t);const i=new g(n.parent,n.index);n._remove();const o=i.nodeBefore,a=i.nodeAfter;return o&&o.is("view:$text")&&a&&a.is("view:$text")?cn(o,a):ln(i)}_breakAttributesRange(e,t=!1){const n=e.start,r=e.end;if(Fe(e,this.document),e.isCollapsed){const l=this._breakAttributes(e.start,t);return new w(l,l)}const i=this._breakAttributes(r,t),o=i.parent.childCount,a=this._breakAttributes(n,t);return i.offset+=i.parent.childCount-o,new w(a,i)}_breakAttributes(e,t=!1){const n=e.offset,r=e.parent;if(e.parent.is("emptyElement"))throw new f("view-writer-cannot-break-empty-element",this.document);if(e.parent.is("uiElement"))throw new f("view-writer-cannot-break-ui-element",this.document);if(e.parent.is("rawElement"))throw new f("view-writer-cannot-break-raw-element",this.document);if(!t&&r.is("$text")&&Ft(r.parent)||Ft(r))return e.clone();if(r.is("$text"))return this._breakAttributes(kt(e),t);const i=r.childCount;if(n==i){const o=new g(r.parent,r.index+1);return this._breakAttributes(o,t)}else if(n===0){const o=new g(r.parent,r.index);return this._breakAttributes(o,t)}else{const o=r.index+1,a=r._clone();r.parent._insertChild(o,a),this._addToClonedElementsGroup(a);const l=r.childCount-n,c=r._removeChildren(n,l);a._appendChild(c);const h=new g(r.parent,o);return this._breakAttributes(h,t)}}_addToClonedElementsGroup(e){if(!e.root.is("rootElement"))return;if(e.is("element"))for(const r of e.getChildren())this._addToClonedElementsGroup(r);const t=e.id;if(!t)return;let n=this._cloneGroups.get(t);n||(n=new Set,this._cloneGroups.set(t,n)),n.add(e),e._clonesGroup=n}_removeFromClonedElementsGroup(e){if(e.is("element"))for(const r of e.getChildren())this._removeFromClonedElementsGroup(r);const t=e.id;if(!t)return;const n=this._cloneGroups.get(t);n&&n.delete(e)}}function pr(s){return Array.from(s.getChildren()).some(e=>!e.is("uiElement"))}function It(s){let e=s.parent;for(;!Ft(e);){if(!e)return;e=e.parent}return e}function _r(s,e){return s.priority<e.priority?!0:s.priority>e.priority?!1:s.getIdentity()<e.getIdentity()}function ln(s){const e=s.nodeBefore;if(e&&e.is("$text"))return new g(e,e.data.length);const t=s.nodeAfter;return t&&t.is("$text")?new g(t,0):s}function kt(s){if(s.offset==s.parent.data.length)return new g(s.parent.parent,s.parent.index+1);if(s.offset===0)return new g(s.parent.parent,s.parent.index);const e=s.parent.data.slice(s.offset);return s.parent._data=s.parent.data.slice(0,s.offset),s.parent.parent._insertChild(s.parent.index+1,new x(s.root.document,e)),new g(s.parent.parent,s.parent.index+1)}function cn(s,e){const t=s.data.length;return s._data+=e.data,e._remove(),new g(s,t)}const wr=[x,Me,Ge,Jt,jt,mt];function Qn(s,e){for(const t of s){if(!wr.some(n=>t instanceof n))throw new f("view-writer-insert-invalid-node-type",e);t.is("$text")||Qn(t.getChildren(),e)}}function Ft(s){return s&&(s.is("containerElement")||s.is("documentFragment"))}function Fe(s,e){const t=It(s.start),n=It(s.end);if(!t||!n||t!==n)throw new f("view-writer-invalid-range-container",e)}const Zn=s=>s.createTextNode(" "),es=s=>{const e=s.createElement("span");return e.dataset.ckeFiller="true",e.innerText=" ",e},ts=s=>{const e=s.createElement("br");return e.dataset.ckeFiller="true",e},L=7,He="⁠".repeat(L);function D(s){return typeof s=="string"?s.substr(0,L)===He:E(s)&&s.data.substr(0,L)===He}function Re(s){return s.data.length==L&&D(s)}function hn(s){const e=typeof s=="string"?s:s.data;return D(s)?e.slice(L):e}function br(s){s.document.on("arrowKey",yr,{priority:"low"})}function yr(s,e){if(e.keyCode==de.arrowleft){const t=e.domTarget.ownerDocument.defaultView.getSelection();if(t.rangeCount==1&&t.getRangeAt(0).collapsed){const n=t.getRangeAt(0).startContainer,r=t.getRangeAt(0).startOffset;D(n)&&r<=L&&t.collapse(n,0)}}}class vr extends U(){domDocuments=new Set;domConverter;markedAttributes=new Set;markedChildren=new Set;markedTexts=new Set;selection;_inlineFiller=null;_fakeSelectionContainer=null;constructor(e,t){super(),this.domConverter=e,this.selection=t,this.set("isFocused",!1),this.set("isSelecting",!1),this.set("isComposing",!1),M.isBlink&&!M.isAndroid&&this.on("change:isSelecting",()=>{this.isSelecting||this.render()})}markToSync(e,t){if(e==="text")this.domConverter.mapViewToDom(t.parent)&&this.markedTexts.add(t);else{if(!this.domConverter.mapViewToDom(t))return;if(e==="attributes")this.markedAttributes.add(t);else if(e==="children")this.markedChildren.add(t);else throw new f("view-renderer-unknown-type",this)}}render(){if(this.isComposing&&!M.isAndroid)return;let e=null;const t=M.isBlink&&!M.isAndroid?!this.isSelecting:!0;for(const n of this.markedChildren)this._updateChildrenMappings(n);t?(this._inlineFiller&&!this._isSelectionInInlineFiller()&&this._removeInlineFiller(),this._inlineFiller?e=this._getInlineFillerPosition():this._needsInlineFillerAtSelection()&&(e=this.selection.getFirstPosition(),this.markedChildren.add(e.parent))):this._inlineFiller&&this._inlineFiller.parentNode&&(e=this.domConverter.domPositionToView(this._inlineFiller),e&&e.parent.is("$text")&&(e=g._createBefore(e.parent)));for(const n of this.markedAttributes)this._updateAttrs(n);for(const n of this.markedChildren)this._updateChildren(n,{inlineFillerPosition:e});for(const n of this.markedTexts)!this.markedChildren.has(n.parent)&&this.domConverter.mapViewToDom(n.parent)&&this._updateText(n,{inlineFillerPosition:e});if(t)if(e){const n=this.domConverter.viewPositionToDom(e),r=n.parent.ownerDocument;D(n.parent)?this._inlineFiller=n.parent:this._inlineFiller=un(r,n.parent,n.offset)}else this._inlineFiller=null;this._updateFocus(),this._updateSelection(),this.domConverter._clearTemporaryCustomProperties(),this.markedTexts.clear(),this.markedAttributes.clear(),this.markedChildren.clear()}_updateChildrenMappings(e){const t=this.domConverter.mapViewToDom(e);if(!t)return;const n=Array.from(t.childNodes),r=Array.from(this.domConverter.viewChildrenToDom(e,{withChildren:!1})),i=this._diffNodeLists(n,r),o=this._findUpdateActions(i,n,r,Cr);if(o.indexOf("update")!==-1){const a={equal:0,insert:0,delete:0};for(const l of o)if(l==="update"){const c=a.equal+a.insert,h=a.equal+a.delete,d=e.getChild(c);d&&!d.is("uiElement")&&!d.is("rawElement")&&this._updateElementMappings(d,n[h]),tn(r[c]),a.equal++}else a[l]++}}_updateElementMappings(e,t){this.domConverter.unbindDomElement(t),this.domConverter.bindElements(t,e),this.markedChildren.add(e),this.markedAttributes.add(e)}_getInlineFillerPosition(){const e=this.selection.getFirstPosition();return e.parent.is("$text")?g._createBefore(e.parent):e}_isSelectionInInlineFiller(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=this.domConverter.viewPositionToDom(e);return!!(t&&E(t.parent)&&D(t.parent))}_removeInlineFiller(){const e=this._inlineFiller;if(!D(e))throw new f("view-renderer-filler-was-lost",this);Re(e)?e.remove():e.data=e.data.substr(L),this._inlineFiller=null}_needsInlineFillerAtSelection(){if(this.selection.rangeCount!=1||!this.selection.isCollapsed)return!1;const e=this.selection.getFirstPosition(),t=e.parent,n=e.offset;if(!this.domConverter.mapViewToDom(t.root)||!t.is("element")||!Pr(t))return!1;const r=e.nodeBefore,i=e.nodeAfter;return!(r instanceof x||i instanceof x||n===t.getFillerOffset()&&(!r||!r.is("element","br"))||M.isAndroid&&(r||i))}_updateText(e,t){const n=this.domConverter.findCorrespondingDomText(e);let i=this.domConverter.viewToDom(e).data;const o=t.inlineFillerPosition;o&&o.parent==e.parent&&o.offset==e.index&&(i=He+i),this._updateTextNode(n,i)}_updateAttrs(e){const t=this.domConverter.mapViewToDom(e);if(t){for(const n of Array.from(t.attributes)){const r=n.name;e.hasAttribute(r)||this.domConverter.removeDomElementAttribute(t,r)}for(const n of e.getAttributeKeys())this.domConverter.setDomElementAttribute(t,n,e.getAttribute(n),e)}}_updateChildren(e,t){const n=this.domConverter.mapViewToDom(e);if(!n)return;if(M.isAndroid){let d=null;for(const p of Array.from(n.childNodes)){if(d&&E(d)&&E(p)){n.normalize();break}d=p}}const r=t.inlineFillerPosition,i=n.childNodes,o=Array.from(this.domConverter.viewChildrenToDom(e,{bind:!0}));r&&r.parent===e&&un(n.ownerDocument,o,r.offset);const a=this._diffNodeLists(i,o),l=this._findUpdateActions(a,i,o,kr);let c=0;const h=new Set;for(const d of l)d==="delete"?(h.add(i[c]),tn(i[c])):(d==="equal"||d==="update")&&c++;c=0;for(const d of l)d==="insert"?(zn(n,c,o[c]),c++):d==="update"?(this._updateTextNode(i[c],o[c].data),c++):d==="equal"&&(this._markDescendantTextToSync(this.domConverter.domToView(o[c])),c++);for(const d of h)d.parentNode||this.domConverter.unbindDomElement(d)}_diffNodeLists(e,t){return e=Er(e,this._fakeSelectionContainer),gt(e,t,Ar.bind(null,this.domConverter))}_findUpdateActions(e,t,n,r){if(e.indexOf("insert")===-1||e.indexOf("delete")===-1)return e;let i=[],o=[],a=[];const l={equal:0,insert:0,delete:0};for(const c of e)c==="insert"?a.push(n[l.equal+l.insert]):c==="delete"?o.push(t[l.equal+l.delete]):(i=i.concat(gt(o,a,r).map(h=>h==="equal"?"update":h)),i.push("equal"),o=[],a=[]),l[c]++;return i.concat(gt(o,a,r).map(c=>c==="equal"?"update":c))}_updateTextNode(e,t){const n=e.data;n!=t&&(M.isAndroid&&this.isComposing&&n.replace(/\u00A0/g," ")==t.replace(/\u00A0/g," ")||this._updateTextNodeInternal(e,t))}_updateTextNodeInternal(e,t){const n=Ls(e.data,t);for(const r of n)r.type==="insert"?e.insertData(r.index,r.values.join("")):e.deleteData(r.index,r.howMany)}_markDescendantTextToSync(e){if(e){if(e.is("$text"))this.markedTexts.add(e);else if(e.is("element"))for(const t of e.getChildren())this._markDescendantTextToSync(t)}}_updateSelection(){if(M.isBlink&&!M.isAndroid&&this.isSelecting&&!this.markedChildren.size)return;if(this.selection.rangeCount===0){this._removeDomSelection(),this._removeFakeSelection();return}const e=this.domConverter.mapViewToDom(this.selection.editableElement);if(!this.isFocused||!e){!this.selection.isFake&&this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected&&this._removeFakeSelection();return}this.selection.isFake?this._updateFakeSelection(e):this._fakeSelectionContainer&&this._fakeSelectionContainer.isConnected?(this._removeFakeSelection(),this._updateDomSelection(e)):this.isComposing&&M.isAndroid||this._updateDomSelection(e)}_updateFakeSelection(e){const t=e.ownerDocument;this._fakeSelectionContainer||(this._fakeSelectionContainer=Rr(t));const n=this._fakeSelectionContainer;if(this.domConverter.bindFakeSelection(n,this.selection),!this._fakeSelectionNeedsUpdate(e))return;(!n.parentElement||n.parentElement!=e)&&e.appendChild(n),n.textContent=this.selection.fakeSelectionLabel||" ";const r=t.getSelection(),i=t.createRange();r.removeAllRanges(),i.selectNodeContents(n),r.addRange(i)}_updateDomSelection(e){const t=e.ownerDocument.defaultView.getSelection();if(!this._domSelectionNeedsUpdate(t))return;const n=this.domConverter.viewPositionToDom(this.selection.anchor),r=this.domConverter.viewPositionToDom(this.selection.focus);t.setBaseAndExtent(n.parent,n.offset,r.parent,r.offset),M.isGecko&&Sr(r,t)}_domSelectionNeedsUpdate(e){if(!this.domConverter.isDomSelectionCorrect(e))return!0;const t=e&&this.domConverter.domSelectionToView(e);return!(t&&this.selection.isEqual(t)||!this.selection.isCollapsed&&this.selection.isSimilar(t))}_fakeSelectionNeedsUpdate(e){const t=this._fakeSelectionContainer,n=e.ownerDocument.getSelection();return!t||t.parentElement!==e||n.anchorNode!==t&&!t.contains(n.anchorNode)?!0:t.textContent!==this.selection.fakeSelectionLabel}_removeDomSelection(){for(const e of this.domDocuments){const t=e.getSelection();if(t.rangeCount){const n=e.activeElement,r=this.domConverter.mapDomToView(n);n&&r&&t.removeAllRanges()}}}_removeFakeSelection(){const e=this._fakeSelectionContainer;e&&e.remove()}_updateFocus(){if(this.isFocused){const e=this.selection.editableElement;e&&this.domConverter.focus(e)}}}function Pr(s){if(s.getAttribute("contenteditable")=="false")return!1;const e=s.findAncestor(t=>t.hasAttribute("contenteditable"));return!e||e.getAttribute("contenteditable")=="true"}function un(s,e,t){const n=e instanceof Array?e:e.childNodes,r=n[t];if(E(r))return r.data=He+r.data,r;{const i=s.createTextNode(He);return Array.isArray(e)?n.splice(t,0,i):zn(e,t,i),i}}function Cr(s,e){return ot(s)&&ot(e)&&!E(s)&&!E(e)&&!Le(s)&&!Le(e)&&s.tagName.toLowerCase()===e.tagName.toLowerCase()}function kr(s,e){return ot(s)&&ot(e)&&E(s)&&E(e)}function Ar(s,e,t){return e===t?!0:E(e)&&E(t)?e.data===t.data:!!(s.isBlockFiller(e)&&s.isBlockFiller(t))}function Sr(s,e){let t=s.parent,n=s.offset;if(E(t)&&Re(t)&&(n=Ee(t)+1,t=t.parentNode),t.nodeType!=Node.ELEMENT_NODE||n!=t.childNodes.length-1)return;const r=t.childNodes[n];r&&r.tagName=="BR"&&e.addRange(e.getRangeAt(0))}function Er(s,e){const t=Array.from(s);return t.length==0||!e||t[t.length-1]==e&&t.pop(),t}function Rr(s){const e=s.createElement("div");return e.className="ck-fake-selection-container",Object.assign(e.style,{position:"fixed",top:0,left:"-9999px",width:"42px"}),e.textContent=" ",e}const Tr=ts(re.document),Mr=Zn(re.document),xr=es(re.document),tt="data-ck-unsafe-attribute-",fn="data-ck-unsafe-element";class ns{document;renderingMode;blockFillerMode;preElements;blockElements;inlineObjectElements;unsafeElements;_domDocument;_domToViewMapping=new WeakMap;_viewToDomMapping=new WeakMap;_fakeSelectionMapping=new WeakMap;_rawContentElementMatcher=new je;_inlineObjectElementMatcher=new je;_elementsWithTemporaryCustomProperties=new Set;constructor(e,{blockFillerMode:t,renderingMode:n="editing"}={}){this.document=e,this.renderingMode=n,this.blockFillerMode=t||(n==="editing"?"br":"nbsp"),this.preElements=["pre","textarea"],this.blockElements=["address","article","aside","blockquote","caption","center","dd","details","dir","div","dl","dt","fieldset","figcaption","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","legend","li","main","menu","nav","ol","p","pre","section","summary","table","tbody","td","tfoot","th","thead","tr","ul"],this.inlineObjectElements=["object","iframe","input","button","textarea","select","option","video","embed","audio","img","canvas"],this.unsafeElements=["script","style"],this._domDocument=this.renderingMode==="editing"?re.document:re.document.implementation.createHTMLDocument("")}get domDocument(){return this._domDocument}bindFakeSelection(e,t){this._fakeSelectionMapping.set(e,new Z(t))}fakeSelectionToView(e){return this._fakeSelectionMapping.get(e)}bindElements(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}unbindDomElement(e){const t=this._domToViewMapping.get(e);if(t){this._domToViewMapping.delete(e),this._viewToDomMapping.delete(t);for(const n of e.children)this.unbindDomElement(n)}}bindDocumentFragments(e,t){this._domToViewMapping.set(e,t),this._viewToDomMapping.set(t,e)}shouldRenderAttribute(e,t,n){return this.renderingMode==="data"?!0:(e=e.toLowerCase(),e.startsWith("on")||e==="srcdoc"&&t.match(/\bon\S+\s*=|javascript:|<\s*\/*script/i)?!1:n==="img"&&(e==="src"||e==="srcset")||n==="source"&&e==="srcset"?!0:!t.match(/^\s*(javascript:|data:(image\/svg|text\/x?html))/i))}setContentOf(e,t){if(this.renderingMode==="data"){e.innerHTML=t;return}const n=new DOMParser().parseFromString(t,"text/html"),r=n.createDocumentFragment(),i=n.body.childNodes;for(;i.length>0;)r.appendChild(i[0]);const o=n.createTreeWalker(r,NodeFilter.SHOW_ELEMENT),a=[];let l;for(;l=o.nextNode();)a.push(l);for(const c of a){for(const d of c.getAttributeNames())this.setDomElementAttribute(c,d,c.getAttribute(d));const h=c.tagName.toLowerCase();this._shouldRenameElement(h)&&(pn(h),c.replaceWith(this._createReplacementDomElement(h,c)))}for(;e.firstChild;)e.firstChild.remove();e.append(r)}viewToDom(e,t={}){if(e.is("$text")){const n=this._processDataFromViewText(e);return this._domDocument.createTextNode(n)}else{const n=e;if(this.mapViewToDom(n))if(n.getCustomProperty("editingPipeline:doNotReuseOnce"))this._elementsWithTemporaryCustomProperties.add(n);else return this.mapViewToDom(n);let r;if(n.is("documentFragment"))r=this._domDocument.createDocumentFragment(),t.bind&&this.bindDocumentFragments(r,n);else{if(n.is("uiElement"))return n.name==="$comment"?r=this._domDocument.createComment(n.getCustomProperty("$rawContent")):r=n.render(this._domDocument,this),t.bind&&this.bindElements(r,n),r;this._shouldRenameElement(n.name)?(pn(n.name),r=this._createReplacementDomElement(n.name)):n.hasAttribute("xmlns")?r=this._domDocument.createElementNS(n.getAttribute("xmlns"),n.name):r=this._domDocument.createElement(n.name),n.is("rawElement")&&n.render(r,this),t.bind&&this.bindElements(r,n);for(const i of n.getAttributeKeys())this.setDomElementAttribute(r,i,n.getAttribute(i),n)}if(t.withChildren!==!1)for(const i of this.viewChildrenToDom(n,t))r instanceof HTMLTemplateElement?r.content.appendChild(i):r.appendChild(i);return r}}setDomElementAttribute(e,t,n,r){const i=this.shouldRenderAttribute(t,n,e.tagName.toLowerCase())||r&&r.shouldRenderUnsafeAttribute(t);if(i||W("domconverter-unsafe-attribute-detected",{domElement:e,key:t,value:n}),!Bs(t)){W("domconverter-invalid-attribute-detected",{domElement:e,key:t,value:n});return}e.hasAttribute(t)&&!i?e.removeAttribute(t):e.hasAttribute(tt+t)&&i&&e.removeAttribute(tt+t),e.setAttribute(i?t:tt+t,n)}removeDomElementAttribute(e,t){t!=fn&&(e.removeAttribute(t),e.removeAttribute(tt+t))}*viewChildrenToDom(e,t={}){const n=e.getFillerOffset&&e.getFillerOffset();let r=0;for(const i of e.getChildren()){n===r&&(yield this._getBlockFiller());const o=i.is("element")&&!!i.getCustomProperty("dataPipeline:transparentRendering")&&!Wt(i.getAttributes());if(o&&this.renderingMode=="data")if(i.is("rawElement")){const a=this._domDocument.createElement(i.name);i.render(a,this),yield*[...a.childNodes]}else yield*this.viewChildrenToDom(i,t);else o&&W("domconverter-transparent-rendering-unsupported-in-editing-pipeline",{viewElement:i}),yield this.viewToDom(i,t);r++}n===r&&(yield this._getBlockFiller())}viewRangeToDom(e){const t=this.viewPositionToDom(e.start),n=this.viewPositionToDom(e.end),r=this._domDocument.createRange();return r.setStart(t.parent,t.offset),r.setEnd(n.parent,n.offset),r}viewPositionToDom(e){const t=e.parent;if(t.is("$text")){const n=this.findCorrespondingDomText(t);if(!n)return null;let r=e.offset;return D(n)&&(r+=L),n.data&&r>n.data.length&&(r=n.data.length),{parent:n,offset:r}}else{let n,r,i;if(e.offset===0){if(n=this.mapViewToDom(t),!n)return null;i=n.childNodes[0]}else{const a=e.nodeBefore;if(r=a.is("$text")?this.findCorrespondingDomText(a):this.mapViewToDom(a),!r)return null;n=r.parentNode,i=r.nextSibling}if(E(i)&&D(i))return{parent:i,offset:L};const o=r?Ee(r)+1:0;return{parent:n,offset:o}}}domToView(e,t={}){const n=[],r=this._domToView(e,t,n),i=r.next().value;return!i||(r.next(),this._processDomInlineNodes(null,n,t),this.blockFillerMode=="br"&&mn(i))||i.is("$text")&&i.data.length==0?null:i}*domChildrenToView(e,t={},n=[]){let r=[];e instanceof HTMLTemplateElement?r=[...e.content.childNodes]:r=[...e.childNodes];for(let i=0;i<r.length;i++){const o=r[i],a=this._domToView(o,t,n),l=a.next().value;l!==null&&(this._isBlockViewElement(l)&&this._processDomInlineNodes(e,n,t),this.blockFillerMode=="br"&&mn(l)||(yield l),a.next())}this._processDomInlineNodes(e,n,t)}domSelectionToView(e){if(Dr(e))return new Z([]);if(e.rangeCount===1){let r=e.getRangeAt(0).startContainer;E(r)&&(r=r.parentNode);const i=this.fakeSelectionToView(r);if(i)return i}const t=this.isDomSelectionBackward(e),n=[];for(let r=0;r<e.rangeCount;r++){const i=e.getRangeAt(r),o=this.domRangeToView(i);o&&n.push(o)}return new Z(n,{backward:t})}domRangeToView(e){const t=this.domPositionToView(e.startContainer,e.startOffset),n=this.domPositionToView(e.endContainer,e.endOffset);return t&&n?new w(t,n):null}domPositionToView(e,t=0){if(this.isBlockFiller(e))return this.domPositionToView(e.parentNode,Ee(e));const n=this.mapDomToView(e);if(n&&(n.is("uiElement")||n.is("rawElement")))return g._createBefore(n);if(E(e)){if(Re(e))return this.domPositionToView(e.parentNode,Ee(e));const r=this.findCorrespondingViewText(e);let i=t;return r?(D(e)&&(i-=L,i=i<0?0:i),new g(r,i)):null}else{if(t===0){const r=this.mapDomToView(e);if(r)return new g(r,0)}else{const r=e.childNodes[t-1];if(E(r)&&Re(r)||r&&this.isBlockFiller(r))return this.domPositionToView(r.parentNode,Ee(r));const i=E(r)?this.findCorrespondingViewText(r):this.mapDomToView(r);if(i&&i.parent)return new g(i.parent,i.index+1)}return null}}mapDomToView(e){return this.getHostViewElement(e)||this._domToViewMapping.get(e)}findCorrespondingViewText(e){if(Re(e))return null;const t=this.getHostViewElement(e);if(t)return t;const n=e.previousSibling;if(n){if(!this.isElement(n))return null;const r=this.mapDomToView(n);if(r){const i=r.nextSibling;return i instanceof x?i:null}}else{const r=this.mapDomToView(e.parentNode);if(r){const i=r.getChild(0);return i instanceof x?i:null}}return null}mapViewToDom(e){return this._viewToDomMapping.get(e)}findCorrespondingDomText(e){const t=e.previousSibling;return t&&this.mapViewToDom(t)?this.mapViewToDom(t).nextSibling:!t&&e.parent&&this.mapViewToDom(e.parent)?this.mapViewToDom(e.parent).childNodes[0]:null}focus(e){const t=this.mapViewToDom(e);if(!t||t.ownerDocument.activeElement===t)return;const{scrollX:n,scrollY:r}=re.window,i=[];dn(t,o=>{const{scrollLeft:a,scrollTop:l}=o;i.push([a,l])}),t.focus(),dn(t,o=>{const[a,l]=i.shift();o.scrollLeft=a,o.scrollTop=l}),re.window.scrollTo(n,r)}_clearDomSelection(){const e=this.mapViewToDom(this.document.selection.editableElement);if(!e)return;const t=e.ownerDocument.defaultView.getSelection(),n=this.domSelectionToView(t);n&&n.rangeCount>0&&t.removeAllRanges()}isElement(e){return e&&e.nodeType==Node.ELEMENT_NODE}isDocumentFragment(e){return e&&e.nodeType==Node.DOCUMENT_FRAGMENT_NODE}isBlockFiller(e){return this.blockFillerMode=="br"?e.isEqualNode(Tr):gn(e,this.blockElements)?!0:e.isEqualNode(xr)||Or(e,this.blockElements)}isDomSelectionBackward(e){if(e.isCollapsed)return!1;const t=this._domDocument.createRange();try{t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset)}catch{return!1}const n=t.collapsed;return t.detach(),n}getHostViewElement(e){const t=Vs(e);for(t.pop();t.length;){const n=t.pop(),r=this._domToViewMapping.get(n);if(r&&(r.is("uiElement")||r.is("rawElement")))return r}return null}isDomSelectionCorrect(e){return this._isDomSelectionPositionCorrect(e.anchorNode,e.anchorOffset)&&this._isDomSelectionPositionCorrect(e.focusNode,e.focusOffset)}registerRawContentMatcher(e){this._rawContentElementMatcher.add(e)}registerInlineObjectMatcher(e){this._inlineObjectElementMatcher.add(e)}_clearTemporaryCustomProperties(){for(const e of this._elementsWithTemporaryCustomProperties)e._removeCustomProperty("editingPipeline:doNotReuseOnce");this._elementsWithTemporaryCustomProperties.clear()}_getBlockFiller(){switch(this.blockFillerMode){case"nbsp":return Zn(this._domDocument);case"markedNbsp":return es(this._domDocument);case"br":return ts(this._domDocument)}}_isDomSelectionPositionCorrect(e,t){if(E(e)&&D(e)&&t<L||this.isElement(e)&&D(e.childNodes[t]))return!1;const n=this.mapDomToView(e);return!(n&&(n.is("uiElement")||n.is("rawElement")))}*_domToView(e,t,n){if(this.blockFillerMode!="br"&&gn(e,this.blockElements))return null;const r=this.getHostViewElement(e);if(r)return r;if(Le(e)&&t.skipComments)return null;if(E(e)){if(Re(e))return null;{const i=e.data;if(i==="")return null;const o=new x(this.document,i);return n.push(o),o}}else{let i=this.mapDomToView(e);if(i)return this._isInlineObjectElement(i)&&n.push(i),i;if(this.isDocumentFragment(e))i=new ge(this.document),t.bind&&this.bindDocumentFragments(e,i);else{i=this._createViewElement(e,t),t.bind&&this.bindElements(e,i);const a=e.attributes;if(a)for(let l=a.length,c=0;c<l;c++)i._setAttribute(a[c].name,a[c].value);if(this._isViewElementWithRawContent(i,t))return i._setCustomProperty("$rawContent",e.innerHTML),this._isBlockViewElement(i)||n.push(i),i;if(Le(e))return i._setCustomProperty("$rawContent",e.data),i}yield i;const o=[];if(t.withChildren!==!1)for(const a of this.domChildrenToView(e,t,o))i._appendChild(a);if(this._isInlineObjectElement(i))n.push(i),this._processDomInlineNodes(null,o,t);else for(const a of o)n.push(a)}}_processDomInlineNodes(e,t,n){if(!t.length||e&&!this.isDocumentFragment(e)&&!this._isBlockDomElement(e))return;let r=!1;for(let i=0;i<t.length;i++){const o=t[i];if(!o.is("$text")){r=!1;continue}let a,l=!1;if(this._isPreFormatted(o))a=hn(o.data);else{a=o.data.replace(/[ \n\t\r]{1,}/g," "),l=/[^\S\u00A0]/.test(a.charAt(a.length-1));const c=i>0?t[i-1]:null,h=i+1<t.length?t[i+1]:null,d=!c||c.is("element")&&c.name=="br"||r,p=h?!1:!D(o.data);n.withChildren!==!1&&(d&&(a=a.replace(/^ /,"")),p&&(a=a.replace(/ $/,""))),a=hn(a),this.blockFillerMode!="br"&&o.parent&&(Fr(o.parent,a)?(a="",o.parent.parent&&(o.parent.parent._setCustomProperty("$hasBlockFiller",!0),o.parent._remove())):Ir(o.parent,a,this.blockElements)&&(a="",o.parent._setCustomProperty("$hasBlockFiller",!0))),a=a.replace(/ \u00A0/g," ");const _=h&&h.is("element")&&h.name!="br",y=h&&h.is("$text")&&h.data.charAt(0)==" ";(/[ \u00A0]\u00A0$/.test(a)||!h||_||y)&&(a=a.replace(/\u00A0$/," ")),(d||c&&c.is("element")&&c.name!="br")&&(a=a.replace(/^\u00A0/," "))}a.length==0&&o.parent?(o._remove(),t.splice(i,1),i--):(o._data=a,r=l)}t.length=0}_processDataFromViewText(e){let t=e.data;if(this._isPreFormatted(e))return t;if(t.charAt(0)==" "){const n=this._getTouchingInlineViewNode(e,!1);(n&&n.is("$textProxy")&&this._nodeEndsWithSpace(n)||!n)&&(t=" "+t.substr(1))}if(t.charAt(t.length-1)==" "){const n=this._getTouchingInlineViewNode(e,!0),r=n&&n.is("$textProxy")&&n.data.charAt(0)==" ";(t.charAt(t.length-2)==" "||!n||r)&&(t=t.substr(0,t.length-1)+" ")}return t.replace(/ {2}/g,"  ")}_nodeEndsWithSpace(e){if(this._isPreFormatted(e))return!1;const t=this._processDataFromViewText(e);return t.charAt(t.length-1)==" "}_isPreFormatted(e){if(Nr(e,this.preElements))return!0;for(const t of e.getAncestors({parentFirst:!0}))if(!(!t.is("element")||!t.hasStyle("white-space")||t.getStyle("white-space")==="inherit"))return["pre","pre-wrap","break-spaces"].includes(t.getStyle("white-space"));return!1}_getTouchingInlineViewNode(e,t){const n=new me({startPosition:t?g._createAfter(e):g._createBefore(e),direction:t?"forward":"backward"});for(const{item:r}of n){if(r.is("$textProxy"))return r;if(r.is("element")&&r.getCustomProperty("dataPipeline:transparentRendering"))continue;if(r.is("element","br"))return null;if(this._isInlineObjectElement(r))return r;if(r.is("containerElement"))return null}return null}_isBlockDomElement(e){return this.isElement(e)&&this.blockElements.includes(e.tagName.toLowerCase())}_isBlockViewElement(e){return e.is("element")&&this.blockElements.includes(e.name)}_isInlineObjectElement(e){return e.is("element")?e.name=="br"||this.inlineObjectElements.includes(e.name)||!!this._inlineObjectElementMatcher.match(e):!1}_createViewElement(e,t){if(Le(e))return new mt(this.document,"$comment");const n=t.keepOriginalCase?e.tagName:e.tagName.toLowerCase();return new te(this.document,n)}_isViewElementWithRawContent(e,t){return t.withChildren!==!1&&e.is("element")&&!!this._rawContentElementMatcher.match(e)}_shouldRenameElement(e){const t=e.toLowerCase();return this.renderingMode==="editing"&&this.unsafeElements.includes(t)}_createReplacementDomElement(e,t){const n=this._domDocument.createElement("span");if(n.setAttribute(fn,e),t){for(;t.firstChild;)n.appendChild(t.firstChild);for(const r of t.getAttributeNames())n.setAttribute(r,t.getAttribute(r))}return n}}function Nr(s,e){return s.getAncestors().some(t=>t.is("element")&&e.includes(t.name))}function dn(s,e){let t=s;for(;t;)e(t),t=t.parentElement}function Or(s,e){return s.isEqualNode(Mr)&&ss(s,e)&&s.parentNode.childNodes.length===1}function ss(s,e){const t=s.parentNode;return!!t&&!!t.tagName&&e.includes(t.tagName.toLowerCase())}function Ir(s,e,t){return e==" "&&s&&s.is("element")&&s.childCount==1&&t.includes(s.name)}function Fr(s,e){return e==" "&&s&&s.is("element","span")&&s.childCount==1&&s.hasAttribute("data-cke-filler")}function mn(s){return s.is("element","br")&&s.hasAttribute("data-cke-filler")}function gn(s,e){return s.tagName==="BR"&&ss(s,e)&&s.parentNode.childNodes.length===1}function pn(s){s==="script"&&W("domconverter-unsafe-script-element-detected"),s==="style"&&W("domconverter-unsafe-style-element-detected")}function Dr(s){if(!M.isGecko||!s.rangeCount)return!1;const e=s.getRangeAt(0).startContainer;try{Object.prototype.toString.call(e)}catch{return!0}return!1}class xe extends Ds(){view;document;_isEnabled=!1;constructor(e){super(),this.view=e,this.document=e.document}get isEnabled(){return this._isEnabled}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}destroy(){this.disable(),this.stopListening()}checkShouldIgnoreEventFromTarget(e){return e&&e.nodeType===3&&(e=e.parentNode),!e||e.nodeType!==1?!1:e.matches("[data-cke-ignore-events], [data-cke-ignore-events] *")}}class Br{view;document;domEvent;domTarget;constructor(e,t,n){this.view=e,this.document=e.document,this.domEvent=t,this.domTarget=t.target,Js(this,n)}get target(){return this.view.domConverter.mapDomToView(this.domTarget)}preventDefault(){this.domEvent.preventDefault()}stopPropagation(){this.domEvent.stopPropagation()}}class ye extends xe{useCapture=!1;usePassive=!1;observe(e){(typeof this.domEventType=="string"?[this.domEventType]:this.domEventType).forEach(n=>{this.listenTo(e,n,(r,i)=>{this.isEnabled&&!this.checkShouldIgnoreEventFromTarget(i.target)&&this.onDomEvent(i)},{useCapture:this.useCapture,usePassive:this.usePassive})})}stopObserving(e){this.stopListening(e)}fire(e,t,n){this.isEnabled&&this.document.fire(e,new Br(this.view,t,n))}}class Vr extends ye{domEventType=["keydown","keyup"];onDomEvent(e){const t={keyCode:e.keyCode,altKey:e.altKey,ctrlKey:e.ctrlKey,shiftKey:e.shiftKey,metaKey:e.metaKey,get keystroke(){return zs(this)}};this.fire(e.type,e,t)}}class $r extends xe{_fireSelectionChangeDoneDebounced;constructor(e){super(e),this._fireSelectionChangeDoneDebounced=Mt(t=>{this.document.fire("selectionChangeDone",t)},200)}observe(){const e=this.document;e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&n.preventDefault()},{context:"$capture"}),e.on("arrowKey",(t,n)=>{e.selection.isFake&&this.isEnabled&&this._handleSelectionMove(n.keyCode)},{priority:"lowest"})}stopObserving(){}destroy(){super.destroy(),this._fireSelectionChangeDoneDebounced.cancel()}_handleSelectionMove(e){const t=this.document.selection,n=new Z(t.getRanges(),{backward:t.isBackward,fake:!1});(e==de.arrowleft||e==de.arrowup)&&n.setTo(n.getFirstPosition()),(e==de.arrowright||e==de.arrowdown)&&n.setTo(n.getLastPosition());const r={oldSelection:t,newSelection:n,domSelection:null};this.document.fire("selectionChange",r),this._fireSelectionChangeDoneDebounced(r)}}class rs extends xe{domConverter;_config;_domElements;_mutationObserver;constructor(e){super(e),this._config={childList:!0,characterData:!0,subtree:!0},this.domConverter=e.domConverter,this._domElements=new Set,this._mutationObserver=new window.MutationObserver(this._onMutations.bind(this))}flush(){this._onMutations(this._mutationObserver.takeRecords())}observe(e){this._domElements.add(e),this.isEnabled&&this._mutationObserver.observe(e,this._config)}stopObserving(e){if(this._domElements.delete(e),this.isEnabled){this._mutationObserver.disconnect();for(const t of this._domElements)this._mutationObserver.observe(t,this._config)}}enable(){super.enable();for(const e of this._domElements)this._mutationObserver.observe(e,this._config)}disable(){super.disable(),this._mutationObserver.disconnect()}destroy(){super.destroy(),this._mutationObserver.disconnect()}_onMutations(e){if(e.length===0)return;const t=this.domConverter,n=new Set,r=new Set;for(const o of e){const a=t.mapDomToView(o.target);a&&(a.is("uiElement")||a.is("rawElement")||o.type==="childList"&&!this._isBogusBrMutation(o)&&r.add(a))}for(const o of e){const a=t.mapDomToView(o.target);if(!(a&&(a.is("uiElement")||a.is("rawElement")))&&o.type==="characterData"){const l=t.findCorrespondingViewText(o.target);l&&!r.has(l.parent)?n.add(l):!l&&D(o.target)&&r.add(t.mapDomToView(o.target.parentNode))}}const i=[];for(const o of n)i.push({type:"text",node:o});for(const o of r){const a=t.mapViewToDom(o),l=Array.from(o.getChildren()),c=Array.from(t.domChildrenToView(a,{withChildren:!1}));Gs(l,c,Lr)||i.push({type:"children",node:o})}i.length&&this.document.fire("mutations",{mutations:i})}_isBogusBrMutation(e){let t=null;return e.nextSibling===null&&e.removedNodes.length===0&&e.addedNodes.length==1&&(t=this.domConverter.domToView(e.addedNodes[0],{withChildren:!1})),t&&t.is("element","br")}}function Lr(s,e){if(!Array.isArray(s))return s===e?!0:s.is("$text")&&e.is("$text")?s.data===e.data:!1}class Dt extends ye{_renderTimeoutId=null;_isFocusChanging=!1;domEventType=["focus","blur"];constructor(e){super(e),this.useCapture=!0;const t=this.document;t.on("focus",()=>this._handleFocus()),t.on("blur",(n,r)=>this._handleBlur(r)),t.on("beforeinput",()=>{t.isFocused||this._handleFocus()},{priority:"highest"})}flush(){this._isFocusChanging&&(this._isFocusChanging=!1,this.document.isFocused=!0)}onDomEvent(e){this.fire(e.type,e)}destroy(){this._clearTimeout(),super.destroy()}_handleFocus(){this._clearTimeout(),this._isFocusChanging=!0,this._renderTimeoutId=setTimeout(()=>{this._renderTimeoutId=null,this.flush(),this.view.change(()=>{})},50)}_handleBlur(e){const t=this.document.selection.editableElement;(t===null||t===e.target)&&(this.document.isFocused=!1,this._isFocusChanging=!1,this.view.change(()=>{}))}_clearTimeout(){this._renderTimeoutId&&(clearTimeout(this._renderTimeoutId),this._renderTimeoutId=null)}}class Wr extends xe{mutationObserver;focusObserver;selection;domConverter;_documents=new WeakSet;_fireSelectionChangeDoneDebounced;_clearInfiniteLoopInterval;_documentIsSelectingInactivityTimeoutDebounced;_loopbackCounter=0;_pendingSelectionChange=new Set;constructor(e){super(e),this.mutationObserver=e.getObserver(rs),this.focusObserver=e.getObserver(Dt),this.selection=this.document.selection,this.domConverter=e.domConverter,this._fireSelectionChangeDoneDebounced=Mt(t=>{this.document.fire("selectionChangeDone",t)},200),this._clearInfiniteLoopInterval=setInterval(()=>this._clearInfiniteLoop(),1e3),this._documentIsSelectingInactivityTimeoutDebounced=Mt(()=>this.document.isSelecting=!1,5e3),this.view.document.on("change:isFocused",(t,n,r)=>{if(r&&this._pendingSelectionChange.size){for(const i of Array.from(this._pendingSelectionChange))this._handleSelectionChange(i);this._pendingSelectionChange.clear()}})}observe(e){const t=e.ownerDocument,n=()=>{this.document.isSelecting=!0,this._documentIsSelectingInactivityTimeoutDebounced()},r=()=>{this.document.isSelecting&&(this._handleSelectionChange(t),this.document.isSelecting=!1,this._documentIsSelectingInactivityTimeoutDebounced.cancel())};this.listenTo(e,"selectstart",n,{priority:"highest"}),this.listenTo(e,"keydown",r,{priority:"highest",useCapture:!0}),this.listenTo(e,"keyup",r,{priority:"highest",useCapture:!0}),!this._documents.has(t)&&(this.listenTo(t,"mouseup",r,{priority:"highest",useCapture:!0}),this.listenTo(t,"selectionchange",()=>{this.document.isComposing&&!M.isAndroid||(this._handleSelectionChange(t),this._documentIsSelectingInactivityTimeoutDebounced())}),this.listenTo(this.view.document,"compositionstart",()=>{this._handleSelectionChange(t)},{priority:"lowest"}),this._documents.add(t))}stopObserving(e){this.stopListening(e)}destroy(){super.destroy(),clearInterval(this._clearInfiniteLoopInterval),this._fireSelectionChangeDoneDebounced.cancel(),this._documentIsSelectingInactivityTimeoutDebounced.cancel()}_reportInfiniteLoop(){}_handleSelectionChange(e){if(!this.isEnabled)return;const t=e.defaultView.getSelection();if(this.checkShouldIgnoreEventFromTarget(t.anchorNode))return;this.mutationObserver.flush();const n=this.domConverter.domSelectionToView(t);if(n.rangeCount==0){this.view.hasDomSelection=!1;return}if(this.view.hasDomSelection=!0,this.focusObserver.flush(),!this.view.document.isFocused&&!this.view.document.isReadOnly){this._pendingSelectionChange.add(e);return}if(this._pendingSelectionChange.delete(e),!(this.selection.isEqual(n)&&this.domConverter.isDomSelectionCorrect(t))){if(++this._loopbackCounter>60){this._reportInfiniteLoop();return}if(this.selection.isSimilar(n))this.view.forceRender();else{const r={oldSelection:this.selection,newSelection:n,domSelection:t};this.document.fire("selectionChange",r),this._fireSelectionChangeDoneDebounced(r)}}}_clearInfiniteLoop(){this._loopbackCounter=0}}class qr extends ye{domEventType=["compositionstart","compositionupdate","compositionend"];constructor(e){super(e);const t=this.document;t.on("compositionstart",()=>{t.isComposing=!0}),t.on("compositionend",()=>{t.isComposing=!1})}onDomEvent(e){this.fire(e.type,e,{data:e.data})}}/**
8
8
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
9
9
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
10
- */class Gr{constructor(t,e={}){c(this,"_files");c(this,"_native");this._files=e.cacheFiles?bn(t):null,this._native=t}get files(){return this._files||(this._files=bn(this._native)),this._files}get types(){return this._native.types}getData(t){return this._native.getData(t)}setData(t,e){this._native.setData(t,e)}set effectAllowed(t){this._native.effectAllowed=t}get effectAllowed(){return this._native.effectAllowed}set dropEffect(t){this._native.dropEffect=t}get dropEffect(){return this._native.dropEffect}setDragImage(t,e,n){this._native.setDragImage(t,e,n)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function bn(r){const t=Array.from(r.files||[]),e=Array.from(r.items||[]);return t.length?t:e.filter(n=>n.kind==="file").map(n=>n.getAsFile())}class Hr extends Pe{constructor(){super(...arguments);c(this,"domEventType","beforeinput")}onDomEvent(e){const n=e.getTargetRanges(),s=this.view,i=s.document;let o=null,a=null,l=[];if(e.dataTransfer&&(o=new Gr(e.dataTransfer)),e.data!==null?a=e.data:o&&(a=o.getData("text/plain")),i.selection.isFake)l=Array.from(i.selection.getRanges()),e.preventDefault();else if(n.length)l=n.map(h=>{let u=s.domConverter.domPositionToView(h.startContainer,h.startOffset);const m=s.domConverter.domPositionToView(h.endContainer,h.endOffset);if(u&&D(h.startContainer)&&h.startOffset<W){e.preventDefault();let p=W-h.startOffset;u=u.getLastMatchingPosition(w=>!!(w.item.is("attributeElement")||w.item.is("uiElement")||w.item.is("$textProxy")&&p--),{direction:"backward",singleCharacters:!0})}if(Kr(h.endContainer,h.endOffset)&&e.preventDefault(),u)return s.createRange(u,m);if(m)return s.createRange(m)}).filter(h=>!!h);else if(x.isAndroid){const h=e.target.ownerDocument.defaultView.getSelection();l=Array.from(s.domConverter.domSelectionToView(h).getRanges())}if(x.isAndroid&&e.inputType=="insertCompositionText"&&a&&a.endsWith(`
11
- `)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[s.createRange(l[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&a&&a.includes(`
12
- `)){const h=a.split(/\n{1,2}/g);let u=l;e.preventDefault();for(let m=0;m<h.length;m++){const p=h[m];p!=""&&(this.fire(e.type,e,{data:p,dataTransfer:o,targetRanges:u,inputType:e.inputType,isComposing:e.isComposing}),u=[i.selection.getFirstRange()]),m+1<h.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:u}),u=[i.selection.getFirstRange()])}return}this.fire(e.type,e,{data:a,dataTransfer:o,targetRanges:l,inputType:e.inputType,isComposing:e.isComposing})}}function Kr(r,t){for(;r.parentNode;){if(R(r)){if(t!=r.data.length)return!1}else if(t!=r.childNodes.length)return!1;if(t=Te(r)+1,r=r.parentNode,t<r.childNodes.length&&D(r.childNodes[t]))return!0}return!1}class Xr extends Ne{constructor(t){super(t),this.document.on("keydown",(e,n)=>{if(this.isEnabled&&Js(n.keyCode)){const s=new jt(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(s,n),s.stop.called&&e.stop()}})}observe(){}stopObserving(){}}class Yr extends Ne{constructor(t){super(t);const e=this.document;e.on("keydown",(n,s)=>{if(!this.isEnabled||s.keyCode!=me.tab||s.ctrlKey)return;const i=new jt(e,"tab",e.selection.getFirstRange());e.fire(i,s),i.stop.called&&n.stop()})}observe(){}stopObserving(){}}class Qr extends J(){constructor(e){super();c(this,"document");c(this,"domConverter");c(this,"domRoots",new Map);c(this,"_renderer");c(this,"_initialDomRootAttributes",new WeakMap);c(this,"_observers",new Map);c(this,"_writer");c(this,"_ongoingChange",!1);c(this,"_postFixersInProgress",!1);c(this,"_renderingDisabled",!1);c(this,"_hasChangedSinceTheLastRendering",!1);this.document=new Qn(e),this.domConverter=new rs(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new Ar(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Zn(this.document),this.addObserver(os),this.addObserver(Dt),this.addObserver(Jr),this.addObserver(qr),this.addObserver(zr),this.addObserver(jr),this.addObserver(Xr),this.addObserver(Hr),this.addObserver(Yr),Cr(this),gr(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0}),x.isiOS&&this.listenTo(this.document,"blur",(n,s)=>{this.domConverter.mapDomToView(s.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(n,{mutations:s})=>{s.forEach(i=>this._renderer.markToSync(i.type,i.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,n="main"){const s=this.document.getRoot(n);s._name=e.tagName.toLowerCase();const i={};for(const{name:a,value:l}of Array.from(e.attributes))i[a]=l,a==="class"?this._writer.addClass(l.split(" "),s):s.hasAttribute(a)||this._writer.setAttribute(a,l,s);this._initialDomRootAttributes.set(e,i);const o=()=>{this._writer.setAttribute("contenteditable",(!s.isReadOnly).toString(),s),s.isReadOnly?this._writer.addClass("ck-read-only",s):this._writer.removeClass("ck-read-only",s)};o(),this.domRoots.set(n,e),this.domConverter.bindElements(e,s),this._renderer.markToSync("children",s),this._renderer.markToSync("attributes",s),this._renderer.domDocuments.add(e.ownerDocument),s.on("change:children",(a,l)=>this._renderer.markToSync("children",l)),s.on("change:attributes",(a,l)=>this._renderer.markToSync("attributes",l)),s.on("change:text",(a,l)=>this._renderer.markToSync("text",l)),s.on("change:isReadOnly",()=>this.change(o)),s.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const a of this._observers.values())a.observe(e,n)}detachDomRoot(e){const n=this.domRoots.get(e);Array.from(n.attributes).forEach(({name:i})=>n.removeAttribute(i));const s=this._initialDomRootAttributes.get(n);for(const i in s)n.setAttribute(i,s[i]);this.domRoots.delete(e),this.domConverter.unbindDomElement(n);for(const i of this._observers.values())i.stopObserving(n)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let n=this._observers.get(e);if(n)return n;n=new e(this),this._observers.set(e,n);for(const[s,i]of this.domRoots)n.observe(i,s);return n.enable(),n}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:n,viewportOffset:s=20,ancestorOffset:i=20}={}){const o=this.document.selection.getFirstRange();if(!o)return;const a=he({alignToTop:e,forceScroll:n,viewportOffset:s,ancestorOffset:i});typeof s=="number"&&(s={top:s,bottom:s,left:s,right:s});const l={target:this.domConverter.viewRangeToDom(o),viewportOffset:s,ancestorOffset:i,alignToTop:e,forceScroll:n};this.fire("scrollToTheSelection",l,a),zs(l)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new d("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const n=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),n}catch(n){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(n,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Dt).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,n){return _._createAt(e,n)}createPositionAfter(e){return _._createAfter(e)}createPositionBefore(e){return _._createBefore(e)}createRange(e,n){return new b(e,n)}createRangeOn(e){return b._createOn(e)}createRangeIn(e){return b._createIn(e)}createSelection(...e){return new ee(...e)}_disableRendering(e){this._renderingDisabled=e,e==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}/**
10
+ */class zr{_files;_native;constructor(e,t={}){this._files=t.cacheFiles?_n(e):null,this._native=e}get files(){return this._files||(this._files=_n(this._native)),this._files}get types(){return this._native.types}getData(e){return this._native.getData(e)}setData(e,t){this._native.setData(e,t)}set effectAllowed(e){this._native.effectAllowed=e}get effectAllowed(){return this._native.effectAllowed}set dropEffect(e){this._native.dropEffect=e}get dropEffect(){return this._native.dropEffect}setDragImage(e,t,n){this._native.setDragImage(e,t,n)}get isCanceled(){return this._native.dropEffect=="none"||!!this._native.mozUserCancelled}}function _n(s){const e=Array.from(s.files||[]),t=Array.from(s.items||[]);return e.length?e:t.filter(n=>n.kind==="file").map(n=>n.getAsFile())}class Ur extends ye{domEventType="beforeinput";onDomEvent(e){const t=e.getTargetRanges(),n=this.view,r=n.document;let i=null,o=null,a=[];if(e.dataTransfer&&(i=new zr(e.dataTransfer)),e.data!==null?o=e.data:i&&(o=i.getData("text/plain")),r.selection.isFake)a=Array.from(r.selection.getRanges()),e.preventDefault();else if(t.length)a=t.map(l=>{let c=n.domConverter.domPositionToView(l.startContainer,l.startOffset);const h=n.domConverter.domPositionToView(l.endContainer,l.endOffset);if(c&&D(l.startContainer)&&l.startOffset<L){e.preventDefault();let d=L-l.startOffset;c=c.getLastMatchingPosition(p=>!!(p.item.is("attributeElement")||p.item.is("uiElement")||p.item.is("$textProxy")&&d--),{direction:"backward",singleCharacters:!0})}if(Jr(l.endContainer,l.endOffset)&&e.preventDefault(),c)return n.createRange(c,h);if(h)return n.createRange(h)}).filter(l=>!!l);else if(M.isAndroid){const l=e.target.ownerDocument.defaultView.getSelection();a=Array.from(n.domConverter.domSelectionToView(l).getRanges())}if(M.isAndroid&&e.inputType=="insertCompositionText"&&o&&o.endsWith(`
11
+ `)){this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:[n.createRange(a[0].end)]});return}if(["insertText","insertReplacementText"].includes(e.inputType)&&o&&o.includes(`
12
+ `)){const l=o.split(/\n{1,2}/g);let c=a;e.preventDefault();for(let h=0;h<l.length;h++){const d=l[h];d!=""&&(this.fire(e.type,e,{data:d,dataTransfer:i,targetRanges:c,inputType:e.inputType,isComposing:e.isComposing}),c=[r.selection.getFirstRange()]),h+1<l.length&&(this.fire(e.type,e,{inputType:"insertParagraph",targetRanges:c}),c=[r.selection.getFirstRange()])}return}this.fire(e.type,e,{data:o,dataTransfer:i,targetRanges:a,inputType:e.inputType,isComposing:e.isComposing})}}function Jr(s,e){for(;s.parentNode;){if(E(s)){if(e!=s.data.length)return!1}else if(e!=s.childNodes.length)return!1;if(e=Ee(s)+1,s=s.parentNode,e<s.childNodes.length&&D(s.childNodes[e]))return!0}return!1}class jr extends xe{constructor(e){super(e),this.document.on("keydown",(t,n)=>{if(this.isEnabled&&Ws(n.keyCode)){const r=new Ut(this.document,"arrowKey",this.document.selection.getFirstRange());this.document.fire(r,n),r.stop.called&&t.stop()}})}observe(){}stopObserving(){}}class Gr extends xe{constructor(e){super(e);const t=this.document;t.on("keydown",(n,r)=>{if(!this.isEnabled||r.keyCode!=de.tab||r.ctrlKey)return;const i=new Ut(t,"tab",t.selection.getFirstRange());t.fire(i,r),i.stop.called&&n.stop()})}observe(){}stopObserving(){}}class Hr extends U(){document;domConverter;domRoots=new Map;_renderer;_initialDomRootAttributes=new WeakMap;_observers=new Map;_writer;_ongoingChange=!1;_postFixersInProgress=!1;_renderingDisabled=!1;_hasChangedSinceTheLastRendering=!1;constructor(e){super(),this.document=new Xn(e),this.domConverter=new ns(this.document),this.set("isRenderingInProgress",!1),this.set("hasDomSelection",!1),this._renderer=new vr(this.domConverter,this.document.selection),this._renderer.bind("isFocused","isSelecting","isComposing").to(this.document,"isFocused","isSelecting","isComposing"),this._writer=new Yn(this.document),this.addObserver(rs),this.addObserver(Dt),this.addObserver(Wr),this.addObserver(Vr),this.addObserver($r),this.addObserver(qr),this.addObserver(jr),this.addObserver(Ur),this.addObserver(Gr),br(this),ur(this),this.on("render",()=>{this._render(),this.document.fire("layoutChanged"),this._hasChangedSinceTheLastRendering=!1}),this.listenTo(this.document.selection,"change",()=>{this._hasChangedSinceTheLastRendering=!0}),this.listenTo(this.document,"change:isFocused",()=>{this._hasChangedSinceTheLastRendering=!0}),M.isiOS&&this.listenTo(this.document,"blur",(t,n)=>{this.domConverter.mapDomToView(n.domEvent.relatedTarget)||this.domConverter._clearDomSelection()}),this.listenTo(this.document,"mutations",(t,{mutations:n})=>{n.forEach(r=>this._renderer.markToSync(r.type,r.node))},{priority:"low"}),this.listenTo(this.document,"mutations",()=>{this.forceRender()},{priority:"lowest"})}attachDomRoot(e,t="main"){const n=this.document.getRoot(t);n._name=e.tagName.toLowerCase();const r={};for(const{name:o,value:a}of Array.from(e.attributes))r[o]=a,o==="class"?this._writer.addClass(a.split(" "),n):n.hasAttribute(o)||this._writer.setAttribute(o,a,n);this._initialDomRootAttributes.set(e,r);const i=()=>{this._writer.setAttribute("contenteditable",(!n.isReadOnly).toString(),n),n.isReadOnly?this._writer.addClass("ck-read-only",n):this._writer.removeClass("ck-read-only",n)};i(),this.domRoots.set(t,e),this.domConverter.bindElements(e,n),this._renderer.markToSync("children",n),this._renderer.markToSync("attributes",n),this._renderer.domDocuments.add(e.ownerDocument),n.on("change:children",(o,a)=>this._renderer.markToSync("children",a)),n.on("change:attributes",(o,a)=>this._renderer.markToSync("attributes",a)),n.on("change:text",(o,a)=>this._renderer.markToSync("text",a)),n.on("change:isReadOnly",()=>this.change(i)),n.on("change",()=>{this._hasChangedSinceTheLastRendering=!0});for(const o of this._observers.values())o.observe(e,t)}detachDomRoot(e){const t=this.domRoots.get(e);Array.from(t.attributes).forEach(({name:r})=>t.removeAttribute(r));const n=this._initialDomRootAttributes.get(t);for(const r in n)t.setAttribute(r,n[r]);this.domRoots.delete(e),this.domConverter.unbindDomElement(t);for(const r of this._observers.values())r.stopObserving(t)}getDomRoot(e="main"){return this.domRoots.get(e)}addObserver(e){let t=this._observers.get(e);if(t)return t;t=new e(this),this._observers.set(e,t);for(const[n,r]of this.domRoots)t.observe(r,n);return t.enable(),t}getObserver(e){return this._observers.get(e)}disableObservers(){for(const e of this._observers.values())e.disable()}enableObservers(){for(const e of this._observers.values())e.enable()}scrollToTheSelection({alignToTop:e,forceScroll:t,viewportOffset:n=20,ancestorOffset:r=20}={}){const i=this.document.selection.getFirstRange();if(!i)return;const o=ce({alignToTop:e,forceScroll:t,viewportOffset:n,ancestorOffset:r});typeof n=="number"&&(n={top:n,bottom:n,left:n,right:n});const a={target:this.domConverter.viewRangeToDom(i),viewportOffset:n,ancestorOffset:r,alignToTop:e,forceScroll:t};this.fire("scrollToTheSelection",a,o),$s(a)}focus(){if(!this.document.isFocused){const e=this.document.selection.editableElement;e&&(this.domConverter.focus(e),this.forceRender())}}change(e){if(this.isRenderingInProgress||this._postFixersInProgress)throw new f("cannot-change-view-tree",this);try{if(this._ongoingChange)return e(this._writer);this._ongoingChange=!0;const t=e(this._writer);return this._ongoingChange=!1,!this._renderingDisabled&&this._hasChangedSinceTheLastRendering&&(this._postFixersInProgress=!0,this.document._callPostFixers(this._writer),this._postFixersInProgress=!1,this.fire("render")),t}catch(t){/* istanbul ignore next -- @preserve */f.rethrowUnexpectedError(t,this)}}forceRender(){this._hasChangedSinceTheLastRendering=!0,this.getObserver(Dt).flush(),this.change(()=>{})}destroy(){for(const e of this._observers.values())e.destroy();this.document.destroy(),this.stopListening()}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Z(...e)}_disableRendering(e){this._renderingDisabled=e,e==!1&&this.change(()=>{})}_render(){this.isRenderingInProgress=!0,this.disableObservers(),this._renderer.render(),this.enableObservers(),this.isRenderingInProgress=!1}}/**
13
13
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
14
14
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
15
- */class ue{is(){throw new Error("is() method is abstract")}}class G extends ue{constructor(e,n,s){super();c(this,"textNode");c(this,"data");c(this,"offsetInText");if(this.textNode=e,n<0||n>e.offsetSize)throw new d("model-textproxy-wrong-offsetintext",this);if(s<0||n+s>e.offsetSize)throw new d("model-textproxy-wrong-length",this);this.data=e.data.substring(n,n+s),this.offsetInText=n}get startOffset(){return this.textNode.startOffset!==null?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset!==null?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const n=[];let s=e.includeSelf?this:this.parent;for(;s;)n[e.parentFirst?"push":"unshift"](s),s=s.parent;return n}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}G.prototype.is=function(r){return r==="$textProxy"||r==="model:$textProxy"||r==="textProxy"||r==="model:textProxy"};class oe{constructor(t){c(this,"direction");c(this,"boundaries");c(this,"singleCharacters");c(this,"shallow");c(this,"ignoreElementEnd");c(this,"_position");c(this,"_boundaryStartParent");c(this,"_boundaryEndParent");c(this,"_visitedParent");if(!t||!t.boundaries&&!t.startPosition)throw new d("model-tree-walker-no-start-position",null);const e=t.direction||"forward";if(e!="forward"&&e!="backward")throw new d("model-tree-walker-unknown-direction",t,{direction:e});this.direction=e,this.boundaries=t.boundaries||null,t.startPosition?this._position=t.startPosition.clone():this._position=g._createAt(this.boundaries[this.direction=="backward"?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!t.singleCharacters,this.shallow=!!t.shallow,this.ignoreElementEnd=!!t.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(t){let e,n,s,i;do s=this.position,i=this._visitedParent,{done:e,value:n}=this.next();while(!e&&t(n));e||(this._position=s,this._visitedParent=i)}jumpTo(t){this._boundaryStartParent&&t.isBefore(this.boundaries.start)?t=this.boundaries.start:this._boundaryEndParent&&t.isAfter(this.boundaries.end)&&(t=this.boundaries.end),this._position=t.clone(),this._visitedParent=t.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const t=this.position,e=this.position.clone(),n=this._visitedParent;if(n.parent===null&&e.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&e.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const s=ze(e,n),i=s||as(e,n,s);if(i&&i.is("model:element")){if(!this.shallow)e.path.push(0),this._visitedParent=i;else{if(this.boundaries&&this.boundaries.end.isBefore(e))return{done:!0,value:void 0};e.offset++}return this._position=e,de("elementStart",i,t,e,1)}if(i&&i.is("model:$text")){let o;if(this.singleCharacters)o=1;else{let h=i.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offset<h&&(h=this.boundaries.end.offset),o=h-e.offset}const a=e.offset-i.startOffset,l=new G(i,a,o);return e.offset+=o,this._position=e,de("text",l,t,e,o)}return e.path.pop(),e.offset++,this._position=e,this._visitedParent=n.parent,this.ignoreElementEnd?this._next():de("elementEnd",n,t,e)}_previous(){const t=this.position,e=this.position.clone(),n=this._visitedParent;if(n.parent===null&&e.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&e.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const s=e.parent,i=ze(e,s),o=i||ls(e,s,i);if(o&&o.is("model:element"))return e.offset--,this.shallow?(this._position=e,de("elementStart",o,t,e,1)):(e.path.push(o.maxOffset),this._position=e,this._visitedParent=o,this.ignoreElementEnd?this._previous():de("elementEnd",o,t,e));if(o&&o.is("model:$text")){let a;if(this.singleCharacters)a=1;else{let u=o.startOffset;this._boundaryStartParent==n&&this.boundaries.start.offset>u&&(u=this.boundaries.start.offset),a=e.offset-u}const l=e.offset-o.startOffset,h=new G(o,l-a,a);return e.offset-=a,this._position=e,de("text",h,t,e,a)}return e.path.pop(),this._position=e,this._visitedParent=n.parent,de("elementStart",n,t,e,1)}}function de(r,t,e,n,s){return{done:!1,value:{type:r,item:t,previousPosition:e,nextPosition:n,length:s}}}class g extends ue{constructor(e,n,s="toNone"){super();c(this,"root");c(this,"path");c(this,"stickiness");if(!e.is("element")&&!e.is("documentFragment"))throw new d("model-position-root-invalid",e);if(!Array.isArray(n)||n.length===0)throw new d("model-position-path-incorrect-format",e,{path:n});e.is("rootElement")?n=n.slice():(n=[...e.getPath(),...n],e=e.root),this.root=e,this.path=n,this.stickiness=s}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let n=0;n<this.path.length-1;n++)if(e=e.getChildAtOffset(this.path[n]),!e)throw new d("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new d("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return ze(this,this.parent)}get nodeAfter(){const e=this.parent;return as(this,e,ze(this,e))}get nodeBefore(){const e=this.parent;return ls(this,e,ze(this,e))}get isAtStart(){return this.offset===0}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let n=0;n<this.path.length-1;n++)if(e=e.getChildAtOffset(this.path[n]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const n=B(this.path,e.path);switch(n){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[n]<e.path[n]?"before":"after"}}getLastMatchingPosition(e,n={}){n.startPosition=this;const s=new oe(n);return s.skip(e),s.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const n=this.parent;return n.is("element")?n.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const n=B(this.path,e.path),s=typeof n=="string"?Math.min(this.path.length,e.path.length):n;return this.path.slice(0,s)}getCommonAncestor(e){const n=this.getAncestors(),s=e.getAncestors();let i=0;for(;n[i]==s[i]&&n[i];)i++;return i===0?null:n[i-1]}getShiftedBy(e){const n=this.clone(),s=n.offset+e;return n.offset=s<0?0:s,n}isAfter(e){return this.compareWith(e)=="after"}isBefore(e){return this.compareWith(e)=="before"}isEqual(e){return this.compareWith(e)=="same"}isTouching(e){if(this.root!==e.root)return!1;const n=Math.min(this.path.length,e.path.length);for(let s=0;s<n;s++){const i=this.path[s]-e.path[s];if(i<-1||i>1)return!1;if(i===1)return yn(e,this,s);if(i===-1)return yn(this,e,s)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Vt(this.path,n):Vt(e.path,n)}hasSameParentAs(e){if(this.root!==e.root)return!1;const n=this.getParentPath(),s=e.getParentPath();return B(n,s)=="same"}getTransformedByOperation(e){let n;switch(e.type){case"insert":n=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":n=this._getTransformedByMoveOperation(e);break;case"split":n=this._getTransformedBySplitOperation(e);break;case"merge":n=this._getTransformedByMergeOperation(e);break;default:n=g._createAt(this);break}return n}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const n=e.movedRange;return n.containsPosition(this)||n.start.isEqual(this)&&this.stickiness=="toNext"?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const n=e.movedRange,s=n.containsPosition(this)||n.start.isEqual(this);let i;return s?(i=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(i=i._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?i=g._createAt(e.deletionPosition):i=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),i}_getTransformedByDeletion(e,n){const s=g._createAt(this);if(this.root!=e.root)return s;if(B(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+n>this.offset)return null;s.offset-=n}}else if(B(e.getParentPath(),this.getParentPath())=="prefix"){const i=e.path.length-1;if(e.offset<=this.path[i]){if(e.offset+n>this.path[i])return null;s.path[i]-=n}}return s}_getTransformedByInsertion(e,n){const s=g._createAt(this);if(this.root!=e.root)return s;if(B(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(s.offset+=n);else if(B(e.getParentPath(),this.getParentPath())=="prefix"){const i=e.path.length-1;e.offset<=this.path[i]&&(s.path[i]+=n)}return s}_getTransformedByMove(e,n,s){if(n=n._getTransformedByDeletion(e,s),e.isEqual(n))return g._createAt(this);const i=this._getTransformedByDeletion(e,s);return i===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(s).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,n):i._getTransformedByInsertion(n,s)}_getCombined(e,n){const s=e.path.length-1,i=g._createAt(n);return i.stickiness=this.stickiness,i.offset=i.offset+this.path[s]-e.offset,i.path=[...i.path,...this.path.slice(s+1)],i}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,n,s="toNone"){if(e.is("model:position"))return new g(e.root,e.path,e.stickiness);{const i=e;if(n=="end")n=i.maxOffset;else{if(n=="before")return this._createBefore(i,s);if(n=="after")return this._createAfter(i,s);if(n!==0&&!n)throw new d("model-createpositionat-offset-required",[this,e])}if(!i.is("element")&&!i.is("documentFragment"))throw new d("model-position-parent-incorrect",[this,e]);const o=i.getPath();return o.push(n),new this(i.root,o,s)}}static _createAfter(e,n){if(!e.parent)throw new d("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,n)}static _createBefore(e,n){if(!e.parent)throw new d("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,n)}static fromJSON(e,n){if(e.root==="$graveyard"){const s=new g(n.graveyard,e.path);return s.stickiness=e.stickiness,s}if(!n.getRoot(e.root))throw new d("model-position-fromjson-no-root",n,{rootName:e.root});return new g(n.getRoot(e.root),e.path,e.stickiness)}}g.prototype.is=function(r){return r==="position"||r==="model:position"};function ze(r,t){const e=t.getChildAtOffset(r.offset);return e&&e.is("$text")&&e.startOffset<r.offset?e:null}function as(r,t,e){return e!==null?null:t.getChildAtOffset(r.offset)}function ls(r,t,e){return e!==null?null:t.getChild(t.offsetToIndex(r.offset)-1)}function yn(r,t,e){return!(e+1===r.path.length||!Vt(t.path,e+1)||!Zr(r,e+1))}function Vt(r,t){for(;t<r.length;){if(r[t]!==0)return!1;t++}return!0}function Zr(r,t){let e=r.parent,n=r.path.length-1,s=0;for(;n>=t;){if(r.path[n]+s!==e.maxOffset)return!1;s=1,n--,e=e.parent}return!0}class f extends ue{constructor(e,n){super();c(this,"start");c(this,"end");this.start=g._createAt(e),this.end=n?g._createAt(n):g._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new oe({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),n=this.end.getParentPath();return B(e,n)=="same"}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,n=!1){e.isCollapsed&&(n=!1);const s=this.containsPosition(e.start)||n&&this.start.isEqual(e.start),i=this.containsPosition(e.end)||n&&this.end.isEqual(e.end);return s&&i}containsItem(e){const n=g._createBefore(e);return this.containsPosition(n)||this.start.isEqual(n)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const n=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&n.push(new f(this.start,e.start)),this.containsPosition(e.end)&&n.push(new f(e.end,this.end))):n.push(new f(this.start,this.end)),n}getIntersection(e){if(this.isIntersecting(e)){let n=this.start,s=this.end;return this.containsPosition(e.start)&&(n=e.start),this.containsPosition(e.end)&&(s=e.end),new f(n,s)}return null}getJoined(e,n=!1){let s=this.isIntersecting(e);if(s||(this.start.isBefore(e.start)?s=n?this.end.isTouching(e.start):this.end.isEqual(e.start):s=n?e.end.isTouching(this.start):e.end.isEqual(this.start)),!s)return null;let i=this.start,o=this.end;return e.start.isBefore(i)&&(i=e.start),e.end.isAfter(o)&&(o=e.end),new f(i,o)}getMinimalFlatRanges(){const e=[],n=this.start.getCommonPath(this.end).length,s=g._createAt(this.start);let i=s.parent;for(;s.path.length>n+1;){const o=i.maxOffset-s.offset;o!==0&&e.push(new f(s,s.getShiftedBy(o))),s.path=s.path.slice(0,-1),s.offset++,i=i.parent}for(;s.path.length<=this.end.path.length;){const o=this.end.path[s.path.length-1],a=o-s.offset;a!==0&&e.push(new f(s,s.getShiftedBy(a))),s.offset=o,s.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new oe(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const n=new oe(e);for(const s of n)yield s.item}*getPositions(e={}){e.boundaries=this;const n=new oe(e);yield n.position;for(const s of n)yield s.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new f(this.start,this.end)]}getTransformedByOperations(e){const n=[new f(this.start,this.end)];for(const s of e)for(let i=0;i<n.length;i++){const o=n[i].getTransformedByOperation(s);n.splice(i,1,...o),i+=o.length-1}for(let s=0;s<n.length;s++){const i=n[s];for(let o=s+1;o<n.length;o++){const a=n[o];(i.containsRange(a)||a.containsRange(i)||i.isEqual(a))&&n.splice(o,1)}}return n}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,n=this.end.nodeBefore;return e&&e.is("element")&&e===n?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,n=!1){return this._getTransformedByInsertion(e.position,e.howMany,n)}_getTransformedByMoveOperation(e,n=!1){const s=e.sourcePosition,i=e.howMany,o=e.targetPosition;return this._getTransformedByMove(s,o,i,n)}_getTransformedBySplitOperation(e){const n=this.start._getTransformedBySplitOperation(e);let s=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(s=this.end.getShiftedBy(1)),n.root!=s.root&&(s=this.end.getShiftedBy(-1)),new f(n,s)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new f(this.start);let n=this.start._getTransformedByMergeOperation(e),s=this.end._getTransformedByMergeOperation(e);return n.root!=s.root&&(s=this.end.getShiftedBy(-1)),n.isAfter(s)?(e.sourcePosition.isBefore(e.targetPosition)?(n=g._createAt(s),n.offset=0):(e.deletionPosition.isEqual(n)||(s=e.deletionPosition),n=e.targetPosition),new f(n,s)):new f(n,s)}_getTransformedByInsertion(e,n,s=!1){if(s&&this.containsPosition(e))return[new f(this.start,e),new f(e.getShiftedBy(n),this.end._getTransformedByInsertion(e,n))];{const i=new f(this.start,this.end);return i.start=i.start._getTransformedByInsertion(e,n),i.end=i.end._getTransformedByInsertion(e,n),[i]}}_getTransformedByMove(e,n,s,i=!1){if(this.isCollapsed){const p=this.start._getTransformedByMove(e,n,s);return[new f(p)]}const o=f._createFromPositionAndShift(e,s),a=n._getTransformedByDeletion(e,s);if(this.containsPosition(n)&&!i&&(o.containsPosition(this.start)||o.containsPosition(this.end))){const p=this.start._getTransformedByMove(e,n,s),w=this.end._getTransformedByMove(e,n,s);return[new f(p,w)]}let l;const h=this.getDifference(o);let u=null;const m=this.getIntersection(o);if(h.length==1?u=new f(h[0].start._getTransformedByDeletion(e,s),h[0].end._getTransformedByDeletion(e,s)):h.length==2&&(u=new f(this.start,this.end._getTransformedByDeletion(e,s))),u?l=u._getTransformedByInsertion(a,s,m!==null||i):l=[],m){const p=new f(m.start._getCombined(o.start,a),m.end._getCombined(o.start,a));l.length==2?l.splice(1,0,p):l.push(p)}return l}_getTransformedByDeletion(e,n){let s=this.start._getTransformedByDeletion(e,n),i=this.end._getTransformedByDeletion(e,n);return s==null&&i==null?null:(s==null&&(s=e),i==null&&(i=e),new f(s,i))}static _createFromPositionAndShift(e,n){const s=e,i=e.getShiftedBy(n);return n>0?new this(s,i):new this(i,s)}static _createIn(e){return new this(g._createAt(e,0),g._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(g._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new d("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const n=e[0];e.sort((o,a)=>o.start.isAfter(a.start)?1:-1);const s=e.indexOf(n),i=new this(n.start,n.end);for(let o=s-1;o>=0&&e[o].end.isEqual(i.start);o--)i.start=g._createAt(e[o].start);for(let o=s+1;o<e.length&&e[o].start.isEqual(i.end);o++)i.end=g._createAt(e[o].end);return i}static fromJSON(e,n){return new this(g.fromJSON(e.start,n),g.fromJSON(e.end,n))}}f.prototype.is=function(r){return r==="range"||r==="model:range"};class cs extends O(){constructor(){super();c(this,"_modelToViewMapping",new WeakMap);c(this,"_viewToModelMapping",new WeakMap);c(this,"_viewToModelLengthCallbacks",new Map);c(this,"_markerNameToElements",new Map);c(this,"_elementToMarkerNames",new Map);c(this,"_deferredBindingRemovals",new Map);c(this,"_unboundMarkerNames",new Set);c(this,"_cache",new ei);this.on("modelToViewPosition",(e,n)=>{if(n.viewPosition)return;const s=this._modelToViewMapping.get(n.modelPosition.parent);if(!s)throw new d("mapping-model-position-view-parent-not-found",this,{modelPosition:n.modelPosition});n.viewPosition=this.findPositionIn(s,n.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,n)=>{if(n.modelPosition)return;const s=this.findMappedViewAncestor(n.viewPosition),i=this._viewToModelMapping.get(s),o=this._toModelOffset(n.viewPosition.parent,n.viewPosition.offset,s);n.modelPosition=g._createAt(i,o)},{priority:"low"})}bindElements(e,n){this._modelToViewMapping.set(e,n),this._viewToModelMapping.set(n,e)}unbindViewElement(e,n={}){const s=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const i of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(i);n.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(s)==e&&this._modelToViewMapping.delete(s))}unbindModelElement(e){const n=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(n)==e&&this._viewToModelMapping.delete(n)&&this._cache.stopTracking(n)}bindElementToMarker(e,n){const s=this._markerNameToElements.get(n)||new Set;s.add(e);const i=this._elementToMarkerNames.get(e)||new Set;i.add(n),this._markerNameToElements.set(n,s),this._elementToMarkerNames.set(e,i)}unbindElementFromMarkerName(e,n){const s=this._markerNameToElements.get(n);s&&(s.delete(e),s.size==0&&this._markerNameToElements.delete(n));const i=this._elementToMarkerNames.get(e);i&&(i.delete(n),i.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,n]of this._deferredBindingRemovals)e.root==n&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new f(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new b(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const n={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",n),n.modelPosition}toViewPosition(e,n={}){const s={modelPosition:e,mapper:this,isPhantom:n.isPhantom};return this.fire("modelToViewPosition",s),s.viewPosition}markerNameToElements(e){const n=this._markerNameToElements.get(e);if(!n)return null;const s=new Set;for(const i of n)if(i.is("attributeElement"))for(const o of i.getElementsWithSameId())s.add(o);else s.add(i);return s}registerViewToModelLength(e,n){this._viewToModelLengthCallbacks.set(e,n)}findMappedViewAncestor(e){let n=e.parent;for(;!this._viewToModelMapping.has(n);)n=n.parent;return n}_toModelOffset(e,n,s){if(s!=e){const o=this._toModelOffset(e.parent,e.index,s),a=this._toModelOffset(e,n,e);return o+a}if(e.is("$text"))return n;let i=0;for(let o=0;o<n;o++)i+=this.getModelLength(e.getChild(o));return i}getModelLength(e){const n=[e];let s=0;for(;n.length>0;){const i=n.pop(),o=i.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(i.name);if(o)s+=o(i);else if(this._viewToModelMapping.has(i))s+=1;else if(i.is("$text"))s+=i.data.length;else{if(i.is("uiElement"))continue;for(const a of i.getChildren())n.push(a)}}return s}findPositionIn(e,n){if(n===0)return this._moveViewPositionToTextNode(new _(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const i=this._cache.getClosest(e,n);return this._findPositionStartingFrom(i.viewPosition,i.modelOffset,n,e,!0)}else return this._findPositionStartingFrom(new _(e,0),0,n,e,!1)}_findPositionStartingFrom(e,n,s,i,o){let a=e.parent,l=e.offset;if(a.is("$text"))return new _(a,s-n);let h,u=n,m=0;for(;u<s;){if(h=a.getChild(l),!h){if(a==i)throw new d("mapping-model-offset-not-found",this,{modelOffset:s,viewContainer:i});l=a.parent.getChildIndex(a)+1,a=a.parent,o&&this._cache.save(a,l,i,u);continue}o?m=this._getModelLengthAndCache(h,i,u):m=this.getModelLength(h),u+=m,l++}let p=new _(a,l);if(o)for(;p.isAtEnd&&p.parent!==i&&p.parent.parent;){const w=p.parent.parent,y=w.getChildIndex(p.parent)+1;this._cache.save(w,y,i,u),p=new _(w,y)}return u==s?this._moveViewPositionToTextNode(p):this._findPositionStartingFrom(new _(h,0),u-m,s,i,o)}_getModelLengthAndCache(e,n,s){let i=0;if(this._viewToModelMapping.has(e))i=1;else if(e.is("$text"))i=e.data.length;else if(!e.is("uiElement"))for(const o of e.getChildren())i+=this._getModelLengthAndCache(o,n,s+i);return this._cache.save(e.parent,e.index+1,n,s+i),i}_moveViewPositionToTextNode(e){const n=e.nodeBefore,s=e.nodeAfter;return n&&n.is("view:$text")?new _(n,n.data.length):s&&s.is("view:$text")?new _(s,0):e}}class ei extends O(){constructor(){super(...arguments);c(this,"_cachedMapping",new WeakMap);c(this,"_nodeToCacheListIndex",new WeakMap);c(this,"_invalidateOnChildrenChangeCallback",(e,n,s)=>{this._clearCacheInsideParent(n,s.index)});c(this,"_invalidateOnTextChangeCallback",(e,n)=>{this._clearCacheAfter(n)})}save(e,n,s,i){const o=this._cachedMapping.get(s),a=o.cacheMap.get(i);if(a){const m=e.getChild(n-1),p=a.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(a.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(m,p);return}const h={viewPosition:new _(e,n),modelOffset:i};o.maxModelOffset=i>o.maxModelOffset?i:o.maxModelOffset,o.cacheMap.set(i,h);let u=o.cacheList.length-1;for(;u>=0&&o.cacheList[u].modelOffset>i;)u--;if(o.cacheList.splice(u+1,0,h),n>0){const m=e.getChild(n-1);this._nodeToCacheListIndex.set(m,u+1)}}getClosest(e,n){const s=this._cachedMapping.get(e);let i;if(s)if(n>s.maxModelOffset)i=s.cacheList[s.cacheList.length-1];else{const o=s.cacheMap.get(n);o?i=o:i=this._findInCacheList(s.cacheList,n)}else i=this.startTracking(e);return{modelOffset:i.modelOffset,viewPosition:i.viewPosition.clone()}}startTracking(e){const s={viewPosition:new _(e,0),modelOffset:0},i={maxModelOffset:0,cacheList:[s],cacheMap:new Map([[0,s]])};return this._cachedMapping.set(e,i),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),s}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,n){if(n==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const s=e.getChild(n-1);this._clearCacheAfter(s)}}_clearCacheAll(e){const n=this._cachedMapping.get(e);n.maxModelOffset>0&&(n.maxModelOffset=0,n.cacheList.length=1,n.cacheMap.clear(),n.cacheMap.set(0,n.cacheList[0]))}_clearCacheAfter(e){const n=this._nodeToCacheListIndex.get(e);if(n===void 0){const i=e.parent;this._cachedMapping.has(i)||this._clearCacheInsideParent(i.parent,i.index);return}let s=e.parent;for(;!this._cachedMapping.has(s);)s=s.parent;this._clearCacheFromCacheIndex(s,n)}_clearCacheFromCacheIndex(e,n){n===0&&(n=1);const s=this._cachedMapping.get(e),i=s.cacheList[n-1];if(!i)return;s.maxModelOffset=i.modelOffset;const o=s.cacheList.splice(n);for(const a of o){s.cacheMap.delete(a.modelOffset);const l=a.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(l)}}_findInCacheList(e,n){let s=0,i=e.length-1,o=i-s>>1,a=e[o];for(;s<i;)a.modelOffset<n?s=o+1:i=o-1,o=s+(i-s>>1),a=e[o];return a.modelOffset<=n?a:e[o-1]}}class ti{constructor(){c(this,"_consumable",new Map);c(this,"_textProxyRegistry",new Map)}add(t,e){e=rt(e),t instanceof G&&(t=this._getSymbolForTextProxy(t)),this._consumable.has(t)||this._consumable.set(t,new Map),this._consumable.get(t).set(e,!0)}consume(t,e){return e=rt(e),t instanceof G&&(t=this._getSymbolForTextProxy(t)),this.test(t,e)?(this._consumable.get(t).set(e,!1),!0):!1}test(t,e){e=rt(e),t instanceof G&&(t=this._getSymbolForTextProxy(t));const n=this._consumable.get(t);if(n===void 0)return null;const s=n.get(e);return s===void 0?null:s}revert(t,e){e=rt(e),t instanceof G&&(t=this._getSymbolForTextProxy(t));const n=this.test(t,e);return n===!1?(this._consumable.get(t).set(e,!0),!0):n===!0?!1:null}verifyAllConsumed(t){const e=[];for(const[n,s]of this._consumable)for(const[i,o]of s){const a=i.split(":")[0];o&&t==a&&e.push({event:i,item:n.name||n.description})}if(e.length)throw new d("conversion-model-consumable-not-consumed",null,{items:e})}_getSymbolForTextProxy(t){let e=null;const n=this._textProxyRegistry.get(t.startOffset);if(n){const s=n.get(t.endOffset);s&&(e=s.get(t.parent))}return e||(e=this._addSymbolForTextProxy(t)),e}_addSymbolForTextProxy(t){const e=t.startOffset,n=t.endOffset,s=t.parent,i=Symbol("$textProxy:"+t.data);let o,a;return o=this._textProxyRegistry.get(e),o||(o=new Map,this._textProxyRegistry.set(e,o)),a=o.get(n),a||(a=new Map,o.set(n,a)),a.set(s,i),i}}function rt(r){const t=r.split(":");return t[0]=="insert"?t[0]:t[0]=="addMarker"||t[0]=="removeMarker"?r:t.length>1?t[0]+":"+t[1]:t[0]}class hs extends O(){constructor(e){super();c(this,"_conversionApi");c(this,"_firedEventsMap");this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,n,s){const i=this._createConversionApi(s,e.getRefreshedItems());for(const a of e.getMarkersToRemove())this._convertMarkerRemove(a.name,a.range,i);const o=this._reduceChanges(e.getChanges());for(const a of o)a.type==="insert"?this._convertInsert(f._createFromPositionAndShift(a.position,a.length),i):a.type==="reinsert"?this._convertReinsert(f._createFromPositionAndShift(a.position,a.length),i):a.type==="remove"?this._convertRemove(a.position,a.length,a.name,i):this._convertAttribute(a.range,a.attributeKey,a.attributeOldValue,a.attributeNewValue,i);i.mapper.flushDeferredBindings();for(const a of i.mapper.flushUnboundMarkerNames()){const l=n.get(a).getRange();this._convertMarkerRemove(a,l,i),this._convertMarkerAdd(a,l,i)}for(const a of e.getMarkersToAdd())this._convertMarkerAdd(a.name,a.range,i);i.consumable.verifyAllConsumed("insert")}convert(e,n,s,i={}){const o=this._createConversionApi(s,void 0,i);this._convertInsert(e,o);for(const[a,l]of n)this._convertMarkerAdd(a,l,o);o.consumable.verifyAllConsumed("insert")}convertSelection(e,n,s){const i=this._createConversionApi(s);this.fire("cleanSelection",{selection:e},i);const o=e.getFirstPosition().root;if(!i.mapper.toViewElement(o))return;const a=Array.from(n.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(i.consumable,e,a),this.fire("selection",{selection:e},i),!!e.isCollapsed){for(const l of a)if(i.consumable.test(e,"addMarker:"+l.name)){const h=l.getRange();if(!ni(e.getFirstPosition(),l,i.mapper))continue;const u={item:e,markerName:l.name,markerRange:h};this.fire(`addMarker:${l.name}`,u,i)}for(const l of e.getAttributeKeys())if(i.consumable.test(e,"attribute:"+l)){const h={item:e,range:e.getFirstRange(),attributeKey:l,attributeOldValue:null,attributeNewValue:e.getAttribute(l)};this.fire(`attribute:${l}:$text`,h,i)}}}_convertInsert(e,n,s={}){s.doNotAddConsumables||this._addConsumablesForInsert(n.consumable,e);for(const i of e.getWalker({shallow:!0}))this._testAndFire("insert",vn(i),n)}_convertRemove(e,n,s,i){this.fire(`remove:${s}`,{position:e,length:n},i)}_convertAttribute(e,n,s,i,o){this._addConsumablesForRange(o.consumable,e,`attribute:${n}`);for(const a of e){const l={item:a.item,range:f._createFromPositionAndShift(a.previousPosition,a.length),attributeKey:n,attributeOldValue:s,attributeNewValue:i};this._testAndFire(`attribute:${n}`,l,o)}}_convertReinsert(e,n){const s=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(n.consumable,s);for(const i of s.map(vn))this._testAndFire("insert",{...i,reconversion:!0},n)}_convertMarkerAdd(e,n,s){if(n.root.rootName=="$graveyard")return;const i=`addMarker:${e}`;if(s.consumable.add(n,i),this.fire(i,{markerName:e,markerRange:n},s),!!s.consumable.consume(n,i)){this._addConsumablesForRange(s.consumable,n,i);for(const o of n.getItems()){if(!s.consumable.test(o,i))continue;const a={item:o,range:f._createOn(o),markerName:e,markerRange:n};this.fire(i,a,s)}}}_convertMarkerRemove(e,n,s){n.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:n},s)}_reduceChanges(e){const n={changes:e};return this.fire("reduceChanges",n),n.changes}_addConsumablesForInsert(e,n){for(const s of n){const i=s.item;if(e.test(i,"insert")===null){e.add(i,"insert");for(const o of i.getAttributeKeys())e.add(i,"attribute:"+o)}}return e}_addConsumablesForRange(e,n,s){for(const i of n.getItems())e.add(i,s);return e}_addConsumablesForSelection(e,n,s){e.add(n,"selection");for(const i of s)e.add(n,"addMarker:"+i.name);for(const i of n.getAttributeKeys())e.add(n,"attribute:"+i);return e}_testAndFire(e,n,s){const i=si(e,n),o=n.item.is("$textProxy")?s.consumable._getSymbolForTextProxy(n.item):n.item,a=this._firedEventsMap.get(s),l=a.get(o);if(!l)a.set(o,new Set([i]));else if(!l.has(i))l.add(i);else return;this.fire(i,n,s)}_testAndFireAddAttributes(e,n){const s={item:e,range:f._createOn(e)};for(const i of s.item.getAttributeKeys())s.attributeKey=i,s.attributeOldValue=null,s.attributeNewValue=s.item.getAttribute(i),this._testAndFire(`attribute:${i}`,s,n)}_createConversionApi(e,n=new Set,s={}){const i={...this._conversionApi,consumable:new ti,writer:e,options:s,convertItem:o=>this._convertInsert(f._createOn(o),i),convertChildren:o=>this._convertInsert(f._createIn(o),i,{doNotAddConsumables:!0}),convertAttributes:o=>this._testAndFireAddAttributes(o,i),canReuseView:o=>!n.has(i.mapper.toModelElement(o))};return this._firedEventsMap.set(i,new Map),i}}function ni(r,t,e){const n=t.getRange(),s=Array.from(r.getAncestors());return s.shift(),s.reverse(),!s.some(o=>{if(n.containsItem(o))return!!e.toViewElement(o).getCustomProperty("addHighlight")})}function si(r,t){const e=t.item.is("element")?t.item.name:"$text";return`${r}:${e}`}function vn(r){return{item:r.item,range:f._createFromPositionAndShift(r.previousPosition,r.length)}}let Ce=class extends ue{constructor(e){super();c(this,"parent",null);c(this,"_attrs");c(this,"_index",null);c(this,"_startOffset",null);this._attrs=we(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const e=[];let n=this;for(;n.parent;)e.unshift(n.startOffset),n=n.parent;return e}getAncestors(e={}){const n=[];let s=e.includeSelf?this:this.parent;for(;s;)n[e.parentFirst?"push":"unshift"](s),s=s.parent;return n}getCommonAncestor(e,n={}){const s=this.getAncestors(n),i=e.getAncestors(n);let o=0;for(;s[o]==i[o]&&s[o];)o++;return o===0?null:s[o-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const n=this.getPath(),s=e.getPath(),i=B(n,s);switch(i){case"prefix":return!0;case"extension":return!1;default:return n[i]<s[i]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((n,s)=>(n[s[0]]=s[1],n),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,n){this._attrs.set(e,n)}_setAttributesTo(e){this._attrs=we(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}};Ce.prototype.is=function(r){return r==="node"||r==="model:node"};class L extends O(ue){constructor(...e){super();c(this,"_lastRangeBackward",!1);c(this,"_attrs",new Map);c(this,"_ranges",[]);e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const n of this._ranges){let s=!1;for(const i of e._ranges)if(n.isEqual(i)){s=!0;break}if(!s)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new f(e.start,e.end)}getFirstRange(){let e=null;for(const n of this._ranges)(!e||n.start.isBefore(e.start))&&(e=n);return e?new f(e.start,e.end):null}getLastRange(){let e=null;for(const n of this._ranges)(!e||n.end.isAfter(e.end))&&(e=n);return e?new f(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[n,s,i]=e;if(typeof s=="object"&&(i=s,s=void 0),n===null)this._setRanges([]);else if(n instanceof L)this._setRanges(n.getRanges(),n.isBackward);else if(n&&typeof n.getRanges=="function")this._setRanges(n.getRanges(),n.isBackward);else if(n instanceof f)this._setRanges([n],!!i&&!!i.backward);else if(n instanceof g)this._setRanges([new f(n)]);else if(n instanceof Ce){const o=!!i&&!!i.backward;let a;if(s=="in")a=f._createIn(n);else if(s=="on")a=f._createOn(n);else if(s!==void 0)a=new f(g._createAt(n,s));else throw new d("model-selection-setto-required-second-parameter",[this,n]);this._setRanges([a],o)}else if(ce(n))this._setRanges(n,i&&!!i.backward);else throw new d("model-selection-setto-not-selectable",[this,n])}_setRanges(e,n=!1){const s=Array.from(e),i=s.some(o=>{if(!(o instanceof f))throw new d("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(a=>!a.isEqual(o))});s.length===this._ranges.length&&!i||(this._replaceAllRanges(s),this._lastRangeBackward=!!n,this.fire("change:range",{directChange:!0}))}setFocus(e,n){if(this.anchor===null)throw new d("model-selection-setfocus-no-ranges",[this,e]);const s=g._createAt(e,n);if(s.compareWith(this.focus)=="same")return;const i=this.anchor;this._ranges.length&&this._popRange(),s.compareWith(i)=="before"?(this._pushRange(new f(s,i)),this._lastRangeBackward=!0):(this._pushRange(new f(i,s)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,n){this.getAttribute(e)!==n&&(this._attrs.set(e,n),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const n of this.getRanges()){const s=Pn(n.start,e);ii(s,n)&&(yield s);const i=n.getWalker();for(const a of i){const l=a.item;a.type=="elementEnd"&&ri(l,e,n)?yield l:a.type=="elementStart"&&l.is("model:element")&&l.root.document.model.schema.isBlock(l)&&i.jumpTo(g._createAt(l,"end"))}const o=Pn(n.end,e);oi(o,n)&&(yield o)}}containsEntireContent(e=this.anchor.root){const n=g._createAt(e,0),s=g._createAt(e,"end");return n.isTouching(this.getFirstPosition())&&s.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new f(e.start,e.end))}_checkRange(e){for(let n=0;n<this._ranges.length;n++)if(e.isIntersecting(this._ranges[n]))throw new d("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[n]})}_replaceAllRanges(e){this._removeAllRanges();for(const n of e)this._pushRange(n)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}L.prototype.is=function(r){return r==="selection"||r==="model:selection"};function us(r,t){return t.has(r)?!1:(t.add(r),r.root.document.model.schema.isBlock(r)&&!!r.parent)}function ri(r,t,e){return us(r,t)&&Kt(r,e)}function Pn(r,t){const n=r.parent.root.document.model.schema,s=r.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const o=s.find(a=>i?!1:(i=n.isLimit(a),!i&&us(a,t)));return s.forEach(a=>t.add(a)),o}function Kt(r,t){const e=ai(r);return e?!t.containsRange(f._createOn(e),!0):!0}function ii(r,t){return r?t.isCollapsed||r.isEmpty?!0:t.start.isTouching(g._createAt(r,r.maxOffset))?!1:Kt(r,t):!1}function oi(r,t){return r?t.isCollapsed||r.isEmpty?!0:t.end.isTouching(g._createAt(r,0))?!1:Kt(r,t):!1}function ai(r){const t=r.root.document.model.schema;let e=r.parent;for(;e;){if(t.isBlock(e))return e;e=e.parent}}class be extends O(f){constructor(t,e){super(t,e),li.call(this)}detach(){this.stopListening()}toRange(){return new f(this.start,this.end)}static fromRange(t){return new be(t.start,t.end)}}be.prototype.is=function(r){return r==="liveRange"||r==="model:liveRange"||r=="range"||r==="model:range"};function li(){this.listenTo(this.root.document.model,"applyOperation",(r,t)=>{const e=t[0];e.isDocumentOperation&&ci.call(this,e)},{priority:"low"})}function ci(r){const t=this.getTransformedByOperation(r),e=f._createFromRanges(t),n=!e.isEqual(this),s=hi(this,r);let i=null;if(n){e.root.rootName=="$graveyard"&&(r.type=="remove"?i=r.sourcePosition:i=r.deletionPosition);const o=this.toRange();this.start=e.start,this.end=e.end,this.fire("change:range",o,{deletionPosition:i})}else s&&this.fire("change:content",this.toRange(),{deletionPosition:i})}function hi(r,t){switch(t.type){case"insert":return r.containsPosition(t.position);case"move":case"remove":case"reinsert":case"merge":return r.containsPosition(t.sourcePosition)||r.start.isEqual(t.sourcePosition)||r.containsPosition(t.targetPosition);case"split":return r.containsPosition(t.splitPosition)||r.containsPosition(t.insertionPosition)}return!1}class A extends Ce{constructor(e,n){super(n);c(this,"_data");this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new A(this.data,this.getAttributes())}static fromJSON(e){return new A(e.data,e.attributes)}}A.prototype.is=function(r){return r==="$text"||r==="model:$text"||r==="text"||r==="model:text"||r==="node"||r==="model:node"};const Ye="selection:";class H extends O(ue){constructor(e){super();c(this,"_selection");this._selection=new ui(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,n){this._selection.setFocus(e,n)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,n){this._selection.setAttribute(e,n)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return Ye+e}static _isStoreAttributeKey(e){return e.startsWith(Ye)}}H.prototype.is=function(r){return r==="selection"||r=="model:selection"||r=="documentSelection"||r=="model:documentSelection"};class ui extends L{constructor(e){super();c(this,"markers",new qt({idProperty:"name"}));c(this,"_model");c(this,"_document");c(this,"_attributePriority",new Map);c(this,"_selectionRestorePosition",null);c(this,"_hasChangedRange",!1);c(this,"_overriddenGravityRegister",new Set);c(this,"_observedMarkers",new Set);this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(n,s)=>{const i=s[0];!i.isDocumentOperation||i.type=="marker"||i.type=="rename"||i.type=="noop"||(this._ranges.length==0&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(n,s,i,o)=>{this._updateMarker(s,o)}),this.listenTo(this._document,"change",(n,s)=>{fi(this._model,s)})}get isCollapsed(){return this._ranges.length===0?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,n){super.setFocus(e,n),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,n){if(this._setAttribute(e,n)){const s=[e];this.fire("change:attribute",{attributeKeys:s,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const n=[e];this.fire("change:attribute",{attributeKeys:n,directChange:!0})}}overrideGravity(){const e=$s();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new d("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const n=this._prepareRange(e);n&&this._ranges.push(n)}_validateSelectionRanges(e){for(const n of e)if(!this._document._validateSelectionRange(n))throw new d("document-selection-wrong-position",this,{range:n})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const n=be.fromRange(e);return n.on("change:range",(s,i,o)=>{if(this._hasChangedRange=!0,n.root==this._document.graveyard){this._selectionRestorePosition=o.deletionPosition;const a=this._ranges.indexOf(n);this._ranges.splice(a,1),n.detach()}}),n}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let n=!1;for(const i of this._model.markers){const o=i.name.split(":",1)[0];if(!this._observedMarkers.has(o))continue;const a=i.getRange();for(const l of this.getRanges())a.containsRange(l,!l.isCollapsed)&&e.push(i)}const s=Array.from(this.markers);for(const i of e)this.markers.has(i)||(this.markers.add(i),n=!0);for(const i of Array.from(this.markers))e.includes(i)||(this.markers.remove(i),n=!0);n&&this.fire("change:marker",{oldMarkers:s,directChange:!1})}_updateMarker(e,n){const s=e.name.split(":",1)[0];if(!this._observedMarkers.has(s))return;let i=!1;const o=Array.from(this.markers),a=this.markers.has(e);if(!n)a&&(this.markers.remove(e),i=!0);else{let l=!1;for(const h of this.getRanges())if(n.containsRange(h,!h.isCollapsed)){l=!0;break}l&&!a?(this.markers.add(e),i=!0):!l&&a&&(this.markers.remove(e),i=!0)}i&&this.fire("change:marker",{oldMarkers:o,directChange:!1})}_updateAttributes(e){const n=we(this._getSurroundingAttributes()),s=we(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[o,a]of this._attributePriority)a=="low"&&(this._attrs.delete(o),this._attributePriority.delete(o));this._setAttributesTo(n);const i=[];for(const[o,a]of this.getAttributes())(!s.has(o)||s.get(o)!==a)&&i.push(o);for(const[o]of s)this.hasAttribute(o)||i.push(o);i.length>0&&this.fire("change:attribute",{attributeKeys:i,directChange:!1})}_setAttribute(e,n,s=!0){const i=s?"normal":"low";return i=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===n?!1:(this._attrs.set(e,n),this._attributePriority.set(e,i),!0)}_removeAttribute(e,n=!0){const s=n?"normal":"low";return s=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,s),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const n=new Set;for(const[s,i]of this.getAttributes())e.get(s)!==i&&this._removeAttribute(s,!1);for(const[s,i]of e)this._setAttribute(s,i,!1)&&n.add(s);return n}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const n of e.getAttributeKeys())n.startsWith(Ye)&&(yield[n.substr(Ye.length),e.getAttribute(n)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),n=this._model.schema;if(e.root.rootName=="$graveyard")return null;let s=null;if(this.isCollapsed){const i=e.textNode?e.textNode:e.nodeBefore,o=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(s=De(i,n)),s||(s=De(o,n)),!this.isGravityOverridden&&!s){let a=i;for(;a&&!s;)a=a.previousSibling,s=De(a,n)}if(!s){let a=o;for(;a&&!s;)a=a.nextSibling,s=De(a,n)}s||(s=this.getStoredAttributes())}else{const i=this.getFirstRange();for(const o of i){if(o.item.is("element")&&n.isObject(o.item)){s=De(o.item,n);break}if(o.type=="text"){s=o.item.getAttributes();break}}}return s}_fixGraveyardSelection(e){const n=this._model.schema.getNearestSelectionRange(e);n&&this._pushRange(n)}}function De(r,t){if(!r)return null;if(r instanceof G||r instanceof A)return r.getAttributes();if(!t.isInline(r))return null;if(!t.isObject(r))return[];const e=[];for(const[n,s]of r.getAttributes())t.checkAttribute("$text",n)&&t.getAttributeProperties(n).copyFromObject!==!1&&e.push([n,s]);return e}function fi(r,t){const e=r.document.differ;for(const n of e.getChanges()){if(n.type!="insert")continue;const s=n.position.parent;n.length===s.maxOffset&&r.enqueueChange(t,o=>{const a=Array.from(s.getAttributeKeys()).filter(l=>l.startsWith(Ye));for(const l of a)o.removeAttribute(l,s)})}}class Ue{constructor(t){c(this,"_nodes",[]);c(this,"_offsetToNode",[]);t&&this._insertNodes(0,t)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(t){return this._nodes[t]||null}getNodeAtOffset(t){return this._offsetToNode[t]||null}getNodeIndex(t){return t.index}getNodeStartOffset(t){return t.startOffset}indexToOffset(t){if(t==this._nodes.length)return this.maxOffset;const e=this._nodes[t];if(!e)throw new d("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(e)}offsetToIndex(t){if(t==this._offsetToNode.length)return this._nodes.length;const e=this._offsetToNode[t];if(!e)throw new d("model-nodelist-offset-out-of-bounds",this,{offset:t,nodeList:this});return this.getNodeIndex(e)}_insertNodes(t,e){const n=[];for(const i of e){if(!(i instanceof Ce))throw new d("model-nodelist-insertnodes-not-node",this);n.push(i)}let s=this.indexToOffset(t);nn(this._nodes,n,t),nn(this._offsetToNode,di(n),s);for(let i=t;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=s,s+=this._nodes[i].offsetSize}_removeNodes(t,e=1){if(e==0)return[];let n=this.indexToOffset(t);const s=this._nodes.splice(t,e),i=s[s.length-1],o=i.startOffset+i.offsetSize-n;this._offsetToNode.splice(n,o);for(const a of s)a._index=null,a._startOffset=null;for(let a=t;a<this._nodes.length;a++)this._nodes[a]._index=a,this._nodes[a]._startOffset=n,n+=this._nodes[a].offsetSize;return s}_removeNodesArray(t){if(t.length==0)return;for(const n of t)n._index=null,n._startOffset=null;this._nodes=this._nodes.filter(n=>n.index!==null),this._offsetToNode=this._offsetToNode.filter(n=>n.index!==null);let e=0;for(let n=0;n<this._nodes.length;n++)this._nodes[n]._index=n,this._nodes[n]._startOffset=e,e+=this._nodes[n].offsetSize}toJSON(){return this._nodes.map(t=>t.toJSON())}}function di(r){const t=[];let e=0;for(const n of r)for(let s=0;s<n.offsetSize;s++)t[e++]=n;return t}class k extends Ce{constructor(e,n,s){super(n);c(this,"name");c(this,"_children",new Ue);this.name=e,s&&this._insertChild(0,s)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let n=this;for(const s of e)n=n.getChildAtOffset(s);return n}findAncestor(e,n={}){let s=n.includeSelf?this:this.parent;for(;s;){if(s.name===e)return s;s=s.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const n of this._children)e.children.push(n.toJSON())}return e}_clone(e=!1){const n=e?gi(this._children):void 0;return new k(this.name,this.getAttributes(),n)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,n){const s=mi(n);for(const i of s)i.parent!==null&&i._remove(),i.parent=this;this._children._insertNodes(e,s)}_removeChildren(e,n=1){const s=this._children._removeNodes(e,n);for(const i of s)i.parent=null;return s}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const n of e)n.parent=null}static fromJSON(e){let n;if(e.children){n=[];for(const s of e.children)s.name?n.push(k.fromJSON(s)):n.push(A.fromJSON(s))}return new k(e.name,e.attributes,n)}}k.prototype.is=function(r,t){return t?t===this.name&&(r==="element"||r==="model:element"):r==="element"||r==="model:element"||r==="node"||r==="model:node"};function mi(r){if(typeof r=="string")return[new A(r)];ce(r)||(r=[r]);const t=[];for(const e of r)typeof e=="string"?t.push(new A(e)):e instanceof G?t.push(new A(e.data,e.getAttributes())):t.push(e);return t}function gi(r){const t=[];for(const e of r)t.push(e._clone(!0));return t}/**
15
+ */class he{is(){throw new Error("is() method is abstract")}}class j extends he{textNode;data;offsetInText;constructor(e,t,n){if(super(),this.textNode=e,t<0||t>e.offsetSize)throw new f("model-textproxy-wrong-offsetintext",this);if(n<0||t+n>e.offsetSize)throw new f("model-textproxy-wrong-length",this);this.data=e.data.substring(t,t+n),this.offsetInText=t}get startOffset(){return this.textNode.startOffset!==null?this.textNode.startOffset+this.offsetInText:null}get offsetSize(){return this.data.length}get endOffset(){return this.startOffset!==null?this.startOffset+this.offsetSize:null}get isPartial(){return this.offsetSize!==this.textNode.offsetSize}get parent(){return this.textNode.parent}get root(){return this.textNode.root}getPath(){const e=this.textNode.getPath();return e.length>0&&(e[e.length-1]+=this.offsetInText),e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}hasAttribute(e){return this.textNode.hasAttribute(e)}getAttribute(e){return this.textNode.getAttribute(e)}getAttributes(){return this.textNode.getAttributes()}getAttributeKeys(){return this.textNode.getAttributeKeys()}}j.prototype.is=function(s){return s==="$textProxy"||s==="model:$textProxy"||s==="textProxy"||s==="model:textProxy"};class ie{direction;boundaries;singleCharacters;shallow;ignoreElementEnd;_position;_boundaryStartParent;_boundaryEndParent;_visitedParent;constructor(e){if(!e||!e.boundaries&&!e.startPosition)throw new f("model-tree-walker-no-start-position",null);const t=e.direction||"forward";if(t!="forward"&&t!="backward")throw new f("model-tree-walker-unknown-direction",e,{direction:t});this.direction=t,this.boundaries=e.boundaries||null,e.startPosition?this._position=e.startPosition.clone():this._position=m._createAt(this.boundaries[this.direction=="backward"?"end":"start"]),this.position.stickiness="toNone",this.singleCharacters=!!e.singleCharacters,this.shallow=!!e.shallow,this.ignoreElementEnd=!!e.ignoreElementEnd,this._boundaryStartParent=this.boundaries?this.boundaries.start.parent:null,this._boundaryEndParent=this.boundaries?this.boundaries.end.parent:null,this._visitedParent=this.position.parent}[Symbol.iterator](){return this}get position(){return this._position}skip(e){let t,n,r,i;do r=this.position,i=this._visitedParent,{done:t,value:n}=this.next();while(!t&&e(n));t||(this._position=r,this._visitedParent=i)}jumpTo(e){this._boundaryStartParent&&e.isBefore(this.boundaries.start)?e=this.boundaries.start:this._boundaryEndParent&&e.isAfter(this.boundaries.end)&&(e=this.boundaries.end),this._position=e.clone(),this._visitedParent=e.parent}next(){return this.direction=="forward"?this._next():this._previous()}_next(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===n.maxOffset)return{done:!0,value:void 0};if(n===this._boundaryEndParent&&t.offset==this.boundaries.end.offset)return{done:!0,value:void 0};const r=qe(t,n),i=r||is(t,n,r);if(i&&i.is("model:element")){if(!this.shallow)t.path.push(0),this._visitedParent=i;else{if(this.boundaries&&this.boundaries.end.isBefore(t))return{done:!0,value:void 0};t.offset++}return this._position=t,fe("elementStart",i,e,t,1)}if(i&&i.is("model:$text")){let o;if(this.singleCharacters)o=1;else{let c=i.endOffset;this._boundaryEndParent==n&&this.boundaries.end.offset<c&&(c=this.boundaries.end.offset),o=c-t.offset}const a=t.offset-i.startOffset,l=new j(i,a,o);return t.offset+=o,this._position=t,fe("text",l,e,t,o)}return t.path.pop(),t.offset++,this._position=t,this._visitedParent=n.parent,this.ignoreElementEnd?this._next():fe("elementEnd",n,e,t)}_previous(){const e=this.position,t=this.position.clone(),n=this._visitedParent;if(n.parent===null&&t.offset===0)return{done:!0,value:void 0};if(n==this._boundaryStartParent&&t.offset==this.boundaries.start.offset)return{done:!0,value:void 0};const r=t.parent,i=qe(t,r),o=i||os(t,r,i);if(o&&o.is("model:element"))return t.offset--,this.shallow?(this._position=t,fe("elementStart",o,e,t,1)):(t.path.push(o.maxOffset),this._position=t,this._visitedParent=o,this.ignoreElementEnd?this._previous():fe("elementEnd",o,e,t));if(o&&o.is("model:$text")){let a;if(this.singleCharacters)a=1;else{let h=o.startOffset;this._boundaryStartParent==n&&this.boundaries.start.offset>h&&(h=this.boundaries.start.offset),a=t.offset-h}const l=t.offset-o.startOffset,c=new j(o,l-a,a);return t.offset-=a,this._position=t,fe("text",c,e,t,a)}return t.path.pop(),this._position=t,this._visitedParent=n.parent,fe("elementStart",n,e,t,1)}}function fe(s,e,t,n,r){return{done:!1,value:{type:s,item:e,previousPosition:t,nextPosition:n,length:r}}}class m extends he{root;path;stickiness;constructor(e,t,n="toNone"){if(super(),!e.is("element")&&!e.is("documentFragment"))throw new f("model-position-root-invalid",e);if(!Array.isArray(t)||t.length===0)throw new f("model-position-path-incorrect-format",e,{path:t});e.is("rootElement")?t=t.slice():(t=[...e.getPath(),...t],e=e.root),this.root=e,this.path=t,this.stickiness=n}get offset(){return this.path[this.path.length-1]}set offset(e){this.path[this.path.length-1]=e}get parent(){let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)throw new f("model-position-path-incorrect",this,{position:this});if(e.is("$text"))throw new f("model-position-path-incorrect",this,{position:this});return e}get index(){return this.parent.offsetToIndex(this.offset)}get textNode(){return qe(this,this.parent)}get nodeAfter(){const e=this.parent;return is(this,e,qe(this,e))}get nodeBefore(){const e=this.parent;return os(this,e,qe(this,e))}get isAtStart(){return this.offset===0}get isAtEnd(){return this.offset==this.parent.maxOffset}isValid(){if(this.offset<0)return!1;let e=this.root;for(let t=0;t<this.path.length-1;t++)if(e=e.getChildAtOffset(this.path[t]),!e)return!1;return this.offset<=e.maxOffset}compareWith(e){if(this.root!=e.root)return"different";const t=F(this.path,e.path);switch(t){case"same":return"same";case"prefix":return"before";case"extension":return"after";default:return this.path[t]<e.path[t]?"before":"after"}}getLastMatchingPosition(e,t={}){t.startPosition=this;const n=new ie(t);return n.skip(e),n.position}getParentPath(){return this.path.slice(0,-1)}getAncestors(){const e=this.parent;return e.is("documentFragment")?[e]:e.getAncestors({includeSelf:!0})}findAncestor(e){const t=this.parent;return t.is("element")?t.findAncestor(e,{includeSelf:!0}):null}getCommonPath(e){if(this.root!=e.root)return[];const t=F(this.path,e.path),n=typeof t=="string"?Math.min(this.path.length,e.path.length):t;return this.path.slice(0,n)}getCommonAncestor(e){const t=this.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]==n[r]&&t[r];)r++;return r===0?null:t[r-1]}getShiftedBy(e){const t=this.clone(),n=t.offset+e;return t.offset=n<0?0:n,t}isAfter(e){return this.compareWith(e)=="after"}isBefore(e){return this.compareWith(e)=="before"}isEqual(e){return this.compareWith(e)=="same"}isTouching(e){if(this.root!==e.root)return!1;const t=Math.min(this.path.length,e.path.length);for(let n=0;n<t;n++){const r=this.path[n]-e.path[n];if(r<-1||r>1)return!1;if(r===1)return wn(e,this,n);if(r===-1)return wn(this,e,n)}return this.path.length===e.path.length?!0:this.path.length>e.path.length?Bt(this.path,t):Bt(e.path,t)}hasSameParentAs(e){if(this.root!==e.root)return!1;const t=this.getParentPath(),n=e.getParentPath();return F(t,n)=="same"}getTransformedByOperation(e){let t;switch(e.type){case"insert":t=this._getTransformedByInsertOperation(e);break;case"move":case"remove":case"reinsert":t=this._getTransformedByMoveOperation(e);break;case"split":t=this._getTransformedBySplitOperation(e);break;case"merge":t=this._getTransformedByMergeOperation(e);break;default:t=m._createAt(this);break}return t}_getTransformedByInsertOperation(e){return this._getTransformedByInsertion(e.position,e.howMany)}_getTransformedByMoveOperation(e){return this._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany)}_getTransformedBySplitOperation(e){const t=e.movedRange;return t.containsPosition(this)||t.start.isEqual(this)&&this.stickiness=="toNext"?this._getCombined(e.splitPosition,e.moveTargetPosition):e.graveyardPosition?this._getTransformedByMove(e.graveyardPosition,e.insertionPosition,1):this._getTransformedByInsertion(e.insertionPosition,1)}_getTransformedByMergeOperation(e){const t=e.movedRange,n=t.containsPosition(this)||t.start.isEqual(this);let r;return n?(r=this._getCombined(e.sourcePosition,e.targetPosition),e.sourcePosition.isBefore(e.targetPosition)&&(r=r._getTransformedByDeletion(e.deletionPosition,1))):this.isEqual(e.deletionPosition)?r=m._createAt(e.deletionPosition):r=this._getTransformedByMove(e.deletionPosition,e.graveyardPosition,1),r}_getTransformedByDeletion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if(F(e.getParentPath(),this.getParentPath())=="same"){if(e.offset<this.offset){if(e.offset+t>this.offset)return null;n.offset-=t}}else if(F(e.getParentPath(),this.getParentPath())=="prefix"){const r=e.path.length-1;if(e.offset<=this.path[r]){if(e.offset+t>this.path[r])return null;n.path[r]-=t}}return n}_getTransformedByInsertion(e,t){const n=m._createAt(this);if(this.root!=e.root)return n;if(F(e.getParentPath(),this.getParentPath())=="same")(e.offset<this.offset||e.offset==this.offset&&this.stickiness!="toPrevious")&&(n.offset+=t);else if(F(e.getParentPath(),this.getParentPath())=="prefix"){const r=e.path.length-1;e.offset<=this.path[r]&&(n.path[r]+=t)}return n}_getTransformedByMove(e,t,n){if(t=t._getTransformedByDeletion(e,n),e.isEqual(t))return m._createAt(this);const r=this._getTransformedByDeletion(e,n);return r===null||e.isEqual(this)&&this.stickiness=="toNext"||e.getShiftedBy(n).isEqual(this)&&this.stickiness=="toPrevious"?this._getCombined(e,t):r._getTransformedByInsertion(t,n)}_getCombined(e,t){const n=e.path.length-1,r=m._createAt(t);return r.stickiness=this.stickiness,r.offset=r.offset+this.path[n]-e.offset,r.path=[...r.path,...this.path.slice(n+1)],r}toJSON(){return{root:this.root.toJSON(),path:Array.from(this.path),stickiness:this.stickiness}}clone(){return new this.constructor(this.root,this.path,this.stickiness)}static _createAt(e,t,n="toNone"){if(e.is("model:position"))return new m(e.root,e.path,e.stickiness);{const r=e;if(t=="end")t=r.maxOffset;else{if(t=="before")return this._createBefore(r,n);if(t=="after")return this._createAfter(r,n);if(t!==0&&!t)throw new f("model-createpositionat-offset-required",[this,e])}if(!r.is("element")&&!r.is("documentFragment"))throw new f("model-position-parent-incorrect",[this,e]);const i=r.getPath();return i.push(t),new this(r.root,i,n)}}static _createAfter(e,t){if(!e.parent)throw new f("model-position-after-root",[this,e],{root:e});return this._createAt(e.parent,e.endOffset,t)}static _createBefore(e,t){if(!e.parent)throw new f("model-position-before-root",e,{root:e});return this._createAt(e.parent,e.startOffset,t)}static fromJSON(e,t){if(e.root==="$graveyard"){const n=new m(t.graveyard,e.path);return n.stickiness=e.stickiness,n}if(!t.getRoot(e.root))throw new f("model-position-fromjson-no-root",t,{rootName:e.root});return new m(t.getRoot(e.root),e.path,e.stickiness)}}m.prototype.is=function(s){return s==="position"||s==="model:position"};function qe(s,e){const t=e.getChildAtOffset(s.offset);return t&&t.is("$text")&&t.startOffset<s.offset?t:null}function is(s,e,t){return t!==null?null:e.getChildAtOffset(s.offset)}function os(s,e,t){return t!==null?null:e.getChild(e.offsetToIndex(s.offset)-1)}function wn(s,e,t){return!(t+1===s.path.length||!Bt(e.path,t+1)||!Kr(s,t+1))}function Bt(s,e){for(;e<s.length;){if(s[e]!==0)return!1;e++}return!0}function Kr(s,e){let t=s.parent,n=s.path.length-1,r=0;for(;n>=e;){if(s.path[n]+r!==t.maxOffset)return!1;r=1,n--,t=t.parent}return!0}class u extends he{start;end;constructor(e,t){super(),this.start=m._createAt(e),this.end=t?m._createAt(t):m._createAt(e),this.start.stickiness=this.isCollapsed?"toNone":"toNext",this.end.stickiness=this.isCollapsed?"toNone":"toPrevious"}*[Symbol.iterator](){yield*new ie({boundaries:this,ignoreElementEnd:!0})}get isCollapsed(){return this.start.isEqual(this.end)}get isFlat(){const e=this.start.getParentPath(),t=this.end.getParentPath();return F(e,t)=="same"}get root(){return this.start.root}containsPosition(e){return e.isAfter(this.start)&&e.isBefore(this.end)}containsRange(e,t=!1){e.isCollapsed&&(t=!1);const n=this.containsPosition(e.start)||t&&this.start.isEqual(e.start),r=this.containsPosition(e.end)||t&&this.end.isEqual(e.end);return n&&r}containsItem(e){const t=m._createBefore(e);return this.containsPosition(t)||this.start.isEqual(t)}isEqual(e){return this.start.isEqual(e.start)&&this.end.isEqual(e.end)}isIntersecting(e){return this.start.isBefore(e.end)&&this.end.isAfter(e.start)}getDifference(e){const t=[];return this.isIntersecting(e)?(this.containsPosition(e.start)&&t.push(new u(this.start,e.start)),this.containsPosition(e.end)&&t.push(new u(e.end,this.end))):t.push(new u(this.start,this.end)),t}getIntersection(e){if(this.isIntersecting(e)){let t=this.start,n=this.end;return this.containsPosition(e.start)&&(t=e.start),this.containsPosition(e.end)&&(n=e.end),new u(t,n)}return null}getJoined(e,t=!1){let n=this.isIntersecting(e);if(n||(this.start.isBefore(e.start)?n=t?this.end.isTouching(e.start):this.end.isEqual(e.start):n=t?e.end.isTouching(this.start):e.end.isEqual(this.start)),!n)return null;let r=this.start,i=this.end;return e.start.isBefore(r)&&(r=e.start),e.end.isAfter(i)&&(i=e.end),new u(r,i)}getMinimalFlatRanges(){const e=[],t=this.start.getCommonPath(this.end).length,n=m._createAt(this.start);let r=n.parent;for(;n.path.length>t+1;){const i=r.maxOffset-n.offset;i!==0&&e.push(new u(n,n.getShiftedBy(i))),n.path=n.path.slice(0,-1),n.offset++,r=r.parent}for(;n.path.length<=this.end.path.length;){const i=this.end.path[n.path.length-1],o=i-n.offset;o!==0&&e.push(new u(n,n.getShiftedBy(o))),n.offset=i,n.path.push(0)}return e}getWalker(e={}){return e.boundaries=this,new ie(e)}*getItems(e={}){e.boundaries=this,e.ignoreElementEnd=!0;const t=new ie(e);for(const n of t)yield n.item}*getPositions(e={}){e.boundaries=this;const t=new ie(e);yield t.position;for(const n of t)yield n.nextPosition}getTransformedByOperation(e){switch(e.type){case"insert":return this._getTransformedByInsertOperation(e);case"move":case"remove":case"reinsert":return this._getTransformedByMoveOperation(e);case"split":return[this._getTransformedBySplitOperation(e)];case"merge":return[this._getTransformedByMergeOperation(e)]}return[new u(this.start,this.end)]}getTransformedByOperations(e){const t=[new u(this.start,this.end)];for(const n of e)for(let r=0;r<t.length;r++){const i=t[r].getTransformedByOperation(n);t.splice(r,1,...i),r+=i.length-1}for(let n=0;n<t.length;n++){const r=t[n];for(let i=n+1;i<t.length;i++){const o=t[i];(r.containsRange(o)||o.containsRange(r)||r.isEqual(o))&&t.splice(i,1)}}return t}getCommonAncestor(){return this.start.getCommonAncestor(this.end)}getContainedElement(){if(this.isCollapsed)return null;const e=this.start.nodeAfter,t=this.end.nodeBefore;return e&&e.is("element")&&e===t?e:null}toJSON(){return{start:this.start.toJSON(),end:this.end.toJSON()}}clone(){return new this.constructor(this.start,this.end)}_getTransformedByInsertOperation(e,t=!1){return this._getTransformedByInsertion(e.position,e.howMany,t)}_getTransformedByMoveOperation(e,t=!1){const n=e.sourcePosition,r=e.howMany,i=e.targetPosition;return this._getTransformedByMove(n,i,r,t)}_getTransformedBySplitOperation(e){const t=this.start._getTransformedBySplitOperation(e);let n=this.end._getTransformedBySplitOperation(e);return this.end.isEqual(e.insertionPosition)&&(n=this.end.getShiftedBy(1)),t.root!=n.root&&(n=this.end.getShiftedBy(-1)),new u(t,n)}_getTransformedByMergeOperation(e){if(this.start.isEqual(e.targetPosition)&&this.end.isEqual(e.deletionPosition))return new u(this.start);let t=this.start._getTransformedByMergeOperation(e),n=this.end._getTransformedByMergeOperation(e);return t.root!=n.root&&(n=this.end.getShiftedBy(-1)),t.isAfter(n)?(e.sourcePosition.isBefore(e.targetPosition)?(t=m._createAt(n),t.offset=0):(e.deletionPosition.isEqual(t)||(n=e.deletionPosition),t=e.targetPosition),new u(t,n)):new u(t,n)}_getTransformedByInsertion(e,t,n=!1){if(n&&this.containsPosition(e))return[new u(this.start,e),new u(e.getShiftedBy(t),this.end._getTransformedByInsertion(e,t))];{const r=new u(this.start,this.end);return r.start=r.start._getTransformedByInsertion(e,t),r.end=r.end._getTransformedByInsertion(e,t),[r]}}_getTransformedByMove(e,t,n,r=!1){if(this.isCollapsed){const d=this.start._getTransformedByMove(e,t,n);return[new u(d)]}const i=u._createFromPositionAndShift(e,n),o=t._getTransformedByDeletion(e,n);if(this.containsPosition(t)&&!r&&(i.containsPosition(this.start)||i.containsPosition(this.end))){const d=this.start._getTransformedByMove(e,t,n),p=this.end._getTransformedByMove(e,t,n);return[new u(d,p)]}let a;const l=this.getDifference(i);let c=null;const h=this.getIntersection(i);if(l.length==1?c=new u(l[0].start._getTransformedByDeletion(e,n),l[0].end._getTransformedByDeletion(e,n)):l.length==2&&(c=new u(this.start,this.end._getTransformedByDeletion(e,n))),c?a=c._getTransformedByInsertion(o,n,h!==null||r):a=[],h){const d=new u(h.start._getCombined(i.start,o),h.end._getCombined(i.start,o));a.length==2?a.splice(1,0,d):a.push(d)}return a}_getTransformedByDeletion(e,t){let n=this.start._getTransformedByDeletion(e,t),r=this.end._getTransformedByDeletion(e,t);return n==null&&r==null?null:(n==null&&(n=e),r==null&&(r=e),new u(n,r))}static _createFromPositionAndShift(e,t){const n=e,r=e.getShiftedBy(t);return t>0?new this(n,r):new this(r,n)}static _createIn(e){return new this(m._createAt(e,0),m._createAt(e,e.maxOffset))}static _createOn(e){return this._createFromPositionAndShift(m._createBefore(e),e.offsetSize)}static _createFromRanges(e){if(e.length===0)throw new f("range-create-from-ranges-empty-array",null);if(e.length==1)return e[0].clone();const t=e[0];e.sort((i,o)=>i.start.isAfter(o.start)?1:-1);const n=e.indexOf(t),r=new this(t.start,t.end);for(let i=n-1;i>=0&&e[i].end.isEqual(r.start);i--)r.start=m._createAt(e[i].start);for(let i=n+1;i<e.length&&e[i].start.isEqual(r.end);i++)r.end=m._createAt(e[i].end);return r}static fromJSON(e,t){return new this(m.fromJSON(e.start,t),m.fromJSON(e.end,t))}}u.prototype.is=function(s){return s==="range"||s==="model:range"};class as extends N(){_modelToViewMapping=new WeakMap;_viewToModelMapping=new WeakMap;_viewToModelLengthCallbacks=new Map;_markerNameToElements=new Map;_elementToMarkerNames=new Map;_deferredBindingRemovals=new Map;_unboundMarkerNames=new Set;_cache=new Xr;constructor(){super(),this.on("modelToViewPosition",(e,t)=>{if(t.viewPosition)return;const n=this._modelToViewMapping.get(t.modelPosition.parent);if(!n)throw new f("mapping-model-position-view-parent-not-found",this,{modelPosition:t.modelPosition});t.viewPosition=this.findPositionIn(n,t.modelPosition.offset)},{priority:"low"}),this.on("viewToModelPosition",(e,t)=>{if(t.modelPosition)return;const n=this.findMappedViewAncestor(t.viewPosition),r=this._viewToModelMapping.get(n),i=this._toModelOffset(t.viewPosition.parent,t.viewPosition.offset,n);t.modelPosition=m._createAt(r,i)},{priority:"low"})}bindElements(e,t){this._modelToViewMapping.set(e,t),this._viewToModelMapping.set(t,e)}unbindViewElement(e,t={}){const n=this.toModelElement(e);if(this._elementToMarkerNames.has(e))for(const r of this._elementToMarkerNames.get(e))this._unboundMarkerNames.add(r);t.defer?this._deferredBindingRemovals.set(e,e.root):(this._viewToModelMapping.delete(e)&&this._cache.stopTracking(e),this._modelToViewMapping.get(n)==e&&this._modelToViewMapping.delete(n))}unbindModelElement(e){const t=this.toViewElement(e);this._modelToViewMapping.delete(e),this._viewToModelMapping.get(t)==e&&this._viewToModelMapping.delete(t)&&this._cache.stopTracking(t)}bindElementToMarker(e,t){const n=this._markerNameToElements.get(t)||new Set;n.add(e);const r=this._elementToMarkerNames.get(e)||new Set;r.add(t),this._markerNameToElements.set(t,n),this._elementToMarkerNames.set(e,r)}unbindElementFromMarkerName(e,t){const n=this._markerNameToElements.get(t);n&&(n.delete(e),n.size==0&&this._markerNameToElements.delete(t));const r=this._elementToMarkerNames.get(e);r&&(r.delete(t),r.size==0&&this._elementToMarkerNames.delete(e))}flushUnboundMarkerNames(){const e=Array.from(this._unboundMarkerNames);return this._unboundMarkerNames.clear(),e}flushDeferredBindings(){for(const[e,t]of this._deferredBindingRemovals)e.root==t&&this.unbindViewElement(e);this._deferredBindingRemovals=new Map}clearBindings(){this._modelToViewMapping=new WeakMap,this._viewToModelMapping=new WeakMap,this._markerNameToElements=new Map,this._elementToMarkerNames=new Map,this._unboundMarkerNames=new Set,this._deferredBindingRemovals=new Map}toModelElement(e){return this._viewToModelMapping.get(e)}toViewElement(e){return this._modelToViewMapping.get(e)}toModelRange(e){return new u(this.toModelPosition(e.start),this.toModelPosition(e.end))}toViewRange(e){return new w(this.toViewPosition(e.start),this.toViewPosition(e.end))}toModelPosition(e){const t={viewPosition:e,mapper:this};return this.fire("viewToModelPosition",t),t.modelPosition}toViewPosition(e,t={}){const n={modelPosition:e,mapper:this,isPhantom:t.isPhantom};return this.fire("modelToViewPosition",n),n.viewPosition}markerNameToElements(e){const t=this._markerNameToElements.get(e);if(!t)return null;const n=new Set;for(const r of t)if(r.is("attributeElement"))for(const i of r.getElementsWithSameId())n.add(i);else n.add(r);return n}registerViewToModelLength(e,t){this._viewToModelLengthCallbacks.set(e,t)}findMappedViewAncestor(e){let t=e.parent;for(;!this._viewToModelMapping.has(t);)t=t.parent;return t}_toModelOffset(e,t,n){if(n!=e){const i=this._toModelOffset(e.parent,e.index,n),o=this._toModelOffset(e,t,e);return i+o}if(e.is("$text"))return t;let r=0;for(let i=0;i<t;i++)r+=this.getModelLength(e.getChild(i));return r}getModelLength(e){const t=[e];let n=0;for(;t.length>0;){const r=t.pop(),i=r.name&&this._viewToModelLengthCallbacks.size>0&&this._viewToModelLengthCallbacks.get(r.name);if(i)n+=i(r);else if(this._viewToModelMapping.has(r))n+=1;else if(r.is("$text"))n+=r.data.length;else{if(r.is("uiElement"))continue;for(const o of r.getChildren())t.push(o)}}return n}findPositionIn(e,t){if(t===0)return this._moveViewPositionToTextNode(new g(e,0));if(this._viewToModelLengthCallbacks.size==0&&this._viewToModelMapping.has(e)){const r=this._cache.getClosest(e,t);return this._findPositionStartingFrom(r.viewPosition,r.modelOffset,t,e,!0)}else return this._findPositionStartingFrom(new g(e,0),0,t,e,!1)}_findPositionStartingFrom(e,t,n,r,i){let o=e.parent,a=e.offset;if(o.is("$text"))return new g(o,n-t);let l,c=t,h=0;for(;c<n;){if(l=o.getChild(a),!l){if(o==r)throw new f("mapping-model-offset-not-found",this,{modelOffset:n,viewContainer:r});a=o.parent.getChildIndex(o)+1,o=o.parent,i&&this._cache.save(o,a,r,c);continue}i?h=this._getModelLengthAndCache(l,r,c):h=this.getModelLength(l),c+=h,a++}let d=new g(o,a);if(i)for(;d.isAtEnd&&d.parent!==r&&d.parent.parent;){const p=d.parent.parent,_=p.getChildIndex(d.parent)+1;this._cache.save(p,_,r,c),d=new g(p,_)}return c==n?this._moveViewPositionToTextNode(d):this._findPositionStartingFrom(new g(l,0),c-h,n,r,i)}_getModelLengthAndCache(e,t,n){let r=0;if(this._viewToModelMapping.has(e))r=1;else if(e.is("$text"))r=e.data.length;else if(!e.is("uiElement"))for(const i of e.getChildren())r+=this._getModelLengthAndCache(i,t,n+r);return this._cache.save(e.parent,e.index+1,t,n+r),r}_moveViewPositionToTextNode(e){const t=e.nodeBefore,n=e.nodeAfter;return t&&t.is("view:$text")?new g(t,t.data.length):n&&n.is("view:$text")?new g(n,0):e}}class Xr extends N(){_cachedMapping=new WeakMap;_nodeToCacheListIndex=new WeakMap;_invalidateOnChildrenChangeCallback=(e,t,n)=>{this._clearCacheInsideParent(t,n.index)};_invalidateOnTextChangeCallback=(e,t)=>{this._clearCacheAfter(t)};save(e,t,n,r){const i=this._cachedMapping.get(n),o=i.cacheMap.get(r);if(o){const h=e.getChild(t-1),d=o.viewPosition.nodeBefore?this._nodeToCacheListIndex.get(o.viewPosition.nodeBefore):0;this._nodeToCacheListIndex.set(h,d);return}const l={viewPosition:new g(e,t),modelOffset:r};i.maxModelOffset=r>i.maxModelOffset?r:i.maxModelOffset,i.cacheMap.set(r,l);let c=i.cacheList.length-1;for(;c>=0&&i.cacheList[c].modelOffset>r;)c--;if(i.cacheList.splice(c+1,0,l),t>0){const h=e.getChild(t-1);this._nodeToCacheListIndex.set(h,c+1)}}getClosest(e,t){const n=this._cachedMapping.get(e);let r;if(n)if(t>n.maxModelOffset)r=n.cacheList[n.cacheList.length-1];else{const i=n.cacheMap.get(t);i?r=i:r=this._findInCacheList(n.cacheList,t)}else r=this.startTracking(e);return{modelOffset:r.modelOffset,viewPosition:r.viewPosition.clone()}}startTracking(e){const n={viewPosition:new g(e,0),modelOffset:0},r={maxModelOffset:0,cacheList:[n],cacheMap:new Map([[0,n]])};return this._cachedMapping.set(e,r),e.on("change:children",this._invalidateOnChildrenChangeCallback),e.on("change:text",this._invalidateOnTextChangeCallback),n}stopTracking(e){e.off("change:children",this._invalidateOnChildrenChangeCallback),e.off("change:text",this._invalidateOnTextChangeCallback),this._cachedMapping.delete(e)}_clearCacheInsideParent(e,t){if(t==0)this._cachedMapping.has(e)?this._clearCacheAll(e):this._clearCacheInsideParent(e.parent,e.index);else{const n=e.getChild(t-1);this._clearCacheAfter(n)}}_clearCacheAll(e){const t=this._cachedMapping.get(e);t.maxModelOffset>0&&(t.maxModelOffset=0,t.cacheList.length=1,t.cacheMap.clear(),t.cacheMap.set(0,t.cacheList[0]))}_clearCacheAfter(e){const t=this._nodeToCacheListIndex.get(e);if(t===void 0){const r=e.parent;this._cachedMapping.has(r)||this._clearCacheInsideParent(r.parent,r.index);return}let n=e.parent;for(;!this._cachedMapping.has(n);)n=n.parent;this._clearCacheFromCacheIndex(n,t)}_clearCacheFromCacheIndex(e,t){t===0&&(t=1);const n=this._cachedMapping.get(e),r=n.cacheList[t-1];if(!r)return;n.maxModelOffset=r.modelOffset;const i=n.cacheList.splice(t);for(const o of i){n.cacheMap.delete(o.modelOffset);const a=o.viewPosition.nodeBefore;this._nodeToCacheListIndex.delete(a)}}_findInCacheList(e,t){let n=0,r=e.length-1,i=r-n>>1,o=e[i];for(;n<r;)o.modelOffset<t?n=i+1:r=i-1,i=n+(r-n>>1),o=e[i];return o.modelOffset<=t?o:e[i-1]}}class Yr{_consumable=new Map;_textProxyRegistry=new Map;add(e,t){t=nt(t),e instanceof j&&(e=this._getSymbolForTextProxy(e)),this._consumable.has(e)||this._consumable.set(e,new Map),this._consumable.get(e).set(t,!0)}consume(e,t){return t=nt(t),e instanceof j&&(e=this._getSymbolForTextProxy(e)),this.test(e,t)?(this._consumable.get(e).set(t,!1),!0):!1}test(e,t){t=nt(t),e instanceof j&&(e=this._getSymbolForTextProxy(e));const n=this._consumable.get(e);if(n===void 0)return null;const r=n.get(t);return r===void 0?null:r}revert(e,t){t=nt(t),e instanceof j&&(e=this._getSymbolForTextProxy(e));const n=this.test(e,t);return n===!1?(this._consumable.get(e).set(t,!0),!0):n===!0?!1:null}verifyAllConsumed(e){const t=[];for(const[n,r]of this._consumable)for(const[i,o]of r){const a=i.split(":")[0];o&&e==a&&t.push({event:i,item:n.name||n.description})}if(t.length)throw new f("conversion-model-consumable-not-consumed",null,{items:t})}_getSymbolForTextProxy(e){let t=null;const n=this._textProxyRegistry.get(e.startOffset);if(n){const r=n.get(e.endOffset);r&&(t=r.get(e.parent))}return t||(t=this._addSymbolForTextProxy(e)),t}_addSymbolForTextProxy(e){const t=e.startOffset,n=e.endOffset,r=e.parent,i=Symbol("$textProxy:"+e.data);let o,a;return o=this._textProxyRegistry.get(t),o||(o=new Map,this._textProxyRegistry.set(t,o)),a=o.get(n),a||(a=new Map,o.set(n,a)),a.set(r,i),i}}function nt(s){const e=s.split(":");return e[0]=="insert"?e[0]:e[0]=="addMarker"||e[0]=="removeMarker"?s:e.length>1?e[0]+":"+e[1]:e[0]}class ls extends N(){_conversionApi;_firedEventsMap;constructor(e){super(),this._conversionApi={dispatcher:this,...e},this._firedEventsMap=new WeakMap}convertChanges(e,t,n){const r=this._createConversionApi(n,e.getRefreshedItems());for(const o of e.getMarkersToRemove())this._convertMarkerRemove(o.name,o.range,r);const i=this._reduceChanges(e.getChanges());for(const o of i)o.type==="insert"?this._convertInsert(u._createFromPositionAndShift(o.position,o.length),r):o.type==="reinsert"?this._convertReinsert(u._createFromPositionAndShift(o.position,o.length),r):o.type==="remove"?this._convertRemove(o.position,o.length,o.name,r):this._convertAttribute(o.range,o.attributeKey,o.attributeOldValue,o.attributeNewValue,r);r.mapper.flushDeferredBindings();for(const o of r.mapper.flushUnboundMarkerNames()){const a=t.get(o).getRange();this._convertMarkerRemove(o,a,r),this._convertMarkerAdd(o,a,r)}for(const o of e.getMarkersToAdd())this._convertMarkerAdd(o.name,o.range,r);r.consumable.verifyAllConsumed("insert")}convert(e,t,n,r={}){const i=this._createConversionApi(n,void 0,r);this._convertInsert(e,i);for(const[o,a]of t)this._convertMarkerAdd(o,a,i);i.consumable.verifyAllConsumed("insert")}convertSelection(e,t,n){const r=this._createConversionApi(n);this.fire("cleanSelection",{selection:e},r);const i=e.getFirstPosition().root;if(!r.mapper.toViewElement(i))return;const o=Array.from(t.getMarkersAtPosition(e.getFirstPosition()));if(this._addConsumablesForSelection(r.consumable,e,o),this.fire("selection",{selection:e},r),!!e.isCollapsed){for(const a of o)if(r.consumable.test(e,"addMarker:"+a.name)){const l=a.getRange();if(!Qr(e.getFirstPosition(),a,r.mapper))continue;const c={item:e,markerName:a.name,markerRange:l};this.fire(`addMarker:${a.name}`,c,r)}for(const a of e.getAttributeKeys())if(r.consumable.test(e,"attribute:"+a)){const l={item:e,range:e.getFirstRange(),attributeKey:a,attributeOldValue:null,attributeNewValue:e.getAttribute(a)};this.fire(`attribute:${a}:$text`,l,r)}}}_convertInsert(e,t,n={}){n.doNotAddConsumables||this._addConsumablesForInsert(t.consumable,e);for(const r of e.getWalker({shallow:!0}))this._testAndFire("insert",bn(r),t)}_convertRemove(e,t,n,r){this.fire(`remove:${n}`,{position:e,length:t},r)}_convertAttribute(e,t,n,r,i){this._addConsumablesForRange(i.consumable,e,`attribute:${t}`);for(const o of e){const a={item:o.item,range:u._createFromPositionAndShift(o.previousPosition,o.length),attributeKey:t,attributeOldValue:n,attributeNewValue:r};this._testAndFire(`attribute:${t}`,a,i)}}_convertReinsert(e,t){const n=Array.from(e.getWalker({shallow:!0}));this._addConsumablesForInsert(t.consumable,n);for(const r of n.map(bn))this._testAndFire("insert",{...r,reconversion:!0},t)}_convertMarkerAdd(e,t,n){if(t.root.rootName=="$graveyard")return;const r=`addMarker:${e}`;if(n.consumable.add(t,r),this.fire(r,{markerName:e,markerRange:t},n),!!n.consumable.consume(t,r)){this._addConsumablesForRange(n.consumable,t,r);for(const i of t.getItems()){if(!n.consumable.test(i,r))continue;const o={item:i,range:u._createOn(i),markerName:e,markerRange:t};this.fire(r,o,n)}}}_convertMarkerRemove(e,t,n){t.root.rootName!="$graveyard"&&this.fire(`removeMarker:${e}`,{markerName:e,markerRange:t},n)}_reduceChanges(e){const t={changes:e};return this.fire("reduceChanges",t),t.changes}_addConsumablesForInsert(e,t){for(const n of t){const r=n.item;if(e.test(r,"insert")===null){e.add(r,"insert");for(const i of r.getAttributeKeys())e.add(r,"attribute:"+i)}}return e}_addConsumablesForRange(e,t,n){for(const r of t.getItems())e.add(r,n);return e}_addConsumablesForSelection(e,t,n){e.add(t,"selection");for(const r of n)e.add(t,"addMarker:"+r.name);for(const r of t.getAttributeKeys())e.add(t,"attribute:"+r);return e}_testAndFire(e,t,n){const r=Zr(e,t),i=t.item.is("$textProxy")?n.consumable._getSymbolForTextProxy(t.item):t.item,o=this._firedEventsMap.get(n),a=o.get(i);if(!a)o.set(i,new Set([r]));else if(!a.has(r))a.add(r);else return;this.fire(r,t,n)}_testAndFireAddAttributes(e,t){const n={item:e,range:u._createOn(e)};for(const r of n.item.getAttributeKeys())n.attributeKey=r,n.attributeOldValue=null,n.attributeNewValue=n.item.getAttribute(r),this._testAndFire(`attribute:${r}`,n,t)}_createConversionApi(e,t=new Set,n={}){const r={...this._conversionApi,consumable:new Yr,writer:e,options:n,convertItem:i=>this._convertInsert(u._createOn(i),r),convertChildren:i=>this._convertInsert(u._createIn(i),r,{doNotAddConsumables:!0}),convertAttributes:i=>this._testAndFireAddAttributes(i,r),canReuseView:i=>!t.has(r.mapper.toModelElement(i))};return this._firedEventsMap.set(r,new Map),r}}function Qr(s,e,t){const n=e.getRange(),r=Array.from(s.getAncestors());return r.shift(),r.reverse(),!r.some(o=>{if(n.containsItem(o))return!!t.toViewElement(o).getCustomProperty("addHighlight")})}function Zr(s,e){const t=e.item.is("element")?e.item.name:"$text";return`${s}:${t}`}function bn(s){return{item:s.item,range:u._createFromPositionAndShift(s.previousPosition,s.length)}}let ve=class extends he{parent=null;_attrs;_index=null;_startOffset=null;constructor(e){super(),this._attrs=pe(e)}get document(){return null}get index(){return this._index}get startOffset(){return this._startOffset}get offsetSize(){return 1}get endOffset(){return this.startOffset===null?null:this.startOffset+this.offsetSize}get nextSibling(){const e=this.index;return e!==null&&this.parent.getChild(e+1)||null}get previousSibling(){const e=this.index;return e!==null&&this.parent.getChild(e-1)||null}get root(){let e=this;for(;e.parent;)e=e.parent;return e}isAttached(){return this.parent===null?!1:this.root.isAttached()}getPath(){const e=[];let t=this;for(;t.parent;)e.unshift(t.startOffset),t=t.parent;return e}getAncestors(e={}){const t=[];let n=e.includeSelf?this:this.parent;for(;n;)t[e.parentFirst?"push":"unshift"](n),n=n.parent;return t}getCommonAncestor(e,t={}){const n=this.getAncestors(t),r=e.getAncestors(t);let i=0;for(;n[i]==r[i]&&n[i];)i++;return i===0?null:n[i-1]}isBefore(e){if(this==e||this.root!==e.root)return!1;const t=this.getPath(),n=e.getPath(),r=F(t,n);switch(r){case"prefix":return!0;case"extension":return!1;default:return t[r]<n[r]}}isAfter(e){return this==e||this.root!==e.root?!1:!this.isBefore(e)}hasAttribute(e){return this._attrs.has(e)}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}toJSON(){const e={};return this._attrs.size&&(e.attributes=Array.from(this._attrs).reduce((t,n)=>(t[n[0]]=n[1],t),{})),e}_clone(e){return new this.constructor(this._attrs)}_remove(){this.parent._removeChildren(this.index)}_setAttribute(e,t){this._attrs.set(e,t)}_setAttributesTo(e){this._attrs=pe(e)}_removeAttribute(e){return this._attrs.delete(e)}_clearAttributes(){this._attrs.clear()}};ve.prototype.is=function(s){return s==="node"||s==="model:node"};class $ extends N(he){_lastRangeBackward=!1;_attrs=new Map;_ranges=[];constructor(...e){super(),e.length&&this.setTo(...e)}get anchor(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.end:e.start}return null}get focus(){if(this._ranges.length>0){const e=this._ranges[this._ranges.length-1];return this._lastRangeBackward?e.start:e.end}return null}get isCollapsed(){return this._ranges.length===1?this._ranges[0].isCollapsed:!1}get rangeCount(){return this._ranges.length}get isBackward(){return!this.isCollapsed&&this._lastRangeBackward}isEqual(e){if(this.rangeCount!=e.rangeCount)return!1;if(this.rangeCount===0)return!0;if(!this.anchor.isEqual(e.anchor)||!this.focus.isEqual(e.focus))return!1;for(const t of this._ranges){let n=!1;for(const r of e._ranges)if(t.isEqual(r)){n=!0;break}if(!n)return!1}return!0}*getRanges(){for(const e of this._ranges)yield new u(e.start,e.end)}getFirstRange(){let e=null;for(const t of this._ranges)(!e||t.start.isBefore(e.start))&&(e=t);return e?new u(e.start,e.end):null}getLastRange(){let e=null;for(const t of this._ranges)(!e||t.end.isAfter(e.end))&&(e=t);return e?new u(e.start,e.end):null}getFirstPosition(){const e=this.getFirstRange();return e?e.start.clone():null}getLastPosition(){const e=this.getLastRange();return e?e.end.clone():null}setTo(...e){let[t,n,r]=e;if(typeof n=="object"&&(r=n,n=void 0),t===null)this._setRanges([]);else if(t instanceof $)this._setRanges(t.getRanges(),t.isBackward);else if(t&&typeof t.getRanges=="function")this._setRanges(t.getRanges(),t.isBackward);else if(t instanceof u)this._setRanges([t],!!r&&!!r.backward);else if(t instanceof m)this._setRanges([new u(t)]);else if(t instanceof ve){const i=!!r&&!!r.backward;let o;if(n=="in")o=u._createIn(t);else if(n=="on")o=u._createOn(t);else if(n!==void 0)o=new u(m._createAt(t,n));else throw new f("model-selection-setto-required-second-parameter",[this,t]);this._setRanges([o],i)}else if(le(t))this._setRanges(t,r&&!!r.backward);else throw new f("model-selection-setto-not-selectable",[this,t])}_setRanges(e,t=!1){const n=Array.from(e),r=n.some(i=>{if(!(i instanceof u))throw new f("model-selection-set-ranges-not-range",[this,e]);return this._ranges.every(o=>!o.isEqual(i))});n.length===this._ranges.length&&!r||(this._replaceAllRanges(n),this._lastRangeBackward=!!t,this.fire("change:range",{directChange:!0}))}setFocus(e,t){if(this.anchor===null)throw new f("model-selection-setfocus-no-ranges",[this,e]);const n=m._createAt(e,t);if(n.compareWith(this.focus)=="same")return;const r=this.anchor;this._ranges.length&&this._popRange(),n.compareWith(r)=="before"?(this._pushRange(new u(n,r)),this._lastRangeBackward=!0):(this._pushRange(new u(r,n)),this._lastRangeBackward=!1),this.fire("change:range",{directChange:!0})}getAttribute(e){return this._attrs.get(e)}getAttributes(){return this._attrs.entries()}getAttributeKeys(){return this._attrs.keys()}hasAttribute(e){return this._attrs.has(e)}removeAttribute(e){this.hasAttribute(e)&&(this._attrs.delete(e),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}setAttribute(e,t){this.getAttribute(e)!==t&&(this._attrs.set(e,t),this.fire("change:attribute",{attributeKeys:[e],directChange:!0}))}getSelectedElement(){return this.rangeCount!==1?null:this.getFirstRange().getContainedElement()}*getSelectedBlocks(){const e=new WeakSet;for(const t of this.getRanges()){const n=yn(t.start,e);ti(n,t)&&(yield n);const r=t.getWalker();for(const o of r){const a=o.item;o.type=="elementEnd"&&ei(a,e,t)?yield a:o.type=="elementStart"&&a.is("model:element")&&a.root.document.model.schema.isBlock(a)&&r.jumpTo(m._createAt(a,"end"))}const i=yn(t.end,e);ni(i,t)&&(yield i)}}containsEntireContent(e=this.anchor.root){const t=m._createAt(e,0),n=m._createAt(e,"end");return t.isTouching(this.getFirstPosition())&&n.isTouching(this.getLastPosition())}_pushRange(e){this._checkRange(e),this._ranges.push(new u(e.start,e.end))}_checkRange(e){for(let t=0;t<this._ranges.length;t++)if(e.isIntersecting(this._ranges[t]))throw new f("model-selection-range-intersects",[this,e],{addedRange:e,intersectingRange:this._ranges[t]})}_replaceAllRanges(e){this._removeAllRanges();for(const t of e)this._pushRange(t)}_removeAllRanges(){for(;this._ranges.length>0;)this._popRange()}_popRange(){this._ranges.pop()}}$.prototype.is=function(s){return s==="selection"||s==="model:selection"};function cs(s,e){return e.has(s)?!1:(e.add(s),s.root.document.model.schema.isBlock(s)&&!!s.parent)}function ei(s,e,t){return cs(s,e)&&Gt(s,t)}function yn(s,e){const n=s.parent.root.document.model.schema,r=s.parent.getAncestors({parentFirst:!0,includeSelf:!0});let i=!1;const o=r.find(a=>i?!1:(i=n.isLimit(a),!i&&cs(a,e)));return r.forEach(a=>e.add(a)),o}function Gt(s,e){const t=si(s);return t?!e.containsRange(u._createOn(t),!0):!0}function ti(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.start.isTouching(m._createAt(s,s.maxOffset))?!1:Gt(s,e):!1}function ni(s,e){return s?e.isCollapsed||s.isEmpty?!0:e.end.isTouching(m._createAt(s,0))?!1:Gt(s,e):!1}function si(s){const e=s.root.document.model.schema;let t=s.parent;for(;t;){if(e.isBlock(t))return t;t=t.parent}}class _e extends N(u){constructor(e,t){super(e,t),ri.call(this)}detach(){this.stopListening()}toRange(){return new u(this.start,this.end)}static fromRange(e){return new _e(e.start,e.end)}}_e.prototype.is=function(s){return s==="liveRange"||s==="model:liveRange"||s=="range"||s==="model:range"};function ri(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&ii.call(this,t)},{priority:"low"})}function ii(s){const e=this.getTransformedByOperation(s),t=u._createFromRanges(e),n=!t.isEqual(this),r=oi(this,s);let i=null;if(n){t.root.rootName=="$graveyard"&&(s.type=="remove"?i=s.sourcePosition:i=s.deletionPosition);const o=this.toRange();this.start=t.start,this.end=t.end,this.fire("change:range",o,{deletionPosition:i})}else r&&this.fire("change:content",this.toRange(),{deletionPosition:i})}function oi(s,e){switch(e.type){case"insert":return s.containsPosition(e.position);case"move":case"remove":case"reinsert":case"merge":return s.containsPosition(e.sourcePosition)||s.start.isEqual(e.sourcePosition)||s.containsPosition(e.targetPosition);case"split":return s.containsPosition(e.splitPosition)||s.containsPosition(e.insertionPosition)}return!1}class k extends ve{_data;constructor(e,t){super(t),this._data=e||""}get offsetSize(){return this.data.length}get data(){return this._data}toJSON(){const e=super.toJSON();return e.data=this.data,e}_clone(){return new k(this.data,this.getAttributes())}static fromJSON(e){return new k(e.data,e.attributes)}}k.prototype.is=function(s){return s==="$text"||s==="model:$text"||s==="text"||s==="model:text"||s==="node"||s==="model:node"};const Ke="selection:";class G extends N(he){_selection;constructor(e){super(),this._selection=new ai(e),this._selection.delegate("change:range").to(this),this._selection.delegate("change:attribute").to(this),this._selection.delegate("change:marker").to(this)}get isCollapsed(){return this._selection.isCollapsed}get anchor(){return this._selection.anchor}get focus(){return this._selection.focus}get rangeCount(){return this._selection.rangeCount}get hasOwnRange(){return this._selection.hasOwnRange}get isBackward(){return this._selection.isBackward}get isGravityOverridden(){return this._selection.isGravityOverridden}get markers(){return this._selection.markers}get _ranges(){return this._selection._ranges}getRanges(){return this._selection.getRanges()}getFirstPosition(){return this._selection.getFirstPosition()}getLastPosition(){return this._selection.getLastPosition()}getFirstRange(){return this._selection.getFirstRange()}getLastRange(){return this._selection.getLastRange()}getSelectedBlocks(){return this._selection.getSelectedBlocks()}getSelectedElement(){return this._selection.getSelectedElement()}containsEntireContent(e){return this._selection.containsEntireContent(e)}destroy(){this._selection.destroy()}getAttributeKeys(){return this._selection.getAttributeKeys()}getAttributes(){return this._selection.getAttributes()}getAttribute(e){return this._selection.getAttribute(e)}hasAttribute(e){return this._selection.hasAttribute(e)}refresh(){this._selection.updateMarkers(),this._selection._updateAttributes(!1)}observeMarkers(e){this._selection.observeMarkers(e)}_setFocus(e,t){this._selection.setFocus(e,t)}_setTo(...e){this._selection.setTo(...e)}_setAttribute(e,t){this._selection.setAttribute(e,t)}_removeAttribute(e){this._selection.removeAttribute(e)}_getStoredAttributes(){return this._selection.getStoredAttributes()}_overrideGravity(){return this._selection.overrideGravity()}_restoreGravity(e){this._selection.restoreGravity(e)}static _getStoreAttributeKey(e){return Ke+e}static _isStoreAttributeKey(e){return e.startsWith(Ke)}}G.prototype.is=function(s){return s==="selection"||s=="model:selection"||s=="documentSelection"||s=="model:documentSelection"};class ai extends ${markers=new Lt({idProperty:"name"});_model;_document;_attributePriority=new Map;_selectionRestorePosition=null;_hasChangedRange=!1;_overriddenGravityRegister=new Set;_observedMarkers=new Set;constructor(e){super(),this._model=e.model,this._document=e,this.listenTo(this._model,"applyOperation",(t,n)=>{const r=n[0];!r.isDocumentOperation||r.type=="marker"||r.type=="rename"||r.type=="noop"||(this._ranges.length==0&&this._selectionRestorePosition&&this._fixGraveyardSelection(this._selectionRestorePosition),this._selectionRestorePosition=null,this._hasChangedRange&&(this._hasChangedRange=!1,this.fire("change:range",{directChange:!1})))},{priority:"lowest"}),this.on("change:range",()=>{this._validateSelectionRanges(this.getRanges())}),this.listenTo(this._model.markers,"update",(t,n,r,i)=>{this._updateMarker(n,i)}),this.listenTo(this._document,"change",(t,n)=>{li(this._model,n)})}get isCollapsed(){return this._ranges.length===0?this._document._getDefaultRange().isCollapsed:super.isCollapsed}get anchor(){return super.anchor||this._document._getDefaultRange().start}get focus(){return super.focus||this._document._getDefaultRange().end}get rangeCount(){return this._ranges.length?this._ranges.length:1}get hasOwnRange(){return this._ranges.length>0}get isGravityOverridden(){return!!this._overriddenGravityRegister.size}destroy(){for(let e=0;e<this._ranges.length;e++)this._ranges[e].detach();this.stopListening()}*getRanges(){this._ranges.length?yield*super.getRanges():yield this._document._getDefaultRange()}getFirstRange(){return super.getFirstRange()||this._document._getDefaultRange()}getLastRange(){return super.getLastRange()||this._document._getDefaultRange()}setTo(...e){super.setTo(...e),this._updateAttributes(!0),this.updateMarkers()}setFocus(e,t){super.setFocus(e,t),this._updateAttributes(!0),this.updateMarkers()}setAttribute(e,t){if(this._setAttribute(e,t)){const n=[e];this.fire("change:attribute",{attributeKeys:n,directChange:!0})}}removeAttribute(e){if(this._removeAttribute(e)){const t=[e];this.fire("change:attribute",{attributeKeys:t,directChange:!0})}}overrideGravity(){const e=Fs();return this._overriddenGravityRegister.add(e),this._overriddenGravityRegister.size===1&&this._updateAttributes(!0),e}restoreGravity(e){if(!this._overriddenGravityRegister.has(e))throw new f("document-selection-gravity-wrong-restore",this,{uid:e});this._overriddenGravityRegister.delete(e),this.isGravityOverridden||this._updateAttributes(!0)}observeMarkers(e){this._observedMarkers.add(e),this.updateMarkers()}_replaceAllRanges(e){this._validateSelectionRanges(e),super._replaceAllRanges(e)}_popRange(){this._ranges.pop().detach()}_pushRange(e){const t=this._prepareRange(e);t&&this._ranges.push(t)}_validateSelectionRanges(e){for(const t of e)if(!this._document._validateSelectionRange(t))throw new f("document-selection-wrong-position",this,{range:t})}_prepareRange(e){if(this._checkRange(e),e.root==this._document.graveyard)return;const t=_e.fromRange(e);return t.on("change:range",(n,r,i)=>{if(this._hasChangedRange=!0,t.root==this._document.graveyard){this._selectionRestorePosition=i.deletionPosition;const o=this._ranges.indexOf(t);this._ranges.splice(o,1),t.detach()}}),t}updateMarkers(){if(!this._observedMarkers.size)return;const e=[];let t=!1;for(const r of this._model.markers){const i=r.name.split(":",1)[0];if(!this._observedMarkers.has(i))continue;const o=r.getRange();for(const a of this.getRanges())o.containsRange(a,!a.isCollapsed)&&e.push(r)}const n=Array.from(this.markers);for(const r of e)this.markers.has(r)||(this.markers.add(r),t=!0);for(const r of Array.from(this.markers))e.includes(r)||(this.markers.remove(r),t=!0);t&&this.fire("change:marker",{oldMarkers:n,directChange:!1})}_updateMarker(e,t){const n=e.name.split(":",1)[0];if(!this._observedMarkers.has(n))return;let r=!1;const i=Array.from(this.markers),o=this.markers.has(e);if(!t)o&&(this.markers.remove(e),r=!0);else{let a=!1;for(const l of this.getRanges())if(t.containsRange(l,!l.isCollapsed)){a=!0;break}a&&!o?(this.markers.add(e),r=!0):!a&&o&&(this.markers.remove(e),r=!0)}r&&this.fire("change:marker",{oldMarkers:i,directChange:!1})}_updateAttributes(e){const t=pe(this._getSurroundingAttributes()),n=pe(this.getAttributes());if(e)this._attributePriority=new Map,this._attrs=new Map;else for(const[i,o]of this._attributePriority)o=="low"&&(this._attrs.delete(i),this._attributePriority.delete(i));this._setAttributesTo(t);const r=[];for(const[i,o]of this.getAttributes())(!n.has(i)||n.get(i)!==o)&&r.push(i);for(const[i]of n)this.hasAttribute(i)||r.push(i);r.length>0&&this.fire("change:attribute",{attributeKeys:r,directChange:!1})}_setAttribute(e,t,n=!0){const r=n?"normal":"low";return r=="low"&&this._attributePriority.get(e)=="normal"||super.getAttribute(e)===t?!1:(this._attrs.set(e,t),this._attributePriority.set(e,r),!0)}_removeAttribute(e,t=!0){const n=t?"normal":"low";return n=="low"&&this._attributePriority.get(e)=="normal"||(this._attributePriority.set(e,n),!super.hasAttribute(e))?!1:(this._attrs.delete(e),!0)}_setAttributesTo(e){const t=new Set;for(const[n,r]of this.getAttributes())e.get(n)!==r&&this._removeAttribute(n,!1);for(const[n,r]of e)this._setAttribute(n,r,!1)&&t.add(n);return t}*getStoredAttributes(){const e=this.getFirstPosition().parent;if(this.isCollapsed&&e.isEmpty)for(const t of e.getAttributeKeys())t.startsWith(Ke)&&(yield[t.substr(Ke.length),e.getAttribute(t)])}_getSurroundingAttributes(){const e=this.getFirstPosition(),t=this._model.schema;if(e.root.rootName=="$graveyard")return null;let n=null;if(this.isCollapsed){const r=e.textNode?e.textNode:e.nodeBefore,i=e.textNode?e.textNode:e.nodeAfter;if(this.isGravityOverridden||(n=De(r,t)),n||(n=De(i,t)),!this.isGravityOverridden&&!n){let o=r;for(;o&&!n;)o=o.previousSibling,n=De(o,t)}if(!n){let o=i;for(;o&&!n;)o=o.nextSibling,n=De(o,t)}n||(n=this.getStoredAttributes())}else{const r=this.getFirstRange();for(const i of r){if(i.item.is("element")&&t.isObject(i.item)){n=De(i.item,t);break}if(i.type=="text"){n=i.item.getAttributes();break}}}return n}_fixGraveyardSelection(e){const t=this._model.schema.getNearestSelectionRange(e);t&&this._pushRange(t)}}function De(s,e){if(!s)return null;if(s instanceof j||s instanceof k)return s.getAttributes();if(!e.isInline(s))return null;if(!e.isObject(s))return[];const t=[];for(const[n,r]of s.getAttributes())e.checkAttribute("$text",n)&&e.getAttributeProperties(n).copyFromObject!==!1&&t.push([n,r]);return t}function li(s,e){const t=s.document.differ;for(const n of t.getChanges()){if(n.type!="insert")continue;const r=n.position.parent;n.length===r.maxOffset&&s.enqueueChange(e,o=>{const a=Array.from(r.getAttributeKeys()).filter(l=>l.startsWith(Ke));for(const l of a)o.removeAttribute(l,r)})}}class ze{_nodes=[];_offsetToNode=[];constructor(e){e&&this._insertNodes(0,e)}[Symbol.iterator](){return this._nodes[Symbol.iterator]()}get length(){return this._nodes.length}get maxOffset(){return this._offsetToNode.length}getNode(e){return this._nodes[e]||null}getNodeAtOffset(e){return this._offsetToNode[e]||null}getNodeIndex(e){return e.index}getNodeStartOffset(e){return e.startOffset}indexToOffset(e){if(e==this._nodes.length)return this.maxOffset;const t=this._nodes[e];if(!t)throw new f("model-nodelist-index-out-of-bounds",this);return this.getNodeStartOffset(t)}offsetToIndex(e){if(e==this._offsetToNode.length)return this._nodes.length;const t=this._offsetToNode[e];if(!t)throw new f("model-nodelist-offset-out-of-bounds",this,{offset:e,nodeList:this});return this.getNodeIndex(t)}_insertNodes(e,t){const n=[];for(const i of t){if(!(i instanceof ve))throw new f("model-nodelist-insertnodes-not-node",this);n.push(i)}let r=this.indexToOffset(e);en(this._nodes,n,e),en(this._offsetToNode,ci(n),r);for(let i=e;i<this._nodes.length;i++)this._nodes[i]._index=i,this._nodes[i]._startOffset=r,r+=this._nodes[i].offsetSize}_removeNodes(e,t=1){if(t==0)return[];let n=this.indexToOffset(e);const r=this._nodes.splice(e,t),i=r[r.length-1],o=i.startOffset+i.offsetSize-n;this._offsetToNode.splice(n,o);for(const a of r)a._index=null,a._startOffset=null;for(let a=e;a<this._nodes.length;a++)this._nodes[a]._index=a,this._nodes[a]._startOffset=n,n+=this._nodes[a].offsetSize;return r}_removeNodesArray(e){if(e.length==0)return;for(const n of e)n._index=null,n._startOffset=null;this._nodes=this._nodes.filter(n=>n.index!==null),this._offsetToNode=this._offsetToNode.filter(n=>n.index!==null);let t=0;for(let n=0;n<this._nodes.length;n++)this._nodes[n]._index=n,this._nodes[n]._startOffset=t,t+=this._nodes[n].offsetSize}toJSON(){return this._nodes.map(e=>e.toJSON())}}function ci(s){const e=[];let t=0;for(const n of s)for(let r=0;r<n.offsetSize;r++)e[t++]=n;return e}class C extends ve{name;_children=new ze;constructor(e,t,n){super(t),this.name=e,n&&this._insertChild(0,n)}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}offsetToIndex(e){return this._children.offsetToIndex(e)}getNodeByPath(e){let t=this;for(const n of e)t=t.getChildAtOffset(n);return t}findAncestor(e,t={}){let n=t.includeSelf?this:this.parent;for(;n;){if(n.name===e)return n;n=n.parent}return null}toJSON(){const e=super.toJSON();if(e.name=this.name,this._children.length>0){e.children=[];for(const t of this._children)e.children.push(t.toJSON())}return e}_clone(e=!1){const t=e?ui(this._children):void 0;return new C(this.name,this.getAttributes(),t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=hi(t);for(const r of n)r.parent!==null&&r._remove(),r.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const r of n)r.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}static fromJSON(e){let t;if(e.children){t=[];for(const n of e.children)n.name?t.push(C.fromJSON(n)):t.push(k.fromJSON(n))}return new C(e.name,e.attributes,t)}}C.prototype.is=function(s,e){return e?e===this.name&&(s==="element"||s==="model:element"):s==="element"||s==="model:element"||s==="node"||s==="model:node"};function hi(s){if(typeof s=="string")return[new k(s)];le(s)||(s=[s]);const e=[];for(const t of s)typeof t=="string"?e.push(new k(t)):t instanceof j?e.push(new k(t.data,t.getAttributes())):e.push(t);return e}function ui(s){const e=[];for(const t of s)e.push(t._clone(!0));return e}/**
16
16
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
17
17
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
18
- */class fs{constructor(t){c(this,"_dispatchers");this._dispatchers=t}add(t){for(const e of this._dispatchers)t(e);return this}}class pi extends fs{elementToElement(t){return this.add(Ii(t))}elementToStructure(t){return this.add(Fi(t))}attributeToElement(t){return this.add(Bi(t))}attributeToAttribute(t){return this.add(Di(t))}markerToElement(t){return this.add(Vi(t))}markerToHighlight(t){return this.add(Li(t))}markerToData(t){return this.add($i(t))}}function ds(){return(r,t,e)=>{if(!e.consumable.consume(t.item,r.name))return;const n=e.writer,s=e.mapper.toViewPosition(t.range.start),i=n.createText(t.item.data);n.insert(s,i)}}function ms(){return(r,t,e)=>{e.convertAttributes(t.item),!t.reconversion&&t.item.is("element")&&!t.item.isEmpty&&e.convertChildren(t.item)}}function _i(){return(r,t,e)=>{const n=e.mapper.toViewPosition(t.position),s=t.position.getShiftedBy(t.length),i=e.mapper.toViewPosition(s,{isPhantom:!0}),o=e.writer.createRange(n,i),a=e.writer.remove(o.getTrimmed());for(const l of e.writer.createRangeIn(a).getItems())e.mapper.unbindViewElement(l,{defer:!0})}}function gs(r,t){const e=r.createAttributeElement("span",t.attributes);return t.classes&&e._addClass(t.classes),typeof t.priority=="number"&&(e._priority=t.priority),e._id=t.id,e}function wi(){return(r,t,e)=>{const n=t.selection;if(n.isCollapsed||!e.consumable.consume(n,"selection"))return;const s=[];for(const i of n.getRanges())s.push(e.mapper.toViewRange(i));e.writer.setSelection(s,{backward:n.isBackward})}}function bi(){return(r,t,e)=>{const n=t.selection;if(!n.isCollapsed||!e.consumable.consume(n,"selection"))return;const s=e.writer,i=n.getFirstPosition(),o=e.mapper.toViewPosition(i),a=s.breakAttributes(o);s.setSelection(a)}}function yi(){return(r,t,e)=>{const n=e.writer,s=n.document.selection;for(const i of s.getRanges())i.isCollapsed&&i.end.parent.isAttached()&&e.writer.mergeAttributes(i.start);n.setSelection(null)}}function vi(r){return(t,e,n)=>{if(!n.consumable.test(e.item,t.name))return;const s=r(e.attributeOldValue,n,e),i=r(e.attributeNewValue,n,e);if(!s&&!i)return;n.consumable.consume(e.item,t.name);const o=n.writer,a=o.document.selection;if(e.item instanceof L||e.item instanceof H)o.wrap(a.getFirstRange(),i);else{let l=n.mapper.toViewRange(e.range);e.attributeOldValue!==null&&s&&(l=o.unwrap(l,s)),e.attributeNewValue!==null&&i&&o.wrap(l,i)}}}function Pi(r,t=Gi){return(e,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const i=r(n.item,s,n);if(!i)return;t(n.item,s.consumable);const o=s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,i),s.writer.insert(o,i),s.convertAttributes(n.item),ys(i,n.item.getChildren(),s,{reconversion:n.reconversion})}}function Ci(r,t){return(e,n,s)=>{if(!t(n.item,s.consumable,{preflight:!0}))return;const i=new Map;s.writer._registerSlotFactory(zi(n.item,i,s));const o=r(n.item,s,n);if(s.writer._clearSlotFactory(),!o)return;Ui(n.item,i,s),t(n.item,s.consumable);const a=s.mapper.toViewPosition(n.range.start);s.mapper.bindElements(n.item,o),s.writer.insert(a,o),s.convertAttributes(n.item),Ji(o,i,s,{reconversion:n.reconversion})}}function ki(r){return(t,e,n)=>{e.isOpening=!0;const s=r(e,n);e.isOpening=!1;const i=r(e,n);if(!s||!i)return;const o=e.markerRange;if(o.isCollapsed&&!n.consumable.consume(o,t.name))return;for(const h of o)if(!n.consumable.consume(h.item,t.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(o.start),s),n.mapper.bindElementToMarker(s,e.markerName),o.isCollapsed||(l.insert(a.toViewPosition(o.end),i),n.mapper.bindElementToMarker(i,e.markerName)),t.stop()}}function Ai(){return(r,t,e)=>{const n=e.mapper.markerNameToElements(t.markerName);if(n){for(const s of n)e.mapper.unbindElementFromMarkerName(s,t.markerName),e.writer.clear(e.writer.createRangeOn(s),s);e.writer.clearClonedElementsGroup(t.markerName),r.stop()}}}function Si(r){return(t,e,n)=>{const s=r(e.markerName,n);if(!s)return;const i=e.markerRange;n.consumable.consume(i,t.name)&&(Cn(i,!1,n,e,s),Cn(i,!0,n,e,s),t.stop())}}function Cn(r,t,e,n,s){const i=t?r.start:r.end,o=i.nodeAfter&&i.nodeAfter.is("element")?i.nodeAfter:null,a=i.nodeBefore&&i.nodeBefore.is("element")?i.nodeBefore:null;if(o||a){let h,u;t&&o||!t&&!a?(h=o,u=!0):(h=a,u=!1);const m=e.mapper.toViewElement(h);if(m){Ei(m,t,u,e,n,s);return}}const l=e.mapper.toViewPosition(i);Ri(l,t,e,n,s)}function Ei(r,t,e,n,s,i){const o=`data-${i.group}-${t?"start":"end"}-${e?"before":"after"}`,a=r.hasAttribute(o)?r.getAttribute(o).split(","):[];a.unshift(i.name),n.writer.setAttribute(o,a.join(","),r),n.mapper.bindElementToMarker(r,s.markerName)}function Ri(r,t,e,n,s){const i=`${s.group}-${t?"start":"end"}`,o=s.name?{name:s.name}:null,a=e.writer.createUIElement(i,o);e.writer.insert(r,a),e.mapper.bindElementToMarker(a,n.markerName)}function Ti(r){return(t,e,n)=>{const s=r(e.markerName,n);if(!s)return;const i=n.mapper.markerNameToElements(e.markerName);if(!i)return;for(const a of i)n.mapper.unbindElementFromMarkerName(a,e.markerName),a.is("containerElement")?(o(`data-${s.group}-start-before`,a),o(`data-${s.group}-start-after`,a),o(`data-${s.group}-end-before`,a),o(`data-${s.group}-end-after`,a)):n.writer.clear(n.writer.createRangeOn(a),a);n.writer.clearClonedElementsGroup(e.markerName),t.stop();function o(a,l){if(l.hasAttribute(a)){const h=new Set(l.getAttribute(a).split(","));h.delete(s.name),h.size==0?n.writer.removeAttribute(a,l):n.writer.setAttribute(a,Array.from(h).join(","),l)}}}}function Mi(r){return(t,e,n)=>{if(!n.consumable.test(e.item,t.name))return;const s=r(e.attributeOldValue,n,e),i=r(e.attributeNewValue,n,e);if(!s&&!i)return;n.consumable.consume(e.item,t.name);const o=n.mapper.toViewElement(e.item),a=n.writer;if(!o)throw new d("conversion-attribute-to-attribute-on-text",n.dispatcher,e);if(e.attributeOldValue!==null&&s){let l=s.value;s.key=="style"&&(typeof s.value=="string"?l=new qe(a.document.stylesProcessor).setTo(s.value).getStylesEntries().map(([h])=>h):l=Object.keys(s.value)),a.removeAttribute(s.key,l,o)}if(e.attributeNewValue!==null&&i){let l=i.value;i.key=="style"&&typeof i.value=="string"&&(l=Object.fromEntries(new qe(a.document.stylesProcessor).setTo(i.value).getStylesEntries())),a.setAttribute(i.key,l,!1,o)}}}function xi(r){return(t,e,n)=>{if(!e.item||!(e.item instanceof L||e.item instanceof H)&&!e.item.is("$textProxy"))return;const s=Xt(r,e,n);if(!s||!n.consumable.consume(e.item,t.name))return;const i=n.writer,o=gs(i,s),a=i.document.selection;if(e.item instanceof L||e.item instanceof H)i.wrap(a.getFirstRange(),o);else{const l=n.mapper.toViewRange(e.range),h=i.wrap(l,o);for(const u of h.getItems())if(u.is("attributeElement")&&u.isSimilar(o)){n.mapper.bindElementToMarker(u,e.markerName);break}}}}function Ni(r){return(t,e,n)=>{if(!e.item||!(e.item instanceof k))return;const s=Xt(r,e,n);if(!s||!n.consumable.test(e.item,t.name))return;const i=n.mapper.toViewElement(e.item);if(i&&i.getCustomProperty("addHighlight")){n.consumable.consume(e.item,t.name);for(const a of f._createIn(e.item))n.consumable.consume(a.item,t.name);i.getCustomProperty("addHighlight")(i,s,n.writer),n.mapper.bindElementToMarker(i,e.markerName)}}}function Oi(r){return(t,e,n)=>{if(e.markerRange.isCollapsed)return;const s=Xt(r,e,n);if(!s)return;const i=gs(n.writer,s),o=n.mapper.markerNameToElements(e.markerName);if(o){for(const a of o)n.mapper.unbindElementFromMarkerName(a,e.markerName),a.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(a),i):a.getCustomProperty("removeHighlight")(a,s.id,n.writer);n.writer.clearClonedElementsGroup(e.markerName),t.stop()}}}function Ii(r){const t=ps(r.model),e=Qe(r.view,"container");return t.attributes.length&&(t.children=!0),n=>{n.on(`insert:${t.name}`,Pi(e,bs(t)),{priority:r.converterPriority||"normal"}),(t.children||t.attributes.length)&&n.on("reduceChanges",ws(t),{priority:"low"})}}function Fi(r){const t=ps(r.model),e=Qe(r.view,"container");return t.children=!0,n=>{if(n._conversionApi.schema.checkChild(t.name,"$text"))throw new d("conversion-element-to-structure-disallowed-text",n,{elementName:t.name});n.on(`insert:${t.name}`,Ci(e,bs(t)),{priority:r.converterPriority||"normal"}),n.on("reduceChanges",ws(t),{priority:"low"})}}function Bi(r){r=he(r);let t=r.model;typeof t=="string"&&(t={key:t});let e=`attribute:${t.key}`;if(t.name&&(e+=":"+t.name),t.values)for(const s of t.values)r.view[s]=Qe(r.view[s],"attribute");else r.view=Qe(r.view,"attribute");const n=_s(r);return s=>{s.on(e,vi(n),{priority:r.converterPriority||"normal"})}}function Di(r){r=he(r);let t=r.model;typeof t=="string"&&(t={key:t});let e=`attribute:${t.key}`;if(t.name&&(e+=":"+t.name),t.values)for(const s of t.values)r.view[s]=kn(r.view[s]);else r.view=kn(r.view);const n=_s(r);return s=>{s.on(e,Mi(n),{priority:r.converterPriority||"normal"})}}function Vi(r){const t=Qe(r.view,"ui");return e=>{e.on(`addMarker:${r.model}`,ki(t),{priority:r.converterPriority||"normal"}),e.on(`removeMarker:${r.model}`,Ai(),{priority:r.converterPriority||"normal"})}}function $i(r){r=he(r);const t=r.model;let e=r.view;return e||(e=n=>({group:t,name:n.substr(r.model.length+1)})),n=>{n.on(`addMarker:${t}`,Si(e),{priority:r.converterPriority||"normal"}),n.on(`removeMarker:${t}`,Ti(e),{priority:r.converterPriority||"normal"})}}function Li(r){return t=>{t.on(`addMarker:${r.model}`,xi(r.view),{priority:r.converterPriority||"normal"}),t.on(`addMarker:${r.model}`,Ni(r.view),{priority:r.converterPriority||"normal"}),t.on(`removeMarker:${r.model}`,Oi(r.view),{priority:r.converterPriority||"normal"})}}function ps(r){return typeof r=="string"&&(r={name:r}),{name:r.name,attributes:r.attributes?le(r.attributes):[],children:!!r.children}}function Qe(r,t){return typeof r=="function"?r:(e,n)=>Wi(r,n,t)}function Wi(r,t,e){typeof r=="string"&&(r={name:r});let n;const s=t.writer,i=Object.assign({},r.attributes);if(e=="container")n=s.createContainerElement(r.name,i);else if(e=="attribute"){const o={priority:r.priority||pe.DEFAULT_PRIORITY};n=s.createAttributeElement(r.name,i,o)}else n=s.createUIElement(r.name,i);if(r.styles){const o=Object.keys(r.styles);for(const a of o)s.setStyle(a,r.styles[a],n)}if(r.classes){const o=r.classes;if(typeof o=="string")s.addClass(o,n);else for(const a of o)s.addClass(a,n)}return n}function _s(r){return r.model.values?(t,e,n)=>{const s=r.view[t];return s?s(t,e,n):null}:r.view}function kn(r){return typeof r=="string"?t=>({key:r,value:t}):typeof r=="object"?r.value?()=>r:t=>({key:r.key,value:t}):r}function Xt(r,t,e){const n=typeof r=="function"?r(t,e):r;return n?(n.priority||(n.priority=10),n.id||(n.id=t.markerName),n):null}function qi(r){return(t,e)=>{if(!t.is("element",r.name))return!1;if(e.type=="attribute"){if(r.attributes.includes(e.attributeKey))return!0}else{/* istanbul ignore else: This is always true because otherwise it would not register a reducer callback. -- @preserve */if(r.children)return!0}return!1}}function ws(r){const t=qi(r);return(e,n)=>{const s=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const i of n.changes){const o=i.type=="attribute"?i.range.start.nodeAfter:i.position.parent;if(!o||!t(o,i)){s.push(i);continue}if(!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const a=g._createBefore(o);let l=s.length;for(let h=s.length-1;h>=0;h--){const u=s[h],p=(u.type=="attribute"?u.range.start:u.position).compareWith(a);if(p=="before"||u.type=="remove"&&p=="same")break;l=h}s.splice(l,0,{type:"remove",name:o.name,position:a,length:1},{type:"reinsert",name:o.name,position:a,length:1})}}n.changes=s}}function bs(r){return(t,e,n={})=>{const s=["insert"];for(const i of r.attributes)t.hasAttribute(i)&&s.push(`attribute:${i}`);return s.every(i=>e.test(t,i))?(n.preflight||s.forEach(i=>e.consume(t,i)),!0):!1}}function zi(r,t,e){return(n,s)=>{const i=n.createContainerElement("$slot");let o=null;if(s==="children")o=Array.from(r.getChildren());else if(typeof s=="function")o=Array.from(r.getChildren()).filter(a=>s(a));else throw new d("conversion-slot-mode-unknown",e.dispatcher,{modeOrFilter:s});return t.set(i,o),i}}function Ui(r,t,e){const n=Array.from(t.values()).flat(),s=new Set(n);if(s.size!=n.length)throw new d("conversion-slot-filter-overlap",e.dispatcher,{element:r});if(s.size!=r.childCount)throw new d("conversion-slot-filter-incomplete",e.dispatcher,{element:r})}function Ji(r,t,e,n){e.mapper.on("modelToViewPosition",o,{priority:"highest"});let s=null,i=null;for([s,i]of t)ys(r,i,e,n),e.writer.move(e.writer.createRangeIn(s),e.writer.createPositionBefore(s)),e.writer.remove(s);e.mapper.off("modelToViewPosition",o);function o(a,l){const h=l.modelPosition.nodeAfter,u=i.indexOf(h);u<0||(l.viewPosition=l.mapper.findPositionIn(s,u))}}function ys(r,t,e,n){for(const s of t)ji(r.root,s,e,n)||e.convertItem(s)}function ji(r,t,e,n){const{writer:s,mapper:i}=e;if(!n.reconversion)return!1;const o=i.toViewElement(t);return!o||o.root==r||!e.canReuseView(o)?!1:(s.move(s.createRangeOn(o),i.toViewPosition(g._createBefore(t))),!0)}function Gi(r,t,{preflight:e}={}){return e?t.test(r,"insert"):t.consume(r,"insert")}/**
18
+ */class hs{_dispatchers;constructor(e){this._dispatchers=e}add(e){for(const t of this._dispatchers)e(t);return this}}class fi extends hs{elementToElement(e){return this.add(Mi(e))}elementToStructure(e){return this.add(xi(e))}attributeToElement(e){return this.add(Ni(e))}attributeToAttribute(e){return this.add(Oi(e))}markerToElement(e){return this.add(Ii(e))}markerToHighlight(e){return this.add(Di(e))}markerToData(e){return this.add(Fi(e))}}function us(){return(s,e,t)=>{if(!t.consumable.consume(e.item,s.name))return;const n=t.writer,r=t.mapper.toViewPosition(e.range.start),i=n.createText(e.item.data);n.insert(r,i)}}function fs(){return(s,e,t)=>{t.convertAttributes(e.item),!e.reconversion&&e.item.is("element")&&!e.item.isEmpty&&t.convertChildren(e.item)}}function di(){return(s,e,t)=>{const n=t.mapper.toViewPosition(e.position),r=e.position.getShiftedBy(e.length),i=t.mapper.toViewPosition(r,{isPhantom:!0}),o=t.writer.createRange(n,i),a=t.writer.remove(o.getTrimmed());for(const l of t.writer.createRangeIn(a).getItems())t.mapper.unbindViewElement(l,{defer:!0})}}function ds(s,e){const t=s.createAttributeElement("span",e.attributes);return e.classes&&t._addClass(e.classes),typeof e.priority=="number"&&(t._priority=e.priority),t._id=e.id,t}function mi(){return(s,e,t)=>{const n=e.selection;if(n.isCollapsed||!t.consumable.consume(n,"selection"))return;const r=[];for(const i of n.getRanges())r.push(t.mapper.toViewRange(i));t.writer.setSelection(r,{backward:n.isBackward})}}function gi(){return(s,e,t)=>{const n=e.selection;if(!n.isCollapsed||!t.consumable.consume(n,"selection"))return;const r=t.writer,i=n.getFirstPosition(),o=t.mapper.toViewPosition(i),a=r.breakAttributes(o);r.setSelection(a)}}function pi(){return(s,e,t)=>{const n=t.writer,r=n.document.selection;for(const i of r.getRanges())i.isCollapsed&&i.end.parent.isAttached()&&t.writer.mergeAttributes(i.start);n.setSelection(null)}}function _i(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const r=s(t.attributeOldValue,n,t),i=s(t.attributeNewValue,n,t);if(!r&&!i)return;n.consumable.consume(t.item,e.name);const o=n.writer,a=o.document.selection;if(t.item instanceof $||t.item instanceof G)o.wrap(a.getFirstRange(),i);else{let l=n.mapper.toViewRange(t.range);t.attributeOldValue!==null&&r&&(l=o.unwrap(l,r)),t.attributeNewValue!==null&&i&&o.wrap(l,i)}}}function wi(s,e=zi){return(t,n,r)=>{if(!e(n.item,r.consumable,{preflight:!0}))return;const i=s(n.item,r,n);if(!i)return;e(n.item,r.consumable);const o=r.mapper.toViewPosition(n.range.start);r.mapper.bindElements(n.item,i),r.writer.insert(o,i),r.convertAttributes(n.item),ws(i,n.item.getChildren(),r,{reconversion:n.reconversion})}}function bi(s,e){return(t,n,r)=>{if(!e(n.item,r.consumable,{preflight:!0}))return;const i=new Map;r.writer._registerSlotFactory($i(n.item,i,r));const o=s(n.item,r,n);if(r.writer._clearSlotFactory(),!o)return;Li(n.item,i,r),e(n.item,r.consumable);const a=r.mapper.toViewPosition(n.range.start);r.mapper.bindElements(n.item,o),r.writer.insert(a,o),r.convertAttributes(n.item),Wi(o,i,r,{reconversion:n.reconversion})}}function yi(s){return(e,t,n)=>{t.isOpening=!0;const r=s(t,n);t.isOpening=!1;const i=s(t,n);if(!r||!i)return;const o=t.markerRange;if(o.isCollapsed&&!n.consumable.consume(o,e.name))return;for(const c of o)if(!n.consumable.consume(c.item,e.name))return;const a=n.mapper,l=n.writer;l.insert(a.toViewPosition(o.start),r),n.mapper.bindElementToMarker(r,t.markerName),o.isCollapsed||(l.insert(a.toViewPosition(o.end),i),n.mapper.bindElementToMarker(i,t.markerName)),e.stop()}}function vi(){return(s,e,t)=>{const n=t.mapper.markerNameToElements(e.markerName);if(n){for(const r of n)t.mapper.unbindElementFromMarkerName(r,e.markerName),t.writer.clear(t.writer.createRangeOn(r),r);t.writer.clearClonedElementsGroup(e.markerName),s.stop()}}}function Pi(s){return(e,t,n)=>{const r=s(t.markerName,n);if(!r)return;const i=t.markerRange;n.consumable.consume(i,e.name)&&(vn(i,!1,n,t,r),vn(i,!0,n,t,r),e.stop())}}function vn(s,e,t,n,r){const i=e?s.start:s.end,o=i.nodeAfter&&i.nodeAfter.is("element")?i.nodeAfter:null,a=i.nodeBefore&&i.nodeBefore.is("element")?i.nodeBefore:null;if(o||a){let c,h;e&&o||!e&&!a?(c=o,h=!0):(c=a,h=!1);const d=t.mapper.toViewElement(c);if(d){Ci(d,e,h,t,n,r);return}}const l=t.mapper.toViewPosition(i);ki(l,e,t,n,r)}function Ci(s,e,t,n,r,i){const o=`data-${i.group}-${e?"start":"end"}-${t?"before":"after"}`,a=s.hasAttribute(o)?s.getAttribute(o).split(","):[];a.unshift(i.name),n.writer.setAttribute(o,a.join(","),s),n.mapper.bindElementToMarker(s,r.markerName)}function ki(s,e,t,n,r){const i=`${r.group}-${e?"start":"end"}`,o=r.name?{name:r.name}:null,a=t.writer.createUIElement(i,o);t.writer.insert(s,a),t.mapper.bindElementToMarker(a,n.markerName)}function Ai(s){return(e,t,n)=>{const r=s(t.markerName,n);if(!r)return;const i=n.mapper.markerNameToElements(t.markerName);if(!i)return;for(const a of i)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("containerElement")?(o(`data-${r.group}-start-before`,a),o(`data-${r.group}-start-after`,a),o(`data-${r.group}-end-before`,a),o(`data-${r.group}-end-after`,a)):n.writer.clear(n.writer.createRangeOn(a),a);n.writer.clearClonedElementsGroup(t.markerName),e.stop();function o(a,l){if(l.hasAttribute(a)){const c=new Set(l.getAttribute(a).split(","));c.delete(r.name),c.size==0?n.writer.removeAttribute(a,l):n.writer.setAttribute(a,Array.from(c).join(","),l)}}}}function Si(s){return(e,t,n)=>{if(!n.consumable.test(t.item,e.name))return;const r=s(t.attributeOldValue,n,t),i=s(t.attributeNewValue,n,t);if(!r&&!i)return;n.consumable.consume(t.item,e.name);const o=n.mapper.toViewElement(t.item),a=n.writer;if(!o)throw new f("conversion-attribute-to-attribute-on-text",n.dispatcher,t);if(t.attributeOldValue!==null&&r){let l=r.value;r.key=="style"&&(typeof r.value=="string"?l=new We(a.document.stylesProcessor).setTo(r.value).getStylesEntries().map(([c])=>c):l=Object.keys(r.value)),a.removeAttribute(r.key,l,o)}if(t.attributeNewValue!==null&&i){let l=i.value;i.key=="style"&&typeof i.value=="string"&&(l=Object.fromEntries(new We(a.document.stylesProcessor).setTo(i.value).getStylesEntries())),a.setAttribute(i.key,l,!1,o)}}}function Ei(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof $||t.item instanceof G)&&!t.item.is("$textProxy"))return;const r=Ht(s,t,n);if(!r||!n.consumable.consume(t.item,e.name))return;const i=n.writer,o=ds(i,r),a=i.document.selection;if(t.item instanceof $||t.item instanceof G)i.wrap(a.getFirstRange(),o);else{const l=n.mapper.toViewRange(t.range),c=i.wrap(l,o);for(const h of c.getItems())if(h.is("attributeElement")&&h.isSimilar(o)){n.mapper.bindElementToMarker(h,t.markerName);break}}}}function Ri(s){return(e,t,n)=>{if(!t.item||!(t.item instanceof C))return;const r=Ht(s,t,n);if(!r||!n.consumable.test(t.item,e.name))return;const i=n.mapper.toViewElement(t.item);if(i&&i.getCustomProperty("addHighlight")){n.consumable.consume(t.item,e.name);for(const a of u._createIn(t.item))n.consumable.consume(a.item,e.name);i.getCustomProperty("addHighlight")(i,r,n.writer),n.mapper.bindElementToMarker(i,t.markerName)}}}function Ti(s){return(e,t,n)=>{if(t.markerRange.isCollapsed)return;const r=Ht(s,t,n);if(!r)return;const i=ds(n.writer,r),o=n.mapper.markerNameToElements(t.markerName);if(o){for(const a of o)n.mapper.unbindElementFromMarkerName(a,t.markerName),a.is("attributeElement")?n.writer.unwrap(n.writer.createRangeOn(a),i):a.getCustomProperty("removeHighlight")(a,r.id,n.writer);n.writer.clearClonedElementsGroup(t.markerName),e.stop()}}}function Mi(s){const e=ms(s.model),t=Xe(s.view,"container");return e.attributes.length&&(e.children=!0),n=>{n.on(`insert:${e.name}`,wi(t,_s(e)),{priority:s.converterPriority||"normal"}),(e.children||e.attributes.length)&&n.on("reduceChanges",ps(e),{priority:"low"})}}function xi(s){const e=ms(s.model),t=Xe(s.view,"container");return e.children=!0,n=>{if(n._conversionApi.schema.checkChild(e.name,"$text"))throw new f("conversion-element-to-structure-disallowed-text",n,{elementName:e.name});n.on(`insert:${e.name}`,bi(t,_s(e)),{priority:s.converterPriority||"normal"}),n.on("reduceChanges",ps(e),{priority:"low"})}}function Ni(s){s=ce(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const r of e.values)s.view[r]=Xe(s.view[r],"attribute");else s.view=Xe(s.view,"attribute");const n=gs(s);return r=>{r.on(t,_i(n),{priority:s.converterPriority||"normal"})}}function Oi(s){s=ce(s);let e=s.model;typeof e=="string"&&(e={key:e});let t=`attribute:${e.key}`;if(e.name&&(t+=":"+e.name),e.values)for(const r of e.values)s.view[r]=Pn(s.view[r]);else s.view=Pn(s.view);const n=gs(s);return r=>{r.on(t,Si(n),{priority:s.converterPriority||"normal"})}}function Ii(s){const e=Xe(s.view,"ui");return t=>{t.on(`addMarker:${s.model}`,yi(e),{priority:s.converterPriority||"normal"}),t.on(`removeMarker:${s.model}`,vi(),{priority:s.converterPriority||"normal"})}}function Fi(s){s=ce(s);const e=s.model;let t=s.view;return t||(t=n=>({group:e,name:n.substr(s.model.length+1)})),n=>{n.on(`addMarker:${e}`,Pi(t),{priority:s.converterPriority||"normal"}),n.on(`removeMarker:${e}`,Ai(t),{priority:s.converterPriority||"normal"})}}function Di(s){return e=>{e.on(`addMarker:${s.model}`,Ei(s.view),{priority:s.converterPriority||"normal"}),e.on(`addMarker:${s.model}`,Ri(s.view),{priority:s.converterPriority||"normal"}),e.on(`removeMarker:${s.model}`,Ti(s.view),{priority:s.converterPriority||"normal"})}}function ms(s){return typeof s=="string"&&(s={name:s}),{name:s.name,attributes:s.attributes?ae(s.attributes):[],children:!!s.children}}function Xe(s,e){return typeof s=="function"?s:(t,n)=>Bi(s,n,e)}function Bi(s,e,t){typeof s=="string"&&(s={name:s});let n;const r=e.writer,i=Object.assign({},s.attributes);if(t=="container")n=r.createContainerElement(s.name,i);else if(t=="attribute"){const o={priority:s.priority||Me.DEFAULT_PRIORITY};n=r.createAttributeElement(s.name,i,o)}else n=r.createUIElement(s.name,i);if(s.styles){const o=Object.keys(s.styles);for(const a of o)r.setStyle(a,s.styles[a],n)}if(s.classes){const o=s.classes;if(typeof o=="string")r.addClass(o,n);else for(const a of o)r.addClass(a,n)}return n}function gs(s){return s.model.values?(e,t,n)=>{const r=s.view[e];return r?r(e,t,n):null}:s.view}function Pn(s){return typeof s=="string"?e=>({key:s,value:e}):typeof s=="object"?s.value?()=>s:e=>({key:s.key,value:e}):s}function Ht(s,e,t){const n=typeof s=="function"?s(e,t):s;return n?(n.priority||(n.priority=10),n.id||(n.id=e.markerName),n):null}function Vi(s){return(e,t)=>{if(!e.is("element",s.name))return!1;if(t.type=="attribute"){if(s.attributes.includes(t.attributeKey))return!0}else{/* istanbul ignore else: This is always true because otherwise it would not register a reducer callback. -- @preserve */if(s.children)return!0}return!1}}function ps(s){const e=Vi(s);return(t,n)=>{const r=[];n.reconvertedElements||(n.reconvertedElements=new Set);for(const i of n.changes){const o=i.type=="attribute"?i.range.start.nodeAfter:i.position.parent;if(!o||!e(o,i)){r.push(i);continue}if(!n.reconvertedElements.has(o)){n.reconvertedElements.add(o);const a=m._createBefore(o);let l=r.length;for(let c=r.length-1;c>=0;c--){const h=r[c],p=(h.type=="attribute"?h.range.start:h.position).compareWith(a);if(p=="before"||h.type=="remove"&&p=="same")break;l=c}r.splice(l,0,{type:"remove",name:o.name,position:a,length:1},{type:"reinsert",name:o.name,position:a,length:1})}}n.changes=r}}function _s(s){return(e,t,n={})=>{const r=["insert"];for(const i of s.attributes)e.hasAttribute(i)&&r.push(`attribute:${i}`);return r.every(i=>t.test(e,i))?(n.preflight||r.forEach(i=>t.consume(e,i)),!0):!1}}function $i(s,e,t){return(n,r)=>{const i=n.createContainerElement("$slot");let o=null;if(r==="children")o=Array.from(s.getChildren());else if(typeof r=="function")o=Array.from(s.getChildren()).filter(a=>r(a));else throw new f("conversion-slot-mode-unknown",t.dispatcher,{modeOrFilter:r});return e.set(i,o),i}}function Li(s,e,t){const n=Array.from(e.values()).flat(),r=new Set(n);if(r.size!=n.length)throw new f("conversion-slot-filter-overlap",t.dispatcher,{element:s});if(r.size!=s.childCount)throw new f("conversion-slot-filter-incomplete",t.dispatcher,{element:s})}function Wi(s,e,t,n){t.mapper.on("modelToViewPosition",o,{priority:"highest"});let r=null,i=null;for([r,i]of e)ws(s,i,t,n),t.writer.move(t.writer.createRangeIn(r),t.writer.createPositionBefore(r)),t.writer.remove(r);t.mapper.off("modelToViewPosition",o);function o(a,l){const c=l.modelPosition.nodeAfter,h=i.indexOf(c);h<0||(l.viewPosition=l.mapper.findPositionIn(r,h))}}function ws(s,e,t,n){for(const r of e)qi(s.root,r,t,n)||t.convertItem(r)}function qi(s,e,t,n){const{writer:r,mapper:i}=t;if(!n.reconversion)return!1;const o=i.toViewElement(e);return!o||o.root==s||!t.canReuseView(o)?!1:(r.move(r.createRangeOn(o),i.toViewPosition(m._createBefore(e))),!0)}function zi(s,e,{preflight:t}={}){return t?e.test(s,"insert"):e.consume(s,"insert")}/**
19
19
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
20
20
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
21
- */function vs(r){const{schema:t,document:e}=r.model;for(const n of e.getRoots())if(n.isEmpty&&!t.checkChild(n,"$text")&&t.checkChild(n,"paragraph"))return r.insertElement("paragraph",n),!0;return!1}function Ps(r,t,e){const n=e.createContext(r);return!(!e.checkChild(n,"paragraph")||!e.checkChild(n.push("paragraph"),t))}function Cs(r,t){const e=t.createElement("paragraph");return t.insert(e,r),t.createPositionAt(e,0)}class Hi extends fs{elementToElement(t){return this.add(ks(t))}elementToAttribute(t){return this.add(Yi(t))}attributeToAttribute(t){return this.add(Qi(t))}elementToMarker(t){return this.add(Zi(t))}dataToMarker(t){return this.add(eo(t))}}function An(){return(r,t,e)=>{if(!t.modelRange&&e.consumable.consume(t.viewItem,{name:!0})){const{modelRange:n,modelCursor:s}=e.convertChildren(t.viewItem,t.modelCursor);t.modelRange=n,t.modelCursor=s}}}function Ki(){return(r,t,{schema:e,consumable:n,writer:s})=>{let i=t.modelCursor;if(!n.test(t.viewItem))return;if(!e.checkChild(i,"$text")){if(!Ps(i,"$text",e)||t.viewItem.data.trim().length==0)return;i=Cs(i,s)}n.consume(t.viewItem);const o=s.createText(t.viewItem.data);s.insert(o,i),t.modelRange=s.createRange(i,i.getShiftedBy(o.offsetSize)),t.modelCursor=t.modelRange.end}}function Xi(r,t){return(e,n)=>{const s=n.newSelection,i=[];for(const a of s.getRanges())i.push(t.toModelRange(a));const o=r.createSelection(i,{backward:s.isBackward});o.isEqual(r.document.selection)||r.change(a=>{a.setSelection(o)})}}function ks(r){r=he(r);const t=$t(r),e=Yt(r.view),n=e?`element:${e}`:"element";return s=>{s.on(n,t,{priority:r.converterPriority||"normal"})}}function Yi(r){r=he(r),As(r);const t=Ss(r,!1),e=Yt(r.view),n=e?`element:${e}`:"element";return s=>{s.on(n,t,{priority:r.converterPriority||"low"})}}function Qi(r){r=he(r);let t=null;(typeof r.view=="string"||r.view.key)&&(t=so(r)),As(r,t);const e=Ss(r,!0);return n=>{n.on("element",e,{priority:r.converterPriority||"low"})}}function Zi(r){const t=oo(r.model);return ks({...r,model:t})}function eo(r){r=he(r),r.model||(r.model=s=>s?r.view+":"+s:r.view);const t={view:r.view,model:r.model},e=$t(Sn(t,"start")),n=$t(Sn(t,"end"));return s=>{s.on(`element:${r.view}-start`,e,{priority:r.converterPriority||"normal"}),s.on(`element:${r.view}-end`,n,{priority:r.converterPriority||"normal"});const i=_t.low,o=_t.highest,a=_t.get(r.converterPriority)/o;s.on("element",to(t),{priority:i+a})}}function to(r){return(t,e,n)=>{const s=`data-${r.view}`;if(!n.consumable.test(e.viewItem,{attributes:s+"-end-after"})&&!n.consumable.test(e.viewItem,{attributes:s+"-start-after"})&&!n.consumable.test(e.viewItem,{attributes:s+"-end-before"})&&!n.consumable.test(e.viewItem,{attributes:s+"-start-before"}))return;e.modelRange||Object.assign(e,n.convertChildren(e.viewItem,e.modelCursor)),n.consumable.consume(e.viewItem,{attributes:s+"-end-after"})&&i(e.modelRange.end,e.viewItem.getAttribute(s+"-end-after").split(",")),n.consumable.consume(e.viewItem,{attributes:s+"-start-after"})&&i(e.modelRange.end,e.viewItem.getAttribute(s+"-start-after").split(",")),n.consumable.consume(e.viewItem,{attributes:s+"-end-before"})&&i(e.modelRange.start,e.viewItem.getAttribute(s+"-end-before").split(",")),n.consumable.consume(e.viewItem,{attributes:s+"-start-before"})&&i(e.modelRange.start,e.viewItem.getAttribute(s+"-start-before").split(","));function i(o,a){for(const l of a){const h=r.model(l,n),u=n.writer.createElement("$marker",{"data-name":h});n.writer.insert(u,o),e.modelCursor.isEqual(o)?e.modelCursor=e.modelCursor.getShiftedBy(1):e.modelCursor=e.modelCursor._getTransformedByInsertion(o,1),e.modelRange=e.modelRange._getTransformedByInsertion(o,1)[0]}}}}function Yt(r){return typeof r=="string"?r:typeof r=="object"&&typeof r.name=="string"?r.name:null}function $t(r){const t=new He(r.view);return(e,n,s)=>{const i=t.match(n.viewItem);if(!i)return;const o=i.match;if(o.name=!0,!s.consumable.test(n.viewItem,o))return;const a=no(r.model,n.viewItem,s);a&&s.safeInsert(a,n.modelCursor)&&(s.consumable.consume(n.viewItem,o),s.convertChildren(n.viewItem,a),s.updateConversionResult(a,n))}}function no(r,t,e){return r instanceof Function?r(t,e):e.writer.createElement(r)}function so(r){typeof r.view=="string"&&(r.view={key:r.view});const t=r.view.key,e=typeof r.view.value>"u"?/[\s\S]*/:r.view.value;let n;return t=="class"||t=="style"?n={[t=="class"?"classes":"styles"]:e}:n={attributes:{[t]:e}},r.view.name&&(n.name=r.view.name),r.view=n,t}function As(r,t=null){const e=t===null?!0:i=>i.getAttribute(t),n=typeof r.model!="object"?r.model:r.model.key,s=typeof r.model!="object"||typeof r.model.value>"u"?e:r.model.value;r.model={key:n,value:s}}function Ss(r,t){const e=new He(r.view);return(n,s,i)=>{if(!s.modelRange&&t)return;const o=e.match(s.viewItem);if(!o||(ro(r.view,s.viewItem)?o.match.name=!0:delete o.match.name,!i.consumable.test(s.viewItem,o.match)))return;const a=r.model.key,l=typeof r.model.value=="function"?r.model.value(s.viewItem,i,s):r.model.value;if(l===null)return;s.modelRange||Object.assign(s,i.convertChildren(s.viewItem,s.modelCursor)),io(s.modelRange,{key:a,value:l},t,i)&&(i.consumable.test(s.viewItem,{name:!0})&&(o.match.name=!0),i.consumable.consume(s.viewItem,o.match))}}function ro(r,t){const e=typeof r=="function"?r(t):r;return typeof e=="object"&&!Yt(e)?!1:!e.classes&&!e.attributes&&!e.styles}function io(r,t,e,n){let s=!1;for(const i of Array.from(r.getItems({shallow:e})))n.schema.checkAttribute(i,t.key)&&(s=!0,!i.hasAttribute(t.key)&&n.writer.setAttribute(t.key,t.value,i));return s}function oo(r){return(t,e)=>{const n=typeof r=="string"?r:r(t,e);return e.writer.createElement("$marker",{"data-name":n})}}function Sn(r,t){const e=(n,s)=>{const i=n.getAttribute("name"),o=r.model(i,s);return s.writer.createElement("$marker",{"data-name":o})};return{view:`${r.view}-${t}`,model:e}}class Pl extends J(){constructor(e,n){super();c(this,"model");c(this,"view");c(this,"mapper");c(this,"downcastDispatcher");this.model=e,this.view=new Qr(n),this.mapper=new cs,this.downcastDispatcher=new hs({mapper:this.mapper,schema:e.schema});const s=this.model.document,i=s.selection,o=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(s,"change",()=>{this.view.change(a=>{this.downcastDispatcher.convertChanges(s.differ,o,a),this.downcastDispatcher.convertSelection(i,o,a)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",Xi(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",ds(),{priority:"lowest"}),this.downcastDispatcher.on("insert",ms(),{priority:"lowest"}),this.downcastDispatcher.on("remove",_i(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",yi()),this.downcastDispatcher.on("selection",wi(),{priority:"low"}),this.downcastDispatcher.on("selection",bi(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(a=>{if(a.rootName=="$graveyard")return null;const l=new Kn(this.view.document,a.name);return l.rootName=a.rootName,this.mapper.bindElements(a,l),l})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const n=typeof e=="string"?e:e.name,s=this.model.markers.get(n);if(!s)throw new d("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:n});this.model.change(()=>{this.model.markers._refresh(s)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class ao extends J(){constructor(){super();c(this,"_sourceDefinitions",{});c(this,"_attributeProperties",Object.create(null));c(this,"_customChildChecks",new Map);c(this,"_customAttributeChecks",new Map);c(this,"_genericCheckSymbol",Symbol("$generic"));c(this,"_compiledDefinitions");this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,n)=>{n[0]=new ae(n[0])},{priority:"highest"}),this.on("checkChild",(e,n)=>{n[0]=new ae(n[0]),n[1]=this.getDefinition(n[1])},{priority:"highest"})}register(e,n){if(this._sourceDefinitions[e])throw new d("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},n)],this._clearCache()}extend(e,n){if(!this._sourceDefinitions[e])throw new d("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},n)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let n;return typeof e=="string"?n=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?n="$text":n=e.name,this.getDefinitions()[n]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const n=this.getDefinition(e);return!!(n&&n.isBlock)}isLimit(e){const n=this.getDefinition(e);return n?!!(n.isLimit||n.isObject):!1}isObject(e){const n=this.getDefinition(e);return n?!!(n.isObject||n.isLimit&&n.isSelectable&&n.isContent):!1}isInline(e){const n=this.getDefinition(e);return!!(n&&n.isInline)}isSelectable(e){const n=this.getDefinition(e);return n?!!(n.isSelectable||n.isObject):!1}isContent(e){const n=this.getDefinition(e);return n?!!(n.isContent||n.isObject):!1}checkChild(e,n){return n?this._checkContextMatch(e,n):!1}checkAttribute(e,n){const s=this.getDefinition(e.last);if(!s)return!1;const i=this._evaluateAttributeChecks(e,n);return i!==void 0?i:s.allowAttributes.includes(n)}checkMerge(e,n){if(e instanceof g){const s=e.nodeBefore,i=e.nodeAfter;if(!(s instanceof k))throw new d("schema-check-merge-no-element-before",this);if(!(i instanceof k))throw new d("schema-check-merge-no-element-after",this);return this.checkMerge(s,i)}if(this.isLimit(e)||this.isLimit(n))return!1;for(const s of n.getChildren())if(!this.checkChild(e,s))return!1;return!0}addChildCheck(e,n){const s=n!==void 0?n:this._genericCheckSymbol,i=this._customChildChecks.get(s)||[];i.push(e),this._customChildChecks.set(s,i)}addAttributeCheck(e,n){const s=n!==void 0?n:this._genericCheckSymbol,i=this._customAttributeChecks.get(s)||[];i.push(e),this._customAttributeChecks.set(s,i)}setAttributeProperties(e,n){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),n)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let n;for(e instanceof g?n=e.parent:n=(e instanceof f?[e]:Array.from(e.getRanges())).reduce((i,o)=>{const a=o.getCommonAncestor();return i?i.getCommonAncestor(a,{includeSelf:!0}):a},null);!this.isLimit(n)&&n.parent;)n=n.parent;return n}checkAttributeInSelection(e,n){if(e.isCollapsed){const i=[...e.getFirstPosition().getAncestors(),new A("",e.getAttributes())];return this.checkAttribute(i,n)}else{const s=e.getRanges();for(const i of s)for(const o of i)if(this.checkAttribute(o.item,n))return!0}return!1}*getValidRanges(e,n){e=ko(e);for(const s of e)yield*this._getValidRangesForRange(s,n)}getNearestSelectionRange(e,n="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new f(e);let s,i;const o=e.getAncestors().reverse().find(a=>this.isLimit(a))||e.root;(n=="both"||n=="backward")&&(s=new oe({boundaries:f._createIn(o),startPosition:e,direction:"backward"})),(n=="both"||n=="forward")&&(i=new oe({boundaries:f._createIn(o),startPosition:e}));for(const a of Co(s,i)){const l=a.walker==s?"elementEnd":"elementStart",h=a.value;if(h.type==l&&this.isObject(h.item))return f._createOn(h.item);if(this.checkChild(h.nextPosition,"$text"))return new f(h.nextPosition)}return null}findAllowedParent(e,n){let s=e.parent;for(;s;){if(this.checkChild(s,n))return s;if(this.isLimit(s))return null;s=s.parent}return null}setAllowedAttributes(e,n,s){const i=s.model;for(const[o,a]of Object.entries(n))i.schema.checkAttribute(e,o)&&s.setAttribute(o,a,e)}removeDisallowedAttributes(e,n){for(const s of e)if(s.is("$text"))En(this,s,n);else{const o=f._createIn(s).getPositions();for(const a of o){const l=a.nodeBefore||a.parent;En(this,l,n)}}}getAttributesWithProperty(e,n,s){const i={};for(const[o,a]of e.getAttributes()){const l=this.getAttributeProperties(o);l[n]!==void 0&&(s===void 0||s===l[n])&&(i[o]=a)}return i}createContext(e){return new ae(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},n=this._sourceDefinitions,s=Object.keys(n);for(const o of s)e[o]=lo(n[o],o);const i=Object.values(e);for(const o of i)co(e,o),ho(e,o),uo(e,o),fo(e,o);for(const o of i)mo(e,o);for(const o of i)go(e,o);for(const o of i)po(e,o);for(const o of i)wo(e,o);for(const o of i)bo(e,o);this._compiledDefinitions=_o(e)}_checkContextMatch(e,n){const s=e.last;let i=this._evaluateChildChecks(e,n);if(i=i!==void 0?i:n.allowIn.includes(s.name),!i)return!1;const o=this.getDefinition(s),a=e.trimLast();return o?a.length==0?!0:this._checkContextMatch(a,o):!1}_evaluateChildChecks(e,n){const s=this._customChildChecks.get(this._genericCheckSymbol)||[],i=this._customChildChecks.get(n.name)||[];for(const o of[...s,...i]){const a=o(e,n);if(a!==void 0)return a}}_evaluateAttributeChecks(e,n){const s=this._customAttributeChecks.get(this._genericCheckSymbol)||[],i=this._customAttributeChecks.get(n)||[];for(const o of[...s,...i]){const a=o(e,n);if(a!==void 0)return a}}*_getValidRangesForRange(e,n){let s=e.start,i=e.start;for(const o of e.getItems({shallow:!0}))o.is("element")&&(yield*this._getValidRangesForRange(f._createIn(o),n)),this.checkAttribute(o,n)||(s.isEqual(i)||(yield new f(s,i)),s=g._createAfter(o)),i=g._createAfter(o);s.isEqual(i)||(yield new f(s,i))}findOptimalInsertionRange(e,n){const s=e.getSelectedElement();if(s&&this.isObject(s)&&!this.isInline(s))return n=="before"||n=="after"?new f(g._createAt(s,n)):f._createOn(s);const i=zt(e.getSelectedBlocks());if(!i)return new f(e.focus);if(i.isEmpty)return new f(g._createAt(i,0));const o=g._createAfter(i);return e.focus.isTouching(o)?new f(o):new f(g._createBefore(i))}}class ae{constructor(t){c(this,"_items");if(t instanceof ae)return t;let e;typeof t=="string"?e=[t]:Array.isArray(t)?e=t:e=t.getAncestors({includeSelf:!0}),this._items=e.map(Po)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(t){const e=new ae([t]);return e._items=[...this._items,...e._items],e}trimLast(){const t=new ae([]);return t._items=this._items.slice(0,-1),t}getItem(t){return this._items[t]}*getNames(){yield*this._items.map(t=>t.name)}endsWith(t){return Array.from(this.getNames()).join(" ").endsWith(t)}startsWith(t){return Array.from(this.getNames()).join(" ").startsWith(t)}}function lo(r,t){const e={name:t,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return yo(r,e),K(r,e,"allowIn"),K(r,e,"allowChildren"),K(r,e,"disallowIn"),K(r,e,"disallowChildren"),K(r,e,"allowContentOf"),K(r,e,"allowWhere"),K(r,e,"allowAttributes"),K(r,e,"disallowAttributes"),K(r,e,"allowAttributesOf"),K(r,e,"inheritTypesFrom"),vo(r,e),e}function co(r,t){for(const e of t.allowIn){const n=r[e];n?n.allowChildren.add(t.name):t.allowIn.delete(e)}}function ho(r,t){for(const e of t.allowChildren){const n=r[e];n?n.allowIn.add(t.name):t.allowChildren.delete(e)}}function uo(r,t){for(const e of t.disallowIn){const n=r[e];n?n.disallowChildren.add(t.name):t.disallowIn.delete(e)}}function fo(r,t){for(const e of t.disallowChildren){const n=r[e];n?n.disallowIn.add(t.name):t.disallowChildren.delete(e)}}function mo(r,t){for(const e of t.disallowChildren)t.allowChildren.delete(e);for(const e of t.disallowIn)t.allowIn.delete(e);for(const e of t.disallowAttributes)t.allowAttributes.delete(e)}function go(r,t){for(const e of t.allowContentOf){const n=r[e];n&&(n.disallowChildren.forEach(s=>{t.allowChildren.has(s)||(t.disallowChildren.add(s),r[s].disallowIn.add(t.name))}),n.allowChildren.forEach(s=>{t.disallowChildren.has(s)||(t.allowChildren.add(s),r[s].allowIn.add(t.name))}))}}function po(r,t){for(const e of t.allowWhere){const n=r[e];n&&(n.disallowIn.forEach(s=>{t.allowIn.has(s)||(t.disallowIn.add(s),r[s].disallowChildren.add(t.name))}),n.allowIn.forEach(s=>{t.disallowIn.has(s)||(t.allowIn.add(s),r[s].allowChildren.add(t.name))}))}}function _o(r){const t={};for(const e of Object.values(r))t[e.name]={name:e.name,isBlock:!!e.isBlock,isContent:!!e.isContent,isInline:!!e.isInline,isLimit:!!e.isLimit,isObject:!!e.isObject,isSelectable:!!e.isSelectable,allowIn:Array.from(e.allowIn).filter(n=>!!r[n]),allowChildren:Array.from(e.allowChildren).filter(n=>!!r[n]),allowAttributes:Array.from(e.allowAttributes)};return t}function wo(r,t){for(const e of t.allowAttributesOf){const n=r[e];if(!n)return;n.allowAttributes.forEach(s=>{t.disallowAttributes.has(s)||t.allowAttributes.add(s)})}}function bo(r,t){for(const e of t.inheritTypesFrom){const n=r[e];if(n){const s=Object.keys(n).filter(i=>i.startsWith("is"));for(const i of s)i in t||(t[i]=n[i])}}}function yo(r,t){for(const e of r){const n=Object.keys(e).filter(s=>s.startsWith("is"));for(const s of n)t[s]=!!e[s]}}function K(r,t,e){for(const n of r){let s=n[e];typeof s=="string"&&(s=[s]),Array.isArray(s)&&s.forEach(i=>t[e].add(i))}}function vo(r,t){for(const e of r){const n=e.inheritAllFrom;n&&(t.allowContentOf.add(n),t.allowWhere.add(n),t.allowAttributesOf.add(n),t.inheritTypesFrom.add(n))}}function Po(r){return typeof r=="string"||r.is("documentFragment")?{name:typeof r=="string"?r:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:r.is("element")?r.name:"$text",*getAttributeKeys(){yield*r.getAttributeKeys()},getAttribute(t){return r.getAttribute(t)}}}function*Co(r,t){let e=!1;for(;!e;){if(e=!0,r){const n=r.next();n.done||(e=!1,yield{walker:r,value:n.value})}if(t){const n=t.next();n.done||(e=!1,yield{walker:t,value:n.value})}}}function*ko(r){for(const t of r)yield*t.getMinimalFlatRanges()}function En(r,t,e){for(const n of t.getAttributeKeys())r.checkAttribute(t,n)||e.removeAttribute(n,t)}class Ao extends O(){constructor(e){super();c(this,"conversionApi");c(this,"_splitParts",new Map);c(this,"_cursorParents",new Map);c(this,"_modelCursor",null);c(this,"_emptyElementsToKeep",new Set);this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(n,s)=>this._convertItem(n,s),convertChildren:(n,s)=>this._convertChildren(n,s),safeInsert:(n,s)=>this._safeInsert(n,s),updateConversionResult:(n,s)=>this._updateConversionResult(n,s),splitToAllowedParent:(n,s)=>this._splitToAllowedParent(n,s),getSplitParts:n=>this._getSplitParts(n),keepEmptyElement:n=>this._keepEmptyElement(n)}}convert(e,n,s=["$root"]){this.fire("viewCleanup",e),this._modelCursor=Eo(s,n),this.conversionApi.writer=n,this.conversionApi.consumable=ut.createFrom(e),this.conversionApi.store={};const{modelRange:i}=this._convertItem(e,this._modelCursor),o=n.createDocumentFragment();if(i){this._removeEmptyElements();const a=this._modelCursor.parent,l=a._removeChildren(0,a.childCount);o._insertChild(0,l),o.markers=So(o,n)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,o}_convertItem(e,n){const s={viewItem:e,modelCursor:n,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,s,this.conversionApi):e.is("$text")?this.fire("text",s,this.conversionApi):this.fire("documentFragment",s,this.conversionApi),s.modelRange&&!(s.modelRange instanceof f))throw new d("view-conversion-dispatcher-incorrect-result",this);return{modelRange:s.modelRange,modelCursor:s.modelCursor}}_convertChildren(e,n){let s=n.is("position")?n:g._createAt(n,0);const i=new f(s);for(const o of Array.from(e.getChildren())){const a=this._convertItem(o,s);a.modelRange instanceof f&&(i.end=a.modelRange.end,s=a.modelCursor)}return{modelRange:i,modelCursor:s}}_safeInsert(e,n){const s=this._splitToAllowedParent(e,n);return s?(this.conversionApi.writer.insert(e,s.position),!0):!1}_updateConversionResult(e,n){const s=this._getSplitParts(e),i=this.conversionApi.writer;n.modelRange||(n.modelRange=i.createRange(i.createPositionBefore(e),i.createPositionAfter(s[s.length-1])));const o=this._cursorParents.get(e);o?n.modelCursor=i.createPositionAt(o,0):n.modelCursor=n.modelRange.end}_splitToAllowedParent(e,n){const{schema:s,writer:i}=this.conversionApi;let o=s.findAllowedParent(n,e);if(o){if(o===n.parent)return{position:n};this._modelCursor.parent.getAncestors().includes(o)&&(o=null)}if(!o)return Ps(n,e,s)?{position:Cs(n,i)}:null;const a=this.conversionApi.writer.split(n,o),l=[];for(const u of a.range.getWalker())if(u.type=="elementEnd")l.push(u.item);else{const m=l.pop(),p=u.item;this._registerSplitPair(m,p)}const h=a.range.end.parent;return this._cursorParents.set(e,h),{position:a.position,cursorParent:h}}_registerSplitPair(e,n){this._splitParts.has(e)||this._splitParts.set(e,[e]);const s=this._splitParts.get(e);this._splitParts.set(n,s),s.push(n)}_getSplitParts(e){let n;return this._splitParts.has(e)?n=this._splitParts.get(e):n=[e],n}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const n of this._splitParts.keys())if(n.isEmpty&&!this._emptyElementsToKeep.has(n)){const s=e.get(n.parent)||[];s.push(n),this._splitParts.delete(n),e.set(n.parent,s)}for(const[n,s]of e)n._removeChildrenArray(s);e.size&&this._removeEmptyElements()}}function So(r,t){const e=new Set,n=new Map,s=f._createIn(r).getItems();for(const i of s)i.is("element","$marker")&&e.add(i);for(const i of e){const o=i.getAttribute("data-name"),a=t.createPositionBefore(i);n.has(o)?n.get(o).end=a.clone():n.set(o,new f(a.clone())),t.remove(i)}return n}function Eo(r,t){let e;for(const n of new ae(r)){const s={};for(const o of n.getAttributeKeys())s[o]=n.getAttribute(o);const i=t.createElement(n.name,s);e&&t.insert(i,e),e=g._createAt(i,0)}return e}class Ro{getHtml(t){const n=ie.document.implementation.createHTMLDocument("").createElement("div");return n.appendChild(t),n.innerHTML}}class To{constructor(t){c(this,"domParser");c(this,"domConverter");c(this,"htmlWriter");c(this,"skipComments",!0);this.domParser=new DOMParser,this.domConverter=new rs(t,{renderingMode:"data"}),this.htmlWriter=new Ro}toData(t){const e=this.domConverter.viewToDom(t);return this.htmlWriter.getHtml(e)}toView(t){const e=this._toDom(t);return this.domConverter.domToView(e,{skipComments:this.skipComments})}registerRawContentMatcher(t){this.domConverter.registerRawContentMatcher(t)}useFillerType(t){this.domConverter.blockFillerMode=t=="marked"?"markedNbsp":"nbsp"}_toDom(t){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(t.trim().slice(0,1e4))||(t=`<body>${t}</body>`);const e=this.domParser.parseFromString(t,"text/html"),n=e.createDocumentFragment(),s=e.body.childNodes;for(;s.length>0;)n.appendChild(s[0]);return n}}class Cl extends O(){constructor(e,n){super();c(this,"model");c(this,"mapper");c(this,"downcastDispatcher");c(this,"upcastDispatcher");c(this,"viewDocument");c(this,"stylesProcessor");c(this,"htmlProcessor");c(this,"processor");c(this,"_viewWriter");this.model=e,this.mapper=new cs,this.downcastDispatcher=new hs({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",ds(),{priority:"lowest"}),this.downcastDispatcher.on("insert",ms(),{priority:"lowest"}),this.upcastDispatcher=new Ao({schema:e.schema}),this.viewDocument=new Qn(n),this.stylesProcessor=n,this.htmlProcessor=new To(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Zn(this.viewDocument),this.upcastDispatcher.on("text",Ki(),{priority:"lowest"}),this.upcastDispatcher.on("element",An(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",An(),{priority:"lowest"}),J().prototype.decorate.call(this,"init"),J().prototype.decorate.call(this,"set"),J().prototype.decorate.call(this,"get"),J().prototype.decorate.call(this,"toView"),J().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},vs)},{priority:"lowest"})}get(e={}){const{rootName:n="main",trim:s="empty"}=e;if(!this._checkIfRootsExists([n]))throw new d("datacontroller-get-non-existent-root",this);const i=this.model.document.getRoot(n);return i.isAttached()||q("datacontroller-get-detached-root",this),s==="empty"&&!this.model.hasContent(i,{ignoreWhitespaces:!0})?"":this.stringify(i,e)}stringify(e,n={}){const s=this.toView(e,n);return this.processor.toData(s)}toView(e,n={}){const s=this.viewDocument,i=this._viewWriter;this.mapper.clearBindings();const o=f._createIn(e),a=new _e(s);this.mapper.bindElements(e,a);const l=e.is("documentFragment")?e.markers:Mo(e);return this.downcastDispatcher.convert(o,l,i,n),a}init(e){if(this.model.document.version)throw new d("datacontroller-init-document-not-empty",this);let n={};if(typeof e=="string"?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new d("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},s=>{for(const i of Object.keys(n)){const o=this.model.document.getRoot(i);s.insert(this.parse(n[i],o),o,0)}}),Promise.resolve()}set(e,n={}){let s={};if(typeof e=="string"?s.main=e:s=e,!this._checkIfRootsExists(Object.keys(s)))throw new d("datacontroller-set-non-existent-root",this);this.model.enqueueChange(n.batchType||{},i=>{i.setSelection(null),i.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const o of Object.keys(s)){const a=this.model.document.getRoot(o);i.remove(i.createRangeIn(a)),i.insert(this.parse(s[o],a),a,0)}})}parse(e,n="$root"){const s=this.processor.toView(e);return this.toModel(s,n)}toModel(e,n="$root"){return this.model.change(s=>this.upcastDispatcher.convert(e,s,n))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const n of e)if(!this.model.document.getRoot(n))return!1;return!0}}function Mo(r){const t=[],e=r.root.document;if(!e)return new Map;const n=f._createIn(r);for(const s of e.model.markers){const i=s.getRange(),o=i.isCollapsed,a=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&a)t.push([s.name,i]);else{const l=n.getIntersection(i);l&&t.push([s.name,l])}}return t.sort(([s,i],[o,a])=>{if(i.end.compareWith(a.start)!=="after")return 1;if(i.start.compareWith(a.end)!=="before")return-1;switch(i.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(i.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return o.localeCompare(s)}}}),new Map(t)}class kl{constructor(t,e){c(this,"_helpers",new Map);c(this,"_downcast");c(this,"_upcast");this._downcast=le(t),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=le(e),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(t,e){const n=this._downcast.includes(e);if(!this._upcast.includes(e)&&!n)throw new d("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:t,dispatchers:[e],isDowncast:n})}for(t){if(!this._helpers.has(t))throw new d("conversion-for-unknown-group",this);return this._helpers.get(t)}elementToElement(t){this.for("downcast").elementToElement(t);for(const{model:e,view:n}of St(t))this.for("upcast").elementToElement({model:e,view:n,converterPriority:t.converterPriority})}attributeToElement(t){this.for("downcast").attributeToElement(t);for(const{model:e,view:n}of St(t))this.for("upcast").elementToAttribute({view:n,model:e,converterPriority:t.converterPriority})}attributeToAttribute(t){this.for("downcast").attributeToAttribute(t);for(const{model:e,view:n}of St(t))this.for("upcast").attributeToAttribute({view:n,model:e})}_createConversionHelpers({name:t,dispatchers:e,isDowncast:n}){if(this._helpers.has(t))throw new d("conversion-group-exists",this);const s=n?new pi(e):new Hi(e);this._helpers.set(t,s)}}function*St(r){if(r.model.values)for(const t of r.model.values){const e={key:r.model.key,value:t},n=r.view[t],s=r.upcastAlso?r.upcastAlso[t]:void 0;yield*Rn(e,n,s)}else yield*Rn(r.model,r.view,r.upcastAlso)}function*Rn(r,t,e){if(yield{model:r,view:t},e)for(const n of le(e))yield{model:r,view:n}}/**
21
+ */function bs(s){const{schema:e,document:t}=s.model;for(const n of t.getRoots())if(n.isEmpty&&!e.checkChild(n,"$text")&&e.checkChild(n,"paragraph"))return s.insertElement("paragraph",n),!0;return!1}function ys(s,e,t){const n=t.createContext(s);return!(!t.checkChild(n,"paragraph")||!t.checkChild(n.push("paragraph"),e))}function vs(s,e){const t=e.createElement("paragraph");return e.insert(t,s),e.createPositionAt(t,0)}class Ui extends hs{elementToElement(e){return this.add(Ps(e))}elementToAttribute(e){return this.add(Gi(e))}attributeToAttribute(e){return this.add(Hi(e))}elementToMarker(e){return this.add(Ki(e))}dataToMarker(e){return this.add(Xi(e))}}function Cn(){return(s,e,t)=>{if(!e.modelRange&&t.consumable.consume(e.viewItem,{name:!0})){const{modelRange:n,modelCursor:r}=t.convertChildren(e.viewItem,e.modelCursor);e.modelRange=n,e.modelCursor=r}}}function Ji(){return(s,e,{schema:t,consumable:n,writer:r})=>{let i=e.modelCursor;if(!n.test(e.viewItem))return;if(!t.checkChild(i,"$text")){if(!ys(i,"$text",t)||e.viewItem.data.trim().length==0)return;i=vs(i,r)}n.consume(e.viewItem);const o=r.createText(e.viewItem.data);r.insert(o,i),e.modelRange=r.createRange(i,i.getShiftedBy(o.offsetSize)),e.modelCursor=e.modelRange.end}}function ji(s,e){return(t,n)=>{const r=n.newSelection,i=[];for(const a of r.getRanges())i.push(e.toModelRange(a));const o=s.createSelection(i,{backward:r.isBackward});o.isEqual(s.document.selection)||s.change(a=>{a.setSelection(o)})}}function Ps(s){s=ce(s);const e=Vt(s),t=Kt(s.view),n=t?`element:${t}`:"element";return r=>{r.on(n,e,{priority:s.converterPriority||"normal"})}}function Gi(s){s=ce(s),Cs(s);const e=ks(s,!1),t=Kt(s.view),n=t?`element:${t}`:"element";return r=>{r.on(n,e,{priority:s.converterPriority||"low"})}}function Hi(s){s=ce(s);let e=null;(typeof s.view=="string"||s.view.key)&&(e=Zi(s)),Cs(s,e);const t=ks(s,!0);return n=>{n.on("element",t,{priority:s.converterPriority||"low"})}}function Ki(s){const e=no(s.model);return Ps({...s,model:e})}function Xi(s){s=ce(s),s.model||(s.model=r=>r?s.view+":"+r:s.view);const e={view:s.view,model:s.model},t=Vt(kn(e,"start")),n=Vt(kn(e,"end"));return r=>{r.on(`element:${s.view}-start`,t,{priority:s.converterPriority||"normal"}),r.on(`element:${s.view}-end`,n,{priority:s.converterPriority||"normal"});const i=pt.low,o=pt.highest,a=pt.get(s.converterPriority)/o;r.on("element",Yi(e),{priority:i+a})}}function Yi(s){return(e,t,n)=>{const r=`data-${s.view}`;if(!n.consumable.test(t.viewItem,{attributes:r+"-end-after"})&&!n.consumable.test(t.viewItem,{attributes:r+"-start-after"})&&!n.consumable.test(t.viewItem,{attributes:r+"-end-before"})&&!n.consumable.test(t.viewItem,{attributes:r+"-start-before"}))return;t.modelRange||Object.assign(t,n.convertChildren(t.viewItem,t.modelCursor)),n.consumable.consume(t.viewItem,{attributes:r+"-end-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(r+"-end-after").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-start-after"})&&i(t.modelRange.end,t.viewItem.getAttribute(r+"-start-after").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-end-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(r+"-end-before").split(",")),n.consumable.consume(t.viewItem,{attributes:r+"-start-before"})&&i(t.modelRange.start,t.viewItem.getAttribute(r+"-start-before").split(","));function i(o,a){for(const l of a){const c=s.model(l,n),h=n.writer.createElement("$marker",{"data-name":c});n.writer.insert(h,o),t.modelCursor.isEqual(o)?t.modelCursor=t.modelCursor.getShiftedBy(1):t.modelCursor=t.modelCursor._getTransformedByInsertion(o,1),t.modelRange=t.modelRange._getTransformedByInsertion(o,1)[0]}}}}function Kt(s){return typeof s=="string"?s:typeof s=="object"&&typeof s.name=="string"?s.name:null}function Vt(s){const e=new je(s.view);return(t,n,r)=>{const i=e.match(n.viewItem);if(!i)return;const o=i.match;if(o.name=!0,!r.consumable.test(n.viewItem,o))return;const a=Qi(s.model,n.viewItem,r);a&&r.safeInsert(a,n.modelCursor)&&(r.consumable.consume(n.viewItem,o),r.convertChildren(n.viewItem,a),r.updateConversionResult(a,n))}}function Qi(s,e,t){return s instanceof Function?s(e,t):t.writer.createElement(s)}function Zi(s){typeof s.view=="string"&&(s.view={key:s.view});const e=s.view.key,t=typeof s.view.value>"u"?/[\s\S]*/:s.view.value;let n;return e=="class"||e=="style"?n={[e=="class"?"classes":"styles"]:t}:n={attributes:{[e]:t}},s.view.name&&(n.name=s.view.name),s.view=n,e}function Cs(s,e=null){const t=e===null?!0:i=>i.getAttribute(e),n=typeof s.model!="object"?s.model:s.model.key,r=typeof s.model!="object"||typeof s.model.value>"u"?t:s.model.value;s.model={key:n,value:r}}function ks(s,e){const t=new je(s.view);return(n,r,i)=>{if(!r.modelRange&&e)return;const o=t.match(r.viewItem);if(!o||(eo(s.view,r.viewItem)?o.match.name=!0:delete o.match.name,!i.consumable.test(r.viewItem,o.match)))return;const a=s.model.key,l=typeof s.model.value=="function"?s.model.value(r.viewItem,i,r):s.model.value;if(l===null)return;r.modelRange||Object.assign(r,i.convertChildren(r.viewItem,r.modelCursor)),to(r.modelRange,{key:a,value:l},e,i)&&(i.consumable.test(r.viewItem,{name:!0})&&(o.match.name=!0),i.consumable.consume(r.viewItem,o.match))}}function eo(s,e){const t=typeof s=="function"?s(e):s;return typeof t=="object"&&!Kt(t)?!1:!t.classes&&!t.attributes&&!t.styles}function to(s,e,t,n){let r=!1;for(const i of Array.from(s.getItems({shallow:t})))n.schema.checkAttribute(i,e.key)&&(r=!0,!i.hasAttribute(e.key)&&n.writer.setAttribute(e.key,e.value,i));return r}function no(s){return(e,t)=>{const n=typeof s=="string"?s:s(e,t);return t.writer.createElement("$marker",{"data-name":n})}}function kn(s,e){const t=(n,r)=>{const i=n.getAttribute("name"),o=s.model(i,r);return r.writer.createElement("$marker",{"data-name":o})};return{view:`${s.view}-${e}`,model:t}}class _l extends U(){model;view;mapper;downcastDispatcher;constructor(e,t){super(),this.model=e,this.view=new Hr(t),this.mapper=new as,this.downcastDispatcher=new ls({mapper:this.mapper,schema:e.schema});const n=this.model.document,r=n.selection,i=this.model.markers;this.listenTo(this.model,"_beforeChanges",()=>{this.view._disableRendering(!0)},{priority:"highest"}),this.listenTo(this.model,"_afterChanges",()=>{this.view._disableRendering(!1)},{priority:"lowest"}),this.listenTo(n,"change",()=>{this.view.change(o=>{this.downcastDispatcher.convertChanges(n.differ,i,o),this.downcastDispatcher.convertSelection(r,i,o)})},{priority:"low"}),this.listenTo(this.view.document,"selectionChange",ji(this.model,this.mapper)),this.downcastDispatcher.on("insert:$text",us(),{priority:"lowest"}),this.downcastDispatcher.on("insert",fs(),{priority:"lowest"}),this.downcastDispatcher.on("remove",di(),{priority:"low"}),this.downcastDispatcher.on("cleanSelection",pi()),this.downcastDispatcher.on("selection",mi(),{priority:"low"}),this.downcastDispatcher.on("selection",gi(),{priority:"low"}),this.view.document.roots.bindTo(this.model.document.roots).using(o=>{if(o.rootName=="$graveyard")return null;const a=new Gn(this.view.document,o.name);return a.rootName=o.rootName,this.mapper.bindElements(o,a),a})}destroy(){this.view.destroy(),this.stopListening()}reconvertMarker(e){const t=typeof e=="string"?e:e.name,n=this.model.markers.get(t);if(!n)throw new f("editingcontroller-reconvertmarker-marker-not-exist",this,{markerName:t});this.model.change(()=>{this.model.markers._refresh(n)})}reconvertItem(e){this.model.change(()=>{this.model.document.differ._refreshItem(e)})}}class so extends U(){_sourceDefinitions={};_attributeProperties=Object.create(null);_customChildChecks=new Map;_customAttributeChecks=new Map;_genericCheckSymbol=Symbol("$generic");_compiledDefinitions;constructor(){super(),this.decorate("checkChild"),this.decorate("checkAttribute"),this.on("checkAttribute",(e,t)=>{t[0]=new oe(t[0])},{priority:"highest"}),this.on("checkChild",(e,t)=>{t[0]=new oe(t[0]),t[1]=this.getDefinition(t[1])},{priority:"highest"})}register(e,t){if(this._sourceDefinitions[e])throw new f("schema-cannot-register-item-twice",this,{itemName:e});this._sourceDefinitions[e]=[Object.assign({},t)],this._clearCache()}extend(e,t){if(!this._sourceDefinitions[e])throw new f("schema-cannot-extend-missing-item",this,{itemName:e});this._sourceDefinitions[e].push(Object.assign({},t)),this._clearCache()}getDefinitions(){return this._compiledDefinitions||this._compile(),this._compiledDefinitions}getDefinition(e){let t;return typeof e=="string"?t=e:"is"in e&&(e.is("$text")||e.is("$textProxy"))?t="$text":t=e.name,this.getDefinitions()[t]}isRegistered(e){return!!this.getDefinition(e)}isBlock(e){const t=this.getDefinition(e);return!!(t&&t.isBlock)}isLimit(e){const t=this.getDefinition(e);return t?!!(t.isLimit||t.isObject):!1}isObject(e){const t=this.getDefinition(e);return t?!!(t.isObject||t.isLimit&&t.isSelectable&&t.isContent):!1}isInline(e){const t=this.getDefinition(e);return!!(t&&t.isInline)}isSelectable(e){const t=this.getDefinition(e);return t?!!(t.isSelectable||t.isObject):!1}isContent(e){const t=this.getDefinition(e);return t?!!(t.isContent||t.isObject):!1}checkChild(e,t){return t?this._checkContextMatch(e,t):!1}checkAttribute(e,t){const n=this.getDefinition(e.last);if(!n)return!1;const r=this._evaluateAttributeChecks(e,t);return r!==void 0?r:n.allowAttributes.includes(t)}checkMerge(e,t){if(e instanceof m){const n=e.nodeBefore,r=e.nodeAfter;if(!(n instanceof C))throw new f("schema-check-merge-no-element-before",this);if(!(r instanceof C))throw new f("schema-check-merge-no-element-after",this);return this.checkMerge(n,r)}if(this.isLimit(e)||this.isLimit(t))return!1;for(const n of t.getChildren())if(!this.checkChild(e,n))return!1;return!0}addChildCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,r=this._customChildChecks.get(n)||[];r.push(e),this._customChildChecks.set(n,r)}addAttributeCheck(e,t){const n=t!==void 0?t:this._genericCheckSymbol,r=this._customAttributeChecks.get(n)||[];r.push(e),this._customAttributeChecks.set(n,r)}setAttributeProperties(e,t){this._attributeProperties[e]=Object.assign(this.getAttributeProperties(e),t)}getAttributeProperties(e){return this._attributeProperties[e]||Object.create(null)}getLimitElement(e){let t;for(e instanceof m?t=e.parent:t=(e instanceof u?[e]:Array.from(e.getRanges())).reduce((r,i)=>{const o=i.getCommonAncestor();return r?r.getCommonAncestor(o,{includeSelf:!0}):o},null);!this.isLimit(t)&&t.parent;)t=t.parent;return t}checkAttributeInSelection(e,t){if(e.isCollapsed){const r=[...e.getFirstPosition().getAncestors(),new k("",e.getAttributes())];return this.checkAttribute(r,t)}else{const n=e.getRanges();for(const r of n)for(const i of r)if(this.checkAttribute(i.item,t))return!0}return!1}*getValidRanges(e,t){e=yo(e);for(const n of e)yield*this._getValidRangesForRange(n,t)}getNearestSelectionRange(e,t="both"){if(e.root.rootName=="$graveyard")return null;if(this.checkChild(e,"$text"))return new u(e);let n,r;const i=e.getAncestors().reverse().find(o=>this.isLimit(o))||e.root;(t=="both"||t=="backward")&&(n=new ie({boundaries:u._createIn(i),startPosition:e,direction:"backward"})),(t=="both"||t=="forward")&&(r=new ie({boundaries:u._createIn(i),startPosition:e}));for(const o of bo(n,r)){const a=o.walker==n?"elementEnd":"elementStart",l=o.value;if(l.type==a&&this.isObject(l.item))return u._createOn(l.item);if(this.checkChild(l.nextPosition,"$text"))return new u(l.nextPosition)}return null}findAllowedParent(e,t){let n=e.parent;for(;n;){if(this.checkChild(n,t))return n;if(this.isLimit(n))return null;n=n.parent}return null}setAllowedAttributes(e,t,n){const r=n.model;for(const[i,o]of Object.entries(t))r.schema.checkAttribute(e,i)&&n.setAttribute(i,o,e)}removeDisallowedAttributes(e,t){for(const n of e)if(n.is("$text"))An(this,n,t);else{const i=u._createIn(n).getPositions();for(const o of i){const a=o.nodeBefore||o.parent;An(this,a,t)}}}getAttributesWithProperty(e,t,n){const r={};for(const[i,o]of e.getAttributes()){const a=this.getAttributeProperties(i);a[t]!==void 0&&(n===void 0||n===a[t])&&(r[i]=o)}return r}createContext(e){return new oe(e)}_clearCache(){this._compiledDefinitions=null}_compile(){const e={},t=this._sourceDefinitions,n=Object.keys(t);for(const i of n)e[i]=ro(t[i],i);const r=Object.values(e);for(const i of r)io(e,i),oo(e,i),ao(e,i),lo(e,i);for(const i of r)co(e,i);for(const i of r)ho(e,i);for(const i of r)uo(e,i);for(const i of r)mo(e,i);for(const i of r)go(e,i);this._compiledDefinitions=fo(e)}_checkContextMatch(e,t){const n=e.last;let r=this._evaluateChildChecks(e,t);if(r=r!==void 0?r:t.allowIn.includes(n.name),!r)return!1;const i=this.getDefinition(n),o=e.trimLast();return i?o.length==0?!0:this._checkContextMatch(o,i):!1}_evaluateChildChecks(e,t){const n=this._customChildChecks.get(this._genericCheckSymbol)||[],r=this._customChildChecks.get(t.name)||[];for(const i of[...n,...r]){const o=i(e,t);if(o!==void 0)return o}}_evaluateAttributeChecks(e,t){const n=this._customAttributeChecks.get(this._genericCheckSymbol)||[],r=this._customAttributeChecks.get(t)||[];for(const i of[...n,...r]){const o=i(e,t);if(o!==void 0)return o}}*_getValidRangesForRange(e,t){let n=e.start,r=e.start;for(const i of e.getItems({shallow:!0}))i.is("element")&&(yield*this._getValidRangesForRange(u._createIn(i),t)),this.checkAttribute(i,t)||(n.isEqual(r)||(yield new u(n,r)),n=m._createAfter(i)),r=m._createAfter(i);n.isEqual(r)||(yield new u(n,r))}findOptimalInsertionRange(e,t){const n=e.getSelectedElement();if(n&&this.isObject(n)&&!this.isInline(n))return t=="before"||t=="after"?new u(m._createAt(n,t)):u._createOn(n);const r=Wt(e.getSelectedBlocks());if(!r)return new u(e.focus);if(r.isEmpty)return new u(m._createAt(r,0));const i=m._createAfter(r);return e.focus.isTouching(i)?new u(i):new u(m._createBefore(r))}}class oe{_items;constructor(e){if(e instanceof oe)return e;let t;typeof e=="string"?t=[e]:Array.isArray(e)?t=e:t=e.getAncestors({includeSelf:!0}),this._items=t.map(wo)}get length(){return this._items.length}get last(){return this._items[this._items.length-1]}[Symbol.iterator](){return this._items[Symbol.iterator]()}push(e){const t=new oe([e]);return t._items=[...this._items,...t._items],t}trimLast(){const e=new oe([]);return e._items=this._items.slice(0,-1),e}getItem(e){return this._items[e]}*getNames(){yield*this._items.map(e=>e.name)}endsWith(e){return Array.from(this.getNames()).join(" ").endsWith(e)}startsWith(e){return Array.from(this.getNames()).join(" ").startsWith(e)}}function ro(s,e){const t={name:e,allowIn:new Set,allowChildren:new Set,disallowIn:new Set,disallowChildren:new Set,allowContentOf:new Set,allowWhere:new Set,allowAttributes:new Set,disallowAttributes:new Set,allowAttributesOf:new Set,inheritTypesFrom:new Set};return po(s,t),H(s,t,"allowIn"),H(s,t,"allowChildren"),H(s,t,"disallowIn"),H(s,t,"disallowChildren"),H(s,t,"allowContentOf"),H(s,t,"allowWhere"),H(s,t,"allowAttributes"),H(s,t,"disallowAttributes"),H(s,t,"allowAttributesOf"),H(s,t,"inheritTypesFrom"),_o(s,t),t}function io(s,e){for(const t of e.allowIn){const n=s[t];n?n.allowChildren.add(e.name):e.allowIn.delete(t)}}function oo(s,e){for(const t of e.allowChildren){const n=s[t];n?n.allowIn.add(e.name):e.allowChildren.delete(t)}}function ao(s,e){for(const t of e.disallowIn){const n=s[t];n?n.disallowChildren.add(e.name):e.disallowIn.delete(t)}}function lo(s,e){for(const t of e.disallowChildren){const n=s[t];n?n.disallowIn.add(e.name):e.disallowChildren.delete(t)}}function co(s,e){for(const t of e.disallowChildren)e.allowChildren.delete(t);for(const t of e.disallowIn)e.allowIn.delete(t);for(const t of e.disallowAttributes)e.allowAttributes.delete(t)}function ho(s,e){for(const t of e.allowContentOf){const n=s[t];n&&(n.disallowChildren.forEach(r=>{e.allowChildren.has(r)||(e.disallowChildren.add(r),s[r].disallowIn.add(e.name))}),n.allowChildren.forEach(r=>{e.disallowChildren.has(r)||(e.allowChildren.add(r),s[r].allowIn.add(e.name))}))}}function uo(s,e){for(const t of e.allowWhere){const n=s[t];n&&(n.disallowIn.forEach(r=>{e.allowIn.has(r)||(e.disallowIn.add(r),s[r].disallowChildren.add(e.name))}),n.allowIn.forEach(r=>{e.disallowIn.has(r)||(e.allowIn.add(r),s[r].allowChildren.add(e.name))}))}}function fo(s){const e={};for(const t of Object.values(s))e[t.name]={name:t.name,isBlock:!!t.isBlock,isContent:!!t.isContent,isInline:!!t.isInline,isLimit:!!t.isLimit,isObject:!!t.isObject,isSelectable:!!t.isSelectable,allowIn:Array.from(t.allowIn).filter(n=>!!s[n]),allowChildren:Array.from(t.allowChildren).filter(n=>!!s[n]),allowAttributes:Array.from(t.allowAttributes)};return e}function mo(s,e){for(const t of e.allowAttributesOf){const n=s[t];if(!n)return;n.allowAttributes.forEach(r=>{e.disallowAttributes.has(r)||e.allowAttributes.add(r)})}}function go(s,e){for(const t of e.inheritTypesFrom){const n=s[t];if(n){const r=Object.keys(n).filter(i=>i.startsWith("is"));for(const i of r)i in e||(e[i]=n[i])}}}function po(s,e){for(const t of s){const n=Object.keys(t).filter(r=>r.startsWith("is"));for(const r of n)e[r]=!!t[r]}}function H(s,e,t){for(const n of s){let r=n[t];typeof r=="string"&&(r=[r]),Array.isArray(r)&&r.forEach(i=>e[t].add(i))}}function _o(s,e){for(const t of s){const n=t.inheritAllFrom;n&&(e.allowContentOf.add(n),e.allowWhere.add(n),e.allowAttributesOf.add(n),e.inheritTypesFrom.add(n))}}function wo(s){return typeof s=="string"||s.is("documentFragment")?{name:typeof s=="string"?s:"$documentFragment",*getAttributeKeys(){},getAttribute(){}}:{name:s.is("element")?s.name:"$text",*getAttributeKeys(){yield*s.getAttributeKeys()},getAttribute(e){return s.getAttribute(e)}}}function*bo(s,e){let t=!1;for(;!t;){if(t=!0,s){const n=s.next();n.done||(t=!1,yield{walker:s,value:n.value})}if(e){const n=e.next();n.done||(t=!1,yield{walker:e,value:n.value})}}}function*yo(s){for(const e of s)yield*e.getMinimalFlatRanges()}function An(s,e,t){for(const n of e.getAttributeKeys())s.checkAttribute(e,n)||t.removeAttribute(n,e)}class vo extends N(){conversionApi;_splitParts=new Map;_cursorParents=new Map;_modelCursor=null;_emptyElementsToKeep=new Set;constructor(e){super(),this.conversionApi={...e,consumable:null,writer:null,store:null,convertItem:(t,n)=>this._convertItem(t,n),convertChildren:(t,n)=>this._convertChildren(t,n),safeInsert:(t,n)=>this._safeInsert(t,n),updateConversionResult:(t,n)=>this._updateConversionResult(t,n),splitToAllowedParent:(t,n)=>this._splitToAllowedParent(t,n),getSplitParts:t=>this._getSplitParts(t),keepEmptyElement:t=>this._keepEmptyElement(t)}}convert(e,t,n=["$root"]){this.fire("viewCleanup",e),this._modelCursor=Co(n,t),this.conversionApi.writer=t,this.conversionApi.consumable=ct.createFrom(e),this.conversionApi.store={};const{modelRange:r}=this._convertItem(e,this._modelCursor),i=t.createDocumentFragment();if(r){this._removeEmptyElements();const o=this._modelCursor.parent,a=o._removeChildren(0,o.childCount);i._insertChild(0,a),i.markers=Po(i,t)}return this._modelCursor=null,this._splitParts.clear(),this._cursorParents.clear(),this._emptyElementsToKeep.clear(),this.conversionApi.writer=null,this.conversionApi.store=null,i}_convertItem(e,t){const n={viewItem:e,modelCursor:t,modelRange:null};if(e.is("element")?this.fire(`element:${e.name}`,n,this.conversionApi):e.is("$text")?this.fire("text",n,this.conversionApi):this.fire("documentFragment",n,this.conversionApi),n.modelRange&&!(n.modelRange instanceof u))throw new f("view-conversion-dispatcher-incorrect-result",this);return{modelRange:n.modelRange,modelCursor:n.modelCursor}}_convertChildren(e,t){let n=t.is("position")?t:m._createAt(t,0);const r=new u(n);for(const i of Array.from(e.getChildren())){const o=this._convertItem(i,n);o.modelRange instanceof u&&(r.end=o.modelRange.end,n=o.modelCursor)}return{modelRange:r,modelCursor:n}}_safeInsert(e,t){const n=this._splitToAllowedParent(e,t);return n?(this.conversionApi.writer.insert(e,n.position),!0):!1}_updateConversionResult(e,t){const n=this._getSplitParts(e),r=this.conversionApi.writer;t.modelRange||(t.modelRange=r.createRange(r.createPositionBefore(e),r.createPositionAfter(n[n.length-1])));const i=this._cursorParents.get(e);i?t.modelCursor=r.createPositionAt(i,0):t.modelCursor=t.modelRange.end}_splitToAllowedParent(e,t){const{schema:n,writer:r}=this.conversionApi;let i=n.findAllowedParent(t,e);if(i){if(i===t.parent)return{position:t};this._modelCursor.parent.getAncestors().includes(i)&&(i=null)}if(!i)return ys(t,e,n)?{position:vs(t,r)}:null;const o=this.conversionApi.writer.split(t,i),a=[];for(const c of o.range.getWalker())if(c.type=="elementEnd")a.push(c.item);else{const h=a.pop(),d=c.item;this._registerSplitPair(h,d)}const l=o.range.end.parent;return this._cursorParents.set(e,l),{position:o.position,cursorParent:l}}_registerSplitPair(e,t){this._splitParts.has(e)||this._splitParts.set(e,[e]);const n=this._splitParts.get(e);this._splitParts.set(t,n),n.push(t)}_getSplitParts(e){let t;return this._splitParts.has(e)?t=this._splitParts.get(e):t=[e],t}_keepEmptyElement(e){this._emptyElementsToKeep.add(e)}_removeEmptyElements(){const e=new Map;for(const t of this._splitParts.keys())if(t.isEmpty&&!this._emptyElementsToKeep.has(t)){const n=e.get(t.parent)||[];n.push(t),this._splitParts.delete(t),e.set(t.parent,n)}for(const[t,n]of e)t._removeChildrenArray(n);e.size&&this._removeEmptyElements()}}function Po(s,e){const t=new Set,n=new Map,r=u._createIn(s).getItems();for(const i of r)i.is("element","$marker")&&t.add(i);for(const i of t){const o=i.getAttribute("data-name"),a=e.createPositionBefore(i);n.has(o)?n.get(o).end=a.clone():n.set(o,new u(a.clone())),e.remove(i)}return n}function Co(s,e){let t;for(const n of new oe(s)){const r={};for(const o of n.getAttributeKeys())r[o]=n.getAttribute(o);const i=e.createElement(n.name,r);t&&e.insert(i,t),t=m._createAt(i,0)}return t}class ko{getHtml(e){const n=re.document.implementation.createHTMLDocument("").createElement("div");return n.appendChild(e),n.innerHTML}}class Ao{domParser;domConverter;htmlWriter;skipComments=!0;constructor(e){this.domParser=new DOMParser,this.domConverter=new ns(e,{renderingMode:"data"}),this.htmlWriter=new ko}toData(e){const t=this.domConverter.viewToDom(e);return this.htmlWriter.getHtml(t)}toView(e){const t=this._toDom(e);return this.domConverter.domToView(t,{skipComments:this.skipComments})}registerRawContentMatcher(e){this.domConverter.registerRawContentMatcher(e)}useFillerType(e){this.domConverter.blockFillerMode=e=="marked"?"markedNbsp":"nbsp"}_toDom(e){/<(?:html|body|head|meta)(?:\s[^>]*)?>/i.test(e.trim().slice(0,1e4))||(e=`<body>${e}</body>`);const t=this.domParser.parseFromString(e,"text/html"),n=t.createDocumentFragment(),r=t.body.childNodes;for(;r.length>0;)n.appendChild(r[0]);return n}}class wl extends N(){model;mapper;downcastDispatcher;upcastDispatcher;viewDocument;stylesProcessor;htmlProcessor;processor;_viewWriter;constructor(e,t){super(),this.model=e,this.mapper=new as,this.downcastDispatcher=new ls({mapper:this.mapper,schema:e.schema}),this.downcastDispatcher.on("insert:$text",us(),{priority:"lowest"}),this.downcastDispatcher.on("insert",fs(),{priority:"lowest"}),this.upcastDispatcher=new vo({schema:e.schema}),this.viewDocument=new Xn(t),this.stylesProcessor=t,this.htmlProcessor=new Ao(this.viewDocument),this.processor=this.htmlProcessor,this._viewWriter=new Yn(this.viewDocument),this.upcastDispatcher.on("text",Ji(),{priority:"lowest"}),this.upcastDispatcher.on("element",Cn(),{priority:"lowest"}),this.upcastDispatcher.on("documentFragment",Cn(),{priority:"lowest"}),U().prototype.decorate.call(this,"init"),U().prototype.decorate.call(this,"set"),U().prototype.decorate.call(this,"get"),U().prototype.decorate.call(this,"toView"),U().prototype.decorate.call(this,"toModel"),this.on("init",()=>{this.fire("ready")},{priority:"lowest"}),this.on("ready",()=>{this.model.enqueueChange({isUndoable:!1},bs)},{priority:"lowest"})}get(e={}){const{rootName:t="main",trim:n="empty"}=e;if(!this._checkIfRootsExists([t]))throw new f("datacontroller-get-non-existent-root",this);const r=this.model.document.getRoot(t);return r.isAttached()||W("datacontroller-get-detached-root",this),n==="empty"&&!this.model.hasContent(r,{ignoreWhitespaces:!0})?"":this.stringify(r,e)}stringify(e,t={}){const n=this.toView(e,t);return this.processor.toData(n)}toView(e,t={}){const n=this.viewDocument,r=this._viewWriter;this.mapper.clearBindings();const i=u._createIn(e),o=new ge(n);this.mapper.bindElements(e,o);const a=e.is("documentFragment")?e.markers:So(e);return this.downcastDispatcher.convert(i,a,r,t),o}init(e){if(this.model.document.version)throw new f("datacontroller-init-document-not-empty",this);let t={};if(typeof e=="string"?t.main=e:t=e,!this._checkIfRootsExists(Object.keys(t)))throw new f("datacontroller-init-non-existent-root",this);return this.model.enqueueChange({isUndoable:!1},n=>{for(const r of Object.keys(t)){const i=this.model.document.getRoot(r);n.insert(this.parse(t[r],i),i,0)}}),Promise.resolve()}set(e,t={}){let n={};if(typeof e=="string"?n.main=e:n=e,!this._checkIfRootsExists(Object.keys(n)))throw new f("datacontroller-set-non-existent-root",this);this.model.enqueueChange(t.batchType||{},r=>{r.setSelection(null),r.removeSelectionAttribute(this.model.document.selection.getAttributeKeys());for(const i of Object.keys(n)){const o=this.model.document.getRoot(i);r.remove(r.createRangeIn(o)),r.insert(this.parse(n[i],o),o,0)}})}parse(e,t="$root"){const n=this.processor.toView(e);return this.toModel(n,t)}toModel(e,t="$root"){return this.model.change(n=>this.upcastDispatcher.convert(e,n,t))}addStyleProcessorRules(e){e(this.stylesProcessor)}registerRawContentMatcher(e){this.processor&&this.processor!==this.htmlProcessor&&this.processor.registerRawContentMatcher(e),this.htmlProcessor.registerRawContentMatcher(e)}destroy(){this.stopListening()}_checkIfRootsExists(e){for(const t of e)if(!this.model.document.getRoot(t))return!1;return!0}}function So(s){const e=[],t=s.root.document;if(!t)return new Map;const n=u._createIn(s);for(const r of t.model.markers){const i=r.getRange(),o=i.isCollapsed,a=i.start.isEqual(n.start)||i.end.isEqual(n.end);if(o&&a)e.push([r.name,i]);else{const l=n.getIntersection(i);l&&e.push([r.name,l])}}return e.sort(([r,i],[o,a])=>{if(i.end.compareWith(a.start)!=="after")return 1;if(i.start.compareWith(a.end)!=="before")return-1;switch(i.start.compareWith(a.start)){case"before":return 1;case"after":return-1;default:switch(i.end.compareWith(a.end)){case"before":return 1;case"after":return-1;default:return o.localeCompare(r)}}}),new Map(e)}class bl{_helpers=new Map;_downcast;_upcast;constructor(e,t){this._downcast=ae(e),this._createConversionHelpers({name:"downcast",dispatchers:this._downcast,isDowncast:!0}),this._upcast=ae(t),this._createConversionHelpers({name:"upcast",dispatchers:this._upcast,isDowncast:!1})}addAlias(e,t){const n=this._downcast.includes(t);if(!this._upcast.includes(t)&&!n)throw new f("conversion-add-alias-dispatcher-not-registered",this);this._createConversionHelpers({name:e,dispatchers:[t],isDowncast:n})}for(e){if(!this._helpers.has(e))throw new f("conversion-for-unknown-group",this);return this._helpers.get(e)}elementToElement(e){this.for("downcast").elementToElement(e);for(const{model:t,view:n}of At(e))this.for("upcast").elementToElement({model:t,view:n,converterPriority:e.converterPriority})}attributeToElement(e){this.for("downcast").attributeToElement(e);for(const{model:t,view:n}of At(e))this.for("upcast").elementToAttribute({view:n,model:t,converterPriority:e.converterPriority})}attributeToAttribute(e){this.for("downcast").attributeToAttribute(e);for(const{model:t,view:n}of At(e))this.for("upcast").attributeToAttribute({view:n,model:t})}_createConversionHelpers({name:e,dispatchers:t,isDowncast:n}){if(this._helpers.has(e))throw new f("conversion-group-exists",this);const r=n?new fi(t):new Ui(t);this._helpers.set(e,r)}}function*At(s){if(s.model.values)for(const e of s.model.values){const t={key:s.model.key,value:e},n=s.view[e],r=s.upcastAlso?s.upcastAlso[e]:void 0;yield*Sn(t,n,r)}else yield*Sn(s.model,s.view,s.upcastAlso)}function*Sn(s,e,t){if(yield{model:s,view:e},t)for(const n of ae(t))yield{model:s,view:n}}/**
22
22
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
23
23
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
24
- */class z{constructor(t){c(this,"baseVersion");c(this,"isDocumentOperation");c(this,"batch");this.baseVersion=t,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){const t=Object.assign({},this);return t.__className=this.constructor.className,delete t.batch,delete t.isDocumentOperation,t}static get className(){return"Operation"}static fromJSON(t,e){return new this(t.baseVersion)}}function Qt(r,t){const e=Rs(t),n=e.reduce((o,a)=>o+a.offsetSize,0),s=r.parent;tt(r);const i=r.index;return s._insertChild(i,e),et(s,i+e.length),et(s,i),new f(r,r.getShiftedBy(n))}function Es(r){if(!r.isFlat)throw new d("operation-utils-remove-range-not-flat",this);const t=r.start.parent;tt(r.start),tt(r.end);const e=t._removeChildren(r.start.index,r.end.index-r.start.index);return et(t,r.start.index),e}function Ze(r,t){if(!r.isFlat)throw new d("operation-utils-move-range-not-flat",this);const e=Es(r);return t=t._getTransformedByDeletion(r.start,r.end.offset-r.start.offset),Qt(t,e)}function xo(r,t,e){tt(r.start),tt(r.end);for(const n of r.getItems({shallow:!0})){const s=n.is("$textProxy")?n.textNode:n;e!==null?s._setAttribute(t,e):s._removeAttribute(t),et(s.parent,s.index)}et(r.end.parent,r.end.index)}function Rs(r){const t=[];function e(n){if(typeof n=="string")t.push(new A(n));else if(n instanceof G)t.push(new A(n.data,n.getAttributes()));else if(n instanceof Ce)t.push(n);else if(ce(n))for(const s of n)e(s)}e(r);for(let n=1;n<t.length;n++){const s=t[n],i=t[n-1];s instanceof A&&i instanceof A&&Ts(s,i)&&(t.splice(n-1,2,new A(i.data+s.data,i.getAttributes())),n--)}return t}function et(r,t){const e=r.getChild(t-1),n=r.getChild(t);if(e&&n&&e.is("$text")&&n.is("$text")&&Ts(e,n)){const s=new A(e.data+n.data,e.getAttributes());r._removeChildren(t-1,2),r._insertChild(t-1,s)}}function tt(r){const t=r.textNode,e=r.parent;if(t){const n=r.offset-t.startOffset,s=t.index;e._removeChildren(s,1);const i=new A(t.data.substr(0,n),t.getAttributes()),o=new A(t.data.substr(n),t.getAttributes());e._insertChild(s,[i,o])}}function Ts(r,t){const e=r.getAttributes(),n=t.getAttributes();for(const s of e){if(s[1]!==t.getAttribute(s[0]))return!1;n.next()}return n.next().done}class P extends z{constructor(e,n,s,i){super(i);c(this,"sourcePosition");c(this,"howMany");c(this,"targetPosition");this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=n,this.targetPosition=s.clone(),this.targetPosition.stickiness="toNone"}get type(){return this.targetPosition.root.rootName=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[f._createFromPositionAndShift(this.sourcePosition,this.howMany),f._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new P(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new P(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,n=this.targetPosition.parent,s=this.sourcePosition.offset,i=this.targetPosition.offset;if(s+this.howMany>e.maxOffset)throw new d("move-operation-nodes-do-not-exist",this);if(e===n&&s<i&&i<s+this.howMany)throw new d("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&B(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const o=this.sourcePosition.path.length-1;if(this.targetPosition.path[o]>=s&&this.targetPosition.path[o]<s+this.howMany)throw new d("move-operation-node-into-itself",this)}}_execute(){Ze(f._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,n){const s=g.fromJSON(e.sourcePosition,n),i=g.fromJSON(e.targetPosition,n);return new this(s,e.howMany,i,e.baseVersion)}}class M extends z{constructor(e,n,s){super(s);c(this,"position");c(this,"nodes");c(this,"shouldReceiveAttributes");this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new Ue(Rs(n)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new Ue([...this.nodes].map(s=>s._clone(!0))),n=new M(this.position,e,this.baseVersion);return n.shouldReceiveAttributes=this.shouldReceiveAttributes,n}getReversed(){const e=this.position.root.document.graveyard,n=new g(e,[0]);return new P(this.position,this.nodes.maxOffset,n,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new d("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new Ue([...e].map(n=>n._clone(!0))),Qt(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,n){const s=[];for(const o of e.nodes)o.name?s.push(k.fromJSON(o)):s.push(A.fromJSON(o));const i=new M(g.fromJSON(e.position,n),s,e.baseVersion);return i.shouldReceiveAttributes=e.shouldReceiveAttributes,i}}class C extends z{constructor(e,n,s,i,o){super(o);c(this,"splitPosition");c(this,"howMany");c(this,"insertionPosition");c(this,"graveyardPosition");this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=n,this.insertionPosition=s,this.graveyardPosition=i?i.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new g(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new f(this.splitPosition,e)}get affectedSelectable(){const e=[f._createFromPositionAndShift(this.splitPosition,0),f._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(f._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new C(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,n=new g(e,[0]);return new S(this.moveTargetPosition,this.howMany,this.splitPosition,n,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,n=this.splitPosition.offset;if(!e||e.maxOffset<n)throw new d("split-operation-position-invalid",this);if(e.parent){if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new d("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new d("split-operation-graveyard-position-invalid",this)}else throw new d("split-operation-split-in-root",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)Ze(f._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const s=e._clone();Qt(this.insertionPosition,s)}const n=new f(g._createAt(e,this.splitPosition.offset),g._createAt(e,e.maxOffset));Ze(n,this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const n=e.path.slice(0,-1);return n[n.length-1]++,new g(e.root,n,"toPrevious")}static fromJSON(e,n){const s=g.fromJSON(e.splitPosition,n),i=g.fromJSON(e.insertionPosition,n),o=e.graveyardPosition?g.fromJSON(e.graveyardPosition,n):null;return new this(s,e.howMany,i,o,e.baseVersion)}}class S extends z{constructor(e,n,s,i,o){super(o);c(this,"sourcePosition");c(this,"howMany");c(this,"targetPosition");c(this,"graveyardPosition");this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=n,this.targetPosition=s.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=i.clone()}get type(){return"merge"}get deletionPosition(){return new g(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new f(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[f._createOn(e),f._createFromPositionAndShift(this.targetPosition,0),f._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new S(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),n=this.sourcePosition.path.slice(0,-1),s=new g(this.sourcePosition.root,n)._getTransformedByMergeOperation(this);return new C(e,this.howMany,s,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,n=this.targetPosition.parent;if(e.parent)if(n.parent){if(this.howMany!=e.maxOffset)throw new d("merge-operation-how-many-invalid",this)}else throw new d("merge-operation-target-position-invalid",this);else throw new d("merge-operation-source-position-invalid",this)}_execute(){const e=this.sourcePosition.parent,n=f._createIn(e);Ze(n,this.targetPosition),Ze(f._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,n){const s=g.fromJSON(e.sourcePosition,n),i=g.fromJSON(e.targetPosition,n),o=g.fromJSON(e.graveyardPosition,n);return new this(s,e.howMany,i,o,e.baseVersion)}}class V extends z{constructor(e,n,s,i,o,a){super(a);c(this,"name");c(this,"oldRange");c(this,"newRange");c(this,"affectsData");c(this,"_markers");this.name=e,this.oldRange=n?n.clone():null,this.newRange=s?s.clone():null,this.affectsData=o,this._markers=i}get type(){return"marker"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new V(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new V(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,n){return new V(e.name,e.oldRange?f.fromJSON(e.oldRange,n):null,e.newRange?f.fromJSON(e.newRange,n):null,n.model.markers,e.affectsData,e.baseVersion)}}class E extends z{constructor(e,n,s,i,o){super(o);c(this,"range");c(this,"key");c(this,"oldValue");c(this,"newValue");this.range=e.clone(),this.key=n,this.oldValue=s===void 0?null:s,this.newValue=i===void 0?null:i}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new E(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new E(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new d("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!rn(e.getAttribute(this.key),this.oldValue))throw new d("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(this.oldValue===null&&this.newValue!==null&&e.hasAttribute(this.key))throw new d("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){rn(this.oldValue,this.newValue)||xo(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,n){return new E(f.fromJSON(e.range,n),e.key,e.oldValue,e.newValue,e.baseVersion)}}class T extends z{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new T(this.baseVersion)}getReversed(){return new T(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class $ extends z{constructor(e,n,s,i){super(i);c(this,"position");c(this,"oldName");c(this,"newName");this.position=e,this.position.stickiness="toNext",this.oldName=n,this.newName=s}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new $(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new $(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof k){if(e.name!==this.oldName)throw new d("rename-operation-wrong-name",this)}else throw new d("rename-operation-wrong-position",this)}_execute(){const e=this.position.nodeAfter;e.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,n){return new $(g.fromJSON(e.position,n),e.oldName,e.newName,e.baseVersion)}}class te extends z{constructor(e,n,s,i,o){super(o);c(this,"root");c(this,"key");c(this,"oldValue");c(this,"newValue");this.root=e,this.key=n,this.oldValue=s===void 0?null:s,this.newValue=i===void 0?null:i}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new te(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new te(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new d("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(this.oldValue!==null&&this.root.getAttribute(this.key)!==this.oldValue)throw new d("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(this.oldValue===null&&this.newValue!==null&&this.root.hasAttribute(this.key))throw new d("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){this.newValue!==null?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,n){if(!n.getRoot(e.root))throw new d("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new te(n.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class Y extends z{constructor(e,n,s,i,o){super(o);c(this,"rootName");c(this,"elementName");c(this,"isAdd");c(this,"_document");if(this.rootName=e,this.elementName=n,this.isAdd=s,this._document=i,!this._document.getRoot(this.rootName)){const a=this._document.createRoot(this.elementName,this.rootName);a._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new Y(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new Y(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,n){return new Y(e.rootName,e.elementName,e.isAdd,n,e.baseVersion)}}const j={};j[E.className]=E;j[M.className]=M;j[V.className]=V;j[P.className]=P;j[T.className]=T;j[z.className]=z;j[$.className]=$;j[te.className]=te;j[Y.className]=Y;j[C.className]=C;j[S.className]=S;class No{static fromJSON(t,e){return j[t.__className].fromJSON(t,e)}}const Lt=new Map;function v(r,t,e){let n=Lt.get(r);n||(n=new Map,Lt.set(r,n)),n.set(t,e)}function Oo(r,t){const e=Lt.get(r);return e&&e.has(t)?e.get(t):Io}function Io(r){return[r]}function Tn(r,t,e={}){const n=Oo(r.constructor,t.constructor);try{return r=r.clone(),n(r,t,e)}catch(s){throw s}}function Al(r,t,e){r=r.slice(),t=t.slice();const n=new Fo(e.document,e.useRelations,e.forceWeakRemove);n.setOriginalOperations(r),n.setOriginalOperations(t);const s=n.originalOperations;if(r.length==0||t.length==0)return{operationsA:r,operationsB:t,originalOperations:s};const i=new WeakMap;for(const l of r)i.set(l,0);const o={nextBaseVersionA:r[r.length-1].baseVersion+1,nextBaseVersionB:t[t.length-1].baseVersion+1,originalOperationsACount:r.length,originalOperationsBCount:t.length};let a=0;for(;a<r.length;){const l=r[a],h=i.get(l);if(h==t.length){a++;continue}const u=t[h],m=Tn(l,u,n.getContext(l,u,!0)),p=Tn(u,l,n.getContext(u,l,!1));n.updateRelation(l,u),n.setOriginalOperations(m,l),n.setOriginalOperations(p,u);for(const w of m)i.set(w,h+p.length);r.splice(a,1,...m),t.splice(h,1,...p)}return xn(r),xn(t),Mn(r,o.nextBaseVersionB),Mn(t,o.nextBaseVersionA),{operationsA:r,operationsB:t,originalOperations:s}}class Fo{constructor(t,e,n=!1){c(this,"originalOperations");c(this,"_history");c(this,"_useRelations");c(this,"_forceWeakRemove");c(this,"_relations");this.originalOperations=new Map,this._history=t.history,this._useRelations=e,this._forceWeakRemove=!!n,this._relations=new Map}setOriginalOperations(t,e=null){const n=e?this.originalOperations.get(e):null;for(const s of t)this.originalOperations.set(s,n||s)}updateRelation(t,e){if(t instanceof P)e instanceof S?t.targetPosition.isEqual(e.sourcePosition)||e.movedRange.containsPosition(t.targetPosition)?this._setRelation(t,e,"insertAtSource"):t.targetPosition.isEqual(e.deletionPosition)?this._setRelation(t,e,"insertBetween"):t.targetPosition.isAfter(e.sourcePosition)&&this._setRelation(t,e,"moveTargetAfter"):e instanceof P&&(t.targetPosition.isEqual(e.sourcePosition)||t.targetPosition.isBefore(e.sourcePosition)?this._setRelation(t,e,"insertBefore"):this._setRelation(t,e,"insertAfter"));else if(t instanceof C){if(e instanceof S)t.splitPosition.isBefore(e.sourcePosition)&&this._setRelation(t,e,"splitBefore");else if(e instanceof P)if(t.splitPosition.isEqual(e.sourcePosition)||t.splitPosition.isBefore(e.sourcePosition))this._setRelation(t,e,"splitBefore");else{const n=f._createFromPositionAndShift(e.sourcePosition,e.howMany);if(t.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(t.splitPosition)){const s=n.end.offset-t.splitPosition.offset,i=t.splitPosition.offset-n.start.offset;this._setRelation(t,e,{howMany:s,offset:i})}}}else if(t instanceof S)e instanceof S?(t.targetPosition.isEqual(e.sourcePosition)||this._setRelation(t,e,"mergeTargetNotMoved"),t.sourcePosition.isEqual(e.targetPosition)&&this._setRelation(t,e,"mergeSourceNotMoved"),t.sourcePosition.isEqual(e.sourcePosition)&&this._setRelation(t,e,"mergeSameElement")):e instanceof C?t.sourcePosition.isEqual(e.splitPosition)&&this._setRelation(t,e,"splitAtSource"):e instanceof P&&e.howMany>0&&(t.sourcePosition.isEqual(e.sourcePosition.getShiftedBy(e.howMany))&&this._setRelation(t,e,"mergeSourceAffected"),t.targetPosition.isEqual(e.sourcePosition)&&this._setRelation(t,e,"mergeTargetWasBefore"));else if(t instanceof V){const n=t.newRange;if(!n)return;if(e instanceof S){const s=n.start.isEqual(e.targetPosition),i=n.start.isEqual(e.deletionPosition),o=n.end.isEqual(e.deletionPosition),a=n.end.isEqual(e.sourcePosition);(s||i||o||a)&&this._setRelation(t,e,{wasInLeftElement:s,wasStartBeforeMergedElement:i,wasEndBeforeMergedElement:o,wasInRightElement:a})}}}getContext(t,e,n){return{aIsStrong:n,aWasUndone:this._wasUndone(t),bWasUndone:this._wasUndone(e),abRelation:this._useRelations?this._getRelation(t,e):null,baRelation:this._useRelations?this._getRelation(e,t):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(t){const e=this.originalOperations.get(t);return e.wasUndone||this._history.isUndoneOperation(e)}_getRelation(t,e){const n=this.originalOperations.get(e),s=this._history.getUndoneOperation(n);if(!s)return null;const i=this.originalOperations.get(t),o=this._relations.get(i);return o&&o.get(s)||null}_setRelation(t,e,n){const s=this.originalOperations.get(t),i=this.originalOperations.get(e);let o=this._relations.get(s);o||(o=new Map,this._relations.set(s,o)),o.set(i,n)}}function Mn(r,t){for(const e of r)e.baseVersion=t++}function xn(r){const t=new Map;for(let e=0;e<r.length;e++){const n=r[e];n instanceof V&&(n.baseVersion!==-1?t.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]}):(n.newRange&&t.get(n.name).ranges.push(n.newRange),r.splice(e,1),e--))}for(const{op:e,ranges:n}of t.values())n.length?e.newRange=f._createFromRanges(n):e.newRange=null}v(E,E,(r,t,e)=>{if(r.key===t.key&&r.range.start.hasSameParentAs(t.range.start)){const n=r.range.getDifference(t.range).map(i=>new E(i,r.key,r.oldValue,r.newValue,0)),s=r.range.getIntersection(t.range);return s&&e.aIsStrong&&n.push(new E(s,t.key,t.newValue,r.newValue,0)),n.length==0?[new T(0)]:n}else return[r]});v(E,M,(r,t)=>{if(r.range.start.hasSameParentAs(t.position)&&r.range.containsPosition(t.position)){const n=r.range._getTransformedByInsertion(t.position,t.howMany,!t.shouldReceiveAttributes).map(s=>new E(s,r.key,r.oldValue,r.newValue,r.baseVersion));if(t.shouldReceiveAttributes){const s=Ms(t,r.key,r.oldValue);s&&n.unshift(s)}return n}return r.range=r.range._getTransformedByInsertion(t.position,t.howMany,!1)[0],[r]});function Ms(r,t,e){const s=r.nodes.getNode(0).getAttribute(t);if(s==e)return null;const i=new f(r.position,r.position.getShiftedBy(r.howMany));return new E(i,t,s,e,0)}v(E,S,(r,t)=>{const e=[];r.range.start.hasSameParentAs(t.deletionPosition)&&(r.range.containsPosition(t.deletionPosition)||r.range.start.isEqual(t.deletionPosition))&&e.push(f._createFromPositionAndShift(t.graveyardPosition,1));const n=r.range._getTransformedByMergeOperation(t);return n.isCollapsed||e.push(n),e.map(s=>new E(s,r.key,r.oldValue,r.newValue,r.baseVersion))});v(E,P,(r,t)=>Bo(r.range,t).map(n=>new E(n,r.key,r.oldValue,r.newValue,r.baseVersion)));function Bo(r,t){const e=f._createFromPositionAndShift(t.sourcePosition,t.howMany);let n=null,s=[];e.containsRange(r,!0)?n=r:r.start.hasSameParentAs(e.start)?(s=r.getDifference(e),n=r.getIntersection(e)):s=[r];const i=[];for(let o of s){o=o._getTransformedByDeletion(t.sourcePosition,t.howMany);const a=t.getMovedRangeStart(),l=o.start.hasSameParentAs(a),h=o._getTransformedByInsertion(a,t.howMany,l);i.push(...h)}return n&&i.push(n._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany,!1)[0]),i}v(E,C,(r,t)=>{if(r.range.end.isEqual(t.insertionPosition))return t.graveyardPosition||r.range.end.offset++,[r];if(r.range.start.hasSameParentAs(t.splitPosition)&&r.range.containsPosition(t.splitPosition)){const e=r.clone();return e.range=new f(t.moveTargetPosition.clone(),r.range.end._getCombined(t.splitPosition,t.moveTargetPosition)),r.range.end=t.splitPosition.clone(),r.range.end.stickiness="toPrevious",[r,e]}return r.range=r.range._getTransformedBySplitOperation(t),[r]});v(M,E,(r,t)=>{const e=[r];if(r.shouldReceiveAttributes&&r.position.hasSameParentAs(t.range.start)&&t.range.containsPosition(r.position)){const n=Ms(r,t.key,t.newValue);n&&e.push(n)}return e});v(M,M,(r,t,e)=>r.position.isEqual(t.position)&&e.aIsStrong?[r]:(r.position=r.position._getTransformedByInsertOperation(t),[r]));v(M,P,(r,t)=>(r.position=r.position._getTransformedByMoveOperation(t),[r]));v(M,C,(r,t)=>(r.position=r.position._getTransformedBySplitOperation(t),[r]));v(M,S,(r,t)=>(r.position=r.position._getTransformedByMergeOperation(t),[r]));v(V,M,(r,t)=>(r.oldRange&&(r.oldRange=r.oldRange._getTransformedByInsertOperation(t)[0]),r.newRange&&(r.newRange=r.newRange._getTransformedByInsertOperation(t)[0]),[r]));v(V,V,(r,t,e)=>{if(r.name==t.name)if(e.aIsStrong)r.oldRange=t.newRange?t.newRange.clone():null;else return[new T(0)];return[r]});v(V,S,(r,t)=>(r.oldRange&&(r.oldRange=r.oldRange._getTransformedByMergeOperation(t)),r.newRange&&(r.newRange=r.newRange._getTransformedByMergeOperation(t)),[r]));v(V,P,(r,t)=>{const e=[r];if(r.oldRange&&(r.oldRange=f._createFromRanges(r.oldRange._getTransformedByMoveOperation(t))),r.newRange){const n=r.newRange._getTransformedByMoveOperation(t);r.newRange=n[0];for(let s=1;s<n.length;s++){const i=r.clone();i.oldRange=null,i.newRange=n[s],i.baseVersion=-1,e.push(i)}}return e});v(V,C,(r,t,e)=>{if(r.oldRange&&(r.oldRange=r.oldRange._getTransformedBySplitOperation(t)),r.newRange){if(e.abRelation){const n=r.newRange._getTransformedBySplitOperation(t);return r.newRange.start.isEqual(t.splitPosition)?e.abRelation.wasStartBeforeMergedElement?r.newRange.start=g._createAt(t.insertionPosition):e.abRelation.wasInLeftElement?r.newRange.start=g._createAt(r.newRange.start):r.newRange.start=g._createAt(t.moveTargetPosition):r.newRange.start=n.start,r.newRange.end.isEqual(t.splitPosition)?r.newRange.end.isEqual(t.splitPosition)&&e.abRelation.wasEndBeforeMergedElement?r.newRange.end=g._createAt(t.insertionPosition):e.abRelation.wasInRightElement?r.newRange.end=g._createAt(t.moveTargetPosition):r.newRange.end=g._createAt(r.newRange.end):r.newRange.end=n.end,[r]}r.newRange=r.newRange._getTransformedBySplitOperation(t)}return[r]});v(S,M,(r,t)=>(r.sourcePosition.hasSameParentAs(t.position)&&(r.howMany+=t.howMany),r.sourcePosition=r.sourcePosition._getTransformedByInsertOperation(t),r.targetPosition=r.targetPosition._getTransformedByInsertOperation(t),[r]));v(S,S,(r,t,e)=>{if(r.sourcePosition.isEqual(t.sourcePosition)&&r.targetPosition.isEqual(t.targetPosition))if(e.bWasUndone){const n=t.graveyardPosition.path.slice();return n.push(0),r.sourcePosition=new g(t.graveyardPosition.root,n),r.howMany=0,[r]}else return[new T(0)];if(r.sourcePosition.isEqual(t.sourcePosition)&&!r.targetPosition.isEqual(t.targetPosition)&&!e.bWasUndone&&e.abRelation!="splitAtSource"){const n=r.targetPosition.root.rootName=="$graveyard",s=t.targetPosition.root.rootName=="$graveyard";if(s&&!n||!(n&&!s)&&e.aIsStrong){const l=t.targetPosition._getTransformedByMergeOperation(t),h=r.targetPosition._getTransformedByMergeOperation(t);return[new P(l,r.howMany,h,0)]}else return[new T(0)]}return r.sourcePosition.hasSameParentAs(t.targetPosition)&&(r.howMany+=t.howMany),r.sourcePosition=r.sourcePosition._getTransformedByMergeOperation(t),r.targetPosition=r.targetPosition._getTransformedByMergeOperation(t),(!r.graveyardPosition.isEqual(t.graveyardPosition)||!e.aIsStrong)&&(r.graveyardPosition=r.graveyardPosition._getTransformedByMergeOperation(t)),[r]});v(S,P,(r,t,e)=>{const n=f._createFromPositionAndShift(t.sourcePosition,t.howMany);return t.type=="remove"&&!e.bWasUndone&&r.deletionPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(r.sourcePosition)?[new T(0)]:(t.sourcePosition.getShiftedBy(t.howMany).isEqual(r.sourcePosition)?r.sourcePosition.stickiness="toNone":t.targetPosition.isEqual(r.sourcePosition)&&e.abRelation=="mergeSourceAffected"?r.sourcePosition.stickiness="toNext":t.sourcePosition.isEqual(r.targetPosition)?(r.targetPosition.stickiness="toNone",r.howMany-=t.howMany):t.targetPosition.isEqual(r.targetPosition)&&e.abRelation=="mergeTargetWasBefore"?(r.targetPosition.stickiness="toPrevious",r.howMany+=t.howMany):(r.sourcePosition.hasSameParentAs(t.targetPosition)&&(r.howMany+=t.howMany),r.sourcePosition.hasSameParentAs(t.sourcePosition)&&(r.howMany-=t.howMany)),r.sourcePosition=r.sourcePosition._getTransformedByMoveOperation(t),r.targetPosition=r.targetPosition._getTransformedByMoveOperation(t),r.sourcePosition.stickiness="toPrevious",r.targetPosition.stickiness="toNext",r.graveyardPosition.isEqual(t.targetPosition)||(r.graveyardPosition=r.graveyardPosition._getTransformedByMoveOperation(t)),[r])});v(S,C,(r,t,e)=>{if(t.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedByDeletion(t.graveyardPosition,1),r.deletionPosition.isEqual(t.graveyardPosition)&&(r.howMany=t.howMany)),r.targetPosition.isEqual(t.splitPosition)&&(t.graveyardPosition&&r.deletionPosition.isEqual(t.graveyardPosition)||e.abRelation=="mergeTargetNotMoved"))return r.sourcePosition=r.sourcePosition._getTransformedBySplitOperation(t),[r];if(r.sourcePosition.isEqual(t.splitPosition)){if(e.abRelation=="mergeSourceNotMoved")return r.howMany=0,r.targetPosition=r.targetPosition._getTransformedBySplitOperation(t),[r];if(e.abRelation=="mergeSameElement"||r.sourcePosition.offset>0)return r.sourcePosition=t.moveTargetPosition.clone(),r.targetPosition=r.targetPosition._getTransformedBySplitOperation(t),[r]}return r.sourcePosition.hasSameParentAs(t.splitPosition)&&(r.howMany=t.splitPosition.offset),r.sourcePosition=r.sourcePosition._getTransformedBySplitOperation(t),r.targetPosition=r.targetPosition._getTransformedBySplitOperation(t),[r]});v(P,M,(r,t)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany)._getTransformedByInsertOperation(t,!1)[0];return r.sourcePosition=n.start,r.howMany=n.end.offset-n.start.offset,r.targetPosition.isEqual(t.position)||(r.targetPosition=r.targetPosition._getTransformedByInsertOperation(t)),[r]});v(P,P,(r,t,e)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany),s=f._createFromPositionAndShift(t.sourcePosition,t.howMany);let i=e.aIsStrong,o=!e.aIsStrong;e.abRelation=="insertBefore"||e.baRelation=="insertAfter"?o=!0:(e.abRelation=="insertAfter"||e.baRelation=="insertBefore")&&(o=!1);let a;if(r.targetPosition.isEqual(t.targetPosition)&&o?a=r.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany):a=r.targetPosition._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),Nn(r,t)&&Nn(t,r))return[t.getReversed()];if(n.containsPosition(t.targetPosition)&&n.containsRange(s,!0))return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),xe([n],a);if(s.containsPosition(r.targetPosition)&&s.containsRange(n,!0))return n.start=n.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),n.end=n.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),xe([n],a);const u=B(r.sourcePosition.getParentPath(),t.sourcePosition.getParentPath());if(u=="prefix"||u=="extension")return n.start=n.start._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),n.end=n.end._getTransformedByMove(t.sourcePosition,t.targetPosition,t.howMany),xe([n],a);r.type=="remove"&&t.type!="remove"&&!e.aWasUndone&&!e.forceWeakRemove?i=!0:r.type!="remove"&&t.type=="remove"&&!e.bWasUndone&&!e.forceWeakRemove&&(i=!1);const m=[],p=n.getDifference(s);for(const y of p){y.start=y.start._getTransformedByDeletion(t.sourcePosition,t.howMany),y.end=y.end._getTransformedByDeletion(t.sourcePosition,t.howMany);const F=B(y.start.getParentPath(),t.getMovedRangeStart().getParentPath())=="same",fe=y._getTransformedByInsertion(t.getMovedRangeStart(),t.howMany,F);m.push(...fe)}const w=n.getIntersection(s);return w!==null&&i&&(w.start=w.start._getCombined(t.sourcePosition,t.getMovedRangeStart()),w.end=w.end._getCombined(t.sourcePosition,t.getMovedRangeStart()),m.length===0?m.push(w):m.length==1?s.start.isBefore(n.start)||s.start.isEqual(n.start)?m.unshift(w):m.push(w):m.splice(1,0,w)),m.length===0?[new T(r.baseVersion)]:xe(m,a)});v(P,C,(r,t,e)=>{let n=r.targetPosition.clone();(!r.targetPosition.isEqual(t.insertionPosition)||!t.graveyardPosition||e.abRelation=="moveTargetAfter")&&(n=r.targetPosition._getTransformedBySplitOperation(t));const s=f._createFromPositionAndShift(r.sourcePosition,r.howMany);if(s.end.isEqual(t.insertionPosition))return t.graveyardPosition||r.howMany++,r.targetPosition=n,[r];if(s.start.hasSameParentAs(t.splitPosition)&&s.containsPosition(t.splitPosition)){let a=new f(t.splitPosition,s.end);a=a._getTransformedBySplitOperation(t);const l=[new f(s.start,t.splitPosition),a];return xe(l,n)}r.targetPosition.isEqual(t.splitPosition)&&e.abRelation=="insertAtSource"&&(n=t.moveTargetPosition),r.targetPosition.isEqual(t.insertionPosition)&&e.abRelation=="insertBetween"&&(n=r.targetPosition);const o=[s._getTransformedBySplitOperation(t)];if(t.graveyardPosition){const a=s.start.isEqual(t.graveyardPosition)||s.containsPosition(t.graveyardPosition);r.howMany>1&&a&&!e.aWasUndone&&o.push(f._createFromPositionAndShift(t.insertionPosition,1))}return xe(o,n)});v(P,S,(r,t,e)=>{const n=f._createFromPositionAndShift(r.sourcePosition,r.howMany);if(t.deletionPosition.hasSameParentAs(r.sourcePosition)&&n.containsPosition(t.sourcePosition)){if(r.type=="remove"&&!e.forceWeakRemove){if(!e.aWasUndone){const o=[];let a=t.graveyardPosition.clone(),l=t.targetPosition._getTransformedByMergeOperation(t);const h=r.targetPosition.getTransformedByOperation(t);r.howMany>1&&(o.push(new P(r.sourcePosition,r.howMany-1,h,0)),a=a._getTransformedByMove(r.sourcePosition,h,r.howMany-1),l=l._getTransformedByMove(r.sourcePosition,h,r.howMany-1));const u=t.deletionPosition._getCombined(r.sourcePosition,h),m=new P(a,1,u,0),p=m.getMovedRangeStart().path.slice();p.push(0);const w=new g(m.targetPosition.root,p);l=l._getTransformedByMove(a,u,1);const y=new P(l,t.howMany,w,0);return o.push(m),o.push(y),o}}else if(r.howMany==1)return e.bWasUndone?(r.sourcePosition=t.graveyardPosition.clone(),r.targetPosition=r.targetPosition._getTransformedByMergeOperation(t),[r]):[new T(0)]}const i=f._createFromPositionAndShift(r.sourcePosition,r.howMany)._getTransformedByMergeOperation(t);return r.sourcePosition=i.start,r.howMany=i.end.offset-i.start.offset,r.targetPosition=r.targetPosition._getTransformedByMergeOperation(t),[r]});v($,M,(r,t)=>(r.position=r.position._getTransformedByInsertOperation(t),[r]));v($,S,(r,t)=>r.position.isEqual(t.deletionPosition)?(r.position=t.graveyardPosition.clone(),r.position.stickiness="toNext",[r]):(r.position=r.position._getTransformedByMergeOperation(t),[r]));v($,P,(r,t)=>(r.position=r.position._getTransformedByMoveOperation(t),[r]));v($,$,(r,t,e)=>{if(r.position.isEqual(t.position))if(e.aIsStrong)r.oldName=t.newName;else return[new T(0)];return[r]});v($,C,(r,t)=>{const e=r.position.path,n=t.splitPosition.getParentPath();if(B(e,n)=="same"&&!t.graveyardPosition){const s=new $(r.position.getShiftedBy(1),r.oldName,r.newName,0);return[r,s]}return r.position=r.position._getTransformedBySplitOperation(t),[r]});v(te,te,(r,t,e)=>{if(r.root===t.root&&r.key===t.key){if(!e.aIsStrong||r.newValue===t.newValue)return[new T(0)];r.oldValue=t.newValue}return[r]});v(Y,Y,(r,t)=>r.rootName===t.rootName&&r.isAdd===t.isAdd?[new T(0)]:[r]);v(C,M,(r,t)=>(r.splitPosition.hasSameParentAs(t.position)&&r.splitPosition.offset<t.position.offset&&(r.howMany+=t.howMany),r.splitPosition=r.splitPosition._getTransformedByInsertOperation(t),r.insertionPosition=r.insertionPosition._getTransformedByInsertOperation(t),[r]));v(C,S,(r,t,e)=>{if(!r.graveyardPosition&&!e.bWasUndone&&r.splitPosition.hasSameParentAs(t.sourcePosition)){const n=t.graveyardPosition.path.slice();n.push(0);const s=new g(t.graveyardPosition.root,n),i=C.getInsertionPosition(new g(t.graveyardPosition.root,n)),o=new C(s,0,i,null,0);return r.splitPosition=r.splitPosition._getTransformedByMergeOperation(t),r.insertionPosition=C.getInsertionPosition(r.splitPosition),r.graveyardPosition=o.insertionPosition.clone(),r.graveyardPosition.stickiness="toNext",[o,r]}return r.splitPosition.hasSameParentAs(t.deletionPosition)&&!r.splitPosition.isAfter(t.deletionPosition)&&r.howMany--,r.splitPosition.hasSameParentAs(t.targetPosition)&&(r.howMany+=t.howMany),r.splitPosition=r.splitPosition._getTransformedByMergeOperation(t),r.insertionPosition=C.getInsertionPosition(r.splitPosition),r.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedByMergeOperation(t)),[r]});v(C,P,(r,t,e)=>{const n=f._createFromPositionAndShift(t.sourcePosition,t.howMany);if(r.graveyardPosition){const i=n.start.isEqual(r.graveyardPosition)||n.containsPosition(r.graveyardPosition);if(!e.bWasUndone&&i){const o=r.splitPosition._getTransformedByMoveOperation(t),a=r.graveyardPosition._getTransformedByMoveOperation(t),l=a.path.slice();l.push(0);const h=new g(a.root,l);return[new P(o,r.howMany,h,0)]}r.graveyardPosition=r.graveyardPosition._getTransformedByMoveOperation(t)}const s=r.splitPosition.isEqual(t.targetPosition);if(s&&(e.baRelation=="insertAtSource"||e.abRelation=="splitBefore"))return r.howMany+=t.howMany,r.splitPosition=r.splitPosition._getTransformedByDeletion(t.sourcePosition,t.howMany),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r];if(s&&e.abRelation&&e.abRelation.howMany){const{howMany:i,offset:o}=e.abRelation;return r.howMany+=i,r.splitPosition=r.splitPosition.getShiftedBy(o),[r]}if(r.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(r.splitPosition)){const i=t.howMany-(r.splitPosition.offset-t.sourcePosition.offset);return r.howMany-=i,r.splitPosition.hasSameParentAs(t.targetPosition)&&r.splitPosition.offset<t.targetPosition.offset&&(r.howMany+=t.howMany),r.splitPosition=t.sourcePosition.clone(),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]}return t.sourcePosition.isEqual(t.targetPosition)||(r.splitPosition.hasSameParentAs(t.sourcePosition)&&r.splitPosition.offset<=t.sourcePosition.offset&&(r.howMany-=t.howMany),r.splitPosition.hasSameParentAs(t.targetPosition)&&r.splitPosition.offset<t.targetPosition.offset&&(r.howMany+=t.howMany)),r.splitPosition.stickiness="toNone",r.splitPosition=r.splitPosition._getTransformedByMoveOperation(t),r.splitPosition.stickiness="toNext",r.graveyardPosition?r.insertionPosition=r.insertionPosition._getTransformedByMoveOperation(t):r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]});v(C,C,(r,t,e)=>{if(r.splitPosition.isEqual(t.splitPosition)){if(!r.graveyardPosition&&!t.graveyardPosition)return[new T(0)];if(r.graveyardPosition&&t.graveyardPosition&&r.graveyardPosition.isEqual(t.graveyardPosition))return[new T(0)];if(e.abRelation=="splitBefore")return r.howMany=0,r.graveyardPosition=r.graveyardPosition._getTransformedBySplitOperation(t),[r]}if(r.graveyardPosition&&t.graveyardPosition&&r.graveyardPosition.isEqual(t.graveyardPosition)){const n=r.splitPosition.root.rootName=="$graveyard",s=t.splitPosition.root.rootName=="$graveyard";if(s&&!n||!(n&&!s)&&e.aIsStrong){const l=[];return t.howMany&&l.push(new P(t.moveTargetPosition,t.howMany,t.splitPosition,0)),r.howMany&&l.push(new P(r.splitPosition,r.howMany,r.moveTargetPosition,0)),l}else return[new T(0)]}if(r.graveyardPosition&&(r.graveyardPosition=r.graveyardPosition._getTransformedBySplitOperation(t)),r.splitPosition.isEqual(t.insertionPosition)&&e.abRelation=="splitBefore")return r.howMany++,[r];if(t.splitPosition.isEqual(r.insertionPosition)&&e.baRelation=="splitBefore"){const n=t.insertionPosition.path.slice();n.push(0);const s=new g(t.insertionPosition.root,n),i=new P(r.insertionPosition,1,s,0);return[r,i]}return r.splitPosition.hasSameParentAs(t.splitPosition)&&r.splitPosition.offset<t.splitPosition.offset&&(r.howMany-=t.howMany),r.splitPosition=r.splitPosition._getTransformedBySplitOperation(t),r.insertionPosition=C.getInsertionPosition(r.splitPosition),[r]});function Nn(r,t){return r.targetPosition._getTransformedByDeletion(t.sourcePosition,t.howMany)===null}function xe(r,t){const e=[];for(let n=0;n<r.length;n++){const s=r[n],i=new P(s.start,s.end.offset-s.start.offset,t,0);e.push(i);for(let o=n+1;o<r.length;o++)r[o]=r[o]._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)[0];t=t._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)}return e}class I extends O(g){constructor(t,e,n="toNone"){if(super(t,e,n),!this.root.is("rootElement"))throw new d("model-liveposition-root-not-rootelement",t);Do.call(this)}detach(){this.stopListening()}toPosition(){return new g(this.root,this.path.slice(),this.stickiness)}static fromPosition(t,e){return new this(t.root,t.path.slice(),e||t.stickiness)}}I.prototype.is=function(r){return r==="livePosition"||r==="model:livePosition"||r=="position"||r==="model:position"};function Do(){this.listenTo(this.root.document.model,"applyOperation",(r,t)=>{const e=t[0];e.isDocumentOperation&&Vo.call(this,e)},{priority:"low"})}function Vo(r){const t=this.getTransformedByOperation(r);if(!this.isEqual(t)){const e=this.toPosition();this.path=t.path,this.root=t.root,this.fire("change",e)}}class Se{constructor(t={}){c(this,"operations");c(this,"isUndoable");c(this,"isLocal");c(this,"isUndo");c(this,"isTyping");typeof t=="string"&&(t=t==="transparent"?{isUndoable:!1}:{},q("batch-constructor-deprecated-string-type"));const{isUndoable:e=!0,isLocal:n=!0,isUndo:s=!1,isTyping:i=!1}=t;this.operations=[],this.isUndoable=e,this.isLocal=n,this.isUndo=s,this.isTyping=i}get type(){return q("batch-type-deprecated"),"default"}get baseVersion(){for(const t of this.operations)if(t.baseVersion!==null)return t.baseVersion;return null}addOperation(t){return t.isDocumentOperation&&(t.batch=this,this.operations.push(t)),t}}const Ge=class Ge{constructor(t){c(this,"_markerCollection");c(this,"_changesInElement",new Map);c(this,"_elementsSnapshots",new Map);c(this,"_elementChildrenSnapshots",new Map);c(this,"_elementState",new Map);c(this,"_changedMarkers",new Map);c(this,"_changedRoots",new Map);c(this,"_changeCount",0);c(this,"_cachedChanges",null);c(this,"_cachedChangesWithGraveyard",null);c(this,"_refreshedItems",new Set);this._markerCollection=t}get isEmpty(){return this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(t){const e=t;switch(e.type){case"insert":{if(this._isInInsertedElement(e.position.parent))return;this._markInsert(e.position.parent,e.position.offset,e.nodes.maxOffset);break}case"addAttribute":case"removeAttribute":case"changeAttribute":{for(const n of e.range.getItems({shallow:!0}))this._isInInsertedElement(n.parent)||this._markAttribute(n);break}case"remove":case"move":case"reinsert":{if(e.sourcePosition.isEqual(e.targetPosition)||e.sourcePosition.getShiftedBy(e.howMany).isEqual(e.targetPosition))return;const n=this._isInInsertedElement(e.sourcePosition.parent),s=this._isInInsertedElement(e.targetPosition.parent);n||this._markRemove(e.sourcePosition.parent,e.sourcePosition.offset,e.howMany),s||this._markInsert(e.targetPosition.parent,e.getMovedRangeStart().offset,e.howMany);const i=f._createFromPositionAndShift(e.sourcePosition,e.howMany);for(const o of i.getItems({shallow:!0}))this._setElementState(o,"move");break}case"rename":{if(this._isInInsertedElement(e.position.parent))return;this._markRemove(e.position.parent,e.position.offset,1),this._markInsert(e.position.parent,e.position.offset,1);const n=f._createFromPositionAndShift(e.position,1);for(const s of this._markerCollection.getMarkersIntersectingRange(n)){const i=s.getData();this.bufferMarkerChange(s.name,i,i)}this._setElementState(e.position.nodeAfter,"rename");break}case"split":{const n=e.splitPosition.parent;if(!this._isInInsertedElement(n)){this._markRemove(n,e.splitPosition.offset,e.howMany);const s=f._createFromPositionAndShift(e.splitPosition,e.howMany);for(const i of s.getItems({shallow:!0}))this._setElementState(i,"move")}this._isInInsertedElement(e.insertionPosition.parent)||this._markInsert(e.insertionPosition.parent,e.insertionPosition.offset,1),e.graveyardPosition&&(this._markRemove(e.graveyardPosition.parent,e.graveyardPosition.offset,1),this._setElementState(e.graveyardPosition.nodeAfter,"move"));break}case"merge":{const n=e.sourcePosition.parent;this._isInInsertedElement(n.parent)||this._markRemove(n.parent,n.startOffset,1);const s=e.graveyardPosition.parent;this._markInsert(s,e.graveyardPosition.offset,1),this._setElementState(n,"move");const i=e.targetPosition.parent;if(!this._isInInsertedElement(i)){this._markInsert(i,e.targetPosition.offset,n.maxOffset);const o=f._createFromPositionAndShift(e.sourcePosition,e.howMany);for(const a of o.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const n=e.affectedSelectable;if(!n._isLoaded||n.isAttached()==e.isAdd)return;this._bufferRootStateChange(e.rootName,e.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!e.root._isLoaded)return;const n=e.root.rootName;this._bufferRootAttributeChange(n,e.key,e.oldValue,e.newValue);break}}this._cachedChanges=null}bufferMarkerChange(t,e,n){e.range&&e.range.root.is("rootElement")&&!e.range.root._isLoaded&&(e.range=null),n.range&&n.range.root.is("rootElement")&&!n.range.root._isLoaded&&(n.range=null);let s=this._changedMarkers.get(t);s?s.newMarkerData=n:(s={newMarkerData:n,oldMarkerData:e},this._changedMarkers.set(t,s)),s.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(t)}getMarkersToRemove(){const t=[];for(const[e,n]of this._changedMarkers)n.oldMarkerData.range!=null&&t.push({name:e,range:n.oldMarkerData.range});return t}getMarkersToAdd(){const t=[];for(const[e,n]of this._changedMarkers)n.newMarkerData.range!=null&&t.push({name:e,range:n.newMarkerData.range});return t}getChangedMarkers(){return Array.from(this._changedMarkers).map(([t,e])=>({name:t,data:{oldRange:e.oldMarkerData.range,newRange:e.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:t,oldMarkerData:e}of this._changedMarkers.values()){if(t.affectsData!==e.affectsData)return!0;if(t.affectsData){const n=t.range&&!e.range,s=!t.range&&e.range,i=t.range&&e.range&&!t.range.isEqual(e.range);if(n||s||i)return!0}}return!1}getChanges(t={}){if(this._cachedChanges)return t.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let e=[];for(const n of this._changesInElement.keys()){const s=this._changesInElement.get(n).sort((u,m)=>u.offset===m.offset?u.type!=m.type?u.type=="remove"?-1:1:0:u.offset<m.offset?-1:1),i=this._elementChildrenSnapshots.get(n),o=In(n.getChildren()),a=$o(i.length,s);let l=0,h=0;for(const u of a)if(u==="i"){const m=this._getDiffActionForNode(o[l].node,"insert"),p=this._elementsSnapshots.get(o[l].node),w=this._getInsertDiff(n,l,m,o[l],p);e.push(w),l++}else if(u==="r"){const m=this._getDiffActionForNode(i[h].node,"remove"),p=this._getRemoveDiff(n,l,m,i[h]);e.push(p),h++}else if(u==="a"){const m=i[h].attributes,p=o[l].attributes;let w;if(o[l].name=="$text")w=new f(g._createAt(n,l),g._createAt(n,l+1));else{const F=n.offsetToIndex(l);w=new f(g._createAt(n,l),g._createAt(n.getChild(F),0))}const y=this._getAttributesDiff(w,m,p);e.push(...y),l++,h++}else l++,h++}e.sort((n,s)=>n.position.root!=s.position.root?n.position.root.rootName<s.position.root.rootName?-1:1:n.position.isEqual(s.position)?n.changeCount-s.changeCount:n.position.isBefore(s.position)?-1:1);for(let n=1,s=0;n<e.length;n++){const i=e[s],o=e[n],a=i.type=="remove"&&o.type=="remove"&&i.name=="$text"&&o.name=="$text"&&i.position.isEqual(o.position),l=i.type=="insert"&&o.type=="insert"&&i.name=="$text"&&o.name=="$text"&&i.position.parent==o.position.parent&&i.position.offset+i.length==o.position.offset,h=i.type=="attribute"&&o.type=="attribute"&&i.position.parent==o.position.parent&&i.range.isFlat&&o.range.isFlat&&i.position.offset+i.length==o.position.offset&&i.attributeKey==o.attributeKey&&i.attributeOldValue==o.attributeOldValue&&i.attributeNewValue==o.attributeNewValue;a||l||h?(i.length++,h&&(i.range.end=i.range.end.getShiftedBy(1)),e[n]=null):s=n}e=e.filter(n=>n);for(const n of e)delete n.changeCount,n.type=="attribute"&&(delete n.position,delete n.length);return this._changeCount=0,this._cachedChangesWithGraveyard=e,this._cachedChanges=e.filter(Lo),t.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(t=>{const e={...t};return e.state!==void 0&&delete e.attributes,e})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(t){if(this._isInInsertedElement(t.parent))return;this._markRemove(t.parent,t.startOffset,t.offsetSize),this._markInsert(t.parent,t.startOffset,t.offsetSize),this._refreshedItems.add(t),this._setElementState(t,"refresh");const e=f._createOn(t);for(const n of this._markerCollection.getMarkersIntersectingRange(e)){const s=n.getData();this.bufferMarkerChange(n.name,s,s)}this._cachedChanges=null}_bufferRootLoad(t){if(t.isAttached()){this._bufferRootStateChange(t.rootName,!0),this._markInsert(t,0,t.maxOffset);for(const e of t.getAttributeKeys())this._bufferRootAttributeChange(t.rootName,e,null,t.getAttribute(e));for(const e of this._markerCollection)if(e.getRange().root==t){const n=e.getData();this.bufferMarkerChange(e.name,{...n,range:null},n)}}}_bufferRootStateChange(t,e){if(!this._changedRoots.has(t)){this._changedRoots.set(t,{name:t,state:e?"attached":"detached"});return}const n=this._changedRoots.get(t);n.state!==void 0?(delete n.state,n.attributes===void 0&&this._changedRoots.delete(t)):n.state=e?"attached":"detached"}_bufferRootAttributeChange(t,e,n,s){const i=this._changedRoots.get(t)||{name:t},o=i.attributes||{};if(o[e]){const a=o[e];s===a.oldValue?delete o[e]:a.newValue=s}else o[e]={oldValue:n,newValue:s};Object.entries(o).length===0?(delete i.attributes,i.state===void 0&&this._changedRoots.delete(t)):(i.attributes=o,this._changedRoots.set(t,i))}_markInsert(t,e,n){if(t.root.is("rootElement")&&!t.root._isLoaded)return;const s={type:"insert",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,s)}_markRemove(t,e,n){if(t.root.is("rootElement")&&!t.root._isLoaded)return;const s={type:"remove",offset:e,howMany:n,count:this._changeCount++};this._markChange(t,s),this._removeAllNestedChanges(t,e,n)}_markAttribute(t){if(t.root.is("rootElement")&&!t.root._isLoaded)return;const e={type:"attribute",offset:t.startOffset,howMany:t.offsetSize,count:this._changeCount++};this._markChange(t.parent,e)}_markChange(t,e){this._makeSnapshots(t);const n=this._getChangesForElement(t);this._handleChange(e,n),n.push(e);for(let s=0;s<n.length;s++)n[s].howMany<1&&(n.splice(s,1),s--)}_setElementState(t,e){if(!t.is("element"))return;const n=Ge._statesPriority.indexOf(this._elementState.get(t));Ge._statesPriority.indexOf(e)>n&&this._elementState.set(t,e)}_getDiffActionForNode(t,e){if(!t.is("element")||!this._elementsSnapshots.has(t))return e;const n=this._elementState.get(t);return!n||n=="move"?e:n}_getChangesForElement(t){let e;return this._changesInElement.has(t)?e=this._changesInElement.get(t):(e=[],this._changesInElement.set(t,e)),e}_makeSnapshots(t){if(this._elementChildrenSnapshots.has(t))return;const e=In(t.getChildren());this._elementChildrenSnapshots.set(t,e);for(const n of e)this._elementsSnapshots.set(n.node,n)}_handleChange(t,e){t.nodesToHandle=t.howMany;for(const n of e){const s=t.offset+t.howMany,i=n.offset+n.howMany;if(t.type=="insert"&&(n.type=="insert"&&(t.offset<=n.offset?n.offset+=t.howMany:t.offset<i&&(n.howMany+=t.nodesToHandle,t.nodesToHandle=0)),n.type=="remove"&&t.offset<n.offset&&(n.offset+=t.howMany),n.type=="attribute")){if(t.offset<=n.offset)n.offset+=t.howMany;else if(t.offset<i){const o=n.howMany;n.howMany=t.offset-n.offset,e.unshift({type:"attribute",offset:s,howMany:o-n.howMany,count:this._changeCount++})}}if(t.type=="remove"){if(n.type=="insert"){if(s<=n.offset)n.offset-=t.howMany;else if(s<=i)if(t.offset<n.offset){const o=s-n.offset;n.offset=t.offset,n.howMany-=o,t.nodesToHandle-=o}else n.howMany-=t.nodesToHandle,t.nodesToHandle=0;else if(t.offset<=n.offset)t.nodesToHandle-=n.howMany,n.howMany=0;else if(t.offset<i){const o=i-t.offset;n.howMany-=o,t.nodesToHandle-=o}}if(n.type=="remove"&&(s<=n.offset?n.offset-=t.howMany:t.offset<n.offset&&(t.nodesToHandle+=n.howMany,n.howMany=0)),n.type=="attribute"){if(s<=n.offset)n.offset-=t.howMany;else if(t.offset<n.offset){const o=s-n.offset;n.offset=t.offset,n.howMany-=o}else if(t.offset<i)if(s<=i){const o=n.howMany;n.howMany=t.offset-n.offset;const a=o-n.howMany-t.nodesToHandle;e.unshift({type:"attribute",offset:t.offset,howMany:a,count:this._changeCount++})}else n.howMany-=i-t.offset}}if(t.type=="attribute"){if(n.type=="insert")if(t.offset<n.offset&&s>n.offset){if(s>i){const o={type:"attribute",offset:i,howMany:s-i,count:this._changeCount++};this._handleChange(o,e),e.push(o)}t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}else t.offset>=n.offset&&t.offset<i&&(s>i?(t.nodesToHandle=s-i,t.offset=i):t.nodesToHandle=0);if(n.type=="remove"&&t.offset<n.offset&&s>n.offset){const o={type:"attribute",offset:n.offset,howMany:s-n.offset,count:this._changeCount++};this._handleChange(o,e),e.push(o),t.nodesToHandle=n.offset-t.offset,t.howMany=t.nodesToHandle}n.type=="attribute"&&(t.offset>=n.offset&&s<=i?(t.nodesToHandle=0,t.howMany=0,t.offset=0):t.offset<=n.offset&&s>=i&&(n.howMany=0))}}t.howMany=t.nodesToHandle,delete t.nodesToHandle}_getInsertDiff(t,e,n,s,i){const o={type:"insert",position:g._createAt(t,e),name:s.name,attributes:new Map(s.attributes),length:1,changeCount:this._changeCount++,action:n};return n!="insert"&&i&&(o.before={name:i.name,attributes:new Map(i.attributes)}),o}_getRemoveDiff(t,e,n,s){return{type:"remove",action:n,position:g._createAt(t,e),name:s.name,attributes:new Map(s.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(t,e,n){const s=[];n=new Map(n);for(const[i,o]of e){const a=n.has(i)?n.get(i):null;a!==o&&s.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:i,attributeOldValue:o,attributeNewValue:a,changeCount:this._changeCount++}),n.delete(i)}for(const[i,o]of n)s.push({type:"attribute",position:t.start,range:t.clone(),length:1,attributeKey:i,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return s}_isInInsertedElement(t){const e=t.parent;if(!e)return!1;const n=this._changesInElement.get(e),s=t.startOffset;if(n){for(const i of n)if(i.type=="insert"&&s>=i.offset&&s<i.offset+i.howMany)return!0}return this._isInInsertedElement(e)}_removeAllNestedChanges(t,e,n){const s=new f(g._createAt(t,e),g._createAt(t,e+n));for(const i of s.getItems({shallow:!0}))i.is("element")&&(this._changesInElement.delete(i),this._removeAllNestedChanges(i,0,i.maxOffset))}};c(Ge,"_statesPriority",[void 0,"refresh","rename","move"]);let Wt=Ge;function On(r){return{node:r,name:r.is("$text")?"$text":r.name,attributes:new Map(r.getAttributes())}}function In(r){const t=[];for(const e of r)if(e.is("$text"))for(let n=0;n<e.data.length;++n)t.push(On(e));else t.push(On(e));return t}function $o(r,t){const e=[];let n=0,s=0;for(const i of t){if(i.offset>n){for(let o=0;o<i.offset-n;o++)e.push("e");s+=i.offset-n}if(i.type=="insert"){for(let o=0;o<i.howMany;o++)e.push("i");n=i.offset+i.howMany}else if(i.type=="remove"){for(let o=0;o<i.howMany;o++)e.push("r");n=i.offset,s+=i.howMany}else{if(i.howMany>1500)for(let o=0;o<i.howMany;o++)e.push("a");else e.push(..."a".repeat(i.howMany).split(""));n=i.offset+i.howMany,s+=i.howMany}}if(s<r)for(let i=0;i<r-s-n;i++)e.push("e");return e}function Lo(r){const t="position"in r&&r.position.root.rootName=="$graveyard",e="range"in r&&r.range.root.rootName=="$graveyard";return!t&&!e}class Wo{constructor(){c(this,"_operations",[]);c(this,"_undoPairs",new Map);c(this,"_undoneOperations",new Set);c(this,"_baseVersionToOperationIndex",new Map);c(this,"_version",0);c(this,"_gaps",new Map)}get version(){return this._version}set version(t){this._operations.length&&t>this._version+1&&this._gaps.set(this._version,t),this._version=t}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(t){if(t.baseVersion!==this.version)throw new d("model-document-history-addoperation-incorrect-version",this,{operation:t,historyVersion:this.version});this._operations.push(t),this._version++,this._baseVersionToOperationIndex.set(t.baseVersion,this._operations.length-1)}getOperations(t,e=this.version){if(!this._operations.length)return[];const n=this._operations[0];t===void 0&&(t=n.baseVersion);let s=e-1;for(const[a,l]of this._gaps)t>a&&t<l&&(t=l),s>a&&s<l&&(s=a-1);if(s<n.baseVersion||t>this.lastOperation.baseVersion)return[];let i=this._baseVersionToOperationIndex.get(t);i===void 0&&(i=0);let o=this._baseVersionToOperationIndex.get(s);return o===void 0&&(o=this._operations.length-1),this._operations.slice(i,o+1)}getOperation(t){const e=this._baseVersionToOperationIndex.get(t);if(e!==void 0)return this._operations[e]}setOperationAsUndone(t,e){this._undoPairs.set(e,t),this._undoneOperations.add(t)}isUndoingOperation(t){return this._undoPairs.has(t)}isUndoneOperation(t){return this._undoneOperations.has(t)}getUndoneOperation(t){return this._undoPairs.get(t)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class dt extends k{constructor(e,n,s="main"){super(n);c(this,"rootName");c(this,"_document");c(this,"_isAttached",!0);c(this,"_isLoaded",!0);this._document=e,this.rootName=s}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}dt.prototype.is=function(r,t){return t?t===this.name&&(r==="rootElement"||r==="model:rootElement"||r==="element"||r==="model:element"):r==="rootElement"||r==="model:rootElement"||r==="element"||r==="model:element"||r==="node"||r==="model:node"};const Fn="$graveyard";class qo extends O(){constructor(e){super();c(this,"model");c(this,"history");c(this,"selection");c(this,"roots");c(this,"differ");c(this,"isReadOnly");c(this,"_postFixers");c(this,"_hasSelectionChangedFromTheLastChangeBlock");this.model=e,this.history=new Wo,this.selection=new H(this),this.roots=new qt({idProperty:"rootName"}),this.differ=new Wt(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",Fn),this.listenTo(e,"applyOperation",(n,s)=>{const i=s[0];i.isDocumentOperation&&this.differ.bufferOperation(i)},{priority:"high"}),this.listenTo(e,"applyOperation",(n,s)=>{const i=s[0];i.isDocumentOperation&&this.history.addOperation(i)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(n,s,i,o,a)=>{const l={...s.getData(),range:o};this.differ.bufferMarkerChange(s.name,a,l),i===null&&s.on("change",(h,u)=>{const m=s.getData();this.differ.bufferMarkerChange(s.name,{...m,range:u},m)})}),this.registerPostFixer(n=>{let s=!1;for(const i of this.roots)!i.isAttached()&&!i.isEmpty&&(n.remove(n.createRangeIn(i)),s=!0);for(const i of this.model.markers)i.getRange().root.isAttached()||(n.removeMarker(i),s=!0);return s})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(Fn)}createRoot(e="$root",n="main"){if(this.roots.get(n))throw new d("model-document-createroot-name-exists",this,{name:n});const s=new dt(this,e,n);return this.roots.add(s),s}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(n=>n.rootName)}getRoots(e=!1){return this.roots.filter(n=>n!=this.graveyard&&(e||n.isAttached())&&n._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=jn(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),n=this.model,s=n.schema,i=n.createPositionFromPath(e,[0]);return s.getNearestSelectionRange(i)||n.createRange(i)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&Bn(e.start)&&Bn(e.end)}_callPostFixers(e){let n=!1;do for(const s of this._postFixers)if(this.selection.refresh(),n=s(e),n)break;while(n)}}function Bn(r){const t=r.textNode;if(t){const e=t.data,n=r.offset-t.startOffset;return!zn(e,n)&&!Un(e,n)}return!0}class zo extends O(){constructor(){super(...arguments);c(this,"_markers",new Map)}[Symbol.iterator](){return this._markers.values()}has(e){const n=e instanceof Ee?e.name:e;return this._markers.has(n)}get(e){return this._markers.get(e)||null}_set(e,n,s=!1,i=!1){const o=e instanceof Ee?e.name:e;if(o.includes(","))throw new d("markercollection-incorrect-marker-name",this);const a=this._markers.get(o);if(a){const u=a.getData(),m=a.getRange();let p=!1;return m.isEqual(n)||(a._attachLiveRange(be.fromRange(n)),p=!0),s!=a.managedUsingOperations&&(a._managedUsingOperations=s,p=!0),typeof i=="boolean"&&i!=a.affectsData&&(a._affectsData=i,p=!0),p&&this.fire(`update:${o}`,a,m,n,u),a}const l=be.fromRange(n),h=new Ee(o,l,s,i);return this._markers.set(o,h),this.fire(`update:${o}`,h,null,n,{...h.getData(),range:null}),h}_remove(e){const n=e instanceof Ee?e.name:e,s=this._markers.get(n);return s?(this._markers.delete(n),this.fire(`update:${n}`,s,s.getRange(),null,s.getData()),this._destroyMarker(s),!0):!1}_refresh(e){const n=e instanceof Ee?e.name:e,s=this._markers.get(n);if(!s)throw new d("markercollection-refresh-marker-not-exists",this);const i=s.getRange();this.fire(`update:${n}`,s,i,i,s.getData())}*getMarkersAtPosition(e){for(const n of this)n.getRange().containsPosition(e)&&(yield n)}*getMarkersIntersectingRange(e){for(const n of this)n.getRange().getIntersection(e)!==null&&(yield n)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const n of this._markers.values())n.name.startsWith(e+":")&&(yield n)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Ee extends O(ue){constructor(e,n,s,i){super();c(this,"name");c(this,"_managedUsingOperations");c(this,"_affectsData");c(this,"_liveRange");this.name=e,this._liveRange=this._attachLiveRange(n),this._managedUsingOperations=s,this._affectsData=i}get managedUsingOperations(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new d("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Ee.prototype.is=function(r){return r==="marker"||r==="model:marker"};class Uo extends z{constructor(e,n){super(null);c(this,"sourcePosition");c(this,"howMany");this.sourcePosition=e.clone(),this.howMany=n}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new d("detach-operation-on-document-node",this)}_execute(){Es(f._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class X extends ue{constructor(e){super();c(this,"markers",new Map);c(this,"_children",new Ue);e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let n=this;for(const s of e)n=n.getChildAtOffset(s);return n}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const n of this._children)e.push(n.toJSON());return e}static fromJSON(e){const n=[];for(const s of e)s.name?n.push(k.fromJSON(s)):n.push(A.fromJSON(s));return new X(n)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,n){const s=Jo(n);for(const i of s)i.parent!==null&&i._remove(),i.parent=this;this._children._insertNodes(e,s)}_removeChildren(e,n=1){const s=this._children._removeNodes(e,n);for(const i of s)i.parent=null;return s}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const n of e)n.parent=null}}X.prototype.is=function(r){return r==="documentFragment"||r==="model:documentFragment"};function Jo(r){return typeof r=="string"?[new A(r)]:(ce(r)||(r=[r]),Array.from(r).map(t=>typeof t=="string"?new A(t):t instanceof G?new A(t.data,t.getAttributes()):t))}class jo{constructor(t,e){c(this,"model");c(this,"batch");this.model=t,this.batch=e}createText(t,e){return new A(t,e)}createElement(t,e){return new k(t,e)}createDocumentFragment(){return new X}cloneElement(t,e=!0){return t._clone(e)}insert(t,e,n=0){if(this._assertWriterUsedCorrectly(),t instanceof A&&t.data=="")return;const s=g._createAt(e,n);if(t.parent)if($n(t.root,s.root)){this.move(f._createOn(t),s);return}else{if(t.root.document)throw new d("model-writer-insert-forbidden-move",this);this.remove(t)}const i=s.root.document?s.root.document.version:null,o=t instanceof X?t._removeChildren(0,t.childCount):t,a=new M(s,o,i);if(t instanceof A&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),t instanceof X)for(const[l,h]of t.markers){const u=g._createAt(h.root,0),p={range:new f(h.start._getCombined(u,s),h.end._getCombined(u,s)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,p):this.addMarker(l,p)}}insertText(t,e,n,s){e instanceof X||e instanceof k||e instanceof g?this.insert(this.createText(t),e,n):this.insert(this.createText(t,e),n,s)}insertElement(t,e,n,s){e instanceof X||e instanceof k||e instanceof g?this.insert(this.createElement(t),e,n):this.insert(this.createElement(t,e),n,s)}append(t,e){this.insert(t,e,"end")}appendText(t,e,n){e instanceof X||e instanceof k?this.insert(this.createText(t),e,"end"):this.insert(this.createText(t,e),n,"end")}appendElement(t,e,n){e instanceof X||e instanceof k?this.insert(this.createElement(t),e,"end"):this.insert(this.createElement(t,e),n,"end")}setAttribute(t,e,n){if(this._assertWriterUsedCorrectly(),n instanceof f){const s=n.getMinimalFlatRanges();for(const i of s)Dn(this,t,e,i)}else Vn(this,t,e,n)}setAttributes(t,e){for(const[n,s]of we(t))this.setAttribute(n,s,e)}removeAttribute(t,e){if(this._assertWriterUsedCorrectly(),e instanceof f){const n=e.getMinimalFlatRanges();for(const s of n)Dn(this,t,null,s)}else Vn(this,t,null,e)}clearAttributes(t){this._assertWriterUsedCorrectly();const e=n=>{for(const s of n.getAttributeKeys())this.removeAttribute(s,n)};if(!(t instanceof f))e(t);else for(const n of t.getItems())e(n)}move(t,e,n){if(this._assertWriterUsedCorrectly(),!(t instanceof f))throw new d("writer-move-invalid-range",this);if(!t.isFlat)throw new d("writer-move-range-not-flat",this);const s=g._createAt(e,n);if(s.isEqual(t.start))return;if(this._addOperationForAffectedMarkers("move",t),!$n(t.root,s.root))throw new d("writer-move-different-document",this);const i=t.root.document?t.root.document.version:null,o=new P(t.start,t.end.offset-t.start.offset,s,i);this.batch.addOperation(o),this.model.applyOperation(o)}remove(t){this._assertWriterUsedCorrectly();const n=(t instanceof f?t:f._createOn(t)).getMinimalFlatRanges().reverse();for(const s of n)this._addOperationForAffectedMarkers("move",s),Go(s.start,s.end.offset-s.start.offset,this.batch,this.model)}merge(t){this._assertWriterUsedCorrectly();const e=t.nodeBefore,n=t.nodeAfter;if(this._addOperationForAffectedMarkers("merge",t),!(e instanceof k))throw new d("writer-merge-no-element-before",this);if(!(n instanceof k))throw new d("writer-merge-no-element-after",this);t.root.document?this._merge(t):this._mergeDetached(t)}createPositionFromPath(t,e,n){return this.model.createPositionFromPath(t,e,n)}createPositionAt(t,e){return this.model.createPositionAt(t,e)}createPositionAfter(t){return this.model.createPositionAfter(t)}createPositionBefore(t){return this.model.createPositionBefore(t)}createRange(t,e){return this.model.createRange(t,e)}createRangeIn(t){return this.model.createRangeIn(t)}createRangeOn(t){return this.model.createRangeOn(t)}createSelection(...t){return this.model.createSelection(...t)}_mergeDetached(t){const e=t.nodeBefore,n=t.nodeAfter;this.move(f._createIn(n),g._createAt(e,"end")),this.remove(n)}_merge(t){const e=g._createAt(t.nodeBefore,"end"),n=g._createAt(t.nodeAfter,0),s=t.root.document.graveyard,i=new g(s,[0]),o=t.root.document.version,a=new S(n,t.nodeAfter.maxOffset,e,i,o);this.batch.addOperation(a),this.model.applyOperation(a)}rename(t,e){if(this._assertWriterUsedCorrectly(),!(t instanceof k))throw new d("writer-rename-not-element-instance",this);const n=t.root.document?t.root.document.version:null,s=new $(g._createBefore(t),t.name,e,n);this.batch.addOperation(s),this.model.applyOperation(s)}split(t,e){this._assertWriterUsedCorrectly();let n=t.parent;if(!n.parent)throw new d("writer-split-element-no-parent",this);if(e||(e=n.parent),!t.parent.getAncestors({includeSelf:!0}).includes(e))throw new d("writer-split-invalid-limit-element",this);let s,i;do{const o=n.root.document?n.root.document.version:null,a=n.maxOffset-t.offset,l=C.getInsertionPosition(t),h=new C(t,a,l,null,o);this.batch.addOperation(h),this.model.applyOperation(h),!s&&!i&&(s=n,i=t.parent.nextSibling),t=this.createPositionAfter(t.parent),n=t.parent}while(n!==e);return{position:t,range:new f(g._createAt(s,"end"),g._createAt(i,0))}}wrap(t,e){if(this._assertWriterUsedCorrectly(),!t.isFlat)throw new d("writer-wrap-range-not-flat",this);const n=e instanceof k?e:new k(e);if(n.childCount>0)throw new d("writer-wrap-element-not-empty",this);if(n.parent!==null)throw new d("writer-wrap-element-attached",this);this.insert(n,t.start);const s=new f(t.start.getShiftedBy(1),t.end.getShiftedBy(1));this.move(s,g._createAt(n,0))}unwrap(t){if(this._assertWriterUsedCorrectly(),t.parent===null)throw new d("writer-unwrap-element-no-parent",this);this.move(f._createIn(t),this.createPositionAfter(t)),this.remove(t)}addMarker(t,e){if(this._assertWriterUsedCorrectly(),!e||typeof e.usingOperation!="boolean")throw new d("writer-addmarker-no-usingoperation",this);const n=e.usingOperation,s=e.range,i=e.affectsData===void 0?!1:e.affectsData;if(this.model.markers.has(t))throw new d("writer-addmarker-marker-exists",this);if(!s)throw new d("writer-addmarker-no-range",this);return n?(Ve(this,t,null,s,i),this.model.markers.get(t)):this.model.markers._set(t,s,n,i)}updateMarker(t,e){this._assertWriterUsedCorrectly();const n=typeof t=="string"?t:t.name,s=this.model.markers.get(n);if(!s)throw new d("writer-updatemarker-marker-not-exists",this);if(!e){q("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),this.model.markers._refresh(s);return}const i=typeof e.usingOperation=="boolean",o=typeof e.affectsData=="boolean",a=o?e.affectsData:s.affectsData;if(!i&&!e.range&&!o)throw new d("writer-updatemarker-wrong-options",this);const l=s.getRange(),h=e.range?e.range:l;if(i&&e.usingOperation!==s.managedUsingOperations){e.usingOperation?Ve(this,n,null,h,a):(Ve(this,n,l,null,a),this.model.markers._set(n,h,void 0,a));return}s.managedUsingOperations?Ve(this,n,l,h,a):this.model.markers._set(n,h,void 0,a)}removeMarker(t){this._assertWriterUsedCorrectly();const e=typeof t=="string"?t:t.name;if(!this.model.markers.has(e))throw new d("writer-removemarker-no-marker",this);const n=this.model.markers.get(e);if(!n.managedUsingOperations){this.model.markers._remove(e);return}const s=n.getRange();Ve(this,e,s,null,n.affectsData)}addRoot(t,e="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(t);if(n&&n.isAttached())throw new d("writer-addroot-root-exists",this);const s=this.model.document,i=new Y(t,e,!0,s,s.version);return this.batch.addOperation(i),this.model.applyOperation(i),this.model.document.getRoot(t)}detachRoot(t){this._assertWriterUsedCorrectly();const e=typeof t=="string"?this.model.document.getRoot(t):t;if(!e||!e.isAttached())throw new d("writer-detachroot-no-root",this);for(const i of this.model.markers)i.getRange().root===e&&this.removeMarker(i);for(const i of e.getAttributeKeys())this.removeAttribute(i,e);this.remove(this.createRangeIn(e));const n=this.model.document,s=new Y(e.rootName,e.name,!1,n,n.version);this.batch.addOperation(s),this.model.applyOperation(s)}setSelection(...t){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...t)}setSelectionFocus(t,e){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(t,e)}setSelectionAttribute(t,e){if(this._assertWriterUsedCorrectly(),typeof t=="string")this._setSelectionAttribute(t,e);else for(const[n,s]of we(t))this._setSelectionAttribute(n,s)}removeSelectionAttribute(t){if(this._assertWriterUsedCorrectly(),typeof t=="string")this._removeSelectionAttribute(t);else for(const e of t)this._removeSelectionAttribute(e)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(t){this.model.document.selection._restoreGravity(t)}_setSelectionAttribute(t,e){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const s=H._getStoreAttributeKey(t);this.setAttribute(s,e,n.anchor.parent)}n._setAttribute(t,e)}_removeSelectionAttribute(t){const e=this.model.document.selection;if(e.isCollapsed&&e.anchor.parent.isEmpty){const n=H._getStoreAttributeKey(t);this.removeAttribute(n,e.anchor.parent)}e._removeAttribute(t)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new d("writer-incorrect-use",this)}_addOperationForAffectedMarkers(t,e){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const s=n.getRange();let i=!1;if(t==="move"){const o=e;i=o.containsPosition(s.start)||o.start.isEqual(s.start)||o.containsPosition(s.end)||o.end.isEqual(s.end)}else{const o=e,a=o.nodeBefore,l=o.nodeAfter,h=s.start.parent==a&&s.start.isAtEnd,u=s.end.parent==l&&s.end.offset==0,m=s.end.nodeAfter==l,p=s.start.nodeAfter==l;i=h||u||m||p}i&&this.updateMarker(n.name,{range:s})}}}function Dn(r,t,e,n){const s=r.model,i=s.document;let o=n.start,a,l,h;for(const m of n.getWalker({shallow:!0}))h=m.item.getAttribute(t),a&&l!=h&&(l!=e&&u(),o=a),a=m.nextPosition,l=h;a instanceof g&&a!=o&&l!=e&&u();function u(){const m=new f(o,a),p=m.root.document?i.version:null,w=new E(m,t,l,e,p);r.batch.addOperation(w),s.applyOperation(w)}}function Vn(r,t,e,n){const s=r.model,i=s.document,o=n.getAttribute(t);let a,l;if(o!=e){if(n.root===n){const u=n.document?i.version:null;l=new te(n,t,o,e,u)}else{a=new f(g._createBefore(n),r.createPositionAfter(n));const u=a.root.document?i.version:null;l=new E(a,t,o,e,u)}r.batch.addOperation(l),s.applyOperation(l)}}function Ve(r,t,e,n,s){const i=r.model,o=i.document,a=new V(t,e,n,i.markers,!!s,o.version);r.batch.addOperation(a),i.applyOperation(a)}function Go(r,t,e,n){let s;if(r.root.document){const i=n.document,o=new g(i.graveyard,[0]);s=new P(r,t,o,i.version)}else s=new Uo(r,t);e.addOperation(s),n.applyOperation(s)}function $n(r,t){return r===t||r instanceof dt&&t instanceof dt}function Ho(r){r.document.registerPostFixer(t=>Ko(t,r))}function Ko(r,t){const e=t.document.selection,n=t.schema,s=[];let i=!1;for(const o of e.getRanges()){const a=Xo(o,n);a&&!a.isEqual(o)?(s.push(a),i=!0):s.push(o)}return i&&r.setSelection(ea(s),{backward:e.isBackward}),!1}function Xo(r,t){return r.isCollapsed?Yo(r,t):Qo(r,t)}function Yo(r,t){const e=r.start,n=t.getNearestSelectionRange(e);if(!n){const i=e.getAncestors().reverse().find(o=>t.isObject(o));return i?f._createOn(i):null}if(!n.isCollapsed)return n;const s=n.start;return e.isEqual(s)?null:new f(s)}function Qo(r,t){const{start:e,end:n}=r,s=t.checkChild(e,"$text"),i=t.checkChild(n,"$text"),o=t.getLimitElement(e),a=t.getLimitElement(n);if(o===a){if(s&&i)return null;if(Zo(e,n,t)){const m=e.nodeAfter&&t.isSelectable(e.nodeAfter)?null:t.getNearestSelectionRange(e,"forward"),w=n.nodeBefore&&t.isSelectable(n.nodeBefore)?null:t.getNearestSelectionRange(n,"backward"),y=m?m.start:e,F=w?w.end:n;return new f(y,F)}}const l=o&&!o.is("rootElement"),h=a&&!a.is("rootElement");if(l||h){const u=e.nodeAfter&&n.nodeBefore&&e.nodeAfter.parent===n.nodeBefore.parent,m=l&&(!u||!Wn(e.nodeAfter,t)),p=h&&(!u||!Wn(n.nodeBefore,t));let w=e,y=n;return m&&(w=g._createBefore(Ln(o,t))),p&&(y=g._createAfter(Ln(a,t))),new f(w,y)}return null}function Ln(r,t){let e=r,n=e;for(;t.isLimit(n)&&n.parent;)e=n,n=n.parent;return e}function Zo(r,t,e){const n=r.nodeAfter&&!e.isLimit(r.nodeAfter)||e.checkChild(r,"$text"),s=t.nodeBefore&&!e.isLimit(t.nodeBefore)||e.checkChild(t,"$text");return n||s}function ea(r){const t=[...r],e=new Set;let n=1;for(;n<t.length;){const i=t[n],o=t.slice(0,n);for(const[a,l]of o.entries())if(!e.has(a)){if(i.isEqual(l))e.add(a);else if(i.isIntersecting(l)){e.add(a),e.add(n);const h=i.getJoined(l);t.push(h)}}n++}return t.filter((i,o)=>!e.has(o))}function Wn(r,t){return r&&t.isSelectable(r)}function ta(r,t,e={}){if(t.isCollapsed)return;const n=t.getFirstRange();if(n.root.rootName=="$graveyard")return;const s=r.schema;r.change(i=>{if(!e.doNotResetEntireContent&&ha(s,t)){ca(i,t);return}const o={};if(!e.doNotAutoparagraph){const h=t.getSelectedElement();h&&Object.assign(o,s.getAttributesWithProperty(h,"copyOnReplace",!0))}let a,l;e.doNotFixSelection?(a=I.fromPosition(n.start,"toPrevious"),l=I.fromPosition(n.end,"toNext")):[a,l]=na(n),a.isTouching(l)||i.remove(i.createRange(a,l)),e.leaveUnmerged||(ra(i,a,l),s.removeDisallowedAttributes(a.parent.getChildren(),i)),Is(i,t,a),!e.doNotAutoparagraph&&aa(s,a)&&Os(i,a,t,o),a.detach(),l.detach()})}function na(r){const t=r.root.document.model,e=r.start;let n=r.end;if(t.hasContent(r,{ignoreMarkers:!0})){const s=sa(n);if(s&&n.isTouching(t.createPositionAt(s,0))){const i=t.createSelection(r);t.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),a=t.createRange(o,n);t.hasContent(a,{ignoreMarkers:!0})||(n=o)}}return[I.fromPosition(e,"toPrevious"),I.fromPosition(n,"toNext")]}function sa(r){const t=r.parent,e=t.root.document.model.schema,n=t.getAncestors({parentFirst:!0,includeSelf:!0});for(const s of n){if(e.isLimit(s))return null;if(e.isBlock(s))return s}}function ra(r,t,e){const n=r.model;if(!Zt(r.model.schema,t,e))return;const[s,i]=oa(t,e);!s||!i||(!n.hasContent(s,{ignoreMarkers:!0})&&n.hasContent(i,{ignoreMarkers:!0})?Ns(r,t,e,s.parent):xs(r,t,e,s.parent))}function xs(r,t,e,n){const s=t.parent,i=e.parent;if(!(s==n||i==n)){for(t=r.createPositionAfter(s),e=r.createPositionBefore(i),e.isEqual(t)||r.insert(i,t),r.merge(t);e.parent.isEmpty;){const o=e.parent;e=r.createPositionBefore(o),r.remove(o)}Zt(r.model.schema,t,e)&&xs(r,t,e,n)}}function Ns(r,t,e,n){const s=t.parent,i=e.parent;if(!(s==n||i==n)){for(t=r.createPositionAfter(s),e=r.createPositionBefore(i),e.isEqual(t)||r.insert(s,e);t.parent.isEmpty;){const o=t.parent;t=r.createPositionBefore(o),r.remove(o)}e=r.createPositionBefore(i),ia(r,e),Zt(r.model.schema,t,e)&&Ns(r,t,e,n)}}function ia(r,t){const e=t.nodeBefore,n=t.nodeAfter;e.name!=n.name&&r.rename(e,n.name),r.clearAttributes(e),r.setAttributes(Object.fromEntries(n.getAttributes()),e),r.merge(t)}function Zt(r,t,e){const n=t.parent,s=e.parent;return n==s||r.isLimit(n)||r.isLimit(s)?!1:la(t,e,r)}function oa(r,t){const e=r.getAncestors(),n=t.getAncestors();let s=0;for(;e[s]&&e[s]==n[s];)s++;return[e[s],n[s]]}function aa(r,t){const e=r.checkChild(t,"$text"),n=r.checkChild(t,"paragraph");return!e&&n}function la(r,t,e){const n=new f(r,t);for(const s of n.getWalker())if(e.isLimit(s.item))return!1;return!0}function Os(r,t,e,n={}){const s=r.createElement("paragraph");r.model.schema.setAllowedAttributes(s,n,r),r.insert(s,t),Is(r,e,r.createPositionAt(s,0))}function ca(r,t){const e=r.model.schema.getLimitElement(t);r.remove(r.createRangeIn(e)),Os(r,r.createPositionAt(e,0),t)}function ha(r,t){const e=r.getLimitElement(t);if(!t.containsEntireContent(e))return!1;const n=t.getFirstRange();return n.start.parent==n.end.parent?!1:r.checkChild(e,"paragraph")}function Is(r,t,e){t instanceof H?r.setSelection(e):t.setTo(e)}/**
24
+ */class q{baseVersion;isDocumentOperation;batch;constructor(e){this.baseVersion=e,this.isDocumentOperation=this.baseVersion!==null,this.batch=null}_validate(){}toJSON(){const e=Object.assign({},this);return e.__className=this.constructor.className,delete e.batch,delete e.isDocumentOperation,e}static get className(){return"Operation"}static fromJSON(e,t){return new this(e.baseVersion)}}function Xt(s,e){const t=Ss(e),n=t.reduce((o,a)=>o+a.offsetSize,0),r=s.parent;Ze(s);const i=s.index;return r._insertChild(i,t),Qe(r,i+t.length),Qe(r,i),new u(s,s.getShiftedBy(n))}function As(s){if(!s.isFlat)throw new f("operation-utils-remove-range-not-flat",this);const e=s.start.parent;Ze(s.start),Ze(s.end);const t=e._removeChildren(s.start.index,s.end.index-s.start.index);return Qe(e,s.start.index),t}function Ye(s,e){if(!s.isFlat)throw new f("operation-utils-move-range-not-flat",this);const t=As(s);return e=e._getTransformedByDeletion(s.start,s.end.offset-s.start.offset),Xt(e,t)}function Eo(s,e,t){Ze(s.start),Ze(s.end);for(const n of s.getItems({shallow:!0})){const r=n.is("$textProxy")?n.textNode:n;t!==null?r._setAttribute(e,t):r._removeAttribute(e),Qe(r.parent,r.index)}Qe(s.end.parent,s.end.index)}function Ss(s){const e=[];function t(n){if(typeof n=="string")e.push(new k(n));else if(n instanceof j)e.push(new k(n.data,n.getAttributes()));else if(n instanceof ve)e.push(n);else if(le(n))for(const r of n)t(r)}t(s);for(let n=1;n<e.length;n++){const r=e[n],i=e[n-1];r instanceof k&&i instanceof k&&Es(r,i)&&(e.splice(n-1,2,new k(i.data+r.data,i.getAttributes())),n--)}return e}function Qe(s,e){const t=s.getChild(e-1),n=s.getChild(e);if(t&&n&&t.is("$text")&&n.is("$text")&&Es(t,n)){const r=new k(t.data+n.data,t.getAttributes());s._removeChildren(e-1,2),s._insertChild(e-1,r)}}function Ze(s){const e=s.textNode,t=s.parent;if(e){const n=s.offset-e.startOffset,r=e.index;t._removeChildren(r,1);const i=new k(e.data.substr(0,n),e.getAttributes()),o=new k(e.data.substr(n),e.getAttributes());t._insertChild(r,[i,o])}}function Es(s,e){const t=s.getAttributes(),n=e.getAttributes();for(const r of t){if(r[1]!==e.getAttribute(r[0]))return!1;n.next()}return n.next().done}class v extends q{sourcePosition;howMany;targetPosition;constructor(e,t,n,r){super(r),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toNext",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNone"}get type(){return this.targetPosition.root.rootName=="$graveyard"?"remove":this.sourcePosition.root.rootName=="$graveyard"?"reinsert":"move"}get affectedSelectable(){return[u._createFromPositionAndShift(this.sourcePosition,this.howMany),u._createFromPositionAndShift(this.targetPosition,0)]}clone(){return new v(this.sourcePosition,this.howMany,this.targetPosition,this.baseVersion)}getMovedRangeStart(){return this.targetPosition._getTransformedByDeletion(this.sourcePosition,this.howMany)}getReversed(){const e=this.sourcePosition._getTransformedByInsertion(this.targetPosition,this.howMany);return new v(this.getMovedRangeStart(),this.howMany,e,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent,n=this.sourcePosition.offset,r=this.targetPosition.offset;if(n+this.howMany>e.maxOffset)throw new f("move-operation-nodes-do-not-exist",this);if(e===t&&n<r&&r<n+this.howMany)throw new f("move-operation-range-into-itself",this);if(this.sourcePosition.root==this.targetPosition.root&&F(this.sourcePosition.getParentPath(),this.targetPosition.getParentPath())=="prefix"){const i=this.sourcePosition.path.length-1;if(this.targetPosition.path[i]>=n&&this.targetPosition.path[i]<n+this.howMany)throw new f("move-operation-node-into-itself",this)}}_execute(){Ye(u._createFromPositionAndShift(this.sourcePosition,this.howMany),this.targetPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e.targetPosition=this.targetPosition.toJSON(),e}static get className(){return"MoveOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),r=m.fromJSON(e.targetPosition,t);return new this(n,e.howMany,r,e.baseVersion)}}class T extends q{position;nodes;shouldReceiveAttributes;constructor(e,t,n){super(n),this.position=e.clone(),this.position.stickiness="toNone",this.nodes=new ze(Ss(t)),this.shouldReceiveAttributes=!1}get type(){return"insert"}get howMany(){return this.nodes.maxOffset}get affectedSelectable(){return this.position.clone()}clone(){const e=new ze([...this.nodes].map(n=>n._clone(!0))),t=new T(this.position,e,this.baseVersion);return t.shouldReceiveAttributes=this.shouldReceiveAttributes,t}getReversed(){const e=this.position.root.document.graveyard,t=new m(e,[0]);return new v(this.position,this.nodes.maxOffset,t,this.baseVersion+1)}_validate(){const e=this.position.parent;if(!e||e.maxOffset<this.position.offset)throw new f("insert-operation-position-invalid",this)}_execute(){const e=this.nodes;this.nodes=new ze([...e].map(t=>t._clone(!0))),Xt(this.position,e)}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e.nodes=this.nodes.toJSON(),e}static get className(){return"InsertOperation"}static fromJSON(e,t){const n=[];for(const i of e.nodes)i.name?n.push(C.fromJSON(i)):n.push(k.fromJSON(i));const r=new T(m.fromJSON(e.position,t),n,e.baseVersion);return r.shouldReceiveAttributes=e.shouldReceiveAttributes,r}}class P extends q{splitPosition;howMany;insertionPosition;graveyardPosition;constructor(e,t,n,r,i){super(i),this.splitPosition=e.clone(),this.splitPosition.stickiness="toNext",this.howMany=t,this.insertionPosition=n,this.graveyardPosition=r?r.clone():null,this.graveyardPosition&&(this.graveyardPosition.stickiness="toNext")}get type(){return"split"}get moveTargetPosition(){const e=this.insertionPosition.path.slice();return e.push(0),new m(this.insertionPosition.root,e)}get movedRange(){const e=this.splitPosition.getShiftedBy(Number.POSITIVE_INFINITY);return new u(this.splitPosition,e)}get affectedSelectable(){const e=[u._createFromPositionAndShift(this.splitPosition,0),u._createFromPositionAndShift(this.insertionPosition,0)];return this.graveyardPosition&&e.push(u._createFromPositionAndShift(this.graveyardPosition,0)),e}clone(){return new P(this.splitPosition,this.howMany,this.insertionPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.splitPosition.root.document.graveyard,t=new m(e,[0]);return new A(this.moveTargetPosition,this.howMany,this.splitPosition,t,this.baseVersion+1)}_validate(){const e=this.splitPosition.parent,t=this.splitPosition.offset;if(!e||e.maxOffset<t)throw new f("split-operation-position-invalid",this);if(e.parent){if(this.howMany!=e.maxOffset-this.splitPosition.offset)throw new f("split-operation-how-many-invalid",this);if(this.graveyardPosition&&!this.graveyardPosition.nodeAfter)throw new f("split-operation-graveyard-position-invalid",this)}else throw new f("split-operation-split-in-root",this)}_execute(){const e=this.splitPosition.parent;if(this.graveyardPosition)Ye(u._createFromPositionAndShift(this.graveyardPosition,1),this.insertionPosition);else{const n=e._clone();Xt(this.insertionPosition,n)}const t=new u(m._createAt(e,this.splitPosition.offset),m._createAt(e,e.maxOffset));Ye(t,this.moveTargetPosition)}toJSON(){const e=super.toJSON();return e.splitPosition=this.splitPosition.toJSON(),e.insertionPosition=this.insertionPosition.toJSON(),this.graveyardPosition&&(e.graveyardPosition=this.graveyardPosition.toJSON()),e}static get className(){return"SplitOperation"}static getInsertionPosition(e){const t=e.path.slice(0,-1);return t[t.length-1]++,new m(e.root,t,"toPrevious")}static fromJSON(e,t){const n=m.fromJSON(e.splitPosition,t),r=m.fromJSON(e.insertionPosition,t),i=e.graveyardPosition?m.fromJSON(e.graveyardPosition,t):null;return new this(n,e.howMany,r,i,e.baseVersion)}}class A extends q{sourcePosition;howMany;targetPosition;graveyardPosition;constructor(e,t,n,r,i){super(i),this.sourcePosition=e.clone(),this.sourcePosition.stickiness="toPrevious",this.howMany=t,this.targetPosition=n.clone(),this.targetPosition.stickiness="toNext",this.graveyardPosition=r.clone()}get type(){return"merge"}get deletionPosition(){return new m(this.sourcePosition.root,this.sourcePosition.path.slice(0,-1))}get movedRange(){const e=this.sourcePosition.getShiftedBy(Number.POSITIVE_INFINITY);return new u(this.sourcePosition,e)}get affectedSelectable(){const e=this.sourcePosition.parent;return[u._createOn(e),u._createFromPositionAndShift(this.targetPosition,0),u._createFromPositionAndShift(this.graveyardPosition,0)]}clone(){return new A(this.sourcePosition,this.howMany,this.targetPosition,this.graveyardPosition,this.baseVersion)}getReversed(){const e=this.targetPosition._getTransformedByMergeOperation(this),t=this.sourcePosition.path.slice(0,-1),n=new m(this.sourcePosition.root,t)._getTransformedByMergeOperation(this);return new P(e,this.howMany,n,this.graveyardPosition,this.baseVersion+1)}_validate(){const e=this.sourcePosition.parent,t=this.targetPosition.parent;if(e.parent)if(t.parent){if(this.howMany!=e.maxOffset)throw new f("merge-operation-how-many-invalid",this)}else throw new f("merge-operation-target-position-invalid",this);else throw new f("merge-operation-source-position-invalid",this)}_execute(){const e=this.sourcePosition.parent,t=u._createIn(e);Ye(t,this.targetPosition),Ye(u._createOn(e),this.graveyardPosition)}toJSON(){const e=super.toJSON();return e.sourcePosition=e.sourcePosition.toJSON(),e.targetPosition=e.targetPosition.toJSON(),e.graveyardPosition=e.graveyardPosition.toJSON(),e}static get className(){return"MergeOperation"}static fromJSON(e,t){const n=m.fromJSON(e.sourcePosition,t),r=m.fromJSON(e.targetPosition,t),i=m.fromJSON(e.graveyardPosition,t);return new this(n,e.howMany,r,i,e.baseVersion)}}class B extends q{name;oldRange;newRange;affectsData;_markers;constructor(e,t,n,r,i,o){super(o),this.name=e,this.oldRange=t?t.clone():null,this.newRange=n?n.clone():null,this.affectsData=i,this._markers=r}get type(){return"marker"}get affectedSelectable(){const e=[];return this.oldRange&&e.push(this.oldRange.clone()),this.newRange&&(this.oldRange?e.push(...this.newRange.getDifference(this.oldRange)):e.push(this.newRange.clone())),e}clone(){return new B(this.name,this.oldRange,this.newRange,this._markers,this.affectsData,this.baseVersion)}getReversed(){return new B(this.name,this.newRange,this.oldRange,this._markers,this.affectsData,this.baseVersion+1)}_execute(){this.newRange?this._markers._set(this.name,this.newRange,!0,this.affectsData):this._markers._remove(this.name)}toJSON(){const e=super.toJSON();return this.oldRange&&(e.oldRange=this.oldRange.toJSON()),this.newRange&&(e.newRange=this.newRange.toJSON()),delete e._markers,e}static get className(){return"MarkerOperation"}static fromJSON(e,t){return new B(e.name,e.oldRange?u.fromJSON(e.oldRange,t):null,e.newRange?u.fromJSON(e.newRange,t):null,t.model.markers,e.affectsData,e.baseVersion)}}class S extends q{range;key;oldValue;newValue;constructor(e,t,n,r,i){super(i),this.range=e.clone(),this.key=t,this.oldValue=n===void 0?null:n,this.newValue=r===void 0?null:r}get type(){return this.oldValue===null?"addAttribute":this.newValue===null?"removeAttribute":"changeAttribute"}get affectedSelectable(){return this.range.clone()}clone(){return new S(this.range,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new S(this.range,this.key,this.newValue,this.oldValue,this.baseVersion+1)}toJSON(){const e=super.toJSON();return e.range=this.range.toJSON(),e}_validate(){if(!this.range.isFlat)throw new f("attribute-operation-range-not-flat",this);for(const e of this.range.getItems({shallow:!0})){if(this.oldValue!==null&&!nn(e.getAttribute(this.key),this.oldValue))throw new f("attribute-operation-wrong-old-value",this,{item:e,key:this.key,value:this.oldValue});if(this.oldValue===null&&this.newValue!==null&&e.hasAttribute(this.key))throw new f("attribute-operation-attribute-exists",this,{node:e,key:this.key})}}_execute(){nn(this.oldValue,this.newValue)||Eo(this.range,this.key,this.newValue)}static get className(){return"AttributeOperation"}static fromJSON(e,t){return new S(u.fromJSON(e.range,t),e.key,e.oldValue,e.newValue,e.baseVersion)}}class R extends q{get type(){return"noop"}get affectedSelectable(){return null}clone(){return new R(this.baseVersion)}getReversed(){return new R(this.baseVersion+1)}_execute(){}static get className(){return"NoOperation"}}class V extends q{position;oldName;newName;constructor(e,t,n,r){super(r),this.position=e,this.position.stickiness="toNext",this.oldName=t,this.newName=n}get type(){return"rename"}get affectedSelectable(){return this.position.nodeAfter}clone(){return new V(this.position.clone(),this.oldName,this.newName,this.baseVersion)}getReversed(){return new V(this.position.clone(),this.newName,this.oldName,this.baseVersion+1)}_validate(){const e=this.position.nodeAfter;if(e instanceof C){if(e.name!==this.oldName)throw new f("rename-operation-wrong-name",this)}else throw new f("rename-operation-wrong-position",this)}_execute(){const e=this.position.nodeAfter;e.name=this.newName}toJSON(){const e=super.toJSON();return e.position=this.position.toJSON(),e}static get className(){return"RenameOperation"}static fromJSON(e,t){return new V(m.fromJSON(e.position,t),e.oldName,e.newName,e.baseVersion)}}class ee extends q{root;key;oldValue;newValue;constructor(e,t,n,r,i){super(i),this.root=e,this.key=t,this.oldValue=n===void 0?null:n,this.newValue=r===void 0?null:r}get type(){return this.oldValue===null?"addRootAttribute":this.newValue===null?"removeRootAttribute":"changeRootAttribute"}get affectedSelectable(){return this.root}clone(){return new ee(this.root,this.key,this.oldValue,this.newValue,this.baseVersion)}getReversed(){return new ee(this.root,this.key,this.newValue,this.oldValue,this.baseVersion+1)}_validate(){if(this.root!=this.root.root||this.root.is("documentFragment"))throw new f("rootattribute-operation-not-a-root",this,{root:this.root,key:this.key});if(this.oldValue!==null&&this.root.getAttribute(this.key)!==this.oldValue)throw new f("rootattribute-operation-wrong-old-value",this,{root:this.root,key:this.key});if(this.oldValue===null&&this.newValue!==null&&this.root.hasAttribute(this.key))throw new f("rootattribute-operation-attribute-exists",this,{root:this.root,key:this.key})}_execute(){this.newValue!==null?this.root._setAttribute(this.key,this.newValue):this.root._removeAttribute(this.key)}toJSON(){const e=super.toJSON();return e.root=this.root.toJSON(),e}static get className(){return"RootAttributeOperation"}static fromJSON(e,t){if(!t.getRoot(e.root))throw new f("rootattribute-operation-fromjson-no-root",this,{rootName:e.root});return new ee(t.getRoot(e.root),e.key,e.oldValue,e.newValue,e.baseVersion)}}class X extends q{rootName;elementName;isAdd;_document;constructor(e,t,n,r,i){if(super(i),this.rootName=e,this.elementName=t,this.isAdd=n,this._document=r,!this._document.getRoot(this.rootName)){const o=this._document.createRoot(this.elementName,this.rootName);o._isAttached=!1}}get type(){return this.isAdd?"addRoot":"detachRoot"}get affectedSelectable(){return this._document.getRoot(this.rootName)}clone(){return new X(this.rootName,this.elementName,this.isAdd,this._document,this.baseVersion)}getReversed(){return new X(this.rootName,this.elementName,!this.isAdd,this._document,this.baseVersion+1)}_execute(){this._document.getRoot(this.rootName)._isAttached=this.isAdd}toJSON(){const e=super.toJSON();return delete e._document,e}static get className(){return"RootOperation"}static fromJSON(e,t){return new X(e.rootName,e.elementName,e.isAdd,t,e.baseVersion)}}const J={};J[S.className]=S;J[T.className]=T;J[B.className]=B;J[v.className]=v;J[R.className]=R;J[q.className]=q;J[V.className]=V;J[ee.className]=ee;J[X.className]=X;J[P.className]=P;J[A.className]=A;class Ro{static fromJSON(e,t){return J[e.__className].fromJSON(e,t)}}const $t=new Map;function b(s,e,t){let n=$t.get(s);n||(n=new Map,$t.set(s,n)),n.set(e,t)}function To(s,e){const t=$t.get(s);return t&&t.has(e)?t.get(e):Mo}function Mo(s){return[s]}function En(s,e,t={}){const n=To(s.constructor,e.constructor);try{return s=s.clone(),n(s,e,t)}catch(r){throw r}}function yl(s,e,t){s=s.slice(),e=e.slice();const n=new xo(t.document,t.useRelations,t.forceWeakRemove);n.setOriginalOperations(s),n.setOriginalOperations(e);const r=n.originalOperations;if(s.length==0||e.length==0)return{operationsA:s,operationsB:e,originalOperations:r};const i=new WeakMap;for(const l of s)i.set(l,0);const o={nextBaseVersionA:s[s.length-1].baseVersion+1,nextBaseVersionB:e[e.length-1].baseVersion+1,originalOperationsACount:s.length,originalOperationsBCount:e.length};let a=0;for(;a<s.length;){const l=s[a],c=i.get(l);if(c==e.length){a++;continue}const h=e[c],d=En(l,h,n.getContext(l,h,!0)),p=En(h,l,n.getContext(h,l,!1));n.updateRelation(l,h),n.setOriginalOperations(d,l),n.setOriginalOperations(p,h);for(const _ of d)i.set(_,c+p.length);s.splice(a,1,...d),e.splice(c,1,...p)}return Tn(s),Tn(e),Rn(s,o.nextBaseVersionB),Rn(e,o.nextBaseVersionA),{operationsA:s,operationsB:e,originalOperations:r}}class xo{originalOperations;_history;_useRelations;_forceWeakRemove;_relations;constructor(e,t,n=!1){this.originalOperations=new Map,this._history=e.history,this._useRelations=t,this._forceWeakRemove=!!n,this._relations=new Map}setOriginalOperations(e,t=null){const n=t?this.originalOperations.get(t):null;for(const r of e)this.originalOperations.set(r,n||r)}updateRelation(e,t){if(e instanceof v)t instanceof A?e.targetPosition.isEqual(t.sourcePosition)||t.movedRange.containsPosition(e.targetPosition)?this._setRelation(e,t,"insertAtSource"):e.targetPosition.isEqual(t.deletionPosition)?this._setRelation(e,t,"insertBetween"):e.targetPosition.isAfter(t.sourcePosition)&&this._setRelation(e,t,"moveTargetAfter"):t instanceof v&&(e.targetPosition.isEqual(t.sourcePosition)||e.targetPosition.isBefore(t.sourcePosition)?this._setRelation(e,t,"insertBefore"):this._setRelation(e,t,"insertAfter"));else if(e instanceof P){if(t instanceof A)e.splitPosition.isBefore(t.sourcePosition)&&this._setRelation(e,t,"splitBefore");else if(t instanceof v)if(e.splitPosition.isEqual(t.sourcePosition)||e.splitPosition.isBefore(t.sourcePosition))this._setRelation(e,t,"splitBefore");else{const n=u._createFromPositionAndShift(t.sourcePosition,t.howMany);if(e.splitPosition.hasSameParentAs(t.sourcePosition)&&n.containsPosition(e.splitPosition)){const r=n.end.offset-e.splitPosition.offset,i=e.splitPosition.offset-n.start.offset;this._setRelation(e,t,{howMany:r,offset:i})}}}else if(e instanceof A)t instanceof A?(e.targetPosition.isEqual(t.sourcePosition)||this._setRelation(e,t,"mergeTargetNotMoved"),e.sourcePosition.isEqual(t.targetPosition)&&this._setRelation(e,t,"mergeSourceNotMoved"),e.sourcePosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeSameElement")):t instanceof P?e.sourcePosition.isEqual(t.splitPosition)&&this._setRelation(e,t,"splitAtSource"):t instanceof v&&t.howMany>0&&(e.sourcePosition.isEqual(t.sourcePosition.getShiftedBy(t.howMany))&&this._setRelation(e,t,"mergeSourceAffected"),e.targetPosition.isEqual(t.sourcePosition)&&this._setRelation(e,t,"mergeTargetWasBefore"));else if(e instanceof B){const n=e.newRange;if(!n)return;if(t instanceof A){const r=n.start.isEqual(t.targetPosition),i=n.start.isEqual(t.deletionPosition),o=n.end.isEqual(t.deletionPosition),a=n.end.isEqual(t.sourcePosition);(r||i||o||a)&&this._setRelation(e,t,{wasInLeftElement:r,wasStartBeforeMergedElement:i,wasEndBeforeMergedElement:o,wasInRightElement:a})}}}getContext(e,t,n){return{aIsStrong:n,aWasUndone:this._wasUndone(e),bWasUndone:this._wasUndone(t),abRelation:this._useRelations?this._getRelation(e,t):null,baRelation:this._useRelations?this._getRelation(t,e):null,forceWeakRemove:this._forceWeakRemove}}_wasUndone(e){const t=this.originalOperations.get(e);return t.wasUndone||this._history.isUndoneOperation(t)}_getRelation(e,t){const n=this.originalOperations.get(t),r=this._history.getUndoneOperation(n);if(!r)return null;const i=this.originalOperations.get(e),o=this._relations.get(i);return o&&o.get(r)||null}_setRelation(e,t,n){const r=this.originalOperations.get(e),i=this.originalOperations.get(t);let o=this._relations.get(r);o||(o=new Map,this._relations.set(r,o)),o.set(i,n)}}function Rn(s,e){for(const t of s)t.baseVersion=e++}function Tn(s){const e=new Map;for(let t=0;t<s.length;t++){const n=s[t];n instanceof B&&(n.baseVersion!==-1?e.set(n.name,{op:n,ranges:n.newRange?[n.newRange]:[]}):(n.newRange&&e.get(n.name).ranges.push(n.newRange),s.splice(t,1),t--))}for(const{op:t,ranges:n}of e.values())n.length?t.newRange=u._createFromRanges(n):t.newRange=null}b(S,S,(s,e,t)=>{if(s.key===e.key&&s.range.start.hasSameParentAs(e.range.start)){const n=s.range.getDifference(e.range).map(i=>new S(i,s.key,s.oldValue,s.newValue,0)),r=s.range.getIntersection(e.range);return r&&t.aIsStrong&&n.push(new S(r,e.key,e.newValue,s.newValue,0)),n.length==0?[new R(0)]:n}else return[s]});b(S,T,(s,e)=>{if(s.range.start.hasSameParentAs(e.position)&&s.range.containsPosition(e.position)){const n=s.range._getTransformedByInsertion(e.position,e.howMany,!e.shouldReceiveAttributes).map(r=>new S(r,s.key,s.oldValue,s.newValue,s.baseVersion));if(e.shouldReceiveAttributes){const r=Rs(e,s.key,s.oldValue);r&&n.unshift(r)}return n}return s.range=s.range._getTransformedByInsertion(e.position,e.howMany,!1)[0],[s]});function Rs(s,e,t){const r=s.nodes.getNode(0).getAttribute(e);if(r==t)return null;const i=new u(s.position,s.position.getShiftedBy(s.howMany));return new S(i,e,r,t,0)}b(S,A,(s,e)=>{const t=[];s.range.start.hasSameParentAs(e.deletionPosition)&&(s.range.containsPosition(e.deletionPosition)||s.range.start.isEqual(e.deletionPosition))&&t.push(u._createFromPositionAndShift(e.graveyardPosition,1));const n=s.range._getTransformedByMergeOperation(e);return n.isCollapsed||t.push(n),t.map(r=>new S(r,s.key,s.oldValue,s.newValue,s.baseVersion))});b(S,v,(s,e)=>No(s.range,e).map(n=>new S(n,s.key,s.oldValue,s.newValue,s.baseVersion)));function No(s,e){const t=u._createFromPositionAndShift(e.sourcePosition,e.howMany);let n=null,r=[];t.containsRange(s,!0)?n=s:s.start.hasSameParentAs(t.start)?(r=s.getDifference(t),n=s.getIntersection(t)):r=[s];const i=[];for(let o of r){o=o._getTransformedByDeletion(e.sourcePosition,e.howMany);const a=e.getMovedRangeStart(),l=o.start.hasSameParentAs(a),c=o._getTransformedByInsertion(a,e.howMany,l);i.push(...c)}return n&&i.push(n._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany,!1)[0]),i}b(S,P,(s,e)=>{if(s.range.end.isEqual(e.insertionPosition))return e.graveyardPosition||s.range.end.offset++,[s];if(s.range.start.hasSameParentAs(e.splitPosition)&&s.range.containsPosition(e.splitPosition)){const t=s.clone();return t.range=new u(e.moveTargetPosition.clone(),s.range.end._getCombined(e.splitPosition,e.moveTargetPosition)),s.range.end=e.splitPosition.clone(),s.range.end.stickiness="toPrevious",[s,t]}return s.range=s.range._getTransformedBySplitOperation(e),[s]});b(T,S,(s,e)=>{const t=[s];if(s.shouldReceiveAttributes&&s.position.hasSameParentAs(e.range.start)&&e.range.containsPosition(s.position)){const n=Rs(s,e.key,e.newValue);n&&t.push(n)}return t});b(T,T,(s,e,t)=>s.position.isEqual(e.position)&&t.aIsStrong?[s]:(s.position=s.position._getTransformedByInsertOperation(e),[s]));b(T,v,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));b(T,P,(s,e)=>(s.position=s.position._getTransformedBySplitOperation(e),[s]));b(T,A,(s,e)=>(s.position=s.position._getTransformedByMergeOperation(e),[s]));b(B,T,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByInsertOperation(e)[0]),s.newRange&&(s.newRange=s.newRange._getTransformedByInsertOperation(e)[0]),[s]));b(B,B,(s,e,t)=>{if(s.name==e.name)if(t.aIsStrong)s.oldRange=e.newRange?e.newRange.clone():null;else return[new R(0)];return[s]});b(B,A,(s,e)=>(s.oldRange&&(s.oldRange=s.oldRange._getTransformedByMergeOperation(e)),s.newRange&&(s.newRange=s.newRange._getTransformedByMergeOperation(e)),[s]));b(B,v,(s,e)=>{const t=[s];if(s.oldRange&&(s.oldRange=u._createFromRanges(s.oldRange._getTransformedByMoveOperation(e))),s.newRange){const n=s.newRange._getTransformedByMoveOperation(e);s.newRange=n[0];for(let r=1;r<n.length;r++){const i=s.clone();i.oldRange=null,i.newRange=n[r],i.baseVersion=-1,t.push(i)}}return t});b(B,P,(s,e,t)=>{if(s.oldRange&&(s.oldRange=s.oldRange._getTransformedBySplitOperation(e)),s.newRange){if(t.abRelation){const n=s.newRange._getTransformedBySplitOperation(e);return s.newRange.start.isEqual(e.splitPosition)?t.abRelation.wasStartBeforeMergedElement?s.newRange.start=m._createAt(e.insertionPosition):t.abRelation.wasInLeftElement?s.newRange.start=m._createAt(s.newRange.start):s.newRange.start=m._createAt(e.moveTargetPosition):s.newRange.start=n.start,s.newRange.end.isEqual(e.splitPosition)?s.newRange.end.isEqual(e.splitPosition)&&t.abRelation.wasEndBeforeMergedElement?s.newRange.end=m._createAt(e.insertionPosition):t.abRelation.wasInRightElement?s.newRange.end=m._createAt(e.moveTargetPosition):s.newRange.end=m._createAt(s.newRange.end):s.newRange.end=n.end,[s]}s.newRange=s.newRange._getTransformedBySplitOperation(e)}return[s]});b(A,T,(s,e)=>(s.sourcePosition.hasSameParentAs(e.position)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByInsertOperation(e),s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e),[s]));b(A,A,(s,e,t)=>{if(s.sourcePosition.isEqual(e.sourcePosition)&&s.targetPosition.isEqual(e.targetPosition))if(t.bWasUndone){const n=e.graveyardPosition.path.slice();return n.push(0),s.sourcePosition=new m(e.graveyardPosition.root,n),s.howMany=0,[s]}else return[new R(0)];if(s.sourcePosition.isEqual(e.sourcePosition)&&!s.targetPosition.isEqual(e.targetPosition)&&!t.bWasUndone&&t.abRelation!="splitAtSource"){const n=s.targetPosition.root.rootName=="$graveyard",r=e.targetPosition.root.rootName=="$graveyard";if(r&&!n||!(n&&!r)&&t.aIsStrong){const l=e.targetPosition._getTransformedByMergeOperation(e),c=s.targetPosition._getTransformedByMergeOperation(e);return[new v(l,s.howMany,c,0)]}else return[new R(0)]}return s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition=s.sourcePosition._getTransformedByMergeOperation(e),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),(!s.graveyardPosition.isEqual(e.graveyardPosition)||!t.aIsStrong)&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});b(A,v,(s,e,t)=>{const n=u._createFromPositionAndShift(e.sourcePosition,e.howMany);return e.type=="remove"&&!t.bWasUndone&&s.deletionPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.sourcePosition)?[new R(0)]:(e.sourcePosition.getShiftedBy(e.howMany).isEqual(s.sourcePosition)?s.sourcePosition.stickiness="toNone":e.targetPosition.isEqual(s.sourcePosition)&&t.abRelation=="mergeSourceAffected"?s.sourcePosition.stickiness="toNext":e.sourcePosition.isEqual(s.targetPosition)?(s.targetPosition.stickiness="toNone",s.howMany-=e.howMany):e.targetPosition.isEqual(s.targetPosition)&&t.abRelation=="mergeTargetWasBefore"?(s.targetPosition.stickiness="toPrevious",s.howMany+=e.howMany):(s.sourcePosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.sourcePosition.hasSameParentAs(e.sourcePosition)&&(s.howMany-=e.howMany)),s.sourcePosition=s.sourcePosition._getTransformedByMoveOperation(e),s.targetPosition=s.targetPosition._getTransformedByMoveOperation(e),s.sourcePosition.stickiness="toPrevious",s.targetPosition.stickiness="toNext",s.graveyardPosition.isEqual(e.targetPosition)||(s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)),[s])});b(A,P,(s,e,t)=>{if(e.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByDeletion(e.graveyardPosition,1),s.deletionPosition.isEqual(e.graveyardPosition)&&(s.howMany=e.howMany)),s.targetPosition.isEqual(e.splitPosition)&&(e.graveyardPosition&&s.deletionPosition.isEqual(e.graveyardPosition)||t.abRelation=="mergeTargetNotMoved"))return s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),[s];if(s.sourcePosition.isEqual(e.splitPosition)){if(t.abRelation=="mergeSourceNotMoved")return s.howMany=0,s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s];if(t.abRelation=="mergeSameElement"||s.sourcePosition.offset>0)return s.sourcePosition=e.moveTargetPosition.clone(),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]}return s.sourcePosition.hasSameParentAs(e.splitPosition)&&(s.howMany=e.splitPosition.offset),s.sourcePosition=s.sourcePosition._getTransformedBySplitOperation(e),s.targetPosition=s.targetPosition._getTransformedBySplitOperation(e),[s]});b(v,T,(s,e)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByInsertOperation(e,!1)[0];return s.sourcePosition=n.start,s.howMany=n.end.offset-n.start.offset,s.targetPosition.isEqual(e.position)||(s.targetPosition=s.targetPosition._getTransformedByInsertOperation(e)),[s]});b(v,v,(s,e,t)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany),r=u._createFromPositionAndShift(e.sourcePosition,e.howMany);let i=t.aIsStrong,o=!t.aIsStrong;t.abRelation=="insertBefore"||t.baRelation=="insertAfter"?o=!0:(t.abRelation=="insertAfter"||t.baRelation=="insertBefore")&&(o=!1);let a;if(s.targetPosition.isEqual(e.targetPosition)&&o?a=s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany):a=s.targetPosition._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Mn(s,e)&&Mn(e,s))return[e.getReversed()];if(n.containsPosition(e.targetPosition)&&n.containsRange(r,!0))return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Te([n],a);if(r.containsPosition(s.targetPosition)&&r.containsRange(n,!0))return n.start=n.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),n.end=n.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),Te([n],a);const h=F(s.sourcePosition.getParentPath(),e.sourcePosition.getParentPath());if(h=="prefix"||h=="extension")return n.start=n.start._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),n.end=n.end._getTransformedByMove(e.sourcePosition,e.targetPosition,e.howMany),Te([n],a);s.type=="remove"&&e.type!="remove"&&!t.aWasUndone&&!t.forceWeakRemove?i=!0:s.type!="remove"&&e.type=="remove"&&!t.bWasUndone&&!t.forceWeakRemove&&(i=!1);const d=[],p=n.getDifference(r);for(const y of p){y.start=y.start._getTransformedByDeletion(e.sourcePosition,e.howMany),y.end=y.end._getTransformedByDeletion(e.sourcePosition,e.howMany);const I=F(y.start.getParentPath(),e.getMovedRangeStart().getParentPath())=="same",ue=y._getTransformedByInsertion(e.getMovedRangeStart(),e.howMany,I);d.push(...ue)}const _=n.getIntersection(r);return _!==null&&i&&(_.start=_.start._getCombined(e.sourcePosition,e.getMovedRangeStart()),_.end=_.end._getCombined(e.sourcePosition,e.getMovedRangeStart()),d.length===0?d.push(_):d.length==1?r.start.isBefore(n.start)||r.start.isEqual(n.start)?d.unshift(_):d.push(_):d.splice(1,0,_)),d.length===0?[new R(s.baseVersion)]:Te(d,a)});b(v,P,(s,e,t)=>{let n=s.targetPosition.clone();(!s.targetPosition.isEqual(e.insertionPosition)||!e.graveyardPosition||t.abRelation=="moveTargetAfter")&&(n=s.targetPosition._getTransformedBySplitOperation(e));const r=u._createFromPositionAndShift(s.sourcePosition,s.howMany);if(r.end.isEqual(e.insertionPosition))return e.graveyardPosition||s.howMany++,s.targetPosition=n,[s];if(r.start.hasSameParentAs(e.splitPosition)&&r.containsPosition(e.splitPosition)){let a=new u(e.splitPosition,r.end);a=a._getTransformedBySplitOperation(e);const l=[new u(r.start,e.splitPosition),a];return Te(l,n)}s.targetPosition.isEqual(e.splitPosition)&&t.abRelation=="insertAtSource"&&(n=e.moveTargetPosition),s.targetPosition.isEqual(e.insertionPosition)&&t.abRelation=="insertBetween"&&(n=s.targetPosition);const o=[r._getTransformedBySplitOperation(e)];if(e.graveyardPosition){const a=r.start.isEqual(e.graveyardPosition)||r.containsPosition(e.graveyardPosition);s.howMany>1&&a&&!t.aWasUndone&&o.push(u._createFromPositionAndShift(e.insertionPosition,1))}return Te(o,n)});b(v,A,(s,e,t)=>{const n=u._createFromPositionAndShift(s.sourcePosition,s.howMany);if(e.deletionPosition.hasSameParentAs(s.sourcePosition)&&n.containsPosition(e.sourcePosition)){if(s.type=="remove"&&!t.forceWeakRemove){if(!t.aWasUndone){const o=[];let a=e.graveyardPosition.clone(),l=e.targetPosition._getTransformedByMergeOperation(e);const c=s.targetPosition.getTransformedByOperation(e);s.howMany>1&&(o.push(new v(s.sourcePosition,s.howMany-1,c,0)),a=a._getTransformedByMove(s.sourcePosition,c,s.howMany-1),l=l._getTransformedByMove(s.sourcePosition,c,s.howMany-1));const h=e.deletionPosition._getCombined(s.sourcePosition,c),d=new v(a,1,h,0),p=d.getMovedRangeStart().path.slice();p.push(0);const _=new m(d.targetPosition.root,p);l=l._getTransformedByMove(a,h,1);const y=new v(l,e.howMany,_,0);return o.push(d),o.push(y),o}}else if(s.howMany==1)return t.bWasUndone?(s.sourcePosition=e.graveyardPosition.clone(),s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]):[new R(0)]}const i=u._createFromPositionAndShift(s.sourcePosition,s.howMany)._getTransformedByMergeOperation(e);return s.sourcePosition=i.start,s.howMany=i.end.offset-i.start.offset,s.targetPosition=s.targetPosition._getTransformedByMergeOperation(e),[s]});b(V,T,(s,e)=>(s.position=s.position._getTransformedByInsertOperation(e),[s]));b(V,A,(s,e)=>s.position.isEqual(e.deletionPosition)?(s.position=e.graveyardPosition.clone(),s.position.stickiness="toNext",[s]):(s.position=s.position._getTransformedByMergeOperation(e),[s]));b(V,v,(s,e)=>(s.position=s.position._getTransformedByMoveOperation(e),[s]));b(V,V,(s,e,t)=>{if(s.position.isEqual(e.position))if(t.aIsStrong)s.oldName=e.newName;else return[new R(0)];return[s]});b(V,P,(s,e)=>{const t=s.position.path,n=e.splitPosition.getParentPath();if(F(t,n)=="same"&&!e.graveyardPosition){const r=new V(s.position.getShiftedBy(1),s.oldName,s.newName,0);return[s,r]}return s.position=s.position._getTransformedBySplitOperation(e),[s]});b(ee,ee,(s,e,t)=>{if(s.root===e.root&&s.key===e.key){if(!t.aIsStrong||s.newValue===e.newValue)return[new R(0)];s.oldValue=e.newValue}return[s]});b(X,X,(s,e)=>s.rootName===e.rootName&&s.isAdd===e.isAdd?[new R(0)]:[s]);b(P,T,(s,e)=>(s.splitPosition.hasSameParentAs(e.position)&&s.splitPosition.offset<e.position.offset&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByInsertOperation(e),s.insertionPosition=s.insertionPosition._getTransformedByInsertOperation(e),[s]));b(P,A,(s,e,t)=>{if(!s.graveyardPosition&&!t.bWasUndone&&s.splitPosition.hasSameParentAs(e.sourcePosition)){const n=e.graveyardPosition.path.slice();n.push(0);const r=new m(e.graveyardPosition.root,n),i=P.getInsertionPosition(new m(e.graveyardPosition.root,n)),o=new P(r,0,i,null,0);return s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),s.graveyardPosition=o.insertionPosition.clone(),s.graveyardPosition.stickiness="toNext",[o,s]}return s.splitPosition.hasSameParentAs(e.deletionPosition)&&!s.splitPosition.isAfter(e.deletionPosition)&&s.howMany--,s.splitPosition.hasSameParentAs(e.targetPosition)&&(s.howMany+=e.howMany),s.splitPosition=s.splitPosition._getTransformedByMergeOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedByMergeOperation(e)),[s]});b(P,v,(s,e,t)=>{const n=u._createFromPositionAndShift(e.sourcePosition,e.howMany);if(s.graveyardPosition){const i=n.start.isEqual(s.graveyardPosition)||n.containsPosition(s.graveyardPosition);if(!t.bWasUndone&&i){const o=s.splitPosition._getTransformedByMoveOperation(e),a=s.graveyardPosition._getTransformedByMoveOperation(e),l=a.path.slice();l.push(0);const c=new m(a.root,l);return[new v(o,s.howMany,c,0)]}s.graveyardPosition=s.graveyardPosition._getTransformedByMoveOperation(e)}const r=s.splitPosition.isEqual(e.targetPosition);if(r&&(t.baRelation=="insertAtSource"||t.abRelation=="splitBefore"))return s.howMany+=e.howMany,s.splitPosition=s.splitPosition._getTransformedByDeletion(e.sourcePosition,e.howMany),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s];if(r&&t.abRelation&&t.abRelation.howMany){const{howMany:i,offset:o}=t.abRelation;return s.howMany+=i,s.splitPosition=s.splitPosition.getShiftedBy(o),[s]}if(s.splitPosition.hasSameParentAs(e.sourcePosition)&&n.containsPosition(s.splitPosition)){const i=e.howMany-(s.splitPosition.offset-e.sourcePosition.offset);return s.howMany-=i,s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany),s.splitPosition=e.sourcePosition.clone(),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]}return e.sourcePosition.isEqual(e.targetPosition)||(s.splitPosition.hasSameParentAs(e.sourcePosition)&&s.splitPosition.offset<=e.sourcePosition.offset&&(s.howMany-=e.howMany),s.splitPosition.hasSameParentAs(e.targetPosition)&&s.splitPosition.offset<e.targetPosition.offset&&(s.howMany+=e.howMany)),s.splitPosition.stickiness="toNone",s.splitPosition=s.splitPosition._getTransformedByMoveOperation(e),s.splitPosition.stickiness="toNext",s.graveyardPosition?s.insertionPosition=s.insertionPosition._getTransformedByMoveOperation(e):s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]});b(P,P,(s,e,t)=>{if(s.splitPosition.isEqual(e.splitPosition)){if(!s.graveyardPosition&&!e.graveyardPosition)return[new R(0)];if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition))return[new R(0)];if(t.abRelation=="splitBefore")return s.howMany=0,s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e),[s]}if(s.graveyardPosition&&e.graveyardPosition&&s.graveyardPosition.isEqual(e.graveyardPosition)){const n=s.splitPosition.root.rootName=="$graveyard",r=e.splitPosition.root.rootName=="$graveyard";if(r&&!n||!(n&&!r)&&t.aIsStrong){const l=[];return e.howMany&&l.push(new v(e.moveTargetPosition,e.howMany,e.splitPosition,0)),s.howMany&&l.push(new v(s.splitPosition,s.howMany,s.moveTargetPosition,0)),l}else return[new R(0)]}if(s.graveyardPosition&&(s.graveyardPosition=s.graveyardPosition._getTransformedBySplitOperation(e)),s.splitPosition.isEqual(e.insertionPosition)&&t.abRelation=="splitBefore")return s.howMany++,[s];if(e.splitPosition.isEqual(s.insertionPosition)&&t.baRelation=="splitBefore"){const n=e.insertionPosition.path.slice();n.push(0);const r=new m(e.insertionPosition.root,n),i=new v(s.insertionPosition,1,r,0);return[s,i]}return s.splitPosition.hasSameParentAs(e.splitPosition)&&s.splitPosition.offset<e.splitPosition.offset&&(s.howMany-=e.howMany),s.splitPosition=s.splitPosition._getTransformedBySplitOperation(e),s.insertionPosition=P.getInsertionPosition(s.splitPosition),[s]});function Mn(s,e){return s.targetPosition._getTransformedByDeletion(e.sourcePosition,e.howMany)===null}function Te(s,e){const t=[];for(let n=0;n<s.length;n++){const r=s[n],i=new v(r.start,r.end.offset-r.start.offset,e,0);t.push(i);for(let o=n+1;o<s.length;o++)s[o]=s[o]._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)[0];e=e._getTransformedByMove(i.sourcePosition,i.targetPosition,i.howMany)}return t}class O extends N(m){constructor(e,t,n="toNone"){if(super(e,t,n),!this.root.is("rootElement"))throw new f("model-liveposition-root-not-rootelement",e);Oo.call(this)}detach(){this.stopListening()}toPosition(){return new m(this.root,this.path.slice(),this.stickiness)}static fromPosition(e,t){return new this(e.root,e.path.slice(),t||e.stickiness)}}O.prototype.is=function(s){return s==="livePosition"||s==="model:livePosition"||s=="position"||s==="model:position"};function Oo(){this.listenTo(this.root.document.model,"applyOperation",(s,e)=>{const t=e[0];t.isDocumentOperation&&Io.call(this,t)},{priority:"low"})}function Io(s){const e=this.getTransformedByOperation(s);if(!this.isEqual(e)){const t=this.toPosition();this.path=e.path,this.root=e.root,this.fire("change",t)}}class ke{operations;isUndoable;isLocal;isUndo;isTyping;constructor(e={}){typeof e=="string"&&(e=e==="transparent"?{isUndoable:!1}:{},W("batch-constructor-deprecated-string-type"));const{isUndoable:t=!0,isLocal:n=!0,isUndo:r=!1,isTyping:i=!1}=e;this.operations=[],this.isUndoable=t,this.isLocal=n,this.isUndo=r,this.isTyping=i}get type(){return W("batch-type-deprecated"),"default"}get baseVersion(){for(const e of this.operations)if(e.baseVersion!==null)return e.baseVersion;return null}addOperation(e){return e.isDocumentOperation&&(e.batch=this,this.operations.push(e)),e}}class ut{static _statesPriority=[void 0,"refresh","rename","move"];_markerCollection;_changesInElement=new Map;_elementsSnapshots=new Map;_elementChildrenSnapshots=new Map;_elementState=new Map;_changedMarkers=new Map;_changedRoots=new Map;_changeCount=0;_cachedChanges=null;_cachedChangesWithGraveyard=null;_refreshedItems=new Set;constructor(e){this._markerCollection=e}get isEmpty(){return this._changesInElement.size==0&&this._changedMarkers.size==0&&this._changedRoots.size==0}bufferOperation(e){const t=e;switch(t.type){case"insert":{if(this._isInInsertedElement(t.position.parent))return;this._markInsert(t.position.parent,t.position.offset,t.nodes.maxOffset);break}case"addAttribute":case"removeAttribute":case"changeAttribute":{for(const n of t.range.getItems({shallow:!0}))this._isInInsertedElement(n.parent)||this._markAttribute(n);break}case"remove":case"move":case"reinsert":{if(t.sourcePosition.isEqual(t.targetPosition)||t.sourcePosition.getShiftedBy(t.howMany).isEqual(t.targetPosition))return;const n=this._isInInsertedElement(t.sourcePosition.parent),r=this._isInInsertedElement(t.targetPosition.parent);n||this._markRemove(t.sourcePosition.parent,t.sourcePosition.offset,t.howMany),r||this._markInsert(t.targetPosition.parent,t.getMovedRangeStart().offset,t.howMany);const i=u._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const o of i.getItems({shallow:!0}))this._setElementState(o,"move");break}case"rename":{if(this._isInInsertedElement(t.position.parent))return;this._markRemove(t.position.parent,t.position.offset,1),this._markInsert(t.position.parent,t.position.offset,1);const n=u._createFromPositionAndShift(t.position,1);for(const r of this._markerCollection.getMarkersIntersectingRange(n)){const i=r.getData();this.bufferMarkerChange(r.name,i,i)}this._setElementState(t.position.nodeAfter,"rename");break}case"split":{const n=t.splitPosition.parent;if(!this._isInInsertedElement(n)){this._markRemove(n,t.splitPosition.offset,t.howMany);const r=u._createFromPositionAndShift(t.splitPosition,t.howMany);for(const i of r.getItems({shallow:!0}))this._setElementState(i,"move")}this._isInInsertedElement(t.insertionPosition.parent)||this._markInsert(t.insertionPosition.parent,t.insertionPosition.offset,1),t.graveyardPosition&&(this._markRemove(t.graveyardPosition.parent,t.graveyardPosition.offset,1),this._setElementState(t.graveyardPosition.nodeAfter,"move"));break}case"merge":{const n=t.sourcePosition.parent;this._isInInsertedElement(n.parent)||this._markRemove(n.parent,n.startOffset,1);const r=t.graveyardPosition.parent;this._markInsert(r,t.graveyardPosition.offset,1),this._setElementState(n,"move");const i=t.targetPosition.parent;if(!this._isInInsertedElement(i)){this._markInsert(i,t.targetPosition.offset,n.maxOffset);const o=u._createFromPositionAndShift(t.sourcePosition,t.howMany);for(const a of o.getItems({shallow:!0}))this._setElementState(a,"move")}break}case"detachRoot":case"addRoot":{const n=t.affectedSelectable;if(!n._isLoaded||n.isAttached()==t.isAdd)return;this._bufferRootStateChange(t.rootName,t.isAdd);break}case"addRootAttribute":case"removeRootAttribute":case"changeRootAttribute":{if(!t.root._isLoaded)return;const n=t.root.rootName;this._bufferRootAttributeChange(n,t.key,t.oldValue,t.newValue);break}}this._cachedChanges=null}bufferMarkerChange(e,t,n){t.range&&t.range.root.is("rootElement")&&!t.range.root._isLoaded&&(t.range=null),n.range&&n.range.root.is("rootElement")&&!n.range.root._isLoaded&&(n.range=null);let r=this._changedMarkers.get(e);r?r.newMarkerData=n:(r={newMarkerData:n,oldMarkerData:t},this._changedMarkers.set(e,r)),r.oldMarkerData.range==null&&n.range==null&&this._changedMarkers.delete(e)}getMarkersToRemove(){const e=[];for(const[t,n]of this._changedMarkers)n.oldMarkerData.range!=null&&e.push({name:t,range:n.oldMarkerData.range});return e}getMarkersToAdd(){const e=[];for(const[t,n]of this._changedMarkers)n.newMarkerData.range!=null&&e.push({name:t,range:n.newMarkerData.range});return e}getChangedMarkers(){return Array.from(this._changedMarkers).map(([e,t])=>({name:e,data:{oldRange:t.oldMarkerData.range,newRange:t.newMarkerData.range}}))}hasDataChanges(){if(this.getChanges().length||this._changedRoots.size>0)return!0;for(const{newMarkerData:e,oldMarkerData:t}of this._changedMarkers.values()){if(e.affectsData!==t.affectsData)return!0;if(e.affectsData){const n=e.range&&!t.range,r=!e.range&&t.range,i=e.range&&t.range&&!e.range.isEqual(t.range);if(n||r||i)return!0}}return!1}getChanges(e={}){if(this._cachedChanges)return e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice();let t=[];for(const n of this._changesInElement.keys()){const r=this._changesInElement.get(n).sort((h,d)=>h.offset===d.offset?h.type!=d.type?h.type=="remove"?-1:1:0:h.offset<d.offset?-1:1),i=this._elementChildrenSnapshots.get(n),o=Nn(n.getChildren()),a=Fo(i.length,r);let l=0,c=0;for(const h of a)if(h==="i"){const d=this._getDiffActionForNode(o[l].node,"insert"),p=this._elementsSnapshots.get(o[l].node),_=this._getInsertDiff(n,l,d,o[l],p);t.push(_),l++}else if(h==="r"){const d=this._getDiffActionForNode(i[c].node,"remove"),p=this._getRemoveDiff(n,l,d,i[c]);t.push(p),c++}else if(h==="a"){const d=i[c].attributes,p=o[l].attributes;let _;if(o[l].name=="$text")_=new u(m._createAt(n,l),m._createAt(n,l+1));else{const I=n.offsetToIndex(l);_=new u(m._createAt(n,l),m._createAt(n.getChild(I),0))}const y=this._getAttributesDiff(_,d,p);t.push(...y),l++,c++}else l++,c++}t.sort((n,r)=>n.position.root!=r.position.root?n.position.root.rootName<r.position.root.rootName?-1:1:n.position.isEqual(r.position)?n.changeCount-r.changeCount:n.position.isBefore(r.position)?-1:1);for(let n=1,r=0;n<t.length;n++){const i=t[r],o=t[n],a=i.type=="remove"&&o.type=="remove"&&i.name=="$text"&&o.name=="$text"&&i.position.isEqual(o.position),l=i.type=="insert"&&o.type=="insert"&&i.name=="$text"&&o.name=="$text"&&i.position.parent==o.position.parent&&i.position.offset+i.length==o.position.offset,c=i.type=="attribute"&&o.type=="attribute"&&i.position.parent==o.position.parent&&i.range.isFlat&&o.range.isFlat&&i.position.offset+i.length==o.position.offset&&i.attributeKey==o.attributeKey&&i.attributeOldValue==o.attributeOldValue&&i.attributeNewValue==o.attributeNewValue;a||l||c?(i.length++,c&&(i.range.end=i.range.end.getShiftedBy(1)),t[n]=null):r=n}t=t.filter(n=>n);for(const n of t)delete n.changeCount,n.type=="attribute"&&(delete n.position,delete n.length);return this._changeCount=0,this._cachedChangesWithGraveyard=t,this._cachedChanges=t.filter(Do),e.includeChangesInGraveyard?this._cachedChangesWithGraveyard.slice():this._cachedChanges.slice()}getChangedRoots(){return Array.from(this._changedRoots.values()).map(e=>{const t={...e};return t.state!==void 0&&delete t.attributes,t})}getRefreshedItems(){return new Set(this._refreshedItems)}reset(){this._changesInElement.clear(),this._elementChildrenSnapshots.clear(),this._elementsSnapshots.clear(),this._elementState.clear(),this._changedMarkers.clear(),this._changedRoots.clear(),this._refreshedItems.clear(),this._cachedChanges=null}_refreshItem(e){if(this._isInInsertedElement(e.parent))return;this._markRemove(e.parent,e.startOffset,e.offsetSize),this._markInsert(e.parent,e.startOffset,e.offsetSize),this._refreshedItems.add(e),this._setElementState(e,"refresh");const t=u._createOn(e);for(const n of this._markerCollection.getMarkersIntersectingRange(t)){const r=n.getData();this.bufferMarkerChange(n.name,r,r)}this._cachedChanges=null}_bufferRootLoad(e){if(e.isAttached()){this._bufferRootStateChange(e.rootName,!0),this._markInsert(e,0,e.maxOffset);for(const t of e.getAttributeKeys())this._bufferRootAttributeChange(e.rootName,t,null,e.getAttribute(t));for(const t of this._markerCollection)if(t.getRange().root==e){const n=t.getData();this.bufferMarkerChange(t.name,{...n,range:null},n)}}}_bufferRootStateChange(e,t){if(!this._changedRoots.has(e)){this._changedRoots.set(e,{name:e,state:t?"attached":"detached"});return}const n=this._changedRoots.get(e);n.state!==void 0?(delete n.state,n.attributes===void 0&&this._changedRoots.delete(e)):n.state=t?"attached":"detached"}_bufferRootAttributeChange(e,t,n,r){const i=this._changedRoots.get(e)||{name:e},o=i.attributes||{};if(o[t]){const a=o[t];r===a.oldValue?delete o[t]:a.newValue=r}else o[t]={oldValue:n,newValue:r};Object.entries(o).length===0?(delete i.attributes,i.state===void 0&&this._changedRoots.delete(e)):(i.attributes=o,this._changedRoots.set(e,i))}_markInsert(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"insert",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r)}_markRemove(e,t,n){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const r={type:"remove",offset:t,howMany:n,count:this._changeCount++};this._markChange(e,r),this._removeAllNestedChanges(e,t,n)}_markAttribute(e){if(e.root.is("rootElement")&&!e.root._isLoaded)return;const t={type:"attribute",offset:e.startOffset,howMany:e.offsetSize,count:this._changeCount++};this._markChange(e.parent,t)}_markChange(e,t){this._makeSnapshots(e);const n=this._getChangesForElement(e);this._handleChange(t,n),n.push(t);for(let r=0;r<n.length;r++)n[r].howMany<1&&(n.splice(r,1),r--)}_setElementState(e,t){if(!e.is("element"))return;const n=ut._statesPriority.indexOf(this._elementState.get(e));ut._statesPriority.indexOf(t)>n&&this._elementState.set(e,t)}_getDiffActionForNode(e,t){if(!e.is("element")||!this._elementsSnapshots.has(e))return t;const n=this._elementState.get(e);return!n||n=="move"?t:n}_getChangesForElement(e){let t;return this._changesInElement.has(e)?t=this._changesInElement.get(e):(t=[],this._changesInElement.set(e,t)),t}_makeSnapshots(e){if(this._elementChildrenSnapshots.has(e))return;const t=Nn(e.getChildren());this._elementChildrenSnapshots.set(e,t);for(const n of t)this._elementsSnapshots.set(n.node,n)}_handleChange(e,t){e.nodesToHandle=e.howMany;for(const n of t){const r=e.offset+e.howMany,i=n.offset+n.howMany;if(e.type=="insert"&&(n.type=="insert"&&(e.offset<=n.offset?n.offset+=e.howMany:e.offset<i&&(n.howMany+=e.nodesToHandle,e.nodesToHandle=0)),n.type=="remove"&&e.offset<n.offset&&(n.offset+=e.howMany),n.type=="attribute")){if(e.offset<=n.offset)n.offset+=e.howMany;else if(e.offset<i){const o=n.howMany;n.howMany=e.offset-n.offset,t.unshift({type:"attribute",offset:r,howMany:o-n.howMany,count:this._changeCount++})}}if(e.type=="remove"){if(n.type=="insert"){if(r<=n.offset)n.offset-=e.howMany;else if(r<=i)if(e.offset<n.offset){const o=r-n.offset;n.offset=e.offset,n.howMany-=o,e.nodesToHandle-=o}else n.howMany-=e.nodesToHandle,e.nodesToHandle=0;else if(e.offset<=n.offset)e.nodesToHandle-=n.howMany,n.howMany=0;else if(e.offset<i){const o=i-e.offset;n.howMany-=o,e.nodesToHandle-=o}}if(n.type=="remove"&&(r<=n.offset?n.offset-=e.howMany:e.offset<n.offset&&(e.nodesToHandle+=n.howMany,n.howMany=0)),n.type=="attribute"){if(r<=n.offset)n.offset-=e.howMany;else if(e.offset<n.offset){const o=r-n.offset;n.offset=e.offset,n.howMany-=o}else if(e.offset<i)if(r<=i){const o=n.howMany;n.howMany=e.offset-n.offset;const a=o-n.howMany-e.nodesToHandle;t.unshift({type:"attribute",offset:e.offset,howMany:a,count:this._changeCount++})}else n.howMany-=i-e.offset}}if(e.type=="attribute"){if(n.type=="insert")if(e.offset<n.offset&&r>n.offset){if(r>i){const o={type:"attribute",offset:i,howMany:r-i,count:this._changeCount++};this._handleChange(o,t),t.push(o)}e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}else e.offset>=n.offset&&e.offset<i&&(r>i?(e.nodesToHandle=r-i,e.offset=i):e.nodesToHandle=0);if(n.type=="remove"&&e.offset<n.offset&&r>n.offset){const o={type:"attribute",offset:n.offset,howMany:r-n.offset,count:this._changeCount++};this._handleChange(o,t),t.push(o),e.nodesToHandle=n.offset-e.offset,e.howMany=e.nodesToHandle}n.type=="attribute"&&(e.offset>=n.offset&&r<=i?(e.nodesToHandle=0,e.howMany=0,e.offset=0):e.offset<=n.offset&&r>=i&&(n.howMany=0))}}e.howMany=e.nodesToHandle,delete e.nodesToHandle}_getInsertDiff(e,t,n,r,i){const o={type:"insert",position:m._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++,action:n};return n!="insert"&&i&&(o.before={name:i.name,attributes:new Map(i.attributes)}),o}_getRemoveDiff(e,t,n,r){return{type:"remove",action:n,position:m._createAt(e,t),name:r.name,attributes:new Map(r.attributes),length:1,changeCount:this._changeCount++}}_getAttributesDiff(e,t,n){const r=[];n=new Map(n);for(const[i,o]of t){const a=n.has(i)?n.get(i):null;a!==o&&r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:o,attributeNewValue:a,changeCount:this._changeCount++}),n.delete(i)}for(const[i,o]of n)r.push({type:"attribute",position:e.start,range:e.clone(),length:1,attributeKey:i,attributeOldValue:null,attributeNewValue:o,changeCount:this._changeCount++});return r}_isInInsertedElement(e){const t=e.parent;if(!t)return!1;const n=this._changesInElement.get(t),r=e.startOffset;if(n){for(const i of n)if(i.type=="insert"&&r>=i.offset&&r<i.offset+i.howMany)return!0}return this._isInInsertedElement(t)}_removeAllNestedChanges(e,t,n){const r=new u(m._createAt(e,t),m._createAt(e,t+n));for(const i of r.getItems({shallow:!0}))i.is("element")&&(this._changesInElement.delete(i),this._removeAllNestedChanges(i,0,i.maxOffset))}}function xn(s){return{node:s,name:s.is("$text")?"$text":s.name,attributes:new Map(s.getAttributes())}}function Nn(s){const e=[];for(const t of s)if(t.is("$text"))for(let n=0;n<t.data.length;++n)e.push(xn(t));else e.push(xn(t));return e}function Fo(s,e){const t=[];let n=0,r=0;for(const i of e){if(i.offset>n){for(let o=0;o<i.offset-n;o++)t.push("e");r+=i.offset-n}if(i.type=="insert"){for(let o=0;o<i.howMany;o++)t.push("i");n=i.offset+i.howMany}else if(i.type=="remove"){for(let o=0;o<i.howMany;o++)t.push("r");n=i.offset,r+=i.howMany}else{if(i.howMany>1500)for(let o=0;o<i.howMany;o++)t.push("a");else t.push(..."a".repeat(i.howMany).split(""));n=i.offset+i.howMany,r+=i.howMany}}if(r<s)for(let i=0;i<s-r-n;i++)t.push("e");return t}function Do(s){const e="position"in s&&s.position.root.rootName=="$graveyard",t="range"in s&&s.range.root.rootName=="$graveyard";return!e&&!t}class Bo{_operations=[];_undoPairs=new Map;_undoneOperations=new Set;_baseVersionToOperationIndex=new Map;_version=0;_gaps=new Map;get version(){return this._version}set version(e){this._operations.length&&e>this._version+1&&this._gaps.set(this._version,e),this._version=e}get lastOperation(){return this._operations[this._operations.length-1]}addOperation(e){if(e.baseVersion!==this.version)throw new f("model-document-history-addoperation-incorrect-version",this,{operation:e,historyVersion:this.version});this._operations.push(e),this._version++,this._baseVersionToOperationIndex.set(e.baseVersion,this._operations.length-1)}getOperations(e,t=this.version){if(!this._operations.length)return[];const n=this._operations[0];e===void 0&&(e=n.baseVersion);let r=t-1;for(const[a,l]of this._gaps)e>a&&e<l&&(e=l),r>a&&r<l&&(r=a-1);if(r<n.baseVersion||e>this.lastOperation.baseVersion)return[];let i=this._baseVersionToOperationIndex.get(e);i===void 0&&(i=0);let o=this._baseVersionToOperationIndex.get(r);return o===void 0&&(o=this._operations.length-1),this._operations.slice(i,o+1)}getOperation(e){const t=this._baseVersionToOperationIndex.get(e);if(t!==void 0)return this._operations[t]}setOperationAsUndone(e,t){this._undoPairs.set(t,e),this._undoneOperations.add(e)}isUndoingOperation(e){return this._undoPairs.has(e)}isUndoneOperation(e){return this._undoneOperations.has(e)}getUndoneOperation(e){return this._undoPairs.get(e)}reset(){this._version=0,this._undoPairs=new Map,this._operations=[],this._undoneOperations=new Set,this._gaps=new Map,this._baseVersionToOperationIndex=new Map}}class ft extends C{rootName;_document;_isAttached=!0;_isLoaded=!0;constructor(e,t,n="main"){super(t),this._document=e,this.rootName=n}get document(){return this._document}isAttached(){return this._isAttached}toJSON(){return this.rootName}}ft.prototype.is=function(s,e){return e?e===this.name&&(s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"):s==="rootElement"||s==="model:rootElement"||s==="element"||s==="model:element"||s==="node"||s==="model:node"};const On="$graveyard";class Vo extends N(){model;history;selection;roots;differ;isReadOnly;_postFixers;_hasSelectionChangedFromTheLastChangeBlock;constructor(e){super(),this.model=e,this.history=new Bo,this.selection=new G(this),this.roots=new Lt({idProperty:"rootName"}),this.differ=new ut(e.markers),this.isReadOnly=!1,this._postFixers=new Set,this._hasSelectionChangedFromTheLastChangeBlock=!1,this.createRoot("$root",On),this.listenTo(e,"applyOperation",(t,n)=>{const r=n[0];r.isDocumentOperation&&this.differ.bufferOperation(r)},{priority:"high"}),this.listenTo(e,"applyOperation",(t,n)=>{const r=n[0];r.isDocumentOperation&&this.history.addOperation(r)},{priority:"low"}),this.listenTo(this.selection,"change",()=>{this._hasSelectionChangedFromTheLastChangeBlock=!0}),this.listenTo(e.markers,"update",(t,n,r,i,o)=>{const a={...n.getData(),range:i};this.differ.bufferMarkerChange(n.name,o,a),r===null&&n.on("change",(l,c)=>{const h=n.getData();this.differ.bufferMarkerChange(n.name,{...h,range:c},h)})}),this.registerPostFixer(t=>{let n=!1;for(const r of this.roots)!r.isAttached()&&!r.isEmpty&&(t.remove(t.createRangeIn(r)),n=!0);for(const r of this.model.markers)r.getRange().root.isAttached()||(t.removeMarker(r),n=!0);return n})}get version(){return this.history.version}set version(e){this.history.version=e}get graveyard(){return this.getRoot(On)}createRoot(e="$root",t="main"){if(this.roots.get(t))throw new f("model-document-createroot-name-exists",this,{name:t});const n=new ft(this,e,t);return this.roots.add(n),n}destroy(){this.selection.destroy(),this.stopListening()}getRoot(e="main"){return this.roots.get(e)}getRootNames(e=!1){return this.getRoots(e).map(t=>t.rootName)}getRoots(e=!1){return this.roots.filter(t=>t!=this.graveyard&&(e||t.isAttached())&&t._isLoaded)}registerPostFixer(e){this._postFixers.add(e)}toJSON(){const e=Un(this);return e.selection="[engine.model.DocumentSelection]",e.model="[engine.model.Model]",e}_handleChangeBlock(e){this._hasDocumentChangedFromTheLastChangeBlock()&&(this._callPostFixers(e),this.selection.refresh(),this.differ.hasDataChanges()?this.fire("change:data",e.batch):this.fire("change",e.batch),this.selection.refresh(),this.differ.reset()),this._hasSelectionChangedFromTheLastChangeBlock=!1}_hasDocumentChangedFromTheLastChangeBlock(){return!this.differ.isEmpty||this._hasSelectionChangedFromTheLastChangeBlock}_getDefaultRoot(){const e=this.getRoots();return e.length?e[0]:this.graveyard}_getDefaultRange(){const e=this._getDefaultRoot(),t=this.model,n=t.schema,r=t.createPositionFromPath(e,[0]);return n.getNearestSelectionRange(r)||t.createRange(r)}_validateSelectionRange(e){return e.start.isValid()&&e.end.isValid()&&In(e.start)&&In(e.end)}_callPostFixers(e){let t=!1;do for(const n of this._postFixers)if(this.selection.refresh(),t=n(e),t)break;while(t)}}function In(s){const e=s.textNode;if(e){const t=e.data,n=s.offset-e.startOffset;return!Wn(t,n)&&!qn(t,n)}return!0}class $o extends N(){_markers=new Map;[Symbol.iterator](){return this._markers.values()}has(e){const t=e instanceof Ae?e.name:e;return this._markers.has(t)}get(e){return this._markers.get(e)||null}_set(e,t,n=!1,r=!1){const i=e instanceof Ae?e.name:e;if(i.includes(","))throw new f("markercollection-incorrect-marker-name",this);const o=this._markers.get(i);if(o){const c=o.getData(),h=o.getRange();let d=!1;return h.isEqual(t)||(o._attachLiveRange(_e.fromRange(t)),d=!0),n!=o.managedUsingOperations&&(o._managedUsingOperations=n,d=!0),typeof r=="boolean"&&r!=o.affectsData&&(o._affectsData=r,d=!0),d&&this.fire(`update:${i}`,o,h,t,c),o}const a=_e.fromRange(t),l=new Ae(i,a,n,r);return this._markers.set(i,l),this.fire(`update:${i}`,l,null,t,{...l.getData(),range:null}),l}_remove(e){const t=e instanceof Ae?e.name:e,n=this._markers.get(t);return n?(this._markers.delete(t),this.fire(`update:${t}`,n,n.getRange(),null,n.getData()),this._destroyMarker(n),!0):!1}_refresh(e){const t=e instanceof Ae?e.name:e,n=this._markers.get(t);if(!n)throw new f("markercollection-refresh-marker-not-exists",this);const r=n.getRange();this.fire(`update:${t}`,n,r,r,n.getData())}*getMarkersAtPosition(e){for(const t of this)t.getRange().containsPosition(e)&&(yield t)}*getMarkersIntersectingRange(e){for(const t of this)t.getRange().getIntersection(e)!==null&&(yield t)}destroy(){for(const e of this._markers.values())this._destroyMarker(e);this._markers=null,this.stopListening()}*getMarkersGroup(e){for(const t of this._markers.values())t.name.startsWith(e+":")&&(yield t)}_destroyMarker(e){e.stopListening(),e._detachLiveRange()}}class Ae extends N(he){name;_managedUsingOperations;_affectsData;_liveRange;constructor(e,t,n,r){super(),this.name=e,this._liveRange=this._attachLiveRange(t),this._managedUsingOperations=n,this._affectsData=r}get managedUsingOperations(){if(!this._liveRange)throw new f("marker-destroyed",this);return this._managedUsingOperations}get affectsData(){if(!this._liveRange)throw new f("marker-destroyed",this);return this._affectsData}getData(){return{range:this.getRange(),affectsData:this.affectsData,managedUsingOperations:this.managedUsingOperations}}getStart(){if(!this._liveRange)throw new f("marker-destroyed",this);return this._liveRange.start.clone()}getEnd(){if(!this._liveRange)throw new f("marker-destroyed",this);return this._liveRange.end.clone()}getRange(){if(!this._liveRange)throw new f("marker-destroyed",this);return this._liveRange.toRange()}_attachLiveRange(e){return this._liveRange&&this._detachLiveRange(),e.delegate("change:range").to(this),e.delegate("change:content").to(this),this._liveRange=e,e}_detachLiveRange(){this._liveRange.stopDelegating("change:range",this),this._liveRange.stopDelegating("change:content",this),this._liveRange.detach(),this._liveRange=null}}Ae.prototype.is=function(s){return s==="marker"||s==="model:marker"};class Lo extends q{sourcePosition;howMany;constructor(e,t){super(null),this.sourcePosition=e.clone(),this.howMany=t}get type(){return"detach"}get affectedSelectable(){return null}toJSON(){const e=super.toJSON();return e.sourcePosition=this.sourcePosition.toJSON(),e}_validate(){if(this.sourcePosition.root.document)throw new f("detach-operation-on-document-node",this)}_execute(){As(u._createFromPositionAndShift(this.sourcePosition,this.howMany))}static get className(){return"DetachOperation"}}class K extends he{markers=new Map;_children=new ze;constructor(e){super(),e&&this._insertChild(0,e)}[Symbol.iterator](){return this.getChildren()}get childCount(){return this._children.length}get maxOffset(){return this._children.maxOffset}get isEmpty(){return this.childCount===0}get nextSibling(){return null}get previousSibling(){return null}get root(){return this}get parent(){return null}get document(){return null}isAttached(){return!1}getAncestors(){return[]}getChild(e){return this._children.getNode(e)}getChildAtOffset(e){return this._children.getNodeAtOffset(e)}getChildren(){return this._children[Symbol.iterator]()}getChildIndex(e){return this._children.getNodeIndex(e)}getChildStartOffset(e){return this._children.getNodeStartOffset(e)}getPath(){return[]}getNodeByPath(e){let t=this;for(const n of e)t=t.getChildAtOffset(n);return t}offsetToIndex(e){return this._children.offsetToIndex(e)}toJSON(){const e=[];for(const t of this._children)e.push(t.toJSON());return e}static fromJSON(e){const t=[];for(const n of e)n.name?t.push(C.fromJSON(n)):t.push(k.fromJSON(n));return new K(t)}_appendChild(e){this._insertChild(this.childCount,e)}_insertChild(e,t){const n=Wo(t);for(const r of n)r.parent!==null&&r._remove(),r.parent=this;this._children._insertNodes(e,n)}_removeChildren(e,t=1){const n=this._children._removeNodes(e,t);for(const r of n)r.parent=null;return n}_removeChildrenArray(e){this._children._removeNodesArray(e);for(const t of e)t.parent=null}}K.prototype.is=function(s){return s==="documentFragment"||s==="model:documentFragment"};function Wo(s){return typeof s=="string"?[new k(s)]:(le(s)||(s=[s]),Array.from(s).map(e=>typeof e=="string"?new k(e):e instanceof j?new k(e.data,e.getAttributes()):e))}class qo{model;batch;constructor(e,t){this.model=e,this.batch=t}createText(e,t){return new k(e,t)}createElement(e,t){return new C(e,t)}createDocumentFragment(){return new K}cloneElement(e,t=!0){return e._clone(t)}insert(e,t,n=0){if(this._assertWriterUsedCorrectly(),e instanceof k&&e.data=="")return;const r=m._createAt(t,n);if(e.parent)if(Bn(e.root,r.root)){this.move(u._createOn(e),r);return}else{if(e.root.document)throw new f("model-writer-insert-forbidden-move",this);this.remove(e)}const i=r.root.document?r.root.document.version:null,o=e instanceof K?e._removeChildren(0,e.childCount):e,a=new T(r,o,i);if(e instanceof k&&(a.shouldReceiveAttributes=!0),this.batch.addOperation(a),this.model.applyOperation(a),e instanceof K)for(const[l,c]of e.markers){const h=m._createAt(c.root,0),p={range:new u(c.start._getCombined(h,r),c.end._getCombined(h,r)),usingOperation:!0,affectsData:!0};this.model.markers.has(l)?this.updateMarker(l,p):this.addMarker(l,p)}}insertText(e,t,n,r){t instanceof K||t instanceof C||t instanceof m?this.insert(this.createText(e),t,n):this.insert(this.createText(e,t),n,r)}insertElement(e,t,n,r){t instanceof K||t instanceof C||t instanceof m?this.insert(this.createElement(e),t,n):this.insert(this.createElement(e,t),n,r)}append(e,t){this.insert(e,t,"end")}appendText(e,t,n){t instanceof K||t instanceof C?this.insert(this.createText(e),t,"end"):this.insert(this.createText(e,t),n,"end")}appendElement(e,t,n){t instanceof K||t instanceof C?this.insert(this.createElement(e),t,"end"):this.insert(this.createElement(e,t),n,"end")}setAttribute(e,t,n){if(this._assertWriterUsedCorrectly(),n instanceof u){const r=n.getMinimalFlatRanges();for(const i of r)Fn(this,e,t,i)}else Dn(this,e,t,n)}setAttributes(e,t){for(const[n,r]of pe(e))this.setAttribute(n,r,t)}removeAttribute(e,t){if(this._assertWriterUsedCorrectly(),t instanceof u){const n=t.getMinimalFlatRanges();for(const r of n)Fn(this,e,null,r)}else Dn(this,e,null,t)}clearAttributes(e){this._assertWriterUsedCorrectly();const t=n=>{for(const r of n.getAttributeKeys())this.removeAttribute(r,n)};if(!(e instanceof u))t(e);else for(const n of e.getItems())t(n)}move(e,t,n){if(this._assertWriterUsedCorrectly(),!(e instanceof u))throw new f("writer-move-invalid-range",this);if(!e.isFlat)throw new f("writer-move-range-not-flat",this);const r=m._createAt(t,n);if(r.isEqual(e.start))return;if(this._addOperationForAffectedMarkers("move",e),!Bn(e.root,r.root))throw new f("writer-move-different-document",this);const i=e.root.document?e.root.document.version:null,o=new v(e.start,e.end.offset-e.start.offset,r,i);this.batch.addOperation(o),this.model.applyOperation(o)}remove(e){this._assertWriterUsedCorrectly();const n=(e instanceof u?e:u._createOn(e)).getMinimalFlatRanges().reverse();for(const r of n)this._addOperationForAffectedMarkers("move",r),zo(r.start,r.end.offset-r.start.offset,this.batch,this.model)}merge(e){this._assertWriterUsedCorrectly();const t=e.nodeBefore,n=e.nodeAfter;if(this._addOperationForAffectedMarkers("merge",e),!(t instanceof C))throw new f("writer-merge-no-element-before",this);if(!(n instanceof C))throw new f("writer-merge-no-element-after",this);e.root.document?this._merge(e):this._mergeDetached(e)}createPositionFromPath(e,t,n){return this.model.createPositionFromPath(e,t,n)}createPositionAt(e,t){return this.model.createPositionAt(e,t)}createPositionAfter(e){return this.model.createPositionAfter(e)}createPositionBefore(e){return this.model.createPositionBefore(e)}createRange(e,t){return this.model.createRange(e,t)}createRangeIn(e){return this.model.createRangeIn(e)}createRangeOn(e){return this.model.createRangeOn(e)}createSelection(...e){return this.model.createSelection(...e)}_mergeDetached(e){const t=e.nodeBefore,n=e.nodeAfter;this.move(u._createIn(n),m._createAt(t,"end")),this.remove(n)}_merge(e){const t=m._createAt(e.nodeBefore,"end"),n=m._createAt(e.nodeAfter,0),r=e.root.document.graveyard,i=new m(r,[0]),o=e.root.document.version,a=new A(n,e.nodeAfter.maxOffset,t,i,o);this.batch.addOperation(a),this.model.applyOperation(a)}rename(e,t){if(this._assertWriterUsedCorrectly(),!(e instanceof C))throw new f("writer-rename-not-element-instance",this);const n=e.root.document?e.root.document.version:null,r=new V(m._createBefore(e),e.name,t,n);this.batch.addOperation(r),this.model.applyOperation(r)}split(e,t){this._assertWriterUsedCorrectly();let n=e.parent;if(!n.parent)throw new f("writer-split-element-no-parent",this);if(t||(t=n.parent),!e.parent.getAncestors({includeSelf:!0}).includes(t))throw new f("writer-split-invalid-limit-element",this);let r,i;do{const o=n.root.document?n.root.document.version:null,a=n.maxOffset-e.offset,l=P.getInsertionPosition(e),c=new P(e,a,l,null,o);this.batch.addOperation(c),this.model.applyOperation(c),!r&&!i&&(r=n,i=e.parent.nextSibling),e=this.createPositionAfter(e.parent),n=e.parent}while(n!==t);return{position:e,range:new u(m._createAt(r,"end"),m._createAt(i,0))}}wrap(e,t){if(this._assertWriterUsedCorrectly(),!e.isFlat)throw new f("writer-wrap-range-not-flat",this);const n=t instanceof C?t:new C(t);if(n.childCount>0)throw new f("writer-wrap-element-not-empty",this);if(n.parent!==null)throw new f("writer-wrap-element-attached",this);this.insert(n,e.start);const r=new u(e.start.getShiftedBy(1),e.end.getShiftedBy(1));this.move(r,m._createAt(n,0))}unwrap(e){if(this._assertWriterUsedCorrectly(),e.parent===null)throw new f("writer-unwrap-element-no-parent",this);this.move(u._createIn(e),this.createPositionAfter(e)),this.remove(e)}addMarker(e,t){if(this._assertWriterUsedCorrectly(),!t||typeof t.usingOperation!="boolean")throw new f("writer-addmarker-no-usingoperation",this);const n=t.usingOperation,r=t.range,i=t.affectsData===void 0?!1:t.affectsData;if(this.model.markers.has(e))throw new f("writer-addmarker-marker-exists",this);if(!r)throw new f("writer-addmarker-no-range",this);return n?(Be(this,e,null,r,i),this.model.markers.get(e)):this.model.markers._set(e,r,n,i)}updateMarker(e,t){this._assertWriterUsedCorrectly();const n=typeof e=="string"?e:e.name,r=this.model.markers.get(n);if(!r)throw new f("writer-updatemarker-marker-not-exists",this);if(!t){W("writer-updatemarker-reconvert-using-editingcontroller",{markerName:n}),this.model.markers._refresh(r);return}const i=typeof t.usingOperation=="boolean",o=typeof t.affectsData=="boolean",a=o?t.affectsData:r.affectsData;if(!i&&!t.range&&!o)throw new f("writer-updatemarker-wrong-options",this);const l=r.getRange(),c=t.range?t.range:l;if(i&&t.usingOperation!==r.managedUsingOperations){t.usingOperation?Be(this,n,null,c,a):(Be(this,n,l,null,a),this.model.markers._set(n,c,void 0,a));return}r.managedUsingOperations?Be(this,n,l,c,a):this.model.markers._set(n,c,void 0,a)}removeMarker(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?e:e.name;if(!this.model.markers.has(t))throw new f("writer-removemarker-no-marker",this);const n=this.model.markers.get(t);if(!n.managedUsingOperations){this.model.markers._remove(t);return}const r=n.getRange();Be(this,t,r,null,n.affectsData)}addRoot(e,t="$root"){this._assertWriterUsedCorrectly();const n=this.model.document.getRoot(e);if(n&&n.isAttached())throw new f("writer-addroot-root-exists",this);const r=this.model.document,i=new X(e,t,!0,r,r.version);return this.batch.addOperation(i),this.model.applyOperation(i),this.model.document.getRoot(e)}detachRoot(e){this._assertWriterUsedCorrectly();const t=typeof e=="string"?this.model.document.getRoot(e):e;if(!t||!t.isAttached())throw new f("writer-detachroot-no-root",this);for(const i of this.model.markers)i.getRange().root===t&&this.removeMarker(i);for(const i of t.getAttributeKeys())this.removeAttribute(i,t);this.remove(this.createRangeIn(t));const n=this.model.document,r=new X(t.rootName,t.name,!1,n,n.version);this.batch.addOperation(r),this.model.applyOperation(r)}setSelection(...e){this._assertWriterUsedCorrectly(),this.model.document.selection._setTo(...e)}setSelectionFocus(e,t){this._assertWriterUsedCorrectly(),this.model.document.selection._setFocus(e,t)}setSelectionAttribute(e,t){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._setSelectionAttribute(e,t);else for(const[n,r]of pe(e))this._setSelectionAttribute(n,r)}removeSelectionAttribute(e){if(this._assertWriterUsedCorrectly(),typeof e=="string")this._removeSelectionAttribute(e);else for(const t of e)this._removeSelectionAttribute(t)}overrideSelectionGravity(){return this.model.document.selection._overrideGravity()}restoreSelectionGravity(e){this.model.document.selection._restoreGravity(e)}_setSelectionAttribute(e,t){const n=this.model.document.selection;if(n.isCollapsed&&n.anchor.parent.isEmpty){const r=G._getStoreAttributeKey(e);this.setAttribute(r,t,n.anchor.parent)}n._setAttribute(e,t)}_removeSelectionAttribute(e){const t=this.model.document.selection;if(t.isCollapsed&&t.anchor.parent.isEmpty){const n=G._getStoreAttributeKey(e);this.removeAttribute(n,t.anchor.parent)}t._removeAttribute(e)}_assertWriterUsedCorrectly(){if(this.model._currentWriter!==this)throw new f("writer-incorrect-use",this)}_addOperationForAffectedMarkers(e,t){for(const n of this.model.markers){if(!n.managedUsingOperations)continue;const r=n.getRange();let i=!1;if(e==="move"){const o=t;i=o.containsPosition(r.start)||o.start.isEqual(r.start)||o.containsPosition(r.end)||o.end.isEqual(r.end)}else{const o=t,a=o.nodeBefore,l=o.nodeAfter,c=r.start.parent==a&&r.start.isAtEnd,h=r.end.parent==l&&r.end.offset==0,d=r.end.nodeAfter==l,p=r.start.nodeAfter==l;i=c||h||d||p}i&&this.updateMarker(n.name,{range:r})}}}function Fn(s,e,t,n){const r=s.model,i=r.document;let o=n.start,a,l,c;for(const d of n.getWalker({shallow:!0}))c=d.item.getAttribute(e),a&&l!=c&&(l!=t&&h(),o=a),a=d.nextPosition,l=c;a instanceof m&&a!=o&&l!=t&&h();function h(){const d=new u(o,a),p=d.root.document?i.version:null,_=new S(d,e,l,t,p);s.batch.addOperation(_),r.applyOperation(_)}}function Dn(s,e,t,n){const r=s.model,i=r.document,o=n.getAttribute(e);let a,l;if(o!=t){if(n.root===n){const h=n.document?i.version:null;l=new ee(n,e,o,t,h)}else{a=new u(m._createBefore(n),s.createPositionAfter(n));const h=a.root.document?i.version:null;l=new S(a,e,o,t,h)}s.batch.addOperation(l),r.applyOperation(l)}}function Be(s,e,t,n,r){const i=s.model,o=i.document,a=new B(e,t,n,i.markers,!!r,o.version);s.batch.addOperation(a),i.applyOperation(a)}function zo(s,e,t,n){let r;if(s.root.document){const i=n.document,o=new m(i.graveyard,[0]);r=new v(s,e,o,i.version)}else r=new Lo(s,e);t.addOperation(r),n.applyOperation(r)}function Bn(s,e){return s===e||s instanceof ft&&e instanceof ft}function Uo(s){s.document.registerPostFixer(e=>Jo(e,s))}function Jo(s,e){const t=e.document.selection,n=e.schema,r=[];let i=!1;for(const o of t.getRanges()){const a=jo(o,n);a&&!a.isEqual(o)?(r.push(a),i=!0):r.push(o)}return i&&s.setSelection(Xo(r),{backward:t.isBackward}),!1}function jo(s,e){return s.isCollapsed?Go(s,e):Ho(s,e)}function Go(s,e){const t=s.start,n=e.getNearestSelectionRange(t);if(!n){const i=t.getAncestors().reverse().find(o=>e.isObject(o));return i?u._createOn(i):null}if(!n.isCollapsed)return n;const r=n.start;return t.isEqual(r)?null:new u(r)}function Ho(s,e){const{start:t,end:n}=s,r=e.checkChild(t,"$text"),i=e.checkChild(n,"$text"),o=e.getLimitElement(t),a=e.getLimitElement(n);if(o===a){if(r&&i)return null;if(Ko(t,n,e)){const d=t.nodeAfter&&e.isSelectable(t.nodeAfter)?null:e.getNearestSelectionRange(t,"forward"),_=n.nodeBefore&&e.isSelectable(n.nodeBefore)?null:e.getNearestSelectionRange(n,"backward"),y=d?d.start:t,I=_?_.end:n;return new u(y,I)}}const l=o&&!o.is("rootElement"),c=a&&!a.is("rootElement");if(l||c){const h=t.nodeAfter&&n.nodeBefore&&t.nodeAfter.parent===n.nodeBefore.parent,d=l&&(!h||!$n(t.nodeAfter,e)),p=c&&(!h||!$n(n.nodeBefore,e));let _=t,y=n;return d&&(_=m._createBefore(Vn(o,e))),p&&(y=m._createAfter(Vn(a,e))),new u(_,y)}return null}function Vn(s,e){let t=s,n=t;for(;e.isLimit(n)&&n.parent;)t=n,n=n.parent;return t}function Ko(s,e,t){const n=s.nodeAfter&&!t.isLimit(s.nodeAfter)||t.checkChild(s,"$text"),r=e.nodeBefore&&!t.isLimit(e.nodeBefore)||t.checkChild(e,"$text");return n||r}function Xo(s){const e=[...s],t=new Set;let n=1;for(;n<e.length;){const i=e[n],o=e.slice(0,n);for(const[a,l]of o.entries())if(!t.has(a)){if(i.isEqual(l))t.add(a);else if(i.isIntersecting(l)){t.add(a),t.add(n);const c=i.getJoined(l);e.push(c)}}n++}return e.filter((i,o)=>!t.has(o))}function $n(s,e){return s&&e.isSelectable(s)}function Yo(s,e,t={}){if(e.isCollapsed)return;const n=e.getFirstRange();if(n.root.rootName=="$graveyard")return;const r=s.schema;s.change(i=>{if(!t.doNotResetEntireContent&&oa(r,e)){ia(i,e);return}const o={};if(!t.doNotAutoparagraph){const c=e.getSelectedElement();c&&Object.assign(o,r.getAttributesWithProperty(c,"copyOnReplace",!0))}let a,l;t.doNotFixSelection?(a=O.fromPosition(n.start,"toPrevious"),l=O.fromPosition(n.end,"toNext")):[a,l]=Qo(n),a.isTouching(l)||i.remove(i.createRange(a,l)),t.leaveUnmerged||(ea(i,a,l),r.removeDisallowedAttributes(a.parent.getChildren(),i)),Ns(i,e,a),!t.doNotAutoparagraph&&sa(r,a)&&xs(i,a,e,o),a.detach(),l.detach()})}function Qo(s){const e=s.root.document.model,t=s.start;let n=s.end;if(e.hasContent(s,{ignoreMarkers:!0})){const r=Zo(n);if(r&&n.isTouching(e.createPositionAt(r,0))){const i=e.createSelection(s);e.modifySelection(i,{direction:"backward"});const o=i.getLastPosition(),a=e.createRange(o,n);e.hasContent(a,{ignoreMarkers:!0})||(n=o)}}return[O.fromPosition(t,"toPrevious"),O.fromPosition(n,"toNext")]}function Zo(s){const e=s.parent,t=e.root.document.model.schema,n=e.getAncestors({parentFirst:!0,includeSelf:!0});for(const r of n){if(t.isLimit(r))return null;if(t.isBlock(r))return r}}function ea(s,e,t){const n=s.model;if(!Yt(s.model.schema,e,t))return;const[r,i]=na(e,t);!r||!i||(!n.hasContent(r,{ignoreMarkers:!0})&&n.hasContent(i,{ignoreMarkers:!0})?Ms(s,e,t,r.parent):Ts(s,e,t,r.parent))}function Ts(s,e,t,n){const r=e.parent,i=t.parent;if(!(r==n||i==n)){for(e=s.createPositionAfter(r),t=s.createPositionBefore(i),t.isEqual(e)||s.insert(i,e),s.merge(e);t.parent.isEmpty;){const o=t.parent;t=s.createPositionBefore(o),s.remove(o)}Yt(s.model.schema,e,t)&&Ts(s,e,t,n)}}function Ms(s,e,t,n){const r=e.parent,i=t.parent;if(!(r==n||i==n)){for(e=s.createPositionAfter(r),t=s.createPositionBefore(i),t.isEqual(e)||s.insert(r,t);e.parent.isEmpty;){const o=e.parent;e=s.createPositionBefore(o),s.remove(o)}t=s.createPositionBefore(i),ta(s,t),Yt(s.model.schema,e,t)&&Ms(s,e,t,n)}}function ta(s,e){const t=e.nodeBefore,n=e.nodeAfter;t.name!=n.name&&s.rename(t,n.name),s.clearAttributes(t),s.setAttributes(Object.fromEntries(n.getAttributes()),t),s.merge(e)}function Yt(s,e,t){const n=e.parent,r=t.parent;return n==r||s.isLimit(n)||s.isLimit(r)?!1:ra(e,t,s)}function na(s,e){const t=s.getAncestors(),n=e.getAncestors();let r=0;for(;t[r]&&t[r]==n[r];)r++;return[t[r],n[r]]}function sa(s,e){const t=s.checkChild(e,"$text"),n=s.checkChild(e,"paragraph");return!t&&n}function ra(s,e,t){const n=new u(s,e);for(const r of n.getWalker())if(t.isLimit(r.item))return!1;return!0}function xs(s,e,t,n={}){const r=s.createElement("paragraph");s.model.schema.setAllowedAttributes(r,n,s),s.insert(r,e),Ns(s,t,s.createPositionAt(r,0))}function ia(s,e){const t=s.model.schema.getLimitElement(e);s.remove(s.createRangeIn(t)),xs(s,s.createPositionAt(t,0),e)}function oa(s,e){const t=s.getLimitElement(e);if(!e.containsEntireContent(t))return!1;const n=e.getFirstRange();return n.start.parent==n.end.parent?!1:s.checkChild(t,"paragraph")}function Ns(s,e,t){e instanceof G?s.setSelection(t):e.setTo(t)}/**
25
25
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
26
26
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
27
- */function ua(r,t){return r.change(e=>{const n=e.createDocumentFragment(),s=t.getFirstRange();if(!s||s.isCollapsed)return n;const i=s.start.root,o=s.start.getCommonPath(s.end),a=i.getNodeByPath(o);let l;s.start.parent==s.end.parent?l=s:l=e.createRange(e.createPositionAt(a,s.start.path[o.length]),e.createPositionAt(a,s.end.path[o.length]+1));const h=l.end.offset-l.start.offset;for(const u of l.getItems({shallow:!0}))u.is("$textProxy")?e.appendText(u.data,u.getAttributes(),n):e.append(e.cloneElement(u,!0),n);if(l!=s){const u=s._getTransformedByMove(l.start,e.createPositionAt(n,0),h)[0],m=e.createRange(e.createPositionAt(n,0),u.start),p=e.createRange(u.end,e.createPositionAt(n,"end"));qn(p,e),qn(m,e)}return n})}function qn(r,t){const e=[];Array.from(r.getItems({direction:"backward"})).map(n=>t.createRangeOn(n)).filter(n=>(n.start.isAfter(r.start)||n.start.isEqual(r.start))&&(n.end.isBefore(r.end)||n.end.isEqual(r.end))).forEach(n=>{e.push(n.start.parent),t.remove(n)}),e.forEach(n=>{let s=n;for(;s.parent&&s.isEmpty;){const i=t.createRangeOn(s);s=s.parent,t.remove(i)}})}function fa(r,t,e){return r.change(n=>{const s=e||r.document.selection;s.isCollapsed||r.deleteContent(s,{doNotAutoparagraph:!0});const i=new da(r,n,s.anchor),o=[];let a;if(t.is("documentFragment")){if(t.markers.size){const u=[];for(const[m,p]of t.markers){const{start:w,end:y}=p,F=w.isEqual(y);u.push({position:w,name:m,isCollapsed:F},{position:y,name:m,isCollapsed:F})}u.sort(({position:m},{position:p})=>m.isBefore(p)?1:-1);for(const{position:m,name:p,isCollapsed:w}of u){let y=null,F=null;const fe=m.parent===t&&m.isAtStart,se=m.parent===t&&m.isAtEnd;!fe&&!se?(y=n.createElement("$marker"),n.insert(y,m)):w&&(F=fe?"start":"end"),o.push({name:p,element:y,collapsed:F})}}a=t.getChildren()}else a=[t];i.handleNodes(a);let l=i.getSelectionRange();if(t.is("documentFragment")&&o.length){const u=l?be.fromRange(l):null,m={};for(let p=o.length-1;p>=0;p--){const{name:w,element:y,collapsed:F}=o[p],fe=!m[w];if(fe&&(m[w]=[]),y){const se=n.createPositionAt(y,"before");m[w].push(se),n.remove(y)}else{const se=i.getAffectedRange();if(!se){F&&m[w].push(i.position);continue}F?m[w].push(se[F]):m[w].push(fe?se.start:se.end)}}for(const[p,[w,y]]of Object.entries(m))w&&y&&w.root===y.root&&w.root.document&&!n.model.markers.has(p)&&n.addMarker(p,{usingOperation:!0,affectsData:!0,range:new f(w,y)});u&&(l=u.toRange(),u.detach())}/* istanbul ignore else -- @preserve */l&&(s instanceof H?n.setSelection(l):s.setTo(l));const h=i.getAffectedRange()||r.createRange(s.anchor);return i.destroy(),h})}class da{constructor(t,e,n){c(this,"model");c(this,"writer");c(this,"position");c(this,"canMergeWith");c(this,"schema");c(this,"_documentFragment");c(this,"_documentFragmentPosition");c(this,"_firstNode",null);c(this,"_lastNode",null);c(this,"_lastAutoParagraph",null);c(this,"_filterAttributesOf",[]);c(this,"_affectedStart",null);c(this,"_affectedEnd",null);c(this,"_nodeToSelect",null);this.model=t,this.writer=e,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=t.schema,this._documentFragment=e.createDocumentFragment(),this._documentFragmentPosition=e.createPositionAt(this._documentFragment,0)}handleNodes(t){for(const e of Array.from(t))this._handleNode(e);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(t){const e=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(t);if(n.isAfter(e)){this._lastNode=t;/* istanbul ignore if -- @preserve */if(this.position.parent!=t||!this.position.isAtEnd)throw new d("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?f._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new f(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(t){if(!this._checkAndSplitToAllowedPosition(t)){this.schema.isObject(t)||this._handleDisallowedNode(t);return}this._appendToFragment(t),this._firstNode||(this._firstNode=t),this._lastNode=t}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const t=I.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=t.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=t.toPosition(),t.detach()}_handleDisallowedNode(t){t.is("element")&&this.handleNodes(t.getChildren())}_appendToFragment(t){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,t))throw new d("insertcontent-wrong-position",this,{node:t,position:this.position});this.writer.insert(t,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(t.offsetSize),this.schema.isObject(t)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=t:this._nodeToSelect=null,this._filterAttributesOf.push(t)}_setAffectedBoundaries(t){this._affectedStart||(this._affectedStart=I.fromPosition(t,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(t))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=I.fromPosition(t,"toNext"))}_mergeOnLeft(){const t=this._firstNode;if(!(t instanceof k)||!this._canMergeLeft(t))return;const e=I._createBefore(t);e.stickiness="toNext";const n=I.fromPosition(this.position,"toNext");this._affectedStart.isEqual(e)&&(this._affectedStart.detach(),this._affectedStart=I._createAt(e.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=I._createAt(e.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_mergeOnRight(){const t=this._lastNode;if(!(t instanceof k)||!this._canMergeRight(t))return;const e=I._createAfter(t);e.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(e))throw new d("insertcontent-invalid-insertion-position",this);this.position=g._createAt(e.nodeBefore,"end");const n=I.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(e)&&(this._affectedEnd.detach(),this._affectedEnd=I._createAt(e.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=e.nodeBefore,this._lastNode=e.nodeBefore),this.writer.merge(e),e.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=I._createAt(e.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),e.detach()}_canMergeLeft(t){const e=t.previousSibling;return e instanceof k&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(e,t)}_canMergeRight(t){const e=t.nextSibling;return e instanceof k&&this.canMergeWith.has(e)&&this.model.schema.checkMerge(t,e)}_insertAutoParagraph(){this._insertPartialFragment();const t=this.writer.createElement("paragraph");this.writer.insert(t,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=t,this.position=this.writer.createPositionAt(t,0)}_checkAndSplitToAllowedPosition(t){const e=this._getAllowedIn(this.position.parent,t);if(!e)return!1;for(e!=this.position.parent&&this._insertPartialFragment();e!=this.position.parent;)if(this.position.isAtStart){const n=this.position.parent;this.position=this.writer.createPositionBefore(n),n.isEmpty&&n.parent===e&&this.writer.remove(n)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const n=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=n,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,t)||this._insertAutoParagraph(),!0}_getAllowedIn(t,e){return this.schema.checkChild(t,e)||this.schema.checkChild(t,"paragraph")&&this.schema.checkChild("paragraph",e)?t:this.schema.isLimit(t)?null:this._getAllowedIn(t.parent,e)}}function ma(r,t,e,n={}){if(!r.schema.isObject(t))throw new d("insertobject-element-not-an-object",r,{object:t});const s=e||r.document.selection;let i=s;n.findOptimalPosition&&r.schema.isBlock(t)&&(i=r.createSelection(r.schema.findOptimalInsertionRange(s,n.findOptimalPosition)));const o=zt(s.getSelectedBlocks()),a={};return o&&Object.assign(a,r.schema.getAttributesWithProperty(o,"copyOnReplace",!0)),r.change(l=>{i.isCollapsed||r.deleteContent(i,{doNotAutoparagraph:!0});let h=t;const u=i.anchor.parent;!r.schema.checkChild(u,t)&&r.schema.checkChild(u,"paragraph")&&r.schema.checkChild("paragraph",t)&&(h=l.createElement("paragraph"),l.insert(t,h)),r.schema.setAllowedAttributes(h,a,l);const m=r.insertContent(h,i);return m.isCollapsed||n.setSelection&&ga(l,t,n.setSelection,a),m})}function ga(r,t,e,n){const s=r.model;if(e=="on"){r.setSelection(t,"on");return}if(e!="after")throw new d("insertobject-invalid-place-parameter-value",s);let i=t.nextSibling;if(s.schema.isInline(t)){r.setSelection(t,"after");return}!(i&&s.schema.checkChild(i,"$text"))&&s.schema.checkChild(t.parent,"paragraph")&&(i=r.createElement("paragraph"),s.schema.setAllowedAttributes(i,n,r),s.insertContent(i,r.createPositionAfter(t))),i&&r.setSelection(i,0)}const pa=' ,.?!:;"-()';function _a(r,t,e={}){const n=r.schema,s=e.direction!="backward",i=e.unit?e.unit:"character",o=!!e.treatEmojiAsSingleUnit,a=t.focus,l=new oe({boundaries:va(a,s),singleCharacters:!0,direction:s?"forward":"backward"}),h={walker:l,schema:n,isForward:s,unit:i,treatEmojiAsSingleUnit:o};let u;for(;u=l.next();){if(u.done)return;const m=wa(h,u.value);if(m){t instanceof H?r.change(p=>{p.setSelectionFocus(m)}):t.setFocus(m);return}}}function wa(r,t){const{isForward:e,walker:n,unit:s,schema:i,treatEmojiAsSingleUnit:o}=r,{type:a,item:l,nextPosition:h}=t;if(a=="text")return r.unit==="word"?ya(n,e):ba(n,s,o);if(a==(e?"elementStart":"elementEnd")){if(i.isSelectable(l))return g._createAt(l,e?"after":"before");if(i.checkChild(h,"$text"))return h}else{if(i.isLimit(l)){n.skip(()=>!0);return}if(i.checkChild(h,"$text"))return h}}function ba(r,t,e){const n=r.position.textNode;if(n){const s=n.data;let i=r.position.offset-n.startOffset;for(;zn(s,i)||t=="character"&&Un(s,i)||e&&js(s,i);)r.next(),i=r.position.offset-n.startOffset}return r.position}function ya(r,t){let e=r.position.textNode;for(e||(e=t?r.position.nodeAfter:r.position.nodeBefore);e&&e.is("$text");){const n=r.position.offset-e.startOffset;if(Ca(e,n,t))e=t?r.position.nodeAfter:r.position.nodeBefore;else{if(Pa(e.data,n,t))break;r.next()}}return r.position}function va(r,t){const e=r.root,n=g._createAt(e,t?"end":0);return t?new f(r,n):new f(n,r)}function Pa(r,t,e){const n=t+(e?0:-1);return pa.includes(r.charAt(n))}function Ca(r,t,e){return t===(e?r.offsetSize:0)}class Sl extends J(){constructor(){super();c(this,"markers");c(this,"document");c(this,"schema");c(this,"_pendingChanges");c(this,"_currentWriter");this.markers=new zo,this.document=new qo(this),this.schema=new ao,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,n)=>{n[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),Ho(this),this.document.registerPostFixer(vs),this.on("insertContent",(e,[n,s])=>{e.return=fa(this,n,s)}),this.on("insertObject",(e,[n,s,i])=>{e.return=ma(this,n,s,i)}),this.on("canEditAt",e=>{const n=!this.document.isReadOnly;e.return=n,n||e.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new Se,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(n){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(n,this)}}enqueueChange(e,n){try{e?typeof e=="function"?(n=e,e=new Se):e instanceof Se||(e=new Se(e)):e=new Se,this._pendingChanges.push({batch:e,callback:n}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(s){/* istanbul ignore next -- @preserve */d.rethrowUnexpectedError(s,this)}}applyOperation(e){e._execute()}insertContent(e,n,s,...i){const o=Et(n,s);return this.fire("insertContent",[e,o,s,...i])}insertObject(e,n,s,i,...o){const a=Et(n,s);return this.fire("insertObject",[e,a,i,i,...o])}deleteContent(e,n){ta(this,e,n)}modifySelection(e,n){_a(this,e,n)}getSelectedContent(e){return ua(this,e)}hasContent(e,n={}){const s=e instanceof f?e:f._createIn(e);if(s.isCollapsed)return!1;const{ignoreWhitespaces:i=!1,ignoreMarkers:o=!1}=n;if(!o){for(const a of this.markers.getMarkersIntersectingRange(s))if(a.affectsData)return!0}for(const a of s.getItems())if(this.schema.isContent(a))if(a.is("$textProxy"))if(i){if(a.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(e){const n=Et(e);return this.fire("canEditAt",[n])}createPositionFromPath(e,n,s){return new g(e,n,s)}createPositionAt(e,n){return g._createAt(e,n)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,n){return new f(e,n)}createRangeIn(e){return f._createIn(e)}createRangeOn(e){return f._createOn(e)}createSelection(...e){return new L(...e)}createBatch(e){return new Se(e)}createOperationFromJSON(e){return No.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const n=this._pendingChanges[0].batch;this._currentWriter=new jo(this,n);const s=this._pendingChanges[0].callback(this._currentWriter);e.push(s),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function Et(r,t){if(r)return r instanceof L||r instanceof H?r:r instanceof Ce?t||t===0?new L(r,t):r.is("rootElement")?new L(r,"in"):new L(r,"on"):new L(r)}class El extends Pe{constructor(){super(...arguments);c(this,"domEventType","click")}onDomEvent(e){this.fire(e.type,e)}}class Rl extends Pe{constructor(){super(...arguments);c(this,"domEventType",["mousedown","mouseup","mouseover","mouseout"])}onDomEvent(e){this.fire(e.type,e)}}class Tl extends Pe{constructor(){super(...arguments);c(this,"domEventType",["touchstart","touchend","touchmove"])}onDomEvent(e){this.fire(e.type,e)}}class Ml{constructor(t){c(this,"document");this.document=t}createDocumentFragment(t){return new _e(this.document,t)}createElement(t,e,n){return new ne(this.document,t,e,n)}createText(t){return new N(this.document,t)}clone(t,e=!1){return t._clone(e)}appendChild(t,e){return e._appendChild(t)}insertChild(t,e,n){return n._insertChild(t,e)}removeChildren(t,e,n){return n._removeChildren(t,e)}remove(t){const e=t.parent;return e?this.removeChildren(e.getChildIndex(t),1,e):[]}replace(t,e){const n=t.parent;if(n){const s=n.getChildIndex(t);return this.removeChildren(s,1,n),this.insertChild(s,e,n),!0}return!1}unwrapElement(t){const e=t.parent;if(e){const n=e.getChildIndex(t);this.remove(t),this.insertChild(n,t.getChildren(),e)}}rename(t,e){const n=new ne(this.document,t,e.getAttributes(),e.getChildren());return this.replace(e,n)?n:null}setAttribute(t,e,n){n._setAttribute(t,e)}removeAttribute(t,e){e._removeAttribute(t)}addClass(t,e){e._addClass(t)}removeClass(t,e){e._removeClass(t)}setStyle(t,e,n){Mt(t)&&n===void 0?e._setStyle(t):n._setStyle(t,e)}removeStyle(t,e){e._removeStyle(t)}setCustomProperty(t,e,n){n._setCustomProperty(t,e)}removeCustomProperty(t,e){return e._removeCustomProperty(t)}createPositionAt(t,e){return _._createAt(t,e)}createPositionAfter(t){return _._createAfter(t)}createPositionBefore(t){return _._createBefore(t)}createRange(t,e){return new b(t,e)}createRangeOn(t){return b._createOn(t)}createRangeIn(t){return b._createIn(t)}createSelection(...t){return new ee(...t)}}/**
27
+ */function aa(s,e){return s.change(t=>{const n=t.createDocumentFragment(),r=e.getFirstRange();if(!r||r.isCollapsed)return n;const i=r.start.root,o=r.start.getCommonPath(r.end),a=i.getNodeByPath(o);let l;r.start.parent==r.end.parent?l=r:l=t.createRange(t.createPositionAt(a,r.start.path[o.length]),t.createPositionAt(a,r.end.path[o.length]+1));const c=l.end.offset-l.start.offset;for(const h of l.getItems({shallow:!0}))h.is("$textProxy")?t.appendText(h.data,h.getAttributes(),n):t.append(t.cloneElement(h,!0),n);if(l!=r){const h=r._getTransformedByMove(l.start,t.createPositionAt(n,0),c)[0],d=t.createRange(t.createPositionAt(n,0),h.start),p=t.createRange(h.end,t.createPositionAt(n,"end"));Ln(p,t),Ln(d,t)}return n})}function Ln(s,e){const t=[];Array.from(s.getItems({direction:"backward"})).map(n=>e.createRangeOn(n)).filter(n=>(n.start.isAfter(s.start)||n.start.isEqual(s.start))&&(n.end.isBefore(s.end)||n.end.isEqual(s.end))).forEach(n=>{t.push(n.start.parent),e.remove(n)}),t.forEach(n=>{let r=n;for(;r.parent&&r.isEmpty;){const i=e.createRangeOn(r);r=r.parent,e.remove(i)}})}function la(s,e,t){return s.change(n=>{const r=t||s.document.selection;r.isCollapsed||s.deleteContent(r,{doNotAutoparagraph:!0});const i=new ca(s,n,r.anchor),o=[];let a;if(e.is("documentFragment")){if(e.markers.size){const h=[];for(const[d,p]of e.markers){const{start:_,end:y}=p,I=_.isEqual(y);h.push({position:_,name:d,isCollapsed:I},{position:y,name:d,isCollapsed:I})}h.sort(({position:d},{position:p})=>d.isBefore(p)?1:-1);for(const{position:d,name:p,isCollapsed:_}of h){let y=null,I=null;const ue=d.parent===e&&d.isAtStart,ne=d.parent===e&&d.isAtEnd;!ue&&!ne?(y=n.createElement("$marker"),n.insert(y,d)):_&&(I=ue?"start":"end"),o.push({name:p,element:y,collapsed:I})}}a=e.getChildren()}else a=[e];i.handleNodes(a);let l=i.getSelectionRange();if(e.is("documentFragment")&&o.length){const h=l?_e.fromRange(l):null,d={};for(let p=o.length-1;p>=0;p--){const{name:_,element:y,collapsed:I}=o[p],ue=!d[_];if(ue&&(d[_]=[]),y){const ne=n.createPositionAt(y,"before");d[_].push(ne),n.remove(y)}else{const ne=i.getAffectedRange();if(!ne){I&&d[_].push(i.position);continue}I?d[_].push(ne[I]):d[_].push(ue?ne.start:ne.end)}}for(const[p,[_,y]]of Object.entries(d))_&&y&&_.root===y.root&&_.root.document&&!n.model.markers.has(p)&&n.addMarker(p,{usingOperation:!0,affectsData:!0,range:new u(_,y)});h&&(l=h.toRange(),h.detach())}/* istanbul ignore else -- @preserve */l&&(r instanceof G?n.setSelection(l):r.setTo(l));const c=i.getAffectedRange()||s.createRange(r.anchor);return i.destroy(),c})}class ca{model;writer;position;canMergeWith;schema;_documentFragment;_documentFragmentPosition;_firstNode=null;_lastNode=null;_lastAutoParagraph=null;_filterAttributesOf=[];_affectedStart=null;_affectedEnd=null;_nodeToSelect=null;constructor(e,t,n){this.model=e,this.writer=t,this.position=n,this.canMergeWith=new Set([this.position.parent]),this.schema=e.schema,this._documentFragment=t.createDocumentFragment(),this._documentFragmentPosition=t.createPositionAt(this._documentFragment,0)}handleNodes(e){for(const t of Array.from(e))this._handleNode(t);this._insertPartialFragment(),this._lastAutoParagraph&&this._updateLastNodeFromAutoParagraph(this._lastAutoParagraph),this._mergeOnRight(),this.schema.removeDisallowedAttributes(this._filterAttributesOf,this.writer),this._filterAttributesOf=[]}_updateLastNodeFromAutoParagraph(e){const t=this.writer.createPositionAfter(this._lastNode),n=this.writer.createPositionAfter(e);if(n.isAfter(t)){this._lastNode=e;/* istanbul ignore if -- @preserve */if(this.position.parent!=e||!this.position.isAtEnd)throw new f("insertcontent-invalid-insertion-position",this);this.position=n,this._setAffectedBoundaries(this.position)}}getSelectionRange(){return this._nodeToSelect?u._createOn(this._nodeToSelect):this.model.schema.getNearestSelectionRange(this.position)}getAffectedRange(){return this._affectedStart?new u(this._affectedStart,this._affectedEnd):null}destroy(){this._affectedStart&&this._affectedStart.detach(),this._affectedEnd&&this._affectedEnd.detach()}_handleNode(e){if(!this._checkAndSplitToAllowedPosition(e)){this.schema.isObject(e)||this._handleDisallowedNode(e);return}this._appendToFragment(e),this._firstNode||(this._firstNode=e),this._lastNode=e}_insertPartialFragment(){if(this._documentFragment.isEmpty)return;const e=O.fromPosition(this.position,"toNext");this._setAffectedBoundaries(this.position),this._documentFragment.getChild(0)==this._firstNode&&(this.writer.insert(this._firstNode,this.position),this._mergeOnLeft(),this.position=e.toPosition()),this._documentFragment.isEmpty||this.writer.insert(this._documentFragment,this.position),this._documentFragmentPosition=this.writer.createPositionAt(this._documentFragment,0),this.position=e.toPosition(),e.detach()}_handleDisallowedNode(e){e.is("element")&&this.handleNodes(e.getChildren())}_appendToFragment(e){/* istanbul ignore if -- @preserve */if(!this.schema.checkChild(this.position,e))throw new f("insertcontent-wrong-position",this,{node:e,position:this.position});this.writer.insert(e,this._documentFragmentPosition),this._documentFragmentPosition=this._documentFragmentPosition.getShiftedBy(e.offsetSize),this.schema.isObject(e)&&!this.schema.checkChild(this.position,"$text")?this._nodeToSelect=e:this._nodeToSelect=null,this._filterAttributesOf.push(e)}_setAffectedBoundaries(e){this._affectedStart||(this._affectedStart=O.fromPosition(e,"toPrevious")),(!this._affectedEnd||this._affectedEnd.isBefore(e))&&(this._affectedEnd&&this._affectedEnd.detach(),this._affectedEnd=O.fromPosition(e,"toNext"))}_mergeOnLeft(){const e=this._firstNode;if(!(e instanceof C)||!this._canMergeLeft(e))return;const t=O._createBefore(e);t.stickiness="toNext";const n=O.fromPosition(this.position,"toNext");this._affectedStart.isEqual(t)&&(this._affectedStart.detach(),this._affectedStart=O._createAt(t.nodeBefore,"end","toPrevious")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.isEqual(this._affectedEnd)&&this._firstNode===this._lastNode&&(this._affectedEnd.detach(),this._affectedEnd=O._createAt(t.nodeBefore,"end","toNext")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_mergeOnRight(){const e=this._lastNode;if(!(e instanceof C)||!this._canMergeRight(e))return;const t=O._createAfter(e);t.stickiness="toNext";/* istanbul ignore if -- @preserve */if(!this.position.isEqual(t))throw new f("insertcontent-invalid-insertion-position",this);this.position=m._createAt(t.nodeBefore,"end");const n=O.fromPosition(this.position,"toPrevious");this._affectedEnd.isEqual(t)&&(this._affectedEnd.detach(),this._affectedEnd=O._createAt(t.nodeBefore,"end","toNext")),this._firstNode===this._lastNode&&(this._firstNode=t.nodeBefore,this._lastNode=t.nodeBefore),this.writer.merge(t),t.getShiftedBy(-1).isEqual(this._affectedStart)&&this._firstNode===this._lastNode&&(this._affectedStart.detach(),this._affectedStart=O._createAt(t.nodeBefore,0,"toPrevious")),this.position=n.toPosition(),n.detach(),this._filterAttributesOf.push(this.position.parent),t.detach()}_canMergeLeft(e){const t=e.previousSibling;return t instanceof C&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(t,e)}_canMergeRight(e){const t=e.nextSibling;return t instanceof C&&this.canMergeWith.has(t)&&this.model.schema.checkMerge(e,t)}_insertAutoParagraph(){this._insertPartialFragment();const e=this.writer.createElement("paragraph");this.writer.insert(e,this.position),this._setAffectedBoundaries(this.position),this._lastAutoParagraph=e,this.position=this.writer.createPositionAt(e,0)}_checkAndSplitToAllowedPosition(e){const t=this._getAllowedIn(this.position.parent,e);if(!t)return!1;for(t!=this.position.parent&&this._insertPartialFragment();t!=this.position.parent;)if(this.position.isAtStart){const n=this.position.parent;this.position=this.writer.createPositionBefore(n),n.isEmpty&&n.parent===t&&this.writer.remove(n)}else if(this.position.isAtEnd)this.position=this.writer.createPositionAfter(this.position.parent);else{const n=this.writer.createPositionAfter(this.position.parent);this._setAffectedBoundaries(this.position),this.writer.split(this.position),this.position=n,this.canMergeWith.add(this.position.nodeAfter)}return this.schema.checkChild(this.position.parent,e)||this._insertAutoParagraph(),!0}_getAllowedIn(e,t){return this.schema.checkChild(e,t)||this.schema.checkChild(e,"paragraph")&&this.schema.checkChild("paragraph",t)?e:this.schema.isLimit(e)?null:this._getAllowedIn(e.parent,t)}}function ha(s,e,t,n={}){if(!s.schema.isObject(e))throw new f("insertobject-element-not-an-object",s,{object:e});const r=t||s.document.selection;let i=r;n.findOptimalPosition&&s.schema.isBlock(e)&&(i=s.createSelection(s.schema.findOptimalInsertionRange(r,n.findOptimalPosition)));const o=Wt(r.getSelectedBlocks()),a={};return o&&Object.assign(a,s.schema.getAttributesWithProperty(o,"copyOnReplace",!0)),s.change(l=>{i.isCollapsed||s.deleteContent(i,{doNotAutoparagraph:!0});let c=e;const h=i.anchor.parent;!s.schema.checkChild(h,e)&&s.schema.checkChild(h,"paragraph")&&s.schema.checkChild("paragraph",e)&&(c=l.createElement("paragraph"),l.insert(e,c)),s.schema.setAllowedAttributes(c,a,l);const d=s.insertContent(c,i);return d.isCollapsed||n.setSelection&&ua(l,e,n.setSelection,a),d})}function ua(s,e,t,n){const r=s.model;if(t=="on"){s.setSelection(e,"on");return}if(t!="after")throw new f("insertobject-invalid-place-parameter-value",r);let i=e.nextSibling;if(r.schema.isInline(e)){s.setSelection(e,"after");return}!(i&&r.schema.checkChild(i,"$text"))&&r.schema.checkChild(e.parent,"paragraph")&&(i=s.createElement("paragraph"),r.schema.setAllowedAttributes(i,n,s),r.insertContent(i,s.createPositionAfter(e))),i&&s.setSelection(i,0)}const fa=' ,.?!:;"-()';function da(s,e,t={}){const n=s.schema,r=t.direction!="backward",i=t.unit?t.unit:"character",o=!!t.treatEmojiAsSingleUnit,a=e.focus,l=new ie({boundaries:_a(a,r),singleCharacters:!0,direction:r?"forward":"backward"}),c={walker:l,schema:n,isForward:r,unit:i,treatEmojiAsSingleUnit:o};let h;for(;h=l.next();){if(h.done)return;const d=ma(c,h.value);if(d){e instanceof G?s.change(p=>{p.setSelectionFocus(d)}):e.setFocus(d);return}}}function ma(s,e){const{isForward:t,walker:n,unit:r,schema:i,treatEmojiAsSingleUnit:o}=s,{type:a,item:l,nextPosition:c}=e;if(a=="text")return s.unit==="word"?pa(n,t):ga(n,r,o);if(a==(t?"elementStart":"elementEnd")){if(i.isSelectable(l))return m._createAt(l,t?"after":"before");if(i.checkChild(c,"$text"))return c}else{if(i.isLimit(l)){n.skip(()=>!0);return}if(i.checkChild(c,"$text"))return c}}function ga(s,e,t){const n=s.position.textNode;if(n){const r=n.data;let i=s.position.offset-n.startOffset;for(;Wn(r,i)||e=="character"&&qn(r,i)||t&&qs(r,i);)s.next(),i=s.position.offset-n.startOffset}return s.position}function pa(s,e){let t=s.position.textNode;for(t||(t=e?s.position.nodeAfter:s.position.nodeBefore);t&&t.is("$text");){const n=s.position.offset-t.startOffset;if(ba(t,n,e))t=e?s.position.nodeAfter:s.position.nodeBefore;else{if(wa(t.data,n,e))break;s.next()}}return s.position}function _a(s,e){const t=s.root,n=m._createAt(t,e?"end":0);return e?new u(s,n):new u(n,s)}function wa(s,e,t){const n=e+(t?0:-1);return fa.includes(s.charAt(n))}function ba(s,e,t){return e===(t?s.offsetSize:0)}class vl extends U(){markers;document;schema;_pendingChanges;_currentWriter;constructor(){super(),this.markers=new $o,this.document=new Vo(this),this.schema=new so,this._pendingChanges=[],this._currentWriter=null,["deleteContent","modifySelection","getSelectedContent","applyOperation"].forEach(e=>this.decorate(e)),this.on("applyOperation",(e,t)=>{t[0]._validate()},{priority:"highest"}),this.schema.register("$root",{isLimit:!0}),this.schema.register("$container",{allowIn:["$root","$container"]}),this.schema.register("$block",{allowIn:["$root","$container"],isBlock:!0}),this.schema.register("$blockObject",{allowWhere:"$block",isBlock:!0,isObject:!0}),this.schema.register("$inlineObject",{allowWhere:"$text",allowAttributesOf:"$text",isInline:!0,isObject:!0}),this.schema.register("$text",{allowIn:"$block",isInline:!0,isContent:!0}),this.schema.register("$clipboardHolder",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$documentFragment",{allowContentOf:"$root",allowChildren:"$text",isLimit:!0}),this.schema.register("$marker"),this.schema.addChildCheck(()=>!0,"$marker"),Uo(this),this.document.registerPostFixer(bs),this.on("insertContent",(e,[t,n])=>{e.return=la(this,t,n)}),this.on("insertObject",(e,[t,n,r])=>{e.return=ha(this,t,n,r)}),this.on("canEditAt",e=>{const t=!this.document.isReadOnly;e.return=t,t||e.stop()})}change(e){try{return this._pendingChanges.length===0?(this._pendingChanges.push({batch:new ke,callback:e}),this._runPendingChanges()[0]):e(this._currentWriter)}catch(t){/* istanbul ignore next -- @preserve */f.rethrowUnexpectedError(t,this)}}enqueueChange(e,t){try{e?typeof e=="function"?(t=e,e=new ke):e instanceof ke||(e=new ke(e)):e=new ke,this._pendingChanges.push({batch:e,callback:t}),this._pendingChanges.length==1&&this._runPendingChanges()}catch(n){/* istanbul ignore next -- @preserve */f.rethrowUnexpectedError(n,this)}}applyOperation(e){e._execute()}insertContent(e,t,n,...r){const i=St(t,n);return this.fire("insertContent",[e,i,n,...r])}insertObject(e,t,n,r,...i){const o=St(t,n);return this.fire("insertObject",[e,o,r,r,...i])}deleteContent(e,t){Yo(this,e,t)}modifySelection(e,t){da(this,e,t)}getSelectedContent(e){return aa(this,e)}hasContent(e,t={}){const n=e instanceof u?e:u._createIn(e);if(n.isCollapsed)return!1;const{ignoreWhitespaces:r=!1,ignoreMarkers:i=!1}=t;if(!i){for(const o of this.markers.getMarkersIntersectingRange(n))if(o.affectsData)return!0}for(const o of n.getItems())if(this.schema.isContent(o))if(o.is("$textProxy"))if(r){if(o.data.search(/\S/)!==-1)return!0}else return!0;else return!0;return!1}canEditAt(e){const t=St(e);return this.fire("canEditAt",[t])}createPositionFromPath(e,t,n){return new m(e,t,n)}createPositionAt(e,t){return m._createAt(e,t)}createPositionAfter(e){return m._createAfter(e)}createPositionBefore(e){return m._createBefore(e)}createRange(e,t){return new u(e,t)}createRangeIn(e){return u._createIn(e)}createRangeOn(e){return u._createOn(e)}createSelection(...e){return new $(...e)}createBatch(e){return new ke(e)}createOperationFromJSON(e){return Ro.fromJSON(e,this.document)}destroy(){this.document.destroy(),this.stopListening()}_runPendingChanges(){const e=[];this.fire("_beforeChanges");try{for(;this._pendingChanges.length;){const t=this._pendingChanges[0].batch;this._currentWriter=new qo(this,t);const n=this._pendingChanges[0].callback(this._currentWriter);e.push(n),this.document._handleChangeBlock(this._currentWriter),this._pendingChanges.shift(),this._currentWriter=null}}finally{this._pendingChanges.length=0,this._currentWriter=null,this.fire("_afterChanges")}return e}}function St(s,e){if(s)return s instanceof $||s instanceof G?s:s instanceof ve?e||e===0?new $(s,e):s.is("rootElement")?new $(s,"in"):new $(s,"on"):new $(s)}class Pl extends ye{domEventType="click";onDomEvent(e){this.fire(e.type,e)}}class Cl extends ye{domEventType=["mousedown","mouseup","mouseover","mouseout"];onDomEvent(e){this.fire(e.type,e)}}class kl extends ye{domEventType=["touchstart","touchend","touchmove"];onDomEvent(e){this.fire(e.type,e)}}class Al{document;constructor(e){this.document=e}createDocumentFragment(e){return new ge(this.document,e)}createElement(e,t,n){return new te(this.document,e,t,n)}createText(e){return new x(this.document,e)}clone(e,t=!1){return e._clone(t)}appendChild(e,t){return t._appendChild(e)}insertChild(e,t,n){return n._insertChild(e,t)}removeChildren(e,t,n){return n._removeChildren(e,t)}remove(e){const t=e.parent;return t?this.removeChildren(t.getChildIndex(e),1,t):[]}replace(e,t){const n=e.parent;if(n){const r=n.getChildIndex(e);return this.removeChildren(r,1,n),this.insertChild(r,t,n),!0}return!1}unwrapElement(e){const t=e.parent;if(t){const n=t.getChildIndex(e);this.remove(e),this.insertChild(n,e.getChildren(),t)}}rename(e,t){const n=new te(this.document,e,t.getAttributes(),t.getChildren());return this.replace(t,n)?n:null}setAttribute(e,t,n){n._setAttribute(e,t)}removeAttribute(e,t){t._removeAttribute(e)}addClass(e,t){t._addClass(e)}removeClass(e,t){t._removeClass(e)}setStyle(e,t,n){Tt(e)&&n===void 0?t._setStyle(e):n._setStyle(e,t)}removeStyle(e,t){t._removeStyle(e)}setCustomProperty(e,t,n){n._setCustomProperty(e,t)}removeCustomProperty(e,t){return t._removeCustomProperty(e)}createPositionAt(e,t){return g._createAt(e,t)}createPositionAfter(e){return g._createAfter(e)}createPositionBefore(e){return g._createBefore(e)}createRange(e,t){return new w(e,t)}createRangeOn(e){return w._createOn(e)}createRangeIn(e){return w._createIn(e)}createSelection(...e){return new Z(...e)}}/**
28
28
  * @license Copyright (c) 2003-2025, CKSource Holding sp. z o.o. All rights reserved.
29
29
  * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-licensing-options
30
- */const ka=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,Aa=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Sa=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ea=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,Ra=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ta=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Ma=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function xa(r){return r.startsWith("#")?ka.test(r):r.startsWith("rgb")?Aa.test(r)||Sa.test(r):r.startsWith("hsl")?Ea.test(r)||Ra.test(r):Ma.has(r.toLowerCase())}const Na=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Oa(r){return Na.includes(r)}const Ia=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function Fa(r){return Ia.test(r)}const Ba=/^[+-]?[0-9]*([.][0-9]+)?%$/;function xl(r){return Ba.test(r)}const Da=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Va(r){return Da.includes(r)}const $a=["center","top","bottom","left","right"];function La(r){return $a.includes(r)}const Wa=["fixed","scroll","local"];function qa(r){return Wa.includes(r)}const za=/^url\(/;function Ua(r){return za.test(r)}function Je(r=""){if(r==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const t=en(r),e=t[0],n=t[2]||e,s=t[1]||e,i=t[3]||s;return{top:e,bottom:n,right:s,left:i}}function je(r){return t=>{const{top:e,right:n,bottom:s,left:i}=t,o=[];return[e,n,i,s].every(a=>!!a)?o.push([r,Ja(t)]):(e&&o.push([r+"-top",e]),n&&o.push([r+"-right",n]),s&&o.push([r+"-bottom",s]),i&&o.push([r+"-left",i])),o}}function Ja({top:r,right:t,bottom:e,left:n}){const s=[];return n!==t?s.push(r,t,e,n):e!==r?s.push(r,t,e):t!==r?s.push(r,t):s.push(r),s.join(" ")}function Fs(r){return t=>({path:r,value:Je(t)})}function en(r){const t=r.trim().slice(0,1500).matchAll(Ta);return Array.from(t).map(e=>e[0])}function Nl(r){r.setNormalizer("background",ja()),r.setNormalizer("background-color",Ga()),r.setReducer("background",Ha()),r.setStyleRelation("background",["background-color"])}function ja(){return r=>{const t={},e=en(r);for(const n of e)Va(n)?(t.repeat=t.repeat||[],t.repeat.push(n)):La(n)?(t.position=t.position||[],t.position.push(n)):qa(n)?t.attachment=n:xa(n)?t.color=n:Ua(n)&&(t.image=n);return{path:"background",value:t}}}function Ga(){return r=>({path:"background.color",value:r})}function Ha(){return r=>{const t=[];return t.push(["background-color",r.color]),t}}function Ol(r){r.setNormalizer("border",Ka()),r.setNormalizer("border-top",it("top")),r.setNormalizer("border-right",it("right")),r.setNormalizer("border-bottom",it("bottom")),r.setNormalizer("border-left",it("left")),r.setNormalizer("border-color",Rt("color")),r.setNormalizer("border-width",Rt("width")),r.setNormalizer("border-style",Rt("style")),r.setNormalizer("border-top-color",U("color","top")),r.setNormalizer("border-top-style",U("style","top")),r.setNormalizer("border-top-width",U("width","top")),r.setNormalizer("border-right-color",U("color","right")),r.setNormalizer("border-right-style",U("style","right")),r.setNormalizer("border-right-width",U("width","right")),r.setNormalizer("border-bottom-color",U("color","bottom")),r.setNormalizer("border-bottom-style",U("style","bottom")),r.setNormalizer("border-bottom-width",U("width","bottom")),r.setNormalizer("border-left-color",U("color","left")),r.setNormalizer("border-left-style",U("style","left")),r.setNormalizer("border-left-width",U("width","left")),r.setExtractor("border-top",ot("top")),r.setExtractor("border-right",ot("right")),r.setExtractor("border-bottom",ot("bottom")),r.setExtractor("border-left",ot("left")),r.setExtractor("border-top-color","border.color.top"),r.setExtractor("border-right-color","border.color.right"),r.setExtractor("border-bottom-color","border.color.bottom"),r.setExtractor("border-left-color","border.color.left"),r.setExtractor("border-top-width","border.width.top"),r.setExtractor("border-right-width","border.width.right"),r.setExtractor("border-bottom-width","border.width.bottom"),r.setExtractor("border-left-width","border.width.left"),r.setExtractor("border-top-style","border.style.top"),r.setExtractor("border-right-style","border.style.right"),r.setExtractor("border-bottom-style","border.style.bottom"),r.setExtractor("border-left-style","border.style.left"),r.setReducer("border-color",je("border-color")),r.setReducer("border-style",je("border-style")),r.setReducer("border-width",je("border-width")),r.setReducer("border-top",at("top")),r.setReducer("border-right",at("right")),r.setReducer("border-bottom",at("bottom")),r.setReducer("border-left",at("left")),r.setReducer("border",Ya()),r.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),r.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),r.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),r.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),r.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),r.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),r.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),r.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Ka(){return r=>{const{color:t,style:e,width:n}=Bs(r);return{path:"border",value:{color:Je(t),style:Je(e),width:Je(n)}}}}function it(r){return t=>{const{color:e,style:n,width:s}=Bs(t),i={};return e!==void 0&&(i.color={[r]:e}),n!==void 0&&(i.style={[r]:n}),s!==void 0&&(i.width={[r]:s}),{path:"border",value:i}}}function Rt(r){return t=>({path:"border",value:Xa(t,r)})}function Xa(r,t){return{[t]:Je(r)}}function U(r,t){return e=>({path:"border",value:{[r]:{[t]:e}}})}function ot(r){return(t,e)=>{if(e.border)return Le(e.border,r)}}function Le(r,t){const e={};return r.width&&r.width[t]&&(e.width=r.width[t]),r.style&&r.style[t]&&(e.style=r.style[t]),r.color&&r.color[t]&&(e.color=r.color[t]),e}function Bs(r){const t={},e=en(r);for(const n of e)Fa(n)||/thin|medium|thick/.test(n)?t.width=n:Oa(n)?t.style=n:t.color=n;return t}function Ya(){return t=>{const e=Le(t,"top"),n=Le(t,"right"),s=Le(t,"bottom"),i=Le(t,"left"),o=[e,n,s,i],a={width:r(o,"width"),style:r(o,"style"),color:r(o,"color")},l=Re(a,"all");return l.length?l:[...Object.entries(a).reduce((u,[m,p])=>(p&&(u.push([`border-${m}`,p]),o.forEach(w=>delete w[m])),u),[]),...Re(e,"top"),...Re(n,"right"),...Re(s,"bottom"),...Re(i,"left")]};function r(t,e){return t.map(n=>n[e]).reduce((n,s)=>n==s?n:null)}}function at(r){return t=>Re(t,r)}function Re(r,t){const e=[];if(r&&r.width&&e.push("width"),r&&r.style&&e.push("style"),r&&r.color&&e.push("color"),e.length==3){const n=e.map(s=>r[s]).join(" ");return[t=="all"?["border",n]:[`border-${t}`,n]]}return t=="all"?[]:e.map(n=>[`border-${t}-${n}`,r[n]])}function Il(r){r.setNormalizer("margin",Fs("margin")),r.setNormalizer("margin-top",t=>({path:"margin.top",value:t})),r.setNormalizer("margin-right",t=>({path:"margin.right",value:t})),r.setNormalizer("margin-bottom",t=>({path:"margin.bottom",value:t})),r.setNormalizer("margin-left",t=>({path:"margin.left",value:t})),r.setReducer("margin",je("margin")),r.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Fl(r){r.setNormalizer("padding",Fs("padding")),r.setNormalizer("padding-top",t=>({path:"padding.top",value:t})),r.setNormalizer("padding-right",t=>({path:"padding.right",value:t})),r.setNormalizer("padding-bottom",t=>({path:"padding.bottom",value:t})),r.setNormalizer("padding-left",t=>({path:"padding.left",value:t})),r.setReducer("padding",je("padding")),r.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}export{pe as AttributeElement,E as AttributeOperation,jt as BubblingEventInfo,El as ClickObserver,kl as Conversion,Cl as DataController,Gr as DataTransfer,X as DocumentFragment,H as DocumentSelection,rs as DomConverter,Wr as DomEventData,Pe as DomEventObserver,Zn as DowncastWriter,Pl as EditingController,Qr as EditingView,k as Element,Dt as FocusObserver,Wo as History,To as HtmlDataProcessor,M as InsertOperation,I as LivePosition,be as LiveRange,V as MarkerOperation,He as Matcher,S as MergeOperation,Sl as Model,Rl as MouseObserver,P as MoveOperation,T as NoOperation,Ne as Observer,No as OperationFactory,g as Position,f as Range,$ as RenameOperation,Ar as Renderer,te as RootAttributeOperation,Y as RootOperation,ae as SchemaContext,C as SplitOperation,qe as StylesMap,pl as StylesProcessor,Yr as TabObserver,A as Text,G as TextProxy,Tl as TouchObserver,oe as TreeWalker,Ml as UpcastWriter,pe as ViewAttributeElement,Ke as ViewContainerElement,Qn as ViewDocument,_e as ViewDocumentFragment,mt as ViewEditableElement,ne as ViewElement,Gt as ViewEmptyElement,Ht as ViewRawElement,Kn as ViewRootEditableElement,N as ViewText,ge as ViewTreeWalker,gt as ViewUIElement,Xo as _tryFixingModelRange,Nl as addBackgroundRules,Ol as addBorderRules,Il as addMarginRules,Fl as addPaddingRules,vs as autoParagraphEmptyRoots,fl as enablePlaceholder,Ja as getBoxSidesShorthandValue,je as getBoxSidesValueReducer,Je as getBoxSidesValues,ur as getFillerOffset,Fs as getPositionShorthandNormalizer,en as getShorthandValues,Zs as hidePlaceholder,qa as isAttachment,xa as isColor,Fa as isLength,Oa as isLineStyle,Ps as isParagraphable,xl as isPercentage,La as isPosition,Va as isRepeat,Ua as isURL,er as needsPlaceholder,Qs as showPlaceholder,Al as transformSets,Cs as wrapInParagraph};
30
+ */const ya=/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,va=/^rgb\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}[0-9]{1,3}[ %]?\)$/i,Pa=/^rgba\([ ]?([0-9]{1,3}[ %]?,[ ]?){3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Ca=/^hsl\([ ]?([0-9]{1,3}[ %]?[,]?[ ]*){3}(1|[0-9]+%|[0]?\.?[0-9]+)?\)$/i,ka=/^hsla\([ ]?([0-9]{1,3}[ %]?,[ ]?){2,3}(1|[0-9]+%|[0]?\.?[0-9]+)\)$/i,Aa=/\w+\((?:[^()]|\([^()]*\))*\)|\S+/gi,Sa=new Set(["black","silver","gray","white","maroon","red","purple","fuchsia","green","lime","olive","yellow","navy","blue","teal","aqua","orange","aliceblue","antiquewhite","aquamarine","azure","beige","bisque","blanchedalmond","blueviolet","brown","burlywood","cadetblue","chartreuse","chocolate","coral","cornflowerblue","cornsilk","crimson","cyan","darkblue","darkcyan","darkgoldenrod","darkgray","darkgreen","darkgrey","darkkhaki","darkmagenta","darkolivegreen","darkorange","darkorchid","darkred","darksalmon","darkseagreen","darkslateblue","darkslategray","darkslategrey","darkturquoise","darkviolet","deeppink","deepskyblue","dimgray","dimgrey","dodgerblue","firebrick","floralwhite","forestgreen","gainsboro","ghostwhite","gold","goldenrod","greenyellow","grey","honeydew","hotpink","indianred","indigo","ivory","khaki","lavender","lavenderblush","lawngreen","lemonchiffon","lightblue","lightcoral","lightcyan","lightgoldenrodyellow","lightgray","lightgreen","lightgrey","lightpink","lightsalmon","lightseagreen","lightskyblue","lightslategray","lightslategrey","lightsteelblue","lightyellow","limegreen","linen","magenta","mediumaquamarine","mediumblue","mediumorchid","mediumpurple","mediumseagreen","mediumslateblue","mediumspringgreen","mediumturquoise","mediumvioletred","midnightblue","mintcream","mistyrose","moccasin","navajowhite","oldlace","olivedrab","orangered","orchid","palegoldenrod","palegreen","paleturquoise","palevioletred","papayawhip","peachpuff","peru","pink","plum","powderblue","rosybrown","royalblue","saddlebrown","salmon","sandybrown","seagreen","seashell","sienna","skyblue","slateblue","slategray","slategrey","snow","springgreen","steelblue","tan","thistle","tomato","turquoise","violet","wheat","whitesmoke","yellowgreen","activeborder","activecaption","appworkspace","background","buttonface","buttonhighlight","buttonshadow","buttontext","captiontext","graytext","highlight","highlighttext","inactiveborder","inactivecaption","inactivecaptiontext","infobackground","infotext","menu","menutext","scrollbar","threeddarkshadow","threedface","threedhighlight","threedlightshadow","threedshadow","window","windowframe","windowtext","rebeccapurple","currentcolor","transparent"]);function Ea(s){return s.startsWith("#")?ya.test(s):s.startsWith("rgb")?va.test(s)||Pa.test(s):s.startsWith("hsl")?Ca.test(s)||ka.test(s):Sa.has(s.toLowerCase())}const Ra=["none","hidden","dotted","dashed","solid","double","groove","ridge","inset","outset"];function Ta(s){return Ra.includes(s)}const Ma=/^([+-]?[0-9]*([.][0-9]+)?(px|cm|mm|in|pc|pt|ch|em|ex|rem|vh|vw|vmin|vmax)|0)$/;function xa(s){return Ma.test(s)}const Na=/^[+-]?[0-9]*([.][0-9]+)?%$/;function Sl(s){return Na.test(s)}const Oa=["repeat-x","repeat-y","repeat","space","round","no-repeat"];function Ia(s){return Oa.includes(s)}const Fa=["center","top","bottom","left","right"];function Da(s){return Fa.includes(s)}const Ba=["fixed","scroll","local"];function Va(s){return Ba.includes(s)}const $a=/^url\(/;function La(s){return $a.test(s)}function Ue(s=""){if(s==="")return{top:void 0,right:void 0,bottom:void 0,left:void 0};const e=Qt(s),t=e[0],n=e[2]||t,r=e[1]||t,i=e[3]||r;return{top:t,bottom:n,right:r,left:i}}function Je(s){return e=>{const{top:t,right:n,bottom:r,left:i}=e,o=[];return[t,n,i,r].every(a=>!!a)?o.push([s,Wa(e)]):(t&&o.push([s+"-top",t]),n&&o.push([s+"-right",n]),r&&o.push([s+"-bottom",r]),i&&o.push([s+"-left",i])),o}}function Wa({top:s,right:e,bottom:t,left:n}){const r=[];return n!==e?r.push(s,e,t,n):t!==s?r.push(s,e,t):e!==s?r.push(s,e):r.push(s),r.join(" ")}function Os(s){return e=>({path:s,value:Ue(e)})}function Qt(s){const e=s.trim().slice(0,1500).matchAll(Aa);return Array.from(e).map(t=>t[0])}function El(s){s.setNormalizer("background",qa()),s.setNormalizer("background-color",za()),s.setReducer("background",Ua()),s.setStyleRelation("background",["background-color"])}function qa(){return s=>{const e={},t=Qt(s);for(const n of t)Ia(n)?(e.repeat=e.repeat||[],e.repeat.push(n)):Da(n)?(e.position=e.position||[],e.position.push(n)):Va(n)?e.attachment=n:Ea(n)?e.color=n:La(n)&&(e.image=n);return{path:"background",value:e}}}function za(){return s=>({path:"background.color",value:s})}function Ua(){return s=>{const e=[];return e.push(["background-color",s.color]),e}}function Rl(s){s.setNormalizer("border",Ja()),s.setNormalizer("border-top",st("top")),s.setNormalizer("border-right",st("right")),s.setNormalizer("border-bottom",st("bottom")),s.setNormalizer("border-left",st("left")),s.setNormalizer("border-color",Et("color")),s.setNormalizer("border-width",Et("width")),s.setNormalizer("border-style",Et("style")),s.setNormalizer("border-top-color",z("color","top")),s.setNormalizer("border-top-style",z("style","top")),s.setNormalizer("border-top-width",z("width","top")),s.setNormalizer("border-right-color",z("color","right")),s.setNormalizer("border-right-style",z("style","right")),s.setNormalizer("border-right-width",z("width","right")),s.setNormalizer("border-bottom-color",z("color","bottom")),s.setNormalizer("border-bottom-style",z("style","bottom")),s.setNormalizer("border-bottom-width",z("width","bottom")),s.setNormalizer("border-left-color",z("color","left")),s.setNormalizer("border-left-style",z("style","left")),s.setNormalizer("border-left-width",z("width","left")),s.setExtractor("border-top",rt("top")),s.setExtractor("border-right",rt("right")),s.setExtractor("border-bottom",rt("bottom")),s.setExtractor("border-left",rt("left")),s.setExtractor("border-top-color","border.color.top"),s.setExtractor("border-right-color","border.color.right"),s.setExtractor("border-bottom-color","border.color.bottom"),s.setExtractor("border-left-color","border.color.left"),s.setExtractor("border-top-width","border.width.top"),s.setExtractor("border-right-width","border.width.right"),s.setExtractor("border-bottom-width","border.width.bottom"),s.setExtractor("border-left-width","border.width.left"),s.setExtractor("border-top-style","border.style.top"),s.setExtractor("border-right-style","border.style.right"),s.setExtractor("border-bottom-style","border.style.bottom"),s.setExtractor("border-left-style","border.style.left"),s.setReducer("border-color",Je("border-color")),s.setReducer("border-style",Je("border-style")),s.setReducer("border-width",Je("border-width")),s.setReducer("border-top",it("top")),s.setReducer("border-right",it("right")),s.setReducer("border-bottom",it("bottom")),s.setReducer("border-left",it("left")),s.setReducer("border",Ga()),s.setStyleRelation("border",["border-color","border-style","border-width","border-top","border-right","border-bottom","border-left","border-top-color","border-right-color","border-bottom-color","border-left-color","border-top-style","border-right-style","border-bottom-style","border-left-style","border-top-width","border-right-width","border-bottom-width","border-left-width"]),s.setStyleRelation("border-color",["border-top-color","border-right-color","border-bottom-color","border-left-color"]),s.setStyleRelation("border-style",["border-top-style","border-right-style","border-bottom-style","border-left-style"]),s.setStyleRelation("border-width",["border-top-width","border-right-width","border-bottom-width","border-left-width"]),s.setStyleRelation("border-top",["border-top-color","border-top-style","border-top-width"]),s.setStyleRelation("border-right",["border-right-color","border-right-style","border-right-width"]),s.setStyleRelation("border-bottom",["border-bottom-color","border-bottom-style","border-bottom-width"]),s.setStyleRelation("border-left",["border-left-color","border-left-style","border-left-width"])}function Ja(){return s=>{const{color:e,style:t,width:n}=Is(s);return{path:"border",value:{color:Ue(e),style:Ue(t),width:Ue(n)}}}}function st(s){return e=>{const{color:t,style:n,width:r}=Is(e),i={};return t!==void 0&&(i.color={[s]:t}),n!==void 0&&(i.style={[s]:n}),r!==void 0&&(i.width={[s]:r}),{path:"border",value:i}}}function Et(s){return e=>({path:"border",value:ja(e,s)})}function ja(s,e){return{[e]:Ue(s)}}function z(s,e){return t=>({path:"border",value:{[s]:{[e]:t}}})}function rt(s){return(e,t)=>{if(t.border)return $e(t.border,s)}}function $e(s,e){const t={};return s.width&&s.width[e]&&(t.width=s.width[e]),s.style&&s.style[e]&&(t.style=s.style[e]),s.color&&s.color[e]&&(t.color=s.color[e]),t}function Is(s){const e={},t=Qt(s);for(const n of t)xa(n)||/thin|medium|thick/.test(n)?e.width=n:Ta(n)?e.style=n:e.color=n;return e}function Ga(){return e=>{const t=$e(e,"top"),n=$e(e,"right"),r=$e(e,"bottom"),i=$e(e,"left"),o=[t,n,r,i],a={width:s(o,"width"),style:s(o,"style"),color:s(o,"color")},l=Se(a,"all");return l.length?l:[...Object.entries(a).reduce((h,[d,p])=>(p&&(h.push([`border-${d}`,p]),o.forEach(_=>delete _[d])),h),[]),...Se(t,"top"),...Se(n,"right"),...Se(r,"bottom"),...Se(i,"left")]};function s(e,t){return e.map(n=>n[t]).reduce((n,r)=>n==r?n:null)}}function it(s){return e=>Se(e,s)}function Se(s,e){const t=[];if(s&&s.width&&t.push("width"),s&&s.style&&t.push("style"),s&&s.color&&t.push("color"),t.length==3){const n=t.map(r=>s[r]).join(" ");return[e=="all"?["border",n]:[`border-${e}`,n]]}return e=="all"?[]:t.map(n=>[`border-${e}-${n}`,s[n]])}function Tl(s){s.setNormalizer("margin",Os("margin")),s.setNormalizer("margin-top",e=>({path:"margin.top",value:e})),s.setNormalizer("margin-right",e=>({path:"margin.right",value:e})),s.setNormalizer("margin-bottom",e=>({path:"margin.bottom",value:e})),s.setNormalizer("margin-left",e=>({path:"margin.left",value:e})),s.setReducer("margin",Je("margin")),s.setStyleRelation("margin",["margin-top","margin-right","margin-bottom","margin-left"])}function Ml(s){s.setNormalizer("padding",Os("padding")),s.setNormalizer("padding-top",e=>({path:"padding.top",value:e})),s.setNormalizer("padding-right",e=>({path:"padding.right",value:e})),s.setNormalizer("padding-bottom",e=>({path:"padding.bottom",value:e})),s.setNormalizer("padding-left",e=>({path:"padding.left",value:e})),s.setReducer("padding",Je("padding")),s.setStyleRelation("padding",["padding-top","padding-right","padding-bottom","padding-left"])}export{Me as AttributeElement,S as AttributeOperation,Ut as BubblingEventInfo,Pl as ClickObserver,bl as Conversion,wl as DataController,zr as DataTransfer,K as DocumentFragment,G as DocumentSelection,ns as DomConverter,Br as DomEventData,ye as DomEventObserver,Yn as DowncastWriter,_l as EditingController,Hr as EditingView,C as Element,Dt as FocusObserver,Bo as History,Ao as HtmlDataProcessor,T as InsertOperation,O as LivePosition,_e as LiveRange,B as MarkerOperation,je as Matcher,A as MergeOperation,vl as Model,Cl as MouseObserver,v as MoveOperation,R as NoOperation,xe as Observer,Ro as OperationFactory,m as Position,u as Range,V as RenameOperation,vr as Renderer,ee as RootAttributeOperation,X as RootOperation,oe as SchemaContext,P as SplitOperation,We as StylesMap,ul as StylesProcessor,Gr as TabObserver,k as Text,j as TextProxy,kl as TouchObserver,ie as TreeWalker,Al as UpcastWriter,Me as ViewAttributeElement,Ge as ViewContainerElement,Xn as ViewDocument,ge as ViewDocumentFragment,dt as ViewEditableElement,te as ViewElement,Jt as ViewEmptyElement,jt as ViewRawElement,Gn as ViewRootEditableElement,x as ViewText,me as ViewTreeWalker,mt as ViewUIElement,jo as _tryFixingModelRange,El as addBackgroundRules,Rl as addBorderRules,Tl as addMarginRules,Ml as addPaddingRules,bs as autoParagraphEmptyRoots,al as enablePlaceholder,Wa as getBoxSidesShorthandValue,Je as getBoxSidesValueReducer,Ue as getBoxSidesValues,ar as getFillerOffset,Os as getPositionShorthandNormalizer,Qt as getShorthandValues,Ks as hidePlaceholder,Va as isAttachment,Ea as isColor,xa as isLength,Ta as isLineStyle,ys as isParagraphable,Sl as isPercentage,Da as isPosition,Ia as isRepeat,La as isURL,Xs as needsPlaceholder,Hs as showPlaceholder,yl as transformSets,vs as wrapInParagraph};